export declare function getProviderFirstEventTimeoutFallbackMs(provider: string): number | undefined; /** * Returns the idle timeout used for provider streaming transports. * * `SKC_OPENAI_STREAM_IDLE_TIMEOUT_MS` is honored first; `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS` is a backward-compatible alias. * Set `PI_STREAM_IDLE_TIMEOUT_MS=0` to disable the watchdog. * * Providers that legitimately stream much slower than the global default can pass * `fallbackMs` to widen the floor used when neither env var nor caller option is set. * Caller options still take precedence; env overrides still trump the fallback. */ export declare function getStreamIdleTimeoutMs(fallbackMs?: number): number | undefined; /** * Returns the idle timeout used for OpenAI-family streaming transports. * * Honors `SKC_OPENAI_STREAM_IDLE_TIMEOUT_MS` first (`PI_OPENAI_STREAM_IDLE_TIMEOUT_MS` is the legacy alias). Set `=0` to disable. */ export declare function getOpenAIStreamIdleTimeoutMs(): number | undefined; /** * Returns the timeout used while waiting for the first stream event. * The first token can legitimately take longer than later inter-event gaps, * so the default never undershoots the steady-state idle timeout. * * Set `PI_STREAM_FIRST_EVENT_TIMEOUT_MS=0` to disable the watchdog. * * Providers whose first response can legitimately take longer (heavy reasoning, * slow cold-start proxies) can pass `fallbackMs` to widen the floor used when * neither env var nor caller option is set. Caller options still take precedence; * env overrides still trump the fallback. */ export declare function getStreamFirstEventTimeoutMs(idleTimeoutMs?: number, fallbackMs?: number): number | undefined; export type Watchdog = NodeJS.Timeout | undefined; /** * Starts a watchdog that aborts a request if no first stream event arrives in time. * Call `markFirstEventReceived()` as soon as the first event is observed. */ export declare function createWatchdog(timeoutMs: number | undefined, onTimeout: () => void): Watchdog; export interface IdleTimeoutIteratorOptions { watchdog?: Watchdog; idleTimeoutMs?: number; firstItemTimeoutMs?: number; errorMessage: string; firstItemErrorMessage?: string; onIdle?: () => void; onFirstItemTimeout?: () => void; /** * Optional semantic-progress predicate. Non-progress items are still yielded, * but they do not reset the idle deadline. This prevents provider * keepalive/no-op events from keeping a stalled tool call alive forever. */ isProgressItem?: (item: unknown) => boolean; /** * Cancel iteration as soon as this signal aborts. Required for caller-driven * cancellation (ESC) when the underlying transport does not surface signal * aborts to the iterator (HTTP/2 proxies, native sockets, mocked fetch). * Without this, the consumer sleeps on iterator.next() until the idle/first * -event watchdog fires — observable as the issue #912 "Working… forever" * symptom on the github-copilot provider. */ abortSignal?: AbortSignal; } /** * Yields items from an async iterable while enforcing a maximum idle gap between items. * * The first item may use a shorter timeout so stuck requests can be aborted and retried * before any user-visible content has streamed. */ export declare function iterateWithIdleTimeout(iterable: AsyncIterable, options: IdleTimeoutIteratorOptions): AsyncGenerator;