@adhdev/daemon-core 0.9.82-rc.567 → 0.9.82-rc.568

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
@@ -423,10 +423,10 @@ function readInjected(value) {
423
423
  }
424
424
  function getDaemonBuildInfo() {
425
425
  if (cached) return cached;
426
- const commit = readInjected(true ? "86f8d403efe203d7ff1d9b6997ede5f30620a485" : void 0) ?? "unknown";
427
- const commitShort = readInjected(true ? "86f8d403" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
428
- const version = readInjected(true ? "0.9.82-rc.567" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
429
- const builtAt = readInjected(true ? "2026-07-18T09:04:16.210Z" : void 0);
426
+ const commit = readInjected(true ? "39e0687342226d334e36c982bd8988802f43dd3e" : void 0) ?? "unknown";
427
+ const commitShort = readInjected(true ? "39e06873" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
428
+ const version = readInjected(true ? "0.9.82-rc.568" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
429
+ const builtAt = readInjected(true ? "2026-07-18T14:18:06.483Z" : void 0);
430
430
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
431
431
  return cached;
432
432
  }
@@ -48358,18 +48358,30 @@ var CliProviderInstance = class _CliProviderInstance {
48358
48358
  * the dashboard tail-repair cache — a display value, not a completion decision.
48359
48359
  */
48360
48360
  lastVisibleAssistantSummary(messages) {
48361
- if (!Array.isArray(messages)) return "";
48361
+ return this.lastVisibleAssistantSummaryDetail(messages).content;
48362
+ }
48363
+ // Like lastVisibleAssistantSummary but also returns the source bubble's own
48364
+ // timestamp (ms), so a cached summary can later be turn-scoped: the display
48365
+ // cache is populated from an UNSCOPED tail read (it must show the answer as
48366
+ // soon as native-history has it), so it can hold a bubble that predates the
48367
+ // current turn. Recording the bubble's timestamp lets the weak-completion
48368
+ // fallback reject a turn-stale cached summary instead of re-leaking the exact
48369
+ // stale bubble the turn-boundary gate already rejected (FALSE-IDLE Defect 1c).
48370
+ lastVisibleAssistantSummaryDetail(messages) {
48371
+ if (!Array.isArray(messages)) return { content: "" };
48362
48372
  for (let i = messages.length - 1; i >= 0; i -= 1) {
48363
48373
  const m = messages[i];
48364
48374
  const role = typeof m?.role === "string" ? m.role : "";
48365
48375
  const kind = typeof m?.kind === "string" ? m.kind : "";
48366
48376
  if (role === "system") continue;
48367
48377
  if (kind === "tool" || kind === "activity") continue;
48368
- if (role === "user" || role === "human") return "";
48369
- if (role === "assistant") return flattenContent(m.content).trim();
48370
- return "";
48378
+ if (role === "user" || role === "human") return { content: "" };
48379
+ if (role === "assistant") {
48380
+ return { content: flattenContent(m.content).trim(), timestampMs: readChatMessageTimestampMs(m) };
48381
+ }
48382
+ return { content: "" };
48371
48383
  }
48372
- return "";
48384
+ return { content: "" };
48373
48385
  }
48374
48386
  /**
48375
48387
  * NOTIF Defect-B: the final assistant summary this instance ALREADY parsed and
@@ -48390,6 +48402,28 @@ var CliProviderInstance = class _CliProviderInstance {
48390
48402
  const content = typeof cached3?.content === "string" ? cached3.content.trim() : "";
48391
48403
  return content;
48392
48404
  }
48405
+ // FALSE-IDLE Defect 1c: turn-scoped view of the cached completion summary.
48406
+ // The cache is populated from an UNSCOPED tail read (lastVisibleAssistant‑
48407
+ // SummaryDetail) so the dashboard can show the answer the instant native-history
48408
+ // has it — which means it can hold a bubble that PREDATES the producing turn.
48409
+ // The weak-completion (missing_final_assistant) emit path falls back to the cache
48410
+ // for finalSummary; without turn-scoping it would re-surface the exact stale
48411
+ // mid-turn bubble the turn-boundary gate already rejected as evidence, freezing
48412
+ // that stale text as the completion's finalSummary. Consult the cache only when
48413
+ // its source bubble is proven in-turn (timestamp at/after turnStartedAt). When no
48414
+ // boundary is known (turnStartedAt falsy) or the cache carries no source timestamp
48415
+ // (legacy writes), behaviour is identical to the unscoped read.
48416
+ cachedInTurnCompletionSummaryContent(turnStartedAt) {
48417
+ const cached3 = this.lastCompletionSummary;
48418
+ const content = typeof cached3?.content === "string" ? cached3.content.trim() : "";
48419
+ if (!content) return "";
48420
+ const hasBoundary = typeof turnStartedAt === "number" && Number.isFinite(turnStartedAt) && turnStartedAt > 0;
48421
+ const ts2 = cached3?.sourceTimestampMs;
48422
+ if (hasBoundary && typeof ts2 === "number" && Number.isFinite(ts2) && ts2 < turnStartedAt) {
48423
+ return "";
48424
+ }
48425
+ return content;
48426
+ }
48393
48427
  completionFinalAssistantEvidence(parsedMessages, turnStartedAt) {
48394
48428
  const turnClosed = !this.hasAdapterPendingResponse();
48395
48429
  if (this.completionHasFinalAssistantMessage(parsedMessages, turnStartedAt)) {
@@ -48403,9 +48437,9 @@ var CliProviderInstance = class _CliProviderInstance {
48403
48437
  if (externalMessages) {
48404
48438
  const injectedTaskGenerating = this.injectedTaskHasStartedGenerating();
48405
48439
  const present = injectedTaskGenerating && turnClosed && this.completionHasFinalAssistantMessage(externalMessages, turnStartedAt);
48406
- const lastVisibleAssistant = this.lastVisibleAssistantSummary(externalMessages);
48407
- if (lastVisibleAssistant) {
48408
- this.lastCompletionSummary = { content: lastVisibleAssistant, receivedAt: Date.now() };
48440
+ const lastVisibleAssistant = this.lastVisibleAssistantSummaryDetail(externalMessages);
48441
+ if (lastVisibleAssistant.content) {
48442
+ this.lastCompletionSummary = { content: lastVisibleAssistant.content, receivedAt: Date.now(), sourceTimestampMs: lastVisibleAssistant.timestampMs };
48409
48443
  }
48410
48444
  return {
48411
48445
  present,
@@ -48429,7 +48463,7 @@ var CliProviderInstance = class _CliProviderInstance {
48429
48463
  const externalMessages = this.readExternalCompletionMessages();
48430
48464
  const externalSummary = externalMessages ? extractFinalSummaryFromMessagesAfter(externalMessages, turnStartedAt) : "";
48431
48465
  if (externalSummary) {
48432
- this.lastCompletionSummary = { content: externalSummary, receivedAt: Date.now() };
48466
+ this.lastCompletionSummary = { content: externalSummary, receivedAt: Date.now(), sourceTimestampMs: typeof turnStartedAt === "number" ? turnStartedAt : void 0 };
48433
48467
  return externalSummary;
48434
48468
  }
48435
48469
  return parsedSummary || void 0;
@@ -48444,7 +48478,7 @@ var CliProviderInstance = class _CliProviderInstance {
48444
48478
  } catch (error) {
48445
48479
  parseError = error?.message || String(error);
48446
48480
  }
48447
- const evidence = this.completionFinalAssistantEvidence(parsed?.messages);
48481
+ const evidence = this.completionFinalAssistantEvidence(parsed?.messages, args.pending.turnStartedAt);
48448
48482
  if (evidence.source === "external-native") {
48449
48483
  this.recordPendingTranscriptProbe(args.pending);
48450
48484
  }
@@ -48453,7 +48487,7 @@ var CliProviderInstance = class _CliProviderInstance {
48453
48487
  const lastVisibleRole = typeof lastVisible?.role === "string" ? lastVisible.role.trim().toLowerCase() : null;
48454
48488
  const lastVisibleKind = typeof lastVisible?.kind === "string" ? lastVisible.kind : null;
48455
48489
  const lastVisibleContentLength = lastVisible ? flattenContent(lastVisible.content).trim().length : 0;
48456
- const cachedSummary = evidence.present ? "" : this.cachedCompletionSummaryContent();
48490
+ const cachedSummary = evidence.present ? "" : this.cachedInTurnCompletionSummaryContent(args.pending.turnStartedAt);
48457
48491
  const creditedFromCache = !evidence.present && cachedSummary.length > 0;
48458
48492
  const finalAssistantPresent = evidence.present || creditedFromCache;
48459
48493
  const finalAssistantEvidenceSource = evidence.present ? evidence.source : creditedFromCache ? "cached-summary" : evidence.source;
@@ -49117,7 +49151,7 @@ var CliProviderInstance = class _CliProviderInstance {
49117
49151
  // real answer (lastCompletionSummary). Fall back to the cache so the notification
49118
49152
  // carries the summary that mesh_read_chat.summary already shows — consistent with
49119
49153
  // completionDiagnostic.finalAssistantPresent being credited from the same cache.
49120
- finalSummary: this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages, pending.turnStartedAt) || this.cachedCompletionSummaryContent() || (blockReason.startsWith("parsed_status:") ? "" : void 0),
49154
+ finalSummary: this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages, pending.turnStartedAt) || this.cachedInTurnCompletionSummaryContent(pending.turnStartedAt) || (blockReason.startsWith("parsed_status:") ? "" : void 0),
49121
49155
  completionDiagnostic
49122
49156
  });
49123
49157
  this.completedDebouncePending = null;