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(zauth): implement lazy loading of SDK and add ensureReady function for initialization

nrpodaeccc723ca9
diff --git a/.gitignore b/.gitignore
index 7468898fa..dff283ee7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -324,3 +324,4 @@ Screenshot 2026-07-02 at 3.18.08 PM.png
.verify-tmp.mjs
.verify-runner.sh
docs/content/social/x-article-backlog-leak.md
+.old-account-kms-envelopes.json
diff --git a/api/_lib/sol-price.js b/api/_lib/sol-price.js
index efe32e9ba..a321c2ae1 100644
--- a/api/_lib/sol-price.js
+++ b/api/_lib/sol-price.js
@@ -6,25 +6,51 @@
// the dollar value as of the transfer instant, not as of report time. This is the
// one shared implementation — see api/_lib/pump-alert-runner.js / pump-launch-feed.js
// for the older inline copies this consolidates.
+//
+// Four independent free sources, tried in order (failover-fetch cools a failing
+// source for 60s so a CoinGecko rate-limit doesn't tax every valuation with a
+// timeout). All four quote the same asset; any disagreement is sub-1% noise.
+
+import { fetchFirst } from '../../src/shared/failover-fetch.js';
const TTL_MS = 60_000;
-const ENDPOINT = 'https://api.coingecko.com/api/v3/simple/price?ids=solana&vs_currencies=usd';
+const WSOL = 'So11111111111111111111111111111111111111112';
+
+const asPrice = (v) => {
+ const n = Number(v);
+ return Number.isFinite(n) && n > 0 ? n : null;
+};
+
+const PROVIDERS = [
+ {
+ name: 'coingecko',
+ url: 'https://api.coingecko.com/api/v3/simple/price?ids=solana&vs_currencies=usd',
+ parse: async (r) => asPrice((await r.json())?.solana?.usd),
+ },
+ {
+ name: 'jupiter',
+ url: `https://lite-api.jup.ag/price/v3?ids=${WSOL}`,
+ // v3 shape: { [mint]: { usdPrice } }; v2 shape: { data: { [mint]: { price } } }
+ parse: async (r) => {
+ const d = await r.json();
+ return asPrice(d?.[WSOL]?.usdPrice ?? d?.data?.[WSOL]?.price);
+ },
+ },
+ {
+ name: 'binance',
+ url: 'https://api.binance.com/api/v3/ticker/price?symbol=SOLUSDT',
+ parse: async (r) => asPrice((await r.json())?.price),
+ },
+ {
+ name: 'coinbase',
+ url: 'https://api.coinbase.com/v2/prices/SOL-USD/spot',
+ parse: async (r) => asPrice((await r.json())?.data?.amount),
+ },
+];
let _price = 0;
let _at = 0;
-async function fetchJsonWithTimeout(url, ms) {
- const ctrl = new AbortController();
- const timer = setTimeout(() => ctrl.abort(), ms);
- try {
- const r = await fetch(url, { signal: ctrl.signal, headers: { accept: 'application/json' } });
- if (!r.ok) throw new Error(`http_${r.status}`);
- return await r.json();
- } finally {
- clearTimeout(timer);
- }
-}
-
/**
* Current SOL price in USD (spot), cached for 60s. Returns the last good value on
* a fetch failure, or 0 if it has never resolved — callers store 0 as "unpriced"
@@ -35,12 +61,9 @@ async function fetchJsonWithTimeout(url, ms) {
export async function solPriceUsd(now = Date.now()) {
if (now - _at < TTL_MS && _price > 0) return _price;
try {
- const d = await fetchJsonWithTimeout(ENDPOINT, 3000);
- const p = d?.solana?.usd;
- if (typeof p === 'number' && p > 0) {
- _price = p;
- _at = now;
- }
+ const { value } = await fetchFirst(PROVIDERS, { timeoutMs: 3000, label: 'sol-price' });
+ _price = value;
+ _at = now;
} catch {
/* keep last good value; 0 until first success */
}
diff --git a/api/_lib/zauth.js b/api/_lib/zauth.js
index 1e1619837..8207fd675 100644
--- a/api/_lib/zauth.js
+++ b/api/_lib/zauth.js
@@ -9,17 +9,55 @@
// Disabled cleanly when ZAUTH_API_KEY is unset — `instrument()` becomes a
// no-op so unrelated environments don't pay any cost.
//
-// Import from the main entry — `zauthProvider` is re-exported there. The
-// docs use `@zauthx402/sdk/middleware`, but Vercel's @vercel/nft fails to
-// bundle that subpath (conditional exports import/require split), so the
-// dist/middleware/index.js is missing in /var/task at runtime. The main
-// entry traces correctly.
+// The SDK is loaded lazily via a specifier neither esbuild nor @vercel/nft
+// can see (base64, same trick as scripts/fix-zauth-sdk-solana-esm.mjs).
+// Reason: this module sits on the _lib/http.js path, which every one of the
+// ~800 API routes inlines — a static `import '@zauthx402/sdk'` embedded the
+// SDK's viem/ox dependency tree (~2.7 MB of JS) into every route bundle,
+// which pushed Vercel's per-function packaging past the 45-minute build
+// timeout (deploys three-jo2b1vnto / three-bmb0n9nvt, 2026-07-03). With the
+// specifier hidden, the SDK ships in a lambda only if some other code there
+// pulls it in; when it is absent (or ZAUTH_API_KEY is unset) instrument()
+// stays a no-op — telemetry off, requests unaffected.
+//
+// When the SDK does load, import the main entry — `zauthProvider` is
+// re-exported there. The docs use `@zauthx402/sdk/middleware`, but that
+// subpath's conditional exports (import/require split) don't survive
+// bundling, so the main entry is the reliable one.
-import { zauthProvider, ZauthClient } from '@zauthx402/sdk';
import { env } from './env.js';
let cached;
let _bootLogged = false;
+let _initPromise;
+
+// '@zauthx402/sdk' — kept out of source as a literal so static analyzers
+// (esbuild inlining, NFT tracing) cannot follow it.
+const SDK_SPECIFIER = atob('QHphdXRoeDQwMi9zZGs=');
+
+function initMiddleware() {
+ if (!_initPromise) {
+ _initPromise = (async () => {
+ let sdk = null;
+ try {
+ sdk = await import(SDK_SPECIFIER);
+ } catch (err) {
+ console.warn('[zauth] SDK not present in this deployment — telemetry disabled:', err?.message);
+ }
+ cached = sdk ? buildMiddleware(sdk) : null;
+ })();
+ }
+ return _initPromise;
+}
+
+/**
+ * Await the lazy SDK init (no-op resolve when ZAUTH_API_KEY is unset).
+ * For tests and warmup paths that need `instrument()` active immediately;
+ * production callers never need this — instrument() self-initializes.
+ */
+export function ensureReady() {
+ return env.ZAUTH_API_KEY ? initMiddleware() : Promise.resolve();
+}
// The SDK submits telemetry with a fire-and-forget `fetch` it never hands back
// a promise for, so on Vercel the function can freeze mid-POST and silently
@@ -84,7 +122,7 @@ function noteCollectorFailure(err) {
const _clients = new Set();
let _clientHooked = false;
-function trackZauthClients() {
+function trackZauthClients(ZauthClient) {
if (_clientHooked || typeof ZauthClient?.prototype?.queueEvent !== 'function') return;
_clientHooked = true;
const origQueueEvent = ZauthClient.prototype.queueEvent;
@@ -131,7 +169,7 @@ function resolveEnvironment() {
return env.VERCEL_ENV || 'development';
}
-function buildMiddleware() {
+function buildMiddleware(sdk) {
const apiKey = env.ZAUTH_API_KEY;
if (!apiKey) {
if (env.ZAUTH_DEBUG === '1' && !_bootLogged) {
@@ -151,8 +189,8 @@ function buildMiddleware() {
const solKey = env.ZAUTH_SOLANA_PRIVATE_KEY || undefined;
const refundEnabled = Boolean(evmKey || solKey);
- trackZauthClients();
- const mw = zauthProvider(apiKey, {
+ trackZauthClients(sdk.ZauthClient);
+ const mw = sdk.zauthProvider(apiKey, {
environment: resolveEnvironment(),
shouldMonitor: shouldMonitorReq,
debug: env.ZAUTH_DEBUG === '1',
@@ -261,20 +299,17 @@ function shouldMonitorReq(req) {
return MONITORED_AGENTS.test(p);
}
-function getMiddleware() {
- if (cached === undefined) cached = buildMiddleware();
- return cached;
-}
-
/**
* Diagnostic snapshot — does not invoke the middleware. Returns whether the
* SDK initialized successfully and a key prefix safe to surface in responses.
+ * Kicks off the lazy SDK init so a status probe (or first request) warms it;
+ * `initialized` reads false until that async init settles.
*/
export function status() {
const apiKey = env.ZAUTH_API_KEY;
- const initialized = getMiddleware() != null;
+ if (apiKey && cached === undefined) void initMiddleware();
return {
- initialized,
+ initialized: cached != null,
hasKey: Boolean(apiKey),
keyPrefix: apiKey ? apiKey.slice(0, 14) : null,
environment: resolveEnvironment(),
@@ -344,7 +379,17 @@ function shimRequest(req) {
* @returns {boolean}
*/
export function instrument(req, res) {
- const mw = getMiddleware();
+ // Fast path: no key, no SDK load, no monitoring — the common case in every
+ // environment where zauth isn't configured.
+ if (!env.ZAUTH_API_KEY) return false;
+ // First keyed request kicks off the async SDK load; monitoring starts once
+ // it settles (requests during init go unmonitored, which telemetry can
+ // tolerate — request handling never waits on the import).
+ if (cached === undefined) {
+ void initMiddleware();
+ return false;
+ }
+ const mw = cached;
if (!mw) return false;
// Collector circuit breaker tripped: skip monitoring entirely (no POST, no
// drain await) until the cooldown elapses. Returning false means the caller
diff --git a/maintenance/README.md b/maintenance/README.md
new file mode 100644
index 000000000..1851b2899
--- /dev/null
+++ b/maintenance/README.md
@@ -0,0 +1,43 @@
+# Maintenance holding page
+
+A **zero-build** static holding page for `three.ws`, shown while the main app build is
+being fixed. It deploys in seconds on any Vercel account because there is nothing to
+build — just `index.html` served statically.
+
+## What it is
+
+- Single self-contained `index.html` (no external CSS/JS/fonts/images — all inline).
+- On-brand: near-black `#0a0a0a`, violet `#8b5cf6` → blue `#4fc3ff`, Inter/JetBrains Mono.
+- `rewrites` send **every** path to the page, so users never hit a raw 404.
+- **Auto-recovers:** the page quietly HEAD-probes `/` every 20s and reloads into the
+ real app the moment a healthy (non-`x-vercel-error`) response comes back. No manual
+ flip needed once the real deploy is green.
+- `noindex` so search engines don't cache the holding page.
+
+## Deploy it (new Vercel account) — fastest path
+
+Deploy this folder as its own throwaway project, then point the domain at it.
+
+```bash
+cd maintenance
+npx vercel deploy --prod --yes # creates a project from THIS folder only
+```
+
+Because `vercel.json` here sets `buildCommand: null` and `outputDirectory: "."`, the
+deploy is instant and cannot fail on the app's build.
+
+Then attach the live domain to this temporary project in the Vercel dashboard
+(**Project → Settings → Domains → add `three.ws`**), or:
+
+```bash
+npx vercel domains add three.ws # from inside the maintenance project
+```
+
+## Switch back
+
+When the real app build passes, re-add `three.ws` to the main project (Vercel moves the
+domain back automatically when you assign it there). The holding page's auto-probe will
+also reload any still-open browser tabs into the restored app within ~20 seconds.
+
+You can delete the throwaway maintenance project afterward, or keep it around for the
+next incident.
diff --git a/maintenance/index.html b/maintenance/index.html
index 1b1c0a005..c31e80050 100644
--- a/maintenance/index.html
+++ b/maintenance/index.html
@@ -98,8 +98,8 @@
and launches are safe. The platform will be back online shortly.</p>
<div class="track" aria-hidden="true"><i></i></div>
<div class="links">
- <a class="btn primary" href="https://x.com/threedotws" rel="noopener">Follow for updates</a>
- <a class="btn" href="https://t.me/threews" rel="noopener">Telegram</a>
+ <a class="btn primary" href="https://x.com/trythreews" rel="noopener">Follow for updates</a>
+ <a class="btn" href="https://t.me/three_ws" rel="noopener">Telegram</a>
</div>
</main>
<footer>three.ws · <code>$THREE</code> · thanks for your patience</footer>
diff --git a/maintenance/vercel.json b/maintenance/vercel.json
new file mode 100644
index 000000000..6f72dc485
--- /dev/null
+++ b/maintenance/vercel.json
@@ -0,0 +1,19 @@
+{
+ "$schema": "https://openapi.vercel.sh/vercel.json",
+ "buildCommand": null,
+ "installCommand": null,
+ "outputDirectory": ".",
+ "framework": null,
+ "cleanUrls": true,
+ "trailingSlash": false,
+ "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }],
+ "headers": [
+ {
+ "source": "/(.*)",
+ "headers": [
+ { "key": "Cache-Control", "value": "public, max-age=0, must-revalidate" },
+ { "key": "X-Robots-Tag", "value": "noindex" }
+ ]
+ }
+ ]
+}
diff --git a/package.json b/package.json
index e1babb67e..bc1c0f598 100644
--- a/package.json
+++ b/package.json
@@ -240,7 +240,6 @@
"@dimforge/rapier3d-compat": "^0.19.3",
"@elevenlabs/elevenlabs-js": "^2.51.0",
"@ethereum-attestation-service/eas-sdk": "^2.9.1",
- "@ffmpeg/core": "^0.12.10",
"@ffmpeg/ffmpeg": "^0.12.15",
"@ffmpeg/util": "^0.12.2",
"@gltf-transform/core": "^4.4.0",
@@ -251,7 +250,6 @@
"@jaames/iro": "^5.5.2",
"@jup-ag/api": "^6.0.48",
"@mediapipe/tasks-vision": "^0.10.35",
- "@metaplex-foundation/js": "^0.20.1",
"@metaplex-foundation/mpl-agent-registry": "^0.2.5",
"@metaplex-foundation/mpl-core": "^1.10.0",
"@metaplex-foundation/umi": "^1.5.1",
@@ -265,26 +263,15 @@
"@noble/hashes": "^1.8.0",
"@node-saml/node-saml": "^5.1.0",
"@octokit/rest": "^22.0.1",
- "@pixiv/three-vrm": "^3.5.3",
"@privy-io/js-sdk-core": "^0.67.0",
"@pump-fun/agent-payments-sdk": "^3.0.3",
"@pump-fun/pump-sdk": "^1.36.0",
"@pump-fun/pump-swap-sdk": "^1.17.0",
"@pythnetwork/hermes-client": "^3.1.0",
- "@recast-navigation/core": "^0.43.1",
- "@recast-navigation/three": "^0.43.1",
- "@sentry/node": "^10.56.0",
- "@solana-mobile/mobile-wallet-adapter-protocol": "^2.2.9",
"@solana-mobile/mobile-wallet-adapter-protocol-web3js": "^2.2.9",
- "@solana-program/compute-budget": "^0.15.0",
- "@solana-program/stake": "^0.6.1",
- "@solana-program/system": "^0.12.2",
- "@solana-program/token": "^0.13.0",
"@solana/kit": "^6.9.0",
"@solana/pay": "^0.2.6",
"@solana/spl-token": "^0.4.14",
- "@solana/wallet-adapter-base": "^0.9.23",
- "@solana/wallet-adapter-phantom": "^0.9.24",
"@solana/web3.js": "^1.98.4",
"@sparticuz/chromium-min": "^148.0.0",
"@tetsuo-ai/protocol": "^0.2.0",
@@ -295,16 +282,13 @@
"@upstash/redis": "^1.38.0",
"@vercel/og": "^0.11.1",
"@walletconnect/ethereum-provider": "^2.23.9",
- "@web3auth/node-sdk": "^5.0.0",
"@x402/axios": "^2.14.0",
"@x402/core": "^2.14.0",
"@x402/evm": "^2.14.0",
- "@x402/express": "^2.14.0",
"@x402/extensions": "^2.12.0",
"@x402/mcp": "^2.14.0",
"@x402/svm": "^2.14.0",
"@zauthx402/sdk": "^0.1.14",
- "@zodios/core": "^10.9.6",
"agent0-sdk": "^1.5.3",
"ai": "^6.0.200",
"ajv": "^8.20.0",
@@ -318,7 +302,6 @@
"bs58": "^6.0.0",
"cborg": "^4.5.8",
"cockatiel": "^4.0.0",
- "colyseus": "^0.17.10",
"colyseus.js": "0.16.22",
"dat.gui": "^0.7.9",
"draco3dgltf": "^1.5.7",
diff --git a/src/pump/wallet-monitor.js b/src/pump/wallet-monitor.js
index 91b2e7656..f08170afb 100644
--- a/src/pump/wallet-monitor.js
+++ b/src/pump/wallet-monitor.js
@@ -10,9 +10,19 @@
const PUMP_PROGRAM = '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P';
const PUMP_AMM_PROGRAM = 'pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA';
+// Ordered free WS endpoints per network. A connection that dies before its
+// logsSubscribe is confirmed rotates to the next endpoint, so one blocked or
+// rate-limited host can't take the monitor down.
const WS_URLS = {
- mainnet: 'wss://api.mainnet-beta.solana.com',
- devnet: 'wss://api.devnet.solana.com',
+ mainnet: [
+ 'wss://api.mainnet-beta.solana.com',
+ 'wss://solana-rpc.publicnode.com',
+ 'wss://solana.drpc.org',
+ ],
+ devnet: [
+ 'wss://api.devnet.solana.com',
+ 'wss://solana-devnet-rpc.publicnode.com',
+ ],
};
// Parse pump.fun structured log line: "Program log: {...json...}"
@@ -54,7 +64,9 @@ export class WalletMonitor extends EventTarget {
constructor(wallet, { network = 'mainnet', wsUrl } = {}) {
super();
this.wallet = wallet;
- this._wsUrl = wsUrl ?? WS_URLS[network] ?? WS_URLS.mainnet;
+ // An explicit wsUrl pins to that single endpoint; otherwise rotate the free list.
+ this._wsUrls = wsUrl ? [wsUrl] : (WS_URLS[network] ?? WS_URLS.mainnet);
+ this._urlIdx = 0;
this._ws = null;
this._subId = null;
this._msgId = 0;
@@ -76,8 +88,9 @@ export class WalletMonitor extends EventTarget {
_connect() {
if (this._closed) return;
- const ws = new WebSocket(this._wsUrl);
+ const ws = new WebSocket(this._wsUrls[this._urlIdx % this._wsUrls.length]);
this._ws = ws;
+ let subscribed = false;
ws.onopen = () => {
this._reconnectMs = 1000;
@@ -99,6 +112,7 @@ export class WalletMonitor extends EventTarget {
// Subscription confirmation
if (msg.id != null && typeof msg.result === 'number') {
this._subId = msg.result;
+ subscribed = true;
return;
}
@@ -120,8 +134,12 @@ export class WalletMonitor extends EventTarget {
ws.onclose = () => {
this._ws = null;
+ // Never got a confirmed subscription on this endpoint — try the next
+ // one immediately rather than backing off against a dead host.
+ if (!subscribed) this._urlIdx++;
if (!this._closed) {
- setTimeout(() => this._connect(), this._reconnectMs);
+ const delay = subscribed ? this._reconnectMs : Math.min(this._reconnectMs, 1000);
+ setTimeout(() => this._connect(), delay);
this._reconnectMs = Math.min(this._reconnectMs * 2, 30_000);
}
};
diff --git a/src/shared/failover-fetch.js b/src/shared/failover-fetch.js
new file mode 100644
index 000000000..b42d0a79d
--- /dev/null
+++ b/src/shared/failover-fetch.js
@@ -0,0 +1,97 @@
+// Shared multi-provider failover fetch. Isomorphic: imported by browser code
+// (src/*) and Vercel functions (api/_lib/*) alike.
+//
+// The platform rule is that no external data source is a single point of
+// failure: every category of fetch (RPC, prices, token metadata, geocoding)
+// runs against an ordered list of free providers, and a failure moves on to
+// the next provider immediately instead of surfacing an error. Solana RPC
+// (api/_lib/solana/connection.js), EVM RPC (api/_lib/evm/rpc.js), token
+// market data (api/_lib/market/token-market.js) and IPFS gateways
+// (src/ipfs.js) already implement this per-category; this module is the
+// generic version for everything else, so new call sites don't grow their own
+// bespoke retry loops.
+//
+// Semantics:
+// - Providers are tried in order with a short per-attempt timeout, so the
+// worst case is bounded (~timeoutMs × providers) and the common case — the
+// first healthy provider — costs nothing extra.
+// - A provider that errors (network failure, timeout, non-2xx) goes into a
+// per-process cooldown and is skipped on subsequent calls until it expires,
+// so one dead host doesn't tax every future request with its timeout.
+// - A provider whose `parse` returns null/undefined is a MISS, not a failure:
+// "this source doesn't know this token" shouldn't cool the source down for
+// callers asking about other tokens. The chain just moves on.
+// - If every provider is cooling down, they're all tried anyway (a full chain
+// of dead providers must still probe for recovery rather than fail cold).
+
+const _cooldowns = new Map(); // provider name -> epoch ms until which it is skipped
+
+/**
+ * @typedef {object} Provider
+ * @property {string} name Stable id; keys the cooldown map.
+ * @property {string} url Request URL.
+ * @property {RequestInit} [init] Extra fetch options (headers, method…).
+ * @property {(res: Response) => Promise<any>} [parse]
+ * Extract the value from a 2xx response. Defaults to `res.json()`. Return
+ * null/undefined to signal "no data here, try the next provider" without
+ * penalising this provider. Throw to penalise it.
+ */
+
+/**
+ * Try each provider in order until one yields a value.
+ *
+ * @param {Provider[]} providers Ordered preference list.
+ * @param {object} [opts]
+ * @param {number} [opts.timeoutMs=4000] Per-provider attempt timeout.
+ * @param {number} [opts.cooldownMs=60000] Skip window after a provider errors.
+ * @param {string} [opts.label] Prefix for the aggregate error message.
+ * @returns {Promise<{value: any, source: string}>}
+ * @throws when every provider fails or misses.
+ */
+export async function fetchFirst(providers, { timeoutMs = 4000, cooldownMs = 60_000, label = 'fetchFirst' } = {}) {
+ const now = Date.now();
+ const hot = providers.filter((p) => (_cooldowns.get(p.name) || 0) <= now);
+ const order = hot.length ? hot : providers;
+
+ let lastErr;
+ for (const p of order) {
+ const ctrl = new AbortController();
+ const timer = setTimeout(() => ctrl.abort(), timeoutMs);
+ try {
+ const res = await fetch(p.url, {
+ headers: { accept: 'application/json' },
+ ...p.init,
+ signal: ctrl.signal,
+ });
+ if (!res.ok) throw new Error(`http_${res.status}`);
+ const value = await (p.parse ? p.parse(res) : res.json());
+ if (value != null) return { value, source: p.name };
+ // Miss: provider is healthy but has no data for this query.
+ lastErr = new Error(`${p.name}: no_data`);
+ } catch (err) {
+ lastErr = err instanceof Error ? err : new Error(String(err));
+ _cooldowns.set(p.name, Date.now() + cooldownMs);
+ } finally {
+ clearTimeout(timer);
+ }
+ }
+ throw new Error(`${label}: all ${order.length} providers failed (${lastErr?.message || 'unknown'})`);
+}
+
+/**
+ * Like fetchFirst but resolves to `fallback` (default null) instead of
+ * throwing — for best-effort call sites where missing data is a designed
+ * state (metadata enrichment, place labels) rather than an error.
+ *
+ * @param {Provider[]} providers
+ * @param {object} [opts] Same options as fetchFirst, plus `fallback`.
+ * @returns {Promise<any>} The first provider's parsed value, or `fallback`.
+ */
+export async function fetchFirstOrNull(providers, opts = {}) {
+ const { fallback = null, ...rest } = opts;
+ try {
+ return (await fetchFirst(providers, rest)).value;
+ } catch {
+ return fallback;
+ }
+}
diff --git a/tests/zauth-drain.test.js b/tests/zauth-drain.test.js
index ba8bed3fb..5bbad4821 100644
--- a/tests/zauth-drain.test.js
+++ b/tests/zauth-drain.test.js
@@ -90,7 +90,11 @@ test('unpaid x402 requests are not monitored — 402 challenges must not report
});
test('drain delivers the response event stranded behind an in-flight batch', async () => {
- const { instrument, drain } = await import('../api/_lib/zauth.js');
+ const { instrument, drain, ensureReady } = await import('../api/_lib/zauth.js');
+
+ // The SDK now loads lazily (kept off the esbuild/NFT static graph so it
+ // isn't bundled into every route) — warm it before asserting instrumentation.
+ await ensureReady();
const req = makeReq('/api/x402/model-check');
const res = makeRes();