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
fn is_available(&self) -> boolWhether the sandbox backend is available.
sandbox_type
fn sandbox_type(&self) -> &strType 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:
| Name | Type |
|---|---|
code | &str |
language | &str |
limits | Option<ResourceLimits> |
env | Option<HashMap<String |
working_dir | Option<String> |
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:
| Name | Type |
|---|---|
file_path | &str |
args | Option<Vec<String>> |
limits | Option<ResourceLimits> |
env | Option<HashMap<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:
| Name | Type |
|---|---|
command | &str |
limits | Option<ResourceLimits> |
env | Option<HashMap<String |
working_dir | Option<String> |
write_file
async fn write_file(&self, path: &str, content: &[u8]) -> Result<bool>Write a file to the sandbox.
Parameters:
| Name | Type |
|---|---|
path | &str |
content | &[u8] |
read_file
async fn read_file(&self, path: &str) -> Result<Option<Vec<u8>>>Read a file from the sandbox.
Parameters:
| Name | Type |
|---|---|
path | &str |
list_files
async fn list_files(&self, path: &str) -> Result<Vec<String>>List files in a sandbox directory.
Parameters:
| Name | Type |
|---|---|
path | &str |
get_status
fn get_status(&self) -> SandboxStatusInfoGet 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 GitHubpraisonai/src/sandbox/mod.rs at line 0