惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Last Week in AI
Last Week in AI
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
V
Visual Studio Blog
小众软件
小众软件
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
IT之家
IT之家
Vercel News
Vercel News
C
Check Point Blog
Google DeepMind News
Google DeepMind News
月光博客
月光博客
D
DataBreaches.Net
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: align claude cli permissions with exec policy · open...
steipete · 2026-04-24 · via Recent Commits to openclaw:main

@@ -1,4 +1,7 @@

1-

import type { CliBackendConfig } from "openclaw/plugin-sdk/cli-backend";

1+

import type {

2+

CliBackendConfig,

3+

CliBackendNormalizeConfigContext,

4+

} from "openclaw/plugin-sdk/cli-backend";

25

import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/text-runtime";

36

import { CLAUDE_CLI_BACKEND_ID } from "./cli-constants.js";

47

export {

@@ -58,16 +61,40 @@ const CLAUDE_LEGACY_SKIP_PERMISSIONS_ARG = "--dangerously-skip-permissions";

5861

const CLAUDE_PERMISSION_MODE_ARG = "--permission-mode";

5962

const CLAUDE_SETTING_SOURCES_ARG = "--setting-sources";

6063

const CLAUDE_SAFE_SETTING_SOURCES = "user";

64+

const CLAUDE_BYPASS_PERMISSION_MODE = "bypassPermissions";

61656266

export function isClaudeCliProvider(providerId: string): boolean {

6367

return normalizeOptionalLowercaseString(providerId) === CLAUDE_CLI_BACKEND_ID;

6468

}

656966-

export function normalizeClaudePermissionArgs(args?: string[]): string[] | undefined {

70+

function isOpenClawRequestedYolo(context?: CliBackendNormalizeConfigContext): boolean {

71+

const agentExec = context?.agentId

72+

? context.config?.agents?.list?.find((agent) => agent.id === context.agentId)?.tools?.exec

73+

: undefined;

74+

const exec = agentExec ?? context?.config?.tools?.exec;

75+

const security = exec?.security ?? "full";

76+

const ask = exec?.ask ?? "off";

77+

return security === "full" && ask === "off";

78+

}

79+80+

export function resolveClaudePermissionMode(context?: CliBackendNormalizeConfigContext): {

81+

mode?: string;

82+

overrideExisting: boolean;

83+

} {

84+

return isOpenClawRequestedYolo(context)

85+

? { mode: CLAUDE_BYPASS_PERMISSION_MODE, overrideExisting: false }

86+

: { overrideExisting: false };

87+

}

88+89+

export function normalizeClaudePermissionArgs(

90+

args?: string[],

91+

options?: { mode?: string; overrideExisting?: boolean },

92+

): string[] | undefined {

6793

if (!args) {

68-

return args;

94+

return options?.mode ? [CLAUDE_PERMISSION_MODE_ARG, options.mode] : args;

6995

}

7096

const normalized: string[] = [];

97+

let hasPermissionMode = false;

7198

for (let i = 0; i < args.length; i += 1) {

7299

const arg = args[i];

73100

if (arg === CLAUDE_LEGACY_SKIP_PERMISSIONS_ARG) {

@@ -80,21 +107,30 @@ export function normalizeClaudePermissionArgs(args?: string[]): string[] | undef

80107

maybeValue.trim().length > 0 &&

81108

!maybeValue.startsWith("-")

82109

) {

83-

normalized.push(arg);

84-

normalized.push(maybeValue);

110+

hasPermissionMode = true;

111+

if (!options?.overrideExisting) {

112+

normalized.push(arg);

113+

normalized.push(maybeValue);

114+

}

85115

i += 1;

86116

}

87117

continue;

88118

}

89119

if (arg.startsWith(`${CLAUDE_PERMISSION_MODE_ARG}=`)) {

90120

const maybeValue = arg.slice(`${CLAUDE_PERMISSION_MODE_ARG}=`.length).trim();

91121

if (maybeValue.length > 0 && !maybeValue.startsWith("-")) {

92-

normalized.push(`${CLAUDE_PERMISSION_MODE_ARG}=${maybeValue}`);

122+

hasPermissionMode = true;

123+

if (!options?.overrideExisting) {

124+

normalized.push(`${CLAUDE_PERMISSION_MODE_ARG}=${maybeValue}`);

125+

}

93126

}

94127

continue;

95128

}

96129

normalized.push(arg);

97130

}

131+

if (options?.mode && (!hasPermissionMode || options.overrideExisting)) {

132+

normalized.push(CLAUDE_PERMISSION_MODE_ARG, options.mode);

133+

}

98134

return normalized;

99135

}

100136

@@ -132,13 +168,20 @@ export function normalizeClaudeSettingSourcesArgs(args?: string[]): string[] | u

132168

return normalized;

133169

}

134170135-

export function normalizeClaudeBackendConfig(config: CliBackendConfig): CliBackendConfig {

171+

export function normalizeClaudeBackendConfig(

172+

config: CliBackendConfig,

173+

context?: CliBackendNormalizeConfigContext,

174+

): CliBackendConfig {

136175

const output = config.output ?? "jsonl";

137176

const input = config.input ?? "stdin";

177+

const permission = resolveClaudePermissionMode(context);

138178

return {

139179

...config,

140-

args: normalizeClaudePermissionArgs(normalizeClaudeSettingSourcesArgs(config.args)),

141-

resumeArgs: normalizeClaudePermissionArgs(normalizeClaudeSettingSourcesArgs(config.resumeArgs)),

180+

args: normalizeClaudePermissionArgs(normalizeClaudeSettingSourcesArgs(config.args), permission),

181+

resumeArgs: normalizeClaudePermissionArgs(

182+

normalizeClaudeSettingSourcesArgs(config.resumeArgs),

183+

permission,

184+

),

142185

output,

143186

liveSession:

144187

config.liveSession ?? (output === "jsonl" && input === "stdin" ? "claude-stdio" : undefined),