@adhdev/daemon-core 0.8.102 → 0.9.1

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
@@ -2321,6 +2321,10 @@ var init_provider_cli_adapter = __esm({
2321
2321
  this.activeModal = startupModal;
2322
2322
  this.setStatus("waiting_approval", `startup_ready:${trigger}`);
2323
2323
  } else {
2324
+ if (this.currentStatus === "waiting_approval" || this.activeModal) {
2325
+ this.lastApprovalResolvedAt = Date.now();
2326
+ }
2327
+ this.activeModal = null;
2324
2328
  this.setStatus("idle", `startup_ready:${trigger}`);
2325
2329
  }
2326
2330
  LOG.info(
@@ -3119,6 +3123,28 @@ var init_provider_cli_adapter = __esm({
3119
3123
  if (this.isWaitingForResponse && this.currentTurnScope && this.currentStatus === "idle") return "generating";
3120
3124
  return this.currentStatus;
3121
3125
  }
3126
+ suppressStaleParsedApproval(parsed, recentBuffer, screenText) {
3127
+ const actionableParsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
3128
+ if (!parsed || parsed?.status !== "waiting_approval" || !actionableParsedModal) {
3129
+ return parsed;
3130
+ }
3131
+ const inApprovalCooldown = this.lastApprovalResolvedAt > 0 && Date.now() - this.lastApprovalResolvedAt < this.timeouts.approvalCooldown;
3132
+ if (!inApprovalCooldown) {
3133
+ return parsed;
3134
+ }
3135
+ const startupModal = this.getStartupConfirmationModal(screenText || "");
3136
+ const visibleModal = this.runParseApproval(recentBuffer) || startupModal;
3137
+ if (visibleModal) {
3138
+ return parsed;
3139
+ }
3140
+ const detectedStatus = this.runDetectStatus(recentBuffer);
3141
+ const fallbackStatus = detectedStatus && detectedStatus !== "waiting_approval" ? detectedStatus : this.isWaitingForResponse || this.currentTurnScope ? "generating" : this.currentStatus === "waiting_approval" ? "idle" : this.currentStatus;
3142
+ return {
3143
+ ...parsed,
3144
+ status: fallbackStatus,
3145
+ activeModal: null
3146
+ };
3147
+ }
3122
3148
  // ─── Public API (CliAdapter) ───────────────────
3123
3149
  getStatus() {
3124
3150
  const screenText = this.terminalScreen.getText() || "";
@@ -3337,15 +3363,16 @@ var init_provider_cli_adapter = __esm({
3337
3363
  if (parsed && refinedStatus && parsed.status !== refinedStatus) {
3338
3364
  parsed.status = refinedStatus;
3339
3365
  }
3366
+ const normalizedParsed = this.suppressStaleParsedApproval(parsed, input.recentBuffer, input.screenText);
3340
3367
  const promptForTrim = scope?.prompt || getLastUserPromptText(baseMessages);
3341
- if (parsed && Array.isArray(parsed.messages) && promptForTrim) {
3342
- const lastAssistant = [...parsed.messages].reverse().find((message) => message?.role === "assistant" && typeof message.content === "string");
3368
+ if (normalizedParsed && Array.isArray(normalizedParsed.messages) && promptForTrim) {
3369
+ const lastAssistant = [...normalizedParsed.messages].reverse().find((message) => message?.role === "assistant" && typeof message.content === "string");
3343
3370
  if (lastAssistant) {
3344
3371
  lastAssistant.content = trimPromptEchoPrefix(lastAssistant.content, promptForTrim);
3345
3372
  }
3346
3373
  }
3347
3374
  this.parseErrorMessage = null;
3348
- return parsed;
3375
+ return normalizedParsed;
3349
3376
  } catch (e) {
3350
3377
  const message = e?.message || String(e);
3351
3378
  this.parseErrorMessage = message;
@@ -9457,10 +9484,13 @@ function normalizeActiveChatData(activeChat, options = FULL_STATUS_ACTIVE_CHAT_O
9457
9484
  ...FULL_STATUS_ACTIVE_CHAT_OPTIONS,
9458
9485
  ...options
9459
9486
  };
9460
- return {
9461
- ...activeChat,
9487
+ const {
9488
+ messages: _messages,
9489
+ ...rest
9490
+ } = activeChat;
9491
+ const normalized = {
9492
+ ...rest,
9462
9493
  status: normalizeManagedStatus(activeChat.status, { activeModal: activeChat.activeModal }),
9463
- messages: trimMessagesForStatus(activeChat.messages, resolvedOptions),
9464
9494
  activeModal: resolvedOptions.includeActiveModal && activeChat.activeModal ? {
9465
9495
  message: truncateString(activeChat.activeModal.message || "", STATUS_MODAL_MESSAGE_LIMIT),
9466
9496
  buttons: (activeChat.activeModal.buttons || []).map(
@@ -9469,6 +9499,10 @@ function normalizeActiveChatData(activeChat, options = FULL_STATUS_ACTIVE_CHAT_O
9469
9499
  } : null,
9470
9500
  inputContent: resolvedOptions.includeInputContent && activeChat.inputContent ? truncateString(activeChat.inputContent, 2 * 1024) : void 0
9471
9501
  };
9502
+ if (resolvedOptions.includeMessages) {
9503
+ normalized.messages = trimMessagesForStatus(activeChat.messages, resolvedOptions);
9504
+ }
9505
+ return normalized;
9472
9506
  }
9473
9507
 
9474
9508
  // src/status/builders.ts