Skip to main content

ToolRegistry

Struct ToolRegistry 

Source
pub struct ToolRegistry { /* private fields */ }
Expand description

Registry for built-in, provider, alias, and localized tool lookup.

Implementations§

Source§

impl ToolRegistry

Source

pub fn new() -> Self

Creates an empty registry with versioned canonical indexes.

Source

pub fn version(&self) -> u64

Returns the registry version used in tool execution evidence.

Source

pub fn register(&mut self, tool: Arc<dyn Tool>) -> Result<(), ToolError>

Registers a built-in or custom tool by canonical ID.

Source

pub fn get(&self, id_or_alias: &str) -> Option<Arc<dyn Tool>>

Source

pub fn canonical_id(&self, id_or_alias: &str) -> Option<String>

Resolves any accepted name to a canonical tool ID.

Source

pub fn safety_metadata(&self, id_or_alias: &str) -> Option<ToolSafetyMetadata>

Resolves safety metadata for a registered tool.

Source

pub fn question_handler_slot(&self) -> QuestionHandlerSlot

Returns the shared question handler slot for host-bound tools.

Source

pub fn set_question_handler(&self, handler: Option<Arc<dyn QuestionHandler>>)

Installs or clears the question handler used by ask_user.

Source

pub fn diagnostics_provider_slot(&self) -> DiagnosticsProviderSlot

Returns the shared diagnostics provider slot for host-bound tools.

Source

pub fn set_diagnostics_provider(&self, provider: Arc<dyn DiagnosticsProvider>)

Installs the diagnostics provider used by diagnostics.

Source

pub fn diagnostics_available(&self) -> bool

Returns whether the diagnostics provider can serve requests now.

Source

pub fn command_runner_slot(&self) -> CommandRunnerSlot

Returns the shared command runner slot for host-bound tools.

Source

pub fn set_command_runner(&self, runner: Arc<dyn CommandRunner>)

Installs the command runner used by command.

Source

pub fn command_runner_available(&self) -> bool

Returns whether the command runner can serve requests now.

Source

pub fn file_version_store(&self) -> FileVersionStore

Returns the session-local file version store shared with file tools.

Source

pub fn todo_store(&self) -> TodoStore

Returns the session-local todo store shared with todo.

Source

pub fn todos(&self) -> Vec<TodoItem>

Returns a snapshot of session-local todo items.

Source

pub fn web_fetch_extractor_slot( &self, ) -> Arc<RwLock<Option<Arc<dyn LLMProvider>>>>

Returns the shared web-fetch extractor slot.

Source

pub fn set_web_fetch_extractor(&self, extractor: Option<Arc<dyn LLMProvider>>)

Installs or clears the LLM used for web_fetch prompt extraction.

Source

pub fn web_search_provider_slot(&self) -> WebSearchProviderSlot

Returns the shared provider slot for web_search.

Source

pub fn set_web_search_provider(&self, provider: Arc<dyn WebSearchProvider>)

Installs the provider used by web_search.

Source

pub fn web_search_available(&self) -> bool

Returns whether the web search provider can serve requests now.

Source

pub fn resolve(&self, id_or_alias: &str) -> Option<ResolvedTool>

Resolves IDs, display names, and aliases to one canonical tool.

Source

pub fn list_ids(&self) -> Vec<String>

Source

pub fn list_infos(&self) -> Vec<ToolInfo>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn map_tools<F>(&self, f: F) -> ToolRegistry
where F: FnMut(Arc<dyn Tool>) -> Arc<dyn Tool>,

Source

pub async fn register_provider( &self, provider: Arc<dyn ToolProvider>, ) -> Result<(), ToolError>

Source

pub fn unregister_provider(&self, provider_id: &str) -> bool

Source

pub fn set_tool_aliases(&self, tool_id: &str, aliases: ToolAliases)

Source

pub fn get_by_alias(&self, alias: &str, lang: &str) -> Option<Arc<dyn Tool>>

Source

pub fn list_providers(&self) -> Vec<String>

Source

pub async fn provider_health(&self, provider_id: &str) -> Option<ProviderHealth>

Source

pub async fn refresh_provider( &self, provider_id: &str, ) -> Result<(), ToolProviderError>

Source

pub fn generate_tools_prompt(&self) -> String

Source

pub fn generate_tools_prompt_with_parallel(&self, parallel: bool) -> String

Source

pub fn generate_tools_prompt_with_lang( &self, language: Option<&str>, parallel: bool, ) -> String

Source

pub fn generate_filtered_prompt(&self, tool_ids: &[String]) -> String

Source

pub fn generate_filtered_prompt_with_parallel( &self, tool_ids: &[String], parallel: bool, ) -> String

Source

pub fn generate_scoped_prompt_with_parallel( &self, tool_ids: &[String], parallel: bool, ) -> String

Generates a prompt for an explicit tool scope.

Source

pub fn generate_scoped_prompt_with_lang( &self, tool_ids: &[String], language: Option<&str>, parallel: bool, ) -> String

Source

pub fn generate_filtered_prompt_with_lang( &self, tool_ids: &[String], language: Option<&str>, parallel: bool, ) -> String

Source

pub fn generate_scoped_prompt_with_mode( &self, tool_ids: &[impl AsRef<str>], language: Option<&str>, parallel: bool, mode: ToolSchemaPromptMode, ) -> String

Generate a scoped prompt with a configurable schema rendering mode.

Trait Implementations§

Source§

impl Default for ToolRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more