Config
Source: core/config/config.gleam, core/config/helpers.gleam
The config loader reads .env (secrets) and agent.toml (configuration) at startup and populates OS environment variables via envoy. It is one of the Blessed Violators (violator #1) -- the only core module that imports every service and plugin cfg module, because it must delegate TOML parsing to each submodule.
Loading priority: environment variable > TOML value > hardcoded default.
Key Functions
config.gleam
load_env()-- reads.envandagent.toml, sets environment variables. Called once at startup.load_config()-- parses agent-level settings from TOML, then delegates to eachcfgmodule'sload(toml)function.get(key)-- returnsResult(String, Nil)for an env var. Does not panic.require(key)-- likegetbut panics if the variable is missing. Use for mandatory vars.get_or(key, default)-- returns the env var value or a default string.get_api_key()-- readsDEEPSEEK_API_KEY.
Agent identity getters (get_working_dir, get_default_persona, get_timezone, etc.) live here as truly-core settings. Session lifecycle (prune, crash recovery) and approval configuration also live here.
helpers.gleam
Shared utilities for env var access and TOML loading, used by both config.gleam and per-module cfg.gleam files:
get_or(key, default)-- get a string env var with a defaultget_or_int(key, default)-- get an integer env var with a defaultget_or_float(key, default)-- get a float env var with a defaultget_or_bool(key, default)-- get a boolean env var (truthy:"true","1","yes")get_or_list(key, default)-- get a comma-separated list env varresolve_home(path)-- expand~to the user's home directoryset_default(key, toml_val, path)-- set an env var from a TOML string, only if not already setset_default_int,set_default_float,set_default_bool,set_default_list-- typed variants
Related Pages
- Blessed Violators -- Why this module is allowed to import from everywhere
- Behaviours -- Behaviour records that config maps to service constructors