import { M as Message } from './streaming.d-Cj-pZLSI.js'; /** * Type definitions for conversation store */ /** * Metadata about a conversation */ interface ConversationMetadata { /** Unique conversation identifier */ conversationId: string; /** Timestamp when conversation was created */ createdAt: number; /** Timestamp when conversation was last updated */ updatedAt: number; /** Number of messages in the conversation */ messageCount: number; /** Optional TTL in seconds */ ttl?: number; /** Custom metadata */ metadata?: Record; } /** * A conversation containing messages and metadata */ interface Conversation { /** Unique conversation identifier */ conversationId: string; /** Array of messages in the conversation */ messages: Message[]; /** Conversation metadata */ metadata: ConversationMetadata; } /** * Backend type for store implementation */ type StoreBackend = 'memory' | 'redis' | 'zerodb'; /** * Base configuration for all stores */ interface BaseStoreConfig { /** Default TTL in seconds (0 = no expiration) */ defaultTTL?: number; /** Namespace/prefix for keys */ namespace?: string; } /** * Configuration for Memory store */ interface MemoryStoreConfig extends BaseStoreConfig { type: 'memory'; /** Maximum number of conversations to store (LRU eviction) */ maxConversations?: number; } /** * Configuration for Redis store */ interface RedisStoreConfig extends BaseStoreConfig { type: 'redis'; /** Redis connection URL */ url?: string; /** Redis host */ host?: string; /** Redis port */ port?: number; /** Redis password */ password?: string; /** Redis database number */ db?: number; /** Key prefix for Redis keys */ keyPrefix?: string; } /** * Configuration for ZeroDB store */ interface ZeroDBStoreConfig extends BaseStoreConfig { type: 'zerodb'; /** ZeroDB project ID */ projectId: string; /** ZeroDB API key */ apiKey: string; /** Table name for conversations */ tableName?: string; } /** * Union type for all store configurations */ type StoreConfig = MemoryStoreConfig | RedisStoreConfig | ZeroDBStoreConfig; /** * Options for saving a conversation */ interface SaveOptions { /** TTL in seconds (overrides default) */ ttl?: number; /** Custom metadata to merge */ metadata?: Record; } /** * Options for appending messages */ interface AppendOptions { /** Whether to update the updatedAt timestamp */ updateTimestamp?: boolean; } /** * Options for loading conversations */ interface LoadOptions { /** Whether to include expired conversations */ includeExpired?: boolean; } /** * Statistics about the store */ interface StoreStats { /** Total number of conversations */ totalConversations: number; /** Total number of messages across all conversations */ totalMessages: number; /** Number of expired conversations */ expiredConversations?: number; /** Storage size in bytes (if available) */ storageSize?: number; } /** * Abstract base class for conversation stores * * Provides a common interface for persisting conversations across different backends. * All store implementations must extend this class and implement the abstract methods. */ declare abstract class ConversationStore { protected config: BaseStoreConfig; constructor(config?: BaseStoreConfig); /** * Save a complete conversation * @param conversationId - Unique identifier for the conversation * @param messages - Array of messages to save * @param options - Optional save options (TTL, metadata) * @returns The saved conversation with metadata */ abstract save(conversationId: string, messages: Message[], options?: SaveOptions): Promise; /** * Load a conversation by ID * @param conversationId - Unique identifier for the conversation * @param options - Optional load options * @returns The conversation if found, null otherwise */ abstract load(conversationId: string, options?: LoadOptions): Promise; /** * Append messages to an existing conversation * @param conversationId - Unique identifier for the conversation * @param messages - Array of messages to append * @param options - Optional append options * @returns The updated conversation with metadata */ abstract append(conversationId: string, messages: Message[], options?: AppendOptions): Promise; /** * Delete a conversation by ID * @param conversationId - Unique identifier for the conversation * @returns True if deleted, false if not found */ abstract delete(conversationId: string): Promise; /** * Clear all conversations from the store * @returns Number of conversations cleared */ abstract clear(): Promise; /** * List all conversation IDs * @returns Array of conversation IDs */ abstract list(): Promise; /** * Check if a conversation exists * @param conversationId - Unique identifier for the conversation * @returns True if exists, false otherwise */ abstract exists(conversationId: string): Promise; /** * Get store statistics * @returns Store statistics */ abstract getStats(): Promise; /** * Create conversation metadata * @param conversationId - Unique identifier * @param messages - Array of messages * @param options - Optional save options * @param existingMetadata - Existing metadata to preserve * @returns Conversation metadata */ protected createMetadata(conversationId: string, messages: Message[], options?: SaveOptions, existingMetadata?: ConversationMetadata): ConversationMetadata; /** * Check if a conversation has expired based on TTL * @param metadata - Conversation metadata * @returns True if expired, false otherwise */ protected isExpired(metadata: ConversationMetadata): boolean; /** * Generate a namespaced key for storage * @param conversationId - Conversation identifier * @returns Namespaced key */ protected getKey(conversationId: string): string; /** * Close the store and cleanup resources */ abstract close(): Promise; } export { type AppendOptions as A, type BaseStoreConfig as B, ConversationStore as C, type LoadOptions as L, type MemoryStoreConfig as M, type RedisStoreConfig as R, type StoreConfig as S, type ZeroDBStoreConfig as Z, type Conversation as a, type ConversationMetadata as b, type StoreBackend as c, type SaveOptions as d, type StoreStats as e };