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(providers): detect conflicting systems before choosing a preset

xdb6e5c370c553
diff --git a/apps/desktop/src/main/maker-host/__tests__/providerDetection.test.ts b/apps/desktop/src/main/maker-host/__tests__/providerDetection.test.ts
index 1d1db3c97d..d2646204a0 100644
--- a/apps/desktop/src/main/maker-host/__tests__/providerDetection.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/providerDetection.test.ts
@@ -30,6 +30,22 @@ describe('bounded deployment detection', () => {
expect(fetcher.mock.calls.length).toBeLessThanOrEqual(9);
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith('/health'))).toBe(false);
});
+ it.each(['lmstudio', 'llamacpp'])('does not let an early %s match hide a later Sub2API conflict', async early => {
+ const bodies: Record<string, unknown> = {
+ '/v1/models': { data: [{ id: 'one' }] },
+ '/api/v1/settings/public': { code: 0, data: { version: '0.2.17', hide_ccs_import_button: false, backend_mode_enabled: true, subscription_enabled: false } },
+ '/v1/sub2api/billing': { object: 'sub2api.key_billing', schema_version: 1 },
+ ...(early === 'lmstudio' ? { '/lmstudio-greeting': { lmstudio: true }, '/api/v1/models': { models: [] } }
+ : { '/props': { default_generation_settings: {}, total_slots: 1, build_info: 'b11723' } }),
+ };
+ const result = await detectProviderDeployment(spec, new AbortController().signal, async url => {
+ const body = bodies[new URL(String(url)).pathname.replace(/^\/team/, '')];
+ return body ? json(body) : json({ error: 'not found' }, 404);
+ });
+ expect(result.reason).toBe('conflict');
+ expect(result.candidates).toEqual(expect.arrayContaining([early, 'sub2api']));
+ expect(result.catalog).toMatchObject({ ok: true, models: [{ id: 'one' }] });
+ });
it.each([401, 403, 404, 429, 200])('keeps usable models when diagnostics fail with %s', async status => {
const result = await detectProviderDeployment(spec, new AbortController().signal, async url =>
String(url).endsWith('/v1/models') ? json({ data: [{ id: 'company-chat' }] }) : json({ error: 'unavailable' }, status));
diff --git a/apps/desktop/src/main/maker-host/provider-detection.ts b/apps/desktop/src/main/maker-host/provider-detection.ts
index 1346fbfdf6..4046d52535 100644
--- a/apps/desktop/src/main/maker-host/provider-detection.ts
+++ b/apps/desktop/src/main/maker-host/provider-detection.ts
@@ -59,7 +59,6 @@ export async function detectProviderDeployment(
const worker = async () => {
while (index < PROBES.length && !identitySignal.aborted) {
const probe = PROBES[index++];
- if (candidates.length && !candidates.includes(probe.system)) continue;
if (probe.auth === 'required' && !spec.apiKey?.trim()) continue;
const headers: Record<string, string> = {};
if (probe.auth) {
diff --git a/docs/product-rules/provider-auto-detection.md b/docs/product-rules/provider-auto-detection.md
index 1631481956..882a5bdacf 100644
--- a/docs/product-rules/provider-auto-detection.md
+++ b/docs/product-rules/provider-auto-detection.md
@@ -62,7 +62,7 @@ LM Studio 详情按 key 或 loaded_instances.id 关联,不把本机所有已
- 公开诊断请求不带 key 或自定义请求头。需要认证的诊断使用用户提供的 Bearer key;
可选认证用于 LM Studio 原生目录和 llama.cpp props。不要求管理员 key。
- 最多八个身份请求,同时最多两个,每个 3 秒,总身份预算 8 秒,单响应不超过 1 MiB。
- 已得到充分证据后不再启动其他系统请求,但会收完已发出的请求以发现冲突。
+ 在该预算内继续检查固定队列,不因先命中一种系统而跳过其他系统的冲突证据。
- 通用模型目录使用现有解析器、认证、分页和超时机制,响应上限 8 MiB;它与身份预算分别计时。
- 返回 Renderer 的只有候选、模型元数据和分类错误,绝不返回账单、诊断原文或凭证。
- IPC 复用供应商配置的可信本机窗口校验,按真实 sender 隔离取消;页面销毁、账号代次变化后结果不可复用。