1use crate::types::*;
7
8pub struct ConfigTool;
10
11impl ConfigTool {
12 pub fn new() -> Self {
13 Self
14 }
15
16 pub fn input_schema(&self) -> ToolInputSchema {
17 ToolInputSchema {
18 schema_type: "object".to_string(),
19 properties: serde_json::json!({
20 "action": {
21 "type": "string",
22 "enum": ["get", "set", "list"],
23 "description": "Action to perform: get, set, or list"
24 },
25 "key": {
26 "type": "string",
27 "description": "Configuration key (for get/set actions)"
28 },
29 "value": {
30 "type": "string",
31 "description": "Configuration value (for set action)"
32 }
33 }),
34 required: Some(vec!["action".to_string()]),
35 }
36 }
37
38 pub async fn execute(
39 &self,
40 input: serde_json::Value,
41 _context: &ToolContext,
42 ) -> Result<ToolResult, crate::error::AgentError> {
43 let action = input["action"].as_str().unwrap_or("list");
44 let key = input["key"].as_str().unwrap_or("");
45 let value = input["value"].as_str().unwrap_or("");
46
47 let response = match action {
48 "get" => format!("Config '{}' = (placeholder value)", key),
49 "set" => format!("Config '{}' set to '{}'", key, value),
50 "list" => "Config:\n- (placeholder list)".to_string(),
51 _ => "Invalid action".to_string(),
52 };
53
54 Ok(ToolResult {
55 result_type: "text".to_string(),
56 tool_use_id: "config".to_string(),
57 content: response,
58 is_error: Some(false),
59 })
60 }
61}
62
63impl Default for ConfigTool {
64 fn default() -> Self {
65 Self::new()
66 }
67}
68
69#[cfg(test)]
70mod tests {
71 use super::*;
72
73 #[test]
74 fn test_config_schema() {
75 let tool = ConfigTool::new();
76 let schema = tool.input_schema();
77 assert!(schema.properties.get("action").is_some());
78 }
79}