import type { SqliteExecutor } from "@bastani/atomic/storage"; import { type JournalEntry, type RunJournal } from "./types.js"; export declare const JOURNAL_READ_PAGE_SIZE = 256; /** Event types the durable backend folds without replacing the run's handle; every other event carries it. */ export declare const NON_SNAPSHOT_EVENT_TYPES: readonly ["CheckpointRecorded", "MessageSettled", "MessageDelivered"]; /** A run's latest event. A run whose history was deleted and recorded again ends with a different event. */ export interface RunVersion { readonly seq: number; readonly at: number; } /** * A run's latest snapshot event (one carrying the run's handle) and the checkpoints recorded after it: enough to * list the run in a catalog without reading its history. */ export interface RunSnapshotTail { /** The run's latest event of any type. */ readonly version: RunVersion; readonly snapshot: JournalEntry; readonly laterCheckpoints: number; /** `completedAt` of the last of `laterCheckpoints`. */ readonly lastCheckpointAt?: number; } /** Lets a durable backend re-read only the runs that changed; kept off the public journal shape. */ export interface RunJournalVersions { /** Moves whenever any connection, in this process or another, commits a change to the journal's store. */ changeToken(): Promise; /** Every listed run with its latest event; a run with no events has version `{ seq: 0, at: 0 }`. */ runVersions(): Promise>; /** Undefined for a run with no snapshot event. */ snapshotTail(runId: string): Promise; } export declare function registerRunJournalVersions(journal: RunJournal, versions: RunJournalVersions): void; /** Change tracking for a journal that registered it; other journals are re-read in full. */ export declare function runJournalVersions(journal: RunJournal): RunJournalVersions | undefined; export type JournalAppendGuard = (tx: SqliteExecutor, runId: string) => Promise; export interface SqlPoolStorage { transaction(body: (tx: SqliteExecutor) => Promise): Promise; withAppendGuard(guard: JournalAppendGuard, action: () => Promise): Promise; readonly tables: Readonly<{ runs: string; events: string; leases: string; }>; } export declare function registerSqlPoolStorage(journal: RunJournal, storage: SqlPoolStorage): void; export declare function sqlPoolStorage(journal: RunJournal): SqlPoolStorage | undefined;