@blockrun/clawrouter 0.8.18 → 0.8.19

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
@@ -2372,6 +2372,42 @@ function getSessionId(headers, headerName = DEFAULT_SESSION_CONFIG.headerName) {
2372
2372
  return void 0;
2373
2373
  }
2374
2374
 
2375
+ // src/updater.ts
2376
+ var NPM_REGISTRY = "https://registry.npmjs.org/@blockrun/clawrouter/latest";
2377
+ var UPDATE_URL = "https://blockrun.ai/ClawRouter-update";
2378
+ var CHECK_TIMEOUT_MS = 5e3;
2379
+ function compareSemver(a, b) {
2380
+ const pa = a.split(".").map(Number);
2381
+ const pb = b.split(".").map(Number);
2382
+ for (let i = 0; i < 3; i++) {
2383
+ if ((pa[i] || 0) > (pb[i] || 0)) return 1;
2384
+ if ((pa[i] || 0) < (pb[i] || 0)) return -1;
2385
+ }
2386
+ return 0;
2387
+ }
2388
+ async function checkForUpdates() {
2389
+ try {
2390
+ const controller = new AbortController();
2391
+ const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS);
2392
+ const res = await fetch(NPM_REGISTRY, {
2393
+ signal: controller.signal,
2394
+ headers: { Accept: "application/json" }
2395
+ });
2396
+ clearTimeout(timeout);
2397
+ if (!res.ok) return;
2398
+ const data = await res.json();
2399
+ const latest = data.version;
2400
+ if (!latest) return;
2401
+ if (compareSemver(latest, VERSION) > 0) {
2402
+ console.log("");
2403
+ console.log(`\x1B[33m\u2B06\uFE0F ClawRouter ${latest} available (you have ${VERSION})\x1B[0m`);
2404
+ console.log(` Run: \x1B[36mcurl -fsSL ${UPDATE_URL} | bash\x1B[0m`);
2405
+ console.log("");
2406
+ }
2407
+ } catch {
2408
+ }
2409
+ }
2410
+
2375
2411
  // src/proxy.ts
2376
2412
  var BLOCKRUN_API = "https://blockrun.ai/api";
2377
2413
  var AUTO_MODEL = "blockrun/auto";
@@ -2917,6 +2953,7 @@ async function startProxy(options) {
2917
2953
  const port = addr.port;
2918
2954
  const baseUrl = `http://127.0.0.1:${port}`;
2919
2955
  options.onReady?.(port);
2956
+ checkForUpdates();
2920
2957
  server.on("error", (err) => {
2921
2958
  console.error(`[ClawRouter] Server runtime error: ${err.message}`);
2922
2959
  options.onError?.(err);