Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 无标题通道的供应商改走官方 Cindy AI 起名
Dashf55fce3d0c75
diff --git a/apps/desktop/src/main/maker-host/__tests__/titleOneShot.test.ts b/apps/desktop/src/main/maker-host/__tests__/titleOneShot.test.tsindex 9bc0669370..fc4324a2bb 100644--- a/apps/desktop/src/main/maker-host/__tests__/titleOneShot.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/titleOneShot.test.ts@@ -6,7 +6,8 @@* 2. buildTitleTarget:据 catalog titleModel 组装目标(模型 / 最低 effort / wire / upstream)* —— 同时锁定 providers.json 里三家 titleModel 的配置(haiku / gpt-5.4-mini / gpt-5.4-mini)。* 3. generateTitleViaProvider:三家 wire 各发一次 fetch,断言 URL/headers/body 形状 + 响应解析;- * 凭证缺失 / 非 2xx → 返回 null(不抛、不试别家)。+ * 凭证缺失 / 非 2xx → 返回 null(不抛;有标题 wire 的供应商不试别家)。+ * 无标题 wire 的会话供应商在官方 `xd` 已连接时回落官方通道。** electron 在此 mock(stub app.getPath)纯粹是为了让 import 链(auth-adapters 顶层单例)能在* 无 electron 的 vitest 里加载;真正的凭证 / fetch / 会话 provider 全部经 deps 注入,不碰真实实现。@@ -341,7 +342,7 @@ describe('generateTitleViaProvider — provider 解析', () => {});describe('generateTitleViaProviderResult — 手动重命名失败语义', () => {- it('direct custom DeepSeek 没有受支持的标题 wire → unsupported-provider', async () => {+ it('无标题 wire 的会话供应商且官方未连接 → unsupported-provider', async () => {const fetchImpl = fakeFetch(() => ({json: { choices: [{ message: { content: '不应出现' } }] },}));@@ -371,6 +372,43 @@ describe('generateTitleViaProviderResult — 手动重命名失败语义', () =>).resolves.toBeNull();});+ it('无标题 wire 的会话供应商 + 官方已连接 → 走 xd 网关', async () => {+ setXdGatewayModels([xdGatewayModel('deepseek/deepseek-v4-flash', 'chat')]);+ try {+ const fetchImpl = fakeFetch(() => ({+ json: { choices: [{ message: { content: '官方标题' } }] },+ }));++ await expect(+ generateTitleViaProviderResult(+ { sessionId: 's-deepseek-official', agentKind: 'claude-code', prompt: 'x' },+ {+ fetchImpl,+ readSessionProviderId: async () => 'deepseek',+ listConnectedProviders: async () => [providerStub('deepseek'), providerStub('xd')],+ readGatewayKey: () => 'gk',+ },+ ),+ ).resolves.toEqual({ status: 'ok', title: '官方标题' });+ expect(String(vi.mocked(fetchImpl).mock.calls[0][0])).toContain('/v1/chat/completions');++ // 自动起名同样走官方,不再折叠为启发式。+ await expect(+ generateTitleViaProvider(+ { sessionId: 's-deepseek-official', agentKind: 'claude-code', prompt: 'x' },+ {+ fetchImpl,+ readSessionProviderId: async () => 'deepseek',+ listConnectedProviders: async () => [providerStub('deepseek'), providerStub('xd')],+ readGatewayKey: () => 'gk',+ },+ ),+ ).resolves.toBe('官方标题');+ } finally {+ setXdGatewayModels([]);+ }+ });+it('XD 结构上受支持但实时目录暂无聊天模型 → failed', async () => {setXdGatewayModels([]);const result = await generateTitleViaProviderResult(diff --git a/apps/desktop/src/main/maker-host/title-one-shot.ts b/apps/desktop/src/main/maker-host/title-one-shot.tsindex edf5772a54..3fe015015c 100644--- a/apps/desktop/src/main/maker-host/title-one-shot.ts+++ b/apps/desktop/src/main/maker-host/title-one-shot.ts@@ -9,8 +9,11 @@* - xd 网关 → litellm chat-completions(`/v1/chat/completions`,Bearer 网关 key)** 约束(用户敲定):- * - **只试本会话的单一 provider,不做跨 provider 兜底**。凭证缺失 / HTTP 失败 / 空响应 → 返回- * null,调用方(renderer scheduleAutoName)回落到「消息前 N 字」启发式。+ * - **本会话供应商有标题 wire 时,只试这一家,不做跨 provider 兜底**。凭证缺失 /+ * HTTP 失败 / 空响应 → 返回 null,调用方(renderer scheduleAutoName)回落「消息前 N 字」启发式。+ * - **本会话供应商没有标题 wire 时,回落到官方 `xd`(个人账号 Cindy AI /企业登录 XD,同一+ * provider)**。官方未连接或组不出标题目标 → 手动重命名报 TITLE_PROVIDER_UNSUPPORTED,自动起名仍+ * 折叠为启发式。官方通道自己的凭证 / HTTP 失败同样不再 hop。* - **不实现 token 自动 refresh** —— OAuth/订阅 token 的刷新由 cc 子进程 / codex app-server 负责* (它们读写同一处凭证),本模块每次实时读当下值;过期就当次失败、优雅降级。* - 三条标题调用都**不注入任何 system / 身份提示词**(实测 anthropic 裸调即 200),不触及系统提示词。@@ -103,6 +106,9 @@ export type TitleOneShotResult =/** 当前实现具备完整凭证与 wire 契约的供应商;目标暂不可用不等于供应商不受支持。 */const TITLE_ONE_SHOT_PROVIDER_IDS = new Set(['anthropic', 'openai', 'xd']);+/** 无标题 wire 的会话供应商回落到官方 Cindy AI / XD 网关(同一 provider id)。 */+const OFFICIAL_TITLE_FALLBACK_ID = 'xd';+/** 注入点 —— 便于单测(mock fetch / 伪造凭证 / 伪造 provider)。缺省均返回 null(回落启发式)。 */export interface TitleOneShotDeps {fetchImpl?: FetchImpl;@@ -396,8 +402,8 @@ export function parseResponsesSse(raw: string): string {/*** 标题 oneShot 诊断入口:解析本会话 provider → titleModel → 单次 HTTP 起标题。- * 仅区分“当前供应商不支持”与通用失败,供手动 AI 重命名给出可操作提示。- * 全程不打印 token(只记 providerId / model / wire / 耗时)。+ * 无标题 wire 的会话供应商先回落官方 `xd`;仍组不出目标时才区分“当前供应商不支持”与通用失败,+ * 供手动 AI 重命名给出可操作提示。全程不打印 token(只记 providerId / model / wire / 耗时)。*/export async function generateTitleViaProviderResult(args: { sessionId: string; agentKind: AgentKind; prompt: string; signal?: AbortSignal },@@ -435,13 +441,31 @@ export async function generateTitleViaProviderResult(return { status: 'failed' };}- const target = buildTitleTarget(providerId);+ const sessionProviderId = providerId;+ let target = buildTitleTarget(providerId);+ // 无标题 wire 的会话供应商(自定义 DeepSeek / xAI 等)回落官方+ // Cindy AI / XD;有 wire 的三家仍不因组不出目标而 hop。+ if (!target && !TITLE_ONE_SHOT_PROVIDER_IDS.has(providerId)) {+ const officialConnected = rail.some((p) => p.id === OFFICIAL_TITLE_FALLBACK_ID);+ const officialTarget = officialConnected+ ? buildTitleTarget(OFFICIAL_TITLE_FALLBACK_ID)+ : null;+ if (officialTarget) {+ log.info('title oneShot falling back to official provider', {+ sessionProviderId,+ providerId: OFFICIAL_TITLE_FALLBACK_ID,+ agentKind: args.agentKind,+ });+ providerId = OFFICIAL_TITLE_FALLBACK_ID;+ target = officialTarget;+ }+ }if (!target) {- const status = TITLE_ONE_SHOT_PROVIDER_IDS.has(providerId)+ const status = TITLE_ONE_SHOT_PROVIDER_IDS.has(sessionProviderId)? 'failed': 'unsupported-provider';log.debug('title oneShot skipped: no title target', {- providerId,+ providerId: sessionProviderId,agentKind: args.agentKind,status,});diff --git a/apps/desktop/src/main/maker-ipc/title.ts b/apps/desktop/src/main/maker-ipc/title.tsindex 6c6e581d24..7a08650c5d 100644--- a/apps/desktop/src/main/maker-ipc/title.ts+++ b/apps/desktop/src/main/maker-ipc/title.ts@@ -4,7 +4,8 @@* 给会话起一个 ≤ 20 字标题。标题 oneShot 已统一为「单次 HTTP 请求」:按本会话所属 provider* (WYSIWYG,与模型选择器高亮同口径:DB 显式选中优先,无则取已连接供应商的原生默认)* 取 catalog 配的 `titleModel`(最经济模型),用该 provider 自家凭证直起- * (见 maker-host/title-one-shot)。起不出来(零已连接 / 凭证缺失 / HTTP 失败 / 超时)+ * (见 maker-host/title-one-shot)。无标题 wire 的会话供应商回落官方 `xd`。+ * 起不出来(零已连接 / 官方也不可用 / 凭证缺失 / HTTP 失败 / 超时)* → 返回 null,renderer 回落「消息前 40 字」启发式。fire-and-forget,* 不阻塞主流程,也不向用户暴露失败。*