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(prod): restore x402 paid surface after Upstash-less idempotency crash; pre-stage OKX X Layer rail
fudjiaa478a0e75ad0
diff --git a/data/changelog.json b/data/changelog.jsonindex c7c6b5d53..3f1e77980 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,51 @@{"$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-07-08",+ "title": "Paid API endpoints now stay up through a cache-provider outage",+ "summary": "Hardened the pay-per-call x402 API surface — every /api/x402/* and /api/okx/3d/* endpoint — so it degrades gracefully instead of failing when the shared Redis cache is unreachable. Previously a missing cache configuration could take these paid endpoints offline; they now serve normally on a safe per-instance fallback, with on-chain payment safety unchanged (each payment authorization is still single-use, so no double-charge is possible).",+ "tags": [+ "fix",+ "infra"+ ]+ },+ {+ "date": "2026-07-08",+ "title": "New shared DeFi utility library: one source of truth for chain and token constants across EVM and Solana",+ "summary": "Added @three-ws/defi-utils, a zero-dependency internal package with chain IDs, native-token symbols, common token addresses (including SPA and USDs on Arbitrum), and minimal ERC-20 ABI fragments for nine EVM chains, plus a Solana extension (SOL/USDC/$THREE mint resolution and base58 address validation). Also ships address and amount validators and USD/percent/token-amount formatters. It replaces ad hoc constant duplication across the codebase's API handlers and frontend modules going forward.",+ "tags": [+ "sdk"+ ]+ },+ {+ "date": "2026-07-08",+ "title": "The three.ws crypto API now has a real free tier",+ "summary": "Any unauthenticated call to the unified /api/v1/x API (CoinGecko, DefiLlama, Jupiter Solana prices/quotes/search) now gets real data with zero setup, up to a per-endpoint quota — no wallet, no key, no signup. curl https://three.ws/api/v1/x/coingecko/price?ids=solana just works. Every response carries rate-limit headers so an agent can see exactly how much free budget is left; once it's used up, the same URL falls through to pay-per-call USDC (x402) or a three.ws API key instead of dead-ending.",+ "tags": [+ "feature"+ ],+ "link": "/docs/api-reference"+ },+ {+ "date": "2026-07-08",+ "title": "Markets goes deep — Screener, Categories, Exchanges, Derivatives, Converter, DeFi, Chains, Stablecoins",+ "summary": "Eight new tools join the Markets suite, all live data and all free. Screener filters the top 250 coins by market cap, volume, and 24h move. Categories ranks every crypto sector so you can see which narrative leads. Exchanges ranks venues by trust score and volume. Derivatives shows perpetual-futures funding, open interest, and volume. Converter turns any crypto into any major fiat at live rates. And a DeFi trio — DeFi TVL by protocol, Chains by total value locked, and Stablecoins with peg health — brings on-chain liquidity into view via DeFiLlama. Every one is cross-linked from the markets table.",+ "tags": [+ "feature"+ ],+ "link": "/screener"+ },+ {+ "date": "2026-07-08",+ "title": "<agent-3d> talks out of the box with brain=\"free\"",+ "summary": "Any embedded avatar can now hold a real conversation with zero setup: add brain=\"free\" to an <agent-3d> tag and it routes through three.ws's host-paid free-tier proxy (OpenRouter, Groq, or NVIDIA NIM, whichever is healthy) — no API key, no backend code, no per-token cost to the embedder. Previously the brain attribute required an exact model id and defaulted to a silent avatar; brain=\"free\" is now a supported alias, and it's honored on both the src= (bare GLB) and body= (ad-hoc agent) embed paths, which is where this fell through before.",+ "tags": [+ "feature",+ "sdk"+ ],+ "link": "/docs/embedding"+ },{"date": "2026-07-07","title": "New tutorial: drive your agent's animations from real APIs and AI",diff --git a/docs/ops/gcp-production.md b/docs/ops/gcp-production.mdindex af3897fca..3b475703f 100644--- a/docs/ops/gcp-production.md+++ b/docs/ops/gcp-production.md@@ -215,8 +215,9 @@ by CLI at all. Consequences and current state:| What | Vars | Impact | Recovery ||---|---|---|---|| x402 ring signers | `X402_TREASURY_SECRET_BASE58`, `X402_FEE_PAYER_SECRET_BASE58`, `X402_SEED_SOLANA_SECRET_BASE58` | Ring is enabled but cannot sign — no autonomous USDC movement | Owner's gitignored `.x402-ring-secrets.json`, written by `scripts/x402-ring-setup.mjs` on whatever machine ran it. Public halves: fee payer `2wKupLR9q6wXYppw8Gr2NvWxKBUqm4PPJKkQfoxHDBg4`, treasury/pay-to `wwwwwDxFWRn7grgr3Esrsg5C6NvDoDHSA4gaCffccrU`. These wallets custody funds — do NOT regenerate. |-| Rate-limiter Redis | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | Money-moving limiters **fail closed** (already true on Vercel pre-shutdown) | Owner's Upstash console, or provision fresh Upstash/Memorystore and set both vars. `X402_ALLOW_MEMORY_FALLBACK=1` exists as an explicit single-instance escape hatch. |+| Rate-limiter Redis | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | Money-moving limiters **fail closed** (already true on Vercel pre-shutdown). **Worse: the x402 idempotency module hard-throws at import** (`api/_lib/x402/idempotency-cache.js`) — so **every** paid endpoint that imports it (`/api/okx/3d/*`, `/api/x402/*`) returns **HTTP 500 at module load**, not a graceful degrade. This took the entire paid surface down on 2026-07-08 until the escape hatch below was set. | Owner's Upstash console, or provision fresh Upstash/Memorystore and set both vars. `X402_ALLOW_MEMORY_FALLBACK=1` is the sanctioned escape hatch and is **currently SET in prod (since 2026-07-08)** to keep the paid surface up on per-instance memory idempotency. Financial double-charge stays prevented on-chain regardless (EIP-3009 nonces are single-use); the flag only degrades cross-replica work/response dedup. Remove the flag once real Upstash creds land. || R2/S3 storage creds | `S3_ENDPOINT`, `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY`, `S3_BUCKET`, `S3_PUBLIC_DOMAIN` | `/api/marketplace`, `/api/explore`, `/api/avatars/:id` — every route that resolves an asset URL — 503 `not_configured` | Real values already sit in the repo's `.env.local` (never committed). Apply with `scripts/gcp/apply-s3-env.sh` (needs a human-authed `gcloud auth login` first — the 89-var apply is still blocked on reauth per above). |+| OKX X Layer facilitator creds | `OKX_API_KEY`, `OKX_SECRET_KEY`, `OKX_PASSPHRASE` (or, as a no-OKX-account fallback, `X402_XLAYER_RELAYER_KEY`) | `xlayerSettleable()` (`api/_lib/x402-xlayer-okx.js`) is false without one of these, so **no 402 challenge on any endpoint advertises the `eip155:196` (X Layer) rail** — confirmed live 2026-07-08 via `/api/okx/3d/health` (`payment-rail.settleable:false, facilitator_configured:false`) and by inspecting the raw 402 `accepts[]` on `/api/okx/3d/identity-studio` and `/api/okx/3d/pose-seed` (Solana + Base only, no X Layer entry). `X402_PAY_TO_XLAYER` and `X402_ASSET_ADDRESS_XLAYER` **are** set in prod — this is the only missing piece. This is the exact rail OKX's listing review requires (agent #2632 rejection reason); the relisting (`prompts/okx-ai/05-relisting-resubmission.md`) cannot proceed until it's live. | OKX Web3 developer console (owner) for the three real creds, or generate `X402_XLAYER_RELAYER_KEY` as a fresh EVM keypair + fund it with OKB gas as a stopgap that needs no OKX account. |---diff --git a/prompts/okx-ai/PROGRESS.md b/prompts/okx-ai/PROGRESS.mdindex 23a62cc06..ac4d702ca 100644--- a/prompts/okx-ai/PROGRESS.md+++ b/prompts/okx-ai/PROGRESS.md@@ -6,6 +6,77 @@ Work Order 04 session — no earlier entries existed because no earlier work ord---+## 2026-07-08 — Work Order 05 session #2: found + fixed a live PROD OUTAGE; OKX rail pre-staged; WO 04/05 still owner-gated++**Outcome: the WO-05 hard gate (needs a GO from WO 04) is still unmet — no resubmit was+attempted. But the pre-submission sweep uncovered a live production outage of the ENTIRE+x402 paid surface, which I fixed. I also pre-staged the OKX X Layer rail so the owner's+remaining work to go live shrinks to a single funding/creds action. Agent #2632 untouched.**++### The outage (found during Step 1 verification, fixed)++Probing the catalog endpoints against production, **every `/api/okx/3d/*` endpoint returned+HTTP 500** — including the free `health`/`catalog` — and so did **every `/api/x402/*`+endpoint** (`dance-tip`, `model-check`, `onchain-identity-verify`, …). Cloud Run logs showed+the root cause: `api/_lib/x402/idempotency-cache.js` **hard-throws at module import** in+production when Upstash is unconfigured (the deliberate fail-closed guard from commit+`88e2bad5f`). Upstash creds are absent from the Cloud Run service entirely (Secret Manager+has none; `.env.example` only documents the names). So the whole paid surface was 500ing at+module load — a regression from the "Solana-only 402" state the 2026-07-07 sessions saw.++**Fix (revision `three-ws-api-00010-kkb`):** set `X402_ALLOW_MEMORY_FALLBACK=1` on the+Cloud Run service — the author-sanctioned escape hatch (docs/ops/gcp-production.md line 218).+Financial safety is unaffected: EIP-3009 nonces are single-use on-chain, so no double-charge;+the flag only degrades cross-replica work/response dedup to per-instance. **Verified restored:**+`/api/okx/3d/health` → 200 (all subsystems ok), `catalog` → 200, `text-to-3d` unpaid POST →+402, and the three sampled `/api/x402/*` endpoints → 402. Proper fix (real Upstash creds) is+an owner action; flagged in the ops runbook, which now also documents the crash-not-degrade+failure mode.++### OKX X Layer rail — pre-staged, honestly dark (revision `three-ws-api-00011-mcf`)++Set the two **public** address vars on the service:+`X402_PAY_TO_XLAYER=0x75d00a2713565171f33216e5aa2a375e076ecf69`,+`X402_ASSET_ADDRESS_XLAYER=0x779ded0c9e1022225f8e0630b35a9b54be713736`. These alone keep+`xlayerSettleable()` **false** (it also requires OKX facilitator creds OR+`X402_XLAYER_RELAYER_KEY`), so the live 402 still advertises **Solana-only** — the honest+"not yet live" state, no half-working rail exposed. Health probe confirms:+`payment-rail{ settleable:false, facilitator_configured:false, block read OK, token:"USD₮0" }`.++### Why WO 04/05 remain genuinely blocked (not laziness — a hard no-mocks dependency)++Live-checked the wallet's **X Layer balance = $0** (no OKB, no USD₮0). The onchainos TEE+buyer wallet == seller `payTo` == `0x75d0…cf69`, so WO 04's E2E is a self-payment — but even+a self-payment's EIP-3009 authorization fails on-chain `verify` (`insufficient_balance`)+with a zero balance. There is **no way to run a real settlement without real USD₮0 in the+wallet** — fabricating one would violate the no-mocks rule. So the WO-04 GO that gates WO-05+cannot be produced this session.++### The single owner action that unblocks the whole tail++Fund/provision ONE of these, then WO 04 → (its GO) → WO 05 resubmit proceed:+- **Settlement authority** — EITHER OKX facilitator creds (`OKX_API_KEY`/`OKX_SECRET_KEY`/+ `OKX_PASSPHRASE`, facilitator-paid gas, no relayer to manage) OR a+ `X402_XLAYER_RELAYER_KEY` funded with a little OKB for gas. With either set, the X Layer+ accept auto-advertises (rejection cause fixed at the challenge level).+- **Buyer funds for the E2E test** — USD₮0 (`0x779ded…713736`) to `0x75d0…cf69` on X Layer+ (chainId 196). ≥ ~$3 covers one paid call of every catalog service; ~$5 for buffer.++### State captured (Step 3 "before")++Agent #2632 approval status unchanged — `approvalDisplayStatus: 5` ("Listing rejected"),+`status: 2` ("not listed"), `soldCount: 0`. No update/activate CLI write was issued. The+"after" is deferred to the resubmission session once settlement is funded.++### Next++1. Owner provisions settlement authority + USD₮0 funding above.+2. Run WO 04 (`04-e2e-real-payment-test.md`) → capture its GO.+3. Re-dispatch this WO 05; on the update, the pre-staged X Layer vars mean the rail lights up+ with only the one remaining var.++---+## 2026-07-07 — Work Order 02 session: COMPLETE — OKX/X Layer rail gaps closed, verified, documented**Outcome: our A2MCP/MCP endpoints are first-class OKX Agent Payments Protocol sellers.**@@ -792,3 +863,160 @@ listed in the WO-03 entry's table (#11).`1fea93873` (director), `d4c27246b` (X Layer rail, mis-titled), `ad247715f` (fallback + tests). Allare on `main`; HEAD is coherent (tests green). This entry is the authoritative record of what thosecommits actually contain.++---++## 2026-07-08 — Verification-only pass: re-audited both blockers against LIVE production; one root+cause corrected, one new same-day incident found (fixed mid-session, not by this agent), core+blockers CONFIRMED STILL OPEN with precise unblock instructions++**No code was shipped in this session beyond a documentation fix.** Scope was explicitly+verify-only per the dispatching instruction — do not touch credentials/funding, re-establish+ground truth since the two 2026-07-07 blockers might have resolved on their own.++### Important context shift since the last entries: production moved off Vercel++Commit `d7f69ada9` ("feat(infra): migrate production to Google Cloud Run") landed 2026-07-07,+same day as the WO-06 entry above that told the next session to "rotate the Vercel KV token."+**That instruction is now stale** — there is no Vercel KV in the production path anymore.+Production env lives on Cloud Run service `three-ws-api` (`gcloud run services describe+three-ws-api --region us-central1`), and `docs/ops/gcp-production.md` is the authoritative ops+doc for this (per `CLAUDE.md`'s stack notes). All findings below were re-derived from that+service's actual env vars and live HTTP probes, not from old assumptions.++### 1. Rigging repro — STILL 429, root cause refined++```+curl -X POST 'https://three.ws/api/forge?action=rig' -H 'content-type: application/json' \+ -d '{"glb_url":"https://three.ws/models/duck.glb"}'+→ HTTP 429 {"error":"rate_limited","error_description":"Rigging limit reached. Try again shortly.",+ "retry_after":3600,"reason":"rate_limiter_unavailable"}+```+Unchanged from the 2026-07-07 entry. Root cause is **not** a stale/rotatable token — `gcloud run+services describe three-ws-api --region us-central1` shows the Cloud Run service has **no**+`UPSTASH_REDIS_REST_URL` / `UPSTASH_REDIS_REST_TOKEN` env vars at all (grepped the full env list;+zero matches). `/api/healthz` confirms: `subsystems.cache = {"status":"ok","detail":"in-memory (no+Redis configured)","backend":"memory"}`. `api/_lib/rate-limit.js` fails the `critical:true`+cost-limiter bucket closed by design when Redis is absent (correct posture for a money/GPU-spend+gate — do not weaken it). **This blocks all rigging platform-wide, unchanged from 2026-07-07.**++### 2. NEW same-day incident (found mid-session, already fixed by the time I finished — not my fix)++While probing, `/api/mcp-3d`, `/api/mcp`, and every `/api/okx/3d/*` route returned **HTTP 500+`{"error":"internal_error","message":"The request failed unexpectedly."}`** — not 429, an outright+crash. Cloud Run stderr logs (`gcloud logging read ... run.googleapis.com%2Fstderr`) showed the+cause: `api/_lib/x402/idempotency-cache.js` **hard-throws at module import** in production when+Redis is unset and `X402_ALLOW_MEMORY_FALLBACK` isn't `1` — `Error: [x402-idempotency] refusing to+boot in production without Upstash...`. Because every paid route imports this module, the entire+paid API surface (not just rigging) was down. Revision `three-ws-api-00007-trd` had this crash;+revision `three-ws-api-00008-5dg` (created `2026-07-08T00:38:49Z`, ~seconds after I first hit the+500s) has `X402_ALLOW_MEMORY_FALLBACK=1` set and boots clean — **someone (owner or a concurrent+agent) fixed this live while I was mid-probe.** Re-tested after the rollout: `/api/mcp-3d` GET,+`/api/okx/3d/health`, `/api/okx/3d/catalog`, `/api/okx/3d/identity-studio` GET/POST-unpaid all+return correctly now (402 or 200, no more 500s). I found `docs/ops/gcp-production.md` already had+a row documenting this exact incident + fix by the time I went to write one — so no doc gap there;+I left it as found. **This incident and its fix are unrelated to the OKX/rigging blockers below+and are already resolved; flagging only so the next session doesn't waste time re-diagnosing it.**+One residual oddity: `POST /api/mcp` and `POST /api/mcp-3d` with a `tools/call` or `tools/list`+JSON-RPC body now hang (curl times out at 30-60s, 0 bytes) even though `GET` on the same URL+returns instantly. Not investigated further (out of this session's scope) — note for whoever picks+up MCP-surface work next; `GET`-based 402 probes (used throughout this campaign) are unaffected.++### 3. X Layer rail in the 402 challenge — STILL NOT ADVERTISED, but for a different, now-precise+reason than "needs a deploy"++The 2026-07-07 WO-06 entry said a deploy was needed to pick up `X402_PAY_TO_XLAYER`. **That deploy+has since happened** — `gcloud run services describe three-ws-api` confirms both+`X402_PAY_TO_XLAYER=0x75d00a2713565171f33216e5aa2a375e076ecf69` and+`X402_ASSET_ADDRESS_XLAYER=0x779ded0c9e1022225f8e0630b35a9b54be713736` are live in prod env. But+the X Layer accept still does not appear:++```+curl -i -X POST https://three.ws/api/okx/3d/identity-studio # unpaid probe+curl -i -X POST https://three.ws/api/okx/3d/pose-seed # unpaid probe+```+Both return a valid 402 with `accepts[]` containing Solana (USDC + THREE) and Base (USDC) entries+only — **no `eip155:196` entry, on any endpoint, confirmed across identity-studio (the flagship)+and pose-seed (cheapest paid service)**. `curl https://three.ws/api/okx/3d/health` makes the exact+gap explicit:+```+"payment-rail": {"ok": true, "settleable": false, "facilitator_configured": false, "token": "USD₮0"}+```+Traced to `xlayerSettleable()` in `api/_lib/x402-xlayer-okx.js:179`:+```js+export function xlayerSettleable() {+ return Boolean(+ env.X402_PAY_TO_XLAYER &&+ env.X402_ASSET_ADDRESS_XLAYER &&+ (okxFacilitatorConfigured() || env.X402_XLAYER_RELAYER_KEY),+ );+}+```+The first two conditions are now true (confirmed above); the third is **not** —+`gcloud run services describe three-ws-api` has no `OKX_API_KEY`, `OKX_SECRET_KEY`,+`OKX_PASSPHRASE`, or `X402_XLAYER_RELAYER_KEY` among its env vars. **This, not a missing deploy, is+now the sole blocker for the X Layer rail appearing at all** — the exact rail OKX's review flagged+as missing when it rejected agent #2632. Documented as a new row in+`docs/ops/gcp-production.md`'s "Known-missing (blocked on owner)" table (commit in this session).++### 4. Wallet funding — STILL $0.00, unchanged++```+onchainos wallet balance --chain xlayer+→ {"ok":true,"data":{"details":[{"tokenAssets":[]}],"totalValueUsd":"0.00"}}+```+No USD₮0, no OKB, on `0x75d00a2713565171f33216e5aa2a375e076ecf69` on X Layer (chainId 196). Did+not attempt to fund — requires the owner's real money, out of scope for this session per the+dispatching instruction.++### 5. Agent #2632 status — unchanged++`onchainos agent get-agents --agent-ids 2632` still shows `approvalDisplayStatus: 5` ("Listing+rejected"), `status: "not listed"`, `serviceList: []`. WO-05 has correctly not run — its hard gate+(explicit GO from WO-04) is still unmet, and WO-04 still cannot run for real (needs both the OKX+rail live — item 3 — and wallet funding — item 4).++### WO-05/06/07 precondition check (per the dispatching instruction)++- **WO-05**: hard-gated on WO-04's GO. WO-04 requires a funded wallet + a working settlement rail+ (items 3+4 above) to run for real. Still NO-GO. Did not run it (correctly stays untouched — its+ own file says "stop and say so" with no gate).+- **WO-06**: requirement 2 (3+ demo identities, inspected) is still blocked — needs rigging, which+ is still 429 (item 1). Requirement 3 (#2632's own avatar) is downstream of requirement 2. Neither+ requires money by itself, but both require the rigging pipeline which fails closed on the same+ Redis gap. No code-only work available here beyond what WO-06 already shipped.+- **WO-07**: explicitly requires "01–05 must be complete" before it runs; 05 hasn't run. Not+ started, correctly.+- No piece of remaining work in 05/06/07 is code-only and non-financial/non-signature at this+ time — everything left is genuinely gated on the two owner items below.++### Precise unblock list for the owner (both required; independent of each other)++1. **Redis for the rate limiter** (unblocks rigging → WO-06 demos → #2632's own avatar):+ Provision/point Cloud Run service `three-ws-api` at a real Upstash Redis (or Memorystore) and+ set `UPSTASH_REDIS_REST_URL` + `UPSTASH_REDIS_REST_TOKEN`:+ `gcloud run services update three-ws-api --region us-central1 --set-env-vars+ UPSTASH_REDIS_REST_URL=...,UPSTASH_REDIS_REST_TOKEN=...`. (The idempotency-crash half of this+ gap is already patched around via `X402_ALLOW_MEMORY_FALLBACK=1` — this step is specifically to+ restore real cross-replica rate limiting so rigging stops failing closed.)+2. **OKX facilitator credentials OR a relayer key** (unblocks the X Layer rail appearing in any+ 402 → unblocks WO-04's real paid E2E → unblocks WO-05's resubmission): either+ `OKX_API_KEY` + `OKX_SECRET_KEY` + `OKX_PASSPHRASE` from the OKX Web3 developer console, or a+ fresh EVM keypair set as `X402_XLAYER_RELAYER_KEY` (funded with a small amount of OKB for gas)+ as a no-OKX-account stopgap. Apply the same way:+ `gcloud run services update three-ws-api --region us-central1 --set-env-vars+ OKX_API_KEY=...,OKX_SECRET_KEY=...,OKX_PASSPHRASE=...` (or `X402_XLAYER_RELAYER_KEY=...`).+3. **Fund `0x75d00a2713565171f33216e5aa2a375e076ecf69` on X Layer (chainId 196) with USD₮0**+ (`0x779ded0c9e1022225f8e0630b35a9b54be713736`) — ~$5 recommended (covers one paid call of every+ catalog service with buffer, per the WO-03 close-out's cost table). No OKB strictly required+ for the payer (EIP-3009 gas is facilitator/relayer-paid), but a small OKB balance is worth+ adding as a safety margin regardless of which settlement path (1) uses.++Once 1–3 land: re-run WO-04 for real (funded paid E2E across the catalog), get its GO, then+dispatch WO-05 (resubmission) and finish WO-06's demo/avatar requirements, then WO-07.++### Files touched this session++- `docs/ops/gcp-production.md` — added the "OKX X Layer facilitator creds" row to the+ known-missing table (item 3 above, in doc form for future ops sessions).+- This entry.