1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Tool Executor trait
//!
//! Defines the [`ToolExecutor`] trait for abstracted tool execution.
//! Framework crates like `brainwires-agents` depend on this trait
//! to call tools without coupling to any concrete implementation.
use Result;
use async_trait;
use ;
/// Trait for executing tools in an agent context.
///
/// Implement this on your tool executor to integrate with framework agents
/// like `TaskAgent`. The trait is object-safe and can be used as
/// `Arc<dyn ToolExecutor>`.
///
/// # Example
///
/// ```rust,ignore
/// use brainwires_tools::ToolExecutor;
/// use brainwires_core::{Tool, ToolContext, ToolResult, ToolUse};
/// use async_trait::async_trait;
///
/// struct MyExecutor;
///
/// #[async_trait]
/// impl ToolExecutor for MyExecutor {
/// async fn execute(&self, tool_use: &ToolUse, context: &ToolContext) -> anyhow::Result<ToolResult> {
/// Ok(ToolResult::success(tool_use.id.clone(), "done".to_string()))
/// }
///
/// fn available_tools(&self) -> Vec<Tool> {
/// vec![]
/// }
/// }
/// ```
/// Decision returned by a [`ToolPreHook`] before a tool call.
/// Pluggable pre-execution hook for semantic tool validation.
///
/// Implement this to intercept tool calls before execution and validate
/// call intent against current agent state (not just JSON schema).
/// Hook is set via `AgentContext::with_pre_execute_hook()`.