pub struct ToolRegistry { /* private fields */ }Expand description
Deterministic active tool registry.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register(
&mut self,
spec: ToolSpec,
resolver: Arc<dyn ToolResourceResolver>,
executor: Arc<dyn ToolExecutor>,
) -> Result<(), ToolRegistryError>
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.
Sourcepub fn register_binding(
&mut self,
spec: ToolSpec,
binding: ToolBinding,
) -> Result<(), ToolRegistryError>
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.
Sourcepub fn register_hosted(
&mut self,
spec: ToolSpec,
options: HostedToolOptions,
) -> Result<(), ToolRegistryError>
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.
Sourcepub fn register_hybrid(
&mut self,
spec: ToolSpec,
options: HostedToolOptions,
preference: ToolRoutePreference,
resolver: Arc<dyn ToolResourceResolver>,
executor: Arc<dyn ToolExecutor>,
) -> Result<(), ToolRegistryError>
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.
Sourcepub fn names(&self) -> impl Iterator<Item = &ToolName>
pub fn names(&self) -> impl Iterator<Item = &ToolName>
Returns registered names in canonical sorted order.
Sourcepub fn specs(&self) -> impl Iterator<Item = &ToolSpec>
pub fn specs(&self) -> impl Iterator<Item = &ToolSpec>
Returns registered specifications in canonical tool-name order.
Sourcepub fn model_definitions(
&self,
model: &ModelSpec,
) -> Result<Vec<ModelToolDefinition>, ToolRegistryError>
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.
Sourcepub fn validate(
&self,
invocation: ToolInvocation,
) -> Result<ValidatedToolInvocation, ToolRegistryError>
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.
Sourcepub fn execute(
&self,
invocation: ToolInvocation,
cancellation: CancellationScope,
) -> Result<BoxToolExecutionStream, ToolRegistryError>
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.
Sourcepub fn execute_validated(
&self,
invocation: ValidatedToolInvocation,
cancellation: CancellationScope,
) -> Result<BoxToolExecutionStream, ToolRegistryError>
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.
Sourcepub fn preview_validated(
&self,
invocation: &ValidatedToolInvocation,
) -> Option<ToolPresentation>
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.