/**
 * Agent Instance — Product Mode orchestrator.
 *
 * Manages the lifecycle of a Product: creating instances (agents),
 * scheduling tasks via DAG, enforcing budget, checkpointing state.
 *
 * Flow:
 *   1. product.create → validate DAG, create instances, start scheduling
 *   2. DAG readyTasks → spawn agent → sendTask → on complete → markCompleted → checkpoint
 *   3. product.pause → pause all, checkpoint
 *   4. product.resume → load state, resume scheduling
 *   5. product.checkpoint → manual checkpoint
 */
import type { AgentProcessManager } from "../runtime/infra/agent-process.js";
import type { AcpDetector } from "../runtime/infra/acp-detector.js";
import type { AgentConfigStore } from "../runtime/infra/agent-config-store.js";
import type { ProductPhase, ProductCreateParams, ProductStatus, ProductSummary } from "../protocol/wire/acp-agent-management.js";
import type { DagMutation } from "./product-planner.js";
import type { ProductLeaderCoordinator } from "./product-run-coordinator.js";
export type { ProductLeaderCoordinator } from "./product-run-coordinator.js";
export interface ProductCallbacks {
    log?: {
        info(msg: string): void;
        warn(msg: string): void;
    };
    onTaskStarted?: (productId: string, taskId: string, assignee: string) => void;
    onTaskCompleted?: (productId: string, taskId: string, result: string) => void;
    onTaskFailed?: (productId: string, taskId: string, error: string) => void;
    onCheckpointed?: (productId: string, timestamp: string) => void;
    onBudgetWarning?: (productId: string, usedTokens: number, maxTotalTokens: number, percentage: number) => void;
    onCompleted?: (productId: string, summary: string, phase: Extract<ProductPhase, "completed" | "failed">) => void;
    /** DAG topology resolved and sent to client for visualization. */
    onDagTopology?: (productId: string, nodes: {
        id: string;
        label: string;
        deps: string[];
    }[], edges: {
        from: string;
        to: string;
    }[]) => void;
    /** Real-time budget consumption update. */
    onBudgetUpdate?: (productId: string, inputTokens: number, outputTokens: number, elapsed: number, maxTotalTokens?: number) => void;
    /** Streaming text output from a running task. */
    onTaskOutputDelta?: (productId: string, taskId: string, text: string) => void;
}
export declare class ProductOrchestrator {
    private processManager;
    private acpDetector;
    private configStore;
    private callbacks;
    private leaderCoordinator?;
    private sessions;
    constructor(processManager: AgentProcessManager, acpDetector: AcpDetector, configStore: AgentConfigStore | null, callbacks?: ProductCallbacks, leaderCoordinator?: ProductLeaderCoordinator | undefined);
    setLeaderCoordinator(leaderCoordinator: ProductLeaderCoordinator): void;
    /**
     * Create a new Product Mode session.
     */
    create(params: ProductCreateParams): Promise<string>;
    /** Resume a product from persisted state. */
    resume(productId: string, cwd?: string): Promise<void>;
    /** Pause a running product. */
    pause(productId: string): Promise<void>;
    /** Manual checkpoint. */
    checkpoint(productId: string): Promise<void>;
    applyDagMutations(productId: string, mutations: readonly DagMutation[]): void;
    /** Delete a product session, pausing first if active. */
    delete(productId: string): Promise<void>;
    /** Rollback a product to a checkpoint: delete running session then resume from disk. */
    rollback(productId: string, _checkpoint: string): Promise<void>;
    /** Get product status. */
    getStatus(productId: string): ProductStatus | null;
    getPersistedStatus(productId: string, cwd?: string): Promise<ProductStatus | null>;
    /** List all products (in-memory + on-disk). */
    list(cwd?: string): Promise<ProductSummary[]>;
    private scheduleNext;
    private isInstanceBusy;
    private dispatchTask;
    private runTask;
    private consultLeaderAfterFailure;
    private applyDagMutationsToSession;
    private finishProduct;
    private emitDagTopology;
    private cleanupInstanceWorktree;
    private buildPersistedState;
}
