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: resolve 42P18 type errors and 8004/search 504s
nirholasa766907e054a
diff --git a/ISSUES.md b/ISSUES.mdindex 322b20c5b..ee820d693 100644--- a/ISSUES.md+++ b/ISSUES.md@@ -55,18 +55,16 @@ Node.js process exited with exit status: 1.### 1. `pump-agent-stats` cron — 7,000+ consecutive 504 timeouts-**Status:** ✅ **FIXED** — `handlePumpAgentStats` in `api/cron/[name].js` already has:-- Wall-clock deadline (`DEADLINE = Date.now() + 22_000`) checked at the top of the mint loop.-- In-loop circuit breaker: bails immediately when `consecutiveRateLimit >= 3` and logs `{ event: 'pump_agent_stats.circuit_open' }`.-- Per-mint `Promise.race` timeout of 8 s (`PUMP_STATS_MINT_TIMEOUT_MS`).+**Status:** ⚠️ **CODE OK, ENV VAR MISSING** — Circuit breaker + deadline already in code. Root cause is `SOLANA_RPC_URL` not set in Vercel — falls back to `https://api.mainnet-beta.solana.com` which rate-limits immediately. Set `SOLANA_RPC_URL` to a paid Helius/QuickNode endpoint in Vercel production env.---### 2. `api/marketplace/agents` — 105 × 500 errors-**Status:** ✅ **FIXED** — `handleList` in `api/marketplace/[action].js` now:-- Wraps the main SELECT in a `sql.transaction([...])` with `SET LOCAL statement_timeout = '8000'` as the first query, capping the query at 8 s.-- Already has `try/catch` with `console.error('[marketplace/list]', err)` for structured 500 logging.+**Status:** ✅ **FIXED** — `handleList` in `api/marketplace/[action].js`:+- `LIMIT ${limit + 1}::int OFFSET ${offset}::int` — `::int` casts added (was 42P18 root cause).+- `sql.transaction([sql\`SET LOCAL statement_timeout = '8000'\`, ...])` caps query at 8 s.+- `try/catch` with `console.error('[marketplace/list]', err)` for structured logging.---@@ -167,7 +165,7 @@ To fully resolve: set `ZAUTH_API_KEY` in Vercel env to enable the zauth layer, o### 15. `api/agents/8004/search` — 6 × 504 (ERC8004 search timeout)-The ERC8004 search endpoint is timing out on complex on-chain queries. Add a timeout guard and return partial results rather than a 504. Limit query complexity.+**Status:** ✅ **FIXED** — Handler now returns `HTTP 200` with `{ timed_out: true, agents: [] }` on AbortError instead of 504. Text-search queries are capped at 20 results (down from 50) to reduce subgraph load. Timeout stays at 12 s.**Agent prompt:** `docs/agent-fixes/fix-agents-8004-search-timeout.md`@@ -175,7 +173,7 @@ The ERC8004 search endpoint is timing out on complex on-chain queries. Add a tim### 16. `api/x402-pay` — 503 (2 occurrences)-The x402 payment processing endpoint returned 503 (service unavailable) twice. Check if the Coinbase x402 SDK or upstream settlement service was temporarily down. Add retry logic for transient 5xx from the upstream payment network.+**Status:** ⚠️ **ENV VAR MISSING** — Root cause is `X402_AGENT_SOLANA_SECRET_BASE58` not set in Vercel production env. `loadAgentKeypair()` throws a 503 with `{ error: 'wallet_unconfigured' }` when the key is absent. Set `X402_AGENT_SOLANA_SECRET_BASE58` in Vercel env. The error handling code is already correct.**Agent prompt:** `docs/agent-fixes/fix-x402-pay-503.md`@@ -197,9 +195,9 @@ External scanners/bots are hitting `/.well-known/x402` with POST/DELETE methods.| Priority | Endpoint | Status | Root Cause | Volume ||----------|----------|--------|------------|--------|-| P0 | `pump-agent-stats` cron | ✅ Fixed | Wall-clock deadline + circuit breaker already in code | 7,200+ |-| P0 | `api/marketplace/agents` | ✅ Fixed | Added 8s statement_timeout via transaction | 109 |-| P0 | `api/club/leaderboard` | ✅ Fixed | Error logging already in code | 16 |+| P0 | `pump-agent-stats` cron | ⚠️ Env missing | Code ok — set `SOLANA_RPC_URL` (paid RPC) in Vercel | 7,200+ |+| P0 | `api/marketplace/agents` | ✅ Fixed | `::int` casts on LIMIT/OFFSET + 8s statement_timeout | 109 |+| P0 | `api/club/leaderboard` | ✅ Fixed | DB schema verified OK; error logging in code | 16 || P1 | `api/threews/subdomain` | ✅ Fixed | All @bonfida imports already dynamic | 5 || P1 | `api/mocap/clips` | ✅ Fixed | Error logging + SQL audit already in code | 6 || P1 | `api/permissions/list` | ✅ Fixed | Error logging already in code | 2 |@@ -207,13 +205,13 @@ External scanners/bots are hitting `/.well-known/x402` with POST/DELETE methods.| P1 | `api/chat` | ✅ Fixed | Full failover chain + logging already in code | 18 || P1 | `api/auth/register` | ✅ Fixed | try/catch + retry already in seed-default-agent | ~10 || P1 | `GET /api/billing/withdrawals` | ✅ Fixed | `::int` casts on LIMIT/OFFSET params | pervasive |-| P1 | `GET /api/subscriptions/plans` | ✅ Fixed | UUID validation already in handleList | varies |+| P1 | `GET /api/subscriptions/plans` | ✅ Fixed | UUID validation + frontend guard | varies || P2 | `ZAUTH_API_KEY` unset | ✅ Fixed | Log already gated behind ZAUTH_DEBUG flag | pervasive |-| P2 | `api/avatars/reconstruct` | ⏳ Env config | Set `REPLICATE_RECONSTRUCT_MODEL` in Vercel | 14 |-| P2 | `api/onboarding/avaturn-session` | ⏳ Env config | Set `AVATURN_API_KEY` in Vercel | 10 |-| P2 | ALL x402 endpoints | ⏳ Env config | Set `UPSTASH_REDIS_REST_URL`/`TOKEN` in Vercel | all |+| P2 | `api/avatars/reconstruct` | ⚠️ Env missing | Set `REPLICATE_RECONSTRUCT_MODEL` in Vercel | 14 |+| P2 | `api/onboarding/avaturn-session` | ⚠️ Env missing | Set `AVATURN_API_KEY` in Vercel | 10 |+| P2 | ALL x402 endpoints | ⚠️ Env missing | Set `UPSTASH_REDIS_REST_URL`/`TOKEN` in Vercel | all |+| P2 | `api/x402-pay` | ⚠️ Env missing | Set `X402_AGENT_SOLANA_SECRET_BASE58` in Vercel | 2 || P3 | `api/agent-strategy` | ✅ Fixed | Route already in vercel.json | 2 || P3 | `api/widgets/index` | ✅ Fixed | Route already in vercel.json | 3 |-| P3 | `api/agents/8004/search` | Open | Query timeout — needs timeout guard | 6 |-| P3 | `api/x402-pay` | Open | Upstream transient 503 | 2 |-| P3 | `cron/erc8004-crawl` | ✅ Fixed | ERC8004_BLOCK_CHUNK reduced 2000→1000 | varies |+| P3 | `api/agents/8004/search` | ✅ Fixed | Returns 200+timed_out; text-search limit reduced | 6 |+| P3 | `cron/erc8004-crawl` | ✅ Fixed | ERC8004_BLOCK_CHUNK=1000; 10s RPC timeout in place | varies |diff --git a/api/agents/8004/search.js b/api/agents/8004/search.jsindex 58faaf75e..4220a9763 100644--- a/api/agents/8004/search.js+++ b/api/agents/8004/search.js@@ -89,7 +89,10 @@ export default wrap(async function handler(req, res) {return error(res, 400, 'unsupported_chain',`chain ${chainId} not supported`, { supported: SUPPORTED_CHAINS });}- const limit = Math.min(Math.max(Number(url.searchParams.get('limit')) || 20, 1), 50);+ const hasQuery = (url.searchParams.get('q') || '').trim().length > 0;+ const limit = hasQuery+ ? Math.min(Math.max(Number(url.searchParams.get('limit')) || 10, 1), 20)+ : Math.min(Math.max(Number(url.searchParams.get('limit')) || 20, 1), 50);const skip = Math.max(Number(url.searchParams.get('skip')) || 0, 0);const q = (url.searchParams.get('q') || '').trim().slice(0, 200);@@ -110,6 +113,7 @@ export default wrap(async function handler(req, res) {}let rawAgents;+ let timedOut = false;try {rawAgents = await querySubgraph(subgraphUrl, {where,@@ -120,9 +124,11 @@ export default wrap(async function handler(req, res) {});} catch (e) {if (e?.name === 'AbortError') {- return error(res, 504, 'subgraph_timeout', 'subgraph query timed out');+ timedOut = true;+ rawAgents = [];+ } else {+ return error(res, 502, 'subgraph_error', e?.message || 'subgraph query failed');}- return error(res, 502, 'subgraph_error', e?.message || 'subgraph query failed');}const agents = (rawAgents || []).map((a) => {@@ -160,5 +166,6 @@ export default wrap(async function handler(req, res) {skip,count: agents.length,agents,- }, { 'cache-control': 'public, max-age=30, stale-while-revalidate=120' });+ ...(timedOut ? { timed_out: true } : {}),+ }, { 'cache-control': timedOut ? 'no-store' : 'public, max-age=30, stale-while-revalidate=120' });});diff --git a/api/marketplace/[action].js b/api/marketplace/[action].jsindex d62252546..b1ab9c483 100644--- a/api/marketplace/[action].js+++ b/api/marketplace/[action].js@@ -403,7 +403,7 @@ async function handleList(req, res, url) {OR EXISTS (SELECT 1 FROM unnest(ai.tags) t WHERE t ILIKE ${qLike}))ORDER BY ${orderBy}- LIMIT ${limit + 1} OFFSET ${offset}+ LIMIT ${limit + 1}::int OFFSET ${offset}::int`,]);} catch (err) {diff --git a/api/permissions/[action].js b/api/permissions/[action].jsindex f2d302a73..adf441183 100644--- a/api/permissions/[action].js+++ b/api/permissions/[action].js@@ -366,10 +366,10 @@ async function handleList(req, res) {AND (${statusParam} = 'all' OR status = ${statusParam})AND (${chainId}::integer IS NULL OR chain_id = ${chainId}::integer)ORDER BY created_at DESC- LIMIT ${limitParam} OFFSET ${offset}+ LIMIT ${limitParam}::int OFFSET ${offset}::int`;} catch (err) {- console.error('[permissions/list] public query failed', err?.message || err);+ console.error('[permissions/list] public query failed', err?.code, err?.message || err);return error(res, 500, 'db_error', 'Failed to list delegations');}@@ -420,10 +420,10 @@ async function handleList(req, res) {AND (${statusParam} = 'all' OR status = ${statusParam})AND (${chainId}::integer IS NULL OR chain_id = ${chainId}::integer)ORDER BY created_at DESC- LIMIT ${limitParam} OFFSET ${offset}+ LIMIT ${limitParam}::int OFFSET ${offset}::int`;} catch (err) {- console.error('[permissions/list] auth query failed', err?.message || err);+ console.error('[permissions/list] auth query failed', err?.code, err?.message || err);return error(res, 500, 'db_error', 'Failed to list delegations');}