Updated protocol for pluggable memory backends.
Key differences from BackendProtocol:
read() returns ReadResult instead of a plain stringreadRaw() returns ReadRawResult instead of FileDatagrep() returns GrepResult instead of GrepMatch[] | stringls() returns LsResult instead of FileInfo[]glob() returns GlobResult instead of FileInfo[]Existing v1 backends can be adapted to this interface using adaptBackendProtocol from utils.
interface BackendProtocolV2Omit<BackendProtocolV1, "read" | "readRaw" | "grepRaw" | "lsInfo" | "globInfo">Delete a single file. Optional - backends that don't support file deletion can omit this.
Edit a file by replacing string occurrences.
Structured glob matching returning FileInfo objects.
Search file contents for a literal text pattern.
Binary files (determined by MIME type) are skipped.
Structured listing with file metadata.
Lists files and directories in the specified directory (non-recursive). Directories have a trailing / in their path and is_dir=true.
Read file content.
For text files, content is paginated by line offset/limit. For binary files, the full raw Uint8Array content is returned.
Read file content as raw FileData.
Write content to a file, creating it or overwriting it if it already exists.