Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(auto): preserve plan rejection feedback in runtime intent
Dash9c4d5b075823
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.tsindex be21624ca7..5031b22b66 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts@@ -2773,12 +2773,13 @@ describe('production plugin Auto admission after reservation', () => {const task = () => ({ revision: 1, permissionMode: taskMode, workingDir: path.resolve('repo') });const receipt = { pluginId: 'plugin', operation: 'create', payload: JSON.stringify(planned ? { teamPlan: { concurrency: 2, items: [{ label: 'sample', route: { agentKind: 'codex' } }] } } : {}) };const depsForCallback = {+ readPluginTaskPlanReceipt: JSON.parse,getCurrentDbClientSnapshot: () => epoch,- createPluginTaskStore: () => ({ get: async () => { if (++receiptReads === 4 && point === 'receipt') revoke(); return receipt; } }),+ createPluginTaskStore: () => ({ get: async () => { if (++receiptReads === 6 && point === 'receipt') revoke(); return receipt; } }),pluginTaskServiceForCurrentOwner: () => ({ get: async () => {++taskReads;- if (taskReads === 4 && point === 'final-task') revoke();- if (taskReads === 4 && point === 'task-mode') taskMode = 'plan';+ if (taskReads === 6 && point === 'final-task') revoke();+ if (taskReads === 6 && point === 'task-mode') taskMode = 'plan';return task();} }),readGhostErrandConfig: () => ({ permissionMode: mode, workingDir: path.resolve('repo') }),diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskReviewContext.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskReviewContext.test.tsindex e6577c027b..73f1b9010b 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskReviewContext.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskReviewContext.test.ts@@ -67,6 +67,19 @@ describe('plugin delegated Auto context', () => {expect(result.authorizationError).toContain('size');expect(result.delegatedTask).toBeUndefined();});+ it('matches runtime rejection then approval with restored persisted authority', async () => {+ const s = fixture();+ const texts = ['Fix parser.', 'Do not publish.', 'Only change parser files.', 'Approved plan:\nRun tests.'];+ s.history = texts.map((text, i) => ({ clientId: String(i), role: i ? 'plan_review' : 'user', createdAt: i + 1,+ content: { text }, agentMeta: { delivery: 'turn', autoReviewUserText: i ? { text, acceptedAt: i + 10 } : text } }));+ s.sessionHistory = s.history;+ let live: AutoReviewUserIntent = '';+ for (const text of texts) live = appendAutoReviewUserIntent(live, text);+ expect(restoreAutoReviewUserIntent(s.history)).toEqual(live);+ const resolver = createPluginTaskReviewResolver(async () => s);+ expect((await resolver({ ...request, userIntent: live })).authorizationError).toBeUndefined();+ expect((await resolver({ ...request, userIntent: appendAutoReviewUserIntent('Fix parser.', texts[3]!) })).authorizationError).toContain('not synchronized');+ });it('uses persisted bounded evidence, rejects live drift and keys cached decisions by revision', async () => {const s = fixture();s.projection = { revision: 7, sessionIntent: 'Worker restriction', reviewIntent: 'Lead and Worker restrictions' };diff --git a/packages/maker-core/src/agents/claude-code/__tests__/mcp-approval-policy.test.ts b/packages/maker-core/src/agents/claude-code/__tests__/mcp-approval-policy.test.tsindex 620bfd8056..688248a666 100644--- a/packages/maker-core/src/agents/claude-code/__tests__/mcp-approval-policy.test.ts+++ b/packages/maker-core/src/agents/claude-code/__tests__/mcp-approval-policy.test.ts@@ -1326,6 +1326,25 @@ describe('remote sessions share the same permission semantics', () => {await handle.close();});+ it('retains remote plan rejection restrictions through approval', async () => {+ const review = vi.fn<NonNullable<AgentDeps['reviewAutoPermissionAction']>>(async () => ({ verdict: 'allow' }));+ let response = 0;+ const { handle, onApprovalRequest } = await startRemoteSession(() => 'prompt', {+ permissionMode: 'auto', reviewAutoPermissionAction: review,+ attachResolver: () => response++ === 0+ ? { kind: 'plan_review', behavior: 'deny', reason: 'Do not publish.' }+ : { kind: 'plan_review', behavior: 'allow' },+ });+ await handle.send({ type: 'user', content: 'Fix parser.' });+ await onApprovalRequest({ requestId: 'reject', kind: 'plan_review', plan: 'draft' });+ await onApprovalRequest({ requestId: 'approve', kind: 'plan_review', plan: 'Run tests.' });+ await onApprovalRequest({ requestId: 'tool', kind: 'permission', toolName: 'Bash', input: { command: 'npm test' } });+ expect(review).toHaveBeenCalledWith(expect.objectContaining({ userIntent: {+ earlierUserMessages: ['Fix parser.', 'Do not publish.'], currentUserMessage: 'Approved plan:\nRun tests.',+ } }));+ await handle.close();+ });+/** 起一个远端会话并拿到 daemon 侧的 approval 回调。 */async function startRemoteSession(policy: (context: McpToolApprovalContext) => McpToolApprovalPolicy,diff --git a/packages/maker-core/src/agents/claude-code/__tests__/plan-mode.test.ts b/packages/maker-core/src/agents/claude-code/__tests__/plan-mode.test.tsindex 17f5637927..93c861538f 100644--- a/packages/maker-core/src/agents/claude-code/__tests__/plan-mode.test.ts+++ b/packages/maker-core/src/agents/claude-code/__tests__/plan-mode.test.ts@@ -1479,8 +1479,12 @@ describe('ClaudeCodeAgent plan mode', () => {{ reviewAutoPermissionAction },'auto',);+ const feedback = ['Do not publish.', 'Only change parser files.'];+ let response = 0;handle.setInteractionResolver(async (req): Promise<InteractionDecision> => {- if (req.kind === 'plan_review') return { kind: 'plan_review', behavior: 'allow' };+ if (req.kind === 'plan_review') return response < feedback.length+ ? { kind: 'plan_review', behavior: 'deny', reason: feedback[response++] }+ : { kind: 'plan_review', behavior: 'allow' };return { kind: 'permission', behavior: 'allow' };});const canUseTool = queryOptions.canUseTool;@@ -1490,6 +1494,7 @@ describe('ClaudeCodeAgent plan mode', () => {type: 'user',content: 'Refactor the parser without changing public behavior',});+ for (let i = 0; i < feedback.length; i++) await canUseTool('ExitPlanMode', { plan: 'draft' }, { toolUseID: `rejected-${i}` });await canUseTool('ExitPlanMode',{ plan: '1. Inspect parser call sites\n2. Update parser\n3. Run focused tests' },@@ -1503,7 +1508,7 @@ describe('ClaudeCodeAgent plan mode', () => {expect(reviewAutoPermissionAction).toHaveBeenCalledWith(expect.objectContaining({userIntent: {- earlierUserMessages: ['Refactor the parser without changing public behavior'],+ earlierUserMessages: ['Refactor the parser without changing public behavior', ...feedback],currentUserMessage: 'Approved plan:\n1. Inspect parser call sites\n2. Update parser\n3. Run focused tests',},}));diff --git a/packages/maker-core/src/agents/claude-code/index.ts b/packages/maker-core/src/agents/claude-code/index.tsindex 93767c49b7..28b79c72eb 100644--- a/packages/maker-core/src/agents/claude-code/index.ts+++ b/packages/maker-core/src/agents/claude-code/index.ts@@ -2310,6 +2310,7 @@ export class ClaudeCodeAgent extends BaseAgent {if (decision.behavior === 'deny') {if (!decision.dismissed) {appendActiveCapabilitySelectionText(decision.reason);+ if (decision.reason?.trim()) setAutoReviewIntent(appendAutoReviewUserIntent(planRequestAutoReviewIntent, decision.reason));}return { behavior: 'deny', message: decision.reason ?? 'plan rejected by user' };}@@ -3629,6 +3630,7 @@ export class ClaudeCodeAgent extends BaseAgent {));} else if (!decision.dismissed) {appendActiveCapabilitySelectionText(decision.reason);+ if (decision.reason?.trim()) setAutoReviewIntent(appendAutoReviewUserIntent(planRequestAutoReviewIntent, decision.reason));}return {kind: 'plan_review',diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.tsindex 456e2f37cd..28d3e28e09 100644--- a/packages/maker-core/src/agents/codex/index.test.ts+++ b/packages/maker-core/src/agents/codex/index.test.ts@@ -30450,6 +30450,29 @@ describe('CodexAgent plan mode', () => {await handle.close();});+ it('keeps rejected plan restrictions in the implementation reviewer', async () => {+ const review = vi.fn<AutoReviewDelegate>(async () => ({ verdict: 'allow' }));+ const agent = new CodexAgent(createDeps({}, { reviewAutoPermissionAction: review }));+ const host = installTurnHost(agent);+ const handle = await startPlanSession(agent, host, 'session-plan-rejection-intent');+ await handle.setPermissionMode!('auto');+ let response = 0;+ handle.setInteractionResolver(async () => response++ === 0+ ? { kind: 'plan_review', behavior: 'deny', reason: 'Do not publish.' }+ : { kind: 'plan_review', behavior: 'allow' });+ await handle.send({ type: 'user', content: 'Fix parser.' });+ runPlanTurn(host, 'turn-1', 'draft');+ await vi.waitFor(() => expect(turnStartCalls(host)).toHaveLength(2));+ runPlanTurn(host, 'turn-2', 'Run tests.');+ await vi.waitFor(() => expect(turnStartCalls(host)).toHaveLength(3));+ const handlers = host.getThreadHandlers();+ await handlers!.commandExecutionApproval!({ threadId: 'start-thread-id', turnId: 'turn-3', itemId: 'test', command: 'npm test', cwd: '/repo' });+ expect(review).toHaveBeenCalledWith(expect.objectContaining({ userIntent: {+ earlierUserMessages: ['Fix parser.', 'Do not publish.'], currentUserMessage: 'Approved plan:\nRun tests.',+ } }));+ await handle.close();+ });+it('stays in plan mode and sends the feedback as a revision turn on deny with reason', async () => {const agent = new CodexAgent(createDeps());const host = installTurnHost(agent);diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.tsindex b0f3cd231c..85ed27128b 100644--- a/packages/maker-core/src/agents/codex/index.ts+++ b/packages/maker-core/src/agents/codex/index.ts@@ -7652,9 +7652,9 @@ assertRouteCurrent();if (closed) return;await sendInteractionContinuation(requestId,{ type: 'user', content: feedback },- // 修订轮同样带上原始审查意图快照:否则 send 会把 auto-review intent 覆盖成这条修改意见,- // 下一次计划获批后 implementation reviewer 拿到的是"修改意见+计划"而非原始用户请求(codex 报)。- planFollowUpSendOptions(feedback, planRequestAutoReviewIntent),+ // Keep the original request and genuine rejection restrictions together;+ // internal continuation text must not replace either part of authority.+ planFollowUpSendOptions(feedback, appendAutoReviewUserIntent(planRequestAutoReviewIntent, feedback)),'plan revision turn failed to start',);} catch (e) {