/** * Shared browser-approval poll loop. * * The create→approve→poll shape used by both: * - CP login (`login()` in auth.ts) — poll the CP for a session token + pod, * gated by a pollSecret Bearer header. * - Pod agent-key approval (`provisionAgentKey` in targets.ts) — poll the pod * for key activation, gated by the human API key. * * No localhost server, no redirect back to the CLI — the browser only APPROVES * a pending record; the CLI holds a secret and polls for the outcome. Every * failure resolves to a clean rejected/timeout instead of a dead browser tab. */ export interface PollForApprovalOptions { /** Endpoint to GET each tick. */ url: string; /** Auth/other headers sent on every poll (e.g. Bearer pollSecret). */ headers?: Record; /** Delay between polls. Default 2000ms. */ intervalMs?: number; /** Overall deadline. Default 120_000ms. */ timeoutMs?: number; /** Per-request timeout. Default 30_000ms. */ requestTimeoutMs?: number; /** True when the parsed response means "approved / done". */ isApproved: (data: unknown) => boolean; /** True when the parsed response means "rejected / denied". */ isRejected: (data: unknown) => boolean; /** Extract the result from an approved response. */ onApproved: (data: unknown) => T; /** Error thrown when isRejected fires. */ rejectedError?: string; /** Error thrown when the deadline elapses. */ timeoutError?: string; } /** * Poll `url` until the response is approved (→ resolve with `onApproved`), * rejected (→ throw `rejectedError`), or the deadline elapses (→ throw * `timeoutError`). Transient network errors and non-2xx responses are ignored * and simply retried until the deadline. */ export declare function pollForApproval(opts: PollForApprovalOptions): Promise;