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 Details

    • read

      String read(String filePath, int offset, int limit)
      Read file content with line numbers and pagination.
      Parameters:
      filePath - Absolute or relative file path
      offset - 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

      WriteResult write(String filePath, String content)
      Write content to a new file.
      Parameters:
      filePath - Absolute or relative file path
      content - Content to write
      Returns:
      WriteResult with path or error. External storage sets filesUpdate=null.
    • edit

      EditResult edit(String filePath, String oldString, String newString, boolean replaceAll)
      Edit file by replacing string occurrences.
      Parameters:
      filePath - Absolute or relative file path
      oldString - String to replace
      newString - Replacement string
      replaceAll - Whether to replace all occurrences
      Returns:
      EditResult with occurrences count or error. External storage sets filesUpdate=null.
    • lsInfo

      List<FileInfo> lsInfo(String path)
      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

      List<FileInfo> globInfo(String pattern, String path)
      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

      Object grepRaw(String pattern, String path, String glob)
      Search for pattern in files using regex.
      Parameters:
      pattern - Regex pattern to search for
      path - 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