import type { StorageDescriptor } from "./database.js"; export declare const RUN_EVENT_TYPES: { readonly runStarted: "RunStarted"; readonly runFinished: "RunFinished"; readonly statusChanged: "StatusChanged"; readonly checkpointRecorded: "CheckpointRecorded"; readonly promptAsked: "PromptAsked"; readonly promptReleased: "PromptReleased"; readonly controlRequested: "ControlRequested"; readonly messageQueued: "MessageQueued"; readonly messageDelivered: "MessageDelivered"; readonly messageSettled: "MessageSettled"; readonly timerScheduled: "TimerScheduled"; readonly summaryRecorded: "SummaryRecorded"; }; export type RunEventType = (typeof RUN_EVENT_TYPES)[keyof typeof RUN_EVENT_TYPES]; export type JournalSerializableValue = string | number | boolean | null | readonly JournalSerializableValue[] | { readonly [key: string]: JournalSerializableValue | undefined; }; export interface RunHeader { readonly runId: string; readonly name: string; readonly cwd: string; readonly createdAt: number; readonly status: string; readonly inputs?: JournalSerializableValue; readonly storage?: StorageDescriptor; } export type RunSummary = RunHeader; type EventOf = { readonly type: Type; readonly payload: Payload; }; export type RunEvent = EventOf<"RunStarted" | "RunFinished"> | EventOf<"StatusChanged", { readonly status: string; readonly [key: string]: JournalSerializableValue; }> | EventOf<"CheckpointRecorded", { readonly kind: "tool" | "ui" | "stage" | "task" | "boundary"; readonly [key: string]: JournalSerializableValue; }> | EventOf<"PromptAsked" | "PromptReleased" | "ControlRequested" | "MessageQueued" | "MessageDelivered" | "MessageSettled" | "TimerScheduled" | "SummaryRecorded">; export interface Lease { readonly runId: string; readonly holderId: string; readonly epoch: number; } export type LeaseState = Lease & { readonly renewedAt: number; readonly ageMs: number; }; export type LeaseOutcome = { readonly status: "acquired"; readonly lease: Lease; } | { readonly status: "held"; readonly holderId: string | null; readonly epoch: number; }; export interface JournalEntry { readonly runId: string; readonly seq: number; readonly epoch: number; readonly key?: string; readonly event: RunEvent; readonly at: number; } export type AppendOutcome = { readonly status: "appended" | "exists"; readonly entry: JournalEntry; }; export interface RunJournal { createRun(header: RunHeader): Promise<"created" | "exists">; getRun(runId: string): Promise; listRuns(filter?: { cwd?: string; }): Promise; acquire(runId: string, holderId: string): Promise; takeover(runId: string, holderId: string, expectedHolder: string): Promise; takeoverExpired(runId: string, holderId: string, staleAfterMs: number): Promise; leaseState(runId: string): Promise; renew(lease: Lease): Promise; release(lease: Lease): Promise; append(lease: Lease, event: RunEvent, options?: { key?: string; expectSeq?: number; }): Promise; read(runId: string, fromSeq?: number): AsyncIterable; readKey(runId: string, key: string): Promise; deleteOwnedRun(lease: Lease, expectSeq?: number): Promise; deleteRun(runId: string): Promise; close(): Promise; } export {}; //# sourceMappingURL=run-journal.d.ts.map