import { type JsonObject } from "../state/json.js"; import { ProjectStore } from "../state/project-store.js"; export type WorkflowRunLaunchStatus = "queued" | "starting" | "running" | "parked" | "done" | "failed" | "cancelled"; export type WorkflowRunReservationOptions = { runId: string; workflowName: string; workflowSourceRef: string; workflowSource: unknown; definitionDigest: string; definitionSnapshot: unknown; input: unknown; launchOptions?: unknown; originSessionId: string; executionMode?: "interactive" | "headless"; parentRunId?: string; lineageKind?: "restart"; restartNumber?: number; parentRunRevision?: number; now?: string; }; export type WorkflowRunQueueViewRecord = { runId: string; workflowName: string; workflowSourceRef: string; workflowSource: unknown; initialized: boolean; definitionDigest: string; runStateStatus: string; paused: boolean; status: WorkflowRunLaunchStatus; originSessionId: string | null; executionMode: "interactive" | "headless"; parentRunId: string | null; rootRunId: string; lineageKind: "restart" | null; restartNumber: number; parentRunRevision: number | null; errorCode: string | null; errorMessage: string | null; createdAt: string; updatedAt: string; startedAt: string | null; finishedAt: string | null; }; export type WorkflowRunQueueRecord = { runId: string; workflowName: string; workflowSourceRef: string; workflowSource: unknown; initialized: boolean; definitionDigest: string; input: unknown; launchOptions: unknown; status: WorkflowRunLaunchStatus; runnerId: string | null; claimToken: string | null; claimGeneration: number | null; claimExpiresAt: string | null; originSessionId: string | null; executionMode: "interactive" | "headless"; parentRunId: string | null; rootRunId: string; lineageKind: "restart" | null; restartNumber: number; parentRunRevision: number | null; errorCode: string | null; errorMessage: string | null; createdAt: string; updatedAt: string; startedAt: string | null; finishedAt: string | null; }; export type WorkflowRunPreparationResult = { state: "reserved"; run: WorkflowRunQueueRecord; } | { state: "adopted"; run: WorkflowRunQueueRecord; }; export type RunEventRecord = { seq: number; recordedAt: string; runId: string; workflowRef: string; type: string; runnerId: string | null; payload: JsonObject; }; export declare class WorkflowRunQueueStore extends ProjectStore { private readonly workflowMessages; reserveWorkflowRun(options: WorkflowRunReservationOptions): WorkflowRunQueueRecord; private reserveWorkflowRunInTransaction; reserveOrAdoptWorkflowRun(options: WorkflowRunReservationOptions): WorkflowRunPreparationResult; getWorkflowRun(runId: string): WorkflowRunQueueRecord | undefined; getWorkflowRunView(runId: string): WorkflowRunQueueViewRecord | undefined; workflowRunListRevision(): { total: number; revision: string; }; listWorkflowRunViews(options: { offset: number; limit: number; }): { total: number; revision: string; runs: WorkflowRunQueueViewRecord[]; }; workflowRunProjectPath(runId: string): string | undefined; listWorkflowRuns(options?: { statuses?: WorkflowRunLaunchStatus[]; excludeRunIds?: string[]; limit?: number; }): WorkflowRunQueueRecord[]; findSessionReservation(sessionId: string): WorkflowRunQueueRecord | undefined; findSessionReservationView(sessionId: string): WorkflowRunQueueViewRecord | undefined; claimWorkflowRun(options: { runId: string; runnerId: string; claimToken: string; leaseMs: number; now?: string; }): WorkflowRunQueueRecord | undefined; /** Schedule a runner that validates one pending interactive submission. */ claimWorkflowRunForInteractionValidation(options: { runId: string; runnerId: string; claimToken: string; leaseMs: number; now?: string; }): WorkflowRunQueueRecord | undefined; /** Take a short server claim without scheduling a parked interactive run. */ claimWorkflowRunForControl(options: { runId: string; runnerId: string; claimToken: string; leaseMs: number; now?: string; }): WorkflowRunQueueRecord | undefined; beginWorkflowRunInteractionTimeout(options: { runId: string; targetSessionId: string; claimToken: string; now?: string; }): boolean; markWorkflowRunRunning(options: { runId: string; claimToken: string; now?: string; }): boolean; claimNextWorkflowRun(options: { runnerId: string; claimToken: string; leaseMs: number; now?: string; excludeRunIds?: string[]; }): WorkflowRunQueueRecord | undefined; renewWorkflowRunClaim(options: { runId: string; claimToken: string; leaseMs: number; now?: string; }): boolean; verifyWorkflowRunClaim(options: { runId: string; claimToken: string; now?: string; }): boolean; workflowRunAuthority(runId: string, claimToken: string): { actor: { type: "session" | "host"; id: string; }; ownerType: "session" | "host"; ownerId: string; token: string; generation: number; leaseMs: number; } | undefined; parkWorkflowRun(options: { runId: string; claimToken: string; now?: string; }): boolean; parkWorkflowRunForRunnerNoProgress(options: { runId: string; claimToken: string; detail: string; now?: string; }): boolean; pauseParkedWorkflowRun(options: { runId: string; now?: string; }): boolean; resumePausedInteraction(options: { runId: string; now?: string; }): boolean; requestWorkflowRunResume(options: { runId: string; now?: string; }): boolean; isWorkflowRunPaused(runId: string): boolean; parkWorkflowRunForSourceChange(options: { runId: string; claimToken: string; detail: string; now?: string; }): boolean; parkWorkflowRunForAmbiguousEffect(options: { runId: string; claimToken: string; now?: string; }): boolean; failWorkflowRun(options: { runId: string; claimToken?: string; errorCode: string; errorMessage: string; now?: string; }): boolean; cancelWorkflowRun(options: { runId: string; claimToken?: string; now?: string; }): boolean; /** Cancel a nonterminal run only when its claim is absent or expired. */ cancelStaleWorkflowRun(options: { runId: string; controlId?: string; claimToken?: string; now?: string; }): boolean; deleteWorkflowRun(options: { runId: string; claimToken: string; }): boolean; completeWorkflowRun(options: { runId: string; claimToken: string; now?: string; }): boolean; recordRunEvent(options: { runId: string; workflowRef: string; type: string; payload?: JsonObject; runnerId?: string; now?: string; }): RunEventRecord; listRunEventsAfter(seq: number, options?: { limit?: number; }): RunEventRecord[]; settleRunEffect(runId: string, effectType: "run.park_queue" | "run.settle_queue"): void; private workflowRunRow; private requireWorkflowRunRow; private requireWorkflowRun; private assertWorkflowRunPreparationCompatible; private workflowRunViewRows; private mapWorkflowRun; private claimRun; private claimRunInTransaction; private updateClaimedRunStatus; private releaseRunClaim; private terminalRun; private cancelWorkflowRunDependents; }