/** * Bounded outbound retry for channel deliveries. * * The core wraps every registered adapter's delivery methods (sendText / * sendCard / promptChoice / closeMenu) so a transient channel failure — * network blip, 429, 5xx — retries a few times with jittered exponential * backoff instead of silently dropping a user-visible message. streamText is * deliberately NOT retried: a partially-streamed reply cannot be resumed, and * restarting it would duplicate the streaming card. * @module dsh-connect/retry */ import type { ChannelAdapter } from "./types.js"; export interface RetryOptions { /** Total attempts including the first call (default 3). */ attempts?: number; /** Base delay between attempts in ms (default 250). */ baseDelayMs?: number; /** Cap for a single delay in ms (default 2000). */ maxDelayMs?: number; /** * Decide whether an error is worth retrying. Defaults to retrying every * error — bounded attempts keep permanent failures cheap (a few extra * channel calls), while transient ones actually recover. */ isTransient?: (error: unknown) => boolean; } /** Run `fn` with bounded, jittered exponential backoff on failure. */ export declare function retry(fn: () => Promise, options?: RetryOptions): Promise; /** * Wrap an adapter so its delivery methods retry transient failures. * Non-delivery faces (start/stop/onInbound) and streamText pass through * untouched. * * Every *optional* member of `ChannelAdapter` must be forwarded here by hand — * this builds a fresh object, so anything not named below is dropped from the * adapter the service actually holds. That is not hypothetical: `sendFile` was * silently lost this way, which made `runner.ts`'s `this.adapter.sendFile === * undefined` check always true and degraded `/send ` to sending the path * as text on every channel. There is a test for the passthrough list; extend it * rather than adding a member to `ChannelAdapter` alone. */ export declare function withOutboundRetry(adapter: ChannelAdapter, options?: RetryOptions): ChannelAdapter; //# sourceMappingURL=retry.d.ts.map