blun-king-cli 9.1.356 → 9.1.358

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,33 @@
1
+ 'use strict';
2
+
3
+ function joinSystemPrompt(base, append) {
4
+ if (append.length === 0) return base;
5
+ return base.length === 0 ? append : `${base}\n\n${append}`;
6
+ }
7
+
8
+ function createEffectiveSystemPromptResolver(joinPrompts = joinSystemPrompt) {
9
+ if (typeof joinPrompts !== 'function') {
10
+ throw new TypeError('joinPrompts must be a function');
11
+ }
12
+
13
+ let initialized = false;
14
+ let cachedBase = '';
15
+ let cachedAppend = '';
16
+ let cachedPrompt = '';
17
+
18
+ return function resolveEffectiveSystemPrompt(base, append) {
19
+ if (initialized && base === cachedBase && append === cachedAppend) {
20
+ return cachedPrompt;
21
+ }
22
+
23
+ cachedPrompt = joinPrompts(base, append);
24
+ cachedBase = base;
25
+ cachedAppend = append;
26
+ initialized = true;
27
+ return cachedPrompt;
28
+ };
29
+ }
30
+
31
+ module.exports = {
32
+ createEffectiveSystemPromptResolver,
33
+ };
@@ -68,6 +68,7 @@ const RUNNING_UPDATE_RESUME_SESSION_ENV = 'BLUN_RUNNING_UPDATE_RESUME_SESSION_ID
68
68
  const RUNTIME_READY_TIMEOUT_MS = 60_000;
69
69
  const RUNNING_UPDATE_RECHECK_MS = 5 * 60_000;
70
70
  const RUNNING_UPDATE_RECHECK_JITTER_MS = 2 * 60_000;
71
+ const RUNNING_UPDATE_ERROR_RETRY_MS = 10_000;
71
72
  const RUNNING_UPDATE_STABILIZATION_MS = 2 * 60 * 1000;
72
73
 
73
74
  function runningUpdateRecheckDelay(randomValue = Math.random()) {
@@ -87,6 +88,17 @@ function scheduleRunningUpdateRecheck(callback, options = {}) {
87
88
  return timer;
88
89
  }
89
90
 
91
+ function runningUpdateFailureDetails(error) {
92
+ const safeField = (value, fallback) => typeof value === 'string'
93
+ && /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u.test(value)
94
+ ? value
95
+ : fallback;
96
+ return {
97
+ errorName: safeField(error?.name, 'Error'),
98
+ errorCode: safeField(error?.code, 'UNKNOWN'),
99
+ };
100
+ }
101
+
90
102
  function normalizeWindowsPath(value) {
91
103
  return path.win32.normalize(value).replace(/\\+$/u, '').toLowerCase();
92
104
  }
@@ -350,7 +362,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
350
362
  if (typeof sharedHome !== 'string' || sharedHome.length === 0) return;
351
363
  (options.stageRuntime || stageRuntime)(sharedHome, preparedTarget, stagedRuntimeOptions());
352
364
  };
353
- const scheduleNextPreparation = (child) => {
365
+ const scheduleNextPreparation = (child, scheduleOptions = {}) => {
354
366
  clearRunningUpdatePoll();
355
367
  if (supervisionCompleted || updateStarted) return;
356
368
  runningUpdatePollTimer = (options.scheduleRunningUpdateRecheck || scheduleRunningUpdateRecheck)(() => {
@@ -358,7 +370,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
358
370
  refreshRunningUpdateMode();
359
371
  if (automaticMode()) startPreparation(child);
360
372
  else scheduleNextPreparation(child);
361
- });
373
+ }, scheduleOptions);
362
374
  };
363
375
  const startPreparation = (child) => {
364
376
  if (supervisionCompleted || updateStarted
@@ -417,7 +429,16 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
417
429
  }).catch((error) => {
418
430
  updateStarted = false;
419
431
  options.onRunningUpdateError?.(error);
420
- scheduleNextPreparation(child);
432
+ try {
433
+ (options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, {
434
+ event: 'prepare-failed',
435
+ runningVersion: readPackageVersionAt(packageRoot),
436
+ ...runningUpdateFailureDetails(error),
437
+ }, { now: options.nowImpl });
438
+ } catch (recordError) {
439
+ options.onRunningUpdateError?.(recordError);
440
+ }
441
+ scheduleNextPreparation(child, { delayMs: RUNNING_UPDATE_ERROR_RETRY_MS });
421
442
  });
422
443
  };
423
444
  const handleCoreMessage = (message, child) => {
@@ -931,6 +952,7 @@ async function runLauncher(options = {}) {
931
952
  }
932
953
 
933
954
  module.exports = {
955
+ RUNNING_UPDATE_ERROR_RETRY_MS,
934
956
  RUNNING_UPDATE_RECHECK_JITTER_MS,
935
957
  RUNNING_UPDATE_RECHECK_MS,
936
958
  RUNNING_UPDATE_STABILIZATION_MS,
package/blun.mjs CHANGED
@@ -265004,7 +265004,7 @@ var init_llm_request_logger = __esmMin((() => {
265004
265004
  function normalizeRuntimeSystemPromptAppend(value) {
265005
265005
  return value?.trim().slice(0, 16e3) ?? "";
265006
265006
  }
265007
- var PINNED_MODEL_ALIASES, resolveProviderIdleTimeoutMs, capCompletionBudgetForAdaptiveEffort, capTurnCompletionTokens, selectThinkingEffortForBufferedSteer, selectThinkingEffortForWorkStep, selectThinkingEffortForTurn, Agent$1;
265007
+ var PINNED_MODEL_ALIASES, createEffectiveSystemPromptResolver, resolveProviderIdleTimeoutMs, capCompletionBudgetForAdaptiveEffort, capTurnCompletionTokens, selectThinkingEffortForBufferedSteer, selectThinkingEffortForWorkStep, selectThinkingEffortForTurn, Agent$1;
265008
265008
  var init_agent = __esmMin((() => {
265009
265009
  init_dist$6();
265010
265010
  init_config$4();
@@ -265041,6 +265041,7 @@ var init_agent = __esmMin((() => {
265041
265041
  init_goal$1();
265042
265042
  init_session_loop();
265043
265043
  init_error_memory();
265044
+ ({ createEffectiveSystemPromptResolver } = createRequire(import.meta.url)("./bin/effective-system-prompt-cache-policy.cjs"));
265044
265045
  ({ resolveProviderIdleTimeoutMs } = createRequire(import.meta.url)("./bin/provider-idle-timeout-policy.cjs"));
265045
265046
  ({ capCompletionBudgetForAdaptiveEffort, capTurnCompletionTokens, selectThinkingEffortForBufferedSteer, selectThinkingEffortForWorkStep, selectThinkingEffortForTurn } = createRequire(import.meta.url)("./bin/turn-thinking-policy.cjs"));
265046
265047
  PINNED_MODEL_ALIASES = new Set(["king-blun", "pruefstand"]);
@@ -265098,6 +265099,7 @@ var init_agent = __esmMin((() => {
265098
265099
  allowModelFallback = true;
265099
265100
  personalMemoryHostCapabilityEnabled = false;
265100
265101
  runtimeSystemPromptAppend = "";
265102
+ resolveEffectiveSystemPrompt = createEffectiveSystemPromptResolver();
265101
265103
  systemPromptContextProvider;
265102
265104
  systemPromptTimestamp = new Date();
265103
265105
  systemPromptContextFingerprint = "";
@@ -265264,9 +265266,7 @@ var init_agent = __esmMin((() => {
265264
265266
  this.emitStatusUpdated();
265265
265267
  }
265266
265268
  get effectiveSystemPrompt() {
265267
- const base = this.config.systemPrompt;
265268
- if (this.runtimeSystemPromptAppend.length === 0) return base;
265269
- return base.length === 0 ? this.runtimeSystemPromptAppend : `${base}\n\n${this.runtimeSystemPromptAppend}`;
265269
+ return this.resolveEffectiveSystemPrompt(this.config.systemPrompt, this.runtimeSystemPromptAppend);
265270
265270
  }
265271
265271
  get fastConversationSystemPrompt() {
265272
265272
  return [personaSystemBlock(), soulSystemBlock(), identitySystemBlock(), naturalPresenceSystemBlock(), conductSystemBlock(), `## Fast conversation mode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.356",
3
+ "version": "9.1.358",
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": {