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

| Parameter | Type | Description | | --------- | -------- | ------------------------------------------------------------------ | | baseDir | string | Absolute 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.

| Parameter | Type | | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | params | { location: SnapshotLocation; snapshotId: string; isLatest: boolean; snapshot: Snapshot; } | | params.location | SnapshotLocation | | params.snapshotId | string | | params.isLatest | boolean | | params.snapshot | Snapshot |

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.

| Parameter | Type | | -------------------- | ------------------------------------------------------------------------------------- | | params | { location: SnapshotLocation; snapshotId?: string; } | | params.location | SnapshotLocation | | 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.

| Parameter | Type | | -------------------- | --------------------------------------------------------------------------------------------------------- | | params | { location: SnapshotLocation; limit?: number; startAfter?: string; } | | params.location | SnapshotLocation | | 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.

| Parameter | Type | | ------------------ | --------------------------- | | params | { sessionId: string; } | | params.sessionId | string |

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.

| Parameter | Type | | ----------------- | ------------------------------------------------------------ | | params | { location: SnapshotLocation; } | | params.location | SnapshotLocation |

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.

| Parameter | Type | | ----------------- | -------------------------------------------------------------------------------------------------------------------- | | params | { location: SnapshotLocation; manifest: SnapshotManifest; } | | params.location | SnapshotLocation | | params.manifest | SnapshotManifest |

Promise<void>

SnapshotStorage.saveManifest