Skip to main content

Crate adk_code

Crate adk_code 

Source
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:

§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§

ArtifactRef
Reference to an externally stored artifact.
BackendCapabilities
Capabilities that a backend can actually enforce.
CodeResult
Result of a successful RustExecutor::execute call.
CodeTool
A tool that executes code through language-specific pipelines.
CollaborationEvent
A typed collaboration event for cross-agent coordination in a shared workspace.
ContainerCommandExecutor
CLI-based container executor that shells out to docker run per execution.
ContainerConfig
Configuration for the CLI-based container command executor.
DockerConfig
Configuration for the Docker executor.
ExecutionMetadata
Execution metadata for telemetry, audit, and artifact correlation.
ExecutionRequest
A full execution request.
ExecutionResult
Structured result of a code execution.
RustExecutor
Rust-specific executor that compiles code through a check → build → execute pipeline and delegates execution to a SandboxBackend.
RustExecutorConfig
Configuration for the RustExecutor pipeline.
RustSandboxConfig
Configuration for the Rust sandbox executor.
RustSandboxExecutor
The flagship Rust-authored code execution backend.
SandboxPolicy
Sandbox policy describing the requested execution constraints.
WasmGuestConfig
Configuration for the WASM guest executor.
WasmGuestExecutor
Guest-module backend for precompiled .wasm modules.
Workspace
A shared project context for collaborative code generation and execution.
WorkspaceBuilder
Builder for constructing a Workspace with fluent configuration.
WorkspaceMetadata
Metadata about a workspace project and execution session.

Enums§

CodeError
Errors from the language-aware code pipeline ([RustExecutor]).
CollaborationEventKind
The kind of a collaboration event in a shared workspace.
EnvironmentPolicy
Environment variable access policy for sandboxed execution.
ExecutionError
Errors that can occur during code execution.
ExecutionIsolation
Backend isolation class.
ExecutionLanguage
Supported execution languages.
ExecutionPayload
The code or module to execute.
ExecutionStatus
Terminal status of an execution.
FilesystemPolicy
Filesystem access policy for sandboxed execution.
GuestModuleFormat
Format of a precompiled guest module.
NetworkPolicy
Network access policy for sandboxed execution.

Traits§

CodeExecutor
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.