@adhdev/daemon-core 0.9.55 → 0.9.56

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
@@ -2302,6 +2302,12 @@ var init_provider_cli_adapter = __esm({
2302
2302
  accumulatedRawBuffer = "";
2303
2303
  /** Current visible terminal screen snapshot */
2304
2304
  terminalScreen = new TerminalScreen(24, 80);
2305
+ static MAX_RESPONSE_BUFFER = 8e3;
2306
+ static MAX_RECENT_OUTPUT_BUFFER = 1e3;
2307
+ responseBufferDroppedChars = 0;
2308
+ recentOutputDroppedChars = 0;
2309
+ accumulatedBufferDroppedChars = 0;
2310
+ accumulatedRawBufferDroppedChars = 0;
2305
2311
  /** Max accumulated buffer size. Sized to comfortably hold a single long
2306
2312
  * Hermes turn (tool calls + reasoning + final bubble) without the
2307
2313
  * rolling window pushing the turn's ╭─ opening line out of view. */
@@ -2319,6 +2325,23 @@ var init_provider_cli_adapter = __esm({
2319
2325
  providerResolutionMeta;
2320
2326
  static FINISH_RETRY_DELAY_MS = 300;
2321
2327
  static MAX_FINISH_RETRIES = 2;
2328
+ getBufferState() {
2329
+ const build = (droppedChars, maxChars) => droppedChars > 0 ? { truncated: true, droppedChars, maxChars } : void 0;
2330
+ const responseBuffer = build(this.responseBufferDroppedChars, _ProviderCliAdapter.MAX_RESPONSE_BUFFER);
2331
+ const recentOutputBuffer = build(this.recentOutputDroppedChars, _ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
2332
+ const accumulatedBuffer = build(this.accumulatedBufferDroppedChars, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
2333
+ const accumulatedRawBuffer = build(this.accumulatedRawBufferDroppedChars, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
2334
+ if (!responseBuffer && !recentOutputBuffer && !accumulatedBuffer && !accumulatedRawBuffer) return void 0;
2335
+ return {
2336
+ ...responseBuffer ? { responseBuffer } : {},
2337
+ ...recentOutputBuffer ? { recentOutputBuffer } : {},
2338
+ ...accumulatedBuffer ? { accumulatedBuffer } : {},
2339
+ ...accumulatedRawBuffer ? { accumulatedRawBuffer } : {}
2340
+ };
2341
+ }
2342
+ recordBoundedAppendDrop(previousLength, appendedLength, nextLength) {
2343
+ return Math.max(0, previousLength + appendedLength - nextLength);
2344
+ }
2322
2345
  buildCommittedMessagesActivitySignature() {
2323
2346
  const last = this.committedMessages[this.committedMessages.length - 1];
2324
2347
  return [
@@ -2684,7 +2707,9 @@ var init_provider_cli_adapter = __esm({
2684
2707
  this.scheduleStartupSettleCheck();
2685
2708
  }
2686
2709
  if (this.isWaitingForResponse && cleanData) {
2687
- this.responseBuffer = appendBoundedText(this.responseBuffer, cleanData, 8e3);
2710
+ const previousResponseLen = this.responseBuffer.length;
2711
+ this.responseBuffer = appendBoundedText(this.responseBuffer, cleanData, _ProviderCliAdapter.MAX_RESPONSE_BUFFER);
2712
+ this.responseBufferDroppedChars += this.recordBoundedAppendDrop(previousResponseLen, cleanData.length, this.responseBuffer.length);
2688
2713
  }
2689
2714
  if (cleanData.trim()) {
2690
2715
  if (this.serverConn) {
@@ -2693,14 +2718,19 @@ var init_provider_cli_adapter = __esm({
2693
2718
  this.logBuffer.push({ message: cleanData.trim(), level: "info" });
2694
2719
  }
2695
2720
  }
2721
+ const prevRecentLen = this.recentOutputBuffer.length;
2696
2722
  const prevAccumulatedLen = this.accumulatedBuffer.length;
2697
2723
  const prevAccumulatedRawLen = this.accumulatedRawBuffer.length;
2698
- this.recentOutputBuffer = appendBoundedText(this.recentOutputBuffer, cleanData, 1e3);
2724
+ this.recentOutputBuffer = appendBoundedText(this.recentOutputBuffer, cleanData, _ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
2699
2725
  this.accumulatedBuffer = appendBoundedText(this.accumulatedBuffer, cleanData, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
2700
2726
  this.accumulatedRawBuffer = appendBoundedText(this.accumulatedRawBuffer, rawData, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
2727
+ const droppedRecent = this.recordBoundedAppendDrop(prevRecentLen, cleanData.length, this.recentOutputBuffer.length);
2728
+ const droppedClean = this.recordBoundedAppendDrop(prevAccumulatedLen, cleanData.length, this.accumulatedBuffer.length);
2729
+ const droppedRaw = this.recordBoundedAppendDrop(prevAccumulatedRawLen, rawData.length, this.accumulatedRawBuffer.length);
2730
+ this.recentOutputDroppedChars += droppedRecent;
2731
+ this.accumulatedBufferDroppedChars += droppedClean;
2732
+ this.accumulatedRawBufferDroppedChars += droppedRaw;
2701
2733
  if (this.currentTurnScope) {
2702
- const droppedClean = prevAccumulatedLen + cleanData.length - this.accumulatedBuffer.length;
2703
- const droppedRaw = prevAccumulatedRawLen + rawData.length - this.accumulatedRawBuffer.length;
2704
2734
  if (droppedClean > 0) {
2705
2735
  this.currentTurnScope.bufferStart = Math.max(0, this.currentTurnScope.bufferStart - droppedClean);
2706
2736
  }
@@ -3530,13 +3560,15 @@ var init_provider_cli_adapter = __esm({
3530
3560
  effectiveModal = parsedModal;
3531
3561
  }
3532
3562
  }
3563
+ const bufferState = this.getBufferState();
3533
3564
  return {
3534
3565
  status: effectiveStatus,
3535
3566
  messages: [...this.committedMessages],
3536
3567
  workingDir: this.workingDir,
3537
3568
  activeModal: effectiveModal,
3538
3569
  errorMessage: this.parseErrorMessage || void 0,
3539
- errorReason: this.parseErrorMessage ? "parse_error" : void 0
3570
+ errorReason: this.parseErrorMessage ? "parse_error" : void 0,
3571
+ ...bufferState ? { bufferState } : {}
3540
3572
  };
3541
3573
  }
3542
3574
  seedCommittedMessages(messages) {
@@ -3718,10 +3750,12 @@ var init_provider_cli_adapter = __esm({
3718
3750
  messages: hydratedMessages,
3719
3751
  activeModal: parsed.activeModal ?? this.activeModal,
3720
3752
  providerSessionId: typeof parsed.providerSessionId === "string" ? parsed.providerSessionId : void 0,
3753
+ ...this.getBufferState() ? { bufferState: this.getBufferState() } : {},
3721
3754
  ...this.providerOwnsTranscript() ? { transcriptAuthority: "provider", coverage: this.shouldUseFullProviderTranscriptContext() ? "full" : "tail" } : {}
3722
3755
  };
3723
3756
  } else {
3724
3757
  const messages = [...this.committedMessages];
3758
+ const bufferState = this.getBufferState();
3725
3759
  result = {
3726
3760
  id: "cli_session",
3727
3761
  status: this.currentStatus,
@@ -3732,7 +3766,8 @@ var init_provider_cli_adapter = __esm({
3732
3766
  index: typeof message.index === "number" ? message.index : index,
3733
3767
  receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
3734
3768
  })),
3735
- activeModal: this.activeModal
3769
+ activeModal: this.activeModal,
3770
+ ...bufferState ? { bufferState } : {}
3736
3771
  };
3737
3772
  }
3738
3773
  const hasVisibleAssistantMessage = Array.isArray(result?.messages) && result.messages.some((message) => message?.role === "assistant" && typeof message?.content === "string" && message.content.trim());