Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 支持 Kimi Code 编程计划包月 Codex 路线图片桥接 (#3423)

LeeCarry22edc79840cd
diff --git a/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts b/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts
index 76e8f9e4e1..95869178d2 100644
--- a/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts
@@ -621,6 +621,14 @@ describe('chatBridgeCapabilitiesForRoute', () => {
expect(chatBridgeCapabilitiesForRoute(upstream, 'kimi-k3').imageInput).toBe('image_url');
});
+ it.each([
+ ['https://api.kimi.com/coding/v1', 'k3'],
+ ['https://api.kimi.com/coding/v1/', 'k3-256k'],
+ ])('enables image_url for Kimi Code coding-plan route: %s / %s (#2732)', async (upstream, model) => {
+ const { chatBridgeCapabilitiesForRoute } = await freshCodexProxyHost();
+ expect(chatBridgeCapabilitiesForRoute(upstream, model).imageInput).toBe('image_url');
+ });
+
it.each([
['https://ark.cn-beijing.volces.com/api/v3', 'doubao-seed-2-1-pro-260628'],
['https://ark.ap-southeast-1.volces.com/api/v3/', 'doubao-seed-1-6-vision-260615'],
@@ -642,6 +650,12 @@ describe('chatBridgeCapabilitiesForRoute', () => {
it.each([
['https://api.moonshot.cn/v1', 'kimi-k2.6'],
+ // Kimi Code: non-HTTPS, spoofed subdomain, and models without verified image support stay closed.
+ ['http://api.kimi.com/coding/v1', 'k3'],
+ ['https://api.kimi.com.evil.example/coding/v1', 'k3'],
+ ['https://api.kimi.com/coding/v1', 'kimi-k3'],
+ ['https://api.kimi.com/coding/v1', 'kimi-for-coding'],
+ ['https://api.moonshot.cn/v1', 'k3'],
['https://api.deepseek.com/v1', 'kimi-k3'],
['https://api.moonshot.cn.evil.example/v1', 'kimi-k3'],
['http://api.moonshot.cn/v1', 'kimi-k3'],
diff --git a/apps/desktop/src/main/maker-host/codex-proxy-host.ts b/apps/desktop/src/main/maker-host/codex-proxy-host.ts
index a169678d38..f208d14e9f 100644
--- a/apps/desktop/src/main/maker-host/codex-proxy-host.ts
+++ b/apps/desktop/src/main/maker-host/codex-proxy-host.ts
@@ -754,6 +754,10 @@ function isGoogleGeminiChatUpstream(upstream: string): boolean {
}
const MOONSHOT_CHAT_HOSTS = new Set(['api.moonshot.cn', 'api.moonshot.ai']);
+/** Kimi Code (coding plan) official endpoint DNS boundary. */
+const KIMI_CODING_CHAT_HOST = 'api.kimi.com';
+/** Model ids on the Kimi Code Codex (openai-chat) route verified for image input. */
+const KIMI_CODING_IMAGE_CHAT_MODELS = new Set(['k3', 'k3-256k']);
/** 火山方舟(豆包)官方 DNS 边界:ark.<region>.volces.com(如 ark.cn-beijing.volces.com)。 */
const VOLCENGINE_ARK_CHAT_HOST_RE = /^ark\.[a-z0-9-]+\.volces\.com$/;
/** 阿里云百炼 Coding Plan / Token Plan / 按量付费官方 DNS 边界。 */
@@ -798,6 +802,7 @@ function rewriteChatBridgeModel(model: string, stripPrefix: string | undefined):
* 在模型级多模态能力元数据接入路由前,图片桥接先按已验证的上游能力显式开启。
*
* 当前覆盖:
+ * - Kimi Code(编程计划包月)K3
* - Moonshot Kimi K3
* - Volcengine Doubao Seed 系列
* - Alibaba Cloud Bailian Coding Plan Qwen 3.7 Plus
@@ -828,6 +833,7 @@ function isVerifiedImageChatRoute(upstream: string, realModel: string): boolean
if (url.protocol !== 'https:') return false;
const host = url.hostname.toLowerCase();
if (realModel === 'kimi-k3') return MOONSHOT_CHAT_HOSTS.has(host);
+ if (KIMI_CODING_IMAGE_CHAT_MODELS.has(realModel)) return host === KIMI_CODING_CHAT_HOST;
if (isDoubaoVisionModel(realModel)) return VOLCENGINE_ARK_CHAT_HOST_RE.test(host);
if (isQwenImageChatModel(realModel)) return DASHSCOPE_CODING_CHAT_HOSTS.has(host);
return false;