@adhdev/daemon-core 0.9.82-rc.254 → 0.9.82-rc.256

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.254",
3
+ "version": "0.9.82-rc.256",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4309,6 +4309,27 @@ export class DaemonCommandRouter {
4309
4309
  }
4310
4310
 
4311
4311
  case 'launch_cli': {
4312
+ // Worker launch envelope hardening: a mesh worker session must carry
4313
+ // meshCoordinatorDaemonId so completion events route back to the
4314
+ // coordinator (the cloud relay and the daemon-core forwarder both key on
4315
+ // it). mesh_launch_session resolves coordinatorNode.daemonId || ctx.localDaemonId
4316
+ // upstream, but for a freshly-cloned local worktree both can be empty. When the
4317
+ // launch is a coordinator-driven worker on this machine and the id is missing,
4318
+ // stamp this daemon's own id — worker and coordinator are co-located here.
4319
+ {
4320
+ const launchSettings = (args?.settings && typeof args.settings === 'object')
4321
+ ? args.settings as Record<string, unknown>
4322
+ : undefined;
4323
+ const isMeshWorkerLaunch = !!launchSettings
4324
+ && (readStringValue(launchSettings.meshNodeFor) || launchSettings.launchedByCoordinator === true);
4325
+ const hasCoordinatorDaemonId = !!launchSettings && !!readStringValue(launchSettings.meshCoordinatorDaemonId);
4326
+ if (launchSettings && isMeshWorkerLaunch && !hasCoordinatorDaemonId) {
4327
+ try {
4328
+ const localDaemonId = readStringValue(loadConfig().machineId);
4329
+ if (localDaemonId) launchSettings.meshCoordinatorDaemonId = localDaemonId;
4330
+ } catch { /* best-effort — launch proceeds without the stamp */ }
4331
+ }
4332
+ }
4312
4333
  const launchResult = await this.deps.cliManager.handleCliCommand(cmd, args);
4313
4334
  // Bug C fix (part 1): when launching a mesh node worker session, surface
4314
4335
  // bootstrapPending:true if the node's worktree bootstrap is still running.
@@ -1088,8 +1088,31 @@ export class CliProviderInstance implements ProviderInstance {
1088
1088
  }
1089
1089
 
1090
1090
  private completionFinalSummary(parsedMessages: unknown): string | undefined {
1091
- const evidence = this.completionFinalAssistantEvidence(parsedMessages);
1092
- return extractFinalSummaryFromMessages(evidence.messages as any);
1091
+ // For native-source providers (claude-cli: chatMessagesOwnedExternally), the PTY
1092
+ // screen parse is NOT the source of truth for the final summary — the terminal
1093
+ // wraps/scrolls/clips text, so a screen-parsed assistant message is often a partial
1094
+ // prefix (e.g. 76 chars of a 112-char turn). The append-only native transcript holds
1095
+ // the complete turn. Prefer it whenever it yields a longer/complete summary; fall back
1096
+ // to the parsed screen only when the transcript is unavailable. This is the real cause
1097
+ // of the truncated finalSummary — independent of cloud vs standalone (it surfaces on
1098
+ // any short, fast-completing task where screen parse wins the race).
1099
+ const adapterOwnsMessagesElsewhere = (this.adapter as any)?.chatMessagesOwnedExternally === true;
1100
+ const parsedSummary = extractFinalSummaryFromMessages(
1101
+ (this.completionHasFinalAssistantMessage(parsedMessages)
1102
+ ? (Array.isArray(parsedMessages) ? parsedMessages : [])
1103
+ : []) as any,
1104
+ );
1105
+ if (adapterOwnsMessagesElsewhere) {
1106
+ const externalMessages = this.readExternalCompletionMessages();
1107
+ const externalSummary = externalMessages
1108
+ ? extractFinalSummaryFromMessages(externalMessages as any)
1109
+ : '';
1110
+ // The transcript is authoritative for native-source providers. Use it unless it is
1111
+ // empty (not yet written) — only then fall back to whatever the screen parsed.
1112
+ if (externalSummary) return externalSummary;
1113
+ return parsedSummary || undefined;
1114
+ }
1115
+ return parsedSummary || undefined;
1093
1116
  }
1094
1117
 
1095
1118
  private buildCompletedFinalizationDiagnostic(args: {