Documentation
¶
Overview ¶
Package agent is the external control-plane layer that composes the gateway's LLM, MCP, ACP, and metrics surfaces around an operator-facing agent identity.
It depends on the lower-level protocol managers and query services; the protocol packages must not depend on pkg/agent. See docs/design/agents-control-plane.md for the full direction.
Index ¶
- Constants
- Variables
- func DecodeStoredAgentConfig(data []byte) (any, error)
- type ACPRouteServiceLookup
- type ACPRuntime
- type Agent
- type Budget
- type HTTPRuntime
- type Manager
- func (m *Manager) Create(ctx context.Context, a Agent) error
- func (m *Manager) Delete(ctx context.Context, id string) error
- func (m *Manager) Get(ctx context.Context, id string) (Agent, error)
- func (m *Manager) List(ctx context.Context) ([]Agent, error)
- func (m *Manager) Refresh(ctx context.Context) error
- func (m *Manager) ResolveAgentID(routeID, serviceID, sessionID string) (string, bool)
- func (m *Manager) SetRouteLookup(lookup ACPRouteServiceLookup)
- func (m *Manager) Update(ctx context.Context, id string, a Agent) error
- type Policy
- type Resources
- type Routes
- type Runtime
Constants ¶
const ( // RuntimeTypeACP: the gateway owns the lifecycle (process pool, sessions, // permission flow, transcript) through an ACP service. RuntimeTypeACP = "acp" // RuntimeTypeHTTP: the agent service owns its own lifecycle; the gateway is // only a client. P0 defines the shape but does not dispatch to it yet. RuntimeTypeHTTP = "http" )
Runtime backend types, split by who owns the agent's process lifecycle.
Variables ¶
var ErrAgentNotConfigured = fmt.Errorf("agent is not configured")
Functions ¶
func DecodeStoredAgentConfig ¶
Types ¶
type ACPRouteServiceLookup ¶
type ACPRouteServiceLookup interface {
ACPRouteServiceID(ctx context.Context, routeID string) (string, error)
}
ACPRouteServiceLookup resolves an ACP route id to its backing service id. The agent manager uses it to enforce that an agent's acp_route_ids all point at the agent's runtime service. It is optional; when nil the consistency check is skipped (the manager still enforces service_id uniqueness).
type ACPRuntime ¶
type ACPRuntime struct {
ServiceID string `json:"service_id"`
}
ACPRuntime holds only the binding to an ACP service. ACP operational config (permission_mode, allowed_roots, default_cwd) is owned by the ACP service under /admin/acp/services, not duplicated here.
type Agent ¶
type Agent struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Runtime Runtime `json:"runtime"`
Routes Routes `json:"routes"`
Resources Resources `json:"resources"`
Policy Policy `json:"policy"`
Disabled bool `json:"disabled"`
// OwnsService records that this agent auto-created its backing ACP service
// (provenance). It distinguishes "agent owns this service" from "agent
// references a pre-existing shared service" for deletion/cascade decisions.
OwnsService bool `json:"owns_service,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Agent is a first-class management object representing an operator-facing agent identity, not a protocol-specific service.
func (Agent) ACPServiceID ¶
ACPServiceID returns the bound ACP service id, or "" when the agent is not ACP-backed.
func (*Agent) NormalizeTimestamps ¶
type HTTPRuntime ¶
type HTTPRuntime struct {
Endpoint string `json:"endpoint"`
AuthRef string `json:"auth_ref,omitempty"`
}
HTTPRuntime carries the agent-level endpoint and callback auth for an agent that owns its own lifecycle.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns agent CRUD plus the in-memory route/service -> agent index used for write-time attribution. The index is rebuilt on every mutation and never read from the config store on the hot path.
func NewManager ¶
func NewManager(store configstore.ConfigStore) *Manager
func (*Manager) Refresh ¶
Refresh rebuilds the in-memory route/service -> agent index from the store.
func (*Manager) ResolveAgentID ¶
ResolveAgentID maps an originating route/service back to a single agent for write-time usage attribution. It implements usage.AgentAttributor. It returns ok=false when the mapping is empty (the caller then leaves agent_id empty).
func (*Manager) SetRouteLookup ¶
func (m *Manager) SetRouteLookup(lookup ACPRouteServiceLookup)
SetRouteLookup wires the optional ACP route -> service resolver used for the acp_route_ids consistency check.
type Policy ¶
type Policy struct {
MaxAgentDepth int `json:"max_agent_depth,omitempty"`
Budget *Budget `json:"budget,omitempty"`
}
Policy holds runtime-agnostic governance only. Runtime-specific config belongs under runtime.<type> or on the backing service.
type Resources ¶
type Resources struct {
ProviderIDs []string `json:"provider_ids,omitempty"`
MCPServiceIDs []string `json:"mcp_service_ids,omitempty"`
VirtualKeyIDs []string `json:"virtual_key_ids,omitempty"`
}
Resources is a management view of what the agent is allowed to use. It is not enforced inline on the data-plane request path in P0/P1.
type Routes ¶
type Routes struct {
ACPRouteIDs []string `json:"acp_route_ids,omitempty"`
LLMRouteIDs []string `json:"llm_route_ids,omitempty"`
MCPRouteIDs []string `json:"mcp_route_ids,omitempty"`
}
Routes are management/display references used to surface matching ingress routes and to drive attribution; they do not select the execution backend.
type Runtime ¶
type Runtime struct {
Type string `json:"type"`
ACP *ACPRuntime `json:"acp,omitempty"`
HTTP *HTTPRuntime `json:"http,omitempty"`
}
Runtime is authoritative for execution. It binds the agent to exactly one runtime backend instance, selected by Type.