Skip to content

computer: Rename WorkerJavaScriptBackend to CodemodeBackend - #305

Open
ben-reitz wants to merge 1 commit into
browser/browser-modulefrom
browser/codemode-backend
Open

ben-reitz wants to merge 1 commit into
browser/browser-modulefrom
browser/codemode-backend

Conversation

@ben-reitz

@ben-reitz ben-reitz commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

The backend that runs ECMAScript modules in a Dynamic Worker is where codemode modules and the codemode:* host modules live, but WorkerJavaScriptBackend names where it runs rather than what it's for. The docs and comments also called it several other things: "Worker JavaScript", "isolate JavaScript" and "the JavaScript backend".

This change renames it to CodemodeBackend and uses that name everywhere, including its default id, which is now "codemode" instead of "worker-javascript". There's no alias for the old names. This is a breaking change in two steps. The first is a rename:

import { WorkerJavaScriptBackend } from "@cloudflare/computer/backends/worker-javascript";
// →
import { CodemodeBackend } from "@cloudflare/computer/backends/codemode";

WorkerJavaScriptBackend        → CodemodeBackend
WorkerJavaScriptBackendOptions → CodemodeBackendOptions

The second is the id. Runs are saved under the id of the backend that started them, and a backend only looks at its own. A backend under the new id doesn't fail on runs saved as "worker-javascript"; it ignores them. It doesn't resume them, pending() doesn't list their waiting calls, and getExec() can't find them. An app that wants to keep those runs, or its existing backend: "worker-javascript" and exec.backends keys, passes the old id:

new CodemodeBackend({ id: "worker-javascript", loader: env.LOADER });

Otherwise it changes those references to "codemode", and runs that were in flight when it deploys are out of reach. The exec tool shows the model each backend's id, so it now offers this one as "codemode". The changeset spells out both paths and we should make sure this change is clear in the ugprade notes.

The source folder moves to packages/computer/src/backends/codemode/, and the example moves to examples/codemode, with its Worker and R2 bucket renamed to computer-codemode-example and computer-codemode-hello. docs/17_isolate_javascript.md keeps its file name and title, since links point at them.

To check it, build and import the new path:

npm run build --workspace @cloudflare/computer
ls packages/computer/dist/backends/codemode

The existing tests cover the backend under its new name and id, and every test config in packages/computer passes. The package README, the root README, the design docs, and the egress, rlm and celld examples use the new names.

Agents code that imports @cloudflare/computer/backends/worker-javascript or selects the "worker-javascript" backend needs the same changes when it picks up this release.


Devin Review

@ben-reitz ben-reitz added the allow-pr Allow a PR to remain open. label Nov 4, 2026
@changeset-bot

changeset-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 330a701

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@cloudflare/computer Minor
@cloudflare/dofs Minor
@cloudflare/computer-rpc Minor
@cloudflare/computerd Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@ben-reitz
ben-reitz added this pull request to stack #304 November 4, 2026 12:24
@pkg-pr-new

pkg-pr-new Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@cloudflare/computer@305

commit: 330a701

@ben-reitz
ben-reitz removed this pull request from stack #304 November 4, 2026 13:38
@ben-reitz
ben-reitz added this pull request to stack #306 November 4, 2026 13:39
The backend that runs ECMAScript modules in a Dynamic Worker is the
home of codemode modules and the `codemode:*` host modules, but its
name described where it runs rather than what it is for. Rename it to
`CodemodeBackend`, its options to `CodemodeBackendOptions`, and its
import path to `@cloudflare/computer/backends/codemode`, with no alias
for the old names. The source folder, the example, the docs and the
tests follow.

The backend's default id and its `type` change from
`"worker-javascript"` to `"codemode"`, so the exec tool now offers it
to the model as `"codemode"`. Runs are saved under the id of the
backend that started them, and a backend only looks at its own, so a
backend under the new id leaves runs saved under the old one alone:
it doesn't resume them, list their waiting calls or find them by id.
Passing `id: "worker-javascript"` keeps them reachable. The changeset
describes both upgrade paths.

The example's Worker and R2 bucket are renamed to
`computer-codemode-example` and `computer-codemode-hello`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-pr Allow a PR to remain open.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant