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

推荐订阅源

Vercel News
Vercel News
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
IT之家
IT之家
B
Blog
博客园_首页
量子位
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
J
Java Code Geeks
H
Help Net Security
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
D
DataBreaches.Net
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News

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(crabbox): scope env-wrapped macOS bootstrap · opencla...
vincentkoc · 2026-05-27 · via Recent Commits to openclaw:main

@@ -531,12 +531,6 @@ function runCommandArgs(commandArgs) {

531531532532

function normalizedCommandWords(commandArgs) {

533533

const words = commandArgs.length === 1 ? commandArgs[0].split(/\s+/u) : [...commandArgs];

534-

while (words[0] === "env") {

535-

words.shift();

536-

while (/^[A-Za-z_][A-Za-z0-9_]*=/.test(words[0] ?? "")) {

537-

words.shift();

538-

}

539-

}

540534

while (/^[A-Za-z_][A-Za-z0-9_]*=/.test(words[0] ?? "")) {

541535

words.shift();

542536

}

@@ -708,6 +702,12 @@ function stripShellExecutionPrefixes(words) {

708702

}

709703

continue;

710704

}

705+

if (first === "env") {

706+

if (!stripEnvCommandOptions(words, { canShimIgnoreEnvironment: false })) {

707+

return words;

708+

}

709+

continue;

710+

}

711711

if (first === "time") {

712712

words.shift();

713713

stripTimeOptions(words);

@@ -721,6 +721,91 @@ function stripShellExecutionPrefixes(words) {

721721

}

722722

}

723723724+

function stripEnvCommandOptions(words, { canShimIgnoreEnvironment = true } = {}) {

725+

const originalWords = [...words];

726+

const envCommand = words.shift() ?? "";

727+

let ignoresEnvironment = false;

728+

for (;;) {

729+

const word = words[0] ?? "";

730+

if (!word) {

731+

words.splice(0, words.length, ...originalWords);

732+

return false;

733+

}

734+

if (word === "--") {

735+

words.shift();

736+

return true;

737+

}

738+

if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(word)) {

739+

words.shift();

740+

continue;

741+

}

742+

if (word === "-S" || word === "--split-string") {

743+

if (ignoresEnvironment) {

744+

words.splice(0, words.length, ...originalWords);

745+

return false;

746+

}

747+

words.shift();

748+

const split = splitShellWords(words.shift() ?? "");

749+

words.unshift(...split);

750+

return words.length > 0;

751+

}

752+

if (word.startsWith("-S") && word !== "-S") {

753+

if (ignoresEnvironment) {

754+

words.splice(0, words.length, ...originalWords);

755+

return false;

756+

}

757+

words.shift();

758+

words.unshift(...splitShellWords(word.slice(2)));

759+

return words.length > 0;

760+

}

761+

if (word.startsWith("--split-string=")) {

762+

if (ignoresEnvironment) {

763+

words.splice(0, words.length, ...originalWords);

764+

return false;

765+

}

766+

words.shift();

767+

words.unshift(...splitShellWords(word.slice("--split-string=".length)));

768+

return words.length > 0;

769+

}

770+

if (word === "-i" || word === "--ignore-environment") {

771+

if (!canShimIgnoreEnvironment || envCommand.includes("/")) {

772+

words.splice(0, words.length, ...originalWords);

773+

return false;

774+

}

775+

ignoresEnvironment = true;

776+

words.shift();

777+

continue;

778+

}

779+

if (word === "-u" || word === "--unset" || word === "-C" || word === "--chdir") {

780+

words.shift();

781+

if (words[0]) {

782+

words.shift();

783+

}

784+

continue;

785+

}

786+

if (word.startsWith("--unset=") || word.startsWith("--chdir=")) {

787+

words.shift();

788+

continue;

789+

}

790+

if (word.startsWith("-") && word !== "-") {

791+

if (word.includes("i")) {

792+

if (!canShimIgnoreEnvironment || envCommand.includes("/")) {

793+

words.splice(0, words.length, ...originalWords);

794+

return false;

795+

}

796+

ignoresEnvironment = true;

797+

}

798+

words.shift();

799+

continue;

800+

}

801+

if (ignoresEnvironment && (!canShimIgnoreEnvironment || envCommand.includes("/"))) {

802+

words.splice(0, words.length, ...originalWords);

803+

return false;

804+

}

805+

return true;

806+

}

807+

}

808+724809

function shellWordBasename(word) {

725810

return (word ?? "").split("/").pop() ?? "";

726811

}

@@ -1249,7 +1334,27 @@ function remoteAwsMacosJsBootstrap({ packageManager = false } = {}) {

12491334

'tar -xzf "$tmp_dir/$pkg" -C "$tool_root" || { status=$?; rm -rf "$tmp_dir"; return "$status"; };',

12501335

'rm -rf "$tmp_dir";',

12511336

"fi;",

1252-

"node --version >&2;",

1337+

"node --version >&2 || return 1;",

1338+

"openclaw_crabbox_env() {",

1339+

"openclaw_env_args=();",

1340+

"openclaw_env_ignore=0;",

1341+

"openclaw_env_path_seen=0;",

1342+

'while [ "$#" -gt 0 ]; do',

1343+

'case "$1" in',

1344+

'-i|--ignore-environment) openclaw_env_ignore=1; openclaw_env_args+=("$1"); shift ;;',

1345+

'-S|--split-string|-S*|--split-string=*) command env "${openclaw_env_args[@]}" "$@"; return ;;',

1346+

'-[!-]*i*) openclaw_env_ignore=1; openclaw_env_args+=("$1"); shift ;;',

1347+

'-u|--unset|-C|--chdir) openclaw_env_args+=("$1"); shift; if [ "$#" -gt 0 ]; then openclaw_env_args+=("$1"); shift; fi ;;',

1348+

'--unset=*|--chdir=*) openclaw_env_args+=("$1"); shift ;;',

1349+

'PATH=*) if [ "$openclaw_env_ignore" = "1" ]; then openclaw_env_args+=("PATH=$PATH:${1#PATH=}"); else openclaw_env_args+=("$1"); fi; openclaw_env_path_seen=1; shift ;;',

1350+

'[A-Za-z_]*=*) openclaw_env_args+=("$1"); shift ;;',

1351+

'--) openclaw_env_args+=("--"); shift; break ;;',

1352+

"*) break ;;",

1353+

"esac;",

1354+

"done;",

1355+

'if [ "$openclaw_env_ignore" = "1" ] && [ "$openclaw_env_path_seen" = "0" ]; then openclaw_env_args+=("PATH=$PATH"); fi;',

1356+

'command env "${openclaw_env_args[@]}" "$@";',

1357+

"};",

12531358

];

12541359

if (packageManager) {

12551360

bootstrap.push(

@@ -1265,9 +1370,34 @@ function remoteAwsMacosJsBootstrap({ packageManager = false } = {}) {

12651370

return bootstrap.join(" ");

12661371

}

126713721373+

function scopedAwsMacosEnvCommand(commandArgs) {

1374+

if (commandArgs.length <= 1 || shellWordBasename(commandArgs[0]) !== "env" || commandArgs[0].includes("/")) {

1375+

return null;

1376+

}

1377+1378+

const targetWords = [...commandArgs];

1379+

if (!stripEnvCommandOptions(targetWords, { canShimIgnoreEnvironment: true })) {

1380+

return null;

1381+

}

1382+1383+

const targetEntrypoint = shellWordBasename(targetWords[0]);

1384+

if (!jsRuntimeEntrypoints.has(targetEntrypoint) && !awsMacosCorepackEntrypoints.has(targetEntrypoint)) {

1385+

return null;

1386+

}

1387+1388+

return {

1389+

runtimeEntrypoint: targetEntrypoint,

1390+

packageManager: awsMacosCorepackEntrypoints.has(targetEntrypoint),

1391+

shellCommand: `openclaw_crabbox_env ${shellJoin(commandArgs.slice(1))}`,

1392+

};

1393+

}

1394+12681395

function injectRemoteAwsMacosJsBootstrap(commandArgs, providerName) {

12691396

const runArgs = runCommandArgs(commandArgs);

1270-

const runtimeEntrypoint = commandRuntimeEntrypoint(runArgs);

1397+

const directScopedEnvCommand = hasOption(commandArgs, "--shell")

1398+

? null

1399+

: scopedAwsMacosEnvCommand(runArgs);

1400+

const runtimeEntrypoint = directScopedEnvCommand?.runtimeEntrypoint || commandRuntimeEntrypoint(runArgs);

12711401

if (!isAwsMacosRemoteTarget(commandArgs, providerName) || !runtimeEntrypoint) {

12721402

return commandArgs;

12731403

}

@@ -1280,11 +1410,12 @@ function injectRemoteAwsMacosJsBootstrap(commandArgs, providerName) {

12801410

const normalizedArgs = [...commandArgs];

12811411

const remoteCommand = normalizedArgs.slice(start);

12821412

const originalShellCommand =

1283-

hasOption(normalizedArgs, "--shell") && remoteCommand.length === 1

1413+

directScopedEnvCommand?.shellCommand ??

1414+

(hasOption(normalizedArgs, "--shell") && remoteCommand.length === 1

12841415

? remoteCommand[0]

1285-

: shellJoin(remoteCommand);

1416+

: shellJoin(remoteCommand));

12861417

const shellCommand = `${remoteAwsMacosJsBootstrap({

1287-

packageManager: commandNeedsAwsMacosPackageManager(runArgs),

1418+

packageManager: directScopedEnvCommand?.packageManager || commandNeedsAwsMacosPackageManager(runArgs),

12881419

})} && { ${originalShellCommand}\n}`;

1289142012901421

if (!hasOption(normalizedArgs, "--shell")) {