@adhdev/daemon-core 0.8.95 → 0.8.97

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
@@ -1855,6 +1855,28 @@ __export(provider_cli_adapter_exports, {
1855
1855
  normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime
1856
1856
  });
1857
1857
  import * as os10 from "os";
1858
+ function normalizeComparableTranscriptText(value) {
1859
+ return sanitizeTerminalText(String(value || "")).replace(/\s+/g, " ").trim();
1860
+ }
1861
+ function parsedTranscriptIsRicherThanCommitted(parsedMessages, committedMessages) {
1862
+ if (!Array.isArray(parsedMessages) || !Array.isArray(committedMessages)) return false;
1863
+ if (parsedMessages.length > committedMessages.length) return true;
1864
+ if (parsedMessages.length !== committedMessages.length) return false;
1865
+ for (let index = 0; index < parsedMessages.length; index += 1) {
1866
+ const parsed = parsedMessages[index];
1867
+ const committed = committedMessages[index];
1868
+ if (!parsed || !committed) return false;
1869
+ if ((parsed.role || "") !== (committed.role || "")) return false;
1870
+ if (parsed.id && committed.id && String(parsed.id) !== String(committed.id)) return false;
1871
+ if (typeof parsed.index === "number" && typeof committed.index === "number" && parsed.index !== committed.index) return false;
1872
+ const parsedText = normalizeComparableTranscriptText(parsed.content);
1873
+ const committedText = normalizeComparableTranscriptText(committed.content);
1874
+ if (!parsedText || !committedText || parsedText === committedText) continue;
1875
+ if (parsedText.length > committedText.length && parsedText.startsWith(committedText)) return true;
1876
+ return false;
1877
+ }
1878
+ return false;
1879
+ }
1858
1880
  var ProviderCliAdapter;
1859
1881
  var init_provider_cli_adapter = __esm({
1860
1882
  "src/cli-adapters/provider-cli-adapter.ts"() {
@@ -3181,7 +3203,7 @@ var init_provider_cli_adapter = __esm({
3181
3203
  }));
3182
3204
  const parsedLastAssistant = [...parsedHydratedMessages].reverse().find((message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim());
3183
3205
  const visibleIdlePrompt = this.looksLikeVisibleIdlePrompt(screenText);
3184
- const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedHydratedMessages.length > committedHydratedMessages.length && (this.currentStatus === "idle" || this.currentStatus === "generating" && this.isWaitingForResponse && parsed.status === "idle" && visibleIdlePrompt);
3206
+ const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedTranscriptIsRicherThanCommitted(parsedHydratedMessages, committedHydratedMessages) && (this.currentStatus === "idle" || this.currentStatus === "generating" && this.isWaitingForResponse && parsed.status === "idle" && visibleIdlePrompt);
3185
3207
  if (shouldAdoptParsedIdleReplay) {
3186
3208
  this.committedMessages = normalizeCliParsedMessages(parsed.messages, {
3187
3209
  committedMessages: this.committedMessages,
@@ -12545,6 +12567,8 @@ var CliProviderInstance = class {
12545
12567
  generatingDebounceTimer = null;
12546
12568
  generatingDebouncePending = null;
12547
12569
  lastApprovalEventAt = 0;
12570
+ autoApproveBusy = false;
12571
+ autoApproveBusyTimer = null;
12548
12572
  controlValues = {};
12549
12573
  summaryMetadata = void 0;
12550
12574
  appliedEffectKeys = /* @__PURE__ */ new Set();
@@ -12836,7 +12860,13 @@ var CliProviderInstance = class {
12836
12860
  const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
12837
12861
  const rawStatus = adapterStatus.status;
12838
12862
  const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
12839
- if (autoApproveActive) {
12863
+ if (autoApproveActive && !this.autoApproveBusy) {
12864
+ this.autoApproveBusy = true;
12865
+ if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
12866
+ this.autoApproveBusyTimer = setTimeout(() => {
12867
+ this.autoApproveBusy = false;
12868
+ this.autoApproveBusyTimer = null;
12869
+ }, 2e3);
12840
12870
  const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(adapterStatus.activeModal?.buttons, this.provider);
12841
12871
  this.recordAutoApproval(adapterStatus.activeModal?.message, buttonLabel, now);
12842
12872
  setTimeout(() => {
@@ -13202,7 +13232,7 @@ ${effect.notification.body || ""}`.trim();
13202
13232
  const rebuilt = rebuildHermesSavedHistoryFromCanonicalSession(this.providerSessionId);
13203
13233
  if (!rebuilt) return false;
13204
13234
  this.lastCanonicalHermesSyncMtimeMs = stat.mtimeMs;
13205
- const restoredHistory = readChatHistory(this.type, 0, 200, this.providerSessionId);
13235
+ const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId);
13206
13236
  this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
13207
13237
  role: message.role,
13208
13238
  content: message.content,
@@ -13219,7 +13249,7 @@ ${effect.notification.body || ""}`.trim();
13219
13249
  if (!this.providerSessionId) return;
13220
13250
  this.syncCanonicalHermesSavedHistoryIfNeeded();
13221
13251
  this.historyWriter.compactHistorySession(this.type, this.providerSessionId);
13222
- const restoredHistory = readChatHistory(this.type, 0, 200, this.providerSessionId);
13252
+ const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId);
13223
13253
  this.historyWriter.seedSessionHistory(
13224
13254
  this.type,
13225
13255
  restoredHistory.messages,