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): pi 钉档放行 toWireOption,清单排除 google wire

Zhang Yunjinefe11ea4a6ce
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/auxiliaryModelSettings.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/auxiliaryModelSettings.test.ts
index 993e72735e..ed216f3066 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/auxiliaryModelSettings.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/auxiliaryModelSettings.test.ts
@@ -150,6 +150,55 @@ describe('auxiliary model settings IPC helpers', () => {
]);
});
+ it('routes pi-runtime options through toWireOption without throwing', () => {
+ const piCatalog = {
+ providers: [
+ {
+ id: 'opencode-go',
+ name: 'OpenCode Go',
+ source: 'user',
+ agents: ['pi'],
+ auth: { method: 'apiKey' },
+ routing: {
+ pi: {
+ upstream: 'https://opencode.example/zen/go/v1',
+ authStrategy: 'api-key-header',
+ wireProtocol: 'openai-chat',
+ },
+ },
+ models: {
+ pi: [
+ {
+ id: 'step-5-preview-free',
+ name: 'Step 5 preview free',
+ contextWindow: 200_000,
+ group: 'custom:opencode-go',
+ },
+ ],
+ },
+ },
+ ],
+ } as never;
+ const pin = 'cat:opencode-go:pi:step-5-preview-free';
+ const options = buildAuxiliaryModelOptions({
+ settings: { models: [pin] },
+ catalog: piCatalog,
+ overrides: { disabledModels: {}, disabledProviders: {} },
+ hasCredential: () => true,
+ });
+
+ expect(options).toEqual([
+ expect.objectContaining({
+ id: pin,
+ providerId: 'opencode-go',
+ agentKind: 'pi',
+ modelId: 'step-5-preview-free',
+ agentSuffix: 'Pi',
+ available: true,
+ }),
+ ]);
+ });
+
it('marks a migrated utility profile available when its direct route is usable', () => {
const options = buildAuxiliaryModelOptions({
settings: { models: [PROFILE] },
diff --git a/apps/desktop/src/main/maker-ipc/auxiliary-model-settings.ts b/apps/desktop/src/main/maker-ipc/auxiliary-model-settings.ts
index 79a9b38d5b..84905de5db 100644
--- a/apps/desktop/src/main/maker-ipc/auxiliary-model-settings.ts
+++ b/apps/desktop/src/main/maker-ipc/auxiliary-model-settings.ts
@@ -43,7 +43,7 @@ import { MAKER_INVOKE } from './channels.js';
const log = createLogger('maker-ipc/auxiliary-model-settings');
function toWireOption(option: TextOneshotPinOption, available: boolean): AuxiliaryModelOption {
- if (option.agentKind !== 'codex' && option.agentKind !== 'claude-code') {
+ if (option.agentKind !== 'codex' && option.agentKind !== 'claude-code' && option.agentKind !== 'pi') {
throw new Error(`unsupported auxiliary model agent: ${option.agentKind}`);
}
return {
diff --git a/apps/desktop/src/main/utility-model/__tests__/textOneshotPinOptions.test.ts b/apps/desktop/src/main/utility-model/__tests__/textOneshotPinOptions.test.ts
index a0e1554838..aacd037819 100644
--- a/apps/desktop/src/main/utility-model/__tests__/textOneshotPinOptions.test.ts
+++ b/apps/desktop/src/main/utility-model/__tests__/textOneshotPinOptions.test.ts
@@ -289,8 +289,10 @@ describe('buildTextOneshotPinOptions', () => {
custom('cx-chat', 'codex', 'openai-chat'),
custom('cx-anthropic', 'codex', 'anthropic-messages'),
custom('cx-default', 'codex'),
+ custom('cx-google', 'codex', 'google-generative-ai'),
custom('pi-chat', 'pi', 'openai-chat'),
custom('pi-anthropic', 'pi', 'anthropic-messages'),
+ custom('pi-google', 'pi', 'google-generative-ai'),
custom('pi-default', 'pi'),
),
undefined,
diff --git a/apps/desktop/src/main/utility-model/textOneshotPinOptions.ts b/apps/desktop/src/main/utility-model/textOneshotPinOptions.ts
index 5eff879ccb..aa15f56532 100644
--- a/apps/desktop/src/main/utility-model/textOneshotPinOptions.ts
+++ b/apps/desktop/src/main/utility-model/textOneshotPinOptions.ts
@@ -79,8 +79,8 @@ export function decodeCatalogPin(
* 四家(见 ONESHOT_EXECUTABLE_BUILTIN_PROVIDERS);自定义供应商要求 routing
* 未禁用 + 鉴权策略受支持 + 有上游地址 + 声明的 wire 与执行侧该 agent 的
* 实际出线一致(claude-code 恒发 anthropic-messages;codex 与 pi 发不出
- * anthropic-messages,会被静默当 responses——配置错线的组合钉上恒失败,
- * 不进清单)。
+ * anthropic-messages,会被静默当 responses;google-generative-ai 两条执行路
+ * 都拒绝——配置错线的组合钉上恒失败,不进清单)。
*/
function isRoutableForOneshot(provider: Provider, agentKind: AgentKind): boolean {
if (!provider.agents.includes(agentKind)) return false;
@@ -91,7 +91,12 @@ function isRoutableForOneshot(provider: Provider, agentKind: AgentKind): boolean
if (provider.source === 'builtin') return ONESHOT_EXECUTABLE_BUILTIN_PROVIDERS.has(provider.id);
if (agentKind === 'claude-code') {
if (routing.wireProtocol !== undefined && routing.wireProtocol !== 'anthropic-messages') return false;
- } else if (routing.wireProtocol === 'anthropic-messages') return false;
+ } else if (
+ routing.wireProtocol === 'anthropic-messages'
+ // 执行侧(requestExplicitProviderText)对 google wire 直接 no_candidate,
+ // 清单侧同步排除(含存量 codex 档的同一缺口)。
+ || routing.wireProtocol === 'google-generative-ai'
+ ) return false;
return (
(routing.authStrategy === 'api-key-header'
|| routing.authStrategy === 'oauth-token'