import type { Context } from "@earendil-works/chord/context"; import type { JsonObject, TaskDocToken, ToolExecutionApi } from "@earendil-works/pi-durable"; import type { FabricJournalDelivery, FabricJournalDriver, FabricJournalOutcome, FabricJournalStop } from "./runtime/kernel.js"; /** Bump when what a recorded run means changes: record shapes, keys, or the replay rules. */ export declare const FABRIC_DURABLE_JOURNAL_FORMAT = "pi-fabric.durable-journal.v1"; type JournalOutcomeJson = { ok: true; json?: string; } | { ok: false; message: string; fields?: Array<[string, number]>; }; type JournalHeader = { format: string; engine: string; identity: string; seed: number; startedAt: number; }; type JournalCompletion = { c: number; seq: number; ref: string; t?: string; d: string; at: number; o: JournalOutcomeJson; }; type JournalIntent = { seq: number; ref: string; }; export type FabricRunState = { header: JournalHeader | null; intents: JournalIntent[]; completions: JournalCompletion[]; }; /** The journal document of one fabric_exec task; it retires with the task. */ export declare const FabricRunDoc: TaskDocToken; /** A resume the journal cannot trust; the program must not run. The message is for the model. */ export declare class FabricDurableJournalRefusal extends Error { readonly name = "FabricDurableJournalRefusal"; } export declare const durableJournalDigest: (args: unknown) => string; /** The tool or action a bridge ref names: tools.call and tools. carry it in their arguments. */ export declare const callTarget: (ref: string, args: Record) => { ref: string; args: unknown; }; export declare const callPreview: (ref: string, args: Record) => string; export interface DurableJournalHooks { /** A journal write failed; the error may hold storage details, so it goes here, not to the program. */ readonly onWriteError: (error: unknown) => void; } export declare class FabricDurableJournal implements FabricJournalDriver { #private; readonly shim: string; readonly startedAt: number; readonly resuming: boolean; readonly replay: readonly FabricJournalDelivery[]; private constructor(); /** * Open the journal of this fabric_exec task: a fresh one on the first run, the recorded one on a rerun. * Throws FabricDurableJournalRefusal when the recorded run cannot be trusted to replay. */ static open(api: ToolExecutionApi, context: Context, identity: Record, engine: string, hooks: DurableJournalHooks): Promise; /** The recorded tool and provider calls a resume serves without running them again. */ replayedCalls(): number; /** Set when the journal stopped the program; the model sees exactly this text. */ stopReport: string | undefined; digest(args: Record): string; /** True when call `seq` was recorded as about to reach its effect. */ hasIntent(seq: number): boolean; /** Commit that call `seq` is about to reach its effect, before it does. */ intent(seq: number, ref: string): Promise; complete(seq: number, ref: string, args: Record, _value: unknown, outcome: FabricJournalOutcome): Promise; served(): void; frontier(held: ReadonlyArray<{ seq: number; ref: string; args: Record; }>): FabricJournalStop | undefined; diverged(expected: FabricJournalDelivery, actual?: { ref: string; args: Record; }): string; } /** What the model reads when a call that may have taken effect was interrupted. */ export declare const maybeRanReport: (call: string, replayed: number) => string; /** Extra JSON for the model-facing result of a journaled call; exported for tests. */ export type FabricRunStateJson = FabricRunState & JsonObject; export {}; //# sourceMappingURL=durable-journal.d.ts.map