The best way to control Claude Code, Codex and more from any computer or phone
fix(acp): only approved execute requests let the agent open client terminals (#34526)
Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>
maria committed
Nov 12, 2026 at 00:23 UTC
26f0a62f73418d8a31ba1115dd3fb69c77ddf917
4 files changed
+45
-20
apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
+29
-4
@@ -4708,7 +4708,25 @@ describe("AcpAdapterV2", () => {
4708
kind: "other",
4709
granted: false,
4710
},
4711
- ] as const)("$label", ({ kind, granted }) =>
4711
+ {
4712
+ label: "grants an explicit execute approval",
4713
+ kind: "execute",
4714
+ requestKind: "execute",
4715
+ granted: true,
4716
+ },
4717
+ {
4718
+ label: "does not grant execution to an approved mode switch",
4719
+ kind: "execute",
4720
+ requestKind: "switch_mode",
4721
+ granted: false,
4722
+ },
4723
+ {
4724
+ label: "does not grant execution to an approved explicit other tool",
4725
+ kind: "other",
4726
+ requestKind: "other",
4727
+ granted: false,
4728
+ },
4729
+ ] as const)("$label", ({ kind, granted, ...testCase }) =>
4730
Effect.gen(function* () {
4731
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4732
const path = yield* Path.Path;
@@ -4795,7 +4813,10 @@ describe("AcpAdapterV2", () => {
4813
const permissionFiber = yield* requestPermission(
4814
{
4815
sessionId: "mock-session-1",
4798
- toolCall: { toolCallId: "tracked-tool-call" },
4816
+ toolCall: {
4817
+ toolCallId: "tracked-tool-call",
4818
+ ...("requestKind" in testCase ? { kind: testCase.requestKind } : {}),
4819
+ },
4820
options: [{ optionId: "allow-once", name: "Allow once", kind: "allow_once" }],
4821
},
4822
{ requestId: "id-only-permission-request", method: "session/request_permission" },
@@ -4837,8 +4858,12 @@ describe("AcpAdapterV2", () => {
4858
{ requestId: "id-only-permission-terminal", method: "terminal/create" },
4859
).pipe(Effect.exit);
4860
assert.deepEqual(
4840
- { prompt: approval.prompt, terminalCreated: Exit.isSuccess(terminalExit) },
4841
- { prompt: "git status", terminalCreated: granted },
4861
+ {
4862
+ prompt: approval.prompt,
4863
+ requestKind: approval.requestKind,
4864
+ terminalCreated: Exit.isSuccess(terminalExit),
4865
+ },
4866
+ { prompt: "git status", requestKind: "command", terminalCreated: granted },
4867
);
4868
4869
yield* runtime.interruptTurn({ providerThread, providerTurnId });
packages/provider-acp/src/server/adapter.ts
+2
-5
@@ -6660,12 +6660,9 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
6660
!offeredOptions.some((option) => option.decision === "acceptForSession")
6661
? "accept"
6662
: answered;
6663
- if (
6664
- parsedPermission.kind !== "unknown" &&
6665
- (decision === "accept" || decision === "acceptForSession")
6666
- ) {
6663
+ if (decision === "accept" || decision === "acceptForSession") {
6664
clientPolicyGrants.recordApproval({
6668
- kind: providerRequestKind(parsedPermission.kind),
6665
+ toolKind: parsedPermission.kind,
6666
scope: decision === "acceptForSession" ? "session" : "turn",
6667
turnKey: String(context.providerTurnId),
6668
});
packages/provider-acp/src/server/clientPolicy.test.ts
+8
-7
@@ -319,12 +319,13 @@ describe("client terminal disposition", () => {
319
});
320
321
describe("makeAcpClientPolicyGrants", () => {
322
- it("grants terminals only from commands, never from an approved read or edit", () => {
322
+ it("grants terminals only from execute approvals, never from any other approved kind", () => {
323
const grants = makeAcpClientPolicyGrants();
324
- grants.recordApproval({ kind: "file-read", scope: "turn", turnKey: "turn-1" });
325
- grants.recordApproval({ kind: "file-change", scope: "session", turnKey: "turn-1" });
324
+ for (const toolKind of ["read", "edit", "switch_mode", "other", "unknown", "browse"]) {
325
+ grants.recordApproval({ toolKind, scope: "session", turnKey: "turn-1" });
326
+ }
327
assert.isFalse(grants.allowsExecute("turn-1"));
327
- grants.recordApproval({ kind: "command", scope: "turn", turnKey: "turn-1" });
328
+ grants.recordApproval({ toolKind: "execute", scope: "turn", turnKey: "turn-1" });
329
assert.isTrue(grants.allowsExecute("turn-1"));
330
assert.isFalse(grants.allowsExecute("turn-2"));
331
assert.isFalse(grants.allowsExecute(null));
@@ -332,15 +333,15 @@ describe("makeAcpClientPolicyGrants", () => {
333
334
it("keeps accept-for-session command grants across turns", () => {
335
const grants = makeAcpClientPolicyGrants();
335
- grants.recordApproval({ kind: "command", scope: "session", turnKey: "turn-1" });
336
+ grants.recordApproval({ toolKind: "execute", scope: "session", turnKey: "turn-1" });
337
assert.isTrue(grants.allowsExecute("turn-9"));
338
assert.isTrue(grants.allowsExecute(null));
339
});
340
341
it("drops a turn's command grant when a later turn approves one", () => {
342
const grants = makeAcpClientPolicyGrants();
342
- grants.recordApproval({ kind: "command", scope: "turn", turnKey: "turn-1" });
343
- grants.recordApproval({ kind: "command", scope: "turn", turnKey: "turn-2" });
343
+ grants.recordApproval({ toolKind: "execute", scope: "turn", turnKey: "turn-1" });
344
+ grants.recordApproval({ toolKind: "execute", scope: "turn", turnKey: "turn-2" });
345
assert.isFalse(grants.allowsExecute("turn-1"));
346
assert.isTrue(grants.allowsExecute("turn-2"));
347
});
packages/provider-acp/src/server/clientPolicy.ts
+6
-4
@@ -1,5 +1,5 @@
1
// @effect-diagnostics nodeBuiltinImport:off
2
-import type { ProviderRequestKind, RuntimeMode } from "@t3tools/contracts";
2
+import type { RuntimeMode } from "@t3tools/contracts";
3
import type * as EffectAcpSchema from "effect-acp/compat";
4
import * as NodeFS from "node:fs";
5
import * as NodePath from "node:path";
@@ -222,7 +222,8 @@ export function acpClientExecuteDisposition(
222
}
223
224
export interface AcpApprovalGrantInput {
225
- readonly kind: ProviderRequestKind;
225
+ /** The approved request's ACP tool kind, after ID-only requests take their tracked call's kind. */
226
+ readonly toolKind: string;
227
readonly scope: "session" | "turn";
228
readonly turnKey: string;
229
}
@@ -232,13 +233,14 @@ export interface AcpClientPolicyGrants {
233
readonly allowsExecute: (turnKey: string | null) => boolean;
234
}
235
235
-/** ACP cannot link commands to terminals; command approvals grant execution for the turn or accepted session. */
236
+/** ACP cannot link commands to terminals; approved execute requests grant execution for the turn or accepted session. */
237
export function makeAcpClientPolicyGrants(): AcpClientPolicyGrants {
238
let sessionExecute = false;
239
let turnExecute: string | null = null;
240
return {
241
recordApproval: (input) => {
241
- if (input.kind !== "command") return;
242
+ // Other kinds also show as command cards, but approving them must not open terminals.
243
+ if (input.toolKind !== "execute") return;
244
if (input.scope === "session") {
245
sessionExecute = true;
246
} else {