Package com.tnsai.server.tools
Class ServerFileTools
java.lang.Object
com.tnsai.server.tools.ServerFileTools
Function-shape file tools sandboxed to a working directory. Replaces the
legacy
FileReadTool + FileWriteTool (Phase 3b sweep,
issue #188).
| Method | Purpose | Idempotent |
|---|---|---|
fileRead(java.lang.String) | Read a file's contents (max 512 KB) | true |
fileWrite(java.lang.String, java.lang.String) | Write content to a file (overwrite-or-create, requires approval) | true (set semantics — same write twice yields the same file state) |
All paths are resolved relative to the agent's working directory. Path
traversal outside the working directory throws SecurityException.
- Since:
- 0.5.7 (Phase 3b — server-tool migration to function shape, see #188)
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ServerFileTools
-
-
Method Details
-
fileRead
@Tool(name="file_read", description="Read the contents of a file at {path} (relative to the agent\'s working directory). Returns the file content as a string. Capped at 512 KB. Throws if the path escapes the working directory or the file doesn\'t exist.", keywords={"file","read","load","open"}, idempotent=true) public String fileRead(@ToolParam(description="Relative or absolute file path") String path) throws IOException - Throws:
IOException
-
fileWrite
@Tool(name="file_write", description="Write {content} to a file at {path} (relative to the agent\'s working directory). Creates the file if it doesn\'t exist; overwrites if it does. Parent directories are auto-created. Returns the absolute path of the written file. Path is sandboxed to the working directory.", keywords={"file","write","save","create"}, idempotent=true) public String fileWrite(@ToolParam(description="Relative or absolute file path") String path, @ToolParam(description="File content to write") String content) throws IOException - Throws:
IOException
-