Skip to content

v0.3.1

Choose a tag to compare

@ggoodman ggoodman released this 23 Jul 10:41
3ac3767

Build Node.js runtimes without copying Host Node

Runtime-driver packages can now reuse code-mode's canonical Node.js 24
declarations and guest execution semantics through
@torkbot/code-mode/node-runtime:

import {
  assertNode24Version,
  createNode24BootstrapSource,
  loadNode24TypeDefinitionFiles,
} from "@torkbot/code-mode/node-runtime";

const driver: RuntimeDriver<MyNodeOptions> = {
  description: "My Node.js 24 runtime",
  loadTypeDefinitionFiles: loadNode24TypeDefinitionFiles,
  async connect(options, { runnerSource, signal }) {
    const version = await readRuntimeNodeVersion(options, signal);
    assertNode24Version(version, "My Node runtime");

    const source = createNode24BootstrapSource({
      runnerSource,
      channelFileDescriptor: 3,
    });
    return launchRuntimeNode(options, source, signal);
  },
};

The generated self-contained ESM provides the behavior Node runtime drivers
need to share:

  • fresh root modules with native ESM and package resolution from
    process.cwd();
  • multiplexed execution scheduling;
  • Node-formatted captured console output with stdout/stderr provenance;
  • the version-matched runner supplied by createRuntimeFactory().

Drivers still own process or VM launch, the connected file descriptor, ambient
stdio, boot cancellation, and resource disposal. Host Node now consumes this
same authoring surface, so Sandbox Node and future Node substrates can share
execution semantics without importing or copying Host Node lifecycle code.

This fixes the Node driver-authoring gap in v0.3.0. Install the patch with:

npm install @torkbot/code-mode@0.3.1