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
// POST /api/social/sentiment-pulse
//
// One-call sentiment pulse for a Solana token. Pulls the coin's live
// community commentary from pump.fun and scores it with the in-repo lexicon
// scorer. Optionally accepts a list of additional text snippets to fold into
// the score (e.g. X posts the caller has already collected).
//
// Source note: pump.fun retired the `/replies/:mint` comments route this
// endpoint used to read (it now 404s for every mint, including $THREE), so
// the pulse silently scored an empty set and reported a confident neutral
// reading. Coin commentary lives in "callouts" now, the feed the coin page
// renders via frontend-api-v3 `/callout/coin/:mint` (the earlier
// `/callout/top/:mint` route was removed upstream in 2026-10), where each
// entry carries the poster's thesis and timestamp. That is the source below,
// read through api/_lib/pump-callouts.js and the shared pump.fun fetch helper
// (identified user-agent, bounded timeout, one retry on a rate limit or 5xx).
//
// This is the unauthenticated, no-key endpoint behind the paid
// `sentiment_pulse` MCP tool. The pump.fun read itself is cached with a
// last-known-good tier (api/_lib/pump-callouts.js, via cacheWrapLastGood):
// a prior successful fetch for the same mint+limit survives a Cloudflare
// block and is served stale (`sources.pumpfunStatus: 'stale'`) rather than
// erroring. Callers who already have the texts should still hit
// /api/social/sentiment instead.
//
// Body:
// {
// token: string, // Solana SPL or pump.fun mint pubkey
// limit?: number, // max callouts to score (default 100, max 200;
// // pump.fun serves at most 100 per read)
// extraTexts?: string[], // additional snippets to score
// }
//
// Response:
// {
// ok: true,
// token,
// overall: { score, posPct, negPct, neuPct, count, examples },
// breakdown: { pumpfun: <result>, extra: <result> },
// sources: { pumpfun: 'https://...', pumpfunStatus, pumpfunCount, extraCount },
// fetchedAt
// }
//
// A pump.fun outage with no caller-supplied texts answers 502
// `upstream_unavailable`, never a fabricated neutral score, UNLESS a
// last-known-good copy of that mint+limit survives, in which case the stale
// copy is served (sources.pumpfunStatus: 'stale') and only a true double
// miss (upstream down AND no cached copy yet) still 502s. A coin that is
// simply quiet (upstream fine, zero callouts) still answers 200 with
// `count: 0`, because an empty feed is data, not an outage.
import { z } from 'zod';
import { cors, error, json, method, readJson, wrap, rateLimited } from '../_lib/http.js';
import { limits, clientIp } from '../_lib/rate-limit.js';
import { calloutsToPosts, fetchPumpFunCallouts } from '../_lib/pump-callouts.js';
const SOLANA_MINT_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
const bodySchema = z.object({
token: z.string().regex(SOLANA_MINT_RE, 'token must be a base58 Solana mint pubkey'),
limit: z.number().int().min(1).max(200).optional(),
extraTexts: z.array(z.string().max(2000)).max(200).optional(),
});
export { calloutsToPosts };
export default wrap(async (req, res) => {
if (cors(req, res, { methods: 'POST,OPTIONS', credentials: false })) return;
if (!method(req, res, ['POST'])) return;
const rl = await limits.mcpIp(clientIp(req));
if (!rl.success) return rateLimited(res, rl);
let raw;
try {
raw = await readJson(req);
} catch {
return error(res, 400, 'validation_error', 'invalid json');
}
const parsed = bodySchema.safeParse(raw);
if (!parsed.success) {
return error(res, 400, 'validation_error', parsed.error.issues[0]?.message ?? 'invalid body');
}
const { token, limit = 100, extraTexts = [] } = parsed.data;
const { scoreSentiment } = await import('../../src/social/sentiment.js');
const pumpfun = await fetchPumpFunCallouts(token, limit);
const pumpfunPosts = pumpfun.error ? [] : pumpfun.posts;
const extraPosts = extraTexts
.map((t, i) => ({ id: `extra-${i}`, text: String(t).trim() }))
.filter((p) => p.text);
// With the only live source down and nothing supplied by the caller there
// is nothing to score. Scoring the empty set would answer "neutral, 100%"
// with the same confidence as a real reading, so report the outage.
if (pumpfun.error && extraPosts.length === 0) {
return error(res, 502, 'upstream_unavailable', pumpfun.error, {
token,
source: 'pump.fun',
});
}
const all = [...pumpfunPosts, ...extraPosts];
const overall = scoreSentiment(all);
const breakdown = {
pumpfun: pumpfun.error ? { error: pumpfun.error, count: 0 } : scoreSentiment(pumpfunPosts),
extra: scoreSentiment(extraPosts),
};
return json(res, 200, {
ok: true,
token,
overall,
breakdown,
sources: {
pumpfun: pumpfun.error ? null : pumpfun.url,
pumpfunStatus: pumpfun.error ? 'unavailable' : pumpfun.stale ? 'stale' : 'ok',
pumpfunCount: pumpfunPosts.length,
extraCount: extraPosts.length,
},
fetchedAt: new Date().toISOString(),
});
});