@blockrun/clawrouter 0.12.68 → 0.12.70

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
@@ -497,6 +497,11 @@ declare class SolanaBalanceMonitor {
497
497
  */
498
498
  formatUSDC(amountMicros: bigint): string;
499
499
  getWalletAddress(): string;
500
+ /**
501
+ * Check native SOL balance (in lamports). Useful for detecting users who
502
+ * funded with SOL instead of USDC.
503
+ */
504
+ checkSolBalance(): Promise<bigint>;
500
505
  private fetchBalance;
501
506
  private fetchBalanceOnce;
502
507
  private buildInfo;
@@ -870,6 +875,10 @@ type BlockRunModel = {
870
875
  * Default: false (must opt-in to prevent silent regressions on new models).
871
876
  */
872
877
  toolCalling?: boolean;
878
+ /** Model is deprecated — will be routed to fallbackModel if set */
879
+ deprecated?: boolean;
880
+ /** Model ID to route to when this model is deprecated */
881
+ fallbackModel?: string;
873
882
  };
874
883
  declare const BLOCKRUN_MODELS: BlockRunModel[];
875
884
  /**
package/dist/index.js CHANGED
@@ -31728,6 +31728,23 @@ var init_solana_balance = __esm({
31728
31728
  getWalletAddress() {
31729
31729
  return this.walletAddress;
31730
31730
  }
31731
+ /**
31732
+ * Check native SOL balance (in lamports). Useful for detecting users who
31733
+ * funded with SOL instead of USDC.
31734
+ */
31735
+ async checkSolBalance() {
31736
+ const controller = new AbortController();
31737
+ const timer = setTimeout(() => controller.abort(), BALANCE_TIMEOUT_MS);
31738
+ try {
31739
+ const owner = address(this.walletAddress);
31740
+ const response = await this.rpc.getBalance(owner).send({ abortSignal: controller.signal });
31741
+ return BigInt(response.value);
31742
+ } catch {
31743
+ return 0n;
31744
+ } finally {
31745
+ clearTimeout(timer);
31746
+ }
31747
+ }
31731
31748
  async fetchBalance() {
31732
31749
  const owner = address(this.walletAddress);
31733
31750
  const mint = address(SOLANA_USDC_MINT);
@@ -32856,6 +32873,9 @@ var MODEL_ALIASES = {
32856
32873
  gpt5: "openai/gpt-5.4",
32857
32874
  "gpt-5.4": "openai/gpt-5.4",
32858
32875
  "gpt-5.4-pro": "openai/gpt-5.4-pro",
32876
+ "gpt-5.4-nano": "openai/gpt-5.4-nano",
32877
+ nano: "openai/gpt-5.4-nano",
32878
+ "gpt-5-nano": "openai/gpt-5.4-nano",
32859
32879
  codex: "openai/gpt-5.3-codex",
32860
32880
  mini: "openai/gpt-4o-mini",
32861
32881
  o1: "openai/o1",
@@ -32873,6 +32893,7 @@ var MODEL_ALIASES = {
32873
32893
  flash: "google/gemini-2.5-flash",
32874
32894
  "gemini-3.1-pro-preview": "google/gemini-3.1-pro",
32875
32895
  "google/gemini-3.1-pro-preview": "google/gemini-3.1-pro",
32896
+ "gemini-3.1-flash-lite": "google/gemini-3.1-flash-lite",
32876
32897
  // xAI
32877
32898
  grok: "xai/grok-3",
32878
32899
  "grok-fast": "xai/grok-4-fast-reasoning",
@@ -32988,7 +33009,9 @@ var BLOCKRUN_MODELS = [
32988
33009
  outputPrice: 0.4,
32989
33010
  contextWindow: 128e3,
32990
33011
  maxOutput: 32768,
32991
- toolCalling: true
33012
+ toolCalling: true,
33013
+ deprecated: true,
33014
+ fallbackModel: "openai/gpt-5.4-nano"
32992
33015
  },
32993
33016
  {
32994
33017
  id: "openai/gpt-5.2-pro",
@@ -33026,6 +33049,16 @@ var BLOCKRUN_MODELS = [
33026
33049
  reasoning: true,
33027
33050
  toolCalling: true
33028
33051
  },
33052
+ {
33053
+ id: "openai/gpt-5.4-nano",
33054
+ name: "GPT-5.4 Nano",
33055
+ version: "5.4",
33056
+ inputPrice: 0.2,
33057
+ outputPrice: 1.25,
33058
+ contextWindow: 105e4,
33059
+ maxOutput: 32768,
33060
+ toolCalling: true
33061
+ },
33029
33062
  // OpenAI GPT-5.3 Family
33030
33063
  {
33031
33064
  id: "openai/gpt-5.3",
@@ -33270,6 +33303,16 @@ var BLOCKRUN_MODELS = [
33270
33303
  maxOutput: 65536,
33271
33304
  toolCalling: true
33272
33305
  },
33306
+ {
33307
+ id: "google/gemini-3.1-flash-lite",
33308
+ name: "Gemini 3.1 Flash Lite",
33309
+ version: "3.1",
33310
+ inputPrice: 0.25,
33311
+ outputPrice: 1.5,
33312
+ contextWindow: 1e6,
33313
+ maxOutput: 8192,
33314
+ toolCalling: true
33315
+ },
33273
33316
  // DeepSeek
33274
33317
  {
33275
33318
  id: "deepseek/deepseek-chat",
@@ -44678,8 +44721,12 @@ var DEFAULT_ROUTING_CONFIG = {
44678
44721
  // 1,431ms, IQ 32, 41% retention
44679
44722
  "moonshot/kimi-k2.5",
44680
44723
  // 1,646ms, IQ 47, strong quality
44724
+ "google/gemini-3.1-flash-lite",
44725
+ // $0.25/$1.50, 1M context — newest flash-lite
44681
44726
  "google/gemini-2.5-flash-lite",
44682
- // 1,353ms, 1M context, ultra cheap ($0.10/$0.40)
44727
+ // 1,353ms, $0.10/$0.40
44728
+ "openai/gpt-5.4-nano",
44729
+ // $0.20/$1.25, 1M context
44683
44730
  "xai/grok-4-fast-non-reasoning",
44684
44731
  // 1,143ms, $0.20/$0.50 — fast fallback
44685
44732
  "nvidia/gpt-oss-120b"
@@ -44696,8 +44743,10 @@ var DEFAULT_ROUTING_CONFIG = {
44696
44743
  // 1,431ms, IQ 32, 41% retention
44697
44744
  "google/gemini-2.5-flash",
44698
44745
  // 1,238ms, 60% retention
44746
+ "google/gemini-3.1-flash-lite",
44747
+ // $0.25/$1.50, 1M context
44699
44748
  "google/gemini-2.5-flash-lite",
44700
- // 1,353ms, 1M context ($0.10/$0.40)
44749
+ // 1,353ms, $0.10/$0.40
44701
44750
  "xai/grok-4-1-fast-non-reasoning",
44702
44751
  // 1,244ms, fast fallback
44703
44752
  "xai/grok-3-mini"
@@ -44747,28 +44796,38 @@ var DEFAULT_ROUTING_CONFIG = {
44747
44796
  primary: "nvidia/gpt-oss-120b",
44748
44797
  // 1,252ms, FREE! $0.00/$0.00
44749
44798
  fallback: [
44799
+ "google/gemini-3.1-flash-lite",
44800
+ // $0.25/$1.50 — newest flash-lite
44801
+ "openai/gpt-5.4-nano",
44802
+ // $0.20/$1.25 — fast nano
44750
44803
  "google/gemini-2.5-flash-lite",
44751
44804
  // 1,353ms, $0.10/$0.40
44752
- "xai/grok-4-fast-non-reasoning",
44805
+ "xai/grok-4-fast-non-reasoning"
44753
44806
  // 1,143ms, $0.20/$0.50
44754
- "google/gemini-2.5-flash"
44755
- // 1,238ms
44756
44807
  ]
44757
44808
  },
44758
44809
  MEDIUM: {
44759
- primary: "google/gemini-2.5-flash-lite",
44760
- // 1,353ms, $0.10/$0.40 - cheapest capable with 1M context
44810
+ primary: "google/gemini-3.1-flash-lite",
44811
+ // $0.25/$1.50 1M context, newest flash-lite
44761
44812
  fallback: [
44813
+ "openai/gpt-5.4-nano",
44814
+ // $0.20/$1.25, 1M context
44815
+ "google/gemini-2.5-flash-lite",
44816
+ // 1,353ms, $0.10/$0.40
44762
44817
  "xai/grok-4-fast-non-reasoning",
44763
44818
  "google/gemini-2.5-flash",
44764
- "deepseek/deepseek-chat",
44765
44819
  "nvidia/gpt-oss-120b"
44766
44820
  ]
44767
44821
  },
44768
44822
  COMPLEX: {
44769
- primary: "google/gemini-2.5-flash-lite",
44770
- // 1,353ms, $0.10/$0.40 - 1M context handles complexity
44771
- fallback: ["xai/grok-4-0709", "google/gemini-2.5-flash", "deepseek/deepseek-chat"]
44823
+ primary: "google/gemini-3.1-flash-lite",
44824
+ // $0.25/$1.50 1M context handles complexity
44825
+ fallback: [
44826
+ "google/gemini-2.5-flash-lite",
44827
+ "xai/grok-4-0709",
44828
+ "google/gemini-2.5-flash",
44829
+ "deepseek/deepseek-chat"
44830
+ ]
44772
44831
  },
44773
44832
  REASONING: {
44774
44833
  primary: "xai/grok-4-1-fast-reasoning",
@@ -47720,11 +47779,20 @@ function estimateAmount(modelId, bodyLength, maxTokens) {
47720
47779
  return amountMicros.toString();
47721
47780
  }
47722
47781
  var IMAGE_PRICING = {
47723
- "openai/dall-e-3": { default: 0.04, sizes: { "1024x1024": 0.04, "1792x1024": 0.08, "1024x1792": 0.08 } },
47724
- "openai/gpt-image-1": { default: 0.02, sizes: { "1024x1024": 0.02, "1536x1024": 0.04, "1024x1536": 0.04 } },
47782
+ "openai/dall-e-3": {
47783
+ default: 0.04,
47784
+ sizes: { "1024x1024": 0.04, "1792x1024": 0.08, "1024x1792": 0.08 }
47785
+ },
47786
+ "openai/gpt-image-1": {
47787
+ default: 0.02,
47788
+ sizes: { "1024x1024": 0.02, "1536x1024": 0.04, "1024x1536": 0.04 }
47789
+ },
47725
47790
  "black-forest/flux-1.1-pro": { default: 0.04 },
47726
47791
  "google/nano-banana": { default: 0.05 },
47727
- "google/nano-banana-pro": { default: 0.1, sizes: { "1024x1024": 0.1, "2048x2048": 0.1, "4096x4096": 0.15 } }
47792
+ "google/nano-banana-pro": {
47793
+ default: 0.1,
47794
+ sizes: { "1024x1024": 0.1, "2048x2048": 0.1, "4096x4096": 0.15 }
47795
+ }
47728
47796
  };
47729
47797
  function estimateImageCost(model, size5, n = 1) {
47730
47798
  const pricing = IMAGE_PRICING[model];
@@ -48280,7 +48348,13 @@ async function startProxy(options) {
48280
48348
  }
48281
48349
  if (req.url?.match(/^\/v1\/(?:x|partner)\//)) {
48282
48350
  try {
48283
- await proxyPartnerRequest(req, res, apiBase, payFetch, () => paymentStore.getStore()?.amountUsd ?? 0);
48351
+ await proxyPartnerRequest(
48352
+ req,
48353
+ res,
48354
+ apiBase,
48355
+ payFetch,
48356
+ () => paymentStore.getStore()?.amountUsd ?? 0
48357
+ );
48284
48358
  } catch (err) {
48285
48359
  const error = err instanceof Error ? err : new Error(String(err));
48286
48360
  options.onError?.(error);
@@ -50769,8 +50843,9 @@ function injectModelsConfig(logger) {
50769
50843
  needsWrite = true;
50770
50844
  }
50771
50845
  const defaults = agents.defaults;
50772
- if (!defaults.model) {
50773
- defaults.model = {};
50846
+ if (!defaults.model || typeof defaults.model !== "object" || Array.isArray(defaults.model)) {
50847
+ const prev = typeof defaults.model === "string" ? defaults.model : void 0;
50848
+ defaults.model = prev ? { primary: prev } : {};
50774
50849
  needsWrite = true;
50775
50850
  }
50776
50851
  const model = defaults.model;
@@ -50964,7 +51039,7 @@ async function startProxyInBackground(api) {
50964
51039
  const currentChain = await resolvePaymentChain();
50965
51040
  const displayAddress = currentChain === "solana" && proxy.solanaAddress ? proxy.solanaAddress : wallet.address;
50966
51041
  const network = currentChain === "solana" ? "Solana" : "Base";
50967
- proxy.balanceMonitor.checkBalance().then((balance) => {
51042
+ proxy.balanceMonitor.checkBalance().then(async (balance) => {
50968
51043
  if (balance.isEmpty) {
50969
51044
  api.logger.info(`Wallet (${network}): ${displayAddress}`);
50970
51045
  api.logger.info(
@@ -50977,6 +51052,18 @@ async function startProxyInBackground(api) {
50977
51052
  } else {
50978
51053
  api.logger.info(`Wallet (${network}): ${displayAddress} | Balance: ${balance.balanceUSD}`);
50979
51054
  }
51055
+ if (currentChain === "solana" && (balance.isEmpty || balance.isLow)) {
51056
+ try {
51057
+ const solLamports = await proxy.balanceMonitor.checkSolBalance();
51058
+ if (solLamports > 10000000n) {
51059
+ const sol = Number(solLamports) / 1e9;
51060
+ api.logger.info(
51061
+ `You have ${sol.toFixed(2)} SOL \u2014 swap to USDC: https://jup.ag/swap/SOL-USDC`
51062
+ );
51063
+ }
51064
+ } catch {
51065
+ }
51066
+ }
50980
51067
  }).catch(() => {
50981
51068
  api.logger.info(`Wallet (${network}): ${displayAddress} | Balance: (checking...)`);
50982
51069
  });