@blockrun/clawrouter 0.12.65 → 0.12.66

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
@@ -49620,6 +49620,26 @@ data: [DONE]
49620
49620
  reason: result.errorCategory || `HTTP ${result.errorStatus || 500}`,
49621
49621
  status: result.errorStatus || 500
49622
49622
  });
49623
+ const isPaymentErr = /payment.*verification.*failed|payment.*settlement.*failed|insufficient.*funds|transaction_simulation_failed/i.test(
49624
+ result.errorBody || ""
49625
+ );
49626
+ if (isPaymentErr && tryModel !== FREE_MODEL && !isLastAttempt) {
49627
+ failedAttempts.push({
49628
+ ...failedAttempts[failedAttempts.length - 1],
49629
+ reason: "payment_error"
49630
+ });
49631
+ const freeIdx = modelsToTry.indexOf(FREE_MODEL);
49632
+ if (freeIdx > i + 1) {
49633
+ console.log(`[ClawRouter] Payment error \u2014 skipping to free model: ${FREE_MODEL}`);
49634
+ i = freeIdx - 1;
49635
+ continue;
49636
+ }
49637
+ if (freeIdx === -1) {
49638
+ modelsToTry.push(FREE_MODEL);
49639
+ console.log(`[ClawRouter] Payment error \u2014 appending free model: ${FREE_MODEL}`);
49640
+ continue;
49641
+ }
49642
+ }
49623
49643
  if (result.isProviderError && !isLastAttempt) {
49624
49644
  const isExplicitModelError = !routingDecision;
49625
49645
  const isUnknownExplicitModel = isExplicitModelError && /unknown.*model|invalid.*model/i.test(result.errorBody || "");
@@ -49697,17 +49717,6 @@ data: [DONE]
49697
49717
  `[ClawRouter] \u{1F511} ${errorCat === "auth_failure" ? "Auth failure" : "Quota exceeded"} for ${tryModel} \u2014 check provider config`
49698
49718
  );
49699
49719
  }
49700
- const isPaymentErr = /payment.*verification.*failed|payment.*settlement.*failed|insufficient.*funds|transaction_simulation_failed/i.test(
49701
- result.errorBody || ""
49702
- );
49703
- if (isPaymentErr && tryModel !== FREE_MODEL) {
49704
- const freeIdx = modelsToTry.indexOf(FREE_MODEL);
49705
- if (freeIdx > i + 1) {
49706
- console.log(`[ClawRouter] Payment error \u2014 skipping to free model: ${FREE_MODEL}`);
49707
- i = freeIdx - 1;
49708
- continue;
49709
- }
49710
- }
49711
49720
  console.log(
49712
49721
  `[ClawRouter] Provider error from ${tryModel}, trying fallback: ${result.errorBody?.slice(0, 100)}`
49713
49722
  );