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: harden Solana RPC resolution, tighten 8004 subgraph timeout, graceful avatar-editor 501 handling
nirholas22b8ba33afcd
diff --git a/api/_lib/agent-pumpfun.js b/api/_lib/agent-pumpfun.jsindex ecafe824a..382a58528 100644--- a/api/_lib/agent-pumpfun.js+++ b/api/_lib/agent-pumpfun.js@@ -9,16 +9,34 @@ import {recoverSolanaAgentKeypair,} from './agent-wallet.js';-const RPC = {- mainnet: process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com',- devnet: process.env.SOLANA_RPC_URL_DEVNET || 'https://api.devnet.solana.com',-};-const RPC_PUBLIC = {mainnet: 'https://api.mainnet-beta.solana.com',devnet: 'https://api.devnet.solana.com',};+// Resolve the primary mainnet RPC, preferring a real paid endpoint over the+// public one (which 429s under load). Order:+// 1. SOLANA_RPC_URL, but only when it points at something other than the+// public endpoint — operators sometimes set it to the public URL, which+// is no better than leaving it unset.+// 2. A Helius endpoint derived from HELIUS_API_KEY — the same credential that+// already powers the DAS balance path in balances.js, so one key fixes+// both the portfolio reads and the agent-wallet balance reads.+// 3. The public endpoint as a last resort.+function resolveMainnetRpc() {+ const configured = process.env.SOLANA_RPC_URL;+ if (configured && configured !== RPC_PUBLIC.mainnet) return configured;+ if (process.env.HELIUS_API_KEY) {+ return `https://mainnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`;+ }+ return RPC_PUBLIC.mainnet;+}++const RPC = {+ mainnet: resolveMainnetRpc(),+ devnet: process.env.SOLANA_RPC_URL_DEVNET || RPC_PUBLIC.devnet,+};+export function solanaConnection(network = 'mainnet') {return new Connection(RPC[network] || RPC.mainnet, 'confirmed');}diff --git a/api/agents/8004/agent.js b/api/agents/8004/agent.jsindex c6a6704ee..95757ff05 100644--- a/api/agents/8004/agent.js+++ b/api/agents/8004/agent.js@@ -9,7 +9,10 @@ import { cors, method, error, wrap, json } from '../../_lib/http.js';export const maxDuration = 30;const SUPPORTED_CHAINS = Object.keys(DEFAULT_REGISTRIES).map(Number);-const SUBGRAPH_TIMEOUT_MS = 12_000;+// Match the search endpoint's budget: a 12s timeout never fires on runtimes that+// enforce a ~10s ceiling — the function is killed and 504s before our graceful+// subgraph_timeout path can run. 6s leaves room to map the result and respond.+const SUBGRAPH_TIMEOUT_MS = 6_000;const AGENT_QUERY = `query GetAgent($agentId: String!) {diff --git a/docs/agent-briefs/R-3d-world-fun/R00-program-overview.md b/docs/agent-briefs/R-3d-world-fun/R00-program-overview.mdnew file mode 100644index 000000000..67dd2bfc9--- /dev/null+++ b/docs/agent-briefs/R-3d-world-fun/R00-program-overview.md@@ -0,0 +1,112 @@+# R00 — 3D World "Make It Fun" — program overview & shared architecture (READ FIRST)++> Every agent picking up an `Rxx` brief in this folder MUST read this file first. It is the+> shared context the individual briefs assume. Do not re-decide the stack, the coin rules, or+> the networking pattern — they are settled here. Each `Rxx` brief is a **self-contained agent+> prompt**: paste it into a fresh agent chat and it will have everything it needs alongside+> this overview.++---++## North Star++Turn the existing `/play` 3D worlds from a pretty hangout into a place with things to **do**+together — Roblox-style social play + mini-games + avatar economy, plus a Minecraft-style+shared sandbox. Source roadmap: [`docs/roadmap/3d-world-fun.md`](../../roadmap/3d-world-fun.md).+These briefs are that roadmap, expanded into individual, ready-to-dispatch prompts.++The quality bar from [`CLAUDE.md`](../../../CLAUDE.md) is the law here. Every brief inherits it:++- **No mocks. No fake data. No placeholders.** Real APIs, real endpoints, real on-chain calls.+- **No TODOs, no stubs, no `throw new Error("not implemented")`, no `setTimeout` fake-loading.**+- **Every state is designed** — loading (skeletons over spinners), empty (tells the user what to+ do), error (actionable), populated, overflow.+- **Every interactive element** has hover, active, and focus states; keyboard + touch reachable.+- **The only coin is `$THREE`** (CA `FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`). Never name,+ hardcode, or surface any other token in code, tests, fixtures, copy, or commits. Generic+ coin-agnostic plumbing that takes a runtime mint is the only exception, and even there nothing+ is hardcoded.+- **Done means done.** Walk the Definition of Done in `CLAUDE.md` for every brief before claiming+ completion. If you cannot verify a step, say so explicitly — do not claim done.++A task is **100% complete** only when it is written, wired into the UI, reachable by the user via+navigation, exercised in a real browser with no console errors/warnings, real network calls+succeeding, all states designed, existing tests still passing, and the diff self-reviewed.++---++## Existing assets you MUST mine before writing anything++Do not make agents re-discover these. Read them, match their patterns, extend them.++| System | Files |+|--------|-------|+| `/play` scene | `src/game/coincommunities.js`, `src/game/coincommunities-ui.js`, `src/game/coincommunities.css` |+| `/play` net client | `src/game/community-net.js` |+| Authoritative server | `multiplayer/src/rooms/WalkRoom.js`, `multiplayer/src/schemas.js` |+| Avatars / animation | `src/animation-manager.js`, `public/animations/manifest.json` (70 clips) |+| Accessory GLBs (unwired) | `public/accessories/` (`hat-*`, `glasses-*`, `earrings-*`, `presets.json`) |+| Payments | `api/x402/`, `agent-payments-sdk/`, `solana-agent-sdk/` |++**Reuse-first is a hard rule.** We extend three.js + Colyseus + the WalkRoom and the existing+`/play` client. We do not switch engines and we do not build a second world client. Several+sibling programs share this foundation — see memories `play-game-features-port`,+`w08-world-life-npcs`, and the [`W-world-online`](../W-world-online/) briefs. If a system in+`world.three.ws` (our already-built world framework) does it better, port from there.++---++## The networking pattern every gameplay feature follows (off-schema economy)++This is how `/play` already does fishing/inventory/XP, and how EVERY new server-authoritative+mechanic in this program must be built. Do not invent a second pattern.++- **Synced world state** (player positions, shared objects, who's present) lives in the Colyseus+ `WalkState` schema (`multiplayer/src/schemas.js`) and auto-replicates to all clients.+- **Private/per-player state** (inventory, owned cosmetics, scores, game round data) lives in+ per-client server memory and is pushed to the owning client via targeted messages — not the+ replicated schema — unless all clients genuinely need to see it.+- **Intents flow client→server as messages** (`sendChat`/`sendEmote` style on `community-net.js`).+ The **server is authoritative**: it validates, rate-limits, clamps to world bounds, applies the+ effect, and broadcasts the result. Clients never trust each other.+- **Every new message handler** mirrors the existing chat/emote limiter: per-client rate limit,+ payload validation, world-radius clamps, sane caps. Anti-cheat is not optional.++---++## Phase map & dependency graph++The roadmap's "waves" are these four phases. Within a phase, only parallelize briefs that do not+edit the same file — several touch `WalkRoom.js` / `coincommunities-ui.js`, so stagger those or+have one agent own the shared file for the phase.++| Phase | Theme | Briefs | Run style |+|-------|-------|--------|-----------|+| **1 — Foundation** | Generic shared-object sync + cosmetics rig | R01 → R02 → R03 | Sequential. Unblocks everything. |+| **2 — Social playground** | Reactions, ball, dance floor, mini-games, emote wheel | R04–R09 | Parallel after Phase 1. |+| **3 — Sandbox building** | Persistent Minecraft-style building | R17 → R18 → R19 → R20 | Mostly sequential. |+| **4 — Avatar economy** | Cosmetics shop, x402 purchases, inventory, gating, splits | R21 → R22 → {R23, R24, R25} | R21→R22 sequential, then fan out. |++Brief numbers match the roadmap task numbers exactly (the gaps — no R10–R16 — mirror the+roadmap's own numbering) so anything here traces straight back to `docs/roadmap/3d-world-fun.md`.++```+Phase 1: R01 ──► R02 ──► R03+ │ │ │+Phase 2: └──┬────┴─► R05 (ball) R04 R06 R07 R08 R09 (R04/06/07/08/09 need only R01/R02)+ │+Phase 3: R01 ──► R17 ──► R18 ──► R19 ──► R20 (R18 also needs R02)+Phase 4: R03 ──► R21 ──► R22 ──► R23+ │+ ├──► R25+ (Solana rails) ──► R24+```++## Suggested dispatch order++1. **Phase 1** (R01→R02→R03) — sequential, ~3 chats.+2. **Phase 2** (R04–R09) — parallel, 6 chats. Fastest visible fun.+3. **Phase 3** (R17→R18→R19→R20) — building, 4 chats.+4. **Phase 4** (R21→R22→{R23,R24,R25}) — economy, 5 chats.++Total: 18 briefs. Read this file, then your brief, then the files your brief names — in that order.diff --git a/docs/agent-briefs/R-3d-world-fun/README.md b/docs/agent-briefs/R-3d-world-fun/README.mdnew file mode 100644index 000000000..f38de33f9--- /dev/null+++ b/docs/agent-briefs/R-3d-world-fun/README.md@@ -0,0 +1,56 @@+# R — 3D World "Make It Fun" program++Turn `/play` from a charming hangout into a place with things to **do** together: Roblox-style+social play + mini-games + an avatar economy, plus a Minecraft-style shared sandbox — all+wallet-native to `$THREE`.++Source roadmap: [`docs/roadmap/3d-world-fun.md`](../../roadmap/3d-world-fun.md). Each brief below+is the corresponding roadmap task, expanded into a self-contained agent prompt.++## Read order++1. **[R00 — Program overview & shared architecture](R00-program-overview.md)** — READ FIRST.+ Stack, the off-schema networking pattern, coin rules, phase map, dependency graph, DoD.+ Every other brief assumes it.++## Briefs (one agent each, end-to-end)++### Phase 1 — Foundation (sequential; unblocks everything)++| Brief | Feature | Depends on |+|-------|---------|------------|+| [R01](phase-1/R01-server-world-object-sync.md) | Server: generic world-object state sync | — |+| [R02](phase-1/R02-client-world-objects-manager.md) | Client: WorldObjects manager for /play | R01 |+| [R03](phase-1/R03-cosmetics-accessory-rig.md) | Cosmetics rig: wire accessory GLBs to avatars | — |++### Phase 2 — Social playground (parallel after Phase 1)++| Brief | Feature | Depends on |+|-------|---------|------------|+| [R04](phase-2/R04-emoji-confetti-reactions.md) | Emoji & confetti reactions | — |+| [R05](phase-2/R05-kickable-physics-ball.md) | Kickable physics ball | R01, R02 |+| [R06](phase-2/R06-dance-floor-zone.md) | Dance floor zone | — |+| [R07](phase-2/R07-minigame-king-of-the-totem.md) | Mini-game: King of the Totem | — |+| [R08](phase-2/R08-minigame-tag.md) | Mini-game: Tag | — |+| [R09](phase-2/R09-emote-wheel.md) | Emote wheel (expose all 70 animations) | — |++### Phase 3 — Sandbox building (mostly sequential)++| Brief | Feature | Depends on |+|-------|---------|------------|+| [R17](phase-3/R17-world-object-persistence.md) | Persistence layer for world objects | R01 |+| [R18](phase-3/R18-build-mode-and-placement-ui.md) | Build mode + placement UI | R01, R02 |+| [R19](phase-3/R19-build-netcode-permissions-antigrief.md) | Build netcode hardening + permissions + anti-grief | R17, R18 |+| [R20](phase-3/R20-structures-snapping-sharing.md) | Structures, snapping, and sharing | R18, R19 |++### Phase 4 — Avatar economy (depends on R03 rig + x402 rails)++| Brief | Feature | Depends on |+|-------|---------|------------|+| [R21](phase-4/R21-cosmetics-catalog-shop-ui.md) | Cosmetics catalog + shop UI | R03 |+| [R22](phase-4/R22-x402-purchase-flow.md) | x402 purchase flow | R21 |+| [R23](phase-4/R23-owned-inventory-equip-persistence.md) | Owned-cosmetics inventory + equip persistence | R03, R22 |+| [R24](phase-4/R24-token-gated-worlds.md) | Token-gated worlds | Solana rails |+| [R25](phase-4/R25-creator-revenue-splits.md) | Creator revenue splits + economy polish | R22 |++Suggested build order = phase order. Phase 1 unblocks the most. See R00 for the full graph.diff --git a/docs/agent-briefs/R-3d-world-fun/phase-1/R01-server-world-object-sync.md b/docs/agent-briefs/R-3d-world-fun/phase-1/R01-server-world-object-sync.mdnew file mode 100644index 000000000..66fa17aa5--- /dev/null+++ b/docs/agent-briefs/R-3d-world-fun/phase-1/R01-server-world-object-sync.md@@ -0,0 +1,48 @@+# R01 — Server: generic world-object state sync++**Phase 1 (Foundation) · Depends on: nothing · Unblocks: R02, R05, R17, R18 (the entire object pipeline)**++> Read [`../R00-program-overview.md`](../R00-program-overview.md) and [`CLAUDE.md`](../../../../CLAUDE.md)+> first. Follow the off-schema networking pattern described in R00. Server is authoritative.++## Goal++Extend the multiplayer server so worlds can hold shared, networked **objects** — not just players.+Balls, thrown props, placed build pieces, pickups. This is the single channel every later object+feature (ball, confetti, blocks, props) reuses, so it must be generic and bulletproof.++## Files++- `multiplayer/src/schemas.js` — add the `WorldObject` schema + `objects` map on world state.+- `multiplayer/src/rooms/WalkRoom.js` — add the `obj:*` message handlers, rate limits, bounds,+ and disconnect cleanup. Match the existing chat/emote limiter style exactly.++## Spec++1. **Schema.** Add a `WorldObject` schema with fields: `id` (string), `type` (string), `x`, `y`,+ `z` (number), `yaw` (number), `scale` (number), `ownerId` (string), `vx`, `vy`, `vz` (number),+ `kind` (string), `ts` (number). Add `objects: MapSchema<WorldObject>` to the world state schema.+ Keep field types consistent with how players are declared in the same file.+2. **Message handlers** in `WalkRoom.js`:+ - `obj:spawn` — validate payload, assign/accept an `id`, set `ownerId` to the sender, clamp+ position to world radius, stamp `ts`, add to the `objects` map.+ - `obj:update` — only the owner (or server-owned objects, see R05) may move an object; clamp+ to bounds; update position/rotation/velocity.+ - `obj:remove` — only the owner (or coin creator) may remove; delete from the map.+3. **Anti-cheat & limits** — mirror the existing avatar/chat limiter style:+ - Per-client rate limit on each handler (reuse the limiter pattern already in the room).+ - Clamp all positions to the world radius; reject NaN/Infinity/out-of-range payloads.+ - Cap total objects per room (~200) and per player (~30). Reject over-cap spawns; do not crash.+4. **Lifetime** — server owns object lifetime. On owner disconnect, clean up that owner's+ non-persistent objects (persistence comes later in R17; do not build it here).+5. **Document the protocol** in a top-of-file comment block: every message name, its payload+ shape, who is authorized, and the limits. Later briefs read this comment instead of the code.++## Definition of done++- Schema compiles; `objects` map replicates with no schema-encoding errors.+- Each handler is rate-limited, bounds-clamped, and cap-bounded; bad payloads are rejected+ cleanly (no unhandled throw, no room crash).+- **No client changes** are needed for this brief — existing `/play` and `/walk` still connect and+ behave identically (verify both load and a second client still sees you move).+- Protocol documented in the top comment. Diff self-reviewed per the R00 / CLAUDE.md DoD.diff --git a/docs/agent-briefs/R-3d-world-fun/phase-1/R02-client-world-objects-manager.md b/docs/agent-briefs/R-3d-world-fun/phase-1/R02-client-world-objects-manager.mdnew file mode 100644index 000000000..29c7b96fe--- /dev/null+++ b/docs/agent-briefs/R-3d-world-fun/phase-1/R02-client-world-objects-manager.md@@ -0,0 +1,47 @@+# R02 — Client: WorldObjects manager for /play++**Phase 1 (Foundation) · Depends on: R01 · Unblocks: R05, R18**++> Read [`../R00-program-overview.md`](../R00-program-overview.md) and [`CLAUDE.md`](../../../../CLAUDE.md)+> first. R01 must be merged — this brief consumes its `objects` map and `obj:*` protocol.++## Goal++Build a client manager that mirrors R01's server `objects` map into the 3D scene: instantiate a+Three.js node per object, interpolate it smoothly each frame, and dispose cleanly. It must be+**feature-agnostic** — later features (ball, blocks, props) register their own mesh factory+without editing this manager.++## Files++- `src/game/world-objects.js` — **new** module exporting a `WorldObjects` class.+- `src/game/community-net.js` — add `spawnObject` / `updateObject` / `removeObject` send methods,+ mirroring the existing `sendChat` / `sendEmote`.+- `src/game/coincommunities.js` — wire `WorldObjects` into the `CoinCommunities` construction,+ per-frame update loop, and net add/change/remove events; dispose on teardown.++## Spec++1. **`WorldObjects` class** — subscribe to `community-net` object add/change/remove events. On add,+ look up a mesh factory by `kind` and instantiate a scene node; on change, update its target+ transform; on remove, dispose geometry/materials and remove from the scene.+2. **Interpolation** — reuse the `REMOTE_LERP` interpolation pattern from `RemotePlayer` in+ `coincommunities.js` so objects glide between server updates instead of snapping. Same lerp+ feel as remote avatars.+3. **`kind` registry** — expose a small registry (e.g. `WorldObjects.registerKind(kind, factory)`)+ where `factory` returns/configures the Three.js node for that `kind`. Provide a sane default+ primitive mesh fallback for unknown kinds. Later briefs (R05 ball, R18 blocks) register here.+4. **`community-net` methods** — `spawnObject(kind, opts)`, `updateObject(id, transform)`,+ `removeObject(id)` that emit the R01 `obj:spawn` / `obj:update` / `obj:remove` messages with+ validated payloads.+5. **Lifecycle** — instantiate, update each frame, and dispose alongside the rest of the+ `CoinCommunities` lifecycle. No leaked geometries/materials/timers on world teardown.++## Definition of done++- Objects spawned via the net appear for **all** clients, interpolate smoothly, and clean up.+- The manager is feature-agnostic: it has no ball/block-specific logic — those live in the+ registered factories.+- Verified in a real browser with two clients: one spawns a test object via the net, the other+ sees it appear, move, and disappear. No console errors/warnings; no leaks on teardown.+- Diff self-reviewed per the R00 / CLAUDE.md DoD.diff --git a/docs/agent-briefs/R-3d-world-fun/phase-1/R03-cosmetics-accessory-rig.md b/docs/agent-briefs/R-3d-world-fun/phase-1/R03-cosmetics-accessory-rig.mdnew file mode 100644index 000000000..b06d011fa--- /dev/null+++ b/docs/agent-briefs/R-3d-world-fun/phase-1/R03-cosmetics-accessory-rig.md@@ -0,0 +1,46 @@+# R03 — Cosmetics rig: wire the accessory GLBs to avatars++**Phase 1 (Foundation) · Depends on: nothing · Unblocks: R21, R23 (the entire avatar economy)**++> Read [`../R00-program-overview.md`](../R00-program-overview.md) and [`CLAUDE.md`](../../../../CLAUDE.md)+> first. Follow the off-schema networking pattern in R00. Server whitelists URLs like avatars.++## Goal++The GLBs in `public/accessories/` (baseball/beanie/cowboy hats, round/shades glasses, hoop/stud+earrings) are unused. Build attachment so a player can wear them, the wear state syncs to everyone,+and it survives avatar swaps. This rig is the foundation the Phase 4 economy sells against.++## Files++- `src/game/coincommunities.js` — the avatar build path (`buildAvatar` / `RemotePlayer`): add the+ bone-attachment logic and `equipCosmetic` / `unequip`.+- `multiplayer/src/schemas.js` — add a `cosmetics` field to the player schema.+- `multiplayer/src/rooms/WalkRoom.js` — sync `cosmetics` like `avatar`; whitelist accessory URLs.+- `src/game/community-net.js` — add a `setCosmetics()` send method.++## Spec++1. **Attachment.** After an avatar GLB loads, locate the head bone and the parent attachment+ points. Add `equipCosmetic(slot, url)` and `unequip(slot)` that load and parent an accessory+ GLB using a **per-slot offset table**: `hat` → top of head, `glasses` → eyes, `earrings` → ears.+ Tune offsets so each accessory sits correctly on the rig used by `/play` avatars.+2. **Schema + sync.** Add a `cosmetics` string field to the player schema, comma-separated+ `slot:url` (e.g. `hat:/accessories/hat-cowboy.glb,glasses:/accessories/glasses-shades.glb`).+ Sync it like the existing `avatar` field. Apply remote players' cosmetics on add **and** on+ change.+3. **Net send.** Add `community-net` `setCosmetics(cosmeticsString)` mirroring how the avatar is+ sent.+4. **Server whitelist.** Validate/whitelist accessory URLs server-side exactly like avatar URLs —+ reject anything not under the known accessory set. No arbitrary URLs.+5. **Survives swaps.** Equipped cosmetics must re-apply after an avatar swap (re-parent on the new+ rig), persist through the session, and never duplicate/orphan attachment nodes.++## Definition of done++- Equipping a hat shows it on **your** head and on **everyone else's** view of you.+- Cosmetics persist through the session and survive an avatar swap with no orphaned/duplicated+ meshes; `unequip` cleanly removes and disposes.+- Server rejects non-whitelisted accessory URLs.+- Verified in a real browser with two clients. No console errors/warnings; no leaks.+- Diff self-reviewed per the R00 / CLAUDE.md DoD.diff --git a/docs/agent-briefs/R-3d-world-fun/phase-2/R04-emoji-confetti-reactions.md b/docs/agent-briefs/R-3d-world-fun/phase-2/R04-emoji-confetti-reactions.mdnew file mode 100644index 000000000..8abf97999--- /dev/null+++ b/docs/agent-briefs/R-3d-world-fun/phase-2/R04-emoji-confetti-reactions.md@@ -0,0 +1,39 @@+# R04 — Emoji & confetti reactions++**Phase 2 (Social playground) · Depends on: nothing (broadcast-only) · Pairs with: R07 (reuses confetti)**++> Read [`../R00-program-overview.md`](../R00-program-overview.md) and [`CLAUDE.md`](../../../../CLAUDE.md)+> first. This is a pure broadcast feature — no object persistence, no schema changes.++## Goal++Add lightweight, snappy broadcast reactions to `/play`: a reaction bar of ~6 emoji, and on use a+floating-rising-fading emoji sprite above the sender's avatar, plus a confetti burst for 🎉.++## Files++- `src/game/coincommunities-ui.js` — extend the emote tray with a reaction bar.+- `src/game/coincommunities.js` — spawn/animate the floating sprite + confetti above an avatar+ (reuse the screen-projection logic in `_updateLabels`).+- `src/game/community-net.js` — add a `sendReaction(emoji)` method.+- `multiplayer/src/rooms/WalkRoom.js` — add a `reaction` broadcast handler with a 500ms cooldown.++## Spec++1. **Reaction bar** — ~6 emoji (🎉😂🔥❤️👏🤔) added to the emote tray in `coincommunities-ui.js`.+ Each button has hover/active/focus states; keyboard and touch reachable; ARIA labels.+2. **Net** — clicking sends a `reaction` over `community-net`. Server `WalkRoom.js` rebroadcasts to+ the room with a **500ms per-client cooldown** (drop, don't queue, over-rate sends).+3. **On receipt** — spawn a floating emoji sprite above the **sender's** avatar that rises and+ fades over ~1.2s, projected to the correct screen position using the same logic as+ `_updateLabels`. For 🎉, also fire a small confetti particle burst.+4. **Performance** — must stay smooth with 10+ simultaneous reactions: pool/dispose sprites and+ particles, no per-frame allocations, no leaks.+5. **States** — designed empty/active states for the bar; disabled/cooldown affordance so users+ aren't confused when a rapid second tap is dropped.++## Definition of done++- Reactions pop above the **right** avatar for everyone, feel instant, and clean up.+- No jank with 10+ at once; no console errors/warnings; no leaks.+- Buttons fully accessible (keyboard + screen-reader labels). Diff self-reviewed per DoD.diff --git a/docs/agent-briefs/R-3d-world-fun/phase-2/R05-kickable-physics-ball.md b/docs/agent-briefs/R-3d-world-fun/phase-2/R05-kickable-physics-ball.mdnew file mode 100644index 000000000..83ff70ece--- /dev/null+++ b/docs/agent-briefs/R-3d-world-fun/phase-2/R05-kickable-physics-ball.md@@ -0,0 +1,39 @@+# R05 — Kickable physics ball++**Phase 2 (Social playground) · Depends on: R01, R02 · Server-authoritative physics**++> Read [`../R00-program-overview.md`](../R00-program-overview.md) and [`CLAUDE.md`](../../../../CLAUDE.md)+> first. Reuse the R01 object channel and the R02 `kind` registry. The **server owns the physics**.++## Goal++Spawn a shared beach ball in `/play` that players kick by walking into it. All clients see the+same trajectory; it settles realistically and never desyncs badly.++## Files++- `multiplayer/src/rooms/WalkRoom.js` — `ball:kick` handler + server-side ball physics integration+ on the room tick; uses the R01 `objects` map (`kind:'ball'`).+- `src/game/world-objects.js` — register a ball mesh factory in the R02 `kind` registry.+- `src/game/coincommunities.js` — detect walk-into-ball collision intent and send `ball:kick` with+ an impulse derived from player velocity.++## Spec++1. **One ball per room**, `kind:'ball'`, spawned via the R01 object channel on room start, owned by+ the server (not a player).+2. **Kick intent** — when the local player walks into the ball, the client sends `ball:kick` with+ an impulse direction/magnitude derived from the player's velocity. Rate-limit the intent.+3. **Server physics** — on `ball:kick` the server applies velocity, then each tick integrates with+ **friction + world-radius bounce**, and streams position via the `objects` map (`obj:update`).+ The server validates the impulse (cap magnitude, sane direction) — never trust the client's+ raw values.+4. **Respawn** — auto-respawn at world center if the ball leaves bounds or on room start.+5. **Mesh** — the registered factory renders a recognizable beach ball; it interpolates via R02.++## Definition of done++- Any player can kick it; all clients see the same trajectory within interpolation tolerance.+- It settles realistically (friction), bounces off the world edge, and auto-respawns when lost.+- No bad desync, no client-trusted physics, no leaks. Verified with two clients in a real browser.+- Diff self-reviewed per the R00 / CLAUDE.md DoD.diff --git a/docs/agent-briefs/R-3d-world-fun/phase-2/R06-dance-floor-zone.md b/docs/agent-briefs/R-3d-world-fun/phase-2/R06-dance-floor-zone.mdnew file mode 100644index 000000000..ca824f73b--- /dev/null+++ b/docs/agent-briefs/R-3d-world-fun/phase-2/R06-dance-floor-zone.md@@ -0,0 +1,42 @@+# R06 — Dance floor zone++**Phase 2 (Social playground) · Depends on: nothing (uses existing emote/anim path) · Touches WalkRoom for the beat tick**++> Read [`../R00-program-overview.md`](../R00-program-overview.md) and [`CLAUDE.md`](../../../../CLAUDE.md)+> first. Reuse the existing emote broadcast path and the animation manifest — no new anim system.++## Goal++A circular "dance floor" pad near (but not on) the totem in `/play`: emissive animated tiles ++pulsing lights. Standing on it suggests dance emotes; a "🪩 Dance" button triggers a **synchronized**+dance where everyone on the floor crossfades to the same clip on a shared beat.++## Files++- `src/game/coincommunities.js` — the dance floor mesh/pad, lights, on-floor detection, and+ beat-synced crossfade using the existing animation manager.+- `src/game/coincommunities-ui.js` — the "🪩 Dance" button (shown/enabled when on the floor).+- `src/game/coincommunities.css` — pad/light styling tokens if any DOM overlay is used.+- `multiplayer/src/rooms/WalkRoom.js` — broadcast a `floor:beat` tick every N seconds so all+ clients line up.++## Spec++1. **The pad** — a circular emissive floor with animated tiles and pulsing lights, placed near but+ not overlapping the totem. Lights react/pulse on the beat.+2. **On-floor detection** — when a player stands inside the pad radius, surface dance suggestions+ and enable the "🪩 Dance" button. Leaving returns the avatar to idle.+3. **Synchronized dance** — pressing Dance plays a dance clip; everyone on the floor crossfades to+ the **same** clip aligned to the server `floor:beat` tick so movements line up. Use clips already+ in `public/animations/manifest.json`: `av-dance-shuffle`, `av-rap-dance`, `av-headbang`, `dance`.+4. **Beat tick** — `WalkRoom.js` broadcasts `floor:beat` every N seconds; clients schedule+ crossfades to the beat rather than to local time.+5. **States** — button has hover/active/focus; clear on/off-floor affordance; no jank when several+ players join/leave the floor.++## Definition of done++- Standing on the floor + pressing Dance syncs your avatar with others on the floor on a shared+ beat; lights react; leaving returns you to idle.+- Reuses the existing emote/anim path — no second animation system. Clips lazy-load on first use.+- No console errors/warnings, no leaks. Verified with two clients. Diff self-reviewed per DoD.diff --git a/docs/agent-briefs/R-3d-world-fun/phase-2/R07-minigame-king-of-the-totem.md b/docs/agent-briefs/R-3d-world-fun/phase-2/R07-minigame-king-of-the-totem.mdnew file mode 100644index 000000000..d2a50c97a--- /dev/null+++ b/docs/agent-briefs/R-3d-world-fun/phase-2/R07-minigame-king-of-the-totem.md@@ -0,0 +1,41 @@+# R07 — Mini-game: King of the Totem++**Phase 2 (Social playground) · Depends on: nothing (reuses R04 confetti if present) · Server-authoritative**++> Read [`../R00-program-overview.md`](../R00-program-overview.md) and [`CLAUDE.md`](../../../../CLAUDE.md)+> first. Scoring is server-authoritative — clients only render the HUD.++## Goal++A round-based game in `/play`: hold the area at the base of the totem to score. The sole occupant+of the king-zone earns points/sec; contested = no points. 90-second rounds, winner announce ++confetti.++## Files++- `multiplayer/src/rooms/WalkRoom.js` — `game:king` round timer, per-player scores, king-zone+ occupancy logic, and broadcasts (round start/tick/end, winner).+- `src/game/coincommunities.js` — king-zone visualization + HUD hooks.+- `src/game/coincommunities-ui.js` — round timer, live scoreboard, your score, winner banner.+- `src/game/coincommunities.css` — HUD styling using existing `cc-*` tokens.++## Spec++1. **Server logic** — track which players are inside the king-zone radius at the totem base. Award+ points/sec **only** to a sole occupant; if 2+ are inside, no one scores (contested). Run+ **90-second rounds** with a clear start, live tick, and end + winner announcement. All scoring+ and timing is on the server.+2. **Broadcasts** — round timer, per-player scores, current king, and winner. Clients render only.+3. **HUD** — round timer, live scoreboard (sorted), your own score highlighted, and a winner banner+ on round end. Designed empty (waiting for players), active, and between-rounds states.+4. **Celebration** — confetti on the winner. Reuse the R04 reaction confetti if that brief is+ merged; otherwise a simple self-contained burst.+5. **Robustness** — correct with players joining/leaving mid-round; no scoring exploit from outside+ the zone; handles a round with zero/one eligible players gracefully.++## Definition of done++- Rounds start/end on a timer; scoring is correct and contested-aware; HUD is clear; winner is+ celebrated. Works with 2+ players.+- No client-trusted scoring. No console errors/warnings, no leaks. Verified with two clients.+- Diff self-reviewed per the R00 / CLAUDE.md DoD.diff --git a/docs/agent-briefs/R-3d-world-fun/phase-2/R08-minigame-tag.md b/docs/agent-briefs/R-3d-world-fun/phase-2/R08-minigame-tag.mdnew file mode 100644index 000000000..78f52e01b--- /dev/null+++ b/docs/agent-briefs/R-3d-world-fun/phase-2/R08-minigame-tag.md@@ -0,0 +1,41 @@+# R08 — Mini-game: Tag++**Phase 2 (Social playground) · Depends on: nothing · Server-authoritative proximity**++> Read [`../R00-program-overview.md`](../R00-program-overview.md) and [`CLAUDE.md`](../../../../CLAUDE.md)+> first. The server validates every tag — never trust client-claimed proximity.++## Goal++"It"-tag in `/play`. One random player becomes "it" when ≥2 are present. Walking adjacent to+another player transfers "it" (server-validated proximity + tag-back immunity). "It" has an obvious+marker.++## Files++- `multiplayer/src/schemas.js` — add `it` (boolean) and `itSince` (number) to the player schema.+- `multiplayer/src/rooms/WalkRoom.js` — assign "it", validate tag transfers (proximity + 2s+ immunity), track per-session time-as-it.+- `src/game/coincommunities.js` — the "it" marker (red glow ring under the avatar + 🏃 over head).+- `src/game/coincommunities-ui.js` — HUD: who's it, a "you're it!" alert, lightweight leaderboard.++## Spec++1. **Schema** — `it` boolean + `itSince` on the player. One random present player becomes "it" when+ the room reaches ≥2 players; reassign sensibly if "it" disconnects.+2. **Transfer** — when "it" walks adjacent to another player, the **server** validates the proximity+ and transfers "it", applying a **2s tag-back immunity** so it can't bounce instantly. No+ tagging from across the map — proximity is checked server-side against authoritative positions.+3. **Marker** — "it" shows a red glow ring under the avatar and a 🏃 marker over the head, visible+ to everyone.+4. **HUD** — shows who is "it", a "you're it!" alert when you become it, and a lightweight+ leaderboard of per-session time-as-it.+5. **Robustness** — fun with 3+ players; no double-it; no exploit; clean handling of+ join/leave/disconnect.++## Definition of done++- "It" transfers correctly on contact with immunity; marker is obvious to everyone; no+ across-map exploit. Fun with 3+ players.+- No client-trusted proximity. No console errors/warnings, no leaks. Verified with multiple clients.+- Diff self-reviewed per the R00 / CLAUDE.md DoD.diff --git a/docs/agent-briefs/R-3d-world-fun/phase-2/R09-emote-wheel.md b/docs/agent-briefs/R-3d-world-fun/phase-2/R09-emote-wheel.mdnew file mode 100644index 000000000..1cde12e6f--- /dev/null+++ b/docs/agent-briefs/R-3d-world-fun/phase-2/R09-emote-wheel.md@@ -0,0 +1,40 @@+# R09 — Emote wheel (expose all 70 animations)++**Phase 2 (Social playground) · Depends on: nothing (uses existing emote broadcast + lazy-load)**++> Read [`../R00-program-overview.md`](../R00-program-overview.md) and [`CLAUDE.md`](../../../../CLAUDE.md)+> first. Reuse the existing emote broadcast path and the animation manager's lazy loading.++## Goal++Replace/augment the 6-button emote tray with a radial **emote wheel** that exposes all categories+from `public/animations/manifest.json` (dances, flips, poses, combat, social). Keep the quick tray+for the top 6.++## Files++- `src/game/coincommunities-ui.js` — the radial wheel UI (open/select/release), category arcs,+ labels/icons; keep the existing quick tray.+- `src/game/coincommunities.css` — wheel styling using existing `cc-*` tokens.+- `src/game/coincommunities.js` — input handling (key/long-press/gamepad) and playing+broadcasting+ the chosen clip via the existing emote path.++## Spec++1. **Wheel interaction** — hold a key / long-press to open, move to select a segment, release to+ play. Smooth open/close transitions (opacity + transform). Top 6 stay in the existing quick tray.+2. **Categories** — read `public/animations/manifest.json` and group clips into category arcs+ (dances, flips, poses, combat, social) with labels/icons. All 70 emotes must be reachable.+3. **Lazy-load** — clips load on first use (the animation manager already supports this); don't+ preload all 70.+4. **Input** — keyboard, touch, **and** gamepad friendly. Selection plays the clip and broadcasts+ via the existing emote path so others see it.+5. **Accessibility** — screen-reader labels on segments, keyboard navigation, focus indicators,+ sufficient contrast on arcs/labels.++## Definition of done++- Wheel opens smoothly; every manifest emote is reachable and categorized; selection plays and+ broadcasts via the existing emote path.+- Keyboard + touch + gamepad all work; accessible (labels, focus). Clips lazy-load.+- No console errors/warnings, no jank. Verified in a real browser. Diff self-reviewed per DoD.diff --git a/public/demos/selfie-fit.html b/public/demos/selfie-fit.htmlindex c243b7431..47512bdd6 100644--- a/public/demos/selfie-fit.html+++ b/public/demos/selfie-fit.html@@ -926,6 +926,17 @@avatar_type: state.style,}),});+ if (res.status === 501) {+ // Editor fallback is not configured in this environment+ // (AVATURN_API_KEY absent). The native pipeline above is the+ // primary path; surface a clear, non-error message instead of+ // throwing a raw HTTP 501 at the user.+ const why = await res.json().catch(() => ({}));+ log(`editor path unavailable (${why?.error || '501'}): avatar customization is temporarily unavailable in this environment.`, 'info');+ submitBtn.disabled = false;+ submitBtn.textContent = original;+ return;+ }if (!res.ok) {const text = await res.text();throw new Error(`HTTP ${res.status}: ${text.slice(0, 240)}`);diff --git a/src/avaturn-client.js b/src/avaturn-client.jsindex 40e972849..86e206116 100644--- a/src/avaturn-client.js+++ b/src/avaturn-client.js@@ -30,7 +30,7 @@ const EXPIRY_GRACE_MS = 10_000;export class AvaturnError extends Error {/*** @param {string} message- * @param {'quota'|'auth'|'session-expired'|'network'|'timeout'} code+ * @param {'quota'|'auth'|'session-expired'|'network'|'timeout'|'not-configured'} code*/constructor(message, code) {super(message);@@ -81,14 +81,19 @@ export async function createAvaturnSession({ front, left, right }) {if (!res.ok) {const payload = await res.json().catch(() => ({}));const code = payload?.error;+ // 501 not_configured = the avatar editor key is absent in this environment.+ // Surface a distinct code so callers can skip the editor step gracefully+ // rather than treating it as an auth failure the user could act on.+ if (res.status === 501 || code === 'not_configured')+ throw new AvaturnError(+ payload?.error_description || 'avatar editor is not available right now',+ 'not-configured',+ );if (res.status === 401 || res.status === 403)throw new AvaturnError(payload?.error_description || 'unauthorized', 'auth');if (res.status === 429)throw new AvaturnError(payload?.error_description || 'rate limited', 'quota');- throw new AvaturnError(- payload?.error_description || `http ${res.status}`,- code === 'not_configured' ? 'auth' : 'network',- );+ throw new AvaturnError(payload?.error_description || `http ${res.status}`, 'network');}const data = await res.json();