all: each plugin fails with its built-in's status and marks the sign-in as it did, through X-Magpie-Sign-In (要保证插件跟内置的所有逻辑都要一模一样) — Factory's and MiMo's refused renewals are the built-ins' 502 marked expired, not 401s; Qoder's vendor 403 is the built-in's 401 kept, its model list's failure a 400, its job refresh refused marked expired; Zed's retried 401 is a 401 kept, not a 403; Kiro's unreachable refresh a 401 kept; Cursor's expired trial a 401 kept; a vendor 401 WorkBuddy, Grok, Devin, Command Code and ZCode passed on no longer marks the account, as their built-ins never did, and Grok and MiMo no longer retry what their built-ins sent once. Messages take the built-ins' words. New tests fail against the previous index.mjs.

This commit is contained in:
yetone
2026-10-01 04:47:03 +08:00
parent 53e0db6648
commit 85d7dd0d0a
38 changed files with 769 additions and 182 deletions
+16 -2
View File
@@ -719,12 +719,24 @@ function streamError(e) {
return failure(status || 500, msg)
}
// errorResponse is a failure as the built-in answered it, the account
// kept: the built-in never marked a Command Code account lapsed, a 401 of
// Command Code's among them.
const errorResponse = ({ status, message }) =>
new Response(JSON.stringify({ error: { message, type: "commandcode_error", code: status } }), {
status,
headers: { "Content-Type": "application/json" },
headers: { "Content-Type": "application/json", "X-Magpie-Sign-In": "kept" },
})
// kept is a Provider API answer, as it came, saying the account is kept.
function kept(res) {
const headers = new Headers(res.headers)
headers.delete("content-length")
headers.delete("content-encoding")
headers.set("X-Magpie-Sign-In", "kept")
return new Response(res.body, { status: res.status, statusText: res.statusText, headers })
}
// lines reads the reply a JSON object a line.
async function* lines(body) {
const dec = new TextDecoder()
@@ -907,7 +919,9 @@ export async function CommandCodePlugin({ client } = {}) {
}
return generate(key, chat, init.signal)
}
return fetch(input, { ...init, headers })
// the Provider API's 401 went on as it came, the account kept
const res = await fetch(input, { ...init, headers })
return res.status === 401 ? kept(res) : res
},
}
},