@adhdev/daemon-core 0.9.74 → 0.9.75

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.mjs CHANGED
@@ -128,6 +128,7 @@ function normalizeConfig(raw) {
128
128
  ideSettings: isPlainObject(parsed.ideSettings) ? parsed.ideSettings : {},
129
129
  providerSourceMode: resolveProviderSourceMode(parsed.providerSourceMode, parsed.disableUpstream),
130
130
  providerDir: asOptionalString(parsed.providerDir),
131
+ updateChannel: parsed.updateChannel === "preview" ? "preview" : "stable",
131
132
  terminalSizingMode: parsed.terminalSizingMode === "fit" ? "fit" : "measured"
132
133
  };
133
134
  }
@@ -273,6 +274,7 @@ var init_config = __esm({
273
274
  machineProviders: {},
274
275
  ideSettings: {},
275
276
  providerSourceMode: "normal",
277
+ updateChannel: "stable",
276
278
  terminalSizingMode: "measured"
277
279
  };
278
280
  MACHINE_ID_PREFIX = "mach_";
@@ -1754,6 +1756,13 @@ var init_provider_cli_adapter = __esm({
1754
1756
  this.lastScreenSnapshotReadAt = now;
1755
1757
  return screenText;
1756
1758
  }
1759
+ getParseScreenText(screenText) {
1760
+ const currentSnapshot = normalizeScreenSnapshot(screenText);
1761
+ const lastSnapshot = this.lastScreenSnapshot;
1762
+ if (!lastSnapshot || lastSnapshot === currentSnapshot) return screenText;
1763
+ return `${screenText}
1764
+ ${lastSnapshot}`;
1765
+ }
1757
1766
  shouldReadTerminalScreenSnapshot(now) {
1758
1767
  if (!this.lastScreenText) return true;
1759
1768
  return now - this.lastScreenSnapshotReadAt >= _ProviderCliAdapter.SCREEN_SNAPSHOT_MIN_INTERVAL_MS;
@@ -2744,12 +2753,13 @@ var init_provider_cli_adapter = __esm({
2744
2753
  }
2745
2754
  try {
2746
2755
  const screenText = this.terminalScreen.getText();
2756
+ const parseScreenText = this.getParseScreenText(screenText);
2747
2757
  const tail = this.recentOutputBuffer.slice(-500);
2748
2758
  const input = buildCliParseInput({
2749
2759
  accumulatedBuffer: this.accumulatedBuffer,
2750
2760
  accumulatedRawBuffer: this.accumulatedRawBuffer,
2751
2761
  recentOutputBuffer: this.recentOutputBuffer,
2752
- terminalScreenText: screenText,
2762
+ terminalScreenText: parseScreenText,
2753
2763
  baseMessages: [],
2754
2764
  partialResponse: this.responseBuffer,
2755
2765
  isWaitingForResponse: this.isWaitingForResponse,
@@ -2843,8 +2853,9 @@ var init_provider_cli_adapter = __esm({
2843
2853
  */
2844
2854
  getScriptParsedStatus() {
2845
2855
  const screenText = this.readTerminalScreenText();
2856
+ const parseScreenText = this.getParseScreenText(screenText);
2846
2857
  const cached = this.parsedStatusCache;
2847
- if (cached && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.screenText === screenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName) {
2858
+ if (cached && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.screenText === parseScreenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName) {
2848
2859
  return cached.result;
2849
2860
  }
2850
2861
  const parsed = this.runParseSession();
@@ -2872,7 +2883,7 @@ var init_provider_cli_adapter = __esm({
2872
2883
  currentTurnScope: this.currentTurnScope,
2873
2884
  recentOutputBuffer: this.recentOutputBuffer,
2874
2885
  accumulatedBuffer: this.accumulatedBuffer,
2875
- screenText,
2886
+ screenText: parseScreenText,
2876
2887
  currentStatus: this.currentStatus,
2877
2888
  activeModal: this.activeModal,
2878
2889
  cliName: this.cliName,
@@ -2889,7 +2900,7 @@ var init_provider_cli_adapter = __esm({
2889
2900
  accumulatedBuffer: this.accumulatedBuffer,
2890
2901
  accumulatedRawBuffer: this.accumulatedRawBuffer,
2891
2902
  recentOutputBuffer: this.recentOutputBuffer,
2892
- terminalScreenText: this.terminalScreen.getText(),
2903
+ terminalScreenText: this.getParseScreenText(this.terminalScreen.getText()),
2893
2904
  baseMessages: [],
2894
2905
  partialResponse: this.responseBuffer,
2895
2906
  isWaitingForResponse: this.isWaitingForResponse,
@@ -19905,6 +19916,8 @@ function resolveAdhdevMcpEntryPath(explicitPath) {
19905
19916
  addCandidate(resolve13(dir, "../vendor/mcp-server/index.js"));
19906
19917
  addCandidate(resolve13(dir, "../../vendor/mcp-server/index.js"));
19907
19918
  addCandidate(resolve13(dir, "../../../vendor/mcp-server/index.js"));
19919
+ addCandidate(resolve13(dir, "../../mcp-server/dist/index.js"));
19920
+ addCandidate(resolve13(dir, "../../../mcp-server/dist/index.js"));
19908
19921
  };
19909
19922
  addPackagedCandidates(process.argv[1]);
19910
19923
  for (const candidate of candidates) {
@@ -20582,6 +20595,17 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
20582
20595
 
20583
20596
  // src/commands/router.ts
20584
20597
  import * as fs10 from "fs";
20598
+ var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
20599
+ function normalizeReleaseChannel(value) {
20600
+ if (typeof value !== "string") return null;
20601
+ const normalized = value.trim().toLowerCase();
20602
+ if (normalized === "stable" || normalized === "latest") return "stable";
20603
+ if (normalized === "preview" || normalized === "next") return "preview";
20604
+ return null;
20605
+ }
20606
+ function resolveUpgradeChannel(args) {
20607
+ return normalizeReleaseChannel(args?.channel) || normalizeReleaseChannel(args?.updatePolicy?.channel) || normalizeReleaseChannel(args?.npmTag) || normalizeReleaseChannel(loadConfig().updateChannel) || "stable";
20608
+ }
20585
20609
  var CHAT_COMMANDS = [
20586
20610
  "send_chat",
20587
20611
  "new_chat",
@@ -21264,8 +21288,10 @@ var DaemonCommandRouter = class {
21264
21288
  const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
21265
21289
  const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
21266
21290
  const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
21267
- const latest = String(execNpmCommandSync(["view", pkgName, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
21268
- LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
21291
+ const channel = resolveUpgradeChannel(args);
21292
+ const npmTag = CHANNEL_NPM_TAG[channel];
21293
+ const latest = String(execNpmCommandSync(["view", `${pkgName}@${npmTag}`, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
21294
+ LOG.info("Upgrade", `Latest ${pkgName}@${npmTag}: v${latest}`);
21269
21295
  let currentInstalled = null;
21270
21296
  try {
21271
21297
  const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
@@ -21279,8 +21305,8 @@ var DaemonCommandRouter = class {
21279
21305
  }
21280
21306
  const runningVersion = typeof this.deps.statusVersion === "string" ? this.deps.statusVersion.trim().replace(/^v/, "") : null;
21281
21307
  if (currentInstalled === latest && runningVersion === latest) {
21282
- LOG.info("Upgrade", `Already on latest version v${latest}; skipping install`);
21283
- return { success: true, upgraded: false, alreadyLatest: true, version: latest };
21308
+ LOG.info("Upgrade", `Already on ${channel} channel version v${latest}; skipping install`);
21309
+ return { success: true, upgraded: false, alreadyLatest: true, version: latest, channel, npmTag };
21284
21310
  }
21285
21311
  if (currentInstalled === latest && runningVersion && runningVersion !== latest) {
21286
21312
  LOG.info("Upgrade", `Installed package is v${latest}, but running daemon is v${runningVersion}; scheduling restart`);
@@ -21293,12 +21319,12 @@ var DaemonCommandRouter = class {
21293
21319
  cwd: process.cwd(),
21294
21320
  sessionHostAppName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev"
21295
21321
  });
21296
- LOG.info("Upgrade", `Scheduled detached upgrade to v${latest}`);
21322
+ LOG.info("Upgrade", `Scheduled detached ${channel} upgrade to v${latest}`);
21297
21323
  setTimeout(() => {
21298
21324
  LOG.info("Upgrade", "Exiting daemon so detached upgrader can continue...");
21299
21325
  process.exit(0);
21300
21326
  }, 3e3);
21301
- return { success: true, upgraded: true, version: latest, restarting: true };
21327
+ return { success: true, upgraded: true, version: latest, restarting: true, channel, npmTag };
21302
21328
  } catch (e) {
21303
21329
  LOG.error("Upgrade", `Failed: ${e.message}`);
21304
21330
  return { success: false, error: e.message };
@@ -21462,14 +21488,20 @@ var DaemonCommandRouter = class {
21462
21488
  } catch {
21463
21489
  }
21464
21490
  }
21491
+ const mcpServerEntry = {
21492
+ command: coordinatorSetup.mcpServer.command,
21493
+ args: coordinatorSetup.mcpServer.args
21494
+ };
21495
+ if (args?.inlineMesh) {
21496
+ mcpServerEntry.env = {
21497
+ ADHDEV_INLINE_MESH: JSON.stringify(mesh)
21498
+ };
21499
+ }
21465
21500
  const mcpConfig = {
21466
21501
  ...existingMcpConfig,
21467
21502
  mcpServers: {
21468
21503
  ...existingMcpConfig.mcpServers || {},
21469
- [coordinatorSetup.serverName]: {
21470
- command: coordinatorSetup.mcpServer.command,
21471
- args: coordinatorSetup.mcpServer.args
21472
- }
21504
+ [coordinatorSetup.serverName]: mcpServerEntry
21473
21505
  }
21474
21506
  };
21475
21507
  writeFileSync12(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf-8");