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(a2a): correct the refusal codes to the ones the guard actually returns

nirholas7f7ad09f3e3d
diff --git a/STRUCTURE.md b/STRUCTURE.md
index c1c248af1..bb4063d5c 100644
--- a/STRUCTURE.md
+++ b/STRUCTURE.md
@@ -175,6 +175,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. |
+| 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) |
| Master wallet (per-user custodial hub) | page [pages/wallet.html](pages/wallet.html) `→ /wallet` + controller [src/master-wallet.js](src/master-wallet.js), client [src/wallet-api.js](src/wallet-api.js), styles [public/master-wallet.css](public/master-wallet.css); API [api/user/wallet/index.js](api/user/wallet/index.js) (create + balances), [send.js](api/user/wallet/send.js), [fund-agent.js](api/user/wallet/fund-agent.js), [history.js](api/user/wallet/history.js); schema [master_wallets](api/_lib/migrations/20260730040000_master_wallets.sql) | In-repo | One custodial Solana + EVM keypair per USER account (distinct from per-agent wallets): hold SOL/USDC across Solana and Base, top up any agent you own, send to any Solana address, and read history straight from chain. Session-cookie auth only, so no API key or agent can ever spend it; writes are CSRF-guarded and capped at 5 outbound transfers per user per day. The page prices every send through the server's `simulate` path first and requires an explicit confirm showing recipient, amount, asset and network before anything is signed. NOT [src/wallet.js](src/wallet.js), which connects an external Phantom/Seed-Vault wallet. Docs: [docs/user-wallet.md](docs/user-wallet.md). Tests: [tests/master-wallet-page.test.js](tests/master-wallet-page.test.js) |
diff --git a/docs/a2a-payments.md b/docs/a2a-payments.md
index 9dc8161dd..481c1ea8c 100644
--- a/docs/a2a-payments.md
+++ b/docs/a2a-payments.md
@@ -44,13 +44,13 @@ token moves.
| # | Gate | What it decides | Refusal code |
|---|------|-----------------|--------------|
-| 1 | Mandate signature + ownership | Is this a real mandate, issued to this user, still unexpired? | `mandate_invalid`, `mandate_expired`, `mandate_not_yours` |
+| 1 | Mandate signature + ownership | Is this a real mandate, issued to this user, still unexpired? | `invalid_mandate`, `mandate_expired`, `mandate_not_yours` |
| 2 | Subject agent | Does the agent the mandate names still exist, and is it still this user's? | `agent_not_found`, `agent_not_yours` |
| 3 | Kill switch | Is the agent halted? Checked before the peer is even quoted | `wallet_frozen` |
-| 4 | Mandate per-call policy | Is this amount, network, currency and resource inside what was authorized? | `per_call_exceeded`, `network_not_allowed`, `resource_not_allowed` |
-| 5 | Peer reputation (opt-in) | Does the peer clear the caller's ERC-8004 trust bar? | `reputation_below_bar` |
+| 4 | Mandate per-call policy | Is this amount, network, currency and resource inside what was authorized? | `amount_over_per_call`, `currency_mismatch`, `network_not_allowed`, `resource_not_allowed` |
+| 5 | Peer reputation (opt-in) | Does the peer clear the caller's ERC-8004 trust bar? | `reputation_too_low`, `reputation_too_few_reviews`, `reputation_unavailable` |
| 6 | Mandate cumulative budget | Would lifetime spend under this mandate exceed its total cap? | `budget_exceeded` |
-| 7 | The agent's own spend policy | Per-transaction, rolling-daily and per-counterparty ceilings, the owner's plain-English rules, the anomaly guard, any scoped capability | `per_tx_exceeded`, `daily_exceeded`, `counterparty_daily_exceeded`, `policy_denied`, `wallet_anomaly_frozen`, `capability_required` |
+| 7 | The agent's own spend policy | Per-transaction, rolling-daily and per-counterparty ceilings, the owner's plain-English rules, the anomaly guard, any scoped capability | `per_tx_exceeded`, `daily_exceeded`, `counterparty_daily_exceeded`, `policy_blocked`, `policy_step_up`, `policy_freeze`, `wallet_anomaly_frozen`, `capability_required` |
Gate 7 is atomic: it enforces the ceilings **and** writes the payment's pending
receipt row in one statement under a per-agent advisory lock, so concurrent
diff --git a/prompts/swarm-100/roadmap-p2-voice-clone-mainflow.md b/prompts/swarm-100/roadmap-p2-voice-clone-mainflow.md
deleted file mode 100644
index 475a5d989..000000000
--- a/prompts/swarm-100/roadmap-p2-voice-clone-mainflow.md
+++ /dev/null
@@ -1,101 +0,0 @@
-# Roadmap build: Phase 2: voice cloning integrated into the main create flow
-
-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.
-
-## Context
-
-This order builds one roadmap slice from the README Roadmap (the canonical
-phase plan). It is independent of every other roadmap order: if adjacent
-slices are absent, build to this slice's boundary with clean interfaces and
-never block on them. Solana leads on every chain decision; EVM legs ship
-behind flags and never stall the Solana path.
-
-## Task
-
-Roadmap: voice clone shipped behind /demos; main-flow integration is the gap.
-Move it into the primary agent creation flow.
-
-Step 0: find the demo implementation (grep voice clone across src/, api/,
-packages/voice), read /voice and the create flow, and run the demo path to
-see what works. Known constraint: there is no platform ELEVENLABS_API_KEY
-anywhere in prod, so the working lane is bring-your-own-key, and owner rule
-requires vendor-billed features be metered to $THREE credits or BYOK.
-
-Build: a voice step in the create flow where a user records or uploads a
-short sample and binds the resulting voice to their agent. BYOK is the
-activation path today: design the key entry, storage, and per-agent binding
-properly. Wire the platform-key lane fully behind its env var so one
-credential activates it. The agent's voice must actually play in the chat
-and embed surfaces once bound.
-
-Documentation is part of the feature, not a follow-up: update the docs layer
-that applies (data/pages.json for a new page, README for a new directory,
-docs/ for a developer capability, specs/ for a wire format) and append a
-holder-readable entry to data/changelog.json for anything user-visible.
-
-## Definition of done
-
-- [ ] Voice binding exercised end to end with a real key (BYOK) and the bound
- voice heard on the agent's chat surface.
-- [ ] Platform-key lane fully wired behind ELEVENLABS_API_KEY and proven with
- a dry run; the single missing var named in the report.
-- [ ] Designed states for no key, bad sample, and provider failure.
-- [ ] npm test green; check:rules clean.
-- [ ] Docs and changelog layers updated per the CLAUDE.md documentation
- rules; npm run audit:docs clean if docs changed.
-- [ ] git diff reviewed line by line before claiming completion.
-
-## 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/roadmap-p2-voice-clone-mainflow.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.