Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(plugins): list models only for registered runtimes
Dash31c78db5316d
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/ghostAgentModels.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/ghostAgentModels.test.tsindex 266c8500b2..14cf054ca6 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/ghostAgentModels.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/ghostAgentModels.test.ts@@ -25,16 +25,16 @@ describe('plugin model projection', () => {const a = provider('a', ['high']);a.models.codex![0]!.defaultEnabled = false;const b = provider('b', ['high']);- const result = projectGhostAgentModels([a,b], (_, id) => id === 'a' ? true : false);+ const result = projectGhostAgentModels([a,b], ['codex'], (_, id) => id === 'a' ? true : false);expect(result.ok && result.models.map(m => m.visible)).toEqual([true,false]);- const defaults = projectGhostAgentModels([a,b]);+ const defaults = projectGhostAgentModels([a,b], ['codex']);expect(defaults.ok && defaults.models.map(m => m.visible)).toEqual([false,true]);});it('preserves per-provider efforts and exposes only explicit metadata fields', () => {const result = projectGhostAgentModels([provider('a', ['low', 'high']),provider('b', ['medium']),- ]);+ ], ['codex']);expect(result).toEqual({ok: true,models: [@@ -77,7 +77,7 @@ describe('plugin model projection', () => {a,{ ...provider('offline', []), connected: false },{ ...provider('paused', []), suspended: true },- ]);+ ], ['codex']);expect(result).toEqual({ok: true,models: [@@ -94,4 +94,15 @@ describe('plugin model projection', () => {],});});+ it('only exposes registered runtimes, including registration after initial startup', () => {+ const p = provider('p', ['high']);+ p.agents = ['codex', 'pi'];+ p.routing.pi = p.routing.codex;+ p.models.pi = [...p.models.codex!];+ expect(projectGhostAgentModels([p], [])).toEqual({ ok: true, models: [] });+ const before = projectGhostAgentModels([p], ['codex']);+ expect(before.ok && before.models.map(m => m.agent)).toEqual(['codex']);+ const after = projectGhostAgentModels([p], ['codex', 'pi']);+ expect(after.ok && after.models.map(m => m.agent)).toEqual(['codex', 'pi']);+ });});diff --git a/apps/desktop/src/main/cindy-brain/ghostAgentModels.ts b/apps/desktop/src/main/cindy-brain/ghostAgentModels.tsindex 47ae871f4a..cd4bf4216d 100644--- a/apps/desktop/src/main/cindy-brain/ghostAgentModels.ts+++ b/apps/desktop/src/main/cindy-brain/ghostAgentModels.ts@@ -7,9 +7,10 @@ import {import type { GhostAgentModelsResult } from '../../shared/ghost.js';/** Project each provider separately: the same model can support different efforts per route. */-export function projectGhostAgentModels(views: ProviderView[], visibilityOverride: (agent: 'codex' | 'claude-code' | 'pi', providerId: string, modelId: string) => boolean | undefined = () => undefined): GhostAgentModelsResult {+export function projectGhostAgentModels(views: ProviderView[], availableAgents: readonly string[], visibilityOverride: (agent: 'codex' | 'claude-code' | 'pi', providerId: string, modelId: string) => boolean | undefined = () => undefined): GhostAgentModelsResult {const models: Extract<GhostAgentModelsResult, { ok: true }>['models'] = [];for (const agent of ['codex', 'claude-code', 'pi'] as const) {+ if (!availableAgents.includes(agent)) continue;for (const provider of connectedProvidersForAgent(views, agent)) {for (const model of provider.models[agent] ?? []) {if (!isModelSelectableForNewRoute(model, { userProvider: provider.source === 'user' }))diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.tsindex b42aace4b3..462672f9cb 100644--- a/apps/desktop/src/main/cindy-brain/index.ts+++ b/apps/desktop/src/main/cindy-brain/index.ts@@ -6657,7 +6657,13 @@ export function registerGhostIpc(): void {}await waitForModelVisibilityMirror();if (owner !== activeOwnerScopeKey() || !findAvailableGhost(ghostId)?.enabled) return { ok: false, errorCode: 'NOT_AVAILABLE', message: 'Plugin unavailable' };- return projectGhostAgentModels(views, getModelVisibilityOverride);+ // Do not initialize runtimes as a side effect of a plugin's read-only GET.+ const { getMakerIfReady } = await import('../maker-host/index.js');+ const maker = getMakerIfReady();+ if (owner !== activeOwnerScopeKey() || !findAvailableGhost(ghostId)?.enabled || !maker) {+ return { ok: false, errorCode: 'NOT_AVAILABLE', message: 'Model runtimes unavailable' };+ }+ return projectGhostAgentModels(views, maker.listAvailableAgents(), getModelVisibilityOverride);});// 面板唤醒电子脑(cindy-ghost://<id>/wake 供片分支):面板零桥,唤醒经它// 自己的协议通道进来。只对"已装且唤醒"的意识放行;熔断态不清账(重载 /