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(mcp-packages): point brain and copy at the live API-key page, refresh the model list, and cover clash's write path with real-signature tests
nirholas2c1b66734673
diff --git a/data/changelog.json b/data/changelog.jsonindex d9b92a79a..297aaa1f4 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,16 @@{"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-08-14",+ "title": "The 3D generation SDK can finally pay per call, and its bring-your-own-key option actually does something",+ "summary": "The npm package that turns a prompt into a 3D model documented two things it did not do. It listed a per-call option for supplying your own Meshy or Tripo key, and that option was read from nowhere: the key was silently dropped, so anyone following the README's own example was told to add a key that the generator then said was missing. It also documented paying per call in USDC as the default billing lane, when the flag it described was ignored by the endpoint it was sent to. Both are now real. A key passed on the call is used, overrides the one set on the client, and is resent on every status check, which the generator requires and the old code never did, so a job started with your own key could never be polled to completion. The pay-per-call lane now routes to the endpoint that actually accepts payment, quotes Solana USDC, and hands back a job you poll for free, and it refuses upfront the options it cannot honour rather than accepting them and ignoring them. The package now also exposes a way to read one job's state without waiting for it, so a generation survives a restart. Alongside that, the reference pages listed a price and a set of engines that had both moved on, named an error the service never returns, and pointed at three addresses that no longer exist: the sign-up link for API keys in the copy-trading and LLM router packages went to a dead page, as did the link to the 3D studio tool server. All of them now resolve.",+ "tags": [+ "sdk",+ "fix",+ "docs"+ ]+ },{"date": "2026-08-14","title": "The AR docs stopped handing readers three commands the tool rejects or quietly ruins",diff --git a/packages/brain-mcp/README.md b/packages/brain-mcp/README.mdindex c86c91b90..56e86cb4c 100644--- a/packages/brain-mcp/README.md+++ b/packages/brain-mcp/README.md@@ -90,13 +90,13 @@ Both responses below are shape illustrations — the live provider set and gener> {}{"ok": true,- "count": 18,- "available": 11,+ "count": 34,+ "available": 33,"default_provider": "gpt-oss-120b","providers": [- { "key": "gpt-oss-120b", "label": "GPT-OSS 120B", "network": "OpenAI · OpenRouter", "tier": "balanced", "maxOutput": 8192, "available": true, "requiresAuth": false },- { "key": "claude-sonnet-4-6", "label": "Claude Sonnet 4.6", "network": "Anthropic", "tier": "balanced", "maxOutput": 16384, "available": true, "requiresAuth": true },- { "key": "deepseek-r1", "label": "DeepSeek R1", "network": "DeepSeek", "tier": "reasoning", "maxOutput": 8192, "available": true, "requiresAuth": true }+ { "key": "gpt-oss-120b", "label": "GPT-OSS 120B", "network": "OpenAI · OpenRouter", "tier": "balanced", "maxOutput": 8192, "description": "Open-weight 120B from OpenAI. Fast, capable, free tier. Platform default.", "available": true, "requiresAuth": false },+ { "key": "claude-sonnet-5", "label": "Claude Sonnet 5", "network": "Anthropic", "tier": "balanced", "maxOutput": 16384, "description": "Near-Opus quality on coding and agentic work at Sonnet cost. Best for most tasks.", "available": true, "requiresAuth": true },+ { "key": "deepseek-r1", "label": "DeepSeek R1", "network": "DeepSeek", "tier": "reasoning", "maxOutput": 8192, "description": "Open reasoning model. Strong at math and code.", "available": true, "requiresAuth": true }/* … */]}@@ -105,14 +105,14 @@ Both responses below are shape illustrations — the live provider set and gener```jsonc// chat (example response)> {- "provider": "claude-sonnet-4-6",+ "provider": "claude-sonnet-5","system": "You are terse.","messages": [{ "role": "user", "content": "Name three Solana RPC methods." }]}{"ok": true,- "provider": "claude-sonnet-4-6",- "model": "Claude Sonnet 4.6",+ "provider": "claude-sonnet-5",+ "model": "Claude Sonnet 5","network": "Anthropic","tier": "balanced","routed_via": null,@@ -124,16 +124,16 @@ Both responses below are shape illustrations — the live provider set and gener`routed_via` is `null` when the requested provider answered directly; otherwise it names the mirror or free-tier route the router fell back to (so you always get an answer even if the first choice is briefly down).-> Model availability is dynamic. Always call `list_providers` first rather than hardcoding a key — the current Claude ids are `claude-fable-5`, `claude-opus-4-7`, `claude-sonnet-4-6`, and `claude-haiku-4-5`, but the live list is the source of truth.+> Model availability is dynamic. Always call `list_providers` first rather than hardcoding a key. The current Claude ids are `claude-fable-5`, `claude-opus-5`, `claude-sonnet-5`, `claude-opus-4-7`, `claude-sonnet-4-6`, and `claude-haiku-4-5`, but the live list is the source of truth.## Authentication| Model class | Needs a key? || ---------------------------------------------------------------------------- | --------------------------- |-| Free open-weight tiers (GPT-OSS 120B, NVIDIA NIM: Nemotron / Kimi / Llama 4) | No |+| Free open-weight tiers (GPT-OSS 120B, and the NVIDIA NIM set: Nemotron 3 Super / Nemotron Super 49B / Nemotron Nano / DeepSeek V4 / Kimi K2 / Llama 4 Maverick / MiniMax M2) | No || Paid first-party flagships (Claude, GPT-5.6, o3, Qwen Plus, DeepSeek, …) | Yes — set `THREE_WS_API_KEY` |-Create an API key at [three.ws/account](https://three.ws/account). Without it, paid models return a sign-in error and `list_providers` flags them with `requiresAuth: true`.+Create an API key at [three.ws/dashboard/developers](https://three.ws/dashboard/developers). Without it, paid models return a sign-in error and `list_providers` flags them with `requiresAuth: true`.## Requirementsdiff --git a/packages/brain-mcp/package.json b/packages/brain-mcp/package.jsonindex da667da64..e3751a2c1 100644--- a/packages/brain-mcp/package.json+++ b/packages/brain-mcp/package.json@@ -2,7 +2,7 @@"name": "@three-ws/brain-mcp","version": "0.1.3","mcpName": "io.github.nirholas/brain-mcp",- "description": "Any model, one interface — the three.ws multi-provider LLM router over MCP. Discover available providers/models (Claude, GPT-4o, Qwen, DeepSeek, NVIDIA Nemotron, IBM Granite…) and run a chat completion through whichever one fits. Free tiers need no key; paid flagships unlock with a three.ws API key.",+ "description": "Any model, one interface: the three.ws multi-provider LLM router over MCP. Discover available providers/models (Claude, GPT-5, Grok, Qwen, DeepSeek, NVIDIA Nemotron, IBM Granite and more) and run a chat completion through whichever one fits. Free tiers need no key; paid flagships unlock with a three.ws API key.","type": "module","author": "nirholas <[email protected]>","license": "SEE LICENSE IN LICENSE",diff --git a/packages/brain-mcp/server.json b/packages/brain-mcp/server.jsonindex 56b5e76cb..d0ef93f89 100644--- a/packages/brain-mcp/server.json+++ b/packages/brain-mcp/server.json@@ -38,7 +38,7 @@},{"name": "THREE_WS_API_KEY",- "description": "Optional three.ws API key (sk_live_… / sk_test_…) or OAuth access token, sent as a Bearer token. Required only to use paid first-party flagships (Claude, GPT-4o, o3, Qwen Plus, DeepSeek). Free open-weight tiers (GPT-OSS 120B, NVIDIA NIM models) work with no key. Create one at https://three.ws/account.",+ "description": "Optional three.ws API key (sk_live_… / sk_test_…) or OAuth access token, sent as a Bearer token. Required only to use paid first-party flagships (Claude, GPT-5, o3, Grok, Qwen Plus, DeepSeek). Free open-weight tiers (GPT-OSS 120B, NVIDIA NIM models) work with no key. Create one at https://three.ws/dashboard/developers.","format": "string","isRequired": false,"isSecret": truediff --git a/packages/brain-mcp/src/config.js b/packages/brain-mcp/src/config.jsindex b7aaf22e6..fad8f9d7d 100644--- a/packages/brain-mcp/src/config.js+++ b/packages/brain-mcp/src/config.js@@ -2,7 +2,7 @@//// This server is a thin wrapper over the three.ws multi-provider LLM router// (/api/brain/chat). It holds no model keys of its own — the router fronts-// Claude, GPT-4o, Qwen, DeepSeek, NVIDIA NIM, IBM Granite, and more on the+// Claude, GPT-5, Grok, Qwen, DeepSeek, NVIDIA NIM, IBM Granite, and more on the// server's billed keys. The only knobs here are which deployment to talk to,// how long to wait, and an optional three.ws API key that unlocks the paid// first-party flagships (free open-weight tiers need no key).@@ -19,7 +19,7 @@ export const THREE_WS_BASE = env('THREE_WS_BASE', 'https://three.ws').replace(/\// Optional bearer credential (three.ws API key `sk_live_…`/`sk_test_…`, or an// OAuth access token). Sent as `Authorization: Bearer …` on every request. The// router serves the free open-weight tiers anonymously; the paid first-party-// flagships (Claude, GPT-4o, o3, Qwen Plus, DeepSeek) require this credential.+// flagships (Claude, GPT-5, o3, Grok, Qwen Plus, DeepSeek) require this credential.export const THREE_WS_API_KEY = env('THREE_WS_API_KEY');// Per-request timeout (ms). A chat completion streams server-side and isdiff --git a/packages/brain-mcp/src/index.js b/packages/brain-mcp/src/index.jsindex 2fce0e927..532c59eba 100755--- a/packages/brain-mcp/src/index.js+++ b/packages/brain-mcp/src/index.js@@ -7,7 +7,7 @@// • chat — run a chat completion through whichever one fits//// A thin wrapper over the three.ws API (POST /api/brain/chat). The route fronts-// Claude, GPT-4o, o3, Qwen, DeepSeek, NVIDIA Nemotron, IBM Granite, and more, and+// Claude, GPT-5, o3, Grok, Qwen, DeepSeek, NVIDIA Nemotron, IBM Granite, and more, and// auto-falls-back across mirrors/free tiers on an upstream outage. The free// open-weight tiers need no key; paid first-party flagships unlock with a// three.ws API key (THREE_WS_API_KEY).@@ -45,7 +45,7 @@ export function buildServer() {capabilities: { tools: {} },instructions:'three.ws Brain MCP — any model, one interface. list_providers discovers every LLM the router can ' +- 'run a completion through (Claude, GPT-4o, o3, Qwen, DeepSeek, NVIDIA Nemotron, IBM Granite, and ' ++ 'run a completion through (Claude, GPT-5, o3, Grok, Qwen, DeepSeek, NVIDIA Nemotron, IBM Granite, and ' +'more), each with its key, network, tier, max output, live availability, and whether it needs auth. ' +'chat runs a completion through the chosen provider and returns the full reply as one message, plus ' +'the route actually taken, token usage, and timing — the router transparently falls back across ' +diff --git a/packages/brain-mcp/src/tools/chat.js b/packages/brain-mcp/src/tools/chat.jsindex 6afb2e339..45877a9cf 100644--- a/packages/brain-mcp/src/tools/chat.js+++ b/packages/brain-mcp/src/tools/chat.js@@ -27,7 +27,7 @@ export const def = {'the conversation so far (roles `user`/`assistant`); add system instructions via `system`. The route ' +'streams and auto-falls-back across mirrors/free tiers if the chosen model is briefly down — this tool ' +'collapses that into one reply and reports the actual route taken, token usage, and timing. ' +- 'Paid first-party flagships (Claude, GPT-4o, o3, Qwen Plus, DeepSeek) need a three.ws API key ' ++ 'Paid first-party flagships (Claude, GPT-5, o3, Grok, Qwen Plus, DeepSeek) need a three.ws API key ' +'(set THREE_WS_API_KEY); the free open-weight tiers (GPT-OSS 120B, NVIDIA NIM models) need none. ' +'Read-only: a completion does not change any platform state.',inputSchema: {@@ -40,7 +40,7 @@ export const def = {.string().min(1).optional()- .describe('Provider/model key from list_providers (e.g. "claude-sonnet-4-6", "gpt-4o", "deepseek-r1"). Defaults to "gpt-oss-120b".'),+ .describe('Provider/model key from list_providers (e.g. "claude-sonnet-5", "gpt-5.4", "deepseek-r1"). Defaults to "gpt-oss-120b".'),system: z.string().max(8000)diff --git a/packages/brain-mcp/src/tools/list-providers.js b/packages/brain-mcp/src/tools/list-providers.jsindex 56df4f8f2..b0057b7eb 100644--- a/packages/brain-mcp/src/tools/list-providers.js+++ b/packages/brain-mcp/src/tools/list-providers.js@@ -13,7 +13,8 @@ export const def = {description:'List every LLM the three.ws router can run a completion through — one entry per provider/model. ' +'Each entry has: `key` (the id you pass to `chat`), `label` (human name), `network` (e.g. Anthropic, ' +- 'OpenAI, DashScope, NVIDIA NIM, IBM watsonx.ai), `tier` (flagship | balanced | fast | reasoning), ' ++ 'OpenAI, xAI, DashScope, NVIDIA NIM, IBM watsonx.ai), `tier` (flagship | balanced | fast | reasoning | ' ++ 'pro | coding), ' +'`maxOutput` (max output tokens), `description`, `available` (true when the server currently holds a ' +'working key/route for it), and `requiresAuth` (true when it is a paid first-party model that needs a ' +'three.ws API key — set THREE_WS_API_KEY; false for the free open-weight tiers). Call this first to ' +diff --git a/packages/clash-mcp/test/handlers.test.mjs b/packages/clash-mcp/test/handlers.test.mjsnew file mode 100644index 000000000..cc038608f--- /dev/null+++ b/packages/clash-mcp/test/handlers.test.mjs@@ -0,0 +1,325 @@+// Handler behavior for @three-ws/clash-mcp: request building, the full enlist+// proof (real ed25519 signing, verified in-test), response shaping, and error+// normalization. Global fetch is stubbed for every test, so nothing here touches+// the network. The signing is NOT stubbed: every signature below is produced by+// the package's own signer and verified against the challenge bytes with+// tweetnacl, which is the whole point of the write path.+//+// Env is pinned BEFORE the dynamic imports because src/config.js reads+// process.env at module load. SOLANA_SECRET_KEY is deliberately left unset so+// the missing-signer path is exercised as it ships.+//+// Run: node --test packages/clash-mcp/test/handlers.test.mjs++import { test } from 'node:test';+import assert from 'node:assert/strict';+import nacl from 'tweetnacl';+import bs58 from 'bs58';++process.env.THREE_WS_BASE = 'https://clash.test';+delete process.env.SOLANA_SECRET_KEY;+delete process.env.CLASH_SOLANA_SECRET;+delete process.env.THREE_WS_TIMEOUT_MS;++const { def: state } = await import('../src/tools/get-clash-state.js');+const { def: leaderboard } = await import('../src/tools/get-clash-leaderboard.js');+const { def: enlistFaction } = await import('../src/tools/enlist-faction.js');+const { def: rallyFaction } = await import('../src/tools/rally-faction.js');+const { loadSigner, signMessage } = await import('../src/lib/signer.js');++const bs58encode = bs58.default ? bs58.default.encode : bs58.encode;++// A real, throwaway ed25519 keypair. The 64-byte secret is exactly the base58+// form the tools accept, so the signatures below are the ones a soldier's+// wallet would produce.+const KEYPAIR = nacl.sign.keyPair();+const SECRET = bs58encode(KEYPAIR.secretKey);+const WALLET = bs58encode(KEYPAIR.publicKey);++// A synthetic faction mint. Never a real third-party token.+const FACTION = 'THREEsynthetic1111111111111111111111111111';++// Swap globalThis.fetch for the duration of fn, always restoring it.+async function withFetch(stub, fn) {+ const original = globalThis.fetch;+ globalThis.fetch = stub;+ try {+ return await fn();+ } finally {+ globalThis.fetch = original;+ }+}++// A scripted fetch: route by pathname, record every call. Each route is either a+// literal body (answered 200) or `{ status, body }`.+function routedFetch(routes, log) {+ return async (url, init) => {+ const u = new URL(String(url));+ const body = init?.body ? JSON.parse(init.body) : null;+ log.push({ path: u.pathname, search: u.searchParams, method: init?.method || 'GET', body });+ const route = routes[u.pathname];+ if (!route) throw new Error(`routedFetch: no route for ${u.pathname}`);+ const answer = typeof route === 'function' ? route(body) : route;+ const { status = 200, body: payload = answer } = answer?.status ? answer : { body: answer };+ return new Response(JSON.stringify(payload), {+ status,+ headers: { 'content-type': 'application/json' },+ });+ };+}++const STATE_ENVELOPE = {+ data: {+ epoch: 412,+ endsAt: 1770000000000,+ msLeft: 128000,+ epochMs: 900000,+ factionCount: 3,+ arena: [+ {+ a: { token: FACTION, symbol: 'THREE', power: 120, momentum: 1.4 },+ b: { token: `${FACTION}b`, symbol: 'OTHER', power: 80, momentum: 1 },+ aShare: 0.6,+ leader: FACTION,+ },+ ],+ bye: null,+ },+};++// ── read tools ────────────────────────────────────────────────────────────────++test('get_clash_state reads the board and shapes the envelope', async () => {+ const log = [];+ const out = await withFetch(routedFetch({ '/api/clash/state': STATE_ENVELOPE }, log), () => state.handler());++ assert.equal(log.length, 1);+ assert.equal(log[0].path, '/api/clash/state');+ assert.equal(log[0].method, 'GET');+ assert.equal(out.ok, true);+ assert.equal(out.epoch, 412);+ assert.equal(out.msLeft, 128000);+ assert.equal(out.factionCount, 3);+ assert.equal(out.arena[0].leader, FACTION);+});++test('get_clash_state defaults every field when the round has no data yet', async () => {+ const out = await withFetch(routedFetch({ '/api/clash/state': { data: {} } }, []), () => state.handler());+ assert.deepEqual(out, {+ ok: true,+ epoch: null,+ endsAt: null,+ msLeft: null,+ epochMs: null,+ factionCount: 0,+ arena: [],+ bye: null,+ });+});++test('get_clash_leaderboard omits the faction query when none is asked for', async () => {+ const log = [];+ const board = [{ token: FACTION, symbol: 'THREE', w: 3, l: 1, d: 0, battles: 4, power: 900, winRate: 75 }];+ const out = await withFetch(routedFetch({ '/api/clash/leaderboard': { data: { board, soldiers: null } } }, log), () =>+ leaderboard.handler({}),+ );++ assert.equal(log[0].search.get('faction'), null);+ assert.equal(out.board[0].winRate, 75);+ assert.equal(out.soldiers, null);+});++test('get_clash_leaderboard forwards a faction mint and returns its soldiers', async () => {+ const log = [];+ const soldiers = [{ wallet: WALLET, power: 240 }];+ const out = await withFetch(+ routedFetch({ '/api/clash/leaderboard': { data: { board: [], soldiers } } }, log),+ () => leaderboard.handler({ faction: ` ${FACTION} ` }),+ );++ assert.equal(log[0].search.get('faction'), FACTION, 'the mint is trimmed before it is sent');+ assert.deepEqual(out.soldiers, soldiers);+});++test('an upstream rejection becomes a typed upstream_error carrying the status', async () => {+ const routes = { '/api/clash/state': { status: 503, body: { error: 'cc_unconfigured', message: 'Coin Clash is not configured.' } } };+ await withFetch(routedFetch(routes, []), async () => {+ await assert.rejects(() => state.handler(), (err) => {+ assert.equal(err.code, 'upstream_error');+ assert.equal(err.status, 503);+ assert.equal(err.message, 'Coin Clash is not configured.');+ assert.equal(err.body.error, 'cc_unconfigured');+ return true;+ });+ });+});++// ── signer ────────────────────────────────────────────────────────────────────++test('loadSigner derives the wallet from the secret and signs verifiably', () => {+ const { wallet } = loadSigner(SECRET);+ assert.equal(wallet, WALLET);++ const message = 'three.ws Coin Clash enlistment\nwallet: ' + WALLET;+ const { signature } = signMessage(message, SECRET);+ const ok = nacl.sign.detached.verify(+ new TextEncoder().encode(message),+ bs58.default ? bs58.default.decode(signature) : bs58.decode(signature),+ KEYPAIR.publicKey,+ );+ assert.ok(ok, 'the detached signature must verify against the challenge bytes');+});++test('loadSigner refuses a missing, non-base58, or wrong-length secret', () => {+ assert.throws(() => loadSigner(), (err) => err.code === 'no_signer');+ assert.throws(() => loadSigner('not base58 0OIl'), (err) => err.code === 'invalid_secret');+ // Valid base58, but a 32-byte key rather than the 64-byte secret key.+ assert.throws(+ () => loadSigner(bs58encode(KEYPAIR.publicKey)),+ (err) => err.code === 'invalid_secret' && /64 bytes/.test(err.message),+ );+});++// ── enlist ────────────────────────────────────────────────────────────────────++const CHALLENGE = `three.ws Coin Clash\nfaction: ${FACTION}\nnonce: 8f2c`;++function enlistRoutes({ verify } = {}) {+ return {+ '/api/clash/enlist': { data: { message: CHALLENGE, expiresAt: 1770000300000 } },+ '/api/clash/enlist-verify':+ verify ?? { data: { eligible: true, wallet: WALLET, amount: 125000, usd: 42.5, warPass: 'pass_abc' } },+ };+}++test('enlist_faction runs challenge, real signature, and verify in order', async () => {+ const log = [];+ const out = await withFetch(routedFetch(enlistRoutes(), log), () =>+ enlistFaction.handler({ token: FACTION, secret: SECRET }),+ );++ assert.deepEqual(log.map((c) => c.path), ['/api/clash/enlist', '/api/clash/enlist-verify']);+ assert.deepEqual(log[0].body, { token: FACTION, wallet: WALLET }, 'the challenge is bound to the derived wallet');++ const submitted = log[1].body;+ assert.equal(submitted.token, FACTION);+ assert.equal(submitted.wallet, WALLET);+ assert.equal(submitted.message, CHALLENGE, 'the exact challenge text is echoed back');+ const verified = nacl.sign.detached.verify(+ new TextEncoder().encode(CHALLENGE),+ bs58.default ? bs58.default.decode(submitted.signature) : bs58.decode(submitted.signature),+ KEYPAIR.publicKey,+ );+ assert.ok(verified, 'the submitted signature must verify against the challenge');++ assert.equal(out.ok, true);+ assert.equal(out.eligible, true);+ assert.equal(out.warPass, 'pass_abc');+ assert.equal(out.amount, 125000);+ assert.equal(out.usd, 42.5);+ assert.equal(out.reason, null);+ assert.equal(out.challengeExpiresAt, 1770000300000);+});++test('a wallet that holds none of the coin is answered, not thrown', async () => {+ const routes = enlistRoutes({ verify: { data: { eligible: false, wallet: WALLET, amount: 0, usd: 0, reason: 'not_a_holder' } } });+ const out = await withFetch(routedFetch(routes, []), () => enlistFaction.handler({ token: FACTION, secret: SECRET }));++ assert.equal(out.ok, true);+ assert.equal(out.eligible, false);+ assert.equal(out.warPass, null);+ assert.equal(out.reason, 'not_a_holder');+});++test('enlist_faction rejects an empty faction and a missing signer before any request', async () => {+ const log = [];+ await withFetch(routedFetch({}, log), async () => {+ await assert.rejects(() => enlistFaction.handler({ token: ' ', secret: SECRET }), (err) => err.code === 'validation_error');+ await assert.rejects(() => enlistFaction.handler({ token: FACTION }), (err) => err.code === 'no_signer');+ });+ assert.equal(log.length, 0, 'neither failure should reach the network');+});++test('a challenge with no message to sign is an upstream_error', async () => {+ const routes = { '/api/clash/enlist': { data: {} } };+ await withFetch(routedFetch(routes, []), async () => {+ await assert.rejects(+ () => enlistFaction.handler({ token: FACTION, secret: SECRET }),+ (err) => err.code === 'upstream_error' && /challenge/.test(err.message),+ );+ });+});++// ── rally ─────────────────────────────────────────────────────────────────────++const RALLY_ENVELOPE = {+ data: {+ epoch: 412,+ mint: FACTION,+ added: 14,+ momentum: 1.4,+ walletPower: 140,+ walletCap: 500,+ capped: false,+ factionPower: 1340,+ msLeft: 96000,+ },+};++test('rally_faction spends a war pass directly and shapes the round result', async () => {+ const log = [];+ const out = await withFetch(routedFetch({ '/api/clash/rally': RALLY_ENVELOPE }, log), () =>+ rallyFaction.handler({ pass: ' pass_abc ', taps: 10 }),+ );++ assert.equal(log.length, 1, 'a supplied pass skips the enlist round trip entirely');+ assert.equal(log[0].path, '/api/clash/rally');+ assert.deepEqual(log[0].body, { pass: 'pass_abc', taps: 10 });+ assert.equal(out.ok, true);+ assert.equal(out.added, 14);+ assert.equal(out.factionPower, 1340);+ assert.equal(out.capped, false);+ assert.equal(out.enlisted, undefined, 'no auto-enlist happened, so no enlistment is reported');+});++test('rally_faction auto-enlists from a token and reports the enlistment', async () => {+ const log = [];+ const out = await withFetch(routedFetch({ ...enlistRoutes(), '/api/clash/rally': RALLY_ENVELOPE }, log), () =>+ rallyFaction.handler({ token: FACTION, secret: SECRET, taps: 10 }),+ );++ assert.deepEqual(log.map((c) => c.path), ['/api/clash/enlist', '/api/clash/enlist-verify', '/api/clash/rally']);+ assert.equal(log[2].body.pass, 'pass_abc', 'the freshly minted pass is what gets spent');+ assert.deepEqual(out.enlisted, { wallet: WALLET, amount: 125000, usd: 42.5 });+ assert.equal(out.added, 14);+});++test('rally_faction needs either a pass or a token', async () => {+ const log = [];+ await withFetch(routedFetch({}, log), async () => {+ await assert.rejects(() => rallyFaction.handler({ taps: 5 }), (err) => err.code === 'validation_error');+ });+ assert.equal(log.length, 0);+});++test('auto-enlisting a non-holder throws not_eligible with the wallet and reason', async () => {+ const routes = {+ ...enlistRoutes({ verify: { data: { eligible: false, wallet: WALLET, amount: 0, usd: 0, reason: 'not_a_holder' } } }),+ '/api/clash/rally': RALLY_ENVELOPE,+ };+ const log = [];+ await withFetch(routedFetch(routes, log), async () => {+ await assert.rejects(+ () => rallyFaction.handler({ token: FACTION, secret: SECRET, taps: 5 }),+ (err) => {+ assert.equal(err.code, 'not_eligible');+ assert.deepEqual(err.detail, { wallet: WALLET, faction: FACTION, reason: 'not_a_holder' });+ return true;+ },+ );+ });+ assert.ok(+ !log.some((c) => c.path === '/api/clash/rally'),+ 'an ineligible wallet must never reach the rally endpoint',+ );+});diff --git a/packages/copy-mcp/README.md b/packages/copy-mcp/README.mdindex c1ad11104..29fd9903c 100644--- a/packages/copy-mcp/README.md+++ b/packages/copy-mcp/README.md@@ -34,7 +34,7 @@ npx @three-ws/copy-mcp## Quick start-Copy trading is account-scoped, so set `THREE_WS_API_KEY` to a three.ws API key (`sk_live_…` / `sk_test_…`) or OAuth access token — mint one at [three.ws/settings/api-keys](https://three.ws/settings/api-keys).+Copy trading is account-scoped, so set `THREE_WS_API_KEY` to a three.ws API key (`sk_live_…` / `sk_test_…`) or OAuth access token. Mint one at [three.ws/dashboard/developers](https://three.ws/dashboard/developers).**Claude Code**, one line:@@ -180,8 +180,8 @@ A failed tool call returns an MCP error result (`isError: true`) whose text is a| `missing_credential` | The tool needs auth and `THREE_WS_API_KEY` is unset. Thrown before any request is sent. | Set the key. || `validation_error` | Bad arguments caught client-side, e.g. `sizing_rule: "fixed"` without a positive `fixed_sol`. | Fix the call. || `no_changes` | `update_subscription` was called with only an `id`. | Pass at least one field to change. |-| `not_found` | The subscription `id` does not exist on this account. | Check `list_subscriptions`. |-| `upstream_error` | The API rejected the request; `status` carries the HTTP code (`400` bad fields, `401` bad/expired credential, `429` rate-limited). | Act on the message and `status`. |+| `not_found` | `update_subscription` was given an `id` that is not one of your subscriptions. | Check `list_subscriptions`. |+| `upstream_error` | The API rejected the request; `status` carries the HTTP code (`400` bad fields, `401` bad/expired credential, `404` no such subscription on `cancel_subscription`, `409` no such pending intent on `record_execution`, `429` rate-limited). | Act on the message and `status`. || `timeout` | No response within `THREE_WS_TIMEOUT_MS`. | Retry or raise the timeout. || `network_error` | The request never reached the API (DNS, offline, TLS). | Check connectivity / `THREE_WS_BASE`. || `bad_config` | `THREE_WS_TIMEOUT_MS` is not a positive number. Thrown while the server starts (module load), so the process exits before serving. | Fix the env var. |diff --git a/packages/copy-mcp/server.json b/packages/copy-mcp/server.jsonindex 9351d47f6..81a23896a 100644--- a/packages/copy-mcp/server.json+++ b/packages/copy-mcp/server.json@@ -31,7 +31,7 @@"environmentVariables": [{"name": "THREE_WS_API_KEY",- "description": "Your three.ws bearer credential — an API key (sk_live_… / sk_test_…) or OAuth access token. Every copy-trade subscription, intent, and fee is scoped to the account it identifies. Required for all tools except a leader's public aggregate earnings. Mint one at https://three.ws/settings/api-keys. Treat like cash.",+ "description": "Your three.ws bearer credential: an API key (sk_live_… / sk_test_…) or OAuth access token. Every copy-trade subscription, intent, and fee is scoped to the account it identifies. Required for all tools except a leader's public aggregate earnings. Mint one at https://three.ws/dashboard/developers. Treat like cash.","format": "string","isRequired": true,"isSecret": truediff --git a/packages/copy-mcp/src/config.js b/packages/copy-mcp/src/config.jsindex a0f72dfae..5a799e69f 100644--- a/packages/copy-mcp/src/config.js+++ b/packages/copy-mcp/src/config.js@@ -20,7 +20,7 @@ export const THREE_WS_BASE = env('THREE_WS_BASE', 'https://three.ws').replace(/\// The copier's bearer credential. Read lazily (empty default) so importing the// module — and therefore buildServer() in the offline tests — never requires a// key; account-scoped tools throw a clear `missing_credential` at call time if-// it is absent. Mint one at https://three.ws/settings/api-keys.+// it is absent. Mint one at https://three.ws/dashboard/developers.export const THREE_WS_API_KEY = env('THREE_WS_API_KEY', '');// Per-request timeout (ms). These are live reads/writes against the copy enginediff --git a/packages/copy-mcp/src/lib/api.js b/packages/copy-mcp/src/lib/api.jsindex be992e6a1..a07e8d831 100644--- a/packages/copy-mcp/src/lib/api.js+++ b/packages/copy-mcp/src/lib/api.js@@ -23,8 +23,8 @@ export async function apiRequest(path, { method = 'GET', query, body, auth = truthrow Object.assign(new Error('This action is account-scoped. Set THREE_WS_API_KEY to a three.ws API key ' +- '(sk_live_… / sk_test_…) or OAuth access token — mint one at ' +- 'https://three.ws/settings/api-keys.',+ '(sk_live_… / sk_test_…) or OAuth access token. Mint one at ' ++ 'https://three.ws/dashboard/developers.',),{ code: 'missing_credential', status: 401 },);diff --git a/prompts/swarm-100/packages-batch-04.md b/prompts/swarm-100/packages-batch-04.mddeleted file mode 100644index 9f2d8586b..000000000--- a/prompts/swarm-100/packages-batch-04.md+++ /dev/null@@ -1,95 +0,0 @@-# Package audit batch 04: brain-mcp, clash-mcp, concierge-mcp, copy-mcp, defi-utils, forge--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--For each package below: read its package.json and README.md, then find its-tests (its own directory and tests/ at the repo root).--## Task: audit and fix these packages--Packages in this batch:--- packages/brain-mcp-- packages/clash-mcp-- packages/concierge-mcp-- packages/copy-mcp-- packages/defi-utils-- packages/forge--For each one:--1. README: present (repo standard is 100% coverage under packages/) and- accurate: what it does, install and use, public exports, one runnable- example. Run the example for real.-2. Exports resolve: import the package's declared entry points with node and- confirm they load without error.-3. Tests: run the tests that cover it; if its core path has none, add a real- one.-4. Hard-rule scan across its source: no stubs, no mock fallbacks, no- unfinished markers, no commented-out code. Fix at root.-5. package.json sanity: name, version, license, exports and files fields- consistent with what is actually shipped.--## Definition of done--- [ ] Every package in the batch: README verified accurate, example executed,- entry points imported cleanly, tests green with core-path coverage.-- [ ] Zero hard-rule violations remain in these packages.-- [ ] npm run check:rules -- --paths <touched files> exits 0.--## 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/packages-batch-04.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.