a3s_code_core/orchestrator/
config.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone)]
7pub struct OrchestratorConfig {
8 pub event_buffer_size: usize,
10
11 pub control_buffer_size: usize,
13
14 pub max_concurrent_subagents: usize,
16
17 pub subject_prefix: String,
19}
20
21impl Default for OrchestratorConfig {
22 fn default() -> Self {
23 Self {
24 event_buffer_size: 1000,
25 control_buffer_size: 100,
26 max_concurrent_subagents: 50,
27 subject_prefix: "agent".to_string(),
28 }
29 }
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct SubAgentConfig {
35 pub agent_type: String,
37
38 pub description: String,
40
41 pub prompt: String,
43
44 pub max_steps: Option<usize>,
46
47 pub timeout_ms: Option<u64>,
49
50 #[serde(skip_serializing_if = "Option::is_none")]
52 pub parent_id: Option<String>,
53
54 #[serde(default)]
56 pub metadata: serde_json::Value,
57
58 #[serde(default = "default_workspace")]
60 pub workspace: String,
61
62 #[serde(default)]
64 pub agent_dirs: Vec<String>,
65
66 #[serde(default)]
68 pub skill_dirs: Vec<String>,
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
73pub struct SubAgentInfo {
74 pub id: String,
76
77 pub agent_type: String,
79
80 pub description: String,
82
83 pub state: String,
85
86 pub parent_id: Option<String>,
88
89 pub created_at: u64,
91
92 pub updated_at: u64,
94
95 pub current_activity: Option<SubAgentActivity>,
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(tag = "type", rename_all = "snake_case")]
102pub enum SubAgentActivity {
103 Idle,
105
106 CallingTool {
108 tool_name: String,
109 args: serde_json::Value,
110 },
111
112 RequestingLlm { message_count: usize },
114
115 WaitingForControl { reason: String },
117}
118
119impl SubAgentConfig {
120 pub fn new(agent_type: impl Into<String>, prompt: impl Into<String>) -> Self {
122 Self {
123 agent_type: agent_type.into(),
124 description: String::new(),
125 prompt: prompt.into(),
126 max_steps: None,
127 timeout_ms: None,
128 parent_id: None,
129 metadata: serde_json::Value::Null,
130 workspace: default_workspace(),
131 agent_dirs: Vec::new(),
132 skill_dirs: Vec::new(),
133 }
134 }
135
136 pub fn with_description(mut self, description: impl Into<String>) -> Self {
138 self.description = description.into();
139 self
140 }
141
142 pub fn with_max_steps(mut self, max_steps: usize) -> Self {
144 self.max_steps = Some(max_steps);
145 self
146 }
147
148 pub fn with_timeout_ms(mut self, timeout_ms: u64) -> Self {
150 self.timeout_ms = Some(timeout_ms);
151 self
152 }
153
154 pub fn with_parent_id(mut self, parent_id: impl Into<String>) -> Self {
156 self.parent_id = Some(parent_id.into());
157 self
158 }
159
160 pub fn with_metadata(mut self, metadata: serde_json::Value) -> Self {
162 self.metadata = metadata;
163 self
164 }
165
166 pub fn with_workspace(mut self, workspace: impl Into<String>) -> Self {
168 self.workspace = workspace.into();
169 self
170 }
171
172 pub fn with_agent_dirs(mut self, dirs: Vec<String>) -> Self {
174 self.agent_dirs = dirs;
175 self
176 }
177
178 pub fn with_skill_dirs(mut self, dirs: Vec<String>) -> Self {
180 self.skill_dirs = dirs;
181 self
182 }
183}
184
185fn default_workspace() -> String {
186 ".".to_string()
187}