@adhdev/daemon-core 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.
@@ -146,6 +146,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
146
146
  private commitCurrentTranscript;
147
147
  private runDetectStatus;
148
148
  private runParseApproval;
149
+ private projectEffectiveStatus;
149
150
  getStatus(): CliSessionStatus;
150
151
  seedCommittedMessages(messages: SeedCliChatMessage[]): void;
151
152
  /**
package/dist/index.js CHANGED
@@ -1664,8 +1664,8 @@ function buildCliParseInput(options) {
1664
1664
  scope,
1665
1665
  runtimeSettings
1666
1666
  } = options;
1667
- const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) || accumulatedBuffer : accumulatedBuffer;
1668
- const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) || accumulatedRawBuffer : accumulatedRawBuffer;
1667
+ const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
1668
+ const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
1669
1669
  const screenText = terminalScreenText;
1670
1670
  const recentBuffer = buffer.slice(-1e3) || recentOutputBuffer;
1671
1671
  return {
@@ -1697,8 +1697,8 @@ function summarizeCliTraceMessages(messages, limit = 3) {
1697
1697
  }
1698
1698
  function buildCliTraceParseSnapshot(options) {
1699
1699
  const { accumulatedBuffer, accumulatedRawBuffer, responseBuffer, partialResponse, scope } = options;
1700
- const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) || accumulatedBuffer : accumulatedBuffer;
1701
- const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) || accumulatedRawBuffer : accumulatedRawBuffer;
1700
+ const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
1701
+ const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
1702
1702
  return {
1703
1703
  currentTurnScope: scope || null,
1704
1704
  responseBuffer: summarizeCliTraceText(responseBuffer, 1200),
@@ -2362,6 +2362,7 @@ var init_provider_cli_adapter = __esm({
2362
2362
  looksLikeClaudeGeneratingLine(line) {
2363
2363
  const trimmed = String(line || "").trim();
2364
2364
  if (!trimmed) return false;
2365
+ if (/^⏵⏵\s+accept edits on/i.test(trimmed)) return false;
2365
2366
  if (/esc to (cancel|interrupt|stop)/i.test(trimmed)) return true;
2366
2367
  if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+\S+.*\b(?:thinking|thought for \d+s?)\b/i.test(trimmed)) return true;
2367
2368
  if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+[A-Z][A-Za-z-]{3,}ing\b.*(?:…|\.{3})/u.test(trimmed)) return true;
@@ -2571,14 +2572,15 @@ var init_provider_cli_adapter = __esm({
2571
2572
  return;
2572
2573
  }
2573
2574
  const startupModal = this.getStartupConfirmationModal(screenText);
2574
- const modal = this.runParseApproval(tail) || startupModal;
2575
- const rawScriptStatus = this.runDetectStatus(tail);
2576
- const scriptStatus = startupModal ? "waiting_approval" : rawScriptStatus;
2577
2575
  const parsedTranscript = this.parseCurrentTranscript(
2578
2576
  this.committedMessages,
2579
2577
  this.responseBuffer,
2580
2578
  this.currentTurnScope
2581
2579
  );
2580
+ const parsedModal = parsedTranscript?.activeModal && Array.isArray(parsedTranscript.activeModal.buttons) && parsedTranscript.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsedTranscript.activeModal : null;
2581
+ const modal = this.runParseApproval(tail) || parsedModal || startupModal;
2582
+ const rawScriptStatus = this.runDetectStatus(tail);
2583
+ const scriptStatus = startupModal ? "waiting_approval" : parsedModal && parsedTranscript?.status === "waiting_approval" ? "waiting_approval" : rawScriptStatus;
2582
2584
  const parsedMessages = Array.isArray(parsedTranscript?.messages) ? normalizeCliParsedMessages(parsedTranscript.messages, {
2583
2585
  committedMessages: this.committedMessages,
2584
2586
  scope: this.currentTurnScope,
@@ -2588,6 +2590,7 @@ var init_provider_cli_adapter = __esm({
2588
2590
  return;
2589
2591
  }
2590
2592
  const lastParsedAssistant = [...parsedMessages].reverse().find((message) => message.role === "assistant");
2593
+ const parsedShowsLiveAssistantProgress = parsedTranscript?.status === "generating" && !!lastParsedAssistant && parsedMessages.length > this.committedMessages.length;
2591
2594
  const normalizedPromptSnippet = normalizePromptText(this.submitRetryPromptSnippet || this.currentTurnScope?.prompt || "");
2592
2595
  this.recordTrace("settled", {
2593
2596
  tail: summarizeCliTraceText(tail, 500),
@@ -2674,7 +2677,7 @@ var init_provider_cli_adapter = __esm({
2674
2677
  `[${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)}`
2675
2678
  );
2676
2679
  }
2677
- const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate);
2680
+ const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate) && !(parsedTranscript?.status === "idle" && !!lastParsedAssistant);
2678
2681
  if (shouldHoldGenerating) {
2679
2682
  this.clearIdleFinishCandidate("hold_generating_recent_activity");
2680
2683
  this.setStatus("generating", "recent_activity_hold");
@@ -2742,7 +2745,7 @@ var init_provider_cli_adapter = __esm({
2742
2745
  const effectiveScreenText = screenText || this.accumulatedBuffer;
2743
2746
  const noActiveTurn = !this.currentTurnScope;
2744
2747
  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));
2745
- if (prevStatus === "idle" && !this.isWaitingForResponse && noActiveTurn && !modal && looksIdleChrome) {
2748
+ if (prevStatus === "idle" && !this.isWaitingForResponse && noActiveTurn && !modal && looksIdleChrome && !parsedShowsLiveAssistantProgress) {
2746
2749
  return;
2747
2750
  }
2748
2751
  if (prevStatus === "waiting_approval") {
@@ -3076,11 +3079,17 @@ var init_provider_cli_adapter = __esm({
3076
3079
  return null;
3077
3080
  }
3078
3081
  }
3082
+ projectEffectiveStatus(startupModal = null) {
3083
+ if (this.parseErrorMessage) return "error";
3084
+ if (startupModal) return "waiting_approval";
3085
+ if (this.isWaitingForResponse && this.currentTurnScope && this.currentStatus === "idle") return "generating";
3086
+ return this.currentStatus;
3087
+ }
3079
3088
  // ─── Public API (CliAdapter) ───────────────────
3080
3089
  getStatus() {
3081
3090
  const screenText = this.terminalScreen.getText() || "";
3082
3091
  const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
3083
- const effectiveStatus = this.parseErrorMessage ? "error" : startupModal ? "waiting_approval" : this.currentStatus;
3092
+ const effectiveStatus = this.projectEffectiveStatus(startupModal);
3084
3093
  return {
3085
3094
  status: effectiveStatus,
3086
3095
  messages: [...this.committedMessages],
@@ -3787,7 +3796,7 @@ ${data.message || ""}`.trim();
3787
3796
  }
3788
3797
  this.setStatus("generating", "approval_resolved");
3789
3798
  this.onStatusChange?.();
3790
- 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 || ""));
3799
+ 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 || ""));
3791
3800
  if (startupTrustModal && buttonIndex in this.approvalKeys) {
3792
3801
  this.ptyProcess.write(`${this.approvalKeys[buttonIndex]}\r`);
3793
3802
  } else if (this.shouldResolveModalWithEnter(modal, buttonIndex)) {
@@ -3813,7 +3822,7 @@ ${data.message || ""}`.trim();
3813
3822
  getDebugState() {
3814
3823
  const screenText = sanitizeTerminalText(this.terminalScreen.getText());
3815
3824
  const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
3816
- const effectiveStatus = startupModal ? "waiting_approval" : this.currentStatus;
3825
+ const effectiveStatus = this.projectEffectiveStatus(startupModal);
3817
3826
  const effectiveReady = this.ready || !!startupModal;
3818
3827
  return {
3819
3828
  type: this.cliType,
@@ -10142,10 +10151,11 @@ async function handleReadChat(h, args) {
10142
10151
  const parsedRecord = parsedStatus && typeof parsedStatus === "object" ? parsedStatus : null;
10143
10152
  const adapterStatus = adapter.getStatus();
10144
10153
  const shouldPreferAdapterMessages = Array.isArray(adapterStatus.messages) && adapterStatus.messages.length > 0 && Array.isArray(parsedRecord?.messages) && adapterStatus.messages.length > parsedRecord.messages.length;
10154
+ const parsedShowsApproval = hasNonEmptyModalButtons(parsedRecord?.activeModal) && parsedRecord?.status === "waiting_approval";
10145
10155
  const status = parsedRecord ? {
10146
10156
  ...parsedRecord,
10147
10157
  messages: shouldPreferAdapterMessages ? adapterStatus.messages : parsedRecord.messages,
10148
- status: adapterStatus.status !== "idle" ? adapterStatus.status : parsedRecord.status || adapterStatus.status,
10158
+ status: parsedShowsApproval ? parsedRecord.status : adapterStatus.status !== "idle" ? adapterStatus.status : parsedRecord.status || adapterStatus.status,
10149
10159
  activeModal: parsedRecord.activeModal || adapterStatus.activeModal
10150
10160
  } : adapterStatus;
10151
10161
  const title = typeof parsedRecord?.title === "string" ? parsedRecord.title : void 0;
@@ -18315,6 +18325,10 @@ var DaemonStatusReporter = class {
18315
18325
  }
18316
18326
  }
18317
18327
  onStatusChange() {
18328
+ if (this.deps.p2p?.isConnected) {
18329
+ this.resetP2PHash();
18330
+ this.sendUnifiedStatusReport({ p2pOnly: true, reason: "status-change" }).catch((e) => LOG.warn("Status", `Immediate P2P status send failed: ${e?.message}`));
18331
+ }
18318
18332
  this.throttledReport();
18319
18333
  }
18320
18334
  throttledReport() {
@@ -18412,10 +18426,12 @@ var DaemonStatusReporter = class {
18412
18426
  }
18413
18427
  async sendUnifiedStatusReport(opts) {
18414
18428
  const { serverConn, p2p } = this.deps;
18415
- if (!serverConn?.isConnected()) return;
18429
+ const serverConnected = !!serverConn?.isConnected();
18430
+ const p2pConnected = !!p2p?.isConnected;
18431
+ if (!serverConnected && !p2pConnected) return;
18416
18432
  this.lastStatusSentAt = Date.now();
18417
18433
  const now = this.lastStatusSentAt;
18418
- const target = opts?.p2pOnly ? "P2P" : "P2P+Server";
18434
+ const target = opts?.p2pOnly ? "P2P" : serverConnected ? "P2P+Server" : "P2P";
18419
18435
  const allStates = this.deps.instanceManager.collectAllStates();
18420
18436
  const ideStates = allStates.filter((s) => s.category === "ide");
18421
18437
  const cliStates = allStates.filter((s) => s.category === "cli");
@@ -18494,6 +18510,7 @@ var DaemonStatusReporter = class {
18494
18510
  ...wsPayload,
18495
18511
  timestamp: void 0
18496
18512
  }));
18513
+ if (!serverConnected || !serverConn) return;
18497
18514
  if (!opts?.forceServer && wsHash === this.lastServerStatusHash) {
18498
18515
  LOG.debug("Server", `skip duplicate status_report${opts?.reason ? ` (${opts.reason})` : ""}`);
18499
18516
  return;