/**
 * Idle Detection Service
 *
 * Periodically checks for idle agents and suspends them to free resources.
 * Uses PtyActivityTrackerService for PTY idle time and AgentHeartbeatService
 * for heartbeat staleness as dual signals.
 *
 * @module idle-detection-service
 */
import type { AgentRegistrationService } from './agent-registration.service.js';
/**
 * Periodically scans active agents and suspends those that have been
 * idle longer than the configured `agentIdleTimeoutMinutes`.
 *
 * An agent is considered idle when BOTH:
 * 1. PTY has had no output for the timeout period
 * 2. Agent is not the orchestrator (exempt)
 */
export declare class IdleDetectionService {
    private static instance;
    private logger;
    private timer;
    private agentRegistrationService;
    private isChecking;
    private lastTickStartedAt;
    private lastTickCompletedAt;
    private lastTickDurationMs;
    private consecutiveSkippedTicks;
    private forcedResetCount;
    private constructor();
    /**
     * Inject AgentRegistrationService for auto-stop capability.
     *
     * @param service - AgentRegistrationService instance
     */
    setAgentRegistrationService(service: AgentRegistrationService): void;
    /**
     * Get the singleton instance.
     *
     * @returns The IdleDetectionService singleton
     */
    static getInstance(): IdleDetectionService;
    /**
     * Reset the singleton (for testing).
     */
    static resetInstance(): void;
    /**
     * Start the periodic idle check cycle.
     */
    start(): void;
    /**
     * Wrapper around `performCheck` that adds re-entrancy guard, heartbeat
     * logging, and duration tracking. Defensive against silent hangs — if
     * `performCheck` ever stops resolving (e.g., dependency hangs), the
     * `isChecking` guard prevents overlapping invocations from piling up,
     * and `consecutiveSkippedTicks` makes the stuck state observable.
     *
     * Why: on 2026-05-14 the loop stopped producing logs for 21 hours while
     * the timer was still scheduled. Without a per-tick heartbeat the
     * regression was invisible.
     */
    private runTick;
    /**
     * Snapshot of recent tick activity. Used by health/status endpoints
     * to detect a silently stuck loop without parsing logs.
     *
     * @returns Tick observability stats. All timestamps in epoch ms.
     */
    getStats(): {
        isRunning: boolean;
        isChecking: boolean;
        lastTickStartedAt: number | null;
        lastTickCompletedAt: number | null;
        lastTickDurationMs: number | null;
        consecutiveSkippedTicks: number;
        forcedResetCount: number;
    };
    /**
     * Stop the periodic idle check cycle.
     */
    stop(): void;
    /**
     * Check if the service is currently running.
     *
     * @returns True if the check cycle is active
     */
    isRunning(): boolean;
    /**
     * Perform a single idle check across all active agents.
     * Reads the timeout setting, iterates active members, and
     * suspends any that exceed the idle threshold.
     */
    performCheck(): Promise<void>;
    /**
     * Emergency stop of idle agents during memory pressure.
     * Stops all non-orchestrator agents with workingStatus 'idle',
     * regardless of the configured idle timeout.
     *
     * Called by SystemResourceAlertService when memory usage is critical.
     *
     * @returns Number of agents stopped
     */
    forceStopIdleAgents(): Promise<number>;
}
//# sourceMappingURL=idle-detection.service.d.ts.map