Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(build): ship app/peer-stamp.mjs in npm pack (server-ws.mjs hard-dep)

diegosouzapwa9f1e7f5b430
diff --git a/scripts/build/pack-artifact-policy.ts b/scripts/build/pack-artifact-policy.ts
index bb03860db4..5a7c768d4f 100644
--- a/scripts/build/pack-artifact-policy.ts
+++ b/scripts/build/pack-artifact-policy.ts
@@ -32,6 +32,7 @@ export const APP_STAGING_ALLOWED_EXACT_PATHS: string[] = [
"docs/reference/openapi.yaml",
"open-sse/mcp-server/server.js",
"package.json",
+ "peer-stamp.mjs",
"responses-ws-proxy.mjs",
"scripts/dev/sync-env.mjs",
"server.js",
@@ -104,6 +105,7 @@ export const PACK_ARTIFACT_REQUIRED_PATHS: string[] = [
"app/server.js",
"app/server-ws.mjs",
"app/responses-ws-proxy.mjs",
+ "app/peer-stamp.mjs",
"bin/cli/program.mjs",
"bin/mcp-server.mjs",
"bin/nodeRuntimeSupport.mjs",
diff --git a/scripts/build/prepublish.ts b/scripts/build/prepublish.ts
index c784076e3c..6d3f861015 100644
--- a/scripts/build/prepublish.ts
+++ b/scripts/build/prepublish.ts
@@ -202,13 +202,19 @@ cpSync(standaloneDir, APP_DIR, { recursive: true });
const standaloneWsSrc = join(ROOT, "scripts", "dev", "standalone-server-ws.mjs");
const responsesWsProxySrc = join(ROOT, "scripts", "dev", "responses-ws-proxy.mjs");
-if (existsSync(standaloneWsSrc) && existsSync(responsesWsProxySrc)) {
+const peerStampSrc = join(ROOT, "scripts", "dev", "peer-stamp.mjs");
+if (existsSync(standaloneWsSrc) && existsSync(responsesWsProxySrc) && existsSync(peerStampSrc)) {
console.log(" 📋 Adding Responses WebSocket standalone wrapper...");
cpSync(standaloneWsSrc, join(APP_DIR, "server-ws.mjs"));
writeFileSync(
join(APP_DIR, "responses-ws-proxy.mjs"),
'export * from "../scripts/dev/responses-ws-proxy.mjs";\n'
);
+ // server-ws.mjs imports ./peer-stamp.mjs (the trusted peer-IP stamp helper
+ // the authz middleware relies on). It is self-contained (node builtins only),
+ // so copy it directly alongside server-ws.mjs. Without this the wrapper throws
+ // ERR_MODULE_NOT_FOUND on boot and the server falls back to no peer stamp.
+ cpSync(peerStampSrc, join(APP_DIR, "peer-stamp.mjs"));
}
// ── Next.js Turbopack Standalone Tracer Fix ───────────────