/**
 * Token Refresh Worker
 *
 * Background worker that periodically checks and refreshes OAuth tokens
 * before they expire. Runs as interval loop with retry logic.
 */
import { CLIProxyProvider } from '../types';
/** Worker configuration */
export interface TokenRefreshConfig {
    /** Refresh check interval in minutes (default: 30) */
    refreshInterval: number;
    /** Preemptive refresh time in minutes (default: 45) */
    preemptiveTime: number;
    /** Maximum retry attempts per token (default: 3) */
    maxRetries: number;
    /** Base delay for exponential backoff in ms (default: 1000) */
    retryBaseDelay: number;
    /** Timeout for refresh operations in ms (default: 10000) */
    refreshTimeout: number;
    /** Enable verbose logging */
    verbose: boolean;
}
/** Result of a token refresh attempt */
export interface RefreshResult {
    provider: CLIProxyProvider;
    accountId: string;
    success: boolean;
    error?: string;
    refreshedAt?: Date;
    nextExpiry?: number;
}
/**
 * Background token refresh worker
 * Manages periodic token refresh checks with retry logic
 */
export declare class TokenRefreshWorker {
    private config;
    private intervalId;
    private running;
    private lastResults;
    private exitHandler;
    constructor(config?: Partial<TokenRefreshConfig>);
    /**
     * Start the worker
     * Runs refresh loop immediately, then on interval
     */
    start(): void;
    /**
     * Stop the worker
     */
    stop(): void;
    /**
     * Check if worker is active
     */
    isActive(): boolean;
    /**
     * Manually trigger refresh check now
     */
    refreshNow(): Promise<RefreshResult[]>;
    /**
     * Get results from last refresh cycle
     */
    getLastRefreshResults(): RefreshResult[];
    /**
     * Main refresh loop
     * Checks all tokens and refreshes those needing refresh
     */
    private refreshLoop;
    /**
     * Refresh a single token with retry logic
     * Uses exponential backoff on failures
     */
    private refreshWithRetry;
    /**
     * Check if error is unrecoverable (should not retry)
     */
    private isUnrecoverableError;
    /**
     * Log message if verbose enabled
     */
    private log;
}
//# sourceMappingURL=token-refresh-worker.d.ts.map