@blockrun/clawrouter 0.8.14 → 0.8.16
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 +1 -0
- package/dist/cli.js +27 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.js +33 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,6 +60,7 @@ Done! Smart routing (`blockrun/auto`) is now your default model.
|
|
|
60
60
|
**📖 Full Windows Guide:** [docs/windows-installation.md](docs/windows-installation.md)
|
|
61
61
|
|
|
62
62
|
**Quick Summary:**
|
|
63
|
+
|
|
63
64
|
- ✅ ClawRouter code is Windows-compatible
|
|
64
65
|
- ❌ OpenClaw CLI has a `spawn EINVAL` bug on Windows
|
|
65
66
|
- ✅ Works perfectly on **Linux** and **macOS**
|
package/dist/cli.js
CHANGED
|
@@ -1150,7 +1150,11 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
1150
1150
|
SIMPLE: {
|
|
1151
1151
|
primary: "moonshot/kimi-k2.5",
|
|
1152
1152
|
// Cheaper than Haiku ($0.5/$2.4 vs $1/$5), larger context
|
|
1153
|
-
fallback: [
|
|
1153
|
+
fallback: [
|
|
1154
|
+
"anthropic/claude-haiku-4.5",
|
|
1155
|
+
"xai/grok-4-fast-non-reasoning",
|
|
1156
|
+
"openai/gpt-4o-mini"
|
|
1157
|
+
]
|
|
1154
1158
|
},
|
|
1155
1159
|
MEDIUM: {
|
|
1156
1160
|
primary: "xai/grok-code-fast-1",
|
|
@@ -1662,6 +1666,11 @@ function getModelContextWindow(modelId) {
|
|
|
1662
1666
|
const model = BLOCKRUN_MODELS.find((m) => m.id === normalized);
|
|
1663
1667
|
return model?.contextWindow;
|
|
1664
1668
|
}
|
|
1669
|
+
function isReasoningModel(modelId) {
|
|
1670
|
+
const normalized = modelId.replace("blockrun/", "");
|
|
1671
|
+
const model = BLOCKRUN_MODELS.find((m) => m.id === normalized);
|
|
1672
|
+
return model?.reasoning ?? false;
|
|
1673
|
+
}
|
|
1665
1674
|
|
|
1666
1675
|
// src/logger.ts
|
|
1667
1676
|
import { appendFile, mkdir } from "fs/promises";
|
|
@@ -2493,7 +2502,12 @@ function normalizeMessagesForThinking(messages) {
|
|
|
2493
2502
|
if (!messages || messages.length === 0) return messages;
|
|
2494
2503
|
let hasChanges = false;
|
|
2495
2504
|
const normalized = messages.map((msg) => {
|
|
2496
|
-
if (msg.role
|
|
2505
|
+
if (msg.role !== "assistant" || msg.reasoning_content !== void 0) {
|
|
2506
|
+
return msg;
|
|
2507
|
+
}
|
|
2508
|
+
const hasOpenAIToolCalls = msg.tool_calls && Array.isArray(msg.tool_calls) && msg.tool_calls.length > 0;
|
|
2509
|
+
const hasAnthropicToolUse = Array.isArray(msg.content) && msg.content.some((block) => block?.type === "tool_use");
|
|
2510
|
+
if (hasOpenAIToolCalls || hasAnthropicToolUse) {
|
|
2497
2511
|
hasChanges = true;
|
|
2498
2512
|
return { ...msg, reasoning_content: "" };
|
|
2499
2513
|
}
|
|
@@ -2815,7 +2829,8 @@ async function tryModelRequest(upstreamUrl, method, headers, body, modelId, maxT
|
|
|
2815
2829
|
if (isGoogleModel(modelId) && Array.isArray(parsed.messages)) {
|
|
2816
2830
|
parsed.messages = normalizeMessagesForGoogle(parsed.messages);
|
|
2817
2831
|
}
|
|
2818
|
-
|
|
2832
|
+
const hasThinkingEnabled = !!(parsed.thinking || parsed.extended_thinking || isReasoningModel(modelId));
|
|
2833
|
+
if (hasThinkingEnabled && Array.isArray(parsed.messages)) {
|
|
2819
2834
|
parsed.messages = normalizeMessagesForThinking(parsed.messages);
|
|
2820
2835
|
}
|
|
2821
2836
|
requestBody = Buffer.from(JSON.stringify(parsed));
|
|
@@ -3057,7 +3072,11 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
3057
3072
|
modelsToTry = contextFiltered.slice(0, MAX_FALLBACK_ATTEMPTS);
|
|
3058
3073
|
modelsToTry = prioritizeNonRateLimited(modelsToTry);
|
|
3059
3074
|
} else {
|
|
3060
|
-
|
|
3075
|
+
if (modelId && modelId !== FREE_MODEL) {
|
|
3076
|
+
modelsToTry = [modelId, FREE_MODEL];
|
|
3077
|
+
} else {
|
|
3078
|
+
modelsToTry = modelId ? [modelId] : [];
|
|
3079
|
+
}
|
|
3061
3080
|
}
|
|
3062
3081
|
let upstream;
|
|
3063
3082
|
let lastError;
|
|
@@ -3136,7 +3155,9 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
3136
3155
|
const parsed = JSON.parse(transformedErr);
|
|
3137
3156
|
errPayload = JSON.stringify(parsed);
|
|
3138
3157
|
} catch {
|
|
3139
|
-
errPayload = JSON.stringify({
|
|
3158
|
+
errPayload = JSON.stringify({
|
|
3159
|
+
error: { message: rawErrBody, type: "provider_error", status: errStatus }
|
|
3160
|
+
});
|
|
3140
3161
|
}
|
|
3141
3162
|
const errEvent = `data: ${errPayload}
|
|
3142
3163
|
|
|
@@ -3240,7 +3261,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
3240
3261
|
index,
|
|
3241
3262
|
delta: {},
|
|
3242
3263
|
logprobs: null,
|
|
3243
|
-
finish_reason: choice.finish_reason ?? "stop"
|
|
3264
|
+
finish_reason: toolCalls && toolCalls.length > 0 ? "tool_calls" : choice.finish_reason ?? "stop"
|
|
3244
3265
|
}
|
|
3245
3266
|
]
|
|
3246
3267
|
};
|