billion-context 0.1.5 → 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
@@ -3185,6 +3185,7 @@ var THROTTLE_FILE = path4.join(cacheDir(), ".update-check");
3185
3185
  var SEMVER_RE = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/;
3186
3186
  var timer;
3187
3187
  var inFlight = false;
3188
+ var notified = /* @__PURE__ */ new Set();
3188
3189
  function parseVersion(v) {
3189
3190
  return v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
3190
3191
  }
@@ -3220,28 +3221,46 @@ async function checkForUpdate(opts, force = false) {
3220
3221
  inFlight = true;
3221
3222
  try {
3222
3223
  const now = Date.now();
3223
- 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
+ }
3224
3229
  await writeLastCheck(now);
3230
+ log("info", `[update] checking npm registry for ${opts.packageName}\u2026`);
3225
3231
  const url = `${REGISTRY_BASE}/${opts.packageName}/latest`;
3226
3232
  const res = await fetch(url, {
3227
3233
  signal: AbortSignal.timeout(5e3),
3228
3234
  headers: { Accept: "application/json" }
3229
3235
  });
3230
- if (!res.ok) return;
3236
+ if (!res.ok) {
3237
+ log("warn", `[update] registry returned ${res.status} ${res.statusText}, skipping`);
3238
+ return;
3239
+ }
3231
3240
  const data = await res.json();
3232
3241
  const latest = data.version;
3233
- if (!latest || !isNewer(latest, opts.currentVersion)) 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`);
3234
3255
  const installed = await installLatest(opts.packageName, latest);
3256
+ notified.add(latest);
3235
3257
  if (installed) {
3236
- console.error(
3237
- `\x1B[32m\u2714 ${opts.packageName} auto-updated ${opts.currentVersion} \u2192 ${latest}. Restart bili to finish.\x1B[0m`
3238
- );
3258
+ log("info", `[update] installed ${opts.packageName} ${opts.currentVersion} \u2192 ${latest}. Restart to finish.`);
3239
3259
  } else {
3240
- console.error(
3241
- `\x1B[33m${opts.packageName} ${latest} is available (you have ${opts.currentVersion}). Update with: npm install -g ${opts.packageName}@latest\x1B[0m`
3242
- );
3260
+ log("warn", `[update] install failed; run manually: npm install -g ${opts.packageName}@${latest}`);
3243
3261
  }
3244
- } catch {
3262
+ } catch (e) {
3263
+ log("warn", `[update] check failed: ${String(e)}`);
3245
3264
  } finally {
3246
3265
  inFlight = false;
3247
3266
  }
@@ -3263,6 +3282,7 @@ async function installLatest(packageName, latest) {
3263
3282
  }
3264
3283
  }
3265
3284
  function startAutoUpdate(opts) {
3285
+ log("info", `[update] auto-update enabled (checking every ${CHECK_INTERVAL_MS / 1e3 | 0}s)`);
3266
3286
  setTimeout(() => {
3267
3287
  void checkForUpdate(opts);
3268
3288
  }, 1e4);