@wrongstack/webui 0.119.1 → 0.141.0

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.
@@ -166,7 +166,7 @@ import {
166
166
  collabInjectMiddleware,
167
167
  estimateRequestTokensCalibrated,
168
168
  EventBus,
169
- HybridCompactor as HybridCompactor2,
169
+ createStrategyCompactor as createStrategyCompactor2,
170
170
  ProviderRegistry,
171
171
  TOKENS as TOKENS2,
172
172
  ToolRegistry,
@@ -198,7 +198,8 @@ import {
198
198
  DefaultSkillLoader,
199
199
  DefaultSystemPromptBuilder,
200
200
  DefaultTokenCounter,
201
- HybridCompactor,
201
+ createStrategyCompactor,
202
+ buildRecoveryStrategies,
202
203
  TOKENS
203
204
  } from "@wrongstack/core";
204
205
  function createDefaultContainer(opts) {
@@ -209,7 +210,15 @@ function createDefaultContainer(opts) {
209
210
  container.bind(TOKENS.Logger, () => logger);
210
211
  container.bind(TOKENS.SecretScrubber, () => new DefaultSecretScrubber());
211
212
  container.bind(TOKENS.RetryPolicy, () => new DefaultRetryPolicy());
212
- container.bind(TOKENS.ErrorHandler, () => new DefaultErrorHandler());
213
+ container.bind(
214
+ TOKENS.ErrorHandler,
215
+ () => new DefaultErrorHandler(
216
+ buildRecoveryStrategies({
217
+ compactor: container.resolve(TOKENS.Compactor),
218
+ modelsRegistry
219
+ })
220
+ )
221
+ );
213
222
  container.bind(TOKENS.ModelsRegistry, () => modelsRegistry);
214
223
  container.bind(
215
224
  TOKENS.TokenCounter,
@@ -253,10 +262,23 @@ function createDefaultContainer(opts) {
253
262
  );
254
263
  container.bind(
255
264
  TOKENS.Compactor,
256
- () => new HybridCompactor({
257
- preserveK: opts.compactor?.preserveK ?? 20,
258
- eliseThreshold: opts.compactor?.eliseThreshold ?? 0.7
259
- })
265
+ () => (
266
+ // Strategy comes from config.context.strategy: 'hybrid' (default, lossless
267
+ // rules, no LLM), 'intelligent' (LLM summarization), or 'selective'
268
+ // (LLM-driven selection). The LLM strategies resolve their provider from
269
+ // ctx at compact()-time, so binding here (before context.provider exists)
270
+ // is safe. preserveK / eliseThreshold are class-level fallbacks; the active
271
+ // ContextWindowPolicy in ctx.meta normally overrides both at runtime.
272
+ // eliseThreshold is a TOKEN COUNT — a previous value of 0.7 elided
273
+ // essentially every tool_result (anything > 1 token).
274
+ createStrategyCompactor({
275
+ strategy: config.context?.strategy,
276
+ preserveK: opts.compactor?.preserveK ?? 10,
277
+ eliseThreshold: opts.compactor?.eliseThreshold ?? 2e3,
278
+ summarizerModel: config.context?.summarizerModel,
279
+ llmSelector: config.context?.llmSelector
280
+ })
281
+ )
260
282
  );
261
283
  return container;
262
284
  }
@@ -2181,9 +2203,12 @@ async function startWebUI(opts = {}) {
2181
2203
  const collabInject = collabInjectMiddleware(collabBus, { logger });
2182
2204
  Object.defineProperty(collabInject, "name", { value: "collab-inject" });
2183
2205
  pipelines.toolCall.prepend(collabInject);
2184
- const compactor = new HybridCompactor2({
2185
- preserveK: config.context?.preserveK ?? 20,
2186
- eliseThreshold: config.context?.eliseThreshold ?? 0.7
2206
+ const compactor = createStrategyCompactor2({
2207
+ strategy: config.context?.strategy,
2208
+ preserveK: config.context?.preserveK ?? 10,
2209
+ eliseThreshold: config.context?.eliseThreshold ?? 2e3,
2210
+ summarizerModel: config.context?.summarizerModel,
2211
+ llmSelector: config.context?.llmSelector
2187
2212
  });
2188
2213
  let autoCompactor;
2189
2214
  if (config.context?.autoCompact !== false) {
@@ -2199,7 +2224,12 @@ async function startWebUI(opts = {}) {
2199
2224
  autoCompactor = new AutoCompactionMiddleware(
2200
2225
  compactor,
2201
2226
  effectiveMaxContext,
2202
- (ctx) => estimateRequestTokensCalibrated(ctx.messages, ctx.systemPrompt, ctx.tools ?? []).total,
2227
+ (ctx) => estimateRequestTokensCalibrated(
2228
+ ctx.messages,
2229
+ ctx.systemPrompt,
2230
+ ctx.tools ?? [],
2231
+ `${ctx.provider?.id ?? "unknown"}/${ctx.model}`
2232
+ ).total,
2203
2233
  {
2204
2234
  warn: initialContextPolicy.thresholds.warn,
2205
2235
  soft: initialContextPolicy.thresholds.soft,