a2a

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package a2a implements the Agent-to-Agent (A2A) protocol for cross-framework agent communication. It provides both server and client implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentCard

type AgentCard struct {
	Name         string   `json:"name"`
	Description  string   `json:"description"`
	Version      string   `json:"version"`
	Capabilities []string `json:"capabilities"`
	InputSchema  any      `json:"input_schema,omitempty"`
	OutputSchema any      `json:"output_schema,omitempty"`
}

AgentCard describes an A2A agent's capabilities.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client connects to an external A2A agent.

func NewClient

func NewClient(baseURL string) *Client

NewClient creates an A2A client for connecting to an external agent.

func (*Client) CreateTask

func (c *Client) CreateTask(ctx context.Context, input string, metadata map[string]any) (*Task, error)

CreateTask submits a task to the remote agent.

func (*Client) GetAgentCard

func (c *Client) GetAgentCard(ctx context.Context) (*AgentCard, error)

GetAgentCard retrieves the agent's capability card.

func (*Client) GetTask

func (c *Client) GetTask(ctx context.Context, taskID string) (*Task, error)

GetTask polls the status of a task.

func (*Client) WaitForCompletion

func (c *Client) WaitForCompletion(ctx context.Context, taskID string, pollInterval time.Duration) (*Task, error)

WaitForCompletion polls a task until it reaches a terminal state.

type Handler

type Handler func(ctx context.Context, task *Task) error

Handler processes A2A tasks.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server exposes an agent as an A2A endpoint.

func NewServer

func NewServer(card AgentCard, handler Handler) *Server

NewServer creates an A2A server for the given agent.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles A2A protocol requests.

type Task

type Task struct {
	ID        string         `json:"id"`
	Status    TaskStatus     `json:"status"`
	Input     string         `json:"input"`
	Output    string         `json:"output,omitempty"`
	Error     string         `json:"error,omitempty"`
	Metadata  map[string]any `json:"metadata,omitempty"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
}

Task represents an A2A task.

type TaskStatus

type TaskStatus string

TaskStatus represents the status of an A2A task.

const (
	TaskStatusPending   TaskStatus = "pending"
	TaskStatusRunning   TaskStatus = "running"
	TaskStatusCompleted TaskStatus = "completed"
	TaskStatusFailed    TaskStatus = "failed"
	TaskStatusCancelled TaskStatus = "cancelled" //nolint:misspell // wire value; external clients may expect British spelling
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL