Available on crate features
code and tools only.Expand description
Code execution tools for ADK agents.
This module provides language-preset tool wrappers over the adk-code execution
substrate. Each tool chooses a default backend and sandbox policy automatically.
§Available Tools
CodeTool— Recommended Rust code execution tool usingRustExecutor+SandboxBackend.FrontendCodeTool— Placeholder frontend preset for collaborative workspace examples.JavaScriptCodeTool— Secondary scripting preset for lightweight transforms.PythonCodeTool— Container-backed CPython execution preset (full Python ecosystem: pip packages, C extensions, complete standard library).MontyPythonCodeTool— In-process Python execution via the Monty interpreter (one-shot or per-session REPL; no container required).
§Scope Model
Each tool declares the authorization scopes it requires via
Tool::required_scopes(). When a ScopeGuard (from adk_auth)
is active, the framework checks that the calling user possesses all
declared scopes before dispatching execution.
| Tool | Required Scopes | Rationale |
|---|---|---|
CodeTool | code:execute, code:execute:rust | Sandboxed Rust execution with strict defaults |
JavaScriptCodeTool | code:execute | In-process embedded JS, no elevated access |
PythonCodeTool | code:execute, code:execute:container | Container-backed, elevated mode |
MontyPythonCodeTool | code:execute | In-process Monty interpreter, host-granted OS access only |
FrontendCodeTool | code:execute, code:execute:container | Container-backed, elevated mode |
§Elevated Modes and Confirmation
Certain execution modes go beyond the base scope and should be gated by additional scopes and/or the ADK confirmation flow:
- Host execution (
code:execute:host): Runs on the local host without container isolation. Confirmation is required unless explicitly disabled by the deployer. - Container execution (
code:execute:container): Spawns an isolated container. Deployers should consider confirmation gating. - Network access (
code:network): Enables outbound network from the execution environment. Confirmation is strongly recommended. - Writable filesystem (
code:filesystem:write): Grants write access beyond the default read-only sandbox. Confirmation is strongly recommended.
Generic command execution should not silently inherit the trust posture of the Rust sandbox preset.
§Quick Start
ⓘ
use adk_tool::{
CodeTool, FrontendCodeTool, JavaScriptCodeTool, MontyPythonCodeTool, PythonCodeTool,
};
use std::sync::Arc;
// Rust code execution (recommended)
let rust_tool = Arc::new(CodeTool::new());
// Frontend specialist (placeholder until container backend ships)
let frontend_tool = Arc::new(FrontendCodeTool::react());
// Lightweight JS transforms (requires the `code-embedded-js` feature)
let js_tool = Arc::new(JavaScriptCodeTool::new());
// Container-backed CPython execution
let py_tool = Arc::new(PythonCodeTool::new());
// In-process Python execution (requires the `code-embedded-python` feature)
let monty_tool = Arc::new(MontyPythonCodeTool::new());Structs§
- Code
Tool - A tool that executes code through language-specific pipelines.
- Frontend
Code Tool - Container-backed frontend code execution tool.
- Java
Script Code Tool - Embedded JavaScript code execution tool.
- Monty
Python Code Tool - Embedded Python code execution tool backed by the Monty interpreter.
- Monty
Python Code Tool Builder - Configures a
MontyPythonCodeTool: OS-access grants, host functions, and limits are forwarded toMontyExecutorBuilder; the terminal methods select the mode. - Python
Code Tool - Container-backed Python code execution tool.