pub struct BuiltinToolExecutor { /* private fields */ }Expand description
Concrete executor that dispatches tool calls to the built-in tool modules
registered in a ToolRegistry.
§Example
ⓘ
use brainwires_tools::{BuiltinToolExecutor, ToolRegistry};
use brainwires_core::ToolContext;
let registry = ToolRegistry::with_builtins();
let context = ToolContext::default();
let executor = BuiltinToolExecutor::new(registry, context);
// Check available tools
assert!(executor.has_tool("execute_command"));
// Execute via the ToolExecutor trait
// let result = executor.execute(&tool_use, &context).await?;Implementations§
Source§impl BuiltinToolExecutor
impl BuiltinToolExecutor
Sourcepub fn new(registry: ToolRegistry, context: ToolContext) -> Self
pub fn new(registry: ToolRegistry, context: ToolContext) -> Self
Create a new executor backed by the given registry and default context.
Sourcepub async fn execute_tool(
&self,
tool_name: &str,
tool_use_id: &str,
input: &Value,
) -> ToolResult
pub async fn execute_tool( &self, tool_name: &str, tool_use_id: &str, input: &Value, ) -> ToolResult
Execute a tool by name, dispatching to the correct handler.
This is the standalone entry-point that mirrors the old
dispatch_tool() function from agent-chat.
Sourcepub fn registry(&self) -> &ToolRegistry
pub fn registry(&self) -> &ToolRegistry
Return a reference to the underlying registry.
Sourcepub fn context(&self) -> &ToolContext
pub fn context(&self) -> &ToolContext
Return a reference to the default context.
Trait Implementations§
Source§impl ToolExecutor for BuiltinToolExecutor
impl ToolExecutor for BuiltinToolExecutor
Source§fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_use: &'life1 ToolUse,
context: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_use: &'life1 ToolUse,
context: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute a tool and return its result. Read more
Source§fn available_tools(&self) -> Vec<Tool>
fn available_tools(&self) -> Vec<Tool>
Return the list of tools available for the AI to invoke.
Auto Trait Implementations§
impl Freeze for BuiltinToolExecutor
impl !RefUnwindSafe for BuiltinToolExecutor
impl Send for BuiltinToolExecutor
impl Sync for BuiltinToolExecutor
impl Unpin for BuiltinToolExecutor
impl UnsafeUnpin for BuiltinToolExecutor
impl !UnwindSafe for BuiltinToolExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more