# v0.4.52 (2026-05-17)

## Features
- Add Vercel AI Gateway provider support (#1183)
- rtk: Kiro format tool result compression — handle conversationState.history & currentMessage, preserve error results, ~13.6% savings (#1194)

## Fixes
- openclaw: normalize agent.model object form `{primary, fallbacks}` before .startsWith → fix TypeError & 'not configured' status (#1216)
- Usage Details pagination: stay inside mobile viewport <640px (#1218)
- Fix test model error
- Fix MIMO provider in Codex
- Disable log file creation when using MITM AG
This commit is contained in:
decolua
2026-05-17 16:37:26 +07:00
parent 9326589452
commit 9abbb8ad9b
12 changed files with 188 additions and 79 deletions

View File

@@ -1,5 +1,7 @@
// All intercepted domains + URL patterns per tool
const IS_DEV = process.env.NODE_ENV === "development";
const TARGET_HOSTS = [
"daily-cloudcode-pa.googleapis.com",
"cloudcode-pa.googleapis.com",
@@ -20,6 +22,19 @@ const MODEL_SYNONYMS = {
antigravity: { "gemini-default": "gemini-3-flash" },
};
// Pattern fallback: rawModel regex → canonical alias key (when exact + prefix match fail)
// Order matters: more specific patterns first. Catches AG renamed variants (e.g. gemini-pro-agent)
const MODEL_PATTERNS = {
antigravity: [
{ match: /flash/i, alias: "gemini-3-flash" },
{ match: /pro.*low|low.*pro/i, alias: "gemini-3.1-pro-low" },
{ match: /gemini.*pro|pro.*gemini/i, alias: "gemini-3.1-pro-high" },
{ match: /opus/i, alias: "claude-opus-4-6-thinking" },
{ match: /sonnet|claude/i, alias: "claude-sonnet-4-6" },
{ match: /gpt.*oss|oss/i, alias: "gpt-oss-120b-medium" },
],
};
// URL substrings whose request/response should NOT be dumped to file (telemetry, polling, empty)
const LOG_BLACKLIST_URL_PARTS = [
"recordCodeAssistMetrics",
@@ -38,4 +53,4 @@ function getToolForHost(host) {
return null;
}
module.exports = { TARGET_HOSTS, URL_PATTERNS, MODEL_SYNONYMS, LOG_BLACKLIST_URL_PARTS, getToolForHost };
module.exports = { IS_DEV, TARGET_HOSTS, URL_PATTERNS, MODEL_SYNONYMS, MODEL_PATTERNS, LOG_BLACKLIST_URL_PARTS, getToolForHost };

View File

@@ -1,4 +1,5 @@
const { err, createResponseDumper } = require("../logger");
const { IS_DEV } = require("../config");
const { fetchRouter, pipeSSE } = require("./base");
/**
@@ -7,7 +8,7 @@ const { fetchRouter, pipeSSE } = require("./base");
* runs antigravity→openai→provider→openai→antigravity translators internally.
*/
async function intercept(req, res, bodyBuffer, mappedModel) {
const dumper = createResponseDumper(req, "intercept-antigravity");
const dumper = IS_DEV ? createResponseDumper(req, "intercept-antigravity") : null;
const isStream = req.url.includes(":streamGenerateContent");
try {
const body = JSON.parse(bodyBuffer.toString());

View File

@@ -1,11 +1,13 @@
const { err } = require("../logger");
const { IS_DEV } = require("../config");
const { fetchRouter } = require("./base");
const fs = require("fs");
const path = require("path");
// Debug trace log — written to data/logs/mitm/kiro-debug.log
// Debug trace log — written to data/logs/mitm/kiro-debug.log (dev only)
const DEBUG_LOG = path.join(__dirname, "../../../data/logs/mitm/kiro-debug.log");
function dbg(msg) {
if (!IS_DEV) return;
try {
fs.appendFileSync(DEBUG_LOG, `${new Date().toISOString()} ${msg}\n`);
} catch {}

View File

@@ -14,6 +14,16 @@ const err = (msg) => console.error(`[${time()}] ❌ [MITM] ${msg}`);
const DUMP_DIR = path.join(DATA_DIR, "logs", "mitm");
if (!fs.existsSync(DUMP_DIR)) fs.mkdirSync(DUMP_DIR, { recursive: true });
// Clear all files inside DUMP_DIR (called on MITM server start to avoid unbounded growth)
function clearDumpDir() {
try {
if (!fs.existsSync(DUMP_DIR)) return;
for (const f of fs.readdirSync(DUMP_DIR)) {
try { fs.rmSync(path.join(DUMP_DIR, f), { recursive: true, force: true }); } catch { /* ignore */ }
}
} catch { /* ignore */ }
}
const EMPTY_BODY_RE = /^\s*(\{\s*\}|\[\s*\]|null)?\s*$/;
function slugify(s, max = 80) {
@@ -93,4 +103,4 @@ function createResponseDumper(req, tag = "raw") {
};
}
module.exports = { log, err, dumpRequest, createResponseDumper };
module.exports = { log, err, dumpRequest, createResponseDumper, clearDumpDir };

View File

@@ -4,14 +4,17 @@ const path = require("path");
const dns = require("dns");
const { promisify } = require("util");
const { execSync } = require("child_process");
const { log, err, dumpRequest, createResponseDumper } = require("./logger");
const { TARGET_HOSTS, URL_PATTERNS, MODEL_SYNONYMS, getToolForHost } = require("./config");
const { log, err, dumpRequest, createResponseDumper, clearDumpDir } = require("./logger");
const { IS_DEV, TARGET_HOSTS, URL_PATTERNS, MODEL_SYNONYMS, MODEL_PATTERNS, getToolForHost } = require("./config");
const { DATA_DIR, MITM_DIR } = require("./paths");
const { getCertForDomain } = require("./cert/generate");
const { getMitmAlias } = require("./dbReader");
const LOCAL_PORT = 443;
const IS_WIN = process.platform === "win32";
const ENABLE_FILE_LOG = true;
const ENABLE_FILE_LOG = IS_DEV;
// Clear stale dump files on every MITM start (prevents unbounded disk usage)
clearDumpDir();
const INTERNAL_REQUEST_HEADER = { name: "x-request-source", value: "local" };
// Host rewrite for upstream forward: PROD cloudcode-pa is rate-limited (429),
@@ -108,7 +111,13 @@ function getMappedModel(tool, model) {
if (aliases[lookup]) return aliases[lookup];
// Prefix match fallback
const prefixKey = Object.keys(aliases).find(k => k && aliases[k] && (lookup.startsWith(k) || k.startsWith(lookup)));
return prefixKey ? aliases[prefixKey] : null;
if (prefixKey) return aliases[prefixKey];
// Pattern fallback: catches AG renamed variants (e.g. gemini-pro-agent → gemini-3.1-pro-high)
const patterns = MODEL_PATTERNS?.[tool] || [];
for (const { match, alias } of patterns) {
if (match.test(lookup) && aliases[alias]) return aliases[alias];
}
return null;
} catch { return null; }
}