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.

feat(api): image proxy endpoint, rate-limit + mcp-server resilience hardening

nirholasaafcdcbfd146
diff --git a/agent-payments-sdk/package.json b/agent-payments-sdk/package.json
index faae267bf..e90cdbfbf 100644
--- a/agent-payments-sdk/package.json
+++ b/agent-payments-sdk/package.json
@@ -91,6 +91,7 @@
},
"devDependencies": {
"@eslint/js": "^9.17.0",
+ "@pump-fun/agent-payments-sdk-legacy": "npm:@pump-fun/[email protected]",
"@types/bn.js": "^5.2.0",
"@types/express": "^5.0.6",
"@types/jest": "^30.0.0",
diff --git a/agent-payments-sdk/src/solana/legacy-agent-payments/__tests__/pdas.test.ts b/agent-payments-sdk/src/solana/legacy-agent-payments/__tests__/pdas.test.ts
index 299246bcd..f0c397a33 100644
--- a/agent-payments-sdk/src/solana/legacy-agent-payments/__tests__/pdas.test.ts
+++ b/agent-payments-sdk/src/solana/legacy-agent-payments/__tests__/pdas.test.ts
@@ -25,9 +25,11 @@ import {
getWithdrawAuthorityPDA,
} from "../pdas.js";
-// 1.0.7 reference bundle (CommonJS).
+// 1.0.7 reference bundle, pinned explicitly via npm alias so this parity check
+// is deterministic and independent of which version the bare
+// `@pump-fun/agent-payments-sdk` specifier resolves to elsewhere in the repo.
// eslint-disable-next-line @typescript-eslint/no-require-imports
-import * as ref from "@pump-fun/agent-payments-sdk";
+import * as ref from "@pump-fun/agent-payments-sdk-legacy";
const TEST_MINT = new PublicKey("11111111111111111111111111111112");
const TEST_CURRENCY = new PublicKey(
diff --git a/api/_lib/rate-limit.js b/api/_lib/rate-limit.js
index 521d5548c..726a43e2b 100644
--- a/api/_lib/rate-limit.js
+++ b/api/_lib/rate-limit.js
@@ -163,6 +163,10 @@ export const limits = {
// `authIp` budget shared by on-chain buy/sell/launch actions. Iterating in
// the launch wizard would otherwise lock the user out of trading for 10 min.
pumpMetaIp: (ip) => getLimiter('pump:meta:ip', { limit: 60, window: '10 m' }).limit(ip),
+ // Same-origin image proxy (api/img). A token-cloud view loads dozens of
+ // thumbnails at once, so the ceiling is generous — but bounded so the proxy
+ // can't be turned into an open bandwidth relay. Responses are CDN-cached.
+ imgProxyIp: (ip) => getLimiter('img:ip', { limit: 300, window: '5 m' }).limit(ip),
// Live holder-cohort reads (api/coin/:mint/cohorts for un-snapshotted agent
// tokens) fan out to a paid Helius getTokenAccounts walk. Responses are CDN-
// cached, so this only gates cache-miss origin hits — generous for an
diff --git a/api/a-page.js b/api/a-page.js
index 19f8cee60..922912f7d 100644
--- a/api/a-page.js
+++ b/api/a-page.js
@@ -29,11 +29,15 @@ export default wrap(async (req, res) => {
const agent = await resolveOnChainAgent({ chainId, agentId });
- // Hard 404 only when the on-chain read itself failed (token likely doesn't
- // exist). Manifest fetch failures still render a card so the link shares.
- if (agent.error && agent.error.startsWith('chain_read')) {
- return notFound(res, `Agent #${agentId} not found on ${agent.chainName}`);
- }
+ // A `chain_read` error is ambiguous: it fires both for a genuinely
+ // nonexistent token (ERC-721 reverts on tokenURI) AND for a transient RPC
+ // read failure. We must NOT hard-404 the second case — the SPA viewer
+ // resolves the agent client-side and renders fine, so a server-side RPC
+ // hiccup would otherwise turn a working agent into a dead 404. Instead we
+ // degrade: render the card with fallback metadata, mark it `noindex` so a
+ // truly-phantom agent never pollutes search, and let the inline script send
+ // real browsers on to the viewer. Crawlers get a shareable (un-indexed) card.
+ const unverified = !!(agent.error && agent.error.startsWith('chain_read'));
const origin = env.APP_ORIGIN;
const pageUrl = `${origin}/a/${chainId}/${agentId}`;
@@ -60,6 +64,7 @@ export default wrap(async (req, res) => {
chainId,
agentId,
ownerShort,
+ noindex: unverified,
pageUrl,
embedUrl,
viewerUrl,
@@ -95,7 +100,7 @@ function renderHtml(p) {
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<meta name="description" content="${d}">
<meta name="theme-color" content="#0a0a0a">
-
+${p.noindex ? '\t<meta name="robots" content="noindex, nofollow">\n' : ''}
<meta property="og:type" content="profile">
<meta property="og:site_name" content="three.ws">
<meta property="og:title" content="${t}">
diff --git a/api/img.js b/api/img.js
new file mode 100644
index 000000000..3a4bc0f80
--- /dev/null
+++ b/api/img.js
@@ -0,0 +1,104 @@
+// Same-origin image proxy with IPFS multi-gateway fallback.
+//
+// Token art on /pump-visualizer (and any 3D surface that textures remote
+// images) is loaded by Three.js with `crossOrigin = 'anonymous'`. The public
+// IPFS gateways and metadata hosts these images live on (ipfs.io, arweave,
+// per-launch CDNs) frequently answer browser requests with no
+// `Access-Control-Allow-Origin` header, or get blocked by the browser's Opaque
+// Response Blocking (ORB) — so the texture fails and the console fills with CORS
+// / ERR_BLOCKED_BY_ORB errors, one per token.
+//
+// Routing the image through this same-origin endpoint removes the cross-origin
+// problem entirely: the browser only ever talks to three.ws. Server-side we:
+// 1. Fetch the upstream image through the SSRF-hardened fetcher (scheme
+// allowlist, our-side DNS + private-IP blocklist, connection pinning,
+// per-redirect re-validation, byte cap, timeout) — see api/_lib/ssrf.js.
+// 2. If the source is an IPFS URL that fails, retry across alternate public
+// gateways so one slow gateway never blanks the art.
+// 3. On total failure, 302 to a deterministic dicebear placeholder (which
+// serves permissive CORS) so the loader ALWAYS receives a valid 200 image
+// and never logs an error.
+//
+// Responses are immutable and CDN-cached: a given upstream URL yields the same
+// bytes forever, so we cache hard at the edge and the proxy is hit once per art.
+
+import { wrap, cors, method, error, redirect, rateLimited } from './_lib/http.js';
+import { limits, clientIp } from './_lib/rate-limit.js';
+import { fetchModel } from './_lib/fetch-model.js';
+
+const MAX_BYTES = 8 * 1024 * 1024; // 8 MB — generous for token art, bounded for abuse
+const TIMEOUT_MS = 10_000;
+
+// Public IPFS gateways tried in order. ipfs.io is the canonical resolver the
+// rest of the platform pins to (api/_lib/onchain.js), but it is also the one
+// most likely to ORB-block or stall, so we fan out to mirrors on failure.
+const IPFS_GATEWAYS = [
+ 'https://ipfs.io/ipfs/',
+ 'https://cloudflare-ipfs.com/ipfs/',
+ 'https://gateway.pinata.cloud/ipfs/',
+ 'https://dweb.link/ipfs/',
+];
+
+// Pull the `<cid>/<path?>` portion out of any recognised IPFS URL form so we can
+// re-point it at a different gateway. Returns null for non-IPFS URLs.
+function ipfsPath(rawUrl) {
+ if (rawUrl.startsWith('ipfs://')) return rawUrl.slice('ipfs://'.length).replace(/^ipfs\//, '');
+ const m = rawUrl.match(/\/ipfs\/(.+)$/);
+ return m ? m[1] : null;
+}
+
+// Build the ordered list of candidate URLs to try for one logical image.
+function candidates(rawUrl) {
+ const path = ipfsPath(rawUrl);
+ if (path) return IPFS_GATEWAYS.map((g) => g + path);
+ // Non-IPFS: a single source (already an https CDN / arweave / data: link).
+ return [rawUrl.startsWith('ipfs://') ? IPFS_GATEWAYS[0] + rawUrl.slice(7) : rawUrl];
+}
+
+function placeholder(seed) {
+ const s = encodeURIComponent(seed || 'token');
+ return `https://api.dicebear.com/7.x/shapes/png?seed=${s}`;
+}
+
+export default wrap(async function handler(req, res) {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: false })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const ip = clientIp(req);
+ const rl = await limits.imgProxyIp(ip);
+ if (!rl.success) return rateLimited(res, rl, 'too many image requests');
+
+ const url = new URL(req.url, 'http://x');
+ const target = url.searchParams.get('url');
+ const seed = url.searchParams.get('seed') || target || '';
+ if (!target) return error(res, 400, 'missing_url', 'url query parameter is required');
+
+ // data: URIs are already inline and same-origin-safe — nothing to proxy.
+ if (target.startsWith('data:')) return redirect(res, target, 302);
+
+ let image = null;
+ for (const candidate of candidates(target)) {
+ try {
+ const result = await fetchModel(candidate, { maxBytes: MAX_BYTES, timeoutMs: TIMEOUT_MS });
+ if (!result.contentType.startsWith('image/')) continue; // HTML error page etc. — try next
+ image = result;
+ break;
+ } catch {
+ // SSRF refusal, timeout, gateway 5xx — fall through to the next candidate.
+ }
+ }
+
+ if (!image) {
+ // Every source failed. Hand back a valid, CORS-clean placeholder so the
+ // texture/image loader resolves with a 200 instead of logging an error.
+ return redirect(res, placeholder(seed), 302);
+ }
+
+ res.statusCode = 200;
+ res.setHeader('content-type', image.contentType);
+ res.setHeader('access-control-allow-origin', '*');
+ // Immutable: a given upstream URL is content-addressed (IPFS) or a fixed CDN
+ // asset, so the bytes never change. Cache hard at the browser and the edge.
+ res.setHeader('cache-control', 'public, max-age=86400, s-maxage=604800, immutable');
+ res.end(Buffer.from(image.bytes));
+});
diff --git a/api/solana-rpc.js b/api/solana-rpc.js
index 46264154e..901ea69f9 100644
--- a/api/solana-rpc.js
+++ b/api/solana-rpc.js
@@ -43,6 +43,8 @@ const ALLOWED_METHODS = new Set([
'getTokenAccountBalance',
'getTokenAccountsByOwner',
'getTokenSupply',
+ // Inherently bounded — returns at most the top 20 holders of one mint.
+ 'getTokenLargestAccounts',
'getEpochInfo',
'getSlot',
'getBlockHeight',
@@ -51,6 +53,18 @@ const ALLOWED_METHODS = new Set([
'getVersion',
]);
+// getProgramAccounts is an unbounded scan in the general case — the prime
+// vector for draining the keyed upstream — so it is NOT in ALLOWED_METHODS.
+// We permit it ONLY when the caller supplies a `filters` array that bounds the
+// result set (e.g. a memcmp on a specific mint, as the pump dashboard's bonding
+// curve probe does). A filtered, slice-limited query is cheap; a bare scan is
+// still refused.
+function isBoundedProgramScan(entry) {
+ if (entry.method !== 'getProgramAccounts') return false;
+ const opts = Array.isArray(entry.params) ? entry.params[1] : null;
+ return !!(opts && Array.isArray(opts.filters) && opts.filters.length > 0);
+}
+
// Cap batch requests so a single POST can't fan out into hundreds of upstream
// calls and sidestep the per-request rate limit.
const MAX_BATCH = 10;
@@ -71,7 +85,10 @@ function rejectReason(body) {
for (const e of entries) {
if (!e || typeof e !== 'object') return 'malformed_request';
if (typeof e.method !== 'string') return 'malformed_request';
- if (!ALLOWED_METHODS.has(e.method)) return 'method_not_allowed';
+ if (ALLOWED_METHODS.has(e.method)) continue;
+ if (isBoundedProgramScan(e)) continue; // filtered getProgramAccounts is allowed
+ if (e.method === 'getProgramAccounts') return 'unbounded_scan';
+ return 'method_not_allowed';
}
return null;
}
@@ -101,10 +118,13 @@ export default wrap(async function handler(req, res) {
const msg =
reason === 'method_not_allowed'
? 'this RPC method is not permitted through the proxy'
- : reason === 'batch_too_large'
- ? `batch exceeds ${MAX_BATCH} requests`
- : 'malformed JSON-RPC request';
- return error(res, reason === 'method_not_allowed' ? 403 : 400, reason, msg);
+ : reason === 'unbounded_scan'
+ ? 'getProgramAccounts requires a bounding `filters` array through this proxy'
+ : reason === 'batch_too_large'
+ ? `batch exceeds ${MAX_BATCH} requests`
+ : 'malformed JSON-RPC request';
+ const status = reason === 'method_not_allowed' || reason === 'unbounded_scan' ? 403 : 400;
+ return error(res, status, reason, msg);
}
let upstream;
diff --git a/api/watsonx/embed.js b/api/watsonx/embed.js
index 220147147..9838ce79c 100644
--- a/api/watsonx/embed.js
+++ b/api/watsonx/embed.js
@@ -9,15 +9,23 @@
// lay them out in semantic space (e.g. the watsonx Constellation at
// /constellation). Inference runs on watsonx.ai with the server's IBM Cloud key.
//
-// There is no mock path. When watsonx is unconfigured the endpoint returns 503
-// `watsonx_unconfigured` so the client can show an honest "not configured" state
-// instead of inventing vectors. Every successful vector is a real Granite call.
+// There is no mock path — every vector is a real embedding call. The provider
+// chain degrades gracefully so a watsonx outage never blanks the page:
+// 1. IBM Granite on watsonx.ai (primary, when WATSONX_* is configured)
+// 2. OpenAI text-embedding-3-small (fallback, when OPENAI_API_KEY is set)
+// 3. 503 `embed_unconfigured` only when NEITHER provider is available, so the
+// client can show an honest "not configured" state instead of inventing
+// vectors. Within a single response all vectors come from one provider, so
+// `dimensions` is uniform regardless of which tier served the request.
import { createHash } from 'node:crypto';
import { cors, method, readJson, error, json, wrap, rateLimited } from '../_lib/http.js';
import { watsonxConfig, watsonxEmbed } from '../_lib/watsonx.js';
+import { embed as openaiEmbed, embeddingsConfigured } from '../_lib/embeddings.js';
import { limits, clientIp } from '../_lib/rate-limit.js';
+const OPENAI_EMBED_MODEL = 'text-embedding-3-small';
+
// watsonx accepts many inputs per call; cap a single request so one caller can't
// submit an unbounded batch. Matches the chunk size used by agent-embeddings.
const MAX_TEXTS = 96;
@@ -99,18 +107,76 @@ export default wrap(async function handler(req, res) {
}
const cfg = watsonxConfig();
- if (!cfg.configured) {
- // No fabricated vectors. Tell the client exactly what's missing so the UI
- // can render a real "IBM watsonx not configured" state.
- return error(res, 503, 'watsonx_unconfigured',
- 'IBM watsonx is not configured. Set WATSONX_API_KEY and WATSONX_PROJECT_ID to enable Granite embeddings.');
+ const openaiReady = embeddingsConfigured();
+ if (!cfg.configured && !openaiReady) {
+ // No provider at all. No fabricated vectors — tell the client exactly
+ // what's missing so the UI can render an honest "not configured" state.
+ return error(res, 503, 'embed_unconfigured',
+ 'No embedding provider is configured. Set WATSONX_API_KEY + WATSONX_PROJECT_ID (IBM Granite) or OPENAI_API_KEY (fallback) to enable embeddings.');
+ }
+
+ // Provider chain: Granite (primary) → OpenAI (fallback). The first provider
+ // that returns a full batch wins; a watsonx outage transparently falls
+ // through so /constellation keeps rendering.
+ let result = null;
+ let lastError = null;
+
+ if (cfg.configured) {
+ const model = typeof body.model === 'string' && body.model.trim()
+ ? body.model.trim()
+ : cfg.embedModel;
+ try {
+ result = await embedBatch(texts, model, (inputs) =>
+ watsonxEmbed(cfg, { inputs, model }).then((r) => ({
+ vectors: r.vectors,
+ dimensions: r.dimensions,
+ })),
+ );
+ } catch (e) {
+ // Hold the cause; if OpenAI can cover we still serve a 200.
+ lastError = e;
+ }
}
- const model = typeof body.model === 'string' && body.model.trim()
- ? body.model.trim()
- : cfg.embedModel;
+ if (!result && openaiReady) {
+ try {
+ result = await embedBatch(texts, OPENAI_EMBED_MODEL, async (inputs) => {
+ const vecs = await openaiEmbed(inputs);
+ return {
+ vectors: vecs.map((v) => Array.from(v)),
+ dimensions: vecs[0]?.length ?? 0,
+ };
+ });
+ } catch (e) {
+ lastError = e;
+ }
+ }
+
+ if (!result) {
+ // Both tiers failed at the network level — surface the real upstream cause.
+ return error(res, 502, 'embed_error', lastError?.message || 'embeddings failed');
+ }
+
+ // json() defaults to no-store, which is correct here: this is a POST whose
+ // body varies per request, so it must not be shared-cached. Determinism is
+ // exploited by the process-local `cache` above, not by HTTP caches.
+ return json(res, 200, {
+ model: result.model,
+ dimensions: result.dimensions,
+ count: result.vectors.length,
+ cachedHits: result.cachedHits,
+ vectors: result.vectors,
+ });
+});
- // Resolve from cache first; only the genuinely-uncached texts hit watsonx.
+/**
+ * Embed `texts` with a single provider, reusing the process-local cache for
+ * already-seen (model, text) pairs so repeat lookups cost nothing. `fetcher`
+ * receives the genuinely-uncached inputs and returns { vectors, dimensions }.
+ * Caching is keyed by model, so Granite and OpenAI vectors never mix — every
+ * returned batch is uniform in dimensionality.
+ */
+async function embedBatch(texts, model, fetcher) {
const vectors = new Array(texts.length).fill(null);
const missIdx = [];
const missText = [];
@@ -123,30 +189,15 @@ export default wrap(async function handler(req, res) {
let dimensions = vectors.find((v) => v)?.length ?? 0;
if (missText.length) {
- let result;
- try {
- result = await watsonxEmbed(cfg, { inputs: missText, model });
- } catch (e) {
- // Surface the real upstream cause (auth, quota, unsupported model).
- return error(res, 502, 'watsonx_error', e.message || 'watsonx embeddings failed');
- }
- dimensions = result.dimensions || dimensions;
+ const fetched = await fetcher(missText);
+ dimensions = fetched.dimensions || dimensions;
for (let k = 0; k < missIdx.length; k++) {
- const vec = result.vectors[k];
+ const vec = fetched.vectors[k];
if (!vec?.length) continue;
vectors[missIdx[k]] = vec;
cacheSet(cacheKey(model, missText[k]), vec);
}
}
- // json() defaults to no-store, which is correct here: this is a POST whose
- // body varies per request, so it must not be shared-cached. Determinism is
- // exploited by the process-local `cache` above, not by HTTP caches.
- return json(res, 200, {
- model,
- dimensions,
- count: vectors.length,
- cachedHits: texts.length - missText.length,
- vectors,
- });
-});
+ return { model, dimensions, vectors, cachedHits: texts.length - missText.length };
+}
diff --git a/mcp-server/README.md b/mcp-server/README.md
index 1e1190fe2..12a00b1b2 100644
--- a/mcp-server/README.md
+++ b/mcp-server/README.md
@@ -69,13 +69,16 @@ Then replace `"command": "npx", "args": ["-y", "@3d-agent/mcp-server"]` with `"c
| Var | Default | Description |
|-----|---------|-------------|
| `HELIUS_API_KEY` | unset | Adds Helius DAS enrichment to `pump_snapshot` |
-| `SOLANA_RPC_URL` | `https://api.mainnet-beta.solana.com` | Solana RPC endpoint for `pump_snapshot` and `vanity_grinder` |
-| `X402_FACILITATOR_URL_SOLANA` | `https://facilitator.payai.network` | PayAI Solana facilitator that verifies + settles payments |
+| `SOLANA_RPC_URL` | `https://api.mainnet-beta.solana.com` | Primary Solana RPC for `pump_snapshot` / AgenC reads |
+| `SOLANA_RPC_URLS` | built-in public set | **Failover** — comma-separated Solana RPCs tried in order; first healthy one answers |
+| `MCP_EVM_RPC_<chainId>` | built-in public set | **Failover** — comma-separated EVM RPCs for that chain (`agent_reputation`, ENS uses chain 1) |
+| `X402_FACILITATOR_URL_SOLANA` | `https://facilitator.payai.network` | Primary PayAI Solana facilitator that verifies + settles payments |
+| `X402_FACILITATOR_URLS_SOLANA` | unset | **Failover** — comma-separated facilitators; earlier entries take precedence at init, a later one covers an outage |
| `X402_FACILITATOR_TOKEN_SOLANA` | unset | Bearer token for the Solana facilitator, if required |
| `X402_FEE_PAYER_SOLANA` | three.ws default | Fee payer for the settlement transaction |
| `MCP_VANITY_PRICE_USD` | `$0.05` | Flat price for `vanity_grinder` |
| `MCP_POSE_PREVIEW_BASE` | `https://three.ws/pose` | Base URL for `get_pose_seed` preview links |
-| `MCP_AGENT_REP_RPC_<chainId>` | public RPC | Per-chain RPC override for `agent_reputation` |
+| `MCP_AGENT_REP_RPC_<chainId>` | public RPC | Per-chain RPC override for `agent_reputation` (tried before the failover set) |
| `MCP_AGENT_REP_LOG_WINDOW` | `200000` | Block window for `agent_reputation` event scan |
---
@@ -184,6 +187,26 @@ A successful result carries the tool's JSON in two forms: `content[0].text` (for
---
+## Reliability & failover
+
+Every external dependency has a backup path, so a single provider blip doesn't take a tool down — and no call can hang a paid request indefinitely.
+
+- **Every outbound HTTP call** runs through a shared resilient layer (`src/lib/resilient-fetch.js`): a hard per-attempt timeout plus jittered exponential-backoff retries on transient `429`/`5xx`/network errors, honoring `Retry-After`. Retries are restricted to idempotent reads by default — a non-idempotent action like `agent_delegate_action` gets the timeout but is **never** silently replayed.
+- **Solana RPC** (`src/lib/solana-rpc.js`) fails over across an ordered endpoint list (`SOLANA_RPC_URLS`, else the primary, else a built-in public set). A throttling or down endpoint rotates to the back and the next one answers.
+- **EVM RPC** (`src/lib/evm-rpc.js`) uses an ethers `FallbackProvider` (quorum 1) over multiple endpoints per chain (`MCP_EVM_RPC_<chainId>` or built-in redundancy), each request timeout-bounded.
+- **The x402 facilitator** accepts a comma-separated `X402_FACILITATOR_URLS_SOLANA`: earlier entries take precedence at init, and a later facilitator covers the Solana `exact` kind if the primary's `/supported` is unreachable.
+- **Data fallback:** `pump_snapshot` cross-fills its USD price from Dexscreener when Jupiter is unavailable, and each upstream fails soft to a `null`/`{ error }` field rather than failing the whole snapshot.
+
+For maximum redundancy, set dedicated endpoints rather than relying on the public defaults:
+
+```bash
+SOLANA_RPC_URLS="https://your-primary-rpc,https://your-secondary-rpc"
+MCP_EVM_RPC_8453="https://your-base-rpc,https://base-rpc.publicnode.com"
+X402_FACILITATOR_URLS_SOLANA="https://facilitator.payai.network,https://your-backup-facilitator"
+```
+
+---
+
## Architecture
```
diff --git a/mcp-server/src/lib/evm-rpc.js b/mcp-server/src/lib/evm-rpc.js
index 4e20b51be..74972b07a 100644
--- a/mcp-server/src/lib/evm-rpc.js
+++ b/mcp-server/src/lib/evm-rpc.js
@@ -22,13 +22,24 @@ import { FallbackProvider, FetchRequest, JsonRpcProvider, Network } from 'ethers
// single provider outage is survivable out of the box. Operators who need
// guaranteed throughput should pin dedicated endpoints via MCP_EVM_RPC_<id>.
const BUILTIN_RPCS = {
- 1: ['https://eth.llamarpc.com', 'https://ethereum-rpc.publicnode.com', 'https://cloudflare-eth.com'],
- 8453: ['https://mainnet.base.org', 'https://base-rpc.publicnode.com', 'https://base.llamarpc.com'],
+ 1: [
+ 'https://eth.llamarpc.com',
+ 'https://ethereum-rpc.publicnode.com',
+ 'https://cloudflare-eth.com',
+ ],
+ 8453: [
+ 'https://mainnet.base.org',
+ 'https://base-rpc.publicnode.com',
+ 'https://base.llamarpc.com',
+ ],
42161: ['https://arb1.arbitrum.io/rpc', 'https://arbitrum-one-rpc.publicnode.com'],
10: ['https://mainnet.optimism.io', 'https://optimism-rpc.publicnode.com'],
137: ['https://polygon-rpc.com', 'https://polygon-bor-rpc.publicnode.com'],
56: ['https://bsc-dataseed1.binance.org', 'https://bsc-rpc.publicnode.com'],
- 43114: ['https://api.avax.network/ext/bc/C/rpc', 'https://avalanche-c-chain-rpc.publicnode.com'],
+ 43114: [
+ 'https://api.avax.network/ext/bc/C/rpc',
+ 'https://avalanche-c-chain-rpc.publicnode.com',
+ ],
42220: ['https://forno.celo.org'],
59144: ['https://rpc.linea.build'],
534352: ['https://rpc.scroll.io'],
diff --git a/mcp-server/src/payments.js b/mcp-server/src/payments.js
index a20457c49..4c429f5fd 100644
--- a/mcp-server/src/payments.js
+++ b/mcp-server/src/payments.js
@@ -93,7 +93,9 @@ function buildSolanaFacilitators() {
const createAuthHeaders = token
? async () => ({ headers: { Authorization: `Bearer ${token}` } })
: undefined;
- return solanaFacilitatorUrls().map((url) => new HTTPFacilitatorClient({ url, createAuthHeaders }));
+ return solanaFacilitatorUrls().map(
+ (url) => new HTTPFacilitatorClient({ url, createAuthHeaders }),
+ );
}
let resourceServerPromise = null;
@@ -132,7 +134,14 @@ export function getLastFacilitatorInitError() {
// Build the per-tool `accepts` list. Every paid tool settles in USDC on Solana
// mainnet via the `exact` scheme.
-async function buildAcceptsForTool({ resourceServer, scheme, priceUsd, networks, resourceUrl, extra }) {
+async function buildAcceptsForTool({
+ resourceServer,
+ scheme,
+ priceUsd,
+ networks,
+ resourceUrl,
+ extra,
+}) {
const opts = [];
for (const net of networks) {
if (net !== NETWORK_SOLANA_MAINNET) {
@@ -283,8 +292,7 @@ export function paid(cfg, handler) {
export function buildToolResult(result) {
const text = typeof result === 'string' ? result : JSON.stringify(result);
const envelope = { content: [{ type: 'text', text }] };
- const isPlainObject =
- result !== null && typeof result === 'object' && !Array.isArray(result);
+ const isPlainObject = result !== null && typeof result === 'object' && !Array.isArray(result);
if (isPlainObject) {
envelope.structuredContent = result;
if (result.ok === false) {
diff --git a/mcp-server/src/tools/agent-delegate-action.js b/mcp-server/src/tools/agent-delegate-action.js
index db5d7d1b9..da8e12189 100644
--- a/mcp-server/src/tools/agent-delegate-action.js
+++ b/mcp-server/src/tools/agent-delegate-action.js
@@ -36,7 +36,9 @@ const inputZodShape = {
.string()
.min(1)
.max(100)
- .describe('Optional Claude model override (e.g. claude-sonnet-4-6). Must be in the allowlist.')
+ .describe(
+ 'Optional Claude model override (e.g. claude-sonnet-4-6). Must be in the allowlist.',
+ )
.optional(),
};
diff --git a/mcp-server/src/tools/agent-reputation.js b/mcp-server/src/tools/agent-reputation.js
index e6bbffe1e..ba017177a 100644
--- a/mcp-server/src/tools/agent-reputation.js
+++ b/mcp-server/src/tools/agent-reputation.js
@@ -95,7 +95,9 @@ function parseAgentInput(raw, defaultChain) {
if (isAddress(value)) {
return { kind: 'wallet', wallet: value, chain: defaultChain };
}
- throw new Error(`could not parse agent identifier "${value}" — expected uint, EVM wallet, or eip155:<chain>:<addr>`);
+ throw new Error(
+ `could not parse agent identifier "${value}" — expected uint, EVM wallet, or eip155:<chain>:<addr>`,
+ );
}
async function resolveAgentId(provider, wallet) {
@@ -125,7 +127,10 @@ async function readIdentity(provider, agentId) {
async function readReputationAggregate(provider, agentId) {
const rep = new Contract(REPUTATION_REGISTRY_MAINNET, REPUTATION_REGISTRY_ABI, provider);
- const [agg, totalStake] = await Promise.all([rep.getReputation(agentId), rep.getTotalStake(agentId)]);
+ const [agg, totalStake] = await Promise.all([
+ rep.getReputation(agentId),
+ rep.getTotalStake(agentId),
+ ]);
const [totalScore, count] = agg;
const totalScoreNum = Number(totalScore);
const countNum = Number(count);
@@ -170,7 +175,9 @@ async function readRecentEvents(provider, agentId) {
windowBlocks: LOG_WINDOW_BLOCKS,
fromBlock: from,
toBlock: latest,
- events: [...submittedDecoded, ...stakedDecoded].sort((a, b) => b.blockNumber - a.blockNumber).slice(0, 25),
+ events: [...submittedDecoded, ...stakedDecoded]
+ .sort((a, b) => b.blockNumber - a.blockNumber)
+ .slice(0, 25),
};
}
@@ -179,10 +186,14 @@ const inputZodShape = {
address: z
.string()
.min(1)
- .describe('ERC-8004 agentId (uint), EVM wallet address (0x...), or CAIP-10 "eip155:<chainId>:<wallet>".'),
+ .describe(
+ 'ERC-8004 agentId (uint), EVM wallet address (0x...), or CAIP-10 "eip155:<chainId>:<wallet>".',
+ ),
chain: z
.string()
- .describe('Chain to query (default: base). Accepts name or numeric chainId. Overridden by CAIP-10 input.')
+ .describe(
+ 'Chain to query (default: base). Accepts name or numeric chainId. Overridden by CAIP-10 input.',
+ )
.optional(),
};
diff --git a/mcp-server/src/tools/aixbt-intel.js b/mcp-server/src/tools/aixbt-intel.js
index d391b5f76..e0441c725 100644
--- a/mcp-server/src/tools/aixbt-intel.js
+++ b/mcp-server/src/tools/aixbt-intel.js
@@ -32,7 +32,11 @@ const inputZodShape = {
.describe('Max intel items to return (default 20).')
.optional(),
category: z.string().max(64).describe('Filter to a single aixbt intel category.').optional(),
- chain: z.string().max(32).describe('Filter to a chain (e.g. solana, base, ethereum).').optional(),
+ chain: z
+ .string()
+ .max(32)
+ .describe('Filter to a chain (e.g. solana, base, ethereum).')
+ .optional(),
};
const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
diff --git a/mcp-server/src/tools/aixbt-projects.js b/mcp-server/src/tools/aixbt-projects.js
index ee98fbea9..b317dffa2 100644
--- a/mcp-server/src/tools/aixbt-projects.js
+++ b/mcp-server/src/tools/aixbt-projects.js
@@ -36,7 +36,11 @@ const inputZodShape = {
.max(256)
.describe('Comma-separated project names/tickers to filter to.')
.optional(),
- chain: z.string().max(32).describe('Filter to a chain (e.g. solana, base, ethereum).').optional(),
+ chain: z
+ .string()
+ .max(32)
+ .describe('Filter to a chain (e.g. solana, base, ethereum).')
+ .optional(),
};
const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
@@ -57,7 +61,12 @@ export async function buildAixbtProjectsTool() {
ticker: 'THREE',
chain: 'solana',
scores: { spiking: 0.91, climbing: 0.74, active: 0.88 },
- market: { price_usd: 0.00464, market_cap: null, volume_24h: null, change_24h: 45.9 },
+ market: {
+ price_usd: 0.00464,
+ market_cap: null,
+ volume_24h: null,
+ change_24h: 45.9,
+ },
source: 'aixbt',
},
],
diff --git a/mcp-server/src/tools/ens-sns-resolve.js b/mcp-server/src/tools/ens-sns-resolve.js
index 5de425387..344793f30 100644
--- a/mcp-server/src/tools/ens-sns-resolve.js
+++ b/mcp-server/src/tools/ens-sns-resolve.js
@@ -23,7 +23,7 @@ import { makeEvmProvider } from '../lib/evm-rpc.js';
const TOOL_NAME = 'ens_sns_resolve';
const TOOL_DESCRIPTION =
- 'Resolve a human-readable name to addresses across ENS (Ethereum) and SNS (Solana). For .eth: returns Ethereum address via ethers. For .sol: returns Solana owner wallet via Bonfida SNS plus the wallet\'s other owned .sol domains. Names without a suffix are tried against both registries. Paid: $0.0005 USDC.';
+ "Resolve a human-readable name to addresses across ENS (Ethereum) and SNS (Solana). For .eth: returns Ethereum address via ethers. For .sol: returns Solana owner wallet via Bonfida SNS plus the wallet's other owned .sol domains. Names without a suffix are tried against both registries. Paid: $0.0005 USDC.";
const ENS_RE = /^(?:[a-z0-9-]+\.)*[a-z0-9-]+\.eth$/i;
const SOL_RE = /^[a-z0-9-]{1,63}(?:\.sol)?$/i;
@@ -35,7 +35,9 @@ function env(k, def) {
}
async function withTimeout(promise, ms, label) {
- const timeout = new Promise((_, rej) => setTimeout(() => rej(new Error(`${label} timed out after ${ms}ms`)), ms));
+ const timeout = new Promise((_, rej) =>
+ setTimeout(() => rej(new Error(`${label} timed out after ${ms}ms`)), ms),
+ );
return Promise.race([promise, timeout]);
}
@@ -123,7 +125,9 @@ const inputZodShape = {
.string()
.min(1)
.max(253)
- .describe('Name to resolve (e.g. "vitalik.eth", "bonfida.sol", or bare "vitalik" which is tried in both).'),
+ .describe(
+ 'Name to resolve (e.g. "vitalik.eth", "bonfida.sol", or bare "vitalik" which is tried in both).',
+ ),
};
const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
@@ -140,20 +144,38 @@ export async function buildEnsSnsResolveTool() {
outputExample: {
ok: true,
input: 'vitalik.eth',
- ens: { network: 'ethereum', name: 'vitalik.eth', address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', reverseName: 'vitalik.eth' },
+ ens: {
+ network: 'ethereum',
+ name: 'vitalik.eth',
+ address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
+ reverseName: 'vitalik.eth',
+ },
sns: null,
},
},
async ({ name }) => {
- const trimmed = String(name || '').trim().toLowerCase();
+ const trimmed = String(name || '')
+ .trim()
+ .toLowerCase();
const isEns = ENS_RE.test(trimmed);
const isSol = /\.sol$/.test(trimmed) || (!isEns && SOL_RE.test(trimmed));
const tasks = [];
- if (isEns) tasks.push(['ens', resolveEns(trimmed).catch((e) => ({ error: e?.message || 'ens failed' }))]);
- if (isSol) tasks.push(['sns', resolveSns(trimmed).catch((e) => ({ error: e?.message || 'sns failed' }))]);
+ if (isEns)
+ tasks.push([
+ 'ens',
+ resolveEns(trimmed).catch((e) => ({ error: e?.message || 'ens failed' })),
+ ]);
+ if (isSol)
+ tasks.push([
+ 'sns',
+ resolveSns(trimmed).catch((e) => ({ error: e?.message || 'sns failed' })),
+ ]);
if (!isEns && !isSol) {
- return toolError('invalid_name', 'name does not look like a .eth, .sol, or bare label');
+ return toolError(
+ 'invalid_name',
+ 'name does not look like a .eth, .sol, or bare label',
+ );
}
const results = await Promise.all(tasks.map((t) => t[1]));
const out = { ok: false, input: trimmed, ens: null, sns: null };
diff --git a/mcp-server/src/tools/pump-snapshot.js b/mcp-server/src/tools/pump-snapshot.js
index 50bf45bbe..45aacfc3b 100644
--- a/mcp-server/src/tools/pump-snapshot.js
+++ b/mcp-server/src/tools/pump-snapshot.js
@@ -222,7 +222,8 @@ export async function buildPumpSnapshotTool() {
// pair price, surface it rather than leaving price null — two
// independent sources back the single most important field.
const priceUsd = price?.usdPrice ?? ds?.priceUsd ?? null;
- const priceSource = price?.usdPrice != null ? 'jupiter' : ds?.priceUsd != null ? 'dexscreener' : null;
+ const priceSource =
+ price?.usdPrice != null ? 'jupiter' : ds?.priceUsd != null ? 'dexscreener' : null;
return {
token,
fetchedAt: new Date().toISOString(),
diff --git a/mcp-server/src/tools/sentiment-pulse.js b/mcp-server/src/tools/sentiment-pulse.js
index 8d7846647..8478801be 100644
--- a/mcp-server/src/tools/sentiment-pulse.js
+++ b/mcp-server/src/tools/sentiment-pulse.js
@@ -67,7 +67,10 @@ export async function buildSentimentPulseTool() {
},
},
async ({ token, limit, extraTexts }) => {
- const endpoint = env('MCP_SENTIMENT_PULSE_ENDPOINT', 'https://three.ws/api/social/sentiment-pulse');
+ const endpoint = env(
+ 'MCP_SENTIMENT_PULSE_ENDPOINT',
+ 'https://three.ws/api/social/sentiment-pulse',
+ );
let res;
try {
// Read-only scoring computation — safe to retry on a transient blip.
@@ -78,7 +81,12 @@ export async function buildSentimentPulseTool() {
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ token, limit, extraTexts }),
},
- { timeoutMs: 15_000, retries: 2, retryNonIdempotent: true, label: 'sentiment-pulse' },
+ {
+ timeoutMs: 15_000,
+ retries: 2,
+ retryNonIdempotent: true,
+ label: 'sentiment-pulse',
+ },
);
} catch (err) {
return toolError('upstream_unreachable', err?.message || 'fetch failed');
diff --git a/package-lock.json b/package-lock.json
index a86d372a1..f9c104f80 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -178,6 +178,7 @@
},
"devDependencies": {
"@eslint/js": "^9.17.0",
+ "@pump-fun/agent-payments-sdk-legacy": "npm:@pump-fun/[email protected]",
"@types/bn.js": "^5.2.0",
"@types/express": "^5.0.6",
"@types/jest": "^30.0.0",
@@ -15466,6 +15467,81 @@
"@rollup/rollup-linux-x64-gnu": "*"
}
},
+ "node_modules/@pump-fun/agent-payments-sdk-legacy": {
+ "name": "@pump-fun/agent-payments-sdk",
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/@pump-fun/agent-payments-sdk/-/agent-payments-sdk-1.0.7.tgz",
+ "integrity": "sha512-RnYh3GDMTaLvrmu9Hz4W11ulRNQYhrQoOOJyhpMa/wMRuY7ibhoQczcA17R3Zy3fKyhveiLmYI+GKF4pnp2nVg==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "@coral-xyz/anchor": "^0.31.1",
+ "@solana/spl-token": "^0.4.9",
+ "@solana/web3.js": "^1.98.0"
+ },
+ "optionalDependencies": {
+ "@rollup/rollup-linux-x64-gnu": "*"
+ }
+ },
+ "node_modules/@pump-fun/agent-payments-sdk-legacy/node_modules/@coral-xyz/anchor": {
+ "version": "0.31.1",
+ "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.31.1.tgz",
+ "integrity": "sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA==",
+ "dev": true,
+ "license": "(MIT OR Apache-2.0)",
+ "dependencies": {
+ "@coral-xyz/anchor-errors": "^0.31.1",
+ "@coral-xyz/borsh": "^0.31.1",
+ "@noble/hashes": "^1.3.1",
+ "@solana/web3.js": "^1.69.0",
+ "bn.js": "^5.1.2",
+ "bs58": "^4.0.1",
+ "buffer-layout": "^1.2.2",
+ "camelcase": "^6.3.0",
+ "cross-fetch": "^3.1.5",
+ "eventemitter3": "^4.0.7",
+ "pako": "^2.0.3",
+ "superstruct": "^0.15.4",
+ "toml": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=17"
+ }
+ },
+ "node_modules/@pump-fun/agent-payments-sdk-legacy/node_modules/base-x": {
+ "version": "3.0.11",
+ "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.11.tgz",
+ "integrity": "sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "safe-buffer": "^5.0.1"
+ }
+ },
+ "node_modules/@pump-fun/agent-payments-sdk-legacy/node_modules/bs58": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
+ "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "base-x": "^3.0.2"
+ }
+ },
+ "node_modules/@pump-fun/agent-payments-sdk-legacy/node_modules/eventemitter3": {
+ "version": "4.0.7",
+ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
+ "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@pump-fun/agent-payments-sdk-legacy/node_modules/superstruct": {
+ "version": "0.15.5",
+ "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz",
+ "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@pump-fun/agent-payments-sdk/node_modules/@coral-xyz/anchor": {
"version": "0.31.1",
"resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.31.1.tgz",
diff --git a/pages/pump-dashboard.html b/pages/pump-dashboard.html
index c3f7533e0..03d6c61a2 100644
--- a/pages/pump-dashboard.html
+++ b/pages/pump-dashboard.html
@@ -704,7 +704,7 @@
<div class="pd-panel-body">
<div class="pd-form-group">
<label>RPC endpoint <span class="pd-probe" id="pd-probe-rpc"></span></label>
- <input class="pd-input" type="text" id="pd-cfg-rpc-url" value="https://api.mainnet-beta.solana.com" />
+ <input class="pd-input" type="text" id="pd-cfg-rpc-url" value="/api/solana-rpc" placeholder="/api/solana-rpc or your own RPC URL" />
</div>
<div class="pd-form-group">
<label>Commitment level</label>
@@ -867,7 +867,17 @@
apiUrl: localStorage.getItem('pumpbot-api-url') || location.origin,
wsUrl: localStorage.getItem('pumpbot-ws-url') || 'wss://pumpportal.fun/api/data',
apiKey: localStorage.getItem('pumpbot-api-key') || '',
- rpcUrl: localStorage.getItem('pumpbot-rpc-url') || 'https://api.mainnet-beta.solana.com',
+ // Default to the same-origin proxy (/api/solana-rpc), which forwards
+ // to a keyed Helius upstream server-side. The public RPC 403s
+ // browser requests, so we also migrate anyone whose stored value is
+ // that old broken default onto the proxy; genuine custom RPCs are
+ // preserved untouched.
+ rpcUrl: (() => {
+ const stored = localStorage.getItem('pumpbot-rpc-url');
+ return stored && stored !== 'https://api.mainnet-beta.solana.com'
+ ? stored
+ : '/api/solana-rpc';
+ })(),
currentPage: 'dashboard',
currentFilter: 'all',
ws: null,
@@ -2160,7 +2170,7 @@
state.apiUrl = $('pd-cfg-api-url').value.trim() || location.origin;
state.wsUrl = $('pd-cfg-ws-url').value.trim() || 'wss://pumpportal.fun/api/data';
state.apiKey = $('pd-cfg-api-key').value.trim();
- state.rpcUrl = $('pd-cfg-rpc-url').value.trim() || 'https://api.mainnet-beta.solana.com';
+ state.rpcUrl = $('pd-cfg-rpc-url').value.trim() || '/api/solana-rpc';
localStorage.setItem('pumpbot-api-url', state.apiUrl);
localStorage.setItem('pumpbot-ws-url', state.wsUrl);
localStorage.setItem('pumpbot-api-key', state.apiKey);
diff --git a/pages/pump-visualizer.html b/pages/pump-visualizer.html
index 21466c213..78fcb76b6 100644
--- a/pages/pump-visualizer.html
+++ b/pages/pump-visualizer.html
@@ -822,6 +822,19 @@
const textureLoader = new THREE.TextureLoader();
textureLoader.crossOrigin = 'anonymous';
+ // Route remote token art through the same-origin proxy (/api/img) so the
+ // browser never makes a cross-origin image request — this eliminates the
+ // CORS / ERR_BLOCKED_BY_ORB failures that blanked token textures (one per
+ // token in the cloud). data: URIs and already-same-origin paths pass
+ // through untouched; the proxy itself falls back to a placeholder on any
+ // upstream failure, so a returned src always resolves.
+ function proxiedImg(uri, seed) {
+ if (!uri || typeof uri !== 'string') return null;
+ if (uri.startsWith('data:') || uri.startsWith('/')) return uri;
+ const s = seed ? `&seed=${encodeURIComponent(seed)}` : '';
+ return `/api/img?url=${encodeURIComponent(uri)}${s}`;
+ }
+
function fibonacciSphere(n) {
const points = [];
const phi = Math.PI * (Math.sqrt(5) - 1);
@@ -952,7 +965,7 @@
// Swap to real artwork asynchronously; keeps fallback if it fails.
if (token.image_uri) {
- loadTokenTexture(token.image_uri, null).then((tex) => {
+ loadTokenTexture(proxiedImg(token.image_uri, token.mint || token.symbol), null).then((tex) => {
if (tex) {
material.map = tex;
material.needsUpdate = true;
@@ -1210,7 +1223,7 @@
function renderDetail(token) {
const avatar = document.getElementById('vz-detail-avatar');
const fallbackAvatar = `https://api.dicebear.com/7.x/shapes/svg?seed=${encodeURIComponent(token.mint || token.symbol || 'x')}`;
- avatar.src = token.image_uri || fallbackAvatar;
+ avatar.src = proxiedImg(token.image_uri, token.mint || token.symbol) || fallbackAvatar;
avatar.onerror = () => { avatar.onerror = null; avatar.src = fallbackAvatar; };
document.getElementById('vz-detail-name').textContent = token.name || 'Unknown';
@@ -1306,7 +1319,7 @@
thumb.alt = '';
thumb.loading = 'lazy';
thumb.referrerPolicy = 'no-referrer';
- thumb.src = token.image_uri || `https://api.dicebear.com/7.x/shapes/svg?seed=${encodeURIComponent(token.mint || token.symbol || 'x')}`;
+ thumb.src = proxiedImg(token.image_uri, token.mint || token.symbol) || `https://api.dicebear.com/7.x/shapes/svg?seed=${encodeURIComponent(token.mint || token.symbol || 'x')}`;
thumb.onerror = () => { thumb.onerror = null; thumb.src = `https://api.dicebear.com/7.x/shapes/svg?seed=${encodeURIComponent(token.mint || 'x')}`; };
const name = document.createElement('span');
diff --git a/src/footer-bot.js b/src/footer-bot.js
index e2a9239c2..7158a7ab9 100644
--- a/src/footer-bot.js
+++ b/src/footer-bot.js
@@ -51,14 +51,34 @@ let mixer = null;
const clock = new Clock();
let robot = null;
-new GLTFLoader().load('/animations/robotexpressive.glb', (gltf) => {
+// The footer bot is decorative: a transient CDN/network blip on the primary
+// asset must never leave an empty canvas or throw. Walk a fallback chain —
+// the expressive robot, retried once for transient failures, then a static
+// avatar that ships in the same bundle — and give up silently only if every
+// source is unreachable. A model with no clips simply renders without motion.
+const BOT_ASSETS = ['/animations/robotexpressive.glb', '/avatars/default.glb'];
+
+function mountBot(gltf) {
robot = gltf.scene;
scene.add(robot);
if (gltf.animations.length > 0) {
mixer = new AnimationMixer(robot);
mixer.clipAction(gltf.animations[0]).play();
}
-});
+}
+
+function loadBot(index = 0, retried = false) {
+ if (index >= BOT_ASSETS.length) return; // every source exhausted — leave the canvas empty
+ const url = BOT_ASSETS[index];
+ new GLTFLoader().load(url, mountBot, undefined, () => {
+ // Retry the same source once (transient fetch failures usually clear),
+ // then advance to the next fallback asset.
+ if (!retried) loadBot(index, true);
+ else loadBot(index + 1, false);
+ });
+}
+
+loadBot();
// 20deg/sec auto-rotate, matching model-viewer rotation-per-second="20deg"
const rotSpeed = MathUtils.degToRad(20);
diff --git a/tests/mcp-resilience.test.js b/tests/mcp-resilience.test.js
index 8a88a6951..9eead2f20 100644
--- a/tests/mcp-resilience.test.js
+++ b/tests/mcp-resilience.test.js
@@ -46,10 +46,12 @@ describe('resilientFetch — timeout + safe retries', () => {
});
it('retries a GET on a 503 then succeeds', async () => {
- fetchMock
- .mockResolvedValueOnce(res(503))
- .mockResolvedValueOnce(res(200, { ok: true }));
- const r = await resilientFetch('https://x.test', {}, { retries: 2, baseDelayMs: 1, maxDelayMs: 2 });
+ fetchMock.mockResolvedValueOnce(res(503)).mockResolvedValueOnce(res(200, { ok: true }));
+ const r = await resilientFetch(
+ 'https://x.test',
+ {},
+ { retries: 2, baseDelayMs: 1, maxDelayMs: 2 },
+ );
expect(r.status).toBe(200);
expect(fetchMock).toHaveBeenCalledTimes(2);
});
@@ -58,22 +60,28 @@ describe('resilientFetch — timeout + safe retries', () => {
fetchMock
.mockRejectedValueOnce(new Error('ECONNRESET'))
.mockResolvedValueOnce(res(200, { ok: true }));
- const r = await resilientFetch('https://x.test', {}, { retries: 2, baseDelayMs: 1, maxDelayMs: 2 });
+ const r = await resilientFetch(
+ 'https://x.test',
+ {},
+ { retries: 2, baseDelayMs: 1, maxDelayMs: 2 },
+ );
expect(r.status).toBe(200);
expect(fetchMock).toHaveBeenCalledTimes(2);
});
it('does NOT retry a non-idempotent POST by default (no double-send)', async () => {
fetchMock.mockResolvedValueOnce(res(503));
- const r = await resilientFetch('https://x.test', { method: 'POST' }, { retries: 3, baseDelayMs: 1 });
+ const r = await resilientFetch(
+ 'https://x.test',
+ { method: 'POST' },
+ { retries: 3, baseDelayMs: 1 },
+ );
expect(r.status).toBe(503);
expect(fetchMock).toHaveBeenCalledTimes(1);
});
it('retries a POST when the caller opts in with retryNonIdempotent', async () => {
- fetchMock
- .mockResolvedValueOnce(res(500))
- .mockResolvedValueOnce(res(200, { ok: true }));
+ fetchMock.mockResolvedValueOnce(res(500)).mockResolvedValueOnce(res(200, { ok: true }));
const r = await resilientFetch(
'https://x.test',
{ method: 'POST' },
@@ -85,7 +93,11 @@ describe('resilientFetch — timeout + safe retries', () => {
it('returns the last response (not throw) when retries are exhausted on status', async () => {
fetchMock.mockResolvedValue(res(429));
- const r = await resilientFetch('https://x.test', {}, { retries: 2, baseDelayMs: 1, maxDelayMs: 2 });
+ const r = await resilientFetch(
+ 'https://x.test',
+ {},
+ { retries: 2, baseDelayMs: 1, maxDelayMs: 2 },
+ );
expect(r.status).toBe(429);
expect(fetchMock).toHaveBeenCalledTimes(3); // 1 + 2 retries
});
@@ -112,7 +124,9 @@ describe('resilientFetch — timeout + safe retries', () => {
it('fetchJson returns parsed JSON on success', async () => {
fetchMock.mockResolvedValueOnce(res(200, { hello: 'world' }));
- await expect(fetchJson('https://x.test', {}, { retries: 0 })).resolves.toEqual({ hello: 'world' });
+ await expect(fetchJson('https://x.test', {}, { retries: 0 })).resolves.toEqual({
+ hello: 'world',
+ });
});
});