Utility class for managing memory entry persistence.
Features:
Storage layout: ./dump/memory/<signalId>/<bucketName>/<memoryId>.json
Used by MemoryPersistInstance for crash-safe memory persistence.
constructor();
PersistMemoryFactory: any
getMemoryStorage: any
waitForInit: (signalId: string, bucketName: string, initial: boolean) => Promise<void>
Initializes the storage for a given (signalId, bucketName) pair.
readMemoryData: (signalId: string, bucketName: string, memoryId: string) => Promise<MemoryData>
Reads a memory entry from persistence storage.
hasMemoryData: (signalId: string, bucketName: string, memoryId: string) => Promise<boolean>
Checks if a memory entry exists in persistence storage.
writeMemoryData: (data: MemoryData, signalId: string, bucketName: string, memoryId: string) => Promise<void>
Writes a memory entry to disk with atomic file writes.
removeMemoryData: (signalId: string, bucketName: string, memoryId: string) => Promise<void>
Marks a memory entry as removed (soft delete — file is kept on disk).
clear: () => void
Clears the memoized storage cache. Call this when process.cwd() changes between strategy iterations so new storage instances are created with the updated base path.
dispose: (signalId: string, bucketName: string) => void
Disposes of the memory adapter and releases any resources. Call this when a signal is removed to clean up its associated storage.
usePersistMemoryAdapter(Ctor: TPersistBaseCtor<string, MemoryData>): void;
Registers a custom persistence adapter.
listMemoryData(signalId: string, bucketName: string): AsyncGenerator<{
memoryId: string;
data: MemoryData;
}>;
Lists all memory entry IDs for a given (signalId, bucketName) pair. Used by MemoryPersistInstance to rebuild the BM25 index on init.
useJson(): void;
Switches to the default JSON persist adapter. All future persistence writes will use JSON storage.
useDummy(): void;
Switches to a dummy persist adapter that discards all writes. All future persistence writes will be no-ops.