@wu529778790/open-im 1.10.3-beta.1 → 1.10.3-beta.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.
@@ -3,6 +3,7 @@ import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "
3
3
  import { dirname, extname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { APP_HOME } from "./constants.js";
6
+ import { resolveNodeExecutable } from "./node-exec.js";
6
7
  import { isRunning } from "./service-control.js";
7
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
8
9
  const PID_FILE = join(APP_HOME, "open-im.pid");
@@ -12,15 +13,16 @@ function logError(prefix, err) {
12
13
  process.stderr.write(`[manager-control] ${prefix} ${msg}\n`);
13
14
  }
14
15
  function getManagerEntry() {
16
+ const node = resolveNodeExecutable();
15
17
  const extension = extname(fileURLToPath(import.meta.url));
16
18
  if (extension === ".ts") {
17
19
  return {
18
- command: process.execPath,
20
+ command: node,
19
21
  args: ["--import", "tsx", join(__dirname, "manager.ts")],
20
22
  };
21
23
  }
22
24
  return {
23
- command: process.execPath,
25
+ command: node,
24
26
  args: [join(__dirname, "manager.js")],
25
27
  };
26
28
  }
@@ -111,7 +113,8 @@ export async function startManagerProcess(cwd) {
111
113
  }
112
114
  catch (err) {
113
115
  logError("Manager process spawn failed:", err);
114
- throw new Error(`Failed to start manager process: ${err instanceof Error ? err.message : String(err)}`);
116
+ const hint = " Node 安装路径已失效,请设置环境变量 OPEN_IM_NODE 指向有效的 node 可执行文件(Windows 一般为 node.exe)。";
117
+ throw new Error(`Failed to start manager process: ${err instanceof Error ? err.message : String(err)}${hint}`);
115
118
  }
116
119
  child.unref();
117
120
  child.on("error", (err) => {
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 用于 spawn 子进程的 Node 可执行文件路径。
3
+ * Windows 上偶发 process.execPath 指向已删除/移动的安装(如 D: 盘路径失效),导致 ENOENT;
4
+ * 此时回退到 PATH 中的 `node`,或通过 OPEN_IM_NODE / NODE_EXE 显式指定。
5
+ */
6
+ export declare function resolveNodeExecutable(): string;
@@ -0,0 +1,16 @@
1
+ import { existsSync } from "node:fs";
2
+ /**
3
+ * 用于 spawn 子进程的 Node 可执行文件路径。
4
+ * Windows 上偶发 process.execPath 指向已删除/移动的安装(如 D: 盘路径失效),导致 ENOENT;
5
+ * 此时回退到 PATH 中的 `node`,或通过 OPEN_IM_NODE / NODE_EXE 显式指定。
6
+ */
7
+ export function resolveNodeExecutable() {
8
+ const fromEnv = (process.env.OPEN_IM_NODE ?? process.env.NODE_EXE)?.trim();
9
+ if (fromEnv && existsSync(fromEnv)) {
10
+ return fromEnv;
11
+ }
12
+ if (process.execPath && existsSync(process.execPath)) {
13
+ return process.execPath;
14
+ }
15
+ return "node";
16
+ }
@@ -3,6 +3,7 @@ import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
3
3
  import { dirname, extname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { APP_HOME, SHUTDOWN_PORT } from "./constants.js";
6
+ import { resolveNodeExecutable } from "./node-exec.js";
6
7
  const __dirname = dirname(fileURLToPath(import.meta.url));
7
8
  const PID_FILE = join(APP_HOME, "open-im-worker.pid");
8
9
  const PORT_FILE = join(APP_HOME, "open-im.port");
@@ -16,15 +17,16 @@ function removePortFile() {
16
17
  }
17
18
  }
18
19
  function getServiceEntry() {
20
+ const node = resolveNodeExecutable();
19
21
  const extension = extname(fileURLToPath(import.meta.url));
20
22
  if (extension === ".ts") {
21
23
  return {
22
- command: process.execPath,
24
+ command: node,
23
25
  args: ["--import", "tsx", join(__dirname, "index.ts")],
24
26
  };
25
27
  }
26
28
  return {
27
- command: process.execPath,
29
+ command: node,
28
30
  args: [join(__dirname, "index.js")],
29
31
  };
30
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.10.3-beta.1",
3
+ "version": "1.10.3-beta.2",
4
4
  "description": "Multi-platform IM bridge for AI CLI tools (Claude, Codex, CodeBuddy)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",