config

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package config provides loading and aggregation of Genie configuration.

It solves the problem of unifying all component settings (model, MCP, tools, messenger, cron, data sources, security, etc.) from files (.genie.toml, .genie.yaml) and environment variables. LoadGenieConfig resolves secret placeholders (${VAR}) via a SecretProvider and applies defaults so the rest of the application receives a single GenieConfig struct. Without this package, each component would read config independently and secret resolution would be scattered.

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   = "dev"
	BuildDate = ""
)

Functions

func LoadMCPConfig

func LoadMCPConfig(ctx context.Context, sp security.SecretProvider, path string) (mcp.MCPConfig, error)

LoadMCPConfig loads only the MCP section from the config file at path. It uses the same path resolution as LoadGenieConfig (path can be empty to mean "no config") and expands ${VAR} via the given SecretProvider. This allows "genie mcp validate" to run without requiring model provider API keys.

func WarnMissingTokens

func WarnMissingTokens(ctx context.Context, cfg GenieConfig, configPath string)

WarnMissingTokens logs a warning for each model provider that typically requires an API key but has an empty token. Call this after the final config pass so that runtimevar-backed secrets have been resolved. Without this separation, the two-pass loading in cmd/root.go would emit spurious warnings during the preliminary env-only pass.

Types

type GenieConfig

type GenieConfig struct {
	// AgentName is the user-chosen name for the agent. It gives the agent a
	// personality and is used for the default audit log path
	// (~/.genie/{agent_name}.<yyyy_mm_dd>.ndjson).
	AgentName string `yaml:"agent_name,omitempty" toml:"agent_name,omitempty"`
	// Persona configures the project-level coding standards and agent capabilities file.
	Persona PersonaConfig `yaml:"persona,omitempty" toml:"persona,omitempty"`
	// PersonaTokenThreshold is the maximum recommended token length for the
	// persona/system prompt. If exceeded at boot, a warning is emitted.
	// Defaults to 2000.
	PersonaTokenThreshold int `yaml:"persona_token_threshold,omitempty" toml:"persona_token_threshold,omitempty"`
	// AuditPath overrides the default audit log path. When set, the auditor
	// writes to this single file (no date rotation). Used for tests or custom paths.
	AuditPath       string                    `yaml:"audit_path,omitempty" toml:"audit_path,omitempty"`
	ModelConfig     modelprovider.ModelConfig `yaml:"model_config,omitempty" toml:"model_config,omitempty"`
	SkillLoadConfig tools.SkillLoadConfig     `yaml:"skill_load,omitempty" toml:"skill_load,omitempty"`
	MCP             mcp.MCPConfig             `yaml:"mcp,omitempty" toml:"mcp,omitempty"`
	WebSearch       websearch.Config          `yaml:"web_search,omitempty" toml:"web_search,omitempty"`
	VectorMemory    vector.Config             `yaml:"vector_memory,omitempty" toml:"vector_memory,omitempty"`
	Graph           graph.Config              `yaml:"graph,omitempty" toml:"graph,omitempty"`
	Messenger       messenger.Config          `yaml:"messenger,omitempty" toml:"messenger,omitempty"`
	Browser         browser.Config            `yaml:"browser,omitempty" toml:"browser,omitempty"`
	SCM             scm.Config                `yaml:"scm,omitempty" toml:"scm,omitempty"`
	GHCli           ghcli.Config              `yaml:"ghcli,omitempty" toml:"ghcli,omitempty"`

	ProjectManagement pm.Config `yaml:"project_management,omitempty" toml:"project_management,omitempty"`

	Email        email.Config        `yaml:"email,omitempty" toml:"email,omitempty"`
	GDrive       gdrive.Config       `yaml:"google_drive,omitempty" toml:"google_drive,omitempty"`
	Notification notification.Config `yaml:"notification,omitempty" toml:"notification,omitempty"`
	HITL         hitl.Config         `yaml:"hitl,omitempty" toml:"hitl,omitempty"`
	DBConfig     db.Config           `yaml:"db_config,omitempty" toml:"db_config,omitempty"`
	Langfuse     langfuse.Config     `yaml:"langfuse,omitempty" toml:"langfuse,omitempty"`

	Cron cron.Config `yaml:"cron,omitempty" toml:"cron,omitempty"`
	// Unified data sources configuration
	DataSources datasource.Config `yaml:"data_sources,omitempty" toml:"data_sources,omitempty"`

	Security security.Config           `yaml:"security,omitempty" toml:"security,omitempty"`
	PII      pii.Config                `yaml:"pii,omitempty" toml:"pii,omitempty"`
	Toolwrap toolwrap.MiddlewareConfig `yaml:"toolwrap,omitempty" toml:"toolwrap,omitempty"`

	// ShellTool configures the run_shell tool's security behaviour.
	// Use shell_tool.allowed_env to control which environment variables
	// are visible to shell commands (principle of least privilege). When
	// shell_tool.allowed_env is unset or empty, only PATH is exposed to
	// shell commands; any additional environment variables must be listed
	// explicitly.
	ShellTool unixtools.ShellToolConfig `yaml:"shell_tool,omitempty" toml:"shell_tool,omitempty"`

	// DisablePensieve disables the Pensieve context management tools
	// (delete_context, check_budget, note, read_notes) from arXiv:2602.12108.
	// When true, the agent can actively manage its own context window.
	// delete_context and note require HITL approval; check_budget and
	// read_notes are read-only and auto-approved.
	DisablePensieve bool `yaml:"disable_pensieve,omitempty" toml:"disable_pensieve,omitempty"`

	// HalGuard configures the hallucination guard that validates
	// sub-agent goals (pre-check) and outputs (post-check).
	// See halguard.DefaultConfig() for defaults.
	HalGuard halguard.Config `yaml:"halguard,omitempty" toml:"halguard,omitempty"`

	// SemanticRouter configures the fast embedding-based intent routing,
	// jailbreak detection, and response semantic caching.
	SemanticRouter semanticrouter.Config `yaml:"semantic_router,omitempty" toml:"semantic_router,omitempty"`
}

func LoadGenieConfig

func LoadGenieConfig(ctx context.Context, sp security.SecretProvider, path string) (GenieConfig, error)

LoadGenieConfig loads the Genie configuration from a file, resolving secret-dependent defaults and ${VAR} placeholders through the given SecretProvider. Each ${NAME} occurrence in the config file is resolved by calling sp.GetSecret(ctx, NAME), which may consult runtimevar backends (GCP Secret Manager, AWS Secrets Manager, mounted files, etc.) or fall back to os.Getenv depending on the provider.

Passing security.NewEnvProvider() preserves the legacy os.Getenv behavior. Passing a security.Manager created from the config's [security.secrets] section enables runtimevar-backed resolution.

After interpolation, secret values are resolved via sp.GetSecret; empty or missing values are not logged here (use WarnMissingTokens or provider-specific validation if early surfacing of typos is needed).

type PersonaConfig added in v0.1.7

type PersonaConfig struct {
	// File is an optional path to a file whose contents are appended
	// to the agent's system prompt as project-level coding standards.
	// When empty, no persona content is loaded.
	File string `yaml:"file,omitempty" toml:"file,omitempty"`

	// DisableResume makes the generation of the agent's resume optional.
	// If disabled, the persona file is used as is.
	DisableResume bool `yaml:"disable_resume,omitempty" toml:"disable_resume,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL