Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub defaults: Defaults,
    pub models: AgentModels,
    pub auto: AutoConfig,
    pub ollama: OllamaConfig,
    pub listen: ListenConfig,
}
Expand description

Root configuration structure.

Fields§

§defaults: Defaults

Default settings

§models: AgentModels

Per-agent model defaults

§auto: AutoConfig

Auto-selection settings

§ollama: OllamaConfig

Ollama-specific settings

§listen: ListenConfig

Listen command settings

Implementations§

Source§

impl Config

Source

pub const VALID_PROVIDERS: &'static [&'static str]

Valid provider names (including “auto”).

Source

pub const VALID_KEYS: &'static [&'static str]

All valid config keys for listing/discovery.

Source

pub fn load(root: Option<&str>) -> Result<Self>

Load configuration from ~/.zag/projects/<id>/zag.toml.

The project ID is derived from the git repo root or explicit --root. Returns default config if file doesn’t exist.

Source

pub fn save(&self, root: Option<&str>) -> Result<()>

Save configuration to ~/.zag/projects/<id>/zag.toml.

Creates the directory if it doesn’t exist.

Source

pub fn init(root: Option<&str>) -> Result<bool>

Initialize config file with defaults if it doesn’t exist.

Returns true if a new config was created, false if it already existed.

Source

pub fn global_base_dir() -> PathBuf

Get the global base directory (~/.zag).

Source

pub fn sanitize_path(path: &str) -> String

Sanitize an absolute path into a directory name. Strips leading / and replaces / with -.

Source

pub fn config_path(root: Option<&str>) -> PathBuf

Get the path to the config file.

Source

pub fn agent_dir(root: Option<&str>) -> PathBuf

Get the project directory path (for sessions, etc.).

Source

pub fn global_logs_dir() -> PathBuf

Get the global logs directory path.

Source

pub fn get_model(&self, agent: &str) -> Option<&str>

Get the default model for a specific agent, if configured. Checks agent-specific model first, then falls back to defaults.model.

Source

pub fn default_model(&self) -> Option<&str>

Get the global default model (without agent-specific override).

Source

pub fn ollama_model(&self) -> &str

Get the ollama model name (default: “qwen3.5”).

Source

pub fn ollama_size(&self) -> &str

Get the ollama default size (default: “9b”).

Source

pub fn ollama_size_for<'a>(&'a self, size: &'a str) -> &'a str

Get the ollama size for a model size alias, with config override.

Source

pub fn auto_approve(&self) -> bool

Check if auto-approve is enabled by default.

Source

pub fn max_turns(&self) -> Option<u32>

Get the default max turns, if configured.

Source

pub fn system_prompt(&self) -> Option<&str>

Get the default system prompt, if configured.

Source

pub fn provider(&self) -> Option<&str>

Get the default provider, if configured.

Source

pub fn auto_provider(&self) -> Option<&str>

Get the auto-selection provider, if configured.

Source

pub fn auto_model(&self) -> Option<&str>

Get the auto-selection model, if configured.

Source

pub fn listen_format(&self) -> Option<&str>

Get the listen output format, if configured.

Source

pub fn listen_timestamp_format(&self) -> &str

Get the listen timestamp format (strftime-style, default: “%H:%M:%S”).

Source

pub fn get_value(&self, key: &str) -> Option<String>

Get a config value by dot-notation key. Get a config value by dot-notation key.

Source

pub fn set_value(&mut self, key: &str, value: &str) -> Result<()>

Set a config value by dot-notation key. Validates inputs.

Source

pub fn unset_value(&mut self, key: &str) -> Result<()>

Unset a config value by dot-notation key (revert to default).

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Config

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

impl<'de> Deserialize<'de> for Config

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 Config

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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
Source§

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