Documentation
¶
Index ¶
- Variables
- func ResetRegistry()
- func SendStream(ctx context.Context, endpoint string, msg *A2AMessage, authToken string) (<-chan A2AStreamMessage, error)
- type A2AClient
- type A2AClientOption
- type A2AHandler
- type A2AMessage
- type A2AMessageType
- type A2ARouter
- type A2AServer
- type A2AServerOption
- type A2AStreamMessage
- type A2ATaskRequest
- type A2ATaskResponse
- type AgentCard
- type AgentRegistry
- func (r *AgentRegistry) Count() int
- func (r *AgentRegistry) FindByCapability(capability string) []*AgentCard
- func (r *AgentRegistry) ListAll() []*AgentCard
- func (r *AgentRegistry) Lookup(id string) (*AgentCard, error)
- func (r *AgentRegistry) Register(card *AgentCard) error
- func (r *AgentRegistry) Unregister(id string)
- type DelegationFuture
- type StreamHandler
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCircuitOpen is returned when the circuit breaker is open. ErrCircuitOpen = fmt.Errorf("circuit breaker open") // ErrPayloadTooLarge is returned when the request payload exceeds the limit. ErrPayloadTooLarge = fmt.Errorf("payload too large") )
var DefaultAwaitTimeout = 60 * time.Second
DefaultAwaitTimeout is the default timeout for DelegationFuture.Await.
Functions ¶
func ResetRegistry ¶
func ResetRegistry()
ResetRegistry clears all entries from the global registry. Used in tests.
func SendStream ¶
func SendStream(ctx context.Context, endpoint string, msg *A2AMessage, authToken string) (<-chan A2AStreamMessage, error)
SendStream sends a message via WebSocket and returns a channel of stream messages.
Types ¶
type A2AClient ¶
type A2AClient struct {
// contains filtered or unexported fields
}
A2AClient sends A2A messages to remote agents over HTTP.
func NewA2AClient ¶
func NewA2AClient(opts ...A2AClientOption) *A2AClient
NewA2AClient creates a new A2AClient with sensible defaults.
func (*A2AClient) GetStatus ¶
func (c *A2AClient) GetStatus(ctx context.Context, endpoint, fromID, toID string) (*A2AMessage, error)
@sk-task a2a#polish: GetStatus sends a health check request to a remote agent.
func (*A2AClient) ResetCircuit ¶
ResetCircuit resets the circuit breaker for a given endpoint.
func (*A2AClient) Send ¶
func (c *A2AClient) Send(ctx context.Context, endpoint string, msg *A2AMessage) (*A2AMessage, error)
Send sends an A2A message to the given endpoint and returns the response.
type A2AClientOption ¶
type A2AClientOption func(*A2AClient)
A2AClientOption configures an A2AClient.
func WithClientAuthToken ¶
func WithClientAuthToken(token string) A2AClientOption
WithClientAuthToken sets the bearer token for A2A requests.
func WithClientTimeout ¶
func WithClientTimeout(timeout time.Duration) A2AClientOption
WithClientTimeout sets the HTTP client timeout.
func WithMaxRetries ¶
func WithMaxRetries(n int) A2AClientOption
WithMaxRetries sets the maximum number of retry attempts.
type A2AHandler ¶
type A2AHandler func(ctx context.Context, msg *A2AMessage) (*A2AMessage, error)
A2AHandler is a function that processes an A2AMessage and returns a response.
type A2AMessage ¶
type A2AMessage struct {
ID string `json:"id"`
From string `json:"from"`
To string `json:"to"`
Type A2AMessageType `json:"type"`
Action string `json:"action"`
Payload map[string]interface{} `json:"payload,omitempty"`
CorrelationID string `json:"correlation_id,omitempty"`
TraceID string `json:"trace_id,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
}
A2AMessage is the universal envelope for all A2A communication between agents.
type A2AMessageType ¶
type A2AMessageType string
A2AMessageType represents the type of an A2A message.
const ( A2AMessageTypeRequest A2AMessageType = "request" A2AMessageTypeResponse A2AMessageType = "response" A2AMessageTypeEvent A2AMessageType = "event" A2AMessageTypeError A2AMessageType = "error" A2AMessageTypeStream A2AMessageType = "stream" )
A2A message type constants for the A2A protocol envelope.
type A2ARouter ¶
type A2ARouter struct {
// contains filtered or unexported fields
}
A2ARouter routes incoming A2A messages by action name.
func (*A2ARouter) Handle ¶
func (r *A2ARouter) Handle(action string, handler A2AHandler)
Handle registers a handler for the given action.
func (*A2ARouter) Route ¶
func (r *A2ARouter) Route(ctx context.Context, msg *A2AMessage) (*A2AMessage, error)
Route dispatches a message to the appropriate handler based on its action.
func (*A2ARouter) SetFallback ¶
func (r *A2ARouter) SetFallback(handler A2AHandler)
SetFallback sets the fallback handler for unknown actions.
type A2AServer ¶
type A2AServer struct {
// contains filtered or unexported fields
}
A2AServer is an HTTP server that accepts A2A messages.
func NewA2AServer ¶
func NewA2AServer(router *A2ARouter, addr string, opts ...A2AServerOption) *A2AServer
NewA2AServer creates a new A2AServer with the given router and options.
func (*A2AServer) HandleWS ¶
func (s *A2AServer) HandleWS(handler StreamHandler)
HandleWS registers a WebSocket handler at /ws on the server.
type A2AServerOption ¶
type A2AServerOption func(*A2AServer)
A2AServerOption configures an A2AServer.
func WithAuthToken ¶
func WithAuthToken(token string) A2AServerOption
WithAuthToken sets the bearer token required for A2A requests.
type A2AStreamMessage ¶
type A2AStreamMessage struct {
Type string `json:"type"`
Content string `json:"content,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
Done bool `json:"done,omitempty"`
Error string `json:"error,omitempty"`
}
A2AStreamMessage represents a streaming token or final response over WS.
type A2ATaskRequest ¶
type A2ATaskRequest struct {
Description string `json:"description"`
ExpectedOutput string `json:"expected_output,omitempty"`
Context string `json:"context,omitempty"`
Priority int `json:"priority,omitempty"`
Deadline time.Time `json:"deadline,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
A2ATaskRequest is the typed payload for delegating a task to an agent.
type A2ATaskResponse ¶
type A2ATaskResponse struct {
Result string `json:"result,omitempty"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
}
A2ATaskResponse is the typed payload with the task execution result.
type AgentCard ¶
type AgentCard struct {
ID string `json:"id"`
Name string `json:"name"`
Role string `json:"role"`
Description string `json:"description,omitempty"`
Capabilities []string `json:"capabilities"`
Endpoint string `json:"endpoint"`
Version string `json:"version,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
AgentCard is the public agent identity for discovery via the registry.
type AgentRegistry ¶
type AgentRegistry struct {
// contains filtered or unexported fields
}
AgentRegistry provides in-memory agent discovery by ID or capability.
func GlobalA2ARegistry ¶
func GlobalA2ARegistry() *AgentRegistry
GlobalA2ARegistry returns the package-level singleton registry.
func (*AgentRegistry) Count ¶
func (r *AgentRegistry) Count() int
Count returns the number of registered agents.
func (*AgentRegistry) FindByCapability ¶
func (r *AgentRegistry) FindByCapability(capability string) []*AgentCard
FindByCapability returns all agent cards that have the given capability.
func (*AgentRegistry) ListAll ¶
func (r *AgentRegistry) ListAll() []*AgentCard
ListAll returns all registered agent cards.
func (*AgentRegistry) Lookup ¶
func (r *AgentRegistry) Lookup(id string) (*AgentCard, error)
Lookup returns an agent card by ID, or an error if not found.
func (*AgentRegistry) Register ¶
func (r *AgentRegistry) Register(card *AgentCard) error
Register adds an agent card to the registry. Returns an error if the ID already exists.
func (*AgentRegistry) Unregister ¶
func (r *AgentRegistry) Unregister(id string)
Unregister removes an agent card from the registry by ID.
type DelegationFuture ¶
DelegationFuture represents an async delegation result.
type StreamHandler ¶
type StreamHandler func(ctx context.Context, msg *A2AMessage) (<-chan A2AStreamMessage, error)
StreamHandler is a function that processes an A2AMessage and returns a channel of stream messages.