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: enhance pumpfun feed with enriched graduation events and gesture animations
nirholas0c512f3bb4c5
diff --git a/api/_lib/pumpfun-ws-feed.js b/api/_lib/pumpfun-ws-feed.jsindex bba1549b8..c241c4770 100644--- a/api/_lib/pumpfun-ws-feed.js+++ b/api/_lib/pumpfun-ws-feed.js@@ -97,7 +97,11 @@ export function connectPumpFunFeed({ onEvent, signal, kind = 'all' }) {if (active) onEvent({ kind: 'mint', data: normalizeMint(msg, null, 0) });});} else if ((msg.txType === 'migrate' || msg.txType === 'migration') && (kind === 'all' || kind === 'graduation')) {- onEvent({ kind: 'graduation', data: normalizeGrad(msg) });+ enrichGrad(msg).then((data) => {+ if (active) onEvent({ kind: 'graduation', data });+ }).catch(() => {+ if (active) onEvent({ kind: 'graduation', data: normalizeGrad(msg) });+ });}});@@ -153,5 +157,138 @@ function normalizeGrad(d) {name: d.name,symbol: d.symbol,pool: d.pool,+ timestamp: Math.floor(Date.now() / 1000),+ };+}++// ── graduation enrichment ────────────────────────────────────────────────────+//+// PumpPortal's migration message only carries {signature, mint, name, symbol,+// pool}. To render a rich card matching the desired feed format we resolve:+// - coin metadata: usd_market_cap, market_cap_at_launch, created_timestamp,+// description, creator from pump.fun's frontend coin endpoint+// - creator history: total launches + best-token by market cap by listing+// the creator's coins+// A short pump.fun coin TTL cache prevents hammering the endpoint when a+// migration shows up multiple times across reconnects, and per-fetch timeouts+// keep stalls bounded so a slow upstream can't pin the SSE worker.++const PUMPFUN_COIN_API = 'https://frontend-api-v3.pump.fun/coins';+const PUMPFUN_USER_COINS_API = 'https://frontend-api-v3.pump.fun/coins/user-created-coins';+const ENRICH_TIMEOUT_MS = 2_500;+const COIN_CACHE_TTL_MS = 30_000;+const _coinCache = new Map();+const _creatorCache = new Map();++async function fetchJsonWithTimeout(url, ms = ENRICH_TIMEOUT_MS) {+ const ctrl = new AbortController();+ const tid = setTimeout(() => ctrl.abort(), ms);+ try {+ const r = await fetch(url, {+ signal: ctrl.signal,+ headers: { 'accept': 'application/json', 'user-agent': 'three.ws-pumpfun-feed/1' },+ });+ if (!r.ok) return null;+ return await r.json();+ } catch { return null; } finally { clearTimeout(tid); }+}++async function fetchCoin(mint) {+ const hit = _coinCache.get(mint);+ if (hit && Date.now() - hit.t < COIN_CACHE_TTL_MS) return hit.v;+ const v = await fetchJsonWithTimeout(`${PUMPFUN_COIN_API}/${encodeURIComponent(mint)}`);+ if (_coinCache.size > 500) _coinCache.clear();+ _coinCache.set(mint, { t: Date.now(), v });+ return v;+}++async function fetchCreatorCoins(creator) {+ if (!creator) return null;+ const hit = _creatorCache.get(creator);+ if (hit && Date.now() - hit.t < COIN_CACHE_TTL_MS) return hit.v;+ const v = await fetchJsonWithTimeout(+ `${PUMPFUN_USER_COINS_API}/${encodeURIComponent(creator)}?offset=0&limit=50&includeNsfw=true`,+ );+ if (_creatorCache.size > 500) _creatorCache.clear();+ _creatorCache.set(creator, { t: Date.now(), v });+ return v;+}++function formatAge(createdAtMs) {+ if (!createdAtMs) return '';+ const s = Math.max(0, Math.floor((Date.now() - createdAtMs) / 1000));+ if (s < 60) return s + 's';+ const m = Math.floor(s / 60);+ if (m < 60) return m + 'm';+ const h = Math.floor(m / 60);+ if (h < 24) return h + 'h';+ return Math.floor(h / 24) + 'd';+}++async function enrichGrad(d) {+ const base = normalizeGrad(d);+ const mint = d.mint;+ if (!mint) return base;++ const [solPrice, coin] = await Promise.all([+ getSolPrice(),+ fetchCoin(mint),+ ]);++ if (!coin) return base;++ const creator = coin.creator || d.traderPublicKey || null;+ const userCoins = creator ? await fetchCreatorCoins(creator) : null;++ const usdMc = typeof coin.usd_market_cap === 'number' ? coin.usd_market_cap : null;+ const launchSol = typeof coin.market_cap_at_launch === 'number' ? coin.market_cap_at_launch : null;+ const launchUsd = launchSol != null && solPrice > 0 ? launchSol * solPrice : null;++ const createdMs = coin.created_timestamp ? Number(coin.created_timestamp) : null;+ const age = formatAge(createdMs);++ let creatorTokens = [];+ let launches = null;+ if (Array.isArray(userCoins)) {+ launches = userCoins.length;+ creatorTokens = userCoins+ .map((c) => ({+ mint: c.mint,+ symbol: c.symbol,+ name: c.name,+ mc: typeof c.usd_market_cap === 'number'+ ? c.usd_market_cap+ : (typeof c.market_cap === 'number' && solPrice > 0 ? c.market_cap * solPrice : null),+ }))+ .filter((c) => c.symbol);+ }++ const amountSol = typeof d.solAmount === 'number' ? d.solAmount+ : typeof coin.virtual_sol_reserves === 'number' && coin.virtual_sol_reserves > 0+ ? coin.virtual_sol_reserves / 1e9+ : null;+ const amountUsd = amountSol != null && solPrice > 0 ? amountSol * solPrice : null;++ return {+ ...base,+ name: coin.name || base.name,+ symbol: coin.symbol || base.symbol,+ description: coin.description || null,+ creator,+ image_uri: coin.image_uri || null,+ twitter: coin.twitter || null,+ telegram: coin.telegram || null,+ website: coin.website || null,+ usd_market_cap: usdMc,+ market_cap: usdMc,+ market_cap_usd_initial: launchUsd,+ market_cap_at_launch: launchSol,+ sol_price: solPrice || null,+ created_at: createdMs ? Math.floor(createdMs / 1000) : null,+ age,+ amount_sol: amountSol,+ amount_usd: amountUsd,+ creator_launches: launches,+ creator_tokens: creatorTokens,};}diff --git a/src/agent-avatar.js b/src/agent-avatar.jsindex e0977c8b8..94838f1c0 100644--- a/src/agent-avatar.js+++ b/src/agent-avatar.js@@ -21,7 +21,7 @@import { ACTION_TYPES } from './agent-protocol.js';import { Vector3, Box3, MathUtils, PositionalAudio } from 'three';-import { resolveSlot, DEFAULT_ANIMATION_MAP, SLOTS } from './runtime/animation-slots.js';+import { resolveSlot, DEFAULT_ANIMATION_MAP } from './runtime/animation-slots.js';import { ElevenLabsTTS } from './runtime/speech.js';import { LipSyncAnalyser } from './lip-sync-analyser.js';// BEGIN:IDLE_LOOP_IMPORT@@ -469,11 +469,7 @@ export class AgentAvatar {_onGesture(action) {const name = action.payload?.name || 'nod';const duration = (action.payload?.duration || 1500) / 1000;- if (SLOTS.includes(name)) {- this._playSlot(name, duration);- } else {- this._triggerOneShot(name, duration);- }+ this._playSlot(name, duration);}_onEmote(action) {diff --git a/src/widgets/pumpfun-feed.js b/src/widgets/pumpfun-feed.jsindex 6d425e333..fcbe2d863 100644--- a/src/widgets/pumpfun-feed.js+++ b/src/widgets/pumpfun-feed.js@@ -396,6 +396,9 @@ function narrateClaim(protocol, ev) {if (!protocol) return;if (ev.first_time_claim) {protocol.emit({ type: 'emote', payload: { trigger: 'celebration', weight: 0.9 } });+ // First GitHub-linked claim → silly hip-hop dance+ const danceClip = ev.github_user ? 'silly' : 'celebrate';+ protocol.emit({ type: 'gesture', payload: { name: danceClip, duration: 4000 } });protocol.emit({type: 'speak',payload: {@@ -405,19 +408,25 @@ function narrateClaim(protocol, ev) {});} else if (ev.fake_claim) {protocol.emit({ type: 'emote', payload: { trigger: 'concern', weight: 0.7 } });+ protocol.emit({ type: 'gesture', payload: { name: 'shake', duration: 1500 } });protocol.emit({type: 'speak',payload: { text: `Fake claim from ${ev.github_user || ev.claimer}.`, sentiment: -0.5 },});- } else if (ev.tier === 'mega' || ev.tier === 'influencer') {+ } else if (ev.tier === 'mega') {+ protocol.emit({ type: 'emote', payload: { trigger: 'celebration', weight: 0.7 } });+ protocol.emit({ type: 'gesture', payload: { name: 'thriller', duration: 5000 } });+ } else if (ev.tier === 'influencer') {protocol.emit({ type: 'emote', payload: { trigger: 'curiosity', weight: 0.5 } });+ protocol.emit({ type: 'gesture', payload: { name: 'taunt', duration: 2500 } });}}function narrateGraduation(protocol, ev) {if (!protocol) return;protocol.emit({ type: 'emote', payload: { trigger: 'celebration', weight: 0.9 } });- protocol.emit({ type: 'gesture', payload: { name: 'dance', duration: 5000 } });+ // Graduation = the big one → rumba+ protocol.emit({ type: 'gesture', payload: { name: 'rumba', duration: 6000 } });protocol.emit({type: 'speak',payload: { text: `Migration: ${ev.symbol || ev.name || 'a token'} bonded to PumpAMM.`, sentiment: 0.6 },