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
Add compressed CSS file for chat assets
nirholas686fc30e21f3
diff --git a/api/_lib/pumpfun-ws-feed.js b/api/_lib/pumpfun-ws-feed.jsindex 4daf6d49c..e2449d115 100644--- a/api/_lib/pumpfun-ws-feed.js+++ b/api/_lib/pumpfun-ws-feed.js@@ -1,98 +1,80 @@-// Pump.fun public WebSocket feed — no Redis or Solana RPC required.-// Uses pump.fun's Socket.IO endpoint for live mint events and polls-// their REST API for graduation (migration) events.+// Pump.fun live feed via PumpPortal public WebSocket.+// No Redis, no Solana RPC, no auth required.+// wss://pumpportal.fun/api/data — same source pumpkit tools use.import WebSocket from 'ws';-const PUMP_WS = 'wss://frontend-api.pump.fun/socket.io/?EIO=4&transport=websocket';-const PUMP_REST = 'https://frontend-api.pump.fun';-const GRAD_POLL_MS = 5_000;+const PUMPPORTAL_WS = 'wss://pumpportal.fun/api/data';+const RECONNECT_DELAY_MS = 2_000;+const MAX_RECONNECTS = 5;/**- * Connect to the pump.fun public feed.+ * Connect to the PumpPortal WebSocket and stream pump.fun events.* @param {{ onEvent: Function, signal?: AbortSignal, kind?: string }} opts- * kind: 'all' | 'mint' | 'graduation' (default 'all')+ * kind: 'all' | 'mint' | 'graduation'* onEvent: ({ kind, data }) => void- * @returns {Function} cleanup — call to stop everything early+ * @returns {Function} stop — call to clean up*/export function connectPumpFunFeed({ onEvent, signal, kind = 'all' }) {let active = true;let ws = null;- let pollTimer = null;- const seenGrad = new Set();+ let reconnects = 0;+ let reconnectTimer = null;function stop() {active = false;- clearTimeout(pollTimer);+ clearTimeout(reconnectTimer);if (ws) try { ws.close(); } catch {}}signal?.addEventListener('abort', stop);- // Socket.IO WebSocket for real-time mint events- if (kind === 'all' || kind === 'mint') {- ws = new WebSocket(PUMP_WS, {- headers: { Origin: 'https://pump.fun', 'User-Agent': 'Mozilla/5.0' },- });+ function connect() {+ if (!active) return;++ ws = new WebSocket(PUMPPORTAL_WS);ws.on('open', () => {- ws.send('40'); // Engine.IO → Socket.IO connect+ reconnects = 0;+ // Subscribe based on requested kind+ if (kind === 'all' || kind === 'mint') {+ ws.send(JSON.stringify({ method: 'subscribeNewToken' }));+ }+ if (kind === 'all' || kind === 'graduation') {+ ws.send(JSON.stringify({ method: 'subscribeMigration' }));+ }});ws.on('message', (raw) => {if (!active) return;- const str = raw.toString();-- if (str === '2') { ws.send('3'); return; } // ping → pong-- if (str.startsWith('40')) {- // Socket.IO connected — subscribe to new tokens- ws.send('42["subscribeNewToken"]');- return;- }-- if (!str.startsWith('42')) return;let msg;- try { msg = JSON.parse(str.slice(2)); } catch { return; }- const [event, data] = msg;+ try { msg = JSON.parse(raw.toString()); } catch { return; }++ // Skip subscription acks+ if (msg.message) return;- if (event === 'newCoinCreated' && data?.mint) {- onEvent({ kind: 'mint', data: normalizeMint(data) });+ if (msg.txType === 'create') {+ if (kind === 'all' || kind === 'mint') {+ onEvent({ kind: 'mint', data: normalizeMint(msg) });+ }+ } else if (msg.txType === 'migrate' || msg.txType === 'migration') {+ if (kind === 'all' || kind === 'graduation') {+ onEvent({ kind: 'graduation', data: normalizeGrad(msg) });+ }}});- ws.on('error', (err) => console.error('[pumpfun-ws] error:', err?.message));- }+ ws.on('error', (err) => console.error('[pumpportal-ws] error:', err?.message));- // REST polling for graduations (pump.fun doesn't emit these on Socket.IO)- if (kind === 'all' || kind === 'graduation') {- const pollGrads = async () => {+ ws.on('close', () => {if (!active) return;- try {- const r = await fetch(`${PUMP_REST}/coins/migrated?limit=20`, {- headers: { 'User-Agent': 'Mozilla/5.0' },- signal: signal ?? undefined,- });- if (r.ok) {- const coins = await r.json();- const list = Array.isArray(coins) ? coins : (coins?.coins ?? []);- for (const coin of list) {- const id = coin.tx_hash || coin.mint;- if (seenGrad.has(id)) continue;- seenGrad.add(id);- if (seenGrad.size > 500) {- const oldest = seenGrad.values().next().value;- seenGrad.delete(oldest);- }- onEvent({ kind: 'graduation', data: normalizeGrad(coin) });- }- }- } catch {}- if (active) pollTimer = setTimeout(pollGrads, GRAD_POLL_MS);- };- pollGrads();+ if (reconnects >= MAX_RECONNECTS) return;+ reconnects++;+ reconnectTimer = setTimeout(connect, RECONNECT_DELAY_MS);+ });}+ connect();return stop;}@@ -101,22 +83,21 @@ function normalizeMint(d) {mint: d.mint,name: d.name,symbol: d.symbol,- image_uri: d.image_uri,- creator: d.creator,- created_timestamp: d.created_timestamp,- usd_market_cap: d.usd_market_cap,- description: d.description,+ creator: d.traderPublicKey,+ signature: d.signature,+ market_cap_sol: d.marketCapSol,+ image_uri: d.uri,+ bonding_curve: d.bondingCurveKey,};}function normalizeGrad(d) {return {- tx_signature: d.tx_hash || null,- signature: d.tx_hash || null,+ tx_signature: d.signature,+ signature: d.signature,mint: d.mint,name: d.name,symbol: d.symbol,- usd_market_cap: d.usd_market_cap,- raydium_pool: d.raydium_pool,+ pool: d.pool,};}diff --git a/api/chat/config.js b/api/chat/config.jsindex c9893885d..b1682d602 100644--- a/api/chat/config.js+++ b/api/chat/config.js@@ -9,6 +9,7 @@ const DEFAULTS = {accent_color: '#6366f1',tagline: 'Chat with any AI model',default_model: 'google/gemini-2.0-flash-exp:free',+ agent_id: null,};const bodySchema = z.object({@@ -17,6 +18,7 @@ const bodySchema = z.object({accent_color: z.string().regex(/^#[0-9a-fA-F]{6}$/).default('#6366f1'),tagline: z.string().trim().max(200).optional(),default_model: z.string().trim().min(1).max(100).optional(),+ agent_id: z.string().trim().max(100).nullable().optional(),});export default wrap(async (req, res) => {@@ -25,7 +27,7 @@ export default wrap(async (req, res) => {// GET — fully public, returns current brand configif (req.method === 'GET') {- const [row] = await sql`SELECT name, logo_url, accent_color, tagline, default_model FROM chat_brand_config WHERE key = 'global'`;+ const [row] = await sql`SELECT name, logo_url, accent_color, tagline, default_model, agent_id FROM chat_brand_config WHERE key = 'global'`;return json(res, 200, { data: row ?? DEFAULTS });}@@ -55,9 +57,10 @@ export default wrap(async (req, res) => {accent_color = ${body.accent_color},tagline = ${body.tagline ?? DEFAULTS.tagline},default_model = ${body.default_model ?? DEFAULTS.default_model},+ agent_id = ${body.agent_id ?? null},updated_at = now()WHERE key = 'global'- RETURNING name, logo_url, accent_color, tagline, default_model, updated_at+ RETURNING name, logo_url, accent_color, tagline, default_model, agent_id, updated_at`;return json(res, 200, { data: row });diff --git a/chat/src/App.svelte b/chat/src/App.svelteindex 6df9515bc..223a9d4c3 100644--- a/chat/src/App.svelte+++ b/chat/src/App.svelte@@ -43,7 +43,7 @@feTerminal,feMoreHorizontal,fePaperclip,- fthree.ws-chat,+ feStar,feRefreshCw,feSettings,feShare,@@ -422,6 +422,7 @@}$controller.abort();generating = false;+ speakLastMessage();// Stop thinkingconst i = convo.messages.length - 1;if (convo.messages[i].reasoning) {@@ -1134,6 +1135,25 @@let savedTime = 0;let video;++ // Floating 3D agent+ let agentEl;+ let agentVisible = true;+ let agentScriptLoaded = false;++ $: if ($brandConfig.agent_id && !agentScriptLoaded) {+ agentScriptLoaded = true;+ const s = document.createElement('script');+ s.type = 'module';+ s.src = '/agent-3d/latest/agent-3d.js';+ document.head.appendChild(s);+ }++ function speakLastMessage() {+ if (!agentEl || !$brandConfig.agent_id) return;+ const last = [...convo.messages].reverse().find((m) => m.role === 'assistant' && m.content);+ if (last?.content) agentEl.speak(last.content);+ }</script><svelte:window@@ -1176,7 +1196,7 @@on:click={newConversation}class="flex rounded-full p-2 transition-colors hover:bg-gray-100">- <Icon icon={fthree.ws-chat} strokeWidth={3} class="ml-auto h-4 w-4 text-slate-700" />+ <Icon icon={feStar} strokeWidth={3} class="ml-auto h-4 w-4 text-slate-700" /></button><buttondata-trigger="history"@@ -1232,7 +1252,7 @@class="flex w-full items-center rounded-[10px] border py-2.5 pl-3 pr-4 text-left text-sm font-medium hover:bg-gray-100">New chat- <Icon icon={fthree.ws-chat} strokeWidth={3} class="ml-auto h-3.5 w-3.5 text-slate-700" />+ <Icon icon={feStar} strokeWidth={3} class="ml-auto h-3.5 w-3.5 text-slate-700" /></button></div><ol@@ -1511,6 +1531,30 @@</Modal>{/if}+{#if $brandConfig.agent_id}+ <div class="fixed bottom-4 right-4 z-50 flex flex-col items-end gap-2">+ {#if agentVisible}+ <!-- svelte-ignore custom-element-no-implicit-ns -->+ <agent-3d+ bind:this={agentEl}+ agent-id={$brandConfig.agent_id}+ mode="embed"+ width="220"+ height="220"+ background="transparent"+ style="width:220px;height:220px;border-radius:16px;overflow:hidden;box-shadow:0 8px 32px rgba(0,0,0,0.18);"+ ></agent-3d>+ {/if}+ <button+ class="flex h-8 w-8 items-center justify-center rounded-full bg-white shadow-md ring-1 ring-gray-200 transition hover:bg-gray-50"+ title={agentVisible ? 'Hide agent' : 'Show agent'}+ on:click={() => (agentVisible = !agentVisible)}+ >+ <Icon icon={agentVisible ? feX : feCpu} class="h-3.5 w-3.5 text-slate-600" />+ </button>+ </div>+{/if}+<style lang="postcss">:global(.standalone .input-floating) {@apply bottom-[32px];diff --git a/chat/src/ClientToolSetting.svelte b/chat/src/ClientToolSetting.svelteindex f5b5c385d..69d1df93c 100644--- a/chat/src/ClientToolSetting.svelte+++ b/chat/src/ClientToolSetting.svelte@@ -2,7 +2,7 @@import { createEventDispatcher } from 'svelte';import Button from './Button.svelte';import Icon from './Icon.svelte';- import { feCheck, fthree.ws-chat, feTrash } from './feather.js';+ import { feCheck, fePlus, feTrash } from './feather.js';const dispatch = createEventDispatcher();@@ -168,7 +168,7 @@];}}>- <Icon icon={fthree.ws-chat} strokeWidth={3} class="mr-2 h-3 w-3 text-slate-700" />+ <Icon icon={fePlus} strokeWidth={3} class="mr-2 h-3 w-3 text-slate-700" />Add argument</Button></div>diff --git a/chat/src/Message.svelte b/chat/src/Message.svelteindex 72a32e3dc..ee8ca63a7 100644--- a/chat/src/Message.svelte+++ b/chat/src/Message.svelte@@ -13,7 +13,7 @@feEdit2,feTerminal,feMoreHorizontal,- fthree.ws-chat,+ feStar,feRefreshCw,feUser,feX,@@ -581,7 +581,7 @@? 'group-hover:opacity-100': ''} z-1 absolute bottom-0 left-1/2 flex h-6 w-6 -translate-x-1/2 translate-y-1/2 items-center justify-center rounded-md border border-slate-200 bg-white opacity-0 transition-opacity hover:bg-gray-200">- <Icon icon={fthree.ws-chat} class="m-auto h-3 w-3 text-slate-600" />+ <Icon icon={feStar} class="m-auto h-3 w-3 text-slate-600" /></button></li>{/if}diff --git a/chat/src/SettingsModal.svelte b/chat/src/SettingsModal.svelteindex d87f526d6..bdd849f9c 100644--- a/chat/src/SettingsModal.svelte+++ b/chat/src/SettingsModal.svelte@@ -22,7 +22,7 @@feHardDrive,feKey,feLayout,- fthree.ws-chat,+ feStar,feRefreshCw,feTool,feUsers,@@ -59,6 +59,7 @@accent_color: $brandConfig.accent_color,tagline: $brandConfig.tagline,default_model: $brandConfig.default_model,+ agent_id: $brandConfig.agent_id ?? '',};}@@ -73,6 +74,7 @@body: JSON.stringify({...brandDraft,logo_url: brandDraft.logo_url || null,+ agent_id: brandDraft.agent_id || null,}),});const json = await res.json();@@ -473,7 +475,7 @@});}}>- <Icon icon={fthree.ws-chat} strokeWidth={3} class="mr-2 h-3 w-3 text-slate-700" />+ <Icon icon={feStar} strokeWidth={3} class="mr-2 h-3 w-3 text-slate-700" />Add new tool</Button></div>@@ -546,6 +548,15 @@{/each}</select></label>+ <label class="flex flex-col text-[10px] uppercase tracking-wide">+ <span class="mb-2 ml-[3px]">Floating agent ID</span>+ <input+ type="text"+ bind:value={brandDraft.agent_id}+ class="rounded-lg border border-gray-200 bg-white px-3 py-2 text-[13px] outline-none focus:border-indigo-400"+ placeholder="e.g. agent-abc123 (leave blank to hide)"+ />+ </label><label class="flex flex-col text-[10px] uppercase tracking-wide"><span class="mb-2 ml-[3px]">Accent color</span><div class="flex items-center gap-3">diff --git a/chat/src/feather.js b/chat/src/feather.jsindex 6ca61b7f1..b976727ee 100644--- a/chat/src/feather.js+++ b/chat/src/feather.js@@ -105,7 +105,7 @@ export const feFastForward = `<polygon points="13 19 22 12 13 5 13 19"></polygonexport const feFeather = `<path d="M20.24 12.24a6 6 0 0 0-8.49-8.49L5 10.5V19h8.5z"></path><line x1="16" y1="8" x2="2" y2="22"></line><line x1="17.5" y1="15" x2="9" y2="15"></line>`;export const feFigma = `<path d="M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z"></path><path d="M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z"></path><path d="M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z"></path><path d="M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z"></path><path d="M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z"></path>`;export const feFileMinus = `<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="9" y1="15" x2="15" y2="15"></line>`;-export const feFilthree.ws-chat = `<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="12" y1="18" x2="12" y2="12"></line><line x1="9" y1="15" x2="15" y2="15"></line>`;+export const feFilePlus = `<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="12" y1="18" x2="12" y2="12"></line><line x1="9" y1="15" x2="15" y2="15"></line>`;export const feFileText = `<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline>`;export const feFile = `<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline>`;export const feFilm = `<rect x="2" y="2" width="20" height="20" rx="2.18" ry="2.18"></rect><line x1="7" y1="2" x2="7" y2="22"></line><line x1="17" y1="2" x2="17" y2="22"></line><line x1="2" y1="12" x2="22" y2="12"></line><line x1="2" y1="7" x2="7" y2="7"></line><line x1="2" y1="17" x2="7" y2="17"></line><line x1="17" y1="17" x2="22" y2="17"></line><line x1="17" y1="7" x2="22" y2="7"></line>`;@@ -191,9 +191,9 @@ export const fePhone = `<path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-export const fePieChart = `<path d="M21.21 15.89A10 10 0 1 1 8 2.83"></path><path d="M22 12A10 10 0 0 0 12 2v10z"></path>`;export const fePlayCircle = `<circle cx="12" cy="12" r="10"></circle><polygon points="10 8 16 12 10 16 10 8"></polygon>`;export const fePlay = `<polygon points="5 3 19 12 5 21 5 3"></polygon>`;-export const fthree.ws-chatCircle = `<circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line>`;-export const fthree.ws-chatSquare = `<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line>`;-export const fthree.ws-chat = `<line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line>`;+export const fePlusCircle = `<circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line>`;+export const fePlusSquare = `<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line>`;+export const fePlus = `<line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line>`;export const fePocket = `<path d="M4 3h16a2 2 0 0 1 2 2v6a10 10 0 0 1-10 10A10 10 0 0 1 2 11V5a2 2 0 0 1 2-2z"></path><polyline points="8 10 12 14 16 10"></polyline>`;export const fePower = `<path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line>`;export const fePrinter = `<polyline points="6 9 6 2 18 2 18 9"></polyline><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"></path><rect x="6" y="14" width="12" height="8"></rect>`;diff --git a/chat/src/stores.js b/chat/src/stores.jsindex bc3faa705..5c9a8afb4 100644--- a/chat/src/stores.js+++ b/chat/src/stores.js@@ -1,7 +1,7 @@import { writable, get } from 'svelte/store';import { persisted } from './localstorage.js';import { v4 as uuidv4 } from 'uuid';-import { three.ws-chatHostedAddress } from './sync.js';+import { syncHostedAddress } from './sync.js';export const brandConfig = writable({name: 'three.ws chat',@@ -9,6 +9,7 @@ export const brandConfig = writable({accent_color: '#6366f1',tagline: 'Chat with any AI model',default_model: 'google/gemini-2.0-flash-exp:free',+ agent_id: null,});export const controller = writable(null);@@ -53,7 +54,7 @@ export function setAPIKeysFromObject(obj) {export const remoteServer = persisted('remoteServer', { address: 'http://localhost:8081', password: '' });export const syncServer = persisted('syncServer', {- address: three.ws-chatHostedAddress,+ address: syncHostedAddress,token: uuidv4(),password: '',});diff --git a/chat/src/sync.js b/chat/src/sync.jsindex b5e6bb90f..50de8bdf1 100644--- a/chat/src/sync.js+++ b/chat/src/sync.js@@ -1,7 +1,7 @@import { getAPIKeysAsObject, setAPIKeysFromObject, syncServer } from './stores.js';import { get } from 'svelte/store';-export const three.ws-chatHostedAddress = 'https://sync.three.ws';+export const syncHostedAddress = 'https://sync.three.ws';// Encryption statelet encryptionKey = null;diff --git a/public/chat/index.html b/public/chat/index.htmlindex 8b9f1ae6f..4fa57ce9c 100644--- a/public/chat/index.html+++ b/public/chat/index.html@@ -31,8 +31,8 @@crossorigin="anonymous"/><title>three.ws chat</title>- <script type="module" crossorigin src="/chat/assets/index-rSnwP_QW.js"></script>- <link rel="stylesheet" crossorigin href="/chat/assets/index-DoMK3nJH.css">+ <script type="module" crossorigin src="/chat/assets/index-BV3ILwfd.js"></script>+ <link rel="stylesheet" crossorigin href="/chat/assets/index-ym5zKA4q.css"></head><body><div id="app"></div>diff --git a/public/pumpfun.html b/public/pumpfun.htmlindex 38da15180..cfd5605e1 100644--- a/public/pumpfun.html+++ b/public/pumpfun.html@@ -228,12 +228,11 @@}function renderMint(ev) {- const cap = ev.usd_market_cap != null ? `$${Number(ev.usd_market_cap).toLocaleString(undefined,{maximumFractionDigits:0})}` : '';+ const cap = ev.market_cap_sol != null ? `${Number(ev.market_cap_sol).toFixed(1)} SOL` : '';return `<div class="evt"><div class="evt-row"><span class="evt-kind">🌱 new token</span><span class="evt-time">${cap}</span></div><div class="evt-who">${escapeHtml(ev.name || ev.symbol || ev.mint || '—')}</div>${ev.symbol ? `<div class="evt-amt">$${escapeHtml(ev.symbol)}</div>` : ''}- ${ev.description ? `<div class="evt-take">${escapeHtml(ev.description.slice(0,80))}</div>` : ''}</div>`;}