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(api): catalog assemblers resolve descriptor dir under esbuild-bundled lambdas
fudjiae8e6db37f833
diff --git a/api/_lib/3d-catalog/index.js b/api/_lib/3d-catalog/index.jsindex ab935ec0a..08a3b7e68 100644--- a/api/_lib/3d-catalog/index.js+++ b/api/_lib/3d-catalog/index.js@@ -27,10 +27,20 @@import { readdirSync } from 'node:fs';import { pathToFileURL } from 'node:url';-import { dirname, join } from 'node:path';+import { basename, dirname, join } from 'node:path';import { fileURLToPath } from 'node:url';-const __dirname = dirname(fileURLToPath(import.meta.url));+// In dev/tests `import.meta.url` is this source file, so its own directory is+// the descriptor dir. In production Vercel esbuild-bundles this module INTO the+// `api/3d/*.js` handler, so `import.meta.url` resolves to `api/3d/` — full of+// route handlers, not descriptors — and the catalog would silently assemble+// empty. The basename check detects that case and falls back to the+// repo-relative descriptor path, which exists inside the lambda because+// vercel.json pins `includeFiles: "api/_lib/3d-catalog/**"` (Vercel preserves+// repo-relative layout under the function root / cwd).+const SELF = dirname(fileURLToPath(import.meta.url));+const __dirname =+ basename(SELF) === '3d-catalog' ? SELF : join(process.cwd(), 'api', '_lib', '3d-catalog');// Infrastructure modules that live in this directory but are NOT catalog// entries — the assembler itself and the OpenAPI builder. Everything else thatdiff --git a/api/_lib/crypto-catalog/index.js b/api/_lib/crypto-catalog/index.jsindex cab3f1637..5ddd0377d 100644--- a/api/_lib/crypto-catalog/index.js+++ b/api/_lib/crypto-catalog/index.js@@ -24,9 +24,19 @@import { readdirSync } from 'node:fs';import { fileURLToPath, pathToFileURL } from 'node:url';-import { dirname, join } from 'node:path';+import { basename, dirname, join } from 'node:path';-const HERE = dirname(fileURLToPath(import.meta.url));+// In dev/tests `import.meta.url` is this source file, so its own directory is+// the entry dir. In production Vercel esbuild-bundles this module INTO the+// `api/crypto/*.js` handler, so `import.meta.url` resolves to the handler's+// directory (`api/crypto/`) — full of route handlers, not descriptors — and the+// catalog would silently assemble empty. The basename check detects that case+// and falls back to the repo-relative descriptor path, which exists inside the+// lambda because vercel.json pins `includeFiles: "api/_lib/crypto-catalog/**"`+// (Vercel preserves repo-relative layout under the function root / cwd).+const SELF = dirname(fileURLToPath(import.meta.url));+const HERE =+ basename(SELF) === 'crypto-catalog' ? SELF : join(process.cwd(), 'api', '_lib', 'crypto-catalog');// Files in this directory that are the machinery, not catalog entries. Anything// starting with `_` or `.` is also treated as non-entry (private/hidden).diff --git a/prompts/x402-overhaul/PROGRESS.md b/prompts/x402-overhaul/PROGRESS.mdindex d0d600ae5..d58ed55b2 100644--- a/prompts/x402-overhaul/PROGRESS.md+++ b/prompts/x402-overhaul/PROGRESS.md@@ -4,6 +4,49 @@ Dated entries per prompt. Newest first.---+## 2026-07-07 — Prompt 10 follow-up: production catalog assembled EMPTY — root-caused + fixed (also fixed the same bug in the 3D catalog)++**What changed since the original entry:** the `/api/crypto/*` surface DEPLOYED+(prompt 11's probe of 404s is stale — `GET /api/crypto`, `/api/crypto/openapi.json`,+and sibling endpoints like `/api/crypto/trending` all return **200** live now).+But the live index returned `"endpoints": [], "count": 0` and the OpenAPI doc had+`"paths": {}` — while the repo has 5 committed descriptors. The zero-entry state+rendered exactly as designed (valid empty catalog + coming-soon note, no error),+which is why nothing alarmed: **graceful degradation masked a real bug.**++**Root cause:** Vercel esbuild-bundles each `api/` function (the known+CLAUDE.md trap). The assembler is bundled INTO `api/crypto/index.js`, so at+runtime `import.meta.url` resolves to the handler's own directory+(`/var/task/api/crypto/`) — full of route handlers, not descriptors. The+`readdirSync` found the handler files, none exported a valid descriptor, all were+"skipped" per the robustness contract → empty catalog. The+`includeFiles: "api/_lib/crypto-catalog/**"` pin WAS working — the descriptor+files sit at their repo-relative path under the function root — the assembler was+just looking in the wrong directory.++**Fix** (`api/_lib/crypto-catalog/index.js`): derive the entry dir with a+basename discriminator — if `dirname(import.meta.url)` doesn't end in+`crypto-catalog`, the module is running from an esbuild bundle, so fall back to+`join(process.cwd(), 'api/_lib/crypto-catalog')` (cwd = function root on Vercel,+repo root in dev). Same fix applied to `api/_lib/3d-catalog/index.js`, which had+the identical bug — live `GET /api/3d` was also serving `"endpoints": []` with+2 descriptors committed.++**Proof:**+- Simulated the bundle relocation: copied each assembler to a foreign directory+ and imported it from the repo root — crypto found **5** entries+ (`bonding,symbol,trending,wallet,whales`), 3d found **2** (`generate,inspect`).+ Before the fix this reproduced production's empty catalog.+- `npx vitest run tests/crypto-catalog.test.js tests/3d-catalog.test.js` →+ **2 files, 24/24 passed** (dev-path behavior unchanged).+- Post-deploy live capture: see below (added after the deploy went out).++**Also closed:** the original entry's vitest placeholder — the shared+`node_modules` install-storm settled, `tests/crypto-catalog.test.js` runs green+under real vitest (12/12); output pasted in that entry.++---+## 2026-07-07 — Prompt 19: Elevate the Pump Launcher listing**Shipped (listing quality + discovery + free→paid funnel; deploy/signing internals untouched):**@@ -168,8 +211,21 @@ installs. A background poller re-runs `npx vitest run tests/crypto-catalog.test.the moment the tree is whole — see the vitest result below.```-<!-- vitest output pasted here once the shared node_modules install storm settles;- logic already proven 17/17 via scratchpad standalone harness -->+$ npx vitest run tests/crypto-catalog.test.js (2026-07-07, node_modules repaired)+ ✓ crypto-catalog assembler > merges every valid entry, skips malformed, skips throwing, dedups routes+ ✓ crypto-catalog assembler > accepts the terse input/output aliases and a multi-verb methods array+ ✓ crypto-catalog assembler > normalizes entries: method upper-cased, optional fields defaulted+ ✓ crypto-catalog assembler > returns a valid EMPTY catalog for a directory with no entries+ ✓ crypto-catalog assembler > never throws on an unreadable directory+ ✓ crypto-catalog OpenAPI generator > produces a structurally valid OpenAPI 3.1 doc from the entries+ ✓ crypto-catalog OpenAPI generator > converts inputSchema into query + path parameters+ ✓ crypto-catalog OpenAPI generator > emits one operation per verb for multi-verb entries+ ✓ crypto-catalog OpenAPI generator > validates an empty-catalog doc (no paths) as still well-formed+ ✓ crypto-catalog OpenAPI generator > flags a malformed doc+ ✓ GET /api/crypto content negotiation > returns JSON by default with the discovery envelope+ ✓ GET /api/crypto content negotiation > returns HTML when the client asks for text/html+ Test Files 1 passed (1)+ Tests 12 passed (12)```**Adjacent gaps noticed (for other prompts):**