Skip to content

Conversation

@threepointone
Copy link
Contributor

Summary

  • Migrate x402 from legacy x402 package to @x402/core and @x402/evm v2. Updates both server-side (withX402) and client-side (withX402Client) wrappers, with backward-compatible normalizeNetwork for legacy network names (e.g. "base-sepolia""eip155:84532"). The deprecated version field is preserved as a no-op for existing consumers. Adds 33 new unit tests covering payment flows, lazy initialization, token parsing, and error handling.
  • Rewrite both x402 examples (examples/x402 and examples/x402-mcp) to use the v2 @x402/* packages and CAIP-2 network identifiers.
  • Parallelize test execution with Vitest projects. Adds root vitest.config.ts with test.projects to both packages/agents (4 projects: workers, react, cli, x402) and packages/ai-chat (2 projects: workers, react). All test suites now run in parallel within a single vitest --run invocation, with named projects for clear output labeling and --project filtering for focused runs.
  • Simplify test scripts. Remove redundant check:test:* scripts from both packages. The test script is now just vitest --run, and individual suites are accessible via test:workers, test:react, etc. using --project.
  • Delete redundant e2e tests. The src/e2e/ directory (5 files, ~800 lines) tested MCP tool listing/calling and OAuth flows over real Cloudflare deploys via alchemy. All scenarios are already covered by the workers pool tests (streamable-http.test.ts, sse.test.ts, oauth2-mcp-client.test.ts, add-mcp-server.test.ts), making the e2e suite unnecessary overhead.

Test plan

  • npm run test -w agents passes — all 4 projects (workers, react, cli, x402) run in parallel
  • npm run test -w @cloudflare/ai-chat passes — both projects (workers, react) run in parallel
  • Individual project filters work (e.g. npm run test:x402 -w agents)
  • npm run check passes (typecheck, lint, format, exports)

Upgrade x402 MCP integration to x402 v2: replace legacy `x402` usage with `@x402/core`, `@x402/evm` and related v2 packages. Update agents implementation, examples (examples/x402, examples/x402-mcp) and package dependencies to use CAIP-2 network identifiers, viem signers, and new v2 APIs; adjust imports and middleware accordingly. Add migration changelog (.changeset) and new Vitest tests for x402 integration; update package.json files to include v2 deps and viem where needed.
Consolidate Vitest project configuration and simplify test scripts. Added top-level vitest.config.ts to packages/agents and packages/ai-chat to declare test projects, and set per-project names in existing vitest configs (react, cli, workers, x402). Updated package.json test scripts to use `vitest --run` and `--project <name>` instead of chaining runs. Removed the agents e2e test suite and related remote-mcp and utils files (deleted src/e2e/*), cleaning up flaky/legacy end-to-end tests.
@changeset-bot
Copy link

changeset-bot bot commented Feb 9, 2026

🦋 Changeset detected

Latest commit: 4341d8b

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

This PR includes changesets to release 1 package
Name Type
agents 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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 9, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@871

commit: 4341d8b

Add TestWorkflowAgent.expectThrow to safely call methods expected to throw and capture their error messages (avoids unhandled RPC rejections in workerd). Update workflow tests to replace expect(...).rejects.toThrow(...) with expectThrow checks and assert threw/message for various error cases (duplicate tracking insert, binding migration, terminate/pause/resume/restart errors, pagination cursor validation, sendApprovalEvent). Changes in packages/agents/src/tests/agents/workflow.ts and packages/agents/src/tests/workflow.test.ts.
@threepointone threepointone merged commit 27f8f75 into main Feb 9, 2026
10 of 11 checks passed
@threepointone threepointone deleted the fix-x402 branch February 9, 2026 02:09
@github-actions github-actions bot mentioned this pull request Feb 9, 2026
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.

1 participant