Skip to main content

File System

Read, write, list, and inspect local files. All paths are sandboxed to a basePath directory, preventing traversal attacks.

Quick Start

import { Agent, openai, FileSystemToolkit } from "@radaros/core";

const fsTk = new FileSystemToolkit({
  basePath: "./data",
  allowWrite: true,
});

const agent = new Agent({
  name: "file-manager",
  model: openai("gpt-4o"),
  instructions: "Help manage files in the data directory.",
  tools: [...fsTk.getTools()],
});

const result = await agent.run("List all files in the data directory");

Config

basePath
string
Root directory for file access. All paths are resolved relative to this. Prevents directory traversal.
allowWrite
boolean
default:"false"
Enable the fs_write_file tool. Disabled by default for safety.

Tools

ToolDescription
fs_read_fileRead the contents of a file.
fs_list_directoryList files and subdirectories. Supports recursive listing.
fs_file_infoGet file metadata (size, type, modified/created dates).
fs_write_fileWrite or append to a file. Only available when allowWrite: true.
Enable allowWrite only when necessary. Always set a basePath to restrict file access.