blun-king-cli 9.1.231 → 9.1.232

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.
@@ -267,6 +267,33 @@ function resolveHandoffCwd(candidate, fallback) {
267
267
  }
268
268
  }
269
269
 
270
+ function isAutomaticRunningUpdateMode(mode) {
271
+ return mode === RUNNING_UPDATE_MODES.RESUME || mode === RUNNING_UPDATE_MODES.NEW;
272
+ }
273
+
274
+ async function prepareAutomaticStartupRuntime(options) {
275
+ if (options.existingRuntime !== undefined) return options.existingRuntime;
276
+ const runningUpdateMode = readRunningUpdateMode(options.profileHome);
277
+ if (!isAutomaticRunningUpdateMode(runningUpdateMode)) return undefined;
278
+ const target = await (options.prepareRunningUpdate || prepareRunningUpdate)({
279
+ currentVersion: options.currentVersion,
280
+ sharedHome: options.sharedHome,
281
+ env: options.env,
282
+ });
283
+ if (target === null) return undefined;
284
+ (options.stageRuntime || stageRuntime)(options.sharedHome, target, {
285
+ mode: runningUpdateMode,
286
+ cwd: options.cwd,
287
+ });
288
+ (options.recordRunningUpdateEvent || recordRunningUpdateEvent)(options.sharedHome, {
289
+ event: 'prepared-on-cold-start',
290
+ fromVersion: options.currentVersion,
291
+ toVersion: target.version,
292
+ });
293
+ return (options.readPendingRuntime || readPendingRuntime)(options.sharedHome)
294
+ || Object.freeze({ ...target, mode: runningUpdateMode, cwd: options.cwd });
295
+ }
296
+
270
297
  function shouldRecoverActivatedRuntime(result, recovery, options = {}) {
271
298
  if (recovery === undefined || options.runtimeExitIntent === true) return false;
272
299
  const signal = result?.signal;
@@ -697,6 +724,19 @@ async function runLauncher(options = {}) {
697
724
  const blunDir = profilePaths.home;
698
725
  ensurePrivateDirectory(blunDir);
699
726
 
727
+ const runningUpdateMode = readRunningUpdateMode(profilePaths.home);
728
+ if (deferredPendingRuntime === undefined && isAutomaticRunningUpdateMode(runningUpdateMode)) {
729
+ try {
730
+ deferredPendingRuntime = await prepareAutomaticStartupRuntime({
731
+ currentVersion: readPackageVersion(),
732
+ cwd: callerCwd,
733
+ env: process.env,
734
+ profileHome: profilePaths.home,
735
+ sharedHome: privatePaths.sharedHome,
736
+ });
737
+ } catch {}
738
+ }
739
+
700
740
  // --- 1. Oeffentlicher npm-Update-Dialog. -------------------------------
701
741
  const updateResult = options.skipUpdateNotice === true
702
742
  ? { kind: 'continue', reason: 'notice_busy' }
@@ -710,6 +750,7 @@ async function runLauncher(options = {}) {
710
750
  blunDir: privatePaths.sharedHome,
711
751
  packageRoot: PKG,
712
752
  preparedRuntime: deferredPendingRuntime,
753
+ autoInstallPreparedRuntime: isAutomaticRunningUpdateMode(runningUpdateMode),
713
754
  noticeLease,
714
755
  });
715
756
  if (updateResult.kind === 'installed'
@@ -798,6 +839,7 @@ module.exports = {
798
839
  RUNNING_UPDATE_RECHECK_MS,
799
840
  RUNNING_UPDATE_STABILIZATION_MS,
800
841
  createManagedNodeEnvironment,
842
+ prepareAutomaticStartupRuntime,
801
843
  resolveLauncherPrivatePaths,
802
844
  resolveHandoffCwd,
803
845
  runningUpdateRecheckDelay,
@@ -1400,8 +1400,11 @@ async function runUpdateFlow(options, explicitUpdate) {
1400
1400
  && typeof preparedRuntime.packageRoot === 'string'
1401
1401
  && path.isAbsolute(preparedRuntime.packageRoot)
1402
1402
  && verifyInstalledPackageVersion(preparedRuntime.packageRoot, release.version);
1403
+ const automaticPreparedRuntimeReady = options.autoInstallPreparedRuntime === true
1404
+ && preparedRuntimeReady;
1403
1405
  if (!explicitUpdate
1404
1406
  && pendingVersion === undefined
1407
+ && !automaticPreparedRuntimeReady
1405
1408
  && readSnoozeState(blunDir, release.version, now)) {
1406
1409
  return { kind: 'continue', reason: 'snoozed' };
1407
1410
  }
@@ -1417,7 +1420,10 @@ async function runUpdateFlow(options, explicitUpdate) {
1417
1420
  ? explicitFailure(stderr, 'lease_unavailable')
1418
1421
  : { kind: 'continue', reason: 'lease_unavailable' };
1419
1422
  }
1420
- if (!explicitUpdate && !queuedForRelease && readSkippedVersion(blunDir) === release.version) {
1423
+ if (!explicitUpdate
1424
+ && !queuedForRelease
1425
+ && !automaticPreparedRuntimeReady
1426
+ && readSkippedVersion(blunDir) === release.version) {
1421
1427
  return { kind: 'continue', reason: 'skipped_version' };
1422
1428
  }
1423
1429
  if (explicitUpdate || queuedForRelease) {
@@ -1460,7 +1466,7 @@ async function runUpdateFlow(options, explicitUpdate) {
1460
1466
  }
1461
1467
  }
1462
1468
  let action;
1463
- if (explicitUpdate || queuedForRelease) {
1469
+ if (explicitUpdate || queuedForRelease || automaticPreparedRuntimeReady) {
1464
1470
  action = 'install';
1465
1471
  } else {
1466
1472
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.231",
3
+ "version": "9.1.232",
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": {