@blockrun/clawrouter 0.12.13 → 0.12.17

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.d.ts CHANGED
@@ -504,6 +504,7 @@ declare class SolanaBalanceMonitor {
504
504
  formatUSDC(amountMicros: bigint): string;
505
505
  getWalletAddress(): string;
506
506
  private fetchBalance;
507
+ private fetchBalanceOnce;
507
508
  private buildInfo;
508
509
  }
509
510
 
package/dist/index.js CHANGED
@@ -83,6 +83,14 @@ var init_solana_balance = __esm({
83
83
  async fetchBalance() {
84
84
  const owner = solAddress(this.walletAddress);
85
85
  const mint = solAddress(SOLANA_USDC_MINT);
86
+ for (let attempt = 0; attempt < 2; attempt++) {
87
+ const result = await this.fetchBalanceOnce(owner, mint);
88
+ if (result > 0n || attempt === 1) return result;
89
+ await new Promise((r) => setTimeout(r, 1e3));
90
+ }
91
+ return 0n;
92
+ }
93
+ async fetchBalanceOnce(owner, mint) {
86
94
  const controller = new AbortController();
87
95
  const timer = setTimeout(() => controller.abort(), BALANCE_TIMEOUT_MS);
88
96
  try {
@@ -1021,6 +1029,13 @@ function resolveModelAlias(model) {
1021
1029
  if (resolvedWithoutPrefix) return resolvedWithoutPrefix;
1022
1030
  return withoutPrefix;
1023
1031
  }
1032
+ if (normalized.startsWith("openai/")) {
1033
+ const withoutPrefix = normalized.slice("openai/".length);
1034
+ const resolvedWithoutPrefix = MODEL_ALIASES[withoutPrefix];
1035
+ if (resolvedWithoutPrefix) return resolvedWithoutPrefix;
1036
+ const isVirtualProfile = BLOCKRUN_MODELS.some((m) => m.id === withoutPrefix);
1037
+ if (isVirtualProfile) return withoutPrefix;
1038
+ }
1024
1039
  return model;
1025
1040
  }
1026
1041
  var BLOCKRUN_MODELS = [
@@ -4134,7 +4149,14 @@ async function generateAndSaveWallet() {
4134
4149
  const existingMnemonic = await loadMnemonic();
4135
4150
  if (existingMnemonic) {
4136
4151
  throw new Error(
4137
- `Mnemonic file exists at ${MNEMONIC_FILE} but wallet.key is missing. This means a Solana wallet was derived from this mnemonic. Refusing to generate a new wallet to protect Solana funds. Restore your EVM key with: export BLOCKRUN_WALLET_KEY=<your_key>`
4152
+ `Mnemonic file exists at ${MNEMONIC_FILE} but wallet.key is missing.
4153
+ Refusing to generate a new wallet to protect existing funds.
4154
+
4155
+ Restore your EVM private key using one of:
4156
+ Windows: set BLOCKRUN_WALLET_KEY=0x<your_key>
4157
+ Mac/Linux: export BLOCKRUN_WALLET_KEY=0x<your_key>
4158
+
4159
+ Then run: npx @blockrun/clawrouter`
4138
4160
  );
4139
4161
  }
4140
4162
  const mnemonic = generateWalletMnemonic();
@@ -6845,9 +6867,9 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
6845
6867
  const normalizedModel = typeof parsed.model === "string" ? parsed.model.trim().toLowerCase() : "";
6846
6868
  const resolvedModel = resolveModelAlias(normalizedModel);
6847
6869
  const wasAlias = resolvedModel !== normalizedModel;
6848
- const isRoutingProfile = ROUTING_PROFILES.has(normalizedModel);
6870
+ const isRoutingProfile = ROUTING_PROFILES.has(normalizedModel) || ROUTING_PROFILES.has(resolvedModel);
6849
6871
  if (isRoutingProfile) {
6850
- const profileName = normalizedModel.replace("blockrun/", "");
6872
+ const profileName = resolvedModel.replace("blockrun/", "");
6851
6873
  routingProfile = profileName;
6852
6874
  }
6853
6875
  console.log(