blun-king-cli 9.1.292 → 9.1.294

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,
@@ -380,15 +379,6 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
380
379
  toVersion: target.version,
381
380
  runningVersion,
382
381
  }, { now: options.nowImpl });
383
- if (previousTarget === undefined && child?.connected === true) {
384
- try {
385
- child.send({
386
- type: RUNNING_UPDATE_PREPARED_MESSAGE,
387
- version: target.version,
388
- mode: runningUpdateMode,
389
- });
390
- } catch {}
391
- }
392
382
  Promise.resolve((options.pruneRunningUpdateReleases || pruneRunningUpdateReleases)(sharedHome, {
393
383
  activePackageRoot: packageRoot,
394
384
  })).catch((error) => options.onRunningUpdateError?.(error));
@@ -22,6 +22,7 @@ const INSTALL_REGISTRY_URL = 'https://registry.npmjs.org/';
22
22
  const FALLBACK_MANIFEST_URL = 'https://chat.blun.ai/blun-code-version.json';
23
23
  const SNOOZE_MS = 7 * 24 * 60 * 60 * 1000;
24
24
  const REQUEST_TIMEOUT_MS = 2_500;
25
+ const UPDATE_SOURCE_RETRY_DELAYS_MS = Object.freeze([250, 750]);
25
26
  const STATE_FILE = 'update-notice.json';
26
27
  const UPDATE_SKIP_FILE = 'update-skip-version.json';
27
28
  const PENDING_UPDATE_FILE = 'update-pending.json';
@@ -385,10 +386,54 @@ function requestTrustedJson(url, options = {}) {
385
386
  });
386
387
  }
387
388
 
388
- async function loadReleaseSources() {
389
+ function retryableUpdateSourceError(error) {
390
+ const message = error instanceof Error ? error.message : String(error || '');
391
+ if (message === 'UPDATE_REQUEST_TIMEOUT') return true;
392
+ const statusMatch = /^UPDATE_HTTP_STATUS_(\d{3})$/u.exec(message);
393
+ if (statusMatch) {
394
+ const status = Number(statusMatch[1]);
395
+ return status === 408 || status === 425 || status === 429 || status >= 500;
396
+ }
397
+ return new Set([
398
+ 'EAI_AGAIN',
399
+ 'ECONNREFUSED',
400
+ 'ECONNRESET',
401
+ 'ENETDOWN',
402
+ 'ENETUNREACH',
403
+ 'ENOTFOUND',
404
+ 'EPIPE',
405
+ 'ETIMEDOUT',
406
+ ]).has(error?.code);
407
+ }
408
+
409
+ function sleepForUpdateRetry(delayMs) {
410
+ return new Promise((resolve) => setTimeout(resolve, delayMs));
411
+ }
412
+
413
+ async function requestTrustedJsonWithRetry(url, options = {}) {
414
+ const request = options.request || requestTrustedJson;
415
+ const sleep = options.sleep || sleepForUpdateRetry;
416
+ const configuredDelays = Array.isArray(options.retryDelaysMs)
417
+ ? options.retryDelaysMs
418
+ : UPDATE_SOURCE_RETRY_DELAYS_MS;
419
+ const retryDelaysMs = configuredDelays
420
+ .slice(0, UPDATE_SOURCE_RETRY_DELAYS_MS.length)
421
+ .map((value) => (Number.isFinite(value) && value >= 0 ? Math.min(value, 2_000) : 0));
422
+
423
+ for (let attempt = 0; ; attempt += 1) {
424
+ try {
425
+ return await request(url, options);
426
+ } catch (error) {
427
+ if (attempt >= retryDelaysMs.length || !retryableUpdateSourceError(error)) throw error;
428
+ await sleep(retryDelaysMs[attempt]);
429
+ }
430
+ }
431
+ }
432
+
433
+ async function loadReleaseSources(options = {}) {
389
434
  const [registry, fallback] = await Promise.allSettled([
390
- requestTrustedJson(REGISTRY_URL),
391
- requestTrustedJson(FALLBACK_MANIFEST_URL),
435
+ requestTrustedJsonWithRetry(REGISTRY_URL, options),
436
+ requestTrustedJsonWithRetry(FALLBACK_MANIFEST_URL, options),
392
437
  ]);
393
438
  return {
394
439
  registryDocument: registry.status === 'fulfilled' ? registry.value : undefined,
@@ -1636,6 +1681,7 @@ module.exports = {
1636
1681
  readSkippedVersion,
1637
1682
  readSnoozeState,
1638
1683
  requestTrustedJson,
1684
+ requestTrustedJsonWithRetry,
1639
1685
  resolveEffectiveRelease,
1640
1686
  runExplicitUpdate,
1641
1687
  runUpdateNotice,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.292",
3
+ "version": "9.1.294",
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": {