use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
pub struct OrchestratorConfig {
pub event_buffer_size: usize,
pub control_buffer_size: usize,
pub max_concurrent_subagents: usize,
pub subject_prefix: String,
}
impl Default for OrchestratorConfig {
fn default() -> Self {
Self {
event_buffer_size: 1000,
control_buffer_size: 100,
max_concurrent_subagents: 50,
subject_prefix: "agent".to_string(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SubAgentConfig {
pub agent_type: String,
pub description: String,
pub prompt: String,
pub max_steps: Option<usize>,
pub timeout_ms: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_id: Option<String>,
#[serde(default)]
pub metadata: serde_json::Value,
#[serde(default = "default_workspace")]
pub workspace: String,
#[serde(default)]
pub agent_dirs: Vec<String>,
#[serde(default)]
pub skill_dirs: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SubAgentInfo {
pub id: String,
pub agent_type: String,
pub description: String,
pub state: String,
pub parent_id: Option<String>,
pub created_at: u64,
pub updated_at: u64,
pub current_activity: Option<SubAgentActivity>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum SubAgentActivity {
Idle,
CallingTool {
tool_name: String,
args: serde_json::Value,
},
RequestingLlm { message_count: usize },
WaitingForControl { reason: String },
}
impl SubAgentConfig {
pub fn new(agent_type: impl Into<String>, prompt: impl Into<String>) -> Self {
Self {
agent_type: agent_type.into(),
description: String::new(),
prompt: prompt.into(),
max_steps: None,
timeout_ms: None,
parent_id: None,
metadata: serde_json::Value::Null,
workspace: default_workspace(),
agent_dirs: Vec::new(),
skill_dirs: Vec::new(),
}
}
pub fn with_description(mut self, description: impl Into<String>) -> Self {
self.description = description.into();
self
}
pub fn with_max_steps(mut self, max_steps: usize) -> Self {
self.max_steps = Some(max_steps);
self
}
pub fn with_timeout_ms(mut self, timeout_ms: u64) -> Self {
self.timeout_ms = Some(timeout_ms);
self
}
pub fn with_parent_id(mut self, parent_id: impl Into<String>) -> Self {
self.parent_id = Some(parent_id.into());
self
}
pub fn with_metadata(mut self, metadata: serde_json::Value) -> Self {
self.metadata = metadata;
self
}
pub fn with_workspace(mut self, workspace: impl Into<String>) -> Self {
self.workspace = workspace.into();
self
}
pub fn with_agent_dirs(mut self, dirs: Vec<String>) -> Self {
self.agent_dirs = dirs;
self
}
pub fn with_skill_dirs(mut self, dirs: Vec<String>) -> Self {
self.skill_dirs = dirs;
self
}
}
fn default_workspace() -> String {
".".to_string()
}