pub struct ToolRegistry { /* private fields */ }Expand description
Registry of available tools. Maintains a name→tool map and a cached JSON schema
array that gets sent to the API. Thread-safe via Arc<RwLock<ToolRegistry>>.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
pub fn new() -> Self
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Empty registry for tests and narrow embedded runtimes that want to opt in to specific tools explicitly.
Sourcepub fn without_subagent() -> Self
pub fn without_subagent() -> Self
Registry without subagent tool — used for subagent runtimes to prevent recursion.
Sourcepub fn without_subagent_with_extensions(extension_tools: &ToolRegistry) -> Self
pub fn without_subagent_with_extensions(extension_tools: &ToolRegistry) -> Self
Built-in subagent registry plus extension tools merged in from a shared
registry. Used by subagents that need to invoke extension-provided
tools while still excluding the recursive subagent_* tools.
Only tools whose Tool::extension_id() returns Some(_) are merged;
built-ins inside extension_tools are ignored to avoid duplicating or
shadowing the canonical built-in instances.
Sourcepub fn register(&mut self, tool: Arc<dyn Tool>)
pub fn register(&mut self, tool: Arc<dyn Tool>)
Register an additional tool at runtime (e.g. MCP tools, custom tools). If a tool with the same name exists, it is replaced.
pub fn get(&self, name: &str) -> Option<&Arc<dyn Tool>>
pub fn runtime_name_for_api<'a>(&'a self, name: &'a str) -> &'a str
pub fn translate_input_for_api_tool( &self, tool_name: &str, input: Value, ) -> Value
pub fn tools_schema(&self) -> Arc<Vec<Value>>
Sourcepub fn tool_names_for_extension(&self, extension_id: &str) -> Vec<String>
pub fn tool_names_for_extension(&self, extension_id: &str) -> Vec<String>
Return runtime names of tools owned by the given extension id, sorted ascending.
Built-in tools (which return None from Tool::extension_id) are excluded.
Trait Implementations§
Source§impl Clone for ToolRegistry
impl Clone for ToolRegistry
Source§fn clone(&self) -> ToolRegistry
fn clone(&self) -> ToolRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
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.