use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentDefinition {
pub name: String,
pub description: String,
pub system_prompt: Option<String>,
pub model: Option<String>,
pub include_tools: Vec<String>,
pub exclude_tools: Vec<String>,
pub read_only: bool,
pub max_turns: Option<usize>,
}
pub struct AgentRegistry {
agents: HashMap<String, AgentDefinition>,
}
impl AgentRegistry {
pub fn with_defaults() -> Self {
let mut agents = HashMap::new();
agents.insert(
"general-purpose".to_string(),
AgentDefinition {
name: "general-purpose".to_string(),
description: "General-purpose agent with full tool access.".to_string(),
system_prompt: None,
model: None,
include_tools: Vec::new(),
exclude_tools: Vec::new(),
read_only: false,
max_turns: None,
},
);
agents.insert(
"explore".to_string(),
AgentDefinition {
name: "explore".to_string(),
description: "Fast read-only agent for searching and understanding code."
.to_string(),
system_prompt: Some(
"You are a fast exploration agent. Focus on finding information \
quickly. Use Grep, Glob, and FileRead to answer questions about \
the codebase. Do not modify files."
.to_string(),
),
model: None,
include_tools: vec![
"FileRead".into(),
"Grep".into(),
"Glob".into(),
"Bash".into(),
"WebFetch".into(),
],
exclude_tools: Vec::new(),
read_only: true,
max_turns: Some(20),
},
);
agents.insert(
"plan".to_string(),
AgentDefinition {
name: "plan".to_string(),
description: "Planning agent that designs implementation strategies.".to_string(),
system_prompt: Some(
"You are a software architect agent. Design implementation plans, \
identify critical files, and consider architectural trade-offs. \
Do not modify files directly."
.to_string(),
),
model: None,
include_tools: vec![
"FileRead".into(),
"Grep".into(),
"Glob".into(),
"Bash".into(),
],
exclude_tools: Vec::new(),
read_only: true,
max_turns: Some(30),
},
);
Self { agents }
}
pub fn get(&self, name: &str) -> Option<&AgentDefinition> {
self.agents.get(name)
}
pub fn register(&mut self, definition: AgentDefinition) {
self.agents.insert(definition.name.clone(), definition);
}
pub fn list(&self) -> Vec<&AgentDefinition> {
let mut agents: Vec<_> = self.agents.values().collect();
agents.sort_by_key(|a| &a.name);
agents
}
}