import type { LLMProvider } from '../types/provider/interface.js'; import type { Logger } from '../utils/logger.js'; /** Five minutes without one provider chunk is a stalled model call. */ export declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS: number; /** Resolve the shared run/router stream bound before either creates durable turn identity. */ export declare function resolveStreamIdleTimeoutMs(value: number | undefined): number; /** * Notices a stream that stopped producing without ending. * * One driver had a per-chunk watchdog, written inline, and it defaulted to * OFF — so zero of seven drivers re-armed on a stall unless a host set a * config key it had no reason to know about. The only other bound is each * driver's whole-REQUEST timeout, which a stream that opened successfully * and then went quiet does not trip: the request is fine, the bytes have * simply stopped. * * A turn in that state is not slow, it is stuck. It holds its budget, its * claim and its process, and nothing settles it until an operator * notices — which is the failure mode a kernel with checkpoints and * budgets exists to make impossible. * * ## Why a decorator and not a driver feature * * Written once here, in the shape `withProviderRetry` and * `withProviderFallback` already use, so it composes with them rather than * being reimplemented per driver. The failure is classified `network`, * which is the same classification the inline version produced and the one * retry and fallback already know how to act on: a stalled stream is * retried by the layer above, or the chain moves to the next member. * * ## What it cannot do * * It cannot un-emit. A stall AFTER the first chunk surfaces as an error * rather than a silent restart, exactly as `withProviderRetry` documents * for the same reason — the consumer has already emitted those deltas. */ export interface WithStreamIdleTimeoutOptions { /** * Milliseconds without a chunk before the stream is treated as stalled. * `0` or a non-finite value disables the watchdog and returns the * provider unwrapped. */ readonly idleTimeoutMs: number; readonly log?: Logger; /** Test seam. Defaults to `setTimeout`. */ readonly setTimeoutFn?: typeof setTimeout; /** Test seam. Defaults to `clearTimeout`. */ readonly clearTimeoutFn?: typeof clearTimeout; } export declare function withStreamIdleTimeout(provider: LLMProvider, options: WithStreamIdleTimeoutOptions): LLMProvider; //# sourceMappingURL=idle-timeout.d.ts.map