/**
 * Output Analyzer Service
 *
 * Analyzes terminal output to determine the agent's state
 * and whether continuation is needed.
 *
 * @module services/continuation/output-analyzer.service
 */
import { AgentStateAnalysis, TaskInfo, IOutputAnalyzer, OutputAnalysisContext } from '../../types/continuation.types.js';
import { ErrorType } from './patterns/error-patterns.js';
/**
 * Signals indicating task completion
 */
export interface CompletionSignals {
    /** Agent called complete_task tool */
    taskMarkedComplete: boolean;
    /** Test output shows all tests pass */
    testsAllPassed: boolean;
    /** Build completed successfully */
    buildSucceeded: boolean;
    /** Git commit was made */
    commitMade: boolean;
    /** PR was created */
    prCreated: boolean;
    /** Agent explicitly said done/finished */
    explicitDone: boolean;
}
/**
 * Signals indicating errors
 */
export interface ErrorSignals {
    /** Whether any error was detected */
    hasError: boolean;
    /** Type of error if detected */
    errorType?: ErrorType;
    /** Extracted error message */
    errorMessage?: string;
    /** Stack trace if available */
    stackTrace?: string;
    /** Suggested fix for the error */
    suggestedFix?: string;
}
/**
 * Signals indicating agent is waiting
 */
export interface WaitingSignals {
    /** Agent is waiting for input */
    waitingForInput: boolean;
    /** Agent is waiting for approval */
    waitingForApproval: boolean;
    /** Agent is asking a question */
    askingQuestion: boolean;
    /** Agent is waiting for another agent */
    waitingForOtherAgent: boolean;
    /** Reason for waiting if detectable */
    waitingReason?: string;
}
/**
 * Parameters for output analysis
 */
export interface AnalyzeParams {
    /** Session name being analyzed */
    sessionName: string;
    /** Terminal output to analyze */
    output: string;
    /** Current assigned task */
    currentTask?: TaskInfo;
    /** PTY exit code if applicable */
    exitCode?: number;
    /** Previous analysis for context */
    previousAnalysis?: AgentStateAnalysis;
    /** Number of iterations so far */
    iterations?: number;
}
/**
 * Service that analyzes terminal output to determine agent state
 *
 * Features:
 * - Pattern matching for completion, error, waiting, and idle signals
 * - Confidence scoring based on signal strength
 * - Error extraction and fix suggestions
 * - Iteration tracking integration
 *
 * @example
 * ```typescript
 * const analyzer = OutputAnalyzer.getInstance();
 *
 * const analysis = await analyzer.analyze({
 *   sessionName: 'team-dev',
 *   output: terminalOutput,
 *   currentTask: { id: '1', title: 'Fix bug' },
 * });
 *
 * if (analysis.conclusion === 'TASK_COMPLETE') {
 *   // Move to next task
 * }
 * ```
 */
export declare class OutputAnalyzer implements IOutputAnalyzer {
    private static instance;
    private readonly logger;
    /**
     * Creates a new OutputAnalyzer
     */
    private constructor();
    /**
     * Gets the singleton instance
     *
     * @returns The OutputAnalyzer instance
     */
    static getInstance(): OutputAnalyzer;
    /**
     * Clears the singleton instance (for testing)
     */
    static clearInstance(): void;
    /**
     * Analyze terminal output to determine agent state
     *
     * @param sessionName - Session to analyze
     * @param output - Terminal output to analyze
     * @param context - Additional context for analysis
     * @returns Analysis result with conclusion and recommendation
     */
    analyze(sessionName: string, output: string, context?: OutputAnalysisContext): Promise<AgentStateAnalysis>;
    /**
     * Analyze terminal output with full parameters
     *
     * @param params - Analysis parameters
     * @returns Analysis result with conclusion and recommendation
     */
    analyzeWithParams(params: AnalyzeParams): Promise<AgentStateAnalysis>;
    /**
     * Detect completion signals in output
     *
     * @param output - Terminal output to analyze
     * @returns Completion signals found
     */
    detectCompletionSignals(output: string): CompletionSignals;
    /**
     * Detect error patterns in output
     *
     * @param output - Terminal output to analyze
     * @returns Error signals found
     */
    detectErrorPatterns(output: string): ErrorSignals;
    /**
     * Detect waiting signals in output
     *
     * @param output - Terminal output to analyze
     * @returns Waiting signals found
     */
    detectWaitingSignals(output: string): WaitingSignals;
    /**
     * Detect idle state in output
     *
     * @param output - Terminal output to analyze
     * @returns Whether the agent appears idle
     */
    detectIdleState(output: string): boolean;
    /**
     * Determine the overall conclusion from signals
     *
     * @param signals - All detected signals
     * @returns Analysis result with conclusion and recommendation
     */
    private determineConclusion;
    /**
     * Check if any pattern matches the text
     *
     * @param text - Text to search
     * @param patterns - Patterns to match
     * @returns True if any pattern matches
     */
    private matchAny;
    /**
     * Extract error message from output
     *
     * @param output - Terminal output
     * @param patterns - Patterns that matched
     * @returns Extracted error message
     */
    private extractErrorMessage;
    /**
     * Extract stack trace from output
     *
     * @param output - Terminal output
     * @returns Extracted stack trace
     */
    private extractStackTrace;
    /**
     * Get suggested fix for an error type
     *
     * @param errorType - Type of error
     * @param errorMessage - Error message if available
     * @returns Suggested fix
     */
    private getSuggestedFix;
}
//# sourceMappingURL=output-analyzer.service.d.ts.map