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 resolve_manifest_by_id(&self, id: &ToolId) -> Option<ToolManifest> { ... }
    fn resolve_contract_by_id(&self, id: &ToolId) -> Option<Arc<ToolContract>> { ... }
    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 { ... }
    fn execute_by_id<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
        &'life0 self,
        tool_id: &'life1 ToolId,
        args: &'life2 Value,
        context: &'life3 ToolContext<'life4>,
        progress: Option<&'life5 ProgressSender>,
    ) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             'life5: '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 resolve_manifest_by_id(&self, id: &ToolId) -> Option<ToolManifest>

Source

fn resolve_contract_by_id(&self, id: &ToolId) -> Option<Arc<ToolContract>>

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,

Source

fn execute_by_id<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, tool_id: &'life1 ToolId, args: &'life2 Value, context: &'life3 ToolContext<'life4>, progress: Option<&'life5 ProgressSender>, ) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§