Skip to main content

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

fn is_available(&self) -> bool
Whether the sandbox backend is available.

sandbox_type

fn sandbox_type(&self) -> &str
Type of sandbox (docker, subprocess, etc.).

start

async fn start(&mut self) -> Result<()>
Start/initialize the sandbox environment.

stop

async fn stop(&mut self) -> Result<()>
Stop/cleanup the sandbox environment.

execute

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

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

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

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

async fn read_file(&self, path: &str) -> Result<Option<Vec<u8>>>
Read a file from the sandbox. Parameters:
NameType
path&str

list_files

async fn list_files(&self, path: &str) -> Result<Vec<String>>
List files in a sandbox directory. Parameters:
NameType
path&str

get_status

fn get_status(&self) -> SandboxStatusInfo
Get sandbox status information.

cleanup

async fn cleanup(&mut self) -> Result<()>
Clean up sandbox resources.

reset

async fn reset(&mut self) -> Result<()>
Reset sandbox to initial state.

Source

View on GitHub

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