/** * Postgres Vector Store - pgvector-based Vector Storage * * Provides vector embedding storage using PostgreSQL with pgvector extension. * Replaces LanceDB for hosted deployments where file-based storage isn't persistent. * * Requirements: * - PostgreSQL 15+ with pgvector extension * - Supabase, Neon, or self-hosted Postgres with pgvector enabled */ import { PrismaClient } from '@prisma/client'; /** * Options for PostgresVectorStore */ export interface PostgresVectorStoreOptions { prisma?: PrismaClient; dimensions?: number; } /** * Entity types that can be stored */ export type EntityType = 'pattern' | 'skill' | 'content' | 'error'; /** * Embedding record to store */ export interface EmbeddingRecord { id: string; vector: number[] | Float32Array; model: string; version: number; createdAt: number; entityType: EntityType; domain?: string; tenantId?: string; text?: string; } /** * Filter for vector searches */ export interface VectorSearchFilter { entityType?: EntityType; domain?: string; tenantId?: string; minVersion?: number; } /** * Options for vector search */ export interface VectorSearchOptions { limit?: number; minScore?: number; includeVector?: boolean; } /** * Search result */ export interface VectorSearchResult { id: string; score: number; metadata: { entityType: EntityType; domain?: string; tenantId?: string; model: string; version: number; createdAt: number; text?: string; }; vector?: number[]; } /** * Statistics about the vector store */ export interface VectorStoreStats { totalRecords: number; recordsByType: Record; tableExists: boolean; dimensions: number; lastModified?: number; } /** * PostgresVectorStore - pgvector-backed vector storage for semantic search * * Provides CRUD operations and similarity search for embedding vectors * using PostgreSQL's pgvector extension. */ export declare class PostgresVectorStore { private prisma; private ownsPrisma; private initialized; private dimensions; constructor(options?: PostgresVectorStoreOptions); /** * Check if pgvector is available */ static isAvailable(prisma?: PrismaClient): Promise; /** * Initialize the vector store */ initialize(): Promise; /** * Add a single embedding record */ add(record: EmbeddingRecord): Promise; /** * Add multiple embedding records in batch */ addBatch(records: EmbeddingRecord[]): Promise; /** * Search for similar vectors using cosine similarity */ search(vector: number[] | Float32Array, options?: VectorSearchOptions): Promise; /** * Search with metadata filters */ searchFiltered(vector: number[] | Float32Array, filter: VectorSearchFilter, options?: VectorSearchOptions): Promise; /** * Format raw Postgres results into SearchResult objects */ private formatResults; /** * Get a single record by ID */ get(id: string): Promise; /** * Delete a record by ID */ delete(id: string): Promise; /** * Delete records matching a filter */ deleteByFilter(filter: VectorSearchFilter): Promise; /** * Create an index for optimized vector search * Uses IVFFlat index for larger datasets */ createIndex(): Promise; /** * Get statistics about the vector store */ getStats(): Promise; /** * Check if the store is using pgvector */ isUsingPgvector(): boolean; /** * Close the database connection */ close(): Promise; /** * Ensure the store is initialized */ private ensureInitialized; } /** * Create a PostgresVectorStore instance */ export declare function createPostgresVectorStore(options?: PostgresVectorStoreOptions): PostgresVectorStore; /** * Get or create the global vector store (singleton pattern) */ export declare function getPostgresVectorStore(options?: PostgresVectorStoreOptions): Promise; /** * Close the global vector store */ export declare function closePostgresVectorStore(): Promise; //# sourceMappingURL=postgres-vector-store.d.ts.map