/**
 * CLIProxyAPI Stats Fetcher
 *
 * Fetches usage statistics from CLIProxyAPI's management API.
 * Requires usage-statistics-enabled: true in config.yaml.
 */
/** Per-account usage statistics */
export interface AccountUsageStats {
    /** Provider-qualified lookup key (for example: "codex:user@example.com") */
    accountKey: string;
    /** Canonical provider name reported by CLIProxyAPI */
    provider: string;
    /** Raw account email or identifier */
    source: string;
    /** Number of successful requests */
    successCount: number;
    /** Number of failed requests */
    failureCount: number;
    /** Total tokens used */
    totalTokens: number;
    /** Last request timestamp */
    lastUsedAt?: string;
}
/** Usage statistics from CLIProxyAPI */
export interface CliproxyStats {
    /** Total number of requests processed */
    totalRequests: number;
    /** Total successful requests */
    successCount: number;
    /** Total failed requests */
    failureCount: number;
    /** Token counts */
    tokens: {
        input: number;
        output: number;
        total: number;
    };
    /** Requests grouped by model */
    requestsByModel: Record<string, number>;
    /** Requests grouped by provider */
    requestsByProvider: Record<string, number>;
    /** Per-account usage breakdown */
    accountStats: Record<string, AccountUsageStats>;
    /** Number of quota exceeded (429) events */
    quotaExceededCount: number;
    /** Number of request retries */
    retryCount: number;
    /** Timestamp of stats collection */
    collectedAt: string;
}
/** Request detail from CLIProxyAPI */
export interface CliproxyRequestDetail {
    timestamp: string;
    source: string;
    auth_index: string | number;
    request_id?: string;
    tokens: {
        input_tokens: number;
        output_tokens: number;
        reasoning_tokens: number;
        cached_tokens: number;
        total_tokens: number;
    };
    failed: boolean;
}
/** @deprecated Use CliproxyRequestDetail instead */
type RequestDetail = CliproxyRequestDetail;
/** Usage API response from CLIProxyAPI /v0/management/usage endpoint */
export interface CliproxyUsageApiResponse {
    failed_requests?: number;
    usage?: {
        total_requests?: number;
        success_count?: number;
        failure_count?: number;
        total_tokens?: number;
        apis?: Record<string, {
            total_requests?: number;
            total_tokens?: number;
            models?: Record<string, {
                total_requests?: number;
                total_tokens?: number;
                details?: RequestDetail[];
            }>;
        }>;
    };
}
/** Auth file metadata from CLIProxyAPI /v0/management/auth-files */
export interface CliproxyManagementAuthFile {
    auth_index?: string | number;
    provider?: string;
    email?: string;
    name?: string;
}
/**
 * Fetch usage statistics from CLIProxyAPI management API
 * @param port CLIProxyAPI port (default: 8317)
 * @returns Stats object or null if unavailable
 */
export declare function fetchCliproxyStats(port?: number): Promise<CliproxyStats | null>;
/**
 * Fetch raw usage response from CLIProxyAPI management API
 * Returns the unprocessed API response for transformation by cliproxy-usage-transformer
 */
export declare function fetchCliproxyUsageRaw(port?: number): Promise<CliproxyUsageApiResponse | null>;
export declare const __testExports: {
    clearCachedUsageQueueResponse(): void;
};
/** OpenAI-compatible model object from /v1/models endpoint */
export interface CliproxyModel {
    id: string;
    object: string;
    created: number;
    owned_by: string;
}
/** Categorized models response for UI */
export interface CliproxyModelsResponse {
    models: CliproxyModel[];
    byCategory: Record<string, CliproxyModel[]>;
    totalCount: number;
}
/**
 * Fetch available models from CLIProxyAPI /v1/models endpoint
 * @param port CLIProxyAPI port (default: 8317)
 * @returns Categorized models or null if unavailable
 */
export declare function fetchCliproxyModels(port?: number): Promise<CliproxyModelsResponse | null>;
/** Error log file metadata from CLIProxyAPI */
export interface CliproxyErrorLog {
    /** Filename (e.g., "error-v1-chat-completions-2025-01-15T10-30-00.log") */
    name: string;
    /** File size in bytes */
    size: number;
    /** Last modified timestamp (Unix seconds) */
    modified: number;
    /** Absolute path to the log file (injected by backend) */
    absolutePath?: string;
    /** HTTP status code extracted from log (injected by backend) */
    statusCode?: number;
    /** Model name extracted from request body (injected by backend) */
    model?: string;
}
/**
 * Fetch error log file list from CLIProxyAPI management API
 * @param port CLIProxyAPI port (default: 8317)
 * @returns Array of error log metadata or null if unavailable
 */
export declare function fetchCliproxyErrorLogs(port?: number): Promise<CliproxyErrorLog[] | null>;
/**
 * Fetch error log file content from CLIProxyAPI management API
 * @param name Error log filename
 * @param port CLIProxyAPI port (default: 8317)
 * @returns Log file content as string or null if unavailable
 */
export declare function fetchCliproxyErrorLogContent(name: string, port?: number): Promise<string | null>;
/**
 * Check if CLIProxyAPI is running and responsive
 * @param port CLIProxyAPI port (default: 8317)
 * @returns true if proxy is running
 */
export declare function isCliproxyRunning(port?: number): Promise<boolean>;
export {};
//# sourceMappingURL=stats-fetcher.d.ts.map