use std::collections::HashMap; use anyhow::Result; use async_trait::async_trait; use serde_json::Value; pub mod code_exec; pub mod fs_tools; pub mod registry; pub mod web_search; pub mod web_search_detailed; #[async_trait] pub trait Tool: Send + Sync { fn name(&self) -> &'static str; fn description(&self) -> &'static str; fn schema(&self) -> Value; fn requires_network(&self) -> bool { false } fn requires_filesystem(&self) -> Vec { Vec::new() } async fn execute(&self, args: Value) -> Result; } #[derive(Debug, Clone)] pub struct ToolResult { pub success: bool, pub output: Value, pub duration: std::time::Duration, pub metadata: HashMap, } impl ToolResult { pub fn success(output: Value) -> Self { Self { success: true, output, duration: std::time::Duration::from_millis(0), metadata: HashMap::new(), } } pub fn error(message: &str) -> Self { Self { success: false, output: serde_json::json!({ "error": message }), duration: std::time::Duration::from_millis(0), metadata: HashMap::new(), } } }