@blockrun/clawrouter 0.8.14 → 0.8.15
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 +21 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.js +27 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -440,6 +440,11 @@ function getModelContextWindow(modelId) {
|
|
|
440
440
|
const model = BLOCKRUN_MODELS.find((m) => m.id === normalized);
|
|
441
441
|
return model?.contextWindow;
|
|
442
442
|
}
|
|
443
|
+
function isReasoningModel(modelId) {
|
|
444
|
+
const normalized = modelId.replace("blockrun/", "");
|
|
445
|
+
const model = BLOCKRUN_MODELS.find((m) => m.id === normalized);
|
|
446
|
+
return model?.reasoning ?? false;
|
|
447
|
+
}
|
|
443
448
|
|
|
444
449
|
// src/provider.ts
|
|
445
450
|
var activeProxy = null;
|
|
@@ -1615,7 +1620,11 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
1615
1620
|
SIMPLE: {
|
|
1616
1621
|
primary: "moonshot/kimi-k2.5",
|
|
1617
1622
|
// Cheaper than Haiku ($0.5/$2.4 vs $1/$5), larger context
|
|
1618
|
-
fallback: [
|
|
1623
|
+
fallback: [
|
|
1624
|
+
"anthropic/claude-haiku-4.5",
|
|
1625
|
+
"xai/grok-4-fast-non-reasoning",
|
|
1626
|
+
"openai/gpt-4o-mini"
|
|
1627
|
+
]
|
|
1619
1628
|
},
|
|
1620
1629
|
MEDIUM: {
|
|
1621
1630
|
primary: "xai/grok-code-fast-1",
|
|
@@ -2954,7 +2963,8 @@ async function tryModelRequest(upstreamUrl, method, headers, body, modelId, maxT
|
|
|
2954
2963
|
if (isGoogleModel(modelId) && Array.isArray(parsed.messages)) {
|
|
2955
2964
|
parsed.messages = normalizeMessagesForGoogle(parsed.messages);
|
|
2956
2965
|
}
|
|
2957
|
-
|
|
2966
|
+
const hasThinkingEnabled = !!(parsed.thinking || parsed.extended_thinking || isReasoningModel(modelId));
|
|
2967
|
+
if (hasThinkingEnabled && Array.isArray(parsed.messages)) {
|
|
2958
2968
|
parsed.messages = normalizeMessagesForThinking(parsed.messages);
|
|
2959
2969
|
}
|
|
2960
2970
|
requestBody = Buffer.from(JSON.stringify(parsed));
|
|
@@ -3196,7 +3206,11 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
3196
3206
|
modelsToTry = contextFiltered.slice(0, MAX_FALLBACK_ATTEMPTS);
|
|
3197
3207
|
modelsToTry = prioritizeNonRateLimited(modelsToTry);
|
|
3198
3208
|
} else {
|
|
3199
|
-
|
|
3209
|
+
if (modelId && modelId !== FREE_MODEL) {
|
|
3210
|
+
modelsToTry = [modelId, FREE_MODEL];
|
|
3211
|
+
} else {
|
|
3212
|
+
modelsToTry = modelId ? [modelId] : [];
|
|
3213
|
+
}
|
|
3200
3214
|
}
|
|
3201
3215
|
let upstream;
|
|
3202
3216
|
let lastError;
|
|
@@ -3275,7 +3289,9 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
3275
3289
|
const parsed = JSON.parse(transformedErr);
|
|
3276
3290
|
errPayload = JSON.stringify(parsed);
|
|
3277
3291
|
} catch {
|
|
3278
|
-
errPayload = JSON.stringify({
|
|
3292
|
+
errPayload = JSON.stringify({
|
|
3293
|
+
error: { message: rawErrBody, type: "provider_error", status: errStatus }
|
|
3294
|
+
});
|
|
3279
3295
|
}
|
|
3280
3296
|
const errEvent = `data: ${errPayload}
|
|
3281
3297
|
|
|
@@ -3379,7 +3395,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
3379
3395
|
index,
|
|
3380
3396
|
delta: {},
|
|
3381
3397
|
logprobs: null,
|
|
3382
|
-
finish_reason: choice.finish_reason ?? "stop"
|
|
3398
|
+
finish_reason: toolCalls && toolCalls.length > 0 ? "tool_calls" : choice.finish_reason ?? "stop"
|
|
3383
3399
|
}
|
|
3384
3400
|
]
|
|
3385
3401
|
};
|
|
@@ -3608,7 +3624,9 @@ function injectModelsConfig(logger) {
|
|
|
3608
3624
|
mkdirSync(configDir, { recursive: true });
|
|
3609
3625
|
logger.info("Created OpenClaw config directory");
|
|
3610
3626
|
} catch (err) {
|
|
3611
|
-
logger.info(
|
|
3627
|
+
logger.info(
|
|
3628
|
+
`Failed to create config dir: ${err instanceof Error ? err.message : String(err)}`
|
|
3629
|
+
);
|
|
3612
3630
|
return;
|
|
3613
3631
|
}
|
|
3614
3632
|
}
|
|
@@ -3622,7 +3640,9 @@ function injectModelsConfig(logger) {
|
|
|
3622
3640
|
needsWrite = true;
|
|
3623
3641
|
}
|
|
3624
3642
|
} catch (err) {
|
|
3625
|
-
logger.info(
|
|
3643
|
+
logger.info(
|
|
3644
|
+
`Failed to parse config (will recreate): ${err instanceof Error ? err.message : String(err)}`
|
|
3645
|
+
);
|
|
3626
3646
|
config = {};
|
|
3627
3647
|
needsWrite = true;
|
|
3628
3648
|
}
|