A gateway for interacting with the filesystem within a sandboxed base path.
This module provides safe filesystem operations that are restricted to a specific base directory, preventing path traversal attacks.
Summary
Functions
Finds files matching a glob pattern.
Finds files containing text matching a regex pattern.
Finds all lines in a file matching a regex pattern.
Lists all files recursively in a directory.
Lists files in a directory (non-recursive).
Creates a new FilesystemGateway with the specified base path.
Reads the content of a file.
Resolves a path relative to the base path and ensures it stays within the sandbox.
Writes content to a file.
Types
@type t() :: %Mojentic.LLM.Tools.FilesystemGateway{base_path: String.t()}
Functions
Finds files matching a glob pattern.
@spec find_files_containing(t(), String.t(), String.t()) :: {:ok, [String.t()]} | {:error, String.t()}
Finds files containing text matching a regex pattern.
@spec find_lines_matching(t(), String.t(), String.t(), String.t()) :: {:ok, [map()]} | {:error, String.t()}
Finds all lines in a file matching a regex pattern.
Lists all files recursively in a directory.
Lists files in a directory (non-recursive).
Creates a new FilesystemGateway with the specified base path.
Reads the content of a file.
Resolves a path relative to the base path and ensures it stays within the sandbox.
Writes content to a file.