export type WorkerSignal = | { type: "start"; shardId: string; ts: string } | { type: "heartbeat"; shardId: string; ts: string; meta?: Record; } | { type: "done"; shardId: string; ts: string; payload: Record; } | { type: "error"; shardId: string; ts: string; reason: string; meta?: Record; }; export type WorkerSignalEvent = | WorkerSignal | { type: "stale"; shardId: string; ts: string; lastTs: string; timeoutMs: number; }; export class WorkerSignalChannel { constructor(options: { shardId: string; signalDir: string; timeoutMs?: number; now?: () => number; }); start(): Promise; heartbeat(meta?: Record): Promise; done(payload: Record): Promise; error(reason: string, meta?: Record): Promise; static listen(options: { signalDir: string; onSignal: (signal: WorkerSignalEvent) => void; abortSignal?: AbortSignal; timeoutMs?: number; pollMs?: number; now?: () => number; }): Promise; }