Interface IMemoryInstance

Interface for memory instance implementations. Defines the contract for local, persist, and dummy backends.

interface IMemoryInstance {
    dispose(): void;
    listMemory<T extends object = object>(): Promise<
        { content: T; memoryId: string }[],
    >;
    readMemory<T extends object = object>(memoryId: string): Promise<T>;
    removeMemory(memoryId: string): Promise<void>;
    searchMemory<T extends object = object>(
        query: string,
        settings?: SearchSettings,
    ): Promise<{ content: T; memoryId: string; score: number }[]>;
    waitForInit(initial: boolean): Promise<void>;
    writeMemory<T extends object = object>(
        memoryId: string,
        value: T,
        description: string,
    ): Promise<void>;
}

Methods

  • Releases any resources held by this instance.

    Returns void

  • List all entries in memory.

    Type Parameters

    • T extends object = object

    Returns Promise<{ content: T; memoryId: string }[]>

    Array of all stored entries

  • Read a single entry from memory.

    Type Parameters

    • T extends object = object

    Parameters

    • memoryId: string

      Unique entry identifier

    Returns Promise<T>

    Entry value

    Error if entry not found

  • Remove an entry from memory.

    Parameters

    • memoryId: string

      Unique entry identifier

    Returns Promise<void>

  • Search memory using BM25 full-text scoring.

    Type Parameters

    • T extends object = object

    Parameters

    • query: string

      Search query string

    • Optionalsettings: SearchSettings

    Returns Promise<{ content: T; memoryId: string; score: number }[]>

    Array of matching entries with scores

  • Initialize the memory instance.

    Parameters

    • initial: boolean

      Whether this is the first initialization

    Returns Promise<void>

  • Write a value to memory.

    Type Parameters

    • T extends object = object

    Parameters

    • memoryId: string

      Unique entry identifier

    • value: T

      Value to store

    • description: string

      Optional BM25 index string; defaults to JSON.stringify(value)

    Returns Promise<void>