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(inspector): return 'unknown' from kindDetector for unclear signals (B1)
diegosouzapw9df7cad803db
diff --git a/src/mitm/inspector/kindDetector.ts b/src/mitm/inspector/kindDetector.tsindex 7b7c04a4be..3bc98d7b4e 100644--- a/src/mitm/inspector/kindDetector.ts+++ b/src/mitm/inspector/kindDetector.ts@@ -61,12 +61,15 @@ export function detectKind(req: InterceptedRequest): "llm" | "app" | "unknown" {if (LLM_HOST_PATTERNS.some((re) => re.test(req.host))) return "llm";if (LLM_PATH_PATTERNS.some((re) => re.test(req.path))) return "llm";+ let bodySignalFired = false;if (req.requestBody) {try {const parsed = JSON.parse(req.requestBody) as unknown;if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {const body = parsed as Record<string, unknown>;if (LLM_BODY_SHAPES.some((shape) => matchesShape(body, shape))) return "llm";+ // Body parsed as a JSON object but had no LLM shape — clear app signal.+ bodySignalFired = true;}} catch {// Non-JSON body — cannot detect from body@@ -76,7 +79,10 @@ export function detectKind(req: InterceptedRequest): "llm" | "app" | "unknown" {const ua = req.requestHeaders["user-agent"] ?? req.requestHeaders["User-Agent"] ?? "";if (LLM_UA_PATTERN.test(ua)) return "llm";- return "app";+ // Return "app" only when at least one non-LLM signal fired (a parseable JSON body+ // with no LLM shape), indicating the request has recognisable app context.+ // Otherwise nothing was detectable — return "unknown".+ return bodySignalFired ? "app" : "unknown";}/**diff --git a/tests/unit/inspector-kind-detector.test.ts b/tests/unit/inspector-kind-detector.test.tsindex c7b0fa3344..95a526ee1c 100644--- a/tests/unit/inspector-kind-detector.test.ts+++ b/tests/unit/inspector-kind-detector.test.ts@@ -65,8 +65,25 @@ test("detectKind — UA 'antigravity/1.0' → llm", () => {);});-test("detectKind — random.example.com with no clues → app", () => {- assert.equal(detectKind(makeReq({ host: "random.example.com" })), "app");+test("detectKind — random.example.com with no clues → unknown", () => {+ assert.equal(detectKind(makeReq({ host: "random.example.com" })), "unknown");+});++test("detectKind — returns 'unknown' when nothing is detectable (empty body, no UA, unknown host)", () => {+ const req = makeReq({+ host: "internal.example.corp",+ path: "/api/v2/resource",+ requestBody: null,+ requestHeaders: {},+ });+ assert.equal(detectKind(req), "unknown");+});++test("detectKind — non-LLM JSON body → app", () => {+ const req = makeReq({+ requestBody: JSON.stringify({ userId: 42, action: "click" }),+ });+ assert.equal(detectKind(req), "app");});test("detectKind — path /v1/chat/completions → llm", () => {