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