Documentation
¶
Index ¶
- Constants
- type A2AAgentStatus
- type AgentCapabilities
- type AgentCard
- type Artifact
- type CancelTaskParams
- type Client
- func (c *Client) AgentCard() *AgentCard
- func (c *Client) CancelTask(ctx context.Context, taskID string) (*Task, error)
- func (c *Client) Endpoint() string
- func (c *Client) FetchAgentCard(ctx context.Context) (*AgentCard, error)
- func (c *Client) GetTask(ctx context.Context, taskID string, historyLength int) (*Task, error)
- func (c *Client) IsAvailable() bool
- func (c *Client) ListTasks(ctx context.Context, params ListTasksParams) (*ListTasksResult, error)
- func (c *Client) Name() string
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) SendMessage(ctx context.Context, params SendMessageParams) (*SendMessageResult, error)
- func (c *Client) SetAuth(authType, token, headerName string)
- type Error
- type FilePart
- type Gateway
- func (g *Gateway) AggregatedSkills() []Skill
- func (g *Gateway) GetRemoteAgent(name string) *Client
- func (g *Gateway) GetTask(ctx context.Context, taskID string) (*Task, error)
- func (g *Gateway) Handler() *Handler
- func (g *Gateway) ListRemoteAgents() []*Client
- func (g *Gateway) RegisterLocalAgent(name string, card AgentCard, handler TaskHandler)
- func (g *Gateway) RegisterRemoteAgent(ctx context.Context, name, endpoint string, ...) error
- func (g *Gateway) SendMessage(ctx context.Context, targetAgent string, params SendMessageParams) (*SendMessageResult, error)
- func (g *Gateway) Status() []A2AAgentStatus
- func (g *Gateway) UnregisterLocalAgent(name string)
- func (g *Gateway) UnregisterRemoteAgent(name string)
- type GetTaskParams
- type Handler
- type ListTasksParams
- type ListTasksResult
- type LocalAgent
- type Message
- type MessageRole
- type Part
- type PartType
- type Provider
- type Request
- type Response
- type SendMessageParams
- type SendMessageResult
- type Skill
- type Task
- type TaskHandler
- type TaskState
- type TaskStatus
Constants ¶
const ( MethodSendMessage = "message/send" MethodGetTask = "tasks/get" MethodListTasks = "tasks/list" MethodCancelTask = "tasks/cancel" )
A2A JSON-RPC method names.
const ( ParseError = -32700 InvalidRequest = -32600 MethodNotFound = -32601 InvalidParams = -32602 InternalError = -32603 )
Standard JSON-RPC error codes.
const ( ErrTaskNotFound = -32001 ErrTaskNotCancellable = -32002 ErrUnsupportedOperation = -32003 )
A2A-specific error codes.
const ProtocolVersion = "1.0"
ProtocolVersion is the A2A protocol version supported by this implementation.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type A2AAgentStatus ¶
type A2AAgentStatus struct {
Name string `json:"name"`
Role string `json:"role"` // "local" or "remote"
URL string `json:"url,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
Available bool `json:"available"`
SkillCount int `json:"skillCount"`
Skills []string `json:"skills"`
Description string `json:"description,omitempty"`
}
A2AAgentStatus contains status information for an A2A agent.
type AgentCapabilities ¶
type AgentCapabilities struct {
}
AgentCapabilities describes what the agent supports. Note: Currently empty as streaming, push notifications, and state transition history are not implemented. This struct is retained for A2A protocol compatibility.
type AgentCard ¶
type AgentCard struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
URL string `json:"url"`
Version string `json:"version,omitempty"`
Provider *Provider `json:"provider,omitempty"`
DocumentationURL string `json:"documentationUrl,omitempty"`
Capabilities AgentCapabilities `json:"capabilities"`
Skills []Skill `json:"skills"`
DefaultInputModes []string `json:"defaultInputModes,omitempty"`
DefaultOutputModes []string `json:"defaultOutputModes,omitempty"`
}
AgentCard represents the A2A Agent Card for discovery. Served at /.well-known/agent.json
type Artifact ¶
type Artifact struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Parts []Part `json:"parts"`
Index int `json:"index,omitempty"`
}
Artifact represents task output artifacts.
type CancelTaskParams ¶
type CancelTaskParams struct {
ID string `json:"id"`
}
CancelTaskParams contains parameters for tasks/cancel request.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with a remote A2A agent.
func (*Client) CancelTask ¶
CancelTask cancels a running task.
func (*Client) FetchAgentCard ¶
FetchAgentCard retrieves the agent card from /.well-known/agent.json
func (*Client) IsAvailable ¶
IsAvailable returns true if the agent is reachable.
func (*Client) ListTasks ¶
func (c *Client) ListTasks(ctx context.Context, params ListTasksParams) (*ListTasksResult, error)
ListTasks lists tasks matching the criteria.
func (*Client) SendMessage ¶
func (c *Client) SendMessage(ctx context.Context, params SendMessageParams) (*SendMessageResult, error)
SendMessage sends a message to the remote agent.
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
Error represents a JSON-RPC 2.0 error.
type FilePart ¶
type FilePart struct {
Name string `json:"name,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Bytes string `json:"bytes,omitempty"` // base64 encoded
URI string `json:"uri,omitempty"`
}
FilePart represents file content in a message.
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway manages A2A agents - both local (server role) and remote (client role).
func (*Gateway) AggregatedSkills ¶
AggregatedSkills returns all skills from all agents (local and remote).
func (*Gateway) GetRemoteAgent ¶
GetRemoteAgent returns a remote agent client by name.
func (*Gateway) ListRemoteAgents ¶
ListRemoteAgents returns all registered remote agents.
func (*Gateway) RegisterLocalAgent ¶
func (g *Gateway) RegisterLocalAgent(name string, card AgentCard, handler TaskHandler)
RegisterLocalAgent registers an agent that this gateway serves (server role).
func (*Gateway) RegisterRemoteAgent ¶
func (g *Gateway) RegisterRemoteAgent(ctx context.Context, name, endpoint string, authType, authToken, authHeader string) error
RegisterRemoteAgent registers an external A2A agent (client role).
func (*Gateway) SendMessage ¶
func (g *Gateway) SendMessage(ctx context.Context, targetAgent string, params SendMessageParams) (*SendMessageResult, error)
SendMessage routes a message to the appropriate agent.
func (*Gateway) Status ¶
func (g *Gateway) Status() []A2AAgentStatus
Status returns status of all A2A agents.
func (*Gateway) UnregisterLocalAgent ¶
UnregisterLocalAgent removes a local agent.
func (*Gateway) UnregisterRemoteAgent ¶
UnregisterRemoteAgent removes a remote agent.
type GetTaskParams ¶
type GetTaskParams struct {
ID string `json:"id"`
HistoryLength int `json:"historyLength,omitempty"`
}
GetTaskParams contains parameters for tasks/get request.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler provides HTTP handlers for A2A protocol endpoints.
func NewHandler ¶
NewHandler creates a new A2A HTTP handler.
func (*Handler) GetLocalAgent ¶
func (h *Handler) GetLocalAgent(name string) *LocalAgent
GetLocalAgent returns a local agent by name.
func (*Handler) ListLocalAgents ¶
ListLocalAgents returns all registered local agents.
func (*Handler) RegisterLocalAgent ¶
func (h *Handler) RegisterLocalAgent(name string, agent *LocalAgent)
RegisterLocalAgent registers an agent that this gateway serves.
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP routes A2A HTTP requests.
func (*Handler) UnregisterLocalAgent ¶
UnregisterLocalAgent removes a local agent.
type ListTasksParams ¶
type ListTasksParams struct {
ContextID string `json:"contextId,omitempty"`
Status TaskState `json:"status,omitempty"`
PageSize int `json:"pageSize,omitempty"`
PageToken string `json:"pageToken,omitempty"`
}
ListTasksParams contains parameters for tasks/list request.
type ListTasksResult ¶
type ListTasksResult struct {
Tasks []Task `json:"tasks"`
NextPageToken string `json:"nextPageToken,omitempty"`
}
ListTasksResult is the response to tasks/list.
type LocalAgent ¶
type LocalAgent struct {
Card AgentCard
Handler TaskHandler
}
LocalAgent represents an A2A agent served by this gateway.
type Message ¶
type Message struct {
ID string `json:"messageId"`
Role MessageRole `json:"role"`
Parts []Part `json:"parts"`
Metadata map[string]string `json:"metadata,omitempty"`
}
Message represents a conversational message in A2A.
func NewTextMessage ¶
func NewTextMessage(role MessageRole, text string) Message
NewTextMessage creates a message with a single text part.
type MessageRole ¶
type MessageRole string
MessageRole indicates the sender of a message.
const ( RoleUser MessageRole = "user" RoleAgent MessageRole = "agent" )
type Part ¶
type Part struct {
Type PartType `json:"type"`
Text string `json:"text,omitempty"`
File *FilePart `json:"file,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
Part represents a content part in a message.
type Provider ¶
type Provider struct {
Organization string `json:"organization"`
URL string `json:"url,omitempty"`
}
Provider describes the organization providing the agent.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID *json.RawMessage `json:"id,omitempty"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
Request represents a JSON-RPC 2.0 request.
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
ID *json.RawMessage `json:"id,omitempty"`
Result any `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
Response represents a JSON-RPC 2.0 response.
func NewErrorResponse ¶
func NewErrorResponse(id *json.RawMessage, code int, message string) Response
NewErrorResponse creates a JSON-RPC error response.
func NewSuccessResponse ¶
func NewSuccessResponse(id *json.RawMessage, result any) Response
NewSuccessResponse creates a JSON-RPC success response.
type SendMessageParams ¶
type SendMessageParams struct {
Message Message `json:"message"`
ContextID string `json:"contextId,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
SendMessageParams contains parameters for message/send request.
type SendMessageResult ¶
type SendMessageResult struct {
Task *Task `json:"task,omitempty"`
Message *Message `json:"message,omitempty"`
}
SendMessageResult is the response to message/send.
type Skill ¶
type Skill struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Examples []string `json:"examples,omitempty"`
}
Skill represents a distinct capability the agent exposes.
type Task ¶
type Task struct {
ID string `json:"id"`
ContextID string `json:"contextId,omitempty"`
Status TaskStatus `json:"status"`
Messages []Message `json:"messages,omitempty"`
Artifacts []Artifact `json:"artifacts,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Task represents an A2A task.
type TaskHandler ¶
TaskHandler is a function that processes A2A messages for a local agent.
type TaskState ¶
type TaskState string
TaskState represents the current state of a task.
const ( TaskStateSubmitted TaskState = "submitted" TaskStateWorking TaskState = "working" TaskStateInputRequired TaskState = "input_required" TaskStateCompleted TaskState = "completed" TaskStateFailed TaskState = "failed" TaskStateCancelled TaskState = "cancelled" TaskStateRejected TaskState = "rejected" )
func (TaskState) IsTerminal ¶
IsTerminal returns true if the state is a terminal state.
type TaskStatus ¶
TaskStatus represents the status of a task.