Skip to main content

Crate aidaemon_tools

Crate aidaemon_tools 

Source
Expand description

§aidaemon-tools (experimental)

A small default tool set for aidaemon_core agents, built on lessons from agent-computer interfaces (SWE-agent, Claude Code, Aider): few non-overlapping tools, bounded output, actionable errors, and validation before mutation.

ToolNameAnnotations
ReadFileread_fileread-only
WriteFilewrite_filewrite (idempotent)
EditFileedit_filewrite
Globglobread-only
Grepgrepread-only
Shellshelldestructive
WebFetchweb_fetchread-only
Checklisttrack_requirementswrite (agent state only)

Every file tool is confined to a Workspace. The shell runs through a Sandbox; containment (sandboxing) lives there, while approval stays a policy concern for aidaemon_core::Hooks. No tool contains approval logic.

use aidaemon_tools::{default_tools, Checklist, Workspace};
let workspace = Workspace::new("./my-project")?;
let (checklist, gate) = Checklist::with_gate();
let mut builder = aidaemon_core::Agent::builder("coder").allow_unguarded()
    .model("some-model")
    .provider(provider)
    .tool(checklist)
    .hook(gate);
for tool in default_tools(workspace) {
    builder = builder.tool_arc(tool);
}
let agent = builder.build()?;

Re-exports§

pub use backend::BackendDirEntry;
pub use backend::BackendFileType;
pub use backend::BackendKind;
pub use backend::BackendMetadata;
pub use backend::BackendPath;
pub use backend::CommandSpec;
pub use backend::ExecutionBackend;
pub use backend::ExecutionOutput;
pub use backend::ExecutionRequest;
pub use backend::LexicalPaths;
pub use backend::ProcessHandle;
pub use backend::SpawnedProcess;
pub use backend::WriteMode;
pub use backend::shell_quote;
pub use outcome::CallValidator;
pub use outcome::KernelAdapter;
pub use outcome::NothingSentError;
pub use outcome::OutcomeRunner;
pub use outcome::OutcomeTool;
pub use outcome::TargetNotFound;
pub use outcome::ToolTimedOut;
pub use outcome::failed_without_effect;
pub use outcome::timed_out;
pub use path_class::PathClassifier;
pub use web::NetworkGuard;
pub use web::WebFetch;

Modules§

backend
The workspace execution contract: one persistent agent-visible workspace whose files and processes a tool reaches through an ExecutionBackend.
background_deliverable
Typed background artifact attribution.
backoff
Retry delays.
check_environment
cli_agent_flags
The terminal agents’ (codex, claude, gemini, opencode) launch flags: their names, defaults kept in the settings store, and flags discovered from --help.
command_effects
Structural typing of a shell command’s effects for authority decisions.
command_risk
config_file
The host’s config file, as the tools that edit it see it: where it is, how a new text is checked before it is written, and the backups kept beside it. The host owns what a valid config is (ConfigCheck); the tools only read, change and save the TOML.
daemon_guard
duration_format
Compact durations for messages to the owner (45s, 3m 10s, 2h).
execution
Workspace-bound execution backends: where agent-visible files and processes live. The local backend is LocalBackend; this module adds the SSH backend and, behind the docker feature, a persistent Docker container, plus the [execution] settings that pick one.
file_delivery
fs_utils
http_request
internal_markers
The daemon’s own markers, rendered for the owner.
local_backend
The host’s own filesystem and processes as an ExecutionBackend.
local_sites
Sites on this computer that the owner’s own work brought up.
outcome
Tools that report a typed ToolCallOutcome.
owner_answers
Owner approvals the agent kernel delivered for exact call subjects.
path_class
Which paths hold secrets or must not be touched by the file tools.
permission_bypass
Launch arguments that switch a CLI coding agent (claude, codex, gemini, copilot, aider) into unattended auto-approve mode, and their removal. The single list for every place that launches an agent.
platform_shell
The shell a command line runs in: sh -c on Unix, Windows PowerShell on Windows (always present, unlike sh). The command-effect checks are written for POSIX shells and fail closed: a PowerShell line they cannot read as a known observation or local work is treated as unknown, so it asks first.
process_control
result_spill
Spill oversized tool results to disk so the model can recover the full data via read_file paging / terminal jq/grep, instead of losing the middle to in-context head+tail compression. The on-disk file is the full, untruncated result; the returned preview is a bounded head + structural summary + an anti-fabrication pointer to the file.
sanitize
Input sanitization for external content (tool outputs, web fetches).
semantics
The semantic half of a daemon tool: plain data that describes a call without executing it (capabilities, typed call semantics, access manifests, receipt metadata, execution facts) and the helpers that derive the conservative defaults.
services
Narrow store services that tools hold: settings, OAuth connections and runtime-managed CLI agents, plus the plain data those traits carry. The daemon’s SQLite store implements them; a tool receives an Arc<dyn ...> of the slice it needs through its constructor. Memory stores (facts, episodes, history, people) live in aidaemon-memory.
shown
A tool call as the owner’s apps show it: its arguments and its result, secrets redacted and trimmed. One shape for a call seen live and the same call read back from history, so a step says as much either way.
status
Live progress of a turn: what tools and the agent loop report while they work, and the channel a tool call’s progress goes to.
stt_setup
Shared Whisper STT discovery and config helpers for wizard and manage_config.
system
text
Text helpers shared by tools and event payloads.
tls
TLS for the sockets reqwest does not open (websockets, IMAP).
web
web_fetch: GET a page and return its readable text.
web_search

Structs§

BubblewrapSandbox
Linux sandbox using bwrap: the host filesystem is mounted read-only, the workspace read-write, /tmp is a private tmpfs, PID and (unless allowed) network namespaces are unshared, and the sandbox dies with its parent. The credential locations in HOME_SECRET_PATHS are hidden by default.
BubblewrapScope
What a task-scoped bubblewrap sandbox may touch: deny by default, unlike BubblewrapSandbox::args (which mounts the whole host read-only). The command sees the base system directories (the dynamic loader, /usr, /bin, /lib), a private /dev, /proc and /tmp, and exactly the listed paths: read_paths read-only, write_paths read-write. With allow_network it also sees the resolver and CA configuration it needs to use the network. Listed paths that do not exist are skipped.
Checklist
The track_requirements tool. Each call replaces the whole list, so the model always states the full current plan.
ChecklistGate
Stop hook: while any item is pending or in progress, ask the model to keep going, listing them. Once nothing is open it lets the run stop; if any item is deferred (or superseded by one that is), it reports those as unmet (StopDecision::AcceptUnmet) so the run is not counted as a success. The agent’s turn limits still bound how long this can continue.
ChecklistItem
ChecklistState
Shared checklist state. Clone it to share between the tool, the gate and your own code. Use one per run or session.
CommandOutput
What a command did.
DockerSandbox
Runs each command in a fresh container: the workspace is mounted at /workspace, --network none unless allowed, and the container is removed afterwards (and killed on timeout). No other host path is mounted, so host paths in SandboxCommand::deny_read are out of reach already; denied paths inside the workspace are covered by an empty mount. On Unix the container runs as the calling user so files it creates stay editable.
EditFile
Glob
Find files by glob pattern, respecting .gitignore.
Grep
Search file contents with a regular expression.
HostFilePolicy
The policy for file tools on the host’s own filesystem: secret and sensitive paths (and the application’s own files) by DaemonPaths, images as attachments, backups before an overwrite, a syntax check after a write, and the effects of a write (git configuration among them).
HostFilePolicySettings
What a HostFilePolicy says and keeps, as the application words it.
LocalSandbox
Runs commands directly on the host with sh -c.
ProtectedPathGuard
Refuses a call whose declared paths hold secrets or must not be changed.
ReadFile
SandboxCommand
One command to run.
SandboxSelection
The result of select_sandbox.
SearchFiles
SeatbeltSandbox
macOS sandbox using sandbox-exec with a generated profile: everything is readable except the credential locations in HOME_SECRET_PATHS (by default) and each command’s deny list, writes are allowed only under the workspace (plus the /dev null/tty nodes), and the network is denied unless allowed.
Shell
Run shell commands in the workspace.
ToolText
A tool’s model-facing descriptions, for an application that words them for its own tool set.
Workspace
A root directory that confines every path argument a tool receives.
WorkspaceBackend
File access confined to a Workspace. Every operation re-resolves its path, so a symlink cannot lead outside the root. It runs no processes; commands go through crate::Shell and its sandbox.
WorkspaceFilePolicy
The policy for tools confined to a Workspace.
WriteFile

Enums§

ExecError
The command could not be started (as opposed to starting and failing).
ItemStatus
Where an item stands. The model sets pending, in_progress, done, deferred and superseded; only the application sets waived (ChecklistState::waive), because only the owner can drop scope.
PathError
Why a path argument was refused.
SandboxKind
The backends the default shell can choose between.
TerminalConfinement
Where terminal commands execute.

Constants§

DEFAULT_ENV_ALLOWLIST
Host variables passed through by default.
DEFAULT_IGNORE_DIRS
Directories to skip during recursive file walks.
HOME_SECRET_PATHS
Credential locations under the home directory that the contained backends (BubblewrapSandbox, SeatbeltSandbox) keep commands from reading by default: SSH keys, cloud and cluster credentials, GnuPG, registry logins, .netrc and git’s stored credentials. Replace the list per backend with default_deny_read(..) (an empty list turns the defaults off).
MAX_READ_CHARS
Per-call cap on returned content (bytes of line text). Reads that would exceed it return the first lines that fit plus a continuation hint instead of an unbounded payload.
SANDBOX_ENV
Environment variable that overrides the default shell’s backend: auto (or unset), bubblewrap, seatbelt, or local (no containment).

Traits§

FilePolicy
What an application decides about the file tools.
Sandbox
Where commands run.

Functions§

best_available_sandbox
The default shell’s backend: the one named by SANDBOX_ENV, else the most contained one available here (bubblewrap on Linux, seatbelt on macOS), else LocalSandbox (uncontained) with a one-time warning. Docker is never picked automatically because it needs an image choice.
default_deny_read
HOME_SECRET_PATHS under $HOME (empty when HOME is unset): the contained backends’ default deny-read list.
default_tools
The standard set: read_file, write_file, edit_file, glob, grep, shell (with best_available_sandbox: bubblewrap on Linux, seatbelt on macOS) and web_fetch.
default_tools_with_sandbox
default_tools with the shell on an explicit backend, for example SandboxKind::Local.backend() to run commands on the host on purpose.
format_with_line_numbers
Format file content with line numbers.
home_secret_paths
HOME_SECRET_PATHS under home.
render_read_file_output
render_read_file_output_within
Render a read result within a character budget, cutting on line boundaries and appending an explicit continuation hint when lines had to be dropped. Results that fit are rendered unchanged, so big-budget models see exactly what they do today.
sandbox_preference_from_env
Read SANDBOX_ENV: Ok(None) for unset, empty or auto.
select_sandbox
Pick a backend. An explicit preference always wins (an unavailable one then fails each command with ExecError::Unavailable rather than running uncontained). Otherwise the first available of bubblewrap and seatbelt, else SandboxKind::Local with fell_back set. available is the probe, injectable for tests.
sniff_image_mime
The MIME type of an image, from its magic bytes.