Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix: add @x402/*, @coinbase/*, gltf-validator to esbuild externals + fix siwx-server init

Claude (dry-run)8aa173939a21
diff --git a/api/_lib/siwx-server.js b/api/_lib/siwx-server.js
index dc5e483de..f0c4dbdf8 100644
--- a/api/_lib/siwx-server.js
+++ b/api/_lib/siwx-server.js
@@ -22,13 +22,14 @@ import {
SIGN_IN_WITH_X,
} from '@x402/extensions/sign-in-with-x';
-const siwxResourceServerExtension = createSIWxResourceServerExtension();
import { createPublicClient, http } from 'viem';
import { base } from 'viem/chains';
import { env } from './env.js';
import { siwxStorage, normalizeAddress } from './siwx-storage.js';
+const siwxResourceServerExtension = createSIWxResourceServerExtension({ storage: siwxStorage });
+
export { SIGN_IN_WITH_X };
// Lazily build a viem PublicClient so verifySIWxSignature can verify
diff --git a/scripts/bundle-api.mjs b/scripts/bundle-api.mjs
index 0de9e303b..e2f87de93 100644
--- a/scripts/bundle-api.mjs
+++ b/scripts/bundle-api.mjs
@@ -82,6 +82,19 @@ const EXTERNALS = [
'@neynar/*',
'@upstash/*',
'@sparticuz/*',
+ // @x402/extensions v2.13.0 maps both `import` and `require` conditions to
+ // its CJS build (./dist/cjs/index.js). When esbuild bundles that CJS into
+ // an ESM output it wraps require() calls with a __require shim, but
+ // require('url') (a Node.js built-in) throws "Dynamic require of 'url' is
+ // not supported" at runtime — crashing every function that imports x402-spec.js.
+ // Marking @x402/* and @coinbase/* as external lets Node.js ESM loader
+ // handle the CJS→ESM boundary natively (ESM can always import CJS).
+ '@x402/*',
+ '@coinbase/*',
+ // gltf-validator ships only a CJS build (gltf_validator.dart.js) that uses
+ // require('url') — same ESM-bundling incompatibility as @x402/extensions.
+ // Marking it external lets Node.js load it natively as CJS.
+ 'gltf-validator',
'jsdom',
'ethers',
'elevenlabs',