/** * Enhanced Pinecone vector database integration for Agentis memory system * * Features: * - Improved batch operations * - Caching for better performance * - Enhanced error handling with retry logic * - Memory compression capabilities * - Seamless integration with EmbeddingService */ import { LongTermMemory, ShortTermMemory, AgentNote } from './enhanced-memory-interface'; import { EmbeddingService } from './embedding-service'; /** * Configuration for the Pinecone store */ export interface PineconeStoreConfig { apiKey?: string; environment?: string; projectId?: string; index?: string; namespace?: string; dimension?: number; maxBatchSize?: number; cacheSize?: number; maxRetries?: number; retryDelayMs?: number; enableCompression?: boolean; compressionThreshold?: number; embeddingService?: EmbeddingService; embeddingConfig?: { apiKey?: string; model?: string; dimensions?: number; enableCache?: boolean; }; } /** * Interface for vector store operations */ export interface VectorStore { initialize(): Promise; storeVector(id: string, vector: number[], data: any, namespace?: string): Promise; searchVectors(vector: number[], limit: number, namespace?: string): Promise>; getVector(id: string, namespace?: string): Promise<{ id: string; vector: number[]; data: any; } | null>; deleteVector(id: string, namespace?: string): Promise; deleteNamespace(namespace: string): Promise; } /** * Enhanced Pinecone implementation of the vector store * with caching, batching, and retry mechanisms */ export declare class PineconeStore implements VectorStore { private client; private index; private config; private logger; private initialized; private embeddingService; private cache; private batchQueue; private batchTimer; /** * Creates a new enhanced Pinecone store * * @param config - Configuration for the Pinecone store */ constructor(config: PineconeStoreConfig); /** * Sets up cache management to prevent memory leaks */ private setupCacheManagement; /** * Executes a function with retry logic */ private withRetry; /** * Initializes the Pinecone store * * @returns Promise that resolves when initialization is complete */ initialize(): Promise; /** * Ensures that tags are in the correct format for Pinecone * * @param tags - Tags in any format * @returns Tags as an array of strings */ static formatTags(tags: any): string[]; /** * Queues a vector for batch storage and processes the batch if needed * * @param id - Unique ID for the vector * @param vector - The embedding vector * @param data - Metadata to store with the vector * @param namespace - Optional namespace (defaults to config namespace) * @returns Promise that resolves when the vector is queued (not necessarily stored) */ storeVector(id: string, vector: number[], data: any, namespace?: string): Promise; /** * Process the current batch of vectors */ private processBatch; /** * Searches for similar vectors in Pinecone with enhanced features * * @param vector - The query vector * @param limit - Maximum number of results to return * @param namespace - Optional namespace (defaults to config namespace) * @param filter - Optional metadata filter * @returns Promise resolving to search results */ searchVectors(vector: number[], limit: number, namespace?: string, filter?: Record): Promise>; /** * Calculate a confidence score from similarity */ private calculateConfidence; /** * Gets a vector by ID with cache * * @param id - The vector ID * @param namespace - Optional namespace (defaults to config namespace) * @returns Promise resolving to the vector or null if not found */ getVector(id: string, namespace?: string): Promise<{ id: string; vector: number[]; data: any; } | null>; /** * Gets multiple vectors by ID in a single request * * @param ids - Array of vector IDs * @param namespace - Optional namespace * @returns Promise resolving to a map of found vectors */ getVectors(ids: string[], namespace?: string): Promise>; /** * Deletes a vector by ID * * @param id - The vector ID * @param namespace - Optional namespace (defaults to config namespace) * @returns Promise resolving to true if deleted, false if not found */ deleteVector(id: string, namespace?: string): Promise; /** * Deletes multiple vectors by ID in a batch * * @param ids - Array of vector IDs to delete * @param namespace - Optional namespace * @returns Promise resolving to the number of successfully deleted vectors */ deleteVectors(ids: string[], namespace?: string): Promise; /** * Deletes all vectors in a namespace * * @param namespace - The namespace to delete * @returns Promise resolving when deletion is complete */ deleteNamespace(namespace: string): Promise; /** * Get statistics about the index * * @returns Promise resolving to index statistics */ getStats(): Promise<{ namespaces: Record; totalVectorCount: number; dimension: number; }>; /** * Perform a flush to ensure all pending writes are committed */ flush(): Promise; /** * Stores text content with automatically generated embeddings * * @param id - Unique ID for the text * @param text - The text content to store * @param metadata - Additional metadata to store with the text * @param namespace - Optional namespace * @returns Promise resolving when storage is complete */ storeText(id: string, text: string, metadata?: any, namespace?: string): Promise; /** * Stores multiple texts with automatically generated embeddings * * @param items - Array of items to store * @param namespace - Optional namespace * @returns Promise resolving when storage is complete */ storeTexts(items: Array<{ id: string; text: string; metadata?: any; }>, namespace?: string): Promise; /** * Searches for similar text content * * @param text - The query text * @param limit - Maximum number of results * @param namespace - Optional namespace * @param filter - Optional metadata filter * @returns Promise resolving to search results */ searchText(text: string, limit?: number, namespace?: string, filter?: Record): Promise>; /** * Updates existing text content with new text while preserving the ID * * @param id - The ID of the text to update * @param newText - The new text content * @param metadata - Optional new metadata (or undefined to keep existing) * @param namespace - Optional namespace * @returns Promise resolving to true if updated, false if not found */ updateText(id: string, newText: string, metadata?: any, namespace?: string): Promise; /** * Creates a new memory entry from structured data * * @param memory - Memory data to store * @param namespace - Optional namespace * @returns Promise resolving to the memory ID */ storeMemory(memory: LongTermMemory | ShortTermMemory | AgentNote, namespace?: string): Promise; /** * Retrieves memories similar to a query * * @param query - The query text * @param limit - Maximum number of results * @param namespace - Optional namespace * @param filter - Optional filter criteria * @returns Promise resolving to matching memories */ searchMemories(query: string, limit?: number, namespace?: string, filter?: Record): Promise>; }