ai-lab-bridge 0.1.2 → 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 +14 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1168,6 +1168,14 @@ async function cmdConnect() {
1168
1168
  persistConfig(SERVER, TOKEN);
1169
1169
 
1170
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
+ }
1171
1179
  await daemonMain();
1172
1180
  return;
1173
1181
  }
@@ -1283,6 +1291,12 @@ async function cmdStop() {
1283
1291
  console.log("[bridge] 后台进程未运行。");
1284
1292
  return;
1285
1293
  }
1294
+ await stopDaemonByCtl(ctl);
1295
+ console.log(`[bridge] 后台进程已停止 (pid=${ctl.pid})`);
1296
+ }
1297
+
1298
+ /** 按 ctl 记录停止指定 daemon:控制面 /stop → 等待退出 → 强杀兜底 → 清理 ctl 文件。 */
1299
+ async function stopDaemonByCtl(ctl) {
1286
1300
  try {
1287
1301
  await fetch(`http://127.0.0.1:${ctl.port}/stop`, {
1288
1302
  method: "POST",
@@ -1304,7 +1318,6 @@ async function cmdStop() {
1304
1318
  } catch {}
1305
1319
  }
1306
1320
  removeCtlFiles();
1307
- console.log(`[bridge] 后台进程已停止 (pid=${ctl.pid})`);
1308
1321
  }
1309
1322
 
1310
1323
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-lab-bridge",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "AI 开发平台设备桥接进程:反连平台 WebSocket,驱动本地 Claude Code / Codex CLI 执行任务并回传事件流",
5
5
  "license": "MIT",
6
6
  "files": [