/** * FirestoreCortexStore — cloud Firestore-backed implementation of CortexStore. * * Uses firebase-admin for Firestore access. Vector search uses Firestore native * findNearest() for production-grade similarity search. * Dates stored as Firestore Timestamps. Embeddings stored as VectorValue. * * This is the cloud counterpart to SqliteCortexStore. Both implement the same * CortexStore interface, so engines work identically on either backend. */ import type { Firestore, FieldValue as FieldValueType } from '@google-cloud/firestore'; import type { CortexStore, StoreCapabilities } from '../core/store.js'; import type { Memory, Observation, Edge, OpsEntry, OpsFilters, Signal, BeliefEntry, SearchResult, FSRSData, QueryFilter } from '../core/types.js'; export interface FirestoreStoreOptions { /** GCP project ID (required if not using Application Default Credentials) */ projectId?: string; /** Firestore database ID (default: '(default)') */ databaseId?: string; /** Namespace prefix for collection names (for multi-tenant isolation) */ namespace?: string; } export declare class FirestoreCortexStore implements CortexStore { private db; private ns; constructor(db: Firestore, namespace?: string, fieldValue?: typeof FieldValueType); /** Inject the host's FieldValue to avoid ESM dual-package class identity issues. */ static setFieldValue(fv: typeof FieldValueType): void; /** Create a FirestoreCortexStore from firebase-admin Firestore instance. */ static fromFirestore(db: Firestore, namespace?: string, fieldValue?: typeof FieldValueType): FirestoreCortexStore; /** Get the prefixed collection name. */ private col; putMemory(memory: Omit): Promise; getMemory(id: string): Promise; updateMemory(id: string, updates: Partial>): Promise; findNearest(embedding: number[], limit: number): Promise; touchMemory(id: string, fsrsUpdates: Partial): Promise; getAllMemories(): Promise; getRecentMemories(days: number, limit: number): Promise; putObservation(obs: Omit): Promise; getUnprocessedObservations(limit: number): Promise; markObservationProcessed(id: string): Promise; putEdge(edge: Omit): Promise; getEdgesFrom(memoryId: string): Promise; getEdgesForMemories(memoryIds: string[]): Promise; appendOps(entry: Omit): Promise; queryOps(filters: OpsFilters): Promise; updateOps(id: string, updates: Partial>): Promise; putSignal(signal: Omit): Promise; putBelief(entry: Omit): Promise; getBeliefHistory(conceptId: string): Promise; put(collection: string, doc: Record): Promise; get(collection: string, id: string): Promise | null>; update(collection: string, id: string, updates: Record): Promise; query(collection: string, filters: QueryFilter[], options?: { limit?: number; orderBy?: string; orderDir?: 'asc' | 'desc'; }): Promise[]>; countDocuments(collection: string, filters?: QueryFilter[]): Promise; delete(collection: string, id: string): Promise; /** * Wraps db.runTransaction so any direct ref.set/update/delete issued through * the txn-bound proxy commits atomically. The proxy implements only the * subset of CortexStore that maps cleanly onto Firestore's reads-before-writes * transactional model: typed put/get/update for memories, observations, * edges, ops, signals, beliefs, plus generic put/get/update/delete. * * Unsupported inside the txn fn: findNearest (no transactional vector search), * queries that scan (no transactional query()), countDocuments, getRecent*, * getAllMemories, getBeliefHistory, queryOps. Callers needing those reads * must perform them outside the transaction and pass the IDs in. * * Nested calls are forbidden — Firestore actually allows nesting but mixing * outer reads with inner writes is a known footgun, so we treat parity with * SQLite as the contract. */ withTransaction(fn: (txn: CortexStore) => Promise): Promise; upsertMemory(memory: Memory): Promise; upsertObservation(obs: Observation): Promise; upsertEdge(edge: Edge): Promise; upsertOpsEntry(entry: OpsEntry): Promise; upsertSignal(signal: Signal): Promise; upsertBelief(belief: BeliefEntry): Promise; getCapabilities(): Promise; } //# sourceMappingURL=firestore.d.ts.map