Skip to main content

AppConfig

Struct AppConfig 

Source
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: AgentConfig

Agent configuration

§server: ServerConfig

Server configuration

§mcp: McpConfig

MCP (Model Context Protocol) configuration

§tui: TuiConfig

TUI configuration

§prompts: PromptConfig

Prompt configuration

Implementations§

Source§

impl AppConfig

Source

pub fn new() -> Self

Create a new app config with defaults

Source

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:

  1. ./agent.toml
  2. ~/.config/agent/config.toml

If no config file is found, returns defaults with env var overrides.

Source

pub fn load_from_file(path: &Path) -> Result<Self, ConfigError>

Load configuration from a specific file

Source

pub fn parse_toml(content: &str) -> Result<Self, ConfigError>

Parse configuration from TOML string

Source

pub fn discover_config_file() -> Option<PathBuf>

Discover config file in standard locations

Searches in order:

  1. ./agent.toml (current directory)
  2. ~/.config/agent/config.toml (user config)
Source

pub fn apply_env_overrides(&mut self)

Apply environment variable overrides to the configuration

Supported environment variables:

  • ANTHROPIC_API_KEY - API key for Anthropic provider
  • OPENAI_API_KEY - API key for OpenAI provider
  • GEMINI_API_KEY - API key for Gemini provider
  • AGENT_MODEL - Override the model
  • AGENT_PROVIDER - Override the provider
  • AGENT_MAX_TOKENS - Override max tokens
  • AGENT_HOST - Override server host
  • AGENT_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

Source

pub fn api_key(&self) -> Option<String>

Get the API key for the current provider from config or environment

Checks in order:

  1. Config file api_key
  2. Provider-specific env var (ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY)
Source

pub fn with_agent(self, agent: AgentConfig) -> Self

Set the agent configuration

Source

pub fn with_server(self, server: ServerConfig) -> Self

Set the server configuration

Source

pub fn with_mcp(self, mcp: McpConfig) -> Self

Set the MCP configuration

Source

pub fn save_to_file(&self, path: &Path) -> Result<(), ConfigError>

Save configuration to a TOML file

Source

pub fn default_config_path() -> Option<PathBuf>

Get the default config file path in user config directory

Trait Implementations§

Source§

impl Clone for AppConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AppConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AppConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for AppConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AppConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more