/** * WorkflowEngine — abstraction for workflow execution backends. * * Each engine implementation (Temporal, Restate, etc.) adapts its specific * runtime into this common interface so the API layer stays decoupled. */ import type { SerializableWorkflowGraph, WorkflowGraph, InterpreterResult, Scheduler } from './types.js'; import type { SpecResolver } from './spec-resolver.js'; export interface StartExecutionParams { executionId: string; workflowId: string; workflowVersionId: string; graph: SerializableWorkflowGraph; input: unknown; callbackBaseUrl: string; } /** Minimal interface a workflow definition must satisfy for engine.run(). */ export interface RunnableWorkflow { readonly name: string; toGraph(): SerializableWorkflowGraph; toExecutableGraph(resolver: SpecResolver): Promise; } /** Options for engine.run(). */ export interface EngineRunOptions { /** Execution ID (defaults to generated). */ executionId?: string; /** Timeout in ms to wait for completion (default: 30000). */ timeoutMs?: number; } export interface WorkflowEngine { /** Engine identifier (e.g. 'temporal', 'restate'). */ readonly type: string; /** Dispatch model: 'push' (API calls engine) or 'poll' (executor polls API). Default 'push'. */ readonly dispatchMode?: 'push' | 'poll'; /** Initialize the engine (connect, warm up, etc.). */ init(): Promise; /** Start a workflow execution. Returns engine-specific refs for correlation. */ startExecution(params: StartExecutionParams): Promise<{ refs: Record; }>; /** Wait for a workflow execution to complete, with a timeout. */ waitForCompletion(executionId: string, timeoutMs: number): Promise<{ completed: boolean; result?: unknown; }>; /** Send a named signal to a running execution (cancel, pause, resume). */ sendSignal(executionId: string, signalName: string, ...args: unknown[]): Promise; /** Resolve a human task within a running execution. */ resolveHumanTask(executionId: string, nodeKey: string, resolution: { status: string; output?: unknown; error?: unknown; }): Promise; /** Create a scheduler for trigger management. Optional — not all engines support scheduling. */ createScheduler?(workflowId: string, workflowVersionId: string): Scheduler; /** Run a workflow definition end-to-end: start + wait for completion. */ run(definition: RunnableWorkflow, input: unknown, options?: EngineRunOptions): Promise; /** Start a persistent worker that serves multiple workflow definitions. */ serve(definitions: RunnableWorkflow[]): Promise; /** Gracefully shut down the engine connection. */ close(): Promise; } //# sourceMappingURL=workflow-engine.d.ts.map