pub struct ToolRegistry { /* private fields */ }Expand description
A collection of registered tools.
Implements ToolExecutor so the executor can call tools by name
without knowing anything about their implementation.
Tools are registered once at startup and never mutated during execution.
If the tool name is not in the registry, call() returns NotFound.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn set_cost_override(&mut self, tool_name: &str, cost: u64)
pub fn set_cost_override(&mut self, tool_name: &str, cost: u64)
Override the declared cost for a tool.
Reads from nanny.toml [tools.<name>] cost_per_call.
When set, declared_cost() returns this value instead of the
tool’s own declared cost.
Sourcepub fn register(&mut self, tool: Box<dyn Tool>)
pub fn register(&mut self, tool: Box<dyn Tool>)
Register a tool.
If a tool with the same name is already registered, it is replaced.
The registry takes ownership of the tool via Box<dyn Tool>.
Sourcepub fn registered_names(&self) -> Vec<&str>
pub fn registered_names(&self) -> Vec<&str>
Return the names of all registered tools.
Useful for debugging and nanny init suggestions.
Trait Implementations§
Source§impl Default for ToolRegistry
impl Default for ToolRegistry
Source§impl ToolExecutor for ToolRegistry
impl ToolExecutor for ToolRegistry
Source§fn call(&self, name: &str, args: &ToolArgs) -> Result<ToolOutput, ToolCallError>
fn call(&self, name: &str, args: &ToolArgs) -> Result<ToolOutput, ToolCallError>
Call a registered tool by name.
Returns NotFound if no tool with that name is registered.
Returns Execution if the tool was found but failed.