minimax-status 1.2.1 → 1.2.2
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/cli/api.js +37 -18
- package/cli/index.js +1 -1
- package/cli/renderer.js +7 -3
- package/cli/status.js +19 -21
- package/cli/statusbar.js +12 -5
- package/package.json +1 -1
package/cli/api.js
CHANGED
|
@@ -81,10 +81,11 @@ class MinimaxAPI {
|
|
|
81
81
|
|
|
82
82
|
try {
|
|
83
83
|
const response = await axios.get(
|
|
84
|
-
`https://www.minimaxi.com/v1/
|
|
84
|
+
`https://www.minimaxi.com/v1/api/openplatform/coding_plan/remains`,
|
|
85
85
|
{
|
|
86
86
|
headers: {
|
|
87
87
|
Authorization: `Bearer ${this.token}`,
|
|
88
|
+
referer: "https://platform.minimaxi.com/",
|
|
88
89
|
Accept: "application/json",
|
|
89
90
|
},
|
|
90
91
|
timeout: 10000, // 10秒超时
|
|
@@ -296,24 +297,33 @@ class MinimaxAPI {
|
|
|
296
297
|
const endTime = new Date(modelData.end_time);
|
|
297
298
|
|
|
298
299
|
// Calculate counts
|
|
299
|
-
// 新接口 usage_count
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const usedPercentage =
|
|
305
|
-
(
|
|
306
|
-
|
|
300
|
+
// ⚠ 新接口 usage_count 在 video 上语义不一致(usage=3/total=3 但 remaining_percent=100
|
|
301
|
+
// 表示 0% 已用),用 usedPercentage 反算 used(用户视角 = 基于官网显示的已用%)。
|
|
302
|
+
// 这让 video: total=3, usedPercentage=0 → used=0, remaining=3("3/3 剩余"),跟官网一致。
|
|
303
|
+
const totalCount = modelData.current_interval_total_count;
|
|
304
|
+
const remainingPct = modelData.current_interval_remaining_percent;
|
|
305
|
+
const usedPercentage = remainingPct !== undefined && remainingPct !== null
|
|
306
|
+
? Math.round(100 - remainingPct)
|
|
307
|
+
: (totalCount > 0 ? Math.round((modelData.current_interval_usage_count / totalCount) * 100) : 0);
|
|
308
|
+
const usedCount = totalCount > 0 ? Math.round((totalCount * usedPercentage) / 100) : 0;
|
|
309
|
+
const remainingCount = totalCount - usedCount;
|
|
307
310
|
|
|
308
311
|
// Calculate remaining time in human-readable format
|
|
309
312
|
const remainingMs = modelData.remains_time;
|
|
310
313
|
const hours = Math.floor(remainingMs / (1000 * 60 * 60));
|
|
311
314
|
const minutes = Math.floor((remainingMs % (1000 * 60 * 60)) / (1000 * 60));
|
|
312
315
|
|
|
313
|
-
// Calculate weekly usage data
|
|
316
|
+
// Calculate weekly usage data — 同样基于 remaining_percent 反转
|
|
314
317
|
const weeklyUsed = modelData.current_weekly_usage_count;
|
|
315
318
|
const weeklyTotal = modelData.current_weekly_total_count;
|
|
316
|
-
const
|
|
319
|
+
const weeklyRemainingPct = modelData.current_weekly_remaining_percent;
|
|
320
|
+
const weeklyPercentage = weeklyRemainingPct !== undefined && weeklyRemainingPct !== null
|
|
321
|
+
? Math.round(100 - weeklyRemainingPct)
|
|
322
|
+
: (weeklyTotal > 0 ? Math.floor((weeklyUsed / weeklyTotal) * 100) : 0);
|
|
323
|
+
// ⚠ Bug fix: 旧逻辑 weeklyTotal === 0 判 unlimited,但主人账号的 `general`
|
|
324
|
+
// 模型 weekly_total=0、weekly_remaining_percent=97(3% 已用,有数据)。
|
|
325
|
+
// 真正的"无限"应当是 total=0 **且** remaining_percent 也没返回。
|
|
326
|
+
const weeklyUnlimited = weeklyTotal === 0 && (modelData.current_weekly_remaining_percent == null);
|
|
317
327
|
const weeklyRemainingMs = modelData.weekly_remains_time;
|
|
318
328
|
const weeklyDays = Math.floor(weeklyRemainingMs / (1000 * 60 * 60 * 24));
|
|
319
329
|
const weeklyHours = Math.floor((weeklyRemainingMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
@@ -395,7 +405,7 @@ class MinimaxAPI {
|
|
|
395
405
|
percentage: weeklyPercentage,
|
|
396
406
|
days: weeklyDays,
|
|
397
407
|
hours: weeklyHours,
|
|
398
|
-
unlimited:
|
|
408
|
+
unlimited: weeklyUnlimited,
|
|
399
409
|
text: weeklyDays > 0
|
|
400
410
|
? `${weeklyDays} 天 ${weeklyHours} 小时后重置`
|
|
401
411
|
: `${weeklyHours} 小时后重置`,
|
|
@@ -417,16 +427,25 @@ class MinimaxAPI {
|
|
|
417
427
|
|
|
418
428
|
return apiData.model_remains.map(modelData => {
|
|
419
429
|
const totalCount = modelData.current_interval_total_count;
|
|
420
|
-
// 新接口 usage_count
|
|
421
|
-
|
|
430
|
+
// ⚠ 新接口 usage_count 在 video 上语义不一致;用 usedPercentage 反算 used
|
|
431
|
+
// 跟官网一致:video total=3, used%=0 → used=0, remaining=3("3/3 剩余")
|
|
432
|
+
const remainingPct = modelData.current_interval_remaining_percent;
|
|
433
|
+
const usedPercentage = remainingPct !== undefined && remainingPct !== null
|
|
434
|
+
? Math.round(100 - remainingPct)
|
|
435
|
+
: (totalCount > 0 ? Math.round((modelData.current_interval_usage_count / totalCount) * 100) : 0);
|
|
436
|
+
const usedCount = totalCount > 0 ? Math.round((totalCount * usedPercentage) / 100) : 0;
|
|
422
437
|
const remainingCount = totalCount - usedCount;
|
|
423
|
-
const usedPercentage = totalCount > 0 ? Math.round((usedCount / totalCount) * 100) : 0;
|
|
424
438
|
|
|
425
|
-
// Weekly data
|
|
439
|
+
// Weekly data — 同样基于 remaining_percent 反转
|
|
426
440
|
const weeklyTotal = modelData.current_weekly_total_count || 0;
|
|
427
441
|
const weeklyUsed = modelData.current_weekly_usage_count || 0;
|
|
428
442
|
const weeklyRemainingCount = weeklyTotal - weeklyUsed;
|
|
429
|
-
const
|
|
443
|
+
const weeklyRemainingPct = modelData.current_weekly_remaining_percent;
|
|
444
|
+
const weeklyPercentage = weeklyRemainingPct !== undefined && weeklyRemainingPct !== null
|
|
445
|
+
? Math.round(100 - weeklyRemainingPct)
|
|
446
|
+
: (weeklyTotal > 0 ? Math.floor((weeklyUsed / weeklyTotal) * 100) : 0);
|
|
447
|
+
// Bug fix: 同 parseUsageData — 真正"无限"是 total=0 且 remaining_percent 也没
|
|
448
|
+
const weeklyUnlimited = weeklyTotal === 0 && (modelData.current_weekly_remaining_percent == null);
|
|
430
449
|
|
|
431
450
|
return {
|
|
432
451
|
name: modelData.model_name,
|
|
@@ -434,7 +453,7 @@ class MinimaxAPI {
|
|
|
434
453
|
remaining: remainingCount,
|
|
435
454
|
total: totalCount,
|
|
436
455
|
percentage: usedPercentage,
|
|
437
|
-
unlimited:
|
|
456
|
+
unlimited: weeklyUnlimited,
|
|
438
457
|
weeklyPercentage,
|
|
439
458
|
weeklyTotal,
|
|
440
459
|
weeklyRemainingCount,
|
package/cli/index.js
CHANGED
package/cli/renderer.js
CHANGED
|
@@ -100,13 +100,17 @@ class Renderer {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
// 5h 限额 block — 总是显示(即使 total=0 也要显示百分比 + 5h 前缀)
|
|
104
|
+
// ⚠ 不再用 usage.total > 0 过滤(5h 限额数据对 general 模型 total=0 也要显示)
|
|
105
|
+
if (usage && usage.percentage !== undefined && usage.percentage !== null) {
|
|
104
106
|
let bg = '#065F46'; // safe (Emerald 800 - dark enough for white text)
|
|
105
107
|
if (usagePercentage >= 95) bg = '#991B1B'; // danger (Red 800)
|
|
106
108
|
else if (usagePercentage >= 75) bg = '#9A3412'; // warn (Orange 800)
|
|
107
109
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
// total=0 时不显示 (X/Y) 段
|
|
111
|
+
const usedTotalSuffix = usage.total > 0 ? ` (${usage.remaining}/${usage.total})` : '';
|
|
112
|
+
let usageText = ` 5h ${usagePercentage}%${usedTotalSuffix} `;
|
|
113
|
+
|
|
110
114
|
if (weekly) {
|
|
111
115
|
if (weekly.unlimited) {
|
|
112
116
|
usageText += `· W ∞ `;
|
package/cli/status.js
CHANGED
|
@@ -35,7 +35,7 @@ class StatusBar {
|
|
|
35
35
|
|
|
36
36
|
const lines = [];
|
|
37
37
|
lines.push('');
|
|
38
|
-
lines.push(chalk.bold('
|
|
38
|
+
lines.push(chalk.bold('Token 消耗统计'));
|
|
39
39
|
|
|
40
40
|
// 计算表格宽度
|
|
41
41
|
const leftWidth = 12; // "昨日消耗: "
|
|
@@ -63,7 +63,7 @@ class StatusBar {
|
|
|
63
63
|
|
|
64
64
|
const lines = [];
|
|
65
65
|
lines.push('');
|
|
66
|
-
lines.push(chalk.bold('
|
|
66
|
+
lines.push(chalk.bold('所有模型额度'));
|
|
67
67
|
|
|
68
68
|
// 简化模型名称映射
|
|
69
69
|
const shortName = (name) => {
|
|
@@ -86,9 +86,9 @@ class StatusBar {
|
|
|
86
86
|
|
|
87
87
|
// 显示状态
|
|
88
88
|
const getStatusText = (percentage) => {
|
|
89
|
-
if (percentage >= 85) return '
|
|
90
|
-
if (percentage >= 60) return '
|
|
91
|
-
return '
|
|
89
|
+
if (percentage >= 85) return 'X';
|
|
90
|
+
if (percentage >= 60) return '!';
|
|
91
|
+
return 'OK';
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
// 每行显示一个模型
|
|
@@ -97,7 +97,8 @@ class StatusBar {
|
|
|
97
97
|
const color = getStatusColor(model.percentage);
|
|
98
98
|
const status = getStatusText(model.percentage);
|
|
99
99
|
const pct = `${model.percentage}%`;
|
|
100
|
-
|
|
100
|
+
// total=0 时不显示 X/Y(避免 0/0 这种无数据展示)
|
|
101
|
+
const usedTotal = model.total > 0 ? `${model.used}/${model.total}` : '—';
|
|
101
102
|
|
|
102
103
|
lines.push(` ${color(short.padEnd(15))} ${color(pct.padEnd(5))} ${color(usedTotal.padEnd(12))} ${color(status)}`);
|
|
103
104
|
}
|
|
@@ -143,13 +144,6 @@ class StatusBar {
|
|
|
143
144
|
|
|
144
145
|
contentLines.push('');
|
|
145
146
|
|
|
146
|
-
// 模型名称
|
|
147
|
-
contentLines.push(`${chalk.cyan('当前模型:')} ${modelName}`);
|
|
148
|
-
|
|
149
|
-
// 时间窗口
|
|
150
|
-
const timeWindowText = `${timeWindow.start}-${timeWindow.end}(${timeWindow.timezone})`;
|
|
151
|
-
contentLines.push(`${chalk.cyan('时间窗口:')} ${timeWindowText}`);
|
|
152
|
-
|
|
153
147
|
// 剩余时间
|
|
154
148
|
contentLines.push(`${chalk.cyan('剩余时间:')} ${remaining.text}`);
|
|
155
149
|
|
|
@@ -158,8 +152,10 @@ class StatusBar {
|
|
|
158
152
|
// 使用百分比与进度条
|
|
159
153
|
contentLines.push(`${chalk.cyan('已用额度:')} ${progressBar} ${usage.percentage}%`);
|
|
160
154
|
|
|
161
|
-
//
|
|
162
|
-
|
|
155
|
+
// 剩余次数(total=0 时不显示)
|
|
156
|
+
if (usage.total > 0) {
|
|
157
|
+
contentLines.push(`${chalk.dim(' 剩余:')} ${usage.remaining}/${usage.total} 次调用`);
|
|
158
|
+
}
|
|
163
159
|
|
|
164
160
|
// 周用量(如果有数据)
|
|
165
161
|
if (weekly) {
|
|
@@ -176,7 +172,9 @@ class StatusBar {
|
|
|
176
172
|
15 - Math.floor((weeklyPercent / 100) * 15),
|
|
177
173
|
weeklyPercent
|
|
178
174
|
);
|
|
179
|
-
|
|
175
|
+
// total=0 时不显示 (X/Y)
|
|
176
|
+
const weeklyUsedTotal = weekly.total > 0 ? ` (${weekly.used}/${weekly.total})` : '';
|
|
177
|
+
contentLines.push(`${chalk.cyan('周限额:')} ${weeklyColor(weeklyProgress)} ${weeklyColor(weekly.percentage + '%')}${weeklyUsedTotal}`);
|
|
180
178
|
contentLines.push(`${chalk.dim(' 重置:')} ${weekly.text}`);
|
|
181
179
|
}
|
|
182
180
|
}
|
|
@@ -249,13 +247,13 @@ class StatusBar {
|
|
|
249
247
|
}
|
|
250
248
|
|
|
251
249
|
getStatus(percentage) {
|
|
252
|
-
//
|
|
250
|
+
// 基于已使用百分比(去 emoji 跟 vscode 1.0.7 风格一致)
|
|
253
251
|
if (percentage >= 85) {
|
|
254
|
-
return '
|
|
252
|
+
return '即将用完';
|
|
255
253
|
} else if (percentage >= 60) {
|
|
256
|
-
return '
|
|
254
|
+
return '注意使用';
|
|
257
255
|
} else {
|
|
258
|
-
return '
|
|
256
|
+
return '正常使用';
|
|
259
257
|
}
|
|
260
258
|
}
|
|
261
259
|
|
|
@@ -287,7 +285,7 @@ class StatusBar {
|
|
|
287
285
|
|
|
288
286
|
const lines = [];
|
|
289
287
|
lines.push('');
|
|
290
|
-
lines.push(chalk.bold('
|
|
288
|
+
lines.push(chalk.bold('所有模型额度'));
|
|
291
289
|
|
|
292
290
|
// 表头
|
|
293
291
|
lines.push(chalk.gray('─'.repeat(55)));
|
package/cli/statusbar.js
CHANGED
|
@@ -10,7 +10,7 @@ class StatusBar {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
render() {
|
|
13
|
-
const { usage, remaining,
|
|
13
|
+
const { usage, remaining, weekly, expiry } = this.data;
|
|
14
14
|
const percentage = usage.percentage;
|
|
15
15
|
|
|
16
16
|
// 基于已使用百分比:使用越多越危险
|
|
@@ -21,22 +21,29 @@ class StatusBar {
|
|
|
21
21
|
color = chalk.yellow;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const statusIcon = percentage >= 85 ? '⚠' : percentage >= 60 ? '⚡' : '✓';
|
|
25
24
|
const remainingText = remaining.hours > 0
|
|
26
25
|
? `${remaining.hours}h${remaining.minutes}m`
|
|
27
26
|
: `${remaining.minutes}m`;
|
|
28
27
|
|
|
28
|
+
// total=0 时不显示 X/Y(避免 0/0 这种无数据展示,保留百分比)
|
|
29
|
+
const usedTotalSuffix = usage.total > 0 ? ` (${usage.used}/${usage.total})` : '';
|
|
30
|
+
|
|
29
31
|
let weeklyStr = '';
|
|
30
32
|
if (weekly) {
|
|
31
33
|
if (weekly.unlimited) {
|
|
32
|
-
weeklyStr = ` ${chalk.blue('W')}
|
|
34
|
+
weeklyStr = ` ${chalk.blue('W')} ∞`;
|
|
33
35
|
} else {
|
|
34
36
|
const weeklyColor = weekly.percentage >= 85 ? chalk.red : weekly.percentage >= 60 ? chalk.yellow : chalk.green;
|
|
35
|
-
|
|
37
|
+
// total=0 时不显示 (X/Y)
|
|
38
|
+
const weeklySuffix = weekly.total > 0 ? ` (${weekly.used}/${weekly.total})` : '';
|
|
39
|
+
weeklyStr = ` ${chalk.blue('W')} ${weeklyColor(weekly.percentage + '%')}${weeklySuffix}`;
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
// 到期信息(剩 N 天)— 与 claude-code statusline 对齐
|
|
44
|
+
const expiryStr = expiry ? ` 剩${expiry.daysRemaining}天` : '';
|
|
45
|
+
|
|
46
|
+
return `${color(percentage + '%')}${usedTotalSuffix} ${remainingText}${weeklyStr}${expiryStr}`;
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
49
|
|