ai-helper-agent 1.14.1 → 1.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/executor.js +19 -1
package/package.json
CHANGED
package/src/executor.js
CHANGED
|
@@ -86,6 +86,12 @@ const SAFE_ENV_KEYS = [
|
|
|
86
86
|
'GIT_EDITOR', 'GIT_PAGER', 'GIT_SSH_COMMAND',
|
|
87
87
|
// 平台相关
|
|
88
88
|
'TMPDIR', 'TEMPDIR', 'TEMP', 'TMP',
|
|
89
|
+
// Windows 必要环境变量(cmd/powershell 及其子进程依赖)
|
|
90
|
+
// 缺失 COMSPEC/PATHEXT/SystemRoot 会导致 cmd 命令解析异常、npm 等工具找不到;
|
|
91
|
+
// 缺失 PSModulePath 会导致 PowerShell 找不到模块
|
|
92
|
+
'COMSPEC', 'PATHEXT', 'SystemRoot', 'WINDIR',
|
|
93
|
+
'APPDATA', 'LOCALAPPDATA', 'USERPROFILE', 'PROGRAMDATA',
|
|
94
|
+
'PSModulePath', 'NUMBER_OF_PROCESSORS', 'PROCESSOR_ARCHITECTURE',
|
|
89
95
|
// 常用工具
|
|
90
96
|
'NVM_DIR', 'NVM_BIN', 'JAVA_HOME', 'GOPATH', 'GOROOT', 'CARGO_HOME',
|
|
91
97
|
'RUSTUP_HOME', 'PYTHONPATH', 'VIRTUAL_ENV', 'CONDA_PREFIX',
|
|
@@ -134,11 +140,23 @@ function executeCommand(command, cwd, wsClient, onComplete, collectOutput = fals
|
|
|
134
140
|
const timeout = config.commandTimeout || 300000;
|
|
135
141
|
|
|
136
142
|
const { shell, args } = getShellForExec();
|
|
143
|
+
// detached 的取舍(按平台 + shell 类型):
|
|
144
|
+
// - Unix(macOS/Linux):任何 shell(zsh/bash/fish 等)都不弹窗(无控制台窗口概念),
|
|
145
|
+
// 且 detached 才能让 killProcess 的 process.kill(-pid) 杀掉整个进程组 → 始终启用。
|
|
146
|
+
// - Windows:分两类 shell——
|
|
147
|
+
// 1) MSYS/Cygwin 系(Git Bash/MSYS2/Cygwin 的 bash/zsh/fish 等):通过 pty 模拟层,
|
|
148
|
+
// 不依赖 Windows 控制台,detached 不会 AllocConsole → 不弹窗,可安全 detach。
|
|
149
|
+
// 2) Windows 原生控制台程序(cmd/powershell/pwsh 等):detached 脱离父控制台后会
|
|
150
|
+
// AllocConsole 创建可见窗口(黑窗),windowsHide 管不住 → 必须禁用 detached。
|
|
151
|
+
// 进程树终止改靠 taskkill /T /PID(killProcess Windows 分支),不依赖 detached。
|
|
152
|
+
// 用黑名单精确识别会弹窗的原生控制台程序,其余(含 MSMS/Cygwin 系)默认 detach。
|
|
153
|
+
const isWin = os.platform() === 'win32';
|
|
154
|
+
const isWinConsoleShell = isWin && /\b(cmd|powershell|pwsh)\b/i.test(shell);
|
|
137
155
|
const proc = spawn(shell, [...args, command], {
|
|
138
156
|
cwd: workdir,
|
|
139
157
|
env: buildSafeEnv(),
|
|
140
158
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
141
|
-
detached:
|
|
159
|
+
detached: !isWinConsoleShell,
|
|
142
160
|
windowsHide: true
|
|
143
161
|
});
|
|
144
162
|
|