export interface DispatcherOptions { /** Max attempts per task. Default 3. */ maxAttempts?: number; /** Backoff base in ms. backoff = base * 2^failCount. Default 1000. */ backoffBaseMs?: number; } export type WorkerSnapshot Promise> = { index: number; status: 'active'; fn: F; running: boolean; failCount: number; totalRuns: number; blockedMs: number; specificQueue: number; } | { index: number; status: 'pending'; promise: Promise; specificQueue: number; } | { index: number; status: 'rejected'; error: string; specificQueue: number; }; export declare class WorkflowDispatcher Promise> { private readonly maxAttempts; private readonly backoffBaseMs; private readonly slots; private readonly globalQueue; private pendingInits; private everActivated; private drainScheduled; constructor(workersOrPromises: Array>, options?: DispatcherOptions); /** Dispatch: choose eligible active with least totalRuns; retry across workers on failure. */ dispatch(...args: Parameters): Promise>>; /** Dispatch to a specific worker (ignore backoff), wait until it is free; retry on the same worker. */ dispatchSpecific(index: number, ...args: Parameters): Promise>>; /** Replace a worker at index with a new active worker function. */ replaceWorker(index: number, fn: F): void; /** Add a new active worker at the tail; return its index. */ addWorker(fn: F): number; /** * Remove a worker completely (splice). It becomes unavailable immediately. * Returns a Promise that resolves when its last running task (if any) finishes. */ removeWorker(index: number): Promise; snapshot(): WorkerSnapshot[]; get pending(): number; private drain; private _drainLoop; private hasAnyActive; private rejectAllQueued; private isEligibleActive; private pickBestActiveForGlobal; private startTaskOnActiveSlot; }