fix(kiro): intercept chat via x-amz-target and prepend initial-response frame
Kiro IDE 1.0.228+ moved GenerateAssistantResponse from path /generateAssistantResponse to POST / + x-amz-target header, so chat turns bypassed MITM. The SmithyMessageDecoderStream also now requires an initial-response frame at stream start, and agent/vibe mode sends modelId "auto" which had no mappable slot. - Add isChatRequest() header-based match for kiro in mitm/config.js - Add buildInitialResponseFrame/withInitialFrame to emit the mandatory initial-response once per stream (kiro.js) - Add "auto" model slot and update mitmDomain to runtime.us-east-1.kiro.dev
This commit is contained in:
+19
-1
@@ -26,10 +26,28 @@ const TARGET_HOSTS = [
|
||||
const URL_PATTERNS = {
|
||||
antigravity: [":generateContent", ":streamGenerateContent"],
|
||||
copilot: ["/chat/completions", "/v1/messages", "/responses"],
|
||||
// Legacy path form. Kiro IDE 1.0.228+ posts to `/` with x-amz-target instead —
|
||||
// see isChatRequest() for the header-based match.
|
||||
kiro: ["/generateAssistantResponse"],
|
||||
cursor: ["/BidiAppend", "/RunSSE", "/RunPoll", "/Run"],
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether this request is a chat turn we should intercept (vs passthrough).
|
||||
* Kiro Runtime moved GenerateAssistantResponse from path `/generateAssistantResponse`
|
||||
* to `POST /` + `x-amz-target: KiroRuntimeService.GenerateAssistantResponse`
|
||||
* (verified via live mitmproxy capture of Kiro IDE 1.0.228).
|
||||
*/
|
||||
function isChatRequest(tool, req) {
|
||||
const patterns = URL_PATTERNS[tool] || [];
|
||||
if (patterns.some((p) => (req.url || "").includes(p))) return true;
|
||||
if (tool === "kiro") {
|
||||
const target = String(req.headers?.["x-amz-target"] || "");
|
||||
return target.includes("GenerateAssistantResponse");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Synonym map: rawModel from request → canonical alias key in mitmAlias DB
|
||||
const MODEL_SYNONYMS = {
|
||||
antigravity: {
|
||||
@@ -127,4 +145,4 @@ function extractModel(url, body) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { IS_DEV, LSOF_BIN, TARGET_HOSTS, URL_PATTERNS, MODEL_SYNONYMS, MODEL_PATTERNS, MODEL_NO_MAP, LOG_BLACKLIST_URL_PARTS, getToolForHost, extractModel };
|
||||
module.exports = { IS_DEV, LSOF_BIN, TARGET_HOSTS, URL_PATTERNS, MODEL_SYNONYMS, MODEL_PATTERNS, MODEL_NO_MAP, LOG_BLACKLIST_URL_PARTS, getToolForHost, isChatRequest, extractModel };
|
||||
|
||||
Reference in New Issue
Block a user