@blockrun/clawrouter 0.12.299 → 0.12.301
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/cli.js +14 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -43186,7 +43186,7 @@ function createPayFetchWithPreAuth(baseFetch, client, ttlMs = DEFAULT_TTL_MS, op
|
|
|
43186
43186
|
}
|
|
43187
43187
|
};
|
|
43188
43188
|
const cached = !options?.skipPreAuth ? cache2.get(cacheKey3) : void 0;
|
|
43189
|
-
const preAuthCovers = cached !== void 0 && Date.now() - cached.cachedAt < ttlMs && cached.coverMicros !== void 0 && needMicros !== void 0 && needMicros <= cached.coverMicros;
|
|
43189
|
+
const preAuthCovers = cached !== void 0 && Date.now() - cached.cachedAt < ttlMs && cached.coverMicros !== void 0 && needMicros !== void 0 && needMicros <= cached.coverMicros && cached.coverMicros <= needMicros * (1 + PREAUTH_OVERPAY_TOLERANCE);
|
|
43190
43190
|
if (preAuthCovers) {
|
|
43191
43191
|
let paymentInFlight = false;
|
|
43192
43192
|
try {
|
|
@@ -43355,7 +43355,7 @@ function receiptChargedMicros(response) {
|
|
|
43355
43355
|
}
|
|
43356
43356
|
return void 0;
|
|
43357
43357
|
}
|
|
43358
|
-
var DEFAULT_TTL_MS, PaymentInDoubtError;
|
|
43358
|
+
var DEFAULT_TTL_MS, PREAUTH_OVERPAY_TOLERANCE, PaymentInDoubtError;
|
|
43359
43359
|
var init_payment_preauth = __esm({
|
|
43360
43360
|
"src/payment-preauth.ts"() {
|
|
43361
43361
|
"use strict";
|
|
@@ -43363,6 +43363,7 @@ var init_payment_preauth = __esm({
|
|
|
43363
43363
|
init_max_tokens();
|
|
43364
43364
|
init_spend_control();
|
|
43365
43365
|
DEFAULT_TTL_MS = 36e5;
|
|
43366
|
+
PREAUTH_OVERPAY_TOLERANCE = 0.03;
|
|
43366
43367
|
PaymentInDoubtError = class extends Error {
|
|
43367
43368
|
constructor(cause) {
|
|
43368
43369
|
super(
|
|
@@ -48767,7 +48768,8 @@ async function parseLogFile(filePath) {
|
|
|
48767
48768
|
cost: entry.cost || 0,
|
|
48768
48769
|
baselineCost: entry.baselineCost || entry.cost || 0,
|
|
48769
48770
|
savings: entry.savings || 0,
|
|
48770
|
-
latencyMs: entry.latencyMs || 0
|
|
48771
|
+
latencyMs: entry.latencyMs || 0,
|
|
48772
|
+
status: entry.status === "error" || entry.status === "success" ? entry.status : void 0
|
|
48771
48773
|
});
|
|
48772
48774
|
} catch {
|
|
48773
48775
|
}
|
|
@@ -48821,11 +48823,17 @@ async function getStats(days = 7) {
|
|
|
48821
48823
|
let totalCost = 0;
|
|
48822
48824
|
let totalBaselineCost = 0;
|
|
48823
48825
|
let totalLatency = 0;
|
|
48826
|
+
let errorCount = 0;
|
|
48824
48827
|
for (const file of filesToRead) {
|
|
48825
48828
|
const date = file.replace("usage-", "").replace(".jsonl", "");
|
|
48826
48829
|
const filePath = join6(LOG_DIR2, file);
|
|
48827
48830
|
const entries = await parseLogFile(filePath);
|
|
48828
48831
|
if (entries.length === 0) continue;
|
|
48832
|
+
for (const entry of entries) {
|
|
48833
|
+
if (entry.status === "error") {
|
|
48834
|
+
errorCount++;
|
|
48835
|
+
}
|
|
48836
|
+
}
|
|
48829
48837
|
const dayStats = aggregateDay(date, entries);
|
|
48830
48838
|
dailyBreakdown.push(dayStats);
|
|
48831
48839
|
totalRequests += dayStats.totalRequests;
|
|
@@ -48878,8 +48886,9 @@ async function getStats(days = 7) {
|
|
|
48878
48886
|
byModel: byModelWithPercentage,
|
|
48879
48887
|
dailyBreakdown: dailyBreakdown.reverse(),
|
|
48880
48888
|
// Oldest first for charts
|
|
48881
|
-
entriesWithBaseline
|
|
48889
|
+
entriesWithBaseline,
|
|
48882
48890
|
// How many entries have valid baseline tracking
|
|
48891
|
+
errorCount
|
|
48883
48892
|
};
|
|
48884
48893
|
}
|
|
48885
48894
|
function formatStatsAscii(stats) {
|
|
@@ -287489,8 +287498,7 @@ async function collectLogInfo() {
|
|
|
287489
287498
|
return {
|
|
287490
287499
|
requestsLast24h: stats.totalRequests,
|
|
287491
287500
|
costLast24h: `$${stats.totalCost.toFixed(4)}`,
|
|
287492
|
-
errorsFound:
|
|
287493
|
-
// TODO: parse error logs
|
|
287501
|
+
errorsFound: stats.errorCount
|
|
287494
287502
|
};
|
|
287495
287503
|
} catch {
|
|
287496
287504
|
return {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -255465,6 +255465,7 @@ function formatDuration(seconds) {
|
|
|
255465
255465
|
|
|
255466
255466
|
// src/payment-preauth.ts
|
|
255467
255467
|
var DEFAULT_TTL_MS = 36e5;
|
|
255468
|
+
var PREAUTH_OVERPAY_TOLERANCE = 0.03;
|
|
255468
255469
|
var PaymentInDoubtError = class extends Error {
|
|
255469
255470
|
constructor(cause) {
|
|
255470
255471
|
super(
|
|
@@ -255538,7 +255539,7 @@ function createPayFetchWithPreAuth(baseFetch, client, ttlMs = DEFAULT_TTL_MS, op
|
|
|
255538
255539
|
}
|
|
255539
255540
|
};
|
|
255540
255541
|
const cached = !options?.skipPreAuth ? cache2.get(cacheKey3) : void 0;
|
|
255541
|
-
const preAuthCovers = cached !== void 0 && Date.now() - cached.cachedAt < ttlMs && cached.coverMicros !== void 0 && needMicros !== void 0 && needMicros <= cached.coverMicros;
|
|
255542
|
+
const preAuthCovers = cached !== void 0 && Date.now() - cached.cachedAt < ttlMs && cached.coverMicros !== void 0 && needMicros !== void 0 && needMicros <= cached.coverMicros && cached.coverMicros <= needMicros * (1 + PREAUTH_OVERPAY_TOLERANCE);
|
|
255542
255543
|
if (preAuthCovers) {
|
|
255543
255544
|
let paymentInFlight = false;
|
|
255544
255545
|
try {
|
|
@@ -260852,7 +260853,8 @@ async function parseLogFile(filePath) {
|
|
|
260852
260853
|
cost: entry.cost || 0,
|
|
260853
260854
|
baselineCost: entry.baselineCost || entry.cost || 0,
|
|
260854
260855
|
savings: entry.savings || 0,
|
|
260855
|
-
latencyMs: entry.latencyMs || 0
|
|
260856
|
+
latencyMs: entry.latencyMs || 0,
|
|
260857
|
+
status: entry.status === "error" || entry.status === "success" ? entry.status : void 0
|
|
260856
260858
|
});
|
|
260857
260859
|
} catch {
|
|
260858
260860
|
}
|
|
@@ -260906,11 +260908,17 @@ async function getStats(days = 7) {
|
|
|
260906
260908
|
let totalCost = 0;
|
|
260907
260909
|
let totalBaselineCost = 0;
|
|
260908
260910
|
let totalLatency = 0;
|
|
260911
|
+
let errorCount = 0;
|
|
260909
260912
|
for (const file of filesToRead) {
|
|
260910
260913
|
const date = file.replace("usage-", "").replace(".jsonl", "");
|
|
260911
260914
|
const filePath = join6(LOG_DIR2, file);
|
|
260912
260915
|
const entries = await parseLogFile(filePath);
|
|
260913
260916
|
if (entries.length === 0) continue;
|
|
260917
|
+
for (const entry of entries) {
|
|
260918
|
+
if (entry.status === "error") {
|
|
260919
|
+
errorCount++;
|
|
260920
|
+
}
|
|
260921
|
+
}
|
|
260914
260922
|
const dayStats = aggregateDay(date, entries);
|
|
260915
260923
|
dailyBreakdown.push(dayStats);
|
|
260916
260924
|
totalRequests += dayStats.totalRequests;
|
|
@@ -260963,8 +260971,9 @@ async function getStats(days = 7) {
|
|
|
260963
260971
|
byModel: byModelWithPercentage,
|
|
260964
260972
|
dailyBreakdown: dailyBreakdown.reverse(),
|
|
260965
260973
|
// Oldest first for charts
|
|
260966
|
-
entriesWithBaseline
|
|
260974
|
+
entriesWithBaseline,
|
|
260967
260975
|
// How many entries have valid baseline tracking
|
|
260976
|
+
errorCount
|
|
260968
260977
|
};
|
|
260969
260978
|
}
|
|
260970
260979
|
function formatStatsAscii(stats) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockrun/clawrouter",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.301",
|
|
4
4
|
"description": "Smart LLM router — save 84% on inference costs. 90 models (7 free). Pay by credit card (API key) or USDC (x402 wallet).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|