/** * Workflow Worker * * Polls for stalled workflow runs and resumes them. * Enables distributed workflow execution across multiple pods. */ import type { WorkflowBackend } from "../backends/types.js"; /** * Configuration for the workflow worker */ export interface WorkflowWorkerConfig { /** Backend for workflow persistence (must support worker features) */ backend: WorkflowBackend; /** Function to resume a workflow run under the worker that claimed it */ resumeFn: (runId: string, expectedWorkerId?: string) => Promise; /** Interval between poll cycles (ms) */ pollInterval?: number; /** Time after which a run is considered stalled (ms) */ stalledThreshold?: number; /** Maximum concurrent workflow resumes */ concurrency?: number; /** Unique identifier for this worker instance */ workerId?: string; /** Enable debug logging */ debug?: boolean; } /** * Worker status */ export type WorkerStatus = "idle" | "running" | "stopping" | "stopped"; /** * Worker statistics */ export interface WorkerStats { status: WorkerStatus; workerId: string; startedAt?: Date; pollCount: number; resumeCount: number; errorCount: number; lastPollAt?: Date; lastErrorAt?: Date; lastError?: string; } /** Implement workflow worker. */ export declare class WorkflowWorker { private config; private status; private pollTimeout?; private activeResumes; private stats; constructor(config: WorkflowWorkerConfig); /** * Start the worker polling loop */ start(): void; /** * Stop the worker gracefully */ stop(): Promise; /** * Get worker statistics */ getStats(): WorkerStats; /** * Get worker ID */ getWorkerId(): string; /** * Schedule the next poll */ private scheduleNextPoll; /** * Record an error in stats */ private recordError; /** * Poll for stalled workflows and resume them */ private poll; /** * Resume a workflow in the background */ private resumeInBackground; } /** * Create a workflow worker */ export declare function createWorkflowWorker(config: WorkflowWorkerConfig): WorkflowWorker; //# sourceMappingURL=workflow-worker.d.ts.map