@blockrun/clawrouter 0.10.19 → 0.10.21
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 +18 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.js +18 -58
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/update.sh +54 -0
package/dist/index.js
CHANGED
|
@@ -5437,9 +5437,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
5437
5437
|
const tools = parsed.tools;
|
|
5438
5438
|
hasTools = Array.isArray(tools) && tools.length > 0;
|
|
5439
5439
|
if (hasTools && tools) {
|
|
5440
|
-
console.log(
|
|
5441
|
-
`[ClawRouter] Tools detected (${tools.length}), agentic mode via keywords`
|
|
5442
|
-
);
|
|
5440
|
+
console.log(`[ClawRouter] Tools detected (${tools.length}), agentic mode via keywords`);
|
|
5443
5441
|
}
|
|
5444
5442
|
routingDecision = route(prompt, systemPrompt, maxTokens, {
|
|
5445
5443
|
...routerOpts,
|
|
@@ -5704,11 +5702,10 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
5704
5702
|
modelsToTry = toolFiltered.slice(0, MAX_FALLBACK_ATTEMPTS);
|
|
5705
5703
|
modelsToTry = prioritizeNonRateLimited(modelsToTry);
|
|
5706
5704
|
} else {
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
}
|
|
5705
|
+
modelsToTry = modelId ? [modelId] : [];
|
|
5706
|
+
}
|
|
5707
|
+
if (!modelsToTry.includes(FREE_MODEL)) {
|
|
5708
|
+
modelsToTry.push(FREE_MODEL);
|
|
5712
5709
|
}
|
|
5713
5710
|
let upstream;
|
|
5714
5711
|
let lastError;
|
|
@@ -5742,6 +5739,19 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
5742
5739
|
if (result.errorStatus === 429) {
|
|
5743
5740
|
markRateLimited(tryModel);
|
|
5744
5741
|
}
|
|
5742
|
+
const isPaymentErr = /payment.*verification.*failed|insufficient.*funds/i.test(
|
|
5743
|
+
result.errorBody || ""
|
|
5744
|
+
);
|
|
5745
|
+
if (isPaymentErr && tryModel !== FREE_MODEL) {
|
|
5746
|
+
const freeIdx = modelsToTry.indexOf(FREE_MODEL);
|
|
5747
|
+
if (freeIdx > i + 1) {
|
|
5748
|
+
console.log(
|
|
5749
|
+
`[ClawRouter] Payment error \u2014 skipping to free model: ${FREE_MODEL}`
|
|
5750
|
+
);
|
|
5751
|
+
i = freeIdx - 1;
|
|
5752
|
+
continue;
|
|
5753
|
+
}
|
|
5754
|
+
}
|
|
5745
5755
|
console.log(
|
|
5746
5756
|
`[ClawRouter] Provider error from ${tryModel}, trying fallback: ${result.errorBody?.slice(0, 100)}`
|
|
5747
5757
|
);
|
|
@@ -6440,56 +6450,6 @@ function injectModelsConfig(logger) {
|
|
|
6440
6450
|
logger.info("Set default model to blockrun/auto (first install)");
|
|
6441
6451
|
needsWrite = true;
|
|
6442
6452
|
}
|
|
6443
|
-
const KEY_MODEL_ALIASES = [
|
|
6444
|
-
{ id: "auto", alias: "auto" },
|
|
6445
|
-
{ id: "eco", alias: "eco" },
|
|
6446
|
-
{ id: "premium", alias: "premium" },
|
|
6447
|
-
{ id: "free", alias: "free" },
|
|
6448
|
-
{ id: "sonnet", alias: "sonnet-4.6" },
|
|
6449
|
-
{ id: "opus", alias: "opus" },
|
|
6450
|
-
{ id: "haiku", alias: "haiku" },
|
|
6451
|
-
{ id: "gpt5", alias: "gpt5" },
|
|
6452
|
-
{ id: "codex", alias: "codex" },
|
|
6453
|
-
{ id: "grok-fast", alias: "grok-fast" },
|
|
6454
|
-
{ id: "grok-code", alias: "grok-code" },
|
|
6455
|
-
{ id: "deepseek", alias: "deepseek" },
|
|
6456
|
-
{ id: "reasoner", alias: "reasoner" },
|
|
6457
|
-
{ id: "kimi", alias: "kimi" },
|
|
6458
|
-
{ id: "minimax", alias: "minimax" },
|
|
6459
|
-
{ id: "gemini", alias: "gemini" }
|
|
6460
|
-
];
|
|
6461
|
-
const DEPRECATED_ALIASES = [
|
|
6462
|
-
"blockrun/nvidia",
|
|
6463
|
-
"blockrun/gpt",
|
|
6464
|
-
"blockrun/o3",
|
|
6465
|
-
"blockrun/grok",
|
|
6466
|
-
"blockrun/mini",
|
|
6467
|
-
"blockrun/flash"
|
|
6468
|
-
// removed from picker - use gemini instead
|
|
6469
|
-
];
|
|
6470
|
-
if (!defaults.models) {
|
|
6471
|
-
defaults.models = {};
|
|
6472
|
-
needsWrite = true;
|
|
6473
|
-
}
|
|
6474
|
-
const allowlist = defaults.models;
|
|
6475
|
-
for (const deprecated of DEPRECATED_ALIASES) {
|
|
6476
|
-
if (allowlist[deprecated]) {
|
|
6477
|
-
delete allowlist[deprecated];
|
|
6478
|
-
logger.info(`Removed deprecated model alias: ${deprecated}`);
|
|
6479
|
-
needsWrite = true;
|
|
6480
|
-
}
|
|
6481
|
-
}
|
|
6482
|
-
for (const m of KEY_MODEL_ALIASES) {
|
|
6483
|
-
const fullId = `blockrun/${m.id}`;
|
|
6484
|
-
const existing = allowlist[fullId];
|
|
6485
|
-
if (!existing) {
|
|
6486
|
-
allowlist[fullId] = { alias: m.alias };
|
|
6487
|
-
needsWrite = true;
|
|
6488
|
-
} else if (existing.alias !== m.alias) {
|
|
6489
|
-
existing.alias = m.alias;
|
|
6490
|
-
needsWrite = true;
|
|
6491
|
-
}
|
|
6492
|
-
}
|
|
6493
6453
|
if (needsWrite) {
|
|
6494
6454
|
try {
|
|
6495
6455
|
const tmpPath = `${configPath}.tmp.${process.pid}`;
|