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: live pump.fun token card + real "Launch yours" flow on the homepage
nirholas4c36d4507b7f
diff --git a/.gitignore b/.gitignoreindex d52f8e522..6785a971f 100644--- a/.gitignore+++ b/.gitignore@@ -78,6 +78,8 @@ scripts/pump-usdc-race.mjs.fresh-pump-wallet.json.coin-keypair-*.json.coin-metadata-*.json+.x402-test-wallet.json+scripts/x402-test-endpoints.mjswallets/.wallets/x402-test-wallets/diff --git a/api/openapi-json.js b/api/openapi-json.jsindex 9e3b35fb8..ed7801208 100644--- a/api/openapi-json.js+++ b/api/openapi-json.js@@ -31,12 +31,14 @@ export default wrap(async (req, res) => {servers: [{ url: origin }],components: {securitySchemes: {- siwx: {- type: 'apiKey',- in: 'header',- name: 'Authorization',+ bearerAuth: {+ type: 'http',+ scheme: 'bearer',description:- 'Bearer token from OAuth 2.1 or API key. Wallet-based SIWX authentication is supported via SIWE.',+ 'Bearer token in the Authorization header. Obtain one via OAuth 2.1 at ' ++ origin ++ '/oauth/authorize, use an API key from the dashboard, or exchange a ' ++ 'wallet SIWX (CAIP-122) session for an access token.',},},},@@ -47,6 +49,7 @@ export default wrap(async (req, res) => {summary: 'MCP tool call',description:'JSON-RPC 2.0 request to the MCP server. Supports tools for 3D avatar management, model validation, inspection, and optimization.',+ security: [{ bearerAuth: [] }],requestBody: {required: true,content: {@@ -109,7 +112,7 @@ export default wrap(async (req, res) => {get: {operationId: 'list_avatars',summary: 'List my avatars',- security: [{ siwx: [] }],+ security: [{ bearerAuth: [] }],responses: {200: { description: 'Array of avatar objects' },401: { description: 'Unauthorized' },@@ -118,7 +121,7 @@ export default wrap(async (req, res) => {post: {operationId: 'create_avatar',summary: 'Register an uploaded avatar',- security: [{ siwx: [] }],+ security: [{ bearerAuth: [] }],requestBody: {required: true,content: {@@ -176,7 +179,7 @@ export default wrap(async (req, res) => {get: {operationId: 'list_agents',summary: 'List my agents',- security: [{ siwx: [] }],+ security: [{ bearerAuth: [] }],responses: {200: { description: 'Array of agent identity objects' },401: { description: 'Unauthorized' },@@ -386,7 +389,7 @@ export default wrap(async (req, res) => {name: 'mint',in: 'query',required: true,- schema: { type: 'string', minLength: 32, maxLength: 64 },+ schema: { type: 'string', minLength: 32, maxLength: 44 },description: 'Base58 SPL mint address on Solana mainnet.',},],@@ -400,7 +403,7 @@ export default wrap(async (req, res) => {},'/api/insights/revenue-vision': {get: {- operationId: 'x402_revenue_vision',+ operationId: 'insights_revenue_vision',summary: 'Paid: Claude-powered next-best-move for a mission brief',description:'Pay $0.001 USDC to receive a single prioritized next-best move, a data-grounded insight, and an honestly-calibrated confidence rating for the supplied mission brief.',@@ -410,6 +413,8 @@ export default wrap(async (req, res) => {name: 'power_request',in: 'query',required: true,+ description:+ 'Analysis mode. Currently only "revenue-vision" is available; the parameter is required so additional modes can be added without a breaking change.',schema: { type: 'string', enum: ['revenue-vision'] },},{@@ -443,16 +448,19 @@ export default wrap(async (req, res) => {'/api/x402/dance-tip': {get: {operationId: 'x402_dance_tip',- summary: 'Paid: Tip a 3D dancer to perform on the pole stage',+ summary: 'Paid: Tip a 3D dancer to perform a routine on the club stage',description:- 'Pay $0.001 USDC to tip a dancer to perform one routine on the three.ws Pole Club 3D stage. Returns a performance ticket the /club page consumes to spawn the dancer.',+ 'Pay $0.001 USDC to tip a dancer to perform one routine on the three.ws 3D club stage. ' ++ 'Pick a stage slot (1–4) and a style: free-floor (rumba, silly, thriller, capoeira, hiphop) ' ++ 'or pole choreography (spin, climb, combo). Returns a performance ticket the /club page ' ++ 'consumes to spawn the dancer and play the routine.',parameters: [{name: 'dancer',in: 'query',required: true,schema: { type: 'string', enum: ['1', '2', '3', '4'] },- description: 'Stage slot 1-4.',+ description: 'Stage slot — which of the four dancers performs.',},{name: 'dance',@@ -460,9 +468,19 @@ export default wrap(async (req, res) => {required: true,schema: {type: 'string',- enum: ['rumba', 'silly', 'thriller', 'capoeira', 'hiphop'],+ enum: [+ 'rumba',+ 'silly',+ 'thriller',+ 'capoeira',+ 'hiphop',+ 'spin',+ 'climb',+ 'combo',+ ],},- description: 'Performance style — a clip in /animations/manifest.json.',+ description:+ 'Performance style. Free-floor styles (rumba, silly, thriller, capoeira, hiphop) play a single looped clip; pole-choreography styles (spin, climb, combo) chain a sequence of clips.',},],responses: {diff --git a/api/pump/[action].js b/api/pump/[action].jsindex e00183e0d..052b079cb 100644--- a/api/pump/[action].js+++ b/api/pump/[action].js@@ -2424,33 +2424,49 @@ async function handleChannelFeed(req, res) {// ── trending / search (proxies for the CORS-protected pump.fun frontend API) ──const PUMP_FRONTEND_BASE = 'https://frontend-api-v3.pump.fun';-const TRENDING_CACHE = { at: 0, body: null };+// Cache keyed by sort+order+limit so the market_cap view and the+// last_trade_timestamp view (used by the homepage live feed to find an+// actively-trading bonding-curve coin) don't clobber each other.+const TRENDING_CACHE = new Map();const TRENDING_TTL_MS = 15_000;+const TRENDING_SORTS = new Set([+ 'market_cap',+ 'last_trade_timestamp',+ 'created_timestamp',+ 'currently_live',+]);async function handleTrending(req, res) {if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;if (!method(req, res, ['GET'])) return;const rl = await limits.mcpIp(clientIp(req));if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');+ const url = new URL(req.url, `http://${req.headers.host}`);+ const limit = Math.min(Math.max(1, Number(url.searchParams.get('limit') || 50)), 100);+ const sortParam = String(url.searchParams.get('sort') || 'market_cap');+ const sort = TRENDING_SORTS.has(sortParam) ? sortParam : 'market_cap';+ const order = url.searchParams.get('order') === 'ASC' ? 'ASC' : 'DESC';+ const cacheKey = `${sort}:${order}:${limit}`;+const now = Date.now();- if (TRENDING_CACHE.body && now - TRENDING_CACHE.at < TRENDING_TTL_MS) {+ const cached = TRENDING_CACHE.get(cacheKey);+ if (cached && now - cached.at < TRENDING_TTL_MS) {res.setHeader('cache-control', 'public, max-age=15');- return json(res, 200, TRENDING_CACHE.body);+ return json(res, 200, cached.body);}- const url = new URL(req.url, `http://${req.headers.host}`);- const limit = Math.min(Math.max(1, Number(url.searchParams.get('limit') || 50)), 100);+const upstream = new URL('/coins', PUMP_FRONTEND_BASE);upstream.searchParams.set('offset', '0');upstream.searchParams.set('limit', String(limit));- upstream.searchParams.set('sort', 'market_cap');- upstream.searchParams.set('order', 'DESC');+ upstream.searchParams.set('sort', sort);+ upstream.searchParams.set('order', order);upstream.searchParams.set('includeNsfw', 'false');const resp = await fetch(upstream, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(8000) });if (!resp.ok) return error(res, 502, 'upstream_failed', `pump.fun returned ${resp.status}`);const body = await resp.json();const arr = Array.isArray(body) ? body : Array.isArray(body?.coins) ? body.coins : [];- TRENDING_CACHE.at = now;- TRENDING_CACHE.body = arr;+ TRENDING_CACHE.set(cacheKey, { at: now, body: arr });+ if (TRENDING_CACHE.size > 16) TRENDING_CACHE.delete(TRENDING_CACHE.keys().next().value);res.setHeader('cache-control', 'public, max-age=15');return json(res, 200, arr);}diff --git a/api/x402/dance-tip.js b/api/x402/dance-tip.jsindex b69a3dfbc..b0dea44f0 100644--- a/api/x402/dance-tip.js+++ b/api/x402/dance-tip.js@@ -1,9 +1,9 @@// GET /api/x402/dance-tip?dancer=<id>&dance=<style>//// Paid endpoint cataloged by the CDP x402 Bazaar. For $0.001 USDC the caller-// books one dance performance on the three.ws Pole Club stage. The /club page+// books one dance performance on the three.ws club stage. The /club page// uses this from the browser via window.X402.pay — when the payment settles,-// the named dancer steps onto the pole and performs the requested style for+// the named dancer steps onto the stage and performs the requested style for// a fixed duration. Agents can also call it programmatically with @x402/fetch// to drive scripted performances.//@@ -25,7 +25,7 @@ import { priceFor } from '../_lib/x402-prices.js';const ROUTE = '/api/x402/dance-tip';const DESCRIPTION =- 'three.ws Pole Club — tip a dancer to perform one routine on the 3D pole ' ++ 'three.ws club stage — tip a dancer to perform one routine on the 3D ' +'stage. Pay $0.001 USDC per performance. Pick a dancer slot (1-4) and a ' +'dance style (free-floor: rumba, silly, thriller, capoeira, hiphop; ' +'pole choreography: spin, climb, combo). The settled call returns a ' +@@ -91,7 +91,7 @@ const INPUT_SCHEMA = {dancer: {type: 'string',enum: ['1', '2', '3', '4'],- description: 'Stage slot 1-4 — which dancer should take the pole.',+ description: 'Stage slot 1-4 — which dancer takes the stage.',},dance: {type: 'string',@@ -263,7 +263,7 @@ export default paidEndpoint({description: DESCRIPTION,bazaar: BAZAAR,service: withService({- serviceName: 'three.ws Pole Club',+ serviceName: 'three.ws Club Stage',tags: ['3d', 'dance', 'club', 'tip', 'entertainment'],}),requiredScope: 'x402:bypass',diff --git a/api/x402/mint-to-mesh.js b/api/x402/mint-to-mesh.jsindex 157bc7868..427eaf418 100644--- a/api/x402/mint-to-mesh.js+++ b/api/x402/mint-to-mesh.js@@ -73,7 +73,7 @@ const DISCOVERY_INPUT_SCHEMA = {mint: {type: 'string',minLength: 32,- maxLength: 64,+ maxLength: 44,description: 'Base58 SPL mint address on Solana mainnet.',},},diff --git a/pages/home.html b/pages/home.htmlindex a5467d45c..92977a3a0 100644--- a/pages/home.html+++ b/pages/home.html@@ -68,13 +68,10 @@flex-shrink: 0;}.brand-mark {- width: 18px; height: 18px;- border: 1px solid var(--text); border-radius: 3px;- position: relative;- }- .brand-mark::after {- content: ""; position: absolute; inset: 4px;- background: var(--text);+ width: 24px; height: 24px;+ border-radius: 5px;+ display: block;+ flex-shrink: 0;}.nav-main { display: flex; gap: 2px; margin-left: 12px; flex: 1; }.nav-main a {@@ -572,18 +569,36 @@.walk-preview-joystick { display: block; }}+ /* Buy/sell semantic colors — the one place on the page we go full color.+ Everything else is monochrome; trading flow earns real green/red. */+ :root { --buy: #2ecc71; --sell: #ff5c5c; }+/* Pump.fun earn rows */.earn-rows { display: flex; flex-direction: column; gap: 1px; }.earn-row {background: var(--surface-1); padding: 14px 18px;display: flex; justify-content: space-between; align-items: center;border-bottom: 1px solid var(--hairline);+ animation: earn-row-in 0.32s cubic-bezier(.22,.68,0,.98);}+ @keyframes earn-row-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }.earn-row:last-child { border-bottom: none; }- .earn-row-left { display: flex; flex-direction: column; gap: 2px; }+ .earn-row-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }.earn-row-name { font-size: 14px; font-weight: 500; color: var(--text); }.earn-row-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-4); }- .earn-row-amount { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--green); }+ .earn-row-amount { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--green); display: flex; align-items: baseline; gap: 7px; }+ .earn-row-amount.buy { color: var(--buy); }+ .earn-row-amount.sell { color: var(--sell); }+ .hlt-usd { font-family: var(--font-mono); font-size: 10px; font-weight: 500; color: var(--text-4); }+ .hlt-side { font-weight: 700; }+ .hlt-side.buy { color: var(--buy); }+ .hlt-side.sell { color: var(--sell); }+ .hlt-live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--buy); box-shadow: 0 0 6px var(--buy); margin-right: 7px; vertical-align: middle; animation: hlt-pulse 1.4s ease-in-out infinite; }+ @keyframes hlt-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }+ .hlt-idle .earn-row-name { color: var(--text-3); font-weight: 500; }+ .hlt-skel { pointer-events: none; }+ .hlt-skel-bar { height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2, #1a1a1a) 25%, rgba(255,255,255,0.06) 50%, var(--surface-2, #1a1a1a) 75%); background-size: 200% 100%; animation: hlt-shimmer 1.3s linear infinite; }+ @keyframes hlt-shimmer { to { background-position: -200% 0; } }/* Token card */.token-card {@@ -591,15 +606,19 @@border-radius: 10px; padding: 18px; display: flex; gap: 14px; align-items: center;}.token-avatar {- width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;- background: linear-gradient(135deg, #ffffff 0%, #ffffff 100%);+ width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; overflow: hidden;+ background: linear-gradient(135deg, #2a2a3a 0%, #15151f 100%);display: flex; align-items: center; justify-content: center;font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: #fff;}- .token-info { flex: 1; }- .token-name { font-size: 14px; font-weight: 600; color: var(--text); }+ .token-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }+ .token-info { flex: 1; min-width: 0; }+ .token-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }.token-ticker { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }- .token-price { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--green); }+ .token-price { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--green); white-space: nowrap; transition: color .25s; }+ .token-price.up { color: var(--buy); }+ .token-price.down { color: var(--sell); }+ a.token-price { text-decoration: none; }/* ── STEPS ───────────────────────────────────────────────── */.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 64px; }@@ -824,6 +843,16 @@}.pg-status.ok { color: #4ade80; }.pg-status.err { color: #f87171; }+ .pg-status.warn { color: #fbbf24; }+ .pg-status.err::before { background: #f87171; box-shadow: 0 0 5px #f87171; }+ .pg-status.warn::before { background: #fbbf24; box-shadow: 0 0 5px #fbbf24; }+ .pg-key-field { margin-bottom: 16px; }+ .pg-key-hint {+ float: right; text-transform: none; letter-spacing: 0;+ color: var(--text-3); text-decoration: none; font-size: 10.5px;+ transition: color 0.15s;+ }+ .pg-key-hint:hover { color: var(--text); }.pg-response {background: var(--surface-1); border: 1px solid var(--hairline);border-radius: 8px; overflow: hidden;@@ -2268,21 +2297,45 @@.mint-card-inner{display:flex;align-items:center;justify-content:space-between;gap:10px}.mint-card-info{display:flex;flex-direction:column;gap:2px}.mint-card-label{font-family:var(--font-mono);font-size:10px;letter-spacing:.15em;text-transform:uppercase;color:var(--text-4);transition:color .3s}- .mint-card-name{font-family:var(--font-display);font-size:16px;font-weight:600;color:var(--text)}- .mint-card-chain{font-family:var(--font-mono);font-size:10px;color:var(--text-3);display:none}- .mint-card.minted .mint-card-chain{display:block}+ .mint-card-name{font-family:var(--font-display);font-size:16px;font-weight:600;color:var(--text);background:transparent;border:none;border-bottom:1px dashed transparent;padding:0 1px 1px;margin:0;width:auto;max-width:170px;outline:none;transition:border-color .15s}+ .mint-card-name:hover:not(:disabled),.mint-card-name:focus{border-bottom-color:var(--text-4)}+ .mint-card-name::placeholder{color:var(--text-4)}+ .mint-card-name:disabled{opacity:.65;cursor:default}+ .mint-card.error{border-color:rgba(248,113,113,.45)}+ .mint-card-name.shake{animation:mint-shake .4s cubic-bezier(.36,.07,.19,.97)}+ @keyframes mint-shake{10%,90%{transform:translateX(-1px)}20%,80%{transform:translateX(2px)}30%,50%,70%{transform:translateX(-4px)}40%,60%{transform:translateX(4px)}}+ .mint-card-chain{font-family:var(--font-mono);font-size:10px;color:var(--text-3);display:block}+ .mint-card-chain a{color:#4ade80;text-decoration:none;border-bottom:1px solid rgba(74,222,128,.3)}+ .mint-card-chain a:hover{border-bottom-color:#4ade80}.mint-card.minted .mint-card-label{color:#4ade80}+ .mint-status{margin:11px 0 0;font-family:var(--font-mono);font-size:10.5px;line-height:1.4;color:var(--text-3)}+ .mint-status.err{color:#f87171}+ .mint-status.ok{color:#4ade80}+ .mint-status a{color:inherit;text-decoration:underline;text-underline-offset:2px}.mint-progress{width:28px;height:28px;position:relative;display:none}.mint-progress.active{display:block}.mint-progress svg{width:100%;height:100%;transform:rotate(-90deg)}+ .mint-progress.active:not(.done) svg{animation:mint-spin .9s linear infinite}+ @keyframes mint-spin{from{transform:rotate(-90deg)}to{transform:rotate(270deg)}}.mint-progress circle{fill:none;stroke-width:3;stroke:var(--text-2);stroke-linecap:round;stroke-dasharray:78.5;stroke-dashoffset:78.5;transition:stroke-dashoffset 1.2s cubic-bezier(.2,.7,.3,1)}- .mint-progress.done circle{stroke-dashoffset:0;stroke:#4ade80}+ .mint-progress.active:not(.done) circle{stroke-dashoffset:55}+ .mint-progress.done circle{stroke-dashoffset:0;stroke:#4ade80;transition:stroke-dashoffset .5s cubic-bezier(.2,.7,.3,1)}.skill-demo{display:flex;flex-direction:column;gap:8px}.skill-result{background:var(--surface-2);border:1px solid var(--hairline-strong);border-radius:7px;padding:10px 14px;font-family:var(--font-mono);font-size:11px;color:var(--text-2);line-height:1.6;max-height:100px;overflow-y:auto;transition:border-color .3s}.skill-result.fresh{border-color:rgba(255,255,255,.2)}.skill-result .json-key{color:#60a5fa}.skill-result .json-str{color:#4ade80}.skill-result .json-num{color:#fbbf24}+ .skill-result .json-dim{color:var(--text-3)}+ .skill-result.loading{color:var(--text-3)}+ .skill-result.err{border-color:rgba(248,113,113,.4)}+ .skill-loading .json-key{color:#60a5fa}+ .skill-err{color:#f87171}+ .skill-cursor{color:var(--text-3);animation:skillBlink 1s steps(2,end) infinite}+ .skill-dots::after{content:'';animation:skillDots 1.4s steps(4,end) infinite}+ @keyframes skillDots{0%{content:''}25%{content:'.'}50%{content:'..'}75%{content:'...'}}+ @keyframes skillBlink{50%{opacity:0}}+ .bento-pill-btn[aria-busy="true"]{opacity:.6;cursor:progress}.memory-demo{display:flex;flex-direction:column;gap:8px}.memory-input-row{display:flex;gap:6px}.memory-input{flex:1;background:var(--surface-2);border:1px solid var(--hairline-strong);border-radius:6px;padding:7px 10px;font-family:var(--font-mono);font-size:11.5px;color:var(--text);outline:none;transition:border-color .15s}@@ -2316,15 +2369,16 @@.mktplace-item-name{position:absolute;bottom:0;left:0;right:0;padding:2px 4px;font-family:var(--font-mono);font-size:7px;color:var(--text);background:rgba(0,0,0,.7);text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mktplace-more{flex-shrink:0;width:52px;height:52px;border-radius:10px;border:1px dashed var(--hairline-strong);display:flex;align-items:center;justify-content:center;font-family:var(--font-mono);font-size:18px;color:var(--text-4);cursor:pointer;transition:border-color .15s,color .15s;text-decoration:none}.mktplace-more:hover{border-color:var(--text-3);color:var(--text-2)}- .analytics-demo{display:flex;flex-direction:column;gap:10px}+ .analytics-demo{display:flex;flex-direction:column;gap:10px;--spark:#34d399;--spark-deep:#10b981}.analytics-counters{display:flex;gap:16px}.analytics-counter{display:flex;flex-direction:column;gap:1px}.analytics-val{font-family:var(--font-display);font-size:18px;font-weight:600;color:var(--text);font-variant-numeric:tabular-nums;letter-spacing:-0.02em}+ .analytics-val#an-revenue{color:var(--spark)}.analytics-lbl{font-family:var(--font-mono);font-size:9px;letter-spacing:.12em;text-transform:uppercase;color:var(--text-4)}.analytics-spark{width:100%;height:40px;display:block}- .analytics-spark path{fill:none;stroke:var(--text-2);stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}- .analytics-spark .spark-fill{fill:url(#spark-grad);stroke:none;opacity:.15}- .analytics-spark .spark-dot{fill:var(--text);r:2.5;animation:spark-pulse 2s ease-in-out infinite}+ .analytics-spark path{fill:none;stroke:var(--spark);stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round;filter:drop-shadow(0 0 3px color-mix(in srgb,var(--spark) 55%,transparent))}+ .analytics-spark .spark-fill{fill:url(#spark-grad);stroke:none;opacity:1;filter:none}+ .analytics-spark .spark-dot{fill:var(--spark);r:2.5;filter:drop-shadow(0 0 4px var(--spark));animation:spark-pulse 2s ease-in-out infinite}@keyframes spark-pulse{0%,100%{opacity:1}50%{opacity:.4}}/* ── DRAGON VISION SECTION ───────────────────────────────── */@@ -2345,7 +2399,7 @@<header class="nav"><div class="nav-inner"><a class="brand" href="/">- <span class="brand-mark"></span>+ <img class="brand-mark" src="/pwa-icon.svg" alt="three.ws" width="24" height="24" /><span>three.ws</span></a><nav class="nav-main" aria-label="Primary">@@ -3004,27 +3058,28 @@<span style="font-family:var(--font-mono);font-size:11px;letter-spacing:0.15em;text-transform:uppercase;color:var(--text-3)">On-chain Identity</span></div><p class="bento-title">ERC-8004 agent standard</p>- <p class="bento-desc">Mint your agent as an ERC-8004 token — the emerging on-chain standard for AI agents. Own it, trade it, and let other agents discover and call it autonomously via A2A.</p>+ <p class="bento-desc">Mint your agent as an ERC-8004 identity on Solana — a Metaplex Core asset minted in one transaction for sub-cent fees. Own it, trade it, and let other agents discover and call it autonomously via A2A.</p><div class="bento-interact mint-demo"><div class="mint-card" id="mint-card"><div class="mint-card-inner"><div class="mint-card-info">- <span class="mint-card-label" id="mint-label">ERC-8004</span>- <span class="mint-card-name">nich.agent</span>- <span class="mint-card-chain" id="mint-chain">Base · Block 18,291,042</span>+ <span class="mint-card-label" id="mint-label">ERC-8004 · Solana</span>+ <input class="mint-card-name" id="mint-name" type="text" value="my-agent" maxlength="32" spellcheck="false" autocomplete="off" aria-label="Agent name to deploy" />+ <span class="mint-card-chain" id="mint-chain">Metaplex Core · mainnet</span></div><div class="mint-progress" id="mint-progress"><svg viewBox="0 0 28 28"><circle cx="14" cy="14" r="12.5"/></svg></div>- <button class="bento-action-btn sm" id="mint-btn">Mint</button>+ <button class="bento-action-btn sm" id="mint-btn">Deploy</button></div>+ <p class="mint-status" id="mint-status" role="status" aria-live="polite" hidden></p></div></div><div class="bento-pills"><span class="bento-pill">ERC-8004</span>- <span class="bento-pill">EVM</span>+ <span class="bento-pill">Solana</span>+ <span class="bento-pill">Metaplex Core</span><span class="bento-pill">A2A</span>- <span class="bento-pill">MCP</span></div></div>@@ -3109,7 +3164,7 @@<!-- Analytics --><div class="bento-card"><div class="bento-icon">- <span class="dot" style="background:#e8e8e8;box-shadow:0 0 8px #e8e8e855"></span>+ <span class="dot" style="background:#34d399;box-shadow:0 0 8px #34d39988"></span><span style="font-family:var(--font-mono);font-size:11px;letter-spacing:0.15em;text-transform:uppercase;color:var(--text-3)">Analytics</span></div><p class="bento-title">Track everything</p>@@ -3121,7 +3176,7 @@<div class="analytics-counter"><span class="analytics-val" id="an-retention">0%</span><span class="analytics-lbl">retention</span></div></div><svg class="analytics-spark" id="analytics-spark" viewBox="0 0 200 40" preserveAspectRatio="none">- <defs><linearGradient id="spark-grad" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="var(--text-2)"/><stop offset="100%" stop-color="transparent"/></linearGradient></defs>+ <defs><linearGradient id="spark-grad" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#34d399" stop-opacity="0.35"/><stop offset="100%" stop-color="#34d399" stop-opacity="0"/></linearGradient></defs></svg></div></div>@@ -3158,49 +3213,20 @@</div></div><div class="feat-visual">- <div class="feat-visual-label">Live token · $NICH / SOL</div>- <div class="feat-visual-inner">- <div class="token-card">- <div class="token-avatar">NICH</div>+ <div class="feat-visual-label" id="hlt-label">Live token · Pump.fun</div>+ <div class="feat-visual-inner" id="hlt-card">+ <a class="token-card" id="hlt-pump-link" href="https://pump.fun" target="_blank" rel="noopener noreferrer" style="text-decoration:none;color:inherit;">+ <div class="token-avatar" id="hlt-avatar">—</div><div class="token-info">- <div class="token-name">NICH Agent Token</div>- <div class="token-ticker">$NICH · Pump.fun</div>- </div>- <div class="token-price">+24.6%</div>- </div>- <div class="earn-rows" style="border:1px solid var(--hairline);border-radius:8px;overflow:hidden;">- <div class="earn-row">- <div class="earn-row-left">- <div class="earn-row-name">Buy · 0x7f3a…</div>- <div class="earn-row-time">3s ago</div>- </div>- <div class="earn-row-amount">+0.5 SOL</div>- </div>- <div class="earn-row">- <div class="earn-row-left">- <div class="earn-row-name">Buy · 0x2e1b…</div>- <div class="earn-row-time">12s ago</div>- </div>- <div class="earn-row-amount">+2.0 SOL</div>- </div>- <div class="earn-row">- <div class="earn-row-left">- <div class="earn-row-name">Tip · @alice</div>- <div class="earn-row-time">1m ago</div>- </div>- <div class="earn-row-amount">+$4.20</div>+ <div class="token-name" id="hlt-name">Loading live token…</div>+ <div class="token-ticker" id="hlt-ticker">Streaming from pump.fun</div></div>- <div class="earn-row">- <div class="earn-row-left">- <div class="earn-row-name">Buy · 0x9c4f…</div>- <div class="earn-row-time">2m ago</div>- </div>- <div class="earn-row-amount">+1.2 SOL</div>- </div>- </div>+ <div class="token-price" id="hlt-price">Live</div>+ </a>+ <div class="earn-rows" id="hlt-rows" style="border:1px solid var(--hairline);border-radius:8px;overflow:hidden;"></div><div style="display:flex;gap:10px;"><a class="btn sm" href="/pumpfun-trending" style="flex:1;justify-content:center;">Trending tokens</a>- <a class="btn sm primary" href="/create" style="flex:1;justify-content:center;">Launch yours</a>+ <button class="btn sm primary" id="hlt-launch" type="button" style="flex:1;justify-content:center;">Launch yours</button></div></div></div>@@ -3353,6 +3379,10 @@</div><div id="pg-builder" style="display:none;"><div class="pg-request">+ <div class="pg-field pg-key-field">+ <label class="pg-field-label" for="pg-key">API key<a class="pg-key-hint" href="/dashboard/api" target="_blank" rel="noopener">Get a key ↗</a></label>+ <input class="pg-input" id="pg-key" type="password" autocomplete="off" spellcheck="false" placeholder="Bearer token — required for /agents and /chat" />+ </div><div class="pg-url-bar"><div class="pg-url-method" id="pg-method">GET</div><input class="pg-url-path" id="pg-path" readonly />@@ -3709,6 +3739,15 @@if (walkContainer) initWalkPreview(walkContainer);</script>+<script type="module">+ // Live pump.fun token card + real "Launch yours" flow.+ import { initHomeLiveToken } from '/src/home-live-token.js';+ import { initHomepageLauncher } from '/src/pump/homepage-launcher.js';+ const hltCard = document.getElementById('hlt-card');+ if (hltCard) initHomeLiveToken(hltCard);+ initHomepageLauncher(document.getElementById('hlt-launch'));+</script>+<script>// ── Boot live <agent-3d> instances ─────────────────────────────const AVATAR_ID = 'bacff13e-b64b-4ac0-860d-44f0168ad23b';@@ -5466,54 +5505,27 @@ if (canvas && tiers.length && window.matchMedia('(min-width: 861px)').matches) {});})();- // ── 5. On-chain Identity: mint animation ────────────────────────- (function() {- var mintBtn = document.getElementById('mint-btn');- var card = document.getElementById('mint-card');- var progress = document.getElementById('mint-progress');- var label = document.getElementById('mint-label');- if (!mintBtn) return;-- mintBtn.addEventListener('click', function() {- mintBtn.style.display = 'none';- progress.classList.add('active');-- setTimeout(function() {- progress.classList.add('done');- }, 100);+ // ── 5. On-chain Identity: real Solana deploy lives in the module+ // script near the end of <body> (needs ES-module imports). ─────- setTimeout(function() {- card.classList.add('minted');- label.textContent = 'MINTED';-- setTimeout(function() {- card.classList.remove('minted');- label.textContent = 'ERC-8004';- progress.classList.remove('active', 'done');- progress.querySelector('circle').style.strokeDashoffset = '78.5';- void progress.querySelector('circle').offsetWidth;- mintBtn.style.display = '';- }, 3000);- }, 1400);- });- })();-- // ── 6. Skills: tool call demo ───────────────────────────────────+ // ── 6. Skills: live tool-call demo ──────────────────────────────+ // Every pill fires a REAL call: Jupiter's public quote API, our Solana+ // RPC proxy, the live pump.fun launch feed (SSE), and an A2A agent ask+ // streamed through /api/chat. No canned responses.(function() {var tools = document.getElementById('skill-tools');var result = document.getElementById('skill-result');if (!tools || !result) return;- var responses = {- jupiter: { tool: 'jupiter_swap', input: { from: 'USDC', to: 'SOL', amount: '10.00' }, output: { received: '0.0847 SOL', rate: '118.07', slippage: '0.12%' } },- pump: { tool: 'pump_launch', input: { name: 'NICH', ticker: '$NICH' }, output: { status: 'launched', ca: '7xKX...m3Qp', mcap: '$4,200', holders: 12 } },- rpc: { tool: 'solana_rpc', method: 'getBalance', params: ['7xKXp...m3Qp'], result: { value: 2410000000, lamports: true, sol: '2.41' } },- a2a: { protocol: 'a2a', target: 'claude.agent', action: 'ask', input: 'What is ERC-8004?', response: 'ERC-8004 is the on-chain standard for AI agent identity...' }- };+ var USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';+ var WSOL = 'So11111111111111111111111111111111111111112';+ var seq = 0; // monotonic token — only the latest click renders+ var pending = null; // open EventSource to tear down on tool switchfunction colorJson(obj, indent) {indent = indent || 0;var pad = ' '.repeat(indent);+ if (obj === null || obj === undefined) return '<span class="json-dim">null</span>';if (typeof obj === 'string') return '<span class="json-str">"' + obj + '"</span>';if (typeof obj === 'number') return '<span class="json-num">' + obj + '</span>';if (typeof obj === 'boolean') return '<span class="json-num">' + obj + '</span>';@@ -5522,7 +5534,7 @@ if (canvas && tiers.length && window.matchMedia('(min-width: 861px)').matches) {var items = obj.map(function(v) { return pad + ' ' + colorJson(v, indent + 1); });return '[\n' + items.join(',\n') + '\n' + pad + ']';}- var keys = Object.keys(obj);+ var keys = Object.keys(obj).filter(function(k) { return obj[k] !== null && obj[k] !== undefined; });if (keys.length === 0) return '{}';var lines = keys.map(function(k) {return pad + ' <span class="json-key">"' + k + '"</span>: ' + colorJson(obj[k], indent + 1);@@ -5530,12 +5542,177 @@ if (canvas && tiers.length && window.matchMedia('(min-width: 861px)').matches) {return '{\n' + lines.join(',\n') + '\n' + pad + '}';}- function showTool(name) {- var data = responses[name];- if (!data) return;- result.innerHTML = colorJson(data, 0);- result.classList.add('fresh');- setTimeout(function() { result.classList.remove('fresh'); }, 600);+ function setLoading(label) {+ result.classList.remove('err', 'fresh');+ result.classList.add('loading');+ result.innerHTML = '<span class="skill-loading">▸ calling <span class="json-key">' + label + '</span><span class="skill-dots"></span></span>';+ }+ function setError(label, msg) {+ result.classList.remove('loading', 'fresh');+ result.classList.add('err');+ result.innerHTML = '<span class="skill-err">✕ ' + label + ' — ' + msg + '</span>';+ }+ function render(obj, streamingHtml) {+ result.classList.remove('loading', 'err');+ result.innerHTML = streamingHtml || colorJson(obj, 0);+ if (!streamingHtml) {+ result.classList.add('fresh');+ setTimeout(function() { result.classList.remove('fresh'); }, 600);+ }+ }+ function teardown() {+ if (pending) { try { pending.close(); } catch (_) {} pending = null; }+ }++ var runners = {+ jupiter: function(my) {+ setLoading('jupiter_swap');+ return fetch('https://lite-api.jup.ag/swap/v1/quote?inputMint=' + USDC + '&outputMint=' + WSOL + '&amount=10000000&slippageBps=50')+ .then(function(r) { if (!r.ok) throw new Error('HTTP ' + r.status); return r.json(); })+ .then(function(q) {+ if (my !== seq) return;+ var sol = Number(q.outAmount) / 1e9;+ var route = (q.routePlan || []).map(function(p) { return p.swapInfo && p.swapInfo.label; }).filter(Boolean);+ render({+ tool: 'jupiter_swap',+ input: { from: 'USDC', to: 'SOL', amount: '10.00' },+ output: {+ received: sol.toFixed(4) + ' SOL',+ rate: (sol > 0 ? (10 / sol) : 0).toFixed(2) + ' USDC/SOL',+ price_impact: (Number(q.priceImpactPct || 0) * 100).toFixed(3) + '%',+ slippage: ((q.slippageBps || 50) / 100).toFixed(2) + '%',+ route: route.length ? route.join(' → ') : 'direct'+ }+ });+ })+ .catch(function(e) { if (my === seq) setError('jupiter_swap', e.message); });+ },++ rpc: function(my) {+ setLoading('solana_rpc');+ return fetch('/api/solana-rpc', {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'getEpochInfo' })+ })+ .then(function(r) { if (!r.ok) throw new Error('HTTP ' + r.status); return r.json(); })+ .then(function(j) {+ if (my !== seq) return;+ var v = j.result || {};+ render({+ tool: 'solana_rpc',+ method: 'getEpochInfo',+ network: 'mainnet-beta',+ result: {+ epoch: v.epoch,+ absolute_slot: v.absoluteSlot,+ block_height: v.blockHeight,+ slot_index: v.slotIndex + ' / ' + v.slotsInEpoch,+ tx_count: v.transactionCount+ }+ });+ })+ .catch(function(e) { if (my === seq) setError('solana_rpc', e.message); });+ },++ pump: function(my) {+ setLoading('pump_live_feed');+ return new Promise(function(resolve) {+ var es, settled = false, to;+ function finish(fn) {+ if (settled) return;+ settled = true;+ clearTimeout(to);+ if (es) { try { es.close(); } catch (_) {} }+ if (pending === es) pending = null;+ fn();+ resolve();+ }+ try { es = new EventSource('/api/pump/live-stream?kind=mint'); }+ catch (e) { if (my === seq) setError('pump_live_feed', 'feed unavailable'); return resolve(); }+ pending = es;+ to = setTimeout(function() {+ finish(function() { if (my === seq) setError('pump_live_feed', 'no launches in the last 20s — try again'); });+ }, 20000);+ es.addEventListener('mint', function(ev) {+ var d;+ try { d = JSON.parse(ev.data); } catch (_) { return; }+ finish(function() {+ if (my !== seq) return;+ render({+ tool: 'pump_live_feed',+ event: 'new_mint',+ source: 'pump.fun · mainnet',+ data: {+ name: d.name || '(unnamed)',+ symbol: d.symbol ? ('$' + String(d.symbol).replace(/^\$/, '')) : null,+ mint: d.mint ? (d.mint.slice(0, 4) + '…' + d.mint.slice(-4)) : null,+ market_cap_usd: (d.market_cap_usd != null) ? '$' + Math.round(d.market_cap_usd).toLocaleString() : null,+ initial_buy_sol: (d.initial_buy_sol != null) ? Number(d.initial_buy_sol).toFixed(3) + ' SOL' : null+ }+ });+ });+ });+ es.onerror = function() {+ finish(function() { if (my === seq) setError('pump_live_feed', 'feed disconnected'); });+ };+ });+ },++ a2a: function(my) {+ setLoading('a2a · agent.ask');+ var question = 'In one sentence, what can I build on three.ws?';+ var base = { protocol: 'a2a', target: 'claude.agent', action: 'ask', input: question };+ function paint(text, streaming) {+ if (my !== seq) return;+ result.classList.remove('loading', 'err');+ var json = colorJson(Object.assign({}, base, { response: text || '' }), 0);+ result.innerHTML = streaming ? json.replace(/<\/span>(\n\})$/, '<span class="skill-cursor">▍</span></span>$1') : json;+ }+ return fetch('/api/chat', {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({+ message: question,+ system_prompt: 'You are the three.ws platform agent. Answer in ONE concise, confident sentence, no preamble.',+ history: [],+ context: {}+ })+ })+ .then(function(r) { if (!r.ok || !r.body) throw new Error('HTTP ' + r.status); return r.body.getReader(); })+ .then(function(reader) {+ var dec = new TextDecoder(), buf = '', text = '';+ function step(res) {+ if (my !== seq) { try { reader.cancel(); } catch (_) {} return; }+ if (res.done) {+ if (my === seq) { paint(text || '(no response)', false); result.classList.add('fresh'); setTimeout(function() { result.classList.remove('fresh'); }, 600); }+ return;+ }+ buf += dec.decode(res.value, { stream: true });+ var lines = buf.split('\n');+ buf = lines.pop();+ lines.forEach(function(line) {+ if (line.indexOf('data: ') !== 0) return;+ var data = line.slice(6).trim();+ if (!data || data === '[DONE]') return;+ try {+ var parsed = JSON.parse(data);+ if (parsed.type === 'chunk' && parsed.text) text += parsed.text;+ } catch (_) {}+ });+ paint(text, true);+ return reader.read().then(step);+ }+ return reader.read().then(step);+ })+ .catch(function(e) { if (my === seq) setError('a2a · agent.ask', e.message); });+ }+ };++ function run(name) {+ teardown();+ var my = ++seq;+ (runners[name] || runners.jupiter)(my);}tools.addEventListener('click', function(e) {@@ -5543,10 +5720,21 @@ if (canvas && tiers.length && window.matchMedia('(min-width: 861px)').matches) {if (!btn) return;tools.querySelectorAll('.bento-pill-btn').forEach(function(b) { b.classList.remove('active'); });btn.classList.add('active');- showTool(btn.dataset.tool);+ run(btn.dataset.tool);});- showTool('jupiter');+ // Fire the first real call only when the card scrolls into view.+ var fired = false;+ if ('IntersectionObserver' in window) {+ var io = new IntersectionObserver(function(entries) {+ entries.forEach(function(en) {+ if (en.isIntersecting && !fired) { fired = true; run('jupiter'); io.disconnect(); }+ });+ }, { threshold: 0.3 });+ io.observe(result);+ } else {+ run('jupiter');+ }})();// ── 7. Memory: store/recall demo ────────────────────────────────@@ -5729,5 +5917,154 @@ if (canvas && tiers.length && window.matchMedia('(min-width: 861px)').matches) {})();</script>++<!-- On-chain Identity: real Solana (Metaplex Core) deploy. Module scope so we+ can dynamically import the deploy flow only when the user clicks Deploy,+ keeping the rest of the homepage lean. -->+<script type="module">+(function () {+ const btn = document.getElementById('mint-btn');+ const card = document.getElementById('mint-card');+ const progress = document.getElementById('mint-progress');+ const label = document.getElementById('mint-label');+ const nameInput = document.getElementById('mint-name');+ const chainEl = document.getElementById('mint-chain');+ const statusEl = document.getElementById('mint-status');+ if (!btn || !card || !nameInput) return;++ const NETWORK = 'mainnet';+ const DEFAULT_CHAIN = 'Metaplex Core · mainnet';+ let deploying = false;++ const short = (a) => (a ? a.slice(0, 4) + '…' + a.slice(-4) : '');++ function extLink(href, text) {+ const a = document.createElement('a');+ a.href = href;+ a.textContent = text;+ a.target = '_blank';+ a.rel = 'noopener';+ return a;+ }+ function navLink(href, text) {+ const a = document.createElement('a');+ a.href = href;+ a.textContent = text;+ return a;+ }++ function setStatus(parts, kind) {+ if (!parts) {+ statusEl.hidden = true;+ statusEl.textContent = '';+ statusEl.className = 'mint-status';+ return;+ }+ statusEl.hidden = false;+ statusEl.className = 'mint-status' + (kind ? ' ' + kind : '');+ statusEl.textContent = '';+ statusEl.append(...(Array.isArray(parts) ? parts : [parts]));+ }++ function resetRing() {+ progress.classList.remove('active', 'done');+ const c = progress.querySelector('circle');+ if (c) {+ c.style.strokeDashoffset = '';+ void c.offsetWidth;+ }+ }++ function showError(err) {+ card.classList.add('error');+ const code = err && err.code;+ const httpStatus = err && err.status;+ if (code === 'NO_WALLET') {+ setStatus(['No Solana wallet detected — ', extLink('https://phantom.app/', 'install Phantom ↗'), ' to deploy.'], 'err');+ return;+ }+ if (httpStatus === 401) {+ setStatus(['Sign in to mint your agent — ', navLink('/deploy', 'open the deploy console ↗')], 'err');+ return;+ }+ if (code === 'forbidden' || httpStatus === 403) {+ setStatus(['Link this Solana wallet to your account first — ', navLink('/deploy', 'finish in the deploy console ↗')], 'err');+ return;+ }+ const msg = (err && err.message) || 'Deploy failed — try again.';+ if (/reject|denied|cancel|user.*declin/i.test(msg)) {+ setStatus('Transaction cancelled in wallet.', 'err');+ return;+ }+ setStatus(msg.length > 96 ? msg.slice(0, 96) + '…' : msg, 'err');+ }++ async function deploy() {+ if (deploying) return;+ const name = (nameInput.value || '').trim();+ if (!name) {+ nameInput.classList.remove('shake');+ void nameInput.offsetWidth;+ nameInput.classList.add('shake');+ nameInput.focus();+ setStatus('Name your agent first.', 'err');+ card.classList.add('error');+ return;+ }++ deploying = true;+ card.classList.remove('error', 'minted');+ label.textContent = 'ERC-8004 · Solana';+ chainEl.textContent = DEFAULT_CHAIN;+ nameInput.disabled = true;+ btn.disabled = true;+ btn.textContent = 'Deploying…';+ resetRing();+ progress.classList.add('active');+ setStatus('Connecting your Solana wallet…');++ try {+ const { runSolanaDeploy, solanaTxExplorerUrl } = await import('/src/erc8004/solana-deploy.js');+ setStatus('Approve the mint in your wallet, then waiting for confirmation…');+ const res = await runSolanaDeploy({ agent: { name }, network: NETWORK });++ progress.classList.add('done');+ card.classList.add('minted');+ label.textContent = 'MINTED';+ chainEl.textContent = 'Metaplex Core · ';+ chainEl.append(extLink('https://solscan.io/token/' + res.assetPubkey, short(res.assetPubkey)));+ setStatus(['Live on Solana ✓ ', extLink(solanaTxExplorerUrl(res.network, res.txSignature), 'view tx ↗')], 'ok');+ btn.textContent = 'Deployed ✓';+ setTimeout(() => {+ btn.disabled = false;+ btn.textContent = 'Deploy another';+ nameInput.disabled = false;+ deploying = false;+ }, 1400);+ } catch (err) {+ resetRing();+ showError(err);+ nameInput.disabled = false;+ btn.disabled = false;+ btn.textContent = 'Deploy';+ deploying = false;+ }+ }++ btn.addEventListener('click', deploy);+ nameInput.addEventListener('keydown', (e) => {+ if (e.key === 'Enter') {+ e.preventDefault();+ deploy();+ }+ });+ nameInput.addEventListener('input', () => {+ if (card.classList.contains('error')) {+ card.classList.remove('error');+ setStatus(null);+ }+ });+})();+</script></body></html>diff --git a/scripts/render-demo-thumbs.mjs b/scripts/render-demo-thumbs.mjsindex d0548b031..e55c1315f 100644--- a/scripts/render-demo-thumbs.mjs+++ b/scripts/render-demo-thumbs.mjs@@ -85,11 +85,15 @@ async function capture(page, src) {mv.addEventListener('load', () => { clearTimeout(t); res(); }, { once: true });mv.addEventListener('error', () => { clearTimeout(t); rej(new Error('load error')); }, { once: true });});- // Re-apply framing AFTER load: auto radius only fits correctly once the- // geometry is present. Setting it pre-load frames against an empty scene.- mv.fieldOfView = 'auto';+ // Frame deterministically from the model's real bounding box so every+ // model — regardless of its native scale — fills the swatch the same way.+ const FOV = 26; // degrees+ const dims = mv.getDimensions(); // metres, post-load bounding box+ const maxDim = Math.max(dims.x, dims.y, dims.z);+ const radius = (maxDim / 2) / Math.tan((FOV / 2) * Math.PI / 180) * 1.12;+ mv.fieldOfView = `${FOV}deg`;mv.cameraTarget = 'auto auto auto';- mv.cameraOrbit = '0deg 82deg auto';+ mv.cameraOrbit = `0deg 82deg ${radius}m`;await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));}, src);diff --git a/scripts/smoke-api-endpoints.mjs b/scripts/smoke-api-endpoints.mjsnew file mode 100644index 000000000..3d5b06305--- /dev/null+++ b/scripts/smoke-api-endpoints.mjs@@ -0,0 +1,141 @@+#!/usr/bin/env node+// Smoke-test every API endpoint against a deployed target.+//+// Walks api/, derives Vercel routes from the file tree, then GETs each one and+// classifies the response. A GET is a liveness probe: a deployed function that+// requires POST/auth/params answers 405/401/403/400 — all of which prove the+// function is routed and running. Only 5xx (or network failure) means broken.+//+// Usage: node scripts/smoke-api-endpoints.mjs [baseUrl] [--concurrency=12]+// baseUrl defaults to https://three.ws++import { readdir } from 'node:fs/promises';+import { join, relative } from 'node:path';++const BASE = (process.argv.find((a) => /^https?:\/\//.test(a)) || 'https://three.ws').replace(/\/$/, '');+const CONCURRENCY = Number((process.argv.find((a) => a.startsWith('--concurrency=')) || '').split('=')[1]) || 12;+const TIMEOUT_MS = 20000;+const API_DIR = new URL('../api/', import.meta.url).pathname;++// Placeholder values for dynamic segments so the route actually matches.+const DYN = { id: 'test', action: 'status', name: 'health', type: 'index', path: 'test' };++async function walk(dir) {+ const out = [];+ for (const ent of await readdir(dir, { withFileTypes: true })) {+ const full = join(dir, ent.name);+ // Skip helper dirs/files (underscore-prefixed) and non-endpoint files.+ if (ent.name.startsWith('_')) continue;+ if (ent.isDirectory()) {+ out.push(...(await walk(full)));+ } else if (ent.name.endsWith('.js') || ent.name.endsWith('.ts')) {+ out.push(full);+ }+ }+ return out;+}++function fileToRoute(file) {+ let rel = relative(API_DIR, file).replace(/\.(js|ts)$/, '');+ const segments = rel.split('/');+ // index files map to their dir root+ const mapped = segments+ .filter((s, i) => !(s === 'index' && i === segments.length - 1))+ .map((s) => {+ const m = s.match(/^\[\.\.\.(.+)\]$/) || s.match(/^\[(.+)\]$/);+ if (!m) return s;+ const key = m[1];+ return DYN[key] ?? 'test';+ });+ return '/api/' + mapped.join('/');+}++function classify(status) {+ if (status >= 500) return 'BROKEN';+ if (status === 404) return 'NOT_FOUND';+ if (status === 405) return 'alive(405)';+ if (status === 401 || status === 403) return 'alive(auth)';+ if (status === 400 || status === 422) return 'alive(400)';+ if (status >= 200 && status < 300) return 'OK';+ if (status >= 300 && status < 400) return 'OK(redirect)';+ if (status === 402) return 'alive(402)';+ if (status === 429) return 'alive(429)';+ return `other(${status})`;+}++async function probe(route) {+ const url = BASE + route;+ const ctrl = new AbortController();+ const t = setTimeout(() => ctrl.abort(), TIMEOUT_MS);+ const started = Date.now();+ try {+ const r = await fetch(url, {+ method: 'GET',+ headers: { accept: 'application/json', 'user-agent': 'three-ws-smoke/1.0' },+ redirect: 'manual',+ signal: ctrl.signal,+ });+ return { route, status: r.status, ms: Date.now() - started, cls: classify(r.status) };+ } catch (e) {+ return { route, status: 0, ms: Date.now() - started, cls: 'NETERR', err: e.name === 'AbortError' ? 'timeout' : e.message };+ } finally {+ clearTimeout(t);+ }+}++async function pool(items, n, fn) {+ const results = [];+ let i = 0;+ const workers = Array.from({ length: n }, async () => {+ while (i < items.length) {+ const idx = i++;+ results[idx] = await fn(items[idx]);+ }+ });+ await Promise.all(workers);+ return results;+}++const files = await walk(API_DIR);+// Dedupe routes (e.g. index collisions) keeping the first file.+const routeMap = new Map();+for (const f of files) {+ const r = fileToRoute(f);+ if (!routeMap.has(r)) routeMap.set(r, f);+}+const routes = [...routeMap.keys()].sort();++console.log(`Probing ${routes.length} routes against ${BASE} (GET, concurrency=${CONCURRENCY})\n`);+const results = await pool(routes, CONCURRENCY, probe);++const groups = {};+for (const r of results) (groups[r.cls] ??= []).push(r);++// Print the problem groups in full, summarize the healthy ones.+const order = ['BROKEN', 'NETERR', 'NOT_FOUND', 'OK', 'OK(redirect)', 'alive(auth)', 'alive(405)', 'alive(400)', 'alive(402)', 'alive(429)'];+const seen = new Set();+function dump(label, list, full) {+ if (!list?.length) return;+ console.log(`\n=== ${label} — ${list.length} ===`);+ const show = full ? list : list.slice(0, 0);+ for (const r of show.sort((a, b) => a.route.localeCompare(b.route))) {+ console.log(` ${String(r.status).padStart(3)} ${r.route}${r.err ? ' (' + r.err + ')' : ''}`);+ }+}++// Always show broken + network errors in full — these are the real findings.+dump('BROKEN (5xx)', groups.BROKEN, true);+dump('NETWORK ERROR / TIMEOUT', groups.NETERR, true);+dump('NOT_FOUND (404 — unrouted or needs real param)', groups.NOT_FOUND, true);++console.log('\n=== SUMMARY ===');+for (const k of [...order, ...Object.keys(groups)]) {+ if (seen.has(k) || !groups[k]) continue;+ seen.add(k);+ console.log(` ${k.padEnd(16)} ${groups[k].length}`);+}+const healthy = results.filter((r) => r.cls !== 'BROKEN' && r.cls !== 'NETERR').length;+console.log(`\n ${healthy}/${results.length} routes responded without server error.`);++const broken = (groups.BROKEN?.length || 0) + (groups.NETERR?.length || 0);+process.exit(broken > 0 ? 1 : 0);diff --git a/src/api-playground.js b/src/api-playground.jsindex fb462b785..2dfc805f8 100644--- a/src/api-playground.js+++ b/src/api-playground.js@@ -6,18 +6,21 @@'list-agents': {method: 'GET', path: '/api/agents', params: [],desc: 'List all agents in your account',+ auth: true,sampleBody: null,sdk: "const res = await fetch('" + PG_ORIGIN + "/api/agents', {\n headers: { 'Authorization': 'Bearer YOUR_API_KEY' }\n});\nconst agents = await res.json();",},'create-agent': {method: 'POST', path: '/api/agents', params: [],desc: 'Create a new agent from avatar + prompt',+ auth: true,sampleBody: JSON.stringify({ name: 'my-agent', avatar_id: PG_DEMO, system_prompt: 'You are a helpful assistant.' }, null, 2),sdk: "const res = await fetch('" + PG_ORIGIN + "/api/agents', {\n method: 'POST',\n headers: {\n 'Authorization': 'Bearer YOUR_API_KEY',\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n name: 'my-agent',\n avatar_id: '" + PG_DEMO + "',\n system_prompt: 'You are a helpful assistant.'\n })\n});\nconst agent = await res.json();",},'chat': {method: 'POST', path: '/api/chat', params: [],desc: 'Send a message and stream a response',+ auth: false,sampleBody: JSON.stringify({ agent_id: PG_DEMO, message: 'Hello, who are you?', stream: false }, null, 2),sdk: "const res = await fetch('" + PG_ORIGIN + "/api/chat', {\n method: 'POST',\n headers: {\n 'Authorization': 'Bearer YOUR_API_KEY',\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n agent_id: '" + PG_DEMO + "',\n message: 'Hello, who are you?',\n stream: false\n })\n});\nconst reply = await res.json();",},@@ -25,6 +28,7 @@method: 'GET', path: '/api/avatars/:id',params: [{ key: 'id', label: 'Avatar ID', placeholder: PG_DEMO, default: PG_DEMO }],desc: 'Fetch avatar metadata and GLB URL',+ auth: false,sampleBody: null,sdk: "const res = await fetch('" + PG_ORIGIN + "/api/avatars/" + PG_DEMO + "');\nconst avatar = await res.json();",},@@ -32,15 +36,17 @@method: 'POST', path: '/api/mcp',params: [],desc: 'JSON-RPC 2.0 call to the MCP server',+ auth: false, paid: true,sampleBody: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/list', params: {} }, null, 2),sdk: "const res = await fetch('" + PG_ORIGIN + "/api/mcp', {\n method: 'POST',\n headers: {\n 'Authorization': 'Bearer YOUR_API_KEY',\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'tools/list',\n params: {}\n })\n});\nconst result = await res.json();",},'a2a': {- method: 'POST', path: '/api/agents/:agentId/a2a',- params: [{ key: 'agentId', label: 'Agent ID', placeholder: PG_DEMO, default: PG_DEMO }],- desc: 'Agent-to-agent protocol endpoint',- sampleBody: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'message/send', params: { message: { role: 'user', parts: [{ type: 'text', text: 'Hello' }] } } }, null, 2),- sdk: "const res = await fetch('" + PG_ORIGIN + "/api/agents/" + PG_DEMO + "/a2a', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n jsonrpc: '2.0', id: 1,\n method: 'message/send',\n params: { message: { role: 'user', parts: [{ type: 'text', text: 'Hello' }] } }\n })\n});\nconst result = await res.json();",+ method: 'POST', path: '/api/agents/a2a-paid',+ params: [],+ desc: 'Agent-to-agent protocol endpoint (JSON-RPC 2.0)',+ auth: false,+ sampleBody: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'message/send', params: { message: { role: 'user', parts: [{ type: 'text', text: 'Inspect https://three.ws/avatars/default.glb' }] } } }, null, 2),+ sdk: "const res = await fetch('" + PG_ORIGIN + "/api/agents/a2a-paid', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n jsonrpc: '2.0', id: 1,\n method: 'message/send',\n params: { message: { role: 'user', parts: [{ type: 'text', text: 'Inspect https://three.ws/avatars/default.glb' }] } }\n })\n});\nconst result = await res.json();",},};@@ -49,6 +55,7 @@tabs: pgEl('pg-tabs'),empty: pgEl('pg-empty-state'),builder: pgEl('pg-builder'),+ key: pgEl('pg-key'),method: pgEl('pg-method'),path: pgEl('pg-path'),params: pgEl('pg-params'),@@ -67,6 +74,22 @@if (!pgS.tabs || !pgS.endpoints) return;var pgActive = null;+ var PG_KEY_STORE = 'threews_pg_api_key';++ function pgGetKey() {+ return pgS.key ? pgS.key.value.trim() : '';+ }++ // Restore a previously-entered key and persist edits so the playground is+ // usable across reloads without re-pasting credentials.+ if (pgS.key) {+ try { pgS.key.value = localStorage.getItem(PG_KEY_STORE) || ''; } catch (_) {}+ pgS.key.addEventListener('input', function() {+ try { localStorage.setItem(PG_KEY_STORE, pgGetKey()); } catch (_) {}+ pgUpdateCurl();+ pgUpdateSdk();+ });+ }function pgHighlightJson(json) {return json@@ -91,7 +114,10 @@function pgBuildCurl(ep) {var url = PG_ORIGIN + pgResolvePath(ep);var cmd = 'curl -X ' + ep.method + " '" + url + "'";- cmd += " \\\n -H 'Authorization: Bearer YOUR_API_KEY'";+ var key = pgGetKey();+ if (ep.auth || key) {+ cmd += " \\\n -H 'Authorization: Bearer " + (key || 'YOUR_API_KEY') + "'";+ }if (ep.sampleBody) {var body = pgS.body.value.trim() || ep.sampleBody;cmd += " \\\n -H 'Content-Type: application/json'";@@ -109,6 +135,8 @@code = code.split(param.default).join(val);}});+ var key = pgGetKey();+ if (key) code = code.split('YOUR_API_KEY').join(key);return code;}@@ -195,11 +223,76 @@}});+ function pgShowBody(text) {+ var display;+ try {+ display = pgHighlightJson(JSON.stringify(JSON.parse(text), null, 2));+ } catch (_) {+ display = text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');+ }+ pgS.respBody.innerHTML = display;+ pgS.response.style.display = 'block';+ }++ function pgSetStatus(status, statusText, elapsed) {+ var label = status + (statusText ? ' ' + statusText : '') + ' · ' + elapsed + 'ms';+ if (status === 402) {+ // The 402 with payment requirements IS the correct x402 response, not a+ // failure — present the challenge as informational, not a red error.+ pgS.status.textContent = label + ' · x402 — paid endpoint, response is the payment challenge';+ pgS.status.className = 'pg-status warn';+ } else if (status === 401) {+ var hint = pgGetKey() ? ' · check your API key' : ' · add an API key above or sign in';+ pgS.status.textContent = label + hint;+ pgS.status.className = 'pg-status err';+ } else {+ pgS.status.textContent = label;+ pgS.status.className = 'pg-status ' + (status >= 200 && status < 300 ? 'ok' : 'err');+ }+ }++ // Server-Sent Events (e.g. /api/chat) stream `data: {type:'chunk',text}` lines.+ // Accumulate the assistant text and render it live instead of dumping raw SSE.+ async function pgRenderStream(res, t0) {+ var reader = res.body.getReader();+ var decoder = new TextDecoder();+ var buf = '', acc = '', raw = '';+ pgS.response.style.display = 'block';+ pgS.respBody.textContent = '';+ pgS.status.textContent = res.status + ' · streaming…';+ pgS.status.className = 'pg-status ok';+ while (true) {+ var step = await reader.read();+ if (step.done) break;+ buf += decoder.decode(step.value, { stream: true });+ var lines = buf.split('\n');+ buf = lines.pop();+ for (var i = 0; i < lines.length; i++) {+ var line = lines[i].trim();+ if (line.indexOf('data:') !== 0) continue;+ var payload = line.slice(5).trim();+ if (!payload || payload === '[DONE]') continue;+ raw += payload + '\n';+ try {+ var evt = JSON.parse(payload);+ var t = evt.text != null ? evt.text : evt.delta;+ if (typeof t === 'string') acc += t;+ } catch (_) {}+ pgS.respBody.textContent = acc || raw;+ }+ }+ var elapsed = Math.round(performance.now() - t0);+ pgS.status.textContent = res.status + ' OK · ' + elapsed + 'ms · streamed';+ pgS.status.className = 'pg-status ok';+ pgS.respBody.textContent = acc || raw || '(empty stream)';+ }+// Send requestpgS.send.addEventListener('click', async function() {if (!pgActive) return;var ep = PG_ENDPOINTS[pgActive];var url = PG_ORIGIN + pgResolvePath(ep);+ var key = pgGetKey();pgS.send.disabled = true;pgS.send.textContent = 'Sending…';@@ -209,27 +302,26 @@var t0 = performance.now();try {- var opts = { method: ep.method, headers: {} };+ var headers = {};+ if (key) headers['Authorization'] = 'Bearer ' + key;+ // credentials: 'include' lets a signed-in browser session authenticate+ // without a key; a pasted key takes precedence via the header above.+ var opts = { method: ep.method, headers: headers, credentials: 'include' };if (ep.sampleBody) {- opts.headers['Content-Type'] = 'application/json';+ headers['Content-Type'] = 'application/json';opts.body = pgS.body.value.trim() || ep.sampleBody;}var res = await fetch(url, opts);- var elapsed = Math.round(performance.now() - t0);- var text = await res.text();-- pgS.status.textContent = res.status + ' ' + res.statusText + ' · ' + elapsed + 'ms';- pgS.status.className = 'pg-status ' + (res.ok ? 'ok' : 'err');-- var display;- try {- var parsed = JSON.parse(text);- display = pgHighlightJson(JSON.stringify(parsed, null, 2));- } catch (_) {- display = text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');+ var contentType = res.headers.get('content-type') || '';++ if (contentType.indexOf('text/event-stream') !== -1 && res.body) {+ await pgRenderStream(res, t0);+ } else {+ var elapsed = Math.round(performance.now() - t0);+ var text = await res.text();+ pgSetStatus(res.status, res.statusText, elapsed);+ pgShowBody(text);}- pgS.respBody.innerHTML = display;- pgS.response.style.display = 'block';} catch (err) {pgS.status.textContent = 'Network error';pgS.status.className = 'pg-status err';diff --git a/src/home-live-token.js b/src/home-live-token.jsnew file mode 100644index 000000000..f17594892--- /dev/null+++ b/src/home-live-token.js@@ -0,0 +1,368 @@+/**+ * Live token card (homepage) — real pump.fun token + live buy/sell flow.+ *+ * Picks an actively-trading bonding-curve coin from pump.fun's trending feed,+ * renders it in the token card, then streams its real trades over SSE+ * (/api/pump/trades-stream). Buys render green, sells red. No sample data:+ * every row is a real on-chain trade. Loading, empty, and error states are all+ * designed.+ *+ * Graduated coins trade on Raydium, not the bonding curve, so PumpPortal emits+ * no trade events for them — we filter them out and pick a live curve coin.+ */++const TRENDING_URL =+ '/api/pump/trending?sort=last_trade_timestamp&order=DESC&limit=40';+const TRENDING_FALLBACK_URL = '/api/pump/trending?limit=40';+const STREAM_URL = (mint) =>+ `/api/pump/trades-stream?mint=${encodeURIComponent(mint)}`;+const MAX_ROWS = 6;+const RECONNECT_DELAY_MS = 2500;++function esc(s) {+ return String(s ?? '').replace(+ /[<>&"]/g,+ (c) => ({ '<': '<', '>': '>', '&': '&', '"': '"' })[c],+ );+}++function shortAddr(a) {+ const s = String(a || '');+ return s.length > 10 ? `${s.slice(0, 4)}…${s.slice(-4)}` : s || 'unknown';+}++function cleanText(s, max) {+ const t = String(s ?? '').trim().replace(/\s+/g, ' ');+ return t.length > max ? `${t.slice(0, max - 1)}…` : t;+}++function solFmt(n) {+ const v = Number(n);+ if (!isFinite(v) || v === 0) return '0 SOL';+ if (v < 0.01) return `${v.toFixed(4)} SOL`;+ if (v < 1) return `${v.toFixed(3)} SOL`;+ return `${v.toFixed(2)} SOL`;+}++function usdFmt(n) {+ const v = Number(n);+ if (!isFinite(v) || v <= 0) return null;+ if (v >= 1_000_000) return `$${(v / 1_000_000).toFixed(1)}M`;+ if (v >= 1_000) return `$${(v / 1_000).toFixed(1)}K`;+ return `$${v.toFixed(0)}`;+}++function relTime(tsMs) {+ const secs = Math.max(0, Math.round((Date.now() - tsMs) / 1000));+ if (secs < 5) return 'just now';+ if (secs < 60) return `${secs}s ago`;+ const mins = Math.round(secs / 60);+ if (mins < 60) return `${mins}m ago`;+ return `${Math.round(mins / 60)}h ago`;+}++class HomeLiveToken {+ constructor(root) {+ this.root = root;+ this.el = {+ label: root.querySelector('#hlt-label'),+ avatar: root.querySelector('#hlt-avatar'),+ name: root.querySelector('#hlt-name'),+ ticker: root.querySelector('#hlt-ticker'),+ price: root.querySelector('#hlt-price'),+ rows: root.querySelector('#hlt-rows'),+ link: root.querySelector('#hlt-pump-link'),+ };+ this.coin = null;+ this.es = null;+ this.trades = []; // { isBuy, sol, usd, trader, ts, sig }+ this.firstMc = null;+ this.lastMc = null;+ this.reconnectTimer = null;+ this.tickTimer = null;+ this.visible = false;+ this.destroyed = false;+ this.started = false;+ this.idleTimer = null;+ }++ async start() {+ if (this.started || this.destroyed) return;+ this.started = true;+ this._renderSkeleton();+ try {+ const coin = await this._pickCoin();+ if (this.destroyed) return;+ if (!coin) {+ this._renderError('Live feed unavailable right now.');+ return;+ }+ this.coin = coin;+ this._renderHeader(coin);+ this._armIdleState();+ this._connect();+ this.tickTimer = setInterval(() => this._refreshTimes(), 4000);+ } catch {+ if (!this.destroyed) this._renderError('Could not reach the live feed.');+ }+ }++ async _pickCoin() {+ const pick = (arr) => {+ const list = Array.isArray(arr) ? arr : arr?.coins || [];+ const live = list.filter(+ (c) => c && c.mint && c.symbol && !c.complete && !c.raydium_pool,+ );+ live.sort(+ (a, b) =>+ (b.last_trade_timestamp || 0) - (a.last_trade_timestamp || 0),+ );+ return live[0] || list.find((c) => c && c.mint && c.symbol) || null;+ };+ const r1 = await fetch(TRENDING_URL, { headers: { accept: 'application/json' } });+ if (r1.ok) {+ const got = pick(await r1.json());+ if (got && !got.complete) return got;+ // Older proxy ignores the sort param and returns graduated whales.+ // Retry the plain list and keep whichever has a live bonding curve.+ const r2 = await fetch(TRENDING_FALLBACK_URL, {+ headers: { accept: 'application/json' },+ });+ if (r2.ok) {+ const alt = pick(await r2.json());+ if (alt) return alt;+ }+ return got;+ }+ return null;+ }++ // ── Connection ────────────────────────────────────────────────────────────++ _connect() {+ if (this.destroyed || !this.coin || !this.visible) return;+ this._teardownStream();+ const es = new EventSource(STREAM_URL(this.coin.mint));+ this.es = es;+ es.addEventListener('trade', (e) => {+ try {+ this._onTrade(JSON.parse(e.data));+ } catch {+ /* malformed frame — skip */+ }+ });+ es.addEventListener('close', () => this._scheduleReconnect());+ es.onerror = () => {+ // EventSource auto-retries, but the server caps stream duration; force a+ // clean reconnect so we don't sit on a dead socket.+ this._scheduleReconnect();+ };+ }++ _scheduleReconnect() {+ this._teardownStream();+ if (this.destroyed || !this.visible) return;+ clearTimeout(this.reconnectTimer);+ this.reconnectTimer = setTimeout(() => this._connect(), RECONNECT_DELAY_MS);+ }++ _teardownStream() {+ if (this.es) {+ try {+ this.es.close();+ } catch {+ /* already closed */+ }+ this.es = null;+ }+ clearTimeout(this.reconnectTimer);+ }++ _onTrade(d) {+ if (this.destroyed) return;+ const sol =+ typeof d.sol_amount === 'number'+ ? d.sol_amount+ : typeof d.solAmount === 'number'+ ? d.solAmount+ : 0;+ if (sol <= 0) return;+ const isBuy = d.is_buy === true || d.txType === 'buy' || d.tx_type === 'buy';+ const mc = typeof d.market_cap_usd === 'number' ? d.market_cap_usd : null;+ if (mc) {+ if (this.firstMc == null) this.firstMc = mc;+ this.lastMc = mc;+ }+ this.trades.unshift({+ isBuy,+ sol,+ usd: typeof d.sol_value_usd === 'number' ? d.sol_value_usd : null,+ trader: d.trader || d.traderPublicKey || '',+ ts: Date.now(),+ sig: d.signature || d.tx_signature || '',+ });+ if (this.trades.length > MAX_ROWS) this.trades.length = MAX_ROWS;+ clearTimeout(this.idleTimer);+ this._renderRows();+ this._renderPrice();+ }++ // ── Rendering ───────────────────────────────────────────────────────────────++ _renderSkeleton() {+ if (!this.el.rows) return;+ this.el.rows.innerHTML = Array.from({ length: 4 })+ .map(+ () =>+ `<div class="earn-row hlt-skel">+ <div class="earn-row-left">+ <div class="hlt-skel-bar" style="width:120px"></div>+ <div class="hlt-skel-bar" style="width:54px;height:9px"></div>+ </div>+ <div class="hlt-skel-bar" style="width:64px"></div>+ </div>`,+ )+ .join('');+ }++ _renderHeader(coin) {+ const name = cleanText(coin.name || coin.symbol, 28);+ const sym = cleanText(coin.symbol, 10).replace(/^\$/, '');+ if (this.el.label) this.el.label.textContent = `Live token · $${sym} / SOL`;+ if (this.el.name) this.el.name.textContent = name;+ const mc = usdFmt(coin.usd_market_cap);+ if (this.el.ticker)+ this.el.ticker.textContent = mc+ ? `$${sym} · ${mc} MC · Pump.fun`+ : `$${sym} · Pump.fun`;+ if (this.el.avatar) {+ const img = coin.image_uri;+ if (img) {+ this.el.avatar.innerHTML = '';+ this.el.avatar.style.background = '#111';+ const im = new Image();+ im.src = img;+ im.alt = name;+ im.loading = 'lazy';+ im.decoding = 'async';+ im.referrerPolicy = 'no-referrer';+ im.onerror = () => {+ this.el.avatar.textContent = sym.slice(0, 4);+ };+ this.el.avatar.appendChild(im);+ } else {+ this.el.avatar.textContent = sym.slice(0, 4);+ }+ }+ if (this.el.link) {+ this.el.link.href = `https://pump.fun/coin/${coin.mint}`;+ this.el.link.title = `View $${sym} on pump.fun`;+ }+ this._renderPrice();+ }++ _renderPrice() {+ const p = this.el.price;+ if (!p) return;+ if (this.firstMc != null && this.lastMc != null && this.firstMc > 0) {+ const pct = ((this.lastMc - this.firstMc) / this.firstMc) * 100;+ const up = pct >= 0;+ p.textContent = `${up ? '+' : ''}${pct.toFixed(1)}%`;+ p.className = `token-price ${up ? 'up' : 'down'}`;+ p.title = 'Change since this card started streaming';+ } else {+ const mc = usdFmt(this.coin?.usd_market_cap);+ p.textContent = mc ? `${mc} MC` : 'Live';+ p.className = 'token-price';+ }+ }++ _renderRows() {+ if (!this.el.rows) return;+ if (!this.trades.length) {+ this._armIdleState();+ return;+ }+ this.el.rows.innerHTML = this.trades+ .map((t) => {+ const sign = t.isBuy ? '+' : '−';+ const amt = `${sign}${solFmt(t.sol)}`;+ const usd = usdFmt(t.usd);+ return `<div class="earn-row hlt-row">+ <div class="earn-row-left">+ <div class="earn-row-name">+ <span class="hlt-side ${t.isBuy ? 'buy' : 'sell'}">${t.isBuy ? 'Buy' : 'Sell'}</span>+ · ${esc(shortAddr(t.trader))}+ </div>+ <div class="earn-row-time">${esc(relTime(t.ts))}</div>+ </div>+ <div class="earn-row-amount ${t.isBuy ? 'buy' : 'sell'}">${esc(amt)}${+ usd ? `<span class="hlt-usd">${esc(usd)}</span>` : ''+ }</div>+ </div>`;+ })+ .join('');+ }++ _armIdleState() {+ if (!this.el.rows || this.trades.length) return;+ const sym = cleanText(this.coin?.symbol || '', 10).replace(/^\$/, '');+ this.el.rows.innerHTML = `<div class="earn-row hlt-idle">+ <div class="earn-row-left">+ <div class="earn-row-name"><span class="hlt-live-dot"></span>Listening for live trades${+ sym ? ` on $${esc(sym)}` : ''+ }…</div>+ <div class="earn-row-time">streaming from pump.fun</div>+ </div>+ </div>`;+ }++ _renderError(msg) {+ if (this.el.rows)+ this.el.rows.innerHTML = `<div class="earn-row hlt-idle">+ <div class="earn-row-left">+ <div class="earn-row-name">${esc(msg)}</div>+ <div class="earn-row-time">Trending tokens are still one click away below.</div>+ </div>+ </div>`;+ }++ _refreshTimes() {+ if (!this.el.rows || !this.trades.length) return;+ this.el.rows.querySelectorAll('.hlt-row .earn-row-time').forEach((el, i) => {+ if (this.trades[i]) el.textContent = relTime(this.trades[i].ts);+ });+ }++ // ── Lifecycle ────────────────────────────────────────────────────────────────++ setVisible(v) {+ if (v === this.visible) return;+ this.visible = v;+ if (v) {+ if (!this.started) this.start();+ else if (!this.es) this._connect();+ } else {+ this._teardownStream();+ }+ }++ destroy() {+ this.destroyed = true;+ this._teardownStream();+ clearInterval(this.tickTimer);+ clearTimeout(this.idleTimer);+ }+}++export function initHomeLiveToken(root) {+ if (!root) return null;+ const card = new HomeLiveToken(root);+ const io = new IntersectionObserver(+ (entries) => card.setVisible(entries[0]?.isIntersecting === true),+ { rootMargin: '120px' },+ );+ io.observe(root);+ window.addEventListener('pagehide', () => card.destroy(), { once: true });+ return card;+}diff --git a/src/pump/homepage-launcher.js b/src/pump/homepage-launcher.jsnew file mode 100644index 000000000..2d81fdaaf--- /dev/null+++ b/src/pump/homepage-launcher.js@@ -0,0 +1,329 @@+/**+ * Homepage token launcher — wires "Launch yours" to the real pump.fun launch+ * flow without leaving the homepage.+ *+ * Flow:+ * - Resolve the signed-in user's agents (GET /api/agents).+ * - Signed out → prompt to sign in.+ * - Signed in, 0 agents → prompt to create an agent.+ * - Signed in, ≥1 agent → pick an agent, then open the real LaunchTokenModal+ * (deploy-on-Solana step included when needed).+ *+ * No mock launches: every path lands in the production launch pipeline+ * (/api/agents/tokens/launch-prep → wallet sign → launch-confirm).+ */++const AGENTS_URL = '/api/agents';++function esc(s) {+ return String(s ?? '').replace(+ /[<>&"]/g,+ (c) => ({ '<': '<', '>': '>', '&': '&', '"': '"' })[c],+ );+}++function ensureModalCss() {+ if (document.querySelector('link[data-ltm-css]')) return;+ const link = document.createElement('link');+ link.rel = 'stylesheet';+ link.href = '/src/pump/launch-token-modal.css';+ link.setAttribute('data-ltm-css', '');+ document.head.appendChild(link);+}++function ensurePickerCss() {+ if (document.getElementById('hpl-styles')) return;+ const style = document.createElement('style');+ style.id = 'hpl-styles';+ style.textContent = `+ .hpl-intro { font-size: .86rem; color: rgba(255,255,255,.6); line-height: 1.5; }+ .hpl-list { display: flex; flex-direction: column; gap: .5rem; }+ .hpl-item {+ display: flex; align-items: center; gap: .75rem; width: 100%;+ padding: .65rem .7rem; border-radius: 10px; text-align: left;+ background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);+ color: #e5e5e5; font: inherit; cursor: pointer;+ transition: background .15s, border-color .15s, transform .12s;+ }+ .hpl-item:hover:not(:disabled) { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.18); }+ .hpl-item:active:not(:disabled) { transform: scale(.99); }+ .hpl-item:focus-visible { outline: 2px solid rgba(120,200,140,.7); outline-offset: 2px; }+ .hpl-item:disabled { cursor: default; opacity: .85; }+ .hpl-ava {+ width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; overflow: hidden;+ display: flex; align-items: center; justify-content: center;+ background: linear-gradient(135deg,#2a2a3a,#15151f);+ font: 600 12px var(--font-mono, monospace); color: #fff;+ }+ .hpl-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }+ .hpl-meta { flex: 1; min-width: 0; }+ .hpl-name { font-size: .9rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .hpl-sub { font-size: .68rem; color: rgba(255,255,255,.4); margin-top: 1px; }+ .hpl-pill {+ flex-shrink: 0; font: 600 .62rem/1 var(--font-mono, monospace);+ letter-spacing: .04em; text-transform: uppercase;+ padding: .32rem .5rem; border-radius: 99px; white-space: nowrap;+ }+ .hpl-pill.ready { background: rgba(120,200,140,.16); color: #5fd08a; }+ .hpl-pill.deploy { background: rgba(255,255,255,.08); color: rgba(255,255,255,.7); }+ .hpl-pill.live { background: rgba(120,200,140,.16); color: #5fd08a; }+ .hpl-empty { text-align: center; padding: .5rem 0 .25rem; }+ .hpl-empty-emoji { font-size: 2rem; }+ .hpl-empty-title { font-size: .95rem; font-weight: 600; color: #fff; margin: .5rem 0 .3rem; }+ .hpl-empty-sub { font-size: .8rem; color: rgba(255,255,255,.55); line-height: 1.5; }+ .hpl-spinner {+ width: 14px; height: 14px; border-radius: 50%; display: inline-block;+ border: 2px solid rgba(255,255,255,.2); border-top-color: rgba(255,255,255,.7);+ animation: hpl-spin .8s linear infinite; vertical-align: -2px; margin-right: .4rem;+ }+ @keyframes hpl-spin { to { transform: rotate(360deg); } }+ `;+ document.head.appendChild(style);+}++class LaunchPicker {+ constructor() {+ this.overlay = null;+ this.keyHandler = null;+ }++ open() {+ ensureModalCss();+ ensurePickerCss();+ if (this.overlay) return;+ const el = document.createElement('div');+ el.className = 'ltm-overlay';+ document.body.appendChild(el);+ this.overlay = el;+ el.addEventListener('click', (e) => {+ if (e.target === el) this.close();+ });+ this.keyHandler = (e) => {+ if (e.key === 'Escape') this.close();+ };+ window.addEventListener('keydown', this.keyHandler);+ requestAnimationFrame(() => el.classList.add('ltm-open'));+ this._renderLoading();+ this._load();+ }++ close() {+ if (!this.overlay) return;+ this.overlay.classList.remove('ltm-open');+ const el = this.overlay;+ this.overlay = null;+ setTimeout(() => el.remove(), 200);+ if (this.keyHandler) {+ window.removeEventListener('keydown', this.keyHandler);+ this.keyHandler = null;+ }+ }++ _shell(title, body, footer) {+ return `+ <div class="ltm-modal" role="dialog" aria-modal="true" aria-label="Launch a token">+ <div class="ltm-header">+ <span class="ltm-title">${esc(title)}</span>+ <div class="ltm-header-right">+ <button class="ltm-close" aria-label="Close">×</button>+ </div>+ </div>+ <div class="ltm-body">${body}</div>+ <div class="ltm-footer">${footer}</div>+ </div>`;+ }++ _paint(html) {+ if (!this.overlay) return;+ this.overlay.innerHTML = html;+ this.overlay.querySelector('.ltm-close')?.addEventListener('click', () => this.close());+ }++ _renderLoading() {+ this._paint(+ this._shell(+ 'Launch a token',+ `<div class="hpl-intro"><span class="hpl-spinner"></span>Loading your agents…</div>`,+ `<div></div><button class="ltm-btn" id="hpl-cancel">Cancel</button>`,+ ),+ );+ this.overlay.querySelector('#hpl-cancel')?.addEventListener('click', () => this.close());+ }++ async _load() {+ let resp;+ try {+ resp = await fetch(AGENTS_URL, { credentials: 'include', headers: { accept: 'application/json' } });+ } catch {+ this._renderError();+ return;+ }+ if (resp.status === 401) {+ this._renderSignedOut();+ return;+ }+ if (!resp.ok) {+ this._renderError();+ return;+ }+ let agents = [];+ try {+ const data = await resp.json();+ agents = Array.isArray(data?.agents) ? data.agents : [];+ } catch {+ this._renderError();+ return;+ }+ if (!agents.length) {+ this._renderNoAgents();+ return;+ }+ this._renderPicker(agents);+ }++ _renderSignedOut() {+ this._paint(+ this._shell(+ 'Launch your agent’s token',+ `<div class="hpl-empty">+ <div class="hpl-empty-emoji">🚀</div>+ <div class="hpl-empty-title">Sign in to launch on pump.fun</div>+ <div class="hpl-empty-sub">+ Tie a real Solana token to your 3D agent — name, ticker, and image set+ from your avatar. You'll sign the launch in your own wallet.+ </div>+ </div>`,+ `<button class="ltm-btn" id="hpl-cancel">Cancel</button>+ <a class="ltm-btn ltm-btn-primary" href="/login?next=/create">Sign in →</a>`,+ ),+ );+ this.overlay.querySelector('#hpl-cancel')?.addEventListener('click', () => this.close());+ }++ _renderNoAgents() {+ this._paint(+ this._shell(+ 'Create an agent first',+ `<div class="hpl-empty">+ <div class="hpl-empty-emoji">🎭</div>+ <div class="hpl-empty-title">Every token starts with an avatar</div>+ <div class="hpl-empty-sub">+ Create a 3D agent in under a minute — drop a selfie or pick a model —+ then launch its token straight from here.+ </div>+ </div>`,+ `<button class="ltm-btn" id="hpl-cancel">Cancel</button>+ <a class="ltm-btn ltm-btn-primary" href="/create">Create an agent →</a>`,+ ),+ );+ this.overlay.querySelector('#hpl-cancel')?.addEventListener('click', () => this.close());+ }++ _renderError() {+ this._paint(+ this._shell(+ 'Launch a token',+ `<div class="hpl-empty">+ <div class="hpl-empty-emoji">⚠️</div>+ <div class="hpl-empty-title">Couldn't load your agents</div>+ <div class="hpl-empty-sub">Check your connection and try again.</div>+ </div>`,+ `<button class="ltm-btn" id="hpl-cancel">Close</button>+ <button class="ltm-btn ltm-btn-primary" id="hpl-retry">Retry</button>`,+ ),+ );+ this.overlay.querySelector('#hpl-cancel')?.addEventListener('click', () => this.close());+ this.overlay.querySelector('#hpl-retry')?.addEventListener('click', () => {+ this._renderLoading();+ this._load();+ });+ }++ _renderPicker(agents) {+ const rows = agents+ .map((a, i) => {+ const launched = !!a.token?.mint;+ const deployed = a.onchain?.family === 'solana';+ const sym = a.token?.symbol ? `$${esc(a.token.symbol)}` : '';+ const initials = esc(String(a.name || 'A').trim().slice(0, 2).toUpperCase());+ const thumb = a.avatar_thumbnail_url;+ const ava = thumb+ ? `<span class="hpl-ava"><img src="${esc(thumb)}" alt="" loading="lazy" referrerpolicy="no-referrer"></span>`+ : `<span class="hpl-ava">${initials}</span>`;+ let pill;+ let sub;+ if (launched) {+ pill = `<span class="hpl-pill live">Live ${sym}</span>`;+ sub = 'Token already launched — view on pump.fun';+ } else if (deployed) {+ pill = `<span class="hpl-pill ready">Ready</span>`;+ sub = 'Deployed on Solana · launch its token';+ } else {+ pill = `<span class="hpl-pill deploy">Deploy + launch</span>`;+ sub = 'Deploys on Solana, then launches the token';+ }+ return `<button class="hpl-item" data-i="${i}" ${launched ? 'data-launched="1"' : ''}>+ ${ava}+ <span class="hpl-meta">+ <span class="hpl-name">${esc(a.name || 'Untitled agent')}</span>+ <span class="hpl-sub">${sub}</span>+ </span>+ ${pill}+ </button>`;+ })+ .join('');++ this._paint(+ this._shell(+ 'Choose an agent to tokenize',+ `<div class="hpl-intro">Launch a real pump.fun token tied to your agent. You'll sign every transaction in your own wallet.</div>+ <div class="hpl-list">${rows}</div>`,+ `<a class="ltm-btn" href="/create">+ New agent</a>+ <button class="ltm-btn ltm-btn-primary" id="hpl-cancel">Done</button>`,+ ),+ );+ this.overlay.querySelector('#hpl-cancel')?.addEventListener('click', () => this.close());+ this.overlay.querySelectorAll('.hpl-item').forEach((btn) => {+ btn.addEventListener('click', () => {+ const a = agents[Number(btn.dataset.i)];+ if (!a) return;+ if (a.token?.mint) {+ window.open(`https://pump.fun/coin/${a.token.mint}`, '_blank', 'noopener');+ return;+ }+ this._launch(a);+ });+ });+ }++ async _launch(agent) {+ const { openLaunchTokenModal } = await import('/src/pump/launch-token-modal.js');+ const onchain = agent.onchain || agent.meta?.onchain || null;+ const needsDeploy = !onchain || onchain.family !== 'solana';+ const imageUrl = agent.avatar_thumbnail_url || agent.meta?.thumbnail_url || '';+ this.close();+ openLaunchTokenModal({+ agentId: agent.id,+ agentName: agent.name || 'Agent',+ imageUrl,+ needsDeploy,+ agentForDeploy: needsDeploy+ ? {+ id: agent.id,+ name: agent.name || 'Agent',+ description: agent.description || '',+ avatar_id: agent.avatar_id || null,+ skills: agent.skills || undefined,+ }+ : null,+ });+ }+}++export function initHomepageLauncher(button) {+ if (!button) return;+ button.addEventListener('click', (e) => {+ e.preventDefault();+ new LaunchPicker().open();+ });+}diff --git a/src/walk-embed-preview.js b/src/walk-embed-preview.jsindex 0fe58fcff..db0f01307 100644--- a/src/walk-embed-preview.js+++ b/src/walk-embed-preview.js@@ -269,7 +269,21 @@ export function initWalkPreview(container) {blobShadow.material.opacity = 0.6;animationManager.attach(model);- await animationManager.loadAll(ANIMATIONS_MANIFEST_URL);++ // Fetch the clip manifest, register only the clips this preview plays+ // (idle + walk), then load them. loadAll() iterates the registered defs —+ // it does NOT take a manifest URL, so the defs must be set first or no+ // animation ever loads and the avatar renders frozen in its bind pose.+ const manifest = await fetch(ANIMATIONS_MANIFEST_URL, { cache: 'force-cache' })+ .then((r) => {+ if (!r.ok) throw new Error(`HTTP ${r.status} fetching animation manifest`);+ return r.json();+ });+ const needed = manifest.filter((d) => d.name === CLIP_IDLE || d.name === CLIP_WALK);+ if (needed.length === 0) throw new Error('Animation manifest missing idle/walk clips');+ animationManager.setAnimationDefs(needed);+ await animationManager.loadAll();+animationManager.play(CLIP_IDLE);applyCameraImmediate();diff --git a/vite.config.js b/vite.config.jsindex 1e2676529..c1e0918e4 100644--- a/vite.config.js+++ b/vite.config.js@@ -373,13 +373,20 @@ const appConfig = {},},},- // Polyfill the Node `buffer` and `process` globals so @solana/web3.js- // (and any other dep that does `import { Buffer } from 'buffer'`) works- // in the browser without the "Module 'buffer' has been externalized"- // console warning. Scoped to these two — we don't blanket-polyfill all- // Node builtins because most pages don't need them.+ // Polyfill the Node `process` global so @solana/web3.js (and any other dep+ // that touches `process`) works in the browser without the "Module has+ // been externalized" console warning. Scoped narrowly — we don't blanket-+ // polyfill all Node builtins because most pages don't need them.+ //+ // `buffer` is intentionally NOT in `include`: the plugin would alias it to+ // an ESM shim with named exports only, but Vite's dep-optimizer rewrites+ // named buffer imports into a CJS-interop *default* import, which then+ // fails to link ("buffer.js does not provide an export named 'default'").+ // Instead resolve.alias points `buffer` at the real CJS package (which+ // prebundles with both default and named) and `globals.Buffer` still+ // injects the global from it.nodePolyfills({- include: ['buffer', 'process'],+ include: ['process'],globals: { Buffer: true, process: true, global: true },protocolImports: true,}),