- Remove unused imports: AtomicBool, Future (provider.rs), debug (executor.rs) - Remove unused import WorkflowScript (workflow.rs) - Remove unused variables: tool_name, t_ctx, t_args (executor.rs) - Remove dead variable class_indent (semantic_search.rs) CI was failing with 'error: could not compile zesdex-infrastructure due to 10 previous errors' caused by -D warnings treating unused code as compilation errors.
45 lines
1.1 KiB
Rust
45 lines
1.1 KiB
Rust
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<Box<dyn Tool>>,
|
|
}
|
|
|
|
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<Output = Result<String>> + 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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|