/**
 * ParallelOrchestrator — 병렬 에이전트 오케스트레이션 핵심 로직
 *
 * ExecutionPlanner, StateManager, LogStreamer, AgentWorker를 통합하여
 * DAG 기반 병렬 실행을 관리합니다.
 */
import type { Dag, DagNode } from "./dag.js";
import type { RunCapabilityAssignment } from "../contracts/orchestration.js";
import { type ExecutionPlan } from "./execution-planner.js";
import { type OrchestrationEvent, type WorkerState } from "./orchestration-state.js";
import { type LogEntry } from "./log-streamer.js";
import { type NodeCapabilityScopes } from "./capability-routing.js";
import type { TaskRunContext, WorkerManifest } from "../contracts/worker-context.js";
export interface ParallelOrchestratorOptions {
    dag: Dag;
    runId: string;
    goalId?: string;
    objective?: string;
    maxWorkers: number;
    cwd?: string;
    timeout?: number;
    onProgress?: (state: ParallelOrchestrationState) => void;
    onLog?: (entry: LogEntry) => void;
}
export interface ParallelOrchestrationState {
    runId: string;
    status: "initializing" | "running" | "paused" | "completed" | "failed" | "cancelled";
    progress: {
        completed: number;
        total: number;
        percentage: number;
    };
    workers: WorkerState[];
    nodeRuntimes?: Record<string, string>;
    startedAt: string;
    completedAt?: string;
    error?: string;
}
export interface ParallelOrchestrationResult {
    success: boolean;
    state: ParallelOrchestrationState;
    executionPlan: ExecutionPlan;
    events: OrchestrationEvent[];
    error?: string;
}
export interface ParallelWorkerCapabilityContext {
    readonly node: DagNode;
    readonly scopes: NodeCapabilityScopes;
    readonly assignment: RunCapabilityAssignment;
    readonly env: Record<string, string>;
    readonly workerManifest: WorkerManifest;
    readonly runContext: TaskRunContext;
}
export declare function buildParallelWorkerCapabilityContext(node: DagNode, dag?: Dag, options?: {
    readonly runId?: string;
    readonly root?: string;
    readonly goalId?: string;
    readonly objective?: string;
}): ParallelWorkerCapabilityContext;
export declare function buildParallelWorkerEnv(capabilityContext: ParallelWorkerCapabilityContext, providerPolicy?: unknown, capabilities?: unknown): Record<string, string>;
export declare class ParallelOrchestrator {
    private dag;
    private runId;
    private goalId?;
    private objective?;
    private maxWorkers;
    private cwd;
    private timeout;
    private executionPlan;
    private stateManager;
    private logStreamer;
    private activeWorkers;
    private completedNodes;
    private failedNodes;
    private nodeRuntimeMap;
    private onProgress?;
    private onLog?;
    private abortController;
    private runtimeRouter;
    private adaptiveMaxWorkers;
    private consecutiveFailures;
    private lastBatchCompletedAt;
    constructor(options: ParallelOrchestratorOptions);
    /**
     * 오케스트레이션 실행
     */
    execute(): Promise<ParallelOrchestrationResult>;
    /**
     * Non-fatal finalizer: if a run-manifest.json was persisted for this run,
     * link its run -> providerRoute -> provider / evidence / decision / artifact
     * nodes into the local graph. Failures are swallowed so the run is unaffected.
     */
    private linkRunManifestToGraph;
    /**
     * 오케스트레이션 중단
     */
    abort(): Promise<void>;
    /**
     * 초기화
     */
    private initialize;
    /**
     * 메인 실행 루프
     */
    private executeLoop;
    /**
     * 배치 실행
     */
    private executeBatch;
    /**
     * 노드에 대한 CapabilityPlan 생성
     * IntentClassifier + CapabilitySelector를 사용하여 per-node capabilities 결정
     */
    private buildCapabilityPlanForNode;
    /**
     * 노드에 대한 RuntimeSidecar 생성
     * CapabilityPlan을 기반으로 필터링된 런타임 컨텍스트 생성
     */
    private buildSidecarForNode;
    /**
     * 개별 워커 실행
     */
    private executeWorker;
    /**
     * 워커 결과 처리
     */
    private handleWorkerResult;
    /**
     * 워커 실패 처리 (재시도 로직 포함)
     */
    private handleWorkerFailure;
    /**
     * 모든 워커 완료 대기
     */
    private waitForCompletion;
    /**
     * 오케스트레이션 완료 확인
     */
    private isComplete;
    private terminalNodes;
    /**
     * 중단 여부 확인
     */
    private isAborted;
    /**
     * 완료 검증
     */
    private verifyCompletion;
    /**
     * 진행 상황 이벤트 발생
     */
    private emitProgress;
    /**
     * 결과 생성
     */
    private createResult;
    /**
     * 정리
     */
    private cleanup;
    /**
     * Sleep 헬퍼
     */
    private sleep;
}
