@blockrun/clawrouter 0.8.9 → 0.8.10
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 +16 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -908,12 +908,16 @@ function selectModel(tier, confidence, method, reasoning, tierConfigs, modelPric
|
|
|
908
908
|
const tierConfig = tierConfigs[tier];
|
|
909
909
|
const model = tierConfig.primary;
|
|
910
910
|
const pricing = modelPricing.get(model);
|
|
911
|
-
const
|
|
912
|
-
const
|
|
911
|
+
const inputPrice = pricing?.inputPrice ?? 0;
|
|
912
|
+
const outputPrice = pricing?.outputPrice ?? 0;
|
|
913
|
+
const inputCost = estimatedInputTokens / 1e6 * inputPrice;
|
|
914
|
+
const outputCost = maxOutputTokens / 1e6 * outputPrice;
|
|
913
915
|
const costEstimate = inputCost + outputCost;
|
|
914
916
|
const opusPricing = modelPricing.get("anthropic/claude-opus-4");
|
|
915
|
-
const
|
|
916
|
-
const
|
|
917
|
+
const opusInputPrice = opusPricing?.inputPrice ?? 0;
|
|
918
|
+
const opusOutputPrice = opusPricing?.outputPrice ?? 0;
|
|
919
|
+
const baselineInput = estimatedInputTokens / 1e6 * opusInputPrice;
|
|
920
|
+
const baselineOutput = maxOutputTokens / 1e6 * opusOutputPrice;
|
|
917
921
|
const baselineCost = baselineInput + baselineOutput;
|
|
918
922
|
const savings = baselineCost > 0 ? Math.max(0, (baselineCost - costEstimate) / baselineCost) : 0;
|
|
919
923
|
return {
|
|
@@ -933,12 +937,16 @@ function getFallbackChain(tier, tierConfigs) {
|
|
|
933
937
|
}
|
|
934
938
|
function calculateModelCost(model, modelPricing, estimatedInputTokens, maxOutputTokens) {
|
|
935
939
|
const pricing = modelPricing.get(model);
|
|
936
|
-
const
|
|
937
|
-
const
|
|
940
|
+
const inputPrice = pricing?.inputPrice ?? 0;
|
|
941
|
+
const outputPrice = pricing?.outputPrice ?? 0;
|
|
942
|
+
const inputCost = estimatedInputTokens / 1e6 * inputPrice;
|
|
943
|
+
const outputCost = maxOutputTokens / 1e6 * outputPrice;
|
|
938
944
|
const costEstimate = inputCost + outputCost;
|
|
939
945
|
const opusPricing = modelPricing.get("anthropic/claude-opus-4");
|
|
940
|
-
const
|
|
941
|
-
const
|
|
946
|
+
const opusInputPrice = opusPricing?.inputPrice ?? 0;
|
|
947
|
+
const opusOutputPrice = opusPricing?.outputPrice ?? 0;
|
|
948
|
+
const baselineInput = estimatedInputTokens / 1e6 * opusInputPrice;
|
|
949
|
+
const baselineOutput = maxOutputTokens / 1e6 * opusOutputPrice;
|
|
942
950
|
const baselineCost = baselineInput + baselineOutput;
|
|
943
951
|
const savings = baselineCost > 0 ? Math.max(0, (baselineCost - costEstimate) / baselineCost) : 0;
|
|
944
952
|
return { costEstimate, baselineCost, savings };
|