/** * Memory Repository - PostgreSQL Implementation (raw SQL) * * All queries use $executeRaw / $queryRaw to avoid the Prisma 7.7.0 + * @prisma/adapter-pg + Bun incompatibility (isObjectEnumValue bug). * * ORM filter methods (findMany, updateMany, create, etc.) crash at runtime * with: "(0, Ao.isObjectEnumValue) is not a function". * Raw-SQL paths work correctly — both in the API server and in bun:test. */ import { MemoryType } from "@massa-th0th/shared"; import type { InsertMemoryInput, MemoryRow, SearchFilters, UpdateMemoryPatch } from "./memory-repository-contract.js"; export declare class MemoryRepositoryPg { private static instance; private prisma; private constructor(); static getInstance(): MemoryRepositoryPg; /** Convert a raw DB row to the MemoryRow interface used by the rest of the app. */ private toMemoryRow; /** * Insert a new memory using raw SQL ($executeRaw). * Bypasses Prisma ORM to avoid the isObjectEnumValue Bun incompatibility. */ insert(input: InsertMemoryInput): Promise; /** * Get a single memory by ID. */ getById(id: string): Promise; /** * Search memories with filters (used by MemoryConsolidationJob, etc.) */ search(filters: SearchFilters): Promise; /** * Full-text search: word-level ILIKE OR matching, with scope filters. * Mirrors the PostgreSQL FTS5 behaviour: each whitespace-separated token is * searched independently; results are returned if ANY token matches. */ fullTextSearch(query: string, limit: number, filters?: { userId?: string; sessionId?: string; projectId?: string; agentId?: string; minImportance?: number; types?: MemoryType[]; }): Promise; /** * Update importance score. */ updateImportance(id: string, importance: number): Promise; /** * Increment access count and set last_accessed timestamp. */ incrementAccessCount(id: string): Promise; /** * Delete a memory by ID. */ delete(id: string): Promise; /** * Delete a memory by ID. Returns true if a row was deleted. * Uses RETURNING so an absent id reports false (idempotent). */ deleteById(id: string): Promise; /** * Partially update a memory. Only provided fields are changed. * PostgreSQL uses ILIKE (no external FTS table), so no FTS reindex needed. * Returns true if a row was updated. */ update(id: string, patch: UpdateMemoryPatch): Promise; /** * Soft-delete a single memory by id (Phase 1). Sets `deleted_at`; the row * is hidden from recall by the `deleted_at IS NULL` filters. Returns true * only if a previously-live row was tombstoned. Idempotent. */ softDeleteById(id: string): Promise; /** * Delete all memories for a project. Returns the count deleted. */ deleteByProject(projectId: string): Promise; /** * List memories with pagination. */ list(limit: number, offset: number): Promise; /** * Find recent memories that contain a given tag, scoped to session/project, * within a time window. Used by CoRetrievalHook to find co-session memories. */ findRecentByTag(tag: string, opts: { sessionId?: string; projectId?: string; excludeId?: string; sinceMs: number; limit: number; }): Promise>; /** * Find recent memories that have an embedding, for cosine-similarity * comparisons in RelationExtractor. Scoped to a project when provided. */ findRecentWithEmbeddings(excludeId: string, projectId: string | null, limit: number): Promise; /** * List live, non-pinned memories with embeddings older than `staleSinceMs` * for the consolidation job (Phase 1). Bounded by `limit`. */ listConsolidationCandidates(staleSinceMs: number, limit?: number): Promise; /** * No-op — connection is managed by the singleton PrismaClient. */ close(): Promise; } //# sourceMappingURL=memory-repository-pg.d.ts.map