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。

chore: merge upstream/main into cindy/auto-hffm9o to resolve conflicts

Shinku3eb155b303e9
diff --cc apps/desktop/src/main/maker-host/title-one-shot.ts
index 2553223c92,3fe015015c..2e1b7467e1
--- a/apps/desktop/src/main/maker-host/title-one-shot.ts
+++ b/apps/desktop/src/main/maker-host/title-one-shot.ts
@@@ -425,36 -400,10 +431,36 @@@ export function parseResponsesSse(raw:
return (final || delta).trim();
}
+/**
+ * 非标题 one-shot 调用的可选参数覆盖。标题调用不传(走默认值)。
+ * 用于 prompt prediction 等复用同一条 provider 通路但需要不同 token/校验的场景。
+ */
+export interface OneShotOpts {
+ /** 覆盖 max_tokens(标题默认 32)。 */
+ maxTokens?: number;
+ /** 覆盖 Codex instructions(标题默认 CODEX_TITLE_INSTRUCTIONS)。 */
+ codexInstructions?: string;
+ /** 覆盖输出校验时的最大 Unicode 长度(标题默认 256)。0 跳过 validateTitleOutput。 */
+ maxOutputChars?: number;
+ /** 校验通过后的 Unicode 截断长度(标题默认 40)。0 跳过截断。 */
+ maxVisualChars?: number;
+ /**
+ * 可选的 system 指令。
+ * - Anthropic Messages wire: 写入顶层 `system` 字段(该 API 不接受 role: 'system' 消息)。
+ * - Codex Responses wire: 拼接到 instructions 前。
+ * - Gateway chat wire: 作为 role: 'system' 消息插入 messages 数组。
+ * prompt prediction 用此字段将系统指令与对话上下文正确分离。
+ */
+ systemPrompt?: string;
+}
+
/**
* 标题 oneShot 诊断入口:解析本会话 provider → titleModel → 单次 HTTP 起标题。
- * 仅区分“当前供应商不支持”与通用失败,供手动 AI 重命名给出可操作提示。
- * 全程不打印 token(只记 providerId / model / wire / 耗时)。
- * 无标题 wire 的会话供应商先回落官方 `xd`;仍组不出目标时才区分“当前供应商不支持”与通用失败,
++* 无标题 wire 的会话供应商先回落官方 `xd`;仍组不出目标时才区分”当前供应商不支持”与通用失败,
+ * 供手动 AI 重命名给出可操作提示。全程不打印 token(只记 providerId / model / wire / 耗时)。
+ *
+ * `opts` 仅用于非标题场景(如 prompt prediction)覆盖默认 token 数/校验规则;
+ * 标题场景不传即可走默认值。
*/
export async function generateTitleViaProviderResult(
args: { sessionId: string; agentKind: AgentKind; prompt: string; signal?: AbortSignal },
@@@ -493,13 -441,31 +499,31 @@@
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('oneShot skipped: no title target', {
- providerId,
- log.debug('title oneShot skipped: no title target', {
++log.debug('title oneShot skipped: no title target', {
+ providerId: sessionProviderId,
agentKind: args.agentKind,
status,
});