Omni.Tools.Repl.Extensions.Files (Omni Tools v0.3.0)

Copy Markdown View Source

REPL extension that bridges Omni.Tools.Files into the sandbox.

When an agent has both REPL and Files tools, it can generate data in the REPL and then write it via a separate Files tool use. This extension removes that round-trip — code running in the sandbox can read and write files directly through a Files module that operates on the same configured filesystem scope.

The extension accepts a %Omni.Tools.Files.FS{} struct or the same raw options as the Files tool, so the sandbox inherits the same base directory, read-only flag, and nesting policy.

Files.write("chart.html", html_content)   #=> %Entry{}
Files.read("data.csv")                     #=> "csv,content..."
Files.patch("chart.html", "old", "new")    #=> %Entry{}
Files.list()                                #=> [%Entry{}, ...]
Files.delete("temp.txt")                    #=> :ok

Options

Either pass a pre-built %FS{} or the options to build one:

  • :fs — a %Omni.Tools.Files.FS{} struct. When provided, :base_dir, :read_only, and :nested are ignored.
  • :base_dir (required if :fs is not given) — absolute path to the base directory.
  • :read_only — restricts to read and list only. Default false.
  • :nested — allows subdirectory paths. Default true.

Usage

# With a pre-built FS (shared with the Files tool)
fs = Omni.Tools.Files.FS.new(base_dir: "/tmp/workspace")

Omni.Tools.Repl.new(
  extensions: [{Omni.Tools.Repl.Extensions.Files, fs: fs}]
)

# With raw options
Omni.Tools.Repl.new(
  extensions: [{Omni.Tools.Repl.Extensions.Files, base_dir: "/tmp/workspace"}]
)