Documentation
¶
Index ¶
- func AllTools() []agentcard.Tool
- type APIClient
- func (c *APIClient) BrowseDirectory(ctx context.Context, dreq DirectoryRequest) (*DirectoryResponse, error)
- func (c *APIClient) GetAgentProfile(ctx context.Context, agentID string) (*AgentProfile, error)
- func (c *APIClient) GetReputation(ctx context.Context, agentID string, limit int) (*ReputationResult, error)
- func (c *APIClient) InvokeAgent(ctx context.Context, agentID string, req InvokeInput) (*InvokeOutput, error)
- type AgentAPI
- type AgentProfile
- type BroadcastDestResult
- type BroadcastInput
- type BroadcastOutput
- type CheckReputationInput
- type ContactEntry
- type ContactInput
- type DirectoryRequest
- type DirectoryResponse
- type DiscoverAgentResult
- type DiscoverInput
- type GetProfileInput
- type GetTaskInput
- type Handler
- type InvokeInput
- type InvokeOutput
- type ListContactsOutput
- type ListTasksOutput
- type Options
- type ReputationEvent
- type ReputationResult
- type Result
- type SendMessageInput
- type SendMessageOutput
- type SendRequestInput
- type SendRequestOutput
- type TaskAPI
- type TaskInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient is a thin HTTP client for PeerClaw server directory, invoke, and reputation APIs.
func NewAPIClient ¶
NewAPIClient creates a new API client for the given server base URL.
func (*APIClient) BrowseDirectory ¶
func (c *APIClient) BrowseDirectory(ctx context.Context, dreq DirectoryRequest) (*DirectoryResponse, error)
BrowseDirectory searches the public agent directory with optional filters.
func (*APIClient) GetAgentProfile ¶
GetAgentProfile retrieves the public profile of an agent from the directory.
func (*APIClient) GetReputation ¶
func (c *APIClient) GetReputation(ctx context.Context, agentID string, limit int) (*ReputationResult, error)
GetReputation retrieves reputation events for an agent.
func (*APIClient) InvokeAgent ¶
func (c *APIClient) InvokeAgent(ctx context.Context, agentID string, req InvokeInput) (*InvokeOutput, error)
InvokeAgent sends a message to an agent via the gateway and returns the response.
type AgentAPI ¶
type AgentAPI interface {
ID() string
PublicKey() string
Discover(ctx context.Context, capabilities []string) ([]*discovery.DiscoverResult, error)
Send(ctx context.Context, env *envelope.Envelope) error
SendRequest(ctx context.Context, env *envelope.Envelope, timeout time.Duration) (*envelope.Envelope, error)
Broadcast(ctx context.Context, env *envelope.Envelope, destinations []string) map[string]error
AddContact(agentID string)
RemoveContact(agentID string)
BlockAgent(agentID string)
ListContacts() []security.TrustEntry
}
AgentAPI abstracts the agent methods needed by skill handlers. *agent.Agent satisfies this interface with zero changes.
type AgentProfile ¶
type AgentProfile struct {
ID string `json:"id"`
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"`
Protocols []string `json:"protocols,omitempty"`
Status string `json:"status"`
Tags []string `json:"tags,omitempty"`
Verified bool `json:"verified"`
Trusted bool `json:"trusted"`
ReputationScore float64 `json:"reputation_score"`
ReputationEvents int64 `json:"reputation_events"`
PlaygroundEnabled bool `json:"playground_enabled"`
TotalCalls int64 `json:"total_calls"`
EndpointURL string `json:"endpoint_url,omitempty"`
RegisteredAt time.Time `json:"registered_at"`
Categories []string `json:"categories,omitempty"`
}
AgentProfile is the public profile of an agent from the directory.
type BroadcastDestResult ¶
type BroadcastDestResult struct {
Destination string `json:"destination"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
}
BroadcastDestResult is the result for a single destination in a broadcast.
type BroadcastInput ¶
type BroadcastInput struct {
Destinations []string `json:"destinations"`
Payload string `json:"payload"`
Protocol string `json:"protocol,omitempty"`
}
BroadcastInput is the input for the broadcast_message tool.
type BroadcastOutput ¶
type BroadcastOutput struct {
Results []BroadcastDestResult `json:"results"`
}
BroadcastOutput is the output of broadcast_message.
type CheckReputationInput ¶
type CheckReputationInput struct {
AgentID string `json:"agent_id"`
Limit int `json:"limit,omitempty"`
}
CheckReputationInput is the input for the check_reputation tool.
type ContactEntry ¶
type ContactEntry struct {
PublicKey string `json:"public_key"`
Level int `json:"level"`
LevelName string `json:"level_name"`
FirstSeen string `json:"first_seen"`
LastSeen string `json:"last_seen,omitempty"`
Alias string `json:"alias,omitempty"`
}
ContactEntry is a single contact in the trust store.
type ContactInput ¶
type ContactInput struct {
AgentID string `json:"agent_id"`
}
ContactInput is the input for add_contact and remove_contact tools.
type DirectoryRequest ¶
type DirectoryRequest struct {
Capability string `json:"capability,omitempty"`
Search string `json:"search,omitempty"`
PageSize int `json:"page_size,omitempty"`
}
DirectoryRequest holds query parameters for browsing the agent directory.
type DirectoryResponse ¶
type DirectoryResponse struct {
Agents []AgentProfile `json:"agents"`
TotalCount int `json:"total_count"`
}
DirectoryResponse is the response from the directory browse API.
type DiscoverAgentResult ¶
type DiscoverAgentResult struct {
ID string `json:"id"`
Name string `json:"name"`
PublicKey string `json:"public_key"`
}
DiscoverAgentResult is a single agent returned by discover_agents.
type DiscoverInput ¶
type DiscoverInput struct {
Capabilities []string `json:"capabilities"`
}
DiscoverInput is the input for the discover_agents tool.
type GetProfileInput ¶
type GetProfileInput struct {
AgentID string `json:"agent_id"`
}
GetProfileInput is the input for the get_agent_profile tool.
type GetTaskInput ¶
type GetTaskInput struct {
TraceID string `json:"trace_id"`
}
GetTaskInput is the input for the get_task tool.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler dispatches LLM tool calls to PeerClaw agent operations.
func NewHandler ¶
NewHandler creates a Handler with the given options.
func (*Handler) AvailableTools ¶
AvailableTools returns all tools that are not disabled.
func (*Handler) Handle ¶
func (h *Handler) Handle(ctx context.Context, toolName string, input json.RawMessage) (json.RawMessage, error)
Handle dispatches a tool call by name and returns a JSON-encoded Result. Tool execution errors are wrapped in Result{Success: false}; the returned error is only non-nil if JSON marshaling itself fails.
type InvokeInput ¶
type InvokeInput struct {
AgentID string `json:"agent_id"`
Message string `json:"message"`
Protocol string `json:"protocol,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
SessionID string `json:"session_id,omitempty"`
}
InvokeInput is the input for the invoke_agent tool.
type InvokeOutput ¶
type InvokeOutput struct {
ID string `json:"id"`
AgentID string `json:"agent_id"`
Response string `json:"response"`
Protocol string `json:"protocol"`
DurationMs int64 `json:"duration_ms"`
SessionID string `json:"session_id,omitempty"`
}
InvokeOutput is the response from invoke_agent.
type ListContactsOutput ¶
type ListContactsOutput struct {
Contacts []ContactEntry `json:"contacts"`
}
ListContactsOutput is the output of list_contacts.
type ListTasksOutput ¶
type ListTasksOutput struct {
Tasks []TaskInfo `json:"tasks"`
}
ListTasksOutput is the output of list_tasks.
type Options ¶
type Options struct {
// Agent is the local agent instance (required for P2P tools).
Agent AgentAPI
// TaskAPI provides optional task tracking capabilities.
TaskAPI TaskAPI
// APIClient is used for server-dependent tools (invoke, profile, reputation).
// If nil, those tools will return errors when called.
APIClient *APIClient
// Disabled lists tool names to exclude from AvailableTools and reject in Handle.
Disabled []string
}
Options configures a skill Handler.
type ReputationEvent ¶
type ReputationEvent struct {
ID int64 `json:"id"`
AgentID string `json:"agent_id"`
EventType string `json:"event_type"`
Weight float64 `json:"weight"`
ScoreAfter float64 `json:"score_after"`
Metadata string `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
ReputationEvent is a single reputation event.
type ReputationResult ¶
type ReputationResult struct {
Events []ReputationEvent `json:"events"`
}
ReputationResult contains reputation events for an agent.
type Result ¶
type Result struct {
Success bool `json:"success"`
Data json.RawMessage `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
Result wraps every tool response in a uniform JSON structure.
type SendMessageInput ¶
type SendMessageInput struct {
Destination string `json:"destination"`
Payload string `json:"payload"`
Protocol string `json:"protocol,omitempty"`
MessageType string `json:"message_type,omitempty"`
}
SendMessageInput is the input for the send_message tool.
type SendMessageOutput ¶
type SendMessageOutput struct {
MessageID string `json:"message_id"`
}
SendMessageOutput is the output of send_message.
type SendRequestInput ¶
type SendRequestInput struct {
Destination string `json:"destination"`
Payload string `json:"payload"`
Protocol string `json:"protocol,omitempty"`
TimeoutSecs int `json:"timeout_secs,omitempty"`
}
SendRequestInput is the input for the send_request tool.
type SendRequestOutput ¶
type SendRequestOutput struct {
ResponsePayload string `json:"response_payload"`
Source string `json:"source"`
TraceID string `json:"trace_id"`
}
SendRequestOutput is the output of send_request.