blun-king-cli 9.1.316 → 9.1.318

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.
@@ -30,20 +30,16 @@ const { startMnemoConnectHeartbeat } = require('./mnemo-connect-heartbeat.cjs');
30
30
  const { acquireSharedRuntimeLease, tryAcquireUpdateLease } = require('./update-lease');
31
31
  const { compareSemver, runExplicitUpdate, runUpdateNotice } = require('./update-notice');
32
32
  const {
33
- RUNNING_UPDATE_HANDOFF_ACK_MESSAGE,
34
- RUNNING_UPDATE_HANDOFF_EXIT_CODE,
35
- RUNNING_UPDATE_HANDOFF_MESSAGE,
36
33
  RUNNING_UPDATE_MODE_MESSAGE,
34
+ RUNNING_UPDATE_PREPARED_MESSAGE,
37
35
  RUNTIME_EXIT_INTENT_MESSAGE,
38
36
  activateRuntime,
39
37
  clearActiveRuntime,
40
- handoffArgsForMode,
41
38
  prepareRunningUpdate,
42
39
  pruneRunningUpdateReleases,
43
40
  recordRunningUpdateEvent,
44
41
  readActiveRuntime,
45
42
  readPendingRuntime,
46
- restoreActiveRuntime,
47
43
  clearPendingRuntime,
48
44
  stageRuntime,
49
45
  } = require('./running-update.cjs');
@@ -310,7 +306,6 @@ function shouldRecoverActivatedRuntime(result, recovery, options = {}) {
310
306
  async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {}) {
311
307
  const packageRoot = path.resolve(options.packageRoot || PKG);
312
308
  let preparedTarget;
313
- let pendingHandoff;
314
309
  let updateStarted = false;
315
310
  let runtimeReady = false;
316
311
  let activeSession;
@@ -350,7 +345,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
350
345
  };
351
346
  const scheduleNextPreparation = (child) => {
352
347
  clearRunningUpdatePoll();
353
- if (supervisionCompleted || pendingHandoff !== undefined || updateStarted) return;
348
+ if (supervisionCompleted || updateStarted) return;
354
349
  runningUpdatePollTimer = (options.scheduleRunningUpdateRecheck || scheduleRunningUpdateRecheck)(() => {
355
350
  runningUpdatePollTimer = undefined;
356
351
  refreshRunningUpdateMode();
@@ -359,7 +354,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
359
354
  });
360
355
  };
361
356
  const startPreparation = (child) => {
362
- if (supervisionCompleted || pendingHandoff !== undefined || updateStarted
357
+ if (supervisionCompleted || updateStarted
363
358
  || options.runningUpdate === false || !automaticMode()) return;
364
359
  updateStarted = true;
365
360
  const sharedHome = env.BLUN_SHARED_HOME;
@@ -387,6 +382,15 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
387
382
  }
388
383
  preparedTarget = target;
389
384
  persistPreparedRuntime();
385
+ if (child?.connected === true) {
386
+ try {
387
+ child.send({
388
+ type: RUNNING_UPDATE_PREPARED_MESSAGE,
389
+ version: target.version,
390
+ mode: runningUpdateMode,
391
+ });
392
+ } catch {}
393
+ }
390
394
  const runningVersion = readPackageVersionAt(packageRoot);
391
395
  (options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, previousTarget === undefined ? {
392
396
  event: 'prepared-for-next-start',
@@ -411,43 +415,6 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
411
415
  };
412
416
  const handleCoreMessage = (message, child) => {
413
417
  if (message?.type === RUNTIME_EXIT_INTENT_MESSAGE) runtimeExitIntent = true;
414
- if (message?.type === RUNNING_UPDATE_HANDOFF_MESSAGE
415
- && preparedTarget !== undefined
416
- && message.version === preparedTarget.version
417
- && message.mode === runningUpdateMode
418
- && validSessionMessage(message)) {
419
- activeSession = Object.freeze({
420
- cwd: resolveHandoffCwd(message.cwd, cwd),
421
- sessionId: message.sessionId,
422
- });
423
- try {
424
- persistPreparedRuntime();
425
- } catch (error) {
426
- options.onRunningUpdateError?.(error);
427
- scheduleNextPreparation(child);
428
- return;
429
- }
430
- pendingHandoff = Object.freeze({
431
- cwd: activeSession.cwd,
432
- mode: message.mode,
433
- sessionId: message.sessionId,
434
- target: preparedTarget,
435
- });
436
- clearRunningUpdatePoll();
437
- if (child?.connected === true) {
438
- try {
439
- child.send({
440
- type: RUNNING_UPDATE_HANDOFF_ACK_MESSAGE,
441
- version: preparedTarget.version,
442
- mode: message.mode,
443
- sessionId: message.sessionId,
444
- });
445
- } catch {
446
- pendingHandoff = undefined;
447
- scheduleNextPreparation(child);
448
- }
449
- }
450
- }
451
418
  if (message?.type === RUNTIME_READY_MESSAGE) {
452
419
  if (validSessionMessage(message)) {
453
420
  activeSession = Object.freeze({
@@ -513,69 +480,6 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
513
480
  supervisionCompleted = true;
514
481
  clearRunningUpdatePoll();
515
482
  if (existingMessageHandler) core.child.off('message', existingMessageHandler);
516
- if (result.code === RUNNING_UPDATE_HANDOFF_EXIT_CODE && pendingHandoff !== undefined) {
517
- const sharedHome = env.BLUN_SHARED_HOME;
518
- const target = pendingHandoff.target;
519
- const handoffArgs = handoffArgsForMode(args, pendingHandoff.mode, pendingHandoff.sessionId);
520
- const handoffCwd = pendingHandoff.cwd;
521
- const previousActive = (options.readActiveRuntime || readActiveRuntime)(sharedHome);
522
- const resumeEnv = {
523
- ...env,
524
- [RUNNING_UPDATE_RESUME_SESSION_ENV]: pendingHandoff.sessionId,
525
- };
526
- const nextCore = spawnCore(handoffArgs, resumeEnv, handoffCwd, { packageRoot: target.packageRoot });
527
- const nextLoaded = await nextCore.loaded;
528
- const nextReady = nextLoaded && await (options.waitForRuntimeReady || waitForRuntimeReady)(
529
- nextCore,
530
- options.readyTimeoutMs,
531
- );
532
- if (nextReady) {
533
- await (options.activateRuntime || activateRuntime)(sharedHome, target);
534
- (options.clearPendingRuntime || clearPendingRuntime)(sharedHome, target);
535
- const activatedAt = (options.nowImpl || Date.now)();
536
- (options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, {
537
- event: 'activated-at-safe-boundary',
538
- fromVersion: readPackageVersionAt(packageRoot),
539
- toVersion: target.version,
540
- mode: pendingHandoff.mode,
541
- }, { now: options.nowImpl });
542
- return superviseProtectedCore(handoffArgs, resumeEnv, handoffCwd, async () => {}, {
543
- ...options,
544
- existingCore: nextCore,
545
- packageRoot: target.packageRoot,
546
- recoveryRuntime: {
547
- activeRuntime: previousActive,
548
- activatedAt,
549
- packageRoot,
550
- version: readPackageVersionAt(packageRoot),
551
- },
552
- staleActiveRuntime: undefined,
553
- startupPendingRuntime: undefined,
554
- });
555
- }
556
- try { nextCore.child.kill(); } catch {}
557
- (options.clearPendingRuntime || clearPendingRuntime)(sharedHome, target);
558
- (options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, {
559
- event: 'safe-boundary-start-failed',
560
- fromVersion: readPackageVersionAt(packageRoot),
561
- toVersion: target.version,
562
- }, { now: options.nowImpl });
563
- const fallback = spawnCore(handoffArgs, resumeEnv, handoffCwd, { packageRoot });
564
- const fallbackLoaded = await fallback.loaded;
565
- const fallbackReady = fallbackLoaded && await (options.waitForRuntimeReady || waitForRuntimeReady)(
566
- fallback,
567
- options.readyTimeoutMs,
568
- );
569
- if (!fallbackReady) return 1;
570
- return superviseProtectedCore(handoffArgs, resumeEnv, handoffCwd, async () => {}, {
571
- ...options,
572
- existingCore: fallback,
573
- packageRoot,
574
- recoveryRuntime: undefined,
575
- staleActiveRuntime: undefined,
576
- startupPendingRuntime: undefined,
577
- });
578
- }
579
483
  const recovery = options.recoveryRuntime;
580
484
  if (shouldRecoverActivatedRuntime(result, recovery, {
581
485
  now: (options.nowImpl || Date.now)(),
package/blun.mjs CHANGED
@@ -30351,11 +30351,9 @@ async function chatWithRetry(input) {
30351
30351
  }
30352
30352
  function completionBudgetRetryForEmpty(error) {
30353
30353
  if (error.emptyResponseKind !== "length") return;
30354
- const exhaustedBudget = typeof error.completionTokens === "number" && typeof error.maxCompletionTokens === "number" && error.maxCompletionTokens > 0 && error.completionTokens >= error.maxCompletionTokens;
30355
- const negligibleReasoning = error.reasoningLength < 64;
30356
30354
  return {
30357
30355
  minimumCompletionTokens: MIN_THINKING_COMPLETION_TOKENS,
30358
- multiplier: exhaustedBudget && negligibleReasoning ? .125 : 2
30356
+ multiplier: 2
30359
30357
  };
30360
30358
  }
30361
30359
  function retryDelayForError(error, fallbackDelayMs) {
@@ -495661,7 +495659,7 @@ async function handleUpdateCommand(host) {
495661
495659
  }
495662
495660
  host.runningUpdatePreparedVersion = void 0;
495663
495661
  host.runningUpdatePreparedMode = void 0;
495664
- host.runningUpdateHandoffStarted = false;
495662
+ host.runningUpdatePreparedNoticeVersion = void 0;
495665
495663
  if (process.connected) try {
495666
495664
  process.send({ type: RUNNING_UPDATE_MODE_MESSAGE, mode: selectedMode });
495667
495665
  } catch {}
@@ -515763,7 +515761,6 @@ const {
515763
515761
  RUNNING_UPDATE_PREPARED_MESSAGE,
515764
515762
  RUNTIME_EXIT_INTENT_MESSAGE,
515765
515763
  RUNTIME_READY_MESSAGE,
515766
- isSafeRuntimeBoundary,
515767
515764
  pruneRunningUpdateReleases
515768
515765
  } = __require("./bin/running-update.cjs");
515769
515766
  const {
@@ -515794,64 +515791,21 @@ function notifyRunningRuntimeReady(tui) {
515794
515791
  sendRunningRuntimeSession(tui);
515795
515792
  }
515796
515793
  function requestRunningUpdateAtSafeBoundary(tui) {
515797
- if (tui.runningUpdateHandoffStarted || tui.isShuttingDown || !process.connected) return false;
515798
515794
  const version = tui.runningUpdatePreparedVersion;
515799
515795
  const mode = tui.runningUpdatePreparedMode;
515800
- const sessionId = tui.getCurrentSessionId();
515801
- const cwd = tui.state.appState.workDir;
515802
- if (typeof version !== "string" || mode !== RUNNING_UPDATE_MODES.RESUME && mode !== RUNNING_UPDATE_MODES.NEW || sessionId.length === 0) return false;
515803
- if (!isSafeRuntimeBoundary({
515804
- isShuttingDown: tui.isShuttingDown,
515805
- streamingPhase: tui.state.appState.streamingPhase,
515806
- isCompacting: tui.state.appState.isCompacting,
515807
- queuedMessages: tui.state.queuedMessages.length,
515808
- activeToolCalls: tui.streamingUI.hasActiveToolCalls() ? 1 : 0,
515809
- shellCommands: tui.shellOutputStreams.size,
515810
- queueCommandRunning: tui.queueCommandRunning
515811
- })) return false;
515812
- tui.runningUpdateHandoffStarted = true;
515813
- tui.showStatus(`Update ${version} ist bereit. Die sichere Update-Pause beginnt jetzt.`, "success");
515814
- try {
515815
- process.send({
515816
- type: RUNNING_UPDATE_HANDOFF_MESSAGE,
515817
- version,
515818
- mode,
515819
- sessionId,
515820
- cwd
515821
- }, (error) => {
515822
- if (!error) return;
515823
- tui.runningUpdateHandoffStarted = false;
515824
- tui.showStatus("Das Update bleibt bereit und wird an der naechsten sicheren Grenze erneut versucht.", "warning");
515825
- });
515826
- return true;
515827
- } catch {
515828
- tui.runningUpdateHandoffStarted = false;
515829
- return false;
515830
- }
515796
+ if (typeof version !== "string" || mode !== RUNNING_UPDATE_MODES.RESUME && mode !== RUNNING_UPDATE_MODES.NEW) return false;
515797
+ if (tui.runningUpdatePreparedNoticeVersion === version) return false;
515798
+ tui.runningUpdatePreparedNoticeVersion = version;
515799
+ tui.showStatus(`Update ${version} ist sicher geladen. Die laufende Sitzung bleibt aktiv; beim naechsten natuerlichen Start wird sie automatisch fortgesetzt.`, "success");
515800
+ return false;
515831
515801
  }
515832
515802
  function installRunningUpdateListener(tui) {
515833
515803
  const handler = (message) => {
515834
515804
  if (message?.type === RUNNING_UPDATE_PREPARED_MESSAGE && typeof message.version === "string" && (message.mode === RUNNING_UPDATE_MODES.RESUME || message.mode === RUNNING_UPDATE_MODES.NEW)) {
515835
515805
  tui.runningUpdatePreparedVersion = message.version;
515836
515806
  tui.runningUpdatePreparedMode = message.mode;
515837
- if (!requestRunningUpdateAtSafeBoundary(tui)) tui.showStatus(`Update ${message.version} ist bereit und wartet auf die naechste sichere Arbeitsgrenze.`, "success");
515838
- return;
515839
- }
515840
- if (message?.type !== RUNNING_UPDATE_HANDOFF_ACK_MESSAGE || tui.runningUpdateHandoffStarted !== true || message.version !== tui.runningUpdatePreparedVersion || message.mode !== tui.runningUpdatePreparedMode || message.sessionId !== tui.getCurrentSessionId()) return;
515841
- if (!isSafeRuntimeBoundary({
515842
- isShuttingDown: tui.isShuttingDown,
515843
- streamingPhase: tui.state.appState.streamingPhase,
515844
- isCompacting: tui.state.appState.isCompacting,
515845
- queuedMessages: tui.state.queuedMessages.length,
515846
- activeToolCalls: tui.streamingUI.hasActiveToolCalls() ? 1 : 0,
515847
- shellCommands: tui.shellOutputStreams.size,
515848
- queueCommandRunning: tui.queueCommandRunning
515849
- })) {
515850
- tui.runningUpdateHandoffStarted = false;
515851
- return;
515807
+ requestRunningUpdateAtSafeBoundary(tui);
515852
515808
  }
515853
- tui.showStatus(`Update ${message.version} wird aktiviert. Die Sitzung wird automatisch fortgesetzt.`, "success");
515854
- void tui.stop(RUNNING_UPDATE_HANDOFF_EXIT_CODE);
515855
515809
  };
515856
515810
  process.on("message", handler);
515857
515811
  return () => process.off("message", handler);
@@ -515943,7 +515897,7 @@ var BlunTUI = class {
515943
515897
  startupGoalPromptedSessionId;
515944
515898
  runningUpdatePreparedVersion;
515945
515899
  runningUpdatePreparedMode;
515946
- runningUpdateHandoffStarted = false;
515900
+ runningUpdatePreparedNoticeVersion;
515947
515901
  runningUpdateMessageDispose;
515948
515902
  startupPhaseMs = {};
515949
515903
  lastActivityMode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.316",
3
+ "version": "9.1.318",
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": {