@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
48 lines • 2.17 kB
TypeScript
/**
* Storage seam for the hidden recorder.
*
* A store holds the recorder's JSONL files keyed by path
* (`/<day>/<session>.jsonl`). Implementations are infra adapters
* (RAM, disk, opfs); everything above this seam (the Observer queries,
* the /.bash_history view, the history builtin) is storage-agnostic.
*/
export interface ObserverStore {
/** Append bytes to the file at path, creating it if missing. */
append(path: string, data: Uint8Array): Promise<void>;
/** Overwrite the file at path (snapshot restore). */
write(path: string, data: Uint8Array): Promise<void>;
/** Read every stored file, keyed by file path. */
readAll(): Promise<Map<string, Uint8Array>>;
/** Read only the files whose key ends with `suffix`. */
readMatching(suffix: string): Promise<Map<string, Uint8Array>>;
/** Delete every stored file (snapshot-restore rewind). */
clear(): Promise<void>;
/** Release any held connections or handles. */
close(): Promise<void>;
}
/**
* Shared ObserverStore behavior.
*
* Implementations only provide `append`/`write`/`readMatching`/`clear`;
* `readAll` is reading with the empty suffix (every key matches), and
* `close` defaults to a no-op for stores that hold no connections.
* Mirrors Python `ObserverStoreBase`.
*/
export declare abstract class ObserverStoreBase implements ObserverStore {
abstract append(path: string, data: Uint8Array): Promise<void>;
abstract write(path: string, data: Uint8Array): Promise<void>;
abstract readMatching(suffix: string): Promise<Map<string, Uint8Array>>;
abstract clear(): Promise<void>;
readAll(): Promise<Map<string, Uint8Array>>;
close(): Promise<void>;
}
/** In-memory ObserverStore backed by a Map (the default). */
export declare class RAMObserverStore extends ObserverStoreBase {
readonly files: Map<string, Uint8Array<ArrayBufferLike>>;
private readonly room;
append(path: string, data: Uint8Array): Promise<void>;
write(path: string, data: Uint8Array): Promise<void>;
readMatching(suffix: string): Promise<Map<string, Uint8Array>>;
clear(): Promise<void>;
}
//# sourceMappingURL=store.d.ts.map