Skip to main content

Sandbox

Trait Sandbox 

Source
pub trait Sandbox: WasmCompatSend + WasmCompatSync {
    // Required method
    fn execute_tool(
        &self,
        tool: &dyn ToolDyn,
        input: Value,
        ctx: &ToolContext,
    ) -> impl Future<Output = Result<ToolOutput, SandboxError>> + WasmCompatSend;
}
Expand description

Sandbox for isolating tool execution.

Implementations can wrap tool calls with filesystem isolation, network restrictions, resource limits, or container boundaries.

§Example

use neuron_runtime::*;
use neuron_types::*;

struct NoOpSandbox;
impl Sandbox for NoOpSandbox {
    fn execute_tool(
        &self,
        tool: &dyn ToolDyn,
        input: serde_json::Value,
        ctx: &ToolContext,
    ) -> impl Future<Output = Result<ToolOutput, SandboxError>> + Send {
        async move {
            tool.call_dyn(input, ctx)
                .await
                .map_err(|e| SandboxError::ExecutionFailed(e.to_string()))
        }
    }
}

Required Methods§

Source

fn execute_tool( &self, tool: &dyn ToolDyn, input: Value, ctx: &ToolContext, ) -> impl Future<Output = Result<ToolOutput, SandboxError>> + WasmCompatSend

Execute a tool within the sandbox.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§