blun-king-cli 9.1.176 → 9.1.177

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.
@@ -14,6 +14,22 @@ const SYNTHETIC_TOOL_ARGUMENT_MARKER = JSON.stringify({
14
14
  const TELEGRAM_REPLY_TOOL_RE = /^mcp__[^\s]*telegram[^\s]*__reply$/iu;
15
15
  const SYNTHETIC_TOOL_ARGUMENT_SUMMARY_MARKER = '[Historical tool arguments unavailable]';
16
16
 
17
+ function isSyntheticToolArguments(value) {
18
+ let parsed = value;
19
+ if (typeof value === 'string') {
20
+ try {
21
+ parsed = JSON.parse(value);
22
+ } catch {
23
+ return false;
24
+ }
25
+ }
26
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) return false;
27
+ const keys = Object.keys(parsed);
28
+ return keys.length === 1
29
+ && keys[0] === '_blun_compacted'
30
+ && parsed._blun_compacted === '[Old tool call arguments cleared]';
31
+ }
32
+
17
33
  function shouldOffloadHistoricalAssistantMessage(options = {}) {
18
34
  const historyIndex = Number(options.historyIndex);
19
35
  const historyLength = Number(options.historyLength);
@@ -134,7 +150,7 @@ function removeSyntheticToolArgumentFailures(messages) {
134
150
  const syntheticCallIds = new Set(scrubbedMessages.flatMap((message) => (
135
151
  message?.role === 'assistant' && Array.isArray(message.toolCalls)
136
152
  ? message.toolCalls
137
- .filter((call) => call?.arguments === SYNTHETIC_TOOL_ARGUMENT_MARKER)
153
+ .filter((call) => isSyntheticToolArguments(call?.arguments))
138
154
  .map((call) => call?.id)
139
155
  : []
140
156
  )).filter((id) => typeof id === 'string' && id.length > 0));
@@ -165,6 +181,7 @@ module.exports = {
165
181
  ASSISTANT_POST_TELEGRAM_REPLY_MARKER,
166
182
  compactHistoricalPostTelegramReplyNarration,
167
183
  createAssistantMessagePreview,
184
+ isSyntheticToolArguments,
168
185
  removeSyntheticToolArgumentFailures,
169
186
  shouldCompactHistoricalAssistantToolNarration,
170
187
  shouldOffloadHistoricalAssistantMessage,
@@ -60,6 +60,7 @@ const CORE_LOAD_TIMEOUT_MS = 30_000;
60
60
  const RUNTIME_READY_TIMEOUT_MS = 60_000;
61
61
  const RUNNING_UPDATE_RECHECK_MS = 60_000;
62
62
  const RUNNING_UPDATE_RECHECK_JITTER_MS = 30_000;
63
+ const RUNNING_UPDATE_HANDOFF_NOTICE = 'Ein Update wird geladen. Die TUI wird anschließend neu gestartet.';
63
64
 
64
65
  function runningUpdateRecheckDelay(randomValue = Math.random()) {
65
66
  const normalized = Number.isFinite(randomValue)
@@ -78,6 +79,10 @@ function scheduleRunningUpdateRecheck(callback, options = {}) {
78
79
  return timer;
79
80
  }
80
81
 
82
+ function writeRunningUpdateHandoffNotice(output = process.stdout) {
83
+ output.write(`\n${RUNNING_UPDATE_HANDOFF_NOTICE}\n`);
84
+ }
85
+
81
86
  function normalizeWindowsPath(value) {
82
87
  return path.win32.normalize(value).replace(/\\+$/u, '').toLowerCase();
83
88
  }
@@ -255,6 +260,14 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
255
260
  let runningUpdateMode = readRunningUpdateMode(env.BLUN_HOME);
256
261
  const automaticMode = () => runningUpdateMode === RUNNING_UPDATE_MODES.RESUME
257
262
  || runningUpdateMode === RUNNING_UPDATE_MODES.NEW;
263
+ const refreshRunningUpdateMode = () => {
264
+ const persistedMode = readRunningUpdateMode(env.BLUN_HOME);
265
+ if (persistedMode !== runningUpdateMode) {
266
+ runningUpdateMode = persistedMode;
267
+ handoffSessionId = undefined;
268
+ handoffMode = undefined;
269
+ }
270
+ };
258
271
  const clearRunningUpdatePoll = () => {
259
272
  if (runningUpdatePollTimer === undefined) return;
260
273
  (options.clearTimeoutImpl || clearTimeout)(runningUpdatePollTimer);
@@ -262,10 +275,12 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
262
275
  };
263
276
  const scheduleNextPreparation = (child) => {
264
277
  clearRunningUpdatePoll();
265
- if (preparedTarget !== undefined || updateStarted || !automaticMode()) return;
278
+ if (preparedTarget !== undefined || updateStarted) return;
266
279
  runningUpdatePollTimer = (options.scheduleRunningUpdateRecheck || scheduleRunningUpdateRecheck)(() => {
267
280
  runningUpdatePollTimer = undefined;
268
- startPreparation(child);
281
+ refreshRunningUpdateMode();
282
+ if (automaticMode()) startPreparation(child);
283
+ else scheduleNextPreparation(child);
269
284
  });
270
285
  };
271
286
  const announcePrepared = (child) => {
@@ -309,7 +324,9 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
309
324
  onMessage(message, child) {
310
325
  if (message?.type === RUNTIME_READY_MESSAGE) {
311
326
  runtimeReady = true;
312
- startPreparation(child);
327
+ refreshRunningUpdateMode();
328
+ if (automaticMode()) startPreparation(child);
329
+ else scheduleNextPreparation(child);
313
330
  }
314
331
  if (message?.type === RUNNING_UPDATE_MODE_MESSAGE && typeof message.mode === 'string') {
315
332
  runningUpdateMode = normalizeRunningUpdateMode(message.mode);
@@ -322,7 +339,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
322
339
  updateStarted = false;
323
340
  startPreparation(child);
324
341
  }
325
- }
342
+ } else if (runtimeReady) scheduleNextPreparation(child);
326
343
  }
327
344
  if (message?.type === RUNNING_UPDATE_HANDOFF_MESSAGE
328
345
  && typeof message.sessionId === 'string'
@@ -343,6 +360,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
343
360
  && preparedTarget !== undefined
344
361
  && handoffSessionId !== undefined
345
362
  && handoffMode !== undefined) {
363
+ writeRunningUpdateHandoffNotice(options.runningUpdateNoticeOutput || process.stdout);
346
364
  const handoff = await handoffRuntime({
347
365
  target: preparedTarget,
348
366
  previous: { packageRoot, version: readPackageVersion() },
@@ -705,4 +723,5 @@ module.exports = {
705
723
  shouldDetachProtectedCore,
706
724
  spawnManagedLauncher,
707
725
  superviseProtectedCore,
726
+ writeRunningUpdateHandoffNotice,
708
727
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.176",
3
+ "version": "9.1.177",
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": {