import { StateDatabase } from "../state/database.js"; import { type MutationActor, type OwnerType } from "../state/mutation.js"; import type { WorkflowDefinition, WorkflowDefinitionSnapshot, WorkflowRunState, WorkflowSessionBinding, WorkflowSessionCapture, WorkflowSessionEntryRecord, WorkflowSessionEventRecord, WorkflowTraceEvent, WorkflowTraceEventDraft, WorkflowUpdateInput, WorkflowUpdateRecord } from "./types.js"; export declare const RUN_STATE_SCHEMA: "pi-workflows.run-state.v1"; export declare const DEFINITION_SNAPSHOT_SCHEMA: "pi-workflows.definition-snapshot.v1"; export declare const SESSION_BINDING_SCHEMA: "pi-workflows.session-binding.v1"; export declare const SESSION_EVENT_SCHEMA: "pi-workflows.session-event.v1"; export declare const SESSION_CAPTURE_SCHEMA: "pi-workflows.session-capture.v1"; export declare const SESSION_EVENT_MAX_BYTES: number; export declare function workflowStateDatabasePath(homeDir?: string): string; export declare function createRunId(workflowName: string, now?: Date): string; export type RunWriteAuthority = { actor: MutationActor; ownerType: OwnerType; ownerId: string; token: string; generation: number; }; export type WorkflowRunStoreOptions = { authorityProvider?: (runId: string) => RunWriteAuthority | undefined; state?: StateDatabase; readOnly?: boolean; }; export type SessionCaptureIntegrity = { status: "unavailable" | "recording" | "complete" | "failed" | "invalid"; diagnostics: string[]; }; export type SessionCaptureSegment = { attemptId: string; binding: WorkflowSessionBinding | null; entries: WorkflowSessionEntryRecord[]; events: WorkflowSessionEventRecord[]; capture: WorkflowSessionCapture | null; integrity: SessionCaptureIntegrity; }; export type LoadedWorkflowRun = { runId: string; state: WorkflowRunState; snapshot: WorkflowDefinitionSnapshot; traceEvents?: WorkflowTraceEvent[]; sessionBinding: WorkflowSessionBinding | null; sessionEntries: WorkflowSessionEntryRecord[]; sessionEvents: WorkflowSessionEventRecord[]; sessionCapture: WorkflowSessionCapture | null; sessionIntegrity: SessionCaptureIntegrity; sessionSegments: SessionCaptureSegment[]; }; export type ReadWorkflowRunOptions = { includeTrace?: boolean; }; export declare class WorkflowRunStore { readonly databasePath: string; readonly state: StateDatabase; private readonly authorityProvider; private readonly contexts; private readonly ownsState; constructor(databasePath?: string, options?: WorkflowRunStoreOptions); close(): void; initializeRun(workflow: WorkflowDefinition, state: WorkflowRunState): Promise; prepareRunResume(runId: string): Promise; markRunInterrupted(runId: string, reason?: string): Promise; publishUpdate(runId: string, state: WorkflowRunState, nodeId: string, attemptId: string, update: WorkflowUpdateInput, options?: { signal?: AbortSignal; }): Promise<{ event: WorkflowTraceEvent; record: WorkflowUpdateRecord; }>; writeSnapshot(runId: string, state: WorkflowRunState, event: WorkflowTraceEventDraft): Promise; hasSessionBinding(runId: string): Promise; listSessionSegments(runId: string): Promise; writeSessionBinding(runId: string, binding: WorkflowSessionBinding, attemptId?: string): Promise; appendSessionEntry(runId: string, entry: Record, attemptId?: string): Promise; appendSessionEventBatch(runId: string, records: WorkflowSessionEventRecord[], attemptId?: string): Promise; writeSessionCapture(runId: string, capture: WorkflowSessionCapture, attemptId?: string): Promise; sessionCounts(runId: string, attemptId?: string): Promise<{ eventCount: number; entryCount: number; lastEventSeq: number; }>; readRun(runId: string, options?: ReadWorkflowRunOptions): LoadedWorkflowRun | null; listRuns(options?: ReadWorkflowRunOptions): LoadedWorkflowRun[]; readLastTraceEvent(runId: string): WorkflowTraceEvent | null; private contextFor; private withRunLock; private assertSessionWriteAuthority; private resourceRevision; private requireResourceRevision; private bumpResource; private assertWriteAuthority; private persistRunState; private enqueueRunSettlementEffect; private syncNodeAttempts; private ensureAttempt; private nextAttemptNumber; private nextUpdateSequence; private readRunRow; private requireRunRow; private readState; private readDefinition; private traceEvents; private segmentRows; private segmentRow; private requireSegment; private loadSegment; private finalizeRecordingCaptures; } export declare function readWorkflowRun(runId: string, options?: ReadWorkflowRunOptions & { databasePath?: string; }): LoadedWorkflowRun | null; export declare function listWorkflowRuns(options?: ReadWorkflowRunOptions & { databasePath?: string; }): LoadedWorkflowRun[]; export declare function readLastTraceEvent(runId: string, options?: { databasePath?: string; }): WorkflowTraceEvent | null; export declare function createDefinitionSnapshot(workflow: WorkflowDefinition): WorkflowDefinitionSnapshot;