Repository navigation
feat(runtime)!: remove Node-only code from the runtime, and smoke-test it on Workers and Vercel Edge - #8108
Conversation
…e code Cloudflare Workers without nodejs_compat and Vercel Edge cannot resolve Node built-ins, so every static Node import in the runtime's module graph breaks the bundle, even where the code path never runs. - randomUUID: use globalThis.crypto.randomUUID() (4 files). - Skill registry SHA-256: use crypto.subtle.digest via a new sha256Hex helper; both callers were already async. - Managed channel assets: base64 via btoa (bytesToBase64) instead of Buffer. Tests pin both helpers to Buffer / node:crypto output. - URL download: load node:dns/http/https/net through process.getBuiltinModule so edge bundlers never see a Node specifier. Downloads still fail closed where the modules are missing. Tests now stub getBuiltinModule instead of vi.mock-ing the specifier. Refs PE-1107. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The edge-safe license verifier (Web Crypto) is async, but the Intelligence runtime verified the token synchronously in its constructor. Cloudflare Workers also reject crypto work in global scope, which is where runtimes are usually constructed. The `licenseChecker` field is replaced by a memoized `getLicenseChecker(): Promise<LicenseChecker | undefined>` that verifies on first use. The constructor signature is unchanged; /info awaits the checker. Runtimes without Intelligence resolve `undefined`, and the method is optional on `CopilotRuntimeLike` so external implementations stay source-compatible. BREAKING CHANGE: `runtime.licenseChecker` is removed. Use `await runtime.getLicenseChecker()`. Refs PE-1107. Co-Authored-By: Claude Opus 5.5 <[email protected]>
URL download now loads Node networking modules through process.getBuiltinModule (Node 20.16+), which keeps edge bundlers from seeing Node specifiers. 20.19 / 22.12 is also the floor where require(esm) works without a flag, which an ESM-only 2.0 needs anyway (PE-1110). Node 20 has been EOL since 2026-04-30. BREAKING CHANGE: @copilotkit/runtime no longer supports Node 20.0-20.18 or 22.0-22.11. Refs PE-1107. Co-Authored-By: Claude Opus 5.5 <[email protected]>
New tools/runtime-edge-smoke runs a CopilotRuntime + fetch handler on workerd without nodejs_compat (through wrangler) and on the Vercel Edge runtime VM, and checks GET /info and a streamed run on both. It also fails if the runtime's own dist imports a Node built-in outside the /node entry. Dependencies that still need Node are stubbed, each tied to its fix (PE-1105 pino, PE-1102 Vertex, learned-skills yauzl, and the upstream crypto PRs); removing a stub when its fix lands turns the test into proof of that fix. Runs as the `edge` job of the runtime integration workflow. Refs PE-1107. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Web Crypto Ed25519 is stable from these versions. Earlier 20.19.x and 22.12.0 print an ExperimentalWarning when the license is verified. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 1
Please check the settings in the CodeRabbit UI or the
|
|
Size Change: +903 B (+0.04%) Total Size: 2.02 MB 📦 View Changed
ℹ️ View Unchanged
|
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/intelligence-langgraph
@copilotkit/intelligence-mastra
@copilotkit/learning
@copilotkit/markdown-renderer
@copilotkit/mcp-apps-renderer
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/runtime
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
The runtime 2.0 guide now covers getLicenseChecker() and the new Node.js floor. The codemod adds a TODO to each read of licenseChecker, because the replacement is async. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Production Digest-Pinning AuditAll 43 services digest-pinned. Run 2026-10-30 06:38:48 PDT — 0 finding(s). |
…-edge # Conflicts: # pnpm-lock.yaml
Run
pnpm nx run runtime-edge-smoke:smoketo see the runtime serve/infoand stream a run on Cloudflare Workers withoutnodejs_compatand on Vercel Edge. This PR removes the Node-only code from the runtime itself and adds that smoke test to CI. Users cannot deploy to edge yet: some dependencies still need Node. Each one has its own PR or ticket, and the smoke test stubs it until the fix lands.What does this PR do?
node:cryptoandBuffer. UUIDs, SHA-256 and base64 useglobalThis.cryptoandbtoa.processat import. Workers withoutnodejs_compathave noprocess, so the runtime crashed while it loaded. A newprocessEnv()helper in@copilotkit/sharedreplaces every directprocess.envread in the runtime.runtime.licenseCheckerbecomesawait runtime.getLicenseChecker().process.getBuiltinModule. Bundlers no longer seenode:imports. On edge, a download fails with a clear error, as the docs already say.tools/runtime-edge-smokeand CI jobruntime / edge (Workers, Vercel Edge). It runs a real Worker on workerd and the Verceledge-runtimeVM. It also fails if the runtimedistimports a Node built-in outside@copilotkit/runtime/node.The
enginesfloor is now^20.19.3 || >=22.13.0. On these versions,require(esm)needs no flag and Web Crypto Ed25519 prints noExperimentalWarning.Migration: the v2 codemod adds a
TODO(copilotkit-2.0)to each read ofruntime.licenseChecker. It does not rewrite the read, because the new method is async. The runtime 2.0 guide has new "License checker" and "Node.js version" sections, and the codemod's agent skill knows both changes.BREAKING CHANGE:
runtime.licenseCheckeris removed. Useawait runtime.getLicenseChecker()instead.@copilotkit/runtimenow requires Node^20.19.3 || >=22.13.0. If you use an earlier Node version, upgrade Node.Related PRs and Issues
cryptoin the smoke test: fix(a2ui): run without node:crypto on edge runtimes ag-ui-protocol/ag-ui#3268 (A2UI middleware), fix(mcp-apps): run without node:crypto on edge runtimes ag-ui-protocol/ag-ui#3269 (MCP Apps middleware), CopilotKit/Intelligence#2191 (@copilotkit/license-verifier/web)pino), PE-1141 (yauzl)@ag-ui/client1.0.2 makes a UUID in the agent constructor. Until PE-1142 lands, the smoke Worker creates its agent per request.Checklist
!(for examplefeat(react-core)!: ...) and the description has aBREAKING CHANGE:line with migration steps. See VERSIONING.mdTesting
Commands run
pnpm nx run runtime-edge-smoke:smoke: passes. Workers and Vercel Edge each return/info200 and stream 5 events in order.pnpm nx run-many -t test -p @copilotkit/runtime @copilotkit/shared: passes (180 and 30 test files).pnpm nx run-many -t test check-types -p @copilotkit/v2-migration: passes (33.tsfixtures, 3 of them new).distguard fails as expected: I added anode:cryptoimport to adistfile, and the smoke test stopped with exit 1.cryptostub. The A2UI middleware ran in workerd, and the license was verified lazily on/info. That run is not on this branch.pnpm test:pr. Lint and format ran in the pre-commit hook. In one hook run, achannels-teamstest failed under load. It passed 4 of 4 times alone, and this PR does not touch it.Manual test
pnpm install.pnpm nx run runtime-edge-smoke:smoke.✓lines:runtime dist,Cloudflare Workers (no nodejs_compat),Vercel Edge runtime.yauzlentry fromaliasinwrangler.jsoncand fromSTUBSinrun.mjs. Run step 2 again. The Workers bundle fails onyauzl, which is the blocker that PE-1141 tracks.How this PR makes testing easy
pnpm nx run runtime-edge-smoke:smoke, which also runs in CI asruntime / edge (Workers, Vercel Edge).codemods/v2-migration/tests/ts/:runtime-license-checker,-second-run(no duplicate TODO),-unrelated(a file without a CopilotKit runtime import is not changed).web-crypto.test.ts(output is identical toBufferandnode:crypto),runtime-license-checker.test.ts(lazy, memoized, env token, shim),process-env.test.ts.tools/runtime-edge-smoke/README.mdmaps each stub to its fix. To prove a fix, delete its stub.Risk / rollback
runtime.licenseCheckerstops compiling. The codemod marks each read, and the fix is one line (see Public API change)./inforequest, not at startup.engineswarning. Withengine-strict, the install fails.Public API change
Before
After
@copilotkit/runtimeengines.node:>=20before,^20.19.3 || >=22.13.0after.🤖 Generated with Claude Code