ai-lab-bridge 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/index.js +16 -6
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -179,15 +179,14 @@ async function detectCapabilities() {
179
179
  if (fallback) cursorBinary = "cursor-agent";
180
180
  return fallback;
181
181
  };
182
- const [claudeVersion, codexVersion, opencodeVersion, codefreeVersion, cursorVersion, geminiVersion, qwenVersion, iflowVersion] = await Promise.all([
182
+ // 仅探测平台支持的 CLI(gemini/iflow 已下线不支持,探测会以"未安装"标签干扰用户)
183
+ const [claudeVersion, codexVersion, opencodeVersion, codefreeVersion, cursorVersion, qwenVersion] = await Promise.all([
183
184
  runVersionProbe("claude", "--version"),
184
185
  runVersionProbe("codex", "--version"),
185
186
  runVersionProbe("opencode", "--version"),
186
187
  runVersionProbe("codefree-o", "--version"),
187
188
  probeCursor(),
188
- runVersionProbe("gemini", "--version"),
189
189
  runVersionProbe("qwen", "--version"),
190
- runVersionProbe("iflow", "--version"),
191
190
  ]);
192
191
  return [
193
192
  { cli: "claude", version: claudeVersion, available: !!claudeVersion },
@@ -195,9 +194,7 @@ async function detectCapabilities() {
195
194
  { cli: "opencode", version: opencodeVersion, available: !!opencodeVersion },
196
195
  { cli: "codefree-o", version: codefreeVersion, available: !!codefreeVersion },
197
196
  { cli: "cursor", version: cursorVersion, available: !!cursorVersion },
198
- { cli: "gemini", version: geminiVersion, available: !!geminiVersion },
199
197
  { cli: "qwen", version: qwenVersion, available: !!qwenVersion },
200
- { cli: "iflow", version: iflowVersion, available: !!iflowVersion },
201
198
  ];
202
199
  }
203
200
 
@@ -1171,6 +1168,14 @@ async function cmdConnect() {
1171
1168
  persistConfig(SERVER, TOKEN);
1172
1169
 
1173
1170
  if (args.foreground) {
1171
+ // 前台运行前先停掉已有后台 daemon:否则旧进程仍在连接平台发心跳,
1172
+ // 且控制面文件被本进程覆盖后,stop/status 将无法再管理它(成为孤儿进程)
1173
+ const ctl = readCtlState();
1174
+ if (ctl && isPidAlive(ctl.pid)) {
1175
+ console.log(`[bridge] 检测到后台进程正在运行(pid=${ctl.pid}),先停止...`);
1176
+ await stopDaemonByCtl(ctl);
1177
+ console.log(`[bridge] 后台进程已停止 (pid=${ctl.pid})`);
1178
+ }
1174
1179
  await daemonMain();
1175
1180
  return;
1176
1181
  }
@@ -1286,6 +1291,12 @@ async function cmdStop() {
1286
1291
  console.log("[bridge] 后台进程未运行。");
1287
1292
  return;
1288
1293
  }
1294
+ await stopDaemonByCtl(ctl);
1295
+ console.log(`[bridge] 后台进程已停止 (pid=${ctl.pid})`);
1296
+ }
1297
+
1298
+ /** 按 ctl 记录停止指定 daemon:控制面 /stop → 等待退出 → 强杀兜底 → 清理 ctl 文件。 */
1299
+ async function stopDaemonByCtl(ctl) {
1289
1300
  try {
1290
1301
  await fetch(`http://127.0.0.1:${ctl.port}/stop`, {
1291
1302
  method: "POST",
@@ -1307,7 +1318,6 @@ async function cmdStop() {
1307
1318
  } catch {}
1308
1319
  }
1309
1320
  removeCtlFiles();
1310
- console.log(`[bridge] 后台进程已停止 (pid=${ctl.pid})`);
1311
1321
  }
1312
1322
 
1313
1323
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ai-lab-bridge",
3
- "version": "0.1.1",
4
- "description": "AI Lab 平台设备桥接进程:反连平台 WebSocket,驱动本地 Claude Code / Codex CLI 执行任务并回传事件流",
3
+ "version": "0.1.3",
4
+ "description": "AI 开发平台设备桥接进程:反连平台 WebSocket,驱动本地 Claude Code / Codex CLI 执行任务并回传事件流",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "index.js",