billion-context 0.1.9 → 0.1.12

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.
package/dist/index.js CHANGED
@@ -3277,15 +3277,18 @@ async function checkForUpdate(opts, force = false) {
3277
3277
  if (!opts.autoUpdate && !force) return;
3278
3278
  if (inFlight) return;
3279
3279
  inFlight = true;
3280
+ const firstInProcess = !notified.has("__first_check_done__");
3280
3281
  try {
3281
3282
  const now = Date.now();
3282
3283
  const lastCheck = await readLastCheck();
3283
- if (!force && now - lastCheck < CHECK_INTERVAL_MS) {
3284
- log("info", `[update] check skipped (throttled, ${(CHECK_INTERVAL_MS - (now - lastCheck)) / 1e3 | 0}s until next)`);
3284
+ const sinceLastSec = lastCheck ? (now - lastCheck) / 1e3 | 0 : -1;
3285
+ if (!force && !firstInProcess && now - lastCheck < CHECK_INTERVAL_MS) {
3286
+ const retryIn = (CHECK_INTERVAL_MS - (now - lastCheck)) / 1e3 | 0;
3287
+ log("info", `[update] throttled \u2014 last checked ${sinceLastSec}s ago, retry in ${retryIn}s`);
3285
3288
  return;
3286
3289
  }
3287
3290
  await writeLastCheck(now);
3288
- log("info", `[update] checking npm registry for ${opts.packageName}\u2026`);
3291
+ log("info", `[update] checking npm registry for ${opts.packageName}${firstInProcess ? " (startup check)" : sinceLastSec < 0 ? "" : ` (last check ${sinceLastSec}s ago)`}\u2026`);
3289
3292
  const url = `${REGISTRY_BASE}/${opts.packageName}/latest`;
3290
3293
  const res = await fetch(url, {
3291
3294
  signal: AbortSignal.timeout(5e3),
@@ -3311,16 +3314,17 @@ async function checkForUpdate(opts, force = false) {
3311
3314
  }
3312
3315
  log("info", `[update] new version found: ${opts.currentVersion} \u2192 ${latest}, installing\u2026`);
3313
3316
  const installed = await installLatest(opts.packageName, latest);
3314
- notified.add(latest);
3315
3317
  if (installed) {
3318
+ notified.add(latest);
3316
3319
  log("info", `[update] installed ${opts.packageName} ${opts.currentVersion} \u2192 ${latest}. Restart to finish.`);
3317
3320
  } else {
3318
- log("warn", `[update] install failed; run manually: npm install -g ${opts.packageName}@${latest}`);
3321
+ log("warn", `[update] install failed; will retry next cycle. Or: npm install -g ${opts.packageName}@${latest}`);
3319
3322
  }
3320
3323
  } catch (e) {
3321
3324
  log("warn", `[update] check failed: ${String(e)}`);
3322
3325
  } finally {
3323
3326
  inFlight = false;
3327
+ notified.add("__first_check_done__");
3324
3328
  }
3325
3329
  }
3326
3330
  async function installLatest(packageName, latest) {