pub struct ToolRegistry { /* private fields */ }Expand description
Registry of available tools.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
pub fn new() -> Self
Sourcepub fn register_alias(
&mut self,
alias: impl Into<String>,
canonical: impl Into<String>,
)
pub fn register_alias( &mut self, alias: impl Into<String>, canonical: impl Into<String>, )
Register a compatibility alias for an existing canonical tool name.
Aliases resolve at execution time but are intentionally omitted from tool definitions so models see the canonical surface only.
Sourcepub fn get(&self, name: &str) -> Option<&Arc<dyn Tool>>
pub fn get(&self, name: &str) -> Option<&Arc<dyn Tool>>
Get a tool by canonical name or compatibility alias.
Sourcepub fn tools_map(&self) -> HashMap<String, Arc<dyn Tool>>
pub fn tools_map(&self) -> HashMap<String, Arc<dyn Tool>>
Get a cloned map of all tools, including compatibility aliases.
Sourcepub fn definitions(&self) -> Vec<ToolDefinition>
pub fn definitions(&self) -> Vec<ToolDefinition>
Get all canonical tool definitions (for LLM context).
Compatibility aliases such as legacy multi_edit are intentionally hidden
so models learn one canonical edit surface.
Sourcepub fn readonly_definitions(&self) -> Vec<ToolDefinition>
pub fn readonly_definitions(&self) -> Vec<ToolDefinition>
Get only readonly tool definitions (for readonly roles).
Sourcepub fn retain<F>(&mut self, predicate: F)
pub fn retain<F>(&mut self, predicate: F)
Retain only tools whose names satisfy the predicate.
Used by AgentBuilder to filter tools based on agent mode before the
agent is handed out to callers.
Sourcepub fn definitions_for_mode(&self, mode: &AgentMode) -> Vec<ToolDefinition>
pub fn definitions_for_mode(&self, mode: &AgentMode) -> Vec<ToolDefinition>
Get tool definitions filtered to those allowed by an agent mode.
For Full mode (empty allow-list), returns all definitions.
For all other modes, returns only the intersection.
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more