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 /// Minimum local confidence required to auto-delegate a child task.
67 pub min_confidence: f32,
68 /// Maximum number of automatic child tasks per user request.
69 pub max_tasks: usize,
70}
71
72impl Default for AutoDelegationConfig {
73 fn default() -> Self {
74 Self {
75 enabled: false,
76 auto_parallel: true,
77 min_confidence: 0.72,
78 max_tasks: 4,
79 }
80 }
81}
82
83/// Configuration for A3S Code
84#[derive(Debug, Clone, Serialize, Deserialize, Default)]
85#[serde(rename_all = "camelCase")]
86pub struct CodeConfig {
87 /// Default model in "provider/model" format (e.g., "anthropic/claude-sonnet-4-20250514")
88 #[serde(default, alias = "default_model")]
89 pub default_model: Option<String>,
90
91 /// Provider configurations
92 #[serde(default)]
93 pub providers: Vec<ProviderConfig>,
94
95 /// Session storage backend
96 #[serde(default)]
97 pub storage_backend: StorageBackend,
98
99 /// Sessions directory (for file backend)
100 #[serde(skip_serializing_if = "Option::is_none")]
101 pub sessions_dir: Option<PathBuf>,
102
103 /// Connection URL for custom storage backend (e.g., "redis://localhost:6379", "postgres://user:pass@localhost/a3s")
104 #[serde(default, skip_serializing_if = "Option::is_none")]
105 pub storage_url: Option<String>,
106
107 /// Directories to scan for skill files (*.md with tool definitions)
108 #[serde(default, alias = "skill_dirs")]
109 pub skill_dirs: Vec<PathBuf>,
110
111 /// Directories to scan for agent files (*.yaml or *.md)
112 #[serde(default, alias = "agent_dirs")]
113 pub agent_dirs: Vec<PathBuf>,
114
115 /// Maximum tool execution rounds per turn (default: 25)
116 #[serde(default, alias = "max_tool_rounds")]
117 pub max_tool_rounds: Option<usize>,
118
119 /// Maximum sibling branches/tools to run concurrently in bounded parallel fan-out paths.
120 #[serde(default, alias = "max_parallel_tasks")]
121 pub max_parallel_tasks: Option<usize>,
122
123 /// Global automatic child-agent delegation settings.
124 #[serde(default, alias = "auto_delegation")]
125 pub auto_delegation: AutoDelegationConfig,
126
127 /// Convenience global kill switch for automatic parallel child-agent fan-out.
128 ///
129 /// When set, overrides `auto_delegation.auto_parallel`.
130 #[serde(default, alias = "auto_parallel")]
131 pub auto_parallel: Option<bool>,
132
133 /// Thinking/reasoning budget in tokens
134 #[serde(default, alias = "thinking_budget")]
135 pub thinking_budget: Option<usize>,
136
137 /// Memory system configuration
138 #[serde(default, skip_serializing_if = "Option::is_none")]
139 pub memory: Option<MemoryConfig>,
140
141 /// Queue configuration (a3s-lane integration)
142 #[serde(default, skip_serializing_if = "Option::is_none")]
143 pub queue: Option<crate::queue::SessionQueueConfig>,
144
145 /// Search configuration (a3s-search integration)
146 #[serde(default, skip_serializing_if = "Option::is_none")]
147 pub search: Option<SearchConfig>,
148
149 /// Built-in document context extraction configuration.
150 #[serde(default, skip_serializing_if = "Option::is_none")]
151 pub document_parser: Option<DocumentParserConfig>,
152
153 /// MCP server configurations
154 #[serde(default, alias = "mcp_servers")]
155 pub mcp_servers: Vec<crate::mcp::McpServerConfig>,
156}