Skip to main content

ToolProvider

Trait ToolProvider 

Source
pub trait ToolProvider:
    Send
    + Sync
    + 'static {
    // Required methods
    fn tool_manifests(&self) -> Vec<ToolManifest>;
    fn resolve_contract(&self, name: &str) -> Option<Arc<ToolContract>>;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        call: ToolCall<'life1>,
    ) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn resolve_manifest(&self, name: &str) -> Option<ToolManifest> { ... }
    fn prepare_tool_call<'life0, 'life1, 'async_trait>(
        &'life0 self,
        call: ToolPrepareCall<'life1>,
    ) -> Pin<Box<dyn Future<Output = Result<PreparedToolCall, ToolResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Trait for providing tools to the sandbox. Implement this per-project.

Implementations supply cheap ToolManifests, lazily resolved ToolContracts, and a single execute method that handles every call. Tools that need session state read it from call.context; tools that stream progress send through call.progress.

Required Methods§

Source

fn tool_manifests(&self) -> Vec<ToolManifest>

Source

fn resolve_contract(&self, name: &str) -> Option<Arc<ToolContract>>

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, call: ToolCall<'life1>, ) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Provided Methods§

Source

fn resolve_manifest(&self, name: &str) -> Option<ToolManifest>

Source

fn prepare_tool_call<'life0, 'life1, 'async_trait>( &'life0 self, call: ToolPrepareCall<'life1>, ) -> Pin<Box<dyn Future<Output = Result<PreparedToolCall, ToolResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§