@ricsam/isolate-runtime 0.1.16 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -670,29 +670,36 @@ function createLocalCustomFunctionsMarshalOptions() {
670
670
  }
671
671
  function createModuleResolver(state) {
672
672
  return async (specifier, referrer) => {
673
- const staticCached = state.staticModuleCache.get(specifier);
673
+ const importerPath = state.moduleToFilename.get(referrer) ?? "<unknown>";
674
+ const importerResolveDir = import_node_path.default.posix.dirname(importerPath);
675
+ const importerStack = state.moduleImportChain.get(importerPath) ?? [];
676
+ const resolvedSpecifier = specifier.startsWith(".") ? import_node_path.default.posix.normalize(import_node_path.default.posix.join(importerResolveDir, specifier)) : specifier;
677
+ state.specifierToImporter.set(resolvedSpecifier, importerPath);
678
+ const staticCached = state.staticModuleCache.get(resolvedSpecifier);
674
679
  if (staticCached)
675
680
  return staticCached;
676
- const cached = state.moduleCache.get(specifier);
681
+ const cached = state.moduleCache.get(resolvedSpecifier);
677
682
  if (cached)
678
683
  return cached;
679
684
  if (!state.moduleLoader) {
680
685
  throw new Error(`No module loader registered. Cannot import: ${specifier}`);
681
686
  }
682
- const importerPath = state.moduleToFilename.get(referrer) ?? "<unknown>";
683
- const importerResolveDir = import_node_path.default.posix.dirname(importerPath);
684
687
  const result = await state.moduleLoader(specifier, {
685
688
  path: importerPath,
686
689
  resolveDir: importerResolveDir
687
690
  });
688
691
  const { code, resolveDir } = result;
692
+ if (result.filename.includes("/")) {
693
+ throw new Error(`moduleLoader returned a filename with slashes: "${result.filename}". ` + `filename must be a basename (e.g. "utils.js"), not a path.`);
694
+ }
695
+ const resolvedFilename = import_node_path.default.posix.join(resolveDir, result.filename);
689
696
  const hash = import_isolate_transform.contentHash(code);
690
- const cacheKey = `${specifier}:${hash}`;
697
+ const cacheKey = `${resolvedSpecifier}:${hash}`;
691
698
  const inFlightKey = `${result.static ? "static" : "dynamic"}:${cacheKey}`;
692
- const staticCachedAfterLoad = state.staticModuleCache.get(specifier);
699
+ const staticCachedAfterLoad = state.staticModuleCache.get(resolvedSpecifier);
693
700
  if (staticCachedAfterLoad)
694
701
  return staticCachedAfterLoad;
695
- const cachedAfterLoad = state.moduleCache.get(specifier);
702
+ const cachedAfterLoad = state.moduleCache.get(resolvedSpecifier);
696
703
  if (cachedAfterLoad)
697
704
  return cachedAfterLoad;
698
705
  const hashCached = state.moduleCache.get(cacheKey);
@@ -706,41 +713,51 @@ function createModuleResolver(state) {
706
713
  try {
707
714
  let transformed = state.transformCache.get(hash);
708
715
  if (!transformed) {
709
- transformed = await import_isolate_transform.transformModuleCode(code, specifier);
716
+ transformed = await import_isolate_transform.transformModuleCode(code, resolvedSpecifier);
710
717
  state.transformCache.set(hash, transformed);
711
718
  }
712
719
  if (transformed.sourceMap) {
713
- state.sourceMaps.set(specifier, transformed.sourceMap);
720
+ state.sourceMaps.set(resolvedSpecifier, transformed.sourceMap);
714
721
  }
715
722
  mod = await state.isolate.compileModule(transformed.code, {
716
- filename: specifier
723
+ filename: resolvedSpecifier
717
724
  });
718
- const resolvedPath = import_node_path.default.posix.join(resolveDir, import_node_path.default.posix.basename(specifier));
719
- state.moduleToFilename.set(mod, resolvedPath);
725
+ state.moduleToFilename.set(mod, resolvedFilename);
726
+ state.moduleImportChain.set(resolvedFilename, [...importerStack, importerPath]);
720
727
  if (result.static) {
721
- state.staticModuleCache.set(specifier, mod);
728
+ state.staticModuleCache.set(resolvedSpecifier, mod);
722
729
  } else {
723
- state.moduleCache.set(specifier, mod);
730
+ state.moduleCache.set(resolvedSpecifier, mod);
724
731
  state.moduleCache.set(cacheKey, mod);
725
732
  }
726
733
  return mod;
727
734
  } catch (err) {
735
+ const error = err instanceof Error ? err : new Error(String(err));
736
+ error.message = `Failed to compile module "${resolvedSpecifier}" (imported by "${importerPath}"):
737
+ ${error.message}`;
738
+ if (importerStack.length > 0) {
739
+ error.message += `
740
+
741
+ Import chain:
742
+ ${[...importerStack, importerPath].join(`
743
+ -> `)}`;
744
+ }
728
745
  if (mod) {
729
746
  state.moduleToFilename.delete(mod);
730
747
  if (result.static) {
731
- if (state.staticModuleCache.get(specifier) === mod) {
732
- state.staticModuleCache.delete(specifier);
748
+ if (state.staticModuleCache.get(resolvedSpecifier) === mod) {
749
+ state.staticModuleCache.delete(resolvedSpecifier);
733
750
  }
734
751
  } else {
735
- if (state.moduleCache.get(specifier) === mod) {
736
- state.moduleCache.delete(specifier);
752
+ if (state.moduleCache.get(resolvedSpecifier) === mod) {
753
+ state.moduleCache.delete(resolvedSpecifier);
737
754
  }
738
755
  if (state.moduleCache.get(cacheKey) === mod) {
739
756
  state.moduleCache.delete(cacheKey);
740
757
  }
741
758
  }
742
759
  }
743
- throw err;
760
+ throw error;
744
761
  }
745
762
  })();
746
763
  state.moduleLoadsInFlight.set(inFlightKey, loadPromise);
@@ -778,6 +795,8 @@ async function createRuntime(options) {
778
795
  transformCache: new Map,
779
796
  moduleToFilename: new Map,
780
797
  sourceMaps: new Map,
798
+ moduleImportChain: new Map,
799
+ specifierToImporter: new Map,
781
800
  pendingCallbacks: [],
782
801
  evalChain: Promise.resolve(),
783
802
  moduleLoader: opts.moduleLoader,
@@ -1023,8 +1042,53 @@ async function createRuntime(options) {
1023
1042
  filename
1024
1043
  });
1025
1044
  state.moduleToFilename.set(mod, filename);
1045
+ state.moduleImportChain.set(filename, []);
1026
1046
  const resolver = createModuleResolver(state);
1027
- await mod.instantiate(state.context, resolver);
1047
+ try {
1048
+ await mod.instantiate(state.context, resolver);
1049
+ } catch (err) {
1050
+ const error = err instanceof Error ? err : new Error(String(err));
1051
+ const specifierMatch = error.message.match(/The requested module '([^']+)'/);
1052
+ const exportMatch = error.message.match(/export named '([^']+)'/);
1053
+ const failingSpecifier = specifierMatch?.[1];
1054
+ const failingExport = exportMatch?.[1];
1055
+ const importerFile = failingSpecifier ? state.specifierToImporter.get(failingSpecifier) : undefined;
1056
+ const details = [];
1057
+ if (importerFile) {
1058
+ const chain = state.moduleImportChain.get(importerFile) ?? [];
1059
+ const fullChain = [...chain, importerFile];
1060
+ if (failingSpecifier)
1061
+ fullChain.push(failingSpecifier);
1062
+ const trimmed = fullChain.length > 12 ? fullChain.slice(-12) : fullChain;
1063
+ const prefix = fullChain.length > 12 ? ` ...
1064
+ ` : "";
1065
+ details.push(`Import chain:
1066
+ ` + prefix + trimmed.map((p) => ` ${p}`).join(`
1067
+ -> `));
1068
+ } else if (failingSpecifier) {
1069
+ for (const [modPath, chain] of state.moduleImportChain) {
1070
+ if (modPath.includes(failingSpecifier) || modPath.endsWith(failingSpecifier)) {
1071
+ const fullChain = [...chain, modPath];
1072
+ const trimmed = fullChain.length > 12 ? fullChain.slice(-12) : fullChain;
1073
+ details.push(`Import chain:
1074
+ ` + trimmed.map((p) => ` ${p}`).join(`
1075
+ -> `));
1076
+ break;
1077
+ }
1078
+ }
1079
+ }
1080
+ if (failingExport && failingSpecifier) {
1081
+ details.push(`Hint: If '${failingExport}' is a TypeScript type/interface, use \`import type\` to prevent it from being resolved at runtime:
1082
+ ` + ` import type { ${failingExport} } from '${failingSpecifier}';`);
1083
+ }
1084
+ const suffix = details.length > 0 ? `
1085
+
1086
+ ` + details.join(`
1087
+
1088
+ `) : "";
1089
+ error.message = `Module instantiation failed: ${error.message}${suffix}`;
1090
+ throw error;
1091
+ }
1028
1092
  await mod.evaluate();
1029
1093
  const ns = mod.namespace;
1030
1094
  const runRef = await ns.get("default", { reference: true });
@@ -1059,6 +1123,8 @@ async function createRuntime(options) {
1059
1123
  state.moduleCache.clear();
1060
1124
  state.moduleLoadsInFlight.clear();
1061
1125
  state.moduleToFilename.clear();
1126
+ state.moduleImportChain.clear();
1127
+ state.specifierToImporter.clear();
1062
1128
  state.sourceMaps.clear();
1063
1129
  },
1064
1130
  async dispose() {
@@ -1083,4 +1149,4 @@ async function createRuntime(options) {
1083
1149
  };
1084
1150
  }
1085
1151
 
1086
- //# debugId=9159E7F9BC462BBB64756E2164756E21
1152
+ //# debugId=AFA261ED8389256764756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": [
5
- "import ivm from \"isolated-vm\";\nimport path from \"node:path\";\nimport { setupCore } from \"@ricsam/isolate-core\";\nimport { normalizeEntryFilename } from \"@ricsam/isolate-protocol\";\nimport {\n transformEntryCode,\n transformModuleCode,\n contentHash,\n mapErrorStack,\n type SourceMap,\n type TransformResult,\n} from \"@ricsam/isolate-transform\";\n\n// Re-export for convenience\nexport { normalizeEntryFilename } from \"@ricsam/isolate-protocol\";\nimport { setupConsole } from \"@ricsam/isolate-console\";\nimport { setupEncoding } from \"@ricsam/isolate-encoding\";\nimport { setupTimers } from \"@ricsam/isolate-timers\";\nimport { setupPath } from \"@ricsam/isolate-path\";\nimport { setupCrypto } from \"@ricsam/isolate-crypto\";\nimport { setupFetch } from \"@ricsam/isolate-fetch\";\nimport { setupFs } from \"@ricsam/isolate-fs\";\nimport {\n setupTestEnvironment,\n runTests as runTestsInContext,\n hasTests as hasTestsInContext,\n getTestCount as getTestCountInContext,\n} from \"@ricsam/isolate-test-environment\";\nimport {\n setupPlaywright,\n type PlaywrightCallback,\n type PlaywrightSetupOptions,\n} from \"@ricsam/isolate-playwright\";\n\nimport type { ConsoleOptions, ConsoleHandle } from \"@ricsam/isolate-console\";\nimport type {\n FetchOptions,\n FetchHandle,\n DispatchRequestOptions,\n UpgradeRequest,\n WebSocketCommand,\n ClientWebSocketCommand,\n} from \"@ricsam/isolate-fetch\";\nimport type { FsOptions, FsHandle } from \"@ricsam/isolate-fs\";\nimport type { CoreHandle } from \"@ricsam/isolate-core\";\nimport type { EncodingHandle } from \"@ricsam/isolate-encoding\";\nimport type { TimersHandle } from \"@ricsam/isolate-timers\";\nimport type { PathHandle } from \"@ricsam/isolate-path\";\nimport type { CryptoHandle } from \"@ricsam/isolate-crypto\";\nimport type {\n TestEnvironmentHandle,\n RunResults,\n TestEnvironmentOptions,\n TestEvent,\n SuiteInfo,\n SuiteResult,\n TestInfo,\n TestResult,\n TestError,\n} from \"@ricsam/isolate-test-environment\";\nimport type {\n PlaywrightHandle,\n NetworkRequestInfo,\n NetworkResponseInfo,\n BrowserConsoleLogEntry,\n PlaywrightEvent,\n} from \"@ricsam/isolate-playwright\";\nimport type {\n ConsoleCallbacks,\n ConsoleEntry,\n FetchCallback,\n FetchRequestInit,\n ModuleLoaderCallback,\n CustomFunctionDefinition,\n CustomFunctions,\n CustomAsyncGeneratorFunction,\n DispatchOptions,\n EvalOptions as ProtocolEvalOptions,\n PlaywrightOptions as ProtocolPlaywrightOptions,\n BaseRuntimeOptions,\n} from \"@ricsam/isolate-protocol\";\nimport {\n marshalValue,\n unmarshalValue,\n type MarshalContext,\n} from \"@ricsam/isolate-protocol\";\n\n// Re-export shared types from protocol\nexport type {\n ConsoleCallbacks,\n ConsoleEntry,\n FetchCallback,\n FetchRequestInit,\n ModuleLoaderCallback,\n CustomFunction,\n CustomFunctionDefinition,\n CustomFunctions,\n DispatchOptions,\n} from \"@ricsam/isolate-protocol\";\n\n// Re-export shared protocol option types\nexport type EvalOptions = ProtocolEvalOptions;\nexport type PlaywrightOptions = ProtocolPlaywrightOptions;\n\n/**\n * Options for customizing how custom function return values are marshalled.\n * Used by the daemon to support returned callbacks/promises/iterators via IPC.\n */\nexport interface CustomFunctionsMarshalOptions {\n /** Factory to create a MarshalContext for registering returned callbacks/promises/iterators */\n createMarshalContext: () => MarshalContext;\n /** Post-processor to add callback IDs to PromiseRef/AsyncIteratorRef values */\n addCallbackIdsToRefs: (value: unknown) => unknown;\n /** Handler for numeric callback IDs from marshalled refs (CallbackRef, PromiseRef, AsyncIteratorRef) */\n invokeCallback: (callbackId: number, args: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Options for creating a runtime.\n * Extends BaseRuntimeOptions and adds runtime-specific fs type.\n */\nexport interface RuntimeOptions<T extends Record<string, any[]> = Record<string, unknown[]>>\n extends BaseRuntimeOptions<T> {\n /**\n * File system options.\n * Note: For local runtime, this uses FsOptions with getDirectory returning a FileSystemHandler.\n * For remote runtime (isolate-client), use FileSystemCallbacks instead.\n */\n fs?: FsOptions;\n /**\n * Optional marshal options for custom functions.\n * When provided, enables MarshalContext-based marshalling for returned values.\n * Used by the daemon for IPC proxying of callbacks/promises/iterators.\n */\n customFunctionsMarshalOptions?: CustomFunctionsMarshalOptions;\n}\n\n/**\n * Runtime fetch handle - provides access to fetch/serve operations.\n */\nexport interface RuntimeFetchHandle {\n /** Dispatch HTTP request to serve() handler */\n dispatchRequest(\n request: Request,\n options?: DispatchRequestOptions\n ): Promise<Response>;\n /** Check if isolate requested WebSocket upgrade */\n getUpgradeRequest(): UpgradeRequest | null;\n /** Dispatch WebSocket open event to isolate */\n dispatchWebSocketOpen(connectionId: string): void;\n /** Dispatch WebSocket message event to isolate */\n dispatchWebSocketMessage(\n connectionId: string,\n message: string | ArrayBuffer\n ): void;\n /** Dispatch WebSocket close event to isolate */\n dispatchWebSocketClose(\n connectionId: string,\n code: number,\n reason: string\n ): void;\n /** Dispatch WebSocket error event to isolate */\n dispatchWebSocketError(connectionId: string, error: Error): void;\n /** Register callback for WebSocket commands from isolate */\n onWebSocketCommand(callback: (cmd: WebSocketCommand) => void): () => void;\n /** Check if serve() has been called */\n hasServeHandler(): boolean;\n /** Check if there are active WebSocket connections */\n hasActiveConnections(): boolean;\n /** Dispatch open event to a client WebSocket in the isolate */\n dispatchClientWebSocketOpen(socketId: string, protocol: string, extensions: string): void;\n /** Dispatch message event to a client WebSocket in the isolate */\n dispatchClientWebSocketMessage(socketId: string, data: string | ArrayBuffer): void;\n /** Dispatch close event to a client WebSocket in the isolate */\n dispatchClientWebSocketClose(socketId: string, code: number, reason: string, wasClean: boolean): void;\n /** Dispatch error event to a client WebSocket in the isolate */\n dispatchClientWebSocketError(socketId: string): void;\n /** Register callback for client WebSocket commands from isolate */\n onClientWebSocketCommand(callback: (cmd: ClientWebSocketCommand) => void): () => void;\n /** Register callback for events emitted from isolate code */\n onEvent(callback: (event: string, payload: unknown) => void): () => void;\n /** Dispatch an event into the isolate (calls __on listeners) */\n dispatchEvent(event: string, payload: unknown): void;\n}\n\n/**\n * Runtime timers handle - provides access to timer operations.\n * Timers fire automatically based on real time.\n */\nexport interface RuntimeTimersHandle {\n /** Clear all pending timers */\n clearAll(): void;\n}\n\n/**\n * Runtime console handle - provides access to console state.\n */\nexport interface RuntimeConsoleHandle {\n /** Reset all console state (timers, counters, group depth) */\n reset(): void;\n /** Get console.time() timers */\n getTimers(): Map<string, number>;\n /** Get console.count() counters */\n getCounters(): Map<string, number>;\n /** Get current console.group() nesting depth */\n getGroupDepth(): number;\n}\n\n/**\n * Runtime test environment handle - provides access to test execution.\n */\nexport interface RuntimeTestEnvironmentHandle {\n /** Run all registered tests */\n runTests(timeout?: number): Promise<RunResults>;\n /** Check if any tests are registered */\n hasTests(): boolean;\n /** Get count of registered tests */\n getTestCount(): number;\n /** Reset test state */\n reset(): void;\n}\n\n/**\n * Runtime playwright handle - provides access to browser data collection.\n */\nexport interface RuntimePlaywrightHandle {\n /** Get collected browser data (console logs, network requests/responses) */\n getCollectedData(): CollectedData;\n /** Clear collected browser data */\n clearCollectedData(): void;\n}\n\n/**\n * Collected browser data from playwright.\n */\nexport interface CollectedData {\n /** Browser console logs (from the page, not sandbox) */\n browserConsoleLogs: BrowserConsoleLogEntry[];\n networkRequests: NetworkRequestInfo[];\n networkResponses: NetworkResponseInfo[];\n}\n\n/**\n * Runtime handle - the main interface for interacting with the isolate.\n */\nexport interface RuntimeHandle {\n /** Unique runtime identifier */\n readonly id: string;\n /** Execute code as ES module (supports top-level await) */\n eval(code: string, filenameOrOptions?: string | EvalOptions): Promise<void>;\n /** Dispose all resources */\n dispose(): Promise<void>;\n /** Clear module cache and source maps (used for namespace pooling/reuse) */\n clearModuleCache(): void;\n\n /**\n * Array of pending callback promises. Push promises here to have them\n * awaited after each eval() call completes. Used by daemon for IPC flush.\n * For standalone use this array stays empty (callbacks are synchronous).\n */\n readonly pendingCallbacks: Promise<unknown>[];\n\n /** Fetch handle - access to fetch/serve operations */\n readonly fetch: RuntimeFetchHandle;\n /** Timers handle - access to timer operations */\n readonly timers: RuntimeTimersHandle;\n /** Console handle - access to console state */\n readonly console: RuntimeConsoleHandle;\n /** Test environment handle - access to test execution (throws if not enabled) */\n readonly testEnvironment: RuntimeTestEnvironmentHandle;\n /** Playwright handle - access to playwright operations (throws if not configured) */\n readonly playwright: RuntimePlaywrightHandle;\n}\n\n// Internal state for runtime\ninterface RuntimeState {\n isolate: ivm.Isolate;\n context: ivm.Context;\n handles: {\n core?: CoreHandle;\n console?: ConsoleHandle;\n encoding?: EncodingHandle;\n timers?: TimersHandle;\n path?: PathHandle;\n crypto?: CryptoHandle;\n fetch?: FetchHandle;\n fs?: FsHandle;\n testEnvironment?: TestEnvironmentHandle;\n playwright?: PlaywrightHandle;\n };\n moduleCache: Map<string, ivm.Module>;\n staticModuleCache: Map<string, ivm.Module>;\n moduleLoadsInFlight: Map<string, Promise<ivm.Module>>;\n transformCache: Map<string, TransformResult>;\n moduleToFilename: Map<ivm.Module, string>;\n moduleLoader?: ModuleLoaderCallback;\n customFunctions?: CustomFunctions;\n customFnInvokeRef?: ivm.Reference<\n (name: string, argsJson: string) => Promise<string>\n >;\n sourceMaps: Map<string, SourceMap>;\n /** Pending callbacks to await after eval (for daemon IPC fire-and-forget pattern) */\n pendingCallbacks: Promise<unknown>[];\n /** Per-runtime eval queue to prevent overlapping module linking/evaluation */\n evalChain: Promise<void>;\n}\n\n// Iterator session tracking for async iterator custom functions\ninterface IteratorSession {\n iterator: AsyncGenerator<unknown, unknown, unknown>;\n}\n\nconst iteratorSessions = new Map<number, IteratorSession>();\nlet nextIteratorId = 1;\n\n/**\n * Lightweight marshalling code to inject into the isolate.\n * Converts JavaScript types to Ref objects for type-preserving serialization.\n */\nconst ISOLATE_MARSHAL_CODE = `\n(function() {\n // Marshal a value (JavaScript → Ref)\n function marshalForHost(value, depth = 0) {\n if (depth > 100) throw new Error('Maximum marshalling depth exceeded');\n\n if (value === null) return null;\n if (value === undefined) return { __type: 'UndefinedRef' };\n\n const type = typeof value;\n if (type === 'string' || type === 'number' || type === 'boolean') return value;\n if (type === 'bigint') return { __type: 'BigIntRef', value: value.toString() };\n if (type === 'function') throw new Error('Cannot marshal functions from isolate');\n if (type === 'symbol') throw new Error('Cannot marshal Symbol values');\n\n if (type === 'object') {\n if (value instanceof Date) {\n return { __type: 'DateRef', timestamp: value.getTime() };\n }\n if (value instanceof RegExp) {\n return { __type: 'RegExpRef', source: value.source, flags: value.flags };\n }\n if (value instanceof URL) {\n return { __type: 'URLRef', href: value.href };\n }\n if (typeof Headers !== 'undefined' && value instanceof Headers) {\n const pairs = [];\n value.forEach((v, k) => pairs.push([k, v]));\n return { __type: 'HeadersRef', pairs };\n }\n if (value instanceof Uint8Array) {\n return { __type: 'Uint8ArrayRef', data: Array.from(value) };\n }\n if (value instanceof ArrayBuffer) {\n return { __type: 'Uint8ArrayRef', data: Array.from(new Uint8Array(value)) };\n }\n if (typeof Request !== 'undefined' && value instanceof Request) {\n throw new Error('Cannot marshal Request from isolate. Use fetch callback instead.');\n }\n if (typeof Response !== 'undefined' && value instanceof Response) {\n throw new Error('Cannot marshal Response from isolate. Return plain objects instead.');\n }\n if (typeof File !== 'undefined' && value instanceof File) {\n throw new Error('Cannot marshal File from isolate.');\n }\n if (typeof Blob !== 'undefined' && value instanceof Blob) {\n throw new Error('Cannot marshal Blob from isolate.');\n }\n if (typeof FormData !== 'undefined' && value instanceof FormData) {\n throw new Error('Cannot marshal FormData from isolate.');\n }\n if (Array.isArray(value)) {\n return value.map(v => marshalForHost(v, depth + 1));\n }\n // Plain object\n const result = {};\n for (const key of Object.keys(value)) {\n result[key] = marshalForHost(value[key], depth + 1);\n }\n return result;\n }\n return value;\n }\n\n // Unmarshal a value (Ref → JavaScript)\n function unmarshalFromHost(value, depth = 0) {\n if (depth > 100) throw new Error('Maximum unmarshalling depth exceeded');\n\n if (value === null) return null;\n if (typeof value !== 'object') return value;\n\n if (value.__type) {\n switch (value.__type) {\n case 'UndefinedRef': return undefined;\n case 'DateRef': return new Date(value.timestamp);\n case 'RegExpRef': return new RegExp(value.source, value.flags);\n case 'BigIntRef': return BigInt(value.value);\n case 'URLRef': return new URL(value.href);\n case 'HeadersRef': return new Headers(value.pairs);\n case 'Uint8ArrayRef': return new Uint8Array(value.data);\n case 'RequestRef': {\n const init = {\n method: value.method,\n headers: value.headers,\n body: value.body ? new Uint8Array(value.body) : null,\n };\n if (value.mode) init.mode = value.mode;\n if (value.credentials) init.credentials = value.credentials;\n if (value.cache) init.cache = value.cache;\n if (value.redirect) init.redirect = value.redirect;\n if (value.referrer) init.referrer = value.referrer;\n if (value.referrerPolicy) init.referrerPolicy = value.referrerPolicy;\n if (value.integrity) init.integrity = value.integrity;\n return new Request(value.url, init);\n }\n case 'ResponseRef': {\n return new Response(value.body ? new Uint8Array(value.body) : null, {\n status: value.status,\n statusText: value.statusText,\n headers: value.headers,\n });\n }\n case 'FileRef': {\n if (!value.name) {\n return new Blob([new Uint8Array(value.data)], { type: value.type });\n }\n return new File([new Uint8Array(value.data)], value.name, {\n type: value.type,\n lastModified: value.lastModified,\n });\n }\n case 'FormDataRef': {\n const fd = new FormData();\n for (const [key, entry] of value.entries) {\n if (typeof entry === 'string') {\n fd.append(key, entry);\n } else {\n const file = unmarshalFromHost(entry, depth + 1);\n fd.append(key, file);\n }\n }\n return fd;\n }\n case 'CallbackRef': {\n // Create a proxy function that invokes the callback\n const callbackId = value.callbackId;\n return function(...args) {\n const argsJson = JSON.stringify(marshalForHost(args));\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [callbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n }\n case 'PromiseRef': {\n // Create a proxy Promise that resolves via callback\n const promiseId = value.promiseId;\n return new Promise((resolve, reject) => {\n try {\n const argsJson = JSON.stringify([promiseId]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [value.__resolveCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (result.ok) {\n resolve(unmarshalFromHost(result.value));\n } else {\n reject(new Error(result.error.message));\n }\n } catch (e) {\n reject(e);\n }\n });\n }\n case 'AsyncIteratorRef': {\n const iteratorId = value.iteratorId;\n const nextCallbackId = value.__nextCallbackId;\n const returnCallbackId = value.__returnCallbackId;\n return {\n [Symbol.asyncIterator]() { return this; },\n async next() {\n const argsJson = JSON.stringify([iteratorId]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [nextCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (!result.ok) {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n return {\n done: result.value.done,\n value: unmarshalFromHost(result.value.value)\n };\n },\n async return(v) {\n const argsJson = JSON.stringify([iteratorId, marshalForHost(v)]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [returnCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n return { done: true, value: result.ok ? unmarshalFromHost(result.value) : undefined };\n }\n };\n }\n default:\n // Unknown ref type, return as-is\n break;\n }\n }\n\n if (Array.isArray(value)) {\n return value.map(v => unmarshalFromHost(v, depth + 1));\n }\n\n // Plain object - recursively unmarshal\n const result = {};\n for (const key of Object.keys(value)) {\n result[key] = unmarshalFromHost(value[key], depth + 1);\n }\n return result;\n }\n\n // Expose as globals\n globalThis.__marshalForHost = marshalForHost;\n globalThis.__unmarshalFromHost = unmarshalFromHost;\n})();\n`;\n\n// CustomFunctionsMarshalOptions is exported at the top of the file\n\n/**\n * Setup custom functions as globals in the isolate context.\n * Each function directly calls the host callback when invoked.\n *\n * When marshalOptions is provided, returned values are marshalled with a MarshalContext,\n * enabling proper proxying of callbacks/promises/iterators across boundaries.\n */\nasync function setupCustomFunctions(\n context: ivm.Context,\n customFunctions: CustomFunctions,\n marshalOptions?: CustomFunctionsMarshalOptions,\n): Promise<ivm.Reference<(name: string, argsJson: string) => Promise<string>>> {\n const global = context.global;\n\n // Reference that invokes the callback and returns the result.\n // The first argument can be a string function name (for custom functions) or a\n // numeric callback ID (for returned callbacks/promises/iterators from marshal).\n const invokeCallbackRef = new ivm.Reference(\n async (nameOrId: string | number, argsJson: string): Promise<string> => {\n // Check if this is a local callback ID (numeric, used by returned callbacks/promises/iterators)\n if (typeof nameOrId === \"number\" && marshalOptions) {\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n try {\n const result = await marshalOptions.invokeCallback(nameOrId, args);\n const ctx = marshalOptions.createMarshalContext();\n const marshalledResult = await marshalValue(result, ctx);\n const processedResult = marshalOptions.addCallbackIdsToRefs(marshalledResult);\n return JSON.stringify({ ok: true, value: processedResult });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n\n const name = String(nameOrId);\n const def = customFunctions[name];\n if (!def) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Custom function '${name}' not found`,\n name: \"Error\",\n },\n });\n }\n // Unmarshal args from isolate (converts Refs back to JavaScript types)\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n try {\n // Always await the result: for daemon-bridged functions, even \"sync\" custom functions\n // are async due to IPC, so we need to resolve the promise.\n const result = await def.fn(...args);\n // Marshal result for isolate (converts JavaScript types to Refs)\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n const marshalledResult = await marshalValue(result, ctx);\n const processedResult = marshalOptions.addCallbackIdsToRefs(marshalledResult);\n return JSON.stringify({ ok: true, value: processedResult });\n }\n const marshalledResult = await marshalValue(result);\n return JSON.stringify({ ok: true, value: marshalledResult });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__customFn_invoke\", invokeCallbackRef);\n\n // Iterator start: creates iterator, stores in session, returns iteratorId\n const iterStartRef = new ivm.Reference(\n async (name: string, argsJson: string): Promise<string> => {\n const def = customFunctions[name];\n if (!def || def.type !== \"asyncIterator\") {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Async iterator function '${name}' not found`,\n name: \"Error\",\n },\n });\n }\n try {\n // Unmarshal args from isolate\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n const fn = def.fn as CustomAsyncGeneratorFunction;\n const iterator = fn(...args);\n const iteratorId = nextIteratorId++;\n iteratorSessions.set(iteratorId, { iterator });\n return JSON.stringify({ ok: true, iteratorId });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_start\", iterStartRef);\n\n // Iterator next: calls iterator.next(), returns {done, value}\n const iterNextRef = new ivm.Reference(\n async (iteratorId: number): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Iterator session ${iteratorId} not found`,\n name: \"Error\",\n },\n });\n }\n try {\n const result = await session.iterator.next();\n if (result.done) {\n iteratorSessions.delete(iteratorId);\n }\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result.value);\n }\n return JSON.stringify({\n ok: true,\n done: result.done,\n value: marshalledValue,\n });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_next\", iterNextRef);\n\n // Iterator return: calls iterator.return(), cleans up session\n const iterReturnRef = new ivm.Reference(\n async (iteratorId: number, valueJson: string): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({ ok: true, done: true, value: undefined });\n }\n try {\n // Unmarshal value from isolate\n const rawValue = valueJson ? JSON.parse(valueJson) : undefined;\n const value = unmarshalValue(rawValue);\n const result = await session.iterator.return?.(value);\n iteratorSessions.delete(iteratorId);\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result?.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result?.value);\n }\n return JSON.stringify({ ok: true, done: true, value: marshalledValue });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_return\", iterReturnRef);\n\n // Iterator throw: calls iterator.throw(), cleans up session\n const iterThrowRef = new ivm.Reference(\n async (iteratorId: number, errorJson: string): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Iterator session ${iteratorId} not found`,\n name: \"Error\",\n },\n });\n }\n try {\n const errorData = JSON.parse(errorJson) as {\n message: string;\n name: string;\n };\n const error = Object.assign(new Error(errorData.message), {\n name: errorData.name,\n });\n const result = await session.iterator.throw?.(error);\n iteratorSessions.delete(iteratorId);\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result?.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result?.value);\n }\n return JSON.stringify({\n ok: true,\n done: result?.done ?? true,\n value: marshalledValue,\n });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_throw\", iterThrowRef);\n\n // Inject marshalling helpers into the isolate\n context.evalSync(ISOLATE_MARSHAL_CODE);\n\n // Create wrapper functions for each custom function\n for (const name of Object.keys(customFunctions)) {\n const def = customFunctions[name]!;\n\n if (def.type === \"async\") {\n // Async function: use applySyncPromise and async function wrapper\n context.evalSync(`\n globalThis.${name} = async function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const resultJson = __customFn_invoke.applySyncPromise(\n undefined,\n [\"${name}\", JSON.stringify(marshalledArgs)]\n );\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return __unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n `);\n } else if (def.type === \"sync\") {\n // Sync function: use applySyncPromise (to await the host) but wrap in regular function\n // The function blocks until the host responds, but returns the value directly (not a Promise)\n context.evalSync(`\n globalThis.${name} = function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const resultJson = __customFn_invoke.applySyncPromise(\n undefined,\n [\"${name}\", JSON.stringify(marshalledArgs)]\n );\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return __unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n `);\n } else if (def.type === \"asyncIterator\") {\n // Async iterator function: returns an async iterable object\n context.evalSync(`\n globalThis.${name} = function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const startResult = JSON.parse(__iter_start.applySyncPromise(undefined, [\"${name}\", JSON.stringify(marshalledArgs)]));\n if (!startResult.ok) {\n throw Object.assign(new Error(startResult.error.message), { name: startResult.error.name });\n }\n const iteratorId = startResult.iteratorId;\n return {\n [Symbol.asyncIterator]() { return this; },\n async next() {\n const result = JSON.parse(__iter_next.applySyncPromise(undefined, [iteratorId]));\n if (!result.ok) {\n throw Object.assign(new Error(result.error.message), { name: result.error.name });\n }\n return { done: result.done, value: __unmarshalFromHost(result.value) };\n },\n async return(v) {\n const result = JSON.parse(__iter_return.applySyncPromise(undefined, [iteratorId, JSON.stringify(__marshalForHost(v))]));\n return { done: true, value: __unmarshalFromHost(result.value) };\n },\n async throw(e) {\n const result = JSON.parse(__iter_throw.applySyncPromise(undefined, [iteratorId, JSON.stringify({ message: e.message, name: e.name })]));\n if (!result.ok) {\n throw Object.assign(new Error(result.error.message), { name: result.error.name });\n }\n return { done: result.done, value: __unmarshalFromHost(result.value) };\n }\n };\n };\n `);\n }\n }\n\n return invokeCallbackRef;\n}\n\n/**\n * Create local marshal options for standalone runtime custom functions.\n * Enables returned callbacks/promises/iterators without daemon IPC.\n */\nfunction createLocalCustomFunctionsMarshalOptions(): CustomFunctionsMarshalOptions {\n const returnedCallbacks = new Map<number, Function>();\n const returnedPromises = new Map<number, Promise<unknown>>();\n const returnedIterators = new Map<number, AsyncIterator<unknown>>();\n let nextLocalCallbackId = 1_000_000;\n\n const createMarshalContext = (): MarshalContext => ({\n registerCallback: (fn: Function): number => {\n const callbackId = nextLocalCallbackId++;\n returnedCallbacks.set(callbackId, fn);\n return callbackId;\n },\n registerPromise: (promise: Promise<unknown>): number => {\n const promiseId = nextLocalCallbackId++;\n returnedPromises.set(promiseId, promise);\n return promiseId;\n },\n registerIterator: (iterator: AsyncIterator<unknown>): number => {\n const iteratorId = nextLocalCallbackId++;\n returnedIterators.set(iteratorId, iterator);\n return iteratorId;\n },\n });\n\n const isPromiseRef = (\n value: unknown\n ): value is { __type: \"PromiseRef\"; promiseId: number } =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { __type?: string }).__type === \"PromiseRef\";\n\n const isAsyncIteratorRef = (\n value: unknown\n ): value is { __type: \"AsyncIteratorRef\"; iteratorId: number } =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { __type?: string }).__type === \"AsyncIteratorRef\";\n\n const addCallbackIdsToRefs = (value: unknown): unknown => {\n if (value === null || typeof value !== \"object\") return value;\n\n if (isPromiseRef(value)) {\n if (\"__resolveCallbackId\" in value) return value;\n\n const resolveCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(resolveCallbackId, async (promiseId: number) => {\n const promise = returnedPromises.get(promiseId);\n if (!promise) {\n throw new Error(`Promise ${promiseId} not found`);\n }\n const result = await promise;\n returnedPromises.delete(promiseId);\n const ctx = createMarshalContext();\n const marshalled = await marshalValue(result, ctx);\n return addCallbackIdsToRefs(marshalled);\n });\n\n return { ...value, __resolveCallbackId: resolveCallbackId };\n }\n\n if (isAsyncIteratorRef(value)) {\n if (\"__nextCallbackId\" in value) return value;\n\n const nextCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(nextCallbackId, async (iteratorId: number) => {\n const iterator = returnedIterators.get(iteratorId);\n if (!iterator) {\n throw new Error(`Iterator ${iteratorId} not found`);\n }\n const result = await iterator.next();\n if (result.done) {\n returnedIterators.delete(iteratorId);\n }\n const ctx = createMarshalContext();\n const marshalledValue = await marshalValue(result.value, ctx);\n return {\n done: result.done,\n value: addCallbackIdsToRefs(marshalledValue),\n };\n });\n\n const returnCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(\n returnCallbackId,\n async (iteratorId: number, returnValue?: unknown) => {\n const iterator = returnedIterators.get(iteratorId);\n returnedIterators.delete(iteratorId);\n if (!iterator || !iterator.return) {\n return { done: true, value: undefined };\n }\n const result = await iterator.return(returnValue);\n const ctx = createMarshalContext();\n const marshalledValue = await marshalValue(result.value, ctx);\n return {\n done: true,\n value: addCallbackIdsToRefs(marshalledValue),\n };\n }\n );\n\n return {\n ...value,\n __nextCallbackId: nextCallbackId,\n __returnCallbackId: returnCallbackId,\n };\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => addCallbackIdsToRefs(item));\n }\n\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(value)) {\n result[key] = addCallbackIdsToRefs(\n (value as Record<string, unknown>)[key]\n );\n }\n return result;\n };\n\n const invokeCallback = async (\n callbackId: number,\n args: unknown[]\n ): Promise<unknown> => {\n const callback = returnedCallbacks.get(callbackId);\n if (!callback) {\n throw new Error(`Local callback ${callbackId} not found`);\n }\n return await callback(...args);\n };\n\n return { createMarshalContext, addCallbackIdsToRefs, invokeCallback };\n}\n\n/**\n * Create a module resolver function for local execution.\n */\nfunction createModuleResolver(\n state: RuntimeState\n): (specifier: string, referrer: ivm.Module) => Promise<ivm.Module> {\n return async (\n specifier: string,\n referrer: ivm.Module\n ): Promise<ivm.Module> => {\n // Static cache first\n const staticCached = state.staticModuleCache.get(specifier);\n if (staticCached) return staticCached;\n\n // Specifier-only fast path is safe here: each local runtime gets a fresh cache,\n // so there's no cross-lifecycle staleness (unlike the daemon where caches persist across namespace reuse).\n const cached = state.moduleCache.get(specifier);\n if (cached) return cached;\n\n if (!state.moduleLoader) {\n throw new Error(\n `No module loader registered. Cannot import: ${specifier}`\n );\n }\n\n // Get importer info\n const importerPath = state.moduleToFilename.get(referrer) ?? \"<unknown>\";\n const importerResolveDir = path.posix.dirname(importerPath);\n\n // Invoke module loader - capture full result including static flag\n const result = await state.moduleLoader(specifier, {\n path: importerPath,\n resolveDir: importerResolveDir,\n });\n const { code, resolveDir } = result;\n\n // Cache by specifier + content hash (allows invalidation when content changes)\n const hash = contentHash(code);\n const cacheKey = `${specifier}:${hash}`;\n const inFlightKey = `${result.static ? \"static\" : \"dynamic\"}:${cacheKey}`;\n\n // Cache checks again after await in case another resolver call won the race\n const staticCachedAfterLoad = state.staticModuleCache.get(specifier);\n if (staticCachedAfterLoad) return staticCachedAfterLoad;\n\n const cachedAfterLoad = state.moduleCache.get(specifier);\n if (cachedAfterLoad) return cachedAfterLoad;\n\n const hashCached = state.moduleCache.get(cacheKey);\n if (hashCached) return hashCached;\n\n const inFlight = state.moduleLoadsInFlight.get(inFlightKey);\n if (inFlight) return inFlight;\n\n const loadPromise = (async (): Promise<ivm.Module> => {\n let mod: ivm.Module | undefined;\n try {\n // Transform cache — check transform cache first (survives reuse in daemon)\n let transformed: TransformResult | undefined = state.transformCache.get(hash);\n if (!transformed) {\n transformed = await transformModuleCode(code, specifier);\n state.transformCache.set(hash, transformed);\n }\n\n if (transformed.sourceMap) {\n state.sourceMaps.set(specifier, transformed.sourceMap);\n }\n\n // Compile the module\n mod = await state.isolate.compileModule(transformed.code, {\n filename: specifier,\n });\n\n // Construct resolved path and track for nested imports\n const resolvedPath = path.posix.join(resolveDir, path.posix.basename(specifier));\n state.moduleToFilename.set(mod, resolvedPath);\n\n // Cache the compiled module before linker uses it (supports circular deps)\n if (result.static) {\n state.staticModuleCache.set(specifier, mod);\n } else {\n state.moduleCache.set(specifier, mod);\n state.moduleCache.set(cacheKey, mod);\n }\n\n return mod;\n } catch (err) {\n // Remove partial cache state to avoid returning poisoned module entries later.\n if (mod) {\n state.moduleToFilename.delete(mod);\n if (result.static) {\n if (state.staticModuleCache.get(specifier) === mod) {\n state.staticModuleCache.delete(specifier);\n }\n } else {\n if (state.moduleCache.get(specifier) === mod) {\n state.moduleCache.delete(specifier);\n }\n if (state.moduleCache.get(cacheKey) === mod) {\n state.moduleCache.delete(cacheKey);\n }\n }\n }\n throw err;\n }\n })();\n\n state.moduleLoadsInFlight.set(inFlightKey, loadPromise);\n try {\n return await loadPromise;\n } finally {\n state.moduleLoadsInFlight.delete(inFlightKey);\n }\n };\n}\n\n/**\n * Convert FetchCallback to FetchOptions\n */\nfunction convertFetchCallback(callback?: FetchCallback): FetchOptions {\n if (!callback) {\n return {};\n }\n return {\n onFetch: async (url: string, init: FetchRequestInit): Promise<Response> => {\n // Wrap the result in a Promise to handle both sync and async callbacks\n return Promise.resolve(callback(url, init));\n },\n };\n}\n\n/**\n * Create a fully configured isolated-vm runtime\n *\n * Sets up all WHATWG APIs: fetch, fs, console, crypto, encoding, timers\n *\n * @example\n * const runtime = await createRuntime({\n * console: { log: (...args) => console.log(\"[isolate]\", ...args) },\n * fetch: async (request) => fetch(request),\n * });\n *\n * await runtime.eval(`\n * console.log(\"Hello from sandbox!\");\n * const response = await fetch(\"https://example.com\");\n * `);\n *\n * await runtime.dispose();\n */\nexport async function createRuntime<T extends Record<string, any[]> = Record<string, unknown[]>>(\n options?: RuntimeOptions<T>\n): Promise<RuntimeHandle> {\n const opts = options ?? {};\n\n // Generate unique ID\n const id = crypto.randomUUID();\n\n // Create isolate with optional memory limit\n const isolate = new ivm.Isolate({\n memoryLimit: opts.memoryLimitMB,\n });\n const context = await isolate.createContext();\n\n // Initialize state\n const state: RuntimeState = {\n isolate,\n context,\n handles: {},\n moduleCache: new Map(),\n staticModuleCache: new Map(),\n moduleLoadsInFlight: new Map(),\n transformCache: new Map(),\n moduleToFilename: new Map(),\n sourceMaps: new Map(),\n pendingCallbacks: [],\n evalChain: Promise.resolve(),\n moduleLoader: opts.moduleLoader,\n customFunctions: opts.customFunctions as CustomFunctions<Record<string, unknown[]>>,\n };\n\n // Setup all APIs in order\n // Core must be first as it provides Blob, File, streams, URL, etc.\n state.handles.core = await setupCore(context);\n\n // Console\n state.handles.console = await setupConsole(context, opts.console);\n\n // Encoding (btoa/atob) and Buffer\n state.handles.encoding = await setupEncoding(context);\n\n // Timers (setTimeout, setInterval)\n state.handles.timers = await setupTimers(context);\n\n // Path module\n state.handles.path = await setupPath(context, { cwd: opts.cwd });\n\n // Crypto (randomUUID, getRandomValues)\n state.handles.crypto = await setupCrypto(context);\n\n // Fetch API - convert callback to options\n state.handles.fetch = await setupFetch(\n context,\n convertFetchCallback(opts.fetch)\n );\n\n // File system (only if handler provided)\n if (opts.fs) {\n state.handles.fs = await setupFs(context, opts.fs);\n }\n\n // Setup custom functions\n if (opts.customFunctions) {\n const customMarshalOptions =\n opts.customFunctionsMarshalOptions ??\n createLocalCustomFunctionsMarshalOptions();\n\n state.customFnInvokeRef = await setupCustomFunctions(\n context,\n opts.customFunctions as CustomFunctions<Record<string, unknown[]>>,\n customMarshalOptions,\n );\n }\n\n // Setup test environment (if enabled)\n if (opts.testEnvironment) {\n const testEnvOptions: TestEnvironmentOptions | undefined =\n typeof opts.testEnvironment === \"object\"\n ? opts.testEnvironment\n : undefined;\n state.handles.testEnvironment = await setupTestEnvironment(\n context,\n testEnvOptions\n );\n }\n\n // Setup playwright - AFTER test environment so expect can be extended\n if (opts.playwright) {\n if (!opts.playwright.handler) {\n throw new Error(\n \"Playwright configured without handler. Provide playwright.handler in createRuntime options.\"\n );\n }\n\n // Determine event handler\n // If console: true and we have a console handler, wrap onEvent to route browser logs\n let eventCallback = opts.playwright.onEvent;\n\n if (opts.playwright.console && opts.console?.onEntry) {\n const originalCallback = eventCallback;\n const consoleHandler = opts.console.onEntry;\n eventCallback = (event) => {\n // Call original callback if provided\n if (originalCallback) {\n originalCallback(event);\n }\n // Route browser console logs through console handler as browserOutput entry\n if (event.type === \"browserConsoleLog\") {\n consoleHandler({\n type: \"browserOutput\",\n level: event.level,\n stdout: event.stdout,\n timestamp: event.timestamp,\n });\n }\n };\n }\n\n const playwrightSetupOptions: PlaywrightSetupOptions = {\n handler: opts.playwright.handler,\n timeout: opts.playwright.timeout,\n // Don't print directly if routing through console handler\n console: opts.playwright.console && !opts.console?.onEntry,\n onEvent: eventCallback,\n };\n\n state.handles.playwright = await setupPlaywright(context, playwrightSetupOptions);\n }\n\n // Create fetch handle wrapper\n const fetchHandle: RuntimeFetchHandle = {\n async dispatchRequest(\n request: Request,\n options?: DispatchRequestOptions\n ): Promise<Response> {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.dispatchRequest(request, options);\n },\n getUpgradeRequest() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.getUpgradeRequest();\n },\n dispatchWebSocketOpen(connectionId: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketOpen(connectionId);\n },\n dispatchWebSocketMessage(\n connectionId: string,\n message: string | ArrayBuffer\n ) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketMessage(connectionId, message);\n },\n dispatchWebSocketClose(connectionId: string, code: number, reason: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketClose(connectionId, code, reason);\n },\n dispatchWebSocketError(connectionId: string, error: Error) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketError(connectionId, error);\n },\n onWebSocketCommand(callback: (cmd: WebSocketCommand) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onWebSocketCommand(callback);\n },\n hasServeHandler() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.hasServeHandler();\n },\n hasActiveConnections() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.hasActiveConnections();\n },\n dispatchClientWebSocketOpen(socketId: string, protocol: string, extensions: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketOpen(socketId, protocol, extensions);\n },\n dispatchClientWebSocketMessage(socketId: string, data: string | ArrayBuffer) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketMessage(socketId, data);\n },\n dispatchClientWebSocketClose(socketId: string, code: number, reason: string, wasClean: boolean) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketClose(socketId, code, reason, wasClean);\n },\n dispatchClientWebSocketError(socketId: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketError(socketId);\n },\n onClientWebSocketCommand(callback: (cmd: ClientWebSocketCommand) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onClientWebSocketCommand(callback);\n },\n onEvent(callback: (event: string, payload: unknown) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onEvent(callback);\n },\n dispatchEvent(event: string, payload: unknown) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchEvent(event, payload);\n },\n };\n\n // Create timers handle wrapper\n const timersHandle: RuntimeTimersHandle = {\n clearAll() {\n state.handles.timers?.clearAll();\n },\n };\n\n // Create console handle wrapper\n const consoleHandle: RuntimeConsoleHandle = {\n reset() {\n state.handles.console?.reset();\n },\n getTimers() {\n return state.handles.console?.getTimers() ?? new Map();\n },\n getCounters() {\n return state.handles.console?.getCounters() ?? new Map();\n },\n getGroupDepth() {\n return state.handles.console?.getGroupDepth() ?? 0;\n },\n };\n\n // Create test environment handle wrapper\n const testEnvironmentHandle: RuntimeTestEnvironmentHandle = {\n async runTests(timeout?: number): Promise<RunResults> {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n\n if (timeout === undefined) {\n return runTestsInContext(state.context);\n }\n\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => reject(new Error(\"Test timeout\")), timeout);\n });\n\n try {\n return await Promise.race([\n runTestsInContext(state.context),\n timeoutPromise,\n ]);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n },\n hasTests(): boolean {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n return hasTestsInContext(state.context);\n },\n getTestCount(): number {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n return getTestCountInContext(state.context);\n },\n reset() {\n state.handles.testEnvironment?.dispose();\n },\n };\n\n // Create playwright handle wrapper\n const playwrightHandle: RuntimePlaywrightHandle = {\n getCollectedData(): CollectedData {\n if (!state.handles.playwright) {\n throw new Error(\n \"Playwright not configured. Provide playwright.handler in createRuntime options.\"\n );\n }\n return {\n browserConsoleLogs: state.handles.playwright.getBrowserConsoleLogs(),\n networkRequests: state.handles.playwright.getNetworkRequests(),\n networkResponses: state.handles.playwright.getNetworkResponses(),\n };\n },\n clearCollectedData() {\n state.handles.playwright?.clearCollected();\n },\n };\n\n return {\n id,\n pendingCallbacks: state.pendingCallbacks,\n\n // Module handles\n fetch: fetchHandle,\n timers: timersHandle,\n console: consoleHandle,\n testEnvironment: testEnvironmentHandle,\n playwright: playwrightHandle,\n\n async eval(\n code: string,\n filenameOrOptions?: string | EvalOptions\n ): Promise<void> {\n const runEval = async (): Promise<void> => {\n // Parse options\n const options =\n typeof filenameOrOptions === \"string\"\n ? { filename: filenameOrOptions }\n : filenameOrOptions;\n\n // Normalize filename to absolute path for module resolution\n const filename = normalizeEntryFilename(options?.filename);\n\n try {\n // Transform entry code: strip types, validate, wrap in async function\n const transformed = await transformEntryCode(code, filename);\n if (transformed.sourceMap) {\n state.sourceMaps.set(filename, transformed.sourceMap);\n }\n\n // Compile as ES module\n const mod = await state.isolate.compileModule(transformed.code, {\n filename,\n });\n\n // Track entry module filename for nested imports\n state.moduleToFilename.set(mod, filename);\n\n // Instantiate with module resolver\n const resolver = createModuleResolver(state);\n await mod.instantiate(state.context, resolver);\n\n // Evaluate - only resolves imports and defines the default function (no timeout needed)\n await mod.evaluate();\n\n // Get the default export and run it with timeout\n const ns = mod.namespace;\n const runRef = await ns.get(\"default\", { reference: true });\n try {\n await runRef.apply(undefined, [], {\n result: { promise: true },\n });\n } finally {\n runRef.release();\n }\n\n // Await pending callbacks (no-op for local use, enables daemon IPC flush)\n if (state.pendingCallbacks.length > 0) {\n await Promise.all(state.pendingCallbacks);\n state.pendingCallbacks.length = 0;\n }\n } catch (err) {\n const error = err as Error;\n if (error.stack && state.sourceMaps.size > 0) {\n error.stack = mapErrorStack(error.stack, state.sourceMaps);\n }\n throw error;\n }\n };\n\n const queuedEval = state.evalChain.then(runEval, runEval);\n state.evalChain = queuedEval.then(\n () => undefined,\n () => undefined\n );\n return queuedEval;\n },\n\n clearModuleCache() {\n state.moduleCache.clear();\n state.moduleLoadsInFlight.clear();\n state.moduleToFilename.clear();\n state.sourceMaps.clear();\n // staticModuleCache and transformCache intentionally preserved\n },\n\n async dispose(): Promise<void> {\n // Dispose custom function reference\n if (state.customFnInvokeRef) {\n state.customFnInvokeRef.release();\n }\n\n // Dispose all handles (in reverse order of setup)\n state.handles.playwright?.dispose();\n state.handles.testEnvironment?.dispose();\n state.handles.fs?.dispose();\n state.handles.fetch?.dispose();\n state.handles.crypto?.dispose();\n state.handles.path?.dispose();\n state.handles.timers?.dispose();\n state.handles.encoding?.dispose();\n state.handles.console?.dispose();\n state.handles.core?.dispose();\n\n // Clear module cache\n state.moduleCache.clear();\n state.moduleLoadsInFlight.clear();\n\n // Release context and dispose isolate\n state.context.release();\n state.isolate.dispose();\n },\n };\n}\n\n// Re-export all package types and functions\nexport { setupCore } from \"@ricsam/isolate-core\";\nexport type { CoreHandle, SetupCoreOptions } from \"@ricsam/isolate-core\";\n\nexport { setupConsole } from \"@ricsam/isolate-console\";\nexport {\n simpleConsoleHandler,\n type SimpleConsoleCallbacks,\n} from \"@ricsam/isolate-console/utils\";\nexport type {\n ConsoleHandle,\n ConsoleOptions,\n ConsoleEntry as ConsoleEntryFromConsole,\n} from \"@ricsam/isolate-console\";\n\nexport { setupCrypto } from \"@ricsam/isolate-crypto\";\nexport type { CryptoHandle } from \"@ricsam/isolate-crypto\";\n\nexport { setupEncoding } from \"@ricsam/isolate-encoding\";\nexport type { EncodingHandle } from \"@ricsam/isolate-encoding\";\n\nexport { setupFetch } from \"@ricsam/isolate-fetch\";\nexport type {\n FetchHandle,\n FetchOptions,\n WebSocketCommand,\n UpgradeRequest,\n ClientWebSocketCommand,\n} from \"@ricsam/isolate-fetch\";\n\nexport { setupFs, createNodeFileSystemHandler } from \"@ricsam/isolate-fs\";\nexport type {\n FsHandle,\n FsOptions,\n FileSystemHandler,\n NodeFileSystemHandlerOptions,\n} from \"@ricsam/isolate-fs\";\n\nexport { setupPath } from \"@ricsam/isolate-path\";\nexport type { PathHandle, PathOptions } from \"@ricsam/isolate-path\";\n\nexport { setupTimers } from \"@ricsam/isolate-timers\";\nexport type { TimersHandle } from \"@ricsam/isolate-timers\";\n\nexport {\n setupTestEnvironment,\n runTests,\n hasTests,\n getTestCount,\n} from \"@ricsam/isolate-test-environment\";\nexport type {\n TestEnvironmentHandle,\n TestEnvironmentOptions,\n RunResults,\n TestResult,\n TestInfo,\n TestError,\n TestEvent,\n SuiteInfo,\n SuiteResult,\n} from \"@ricsam/isolate-test-environment\";\n\nexport {\n setupPlaywright,\n createPlaywrightHandler,\n defaultPlaywrightHandler,\n getDefaultPlaywrightHandlerMetadata,\n} from \"@ricsam/isolate-playwright\";\nexport type {\n PlaywrightHandle,\n PlaywrightSetupOptions,\n PlaywrightCallback,\n PlaywrightEvent,\n NetworkRequestInfo,\n NetworkResponseInfo,\n BrowserConsoleLogEntry,\n} from \"@ricsam/isolate-playwright\";\n"
5
+ "import ivm from \"isolated-vm\";\nimport path from \"node:path\";\nimport { setupCore } from \"@ricsam/isolate-core\";\nimport { normalizeEntryFilename } from \"@ricsam/isolate-protocol\";\nimport {\n transformEntryCode,\n transformModuleCode,\n contentHash,\n mapErrorStack,\n type SourceMap,\n type TransformResult,\n} from \"@ricsam/isolate-transform\";\n\n// Re-export for convenience\nexport { normalizeEntryFilename } from \"@ricsam/isolate-protocol\";\nimport { setupConsole } from \"@ricsam/isolate-console\";\nimport { setupEncoding } from \"@ricsam/isolate-encoding\";\nimport { setupTimers } from \"@ricsam/isolate-timers\";\nimport { setupPath } from \"@ricsam/isolate-path\";\nimport { setupCrypto } from \"@ricsam/isolate-crypto\";\nimport { setupFetch } from \"@ricsam/isolate-fetch\";\nimport { setupFs } from \"@ricsam/isolate-fs\";\nimport {\n setupTestEnvironment,\n runTests as runTestsInContext,\n hasTests as hasTestsInContext,\n getTestCount as getTestCountInContext,\n} from \"@ricsam/isolate-test-environment\";\nimport {\n setupPlaywright,\n type PlaywrightCallback,\n type PlaywrightSetupOptions,\n} from \"@ricsam/isolate-playwright\";\n\nimport type { ConsoleOptions, ConsoleHandle } from \"@ricsam/isolate-console\";\nimport type {\n FetchOptions,\n FetchHandle,\n DispatchRequestOptions,\n UpgradeRequest,\n WebSocketCommand,\n ClientWebSocketCommand,\n} from \"@ricsam/isolate-fetch\";\nimport type { FsOptions, FsHandle } from \"@ricsam/isolate-fs\";\nimport type { CoreHandle } from \"@ricsam/isolate-core\";\nimport type { EncodingHandle } from \"@ricsam/isolate-encoding\";\nimport type { TimersHandle } from \"@ricsam/isolate-timers\";\nimport type { PathHandle } from \"@ricsam/isolate-path\";\nimport type { CryptoHandle } from \"@ricsam/isolate-crypto\";\nimport type {\n TestEnvironmentHandle,\n RunResults,\n TestEnvironmentOptions,\n TestEvent,\n SuiteInfo,\n SuiteResult,\n TestInfo,\n TestResult,\n TestError,\n} from \"@ricsam/isolate-test-environment\";\nimport type {\n PlaywrightHandle,\n NetworkRequestInfo,\n NetworkResponseInfo,\n BrowserConsoleLogEntry,\n PlaywrightEvent,\n} from \"@ricsam/isolate-playwright\";\nimport type {\n ConsoleCallbacks,\n ConsoleEntry,\n FetchCallback,\n FetchRequestInit,\n ModuleLoaderCallback,\n CustomFunctionDefinition,\n CustomFunctions,\n CustomAsyncGeneratorFunction,\n DispatchOptions,\n EvalOptions as ProtocolEvalOptions,\n PlaywrightOptions as ProtocolPlaywrightOptions,\n BaseRuntimeOptions,\n} from \"@ricsam/isolate-protocol\";\nimport {\n marshalValue,\n unmarshalValue,\n type MarshalContext,\n} from \"@ricsam/isolate-protocol\";\n\n// Re-export shared types from protocol\nexport type {\n ConsoleCallbacks,\n ConsoleEntry,\n FetchCallback,\n FetchRequestInit,\n ModuleLoaderCallback,\n CustomFunction,\n CustomFunctionDefinition,\n CustomFunctions,\n DispatchOptions,\n} from \"@ricsam/isolate-protocol\";\n\n// Re-export shared protocol option types\nexport type EvalOptions = ProtocolEvalOptions;\nexport type PlaywrightOptions = ProtocolPlaywrightOptions;\n\n/**\n * Options for customizing how custom function return values are marshalled.\n * Used by the daemon to support returned callbacks/promises/iterators via IPC.\n */\nexport interface CustomFunctionsMarshalOptions {\n /** Factory to create a MarshalContext for registering returned callbacks/promises/iterators */\n createMarshalContext: () => MarshalContext;\n /** Post-processor to add callback IDs to PromiseRef/AsyncIteratorRef values */\n addCallbackIdsToRefs: (value: unknown) => unknown;\n /** Handler for numeric callback IDs from marshalled refs (CallbackRef, PromiseRef, AsyncIteratorRef) */\n invokeCallback: (callbackId: number, args: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Options for creating a runtime.\n * Extends BaseRuntimeOptions and adds runtime-specific fs type.\n */\nexport interface RuntimeOptions<T extends Record<string, any[]> = Record<string, unknown[]>>\n extends BaseRuntimeOptions<T> {\n /**\n * File system options.\n * Note: For local runtime, this uses FsOptions with getDirectory returning a FileSystemHandler.\n * For remote runtime (isolate-client), use FileSystemCallbacks instead.\n */\n fs?: FsOptions;\n /**\n * Optional marshal options for custom functions.\n * When provided, enables MarshalContext-based marshalling for returned values.\n * Used by the daemon for IPC proxying of callbacks/promises/iterators.\n */\n customFunctionsMarshalOptions?: CustomFunctionsMarshalOptions;\n}\n\n/**\n * Runtime fetch handle - provides access to fetch/serve operations.\n */\nexport interface RuntimeFetchHandle {\n /** Dispatch HTTP request to serve() handler */\n dispatchRequest(\n request: Request,\n options?: DispatchRequestOptions\n ): Promise<Response>;\n /** Check if isolate requested WebSocket upgrade */\n getUpgradeRequest(): UpgradeRequest | null;\n /** Dispatch WebSocket open event to isolate */\n dispatchWebSocketOpen(connectionId: string): void;\n /** Dispatch WebSocket message event to isolate */\n dispatchWebSocketMessage(\n connectionId: string,\n message: string | ArrayBuffer\n ): void;\n /** Dispatch WebSocket close event to isolate */\n dispatchWebSocketClose(\n connectionId: string,\n code: number,\n reason: string\n ): void;\n /** Dispatch WebSocket error event to isolate */\n dispatchWebSocketError(connectionId: string, error: Error): void;\n /** Register callback for WebSocket commands from isolate */\n onWebSocketCommand(callback: (cmd: WebSocketCommand) => void): () => void;\n /** Check if serve() has been called */\n hasServeHandler(): boolean;\n /** Check if there are active WebSocket connections */\n hasActiveConnections(): boolean;\n /** Dispatch open event to a client WebSocket in the isolate */\n dispatchClientWebSocketOpen(socketId: string, protocol: string, extensions: string): void;\n /** Dispatch message event to a client WebSocket in the isolate */\n dispatchClientWebSocketMessage(socketId: string, data: string | ArrayBuffer): void;\n /** Dispatch close event to a client WebSocket in the isolate */\n dispatchClientWebSocketClose(socketId: string, code: number, reason: string, wasClean: boolean): void;\n /** Dispatch error event to a client WebSocket in the isolate */\n dispatchClientWebSocketError(socketId: string): void;\n /** Register callback for client WebSocket commands from isolate */\n onClientWebSocketCommand(callback: (cmd: ClientWebSocketCommand) => void): () => void;\n /** Register callback for events emitted from isolate code */\n onEvent(callback: (event: string, payload: unknown) => void): () => void;\n /** Dispatch an event into the isolate (calls __on listeners) */\n dispatchEvent(event: string, payload: unknown): void;\n}\n\n/**\n * Runtime timers handle - provides access to timer operations.\n * Timers fire automatically based on real time.\n */\nexport interface RuntimeTimersHandle {\n /** Clear all pending timers */\n clearAll(): void;\n}\n\n/**\n * Runtime console handle - provides access to console state.\n */\nexport interface RuntimeConsoleHandle {\n /** Reset all console state (timers, counters, group depth) */\n reset(): void;\n /** Get console.time() timers */\n getTimers(): Map<string, number>;\n /** Get console.count() counters */\n getCounters(): Map<string, number>;\n /** Get current console.group() nesting depth */\n getGroupDepth(): number;\n}\n\n/**\n * Runtime test environment handle - provides access to test execution.\n */\nexport interface RuntimeTestEnvironmentHandle {\n /** Run all registered tests */\n runTests(timeout?: number): Promise<RunResults>;\n /** Check if any tests are registered */\n hasTests(): boolean;\n /** Get count of registered tests */\n getTestCount(): number;\n /** Reset test state */\n reset(): void;\n}\n\n/**\n * Runtime playwright handle - provides access to browser data collection.\n */\nexport interface RuntimePlaywrightHandle {\n /** Get collected browser data (console logs, network requests/responses) */\n getCollectedData(): CollectedData;\n /** Clear collected browser data */\n clearCollectedData(): void;\n}\n\n/**\n * Collected browser data from playwright.\n */\nexport interface CollectedData {\n /** Browser console logs (from the page, not sandbox) */\n browserConsoleLogs: BrowserConsoleLogEntry[];\n networkRequests: NetworkRequestInfo[];\n networkResponses: NetworkResponseInfo[];\n}\n\n/**\n * Runtime handle - the main interface for interacting with the isolate.\n */\nexport interface RuntimeHandle {\n /** Unique runtime identifier */\n readonly id: string;\n /** Execute code as ES module (supports top-level await) */\n eval(code: string, filenameOrOptions?: string | EvalOptions): Promise<void>;\n /** Dispose all resources */\n dispose(): Promise<void>;\n /** Clear module cache and source maps (used for namespace pooling/reuse) */\n clearModuleCache(): void;\n\n /**\n * Array of pending callback promises. Push promises here to have them\n * awaited after each eval() call completes. Used by daemon for IPC flush.\n * For standalone use this array stays empty (callbacks are synchronous).\n */\n readonly pendingCallbacks: Promise<unknown>[];\n\n /** Fetch handle - access to fetch/serve operations */\n readonly fetch: RuntimeFetchHandle;\n /** Timers handle - access to timer operations */\n readonly timers: RuntimeTimersHandle;\n /** Console handle - access to console state */\n readonly console: RuntimeConsoleHandle;\n /** Test environment handle - access to test execution (throws if not enabled) */\n readonly testEnvironment: RuntimeTestEnvironmentHandle;\n /** Playwright handle - access to playwright operations (throws if not configured) */\n readonly playwright: RuntimePlaywrightHandle;\n}\n\n// Internal state for runtime\ninterface RuntimeState {\n isolate: ivm.Isolate;\n context: ivm.Context;\n handles: {\n core?: CoreHandle;\n console?: ConsoleHandle;\n encoding?: EncodingHandle;\n timers?: TimersHandle;\n path?: PathHandle;\n crypto?: CryptoHandle;\n fetch?: FetchHandle;\n fs?: FsHandle;\n testEnvironment?: TestEnvironmentHandle;\n playwright?: PlaywrightHandle;\n };\n moduleCache: Map<string, ivm.Module>;\n staticModuleCache: Map<string, ivm.Module>;\n moduleLoadsInFlight: Map<string, Promise<ivm.Module>>;\n transformCache: Map<string, TransformResult>;\n moduleToFilename: Map<ivm.Module, string>;\n moduleLoader?: ModuleLoaderCallback;\n customFunctions?: CustomFunctions;\n customFnInvokeRef?: ivm.Reference<\n (name: string, argsJson: string) => Promise<string>\n >;\n sourceMaps: Map<string, SourceMap>;\n /** Tracks the import chain for each module (resolved path → list of ancestor paths) */\n moduleImportChain: Map<string, string[]>;\n /** Tracks which file imported a given specifier (resolvedSpecifier → importerPath) */\n specifierToImporter: Map<string, string>;\n /** Pending callbacks to await after eval (for daemon IPC fire-and-forget pattern) */\n pendingCallbacks: Promise<unknown>[];\n /** Per-runtime eval queue to prevent overlapping module linking/evaluation */\n evalChain: Promise<void>;\n}\n\n// Iterator session tracking for async iterator custom functions\ninterface IteratorSession {\n iterator: AsyncGenerator<unknown, unknown, unknown>;\n}\n\nconst iteratorSessions = new Map<number, IteratorSession>();\nlet nextIteratorId = 1;\n\n/**\n * Lightweight marshalling code to inject into the isolate.\n * Converts JavaScript types to Ref objects for type-preserving serialization.\n */\nconst ISOLATE_MARSHAL_CODE = `\n(function() {\n // Marshal a value (JavaScript → Ref)\n function marshalForHost(value, depth = 0) {\n if (depth > 100) throw new Error('Maximum marshalling depth exceeded');\n\n if (value === null) return null;\n if (value === undefined) return { __type: 'UndefinedRef' };\n\n const type = typeof value;\n if (type === 'string' || type === 'number' || type === 'boolean') return value;\n if (type === 'bigint') return { __type: 'BigIntRef', value: value.toString() };\n if (type === 'function') throw new Error('Cannot marshal functions from isolate');\n if (type === 'symbol') throw new Error('Cannot marshal Symbol values');\n\n if (type === 'object') {\n if (value instanceof Date) {\n return { __type: 'DateRef', timestamp: value.getTime() };\n }\n if (value instanceof RegExp) {\n return { __type: 'RegExpRef', source: value.source, flags: value.flags };\n }\n if (value instanceof URL) {\n return { __type: 'URLRef', href: value.href };\n }\n if (typeof Headers !== 'undefined' && value instanceof Headers) {\n const pairs = [];\n value.forEach((v, k) => pairs.push([k, v]));\n return { __type: 'HeadersRef', pairs };\n }\n if (value instanceof Uint8Array) {\n return { __type: 'Uint8ArrayRef', data: Array.from(value) };\n }\n if (value instanceof ArrayBuffer) {\n return { __type: 'Uint8ArrayRef', data: Array.from(new Uint8Array(value)) };\n }\n if (typeof Request !== 'undefined' && value instanceof Request) {\n throw new Error('Cannot marshal Request from isolate. Use fetch callback instead.');\n }\n if (typeof Response !== 'undefined' && value instanceof Response) {\n throw new Error('Cannot marshal Response from isolate. Return plain objects instead.');\n }\n if (typeof File !== 'undefined' && value instanceof File) {\n throw new Error('Cannot marshal File from isolate.');\n }\n if (typeof Blob !== 'undefined' && value instanceof Blob) {\n throw new Error('Cannot marshal Blob from isolate.');\n }\n if (typeof FormData !== 'undefined' && value instanceof FormData) {\n throw new Error('Cannot marshal FormData from isolate.');\n }\n if (Array.isArray(value)) {\n return value.map(v => marshalForHost(v, depth + 1));\n }\n // Plain object\n const result = {};\n for (const key of Object.keys(value)) {\n result[key] = marshalForHost(value[key], depth + 1);\n }\n return result;\n }\n return value;\n }\n\n // Unmarshal a value (Ref → JavaScript)\n function unmarshalFromHost(value, depth = 0) {\n if (depth > 100) throw new Error('Maximum unmarshalling depth exceeded');\n\n if (value === null) return null;\n if (typeof value !== 'object') return value;\n\n if (value.__type) {\n switch (value.__type) {\n case 'UndefinedRef': return undefined;\n case 'DateRef': return new Date(value.timestamp);\n case 'RegExpRef': return new RegExp(value.source, value.flags);\n case 'BigIntRef': return BigInt(value.value);\n case 'URLRef': return new URL(value.href);\n case 'HeadersRef': return new Headers(value.pairs);\n case 'Uint8ArrayRef': return new Uint8Array(value.data);\n case 'RequestRef': {\n const init = {\n method: value.method,\n headers: value.headers,\n body: value.body ? new Uint8Array(value.body) : null,\n };\n if (value.mode) init.mode = value.mode;\n if (value.credentials) init.credentials = value.credentials;\n if (value.cache) init.cache = value.cache;\n if (value.redirect) init.redirect = value.redirect;\n if (value.referrer) init.referrer = value.referrer;\n if (value.referrerPolicy) init.referrerPolicy = value.referrerPolicy;\n if (value.integrity) init.integrity = value.integrity;\n return new Request(value.url, init);\n }\n case 'ResponseRef': {\n return new Response(value.body ? new Uint8Array(value.body) : null, {\n status: value.status,\n statusText: value.statusText,\n headers: value.headers,\n });\n }\n case 'FileRef': {\n if (!value.name) {\n return new Blob([new Uint8Array(value.data)], { type: value.type });\n }\n return new File([new Uint8Array(value.data)], value.name, {\n type: value.type,\n lastModified: value.lastModified,\n });\n }\n case 'FormDataRef': {\n const fd = new FormData();\n for (const [key, entry] of value.entries) {\n if (typeof entry === 'string') {\n fd.append(key, entry);\n } else {\n const file = unmarshalFromHost(entry, depth + 1);\n fd.append(key, file);\n }\n }\n return fd;\n }\n case 'CallbackRef': {\n // Create a proxy function that invokes the callback\n const callbackId = value.callbackId;\n return function(...args) {\n const argsJson = JSON.stringify(marshalForHost(args));\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [callbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n }\n case 'PromiseRef': {\n // Create a proxy Promise that resolves via callback\n const promiseId = value.promiseId;\n return new Promise((resolve, reject) => {\n try {\n const argsJson = JSON.stringify([promiseId]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [value.__resolveCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (result.ok) {\n resolve(unmarshalFromHost(result.value));\n } else {\n reject(new Error(result.error.message));\n }\n } catch (e) {\n reject(e);\n }\n });\n }\n case 'AsyncIteratorRef': {\n const iteratorId = value.iteratorId;\n const nextCallbackId = value.__nextCallbackId;\n const returnCallbackId = value.__returnCallbackId;\n return {\n [Symbol.asyncIterator]() { return this; },\n async next() {\n const argsJson = JSON.stringify([iteratorId]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [nextCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (!result.ok) {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n return {\n done: result.value.done,\n value: unmarshalFromHost(result.value.value)\n };\n },\n async return(v) {\n const argsJson = JSON.stringify([iteratorId, marshalForHost(v)]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [returnCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n return { done: true, value: result.ok ? unmarshalFromHost(result.value) : undefined };\n }\n };\n }\n default:\n // Unknown ref type, return as-is\n break;\n }\n }\n\n if (Array.isArray(value)) {\n return value.map(v => unmarshalFromHost(v, depth + 1));\n }\n\n // Plain object - recursively unmarshal\n const result = {};\n for (const key of Object.keys(value)) {\n result[key] = unmarshalFromHost(value[key], depth + 1);\n }\n return result;\n }\n\n // Expose as globals\n globalThis.__marshalForHost = marshalForHost;\n globalThis.__unmarshalFromHost = unmarshalFromHost;\n})();\n`;\n\n// CustomFunctionsMarshalOptions is exported at the top of the file\n\n/**\n * Setup custom functions as globals in the isolate context.\n * Each function directly calls the host callback when invoked.\n *\n * When marshalOptions is provided, returned values are marshalled with a MarshalContext,\n * enabling proper proxying of callbacks/promises/iterators across boundaries.\n */\nasync function setupCustomFunctions(\n context: ivm.Context,\n customFunctions: CustomFunctions,\n marshalOptions?: CustomFunctionsMarshalOptions,\n): Promise<ivm.Reference<(name: string, argsJson: string) => Promise<string>>> {\n const global = context.global;\n\n // Reference that invokes the callback and returns the result.\n // The first argument can be a string function name (for custom functions) or a\n // numeric callback ID (for returned callbacks/promises/iterators from marshal).\n const invokeCallbackRef = new ivm.Reference(\n async (nameOrId: string | number, argsJson: string): Promise<string> => {\n // Check if this is a local callback ID (numeric, used by returned callbacks/promises/iterators)\n if (typeof nameOrId === \"number\" && marshalOptions) {\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n try {\n const result = await marshalOptions.invokeCallback(nameOrId, args);\n const ctx = marshalOptions.createMarshalContext();\n const marshalledResult = await marshalValue(result, ctx);\n const processedResult = marshalOptions.addCallbackIdsToRefs(marshalledResult);\n return JSON.stringify({ ok: true, value: processedResult });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n\n const name = String(nameOrId);\n const def = customFunctions[name];\n if (!def) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Custom function '${name}' not found`,\n name: \"Error\",\n },\n });\n }\n // Unmarshal args from isolate (converts Refs back to JavaScript types)\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n try {\n // Always await the result: for daemon-bridged functions, even \"sync\" custom functions\n // are async due to IPC, so we need to resolve the promise.\n const result = await def.fn(...args);\n // Marshal result for isolate (converts JavaScript types to Refs)\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n const marshalledResult = await marshalValue(result, ctx);\n const processedResult = marshalOptions.addCallbackIdsToRefs(marshalledResult);\n return JSON.stringify({ ok: true, value: processedResult });\n }\n const marshalledResult = await marshalValue(result);\n return JSON.stringify({ ok: true, value: marshalledResult });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__customFn_invoke\", invokeCallbackRef);\n\n // Iterator start: creates iterator, stores in session, returns iteratorId\n const iterStartRef = new ivm.Reference(\n async (name: string, argsJson: string): Promise<string> => {\n const def = customFunctions[name];\n if (!def || def.type !== \"asyncIterator\") {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Async iterator function '${name}' not found`,\n name: \"Error\",\n },\n });\n }\n try {\n // Unmarshal args from isolate\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n const fn = def.fn as CustomAsyncGeneratorFunction;\n const iterator = fn(...args);\n const iteratorId = nextIteratorId++;\n iteratorSessions.set(iteratorId, { iterator });\n return JSON.stringify({ ok: true, iteratorId });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_start\", iterStartRef);\n\n // Iterator next: calls iterator.next(), returns {done, value}\n const iterNextRef = new ivm.Reference(\n async (iteratorId: number): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Iterator session ${iteratorId} not found`,\n name: \"Error\",\n },\n });\n }\n try {\n const result = await session.iterator.next();\n if (result.done) {\n iteratorSessions.delete(iteratorId);\n }\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result.value);\n }\n return JSON.stringify({\n ok: true,\n done: result.done,\n value: marshalledValue,\n });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_next\", iterNextRef);\n\n // Iterator return: calls iterator.return(), cleans up session\n const iterReturnRef = new ivm.Reference(\n async (iteratorId: number, valueJson: string): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({ ok: true, done: true, value: undefined });\n }\n try {\n // Unmarshal value from isolate\n const rawValue = valueJson ? JSON.parse(valueJson) : undefined;\n const value = unmarshalValue(rawValue);\n const result = await session.iterator.return?.(value);\n iteratorSessions.delete(iteratorId);\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result?.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result?.value);\n }\n return JSON.stringify({ ok: true, done: true, value: marshalledValue });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_return\", iterReturnRef);\n\n // Iterator throw: calls iterator.throw(), cleans up session\n const iterThrowRef = new ivm.Reference(\n async (iteratorId: number, errorJson: string): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Iterator session ${iteratorId} not found`,\n name: \"Error\",\n },\n });\n }\n try {\n const errorData = JSON.parse(errorJson) as {\n message: string;\n name: string;\n };\n const error = Object.assign(new Error(errorData.message), {\n name: errorData.name,\n });\n const result = await session.iterator.throw?.(error);\n iteratorSessions.delete(iteratorId);\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result?.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result?.value);\n }\n return JSON.stringify({\n ok: true,\n done: result?.done ?? true,\n value: marshalledValue,\n });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_throw\", iterThrowRef);\n\n // Inject marshalling helpers into the isolate\n context.evalSync(ISOLATE_MARSHAL_CODE);\n\n // Create wrapper functions for each custom function\n for (const name of Object.keys(customFunctions)) {\n const def = customFunctions[name]!;\n\n if (def.type === \"async\") {\n // Async function: use applySyncPromise and async function wrapper\n context.evalSync(`\n globalThis.${name} = async function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const resultJson = __customFn_invoke.applySyncPromise(\n undefined,\n [\"${name}\", JSON.stringify(marshalledArgs)]\n );\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return __unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n `);\n } else if (def.type === \"sync\") {\n // Sync function: use applySyncPromise (to await the host) but wrap in regular function\n // The function blocks until the host responds, but returns the value directly (not a Promise)\n context.evalSync(`\n globalThis.${name} = function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const resultJson = __customFn_invoke.applySyncPromise(\n undefined,\n [\"${name}\", JSON.stringify(marshalledArgs)]\n );\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return __unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n `);\n } else if (def.type === \"asyncIterator\") {\n // Async iterator function: returns an async iterable object\n context.evalSync(`\n globalThis.${name} = function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const startResult = JSON.parse(__iter_start.applySyncPromise(undefined, [\"${name}\", JSON.stringify(marshalledArgs)]));\n if (!startResult.ok) {\n throw Object.assign(new Error(startResult.error.message), { name: startResult.error.name });\n }\n const iteratorId = startResult.iteratorId;\n return {\n [Symbol.asyncIterator]() { return this; },\n async next() {\n const result = JSON.parse(__iter_next.applySyncPromise(undefined, [iteratorId]));\n if (!result.ok) {\n throw Object.assign(new Error(result.error.message), { name: result.error.name });\n }\n return { done: result.done, value: __unmarshalFromHost(result.value) };\n },\n async return(v) {\n const result = JSON.parse(__iter_return.applySyncPromise(undefined, [iteratorId, JSON.stringify(__marshalForHost(v))]));\n return { done: true, value: __unmarshalFromHost(result.value) };\n },\n async throw(e) {\n const result = JSON.parse(__iter_throw.applySyncPromise(undefined, [iteratorId, JSON.stringify({ message: e.message, name: e.name })]));\n if (!result.ok) {\n throw Object.assign(new Error(result.error.message), { name: result.error.name });\n }\n return { done: result.done, value: __unmarshalFromHost(result.value) };\n }\n };\n };\n `);\n }\n }\n\n return invokeCallbackRef;\n}\n\n/**\n * Create local marshal options for standalone runtime custom functions.\n * Enables returned callbacks/promises/iterators without daemon IPC.\n */\nfunction createLocalCustomFunctionsMarshalOptions(): CustomFunctionsMarshalOptions {\n const returnedCallbacks = new Map<number, Function>();\n const returnedPromises = new Map<number, Promise<unknown>>();\n const returnedIterators = new Map<number, AsyncIterator<unknown>>();\n let nextLocalCallbackId = 1_000_000;\n\n const createMarshalContext = (): MarshalContext => ({\n registerCallback: (fn: Function): number => {\n const callbackId = nextLocalCallbackId++;\n returnedCallbacks.set(callbackId, fn);\n return callbackId;\n },\n registerPromise: (promise: Promise<unknown>): number => {\n const promiseId = nextLocalCallbackId++;\n returnedPromises.set(promiseId, promise);\n return promiseId;\n },\n registerIterator: (iterator: AsyncIterator<unknown>): number => {\n const iteratorId = nextLocalCallbackId++;\n returnedIterators.set(iteratorId, iterator);\n return iteratorId;\n },\n });\n\n const isPromiseRef = (\n value: unknown\n ): value is { __type: \"PromiseRef\"; promiseId: number } =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { __type?: string }).__type === \"PromiseRef\";\n\n const isAsyncIteratorRef = (\n value: unknown\n ): value is { __type: \"AsyncIteratorRef\"; iteratorId: number } =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { __type?: string }).__type === \"AsyncIteratorRef\";\n\n const addCallbackIdsToRefs = (value: unknown): unknown => {\n if (value === null || typeof value !== \"object\") return value;\n\n if (isPromiseRef(value)) {\n if (\"__resolveCallbackId\" in value) return value;\n\n const resolveCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(resolveCallbackId, async (promiseId: number) => {\n const promise = returnedPromises.get(promiseId);\n if (!promise) {\n throw new Error(`Promise ${promiseId} not found`);\n }\n const result = await promise;\n returnedPromises.delete(promiseId);\n const ctx = createMarshalContext();\n const marshalled = await marshalValue(result, ctx);\n return addCallbackIdsToRefs(marshalled);\n });\n\n return { ...value, __resolveCallbackId: resolveCallbackId };\n }\n\n if (isAsyncIteratorRef(value)) {\n if (\"__nextCallbackId\" in value) return value;\n\n const nextCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(nextCallbackId, async (iteratorId: number) => {\n const iterator = returnedIterators.get(iteratorId);\n if (!iterator) {\n throw new Error(`Iterator ${iteratorId} not found`);\n }\n const result = await iterator.next();\n if (result.done) {\n returnedIterators.delete(iteratorId);\n }\n const ctx = createMarshalContext();\n const marshalledValue = await marshalValue(result.value, ctx);\n return {\n done: result.done,\n value: addCallbackIdsToRefs(marshalledValue),\n };\n });\n\n const returnCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(\n returnCallbackId,\n async (iteratorId: number, returnValue?: unknown) => {\n const iterator = returnedIterators.get(iteratorId);\n returnedIterators.delete(iteratorId);\n if (!iterator || !iterator.return) {\n return { done: true, value: undefined };\n }\n const result = await iterator.return(returnValue);\n const ctx = createMarshalContext();\n const marshalledValue = await marshalValue(result.value, ctx);\n return {\n done: true,\n value: addCallbackIdsToRefs(marshalledValue),\n };\n }\n );\n\n return {\n ...value,\n __nextCallbackId: nextCallbackId,\n __returnCallbackId: returnCallbackId,\n };\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => addCallbackIdsToRefs(item));\n }\n\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(value)) {\n result[key] = addCallbackIdsToRefs(\n (value as Record<string, unknown>)[key]\n );\n }\n return result;\n };\n\n const invokeCallback = async (\n callbackId: number,\n args: unknown[]\n ): Promise<unknown> => {\n const callback = returnedCallbacks.get(callbackId);\n if (!callback) {\n throw new Error(`Local callback ${callbackId} not found`);\n }\n return await callback(...args);\n };\n\n return { createMarshalContext, addCallbackIdsToRefs, invokeCallback };\n}\n\n/**\n * Create a module resolver function for local execution.\n */\nfunction createModuleResolver(\n state: RuntimeState\n): (specifier: string, referrer: ivm.Module) => Promise<ivm.Module> {\n return async (\n specifier: string,\n referrer: ivm.Module\n ): Promise<ivm.Module> => {\n // Get importer info\n const importerPath = state.moduleToFilename.get(referrer) ?? \"<unknown>\";\n const importerResolveDir = path.posix.dirname(importerPath);\n const importerStack = state.moduleImportChain.get(importerPath) ?? [];\n\n // Resolve relative specifiers to absolute-like paths for cache key uniqueness.\n // This prevents cross-package collisions (e.g. two different packages both importing \"./utils.js\").\n const resolvedSpecifier = specifier.startsWith('.')\n ? path.posix.normalize(path.posix.join(importerResolveDir, specifier))\n : specifier;\n\n // Track who imports this specifier (for error diagnostics)\n state.specifierToImporter.set(resolvedSpecifier, importerPath);\n\n // Static cache first\n const staticCached = state.staticModuleCache.get(resolvedSpecifier);\n if (staticCached) return staticCached;\n\n const cached = state.moduleCache.get(resolvedSpecifier);\n if (cached) return cached;\n\n if (!state.moduleLoader) {\n throw new Error(\n `No module loader registered. Cannot import: ${specifier}`\n );\n }\n\n // Invoke module loader - capture full result including static flag\n const result = await state.moduleLoader(specifier, {\n path: importerPath,\n resolveDir: importerResolveDir,\n });\n const { code, resolveDir } = result;\n\n // Validate filename: must be a basename (no slashes)\n if (result.filename.includes('/')) {\n throw new Error(\n `moduleLoader returned a filename with slashes: \"${result.filename}\". ` +\n `filename must be a basename (e.g. \"utils.js\"), not a path.`\n );\n }\n\n // Construct resolved filename using result.filename\n const resolvedFilename = path.posix.join(resolveDir, result.filename);\n\n // Cache by specifier + content hash (allows invalidation when content changes)\n const hash = contentHash(code);\n const cacheKey = `${resolvedSpecifier}:${hash}`;\n const inFlightKey = `${result.static ? \"static\" : \"dynamic\"}:${cacheKey}`;\n\n // Cache checks again after await in case another resolver call won the race\n const staticCachedAfterLoad = state.staticModuleCache.get(resolvedSpecifier);\n if (staticCachedAfterLoad) return staticCachedAfterLoad;\n\n const cachedAfterLoad = state.moduleCache.get(resolvedSpecifier);\n if (cachedAfterLoad) return cachedAfterLoad;\n\n const hashCached = state.moduleCache.get(cacheKey);\n if (hashCached) return hashCached;\n\n const inFlight = state.moduleLoadsInFlight.get(inFlightKey);\n if (inFlight) return inFlight;\n\n const loadPromise = (async (): Promise<ivm.Module> => {\n let mod: ivm.Module | undefined;\n try {\n // Transform cache — check transform cache first (survives reuse in daemon)\n let transformed: TransformResult | undefined = state.transformCache.get(hash);\n if (!transformed) {\n transformed = await transformModuleCode(code, resolvedSpecifier);\n state.transformCache.set(hash, transformed);\n }\n\n if (transformed.sourceMap) {\n state.sourceMaps.set(resolvedSpecifier, transformed.sourceMap);\n }\n\n // Compile the module using resolvedSpecifier as filename\n mod = await state.isolate.compileModule(transformed.code, {\n filename: resolvedSpecifier,\n });\n\n // Track resolved filename for nested imports\n state.moduleToFilename.set(mod, resolvedFilename);\n\n // Track import chain for error diagnostics\n state.moduleImportChain.set(resolvedFilename, [...importerStack, importerPath]);\n\n // Cache the compiled module before linker uses it (supports circular deps)\n if (result.static) {\n state.staticModuleCache.set(resolvedSpecifier, mod);\n } else {\n state.moduleCache.set(resolvedSpecifier, mod);\n state.moduleCache.set(cacheKey, mod);\n }\n\n return mod;\n } catch (err) {\n // Annotate error with module resolution context\n const error = err instanceof Error ? err : new Error(String(err));\n error.message = `Failed to compile module \"${resolvedSpecifier}\" (imported by \"${importerPath}\"):\\n${error.message}`;\n if (importerStack.length > 0) {\n error.message += `\\n\\nImport chain:\\n ${[...importerStack, importerPath].join('\\n -> ')}`;\n }\n\n // Remove partial cache state to avoid returning poisoned module entries later.\n if (mod) {\n state.moduleToFilename.delete(mod);\n if (result.static) {\n if (state.staticModuleCache.get(resolvedSpecifier) === mod) {\n state.staticModuleCache.delete(resolvedSpecifier);\n }\n } else {\n if (state.moduleCache.get(resolvedSpecifier) === mod) {\n state.moduleCache.delete(resolvedSpecifier);\n }\n if (state.moduleCache.get(cacheKey) === mod) {\n state.moduleCache.delete(cacheKey);\n }\n }\n }\n throw error;\n }\n })();\n\n state.moduleLoadsInFlight.set(inFlightKey, loadPromise);\n try {\n return await loadPromise;\n } finally {\n state.moduleLoadsInFlight.delete(inFlightKey);\n }\n };\n}\n\n/**\n * Convert FetchCallback to FetchOptions\n */\nfunction convertFetchCallback(callback?: FetchCallback): FetchOptions {\n if (!callback) {\n return {};\n }\n return {\n onFetch: async (url: string, init: FetchRequestInit): Promise<Response> => {\n // Wrap the result in a Promise to handle both sync and async callbacks\n return Promise.resolve(callback(url, init));\n },\n };\n}\n\n/**\n * Create a fully configured isolated-vm runtime\n *\n * Sets up all WHATWG APIs: fetch, fs, console, crypto, encoding, timers\n *\n * @example\n * const runtime = await createRuntime({\n * console: { log: (...args) => console.log(\"[isolate]\", ...args) },\n * fetch: async (request) => fetch(request),\n * });\n *\n * await runtime.eval(`\n * console.log(\"Hello from sandbox!\");\n * const response = await fetch(\"https://example.com\");\n * `);\n *\n * await runtime.dispose();\n */\nexport async function createRuntime<T extends Record<string, any[]> = Record<string, unknown[]>>(\n options?: RuntimeOptions<T>\n): Promise<RuntimeHandle> {\n const opts = options ?? {};\n\n // Generate unique ID\n const id = crypto.randomUUID();\n\n // Create isolate with optional memory limit\n const isolate = new ivm.Isolate({\n memoryLimit: opts.memoryLimitMB,\n });\n const context = await isolate.createContext();\n\n // Initialize state\n const state: RuntimeState = {\n isolate,\n context,\n handles: {},\n moduleCache: new Map(),\n staticModuleCache: new Map(),\n moduleLoadsInFlight: new Map(),\n transformCache: new Map(),\n moduleToFilename: new Map(),\n sourceMaps: new Map(),\n moduleImportChain: new Map(),\n specifierToImporter: new Map(),\n pendingCallbacks: [],\n evalChain: Promise.resolve(),\n moduleLoader: opts.moduleLoader,\n customFunctions: opts.customFunctions as CustomFunctions<Record<string, unknown[]>>,\n };\n\n // Setup all APIs in order\n // Core must be first as it provides Blob, File, streams, URL, etc.\n state.handles.core = await setupCore(context);\n\n // Console\n state.handles.console = await setupConsole(context, opts.console);\n\n // Encoding (btoa/atob) and Buffer\n state.handles.encoding = await setupEncoding(context);\n\n // Timers (setTimeout, setInterval)\n state.handles.timers = await setupTimers(context);\n\n // Path module\n state.handles.path = await setupPath(context, { cwd: opts.cwd });\n\n // Crypto (randomUUID, getRandomValues)\n state.handles.crypto = await setupCrypto(context);\n\n // Fetch API - convert callback to options\n state.handles.fetch = await setupFetch(\n context,\n convertFetchCallback(opts.fetch)\n );\n\n // File system (only if handler provided)\n if (opts.fs) {\n state.handles.fs = await setupFs(context, opts.fs);\n }\n\n // Setup custom functions\n if (opts.customFunctions) {\n const customMarshalOptions =\n opts.customFunctionsMarshalOptions ??\n createLocalCustomFunctionsMarshalOptions();\n\n state.customFnInvokeRef = await setupCustomFunctions(\n context,\n opts.customFunctions as CustomFunctions<Record<string, unknown[]>>,\n customMarshalOptions,\n );\n }\n\n // Setup test environment (if enabled)\n if (opts.testEnvironment) {\n const testEnvOptions: TestEnvironmentOptions | undefined =\n typeof opts.testEnvironment === \"object\"\n ? opts.testEnvironment\n : undefined;\n state.handles.testEnvironment = await setupTestEnvironment(\n context,\n testEnvOptions\n );\n }\n\n // Setup playwright - AFTER test environment so expect can be extended\n if (opts.playwright) {\n if (!opts.playwright.handler) {\n throw new Error(\n \"Playwright configured without handler. Provide playwright.handler in createRuntime options.\"\n );\n }\n\n // Determine event handler\n // If console: true and we have a console handler, wrap onEvent to route browser logs\n let eventCallback = opts.playwright.onEvent;\n\n if (opts.playwright.console && opts.console?.onEntry) {\n const originalCallback = eventCallback;\n const consoleHandler = opts.console.onEntry;\n eventCallback = (event) => {\n // Call original callback if provided\n if (originalCallback) {\n originalCallback(event);\n }\n // Route browser console logs through console handler as browserOutput entry\n if (event.type === \"browserConsoleLog\") {\n consoleHandler({\n type: \"browserOutput\",\n level: event.level,\n stdout: event.stdout,\n timestamp: event.timestamp,\n });\n }\n };\n }\n\n const playwrightSetupOptions: PlaywrightSetupOptions = {\n handler: opts.playwright.handler,\n timeout: opts.playwright.timeout,\n // Don't print directly if routing through console handler\n console: opts.playwright.console && !opts.console?.onEntry,\n onEvent: eventCallback,\n };\n\n state.handles.playwright = await setupPlaywright(context, playwrightSetupOptions);\n }\n\n // Create fetch handle wrapper\n const fetchHandle: RuntimeFetchHandle = {\n async dispatchRequest(\n request: Request,\n options?: DispatchRequestOptions\n ): Promise<Response> {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.dispatchRequest(request, options);\n },\n getUpgradeRequest() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.getUpgradeRequest();\n },\n dispatchWebSocketOpen(connectionId: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketOpen(connectionId);\n },\n dispatchWebSocketMessage(\n connectionId: string,\n message: string | ArrayBuffer\n ) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketMessage(connectionId, message);\n },\n dispatchWebSocketClose(connectionId: string, code: number, reason: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketClose(connectionId, code, reason);\n },\n dispatchWebSocketError(connectionId: string, error: Error) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketError(connectionId, error);\n },\n onWebSocketCommand(callback: (cmd: WebSocketCommand) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onWebSocketCommand(callback);\n },\n hasServeHandler() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.hasServeHandler();\n },\n hasActiveConnections() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.hasActiveConnections();\n },\n dispatchClientWebSocketOpen(socketId: string, protocol: string, extensions: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketOpen(socketId, protocol, extensions);\n },\n dispatchClientWebSocketMessage(socketId: string, data: string | ArrayBuffer) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketMessage(socketId, data);\n },\n dispatchClientWebSocketClose(socketId: string, code: number, reason: string, wasClean: boolean) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketClose(socketId, code, reason, wasClean);\n },\n dispatchClientWebSocketError(socketId: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketError(socketId);\n },\n onClientWebSocketCommand(callback: (cmd: ClientWebSocketCommand) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onClientWebSocketCommand(callback);\n },\n onEvent(callback: (event: string, payload: unknown) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onEvent(callback);\n },\n dispatchEvent(event: string, payload: unknown) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchEvent(event, payload);\n },\n };\n\n // Create timers handle wrapper\n const timersHandle: RuntimeTimersHandle = {\n clearAll() {\n state.handles.timers?.clearAll();\n },\n };\n\n // Create console handle wrapper\n const consoleHandle: RuntimeConsoleHandle = {\n reset() {\n state.handles.console?.reset();\n },\n getTimers() {\n return state.handles.console?.getTimers() ?? new Map();\n },\n getCounters() {\n return state.handles.console?.getCounters() ?? new Map();\n },\n getGroupDepth() {\n return state.handles.console?.getGroupDepth() ?? 0;\n },\n };\n\n // Create test environment handle wrapper\n const testEnvironmentHandle: RuntimeTestEnvironmentHandle = {\n async runTests(timeout?: number): Promise<RunResults> {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n\n if (timeout === undefined) {\n return runTestsInContext(state.context);\n }\n\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => reject(new Error(\"Test timeout\")), timeout);\n });\n\n try {\n return await Promise.race([\n runTestsInContext(state.context),\n timeoutPromise,\n ]);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n },\n hasTests(): boolean {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n return hasTestsInContext(state.context);\n },\n getTestCount(): number {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n return getTestCountInContext(state.context);\n },\n reset() {\n state.handles.testEnvironment?.dispose();\n },\n };\n\n // Create playwright handle wrapper\n const playwrightHandle: RuntimePlaywrightHandle = {\n getCollectedData(): CollectedData {\n if (!state.handles.playwright) {\n throw new Error(\n \"Playwright not configured. Provide playwright.handler in createRuntime options.\"\n );\n }\n return {\n browserConsoleLogs: state.handles.playwright.getBrowserConsoleLogs(),\n networkRequests: state.handles.playwright.getNetworkRequests(),\n networkResponses: state.handles.playwright.getNetworkResponses(),\n };\n },\n clearCollectedData() {\n state.handles.playwright?.clearCollected();\n },\n };\n\n return {\n id,\n pendingCallbacks: state.pendingCallbacks,\n\n // Module handles\n fetch: fetchHandle,\n timers: timersHandle,\n console: consoleHandle,\n testEnvironment: testEnvironmentHandle,\n playwright: playwrightHandle,\n\n async eval(\n code: string,\n filenameOrOptions?: string | EvalOptions\n ): Promise<void> {\n const runEval = async (): Promise<void> => {\n // Parse options\n const options =\n typeof filenameOrOptions === \"string\"\n ? { filename: filenameOrOptions }\n : filenameOrOptions;\n\n // Normalize filename to absolute path for module resolution\n const filename = normalizeEntryFilename(options?.filename);\n\n try {\n // Transform entry code: strip types, validate, wrap in async function\n const transformed = await transformEntryCode(code, filename);\n if (transformed.sourceMap) {\n state.sourceMaps.set(filename, transformed.sourceMap);\n }\n\n // Compile as ES module\n const mod = await state.isolate.compileModule(transformed.code, {\n filename,\n });\n\n // Track entry module filename and import chain\n state.moduleToFilename.set(mod, filename);\n state.moduleImportChain.set(filename, []);\n\n // Instantiate with module resolver\n const resolver = createModuleResolver(state);\n try {\n await mod.instantiate(state.context, resolver);\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n\n // Extract failing module specifier and export name from V8 error\n // e.g. \"The requested module './foo' does not provide an export named 'Bar'\"\n const specifierMatch = error.message.match(/The requested module '([^']+)'/);\n const exportMatch = error.message.match(/export named '([^']+)'/);\n const failingSpecifier = specifierMatch?.[1];\n const failingExport = exportMatch?.[1];\n\n // Find which file imports the failing specifier\n const importerFile = failingSpecifier\n ? state.specifierToImporter.get(failingSpecifier)\n : undefined;\n\n // Build the full import chain from entry → importer → failing module\n const details: string[] = [];\n\n if (importerFile) {\n const chain = state.moduleImportChain.get(importerFile) ?? [];\n const fullChain = [...chain, importerFile];\n if (failingSpecifier) fullChain.push(failingSpecifier);\n const trimmed = fullChain.length > 12 ? fullChain.slice(-12) : fullChain;\n const prefix = fullChain.length > 12 ? ' ...\\n' : '';\n details.push('Import chain:\\n' + prefix + trimmed.map(p => ` ${p}`).join('\\n -> '));\n } else if (failingSpecifier) {\n // Fallback: search moduleImportChain for any path containing the specifier\n for (const [modPath, chain] of state.moduleImportChain) {\n if (modPath.includes(failingSpecifier) || modPath.endsWith(failingSpecifier)) {\n const fullChain = [...chain, modPath];\n const trimmed = fullChain.length > 12 ? fullChain.slice(-12) : fullChain;\n details.push('Import chain:\\n' + trimmed.map(p => ` ${p}`).join('\\n -> '));\n break;\n }\n }\n }\n\n if (failingExport && failingSpecifier) {\n details.push(\n `Hint: If '${failingExport}' is a TypeScript type/interface, use \\`import type\\` to prevent it from being resolved at runtime:\\n` +\n ` import type { ${failingExport} } from '${failingSpecifier}';`\n );\n }\n\n const suffix = details.length > 0 ? '\\n\\n' + details.join('\\n\\n') : '';\n error.message = `Module instantiation failed: ${error.message}${suffix}`;\n throw error;\n }\n\n // Evaluate - only resolves imports and defines the default function (no timeout needed)\n await mod.evaluate();\n\n // Get the default export and run it with timeout\n const ns = mod.namespace;\n const runRef = await ns.get(\"default\", { reference: true });\n try {\n await runRef.apply(undefined, [], {\n result: { promise: true },\n });\n } finally {\n runRef.release();\n }\n\n // Await pending callbacks (no-op for local use, enables daemon IPC flush)\n if (state.pendingCallbacks.length > 0) {\n await Promise.all(state.pendingCallbacks);\n state.pendingCallbacks.length = 0;\n }\n } catch (err) {\n const error = err as Error;\n if (error.stack && state.sourceMaps.size > 0) {\n error.stack = mapErrorStack(error.stack, state.sourceMaps);\n }\n throw error;\n }\n };\n\n const queuedEval = state.evalChain.then(runEval, runEval);\n state.evalChain = queuedEval.then(\n () => undefined,\n () => undefined\n );\n return queuedEval;\n },\n\n clearModuleCache() {\n state.moduleCache.clear();\n state.moduleLoadsInFlight.clear();\n state.moduleToFilename.clear();\n state.moduleImportChain.clear();\n state.specifierToImporter.clear();\n state.sourceMaps.clear();\n // staticModuleCache and transformCache intentionally preserved\n },\n\n async dispose(): Promise<void> {\n // Dispose custom function reference\n if (state.customFnInvokeRef) {\n state.customFnInvokeRef.release();\n }\n\n // Dispose all handles (in reverse order of setup)\n state.handles.playwright?.dispose();\n state.handles.testEnvironment?.dispose();\n state.handles.fs?.dispose();\n state.handles.fetch?.dispose();\n state.handles.crypto?.dispose();\n state.handles.path?.dispose();\n state.handles.timers?.dispose();\n state.handles.encoding?.dispose();\n state.handles.console?.dispose();\n state.handles.core?.dispose();\n\n // Clear module cache\n state.moduleCache.clear();\n state.moduleLoadsInFlight.clear();\n\n // Release context and dispose isolate\n state.context.release();\n state.isolate.dispose();\n },\n };\n}\n\n// Re-export all package types and functions\nexport { setupCore } from \"@ricsam/isolate-core\";\nexport type { CoreHandle, SetupCoreOptions } from \"@ricsam/isolate-core\";\n\nexport { setupConsole } from \"@ricsam/isolate-console\";\nexport {\n simpleConsoleHandler,\n type SimpleConsoleCallbacks,\n} from \"@ricsam/isolate-console/utils\";\nexport type {\n ConsoleHandle,\n ConsoleOptions,\n ConsoleEntry as ConsoleEntryFromConsole,\n} from \"@ricsam/isolate-console\";\n\nexport { setupCrypto } from \"@ricsam/isolate-crypto\";\nexport type { CryptoHandle } from \"@ricsam/isolate-crypto\";\n\nexport { setupEncoding } from \"@ricsam/isolate-encoding\";\nexport type { EncodingHandle } from \"@ricsam/isolate-encoding\";\n\nexport { setupFetch } from \"@ricsam/isolate-fetch\";\nexport type {\n FetchHandle,\n FetchOptions,\n WebSocketCommand,\n UpgradeRequest,\n ClientWebSocketCommand,\n} from \"@ricsam/isolate-fetch\";\n\nexport { setupFs, createNodeFileSystemHandler } from \"@ricsam/isolate-fs\";\nexport type {\n FsHandle,\n FsOptions,\n FileSystemHandler,\n NodeFileSystemHandlerOptions,\n} from \"@ricsam/isolate-fs\";\n\nexport { setupPath } from \"@ricsam/isolate-path\";\nexport type { PathHandle, PathOptions } from \"@ricsam/isolate-path\";\n\nexport { setupTimers } from \"@ricsam/isolate-timers\";\nexport type { TimersHandle } from \"@ricsam/isolate-timers\";\n\nexport {\n setupTestEnvironment,\n runTests,\n hasTests,\n getTestCount,\n} from \"@ricsam/isolate-test-environment\";\nexport type {\n TestEnvironmentHandle,\n TestEnvironmentOptions,\n RunResults,\n TestResult,\n TestInfo,\n TestError,\n TestEvent,\n SuiteInfo,\n SuiteResult,\n} from \"@ricsam/isolate-test-environment\";\n\nexport {\n setupPlaywright,\n createPlaywrightHandler,\n defaultPlaywrightHandler,\n getDefaultPlaywrightHandlerMetadata,\n} from \"@ricsam/isolate-playwright\";\nexport type {\n PlaywrightHandle,\n PlaywrightSetupOptions,\n PlaywrightCallback,\n PlaywrightEvent,\n NetworkRequestInfo,\n NetworkResponseInfo,\n BrowserConsoleLogEntry,\n} from \"@ricsam/isolate-playwright\";\n"
6
6
  ],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAgB,IAAhB;AACiB,IAAjB;AAC0B,IAA1B;AACuC,IAAvC;AAQO,IAPP;AAUuC,IAAvC;AAC6B,IAA7B;AAC8B,IAA9B;AAC4B,IAA5B;AAC0B,IAA1B;AAC4B,IAA5B;AAC2B,IAA3B;AACwB,IAAxB;AAMO,IALP;AAUO,IAJP;AAyDO,IAJP;AAo+C0B,IAA1B;AAG6B,IAA7B;AAIO,IAHP;AAU4B,IAA5B;AAG8B,IAA9B;AAG2B,IAA3B;AASqD,IAArD;AAQ0B,IAA1B;AAG4B,IAA5B;AAQO,IALP;AAuBO,IALP;AA1zCA,IAAM,mBAAmB,IAAI;AAC7B,IAAI,iBAAiB;A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,MAG5B,MAAM,YAAY,MAAM;AAAA,MACxB,MAAM,oBAAoB,MAAM;AAAA,MAGhC,MAAM,QAAQ,QAAQ;AAAA,MACtB,MAAM,QAAQ,QAAQ;AAAA;AAAA,EAE1B;AAAA;",
8
+ "debugId": "AFA261ED8389256764756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/isolate-runtime",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "type": "commonjs"
5
5
  }
@@ -632,29 +632,36 @@ function createLocalCustomFunctionsMarshalOptions() {
632
632
  }
633
633
  function createModuleResolver(state) {
634
634
  return async (specifier, referrer) => {
635
- const staticCached = state.staticModuleCache.get(specifier);
635
+ const importerPath = state.moduleToFilename.get(referrer) ?? "<unknown>";
636
+ const importerResolveDir = path.posix.dirname(importerPath);
637
+ const importerStack = state.moduleImportChain.get(importerPath) ?? [];
638
+ const resolvedSpecifier = specifier.startsWith(".") ? path.posix.normalize(path.posix.join(importerResolveDir, specifier)) : specifier;
639
+ state.specifierToImporter.set(resolvedSpecifier, importerPath);
640
+ const staticCached = state.staticModuleCache.get(resolvedSpecifier);
636
641
  if (staticCached)
637
642
  return staticCached;
638
- const cached = state.moduleCache.get(specifier);
643
+ const cached = state.moduleCache.get(resolvedSpecifier);
639
644
  if (cached)
640
645
  return cached;
641
646
  if (!state.moduleLoader) {
642
647
  throw new Error(`No module loader registered. Cannot import: ${specifier}`);
643
648
  }
644
- const importerPath = state.moduleToFilename.get(referrer) ?? "<unknown>";
645
- const importerResolveDir = path.posix.dirname(importerPath);
646
649
  const result = await state.moduleLoader(specifier, {
647
650
  path: importerPath,
648
651
  resolveDir: importerResolveDir
649
652
  });
650
653
  const { code, resolveDir } = result;
654
+ if (result.filename.includes("/")) {
655
+ throw new Error(`moduleLoader returned a filename with slashes: "${result.filename}". ` + `filename must be a basename (e.g. "utils.js"), not a path.`);
656
+ }
657
+ const resolvedFilename = path.posix.join(resolveDir, result.filename);
651
658
  const hash = contentHash(code);
652
- const cacheKey = `${specifier}:${hash}`;
659
+ const cacheKey = `${resolvedSpecifier}:${hash}`;
653
660
  const inFlightKey = `${result.static ? "static" : "dynamic"}:${cacheKey}`;
654
- const staticCachedAfterLoad = state.staticModuleCache.get(specifier);
661
+ const staticCachedAfterLoad = state.staticModuleCache.get(resolvedSpecifier);
655
662
  if (staticCachedAfterLoad)
656
663
  return staticCachedAfterLoad;
657
- const cachedAfterLoad = state.moduleCache.get(specifier);
664
+ const cachedAfterLoad = state.moduleCache.get(resolvedSpecifier);
658
665
  if (cachedAfterLoad)
659
666
  return cachedAfterLoad;
660
667
  const hashCached = state.moduleCache.get(cacheKey);
@@ -668,41 +675,51 @@ function createModuleResolver(state) {
668
675
  try {
669
676
  let transformed = state.transformCache.get(hash);
670
677
  if (!transformed) {
671
- transformed = await transformModuleCode(code, specifier);
678
+ transformed = await transformModuleCode(code, resolvedSpecifier);
672
679
  state.transformCache.set(hash, transformed);
673
680
  }
674
681
  if (transformed.sourceMap) {
675
- state.sourceMaps.set(specifier, transformed.sourceMap);
682
+ state.sourceMaps.set(resolvedSpecifier, transformed.sourceMap);
676
683
  }
677
684
  mod = await state.isolate.compileModule(transformed.code, {
678
- filename: specifier
685
+ filename: resolvedSpecifier
679
686
  });
680
- const resolvedPath = path.posix.join(resolveDir, path.posix.basename(specifier));
681
- state.moduleToFilename.set(mod, resolvedPath);
687
+ state.moduleToFilename.set(mod, resolvedFilename);
688
+ state.moduleImportChain.set(resolvedFilename, [...importerStack, importerPath]);
682
689
  if (result.static) {
683
- state.staticModuleCache.set(specifier, mod);
690
+ state.staticModuleCache.set(resolvedSpecifier, mod);
684
691
  } else {
685
- state.moduleCache.set(specifier, mod);
692
+ state.moduleCache.set(resolvedSpecifier, mod);
686
693
  state.moduleCache.set(cacheKey, mod);
687
694
  }
688
695
  return mod;
689
696
  } catch (err) {
697
+ const error = err instanceof Error ? err : new Error(String(err));
698
+ error.message = `Failed to compile module "${resolvedSpecifier}" (imported by "${importerPath}"):
699
+ ${error.message}`;
700
+ if (importerStack.length > 0) {
701
+ error.message += `
702
+
703
+ Import chain:
704
+ ${[...importerStack, importerPath].join(`
705
+ -> `)}`;
706
+ }
690
707
  if (mod) {
691
708
  state.moduleToFilename.delete(mod);
692
709
  if (result.static) {
693
- if (state.staticModuleCache.get(specifier) === mod) {
694
- state.staticModuleCache.delete(specifier);
710
+ if (state.staticModuleCache.get(resolvedSpecifier) === mod) {
711
+ state.staticModuleCache.delete(resolvedSpecifier);
695
712
  }
696
713
  } else {
697
- if (state.moduleCache.get(specifier) === mod) {
698
- state.moduleCache.delete(specifier);
714
+ if (state.moduleCache.get(resolvedSpecifier) === mod) {
715
+ state.moduleCache.delete(resolvedSpecifier);
699
716
  }
700
717
  if (state.moduleCache.get(cacheKey) === mod) {
701
718
  state.moduleCache.delete(cacheKey);
702
719
  }
703
720
  }
704
721
  }
705
- throw err;
722
+ throw error;
706
723
  }
707
724
  })();
708
725
  state.moduleLoadsInFlight.set(inFlightKey, loadPromise);
@@ -740,6 +757,8 @@ async function createRuntime(options) {
740
757
  transformCache: new Map,
741
758
  moduleToFilename: new Map,
742
759
  sourceMaps: new Map,
760
+ moduleImportChain: new Map,
761
+ specifierToImporter: new Map,
743
762
  pendingCallbacks: [],
744
763
  evalChain: Promise.resolve(),
745
764
  moduleLoader: opts.moduleLoader,
@@ -985,8 +1004,53 @@ async function createRuntime(options) {
985
1004
  filename
986
1005
  });
987
1006
  state.moduleToFilename.set(mod, filename);
1007
+ state.moduleImportChain.set(filename, []);
988
1008
  const resolver = createModuleResolver(state);
989
- await mod.instantiate(state.context, resolver);
1009
+ try {
1010
+ await mod.instantiate(state.context, resolver);
1011
+ } catch (err) {
1012
+ const error = err instanceof Error ? err : new Error(String(err));
1013
+ const specifierMatch = error.message.match(/The requested module '([^']+)'/);
1014
+ const exportMatch = error.message.match(/export named '([^']+)'/);
1015
+ const failingSpecifier = specifierMatch?.[1];
1016
+ const failingExport = exportMatch?.[1];
1017
+ const importerFile = failingSpecifier ? state.specifierToImporter.get(failingSpecifier) : undefined;
1018
+ const details = [];
1019
+ if (importerFile) {
1020
+ const chain = state.moduleImportChain.get(importerFile) ?? [];
1021
+ const fullChain = [...chain, importerFile];
1022
+ if (failingSpecifier)
1023
+ fullChain.push(failingSpecifier);
1024
+ const trimmed = fullChain.length > 12 ? fullChain.slice(-12) : fullChain;
1025
+ const prefix = fullChain.length > 12 ? ` ...
1026
+ ` : "";
1027
+ details.push(`Import chain:
1028
+ ` + prefix + trimmed.map((p) => ` ${p}`).join(`
1029
+ -> `));
1030
+ } else if (failingSpecifier) {
1031
+ for (const [modPath, chain] of state.moduleImportChain) {
1032
+ if (modPath.includes(failingSpecifier) || modPath.endsWith(failingSpecifier)) {
1033
+ const fullChain = [...chain, modPath];
1034
+ const trimmed = fullChain.length > 12 ? fullChain.slice(-12) : fullChain;
1035
+ details.push(`Import chain:
1036
+ ` + trimmed.map((p) => ` ${p}`).join(`
1037
+ -> `));
1038
+ break;
1039
+ }
1040
+ }
1041
+ }
1042
+ if (failingExport && failingSpecifier) {
1043
+ details.push(`Hint: If '${failingExport}' is a TypeScript type/interface, use \`import type\` to prevent it from being resolved at runtime:
1044
+ ` + ` import type { ${failingExport} } from '${failingSpecifier}';`);
1045
+ }
1046
+ const suffix = details.length > 0 ? `
1047
+
1048
+ ` + details.join(`
1049
+
1050
+ `) : "";
1051
+ error.message = `Module instantiation failed: ${error.message}${suffix}`;
1052
+ throw error;
1053
+ }
990
1054
  await mod.evaluate();
991
1055
  const ns = mod.namespace;
992
1056
  const runRef = await ns.get("default", { reference: true });
@@ -1021,6 +1085,8 @@ async function createRuntime(options) {
1021
1085
  state.moduleCache.clear();
1022
1086
  state.moduleLoadsInFlight.clear();
1023
1087
  state.moduleToFilename.clear();
1088
+ state.moduleImportChain.clear();
1089
+ state.specifierToImporter.clear();
1024
1090
  state.sourceMaps.clear();
1025
1091
  },
1026
1092
  async dispose() {
@@ -1067,4 +1133,4 @@ export {
1067
1133
  createNodeFileSystemHandler
1068
1134
  };
1069
1135
 
1070
- //# debugId=42C800BEB0731DA164756E2164756E21
1136
+ //# debugId=30C3A0A75715847864756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": [
5
- "import ivm from \"isolated-vm\";\nimport path from \"node:path\";\nimport { setupCore } from \"@ricsam/isolate-core\";\nimport { normalizeEntryFilename } from \"@ricsam/isolate-protocol\";\nimport {\n transformEntryCode,\n transformModuleCode,\n contentHash,\n mapErrorStack,\n type SourceMap,\n type TransformResult,\n} from \"@ricsam/isolate-transform\";\n\n// Re-export for convenience\nexport { normalizeEntryFilename } from \"@ricsam/isolate-protocol\";\nimport { setupConsole } from \"@ricsam/isolate-console\";\nimport { setupEncoding } from \"@ricsam/isolate-encoding\";\nimport { setupTimers } from \"@ricsam/isolate-timers\";\nimport { setupPath } from \"@ricsam/isolate-path\";\nimport { setupCrypto } from \"@ricsam/isolate-crypto\";\nimport { setupFetch } from \"@ricsam/isolate-fetch\";\nimport { setupFs } from \"@ricsam/isolate-fs\";\nimport {\n setupTestEnvironment,\n runTests as runTestsInContext,\n hasTests as hasTestsInContext,\n getTestCount as getTestCountInContext,\n} from \"@ricsam/isolate-test-environment\";\nimport {\n setupPlaywright,\n type PlaywrightCallback,\n type PlaywrightSetupOptions,\n} from \"@ricsam/isolate-playwright\";\n\nimport type { ConsoleOptions, ConsoleHandle } from \"@ricsam/isolate-console\";\nimport type {\n FetchOptions,\n FetchHandle,\n DispatchRequestOptions,\n UpgradeRequest,\n WebSocketCommand,\n ClientWebSocketCommand,\n} from \"@ricsam/isolate-fetch\";\nimport type { FsOptions, FsHandle } from \"@ricsam/isolate-fs\";\nimport type { CoreHandle } from \"@ricsam/isolate-core\";\nimport type { EncodingHandle } from \"@ricsam/isolate-encoding\";\nimport type { TimersHandle } from \"@ricsam/isolate-timers\";\nimport type { PathHandle } from \"@ricsam/isolate-path\";\nimport type { CryptoHandle } from \"@ricsam/isolate-crypto\";\nimport type {\n TestEnvironmentHandle,\n RunResults,\n TestEnvironmentOptions,\n TestEvent,\n SuiteInfo,\n SuiteResult,\n TestInfo,\n TestResult,\n TestError,\n} from \"@ricsam/isolate-test-environment\";\nimport type {\n PlaywrightHandle,\n NetworkRequestInfo,\n NetworkResponseInfo,\n BrowserConsoleLogEntry,\n PlaywrightEvent,\n} from \"@ricsam/isolate-playwright\";\nimport type {\n ConsoleCallbacks,\n ConsoleEntry,\n FetchCallback,\n FetchRequestInit,\n ModuleLoaderCallback,\n CustomFunctionDefinition,\n CustomFunctions,\n CustomAsyncGeneratorFunction,\n DispatchOptions,\n EvalOptions as ProtocolEvalOptions,\n PlaywrightOptions as ProtocolPlaywrightOptions,\n BaseRuntimeOptions,\n} from \"@ricsam/isolate-protocol\";\nimport {\n marshalValue,\n unmarshalValue,\n type MarshalContext,\n} from \"@ricsam/isolate-protocol\";\n\n// Re-export shared types from protocol\nexport type {\n ConsoleCallbacks,\n ConsoleEntry,\n FetchCallback,\n FetchRequestInit,\n ModuleLoaderCallback,\n CustomFunction,\n CustomFunctionDefinition,\n CustomFunctions,\n DispatchOptions,\n} from \"@ricsam/isolate-protocol\";\n\n// Re-export shared protocol option types\nexport type EvalOptions = ProtocolEvalOptions;\nexport type PlaywrightOptions = ProtocolPlaywrightOptions;\n\n/**\n * Options for customizing how custom function return values are marshalled.\n * Used by the daemon to support returned callbacks/promises/iterators via IPC.\n */\nexport interface CustomFunctionsMarshalOptions {\n /** Factory to create a MarshalContext for registering returned callbacks/promises/iterators */\n createMarshalContext: () => MarshalContext;\n /** Post-processor to add callback IDs to PromiseRef/AsyncIteratorRef values */\n addCallbackIdsToRefs: (value: unknown) => unknown;\n /** Handler for numeric callback IDs from marshalled refs (CallbackRef, PromiseRef, AsyncIteratorRef) */\n invokeCallback: (callbackId: number, args: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Options for creating a runtime.\n * Extends BaseRuntimeOptions and adds runtime-specific fs type.\n */\nexport interface RuntimeOptions<T extends Record<string, any[]> = Record<string, unknown[]>>\n extends BaseRuntimeOptions<T> {\n /**\n * File system options.\n * Note: For local runtime, this uses FsOptions with getDirectory returning a FileSystemHandler.\n * For remote runtime (isolate-client), use FileSystemCallbacks instead.\n */\n fs?: FsOptions;\n /**\n * Optional marshal options for custom functions.\n * When provided, enables MarshalContext-based marshalling for returned values.\n * Used by the daemon for IPC proxying of callbacks/promises/iterators.\n */\n customFunctionsMarshalOptions?: CustomFunctionsMarshalOptions;\n}\n\n/**\n * Runtime fetch handle - provides access to fetch/serve operations.\n */\nexport interface RuntimeFetchHandle {\n /** Dispatch HTTP request to serve() handler */\n dispatchRequest(\n request: Request,\n options?: DispatchRequestOptions\n ): Promise<Response>;\n /** Check if isolate requested WebSocket upgrade */\n getUpgradeRequest(): UpgradeRequest | null;\n /** Dispatch WebSocket open event to isolate */\n dispatchWebSocketOpen(connectionId: string): void;\n /** Dispatch WebSocket message event to isolate */\n dispatchWebSocketMessage(\n connectionId: string,\n message: string | ArrayBuffer\n ): void;\n /** Dispatch WebSocket close event to isolate */\n dispatchWebSocketClose(\n connectionId: string,\n code: number,\n reason: string\n ): void;\n /** Dispatch WebSocket error event to isolate */\n dispatchWebSocketError(connectionId: string, error: Error): void;\n /** Register callback for WebSocket commands from isolate */\n onWebSocketCommand(callback: (cmd: WebSocketCommand) => void): () => void;\n /** Check if serve() has been called */\n hasServeHandler(): boolean;\n /** Check if there are active WebSocket connections */\n hasActiveConnections(): boolean;\n /** Dispatch open event to a client WebSocket in the isolate */\n dispatchClientWebSocketOpen(socketId: string, protocol: string, extensions: string): void;\n /** Dispatch message event to a client WebSocket in the isolate */\n dispatchClientWebSocketMessage(socketId: string, data: string | ArrayBuffer): void;\n /** Dispatch close event to a client WebSocket in the isolate */\n dispatchClientWebSocketClose(socketId: string, code: number, reason: string, wasClean: boolean): void;\n /** Dispatch error event to a client WebSocket in the isolate */\n dispatchClientWebSocketError(socketId: string): void;\n /** Register callback for client WebSocket commands from isolate */\n onClientWebSocketCommand(callback: (cmd: ClientWebSocketCommand) => void): () => void;\n /** Register callback for events emitted from isolate code */\n onEvent(callback: (event: string, payload: unknown) => void): () => void;\n /** Dispatch an event into the isolate (calls __on listeners) */\n dispatchEvent(event: string, payload: unknown): void;\n}\n\n/**\n * Runtime timers handle - provides access to timer operations.\n * Timers fire automatically based on real time.\n */\nexport interface RuntimeTimersHandle {\n /** Clear all pending timers */\n clearAll(): void;\n}\n\n/**\n * Runtime console handle - provides access to console state.\n */\nexport interface RuntimeConsoleHandle {\n /** Reset all console state (timers, counters, group depth) */\n reset(): void;\n /** Get console.time() timers */\n getTimers(): Map<string, number>;\n /** Get console.count() counters */\n getCounters(): Map<string, number>;\n /** Get current console.group() nesting depth */\n getGroupDepth(): number;\n}\n\n/**\n * Runtime test environment handle - provides access to test execution.\n */\nexport interface RuntimeTestEnvironmentHandle {\n /** Run all registered tests */\n runTests(timeout?: number): Promise<RunResults>;\n /** Check if any tests are registered */\n hasTests(): boolean;\n /** Get count of registered tests */\n getTestCount(): number;\n /** Reset test state */\n reset(): void;\n}\n\n/**\n * Runtime playwright handle - provides access to browser data collection.\n */\nexport interface RuntimePlaywrightHandle {\n /** Get collected browser data (console logs, network requests/responses) */\n getCollectedData(): CollectedData;\n /** Clear collected browser data */\n clearCollectedData(): void;\n}\n\n/**\n * Collected browser data from playwright.\n */\nexport interface CollectedData {\n /** Browser console logs (from the page, not sandbox) */\n browserConsoleLogs: BrowserConsoleLogEntry[];\n networkRequests: NetworkRequestInfo[];\n networkResponses: NetworkResponseInfo[];\n}\n\n/**\n * Runtime handle - the main interface for interacting with the isolate.\n */\nexport interface RuntimeHandle {\n /** Unique runtime identifier */\n readonly id: string;\n /** Execute code as ES module (supports top-level await) */\n eval(code: string, filenameOrOptions?: string | EvalOptions): Promise<void>;\n /** Dispose all resources */\n dispose(): Promise<void>;\n /** Clear module cache and source maps (used for namespace pooling/reuse) */\n clearModuleCache(): void;\n\n /**\n * Array of pending callback promises. Push promises here to have them\n * awaited after each eval() call completes. Used by daemon for IPC flush.\n * For standalone use this array stays empty (callbacks are synchronous).\n */\n readonly pendingCallbacks: Promise<unknown>[];\n\n /** Fetch handle - access to fetch/serve operations */\n readonly fetch: RuntimeFetchHandle;\n /** Timers handle - access to timer operations */\n readonly timers: RuntimeTimersHandle;\n /** Console handle - access to console state */\n readonly console: RuntimeConsoleHandle;\n /** Test environment handle - access to test execution (throws if not enabled) */\n readonly testEnvironment: RuntimeTestEnvironmentHandle;\n /** Playwright handle - access to playwright operations (throws if not configured) */\n readonly playwright: RuntimePlaywrightHandle;\n}\n\n// Internal state for runtime\ninterface RuntimeState {\n isolate: ivm.Isolate;\n context: ivm.Context;\n handles: {\n core?: CoreHandle;\n console?: ConsoleHandle;\n encoding?: EncodingHandle;\n timers?: TimersHandle;\n path?: PathHandle;\n crypto?: CryptoHandle;\n fetch?: FetchHandle;\n fs?: FsHandle;\n testEnvironment?: TestEnvironmentHandle;\n playwright?: PlaywrightHandle;\n };\n moduleCache: Map<string, ivm.Module>;\n staticModuleCache: Map<string, ivm.Module>;\n moduleLoadsInFlight: Map<string, Promise<ivm.Module>>;\n transformCache: Map<string, TransformResult>;\n moduleToFilename: Map<ivm.Module, string>;\n moduleLoader?: ModuleLoaderCallback;\n customFunctions?: CustomFunctions;\n customFnInvokeRef?: ivm.Reference<\n (name: string, argsJson: string) => Promise<string>\n >;\n sourceMaps: Map<string, SourceMap>;\n /** Pending callbacks to await after eval (for daemon IPC fire-and-forget pattern) */\n pendingCallbacks: Promise<unknown>[];\n /** Per-runtime eval queue to prevent overlapping module linking/evaluation */\n evalChain: Promise<void>;\n}\n\n// Iterator session tracking for async iterator custom functions\ninterface IteratorSession {\n iterator: AsyncGenerator<unknown, unknown, unknown>;\n}\n\nconst iteratorSessions = new Map<number, IteratorSession>();\nlet nextIteratorId = 1;\n\n/**\n * Lightweight marshalling code to inject into the isolate.\n * Converts JavaScript types to Ref objects for type-preserving serialization.\n */\nconst ISOLATE_MARSHAL_CODE = `\n(function() {\n // Marshal a value (JavaScript → Ref)\n function marshalForHost(value, depth = 0) {\n if (depth > 100) throw new Error('Maximum marshalling depth exceeded');\n\n if (value === null) return null;\n if (value === undefined) return { __type: 'UndefinedRef' };\n\n const type = typeof value;\n if (type === 'string' || type === 'number' || type === 'boolean') return value;\n if (type === 'bigint') return { __type: 'BigIntRef', value: value.toString() };\n if (type === 'function') throw new Error('Cannot marshal functions from isolate');\n if (type === 'symbol') throw new Error('Cannot marshal Symbol values');\n\n if (type === 'object') {\n if (value instanceof Date) {\n return { __type: 'DateRef', timestamp: value.getTime() };\n }\n if (value instanceof RegExp) {\n return { __type: 'RegExpRef', source: value.source, flags: value.flags };\n }\n if (value instanceof URL) {\n return { __type: 'URLRef', href: value.href };\n }\n if (typeof Headers !== 'undefined' && value instanceof Headers) {\n const pairs = [];\n value.forEach((v, k) => pairs.push([k, v]));\n return { __type: 'HeadersRef', pairs };\n }\n if (value instanceof Uint8Array) {\n return { __type: 'Uint8ArrayRef', data: Array.from(value) };\n }\n if (value instanceof ArrayBuffer) {\n return { __type: 'Uint8ArrayRef', data: Array.from(new Uint8Array(value)) };\n }\n if (typeof Request !== 'undefined' && value instanceof Request) {\n throw new Error('Cannot marshal Request from isolate. Use fetch callback instead.');\n }\n if (typeof Response !== 'undefined' && value instanceof Response) {\n throw new Error('Cannot marshal Response from isolate. Return plain objects instead.');\n }\n if (typeof File !== 'undefined' && value instanceof File) {\n throw new Error('Cannot marshal File from isolate.');\n }\n if (typeof Blob !== 'undefined' && value instanceof Blob) {\n throw new Error('Cannot marshal Blob from isolate.');\n }\n if (typeof FormData !== 'undefined' && value instanceof FormData) {\n throw new Error('Cannot marshal FormData from isolate.');\n }\n if (Array.isArray(value)) {\n return value.map(v => marshalForHost(v, depth + 1));\n }\n // Plain object\n const result = {};\n for (const key of Object.keys(value)) {\n result[key] = marshalForHost(value[key], depth + 1);\n }\n return result;\n }\n return value;\n }\n\n // Unmarshal a value (Ref → JavaScript)\n function unmarshalFromHost(value, depth = 0) {\n if (depth > 100) throw new Error('Maximum unmarshalling depth exceeded');\n\n if (value === null) return null;\n if (typeof value !== 'object') return value;\n\n if (value.__type) {\n switch (value.__type) {\n case 'UndefinedRef': return undefined;\n case 'DateRef': return new Date(value.timestamp);\n case 'RegExpRef': return new RegExp(value.source, value.flags);\n case 'BigIntRef': return BigInt(value.value);\n case 'URLRef': return new URL(value.href);\n case 'HeadersRef': return new Headers(value.pairs);\n case 'Uint8ArrayRef': return new Uint8Array(value.data);\n case 'RequestRef': {\n const init = {\n method: value.method,\n headers: value.headers,\n body: value.body ? new Uint8Array(value.body) : null,\n };\n if (value.mode) init.mode = value.mode;\n if (value.credentials) init.credentials = value.credentials;\n if (value.cache) init.cache = value.cache;\n if (value.redirect) init.redirect = value.redirect;\n if (value.referrer) init.referrer = value.referrer;\n if (value.referrerPolicy) init.referrerPolicy = value.referrerPolicy;\n if (value.integrity) init.integrity = value.integrity;\n return new Request(value.url, init);\n }\n case 'ResponseRef': {\n return new Response(value.body ? new Uint8Array(value.body) : null, {\n status: value.status,\n statusText: value.statusText,\n headers: value.headers,\n });\n }\n case 'FileRef': {\n if (!value.name) {\n return new Blob([new Uint8Array(value.data)], { type: value.type });\n }\n return new File([new Uint8Array(value.data)], value.name, {\n type: value.type,\n lastModified: value.lastModified,\n });\n }\n case 'FormDataRef': {\n const fd = new FormData();\n for (const [key, entry] of value.entries) {\n if (typeof entry === 'string') {\n fd.append(key, entry);\n } else {\n const file = unmarshalFromHost(entry, depth + 1);\n fd.append(key, file);\n }\n }\n return fd;\n }\n case 'CallbackRef': {\n // Create a proxy function that invokes the callback\n const callbackId = value.callbackId;\n return function(...args) {\n const argsJson = JSON.stringify(marshalForHost(args));\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [callbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n }\n case 'PromiseRef': {\n // Create a proxy Promise that resolves via callback\n const promiseId = value.promiseId;\n return new Promise((resolve, reject) => {\n try {\n const argsJson = JSON.stringify([promiseId]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [value.__resolveCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (result.ok) {\n resolve(unmarshalFromHost(result.value));\n } else {\n reject(new Error(result.error.message));\n }\n } catch (e) {\n reject(e);\n }\n });\n }\n case 'AsyncIteratorRef': {\n const iteratorId = value.iteratorId;\n const nextCallbackId = value.__nextCallbackId;\n const returnCallbackId = value.__returnCallbackId;\n return {\n [Symbol.asyncIterator]() { return this; },\n async next() {\n const argsJson = JSON.stringify([iteratorId]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [nextCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (!result.ok) {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n return {\n done: result.value.done,\n value: unmarshalFromHost(result.value.value)\n };\n },\n async return(v) {\n const argsJson = JSON.stringify([iteratorId, marshalForHost(v)]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [returnCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n return { done: true, value: result.ok ? unmarshalFromHost(result.value) : undefined };\n }\n };\n }\n default:\n // Unknown ref type, return as-is\n break;\n }\n }\n\n if (Array.isArray(value)) {\n return value.map(v => unmarshalFromHost(v, depth + 1));\n }\n\n // Plain object - recursively unmarshal\n const result = {};\n for (const key of Object.keys(value)) {\n result[key] = unmarshalFromHost(value[key], depth + 1);\n }\n return result;\n }\n\n // Expose as globals\n globalThis.__marshalForHost = marshalForHost;\n globalThis.__unmarshalFromHost = unmarshalFromHost;\n})();\n`;\n\n// CustomFunctionsMarshalOptions is exported at the top of the file\n\n/**\n * Setup custom functions as globals in the isolate context.\n * Each function directly calls the host callback when invoked.\n *\n * When marshalOptions is provided, returned values are marshalled with a MarshalContext,\n * enabling proper proxying of callbacks/promises/iterators across boundaries.\n */\nasync function setupCustomFunctions(\n context: ivm.Context,\n customFunctions: CustomFunctions,\n marshalOptions?: CustomFunctionsMarshalOptions,\n): Promise<ivm.Reference<(name: string, argsJson: string) => Promise<string>>> {\n const global = context.global;\n\n // Reference that invokes the callback and returns the result.\n // The first argument can be a string function name (for custom functions) or a\n // numeric callback ID (for returned callbacks/promises/iterators from marshal).\n const invokeCallbackRef = new ivm.Reference(\n async (nameOrId: string | number, argsJson: string): Promise<string> => {\n // Check if this is a local callback ID (numeric, used by returned callbacks/promises/iterators)\n if (typeof nameOrId === \"number\" && marshalOptions) {\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n try {\n const result = await marshalOptions.invokeCallback(nameOrId, args);\n const ctx = marshalOptions.createMarshalContext();\n const marshalledResult = await marshalValue(result, ctx);\n const processedResult = marshalOptions.addCallbackIdsToRefs(marshalledResult);\n return JSON.stringify({ ok: true, value: processedResult });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n\n const name = String(nameOrId);\n const def = customFunctions[name];\n if (!def) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Custom function '${name}' not found`,\n name: \"Error\",\n },\n });\n }\n // Unmarshal args from isolate (converts Refs back to JavaScript types)\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n try {\n // Always await the result: for daemon-bridged functions, even \"sync\" custom functions\n // are async due to IPC, so we need to resolve the promise.\n const result = await def.fn(...args);\n // Marshal result for isolate (converts JavaScript types to Refs)\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n const marshalledResult = await marshalValue(result, ctx);\n const processedResult = marshalOptions.addCallbackIdsToRefs(marshalledResult);\n return JSON.stringify({ ok: true, value: processedResult });\n }\n const marshalledResult = await marshalValue(result);\n return JSON.stringify({ ok: true, value: marshalledResult });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__customFn_invoke\", invokeCallbackRef);\n\n // Iterator start: creates iterator, stores in session, returns iteratorId\n const iterStartRef = new ivm.Reference(\n async (name: string, argsJson: string): Promise<string> => {\n const def = customFunctions[name];\n if (!def || def.type !== \"asyncIterator\") {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Async iterator function '${name}' not found`,\n name: \"Error\",\n },\n });\n }\n try {\n // Unmarshal args from isolate\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n const fn = def.fn as CustomAsyncGeneratorFunction;\n const iterator = fn(...args);\n const iteratorId = nextIteratorId++;\n iteratorSessions.set(iteratorId, { iterator });\n return JSON.stringify({ ok: true, iteratorId });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_start\", iterStartRef);\n\n // Iterator next: calls iterator.next(), returns {done, value}\n const iterNextRef = new ivm.Reference(\n async (iteratorId: number): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Iterator session ${iteratorId} not found`,\n name: \"Error\",\n },\n });\n }\n try {\n const result = await session.iterator.next();\n if (result.done) {\n iteratorSessions.delete(iteratorId);\n }\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result.value);\n }\n return JSON.stringify({\n ok: true,\n done: result.done,\n value: marshalledValue,\n });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_next\", iterNextRef);\n\n // Iterator return: calls iterator.return(), cleans up session\n const iterReturnRef = new ivm.Reference(\n async (iteratorId: number, valueJson: string): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({ ok: true, done: true, value: undefined });\n }\n try {\n // Unmarshal value from isolate\n const rawValue = valueJson ? JSON.parse(valueJson) : undefined;\n const value = unmarshalValue(rawValue);\n const result = await session.iterator.return?.(value);\n iteratorSessions.delete(iteratorId);\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result?.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result?.value);\n }\n return JSON.stringify({ ok: true, done: true, value: marshalledValue });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_return\", iterReturnRef);\n\n // Iterator throw: calls iterator.throw(), cleans up session\n const iterThrowRef = new ivm.Reference(\n async (iteratorId: number, errorJson: string): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Iterator session ${iteratorId} not found`,\n name: \"Error\",\n },\n });\n }\n try {\n const errorData = JSON.parse(errorJson) as {\n message: string;\n name: string;\n };\n const error = Object.assign(new Error(errorData.message), {\n name: errorData.name,\n });\n const result = await session.iterator.throw?.(error);\n iteratorSessions.delete(iteratorId);\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result?.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result?.value);\n }\n return JSON.stringify({\n ok: true,\n done: result?.done ?? true,\n value: marshalledValue,\n });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_throw\", iterThrowRef);\n\n // Inject marshalling helpers into the isolate\n context.evalSync(ISOLATE_MARSHAL_CODE);\n\n // Create wrapper functions for each custom function\n for (const name of Object.keys(customFunctions)) {\n const def = customFunctions[name]!;\n\n if (def.type === \"async\") {\n // Async function: use applySyncPromise and async function wrapper\n context.evalSync(`\n globalThis.${name} = async function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const resultJson = __customFn_invoke.applySyncPromise(\n undefined,\n [\"${name}\", JSON.stringify(marshalledArgs)]\n );\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return __unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n `);\n } else if (def.type === \"sync\") {\n // Sync function: use applySyncPromise (to await the host) but wrap in regular function\n // The function blocks until the host responds, but returns the value directly (not a Promise)\n context.evalSync(`\n globalThis.${name} = function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const resultJson = __customFn_invoke.applySyncPromise(\n undefined,\n [\"${name}\", JSON.stringify(marshalledArgs)]\n );\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return __unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n `);\n } else if (def.type === \"asyncIterator\") {\n // Async iterator function: returns an async iterable object\n context.evalSync(`\n globalThis.${name} = function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const startResult = JSON.parse(__iter_start.applySyncPromise(undefined, [\"${name}\", JSON.stringify(marshalledArgs)]));\n if (!startResult.ok) {\n throw Object.assign(new Error(startResult.error.message), { name: startResult.error.name });\n }\n const iteratorId = startResult.iteratorId;\n return {\n [Symbol.asyncIterator]() { return this; },\n async next() {\n const result = JSON.parse(__iter_next.applySyncPromise(undefined, [iteratorId]));\n if (!result.ok) {\n throw Object.assign(new Error(result.error.message), { name: result.error.name });\n }\n return { done: result.done, value: __unmarshalFromHost(result.value) };\n },\n async return(v) {\n const result = JSON.parse(__iter_return.applySyncPromise(undefined, [iteratorId, JSON.stringify(__marshalForHost(v))]));\n return { done: true, value: __unmarshalFromHost(result.value) };\n },\n async throw(e) {\n const result = JSON.parse(__iter_throw.applySyncPromise(undefined, [iteratorId, JSON.stringify({ message: e.message, name: e.name })]));\n if (!result.ok) {\n throw Object.assign(new Error(result.error.message), { name: result.error.name });\n }\n return { done: result.done, value: __unmarshalFromHost(result.value) };\n }\n };\n };\n `);\n }\n }\n\n return invokeCallbackRef;\n}\n\n/**\n * Create local marshal options for standalone runtime custom functions.\n * Enables returned callbacks/promises/iterators without daemon IPC.\n */\nfunction createLocalCustomFunctionsMarshalOptions(): CustomFunctionsMarshalOptions {\n const returnedCallbacks = new Map<number, Function>();\n const returnedPromises = new Map<number, Promise<unknown>>();\n const returnedIterators = new Map<number, AsyncIterator<unknown>>();\n let nextLocalCallbackId = 1_000_000;\n\n const createMarshalContext = (): MarshalContext => ({\n registerCallback: (fn: Function): number => {\n const callbackId = nextLocalCallbackId++;\n returnedCallbacks.set(callbackId, fn);\n return callbackId;\n },\n registerPromise: (promise: Promise<unknown>): number => {\n const promiseId = nextLocalCallbackId++;\n returnedPromises.set(promiseId, promise);\n return promiseId;\n },\n registerIterator: (iterator: AsyncIterator<unknown>): number => {\n const iteratorId = nextLocalCallbackId++;\n returnedIterators.set(iteratorId, iterator);\n return iteratorId;\n },\n });\n\n const isPromiseRef = (\n value: unknown\n ): value is { __type: \"PromiseRef\"; promiseId: number } =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { __type?: string }).__type === \"PromiseRef\";\n\n const isAsyncIteratorRef = (\n value: unknown\n ): value is { __type: \"AsyncIteratorRef\"; iteratorId: number } =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { __type?: string }).__type === \"AsyncIteratorRef\";\n\n const addCallbackIdsToRefs = (value: unknown): unknown => {\n if (value === null || typeof value !== \"object\") return value;\n\n if (isPromiseRef(value)) {\n if (\"__resolveCallbackId\" in value) return value;\n\n const resolveCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(resolveCallbackId, async (promiseId: number) => {\n const promise = returnedPromises.get(promiseId);\n if (!promise) {\n throw new Error(`Promise ${promiseId} not found`);\n }\n const result = await promise;\n returnedPromises.delete(promiseId);\n const ctx = createMarshalContext();\n const marshalled = await marshalValue(result, ctx);\n return addCallbackIdsToRefs(marshalled);\n });\n\n return { ...value, __resolveCallbackId: resolveCallbackId };\n }\n\n if (isAsyncIteratorRef(value)) {\n if (\"__nextCallbackId\" in value) return value;\n\n const nextCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(nextCallbackId, async (iteratorId: number) => {\n const iterator = returnedIterators.get(iteratorId);\n if (!iterator) {\n throw new Error(`Iterator ${iteratorId} not found`);\n }\n const result = await iterator.next();\n if (result.done) {\n returnedIterators.delete(iteratorId);\n }\n const ctx = createMarshalContext();\n const marshalledValue = await marshalValue(result.value, ctx);\n return {\n done: result.done,\n value: addCallbackIdsToRefs(marshalledValue),\n };\n });\n\n const returnCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(\n returnCallbackId,\n async (iteratorId: number, returnValue?: unknown) => {\n const iterator = returnedIterators.get(iteratorId);\n returnedIterators.delete(iteratorId);\n if (!iterator || !iterator.return) {\n return { done: true, value: undefined };\n }\n const result = await iterator.return(returnValue);\n const ctx = createMarshalContext();\n const marshalledValue = await marshalValue(result.value, ctx);\n return {\n done: true,\n value: addCallbackIdsToRefs(marshalledValue),\n };\n }\n );\n\n return {\n ...value,\n __nextCallbackId: nextCallbackId,\n __returnCallbackId: returnCallbackId,\n };\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => addCallbackIdsToRefs(item));\n }\n\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(value)) {\n result[key] = addCallbackIdsToRefs(\n (value as Record<string, unknown>)[key]\n );\n }\n return result;\n };\n\n const invokeCallback = async (\n callbackId: number,\n args: unknown[]\n ): Promise<unknown> => {\n const callback = returnedCallbacks.get(callbackId);\n if (!callback) {\n throw new Error(`Local callback ${callbackId} not found`);\n }\n return await callback(...args);\n };\n\n return { createMarshalContext, addCallbackIdsToRefs, invokeCallback };\n}\n\n/**\n * Create a module resolver function for local execution.\n */\nfunction createModuleResolver(\n state: RuntimeState\n): (specifier: string, referrer: ivm.Module) => Promise<ivm.Module> {\n return async (\n specifier: string,\n referrer: ivm.Module\n ): Promise<ivm.Module> => {\n // Static cache first\n const staticCached = state.staticModuleCache.get(specifier);\n if (staticCached) return staticCached;\n\n // Specifier-only fast path is safe here: each local runtime gets a fresh cache,\n // so there's no cross-lifecycle staleness (unlike the daemon where caches persist across namespace reuse).\n const cached = state.moduleCache.get(specifier);\n if (cached) return cached;\n\n if (!state.moduleLoader) {\n throw new Error(\n `No module loader registered. Cannot import: ${specifier}`\n );\n }\n\n // Get importer info\n const importerPath = state.moduleToFilename.get(referrer) ?? \"<unknown>\";\n const importerResolveDir = path.posix.dirname(importerPath);\n\n // Invoke module loader - capture full result including static flag\n const result = await state.moduleLoader(specifier, {\n path: importerPath,\n resolveDir: importerResolveDir,\n });\n const { code, resolveDir } = result;\n\n // Cache by specifier + content hash (allows invalidation when content changes)\n const hash = contentHash(code);\n const cacheKey = `${specifier}:${hash}`;\n const inFlightKey = `${result.static ? \"static\" : \"dynamic\"}:${cacheKey}`;\n\n // Cache checks again after await in case another resolver call won the race\n const staticCachedAfterLoad = state.staticModuleCache.get(specifier);\n if (staticCachedAfterLoad) return staticCachedAfterLoad;\n\n const cachedAfterLoad = state.moduleCache.get(specifier);\n if (cachedAfterLoad) return cachedAfterLoad;\n\n const hashCached = state.moduleCache.get(cacheKey);\n if (hashCached) return hashCached;\n\n const inFlight = state.moduleLoadsInFlight.get(inFlightKey);\n if (inFlight) return inFlight;\n\n const loadPromise = (async (): Promise<ivm.Module> => {\n let mod: ivm.Module | undefined;\n try {\n // Transform cache — check transform cache first (survives reuse in daemon)\n let transformed: TransformResult | undefined = state.transformCache.get(hash);\n if (!transformed) {\n transformed = await transformModuleCode(code, specifier);\n state.transformCache.set(hash, transformed);\n }\n\n if (transformed.sourceMap) {\n state.sourceMaps.set(specifier, transformed.sourceMap);\n }\n\n // Compile the module\n mod = await state.isolate.compileModule(transformed.code, {\n filename: specifier,\n });\n\n // Construct resolved path and track for nested imports\n const resolvedPath = path.posix.join(resolveDir, path.posix.basename(specifier));\n state.moduleToFilename.set(mod, resolvedPath);\n\n // Cache the compiled module before linker uses it (supports circular deps)\n if (result.static) {\n state.staticModuleCache.set(specifier, mod);\n } else {\n state.moduleCache.set(specifier, mod);\n state.moduleCache.set(cacheKey, mod);\n }\n\n return mod;\n } catch (err) {\n // Remove partial cache state to avoid returning poisoned module entries later.\n if (mod) {\n state.moduleToFilename.delete(mod);\n if (result.static) {\n if (state.staticModuleCache.get(specifier) === mod) {\n state.staticModuleCache.delete(specifier);\n }\n } else {\n if (state.moduleCache.get(specifier) === mod) {\n state.moduleCache.delete(specifier);\n }\n if (state.moduleCache.get(cacheKey) === mod) {\n state.moduleCache.delete(cacheKey);\n }\n }\n }\n throw err;\n }\n })();\n\n state.moduleLoadsInFlight.set(inFlightKey, loadPromise);\n try {\n return await loadPromise;\n } finally {\n state.moduleLoadsInFlight.delete(inFlightKey);\n }\n };\n}\n\n/**\n * Convert FetchCallback to FetchOptions\n */\nfunction convertFetchCallback(callback?: FetchCallback): FetchOptions {\n if (!callback) {\n return {};\n }\n return {\n onFetch: async (url: string, init: FetchRequestInit): Promise<Response> => {\n // Wrap the result in a Promise to handle both sync and async callbacks\n return Promise.resolve(callback(url, init));\n },\n };\n}\n\n/**\n * Create a fully configured isolated-vm runtime\n *\n * Sets up all WHATWG APIs: fetch, fs, console, crypto, encoding, timers\n *\n * @example\n * const runtime = await createRuntime({\n * console: { log: (...args) => console.log(\"[isolate]\", ...args) },\n * fetch: async (request) => fetch(request),\n * });\n *\n * await runtime.eval(`\n * console.log(\"Hello from sandbox!\");\n * const response = await fetch(\"https://example.com\");\n * `);\n *\n * await runtime.dispose();\n */\nexport async function createRuntime<T extends Record<string, any[]> = Record<string, unknown[]>>(\n options?: RuntimeOptions<T>\n): Promise<RuntimeHandle> {\n const opts = options ?? {};\n\n // Generate unique ID\n const id = crypto.randomUUID();\n\n // Create isolate with optional memory limit\n const isolate = new ivm.Isolate({\n memoryLimit: opts.memoryLimitMB,\n });\n const context = await isolate.createContext();\n\n // Initialize state\n const state: RuntimeState = {\n isolate,\n context,\n handles: {},\n moduleCache: new Map(),\n staticModuleCache: new Map(),\n moduleLoadsInFlight: new Map(),\n transformCache: new Map(),\n moduleToFilename: new Map(),\n sourceMaps: new Map(),\n pendingCallbacks: [],\n evalChain: Promise.resolve(),\n moduleLoader: opts.moduleLoader,\n customFunctions: opts.customFunctions as CustomFunctions<Record<string, unknown[]>>,\n };\n\n // Setup all APIs in order\n // Core must be first as it provides Blob, File, streams, URL, etc.\n state.handles.core = await setupCore(context);\n\n // Console\n state.handles.console = await setupConsole(context, opts.console);\n\n // Encoding (btoa/atob) and Buffer\n state.handles.encoding = await setupEncoding(context);\n\n // Timers (setTimeout, setInterval)\n state.handles.timers = await setupTimers(context);\n\n // Path module\n state.handles.path = await setupPath(context, { cwd: opts.cwd });\n\n // Crypto (randomUUID, getRandomValues)\n state.handles.crypto = await setupCrypto(context);\n\n // Fetch API - convert callback to options\n state.handles.fetch = await setupFetch(\n context,\n convertFetchCallback(opts.fetch)\n );\n\n // File system (only if handler provided)\n if (opts.fs) {\n state.handles.fs = await setupFs(context, opts.fs);\n }\n\n // Setup custom functions\n if (opts.customFunctions) {\n const customMarshalOptions =\n opts.customFunctionsMarshalOptions ??\n createLocalCustomFunctionsMarshalOptions();\n\n state.customFnInvokeRef = await setupCustomFunctions(\n context,\n opts.customFunctions as CustomFunctions<Record<string, unknown[]>>,\n customMarshalOptions,\n );\n }\n\n // Setup test environment (if enabled)\n if (opts.testEnvironment) {\n const testEnvOptions: TestEnvironmentOptions | undefined =\n typeof opts.testEnvironment === \"object\"\n ? opts.testEnvironment\n : undefined;\n state.handles.testEnvironment = await setupTestEnvironment(\n context,\n testEnvOptions\n );\n }\n\n // Setup playwright - AFTER test environment so expect can be extended\n if (opts.playwright) {\n if (!opts.playwright.handler) {\n throw new Error(\n \"Playwright configured without handler. Provide playwright.handler in createRuntime options.\"\n );\n }\n\n // Determine event handler\n // If console: true and we have a console handler, wrap onEvent to route browser logs\n let eventCallback = opts.playwright.onEvent;\n\n if (opts.playwright.console && opts.console?.onEntry) {\n const originalCallback = eventCallback;\n const consoleHandler = opts.console.onEntry;\n eventCallback = (event) => {\n // Call original callback if provided\n if (originalCallback) {\n originalCallback(event);\n }\n // Route browser console logs through console handler as browserOutput entry\n if (event.type === \"browserConsoleLog\") {\n consoleHandler({\n type: \"browserOutput\",\n level: event.level,\n stdout: event.stdout,\n timestamp: event.timestamp,\n });\n }\n };\n }\n\n const playwrightSetupOptions: PlaywrightSetupOptions = {\n handler: opts.playwright.handler,\n timeout: opts.playwright.timeout,\n // Don't print directly if routing through console handler\n console: opts.playwright.console && !opts.console?.onEntry,\n onEvent: eventCallback,\n };\n\n state.handles.playwright = await setupPlaywright(context, playwrightSetupOptions);\n }\n\n // Create fetch handle wrapper\n const fetchHandle: RuntimeFetchHandle = {\n async dispatchRequest(\n request: Request,\n options?: DispatchRequestOptions\n ): Promise<Response> {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.dispatchRequest(request, options);\n },\n getUpgradeRequest() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.getUpgradeRequest();\n },\n dispatchWebSocketOpen(connectionId: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketOpen(connectionId);\n },\n dispatchWebSocketMessage(\n connectionId: string,\n message: string | ArrayBuffer\n ) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketMessage(connectionId, message);\n },\n dispatchWebSocketClose(connectionId: string, code: number, reason: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketClose(connectionId, code, reason);\n },\n dispatchWebSocketError(connectionId: string, error: Error) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketError(connectionId, error);\n },\n onWebSocketCommand(callback: (cmd: WebSocketCommand) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onWebSocketCommand(callback);\n },\n hasServeHandler() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.hasServeHandler();\n },\n hasActiveConnections() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.hasActiveConnections();\n },\n dispatchClientWebSocketOpen(socketId: string, protocol: string, extensions: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketOpen(socketId, protocol, extensions);\n },\n dispatchClientWebSocketMessage(socketId: string, data: string | ArrayBuffer) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketMessage(socketId, data);\n },\n dispatchClientWebSocketClose(socketId: string, code: number, reason: string, wasClean: boolean) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketClose(socketId, code, reason, wasClean);\n },\n dispatchClientWebSocketError(socketId: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketError(socketId);\n },\n onClientWebSocketCommand(callback: (cmd: ClientWebSocketCommand) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onClientWebSocketCommand(callback);\n },\n onEvent(callback: (event: string, payload: unknown) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onEvent(callback);\n },\n dispatchEvent(event: string, payload: unknown) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchEvent(event, payload);\n },\n };\n\n // Create timers handle wrapper\n const timersHandle: RuntimeTimersHandle = {\n clearAll() {\n state.handles.timers?.clearAll();\n },\n };\n\n // Create console handle wrapper\n const consoleHandle: RuntimeConsoleHandle = {\n reset() {\n state.handles.console?.reset();\n },\n getTimers() {\n return state.handles.console?.getTimers() ?? new Map();\n },\n getCounters() {\n return state.handles.console?.getCounters() ?? new Map();\n },\n getGroupDepth() {\n return state.handles.console?.getGroupDepth() ?? 0;\n },\n };\n\n // Create test environment handle wrapper\n const testEnvironmentHandle: RuntimeTestEnvironmentHandle = {\n async runTests(timeout?: number): Promise<RunResults> {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n\n if (timeout === undefined) {\n return runTestsInContext(state.context);\n }\n\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => reject(new Error(\"Test timeout\")), timeout);\n });\n\n try {\n return await Promise.race([\n runTestsInContext(state.context),\n timeoutPromise,\n ]);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n },\n hasTests(): boolean {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n return hasTestsInContext(state.context);\n },\n getTestCount(): number {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n return getTestCountInContext(state.context);\n },\n reset() {\n state.handles.testEnvironment?.dispose();\n },\n };\n\n // Create playwright handle wrapper\n const playwrightHandle: RuntimePlaywrightHandle = {\n getCollectedData(): CollectedData {\n if (!state.handles.playwright) {\n throw new Error(\n \"Playwright not configured. Provide playwright.handler in createRuntime options.\"\n );\n }\n return {\n browserConsoleLogs: state.handles.playwright.getBrowserConsoleLogs(),\n networkRequests: state.handles.playwright.getNetworkRequests(),\n networkResponses: state.handles.playwright.getNetworkResponses(),\n };\n },\n clearCollectedData() {\n state.handles.playwright?.clearCollected();\n },\n };\n\n return {\n id,\n pendingCallbacks: state.pendingCallbacks,\n\n // Module handles\n fetch: fetchHandle,\n timers: timersHandle,\n console: consoleHandle,\n testEnvironment: testEnvironmentHandle,\n playwright: playwrightHandle,\n\n async eval(\n code: string,\n filenameOrOptions?: string | EvalOptions\n ): Promise<void> {\n const runEval = async (): Promise<void> => {\n // Parse options\n const options =\n typeof filenameOrOptions === \"string\"\n ? { filename: filenameOrOptions }\n : filenameOrOptions;\n\n // Normalize filename to absolute path for module resolution\n const filename = normalizeEntryFilename(options?.filename);\n\n try {\n // Transform entry code: strip types, validate, wrap in async function\n const transformed = await transformEntryCode(code, filename);\n if (transformed.sourceMap) {\n state.sourceMaps.set(filename, transformed.sourceMap);\n }\n\n // Compile as ES module\n const mod = await state.isolate.compileModule(transformed.code, {\n filename,\n });\n\n // Track entry module filename for nested imports\n state.moduleToFilename.set(mod, filename);\n\n // Instantiate with module resolver\n const resolver = createModuleResolver(state);\n await mod.instantiate(state.context, resolver);\n\n // Evaluate - only resolves imports and defines the default function (no timeout needed)\n await mod.evaluate();\n\n // Get the default export and run it with timeout\n const ns = mod.namespace;\n const runRef = await ns.get(\"default\", { reference: true });\n try {\n await runRef.apply(undefined, [], {\n result: { promise: true },\n });\n } finally {\n runRef.release();\n }\n\n // Await pending callbacks (no-op for local use, enables daemon IPC flush)\n if (state.pendingCallbacks.length > 0) {\n await Promise.all(state.pendingCallbacks);\n state.pendingCallbacks.length = 0;\n }\n } catch (err) {\n const error = err as Error;\n if (error.stack && state.sourceMaps.size > 0) {\n error.stack = mapErrorStack(error.stack, state.sourceMaps);\n }\n throw error;\n }\n };\n\n const queuedEval = state.evalChain.then(runEval, runEval);\n state.evalChain = queuedEval.then(\n () => undefined,\n () => undefined\n );\n return queuedEval;\n },\n\n clearModuleCache() {\n state.moduleCache.clear();\n state.moduleLoadsInFlight.clear();\n state.moduleToFilename.clear();\n state.sourceMaps.clear();\n // staticModuleCache and transformCache intentionally preserved\n },\n\n async dispose(): Promise<void> {\n // Dispose custom function reference\n if (state.customFnInvokeRef) {\n state.customFnInvokeRef.release();\n }\n\n // Dispose all handles (in reverse order of setup)\n state.handles.playwright?.dispose();\n state.handles.testEnvironment?.dispose();\n state.handles.fs?.dispose();\n state.handles.fetch?.dispose();\n state.handles.crypto?.dispose();\n state.handles.path?.dispose();\n state.handles.timers?.dispose();\n state.handles.encoding?.dispose();\n state.handles.console?.dispose();\n state.handles.core?.dispose();\n\n // Clear module cache\n state.moduleCache.clear();\n state.moduleLoadsInFlight.clear();\n\n // Release context and dispose isolate\n state.context.release();\n state.isolate.dispose();\n },\n };\n}\n\n// Re-export all package types and functions\nexport { setupCore } from \"@ricsam/isolate-core\";\nexport type { CoreHandle, SetupCoreOptions } from \"@ricsam/isolate-core\";\n\nexport { setupConsole } from \"@ricsam/isolate-console\";\nexport {\n simpleConsoleHandler,\n type SimpleConsoleCallbacks,\n} from \"@ricsam/isolate-console/utils\";\nexport type {\n ConsoleHandle,\n ConsoleOptions,\n ConsoleEntry as ConsoleEntryFromConsole,\n} from \"@ricsam/isolate-console\";\n\nexport { setupCrypto } from \"@ricsam/isolate-crypto\";\nexport type { CryptoHandle } from \"@ricsam/isolate-crypto\";\n\nexport { setupEncoding } from \"@ricsam/isolate-encoding\";\nexport type { EncodingHandle } from \"@ricsam/isolate-encoding\";\n\nexport { setupFetch } from \"@ricsam/isolate-fetch\";\nexport type {\n FetchHandle,\n FetchOptions,\n WebSocketCommand,\n UpgradeRequest,\n ClientWebSocketCommand,\n} from \"@ricsam/isolate-fetch\";\n\nexport { setupFs, createNodeFileSystemHandler } from \"@ricsam/isolate-fs\";\nexport type {\n FsHandle,\n FsOptions,\n FileSystemHandler,\n NodeFileSystemHandlerOptions,\n} from \"@ricsam/isolate-fs\";\n\nexport { setupPath } from \"@ricsam/isolate-path\";\nexport type { PathHandle, PathOptions } from \"@ricsam/isolate-path\";\n\nexport { setupTimers } from \"@ricsam/isolate-timers\";\nexport type { TimersHandle } from \"@ricsam/isolate-timers\";\n\nexport {\n setupTestEnvironment,\n runTests,\n hasTests,\n getTestCount,\n} from \"@ricsam/isolate-test-environment\";\nexport type {\n TestEnvironmentHandle,\n TestEnvironmentOptions,\n RunResults,\n TestResult,\n TestInfo,\n TestError,\n TestEvent,\n SuiteInfo,\n SuiteResult,\n} from \"@ricsam/isolate-test-environment\";\n\nexport {\n setupPlaywright,\n createPlaywrightHandler,\n defaultPlaywrightHandler,\n getDefaultPlaywrightHandlerMetadata,\n} from \"@ricsam/isolate-playwright\";\nexport type {\n PlaywrightHandle,\n PlaywrightSetupOptions,\n PlaywrightCallback,\n PlaywrightEvent,\n NetworkRequestInfo,\n NetworkResponseInfo,\n BrowserConsoleLogEntry,\n} from \"@ricsam/isolate-playwright\";\n"
5
+ "import ivm from \"isolated-vm\";\nimport path from \"node:path\";\nimport { setupCore } from \"@ricsam/isolate-core\";\nimport { normalizeEntryFilename } from \"@ricsam/isolate-protocol\";\nimport {\n transformEntryCode,\n transformModuleCode,\n contentHash,\n mapErrorStack,\n type SourceMap,\n type TransformResult,\n} from \"@ricsam/isolate-transform\";\n\n// Re-export for convenience\nexport { normalizeEntryFilename } from \"@ricsam/isolate-protocol\";\nimport { setupConsole } from \"@ricsam/isolate-console\";\nimport { setupEncoding } from \"@ricsam/isolate-encoding\";\nimport { setupTimers } from \"@ricsam/isolate-timers\";\nimport { setupPath } from \"@ricsam/isolate-path\";\nimport { setupCrypto } from \"@ricsam/isolate-crypto\";\nimport { setupFetch } from \"@ricsam/isolate-fetch\";\nimport { setupFs } from \"@ricsam/isolate-fs\";\nimport {\n setupTestEnvironment,\n runTests as runTestsInContext,\n hasTests as hasTestsInContext,\n getTestCount as getTestCountInContext,\n} from \"@ricsam/isolate-test-environment\";\nimport {\n setupPlaywright,\n type PlaywrightCallback,\n type PlaywrightSetupOptions,\n} from \"@ricsam/isolate-playwright\";\n\nimport type { ConsoleOptions, ConsoleHandle } from \"@ricsam/isolate-console\";\nimport type {\n FetchOptions,\n FetchHandle,\n DispatchRequestOptions,\n UpgradeRequest,\n WebSocketCommand,\n ClientWebSocketCommand,\n} from \"@ricsam/isolate-fetch\";\nimport type { FsOptions, FsHandle } from \"@ricsam/isolate-fs\";\nimport type { CoreHandle } from \"@ricsam/isolate-core\";\nimport type { EncodingHandle } from \"@ricsam/isolate-encoding\";\nimport type { TimersHandle } from \"@ricsam/isolate-timers\";\nimport type { PathHandle } from \"@ricsam/isolate-path\";\nimport type { CryptoHandle } from \"@ricsam/isolate-crypto\";\nimport type {\n TestEnvironmentHandle,\n RunResults,\n TestEnvironmentOptions,\n TestEvent,\n SuiteInfo,\n SuiteResult,\n TestInfo,\n TestResult,\n TestError,\n} from \"@ricsam/isolate-test-environment\";\nimport type {\n PlaywrightHandle,\n NetworkRequestInfo,\n NetworkResponseInfo,\n BrowserConsoleLogEntry,\n PlaywrightEvent,\n} from \"@ricsam/isolate-playwright\";\nimport type {\n ConsoleCallbacks,\n ConsoleEntry,\n FetchCallback,\n FetchRequestInit,\n ModuleLoaderCallback,\n CustomFunctionDefinition,\n CustomFunctions,\n CustomAsyncGeneratorFunction,\n DispatchOptions,\n EvalOptions as ProtocolEvalOptions,\n PlaywrightOptions as ProtocolPlaywrightOptions,\n BaseRuntimeOptions,\n} from \"@ricsam/isolate-protocol\";\nimport {\n marshalValue,\n unmarshalValue,\n type MarshalContext,\n} from \"@ricsam/isolate-protocol\";\n\n// Re-export shared types from protocol\nexport type {\n ConsoleCallbacks,\n ConsoleEntry,\n FetchCallback,\n FetchRequestInit,\n ModuleLoaderCallback,\n CustomFunction,\n CustomFunctionDefinition,\n CustomFunctions,\n DispatchOptions,\n} from \"@ricsam/isolate-protocol\";\n\n// Re-export shared protocol option types\nexport type EvalOptions = ProtocolEvalOptions;\nexport type PlaywrightOptions = ProtocolPlaywrightOptions;\n\n/**\n * Options for customizing how custom function return values are marshalled.\n * Used by the daemon to support returned callbacks/promises/iterators via IPC.\n */\nexport interface CustomFunctionsMarshalOptions {\n /** Factory to create a MarshalContext for registering returned callbacks/promises/iterators */\n createMarshalContext: () => MarshalContext;\n /** Post-processor to add callback IDs to PromiseRef/AsyncIteratorRef values */\n addCallbackIdsToRefs: (value: unknown) => unknown;\n /** Handler for numeric callback IDs from marshalled refs (CallbackRef, PromiseRef, AsyncIteratorRef) */\n invokeCallback: (callbackId: number, args: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Options for creating a runtime.\n * Extends BaseRuntimeOptions and adds runtime-specific fs type.\n */\nexport interface RuntimeOptions<T extends Record<string, any[]> = Record<string, unknown[]>>\n extends BaseRuntimeOptions<T> {\n /**\n * File system options.\n * Note: For local runtime, this uses FsOptions with getDirectory returning a FileSystemHandler.\n * For remote runtime (isolate-client), use FileSystemCallbacks instead.\n */\n fs?: FsOptions;\n /**\n * Optional marshal options for custom functions.\n * When provided, enables MarshalContext-based marshalling for returned values.\n * Used by the daemon for IPC proxying of callbacks/promises/iterators.\n */\n customFunctionsMarshalOptions?: CustomFunctionsMarshalOptions;\n}\n\n/**\n * Runtime fetch handle - provides access to fetch/serve operations.\n */\nexport interface RuntimeFetchHandle {\n /** Dispatch HTTP request to serve() handler */\n dispatchRequest(\n request: Request,\n options?: DispatchRequestOptions\n ): Promise<Response>;\n /** Check if isolate requested WebSocket upgrade */\n getUpgradeRequest(): UpgradeRequest | null;\n /** Dispatch WebSocket open event to isolate */\n dispatchWebSocketOpen(connectionId: string): void;\n /** Dispatch WebSocket message event to isolate */\n dispatchWebSocketMessage(\n connectionId: string,\n message: string | ArrayBuffer\n ): void;\n /** Dispatch WebSocket close event to isolate */\n dispatchWebSocketClose(\n connectionId: string,\n code: number,\n reason: string\n ): void;\n /** Dispatch WebSocket error event to isolate */\n dispatchWebSocketError(connectionId: string, error: Error): void;\n /** Register callback for WebSocket commands from isolate */\n onWebSocketCommand(callback: (cmd: WebSocketCommand) => void): () => void;\n /** Check if serve() has been called */\n hasServeHandler(): boolean;\n /** Check if there are active WebSocket connections */\n hasActiveConnections(): boolean;\n /** Dispatch open event to a client WebSocket in the isolate */\n dispatchClientWebSocketOpen(socketId: string, protocol: string, extensions: string): void;\n /** Dispatch message event to a client WebSocket in the isolate */\n dispatchClientWebSocketMessage(socketId: string, data: string | ArrayBuffer): void;\n /** Dispatch close event to a client WebSocket in the isolate */\n dispatchClientWebSocketClose(socketId: string, code: number, reason: string, wasClean: boolean): void;\n /** Dispatch error event to a client WebSocket in the isolate */\n dispatchClientWebSocketError(socketId: string): void;\n /** Register callback for client WebSocket commands from isolate */\n onClientWebSocketCommand(callback: (cmd: ClientWebSocketCommand) => void): () => void;\n /** Register callback for events emitted from isolate code */\n onEvent(callback: (event: string, payload: unknown) => void): () => void;\n /** Dispatch an event into the isolate (calls __on listeners) */\n dispatchEvent(event: string, payload: unknown): void;\n}\n\n/**\n * Runtime timers handle - provides access to timer operations.\n * Timers fire automatically based on real time.\n */\nexport interface RuntimeTimersHandle {\n /** Clear all pending timers */\n clearAll(): void;\n}\n\n/**\n * Runtime console handle - provides access to console state.\n */\nexport interface RuntimeConsoleHandle {\n /** Reset all console state (timers, counters, group depth) */\n reset(): void;\n /** Get console.time() timers */\n getTimers(): Map<string, number>;\n /** Get console.count() counters */\n getCounters(): Map<string, number>;\n /** Get current console.group() nesting depth */\n getGroupDepth(): number;\n}\n\n/**\n * Runtime test environment handle - provides access to test execution.\n */\nexport interface RuntimeTestEnvironmentHandle {\n /** Run all registered tests */\n runTests(timeout?: number): Promise<RunResults>;\n /** Check if any tests are registered */\n hasTests(): boolean;\n /** Get count of registered tests */\n getTestCount(): number;\n /** Reset test state */\n reset(): void;\n}\n\n/**\n * Runtime playwright handle - provides access to browser data collection.\n */\nexport interface RuntimePlaywrightHandle {\n /** Get collected browser data (console logs, network requests/responses) */\n getCollectedData(): CollectedData;\n /** Clear collected browser data */\n clearCollectedData(): void;\n}\n\n/**\n * Collected browser data from playwright.\n */\nexport interface CollectedData {\n /** Browser console logs (from the page, not sandbox) */\n browserConsoleLogs: BrowserConsoleLogEntry[];\n networkRequests: NetworkRequestInfo[];\n networkResponses: NetworkResponseInfo[];\n}\n\n/**\n * Runtime handle - the main interface for interacting with the isolate.\n */\nexport interface RuntimeHandle {\n /** Unique runtime identifier */\n readonly id: string;\n /** Execute code as ES module (supports top-level await) */\n eval(code: string, filenameOrOptions?: string | EvalOptions): Promise<void>;\n /** Dispose all resources */\n dispose(): Promise<void>;\n /** Clear module cache and source maps (used for namespace pooling/reuse) */\n clearModuleCache(): void;\n\n /**\n * Array of pending callback promises. Push promises here to have them\n * awaited after each eval() call completes. Used by daemon for IPC flush.\n * For standalone use this array stays empty (callbacks are synchronous).\n */\n readonly pendingCallbacks: Promise<unknown>[];\n\n /** Fetch handle - access to fetch/serve operations */\n readonly fetch: RuntimeFetchHandle;\n /** Timers handle - access to timer operations */\n readonly timers: RuntimeTimersHandle;\n /** Console handle - access to console state */\n readonly console: RuntimeConsoleHandle;\n /** Test environment handle - access to test execution (throws if not enabled) */\n readonly testEnvironment: RuntimeTestEnvironmentHandle;\n /** Playwright handle - access to playwright operations (throws if not configured) */\n readonly playwright: RuntimePlaywrightHandle;\n}\n\n// Internal state for runtime\ninterface RuntimeState {\n isolate: ivm.Isolate;\n context: ivm.Context;\n handles: {\n core?: CoreHandle;\n console?: ConsoleHandle;\n encoding?: EncodingHandle;\n timers?: TimersHandle;\n path?: PathHandle;\n crypto?: CryptoHandle;\n fetch?: FetchHandle;\n fs?: FsHandle;\n testEnvironment?: TestEnvironmentHandle;\n playwright?: PlaywrightHandle;\n };\n moduleCache: Map<string, ivm.Module>;\n staticModuleCache: Map<string, ivm.Module>;\n moduleLoadsInFlight: Map<string, Promise<ivm.Module>>;\n transformCache: Map<string, TransformResult>;\n moduleToFilename: Map<ivm.Module, string>;\n moduleLoader?: ModuleLoaderCallback;\n customFunctions?: CustomFunctions;\n customFnInvokeRef?: ivm.Reference<\n (name: string, argsJson: string) => Promise<string>\n >;\n sourceMaps: Map<string, SourceMap>;\n /** Tracks the import chain for each module (resolved path → list of ancestor paths) */\n moduleImportChain: Map<string, string[]>;\n /** Tracks which file imported a given specifier (resolvedSpecifier → importerPath) */\n specifierToImporter: Map<string, string>;\n /** Pending callbacks to await after eval (for daemon IPC fire-and-forget pattern) */\n pendingCallbacks: Promise<unknown>[];\n /** Per-runtime eval queue to prevent overlapping module linking/evaluation */\n evalChain: Promise<void>;\n}\n\n// Iterator session tracking for async iterator custom functions\ninterface IteratorSession {\n iterator: AsyncGenerator<unknown, unknown, unknown>;\n}\n\nconst iteratorSessions = new Map<number, IteratorSession>();\nlet nextIteratorId = 1;\n\n/**\n * Lightweight marshalling code to inject into the isolate.\n * Converts JavaScript types to Ref objects for type-preserving serialization.\n */\nconst ISOLATE_MARSHAL_CODE = `\n(function() {\n // Marshal a value (JavaScript → Ref)\n function marshalForHost(value, depth = 0) {\n if (depth > 100) throw new Error('Maximum marshalling depth exceeded');\n\n if (value === null) return null;\n if (value === undefined) return { __type: 'UndefinedRef' };\n\n const type = typeof value;\n if (type === 'string' || type === 'number' || type === 'boolean') return value;\n if (type === 'bigint') return { __type: 'BigIntRef', value: value.toString() };\n if (type === 'function') throw new Error('Cannot marshal functions from isolate');\n if (type === 'symbol') throw new Error('Cannot marshal Symbol values');\n\n if (type === 'object') {\n if (value instanceof Date) {\n return { __type: 'DateRef', timestamp: value.getTime() };\n }\n if (value instanceof RegExp) {\n return { __type: 'RegExpRef', source: value.source, flags: value.flags };\n }\n if (value instanceof URL) {\n return { __type: 'URLRef', href: value.href };\n }\n if (typeof Headers !== 'undefined' && value instanceof Headers) {\n const pairs = [];\n value.forEach((v, k) => pairs.push([k, v]));\n return { __type: 'HeadersRef', pairs };\n }\n if (value instanceof Uint8Array) {\n return { __type: 'Uint8ArrayRef', data: Array.from(value) };\n }\n if (value instanceof ArrayBuffer) {\n return { __type: 'Uint8ArrayRef', data: Array.from(new Uint8Array(value)) };\n }\n if (typeof Request !== 'undefined' && value instanceof Request) {\n throw new Error('Cannot marshal Request from isolate. Use fetch callback instead.');\n }\n if (typeof Response !== 'undefined' && value instanceof Response) {\n throw new Error('Cannot marshal Response from isolate. Return plain objects instead.');\n }\n if (typeof File !== 'undefined' && value instanceof File) {\n throw new Error('Cannot marshal File from isolate.');\n }\n if (typeof Blob !== 'undefined' && value instanceof Blob) {\n throw new Error('Cannot marshal Blob from isolate.');\n }\n if (typeof FormData !== 'undefined' && value instanceof FormData) {\n throw new Error('Cannot marshal FormData from isolate.');\n }\n if (Array.isArray(value)) {\n return value.map(v => marshalForHost(v, depth + 1));\n }\n // Plain object\n const result = {};\n for (const key of Object.keys(value)) {\n result[key] = marshalForHost(value[key], depth + 1);\n }\n return result;\n }\n return value;\n }\n\n // Unmarshal a value (Ref → JavaScript)\n function unmarshalFromHost(value, depth = 0) {\n if (depth > 100) throw new Error('Maximum unmarshalling depth exceeded');\n\n if (value === null) return null;\n if (typeof value !== 'object') return value;\n\n if (value.__type) {\n switch (value.__type) {\n case 'UndefinedRef': return undefined;\n case 'DateRef': return new Date(value.timestamp);\n case 'RegExpRef': return new RegExp(value.source, value.flags);\n case 'BigIntRef': return BigInt(value.value);\n case 'URLRef': return new URL(value.href);\n case 'HeadersRef': return new Headers(value.pairs);\n case 'Uint8ArrayRef': return new Uint8Array(value.data);\n case 'RequestRef': {\n const init = {\n method: value.method,\n headers: value.headers,\n body: value.body ? new Uint8Array(value.body) : null,\n };\n if (value.mode) init.mode = value.mode;\n if (value.credentials) init.credentials = value.credentials;\n if (value.cache) init.cache = value.cache;\n if (value.redirect) init.redirect = value.redirect;\n if (value.referrer) init.referrer = value.referrer;\n if (value.referrerPolicy) init.referrerPolicy = value.referrerPolicy;\n if (value.integrity) init.integrity = value.integrity;\n return new Request(value.url, init);\n }\n case 'ResponseRef': {\n return new Response(value.body ? new Uint8Array(value.body) : null, {\n status: value.status,\n statusText: value.statusText,\n headers: value.headers,\n });\n }\n case 'FileRef': {\n if (!value.name) {\n return new Blob([new Uint8Array(value.data)], { type: value.type });\n }\n return new File([new Uint8Array(value.data)], value.name, {\n type: value.type,\n lastModified: value.lastModified,\n });\n }\n case 'FormDataRef': {\n const fd = new FormData();\n for (const [key, entry] of value.entries) {\n if (typeof entry === 'string') {\n fd.append(key, entry);\n } else {\n const file = unmarshalFromHost(entry, depth + 1);\n fd.append(key, file);\n }\n }\n return fd;\n }\n case 'CallbackRef': {\n // Create a proxy function that invokes the callback\n const callbackId = value.callbackId;\n return function(...args) {\n const argsJson = JSON.stringify(marshalForHost(args));\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [callbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n }\n case 'PromiseRef': {\n // Create a proxy Promise that resolves via callback\n const promiseId = value.promiseId;\n return new Promise((resolve, reject) => {\n try {\n const argsJson = JSON.stringify([promiseId]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [value.__resolveCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (result.ok) {\n resolve(unmarshalFromHost(result.value));\n } else {\n reject(new Error(result.error.message));\n }\n } catch (e) {\n reject(e);\n }\n });\n }\n case 'AsyncIteratorRef': {\n const iteratorId = value.iteratorId;\n const nextCallbackId = value.__nextCallbackId;\n const returnCallbackId = value.__returnCallbackId;\n return {\n [Symbol.asyncIterator]() { return this; },\n async next() {\n const argsJson = JSON.stringify([iteratorId]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [nextCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n if (!result.ok) {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n return {\n done: result.value.done,\n value: unmarshalFromHost(result.value.value)\n };\n },\n async return(v) {\n const argsJson = JSON.stringify([iteratorId, marshalForHost(v)]);\n const resultJson = __customFn_invoke.applySyncPromise(undefined, [returnCallbackId, argsJson]);\n const result = JSON.parse(resultJson);\n return { done: true, value: result.ok ? unmarshalFromHost(result.value) : undefined };\n }\n };\n }\n default:\n // Unknown ref type, return as-is\n break;\n }\n }\n\n if (Array.isArray(value)) {\n return value.map(v => unmarshalFromHost(v, depth + 1));\n }\n\n // Plain object - recursively unmarshal\n const result = {};\n for (const key of Object.keys(value)) {\n result[key] = unmarshalFromHost(value[key], depth + 1);\n }\n return result;\n }\n\n // Expose as globals\n globalThis.__marshalForHost = marshalForHost;\n globalThis.__unmarshalFromHost = unmarshalFromHost;\n})();\n`;\n\n// CustomFunctionsMarshalOptions is exported at the top of the file\n\n/**\n * Setup custom functions as globals in the isolate context.\n * Each function directly calls the host callback when invoked.\n *\n * When marshalOptions is provided, returned values are marshalled with a MarshalContext,\n * enabling proper proxying of callbacks/promises/iterators across boundaries.\n */\nasync function setupCustomFunctions(\n context: ivm.Context,\n customFunctions: CustomFunctions,\n marshalOptions?: CustomFunctionsMarshalOptions,\n): Promise<ivm.Reference<(name: string, argsJson: string) => Promise<string>>> {\n const global = context.global;\n\n // Reference that invokes the callback and returns the result.\n // The first argument can be a string function name (for custom functions) or a\n // numeric callback ID (for returned callbacks/promises/iterators from marshal).\n const invokeCallbackRef = new ivm.Reference(\n async (nameOrId: string | number, argsJson: string): Promise<string> => {\n // Check if this is a local callback ID (numeric, used by returned callbacks/promises/iterators)\n if (typeof nameOrId === \"number\" && marshalOptions) {\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n try {\n const result = await marshalOptions.invokeCallback(nameOrId, args);\n const ctx = marshalOptions.createMarshalContext();\n const marshalledResult = await marshalValue(result, ctx);\n const processedResult = marshalOptions.addCallbackIdsToRefs(marshalledResult);\n return JSON.stringify({ ok: true, value: processedResult });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n\n const name = String(nameOrId);\n const def = customFunctions[name];\n if (!def) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Custom function '${name}' not found`,\n name: \"Error\",\n },\n });\n }\n // Unmarshal args from isolate (converts Refs back to JavaScript types)\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n try {\n // Always await the result: for daemon-bridged functions, even \"sync\" custom functions\n // are async due to IPC, so we need to resolve the promise.\n const result = await def.fn(...args);\n // Marshal result for isolate (converts JavaScript types to Refs)\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n const marshalledResult = await marshalValue(result, ctx);\n const processedResult = marshalOptions.addCallbackIdsToRefs(marshalledResult);\n return JSON.stringify({ ok: true, value: processedResult });\n }\n const marshalledResult = await marshalValue(result);\n return JSON.stringify({ ok: true, value: marshalledResult });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__customFn_invoke\", invokeCallbackRef);\n\n // Iterator start: creates iterator, stores in session, returns iteratorId\n const iterStartRef = new ivm.Reference(\n async (name: string, argsJson: string): Promise<string> => {\n const def = customFunctions[name];\n if (!def || def.type !== \"asyncIterator\") {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Async iterator function '${name}' not found`,\n name: \"Error\",\n },\n });\n }\n try {\n // Unmarshal args from isolate\n const rawArgs = JSON.parse(argsJson) as unknown[];\n const args = unmarshalValue(rawArgs) as unknown[];\n const fn = def.fn as CustomAsyncGeneratorFunction;\n const iterator = fn(...args);\n const iteratorId = nextIteratorId++;\n iteratorSessions.set(iteratorId, { iterator });\n return JSON.stringify({ ok: true, iteratorId });\n } catch (error: unknown) {\n const err = error as Error;\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_start\", iterStartRef);\n\n // Iterator next: calls iterator.next(), returns {done, value}\n const iterNextRef = new ivm.Reference(\n async (iteratorId: number): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Iterator session ${iteratorId} not found`,\n name: \"Error\",\n },\n });\n }\n try {\n const result = await session.iterator.next();\n if (result.done) {\n iteratorSessions.delete(iteratorId);\n }\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result.value);\n }\n return JSON.stringify({\n ok: true,\n done: result.done,\n value: marshalledValue,\n });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_next\", iterNextRef);\n\n // Iterator return: calls iterator.return(), cleans up session\n const iterReturnRef = new ivm.Reference(\n async (iteratorId: number, valueJson: string): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({ ok: true, done: true, value: undefined });\n }\n try {\n // Unmarshal value from isolate\n const rawValue = valueJson ? JSON.parse(valueJson) : undefined;\n const value = unmarshalValue(rawValue);\n const result = await session.iterator.return?.(value);\n iteratorSessions.delete(iteratorId);\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result?.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result?.value);\n }\n return JSON.stringify({ ok: true, done: true, value: marshalledValue });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_return\", iterReturnRef);\n\n // Iterator throw: calls iterator.throw(), cleans up session\n const iterThrowRef = new ivm.Reference(\n async (iteratorId: number, errorJson: string): Promise<string> => {\n const session = iteratorSessions.get(iteratorId);\n if (!session) {\n return JSON.stringify({\n ok: false,\n error: {\n message: `Iterator session ${iteratorId} not found`,\n name: \"Error\",\n },\n });\n }\n try {\n const errorData = JSON.parse(errorJson) as {\n message: string;\n name: string;\n };\n const error = Object.assign(new Error(errorData.message), {\n name: errorData.name,\n });\n const result = await session.iterator.throw?.(error);\n iteratorSessions.delete(iteratorId);\n // Marshal value for isolate\n let marshalledValue: unknown;\n if (marshalOptions) {\n const ctx = marshalOptions.createMarshalContext();\n marshalledValue = await marshalValue(result?.value, ctx);\n marshalledValue = marshalOptions.addCallbackIdsToRefs(marshalledValue);\n } else {\n marshalledValue = await marshalValue(result?.value);\n }\n return JSON.stringify({\n ok: true,\n done: result?.done ?? true,\n value: marshalledValue,\n });\n } catch (error: unknown) {\n const err = error as Error;\n iteratorSessions.delete(iteratorId);\n return JSON.stringify({\n ok: false,\n error: { message: err.message, name: err.name },\n });\n }\n }\n );\n\n global.setSync(\"__iter_throw\", iterThrowRef);\n\n // Inject marshalling helpers into the isolate\n context.evalSync(ISOLATE_MARSHAL_CODE);\n\n // Create wrapper functions for each custom function\n for (const name of Object.keys(customFunctions)) {\n const def = customFunctions[name]!;\n\n if (def.type === \"async\") {\n // Async function: use applySyncPromise and async function wrapper\n context.evalSync(`\n globalThis.${name} = async function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const resultJson = __customFn_invoke.applySyncPromise(\n undefined,\n [\"${name}\", JSON.stringify(marshalledArgs)]\n );\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return __unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n `);\n } else if (def.type === \"sync\") {\n // Sync function: use applySyncPromise (to await the host) but wrap in regular function\n // The function blocks until the host responds, but returns the value directly (not a Promise)\n context.evalSync(`\n globalThis.${name} = function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const resultJson = __customFn_invoke.applySyncPromise(\n undefined,\n [\"${name}\", JSON.stringify(marshalledArgs)]\n );\n const result = JSON.parse(resultJson);\n if (result.ok) {\n return __unmarshalFromHost(result.value);\n } else {\n const error = new Error(result.error.message);\n error.name = result.error.name;\n throw error;\n }\n };\n `);\n } else if (def.type === \"asyncIterator\") {\n // Async iterator function: returns an async iterable object\n context.evalSync(`\n globalThis.${name} = function(...args) {\n const marshalledArgs = __marshalForHost(args);\n const startResult = JSON.parse(__iter_start.applySyncPromise(undefined, [\"${name}\", JSON.stringify(marshalledArgs)]));\n if (!startResult.ok) {\n throw Object.assign(new Error(startResult.error.message), { name: startResult.error.name });\n }\n const iteratorId = startResult.iteratorId;\n return {\n [Symbol.asyncIterator]() { return this; },\n async next() {\n const result = JSON.parse(__iter_next.applySyncPromise(undefined, [iteratorId]));\n if (!result.ok) {\n throw Object.assign(new Error(result.error.message), { name: result.error.name });\n }\n return { done: result.done, value: __unmarshalFromHost(result.value) };\n },\n async return(v) {\n const result = JSON.parse(__iter_return.applySyncPromise(undefined, [iteratorId, JSON.stringify(__marshalForHost(v))]));\n return { done: true, value: __unmarshalFromHost(result.value) };\n },\n async throw(e) {\n const result = JSON.parse(__iter_throw.applySyncPromise(undefined, [iteratorId, JSON.stringify({ message: e.message, name: e.name })]));\n if (!result.ok) {\n throw Object.assign(new Error(result.error.message), { name: result.error.name });\n }\n return { done: result.done, value: __unmarshalFromHost(result.value) };\n }\n };\n };\n `);\n }\n }\n\n return invokeCallbackRef;\n}\n\n/**\n * Create local marshal options for standalone runtime custom functions.\n * Enables returned callbacks/promises/iterators without daemon IPC.\n */\nfunction createLocalCustomFunctionsMarshalOptions(): CustomFunctionsMarshalOptions {\n const returnedCallbacks = new Map<number, Function>();\n const returnedPromises = new Map<number, Promise<unknown>>();\n const returnedIterators = new Map<number, AsyncIterator<unknown>>();\n let nextLocalCallbackId = 1_000_000;\n\n const createMarshalContext = (): MarshalContext => ({\n registerCallback: (fn: Function): number => {\n const callbackId = nextLocalCallbackId++;\n returnedCallbacks.set(callbackId, fn);\n return callbackId;\n },\n registerPromise: (promise: Promise<unknown>): number => {\n const promiseId = nextLocalCallbackId++;\n returnedPromises.set(promiseId, promise);\n return promiseId;\n },\n registerIterator: (iterator: AsyncIterator<unknown>): number => {\n const iteratorId = nextLocalCallbackId++;\n returnedIterators.set(iteratorId, iterator);\n return iteratorId;\n },\n });\n\n const isPromiseRef = (\n value: unknown\n ): value is { __type: \"PromiseRef\"; promiseId: number } =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { __type?: string }).__type === \"PromiseRef\";\n\n const isAsyncIteratorRef = (\n value: unknown\n ): value is { __type: \"AsyncIteratorRef\"; iteratorId: number } =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { __type?: string }).__type === \"AsyncIteratorRef\";\n\n const addCallbackIdsToRefs = (value: unknown): unknown => {\n if (value === null || typeof value !== \"object\") return value;\n\n if (isPromiseRef(value)) {\n if (\"__resolveCallbackId\" in value) return value;\n\n const resolveCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(resolveCallbackId, async (promiseId: number) => {\n const promise = returnedPromises.get(promiseId);\n if (!promise) {\n throw new Error(`Promise ${promiseId} not found`);\n }\n const result = await promise;\n returnedPromises.delete(promiseId);\n const ctx = createMarshalContext();\n const marshalled = await marshalValue(result, ctx);\n return addCallbackIdsToRefs(marshalled);\n });\n\n return { ...value, __resolveCallbackId: resolveCallbackId };\n }\n\n if (isAsyncIteratorRef(value)) {\n if (\"__nextCallbackId\" in value) return value;\n\n const nextCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(nextCallbackId, async (iteratorId: number) => {\n const iterator = returnedIterators.get(iteratorId);\n if (!iterator) {\n throw new Error(`Iterator ${iteratorId} not found`);\n }\n const result = await iterator.next();\n if (result.done) {\n returnedIterators.delete(iteratorId);\n }\n const ctx = createMarshalContext();\n const marshalledValue = await marshalValue(result.value, ctx);\n return {\n done: result.done,\n value: addCallbackIdsToRefs(marshalledValue),\n };\n });\n\n const returnCallbackId = nextLocalCallbackId++;\n returnedCallbacks.set(\n returnCallbackId,\n async (iteratorId: number, returnValue?: unknown) => {\n const iterator = returnedIterators.get(iteratorId);\n returnedIterators.delete(iteratorId);\n if (!iterator || !iterator.return) {\n return { done: true, value: undefined };\n }\n const result = await iterator.return(returnValue);\n const ctx = createMarshalContext();\n const marshalledValue = await marshalValue(result.value, ctx);\n return {\n done: true,\n value: addCallbackIdsToRefs(marshalledValue),\n };\n }\n );\n\n return {\n ...value,\n __nextCallbackId: nextCallbackId,\n __returnCallbackId: returnCallbackId,\n };\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => addCallbackIdsToRefs(item));\n }\n\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(value)) {\n result[key] = addCallbackIdsToRefs(\n (value as Record<string, unknown>)[key]\n );\n }\n return result;\n };\n\n const invokeCallback = async (\n callbackId: number,\n args: unknown[]\n ): Promise<unknown> => {\n const callback = returnedCallbacks.get(callbackId);\n if (!callback) {\n throw new Error(`Local callback ${callbackId} not found`);\n }\n return await callback(...args);\n };\n\n return { createMarshalContext, addCallbackIdsToRefs, invokeCallback };\n}\n\n/**\n * Create a module resolver function for local execution.\n */\nfunction createModuleResolver(\n state: RuntimeState\n): (specifier: string, referrer: ivm.Module) => Promise<ivm.Module> {\n return async (\n specifier: string,\n referrer: ivm.Module\n ): Promise<ivm.Module> => {\n // Get importer info\n const importerPath = state.moduleToFilename.get(referrer) ?? \"<unknown>\";\n const importerResolveDir = path.posix.dirname(importerPath);\n const importerStack = state.moduleImportChain.get(importerPath) ?? [];\n\n // Resolve relative specifiers to absolute-like paths for cache key uniqueness.\n // This prevents cross-package collisions (e.g. two different packages both importing \"./utils.js\").\n const resolvedSpecifier = specifier.startsWith('.')\n ? path.posix.normalize(path.posix.join(importerResolveDir, specifier))\n : specifier;\n\n // Track who imports this specifier (for error diagnostics)\n state.specifierToImporter.set(resolvedSpecifier, importerPath);\n\n // Static cache first\n const staticCached = state.staticModuleCache.get(resolvedSpecifier);\n if (staticCached) return staticCached;\n\n const cached = state.moduleCache.get(resolvedSpecifier);\n if (cached) return cached;\n\n if (!state.moduleLoader) {\n throw new Error(\n `No module loader registered. Cannot import: ${specifier}`\n );\n }\n\n // Invoke module loader - capture full result including static flag\n const result = await state.moduleLoader(specifier, {\n path: importerPath,\n resolveDir: importerResolveDir,\n });\n const { code, resolveDir } = result;\n\n // Validate filename: must be a basename (no slashes)\n if (result.filename.includes('/')) {\n throw new Error(\n `moduleLoader returned a filename with slashes: \"${result.filename}\". ` +\n `filename must be a basename (e.g. \"utils.js\"), not a path.`\n );\n }\n\n // Construct resolved filename using result.filename\n const resolvedFilename = path.posix.join(resolveDir, result.filename);\n\n // Cache by specifier + content hash (allows invalidation when content changes)\n const hash = contentHash(code);\n const cacheKey = `${resolvedSpecifier}:${hash}`;\n const inFlightKey = `${result.static ? \"static\" : \"dynamic\"}:${cacheKey}`;\n\n // Cache checks again after await in case another resolver call won the race\n const staticCachedAfterLoad = state.staticModuleCache.get(resolvedSpecifier);\n if (staticCachedAfterLoad) return staticCachedAfterLoad;\n\n const cachedAfterLoad = state.moduleCache.get(resolvedSpecifier);\n if (cachedAfterLoad) return cachedAfterLoad;\n\n const hashCached = state.moduleCache.get(cacheKey);\n if (hashCached) return hashCached;\n\n const inFlight = state.moduleLoadsInFlight.get(inFlightKey);\n if (inFlight) return inFlight;\n\n const loadPromise = (async (): Promise<ivm.Module> => {\n let mod: ivm.Module | undefined;\n try {\n // Transform cache — check transform cache first (survives reuse in daemon)\n let transformed: TransformResult | undefined = state.transformCache.get(hash);\n if (!transformed) {\n transformed = await transformModuleCode(code, resolvedSpecifier);\n state.transformCache.set(hash, transformed);\n }\n\n if (transformed.sourceMap) {\n state.sourceMaps.set(resolvedSpecifier, transformed.sourceMap);\n }\n\n // Compile the module using resolvedSpecifier as filename\n mod = await state.isolate.compileModule(transformed.code, {\n filename: resolvedSpecifier,\n });\n\n // Track resolved filename for nested imports\n state.moduleToFilename.set(mod, resolvedFilename);\n\n // Track import chain for error diagnostics\n state.moduleImportChain.set(resolvedFilename, [...importerStack, importerPath]);\n\n // Cache the compiled module before linker uses it (supports circular deps)\n if (result.static) {\n state.staticModuleCache.set(resolvedSpecifier, mod);\n } else {\n state.moduleCache.set(resolvedSpecifier, mod);\n state.moduleCache.set(cacheKey, mod);\n }\n\n return mod;\n } catch (err) {\n // Annotate error with module resolution context\n const error = err instanceof Error ? err : new Error(String(err));\n error.message = `Failed to compile module \"${resolvedSpecifier}\" (imported by \"${importerPath}\"):\\n${error.message}`;\n if (importerStack.length > 0) {\n error.message += `\\n\\nImport chain:\\n ${[...importerStack, importerPath].join('\\n -> ')}`;\n }\n\n // Remove partial cache state to avoid returning poisoned module entries later.\n if (mod) {\n state.moduleToFilename.delete(mod);\n if (result.static) {\n if (state.staticModuleCache.get(resolvedSpecifier) === mod) {\n state.staticModuleCache.delete(resolvedSpecifier);\n }\n } else {\n if (state.moduleCache.get(resolvedSpecifier) === mod) {\n state.moduleCache.delete(resolvedSpecifier);\n }\n if (state.moduleCache.get(cacheKey) === mod) {\n state.moduleCache.delete(cacheKey);\n }\n }\n }\n throw error;\n }\n })();\n\n state.moduleLoadsInFlight.set(inFlightKey, loadPromise);\n try {\n return await loadPromise;\n } finally {\n state.moduleLoadsInFlight.delete(inFlightKey);\n }\n };\n}\n\n/**\n * Convert FetchCallback to FetchOptions\n */\nfunction convertFetchCallback(callback?: FetchCallback): FetchOptions {\n if (!callback) {\n return {};\n }\n return {\n onFetch: async (url: string, init: FetchRequestInit): Promise<Response> => {\n // Wrap the result in a Promise to handle both sync and async callbacks\n return Promise.resolve(callback(url, init));\n },\n };\n}\n\n/**\n * Create a fully configured isolated-vm runtime\n *\n * Sets up all WHATWG APIs: fetch, fs, console, crypto, encoding, timers\n *\n * @example\n * const runtime = await createRuntime({\n * console: { log: (...args) => console.log(\"[isolate]\", ...args) },\n * fetch: async (request) => fetch(request),\n * });\n *\n * await runtime.eval(`\n * console.log(\"Hello from sandbox!\");\n * const response = await fetch(\"https://example.com\");\n * `);\n *\n * await runtime.dispose();\n */\nexport async function createRuntime<T extends Record<string, any[]> = Record<string, unknown[]>>(\n options?: RuntimeOptions<T>\n): Promise<RuntimeHandle> {\n const opts = options ?? {};\n\n // Generate unique ID\n const id = crypto.randomUUID();\n\n // Create isolate with optional memory limit\n const isolate = new ivm.Isolate({\n memoryLimit: opts.memoryLimitMB,\n });\n const context = await isolate.createContext();\n\n // Initialize state\n const state: RuntimeState = {\n isolate,\n context,\n handles: {},\n moduleCache: new Map(),\n staticModuleCache: new Map(),\n moduleLoadsInFlight: new Map(),\n transformCache: new Map(),\n moduleToFilename: new Map(),\n sourceMaps: new Map(),\n moduleImportChain: new Map(),\n specifierToImporter: new Map(),\n pendingCallbacks: [],\n evalChain: Promise.resolve(),\n moduleLoader: opts.moduleLoader,\n customFunctions: opts.customFunctions as CustomFunctions<Record<string, unknown[]>>,\n };\n\n // Setup all APIs in order\n // Core must be first as it provides Blob, File, streams, URL, etc.\n state.handles.core = await setupCore(context);\n\n // Console\n state.handles.console = await setupConsole(context, opts.console);\n\n // Encoding (btoa/atob) and Buffer\n state.handles.encoding = await setupEncoding(context);\n\n // Timers (setTimeout, setInterval)\n state.handles.timers = await setupTimers(context);\n\n // Path module\n state.handles.path = await setupPath(context, { cwd: opts.cwd });\n\n // Crypto (randomUUID, getRandomValues)\n state.handles.crypto = await setupCrypto(context);\n\n // Fetch API - convert callback to options\n state.handles.fetch = await setupFetch(\n context,\n convertFetchCallback(opts.fetch)\n );\n\n // File system (only if handler provided)\n if (opts.fs) {\n state.handles.fs = await setupFs(context, opts.fs);\n }\n\n // Setup custom functions\n if (opts.customFunctions) {\n const customMarshalOptions =\n opts.customFunctionsMarshalOptions ??\n createLocalCustomFunctionsMarshalOptions();\n\n state.customFnInvokeRef = await setupCustomFunctions(\n context,\n opts.customFunctions as CustomFunctions<Record<string, unknown[]>>,\n customMarshalOptions,\n );\n }\n\n // Setup test environment (if enabled)\n if (opts.testEnvironment) {\n const testEnvOptions: TestEnvironmentOptions | undefined =\n typeof opts.testEnvironment === \"object\"\n ? opts.testEnvironment\n : undefined;\n state.handles.testEnvironment = await setupTestEnvironment(\n context,\n testEnvOptions\n );\n }\n\n // Setup playwright - AFTER test environment so expect can be extended\n if (opts.playwright) {\n if (!opts.playwright.handler) {\n throw new Error(\n \"Playwright configured without handler. Provide playwright.handler in createRuntime options.\"\n );\n }\n\n // Determine event handler\n // If console: true and we have a console handler, wrap onEvent to route browser logs\n let eventCallback = opts.playwright.onEvent;\n\n if (opts.playwright.console && opts.console?.onEntry) {\n const originalCallback = eventCallback;\n const consoleHandler = opts.console.onEntry;\n eventCallback = (event) => {\n // Call original callback if provided\n if (originalCallback) {\n originalCallback(event);\n }\n // Route browser console logs through console handler as browserOutput entry\n if (event.type === \"browserConsoleLog\") {\n consoleHandler({\n type: \"browserOutput\",\n level: event.level,\n stdout: event.stdout,\n timestamp: event.timestamp,\n });\n }\n };\n }\n\n const playwrightSetupOptions: PlaywrightSetupOptions = {\n handler: opts.playwright.handler,\n timeout: opts.playwright.timeout,\n // Don't print directly if routing through console handler\n console: opts.playwright.console && !opts.console?.onEntry,\n onEvent: eventCallback,\n };\n\n state.handles.playwright = await setupPlaywright(context, playwrightSetupOptions);\n }\n\n // Create fetch handle wrapper\n const fetchHandle: RuntimeFetchHandle = {\n async dispatchRequest(\n request: Request,\n options?: DispatchRequestOptions\n ): Promise<Response> {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.dispatchRequest(request, options);\n },\n getUpgradeRequest() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.getUpgradeRequest();\n },\n dispatchWebSocketOpen(connectionId: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketOpen(connectionId);\n },\n dispatchWebSocketMessage(\n connectionId: string,\n message: string | ArrayBuffer\n ) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketMessage(connectionId, message);\n },\n dispatchWebSocketClose(connectionId: string, code: number, reason: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketClose(connectionId, code, reason);\n },\n dispatchWebSocketError(connectionId: string, error: Error) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchWebSocketError(connectionId, error);\n },\n onWebSocketCommand(callback: (cmd: WebSocketCommand) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onWebSocketCommand(callback);\n },\n hasServeHandler() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.hasServeHandler();\n },\n hasActiveConnections() {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.hasActiveConnections();\n },\n dispatchClientWebSocketOpen(socketId: string, protocol: string, extensions: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketOpen(socketId, protocol, extensions);\n },\n dispatchClientWebSocketMessage(socketId: string, data: string | ArrayBuffer) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketMessage(socketId, data);\n },\n dispatchClientWebSocketClose(socketId: string, code: number, reason: string, wasClean: boolean) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketClose(socketId, code, reason, wasClean);\n },\n dispatchClientWebSocketError(socketId: string) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchClientWebSocketError(socketId);\n },\n onClientWebSocketCommand(callback: (cmd: ClientWebSocketCommand) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onClientWebSocketCommand(callback);\n },\n onEvent(callback: (event: string, payload: unknown) => void) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n return state.handles.fetch.onEvent(callback);\n },\n dispatchEvent(event: string, payload: unknown) {\n if (!state.handles.fetch) {\n throw new Error(\"Fetch handle not available\");\n }\n state.handles.fetch.dispatchEvent(event, payload);\n },\n };\n\n // Create timers handle wrapper\n const timersHandle: RuntimeTimersHandle = {\n clearAll() {\n state.handles.timers?.clearAll();\n },\n };\n\n // Create console handle wrapper\n const consoleHandle: RuntimeConsoleHandle = {\n reset() {\n state.handles.console?.reset();\n },\n getTimers() {\n return state.handles.console?.getTimers() ?? new Map();\n },\n getCounters() {\n return state.handles.console?.getCounters() ?? new Map();\n },\n getGroupDepth() {\n return state.handles.console?.getGroupDepth() ?? 0;\n },\n };\n\n // Create test environment handle wrapper\n const testEnvironmentHandle: RuntimeTestEnvironmentHandle = {\n async runTests(timeout?: number): Promise<RunResults> {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n\n if (timeout === undefined) {\n return runTestsInContext(state.context);\n }\n\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => reject(new Error(\"Test timeout\")), timeout);\n });\n\n try {\n return await Promise.race([\n runTestsInContext(state.context),\n timeoutPromise,\n ]);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n },\n hasTests(): boolean {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n return hasTestsInContext(state.context);\n },\n getTestCount(): number {\n if (!state.handles.testEnvironment) {\n throw new Error(\n \"Test environment not enabled. Set testEnvironment: true in createRuntime options.\"\n );\n }\n return getTestCountInContext(state.context);\n },\n reset() {\n state.handles.testEnvironment?.dispose();\n },\n };\n\n // Create playwright handle wrapper\n const playwrightHandle: RuntimePlaywrightHandle = {\n getCollectedData(): CollectedData {\n if (!state.handles.playwright) {\n throw new Error(\n \"Playwright not configured. Provide playwright.handler in createRuntime options.\"\n );\n }\n return {\n browserConsoleLogs: state.handles.playwright.getBrowserConsoleLogs(),\n networkRequests: state.handles.playwright.getNetworkRequests(),\n networkResponses: state.handles.playwright.getNetworkResponses(),\n };\n },\n clearCollectedData() {\n state.handles.playwright?.clearCollected();\n },\n };\n\n return {\n id,\n pendingCallbacks: state.pendingCallbacks,\n\n // Module handles\n fetch: fetchHandle,\n timers: timersHandle,\n console: consoleHandle,\n testEnvironment: testEnvironmentHandle,\n playwright: playwrightHandle,\n\n async eval(\n code: string,\n filenameOrOptions?: string | EvalOptions\n ): Promise<void> {\n const runEval = async (): Promise<void> => {\n // Parse options\n const options =\n typeof filenameOrOptions === \"string\"\n ? { filename: filenameOrOptions }\n : filenameOrOptions;\n\n // Normalize filename to absolute path for module resolution\n const filename = normalizeEntryFilename(options?.filename);\n\n try {\n // Transform entry code: strip types, validate, wrap in async function\n const transformed = await transformEntryCode(code, filename);\n if (transformed.sourceMap) {\n state.sourceMaps.set(filename, transformed.sourceMap);\n }\n\n // Compile as ES module\n const mod = await state.isolate.compileModule(transformed.code, {\n filename,\n });\n\n // Track entry module filename and import chain\n state.moduleToFilename.set(mod, filename);\n state.moduleImportChain.set(filename, []);\n\n // Instantiate with module resolver\n const resolver = createModuleResolver(state);\n try {\n await mod.instantiate(state.context, resolver);\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n\n // Extract failing module specifier and export name from V8 error\n // e.g. \"The requested module './foo' does not provide an export named 'Bar'\"\n const specifierMatch = error.message.match(/The requested module '([^']+)'/);\n const exportMatch = error.message.match(/export named '([^']+)'/);\n const failingSpecifier = specifierMatch?.[1];\n const failingExport = exportMatch?.[1];\n\n // Find which file imports the failing specifier\n const importerFile = failingSpecifier\n ? state.specifierToImporter.get(failingSpecifier)\n : undefined;\n\n // Build the full import chain from entry → importer → failing module\n const details: string[] = [];\n\n if (importerFile) {\n const chain = state.moduleImportChain.get(importerFile) ?? [];\n const fullChain = [...chain, importerFile];\n if (failingSpecifier) fullChain.push(failingSpecifier);\n const trimmed = fullChain.length > 12 ? fullChain.slice(-12) : fullChain;\n const prefix = fullChain.length > 12 ? ' ...\\n' : '';\n details.push('Import chain:\\n' + prefix + trimmed.map(p => ` ${p}`).join('\\n -> '));\n } else if (failingSpecifier) {\n // Fallback: search moduleImportChain for any path containing the specifier\n for (const [modPath, chain] of state.moduleImportChain) {\n if (modPath.includes(failingSpecifier) || modPath.endsWith(failingSpecifier)) {\n const fullChain = [...chain, modPath];\n const trimmed = fullChain.length > 12 ? fullChain.slice(-12) : fullChain;\n details.push('Import chain:\\n' + trimmed.map(p => ` ${p}`).join('\\n -> '));\n break;\n }\n }\n }\n\n if (failingExport && failingSpecifier) {\n details.push(\n `Hint: If '${failingExport}' is a TypeScript type/interface, use \\`import type\\` to prevent it from being resolved at runtime:\\n` +\n ` import type { ${failingExport} } from '${failingSpecifier}';`\n );\n }\n\n const suffix = details.length > 0 ? '\\n\\n' + details.join('\\n\\n') : '';\n error.message = `Module instantiation failed: ${error.message}${suffix}`;\n throw error;\n }\n\n // Evaluate - only resolves imports and defines the default function (no timeout needed)\n await mod.evaluate();\n\n // Get the default export and run it with timeout\n const ns = mod.namespace;\n const runRef = await ns.get(\"default\", { reference: true });\n try {\n await runRef.apply(undefined, [], {\n result: { promise: true },\n });\n } finally {\n runRef.release();\n }\n\n // Await pending callbacks (no-op for local use, enables daemon IPC flush)\n if (state.pendingCallbacks.length > 0) {\n await Promise.all(state.pendingCallbacks);\n state.pendingCallbacks.length = 0;\n }\n } catch (err) {\n const error = err as Error;\n if (error.stack && state.sourceMaps.size > 0) {\n error.stack = mapErrorStack(error.stack, state.sourceMaps);\n }\n throw error;\n }\n };\n\n const queuedEval = state.evalChain.then(runEval, runEval);\n state.evalChain = queuedEval.then(\n () => undefined,\n () => undefined\n );\n return queuedEval;\n },\n\n clearModuleCache() {\n state.moduleCache.clear();\n state.moduleLoadsInFlight.clear();\n state.moduleToFilename.clear();\n state.moduleImportChain.clear();\n state.specifierToImporter.clear();\n state.sourceMaps.clear();\n // staticModuleCache and transformCache intentionally preserved\n },\n\n async dispose(): Promise<void> {\n // Dispose custom function reference\n if (state.customFnInvokeRef) {\n state.customFnInvokeRef.release();\n }\n\n // Dispose all handles (in reverse order of setup)\n state.handles.playwright?.dispose();\n state.handles.testEnvironment?.dispose();\n state.handles.fs?.dispose();\n state.handles.fetch?.dispose();\n state.handles.crypto?.dispose();\n state.handles.path?.dispose();\n state.handles.timers?.dispose();\n state.handles.encoding?.dispose();\n state.handles.console?.dispose();\n state.handles.core?.dispose();\n\n // Clear module cache\n state.moduleCache.clear();\n state.moduleLoadsInFlight.clear();\n\n // Release context and dispose isolate\n state.context.release();\n state.isolate.dispose();\n },\n };\n}\n\n// Re-export all package types and functions\nexport { setupCore } from \"@ricsam/isolate-core\";\nexport type { CoreHandle, SetupCoreOptions } from \"@ricsam/isolate-core\";\n\nexport { setupConsole } from \"@ricsam/isolate-console\";\nexport {\n simpleConsoleHandler,\n type SimpleConsoleCallbacks,\n} from \"@ricsam/isolate-console/utils\";\nexport type {\n ConsoleHandle,\n ConsoleOptions,\n ConsoleEntry as ConsoleEntryFromConsole,\n} from \"@ricsam/isolate-console\";\n\nexport { setupCrypto } from \"@ricsam/isolate-crypto\";\nexport type { CryptoHandle } from \"@ricsam/isolate-crypto\";\n\nexport { setupEncoding } from \"@ricsam/isolate-encoding\";\nexport type { EncodingHandle } from \"@ricsam/isolate-encoding\";\n\nexport { setupFetch } from \"@ricsam/isolate-fetch\";\nexport type {\n FetchHandle,\n FetchOptions,\n WebSocketCommand,\n UpgradeRequest,\n ClientWebSocketCommand,\n} from \"@ricsam/isolate-fetch\";\n\nexport { setupFs, createNodeFileSystemHandler } from \"@ricsam/isolate-fs\";\nexport type {\n FsHandle,\n FsOptions,\n FileSystemHandler,\n NodeFileSystemHandlerOptions,\n} from \"@ricsam/isolate-fs\";\n\nexport { setupPath } from \"@ricsam/isolate-path\";\nexport type { PathHandle, PathOptions } from \"@ricsam/isolate-path\";\n\nexport { setupTimers } from \"@ricsam/isolate-timers\";\nexport type { TimersHandle } from \"@ricsam/isolate-timers\";\n\nexport {\n setupTestEnvironment,\n runTests,\n hasTests,\n getTestCount,\n} from \"@ricsam/isolate-test-environment\";\nexport type {\n TestEnvironmentHandle,\n TestEnvironmentOptions,\n RunResults,\n TestResult,\n TestInfo,\n TestError,\n TestEvent,\n SuiteInfo,\n SuiteResult,\n} from \"@ricsam/isolate-test-environment\";\n\nexport {\n setupPlaywright,\n createPlaywrightHandler,\n defaultPlaywrightHandler,\n getDefaultPlaywrightHandlerMetadata,\n} from \"@ricsam/isolate-playwright\";\nexport type {\n PlaywrightHandle,\n PlaywrightSetupOptions,\n PlaywrightCallback,\n PlaywrightEvent,\n NetworkRequestInfo,\n NetworkResponseInfo,\n BrowserConsoleLogEntry,\n} from \"@ricsam/isolate-playwright\";\n"
6
6
  ],
7
- "mappings": ";AAAA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,mCAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA,cAEE;AAAA,cACA;AAAA,kBACA;AAAA;AAEF;AAAA;AAAA;AAqDA;AAAA;AAAA;AAAA;AAo+CA,sBAAS;AAGT,yBAAS;AACT;AAAA;AAAA;AAUA,wBAAS;AAGT,0BAAS;AAGT,uBAAS;AAST,oBAAS;AAQT,sBAAS;AAGT,wBAAS;AAGT;AAAA,0BACE;AAAA;AAAA;AAAA;AAAA;AAiBF;AAAA,qBACE;A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AAM;AAAA,MAGhC,MAAM,QAAQ,QAAQ;AAAA,MACtB,MAAM,QAAQ,QAAQ;AAAA;AAAA,EAE1B;AAAA;",
8
+ "debugId": "30C3A0A75715847864756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/isolate-runtime",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "type": "module"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/isolate-runtime",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "main": "./dist/cjs/index.cjs",
5
5
  "types": "./dist/types/index.d.ts",
6
6
  "exports": {