billion-context 0.1.6 → 0.1.7

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
@@ -3221,31 +3221,46 @@ async function checkForUpdate(opts, force = false) {
3221
3221
  inFlight = true;
3222
3222
  try {
3223
3223
  const now = Date.now();
3224
- if (!force && now - await readLastCheck() < CHECK_INTERVAL_MS) return;
3224
+ const lastCheck = await readLastCheck();
3225
+ if (!force && now - lastCheck < CHECK_INTERVAL_MS) {
3226
+ log("info", `[update] check skipped (throttled, ${(CHECK_INTERVAL_MS - (now - lastCheck)) / 1e3 | 0}s until next)`);
3227
+ return;
3228
+ }
3225
3229
  await writeLastCheck(now);
3230
+ log("info", `[update] checking npm registry for ${opts.packageName}\u2026`);
3226
3231
  const url = `${REGISTRY_BASE}/${opts.packageName}/latest`;
3227
3232
  const res = await fetch(url, {
3228
3233
  signal: AbortSignal.timeout(5e3),
3229
3234
  headers: { Accept: "application/json" }
3230
3235
  });
3231
- if (!res.ok) return;
3236
+ if (!res.ok) {
3237
+ log("warn", `[update] registry returned ${res.status} ${res.statusText}, skipping`);
3238
+ return;
3239
+ }
3232
3240
  const data = await res.json();
3233
3241
  const latest = data.version;
3234
- if (!latest || !isNewer(latest, opts.currentVersion)) return;
3235
- if (notified.has(latest)) return;
3242
+ if (!latest) {
3243
+ log("warn", `[update] registry response had no version, skipping`);
3244
+ return;
3245
+ }
3246
+ if (!isNewer(latest, opts.currentVersion)) {
3247
+ log("info", `[update] current=${opts.currentVersion} latest=${latest} (up to date)`);
3248
+ return;
3249
+ }
3250
+ if (notified.has(latest)) {
3251
+ log("info", `[update] latest=${latest} already installed this run, awaiting restart`);
3252
+ return;
3253
+ }
3254
+ log("info", `[update] new version found: ${opts.currentVersion} \u2192 ${latest}, installing\u2026`);
3236
3255
  const installed = await installLatest(opts.packageName, latest);
3256
+ notified.add(latest);
3237
3257
  if (installed) {
3238
- notified.add(latest);
3239
- console.error(
3240
- `\x1B[32m\u2714 ${opts.packageName} auto-updated ${opts.currentVersion} \u2192 ${latest}. Restart bili to finish.\x1B[0m`
3241
- );
3258
+ log("info", `[update] installed ${opts.packageName} ${opts.currentVersion} \u2192 ${latest}. Restart to finish.`);
3242
3259
  } else {
3243
- notified.add(latest);
3244
- console.error(
3245
- `\x1B[33m${opts.packageName} ${latest} is available (you have ${opts.currentVersion}). Update with: npm install -g ${opts.packageName}@latest\x1B[0m`
3246
- );
3260
+ log("warn", `[update] install failed; run manually: npm install -g ${opts.packageName}@${latest}`);
3247
3261
  }
3248
- } catch {
3262
+ } catch (e) {
3263
+ log("warn", `[update] check failed: ${String(e)}`);
3249
3264
  } finally {
3250
3265
  inFlight = false;
3251
3266
  }
@@ -3267,6 +3282,7 @@ async function installLatest(packageName, latest) {
3267
3282
  }
3268
3283
  }
3269
3284
  function startAutoUpdate(opts) {
3285
+ log("info", `[update] auto-update enabled (checking every ${CHECK_INTERVAL_MS / 1e3 | 0}s)`);
3270
3286
  setTimeout(() => {
3271
3287
  void checkForUpdate(opts);
3272
3288
  }, 1e4);