mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-25 16:42:16 +03:00
Validated on the resolved merge against the current tip (527da656 + the post-#11281 rebaseline): the single conflict was a comment-only collision in providers/[id]/models/route.ts (kept the tip's #10828-ordering note). Focused suites 125/125 across all 13 touched test files (build-sqlite-stub, cc-compatible, copilot-claude-messages, copilot-gemini-route, executor-github, ghe-copilot, github-copilot-discovery-token, github-copilot-model-discovery, noauth-sibling-7620, provider-header-profiles, provider-models-config, request-log-payloads, upstream-error-passthrough), typecheck:core clean, file-size/changelog-integrity OK. Merged --admin over the inherited 2026-08-23 base-red cluster (#9985) — the reds are proven tip failures (CLI catalog cluster + @testing-library allowlist, being drained by #11280), not from this diff. Note: the rebase means several items the body listed (relay x-relay-path SSRF, /v1/search blocked-providers, #10736 rotation fence, #10903, #10865, #10899, #10916) already landed upstream and are NOT in this delta — the delta is: better-sqlite3 build guard + build heap/worker caps + telemetry-off (#10060 re-derived), credential-echo passthrough refusal + OCR/moderation redaction + call-log key redaction, Copilot CLI 1.0.81-6 wire identity + Claude→/v1/messages name-matched routing + discovery token fix, CC model_not_found 400, compat overrides for no-auth aliases (#7620-pinned). The Copilot wire-identity change is the one to watch in production. Thank you @arminanton — and the ported-author credits in the commit history (@rqzbeh, yidecode, the #10899/#10916 authors) are preserved. Your config-posture finding (REQUIRE_API_KEY default vs 0.0.0.0) is noted for a maintainer decision, as you scoped it.
27 lines
1.2 KiB
TypeScript
27 lines
1.2 KiB
TypeScript
/**
|
|
* Single source of truth for "are we running inside the Next.js production
|
|
* build?" — a leaf module with zero imports so any layer (db/core, the driver
|
|
* factory, lazy copilot loaders, API routes) can depend on it without creating
|
|
* an import cycle.
|
|
*
|
|
* Three signals, OR'd, because no single one is reliable across every build
|
|
* worker:
|
|
* - NEXT_PHASE === "phase-production-build": set by Next.js on the main build
|
|
* process, but Next.js build WORKERS sometimes drop it from process.env.
|
|
* - OMNIROUTE_BUILDING === "1": set by scripts/build/build-next-isolated.mjs
|
|
* and inherited by every spawned build worker, so it survives where
|
|
* NEXT_PHASE does not (#10060).
|
|
* - npm_lifecycle_event === "build": set by npm when the process was launched
|
|
* via `npm run build`, a backstop for direct invocations.
|
|
*
|
|
* Evaluated per-call (not memoized) so tests can toggle the env vars and code
|
|
* paths that legitimately mutate them at startup are respected.
|
|
*/
|
|
export function isNextBuildPhase(): boolean {
|
|
return (
|
|
process.env.NEXT_PHASE === "phase-production-build" ||
|
|
process.env.OMNIROUTE_BUILDING === "1" ||
|
|
process.env.npm_lifecycle_event === "build"
|
|
);
|
|
}
|