import type { ExecutorResult, Loop, LoopRun, StoredWorkflowEvent, WorkflowRun, WorkflowRunStatus, WorkflowSpec, WorkflowStepRun } from "../types.js"; import { preflightTarget, type ExecuteOptions } from "./executor.js"; import type { CreateWorkflowRunInput, WorkflowRecoveryContext } from "./store.js"; import type { GoalRunnerStore } from "./goal/runner.js"; import { type OperationReceiptState, type PrivateOperationDescriptor } from "./operation-contract.js"; export interface ExecuteWorkflowOptions extends ExecuteOptions { loop?: Loop; loopRun?: LoopRun; scheduledFor?: string; idempotencyKey?: string; cancelPollMs?: number; signalTimeoutMessage?: () => string | undefined; /** Per-node goal prompt appended to agent step prompts when a goal executes this workflow. */ goalNodePrompt?: string; } type MaybePromise = T | Promise; export interface WorkflowExecutionStore extends GoalRunnerStore { /** Hosted runners receive server-derived contract events and must not append client-authored copies. */ readonly serverDerivedAgentSessionContracts?: boolean; requireWorkflow(idOrName: string): MaybePromise; createWorkflowRun(input: CreateWorkflowRunInput): MaybePromise; getWorkflowRun(id: string): MaybePromise; requireWorkflowRun(id: string): MaybePromise; listWorkflowStepRuns(workflowRunId: string): MaybePromise; getWorkflowStepRun(workflowRunId: string, stepId: string): MaybePromise; isWorkflowRunTerminal(workflowRunId: string): MaybePromise; startWorkflowStepRun(workflowRunId: string, stepId: string, opts?: { daemonLeaseId?: string; now?: Date; }): MaybePromise; recoverWorkflowRun(workflowRunId: string, reason?: string, context?: WorkflowRecoveryContext): MaybePromise<{ run: WorkflowRun; recoveredSteps: WorkflowStepRun[]; }>; finalizeWorkflowStepRun(workflowRunId: string, stepId: string, patch: Pick & Partial>, opts?: { daemonLeaseId?: string; now?: Date; }): MaybePromise; finalizeWorkflowRun(workflowRunId: string, status: WorkflowRunStatus, patch?: Partial>, opts?: { daemonLeaseId?: string; now?: Date; }): MaybePromise; markWorkflowStepPid(workflowRunId: string, stepId: string, pid: number, opts?: { daemonLeaseId?: string; now?: Date; }): MaybePromise; recordWorkflowStepProgress(workflowRunId: string, stepId: string, progress: { stdout?: string; stderr?: string; payload?: Record; }, opts?: { daemonLeaseId?: string; now?: Date; }): MaybePromise; appendWorkflowEvent(workflowRunId: string, eventType: string, stepId?: string, payload?: Record): MaybePromise; listWorkflowEvents?(workflowRunId: string, limit?: number): MaybePromise; getPrivateOperationDescriptor?(workflowRunId: string, stepId: string): MaybePromise; getPrivateOperationState?(workflowRunId: string, stepId: string): MaybePromise; skipWorkflowStepRun(workflowRunId: string, stepId: string, reason: string, opts?: { daemonLeaseId?: string; now?: Date; }): MaybePromise; } export declare function executeWorkflow(store: WorkflowExecutionStore, workflow: WorkflowSpec, opts?: ExecuteWorkflowOptions): Promise; export declare function preflightWorkflow(workflow: WorkflowSpec, opts?: ExecuteOptions): ReturnType[]; export declare function executeLoopTarget(store: WorkflowExecutionStore, loop: Loop, run: LoopRun, opts?: ExecuteOptions): Promise; export {};