a2a

package
v0.8.3 Latest Latest
Warning

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

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

Documentation

Overview

Package a2a implements a minimal, interoperable subset of the Agent-to-Agent (A2A) protocol so AgentCTL agents can expose themselves as network services and call one another. It is transport-agnostic at the core: the server is given an Executor and never imports the engine, which keeps it testable.

The wire format follows the A2A Agent Card + JSON-RPC `message/send` conventions closely enough to interoperate with other A2A tooling, while staying intentionally small (synchronous, text parts, no push notifications) for the first version.

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"`
	URL                string       `json:"url"`
	Version            string       `json:"version"`
	Capabilities       Capabilities `json:"capabilities"`
	DefaultInputModes  []string     `json:"defaultInputModes"`
	DefaultOutputModes []string     `json:"defaultOutputModes"`
	Skills             []Skill      `json:"skills"`
}

AgentCard is the public description an A2A agent serves at /.well-known/agent.json. Field names match the A2A spec.

func CardFromAgent

func CardFromAgent(spec *config.AgentSpec, baseURL, version string) AgentCard

CardFromAgent builds an AgentCard from a parsed agent spec. baseURL is the externally reachable root (e.g. "http://localhost:8080"); version is the build version string. Both may be empty and are filled with sane defaults.

type Capabilities

type Capabilities struct {
	Streaming         bool `json:"streaming"`
	PushNotifications bool `json:"pushNotifications"`
}

Capabilities advertises optional protocol features. This implementation is synchronous request/response, so streaming and push are false.

type Client

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

Client talks to a remote A2A agent.

func NewClient

func NewClient(baseURL string) *Client

NewClient builds a client for the agent rooted at baseURL (e.g. "http://localhost:8080"). Trailing slashes are trimmed.

func (*Client) Card

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

Card fetches the remote agent's Agent Card.

func (*Client) Send

func (c *Client) Send(ctx context.Context, text string) (string, error)

Send delivers a text task via message/send and returns the agent's reply text. A JSON-RPC error is surfaced as a Go error.

type Executor

type Executor func(ctx context.Context, task string) (string, error)

Executor runs a task (the incoming user text) and returns the agent's reply. The server is decoupled from the engine through this func, so it can be tested with a stub and reused by any caller that can run a task.

type Message

type Message struct {
	Role      string `json:"role"` // "user" or "agent"
	Parts     []Part `json:"parts"`
	MessageID string `json:"messageId,omitempty"`
	Kind      string `json:"kind"` // always "message"
}

Message is an A2A message (a turn from user or agent).

func TextMessage

func TextMessage(role, id, text string) Message

TextMessage builds a single-text-part message.

func (Message) Text

func (m Message) Text() string

Text concatenates all text parts of a message.

type Part

type Part struct {
	Kind string `json:"kind"`
	Text string `json:"text,omitempty"`
}

Part is a single piece of a message. Only text parts are supported.

type Server

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

Server serves a single agent's A2A card and message endpoint.

func NewServer

func NewServer(card AgentCard, exec Executor) *Server

NewServer builds an A2A server for one agent.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns an http.Handler exposing:

  • GET /.well-known/agent.json (and /agent-card.json) → the Agent Card
  • GET /health → liveness
  • POST / → JSON-RPC 2.0 (method "message/send")

type Skill

type Skill struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Tags        []string `json:"tags,omitempty"`
	Examples    []string `json:"examples,omitempty"`
}

Skill is a capability the agent advertises. We map one agent to one primary skill derived from its description.

Jump to

Keyboard shortcuts

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