UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

50 lines • 2.54 kB
import type { RecordClient, RecordFields } from '../../record/types.ts'; export type NodeFields = Record<string, string | number>; /** * Storage seam for mirage's own state: one keyed table of JSON records. * * A workspace keeps two of them: the node table (symlinks and the attribute * overlay, keyed by virtual path) and the session table (env, cwd, functions * and mount grants, keyed by session id). The owner keeps the working copy in * memory, hydrates once from the store, and writes through on mutation, so * both survive process restarts and are visible to any workspace pointed at * the same store. Subclasses are infra adapters (RAM here, disk and Redis in * the node package, a keyed record client); everything above (symlinks, the * overlay, sessions, snapshots) is storage-agnostic, mirroring the * ObserverStore design. */ export declare abstract class NamespaceStore { abstract load(): Promise<Map<string, RecordFields>>; abstract set(key: string, fields: RecordFields): Promise<void>; /** * Write one record iff its stored generation matches. * * Optimistic concurrency for the session flush: the write lands only when * the stored record's `generation` equals `expectedGeneration` (a missing * record and a record without the field both count as generation 0). * `replaceAll` stays unchecked on purpose: a snapshot restore wins * wholesale. Resolves true when the write landed, false on conflict. */ abstract casSet(key: string, fields: RecordFields, expectedGeneration: number): Promise<boolean>; abstract delete(keys: readonly string[]): Promise<void>; abstract replaceAll(entries: Map<string, RecordFields>): Promise<void>; abstract clear(): Promise<void>; abstract close(): Promise<void>; } /** * A NamespaceStore over a keyed-record client, one record per key. The disk * and S3 session tables differ only in the client they hand in. Mirrors * Python's `RecordNamespaceStore`. */ export declare class RecordNamespaceStore extends NamespaceStore { private readonly records; constructor(records: RecordClient); load(): Promise<Map<string, RecordFields>>; set(key: string, fields: RecordFields): Promise<void>; casSet(key: string, fields: RecordFields, expectedGeneration: number): Promise<boolean>; delete(keys: readonly string[]): Promise<void>; replaceAll(entries: Map<string, RecordFields>): Promise<void>; clear(): Promise<void>; close(): Promise<void>; } //# sourceMappingURL=store.d.ts.map