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(dev): let Vite transform avatar-sdk source so the viewer element registers

nirholas64005e0e8cf5
diff --git a/vite.config.js b/vite.config.js
index a0d660c38..9d6c6f7d1 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -2825,6 +2825,16 @@ support: resolve(__dirname, 'pages/support.html'),
const rel = req.url.replace(/\?.*$/, '').slice('/avatar-sdk/'.length);
const file = resolve(__dirname, 'avatar-sdk', rel);
if (!existsSync(file) || statSync(file).isDirectory()) return next();
+ // avatar-sdk/src/* is package SOURCE: it imports bare specifiers
+ // ('three', 'three/addons/*') that only a bundler can resolve. The
+ // production build inlines those through Rollup, but streaming the
+ // raw bytes in dev handed the browser an unresolvable specifier, so
+ // <three-ws-viewer> never registered and every viewer on
+ // /avatar-sdk rendered an empty box. Hand these to Vite's own
+ // transform pipeline (which this middleware would otherwise shadow)
+ // so dev resolves them the same way the deployed bundle does.
+ // avatar-sdk/dist/* is already bundled and stays on the fast path.
+ if (rel.startsWith('src/') && /\.m?js$/.test(rel)) return next();
const mime = MIME[extname(file)] ?? 'application/octet-stream';
res.setHeader('Content-Type', mime);
createReadStream(file).pipe(res);