Skip to main content

ToolRegistry

Struct ToolRegistry 

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

Deterministic active tool registry.

Implementations§

Source§

impl ToolRegistry

Source

pub fn new() -> Self

Creates an empty registry.

Source

pub fn register( &mut self, spec: ToolSpec, resolver: Arc<dyn ToolResourceResolver>, executor: Arc<dyn ToolExecutor>, ) -> Result<(), ToolRegistryError>

Registers one complete tool contract atomically.

§Errors

Returns an error for duplicate/conflicting names or invalid schemas.

Source

pub fn register_binding( &mut self, spec: ToolSpec, binding: ToolBinding, ) -> Result<(), ToolRegistryError>

Registers one complete tool specification and execution binding atomically.

§Errors

Returns an error for duplicate/conflicting names, invalid schemas, or a hosted binding whose stable name differs from the specification.

Source

pub fn register_hosted( &mut self, spec: ToolSpec, options: HostedToolOptions, ) -> Result<(), ToolRegistryError>

Registers a provider-hosted-only tool.

§Errors

Returns an error under the same conditions as Self::register_binding.

Source

pub fn register_hybrid( &mut self, spec: ToolSpec, options: HostedToolOptions, preference: ToolRoutePreference, resolver: Arc<dyn ToolResourceResolver>, executor: Arc<dyn ToolExecutor>, ) -> Result<(), ToolRegistryError>

Registers a tool with hosted and client execution routes.

§Errors

Returns an error under the same conditions as Self::register_binding.

Source

pub fn names(&self) -> impl Iterator<Item = &ToolName>

Returns registered names in canonical sorted order.

Source

pub fn specs(&self) -> impl Iterator<Item = &ToolSpec>

Returns registered specifications in canonical tool-name order.

Source

pub fn model_definitions( &self, model: &ModelSpec, ) -> Result<Vec<ModelToolDefinition>, ToolRegistryError>

Projects active tools for one selected model in canonical name order.

§Errors

Returns an error when an active tool has no route supported by the model or a model-layer definition violates stricter bounds.

Source

pub fn validate( &self, invocation: ToolInvocation, ) -> Result<ValidatedToolInvocation, ToolRegistryError>

Validates arguments and resolves resources without executing side effects.

§Errors

Returns an error for unknown tools, invalid arguments, or resource failures.

Source

pub fn execute( &self, invocation: ToolInvocation, cancellation: CancellationScope, ) -> Result<BoxToolExecutionStream, ToolRegistryError>

Validates, resolves, executes, and enforces terminal output schema.

§Errors

Returns an error before execution for unknown tools, invalid arguments, or resource failures. In-stream executor failures remain terminal events.

Source

pub fn execute_validated( &self, invocation: ValidatedToolInvocation, cancellation: CancellationScope, ) -> Result<BoxToolExecutionStream, ToolRegistryError>

Executes an invocation already validated by this registry.

This is the policy-safe boundary: callers can evaluate one immutable ValidatedToolInvocation and execute that exact value without running schema validation or resource resolution a second time.

§Errors

Returns an error when the validated tool is no longer registered with the same specification.

Source

pub fn preview_validated( &self, invocation: &ValidatedToolInvocation, ) -> Option<ToolPresentation>

Produces a non-durable preview for an invocation already validated by this registry.

The registry identity check keeps preview generation on the same frozen tool contract that policy evaluated. Preview failures are represented by None at the executor boundary and never alter execution semantics.

Trait Implementations§

Source§

impl Debug for ToolRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ToolRegistry

Source§

fn default() -> ToolRegistry

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.