blun-king-cli 9.1.429 → 9.1.430

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.
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ function resolveCompactionModelAlias(configuredAlias, activeAlias) {
4
+ if (typeof configuredAlias === 'string' && configuredAlias.trim().length > 0) {
5
+ return configuredAlias.trim();
6
+ }
7
+ return activeAlias;
8
+ }
9
+
10
+ module.exports = {
11
+ resolveCompactionModelAlias,
12
+ };
package/blun.mjs CHANGED
@@ -9,6 +9,7 @@ import telegramConsoleStatusPolicy from "./bin/telegram-console-status-policy.cj
9
9
  import cognitiveGoalAutostartPolicy from "./bin/cognitive-goal-autostart-policy.cjs";
10
10
  import cognitiveGoalTimeTriggerController from "./bin/cognitive-goal-time-trigger-controller.cjs";
11
11
  import runtimeExitLedger from "./bin/runtime-exit-ledger.cjs";
12
+ import compactionModelPolicy from "./bin/compaction-model-policy.cjs";
12
13
  import crypto$1, { createHash, randomBytes, randomInt, randomUUID, timingSafeEqual } from "node:crypto";
13
14
  import * as fs$16 from "node:fs";
14
15
  import Kt, { accessSync, appendFileSync, chmodSync, closeSync, constants, copyFileSync, createReadStream, createWriteStream, existsSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, promises, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
@@ -42,6 +43,7 @@ const { writeTelegramConsoleStatus } = telegramConsoleStatusPolicy;
42
43
  const { goalAutostartDecision, goalContinuationDecision } = cognitiveGoalAutostartPolicy;
43
44
  const { GoalTimeTriggerController } = cognitiveGoalTimeTriggerController;
44
45
  const { recordRuntimeExit } = runtimeExitLedger;
46
+ const { resolveCompactionModelAlias } = compactionModelPolicy;
45
47
  import { EventEmitter as EventEmitter$1 } from "node:events";
46
48
  import { StringDecoder } from "node:string_decoder";
47
49
  import co from "node:assert";
@@ -10048,7 +10050,8 @@ var init_schema = __esmMin((() => {
10048
10050
  maxRetriesPerStep: number$1().int().min(0).optional(),
10049
10051
  maxRalphIterations: number$1().int().min(-1).optional(),
10050
10052
  reservedContextSize: number$1().int().min(0).optional(),
10051
- compactionTriggerRatio: number$1().min(.5).max(.99).optional()
10053
+ compactionTriggerRatio: number$1().min(.5).max(.99).optional(),
10054
+ compactionModel: string().min(1).optional()
10052
10055
  });
10053
10056
  BackgroundConfigSchema = object({
10054
10057
  maxRunningTasks: number$1().int().min(1).optional(),
@@ -75620,11 +75623,11 @@ var init_full = __esmMin((() => {
75620
75623
  let retryCount = 0;
75621
75624
  try {
75622
75625
  await this.triggerPreCompactHook(data, tokensBefore, signal);
75623
- const model = this.agent.activeResponderModel ?? this.agent.config.model;
75626
+ const model = resolveCompactionModelAlias(this.agent.blunConfig?.loopControl?.compactionModel, this.agent.activeResponderModel ?? this.agent.config.model);
75624
75627
  const runtimeModel = this.agent.config.runtimeModel(model);
75625
75628
  const capability = runtimeModel.modelCapabilities;
75626
75629
  const buildCompactionProvider = (usedContextTokens) => {
75627
- const currentMaxContextTokens = this.getEffectiveMaxContextTokens();
75630
+ const currentMaxContextTokens = this.getEffectiveMaxContextTokens(model);
75628
75631
  const defaultCompactionCap = capCompactionCompletionTokens(currentMaxContextTokens);
75629
75632
  const requestCapability = currentMaxContextTokens > 0 ? {
75630
75633
  ...capability,
@@ -75666,7 +75669,7 @@ var init_full = __esmMin((() => {
75666
75669
  }), createUserMessage(requestInstruction)], capability));
75667
75670
  };
75668
75671
  while (true) {
75669
- const compactionRequestLimit = this.getEffectiveMaxContextTokens();
75672
+ const compactionRequestLimit = this.getEffectiveMaxContextTokens(model);
75670
75673
  const safeCompactionRequestLimit = compactionRequestLimit > 0 ? Math.max(1, Math.floor(compactionRequestLimit * (1 - COMPACTION_SUMMARY_RESERVE_RATIO))) : compactionRequestLimit;
75671
75674
  const targetCompactionRequestLimit = capCompactionStageTarget(safeCompactionRequestLimit);
75672
75675
  let messages = buildRequestMessages(historyForModel, instruction);
@@ -75764,7 +75767,7 @@ var init_full = __esmMin((() => {
75764
75767
  };
75765
75768
  armStallTimer();
75766
75769
  try {
75767
- const response = await this.agent.generate(provider, COMPACTION_SYSTEM_PROMPT, compactionTools, messages, { onMessagePart: observeProgress }, { signal: attemptController.signal });
75770
+ const response = await this.agent.generateForModel(model)(provider, COMPACTION_SYSTEM_PROMPT, compactionTools, messages, { onMessagePart: observeProgress }, { signal: attemptController.signal });
75768
75771
  if (stalled && !signal.aborted && stallPolicy !== void 0) throw new CompactionStallError(stallPolicy.timeoutMs, stallPolicy.measuredIdleMs);
75769
75772
  maxObservedIdleMs = Math.max(maxObservedIdleMs, Date.now() - lastProgressAt);
75770
75773
  if (response.finishReason === "truncated") throw new CompactionTruncatedError();
@@ -75803,10 +75806,10 @@ var init_full = __esmMin((() => {
75803
75806
  if (stalled && !signal.aborted && stallPolicy !== void 0) throw new CompactionStallError(stallPolicy.timeoutMs, stallPolicy.measuredIdleMs);
75804
75807
  if (isModelFallbackStatus(error)) throw error;
75805
75808
  const isContextOverflow = this.shouldRecoverFromContextOverflow(error);
75806
- if (isContextOverflow) this.observeContextOverflow(error);
75809
+ if (isContextOverflow) this.observeContextOverflow(error, model);
75807
75810
  if (isContextOverflow && historyForModel.length > 1) {
75808
75811
  if (data.source === "auto") {
75809
- const learnedMaxContextTokens = this.getEffectiveMaxContextTokens();
75812
+ const learnedMaxContextTokens = this.getEffectiveMaxContextTokens(model);
75810
75813
  if (learnedMaxContextTokens > 0 && learnedMaxContextTokens < compactionRequestLimit) {
75811
75814
  retryCount = 0;
75812
75815
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.429",
3
+ "version": "9.1.430",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {