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§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description added to agent instructions.
Sourcefn read_file(
&self,
options: ReadFileOptions,
) -> BoxFuture<'_, Result<Option<ByteStream>>>
fn read_file( &self, options: ReadFileOptions, ) -> BoxFuture<'_, Result<Option<ByteStream>>>
Streams a file’s bytes.
Sourcefn read_binary_file(
&self,
options: ReadFileOptions,
) -> BoxFuture<'_, Result<Option<Bytes>>>
fn read_binary_file( &self, options: ReadFileOptions, ) -> BoxFuture<'_, Result<Option<Bytes>>>
Reads a file into memory.
Sourcefn read_text_file(
&self,
options: ReadTextFileOptions,
) -> BoxFuture<'_, Result<Option<String>>>
fn read_text_file( &self, options: ReadTextFileOptions, ) -> BoxFuture<'_, Result<Option<String>>>
Reads a text file, optionally a line range.
Sourcefn write_file(
&self,
options: WriteFileOptions<ByteStream>,
) -> BoxFuture<'_, Result<()>>
fn write_file( &self, options: WriteFileOptions<ByteStream>, ) -> BoxFuture<'_, Result<()>>
Writes a file from a byte stream.
Sourcefn write_binary_file(
&self,
options: WriteFileOptions<Bytes>,
) -> BoxFuture<'_, Result<()>>
fn write_binary_file( &self, options: WriteFileOptions<Bytes>, ) -> BoxFuture<'_, Result<()>>
Writes a file from bytes.
Sourcefn write_text_file(
&self,
options: WriteFileOptions<String>,
) -> BoxFuture<'_, Result<()>>
fn write_text_file( &self, options: WriteFileOptions<String>, ) -> BoxFuture<'_, Result<()>>
Writes a text file.
Sourcefn spawn(
&self,
options: ProcessOptions,
) -> BoxFuture<'_, Result<Box<dyn SandboxProcess>>>
fn spawn( &self, options: ProcessOptions, ) -> BoxFuture<'_, Result<Box<dyn SandboxProcess>>>
Starts a process.
Sourcefn run(&self, options: ProcessOptions) -> BoxFuture<'_, Result<ProcessResult>>
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".