blun-king-cli 9.1.214 → 9.1.215

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,6 +30,7 @@ const { acquireSharedRuntimeLease, tryAcquireUpdateLease } = require('./update-l
30
30
  const { compareSemver, runExplicitUpdate, runUpdateNotice } = require('./update-notice');
31
31
  const {
32
32
  RUNNING_UPDATE_HANDOFF_EXIT_CODE,
33
+ RUNNING_UPDATE_HANDOFF_ACK_MESSAGE,
33
34
  RUNNING_UPDATE_HANDOFF_MESSAGE,
34
35
  RUNNING_UPDATE_MODE_MESSAGE,
35
36
  RUNNING_UPDATE_PREPARED_MESSAGE,
@@ -397,12 +398,26 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
397
398
  handoffSessionId = message.sessionId;
398
399
  handoffMode = runningUpdateMode;
399
400
  handoffCwd = resolveHandoffCwd(message.cwd, cwd);
400
- if (preparedTarget !== undefined) {
401
- (options.stageRuntime || stageRuntime)(env.BLUN_SHARED_HOME, preparedTarget, {
402
- mode: handoffMode,
403
- sessionId: handoffSessionId,
404
- cwd: handoffCwd,
405
- });
401
+ if (preparedTarget !== undefined && message.version === preparedTarget.version) {
402
+ try {
403
+ (options.stageRuntime || stageRuntime)(env.BLUN_SHARED_HOME, preparedTarget, {
404
+ mode: handoffMode,
405
+ sessionId: handoffSessionId,
406
+ cwd: handoffCwd,
407
+ });
408
+ child.send({
409
+ type: RUNNING_UPDATE_HANDOFF_ACK_MESSAGE,
410
+ version: preparedTarget.version,
411
+ mode: handoffMode,
412
+ sessionId: handoffSessionId,
413
+ }, (error) => {
414
+ if (error) options.onRunningUpdateError?.(error);
415
+ });
416
+ } catch (error) {
417
+ handoffSessionId = undefined;
418
+ handoffMode = undefined;
419
+ options.onRunningUpdateError?.(error);
420
+ }
406
421
  }
407
422
  }
408
423
  };
@@ -471,6 +486,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
471
486
  },
472
487
  activateTarget: async (target) => {
473
488
  await (options.activateRuntime || activateRuntime)(env.BLUN_SHARED_HOME, target);
489
+ (options.clearPendingRuntime || clearPendingRuntime)(env.BLUN_SHARED_HOME, target);
474
490
  (options.recordRunningUpdateEvent || recordRunningUpdateEvent)(env.BLUN_SHARED_HOME, {
475
491
  event: 'activated',
476
492
  fromVersion: readPackageVersionAt(packageRoot),
@@ -485,6 +501,9 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
485
501
  }
486
502
  },
487
503
  });
504
+ if (handoff.kind !== 'activated') {
505
+ (options.clearPendingRuntime || clearPendingRuntime)(env.BLUN_SHARED_HOME, preparedTarget);
506
+ }
488
507
  const resumed = handoff.core;
489
508
  if (resumed === undefined || resumed.ready !== true) return 1;
490
509
  const resumedArgs = handoffArgsForMode(args, handoffMode, handoffSessionId);
@@ -16,6 +16,7 @@ const REGISTRY_URL = 'https://registry.npmjs.org/blun-king-cli';
16
16
  const ACTIVE_RUNTIME_FILE = 'active-runtime.json';
17
17
  const PENDING_RUNTIME_FILE = 'pending-runtime.json';
18
18
  const RUNNING_UPDATE_HANDOFF_EXIT_CODE = 76;
19
+ const RUNNING_UPDATE_HANDOFF_ACK_MESSAGE = 'blun-running-update-handoff-ack';
19
20
  const RUNNING_UPDATE_PREPARED_MESSAGE = 'blun-running-update-prepared';
20
21
  const RUNNING_UPDATE_HANDOFF_MESSAGE = 'blun-running-update-handoff';
21
22
  const RUNNING_UPDATE_MODE_MESSAGE = 'blun-running-update-mode';
@@ -559,6 +560,7 @@ module.exports = {
559
560
  PENDING_RUNTIME_FILE,
560
561
  AUTO_UPDATE_SETTLE_MS,
561
562
  RUNNING_UPDATE_HANDOFF_EXIT_CODE,
563
+ RUNNING_UPDATE_HANDOFF_ACK_MESSAGE,
562
564
  RUNNING_UPDATE_HANDOFF_MESSAGE,
563
565
  RUNNING_UPDATE_MODE_MESSAGE,
564
566
  RUNNING_UPDATE_PREPARED_MESSAGE,
package/blun.mjs CHANGED
@@ -502555,7 +502555,10 @@ var ChannelQueueDeadlineController = class {
502555
502555
  }
502556
502556
  requestDeliveryNow() {
502557
502557
  if (this.retainReleaseWhileDeliveryIsInFlight()) return;
502558
- if (this.host.hasWaitingWork() && !this.host.canDeliverWork()) return;
502558
+ if (this.host.hasWaitingWork() && !this.host.canDeliverWork()) {
502559
+ this.scheduleRetry();
502560
+ return;
502561
+ }
502559
502562
  this.requestDelivery();
502560
502563
  }
502561
502564
  retainReleaseWhileDeliveryIsInFlight() {
@@ -515086,6 +515089,7 @@ function turnsToTrim(turns, maxTurns, hysteresis) {
515086
515089
  const {
515087
515090
  AUTO_UPDATE_SETTLE_MS,
515088
515091
  RUNNING_UPDATE_HANDOFF_EXIT_CODE,
515092
+ RUNNING_UPDATE_HANDOFF_ACK_MESSAGE,
515089
515093
  RUNNING_UPDATE_HANDOFF_MESSAGE,
515090
515094
  RUNNING_UPDATE_MODE_MESSAGE,
515091
515095
  RUNNING_UPDATE_PREPARED_MESSAGE,
@@ -515148,10 +515152,29 @@ function requestRunningUpdateAtSafeBoundary(tui) {
515148
515152
  }
515149
515153
  function installRunningUpdateListener(tui) {
515150
515154
  const handler = (message) => {
515155
+ if (message?.type === RUNNING_UPDATE_HANDOFF_ACK_MESSAGE) {
515156
+ if (!tui.runningUpdateHandoffStarted || message.version !== tui.runningUpdatePreparedVersion || message.mode !== tui.runningUpdatePreparedMode || message.sessionId !== tui.getCurrentSessionId()) return;
515157
+ if (!isSafeRuntimeBoundary({
515158
+ isShuttingDown: tui.isShuttingDown,
515159
+ streamingPhase: tui.state.appState.streamingPhase,
515160
+ isCompacting: tui.state.appState.isCompacting,
515161
+ queuedMessages: tui.state.queuedMessages.length,
515162
+ activeToolCalls: tui.streamingUI.hasActiveToolCalls() ? 1 : 0,
515163
+ shellCommands: tui.shellOutputStreams.size,
515164
+ queueCommandRunning: tui.queueCommandRunning
515165
+ })) {
515166
+ tui.runningUpdateHandoffStarted = false;
515167
+ return;
515168
+ }
515169
+ tui.showStatus("Ein Update wird geladen und die TUI wird neu gestartet.", "success");
515170
+ void tui.stop(RUNNING_UPDATE_HANDOFF_EXIT_CODE).catch(() => {
515171
+ tui.runningUpdateHandoffStarted = false;
515172
+ });
515173
+ return;
515174
+ }
515151
515175
  if (message?.type !== RUNNING_UPDATE_PREPARED_MESSAGE || typeof message.version !== "string" || message.mode !== RUNNING_UPDATE_MODES.RESUME && message.mode !== RUNNING_UPDATE_MODES.NEW) return;
515152
515176
  tui.runningUpdatePreparedVersion = message.version;
515153
515177
  tui.runningUpdatePreparedMode = message.mode;
515154
- tui.showStatus(`Update ${message.version} ist bereit und wird beim nächsten Start aktiviert.`, "success");
515155
515178
  requestRunningUpdateAtSafeBoundary(tui);
515156
515179
  };
515157
515180
  process.on("message", handler);
@@ -516033,7 +516056,8 @@ var BlunTUI = class {
516033
516056
  }
516034
516057
  canDeliverQueuedChannelHead() {
516035
516058
  const item = this.state.queuedMessages[0];
516036
- if (this.isShuttingDown || this.queueCommandRunning || this.queueSteerInFlight !== void 0 || this.editorReplacementActive || this.deferUserMessages || this.session === void 0 || this.state.appState.model.trim().length === 0 || this.state.appState.streamingPhase === "idle" || this.state.appState.streamingPhase === "shell" || item?.mode !== "channel") return false;
516059
+ const hasActiveTurn = this.streamingUI.hasActiveTurn() || (this.state.appState.streamingPhase !== "idle" && this.state.appState.streamingPhase !== "shell");
516060
+ if (this.isShuttingDown || this.queueCommandRunning || this.queueSteerInFlight !== void 0 || this.editorReplacementActive || this.deferUserMessages || this.session === void 0 || this.state.appState.model.trim().length === 0 || !hasActiveTurn || item?.mode !== "channel") return false;
516037
516061
  return true;
516038
516062
  }
516039
516063
  async deliverQueuedChannelHead() {
@@ -516224,7 +516248,8 @@ var BlunTUI = class {
516224
516248
  this.scheduleQueueDrain();
516225
516249
  }
516226
516250
  steerQueueFlushPrefix() {
516227
- if (this.queueSteerInFlight !== void 0 || this.queueFlushBatchRemaining === 0 || this.deferUserMessages || this.state.appState.isCompacting || this.state.appState.streamingPhase === "idle" || this.state.appState.streamingPhase === "shell") return;
516251
+ const hasActiveTurn = this.streamingUI.hasActiveTurn() || this.state.appState.streamingPhase !== "idle";
516252
+ if (this.queueSteerInFlight !== void 0 || this.queueFlushBatchRemaining === 0 || this.deferUserMessages || this.state.appState.isCompacting || this.state.appState.streamingPhase === "shell" || !hasActiveTurn) return;
516228
516253
  const session = this.session;
516229
516254
  if (session === void 0 || this.state.appState.model.trim().length === 0) {
516230
516255
  this.showError(llmNotSetMessage());
@@ -516337,7 +516362,7 @@ var BlunTUI = class {
516337
516362
  channelAcknowledge: acknowledge,
516338
516363
  ...envelope.meta["image_path"] !== void 0 ? { channelImagePath: envelope.meta["image_path"] } : {}
516339
516364
  });
516340
- this.syncChannelQueueDeadline();
516365
+ this.channelQueueDeadline.requestDeliveryNow();
516341
516366
  this.scheduleQueueDrain();
516342
516367
  this.track("input_queue");
516343
516368
  this.updateQueueDisplay();
@@ -516809,7 +516834,7 @@ var BlunTUI = class {
516809
516834
  this.sendTelegramRemoteCommandMessage(session, input, options, telegramContext);
516810
516835
  return;
516811
516836
  }
516812
- if (this.deferUserMessages || this.state.appState.streamingPhase !== "idle" || this.state.appState.isCompacting) {
516837
+ if (this.deferUserMessages || this.streamingUI.hasActiveTurn() || this.state.appState.streamingPhase !== "idle" || this.state.appState.isCompacting) {
516813
516838
  this.enqueueMessage(input, options);
516814
516839
  return;
516815
516840
  }
@@ -516820,7 +516845,8 @@ var BlunTUI = class {
516820
516845
  for (const part of input) this.enqueueMessage(part);
516821
516846
  return;
516822
516847
  }
516823
- if (this.state.appState.streamingPhase === "idle") {
516848
+ const hasActiveTurn = this.streamingUI.hasActiveTurn() || this.state.appState.streamingPhase !== "idle";
516849
+ if (!hasActiveTurn) {
516824
516850
  for (const part of input) this.sendMessageInternal(session, part);
516825
516851
  return;
516826
516852
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.214",
3
+ "version": "9.1.215",
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": {