claude_rust_tools/infrastructure/
team_create_tool.rs1use claude_rust_errors::AppResult;
2use claude_rust_types::{PermissionLevel, Tool};
3use serde_json::{Value, json};
4
5pub struct TeamCreateTool;
9
10impl TeamCreateTool {
11 pub fn new() -> Self {
12 Self
13 }
14}
15
16#[async_trait::async_trait]
17impl Tool for TeamCreateTool {
18 fn name(&self) -> &str {
19 "team_create"
20 }
21
22 fn description(&self) -> &str {
23 "Create a new agent team with a name and description. Returns a generated team ID."
24 }
25
26 fn input_schema(&self) -> Value {
27 json!({
28 "type": "object",
29 "properties": {
30 "name": {
31 "type": "string",
32 "description": "Name for the new team"
33 },
34 "description": {
35 "type": "string",
36 "description": "Description of the team's purpose"
37 }
38 },
39 "required": ["name", "description"]
40 })
41 }
42
43 fn permission_level(&self) -> PermissionLevel {
44 PermissionLevel::Dangerous
45 }
46
47 async fn execute(&self, input: Value) -> AppResult<String> {
48 let name = input
49 .get("name")
50 .and_then(|v| v.as_str())
51 .ok_or_else(|| claude_rust_errors::AppError::Tool("missing 'name' field".into()))?;
52
53 let description = input
54 .get("description")
55 .and_then(|v| v.as_str())
56 .ok_or_else(|| claude_rust_errors::AppError::Tool("missing 'description' field".into()))?;
57
58 let team_id = format!("team-{:08x}", rand_id());
60
61 tracing::info!(name, description, team_id, "creating team (stub)");
62
63 Ok(format!("Team created.\n id: {team_id}\n name: {name}\n description: {description}"))
64 }
65}
66
67fn rand_id() -> u32 {
68 use std::collections::hash_map::DefaultHasher;
69 use std::hash::{Hash, Hasher};
70 let mut h = DefaultHasher::new();
71 std::time::SystemTime::now().hash(&mut h);
72 h.finish() as u32
73}