@blockrun/clawrouter 0.10.20 → 0.10.21
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 +17 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5552,11 +5552,10 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
5552
5552
|
modelsToTry = toolFiltered.slice(0, MAX_FALLBACK_ATTEMPTS);
|
|
5553
5553
|
modelsToTry = prioritizeNonRateLimited(modelsToTry);
|
|
5554
5554
|
} else {
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
}
|
|
5555
|
+
modelsToTry = modelId ? [modelId] : [];
|
|
5556
|
+
}
|
|
5557
|
+
if (!modelsToTry.includes(FREE_MODEL)) {
|
|
5558
|
+
modelsToTry.push(FREE_MODEL);
|
|
5560
5559
|
}
|
|
5561
5560
|
let upstream;
|
|
5562
5561
|
let lastError;
|
|
@@ -5590,6 +5589,19 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
5590
5589
|
if (result.errorStatus === 429) {
|
|
5591
5590
|
markRateLimited(tryModel);
|
|
5592
5591
|
}
|
|
5592
|
+
const isPaymentErr = /payment.*verification.*failed|insufficient.*funds/i.test(
|
|
5593
|
+
result.errorBody || ""
|
|
5594
|
+
);
|
|
5595
|
+
if (isPaymentErr && tryModel !== FREE_MODEL) {
|
|
5596
|
+
const freeIdx = modelsToTry.indexOf(FREE_MODEL);
|
|
5597
|
+
if (freeIdx > i + 1) {
|
|
5598
|
+
console.log(
|
|
5599
|
+
`[ClawRouter] Payment error \u2014 skipping to free model: ${FREE_MODEL}`
|
|
5600
|
+
);
|
|
5601
|
+
i = freeIdx - 1;
|
|
5602
|
+
continue;
|
|
5603
|
+
}
|
|
5604
|
+
}
|
|
5593
5605
|
console.log(
|
|
5594
5606
|
`[ClawRouter] Provider error from ${tryModel}, trying fallback: ${result.errorBody?.slice(0, 100)}`
|
|
5595
5607
|
);
|