Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
merge: 同步 main 并保留 Auto 拒绝理由与 MCP 提示
Dash9f14afbaca9f
diff --cc packages/maker-core/src/agents/codex/index.tsindex fddb5c566c,9a0d4d1dc6..0db0c7611a--- a/packages/maker-core/src/agents/codex/index.ts+++ b/packages/maker-core/src/agents/codex/index.ts@@@ -6765,12 -6765,32 +6766,35 @@@ export class CodexAgent extends BaseAgeautoReviewAction?: ReviewableAction;itemId?: string;},- ): Promise<ApprovalDecision> {+ ): Promise<{ decision: ApprovalDecision; reason?: string }> {+ // Reasons stay inside Cindy for Host-owned dynamic tool results. Stock Codex+ // approval responses cannot carry them into native exec/patch tool output.const timingPauseId = `approval:${kind}:${requestId}`;- return withCodexGenerationPaused(requestThreadId, turnId, timingPauseId, async () => {+ let denialReason = formatPermissionDenial('system', 'Approval was cancelled or became stale.');+ const decision = await withCodexGenerationPaused<ApprovalDecision>(requestThreadId, turnId, timingPauseId, async () => {+ // Native Codex currently flattens MCP declines to "user rejected" and+ // discards response content/_meta on that path. Preserve the cause in+ // Cindy's diagnostic/UI channel; this notice is NOT model context.+ const reportMcpDenial = (source: 'auto-review' | 'system' | 'user', reason?: string, visible = true) => {+ if (kind !== 'mcpServerElicitation') return;+ const timedOut = source === 'system' && isSystemPermissionDenialReason(reason) &&+ (reason === 'timeout' || reason?.endsWith('_timeout'));+ const code = source === 'auto-review' ? 'MCP_APPROVAL_AUTO_BLOCKED'+ : timedOut ? 'MCP_APPROVAL_CONFIRMATION_TIMEOUT' : 'MCP_APPROVAL_CONFIRMATION_UNAVAILABLE';+ // IDs and a closed set of causes only: no arguments, credentials, or+ // free-text reviewer output may enter the diagnostic log.+ log.info('MCP approval denied', {+ threadId: requestThreadId, turnId, requestId, itemId: opts?.itemId,+ source, cause: source === 'user' ? 'user-denied' : code,+ });+ if (source === 'user' || !visible) return;+ const text = source === 'auto-review'+ ? 'Automatic approval review blocked this tool call. No user rejection was received.'+ : timedOut+ ? 'The permission request timed out without a confirmed decision. This does not establish whether the user clicked a button.'+ : 'The permission confirmation could not be completed. No user rejection was received.';+ emitAutoReviewRuntimeNotice(`[${code}] ${text}`);+ };let forcePrompt =opts?.forcePrompt === true ||(req.kind === 'permission' &&@@@ -6843,9 -6860,8 +6867,9 @@@} else if (decision.verdict === 'allow') {return 'accept';} else if (decision.verdict === 'block') {+ denialReason = formatPermissionDenial('auto', decision.reason);- // 模型判定动作有更安全的做法 —— 按 Auto 本意保持静默。- // (审阅器故障已在 resolveAutoReviewDecision 降级成 ask,不会走到这里。)+ // Keep the denial, but distinguish it from a user decision in Cindy.+ reportMcpDenial('auto-review');return 'decline';} else {// AI ask decisions reach the user and cannot be remembered.@@@ -6892,8 -6906,8 +6917,9 @@@if (entry.settled) return;if (decision.kind !== 'permission') {log.warn('unexpected non-permission decision → decline', { kind: decision.kind });- if (unavailableHandoff) autoReviewConfirmUndeliveredNotice.notify();+ reportMcpDenial('system');+ if (unavailableHandoff && kind !== 'mcpServerElicitation') autoReviewConfirmUndeliveredNotice.notify();+ denialReason = formatPermissionDenial('system', 'Approval returned an unexpected response.');finalize('decline');return;}@@@ -6912,8 -6927,8 +6942,9 @@@.catch((e) => {if (entry.settled) return;log.error('dispatchInteraction threw → decline', { requestId, message: (e as Error).message });- if (unavailableHandoff) autoReviewConfirmUndeliveredNotice.notify();+ reportMcpDenial('system');+ if (unavailableHandoff && kind !== 'mcpServerElicitation') autoReviewConfirmUndeliveredNotice.notify();+ denialReason = formatPermissionDenial('system', 'Approval could not be completed.');finalize('decline');});});@@@ -6939,10 -6953,11 +6970,11 @@@// 里宽松模式仍强制弹 UI 的语义一致。const effectiveResolveAs: 'allow' | 'deny' =resolveAs === 'allow' && entry.forcePrompt === true ? 'deny' : resolveAs;- if (effectiveResolveAs === 'deny' && entry.unavailableHandoff) {+ if (effectiveResolveAs === 'deny') entry.onSystemDenied?.(reason);+ if (effectiveResolveAs === 'deny' && entry.unavailableHandoff && entry.kind !== 'mcpServerElicitation') {autoReviewConfirmUndeliveredNotice.notify();}- entry.resolve(effectiveResolveAs === 'allow' ? 'accept' : 'decline');+ entry.resolve(effectiveResolveAs === 'allow' ? 'accept' : 'decline', reason);eventQueue.push({type: 'interaction_dismissed',data: { requestId, reason, resolvedAs: effectiveResolveAs },