import type Database from 'better-sqlite3'; import { type Embedder } from './embeddings.js'; import type { Fact, FactInsert, Outcome, PersistedOptimization, Verdict, MemoryMatch, MemoryScope, Pack, PackChunk, Entity, EntityKind } from './types.js'; /** * High-level memory API. The rest of the engine should talk to this, not * the raw DB — so when Day 3 swaps in a remote backend, the engine doesn't * change. Every method is null-safe when the DB / vector extension isn't * available (degrades to no-ops rather than throwing). */ export declare class MemoryStore { private db; private vectors; private embedder; /** Vector table name for the configured embedder dim, e.g. `embeddings_1536`. */ private vecTable; constructor(db?: Database.Database, embedder?: Embedder); isHealthy(): boolean; hasVectors(): boolean; upsertSession(sessionId: string): void; recordOptimization(opt: PersistedOptimization): void; getOptimization(id: string): PersistedOptimization | undefined; recordOutcome(o: { optimizationId: string; sessionId: string; verdict: Verdict; diff?: string; ts?: number; }): number; listUnreflectedOutcomes(limit?: number): Outcome[]; markOutcomeReflected(id: number): void; insertFact(f: FactInsert): number; /** * Soft-delete via bi-temporal invalidation, Graphiti-style. * Returns true when an actual invalidation happened (i.e. the row * existed and was still live). Returns false when the id doesn't * exist OR the fact was already invalidated. Lets MCP tool handlers * report a clean "not found" without an extra read. */ invalidateFact(id: number, supersededBy?: number, atMs?: number): boolean; listLiveFacts(scope: MemoryScope, predicate?: string, limit?: number): Fact[]; upsertEntity(scope: MemoryScope, kind: EntityKind, name: string): Entity; /** * Store an embedding vector for a source row. `kind` partitions the * vector table so we can search within a specific memory type. */ embedAndStore(kind: 'fact' | 'outcome' | 'pack_chunk' | 'optimization', sourceId: number | string, text: string): Promise; /** * Semantic search across a single kind. Returns MemoryMatch rows joined * to the source content. Low-level; Pass 3 builds higher-level retrieval * (dual local/global + temporal filter) on top. */ searchByVector(kind: 'fact' | 'outcome' | 'pack_chunk' | 'optimization', query: string, limit?: number): Promise; private hydrateMatch; insertPack(p: Omit): number; insertPackChunk(c: Omit): number; listPacks(scope?: MemoryScope): Pack[]; removePack(id: number): void; } /** Rough token approximation; cheap, good enough for budgeting. ~4 chars/token. */ export declare function approxTokens(s: string): number; export declare function getMemoryStore(): MemoryStore; export declare function resetMemoryStore(): void;