Skip to content

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.

refactor(api): streamline pumpfun route handling and update test imports

nirholasa2e443856811
diff --git a/api/agents/[id].js b/api/agents/[id].js
index 215ee30d0..1c2b5211c 100644
--- a/api/agents/[id].js
+++ b/api/agents/[id].js
@@ -8,12 +8,9 @@
* /api/agents/:id/sns/register — register a .sol; agent wallet pays USDC
* /api/agents/:id/sns/register-prep — build unsigned tx for user wallet to sign
* /api/agents/:id/sns/register-confirm — confirm a user-wallet registration and attach
- * /api/agents/:id/pumpfun/launch — create a pump.fun token from this agent
- * /api/agents/:id/pumpfun/buy — bonding-curve buy
- * /api/agents/:id/pumpfun/sell — bonding-curve sell
- * /api/agents/:id/pumpfun/portfolio — aggregated positions + live PnL
- * /api/agents/:id/pumpfun/swap — swap via @pump-fun/pump-swap-sdk
- * /api/agents/:id/pumpfun/pay — agent payment via @pump-fun/agent-payments-sdk
+ *
+ * /api/agents/:id/pumpfun/* is routed directly to api/agents/pumpfun/[action].js
+ * by vercel.json — see the rewrite for that path family.
*/
import { handleGetOne, handleWallet } from '../agents.js';
import { cors, error, wrap } from '../_lib/http.js';
@@ -50,16 +47,5 @@ export default wrap(async function handler(req, res) {
return mod.default(req, res, id, action);
}
- if (sub === 'pumpfun') {
- if (action === 'launch') return (await import('./pumpfun/launch.js')).default(req, res, id);
- if (action === 'buy') return (await import('./pumpfun/buy.js')).default(req, res, id);
- if (action === 'sell') return (await import('./pumpfun/sell.js')).default(req, res, id);
- if (action === 'portfolio') return (await import('./pumpfun/portfolio.js')).default(req, res, id);
- if (action === 'swap') return (await import('./pumpfun/swap.js')).default(req, res, id);
- if (action === 'pay') return (await import('./pumpfun/pay.js')).default(req, res, id);
- if (cors(req, res)) return;
- return error(res, 404, 'not_found', 'unknown pumpfun action');
- }
-
return handleGetOne(req, res, id);
});
diff --git a/tests/api/pumpfun-monitor.test.js b/tests/api/pumpfun-monitor.test.js
index c3180f844..d8a459d51 100644
--- a/tests/api/pumpfun-monitor.test.js
+++ b/tests/api/pumpfun-monitor.test.js
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
-import { detectEvents } from '../../api/cron/pumpfun-monitor.js';
+import { detectEvents } from '../../api/cron/[name].js';
import { deriveEventId } from '../../api/_lib/attest-event.js';
const baseRow = {
diff --git a/tests/pumpfun-signals.test.js b/tests/pumpfun-signals.test.js
index 62f8bdbb9..77d14a6e8 100644
--- a/tests/pumpfun-signals.test.js
+++ b/tests/pumpfun-signals.test.js
@@ -17,7 +17,9 @@ vi.mock('../api/_lib/env.js', () => ({
env: { APP_ORIGIN: 'http://test', ISSUER: 'http://test', MCP_RESOURCE: 'http://test' },
}));
-const { default: handler } = await import('../api/cron/pumpfun-signals.js');
+const { default: dispatcher } = await import('../api/cron/[name].js');
+const handler = (req, res) =>
+ dispatcher({ ...req, query: { ...(req.query || {}), name: 'pumpfun-signals' } }, res);
function mockRes() {
const res = {