UNPKG

@promptbook/node

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

45 lines (44 loc) 1.29 kB
/** * Default progressive delays used for rate-limit retries: * 1 minute, 2 minutes, 5 minutes, 10 minutes, and 30 minutes. */ export declare const DEFAULT_PROGRESSIVE_BACKOFF_DELAYS_MS: readonly number[]; /** * Options for one progressive backoff counter. */ export type ProgressiveBackoffOptions = { delaysMs?: readonly number[]; maxDelayMs?: number; jitterRatio?: number; random?: () => number; }; /** * Stateful progressive backoff counter with optional jitter and capped maximum delay. */ export declare class ProgressiveBackoff { private readonly delaysMs; private readonly maxDelayMs; private readonly jitterRatio; private readonly random; private failuresSinceSuccess; /** * Creates one progressive backoff counter. */ constructor(options?: ProgressiveBackoffOptions); /** * Number of consecutive failures since the last successful reset. */ get retryCount(): number; /** * Returns the next delay and advances the backoff counter by one failed attempt. */ nextDelayMs(): number; /** * Resets backoff state after one successful call. */ reset(): void; /** * Resolves the non-jittered delay for the given retry index. */ private resolveBaseDelayMs; }