@adhdev/daemon-standalone 0.9.37 → 0.9.39

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
@@ -30718,6 +30718,14 @@ var require_dist2 = __commonJS({
30718
30718
  }
30719
30719
  this.resolveStartupState("settled");
30720
30720
  if (this.startupParseGate) return;
30721
+ if (!this.isWaitingForResponse && !this.currentTurnScope && !this.activeModal && !this.parseErrorMessage) {
30722
+ const tail = this.settledBuffer || this.recentOutputBuffer;
30723
+ const modal2 = this.runParseApproval(tail);
30724
+ const lightweightStatus = this.cliScripts?.detectStatus ? this.runDetectStatus(tail) : null;
30725
+ if (!modal2 && lightweightStatus === "idle" && this.currentStatus === "idle") {
30726
+ return;
30727
+ }
30728
+ }
30721
30729
  const session = this.runParseSession();
30722
30730
  if (!session) return;
30723
30731
  const { status, messages, modal, parsedStatus } = session;
@@ -41051,17 +41059,24 @@ ${effect.notification.body || ""}`.trim();
41051
41059
  normalizePersistableCliHistoryContent(message.content)
41052
41060
  ].join("|");
41053
41061
  }
41062
+ function hasSamePersistableCliHistoryIdentity(a, b2) {
41063
+ return String(a?.role || "") === String(b2?.role || "") && String(a?.kind || "") === String(b2?.kind || "") && String(a?.senderName || "") === String(b2?.senderName || "") && String(a?.content || "") === String(b2?.content || "");
41064
+ }
41054
41065
  function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages) {
41055
41066
  if (!Array.isArray(currentMessages) || currentMessages.length === 0) return [];
41056
41067
  if (!Array.isArray(previousMessages) || previousMessages.length === 0) return currentMessages;
41057
- const previousSignatures = previousMessages.map(buildPersistableCliHistorySignature);
41058
- const currentSignatures = currentMessages.map(buildPersistableCliHistorySignature);
41068
+ const comparableLength = Math.min(previousMessages.length, currentMessages.length);
41059
41069
  let sharedPrefixLength = 0;
41060
- while (sharedPrefixLength < previousSignatures.length && sharedPrefixLength < currentSignatures.length && previousSignatures[sharedPrefixLength] === currentSignatures[sharedPrefixLength]) {
41070
+ while (sharedPrefixLength < comparableLength && hasSamePersistableCliHistoryIdentity(previousMessages[sharedPrefixLength], currentMessages[sharedPrefixLength])) {
41061
41071
  sharedPrefixLength += 1;
41062
41072
  }
41063
- if (sharedPrefixLength === currentSignatures.length) return [];
41064
- if (sharedPrefixLength === previousSignatures.length) return currentMessages.slice(sharedPrefixLength);
41073
+ if (sharedPrefixLength === currentMessages.length) return [];
41074
+ if (sharedPrefixLength === previousMessages.length) return currentMessages.slice(sharedPrefixLength);
41075
+ while (sharedPrefixLength < comparableLength && buildPersistableCliHistorySignature(previousMessages[sharedPrefixLength]) === buildPersistableCliHistorySignature(currentMessages[sharedPrefixLength])) {
41076
+ sharedPrefixLength += 1;
41077
+ }
41078
+ if (sharedPrefixLength === currentMessages.length) return [];
41079
+ if (sharedPrefixLength === previousMessages.length) return currentMessages.slice(sharedPrefixLength);
41065
41080
  return currentMessages;
41066
41081
  }
41067
41082
  var CachedDatabaseSync = null;
@@ -41307,13 +41322,15 @@ ${effect.notification.body || ""}`.trim();
41307
41322
  }));
41308
41323
  if (!canonicalBackedHistory && !shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
41309
41324
  const incrementalMessages = buildIncrementalHistoryAppendMessages(this.lastPersistedHistoryMessages, normalizedMessagesToSave);
41310
- this.historyWriter.appendNewMessages(
41311
- this.type,
41312
- incrementalMessages,
41313
- parsedStatus?.title || dirName,
41314
- this.instanceId,
41315
- this.providerSessionId
41316
- );
41325
+ if (incrementalMessages.length > 0) {
41326
+ this.historyWriter.appendNewMessages(
41327
+ this.type,
41328
+ incrementalMessages,
41329
+ parsedStatus?.title || dirName,
41330
+ this.instanceId,
41331
+ this.providerSessionId
41332
+ );
41333
+ }
41317
41334
  }
41318
41335
  if (!canonicalBackedHistory) {
41319
41336
  this.lastPersistedHistoryMessages = normalizedMessagesToSave;
@@ -41448,8 +41465,8 @@ ${effect.notification.body || ""}`.trim();
41448
41465
  }
41449
41466
  detectStatusTransition() {
41450
41467
  const now = Date.now();
41451
- const adapterStatus = this.adapter.getStatus();
41452
- const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
41468
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
41469
+ const parsedStatus = null;
41453
41470
  const rawStatus = adapterStatus.status;
41454
41471
  const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
41455
41472
  if (autoApproveActive && !this.autoApproveBusy) {
@@ -41542,7 +41559,7 @@ ${effect.notification.body || ""}`.trim();
41542
41559
  this.completedDebouncePending = { chatTitle, duration: duration3, timestamp: now };
41543
41560
  this.completedDebounceTimer = setTimeout(() => {
41544
41561
  if (this.completedDebouncePending) {
41545
- const latestStatus = this.adapter.getStatus();
41562
+ const latestStatus = this.adapter.getStatus({ allowParse: false });
41546
41563
  const latestAutoApproveActive = latestStatus.status === "waiting_approval" && this.shouldAutoApprove();
41547
41564
  const latestVisibleStatus = latestAutoApproveActive ? "generating" : latestStatus.status;
41548
41565
  if (latestVisibleStatus !== "idle") {