awarts 0.2.2 → 0.2.3
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 +27 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5880,6 +5880,27 @@ import path4 from "node:path";
|
|
|
5880
5880
|
import os5 from "node:os";
|
|
5881
5881
|
var CLAUDE_DIR = path4.join(os5.homedir(), ".claude");
|
|
5882
5882
|
var STATS_CACHE = path4.join(CLAUDE_DIR, "stats-cache.json");
|
|
5883
|
+
var MODEL_PRICING = {
|
|
5884
|
+
"claude-opus-4-6": { input: 15, output: 75, cacheRead: 1.875, cacheWrite: 18.75 },
|
|
5885
|
+
"claude-opus-4": { input: 15, output: 75, cacheRead: 1.875, cacheWrite: 18.75 },
|
|
5886
|
+
"claude-sonnet-4": { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
5887
|
+
"claude-sonnet-3-5": { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
5888
|
+
"claude-haiku-3-5": { input: 0.8, output: 4, cacheRead: 0.08, cacheWrite: 1 }
|
|
5889
|
+
};
|
|
5890
|
+
var DEFAULT_PRICING = { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 };
|
|
5891
|
+
function getPricing(model) {
|
|
5892
|
+
if (MODEL_PRICING[model])
|
|
5893
|
+
return MODEL_PRICING[model];
|
|
5894
|
+
for (const [key, pricing] of Object.entries(MODEL_PRICING)) {
|
|
5895
|
+
if (model.startsWith(key))
|
|
5896
|
+
return pricing;
|
|
5897
|
+
}
|
|
5898
|
+
return DEFAULT_PRICING;
|
|
5899
|
+
}
|
|
5900
|
+
function estimateCost(model, inputTokens, outputTokens, cacheReadTokens, cacheCreationTokens) {
|
|
5901
|
+
const p = getPricing(model);
|
|
5902
|
+
return inputTokens / 1e6 * p.input + outputTokens / 1e6 * p.output + cacheReadTokens / 1e6 * p.cacheRead + cacheCreationTokens / 1e6 * p.cacheWrite;
|
|
5903
|
+
}
|
|
5883
5904
|
async function fileExists(filePath) {
|
|
5884
5905
|
try {
|
|
5885
5906
|
const stat = await fs8.stat(filePath);
|
|
@@ -5908,12 +5929,16 @@ async function readStatsCache() {
|
|
|
5908
5929
|
let totalCacheCreation = 0;
|
|
5909
5930
|
let totalCost = 0;
|
|
5910
5931
|
if (cache.modelUsage) {
|
|
5911
|
-
for (const usage of Object.
|
|
5932
|
+
for (const [model, usage] of Object.entries(cache.modelUsage)) {
|
|
5912
5933
|
totalInputTokens += usage.inputTokens || 0;
|
|
5913
5934
|
totalOutputTokens += usage.outputTokens || 0;
|
|
5914
5935
|
totalCacheRead += usage.cacheReadInputTokens || 0;
|
|
5915
5936
|
totalCacheCreation += usage.cacheCreationInputTokens || 0;
|
|
5916
|
-
|
|
5937
|
+
if (usage.costUSD > 0) {
|
|
5938
|
+
totalCost += usage.costUSD;
|
|
5939
|
+
} else {
|
|
5940
|
+
totalCost += estimateCost(model, usage.inputTokens || 0, usage.outputTokens || 0, usage.cacheReadInputTokens || 0, usage.cacheCreationInputTokens || 0);
|
|
5941
|
+
}
|
|
5917
5942
|
}
|
|
5918
5943
|
}
|
|
5919
5944
|
const dailyOutputSum = dailyTokens.reduce((sum, day) => {
|