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 moreSource§impl Default for ToolRegistry
impl Default for ToolRegistry
Source§fn default() -> ToolRegistry
fn default() -> ToolRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for ToolRegistry
impl !UnwindSafe for ToolRegistry
impl Freeze for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.