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: jupiter price fallback for graduated tokens, avatar auto-agent, start-fresh nav
nirholas59e037830365
diff --git a/api/_lib/solana/sdk-bridge.js b/api/_lib/solana/sdk-bridge.jsindex abc4e98bc..86627c46c 100644--- a/api/_lib/solana/sdk-bridge.js+++ b/api/_lib/solana/sdk-bridge.js@@ -47,7 +47,9 @@ export async function getTokenPrice(connection, mint) {const { global, feeConfig, bondingCurve, mintSupply } = await fetchState(connection, pk);return sdkGetTokenPrice({ global, feeConfig, mintSupply, bondingCurve });} catch (err) {- console.warn('[sdk-bridge] getTokenPrice failed: %s', String(err).slice(0, 120));+ if (!err?.graduated) {+ console.warn('[sdk-bridge] getTokenPrice failed: %s', String(err).slice(0, 120));+ }return null;}}diff --git a/api/avatars/index.js b/api/avatars/index.jsindex 417da99b1..fae243da6 100644--- a/api/avatars/index.js+++ b/api/avatars/index.js@@ -116,20 +116,14 @@ async function handleCreate(req, res) {`;}- // Auto-link selfie-derived avatars to the user's primary agent if it has no avatar yet.- // Fire-and-forget — if this UPDATE fails, the 201 still returns.- const providerHint = body.source_meta && typeof body.source_meta === 'object'- ? String(body.source_meta.provider || '').toLowerCase()- : '';- const autoLink = body.source === 'avaturn'- || body.source === 'readyplayer'- || providerHint === 'readyplayer'- || providerHint === 'readyplayerme'- || providerHint === 'avaturn';- if (autoLink && auth.source === 'session') {+ // Every new avatar gets an agent. Skip if this is a re-upload of an existing avatar+ // (parent_avatar_id set) — the re-point above already handled that case.+ // Fire-and-forget — 201 returns regardless.+ if (!body.parent_avatar_id) {queueMicrotask(async () => {try {- await sql`+ // First try to claim an existing agent that has no avatar yet.+ const linked = await sql`WITH agent_to_update AS (SELECT id FROM agent_identitiesWHERE user_id = ${auth.userId}@@ -139,12 +133,27 @@ async function handleCreate(req, res) {LIMIT 1)UPDATE agent_identities- SET avatar_id = ${avatar.id}+ SET avatar_id = ${avatar.id}, updated_at = NOW()FROM agent_to_updateWHERE agent_identities.id = agent_to_update.id+ RETURNING agent_identities.id`;+ // No existing agent to claim — create a default one.+ if (!linked.length) {+ await sql`+ INSERT INTO agent_identities (user_id, name, avatar_id, is_public, created_at, updated_at)+ VALUES (+ ${auth.userId},+ ${avatar.name || 'My Agent'},+ ${avatar.id},+ false,+ NOW(),+ NOW()+ )+ `;+ }} catch (err) {- console.error('[avatars] auto-link to agent_identities failed', {+ console.error('[avatars] auto-agent failed', {avatarId: avatar.id,userId: auth.userId,error: err?.message,diff --git a/api/pump/curve.js b/api/pump/curve.jsindex d0edde1c7..79de8f814 100644--- a/api/pump/curve.js+++ b/api/pump/curve.js@@ -12,6 +12,19 @@import { cors, json, method, wrap, error } from '../_lib/http.js';import { rpcFallbackFromEnv, getBondingCurveState, getTokenPrice, getGraduationProgress } from '../_lib/solana/index.js';+async function jupiterPriceFallback(mint) {+ try {+ const r = await fetch(`https://lite-api.jup.ag/price/v3?ids=${mint}`);+ if (!r.ok) return null;+ const data = await r.json();+ const usd = data?.[mint]?.usdPrice ?? data?.[mint]?.price;+ const n = Number(usd);+ return Number.isFinite(n) && n > 0 ? { priceUsd: n, source: 'jupiter' } : null;+ } catch {+ return null;+ }+}+function readMint(req) {try {const u = new URL(req.url, 'http://x');@@ -51,13 +64,21 @@ export default wrap(async (req, res) => {return error(res, 404, 'no_curve', 'no bonding curve found for that mint');}+ // Graduated coins have no bonding-curve price. Fall back to Jupiter so callers+ // always get a usable price even after migration to a DEX.+ let pricePayload = result.price ? serializeBNs(result.price) : null;+ let graduatedPrice = null;+ if (!pricePayload && result.curve?.complete) {+ graduatedPrice = await jupiterPriceFallback(mint);+ }+return json(res, 200, {mint,network,- ...result,- // price/graduation values from the SDK contain BNs — stringify them for JSON wire safety- price: result.price ? serializeBNs(result.price) : null,+ curve: result.curve,+ price: pricePayload,graduation: result.graduation ? serializeBNs(result.graduation) : null,+ ...(graduatedPrice ? { graduatedPrice } : {}),}, { 'cache-control': 'public, max-age=5, s-maxage=10, stale-while-revalidate=30' });});diff --git a/src/start.js b/src/start.jsindex e1344358d..ac34a1260 100644--- a/src/start.js+++ b/src/start.js@@ -119,8 +119,14 @@ function initState() {const templatesScreen = document.getElementById('templates-screen');const wizardEl = document.getElementById('wizard');+const startFreshBtn = document.getElementById('btn-start-fresh');++function showWizard({ fromTemplate = false } = {}) {+ // Show "← Templates" button only when the gallery was bypassed (stale state).+ // When triggered by a template card click, the gallery is already visible so+ // no need to offer a way back.+ if (startFreshBtn) startFreshBtn.style.display = fromTemplate ? 'none' : '';-function showWizard() {if (templatesScreen) {templatesScreen.classList.add('tpl-exit');setTimeout(() => {@@ -136,6 +142,13 @@ function showWizard() {}}+if (startFreshBtn) {+ startFreshBtn.addEventListener('click', () => {+ try { sessionStorage.removeItem(STORAGE_KEY); } catch {}+ location.reload();+ });+}+function applyTemplate(tpl) {state.description = tpl.bio;state.enabledSkills = [...tpl.skills];@@ -144,7 +157,7 @@ function applyTemplate(tpl) {// Jump to step 2 (Name & Brain) so the user immediately sees the prefilled personastate.step = 2;saveState(state);- showWizard();+ showWizard({ fromTemplate: true });renderStep();}@@ -183,8 +196,9 @@ function initTemplateGallery() {}// If there's an in-progress wizard session, skip the gallery and let caller renderStep.+ // Show "← Templates" so the user can always reset back to the template gallery.if (hasSavedState) {- showWizard();+ showWizard({ fromTemplate: false });return false;}@@ -198,7 +212,8 @@ function initTemplateGallery() {const blankBtn = document.getElementById('btn-blank-start');if (blankBtn) {- blankBtn.addEventListener('click', () => showWizard());+ // Gallery is visible; "Start from scratch" comes from within it, so no back-button needed.+ blankBtn.addEventListener('click', () => showWizard({ fromTemplate: true }));}return false;