Documentation
¶
Index ¶
- Constants
- func GenerateDID(privKey p2pcrypto.PrivKey, appName, name string) string
- type ADKConfig
- type ADKRuntime
- type AgentSpec
- type LocalAgent
- type Manager
- func (m *Manager) ConnectToAgent(ctx context.Context, peerID peer.ID) error
- func (m *Manager) DeregisterAgent(ctx context.Context, agentID string) error
- func (m *Manager) DiscoverAgents(ctx context.Context) ([]types.AgentListing, error)
- func (m *Manager) ExecuteTask(ctx context.Context, agentID, input string) (string, error)
- func (m *Manager) FindListingByAgentID(agentID string) (*types.AgentListing, string)
- func (m *Manager) GetAgent(agentID string) (*LocalAgent, error)
- func (m *Manager) ListAgents() []*LocalAgent
- func (m *Manager) RegisterAgent(ctx context.Context, spec AgentSpec) (*LocalAgent, error)
- func (m *Manager) RegisterStreamHandlers(sh *p2p.StreamHandler)
- func (m *Manager) RegisterX402Handlers(sh *p2p.X402StreamHandler)
- func (m *Manager) RemoteExecuteX402(ctx context.Context, peerID peer.ID, agentID, input string) (string, error)
- func (m *Manager) SetCustomHandler(h func(ctx context.Context, agentID, input string) (string, error))
- func (m *Manager) SetTokenStore(ts *eip8004.TokenStore)
- type Runtime
- type SessionStorer
- type Worker
Constants ¶
const ( DefaultTaskTopic = "betar/tasks" DefaultResultTopic = "betar/tasks/results" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ADKConfig ¶
type ADKConfig struct {
AppName string
ModelName string
APIKey string // Google API key
PrivKey p2pcrypto.PrivKey // libp2p private key for DID generation
// Provider fields
Provider string // "google", "openai", or "" for auto-detect
OpenAIAPIKey string // OpenAI-compatible API key
OpenAIBaseURL string // OpenAI-compatible base URL (empty = api.openai.com)
}
ADKConfig configures the runtime bridge.
type ADKRuntime ¶
type ADKRuntime struct {
// contains filtered or unexported fields
}
ADKRuntime is the runtime wrapper used by the manager and worker.
func NewADKRuntime ¶
func NewADKRuntime(cfg ADKConfig) (*ADKRuntime, error)
NewADKRuntime creates a runtime wrapper.
func (*ADKRuntime) CreateAgent ¶
CreateAgent creates a runtime agent and returns runtime agent ID.
func (*ADKRuntime) DeleteAgent ¶
func (r *ADKRuntime) DeleteAgent(ctx context.Context, runtimeAgentID string) error
DeleteAgent removes runtime agent.
func (*ADKRuntime) RunTask ¶
func (r *ADKRuntime) RunTask(ctx context.Context, req types.TaskRequest) (*types.TaskResult, error)
RunTask executes a task via runtime.
type AgentSpec ¶
type AgentSpec struct {
Name string
Description string
Image string
Price float64
Model string
APIKey string // per-agent Google API key; empty = use global default
Services []types.Service
X402Support bool
OnChain bool // if true, register on-chain via EIP-8004 (default: false)
// Provider fields
Provider string // "google", "openai", or "" for auto-detect
OpenAIAPIKey string // OpenAI-compatible API key
OpenAIBaseURL string // OpenAI-compatible base URL
// CustomHandler skips ADK runtime creation. Use this when the agent
// will be served via sdk.Serve() with a custom TaskHandler.
CustomHandler bool
}
AgentSpec represents agent specification for registration
type LocalAgent ¶
type LocalAgent struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Price float64 `json:"price"`
MetadataCID string `json:"metadataCID"`
AgentID string `json:"agentID"` // ADK runtime agent ID
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
TokenID *big.Int `json:"tokenId,omitempty"` // EIP-8004 on-chain token ID
}
LocalAgent represents a local agent managed by this node
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages agent lifecycle
func NewManager ¶
func NewManager(runtimeCfg ADKConfig, ipfsClient *ipfs.Client, p2pHost *p2p.Host, listingService *marketplace.AgentListingService, privKey crypto.PrivKey, paymentSvc *marketplace.PaymentService, walletAddr string, sessionStore SessionStorer, eip8004Client ...*eip8004.Client) (*Manager, error)
NewManager creates a new agent manager
func (*Manager) ConnectToAgent ¶
ConnectToAgent connects to a remote agent via P2P
func (*Manager) DeregisterAgent ¶
DeregisterAgent removes an agent from local registry and runtime.
func (*Manager) DiscoverAgents ¶
DiscoverAgents discovers agents from the marketplace
func (*Manager) ExecuteTask ¶
ExecuteTask executes a task on a local agent or a remote agent from CRDT
func (*Manager) FindListingByAgentID ¶
func (m *Manager) FindListingByAgentID(agentID string) (*types.AgentListing, string)
FindListingByAgentID is the exported version of findListingByAgentID.
func (*Manager) GetAgent ¶
func (m *Manager) GetAgent(agentID string) (*LocalAgent, error)
GetAgent gets a local agent by ID
func (*Manager) ListAgents ¶
func (m *Manager) ListAgents() []*LocalAgent
ListAgents lists all local agents
func (*Manager) RegisterAgent ¶
RegisterAgent registers a new agent locally and publishes to marketplace
func (*Manager) RegisterStreamHandlers ¶
func (m *Manager) RegisterStreamHandlers(sh *p2p.StreamHandler)
RegisterStreamHandlers registers marketplace stream handlers on the basic StreamHandler. Currently registers an "info" handler that returns all known local listings as JSON.
func (*Manager) RegisterX402Handlers ¶
func (m *Manager) RegisterX402Handlers(sh *p2p.X402StreamHandler)
RegisterX402Handlers wires up the x402 stream handler and stores a reference for client use.
func (*Manager) RemoteExecuteX402 ¶
func (m *Manager) RemoteExecuteX402(ctx context.Context, peerID peer.ID, agentID, input string) (string, error)
RemoteExecuteX402 executes a task on a remote agent using the /x402/libp2p/1.0.0 protocol. It performs the standard 2-trip flow: send x402.request → receive x402.payment_required → sign with challenge nonce → send x402.paid_request → receive x402.response.
func (*Manager) SetCustomHandler ¶
func (m *Manager) SetCustomHandler(h func(ctx context.Context, agentID, input string) (string, error))
SetCustomHandler registers a custom task handler that is used instead of the ADK runtime for agents registered with CustomHandler: true.
func (*Manager) SetTokenStore ¶
func (m *Manager) SetTokenStore(ts *eip8004.TokenStore)
SetTokenStore sets the EIP-8004 token store for persisting on-chain tokenIDs.
type Runtime ¶
type Runtime interface {
CreateAgent(ctx context.Context, spec AgentSpec) (string, error)
DeleteAgent(ctx context.Context, runtimeAgentID string) error
RunTask(ctx context.Context, req types.TaskRequest) (*types.TaskResult, error)
}
Runtime defines required agent runtime capabilities.
type SessionStorer ¶
type SessionStorer interface {
AddExchange(ctx context.Context, agentID, callerID string, ex types.Exchange) error
}
SessionStorer is the interface Manager uses to persist session data. Implemented by *session.Store.