/**
 * @fileoverview Orchestrator Loop — phased plan execution with team agents.
 *
 * State machine that generates plans from user goals, executes them
 * phase-by-phase with verification gates, and adapts on failure.
 *
 * States: idle → planning → approval → executing → verifying → (replanning) → completed/failed
 *
 * Key exports:
 * - `OrchestratorLoop` class — main engine, extends EventEmitter
 * - `OrchestratorLoopEvents` interface — typed event map
 *
 * Lifecycle: `start(goal)` → plan → approve → execute phases → verify → complete
 *
 * @dependencies orchestrator-planner (plan generation), orchestrator-verifier (phase verification),
 *   session-manager (sessions), task-queue (task execution), state-store (persistence),
 *   prompts/orchestrator (prompt templates)
 * @consumedby web/server (orchestrator routes, SSE)
 * @emits stateChanged, planReady, phaseStarted, phaseCompleted, phaseFailed,
 *   taskAssigned, taskCompleted, taskFailed, verificationResult, completed, error
 * @persistence Orchestrator state saved to `~/.codeman/state.json` (orchestrator key)
 *
 * @module orchestrator-loop
 */
import { EventEmitter } from 'node:events';
import type { TerminalMultiplexer } from './mux-interface.js';
import { type OrchestratorState, type OrchestratorPlan, type OrchestratorPhase, type OrchestratorConfig, type OrchestratorStats, type OrchestratorPersistState } from './types.js';
export declare class OrchestratorLoop extends EventEmitter {
    private _state;
    private plan;
    private currentPhaseIndex;
    private config;
    private stats;
    private startedAt;
    private completedAt;
    private workingDir;
    private planner;
    private verifier;
    private sessionManager;
    private taskQueue;
    private store;
    /** State before pause (to resume to correct state) */
    private pausedState;
    /** Phase poll timer for checking task completion */
    private phasePollTimer;
    /** Phase-level timeout timer */
    private phaseTimeoutTimer;
    /** Post-phase delay timer before verification */
    private postPhaseTimer;
    /** Session completion listener (bound for cleanup) */
    private sessionCompletionListener;
    /** Active sessions assigned to current phase */
    private phaseSessionIds;
    constructor(mux: TerminalMultiplexer, workingDir: string, config?: Partial<OrchestratorConfig>);
    /** Start orchestration with a goal. Transitions: idle → planning */
    start(goal: string): Promise<void>;
    /** Approve the generated plan. Transitions: approval → executing */
    approve(): Promise<void>;
    /** Reject plan with feedback. Transitions: approval → planning (regenerate) */
    reject(feedback: string): Promise<void>;
    /** Pause execution. Saves current state. */
    pause(): void;
    /** Resume from pause. */
    resume(): Promise<void>;
    /** Stop everything and clean up. */
    stop(): Promise<void>;
    /** Skip a specific phase. */
    skipPhase(phaseId: string): Promise<void>;
    /** Retry a failed phase. */
    retryPhase(phaseId: string): Promise<void>;
    get state(): OrchestratorState;
    getPlan(): OrchestratorPlan | null;
    getCurrentPhase(): OrchestratorPhase | null;
    getStats(): OrchestratorStats;
    getStatus(): OrchestratorPersistState;
    isRunning(): boolean;
    private executeCurrentPhase;
    private assignPhaseTasks;
    private assignTeamPhase;
    private assignQueuedTasksToSessions;
    private setupTaskHandlers;
    private cleanupTaskHandlers;
    private _finalizeTask;
    private handleTaskCompleted;
    private handleTaskFailed;
    private startPhasePoll;
    private _clearTimer;
    private clearPhasePoll;
    private pollPhaseStatus;
    private checkPhaseCompletion;
    private verifyCurrentPhase;
    private handleVerificationFailure;
    private replanPhase;
    /** Read current state (bypasses TypeScript narrowing from guards) */
    private currentState;
    /** Assert state matches expected or throw */
    private requireState;
    private setState;
    private advanceToNextPhase;
    private handleCompletion;
    private handlePhaseError;
    private handleError;
    private persist;
    private restore;
    private reset;
    private buildTaskPrompt;
    private getCompletedPhasesSummary;
    private findOrchestratorTaskByQueueId;
    /** Clean up resources when the loop is being destroyed. */
    destroy(): void;
}
//# sourceMappingURL=orchestrator-loop.d.ts.map