Sandbox Protocol • Rust AI Agent SDK

SandboxProtocol: Protocol for sandbox implementations. Sandboxes provide isolated environments for safe code execution. Implementations can use Docker, subprocess…

SandboxProtocol

Defined in the sandbox module.

Rust AI Agent SDK

Protocol for sandbox implementations. Sandboxes provide isolated environments for safe code execution. Implementations can use Docker, subprocess isolation, or other containerization technologies.

Methods

is_available

rust
fn is_available(&self) -> bool

Whether the sandbox backend is available.

sandbox_type

rust
fn sandbox_type(&self) -> &str

Type of sandbox (docker, subprocess, etc.).

start

rust
async fn start(&mut self) -> Result<()>

Start/initialize the sandbox environment.

stop

rust
async fn stop(&mut self) -> Result<()>

Stop/cleanup the sandbox environment.

execute

rust
async fn execute(
        &self,
        code: &str,
        language: &str,
        limits: Option<ResourceLimits>,
        env: Option<HashMap<String, String>>,
        working_dir: Option<String>,
    ) -> Result<SandboxResult>

Execute code in the sandbox.

Parameters:

NameType
code&str
language&str
limitsOption&lt;ResourceLimits&gt;
envOption&lt;HashMap&lt;String
working_dirOption&lt;String&gt;

execute_file

rust
async fn execute_file(
        &self,
        file_path: &str,
        args: Option<Vec<String>>,
        limits: Option<ResourceLimits>,
        env: Option<HashMap<String, String>>,
    ) -> Result<SandboxResult>

Execute a file in the sandbox.

Parameters:

NameType
file_path&str
argsOption&lt;Vec&lt;String&gt;&gt;
limitsOption&lt;ResourceLimits&gt;
envOption&lt;HashMap&lt;String

run_command

rust
async fn run_command(
        &self,
        command: &str,
        limits: Option<ResourceLimits>,
        env: Option<HashMap<String, String>>,
        working_dir: Option<String>,
    ) -> Result<SandboxResult>

Run a shell command in the sandbox.

Parameters:

NameType
command&str
limitsOption&lt;ResourceLimits&gt;
envOption&lt;HashMap&lt;String
working_dirOption&lt;String&gt;

write_file

rust
async fn write_file(&self, path: &str, content: &[u8]) -> Result<bool>

Write a file to the sandbox.

Parameters:

NameType
path&str
content&[u8]

read_file

rust
async fn read_file(&self, path: &str) -> Result<Option<Vec<u8>>>

Read a file from the sandbox.

Parameters:

NameType
path&str

list_files

rust
async fn list_files(&self, path: &str) -> Result<Vec<String>>

List files in a sandbox directory.

Parameters:

NameType
path&str

get_status

rust
fn get_status(&self) -> SandboxStatusInfo

Get sandbox status information.

cleanup

rust
async fn cleanup(&mut self) -> Result<()>

Clean up sandbox resources.

reset

rust
async fn reset(&mut self) -> Result<()>

Reset sandbox to initial state.

Source

View on GitHub

praisonai/src/sandbox/mod.rs at line 0


Related Documentation