gusage 1.2.0 → 1.3.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/dist/index.js +28 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { execSync, spawn } from "child_process";
|
|
|
11
11
|
// package.json
|
|
12
12
|
var package_default = {
|
|
13
13
|
name: "gusage",
|
|
14
|
-
version: "1.
|
|
14
|
+
version: "1.3.0",
|
|
15
15
|
description: "A standalone CLI to export Gemini CLI quota and usage statistics",
|
|
16
16
|
module: "index.ts",
|
|
17
17
|
type: "module",
|
|
@@ -66,7 +66,7 @@ var MAIN_ACCOUNT_KEY = "main-account";
|
|
|
66
66
|
var ENCRYPTED_FILE_NAME = "mcp-oauth-tokens-v2.json";
|
|
67
67
|
var LEGACY_OAUTH_FILE = "oauth_creds.json";
|
|
68
68
|
var VALID_GEMINI_MODELS = new Set([
|
|
69
|
-
"gemini-3-pro-preview",
|
|
69
|
+
"gemini-3.1-pro-preview",
|
|
70
70
|
"gemini-3-flash-preview",
|
|
71
71
|
"gemini-2.5-pro",
|
|
72
72
|
"gemini-2.5-flash",
|
|
@@ -136,6 +136,27 @@ function validateNotifyRuntime(notifyThreshold, isWatching, hasNotificationSuppo
|
|
|
136
136
|
function shouldSendThresholdNotification(prevFraction, currentFraction, threshold) {
|
|
137
137
|
return prevFraction !== undefined && prevFraction > threshold && currentFraction <= threshold;
|
|
138
138
|
}
|
|
139
|
+
function parseWatchIntervalArg(raw) {
|
|
140
|
+
let totalMs = 0;
|
|
141
|
+
let found = false;
|
|
142
|
+
const normalizedParts = [];
|
|
143
|
+
const matches = raw.matchAll(/(\d+)(h|m|s)?/g);
|
|
144
|
+
for (const match of matches) {
|
|
145
|
+
found = true;
|
|
146
|
+
const val = parseInt(match[1], 10);
|
|
147
|
+
const unit = match[2] || "s";
|
|
148
|
+
normalizedParts.push(`${val}${unit}`);
|
|
149
|
+
if (unit === "s")
|
|
150
|
+
totalMs += val * 1000;
|
|
151
|
+
else if (unit === "m")
|
|
152
|
+
totalMs += val * 60000;
|
|
153
|
+
else if (unit === "h")
|
|
154
|
+
totalMs += val * 3600000;
|
|
155
|
+
}
|
|
156
|
+
if (!found)
|
|
157
|
+
return null;
|
|
158
|
+
return { intervalMs: totalMs, intervalStr: normalizedParts.join("") };
|
|
159
|
+
}
|
|
139
160
|
function parseVersion(modelId) {
|
|
140
161
|
const match = modelId.match(/gemini-(\d+)(?:\.(\d+))?-(.*)/);
|
|
141
162
|
if (match) {
|
|
@@ -236,23 +257,10 @@ Options:
|
|
|
236
257
|
let intervalMs = 1e4;
|
|
237
258
|
let intervalStr = "10s";
|
|
238
259
|
if (values.watch) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
found = true;
|
|
244
|
-
const val = parseInt(match[1], 10);
|
|
245
|
-
const unit = match[2] || "s";
|
|
246
|
-
if (unit === "s")
|
|
247
|
-
totalMs += val * 1000;
|
|
248
|
-
else if (unit === "m")
|
|
249
|
-
totalMs += val * 60000;
|
|
250
|
-
else if (unit === "h")
|
|
251
|
-
totalMs += val * 3600000;
|
|
252
|
-
}
|
|
253
|
-
if (found) {
|
|
254
|
-
intervalMs = totalMs;
|
|
255
|
-
intervalStr = values.watch;
|
|
260
|
+
const parsedWatch = parseWatchIntervalArg(values.watch);
|
|
261
|
+
if (parsedWatch) {
|
|
262
|
+
intervalMs = parsedWatch.intervalMs;
|
|
263
|
+
intervalStr = parsedWatch.intervalStr;
|
|
256
264
|
}
|
|
257
265
|
}
|
|
258
266
|
const useColor = !values["no-color"] && !process.env.NO_COLOR && process.stdout.isTTY;
|
|
@@ -511,6 +519,7 @@ async function refreshAccessToken(refreshToken) {
|
|
|
511
519
|
export {
|
|
512
520
|
validateNotifyRuntime,
|
|
513
521
|
shouldSendThresholdNotification,
|
|
522
|
+
parseWatchIntervalArg,
|
|
514
523
|
parseNotifyThresholdArg,
|
|
515
524
|
main as default
|
|
516
525
|
};
|