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