adhdev 0.9.13 → 0.9.15

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/index.js CHANGED
@@ -11585,6 +11585,11 @@ __export(provider_cli_adapter_exports, {
11585
11585
  function normalizeComparableTranscriptText(value) {
11586
11586
  return sanitizeTerminalText(String(value || "")).replace(/\s+/g, " ").trim();
11587
11587
  }
11588
+ function hasVisibleInterruptPrompt(text) {
11589
+ return /\bEnter\s+to\s+interrupt\b(?:\s*,?\s*Ctrl\s*(?:\+|-)?\s*C\s+to\s+cancel)?/i.test(
11590
+ sanitizeTerminalText(text || "")
11591
+ );
11592
+ }
11588
11593
  function parsedTranscriptIsRicherThanCommitted(parsedMessages, committedMessages) {
11589
11594
  if (!Array.isArray(parsedMessages) || !Array.isArray(committedMessages)) return false;
11590
11595
  if (parsedMessages.length > committedMessages.length) return true;
@@ -12904,7 +12909,7 @@ var init_provider_cli_adapter = __esm({
12904
12909
  };
12905
12910
  }
12906
12911
  const hasVisibleAssistantMessage = Array.isArray(result?.messages) && result.messages.some((message) => message?.role === "assistant" && typeof message?.content === "string" && message.content.trim());
12907
- const shouldClampStaleGeneratingToIdle = result?.status === "generating" && this.currentStatus === "idle" && !this.currentTurnScope && !result?.activeModal && hasVisibleAssistantMessage;
12912
+ const shouldClampStaleGeneratingToIdle = result?.status === "generating" && this.currentStatus === "idle" && !this.currentTurnScope && !result?.activeModal && hasVisibleAssistantMessage && !hasVisibleInterruptPrompt(screenText);
12908
12913
  if (shouldClampStaleGeneratingToIdle) {
12909
12914
  result = {
12910
12915
  ...result,
@@ -37763,10 +37768,14 @@ var init_router = __esm({
37763
37768
  currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
37764
37769
  } catch {
37765
37770
  }
37766
- if (currentInstalled === latest) {
37771
+ const runningVersion = typeof this.deps.statusVersion === "string" ? this.deps.statusVersion.trim().replace(/^v/, "") : null;
37772
+ if (currentInstalled === latest && runningVersion === latest) {
37767
37773
  LOG.info("Upgrade", `Already on latest version v${latest}; skipping install`);
37768
37774
  return { success: true, upgraded: false, alreadyLatest: true, version: latest };
37769
37775
  }
37776
+ if (currentInstalled === latest && runningVersion && runningVersion !== latest) {
37777
+ LOG.info("Upgrade", `Installed package is v${latest}, but running daemon is v${runningVersion}; scheduling restart`);
37778
+ }
37770
37779
  spawnDetachedDaemonUpgradeHelper({
37771
37780
  packageName: pkgName,
37772
37781
  targetVersion: latest,
@@ -55416,21 +55425,65 @@ function isAdhdevProcess(pid) {
55416
55425
  return true;
55417
55426
  }
55418
55427
  }
55419
- function getDaemonPid(ref = {}) {
55420
- const pidFile = getDaemonPidFile(ref);
55428
+ function getDaemonHealthPid(ref = {}) {
55429
+ const port = resolveDaemonPort(ref);
55421
55430
  try {
55422
- if (!fs18.existsSync(pidFile)) return null;
55423
- const pid = parseInt(fs18.readFileSync(pidFile, "utf-8").trim(), 10);
55431
+ const { execFileSync: execFileSync4 } = require("child_process");
55432
+ const probe = `
55433
+ const http = require('http');
55434
+ const req = http.get('http://127.0.0.1:${port}/health', { timeout: 1500 }, (res) => {
55435
+ let body = '';
55436
+ res.setEncoding('utf8');
55437
+ res.on('data', (chunk) => { body += chunk; });
55438
+ res.on('end', () => {
55439
+ if (res.statusCode !== 200) return;
55440
+ try {
55441
+ const json = JSON.parse(body || '{}');
55442
+ if (Number.isFinite(json.pid)) process.stdout.write(String(json.pid));
55443
+ } catch {}
55444
+ });
55445
+ });
55446
+ req.on('error', () => {});
55447
+ req.on('timeout', () => { req.destroy(); });
55448
+ `;
55449
+ const result = execFileSync4(process.execPath, ["-e", probe], {
55450
+ encoding: "utf-8",
55451
+ timeout: 3e3,
55452
+ stdio: ["ignore", "pipe", "ignore"]
55453
+ }).trim();
55454
+ const pid = parseInt(result, 10);
55424
55455
  return Number.isFinite(pid) ? pid : null;
55425
55456
  } catch {
55426
55457
  return null;
55427
55458
  }
55428
55459
  }
55460
+ function getDaemonPid(ref = {}) {
55461
+ const pidFile = getDaemonPidFile(ref);
55462
+ try {
55463
+ if (fs18.existsSync(pidFile)) {
55464
+ const pid = parseInt(fs18.readFileSync(pidFile, "utf-8").trim(), 10);
55465
+ if (Number.isFinite(pid)) return pid;
55466
+ }
55467
+ } catch {
55468
+ }
55469
+ return getDaemonHealthPid(ref);
55470
+ }
55429
55471
  function stopDaemon(ref = {}) {
55430
55472
  const pidFile = getDaemonPidFile(ref);
55473
+ let pid = null;
55474
+ try {
55475
+ if (fs18.existsSync(pidFile)) {
55476
+ const pidFromFile = parseInt(fs18.readFileSync(pidFile, "utf-8").trim(), 10);
55477
+ if (Number.isFinite(pidFromFile)) pid = pidFromFile;
55478
+ }
55479
+ } catch {
55480
+ removeDaemonPid(ref);
55481
+ }
55482
+ if (pid === null) {
55483
+ pid = getDaemonHealthPid(ref);
55484
+ }
55485
+ if (pid === null) return false;
55431
55486
  try {
55432
- if (!fs18.existsSync(pidFile)) return false;
55433
- const pid = parseInt(fs18.readFileSync(pidFile, "utf-8").trim());
55434
55487
  process.kill(pid, "SIGTERM");
55435
55488
  removeDaemonPid(ref);
55436
55489
  return true;
@@ -55460,7 +55513,7 @@ var init_adhdev_daemon = __esm({
55460
55513
  init_version();
55461
55514
  init_src();
55462
55515
  init_runtime_defaults();
55463
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.13" });
55516
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.15" });
55464
55517
  AdhdevDaemon = class _AdhdevDaemon {
55465
55518
  localHttpServer = null;
55466
55519
  localWss = null;