Interface IPersistMemoryInstance

Per-context memory entry persistence instance interface. Scoped to a specific (signalId, bucketName) pair.

Used by MemoryPersistInstance for LLM memory storage. Supports soft delete via removed: true flag — soft-deleted entries stay on disk but are filtered out by read/list operations.

Custom adapters should implement this interface to override the default file-based memory entry behavior.

interface IPersistMemoryInstance {
    dispose(): void;
    hasMemoryData(memoryId: string): Promise<boolean>;
    listMemoryData(): AsyncGenerator<{ data: MemoryData; memoryId: string }>;
    readMemoryData(memoryId: string): Promise<MemoryData>;
    removeMemoryData(memoryId: string): Promise<void>;
    waitForInit(initial: boolean): Promise<void>;
    writeMemoryData(
        data: MemoryData,
        memoryId: string,
        when: Date,
    ): Promise<void>;
}

Implemented by

Methods

  • Release any resources held by this instance. Default implementations may treat this as a no-op.

    Returns void

  • Check whether a memory entry exists (regardless of removed flag).

    Parameters

    • memoryId: string

      Memory entry identifier

    Returns Promise<boolean>

    Promise resolving to true if entry exists on disk

  • Iterate all non-removed memory entries for this context. Used by MemoryPersistInstance to rebuild the BM25 index on init.

    Returns AsyncGenerator<{ data: MemoryData; memoryId: string }>

    AsyncGenerator yielding entry id + data tuples

  • Read a memory entry by id.

    Parameters

    • memoryId: string

      Memory entry identifier

    Returns Promise<MemoryData>

    Promise resolving to entry data, or null if not found or soft-deleted

  • Soft-delete a memory entry. File stays on disk; subsequent reads return null.

    Parameters

    • memoryId: string

      Memory entry identifier

    Returns Promise<void>

    Promise that resolves when removal is complete

  • Initialize storage for this memory context.

    Parameters

    • initial: boolean

      Whether this is the first initialization

    Returns Promise<void>

    Promise that resolves when initialization is complete

  • Write a memory entry.

    Parameters

    • data: MemoryData

      Entry data to persist (already carries data.when)

    • memoryId: string

      Memory entry identifier

    • when: Date

      Logical timestamp this entry belongs to (duplicates data.when for API consistency)

    Returns Promise<void>

    Promise that resolves when write is complete