@ait-co/devtools 0.1.104 → 0.1.105

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/dist/mcp/cli.js CHANGED
@@ -3560,6 +3560,24 @@ function killAndWait(pid, graceMs = 2e3) {
3560
3560
  } catch {}
3561
3561
  }
3562
3562
  /**
3563
+ * Reaps an orphaned cloudflared tunnel child left behind by a previous session
3564
+ * (issue #628). The normal shutdown path TERM-cascades to the child, but a
3565
+ * SIGKILL'd or crashed Node process can't run cleanup — its cloudflared child
3566
+ * keeps the (now stale) quick tunnel alive. When `acquireLock` reclaims such a
3567
+ * lock, this kills the still-alive `tunnelChildPid` so the new session starts
3568
+ * from a clean slate (companion to the #347/#571 zombie-daemon defenses).
3569
+ *
3570
+ * No-op when the lock carries no `tunnelChildPid` (older lock files) or the
3571
+ * child is already gone. SECRET-HANDLING: logs the PID only — never the tunnel
3572
+ * host/wss (those never enter the lock file or this path).
3573
+ */
3574
+ function reapOrphanTunnelChild(existing) {
3575
+ const childPid = existing.tunnelChildPid;
3576
+ if (typeof childPid !== "number" || !isPidAlive(childPid)) return;
3577
+ process.stderr.write(`[ait-debug] reaping orphaned tunnel child PID=${childPid} from previous session.\n`);
3578
+ killAndWait(childPid);
3579
+ }
3580
+ /**
3563
3581
  * Reads the current lock file without acquiring it. Returns the parsed
3564
3582
  * `LockData` when the file exists and is valid, otherwise `null`. Used by
3565
3583
  * `get_debug_status` to surface the `serverLockHolder` field without
@@ -3591,13 +3609,17 @@ function acquireLock(options = {}) {
3591
3609
  else if (force) {
3592
3610
  process.stderr.write(`[ait-debug] --force: terminating existing session PID=${existing.pid} …\n`);
3593
3611
  killAndWait(existing.pid);
3612
+ reapOrphanTunnelChild(existing);
3594
3613
  process.stderr.write(`[ait-debug] --force: PID=${existing.pid} stopped, taking over.\n`);
3595
3614
  } else {
3596
3615
  const urlPart = existing.wssUrl != null ? `wssUrl=${existing.wssUrl}` : "wssUrl=(tunnel starting)";
3597
3616
  process.stderr.write(`[ait-debug] 기존 debug-mode 세션이 이미 실행 중 — PID=${existing.pid}, started ${existing.startedAt}, ${urlPart}\n[ait-debug] 회복: \`kill ${existing.pid}\` 또는 \`npx @ait-co/devtools devtools-mcp --force\`\n`);
3598
3617
  throw new ServerLockConflictError(existing.pid, existing.wssUrl, existing.startedAt);
3599
3618
  }
3600
- } else process.stderr.write(`[ait-debug] stale lock from PID ${existing.pid} recovered — starting fresh.\n`);
3619
+ } else {
3620
+ process.stderr.write(`[ait-debug] stale lock from PID ${existing.pid} recovered — starting fresh.\n`);
3621
+ reapOrphanTunnelChild(existing);
3622
+ }
3601
3623
  const data = {
3602
3624
  pid: process.pid,
3603
3625
  wssUrl: null,
@@ -4833,7 +4855,7 @@ async function readMcpSdkVersion() {
4833
4855
  * some test environments that skip the build step).
4834
4856
  */
4835
4857
  function readDevtoolsVersion() {
4836
- return "0.1.104";
4858
+ return "0.1.105";
4837
4859
  }
4838
4860
  /**
4839
4861
  * Derives the next recommended action from a completed diagnostics snapshot.
@@ -5425,7 +5447,7 @@ function createDebugServer(deps) {
5425
5447
  const collector = collectorDep ?? new InMemoryDiagnosticsCollector();
5426
5448
  const server = new Server({
5427
5449
  name: "ait-debug",
5428
- version: "0.1.104"
5450
+ version: "0.1.105"
5429
5451
  }, { capabilities: { tools: { listChanged: true } } });
5430
5452
  server.setRequestHandler(ListToolsRequestSchema, () => {
5431
5453
  const conn = router.active;
@@ -7563,7 +7585,7 @@ function createDevServer(deps = {}) {
7563
7585
  const aitSource = deps.aitSource ?? new HttpAitSource({ stateEndpoint });
7564
7586
  const server = new Server({
7565
7587
  name: "ait-devtools",
7566
- version: "0.1.104"
7588
+ version: "0.1.105"
7567
7589
  }, { capabilities: { tools: {} } });
7568
7590
  server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: DEV_TOOL_DEFINITIONS.map((tool) => ({ ...tool })) }));
7569
7591
  server.setRequestHandler(CallToolRequestSchema, async (request) => {