@hashimkarim/usagestat-linux-arm64-gnu 2.3.1 → 2.4.0
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/LICENSE +2250 -758
- package/native-manifest.json +17 -17
- package/package.json +1 -1
- package/plugins/claude/plugin.js +33 -6
- package/plugins/codex/plugin.js +32 -5
- package/usagestat +0 -0
- package/usagestatd +0 -0
package/native-manifest.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"arch": "arm64",
|
|
3
3
|
"archive": {
|
|
4
4
|
"name": "usagestat-linux-aarch64.tar.gz",
|
|
5
|
-
"sha256": "
|
|
6
|
-
"size":
|
|
5
|
+
"sha256": "5632ff30098420b412dbf7cd6578b0980f94f21264a76b71f96089dbbb5b41ed",
|
|
6
|
+
"size": 13773224
|
|
7
7
|
},
|
|
8
8
|
"buildSystem": "Linux-7.0.0-1017-azure-aarch64-with-glibc2.39",
|
|
9
9
|
"dependencies": [
|
|
@@ -49,21 +49,21 @@
|
|
|
49
49
|
"format": "elf",
|
|
50
50
|
"machine": 183,
|
|
51
51
|
"requiredGlibc": "2.39",
|
|
52
|
-
"version": "2.
|
|
52
|
+
"version": "2.4.0"
|
|
53
53
|
},
|
|
54
54
|
"usagestatd": {
|
|
55
55
|
"format": "elf",
|
|
56
56
|
"machine": 183,
|
|
57
57
|
"requiredGlibc": "2.39",
|
|
58
|
-
"version": "2.
|
|
58
|
+
"version": "2.4.0"
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"files": [
|
|
62
62
|
{
|
|
63
63
|
"executable": false,
|
|
64
64
|
"path": "LICENSE",
|
|
65
|
-
"sha256": "
|
|
66
|
-
"size":
|
|
65
|
+
"sha256": "1fa4ef6baf406d09003a812490699525f8ec51597d395440f94ea823c858ba2f",
|
|
66
|
+
"size": 3066598
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
"executable": false,
|
|
@@ -572,8 +572,8 @@
|
|
|
572
572
|
{
|
|
573
573
|
"executable": false,
|
|
574
574
|
"path": "plugins/claude/plugin.js",
|
|
575
|
-
"sha256": "
|
|
576
|
-
"size":
|
|
575
|
+
"sha256": "212c12ed41bb12e3f08d5872c08ee83c0624997edc00a15e501897e4d89a9873",
|
|
576
|
+
"size": 77922
|
|
577
577
|
},
|
|
578
578
|
{
|
|
579
579
|
"executable": false,
|
|
@@ -704,8 +704,8 @@
|
|
|
704
704
|
{
|
|
705
705
|
"executable": false,
|
|
706
706
|
"path": "plugins/codex/plugin.js",
|
|
707
|
-
"sha256": "
|
|
708
|
-
"size":
|
|
707
|
+
"sha256": "1de6aef533646d4e043cce6c357988232f0ad64c3907a1afff9573233718d2b0",
|
|
708
|
+
"size": 36835
|
|
709
709
|
},
|
|
710
710
|
{
|
|
711
711
|
"executable": false,
|
|
@@ -3074,14 +3074,14 @@
|
|
|
3074
3074
|
{
|
|
3075
3075
|
"executable": true,
|
|
3076
3076
|
"path": "usagestat",
|
|
3077
|
-
"sha256": "
|
|
3078
|
-
"size":
|
|
3077
|
+
"sha256": "1695c2261d55076b9b2849234b8783f17145e8976b5443a0be9d5f774bec3f30",
|
|
3078
|
+
"size": 15874040
|
|
3079
3079
|
},
|
|
3080
3080
|
{
|
|
3081
3081
|
"executable": true,
|
|
3082
3082
|
"path": "usagestatd",
|
|
3083
|
-
"sha256": "
|
|
3084
|
-
"size":
|
|
3083
|
+
"sha256": "9efbfd0adda384a1385fde645c7809dcb4e34c4b5298de51029735f7d8a25258",
|
|
3084
|
+
"size": 17009960
|
|
3085
3085
|
}
|
|
3086
3086
|
],
|
|
3087
3087
|
"libc": "glibc",
|
|
@@ -3089,12 +3089,12 @@
|
|
|
3089
3089
|
"minimumSystemQualified": true,
|
|
3090
3090
|
"os": "linux",
|
|
3091
3091
|
"package": "usagestat",
|
|
3092
|
-
"resourcesSha256": "
|
|
3092
|
+
"resourcesSha256": "bc8b69394f081b6628b6146fc0a153a5c14e9b3c932b44aa01b21d8678d5a539",
|
|
3093
3093
|
"schemaVersion": 1,
|
|
3094
3094
|
"signing": "unsigned",
|
|
3095
|
-
"sourceCommit": "
|
|
3095
|
+
"sourceCommit": "a6d134e83e4bef910312075e756360e8dd5b0ca3",
|
|
3096
3096
|
"sourceDirty": false,
|
|
3097
3097
|
"target": "aarch64-unknown-linux-gnu",
|
|
3098
3098
|
"toolchain": "rustc 1.89.0 (29483883e 2025-08-04)\nbinary: rustc\ncommit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2\ncommit-date: 2025-08-04\nhost: aarch64-unknown-linux-gnu\nrelease: 1.89.0\nLLVM version: 20.1.7",
|
|
3099
|
-
"version": "2.
|
|
3099
|
+
"version": "2.4.0"
|
|
3100
3100
|
}
|
package/package.json
CHANGED
package/plugins/claude/plugin.js
CHANGED
|
@@ -683,8 +683,28 @@
|
|
|
683
683
|
return mins + "m"
|
|
684
684
|
}
|
|
685
685
|
|
|
686
|
+
function hasLocalUsage(ctx) {
|
|
687
|
+
return !!(ctx.host.localUsage && typeof ctx.host.localUsage.daily === "function")
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// The host summarizes local logs in the background. Reading its result keeps
|
|
691
|
+
// a quota probe from scanning every transcript again through ccusage. Returns
|
|
692
|
+
// null only when the host cannot cover this log root, so ccusage still can.
|
|
693
|
+
function queryLocalUsage(ctx, sinceStr, homePath) {
|
|
694
|
+
if (!hasLocalUsage(ctx)) return null
|
|
695
|
+
const opts = { since: sinceStr }
|
|
696
|
+
if (homePath) opts.homePath = homePath
|
|
697
|
+
const result = ctx.host.localUsage.daily(opts)
|
|
698
|
+
if (result && result.status === "ok" && result.data && Array.isArray(result.data.daily)) {
|
|
699
|
+
return { status: "ok", data: result.data, native: true }
|
|
700
|
+
}
|
|
701
|
+
if (result && result.status === "not_covered") return null
|
|
702
|
+
// Still warming up: show no local totals this round rather than start a scan.
|
|
703
|
+
return { status: (result && result.status) || "unavailable", data: null }
|
|
704
|
+
}
|
|
705
|
+
|
|
686
706
|
function queryTokenUsage(ctx, homePath) {
|
|
687
|
-
if (!ctx.host.ccusage || typeof ctx.host.ccusage.query !== "function") {
|
|
707
|
+
if (!hasLocalUsage(ctx) && (!ctx.host.ccusage || typeof ctx.host.ccusage.query !== "function")) {
|
|
688
708
|
return { status: "unavailable", data: null }
|
|
689
709
|
}
|
|
690
710
|
|
|
@@ -701,6 +721,9 @@
|
|
|
701
721
|
queryOpts.homePath = homePath
|
|
702
722
|
}
|
|
703
723
|
|
|
724
|
+
const local = queryLocalUsage(ctx, sinceStr, homePath)
|
|
725
|
+
if (local) return local
|
|
726
|
+
|
|
704
727
|
const result = ctx.host.ccusage.query(queryOpts)
|
|
705
728
|
if (!result || typeof result !== "object" || typeof result.status !== "string") {
|
|
706
729
|
return { status: "runner_failed", data: null }
|
|
@@ -1036,7 +1059,8 @@
|
|
|
1036
1059
|
function costAndTokensLabel(data, opts) {
|
|
1037
1060
|
const includeZeroTokens = !!(opts && opts.includeZeroTokens)
|
|
1038
1061
|
const parts = []
|
|
1039
|
-
|
|
1062
|
+
// A partly priced day shows its known cost as a lower bound.
|
|
1063
|
+
if (data.costUSD != null) parts.push("$" + data.costUSD.toFixed(2) + (data.costKnown === false ? "+" : ""))
|
|
1040
1064
|
if (data.tokens > 0 || (includeZeroTokens && data.tokens === 0)) {
|
|
1041
1065
|
parts.push(fmtTokens(data.tokens) + " tokens")
|
|
1042
1066
|
}
|
|
@@ -1069,7 +1093,7 @@
|
|
|
1069
1093
|
label: usageDayLabel(day.date),
|
|
1070
1094
|
value: hasCost ? cost : tokens,
|
|
1071
1095
|
valueLabel: hasCost
|
|
1072
|
-
? "$" + cost.toFixed(2) + " · " + fmtTokens(tokens) + " tokens"
|
|
1096
|
+
? "$" + cost.toFixed(2) + (day.costKnown === false ? "+" : "") + " · " + fmtTokens(tokens) + " tokens"
|
|
1073
1097
|
: fmtTokens(tokens) + " tokens",
|
|
1074
1098
|
})
|
|
1075
1099
|
}
|
|
@@ -1111,7 +1135,7 @@
|
|
|
1111
1135
|
lines.push(ctx.line.text({
|
|
1112
1136
|
label: label,
|
|
1113
1137
|
value: costAndTokensLabel(
|
|
1114
|
-
{ tokens: tokens, costUSD: cost === null ? 0 : cost },
|
|
1138
|
+
{ tokens: tokens, costUSD: cost === null ? 0 : cost, costKnown: dayEntry && dayEntry.costKnown },
|
|
1115
1139
|
{ includeZeroTokens: true }
|
|
1116
1140
|
)
|
|
1117
1141
|
}))
|
|
@@ -1125,7 +1149,7 @@
|
|
|
1125
1149
|
}
|
|
1126
1150
|
|
|
1127
1151
|
function summarizeUsageDaily(daily) {
|
|
1128
|
-
const summary = { tokens: 0, costUSD: 0, hasCost: false }
|
|
1152
|
+
const summary = { tokens: 0, costUSD: 0, hasCost: false, costKnown: true }
|
|
1129
1153
|
const selectedDaily = (daily || []).slice(-30)
|
|
1130
1154
|
for (let i = 0; i < selectedDaily.length; i++) {
|
|
1131
1155
|
const day = selectedDaily[i]
|
|
@@ -1136,6 +1160,7 @@
|
|
|
1136
1160
|
summary.costUSD += dayCost
|
|
1137
1161
|
summary.hasCost = true
|
|
1138
1162
|
}
|
|
1163
|
+
if (day && day.costKnown === false) summary.costKnown = false
|
|
1139
1164
|
}
|
|
1140
1165
|
return summary
|
|
1141
1166
|
}
|
|
@@ -1171,6 +1196,7 @@
|
|
|
1171
1196
|
value: costAndTokensLabel({
|
|
1172
1197
|
tokens: summary.tokens,
|
|
1173
1198
|
costUSD: summary.hasCost ? summary.costUSD : null,
|
|
1199
|
+
costKnown: summary.costKnown,
|
|
1174
1200
|
}, { includeZeroTokens: true })
|
|
1175
1201
|
}))
|
|
1176
1202
|
}
|
|
@@ -1914,7 +1940,8 @@
|
|
|
1914
1940
|
if (usageResult.status === "ok") {
|
|
1915
1941
|
const usage = usageResult.data
|
|
1916
1942
|
appendUsageDailyLines(lines, ctx, usage.daily, "Estimated from local Claude logs at API rates.")
|
|
1917
|
-
|
|
1943
|
+
// The host already saves its own summary as higher-priority history.
|
|
1944
|
+
if (!usageResult.native) persistUsageDaily(ctx, usage.daily, "Claude")
|
|
1918
1945
|
}
|
|
1919
1946
|
} catch (e) {
|
|
1920
1947
|
ctx.host.log.warn("local Claude token usage failed: " + String(e))
|
package/plugins/codex/plugin.js
CHANGED
|
@@ -402,8 +402,28 @@
|
|
|
402
402
|
var PERIOD_SESSION_MS = 5 * 60 * 60 * 1000 // 5 hours
|
|
403
403
|
var PERIOD_WEEKLY_MS = 7 * 24 * 60 * 60 * 1000 // 7 days
|
|
404
404
|
|
|
405
|
+
function hasLocalUsage(ctx) {
|
|
406
|
+
return !!(ctx.host.localUsage && typeof ctx.host.localUsage.daily === "function")
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// The host summarizes local logs in the background. Reading its result keeps
|
|
410
|
+
// a quota probe from scanning every transcript again through ccusage. Returns
|
|
411
|
+
// null only when the host cannot cover this log root, so ccusage still can.
|
|
412
|
+
function queryLocalUsage(ctx, sinceStr, homePath) {
|
|
413
|
+
if (!hasLocalUsage(ctx)) return null
|
|
414
|
+
const opts = { since: sinceStr }
|
|
415
|
+
if (homePath) opts.homePath = homePath
|
|
416
|
+
const result = ctx.host.localUsage.daily(opts)
|
|
417
|
+
if (result && result.status === "ok" && result.data && Array.isArray(result.data.daily)) {
|
|
418
|
+
return { status: "ok", data: result.data, native: true }
|
|
419
|
+
}
|
|
420
|
+
if (result && result.status === "not_covered") return null
|
|
421
|
+
// Still warming up: show no local totals this round rather than start a scan.
|
|
422
|
+
return { status: (result && result.status) || "unavailable", data: null }
|
|
423
|
+
}
|
|
424
|
+
|
|
405
425
|
function queryTokenUsage(ctx) {
|
|
406
|
-
if (!ctx.host.ccusage || typeof ctx.host.ccusage.query !== "function") {
|
|
426
|
+
if (!hasLocalUsage(ctx) && (!ctx.host.ccusage || typeof ctx.host.ccusage.query !== "function")) {
|
|
407
427
|
return { status: "no_runner", data: null }
|
|
408
428
|
}
|
|
409
429
|
|
|
@@ -420,6 +440,9 @@
|
|
|
420
440
|
queryOpts.homePath = codexHome
|
|
421
441
|
}
|
|
422
442
|
|
|
443
|
+
const local = queryLocalUsage(ctx, sinceStr, codexHome)
|
|
444
|
+
if (local) return local
|
|
445
|
+
|
|
423
446
|
const result = ctx.host.ccusage.query(queryOpts)
|
|
424
447
|
if (!result || typeof result !== "object" || typeof result.status !== "string") {
|
|
425
448
|
return { status: "runner_failed", data: null }
|
|
@@ -505,7 +528,8 @@
|
|
|
505
528
|
function costAndTokensLabel(data, opts) {
|
|
506
529
|
const includeZeroTokens = !!(opts && opts.includeZeroTokens)
|
|
507
530
|
const parts = []
|
|
508
|
-
|
|
531
|
+
// A partly priced day shows its known cost as a lower bound.
|
|
532
|
+
if (data.costUSD != null) parts.push("$" + data.costUSD.toFixed(2) + (data.costKnown === false ? "+" : ""))
|
|
509
533
|
if (data.tokens > 0 || (includeZeroTokens && data.tokens === 0)) {
|
|
510
534
|
parts.push(fmtTokens(data.tokens) + " tokens")
|
|
511
535
|
}
|
|
@@ -647,7 +671,7 @@
|
|
|
647
671
|
if (tokens > 0) {
|
|
648
672
|
lines.push(ctx.line.text({
|
|
649
673
|
label: label,
|
|
650
|
-
value: costAndTokensLabel({ tokens: tokens, costUSD: cost })
|
|
674
|
+
value: costAndTokensLabel({ tokens: tokens, costUSD: cost, costKnown: dayEntry.costKnown })
|
|
651
675
|
}))
|
|
652
676
|
return
|
|
653
677
|
}
|
|
@@ -935,6 +959,7 @@
|
|
|
935
959
|
let totalTokens = 0
|
|
936
960
|
let totalCostNanos = 0
|
|
937
961
|
let hasCost = false
|
|
962
|
+
let costKnown = true
|
|
938
963
|
for (let i = 0; i < tokenUsage.daily.length; i++) {
|
|
939
964
|
const day = tokenUsage.daily[i]
|
|
940
965
|
const dayTokens = Number(day.totalTokens)
|
|
@@ -947,17 +972,19 @@
|
|
|
947
972
|
totalCostNanos += Math.round(dayCost * 1e9)
|
|
948
973
|
hasCost = true
|
|
949
974
|
}
|
|
975
|
+
if (day.costKnown === false) costKnown = false
|
|
950
976
|
}
|
|
951
977
|
|
|
952
978
|
if (totalTokens > 0) {
|
|
953
979
|
lines.push(ctx.line.text({
|
|
954
980
|
label: "Last 30 Days",
|
|
955
|
-
value: costAndTokensLabel({ tokens: totalTokens, costUSD: hasCost ? totalCostNanos / 1e9 : null })
|
|
981
|
+
value: costAndTokensLabel({ tokens: totalTokens, costUSD: hasCost ? totalCostNanos / 1e9 : null, costKnown: costKnown })
|
|
956
982
|
}))
|
|
957
983
|
}
|
|
958
984
|
|
|
959
985
|
pushUsageChartLine(lines, ctx, tokenUsage.daily)
|
|
960
|
-
|
|
986
|
+
// The host already saves its own summary as higher-priority history.
|
|
987
|
+
if (!tokenUsageResult.native) persistUsageDaily(ctx, tokenUsage.daily, "Codex")
|
|
961
988
|
}
|
|
962
989
|
} catch (e) {
|
|
963
990
|
ctx.host.log.warn("local Codex token usage failed: " + String(e))
|
package/usagestat
CHANGED
|
Binary file
|
package/usagestatd
CHANGED
|
Binary file
|