Expand description
§adk-code
First-class code execution substrate for ADK-Rust.
This crate provides a typed executor abstraction, a truthful sandbox capability model, and shared execution backends for agent tools, Studio code nodes, and generated projects.
§Overview
adk-code owns:
- Execution request and result types (
ExecutionRequest,ExecutionResult) - Backend interface (
CodeExecutortrait) - Sandbox policy model (
SandboxPolicy,BackendCapabilities) - Request validation helpers (
validate_policy,validate_request) - Workspace abstraction for collaborative project builds (
Workspace,CollaborationEvent) - Built-in execution backends (Rust sandbox, embedded JS, WASM guest, container)
§Product Direction
The primary code-execution path is Rust-first:
- Author Rust code
- Execute it live in a sandbox via
CodeExecutor - Export the same Rust body into generated projects
Secondary support includes embedded JavaScript for lightweight transforms, WASM guest modules for portable sandboxed plugins, and container-backed execution for broader multi-language isolation.
§Quick Start
use adk_code::{
ExecutionLanguage, ExecutionPayload, ExecutionRequest,
ExecutionResult, ExecutionStatus, SandboxPolicy,
};
let request = ExecutionRequest {
language: ExecutionLanguage::Rust,
payload: ExecutionPayload::Source {
code: r#"
fn run(input: serde_json::Value) -> serde_json::Value {
serde_json::json!({ "greeting": "hello" })
}
"#.to_string(),
},
argv: vec![],
stdin: None,
input: None,
sandbox: SandboxPolicy::strict_rust(),
identity: None,
};
assert_eq!(request.language, ExecutionLanguage::Rust);§Crate Relationships
- Depends on [
adk-core] for shared error types - [
adk-tool] depends on this crate for language-preset tool wrappers - [
adk-studio] depends on this crate for live runner and code generation
Re-exports§
pub use diagnostics::RustDiagnostic;pub use diagnostics::parse_diagnostics;pub use harness::HARNESS_TEMPLATE;pub use harness::validate_rust_source;
Modules§
- a2a_
compat - A2A-compatible event mapping boundary for collaboration transport.
- compat
- Migration compatibility guide.
- diagnostics
- Rust compiler diagnostic parsing.
- harness
- Harness template and source validation for Rust code execution.
Structs§
- Artifact
Ref - Reference to an externally stored artifact.
- Backend
Capabilities - Capabilities that a backend can actually enforce.
- Code
Result - Result of a successful
RustExecutor::executecall. - Code
Tool - A tool that executes code through language-specific pipelines.
- Collaboration
Event - A typed collaboration event for cross-agent coordination in a shared workspace.
- Container
Command Executor - CLI-based container executor that shells out to
docker runper execution. - Container
Config - Configuration for the CLI-based container command executor.
- Docker
Config - Configuration for the Docker executor.
- Execution
Metadata - Execution metadata for telemetry, audit, and artifact correlation.
- Execution
Request - A full execution request.
- Execution
Result - Structured result of a code execution.
- Rust
Executor - Rust-specific executor that compiles code through a check → build → execute pipeline
and delegates execution to a
SandboxBackend. - Rust
Executor Config - Configuration for the
RustExecutorpipeline. - Rust
Sandbox Config - Configuration for the Rust sandbox executor.
- Rust
Sandbox Executor - The flagship Rust-authored code execution backend.
- Sandbox
Policy - Sandbox policy describing the requested execution constraints.
- Wasm
Guest Config - Configuration for the WASM guest executor.
- Wasm
Guest Executor - Guest-module backend for precompiled
.wasmmodules. - Workspace
- A shared project context for collaborative code generation and execution.
- Workspace
Builder - Builder for constructing a
Workspacewith fluent configuration. - Workspace
Metadata - Metadata about a workspace project and execution session.
Enums§
- Code
Error - Errors from the language-aware code pipeline ([
RustExecutor]). - Collaboration
Event Kind - The kind of a collaboration event in a shared workspace.
- Environment
Policy - Environment variable access policy for sandboxed execution.
- Execution
Error - Errors that can occur during code execution.
- Execution
Isolation - Backend isolation class.
- Execution
Language - Supported execution languages.
- Execution
Payload - The code or module to execute.
- Execution
Status - Terminal status of an execution.
- Filesystem
Policy - Filesystem access policy for sandboxed execution.
- Guest
Module Format - Format of a precompiled guest module.
- Network
Policy - Network access policy for sandboxed execution.
Traits§
- Code
Executor - Async trait for code execution backends.
Functions§
- validate_
policy - Validates that the backend can enforce the requested sandbox policy.
- validate_
request - Validates a full execution request against a backend’s capabilities.
- validate_
wasm_ bytes - Validate that the bytes represent a valid WASM binary module.