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(llm-proxy): meter streamed embed answers, keep streamed tool calls whole, and repair the dead failover rung
nirholas0c1d00520353
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 569a33310..684540ed4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,12 +9,16 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **A shared walk card no longer sends people to an avatar that is gone**: Sharing a walk produces a card you can post on Farcaster, with a button that opens that avatar walking. A cast stays up forever, but the avatar behind it does not: it can be deleted, or switched to private. When that happened the button still pointed at the missing avatar, so anyone who tapped it landed on a walk that could never load, and the card's second button pointed at the same place as the first, so both said the same thing. The card now checks the avatar before it builds. If the avatar is gone or private it drops the link and invites you to walk your own instead of handing you a dead button, and if the check itself cannot run the link is kept rather than thrown away. The second button now goes to the avatar builder, so the two buttons finally offer two different things. The card also carries its image dimensions now, which stops the preview from reflowing while it loads. (`/walk`) `[fix]`- **An avatar rendered through the MCP server can no longer be turned into a tracking beacon**: When an AI assistant renders one of your avatars through the three.ws MCP server, the server builds a small viewer page and the assistant displays it. The caller picks the background for that page. The check on that value blocked anything that could break out of the styling, but it still allowed a CSS url(), so a caller could point the background at an image on a server they control and quietly collect the address and referring page of everyone who ever viewed that avatar. Backgrounds and gradients never need url(), so it is refused outright now and the safe default is used instead. A second fix went in with it: the server works out its own public web address to build the links it hands back, and its test for a local development address matched anywhere in the name instead of the whole name, so a request arriving with a forged host like evil-127.0.0.1.example.com was treated as local and got plain http links rather than https. That test is now anchored to the whole host, and IPv6 loopback is recognised properly. The animation tools also stopped treating built-in JavaScript property names as though they were real animation clips, and the shared MCP helpers behind all of this are now covered by tests. (`/docs/mcp`) `[security, fix]`- **An expired Bitcoin inscription order now says so, instead of looking like a broken server**: The Forever page writes your message into Bitcoin, then keeps a pay screen open while you send the payment from your own wallet. That screen is restored when you come back to the tab. If the inscription order behind it had since expired, the page had no way to say so: the server reported an order it could not find as a server fault, so the pay screen either sat there polling an order that no longer existed, or repainted itself empty with no charge address and no explanation. An order that no longer exists is now reported as exactly that, and the page retires it, tells you nothing was charged, and puts you back at the message box to start a new one. Three related fixes went in with it. An inscription that the provider rejected could come back marked as success, which briefly showed a pay screen for an order that was never created; every provider failure is now reported as one. A receive address with a typo is now caught by its checksum before the order is created, and tells you to recopy it from your wallet, rather than failing later with a message that explained nothing. And an order that expired unpaid is no longer counted as paid. (`/forever`) `[fix]`+- **Embedded agents keep their tool calls, and the free brain lane bills what it actually used**: The we-pay brain behind every embedded agent streams its answers, and three things in that stream were wrong. Free providers were never asked to report how many tokens a streamed answer used, so the monthly token budget an owner sets on an agent counted zero for the lane most embeds run on: the budget could not be reached, and the usage screen showed no spend for real traffic. Groq reports those numbers in a field of its own, which was being ignored for the same reason; both are now read and charged. Tool calls fared worse: when a provider streamed a tool name in pieces, only the first piece survived, so the agent tried to call a tool that does not exist, and a call whose id never arrived was dropped in silence instead of being passed on. Finally, the second step of the automatic failover chain pointed at a model that no longer exists anywhere, so a rate-limited free lane skipped straight past it; it now points at a live free model on a separate account, and requests that leave the token limit unset no longer draw an avoidable rejection from Anthropic. (`/docs/api-reference`) `[fix, improvement]`+- **FBX export on the OKX 3D service line works again, and the Chinese-brief avatar prompt keeps its subject**: The paid FBX export service at /api/okx/3d/fbx-export was handing the conversion engine the wrong field names, so every call came back as a bad-request error and no model was ever converted. Nobody was charged for the failed calls, but nobody got an FBX either. It now speaks the engine's own contract, honors the requested target format (FBX, OBJ, STL, PLY, USDZ, 3MF), and a new test holds each of the three engine-backed services to the schema its engine publishes so a renamed field cannot break a paid lane again. Separately, when the Agent Identity Studio prompt director is unavailable, a Chinese-language brand brief now contributes only its first sentence to the fallback prompt, the same way an English one does, instead of pushing the style hints out of the generator's prompt budget. (`/api/okx/3d/catalog`) `[fix]`- **FBX export on the OKX 3D studio works again**: The paid FBX export service at /api/okx/3d/fbx-export was handing the conversion engine the wrong parameter names, so every call came back as a rejected request instead of a converted model, and the format you asked for was dropped on the way through. The adapter now speaks the engine's own parameter names, so a rigged GLB converts to FBX (or OBJ, STL, PLY, USDZ, 3MF) and keeps its skeleton, skin weights, and blendshapes. Buyers were never charged for the failed calls. A contract test now checks every OKX studio service against the schema its engine actually publishes, so a renamed parameter cannot slip through again. Separately, a Chinese-language brand brief sent to the Agent Identity Studio now has its first sentence picked out correctly when the prompt director is unavailable, instead of the whole brief crowding out the style hints. (`/api/okx/3d/catalog`) `[fix]`- **Importing an agent you already own on-chain no longer fails because its metadata host is slow**: If you registered an agent on-chain, the hydrate page finds it from your connected wallets and offers to import it into three.ws. Importing read two things: the registry entry on the chain, and the registration file the registry points at, which usually lives on IPFS. If that file did not load in five seconds, the whole import was refused, even though the part that actually matters, the chain saying you own the agent, had already answered. Public IPFS gateways throttle constantly, so owners were locked out of their own agents by a slow third party. The import now only needs the chain read to succeed; a registration file that will not load means the agent lands under its on-chain name and the metadata fills in on the next crawl. Two more changes went in alongside it: ownership is now re-checked against the live registry rather than the crawler's cached copy, so an agent you transferred away cannot be imported by the old wallet, and a chain that is unreachable now says so plainly and asks you to retry instead of reporting a generic failure. Separately, confirming a new registration now reads the transaction receipt over the same priority provider list the rest of the platform uses, instead of the slowest public fallbacks, which is what made a freshly mined registration occasionally come back as "not yet mined". (`/hydrate`) `[fix]`- **One bad request can no longer use up the whole hourly AI-governance budget**: The Trust Layer endpoint that screens messages and proposed money moves through IBM Granite Guardian has an hourly platform-wide ceiling on how much model work it will pay for. That ceiling was being charged on every incoming request, including ones that were rejected before any model ran: a malformed body, a missing field, or a request arriving while the service is not configured. A single misbehaving client sending junk could therefore exhaust the shared budget and leave everyone else rate-limited for the rest of the hour without a single real assessment happening. The ceiling is now charged only when an assessment actually runs. Two error replies were also wrong in a way that misled callers: sending the wrong content type or a body over the size limit both came back as generic malformed JSON, so the fix looked like editing your payload when it was really a header or a smaller body. They now return the correct unsupported-media-type and payload-too-large codes, and the endpoint rejects a non-object body with a message that says so. (`/docs/okx-marketplace`) `[fix, improvement]`+- **Rankings stops counting your own remixes, and the Daily Match board opens up to other sites**: The Remixes Received ranking on /rankings was meant to count derivatives other creators made from your work. It was also counting your own refinements of your own model, and generations that never finished, so a creator could climb the board without anyone else touching their work. It now counts only finished derivatives made by someone else, which is what the board always claimed to measure. Separately, the public Daily Match standings endpoint sent no cross-origin permission header, so any site other than three.ws that tried to read the board was blocked by the browser. It now allows any origin, matching the unified leaderboard, and both boards are covered by tests. (`/rankings`) `[fix]`- **The $THREE tile on the live heatmap shows real buy pressure again**: The 3D market heatmap on agent screens pins $THREE as its anchor tile, and that tile was meant to carry a community pulse alongside price and volume. The pulse read pump.fun's public comments feed, which pump.fun has since removed from its open API, so the tile had been quietly shipping without it: no error, just a signal that never appeared. The anchor now carries its 24h order flow instead, read from the same live market data the tile already fetches: how many of the last day's swaps were buys versus sells, as a percentage and a leaning score. Hovering the anchor shows it, and the screen's spoken market narration calls it out. Two related fixes landed with it. The wallet and coin intel endpoints now reject a malformed address with a clear error instead of answering as though the address simply had no history. And a total market-data outage now returns a proper error rather than an anchor tile with no numbers in it. `[fix, improvement]`- **The 3D sentiment heatmap shows live $THREE order flow again after pump.fun retired its comments API**: The heatmap on agent screens pins $THREE at the centre and used to enrich that tile with a sentiment reading scored from pump.fun coin-page comments. pump.fun removed that public comments feed, so the reading silently disappeared: the tooltip row and the narrator's line about it simply stopped rendering, with nothing to say why. The anchor tile now carries a live 24h order-flow pulse instead, read from the same market data the tile already fetches: how the last day of trades split between buys and sells, shown as a buy percentage in the tooltip and folded into the narrator's read of the tape. It is real observed swap activity and costs no extra upstream call. Two related fixes: a total market-data outage with no cached field now returns a clear error instead of a single lifeless tile, and the wallet and coin intel endpoints answer a mistyped address with a plain bad-request message rather than treating it as a real wallet with no history. (`/docs/api-reference`) `[fix, improvement]`- **The AI safety check stays available even when someone floods it with bad requests**: Every message and every autonomous money move an avatar makes is screened by the IBM Granite Guardian safety check before it runs. That check has an hourly platform-wide ceiling so one busy hour cannot run up an unbounded inference bill. The ceiling was being charged on every request that arrived, including ones that were rejected on the spot for a malformed body and never reached the safety model at all. A single client sending junk could therefore burn the whole platform hour and leave everyone else refused for real, valid checks. The ceiling is now charged only when an actual screening runs. Two error replies were also corrected: sending the wrong content type now answers 415 and an oversized body answers 413, instead of both being reported as generic bad input, so a caller can see which of the two to fix. (`/docs/ibm`) `[fix]`+- **The CC0 object library answers a bad page request instead of quietly handing back the wrong page**: The free prop library behind /objects and the AR Studio Objects tray is also a public API anyone can page through. Ask it for a page size it cannot parse and it used to guess: a word where a number belongs silently returned a single object, a fractional page size handed back a fractional position to ask for next, and a page position sent without a page size was ignored outright. Every one of those looked like working pagination while quietly skipping or repeating props, so a script walking the whole catalogue could finish believing it had seen all 511 when it had not. Bad page requests now come back immediately as a clear error naming the parameter and the accepted range, while an oversized page still simply caps at the documented maximum. Separately, when the storage behind the library has a hiccup the endpoint still degrades to an empty list rather than an error page, but that emptiness is no longer cached for the next five minutes: the library reappears the moment storage recovers instead of staying blank long after. (`/objects`) `[fix, improvement]`- **The decentralized inference demo stops sending your prompt to a gateway that is no longer Livepeer**: The decentralized inference lab runs the same prompt through our own inference chain and through a Livepeer AI gateway, side by side. The free no-key gateway it used has not been Livepeer since early August: that hostname now points at an unrelated server. The demo kept posting prompts to it on every run and showing a bare connection error. It no longer dials that host at all. The decentralized card now reports the gateway as unavailable and names the two settings that bring it back (a Livepeer Studio key, or the address of a self-hosted gateway), and a self-hosted address is now honored by both this demo and the Forge Livepeer lane from one shared setting. The call also has a time limit, so a gateway that accepts the connection and then goes quiet can no longer hold up the reply from the other side of the comparison. (`/demos`) `[fix, improvement]`- **The extra views behind a 3D generation stop being rejected for the wrong file type**: Before a prompt becomes a 3D model, the forge draws a reference picture, then draws two more views of it so the reconstruction can see the sides and back instead of guessing them. Those extra views sent the reference picture to the image model labelled as a PNG no matter what it actually was, so a JPEG or WebP reference could be refused outright and you would quietly get fewer views and a rougher model. The real format is now read from the picture and sent with it. A reference that is unreachable, oversized, or not actually an image is now refused with a clear reason instead of being forwarded as-is and failing further down. And every image this step fetches, including the optional edit mask, now goes through the same address safety check the rest of the platform uses, so a supplied link cannot be aimed at an internal address. (`/create`) `[fix, security]`- **The image step behind 3D generation now times out, checks its inputs, and stops mislabelling them**: Before a prompt becomes a 3D model, the forge draws a reference picture, then draws two extra views of it so the reconstruction can see the sides and back instead of guessing them. Three problems sat in that step. The calls to the image service had no time limit, so a connection that opened and then stalled held a generation open indefinitely rather than falling back to the free image lane; they now give up after ninety seconds and hand off. The extra views sent the reference picture to the model labelled as a PNG no matter what it actually was, so a JPEG or WebP reference could be rejected and you would quietly get fewer views; the real format is now read from the picture and sent with it. And a reference that is unreachable or oversized is refused with a clear reason instead of being forwarded as-is. Alongside that, every image this step fetches, including the optional mask, now goes through the same address safety check the rest of the platform uses, so a supplied URL cannot be aimed at an internal address. (`/create`) `[fix, security]`diff --git a/data/changelog.json b/data/changelog.jsonindex c404a207f..9410e5a14 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,53 @@{"$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-13",+ "title": "Copy-trading set up by an agent now keeps its alerts and can pay its leader",+ "summary": "Agents that arrange copy-trading through the MCP tools hit three problems. A Telegram chat supplied for copy alerts was thrown away, and worse, adjusting an existing subscription erased the chat already set on the dashboard, so the alerts stopped. Subscriptions created this way also never recorded the leader payout wallet, which meant the leader performance fee could not be settled on them. And when the database was briefly unreachable, the tools answered with a confident wrong answer: your leader does not exist, or you have no subscriptions at all. Alerts and the payout wallet are now stored correctly, an outage says plainly that the service is temporarily unavailable, two agents subscribing at the same moment no longer collide, and a trader profile now returns the open positions it always advertised so a leader can be vetted before being copied.",+ "tags": [+ "fix"+ ],+ "link": "/dashboard/copy"+ },+ {+ "date": "2026-08-13",+ "title": "Embedded agents keep their tool calls, and the free brain lane bills what it actually used",+ "summary": "The we-pay brain behind every embedded agent streams its answers, and three things in that stream were wrong. Free providers were never asked to report how many tokens a streamed answer used, so the monthly token budget an owner sets on an agent counted zero for the lane most embeds run on: the budget could not be reached, and the usage screen showed no spend for real traffic. Groq reports those numbers in a field of its own, which was being ignored for the same reason; both are now read and charged. Tool calls fared worse: when a provider streamed a tool name in pieces, only the first piece survived, so the agent tried to call a tool that does not exist, and a call whose id never arrived was dropped in silence instead of being passed on. Finally, the second step of the automatic failover chain pointed at a model that no longer exists anywhere, so a rate-limited free lane skipped straight past it; it now points at a live free model on a separate account, and requests that leave the token limit unset no longer draw an avoidable rejection from Anthropic.",+ "tags": [+ "fix",+ "improvement"+ ],+ "link": "/docs/api-reference"+ },+ {+ "date": "2026-08-13",+ "title": "The CC0 object library answers a bad page request instead of quietly handing back the wrong page",+ "summary": "The free prop library behind /objects and the AR Studio Objects tray is also a public API anyone can page through. Ask it for a page size it cannot parse and it used to guess: a word where a number belongs silently returned a single object, a fractional page size handed back a fractional position to ask for next, and a page position sent without a page size was ignored outright. Every one of those looked like working pagination while quietly skipping or repeating props, so a script walking the whole catalogue could finish believing it had seen all 511 when it had not. Bad page requests now come back immediately as a clear error naming the parameter and the accepted range, while an oversized page still simply caps at the documented maximum. Separately, when the storage behind the library has a hiccup the endpoint still degrades to an empty list rather than an error page, but that emptiness is no longer cached for the next five minutes: the library reappears the moment storage recovers instead of staying blank long after.",+ "tags": [+ "fix",+ "improvement"+ ],+ "link": "/objects"+ },+ {+ "date": "2026-08-13",+ "title": "FBX export on the OKX 3D service line works again, and the Chinese-brief avatar prompt keeps its subject",+ "summary": "The paid FBX export service at /api/okx/3d/fbx-export was handing the conversion engine the wrong field names, so every call came back as a bad-request error and no model was ever converted. Nobody was charged for the failed calls, but nobody got an FBX either. It now speaks the engine's own contract, honors the requested target format (FBX, OBJ, STL, PLY, USDZ, 3MF), and a new test holds each of the three engine-backed services to the schema its engine publishes so a renamed field cannot break a paid lane again. Separately, when the Agent Identity Studio prompt director is unavailable, a Chinese-language brand brief now contributes only its first sentence to the fallback prompt, the same way an English one does, instead of pushing the style hints out of the generator's prompt budget.",+ "tags": [+ "fix"+ ],+ "link": "/api/okx/3d/catalog"+ },+ {+ "date": "2026-08-13",+ "title": "Rankings stops counting your own remixes, and the Daily Match board opens up to other sites",+ "summary": "The Remixes Received ranking on /rankings was meant to count derivatives other creators made from your work. It was also counting your own refinements of your own model, and generations that never finished, so a creator could climb the board without anyone else touching their work. It now counts only finished derivatives made by someone else, which is what the board always claimed to measure. Separately, the public Daily Match standings endpoint sent no cross-origin permission header, so any site other than three.ws that tried to read the board was blocked by the browser. It now allows any origin, matching the unified leaderboard, and both boards are covered by tests.",+ "tags": [+ "fix"+ ],+ "link": "/rankings"+ },{"date": "2026-08-13","title": "The three.ws launchpad directory answers a bad filter instead of erroring out",diff --git a/prompts/swarm-100/api-internal-okx3d-01.md b/prompts/swarm-100/api-internal-okx3d-01.mddeleted file mode 100644index 7e7795f61..000000000--- a/prompts/swarm-100/api-internal-okx3d-01.md+++ /dev/null@@ -1,103 +0,0 @@-# API audit: api/_okx3d batch 01 (3 files)--How to run: paste this file's repo path into a fresh Claude Code chat in this-repository and say "run this work order". This file is fully self-contained:-it depends on no other prompt file anywhere. If neighboring files in-prompts/swarm-100/ are gone, that work is done; if present, ignore them.-Every claim below rots; step 0 re-measures, and what you measure wins.--## Operating clause (binding)--- Read CLAUDE.md first. Its rules override everything, including this file.-- Finish 100% in this session. Never end the turn with a question, an option- list, or an unexecuted plan. A judgment call goes in one line of the final- report; it never becomes a question that halts work.-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real- funds or any irreversible on-chain write, git push or a production deploy,- committing content that references a crypto project other than $THREE, and- destroying unrecoverable data.-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no- commented-out code. Real APIs and real integrations only.-- The em-dash and en-dash characters are banned in everything you write.-- Concurrent agents share this worktree: stage explicit paths only (never a- bare add-everything), and commit finished work promptly.-- Before committing, run: npm run check:rules -- --paths <files you touched>.- It must exit 0.--## Step 0: re-derive the current state--1. Confirm each file below still exists; deleted ones are done, skip them.-2. For each, decide routability: grep its path in vercel.json and read how- server/index.mjs maps filesystem handlers. Routed files get an endpoint- audit; internal modules get a code and test audit.-3. Start a local server for endpoint checks: node server/index.mjs with .env- loaded, on a free PORT if 3000 is busy.--## Task: audit these api files, then fix everything found--Files in this batch:--- api/_okx3d/identity.js-- api/_okx3d/rest-services.js-- api/_okx3d/tools.js--For every routed handler:--1. Exercise it with curl against the local server: the success path returns- real data with the correct status; malformed input returns a 4xx JSON- error, never a stack trace or an HTML error page; auth is enforced where- the code intends it; CORS matches neighboring handlers.-2. Hard-rule scan: no mock fallbacks, no fake-data arrays, no stubbed- responses, no unfinished markers. Errors are handled at the boundary and- internal code trusts itself.-3. Do not spend funds or sign anything on-chain while probing. Payment and- trading handlers get their validation and error paths exercised, never a- live settlement.--For every internal (non-routed) module:--4. Something must import it; if nothing does, delete it as dead code (verify- with a repo-wide grep first).-5. Its main path and one failure path must be covered in tests/; add the- missing test if not.--## Definition of done--- [ ] Every listed file has recorded evidence: a curl transcript for routed- handlers, a passing test or a deletion for internal modules.-- [ ] Zero hard-rule violations remain in these files.-- [ ] vitest run passes; 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/api-internal-okx3d-01.md-- The shrinking directory is this campaign's only progress ledger; there is- no progress log to update.-4. Final report: what step 0 measured, what changed (file list), evidence per- Definition of done line, and any one-line judgment calls. No trailing- questions, no unexecuted plans.--If a line genuinely cannot pass inside this session (an external party must-respond, or an owner-gated action is the final step), finish everything else,-leave this file in place, and state exactly which line remains and who owns-it. Never delete this file on a partial.diff --git a/prompts/swarm-100/api-llm-01.md b/prompts/swarm-100/api-llm-01.mddeleted file mode 100644index d2c85a1d5..000000000--- a/prompts/swarm-100/api-llm-01.md+++ /dev/null@@ -1,102 +0,0 @@-# API audit: api/llm batch 01 (2 files)--How to run: paste this file's repo path into a fresh Claude Code chat in this-repository and say "run this work order". This file is fully self-contained:-it depends on no other prompt file anywhere. If neighboring files in-prompts/swarm-100/ are gone, that work is done; if present, ignore them.-Every claim below rots; step 0 re-measures, and what you measure wins.--## Operating clause (binding)--- Read CLAUDE.md first. Its rules override everything, including this file.-- Finish 100% in this session. Never end the turn with a question, an option- list, or an unexecuted plan. A judgment call goes in one line of the final- report; it never becomes a question that halts work.-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real- funds or any irreversible on-chain write, git push or a production deploy,- committing content that references a crypto project other than $THREE, and- destroying unrecoverable data.-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no- commented-out code. Real APIs and real integrations only.-- The em-dash and en-dash characters are banned in everything you write.-- Concurrent agents share this worktree: stage explicit paths only (never a- bare add-everything), and commit finished work promptly.-- Before committing, run: npm run check:rules -- --paths <files you touched>.- It must exit 0.--## Step 0: re-derive the current state--1. Confirm each file below still exists; deleted ones are done, skip them.-2. For each, decide routability: grep its path in vercel.json and read how- server/index.mjs maps filesystem handlers. Routed files get an endpoint- audit; internal modules get a code and test audit.-3. Start a local server for endpoint checks: node server/index.mjs with .env- loaded, on a free PORT if 3000 is busy.--## Task: audit these api files, then fix everything found--Files in this batch:--- api/llm/anthropic.js-- api/llm/health.js--For every routed handler:--1. Exercise it with curl against the local server: the success path returns- real data with the correct status; malformed input returns a 4xx JSON- error, never a stack trace or an HTML error page; auth is enforced where- the code intends it; CORS matches neighboring handlers.-2. Hard-rule scan: no mock fallbacks, no fake-data arrays, no stubbed- responses, no unfinished markers. Errors are handled at the boundary and- internal code trusts itself.-3. Do not spend funds or sign anything on-chain while probing. Payment and- trading handlers get their validation and error paths exercised, never a- live settlement.--For every internal (non-routed) module:--4. Something must import it; if nothing does, delete it as dead code (verify- with a repo-wide grep first).-5. Its main path and one failure path must be covered in tests/; add the- missing test if not.--## Definition of done--- [ ] Every listed file has recorded evidence: a curl transcript for routed- handlers, a passing test or a deletion for internal modules.-- [ ] Zero hard-rule violations remain in these files.-- [ ] vitest run passes; 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/api-llm-01.md-- The shrinking directory is this campaign's only progress ledger; there is- no progress log to update.-4. Final report: what step 0 measured, what changed (file list), evidence per- Definition of done line, and any one-line judgment calls. No trailing- questions, no unexecuted plans.--If a line genuinely cannot pass inside this session (an external party must-respond, or an owner-gated action is the final step), finish everything else,-leave this file in place, and state exactly which line remains and who owns-it. Never delete this file on a partial.diff --git a/public/changelog.json b/public/changelog.jsonindex 88eb48988..ed606e1a7 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-08-13T01:47:10.912Z",+ "generated_at": "2026-08-13T02:06:29.190Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -37,6 +37,27 @@"fix"]},+ {+ "date": "2026-08-13",+ "type": "update",+ "title": "Embedded agents keep their tool calls, and the free brain lane bills what it actually used",+ "summary": "The we-pay brain behind every embedded agent streams its answers, and three things in that stream were wrong. Free providers were never asked to report how many tokens a streamed answer used, so the monthly token budget an owner sets on an agent counted zero for the lane most embeds run on: the budget could not be reached, and the usage screen showed no spend for real traffic. Groq reports those numbers in a field of its own, which was being ignored for the same reason; both are now read and charged. Tool calls fared worse: when a provider streamed a tool name in pieces, only the first piece survived, so the agent tried to call a tool that does not exist, and a call whose id never arrived was dropped in silence instead of being passed on. Finally, the second step of the automatic failover chain pointed at a model that no longer exists anywhere, so a rate-limited free lane skipped straight past it; it now points at a live free model on a separate account, and requests that leave the token limit unset no longer draw an avoidable rejection from Anthropic.",+ "link": "/docs/api-reference",+ "tags": [+ "fix",+ "improvement"+ ]+ },+ {+ "date": "2026-08-13",+ "type": "update",+ "title": "FBX export on the OKX 3D service line works again, and the Chinese-brief avatar prompt keeps its subject",+ "summary": "The paid FBX export service at /api/okx/3d/fbx-export was handing the conversion engine the wrong field names, so every call came back as a bad-request error and no model was ever converted. Nobody was charged for the failed calls, but nobody got an FBX either. It now speaks the engine's own contract, honors the requested target format (FBX, OBJ, STL, PLY, USDZ, 3MF), and a new test holds each of the three engine-backed services to the schema its engine publishes so a renamed field cannot break a paid lane again. Separately, when the Agent Identity Studio prompt director is unavailable, a Chinese-language brand brief now contributes only its first sentence to the fallback prompt, the same way an English one does, instead of pushing the style hints out of the generator's prompt budget.",+ "link": "/api/okx/3d/catalog",+ "tags": [+ "fix"+ ]+ },{"date": "2026-08-13","type": "update",@@ -68,6 +89,16 @@"improvement"]},+ {+ "date": "2026-08-13",+ "type": "update",+ "title": "Rankings stops counting your own remixes, and the Daily Match board opens up to other sites",+ "summary": "The Remixes Received ranking on /rankings was meant to count derivatives other creators made from your work. It was also counting your own refinements of your own model, and generations that never finished, so a creator could climb the board without anyone else touching their work. It now counts only finished derivatives made by someone else, which is what the board always claimed to measure. Separately, the public Daily Match standings endpoint sent no cross-origin permission header, so any site other than three.ws that tried to read the board was blocked by the browser. It now allows any origin, matching the unified leaderboard, and both boards are covered by tests.",+ "link": "/rankings",+ "tags": [+ "fix"+ ]+ },{"date": "2026-08-13","type": "update",@@ -100,6 +131,17 @@"fix"]},+ {+ "date": "2026-08-13",+ "type": "update",+ "title": "The CC0 object library answers a bad page request instead of quietly handing back the wrong page",+ "summary": "The free prop library behind /objects and the AR Studio Objects tray is also a public API anyone can page through. Ask it for a page size it cannot parse and it used to guess: a word where a number belongs silently returned a single object, a fractional page size handed back a fractional position to ask for next, and a page position sent without a page size was ignored outright. Every one of those looked like working pagination while quietly skipping or repeating props, so a script walking the whole catalogue could finish believing it had seen all 511 when it had not. Bad page requests now come back immediately as a clear error naming the parameter and the accepted range, while an oversized page still simply caps at the documented maximum. Separately, when the storage behind the library has a hiccup the endpoint still degrades to an empty list rather than an error page, but that emptiness is no longer cached for the next five minutes: the library reappears the moment storage recovers instead of staying blank long after.",+ "link": "/objects",+ "tags": [+ "fix",+ "improvement"+ ]+ },{"date": "2026-08-13","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 862c2b791..53ea1a961 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -30,6 +30,22 @@<category>fix</category><description>The Forever page writes your message into Bitcoin, then keeps a pay screen open while you send the payment from your own wallet. That screen is restored when you come back to the tab. If the inscription order behind it had since expired, the page had no way to say so: the server reported an order it could not find as a server fault, so the pay screen either sat there polling an order that no longer existed, or repainted itself empty with no charge address and no explanation. An order that no longer exists is now reported as exactly that, and the page retires it, tells you nothing was charged, and puts you back at the message box to start a new one. Three related fixes went in with it. An inscription that the provider rejected could come back marked as success, which briefly showed a pay screen for an order that was never created; every provider failure is now reported as one. A receive address with a typo is now caught by its checksum before the order is created, and tells you to recopy it from your wallet, rather than failing later with a message that explained nothing. And an order that expired unpaid is no longer counted as paid.</description></item>+ <item>+ <title>Embedded agents keep their tool calls, and the free brain lane bills what it actually used</title>+ <link>https://three.ws/docs/api-reference</link>+ <guid isPermaLink="false">2026-08-13:Embedded agents keep their tool calls, and the free brain lane bills what it actually used</guid>+ <pubDate>Thu, 13 Aug 2026 12:00:00 GMT</pubDate>+ <category>fix</category>+ <description>The we-pay brain behind every embedded agent streams its answers, and three things in that stream were wrong. Free providers were never asked to report how many tokens a streamed answer used, so the monthly token budget an owner sets on an agent counted zero for the lane most embeds run on: the budget could not be reached, and the usage screen showed no spend for real traffic. Groq reports those numbers in a field of its own, which was being ignored for the same reason; both are now read and charged. Tool calls fared worse: when a provider streamed a tool name in pieces, only the first piece survived, so the agent tried to call a tool that does not exist, and a call whose id never arrived was dropped in silence instead of being passed on. Finally, the second step of the automatic failover chain pointed at a model that no longer exists anywhere, so a rate-limited free lane skipped straight past it; it now points at a live free model on a separate account, and requests that leave the token limit unset no longer draw an avoidable rejection from Anthropic.</description>+ </item>+ <item>+ <title>FBX export on the OKX 3D service line works again, and the Chinese-brief avatar prompt keeps its subject</title>+ <link>https://three.ws/api/okx/3d/catalog</link>+ <guid isPermaLink="false">2026-08-13:FBX export on the OKX 3D service line works again, and the Chinese-brief avatar prompt keeps its subject</guid>+ <pubDate>Thu, 13 Aug 2026 12:00:00 GMT</pubDate>+ <category>fix</category>+ <description>The paid FBX export service at /api/okx/3d/fbx-export was handing the conversion engine the wrong field names, so every call came back as a bad-request error and no model was ever converted. Nobody was charged for the failed calls, but nobody got an FBX either. It now speaks the engine's own contract, honors the requested target format (FBX, OBJ, STL, PLY, USDZ, 3MF), and a new test holds each of the three engine-backed services to the schema its engine publishes so a renamed field cannot break a paid lane again. Separately, when the Agent Identity Studio prompt director is unavailable, a Chinese-language brand brief now contributes only its first sentence to the fallback prompt, the same way an English one does, instead of pushing the style hints out of the generator's prompt budget.</description>+ </item><item><title>FBX export on the OKX 3D studio works again</title><link>https://three.ws/api/okx/3d/catalog</link>@@ -54,6 +70,14 @@<category>fix</category><description>The Trust Layer endpoint that screens messages and proposed money moves through IBM Granite Guardian has an hourly platform-wide ceiling on how much model work it will pay for. That ceiling was being charged on every incoming request, including ones that were rejected before any model ran: a malformed body, a missing field, or a request arriving while the service is not configured. A single misbehaving client sending junk could therefore exhaust the shared budget and leave everyone else rate-limited for the rest of the hour without a single real assessment happening. The ceiling is now charged only when an assessment actually runs. Two error replies were also wrong in a way that misled callers: sending the wrong content type or a body over the size limit both came back as generic malformed JSON, so the fix looked like editing your payload when it was really a header or a smaller body. They now return the correct unsupported-media-type and payload-too-large codes, and the endpoint rejects a non-object body with a message that says so.</description></item>+ <item>+ <title>Rankings stops counting your own remixes, and the Daily Match board opens up to other sites</title>+ <link>https://three.ws/rankings</link>+ <guid isPermaLink="false">2026-08-13:Rankings stops counting your own remixes, and the Daily Match board opens up to other sites</guid>+ <pubDate>Thu, 13 Aug 2026 12:00:00 GMT</pubDate>+ <category>fix</category>+ <description>The Remixes Received ranking on /rankings was meant to count derivatives other creators made from your work. It was also counting your own refinements of your own model, and generations that never finished, so a creator could climb the board without anyone else touching their work. It now counts only finished derivatives made by someone else, which is what the board always claimed to measure. Separately, the public Daily Match standings endpoint sent no cross-origin permission header, so any site other than three.ws that tried to read the board was blocked by the browser. It now allows any origin, matching the unified leaderboard, and both boards are covered by tests.</description>+ </item><item><title>The $THREE tile on the live heatmap shows real buy pressure again</title><link>https://three.ws/changelog</link>@@ -78,6 +102,14 @@<category>fix</category><description>Every message and every autonomous money move an avatar makes is screened by the IBM Granite Guardian safety check before it runs. That check has an hourly platform-wide ceiling so one busy hour cannot run up an unbounded inference bill. The ceiling was being charged on every request that arrived, including ones that were rejected on the spot for a malformed body and never reached the safety model at all. A single client sending junk could therefore burn the whole platform hour and leave everyone else refused for real, valid checks. The ceiling is now charged only when an actual screening runs. Two error replies were also corrected: sending the wrong content type now answers 415 and an oversized body answers 413, instead of both being reported as generic bad input, so a caller can see which of the two to fix.</description></item>+ <item>+ <title>The CC0 object library answers a bad page request instead of quietly handing back the wrong page</title>+ <link>https://three.ws/objects</link>+ <guid isPermaLink="false">2026-08-13:The CC0 object library answers a bad page request instead of quietly handing back the wrong page</guid>+ <pubDate>Thu, 13 Aug 2026 12:00:00 GMT</pubDate>+ <category>fix</category>+ <description>The free prop library behind /objects and the AR Studio Objects tray is also a public API anyone can page through. Ask it for a page size it cannot parse and it used to guess: a word where a number belongs silently returned a single object, a fractional page size handed back a fractional position to ask for next, and a page position sent without a page size was ignored outright. Every one of those looked like working pagination while quietly skipping or repeating props, so a script walking the whole catalogue could finish believing it had seen all 511 when it had not. Bad page requests now come back immediately as a clear error naming the parameter and the accepted range, while an oversized page still simply caps at the documented maximum. Separately, when the storage behind the library has a hiccup the endpoint still degrades to an empty list rather than an error page, but that emptiness is no longer cached for the next five minutes: the library reappears the moment storage recovers instead of staying blank long after.</description>+ </item><item><title>The decentralized inference demo stops sending your prompt to a gateway that is no longer Livepeer</title><link>https://three.ws/demos</link>diff --git a/public/features.json b/public/features.jsonindex 46dc9c681..0d0401a0d 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-08-13T01:47:10.769Z",+ "generated_at": "2026-08-13T02:06:29.107Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/tests/api/llm-health-endpoint.test.js b/tests/api/llm-health-endpoint.test.jsnew file mode 100644index 000000000..ff727aecb--- /dev/null+++ b/tests/api/llm-health-endpoint.test.js@@ -0,0 +1,138 @@+// GET /api/llm/health - the gate in front of the provider report.+//+// The report names every configured provider and quotes the upstream error+// text, which is exactly the material that tells an attacker which vendor key+// is dead or out of credits. The handler is also the hourly Cloud Scheduler+// target (vercel.json crons), so it has to accept both header shapes a caller+// can present: `X-Cron-Secret` from an operator or external monitor, and+// `Authorization: Bearer` from the scheduled invocation. These pin the gate and+// the alert hand-off; the probe itself is covered in llm-health-vertex.test.js.++import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';++const healthState = { report: { overall: 'ok', anthropic: { status: 'ok' } } };+vi.mock('../../api/_lib/llm-health.js', () => ({+ probeLlmHealth: vi.fn(async () => healthState.report),+}));++const alerts = [];+vi.mock('../../api/_lib/alerts.js', () => ({+ sendOpsAlert: vi.fn(async (title, detail, opts) => {+ alerts.push({ title, detail, opts });+ }),+}));++const { default: handler } = await import('../../api/llm/health.js');++const SECRET = 'cron-secret-under-test';++function makeRes() {+ return {+ statusCode: 200,+ headers: {},+ body: '',+ writableEnded: false,+ setHeader(k, v) {+ this.headers[k.toLowerCase()] = v;+ },+ getHeader(k) {+ return this.headers[k.toLowerCase()];+ },+ end(chunk) {+ if (chunk !== undefined) this.body += chunk;+ this.writableEnded = true;+ },+ };+}++async function invoke(headers = {}, method = 'GET') {+ const req = { method, url: '/api/llm/health', headers };+ const res = makeRes();+ await handler(req, res);+ let body = null;+ try {+ body = res.body ? JSON.parse(res.body) : null;+ } catch {+ body = res.body;+ }+ return { status: res.statusCode, body };+}++const ORIGINAL_SECRET = process.env.CRON_SECRET;++beforeEach(() => {+ process.env.CRON_SECRET = SECRET;+ healthState.report = { overall: 'ok', anthropic: { status: 'ok' } };+ alerts.length = 0;+});++afterEach(() => {+ if (ORIGINAL_SECRET === undefined) delete process.env.CRON_SECRET;+ else process.env.CRON_SECRET = ORIGINAL_SECRET;+});++describe('GET /api/llm/health: authorization', () => {+ it('serves the provider report to a valid X-Cron-Secret header', async () => {+ const { status, body } = await invoke({ 'x-cron-secret': SECRET });+ expect(status).toBe(200);+ expect(body).toEqual({ overall: 'ok', anthropic: { status: 'ok' } });+ });++ it('serves the provider report to the Bearer form Cloud Scheduler sends', async () => {+ const { status, body } = await invoke({ authorization: `Bearer ${SECRET}` });+ expect(status).toBe(200);+ expect(body.overall).toBe('ok');+ });++ it('refuses an unauthenticated caller without naming a provider', async () => {+ const { status, body } = await invoke();+ expect(status).toBe(403);+ expect(body.error).toBe('forbidden');+ expect(JSON.stringify(body)).not.toContain('anthropic');+ });++ it('refuses a wrong secret in either header', async () => {+ expect((await invoke({ 'x-cron-secret': 'wrong' })).status).toBe(403);+ expect((await invoke({ authorization: 'Bearer wrong' })).status).toBe(403);+ });++ it('refuses a repeated header that arrives as an array', async () => {+ const { status } = await invoke({ 'x-cron-secret': [SECRET, 'wrong'] });+ expect(status).toBe(403);+ });++ it('reports 503 rather than opening the gate when no CRON_SECRET is deployed', async () => {+ delete process.env.CRON_SECRET;+ const { status, body } = await invoke({ 'x-cron-secret': SECRET });+ expect(status).toBe(503);+ expect(body.error).toBe('not_configured');+ });++ it('allows GET only', async () => {+ const { status, body } = await invoke({ 'x-cron-secret': SECRET }, 'POST');+ expect(status).toBe(405);+ expect(body.error).toBe('method_not_allowed');+ });+});++describe('GET /api/llm/health: ops alerting', () => {+ it('pages ops with the failing providers when the report degrades', async () => {+ healthState.report = {+ overall: 'degraded',+ openrouter: { status: 'error', error: 'HTTP 402' },+ anthropic: { status: 'ok' },+ };+ const { status } = await invoke({ 'x-cron-secret': SECRET });+ expect(status).toBe(200);+ expect(alerts).toHaveLength(1);+ expect(alerts[0].title).toContain('DEGRADED');+ expect(alerts[0].detail).toContain('openrouter: HTTP 402');+ // Deduped per failing-provider signature so a sustained outage pages once.+ expect(alerts[0].opts.signature).toBe('llm-health:degraded:openrouter: HTTP 402');+ });++ it('stays quiet while every configured provider passes', async () => {+ await invoke({ 'x-cron-secret': SECRET });+ expect(alerts).toHaveLength(0);+ });+});diff --git a/tests/api/okx-identity-studio.test.js b/tests/api/okx-identity-studio.test.jsindex 6d970bc4c..f779ba9c7 100644--- a/tests/api/okx-identity-studio.test.js+++ b/tests/api/okx-identity-studio.test.js@@ -556,3 +556,67 @@ describe('prompt shaping', () => {expect(shaped.effective.length).toBeLessThanOrEqual(identity.MAX_GENERATION_PROMPT_CHARS);});});++// The fallback template is what a keyless deployment (or a downed LLM chain)+// actually sends to the generator, so its budget math is load-bearing rather+// than a nicety: an over-budget prompt is silently truncated by the text+// encoder, mid-clause, and the identity comes back wrong.+describe('prompt shaping', () => {+ it('leads with the first sentence of the brief plus the style hints, inside the generator budget', () => {+ const p = identity.fallbackIdentityPrompt({+ brief: 'A calm on-chain accounting agent. It also files quarterly taxes and audits vaults.',+ styleHints: 'deep navy and silver',+ });+ expect(p).toContain(+ 'full-body humanoid character embodying: A calm on-chain accounting agent, deep navy and silver',+ );+ // Later sentences are backstory, not a visual subject.+ expect(p).not.toContain('quarterly taxes');+ expect(p).toContain('standing neutral pose');+ expect(p.length).toBeLessThanOrEqual(identity.MAX_GENERATION_PROMPT_CHARS);+ });++ it('a CJK brief keeps its first sentence and never crowds out the hints', () => {+ const p = identity.fallbackIdentityPrompt({+ brief: '一个冷静精准的链上会计智能体。它还负责季度报税与金库审计工作。',+ styleHints: 'deep navy and silver',+ });+ expect(p).toContain('一个冷静精准的链上会计智能体');+ expect(p).not.toContain('季度报税');+ expect(p).toContain('deep navy and silver');+ });++ it('an over-long single-sentence brief is cut at a clean boundary and the hints survive', () => {+ const p = identity.fallbackIdentityPrompt({+ brief: `${'a very long rambling description of the agent '.repeat(20)}and more`,+ styleHints: `${'ultra detailed cinematic lighting '.repeat(10)}chrome`,+ });+ expect(p.length).toBeLessThanOrEqual(identity.MAX_GENERATION_PROMPT_CHARS);+ expect(p).toContain('ultra detailed cinematic lighting');+ // No clause arriving at the comma join with its own trailing punctuation.+ expect(p).not.toMatch(/[.,;:]\s*,/);+ expect(p).toMatch(/plain background$/);+ });++ it('shapes to the fallback template when the director is unreachable', async () => {+ const shaped = await identity.shapeIdentityPrompt({+ agentName: 'LedgerLynx',+ brief: 'a calm on-chain accounting agent',+ styleHints: null,+ });+ expect(shaped.directed).toBe(null);+ expect(shaped.effective).toContain('full-body humanoid character embodying');+ });++ it('rejects a director answer that is prose rather than a prompt', async () => {+ llmSpy.fn = async () => ({ text: 'x'.repeat(1200) });+ const shaped = await identity.shapeIdentityPrompt({+ agentName: 'LedgerLynx',+ brief: 'a calm on-chain accounting agent',+ styleHints: null,+ });+ expect(shaped.directed).toBe(null);+ expect(shaped.effective).toContain('full-body humanoid character embodying');+ expect(shaped.effective.length).toBeLessThanOrEqual(identity.MAX_GENERATION_PROMPT_CHARS);+ });+});