import type { RuntimeBridge, BridgeConfig, ExecuteOptions } from '../types';
/**
 * IsolatedVmBridge - Runtime bridge using isolated-vm for secure expression evaluation.
 *
 * This bridge creates a V8 isolate with:
 * - Hard memory limit (128MB default)
 * - No access to Node.js APIs
 * - Timeout enforcement
 * - Complete isolation from host process
 *
 * Context reuse pattern: Create isolate/context once, reset state between evaluations.
 */
export declare class IsolatedVmBridge implements RuntimeBridge {
    private isolate;
    private context?;
    private initialized;
    private disposed;
    private config;
    private scriptCache;
    private valueAtPathRef?;
    private arrayElementRef?;
    private callFunctionRef?;
    private resetDataProxiesRef?;
    constructor(config?: BridgeConfig);
    /**
     * Initialize the isolate and create execution context.
     *
     * Steps:
     * 1. Create context
     * 2. Set up basic globals (global reference)
     * 3. Load runtime bundle (DateTime, extend, proxy system)
     * 4. Verify proxy system
     *
     * Must be called before execute().
     */
    initialize(): Promise<void>;
    /**
     * Load runtime bundle into the isolate.
     *
     * The runtime bundle includes:
     * - DateTime, extend, extendOptional (expression engine globals)
     * - SafeObject and SafeError wrappers
     * - createDeepLazyProxy function
     * - __data object initialization
     *
     * @private
     * @throws {Error} If context not initialized or bundle loading fails
     */
    private loadVendorLibraries;
    /**
     * Verify the proxy system loaded correctly.
     *
     * The proxy system is loaded as part of the runtime bundle in loadVendorLibraries().
     * This method verifies all required components are available.
     *
     * @private
     * @throws {Error} If context not initialized or proxy system verification fails
     */
    private verifyProxySystem;
    /**
     * Inject the E() error handler into the isolate context.
     *
     * Tournament wraps expressions with try-catch that calls E(error, this).
     * This handler:
     * - Re-throws security violations from __sanitize
     * - Swallows TypeErrors (failed attack attempts return undefined)
     * - Re-throws all other errors
     *
     * @private
     * @throws {Error} If context not initialized
     */
    private injectErrorHandler;
    /**
     * Reset data proxies in the isolate context.
     *
     * This method should be called before each execute() to:
     * 1. Clear proxy caches from previous evaluations
     * 2. Initialize fresh workflow data references
     * 3. Expose workflow properties to globalThis
     *
     * The reset function runs in the isolate and calls back to the host
     * via ivm.Reference callbacks to fetch workflow data.
     *
     * @private
     * @throws {Error} If context not initialized or reset fails
     */
    private resetDataProxies;
    /**
     * Register callback functions for cross-isolate communication.
     *
     * Creates three ivm.Reference callbacks that the runtime bundle uses
     * to fetch data from the host process:
     *
     * - __getValueAtPath: Returns metadata or primitive for a property path
     * - __getArrayElement: Returns individual array elements
     * - __callFunctionAtPath: Executes functions in host context
     *
     * These callbacks are called synchronously from isolate proxy traps.
     *
     * @param data - Current workflow data to use for callback responses
     * @private
     */
    private registerCallbacks;
    /**
     * Execute JavaScript code in the isolated context.
     *
     * Flow:
     * 1. Register callbacks as ivm.Reference for cross-isolate communication
     * 2. Call resetDataProxies() to initialize workflow data proxies
     * 3. Compile script (with caching for performance)
     * 4. Execute with timeout enforcement
     * 5. Return result (copied from isolate)
     *
     * @param code - JavaScript expression to evaluate
     * @param data - Workflow data (e.g., { $json: {...}, $runIndex: 0 })
     * @returns Result of the expression
     * @throws {Error} If bridge not initialized or execution fails
     */
    execute(code: string, data: Record<string, unknown>, options?: ExecuteOptions): unknown;
    /**
     * Dispose of the isolate and free resources.
     *
     * After disposal, the bridge cannot be used again.
     */
    dispose(): Promise<void>;
    /**
     * Check if the bridge has been disposed.
     *
     * @returns true if disposed, false otherwise
     */
    isDisposed(): boolean;
}
//# sourceMappingURL=isolated-vm-bridge.d.ts.map