feat(codemode): add browser iframe executor#1468
Conversation
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 detectedLatest commit: 53c13db The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
| "./browser": { | ||
| "types": "./dist/browser.d.ts", | ||
| "import": "./dist/browser.js", | ||
| "require": "./dist/browser.js" | ||
| } |
There was a problem hiding this comment.
🟡 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
aron-cf
left a comment
There was a problem hiding this comment.
Very cool! Played around with the example, it works great.
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
|
Awesome! Thanks for this @mattzcarey |
Summary
Closes/addresses #1111
Verification
Note: npm run check:exports only passes for @cloudflare/codemode unless all other packages are built first; codemode exports validate successfully.