Skip to main content
Architecture

Node.js Compatibility

Review the Node.js built-in modules and compatibility guarantees available to JavaScript and TypeScript code running inside agentOS VMs.

Guest JavaScript never touches the host Node.js runtime.

  • Every node: import/require resolves to a VM-backed bridge or an in-isolate implementation.
  • Unknown or denied modules fail explicitly with ERR_ACCESS_DENIED.
  • The guest reports Node.js v22.0.0 via process.version.

How builtins are backed:

  • VM-backed — routes through the VM filesystem, sockets, processes, DNS, or entropy.
  • In-isolate — pure JavaScript running inside V8; no host access.
  • Denied — importing throws ERR_ACCESS_DENIED.
A guest never falls through to a real host builtin. Anything not bridged or implemented in the isolate is denied.

VM-backed builtins

ModuleBacked by
fs, fs/promisesVM filesystem: fds, streams, metadata, symlinks, polling watchers.
child_processVM process table. spawn, exec, execFile, sync variants.
net, dgramVM TCP, Unix-socket, and UDP tables.
dns, dns/promisesVM DNS resolver.
http, https, http2, tlsVM socket/TLS paths: clients, servers, pooling.
osVM-scoped platform, arch, hostname, CPU, memory, user.
cryptoEntropy, hashes, HMAC, ciphers, scrypt, UUIDs, WebCrypto.
processVM env, cwd, signals, timers, stdio, umask.
modulecreateRequire, builtin resolution, basic Module compat.
consoleBounded formatting, guest stdout/stderr.
readline, sqlite, ttyVM-backed compatibility surfaces.
timers, timers/promisesTimeout, interval, immediate, promise variants.
stream/web, stream/consumers, stream/promisesWeb Streams + stream helpers.
  • Network builtins obey the VM permission policy.
  • Network access is denied until granted by the VM creator.

In-isolate builtins

  • Full: path, buffer, events, stream, util, assert, url, querystring, string_decoder, zlib, punycode, constants, sys. Default and named ESM imports supported.
  • Async context: AsyncLocalStorage and AsyncResource in async_hooks behave as in Node.js, including across native await, promises, timers, and callbacks from sockets, servers, child processes, and signals. Overlapping calls do not see each other’s store.
  • Feature-detection shims: createHook and the async ID functions in async_hooks, diagnostics_channel, perf_hooks, worker_threads, vm, v8. worker_threads does not create real worker threads.
  • v8.serialize, v8.deserialize, v8.Serializer, and v8.Deserializer use JSON, not the V8 wire format. They accept only JSON-safe values: plain objects, dense arrays, strings, finite numbers, booleans, and null. Other values, such as Map, Date, BigInt, undefined, typed arrays, and shared or circular references, throw an error with code ERR_NOT_IMPLEMENTED.

Denied builtins

cluster, domain, inspector, repl, trace_events, wasi.

Global APIs

  • Modern web globals: fetch, Headers, Request, Response, TextEncoder/TextDecoder, Buffer, URL APIs, Blob, File, FormData, abort APIs, structuredClone, performance, WebAssembly.
  • fetch() uses VM sockets and follows the same policy as http/net.
  • Uint8Array has toHex, toBase64, fromHex, fromBase64, setFromHex, and setFromBase64, with the alphabet, omitPadding, and lastChunkHandling options.

node:sqlite

  • new DatabaseSync(path) uses a file in the VM filesystem.
  • ATTACH DATABASE and VACUUM INTO accept only :memory: and the empty temporary name. Other targets fail with an authorization error, including paths in the VM.
  • PRAGMA writable_schema has no effect. Pragmas that change process-wide SQLite state, such as hard_heap_limit, fail with an authorization error.

Modules and output

  • ESM and CommonJS both use the VM filesystem and normal node_modules resolution.
  • Console/stream output flows through the bounded process-output path — see Processes & Shells.
import { AgentOs } from "@rivet-dev/agentos-core";

const runtime = await AgentOs.create();

try {
	const result = await runtime.javascript.evaluate<{
		filename: string;
		digest: string;
	}>(`(async () => {
		const { createHash } = await import("node:crypto");
		const { join } = await import("node:path");
		return {
			filename: join("/workspace", "report.json"),
			digest: createHash("sha256").update("agentos").digest("hex"),
		};
	})()`);

	if (result.outcome !== "succeeded") throw new Error(result.error.message);
	console.log(result.value);
} finally {
	await runtime.dispose();
}

Back to the JavaScript guide for TypeScript, packages, files, processes, networking, host functions, permissions, and limits.

Edit this page Last updated November 24, 2026