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
docs(okx-ai): WO-04 pre-funding sweep green, record the corrected funding math
nirholas7aa794027fbb
diff --git a/prompts/okx-ai/PROGRESS.md b/prompts/okx-ai/PROGRESS.mdindex af1034ca3..cc5830b72 100644--- a/prompts/okx-ai/PROGRESS.md+++ b/prompts/okx-ai/PROGRESS.md@@ -1607,3 +1607,99 @@ onchainos agent get-agents --agent-ids 2632 # capture approval status AFTEItem 1 alone allows a resubmission of the fixed listing (which is what the 2026-07-26rejection asked for). Item 2 is what turns WO-04's NO-GO into a GO and makes the claim"payments settle" observed rather than unit-tested.++---++## 2026-08-01, Work Order 04: pre-funding sweep green, gauntlet tooling built, blocked on 2 owner actions++Ran every leg of the WO-04 gauntlet that does not move money, built the tooling that runs+the paid legs, and stopped at the two CLAUDE.md stop-and-ask gates (a real spend, and an+email OTP only a human can read). Nothing was simulated in place of a real payment.++### Step 0 preconditions, all verified live against production++| Check | Result |+| --- | --- |+| `onchainos --version` | 4.4.0 |+| `onchainos wallet status` | `loggedIn: false`, `accountCount: 0` (gate 2) |+| `GET /api/okx/3d/health` | 200, 5 subsystems with real latencies, `payment-rail settleable: true`, block 66850672 |+| `GET /api/okx/3d/catalog` | 200, 11 rows |+| Unpaid `POST /api/okx/3d/text-to-3d` | 402, `accepts[0].network = eip155:196` |+| `npx vitest run tests/api/okx-3d-services.test.js` | 27 passed |+| Three-copy rule | PASS, module == live == submission |++**402 sweep across all 11 catalog rows (new, was never done row-by-row).** Every one of the+9 paid services answers 402 with the X Layer accept FIRST, at an `amount` byte-equal to that+row's `amountAtomics`, `payTo` `0x4022de2D…f402`, asset `0x779ded…3736`, x402Version 2. Both+free rows serve live data at 200 with no payment demanded. Evidence:+`e2e-evidence/10-402-<service>.json`, one file per row.++### New tooling, all three committed and exercised++- **`scripts/okx-three-copy-check.mjs`** (`npm run okx:three-copy`). Enforces the three-copy+ rule mechanically: `catalogIndex()` is compared byte-for-byte against the live endpoint+ body (it is the exact function the route serializes, so this is an equality check, not an+ approximation), and the submission payload is compared row by row. It earned its keep the+ same day it was written: a concurrent agent edited `scripts/okx-listing-payload.mjs` (38+ lines) mid-session and the re-run proved copy 3 still matched.+- **`scripts/okx-verify-glb.mjs`**. Artifact truth for cases 2 and 3. Parses the delivered+ bytes with `@gltf-transform/core` and checks container validity, geometry, and (with+ `--rigged`) a skin with joints plus non-degenerate skin weights, counting vertices that+ carry non-zero influence so an all-zero weight set cannot pass. Validated against four+ controls: michelle.glb rigged (exit 0), mannequin.glb with `--rigged` (exit 1, it has 0+ skins), an error JSON renamed `.glb` (exit 1), a 404 (exit 2).+- **`scripts/okx-e2e-gauntlet.mjs`** (`npm run okx:gauntlet`). The full 10-case runner. Signs+ through `onchainos payment pay` (the real OKX buyer path, no hand-rolled signatures),+ replays, verifies the artifact, then reads the settlement transaction back off X Layer and+ confirms a USD₮0 `Transfer` log to the advertised `payTo` for the exact advertised amount.+ Refuses to run without `--yes`.++### Cases green now, with no funding++- **Case 1 (free lane): PASS.** Health 200 with 5 subsystems reporting real latencies,+ catalog 200 with 11 rows. No payment demanded on either.+- **Case 5d (garbage payment header): PASS**, four shapes, none ran a tool:+ `not-base64` → 400 `invalid_payment`; valid-base64-wrong-shape → 402 naming the missing+ EIP-3009 fields; whitespace-only → 402 with a full fresh challenge; truncated JSON → 400.+ The whitespace case was investigated as a possible defect (402 with an empty `error`+ string) and is correct behavior: HTTP trims the header to `''`, which is indistinguishable+ from no header, and the right answer is the standard challenge.+- **Case 7 (legacy rails): PASS** at challenge level. Solana and Base accepts are still+ offered alongside X Layer in every challenge, all at the same `amount`. Adding the X Layer+ rail did not displace the pre-OKX rails.++### Settlement route facts, measured not assumed++- `okxFacilitatorConfigured()` is **false** in production (health reports+ `facilitator_configured: false`), so settlement runs the direct-redemption path: the+ relayer broadcasts `transferWithAuthorization` and waits for the receipt.+- **Gas is a non-issue and the old 0.3 OKB ask is retired.** X Layer gas price measured at+ 0.02 gwei; one redemption at ~100k gas costs 0.000002 OKB, so the relayer's existing+ 0.02 OKB covers roughly 10,000 settlements.+- Code path confirmed by reading `api/okx/3d/[service].js`: engine runs AFTER verify and+ BEFORE settle, so an engine failure returns before any redemption. `verifyOkxXLayerPayment`+ reads `authorizationState(from, nonce)` on-chain before the engine runs, which is what+ makes case 6 mechanically checkable: the assertion is that the nonce is still unredeemed+ after a failed job, not that an error message was polite.++### Blocked on exactly two owner actions, both in `e2e-evidence/FUNDING-REQUEST.md`++1. **3.0 USD₮0 to `0x75d00a2713565171f33216e5aa2a375e076ecf69`** on X Layer (chainId 196),+ token `0x779Ded0c9e1022225f8E0630b35a9b54bE713736`. Buyer wallet reads **0.000000** today.+ The old file's "self-transfer, net-zero" math is void: `payTo` moved to `0x4022de2D…f402`+ while the buyer stayed `0x75d0…cf69`, so payments now genuinely leave the buyer. Sizing:+ one clean run settles $0.52, but the balance floor (verify refuses any authorization whose+ value exceeds `balanceOf(buyer)`, including the ones meant to be rejected) makes the real+ requirement $0.62, plus $2.08 for four fix-loop iterations.+2. **The OKX login OTP.** `wallet login --phase init` session `7a064ccb-…` is minted and the+ browser URL is in the funding file.++### GO/NO-GO++- **Work Order 05: NO-GO.** Unchanged from the previous session's finding, and for the same+ reason: no real settlement has ever landed. Cases 2, 3, 4, 5a, 5b, 5c and 6 are written,+ wired and dry-run-exercised, but they are unproven until they spend.+- Agent #2632 untouched. No on-chain write attempted.+- `docs/okx-marketplace.md` deliberately still carries no "verified behavior" section: the+ RUNBOOK's standing rule is that it must not claim observed on-chain settlement until a tx+ hash exists. Writing that section from intention is exactly what this work order forbids.diff --git a/prompts/okx-ai/e2e-evidence/FUNDING-REQUEST.md b/prompts/okx-ai/e2e-evidence/FUNDING-REQUEST.mdindex be42a03a5..ce891c90d 100644--- a/prompts/okx-ai/e2e-evidence/FUNDING-REQUEST.md+++ b/prompts/okx-ai/e2e-evidence/FUNDING-REQUEST.md@@ -1,61 +1,91 @@-# Work Order 04 — Consolidated funding request (2026-07-07)+# Work Order 04: consolidated funding + login request (2026-08-01)-All preconditions are met and every funding-independent leg passes against production-(`https://three.ws/api/okx/3d/*`). The gauntlet's paid legs are blocked ONLY on funds.-This file is the exact ask; amounts are computed, not padded.+Every leg of the gauntlet that does not move money is finished and green against+production. The paid legs are blocked on exactly two owner actions. Amounts below are+computed from the catalog and the live gas price, not padded.-## Key fact that shrinks the ask: buyer == seller+## What changed since the 2026-07-07 version of this file-The `onchainos` TEE buyer wallet and our seller `payTo` are the SAME address-`0x75d00a2713565171f33216e5aa2a375e076ecf69` on every EVM chain. An EIP-3009-`transferWithAuthorization` therefore moves USD₮0 from this address back to itself — a-**self-transfer, net-zero balance change**. So the USD₮0 float is NOT consumed per call:-it only has to satisfy the seller's on-chain `balanceOf >= amount` verify check for the-single most expensive call. One top-up covers the entire gauntlet plus retries.+That version computed a near-zero float on the grounds that buyer and seller were the same+address, making each payment a self-transfer. **That is no longer true.** The X Layer+`payTo` moved to `0x4022de2D36C334E73C7a108805Cea11C0564f402` (platform merchant wallet)+while the `onchainos` TEE buyer wallet stayed `0x75d00a2713565171f33216e5aa2a375e076ecf69`.+Payments now genuinely leave the buyer, so the float is consumed per call and the ask is+sized on real spend.-## The request+It also asked for 0.3 OKB of settlement gas. **Measured today, that is unnecessary.** X Layer+gas is 0.02 gwei and one `transferWithAuthorization` costs ~100k gas = 0.000002 OKB. The+relayer's existing 0.02 OKB covers roughly 10,000 settlements. No gas funding needed.++## Live balances (X Layer RPC, direct `eth_call`, block 66850812)++| Wallet | Role | USD₮0 | OKB |+| --- | --- | --- | --- |+| `0x75d00a2713565171f33216e5aa2a375e076ecf69` | Buyer (onchainos TEE) | **0.000000** | 0.000000 |+| `0x4022de2D36C334E73C7a108805Cea11C0564f402` | Seller / payTo | 2.427731 | 0.839596 |+| `0xe81DE501Dd5D9299E2bA8964498858d3fAD0415B` | Relayer (gas) | 0.000000 | 0.020000 |++## The ask: 3.0 USD₮0, one transfer-### 1. USD₮0 float — REQUIRED| | |-|---|---|-| To | `0x75d00a2713565171f33216e5aa2a375e076ecf69` |+| --- | --- |+| To | `0x75d00a2713565171f33216e5aa2a375e076ecf69` (buyer, onchainos TEE wallet) || Chain | X Layer mainnet, chainId **196** (`eip155:196`) || Token | USD₮0 `0x779Ded0c9e1022225f8E0630b35a9b54bE713736` (6 decimals) |-| Amount | **2.0 USD₮0** (2,000,000 atomic) |-| Floor | 0.5 USD₮0 (covers the flagship avatar $0.50); 2.0 gives headroom for the $1.50 identity-studio + all retries |+| Amount | **3.0 USD₮0** (3,000,000 atomic) |-### 2. Settlement gas OR facilitator creds — pick ONE path+### How 3.0 was computed-**Path B (default, already wired — direct relayer redemption):**-| | |-|---|---|-| To | `0xe81DE501Dd5D9299E2bA8964498858d3fAD0415B` (corrected 2026-07-28: the LIVE relayer, from Secret Manager `x402-xlayer-relayer-key` v3, rotated 2026-07-12; see RUNBOOK.md section 3. The older `0x238755DE...8b47` and `0x1B60...AB2a` addresses in git history are pre-rotation and must NOT be funded) |-| Chain | X Layer mainnet, chainId 196 |-| Token | **OKB** (native gas) |-| Amount | **0.3 OKB** (each settle = 1 `transferWithAuthorization` tx ~80k gas; ~15–20 txs incl. retries ≪ 0.1 OKB — 0.3 is buffer) |--**Path A (recommended for WO-05 de-risk — official OKX facilitator, gasless):**-Provision from the OKX Web3 developer console and set in Vercel prod env:-`OKX_API_KEY`, `OKX_SECRET_KEY`, `OKX_PASSPHRASE`. This routes verify/settle through-`https://web3.okx.com/api/v6/pay/x402/*` — the exact path an OKX marketplace buyer (and the-listing reviewer) uses. Facilitator sponsors gas, so **no OKB needed** if this is provided.-Path B still runs as fallback and produces a real on-chain tx either way.--### 3. Legacy-rail regression (case 7) — Solana — REQUIRED for that one case-| | |-|---|---|-| To | `9PirGw9wVLLNFgVyjgAt5jvuFQwJ3pYUBWt9n3vZfnyc` (our TEE Solana wallet) |-| Token | USDC SPL `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` |-| Amount | **0.10 USDC** + **0.02 SOL** (gas / ATA rent; the Solana accept sets a feePayer sponsor so SOL may be unused, 0.02 insures it) |--## Total to send-- **2.0 USD₮0** → `0x75d0…cf69` (X Layer)-- **0.3 OKB** → `0xe81DE501…415B` (X Layer, the live relayer; see section 2) *(skip if providing OKX creds instead)*-- **0.10 USDC + 0.02 SOL** → `9PirGw…fnyc` (Solana)--≈ **$2.10 of stablecoin + ~$0.3 gas**. Everything above cost, one-time float (self-transfer).--## What runs the moment funds land-Cases 2 (text-to-3d $0.01), 3 (avatar $0.50, skeleton-verified), 4 (on-chain settlement tx-capture), 5a/b/c (replay / tampered-amount / stale-challenge), 6 (pay-only-on-success), 7-(Solana legacy). Full gauntlet, individually, against production.+One clean gauntlet run settles **$0.52**:++| Case | Service | Price | Settles? |+| --- | --- | --- | --- |+| 2 | text-to-3d | $0.01 | yes |+| 3 | avatar (flagship) | $0.50 | yes |+| 5a | text-to-3d | $0.01 | yes (the replay itself must not settle again) |+| 5b | text-to-3d | $0.01 | no, rejected on amount before redemption |+| 5c | text-to-3d | $0.01 | no, authorization expired |+| 6 | fbx-export | $0.10 | no, that is the assertion |++The binding constraint is not the sum, it is the **balance floor**: verify refuses any+authorization whose value exceeds `balanceOf(buyer)`, including the ones designed to be+rejected. Running in case order, the wallet must still hold $0.50 when case 3 signs and+$0.10 when case 6 signs, so a single clean run needs **$0.62**, not $0.52.++Phase 3's fix loop re-runs the failed case plus cases 2 and 5a as its regression floor.+Budgeting four iterations at the worst case ($0.52 each) adds **$2.08**.++$0.62 + $2.08 = $2.70. **Rounded to 3.0** for margin. Anything unspent stays in the buyer+wallet for work order 05 and future retests.++## Second owner action: the OKX login OTP++The wallet is logged out (`accountCount: 0`), so nothing can be signed. The login is+browser-based and the OTP is emailed, so only a human can complete it.++```+https://web3.okx.com/account/sociallogin?authSessionId=7a064ccb-a627-4ebc-815e-eba3a3b822f0&tempPubKey=PpyeNo6nZexcWiyuhlNdL2oUuAZ3ZO3H0aioDzx%2FbQ8%3D&clientType=agent-cli+```++Open it, choose email, enter `[email protected]`, complete the emailed OTP in the browser.+The session id above expires; if it has, `onchainos wallet login --phase init` mints a new one.++**Buyer address caveat:** `0x75d0…cf69` is the buyer wallet recorded by the previous+authenticated session, and it is what the funding line above targets. The first thing done+after login is `onchainos wallet status` to confirm the TEE account still resolves to that+address. If it does not, no payment is signed and the corrected address is reported before+anything is spent.++## Optional: make case 7 a real paid legacy settlement++Case 7 currently verifies that the pre-OKX rails (Solana, Base) are still advertised in every+challenge at the correct price, which passes with no funding. Turning it into a real paid+legacy settlement needs USDC on the TEE Solana account, whose address is only readable after+login. If that is wanted, the address gets reported post-login and the ask is 0.10 USDC plus+0.02 SOL. It is not a blocker for the resubmission.++## What runs the moment both land++`npm run okx:gauntlet -- --yes`, which executes cases 1, 2, 3, 5a, 5b, 5c, 5d, 6, 7 and then+case 4 (on-chain settlement verification of every payment the run produced), writing evidence+for each into this directory.