magic-agent 1.0.46 → 1.0.49

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.
@@ -71,7 +71,30 @@ function resolve() {
71
71
  if (process.env.MAGIC_AGENT_BIN && fs.existsSync(process.env.MAGIC_AGENT_BIN)) {
72
72
  return process.env.MAGIC_AGENT_BIN;
73
73
  }
74
- return fromDist() || fromLocalBin() || buildFromSource();
74
+ return ensureExecutable(fromDist() || fromLocalBin() || buildFromSource());
75
+ }
76
+
77
+ /* ensureExecutable 补回可执行位再交出去。
78
+ *
79
+ * 为什么需要它(2026-10-20 实测):npm registry 上的包权限一律是 644 ——
80
+ * actions/upload-artifact 打包时不保留文件权限,CI 里构建出的 755 到下载时丢了。
81
+ * 现象是 `spawnSync … EACCES`,而本地 `npm i ./xxx.tgz` 一切正常(tarball 里是 755),
82
+ * 所以只有真从 registry 装的人才会碰上。
83
+ *
84
+ * 已在 CI 侧补了 chmod + 断言;这里再加一层运行时兜底,让**已经发出去的坏包**
85
+ * 也能自救 —— 用户升级到修复版之前,不该被这个卡住。
86
+ * 只对 Unix 生效:Windows 没有可执行位概念(.exe 直接可跑),chmod 会报 EPERM/EINVAL。
87
+ */
88
+ function ensureExecutable(p) {
89
+ if (!p || isWin) return p;
90
+ try {
91
+ const mode = fs.statSync(p).mode;
92
+ if (mode & 0o111) return p; // 已有任意可执行位,不动
93
+ fs.chmodSync(p, 0o755);
94
+ } catch (_) {
95
+ /* 改不动就算了:交给 spawnSync 去报原始错误,别在这里掩盖 */
96
+ }
97
+ return p;
75
98
  }
76
99
 
77
100
  const bin = resolve();
@@ -58,10 +58,28 @@ function buildFromSource() {
58
58
  }
59
59
  }
60
60
 
61
- const bin =
61
+ const bin = ensureExecutable(
62
62
  process.env.MAGIC_CLIENT_BIN && fs.existsSync(process.env.MAGIC_CLIENT_BIN)
63
63
  ? process.env.MAGIC_CLIENT_BIN
64
- : fromDist() || fromLocalBin() || buildFromSource();
64
+ : fromDist() || fromLocalBin() || buildFromSource()
65
+ );
66
+
67
+ /* ensureExecutable 补回可执行位再交出去。
68
+ *
69
+ * npm registry 上的包权限一律 644(artifact 上传不保留权限位,见 release.yml 的
70
+ * chmod 那一步),直接 spawn 会 EACCES。CI 侧已修,这里再加一层运行时兜底,
71
+ * 让**已经发出去的坏包**也能自救。Unix 专用:Windows 的 .exe 不需要可执行位。
72
+ */
73
+ function ensureExecutable(p) {
74
+ if (!p || isWin) return p;
75
+ try {
76
+ if (fs.statSync(p).mode & 0o111) return p;
77
+ fs.chmodSync(p, 0o755);
78
+ } catch (_) {
79
+ /* 改不动就交给 spawnSync 报原始错误 */
80
+ }
81
+ return p;
82
+ }
65
83
 
66
84
  if (!bin) {
67
85
  const packed = fs.existsSync(distDir) ? fs.readdirSync(distDir) : [];
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-agent",
3
- "version": "1.0.46",
3
+ "version": "1.0.49",
4
4
  "description": "专业的 agent CLI 代理工具 - 统一 claude / codebuddy / trae / llm / codex / openclaw 引擎",
5
5
  "license": "MIT",
6
6
  "bin": {