codetether_agent/tool/agent/
tool_impl.rs1use super::actions::execute_kill;
13use super::{handlers, message, spawn};
14use crate::tool::{Tool, ToolResult};
15use anyhow::{Context, Result};
16use async_trait::async_trait;
17use serde_json::Value;
18
19pub struct AgentTool;
31
32impl AgentTool {
33 pub fn new() -> Self {
41 Self
42 }
43}
44
45impl Default for AgentTool {
46 fn default() -> Self {
47 Self::new()
48 }
49}
50
51#[async_trait]
52impl Tool for AgentTool {
53 fn id(&self) -> &str {
54 "agent"
55 }
56
57 fn name(&self) -> &str {
58 "Sub-Agent"
59 }
60
61 fn description(&self) -> &str {
62 "Spawn and communicate with specialized sub-agents. Actions: spawn, message, list, kill. Spawned agents must use a free/subscription-eligible model."
63 }
64
65 fn parameters(&self) -> Value {
66 super::tool_schema::agent_tool_parameters()
67 }
68
69 async fn execute(&self, params: Value) -> Result<ToolResult> {
70 let parsed: super::params::Params =
71 serde_json::from_value(params).context("Invalid params")?;
72 match parsed.action.as_str() {
73 "spawn" => spawn::handle_spawn(&parsed).await,
74 "message" => message::handle_message(&parsed).await,
75 "list" => Ok(handlers::handle_list()),
76 "kill" => execute_kill(&parsed),
77 _ => Ok(super::actions::unknown_action_result(&parsed.action)),
78 }
79 }
80}