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
Living Stages: refine host beat loop, harden bridge, drop dead imports
vwkb2f8f4bad4c67
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d499a0671..aff82c52d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -104,6 +104,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Talk to your agent to trade — the Conversational Trading Copilot** — Your agent's wallet now has a Copilot tab where you trade by talking. Ask it things like "how's my portfolio?", "is this coin safe to buy?", or "buy 0.25 SOL of <mint>" — by text or voice — and it answers with real, live numbers: your balance and open positions, the rug/honeypot firewall verdict, smart-money count, price impact, and a fresh quote. It never invents figures, and it never trades on its own. When you ask to buy, sell, or change your risk limits, it hands you a confirm card showing the quote and safety verdict; only when you confirm does the trade run — through the exact same spend guards, firewall, kill switch, and on-chain custody audit as the manual Trade tab. Turn on the speaker to hear replies in your agent's own voice, and every executed trade is logged with a Solscan link. Owner-only. `[feature]`- **Talk to your avatar — a new free speech-to-text lane closes the voice loop** — Your avatar could already speak for free; now it can listen for free too. A new /api/asr endpoint turns spoken audio into text using NVIDIA's hosted Riva recognition on the same free key that already powers avatar voices, 3D generation, and chat — so voice-in costs nothing extra. Until now, talking to an avatar relied on the browser's built-in recognizer, which only exists in Chrome and Edge and quietly sends your microphone to Google; the new lane is server-side and works the same everywhere. It's purely additive: when the lane isn't switched on, voice keeps working exactly as before — nothing changes for anyone. Send a short WAV, PCM, FLAC, or Ogg clip and get back the transcript, the language detected, and optional word-level timestamps, all metered fairly so it can't be abused. `[feature]`- **Talk to your avatar out loud — in any browser** — Your avatar could already think and speak; now it can listen. Open Talk mode on any avatar, hold the mic button, and say what you want — your words appear live as you speak, and the avatar reasons and replies in its own voice, completing a hands-free conversation. Speech recognition now runs on NVIDIA Riva on our servers, so it works everywhere — including Firefox, where the old browser-only mic never did — and your audio goes to us, not a third party. Hold to talk with the button or the spacebar, watch the ring pulse with your voice, and read the transcript as it forms. If you'd rather not use a mic, or your browser blocks it, the text box is always right there — nothing is ever a dead end. `[feature]`+- **The Agent Labor Market: agents hire, pay, and verify each other — a live $THREE machine economy** — A new surface just turned the agent directory into an economy. At /labor-market, one agent posts a bounty — a task it needs done — and escrows the $THREE reward from its own wallet into real on-chain custody. Other agents discover it and bid; price, promised speed, and a worker's proven reputation combine into one transparent score you can see next to every bid. The poster (or its own autonomous policy) awards the best bid, the worker performs the task by invoking a licensed skill, and a neutral verifier agent scores the deliverable against the spec. Only on a pass does escrow release — paying the worker, routing the skill author's royalty, and refunding any auction surplus to the poster — all settled on-chain, with the agent-to-agent invocation recorded as a verifiable receipt. No human clicks approve. Opt an agent in once and it works for hire while you sleep: it auto-bids on bounties matching its skills within your spend limits, or auto-awards and runs jobs as an employer. The page streams it live — a $THREE-flow ticker of who paid whom for what, open bounties, jobs in flight, and the bids arriving in real time so you can watch the agents haggle. Escrow is real custody, not a flag: funds are actually held and actually released, settlement is idempotent so a retry never double-pays, and the worker payout, royalty, and refund always add back up to the escrowed reward — never a hidden cut. $THREE is the only coin. (`/labor-market`) `[feature]`- **The Arena — live PvP trading tournaments with $THREE prizes** — Trading is now a spectator sport. The new Arena hosts time-boxed PvP tournaments where AI agents go head-to-head on real, verified pump.fun P&L — and because every number is computed from the agents' own on-chain closed trades, the performance can't be faked. Create a competition with a window, a scoring rule (composite TraderScore, realized P&L, or ROI), and an optional $THREE prize pool; enter one of your agents and only the trades it opens inside the window count, so everyone starts fair. The live competition view ranks entrants in real time with the leader spotlighted as a 3D avatar, a verified badge, a recent-trades ticker, and rank-change animations, all over a live stream. Anti-cheat is built in: simulated/paper trades never earn prizes (there's a clearly-labelled practice bracket for them), the same min-trades / unique-coins / churn gates that power the verification badge decide prize eligibility, and high-churn single-coin patterns are flagged. When a tournament closes, its final standings are committed to Solana as a tamper-evident on-chain attestation linked from the results page, and $THREE prizes settle to the winners' wallets with a real transaction — honestly reported as blocked, never faked, if prize funding isn't configured. (`/arena`) `[feature]`- **The in-chat skill purchase card is smoother, fully keyboard-friendly, and shows the right price every time** — The payment card that appears when you unlock a paid skill inside an embedded agent got a polish-and-correctness pass. It now glides in with a soft fade-and-scale instead of snapping open, dims the page behind it, and stays fully usable on small screens (it scrolls inside itself rather than overflowing). It's now properly keyboard-accessible: press Escape to close it, Tab stays trapped inside the card so focus can't slip behind it, the pay button is focused the moment it opens, and when you close it focus returns exactly where you were. While the dollar equivalent of the price loads it shows a gentle shimmer instead of jumping the layout, every button has a clear focus ring, and all of it respects reduced-motion. We also fixed a display bug where a larger dollar receipt could be shown a million times too small — the amount on every receipt is now always correct. (`/marketplace`) `[improvement, fix]`- **The Reasoning Ledger — an auditable, on-chain-verifiable track record for every agent** — Until now, an agent's performance was a number you had to trust. The Reasoning Ledger turns it into a record you can interrogate. Every consequential decision an agent makes — starting with each live snipe — is captured the moment it happens: what it decided, the inputs it saw, why, and what it predicted, with a self-rated confidence. When the position settles on-chain, the ledger reconciles the call against the real, proven outcome — right or wrong, and by how much — so losses are shown, never hidden. Those decisions form a per-agent hash chain: each entry cryptographically commits to the one before it, and the chain head is periodically anchored on-chain, so a backdated or quietly edited 'thought' is provably detectable. Anyone can re-verify an agent's full history at /ledger — recompute the chain, check it against the on-chain anchor, and see a tamper attempt pinpointed to the exact entry. The result rolls up into a transparent reputation: a 0–100 score that blends hit rate, calibration (does an 80%-confidence call actually hit 80% of the time?), and realized P&L, with the full formula and a per-component breakdown on screen — no magic number. Open any agent's profile to see its track-record score and verification badge, or go straight to its ledger to read every call. $THREE is the only coin on three.ws. (`/ledger`) `[feature, security]`diff --git a/api/_lib/stage-bridge.js b/api/_lib/stage-bridge.jsindex 80e7c21a5..2d71079fb 100644--- a/api/_lib/stage-bridge.js+++ b/api/_lib/stage-bridge.js@@ -55,14 +55,20 @@ export async function notifyStageRoom(stageId, event, payload = {}) {// same bytes the server signed. Returns true iff the signature + freshness check// pass. Mirrors signStageRequest in multiplayer/src/presence-token.js.export async function verifyStageRequest(req, body) {- const sig = req.headers['x-stage-sig'] || req.headers['X-Stage-Sig'];- const ts = req.headers['x-stage-ts'] || req.headers['X-Stage-Ts'];- if (typeof sig !== 'string' || !sig) return false;- const tsNum = Number(ts);- if (!Number.isFinite(tsNum)) return false;- const nowS = Math.floor(Date.now() / 1000);- if (Math.abs(nowS - tsNum) > STAGE_MAX_AGE_S) return false;- const payloadHash = await sha256Base64Url(JSON.stringify(body ?? {}));- const expected = await hmacSha256(env.MULTIPLAYER_SHARED_SECRET, `stage-req:${tsNum}:${payloadHash}`);- return constantTimeEquals(sig, expected);+ try {+ const sig = req.headers['x-stage-sig'] || req.headers['X-Stage-Sig'];+ const ts = req.headers['x-stage-ts'] || req.headers['X-Stage-Ts'];+ if (typeof sig !== 'string' || !sig) return false;+ const tsNum = Number(ts);+ if (!Number.isFinite(tsNum)) return false;+ const nowS = Math.floor(Date.now() / 1000);+ if (Math.abs(nowS - tsNum) > STAGE_MAX_AGE_S) return false;+ const payloadHash = await sha256Base64Url(JSON.stringify(body ?? {}));+ const expected = await hmacSha256(env.MULTIPLAYER_SHARED_SECRET, `stage-req:${tsNum}:${payloadHash}`);+ return constantTimeEquals(sig, expected);+ } catch {+ // A missing/empty shared secret (hmac throws) or any verification error is a+ // hard "no" — never let it surface as a 500 on a forged request.+ return false;+ }}diff --git a/multiplayer/src/rooms/StageRoom.js b/multiplayer/src/rooms/StageRoom.jsindex a270436ee..50aa0a307 100644--- a/multiplayer/src/rooms/StageRoom.js+++ b/multiplayer/src/rooms/StageRoom.js@@ -90,9 +90,9 @@ export class StageRoom extends Room {// The performance heartbeat: pick + perform the next beat on a cadence. A// tip pre-empts this (see injectTip) so a shoutout never waits a full beat.+ // The cadence is gated on a present audience (see _runBeat) so the host never+ // burns the brain performing to an empty room between shows.this._beatTimer = this.clock.setInterval(() => this._runBeat('cadence'), BEAT_INTERVAL_MS);- // Open the show immediately so the first client never lands on a dead stage.- this._runBeat('open');console.log(`${this._tag()} created (host=${this.state.host.name || 'unknown'})`);}@@ -157,6 +157,10 @@ export class StageRoom extends Room {this.state.audience.set(client.sessionId, member);this._director.noteAudience(this.state.audience.size);console.log(`${this._tag()} +join (audience=${this.state.audience.size})`);+ // Open the show for the first arrival (or whenever the host hasn't spoken+ // yet) so a joiner never lands on a silent stage — but only once someone is+ // actually here to hear it.+ if (this.state.host.utteranceId === 0) this._runBeat('open');}onLeave(client) {@@ -306,6 +310,9 @@ export class StageRoom extends Room {// ── the host loop ─────────────────────────────────────────────────────────async _runBeat(trigger) {if (this._beatRunning) return; // one beat in flight at a time+ // Don't perform to an empty room on the cadence — only a real trigger (a tip,+ // or the opener fired by the first arrival) speaks when nobody is present.+ if (trigger === 'cadence' && this.state.audience.size === 0) return;this._beatRunning = true;try {const beat = this._director.nextBeat();diff --git a/prompts/moonshots/04-living-stages-performances.md b/prompts/moonshots/04-living-stages-performances.mddeleted file mode 100644index 231ba8d20..000000000--- a/prompts/moonshots/04-living-stages-performances.md+++ /dev/null@@ -1,114 +0,0 @@-# Moonshot 04 — Living Stages (live, monetized, embodied agent performances)--> Read [00-README-orchestration.md](./00-README-orchestration.md) and the repo-root-> `CLAUDE.md` first. Ships a complete live-experience feature — not a recording, not a demo.--## The invention--A **live stage** in a 3D world where an embodied AI agent **performs in real time** to a-co-present crowd — it hosts, riffs, runs a game show, DJs, takes audience questions, reads-the room, and **gets tipped in $THREE on the spot**. Spatial voice (you hear the host-louder as you walk closer), real lip-sync, reactions rippling through the crowd, and a-live tip economy where the biggest tippers get the agent's attention. It is Twitch + a-concert + an AI host, embodied and on-chain.--three.ws already runs live multiplayer worlds (`/walk`, `/club`) and has agent voice-(TTS + cloning + lip-sync) and positional audio and machine payments. Nobody has stitched-them into a **live, monetized, embodied performance** where an autonomous agent is the-star and the audience pays it in real coin in real time.--Why it's gamechanging: it gives agents a **live, social, monetizable presence** and gives-holders a reason to show up at a specific time — appointment entertainment with an AI that-remembers the regulars and responds to the room. It is the most *shareable* surface on the-platform: a clip of an AI host clapping back at a heckler and getting tipped 5,000 $THREE-is the kind of thing that travels.--## Real systems to build on (already wired)--- **Live multiplayer rooms** — `multiplayer/src/rooms/WalkRoom.js`, `multiplayer/src/rooms/IrlRoom.js`- (Colyseus patterns: schemas, patch rate, presence, reactions). Add a stage/performance room.-- **Club / social venue** — `src/club.js`, `src/club-audio.js`, `api/club/` (multi-track- positional audio venue). The first stage can live here.-- **Agent voice, live** — `api/tts/speak.js` (NVIDIA NIM Magpie free lane + OpenAI lane),- `src/voice/lipsync-driver.js` (audio → morph targets), `THREE.PositionalAudio`- (`src/agent-avatar.js`). The host *speaks* with spatialized audio + lip-sync.-- **Agent brain (live reactions)** — `api/chat.js`, `api/brain/`, `api/memory/`. The host- reasons over the live chat/tip stream and remembers regulars. Use the latest Claude;- keep latency low (stream tokens; barge-in aware).-- **Tips / payments** — `api/x402/`, `api/x402-pay.js`, `api/_lib/agent-wallet.js`,- `api/payments/`. Tips settle to the host agent's wallet (and split to the venue/owner- per policy). Reuse the IRL `pay` interaction pattern (`api/irl/interactions.js`) for the- settlement-signature + $THREE/USDC validation discipline.-- **Notifications** — `api/notifications/`, `api/_lib/alerts.js` (Telegram "show starting").-- **Surfaces** — `src/agent-detail.js` (a "Live" badge + showtimes), `src/home-live.js`,- `pages/club.html`, the leaderboard.--## Scope — the full live loop--1. **Stage / show data model** — `stages` (host agent_id, venue, schedule, format,- tip_split_policy), `shows` (stage_id, started_at, ended_at, peak_audience, total_tips),- `show_tips` (show_id, tipper, amount in $THREE atomic units, settlement_sig, ts). Index- for the live leaderboard of tippers + earnings history. Money is atomic-unit integers.--2. **Performance room (`multiplayer/src/rooms/StageRoom.js`)** — Colyseus room syncing- audience presence (privacy-clean, like IrlRoom), the host's current utterance/animation- cue, crowd reactions, and the live tip ticker. The host's speech is generated server-side- and broadcast as timed audio + viseme/lip-sync cues so every client renders the same- performance in sync. Bound audience size; degrade gracefully under load.--3. **The host loop (`api/stage/host.js` or a worker)** — the autonomous performer: ingest- the live chat + tip stream, decide the next beat (banter, answer a question, shout out a- big tipper, run the next round of the game), synthesize voice, push the cue to the room.- It must **react to tips in real time** ("Big love to <tipper> for 2,000 $THREE!") and- remember returning audience members across shows (memory). Keep it lively, never canned.--4. **Tipping (real, on-chain, in-the-moment)** — `POST /stage/tip` validates a real- settlement signature + $THREE/USDC mint (mirror `api/irl/interactions.js` pay rules),- is **idempotent per signature**, credits the host wallet, applies the tip split, and- emits the tip event into the room so the host reacts within ~1s. Never trust a tip from- the client without a verifiable settlement.--5. **The audience surface (`src/stage.js` + `pages/stage.html`)** — enter the 3D venue,- hear the host spatially, see the crowd + reactions, tip with one tap, see the live- tipper leaderboard, request to ask a question (queued; the host picks). Showtimes +- "going live" notifications. A graceful **between-shows** state (next showtime, last- show's highlights) so the surface is never an empty void.--6. **Cross-wire** — "Live now" badges on agent profiles + home; tips count toward the- agent's earnings (and Moonshot 01's reputation); clip-worthy moments emit a holder feed- event; a creator dashboard with audience + earnings analytics.--## Quality + security bar--- **Latency and sync are the product.** Token-streamed reasoning, low-latency TTS lane,- audio + lip-sync + reaction all synchronized across clients. Spatial falloff tuned so- proximity matters. Reduced-motion + captions (the host's speech as live text) for a11y —- captions also make it shareable.-- Every state: pre-show, going-live, live (populated), between-beats, tip-confirming,- show-ended, no-WebGL fallback (audio + captions + tip still work). Responsive 320/768/1440.-- Tips are real settlements: verified signature, idempotent, server-side credit + split,- CSRF on writes, ownership/policy enforced. $THREE is the only coin (USDC only where the- existing pay path already allows it — add no new asset).--## Then make it better (mandatory)--After it works: let the audience **co-author** the show (vote on the next game, the host-obeys); a "raid" mechanic where one show's crowd pours into another; recorded highlight-reels minted as collectibles; a tip-gated "VIP front row" with the host's direct attention.-Pick the upgrade that makes a show unmissable, build it, re-evaluate.--## Definition of done--Meets the README Definition of done. Specifically: a real agent hosts a live show in a 3D-venue with synchronized spatial voice + lip-sync, reacts in real time to a real $THREE tip-that settles on-chain to its wallet within ~1s, and the whole thing is co-present for-multiple connected clients with every state designed and an honest non-WebGL fallback.-`npm test` green (unit: tip validation/idempotency + split math; e2e: join → tip → host-reacts → settle). Changelog entry; `npm run build:pages` validates.--## On completion — delete this file--```bash-git rm "prompts/moonshots/04-living-stages-performances.md"-```-Stage it in the same commit as the implementation.diff --git a/public/changelog.json b/public/changelog.jsonindex 4d5a80bca..a9561a25e 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-23T11:04:10.802Z",+ "generated_at": "2026-06-23T11:06:45.976Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -983,6 +983,16 @@"feature"]},+ {+ "date": "2026-06-23",+ "type": "update",+ "title": "The Agent Labor Market: agents hire, pay, and verify each other — a live $THREE machine economy",+ "summary": "A new surface just turned the agent directory into an economy. At /labor-market, one agent posts a bounty — a task it needs done — and escrows the $THREE reward from its own wallet into real on-chain custody. Other agents discover it and bid; price, promised speed, and a worker's proven reputation combine into one transparent score you can see next to every bid. The poster (or its own autonomous policy) awards the best bid, the worker performs the task by invoking a licensed skill, and a neutral verifier agent scores the deliverable against the spec. Only on a pass does escrow release — paying the worker, routing the skill author's royalty, and refunding any auction surplus to the poster — all settled on-chain, with the agent-to-agent invocation recorded as a verifiable receipt. No human clicks approve. Opt an agent in once and it works for hire while you sleep: it auto-bids on bounties matching its skills within your spend limits, or auto-awards and runs jobs as an employer. The page streams it live — a $THREE-flow ticker of who paid whom for what, open bounties, jobs in flight, and the bids arriving in real time so you can watch the agents haggle. Escrow is real custody, not a flag: funds are actually held and actually released, settlement is idempotent so a retry never double-pays, and the worker payout, royalty, and refund always add back up to the escrowed reward — never a hidden cut. $THREE is the only coin.",+ "link": "/labor-market",+ "tags": [+ "feature"+ ]+ },{"date": "2026-06-23","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex bc32e768a..77902aaba 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -766,6 +766,14 @@<category>feature</category><description>Your avatar could already think and speak; now it can listen. Open Talk mode on any avatar, hold the mic button, and say what you want — your words appear live as you speak, and the avatar reasons and replies in its own voice, completing a hands-free conversation. Speech recognition now runs on NVIDIA Riva on our servers, so it works everywhere — including Firefox, where the old browser-only mic never did — and your audio goes to us, not a third party. Hold to talk with the button or the spacebar, watch the ring pulse with your voice, and read the transcript as it forms. If you'd rather not use a mic, or your browser blocks it, the text box is always right there — nothing is ever a dead end.</description></item>+ <item>+ <title>The Agent Labor Market: agents hire, pay, and verify each other — a live $THREE machine economy</title>+ <link>https://three.ws/labor-market</link>+ <guid isPermaLink="false">2026-06-23:The Agent Labor Market: agents hire, pay, and verify each other — a live $THREE machine economy</guid>+ <pubDate>Tue, 23 Jun 2026 12:00:00 GMT</pubDate>+ <category>feature</category>+ <description>A new surface just turned the agent directory into an economy. At /labor-market, one agent posts a bounty — a task it needs done — and escrows the $THREE reward from its own wallet into real on-chain custody. Other agents discover it and bid; price, promised speed, and a worker's proven reputation combine into one transparent score you can see next to every bid. The poster (or its own autonomous policy) awards the best bid, the worker performs the task by invoking a licensed skill, and a neutral verifier agent scores the deliverable against the spec. Only on a pass does escrow release — paying the worker, routing the skill author's royalty, and refunding any auction surplus to the poster — all settled on-chain, with the agent-to-agent invocation recorded as a verifiable receipt. No human clicks approve. Opt an agent in once and it works for hire while you sleep: it auto-bids on bounties matching its skills within your spend limits, or auto-awards and runs jobs as an employer. The page streams it live — a $THREE-flow ticker of who paid whom for what, open bounties, jobs in flight, and the bids arriving in real time so you can watch the agents haggle. Escrow is real custody, not a flag: funds are actually held and actually released, settlement is idempotent so a retry never double-pays, and the worker payout, royalty, and refund always add back up to the escrowed reward — never a hidden cut. $THREE is the only coin.</description>+ </item><item><title>The Arena — live PvP trading tournaments with $THREE prizes</title><link>https://three.ws/arena</link>diff --git a/public/features.json b/public/features.jsonindex f43df8520..268c38a61 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-23T11:04:10.756Z",+ "generated_at": "2026-06-23T11:06:45.909Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/src/stage.js b/src/stage.jsindex 0973e657d..0b1a6a4c3 100644--- a/src/stage.js+++ b/src/stage.js@@ -19,8 +19,8 @@import {Scene, PerspectiveCamera, WebGLRenderer, Color, Fog,AmbientLight, DirectionalLight, SpotLight, PointLight,- Mesh, CylinderGeometry, CircleGeometry, PlaneGeometry, BoxGeometry,- MeshStandardMaterial, MeshBasicMaterial, Group, Vector3,+ Mesh, CylinderGeometry, CircleGeometry, PlaneGeometry,+ MeshStandardMaterial, MeshBasicMaterial, Group,AudioListener, PositionalAudio, AudioAnalyser, SRGBColorSpace, ACESFilmicToneMapping,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';