@lujoai/lujo-mcp 0.7.6 → 0.7.7

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.
package/bin/cli.js CHANGED
@@ -91,12 +91,7 @@ or reinstall the meta package:
91
91
  // MCP stdio and localhost HTTP, so Browser SDK /ingest events are immediately
92
92
  // visible to the MCP client. Keep an explicit --no-http escape hatch for
93
93
  // clients that require a pure stdio process (and for release smoke tests).
94
- const requestedArgs = process.argv.slice(2);
95
- const disableHttp = requestedArgs.includes('--no-http');
96
- const childArgs = requestedArgs.filter((arg) => arg !== '--no-http');
97
- if (!disableHttp && !childArgs.includes('--http')) childArgs.push('--http');
98
-
99
- const child = spawn(bin, childArgs, {
94
+ const child = spawn(bin, translateArgs(process.argv.slice(2)), {
100
95
  stdio: 'inherit',
101
96
  windowsHide: true,
102
97
  });
@@ -104,10 +99,53 @@ or reinstall the meta package:
104
99
  console.error(`[lujo-mcp-server] failed to spawn ${bin}: ${err.message}`);
105
100
  process.exit(1);
106
101
  });
102
+
103
+ // FIX(R8): 终止信号必须转发。宿主(Claude / Codex / Trae 等)停止 MCP 服务
104
+ // 时只处理它直接启动的那个进程——也就是本启动器——被 spawn 出来的二进制不会
105
+ // 被自动带走(Windows 没有 POSIX 的进程组/信号语义,实测杀掉启动器后二进制
106
+ // 存活并继续监听统一模式的 HTTP 端口)。孤儿会接收浏览器 SDK 发往该端口的
107
+ // 全部上报,新起的实例抢不到端口,当前会话因此表现为「报过错但
108
+ // diagnose_issue 查不到任何现场」。
109
+ // 子进程自身退出时由下面的 exit 处理器决定本进程退出码,这里只负责带离。
110
+ let forwarding = false;
111
+ function forward(signal) {
112
+ if (forwarding) return;
113
+ forwarding = true;
114
+ try {
115
+ child.kill(signal);
116
+ } catch {
117
+ // 子进程可能已经退出:无需要做的,交给 exit 兜底
118
+ }
119
+ }
120
+ // Windows 收不到 SIGTERM/SIGHUP(注册无害且永不触发),但能收到 SIGBREAK。
121
+ for (const sig of ['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGBREAK']) {
122
+ process.on(sig, () => forward('SIGTERM'));
123
+ }
124
+ process.on('uncaughtException', (err) => {
125
+ console.error(`[lujo-mcp-server] launcher error: ${err && err.message}`);
126
+ forward('SIGTERM');
127
+ process.exit(1);
128
+ });
129
+ // 任何原因导致的本进程退出(含上面的 process.exit 路径)都不能把子进程留下。
130
+ process.on('exit', () => forward('SIGTERM'));
131
+
107
132
  child.on('exit', (code, signal) => {
108
133
  if (signal) process.kill(process.pid, signal);
109
134
  else process.exit(code == null ? 0 : code);
110
135
  });
111
136
  }
112
137
 
113
- run();
138
+ // 参数拼装与 npm 默认模式:抽出以便在无平台二进制的环境下直接单测。
139
+ function translateArgs(requestedArgs) {
140
+ const args = Array.isArray(requestedArgs) ? requestedArgs.slice() : [];
141
+ const disableHttp = args.includes('--no-http');
142
+ const childArgs = args.filter((arg) => arg !== '--no-http');
143
+ if (!disableHttp && !childArgs.includes('--http')) childArgs.push('--http');
144
+ return childArgs;
145
+ }
146
+
147
+ if (require.main === module) {
148
+ run();
149
+ }
150
+
151
+ module.exports = { platformPackageName, translateArgs, binaryNameFor };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * lujo-mcp Browser SDK v0.7.5
2
+ * lujo-mcp Browser SDK v0.7.7
3
3
  *
4
4
  * 版本以 browser-sdk/package.json 的 version 为准(本注释仅为可读性,
5
5
  * 升级时随版本 bump 一并更新,避免再次漂移)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lujoai/lujo-mcp",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "Lujo-MCP — MCP Runtime Debugging Context Server for AI coding agents. Gives Claude, Cursor, Trae and any MCP-compatible client real runtime debugging context: browser errors, console logs, network failures, UI interaction traces and session context. Zero-config, install via npm.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,8 +43,8 @@
43
43
  "prepublishOnly": "node ./scripts/check-clean-bin.js"
44
44
  },
45
45
  "optionalDependencies": {
46
- "@lujoai/lujo-mcp-win32-x64": "0.7.6",
47
- "@lujoai/lujo-mcp-linux-x64": "0.7.6",
48
- "@lujoai/lujo-mcp-osx-arm64": "0.7.6"
46
+ "@lujoai/lujo-mcp-win32-x64": "0.7.7",
47
+ "@lujoai/lujo-mcp-linux-x64": "0.7.7",
48
+ "@lujoai/lujo-mcp-osx-arm64": "0.7.7"
49
49
  }
50
50
  }