import Database from 'better-sqlite3-multiple-ciphers'; export type DB = Database.Database; export interface OpenDbOpts { /** * Encryption key (SEC-1/2). Applied via `PRAGMA key` immediately after * open, before any other pragma and before the sqlite-vec extension load. * Ignored for `:memory:` databases — SQLCipher rejects `PRAGMA key` on * in-memory/temporary databases (confirmed by the 1a spike), so in-memory * opens are always plaintext regardless of whether a key is supplied. */ key?: string; } /** * Thrown by `openDb` when the file on disk cannot be trusted as an intact * datadir (FEAT-420 AC-3), and NO encryption key was in play. Distinct from * a raw `SqliteError` so callers and operators get an actionable message * instead of a low-level driver string. */ export declare class CorruptDatadirError extends Error { constructor(path: string, reason: string); } /** * Thrown by `openDb` when a key WAS supplied but the file could not be read * with it (FEAT-420 AC-3 review fix). SQLCipher cannot distinguish * "wrong/missing key" from "corrupted file" at the driver level — both * surface as the exact same `SqliteError: file is not a database` * (SQLITE_NOTADB), which is also the documented stale-v0.3.4-global-install * symptom (CLAUDE.md "Do NOT use bare astramem-local"). Reusing * CorruptDatadirError's corruption-and-delete advice here would actively * steer an operator with a recoverable key/config problem toward destroying * a healthy encrypted database — so this is a distinct class with distinct, * non-destructive advice and NO deletion suggestion. */ export declare class EncryptionKeyError extends Error { constructor(path: string, reason: string); } export declare function openDb(path: string, opts?: OpenDbOpts): DB;