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
chore: nav + home polish, demo-economy / forge / x402-pay refinements
nirholasd6c08f74eb41
diff --git a/api/demo-economy.js b/api/demo-economy.jsindex 340520ac7..22ee178cf 100644--- a/api/demo-economy.js+++ b/api/demo-economy.js@@ -10,7 +10,7 @@// a recipient are configured; simulation mode otherwise (no real money,// full UI still plays).-import { cors, method, wrap } from './_lib/http.js';+import { cors, method, wrap, setRateLimitHeaders } from './_lib/http.js';import { limits, clientIp } from './_lib/rate-limit.js';import { Bazaar } from './_lib/x402/bazaar-client.js';@@ -100,6 +100,8 @@ export default wrap(async (req, res) => {const rl = await limits.publicIp(clientIp(req));if (!rl.success) {+ const retryAfter = Math.max(1, setRateLimitHeaders(res, rl));+ res.setHeader('retry-after', String(retryAfter));res.statusCode = 429;res.end('rate limited');return;diff --git a/api/forge.js b/api/forge.jsindex 89be874e8..f9cbf282e 100644--- a/api/forge.js+++ b/api/forge.js@@ -383,10 +383,12 @@ async function startJob(req, res) {// Upstream throttling is a transient 429, not a server fault — return it as// such with a retry hint so the page can show a "busy, try again" state.if (err?.code === 'rate_limited' || err?.providerStatus === 429) {+ const retryAfter = typeof err?.retryAfter === 'number' ? err.retryAfter : 10;+ res.setHeader('retry-after', String(retryAfter));return json(res, 429, {error: 'rate_limited',message: 'The 3D generator is busy right now. Try again in a few seconds.',- retry_after: typeof err?.retryAfter === 'number' ? err.retryAfter : 10,+ retry_after: retryAfter,});}return json(res, 502, {@@ -457,6 +459,7 @@ async function startRigJob(req, res) {return json(res, 501, { error: 'rig_unconfigured', message: err.message });}if (err?.code === 'rate_limited' || err?.providerStatus === 429) {+ res.setHeader('retry-after', '10');return json(res, 429, {error: 'rate_limited',message: 'The rigger is busy right now. Try again in a few seconds.',diff --git a/api/x402-pay.js b/api/x402-pay.jsindex 8acf16fa9..21cf21591 100644--- a/api/x402-pay.js+++ b/api/x402-pay.js@@ -32,7 +32,7 @@ import {import bs58 from 'bs58';import { Redis } from '@upstash/redis';-import { cors, json, readJson, wrap, rateLimited } from './_lib/http.js';+import { cors, json, readJson, wrap, rateLimited, setRateLimitHeaders } from './_lib/http.js';import { limits, clientIp } from './_lib/rate-limit.js';import {paymentRequirements,@@ -575,10 +575,12 @@ export default wrap(async (req, res) => {}const globalRl = await limits.x402PayGlobal();if (!globalRl.success) {- return json(res, 429, {- error: 'rate_limited_global',- retry_after: Math.ceil((globalRl.reset - Date.now()) / 1000),- });+ // Distinct code from the per-IP limit so the demo UI can tell a global+ // budget exhaustion apart from a single caller's burst. Headers are the+ // same standard shape as rateLimited().+ const retryAfter = Math.max(1, setRateLimitHeaders(res, globalRl));+ res.setHeader('retry-after', String(retryAfter));+ return json(res, 429, { error: 'rate_limited_global', retry_after: retryAfter });}const input = await readJson(req, 50_000);diff --git a/pages/home.html b/pages/home.htmlindex b997b73cf..ba955269f 100644--- a/pages/home.html+++ b/pages/home.html@@ -280,7 +280,13 @@}/* ── Hero stage ──────────────────────────────────────────── */- .hero-stage { position: relative; overflow: hidden; background: var(--bg); container-type: inline-size; }+ .hero-stage {+ position: relative; overflow: hidden; container-type: inline-size;+ background:+ radial-gradient(118% 78% at 50% 20%, rgba(255,255,255,0.075) 0%, rgba(255,255,255,0.022) 36%, transparent 60%),+ radial-gradient(72% 48% at 50% 104%, rgba(0,0,0,0.6) 0%, transparent 72%),+ var(--bg);+ }.hero-stage agent-3d {position: absolute; inset: 0; display: block; width: 100%; height: 100%;}diff --git a/public/nav.js b/public/nav.jsindex 49e46786d..84b55270d 100644--- a/public/nav.js+++ b/public/nav.js@@ -114,7 +114,9 @@ function initDropdowns(root) {if (t) t.setAttribute('aria-expanded', on ? 'true' : 'false');}function closeAll(except) {- groups.forEach((g) => { if (g !== except) setOpen(g, false); });+ groups.forEach((g) => {+ if (g !== except) setOpen(g, false);+ });}groups.forEach((grp) => {@@ -157,7 +159,9 @@ function initDropdowns(root) {(items[(idx + 1) % items.length] || items[0])?.focus({ preventScroll: true });} else if (e.key === 'ArrowUp') {e.preventDefault();- (items[(idx - 1 + items.length) % items.length] || items[0])?.focus({ preventScroll: true });+ (items[(idx - 1 + items.length) % items.length] || items[0])?.focus({+ preventScroll: true,+ });} else if (e.key === 'Escape') {setOpen(grp, false);trigger.focus({ preventScroll: true });@@ -203,7 +207,10 @@ function initDrawer(root) {if (e.target.closest('a')) setOpen(false);});document.addEventListener('keydown', (e) => {- if (e.key === 'Escape' && isOpen()) { setOpen(false); toggle.focus(); }+ if (e.key === 'Escape' && isOpen()) {+ setOpen(false);+ toggle.focus();+ }});window.addEventListener('resize', () => {if (window.innerWidth > 880 && isOpen()) setOpen(false);@@ -272,7 +279,11 @@ function initAuthHint(root) {// 2. Reconcile against the real session. /api/auth/me returns { user } when// signed in and { user: null } (or 401 for a stale cookie) otherwise.- fetch('/api/auth/me', { credentials: 'include' })+ // A hung endpoint must not wedge the nav, so the request self-aborts after+ // 6s and falls through to the optimistic paint left by the hint.+ const ctrl = typeof AbortController !== 'undefined' ? new AbortController() : null;+ const timer = ctrl ? setTimeout(() => ctrl.abort(), 6000) : null;+ fetch('/api/auth/me', { credentials: 'include', signal: ctrl?.signal }).then((r) => (r.ok ? r.json() : null)).then((data) => {const user = data && data.user;@@ -287,8 +298,11 @@ function initAuthHint(root) {}}).catch(() => {- // Network/transient failure: leave the optimistic hint paint untouched- // rather than flashing the visitor back to a signed-out nav.+ // Network/transient failure or timeout: leave the optimistic hint paint+ // untouched rather than flashing the visitor back to a signed-out nav.+ })+ .finally(() => {+ if (timer) clearTimeout(timer);});}@@ -330,7 +344,9 @@ function initWalkToggle(root) {// An explicit ?walk= override decides the initial state; otherwise restore.if (override === '1' || override === '0') {- try { localStorage.setItem(WALK_ENABLED_KEY, override); } catch (_) {}+ try {+ localStorage.setItem(WALK_ENABLED_KEY, override);+ } catch (_) {}}sync();@@ -344,7 +360,9 @@ function initWalkToggle(root) {if (window.__walkCompanion) {window.__walkCompanion.toggle();} else {- try { localStorage.setItem(WALK_ENABLED_KEY, '1'); } catch (_) {}+ try {+ localStorage.setItem(WALK_ENABLED_KEY, '1');+ } catch (_) {}ensureWalkCompanion();}sync();