pub struct ToolRegistry { /* private fields */ }Expand description
Tool registry for managing available tools
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register_arc(&self, tool: Arc<dyn AgentTool>)
pub fn register_arc(&self, tool: Arc<dyn AgentTool>)
Register a tool that is already wrapped in an Arc.
This is the primary path for extensions that produce Arc<dyn AgentTool>.
Sourcepub fn unregister(&self, name: &str) -> bool
pub fn unregister(&self, name: &str) -> bool
Unregister a tool by name.
Returns true if the tool was present and removed.
Sourcepub fn definitions(&self) -> Vec<ToolDefinition>
pub fn definitions(&self) -> Vec<ToolDefinition>
Get all tool definitions
Sourcepub fn has_all(&self, required: &[&str]) -> bool
pub fn has_all(&self, required: &[&str]) -> bool
Check whether all tools in required are registered.
Useful for validating program/module dependencies before execution.
§Example
use oxi_agent::ToolRegistry;
let registry = ToolRegistry::new();
assert!(!registry.has_all(&["read", "write"]));Sourcepub fn missing<'a>(&self, required: &[&'a str]) -> Vec<&'a str>
pub fn missing<'a>(&self, required: &[&'a str]) -> Vec<&'a str>
Return the subset of required tool names that are not registered.
§Example
use oxi_agent::ToolRegistry;
let registry = ToolRegistry::new();
let missing = registry.missing(&["read", "exec", "nonexistent"]);
assert_eq!(missing, vec!["read", "exec", "nonexistent"]);Sourcepub fn with_builtins() -> Self
pub fn with_builtins() -> Self
Create a registry with all built-in tools
§Examples
use oxi_agent::ToolRegistry;
let registry = ToolRegistry::with_builtins();
let tools = registry.names();
assert!(tools.contains(&"read".to_string()));
assert!(tools.contains(&"write".to_string()));
assert!(tools.contains(&"bash".to_string()));Sourcepub fn with_builtins_cwd(cwd: PathBuf, disabled_tools: &[String]) -> Self
pub fn with_builtins_cwd(cwd: PathBuf, disabled_tools: &[String]) -> Self
Create a registry with all built-in tools, using the given cwd.
Pass disabled_tools to selectively disable built-in tools
(e.g. ["web_search", "github_search"] for a minimal setup).
Sourcepub fn with_selected_tools(cwd: PathBuf, names: &[&str]) -> Self
pub fn with_selected_tools(cwd: PathBuf, names: &[&str]) -> Self
Create registry with selected builtins only.
Trait Implementations§
Source§impl Clone for ToolRegistry
impl Clone for ToolRegistry
Source§fn clone(&self) -> ToolRegistry
fn clone(&self) -> ToolRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ToolRegistry
impl !RefUnwindSafe for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl UnsafeUnpin 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