@adhdev/daemon-standalone 0.9.0 → 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.js CHANGED
@@ -30188,6 +30188,10 @@ var require_dist2 = __commonJS({
30188
30188
  this.activeModal = startupModal;
30189
30189
  this.setStatus("waiting_approval", `startup_ready:${trigger}`);
30190
30190
  } else {
30191
+ if (this.currentStatus === "waiting_approval" || this.activeModal) {
30192
+ this.lastApprovalResolvedAt = Date.now();
30193
+ }
30194
+ this.activeModal = null;
30191
30195
  this.setStatus("idle", `startup_ready:${trigger}`);
30192
30196
  }
30193
30197
  LOG2.info(
@@ -30986,6 +30990,28 @@ var require_dist2 = __commonJS({
30986
30990
  if (this.isWaitingForResponse && this.currentTurnScope && this.currentStatus === "idle") return "generating";
30987
30991
  return this.currentStatus;
30988
30992
  }
30993
+ suppressStaleParsedApproval(parsed, recentBuffer, screenText) {
30994
+ const actionableParsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
30995
+ if (!parsed || parsed?.status !== "waiting_approval" || !actionableParsedModal) {
30996
+ return parsed;
30997
+ }
30998
+ const inApprovalCooldown = this.lastApprovalResolvedAt > 0 && Date.now() - this.lastApprovalResolvedAt < this.timeouts.approvalCooldown;
30999
+ if (!inApprovalCooldown) {
31000
+ return parsed;
31001
+ }
31002
+ const startupModal = this.getStartupConfirmationModal(screenText || "");
31003
+ const visibleModal = this.runParseApproval(recentBuffer) || startupModal;
31004
+ if (visibleModal) {
31005
+ return parsed;
31006
+ }
31007
+ const detectedStatus = this.runDetectStatus(recentBuffer);
31008
+ const fallbackStatus = detectedStatus && detectedStatus !== "waiting_approval" ? detectedStatus : this.isWaitingForResponse || this.currentTurnScope ? "generating" : this.currentStatus === "waiting_approval" ? "idle" : this.currentStatus;
31009
+ return {
31010
+ ...parsed,
31011
+ status: fallbackStatus,
31012
+ activeModal: null
31013
+ };
31014
+ }
30989
31015
  // ─── Public API (CliAdapter) ───────────────────
30990
31016
  getStatus() {
30991
31017
  const screenText = this.terminalScreen.getText() || "";
@@ -31204,15 +31230,16 @@ var require_dist2 = __commonJS({
31204
31230
  if (parsed && refinedStatus && parsed.status !== refinedStatus) {
31205
31231
  parsed.status = refinedStatus;
31206
31232
  }
31233
+ const normalizedParsed = this.suppressStaleParsedApproval(parsed, input.recentBuffer, input.screenText);
31207
31234
  const promptForTrim = scope?.prompt || getLastUserPromptText(baseMessages);
31208
- if (parsed && Array.isArray(parsed.messages) && promptForTrim) {
31209
- const lastAssistant = [...parsed.messages].reverse().find((message) => message?.role === "assistant" && typeof message.content === "string");
31235
+ if (normalizedParsed && Array.isArray(normalizedParsed.messages) && promptForTrim) {
31236
+ const lastAssistant = [...normalizedParsed.messages].reverse().find((message) => message?.role === "assistant" && typeof message.content === "string");
31210
31237
  if (lastAssistant) {
31211
31238
  lastAssistant.content = trimPromptEchoPrefix(lastAssistant.content, promptForTrim);
31212
31239
  }
31213
31240
  }
31214
31241
  this.parseErrorMessage = null;
31215
- return parsed;
31242
+ return normalizedParsed;
31216
31243
  } catch (e) {
31217
31244
  const message = e?.message || String(e);
31218
31245
  this.parseErrorMessage = message;
@@ -37404,10 +37431,13 @@ ${effect.notification.body || ""}`.trim();
37404
37431
  ...FULL_STATUS_ACTIVE_CHAT_OPTIONS,
37405
37432
  ...options
37406
37433
  };
37407
- return {
37408
- ...activeChat,
37434
+ const {
37435
+ messages: _messages,
37436
+ ...rest
37437
+ } = activeChat;
37438
+ const normalized = {
37439
+ ...rest,
37409
37440
  status: normalizeManagedStatus(activeChat.status, { activeModal: activeChat.activeModal }),
37410
- messages: trimMessagesForStatus(activeChat.messages, resolvedOptions),
37411
37441
  activeModal: resolvedOptions.includeActiveModal && activeChat.activeModal ? {
37412
37442
  message: truncateString(activeChat.activeModal.message || "", STATUS_MODAL_MESSAGE_LIMIT),
37413
37443
  buttons: (activeChat.activeModal.buttons || []).map(
@@ -37416,6 +37446,10 @@ ${effect.notification.body || ""}`.trim();
37416
37446
  } : null,
37417
37447
  inputContent: resolvedOptions.includeInputContent && activeChat.inputContent ? truncateString(activeChat.inputContent, 2 * 1024) : void 0
37418
37448
  };
37449
+ if (resolvedOptions.includeMessages) {
37450
+ normalized.messages = trimMessagesForStatus(activeChat.messages, resolvedOptions);
37451
+ }
37452
+ return normalized;
37419
37453
  }
37420
37454
  function getActiveChatOptions(profile) {
37421
37455
  if (profile === "full") return {};