Memory-specific HNSW sidecar that wraps the canonical HnswIndexSidecar.

Maintains the original constructor-based API expected by Memory facade and SqliteBrain consumers, while delegating all index operations to the shared RAG implementation.

Accessors

Constructors

Methods

  • Initialize the sidecar. Loads existing index from disk if present. If hnswlib-node is not installed, silently stays inactive.

    Returns Promise<void>

  • Add a vector to the index. If below threshold, does nothing. If threshold is crossed, caller should call rebuildFromData().

    Parameters

    • traceId: string

      The trace ID to associate with this vector.

    • embedding: number[]

      The embedding vector.

    • _totalCount: number

      Current total trace count (unused, kept for API compat).

    Returns Promise<void>

  • Remove a trace from the index by marking its label as deleted. HNSW doesn't support true deletion — cleaned up on rebuild.

    Parameters

    • traceId: string

      The trace ID to remove.

    Returns void

  • Rebuild the entire index from a set of id/embedding pairs. Called on first threshold crossing or when brain.hnsw is missing/corrupt. Filters out dimension-mismatched vectors before delegating.

    Parameters

    • data: {
          id: string;
          embedding: number[];
      }[]

      Array of { id, embedding } to index.

    Returns Promise<void>