2.6 KiB
infrastructure/tools/
Purpose
Tool implementations and execution infrastructure. Provides DefaultToolRegistry, DispatchingToolExecutor, and SandboxedToolExecutor. Implements concrete tools: shell execution (ShellTool), web search (WebSearchTool, requires SearXNG), web fetch + HTML→Markdown extraction (WebFetchTool, jsoup), task management tools, and filesystem tools (in filesystem/).
Ownership
Adapter for core:tools. Depends on core:tools, core:events, core:approvals, core:sessions, core:tasks, core:artifacts, core:artifacts-store. The filesystem/ submodule is a dependency of this module.
Local Contracts
DefaultToolRegistryimplementsToolRegistryfromcore:tools.SandboxedToolExecutorwrapsDispatchingToolExecutor; it enforces approval gates and records all tool side effects as events before returning (invariant #5).- No tool may execute a side effect without emitting an event — silent execution is not allowed.
- Web search and web fetch results are environment observations; they must be recorded as events by callers to preserve replay determinism (invariant #9).
ToolConfigis the only configuration surface; pass viaInfrastructureModule.createToolExecutor().buildTools()extension onToolConfigassembles the full tool list; add new tools there, not in the registry directly.- Filesystem mutation is split by intent:
file_writeonly writes ({path, content}),file_editedits, andfile_deleteonly deletes ({path}) — deletion is a separately-named capability so a model can never delete by getting a write-mode parameter wrong.file_deletesharesfile_write's path jail andfileWrite.enabledtoggle and carriesToolCapability.FILE_WRITE. list_diris shallow by default, but collapses a non-symlink single-child directory chain (bounded depth) to the first branch point and explains that expansion in its output; recursive listings retain normal tree traversal.
Work Guidance
Standard adapter rules apply (see parent AGENTS.md). Network calls (web tools) use Ktor CIO client with withContext(Dispatchers.IO). Shell tool executes OS processes — never suppress CancellationException in process wait loops.
Verification
./gradlew :infrastructure:tools:test --rerun-tasks
./gradlew :infrastructure:tools:filesystem:test --rerun-tasks
Child DOX Index
filesystem/— filesystem tools implementingcore:toolscontracts:FileReadTool,FileWriteTool(write-only),FileDeleteTool,FileEditTool, list; no separate AGENTS.md (sub-leaf, covered by this doc)