blun-king-cli 9.1.291 → 9.1.293

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.
@@ -34,7 +34,6 @@ const {
34
34
  RUNNING_UPDATE_HANDOFF_EXIT_CODE,
35
35
  RUNNING_UPDATE_HANDOFF_MESSAGE,
36
36
  RUNNING_UPDATE_MODE_MESSAGE,
37
- RUNNING_UPDATE_PREPARED_MESSAGE,
38
37
  RUNTIME_EXIT_INTENT_MESSAGE,
39
38
  activateRuntime,
40
39
  clearActiveRuntime,
@@ -314,6 +313,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
314
313
  let updateStarted = false;
315
314
  let runtimeReady = false;
316
315
  let runtimeExitIntent = false;
316
+ let supervisionCompleted = false;
317
317
  let runningUpdatePollTimer;
318
318
  let runningUpdateMode = readRunningUpdateMode(env.BLUN_HOME);
319
319
  const automaticMode = () => runningUpdateMode === RUNNING_UPDATE_MODES.RESUME
@@ -331,7 +331,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
331
331
  };
332
332
  const scheduleNextPreparation = (child) => {
333
333
  clearRunningUpdatePoll();
334
- if (preparedTarget !== undefined || updateStarted) return;
334
+ if (supervisionCompleted || pendingHandoff !== undefined || updateStarted) return;
335
335
  runningUpdatePollTimer = (options.scheduleRunningUpdateRecheck || scheduleRunningUpdateRecheck)(() => {
336
336
  runningUpdatePollTimer = undefined;
337
337
  refreshRunningUpdateMode();
@@ -340,7 +340,8 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
340
340
  });
341
341
  };
342
342
  const startPreparation = (child) => {
343
- if (updateStarted || options.runningUpdate === false || !automaticMode()) return;
343
+ if (supervisionCompleted || pendingHandoff !== undefined || updateStarted
344
+ || options.runningUpdate === false || !automaticMode()) return;
344
345
  updateStarted = true;
345
346
  const sharedHome = env.BLUN_SHARED_HOME;
346
347
  if (typeof sharedHome !== 'string' || sharedHome.length === 0) {
@@ -358,26 +359,31 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
358
359
  scheduleNextPreparation(child);
359
360
  return;
360
361
  }
362
+ const previousTarget = preparedTarget;
363
+ if (previousTarget !== undefined
364
+ && compareSemver(target.version, previousTarget.version) !== 1) {
365
+ updateStarted = false;
366
+ scheduleNextPreparation(child);
367
+ return;
368
+ }
361
369
  preparedTarget = target;
362
370
  (options.stageRuntime || stageRuntime)(sharedHome, target, { mode: runningUpdateMode });
363
- (options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, {
371
+ const runningVersion = readPackageVersionAt(packageRoot);
372
+ (options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, previousTarget === undefined ? {
364
373
  event: 'prepared-for-next-start',
365
- fromVersion: readPackageVersionAt(packageRoot),
374
+ fromVersion: runningVersion,
375
+ toVersion: target.version,
376
+ } : {
377
+ event: 'prepared-target-refreshed',
378
+ fromVersion: previousTarget.version,
366
379
  toVersion: target.version,
380
+ runningVersion,
367
381
  }, { now: options.nowImpl });
368
- if (child?.connected === true) {
369
- try {
370
- child.send({
371
- type: RUNNING_UPDATE_PREPARED_MESSAGE,
372
- version: target.version,
373
- mode: runningUpdateMode,
374
- });
375
- } catch {}
376
- }
377
382
  Promise.resolve((options.pruneRunningUpdateReleases || pruneRunningUpdateReleases)(sharedHome, {
378
383
  activePackageRoot: packageRoot,
379
384
  })).catch((error) => options.onRunningUpdateError?.(error));
380
- clearRunningUpdatePoll();
385
+ updateStarted = false;
386
+ scheduleNextPreparation(child);
381
387
  }).catch((error) => {
382
388
  updateStarted = false;
383
389
  options.onRunningUpdateError?.(error);
@@ -401,6 +407,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
401
407
  sessionId: message.sessionId,
402
408
  target: preparedTarget,
403
409
  });
410
+ clearRunningUpdatePoll();
404
411
  if (child?.connected === true) {
405
412
  try {
406
413
  child.send({
@@ -411,6 +418,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
411
418
  });
412
419
  } catch {
413
420
  pendingHandoff = undefined;
421
+ scheduleNextPreparation(child);
414
422
  }
415
423
  }
416
424
  }
@@ -424,10 +432,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
424
432
  runningUpdateMode = normalizeRunningUpdateMode(message.mode);
425
433
  clearRunningUpdatePoll();
426
434
  if (automaticMode()) {
427
- if (preparedTarget === undefined && runtimeReady) {
428
- updateStarted = false;
429
- startPreparation(child);
430
- }
435
+ if (runtimeReady && !updateStarted) startPreparation(child);
431
436
  } else if (runtimeReady) scheduleNextPreparation(child);
432
437
  }
433
438
  };
@@ -468,6 +473,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
468
473
  }
469
474
  await releaseNotice();
470
475
  const result = await core.completed;
476
+ supervisionCompleted = true;
471
477
  clearRunningUpdatePoll();
472
478
  if (existingMessageHandler) core.child.off('message', existingMessageHandler);
473
479
  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.293",
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": {