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
feat: marketplace updates, IBM twin, privy-login improvements
nirholas544c71c18b0d
diff --git a/api/marketplace.js b/api/marketplace.jsindex 9fe2b4d16..1bbd9706a 100644--- a/api/marketplace.js+++ b/api/marketplace.js@@ -1,3 +1,11 @@+// GET /api/marketplace — canonical alias for /api/marketplace/agents.+// Callers that omit the sub-path get the agents list directly, no round-trip.+import handler from './marketplace/[action].js';+export default (req, res) => {- res.redirect(301, '/api/marketplace/agents');-};\ No newline at end of file+ const url = new URL(req.url, 'http://x');+ // Rewrite the path so the downstream handler sees /api/marketplace/agents.+ url.pathname = '/api/marketplace/agents';+ req.url = url.pathname + (url.search || '');+ return handler(req, res);+};diff --git a/src/ibm-twin.js b/src/ibm-twin.jsindex 19e7bbdf3..81756feb4 100644--- a/src/ibm-twin.js+++ b/src/ibm-twin.js@@ -590,6 +590,7 @@ let inFlight = false;async function spawn(target, { silent = false } = {}) {if (inFlight) return;inFlight = true;+ const prevTarget = activeTarget;activeTarget = target;clearScenario();hud.sim.out.classList.remove('show');@@ -601,9 +602,19 @@ async function spawn(target, { silent = false } = {}) {: `token=${encodeURIComponent(target.token)}`;const r = await fetch(`/api/ibm/twin?${q}`);const data = await r.json();- if (!r.ok) throw new Error(data.error_description || data.error || `HTTP ${r.status}`);+ if (!r.ok) {+ // Permanent failures: don't leave the failing pool as activeTarget so the+ // live-sync timer doesn't keep hammering the same broken endpoint.+ if (r.status === 422 && data.error === 'insufficient_history') {+ activeTarget = prevTarget;+ setStatus('Not enough trading history to model this pool — try a more active market.');+ return;+ }+ throw new Error(data.error_description || data.error || `HTTP ${r.status}`);+ }applySnapshot(data, { silent });} catch (e) {+ activeTarget = prevTarget;setStatus(`Twin failed: ${e.message}`, false, () => spawn(target));} finally {inFlight = false;diff --git a/src/privy-login.js b/src/privy-login.jsindex 040fcf1d2..4747332d8 100644--- a/src/privy-login.js+++ b/src/privy-login.js@@ -250,26 +250,53 @@ function mountPrivyUI(privy) {const address = resp.publicKey.toString();setWalletStatus('Generating sign-in message…');- const { nonce } = await privy.auth.siws.fetchNonce({ address });- const message = createSiwsMessage({+ const nonceRes = await fetch('/api/auth/siws/nonce', { credentials: 'include' });+ if (!nonceRes.ok) throw new Error('Failed to get nonce');+ const { nonce, csrf, domain: serverDomain, uri: serverUri } = await nonceRes.json();++ const domain = serverDomain || location.host;+ const uri = serverUri || location.origin;+ const issuedAt = new Date().toISOString();+ const expirationTime = new Date(Date.now() + 5 * 60 * 1000).toISOString();+ const message = [+ `${domain} wants you to sign in with your Solana account:`,address,- nonce,- domain: location.hostname,- uri: location.origin,- });+ '',+ 'Sign in to three.ws. This request will not trigger any blockchain transaction or cost any fees.',+ '',+ `URI: ${uri}`,+ 'Version: 1',+ 'Chain ID: mainnet',+ `Nonce: ${nonce}`,+ `Issued At: ${issuedAt}`,+ `Expiration Time: ${expirationTime}`,+ ].join('\n');setWalletStatus('Sign the message in your wallet…');const { signature: sigBytes } = await provider.signMessage(new TextEncoder().encode(message),'utf8',);- const signature = bs58.encode(sigBytes);+ const signature = btoa(String.fromCharCode(...sigBytes));setWalletStatus('Signing in…');- const { identity_token } = await privy.auth.siws.login({ message, signature });- if (!identity_token) throw new Error('No identity token returned.');+ const verifyRes = await fetch('/api/auth/siws/verify', {+ method: 'POST',+ credentials: 'include',+ headers: { 'content-type': 'application/json', 'x-csrf-token': csrf },+ body: JSON.stringify({ message, signature }),+ });+ const data = await verifyRes.json().catch(() => ({}));+ if (!verifyRes.ok) throw new Error(data.error_description || 'Sign-in failed.');- await verifyWithBackend(identity_token);+ try {+ localStorage.setItem(+ '3dagent:auth-hint',+ JSON.stringify({ authed: true, name: data.user?.display_name || '', ts: Date.now() }),+ );+ } catch { /* ignore */ }++ location.href = next;} catch (e) {const raw = e?.message || '';showErr(/reject|denied|cancel|refused/i.test(raw) ? 'Signature cancelled.' : raw || 'Wallet sign-in failed.');