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 ¶
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 ¶
func (a *Agent) Run(ctx context.Context, input cascaded.AgentInput) (cascaded.AgentOutput, error)
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
// TurnTimeout bounds the complete request and streamed answer, including
// custom HTTP clients. Zero uses 60 seconds. Turns are never replayed.
TurnTimeout time.Duration
// 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 ¶
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 ¶
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 with an allowlisted public outcome.