ART Framework API Docs
    Preparing search index...

    Class InMemoryStorageAdapter

    An in-memory implementation of the StorageAdapter interface. Stores all data in JavaScript Maps within the current process memory. Data is not persisted and will be lost when the application session ends.

    Useful for:

    • Unit and integration testing (fast, no external dependencies).
    • Simple demos or examples where persistence isn't needed.
    • Ephemeral agents that don't require long-term memory.

    It provides a simple key-value store for various data types used within the ART framework, such as conversation history, agent state, and observations.

    StorageAdapter for the interface definition.

    Implements

    Index

    Constructors

    Methods

    • Removes all items from a specific collection within the in-memory store.

      Parameters

      • collection: string

        The name of the collection to clear.

      Returns Promise<void>

      A promise that resolves when the collection is cleared.

    • Deletes an item from a specified collection using its ID. If the collection or item does not exist, the operation completes silently.

      Parameters

      • collection: string

        The name of the collection.

      • id: string

        The unique ID of the item to delete.

      Returns Promise<void>

      A promise that resolves when the deletion attempt is complete.

    • Retrieves a single item (as a deep copy) from a specified collection by its ID.

      Type Parameters

      • T

        The expected type of the retrieved item.

      Parameters

      • collection: string

        The name of the data collection (e.g., 'messages', 'observations').

      • id: string

        The unique ID of the item within the collection.

      Returns Promise<null | T>

      A promise resolving to a deep copy of the item if found, or null otherwise.

    • Initializes the adapter. This is a no-op for the in-memory adapter and is provided for interface compatibility.

      Parameters

      • Optional_config: any

        Optional configuration (ignored by this adapter).

      Returns Promise<void>

      A promise that resolves immediately.

    • Queries items within a collection based on provided filter options. Note: This in-memory implementation provides basic filtering capabilities:

      • Supports exact matches on top-level properties specified in filterOptions.filter.
      • Supports limiting results via filterOptions.limit.
      • Does not support sorting (filterOptions.sort), skipping (filterOptions.skip), complex operators (like $gt, $in), or nested property filtering.

      Type Parameters

      • T

        The expected type of the items in the collection.

      Parameters

      • collection: string

        The name of the collection to query.

      • filterOptions: FilterOptions

        Options for filtering and limiting the results.

      Returns Promise<T[]>

      A promise resolving to an array of deep copies of the matching items.

    • Saves (creates or updates) an item in a specified collection. Stores a deep copy of the provided data to prevent external mutations.

      Type Parameters

      • T

        The type of the data being saved.

      Parameters

      • collection: string

        The name of the collection.

      • id: string

        The unique ID for the item.

      • data: T

        The data object to save.

      Returns Promise<void>

      A promise that resolves when the data is saved in memory.