tokentracker-cli 0.2.26 → 0.2.27
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/dashboard/dist/assets/{AsciiBox-fxqdUErY.js → AsciiBox-BZ2xYyXa.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-rdYpdfso.js → DashboardPage-ynq92wZf.js} +1 -1
- package/dashboard/dist/assets/{LandingExtras-7PDallbH.js → LandingExtras-BUwK_c-9.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-CU_JeLPO.js → LeaderboardPage-IzN8LibU.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfilePage-D3B45Jjd.js → LeaderboardProfilePage-3JjGYRaz.js} +1 -1
- package/dashboard/dist/assets/{MatrixRain-DR9XEe-r.js → MatrixRain-D7Pm88QF.js} +1 -1
- package/dashboard/dist/assets/{MatrixShell-B6_X7zAp.js → MatrixShell-BtjokX5f.js} +1 -1
- package/dashboard/dist/assets/{main-B206gspN.js → main-oIbJf8pA.js} +4 -4
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/lib/local-api.js +12 -12
- package/src/lib/rollout.js +33 -7
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
]
|
|
108
108
|
}
|
|
109
109
|
</script>
|
|
110
|
-
<script type="module" crossorigin src="/assets/main-
|
|
110
|
+
<script type="module" crossorigin src="/assets/main-oIbJf8pA.js"></script>
|
|
111
111
|
<link rel="stylesheet" crossorigin href="/assets/main-hwTpulbk.css">
|
|
112
112
|
</head>
|
|
113
113
|
<body>
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"description": "Shareable Token Tracker dashboard snapshot."
|
|
52
52
|
}
|
|
53
53
|
</script>
|
|
54
|
-
<script type="module" crossorigin src="/assets/main-
|
|
54
|
+
<script type="module" crossorigin src="/assets/main-oIbJf8pA.js"></script>
|
|
55
55
|
<link rel="stylesheet" crossorigin href="/assets/main-hwTpulbk.css">
|
|
56
56
|
</head>
|
|
57
57
|
<body>
|
package/package.json
CHANGED
package/src/lib/local-api.js
CHANGED
|
@@ -12,14 +12,7 @@ const TRACKER_BIN = path.resolve(__dirname, "../../bin/tracker.js");
|
|
|
12
12
|
|
|
13
13
|
function resolveQueuePath() {
|
|
14
14
|
const home = os.homedir();
|
|
15
|
-
|
|
16
|
-
path.join(home, ".tokentracker", "tracker", "queue.jsonl"),
|
|
17
|
-
path.join(home, ".vibeusage", "tracker", "queue.jsonl"),
|
|
18
|
-
];
|
|
19
|
-
for (const p of candidates) {
|
|
20
|
-
if (fs.existsSync(p)) return p;
|
|
21
|
-
}
|
|
22
|
-
return candidates[0];
|
|
15
|
+
return path.join(home, ".tokentracker", "tracker", "queue.jsonl");
|
|
23
16
|
}
|
|
24
17
|
|
|
25
18
|
function readQueueData(queuePath) {
|
|
@@ -46,6 +39,7 @@ function aggregateByDay(rows) {
|
|
|
46
39
|
input_tokens: 0,
|
|
47
40
|
output_tokens: 0,
|
|
48
41
|
cached_input_tokens: 0,
|
|
42
|
+
cache_creation_input_tokens: 0,
|
|
49
43
|
reasoning_output_tokens: 0,
|
|
50
44
|
conversation_count: 0,
|
|
51
45
|
});
|
|
@@ -56,6 +50,7 @@ function aggregateByDay(rows) {
|
|
|
56
50
|
a.input_tokens += row.input_tokens || 0;
|
|
57
51
|
a.output_tokens += row.output_tokens || 0;
|
|
58
52
|
a.cached_input_tokens += row.cached_input_tokens || 0;
|
|
53
|
+
a.cache_creation_input_tokens += row.cache_creation_input_tokens || 0;
|
|
59
54
|
a.reasoning_output_tokens += row.reasoning_output_tokens || 0;
|
|
60
55
|
a.conversation_count += row.conversation_count || 0;
|
|
61
56
|
}
|
|
@@ -261,11 +256,12 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
261
256
|
acc.input_tokens += r.input_tokens;
|
|
262
257
|
acc.output_tokens += r.output_tokens;
|
|
263
258
|
acc.cached_input_tokens += r.cached_input_tokens;
|
|
259
|
+
acc.cache_creation_input_tokens += r.cache_creation_input_tokens;
|
|
264
260
|
acc.reasoning_output_tokens += r.reasoning_output_tokens;
|
|
265
261
|
acc.conversation_count += r.conversation_count;
|
|
266
262
|
return acc;
|
|
267
263
|
},
|
|
268
|
-
{ total_tokens: 0, billable_total_tokens: 0, input_tokens: 0, output_tokens: 0, cached_input_tokens: 0, reasoning_output_tokens: 0, conversation_count: 0 },
|
|
264
|
+
{ total_tokens: 0, billable_total_tokens: 0, input_tokens: 0, output_tokens: 0, cached_input_tokens: 0, cache_creation_input_tokens: 0, reasoning_output_tokens: 0, conversation_count: 0 },
|
|
269
265
|
);
|
|
270
266
|
const totalCost = (totals.total_tokens * 1.75) / 1_000_000;
|
|
271
267
|
|
|
@@ -379,22 +375,24 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
379
375
|
const src = row.source || "unknown";
|
|
380
376
|
const mdl = row.model || "unknown";
|
|
381
377
|
if (!bySource.has(src))
|
|
382
|
-
bySource.set(src, { source: src, totals: { total_tokens: 0, billable_total_tokens: 0, input_tokens: 0, output_tokens: 0, cached_input_tokens: 0, reasoning_output_tokens: 0, total_cost_usd: "0" }, models: new Map() });
|
|
378
|
+
bySource.set(src, { source: src, totals: { total_tokens: 0, billable_total_tokens: 0, input_tokens: 0, output_tokens: 0, cached_input_tokens: 0, cache_creation_input_tokens: 0, reasoning_output_tokens: 0, total_cost_usd: "0" }, models: new Map() });
|
|
383
379
|
const sa = bySource.get(src);
|
|
384
380
|
sa.totals.total_tokens += row.total_tokens || 0;
|
|
385
381
|
sa.totals.billable_total_tokens += row.total_tokens || 0;
|
|
386
382
|
sa.totals.input_tokens += row.input_tokens || 0;
|
|
387
383
|
sa.totals.output_tokens += row.output_tokens || 0;
|
|
388
384
|
sa.totals.cached_input_tokens += row.cached_input_tokens || 0;
|
|
385
|
+
sa.totals.cache_creation_input_tokens += row.cache_creation_input_tokens || 0;
|
|
389
386
|
sa.totals.reasoning_output_tokens += row.reasoning_output_tokens || 0;
|
|
390
387
|
if (!sa.models.has(mdl))
|
|
391
|
-
sa.models.set(mdl, { model: mdl, model_id: mdl, totals: { total_tokens: 0, billable_total_tokens: 0, input_tokens: 0, output_tokens: 0, cached_input_tokens: 0, reasoning_output_tokens: 0, total_cost_usd: "0" } });
|
|
388
|
+
sa.models.set(mdl, { model: mdl, model_id: mdl, totals: { total_tokens: 0, billable_total_tokens: 0, input_tokens: 0, output_tokens: 0, cached_input_tokens: 0, cache_creation_input_tokens: 0, reasoning_output_tokens: 0, total_cost_usd: "0" } });
|
|
392
389
|
const ma = sa.models.get(mdl);
|
|
393
390
|
ma.totals.total_tokens += row.total_tokens || 0;
|
|
394
391
|
ma.totals.billable_total_tokens += row.total_tokens || 0;
|
|
395
392
|
ma.totals.input_tokens += row.input_tokens || 0;
|
|
396
393
|
ma.totals.output_tokens += row.output_tokens || 0;
|
|
397
394
|
ma.totals.cached_input_tokens += row.cached_input_tokens || 0;
|
|
395
|
+
ma.totals.cache_creation_input_tokens += row.cache_creation_input_tokens || 0;
|
|
398
396
|
ma.totals.reasoning_output_tokens += row.reasoning_output_tokens || 0;
|
|
399
397
|
}
|
|
400
398
|
|
|
@@ -471,6 +469,7 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
471
469
|
input_tokens: r.input_tokens || 0,
|
|
472
470
|
output_tokens: r.output_tokens || 0,
|
|
473
471
|
cached_input_tokens: r.cached_input_tokens || 0,
|
|
472
|
+
cache_creation_input_tokens: r.cache_creation_input_tokens || 0,
|
|
474
473
|
reasoning_output_tokens: r.reasoning_output_tokens || 0,
|
|
475
474
|
conversation_count: r.conversation_count || 0,
|
|
476
475
|
}));
|
|
@@ -490,13 +489,14 @@ function createLocalApiHandler({ queuePath }) {
|
|
|
490
489
|
if (day < from || day > to) continue;
|
|
491
490
|
const month = day.slice(0, 7);
|
|
492
491
|
if (!byMonth.has(month))
|
|
493
|
-
byMonth.set(month, { month, total_tokens: 0, billable_total_tokens: 0, input_tokens: 0, output_tokens: 0, cached_input_tokens: 0, reasoning_output_tokens: 0, conversation_count: 0 });
|
|
492
|
+
byMonth.set(month, { month, total_tokens: 0, billable_total_tokens: 0, input_tokens: 0, output_tokens: 0, cached_input_tokens: 0, cache_creation_input_tokens: 0, reasoning_output_tokens: 0, conversation_count: 0 });
|
|
494
493
|
const a = byMonth.get(month);
|
|
495
494
|
a.total_tokens += row.total_tokens || 0;
|
|
496
495
|
a.billable_total_tokens += row.total_tokens || 0;
|
|
497
496
|
a.input_tokens += row.input_tokens || 0;
|
|
498
497
|
a.output_tokens += row.output_tokens || 0;
|
|
499
498
|
a.cached_input_tokens += row.cached_input_tokens || 0;
|
|
499
|
+
a.cache_creation_input_tokens += row.cache_creation_input_tokens || 0;
|
|
500
500
|
a.reasoning_output_tokens += row.reasoning_output_tokens || 0;
|
|
501
501
|
a.conversation_count += row.conversation_count || 0;
|
|
502
502
|
}
|
package/src/lib/rollout.js
CHANGED
|
@@ -206,6 +206,7 @@ async function parseClaudeIncremental({
|
|
|
206
206
|
const projectMetaCache = projectEnabled ? new Map() : null;
|
|
207
207
|
const publicRepoCache = projectEnabled ? new Map() : null;
|
|
208
208
|
const touchedBuckets = new Set();
|
|
209
|
+
const seenMessageHashes = new Set();
|
|
209
210
|
const defaultSource = normalizeSourceInput(source) || "claude";
|
|
210
211
|
|
|
211
212
|
if (!cursors.files || typeof cursors.files !== "object") {
|
|
@@ -250,6 +251,7 @@ async function parseClaudeIncremental({
|
|
|
250
251
|
projectTouchedBuckets,
|
|
251
252
|
projectRef,
|
|
252
253
|
projectKey,
|
|
254
|
+
seenMessageHashes,
|
|
253
255
|
});
|
|
254
256
|
|
|
255
257
|
cursors.files[key] = {
|
|
@@ -822,6 +824,7 @@ async function parseClaudeFile({
|
|
|
822
824
|
projectTouchedBuckets,
|
|
823
825
|
projectRef,
|
|
824
826
|
projectKey,
|
|
827
|
+
seenMessageHashes,
|
|
825
828
|
}) {
|
|
826
829
|
const st = await fs.stat(filePath).catch(() => null);
|
|
827
830
|
if (!st || !st.isFile()) return { endOffset: startOffset, eventsAggregated: 0 };
|
|
@@ -845,6 +848,16 @@ async function parseClaudeFile({
|
|
|
845
848
|
const usage = obj?.message?.usage || obj?.usage;
|
|
846
849
|
if (!usage || typeof usage !== "object") continue;
|
|
847
850
|
|
|
851
|
+
if (seenMessageHashes) {
|
|
852
|
+
const msgId = obj?.message?.id;
|
|
853
|
+
const reqId = obj?.requestId;
|
|
854
|
+
if (msgId && reqId) {
|
|
855
|
+
const hash = `${msgId}:${reqId}`;
|
|
856
|
+
if (seenMessageHashes.has(hash)) continue;
|
|
857
|
+
seenMessageHashes.add(hash);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
848
861
|
const model = normalizeModelInput(obj?.message?.model || obj?.model) || DEFAULT_MODEL;
|
|
849
862
|
const tokenTimestamp = typeof obj?.timestamp === "string" ? obj.timestamp : null;
|
|
850
863
|
if (!tokenTimestamp) continue;
|
|
@@ -1180,6 +1193,7 @@ async function enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets })
|
|
|
1180
1193
|
hour_start: group.hourStart,
|
|
1181
1194
|
input_tokens: zeroTotals.input_tokens,
|
|
1182
1195
|
cached_input_tokens: zeroTotals.cached_input_tokens,
|
|
1196
|
+
cache_creation_input_tokens: zeroTotals.cache_creation_input_tokens,
|
|
1183
1197
|
output_tokens: zeroTotals.output_tokens,
|
|
1184
1198
|
reasoning_output_tokens: zeroTotals.reasoning_output_tokens,
|
|
1185
1199
|
total_tokens: zeroTotals.total_tokens,
|
|
@@ -1227,6 +1241,7 @@ async function enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets })
|
|
|
1227
1241
|
hour_start: group.hourStart,
|
|
1228
1242
|
input_tokens: totals.input_tokens,
|
|
1229
1243
|
cached_input_tokens: totals.cached_input_tokens,
|
|
1244
|
+
cache_creation_input_tokens: totals.cache_creation_input_tokens,
|
|
1230
1245
|
output_tokens: totals.output_tokens,
|
|
1231
1246
|
reasoning_output_tokens: totals.reasoning_output_tokens,
|
|
1232
1247
|
total_tokens: totals.total_tokens,
|
|
@@ -1274,6 +1289,7 @@ async function enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets })
|
|
|
1274
1289
|
hour_start: group.hourStart,
|
|
1275
1290
|
input_tokens: zeroTotals.input_tokens,
|
|
1276
1291
|
cached_input_tokens: zeroTotals.cached_input_tokens,
|
|
1292
|
+
cache_creation_input_tokens: zeroTotals.cache_creation_input_tokens,
|
|
1277
1293
|
output_tokens: zeroTotals.output_tokens,
|
|
1278
1294
|
reasoning_output_tokens: zeroTotals.reasoning_output_tokens,
|
|
1279
1295
|
total_tokens: zeroTotals.total_tokens,
|
|
@@ -1294,6 +1310,7 @@ async function enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets })
|
|
|
1294
1310
|
hour_start: group.hourStart,
|
|
1295
1311
|
input_tokens: unknownBucket.totals.input_tokens,
|
|
1296
1312
|
cached_input_tokens: unknownBucket.totals.cached_input_tokens,
|
|
1313
|
+
cache_creation_input_tokens: unknownBucket.totals.cache_creation_input_tokens,
|
|
1297
1314
|
output_tokens: unknownBucket.totals.output_tokens,
|
|
1298
1315
|
reasoning_output_tokens: unknownBucket.totals.reasoning_output_tokens,
|
|
1299
1316
|
total_tokens: unknownBucket.totals.total_tokens,
|
|
@@ -1339,6 +1356,7 @@ async function enqueueTouchedBuckets({ queuePath, hourlyState, touchedBuckets })
|
|
|
1339
1356
|
hour_start: group.hourStart,
|
|
1340
1357
|
input_tokens: group.totals.input_tokens,
|
|
1341
1358
|
cached_input_tokens: group.totals.cached_input_tokens,
|
|
1359
|
+
cache_creation_input_tokens: group.totals.cache_creation_input_tokens,
|
|
1342
1360
|
output_tokens: group.totals.output_tokens,
|
|
1343
1361
|
reasoning_output_tokens: group.totals.reasoning_output_tokens,
|
|
1344
1362
|
total_tokens: group.totals.total_tokens,
|
|
@@ -1392,6 +1410,7 @@ async function enqueueTouchedProjectBuckets({
|
|
|
1392
1410
|
hour_start: bucket.hour_start,
|
|
1393
1411
|
input_tokens: totals.input_tokens,
|
|
1394
1412
|
cached_input_tokens: totals.cached_input_tokens,
|
|
1413
|
+
cache_creation_input_tokens: totals.cache_creation_input_tokens,
|
|
1395
1414
|
output_tokens: totals.output_tokens,
|
|
1396
1415
|
reasoning_output_tokens: totals.reasoning_output_tokens,
|
|
1397
1416
|
total_tokens: totals.total_tokens,
|
|
@@ -1646,6 +1665,7 @@ function initTotals() {
|
|
|
1646
1665
|
return {
|
|
1647
1666
|
input_tokens: 0,
|
|
1648
1667
|
cached_input_tokens: 0,
|
|
1668
|
+
cache_creation_input_tokens: 0,
|
|
1649
1669
|
output_tokens: 0,
|
|
1650
1670
|
reasoning_output_tokens: 0,
|
|
1651
1671
|
total_tokens: 0,
|
|
@@ -1656,6 +1676,7 @@ function initTotals() {
|
|
|
1656
1676
|
function addTotals(target, delta) {
|
|
1657
1677
|
target.input_tokens += delta.input_tokens || 0;
|
|
1658
1678
|
target.cached_input_tokens += delta.cached_input_tokens || 0;
|
|
1679
|
+
target.cache_creation_input_tokens += delta.cache_creation_input_tokens || 0;
|
|
1659
1680
|
target.output_tokens += delta.output_tokens || 0;
|
|
1660
1681
|
target.reasoning_output_tokens += delta.reasoning_output_tokens || 0;
|
|
1661
1682
|
target.total_tokens += delta.total_tokens || 0;
|
|
@@ -1666,6 +1687,7 @@ function totalsKey(totals) {
|
|
|
1666
1687
|
return [
|
|
1667
1688
|
totals.input_tokens || 0,
|
|
1668
1689
|
totals.cached_input_tokens || 0,
|
|
1690
|
+
totals.cache_creation_input_tokens || 0,
|
|
1669
1691
|
totals.output_tokens || 0,
|
|
1670
1692
|
totals.reasoning_output_tokens || 0,
|
|
1671
1693
|
totals.total_tokens || 0,
|
|
@@ -1998,6 +2020,7 @@ function normalizeGeminiTokens(tokens) {
|
|
|
1998
2020
|
return {
|
|
1999
2021
|
input_tokens: input,
|
|
2000
2022
|
cached_input_tokens: cached,
|
|
2023
|
+
cache_creation_input_tokens: 0,
|
|
2001
2024
|
output_tokens: output + tool,
|
|
2002
2025
|
reasoning_output_tokens: thoughts,
|
|
2003
2026
|
total_tokens: total,
|
|
@@ -2011,12 +2034,12 @@ function normalizeOpencodeTokens(tokens) {
|
|
|
2011
2034
|
const reasoning = toNonNegativeInt(tokens.reasoning);
|
|
2012
2035
|
const cached = toNonNegativeInt(tokens.cache?.read);
|
|
2013
2036
|
const cacheWrite = toNonNegativeInt(tokens.cache?.write);
|
|
2014
|
-
|
|
2015
|
-
const total = input + output + reasoning;
|
|
2037
|
+
const total = input + output + reasoning + cached + cacheWrite;
|
|
2016
2038
|
|
|
2017
2039
|
return {
|
|
2018
2040
|
input_tokens: input,
|
|
2019
2041
|
cached_input_tokens: cached,
|
|
2042
|
+
cache_creation_input_tokens: cacheWrite,
|
|
2020
2043
|
output_tokens: output,
|
|
2021
2044
|
reasoning_output_tokens: reasoning,
|
|
2022
2045
|
total_tokens: total,
|
|
@@ -2122,6 +2145,7 @@ function normalizeUsage(u) {
|
|
|
2122
2145
|
for (const k of [
|
|
2123
2146
|
"input_tokens",
|
|
2124
2147
|
"cached_input_tokens",
|
|
2148
|
+
"cache_creation_input_tokens",
|
|
2125
2149
|
"output_tokens",
|
|
2126
2150
|
"reasoning_output_tokens",
|
|
2127
2151
|
"total_tokens",
|
|
@@ -2135,13 +2159,13 @@ function normalizeUsage(u) {
|
|
|
2135
2159
|
function normalizeClaudeUsage(u) {
|
|
2136
2160
|
const inputTokens = toNonNegativeInt(u?.input_tokens);
|
|
2137
2161
|
const outputTokens = toNonNegativeInt(u?.output_tokens);
|
|
2138
|
-
const
|
|
2139
|
-
const
|
|
2140
|
-
|
|
2141
|
-
: inputTokens + outputTokens;
|
|
2162
|
+
const cacheCreation = toNonNegativeInt(u?.cache_creation_input_tokens);
|
|
2163
|
+
const cacheRead = toNonNegativeInt(u?.cache_read_input_tokens);
|
|
2164
|
+
const totalTokens = inputTokens + outputTokens + cacheCreation + cacheRead;
|
|
2142
2165
|
return {
|
|
2143
2166
|
input_tokens: inputTokens,
|
|
2144
|
-
cached_input_tokens:
|
|
2167
|
+
cached_input_tokens: cacheRead,
|
|
2168
|
+
cache_creation_input_tokens: cacheCreation,
|
|
2145
2169
|
output_tokens: outputTokens,
|
|
2146
2170
|
reasoning_output_tokens: 0,
|
|
2147
2171
|
total_tokens: totalTokens,
|
|
@@ -2157,6 +2181,7 @@ function isAllZeroUsage(u) {
|
|
|
2157
2181
|
for (const k of [
|
|
2158
2182
|
"input_tokens",
|
|
2159
2183
|
"cached_input_tokens",
|
|
2184
|
+
"cache_creation_input_tokens",
|
|
2160
2185
|
"output_tokens",
|
|
2161
2186
|
"reasoning_output_tokens",
|
|
2162
2187
|
"total_tokens",
|
|
@@ -2170,6 +2195,7 @@ function sameUsage(a, b) {
|
|
|
2170
2195
|
for (const k of [
|
|
2171
2196
|
"input_tokens",
|
|
2172
2197
|
"cached_input_tokens",
|
|
2198
|
+
"cache_creation_input_tokens",
|
|
2173
2199
|
"output_tokens",
|
|
2174
2200
|
"reasoning_output_tokens",
|
|
2175
2201
|
"total_tokens",
|