Skip to content
TypeScript

fix(server): Codex permission requests for glob paths no longer show as command approvals (#24257)

MarcoDotIO5927111c607a
diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
index a975b8d7272..90ee44f3d5b 100644
--- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
@@ -8374,6 +8374,67 @@ describe("CodexAdapterV2 post-settle continuation", () => {
),
),
);
+
+ it.effect("classifies permission requests that only list sandbox entries", () =>
+ Effect.gen(function* () {
+ const permissionRequest = (
+ id: number,
+ itemId: string,
+ entries: CodexSchema.PermissionsRequestApprovalParams__AdditionalFileSystemPermissions["entries"],
+ ): Array<CodexReplay.CodexAppServerReplayEntry> => [
+ {
+ type: "emit_inbound",
+ label: `permissions ${itemId}`,
+ frame: {
+ id,
+ method: "item/permissions/requestApproval",
+ params: {
+ threadId: nativeThreadId,
+ turnId: nativeTurnId,
+ itemId,
+ cwd: "/w",
+ startedAtMs: 2,
+ permissions: { fileSystem: { entries } },
+ },
+ },
+ },
+ {
+ type: "expect_outbound",
+ label: `permissions ${itemId}`,
+ frame: { id, result: { permissions: { fileSystem: { entries } }, scope: "turn" } },
+ },
+ ];
+ const { harness, answerNext } = yield* startApprovalTurn("permission-entries", [
+ ...permissionRequest(0, "write-glob", [
+ { access: "read", path: { type: "path", path: "/w/src" } },
+ { access: "write", path: { type: "glob_pattern", pattern: "/w/out/**" } },
+ ]),
+ ...permissionRequest(1, "read-glob", [
+ { access: "read", path: { type: "glob_pattern", pattern: "/w/docs/**" } },
+ ]),
+ turnCompleted(nativeTurnId),
+ ]);
+ const write = yield* answerNext;
+ const read = yield* answerNext;
+ yield* harness.firstTerminal;
+
+ assert.deepEqual(
+ [write, read].map((request) => [
+ request.kind,
+ approvalItem(harness.events, request)?.requestKind,
+ ]),
+ [
+ ["file-change", "file-change"],
+ ["file-read", "file-read"],
+ ],
+ );
+ }).pipe(
+ Effect.scoped,
+ Effect.provide(
+ Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
+ ),
+ ),
+ );
});
});
diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
index 96bfdf40b13..821cf051c32 100644
--- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
+++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
@@ -587,10 +587,15 @@ function approvalDecisionToLegacyReviewDecision(
function providerRequestKindFromPermissions(
permissions: CodexSchema.PermissionsRequestApprovalParams["permissions"],
): ProviderRequestKind {
- if ((permissions.fileSystem?.write?.length ?? 0) > 0) {
+ // Codex leaves the legacy `read`/`write` lists out when a path is a glob or
+ // special path, and is replacing them with `entries`.
+ const requests = (access: "read" | "write") =>
+ (permissions.fileSystem?.[access]?.length ?? 0) > 0 ||
+ permissions.fileSystem?.entries?.some((entry) => entry.access === access);
+ if (requests("write")) {
return "file-change";
}
- if ((permissions.fileSystem?.read?.length ?? 0) > 0) {
+ if (requests("read")) {
return "file-read";
}
return "command";