Documentation
¶
Overview ¶
Package config is the single place that reads the environment. Everything downstream takes the parsed Config by injection, so no other package touches os.Getenv — that keeps the agent loop, auth, and usage emitter harness-drivable.
It is a direct port of the TypeScript service's src/config.ts. The env var names are identical to the TS service with one deliberate exception noted in Load: AGENT_BINDINGS_FIXTURE is renamed CAPABILITY_DOCS_FIXTURE to reflect the capability-contract inversion (the assistant now owns its capability document schema).
Index ¶
Constants ¶
const ( DefaultPort = 7820 DefaultAnthropicModel = "claude-sonnet-4-6" DefaultGatewayModel = "patch-stub-v1" )
Defaults mirrored from the TS service.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthConfig ¶
type AuthConfig struct {
// SARAPIURL is the control-plane API base URL the SubjectAccessReview is
// POSTed to (env AUTHZ_SAR_API_URL). When unset it is derived from the
// in-cluster KUBERNETES_SERVICE_HOST/PORT.
SARAPIURL string
// SARGroup/Resource/Verb override the resourceAttributes triple the SAR asks
// about (envs AUTHZ_SAR_GROUP/RESOURCE/VERB). Empty ⇒ the auth package
// defaults (assistant.miloapis.com / conversations / create).
SARGroup string
SARResource string
SARVerb string
// SARTokenPath/SARCACertPath point at the assistant's own service-account
// token and CA bundle for the SAR call (envs AUTHZ_SAR_TOKEN_PATH /
// AUTHZ_SAR_CA_CERT_PATH). Default to the standard in-cluster mount paths.
SARTokenPath string
SARCACertPath string
// SARClientCertPath/SARClientKeyPath point at a client certificate the
// assistant presents to identify itself for the SAR call (envs
// AUTHZ_SAR_CLIENT_CERT_PATH / AUTHZ_SAR_CLIENT_KEY_PATH). Unset on a
// same-cluster control plane, where the service-account token is enough.
// Required against Milo, which trusts service-account tokens only from its
// own issuer. No default: an unset path means "no client certificate".
SARClientCertPath string
SARClientKeyPath string
// TokenReviewAPIURL is the control-plane API base URL the TokenReview is
// POSTed to (env AUTHN_TOKENREVIEW_API_URL). When unset it is derived from
// the in-cluster KUBERNETES_SERVICE_HOST/PORT.
TokenReviewAPIURL string
// TokenReviewTokenPath/TokenReviewCACertPath point at the assistant's own
// service-account token and CA bundle for the TokenReview call (envs
// AUTHN_TOKENREVIEW_TOKEN_PATH / AUTHN_TOKENREVIEW_CA_CERT_PATH). Default to
// the standard in-cluster mount paths.
TokenReviewTokenPath string
TokenReviewCACertPath string
// TokenReviewClientCertPath/TokenReviewClientKeyPath point at a client
// certificate the assistant presents to identify itself for the TokenReview
// call (envs AUTHN_TOKENREVIEW_CLIENT_CERT_PATH /
// AUTHN_TOKENREVIEW_CLIENT_KEY_PATH). No default; see the SAR pair above.
TokenReviewClientCertPath string
TokenReviewClientKeyPath string
}
AuthConfig holds the authentication and authorization settings.
type Config ¶
type Config struct {
Port int
Host string
// PublicBaseURL is used for the agent-card url and the CloudEvents source.
PublicBaseURL string
LogLevel string
Auth AuthConfig
// CapabilityDocsFixture is the path to the capability-documents fixture
// (env CAPABILITY_DOCS_FIXTURE). Empty ⇒ no fixture source.
CapabilityDocsFixture string
// CapabilityProviderURL is the base URL of the capability-provider HTTP API
// (env CAPABILITY_PROVIDER_URL). Empty ⇒ no HTTP source. Mutually exclusive
// with CapabilityDocsFixture. With both unset, no provider capabilities are
// composed.
CapabilityProviderURL string
// PersonaPromptFile is the path to a file containing the persona section
// of the system prompt (env PERSONA_PROMPT_FILE), read once at startup.
// Empty ⇒ agent.DefaultPersona. A platform provider sets this to mount
// their own identity/voice text via a ConfigMap without a rebuild; the
// tool-use and provenance rules stay fixed regardless (see
// internal/agent.BuildSystemPrompt).
PersonaPromptFile string
// ConversationStoreURL is the PostgreSQL URL for durable conversation
// history (env CONVERSATION_STORE_URL). Empty ⇒ in-memory history
// (process lifetime). When set, an unreachable database fails boot —
// a service configured for durable history must not silently forget.
ConversationStoreURL string
// AllowPrivateCapabilityNetworks relaxes the capability SSRF guard's
// loopback/RFC1918 block (env CAPABILITY_ALLOW_PRIVATE_NETWORKS). The
// platform's real capability endpoints — the in-cluster AI gateway, provider
// pods — resolve to private ClusterIPs, so every real deployment sets this
// true; local dev/e2e reach services over loopback and need it too. Even
// when true, link-local/cloud-metadata addresses stay blocked. Set false
// only in a posture where all capability endpoints are public AND providers
// are untrusted (then prefer a host allow-list). Default false = safe.
AllowPrivateCapabilityNetworks bool
// PlatformAPIURL is the platform API the base tools read and write a
// project's own resources through (env PLATFORM_API_URL). Unset defaults to
// the SubjectAccessReview endpoint: the platform that decides whether a
// caller may act on a project is the same one that serves that project's
// resources, so a deployment that names one has already named the other.
//
// The service holds no credential for this endpoint. Every request over it
// carries the calling user's own bearer token (see internal/projectapi),
// which is why there is no token path here to go with it.
PlatformAPIURL string
// PlatformAPICACertPath verifies the platform API's certificate (env
// PLATFORM_API_CA_CERT_PATH). Unset defaults to the SubjectAccessReview CA
// bundle, which is the same server.
PlatformAPICACertPath string
// PlanTokenKey binds plans for the base tools' change path (env
// PLAN_TOKEN_KEY; base64 or a raw string of at least 16 bytes). Setting it
// lets one process apply another's plan and survives restarts. Unset
// generates a key per process with a startup warning: the guarantee still
// holds, but an outstanding plan is lost on restart and refused by a
// sibling replica. See internal/plantoken.
PlanTokenKey string
// CapabilityIdentityForwardHosts are the operator-sanctioned MCP endpoint
// hosts that may receive the calling user's bearer token and the turn's
// project (comma-separated env; exact or domain-suffix match). Empty (the
// default) forwards to nobody — a capability document is provider-controlled
// data, so naming an endpoint must never by itself send a credential there.
CapabilityIdentityForwardHosts []string
Model ModelConfig
Usage UsageConfig
}
Config is the fully-parsed service configuration.
func Load ¶
Load parses a Config from the provided environment lookup. Pass os.Getenv (wrapped) in production; tests pass a map-backed lookup. It returns an *Error aggregating every invalid field.
Env var names are identical to the TS service EXCEPT AGENT_BINDINGS_FIXTURE, which is renamed CAPABILITY_DOCS_FIXTURE (capability-contract inversion).
type Error ¶
type Error struct {
Errors []FieldError
}
Error aggregates one or more [FieldError]s from Load.
type FieldError ¶
FieldError describes a single invalid configuration field.
type ModelConfig ¶
type ModelConfig struct {
Mode ModelMode
AnthropicAPIKey string
AnthropicModel string
// GatewayURL is the Envoy AI Gateway base URL (OpenAI-compatible endpoint).
// Distinct from [UsageConfig.GatewayURL] (the metering collector).
GatewayURL string
// GatewayModel is the model name the gateway routes upstream.
GatewayModel string
// GatewayTokenFile is an optional path to a bearer token presented to the
// gateway (GATEWAY_TOKEN_FILE). This authenticates the SERVICE to the
// gateway; it is not a model credential, which the gateway still injects
// itself. On the Datum platform it is a projected ServiceAccount token with
// audience "ai-gateway", which the gateway validates as a JWT.
GatewayTokenFile string
// GatewayCACert is an optional CA PEM path for a self-signed gateway TLS cert.
GatewayCACert string
// GatewayTLSInsecure skips gateway TLS verification (local convenience only).
GatewayTLSInsecure bool
}
ModelConfig holds the model-backend settings.
type ModelMode ¶
type ModelMode string
ModelMode selects the model backend.
const ( // ModelModeAnthropic talks to the real Anthropic API (needs ANTHROPIC_API_KEY). ModelModeAnthropic ModelMode = "anthropic" // ModelModeMock uses the in-process scripted model (no credentials). ModelModeMock ModelMode = "mock" // ModelModeGateway talks to an Envoy AI Gateway (OpenAI-compatible; the // gateway injects the upstream credential, so the service holds none). ModelModeGateway ModelMode = "gateway" )
type UsageConfig ¶
type UsageConfig struct {
// GatewayURL is the collector base URL (USAGE_GATEWAY_URL). Unset ⇒ emit is a no-op.
GatewayURL string
// GatewayAPIKey is an optional collector api-key (USAGE_GATEWAY_API_KEY).
GatewayAPIKey string
}
UsageConfig holds the usage-metering collector settings.