Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(codex): preserve full access for missing-root approvals
david1d9b686ec617
diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.tsindex 13bd7ba7f7..6c6e851346 100644--- a/packages/maker-core/src/agents/codex/index.test.ts+++ b/packages/maker-core/src/agents/codex/index.test.ts@@ -11698,8 +11698,43 @@ describe('CodexAgent MCP thread context hooks', () => {kind: 'permission',toolName: 'file_change',input: { grantRoot: null },- suggestions: undefined,});+ const request = resolver.mock.calls[0]?.[0];+ expect(request?.kind).toBe('permission');+ if (request?.kind !== 'permission') throw new Error('expected permission request');+ expect(request.suggestions).toBeDefined();+ await handle.close();+ });++ it('accepts a pending missing-root file approval when switching to Full access', async () => {+ const agent = new CodexAgent(createDeps());+ const host = installFakeHost(agent);+ const handle = await agent.startSession({+ sessionId: 'session-auto-file-change-without-root-mode-switch',+ model: 'gpt-5.5',+ providerId: 'xd',+ workingDir: '/repo',+ permissionMode: 'auto',+ });+ const handlers = host.getThreadHandlers();+ if (!handlers?.fileChangeApproval) throw new Error('expected fileChangeApproval handler');+ const pendingDecision = deferred<InteractionDecision>();+ const resolver = vi.fn(() => pendingDecision.promise);+ handle.setInteractionResolver(resolver);++ const approval = handlers.fileChangeApproval({+ threadId: 'start-thread-id',+ turnId: 'turn-file-change-without-root-mode-switch',+ itemId: 'patch-without-root-mode-switch',+ grantRoot: null,+ });+ await vi.waitFor(() => expect(resolver).toHaveBeenCalledOnce());++ if (!handle.setPermissionMode) throw new Error('expected setPermissionMode');+ await handle.setPermissionMode('bypassPermissions');++ await expect(approval).resolves.toEqual({ decision: 'accept' });+ pendingDecision.resolve({ kind: 'permission', behavior: 'deny' });await handle.close();});diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.tsindex 0aa6317ec5..0d49b9b31d 100644--- a/packages/maker-core/src/agents/codex/index.ts+++ b/packages/maker-core/src/agents/codex/index.ts@@ -5482,6 +5482,8 @@ export class CodexAgent extends BaseAgent {req: InteractionRequest,opts?: {forcePrompt?: boolean;+ /** Auto 下跳过轻量 reviewer 转人工;仍保留 Full access 自动放行与热切换语义。 */+ promptInAuto?: boolean;autoReviewAction?: ReviewableAction;itemId?: string;},@@ -5492,6 +5494,7 @@ export class CodexAgent extends BaseAgent {opts?.forcePrompt === true ||(req.kind === 'permission' &&forceTurnConfirmation(req.toolName, req.input));+ const promptInAuto = opts?.promptInAuto === true;// Full access 的普通审批不应打断用户。Auto 在已验证路由上由 app-server// auto_review 负责;fallback 路由则由 user reviewer 把越界请求发回客户端,// 再由 Cindy reviewer 静默裁决。@@ -5537,6 +5540,7 @@ export class CodexAgent extends BaseAgent {// UI 不可用时 dispatchInteraction 自然 fail-closed decline。if (!forcePrompt &&+ !promptInAuto &&mutablePermissionMode === 'auto' &&opts?.autoReviewAction) {@@ -6357,10 +6361,11 @@ export class CodexAgent extends BaseAgent {// Codex may omit grantRoot for ordinary apply_patch requests. Without a// concrete target the lightweight reviewer cannot classify the write,// but silently declining is surfaced by app-server as "rejected by user"- // even though no user interaction happened. Escalate that protocol gap- // to a real confirmation; unattended callers still fail closed when no- // interaction resolver is available.- forcePrompt: mutablePermissionMode === 'auto' && !params.grantRoot?.trim(),+ // even though no user interaction happened. In interactive Auto, route+ // that protocol gap to the ordinary approval UI; unlike forcePrompt this+ // still lets a pending request follow a switch to Full access. Unattended+ // policy turns retain their earlier fail-closed branch above.+ promptInAuto: !params.grantRoot?.trim(),autoReviewAction: { kind: 'file-write', path: params.grantRoot ?? undefined },itemId: params.itemId,});