import type { StateDatabase } from "../state/database.js"; import { type JsonValue } from "../state/json.js"; import type { HumanDecisionReceipt } from "./types.js"; export type WorkflowRequestKind = "agent" | "assistant" | "checkpoint" | "decision"; export type WorkflowCheckpointState = { request: InteractiveRequestRecord; output?: JsonValue; humanDecision?: HumanDecisionReceipt; }; export type InteractiveRequestRecord = { requestId: string; runId: string; attemptId: string; targetSessionId: string; kind: WorkflowRequestKind; contract: JsonValue; revision: number; status: "pending" | "settled" | "cancelled"; acceptedSubmissionId: string | null; createdAt: string; updatedAt: string; settledAt: string | null; consumedAt: string | null; }; export declare function workflowRequestId(runId: string, attemptId: string): string; /** Immutable identity and payload; an accepted request is never reopened. */ export declare function ensureWorkflowRequest(state: StateDatabase, options: Pick, now?: number): InteractiveRequestRecord; export declare function readWorkflowRequest(state: StateDatabase, requestId: string): InteractiveRequestRecord | undefined; export declare function requestForAttempt(state: StateDatabase, runId: string, attemptId: string): InteractiveRequestRecord | undefined; export declare function acceptedRequestOutput(state: StateDatabase, request: InteractiveRequestRecord): JsonValue; export type WorkflowSubmissionOptions = { requestId: string; submissionId: string; idempotencyKey: string; expectedRevision: number; payload: JsonValue; outcome: "validating" | "accepted" | "rejected" | "adopted"; settle: boolean; receipt?: JsonValue; }; /** Record one exact response candidate or winner under the request revision. */ export declare function recordWorkflowSubmission(state: StateDatabase, options: WorkflowSubmissionOptions): { interaction: InteractiveRequestRecord; submissionId: string; outcome: "accepted" | "adopted"; receipt: JsonValue; };