@adhdev/daemon-core 0.9.82-rc.408 → 0.9.82-rc.409

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
@@ -394,10 +394,10 @@ function readInjected(value) {
394
394
  }
395
395
  function getDaemonBuildInfo() {
396
396
  if (cached) return cached;
397
- const commit = readInjected(true ? "b6de7b335f9b6b6bfb202135c2ae017429182efa" : void 0) ?? "unknown";
398
- const commitShort = readInjected(true ? "b6de7b33" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
399
- const version = readInjected(true ? "0.9.82-rc.408" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
400
- const builtAt = readInjected(true ? "2026-06-28T07:53:15.742Z" : void 0);
397
+ const commit = readInjected(true ? "69cd9c459ec9efafe19a05f66899bb791d6e0561" : void 0) ?? "unknown";
398
+ const commitShort = readInjected(true ? "69cd9c45" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
399
+ const version = readInjected(true ? "0.9.82-rc.409" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
400
+ const builtAt = readInjected(true ? "2026-06-28T09:03:15.861Z" : void 0);
401
401
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
402
402
  return cached;
403
403
  }
@@ -13825,21 +13825,42 @@ function extractFinalSummaryFromMessages(messages, maxChars = DEFAULT_FINAL_SUMM
13825
13825
  }
13826
13826
  return "";
13827
13827
  }
13828
- function readChatMessageTimestampIso(message) {
13828
+ function readChatMessageTimestampMs(message) {
13829
13829
  if (!message) return void 0;
13830
13830
  const record = message;
13831
- for (const value of [record.timestamp, record.createdAt, record.created_at, record.updatedAt, record.time]) {
13831
+ for (const value of [record.timestamp, record.createdAt, record.created_at, record.updatedAt, record.time, record.receivedAt]) {
13832
13832
  if (typeof value === "number" && Number.isFinite(value)) {
13833
- const ms = value > 1e10 ? value : value * 1e3;
13834
- return new Date(ms).toISOString();
13833
+ return value > 1e10 ? value : value * 1e3;
13835
13834
  }
13836
13835
  if (typeof value === "string" && value.trim()) {
13837
13836
  const ms = new Date(value.trim()).getTime();
13838
- if (Number.isFinite(ms)) return new Date(ms).toISOString();
13837
+ if (Number.isFinite(ms)) return ms;
13839
13838
  }
13840
13839
  }
13841
13840
  return void 0;
13842
13841
  }
13842
+ function readChatMessageTimestampIso(message) {
13843
+ const ms = readChatMessageTimestampMs(message);
13844
+ return typeof ms === "number" ? new Date(ms).toISOString() : void 0;
13845
+ }
13846
+ function extractFinalSummaryFromMessagesAfter(messages, minTimestampMs, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
13847
+ if (!Array.isArray(messages) || messages.length === 0) return "";
13848
+ const hasBoundary = typeof minTimestampMs === "number" && Number.isFinite(minTimestampMs);
13849
+ for (let i = messages.length - 1; i >= 0; i--) {
13850
+ const msg = messages[i];
13851
+ if (!msg) continue;
13852
+ if (hasBoundary) {
13853
+ const ts2 = readChatMessageTimestampMs(msg);
13854
+ if (typeof ts2 === "number" && ts2 < minTimestampMs) continue;
13855
+ }
13856
+ const classification = classifyChatMessageVisibility(msg);
13857
+ if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
13858
+ const text = flattenContent(msg.content).trim();
13859
+ if (text) return text.slice(0, maxChars);
13860
+ }
13861
+ }
13862
+ return "";
13863
+ }
13843
13864
  function extractFinalAssistantSummaryEvidence(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
13844
13865
  if (!Array.isArray(messages) || messages.length === 0) return { finalSummary: "" };
13845
13866
  for (let i = messages.length - 1; i >= 0; i--) {
@@ -32414,6 +32435,10 @@ async function handleResolveAction(h, args) {
32414
32435
  const effectiveStatus = status?.status === "waiting_approval" || targetState?.activeChat?.status === "waiting_approval" || parsedStatus?.status === "waiting_approval" ? "waiting_approval" : status?.status;
32415
32436
  LOG.info("Command", `[resolveAction] CLI PTY gate target=${String(args?.targetSessionId || "")} rawStatus=${String(status?.status || "")} effectiveStatus=${String(effectiveStatus || "")} statusModal=${statusModal ? "yes" : "no"} surfacedModal=${surfacedModal ? "yes" : "no"} parsedModal=${parsedModal ? "yes" : "no"} instance=${targetInstance ? "yes" : "no"}`);
32416
32437
  if (!effectiveModal) {
32438
+ if (typeof adapter.isApprovalRecentlyResolved === "function" && adapter.isApprovalRecentlyResolved()) {
32439
+ LOG.info("Command", `[resolveAction] CLI PTY \u2192 already_resolved (modal gone, resolved within cooldown)`);
32440
+ return { success: true, alreadyResolved: true, status: "already_resolved" };
32441
+ }
32417
32442
  return { success: false, error: "Not in approval state" };
32418
32443
  }
32419
32444
  const buttons = Array.isArray(effectiveModal.buttons) ? effectiveModal.buttons : [];
@@ -40435,14 +40460,14 @@ var CliProviderInstance = class _CliProviderInstance {
40435
40460
  source: "unavailable"
40436
40461
  };
40437
40462
  }
40438
- completionFinalSummary(parsedMessages) {
40463
+ completionFinalSummary(parsedMessages, turnStartedAt) {
40439
40464
  const adapterOwnsMessagesElsewhere = this.adapter?.chatMessagesOwnedExternally === true;
40440
40465
  const parsedSummary = extractFinalSummaryFromMessages(
40441
40466
  this.completionHasFinalAssistantMessage(parsedMessages) ? Array.isArray(parsedMessages) ? parsedMessages : [] : []
40442
40467
  );
40443
40468
  if (adapterOwnsMessagesElsewhere) {
40444
40469
  const externalMessages = this.readExternalCompletionMessages();
40445
- const externalSummary = externalMessages ? extractFinalSummaryFromMessages(externalMessages) : "";
40470
+ const externalSummary = externalMessages ? extractFinalSummaryFromMessagesAfter(externalMessages, turnStartedAt) : "";
40446
40471
  if (externalSummary) return externalSummary;
40447
40472
  return parsedSummary || void 0;
40448
40473
  }
@@ -40729,7 +40754,7 @@ var CliProviderInstance = class _CliProviderInstance {
40729
40754
  // delegated session's inbox preview blank — or, for a LOCAL worktree session,
40730
40755
  // stuck on the dispatched user task. If the parser DID surface assistant text,
40731
40756
  // prefer it; only fall back to '' when no assistant summary can be derived.
40732
- finalSummary: blockReason.startsWith("parsed_status:") ? this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages) ?? "" : this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages),
40757
+ finalSummary: blockReason.startsWith("parsed_status:") ? this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages, pending.turnStartedAt) ?? "" : this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages, pending.turnStartedAt),
40733
40758
  completionDiagnostic
40734
40759
  });
40735
40760
  this.completedDebouncePending = null;
@@ -40749,7 +40774,7 @@ var CliProviderInstance = class _CliProviderInstance {
40749
40774
  timestamp: pending.timestamp,
40750
40775
  // ARCH-REFACTOR R1: attribute to the turn captured at idle-transition.
40751
40776
  ...pending.taskId ? { taskId: pending.taskId } : {},
40752
- finalSummary: this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages)
40777
+ finalSummary: this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages, pending.turnStartedAt)
40753
40778
  });
40754
40779
  this.completedDebouncePending = null;
40755
40780
  this.completedDebounceTimer = null;
@@ -40865,7 +40890,7 @@ var CliProviderInstance = class _CliProviderInstance {
40865
40890
  */
40866
40891
  recheckAutoApproveSettled() {
40867
40892
  try {
40868
- const adapterStatus = this.adapter.getStatus({ allowParse: false });
40893
+ const adapterStatus = this.adapter.getStatus({ allowParse: true });
40869
40894
  this.maybeAutoApproveStatus(adapterStatus, Date.now());
40870
40895
  } catch {
40871
40896
  }
@@ -41096,7 +41121,16 @@ var CliProviderInstance = class _CliProviderInstance {
41096
41121
  // ARCH-REFACTOR R1: snapshot the completing turn's taskId NOW (sync),
41097
41122
  // before any follow-up task's flush can start a new turn and move
41098
41123
  // engine.currentTurnTaskId.
41099
- ...this.completingTurnTaskId() ? { taskId: this.completingTurnTaskId() } : {}
41124
+ ...this.completingTurnTaskId() ? { taskId: this.completingTurnTaskId() } : {},
41125
+ // NOTIF Defect-B: snapshot the producing turn's START instant NOW, for the
41126
+ // same reason as taskId — a follow-up turn moves engine.currentTurnStartedAt.
41127
+ // Prefer the engine's per-turn start (set at onTurnStarted, earliest reliable
41128
+ // anchor) and fall back to generatingStartedAt (when generating was observed).
41129
+ ...(() => {
41130
+ const engineTurnStart = typeof this.adapter?.currentTurnStartedAt === "number" && Number.isFinite(this.adapter.currentTurnStartedAt) ? this.adapter.currentTurnStartedAt : 0;
41131
+ const turnStartedAt = engineTurnStart || this.generatingStartedAt || 0;
41132
+ return turnStartedAt ? { turnStartedAt } : {};
41133
+ })()
41100
41134
  };
41101
41135
  const ownsExternalHistory = !!this.adapter?.chatMessagesOwnedExternally;
41102
41136
  const meshWorkerSession = this.isMeshWorkerSession();