/** * SQLite-backed CheckpointStorage adapter using bun:sqlite. * * Provides local file-based persistence with transaction support * and WAL mode for performance. */ import { Database } from 'bun:sqlite'; import type { CheckpointStorage, Checkpoint, CheckpointStatus } from './types'; /** * Configuration options for SqliteCheckpointStorage. */ export interface SqliteCheckpointStorageOptions { /** * Path to the SQLite database file. * Use ':memory:' for in-memory database (useful for tests). * @default 'fred.db' */ path?: string; /** * Pre-configured Database instance for dependency injection (useful for testing). */ db?: Database; } /** * SQLite-backed implementation of CheckpointStorage. * * Features: * - File-based or in-memory persistence * - Transaction support for atomic operations * - WAL mode for better concurrent read performance * - Best-effort recovery with warnings for corrupted rows */ export declare class SqliteCheckpointStorage implements CheckpointStorage { private db; private initialized; constructor(options?: SqliteCheckpointStorageOptions); /** * Ensure the database schema is initialized. * Enables foreign keys and WAL mode, then creates tables if needed. */ private ensureInitialized; /** * Save a checkpoint (upsert by run_id + step). */ save(checkpoint: Checkpoint): Promise; /** * Get the latest checkpoint for a run (highest step number). * Returns null if no checkpoints exist for the run. */ getLatest(runId: string): Promise; /** * Get a specific checkpoint by run_id and step. * Returns null if not found. */ get(runId: string, step: number): Promise; /** * Update the status of a checkpoint. */ updateStatus(runId: string, step: number, status: CheckpointStatus): Promise; /** * Delete all checkpoints for a run. */ deleteRun(runId: string): Promise; /** * Delete expired checkpoints (where expires_at < current time). * Uses ISO 8601 string comparison since expires_at is stored as ISO string. * @returns The number of deleted checkpoints */ deleteExpired(): Promise; /** * List checkpoints by status (for querying pending pauses). * Excludes expired checkpoints (where expires_at < current time). */ listByStatus(status: CheckpointStatus): Promise; /** * Get the latest checkpoint for a pipeline (highest step, timestamp tie-break). * Returns the checkpoint with the highest step number, using created_at as a tie-breaker. * Excludes expired checkpoints. */ getLatestByPipelineId(pipelineId: string): Promise; /** * Close the database connection. */ close(): Promise; /** * Convert a database row to a Checkpoint object. */ private rowToCheckpoint; } //# sourceMappingURL=sqlite.d.ts.map