Package com.tnsai.tools.file
Class FileIoTools
java.lang.Object
com.tnsai.tools.file.FileIoTools
Function-shape filesystem read/write tools. Sandbox containment, size caps,
and extension whitelist are delegated to
FileGuard; the byte-level
I/O code below is the only thing this class owns directly.
Two ctors:
FileIoTools()— usesFileGuardConfig.defaults()andDEFAULT_EXTENSIONS. Required by theBuiltInToolcatalog which auto-instantiates POJOs via no-arg constructor.FileIoTools(FileGuardConfig)— explicit per-tenant config; use viaagentBuilder.toolPojos(new FileIoTools(tenantConfig)).
fileWrite(java.lang.String, java.lang.String) truncates and overwrites by default. Atomic move +
temp-file would be safer for crash tolerance but is out of scope; consumers
needing it should supply a custom tool.
-
Field Summary
FieldsModifier and TypeFieldDescriptionDefault extension whitelist for general filesystem read/write. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
DEFAULT_EXTENSIONS
Default extension whitelist for general filesystem read/write.
-
-
Constructor Details
-
FileIoTools
public FileIoTools() -
FileIoTools
-
-
Method Details
-
fileRead
@Tool(name="file_read", description="Read the UTF-8 text content of a file from the local filesystem. The path must resolve under the configured sandbox root; absolute paths to system files are rejected. The file size is checked before any byte is read into the JVM heap. Returns the entire file content as a string.", keywords={"file","read","open","load"}, idempotent=true) public String fileRead(@ToolParam(description="File path \u2014 absolute or relative; must resolve under the sandbox root") String path) throws IOException - Throws:
IOException
-
fileWrite
@Tool(name="file_write", description="Write UTF-8 text content to a file. Creates the file (and any missing parent directories) if absent, truncates and overwrites if it exists. Path must resolve under the configured sandbox root. Content size is capped to prevent disk-fill DoS. Returns a success message including the resolved path.", keywords={"file","write","save","output"}) public String fileWrite(@ToolParam(description="File path \u2014 absolute or relative; must resolve under the sandbox root") String path, @ToolParam(description="Content to write (UTF-8). Bound by the configured write cap.") String content) throws IOException - Throws:
IOException
-