Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(ios-simulator): disclose Agent control lease
JiangJiahao4b5eb90f7c29
diff --git a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.tsindex a2af3ec7e9..4eab8e4559 100644--- a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts@@ -191,6 +191,40 @@ describe('desktop MCP approval policy', () => {).toContain('outside the project');});+ it('discloses the task-scoped control lease before an agent creates or attaches a simulator', () => {+ setMainLocale('en');+ for (const [name, title] of [+ ['attach_device', /connect to and control this simulator/i],+ ['create_instance', /create and control a simulator/i],+ ] as const) {+ const presentation = getDesktopMcpToolApprovalPresentation({+ serverName: 'cindy_ios_simulator',+ toolName: 'call_tool',+ toolParams: { name, args: {} },+ });+ expect(presentation?.title).toMatch(title);+ expect(presentation?.description).toMatch(+ /current Cindy task.*start or stop.*install or launch.*tap.*swipe.*type.*screenshots.*settings.*without another device-control prompt.*disconnect.*revoke Agent control.*sensitive actions.*separate approval/i,+ );+ }++ // Codex app-server versions that omit the outer progressive tool name+ // must receive the same Host-owned disclosure from the validated payload.+ expect(+ getDesktopMcpToolApprovalPresentation({+ serverName: 'cindy_ios_simulator',+ toolParams: { name: 'attach_device', args: {} },+ })?.description,+ ).toContain('without another device-control prompt');+ expect(+ getDesktopMcpToolApprovalPresentation({+ serverName: 'cindy_ios_simulator',+ toolName: 'call_tool',+ toolParams: { name: 'open_url', args: {} },+ }),+ ).toBeUndefined();+ });+it('auto-approves read-only discovery entries even on untrusted servers', () => {// server 整体不可信, 但列工具清单 / 查连接状态没有副作用。expect(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 49a220941e..0e8dfe3c57 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@@ -155,9 +155,21 @@ export function getDesktopMcpToolApprovalPresentation(typeof context.toolParams === 'object'? (context.toolParams as { name?: unknown }).name: undefined;- if (innerName !== 'build_app') return undefined;- return {- title: t('rightSidebar.iosSimulator.buildApproval.title'),- description: t('rightSidebar.iosSimulator.buildApproval.description'),- };+ if (innerName === 'build_app') {+ return {+ title: t('rightSidebar.iosSimulator.buildApproval.title'),+ description: t('rightSidebar.iosSimulator.buildApproval.description'),+ };+ }+ if (innerName === 'attach_device' || innerName === 'create_instance') {+ return {+ title: t(+ innerName === 'attach_device'+ ? 'rightSidebar.iosSimulator.agentControlApproval.attachTitle'+ : 'rightSidebar.iosSimulator.agentControlApproval.createTitle',+ ),+ description: t('rightSidebar.iosSimulator.agentControlApproval.description'),+ };+ }+ return undefined;}diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 8b34e36403..54e088a3eb 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -4464,6 +4464,11 @@"title": "Allow Xcode to build this project?","description": "Xcode will run this project's build scripts as your macOS user. They may read or modify files outside the project, and build output is returned to the Agent. Continue only if you trust this project."},+ "agentControlApproval": {+ "attachTitle": "Allow the Agent to connect to and control this simulator?",+ "createTitle": "Allow the Agent to create and control a simulator?",+ "description": "After this succeeds, the Agent can use this simulator for the current Cindy task: start or stop it, install or launch apps, tap, swipe, type, take screenshots, and change simulator settings without another device-control prompt. This access ends when you disconnect the device, end the task, restart Cindy, or revoke Agent control in the simulator panel. Other sensitive actions may still require separate approval."+ },"refresh": "Refresh","checking": "Checking","accessRequiredTitle": "Authorize This Session",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex e860f5409a..1a69a8fb14 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -4462,6 +4462,11 @@"title": "Xcode にこのプロジェクトのビルドを許可しますか?","description": "Xcode は macOS ユーザーの権限でこのプロジェクトのビルドスクリプトを実行します。スクリプトはプロジェクト外のファイルを読み取りまたは変更でき、ビルド出力は Agent に返されます。信頼できるプロジェクトの場合のみ続行してください。"},+ "agentControlApproval": {+ "attachTitle": "Agent にこのシミュレータへの接続と操作を許可しますか?",+ "createTitle": "Agent にシミュレータの作成と操作を許可しますか?",+ "description": "この操作が成功すると、Agent は現在の Cindy タスクでこのシミュレータを使用できます。シミュレータの起動や停止、App のインストールや起動、タップ、スワイプ、文字入力、スクリーンショット、シミュレータ設定の変更は、デバイス操作について再確認せずに実行されます。デバイスを切断する、タスクを終了する、Cindy を再起動する、またはシミュレータパネルで Agent の操作権限を取り消すと、このアクセス権は失効します。その他の機密性の高い操作には、別途承認が必要な場合があります。"+ },"refresh": "更新","checking": "確認中","accessRequiredTitle": "このセッションを承認",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 0aab20beee..fce1cd2ba1 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -4462,6 +4462,11 @@"title": "Xcode가 이 프로젝트를 빌드하도록 허용할까요?","description": "Xcode는 macOS 사용자 권한으로 이 프로젝트의 빌드 스크립트를 실행합니다. 스크립트는 프로젝트 외부의 파일을 읽거나 수정할 수 있고, 빌드 출력은 Agent에 반환됩니다. 신뢰하는 프로젝트인 경우에만 계속하세요."},+ "agentControlApproval": {+ "attachTitle": "Agent가 이 시뮬레이터에 연결하고 제어하도록 허용할까요?",+ "createTitle": "Agent가 시뮬레이터를 생성하고 제어하도록 허용할까요?",+ "description": "이 작업이 성공하면 Agent는 현재 Cindy 작업에서 이 시뮬레이터를 사용할 수 있습니다. 시뮬레이터 시작 또는 중지, App 설치 또는 실행, 탭, 스와이프, 입력, 스크린샷, 시뮬레이터 설정 변경은 기기 제어에 대한 추가 확인 없이 실행됩니다. 기기 연결을 해제하거나 작업을 종료하거나 Cindy를 다시 시작하거나 시뮬레이터 패널에서 Agent 제어 권한을 취소하면 이 접근 권한이 만료됩니다. 그 밖의 민감한 작업에는 별도 승인이 필요할 수 있습니다."+ },"refresh": "새로 고침","checking": "확인 중","accessRequiredTitle": "이 세션 승인",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 516a8aeceb..4d13ec8d21 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -4462,6 +4462,11 @@"title": "允许 Xcode 构建此项目?","description": "Xcode 会以你的 macOS 用户权限运行此项目的构建脚本。这些脚本可能读取或修改项目外的文件,构建输出也会返回给 Agent。请仅在信任此项目时继续。"},+ "agentControlApproval": {+ "attachTitle": "允许 Agent 连接并控制此模拟器?",+ "createTitle": "允许 Agent 创建并控制模拟器?",+ "description": "操作成功后,Agent 可在当前 Cindy 任务中使用此模拟器:启动或停止模拟器、安装或启动 App,以及执行点击、滑动、输入、截图和更改模拟器设置等操作,无需再次确认设备控制。断开设备、结束任务、重启 Cindy 或在模拟器面板中撤销 Agent 控制后,此访问权限即失效。其他敏感操作仍可能需要单独批准。"+ },"refresh": "刷新","checking": "正在检查","accessRequiredTitle": "授权当前任务",diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.tsindex dee61b5632..b3f0bce3e5 100644--- a/packages/maker-core/src/agents/codex/index.test.ts+++ b/packages/maker-core/src/agents/codex/index.test.ts@@ -12450,10 +12450,11 @@ describe('CodexAgent MCP thread context hooks', () => {it('keeps host dynamic tool calls behind the existing MCP approval policy', async () => {const disclosure = {- title: 'Allow Xcode to build this project?',+ title: 'Allow the Agent to connect to and control this simulator?',description:- 'Build scripts may access files outside the project, and output is returned to the Agent.',+ 'The Agent may control the simulator for this task without another device-control prompt.',};+ const presentation = vi.fn(() => disclosure);const callTool = vi.fn(async () => ({contentItems: [{ type: 'inputText' as const, text: '{"ok":true}' }],success: true,@@ -12470,7 +12471,7 @@ describe('CodexAgent MCP thread context hooks', () => {callTool,},getMcpToolApprovalPolicy: () => 'prompt-each-time',- getMcpToolApprovalPresentation: () => disclosure,+ getMcpToolApprovalPresentation: presentation,}));const host = installFakeHost(agent);const handle = await agent.startSession({@@ -12500,7 +12501,7 @@ describe('CodexAgent MCP thread context hooks', () => {callId: 'call-ios',namespace: null,tool: 'cindy_ios_simulator__call_tool',- arguments: { name: 'build_app', args: {} },+ arguments: { name: 'attach_device', args: { udid: 'SIM-1' } },},{ requestId: 'request-ios' },);@@ -12508,6 +12509,11 @@ describe('CodexAgent MCP thread context hooks', () => {contentItems: [{ type: 'inputText', text: 'The user declined this tool call.' }],success: false,});+ expect(presentation).toHaveBeenCalledWith({+ serverName: 'cindy_ios_simulator',+ toolName: 'call_tool',+ toolParams: { name: 'attach_device', args: { udid: 'SIM-1' } },+ });expect(callTool).not.toHaveBeenCalled();await handle.close();});