Expand description
§adk-sandbox
Isolated code execution runtime for ADK agents.
This crate provides the SandboxBackend trait and two implementations:
-
ProcessBackend(default featureprocess): Executes code in child processes viatokio::process::Command. Enforces timeout and environment isolation but not memory or network isolation. -
WasmBackend(featurewasm): Executes WebAssembly modules in-process viawasmtime. Enforces timeout, memory limits, and full sandboxing (no filesystem or network access).
§Quick Start
ⓘ
use adk_sandbox::{ProcessBackend, ExecRequest, Language};
use std::time::Duration;
use std::collections::HashMap;
let backend = ProcessBackend::default();
let request = ExecRequest {
language: Language::Python,
code: "print('hello')".to_string(),
stdin: None,
timeout: Duration::from_secs(30),
memory_limit_mb: None,
env: HashMap::new(),
};
let result = backend.execute(request).await?;
println!("stdout: {}", result.stdout);§Feature Flags
| Feature | Description | Default |
|---|---|---|
process | Subprocess execution via tokio | ✅ |
wasm | In-process WASM execution via wasmtime | ❌ |
Re-exports§
pub use backend::BackendCapabilities;pub use backend::EnforcedLimits;pub use backend::SandboxBackend;pub use error::SandboxError;pub use sandbox::AccessMode;pub use sandbox::AllowedPath;pub use sandbox::NetworkRule;pub use sandbox::SandboxEnforcer;pub use sandbox::SandboxPolicy;pub use sandbox::SandboxPolicyBuilder;pub use sandbox::WrappedCommand;pub use sandbox::get_enforcer;pub use tool::SandboxTool;pub use types::ExecRequest;pub use types::ExecResult;pub use types::Language;pub use process::ProcessBackend;pub use process::ProcessConfig;
Modules§
- backend
- The
SandboxBackendtrait andBackendCapabilitiesdescriptor. - error
- Error types for sandbox execution.
- process
ProcessBackend— subprocess-based code execution viatokio::process::Command.- sandbox
- OS-level sandbox enforcement types and traits.
- tool
SandboxTool— anadk_core::Toolimplementation that delegates execution to a configuredSandboxBackend.- types
- Core types for sandbox execution:
Language,ExecRequest, andExecResult.