Describe the bug
When trying to use codemode feature in local development with wrangler dev, the Worker fails to start with a fatal error: Uncaught ReferenceError: __filename is not defined. This occurs because the json-schema-to-typescript library (a runtime dependency of codemode) requires Node.js filesystem APIs that are not available in the Cloudflare Workers runtime, even with the nodejs_compat, experimental, enable_ctx_exports], compatibility flags enabled.
To Reproduce
Add codemode to an existing mcp-auth0-oidc repo (or likely any other repo) and try to run wrangler dev,
Expected behavior
The codemode feature should initialize successfully and wrap the provided tools for code generation workflows. The Worker should start without errors in local development.
Version:
- Agents SDK: 0.2.20 (latest stable)
- Wrangler: 4.45.3
Additional context
This was completed while following instructions in the official codemode docs https://github.com/cloudflare/agents/blob/main/docs/codemode.md + referencing the example there of codemode as well