Documentation
¶
Index ¶
- type ClaimRegisterer
- type ClaimRequest
- type CompositeDiscovery
- func (cd *CompositeDiscovery) Close() error
- func (cd *CompositeDiscovery) Deregister(ctx context.Context, agentID string) error
- func (cd *CompositeDiscovery) Discover(ctx context.Context, req DiscoverRequest) ([]*agentcard.Card, error)
- func (cd *CompositeDiscovery) Heartbeat(ctx context.Context, agentID, status string) (*HeartbeatResponse, error)
- func (cd *CompositeDiscovery) Register(ctx context.Context, req RegisterRequest) (*agentcard.Card, error)
- type DHTDiscovery
- func (dd *DHTDiscovery) Close() error
- func (dd *DHTDiscovery) Deregister(ctx context.Context, agentID string) error
- func (dd *DHTDiscovery) Discover(ctx context.Context, req DiscoverRequest) ([]*agentcard.Card, error)
- func (dd *DHTDiscovery) Heartbeat(ctx context.Context, agentID, status string) (*HeartbeatResponse, error)
- func (dd *DHTDiscovery) Register(ctx context.Context, req RegisterRequest) (*agentcard.Card, error)
- type DiscoverRequest
- type DiscoverResult
- type Discovery
- type EndpointReq
- type HeartbeatResponse
- type RegisterRequest
- type RegistryClient
- func (c *RegistryClient) ClaimRegister(ctx context.Context, req ClaimRequest) (*agentcard.Card, error)
- func (c *RegistryClient) Close() error
- func (c *RegistryClient) Deregister(ctx context.Context, agentID string) error
- func (c *RegistryClient) Discover(ctx context.Context, req DiscoverRequest) ([]*agentcard.Card, error)
- func (c *RegistryClient) Heartbeat(ctx context.Context, agentID string, status string) (*HeartbeatResponse, error)
- func (c *RegistryClient) Register(ctx context.Context, req RegisterRequest) (*agentcard.Card, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClaimRegisterer ¶
type ClaimRegisterer interface {
ClaimRegister(ctx context.Context, req ClaimRequest) (*agentcard.Card, error)
}
ClaimRegisterer is an optional interface for discovery backends that support claim-token-based registration.
type ClaimRequest ¶
type ClaimRequest struct {
Token string `json:"token"`
Name string `json:"name"`
PublicKey string `json:"public_key"`
Capabilities []string `json:"capabilities,omitempty"`
Protocols []string `json:"protocols"`
Endpoint EndpointReq `json:"endpoint"`
Signature string `json:"signature"`
Metadata map[string]string `json:"metadata,omitempty"`
}
ClaimRequest holds the parameters for claim-token-based agent registration.
type CompositeDiscovery ¶
type CompositeDiscovery struct {
// contains filtered or unexported fields
}
CompositeDiscovery combines a primary (server) and secondary (DHT) discovery. It tries the primary first, and falls back to secondary if primary fails or returns no results.
func NewCompositeDiscovery ¶
func NewCompositeDiscovery(primary, secondary Discovery, logger *slog.Logger) *CompositeDiscovery
NewCompositeDiscovery creates a new composite discovery.
func (*CompositeDiscovery) Close ¶
func (cd *CompositeDiscovery) Close() error
Close closes both discovery implementations.
func (*CompositeDiscovery) Deregister ¶
func (cd *CompositeDiscovery) Deregister(ctx context.Context, agentID string) error
Deregister deregisters from both primary and secondary.
func (*CompositeDiscovery) Discover ¶
func (cd *CompositeDiscovery) Discover(ctx context.Context, req DiscoverRequest) ([]*agentcard.Card, error)
Discover queries the primary first; if it fails or returns no results, queries the secondary. Results are merged and deduplicated.
func (*CompositeDiscovery) Heartbeat ¶
func (cd *CompositeDiscovery) Heartbeat(ctx context.Context, agentID, status string) (*HeartbeatResponse, error)
Heartbeat sends heartbeat to the primary; also refreshes secondary.
func (*CompositeDiscovery) Register ¶
func (cd *CompositeDiscovery) Register(ctx context.Context, req RegisterRequest) (*agentcard.Card, error)
Register registers with the primary; also registers with secondary for redundancy.
type DHTDiscovery ¶
type DHTDiscovery struct {
// contains filtered or unexported fields
}
DHTDiscovery implements the Discovery interface using a distributed hash table.
func NewDHTDiscovery ¶
func NewDHTDiscovery(d *dht.DHT) *DHTDiscovery
NewDHTDiscovery creates a new DHT-backed discovery implementation.
func (*DHTDiscovery) Close ¶
func (dd *DHTDiscovery) Close() error
Close is a no-op for DHTDiscovery (the DHT is managed externally).
func (*DHTDiscovery) Deregister ¶
func (dd *DHTDiscovery) Deregister(ctx context.Context, agentID string) error
Deregister removes an agent from the DHT.
func (*DHTDiscovery) Discover ¶
func (dd *DHTDiscovery) Discover(ctx context.Context, req DiscoverRequest) ([]*agentcard.Card, error)
Discover finds agents by capabilities in the DHT.
func (*DHTDiscovery) Heartbeat ¶
func (dd *DHTDiscovery) Heartbeat(ctx context.Context, agentID, status string) (*HeartbeatResponse, error)
Heartbeat re-publishes the card to refresh TTL.
func (*DHTDiscovery) Register ¶
func (dd *DHTDiscovery) Register(ctx context.Context, req RegisterRequest) (*agentcard.Card, error)
Register stores an agent card in the DHT. Primary key: SHA1(pubkey) -> card JSON Secondary keys: SHA1("cap:"+capability) -> list of pubkeys
type DiscoverRequest ¶
type DiscoverRequest struct {
Capabilities []string `json:"capabilities"`
Protocol string `json:"protocol,omitempty"`
MaxResults int `json:"max_results,omitempty"`
}
DiscoverRequest holds the parameters for agent discovery.
type DiscoverResult ¶
DiscoverResult is a simplified view of a discovered agent.
type Discovery ¶
type Discovery interface {
Register(ctx context.Context, req RegisterRequest) (*agentcard.Card, error)
Deregister(ctx context.Context, agentID string) error
Heartbeat(ctx context.Context, agentID, status string) (*HeartbeatResponse, error)
Discover(ctx context.Context, req DiscoverRequest) ([]*agentcard.Card, error)
Close() error
}
Discovery abstracts agent registration and discovery. Implementations include RegistryClient (centralized server), DHTDiscovery (decentralized), and CompositeDiscovery (hybrid).
type EndpointReq ¶
type EndpointReq struct {
URL string `json:"url"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
Transport string `json:"transport,omitempty"`
}
EndpointReq holds endpoint details for registration.
type HeartbeatResponse ¶
HeartbeatResponse holds the response from a heartbeat request.
type RegisterRequest ¶
type RegisterRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Version string `json:"version,omitempty"`
PublicKey string `json:"public_key,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
Endpoint EndpointReq `json:"endpoint"`
Protocols []string `json:"protocols"`
Metadata map[string]string `json:"metadata,omitempty"`
}
RegisterRequest holds the parameters for agent registration.
type RegistryClient ¶
type RegistryClient struct {
// contains filtered or unexported fields
}
RegistryClient provides methods for interacting with the peerclaw-server registry API (register, deregister, heartbeat, discover).
func NewRegistryClient ¶
func NewRegistryClient(baseURL string, logger *slog.Logger) *RegistryClient
NewRegistryClient creates a new registry client.
func (*RegistryClient) ClaimRegister ¶
func (c *RegistryClient) ClaimRegister(ctx context.Context, req ClaimRequest) (*agentcard.Card, error)
ClaimRegister registers the agent using a claim token. The token itself serves as authentication — no API key or bearer token is needed.
func (*RegistryClient) Close ¶
func (c *RegistryClient) Close() error
Close is a no-op for RegistryClient (satisfies the Discovery interface).
func (*RegistryClient) Deregister ¶
func (c *RegistryClient) Deregister(ctx context.Context, agentID string) error
Deregister removes the agent from the platform.
func (*RegistryClient) Discover ¶
func (c *RegistryClient) Discover(ctx context.Context, req DiscoverRequest) ([]*agentcard.Card, error)
Discover finds agents by capabilities on the platform.
func (*RegistryClient) Heartbeat ¶
func (c *RegistryClient) Heartbeat(ctx context.Context, agentID string, status string) (*HeartbeatResponse, error)
Heartbeat sends a heartbeat to the platform.
func (*RegistryClient) Register ¶
func (c *RegistryClient) Register(ctx context.Context, req RegisterRequest) (*agentcard.Card, error)
Register registers the agent with the platform.