Documentation
¶
Overview ¶
Package config defines the on-disk schema for `.agents/config.json` and the rules for discovering, parsing, and merging it with built-in defaults.
A minimal config.json only needs to set what the consumer wants to override; all other fields fall back to DefaultConfig().
Index ¶
- Constants
- func Find(startDir string) (string, bool, error)
- func Save(path string, cfg *Config) error
- type AgentConfig
- type AnthropicConfig
- type Config
- type MockConfig
- type ModelConfig
- type OTELConfig
- type PathScopeConfig
- type PermissionsConfig
- type PricingConfig
- type ToolOutputConfig
- type ToolOutputPerToolCaps
- type ToolsConfig
- type VertexConfig
Constants ¶
const ( PermissionModeAsk = "ask" PermissionModeAllow = "allow" PermissionModeYolo = "yolo" )
Permission modes.
const ( ProviderGemini = "gemini" ProviderVertex = "vertex" ProviderAnthropic = "anthropic" ProviderAnthropicVertex = "anthropic-vertex" ProviderEcho = "echo" ProviderScripted = "scripted" )
Provider names recognized by the resolver.
const AgentsDirName = ".agents"
AgentsDirName is the project-local directory we discover, analogous to `.git`. It contains config.json, mcp.json, skills/, sessions/, etc.
const ConfigFileName = "config.json"
ConfigFileName is the per-project config file inside AgentsDirName.
const SchemaVersion = 1
SchemaVersion is the current major version of the on-disk config format. Bump when making a breaking change; older versions are rejected at load time with a clear error suggesting the upgrade path.
Variables ¶
This section is empty.
Functions ¶
func Find ¶
Find walks up from startDir looking for a directory named .agents/. On match it returns the absolute path of that directory and ok=true. When no match is found up to the filesystem root, ok=false (not an error).
Types ¶
type AgentConfig ¶
type AgentConfig struct {
MaxSteps int `json:"max_steps,omitempty"`
}
AgentConfig tunes runtime agent behavior.
type AnthropicConfig ¶
type AnthropicConfig struct {
APIKey string `json:"api_key,omitempty"`
Vertex *VertexConfig `json:"vertex,omitempty"`
}
AnthropicConfig holds Claude-specific settings for the anthropic provider family. APIKey is used by the first-party "anthropic" provider (api.anthropic.com); Vertex is used by "anthropic-vertex" (Claude served via Google Vertex AI).
type Config ¶
type Config struct {
Version int `json:"version"`
Model ModelConfig `json:"model"`
Permissions PermissionsConfig `json:"permissions,omitempty"`
PathScope PathScopeConfig `json:"path_scope,omitempty"`
Agent AgentConfig `json:"agent,omitempty"`
ToolOutput ToolOutputConfig `json:"tool_output,omitempty"`
Tools ToolsConfig `json:"tools,omitempty"`
Mock MockConfig `json:"mock,omitempty"`
OTEL OTELConfig `json:"otel,omitempty"`
}
Config is the in-memory representation of `.agents/config.json`.
All sub-sections except Model have sensible zero-valued defaults, so a minimal `config.json` only needs to set what the user wants to override.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with all fields populated by sensible defaults. Override-then-merge happens at Load time.
func Load ¶
Load reads <agentsDir>/config.json, merges it over DefaultConfig(), and validates the result. agentsDir must be the absolute path returned by Find. Missing config.json is treated as "use defaults" (not an error) so that an empty .agents/ directory still yields a working config.
func LoadOrDefault ¶
LoadOrDefault is the convenience entry point used by main: it walks up from startDir, loads `.agents/config.json` if found, otherwise returns pristine defaults. The returned agentsDir is "" when no .agents/ was discovered — callers can use that to skip writes that require a project.
type MockConfig ¶
type MockConfig struct {
Script string `json:"script,omitempty"`
Strict bool `json:"strict,omitempty"`
Record string `json:"record,omitempty"`
}
MockConfig configures the mock providers (echo, scripted) and the orthogonal recording wrapper.
Script is the path to a JSONL transcript consumed by the scripted provider; it's required when model.provider is "scripted".
Strict makes the scripted provider assert that each incoming request's Contents JSON-equal the recorded request. Off by default — the typical use is replaying without caring about prompt drift.
Record is a path to write a JSONL recording of every LLM turn. Works with any provider, not just the mocks; lives in MockConfig because it shares the file format the scripted provider consumes.
type ModelConfig ¶
type ModelConfig struct {
Provider string `json:"provider,omitempty"`
Name string `json:"name"`
APIKey string `json:"api_key,omitempty"`
Vertex *VertexConfig `json:"vertex,omitempty"`
Anthropic *AnthropicConfig `json:"anthropic,omitempty"`
Pricing *PricingConfig `json:"pricing,omitempty"`
}
ModelConfig selects the LLM provider and model.
Provider: one of "gemini", "vertex", "anthropic". When empty, the resolver auto-detects from the environment (see models.Resolve). Name: a model ID, e.g. "gemini-3.1-pro-preview" or "claude-opus-4-7". APIKey: optional inline key for Provider="gemini"; usually unset and read from GOOGLE_API_KEY at runtime. Vertex: required when Provider="vertex"; project + location. Anthropic: optional credentials for Provider="anthropic"; usually unset and read from ANTHROPIC_API_KEY at runtime.
type OTELConfig ¶
type OTELConfig struct {
Exporter string `json:"exporter,omitempty"` // "none" | "console" | "otlp"
Endpoint string `json:"endpoint,omitempty"`
}
OTELConfig configures the OpenTelemetry exporter.
type PathScopeConfig ¶
type PathScopeConfig struct {
Allow []string `json:"allow,omitempty"`
}
PathScopeConfig holds extra paths that file tools may read/write outside the default project + user-home scope. Patterns may be exact paths or directory globs (terminating "/...") and are typically appended via the "Always allow this path/tree" prompt path.
type PermissionsConfig ¶
type PermissionsConfig struct {
Mode string `json:"mode,omitempty"` // "ask" | "allow" | "yolo"
Allow []string `json:"allow,omitempty"` // pattern allowlist
Deny []string `json:"deny,omitempty"` // pattern denylist
}
PermissionsConfig configures the permission gate.
type PricingConfig ¶
type PricingConfig struct {
InputPerMTok float64 `json:"input_per_mtok,omitempty"`
OutputPerMTok float64 `json:"output_per_mtok,omitempty"`
}
PricingConfig overrides the built-in price table for cost estimation.
type ToolOutputConfig ¶
type ToolOutputConfig struct {
MaxBytes int `json:"max_bytes,omitempty"`
MaxLines int `json:"max_lines,omitempty"`
PerTool map[string]ToolOutputPerToolCaps `json:"per_tool,omitempty"`
}
ToolOutputConfig caps tool result size before it enters model context.
type ToolOutputPerToolCaps ¶
type ToolOutputPerToolCaps struct {
MaxBytes int `json:"max_bytes,omitempty"`
MaxLines int `json:"max_lines,omitempty"`
}
ToolOutputPerToolCaps overrides global tool-output limits for one tool.
type ToolsConfig ¶
type ToolsConfig struct {
Disable []string `json:"disable,omitempty"`
}
ToolsConfig configures the bundled CLI's built-in tool suite.
Disable lists tools to turn off. Names must match the canonical built-in names (see tools.BuiltinToolNames). Unknown names cause a startup error from tools.BuiltinTools.Disable, so typos fail loudly rather than silently leaving a tool on.
The CLI's --disable-tools flag composes with this list by union; --no-builtin-tools disables the entire suite and makes Disable moot.
type VertexConfig ¶
VertexConfig holds GCP-specific settings for the vertex provider.