@vybestack/llxprt-code-agents 0.10.0-nightly.260613.1adad3b34
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/.last_build +0 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/src/agents/executor-prompt-builder.d.ts +19 -0
- package/dist/src/agents/executor-prompt-builder.js +44 -0
- package/dist/src/agents/executor-prompt-builder.js.map +1 -0
- package/dist/src/agents/executor-termination.d.ts +22 -0
- package/dist/src/agents/executor-termination.js +44 -0
- package/dist/src/agents/executor-termination.js.map +1 -0
- package/dist/src/agents/executor-validation.d.ts +17 -0
- package/dist/src/agents/executor-validation.js +35 -0
- package/dist/src/agents/executor-validation.js.map +1 -0
- package/dist/src/agents/executor.d.ts +136 -0
- package/dist/src/agents/executor.js +874 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +45 -0
- package/dist/src/agents/invocation.js +118 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/recovery.d.ts +75 -0
- package/dist/src/agents/recovery.js +107 -0
- package/dist/src/agents/recovery.js.map +1 -0
- package/dist/src/agents/types.d.ts +149 -0
- package/dist/src/agents/types.js +18 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +15 -0
- package/dist/src/agents/utils.js +28 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/compression/CompressionHandler.d.ts +178 -0
- package/dist/src/compression/CompressionHandler.js +630 -0
- package/dist/src/compression/CompressionHandler.js.map +1 -0
- package/dist/src/compression/HighDensityStrategy.d.ts +113 -0
- package/dist/src/compression/HighDensityStrategy.js +769 -0
- package/dist/src/compression/HighDensityStrategy.js.map +1 -0
- package/dist/src/compression/MiddleOutStrategy.d.ts +27 -0
- package/dist/src/compression/MiddleOutStrategy.js +347 -0
- package/dist/src/compression/MiddleOutStrategy.js.map +1 -0
- package/dist/src/compression/OneShotStrategy.d.ts +22 -0
- package/dist/src/compression/OneShotStrategy.js +235 -0
- package/dist/src/compression/OneShotStrategy.js.map +1 -0
- package/dist/src/compression/TopDownTruncationStrategy.d.ts +13 -0
- package/dist/src/compression/TopDownTruncationStrategy.js +74 -0
- package/dist/src/compression/TopDownTruncationStrategy.js.map +1 -0
- package/dist/src/compression/compressionBudgeting.d.ts +34 -0
- package/dist/src/compression/compressionBudgeting.js +139 -0
- package/dist/src/compression/compressionBudgeting.js.map +1 -0
- package/dist/src/compression/compressionStrategyFactory.d.ts +23 -0
- package/dist/src/compression/compressionStrategyFactory.js +40 -0
- package/dist/src/compression/compressionStrategyFactory.js.map +1 -0
- package/dist/src/compression/index.d.ts +16 -0
- package/dist/src/compression/index.js +17 -0
- package/dist/src/compression/index.js.map +1 -0
- package/dist/src/compression/reasoningUtils.d.ts +18 -0
- package/dist/src/compression/reasoningUtils.js +22 -0
- package/dist/src/compression/reasoningUtils.js.map +1 -0
- package/dist/src/compression/utils.d.ts +114 -0
- package/dist/src/compression/utils.js +316 -0
- package/dist/src/compression/utils.js.map +1 -0
- package/dist/src/core/AgentHookManager.d.ts +41 -0
- package/dist/src/core/AgentHookManager.js +65 -0
- package/dist/src/core/AgentHookManager.js.map +1 -0
- package/dist/src/core/ChatSessionFactory.d.ts +50 -0
- package/dist/src/core/ChatSessionFactory.js +216 -0
- package/dist/src/core/ChatSessionFactory.js.map +1 -0
- package/dist/src/core/ConversationManager.d.ts +113 -0
- package/dist/src/core/ConversationManager.js +311 -0
- package/dist/src/core/ConversationManager.js.map +1 -0
- package/dist/src/core/DirectMessageProcessor.d.ts +79 -0
- package/dist/src/core/DirectMessageProcessor.js +478 -0
- package/dist/src/core/DirectMessageProcessor.js.map +1 -0
- package/dist/src/core/IdeContextTracker.d.ts +56 -0
- package/dist/src/core/IdeContextTracker.js +207 -0
- package/dist/src/core/IdeContextTracker.js.map +1 -0
- package/dist/src/core/MessageConverter.d.ts +78 -0
- package/dist/src/core/MessageConverter.js +492 -0
- package/dist/src/core/MessageConverter.js.map +1 -0
- package/dist/src/core/MessageStreamOrchestrator.d.ts +85 -0
- package/dist/src/core/MessageStreamOrchestrator.js +448 -0
- package/dist/src/core/MessageStreamOrchestrator.js.map +1 -0
- package/dist/src/core/MessageStreamTerminalHandler.d.ts +16 -0
- package/dist/src/core/MessageStreamTerminalHandler.js +170 -0
- package/dist/src/core/MessageStreamTerminalHandler.js.map +1 -0
- package/dist/src/core/StreamProcessor.d.ts +105 -0
- package/dist/src/core/StreamProcessor.js +660 -0
- package/dist/src/core/StreamProcessor.js.map +1 -0
- package/dist/src/core/TodoContinuationService.d.ts +74 -0
- package/dist/src/core/TodoContinuationService.js +312 -0
- package/dist/src/core/TodoContinuationService.js.map +1 -0
- package/dist/src/core/TurnProcessor.d.ts +91 -0
- package/dist/src/core/TurnProcessor.js +540 -0
- package/dist/src/core/TurnProcessor.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +115 -0
- package/dist/src/core/baseLlmClient.js +231 -0
- package/dist/src/core/baseLlmClient.js.map +1 -0
- package/dist/src/core/bucketFailoverIntegration.d.ts +62 -0
- package/dist/src/core/bucketFailoverIntegration.js +186 -0
- package/dist/src/core/bucketFailoverIntegration.js.map +1 -0
- package/dist/src/core/chatSession.d.ts +121 -0
- package/dist/src/core/chatSession.js +720 -0
- package/dist/src/core/chatSession.js.map +1 -0
- package/dist/src/core/client.d.ts +132 -0
- package/dist/src/core/client.js +524 -0
- package/dist/src/core/client.js.map +1 -0
- package/dist/src/core/clientHelpers.d.ts +15 -0
- package/dist/src/core/clientHelpers.js +122 -0
- package/dist/src/core/clientHelpers.js.map +1 -0
- package/dist/src/core/clientLlmUtilities.d.ts +30 -0
- package/dist/src/core/clientLlmUtilities.js +125 -0
- package/dist/src/core/clientLlmUtilities.js.map +1 -0
- package/dist/src/core/clientToolGovernance.d.ts +37 -0
- package/dist/src/core/clientToolGovernance.js +104 -0
- package/dist/src/core/clientToolGovernance.js.map +1 -0
- package/dist/src/core/compression-config.d.ts +12 -0
- package/dist/src/core/compression-config.js +21 -0
- package/dist/src/core/compression-config.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +105 -0
- package/dist/src/core/coreToolScheduler.js +453 -0
- package/dist/src/core/coreToolScheduler.js.map +1 -0
- package/dist/src/core/hookToolRestrictions.d.ts +18 -0
- package/dist/src/core/hookToolRestrictions.js +187 -0
- package/dist/src/core/hookToolRestrictions.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +17 -0
- package/dist/src/core/nonInteractiveToolExecutor.js +102 -0
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -0
- package/dist/src/core/subagent.d.ts +105 -0
- package/dist/src/core/subagent.js +650 -0
- package/dist/src/core/subagent.js.map +1 -0
- package/dist/src/core/subagentExecution.d.ts +104 -0
- package/dist/src/core/subagentExecution.js +275 -0
- package/dist/src/core/subagentExecution.js.map +1 -0
- package/dist/src/core/subagentOrchestrator.d.ts +84 -0
- package/dist/src/core/subagentOrchestrator.js +503 -0
- package/dist/src/core/subagentOrchestrator.js.map +1 -0
- package/dist/src/core/subagentRuntimeSetup.d.ts +75 -0
- package/dist/src/core/subagentRuntimeSetup.js +387 -0
- package/dist/src/core/subagentRuntimeSetup.js.map +1 -0
- package/dist/src/core/subagentScheduler.d.ts +17 -0
- package/dist/src/core/subagentScheduler.js +7 -0
- package/dist/src/core/subagentScheduler.js.map +1 -0
- package/dist/src/core/subagentToolProcessing.d.ts +51 -0
- package/dist/src/core/subagentToolProcessing.js +359 -0
- package/dist/src/core/subagentToolProcessing.js.map +1 -0
- package/dist/src/core/toolGovernance.d.ts +18 -0
- package/dist/src/core/toolGovernance.js +50 -0
- package/dist/src/core/toolGovernance.js.map +1 -0
- package/dist/src/core/turn.d.ts +47 -0
- package/dist/src/core/turn.js +455 -0
- package/dist/src/core/turn.js.map +1 -0
- package/dist/src/core/turnLogging.d.ts +35 -0
- package/dist/src/core/turnLogging.js +80 -0
- package/dist/src/core/turnLogging.js.map +1 -0
- package/dist/src/index.d.ts +32 -0
- package/dist/src/index.js +44 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/scheduler/confirmation-coordinator.d.ts +139 -0
- package/dist/src/scheduler/confirmation-coordinator.js +443 -0
- package/dist/src/scheduler/confirmation-coordinator.js.map +1 -0
- package/dist/src/scheduler/result-aggregator.d.ts +127 -0
- package/dist/src/scheduler/result-aggregator.js +302 -0
- package/dist/src/scheduler/result-aggregator.js.map +1 -0
- package/dist/src/scheduler/status-transitions.d.ts +39 -0
- package/dist/src/scheduler/status-transitions.js +184 -0
- package/dist/src/scheduler/status-transitions.js.map +1 -0
- package/dist/src/scheduler/tool-dispatcher.d.ts +40 -0
- package/dist/src/scheduler/tool-dispatcher.js +120 -0
- package/dist/src/scheduler/tool-dispatcher.js.map +1 -0
- package/dist/src/scheduler/tool-executor.d.ts +44 -0
- package/dist/src/scheduler/tool-executor.js +117 -0
- package/dist/src/scheduler/tool-executor.js.map +1 -0
- package/dist/src/scheduler/utils.d.ts +11 -0
- package/dist/src/scheduler/utils.js +19 -0
- package/dist/src/scheduler/utils.js.map +1 -0
- package/dist/src/tools/task.d.ts +128 -0
- package/dist/src/tools/task.js +932 -0
- package/dist/src/tools/task.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @plan PLAN-20260211-HIGHDENSITY.P03
|
|
8
|
+
* @plan PLAN-20260211-HIGHDENSITY.P05
|
|
9
|
+
* @requirement REQ-HD-001.3
|
|
10
|
+
* @pseudocode strategy-interface.md lines 90-94
|
|
11
|
+
*
|
|
12
|
+
* One-shot compression strategy: summarizes the entire history except
|
|
13
|
+
* the last N messages in a single LLM call. The preserved tail is
|
|
14
|
+
* determined by the preserveThreshold ephemeral setting.
|
|
15
|
+
*
|
|
16
|
+
* Unlike middle-out (which preserves both top and bottom), one-shot
|
|
17
|
+
* preserves ONLY the recent tail. The summary replaces everything
|
|
18
|
+
* above the preserved messages.
|
|
19
|
+
*/
|
|
20
|
+
import { readFileSync } from 'node:fs';
|
|
21
|
+
import { CompressionExecutionError, EmptySummaryError, PromptResolutionError, isTransientCompressionError, } from '@vybestack/llxprt-code-core/core/compression/types.js';
|
|
22
|
+
import { adjustForToolCallBoundary, aggregateTextFromBlocks, buildTriggerInstruction, COMPRESSION_SECURITY_PREAMBLE, runVerificationPass, sanitizeHistoryForCompression, } from './utils.js';
|
|
23
|
+
import { getCompressionPrompt } from '@vybestack/llxprt-code-core/core/prompts.js';
|
|
24
|
+
import { buildContinuationDirective } from '@vybestack/llxprt-code-core/core/compression/continuationDirective.js';
|
|
25
|
+
function destructureProviderResult(result) {
|
|
26
|
+
return {
|
|
27
|
+
provider: result.provider,
|
|
28
|
+
resolvedRuntime: result.runtime,
|
|
29
|
+
resolvedConfig: result.config,
|
|
30
|
+
resolvedOptions: result.resolved,
|
|
31
|
+
invocation: result.invocation,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const MINIMUM_COMPRESS_MESSAGES = 4;
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// OneShotStrategy
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
export class OneShotStrategy {
|
|
39
|
+
name = 'one-shot';
|
|
40
|
+
requiresLLM = true;
|
|
41
|
+
/** @plan PLAN-20260211-HIGHDENSITY.P03 @requirement REQ-HD-001.3 */
|
|
42
|
+
trigger = {
|
|
43
|
+
mode: 'threshold',
|
|
44
|
+
defaultThreshold: 0.85,
|
|
45
|
+
};
|
|
46
|
+
// eslint-disable-next-line max-lines-per-function -- Strategy orchestration remains linear for readability.
|
|
47
|
+
async compress(context) {
|
|
48
|
+
const { history } = context;
|
|
49
|
+
if (history.length === 0) {
|
|
50
|
+
return this.noCompressionResult(history);
|
|
51
|
+
}
|
|
52
|
+
// Compute the split: everything above the preserved tail gets compressed
|
|
53
|
+
const { toCompress, toKeep } = this.computeSplit(context);
|
|
54
|
+
if (toCompress.length < MINIMUM_COMPRESS_MESSAGES) {
|
|
55
|
+
return this.noCompressionResult(history);
|
|
56
|
+
}
|
|
57
|
+
// Resolve the compression prompt
|
|
58
|
+
const prompt = this.resolvePrompt(context);
|
|
59
|
+
// Resolve the provider (compression profile may be undefined)
|
|
60
|
+
const compressionProfile = context.runtimeContext.ephemerals.compressionProfile();
|
|
61
|
+
const { provider, resolvedRuntime, resolvedConfig, resolvedOptions, invocation, } = destructureProviderResult(await context.resolveProvider(compressionProfile));
|
|
62
|
+
// Build the LLM request
|
|
63
|
+
// @plan PLAN-20260211-HIGHDENSITY.P23
|
|
64
|
+
// @requirement REQ-HD-011.3, REQ-HD-012.2
|
|
65
|
+
const triggerInstruction = buildTriggerInstruction(toCompress);
|
|
66
|
+
const compressionRequest = [
|
|
67
|
+
COMPRESSION_SECURITY_PREAMBLE,
|
|
68
|
+
{
|
|
69
|
+
speaker: 'human',
|
|
70
|
+
blocks: [{ type: 'text', text: prompt }],
|
|
71
|
+
},
|
|
72
|
+
...sanitizeHistoryForCompression(toCompress),
|
|
73
|
+
...this.buildContextInjections(context),
|
|
74
|
+
{
|
|
75
|
+
speaker: 'human',
|
|
76
|
+
blocks: [{ type: 'text', text: triggerInstruction }],
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
// Call the provider and aggregate the streamed response
|
|
80
|
+
const { text: summary, usage: capturedUsage } = await this.callProvider(provider, compressionRequest, context, resolvedRuntime, resolvedConfig, resolvedOptions, invocation);
|
|
81
|
+
if (!summary.trim()) {
|
|
82
|
+
throw new EmptySummaryError('one-shot');
|
|
83
|
+
}
|
|
84
|
+
// Optional verification pass — gated by compressionVerification flag (default off)
|
|
85
|
+
let finalSummary = summary;
|
|
86
|
+
if (context.compressionVerification === true) {
|
|
87
|
+
finalSummary = await runVerificationPass(provider, summary, context, resolvedRuntime, resolvedConfig, resolvedOptions, invocation);
|
|
88
|
+
}
|
|
89
|
+
// Assemble result: summary + continuation directive + preserved tail
|
|
90
|
+
const summaryEntry = {
|
|
91
|
+
speaker: 'human',
|
|
92
|
+
blocks: [{ type: 'text', text: finalSummary }],
|
|
93
|
+
...(capturedUsage ? { metadata: { usage: capturedUsage } } : {}),
|
|
94
|
+
};
|
|
95
|
+
const newHistory = [
|
|
96
|
+
summaryEntry,
|
|
97
|
+
{
|
|
98
|
+
speaker: 'ai',
|
|
99
|
+
blocks: [
|
|
100
|
+
{
|
|
101
|
+
type: 'text',
|
|
102
|
+
text: buildContinuationDirective(context.activeTodos),
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
...toKeep,
|
|
107
|
+
];
|
|
108
|
+
const metadata = {
|
|
109
|
+
originalMessageCount: history.length,
|
|
110
|
+
compressedMessageCount: newHistory.length,
|
|
111
|
+
strategyUsed: 'one-shot',
|
|
112
|
+
llmCallMade: true,
|
|
113
|
+
topPreserved: 0,
|
|
114
|
+
bottomPreserved: toKeep.length,
|
|
115
|
+
middleCompressed: toCompress.length,
|
|
116
|
+
...(capturedUsage ? { usage: capturedUsage } : {}),
|
|
117
|
+
};
|
|
118
|
+
return { newHistory, metadata };
|
|
119
|
+
}
|
|
120
|
+
// -------------------------------------------------------------------------
|
|
121
|
+
// Private helpers
|
|
122
|
+
// -------------------------------------------------------------------------
|
|
123
|
+
computeSplit(context) {
|
|
124
|
+
const history = context.history;
|
|
125
|
+
const preserveThreshold = context.runtimeContext.ephemerals.preserveThreshold();
|
|
126
|
+
let splitIndex = Math.floor(history.length * (1 - preserveThreshold));
|
|
127
|
+
if (splitIndex < MINIMUM_COMPRESS_MESSAGES) {
|
|
128
|
+
return { toCompress: [], toKeep: [...history] };
|
|
129
|
+
}
|
|
130
|
+
splitIndex = adjustForToolCallBoundary(history, splitIndex);
|
|
131
|
+
if (splitIndex < MINIMUM_COMPRESS_MESSAGES) {
|
|
132
|
+
return { toCompress: [], toKeep: [...history] };
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
toCompress: history.slice(0, splitIndex),
|
|
136
|
+
toKeep: history.slice(splitIndex),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
resolvePrompt(context) {
|
|
140
|
+
const resolved = context.promptResolver.resolveFile(context.promptBaseDir, 'compression.md', context.promptContext);
|
|
141
|
+
if (resolved.found && resolved.path) {
|
|
142
|
+
try {
|
|
143
|
+
return readFileSync(resolved.path, 'utf-8');
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
// Fall through to hardcoded default
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const fallback = getCompressionPrompt();
|
|
150
|
+
if (!fallback) {
|
|
151
|
+
throw new PromptResolutionError('compression.md');
|
|
152
|
+
}
|
|
153
|
+
return fallback;
|
|
154
|
+
}
|
|
155
|
+
async callProvider(provider, request, context, resolvedRuntime, resolvedConfig, resolvedOptions, invocation) {
|
|
156
|
+
const providerRuntime = resolvedRuntime;
|
|
157
|
+
try {
|
|
158
|
+
const stream = provider.generateChatCompletion({
|
|
159
|
+
contents: request,
|
|
160
|
+
tools: undefined,
|
|
161
|
+
config: resolvedConfig ?? context.config ?? providerRuntime.config,
|
|
162
|
+
runtime: providerRuntime,
|
|
163
|
+
invocation,
|
|
164
|
+
settings: providerRuntime.settingsService,
|
|
165
|
+
resolved: resolvedOptions,
|
|
166
|
+
metadata: {
|
|
167
|
+
...(providerRuntime.metadata ?? {}),
|
|
168
|
+
source: 'OneShotStrategy.callProvider',
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
let summary = '';
|
|
172
|
+
let lastBlockWasNonText = false;
|
|
173
|
+
let capturedUsage;
|
|
174
|
+
for await (const chunk of stream) {
|
|
175
|
+
const result = aggregateTextFromBlocks(chunk.blocks, summary, lastBlockWasNonText);
|
|
176
|
+
summary = result.text;
|
|
177
|
+
lastBlockWasNonText = result.lastBlockWasNonText;
|
|
178
|
+
if (chunk.metadata?.usage) {
|
|
179
|
+
capturedUsage = chunk.metadata.usage;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return { text: summary, usage: capturedUsage };
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
throw new CompressionExecutionError('one-shot', `LLM provider call failed: ${error instanceof Error ? error.message : String(error)}`, { isTransient: isTransientCompressionError(error) });
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
noCompressionResult(history) {
|
|
189
|
+
return {
|
|
190
|
+
newHistory: [...history],
|
|
191
|
+
metadata: {
|
|
192
|
+
originalMessageCount: history.length,
|
|
193
|
+
compressedMessageCount: history.length,
|
|
194
|
+
strategyUsed: 'one-shot',
|
|
195
|
+
llmCallMade: false,
|
|
196
|
+
topPreserved: 0,
|
|
197
|
+
bottomPreserved: 0,
|
|
198
|
+
middleCompressed: 0,
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* @plan PLAN-20260211-HIGHDENSITY.P23
|
|
204
|
+
* @requirement REQ-HD-011.3, REQ-HD-012.2
|
|
205
|
+
*/
|
|
206
|
+
buildContextInjections(context) {
|
|
207
|
+
const injections = [];
|
|
208
|
+
if (context.activeTodos && context.activeTodos.trim().length > 0) {
|
|
209
|
+
injections.push({
|
|
210
|
+
speaker: 'human',
|
|
211
|
+
blocks: [
|
|
212
|
+
{
|
|
213
|
+
type: 'text',
|
|
214
|
+
text: `The following are the current active todo/task items. When summarizing, preserve context about why each task exists and what has been tried:
|
|
215
|
+
|
|
216
|
+
${context.activeTodos}`,
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
if (context.transcriptPath) {
|
|
222
|
+
injections.push({
|
|
223
|
+
speaker: 'human',
|
|
224
|
+
blocks: [
|
|
225
|
+
{
|
|
226
|
+
type: 'text',
|
|
227
|
+
text: `Note: The full pre-compression transcript is available at: ${context.transcriptPath}`,
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return injections;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=OneShotStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OneShotStrategy.js","sourceRoot":"","sources":["../../../src/compression/OneShotStrategy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAiBvC,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,6BAA6B,GAC9B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,uEAAuE,CAAC;AACnH,SAAS,yBAAyB,CAAC,MAAiC;IAOlE,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,eAAe,EAAE,MAAM,CAAC,OAAO;QAC/B,cAAc,EAAE,MAAM,CAAC,MAAM;QAC7B,eAAe,EAAE,MAAM,CAAC,QAAQ;QAChC,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC;AACJ,CAAC;AAED,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAEpC,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E,MAAM,OAAO,eAAe;IACjB,IAAI,GAAG,UAAmB,CAAC;IAC3B,WAAW,GAAG,IAAI,CAAC;IAC5B,oEAAoE;IAC3D,OAAO,GAAoB;QAClC,IAAI,EAAE,WAAW;QACjB,gBAAgB,EA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AI,CAAC;gBACd,OAAO,EAAE,OAAO;gBAChB,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;EAEhB,OAAO,CAAC,WAAW,EAAE;qBACZ;iBACF;aACF,CAAC,CAAC;QACL,CAAC;QAED,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,UAAU,CAAC,IAAI,CAAC;gBACd,OAAO,EAAE,OAAO;gBAChB,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,8DAA8D,OAAO,CAAC,cAAc,EAAE;qBAC7F;iBACF;aACF,CAAC,CAAC;QACL,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { CompressionContext, CompressionResult, CompressionStrategy, StrategyTrigger } from '@vybestack/llxprt-code-core/core/compression/types.js';
|
|
7
|
+
export declare class TopDownTruncationStrategy implements CompressionStrategy {
|
|
8
|
+
readonly name: "top-down-truncation";
|
|
9
|
+
readonly requiresLLM = false;
|
|
10
|
+
/** @plan PLAN-20260211-HIGHDENSITY.P03 @requirement REQ-HD-001.3 */
|
|
11
|
+
readonly trigger: StrategyTrigger;
|
|
12
|
+
compress(context: CompressionContext): Promise<CompressionResult>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { adjustForToolCallBoundary } from './utils.js';
|
|
7
|
+
export class TopDownTruncationStrategy {
|
|
8
|
+
name = 'top-down-truncation';
|
|
9
|
+
requiresLLM = false;
|
|
10
|
+
/** @plan PLAN-20260211-HIGHDENSITY.P03 @requirement REQ-HD-001.3 */
|
|
11
|
+
trigger = {
|
|
12
|
+
mode: 'threshold',
|
|
13
|
+
defaultThreshold: 0.85,
|
|
14
|
+
};
|
|
15
|
+
async compress(context) {
|
|
16
|
+
const { history, runtimeContext, estimateTokens, currentTokenCount } = context;
|
|
17
|
+
const originalCount = history.length;
|
|
18
|
+
if (originalCount === 0) {
|
|
19
|
+
return {
|
|
20
|
+
newHistory: [],
|
|
21
|
+
metadata: {
|
|
22
|
+
originalMessageCount: 0,
|
|
23
|
+
compressedMessageCount: 0,
|
|
24
|
+
strategyUsed: 'top-down-truncation',
|
|
25
|
+
llmCallMade: false,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const compressionThreshold = runtimeContext.ephemerals.compressionThreshold();
|
|
30
|
+
const contextLimit = runtimeContext.ephemerals.contextLimit();
|
|
31
|
+
const target = compressionThreshold * contextLimit * 0.6;
|
|
32
|
+
if (currentTokenCount <= target) {
|
|
33
|
+
return {
|
|
34
|
+
newHistory: [...history],
|
|
35
|
+
metadata: {
|
|
36
|
+
originalMessageCount: originalCount,
|
|
37
|
+
compressedMessageCount: originalCount,
|
|
38
|
+
strategyUsed: 'top-down-truncation',
|
|
39
|
+
llmCallMade: false,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const minKeep = Math.min(2, originalCount);
|
|
44
|
+
// Remove messages from start (oldest first) until under target
|
|
45
|
+
let removeCount = 0;
|
|
46
|
+
for (let i = 1; i <= originalCount - minKeep; i++) {
|
|
47
|
+
const remaining = history.slice(i);
|
|
48
|
+
const tokens = await estimateTokens(remaining);
|
|
49
|
+
if (tokens < target) {
|
|
50
|
+
removeCount = i;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
removeCount = i;
|
|
54
|
+
}
|
|
55
|
+
// Ensure we keep at least minKeep messages
|
|
56
|
+
removeCount = Math.min(removeCount, originalCount - minKeep);
|
|
57
|
+
// Adjust boundary to avoid orphaning tool call/response pairs
|
|
58
|
+
const mutableHistory = [...history];
|
|
59
|
+
const adjustedIndex = adjustForToolCallBoundary(mutableHistory, removeCount);
|
|
60
|
+
// Clamp: never remove more than originalCount - minKeep
|
|
61
|
+
const finalRemoveCount = Math.min(adjustedIndex, originalCount - minKeep);
|
|
62
|
+
const newHistory = mutableHistory.slice(finalRemoveCount);
|
|
63
|
+
return {
|
|
64
|
+
newHistory,
|
|
65
|
+
metadata: {
|
|
66
|
+
originalMessageCount: originalCount,
|
|
67
|
+
compressedMessageCount: newHistory.length,
|
|
68
|
+
strategyUsed: 'top-down-truncation',
|
|
69
|
+
llmCallMade: false,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=TopDownTruncationStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopDownTruncationStrategy.js","sourceRoot":"","sources":["../../../src/compression/TopDownTruncationStrategy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,OAAO,yBAAyB;IAC3B,IAAI,GAAG,qBAA8B,CAAC;IACtC,WAAW,GAAG,KAAK,CAAC;IAC7B,oEAAoE;IAC3D,OAAO,GAAoB;QAClC,IAAI,EAAE,WAAW;QACjB,gBAAgB,EAAE,IAAI;KACvB,CAAC;IAEF,KAAK,CAAC,QAAQ,CAAC,OAA2B;QACxC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,GAClE,OAAO,CAAC;QACV,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;QAErC,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO;gBACL,UAAU,EAAE,EAAE;gBACd,QAAQ,EAAE;oBACR,oBAAoB,EAAE,CAAC;oBACvB,sBAAsB,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aAAa,GAAG,yBAAyB,CAC7C,cAAc,EACd,WAAW,CACZ,CAAC;QAEF,wDAAwD;QACxD,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC;QAE1E,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAE1D,OAAO;YACL,UAAU;YACV,QAAQ,EAAE;gBACR,oBAAoB,EAAE,aAAa;gBACnC,sBAAsB,EAAE,UAAU,CAAC,MAAM;gBACzC,YAAY,EAAE,qBAAqB;gBACnC,WAAW,EAAE,KAAK;aACnB;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { IContent } from '@vybestack/llxprt-code-core/services/history/IContent.js';
|
|
7
|
+
import type { HistoryService } from '@vybestack/llxprt-code-core/services/history/HistoryService.js';
|
|
8
|
+
import type { GenerateContentConfig } from '@google/genai';
|
|
9
|
+
import type { RuntimeProvider as IProvider } from '@vybestack/llxprt-code-core/runtime/contracts/RuntimeProvider.js';
|
|
10
|
+
/**
|
|
11
|
+
* Extract a number from various value types (number, string, etc.)
|
|
12
|
+
* @plan PLAN-20260220-DECOMPOSE.P03
|
|
13
|
+
*/
|
|
14
|
+
export declare function asNumber(value: unknown): number | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Extract completion budget from generation config parameters.
|
|
17
|
+
* Checks multiple possible parameter names for output token limits.
|
|
18
|
+
* @plan PLAN-20260220-DECOMPOSE.P03
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractCompletionBudgetFromParams(params: Record<string, unknown> | undefined): number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Get completion budget from generation config, provider params, or default.
|
|
23
|
+
* Used to reserve output tokens when calculating context limits.
|
|
24
|
+
* @plan PLAN-20260220-DECOMPOSE.P03
|
|
25
|
+
*/
|
|
26
|
+
export declare function getCompletionBudget(generationConfig: GenerateContentConfig, _model: string, provider?: IProvider, settingsService?: {
|
|
27
|
+
get: (key: string) => unknown;
|
|
28
|
+
}): number;
|
|
29
|
+
/**
|
|
30
|
+
* Estimate token count for pending content that hasn't been added to history yet.
|
|
31
|
+
* Uses historyService tokenizer when available, falls back to text-based estimation.
|
|
32
|
+
* @plan PLAN-20260220-DECOMPOSE.P03
|
|
33
|
+
*/
|
|
34
|
+
export declare function estimatePendingTokens(contents: IContent[], historyService: HistoryService, model: string): Promise<number>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { estimateTokens as estimateTextTokens } from '@vybestack/llxprt-code-core/utils/toolOutputLimiter.js';
|
|
7
|
+
import { DebugLogger } from '@vybestack/llxprt-code-core/debug/index.js';
|
|
8
|
+
const logger = new DebugLogger('llxprt:gemini:compression-budgeting');
|
|
9
|
+
/**
|
|
10
|
+
* Extract a number from various value types (number, string, etc.)
|
|
11
|
+
* @plan PLAN-20260220-DECOMPOSE.P03
|
|
12
|
+
*/
|
|
13
|
+
export function asNumber(value) {
|
|
14
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value === 'string') {
|
|
18
|
+
const parsed = Number(value);
|
|
19
|
+
if (Number.isFinite(parsed)) {
|
|
20
|
+
return parsed;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Extract completion budget from generation config parameters.
|
|
27
|
+
* Checks multiple possible parameter names for output token limits.
|
|
28
|
+
* @plan PLAN-20260220-DECOMPOSE.P03
|
|
29
|
+
*/
|
|
30
|
+
export function extractCompletionBudgetFromParams(params) {
|
|
31
|
+
if (!params) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const candidateKeys = [
|
|
35
|
+
'maxOutputTokens',
|
|
36
|
+
'maxTokens',
|
|
37
|
+
'max_output_tokens',
|
|
38
|
+
'max_tokens',
|
|
39
|
+
];
|
|
40
|
+
for (const key of candidateKeys) {
|
|
41
|
+
if (key in params) {
|
|
42
|
+
const value = asNumber(params[key]);
|
|
43
|
+
if (value !== undefined) {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get completion budget from generation config, provider params, or default.
|
|
52
|
+
* Used to reserve output tokens when calculating context limits.
|
|
53
|
+
* @plan PLAN-20260220-DECOMPOSE.P03
|
|
54
|
+
*/
|
|
55
|
+
export function getCompletionBudget(generationConfig, _model, provider, settingsService) {
|
|
56
|
+
const DEFAULT_COMPLETION_BUDGET = 65_536;
|
|
57
|
+
// Check global ephemeral setting for maxOutputTokens (set via /set maxOutputTokens)
|
|
58
|
+
// This is a generic setting that providers should translate to their native param
|
|
59
|
+
const liveMaxOutputTokens = settingsService?.get('maxOutputTokens');
|
|
60
|
+
const liveBudget = asNumber(liveMaxOutputTokens);
|
|
61
|
+
if (liveBudget !== undefined && liveBudget > 0) {
|
|
62
|
+
return liveBudget;
|
|
63
|
+
}
|
|
64
|
+
const generationBudget = asNumber(generationConfig.maxOutputTokens);
|
|
65
|
+
const providerParams = provider?.getModelParams?.();
|
|
66
|
+
const providerBudget = extractCompletionBudgetFromParams(providerParams);
|
|
67
|
+
return generationBudget ?? providerBudget ?? DEFAULT_COMPLETION_BUDGET;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Estimate token count for pending content that hasn't been added to history yet.
|
|
71
|
+
* Uses historyService tokenizer when available, falls back to text-based estimation.
|
|
72
|
+
* @plan PLAN-20260220-DECOMPOSE.P03
|
|
73
|
+
*/
|
|
74
|
+
export async function estimatePendingTokens(contents, historyService, model) {
|
|
75
|
+
if (contents.length === 0) {
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
return await historyService.estimateTokensForContents(contents, model);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
logger.debug('Falling back to local token estimate', error);
|
|
83
|
+
let fallback = 0;
|
|
84
|
+
for (const content of contents) {
|
|
85
|
+
fallback += estimateFallbackContentTokens(content, logger);
|
|
86
|
+
}
|
|
87
|
+
return fallback;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function estimateFallbackContentTokens(content, fallbackLogger) {
|
|
91
|
+
try {
|
|
92
|
+
const serialized = JSON.stringify(content);
|
|
93
|
+
return estimateTextTokens(serialized);
|
|
94
|
+
}
|
|
95
|
+
catch (stringifyError) {
|
|
96
|
+
fallbackLogger.debug('Failed to stringify content for fallback token estimate', stringifyError);
|
|
97
|
+
return estimateBlockTokens(content);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function estimateBlockTokens(content) {
|
|
101
|
+
try {
|
|
102
|
+
const blockStrings = content.blocks
|
|
103
|
+
.map((block) => {
|
|
104
|
+
switch (block.type) {
|
|
105
|
+
case 'text':
|
|
106
|
+
return block.text;
|
|
107
|
+
case 'tool_call':
|
|
108
|
+
return JSON.stringify({
|
|
109
|
+
name: block.name,
|
|
110
|
+
parameters: block.parameters,
|
|
111
|
+
});
|
|
112
|
+
case 'tool_response':
|
|
113
|
+
return JSON.stringify({
|
|
114
|
+
callId: block.callId,
|
|
115
|
+
toolName: block.toolName,
|
|
116
|
+
result: block.result,
|
|
117
|
+
error: block.error,
|
|
118
|
+
});
|
|
119
|
+
case 'thinking':
|
|
120
|
+
return block.thought;
|
|
121
|
+
case 'code':
|
|
122
|
+
return block.code;
|
|
123
|
+
case 'media':
|
|
124
|
+
return block.caption ?? '';
|
|
125
|
+
default:
|
|
126
|
+
return '';
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
.join('\n');
|
|
130
|
+
if (blockStrings) {
|
|
131
|
+
return estimateTextTokens(blockStrings);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (blockError) {
|
|
135
|
+
logger.debug('Failed to estimate tokens from blocks', blockError);
|
|
136
|
+
}
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=compressionBudgeting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compressionBudgeting.js","sourceRoot":"","sources":["../../../src/compression/compressionBudgeting.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC9G,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAEzE,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,qCAAqC,CAAC,CAAC;AAEtE;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iCAAiC,CAC/C,MAA2C;IAE3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,aAAa,GAAG;QACpB,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AAM,EAAE,KAAK,CAAC,MAAM;wBACpB,KAAK,EAAE,KAAK,CAAC,KAAK;qBACnB,CAAC,CAAC;gBACL,KAAK,UAAU;oBACb,OAAO,KAAK,CAAC,OAAO,CAAC;gBACvB,KAAK,MAAM;oBACT,OAAO,KAAK,CAAC,IAAI,CAAC;gBACpB,KAAK,OAAO;oBACV,OAAO,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC7B;oBACE,OAAO,EAAE,CAAC;YACd,CAAC;QACH,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,kBAAkB,CAAC,YAAY,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAAC,OAAO,UAAU,EAAE,CAAC;QACpB,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,UAAU,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @plan PLAN-20260211-COMPRESSION.P10
|
|
8
|
+
* @plan PLAN-20260211-HIGHDENSITY.P17
|
|
9
|
+
* @requirement REQ-CS-001.2, REQ-CS-001.3, REQ-HD-004.2
|
|
10
|
+
* @pseudocode settings-factory.md lines 140-157
|
|
11
|
+
*
|
|
12
|
+
* Factory functions for resolving compression strategies by name.
|
|
13
|
+
*/
|
|
14
|
+
import type { CompressionStrategy, CompressionStrategyName } from '@vybestack/llxprt-code-core/core/compression/types.js';
|
|
15
|
+
/**
|
|
16
|
+
* Validates a raw string against the known strategy names.
|
|
17
|
+
* Returns the typed name on success; throws {@link UnknownStrategyError} otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseCompressionStrategyName(name: string): CompressionStrategyName;
|
|
20
|
+
/**
|
|
21
|
+
* Returns a fresh {@link CompressionStrategy} instance for the given name.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getCompressionStrategy(name: CompressionStrategyName): CompressionStrategy;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { COMPRESSION_STRATEGIES, UnknownStrategyError, } from '@vybestack/llxprt-code-core/core/compression/types.js';
|
|
7
|
+
import { MiddleOutStrategy } from './MiddleOutStrategy.js';
|
|
8
|
+
import { TopDownTruncationStrategy } from './TopDownTruncationStrategy.js';
|
|
9
|
+
import { OneShotStrategy } from './OneShotStrategy.js';
|
|
10
|
+
import { HighDensityStrategy } from './HighDensityStrategy.js';
|
|
11
|
+
/**
|
|
12
|
+
* Validates a raw string against the known strategy names.
|
|
13
|
+
* Returns the typed name on success; throws {@link UnknownStrategyError} otherwise.
|
|
14
|
+
*/
|
|
15
|
+
export function parseCompressionStrategyName(name) {
|
|
16
|
+
if (COMPRESSION_STRATEGIES.includes(name)) {
|
|
17
|
+
return name;
|
|
18
|
+
}
|
|
19
|
+
throw new UnknownStrategyError(name);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns a fresh {@link CompressionStrategy} instance for the given name.
|
|
23
|
+
*/
|
|
24
|
+
export function getCompressionStrategy(name) {
|
|
25
|
+
switch (name) {
|
|
26
|
+
case 'middle-out':
|
|
27
|
+
return new MiddleOutStrategy();
|
|
28
|
+
case 'top-down-truncation':
|
|
29
|
+
return new TopDownTruncationStrategy();
|
|
30
|
+
case 'one-shot':
|
|
31
|
+
return new OneShotStrategy();
|
|
32
|
+
case 'high-density':
|
|
33
|
+
return new HighDensityStrategy();
|
|
34
|
+
default: {
|
|
35
|
+
const exhaustive = name;
|
|
36
|
+
throw new UnknownStrategyError(exhaustive);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=compressionStrategyFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compressionStrategyFactory.js","sourceRoot":"","sources":["../../../src/compression/compressionStrategyFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAC1C,IAAY;IAEZ,IAAK,sBAA4C,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACjE,OAAO,IAA+B,CAAC;IACzC,CAAC;IACD,MAAM,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAA6B;IAE7B,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY;YACf,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACjC,KAAK,qBAAqB;YACxB,OAAO,IAAI,yBAAyB,EAAE,CAAC;QACzC,KAAK,UAAU;YACb,OAAO,IAAI,eAAe,EAAE,CAAC;QAC/B,KAAK,cAAc;YACjB,OAAO,IAAI,mBAAmB,EAAE,CAAC;QACnC,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,UAAU,GAAU,IAAI,CAAC;YAC/B,MAAM,IAAI,oBAAoB,CAAC,UAAoB,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export * from '@vybestack/llxprt-code-core/core/compression/types.js';
|
|
7
|
+
export * from './utils.js';
|
|
8
|
+
export { MiddleOutStrategy } from './MiddleOutStrategy.js';
|
|
9
|
+
export { TopDownTruncationStrategy } from './TopDownTruncationStrategy.js';
|
|
10
|
+
export { OneShotStrategy } from './OneShotStrategy.js';
|
|
11
|
+
/** @plan PLAN-20260211-HIGHDENSITY.P09 */
|
|
12
|
+
export { HighDensityStrategy } from './HighDensityStrategy.js';
|
|
13
|
+
export * from './compressionStrategyFactory.js';
|
|
14
|
+
/** @plan PLAN-20260220-DECOMPOSE.P03 */
|
|
15
|
+
export { CompressionHandler } from './CompressionHandler.js';
|
|
16
|
+
export * from './compressionBudgeting.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export * from '@vybestack/llxprt-code-core/core/compression/types.js';
|
|
7
|
+
export * from './utils.js';
|
|
8
|
+
export { MiddleOutStrategy } from './MiddleOutStrategy.js';
|
|
9
|
+
export { TopDownTruncationStrategy } from './TopDownTruncationStrategy.js';
|
|
10
|
+
export { OneShotStrategy } from './OneShotStrategy.js';
|
|
11
|
+
/** @plan PLAN-20260211-HIGHDENSITY.P09 */
|
|
12
|
+
export { HighDensityStrategy } from './HighDensityStrategy.js';
|
|
13
|
+
export * from './compressionStrategyFactory.js';
|
|
14
|
+
/** @plan PLAN-20260220-DECOMPOSE.P03 */
|
|
15
|
+
export { CompressionHandler } from './CompressionHandler.js';
|
|
16
|
+
export * from './compressionBudgeting.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/compression/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,uDAAuD,CAAC;AACtE,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,0CAA0C;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,cAAc,iCAAiC,CAAC;AAChD,wCAAwC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Core-owned reasoning helpers used by compression.
|
|
8
|
+
*
|
|
9
|
+
* Provider-specific reasoning parsing remains in the providers package. Core
|
|
10
|
+
* keeps only generic thinking-block accounting helpers needed by compression.
|
|
11
|
+
*
|
|
12
|
+
* @plan:PLAN-20260603-ISSUE1584.P11
|
|
13
|
+
* @requirement:REQ-DEP-001
|
|
14
|
+
* @requirement:REQ-SHIM-001
|
|
15
|
+
*/
|
|
16
|
+
import type { IContent, ThinkingBlock } from '@vybestack/llxprt-code-core/services/history/IContent.js';
|
|
17
|
+
export declare function extractThinkingBlocks(content: IContent): ThinkingBlock[];
|
|
18
|
+
export declare function estimateThinkingTokens(blocks: ThinkingBlock[]): number;
|