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
feat(okx-ai): one-command chat-bot recovery, skills for the responder, listing regression guard
nirholas4c3a1c63f0cf
diff --git a/package.json b/package.jsonindex 17a8035fb..f9036651c 100644--- a/package.json+++ b/package.json@@ -254,7 +254,8 @@"seed:skills": "node scripts/seed-skills.js","install:sdk": "npm install --prefix agent-payments-sdk && npm run build --prefix agent-payments-sdk && npm install ./agent-payments-sdk","claude": "./scripts/claude.sh",- "typecheck": "tsc -p jsconfig.json"+ "typecheck": "tsc -p jsconfig.json",+ "okx:bot": "node scripts/okx-bot-revive.mjs"},"dependencies": {"@0xsplits/splits-sdk": "^6.5.0",diff --git a/prompts/okx-ai/PROGRESS.md b/prompts/okx-ai/PROGRESS.mdindex d8f7f07fb..d3e4992ab 100644--- a/prompts/okx-ai/PROGRESS.md+++ b/prompts/okx-ai/PROGRESS.md@@ -1469,3 +1469,57 @@ create the rest). Submission can no longer drift from the module.yet applied), `validate-listing` batch pass, human confirms the diff card.5. Re-activate (`--preferred-language en-US`), then tell the OKX contact to retest, andresubmit for review via the OKX support chat per the rejection email.++### 2026-07-27 addendum: catalog fix LIVE in production; bot recovery reduced to one command++Continuation of the 2026-07-26 entry. Verified against live production today:++- **The usage-example rewrite is deployed and serving.** `GET /api/okx/3d/catalog` returns+ 11/11 rows carrying a `Example: ...` usage line alongside the numbered parameter list,+ so the three-copy rule (module == live == submission) holds and the resubmission can go+ out as soon as the login lands. Deploy ran from a clean worktree; the first attempt died+ on a missing `DATABASE_URL` in that worktree (`db:check`), fixed by exporting it from+ `.env`.+- **402 + health re-probed:** unpaid `POST /api/okx/3d/text-to-3d` -> `HTTP 402` with+ `accepts[0] = eip155:196` at `10000` (Solana and two Base entries after), and+ `/api/okx/3d/health` reports all five subsystems ok with `payment-rail settleable:true`+ at block 66402405. Nothing regressed while the listing work was in flight.+- **Regression guard added.** `tests/api/okx-3d-services.test.js` now asserts every catalog+ row has a substantial capability line, a `Provide:` parameter list, AND a usage example.+ The exact rejection reason can no longer regress silently. 57 tests green.+- **Changelog + docs:** holder entry added (improvement/docs, links `/docs/okx-marketplace`);+ RUNBOOK 0.5 rewritten around the new one-command recovery.++**The bot went offline again overnight, on its own.** The daemon was alive at 21:09 and+dead ("stale pid") by 03:13 when the codespace idled. This is not a rebuild-only failure+mode, so the revival checklist became a script: **`npm run okx:bot`**+(`scripts/okx-bot-revive.mjs`). It installs both CLIs, starts the daemon, wires the runtime,+regenerates the briefing from the catalog module, links the OKX skills into the AI+workspace, sets permission bypass, and reports health. Exit 0 = online; exit 2 = staged but+logged out, printing the login URL and follow-up commands.++**New finding, a real answer-quality gap (fixed).** The daemon spawns the AI CLI with+`cwd=~/.okx-agent-task/workspace`, and that directory had NO skills: a dry run showed the+subsession loading only generic skills, none of `okx-agent-task`, `okx-agent-payments-protocol`,+or our 3D skills. Task envelopes (accept / negotiate / deliver / dispute) would have been+improvised instead of following the documented flow. Fixed by linking 12 relevant skills+into `<workspace>/.claude/skills`; a dry run now shows all 11 okx/3d skills loaded and+answers correctly ("Text to 3D Model (GLB) at $0.01 USDT is our fastest and cheapest lane").++**Architecture note for whoever tries to make this always-on.** The `okx-a2a` AI adapter+does NOT extract a reply from the CLI's stdout; it dispatches a prompt and expects the AI+subsession itself to send the reply back through the CLI (`okx-a2a session send`). So+swapping the agentic CLI for a one-shot LLM call (our own free `llmComplete` chain, which+would need no personal login and could run anywhere) would silently break the task+lifecycle, not just chat. The adapter does expose escape hatches for a custom host+(`OKX_A2A_AI_<PROVIDER>_COMMAND` and `..._EXEC_ARGS_JSON` / `..._RESUME_ARGS_JSON`, with+`{prompt}`/`{sessionId}`/`{cwd}` placeholders), so a headless box is possible, but it must+run something genuinely agentic. Do not trade task correctness for hostability.++**Still owner-gated, both single actions:**+1. **OKX browser login** (email OTP as `[email protected]`) -> bot online, then+ `service-list` diff -> `agent update` with the delta from+ `scripts/okx-listing-payload.mjs --delta` -> re-activate -> tell the OKX contact to+ retest and resubmit via support chat.+2. **`gcloud auth login`** (the token expired again overnight, same failure the memory+ file records) -> needed for any Cloud Run / VM work, not for the listing itself.diff --git a/prompts/okx-ai/RUNBOOK.md b/prompts/okx-ai/RUNBOOK.mdindex dcae2b6b2..8b6e6a031 100644--- a/prompts/okx-ai/RUNBOOK.md+++ b/prompts/okx-ai/RUNBOOK.md@@ -34,22 +34,43 @@ are reads (they 401 with "session expired" when logged out). Only `curl` against----## 0.5 After ANY codespace rebuild: revive the chat bot (found the hard way, 2026-07-26)--The marketplace chat bot for #2632 is a LOCAL `okx-a2a` daemon + the wallet session, both-outside the repo. A codespace rebuild silently wipes them and OKX chat tests then time out-with "no delivery in 30 min". Revive, in order:--1. Reinstall `onchainos` (checksum-verified installer, `.agents/skills/okx-agentic-wallet/_shared/preflight.md`) and `npm i -g @okxweb3/a2a-node@latest`.-2. `okx-a2a daemon start`, then `okx-a2a switch-runtime --json`, `okx-a2a setup --json`.-3. Complete the browser login (§0). The daemon retries `agent get` every minute and picks- the session up on its own; `okx-a2a agent refresh --json` must then report- `agentCount >= 1`, `activeClients >= 1`. That is the "bot online" proof.-4. Regenerate the responder briefing so chat answers know the catalog:- `node scripts/okx-listing-payload.mjs --briefing > ~/.okx-agent-task/workspace/CLAUDE.md`-5. `okx-a2a agent bypass on` (answers without permission stalls) and- `okx-a2a doctor --non-interactive` for a final sweep. Measured reply latency through- the full claude adapter path: ~12 s per message.+## 0.5 The chat bot goes offline on its own: `npm run okx:bot`++The marketplace chat bot for #2632 is a LOCAL `okx-a2a` daemon plus the `onchainos` wallet+session, both outside this repo. A codespace rebuild wipes the CLIs; an idle nap kills the+daemon (observed: alive 21:09, dead by 03:13 the same night). OKX-side chat tests then time+out with "no delivery in 30 min", which is what got the listing flagged as offline on+2026-07-26.++**One command does the whole recovery:**++```bash+npm run okx:bot+```++It installs/updates both CLIs, starts the daemon, wires the runtime, regenerates the chat+briefing from the live catalog module, links the OKX skills into the AI workspace, turns on+permission bypass, and reports health. Exit code 0 = online. Exit code 2 = everything is+staged but the wallet is logged out, and it prints the login URL a human must open (email+OTP, `[email protected]`) plus the two follow-up commands.++What it wires, and why each matters:++| Piece | Why the bot is broken without it |+|---|---|+| `okx-a2a` daemon | Holds the XMTP identity chat is delivered to. |+| Wallet session | The daemon takes every client offline the moment `onchainos agent get` 401s. |+| `~/.okx-agent-task/workspace/CLAUDE.md` | The AI subsession's only knowledge of what we sell; generated from `api/_lib/okx-catalog.js` so prices can never drift from the endpoints. |+| `.claude/skills` in that workspace | Without them the subsession has no `okx-agent-task` flow and improvises on task envelopes instead of following accept/negotiate/deliver. |+| `agent bypass on` | Otherwise the subsession stalls on a tool-approval prompt nobody is there to answer, which reads to the buyer as an unresponsive bot. |++Measured reply latency through the real adapter path: ~12 s bare, ~46 s with the full skill+set loaded. Both are far inside OKX's 30-minute test window.++**Known limitation:** a codespace cannot stay up on its own, so the bot dies whenever this+workspace sleeps. Run `npm run okx:bot` right before an OKX retest window, and treat an+always-on host (a small always-on VM running the same stack) as the durable fix. That move+needs an AI-provider credential for the headless box, an owner action.## 1. Daily status checkdiff --git a/public/features.json b/public/features.jsonindex decd12584..08f4b85f5 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-27T17:05:08.365Z",+ "generated_at": "2026-07-27T17:10:35.096Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/scripts/okx-bot-revive.mjs b/scripts/okx-bot-revive.mjsnew file mode 100644index 000000000..0de61ec11--- /dev/null+++ b/scripts/okx-bot-revive.mjs@@ -0,0 +1,184 @@+#!/usr/bin/env node+// Brings the OKX.AI marketplace chat bot for agent #2632 back online, end to end.+//+// npm run okx:bot+//+// The bot is a LOCAL `okx-a2a` daemon plus an `onchainos` wallet session, both of+// which live outside this repo. A codespace rebuild (or an idle nap) wipes them,+// and OKX-side chat tests then time out with "no delivery in 30 min". This script+// is the whole recovery: install, daemon, AI workspace, catalog briefing, skills,+// permissions, health sweep. It is safe to run any number of times.+//+// The one step it cannot do for you is the browser login: OKX requires a human to+// complete an email OTP. When logged out, the script prints the login URL and+// exits non-zero so callers can tell "needs a human" from "ready".++import { execFileSync, execSync } from 'node:child_process';+import { existsSync, mkdirSync, symlinkSync, rmSync, writeFileSync } from 'node:fs';+import { homedir } from 'node:os';+import { join, dirname } from 'node:path';+import { fileURLToPath } from 'node:url';++const REPO = join(dirname(fileURLToPath(import.meta.url)), '..');+const WORKSPACE = join(homedir(), '.okx-agent-task', 'workspace');+const SKILLS_SRC = join(REPO, '.agents', 'skills');+const MIN_NODE_MAJOR = 22;++// Skills the chat subsession needs: the A2A task/chat lifecycle, our identity and+// payment surfaces, and the 3D skills a buyer question can land on.+const SKILLS = [+ 'okx-agent-chat',+ 'okx-agent-task',+ 'okx-agent-identity',+ 'okx-agent-payments-protocol',+ 'okx-agentic-wallet',+ 'okx-ai-guide',+ 'okx-ai-support',+ 'okx-task-watch',+ 'create-3d-avatar',+ 'generate-3d-model',+ 'rig-a-model',+ 'embed-three-ws-avatar',+];++const steps = [];+function step(name, detail) {+ steps.push({ name, detail });+ console.log(` ${name}: ${detail}`);+}++function sh(cmd, { allowFail = false } = {}) {+ try {+ return execSync(cmd, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();+ } catch (err) {+ if (allowFail) return '';+ throw err;+ }+}++function has(bin) {+ return sh(`command -v ${bin} || true`, { allowFail: true }).length > 0;+}++console.log('OKX chat bot revive\n');++// 1. Node version, the daemon refuses to run below 22.14.+const major = Number(process.versions.node.split('.')[0]);+if (major < MIN_NODE_MAJOR) {+ console.error(`Node ${process.versions.node} is too old; the okx-a2a daemon needs >= ${MIN_NODE_MAJOR}.14.0.`);+ process.exit(1);+}+step('node', process.versions.node);++// 2. The two CLIs. okx-a2a runs the daemon; onchainos holds the wallet session the+// daemon reads agent identities through.+if (!has('okx-a2a')) {+ console.log(' installing @okxweb3/a2a-node ...');+ sh('npm install -g @okxweb3/a2a-node@latest');+}+step('okx-a2a', sh('okx-a2a --version', { allowFail: true }) || 'installed');++const onchainosBin = join(homedir(), '.local', 'bin', 'onchainos');+if (!has('onchainos') && !existsSync(onchainosBin)) {+ console.error(+ 'onchainos is missing. Install it with the checksum-verified installer described in\n' ++ '.agents/skills/okx-agentic-wallet/_shared/preflight.md, then re-run this script.',+ );+ process.exit(1);+}+process.env.PATH = `${join(homedir(), '.local', 'bin')}:${process.env.PATH}`;+step('onchainos', sh('onchainos --version', { allowFail: true }) || 'present');++// 3. Daemon. `daemon start` is idempotent and reports a stale pid as not running.+const daemonStatus = sh('okx-a2a daemon start', { allowFail: true });+step('daemon', daemonStatus.split('\n').pop() || 'started');++// 4. Runtime wiring (which AI CLI answers chats) and final plugin setup.+sh('okx-a2a switch-runtime --json', { allowFail: true });+const setup = sh('okx-a2a setup --json', { allowFail: true });+const setupState = (() => {+ try {+ return JSON.parse(setup.split('\n').pop()).state;+ } catch {+ return 'unknown';+ }+})();+step('runtime setup', setupState);++// 5. The AI workspace: this is the cwd the daemon spawns the AI CLI in, so its+// CLAUDE.md and .claude/skills are what the chat subsession actually sees.+mkdirSync(join(WORKSPACE, '.claude', 'skills'), { recursive: true });++const briefing = execFileSync(process.execPath, [join(REPO, 'scripts', 'okx-listing-payload.mjs'), '--briefing'], {+ encoding: 'utf8',+});+writeFileSync(join(WORKSPACE, 'CLAUDE.md'), briefing);+step('briefing', `${briefing.length} chars from the live catalog module`);++let linked = 0;+for (const name of SKILLS) {+ const src = join(SKILLS_SRC, name);+ if (!existsSync(src)) continue;+ const dest = join(WORKSPACE, '.claude', 'skills', name);+ rmSync(dest, { force: true, recursive: false });+ symlinkSync(src, dest);+ linked++;+}+step('skills', `${linked} linked into the chat subsession`);++// 6. Permissions: without bypass the subsession stalls on tool approval prompts+// nobody is there to answer, which reads to the buyer as an unresponsive bot.+sh('okx-a2a agent bypass on --json', { allowFail: true });+step('permissions', 'bypass on');++// 7. Wallet session. Everything above is useless while logged out: the daemon+// takes every XMTP client offline when `onchainos agent get` 401s.+const status = sh('onchainos wallet status', { allowFail: true });+let loggedIn = false;+try {+ loggedIn = JSON.parse(status).data.loggedIn === true;+} catch {+ loggedIn = false;+}++if (!loggedIn) {+ console.log('\nNOT ONLINE: the OKX wallet session is logged out.\n');+ const init = sh('onchainos wallet login --phase init', { allowFail: true });+ try {+ const { authSessionId, loginUrl } = JSON.parse(init).data;+ console.log('A human must finish this login (email OTP, account [email protected]):\n');+ console.log(` ${loginUrl}\n`);+ console.log('Then run:');+ console.log(` onchainos wallet login --phase poll --session-id ${authSessionId}`);+ console.log(' okx-a2a agent refresh --json # expect agentCount >= 1, activeClients >= 1');+ } catch {+ console.log('Run `onchainos wallet login --phase init` and open the returned loginUrl.');+ }+ process.exit(2);+}++// 8. Logged in: pull the agent identities so the XMTP clients come online.+const refresh = sh('okx-a2a agent refresh --json', { allowFail: true });+let agentCount = 0;+let activeClients = 0;+try {+ const payload = JSON.parse(refresh).payload ?? {};+ agentCount = payload.agentCount ?? 0;+ activeClients = payload.activeClients ?? 0;+} catch {+ /* refresh may queue instead of completing; the doctor line below is the check */+}+step('agents', `agentCount=${agentCount} activeClients=${activeClients}`);++console.log(`\n${sh('okx-a2a doctor --non-interactive', { allowFail: true })}`);++if (agentCount < 1 || activeClients < 1) {+ console.log(+ '\nLogged in but no active XMTP client yet. The daemon retries every minute;\n' ++ 're-run `okx-a2a agent refresh --json` in a moment, and check\n' ++ '~/.okx-agent-task/logs/listener.log if it stays at zero.',+ );+ process.exit(2);+}++console.log('\nONLINE: agent #2632 is reachable in OKX.AI marketplace chat.');diff --git a/tests/api/okx-3d-services.test.js b/tests/api/okx-3d-services.test.jsindex 941d501e8..26dac5bfe 100644--- a/tests/api/okx-3d-services.test.js+++ b/tests/api/okx-3d-services.test.js@@ -202,6 +202,19 @@ describe('okx catalog — work order 03 rows', () => {}});+ // OKX rejected the listing on 2026-07-26 for "missing a complete description,+ // parameter details, and usage examples". Every row now carries all three, and+ // this is the guard that keeps them from silently regressing.+ it('every row states its parameters AND shows a usage example', () => {+ for (const e of OKX_CATALOG) {+ expect(e.describes.capability.length, `${e.id} capability`).toBeGreaterThan(40);+ // Parameter details: the numbered "Provide:" list OKX's format asks for.+ expect(e.describes.input, `${e.id} input`).toMatch(/^Provide/);+ // Usage example: what the reviewer specifically found missing.+ expect(e.describes.input, `${e.id} usage example`).toMatch(/Example: \S/);+ }+ });+it('the free catalog index carries every service 1:1', () => {const ids = catalogIndex().services.map((s) => s.id);for (const id of PAID_REST_IDS) expect(ids).toContain(id);