blun-king-cli 9.1.291 → 9.1.292

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.
@@ -314,6 +314,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
314
314
  let updateStarted = false;
315
315
  let runtimeReady = false;
316
316
  let runtimeExitIntent = false;
317
+ let supervisionCompleted = false;
317
318
  let runningUpdatePollTimer;
318
319
  let runningUpdateMode = readRunningUpdateMode(env.BLUN_HOME);
319
320
  const automaticMode = () => runningUpdateMode === RUNNING_UPDATE_MODES.RESUME
@@ -331,7 +332,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
331
332
  };
332
333
  const scheduleNextPreparation = (child) => {
333
334
  clearRunningUpdatePoll();
334
- if (preparedTarget !== undefined || updateStarted) return;
335
+ if (supervisionCompleted || pendingHandoff !== undefined || updateStarted) return;
335
336
  runningUpdatePollTimer = (options.scheduleRunningUpdateRecheck || scheduleRunningUpdateRecheck)(() => {
336
337
  runningUpdatePollTimer = undefined;
337
338
  refreshRunningUpdateMode();
@@ -340,7 +341,8 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
340
341
  });
341
342
  };
342
343
  const startPreparation = (child) => {
343
- if (updateStarted || options.runningUpdate === false || !automaticMode()) return;
344
+ if (supervisionCompleted || pendingHandoff !== undefined || updateStarted
345
+ || options.runningUpdate === false || !automaticMode()) return;
344
346
  updateStarted = true;
345
347
  const sharedHome = env.BLUN_SHARED_HOME;
346
348
  if (typeof sharedHome !== 'string' || sharedHome.length === 0) {
@@ -358,14 +360,27 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
358
360
  scheduleNextPreparation(child);
359
361
  return;
360
362
  }
363
+ const previousTarget = preparedTarget;
364
+ if (previousTarget !== undefined
365
+ && compareSemver(target.version, previousTarget.version) !== 1) {
366
+ updateStarted = false;
367
+ scheduleNextPreparation(child);
368
+ return;
369
+ }
361
370
  preparedTarget = target;
362
371
  (options.stageRuntime || stageRuntime)(sharedHome, target, { mode: runningUpdateMode });
363
- (options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, {
372
+ const runningVersion = readPackageVersionAt(packageRoot);
373
+ (options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, previousTarget === undefined ? {
364
374
  event: 'prepared-for-next-start',
365
- fromVersion: readPackageVersionAt(packageRoot),
375
+ fromVersion: runningVersion,
376
+ toVersion: target.version,
377
+ } : {
378
+ event: 'prepared-target-refreshed',
379
+ fromVersion: previousTarget.version,
366
380
  toVersion: target.version,
381
+ runningVersion,
367
382
  }, { now: options.nowImpl });
368
- if (child?.connected === true) {
383
+ if (previousTarget === undefined && child?.connected === true) {
369
384
  try {
370
385
  child.send({
371
386
  type: RUNNING_UPDATE_PREPARED_MESSAGE,
@@ -377,7 +392,8 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
377
392
  Promise.resolve((options.pruneRunningUpdateReleases || pruneRunningUpdateReleases)(sharedHome, {
378
393
  activePackageRoot: packageRoot,
379
394
  })).catch((error) => options.onRunningUpdateError?.(error));
380
- clearRunningUpdatePoll();
395
+ updateStarted = false;
396
+ scheduleNextPreparation(child);
381
397
  }).catch((error) => {
382
398
  updateStarted = false;
383
399
  options.onRunningUpdateError?.(error);
@@ -401,6 +417,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
401
417
  sessionId: message.sessionId,
402
418
  target: preparedTarget,
403
419
  });
420
+ clearRunningUpdatePoll();
404
421
  if (child?.connected === true) {
405
422
  try {
406
423
  child.send({
@@ -411,6 +428,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
411
428
  });
412
429
  } catch {
413
430
  pendingHandoff = undefined;
431
+ scheduleNextPreparation(child);
414
432
  }
415
433
  }
416
434
  }
@@ -424,10 +442,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
424
442
  runningUpdateMode = normalizeRunningUpdateMode(message.mode);
425
443
  clearRunningUpdatePoll();
426
444
  if (automaticMode()) {
427
- if (preparedTarget === undefined && runtimeReady) {
428
- updateStarted = false;
429
- startPreparation(child);
430
- }
445
+ if (runtimeReady && !updateStarted) startPreparation(child);
431
446
  } else if (runtimeReady) scheduleNextPreparation(child);
432
447
  }
433
448
  };
@@ -468,6 +483,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
468
483
  }
469
484
  await releaseNotice();
470
485
  const result = await core.completed;
486
+ supervisionCompleted = true;
471
487
  clearRunningUpdatePoll();
472
488
  if (existingMessageHandler) core.child.off('message', existingMessageHandler);
473
489
  if (result.code === RUNNING_UPDATE_HANDOFF_EXIT_CODE && pendingHandoff !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.291",
3
+ "version": "9.1.292",
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": {