Skip to content

FileStorage

Defined in: src/session/file-storage.ts:25

File-based implementation of SnapshotStorage. Persists session snapshots to the local filesystem under a configurable base directory.

Directory layout:

<baseDir>/<sessionId>/scopes/<scope>/<scopeId>/snapshots/
snapshot_latest.json
immutable_history/
snapshot_<uuid7>.json
new FileStorage(baseDir): FileStorage;

Defined in: src/session/file-storage.ts:32

ParameterTypeDescription
baseDirstringAbsolute path to the root directory for storing session snapshots.

FileStorage

saveSnapshot(params): Promise<void>;

Defined in: src/session/file-storage.ts:62

Persists a snapshot to disk. If isLatest is true, writes to snapshot_latest.json (overwriting any previous). Otherwise, writes to immutable_history/snapshot_<snapshotId>.json.

ParameterType
params{ location: SnapshotLocation; snapshotId: string; isLatest: boolean; snapshot: Snapshot; }
params.locationSnapshotLocation
params.snapshotIdstring
params.isLatestboolean
params.snapshotSnapshot

Promise<void>

SnapshotStorage.saveSnapshot


loadSnapshot(params): Promise<Snapshot>;

Defined in: src/session/file-storage.ts:79

Loads a snapshot from disk. If snapshotId is omitted, loads snapshot_latest.json. Returns null if the file does not exist.

ParameterType
params{ location: SnapshotLocation; snapshotId?: string; }
params.locationSnapshotLocation
params.snapshotId?string

Promise<Snapshot>

SnapshotStorage.loadSnapshot


listSnapshotIds(params): Promise<string[]>;

Defined in: src/session/file-storage.ts:94

Lists immutable snapshot IDs for a scope, sorted chronologically. Since IDs are UUID v7, lexicographic sort equals chronological order. startAfter filters to IDs after the given UUID v7 (exclusive cursor). limit caps the number of returned IDs. Returns an empty array if no snapshots exist yet.

ParameterType
params{ location: SnapshotLocation; limit?: number; startAfter?: string; }
params.locationSnapshotLocation
params.limit?number
params.startAfter?string

Promise<string[]>

SnapshotStorage.listSnapshotIds


deleteSession(params): Promise<void>;

Defined in: src/session/file-storage.ts:126

Deletes all data for a session by removing its root directory (<baseDir>/<sessionId>/) recursively. No-ops if the session directory does not exist.

ParameterType
params{ sessionId: string; }
params.sessionIdstring

Promise<void>

SnapshotStorage.deleteSession


loadManifest(params): Promise<SnapshotManifest>;

Defined in: src/session/file-storage.ts:140

Loads the snapshot manifest for a scope. Returns a default manifest with the current timestamp if none exists yet.

ParameterType
params{ location: SnapshotLocation; }
params.locationSnapshotLocation

Promise<SnapshotManifest>

SnapshotStorage.loadManifest


saveManifest(params): Promise<void>;

Defined in: src/session/file-storage.ts:155

Persists the snapshot manifest for a scope to disk.

ParameterType
params{ location: SnapshotLocation; manifest: SnapshotManifest; }
params.locationSnapshotLocation
params.manifestSnapshotManifest

Promise<void>

SnapshotStorage.saveManifest