@brierb/brier-cli 0.0.12 → 0.0.13

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.
@@ -1,6 +1,30 @@
1
1
  import { spawn } from 'node:child_process';
2
+ import { chmodSync } from 'node:fs';
3
+ import { dirname, join } from 'node:path';
4
+ import { createRequire } from 'node:module';
2
5
  import pty from 'node-pty';
3
6
  import { logger, resolveRuntimeExecutable, RUNTIME_PROMPT_FLAGS } from '../core/index.js';
7
+ const require = createRequire(import.meta.url);
8
+ /**
9
+ * 修复 node-pty 的 darwin spawn-helper 可执行权限。
10
+ *
11
+ * 现象:node-pty 在 macOS 上先 spawn 自带的 spawn-helper 再执行目标命令;
12
+ * 若该 helper 因下载/安装而缺失可执行位(0644),posix_spawnp 返回 EACCES,
13
+ * 且 node-pty 只抛出笼统的 "posix_spawnp failed."(无 errno),难以定位。
14
+ * 每次 pty 启动前兜底 chmod +x,兼容重装后权限再丢失的情况。
15
+ */
16
+ const ensurePtyHelperExecutable = () => {
17
+ if (process.platform !== 'darwin')
18
+ return;
19
+ try {
20
+ const pkgDir = dirname(require.resolve('node-pty/package.json'));
21
+ const helper = join(pkgDir, 'prebuilds', `darwin-${process.arch}`, 'spawn-helper');
22
+ chmodSync(helper, 0o755);
23
+ }
24
+ catch {
25
+ // helper 权限修正失败不致命:若 node-pty 自身可执行则正常走;否则抛错由上层捕获
26
+ }
27
+ };
4
28
  const MAX_CONCURRENT = 3;
5
29
  /** 取消后等待 SIGTERM 生效的时间,超时升级 SIGKILL(仅 pipe 模式需要;pty.kill 为同步终止) */
6
30
  const KILL_GRACE_MS = 2_000;
@@ -125,6 +149,7 @@ export const createTaskExecutor = (callbacks) => {
125
149
  const executePty = (task, cmd, args, childEnv, initialInput) => {
126
150
  let handle;
127
151
  try {
152
+ ensurePtyHelperExecutable();
128
153
  handle = pty.spawn(cmd, args, {
129
154
  name: 'xterm-256color',
130
155
  cols: 120,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brierb/brier-cli",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Brier 平台接入命令行工具:通过加密隧道将本机接入 Brier 远程编码池,接收并执行远程任务",
5
5
  "keywords": [
6
6
  "brier",