Agent Context
AGENTS.md — @inbrowser/node
Architecture boundaries, host header invariants, and workflow conventions for @inbrowser/node.
Browser-isolated Node.js 22.18 container runtime for the @inbrowser monorepo.
Architecture invariants
Read docs/reference/architecture.md, docs/guide/limits.md, and docs/reference/threat-model.md before changing runtime code.
- Strict Worker boundaries (enforced by
scripts/check-boundaries.mjson everybuild):- Only
src/kernel.tsmay importmemfs. Guest processes never touchmemfsdirectly; all VFS access crosses the syscall channel. - Browser runtime sources under
src/**must never importnode:*host modules or rely on a Node-host fallback. src/runtime.ts,src/service-worker.ts, andsrc/sandbox-host.tsstay decoupled from guest-process internals.
- Only
- Zero runtime npm dependencies:
scripts/build.mjsbundles browser shims and the 31 pure-JS files undervendor/node-v22.18.0/lib/intodist/, copies lazy WebAssembly sidecars (sqlite.wasm,zlib-brotli.wasm,zlib-zstd.wasm,context-esbuild.wasm), and generatesdist/THIRD_PARTY_NOTICES.txt. Keepdependenciesabsent so consumer installs stay zero-bloat, and ensuredist/types/**emits zero bare imports to dev-only shim packages. - Lazy WASM cold boot: Never compile or instantiate heavy WASM sidecars (
sqlite.wasm,zlib-brotli.wasm,zlib-zstd.wasm,context-esbuild.wasm) during cold Worker boot; load them lazily on first module/codec use. - Honest boundaries: Unsupported APIs fail explicitly with
ENOSYSor Node-compatible error codes rather than silent no-ops. Do not claim untrusted-code isolation inside a single Worker realm; cross-origin isolation of host DOM/storage requiresSandboxContainer+ per-origin previews (BootOptions.preview.origin).
Verification
TERMINAL
bun run --cwd packages/node typecheck
bun run --cwd packages/node build
bun run --cwd packages/node test
PORT=4670 bun run --cwd packages/node test:e2e