infrastructure

package
v0.231.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 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 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 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)

UseGatewayCredential makes apiKey the bearer token of A2A requests to the gateway at gatewayURL, the token the gateway also expects on inference.

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 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