@blockrun/clawrouter 0.12.230 → 0.12.232

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/README.md CHANGED
@@ -434,6 +434,7 @@ No Surf account, no API key — settles directly to Surf's Base treasury in USDC
434
434
  | google/gemini-2.5-pro | $1.25 | $10.00 | $0.0056 | 1M | reasoning, vision, tools |
435
435
  | zai/glm-5.2 | $1.40 | $4.40 | $0.0029 | 1M | reasoning, coding, tools (flagship) |
436
436
  | zai/glm-5.1 | $1.40 | $4.40 | $0.0029 | 200K | reasoning, tools (promo ended 2026-06-05) |
437
+ | qwen/qwen3.7-max | $1.475 | $4.425 | $0.0030 | 1M | reasoning, agentic, tools (Qwen flagship) |
437
438
  | xai/grok-4.3 | $1.50 | $4.00 | $0.0028 | 1M | reasoning, vision, agentic, tools |
438
439
  | xai/grok-4.5 | $2.50 | $9.00 | $0.0058 | 500K | reasoning, vision, agentic, tools |
439
440
  | xai/grok-build-0.1 | $1.50 | $3.00 | $0.0023 | 256K | agentic coding, tools |
package/dist/cli.js CHANGED
@@ -31393,6 +31393,22 @@ var init_esm4 = __esm({
31393
31393
  }
31394
31394
  });
31395
31395
 
31396
+ // src/max-tokens.ts
31397
+ function resolveMaxTokens(parsed, fallback2 = DEFAULT_MAX_TOKENS) {
31398
+ const usable = (v) => typeof v === "number" && Number.isFinite(v) && v > 0 ? v : void 0;
31399
+ const candidates = [usable(parsed.max_tokens), usable(parsed.max_completion_tokens)].filter(
31400
+ (n) => n !== void 0
31401
+ );
31402
+ return candidates.length > 0 ? Math.max(...candidates) : fallback2;
31403
+ }
31404
+ var DEFAULT_MAX_TOKENS;
31405
+ var init_max_tokens = __esm({
31406
+ "src/max-tokens.ts"() {
31407
+ "use strict";
31408
+ DEFAULT_MAX_TOKENS = 4096;
31409
+ }
31410
+ });
31411
+
31396
31412
  // src/payment-preauth.ts
31397
31413
  function createPayFetchWithPreAuth(baseFetch, client, ttlMs = DEFAULT_TTL_MS, options) {
31398
31414
  const httpClient = new x402HTTPClient(client);
@@ -31410,7 +31426,7 @@ function createPayFetchWithPreAuth(baseFetch, client, ttlMs = DEFAULT_TTL_MS, op
31410
31426
  bodyLength = bodyStr.length;
31411
31427
  const parsed = JSON.parse(bodyStr);
31412
31428
  requestModel = parsed.model ?? "";
31413
- maxTokens = Number(parsed.max_tokens) || 0;
31429
+ maxTokens = resolveMaxTokens(parsed, 0);
31414
31430
  }
31415
31431
  } catch {
31416
31432
  }
@@ -31481,6 +31497,7 @@ var init_payment_preauth = __esm({
31481
31497
  "src/payment-preauth.ts"() {
31482
31498
  "use strict";
31483
31499
  init_esm4();
31500
+ init_max_tokens();
31484
31501
  DEFAULT_TTL_MS = 36e5;
31485
31502
  }
31486
31503
  });
@@ -34296,6 +34313,7 @@ var init_top_models = __esm({
34296
34313
  "minimax/minimax-m3",
34297
34314
  "minimax/minimax-m2.7",
34298
34315
  "moonshot/kimi-k3",
34316
+ "qwen/qwen3.7-max",
34299
34317
  "deepseek/deepseek-v4-pro",
34300
34318
  "deepseek/deepseek-chat",
34301
34319
  "deepseek/deepseek-reasoner",
@@ -34522,6 +34540,17 @@ var init_models = __esm({
34522
34540
  "kimi-k2.6": "moonshot/kimi-k2.6",
34523
34541
  "kimi-k2.5": "moonshot/kimi-k2.5",
34524
34542
  "nvidia/kimi-k2.5": "moonshot/kimi-k2.5",
34543
+ // Qwen — Qwen3.7 Max is Alibaba's current flagship for reasoning, coding,
34544
+ // and agentic tool use. EXPLICIT PINS ONLY: bare `qwen` deliberately stays
34545
+ // unbound. Every other qwen* shorthand below points at a FREE model
34546
+ // (qwen-coder, qwen-thinking, qwen3-next, qwen3.5-122b), so binding the
34547
+ // shortest name to a $1.475/$4.425 flagship would silently charge callers
34548
+ // who typed it expecting the free tier — same rule that keeps generic
34549
+ // `kimi` on K2.7. (`grok` WAS promoted to 4.5, but only after the cost
34550
+ // tradeoff was argued explicitly; there's no such case for qwen yet.)
34551
+ "qwen3.7-max": "qwen/qwen3.7-max",
34552
+ "qwen-3.7-max": "qwen/qwen3.7-max",
34553
+ "qwen3-7-max": "qwen/qwen3.7-max",
34525
34554
  // Google
34526
34555
  // gemini-3-pro-preview delisted by Google 2026-06-06 — mirror the gateway
34527
34556
  // redirect to its successor so pinned callers land on 3.1-pro, not an error.
@@ -35331,6 +35360,27 @@ var init_models = __esm({
35331
35360
  agentic: true,
35332
35361
  toolCalling: true
35333
35362
  },
35363
+ // Qwen3.7 Max — BlockRun's paid Qwen flagship, served through its
35364
+ // OpenRouter credit pool. The gateway applies its standard 5% margin at
35365
+ // settlement, so keep the catalog rates at the upstream $1.475/$4.425 COGS.
35366
+ // NOTE: `reasoning: true` also enrolls this id in REASONING_MODEL_IDS
35367
+ // (proxy.ts), which raises its per-model timeout from 60s to 180s.
35368
+ // `toolCalling: true` is LIVE-VERIFIED (2026-07-20): a real request through
35369
+ // the gateway returned a structured tool_calls array (name + valid JSON
35370
+ // arguments, finish_reason "tool_calls"), not the textual leak that Kimi K3
35371
+ // (#213), Gemini (#189) and GPT (#193) produce. Don't downgrade on a hunch.
35372
+ {
35373
+ id: "qwen/qwen3.7-max",
35374
+ name: "Qwen3.7 Max",
35375
+ version: "3.7-max",
35376
+ inputPrice: 1.475,
35377
+ outputPrice: 4.425,
35378
+ contextWindow: 1e6,
35379
+ maxOutput: 65536,
35380
+ reasoning: true,
35381
+ agentic: true,
35382
+ toolCalling: true
35383
+ },
35334
35384
  // Kimi K2.6 — superseded by K2.7 (2026-06-13), hidden on BlockRun but still routable.
35335
35385
  {
35336
35386
  id: "moonshot/kimi-k2.6",
@@ -86058,7 +86108,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
86058
86108
  let hasVision = false;
86059
86109
  let isStreaming = false;
86060
86110
  let modelId = "";
86061
- let maxTokens = 4096;
86111
+ let maxTokens = DEFAULT_MAX_TOKENS;
86062
86112
  let routingProfile = null;
86063
86113
  let stickyExplicitModel;
86064
86114
  let balanceFallbackNotice;
@@ -86077,7 +86127,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
86077
86127
  const parsed = JSON.parse(body.toString());
86078
86128
  isStreaming = parsed.stream === true;
86079
86129
  modelId = parsed.model || "";
86080
- maxTokens = parsed.max_tokens || 4096;
86130
+ maxTokens = resolveMaxTokens(parsed);
86081
86131
  let bodyModified = false;
86082
86132
  const parsedMessages = Array.isArray(parsed.messages) ? parsed.messages : [];
86083
86133
  const lastUserMsg = [...parsedMessages].reverse().find((m) => m.role === "user");
@@ -88074,6 +88124,7 @@ var init_proxy = __esm({
88074
88124
  init_router();
88075
88125
  init_rules();
88076
88126
  init_models();
88127
+ init_max_tokens();
88077
88128
  init_logger();
88078
88129
  init_stats();
88079
88130
  init_dedup();
@@ -88091,6 +88142,7 @@ var init_proxy = __esm({
88091
88142
  init_textual_tool_calls();
88092
88143
  init_response_store();
88093
88144
  init_share_formatters();
88145
+ init_max_tokens();
88094
88146
  paymentStore = new AsyncLocalStorage();
88095
88147
  BLOCKRUN_API = "https://blockrun.ai/api";
88096
88148
  BLOCKRUN_SOLANA_API = "https://sol.blockrun.ai/api";
package/dist/index.js CHANGED
@@ -86,6 +86,7 @@ var init_top_models = __esm({
86
86
  "minimax/minimax-m3",
87
87
  "minimax/minimax-m2.7",
88
88
  "moonshot/kimi-k3",
89
+ "qwen/qwen3.7-max",
89
90
  "deepseek/deepseek-v4-pro",
90
91
  "deepseek/deepseek-chat",
91
92
  "deepseek/deepseek-reasoner",
@@ -312,6 +313,17 @@ var init_models = __esm({
312
313
  "kimi-k2.6": "moonshot/kimi-k2.6",
313
314
  "kimi-k2.5": "moonshot/kimi-k2.5",
314
315
  "nvidia/kimi-k2.5": "moonshot/kimi-k2.5",
316
+ // Qwen — Qwen3.7 Max is Alibaba's current flagship for reasoning, coding,
317
+ // and agentic tool use. EXPLICIT PINS ONLY: bare `qwen` deliberately stays
318
+ // unbound. Every other qwen* shorthand below points at a FREE model
319
+ // (qwen-coder, qwen-thinking, qwen3-next, qwen3.5-122b), so binding the
320
+ // shortest name to a $1.475/$4.425 flagship would silently charge callers
321
+ // who typed it expecting the free tier — same rule that keeps generic
322
+ // `kimi` on K2.7. (`grok` WAS promoted to 4.5, but only after the cost
323
+ // tradeoff was argued explicitly; there's no such case for qwen yet.)
324
+ "qwen3.7-max": "qwen/qwen3.7-max",
325
+ "qwen-3.7-max": "qwen/qwen3.7-max",
326
+ "qwen3-7-max": "qwen/qwen3.7-max",
315
327
  // Google
316
328
  // gemini-3-pro-preview delisted by Google 2026-06-06 — mirror the gateway
317
329
  // redirect to its successor so pinned callers land on 3.1-pro, not an error.
@@ -1121,6 +1133,27 @@ var init_models = __esm({
1121
1133
  agentic: true,
1122
1134
  toolCalling: true
1123
1135
  },
1136
+ // Qwen3.7 Max — BlockRun's paid Qwen flagship, served through its
1137
+ // OpenRouter credit pool. The gateway applies its standard 5% margin at
1138
+ // settlement, so keep the catalog rates at the upstream $1.475/$4.425 COGS.
1139
+ // NOTE: `reasoning: true` also enrolls this id in REASONING_MODEL_IDS
1140
+ // (proxy.ts), which raises its per-model timeout from 60s to 180s.
1141
+ // `toolCalling: true` is LIVE-VERIFIED (2026-07-20): a real request through
1142
+ // the gateway returned a structured tool_calls array (name + valid JSON
1143
+ // arguments, finish_reason "tool_calls"), not the textual leak that Kimi K3
1144
+ // (#213), Gemini (#189) and GPT (#193) produce. Don't downgrade on a hunch.
1145
+ {
1146
+ id: "qwen/qwen3.7-max",
1147
+ name: "Qwen3.7 Max",
1148
+ version: "3.7-max",
1149
+ inputPrice: 1.475,
1150
+ outputPrice: 4.425,
1151
+ contextWindow: 1e6,
1152
+ maxOutput: 65536,
1153
+ reasoning: true,
1154
+ agentic: true,
1155
+ toolCalling: true
1156
+ },
1124
1157
  // Kimi K2.6 — superseded by K2.7 (2026-06-13), hidden on BlockRun but still routable.
1125
1158
  {
1126
1159
  id: "moonshot/kimi-k2.6",
@@ -32884,6 +32917,22 @@ var init_esm4 = __esm({
32884
32917
  }
32885
32918
  });
32886
32919
 
32920
+ // src/max-tokens.ts
32921
+ function resolveMaxTokens(parsed, fallback2 = DEFAULT_MAX_TOKENS) {
32922
+ const usable = (v) => typeof v === "number" && Number.isFinite(v) && v > 0 ? v : void 0;
32923
+ const candidates = [usable(parsed.max_tokens), usable(parsed.max_completion_tokens)].filter(
32924
+ (n) => n !== void 0
32925
+ );
32926
+ return candidates.length > 0 ? Math.max(...candidates) : fallback2;
32927
+ }
32928
+ var DEFAULT_MAX_TOKENS;
32929
+ var init_max_tokens = __esm({
32930
+ "src/max-tokens.ts"() {
32931
+ "use strict";
32932
+ DEFAULT_MAX_TOKENS = 4096;
32933
+ }
32934
+ });
32935
+
32887
32936
  // src/payment-preauth.ts
32888
32937
  function createPayFetchWithPreAuth(baseFetch, client, ttlMs = DEFAULT_TTL_MS, options) {
32889
32938
  const httpClient = new x402HTTPClient(client);
@@ -32901,7 +32950,7 @@ function createPayFetchWithPreAuth(baseFetch, client, ttlMs = DEFAULT_TTL_MS, op
32901
32950
  bodyLength = bodyStr.length;
32902
32951
  const parsed = JSON.parse(bodyStr);
32903
32952
  requestModel = parsed.model ?? "";
32904
- maxTokens = Number(parsed.max_tokens) || 0;
32953
+ maxTokens = resolveMaxTokens(parsed, 0);
32905
32954
  }
32906
32955
  } catch {
32907
32956
  }
@@ -32972,6 +33021,7 @@ var init_payment_preauth = __esm({
32972
33021
  "src/payment-preauth.ts"() {
32973
33022
  "use strict";
32974
33023
  init_esm4();
33024
+ init_max_tokens();
32975
33025
  DEFAULT_TTL_MS = 36e5;
32976
33026
  }
32977
33027
  });
@@ -85878,7 +85928,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
85878
85928
  let hasVision = false;
85879
85929
  let isStreaming = false;
85880
85930
  let modelId = "";
85881
- let maxTokens = 4096;
85931
+ let maxTokens = DEFAULT_MAX_TOKENS;
85882
85932
  let routingProfile = null;
85883
85933
  let stickyExplicitModel;
85884
85934
  let balanceFallbackNotice;
@@ -85897,7 +85947,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
85897
85947
  const parsed = JSON.parse(body.toString());
85898
85948
  isStreaming = parsed.stream === true;
85899
85949
  modelId = parsed.model || "";
85900
- maxTokens = parsed.max_tokens || 4096;
85950
+ maxTokens = resolveMaxTokens(parsed);
85901
85951
  let bodyModified = false;
85902
85952
  const parsedMessages = Array.isArray(parsed.messages) ? parsed.messages : [];
85903
85953
  const lastUserMsg = [...parsedMessages].reverse().find((m) => m.role === "user");
@@ -87894,6 +87944,7 @@ var init_proxy = __esm({
87894
87944
  init_router();
87895
87945
  init_rules();
87896
87946
  init_models();
87947
+ init_max_tokens();
87897
87948
  init_logger();
87898
87949
  init_stats();
87899
87950
  init_dedup();
@@ -87911,6 +87962,7 @@ var init_proxy = __esm({
87911
87962
  init_textual_tool_calls();
87912
87963
  init_response_store();
87913
87964
  init_share_formatters();
87965
+ init_max_tokens();
87914
87966
  paymentStore = new AsyncLocalStorage();
87915
87967
  BLOCKRUN_API = "https://blockrun.ai/api";
87916
87968
  BLOCKRUN_SOLANA_API = "https://sol.blockrun.ai/api";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/clawrouter",
3
- "version": "0.12.230",
3
+ "version": "0.12.232",
4
4
  "description": "Smart LLM router — save 85% on inference costs. 55+ models (8 free), one wallet, x402 micropayments.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -135,7 +135,7 @@ Rules handle ~~80% of requests in <1ms. Only ambiguous queries hit the LLM class
135
135
 
136
136
  ## Available Models
137
137
 
138
- 55+ models including: gpt-5.6-terra [balanced, stable default], gpt-5.6-sol [flagship], gpt-5.6-luna [cost-efficient], gpt-5.5, gpt-5.4, gpt-4o, o3, claude-fable-5, claude-opus-4.8, claude-opus-4.7, claude-opus-4.5, claude-sonnet-5, claude-sonnet-4.6, gemini-3.1-pro, gemini-2.5-flash, deepseek-v4-pro, deepseek-chat, grok-4.5, grok-4.3, grok-build-0.1, kimi-k3 [1M ctx flagship], kimi-k2.7, and 8 free NVIDIA models (mistral-large-3-675b [default, 675B flagship], deepseek-v4-flash [1M context], seed-oss-36b [coding], nemotron-3-nano-omni-30b-a3b-reasoning [vision], mistral-nemotron, step-3.7-flash, nemotron-nano-9b-v2, nemotron-nano-12b-v2-vl [vision]).
138
+ 55+ models including: gpt-5.6-terra [balanced, stable default], gpt-5.6-sol [flagship], gpt-5.6-luna [cost-efficient], gpt-5.5, gpt-5.4, gpt-4o, o3, claude-fable-5, claude-opus-4.8, claude-opus-4.7, claude-opus-4.5, claude-sonnet-5, claude-sonnet-4.6, gemini-3.1-pro, gemini-2.5-flash, deepseek-v4-pro, deepseek-chat, grok-4.5, grok-4.3, grok-build-0.1, kimi-k3 [1M ctx flagship], kimi-k2.7, qwen3.7-max [Qwen flagship, 1M ctx], and 8 free NVIDIA models (mistral-large-3-675b [default, 675B flagship], deepseek-v4-flash [1M context], seed-oss-36b [coding], nemotron-3-nano-omni-30b-a3b-reasoning [vision], mistral-nemotron, step-3.7-flash, nemotron-nano-9b-v2, nemotron-nano-12b-v2-vl [vision]).
139
139
 
140
140
  ## Built-in Agent Tools
141
141
 
@@ -32,6 +32,7 @@
32
32
  "minimax/minimax-m3",
33
33
  "minimax/minimax-m2.7",
34
34
  "moonshot/kimi-k3",
35
+ "qwen/qwen3.7-max",
35
36
  "deepseek/deepseek-v4-pro",
36
37
  "deepseek/deepseek-chat",
37
38
  "deepseek/deepseek-reasoner",