@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/cli-adapters/provider-cli-adapter.d.ts +8 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +22 -0
- package/dist/index.js +41 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -6
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +43 -4
- package/src/cli-adapters/provider-cli-shared.ts +6 -0
package/package.json
CHANGED
|
@@ -341,6 +341,12 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
341
341
|
private accumulatedRawBuffer: string = '';
|
|
342
342
|
/** Current visible terminal screen snapshot */
|
|
343
343
|
private terminalScreen = new TerminalScreen(24, 80);
|
|
344
|
+
private static readonly MAX_RESPONSE_BUFFER = 8000;
|
|
345
|
+
private static readonly MAX_RECENT_OUTPUT_BUFFER = 1000;
|
|
346
|
+
private responseBufferDroppedChars = 0;
|
|
347
|
+
private recentOutputDroppedChars = 0;
|
|
348
|
+
private accumulatedBufferDroppedChars = 0;
|
|
349
|
+
private accumulatedRawBufferDroppedChars = 0;
|
|
344
350
|
/** Max accumulated buffer size. Sized to comfortably hold a single long
|
|
345
351
|
* Hermes turn (tool calls + reasoning + final bubble) without the
|
|
346
352
|
* rolling window pushing the turn's ╭─ opening line out of view. */
|
|
@@ -371,6 +377,27 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
371
377
|
private static readonly FINISH_RETRY_DELAY_MS = 300;
|
|
372
378
|
private static readonly MAX_FINISH_RETRIES = 2;
|
|
373
379
|
|
|
380
|
+
private getBufferState(): NonNullable<CliSessionStatus['bufferState']> | undefined {
|
|
381
|
+
const build = (droppedChars: number, maxChars: number) => droppedChars > 0
|
|
382
|
+
? { truncated: true, droppedChars, maxChars }
|
|
383
|
+
: undefined;
|
|
384
|
+
const responseBuffer = build(this.responseBufferDroppedChars, ProviderCliAdapter.MAX_RESPONSE_BUFFER);
|
|
385
|
+
const recentOutputBuffer = build(this.recentOutputDroppedChars, ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
|
|
386
|
+
const accumulatedBuffer = build(this.accumulatedBufferDroppedChars, ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
|
|
387
|
+
const accumulatedRawBuffer = build(this.accumulatedRawBufferDroppedChars, ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
|
|
388
|
+
if (!responseBuffer && !recentOutputBuffer && !accumulatedBuffer && !accumulatedRawBuffer) return undefined;
|
|
389
|
+
return {
|
|
390
|
+
...(responseBuffer ? { responseBuffer } : {}),
|
|
391
|
+
...(recentOutputBuffer ? { recentOutputBuffer } : {}),
|
|
392
|
+
...(accumulatedBuffer ? { accumulatedBuffer } : {}),
|
|
393
|
+
...(accumulatedRawBuffer ? { accumulatedRawBuffer } : {}),
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
private recordBoundedAppendDrop(previousLength: number, appendedLength: number, nextLength: number): number {
|
|
398
|
+
return Math.max(0, (previousLength + appendedLength) - nextLength);
|
|
399
|
+
}
|
|
400
|
+
|
|
374
401
|
private buildCommittedMessagesActivitySignature(): string {
|
|
375
402
|
const last = this.committedMessages[this.committedMessages.length - 1];
|
|
376
403
|
return [
|
|
@@ -847,7 +874,9 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
847
874
|
}
|
|
848
875
|
|
|
849
876
|
if (this.isWaitingForResponse && cleanData) {
|
|
850
|
-
|
|
877
|
+
const previousResponseLen = this.responseBuffer.length;
|
|
878
|
+
this.responseBuffer = appendBoundedText(this.responseBuffer, cleanData, ProviderCliAdapter.MAX_RESPONSE_BUFFER);
|
|
879
|
+
this.responseBufferDroppedChars += this.recordBoundedAppendDrop(previousResponseLen, cleanData.length, this.responseBuffer.length);
|
|
851
880
|
}
|
|
852
881
|
|
|
853
882
|
// Server log forwarding
|
|
@@ -860,17 +889,22 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
860
889
|
}
|
|
861
890
|
|
|
862
891
|
// Rolling buffers
|
|
892
|
+
const prevRecentLen = this.recentOutputBuffer.length;
|
|
863
893
|
const prevAccumulatedLen = this.accumulatedBuffer.length;
|
|
864
894
|
const prevAccumulatedRawLen = this.accumulatedRawBuffer.length;
|
|
865
|
-
this.recentOutputBuffer = appendBoundedText(this.recentOutputBuffer, cleanData,
|
|
895
|
+
this.recentOutputBuffer = appendBoundedText(this.recentOutputBuffer, cleanData, ProviderCliAdapter.MAX_RECENT_OUTPUT_BUFFER);
|
|
866
896
|
this.accumulatedBuffer = appendBoundedText(this.accumulatedBuffer, cleanData, ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
|
|
867
897
|
this.accumulatedRawBuffer = appendBoundedText(this.accumulatedRawBuffer, rawData, ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
|
|
898
|
+
const droppedRecent = this.recordBoundedAppendDrop(prevRecentLen, cleanData.length, this.recentOutputBuffer.length);
|
|
899
|
+
const droppedClean = this.recordBoundedAppendDrop(prevAccumulatedLen, cleanData.length, this.accumulatedBuffer.length);
|
|
900
|
+
const droppedRaw = this.recordBoundedAppendDrop(prevAccumulatedRawLen, rawData.length, this.accumulatedRawBuffer.length);
|
|
901
|
+
this.recentOutputDroppedChars += droppedRecent;
|
|
902
|
+
this.accumulatedBufferDroppedChars += droppedClean;
|
|
903
|
+
this.accumulatedRawBufferDroppedChars += droppedRaw;
|
|
868
904
|
// Keep turn-scope offsets aligned with the truncated buffer so scoped
|
|
869
905
|
// parses don't lose the beginning of a long turn (e.g. the Hermes
|
|
870
906
|
// ╭─ opening line) when the rolling window sheds bytes.
|
|
871
907
|
if (this.currentTurnScope) {
|
|
872
|
-
const droppedClean = (prevAccumulatedLen + cleanData.length) - this.accumulatedBuffer.length;
|
|
873
|
-
const droppedRaw = (prevAccumulatedRawLen + rawData.length) - this.accumulatedRawBuffer.length;
|
|
874
908
|
if (droppedClean > 0) {
|
|
875
909
|
this.currentTurnScope.bufferStart = Math.max(0, this.currentTurnScope.bufferStart - droppedClean);
|
|
876
910
|
}
|
|
@@ -1805,6 +1839,7 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
1805
1839
|
effectiveModal = parsedModal;
|
|
1806
1840
|
}
|
|
1807
1841
|
}
|
|
1842
|
+
const bufferState = this.getBufferState();
|
|
1808
1843
|
return {
|
|
1809
1844
|
status: effectiveStatus,
|
|
1810
1845
|
messages: [...this.committedMessages],
|
|
@@ -1812,6 +1847,7 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
1812
1847
|
activeModal: effectiveModal,
|
|
1813
1848
|
errorMessage: this.parseErrorMessage || undefined,
|
|
1814
1849
|
errorReason: this.parseErrorMessage ? 'parse_error' : undefined,
|
|
1850
|
+
...(bufferState ? { bufferState } : {}),
|
|
1815
1851
|
};
|
|
1816
1852
|
}
|
|
1817
1853
|
|
|
@@ -2056,10 +2092,12 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
2056
2092
|
messages: hydratedMessages,
|
|
2057
2093
|
activeModal: parsed.activeModal ?? this.activeModal,
|
|
2058
2094
|
providerSessionId: typeof parsed.providerSessionId === 'string' ? parsed.providerSessionId : undefined,
|
|
2095
|
+
...(this.getBufferState() ? { bufferState: this.getBufferState() } : {}),
|
|
2059
2096
|
...(this.providerOwnsTranscript() ? { transcriptAuthority: 'provider', coverage: this.shouldUseFullProviderTranscriptContext() ? 'full' : 'tail' } : {}),
|
|
2060
2097
|
};
|
|
2061
2098
|
} else {
|
|
2062
2099
|
const messages = [...this.committedMessages];
|
|
2100
|
+
const bufferState = this.getBufferState();
|
|
2063
2101
|
result = {
|
|
2064
2102
|
id: 'cli_session',
|
|
2065
2103
|
status: this.currentStatus,
|
|
@@ -2073,6 +2111,7 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
2073
2111
|
: message.timestamp,
|
|
2074
2112
|
})),
|
|
2075
2113
|
activeModal: this.activeModal,
|
|
2114
|
+
...(bufferState ? { bufferState } : {}),
|
|
2076
2115
|
};
|
|
2077
2116
|
}
|
|
2078
2117
|
|
|
@@ -24,6 +24,12 @@ export interface CliSessionStatus {
|
|
|
24
24
|
activeModal: { message: string; buttons: string[] } | null;
|
|
25
25
|
errorMessage?: string;
|
|
26
26
|
errorReason?: string;
|
|
27
|
+
bufferState?: {
|
|
28
|
+
responseBuffer?: { truncated: boolean; droppedChars: number; maxChars: number };
|
|
29
|
+
recentOutputBuffer?: { truncated: boolean; droppedChars: number; maxChars: number };
|
|
30
|
+
accumulatedBuffer?: { truncated: boolean; droppedChars: number; maxChars: number };
|
|
31
|
+
accumulatedRawBuffer?: { truncated: boolean; droppedChars: number; maxChars: number };
|
|
32
|
+
};
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
export interface ParsedSession {
|