ccstatusline-usage 2.0.36 → 2.0.38
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/ccstatusline.js +22 -4
- package/package.json +1 -1
package/dist/ccstatusline.js
CHANGED
|
@@ -51450,7 +51450,7 @@ import { execSync as execSync3 } from "child_process";
|
|
|
51450
51450
|
import * as fs5 from "fs";
|
|
51451
51451
|
import * as path4 from "path";
|
|
51452
51452
|
var __dirname = "/Users/peter/Documents/Code/ccstatusline-usage/src/utils";
|
|
51453
|
-
var PACKAGE_VERSION = "2.0.
|
|
51453
|
+
var PACKAGE_VERSION = "2.0.38";
|
|
51454
51454
|
function getPackageVersion() {
|
|
51455
51455
|
if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
|
|
51456
51456
|
return PACKAGE_VERSION;
|
|
@@ -54487,7 +54487,7 @@ class ClaudeSessionIdWidget {
|
|
|
54487
54487
|
}
|
|
54488
54488
|
}
|
|
54489
54489
|
// src/widgets/ApiUsage.tsx
|
|
54490
|
-
import { execSync as execSync8 } from "child_process";
|
|
54490
|
+
import { execSync as execSync8, spawnSync } from "child_process";
|
|
54491
54491
|
import * as fs7 from "fs";
|
|
54492
54492
|
import * as path6 from "path";
|
|
54493
54493
|
var CACHE_FILE = path6.join(process.env.HOME ?? "", ".cache", "ccstatusline-api.json");
|
|
@@ -54531,7 +54531,19 @@ function fetchApiData() {
|
|
|
54531
54531
|
if (!token)
|
|
54532
54532
|
return null;
|
|
54533
54533
|
try {
|
|
54534
|
-
const
|
|
54534
|
+
const curlResult = spawnSync("curl", [
|
|
54535
|
+
"-s",
|
|
54536
|
+
"--max-time",
|
|
54537
|
+
"5",
|
|
54538
|
+
"https://api.anthropic.com/api/oauth/usage",
|
|
54539
|
+
"-H",
|
|
54540
|
+
`Authorization: Bearer ${token}`,
|
|
54541
|
+
"-H",
|
|
54542
|
+
"anthropic-beta: oauth-2025-04-20"
|
|
54543
|
+
], { encoding: "utf8", timeout: 5000 });
|
|
54544
|
+
if (curlResult.error || curlResult.status !== 0)
|
|
54545
|
+
return null;
|
|
54546
|
+
const result = curlResult.stdout;
|
|
54535
54547
|
const data = JSON.parse(result);
|
|
54536
54548
|
let apiData = {};
|
|
54537
54549
|
if (data.five_hour) {
|
|
@@ -54684,7 +54696,13 @@ class ContextBarWidget {
|
|
|
54684
54696
|
if (!cw)
|
|
54685
54697
|
return null;
|
|
54686
54698
|
const total = Number(cw.context_window_size) || 200000;
|
|
54687
|
-
|
|
54699
|
+
let used = 0;
|
|
54700
|
+
if (typeof cw.current_usage === "number") {
|
|
54701
|
+
used = cw.current_usage;
|
|
54702
|
+
} else if (cw.current_usage && typeof cw.current_usage === "object") {
|
|
54703
|
+
const u = cw.current_usage;
|
|
54704
|
+
used = (Number(u.input_tokens) || 0) + (Number(u.output_tokens) || 0) + (Number(u.cache_creation_input_tokens) || 0) + (Number(u.cache_read_input_tokens) || 0);
|
|
54705
|
+
}
|
|
54688
54706
|
if (isNaN(total) || isNaN(used))
|
|
54689
54707
|
return null;
|
|
54690
54708
|
const percent = total > 0 ? used / total * 100 : 0;
|