/**
 * Auth Profile Manager
 *
 * OpenClaw-inspired profile manager with round-robin rotation and
 * session stickiness. Manages authentication profiles across multiple
 * providers with exponential backoff cooldowns, billing-aware failure
 * handling, and persistent state.
 */
import { EventEmitter } from 'events';
/**
 * Authentication profile credentials
 */
export interface AuthProfileCredentials {
    /** API key for api-key auth */
    apiKey?: string;
    /** OAuth access token */
    accessToken?: string;
    /** OAuth refresh token */
    refreshToken?: string;
}
/**
 * Authentication profile metadata
 */
export interface AuthProfileMetadata {
    /** Model to use with this profile */
    model?: string;
    /** Base URL override */
    baseURL?: string;
    /** Additional metadata */
    [key: string]: string | undefined;
}
/**
 * Authentication profile
 */
export interface AuthProfile {
    /** Unique profile ID */
    id: string;
    /** Provider name (e.g. 'grok', 'openai', 'anthropic') */
    provider: string;
    /** Authentication type */
    type: 'api-key' | 'oauth';
    /** Credentials */
    credentials: AuthProfileCredentials;
    /** Priority (higher = preferred) */
    priority: number;
    /** Profile metadata */
    metadata: AuthProfileMetadata;
}
/**
 * Rotation strategy for profile selection
 */
export type RotationStrategy = 'round-robin' | 'priority' | 'random';
/**
 * Auth Profile Manager configuration
 */
export interface AuthProfileManagerConfig {
    /** Profiles to manage */
    profiles: AuthProfile[];
    /** Strategy for selecting next profile */
    rotationStrategy: RotationStrategy;
    /** Stick with a profile once selected for a session */
    sessionSticky: boolean;
    /** Base cooldown duration in ms after failure */
    cooldownMs: number;
    /** Cooldown duration for billing failures (5 hours) */
    billingCooldownMs: number;
    /** Maximum cooldown cap (24 hours) */
    maxCooldownMs: number;
    /** Path to persist state */
    persistPath: string;
}
/**
 * Default configuration
 */
export declare const DEFAULT_AUTH_PROFILE_MANAGER_CONFIG: AuthProfileManagerConfig;
/**
 * Auth Profile Manager
 *
 * Manages authentication profiles with round-robin rotation, session
 * stickiness, and exponential backoff cooldowns. Supports billing-aware
 * failure handling with separate escalation.
 *
 * Events:
 * - `profile:selected` - Emitted when a profile is selected (profileId, sessionId?)
 * - `profile:failed` - Emitted when a profile fails (profileId, error)
 * - `profile:cooldown` - Emitted when a profile enters cooldown (profileId, cooldownMs)
 * - `profile:recovered` - Emitted when a profile exits cooldown (profileId)
 */
export declare class AuthProfileManager extends EventEmitter {
    private config;
    private profiles;
    private cooldownStates;
    private sessionBindings;
    private roundRobinIndex;
    private recoveryTimers;
    constructor(config?: Partial<AuthProfileManagerConfig>);
    /**
     * Add a profile
     */
    addProfile(profile: AuthProfile): void;
    /**
     * Remove a profile
     */
    removeProfile(profileId: string): boolean;
    /**
     * Get a profile by ID
     */
    getProfile(profileId: string): AuthProfile | undefined;
    /**
     * Get all registered profiles
     */
    getAllProfiles(): AuthProfile[];
    /**
     * Get the next available profile, optionally sticky to a session.
     *
     * If sessionSticky is enabled and a session already has a bound profile
     * that is healthy, that profile is returned. Otherwise a new profile is
     * selected using the configured rotation strategy.
     */
    getNextProfile(sessionId?: string): AuthProfile | null;
    /**
     * Get the sticky profile for a session (without selecting a new one)
     */
    getProfileForSession(sessionId: string): AuthProfile | null;
    /**
     * Get all profiles not currently in cooldown
     */
    getHealthyProfiles(): AuthProfile[];
    /**
     * Mark a profile as failed with exponential backoff cooldown.
     *
     * Normal failures: 1min -> 5min -> 25min -> 1h (max)
     * Billing failures: 5h -> 10h -> 20h -> 24h (max)
     *
     * The backoff multiplier is 5x for normal and 2x for billing.
     */
    markFailed(profileId: string, error: string, isBilling?: boolean): void;
    /**
     * Mark a profile as successful, resetting its failure count
     */
    markSuccess(profileId: string): void;
    /**
     * Release a session's sticky profile binding
     */
    releaseSession(sessionId: string): void;
    /**
     * Round-robin selection across healthy profiles
     */
    private selectRoundRobin;
    /**
     * Priority-based selection (highest priority first)
     */
    private selectByPriority;
    /**
     * Random selection
     */
    private selectRandom;
    /**
     * Check if a profile is currently in cooldown
     */
    private isInCooldown;
    /**
     * Recover a profile from cooldown
     */
    private recoverProfile;
    /**
     * Schedule automatic recovery after cooldown expires
     */
    private scheduleRecovery;
    /**
     * Save cooldown states to disk
     */
    private saveState;
    /**
     * Load cooldown states from disk
     */
    private loadState;
    /**
     * Get status of all profiles
     */
    getStatus(): Array<{
        profileId: string;
        provider: string;
        type: 'api-key' | 'oauth';
        priority: number;
        healthy: boolean;
        failureCount: number;
        inCooldown: boolean;
        cooldownRemainingMs: number;
        lastError?: string;
    }>;
    /**
     * Shutdown - clear all timers
     */
    shutdown(): void;
}
/**
 * Get the auth profile manager singleton
 */
export declare function getAuthProfileManager(config?: Partial<AuthProfileManagerConfig>): AuthProfileManager;
/**
 * Reset the auth profile manager singleton
 */
export declare function resetAuthProfileManager(): void;
export default AuthProfileManager;
