pub struct ToolRegistry { /* private fields */ }Expand description
Registry for discovering and managing tools
The ToolRegistry maintains a registry of all available tools and provides
methods to discover tools by ID and invoke them. Tools can be registered
at startup or dynamically at runtime.
§Examples
ⓘ
use ricecoder_agents::ToolRegistry;
let mut registry = ToolRegistry::new();
// Register tools...
// Find a tool
let tool = registry.find_tool("webfetch");Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register(&mut self, tool: Arc<dyn ToolInvoker>)
pub fn register(&mut self, tool: Arc<dyn ToolInvoker>)
Register a tool
Registers a tool with the registry, making it available for agent invocation.
§Arguments
tool- The tool invoker to register
Sourcepub fn all_tools(&self) -> Vec<Arc<dyn ToolInvoker>>
pub fn all_tools(&self) -> Vec<Arc<dyn ToolInvoker>>
Sourcepub fn tool_count(&self) -> usize
pub fn tool_count(&self) -> usize
Sourcepub fn get_tool_metadata(&self, tool_id: &str) -> Option<ToolMetadata>
pub fn get_tool_metadata(&self, tool_id: &str) -> Option<ToolMetadata>
Sourcepub fn all_tool_metadata(&self) -> Vec<ToolMetadata>
pub fn all_tool_metadata(&self) -> Vec<ToolMetadata>
Sourcepub fn discover_builtin_tools(&mut self) -> Result<(), String>
pub fn discover_builtin_tools(&mut self) -> Result<(), String>
Discover built-in tools at startup
This method initializes the registry with built-in tools from ricecoder-tools. It registers webfetch, patch, todowrite, todoread, and websearch tools.
Sourcepub fn load_configuration(
&mut self,
config: HashMap<String, Value>,
) -> Result<(), String>
pub fn load_configuration( &mut self, config: HashMap<String, Value>, ) -> Result<(), String>
Load tool configuration from project settings
This method loads tool configuration from a configuration source. The configuration can be used to enable/disable tools or customize their behavior.
Sourcepub fn available_tool_ids(&self) -> Vec<String>
pub fn available_tool_ids(&self) -> Vec<String>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ToolRegistry
impl !RefUnwindSafe for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl !UnwindSafe for ToolRegistry
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