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
13mod loader;
14mod provider;
15mod search;
16#[cfg(test)]
17mod tests;
18
19pub use provider::{ModelConfig, ModelCost, ModelLimit, ModelModalities, ProviderConfig};
20pub use search::{
21    BrowserBackend, DocumentCacheConfig, DocumentOcrConfig, DocumentParserConfig, HeadlessConfig,
22    SearchConfig, SearchEngineConfig, SearchHealthConfig,
23};
24
25use crate::memory::MemoryConfig;
26use serde::{Deserialize, Serialize};
27use std::path::PathBuf;
28
29// ============================================================================
30// Storage Configuration
31// ============================================================================
32
33/// Session storage backend type
34#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq, Hash)]
35#[serde(rename_all = "lowercase")]
36pub enum StorageBackend {
37    /// In-memory storage (no persistence)
38    Memory,
39    /// File-based storage (JSON files)
40    #[default]
41    File,
42    /// Custom external storage (Redis, PostgreSQL, etc.)
43    ///
44    /// Requires a `SessionStore` implementation registered on `AgentSession` options.
45    /// Use `storage_url` in config to pass connection details.
46    Custom,
47}
48
49// ============================================================================
50// Main Configuration
51// ============================================================================
52
53/// Automatic subagent delegation controls.
54#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
55#[serde(default, rename_all = "camelCase")]
56pub struct AutoDelegationConfig {
57    /// Enable runtime-driven automatic child agent delegation.
58    pub enabled: bool,
59    /// Allow automatic delegation to launch multiple child agents in parallel.
60    ///
61    /// Manual `parallel_task` calls remain available when this is false.
62    #[serde(alias = "auto_parallel")]
63    pub auto_parallel: bool,
64    /// Minimum local confidence required to auto-delegate a child task.
65    pub min_confidence: f32,
66    /// Maximum number of automatic child tasks per user request.
67    pub max_tasks: usize,
68}
69
70impl Default for AutoDelegationConfig {
71    fn default() -> Self {
72        Self {
73            enabled: false,
74            auto_parallel: true,
75            min_confidence: 0.72,
76            max_tasks: 4,
77        }
78    }
79}
80
81/// Configuration for A3S Code
82#[derive(Debug, Clone, Serialize, Deserialize, Default)]
83#[serde(rename_all = "camelCase")]
84pub struct CodeConfig {
85    /// Default model in "provider/model" format (e.g., "anthropic/claude-sonnet-4-20250514")
86    #[serde(default, alias = "default_model")]
87    pub default_model: Option<String>,
88
89    /// Provider configurations
90    #[serde(default)]
91    pub providers: Vec<ProviderConfig>,
92
93    /// Session storage backend
94    #[serde(default)]
95    pub storage_backend: StorageBackend,
96
97    /// Sessions directory (for file backend)
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub sessions_dir: Option<PathBuf>,
100
101    /// Connection URL for custom storage backend (e.g., "redis://localhost:6379", "postgres://user:pass@localhost/a3s")
102    #[serde(default, skip_serializing_if = "Option::is_none")]
103    pub storage_url: Option<String>,
104
105    /// Directories to scan for skill files (*.md with tool definitions)
106    #[serde(default, alias = "skill_dirs")]
107    pub skill_dirs: Vec<PathBuf>,
108
109    /// Directories to scan for agent files (*.yaml or *.md)
110    #[serde(default, alias = "agent_dirs")]
111    pub agent_dirs: Vec<PathBuf>,
112
113    /// Maximum tool execution rounds per turn (default: 25)
114    #[serde(default, alias = "max_tool_rounds")]
115    pub max_tool_rounds: Option<usize>,
116
117    /// Maximum sibling branches/tools to run concurrently in bounded parallel fan-out paths.
118    #[serde(default, alias = "max_parallel_tasks")]
119    pub max_parallel_tasks: Option<usize>,
120
121    /// Global automatic child-agent delegation settings.
122    #[serde(default, alias = "auto_delegation")]
123    pub auto_delegation: AutoDelegationConfig,
124
125    /// Convenience global kill switch for automatic parallel child-agent fan-out.
126    ///
127    /// When set, overrides `auto_delegation.auto_parallel`.
128    #[serde(default, alias = "auto_parallel")]
129    pub auto_parallel: Option<bool>,
130
131    /// Thinking/reasoning budget in tokens
132    #[serde(default, alias = "thinking_budget")]
133    pub thinking_budget: Option<usize>,
134
135    /// Memory system configuration
136    #[serde(default, skip_serializing_if = "Option::is_none")]
137    pub memory: Option<MemoryConfig>,
138
139    /// Queue configuration (a3s-lane integration)
140    #[serde(default, skip_serializing_if = "Option::is_none")]
141    pub queue: Option<crate::queue::SessionQueueConfig>,
142
143    /// Search configuration (a3s-search integration)
144    #[serde(default, skip_serializing_if = "Option::is_none")]
145    pub search: Option<SearchConfig>,
146
147    /// Built-in document context extraction configuration.
148    #[serde(default, skip_serializing_if = "Option::is_none")]
149    pub document_parser: Option<DocumentParserConfig>,
150
151    /// MCP server configurations
152    #[serde(default, alias = "mcp_servers")]
153    pub mcp_servers: Vec<crate::mcp::McpServerConfig>,
154}