/** * SQLite-backed ContextStorage adapter using bun:sqlite. * * Provides local file-based persistence with transaction support, * foreign key constraints, and WAL mode for performance. */ import type { ContextStorage, ConversationContext, SessionSummary } from '../context'; /** * Configuration options for SqliteContextStorage. */ export interface SqliteContextStorageOptions { /** * Path to the SQLite database file. * Use ':memory:' for in-memory database (useful for tests). * @default 'fred.db' */ path?: string; } /** * SQLite-backed implementation of ContextStorage. * * Features: * - File-based or in-memory persistence * - Transaction support for atomic operations * - Foreign key constraints with cascade deletes * - WAL mode for better concurrent read performance */ export declare class SqliteContextStorage implements ContextStorage { private db; private initialized; constructor(options?: SqliteContextStorageOptions); /** * Ensure the database schema is initialized. * Enables foreign keys and WAL mode, then creates tables if needed. */ private ensureInitialized; /** * Retrieve a conversation context by ID. * Returns null if the conversation doesn't exist. * Logs warnings on parse failures and returns best-effort context. */ get(id: string): Promise; /** * Store or update a conversation context. * Runs in a transaction: upsert conversation, delete old messages, insert new messages. */ set(id: string, context: ConversationContext): Promise; /** * List session summaries ordered by updated_at DESC. */ listSessions(): Promise; /** * Delete a conversation and all its messages. * Messages are deleted via foreign key cascade, but we explicitly * delete them first for databases that might not have FK enabled. */ delete(id: string): Promise; /** * Clear all conversations and messages. */ clear(): Promise; /** * Close the database connection. * Should be called when the storage is no longer needed. */ close(): void; } //# sourceMappingURL=sqlite.d.ts.map