Documentation
¶
Overview ¶
Package server wires the assistant's HTTP surface: liveness at GET /healthz, readiness at GET /readyz, Prometheus telemetry at GET /metrics, the public agent card at /.well-known/agent-card.json (+ the legacy /.well-known/agent.json alias), and the POST /a2a JSON-RPC endpoint. The A2A protocol itself (JSON-RPC framing, SSE, task store) is owned by a2a-go; this package adds the mux, the auth middleware, request-id correlation, operational metrics, and the dependency wiring.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggerFromContext ¶
LoggerFromContext returns the request-scoped logger (carrying requestId) that the middleware attached, or fallback when none is present. It lets the agent layer emit request-correlated logs without importing the HTTP wiring.
func New ¶
New builds the assistant's HTTP handler from deps. The A2A JSON-RPC endpoint shares its task store with the auth middleware so authorization on GetTask and CancelTask can read the owning project off the stored task. Every route is wrapped with request-id correlation and Prometheus instrumentation.
func RequestIDFromContext ¶
RequestIDFromContext returns the request id threaded onto ctx by the request-id middleware, or "" when absent. Downstream layers can attach it to their own logs to correlate with the HTTP request line.
Types ¶
type Deps ¶
type Deps struct {
Config *config.Config
Logger *slog.Logger
Authenticator auth.Authenticator
Authorizer auth.Authorizer
Runner assistanta2a.AgentRunner
// Compactor drives POST /v1alpha1/compact (the manual "/compact" command). Nil
// answers 503 on that route rather than failing to build the server — a
// Runner that doesn't implement [assistanta2a.Compactor] simply doesn't
// offer manual compaction.
Compactor assistanta2a.Compactor
// Renamer drives POST /v1alpha1/conversations/rename (the "/rename" command) —
// the conversation store the chat path already writes. Nil answers 503 on
// that route, matching Compactor's posture.
Renamer history.Renamer
// SkillAdvertiser backs the authenticated extended agent card
// (GetExtendedAgentCard). Nil means the method answers
// ErrExtendedCardNotConfigured rather than failing to build the server — an
// AgentRunner that can't describe entitlement simply doesn't offer one.
SkillAdvertiser assistanta2a.SkillAdvertiser
// TaskStore backs the A2A task lifecycle. When nil the server falls back to
// the a2a-go in-memory store (dev/tests): tasks are lost on restart. Boot
// injects the durable Postgres store (internal/taskstore) when a conversation
// store URL is configured.
TaskStore a2astore.Store
// ReadyCheck reports dependency readiness for GET /readyz. Nil ⇒ always
// ready (dev, no external dependencies). It must be cheap and bounded — the
// probe wraps it with a short deadline.
ReadyCheck func(context.Context) error
// Metrics is the shared application-level metrics handle (conversation
// turns, tool calls, model calls, history compaction, capability-gap
// reports) — normally the exact instance also injected into
// agent.Deps.Metrics, so this endpoint exposes the same series the agent
// layer records into. Nil builds a fresh, unshared instance rather than
// leaving those series absent from /metrics.
Metrics *appmetrics.Metrics
}
Deps are the fully-constructed dependencies of the HTTP app, so tests can inject fakes and boot wires the real graph.