@blockrun/clawrouter 0.12.316 → 0.12.317

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.
Files changed (3) hide show
  1. package/dist/cli.js +34 -11
  2. package/dist/index.js +34 -11
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -60319,14 +60319,30 @@ function cloneLimits(limits) {
60319
60319
  }
60320
60320
  return clone2;
60321
60321
  }
60322
- function recordKey(r2) {
60323
- return r2.id ?? `${r2.timestamp}|${r2.amount}|${r2.model ?? ""}|${r2.action ?? ""}`;
60324
- }
60325
60322
  function mergeSpendHistory(a, b) {
60326
- const byKey = /* @__PURE__ */ new Map();
60327
- for (const r2 of a) byKey.set(recordKey(r2), r2);
60328
- for (const r2 of b) if (!byKey.has(recordKey(r2))) byKey.set(recordKey(r2), r2);
60329
- return [...byKey.values()].sort((x, y) => x.timestamp - y.timestamp);
60323
+ const merged = [];
60324
+ const ids = /* @__PURE__ */ new Set();
60325
+ const legacyKept = /* @__PURE__ */ new Map();
60326
+ for (const ledger2 of [a, b]) {
60327
+ const legacySeen = /* @__PURE__ */ new Map();
60328
+ for (const r2 of ledger2) {
60329
+ if (r2.id !== void 0) {
60330
+ if (!ids.has(r2.id)) {
60331
+ ids.add(r2.id);
60332
+ merged.push(r2);
60333
+ }
60334
+ continue;
60335
+ }
60336
+ const key3 = `${r2.timestamp}|${r2.amount}|${r2.model ?? ""}|${r2.action ?? ""}`;
60337
+ const nth = (legacySeen.get(key3) ?? 0) + 1;
60338
+ legacySeen.set(key3, nth);
60339
+ if (nth > (legacyKept.get(key3) ?? 0)) {
60340
+ legacyKept.set(key3, nth);
60341
+ merged.push(r2);
60342
+ }
60343
+ }
60344
+ }
60345
+ return merged.sort((x, y) => x.timestamp - y.timestamp);
60330
60346
  }
60331
60347
  function canonicalLimits(limits) {
60332
60348
  return JSON.stringify(
@@ -91788,12 +91804,19 @@ var init_session = __esm({
91788
91804
  });
91789
91805
 
91790
91806
  // src/updater.ts
91807
+ function versionCore(version31) {
91808
+ const core = version31.split(/[+-]/, 1)[0] ?? "";
91809
+ return core.split(".").map((part) => {
91810
+ const value = Number(part);
91811
+ return Number.isFinite(value) ? value : 0;
91812
+ });
91813
+ }
91791
91814
  function compareSemver(a, b) {
91792
- const pa = a.split(".").map(Number);
91793
- const pb = b.split(".").map(Number);
91815
+ const pa = versionCore(a);
91816
+ const pb = versionCore(b);
91794
91817
  for (let i = 0; i < 3; i++) {
91795
- if ((pa[i] || 0) > (pb[i] || 0)) return 1;
91796
- if ((pa[i] || 0) < (pb[i] || 0)) return -1;
91818
+ if ((pa[i] ?? 0) > (pb[i] ?? 0)) return 1;
91819
+ if ((pa[i] ?? 0) < (pb[i] ?? 0)) return -1;
91797
91820
  }
91798
91821
  return 0;
91799
91822
  }
package/dist/index.js CHANGED
@@ -282618,14 +282618,30 @@ function cloneLimits(limits) {
282618
282618
  }
282619
282619
  return clone2;
282620
282620
  }
282621
- function recordKey(r2) {
282622
- return r2.id ?? `${r2.timestamp}|${r2.amount}|${r2.model ?? ""}|${r2.action ?? ""}`;
282623
- }
282624
282621
  function mergeSpendHistory(a, b) {
282625
- const byKey = /* @__PURE__ */ new Map();
282626
- for (const r2 of a) byKey.set(recordKey(r2), r2);
282627
- for (const r2 of b) if (!byKey.has(recordKey(r2))) byKey.set(recordKey(r2), r2);
282628
- return [...byKey.values()].sort((x, y) => x.timestamp - y.timestamp);
282622
+ const merged = [];
282623
+ const ids = /* @__PURE__ */ new Set();
282624
+ const legacyKept = /* @__PURE__ */ new Map();
282625
+ for (const ledger2 of [a, b]) {
282626
+ const legacySeen = /* @__PURE__ */ new Map();
282627
+ for (const r2 of ledger2) {
282628
+ if (r2.id !== void 0) {
282629
+ if (!ids.has(r2.id)) {
282630
+ ids.add(r2.id);
282631
+ merged.push(r2);
282632
+ }
282633
+ continue;
282634
+ }
282635
+ const key3 = `${r2.timestamp}|${r2.amount}|${r2.model ?? ""}|${r2.action ?? ""}`;
282636
+ const nth = (legacySeen.get(key3) ?? 0) + 1;
282637
+ legacySeen.set(key3, nth);
282638
+ if (nth > (legacyKept.get(key3) ?? 0)) {
282639
+ legacyKept.set(key3, nth);
282640
+ merged.push(r2);
282641
+ }
282642
+ }
282643
+ }
282644
+ return merged.sort((x, y) => x.timestamp - y.timestamp);
282629
282645
  }
282630
282646
  function canonicalLimits(limits) {
282631
282647
  return JSON.stringify(
@@ -291226,12 +291242,19 @@ function hashRequestContent(lastUserContent, toolCallNames) {
291226
291242
  // src/updater.ts
291227
291243
  var NPM_REGISTRY = "https://registry.npmjs.org/@blockrun/clawrouter/latest";
291228
291244
  var CHECK_TIMEOUT_MS = 5e3;
291245
+ function versionCore(version31) {
291246
+ const core = version31.split(/[+-]/, 1)[0] ?? "";
291247
+ return core.split(".").map((part) => {
291248
+ const value = Number(part);
291249
+ return Number.isFinite(value) ? value : 0;
291250
+ });
291251
+ }
291229
291252
  function compareSemver(a, b) {
291230
- const pa = a.split(".").map(Number);
291231
- const pb = b.split(".").map(Number);
291253
+ const pa = versionCore(a);
291254
+ const pb = versionCore(b);
291232
291255
  for (let i = 0; i < 3; i++) {
291233
- if ((pa[i] || 0) > (pb[i] || 0)) return 1;
291234
- if ((pa[i] || 0) < (pb[i] || 0)) return -1;
291256
+ if ((pa[i] ?? 0) > (pb[i] ?? 0)) return 1;
291257
+ if ((pa[i] ?? 0) < (pb[i] ?? 0)) return -1;
291235
291258
  }
291236
291259
  return 0;
291237
291260
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/clawrouter",
3
- "version": "0.12.316",
3
+ "version": "0.12.317",
4
4
  "description": "Smart LLM router — save 84% on inference costs. 91 models (8 free). Pay by credit card (API key) or USDC (x402 wallet).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",