Expand description
§adk-devtools
Developer tools for ADK-Rust coding agents — read_file, write_file,
edit_file, apply_patch, glob, grep, and bash — all scoped to a sandboxed
Workspace.
These are the inner-loop tools a coding agent needs: read and edit files,
search the tree, and run commands/tests. Every operation is rooted at a
workspace directory and rejected if it escapes; mutations and bash are
gated by the workspace’s capability flags.
§Quick start
use adk_devtools::{DevToolset, Workspace};
use std::sync::Arc;
// `bash` is off by default; enable it only for agents that need a shell.
let workspace = Workspace::new("./my-repo").allow_bash(true);
assert!(workspace.bash_allowed());
// Register with an agent: `LlmAgentBuilder::new("coding-agent").toolset(toolset)`.
let toolset = Arc::new(DevToolset::new(workspace));§Sandboxing
Workspace enforces path containment (no escaping the root),
read-only mode (deny writes/bash), opt-in bash (off until
Workspace::allow_bash enables it), a bash timeout that a call
can shorten but not extend, and secret exclusion: grep and glob skip
files matching DEFAULT_EXCLUDE_GLOBS and read_file refuses them with
DevToolError::Excluded. edit_file requires a prior read_file by the same
session and agent, and refuses a file that changed since with
DevToolError::Stale: every read and write records the file’s sha256 in a
ReadLedger, which a host can persist with Workspace::with_read_ledger.
edit_file, write_file and apply_patch also take expect_sha256, the content a
decision approved, and write nothing when the file differs (spec 3.1 §7.26).
bash runs host-local through HostLauncher with a cleared environment plus
DEFAULT_ENV_ALLOWLIST, so provider API keys in the agent process are not
visible to commands. The command reads end of file from standard input, runs in
a new session with no controlling terminal, and its process group is killed when
the shell exits, so nothing it starts outlives the call. For strong isolation,
give BashTool::with_launcher a CommandLauncher that wraps the script in a
sandbox, or run commands behind a containerized adk-code executor (see
docs/design/coding-agent.md). The policy vocabulary is aligned with
adk-code’s SandboxPolicy.
Re-exports§
pub use tools::ApplyPatchTool;pub use tools::BashTool;pub use tools::BoundedOutput;pub use tools::DEFAULT_MAX_INLINE_BYTES;pub use tools::EditFileTool;pub use tools::GlobTool;pub use tools::GrepTool;pub use tools::INLINE_OUTPUT_CHARS;pub use tools::OutputFile;pub use tools::OutputStore;pub use tools::ReadFileTool;pub use tools::RunningCommand;pub use tools::WriteFileTool;pub use tools::bound_output;pub use tools::sniff_inline_mime;
Modules§
- patch
- The
*** Begin Patchenvelopeapply_patchtakes: its parser and its matcher (spec 3.1 §7.26, §10 D8). - tools
- The individual developer tools.
Structs§
- DevToolset
- Bundles the developer tools (
read_file,write_file,edit_file,apply_patch,glob,grep,bash) so they can be attached to an agent in one call. - Host
Launcher - Runs a script on the host as
sh -c <script>, the defaultCommandLauncher. - InMemory
Read Ledger - Read records in process memory, per scope, with least-recently-used eviction of scopes (spec 3.1 §10 D2, D7).
- Read
Scope - The session and agent a read is recorded for (spec 3.1 §10 D7).
- Workspace
- A workspace roots every file/search/shell operation at a directory and enforces a small capability policy.
Enums§
- DevTool
Error - Errors produced by the developer tools.
Constants§
- DEFAULT_
ENV_ ALLOWLIST - Environment variables
bashreceives by default. - DEFAULT_
EXCLUDE_ GLOBS - File patterns a new
Workspaceexcludes: environment files, private keys and certificate bundles. - DEFAULT_
MAX_ OUTPUT_ BYTES - The most bytes of a
bashcommand’s output its output file keeps unlessWorkspace::max_output_bytessays otherwise: 64 MiB (spec 3.1 §10 D10).
Traits§
- Command
Launcher - Builds the process that runs one
bashscript. - Read
Ledger - Where read records live (spec 3.1 §10 D7).
Functions§
- sha256_
hex - The lowercase hex sha256 of
bytes, as read records,expect_sha256and theapply_patchreport write it.
Type Aliases§
- Launch
Guard - What a
CommandLauncherkeeps alive until a command’s process has ended (CommandLauncher::guarded_command).