terminator-mcp-agent 0.15.19 → 0.16.1
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/index.js +51 -3
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -185,10 +185,58 @@ if (argv.includes("--add-to-app")) {
|
|
|
185
185
|
process.on("SIGTERM", shutdown);
|
|
186
186
|
process.on("exit", shutdown);
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
let restartAttempts = 0;
|
|
189
|
+
const MAX_RESTART_ATTEMPTS = 3;
|
|
190
|
+
const RESTART_DELAY = 1000; // 1 second
|
|
191
|
+
|
|
192
|
+
child.on("exit", (code, signal) => {
|
|
193
|
+
// Check for stack overflow exit code on Windows (3221225725 = 0xC00000FD)
|
|
194
|
+
const isStackOverflow = code === 3221225725 || code === -1073741571;
|
|
195
|
+
|
|
196
|
+
if (code !== 0 && !shuttingDown) {
|
|
197
|
+
console.error(`[MCP exited with code ${code}${signal ? ` (signal: ${signal})` : ''}]`);
|
|
198
|
+
|
|
199
|
+
// Auto-restart on crash if under max attempts
|
|
200
|
+
if (restartAttempts < MAX_RESTART_ATTEMPTS) {
|
|
201
|
+
restartAttempts++;
|
|
202
|
+
|
|
203
|
+
if (isStackOverflow) {
|
|
204
|
+
console.error(`[Stack overflow detected - this often happens with deeply nested UI trees]`);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
console.error(`[Attempting to restart MCP server (attempt ${restartAttempts}/${MAX_RESTART_ATTEMPTS})...]`);
|
|
208
|
+
|
|
209
|
+
setTimeout(() => {
|
|
210
|
+
console.error(`[Restarting MCP server...]`);
|
|
211
|
+
|
|
212
|
+
// Spawn new process
|
|
213
|
+
const newChild = spawn(binary, agentArgs, {
|
|
214
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
215
|
+
shell: false,
|
|
216
|
+
detached: process.platform !== "win32",
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Reconnect pipes
|
|
220
|
+
process.stdin.unpipe(child.stdin);
|
|
221
|
+
process.stdin.pipe(newChild.stdin);
|
|
222
|
+
newChild.stdout.pipe(process.stdout);
|
|
223
|
+
newChild.stderr.pipe(process.stderr);
|
|
224
|
+
|
|
225
|
+
// Replace child reference
|
|
226
|
+
child = newChild;
|
|
227
|
+
|
|
228
|
+
// Reattach exit handler with same logic
|
|
229
|
+
child.on("exit", arguments.callee);
|
|
230
|
+
|
|
231
|
+
console.error(`[MCP server restarted successfully]`);
|
|
232
|
+
}, RESTART_DELAY);
|
|
233
|
+
|
|
234
|
+
return; // Don't exit the wrapper process
|
|
235
|
+
} else {
|
|
236
|
+
console.error(`[Max restart attempts reached. Exiting.]`);
|
|
237
|
+
}
|
|
191
238
|
}
|
|
239
|
+
|
|
192
240
|
process.exit(code);
|
|
193
241
|
});
|
|
194
242
|
}
|
package/package.json
CHANGED
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
],
|
|
16
16
|
"name": "terminator-mcp-agent",
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"terminator-mcp-darwin-arm64": "0.
|
|
19
|
-
"terminator-mcp-darwin-x64": "0.
|
|
20
|
-
"terminator-mcp-linux-x64-gnu": "0.
|
|
21
|
-
"terminator-mcp-win32-x64-msvc": "0.
|
|
18
|
+
"terminator-mcp-darwin-arm64": "0.16.1",
|
|
19
|
+
"terminator-mcp-darwin-x64": "0.16.1",
|
|
20
|
+
"terminator-mcp-linux-x64-gnu": "0.16.1",
|
|
21
|
+
"terminator-mcp-win32-x64-msvc": "0.16.1"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"sync-version": "node ./utils/sync-version.js",
|
|
31
31
|
"update-badges": "node ./utils/update-badges.js"
|
|
32
32
|
},
|
|
33
|
-
"version": "0.
|
|
33
|
+
"version": "0.16.1"
|
|
34
34
|
}
|