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
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
refactor(build): graceful agent-status stub + robust stub-drift guard (review feedback)
diegosouzapw7c2dc1cde6de
diff --git a/src/mitm/manager.stub.ts b/src/mitm/manager.stub.tsindex 9c70a5c647..bb3193f462 100644--- a/src/mitm/manager.stub.ts+++ b/src/mitm/manager.stub.ts@@ -13,13 +13,14 @@ export const clearCachedPassword = () => {};export const getMitmStatus = async () => {throw new Error(STUB_ERROR);};-// Statically imported by /api/tools/agent-bridge/state — the stub must export it or-// the Turbopack build fails ("Export getAllAgentsStatus doesn't exist"). MITM/agent-// bridge needs host-level access and is non-functional in the bundled build anyway,-// so this throws like the other heavy ops. See issue #3066.-export const getAllAgentsStatus = (): never => {- throw new Error(STUB_ERROR);-};+// Statically imported by /api/tools/agent-bridge/state, so the stub MUST export it or+// the Turbopack build fails ("Export getAllAgentsStatus doesn't exist"). Unlike the+// heavy ops above (dynamic-import paths that should never hit the stub at runtime), a+// static import IS baked into the bundled build, so this is legitimately reached at+// runtime there — it returns the truthful "no agents" state (an empty list) instead of+// throwing. MITM/agent bridge needs host-level access and is otherwise non-functional+// in a bundled/container build. See issue #3066.+export const getAllAgentsStatus = (): never[] => [];export const startMitm = async (_apiKey: string,_sudoPassword: string,diff --git a/tests/unit/next-config.test.ts b/tests/unit/next-config.test.tsindex 96430e30ca..a6f1869a4f 100644--- a/tests/unit/next-config.test.ts+++ b/tests/unit/next-config.test.ts@@ -136,9 +136,10 @@ test("manager.stub.ts exports every name statically imported from @/mitm/managerconst imported = new Set<string>();collectImports(appDir, imported);- // Sanity: the suite is meaningless if it finds nothing to check.+ // Sanity: the guard is meaningless if the scan finds nothing to check. Kept generic+ // (>= 1 import) rather than asserting a specific symbol, so the test stays valid if any+ // single agent-bridge/traffic-inspector route is later renamed or removed.assert.ok(imported.size > 0, "expected at least one static @/mitm/manager import in src/app");- assert.ok(imported.has("getAllAgentsStatus"), "fixture: agent-bridge/state imports getAllAgentsStatus");const stubSrc = fs.readFileSync(path.join(process.cwd(), "src", "mitm", "manager.stub.ts"),