import type { ActivityInterceptor } from '../core/interceptor.ts'; import type { RemoteWorkerActivityFunction } from './workflow-activity-binding.ts'; export interface LongPollWorkerOptions { serverUrl: string; activities: Record; concurrency?: number; queue?: string; pollTimeout?: number; /** * HTTP headers sent with poll and result requests, such as `Authorization`. * When the server enforces authentication, supply credentials with the * `workers:write` scope here. `Content-Type` is reserved on result requests * and is always set to `application/json`, overriding any value passed here. */ headers?: Record; /** Activity interceptors to run around each activity execution on this worker. */ interceptors?: ActivityInterceptor[]; } /** * HTTP long-poll fallback worker for environments where WebSocket connections * are unavailable (e.g. certain serverless runtimes or proxied environments). * * Continuously polls the server for pending tasks using HTTP long-polling and * executes them locally. Supports the same activity and interceptor model as * {@link RemoteWorker} but with slightly higher per-task latency due to the * poll round-trip. * * @example * ```ts * import { LongPollWorker } from '@lostgradient/weft'; * * using worker = new LongPollWorker({ * serverUrl: 'http://localhost:3000', * activities: { * resize: async (input: unknown) => { * return `resized:${JSON.stringify(input)}`; * }, * }, * concurrency: 3, * queue: 'images', * }); * worker.start(); * ``` */ export declare class LongPollWorker implements Disposable { #private; constructor(options: LongPollWorkerOptions); /** Start polling for tasks. */ start(): void; /** Stop polling and wait for in-flight to finish. */ stop(): Promise; get inFlight(): number; get running(): boolean; [Symbol.dispose](): void; }