Skip to main content

Sandbox

Trait Sandbox 

Source
pub trait Sandbox: Send + Sync {
    // Required methods
    fn description(&self) -> &str;
    fn read_file(
        &self,
        options: ReadFileOptions,
    ) -> BoxFuture<'_, Result<Option<ByteStream>>>;
    fn read_binary_file(
        &self,
        options: ReadFileOptions,
    ) -> BoxFuture<'_, Result<Option<Bytes>>>;
    fn read_text_file(
        &self,
        options: ReadTextFileOptions,
    ) -> BoxFuture<'_, Result<Option<String>>>;
    fn write_file(
        &self,
        options: WriteFileOptions<ByteStream>,
    ) -> BoxFuture<'_, Result<()>>;
    fn write_binary_file(
        &self,
        options: WriteFileOptions<Bytes>,
    ) -> BoxFuture<'_, Result<()>>;
    fn write_text_file(
        &self,
        options: WriteFileOptions<String>,
    ) -> BoxFuture<'_, Result<()>>;
    fn spawn(
        &self,
        options: ProcessOptions,
    ) -> BoxFuture<'_, Result<Box<dyn SandboxProcess>>>;
    fn run(
        &self,
        options: ProcessOptions,
    ) -> BoxFuture<'_, Result<ProcessResult>>;
}
Expand description

A sandbox session.

Implement this to run tools inside a container, VM or remote worker. Reads return Ok(None) for missing files; writes create parent directories and overwrite; run is spawn plus collecting both output streams.

Required Methods§

Source

fn description(&self) -> &str

Human-readable description added to agent instructions.

Source

fn read_file( &self, options: ReadFileOptions, ) -> BoxFuture<'_, Result<Option<ByteStream>>>

Streams a file’s bytes.

Source

fn read_binary_file( &self, options: ReadFileOptions, ) -> BoxFuture<'_, Result<Option<Bytes>>>

Reads a file into memory.

Source

fn read_text_file( &self, options: ReadTextFileOptions, ) -> BoxFuture<'_, Result<Option<String>>>

Reads a text file, optionally a line range.

Source

fn write_file( &self, options: WriteFileOptions<ByteStream>, ) -> BoxFuture<'_, Result<()>>

Writes a file from a byte stream.

Source

fn write_binary_file( &self, options: WriteFileOptions<Bytes>, ) -> BoxFuture<'_, Result<()>>

Writes a file from bytes.

Source

fn write_text_file( &self, options: WriteFileOptions<String>, ) -> BoxFuture<'_, Result<()>>

Writes a text file.

Source

fn spawn( &self, options: ProcessOptions, ) -> BoxFuture<'_, Result<Box<dyn SandboxProcess>>>

Starts a process.

Source

fn run(&self, options: ProcessOptions) -> BoxFuture<'_, Result<ProcessResult>>

Runs a command to completion.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§