pub struct AppConfig {
pub agent: AgentConfig,
pub server: ServerConfig,
pub mcp: McpConfig,
pub tui: TuiConfig,
pub prompts: PromptConfig,
}Expand description
Top-level application configuration
This combines all configuration sections into a single struct that can be loaded from a configuration file.
Fields§
§agent: AgentConfigAgent configuration
server: ServerConfigServer configuration
mcp: McpConfigMCP (Model Context Protocol) configuration
tui: TuiConfigTUI configuration
prompts: PromptConfigPrompt configuration
Implementations§
Source§impl AppConfig
impl AppConfig
Sourcepub fn load(path: Option<&Path>) -> Result<Self, ConfigError>
pub fn load(path: Option<&Path>) -> Result<Self, ConfigError>
Load configuration from file with environment variable overrides
§Arguments
path- Optional path to config file. If None, searches default locations.
§Config File Discovery
When no path is specified, searches in order:
./agent.toml~/.config/agent/config.toml
If no config file is found, returns defaults with env var overrides.
Sourcepub fn load_from_file(path: &Path) -> Result<Self, ConfigError>
pub fn load_from_file(path: &Path) -> Result<Self, ConfigError>
Load configuration from a specific file
Sourcepub fn parse_toml(content: &str) -> Result<Self, ConfigError>
pub fn parse_toml(content: &str) -> Result<Self, ConfigError>
Parse configuration from TOML string
Sourcepub fn discover_config_file() -> Option<PathBuf>
pub fn discover_config_file() -> Option<PathBuf>
Discover config file in standard locations
Searches in order:
./agent.toml(current directory)~/.config/agent/config.toml(user config)
Sourcepub fn apply_env_overrides(&mut self)
pub fn apply_env_overrides(&mut self)
Apply environment variable overrides to the configuration
Supported environment variables:
ANTHROPIC_API_KEY- API key for Anthropic providerOPENAI_API_KEY- API key for OpenAI providerGEMINI_API_KEY- API key for Gemini providerAGENT_MODEL- Override the modelAGENT_PROVIDER- Override the providerAGENT_MAX_TOKENS- Override max tokensAGENT_HOST- Override server hostAGENT_PORT- Override server port
If no provider is explicitly set (via config or AGENT_PROVIDER), the system auto-detects the provider based on available API keys in priority order: Anthropic > OpenAI > Gemini
Sourcepub fn api_key(&self) -> Option<String>
pub fn api_key(&self) -> Option<String>
Get the API key for the current provider from config or environment
Checks in order:
- Config file api_key
- Provider-specific env var (ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY)
Sourcepub fn with_agent(self, agent: AgentConfig) -> Self
pub fn with_agent(self, agent: AgentConfig) -> Self
Set the agent configuration
Sourcepub fn with_server(self, server: ServerConfig) -> Self
pub fn with_server(self, server: ServerConfig) -> Self
Set the server configuration
Sourcepub fn save_to_file(&self, path: &Path) -> Result<(), ConfigError>
pub fn save_to_file(&self, path: &Path) -> Result<(), ConfigError>
Save configuration to a TOML file
Sourcepub fn default_config_path() -> Option<PathBuf>
pub fn default_config_path() -> Option<PathBuf>
Get the default config file path in user config directory