Skip to main content

agent_sandbox/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum SandboxError {
5    #[error("WASM runtime error: {0}")]
6    Runtime(#[from] wasmtime::Error),
7
8    #[error("IO error: {0}")]
9    Io(#[from] std::io::Error),
10
11    #[error("path traversal blocked: {0}")]
12    PathTraversal(String),
13
14    #[error("command not found: {0}")]
15    CommandNotFound(String),
16
17    #[error("execution timed out after {0:?}")]
18    Timeout(std::time::Duration),
19
20    #[error("sandbox destroyed")]
21    Destroyed,
22
23    #[error(
24        "WASM toolbox not available — build with: cargo build --target wasm32-wasip1 -p agent-toolbox --release"
25    )]
26    ToolboxNotAvailable,
27
28    #[error("{0}")]
29    Other(String),
30}
31
32pub type Result<T> = std::result::Result<T, SandboxError>;