Documentation
¶
Overview ¶
Package config loads, validates, and redacts Ozy's single configuration file (SPEC.md §11). Configuration is explicit and inspectable: downstream servers are declared under the opencode-shaped `mcp` key, secrets are supplied through {env:NAME} references rather than literals, unresolved references are reported as diagnostics, and a redacted view is available for `ozy doctor`.
Index ¶
- Constants
- func DefaultPath() string
- func Home() string
- func WriteStarter(path string) error
- type BudgetsConfig
- type CacheConfig
- type CallToolBudget
- type Config
- type DescribeToolBudget
- type EmbeddingConfig
- type FindToolBudget
- type LexicalSearch
- type Loaded
- type MissingRef
- type SearchConfig
- type SemanticSearch
- type ServerConfig
- type SurfaceConfig
Constants ¶
const ( VectorBackendTurbovec = "turbovec" VectorBackendFAISS = "faiss" )
VectorBackend names the on-disk vector index implementation used by the embedding sidecar. turbovec is the zero-config default; faiss is an opt-in alternative chosen before the first index is built.
const ( DefaultCacheTTLSeconds = 300 DefaultCacheMaxEntries = 1024 )
Cache defaults applied when the `cache` section omits a field.
const DefaultCallTimeoutMillis = 60000
DefaultCallTimeoutMillis bounds a single brokered callTool invocation (connect plus execute) when a server entry omits `callTimeout`. Invocation gets its own generous clock: real tool calls routinely outlive the 5s discovery budget (process spawn, queries, fetches).
const DefaultDiscoveryTimeoutMillis = 5000
DefaultDiscoveryTimeoutMillis matches opencode's default MCP tool discovery timeout when a server entry omits `timeout`.
const DefaultEmbeddingModel = "BAAI/bge-small-en-v1.5"
DefaultEmbeddingModel is the FastEmbed model id used when configuration does not name one. Documented in SPEC.md §10.4 and pinned in the sidecar.
const DefaultFindToolMaxResults = 5
DefaultFindToolMaxResults bounds the candidates a findTool response surfaces (selected plus alternatives) when budgets.findTool.maxResults is omitted.
const DefaultVectorBackend = VectorBackendTurbovec
DefaultVectorBackend is the resolved vector backend when configuration omits the field. It must match the default the proposal promises so a user who enables semantic search without picking a backend gets turbovec.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath returns the default configuration location, honoring OZY_CONFIG before the OS user config directory.
func WriteStarter ¶
WriteStarter writes the starter configuration to path, creating parent directories. It refuses to overwrite an existing file so a user's config is never clobbered.
Types ¶
type BudgetsConfig ¶
type BudgetsConfig struct {
FindTool FindToolBudget `json:"findTool,omitempty"`
DescribeTool DescribeToolBudget `json:"describeTool,omitempty"`
CallTool CallToolBudget `json:"callTool,omitempty"`
}
BudgetsConfig holds per-tool response budgets (SPEC.md §13).
type CacheConfig ¶
type CacheConfig struct {
Enabled bool `json:"enabled"`
TTLSeconds int `json:"ttlSeconds"`
MaxEntries int `json:"maxEntries"`
}
CacheConfig toggles and tunes the broker result cache. When `enabled` is omitted it defaults to true. TTLSeconds and MaxEntries default via applyDefaults when left at zero.
func (CacheConfig) TTL ¶
func (c CacheConfig) TTL() time.Duration
TTL returns the configured cache entry lifetime.
func (*CacheConfig) UnmarshalJSON ¶
func (c *CacheConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON applies the default-on cache semantics.
type CallToolBudget ¶
type CallToolBudget struct {
MaxResultBytes int `json:"maxResultBytes"`
}
CallToolBudget bounds callTool result payloads.
type Config ¶
type Config struct {
Schema string `json:"$schema,omitempty"`
Version int `json:"version,omitempty"`
MCP map[string]ServerConfig `json:"mcp,omitempty"`
Embedding EmbeddingConfig `json:"embedding,omitempty"`
Search SearchConfig `json:"search,omitempty"`
Budgets BudgetsConfig `json:"budgets,omitempty"`
Cache CacheConfig `json:"cache,omitempty"`
Surface SurfaceConfig `json:"surface,omitempty"`
}
Config is the typed JSONC configuration model. Downstream MCP servers live in MCP, while Ozy-owned sections remain top-level siblings.
type DescribeToolBudget ¶
type DescribeToolBudget struct {
IncludeExamples bool `json:"includeExamples"`
}
DescribeToolBudget bounds describeTool responses.
type EmbeddingConfig ¶
type EmbeddingConfig struct {
Provider string `json:"provider,omitempty"`
Required bool `json:"required"`
VectorBackend string `json:"vectorBackend,omitempty"`
Model string `json:"model,omitempty"`
}
EmbeddingConfig configures the optional embedding worker and its vector index. VectorBackend defaults to "turbovec"; Model defaults to the FastEmbed CPU-friendly default. The vector dimension is derived from the selected model at runtime by the sidecar — it is not configured.
func (*EmbeddingConfig) UnmarshalJSON ¶
func (e *EmbeddingConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON applies the documented defaults for omitted fields.
type FindToolBudget ¶
type FindToolBudget struct {
MaxResults int `json:"maxResults"`
IncludeFullSchemas bool `json:"includeFullSchemas"`
}
FindToolBudget bounds findTool responses. MaxResults caps selected plus alternatives; IncludeFullSchemas forces schema inlining regardless of the fast-path size threshold.
func (FindToolBudget) EffectiveMaxResults ¶
func (b FindToolBudget) EffectiveMaxResults() int
EffectiveMaxResults returns MaxResults with the documented default applied.
type LexicalSearch ¶
type LexicalSearch struct {
Enabled bool `json:"enabled"`
}
LexicalSearch toggles the mandatory lexical baseline.
type Loaded ¶
type Loaded struct {
Path string
Raw *Config
Resolved *Config
Missing []MissingRef
}
Loaded is the outcome of loading configuration: the raw (pre-substitution) view safe to display, the resolved view for runtime use, the source path, and any unresolved environment references.
type MissingRef ¶
type MissingRef struct {
Var string `json:"var"`
Server string `json:"server"`
Field string `json:"field"`
}
MissingRef records an unresolved {env:NAME} reference found during loading.
type SearchConfig ¶
type SearchConfig struct {
Lexical LexicalSearch `json:"lexical,omitempty"`
Semantic SemanticSearch `json:"semantic,omitempty"`
}
SearchConfig configures the lexical baseline and optional semantic search. When the `semantic` section is entirely omitted, semantic search is treated as enabled (the default-on behavior) — see UnmarshalJSON.
func (*SearchConfig) UnmarshalJSON ¶
func (s *SearchConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON applies the default-on semantic search when the semantic sub-section is omitted. A pointer distinguishes omitted from explicit zero.
type SemanticSearch ¶
SemanticSearch toggles optional semantic search and whether it is required. When `enabled` is omitted, semantic search is treated as ON (default-on for the out-of-the-box hybrid experience). Set `enabled: false` explicitly to opt back into lexical-only.
func (*SemanticSearch) UnmarshalJSON ¶
func (s *SemanticSearch) UnmarshalJSON(data []byte) error
UnmarshalJSON applies the default-on semantic semantics.
type ServerConfig ¶
type ServerConfig struct {
Type string `json:"type"`
Command []string `json:"command,omitempty"`
CWD string `json:"cwd,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
URL string `json:"url,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
OAuth json.RawMessage `json:"oauth,omitempty"`
Enabled bool `json:"enabled"`
Timeout int `json:"timeout,omitempty"`
CallTimeout int `json:"callTimeout,omitempty"`
}
ServerConfig describes one downstream MCP server using the opencode shape.
func (ServerConfig) DiscoveryTimeout ¶
func (s ServerConfig) DiscoveryTimeout() time.Duration
DiscoveryTimeout returns the per-server total discovery budget.
func (ServerConfig) InvocationTimeout ¶
func (s ServerConfig) InvocationTimeout() time.Duration
InvocationTimeout returns the per-server callTool budget (connect plus execute). It is independent of DiscoveryTimeout so a slow tool call is never killed by the short discovery clock.
func (ServerConfig) IsEnabled ¶
func (s ServerConfig) IsEnabled() bool
IsEnabled reports whether Ozy should connect to this server.
func (*ServerConfig) UnmarshalJSON ¶
func (s *ServerConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON applies opencode MCP defaults: omitted `enabled` means enabled, and omitted `timeout` means the documented 5000ms discovery timeout.
type SurfaceConfig ¶
type SurfaceConfig struct {
CapabilityBreadcrumb bool `json:"capabilityBreadcrumb"`
}
SurfaceConfig configures Ozy's agent-facing MCP surface. CapabilityBreadcrumb toggles the bounded list of available downstream servers appended to the findTool description; it is on by default for richer pre-call context.
func (*SurfaceConfig) UnmarshalJSON ¶
func (s *SurfaceConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON applies the default-on capability breadcrumb.