pub struct ToolRegistry { /* private fields */ }Expand description
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn new() -> ToolRegistry
pub fn new() -> ToolRegistry
Creates an empty tool registry.
Sourcepub fn set_mcp_manager(&self, mgr: Arc<McpManager>)
pub fn set_mcp_manager(&self, mgr: Arc<McpManager>)
Attach an McpManager to this registry. Replaces any previous one.
Sourcepub fn mcp_manager(&self) -> Option<Arc<McpManager>>
pub fn mcp_manager(&self) -> Option<Arc<McpManager>>
Get the attached McpManager, if any.
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 oxicode_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 oxicode_agent::ToolRegistry;
let registry = ToolRegistry::new();
let missing = registry.missing(&["read", "exec", "nonexistent"]);
assert_eq!(missing, vec!["read", "exec", "nonexistent"]);Sourcepub fn with_builtins() -> ToolRegistry
pub fn with_builtins() -> ToolRegistry
Create a registry with all built-in tools
§Examples
use oxicode_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],
) -> ToolRegistry
pub fn with_builtins_cwd( cwd: PathBuf, disabled_tools: &[String], ) -> ToolRegistry
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 extend_from(&self, other: &ToolRegistry)
pub fn extend_from(&self, other: &ToolRegistry)
Sourcepub fn with_selected_tools(cwd: PathBuf, names: &[&str]) -> ToolRegistry
pub fn with_selected_tools(cwd: PathBuf, names: &[&str]) -> ToolRegistry
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more