a2a

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package a2a implements a minimal A2A (Agent2Agent) surface for seamlessd: the agent card at /.well-known/agent-card.json and a JSON-RPC endpoint at /api/a2a whose one skill is recall -- another agent on this machine sends a text message and gets the owner's fused memory search results back. Synchronous only: message/send replies with a completed Message, never a Task, so the task lifecycle, streaming, and push notifications are all deliberately absent and the card says so.

Index

Constants

View Source
const AgentName = "Seamless"

AgentName is the display name the card leads with. It matches the MCP initialize handshake's mcp.ServerName -- one install, one agent identity -- pinned by a docsgen test rather than an import, because internal/a2a and internal/mcp are sibling API surfaces that do not import each other.

View Source
const ProtocolVersion = "0.3.0"

ProtocolVersion is the A2A generation the endpoint speaks: the v0.3 JSON-RPC binding, whose card names the endpoint in url/preferredTransport. The card additionally carries the newer draft's supportedInterfaces shape (the one the agent-readiness scanners key on), the same both-generations-in-one-document approach as the MCP server card.

Variables

This section is empty.

Functions

func CardJSON

func CardJSON(version, endpoint string) ([]byte, error)

CardJSON is the one rendering path for the card -- the daemon serves these bytes and docsgen commits them, so the two cannot format-drift.

Types

type AgentCapabilities

type AgentCapabilities struct {
	Streaming              bool `json:"streaming"`
	PushNotifications      bool `json:"pushNotifications"`
	StateTransitionHistory bool `json:"stateTransitionHistory"`
}

AgentCapabilities are all explicit booleans for the same reason as SupportsAuthenticatedExtendedCard: absent-vs-false ambiguity costs a client a probe request.

type AgentCard

type AgentCard struct {
	ProtocolVersion    string                    `json:"protocolVersion"`
	Name               string                    `json:"name"`
	Description        string                    `json:"description"`
	URL                string                    `json:"url"`
	PreferredTransport string                    `json:"preferredTransport"`
	Provider           *AgentProvider            `json:"provider,omitempty"`
	Version            string                    `json:"version"`
	DocumentationURL   string                    `json:"documentationUrl,omitempty"`
	Capabilities       AgentCapabilities         `json:"capabilities"`
	SecuritySchemes    map[string]SecurityScheme `json:"securitySchemes,omitempty"`
	Security           []map[string][]string     `json:"security,omitempty"`
	DefaultInputModes  []string                  `json:"defaultInputModes"`
	DefaultOutputModes []string                  `json:"defaultOutputModes"`
	Skills             []AgentSkill              `json:"skills"`
	// SupportsAuthenticatedExtendedCard is explicit (not omitempty) so a
	// client never has to guess whether false means "no" or "not stated".
	SupportsAuthenticatedExtendedCard bool `json:"supportsAuthenticatedExtendedCard"`
	// SupportedInterfaces is the newer draft's interface declaration. Each
	// entry carries both that draft's protocolBinding and v0.3's transport
	// vocabulary, so either generation of client finds the field it expects.
	SupportedInterfaces []AgentInterface `json:"supportedInterfaces"`
}

AgentCard is the A2A agent card (v0.3 field set, plus the newer draft's supportedInterfaces). Exported so docsgen can render the site twin from the same struct the daemon serves -- one shape, no drift.

func Card

func Card(version, endpoint string) AgentCard

Card builds the agent card for one endpoint and version. The daemon passes its build version and real bind address; docsgen passes the server.json version and the default address -- so the site twin and a default install's live card agree on everything a release can know in advance.

type AgentInterface

type AgentInterface struct {
	URL             string `json:"url"`
	Transport       string `json:"transport"`
	ProtocolBinding string `json:"protocolBinding"`
}

type AgentProvider

type AgentProvider struct {
	Organization string `json:"organization"`
	URL          string `json:"url,omitempty"`
}

type AgentSkill

type AgentSkill struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Tags        []string `json:"tags"`
	Examples    []string `json:"examples,omitempty"`
	InputModes  []string `json:"inputModes,omitempty"`
	OutputModes []string `json:"outputModes,omitempty"`
}

type Config

type Config struct {
	Retrieve Recaller
	Events   *events.Recorder // may be nil (recall demand is then not recorded)
	APIKey   string
	Version  string // build version served in the card; defaults to 0.0.0-dev
	Endpoint string // absolute URL the card advertises, e.g. http://127.0.0.1:8081/api/a2a
	Logger   *slog.Logger
}

Config wires the A2A server's dependencies.

type Message

type Message struct {
	Kind      string         `json:"kind"` // always "message"
	MessageID string         `json:"messageId"`
	ContextID string         `json:"contextId,omitempty"`
	Role      string         `json:"role"` // "agent" in replies
	Parts     []Part         `json:"parts"`
	Metadata  map[string]any `json:"metadata,omitempty"`
}

Message is an A2A message. Only the fields this server reads or writes are declared; unknown incoming fields are ignored by encoding/json as usual.

type Part

type Part struct {
	Kind string         `json:"kind"`
	Text string         `json:"text,omitempty"`
	Data map[string]any `json:"data,omitempty"`
}

Part is a message part; kind "text" carries Text, kind "data" carries Data.

type Recaller

type Recaller interface {
	Recall(ctx context.Context, in retrieve.RecallInput) ([]retrieve.Hit, error)
}

Recaller is the one retrieval capability this surface needs; *retrieve.Service satisfies it.

type SecurityScheme

type SecurityScheme struct {
	Type        string `json:"type"`
	Scheme      string `json:"scheme,omitempty"`
	Description string `json:"description,omitempty"`
}

type Server

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

Server hosts the A2A JSON-RPC endpoint and its agent card.

func New

func New(cfg Config) (*Server, error)

func (*Server) CardHandler

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

CardHandler serves the agent card. Public by design (RFC 8615 discovery, no auth): the card carries no secrets -- only the endpoint URL and the name of the auth scheme the endpoint itself will demand.

func (*Server) Handler

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

Handler serves the JSON-RPC endpoint. Auth failures are HTTP-level (401), per the A2A spec's transport-security model; everything after the bearer check speaks JSON-RPC.

Jump to

Keyboard shortcuts

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