Skip to main content

a3s_code_core/config/
mod.rs

1//! Configuration module for A3S Code
2//!
3//! Provides configuration for:
4//! - LLM providers and models (defaultModel in "provider/model" format, providers)
5//! - Queue configuration (a3s-lane integration)
6//! - Search configuration (a3s-search integration)
7//! - Directories for dynamic skill and agent loading
8//!
9//! Configuration is loaded from ACL-compatible files or strings.
10//! Existing `.acl` config filenames are still accepted for compatibility.
11//! JSON support has been removed.
12
13pub mod agent_dir;
14mod loader;
15mod provider;
16mod search;
17#[cfg(test)]
18mod tests;
19
20pub use agent_dir::{AgentDir, ScheduleSpec, ScriptToolLimits, ScriptToolSpec, ToolSpec};
21pub use provider::{ModelConfig, ModelCost, ModelLimit, ModelModalities, ProviderConfig};
22pub use search::{
23    BrowserBackend, DocumentCacheConfig, DocumentOcrConfig, DocumentParserConfig, HeadlessConfig,
24    SearchConfig, SearchEngineConfig, SearchHealthConfig,
25};
26
27use crate::memory::MemoryConfig;
28use serde::{Deserialize, Serialize};
29use std::path::PathBuf;
30
31// ============================================================================
32// Storage Configuration
33// ============================================================================
34
35/// Session storage backend type
36#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq, Hash)]
37#[serde(rename_all = "lowercase")]
38pub enum StorageBackend {
39    /// In-memory storage (no persistence)
40    Memory,
41    /// File-based storage (JSON files)
42    #[default]
43    File,
44    /// Custom external storage (Redis, PostgreSQL, etc.)
45    ///
46    /// Requires a `SessionStore` implementation registered on `AgentSession` options.
47    /// Use `storage_url` in config to pass connection details.
48    Custom,
49}
50
51// ============================================================================
52// Main Configuration
53// ============================================================================
54
55/// Automatic subagent delegation controls.
56#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
57#[serde(default, rename_all = "camelCase")]
58pub struct AutoDelegationConfig {
59    /// Enable runtime-driven automatic child agent delegation.
60    pub enabled: bool,
61    /// Allow automatic delegation to launch multiple child agents in parallel.
62    ///
63    /// Manual `parallel_task` calls remain available when this is false.
64    #[serde(alias = "auto_parallel")]
65    pub auto_parallel: bool,
66    /// Allow model-visible manual `task` and `parallel_task` delegation tools.
67    ///
68    /// Set this to false for cost control or debugging when child-agent tools
69    /// should be absent from the session tool surface. This is not a security
70    /// sandbox: the parent agent may still have other tools such as `bash`,
71    /// MCP tools, or skills.
72    #[serde(alias = "allow_manual_delegation")]
73    pub allow_manual_delegation: bool,
74    /// Minimum local confidence required to auto-delegate a child task.
75    pub min_confidence: f32,
76    /// Maximum number of automatic child tasks per user request.
77    pub max_tasks: usize,
78}
79
80impl Default for AutoDelegationConfig {
81    fn default() -> Self {
82        Self {
83            enabled: false,
84            auto_parallel: true,
85            allow_manual_delegation: true,
86            min_confidence: 0.72,
87            max_tasks: 4,
88        }
89    }
90}
91
92/// Optional A3S OS endpoint used by hosts for account login.
93#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
94#[serde(rename_all = "camelCase")]
95pub struct OsConfig {
96    /// Base address of the user's A3S OS instance.
97    #[serde(alias = "url", alias = "baseUrl", alias = "base_url")]
98    pub address: String,
99}
100
101/// Configuration for A3S Code
102#[derive(Debug, Clone, Serialize, Deserialize, Default)]
103#[serde(rename_all = "camelCase")]
104pub struct CodeConfig {
105    /// Default model in "provider/model" format (e.g., "anthropic/claude-sonnet-4-20250514")
106    #[serde(default, alias = "default_model")]
107    pub default_model: Option<String>,
108
109    /// Provider configurations
110    #[serde(default)]
111    pub providers: Vec<ProviderConfig>,
112
113    /// Session storage backend
114    #[serde(default)]
115    pub storage_backend: StorageBackend,
116
117    /// Sessions directory (for file backend)
118    #[serde(skip_serializing_if = "Option::is_none")]
119    pub sessions_dir: Option<PathBuf>,
120
121    /// Connection URL for custom storage backend (e.g., "redis://localhost:6379", "postgres://user:pass@localhost/a3s")
122    #[serde(default, skip_serializing_if = "Option::is_none")]
123    pub storage_url: Option<String>,
124
125    /// Directories to scan for skill files (*.md with tool definitions)
126    #[serde(default, alias = "skill_dirs")]
127    pub skill_dirs: Vec<PathBuf>,
128
129    /// Directories to scan for agent files (*.yaml or *.md)
130    #[serde(default, alias = "agent_dirs")]
131    pub agent_dirs: Vec<PathBuf>,
132
133    /// Maximum tool execution rounds per turn (default: 25)
134    #[serde(default, alias = "max_tool_rounds")]
135    pub max_tool_rounds: Option<usize>,
136
137    /// Maximum sibling branches/tools to run concurrently in bounded parallel fan-out paths.
138    #[serde(default, alias = "max_parallel_tasks")]
139    pub max_parallel_tasks: Option<usize>,
140
141    /// Global automatic child-agent delegation settings.
142    #[serde(default, alias = "auto_delegation")]
143    pub auto_delegation: AutoDelegationConfig,
144
145    /// Convenience global kill switch for automatic parallel child-agent fan-out.
146    ///
147    /// When set, overrides `auto_delegation.auto_parallel`.
148    #[serde(default, alias = "auto_parallel")]
149    pub auto_parallel: Option<bool>,
150
151    /// Thinking/reasoning budget in tokens
152    #[serde(default, alias = "thinking_budget")]
153    pub thinking_budget: Option<usize>,
154
155    /// Memory system configuration
156    #[serde(default, skip_serializing_if = "Option::is_none")]
157    pub memory: Option<MemoryConfig>,
158
159    /// Queue configuration (a3s-lane integration)
160    #[serde(default, skip_serializing_if = "Option::is_none")]
161    pub queue: Option<crate::queue::SessionQueueConfig>,
162
163    /// Search configuration (a3s-search integration)
164    #[serde(default, skip_serializing_if = "Option::is_none")]
165    pub search: Option<SearchConfig>,
166
167    /// Optional A3S OS endpoint. When set, hosts may enable account login.
168    #[serde(default, skip_serializing_if = "Option::is_none")]
169    pub os: Option<OsConfig>,
170
171    /// Built-in document context extraction configuration.
172    #[serde(default, skip_serializing_if = "Option::is_none")]
173    pub document_parser: Option<DocumentParserConfig>,
174
175    /// MCP server configurations
176    #[serde(default, alias = "mcp_servers")]
177    pub mcp_servers: Vec<crate::mcp::McpServerConfig>,
178}