/**
 * Continuation Service
 *
 * Main orchestrator for continuation detection, analysis, and action execution.
 * Ties together event detection, output analysis, and response actions.
 *
 * @module services/continuation/continuation.service
 */
import { ContinuationEvent, ContinuationAction, AgentStateAnalysis, ContinuationActionResult, IContinuationService, IterationTracking } from '../../types/continuation.types.js';
/**
 * Configuration for a session's continuation behavior
 */
export interface ContinuationConfig {
    /** Maximum iterations allowed before stopping */
    maxIterations: number;
    /** Whether continuation is enabled */
    enabled: boolean;
    /** Whether to auto-assign next task on completion */
    autoAssignNext: boolean;
    /** Whether to notify owner when max iterations reached */
    notifyOnMaxIterations: boolean;
    /** Whether to notify owner on errors */
    notifyOnError: boolean;
}
/**
 * Status of a session's continuation state
 */
export interface SessionContinuationStatus {
    /** Session name */
    sessionName: string;
    /** Whether the session is being monitored */
    isMonitored: boolean;
    /** Current iteration count */
    currentIteration: number;
    /** Maximum iterations allowed */
    maxIterations: number;
    /** Last analysis result */
    lastAnalysis?: AgentStateAnalysis;
    /** Last action taken */
    lastAction?: ContinuationAction;
    /** ISO timestamp of last action */
    lastActionTime?: string;
}
/**
 * Notification stored for dashboard display
 */
export interface ContinuationNotification {
    /** Notification type */
    type: 'continuation';
    /** Session that triggered the notification */
    sessionName: string;
    /** Reason for the notification */
    reason: string;
    /** Analysis that led to notification */
    analysis: AgentStateAnalysis;
    /** ISO timestamp */
    timestamp: string;
    /** Whether the notification has been acknowledged */
    acknowledged: boolean;
}
/**
 * Service that orchestrates continuation detection and response
 *
 * Features:
 * - Subscribes to continuation events
 * - Analyzes agent output to determine state
 * - Executes appropriate actions (prompt injection, task assignment, etc.)
 * - Tracks iteration counts and session status
 * - Stores notifications for dashboard
 *
 * @example
 * ```typescript
 * const service = ContinuationService.getInstance();
 * await service.start();
 *
 * // Service now handles continuation events automatically
 *
 * // Check session status
 * const status = await service.getSessionStatus('team-dev');
 * console.log(`Iteration ${status.currentIteration} of ${status.maxIterations}`);
 * ```
 */
export declare class ContinuationService implements IContinuationService {
    private static instance;
    private readonly logger;
    private readonly eventEmitter;
    private readonly outputAnalyzer;
    private readonly sessionConfigs;
    private readonly sessionStatus;
    private readonly iterationTracking;
    private readonly notifications;
    private isRunning;
    private eventHandler;
    /**
     * Creates a new ContinuationService
     */
    private constructor();
    /**
     * Gets the singleton instance
     *
     * @returns The ContinuationService instance
     */
    static getInstance(): ContinuationService;
    /**
     * Clears the singleton instance (for testing)
     */
    static clearInstance(): void;
    /**
     * Start the continuation service
     *
     * Subscribes to continuation events and begins monitoring.
     */
    start(): Promise<void>;
    /**
     * Stop the continuation service
     *
     * Unsubscribes from events and cleans up.
     */
    stop(): Promise<void>;
    /**
     * Handle a continuation event
     *
     * @param event - The continuation event
     * @returns Action result
     */
    handleEvent(event: ContinuationEvent): Promise<ContinuationActionResult>;
    /**
     * Get iteration tracking for a session
     *
     * @param sessionName - Session name
     * @returns Iteration tracking data or null
     */
    getIterationTracking(sessionName: string): Promise<IterationTracking | null>;
    /**
     * Reset iteration count for a session
     *
     * @param sessionName - Session name
     */
    resetIterations(sessionName: string): Promise<void>;
    /**
     * Execute a continuation action
     *
     * @param sessionName - Session to act on
     * @param analysis - Analysis result
     * @param config - Session configuration
     * @param context - Additional context
     * @returns Action result
     */
    private executeAction;
    /**
     * Inject a continuation prompt into the session
     *
     * @param sessionName - Session to inject into
     * @param analysis - Analysis result
     * @param context - Additional context
     */
    private injectContinuationPrompt;
    /**
     * Assign the next task to the session
     *
     * @param sessionName - Session to assign to
     */
    private assignNextTask;
    /**
     * Notify the owner about the session state
     *
     * @param sessionName - Session that needs attention
     * @param reason - Reason for notification
     * @param analysis - Analysis result
     */
    private notifyOwner;
    /**
     * Retry with error hints
     *
     * @param sessionName - Session to retry
     * @param analysis - Analysis result with error info
     * @param context - Additional context
     */
    private retryWithHints;
    /**
     * Pause the agent session
     *
     * @param sessionName - Session to pause
     */
    private pauseAgent;
    /**
     * Build a continuation prompt based on analysis
     *
     * @param analysis - Analysis result
     * @returns Continuation prompt string
     */
    private buildContinuationPrompt;
    /**
     * Build a retry prompt with error hints
     *
     * @param analysis - Analysis result with error info
     * @returns Retry prompt string
     */
    private buildRetryPrompt;
    /**
     * Get hints based on the conclusion
     *
     * @param conclusion - Agent conclusion
     * @returns Hint string
     */
    private getHintsForConclusion;
    /**
     * Get or create iteration tracking for a session
     *
     * @param sessionName - Session name
     * @param agentId - Agent ID
     * @returns Iteration tracking
     */
    private getOrCreateIterationTracking;
    /**
     * Record an iteration in the history
     *
     * @param sessionName - Session name
     * @param trigger - What triggered this iteration
     * @param analysis - Analysis result
     * @param action - Action taken
     */
    private recordIteration;
    /**
     * Update session status with latest analysis
     *
     * @param sessionName - Session name
     * @param analysis - Analysis result
     */
    private updateSessionStatus;
    /**
     * Set maximum iterations for a session
     *
     * @param sessionName - Session name
     * @param max - Maximum iterations
     */
    setMaxIterations(sessionName: string, max: number): Promise<void>;
    /**
     * Get configuration for a session
     *
     * @param sessionName - Session name
     * @returns Session configuration
     */
    getSessionConfig(sessionName: string): Promise<ContinuationConfig>;
    /**
     * Get active monitors
     *
     * @returns List of session names being monitored
     */
    getActiveMonitors(): string[];
    /**
     * Get status for a session
     *
     * @param sessionName - Session name
     * @returns Session status or null
     */
    getSessionStatus(sessionName: string): Promise<SessionContinuationStatus | null>;
    /**
     * Get all notifications
     *
     * @param unacknowledgedOnly - Only return unacknowledged notifications
     * @returns List of notifications
     */
    getNotifications(unacknowledgedOnly?: boolean): ContinuationNotification[];
    /**
     * Acknowledge a notification
     *
     * @param timestamp - Notification timestamp to acknowledge
     */
    acknowledgeNotification(timestamp: string): void;
    /**
     * Check if service is running
     *
     * @returns True if running
     */
    isServiceRunning(): boolean;
}
//# sourceMappingURL=continuation.service.d.ts.map