@blockrun/clawrouter 0.9.31 → 0.9.33

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
@@ -3,6 +3,8 @@ var MODEL_ALIASES = {
3
3
  // Claude - short names (backend uses bare model names without anthropic/ prefix)
4
4
  claude: "claude-sonnet-4",
5
5
  sonnet: "claude-sonnet-4",
6
+ "sonnet-4.6": "claude-sonnet-4",
7
+ "sonnet-4-6": "claude-sonnet-4",
6
8
  opus: "claude-opus-4",
7
9
  "opus-4": "claude-opus-4",
8
10
  haiku: "claude-haiku-4.5",
@@ -223,7 +225,7 @@ var BLOCKRUN_MODELS = [
223
225
  },
224
226
  {
225
227
  id: "claude-sonnet-4",
226
- name: "Claude Sonnet 4",
228
+ name: "Claude Sonnet 4.6",
227
229
  inputPrice: 3,
228
230
  outputPrice: 15,
229
231
  contextWindow: 2e5,
@@ -233,7 +235,7 @@ var BLOCKRUN_MODELS = [
233
235
  },
234
236
  {
235
237
  id: "claude-opus-4",
236
- name: "Claude Opus 4",
238
+ name: "Claude Opus 4.6",
237
239
  inputPrice: 15,
238
240
  outputPrice: 75,
239
241
  contextWindow: 2e5,
@@ -1735,44 +1737,27 @@ var DEFAULT_ROUTING_CONFIG = {
1735
1737
  ]
1736
1738
  }
1737
1739
  },
1738
- // Eco tier configs - ultra cost-optimized (blockrun/eco)
1740
+ // Eco tier configs - absolute cheapest (blockrun/eco)
1739
1741
  ecoTiers: {
1740
1742
  SIMPLE: {
1741
- primary: "minimax/minimax-m2.5",
1742
- // $0.30/$1.20 - cheapest with reasoning
1743
- fallback: [
1744
- "moonshot/kimi-k2.5",
1745
- "nvidia/gpt-oss-120b",
1746
- "deepseek/deepseek-chat",
1747
- "google/gemini-2.5-flash"
1748
- ]
1743
+ primary: "nvidia/gpt-oss-120b",
1744
+ // FREE! $0.00/$0.00
1745
+ fallback: ["google/gemini-2.5-flash", "deepseek/deepseek-chat", "minimax/minimax-m2.5"]
1749
1746
  },
1750
1747
  MEDIUM: {
1751
- primary: "deepseek/deepseek-chat",
1752
- // $0.14/$0.28
1753
- fallback: [
1754
- "minimax/minimax-m2.5",
1755
- // $0.30/$1.20 - cheap with reasoning
1756
- "xai/grok-code-fast-1",
1757
- "google/gemini-2.5-flash",
1758
- "moonshot/kimi-k2.5"
1759
- ]
1748
+ primary: "google/gemini-2.5-flash",
1749
+ // $0.15/$0.60 - cheapest capable
1750
+ fallback: ["deepseek/deepseek-chat", "nvidia/gpt-oss-120b", "minimax/minimax-m2.5"]
1760
1751
  },
1761
1752
  COMPLEX: {
1762
- primary: "xai/grok-4-0709",
1763
- // $0.20/$1.50
1764
- fallback: [
1765
- "minimax/minimax-m2.5",
1766
- // $0.30/$1.20 - cheap with reasoning
1767
- "deepseek/deepseek-chat",
1768
- "google/gemini-2.5-flash",
1769
- "openai/gpt-4o-mini"
1770
- ]
1753
+ primary: "google/gemini-2.5-flash",
1754
+ // $0.15/$0.60 - 1M context handles complexity
1755
+ fallback: ["deepseek/deepseek-chat", "xai/grok-4-0709", "minimax/minimax-m2.5"]
1771
1756
  },
1772
1757
  REASONING: {
1773
- primary: "minimax/minimax-m2.5",
1774
- // $0.30/$1.20 - cheapest reasoning model
1775
- fallback: ["deepseek/deepseek-reasoner", "xai/grok-4-1-fast-reasoning"]
1758
+ primary: "xai/grok-4-1-fast-reasoning",
1759
+ // $0.20/$0.50 - was MORE expensive than AUTO!
1760
+ fallback: ["deepseek/deepseek-reasoner", "minimax/minimax-m2.5"]
1776
1761
  }
1777
1762
  },
1778
1763
  // Premium tier configs - best quality (blockrun/premium)
@@ -4192,6 +4177,19 @@ function buildModelPricing() {
4192
4177
  }
4193
4178
  return map;
4194
4179
  }
4180
+ function buildProxyModelList(createdAt = Math.floor(Date.now() / 1e3)) {
4181
+ const seen = /* @__PURE__ */ new Set();
4182
+ return OPENCLAW_MODELS.filter((model) => {
4183
+ if (seen.has(model.id)) return false;
4184
+ seen.add(model.id);
4185
+ return true;
4186
+ }).map((model) => ({
4187
+ id: model.id,
4188
+ object: "model",
4189
+ created: createdAt,
4190
+ owned_by: model.id.includes("/") ? model.id.split("/")[0] ?? "blockrun" : "blockrun"
4191
+ }));
4192
+ }
4195
4193
  function mergeRoutingConfig(overrides) {
4196
4194
  if (!overrides) return DEFAULT_ROUTING_CONFIG;
4197
4195
  return {
@@ -4317,12 +4315,7 @@ async function startProxy(options) {
4317
4315
  return;
4318
4316
  }
4319
4317
  if (req.url === "/v1/models" && req.method === "GET") {
4320
- const models = BLOCKRUN_MODELS.filter((m) => m.id !== "blockrun/auto").map((m) => ({
4321
- id: m.id,
4322
- object: "model",
4323
- created: Math.floor(Date.now() / 1e3),
4324
- owned_by: m.id.split("/")[0] || "unknown"
4325
- }));
4318
+ const models = buildProxyModelList();
4326
4319
  res.writeHead(200, { "Content-Type": "application/json" });
4327
4320
  res.end(JSON.stringify({ object: "list", data: models }));
4328
4321
  return;
@@ -4623,10 +4616,12 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
4623
4616
  console.log(
4624
4617
  `[ClawRouter] Received model: "${parsed.model}" -> normalized: "${normalizedModel}"${wasAlias ? ` -> alias: "${resolvedModel}"` : ""}${routingProfile ? `, profile: ${routingProfile}` : ""}`
4625
4618
  );
4626
- if (wasAlias && !isRoutingProfile) {
4627
- parsed.model = resolvedModel;
4619
+ if (!isRoutingProfile) {
4620
+ if (parsed.model !== resolvedModel) {
4621
+ parsed.model = resolvedModel;
4622
+ bodyModified = true;
4623
+ }
4628
4624
  modelId = resolvedModel;
4629
- bodyModified = true;
4630
4625
  }
4631
4626
  if (isRoutingProfile) {
4632
4627
  if (routingProfile === "free") {
@@ -5136,9 +5131,11 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
5136
5131
  body: responseBody,
5137
5132
  status: upstream.status,
5138
5133
  headers: responseHeaders,
5139
- model: modelId
5134
+ model: actualModelUsed
5140
5135
  });
5141
- console.log(`[ClawRouter] Cached response for ${modelId} (${responseBody.length} bytes)`);
5136
+ console.log(
5137
+ `[ClawRouter] Cached response for ${actualModelUsed} (${responseBody.length} bytes)`
5138
+ );
5142
5139
  }
5143
5140
  try {
5144
5141
  const rspJson = JSON.parse(responseBody.toString());
@@ -5468,7 +5465,7 @@ function injectModelsConfig(logger) {
5468
5465
  { id: "eco", alias: "eco" },
5469
5466
  { id: "premium", alias: "premium" },
5470
5467
  { id: "free", alias: "free" },
5471
- { id: "sonnet", alias: "sonnet" },
5468
+ { id: "sonnet", alias: "sonnet-4.6" },
5472
5469
  { id: "opus", alias: "opus" },
5473
5470
  { id: "haiku", alias: "haiku" },
5474
5471
  { id: "gpt5", alias: "gpt5" },