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.

fix(deps): close the dependency and symlink gaps behind the 2026-06-11 outage

nirholas440c8396a84f
diff --git a/package-lock.json b/package-lock.json
index b329ca49b..93fac9184 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -44,6 +44,7 @@
"@ethereum-attestation-service/eas-sdk": "^2.9.1",
"@gltf-transform/core": "^4.4.0",
"@gltf-transform/extensions": "^4.4.0",
+ "@gltf-transform/functions": "^4.4.0",
"@jup-ag/api": "^6.0.48",
"@mediapipe/tasks-vision": "^0.10.35",
"@metaplex-foundation/js": "^0.20.1",
@@ -56,6 +57,7 @@
"@neynar/nodejs-sdk": "^3.176.0",
"@nirholas/pump-sdk": "^1.0.0",
"@noble/curves": "^2.2.0",
+ "@noble/hashes": "^1.3.2",
"@node-saml/node-saml": "^5.1.0",
"@octokit/rest": "^22.0.1",
"@pixiv/three-vrm": "^3.5.3",
@@ -98,15 +100,22 @@
"@zauthx402/sdk": "^0.1.14",
"agent0-sdk": "^1.5.3",
"ai": "^6.0.200",
+ "ajv": "^8.20.0",
+ "ajv-formats": "^3.0.1",
+ "axios": "^1.16.0",
"bcryptjs": "^3.0.3",
+ "bignumber.js": "^9.3.1",
"bn.js": "^5.2.3",
+ "borsher": "^4.0.0",
"bs58": "^6.0.0",
+ "cborg": "^4.5.8",
"colyseus": "^0.17.10",
"colyseus.js": "0.16.22",
"dat.gui": "^0.7.9",
"ethers": "^6.16.0",
"express": "^5.2.1",
"fast-check": "^4.8.0",
+ "fast-xml-parser": "^5.7.3",
"gltf-validator": "^2.0.0-dev.3.10",
"graphql": "^16.14.1",
"helius-sdk": "^3.0.0",
@@ -115,6 +124,8 @@
"livekit-client": "^2.19.2",
"livepeer": "^3.5.0",
"meshoptimizer": "^1.1.1",
+ "multiformats": "^9.9.0",
+ "nanoid": "^3.3.11",
"nipplejs": "^1.0.4",
"node-fetch": "^3.3.2",
"node-html-parser": "^7.1.0",
@@ -125,12 +136,14 @@
"qwen-ai-provider": "^0.1.1",
"resend": "^6.12.4",
"sas-lib": "^1.0.10",
+ "sharp": "^0.34.5",
"short-uuid": "6.0.3",
"simple-dropzone": "^0.8.3",
"three": "^0.184.0",
"three-mesh-bvh": "^0.9.10",
"three-pathfinding": "^1.3.0",
"twitter-api-v2": "^1.29.0",
+ "undici": "^7.27.1",
"vhtml": "^2.2.0",
"viem": "^2.52.2",
"wawa-lipsync": "^0.0.2",
@@ -138,16 +151,14 @@
"zod": "^3.23.8"
},
"devDependencies": {
- "@gltf-transform/functions": "^4.4.0",
"@playwright/test": "^1.60.0",
"@x402/fetch": "^2.14.0",
- "ajv": "^8.20.0",
- "ajv-formats": "^3.0.1",
+ "es-module-lexer": "^2.0.0",
+ "glob": "^11.1.0",
"jsdom": "27.3.0",
"knip": "^6.16.1",
"playwright": "^1.45.1",
"prettier": "^3.8.4",
- "sharp": "^0.34.5",
"vite": "^7.3.2",
"vite-plugin-node-polyfills": "^0.28.0",
"vite-plugin-pwa": "^1.3.0",
@@ -8668,7 +8679,6 @@
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/@gltf-transform/functions/-/functions-4.4.0.tgz",
"integrity": "sha512-CaSTAVAd2NXNWsxdgvq090rKHqy7AQlcNWV4ec7xtQyS8WEv3S3gVN27ikWmdB8nWEsXUbOIDhtPMLbXI6xDJg==",
- "dev": true,
"license": "MIT",
"dependencies": {
"@gltf-transform/core": "^4.4.0",
@@ -22475,7 +22485,6 @@
"version": "1.0.14",
"resolved": "https://registry.npmjs.org/@types/ndarray/-/ndarray-1.0.14.tgz",
"integrity": "sha512-oANmFZMnFQvb219SSBIhI1Ih/r4CvHDOzkWyJS/XRqkMrGH5/kaPSA1hQhdIBzouaE+5KpE/f5ylI9cujmckQg==",
- "dev": true,
"license": "MIT"
},
"node_modules/@types/node": {
@@ -29725,7 +29734,6 @@
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/cwise-compiler/-/cwise-compiler-1.1.3.tgz",
"integrity": "sha512-WXlK/m+Di8DMMcCjcWr4i+XzcQra9eCdXIJrgh4TUgh0pIS/yJduLxS9JgefsHJ/YVLdgPtXm9r62W92MvanEQ==",
- "dev": true,
"license": "MIT",
"dependencies": {
"uniq": "^1.0.0"
@@ -34554,7 +34562,6 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/iota-array/-/iota-array-1.0.0.tgz",
"integrity": "sha512-pZ2xT+LOHckCatGQ3DcG/a+QuEqvoxqkiL7tvE8nn3uuu+f6i1TtpB5/FtWFbxUuVr5PZCx8KskuGatbJDXOWA==",
- "dev": true,
"license": "MIT"
},
"node_modules/ip-address": {
@@ -41052,7 +41059,6 @@
"version": "1.0.19",
"resolved": "https://registry.npmjs.org/ndarray/-/ndarray-1.0.19.tgz",
"integrity": "sha512-B4JHA4vdyZU30ELBw3g7/p9bZupyew5a7tX1Y/gGeF2hafrPaQZhgrGQfsvgfYbgdFZjYwuEcnaobeM/WMW+HQ==",
- "dev": true,
"license": "MIT",
"dependencies": {
"iota-array": "^1.0.0",
@@ -41063,7 +41069,6 @@
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/ndarray-lanczos/-/ndarray-lanczos-0.3.0.tgz",
"integrity": "sha512-5kBmmG3Zvyj77qxIAC4QFLKuYdDIBJwCG+DukT6jQHNa1Ft74/hPH1z5mbQXeHBt8yvGPBGVrr3wEOdJPYYZYg==",
- "dev": true,
"license": "MIT",
"dependencies": {
"@types/ndarray": "^1.0.11",
@@ -41074,7 +41079,6 @@
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/ndarray-ops/-/ndarray-ops-1.2.2.tgz",
"integrity": "sha512-BppWAFRjMYF7N/r6Ie51q6D4fs0iiGmeXIACKY66fLpnwIui3Wc3CXiD/30mgLbDjPpSLrsqcp3Z62+IcHZsDw==",
- "dev": true,
"license": "MIT",
"dependencies": {
"cwise-compiler": "^1.0.0"
@@ -41084,7 +41088,6 @@
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ndarray-pixels/-/ndarray-pixels-5.0.1.tgz",
"integrity": "sha512-IBtrpefpqlI8SPDCGjXk4v5NV5z7r3JSuCbfuEEXaM0vrOJtNGgYUa4C3Lt5H+qWdYF4BCPVFsnXhNC7QvZwkw==",
- "dev": true,
"license": "MIT",
"dependencies": {
"@types/ndarray": "^1.0.14",
@@ -48707,7 +48710,6 @@
"version": "7.27.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.27.1.tgz",
"integrity": "sha512-UDdpiex+mzigiyrXrGbiUaF4HzTNhKbh2vRNFaTMzcqmLIPrZxaCtwo/1TMSuWoM1Xz3WiTo9KdgI3kRqYzJGg==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=20.18.1"
@@ -48792,7 +48794,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz",
"integrity": "sha512-Gw+zz50YNKPDKXs+9d+aKAjVwpjNwqzvNpLigIruT4HA9lMZNdMqs9x07kKHB/L9WRzqp4+DlTU5s4wG2esdoA==",
- "dev": true,
"license": "MIT"
},
"node_modules/unique-string": {
diff --git a/package.json b/package.json
index 8bac4392d..9ff45b083 100644
--- a/package.json
+++ b/package.json
@@ -61,6 +61,7 @@
"presence": "node scripts/three-ws-presence.mjs",
"build:pages": "node scripts/build-page-index.mjs",
"changelog:push": "node scripts/changelog-telegram.mjs",
+ "audit:deploy": "node scripts/audit-deploy-artifacts.mjs",
"audit:pages": "node scripts/audit-page-index.mjs",
"audit:handlers": "node scripts/audit-empty-handlers.mjs",
"audit:web": "node scripts/page-audit.mjs",
@@ -137,6 +138,7 @@
"@ethereum-attestation-service/eas-sdk": "^2.9.1",
"@gltf-transform/core": "^4.4.0",
"@gltf-transform/extensions": "^4.4.0",
+ "@gltf-transform/functions": "^4.4.0",
"@jup-ag/api": "^6.0.48",
"@mediapipe/tasks-vision": "^0.10.35",
"@metaplex-foundation/js": "^0.20.1",
@@ -149,6 +151,7 @@
"@neynar/nodejs-sdk": "^3.176.0",
"@nirholas/pump-sdk": "^1.0.0",
"@noble/curves": "^2.2.0",
+ "@noble/hashes": "^1.3.2",
"@node-saml/node-saml": "^5.1.0",
"@octokit/rest": "^22.0.1",
"@pixiv/three-vrm": "^3.5.3",
@@ -191,15 +194,22 @@
"@zauthx402/sdk": "^0.1.14",
"agent0-sdk": "^1.5.3",
"ai": "^6.0.200",
+ "ajv": "^8.20.0",
+ "ajv-formats": "^3.0.1",
+ "axios": "^1.16.0",
"bcryptjs": "^3.0.3",
+ "bignumber.js": "^9.3.1",
"bn.js": "^5.2.3",
+ "borsher": "^4.0.0",
"bs58": "^6.0.0",
+ "cborg": "^4.5.8",
"colyseus": "^0.17.10",
"colyseus.js": "0.16.22",
"dat.gui": "^0.7.9",
"ethers": "^6.16.0",
"express": "^5.2.1",
"fast-check": "^4.8.0",
+ "fast-xml-parser": "^5.7.3",
"gltf-validator": "^2.0.0-dev.3.10",
"graphql": "^16.14.1",
"helius-sdk": "^3.0.0",
@@ -208,6 +218,8 @@
"livekit-client": "^2.19.2",
"livepeer": "^3.5.0",
"meshoptimizer": "^1.1.1",
+ "multiformats": "^9.9.0",
+ "nanoid": "^3.3.11",
"nipplejs": "^1.0.4",
"node-fetch": "^3.3.2",
"node-html-parser": "^7.1.0",
@@ -218,12 +230,14 @@
"qwen-ai-provider": "^0.1.1",
"resend": "^6.12.4",
"sas-lib": "^1.0.10",
+ "sharp": "^0.34.5",
"short-uuid": "6.0.3",
"simple-dropzone": "^0.8.3",
"three": "^0.184.0",
"three-mesh-bvh": "^0.9.10",
"three-pathfinding": "^1.3.0",
"twitter-api-v2": "^1.29.0",
+ "undici": "^7.27.1",
"vhtml": "^2.2.0",
"viem": "^2.52.2",
"wawa-lipsync": "^0.0.2",
@@ -231,16 +245,14 @@
"zod": "^3.23.8"
},
"devDependencies": {
- "@gltf-transform/functions": "^4.4.0",
"@playwright/test": "^1.60.0",
"@x402/fetch": "^2.14.0",
- "ajv": "^8.20.0",
- "ajv-formats": "^3.0.1",
+ "es-module-lexer": "^2.0.0",
+ "glob": "^11.1.0",
"jsdom": "27.3.0",
"knip": "^6.16.1",
"playwright": "^1.45.1",
"prettier": "^3.8.4",
- "sharp": "^0.34.5",
"vite": "^7.3.2",
"vite-plugin-node-polyfills": "^0.28.0",
"vite-plugin-pwa": "^1.3.0",
diff --git a/scripts/audit-deploy-artifacts.mjs b/scripts/audit-deploy-artifacts.mjs
new file mode 100644
index 000000000..c1b62d4d6
--- /dev/null
+++ b/scripts/audit-deploy-artifacts.mjs
@@ -0,0 +1,262 @@
+#!/usr/bin/env node
+/**
+ * Deploy-artifact pre-flight audit.
+ *
+ * Catches, in seconds, the two failure classes that took production down on
+ * 2026-06-11 (465 consecutive 500s + every deploy failing for 90 minutes):
+ *
+ * 1. Committed symlinks. Vercel's function bundler cannot resolve symlinks
+ * checked into the repo — data/skills/metamask-* (symlinks into
+ * .agents/skills/) failed every build after ~18 minutes of tracing with
+ * "File …/.agents/skills/metamask-agent-workflows does not exist",
+ * which kept the cron/avatar fixes from ever reaching production.
+ *
+ * 2. Unresolvable runtime imports. .npmrc sets legacy-peer-deps=true, so
+ * npm never auto-installs peer dependencies: when helius-sdk 3.0 moved
+ * @solana-program/stake to peerDependencies, the package silently
+ * vanished from the install tree and every /api/cron/* invocation died
+ * at module load with ERR_MODULE_NOT_FOUND. Two checks close that gap:
+ * a. every non-optional peerDependency in the production lock tree
+ * resolves (with a documented allowlist of known-unused peers);
+ * b. every bare import in api/**∕*.js is declared in package.json —
+ * phantom deps that only exist via hoisting disappear on dedupe.
+ *
+ * Runs standalone (`node scripts/audit-deploy-artifacts.mjs`), as phase 1 of
+ * scripts/build-vercel.mjs, and via tests/deploy-artifacts.test.js.
+ */
+import { execFileSync } from 'node:child_process';
+import { readFileSync, existsSync } from 'node:fs';
+import { builtinModules } from 'node:module';
+import { resolve, dirname } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { globSync } from 'glob';
+import { init, parse } from 'es-module-lexer';
+
+const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
+
+// ---------------------------------------------------------------------------
+// 1. Committed symlinks
+// ---------------------------------------------------------------------------
+
+/**
+ * Returns the repo paths of every symlink in the git index (mode 120000).
+ * Local-only symlinks (e.g. .claude/skills/, created by setup-claude-skills.mjs)
+ * are gitignored and never appear here; anything that does appear will reach
+ * Vercel's checkout and break function tracing.
+ */
+export function findCommittedSymlinks({ cwd = ROOT } = {}) {
+ const out = execFileSync('git', ['ls-files', '-s'], {
+ cwd,
+ encoding: 'utf8',
+ maxBuffer: 64 * 1024 * 1024,
+ });
+ const symlinks = [];
+ for (const line of out.split('\n')) {
+ if (line.startsWith('120000 ')) {
+ symlinks.push(line.split('\t')[1]);
+ }
+ }
+ return symlinks;
+}
+
+// ---------------------------------------------------------------------------
+// 2. Unsatisfied peer dependencies in the production lock tree
+// ---------------------------------------------------------------------------
+
+// Known-unsatisfied peers verified unused at runtime (types-only packages,
+// react-native in a web app, codegen CLIs, optional transports). Keyed as
+// "<importer package name>|<peer name>" so npm dedupe moves don't churn the
+// list. Anything NOT listed here fails the audit: either install the peer or,
+// after verifying the code paths that need it are never reached, add it here
+// with a justification.
+const KNOWN_UNUSED_PEERS = new Set([
+ '@solana/pay|@solana-program/memo', // memo ix builder — we never attach memos via @solana/pay
+ '@solana/pay|@solana-program/token-2022', // token-2022 transfers unused (legacy SPL only)
+ '@solana/pay|@solana/kit-plugin-instruction-plan', // kit plugin paths unused
+ '@solana/pay|@solana/kit-plugin-payer', // kit plugin paths unused
+ '@solana/pay|@solana/kit-plugin-rpc', // kit plugin paths unused
+ '@hey-api/client-fetch|@hey-api/openapi-ts', // codegen CLI, build-time only
+ '@lit/react|@types/react', // types-only
+ '@recast-navigation/three|@types/three', // types-only
+ '@solana-mobile/mobile-wallet-adapter-protocol|react-native', // web build never hits RN paths
+ '@solana/codecs-strings|fastestsmallesttextencoderdecoder', // polyfill for envs without TextEncoder; Node has it
+ '@types/react-transition-group|@types/react', // types-only
+ 'arweave-stream-tx|arweave', // arweave upload path unused
+ 'colyseus|@colyseus/uwebsockets-transport', // we use the default WS transport
+ 'livekit-client|@types/dom-mediacapture-record', // types-only
+ 'react-native-webrtc|react-native', // web build never hits RN paths
+]);
+
+function packageNameFromLockPath(lockPath) {
+ const idx = lockPath.lastIndexOf('node_modules/');
+ return idx === -1 ? lockPath : lockPath.slice(idx + 'node_modules/'.length);
+}
+
+/**
+ * Walks package-lock.json and returns every non-optional peerDependency of a
+ * production package that does not resolve anywhere in the importer's
+ * node_modules ancestor chain. This is exactly the hole legacy-peer-deps
+ * opens: npm records the peer requirement but never installs it.
+ */
+export function findUnsatisfiedPeers({ lock } = {}) {
+ if (!lock) {
+ lock = JSON.parse(readFileSync(resolve(ROOT, 'package-lock.json'), 'utf8'));
+ }
+ const pkgs = lock.packages || {};
+ const problems = [];
+ for (const [path, info] of Object.entries(pkgs)) {
+ if (!path || info.link) continue;
+ if (info.dev || info.devOptional) continue;
+ const peers = info.peerDependencies || {};
+ const meta = info.peerDependenciesMeta || {};
+ for (const peer of Object.keys(peers)) {
+ if (meta[peer]?.optional) continue;
+ let found = false;
+ let base = path;
+ for (;;) {
+ const candidate = `${base ? `${base}/` : ''}node_modules/${peer}`;
+ if (pkgs[candidate]) {
+ found = true;
+ break;
+ }
+ const idx = base.lastIndexOf('node_modules/');
+ if (idx === -1) break;
+ base = base.slice(0, idx).replace(/\/$/, '');
+ }
+ if (!found && !pkgs[`node_modules/${peer}`]) {
+ const key = `${packageNameFromLockPath(path)}|${peer}`;
+ if (!KNOWN_UNUSED_PEERS.has(key)) {
+ problems.push({ importer: path, peer });
+ }
+ }
+ }
+ }
+ return problems;
+}
+
+// ---------------------------------------------------------------------------
+// 3. Undeclared bare imports in api/
+// ---------------------------------------------------------------------------
+
+function bareSpecifierToPackageName(spec) {
+ const parts = spec.split('/');
+ return spec.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
+}
+
+function workspacePackageNames(rootPkg) {
+ const names = new Set();
+ for (const pattern of rootPkg.workspaces || []) {
+ for (const dir of globSync(pattern, { cwd: ROOT })) {
+ const manifest = resolve(ROOT, dir, 'package.json');
+ if (!existsSync(manifest)) continue;
+ try {
+ const { name } = JSON.parse(readFileSync(manifest, 'utf8'));
+ if (name) names.add(name);
+ } catch {
+ // unreadable workspace manifest — covered by npm install itself
+ }
+ }
+ }
+ return names;
+}
+
+/**
+ * Lexes every api/**∕*.js file (static AND literal dynamic imports) and
+ * returns bare specifiers whose package is not a Node builtin, not declared
+ * in package.json dependencies/optionalDependencies, and not a workspace
+ * package. Those imports work today only via hoisting from some transitive
+ * dependency — an upstream bump or dedupe deletes them with no signal until
+ * the function 500s at runtime.
+ */
+export async function findUndeclaredApiImports({ apiDir = resolve(ROOT, 'api') } = {}) {
+ await init;
+ const rootPkg = JSON.parse(readFileSync(resolve(ROOT, 'package.json'), 'utf8'));
+ const declared = new Set([
+ ...Object.keys(rootPkg.dependencies || {}),
+ ...Object.keys(rootPkg.optionalDependencies || {}),
+ ...workspacePackageNames(rootPkg),
+ ]);
+ const builtins = new Set(builtinModules);
+ const problems = [];
+ // Test and test-config files under api/ run via vitest only; they are never
+ // part of a deployed function bundle, so their devDep imports are fine.
+ const files = globSync('**/*.js', {
+ cwd: apiDir,
+ absolute: true,
+ ignore: ['**/*.test.js', '**/vitest.config.js'],
+ });
+ for (const file of files) {
+ let imports;
+ try {
+ [imports] = parse(readFileSync(file, 'utf8'));
+ } catch (err) {
+ problems.push({ file, specifier: null, reason: `parse error: ${err.message}` });
+ continue;
+ }
+ for (const imp of imports) {
+ const spec = imp.n;
+ if (!spec) continue; // non-literal dynamic import
+ if (spec.startsWith('.') || spec.startsWith('/') || spec.startsWith('node:')) continue;
+ const name = bareSpecifierToPackageName(spec);
+ if (builtins.has(name) || declared.has(name)) continue;
+ problems.push({
+ file,
+ specifier: spec,
+ reason: 'not declared in package.json dependencies',
+ });
+ }
+ }
+ return problems;
+}
+
+// ---------------------------------------------------------------------------
+// CLI
+// ---------------------------------------------------------------------------
+
+const isMain = process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url);
+if (isMain) {
+ const start = Date.now();
+ let failed = false;
+
+ const symlinks = findCommittedSymlinks();
+ if (symlinks.length) {
+ failed = true;
+ console.error(
+ `[audit:deploy] FAIL — ${symlinks.length} committed symlink(s); Vercel's bundler cannot resolve them (broke every deploy after c96cdefd):`,
+ );
+ for (const s of symlinks) console.error(` ${s} → replace with a real copy of the target`);
+ }
+
+ const peers = findUnsatisfiedPeers();
+ if (peers.length) {
+ failed = true;
+ console.error(
+ `[audit:deploy] FAIL — ${peers.length} unsatisfied peer dependency(ies); legacy-peer-deps never installs peers, so these are missing at runtime (the @solana-program/stake outage):`,
+ );
+ for (const { importer, peer } of peers) {
+ console.error(
+ ` ${importer} requires ${peer} → add "${peer}" to package.json dependencies (or allowlist in scripts/audit-deploy-artifacts.mjs after verifying it is unused)`,
+ );
+ }
+ }
+
+ const undeclared = await findUndeclaredApiImports();
+ if (undeclared.length) {
+ failed = true;
+ console.error(
+ `[audit:deploy] FAIL — ${undeclared.length} undeclared bare import(s) in api/; phantom deps vanish on dedupe:`,
+ );
+ for (const { file, specifier, reason } of undeclared) {
+ console.error(` ${file}: ${specifier ?? ''} (${reason})`);
+ }
+ }
+
+ const elapsed = ((Date.now() - start) / 1000).toFixed(1);
+ if (failed) {
+ console.error(`\n[audit:deploy] failed in ${elapsed}s`);
+ process.exit(1);
+ }
+ console.log(
+ `[audit:deploy] clean in ${elapsed}s — no committed symlinks, no unsatisfied peers, no undeclared api imports`,
+ );
+}
diff --git a/scripts/build-vercel.mjs b/scripts/build-vercel.mjs
index 9933e95de..adb19bab9 100644
--- a/scripts/build-vercel.mjs
+++ b/scripts/build-vercel.mjs
@@ -190,8 +190,12 @@ try {
// @three-ws/agent-payments (not in its EXTERNALS), so the SDK dist must
// exist before esbuild resolves it — sdk-dist gates bundle-api; prebuild
// stays parallel.
- phase(1, 'prebuild ∥ (sdk-dist → bundle-api)');
+ phase(1, 'audit:deploy ∥ prebuild ∥ (sdk-dist → bundle-api)');
await Promise.all([
+ // Fails in seconds on committed symlinks, unsatisfied peer deps, or
+ // undeclared api/ imports — the classes behind the 2026-06-11 outage —
+ // instead of 18 minutes into NFT tracing or, worse, at runtime.
+ run('audit:deploy', 'node scripts/audit-deploy-artifacts.mjs'),
prebuild(),
ensureSDKDist().then(bundleApi),
]);
diff --git a/scripts/bundle-api.mjs b/scripts/bundle-api.mjs
index a6f48adf0..490a62643 100644
--- a/scripts/bundle-api.mjs
+++ b/scripts/bundle-api.mjs
@@ -248,6 +248,60 @@ for (const f of routeFiles) {
}
}
+// Verify every bare specifier the bundles still import (the EXTERNALS above)
+// resolves from node_modules. esbuild never checks externals, and NFT silently
+// skips ones it can't resolve — so a missing external only surfaces as a
+// runtime ERR_MODULE_NOT_FOUND. That is exactly how the 2026-06-11 outage
+// shipped: helius-sdk (inlined) imports @solana-program/stake (external via
+// the @solana-program/* pattern), the package was an uninstalled peer dep,
+// and every /api/cron/* invocation died at module load. Fail the build here,
+// seconds in, instead.
+const { init: lexerInit, parse: lexerParse } = await import('es-module-lexer');
+await lexerInit;
+const externalSpecifiers = new Map(); // specifier -> { firstUser, static }
+for (const f of routeFiles) {
+ let imports;
+ try {
+ [imports] = lexerParse(await readFile(f, 'utf8'));
+ } catch {
+ continue; // unparseable bundles are already reported via individualFailures/stillRaw
+ }
+ for (const imp of imports) {
+ const spec = imp.n;
+ if (!spec || spec.startsWith('.') || spec.startsWith('/') || spec.startsWith('node:'))
+ continue;
+ const isStatic = imp.d === -1;
+ const seen = externalSpecifiers.get(spec);
+ if (!seen) {
+ externalSpecifiers.set(spec, { firstUser: relative(ROOT, f), static: isStatic });
+ } else if (isStatic && !seen.static) {
+ seen.static = true;
+ seen.firstUser = relative(ROOT, f);
+ }
+ }
+}
+// A missing STATIC import crashes the function at module load (the
+// @solana-program/stake outage). A missing DYNAMIC import only throws if its
+// code path runs, and packages guard optional peers exactly that way (e.g.
+// resend's try/catch around @react-email/render) — warn, don't fail.
+const unresolvableExternals = [];
+const unresolvableDynamic = [];
+for (const [spec, { firstUser, static: isStatic }] of externalSpecifiers) {
+ try {
+ import.meta.resolve(spec);
+ } catch {
+ (isStatic ? unresolvableExternals : unresolvableDynamic).push({ spec, firstUser });
+ }
+}
+if (unresolvableDynamic.length) {
+ console.warn(
+ `\n[bundle-api] WARNING — ${unresolvableDynamic.length} dynamically-imported external(s) do not resolve; fine if the import is guarded (optional peer), a crash if that code path runs:`,
+ );
+ for (const { spec, firstUser } of unresolvableDynamic) {
+ console.warn(` ${spec} (first imported by ${firstUser})`);
+ }
+}
+
const elapsed = ((Date.now() - start) / 1000).toFixed(1);
const sizes = await Promise.all(routeFiles.map(async (f) => (await stat(f)).size));
const totalKB = (sizes.reduce((s, n) => s + n, 0) / 1024).toFixed(0);
@@ -279,8 +333,20 @@ if (stillRaw.length) {
if (stillRaw.length > 25) console.error(` …and ${stillRaw.length - 25} more`);
}
+if (unresolvableExternals.length) {
+ console.error(
+ `\n[bundle-api] FAILED — ${unresolvableExternals.length} external import(s) in the bundled output do not resolve from node_modules (would crash at runtime with ERR_MODULE_NOT_FOUND):`,
+ );
+ for (const { spec, firstUser } of unresolvableExternals) {
+ console.error(
+ ` ${spec} (first imported by ${firstUser}) → add it to package.json dependencies; if it came through a peerDependency, remember legacy-peer-deps never auto-installs peers`,
+ );
+ }
+}
+
// Fail fast on the build container instead of letting Vercel time out at 45 min
-// trying to NFT-trace raw route files against the 2 GB node_modules tree.
-if (individualFailures.length > 0 || stillRaw.length > 0) {
+// trying to NFT-trace raw route files against the 2 GB node_modules tree, or —
+// worse — deploy bundles whose runtime imports are missing.
+if (individualFailures.length > 0 || stillRaw.length > 0 || unresolvableExternals.length > 0) {
process.exit(1);
}
diff --git a/tests/deploy-artifacts.test.js b/tests/deploy-artifacts.test.js
new file mode 100644
index 000000000..ca235933f
--- /dev/null
+++ b/tests/deploy-artifacts.test.js
@@ -0,0 +1,107 @@
+// Guards against the deploy-artifact failure classes behind the 2026-06-11
+// production outage (465 consecutive 500s, every deploy red for 90 minutes):
+//
+// 1. Committed symlinks — Vercel's function bundler cannot resolve them;
+// data/skills/metamask-* killed every build after ~18 min of tracing.
+// 2. Unsatisfied peer dependencies — .npmrc legacy-peer-deps=true means npm
+// never auto-installs peers; helius-sdk 3.0's @solana-program/stake peer
+// silently vanished and every /api/cron/* died with ERR_MODULE_NOT_FOUND.
+// 3. Undeclared (phantom) bare imports in api/ — they resolve today only via
+// hoisting from some transitive dep, and disappear on the next dedupe.
+//
+// The same checks gate the Vercel build (scripts/build-vercel.mjs phase 1);
+// running them here means `npm test` catches the regression before a push.
+
+import { describe, it, expect } from 'vitest';
+import {
+ findCommittedSymlinks,
+ findUnsatisfiedPeers,
+ findUndeclaredApiImports,
+} from '../scripts/audit-deploy-artifacts.mjs';
+
+describe('deploy artifacts', () => {
+ it('has no committed symlinks (Vercel function tracing cannot resolve them)', () => {
+ expect(findCommittedSymlinks()).toEqual([]);
+ });
+
+ it('has no unsatisfied non-optional peer dependencies in the production lock tree', () => {
+ expect(findUnsatisfiedPeers()).toEqual([]);
+ });
+
+ it('has no undeclared bare imports in api/', async () => {
+ expect(await findUndeclaredApiImports()).toEqual([]);
+ });
+});
+
+describe('findUnsatisfiedPeers logic', () => {
+ it('flags a missing non-optional peer (the @solana-program/stake class)', () => {
+ const lock = {
+ packages: {
+ '': { dependencies: { 'some-sdk': '^1.0.0' } },
+ 'node_modules/some-sdk': {
+ version: '1.0.0',
+ peerDependencies: { 'missing-peer': '^2.0.0' },
+ },
+ },
+ };
+ expect(findUnsatisfiedPeers({ lock })).toEqual([
+ { importer: 'node_modules/some-sdk', peer: 'missing-peer' },
+ ]);
+ });
+
+ it('accepts a peer satisfied at the root', () => {
+ const lock = {
+ packages: {
+ '': {},
+ 'node_modules/some-sdk': {
+ version: '1.0.0',
+ peerDependencies: { 'present-peer': '^2.0.0' },
+ },
+ 'node_modules/present-peer': { version: '2.1.0' },
+ },
+ };
+ expect(findUnsatisfiedPeers({ lock })).toEqual([]);
+ });
+
+ it('accepts a peer satisfied by a nested install on the ancestor chain', () => {
+ const lock = {
+ packages: {
+ '': {},
+ 'node_modules/parent/node_modules/child': {
+ version: '1.0.0',
+ peerDependencies: { 'nested-peer': '^1.0.0' },
+ },
+ 'node_modules/parent/node_modules/nested-peer': { version: '1.0.0' },
+ },
+ };
+ expect(findUnsatisfiedPeers({ lock })).toEqual([]);
+ });
+
+ it('respects peerDependenciesMeta.optional', () => {
+ const lock = {
+ packages: {
+ '': {},
+ 'node_modules/some-sdk': {
+ version: '1.0.0',
+ peerDependencies: { 'optional-peer': '^2.0.0' },
+ peerDependenciesMeta: { 'optional-peer': { optional: true } },
+ },
+ },
+ };
+ expect(findUnsatisfiedPeers({ lock })).toEqual([]);
+ });
+
+ it('ignores dev-only packages (not installed on Vercel function runtime path)', () => {
+ const lock = {
+ packages: {
+ '': {},
+ 'node_modules/dev-tool': {
+ version: '1.0.0',
+ dev: true,
+ peerDependencies: { 'missing-peer': '^2.0.0' },
+ },
+ },
+ };
+ expect(findUnsatisfiedPeers({ lock })).toEqual([]);
+ });
+});