Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Merge upstream/main at 0e910eeac
JiangJiahao429dc9ce5a8e
diff --cc apps/desktop/src/main/__tests__/deviceLinkAutoTitleWiring.test.tsindex a7952a80a4,a7952a80a4..3c833b7dbb--- a/apps/desktop/src/main/__tests__/deviceLinkAutoTitleWiring.test.ts+++ b/apps/desktop/src/main/__tests__/deviceLinkAutoTitleWiring.test.ts@@@ -203,12 -203,12 +203,12 @@@ describe('user rename notification orde// local-db:sessions:update(本机重命名框)["if (typeof p.title === 'string') noteUserTitleWritten(sid);",-- 'await db.update(sessions).set(setObj).where(eq(sessions.id, sid));',++ 'await withStatusWriteLock(sid, p.status, () => writeSessionPatch(db, sid, setObj, p.status));',],// patchSessionMetaInDb(device-link 远程改名)['if (patch.title !== undefined) noteUserTitleWritten(sessionId);',-- 'await db.update(sessions).set(setObj).where(eq(sessions.id, sessionId));',++ 'await withStatusWriteLock(sessionId, patch.status, async () => {',],// renameSessionTitlesInDb(MCP 批量改名)[diff --cc apps/desktop/src/main/__tests__/setSessionsStatusInDb.test.tsindex 848f3a1792,9d2ce696cd..6a309d09ec--- a/apps/desktop/src/main/__tests__/setSessionsStatusInDb.test.ts+++ b/apps/desktop/src/main/__tests__/setSessionsStatusInDb.test.ts@@@ -6,23 -6,21 +6,29 @@@* 不能广播任何部分成功的 patch。*/--import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } from 'vitest';import fs from 'node:fs';import os from 'node:os';import path from 'node:path';++import type { SessionRouteLock } from '../localDb/sessionRouteLock.js';++++type SessionRouteLockMock = SessionRouteLock &++ MockInstance<(sessionId: string, task: () => Promise<unknown>) => Promise<unknown>>;const h = vi.hoisted(() => ({tx: vi.fn(),tapWindowBroadcast: vi.fn(),webContentsSend: vi.fn(),closeSession: vi.fn(),- withSendToSessionLock: vi.fn(async (_sessionId: string, task: () => Promise<unknown>) => task()),- withSendToSessionLock: vi.fn(- async (_sessionId: string, task: () => Promise<unknown>) => task(),- ),++ withSendToSessionLock: vi.fn(async <T>(_sessionId: string, task: () => Promise<T>): Promise<T> =>++ task(),++ ) as SessionRouteLockMock,isSessionStillRemovable: vi.fn(),+ cancelSessionOperations: vi.fn(),+ removeSessionRefs: vi.fn(),recycleWorktreeForRemovedSession: vi.fn(),+ isOwnerScopeCurrent: vi.fn(),+ drizzle: {},userDataPath: '',agentIslandService: {handleSessionMetadataPatch: vi.fn(),@@@ -338,43 -234,10 +344,43 @@@ describe('recycleSessionWorktreeForStatawait recycleSessionWorktreeForStatusChange('s1', 'deleted');expect(h.withSendToSessionLock).toHaveBeenCalledWith('s1', expect.any(Function));- expect(h.isSessionStillRemovable).toHaveBeenCalledTimes(2);+ expect(h.isSessionStillRemovable).toHaveBeenCalledTimes(4);+ expect(h.cancelSessionOperations).toHaveBeenCalledWith('s1');expect(h.closeSession).toHaveBeenCalledWith('s1');- expect(h.recycleWorktreeForRemovedSession).toHaveBeenCalledWith('s1');+ expect(h.removeSessionRefs).toHaveBeenCalledWith('s1', h.drizzle);+ expect(h.recycleWorktreeForRemovedSession).toHaveBeenCalledWith(+ 's1',+ expect.objectContaining({ db: h.drizzle, isOwnerCurrent: expect.any(Function) }),+ );expect(h.webContentsSend).toHaveBeenCalledWith('worktree:changed', { sessionId: 's1' });+ expect(order).toEqual(['cancel', 'remove-media-refs', 'recycle-worktree']);+ });++ it('keeps media and worktree deletion inside the task route lock', async () => {+ let lockHeld = false;+ h.withSendToSessionLock.mockImplementationOnce(- async (_sessionId: string, task: () => Promise<unknown>) => {++ async <T>(_sessionId: string, task: () => Promise<T>): Promise<T> => {+ lockHeld = true;+ try {+ return await task();+ } finally {+ lockHeld = false;+ }+ },+ );+ h.removeSessionRefs.mockImplementationOnce(async () => {+ expect(lockHeld).toBe(true);+ return 1;+ });+ h.recycleWorktreeForRemovedSession.mockImplementationOnce(async () => {+ expect(lockHeld).toBe(true);+ });++ await recycleSessionWorktreeForStatusChange('s1', 'deleted');++ expect(lockHeld).toBe(false);+ expect(h.removeSessionRefs).toHaveBeenCalledWith('s1', h.drizzle);+ expect(h.recycleWorktreeForRemovedSession).toHaveBeenCalledOnce();});it('does not touch the runtime or worktree for active sessions', async () => {diff --cc apps/desktop/src/main/im/shared/__tests__/sessionRepoRevive.test.tsindex 8c9dab6e8c,8fbeb4ff01..9838a5247f--- a/apps/desktop/src/main/im/shared/__tests__/sessionRepoRevive.test.ts+++ b/apps/desktop/src/main/im/shared/__tests__/sessionRepoRevive.test.ts@@@ -8,7 -8,7 +8,11 @@@* - createSession 的 INSERT 带 onConflictDoUpdate 兜并发竞态,冲突时只翻* status 不碰上下文列。*/- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import { beforeEach, describe, expect, it, vi } from 'vitest';++import { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } from 'vitest';++import type { SessionRouteLock } from '../../../localDb/sessionRouteLock';++++type SessionRouteLockMock = SessionRouteLock &++ MockInstance<(sessionId: string, task: () => Promise<unknown>) => Promise<unknown>>;const mocks = vi.hoisted(() => {const updateWhere = vi.fn(async (_where: unknown) => {});@@@ -75,21 -75,8 +79,23 @@@ vi.mock('../../defaultSessionSettings'}));import { createImSessionRepo, type ImSessionRow } from '../sessionRepo';+import { setSessionRouteLockImplementation } from '../../../localDb/sessionRouteLock';import type { ImOrchestratorConfig, ImSessionNamespace } from '../types';- const routeLock = vi.fn(async (_sessionId: string, task: () => Promise<unknown>) => task());++const routeLock = vi.fn(async <T>(_sessionId: string, task: () => Promise<T>): Promise<T> =>++ task(),++) as SessionRouteLockMock;++beforeEach(() => {+ routeLock.mockClear();+ routeLock.mockImplementation(async (_sessionId, task) => task());+ setSessionRouteLockImplementation(routeLock);+});++afterEach(() => {+ setSessionRouteLockImplementation(null);+});+const ns: ImSessionNamespace = {source: 'feishu',sessionIdFor: (bot: string, user: string) => `feishu_${bot}_${user}`,diff --cc apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.tsindex 17c9f7ef5c,468177c642..514117df28--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.ts@@@ -6,16 -6,15 +6,22 @@@*/import Database from 'better-sqlite3';import { drizzle } from 'drizzle-orm/better-sqlite3';- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import { beforeEach, describe, expect, it, vi } from 'vitest';++import { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } from 'vitest';import { messages, sessions } from '../../schema';++import type { SessionRouteLock } from '../../sessionRouteLock';++++type SessionRouteLockMock = SessionRouteLock &++ MockInstance<(sessionId: string, task: () => Promise<unknown>) => Promise<unknown>>;const h = vi.hoisted(() => ({db: null as ReturnType<typeof drizzle> | null,sqlite: null as InstanceType<typeof import('better-sqlite3')> | null,handlers: new Map<string, (...args: unknown[]) => unknown>(),tapWindowBroadcast: vi.fn(),- routeLock: vi.fn(async (_sessionId: string, task: () => Promise<unknown>) => task()),++ routeLock: vi.fn(async <T>(_sessionId: string, task: () => Promise<T>): Promise<T> =>++ task(),++ ) as SessionRouteLockMock,}));vi.mock('electron', () => ({diff --cc apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.tsindex 87a7503932,cca6af6d2b..647ce306a7--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts@@@ -10,9 -10,9 +10,13 @@@*/import Database from 'better-sqlite3';import { drizzle } from 'drizzle-orm/better-sqlite3';- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import { beforeEach, describe, expect, it, vi } from 'vitest';++import { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } from 'vitest';import { messages, sessions } from '../../schema';++import type { SessionRouteLock } from '../../sessionRouteLock';++++type SessionRouteLockMock = SessionRouteLock &++ MockInstance<(sessionId: string, task: () => Promise<unknown>) => Promise<unknown>>;const h = vi.hoisted(() => ({db: null as ReturnType<typeof drizzle> | null,@@@ -23,7 -23,6 +27,9 @@@})),tapWindowBroadcast: vi.fn(),summarizeSession: vi.fn(async () => undefined),- routeLock: vi.fn(async (_sessionId: string, task: () => Promise<unknown>) => task()),++ routeLock: vi.fn(async <T>(_sessionId: string, task: () => Promise<T>): Promise<T> =>++ task(),++ ) as SessionRouteLockMock,}));vi.mock('electron', () => ({diff --cc apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.tsindex 60b93bdda0,61e71d3880..3149faa86a--- a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts@@@ -9,31 -9,27 +9,32 @@@ describe('desktop Claude read-only alloit('allows only explicitly reviewed read-only tools', () => {const tools = getDesktopClaudeReadOnlyAllowedTools();- expect(tools).toEqual(expect.arrayContaining([- 'mcp__cindy__ghost_list',- 'mcp__cindy__ghost_info',- 'mcp__cindy__ghost_forge_guide',- 'mcp__cindy_helper__list_tools',- 'mcp__cindy_slack__slack_status',- ]));- expect(tools).not.toEqual(expect.arrayContaining([- 'Bash',- 'Edit',- 'Write',- 'Agent',- 'Skill',- // 外发网络请求(搜索词/URL 出境),与 maker-core READ_ONLY_CLAUDE_TOOLS 边界一致,- // 不免审批(Greptile P1 security)。- 'WebSearch',- 'WebFetch',- 'mcp__cindy__ghost_call',- 'mcp__cindy_helper__call_tool',- 'mcp__cindy_slack__slack_list_tools',- ]));+ expect(tools).toEqual(+ expect.arrayContaining([+ 'mcp__cindy__ghost_list',++ 'mcp__cindy__ghost_info',+ 'mcp__cindy__ghost_forge_guide',+ 'mcp__cindy_ios_simulator__list_tools',+ 'mcp__cindy_helper__list_tools',+ 'mcp__cindy_slack__slack_status',+ ]),+ );+ expect(tools).not.toEqual(+ expect.arrayContaining([+ 'Bash',+ 'Edit',+ 'Write',+ 'Agent',+ 'Skill',+ // 外发网络请求(搜索词/URL 出境),与 maker-core READ_ONLY_CLAUDE_TOOLS 边界一致,+ // 不免审批(Greptile P1 security)。+ 'WebSearch',+ 'WebFetch',+ 'mcp__cindy__ghost_call',+ 'mcp__cindy_helper__call_tool',+ 'mcp__cindy_slack__slack_list_tools',+ ]),+ );expect(tools.every((tool) => !tool.includes('*'))).toBe(true);expect(tools.every((tool) => !tool.endsWith('__call_tool'))).toBe(true);});@@@ -127,47 -123,25 +129,50 @@@ describe('desktop MCP approval policy'expect(getDesktopMcpToolApprovalPolicy({ serverName: 'third_party' })).toBe('prompt');});- it('auto-approves read-only discovery entries even on untrusted servers', () => {- // server 整体不可信, 但列工具清单 / 查连接状态没有副作用。+ it('prompts for simulator build, URL, and device creation while device-gated actions stay trusted', () => {expect(- getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_ssh', toolName: 'list_tools' }),+ getDesktopMcpToolApprovalPolicy({+ serverName: 'cindy_ios_simulator',+ toolName: 'list_tools',+ }),).toBe('auto-approve');+ for (const name of ['build_app', 'create_instance', 'open_url']) {+ expect(+ getDesktopMcpToolApprovalPolicy({+ serverName: 'cindy_ios_simulator',+ toolName: 'call_tool',+ toolParams: { name, args: {} },+ }),+ ).toBe('prompt-each-time');+ }expect(- getDesktopMcpToolApprovalPolicy({ serverName: 'cindy', toolName: 'ghost_list' }),+ getDesktopMcpToolApprovalPolicy({+ serverName: 'cindy_ios_simulator',+ toolName: 'call_tool',+ toolParams: { name: 'tap', args: {} },+ }),).toBe('auto-approve');+ });++ it('auto-approves read-only discovery entries even on untrusted servers', () => {+ // server 整体不可信, 但列工具清单 / 查连接状态没有副作用。expect(- getDesktopMcpToolApprovalPolicy({ serverName: 'cindy', toolName: 'ghost_info' }),+ getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_ssh', toolName: 'list_tools' }),).toBe('auto-approve');- expect(- getDesktopMcpToolApprovalPolicy({ serverName: 'cindy', toolName: 'ghost_list' }),- ).toBe('auto-approve');++ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy', toolName: 'ghost_list' })).toBe(++ 'auto-approve',++ );++ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy', toolName: 'ghost_info' })).toBe(++ 'auto-approve',++ );// 同一个 server 的执行入口不跟着沾光。expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_ssh', toolName: 'call_tool' }),).toBe('prompt');-- expect(-- getDesktopMcpToolApprovalPolicy({ serverName: 'cindy', toolName: 'ghost_call' }),-- ).toBe('prompt');++ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy', toolName: 'ghost_call' })).toBe(++ 'prompt',++ );});it('auto-approves the browser call_tool entry that Claude used to prompt for every time', () => {diff --cc apps/desktop/src/main/maker-host/index.tsindex d061f6e830,6036421b02..e147dcdac0--- a/apps/desktop/src/main/maker-host/index.ts+++ b/apps/desktop/src/main/maker-host/index.ts@@@ -27,25 -26,25 +27,21 @@@ importcreateCodexModelBackfillCoordinator,type CodexModelBackfillCoordinator,} from './codex-model-backfill.js';--import {-- createOrcaWorkerBridgeMcpProvider,-- type OrcaBridgeMcpDeps,--} from '@cindy/orca-workflow';++import { createOrcaWorkerBridgeMcpProvider, type OrcaBridgeMcpDeps } from '@cindy/orca-workflow';import { LspServerPool } from '@cindy/mcps';import { createMessage } from '../localDb/ipc/messages.js';--import {-- getWorkerLink,-- updateWorkerStatus,--} from '../localDb/orcaTeamStore.js';++import { getWorkerLink, updateWorkerStatus } from '../localDb/orcaTeamStore.js';import { cleanupSessionTempAttachments } from '../maker-ipc/normalizeAttachments.js';--import {-- markKnownOrcaWorkerSession,--} from '../maker-ipc/orcaManualInterrupt.js';++import { markKnownOrcaWorkerSession } from '../maker-ipc/orcaManualInterrupt.js';import { markOrcaMcpHydratedIfNeeded } from '../maker-ipc/orcaMcpHydrationCache.js';import { preparePersistedOrcaSessionStart } from '../maker-ipc/orcaSessionStartOptions.js';import type { MakerSessionCreateOpts } from '../maker-ipc/sessionRequest.js';--import { dispatchInterAgentMessage, isSessionInTurn, wireSessionToIpc } from '../maker-ipc/register.js';++import {++ dispatchInterAgentMessage,++ isSessionInTurn,++ wireSessionToIpc,++} from '../maker-ipc/register.js';import { MAKER_PUSH } from '../maker-ipc/channels.js';import { tapWindowBroadcast } from '../device-link/broadcast-tap.js';import { remoteInvoke } from '../device-link/index.js';@@@ -68,11 -67,12 +64,9 @@@ import { resolveSessionCcDebugFile } frimport { resetProviderModelAutoRefreshCooldowns } from './provider-model-auto-refresh.js';import { createSshDaemonTransport } from './codex-remote-transport.js';import { getRemoteSshPool } from '../remote-ssh/index.js';--import {-- getRemoteAgentProxyEnv,-- reconcileCodexAgentProxyEnv,--} from '../remote-ssh/agent-proxy.js';++import { getRemoteAgentProxyEnv, reconcileCodexAgentProxyEnv } from '../remote-ssh/agent-proxy.js';import { openCcManagerSession } from './cc-manager-client.js';+ import { routeInjectedRemoteMcpApprovalsThroughCindy } from './remote-claude-permission-mode.js';import { getRemoteClaudeBinaryPath } from '../remote-ssh/cc-manager-install.js';import {createBashConcurrencyHooks,@@@ -107,7 -104,7 +101,11 @@@ importdesktopCodexRuntimeConfig,ensureBundledRipgrepReady,} from './runtime-configs.js';--import { getClaudeEndpoint, setClaudeProxyGatewayKeyReader, setClaudeProxyOAuthSpawnChecker } from './anthropic-compat-proxy-host.js';++import {++ getClaudeEndpoint,++ setClaudeProxyGatewayKeyReader,++ setClaudeProxyOAuthSpawnChecker,++} from './anthropic-compat-proxy-host.js';import { resolveRemoteClaudeRoute } from './remote-claude-route.js';import { claudeSubagentUsageBridge } from './claude-subagent-usage-bridge.js';import { createAutoPermissionReviewer } from './auto-permission-reviewer.js';@@@ -132,13 -129,12 +130,11 @@@ importunregister as unregisterCodexProxyPrompt,} from './codex-proxy-host.js';import { createDesktopMcpProviders } from '../mcp-integrations/mcp-providers.js';+ import { getGhostRosterPrompt } from '../mcp-integrations/ghost.js';+import { getIOSSimulatorMcpDeps } from '../mcp-integrations/ios-simulator.js';import { readContactsSettings } from './contacts-settings-store.js';-import {- captureKnownFileBefore,- noteOpaqueTurnChange,-} from '../turn-change-set/store.js';+import { createIOSSimulatorCodexDynamicToolProvider } from './ios-simulator-codex-dynamic-tools.js';- import {- captureKnownFileBefore,- noteOpaqueTurnChange,- } from '../turn-change-set/store.js';++import { captureKnownFileBefore, noteOpaqueTurnChange } from '../turn-change-set/store.js';/*** 最近一次成功构建的 codex spawn 配置里, 通讯录开关的实际取值(null = 尚未@@@ -164,14 -160,14 +160,23 @@@ import} from '../mcp-integrations/codexEnvironment.js';import type { CodexHttpBridge } from '../mcp-integrations/codexHttpBridge.js';import { setRemoteMcpBridgeTokenRotatedHook } from '../mcp-integrations/remoteMcpBridgeToken.js';--import { ensureRemoteMcpForward, setRemoteMcpForwardRearmedHook, stripRemoteCodexMcpConfig } from '../remote-ssh/codex-remote-mcp.js';++import {++ ensureRemoteMcpForward,++ setRemoteMcpForwardRearmedHook,++ stripRemoteCodexMcpConfig,++} from '../remote-ssh/codex-remote-mcp.js';import {buildCcRemoteHttpMcpServers,CC_MCP_DISABLED_FINGERPRINT,readCcAppliedFingerprint,writeCcAppliedFingerprint,} from './cc-remote-mcp.js';--import { getRemoteSessionStartEnsure, getRemoteCodexLiveTurnChecker, setRemoteCcTurnSettledHandler, setRemoteCcStaleQuery } from './remote-session-start-ensure.js';++import {++ getRemoteSessionStartEnsure,++ getRemoteCodexLiveTurnChecker,++ setRemoteCcTurnSettledHandler,++ setRemoteCcStaleQuery,++} from './remote-session-start-ensure.js';import {refreshRemoteCodexMcpAfterBridgeRecreate,invalidateRemoteCcQueriesForMcpGenerationChange,@@@ -181,7 -177,7 +186,10 @@@ importCODEX_DISABLED_BUILTIN_PLUGIN_IDS_KEY,readDisabledBuiltinPluginIds,} from '../mcp-integrations/codexBuiltinToolPolicy.js';--import { buildCodexProxySpawnArgs, CODEX_OPENAI_COMPACT_PROVIDER_ID } from './codex-gateway-config.js';++import {++ buildCodexProxySpawnArgs,++ CODEX_OPENAI_COMPACT_PROVIDER_ID,++} from './codex-gateway-config.js';import {buildCodexSubagentSpawnArgs,resolveCodexSubagentModelFallback,@@@ -192,12 -188,12 +200,12 @@@ importregisterCodexProcessRole,} from '../process-monitor/codex-process-registry.js';import { getOutboundPathSnapshotFor } from './outbound-proxy-resolver.js';--import {-- createDesktopMakerMemoryManager,-- attachAgentsToMakerMemory,--} from './maker-memory-host.js';++import { createDesktopMakerMemoryManager, attachAgentsToMakerMemory } from './maker-memory-host.js';import { prepareExternalCodexSessionForResume } from './codex-local-sessions.js';--import { rehydrateCloseSuppression, withRehydrateCloseSuppressed } from './rehydrateCloseSuppression.js';++import {++ rehydrateCloseSuppression,++ withRehydrateCloseSuppressed,++} from './rehydrateCloseSuppression.js';import { hydrateSessionProvider } from './session-provider-store.js';import { prepareLocalCodexCredentialModeSwitch } from './codex-credential-switch.js';import { createDesktopOrcaTeamStoreAdapter } from './orcaTeamStoreAdapter.js';@@@ -366,7 -362,7 +374,9 @@@ const staleInvalidatedCcSessions = newlet _lastBridgeForForcedFresh: CodexHttpBridge | null = null;/** getMaker() 首次构造时发起的自定义 MCP 初始加载 promise,供 bootstrap 在注册会话 IPC 前 await。 */let _initialCustomMcpRefresh: Promise<void> | undefined;--type CodexLocalCredentialChangeGuard = Awaited<ReturnType<CodexAgent['beginLocalHostCredentialChange']>>;++type CodexLocalCredentialChangeGuard = Awaited<++ ReturnType<CodexAgent['beginLocalHostCredentialChange']>++>;let _codexCredentialChangeGuard: CodexLocalCredentialChangeGuard | null = null;/**@@@ -603,11 -599,11 +613,15 @@@ export function getMaker(): Maker// 顺序错了, 早抛比 session.start 时再炸更清晰。const claudePath = getReadyBinaryPath('claude-code');if (!claudePath) {-- throw new Error('getMaker: Claude binary not provisioned (bootstrap must run agent-binaries.prepare("claude-code") before getMaker)');++ throw new Error(++ 'getMaker: Claude binary not provisioned (bootstrap must run agent-binaries.prepare("claude-code") before getMaker)',++ );}const codexPath = getCachedBinaryStatus('codex').binaryPath;if (!codexPath) {-- throw new Error('getMaker: Codex binary not provisioned (bootstrap must run agent-binaries.prepare("codex") before getMaker)');++ throw new Error(++ 'getMaker: Codex binary not provisioned (bootstrap must run agent-binaries.prepare("codex") before getMaker)',++ );}// bundled ripgrep 检查与上面 claude/codex 二进制同层:真正的启动期 fail-fast// 在 splash check-environment(Phase 2.5,缺 rg 时 splash 进失败态可重试);@@@ -674,10 -670,10 +688,13 @@@// query 的 mcpServers URL 还指旧端口 — fresh 失效 + detach 促重建// (codex-connector R19 P2)。setRemoteMcpForwardRearmedHook((hostId, remotePort) => {-- desktopMakerLogger.info('remote MCP forward re-armed — invalidating remote CC queries on host', {-- hostId,-- remotePort,-- });++ desktopMakerLogger.info(++ 'remote MCP forward re-armed — invalidating remote CC queries on host',++ {++ hostId,++ remotePort,++ },++ );invalidateActiveRemoteCcQueries({ hostId, reason: 'forward-rearmed' });});// register.ts 的 turn 收口经 holder 回调:远端 CC 的 fresh 已失效且@@@ -719,7 -715,7 +736,12 @@@// ensure 会在 createOpts 上就地归一化 makerMemoryEnabled (全局设置// backfill + stale-bridge 钳制) — 这里是临时对象, 必须把结果读回// 交给 bridge 的真实 createSession (review R6 P2)。-- const createOpts: { id: string; agentKind: typeof params.agentKind; remoteHostId: string; makerMemoryEnabled?: boolean } = {++ const createOpts: {++ id: string;++ agentKind: typeof params.agentKind;++ remoteHostId: string;++ makerMemoryEnabled?: boolean;++ } = {id: params.sessionId,agentKind: params.agentKind,remoteHostId: params.remoteHostId,@@@ -768,8 -764,8 +790,7 @@@beforeKnownFileWrite: captureKnownFileBefore,noteOpaqueWrite: noteOpaqueTurnChange,},-- registerLocalAgentProcess: ({ pid, kind, role }) =>-- registerAgentProcess(pid, kind, role),++ registerLocalAgentProcess: ({ pid, kind, role }) => registerAgentProcess(pid, kind, role),reviewAutoPermissionAction,// 每个 session 的 cc 子进程 debug 写到 sessions/<id>/cc-debug.raw.log (logger 拼路径// + mkdir), tailer 再归一化汇入该 session 的 <date>.ndjson。@@@ -841,7 -834,7 +863,16 @@@// RemoteQuery 实现 SDK Query interface 的子集 (ClaudeCodeAgent 实际只调// for-await / interrupt / setModel / setPermissionMode / applyFlagSettings),// factory 返回时直接 `as unknown as Query` cast 即可。-- remoteCcQueryFactory: async ({ remoteHostId, sessionId, sessionInstanceId, startParams, vendorOptions, onApprovalRequest, onOAuthRefresh, makerMemoryEnabled }) => {++ remoteCcQueryFactory: async ({++ remoteHostId,++ sessionId,++ sessionInstanceId,++ startParams,++ vendorOptions,++ onApprovalRequest,++ onOAuthRefresh,++ makerMemoryEnabled,++ }) => {const host = getRemoteSshPool().get(remoteHostId);if (host?.getStatus() !== 'ready') {throw new Error(`remote ssh host not ready: ${remoteHostId}`);@@@ -936,7 -935,7 +973,9 @@@// fresh 过」时生效, attach 回持旧 Authorization/URL 的 query// (codex-connector R27 P1)。fresh 集合只豁免「同代际的重复注入」。const forceFreshQuery =-- ((injectedServerCount > 0 || mcpNeedsFreshStart || staleInvalidatedCcSessions.has(sessionId)) &&++ ((injectedServerCount > 0 ||++ mcpNeedsFreshStart ||++ staleInvalidatedCcSessions.has(sessionId)) &&!forcedFreshCcBridgeSessions.has(sessionId)) ||ccGenerationDrift ||ccMissingDesiredStale;@@@ -958,10 -957,10 +997,16 @@@return await openCcManagerSession({host,sessionId,-- startParams: startParamsWithProxy as unknown as Parameters<typeof openCcManagerSession>[0]['startParams'],++ startParams: startParamsWithProxy as unknown as Parameters<++ typeof openCcManagerSession++ >[0]['startParams'],claudeBinaryPath,-- onApprovalRequest: onApprovalRequest as Parameters<typeof openCcManagerSession>[0]['onApprovalRequest'],-- onOAuthRefresh: onOAuthRefresh as Parameters<typeof openCcManagerSession>[0]['onOAuthRefresh'],++ onApprovalRequest: onApprovalRequest as Parameters<++ typeof openCcManagerSession++ >[0]['onApprovalRequest'],++ onOAuthRefresh: onOAuthRefresh as Parameters<++ typeof openCcManagerSession++ >[0]['onOAuthRefresh'],forceFreshQuery,});} catch (err) {@@@ -969,7 -968,7 +1014,9 @@@// intent 必须清掉,否则残留到同 session 下一次重建或应用退出。try {mcpCleanup();-- } catch { /* cleanup 失败不掩盖原始错误 */ }++ } catch {++ /* cleanup 失败不掩盖原始错误 */++ }throw err;}})();@@@ -1022,8 -1021,8 +1069,7 @@@runtimeConfig: desktopCodexRuntimeConfig,binaryPath: codexPath,logger: desktopMakerLogger,-- registerLocalCodexAppServerProcess: ({ pid, role }) =>-- registerCodexProcessRole(pid, role),++ registerLocalCodexAppServerProcess: ({ pid, role }) => registerCodexProcessRole(pid, role),// Codex 也接 Cindy MCP providers (跟 claude 共享同一份 provider instances);// codex 子进程没法消费 in-process JS instance, prepareCodexExtraSpawnConfig// 起 streamable-HTTP bridge 把 instance 通过 -c 'mcp_servers...=...' 注入。@@@ -1045,8 -1044,8 +1091,8 @@@ensureCodexBrowserUseReady,}) => {const disabledPluginIds =-- readDisabledBuiltinPluginIds(vendorOptions)-- ?? getPluginRegistry().getDisabledRuntimePluginIds(workingDir);++ readDisabledBuiltinPluginIds(vendorOptions) ??++ getPluginRegistry().getDisabledRuntimePluginIds(workingDir);const cindyBrowserEnabled = !disabledPluginIds.includes('browser');let connectedCodexBrowserUse = codexBrowserUseProvisioned;if (!remoteHostId && !cindyBrowserEnabled && connectedCodexBrowserUse) {@@@ -1062,12 -1061,6 +1108,11 @@@});},makerMemory: makerMemoryManager,+ codexHostDynamicToolProvider: createIOSSimulatorCodexDynamicToolProvider({+ deps: getIOSSimulatorMcpDeps(),- isEnabled: (workingDir) =>- getPluginRegistry().isEnabled('ios-simulator', workingDir),++ isEnabled: (workingDir) => getPluginRegistry().isEnabled('ios-simulator', workingDir),+ }),+ getShellCommandPolicy: ({ command }) => getDesktopShellCommandPolicy(command),// 通讯录 prompt 段有效状态(codex 版): 在 claude 的判定链之上再与「实际应用// 到 running app-server 的 spawn 快照」对齐 —— 开关切换后失效失败(busy,// contacts-ipc 折成 codexMcpRefreshed:false)时 stale 桥里没有新工具面,@@@ -1138,8 -1132,8 +1184,7 @@@let mcpExtraArgs: string[] = [];let mcpExtraEnv: Record<string, string> = {};let buildSessionMcpConfig:-- | ((sessionInstanceId: string) => Record<string, unknown>)-- | undefined;++ ((sessionInstanceId: string) => Record<string, unknown>) | undefined;try {const cfg = await getCodexExtraSpawnConfig({mcpProviders: providers,@@@ -1194,8 -1182,8 +1239,9 @@@// oauth-bearer → requires_openai_auth(codex 带 OAuth token,普通模型走 ChatGPT)// provider-oauth → env_key 占位,proxy 用供应商 OAuth 覆盖 Authorization(如 xAI)// 未显式选择来源时才保留旧 fallback:有 OAuth 用 OAuth,否则用 gateway key。-- const credentialMode = ctx.credentialMode ??-- (await desktopCodexAuthAdapter.hasCodexOAuthLogin() ? 'oauth-bearer' : 'gateway-key');++ const credentialMode =++ ctx.credentialMode ??++ ((await desktopCodexAuthAdapter.hasCodexOAuthLogin()) ? 'oauth-bearer' : 'gateway-key');const authInjection =credentialMode === 'oauth-bearer'? 'oauth-bearer'@@@ -1265,13 -1253,13 +1311,20 @@@: {}),};},-- registerCodexMcpThreadContext: ({ threadId, sessionId, sessionInstanceId, workingDir, remoteHostId, vendorOptions }) => {++ registerCodexMcpThreadContext: ({++ threadId,++ sessionId,++ sessionInstanceId,++ workingDir,++ remoteHostId,++ vendorOptions,++ }) => {// Codex shares one app-server across sessions. Freeze the effective// ordinary-tool policy at thread creation so later Settings changes do// not mutate a runtime that is already running.const disabledPluginIds =-- readDisabledBuiltinPluginIds(vendorOptions)-- ?? getPluginRegistry().getDisabledRuntimePluginIds(workingDir);++ readDisabledBuiltinPluginIds(vendorOptions) ??++ getPluginRegistry().getDisabledRuntimePluginIds(workingDir);registerCodexMcpThreadContext(threadId, {agentKind: 'codex',sessionId,@@@ -1313,10 -1301,10 +1366,14 @@@getRemoteCodexTransport: (remoteHostId) => {const remoteHost = getRemoteSshPool().get(remoteHostId);if (!remoteHost) {-- throw new Error(`remote SSH host "${remoteHostId}" not found in pool — connect it first under Settings → Remote`);++ throw new Error(++ `remote SSH host "${remoteHostId}" not found in pool — connect it first under Settings → Remote`,++ );}if (remoteHost.getStatus() !== 'ready') {-- throw new Error(`remote SSH host "${remoteHostId}" is not connected (status=${remoteHost.getStatus()}) — connect it under Settings → Remote first`);++ throw new Error(++ `remote SSH host "${remoteHostId}" is not connected (status=${remoteHost.getStatus()}) — connect it under Settings → Remote first`,++ );}return createSshDaemonTransport({remoteHost,@@@ -1428,7 -1416,7 +1485,11 @@@};for (const win of BrowserWindow.getAllWindows()) {if (win.isDestroyed()) continue;-- try { win.webContents.send(MAKER_PUSH.AUTH_STATE_CHANGED, payload); } catch { /* no-op */ }++ try {++ win.webContents.send(MAKER_PUSH.AUTH_STATE_CHANGED, payload);++ } catch {++ /* no-op */++ }}});// Claude 同款:订阅 refresh token 被服务端作废(invalid_grant)时,adapter.invalidate()@@@ -1436,7 -1424,7 +1497,9 @@@desktopClaudeAuthAdapter.setOnInvalidatedBroadcast((reason) => {resetProviderModelAutoRefreshCooldowns('anthropic');// 凭证已失效 = anthropic 动态清单失去可用性证明,与登出同款收口(清单+磁盘缓存)。-- void clearAnthropicDiscoveredModels().catch(() => { /* 清理失败不阻断失效广播 */ });++ void clearAnthropicDiscoveredModels().catch(() => {++ /* 清理失败不阻断失效广播 */++ });const payload = {agentKind: 'claude-code' as const,authenticated: false,@@@ -1444,7 -1432,7 +1507,11 @@@};for (const win of BrowserWindow.getAllWindows()) {if (win.isDestroyed()) continue;-- try { win.webContents.send(MAKER_PUSH.AUTH_STATE_CHANGED, payload); } catch { /* no-op */ }++ try {++ win.webContents.send(MAKER_PUSH.AUTH_STATE_CHANGED, payload);++ } catch {++ /* no-op */++ }}});// 预热 codex-home 骨架 + 与本机 codex CLI reconcile 凭证。原本挂在@@@ -1474,8 -1462,8 +1541,7 @@@beforeKnownFileWrite: captureKnownFileBefore,noteOpaqueWrite: noteOpaqueTurnChange,},-- registerLocalAgentProcess: ({ pid, kind, role }) =>-- registerAgentProcess(pid, kind, role),++ registerLocalAgentProcess: ({ pid, kind, role }) => registerAgentProcess(pid, kind, role),reviewAutoPermissionAction,capabilityAdditions: {availableModels: deriveAvailableModels(getDesktopSelectableCatalog(), 'pi'),@@@ -1502,15 -1491,15 +1569,14 @@@lifecycleHooks: {prepareStartOptions: async (sessionId, opts) => {const providerScopeKey = activeOwnerScopeKey();-- const providerReady = await accountProviderReadinessBarrier.waitForScope(providerScopeKey);++ const providerReady =++ await accountProviderReadinessBarrier.waitForScope(providerScopeKey);if (!providerReady ||activeOwnerScopeKey() !== providerScopeKey ||isAppSessionBoundaryPending()) {-- throw new Error(-- 'Account provider models are not ready for this app session; retry.',-- );++ throw new Error('Account provider models are not ready for this app session; retry.');}await preparePersistedOrcaSessionStart(sessionId, opts as MakerSessionCreateOpts);if (opts.agentKind === 'codex') {@@@ -1552,8 -1541,8 +1618,7 @@@markKnownOrcaWorkerSession(sessionId);}},-- getCodexHistoryHasProductPrompt: (sessionId) =>-- readCodexHistoryHasProductPrompt(sessionId),++ getCodexHistoryHasProductPrompt: (sessionId) => readCodexHistoryHasProductPrompt(sessionId),onCodexProductPromptDelivery: async ({ sessionId, historyHasProductPrompt }) => {await writeCodexHistoryHasProductPrompt(sessionId, historyHasProductPrompt);},@@@ -1585,10 -1574,10 +1650,12 @@@_codexModelBackfill = createCodexModelBackfillCoordinator({hasCodexLogin: () => desktopCodexAuthAdapter.hasCodexOAuthLogin(),hasCodexModels: () =>-- (getActiveCatalog().providers.find((p) => p.id === 'openai')?.models.codex?.length ?? 0) > 0,-- refreshLive: () => makerRef.refreshAgentLocalModels('codex', {-- credentialMode: 'oauth-bearer',-- }),++ (getActiveCatalog().providers.find((p) => p.id === 'openai')?.models.codex?.length ?? 0) >++ 0,++ refreshLive: () =>++ makerRef.refreshAgentLocalModels('codex', {++ credentialMode: 'oauth-bearer',++ }),onApplied: () => refreshSelectableModelsAndBroadcast({}),log: desktopMakerLogger,});@@@ -1695,9 -1684,9 +1762,12 @@@ export async function prepareCodexForAuisSessionInTurn,});} catch (e) {-- desktopMakerLogger.warn('restartCodexAfterAuthModeChange: soft-close codex sessions failed', {-- error: e instanceof Error ? e.message : String(e),-- });++ desktopMakerLogger.warn(++ 'restartCodexAfterAuthModeChange: soft-close codex sessions failed',++ {++ error: e instanceof Error ? e.message : String(e),++ },++ );throw e;}}@@@ -1768,7 -1757,7 +1838,11 @@@ export async function broadcastCodexAutconst payload = { agentKind: 'codex' as const, ...state };for (const win of BrowserWindow.getAllWindows()) {if (win.isDestroyed()) continue;-- try { win.webContents.send(MAKER_PUSH.AUTH_STATE_CHANGED, payload); } catch { /* no-op */ }++ try {++ win.webContents.send(MAKER_PUSH.AUTH_STATE_CHANGED, payload);++ } catch {++ /* no-op */++ }}} catch (e) {desktopMakerLogger.warn('broadcastCodexAuthStateChanged: broadcast state failed', {@@@ -1791,7 -1780,7 +1865,11 @@@ export async function broadcastClaudeAuconst payload = { agentKind: 'claude-code' as const, ...state };for (const win of BrowserWindow.getAllWindows()) {if (win.isDestroyed()) continue;-- try { win.webContents.send(MAKER_PUSH.AUTH_STATE_CHANGED, payload); } catch { /* no-op */ }++ try {++ win.webContents.send(MAKER_PUSH.AUTH_STATE_CHANGED, payload);++ } catch {++ /* no-op */++ }}} catch (e) {desktopMakerLogger.warn('broadcastClaudeAuthStateChanged: broadcast state failed', {@@@ -1810,7 -1799,7 +1888,11 @@@export function broadcastXaiAuthStateChanged(): void {for (const win of BrowserWindow.getAllWindows()) {if (win.isDestroyed()) continue;-- try { win.webContents.send(MAKER_PUSH.PROVIDER_CHANGED, {}); } catch { /* no-op */ }++ try {++ win.webContents.send(MAKER_PUSH.PROVIDER_CHANGED, {});++ } catch {++ /* no-op */++ }}}diff --cc apps/desktop/src/main/mcp-integrations/mcp-providers.tsindex 1e8186a2dc,4696dc598f..a858b7d4a1--- a/apps/desktop/src/main/mcp-integrations/mcp-providers.ts+++ b/apps/desktop/src/main/mcp-integrations/mcp-providers.ts@@@ -10,8 -11,8 +11,9 @@@ import type { OrcaMcpDeps } from '@cindimport { createCindyGhostsMcpServer } from 'cindy-tools';import type { MakerMemoryManager } from '@cindy/maker-core';import { getCindyGhostsMcpDeps, type GhostGrantLiveSessionState } from './ghost.js';+ import { createGroupHistoryMcpServer } from './groupHistoryMcpServer.js';import { getAndroidMcpDeps } from './android.js';+import { getIOSSimulatorMcpDeps } from './ios-simulator.js';import { getBrowserMcpDeps } from './browser.js';import { getComputerMcpDeps } from './computer.js';import { feishuIm, wechatIm } from '../im';diff --cc apps/desktop/src/shared/__tests__/ghost.test.tsindex 21149da646,eb6503c9f8..667b9417cd--- a/apps/desktop/src/shared/__tests__/ghost.test.ts+++ b/apps/desktop/src/shared/__tests__/ghost.test.ts@@@ -299,44 -281,49 +300,71 @@@ describe('ghost · 清单校验', () =expect(valid.ok).toBe(true);expect(valid.ok && valid.manifest.locales?.en).toBe('locales/en.json');- expect(validateGhostManifest({- ...goodManifest(),- locales: { 'zh-CN': 'locales/zh-CN.json' },- }).ok).toBe(false);- expect(validateGhostManifest({- ...goodManifest(),- locales: { en: '../en.json' },- }).ok).toBe(false);- expect(validateGhostManifest({- ...goodManifest(),- locales: { en: 'locales/en.json', fr: 'locales/fr.json' },- }).ok).toBe(false);- expect(validateGhostManifest({- ...goodManifest(),- locales: { en: 'locales/en.json', ja: 'locales/en.json' },- }).ok).toBe(false);- expect(validateGhostManifest({- ...goodManifest(),- locales: { en: 'locales/en.json', ja: 'Locales/EN.json' },- }).ok).toBe(false);- expect(validateGhostManifest({- ...goodManifest(),- locales: { en: 'GHOST.JSON' },- }).ok).toBe(false);+ expect(+ validateGhostManifest({+ ...goodManifest(),+ locales: { 'zh-CN': 'locales/zh-CN.json' },+ }).ok,+ ).toBe(false);+ expect(+ validateGhostManifest({+ ...goodManifest(),+ locales: { en: '../en.json' },+ }).ok,+ ).toBe(false);+ expect(+ validateGhostManifest({+ ...goodManifest(),+ locales: { en: 'locales/en.json', fr: 'locales/fr.json' },+ }).ok,+ ).toBe(false);+ expect(+ validateGhostManifest({+ ...goodManifest(),+ locales: { en: 'locales/en.json', ja: 'locales/en.json' },+ }).ok,+ ).toBe(false);+ expect(+ validateGhostManifest({+ ...goodManifest(),+ locales: { en: 'locales/en.json', ja: 'Locales/EN.json' },+ }).ok,+ ).toBe(false);+ expect(+ validateGhostManifest({+ ...goodManifest(),+ locales: { en: 'GHOST.JSON' },+ }).ok,+ ).toBe(false);});+ it('locale description / whenToUse 共用协议仓字符上限', () => {+ const manifest = validateGhostManifest({+ ...goodManifest(),+ description: 'Base description',+ whenToUse: 'Base recall',+ });+ expect(manifest.ok).toBe(true);+ if (!manifest.ok) return;- expect(validateGhostManifestLocaleResource({- description: 'x'.repeat(GHOST_MANIFEST_SUMMARY_MAX_CHARS),- whenToUse: 'y'.repeat(GHOST_MANIFEST_SUMMARY_MAX_CHARS),- }, manifest.manifest).ok).toBe(true);- expect(validateGhostManifestLocaleResource({- description: 'x'.repeat(GHOST_MANIFEST_SUMMARY_MAX_CHARS + 1),- }, manifest.manifest).ok).toBe(false);++ expect(++ validateGhostManifestLocaleResource(++ {++ description: 'x'.repeat(GHOST_MANIFEST_SUMMARY_MAX_CHARS),++ whenToUse: 'y'.repeat(GHOST_MANIFEST_SUMMARY_MAX_CHARS),++ },++ manifest.manifest,++ ).ok,++ ).toBe(true);++ expect(++ validateGhostManifestLocaleResource(++ {++ description: 'x'.repeat(GHOST_MANIFEST_SUMMARY_MAX_CHARS + 1),++ },++ manifest.manifest,++ ).ok,++ ).toBe(false);+ });+it('locale 选择完全跟随宿主,插件不支持或宿主值未知时固定回退英文', () => {const parsed = validateGhostManifest({...goodManifest(),@@@ -1684,7 -1543,7 +1712,9 @@@ describe('ghost · cindy 能力详单�// 2026-08-05:oneshotModel 快问快答偏好模型(标量意图键,不是类目;// 必须与 text.oneshot 成对;权限行说明换带模型版本,装入即知情)。it('oneshotModel 合法声明:落 cindy.oneshotModel,权限行说明带模型', () => {-- const v = validateGhostManifest(chipWithModel({ text: ['oneshot'], oneshotModel: 'codex/gpt-5.5' }));++ const v = validateGhostManifest(++ chipWithModel({ text: ['oneshot'], oneshotModel: 'codex/gpt-5.5' }),++ );expect(v.ok, JSON.stringify(v)).toBe(true);if (!v.ok) return;expect(v.manifest.cindy).toEqual({ text: ['oneshot'], oneshotModel: 'codex/gpt-5.5' });@@@ -1724,35 -1583,35 +1754,49 @@@// 没变",更新时用户看不到重新确认。it('oneshotModel 新增/变更/移除都算权限面变化(diff/基线/未审三条路径)', () => {const plain = validateGhostManifest(chipWithModel({ text: ['oneshot'] }));-- const declared = validateGhostManifest(chipWithModel({ text: ['oneshot'], oneshotModel: 'codex/gpt-5.5' }));-- const declared2 = validateGhostManifest(chipWithModel({ text: ['oneshot'], oneshotModel: 'gpt-5.5' }));++ const declared = validateGhostManifest(++ chipWithModel({ text: ['oneshot'], oneshotModel: 'codex/gpt-5.5' }),++ );++ const declared2 = validateGhostManifest(++ chipWithModel({ text: ['oneshot'], oneshotModel: 'gpt-5.5' }),++ );if (!plain.ok || !declared.ok || !declared2.ok) throw new Error('fixture 应合法');// 新增声明:diff 标 added+removed(key 同、说明变),基线不同,未审列出。const addDiff = diffGhostPermissionItems(plain.manifest, declared.manifest);expect(addDiff.added.map((i) => i.key)).toEqual(['cindy:text.oneshot']);expect(addDiff.removed.map((i) => i.key)).toEqual(['cindy:text.oneshot']);-- expect(ghostPermissionBaselineKey(plain.manifest)).not.toBe(ghostPermissionBaselineKey(declared.manifest));++ expect(ghostPermissionBaselineKey(plain.manifest)).not.toBe(++ ghostPermissionBaselineKey(declared.manifest),++ );expect(-- unreviewedGhostPermissionItems(plain.manifest, plain.manifest, declared.manifest).map((i) => i.key),++ unreviewedGhostPermissionItems(plain.manifest, plain.manifest, declared.manifest).map(++ (i) => i.key,++ ),).toEqual(['cindy:text.oneshot']);// 改模型:同样算变化。-- expect(diffGhostPermissionItems(declared.manifest, declared2.manifest).added.map((i) => i.key)).toEqual([-- 'cindy:text.oneshot',-- ]);++ expect(++ diffGhostPermissionItems(declared.manifest, declared2.manifest).added.map((i) => i.key),++ ).toEqual(['cindy:text.oneshot']);// 移除声明:同样算变化。-- expect(diffGhostPermissionItems(declared.manifest, plain.manifest).added.map((i) => i.key)).toEqual([-- 'cindy:text.oneshot',-- ]);++ expect(++ diffGhostPermissionItems(declared.manifest, plain.manifest).added.map((i) => i.key),++ ).toEqual(['cindy:text.oneshot']);// 声明原样:三条路径都认为无变化。-- const same = validateGhostManifest(chipWithModel({ text: ['oneshot'], oneshotModel: 'codex/gpt-5.5' }));++ const same = validateGhostManifest(++ chipWithModel({ text: ['oneshot'], oneshotModel: 'codex/gpt-5.5' }),++ );if (!same.ok) throw new Error('fixture 应合法');expect(diffGhostPermissionItems(declared.manifest, same.manifest).added).toEqual([]);-- expect(ghostPermissionBaselineKey(declared.manifest)).toBe(ghostPermissionBaselineKey(same.manifest));-- expect(unreviewedGhostPermissionItems(declared.manifest, declared.manifest, same.manifest)).toEqual([]);++ expect(ghostPermissionBaselineKey(declared.manifest)).toBe(++ ghostPermissionBaselineKey(same.manifest),++ );++ expect(++ unreviewedGhostPermissionItems(declared.manifest, declared.manifest, same.manifest),++ ).toEqual([]);});});@@@ -1936,11 -1791,8 +1980,11 @@@ describe('ghost · description(自我�const chip = validateGhostManifest({ ...goodChipManifest(), description: '画图小助手' });expect(chip.ok && chip.manifest.description).toBe('画图小助手');- for (const bad of ['', ' ', 'x'.repeat(301), 42]) {+ for (const bad of ['', ' ', 'x'.repeat(GHOST_MANIFEST_SUMMARY_MAX_CHARS + 1), 42]) {- expect(validateGhostManifest({ ...goodManifest(), description: bad }).ok, JSON.stringify(bad)).toBe(false);+ expect(+ validateGhostManifest({ ...goodManifest(), description: bad }).ok,+ JSON.stringify(bad),+ ).toBe(false);}});});@@@ -1993,9 -1841,10 +2037,12 @@@ describe('ghost · whenToUse(语义召�const chip = validateGhostManifest({ ...goodChipManifest(), whenToUse: '需要出图时找我' });expect(chip.ok && chip.manifest.whenToUse).toBe('需要出图时找我');expect(validateGhostManifest({ ...goodChipManifest(), whenToUse: '' }).ok).toBe(false);- expect(validateGhostManifest({ ...goodChipManifest(), whenToUse: 'x'.repeat(301) }).ok).toBe(- false,- );- expect(validateGhostManifest({- ...goodChipManifest(),- whenToUse: 'x'.repeat(GHOST_MANIFEST_SUMMARY_MAX_CHARS + 1),- }).ok).toBe(false);++ expect(++ validateGhostManifest({++ ...goodChipManifest(),++ whenToUse: 'x'.repeat(GHOST_MANIFEST_SUMMARY_MAX_CHARS + 1),++ }).ok,++ ).toBe(false);});});@@@ -2633,11 -2413,11 +2680,7 @@@ describe('ghost · network 详单校验ghostPermissionBaselineKey(valid.manifest),);expect(-- unreviewedGhostPermissionItems(-- prior.manifest,-- prior.manifest,-- valid.manifest,-- ),++ unreviewedGhostPermissionItems(prior.manifest, prior.manifest, valid.manifest),).toEqual([]);}}diff --cc apps/desktop/src/shared/ghost.tsindex b0188015cc,8865618fb7..e68a8e3836--- a/apps/desktop/src/shared/ghost.ts+++ b/apps/desktop/src/shared/ghost.ts@@@ -1,8 -1,6 +1,12 @@@- import { GHOST_OAUTH_SCOPES_MAX, isValidCindyVersion } from '@cindy/plugin-protocol';-import { GHOST_MANIFEST_SUMMARY_MAX_CHARS, GHOST_OAUTH_SCOPES_MAX, isValidCindyVersion } from '@cindy/plugin-protocol';++import {++ GHOST_MANIFEST_SUMMARY_MAX_CHARS,++ GHOST_OAUTH_SCOPES_MAX,++ isValidCindyVersion,++} from '@cindy/plugin-protocol';+import type { IOSSimulatorMcpErrorCode } from '@cindy/mcps';import { findSplitChildByPanelKind, insertRootSplitPane, type Layout } from './layoutTree';import { DEFAULT_LOCALE, SUPPORTED_LOCALES, type SupportedLocale } from './locale';+import type { IOSSimulatorPublicInstance, IOSSimulatorPublicRouteStatus } from './iosSimulatorIpc';/*** 意识(Ghost,.cindy 文件)的清单数据模型与校验 —— main / renderer 共用。@@@ -809,7 -806,7 +816,13 @@@ export const GHOST_OAUTH_BOUNCE_PATH_R* 改走 source:'oauth' + tokenBroker:'feishu';存量已装清单由内置意识播种器* 按指纹覆盖自愈,未覆盖前该意识加载被拒属预期。)*/--export const GHOST_SECRET_SOURCES = ['user', 'login-email', 'oauth', 'gh-cli', 'oidc-token'] as const;++export const GHOST_SECRET_SOURCES = [++ 'user',++ 'login-email',++ 'oauth',++ 'gh-cli',++ 'oidc-token',++] as const;export type GhostSecretSource = (typeof GHOST_SECRET_SOURCES)[number];/**@@@ -1458,11 -1448,11 +1471,7 @@@ export interface InstalledGhost* 插件包的来源与审核等级;通常只决定 UI 徽标。保留的 gh-cli 凭证来源还会* 要求 cindy-github 具备 cindy-official Host receipt,防止第三方仅自报 id。*/--export type GhostTrustLevel =-- | 'cindy-official'-- | 'reviewed'-- | 'verified-publisher'-- | 'unverified';++export type GhostTrustLevel = 'cindy-official' | 'reviewed' | 'verified-publisher' | 'unverified';export interface GhostTrustInfo {level: GhostTrustLevel;@@@ -1663,7 -1629,7 +1672,9 @@@ export function ghostPermissionItems(ma// 快问快答声明了偏好模型:说明行换带模型的版本(装入即知情,成本透明)。const declaredOneshotModel =cap === 'text.oneshot' ? manifest.cindy?.oneshotModel : undefined;-- const detailKey = declaredOneshotModel ? 'cindyTextOneshotModelDetail' : GHOST_CINDY_PERM_DETAIL[cap];++ const detailKey = declaredOneshotModel++ ? 'cindyTextOneshotModelDetail'++ : GHOST_CINDY_PERM_DETAIL[cap];// 未登记的能力键不该出现(validateGhostManifest 已拦),防御性跳过。if (labelKey) {items.push({@@@ -2084,7 -2032,7 +2095,12 @@@ function ghostPermissionItemFingerprintconst args = item.detailArgs? Object.entries(item.detailArgs).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)): [];-- return JSON.stringify([item.key, item.detail ?? '', permissionDetailKeyForFingerprint(item), args]);++ return JSON.stringify([++ item.key,++ item.detail ?? '',++ permissionDetailKeyForFingerprint(item),++ args,++ ]);}/**@@@ -2097,10 -2045,10 +2113,7 @@@* 每项 JSON 编码后排序拼接,全可打印、无拼接歧义。*/export function ghostPermissionBaselineKey(manifest: GhostManifest): string {-- return ghostPermissionItems(manifest)-- .map(ghostPermissionItemFingerprint)-- .sort()-- .join('\n');++ return ghostPermissionItems(manifest).map(ghostPermissionItemFingerprint).sort().join('\n');}export function diffGhostPermissionItems(@@@ -2145,7 -2093,7 +2158,9 @@@ export function unreviewedGhostPermissifor (const item of ghostPermissionItems(previouslyInstalled ?? reviewed)) {approved.add(ghostPermissionItemFingerprint(item));}-- return ghostPermissionItems(actual).filter((item) => !approved.has(ghostPermissionItemFingerprint(item)));++ return ghostPermissionItems(actual).filter(++ (item) => !approved.has(ghostPermissionItemFingerprint(item)),++ );}/**@@@ -2946,19 -2816,15 +2961,25 @@@ export function validateGhostManifest(r}if (raw.description !== undefined &&- (typeof raw.description !== 'string' || raw.description.trim().length === 0 || raw.description.length > GHOST_MANIFEST_SUMMARY_MAX_CHARS)+ (typeof raw.description !== 'string' ||+ raw.description.trim().length === 0 ||- raw.description.length > 300)++ raw.description.length > GHOST_MANIFEST_SUMMARY_MAX_CHARS)) {- return { ok: false, reason: 'description 必须是 1–300 字符的非空字符串' };- return { ok: false, reason: `description 必须是 1–${GHOST_MANIFEST_SUMMARY_MAX_CHARS} 字符的非空字符串` };++ return {++ ok: false,++ reason: `description 必须是 1–${GHOST_MANIFEST_SUMMARY_MAX_CHARS} 字符的非空字符串`,++ };}if (raw.whenToUse !== undefined &&- (typeof raw.whenToUse !== 'string' || raw.whenToUse.trim().length === 0 || raw.whenToUse.length > GHOST_MANIFEST_SUMMARY_MAX_CHARS)+ (typeof raw.whenToUse !== 'string' ||+ raw.whenToUse.trim().length === 0 ||- raw.whenToUse.length > 300)++ raw.whenToUse.length > GHOST_MANIFEST_SUMMARY_MAX_CHARS)) {- return { ok: false, reason: 'whenToUse 必须是 1–300 字符的非空字符串' };- return { ok: false, reason: `whenToUse 必须是 1–${GHOST_MANIFEST_SUMMARY_MAX_CHARS} 字符的非空字符串` };++ return {++ ok: false,++ reason: `whenToUse 必须是 1–${GHOST_MANIFEST_SUMMARY_MAX_CHARS} 字符的非空字符串`,++ };}if (raw.icon !== undefined) {if (!isSafeGhostRelativePath(raw.icon)) {@@@ -3262,12 -3085,12 +3283,15 @@@// 只验形态不验存在——目录随主机演进,声明式字段永不构成硬依赖。const oneshotModelRaw = cindyRaw.oneshotModel;if (-- oneshotModelRaw !== undefined-- && (typeof oneshotModelRaw !== 'string'-- || oneshotModelRaw.trim().length === 0-- || oneshotModelRaw.length > 128)++ oneshotModelRaw !== undefined &&++ (typeof oneshotModelRaw !== 'string' ||++ oneshotModelRaw.trim().length === 0 ||++ oneshotModelRaw.length > 128)) {-- return { ok: false, reason: 'cindy.oneshotModel 必须是 1–128 字符的目录模型 id(如 "codex/gpt-5.5")' };++ return {++ ok: false,++ reason: 'cindy.oneshotModel 必须是 1–128 字符的目录模型 id(如 "codex/gpt-5.5")',++ };}// 类目 → 合法动作表(image / video / media;image 与 video 的动作集恰好// 同名,但按类目查表,未来某类目动作分叉时这里天然承接)。新增类目必须@@@ -3313,13 -3136,13 +3337,20 @@@else if (category === 'text') cindy.text = actions as GhostCindyTextAction[];else if (category === 'embed') cindy.embed = actions as GhostCindyEmbedAction[];else if (category === 'search') cindy.search = actions as GhostCindySearchAction[];-- else return { ok: false, reason: `cindy 能力类目 ${JSON.stringify(category)} 尚未接线(主机缺陷)` };++ else++ return {++ ok: false,++ reason: `cindy 能力类目 ${JSON.stringify(category)} 尚未接线(主机缺陷)`,++ };}// 偏好模型只是快问快答的选型意图,必须挂在能力本体上(无能力单挂偏好 =// 清单自相矛盾,与"有详单必有槽"同一判据)。if (oneshotModelRaw !== undefined) {if (!cindy.text?.includes('oneshot')) {-- return { ok: false, reason: 'cindy.oneshotModel 必须与 text 含 "oneshot" 成对声明(它是快问快答的偏好模型)' };++ return {++ ok: false,++ reason: 'cindy.oneshotModel 必须与 text 含 "oneshot" 成对声明(它是快问快答的偏好模型)',++ };}cindy.oneshotModel = (oneshotModelRaw as string).trim();}@@@ -3981,7 -3763,7 +4012,8 @@@if (source === 'gh-cli' && s.exchange !== undefined) {return {ok: false,-- reason: 'network.secrets[].source 为 gh-cli 时不允许声明 exchange(GitHub token 只能直接注入 GitHub API)',++ reason:++ 'network.secrets[].source 为 gh-cli 时不允许声明 exchange(GitHub token 只能直接注入 GitHub API)',};}if (@@@ -4102,7 -3859,7 +4134,8 @@@) {return {ok: false,-- reason: 'network.secrets[].source 为 gh-cli 时 inject 必须固定为 api.github.com 的 Authorization: Bearer {value}',++ reason:++ 'network.secrets[].source 为 gh-cli 时 inject 必须固定为 api.github.com 的 Authorization: Bearer {value}',};}}@@@ -4772,19 -4384,19 +4805,18 @@@{ hostDerivedSource: 'login-email' | 'gh-cli' | 'oidc-token' | null }>([...(network?.secrets ?? []).map(-- (s) => [-- s.key,-- {-- hostDerivedSource:-- s.source === 'login-email' || s.source === 'gh-cli' || s.source === 'oidc-token'-- ? s.source-- : null,-- },-- ] as const,-- ),-- ...(node?.secretBindings ?? []).map(-- (s) => [s.key, { hostDerivedSource: null }] as const,++ (s) =>++ [++ s.key,++ {++ hostDerivedSource:++ s.source === 'login-email' || s.source === 'gh-cli' || s.source === 'oidc-token'++ ? s.source++ : null,++ },++ ] as const,),++ ...(node?.secretBindings ?? []).map((s) => [s.key, { hostDerivedSource: null }] as const),]);const connectionKeys = new Set((network?.connections ?? []).map((c) => c.key));const groups: GhostSetupGroup[] = [];