infrastructure

package
v0.244.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const PeerPath = "/a2a"

The peer wire: the A2A 1.0 envelopes two infer daemons exchange when a workspace serves its teleport vocabulary over A2A JSON-RPC. One exchange is one contextId, every frame rides as the text part of a message, and the event that announces the host carries metadata and no frame.

Variables

This section is empty.

Functions

func AuthFailure added in v0.226.0

func AuthFailure(agentURL string, err error) (string, bool)

AuthFailure describes err for the model when it is an authentication failure: credentials that could not be obtained, or a 401 or 403 from the agent. The message names the agent and leaves the response body out.

func DecodePeerEvent added in v0.243.0

func DecodePeerEvent(data []byte) (frame []byte, metadata map[string]string, hasFrame bool)

DecodePeerEvent reads one stream event, returning its frame and metadata.

func DecodePeerReply added in v0.243.0

func DecodePeerReply(body []byte) error

DecodePeerReply is the error a SendMessage reply carries, nil on an ack.

func EncodePeerRequest added in v0.243.0

func EncodePeerRequest(method PeerMethod, exchange string, frame []byte, metadata map[string]string) []byte

EncodePeerRequest is the request a dialing daemon sends: a user message on the exchange carrying the frame, announcing the caller in its metadata.

func NewClient

func NewClient(agentURL string) client.A2AClient

NewClient returns an ADK client for the agent at agentURL whose requests carry the session's trace context, so remote spans nest under ours, and the credentials agents.yaml gives the agent. They go to the host the agent actually runs on. Every request activates the usage extension.

func PeerAck added in v0.243.0

func PeerAck(id adk.Value, exchange string) []byte

PeerAck answers a SendMessage with the completed task on the exchange. Its artifacts stay empty, because every frame rides the stream.

func PeerCard added in v0.243.0

func PeerCard(url, version string) []byte

PeerCard is the agent card of a peer endpoint served at url.

func PeerError added in v0.243.0

func PeerError(id adk.Value, message string) []byte

PeerError answers a request the endpoint cannot serve with the invalid params error.

func PeerEvent added in v0.243.0

func PeerEvent(frame []byte, metadata map[string]string) []byte

PeerEvent is one event of a peer stream: an agent message carrying the frame, or the announcing one carrying only metadata.

func PolicyRefusal added in v0.226.0

func PolicyRefusal(err error) (string, bool)

PolicyRefusal describes err for the model when the gateway's guardrails refused the request: a 403 whose body is a JSON-RPC error. The message carries the policy's own words.

func PreferredEndpointURL added in v0.222.2

func PreferredEndpointURL(card *adk.AgentCard, fallback string) string

PreferredEndpointURL returns the card's preferred interface URL, falling back to the URL the card was fetched from when it declares none. v1.0.1 cards replaced the flat url field with SupportedInterfaces.

func Rejection added in v0.226.0

func Rejection(agentURL string, err error) (string, bool)

Rejection describes err for the model when the agent turned the request down for good, so retrying is pointless: a policy refusal, an authentication failure or a method the agent does not implement.

func RouteAgent added in v0.226.0

func RouteAgent(name, configuredURL, runningAt string)

RouteAgent sends requests for the named agent, configured at configuredURL, to the host of runningAt. Running on the configured origin clears the route.

func SSE added in v0.243.0

func SSE(event []byte) []byte

SSE renders one event as a server-sent events data line.

func UnrouteAgent added in v0.226.0

func UnrouteAgent(name string)

UnrouteAgent sends requests for the named agent back to its configured URL.

func UseGatewayCredential added in v0.226.0

func UseGatewayCredential(gatewayURL, apiKey string, transport http.RoundTripper)

UseGatewayCredential makes apiKey the bearer token of A2A requests to the gateway at gatewayURL, the token the gateway also expects on inference, and sends them over transport, which carries the gateway's TLS settings.

Types

type AgentCardClient

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

func NewAgentCardClient

func NewAgentCardClient(cfg *config.Config) *AgentCardClient

func (*AgentCardClient) GetAgentCard

func (s *AgentCardClient) GetAgentCard(ctx context.Context, agentURL string) (*adk.AgentCard, error)

func (*AgentCardClient) GetAgentCards

func (s *AgentCardClient) GetAgentCards(ctx context.Context) ([]*a2adomain.CachedAgentCard, error)

func (*AgentCardClient) GetConfiguredAgents

func (s *AgentCardClient) GetConfiguredAgents() []string

type AuthError added in v0.226.0

type AuthError struct {
	Agent  string
	Reason string
}

AuthError reports that a request to an agent could not be given credentials. Its reason names variables, URLs and status codes, never a secret.

func (*AuthError) Error added in v0.226.0

func (e *AuthError) Error() string

type HeadlessTaskHandler added in v0.231.0

type HeadlessTaskHandler struct {
	Runner  func(ctx context.Context, opts agentheadless.Options) (agentheadless.Result, error)
	Mode    string
	Timeout time.Duration
}

HeadlessTaskHandler runs every task it gets as one `infer headless --prompt-only` subprocess. The task's text parts are the prompt, the run's final assistant message is the completed task's status message, and a tasks/cancel reaches the run as the cancellation of its context. Timeout bounds one run so a hung one cannot hold the one-at-a-time queue forever.

func NewHeadlessTaskHandler added in v0.231.0

func NewHeadlessTaskHandler(mode string, timeout time.Duration) *HeadlessTaskHandler

NewHeadlessTaskHandler builds the handler for tasks served in the given headless agent mode, each run bounded by timeout (zero means unbounded).

func (*HeadlessTaskHandler) GetAgent added in v0.231.0

GetAgent is the TaskHandler contract; see SetAgent.

func (*HeadlessTaskHandler) HandleTask added in v0.231.0

func (h *HeadlessTaskHandler) HandleTask(ctx context.Context, task *adk.Task, message *adk.Message) (*adk.Task, error)

HandleTask validates the task and runs it. Validation and run failures land in the task's status rather than in the error return, so the state set here is what the client polls. A task whose context was canceled keeps the canceled state the task manager already recorded.

func (*HeadlessTaskHandler) SetAgent added in v0.231.0

SetAgent is the TaskHandler contract; a served task never calls the ADK's OpenAI-compatible agent.

type PeerMethod added in v0.243.0

type PeerMethod string

PeerMethod is one of the two A2A methods the peer endpoint serves.

type PeerRequest added in v0.243.0

type PeerRequest struct {
	ID       adk.Value
	Method   PeerMethod
	Exchange string
	Frame    []byte
	Metadata map[string]string
}

PeerRequest is one JSON-RPC request the peer endpoint takes: its id to echo, the method, the exchange the message's contextId names, the frame in the message's first text part and the metadata the caller announced.

func ParsePeerRequest added in v0.243.0

func ParsePeerRequest(body []byte) (PeerRequest, bool)

ParsePeerRequest reads a peer request. A method that is not SendMessage or SendStreamingMessage is not ok.

type Server added in v0.231.0

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

Server is the A2A server the daemon hosts: the agent card plus the message/send, tasks/{get,list,cancel} methods, tasks kept in the ADK's in-memory store and run one at a time from its queue, each one a headless run.

func NewServer added in v0.231.0

func NewServer(settings Settings) (*Server, error)

NewServer builds the ADK A2A server around infer's values. The ADK reads no environment of its own: serverConfig.NewWithDefaults applies only its struct-tag defaults, so an unprefixed SERVER_PORT or AUTH_ENABLED in the user's shell is never read, and every knob is set from settings.

func (*Server) Start added in v0.231.0

func (s *Server) Start(ctx context.Context) error

Start serves until the process stops. It blocks; run it in a goroutine.

func (*Server) Stop added in v0.231.0

func (s *Server) Stop(ctx context.Context) error

Stop shuts the HTTP server down and lets in-flight runs finish.

type Settings added in v0.231.0

type Settings struct {
	Host        string
	Port        int
	Token       string
	Mode        string
	TaskTimeout time.Duration
	Version     string
}

Settings carries what the daemon passes over: the bind address, the port, the bearer token, the agent mode and time budget served tasks run with, and the card version.

Jump to

Keyboard shortcuts

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