aihezu 2.8.4 → 2.8.5
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/commands/usage.js +26 -0
- package/package.json +1 -1
package/commands/usage.js
CHANGED
|
@@ -318,6 +318,21 @@ function formatDurationMinutes(value) {
|
|
|
318
318
|
return `${human} (${minuteText} 分钟)`;
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
+
function formatNumber(value) {
|
|
322
|
+
const n = asNumber(value);
|
|
323
|
+
if (n === null) return '-';
|
|
324
|
+
return n.toLocaleString('en-US');
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function formatCompactNumber(value) {
|
|
328
|
+
const n = asNumber(value);
|
|
329
|
+
if (n === null) return '-';
|
|
330
|
+
if (n >= 1e9) return `${(n / 1e9).toFixed(2)}B`;
|
|
331
|
+
if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
|
|
332
|
+
if (n >= 1e3) return `${(n / 1e3).toFixed(1)}K`;
|
|
333
|
+
return String(n);
|
|
334
|
+
}
|
|
335
|
+
|
|
321
336
|
function renderBar(current, limit, width = 18) {
|
|
322
337
|
const c = asNumber(current);
|
|
323
338
|
const l = asNumber(limit);
|
|
@@ -419,6 +434,10 @@ function displayUsageStats(stats, origin, source) {
|
|
|
419
434
|
return l - c;
|
|
420
435
|
})();
|
|
421
436
|
|
|
437
|
+
// 提取窗口请求次数和 Token 用量
|
|
438
|
+
const currentWindowRequests = (stats.currentWindowRequests !== undefined) ? stats.currentWindowRequests : limits.currentWindowRequests;
|
|
439
|
+
const currentWindowTokens = (stats.currentWindowTokens !== undefined) ? stats.currentWindowTokens : limits.currentWindowTokens;
|
|
440
|
+
|
|
422
441
|
console.log(`域名: ${origin}`);
|
|
423
442
|
console.log(`来源: ${source}`);
|
|
424
443
|
console.log('');
|
|
@@ -438,6 +457,12 @@ function displayUsageStats(stats, origin, source) {
|
|
|
438
457
|
if (windowRemaining !== null) {
|
|
439
458
|
console.log(`窗口剩余: ${formatCost(windowRemaining)}`);
|
|
440
459
|
}
|
|
460
|
+
if (asNumber(currentWindowRequests) !== null || asNumber(currentWindowTokens) !== null) {
|
|
461
|
+
const parts = [];
|
|
462
|
+
if (asNumber(currentWindowRequests) !== null) parts.push(`请求 ${formatNumber(currentWindowRequests)} 次`);
|
|
463
|
+
if (asNumber(currentWindowTokens) !== null) parts.push(`Token ${formatNumber(currentWindowTokens)}`);
|
|
464
|
+
console.log(`窗口统计: ${parts.join(' | ')}`);
|
|
465
|
+
}
|
|
441
466
|
const windowStartText = formatDateTime(windowStartTime);
|
|
442
467
|
const windowEndText = formatDateTime(windowEndTime);
|
|
443
468
|
if (windowStartText !== '-' || windowEndText !== '-') {
|
|
@@ -457,6 +482,7 @@ function displayUsageStats(stats, origin, source) {
|
|
|
457
482
|
if (resetCountdownText !== '-') {
|
|
458
483
|
console.log(`窗口剩余时间: ${resetCountdownText} (距重置)`);
|
|
459
484
|
}
|
|
485
|
+
|
|
460
486
|
console.log('');
|
|
461
487
|
}
|
|
462
488
|
|