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(mitm): inject x-omniroute-source and x-omniroute-agent headers in server.cjs intercept (C2, master plan §3.5)

diegosouzapw669b5fe4f575
diff --git a/src/mitm/server.cjs b/src/mitm/server.cjs
index a22428b098..0543b80a23 100644
--- a/src/mitm/server.cjs
+++ b/src/mitm/server.cjs
@@ -367,11 +367,21 @@ async function intercept(req, res, bodyBuffer, mappedModel) {
const body = JSON.parse(bodyBuffer.toString());
body.model = mappedModel;
+ // C2 — Inject AgentBridge correlation headers per master plan §3.5.
+ // The OmniRoute router uses these to distinguish AgentBridge traffic from
+ // other inbound clients and to record the originating IDE agent id.
+ // Resolve agent id from the Host header against the target map; defensive
+ // fallback to "unknown" when the host is somehow not in the map.
+ const reqHost = String(req.headers.host || "").split(":")[0].toLowerCase();
+ const agentId = TARGET_HOST_AGENT.get(reqHost) || "unknown";
+
const response = await fetch(ROUTER_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${API_KEY}`,
+ "x-omniroute-source": "agent-bridge",
+ "x-omniroute-agent": agentId,
},
body: JSON.stringify(body),
});