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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(avatar-studio): land the studio and dev-server follow-ups from this worktree
nirholas62be52d5db4a
diff --git a/public/locales/en.json b/public/locales/en.jsonindex 22ca23409..9e2bb00df 100644--- a/public/locales/en.json+++ b/public/locales/en.json@@ -2393,6 +2393,7 @@},"characters": {"characters": "Characters",+ "create": "Create a character","load_more": "Load more","meta_description": "Discover AI characters on three.ws. Chat, trade, and create.","meta_og_description": "Discover AI characters. Chat, trade, create.",@@ -2401,6 +2402,10 @@"meta_twitter_description": "Discover AI characters on three.ws. Chat, trade, and create.","meta_twitter_title": "Characters · three.ws","new": "New",+ "search_label": "Search characters by name or description",+ "search_placeholder": "Search characters…",+ "sort_label": "Sort characters",+ "subtitle": "Discover AI characters on three.ws. Chat, trade, and create.","top": "Top"},"city": {diff --git a/src/avatar-studio.js b/src/avatar-studio.jsindex 19836c136..47fc7d6c2 100644--- a/src/avatar-studio.js+++ b/src/avatar-studio.js@@ -136,6 +136,41 @@ function queueOp(fn) {return next;}+/**+ * queueOp() swallows failures so one bad op cannot stall the chain, which left+ * callers unable to tell success from silence. This keeps the chain intact and+ * still hands the caller the outcome so it can show a real error.+ */+async function runQueued(fn) {+ let captured = null;+ await queueOp(async () => {+ try {+ await fn();+ } catch (err) {+ captured = err;+ }+ });+ return { ok: !captured, error: captured };+}++// ── Busy state ───────────────────────────────────────────────────────+// Accessory work is a network round trip plus a rig pass. Nested/overlapping+// ops are counted so the last one out is the one that clears the indicator.+let busyDepth = 0;++function beginBusy(label) {+ busyDepth++;+ $('as-panel')?.setAttribute('aria-busy', 'true');+ setStatus('spin', label);+ let released = false;+ return () => {+ if (released) return;+ released = true;+ busyDepth = Math.max(0, busyDepth - 1);+ if (busyDepth === 0) $('as-panel')?.removeAttribute('aria-busy');+ };+}+const TABS = [{ id: 'color', label: 'Color', kinds: [], emoji: '🎨', color: true },{ id: 'hat', label: 'Hats', kinds: ['hat'], emoji: '🎩', single: true },@@ -409,11 +444,29 @@ function redoAppearance() {applyHistoryState(history[historyIndex]);}+// Every history step is stamped, so a step superseded while its accessories were+// still loading neither hydrates the rig from the newer step's appearance nor+// repaints the UI over it. Previously the queued thunk read the shared+// `workingAppearance` at execution time, so two quick undo/redo presses could+// leave the rig and the panel showing different states.+let historyToken = 0;+async function applyHistoryState(state) {- workingAppearance = cloneAppearance(state);+ const token = ++historyToken;+ const target = cloneAppearance(state);+ workingAppearance = target;+ // The index moved synchronously, so the buttons must too: gating them behind+ // the accessory fetch left Undo looking dead right after it was pressed.+ updateUndoRedoBtns();+ // Undo/redo also pay the accessory fetch, so they get the same busy feedback+ // a tile click does rather than appearing to do nothing for seconds.+ const done = beginBusy('Applying…');if (accessoryManager) {- await queueOp(() => accessoryManager.hydrateFromAppearance(workingAppearance));+ await runQueued(() => accessoryManager.hydrateFromAppearance(target));}+ done();+ if (token !== historyToken) return;+if (scene?.root) {applyAllColors();applyAllLayers();@@ -425,6 +478,7 @@ async function applyHistoryState(state) {updateUndoRedoBtns();updateDirtyState();scheduleDraftSave();+ setStatusDefault();}function updateUndoRedoBtns() {@@ -1404,14 +1458,26 @@ async function onTileClick(tab, presetId) {previewedId = null;previewToken++;- await queueOp(async () => {- await applyAccessory(tab, presetId || null);- });+ const preset = presetId ? presetsById.get(presetId) : null;+ const label = preset ? preset.name : `${tab.label.toLowerCase()}`;+ // Fetching and rigging an accessory GLB takes seconds on a slow link. Without+ // this the tile click looked like it did nothing at all until the model+ // popped in, and a failed fetch was completely silent.+ const done = beginBusy(presetId ? `Putting on ${label}…` : `Removing ${label}…`);+ const { ok, error } = await runQueued(() => applyAccessory(tab, presetId || null));+ done();+pushHistory();renderActivePanel();renderChips();updateDirtyState();scheduleDraftSave();++ if (!ok) {+ setStatus('err', `Couldn’t load ${label}: ${error?.message || 'Unknown error'}. Tap it again to retry.`);+ return;+ }+ setStatus('ok', presetId ? `${label} on.` : `${label} removed.`);}async function removeCommitted(id) {@@ -1419,15 +1485,18 @@ async function removeCommitted(id) {if (!preset) return;previewedId = null;previewToken++;- await queueOp(async () => {+ const done = beginBusy(`Removing ${preset.name}…`);+ await runQueued(async () => {accessoryManager?.removePreset(id);});+ done();workingAppearance.accessories = workingAppearance.accessories.filter((a) => a !== id);pushHistory();renderActivePanel();renderChips();updateDirtyState();scheduleDraftSave();+ setStatus('ok', `${preset.name} removed.`);}async function applyAccessory(tab, presetId) {diff --git a/vite.config.js b/vite.config.jsindex ab43a353a..5fe52022d 100644--- a/vite.config.js+++ b/vite.config.js@@ -497,8 +497,8 @@ const appConfig = {chunk.name === 'feature-tour' ||chunk.name === 'notifications' ||chunk.name === 'nav-tier-badge' ||- chunk.name === 'agent-bus'- || chunk.name === 'i18n'+ chunk.name === 'agent-bus' ||+ chunk.name === 'i18n'? `${chunk.name}.js`: 'assets/[name]-[hash].js',},@@ -617,7 +617,7 @@ const appConfig = {'agent-detail': resolve(__dirname, 'pages/agent-detail.html'),'agent-detail-classic': resolve(__dirname, 'pages/agent-detail-classic.html'),'agent-screen': resolve(__dirname, 'pages/agent-screen.html'),- 'agents-live': resolve(__dirname, 'pages/agents-live.html'),+ 'agents-live': resolve(__dirname, 'pages/agents-live.html'),monitor: resolve(__dirname, 'pages/monitor.html'),'agent-wallet': resolve(__dirname, 'pages/agent-wallet.html'),wallet: resolve(__dirname, 'pages/wallet.html'),@@ -751,7 +751,10 @@ const appConfig = {profile: resolve(__dirname, 'pages/profile.html'),feed: resolve(__dirname, 'pages/feed.html'),'threews-claim': resolve(__dirname, 'pages/threews-claim.html'),- 'events-build-3d-agents-live': resolve(__dirname, 'pages/events/build-3d-agents-live.html'),+ 'events-build-3d-agents-live': resolve(+ __dirname,+ 'pages/events/build-3d-agents-live.html',+ ),'avatar-page': resolve(__dirname, 'pages/avatar-page.html'),'avatar-sdk': resolve(__dirname, 'pages/avatar-sdk.html'),'avatar-cli': resolve(__dirname, 'pages/avatar-cli.html'),@@ -929,7 +932,7 @@ const appConfig = {press: resolve(__dirname, 'pages/press/index.html'),'agent-trade': resolve(__dirname, 'pages/agent-trade.html'),'autopilot-activity': resolve(__dirname, 'pages/autopilot-activity.html'),-support: resolve(__dirname, 'pages/support.html'),+ support: resolve(__dirname, 'pages/support.html'),// dashboard-next prototype — sub-pages auto-discovered so the parallel// agents that land new pages/dashboard-next/*.html files don't have to// touch this config to register them as Rollup inputs.@@ -1107,7 +1110,9 @@ support: resolve(__dirname, 'pages/support.html'),return /^\/agent-3d\/[^/]+\/agent-3d\.(js|umd\.cjs)$/.test(id) ? id : null;},load(id) {- return /^\/agent-3d\/[^/]+\/agent-3d\.(js|umd\.cjs)$/.test(id) ? 'export {};' : null;+ return /^\/agent-3d\/[^/]+\/agent-3d\.(js|umd\.cjs)$/.test(id)+ ? 'export {};'+ : null;},transformIndexHtml: {order: 'pre',@@ -1450,8 +1455,8 @@ support: resolve(__dirname, 'pages/support.html'),'/pump-visualizer': resolve(root, 'pages/pump-visualizer.html'),'/pump-visualizer/': resolve(root, 'pages/pump-visualizer.html'),'/three': resolve(root, 'pages/three.html'),- '/three/': resolve(root, 'pages/three.html'),- '/three-live': resolve(root, 'pages/three-live.html'),+ '/three/': resolve(root, 'pages/three.html'),+ '/three-live': resolve(root, 'pages/three-live.html'),'/three-live/': resolve(root, 'pages/three-live.html'),'/three-token': resolve(root, 'pages/three-token.html'),'/three-token/': resolve(root, 'pages/three-token.html'),@@ -1540,7 +1545,7 @@ support: resolve(__dirname, 'pages/support.html'),'/nvidia/': resolve(root, 'pages/nvidia/index.html'),'/press': resolve(root, 'pages/press/index.html'),'/press/': resolve(root, 'pages/press/index.html'),-'/support': resolve(root, 'pages/support.html'),+ '/support': resolve(root, 'pages/support.html'),'/support/': resolve(root, 'pages/support.html'),// Top-level galaxy/constellation are routed in vercel.json (prod) and// linked from the global nav — mirror them here so local dev matches prod@@ -1743,7 +1748,10 @@ support: resolve(__dirname, 'pages/support.html'),}// C4: the standalone /avatar-edit landing is retired — the editor is// only reachable in-flow at /avatars/:id/edit (or the legacy ?id= form).- if ((path === '/avatar-edit' || path === '/avatar-edit/') && !/[?&]id=/.test(url)) {+ if (+ (path === '/avatar-edit' || path === '/avatar-edit/') &&+ !/[?&]id=/.test(url)+ ) {res.statusCode = 301;res.setHeader('Location', '/dashboard/avatars');return res.end();@@ -1960,28 +1968,30 @@ support: resolve(__dirname, 'pages/support.html'),)filePath = resolve(root, 'pages/communities.html');// /launches/:mint → rich coin detail page- else if (- !filePath &&- /^\/launches\/[1-9A-HJ-NP-Za-km-z]{32,44}\/?$/.test(path)- )+ else if (!filePath && /^\/launches\/[1-9A-HJ-NP-Za-km-z]{32,44}\/?$/.test(path))filePath = resolve(root, 'pages/launch-detail.html');// /coin/:id → global coin detail page (CoinGecko slug or Solana mint)- else if (- !filePath &&- /^\/coin\/[a-zA-Z0-9][a-zA-Z0-9_-]{0,99}\/?$/.test(path)- )+ else if (!filePath && /^\/coin\/[a-zA-Z0-9][a-zA-Z0-9_-]{0,99}\/?$/.test(path))filePath = resolve(root, 'pages/coin.html');// /m/:id → model detail page (forge_creations uuid)else if (!filePath &&- /^\/m\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\/?$/.test(path)+ /^\/m\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\/?$/.test(+ path,+ ))filePath = resolve(root, 'pages/model.html');// /markets/robinhood/stock/:symbol → Robinhood Chain Stock Token detail- else if (!filePath && /^\/markets\/robinhood\/stock\/[A-Za-z0-9.-]{1,10}\/?$/.test(path))+ else if (+ !filePath &&+ /^\/markets\/robinhood\/stock\/[A-Za-z0-9.-]{1,10}\/?$/.test(path)+ )filePath = resolve(root, 'pages/robinhood-stock.html');// /markets/robinhood/coin/:address → Robinhood Chain coin detail- else if (!filePath && /^\/markets\/robinhood\/coin\/0x[0-9a-fA-F]{40}\/?$/.test(path))+ else if (+ !filePath &&+ /^\/markets\/robinhood\/coin\/0x[0-9a-fA-F]{40}\/?$/.test(path)+ )filePath = resolve(root, 'pages/robinhood-coin.html');// /drop/:id → sealed wallet gift claim page (24 lowercase hex chars,// matching api/vanity/drops.js's id format)@@ -2008,11 +2018,11 @@ support: resolve(__dirname, 'pages/support.html'),// /@<handle> → public live profile pageelse if (!filePath && /^\/@[a-z0-9_-]{3,30}\/?$/i.test(path))filePath = resolve(root, 'pages/handle.html');- else if (- !filePath &&- /^\/u\/(?:0x[0-9a-fA-F]{40}|[a-z0-9_-]{3,30})\/?$/i.test(path)- )- filePath = resolve(root, 'pages/profile.html');+ else if (+ !filePath &&+ /^\/u\/(?:0x[0-9a-fA-F]{40}|[a-z0-9_-]{3,30})\/?$/i.test(path)+ )+ filePath = resolve(root, 'pages/profile.html');// /a/<chainId>/<agentId> or /a/<chainId>/<registry>/<agentId>else if (!filePath && /^\/a\/[^/]+(?:\/[^/]+){1,2}\/?$/.test(path))filePath = resolve(root, 'pages/app.html');@@ -2128,8 +2138,8 @@ support: resolve(__dirname, 'pages/support.html'),]) {const candidate = resolve(root, rel);if (existsSync(candidate)) {- filePath = candidate;- break;+ filePath = candidate;+ break;}}}@@ -2312,7 +2322,11 @@ support: resolve(__dirname, 'pages/support.html'),"window.__threeErrQ=window.__threeErrQ||[];window.__threeErrCap=1;addEventListener('error',function(e){window.__threeErrQ.push(e)},!0);addEventListener('unhandledrejection',function(e){window.__threeErrQ.push(e)});";return [{ tag: 'script', children: BOOTSTRAP, injectTo: 'head' },- { tag: 'script', attrs: { defer: true, src: '/error-reporter.js' }, injectTo: 'head' },+ {+ tag: 'script',+ attrs: { defer: true, src: '/error-reporter.js' },+ injectTo: 'head',+ },];},},@@ -2346,7 +2360,13 @@ support: resolve(__dirname, 'pages/support.html'),.split('/').pop();if (EXCLUDED.has(filename)) return [];- return [{ tag: 'script', attrs: { type: 'module', src: '/atlas.js' }, injectTo: 'body' }];+ return [+ {+ tag: 'script',+ attrs: { type: 'module', src: '/atlas.js' },+ injectTo: 'body',+ },+ ];},},},@@ -2368,7 +2388,13 @@ support: resolve(__dirname, 'pages/support.html'),.split('/').pop();if (FRAGMENTS.has(filename)) return [];- return [{ tag: 'script', attrs: { src: '/inline-behaviors.js', defer: true }, injectTo: 'head' }];+ return [+ {+ tag: 'script',+ attrs: { src: '/inline-behaviors.js', defer: true },+ injectTo: 'head',+ },+ ];},},},@@ -2715,9 +2741,16 @@ support: resolve(__dirname, 'pages/support.html'),if (!rel) return next();const file = resolve(dir, rel);// Path-traversal guard: never serve outside pages/ibm/.- if (!file.startsWith(dir + '/') || !existsSync(file) || !statSync(file).isFile())+ if (+ !file.startsWith(dir + '/') ||+ !existsSync(file) ||+ !statSync(file).isFile()+ )return next();- res.setHeader('Content-Type', MIME[extname(file)] || 'application/octet-stream');+ res.setHeader(+ 'Content-Type',+ MIME[extname(file)] || 'application/octet-stream',+ );createReadStream(file).pipe(res);});},@@ -2827,7 +2860,13 @@ support: resolve(__dirname, 'pages/support.html'),// fallback robot in dev. Only text payloads can carry an r2.dev URL,// so rewrite those and pass anything else through byte-for-byte.if (!/^(application\/(json|.*\+json)|text\/)/i.test(type)) {- for (const h of ['content-length', 'accept-ranges', 'content-range', 'etag', 'cache-control']) {+ for (const h of [+ 'content-length',+ 'accept-ranges',+ 'content-range',+ 'etag',+ 'cache-control',+ ]) {const v = resp.headers.get(h);if (v) res.setHeader(h, v);}@@ -2958,7 +2997,10 @@ support: resolve(__dirname, 'pages/support.html'),['dist/public/character.html', 'dist/character.html'],['dist/public/agents/index.html', 'dist/agents/index.html'],['dist/public/validation/index.html', 'dist/validation/index.html'],- ['dist/public/reputation/market/index.html', 'dist/reputation/market/index.html'],+ [+ 'dist/public/reputation/market/index.html',+ 'dist/reputation/market/index.html',+ ],['dist/public/gallery/index.html', 'dist/gallery/index.html'],['dist/public/demos/brain.html', 'dist/demos/brain.html'],['dist/public/demos/lipsync-tts.html', 'dist/demos/lipsync-tts.html'],@@ -3185,8 +3227,7 @@ support: resolve(__dirname, 'pages/support.html'),urlPattern: ({ url, request, sameOrigin }) =>sameOrigin &&url.pathname.startsWith('/assets/') &&- (request.destination === 'script' ||- request.destination === 'style'),+ (request.destination === 'script' || request.destination === 'style'),handler: 'StaleWhileRevalidate',options: {cacheName: 'app-assets',@@ -3214,8 +3255,7 @@ support: resolve(__dirname, 'pages/support.html'),{urlPattern: ({ request, sameOrigin }) =>sameOrigin &&- (request.destination === 'script' ||- request.destination === 'style'),+ (request.destination === 'script' || request.destination === 'style'),handler: 'NetworkFirst',options: {cacheName: 'app-shell-assets',