import { Queue } from 'bullmq';
import type { Intent } from '../common/types.js';
import type { IIntentService } from './types.js';
import { type TraceContext } from '../common/trace.js';
import { type CircuitState } from '../common/circuit-breaker.js';
/**
 * Close all pooled connections during shutdown
 */
export declare function closePooledConnections(): Promise<void>;
export declare const intentIntakeQueue: Queue<any, any, string>;
export declare const intentEvaluateQueue: Queue<any, any, string>;
export declare const intentDecisionQueue: Queue<any, any, string>;
export declare const intentExecuteQueue: Queue<any, any, string>;
export declare const deadLetterQueue: Queue<any, any, string>;
export declare function enqueueIntentSubmission(intent: Intent, options?: {
    namespace?: string;
    traceContext?: TraceContext;
}): Promise<void>;
export declare function registerIntentWorkers(service: IIntentService): void;
/**
 * Gracefully shutdown all workers
 * Waits for in-flight jobs to complete before closing
 */
export declare function shutdownWorkers(timeoutMs?: number): Promise<void>;
/**
 * Get queue health status and update Prometheus gauges
 */
export declare function getQueueHealth(): Promise<{
    intake: {
        waiting: number;
        active: number;
        failed: number;
    };
    evaluate: {
        waiting: number;
        active: number;
        failed: number;
    };
    decision: {
        waiting: number;
        active: number;
        failed: number;
    };
    deadLetter: {
        count: number;
    };
}>;
/**
 * Retry a job from the dead letter queue
 */
export declare function retryDeadLetterJob(jobId: string): Promise<boolean>;
/**
 * Get the policy evaluation circuit breaker status
 * Useful for health checks and monitoring
 */
export declare function getPolicyCircuitBreakerStatus(): Promise<{
    name: string;
    state: CircuitState;
    failureCount: number;
    failureThreshold: number;
    resetTimeoutMs: number;
    lastFailureTime: Date | null;
    openedAt: Date | null;
    timeUntilReset: number | null;
}>;
/**
 * Force the policy circuit breaker to open state
 * Useful for manual intervention during incidents
 */
export declare function forcePolicyCircuitBreakerOpen(): Promise<void>;
/**
 * Force the policy circuit breaker to closed state
 * Useful for recovery after manual intervention
 */
export declare function forcePolicyCircuitBreakerClose(): Promise<void>;
/**
 * Reset the policy circuit breaker state
 * Clears all failure counts and state
 */
export declare function resetPolicyCircuitBreaker(): Promise<void>;
/**
 * Queue health check result with comprehensive metrics
 */
export interface QueueHealthCheckResult {
    healthy: boolean;
    activeJobs: number;
    waitingJobs: number;
    completedJobs: number;
    failedJobs: number;
    processingLatency: number;
    workersAvailable: boolean;
    queueDepth: number;
    deadLetterCount: number;
    details: {
        intake: {
            waiting: number;
            active: number;
            failed: number;
            completed: number;
        };
        evaluate: {
            waiting: number;
            active: number;
            failed: number;
            completed: number;
        };
        decision: {
            waiting: number;
            active: number;
            failed: number;
            completed: number;
        };
        execute: {
            waiting: number;
            active: number;
            failed: number;
            completed: number;
        };
        deadLetter: {
            count: number;
        };
    };
    canaryJobResult?: {
        success: boolean;
        latencyMs: number;
        error?: string;
    };
}
/**
 * Shutdown the canary queue and worker
 */
export declare function shutdownCanaryQueue(): Promise<void>;
/**
 * Enhanced queue health check
 *
 * Performs comprehensive health check including:
 * - Queue depth and job counts
 * - Worker availability check via canary job
 * - Processing latency measurement
 * - Dead letter queue monitoring
 *
 * @param options.runCanary - Whether to run a canary job (default: true)
 * @param options.canaryTimeoutMs - Timeout for canary job (default: 5000ms)
 * @param options.maxQueueDepth - Maximum allowed queue depth before unhealthy (default: 10000)
 */
export declare function checkQueueHealth(options?: {
    runCanary?: boolean;
    canaryTimeoutMs?: number;
    maxQueueDepth?: number;
}): Promise<QueueHealthCheckResult>;
/**
 * Check if queue workers are currently running
 */
export declare function areWorkersRunning(): boolean;
/**
 * Get the current queue depth (waiting + active jobs)
 */
export declare function getQueueDepth(): Promise<number>;
/**
 * Pause all queue workers (stop processing new jobs)
 * Existing jobs in progress will continue to completion
 */
export declare function pauseWorkers(): Promise<void>;
/**
 * Resume all queue workers
 */
export declare function resumeWorkers(): Promise<void>;
/**
 * Wait for all active jobs to complete with timeout
 * Returns true if all jobs completed, false if timeout was reached
 */
export declare function waitForActiveJobs(timeoutMs: number): Promise<{
    completed: boolean;
    remainingJobs: number;
}>;
//# sourceMappingURL=queues.d.ts.map