/**
 * DebugController intercepts workflow execution at node boundaries,
 * enabling step-through debugging and checkpoint/resume.
 *
 * Injected via globalThis.__fw_debug_controller__ (same pattern as
 * __fw_debugger__ and __fw_agent_channel__). The generated code calls
 * beforeNode/afterNode at each node boundary; the controller decides
 * whether to skip, pause, checkpoint, or continue.
 */
import type { GeneratedExecutionContext } from './ExecutionContext.js';
import type { CheckpointWriter } from './checkpoint.js';
export type DebugMode = 'step' | 'continue' | 'continueToBreakpoint' | 'run';
export interface DebugPauseState {
    /** Node we're paused at */
    currentNodeId: string;
    /** Whether we paused before or after the node executed */
    phase: 'before' | 'after';
    /** Nodes that have finished executing */
    completedNodes: string[];
    /** Full topological execution order */
    executionOrder: string[];
    /** Current index in executionOrder */
    position: number;
    /** All variable values, keyed by "nodeId:portName" */
    variables: Record<string, unknown>;
    /** Outputs of the most recently completed node (convenience shortcut) */
    currentNodeOutputs?: Record<string, unknown>;
    /** Active breakpoints */
    breakpoints: string[];
}
export type DebugResumeAction = {
    type: 'step';
} | {
    type: 'continue';
} | {
    type: 'continueToBreakpoint';
} | {
    type: 'abort';
};
/**
 * Minimal interface for the debug controller as referenced by generated code.
 * The full DebugController class implements this, but generated code only
 * needs beforeNode/afterNode — so this type is what gets imported.
 */
export type TDebugController = {
    beforeNode(nodeId: string, ctx: GeneratedExecutionContext): Promise<boolean> | boolean;
    afterNode(nodeId: string, ctx: GeneratedExecutionContext): Promise<void> | void;
};
export interface DebugControllerConfig {
    /** Enable step-through debugging (pauses before first node) */
    debug?: boolean;
    /** Enable checkpointing to disk after each node */
    checkpoint?: boolean;
    /** Checkpoint writer instance (required when checkpoint=true) */
    checkpointWriter?: CheckpointWriter;
    /** Initial breakpoint node IDs */
    breakpoints?: string[];
    /** Execution order (set by executor after compilation) */
    executionOrder?: string[];
    /** Nodes to skip on resume (loaded from checkpoint) */
    skipNodes?: Map<string, Record<string, unknown>>;
}
export declare class DebugController {
    private mode;
    private breakpoints;
    private completedNodes;
    private completedSet;
    private executionOrder;
    private position;
    private lastCompletedNodeId;
    private checkpointEnabled;
    private checkpointWriter;
    private skipNodes;
    private _gateResolve;
    private _pauseResolve;
    private _pausePromise;
    private pendingModifications;
    constructor(config?: DebugControllerConfig);
    /** Set the execution order (called by executor after compilation) */
    setExecutionOrder(order: string[]): void;
    /**
     * Called before a node executes.
     * Returns true if the node should execute, false to skip.
     */
    beforeNode(nodeId: string, ctx: GeneratedExecutionContext): Promise<boolean>;
    /**
     * Called after a node completes successfully.
     */
    afterNode(nodeId: string, ctx: GeneratedExecutionContext): Promise<void>;
    /**
     * Awaited by the executor to detect when the controller pauses.
     * Resolves with the current debug state.
     */
    onPause(): Promise<DebugPauseState>;
    /**
     * Called by MCP tools or CLI to resume execution.
     */
    resume(action: DebugResumeAction): void;
    /**
     * Queue a variable modification. Applied before the next node runs.
     * Key format: "nodeId:portName:executionIndex"
     */
    setVariable(key: string, value: unknown): void;
    addBreakpoint(nodeId: string): void;
    removeBreakpoint(nodeId: string): void;
    getBreakpoints(): string[];
    /** Build the current debug state for external consumers */
    buildState(nodeId: string, phase: 'before' | 'after', ctx: GeneratedExecutionContext): DebugPauseState;
    /** Get completed nodes list */
    getCompletedNodes(): string[];
    private pause;
    private applyAction;
    private applyPendingModifications;
    private restoreNodeOutputs;
    private extractVariables;
    private extractNodeOutputs;
    private _createPausePromise;
}
//# sourceMappingURL=debug-controller.d.ts.map