@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.js CHANGED
@@ -428,10 +428,10 @@ function readInjected(value) {
428
428
  }
429
429
  function getDaemonBuildInfo() {
430
430
  if (cached) return cached;
431
- const commit = readInjected(true ? "86f8d403efe203d7ff1d9b6997ede5f30620a485" : void 0) ?? "unknown";
432
- const commitShort = readInjected(true ? "86f8d403" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
433
- const version = readInjected(true ? "0.9.82-rc.567" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
434
- const builtAt = readInjected(true ? "2026-07-18T09:04:16.210Z" : void 0);
431
+ const commit = readInjected(true ? "39e0687342226d334e36c982bd8988802f43dd3e" : void 0) ?? "unknown";
432
+ const commitShort = readInjected(true ? "39e06873" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
433
+ const version = readInjected(true ? "0.9.82-rc.568" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
434
+ const builtAt = readInjected(true ? "2026-07-18T14:18:06.483Z" : void 0);
435
435
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
436
436
  return cached;
437
437
  }
@@ -48791,18 +48791,30 @@ var CliProviderInstance = class _CliProviderInstance {
48791
48791
  * the dashboard tail-repair cache — a display value, not a completion decision.
48792
48792
  */
48793
48793
  lastVisibleAssistantSummary(messages) {
48794
- if (!Array.isArray(messages)) return "";
48794
+ return this.lastVisibleAssistantSummaryDetail(messages).content;
48795
+ }
48796
+ // Like lastVisibleAssistantSummary but also returns the source bubble's own
48797
+ // timestamp (ms), so a cached summary can later be turn-scoped: the display
48798
+ // cache is populated from an UNSCOPED tail read (it must show the answer as
48799
+ // soon as native-history has it), so it can hold a bubble that predates the
48800
+ // current turn. Recording the bubble's timestamp lets the weak-completion
48801
+ // fallback reject a turn-stale cached summary instead of re-leaking the exact
48802
+ // stale bubble the turn-boundary gate already rejected (FALSE-IDLE Defect 1c).
48803
+ lastVisibleAssistantSummaryDetail(messages) {
48804
+ if (!Array.isArray(messages)) return { content: "" };
48795
48805
  for (let i = messages.length - 1; i >= 0; i -= 1) {
48796
48806
  const m = messages[i];
48797
48807
  const role = typeof m?.role === "string" ? m.role : "";
48798
48808
  const kind = typeof m?.kind === "string" ? m.kind : "";
48799
48809
  if (role === "system") continue;
48800
48810
  if (kind === "tool" || kind === "activity") continue;
48801
- if (role === "user" || role === "human") return "";
48802
- if (role === "assistant") return flattenContent(m.content).trim();
48803
- return "";
48811
+ if (role === "user" || role === "human") return { content: "" };
48812
+ if (role === "assistant") {
48813
+ return { content: flattenContent(m.content).trim(), timestampMs: readChatMessageTimestampMs(m) };
48814
+ }
48815
+ return { content: "" };
48804
48816
  }
48805
- return "";
48817
+ return { content: "" };
48806
48818
  }
48807
48819
  /**
48808
48820
  * NOTIF Defect-B: the final assistant summary this instance ALREADY parsed and
@@ -48823,6 +48835,28 @@ var CliProviderInstance = class _CliProviderInstance {
48823
48835
  const content = typeof cached3?.content === "string" ? cached3.content.trim() : "";
48824
48836
  return content;
48825
48837
  }
48838
+ // FALSE-IDLE Defect 1c: turn-scoped view of the cached completion summary.
48839
+ // The cache is populated from an UNSCOPED tail read (lastVisibleAssistant‑
48840
+ // SummaryDetail) so the dashboard can show the answer the instant native-history
48841
+ // has it — which means it can hold a bubble that PREDATES the producing turn.
48842
+ // The weak-completion (missing_final_assistant) emit path falls back to the cache
48843
+ // for finalSummary; without turn-scoping it would re-surface the exact stale
48844
+ // mid-turn bubble the turn-boundary gate already rejected as evidence, freezing
48845
+ // that stale text as the completion's finalSummary. Consult the cache only when
48846
+ // its source bubble is proven in-turn (timestamp at/after turnStartedAt). When no
48847
+ // boundary is known (turnStartedAt falsy) or the cache carries no source timestamp
48848
+ // (legacy writes), behaviour is identical to the unscoped read.
48849
+ cachedInTurnCompletionSummaryContent(turnStartedAt) {
48850
+ const cached3 = this.lastCompletionSummary;
48851
+ const content = typeof cached3?.content === "string" ? cached3.content.trim() : "";
48852
+ if (!content) return "";
48853
+ const hasBoundary = typeof turnStartedAt === "number" && Number.isFinite(turnStartedAt) && turnStartedAt > 0;
48854
+ const ts2 = cached3?.sourceTimestampMs;
48855
+ if (hasBoundary && typeof ts2 === "number" && Number.isFinite(ts2) && ts2 < turnStartedAt) {
48856
+ return "";
48857
+ }
48858
+ return content;
48859
+ }
48826
48860
  completionFinalAssistantEvidence(parsedMessages, turnStartedAt) {
48827
48861
  const turnClosed = !this.hasAdapterPendingResponse();
48828
48862
  if (this.completionHasFinalAssistantMessage(parsedMessages, turnStartedAt)) {
@@ -48836,9 +48870,9 @@ var CliProviderInstance = class _CliProviderInstance {
48836
48870
  if (externalMessages) {
48837
48871
  const injectedTaskGenerating = this.injectedTaskHasStartedGenerating();
48838
48872
  const present = injectedTaskGenerating && turnClosed && this.completionHasFinalAssistantMessage(externalMessages, turnStartedAt);
48839
- const lastVisibleAssistant = this.lastVisibleAssistantSummary(externalMessages);
48840
- if (lastVisibleAssistant) {
48841
- this.lastCompletionSummary = { content: lastVisibleAssistant, receivedAt: Date.now() };
48873
+ const lastVisibleAssistant = this.lastVisibleAssistantSummaryDetail(externalMessages);
48874
+ if (lastVisibleAssistant.content) {
48875
+ this.lastCompletionSummary = { content: lastVisibleAssistant.content, receivedAt: Date.now(), sourceTimestampMs: lastVisibleAssistant.timestampMs };
48842
48876
  }
48843
48877
  return {
48844
48878
  present,
@@ -48862,7 +48896,7 @@ var CliProviderInstance = class _CliProviderInstance {
48862
48896
  const externalMessages = this.readExternalCompletionMessages();
48863
48897
  const externalSummary = externalMessages ? extractFinalSummaryFromMessagesAfter(externalMessages, turnStartedAt) : "";
48864
48898
  if (externalSummary) {
48865
- this.lastCompletionSummary = { content: externalSummary, receivedAt: Date.now() };
48899
+ this.lastCompletionSummary = { content: externalSummary, receivedAt: Date.now(), sourceTimestampMs: typeof turnStartedAt === "number" ? turnStartedAt : void 0 };
48866
48900
  return externalSummary;
48867
48901
  }
48868
48902
  return parsedSummary || void 0;
@@ -48877,7 +48911,7 @@ var CliProviderInstance = class _CliProviderInstance {
48877
48911
  } catch (error) {
48878
48912
  parseError = error?.message || String(error);
48879
48913
  }
48880
- const evidence = this.completionFinalAssistantEvidence(parsed?.messages);
48914
+ const evidence = this.completionFinalAssistantEvidence(parsed?.messages, args.pending.turnStartedAt);
48881
48915
  if (evidence.source === "external-native") {
48882
48916
  this.recordPendingTranscriptProbe(args.pending);
48883
48917
  }
@@ -48886,7 +48920,7 @@ var CliProviderInstance = class _CliProviderInstance {
48886
48920
  const lastVisibleRole = typeof lastVisible?.role === "string" ? lastVisible.role.trim().toLowerCase() : null;
48887
48921
  const lastVisibleKind = typeof lastVisible?.kind === "string" ? lastVisible.kind : null;
48888
48922
  const lastVisibleContentLength = lastVisible ? flattenContent(lastVisible.content).trim().length : 0;
48889
- const cachedSummary = evidence.present ? "" : this.cachedCompletionSummaryContent();
48923
+ const cachedSummary = evidence.present ? "" : this.cachedInTurnCompletionSummaryContent(args.pending.turnStartedAt);
48890
48924
  const creditedFromCache = !evidence.present && cachedSummary.length > 0;
48891
48925
  const finalAssistantPresent = evidence.present || creditedFromCache;
48892
48926
  const finalAssistantEvidenceSource = evidence.present ? evidence.source : creditedFromCache ? "cached-summary" : evidence.source;
@@ -49550,7 +49584,7 @@ var CliProviderInstance = class _CliProviderInstance {
49550
49584
  // real answer (lastCompletionSummary). Fall back to the cache so the notification
49551
49585
  // carries the summary that mesh_read_chat.summary already shows — consistent with
49552
49586
  // completionDiagnostic.finalAssistantPresent being credited from the same cache.
49553
- finalSummary: this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages, pending.turnStartedAt) || this.cachedCompletionSummaryContent() || (blockReason.startsWith("parsed_status:") ? "" : void 0),
49587
+ finalSummary: this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages, pending.turnStartedAt) || this.cachedInTurnCompletionSummaryContent(pending.turnStartedAt) || (blockReason.startsWith("parsed_status:") ? "" : void 0),
49554
49588
  completionDiagnostic
49555
49589
  });
49556
49590
  this.completedDebouncePending = null;