@adhdev/daemon-standalone 0.8.89 → 0.8.91

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
@@ -29514,8 +29514,8 @@ var require_dist2 = __commonJS({
29514
29514
  scope,
29515
29515
  runtimeSettings
29516
29516
  } = options;
29517
- const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) || accumulatedBuffer : accumulatedBuffer;
29518
- const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) || accumulatedRawBuffer : accumulatedRawBuffer;
29517
+ const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
29518
+ const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
29519
29519
  const screenText = terminalScreenText;
29520
29520
  const recentBuffer = buffer.slice(-1e3) || recentOutputBuffer;
29521
29521
  return {
@@ -29547,8 +29547,8 @@ var require_dist2 = __commonJS({
29547
29547
  }
29548
29548
  function buildCliTraceParseSnapshot(options) {
29549
29549
  const { accumulatedBuffer, accumulatedRawBuffer, responseBuffer, partialResponse, scope } = options;
29550
- const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) || accumulatedBuffer : accumulatedBuffer;
29551
- const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) || accumulatedRawBuffer : accumulatedRawBuffer;
29550
+ const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
29551
+ const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
29552
29552
  return {
29553
29553
  currentTurnScope: scope || null,
29554
29554
  responseBuffer: summarizeCliTraceText(responseBuffer, 1200),
@@ -30208,6 +30208,7 @@ var require_dist2 = __commonJS({
30208
30208
  looksLikeClaudeGeneratingLine(line) {
30209
30209
  const trimmed = String(line || "").trim();
30210
30210
  if (!trimmed) return false;
30211
+ if (/^⏵⏵\s+accept edits on/i.test(trimmed)) return false;
30211
30212
  if (/esc to (cancel|interrupt|stop)/i.test(trimmed)) return true;
30212
30213
  if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+\S+.*\b(?:thinking|thought for \d+s?)\b/i.test(trimmed)) return true;
30213
30214
  if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+[A-Z][A-Za-z-]{3,}ing\b.*(?:…|\.{3})/u.test(trimmed)) return true;
@@ -30417,14 +30418,15 @@ var require_dist2 = __commonJS({
30417
30418
  return;
30418
30419
  }
30419
30420
  const startupModal = this.getStartupConfirmationModal(screenText);
30420
- const modal = this.runParseApproval(tail) || startupModal;
30421
- const rawScriptStatus = this.runDetectStatus(tail);
30422
- const scriptStatus = startupModal ? "waiting_approval" : rawScriptStatus;
30423
30421
  const parsedTranscript = this.parseCurrentTranscript(
30424
30422
  this.committedMessages,
30425
30423
  this.responseBuffer,
30426
30424
  this.currentTurnScope
30427
30425
  );
30426
+ const parsedModal = parsedTranscript?.activeModal && Array.isArray(parsedTranscript.activeModal.buttons) && parsedTranscript.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsedTranscript.activeModal : null;
30427
+ const modal = this.runParseApproval(tail) || parsedModal || startupModal;
30428
+ const rawScriptStatus = this.runDetectStatus(tail);
30429
+ const scriptStatus = startupModal ? "waiting_approval" : parsedModal && parsedTranscript?.status === "waiting_approval" ? "waiting_approval" : rawScriptStatus;
30428
30430
  const parsedMessages = Array.isArray(parsedTranscript?.messages) ? normalizeCliParsedMessages(parsedTranscript.messages, {
30429
30431
  committedMessages: this.committedMessages,
30430
30432
  scope: this.currentTurnScope,
@@ -30434,6 +30436,7 @@ var require_dist2 = __commonJS({
30434
30436
  return;
30435
30437
  }
30436
30438
  const lastParsedAssistant = [...parsedMessages].reverse().find((message) => message.role === "assistant");
30439
+ const parsedShowsLiveAssistantProgress = parsedTranscript?.status === "generating" && !!lastParsedAssistant && parsedMessages.length > this.committedMessages.length;
30437
30440
  const normalizedPromptSnippet = normalizePromptText(this.submitRetryPromptSnippet || this.currentTurnScope?.prompt || "");
30438
30441
  this.recordTrace("settled", {
30439
30442
  tail: summarizeCliTraceText(tail, 500),
@@ -30520,7 +30523,7 @@ var require_dist2 = __commonJS({
30520
30523
  `[${this.cliType}] settled diagnostics prompt=${JSON.stringify(this.currentTurnScope.prompt).slice(0, 140)} scriptStatus=${String(scriptStatus || "")} parsedStatus=${String(parsedTranscript?.status || "")} parsedMsgCount=${parsedMessages.length} lastParsedAssistant=${JSON.stringify(summarizeCliTraceText(lastParsedAssistant?.content || "", 120)).slice(0, 160)} visibleIdlePrompt=${String(visibleIdlePrompt)} visibleAssistantCandidate=${String(visibleAssistantCandidate)} responseBuffer=${JSON.stringify(summarizeCliTraceText(this.responseBuffer, 160)).slice(0, 220)} screen=${JSON.stringify(summarizeCliTraceText(screenText, 160)).slice(0, 220)}`
30521
30524
  );
30522
30525
  }
30523
- const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate);
30526
+ const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate) && !(parsedTranscript?.status === "idle" && !!lastParsedAssistant);
30524
30527
  if (shouldHoldGenerating) {
30525
30528
  this.clearIdleFinishCandidate("hold_generating_recent_activity");
30526
30529
  this.setStatus("generating", "recent_activity_hold");
@@ -30588,7 +30591,7 @@ var require_dist2 = __commonJS({
30588
30591
  const effectiveScreenText = screenText || this.accumulatedBuffer;
30589
30592
  const noActiveTurn = !this.currentTurnScope;
30590
30593
  const looksIdleChrome = /(^|\n)\s*[❯›>]\s*(?:\n|$)/m.test(effectiveScreenText) || /accept edits on/i.test(effectiveScreenText) && (/Update available!/i.test(screenText) || /\/effort/i.test(screenText) || /^.*➜\s+\S+/m.test(effectiveScreenText));
30591
- if (prevStatus === "idle" && !this.isWaitingForResponse && noActiveTurn && !modal && looksIdleChrome) {
30594
+ if (prevStatus === "idle" && !this.isWaitingForResponse && noActiveTurn && !modal && looksIdleChrome && !parsedShowsLiveAssistantProgress) {
30592
30595
  return;
30593
30596
  }
30594
30597
  if (prevStatus === "waiting_approval") {
@@ -30922,11 +30925,17 @@ var require_dist2 = __commonJS({
30922
30925
  return null;
30923
30926
  }
30924
30927
  }
30928
+ projectEffectiveStatus(startupModal = null) {
30929
+ if (this.parseErrorMessage) return "error";
30930
+ if (startupModal) return "waiting_approval";
30931
+ if (this.isWaitingForResponse && this.currentTurnScope && this.currentStatus === "idle") return "generating";
30932
+ return this.currentStatus;
30933
+ }
30925
30934
  // ─── Public API (CliAdapter) ───────────────────
30926
30935
  getStatus() {
30927
30936
  const screenText = this.terminalScreen.getText() || "";
30928
30937
  const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
30929
- const effectiveStatus = this.parseErrorMessage ? "error" : startupModal ? "waiting_approval" : this.currentStatus;
30938
+ const effectiveStatus = this.projectEffectiveStatus(startupModal);
30930
30939
  return {
30931
30940
  status: effectiveStatus,
30932
30941
  messages: [...this.committedMessages],
@@ -31633,7 +31642,7 @@ ${data.message || ""}`.trim();
31633
31642
  }
31634
31643
  this.setStatus("generating", "approval_resolved");
31635
31644
  this.onStatusChange?.();
31636
- const startupTrustModal = /Quick safety check|project trust|trust (?:this project|the contents of this directory|the files in this folder)/i.test(String(modal?.message || ""));
31645
+ const startupTrustModal = /Quick safety check|project trust|Confirm Claude Code project trust|trust (?:this project|the contents of this directory|the files in this folder)/i.test(String(modal?.message || ""));
31637
31646
  if (startupTrustModal && buttonIndex in this.approvalKeys) {
31638
31647
  this.ptyProcess.write(`${this.approvalKeys[buttonIndex]}\r`);
31639
31648
  } else if (this.shouldResolveModalWithEnter(modal, buttonIndex)) {
@@ -31659,7 +31668,7 @@ ${data.message || ""}`.trim();
31659
31668
  getDebugState() {
31660
31669
  const screenText = sanitizeTerminalText(this.terminalScreen.getText());
31661
31670
  const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
31662
- const effectiveStatus = startupModal ? "waiting_approval" : this.currentStatus;
31671
+ const effectiveStatus = this.projectEffectiveStatus(startupModal);
31663
31672
  const effectiveReady = this.ready || !!startupModal;
31664
31673
  return {
31665
31674
  type: this.cliType,
@@ -37900,10 +37909,11 @@ ${effect.notification.body || ""}`.trim();
37900
37909
  const parsedRecord = parsedStatus && typeof parsedStatus === "object" ? parsedStatus : null;
37901
37910
  const adapterStatus = adapter.getStatus();
37902
37911
  const shouldPreferAdapterMessages = Array.isArray(adapterStatus.messages) && adapterStatus.messages.length > 0 && Array.isArray(parsedRecord?.messages) && adapterStatus.messages.length > parsedRecord.messages.length;
37912
+ const parsedShowsApproval = hasNonEmptyModalButtons(parsedRecord?.activeModal) && parsedRecord?.status === "waiting_approval";
37903
37913
  const status = parsedRecord ? {
37904
37914
  ...parsedRecord,
37905
37915
  messages: shouldPreferAdapterMessages ? adapterStatus.messages : parsedRecord.messages,
37906
- status: adapterStatus.status !== "idle" ? adapterStatus.status : parsedRecord.status || adapterStatus.status,
37916
+ status: parsedShowsApproval ? parsedRecord.status : adapterStatus.status !== "idle" ? adapterStatus.status : parsedRecord.status || adapterStatus.status,
37907
37917
  activeModal: parsedRecord.activeModal || adapterStatus.activeModal
37908
37918
  } : adapterStatus;
37909
37919
  const title = typeof parsedRecord?.title === "string" ? parsedRecord.title : void 0;
@@ -46023,6 +46033,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
46023
46033
  }
46024
46034
  }
46025
46035
  onStatusChange() {
46036
+ if (this.deps.p2p?.isConnected) {
46037
+ this.resetP2PHash();
46038
+ this.sendUnifiedStatusReport({ p2pOnly: true, reason: "status-change" }).catch((e) => LOG2.warn("Status", `Immediate P2P status send failed: ${e?.message}`));
46039
+ }
46026
46040
  this.throttledReport();
46027
46041
  }
46028
46042
  throttledReport() {
@@ -46120,10 +46134,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
46120
46134
  }
46121
46135
  async sendUnifiedStatusReport(opts) {
46122
46136
  const { serverConn, p2p } = this.deps;
46123
- if (!serverConn?.isConnected()) return;
46137
+ const serverConnected = !!serverConn?.isConnected();
46138
+ const p2pConnected = !!p2p?.isConnected;
46139
+ if (!serverConnected && !p2pConnected) return;
46124
46140
  this.lastStatusSentAt = Date.now();
46125
46141
  const now = this.lastStatusSentAt;
46126
- const target = opts?.p2pOnly ? "P2P" : "P2P+Server";
46142
+ const target = opts?.p2pOnly ? "P2P" : serverConnected ? "P2P+Server" : "P2P";
46127
46143
  const allStates = this.deps.instanceManager.collectAllStates();
46128
46144
  const ideStates = allStates.filter((s15) => s15.category === "ide");
46129
46145
  const cliStates = allStates.filter((s15) => s15.category === "cli");
@@ -46202,6 +46218,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46202
46218
  ...wsPayload,
46203
46219
  timestamp: void 0
46204
46220
  }));
46221
+ if (!serverConnected || !serverConn) return;
46205
46222
  if (!opts?.forceServer && wsHash === this.lastServerStatusHash) {
46206
46223
  LOG2.debug("Server", `skip duplicate status_report${opts?.reason ? ` (${opts.reason})` : ""}`);
46207
46224
  return;