feat(codemode): run sandboxes on Cloudflare Workers via a remote Durable Object

Split the host into transport-independent execution logic and a VM driver, so the VM can run in a worker thread (CodemodeSandbox, unchanged), on the calling thread (InlineCodemodeSandbox), or in another isolate over RPC (RemoteCodemodeSandbox).

Add the /portable entry without Node imports and the /cloudflare entry with CodemodeSandboxDurableObject, meant to be deployed as its own Worker so scripts never block the caller's thread. Scripts that compute without awaiting a tool are bounded by an interrupt budget, now also polled while draining promise jobs. examples/cloudflare shows the setup.
This commit is contained in:
Armin Ronacher 2026-10-10 14:41:36 +02:00
parent 42a3497d03
commit 748b351fe2
26 changed files with 2505 additions and 1242 deletions

View file

@ -13,7 +13,9 @@
"@earendil-works/pi-telemetry": ["./packages/telemetry/src/index.ts"],
"@earendil-works/pi-telemetry/testing": ["./packages/telemetry/src/testing/index.ts"],
"@earendil-works/pi-codemode": ["./packages/codemode/src/index.ts"],
"@earendil-works/pi-codemode/cloudflare": ["./packages/codemode/src/cloudflare.ts"],
"@earendil-works/pi-codemode/declarations": ["./packages/codemode/src/declarations.ts"],
"@earendil-works/pi-codemode/portable": ["./packages/codemode/src/portable.ts"],
"@earendil-works/pi-codemode/source": ["./packages/codemode/src/source.ts"],
"@earendil-works/pi-codemode/worker": ["./packages/codemode/src/runtime/worker.ts"],
"@earendil-works/pi-mcp": ["./packages/mcp/src/index.ts"],