Skip to content

Commit 5735693

Browse files
maria-rcksclaude
andauthored
fix(server): let Claude launch args override the derived permission mode (pingdotgg#11026)
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
1 parent 48654c1 commit 5735693

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎apps/server/src/provider/Layers/ClaudeAdapter.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,29 @@ describe("ClaudeAdapterLive", () => {
422422
);
423423
});
424424

425+
it.effect("lets a launch-arg permission flag win over the thread runtime mode", () => {
426+
const harness = makeHarness({
427+
claudeConfig: { launchArgs: "--dangerously-skip-permissions --verbose" },
428+
});
429+
return Effect.gen(function* () {
430+
const adapter = yield* ClaudeAdapter;
431+
yield* adapter.startSession({
432+
threadId: THREAD_ID,
433+
provider: ProviderDriverKind.make("claudeAgent"),
434+
runtimeMode: "auto-accept-edits",
435+
});
436+
437+
const createInput = harness.getLastCreateQueryInput();
438+
assert.equal(createInput?.options.permissionMode, "bypassPermissions");
439+
assert.equal(createInput?.options.allowDangerouslySkipPermissions, true);
440+
// The honored flag is dropped from extraArgs so the CLI sees it once.
441+
assert.deepEqual(createInput?.options.extraArgs, { verbose: null });
442+
}).pipe(
443+
Effect.provideService(Random.Random, makeDeterministicRandomService()),
444+
Effect.provide(harness.layer),
445+
);
446+
});
447+
425448
it.effect("loads Claude filesystem settings sources for SDK sessions", () => {
426449
const harness = makeHarness();
427450
return Effect.gen(function* () {

‎apps/server/src/provider/Layers/ClaudeAdapter.ts‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4608,7 +4608,11 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
46084608
) => runPromise(handleResumeDialog(request, callbackOptions));
46094609

46104610
const claudeBinaryPath = claudeSdkExecutablePath;
4611-
const extraArgs = parseCliArgs(claudeSettings.launchArgs).flags;
4611+
const {
4612+
"permission-mode": launchArgPermissionMode,
4613+
"dangerously-skip-permissions": launchArgSkipPermissions,
4614+
...extraArgs
4615+
} = parseCliArgs(claudeSettings.launchArgs).flags;
46124616
const selectedModel =
46134617
input.modelSelection?.instanceId === boundInstanceId ? input.modelSelection : undefined;
46144618
const modelSelection = selectedModel
@@ -4649,7 +4653,14 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
46494653
auto: "auto",
46504654
"full-access": "bypassPermissions",
46514655
};
4652-
const permissionMode = runtimeModeToPermission[input.runtimeMode];
4656+
// A permission launch arg is folded into the mode T3 sends rather than
4657+
// passed through: the CLI resolves both inputs together, so argv order
4658+
// never let the user's flag win.
4659+
const permissionMode =
4660+
(launchArgPermissionMode as PermissionMode | null | undefined) ??
4661+
(launchArgSkipPermissions === null || launchArgSkipPermissions === "true"
4662+
? "bypassPermissions"
4663+
: runtimeModeToPermission[input.runtimeMode]);
46534664
const settings = {
46544665
...(typeof thinking === "boolean" ? { alwaysThinkingEnabled: thinking } : {}),
46554666
...(fastMode ? { fastMode: true } : {}),

0 commit comments

Comments
 (0)