Skip to content

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.

docs(structure): map the economy lab surface and land its script follow-up

nirholas657f122c70fc
diff --git a/STRUCTURE.md b/STRUCTURE.md
index fde66130a..20bd55ff3 100644
--- a/STRUCTURE.md
+++ b/STRUCTURE.md
@@ -186,6 +186,7 @@ bottom.
| Never sell 100% of a winner (moon-bag policy) | rule [workers/agent-sniper/exit-logic.js](workers/agent-sniper/exit-logic.js) (`moonbagExitFraction`, `moonbagAlways`), retained-bag booking [workers/agent-sniper/executor.js](workers/agent-sniper/executor.js), position fields [api/_lib/migrations/20260725100000_sniper_moonbag_always.sql](api/_lib/migrations/20260725100000_sniper_moonbag_always.sql), board [api/sniper/experiments.js](api/sniper/experiments.js) + [src/sniper-experiments.js](src/sniper-experiments.js) `→ /sniper/experiments` | Live | Fleet-wide owner rule: a terminal exit that is IN PROFIT sells down to the moon-bag floor (default 15%) instead of to zero, and the retained tokens ride indefinitely. Once the cost basis is back the remainder is free, so a bag that goes to zero costs nothing and a bag that runs is the whole upside; selling the last slice for a rounding error gives that up. Applies with or without the proactive 2x ladder. A loss exit with the stake still at risk is still a FULL exit and the hard stop-loss is never overridden. The position still books `closed`, so realized P&L and the `max_concurrent_positions` slot are unaffected and a held bag can never stop an arm trading; only the tokens stay behind (`moonbag_base_amount`). Per-strategy opt-out `moonbag_always = false`. Tests: [tests/sniper-laddered-exit.test.js](tests/sniper-laddered-exit.test.js), [tests/trading-experiment-e2e.test.js](tests/trading-experiment-e2e.test.js). See [docs/trading-experiment.md](docs/trading-experiment.md) |
| Autonomous Trading hub (front door) | [pages/trading.html](pages/trading.html) `→ /trading` + [src/trading-hub.js](src/trading-hub.js), pure formatters [src/trading-hub-format.js](src/trading-hub-format.js), surface + doc directory [src/trading-hub-data.js](src/trading-hub-data.js), styles [src/trading-hub.css](src/trading-hub.css) | Live | One entry point for a trading system that had grown to ~20 pages with no front door. Live fleet vitals from `GET /api/sniper/status` (mode, armed strategies, open positions, feed health, funding, uptime), the agent scoreboard from `GET /api/sniper/leaderboard` (realized P&L only, closed trades only, with cumulative sparkline), the five-gate entry-to-exit explainer, and directories of every trading surface and doc. Feed health is reported separately from process health because a beating worker with a silent feed reads as green while seeing nothing. Directory is data, so [tests/trading-hub.test.js](tests/trading-hub.test.js) asserts every link resolves against `data/pages.json` and the docs tree. Docs: [docs/trading-hub.md](docs/trading-hub.md), tutorial [docs/tutorials/read-the-trading-fleet.md](docs/tutorials/read-the-trading-fleet.md) |
| Sniper Experiments (rules vs LLM A/B fleet) | [pages/sniper-experiments.html](pages/sniper-experiments.html) + [src/sniper-experiments.js](src/sniper-experiments.js) `→ /sniper/experiments`, aggregate [api/sniper/experiments.js](api/sniper/experiments.js), LLM judge [workers/agent-sniper/llm-judge.js](workers/agent-sniper/llm-judge.js), fleet seeding [scripts/seed-sniper-experiments.mjs](scripts/seed-sniper-experiments.mjs) | Live | The sniper fleet runs labeled rule-set variants side by side (strict shields, oracle-gated, and `decision_mode=llm` arms judged per-launch by Grok / Claude / OpenRouter auto with no shields), all behind the same safety rails. The page is the live scoreboard of which entry conditions actually make money; real on-chain fills only. |
+| Coin Intelligence (the read the sniper trades on) | [pages/coin-intel.html](pages/coin-intel.html) `→ /coin-intel` (self-contained page: markup, styles and module script in one file), read API [api/pump/intel.js](api/pump/intel.js) `→ /api/pump/intel`, serverless firehose [api/cron/coin-intel-observe.js](api/cron/coin-intel-observe.js), shared finalize path [workers/agent-sniper/intel/finalize.js](workers/agent-sniper/intel/finalize.js) | Live | The public dashboard over the Coin Intelligence engine: every pump.fun launch observed for its first ~90 seconds, classified, scored 0..100, and labeled by outcome after the fact. Four views off one endpoint (`view=feed` live radar with category/verdict/quality/search filters, `view=leaderboard` best of 24h plus confirmed graduated/pumped winners, `view=traders` cross-coin wallet reputation with real win-rates, `view=learning` the per-signal weights the model learned). A coin's card opens a drawer with its launch signals, trade footprint, risk flags, a funder-cluster bubble map, the classified order book, and Oracle conviction fetched in parallel from [api/oracle/coin.js](api/oracle/coin.js). Reads `pump_coin_intel` / `pump_coin_wallets` / `pump_coin_outcomes` / `pump_intel_weights`, all written by the engine; the endpoint never writes and degrades to a designed "engine warming up" state (200 with `degraded:true`) when those tables are absent. `traders` and `learning` are whole-history aggregates and are edge-cached for minutes; the radar stays on a 5s cache and auto-refreshes every 15s. Watchlist stars share the `ld_watchlist` key with `/oracle`, `/launches` and `/watchlist`. |
| Agent voice cloning (your voice, on your agent) | Capture + BYOK panel [src/voice/voice-setup.js](src/voice/voice-setup.js) (`VoiceSetup`), mounted as step 5 of the create wizard ([src/create-agent.js](src/create-agent.js) `→ /create-agent`), in the agent editor, and in the talk-mode shell [src/voice/voice-clone-modal.js](src/voice/voice-clone-modal.js); server [api/agents/_id/voice.js](api/agents/_id/voice.js) `→ GET/PUT/DELETE /api/agents/:id/voice` + `POST /api/agents/:id/voice/clone`; credential resolver [api/_lib/agent-voice-key.js](api/_lib/agent-voice-key.js); playback config mapper `agentVoiceConfig` in [src/runtime/speech.js](src/runtime/speech.js), consumed by the hosted embed [pages/agent-embed.html](pages/agent-embed.html) `→ /agent/:id/embed` and the SDK runtime [src/runtime/index.js](src/runtime/index.js) | In-repo · BYOK live, platform lane awaits a key | Record or upload 30+ seconds and the agent speaks in that voice everywhere on three.ws. Three credential lanes, and they are not interchangeable: a clone only exists inside the ElevenLabs account that made it, so the winning lane is recorded on `agent_identities.voice_key_source` and replayed on every synthesis. **BYOK is the activation path today** (no platform `ELEVENLABS_API_KEY` is set on the service), and the panel renders inline key entry rather than a dead "not configured" message; setting that one variable lights up the platform lane, metered to $THREE credits. `/api/tts/eleven` only spends an owner's key when the request names the agent, which is what lets a bound voice speak to signed-out visitors inside a cross-origin embed. Docs: [docs/tutorials/voice-and-lipsync.md](docs/tutorials/voice-and-lipsync.md), [src/voice/README.md](src/voice/README.md). Tests: [tests/api/agents-voice.test.js](tests/api/agents-voice.test.js), [tests/runtime/agent-voice-config.test.js](tests/runtime/agent-voice-config.test.js) |
| Trading Copilot (conversational) | client [src/agent-copilot.js](src/agent-copilot.js), hub tab [src/agent-wallet-hub/tabs/copilot.js](src/agent-wallet-hub/tabs/copilot.js), server [api/agents/copilot.js](api/agents/copilot.js) `→ POST /api/agents/:id/copilot` (SSE) | In-repo | Owner-only chat over an agent's Solana wallet: text/voice in, markdown replies, live **data cards** (portfolio, firewall, quote, smart-money, intel) and **confirm-before-execute** trade/limits cards. Read-only tools run server-side; state-changing intents return as proposals the browser re-quotes and runs through the existing spend guards + firewall + custody audit. Slash commands, copy/regenerate, localStorage persistence. See [docs/trading-copilot.md](docs/trading-copilot.md) |
| Alpha Co-pilot (the agent narrates its own read) | page [pages/alpha-copilot.html](pages/alpha-copilot.html) `→ /alpha-copilot`, client [src/alpha-copilot.js](src/alpha-copilot.js), styles [src/alpha-copilot.css](src/alpha-copilot.css), profile cross-link [src/shared/alpha-copilot-link.js](src/shared/alpha-copilot-link.js), server [api/agents/alpha.js](api/agents/alpha.js) `→ GET /api/agents/:id/alpha/candidates` + `POST /api/agents/:id/alpha/read`, grounding + scrub [api/\_lib/alpha-read.js](api/_lib/alpha-read.js) | Live | The intelligence and voice layer on the same trade rails the Trading Copilot uses: pick a public agent from a real gallery, pick a real live pump.fun mint off the candidate feed, and the agent reads it in character while its `<agent-3d>` avatar speaks the verdict aloud (agent TTS provider, then the free server lane, then browser speech). Every figure it says is validated against the `signals` bundle the server actually fetched (bonding-curve state, a real non-binding reference buy quote for true price impact, graduation progress, smart-money wallets, and for the owner the wallet balance and spend limits); a mismatch replaces the line and raises `hallucination_guard.line_replaced`, which the page surfaces rather than hides. The narrator never signs: acting on a read is an owner-only drawer that re-quotes through `previewAgentTrade` and executes through `executeAgentTrade`, so the spend policy, firewall, and custody audit all still apply. Docs: [docs/alpha-copilot.md](docs/alpha-copilot.md) |
diff --git a/src/economy-lab.js b/src/economy-lab.js
index cf6e32a7f..9d3a2c703 100644
--- a/src/economy-lab.js
+++ b/src/economy-lab.js
@@ -487,30 +487,43 @@ function drawChart(series, knobs) {
const danger = col('--el-danger', '#fb7185');
const info = col('--el-info', '#7dd3fc');
- const padL = narrow ? 42 : 58;
- const padR = narrow ? 34 : 52;
+ if (!series.length) return;
+
+ const maxBal = Math.max(knobs.floorLamports * 1.15, ...series.map((s) => s.lamports), 1);
+ const maxCount = Math.max(1, ...series.map((s) => s.admitted + s.refusedFloor + s.refusedGovernor));
+
+ // Tick precision is derived from the range being plotted: a fee wallet
+ // holding 0.0023 SOL rendered every one of its five gridlines as "0.002" or
+ // "0.001" at a fixed three decimals, which is an axis that cannot be read.
+ ctx.font = '11px ui-sans-serif, system-ui, sans-serif';
+ const solDigits = axisSolDigits(maxBal);
+ const ticks = [0, 1, 2, 3, 4].map((g) => ({
+ sol: fmtSol(maxBal * (1 - g / 4), solDigits),
+ count: fmtInt(maxCount * (1 - g / 4)),
+ }));
+ const widest = (key) => Math.max(...ticks.map((t) => ctx.measureText(t[key]).width));
+
+ // The gutters are sized to the labels they must hold. A fixed 42px left gutter
+ // clipped "0.0023" to ".0023" on a phone, which turns a precise axis back into
+ // an unreadable one by a different route.
+ const padL = Math.min(cssW * 0.32, Math.max(narrow ? 34 : 46, widest('sol') + 12));
+ const padR = Math.min(cssW * 0.28, Math.max(narrow ? 28 : 40, widest('count') + 12));
// Room above the plot for the axis unit captions, which used to be drawn
// inside it and landed straight on top of the first gridline label.
const padT = 26;
const padB = 30;
const w = cssW - padL - padR;
const h = cssH - padT - padB;
- if (w <= 0 || h <= 0 || !series.length) return;
+ if (w <= 0 || h <= 0) return;
- const maxBal = Math.max(knobs.floorLamports * 1.15, ...series.map((s) => s.lamports), 1);
- const maxCount = Math.max(1, ...series.map((s) => s.admitted + s.refusedFloor + s.refusedGovernor));
const x = (i) => padL + (series.length === 1 ? w / 2 : (i / (series.length - 1)) * w);
const yBal = (v) => padT + h - (v / maxBal) * h;
const yCount = (v) => padT + h - (v / maxCount) * h;
- // Grid. Tick precision is derived from the range being plotted: a fee wallet
- // holding 0.0023 SOL rendered every one of its five gridlines as "0.002" or
- // "0.001" at a fixed three decimals, which is an axis that cannot be read.
+ // Grid
ctx.strokeStyle = line;
ctx.lineWidth = 1;
- ctx.font = '11px ui-sans-serif, system-ui, sans-serif';
ctx.fillStyle = faint;
- const solDigits = axisSolDigits(maxBal);
for (let g = 0; g <= 4; g++) {
const yy = padT + (h / 4) * g;
ctx.beginPath();
@@ -518,9 +531,9 @@ function drawChart(series, knobs) {
ctx.lineTo(padL + w, yy);
ctx.stroke();
ctx.textAlign = 'right';
- ctx.fillText(fmtSol(maxBal * (1 - g / 4), solDigits), padL - 8, yy + 4);
+ ctx.fillText(ticks[g].sol, padL - 6, yy + 4);
ctx.textAlign = 'left';
- ctx.fillText(fmtInt(maxCount * (1 - g / 4)), padL + w + 8, yy + 4);
+ ctx.fillText(ticks[g].count, padL + w + 6, yy + 4);
}
// Axis captions, in the gutter above the plot so they cannot sit on a tick.