pub struct ToolRegistry { /* private fields */ }Expand description
Registry of available tools for dispatch.
Supports hierarchical lookup: a child registry can overlay a parent. The parent chain is walked when a tool is not found locally.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn with_parent(parent: Arc<ToolRegistry>) -> Self
pub fn with_parent(parent: Arc<ToolRegistry>) -> Self
Create a child registry that delegates to parent for missing tools.
Sourcepub fn register(&mut self, tool: Arc<dyn BuiltinTool>)
pub fn register(&mut self, tool: Arc<dyn BuiltinTool>)
Register a tool (local to this registry level).
When require_signatures is enabled, this rejects unsigned tools
with ToolError::SignatureRequired. Use [register_signed]
to supply a signature, or disable the requirement.
Sourcepub fn try_register(
&mut self,
tool: Arc<dyn BuiltinTool>,
) -> Result<(), ToolError>
pub fn try_register( &mut self, tool: Arc<dyn BuiltinTool>, ) -> Result<(), ToolError>
Register a tool, checking signatures when required.
Returns Err(SignatureRequired) when require_signatures is on
and no signature is provided. Returns Ok(()) otherwise.
Sourcepub fn register_signed(
&mut self,
tool: Arc<dyn BuiltinTool>,
signature: ToolSignature,
) -> Result<(), ToolError>
pub fn register_signed( &mut self, tool: Arc<dyn BuiltinTool>, signature: ToolSignature, ) -> Result<(), ToolError>
Register a tool with a cryptographic signature.
Verifies the signature against trusted keys before allowing registration. The signature is stored and the tool is chain-logged if ExoChain is available.
Sourcepub fn verify_tool_signature(&self, signature: &ToolSignature) -> bool
pub fn verify_tool_signature(&self, signature: &ToolSignature) -> bool
Check whether a tool signature is valid against any trusted key.
Sourcepub fn set_require_signatures(&mut self, require: bool)
pub fn set_require_signatures(&mut self, require: bool)
Enable or disable mandatory signature verification for tool registration.
Sourcepub fn requires_signatures(&self) -> bool
pub fn requires_signatures(&self) -> bool
Whether signatures are required for tool registration.
Sourcepub fn add_trusted_key(&mut self, key: [u8; 32])
pub fn add_trusted_key(&mut self, key: [u8; 32])
Add a trusted Ed25519 public key for signature verification.
Sourcepub fn get_signature(&self, tool_name: &str) -> Option<&ToolSignature>
pub fn get_signature(&self, tool_name: &str) -> Option<&ToolSignature>
Get the signature for a registered tool, if any.
Sourcepub fn get(&self, name: &str) -> Option<&Arc<dyn BuiltinTool>>
pub fn get(&self, name: &str) -> Option<&Arc<dyn BuiltinTool>>
Look up a tool by name, walking the parent chain.
Sourcepub fn execute(&self, name: &str, args: Value) -> Result<Value, ToolError>
pub fn execute(&self, name: &str, args: Value) -> Result<Value, ToolError>
Execute a tool by name, walking the parent chain.
Sourcepub fn list(&self) -> Vec<String>
pub fn list(&self) -> Vec<String>
List all registered tool names (merges parent + local, local wins).
Sourcepub fn parent(&self) -> Option<&Arc<ToolRegistry>>
pub fn parent(&self) -> Option<&Arc<ToolRegistry>>
Get a reference to the parent registry, if any.
Trait Implementations§
Source§impl Default for ToolRegistry
impl Default for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
Auto Trait Implementations§
impl Freeze for ToolRegistry
impl !RefUnwindSafe 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