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 #[serde(default)]
46 pub permissive: bool,
47
48 pub max_steps: Option<usize>,
50
51 pub timeout_ms: Option<u64>,
53
54 #[serde(skip_serializing_if = "Option::is_none")]
56 pub parent_id: Option<String>,
57
58 #[serde(default)]
60 pub metadata: serde_json::Value,
61
62 #[serde(default = "default_workspace")]
64 pub workspace: String,
65
66 #[serde(default)]
68 pub agent_dirs: Vec<String>,
69
70 #[serde(skip_serializing_if = "Option::is_none")]
76 pub lane_config: Option<crate::queue::SessionQueueConfig>,
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct SubAgentInfo {
82 pub id: String,
84
85 pub agent_type: String,
87
88 pub description: String,
90
91 pub state: String,
93
94 pub parent_id: Option<String>,
96
97 pub created_at: u64,
99
100 pub updated_at: u64,
102
103 pub current_activity: Option<SubAgentActivity>,
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(tag = "type", rename_all = "snake_case")]
110pub enum SubAgentActivity {
111 Idle,
113
114 CallingTool {
116 tool_name: String,
117 args: serde_json::Value,
118 },
119
120 RequestingLlm { message_count: usize },
122
123 WaitingForControl { reason: String },
125}
126
127impl SubAgentConfig {
128 pub fn new(agent_type: impl Into<String>, prompt: impl Into<String>) -> Self {
130 Self {
131 agent_type: agent_type.into(),
132 description: String::new(),
133 prompt: prompt.into(),
134 permissive: false,
135 max_steps: None,
136 timeout_ms: None,
137 parent_id: None,
138 metadata: serde_json::Value::Null,
139 workspace: default_workspace(),
140 agent_dirs: Vec::new(),
141 lane_config: None,
142 }
143 }
144
145 pub fn with_description(mut self, description: impl Into<String>) -> Self {
147 self.description = description.into();
148 self
149 }
150
151 pub fn with_permissive(mut self, permissive: bool) -> Self {
153 self.permissive = permissive;
154 self
155 }
156
157 pub fn with_max_steps(mut self, max_steps: usize) -> Self {
159 self.max_steps = Some(max_steps);
160 self
161 }
162
163 pub fn with_timeout_ms(mut self, timeout_ms: u64) -> Self {
165 self.timeout_ms = Some(timeout_ms);
166 self
167 }
168
169 pub fn with_parent_id(mut self, parent_id: impl Into<String>) -> Self {
171 self.parent_id = Some(parent_id.into());
172 self
173 }
174
175 pub fn with_metadata(mut self, metadata: serde_json::Value) -> Self {
177 self.metadata = metadata;
178 self
179 }
180
181 pub fn with_workspace(mut self, workspace: impl Into<String>) -> Self {
183 self.workspace = workspace.into();
184 self
185 }
186
187 pub fn with_agent_dirs(mut self, dirs: Vec<String>) -> Self {
189 self.agent_dirs = dirs;
190 self
191 }
192
193 pub fn with_lane_config(mut self, config: crate::queue::SessionQueueConfig) -> Self {
195 self.lane_config = Some(config);
196 self
197 }
198}
199
200fn default_workspace() -> String {
201 ".".to_string()
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize)]
211pub struct AgentSlot {
212 pub agent_type: String,
214
215 #[serde(skip_serializing_if = "Option::is_none")]
217 pub role: Option<crate::agent_teams::TeamRole>,
218
219 pub description: String,
221
222 pub prompt: String,
224
225 #[serde(default)]
227 pub permissive: bool,
228
229 pub max_steps: Option<usize>,
231
232 pub timeout_ms: Option<u64>,
234
235 #[serde(skip_serializing_if = "Option::is_none")]
237 pub parent_id: Option<String>,
238
239 #[serde(default)]
241 pub metadata: serde_json::Value,
242
243 #[serde(default = "default_workspace")]
245 pub workspace: String,
246
247 #[serde(default)]
249 pub agent_dirs: Vec<String>,
250
251 #[serde(skip_serializing_if = "Option::is_none")]
253 pub lane_config: Option<crate::queue::SessionQueueConfig>,
254}
255
256impl AgentSlot {
257 pub fn new(agent_type: impl Into<String>, prompt: impl Into<String>) -> Self {
259 Self {
260 agent_type: agent_type.into(),
261 role: None,
262 description: String::new(),
263 prompt: prompt.into(),
264 permissive: false,
265 max_steps: None,
266 timeout_ms: None,
267 parent_id: None,
268 metadata: serde_json::Value::Null,
269 workspace: default_workspace(),
270 agent_dirs: Vec::new(),
271 lane_config: None,
272 }
273 }
274
275 pub fn with_role(mut self, role: crate::agent_teams::TeamRole) -> Self {
277 self.role = Some(role);
278 self
279 }
280
281 pub fn with_description(mut self, description: impl Into<String>) -> Self {
283 self.description = description.into();
284 self
285 }
286
287 pub fn with_permissive(mut self, permissive: bool) -> Self {
289 self.permissive = permissive;
290 self
291 }
292
293 pub fn with_max_steps(mut self, max_steps: usize) -> Self {
295 self.max_steps = Some(max_steps);
296 self
297 }
298
299 pub fn with_timeout_ms(mut self, timeout_ms: u64) -> Self {
301 self.timeout_ms = Some(timeout_ms);
302 self
303 }
304
305 pub fn with_parent_id(mut self, parent_id: impl Into<String>) -> Self {
307 self.parent_id = Some(parent_id.into());
308 self
309 }
310
311 pub fn with_metadata(mut self, metadata: serde_json::Value) -> Self {
313 self.metadata = metadata;
314 self
315 }
316
317 pub fn with_workspace(mut self, workspace: impl Into<String>) -> Self {
319 self.workspace = workspace.into();
320 self
321 }
322
323 pub fn with_agent_dirs(mut self, dirs: Vec<String>) -> Self {
325 self.agent_dirs = dirs;
326 self
327 }
328
329 pub fn with_lane_config(mut self, config: crate::queue::SessionQueueConfig) -> Self {
331 self.lane_config = Some(config);
332 self
333 }
334}
335
336impl From<SubAgentConfig> for AgentSlot {
337 fn from(c: SubAgentConfig) -> Self {
338 Self {
339 agent_type: c.agent_type,
340 role: None,
341 description: c.description,
342 prompt: c.prompt,
343 permissive: c.permissive,
344 max_steps: c.max_steps,
345 timeout_ms: c.timeout_ms,
346 parent_id: c.parent_id,
347 metadata: c.metadata,
348 workspace: c.workspace,
349 agent_dirs: c.agent_dirs,
350 lane_config: c.lane_config,
351 }
352 }
353}
354
355impl From<AgentSlot> for SubAgentConfig {
356 fn from(s: AgentSlot) -> Self {
357 Self {
358 agent_type: s.agent_type,
359 description: s.description,
360 prompt: s.prompt,
361 permissive: s.permissive,
362 max_steps: s.max_steps,
363 timeout_ms: s.timeout_ms,
364 parent_id: s.parent_id,
365 metadata: s.metadata,
366 workspace: s.workspace,
367 agent_dirs: s.agent_dirs,
368 lane_config: s.lane_config,
369 }
370 }
371}