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): route three agent handlers that production could never reach
nirholas56c50559f990
diff --git a/tests/vercel-agents-subpath-routes.test.js b/tests/vercel-agents-subpath-routes.test.jsindex 880279d27..3713392fc 100644--- a/tests/vercel-agents-subpath-routes.test.js+++ b/tests/vercel-agents-subpath-routes.test.js@@ -20,10 +20,20 @@* Sub-paths that legitimately resolve to the dispatcher (it switches on the URL* internally) and the hyphen-aliased `<dir>-<action>` routes are unaffected and* asserted here too, so a fix for one cannot silently break the other.+ *+ * The `api/agents/[id]/` sweep below is derived from disk rather than hand-listed,+ * because a hand-list only ever covers the outage someone already found. This test+ * previously named those same three paths and nothing else, so+ * `api/agents/[id]/bundles.js` sat unrouted and unnoticed: every+ * `GET /api/agents/:id/bundles` was answered by the dispatcher with the AGENT+ * object, a 200 carrying the wrong body, which no error monitor can see. The whole+ * skill-bundle feature (create, list, price, buy) was unreachable in production as+ * a result. Deriving the list means the next handler added to that directory is+ * covered the moment it lands.*/import { describe, it, expect } from 'vitest';-import { readFileSync } from 'node:fs';+import { readFileSync, readdirSync } from 'node:fs';const routes = JSON.parse(readFileSync(new URL('../vercel.json', import.meta.url), 'utf8')).routes;const fsPhase = routes.findIndex((r) => r.handle === 'filesystem');@@ -75,6 +85,75 @@ describe('nested /api/agents handlers are reachable, not shadowed by the [id] caexpect(resolve('/api/agents/solana-metadata')).toBe('/api/agents/solana/[action]?action=metadata');});+ // Every handler in api/agents/[id]/ needs at least one route that both names it+ // as a dest AND actually wins resolution for the path that route describes.+ //+ // Asked as "does /api/agents/:id/<filename> resolve to <filename>?" this sweep+ // reports a false failure for memory-seed-x, which is routed and reachable at+ // /api/agents/:id/memory/seed/x. The URL is not required to echo the filename;+ // what matters is that some URL gets there. So the invariant is written over+ // the route table's own srcs instead of over a guessed URL.+ const perIdHandlers = readdirSync(new URL('../api/agents/[id]/', import.meta.url))+ .filter((f) => f.endsWith('.js'))+ .map((f) => f.replace(/\.js$/, ''));++ /**+ * A concrete path that a route's `src` pattern matches, so the resolver can be+ * asked whether that route is the one that wins. Covers the shapes actually used+ * in this table: capture groups, alternations, and the optional-tail suffix.+ */+ function samplePath(src) {+ return src+ .replace(/\(\?:\/\.\*\)\?/g, '')+ .replace(/\(\?:([^)|]+)(\|[^)]*)?\)/g, '$1')+ .replace(/\(([^)|]+)(\|[^)]*)?\)/g, (_, first) => (/^\[\^\/\]\+$/.test(first) ? 'sample' : first))+ .replace(/\\\./g, '.')+ .replace(/\?$/, '');+ }++ it('covers every handler in api/agents/[id]/', () => {+ // A directory that reads as empty would make the sweep below vacuously pass.+ expect(perIdHandlers.length).toBeGreaterThan(0);+ });++ it.each(perIdHandlers)('api/agents/[id]/%s.js is reachable', (name) => {+ const dest = `${DISPATCHER}/${name}`;+ const candidates = routes+ .slice(0, fsPhase)+ .filter((r) => typeof r.src === 'string' && String(r.dest || '').split('?')[0] === dest);++ expect(+ candidates.length,+ `no route in vercel.json has dest ${dest}, so api/agents/[id]/${name}.js can never run`,+ ).toBeGreaterThan(0);++ // Having a route is not enough: an earlier broader route can still win.+ const reachable = candidates.filter((r) => resolve(samplePath(r.src))?.split('?')[0] === dest);+ expect(+ reachable.length,+ `every route for ${dest} is shadowed by a broader route above it (likely ${DISPATCHER}); move it up`,+ ).toBeGreaterThan(0);+ });++ it('routes a bundle sub-resource so update and delete can address one bundle', () => {+ // PATCH/DELETE address /api/agents/:id/bundles/:bundleId. Without its own+ // route that path falls to the plain /bundles route, which carries no+ // bundle_id, and the handler answers 405 instead of editing the bundle.+ expect(resolve('/api/agents/agt_abc/bundles/bdl_123')).toBe(+ '/api/agents/[id]/bundles?id=agt_abc&bundle_id=bdl_123',+ );+ });++ it('routes the bundle purchase confirm sub-path', () => {+ // The create call returns Solana Pay params; the client then POSTs the+ // confirm sub-path. Unrouted, it fell through to the generic /api/(.*)+ // rewrite and resolved to a file that does not exist, so a buyer who had+ // already paid on-chain could never claim the skills.+ expect(resolve('/api/marketplace/purchase-bundle/pur_123/confirm')).toBe(+ '/api/marketplace/purchase-bundle?purchase_id=pur_123&op=confirm',+ );+ });+it('keeps the ens route above the catch-all', () => {const ens = routes.findIndex((r) => r.src === '/api/agents/ens/([^/]+)');const catchAll = routes.findIndex((r) => r.src === '/api/agents/([^/]+)(?:/.*)?');diff --git a/vercel.json b/vercel.jsonindex 53739cca5..c515e76b3 100644--- a/vercel.json+++ b/vercel.json@@ -27,7 +27,7 @@"api/tournaments/[id].js": {"maxDuration": 120},- "{api/agents/networth,api/avatars/from-forge,api/pay/execute,api/cron/launcher-claimer,api/seed/synthesize,api/cron/x402-ring-tick}.js": {+ "{api/agents/networth,api/avatars/from-forge,api/pay/execute,api/pay/simulate,api/cron/launcher-claimer,api/seed/synthesize,api/cron/x402-ring-tick}.js": {"maxDuration": 60},"{api/club/tips-stream,api/feed-stream,api/pump/trades-stream,api/oracle/stream,api/oracle/action-stream,api/sniper/stream,api/sniper/radar-stream,api/agent-screen-stream}.js": {@@ -646,6 +646,26 @@"src": "/api/agents/([^/]+)/tiers","dest": "/api/agents/[id]/tiers?id=$1"},+ {+ "src": "/api/agents/([^/]+)/bundles/([^/]+)",+ "dest": "/api/agents/[id]/bundles?id=$1&bundle_id=$2"+ },+ {+ "src": "/api/agents/([^/]+)/bundles",+ "dest": "/api/agents/[id]/bundles?id=$1"+ },+ {+ "src": "/api/agents/([^/]+)/pricing-rules/([^/]+)",+ "dest": "/api/agents/[id]/pricing-rules?id=$1&rule_id=$2"+ },+ {+ "src": "/api/agents/([^/]+)/pricing-rules",+ "dest": "/api/agents/[id]/pricing-rules?id=$1"+ },+ {+ "src": "/api/agents/([^/]+)/skill-prices",+ "dest": "/api/agents/[id]/skill-prices?id=$1"+ },{"src": "/api/ledger/verify/([^/]+)","dest": "/api/ledger/verify/[agentId]?agentId=$1"@@ -710,6 +730,10 @@"src": "/api/pay/execute","dest": "/api/pay/execute"},+ {+ "src": "/api/pay/simulate",+ "dest": "/api/pay/simulate"+ },{"src": "/api/portfolio/summary","dest": "/api/portfolio/[action]?action=summary"@@ -974,6 +998,10 @@"src": "/trading/?","dest": "/trading.html"},+ {+ "src": "/exit-lab/?",+ "dest": "/exit-lab.html"+ },{"src": "/claim-wallet/?","dest": "/claim-wallet.html"@@ -1238,6 +1266,10 @@"src": "/avatar-cli/?","dest": "/avatar-cli.html"},+ {+ "src": "/rig-doctor/?",+ "dest": "/rig-doctor.html"+ },{"src": "/avatar-artifact/?","dest": "/avatar-artifact.html"@@ -2450,6 +2482,10 @@"src": "/api/marketplace/start-trial","dest": "/api/marketplace/start-trial"},+ {+ "src": "/api/marketplace/purchase-bundle/([^/]+)/confirm",+ "dest": "/api/marketplace/purchase-bundle?purchase_id=$1&op=confirm"+ },{"src": "/api/marketplace/purchase/([^/]+)/confirm","dest": "/api/marketplace/purchase?reference=$1&op=confirm"@@ -3188,6 +3224,10 @@"src": "/api/sniper/status","dest": "/api/sniper/status.js"},+ {+ "src": "/api/sniper/exit-lab",+ "dest": "/api/sniper/exit-lab.js"+ },{"src": "/api/trending","dest": "/api/trending.js"@@ -4032,6 +4072,10 @@"src": "/gestures/?","dest": "/gestures.html"},+ {+ "src": "/choreograph/?",+ "dest": "/choreograph.html"+ },{"src": "/character-library/?","dest": "/character-library.html"@@ -4490,6 +4534,10 @@"src": "/cookbook/self-correcting-3d/?","dest": "/cookbook/self-correcting-3d/index.html"},+ {+ "src": "/cookbook/pipeline/?",+ "dest": "/pipeline-studio.html"+ },{"src": "/cookbook/([a-z0-9-]+)","dest": "/recipe.html"@@ -4988,6 +5036,14 @@"src": "/agent-identities/","dest": "/agent-identities.html"},+ {+ "src": "/inspect",+ "dest": "/inspect.html"+ },+ {+ "src": "/inspect/",+ "dest": "/inspect.html"+ },{"src": "/mcp-tools","dest": "/mcp-tools.html"