fix: Codex 自动压缩不触发 —— 接管时链接模型目录(绝对路径)进 config.toml (hot 1.5.83)

This commit is contained in:
mac
2026-08-16 12:45:32 +08:00
parent e9a261482c
commit 1b687c01e9
50 changed files with 10885 additions and 1161 deletions
+88
View File
@@ -0,0 +1,88 @@
const test = require("node:test");
const assert = require("node:assert/strict");
const media = require("../electron/lib/media-understanding");
test("collectAttachments finds a Responses image part", () => {
const attachments = media.collectAttachments({
input: [{
type: "message",
role: "user",
content: [{ type: "input_image", image_url: "data:image/png;base64,abc" }],
}],
});
assert.equal(attachments.length, 1);
assert.equal(attachments[0].kind, "image");
});
test("collectAttachments finds standard Responses input_audio data", () => {
const attachments = media.collectAttachments({
input: [{
type: "message",
role: "user",
content: [{
type: "input_audio",
input_audio: { data: "YXVkaW8=", format: "wav" },
}],
}],
});
assert.equal(attachments.length, 1);
assert.equal(attachments[0].kind, "audio");
assert.equal(attachments[0].name, "audio.wav");
assert.equal(attachments[0].value, "YXVkaW8=");
});
test("enrichResponsesRequest injects MiniMax evidence without exposing credentials", async () => {
const previousKey = process.env.TD_MULTIMODAL_GATEWAY_KEY;
process.env.TD_MULTIMODAL_GATEWAY_KEY = "test-key";
const request = {
input: [{
type: "message",
role: "user",
content: [{ type: "input_image", image_url: "data:image/png;base64,abc" }],
}],
};
try {
const result = await media.enrichResponsesRequest(request, {
instruction: "图片里写了什么?",
fetchImpl: async () => ({
ok: true,
json: async () => ({
choices: [{
message: {
content: '{"summary":"界面截图","items":[{"kind":"ocr","text":"设置","confidence":0.99}]}',
},
}],
}),
}),
});
assert.equal(result.processed, true);
const last = request.input[0].content.at(-1);
assert.equal(last.type, "input_text");
assert.match(last.text, /界面截图/);
assert.doesNotMatch(last.text, /test-key/);
} finally {
if (previousKey == null) delete process.env.TD_MULTIMODAL_GATEWAY_KEY;
else process.env.TD_MULTIMODAL_GATEWAY_KEY = previousKey;
}
});
test("enrichResponsesRequest reports an unavailable gateway instead of empty image evidence", async () => {
const previousKey = process.env.TD_MULTIMODAL_GATEWAY_KEY;
delete process.env.TD_MULTIMODAL_GATEWAY_KEY;
const request = {
input: [{
type: "message",
role: "user",
content: [{ type: "input_image", image_url: "data:image/png;base64,abc" }],
}],
};
try {
const result = await media.enrichResponsesRequest(request);
assert.match(result.evidence.summary, /尚未注入访问密钥/);
assert.match(request.input[0].content.at(-1).text, /不能识别图片内容/);
} finally {
if (previousKey == null) delete process.env.TD_MULTIMODAL_GATEWAY_KEY;
else process.env.TD_MULTIMODAL_GATEWAY_KEY = previousKey;
}
});