Skip to content

feat(codemode): add browser iframe executor#1468

Merged
mattzcarey merged 17 commits intomainfrom
feat/browser-iframe-executor-upstream
May 6, 2026
Merged

feat(codemode): add browser iframe executor#1468
mattzcarey merged 17 commits intomainfrom
feat/browser-iframe-executor-upstream

Conversation

@mattzcarey
Copy link
Copy Markdown
Contributor

@mattzcarey mattzcarey commented May 6, 2026

Summary

  • cherry-picks MiguelsPizza's browser iframe executor contribution from issue In Browser CodeMode Executors to work for WebMCP Tools or any front end tool #1111
  • adds @cloudflare/codemode/browser export with BrowserToolProvider, BrowserToolExecutor, and iframe sandbox executor/runtime
  • adds browser tests for provider/executor paths and docs for Browser + WebMCP usage
  • updates the browser Vitest config for the current @vitest/browser-playwright provider API

Closes/addresses #1111

Verification

  • npx nx run @cloudflare/codemode:build
  • npx nx run @cloudflare/codemode:test
  • npx nx run @cloudflare/codemode:test:browser

Note: npm run check:exports only passes for @cloudflare/codemode unless all other packages are built first; codemode exports validate successfully.


Open in Devin Review

MiguelsPizza and others added 7 commits May 6, 2026 13:13
Add IframeSandboxExecutor, a browser-native executor that runs
LLM-generated code in a sandboxed iframe using postMessage for
tool dispatch. Available via @cloudflare/codemode/browser.

Also adds createBrowserCodeTool(), a zero-dependency equivalent
of createCodeTool that accepts JSON Schema tools (object or array)
and returns a plain tool descriptor with inputSchema, outputSchema,
and execute. No ai or zod peer deps required.

The iframe uses sandbox="allow-scripts" with a restrictive CSP.
Tool calls flow through postMessage; the iframe is torn down after
each execution.

dist/browser.js: 11.3 KB raw, 3.77 KB gzip. Zero new dependencies.

Closes #1111

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 6, 2026

🦋 Changeset detected

Latest commit: 53c13db

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

This PR includes changesets to release 1 package
Name Type
@cloudflare/codemode Patch

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

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

Comment on lines +67 to 71
"./browser": {
"types": "./dist/browser.d.ts",
"import": "./dist/browser.js",
"require": "./dist/browser.js"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Missing changeset for new @cloudflare/codemode public API export

This PR adds a new ./browser export path to packages/codemode/package.json, which is a public API change. Per AGENTS.md: "Changes to packages/ that affect the public API or fix bugs need a changeset." None of the existing changesets (.changeset/calm-cups-reflect.md, .changeset/fix-voice-stt-turns.md, .changeset/think-replay-sendifopen.md) reference @cloudflare/codemode. A changeset is required before merging.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

@aron-cf aron-cf left a comment

Choose a reason for hiding this comment

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

Very cool! Played around with the example, it works great.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 6, 2026

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@1468

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@1468

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@1468

hono-agents

npm i https://pkg.pr.new/hono-agents@1468

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@1468

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@1468

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@1468

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@1468

commit: 53c13db

@mattzcarey mattzcarey merged commit 186a2a4 into main May 6, 2026
4 checks passed
@mattzcarey mattzcarey deleted the feat/browser-iframe-executor-upstream branch May 6, 2026 15:23
@github-actions github-actions Bot mentioned this pull request May 6, 2026
@MiguelsPizza
Copy link
Copy Markdown
Contributor

Awesome! Thanks for this @mattzcarey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants