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/// Configuration for A3S Code
93#[derive(Debug, Clone, Serialize, Deserialize, Default)]
94#[serde(rename_all = "camelCase")]
95pub struct CodeConfig {
96 /// Default model in "provider/model" format (e.g., "anthropic/claude-sonnet-4-20250514")
97 #[serde(default, alias = "default_model")]
98 pub default_model: Option<String>,
99
100 /// Provider configurations
101 #[serde(default)]
102 pub providers: Vec<ProviderConfig>,
103
104 /// Session storage backend
105 #[serde(default)]
106 pub storage_backend: StorageBackend,
107
108 /// Sessions directory (for file backend)
109 #[serde(skip_serializing_if = "Option::is_none")]
110 pub sessions_dir: Option<PathBuf>,
111
112 /// Connection URL for custom storage backend (e.g., "redis://localhost:6379", "postgres://user:pass@localhost/a3s")
113 #[serde(default, skip_serializing_if = "Option::is_none")]
114 pub storage_url: Option<String>,
115
116 /// Directories to scan for skill files (*.md with tool definitions)
117 #[serde(default, alias = "skill_dirs")]
118 pub skill_dirs: Vec<PathBuf>,
119
120 /// Directories to scan for agent files (*.yaml or *.md)
121 #[serde(default, alias = "agent_dirs")]
122 pub agent_dirs: Vec<PathBuf>,
123
124 /// Maximum tool execution rounds per turn (default: 25)
125 #[serde(default, alias = "max_tool_rounds")]
126 pub max_tool_rounds: Option<usize>,
127
128 /// Maximum sibling branches/tools to run concurrently in bounded parallel fan-out paths.
129 #[serde(default, alias = "max_parallel_tasks")]
130 pub max_parallel_tasks: Option<usize>,
131
132 /// Global automatic child-agent delegation settings.
133 #[serde(default, alias = "auto_delegation")]
134 pub auto_delegation: AutoDelegationConfig,
135
136 /// Convenience global kill switch for automatic parallel child-agent fan-out.
137 ///
138 /// When set, overrides `auto_delegation.auto_parallel`.
139 #[serde(default, alias = "auto_parallel")]
140 pub auto_parallel: Option<bool>,
141
142 /// Thinking/reasoning budget in tokens
143 #[serde(default, alias = "thinking_budget")]
144 pub thinking_budget: Option<usize>,
145
146 /// Memory system configuration
147 #[serde(default, skip_serializing_if = "Option::is_none")]
148 pub memory: Option<MemoryConfig>,
149
150 /// Queue configuration (a3s-lane integration)
151 #[serde(default, skip_serializing_if = "Option::is_none")]
152 pub queue: Option<crate::queue::SessionQueueConfig>,
153
154 /// Search configuration (a3s-search integration)
155 #[serde(default, skip_serializing_if = "Option::is_none")]
156 pub search: Option<SearchConfig>,
157
158 /// Built-in document context extraction configuration.
159 #[serde(default, skip_serializing_if = "Option::is_none")]
160 pub document_parser: Option<DocumentParserConfig>,
161
162 /// MCP server configurations
163 #[serde(default, alias = "mcp_servers")]
164 pub mcp_servers: Vec<crate::mcp::McpServerConfig>,
165}