Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mcp): 校验项目广播窗口并审查跨任务移动
Dashf7c10a4bdb19
diff --git a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.tsindex 13a342e429..7ba68c4a85 100644--- a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts@@ -152,7 +152,6 @@ describe('desktop MCP approval policy', () => {'cindy_slack','cindy_scheduler','cindy_memory',- 'cindy_helper',// worker → lead 回报通道:执行边界在工具内部 fail-closed, 逐次弹窗// 会让远端 daemon 等审批超时断链。'orca_worker_bridge',@@ -430,9 +429,59 @@ describe('desktop MCP approval policy', () => {describe('Cindy market action authorization', () => {it('allows catalog discovery but reviews each selected installation', () => {- expect(getDesktopMcpToolApprovalPolicy({serverName: 'cindy', toolName: 'ghost_market_search'})).toBe('auto-approve');- expect(getDesktopMcpToolApprovalPolicy({serverName: 'cindy', toolName: 'ghost_market_install'})).toBe('prompt-each-time');- expect(getDesktopClaudeReadOnlyAllowedTools()).not.toContain('mcp__cindy__ghost_market_install');+ expect(+ getDesktopMcpToolApprovalPolicy({ serverName: 'cindy', toolName: 'ghost_market_search' }),+ ).toBe('auto-approve');+ expect(+ getDesktopMcpToolApprovalPolicy({ serverName: 'cindy', toolName: 'ghost_market_install' }),+ ).toBe('prompt-each-time');+ expect(getDesktopClaudeReadOnlyAllowedTools()).not.toContain(+ 'mcp__cindy__ghost_market_install',+ );+ });+});++describe('helper task workspace authorization', () => {+ const policy = (toolName: string | undefined, toolParams?: unknown) =>+ getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_helper', toolName, toolParams });++ it('reviews each move across progressive payload representations', () => {+ for (const working_dir of ['/project', null]) {+ for (const args of [+ { session_id: 'target', working_dir },+ JSON.stringify({ session_id: 'target', working_dir }),+ ]) {+ const params = { name: 'move_session', args };+ for (const toolName of ['call_tool', undefined]) {+ expect(policy(toolName, params)).toBe('prompt-each-time');+ expect(policy(toolName, JSON.stringify(params))).toBe('prompt-each-time');+ }+ }+ }+ expect(policy('move_session', { session_id: 'target', working_dir: '/project' })).toBe(+ 'prompt-each-time',+ );+ expect(getDesktopClaudeReadOnlyAllowedTools()).not.toContain('mcp__cindy_helper__call_tool');+ });++ it('does not infer a safe helper action from missing or malformed evidence', () => {+ for (const params of [undefined, null, [], 'invalid JSON', {}, { name: '' }, { name: 42 }]) {+ expect(policy('call_tool', params)).toBe('prompt-each-time');+ expect(policy(undefined, params)).toBe('prompt-each-time');+ }+ });++ it('preserves discovery and other existing helper actions', () => {+ expect(policy('list_tools')).toBe('auto-approve');+ for (const name of [+ 'list_projects',+ 'create_project',+ 'rename_project',+ 'remove_project',+ 'send_to_session',+ ]) {+ expect(policy('call_tool', { name, args: {} })).toBe('auto-approve');+ }});});@@ -456,7 +505,9 @@ describe('Orca Worker directory authorization', () => {it('preserves inherited-directory creation and other Orca operations', () => {expect(policy('create_worker', { label: 'inherits' })).toBe('auto-approve');- expect(policy('create_workers', { workers: [{ label: 'a' }, { label: 'b' }] })).toBe('auto-approve');+ expect(policy('create_workers', { workers: [{ label: 'a' }, { label: 'b' }] })).toBe(+ 'auto-approve',+ );expect(policy('send_to_worker', { worker_id: 'a', message: 'continue' })).toBe('auto-approve');expect(policy('list_workers')).toBe('auto-approve');});diff --git a/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts b/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.tsindex 946a515618..7290442d3d 100644--- a/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts+++ b/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts@@ -237,6 +237,16 @@ export function getDesktopMcpToolApprovalPolicy(if (canAutoApproveCindyArtGhostCall(context)) {return 'auto-approve';}+ // Rebinding another task's workspace delegates its execution root. Review+ // the specific move, never reuse the trusted helper server shortcut/grant.+ if (serverName === 'cindy_helper') {+ if (toolName === 'move_session') return 'prompt-each-time';+ if (!toolName || toolName === 'call_tool') {+ const params = readJsonObject(toolParams);+ const innerName = typeof params?.name === 'string' ? params.name.trim() : '';+ if (!innerName || innerName === 'move_session') return 'prompt-each-time';+ }+ }// Choosing a new Worker root delegates filesystem access. Do not let the// trusted-server shortcut or a cached server grant authorize another root.// Full Access / Auto / Ask still use their existing permission flow.@@ -247,10 +257,13 @@ export function getDesktopMcpToolApprovalPolicy(if (!params) return 'prompt-each-time';const workers = toolName === 'create_worker' ? [params] : params.workers;if (!Array.isArray(workers)) return 'prompt-each-time';- if (workers.some((worker) => {- const spec = readJsonObject(worker);- return !spec || Object.hasOwn(spec, 'working_dir');- })) return 'prompt-each-time';+ if (+ workers.some((worker) => {+ const spec = readJsonObject(worker);+ return !spec || Object.hasOwn(spec, 'working_dir');+ })+ )+ return 'prompt-each-time';}}const iosSimulatorCall = readIOSSimulatorInnerCall(context);diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/createProject.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/createProject.test.tsindex 1ac78e2c0b..50e01dae21 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/createProject.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/createProject.test.ts@@ -11,6 +11,7 @@ const h = vi.hoisted(() => ({upsert: vi.fn(),restore: vi.fn(),send: vi.fn(),+ untrustedSend: vi.fn(),registered: [] as Array<{ path: string }>,list: vi.fn(),aliases: vi.fn(),@@ -20,9 +21,15 @@ const h = vi.hoisted(() => ({}));vi.mock('electron', () => ({BrowserWindow: {- getAllWindows: () => [{ isDestroyed: () => false, webContents: { send: h.send } }],+ getAllWindows: () => [+ { trusted: true, webContents: { send: h.send } },+ { trusted: false, webContents: { send: h.untrustedSend } },+ ],},}));+vi.mock('../../security/trustedAppRenderer.js', () => ({+ isTrustedAppRendererWindow: (window: { trusted: boolean }) => window.trusted,+}));vi.mock('../../appSessionState.js', () => ({getActiveDataOwnerPushStamp: () => ({ ...h.owner }),isAppSessionBoundaryPending: () => h.boundary,@@ -101,6 +108,7 @@ describe('createProject', () => {{ path: workingDir },h.owner,);+ expect(h.untrustedSend).not.toHaveBeenCalled();expect(await readFile(path.join(directory, 'keep.txt'), 'utf8')).toBe('unchanged');expect(await run(directory)).toEqual({ ok: true, workingDir });});diff --git a/apps/desktop/src/main/mcp-integrations/createProject.ts b/apps/desktop/src/main/mcp-integrations/createProject.tsindex 11e8557b85..8afc04fbd9 100644--- a/apps/desktop/src/main/mcp-integrations/createProject.ts+++ b/apps/desktop/src/main/mcp-integrations/createProject.ts@@ -13,6 +13,7 @@ import type { ControlResult } from '@cindy/mcps';import type { DbClient } from '../localDb/client/DbClient.js';import type { DataOwnerPushStamp } from '../../shared/dataOwnerPush.js';import { throwIpcError } from '../utils/ipcValidate.js';+import { isTrustedAppRendererWindow } from '../security/trustedAppRenderer.js';const log = createLogger('mcp/projects');const fail = (errorCode: string, message: string) => ({ ok: false as const, errorCode, message });@@ -120,7 +121,7 @@ export async function createProject({await restoreLocalProjectVisibility(directory.workingDir, owner);assertCurrent();for (const window of BrowserWindow.getAllWindows()) {- if (window.isDestroyed()) continue;+ if (!isTrustedAppRendererWindow(window)) continue;try {window.webContents.send('local-db:recent-workdirs:changed',