a2a

package
v0.74.4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package a2a adapts a registered A2A agent to SpeechKit's cascaded voice pipeline. SpeechKit retains STT/TTS custody; the remote endpoint owns agent semantics, memory, tools and authorization.

Stability: Experimental — may change in any release.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

Agent implements cascaded.Agent by forwarding each utterance to a registered A2A agent and returning the text parts of its answer. Build it with New; it holds no per-turn state and is safe for concurrent use.

func New

func New(config Config) (*Agent, error)

New validates config and returns an Agent. It fails when Endpoint is missing or not HTTPS (HTTP is allowed only on loopback), or when TargetAgentID or SessionID is blank.

func (*Agent) Run

Run sends one user turn as a JSON-RPC "message/stream" request and returns the agent's text answer with Action "display". It fails closed: a blank utterance, a HeaderProvider error (reported before any network call), a non-2xx status, a JSON-RPC error object (also inside an SSE stream; a *TurnError carrying the agent's typed reason), or an answer without text parts is an error. Streamed answers concatenate the text of every result event.

type Config

type Config struct {
	// Endpoint is the agent's A2A JSON-RPC URL. It must use HTTPS; plain
	// HTTP is accepted only for loopback hosts.
	Endpoint string
	// TargetAgentID names the registered agent; it is sent in the request
	// metadata and in every [RequestContext].
	TargetAgentID string
	// SessionID is the A2A contextId every turn is sent under, so the
	// remote agent can keep per-session memory.
	SessionID string
	// HTTPClient sends the turns; nil uses a client with a 60 s timeout.
	HTTPClient *http.Client
	// Headers optionally mints per-turn headers; nil adds none.
	Headers HeaderProvider
}

Config describes the registered A2A agent an Agent talks to. Endpoint, TargetAgentID and SessionID are required.

type HeaderProvider

type HeaderProvider func(context.Context, RequestContext) (http.Header, error)

HeaderProvider supplies per-turn headers. It is deliberately generic: a self-hosted deployment may use a bearer key while a hosted connector can mint a capability lease and signed delegation without exposing either to SpeechKit clients.

type RequestContext

type RequestContext struct {
	TargetAgentID string
	SessionID     string
	RequestBody   []byte
}

RequestContext identifies the exact registered-agent turn for a header provider that mints short-lived authorization or a signed delegation.

type TurnError added in v0.74.2

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

TurnError is a streamed turn the agent answered with a JSON-RPC error. It implements cascaded.CodedError: Code is the agent's typed reason from error.data.code (for example "quota_exhausted" for used-up AI credits), or "" when the agent named none.

func (*TurnError) Code added in v0.74.2

func (e *TurnError) Code() string

Code is the agent's typed reason, or "".

func (*TurnError) Error added in v0.74.2

func (e *TurnError) Error() string

Jump to

Keyboard shortcuts

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