@blockrun/clawrouter 0.12.266 → 0.12.267

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 CHANGED
@@ -32955,6 +32955,7 @@ function createPayFetchWithPreAuth(baseFetch, client, ttlMs = DEFAULT_TTL_MS, op
32955
32955
  const cached = !options?.skipPreAuth ? cache2.get(cacheKey2) : void 0;
32956
32956
  const preAuthCovers = cached !== void 0 && Date.now() - cached.cachedAt < ttlMs && cached.coverMicros !== void 0 && needMicros !== void 0 && needMicros <= cached.coverMicros;
32957
32957
  if (preAuthCovers) {
32958
+ let paymentInFlight = false;
32958
32959
  try {
32959
32960
  const payload2 = await client.createPaymentPayload(cached.paymentRequired);
32960
32961
  const headers = httpClient.encodePaymentSignatureHeader(payload2);
@@ -32962,16 +32963,21 @@ function createPayFetchWithPreAuth(baseFetch, client, ttlMs = DEFAULT_TTL_MS, op
32962
32963
  for (const [key2, value] of Object.entries(headers)) {
32963
32964
  preAuthRequest.headers.set(key2, value);
32964
32965
  }
32966
+ paymentInFlight = true;
32965
32967
  const response2 = await baseFetch(preAuthRequest);
32966
32968
  if (response2.status !== 402) {
32967
32969
  return response2;
32968
32970
  }
32971
+ paymentInFlight = false;
32969
32972
  cache2.delete(cacheKey2);
32970
32973
  } catch (err) {
32971
32974
  cache2.delete(cacheKey2);
32972
32975
  if (err instanceof SpendPolicyError) {
32973
32976
  throw err;
32974
32977
  }
32978
+ if (paymentInFlight) {
32979
+ throw err;
32980
+ }
32975
32981
  }
32976
32982
  }
32977
32983
  const clonedRequest = request2.clone();
package/dist/index.js CHANGED
@@ -35091,6 +35091,7 @@ function createPayFetchWithPreAuth(baseFetch, client, ttlMs = DEFAULT_TTL_MS, op
35091
35091
  const cached = !options?.skipPreAuth ? cache2.get(cacheKey2) : void 0;
35092
35092
  const preAuthCovers = cached !== void 0 && Date.now() - cached.cachedAt < ttlMs && cached.coverMicros !== void 0 && needMicros !== void 0 && needMicros <= cached.coverMicros;
35093
35093
  if (preAuthCovers) {
35094
+ let paymentInFlight = false;
35094
35095
  try {
35095
35096
  const payload2 = await client.createPaymentPayload(cached.paymentRequired);
35096
35097
  const headers = httpClient.encodePaymentSignatureHeader(payload2);
@@ -35098,16 +35099,21 @@ function createPayFetchWithPreAuth(baseFetch, client, ttlMs = DEFAULT_TTL_MS, op
35098
35099
  for (const [key2, value] of Object.entries(headers)) {
35099
35100
  preAuthRequest.headers.set(key2, value);
35100
35101
  }
35102
+ paymentInFlight = true;
35101
35103
  const response2 = await baseFetch(preAuthRequest);
35102
35104
  if (response2.status !== 402) {
35103
35105
  return response2;
35104
35106
  }
35107
+ paymentInFlight = false;
35105
35108
  cache2.delete(cacheKey2);
35106
35109
  } catch (err) {
35107
35110
  cache2.delete(cacheKey2);
35108
35111
  if (err instanceof SpendPolicyError) {
35109
35112
  throw err;
35110
35113
  }
35114
+ if (paymentInFlight) {
35115
+ throw err;
35116
+ }
35111
35117
  }
35112
35118
  }
35113
35119
  const clonedRequest = request2.clone();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/clawrouter",
3
- "version": "0.12.266",
3
+ "version": "0.12.267",
4
4
  "description": "Smart LLM router — save 84% on inference costs. 76 models (7 free), one wallet, x402 micropayments.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",