pi-mono/packages/codemode/src/cloudflare-modules.d.ts
Armin Ronacher 748b351fe2 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.
2026-10-10 14:41:36 +02:00

19 lines
791 B
TypeScript

// Modules that only exist when cloudflare.ts is built by Wrangler. Consumers get the real
// declarations from @cloudflare/workers-types or `wrangler types`; these keep this repository's
// type check free of a Workers type dependency and are not published.
declare module "cloudflare:workers" {
export abstract class DurableObject<Env = unknown> {
protected ctx: unknown;
protected env: Env;
constructor(ctx: unknown, env: Env);
}
}
// A pattern, not the exact specifier: coding-agent declares "quickjs-wasi/quickjs.wasm" as a path
// for Bun, and an exact declaration takes precedence where both are visible. cloudflare.ts casts the
// import to the compiled module Wrangler actually produces.
declare module "*/quickjs.wasm" {
const module: unknown;
export default module;
}