use std::future::Future; use anyhow::Result; use zesdex_application::agent::ToolExecutor; use crate::tools::{all_tools, Tool, ToolCtx}; pub struct InfrastructureToolExecutor { ctx: ToolCtx, tools: Vec>, } impl InfrastructureToolExecutor { pub fn new(ctx: ToolCtx) -> Self { Self { ctx, tools: all_tools(), } } } impl ToolExecutor for InfrastructureToolExecutor { fn execute( &self, tool_name: &str, args: &serde_json::Value, ) -> impl Future> + Send { // Find the tool by name let tool_opt = self.tools.iter().find(|t| t.name() == tool_name); let ctx = self.ctx.clone(); let args = args.clone(); async move { match tool_opt { Some(tool) => { tokio::task::block_in_place(move || { tool.run(&ctx, &args) }) } None => { anyhow::bail!("Unknown tool: {}", tool_name) } } } } }