pub struct ToolRegistry { /* private fields */ }Expand description
A name-keyed collection of Tool implementations.
The registry owns Arc-wrapped tools and is passed to a
BasicToolExecutor (or consumed by ToolCapabilityProvider) so the
agent loop can look up tools by name at execution time.
§Example
use agentkit_tools_core::ToolRegistry;
let registry = ToolRegistry::new()
.with(NoopTool(ToolSpec::new(
ToolName::new("noop"),
"Does nothing",
json!({"type": "object"}),
)));
assert!(registry.get(&ToolName::new("noop")).is_some());
assert_eq!(registry.specs().len(), 1);Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register<T>(&mut self, tool: T) -> &mut Selfwhere
T: Tool + 'static,
pub fn register<T>(&mut self, tool: T) -> &mut Selfwhere
T: Tool + 'static,
Registers a tool by value and returns &mut self for imperative chaining.
Sourcepub fn with<T>(self, tool: T) -> Selfwhere
T: Tool + 'static,
pub fn with<T>(self, tool: T) -> Selfwhere
T: Tool + 'static,
Registers a tool by value and returns self for builder-style chaining.
Sourcepub fn register_arc(&mut self, tool: Arc<dyn Tool>) -> &mut Self
pub fn register_arc(&mut self, tool: Arc<dyn Tool>) -> &mut Self
Registers a pre-wrapped Arc<dyn Tool>.
Sourcepub fn get(&self, name: &ToolName) -> Option<Arc<dyn Tool>>
pub fn get(&self, name: &ToolName) -> Option<Arc<dyn Tool>>
Looks up a tool by name, returning None if not registered.
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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for ToolRegistry
impl Default for ToolRegistry
Source§fn default() -> ToolRegistry
fn default() -> ToolRegistry
Returns the “default value” for a type. Read more
Source§impl ToolSource for ToolRegistry
impl ToolSource for ToolRegistry
Source§fn get(&self, name: &ToolName) -> Option<Arc<dyn Tool>>
fn get(&self, name: &ToolName) -> Option<Arc<dyn Tool>>
Looks up a tool by name, returning
None if not present.Source§fn drain_catalog_events(&self) -> Vec<ToolCatalogEvent>
fn drain_catalog_events(&self) -> Vec<ToolCatalogEvent>
Drains pending catalog change events. Static sources return an empty
list; dynamic sources surface added/removed/changed batches that the
loop forwards to the model on the next turn.
Source§fn prefixed(self, prefix: impl Into<String>) -> Prefixed<Self>where
Self: Sized,
fn prefixed(self, prefix: impl Into<String>) -> Prefixed<Self>where
Self: Sized,
Wraps this source so every advertised tool name is prefixed with
<prefix>_. Useful for mounting the same source under multiple
namespaces, or for avoiding collisions between MCP catalogs. Read moreSource§fn filtered<F>(self, predicate: F) -> Filtered<Self, F>
fn filtered<F>(self, predicate: F) -> Filtered<Self, F>
Wraps this source so only tools whose name passes
predicate are
advertised and resolvable. Tools rejected by the predicate are
invisible to the model and return None on lookup. 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