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
fix(terminal): make Mission Control honest signed out and reachable on a phone
nirholasab5034ed9a1a
diff --git a/pages/terminal.html b/pages/terminal.htmlindex 586e2a10e..2c767f049 100644--- a/pages/terminal.html+++ b/pages/terminal.html@@ -11,7 +11,7 @@<link rel="apple-touch-icon" href="/apple-touch-icon.png" /><link rel="manifest" href="/manifest.webmanifest" /><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />- <title data-i18n="terminal.meta_title">Mission Control — Real-Time Trading Terminal · three.ws</title>+ <title data-i18n="terminal.meta_title">Mission Control: Real-Time Trading Terminal · three.ws</title><metaname="description"content="One screen for pump.fun traders: the live launch firehose with intel scores, firewall verdicts, and smart-money flow, your streaming positions, and one-keystroke firewall + MEV-gated trading from your agent wallet."@@ -52,7 +52,7 @@<meta property="og:image:alt" content="Mission Control — three.ws"></head>- <body>+ <body data-no-lang-switcher><div id="root"></div><script type="module">import { mountMissionControl } from '/src/mission-control/index.js';diff --git a/prompts/swarm-100/route-terminal.md b/prompts/swarm-100/route-terminal.mddeleted file mode 100644index 75ff94d72..000000000--- a/prompts/swarm-100/route-terminal.md+++ /dev/null@@ -1,119 +0,0 @@-# Route audit: /terminal (Mission Control)--How to run: paste this file's repo path into a fresh Claude Code chat in this-repository and say "run this work order". This file is fully self-contained:-it depends on no other prompt file anywhere. If neighboring files in-prompts/swarm-100/ are gone, that work is done; if present, ignore them.-Every claim below rots; step 0 re-measures, and what you measure wins.--## Operating clause (binding)--- Read CLAUDE.md first. Its rules override everything, including this file.-- Finish 100% in this session. Never end the turn with a question, an option- list, or an unexecuted plan. A judgment call goes in one line of the final- report; it never becomes a question that halts work.-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real- funds or any irreversible on-chain write, git push or a production deploy,- committing content that references a crypto project other than $THREE, and- destroying unrecoverable data.-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no- commented-out code. Real APIs and real integrations only.-- The em-dash and en-dash characters are banned in everything you write.-- Concurrent agents share this worktree: stage explicit paths only (never a- bare add-everything), and commit finished work promptly.-- Before committing, run: npm run check:rules -- --paths <files you touched>.- It must exit 0.--## Step 0: re-derive the current state--1. This route's declared entry (path, description, added date):-- node -e "const p=require('./data/pages.json');for(const s of p.sections)for(const g of s.pages)if(g.path==='/terminal')console.log(JSON.stringify(g,null,2))"--2. Find the serving implementation: grep "/terminal" in vercel.json (the live- route table server/index.mjs boots from), then list matching files in- pages/ and src/. STRUCTURE.md maps every surface to its directory if the- grep is ambiguous.-3. Production right now:-- curl -so /dev/null -w '%{http_code}\n' https://three.ws/terminal--4. Start (or reuse) the local dev server: npm run dev (vite, port 3000).--## Task: audit this one route end to end, then fix everything found--Route: /terminal ("Mission Control", section "crypto").-Declared purpose: The real-time pump.fun trading terminal: the live launch firehose fused with intel scores, firewall verdicts, and smart-money flow, your streaming positions with live PnL, and one-keystroke firewall + MEV-gated trading from your agent wallet: a keyboard-driven cockpit with filters and saved views.--Drive the page in a real headless browser. Playwright is already a dev-dependency; keep your probe script in the session scratchpad, never in the-repo.--1. Load http://localhost:3000/terminal. Record the HTTP status, every console- error and warning, and every failed network request.-2. Exercise it like a first-time user: click the primary actions, run the- primary flow if one exists, follow the page's internal links. Every button- must do something real; every link must resolve. If the page renders data,- prove in the network log that it came from a live endpoint, not a baked-in- fallback array.-3. States: verify populated, empty, loading, and error states are designed and- reachable. Block the page's primary fetch in Playwright and confirm an- actionable error state appears, not a blank void or a raw exception.-4. Responsive: render at 320, 768, and 1440 px. No horizontal page scroll, no- overlapping or clipped controls.-5. Accessibility basics: one h1; interactive elements are real buttons or- links with visible focus states; images carry alt text; form fields have- labels.-6. Head: a specific title tag and meta description that match the declared- purpose above.-7. Fix every defect at its root in the page's real source files and re-run the- probe until clean. Defects in shared modules are in scope when this route- exercises them.--## Definition of done--- [ ] Local load of /terminal: HTTP 200, zero console errors, zero unhandled- failed requests (a third-party outage must land in a designed fallback,- not a broken page).-- [ ] No dead interactive element on the page: no stub href="#", no button- without a handler, no link to a missing path.-- [ ] Empty, loading, error, and populated states verified.-- [ ] 320 / 768 / 1440 px renders verified clean.-- [ ] Title and meta description present and specific.-- [ ] npm test passes; npm run check:rules -- --paths <touched files> exits 0.-- [ ] Production status from step 0 recorded in the report; if production- needs a deploy to pick up a fix, the report says so (deploys stay- owner-gated).--## Never blocked--| Blocker | Resolution (act, do not ask) |-|---|---|-| Missing env var or credential | Check .env and .env.local, then the Cloud Run service env, then Secret Manager (the CLAUDE.md self-unblock playbook has the exact commands). If it truly exists nowhere, wire the code fully behind the env var, prove the wiring with a dry run, and name the single missing var in the report. |-| gcloud not on PATH | Run: export PATH="$HOME/google-cloud-sdk/bin:$PATH" |-| Dev server port 3000 busy | Another agent may be serving this repo; probe it and reuse if so. Otherwise start your own on a free port: npx vite --port 3101 |-| Playwright browser missing | npx playwright install chromium |-| A surface needs a signed-in user | Register a fresh account through the real /register flow against the real API and use it. Never mock the session. |-| A defect sits in code you did not touch | Fix it if it blocks a Definition of done line (root cause it, never mask it). Otherwise note it in the report and continue. |-| An unrelated test is red | Same rule. Never pipe npm test through tail; it masks exit codes. |--## Close out (required)--1. Verify every Definition of done line with the actual command output in- front of you. Never claim a line you did not verify.-2. Commit with explicit paths and a subject that describes the diff (house- style: type(scope): what changed and why a reader cares).-3. Delete this prompt file in that same commit:-- git rm prompts/swarm-100/route-terminal.md-- The shrinking directory is this campaign's only progress ledger; there is- no progress log to update.-4. Final report: what step 0 measured, what changed (file list), evidence per- Definition of done line, and any one-line judgment calls. No trailing- questions, no unexecuted plans.--If a line genuinely cannot pass inside this session (an external party must-respond, or an owner-gated action is the final step), finish everything else,-leave this file in place, and state exactly which line remains and who owns-it. Never delete this file on a partial.diff --git a/src/mission-control/focus.js b/src/mission-control/focus.jsindex ea2ceecfb..cc6dee8bf 100644--- a/src/mission-control/focus.js+++ b/src/mission-control/focus.js@@ -21,6 +21,7 @@*/import { createSafetyPanel } from '../shared/safety-panel.js';+import { proxiedImageURL } from '../ipfs.js';import { mountPriceChart } from './chart.js';import { mountTradesTape } from './trades-tape.js';import { buy, sell, quote } from './trade.js';@@ -110,11 +111,29 @@ export function createFocusPane({ store, bus, enrich, mount }) {});}- async function fetchCoin(mint) {+ // A seconds-old launch can be missing from pump.fun for a moment, in which+ // case the server answers 5xx with a Retry-After. The head already renders+ // from the feed row, so the detail is retried once when upstream says to,+ // and only if this coin is still the one in focus.+ let coinRetryTimer = null;+ async function fetchCoin(mint, { retry = true } = {}) {+ clearTimeout(coinRetryTimer);try {- const r = await fetch(`/api/pump/coin?mint=${encodeURIComponent(mint)}`, { headers: { accept: 'application/json' } });- if (!r.ok) return null;- return await r.json();+ const r = await fetch(`/api/pump/coin?mint=${encodeURIComponent(mint)}`, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(10_000) });+ if (r.ok) return await r.json();+ if (retry && r.status >= 500) {+ const after = Math.min(60, Math.max(5, Number(r.headers.get('retry-after')) || 15)) * 1000;+ const mySeq = seq;+ coinRetryTimer = setTimeout(() => {+ if (mySeq !== seq || currentMint !== mint) return;+ fetchCoin(mint, { retry: false }).then((coin) => {+ if (mySeq !== seq || !coin) return;+ coinDetail = coin;+ updateHead(store.getRow(mint) || { mint });+ });+ }, after);+ }+ return null;} catch { return null; }}@@ -185,7 +204,11 @@ export function createFocusPane({ store, bus, enrich, mount }) {const mint = row.mint;const sym = escapeHtml(row.symbol || coin.symbol || mint.slice(0, 4));const name = escapeHtml(row.name || coin.name || '');- const img = row.image_uri || coin.image_uri || coin.image || '';+ // Token art lives on public IPFS gateways that refuse browser image+ // requests (ipfs.io answers 403 with a same-origin resource policy), so+ // it is served through the same-origin /api/img proxy, which always+ // returns a valid image and never logs a blocked request.+ const img = proxiedImageURL(row.image_uri || coin.image_uri || coin.image || '', mint);const mcUsd = coin.usd_market_cap ?? coin.market_cap ?? row.market_cap_usd ?? null;const created = coin.created_timestamp ? Math.floor(coin.created_timestamp / 1000) : row.created_at;const intel = row.intel && !row.intel._none ? row.intel : null;@@ -197,7 +220,7 @@ export function createFocusPane({ store, bus, enrich, mount }) {].filter(Boolean);head.innerHTML = `- ${img ? `<img class="mc-focus-img" src="${escapeHtml(img)}" alt="" loading="lazy" data-fallback="invisible" />` : '<div class="mc-focus-img" aria-hidden="true"></div>'}+ ${img ? `<img class="mc-focus-img" src="${escapeHtml(img)}" alt="" loading="lazy" decoding="async" />` : '<div class="mc-focus-img" aria-hidden="true"></div>'}<div class="mc-focus-id"><h2>${sym} <span class="mc-focus-name">${name}</span></h2><div class="mc-focus-addr">@@ -328,6 +351,20 @@ export function createFocusPane({ store, bus, enrich, mount }) {function mountTrade() {const host = $('[data-host="trade"]');if (!host) return;+ if (!store.getAgent()) {+ // No wallet to trade from: say exactly what unlocks the desk instead of+ // rendering buy/sell buttons that can only refuse.+ const cta = store.isSignedIn()+ ? { href: '/create-agent', label: 'Create an agent wallet', body: 'Trades are signed by an agent wallet you own. Create one and it appears in the top bar.' }+ : { href: '/login?next=%2Fterminal', label: 'Sign in to trade', body: 'Sign in to buy and sell from your agent wallet, firewall and MEV gated on every order.' };+ host.innerHTML = `+ <div class="mc-section-h">Trade</div>+ <div class="mc-trade-cta">+ <p>${cta.body}</p>+ <a class="mc-btn mc-btn--buy" href="${cta.href}">${cta.label}</a>+ </div>`;+ return;+ }const presets = store.getPresets();const active = store.getActiveSize();host.innerHTML = `@@ -425,6 +462,7 @@ export function createFocusPane({ store, bus, enrich, mount }) {teardownChart();teardownTape();clearTimeout(quoteTimer);+ clearTimeout(coinRetryTimer);unsubs.forEach((u) => u());},};diff --git a/src/mission-control/index.js b/src/mission-control/index.jsindex 099f947cb..981431206 100644--- a/src/mission-control/index.js+++ b/src/mission-control/index.js@@ -40,22 +40,23 @@ export function mountMissionControl(root, opts = {}) {let balanceTimer = null;const cleanups = [];let destroyed = false;+ let autoSelecting = false;root.innerHTML = `<div class="mc-root" data-host="mc"><div class="mc-empty" style="height:100%"><div class="mc-empty-ico">◎</div><h3>Booting Mission Control…</h3><p>Connecting to the live launch firehose.</p></div></div>`;const rootEl = root.querySelector('[data-host="mc"]');(async () => {- // Resolve session + agents in parallel; either failing degrades gracefully+ // Resolve the session first and ask for agents only when someone is+ // signed in: /api/agents answers 401 to an anonymous visitor, and the+ // browser logs every 4xx to the console. Either call failing degrades// to a read-only cockpit rather than a dead page.- const [user, agents] = await Promise.all([- getMe().catch(() => null),- loadUserAgents().catch(() => []),- ]);+ const user = await getMe().catch(() => null);+ const agents = user ? await loadUserAgents().catch(() => []) : [];if (destroyed) return;const tradable = (agents || []).filter((a) => a && (a.solana_address || a.meta?.solana_address || a.wallet_ready || a.walletReady));- store = createStore({ bus, userId: user?.id || 'anon' });+ store = createStore({ bus, userId: user?.id || 'anon', signedIn: !!user });enricher = createEnricher({ store });if (opts.network === 'devnet') store.setNetwork('devnet');if (tradable[0]) store.setAgent(normalizeAgent(tradable[0]));@@ -86,6 +87,11 @@ export function mountMissionControl(root, opts = {}) {</div>`;+ // The connection pills subscribe before any pane exists, so the very+ // first state a pane publishes (the positions pane's "idle" for a visitor+ // with no agent, emitted synchronously on creation) is never lost.+ wireConnPills();+// panesconst feed = createFeedPane({ store, bus, enrich: enricher, mount: rootEl.querySelector('[data-host="feed"]') });const focus = createFocusPane({ store, bus, enrich: enricher, mount: rootEl.querySelector('[data-host="focus"]') });@@ -95,12 +101,16 @@ export function mountMissionControl(root, opts = {}) {wireTopbar({ agents });wireMobileBar();- wireConnPills();wireExpressBadge();- // Auto-select the first launch that streams in (one-shot) for instant signal.+ // Auto-select the first launch that streams in (one-shot) for instant+ // signal. It is flagged so the phone layout keeps showing the feed the+ // user just opened; only a selection the user makes jumps to Focus.const offFirst = bus.on('feed:add', (row) => {- if (!store.getSelected()) { store.select(row.mint); }+ if (!store.getSelected()) {+ autoSelecting = true;+ try { store.select(row.mint); } finally { autoSelecting = false; }+ }offFirst();});cleanups.push(offFirst);@@ -127,7 +137,7 @@ export function mountMissionControl(root, opts = {}) {<div class="mc-topbar"><a class="mc-brand" href="/" title="three.ws home"><img class="mc-brand-logo" src="/three.svg" alt="" width="22" height="22" loading="eager" decoding="async" />- <b>Mission Control</b><span>Terminal</span>+ <h1>Mission Control</h1><span>Terminal</span></a><span class="mc-topbar-spacer"></span><span class="mc-balance" data-host="balance" hidden>◎ <b data-host="balsol">—</b></span>@@ -138,6 +148,7 @@ export function mountMissionControl(root, opts = {}) {<option value="devnet">Devnet</option></select></label>+ <lang-switcher compact></lang-switcher><div class="mc-conn-group"><span class="mc-conn" data-host="conn-feed" data-state="reconnecting"><span class="mc-conn-dot"></span>Feed</span><span class="mc-conn" data-host="conn-pos" data-state="reconnecting"><span class="mc-conn-dot"></span>Positions</span>@@ -174,6 +185,7 @@ export function mountMissionControl(root, opts = {}) {setActive('feed');// jump to Focus on the phone when a coin is pickedcleanups.push(bus.on('select', () => {+ if (autoSelecting) return;if (window.matchMedia('(max-width: 760px)').matches) setActive('focus');}));}diff --git a/src/mission-control/positions.js b/src/mission-control/positions.jsindex e0854e684..4969cb1ed 100644--- a/src/mission-control/positions.js+++ b/src/mission-control/positions.js@@ -154,6 +154,14 @@ export function createPositionsPane({ store, bus, mount }) {// ── stream ───────────────────────────────────────────────────────────────────function startStream() {+ if (!agentId) {+ // Nothing to follow without an agent: holding an SSE connection open+ // for an anonymous visitor would only burn a stream slot. The pill+ // reads "idle" rather than pretending to reconnect forever.+ connState = 'idle';+ bus.emit('conn:positions', 'idle');+ return;+ }sse = createSseClient({url: `/api/sniper/stream?network=${store.getNetwork()}`,onState: (s) => { connState = s; bus.emit('conn:positions', s); scheduleRender(); },@@ -223,7 +231,9 @@ export function createPositionsPane({ store, bus, mount }) {tweenSummaryTo(unreal);if (!store.getAgent()) {- body.innerHTML = stateHtml('◎', 'No agent selected', 'Pick a trading agent in the top bar to see its live positions.');+ body.innerHTML = store.isSignedIn()+ ? stateHtml('◎', 'No agent wallet yet', 'Create an agent wallet and its live positions and PnL stream here.', { href: '/create-agent', label: 'Create an agent wallet' })+ : stateHtml('◎', 'Sign in to see positions', 'Your agent wallet\'s open positions, live PnL, and recent exits stream here once you sign in.', { href: '/login?next=%2Fterminal', label: 'Sign in' });return;}if (!open.length && !closed.length) {@@ -298,8 +308,9 @@ export function createPositionsPane({ store, bus, mount }) {</div>`;}- function stateHtml(ico, title, msg) {- return `<div class="mc-empty"><div class="mc-empty-ico" aria-hidden="true">${ico}</div><h3>${title}</h3><p>${msg}</p></div>`;+ function stateHtml(ico, title, msg, link = null) {+ const action = link ? `<a class="mc-chipbtn" href="${escapeHtml(link.href)}">${escapeHtml(link.label)}</a>` : '';+ return `<div class="mc-empty"><div class="mc-empty-ico" aria-hidden="true">${ico}</div><h3>${title}</h3><p>${msg}</p>${action}</div>`;}function cssEscape(s) { return (window.CSS && CSS.escape) ? CSS.escape(s) : String(s).replace(/"/g, '\\"'); }diff --git a/src/mission-control/store.js b/src/mission-control/store.jsindex cfd75f2ce..2ae8baff7 100644--- a/src/mission-control/store.js+++ b/src/mission-control/store.js@@ -48,7 +48,7 @@ function writeLocal(key, value) {}}-export function createStore({ bus, userId = 'anon' }) {+export function createStore({ bus, userId = 'anon', signedIn = false }) {const order = []; // mints, newest firstconst rows = new Map(); // mint -> rowlet filters = { ...DEFAULT_FILTERS };@@ -177,7 +177,9 @@ export function createStore({ bus, userId = 'anon' }) {bus.emit('select', mint);},- // ── agent / network ───────────────────────────────────────────────────+ // ── session / agent / network ─────────────────────────────────────────+ /** Whether a user is signed in (drives the sign-in vs create-wallet CTAs). */+ isSignedIn: () => signedIn,getAgent: () => agent,setAgent(next) {agent = next;diff --git a/src/mission-control/styles.js b/src/mission-control/styles.jsindex 84b4871c0..6d8eb76b2 100644--- a/src/mission-control/styles.js+++ b/src/mission-control/styles.js@@ -28,15 +28,20 @@ const CSS = `.mc-topbar { display: flex; align-items: center; gap: var(--space-3,12px); padding: 8px 14px; border-bottom: 1px solid var(--stroke, rgba(255,255,255,.08)); background: var(--surface-1, rgba(255,255,255,.02)); flex: none; min-height: 50px; }.mc-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink-bright, #fff); letter-spacing: .02em; text-decoration: none; white-space: nowrap; }.mc-brand-logo { width: 22px; height: 22px; border-radius: 6px; }-.mc-brand b { font-family: var(--font-display, system-ui); font-size: var(--text-md,.8125rem); }+.mc-brand h1 { margin: 0; font-family: var(--font-display, system-ui); font-size: var(--text-md,.8125rem); font-weight: 700; line-height: 1; }.mc-brand span { color: var(--ink-dim,#888); font-weight: 600; font-size: var(--text-2xs,.6875rem); text-transform: uppercase; letter-spacing: .08em; padding: 2px 6px; border: 1px solid var(--stroke,rgba(255,255,255,.1)); border-radius: var(--radius-pill,999px); }.mc-topbar-spacer { flex: 1 1 auto; }.mc-conn-group { display: flex; align-items: center; gap: 10px; }+.mc-topbar lang-switcher { display: inline-flex; align-items: center; min-width: 0; }.mc-conn { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-2xs,.6875rem); color: var(--ink-dim,#888); white-space: nowrap; }.mc-conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint,#8a8a8a); flex: none; transition: background var(--duration-fast,140ms); }.mc-conn[data-state="live"] .mc-conn-dot { background: var(--success,#4ade80); box-shadow: 0 0 6px color-mix(in srgb, var(--success,#4ade80) 70%, transparent); animation: mc-breathe 2.4s ease-in-out infinite; }.mc-conn[data-state="reconnecting"] .mc-conn-dot { background: var(--warn,#fbbf24); animation: mc-pulse 1s ease-in-out infinite; }.mc-conn[data-state="down"] .mc-conn-dot { background: var(--danger,#f87171); }+/* Idle dims the dot, never the label: at 11px the label needs the full+ --ink-dim to clear 4.5:1 on the bar, and a whole-chip opacity of .55 put+ "Positions" at 2.41:1 (the a11y floor caught it on /terminal). */+.mc-conn[data-state="idle"] .mc-conn-dot { background: var(--ink-faint,#8a8a8a); opacity: .55; }.mc-ctrl { display: inline-flex; align-items: center; gap: 6px; }.mc-select, .mc-iconbtn { font: inherit; font-size: var(--text-sm,.764rem); color: var(--ink,#e8e8e8); background: var(--surface-2, rgba(255,255,255,.05)); border: 1px solid var(--stroke,rgba(255,255,255,.1)); border-radius: var(--radius-sm,6px); padding: 5px 9px; cursor: pointer; }.mc-select:hover, .mc-iconbtn:hover { border-color: var(--stroke-strong, rgba(255,255,255,.18)); }@@ -207,6 +212,9 @@ const CSS = `.mc-btn--buy:hover:not(:disabled) { background: color-mix(in srgb, var(--success,#4ade80) 88%, #fff); }.mc-btn--sell { background: color-mix(in srgb, var(--danger,#f87171) 18%, transparent); color: var(--danger,#f87171); border-color: color-mix(in srgb, var(--danger,#f87171) 45%, transparent); }.mc-btn--sell:hover:not(:disabled) { background: color-mix(in srgb, var(--danger,#f87171) 28%, transparent); }+a.mc-btn { text-decoration: none; }+.mc-trade-cta { display: flex; flex-direction: column; gap: 10px; }+.mc-trade-cta p { margin: 0; color: var(--ink-dim,#888); font-size: var(--text-sm,.764rem); line-height: 1.5; }.mc-btn kbd { font-family: var(--font-mono,ui-monospace,monospace); font-size: .8em; opacity: .7; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; }.mc-trade-note { font-size: var(--text-sm,.764rem); line-height: 1.45; min-height: 1.2em; }.mc-trade-note.is-err { color: var(--danger,#f87171); } .mc-trade-note.is-warn { color: var(--warn,#fbbf24); } .mc-trade-note.is-ok { color: var(--success,#4ade80); } .mc-trade-note.is-dim { color: var(--ink-dim,#888); }