@adhdev/daemon-standalone 0.9.38 → 0.9.40

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
@@ -29662,9 +29662,7 @@ var require_dist2 = __commonJS({
29662
29662
  };
29663
29663
  });
29664
29664
  }
29665
- function chooseMoreComparableCliMessage(left, right) {
29666
- const leftComparable = normalizeComparableMessageContent(left.content || "");
29667
- const rightComparable = normalizeComparableMessageContent(right.content || "");
29665
+ function chooseMoreComparableCliMessage(left, right, leftComparable = normalizeComparableMessageContent(left.content || ""), rightComparable = normalizeComparableMessageContent(right.content || "")) {
29668
29666
  if (leftComparable && leftComparable === rightComparable) {
29669
29667
  const leftNewlines = String(left.content || "").split(/\r\n|\n|\r/g).length - 1;
29670
29668
  const rightNewlines = String(right.content || "").split(/\r\n|\n|\r/g).length - 1;
@@ -29679,24 +29677,32 @@ var require_dist2 = __commonJS({
29679
29677
  ...message,
29680
29678
  content: typeof message.content === "string" ? message.content : String(message.content || "")
29681
29679
  };
29680
+ const currentComparable = normalizeComparableMessageContent(current.content || "");
29682
29681
  const previous = deduped[deduped.length - 1];
29683
29682
  if (!previous) {
29684
- deduped.push(current);
29683
+ deduped.push({ message: current, comparable: currentComparable });
29685
29684
  continue;
29686
29685
  }
29687
- const previousComparable = normalizeComparableMessageContent(previous.content || "");
29688
- const currentComparable = normalizeComparableMessageContent(current.content || "");
29689
- const sameRole = previous.role === current.role;
29690
- const sameKind = (previous.kind || "standard") === (current.kind || "standard");
29691
- const sameSender = (previous.senderName || "") === (current.senderName || "");
29692
- const comparableMatch = previousComparable && previousComparable === currentComparable;
29686
+ const sameRole = previous.message.role === current.role;
29687
+ const sameKind = (previous.message.kind || "standard") === (current.kind || "standard");
29688
+ const sameSender = (previous.message.senderName || "") === (current.senderName || "");
29689
+ const comparableMatch = previous.comparable && previous.comparable === currentComparable;
29693
29690
  if (sameRole && sameKind && sameSender && comparableMatch) {
29694
- deduped[deduped.length - 1] = chooseMoreComparableCliMessage(previous, current);
29691
+ const selected = chooseMoreComparableCliMessage(
29692
+ previous.message,
29693
+ current,
29694
+ previous.comparable,
29695
+ currentComparable
29696
+ );
29697
+ deduped[deduped.length - 1] = {
29698
+ message: selected,
29699
+ comparable: selected === current ? currentComparable : previous.comparable
29700
+ };
29695
29701
  continue;
29696
29702
  }
29697
- deduped.push(current);
29703
+ deduped.push({ message: current, comparable: currentComparable });
29698
29704
  }
29699
- return deduped;
29705
+ return deduped.map((entry) => entry.message);
29700
29706
  }
29701
29707
  function normalizeCliParsedMessages(parsedMessages, options) {
29702
29708
  return dedupeConsecutiveComparableCliMessages(hydrateCliParsedMessages(parsedMessages, options).map((message) => ({
@@ -30718,6 +30724,14 @@ var require_dist2 = __commonJS({
30718
30724
  }
30719
30725
  this.resolveStartupState("settled");
30720
30726
  if (this.startupParseGate) return;
30727
+ if (!this.isWaitingForResponse && !this.currentTurnScope && !this.activeModal && !this.parseErrorMessage) {
30728
+ const tail = this.settledBuffer || this.recentOutputBuffer;
30729
+ const modal2 = this.runParseApproval(tail);
30730
+ const lightweightStatus = this.cliScripts?.detectStatus ? this.runDetectStatus(tail) : null;
30731
+ if (!modal2 && lightweightStatus === "idle" && this.currentStatus === "idle") {
30732
+ return;
30733
+ }
30734
+ }
30721
30735
  const session = this.runParseSession();
30722
30736
  if (!session) return;
30723
30737
  const { status, messages, modal, parsedStatus } = session;
@@ -38398,68 +38412,66 @@ ${effect.notification.body || ""}`.trim();
38398
38412
  const messages = Array.isArray(payload.messages) ? payload.messages : [];
38399
38413
  return normalizeChatMessages(messages);
38400
38414
  }
38401
- function buildReadChatReplayCollapseSignature(message) {
38402
- if (!message) return "";
38403
- const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
38404
- const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
38405
- const senderName = typeof message.senderName === "string" ? message.senderName.trim().toLowerCase() : "";
38406
- const content = flattenContent(message.content || "").replace(/\s+/g, " ").trim();
38407
- return `${role}:${kind}:${senderName}:${content}`;
38408
- }
38409
- function shouldCollapseReadChatReplayDuplicate(message) {
38410
- if (!message) return false;
38411
- const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
38412
- return role === "assistant" || role === "system";
38415
+ function normalizeReadChatReplayTextContent(content) {
38416
+ return flattenContent(content || "").replace(/\s+/g, " ").trim();
38413
38417
  }
38414
- function normalizeReadChatReplayText(message) {
38415
- return flattenContent(message?.content || "").replace(/\s+/g, " ").trim();
38416
- }
38417
- function isStableReadChatAssistantAnswer(message) {
38418
- if (!message) return false;
38418
+ function getReadChatReplayCollapseInfo(message) {
38419
+ if (!message) return null;
38419
38420
  const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
38420
38421
  const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
38421
- if (role !== "assistant") return false;
38422
- if (kind && kind !== "standard") return false;
38423
- const content = normalizeReadChatReplayText(message);
38424
- if (content.length < 160) return false;
38425
- if (/^(bash|shell|terminal) command\b/i.test(content)) return false;
38422
+ const senderName = typeof message.senderName === "string" ? message.senderName.trim().toLowerCase() : "";
38423
+ const collapsible = role === "assistant" || role === "system";
38424
+ if (!collapsible) return { role, kind, senderName, content: "", signature: "", collapsible };
38425
+ const content = normalizeReadChatReplayTextContent(message.content);
38426
+ return {
38427
+ role,
38428
+ kind,
38429
+ senderName,
38430
+ content,
38431
+ signature: `${role}:${kind}:${senderName}:${content}`,
38432
+ collapsible
38433
+ };
38434
+ }
38435
+ function isStableReadChatAssistantAnswerInfo(info) {
38436
+ if (!info) return false;
38437
+ if (info.role !== "assistant") return false;
38438
+ if (info.kind && info.kind !== "standard") return false;
38439
+ if (info.content.length < 160) return false;
38440
+ if (/^(bash|shell|terminal) command\b/i.test(info.content)) return false;
38426
38441
  return true;
38427
38442
  }
38428
- function isReplayedAssistantAnswerAfterStableAnswer(message, stableAnswer) {
38429
- if (!message || !stableAnswer) return false;
38430
- const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
38431
- const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
38432
- if (role !== "assistant") return false;
38433
- if (kind && kind !== "standard") return false;
38434
- const content = normalizeReadChatReplayText(message);
38435
- const stableContent = normalizeReadChatReplayText(stableAnswer);
38443
+ function isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableContent) {
38444
+ if (!info || !stableContent) return false;
38445
+ if (info.role !== "assistant") return false;
38446
+ if (info.kind && info.kind !== "standard") return false;
38447
+ const content = info.content;
38436
38448
  if (content.length < 80 || stableContent.length < 80) return false;
38437
38449
  return content === stableContent || content.startsWith(stableContent) || stableContent.startsWith(content);
38438
38450
  }
38439
38451
  function collapseReplayDuplicatesFromReadChat(messages) {
38440
38452
  const collapsed = [];
38441
38453
  const replaySignaturesInCurrentTurn = /* @__PURE__ */ new Set();
38442
- let stableAssistantAnswerInCurrentTurn = null;
38454
+ let stableAssistantAnswerContentInCurrentTurn = "";
38455
+ let previousReplaySignature = "";
38443
38456
  for (const message of messages) {
38444
- const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
38445
- if (role === "user") {
38457
+ const info = getReadChatReplayCollapseInfo(message);
38458
+ if (info?.role === "user") {
38446
38459
  replaySignaturesInCurrentTurn.clear();
38447
- stableAssistantAnswerInCurrentTurn = null;
38460
+ stableAssistantAnswerContentInCurrentTurn = "";
38461
+ previousReplaySignature = "";
38448
38462
  }
38449
- const signature = buildReadChatReplayCollapseSignature(message);
38450
- const previous = collapsed[collapsed.length - 1];
38451
- const previousSignature = buildReadChatReplayCollapseSignature(previous);
38452
- if (shouldCollapseReadChatReplayDuplicate(message) && signature) {
38453
- if (previousSignature === signature) continue;
38454
- if (replaySignaturesInCurrentTurn.has(signature)) continue;
38455
- if (isReplayedAssistantAnswerAfterStableAnswer(message, stableAssistantAnswerInCurrentTurn)) continue;
38463
+ if (info?.collapsible && info.signature) {
38464
+ if (previousReplaySignature === info.signature) continue;
38465
+ if (replaySignaturesInCurrentTurn.has(info.signature)) continue;
38466
+ if (isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableAssistantAnswerContentInCurrentTurn)) continue;
38456
38467
  }
38457
38468
  collapsed.push(message);
38458
- if (shouldCollapseReadChatReplayDuplicate(message) && signature) {
38459
- replaySignaturesInCurrentTurn.add(signature);
38469
+ previousReplaySignature = info?.collapsible ? info.signature : "";
38470
+ if (info?.collapsible && info.signature) {
38471
+ replaySignaturesInCurrentTurn.add(info.signature);
38460
38472
  }
38461
- if (isStableReadChatAssistantAnswer(message)) {
38462
- stableAssistantAnswerInCurrentTurn = message;
38473
+ if (isStableReadChatAssistantAnswerInfo(info)) {
38474
+ stableAssistantAnswerContentInCurrentTurn = info?.content || "";
38463
38475
  }
38464
38476
  }
38465
38477
  return collapsed;
@@ -38539,13 +38551,17 @@ ${effect.notification.body || ""}`.trim();
38539
38551
  };
38540
38552
  }
38541
38553
  if (cursor.tailLimit > 0 && knownSignature === lastMessageSignature) {
38542
- return {
38543
- syncMode: "noop",
38544
- replaceFrom: totalMessages,
38545
- messages: [],
38546
- totalMessages,
38547
- lastMessageSignature
38548
- };
38554
+ const requestedTailCount = Math.min(totalMessages, cursor.tailLimit);
38555
+ if (knownMessageCount >= requestedTailCount) {
38556
+ return {
38557
+ syncMode: "noop",
38558
+ replaceFrom: totalMessages,
38559
+ messages: [],
38560
+ totalMessages,
38561
+ lastMessageSignature
38562
+ };
38563
+ }
38564
+ return buildBoundedTailSync(messages, cursor);
38549
38565
  }
38550
38566
  if (knownMessageCount < totalMessages) {
38551
38567
  const anchorSignature = getChatMessageSignature(messages[knownMessageCount - 1]);
@@ -41457,8 +41473,8 @@ ${effect.notification.body || ""}`.trim();
41457
41473
  }
41458
41474
  detectStatusTransition() {
41459
41475
  const now = Date.now();
41460
- const adapterStatus = this.adapter.getStatus();
41461
- const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
41476
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
41477
+ const parsedStatus = null;
41462
41478
  const rawStatus = adapterStatus.status;
41463
41479
  const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
41464
41480
  if (autoApproveActive && !this.autoApproveBusy) {
@@ -41551,7 +41567,7 @@ ${effect.notification.body || ""}`.trim();
41551
41567
  this.completedDebouncePending = { chatTitle, duration: duration3, timestamp: now };
41552
41568
  this.completedDebounceTimer = setTimeout(() => {
41553
41569
  if (this.completedDebouncePending) {
41554
- const latestStatus = this.adapter.getStatus();
41570
+ const latestStatus = this.adapter.getStatus({ allowParse: false });
41555
41571
  const latestAutoApproveActive = latestStatus.status === "waiting_approval" && this.shouldAutoApprove();
41556
41572
  const latestVisibleStatus = latestAutoApproveActive ? "generating" : latestStatus.status;
41557
41573
  if (latestVisibleStatus !== "idle") {