@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.
@@ -94,6 +94,12 @@ export declare class ProviderCliAdapter implements CliAdapter {
94
94
  private accumulatedRawBuffer;
95
95
  /** Current visible terminal screen snapshot */
96
96
  private terminalScreen;
97
+ private static readonly MAX_RESPONSE_BUFFER;
98
+ private static readonly MAX_RECENT_OUTPUT_BUFFER;
99
+ private responseBufferDroppedChars;
100
+ private recentOutputDroppedChars;
101
+ private accumulatedBufferDroppedChars;
102
+ private accumulatedRawBufferDroppedChars;
97
103
  /** Max accumulated buffer size. Sized to comfortably hold a single long
98
104
  * Hermes turn (tool calls + reasoning + final bubble) without the
99
105
  * rolling window pushing the turn's ╭─ opening line out of view. */
@@ -111,6 +117,8 @@ export declare class ProviderCliAdapter implements CliAdapter {
111
117
  private readonly providerResolutionMeta;
112
118
  private static readonly FINISH_RETRY_DELAY_MS;
113
119
  private static readonly MAX_FINISH_RETRIES;
120
+ private getBufferState;
121
+ private recordBoundedAppendDrop;
114
122
  private buildCommittedMessagesActivitySignature;
115
123
  private syncMessageViews;
116
124
  getLastCommittedMessageActivityAt(): number;
@@ -22,6 +22,28 @@ export interface CliSessionStatus {
22
22
  } | null;
23
23
  errorMessage?: string;
24
24
  errorReason?: string;
25
+ bufferState?: {
26
+ responseBuffer?: {
27
+ truncated: boolean;
28
+ droppedChars: number;
29
+ maxChars: number;
30
+ };
31
+ recentOutputBuffer?: {
32
+ truncated: boolean;
33
+ droppedChars: number;
34
+ maxChars: number;
35
+ };
36
+ accumulatedBuffer?: {
37
+ truncated: boolean;
38
+ droppedChars: number;
39
+ maxChars: number;
40
+ };
41
+ accumulatedRawBuffer?: {
42
+ truncated: boolean;
43
+ droppedChars: number;
44
+ maxChars: number;
45
+ };
46
+ };
25
47
  }
26
48
  export interface ParsedSession {
27
49
  status: string;
package/dist/index.js CHANGED
@@ -2305,6 +2305,12 @@ var init_provider_cli_adapter = __esm({
2305
2305
  accumulatedRawBuffer = "";
2306
2306
  /** Current visible terminal screen snapshot */
2307
2307
  terminalScreen = new TerminalScreen(24, 80);
2308
+ static MAX_RESPONSE_BUFFER = 8e3;
2309
+ static MAX_RECENT_OUTPUT_BUFFER = 1e3;
2310
+ responseBufferDroppedChars = 0;
2311
+ recentOutputDroppedChars = 0;
2312
+ accumulatedBufferDroppedChars = 0;
2313
+ accumulatedRawBufferDroppedChars = 0;
2308
2314
  /** Max accumulated buffer size. Sized to comfortably hold a single long
2309
2315
  * Hermes turn (tool calls + reasoning + final bubble) without the
2310
2316
  * rolling window pushing the turn's ╭─ opening line out of view. */
@@ -2322,6 +2328,23 @@ var init_provider_cli_adapter = __esm({
2322
2328
  providerResolutionMeta;
2323
2329
  static FINISH_RETRY_DELAY_MS = 300;
2324
2330
  static MAX_FINISH_RETRIES = 2;
2331
+ getBufferState() {
2332
+ const build = (droppedChars, maxChars) => droppedChars > 0 ? { truncated: true, droppedChars, maxChars } : void 0;
2333
+ const responseBuffer = build(this.responseBufferDroppedChars, _ProviderCliAdapter.MAX_RESPONSE_BUFFER);
2334
+ const recentOutputBuffer = build(this.recentOutputDroppedChars, _ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
2335
+ const accumulatedBuffer = build(this.accumulatedBufferDroppedChars, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
2336
+ const accumulatedRawBuffer = build(this.accumulatedRawBufferDroppedChars, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
2337
+ if (!responseBuffer && !recentOutputBuffer && !accumulatedBuffer && !accumulatedRawBuffer) return void 0;
2338
+ return {
2339
+ ...responseBuffer ? { responseBuffer } : {},
2340
+ ...recentOutputBuffer ? { recentOutputBuffer } : {},
2341
+ ...accumulatedBuffer ? { accumulatedBuffer } : {},
2342
+ ...accumulatedRawBuffer ? { accumulatedRawBuffer } : {}
2343
+ };
2344
+ }
2345
+ recordBoundedAppendDrop(previousLength, appendedLength, nextLength) {
2346
+ return Math.max(0, previousLength + appendedLength - nextLength);
2347
+ }
2325
2348
  buildCommittedMessagesActivitySignature() {
2326
2349
  const last = this.committedMessages[this.committedMessages.length - 1];
2327
2350
  return [
@@ -2687,7 +2710,9 @@ var init_provider_cli_adapter = __esm({
2687
2710
  this.scheduleStartupSettleCheck();
2688
2711
  }
2689
2712
  if (this.isWaitingForResponse && cleanData) {
2690
- this.responseBuffer = appendBoundedText(this.responseBuffer, cleanData, 8e3);
2713
+ const previousResponseLen = this.responseBuffer.length;
2714
+ this.responseBuffer = appendBoundedText(this.responseBuffer, cleanData, _ProviderCliAdapter.MAX_RESPONSE_BUFFER);
2715
+ this.responseBufferDroppedChars += this.recordBoundedAppendDrop(previousResponseLen, cleanData.length, this.responseBuffer.length);
2691
2716
  }
2692
2717
  if (cleanData.trim()) {
2693
2718
  if (this.serverConn) {
@@ -2696,14 +2721,19 @@ var init_provider_cli_adapter = __esm({
2696
2721
  this.logBuffer.push({ message: cleanData.trim(), level: "info" });
2697
2722
  }
2698
2723
  }
2724
+ const prevRecentLen = this.recentOutputBuffer.length;
2699
2725
  const prevAccumulatedLen = this.accumulatedBuffer.length;
2700
2726
  const prevAccumulatedRawLen = this.accumulatedRawBuffer.length;
2701
- this.recentOutputBuffer = appendBoundedText(this.recentOutputBuffer, cleanData, 1e3);
2727
+ this.recentOutputBuffer = appendBoundedText(this.recentOutputBuffer, cleanData, _ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
2702
2728
  this.accumulatedBuffer = appendBoundedText(this.accumulatedBuffer, cleanData, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
2703
2729
  this.accumulatedRawBuffer = appendBoundedText(this.accumulatedRawBuffer, rawData, _ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
2730
+ const droppedRecent = this.recordBoundedAppendDrop(prevRecentLen, cleanData.length, this.recentOutputBuffer.length);
2731
+ const droppedClean = this.recordBoundedAppendDrop(prevAccumulatedLen, cleanData.length, this.accumulatedBuffer.length);
2732
+ const droppedRaw = this.recordBoundedAppendDrop(prevAccumulatedRawLen, rawData.length, this.accumulatedRawBuffer.length);
2733
+ this.recentOutputDroppedChars += droppedRecent;
2734
+ this.accumulatedBufferDroppedChars += droppedClean;
2735
+ this.accumulatedRawBufferDroppedChars += droppedRaw;
2704
2736
  if (this.currentTurnScope) {
2705
- const droppedClean = prevAccumulatedLen + cleanData.length - this.accumulatedBuffer.length;
2706
- const droppedRaw = prevAccumulatedRawLen + rawData.length - this.accumulatedRawBuffer.length;
2707
2737
  if (droppedClean > 0) {
2708
2738
  this.currentTurnScope.bufferStart = Math.max(0, this.currentTurnScope.bufferStart - droppedClean);
2709
2739
  }
@@ -3533,13 +3563,15 @@ var init_provider_cli_adapter = __esm({
3533
3563
  effectiveModal = parsedModal;
3534
3564
  }
3535
3565
  }
3566
+ const bufferState = this.getBufferState();
3536
3567
  return {
3537
3568
  status: effectiveStatus,
3538
3569
  messages: [...this.committedMessages],
3539
3570
  workingDir: this.workingDir,
3540
3571
  activeModal: effectiveModal,
3541
3572
  errorMessage: this.parseErrorMessage || void 0,
3542
- errorReason: this.parseErrorMessage ? "parse_error" : void 0
3573
+ errorReason: this.parseErrorMessage ? "parse_error" : void 0,
3574
+ ...bufferState ? { bufferState } : {}
3543
3575
  };
3544
3576
  }
3545
3577
  seedCommittedMessages(messages) {
@@ -3721,10 +3753,12 @@ var init_provider_cli_adapter = __esm({
3721
3753
  messages: hydratedMessages,
3722
3754
  activeModal: parsed.activeModal ?? this.activeModal,
3723
3755
  providerSessionId: typeof parsed.providerSessionId === "string" ? parsed.providerSessionId : void 0,
3756
+ ...this.getBufferState() ? { bufferState: this.getBufferState() } : {},
3724
3757
  ...this.providerOwnsTranscript() ? { transcriptAuthority: "provider", coverage: this.shouldUseFullProviderTranscriptContext() ? "full" : "tail" } : {}
3725
3758
  };
3726
3759
  } else {
3727
3760
  const messages = [...this.committedMessages];
3761
+ const bufferState = this.getBufferState();
3728
3762
  result = {
3729
3763
  id: "cli_session",
3730
3764
  status: this.currentStatus,
@@ -3735,7 +3769,8 @@ var init_provider_cli_adapter = __esm({
3735
3769
  index: typeof message.index === "number" ? message.index : index,
3736
3770
  receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
3737
3771
  })),
3738
- activeModal: this.activeModal
3772
+ activeModal: this.activeModal,
3773
+ ...bufferState ? { bufferState } : {}
3739
3774
  };
3740
3775
  }
3741
3776
  const hasVisibleAssistantMessage = Array.isArray(result?.messages) && result.messages.some((message) => message?.role === "assistant" && typeof message?.content === "string" && message.content.trim());