Interface FilesystemBackend
- All Known Implementing Classes:
LocalFilesystemBackend
public interface FilesystemBackend
Backend interface for file storage operations.
Protocol for pluggable memory backends (single, unified).
Backends can store files in different locations (state, filesystem, database, etc.)
and provide a uniform interface for file operations.
NOTE: This interface supports different backend implementations:
- StateBackend: Stores files in agent state (ephemeral)
- StoreBackend: Persistent storage using Store
- CompositeBackend: Routes operations to different backends by path
- FilesystemBackend: Direct filesystem operations
-
Method Summary
Modifier and TypeMethodDescriptionEdit file by replacing string occurrences.Find files matching glob pattern.Search for pattern in files using regex.List files and directories in the specified directory (non-recursive).Read file content with line numbers and pagination.Write content to a new file.
-
Method Details
-
read
Read file content with line numbers and pagination.- Parameters:
filePath- Absolute or relative file pathoffset- Line offset to start reading from (0-indexed)limit- Maximum number of lines to read- Returns:
- Formatted file content with line numbers, or error message
-
write
Write content to a new file.- Parameters:
filePath- Absolute or relative file pathcontent- Content to write- Returns:
- WriteResult with path or error. External storage sets filesUpdate=null.
-
edit
Edit file by replacing string occurrences.- Parameters:
filePath- Absolute or relative file patholdString- String to replacenewString- Replacement stringreplaceAll- Whether to replace all occurrences- Returns:
- EditResult with occurrences count or error. External storage sets filesUpdate=null.
-
lsInfo
List files and directories in the specified directory (non-recursive).- Parameters:
path- Absolute directory path to list files from- Returns:
- List of FileInfo objects for files and directories directly in the directory. Directories have a trailing / in their path and isDir=true.
-
globInfo
Find files matching glob pattern.- Parameters:
pattern- Glob pattern (e.g., "*.py", "**/*.ts")path- Base path to search from- Returns:
- List of FileInfo objects for matching files
-
grepRaw
Search for pattern in files using regex.- Parameters:
pattern- Regex pattern to search forpath- Base path to search from (null for current directory)glob- Glob pattern to filter files (null for all files)- Returns:
- List of GrepMatch objects or error message
-