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(orca): 协作写操作统一进入任务权限审批

Dashb031876734ff
diff --git a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts
index bf4b0ae2f7..957abcb252 100644
--- a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest';
+import { ORCA_TASK_ACTION_TOOLS } from '../../maker-ipc/taskActionAuthorization.js';
import {
getDesktopClaudeReadOnlyAllowedTools,
@@ -450,12 +451,17 @@ describe('Orca Worker directory authorization', () => {
}
});
- it('preserves inherited-directory creation and other Orca operations', () => {
- expect(policy('create_worker', { label: 'inherits' })).toBe('auto-approve');
+ // #6699: trusted-server approval used to skip Ask/Auto for Orca mutations.
+ // Unit: use the production policy for each protected action, preserving reads.
+ it('reviews all Orca mutations, including inherited-directory creation, and preserves reads', () => {
+ for (const tool of ORCA_TASK_ACTION_TOOLS) {
+ expect(policy(tool), tool).toBe('prompt-each-time');
+ }
+ expect(policy('create_worker', { label: 'inherits' })).toBe('prompt-each-time');
expect(policy('create_workers', { workers: [{ label: 'a' }, { label: 'b' }] })).toBe(
- 'auto-approve',
+ 'prompt-each-time',
);
- expect(policy('send_to_worker', { worker_id: 'a', message: 'continue' })).toBe('auto-approve');
+ expect(policy('send_to_worker', { worker_id: 'a', message: 'continue' })).toBe('prompt-each-time');
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.ts
index 2d615cf5d5..342800d808 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
@@ -24,7 +24,7 @@ import type {
McpToolApprovalPolicy,
} from '@cindy/maker-core';
import { canAutoApproveContactsMcpTool } from '@cindy/mcps';
-import { TASK_ACTION_TOOLS } from '../maker-ipc/taskActionAuthorization.js';
+import { ORCA_TASK_ACTION_TOOLS, TASK_ACTION_TOOLS } from '../maker-ipc/taskActionAuthorization.js';
/**
@@ -281,24 +281,11 @@ export function getDesktopMcpToolApprovalPolicy(
if (serverName === 'cindy_feishu_bot' && (!toolName || toolName === 'call_api' || toolName === 'recall_message')) {
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.
+ // Orca mutations use the same per-call runtime flow as helper task writes.
+ // Reuse the Host's action set so no mutation slips through the trusted-server
+ // shortcut. Full Access still bypasses; read-only Orca operations stay trusted.
if (serverName === 'cindy_orca') {
- if (!toolName) return 'prompt-each-time';
- if (toolName === 'create_worker' || toolName === 'create_workers') {
- const params = readJsonObject(toolParams);
- 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') || Object.hasOwn(spec, 'new_worktree');
- })
- )
- return 'prompt-each-time';
- }
+ if (!toolName || ORCA_TASK_ACTION_TOOLS.has(toolName)) return 'prompt-each-time';
}
if (TRUSTED_MCP_SERVERS.has(serverName)) {
return 'auto-approve';
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts
index 2ba1051ee3..43611259db 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts
@@ -7,6 +7,7 @@
*/
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { AutoReviewDecision, PermissionMode, SendOrigin } from '@cindy/maker-core';
+import { getDesktopMcpToolApprovalPolicy } from '../../maker-host/mcp-tool-approval-policy.js';
import { withToolCallAuthority } from '../../../../../../packages/lizi-mcps/src/tool-call-authority.js';
import { createOrcaMcpServer } from '../../../../../../packages/lizi-mcps/src/orca/server.js';
import type { AgentInputQueuedMessage } from '../../../shared/agentInputQueue.js';
@@ -317,6 +318,16 @@ describe('Owner-delegated scheduled task actions', () => {
args: { target_session_id: 'target', message: 'Dispatch the new PR feedback' },
});
+ it('reuses a live scheduled permission flow without invoking the recovery reviewer', async () => {
+ const h = scheduledFixture();
+ h.activeInput.permission = {
+ permissionMode: 'auto', planModeEnabled: false, isCurrent: () => true,
+ };
+ expect(await withToolCallAuthority(h.authorize, scheduledSend(), async () => 'sent')).toBe('sent');
+ expect(h.runtime.reviewHostPermissionAction).not.toHaveBeenCalled();
+ expect(h.confirm).not.toHaveBeenCalled();
+ });
+
it.each(['direct', 'queued', 'bound'] as const)('delivers an approved %s scheduled dispatch without another confirmation', async route => {
const h = scheduledFixture();
if (route === 'bound') h.caller.source = 'desktop';
@@ -427,6 +438,10 @@ describe('Desktop owner input task actions', () => {
permissionMode, planModeEnabled: false, isCurrent: () => true,
};
for (const [server, tool] of ownerWrites) {
+ // Host admission can reuse approval only if the production tool policy
+ // actually routes this mutation through the runtime permission flow.
+ expect(getDesktopMcpToolApprovalPolicy({ serverName: server, toolName: tool }))
+ .toBe('prompt-each-time');
expect(await withToolCallAuthority(h.authorize, { ...call(tool), server }, async () => {
expect(hasTaskActionAuthorization('companion')).toBe(true);
const queued = input();
diff --git a/docs/product-rules/agent-user-parity.md b/docs/product-rules/agent-user-parity.md
index acf01ef092..e2739250c2 100644
--- a/docs/product-rules/agent-user-parity.md
+++ b/docs/product-rules/agent-user-parity.md
@@ -113,6 +113,7 @@ Ask 或审核要求确认时复用现有确认入口;Plan 不允许副作用
不得借定时工作扩大原授权范围。
2026-10-22 修订:伙伴、转入消息与定时跟进的任务操作
统一沿用普通任务权限流程:Full Access 免审、Auto 使用原有自动审核、Ask 使用原有确认。
+helper 任务写工具与 Orca 协作写工具均逐次进入该流程,不能借可信 server 静默跳过;Orca 只读查询保持免审。
Host 不因当前输入缺少主人标记再追加行动同意判定。只认运行中任务的实时权限,
不读数据库旧值;权限切换、计划模式或实例变化使尚未执行及排队中的放行失效。
群成员、共享访客、插件托管工具范围及账号归属检查保持原边界。
diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.md
index fde2be293e..c678177962 100644
--- a/docs/product-rules/cindy-bots-runtime.md
+++ b/docs/product-rules/cindy-bots-runtime.md
@@ -764,6 +764,7 @@ Host 在直接工具和渐进调用共用的执行入口核验身份与执行范
不因此获得主人权限;`GROUP_AUTHORIZATION_UNAVAILABLE` 也不能视为主人输入。
2026-10-22 修订:所有实时执行权限档覆盖伙伴任务操作;Full Access 免审、Auto 使用原有自动审核、
Ask 使用原有确认,不再因转入、自动唤醒或主人输入标记缺失追加行动同意判定。
+helper 与 Orca 的写操作均使用同一逐次审批策略;Orca 的只读操作仍沿用可信查询策略。
权限只读运行中任务的稳定状态;权限切换、计划模式、实例变化后,既有调用与排队投递的放行失效。
群成员、共享访客与插件托管工具范围不因权限档扩大,账号与业务对象归属继续校验。
没有可核验的实时执行权限时,保留原有主人输入或委托范围校验,不凭角色放行。