/**
 * Enhanced Concurrency Controller
 *
 * Queue-based rate limiting with:
 * - Priority queue (HIGH/NORMAL/LOW)
 * - Circuit breaker pattern
 * - Resource-aware scheduling
 * - Adaptive auto-scaling
 */
import type { ConcurrencyConfig } from "../../shared/agent/interfaces/concurrency-config.js";
import { ConcurrencyToken } from "./concurrency-token.js";
export type { ConcurrencyConfig } from "../../shared/agent/interfaces/concurrency-config.js";
export declare enum TaskPriority {
    HIGH = 0,
    NORMAL = 1,
    LOW = 2
}
export declare enum CircuitState {
    CLOSED = "CLOSED",// Normal operation
    OPEN = "OPEN",// Blocking requests
    HALF_OPEN = "HALF_OPEN"
}
export declare class ConcurrencyController {
    private counts;
    private queues;
    private limits;
    private config;
    private successStreak;
    private failureCount;
    private circuits;
    private readonly CIRCUIT_THRESHOLD;
    private readonly CIRCUIT_TIMEOUT;
    private readonly HALF_OPEN_SUCCESS;
    private readonly MAX_MEMORY_PERCENT;
    private workerPools;
    constructor(config?: ConcurrencyConfig);
    setLimit(key: string, limit: number): void;
    getConcurrencyLimit(key: string): number;
    getLimit(key: string): number;
    /**
     * Acquire slot with priority support
     */
    acquire(key: string, priority?: TaskPriority): Promise<void>;
    release(key: string): void;
    /**
     * Report result with circuit breaker integration
     */
    reportResult(key: string, success: boolean): void;
    private handleSuccess;
    private handleFailure;
    private isCircuitOpen;
    private getCircuit;
    private isUnderResourcePressure;
    private removeFromQueue;
    getQueueLength(key: string): number;
    getActiveCount(key: string): number;
    getConcurrencyInfo(key: string): string;
    /**
     * Get circuit breaker state for monitoring
     */
    getCircuitState(key: string): CircuitState;
    /**
     * Manually reset circuit breaker
     */
    resetCircuit(key: string): void;
    /**
     * Acquire slot and return RAII token for automatic cleanup
     * @param key - Concurrency key
     * @param priority - Task priority
     * @param autoReleaseMs - Auto-release timeout (default: 10 minutes)
     * @returns ConcurrencyToken - Call .release() when done
     */
    acquireToken(key: string, priority?: TaskPriority, autoReleaseMs?: number): Promise<ConcurrencyToken>;
    /**
     * Enable work-stealing for a concurrency key
     * @param key - Concurrency key
     * @param workerCount - Number of workers (default: 4)
     */
    enableWorkStealing(key: string, workerCount?: number): void;
    /**
     * Get work-stealing pool statistics
     */
    getWorkStealingStats(key: string): {
        workers: number;
        totalExecuted: number;
        totalStolen: number;
        stealRate: number;
        utilizationPercent: number;
        queuedTasks: number;
    } | null;
    /**
     * Shutdown - stops all worker pools
     */
    shutdown(): Promise<void>;
}
