agentkit-tool-fs
Filesystem tools and session-scoped policies for agentkit.
This crate provides seven tools that let an agent interact with the local filesystem, plus a policy layer that can enforce rules like "read before write."
Tools
| Tool name | Description |
|---|---|
fs.read_file |
Read a UTF-8 file, optionally a line range |
fs.write_file |
Write UTF-8 text, creating parent dirs if needed |
fs.replace_in_file |
Find-and-replace exact text in a file |
fs.move |
Move or rename a file or directory |
fs.delete |
Delete a file or directory |
fs.list_directory |
List entries in a directory |
fs.create_directory |
Create a directory (and parents) |
Quick start
Get a ToolRegistry containing all filesystem tools with a single call:
use registry;
let reg = registry;
assert_eq!;
Policy configuration
FileSystemToolResources tracks which paths each session has inspected.
Combined with FileSystemToolPolicy, you can require that the agent reads a
file before it writes, replaces, moves, or deletes it:
use ;
let resources = new
.with_policy;
// Pass `resources` as the ToolResources in your ToolContext so the
// filesystem tools can enforce the policy at invocation time.
let _ = resources;
Using individual tools
Each tool struct implements Default and the Tool trait, so you can also
register only the tools you need:
use ;
use ;
let reg = new
.with
.with;
assert_eq!;