/**
 * @fileoverview Base Class for AI Checker Components
 *
 * Provides shared functionality for AI-powered checkers that spawn fresh Claude CLI
 * sessions to analyze terminal output. This base class handles:
 * - Mux session spawning and cleanup
 * - Temp file management for output capture
 * - Polling for completion markers
 * - Cooldown management
 * - Error handling and consecutive error tracking
 * - Event emission for state changes
 *
 * Subclasses implement:
 * - `muxNamePrefix`: Prefix for mux session names (e.g., 'codeman-aicheck-')
 * - `doneMarker`: Completion marker in output file (e.g., '__AICHECK_DONE__')
 * - `tempFilePrefix`: Prefix for temp files (e.g., 'codeman-aicheck')
 * - `logPrefix`: Prefix for log messages (e.g., '[AiIdleChecker]')
 * - `buildPrompt()`: Build the prompt from terminal buffer
 * - `parseVerdict()`: Parse the verdict from AI output
 * - `getPositiveVerdict()`: Return the "positive" verdict that doesn't trigger cooldown
 * - `defaultConfig`: Default configuration values
 *
 * @module ai-checker-base
 */
import { EventEmitter } from 'node:events';
/** Base configuration shared by all AI checkers */
export interface AiCheckerConfigBase {
    /** Whether the checker is enabled */
    enabled: boolean;
    /** Model to use for the check */
    model: string;
    /** Maximum characters of terminal buffer to send */
    maxContextChars: number;
    /** Timeout for the check in ms */
    checkTimeoutMs: number;
    /** Cooldown after negative verdict in ms */
    cooldownMs: number;
    /** Cooldown after errors in ms */
    errorCooldownMs: number;
    /** Max consecutive errors before disabling */
    maxConsecutiveErrors: number;
}
/** Status values shared by all AI checkers */
export type AiCheckerStatus = 'ready' | 'checking' | 'cooldown' | 'disabled' | 'error';
/** Base result structure for all AI checkers */
export interface AiCheckerResultBase<V extends string> {
    verdict: V;
    reasoning: string;
    durationMs: number;
}
/** Base state structure for all AI checkers */
export interface AiCheckerStateBase<V extends string> {
    status: AiCheckerStatus;
    lastVerdict: V | null;
    lastReasoning: string | null;
    lastCheckDurationMs: number | null;
    cooldownEndsAt: number | null;
    consecutiveErrors: number;
    totalChecks: number;
    disabledReason: string | null;
}
/**
 * Abstract base class for AI-powered checkers.
 * Handles spawning Claude CLI in a mux session to analyze terminal output.
 *
 * @template V - The verdict type (e.g., 'IDLE' | 'WORKING' | 'ERROR')
 * @template C - The configuration type
 * @template R - The result type
 * @template S - The state type
 */
export declare abstract class AiCheckerBase<V extends string, C extends AiCheckerConfigBase, R extends AiCheckerResultBase<V>, S extends AiCheckerStateBase<V>> extends EventEmitter {
    protected config: C;
    protected sessionId: string;
    protected _status: AiCheckerStatus;
    protected lastVerdict: V | null;
    protected lastReasoning: string | null;
    protected lastCheckDurationMs: number | null;
    protected cooldownEndsAt: number | null;
    protected cooldownTimer: NodeJS.Timeout | null;
    protected consecutiveErrors: number;
    protected totalChecks: number;
    protected disabledReason: string | null;
    protected checkMuxName: string | null;
    protected checkTempFile: string | null;
    protected checkPromptFile: string | null;
    protected checkPollTimer: NodeJS.Timeout | null;
    protected checkTimeoutTimer: NodeJS.Timeout | null;
    protected checkStartTime: number;
    protected checkCancelled: boolean;
    protected checkResolve: ((result: R) => void) | null;
    /** Prefix for mux session names (e.g., 'codeman-aicheck-') */
    protected abstract readonly muxNamePrefix: string;
    /** Marker written to temp file when check is complete */
    protected abstract readonly doneMarker: string;
    /** Prefix for temp files (e.g., 'codeman-aicheck') */
    protected abstract readonly tempFilePrefix: string;
    /** Prefix for log messages (e.g., '[AiIdleChecker]') */
    protected abstract readonly logPrefix: string;
    /** Description for log messages (e.g., 'AI idle check', 'AI plan check') */
    protected abstract readonly checkDescription: string;
    /**
     * Build the prompt to send to Claude.
     * @param terminalBuffer - The trimmed and stripped terminal buffer
     * @returns The complete prompt string
     */
    protected abstract buildPrompt(terminalBuffer: string): string;
    /**
     * Parse the verdict from Claude's output.
     * @param output - The raw output from Claude (without done marker)
     * @returns The parsed verdict and reasoning, or null if unparseable
     */
    protected abstract parseVerdict(output: string): {
        verdict: V;
        reasoning: string;
    } | null;
    /**
     * Get the "positive" verdict that indicates success and doesn't trigger cooldown.
     * For idle checker this is 'IDLE', for plan checker this is 'PLAN_MODE'.
     */
    protected abstract getPositiveVerdict(): V;
    /**
     * Get the "negative" verdict that triggers cooldown.
     * For idle checker this is 'WORKING', for plan checker this is 'NOT_PLAN_MODE'.
     */
    protected abstract getNegativeVerdict(): V;
    /**
     * Get the error verdict value.
     */
    protected abstract getErrorVerdict(): V;
    /**
     * Create an error result.
     */
    protected abstract createErrorResult(reasoning: string, durationMs: number): R;
    /**
     * Create a success result.
     */
    protected abstract createResult(verdict: V, reasoning: string, durationMs: number): R;
    constructor(sessionId: string, defaultConfig: C, config?: Partial<C>);
    /** Get the current status */
    get status(): AiCheckerStatus;
    /** Get comprehensive state for UI display */
    getState(): S;
    /** Check if the checker is on cooldown */
    isOnCooldown(): boolean;
    /** Get remaining cooldown time in ms */
    getCooldownRemainingMs(): number;
    /**
     * Run an AI check against the provided terminal buffer.
     * Spawns a fresh Claude CLI in a tmux session, captures output to temp file.
     *
     * @param terminalBuffer - Raw terminal output to analyze
     * @returns The verdict result
     */
    check(terminalBuffer: string): Promise<R>;
    /**
     * Cancel an in-progress check.
     * Kills the mux session and cleans up.
     */
    cancel(): void;
    /** Reset all state for a new cycle */
    reset(): void;
    /** Update configuration at runtime */
    updateConfig(config: Partial<C>): void;
    /** Get current config */
    getConfig(): C;
    private runCheck;
    private parseOutput;
    private cleanupCheck;
    private handleError;
    private startCooldown;
    private clearCooldown;
    private disable;
    private log;
}
//# sourceMappingURL=ai-checker-base.d.ts.map