@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/index.js
CHANGED
|
@@ -5702,11 +5702,10 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
5702
5702
|
modelsToTry = toolFiltered.slice(0, MAX_FALLBACK_ATTEMPTS);
|
|
5703
5703
|
modelsToTry = prioritizeNonRateLimited(modelsToTry);
|
|
5704
5704
|
} else {
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
}
|
|
5705
|
+
modelsToTry = modelId ? [modelId] : [];
|
|
5706
|
+
}
|
|
5707
|
+
if (!modelsToTry.includes(FREE_MODEL)) {
|
|
5708
|
+
modelsToTry.push(FREE_MODEL);
|
|
5710
5709
|
}
|
|
5711
5710
|
let upstream;
|
|
5712
5711
|
let lastError;
|
|
@@ -5740,6 +5739,19 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
5740
5739
|
if (result.errorStatus === 429) {
|
|
5741
5740
|
markRateLimited(tryModel);
|
|
5742
5741
|
}
|
|
5742
|
+
const isPaymentErr = /payment.*verification.*failed|insufficient.*funds/i.test(
|
|
5743
|
+
result.errorBody || ""
|
|
5744
|
+
);
|
|
5745
|
+
if (isPaymentErr && tryModel !== FREE_MODEL) {
|
|
5746
|
+
const freeIdx = modelsToTry.indexOf(FREE_MODEL);
|
|
5747
|
+
if (freeIdx > i + 1) {
|
|
5748
|
+
console.log(
|
|
5749
|
+
`[ClawRouter] Payment error \u2014 skipping to free model: ${FREE_MODEL}`
|
|
5750
|
+
);
|
|
5751
|
+
i = freeIdx - 1;
|
|
5752
|
+
continue;
|
|
5753
|
+
}
|
|
5754
|
+
}
|
|
5743
5755
|
console.log(
|
|
5744
5756
|
`[ClawRouter] Provider error from ${tryModel}, trying fallback: ${result.errorBody?.slice(0, 100)}`
|
|
5745
5757
|
);
|