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
refactor(pump): fold the channel feed and Telegram delivery into one handler
nirholase79c3d2d9708
diff --git a/api/pump/[action].js b/api/pump/[action].jsindex 49067229f..d10a697f7 100644--- a/api/pump/[action].js+++ b/api/pump/[action].js@@ -3451,18 +3451,36 @@ async function handleChannelFeed(req, res) {const url = new URL(req.url, `http://${req.headers.host}`);const limit = Math.min(Math.max(1, Number(url.searchParams.get('limit') || 50)), 200);const kinds = url.searchParams.get('kinds') || null;- const { getMints, getWhales, getClaims } = await import('../_lib/channel-feed-sources.js');+ // `signal` is one of the four kinds buildFeed knows and the only one that+ // carries agent attribution (which agent earned the reputation event, and how+ // much it weighed). Leaving it out of the fan-out published a feed that could+ // never answer ?kinds=signal, so the whole agent-attributed lane was invisible.+ const { getMints, getWhales, getClaims, getSignals } = await import(+ '../_lib/channel-feed-sources.js'+ );const { buildFeed } = await import('../../src/pump/channel-feed.js');- const [mints, whales, claims] = await Promise.all([- getMints(limit),- getWhales(limit),- getClaims(limit),+ // buildFeed filters by kind after the fact; skipping the unrequested reads+ // here keeps ?kinds=mint to one query instead of four. It ignores a `kinds`+ // naming nothing valid and serves everything, so this must too, or the two+ // halves disagree and a typo'd filter returns an empty feed.+ const ALL_KINDS = ['mint', 'whale', 'claim', 'signal'];+ const named = kinds+ ? kinds.split(',').map((k) => k.trim()).filter((k) => ALL_KINDS.includes(k))+ : [];+ const requested = named.length ? new Set(named) : null;+ const wants = (kind) => !requested || requested.has(kind);+ const [mints, whales, claims, signals] = await Promise.all([+ wants('mint') ? getMints(limit) : [],+ wants('whale') ? getWhales(limit) : [],+ wants('claim') ? getClaims(limit) : [],+ wants('signal') ? getSignals(limit) : [],]);const items = buildFeed([{ kind: 'mint', items: mints },{ kind: 'whale', items: whales },{ kind: 'claim', items: claims },+ { kind: 'signal', items: signals },],{ limit, kinds },);@@ -3741,6 +3759,11 @@ async function handleDeliverTelegram(req, res) {if (!method(req, res, ['POST'])) return;const auth = await resolveAuth(req);if (!auth) return error(res, 401, 'unauthorized', 'sign in required');+ // This speaks under the platform's verified bot identity, so an authenticated+ // caller still gets a per-IP ceiling: without one, a single account turns the+ // bot into a spam/phishing relay one POST at a time.+ const rl = await limits.authIp(clientIp(req));+ if (!rl.success) return rateLimited(res, rl, 'too many delivery requests');const botToken = process.env.TELEGRAM_BOT_TOKEN;if (!botToken) return error(res, 500, 'misconfigured', 'TELEGRAM_BOT_TOKEN is not set');const raw = await readJson(req);diff --git a/api/pump/channel-feed.js b/api/pump/channel-feed.jsdeleted file mode 100644index 2fae21b1b..000000000--- a/api/pump/channel-feed.js+++ /dev/null@@ -1,43 +0,0 @@-import { cors, json, method, wrap, rateLimited } from '../_lib/http.js';-import { limits, clientIp } from '../_lib/rate-limit.js';-import { getMints, getWhales, getClaims, getSignals } from '../_lib/channel-feed-sources.js';--export default wrap(async (req, res) => {- if (cors(req, res, { methods: 'GET,OPTIONS' })) return;- if (!method(req, res, ['GET'])) return;-- const rl = await limits.mcpIp(clientIp(req));- if (!rl.success) return rateLimited(res, rl);-- const url = new URL(req.url, 'http://x');- const kindsParam = url.searchParams.get('kinds');- const allowed = kindsParam ? new Set(kindsParam.split(',').map(s => s.trim())) : null;- const limitParam = url.searchParams.get('limit');- const limitRaw = limitParam ? parseInt(limitParam, 10) : 100;- const limit = Math.min(Math.max(Number.isFinite(limitRaw) ? limitRaw : 100, 1), 200);-- const [mints, whales, claims, signals] = await Promise.all([- (!allowed || allowed.has('mint')) ? getMints().catch(() => []) : [],- (!allowed || allowed.has('whale')) ? getWhales().catch(() => []) : [],- (!allowed || allowed.has('claim')) ? getClaims().catch(() => []) : [],- (!allowed || allowed.has('signal')) ? getSignals().catch(() => []) : [],- ]);-- const seen = new Set();- const all = [- ...mints.map(e => ({ ...e, kind: 'mint' })),- ...whales.map(e => ({ ...e, kind: 'whale' })),- ...claims.map(e => ({ ...e, kind: 'claim', signature: e.signature || e.tx_signature })),- ...signals.map(e => ({ ...e, kind: 'signal' })),- ]- .filter(e => {- const sig = e.signature || e.tx_signature;- if (!sig || seen.has(sig)) return false;- seen.add(sig);- return true;- })- .sort((a, b) => (b.timestamp || 0) - (a.timestamp || 0))- .slice(0, limit);-- return json(res, 200, { items: all });-});diff --git a/api/pump/deliver-telegram.js b/api/pump/deliver-telegram.jsdeleted file mode 100644index cf462acd5..000000000--- a/api/pump/deliver-telegram.js+++ /dev/null@@ -1,84 +0,0 @@-// POST /api/pump/deliver-telegram-//-// Pushes a single pump.fun signal to a Telegram chat via the platform bot.-// This drives the verified platform bot identity, so it is gated behind an-// authenticated session OR a valid bearer token and rate-limited per-IP —-// without that, anyone on the internet could turn the bot into a spam/phishing-// relay (a direct server-to-server POST is not subject to browser CORS).--import { cors, error, json, method, readJson, wrap, rateLimited } from '../_lib/http.js';-import { getSessionUser, authenticateBearer, extractBearer } from '../_lib/auth.js';-import { limits, clientIp } from '../_lib/rate-limit.js';-import { z } from 'zod';-import { parse } from '../_lib/validate.js';--const deliverSchema = z.object({- chatId: z.union([z.string().min(1).max(64), z.number().int()]),- signal: z.object({- kind: z.enum(['mint', 'whale', 'claim', 'graduation']),- mint: z.string().max(64).optional().default(''),- summary: z.string().max(2000).optional().default(''),- ts: z.number().optional(),- }),-});--// Escape text for Telegram's legacy `Markdown` parse_mode so attacker-supplied-// summary/mint text can't inject markup or break out of the formatting (and so-// it can't smuggle clickable links under the bot's identity). Legacy Markdown-// treats _ * ` [ as control characters.-function escapeMarkdown(text) {- return String(text).replace(/[_*`[]/g, '\\$&');-}--function formatSignal(signal) {- const time = signal.ts ? new Date(signal.ts).toUTCString() : '';- const kind = escapeMarkdown((signal.kind || 'signal').toUpperCase());- const mint = escapeMarkdown(signal.mint || '');- const summary = escapeMarkdown(signal.summary || '');- return `*${kind}* — \`${mint}\`\n${summary}\n${escapeMarkdown(time)}`;-}--export default wrap(async (req, res) => {- if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;- if (!method(req, res, ['POST'])) return;-- // Authenticate: a signed-in session or a valid bearer token. This bot speaks- // under the platform's verified identity — never let an anonymous caller- // drive it.- let authed = false;- try {- const session = await getSessionUser(req);- if (session) authed = true;- } catch { /* fall through to bearer */ }- if (!authed) {- const token = extractBearer(req);- if (token) {- const bearer = await authenticateBearer(token).catch(() => null);- if (bearer) authed = true;- }- }- if (!authed) return error(res, 401, 'unauthorized', 'sign in or provide a valid bearer token');-- const rl = await limits.authIp(clientIp(req));- if (!rl.success) return rateLimited(res, rl, 'too many delivery requests');-- const token = process.env.TELEGRAM_BOT_TOKEN;- if (!token) return error(res, 500, 'misconfigured', 'TELEGRAM_BOT_TOKEN is not set');-- const body = await readJson(req).catch(() => null);- if (!body) return error(res, 400, 'validation_error', 'JSON body required');- const { chatId, signal } = parse(deliverSchema, body);-- const text = formatSignal(signal);- const r = await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {- method: 'POST',- headers: { 'content-type': 'application/json' },- body: JSON.stringify({ chat_id: chatId, parse_mode: 'Markdown', text }),- signal: AbortSignal.timeout(10000),- });-- const data = await r.json().catch(() => ({}));- if (!r.ok) return error(res, 502, 'telegram_error', data.description || `HTTP ${r.status}`);-- return json(res, 200, { ok: true, messageId: data.result?.message_id });-});