Sandbox executor interface - must be implemented by platform-specific sandboxes

interface SandboxExecutor {
    destroy(): void;
    execute(code: string, context: Record<string, any>, timeout: number): Promise<node.common.apis.cortex.SandboxResult<any>>;
    initializePersistent(): Promise<void>;
    reset(): Promise<void>;
    setupEventStream?(handler: ((event: node.common.apis.cortex.SandboxRuntimeEvent) => void)): (() => void);
}

Implemented by

Methods

  • Destroy sandbox completely

    Returns void

  • Execute JavaScript code in isolated environment

    Parameters

    • code: string

      JavaScript code to execute

    • context: Record<string, any>

      Variables and functions to inject

    • timeout: number

      Execution timeout in milliseconds

    Returns Promise<node.common.apis.cortex.SandboxResult<any>>

    Promise with execution result

  • Initialize persistent sandbox environment

    Returns Promise<void>

  • Reset sandbox environment, clearing all state

    Returns Promise<void>

  • Setup real-time event stream listener (optional) Only implemented by sandboxes that support real-time streaming (e.g., IframeSandbox) NodeSandbox uses synchronous execution and doesn't implement this.

    Parameters

    Returns (() => void)

    Cleanup function to remove the listener

      • (): void
      • Returns void