import type { TDebugger, TStatusType, TVariableIdentification } from './events.js';
/**
 * Address for accessing a variable in the execution context
 *
 * Variables are stored with key format: `nodeName:portName:executionIndex`
 *
 * @example
 * ```typescript
 * const address: VariableAddress = {
 *   nodeName: 'adder1',
 *   portName: 'result',
 *   executionIndex: 0,
 *   nodeTypeName: 'Add'
 * };
 * const value = await ctx.getVariable(address);
 * // Key used internally: "adder1:result:0"
 * ```
 */
export interface VariableAddress {
    id: string;
    portName: string;
    executionIndex: number;
    nodeTypeName?: string | undefined;
    scope?: string | undefined;
    side?: 'start' | 'exit' | undefined;
}
export interface ExecutionInfo {
    id: string;
    index: number;
    parentIndex?: number | undefined;
    scopeName?: string | undefined;
}
type VariableValue = unknown | (() => unknown) | (() => Promise<unknown>);
/**
 * Runtime execution context for generated workflows
 *
 * Manages variable storage, execution tracking, and pull execution (lazy evaluation).
 * This class is used internally by generated workflow code.
 *
 * Key Features:
 * - Variable storage with execution-scoped addressing
 * - Pull execution support (lazy evaluation)
 * - Debug event emission
 * - Async and sync execution modes
 *
 * @example
 * ```typescript
 * const ctx = new GeneratedExecutionContext(true, debugger);
 * const execIndex = ctx.addExecution('node1');
 * ctx.setVariable({ nodeName: 'node1', portName: 'result', executionIndex: execIndex }, 42);
 * const value = await ctx.getVariable({ nodeName: 'node1', portName: 'result', executionIndex: execIndex });
 * ```
 */
export declare class GeneratedExecutionContext {
    private variables;
    private executions;
    private executionCounter;
    private isAsync;
    private flowWeaverDebugger?;
    private pullExecutors;
    private nodeExecutionIndices;
    private abortSignal?;
    /**
     * Create a new execution context
     * @param isAsync - Whether the workflow runs in async mode (default: true)
     * @param flowWeaverDebugger - Optional debugger for emitting execution events
     * @param abortSignal - Optional AbortSignal for cancellation support
     */
    constructor(isAsync?: boolean, flowWeaverDebugger?: TDebugger, abortSignal?: AbortSignal);
    registerPullExecutor(id: string, executor: () => void | Promise<void>): void;
    addExecution(id: string, parentIndex?: number, scopeName?: string): number;
    setVariable(address: VariableAddress, value: VariableValue): void | Promise<void>;
    getVariable(address: VariableAddress): unknown | Promise<unknown>;
    private retrieveVariable;
    hasVariable(address: VariableAddress): boolean;
    getExecution(id: string, index: number): ExecutionInfo | undefined;
    /**
     * Create an isolated execution scope for container nodes
     *
     * Scopes provide isolated variable storage for nodes like ForEach loops.
     * Child nodes execute within the scope, then variables are merged back.
     *
     * @param _parentNodeName - ID of the container node creating the scope
     * @param _parentIndex - Execution index of the container
     * @param _scopeName - Name of the scope (e.g., 'iteration')
     * @param cleanScope - If true, create fresh scope without parent variables (per-port scopes). If false, inherit parent variables (node-level scopes).
     * @returns New ExecutionContext for the scoped execution
     *
     * @example
     * ```typescript
     * // Per-port scope (clean=true): isolated variables
     * const scopedCtx = ctx.createScope('forEach1', 0, 'iteration', true);
     *
     * // Node-level scope (clean=false): inherited variables
     * const scopedCtx = ctx.createScope('container1', 0, 'block', false);
     * ```
     */
    createScope(_parentNodeName: string, _parentIndex: number, _scopeName: string, cleanScope?: boolean): GeneratedExecutionContext;
    /**
     * Merge a scoped execution context back into the parent context
     *
     * Copies all variables and execution info from the scoped context to this context.
     * Updates the execution counter to maintain unique execution indices.
     *
     * @param scopedContext - The scoped context to merge
     */
    mergeScope(scopedContext: GeneratedExecutionContext): void;
    private getVariableKey;
    private getExecutionKey;
    getExecutionCount(): number;
    reset(): void;
    /**
     * Check if the workflow has been aborted
     */
    isAborted(): boolean;
    /**
     * Throw CancellationError if the workflow has been aborted
     * @param nodeId - Optional node ID to include in the error
     */
    checkAborted(nodeId?: string): void;
    sendStatusChangedEvent(args: {
        nodeTypeName: string;
        id: string;
        scope?: string;
        side?: 'start' | 'exit';
        executionIndex: number;
        status: TStatusType;
    }): void;
    sendVariableSetEvent(args: {
        identifier: TVariableIdentification;
        value: unknown;
    }): void;
    sendLogErrorEvent(args: {
        nodeTypeName: string;
        id: string;
        scope?: string;
        side?: 'start' | 'exit';
        executionIndex: number;
        error: string;
    }): void;
    sendWorkflowCompletedEvent(args: {
        executionIndex: number;
        status: 'SUCCEEDED' | 'FAILED' | 'CANCELLED';
        result?: unknown;
    }): void;
}
export {};
//# sourceMappingURL=ExecutionContext.d.ts.map