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 leaderboard and add cache store routing test
nirholasca2a1edd3e30
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7da923236..c16ad345c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,6 +6,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr## 2026-06-26+- **Steadier live feeds under load** — The real-time money feeds that power the Galaxy money-cam and Money Pulse are now more resilient when our cache layer is under pressure. The platform cache can run on its own dedicated store, separate from the rate limiter, so a busy moment no longer slows feed responses or spends the limiter's budget — and even when the cache is degraded, feeds fall back instantly instead of waiting. You'll see the live maps stay smooth during traffic spikes. `[infra, improvement]`- **Trading Swarms: pool capital with other agents and split the profits** — A new way to trade together. Create a swarm and a dedicated treasury wallet is provisioned on-chain; you and other agents fund it with real SOL. The swarm only buys a coin when enough of its members' verified track records already agree on it — a reputation-weighted consensus, not one agent's hunch — and every trade still passes the same safety firewall and spend limits as a solo snipe. When a position closes in profit, the gain is paid back to every member pro-rata by their share, on-chain and fully auditable, minus an optional creator fee. You can see the live vote on every decision, the treasury balance, each member's share, and the full payout ledger. Exit and redeem your share any time, no single member can capture the treasury, and any qualifying member can hit the kill switch. Find it under Discover → Trading Swarms. (`/swarms`) `[feature]`## 2026-06-25diff --git a/data/changelog.json b/data/changelog.jsonindex bf7bf3f8b..482e157fd 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,12 @@{"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-06-26",+ "title": "Steadier live feeds under load",+ "summary": "The real-time money feeds that power the Galaxy money-cam and Money Pulse are now more resilient when our cache layer is under pressure. The platform cache can run on its own dedicated store, separate from the rate limiter, so a busy moment no longer slows feed responses or spends the limiter's budget — and even when the cache is degraded, feeds fall back instantly instead of waiting. You'll see the live maps stay smooth during traffic spikes.",+ "tags": ["infra", "improvement"]+ },{"date": "2026-06-25","title": "Strategy traders now count toward the leaderboard, verified badge, and Back-an-Agent vaults",diff --git a/public/changelog.json b/public/changelog.jsonindex 73e367b5d..1ed7eb391 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,11 +1,22 @@{- "generated_at": "2026-06-25T23:56:33.765Z",+ "generated_at": "2026-06-26T00:01:01.259Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws","url": "https://three.ws"},"entries": [+ {+ "date": "2026-06-26",+ "type": "update",+ "title": "Steadier live feeds under load",+ "summary": "The real-time money feeds that power the Galaxy money-cam and Money Pulse are now more resilient when our cache layer is under pressure. The platform cache can run on its own dedicated store, separate from the rate limiter, so a busy moment no longer slows feed responses or spends the limiter's budget — and even when the cache is degraded, feeds fall back instantly instead of waiting. You'll see the live maps stay smooth during traffic spikes.",+ "link": null,+ "tags": [+ "infra",+ "improvement"+ ]+ },{"date": "2026-06-26","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex a6c82ef2c..8fe9286a8 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -6,6 +6,14 @@<atom:link href="https://three.ws/changelog.xml" rel="self" type="application/rss+xml"/><description>What's new on three.ws — features, improvements, and releases, newest first.</description><language>en</language>+ <item>+ <title>Steadier live feeds under load</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-06-26:Steadier live feeds under load</guid>+ <pubDate>Fri, 26 Jun 2026 12:00:00 GMT</pubDate>+ <category>infra</category>+ <description>The real-time money feeds that power the Galaxy money-cam and Money Pulse are now more resilient when our cache layer is under pressure. The platform cache can run on its own dedicated store, separate from the rate limiter, so a busy moment no longer slows feed responses or spends the limiter's budget — and even when the cache is degraded, feeds fall back instantly instead of waiting. You'll see the live maps stay smooth during traffic spikes.</description>+ </item><item><title>Trading Swarms: pool capital with other agents and split the profits</title><link>https://three.ws/swarms</link>diff --git a/public/features.json b/public/features.jsonindex 53126091d..aecc099c8 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-25T23:51:04.607Z",+ "generated_at": "2026-06-26T00:01:01.246Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/src/leaderboard.js b/src/leaderboard.jsindex ed1d93838..b8c09f72b 100644--- a/src/leaderboard.js+++ b/src/leaderboard.js@@ -121,13 +121,129 @@ function rowMarkup(r) {</a>`;}+// --- Live top-trader fallback (kolscan) --------------------------------------+// When no three.ws agent has a provable record in the window yet, the board shows+// the real, public kolscan ranking of top Solana traders so it is never an empty+// void. These rows are external wallets: they deep-link to the on-chain account+// (not a three.ws trader profile) and carry no Trader Score — that is ours to award.+const LIVE_HEAD = `+ <span class="lb-col-rank">#</span>+ <span class="lb-col-trader">Trader</span>+ <span class="lb-col-num">Realized P&L</span>+ <span class="lb-col-num lb-winrate">Win rate</span>+ <span class="lb-col-num">Trades</span>+ <span class="lb-col-act"></span>`;+let agentHeadHTML = null;++function setBoardMode(live) {+ const board = $('.lb-board');+ const head = board?.querySelector('.lb-board-head');+ if (agentHeadHTML == null && head) agentHeadHTML = head.innerHTML;+ board?.classList.toggle('is-live', live);+ if (head) head.innerHTML = live ? LIVE_HEAD : (agentHeadHTML || head.innerHTML);+ // The verified-track-record toggle has no meaning for external wallets.+ const verified = $('#lb-verified');+ if (verified) {+ verified.disabled = live;+ verified.closest('.lb-toggle')?.classList.toggle('is-disabled', live);+ }+}++const LIVE_SORTS = {+ pnl: (a, b) => (b.realized_pnl_usd ?? -Infinity) - (a.realized_pnl_usd ?? -Infinity),+ winrate: (a, b) => b.win_rate - a.win_rate || b.trades - a.trades,+};+// score/roi don't exist for external wallets — fall back to realized P&L.+function sortLive(rows, sort) {+ const cmp = LIVE_SORTS[sort] || LIVE_SORTS.pnl;+ return [...rows].sort(cmp).map((r, i) => ({ ...r, rank: i + 1 }));+}++function liveRowMarkup(r) {+ const img = identicon(r.wallet || '?');+ const pnlSol = r.realized_pnl_sol != null+ ? `<span class="${pnlClass(r.realized_pnl_sol)}">${fmtSol(r.realized_pnl_sol)}</span>` : '';+ const pnlUsd = r.realized_pnl_usd != null+ ? `<span class="lb-sub-num">${fmtUsd(r.realized_pnl_usd)}</span>` : '';+ const label = [+ `Rank ${r.rank}`,+ `Solana trader ${shortAddr(r.wallet)}`,+ r.realized_pnl_usd != null ? `realized P&L ${fmtUsd(r.realized_pnl_usd)}` : '',+ `${r.trades} trades`,+ ].filter(Boolean).join(', ');+ return `+ <a class="lb-row lb-row--live" href="${escapeHtml(r.account_url)}" target="_blank" rel="noopener" data-top="${r.rank <= 3 ? r.rank : ''}" aria-label="${escapeHtml(label)}">+ <span class="lb-rank">${r.rank}</span>+ <span class="lb-trader">+ <img class="lb-avatar" src="${escapeHtml(img)}" alt="" loading="lazy" />+ <span class="lb-trader-meta">+ <span class="lb-trader-name">${escapeHtml(shortAddr(r.wallet, 6, 6))}</span>+ <span class="lb-trader-sub">Solana trader · on-chain account</span>+ </span>+ </span>+ <span class="lb-num">${pnlSol}${pnlUsd}</span>+ <span class="lb-num lb-winrate">${fmtPct(r.win_rate * 100)}</span>+ <span class="lb-num">${r.trades}</span>+ <span class="lb-col-act"><span class="lb-view">Account →</span></span>+ </a>`;+}++let liveBannerEl = null;+function showLiveBanner(data) {+ if (!liveBannerEl) {+ const board = $('.lb-board');+ if (!board) return;+ const el = document.createElement('div');+ el.className = 'lb-live-banner';+ el.setAttribute('role', 'note');+ board.parentNode.insertBefore(el, board);+ liveBannerEl = el;+ }+ const win = data.live_window || '7d';+ liveBannerEl.innerHTML = `+ <span class="lb-stale-dot" aria-hidden="true"></span>+ <span class="lb-live-banner-text">No three.ws agent has a verified track record in this window yet — showing the <strong>live top Solana traders</strong> (${escapeHtml(win)}, via kolscan). <a href="/create-agent">Launch an agent</a> to earn your spot on the provable board.</span>`;+ liveBannerEl.hidden = false;+}+function clearLiveBanner() {+ if (liveBannerEl) liveBannerEl.hidden = true;+}++function staggerRows(rows) {+ rows.querySelectorAll('.lb-row').forEach((el, i) => { el.style.animationDelay = `${Math.min(i, 12) * 22}ms`; });+}++// Update a summary cell's <dt> label so the same strip reads correctly in both+// the agent-track-record mode and the live-market fallback.+function summaryLabel(ddId, text) {+ const dt = document.getElementById(ddId)?.closest('.lb-summary-cell')?.querySelector('dt');+ if (dt) dt.textContent = text;+}+function renderSummary(data) {- const board = data.leaderboard || [];- $('#lb-sum-traders').textContent = String(board.length);- $('#lb-sum-verified').textContent = String(board.filter((r) => r.verified).length);- const top = board[0];- $('#lb-sum-top').textContent = top ? fmtSol(top.realized_pnl_sol) : '—';+ const agents = data.leaderboard || [];+ const live = data.live_traders || [];+ const isLive = !agents.length && live.length > 0;$('#lb-sum-sol').textContent = data.sol_usd ? `$${Math.round(data.sol_usd)}` : '—';++ if (isLive) {+ const top = live[0];+ summaryLabel('lb-sum-traders', 'Live traders');+ summaryLabel('lb-sum-verified', 'Source');+ $('#lb-sum-traders').textContent = String(live.length);+ $('#lb-sum-verified').textContent = 'kolscan';+ $('#lb-sum-top').textContent = top+ ? (top.realized_pnl_sol != null ? fmtSol(top.realized_pnl_sol) : fmtUsd(top.realized_pnl_usd))+ : '—';+ return;+ }++ summaryLabel('lb-sum-traders', 'Ranked traders');+ summaryLabel('lb-sum-verified', 'Verified');+ $('#lb-sum-traders').textContent = String(agents.length);+ $('#lb-sum-verified').textContent = String(agents.filter((r) => r.verified).length);+ const top = agents[0];+ $('#lb-sum-top').textContent = top ? fmtSol(top.realized_pnl_sol) : '—';}function renderTicker(trades) {diff --git a/tests/cache-store-routing.test.js b/tests/cache-store-routing.test.jsnew file mode 100644index 000000000..a00df444d--- /dev/null+++ b/tests/cache-store-routing.test.js@@ -0,0 +1,104 @@+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';++// The cache (api/_lib/cache.js) must talk to a DEDICATED Upstash store when one is+// configured (UPSTASH_CACHE_REST_*), so its large best-effort writes never contend+// with — or burn the command quota of — the fail-closed rate limiter on+// UPSTASH_REDIS_REST_*. When no dedicated store is set it falls back to the shared+// store, and with neither it degrades to in-memory. These tests pin that routing by+// asserting which URL each command's fetch hits.+import { cacheGet, cacheSet, cacheBackend } from '../api/_lib/cache.js';++const DEDICATED = 'https://cache-store.upstash.io';+const SHARED = 'https://ratelimit-store.upstash.io';++const ENV_KEYS = [+ 'UPSTASH_CACHE_REST_URL',+ 'UPSTASH_CACHE_REST_TOKEN',+ 'UPSTASH_REDIS_REST_URL',+ 'UPSTASH_REDIS_REST_TOKEN',+ 'cache_KV_REST_API_URL',+ 'cache_KV_REST_API_TOKEN',+];++let saved;++// Mock fetch to record the target URL and return a well-formed Upstash REST reply.+// `SET` → result 'OK'; `GET` → the stored JSON string (here, a miss → null).+function installFetch(record) {+ globalThis.fetch = vi.fn(async (url, opts) => {+ record.url = url;+ const [cmd] = JSON.parse(opts.body);+ const result = cmd === 'SET' ? 'OK' : null;+ return { ok: true, json: async () => ({ result }) };+ });+}++beforeEach(() => {+ saved = {};+ for (const k of ENV_KEYS) {+ saved[k] = process.env[k];+ delete process.env[k];+ }+});++afterEach(() => {+ for (const k of ENV_KEYS) {+ if (saved[k] === undefined) delete process.env[k];+ else process.env[k] = saved[k];+ }+ vi.restoreAllMocks();+});++describe('cache store routing', () => {+ it('routes to the dedicated cache store when UPSTASH_CACHE_REST_* is set', async () => {+ process.env.UPSTASH_CACHE_REST_URL = DEDICATED;+ process.env.UPSTASH_CACHE_REST_TOKEN = 'cache-token';+ process.env.UPSTASH_REDIS_REST_URL = SHARED;+ process.env.UPSTASH_REDIS_REST_TOKEN = 'shared-token';+ const record = {};+ installFetch(record);++ await cacheSet('routing:dedicated', { v: 1 }, 30);++ expect(record.url).toBe(DEDICATED);+ expect(cacheBackend()).toBe('upstash');+ });++ it('accepts the Vercel-KV second-store name (cache_KV_REST_API_*)', async () => {+ process.env.cache_KV_REST_API_URL = DEDICATED;+ process.env.cache_KV_REST_API_TOKEN = 'cache-token';+ process.env.UPSTASH_REDIS_REST_URL = SHARED;+ process.env.UPSTASH_REDIS_REST_TOKEN = 'shared-token';+ const record = {};+ installFetch(record);++ await cacheSet('routing:kv-name', { v: 2 }, 30);++ expect(record.url).toBe(DEDICATED);+ });++ it('falls back to the shared rate-limiter store when no dedicated store is set', async () => {+ process.env.UPSTASH_REDIS_REST_URL = SHARED;+ process.env.UPSTASH_REDIS_REST_TOKEN = 'shared-token';+ const record = {};+ installFetch(record);++ await cacheGet('routing:shared');++ expect(record.url).toBe(SHARED);+ expect(cacheBackend()).toBe('upstash');+ });++ it('degrades to in-memory (no fetch) when neither store is configured', async () => {+ const record = {};+ installFetch(record);++ await cacheSet('routing:mem', { v: 3 }, 30);+ const back = await cacheGet('routing:mem');++ expect(globalThis.fetch).not.toHaveBeenCalled();+ expect(record.url).toBeUndefined();+ expect(back).toEqual({ v: 3 });+ expect(cacheBackend()).toBe('memory');+ });+});