@adhdev/daemon-core 0.9.74 → 0.9.76-rc.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.
Files changed (27) hide show
  1. package/dist/cli-adapters/provider-cli-adapter.d.ts +1 -0
  2. package/dist/config/config.d.ts +3 -0
  3. package/dist/index.js +57 -19
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +57 -19
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/repo-mesh-types.d.ts +1 -0
  8. package/package.json +2 -2
  9. package/src/cli-adapters/provider-cli-adapter.ts +23 -4
  10. package/src/commands/mesh-coordinator.ts +5 -0
  11. package/src/commands/router.ts +40 -11
  12. package/src/config/config.ts +6 -0
  13. package/src/mesh/coordinator-prompt.ts +7 -5
  14. package/src/repo-mesh-types.ts +1 -0
  15. package/node_modules/@adhdev/session-host-core/dist/defaults.d.mts +0 -6
  16. package/node_modules/@adhdev/session-host-core/dist/defaults.d.ts +0 -6
  17. package/node_modules/@adhdev/session-host-core/dist/defaults.js +0 -49
  18. package/node_modules/@adhdev/session-host-core/dist/defaults.js.map +0 -1
  19. package/node_modules/@adhdev/session-host-core/dist/defaults.mjs +0 -21
  20. package/node_modules/@adhdev/session-host-core/dist/defaults.mjs.map +0 -1
  21. package/node_modules/@adhdev/session-host-core/dist/index.d.mts +0 -444
  22. package/node_modules/@adhdev/session-host-core/dist/index.d.ts +0 -444
  23. package/node_modules/@adhdev/session-host-core/dist/index.js +0 -702
  24. package/node_modules/@adhdev/session-host-core/dist/index.js.map +0 -1
  25. package/node_modules/@adhdev/session-host-core/dist/index.mjs +0 -648
  26. package/node_modules/@adhdev/session-host-core/dist/index.mjs.map +0 -1
  27. package/node_modules/@adhdev/session-host-core/package.json +0 -49
@@ -106,6 +106,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
106
106
  private getBufferState;
107
107
  private recordBoundedAppendDrop;
108
108
  private readTerminalScreenText;
109
+ private getParseScreenText;
109
110
  private shouldReadTerminalScreenSnapshot;
110
111
  private resetTerminalScreen;
111
112
  private getFreshParsedStatusCache;
@@ -9,6 +9,7 @@ export type { RecentActivityEntry } from './recent-activity.js';
9
9
  export type { SavedProviderSessionEntry } from './saved-sessions.js';
10
10
  export type { DaemonState } from './state-store.js';
11
11
  export type ProviderSourceMode = 'normal' | 'no-upstream';
12
+ export type ReleaseChannel = 'stable' | 'preview';
12
13
  export declare function resolveProviderSourceMode(providerSourceMode: unknown, legacyDisableUpstream: unknown): ProviderSourceMode;
13
14
  export interface MachineProviderCheckResult {
14
15
  ok: boolean;
@@ -70,6 +71,8 @@ export interface ADHDevConfig {
70
71
  disableUpstream?: boolean;
71
72
  providerSourceMode?: ProviderSourceMode;
72
73
  providerDir?: string;
74
+ /** Preferred daemon update channel. Defaults to stable/latest. */
75
+ updateChannel?: ReleaseChannel;
73
76
  /**
74
77
  * Browser terminal sizing behavior for dashboard CLI panes.
75
78
  * Default `measured` keeps terminal size daemon-authoritative.
package/dist/index.js CHANGED
@@ -129,6 +129,7 @@ function normalizeConfig(raw) {
129
129
  ideSettings: isPlainObject(parsed.ideSettings) ? parsed.ideSettings : {},
130
130
  providerSourceMode: resolveProviderSourceMode(parsed.providerSourceMode, parsed.disableUpstream),
131
131
  providerDir: asOptionalString(parsed.providerDir),
132
+ updateChannel: parsed.updateChannel === "preview" ? "preview" : "stable",
132
133
  terminalSizingMode: parsed.terminalSizingMode === "fit" ? "fit" : "measured"
133
134
  };
134
135
  }
@@ -278,6 +279,7 @@ var init_config = __esm({
278
279
  machineProviders: {},
279
280
  ideSettings: {},
280
281
  providerSourceMode: "normal",
282
+ updateChannel: "stable",
281
283
  terminalSizingMode: "measured"
282
284
  };
283
285
  MACHINE_ID_PREFIX = "mach_";
@@ -491,7 +493,7 @@ function buildNodeConfigSection(mesh) {
491
493
  for (const n of mesh.nodes) {
492
494
  const labels = [];
493
495
  if (n.isLocalWorktree) labels.push("worktree");
494
- if (n.policy.readOnly) labels.push("read-only");
496
+ if (n.policy?.readOnly) labels.push("read-only");
495
497
  const suffix = labels.length ? ` [${labels.join(", ")}]` : "";
496
498
  lines.push(`- **${n.workspace}** (${n.id})${suffix}`);
497
499
  }
@@ -537,18 +539,20 @@ var init_coordinator_prompt = __esm({
537
539
  3. **Delegate** \u2014 For each task:
538
540
  a. Pick the best node (consider: health, dirty state, current workload).
539
541
  b. If no session exists, call \`mesh_launch_session\` to start one.
540
- c. Call \`mesh_send_task\` with a clear, self-contained natural-language instruction.
542
+ c. Call \`mesh_send_task\` with a **complete, self-contained** instruction that includes all context the agent needs (file paths, line numbers, what to change, why). Do not send partial instructions expecting future follow-up.
541
543
  4. **Monitor** \u2014 Periodically call \`mesh_read_chat\` to check progress. Handle approvals via \`mesh_approve\`.
542
544
  5. **Verify** \u2014 When a task reports completion, call \`mesh_git_status\` to verify changes were made.
543
545
  6. **Checkpoint** \u2014 Call \`mesh_checkpoint\` to save the work.
544
546
  7. **Report** \u2014 Summarize what was done, what changed, and any issues.`;
545
547
  RULES_SECTION = `## Rules
546
548
 
547
- - **Be conversational.** Delegate work the way a tech lead would \u2014 clear, specific instructions in natural language.
548
- - **Don't inspect code.** Trust the agent's output. Verify via git diff/status, not by reading source files.
549
+ - **Minimize coordinator context.** The coordinator's job is routing, not implementing. Do not read source files, run commands, or analyze code directly \u2014 delegate all of that to node agents. Your context should stay lean.
550
+ - **Delegate analysis too.** If you need to understand a bug or explore the codebase, send that investigation as a task to a node. Do not do it yourself.
551
+ - **Front-load the task message.** When calling \`mesh_send_task\`, include everything the agent needs: what files to touch, what the problem is, what the fix should look like. The agent won't ask follow-up questions.
552
+ - **Don't inspect code.** Trust the agent's output. Verify via \`mesh_git_status\`, not by reading source files.
549
553
  - **Don't over-parallelize.** Start with 1-2 concurrent tasks. Scale up if they succeed.
550
554
  - **Handle failures gracefully.** If a task fails, read the chat to understand why, then retry or reassign.
551
- - **Keep the user informed.** Report progress after each delegation round.
555
+ - **Keep the user informed.** Report progress after each delegation round \u2014 one or two sentences, not a narration.
552
556
  - **Respect node capabilities.** Don't send build tasks to read-only nodes. Don't push from nodes that aren't allowed to.
553
557
  - **Never fabricate tool results.** Always call the actual tool; never pretend you did.`;
554
558
  }
@@ -1758,6 +1762,17 @@ var init_provider_cli_adapter = __esm({
1758
1762
  this.lastScreenSnapshotReadAt = now;
1759
1763
  return screenText;
1760
1764
  }
1765
+ getParseScreenText(screenText) {
1766
+ const currentSnapshot = normalizeScreenSnapshot(screenText);
1767
+ const lastSnapshot = this.lastScreenSnapshot;
1768
+ if (!lastSnapshot || lastSnapshot === currentSnapshot) return screenText;
1769
+ const staleSnapshotLooksActive = /\besc to (?:interrupt|stop)\b|Enter to interrupt, Ctrl\+C to cancel/i.test(lastSnapshot);
1770
+ const currentScreenLooksIdle = /(?:^|\n|\r)\s*[❯›>]\s*(?:\n|\r|$)/.test(screenText) && !/\besc to (?:interrupt|stop)\b|Enter to interrupt, Ctrl\+C to cancel/i.test(screenText);
1771
+ if (staleSnapshotLooksActive && currentScreenLooksIdle) return screenText;
1772
+ if (currentSnapshot.length >= lastSnapshot.length) return screenText;
1773
+ return `${screenText}
1774
+ ${lastSnapshot}`;
1775
+ }
1761
1776
  shouldReadTerminalScreenSnapshot(now) {
1762
1777
  if (!this.lastScreenText) return true;
1763
1778
  return now - this.lastScreenSnapshotReadAt >= _ProviderCliAdapter.SCREEN_SNAPSHOT_MIN_INTERVAL_MS;
@@ -2748,12 +2763,13 @@ var init_provider_cli_adapter = __esm({
2748
2763
  }
2749
2764
  try {
2750
2765
  const screenText = this.terminalScreen.getText();
2766
+ const parseScreenText = this.getParseScreenText(screenText);
2751
2767
  const tail = this.recentOutputBuffer.slice(-500);
2752
2768
  const input = buildCliParseInput({
2753
2769
  accumulatedBuffer: this.accumulatedBuffer,
2754
2770
  accumulatedRawBuffer: this.accumulatedRawBuffer,
2755
2771
  recentOutputBuffer: this.recentOutputBuffer,
2756
- terminalScreenText: screenText,
2772
+ terminalScreenText: parseScreenText,
2757
2773
  baseMessages: [],
2758
2774
  partialResponse: this.responseBuffer,
2759
2775
  isWaitingForResponse: this.isWaitingForResponse,
@@ -2847,8 +2863,9 @@ var init_provider_cli_adapter = __esm({
2847
2863
  */
2848
2864
  getScriptParsedStatus() {
2849
2865
  const screenText = this.readTerminalScreenText();
2866
+ const parseScreenText = this.getParseScreenText(screenText);
2850
2867
  const cached = this.parsedStatusCache;
2851
- 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) {
2868
+ 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) {
2852
2869
  return cached.result;
2853
2870
  }
2854
2871
  const parsed = this.runParseSession();
@@ -2876,7 +2893,7 @@ var init_provider_cli_adapter = __esm({
2876
2893
  currentTurnScope: this.currentTurnScope,
2877
2894
  recentOutputBuffer: this.recentOutputBuffer,
2878
2895
  accumulatedBuffer: this.accumulatedBuffer,
2879
- screenText,
2896
+ screenText: parseScreenText,
2880
2897
  currentStatus: this.currentStatus,
2881
2898
  activeModal: this.activeModal,
2882
2899
  cliName: this.cliName,
@@ -2893,7 +2910,7 @@ var init_provider_cli_adapter = __esm({
2893
2910
  accumulatedBuffer: this.accumulatedBuffer,
2894
2911
  accumulatedRawBuffer: this.accumulatedRawBuffer,
2895
2912
  recentOutputBuffer: this.recentOutputBuffer,
2896
- terminalScreenText: this.terminalScreen.getText(),
2913
+ terminalScreenText: this.getParseScreenText(this.terminalScreen.getText()),
2897
2914
  baseMessages: [],
2898
2915
  partialResponse: this.responseBuffer,
2899
2916
  isWaitingForResponse: this.isWaitingForResponse,
@@ -20092,6 +20109,8 @@ function resolveAdhdevMcpEntryPath(explicitPath) {
20092
20109
  addCandidate((0, import_node_path.resolve)(dir, "../vendor/mcp-server/index.js"));
20093
20110
  addCandidate((0, import_node_path.resolve)(dir, "../../vendor/mcp-server/index.js"));
20094
20111
  addCandidate((0, import_node_path.resolve)(dir, "../../../vendor/mcp-server/index.js"));
20112
+ addCandidate((0, import_node_path.resolve)(dir, "../../mcp-server/dist/index.js"));
20113
+ addCandidate((0, import_node_path.resolve)(dir, "../../../mcp-server/dist/index.js"));
20095
20114
  };
20096
20115
  addPackagedCandidates(process.argv[1]);
20097
20116
  for (const candidate of candidates) {
@@ -20769,6 +20788,17 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
20769
20788
 
20770
20789
  // src/commands/router.ts
20771
20790
  var fs10 = __toESM(require("fs"));
20791
+ var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
20792
+ function normalizeReleaseChannel(value) {
20793
+ if (typeof value !== "string") return null;
20794
+ const normalized = value.trim().toLowerCase();
20795
+ if (normalized === "stable" || normalized === "latest") return "stable";
20796
+ if (normalized === "preview" || normalized === "next") return "preview";
20797
+ return null;
20798
+ }
20799
+ function resolveUpgradeChannel(args) {
20800
+ return normalizeReleaseChannel(args?.channel) || normalizeReleaseChannel(args?.updatePolicy?.channel) || normalizeReleaseChannel(args?.npmTag) || normalizeReleaseChannel(loadConfig().updateChannel) || "stable";
20801
+ }
20772
20802
  var CHAT_COMMANDS = [
20773
20803
  "send_chat",
20774
20804
  "new_chat",
@@ -21451,8 +21481,10 @@ var DaemonCommandRouter = class {
21451
21481
  const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
21452
21482
  const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
21453
21483
  const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
21454
- const latest = String(execNpmCommandSync(["view", pkgName, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
21455
- LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
21484
+ const channel = resolveUpgradeChannel(args);
21485
+ const npmTag = CHANNEL_NPM_TAG[channel];
21486
+ const latest = String(execNpmCommandSync(["view", `${pkgName}@${npmTag}`, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
21487
+ LOG.info("Upgrade", `Latest ${pkgName}@${npmTag}: v${latest}`);
21456
21488
  let currentInstalled = null;
21457
21489
  try {
21458
21490
  const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
@@ -21466,8 +21498,8 @@ var DaemonCommandRouter = class {
21466
21498
  }
21467
21499
  const runningVersion = typeof this.deps.statusVersion === "string" ? this.deps.statusVersion.trim().replace(/^v/, "") : null;
21468
21500
  if (currentInstalled === latest && runningVersion === latest) {
21469
- LOG.info("Upgrade", `Already on latest version v${latest}; skipping install`);
21470
- return { success: true, upgraded: false, alreadyLatest: true, version: latest };
21501
+ LOG.info("Upgrade", `Already on ${channel} channel version v${latest}; skipping install`);
21502
+ return { success: true, upgraded: false, alreadyLatest: true, version: latest, channel, npmTag };
21471
21503
  }
21472
21504
  if (currentInstalled === latest && runningVersion && runningVersion !== latest) {
21473
21505
  LOG.info("Upgrade", `Installed package is v${latest}, but running daemon is v${runningVersion}; scheduling restart`);
@@ -21480,12 +21512,12 @@ var DaemonCommandRouter = class {
21480
21512
  cwd: process.cwd(),
21481
21513
  sessionHostAppName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev"
21482
21514
  });
21483
- LOG.info("Upgrade", `Scheduled detached upgrade to v${latest}`);
21515
+ LOG.info("Upgrade", `Scheduled detached ${channel} upgrade to v${latest}`);
21484
21516
  setTimeout(() => {
21485
21517
  LOG.info("Upgrade", "Exiting daemon so detached upgrader can continue...");
21486
21518
  process.exit(0);
21487
21519
  }, 3e3);
21488
- return { success: true, upgraded: true, version: latest, restarting: true };
21520
+ return { success: true, upgraded: true, version: latest, restarting: true, channel, npmTag };
21489
21521
  } catch (e) {
21490
21522
  LOG.error("Upgrade", `Failed: ${e.message}`);
21491
21523
  return { success: false, error: e.message };
@@ -21649,14 +21681,20 @@ var DaemonCommandRouter = class {
21649
21681
  } catch {
21650
21682
  }
21651
21683
  }
21684
+ const mcpServerEntry = {
21685
+ command: coordinatorSetup.mcpServer.command,
21686
+ args: coordinatorSetup.mcpServer.args
21687
+ };
21688
+ if (args?.inlineMesh) {
21689
+ mcpServerEntry.env = {
21690
+ ADHDEV_INLINE_MESH: JSON.stringify(mesh)
21691
+ };
21692
+ }
21652
21693
  const mcpConfig = {
21653
21694
  ...existingMcpConfig,
21654
21695
  mcpServers: {
21655
21696
  ...existingMcpConfig.mcpServers || {},
21656
- [coordinatorSetup.serverName]: {
21657
- command: coordinatorSetup.mcpServer.command,
21658
- args: coordinatorSetup.mcpServer.args
21659
- }
21697
+ [coordinatorSetup.serverName]: mcpServerEntry
21660
21698
  }
21661
21699
  };
21662
21700
  writeFileSync12(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf-8");