/** * dsh-llm-net-retry — bounded retry for gateway network failures the stock * retry policy cannot classify. * * Sits at the END of the `agent/request-error` waterfall: it first lets the * provider's policy executors (dsh-llm-retry) decide, and only when every one * of them declined (`next()` resolved undefined) AND the failure names a * leaked network variant outside the stock taxonomy (message pattern + code * guard, see match.ts) does it schedule its own bounded retry. Retries are * durable (`llm/retry` / `llm/retry-started` session events, schema- and * shape-compatible with dsh-llm-retry's, so TUI surfaces them unchanged) and * counted under this plugin's own policy key, never touching llm-retry's. * * @module @aiwayds/dsh-llm-net-retry */ import type { Context } from '@deepseek-ai/cordis'; import z from '@deepseek-ai/schemastery'; export { isLeakedNetworkFailure } from './match.ts'; export type { LlmRetryEventData, LlmRetryStartedEventData } from './types.ts'; export { RetryId } from './types.ts'; export declare const name = "dsh-llm-net-retry"; export declare const inject: string[]; /** Plugin configuration. */ export interface Config { /** `off` disables the listener entirely (default `on`). */ mode?: 'on' | 'off'; /** Maximum eligible retries after the first request (default 5). */ maxRetries?: number; /** Local exponential-backoff and jitter configuration. */ backoff?: { /** Initial local exponential-backoff delay in milliseconds (default 500). */ initialDelayMs?: number; /** Maximum locally scheduled delay in milliseconds (default 10000). */ maxDelayMs?: number; /** Symmetric random multiplier range around one (default 0.1). */ jitterRatio?: number; }; } /** Runtime schema for {@link Config}. */ export declare const Config: z; /** Fully resolved plugin policy captured at apply time. */ export interface ResolvedConfig { readonly mode: 'on' | 'off'; readonly maxRetries: number; readonly initialDelayMs: number; readonly maxDelayMs: number; readonly jitterRatio: number; } /** * Validate, default, and detach the plugin configuration. * @param config - optional plugin configuration; omission selects defaults. * @returns an immutable policy safe to capture in listener state. */ export declare function resolveConfig(config: Config | undefined): ResolvedConfig; /** Bounded exponential backoff with symmetric jitter around each local delay. */ export declare function localDelay(config: Pick, retry: number, random: () => number): number; /** Non-serializable hooks used to make timing policy deterministic in tests. */ export interface RetryInternals { /** Random sample in the inclusive zero-to-one range used for jitter. */ random?: () => number; } /** * Install the trailing network-failure safety net on the request-error * waterfall. * @param ctx - plugin context that owns the listener and active waits. * @param config - plugin configuration; omission selects defaults. * @param internals - non-serializable deterministic hooks for tests. */ export declare function apply(ctx: Context, config?: Config, internals?: RetryInternals): void;