creditdaddy 1.7.0 → 1.7.1

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.
@@ -14,7 +14,7 @@
14
14
 
15
15
  import { fetchJsonRace } from './zcodeClient.js';
16
16
  import { loadAccounts, loadSettings, saveSettings } from './store.js';
17
- import { refreshMiniMaxToken, refreshAccountToken, fetchMiniMaxQuota, MINIMAX_MESSAGES_URL } from './minimaxClient.js';
17
+ import { refreshMiniMaxToken, refreshAccountToken, fetchMiniMaxQuota, minimaxEndpointsOf, minimaxFlavorOf } from './minimaxClient.js';
18
18
  import { clearRefreshDead, __resetRefreshGuardForTests } from './refreshGuard.js';
19
19
  import { refreshContext } from './accounts.js';
20
20
  import { gatewayHostSuggestion } from './tenrouter.js';
@@ -61,6 +61,7 @@ export const stats = {
61
61
  lastCallAt: null,
62
62
  calls: 0,
63
63
  lastAccount: null,
64
+ lastAccountAt: null, // 「接口使用中」徽章的 30 分钟窗口锚点(面板 gwRecentWindow 内才亮)
64
65
  };
65
66
 
66
67
  // 平滑加权轮询(SWRR):剩余积分多的账号分到更多请求,而不是雨露均沾地 round-robin。
@@ -142,6 +143,7 @@ export function __resetForTests() {
142
143
  stats.lastCallAt = null;
143
144
  stats.calls = 0;
144
145
  stats.lastAccount = null;
146
+ stats.lastAccountAt = null;
145
147
  __resetRefreshGuardForTests();
146
148
  }
147
149
 
@@ -198,7 +200,7 @@ const STICKY_MARGIN_ABS = 50; // 且绝对差超过 50 积分
198
200
  * 拉黑/冷却在挂载时剔除;扭转主力粘性见上方说明。
199
201
  */
200
202
  async function rotationQueue() {
201
- const all = (await loadAccounts()).filter((a) => a.provider === 'minimax');
203
+ const all = (await loadAccounts()).filter((a) => a.provider === 'minimax' || a.provider === 'minimax-global');
202
204
  const now = Date.now();
203
205
  const candidates = [];
204
206
  for (const a of all) {
@@ -228,7 +230,7 @@ async function rotationQueue() {
228
230
  }
229
231
 
230
232
  async function unavailableReason() {
231
- const all = (await loadAccounts()).filter((a) => a.provider === 'minimax');
233
+ const all = (await loadAccounts()).filter((a) => a.provider === 'minimax' || a.provider === 'minimax-global');
232
234
  if (!all.length) return '没有 MiniMax 账号:请在 MiniMax Code 登录后在面板进行本机导入,或粘贴 Token 添加';
233
235
  const now = Date.now();
234
236
  const n = { dead: 0, cooling: 0, noToken: 0 };
@@ -352,6 +354,8 @@ export async function handleGateway(req, res) {
352
354
  let upstream;
353
355
 
354
356
  let activeToken = account.token;
357
+ // 按账号档位选上游域名(国内 agent.minimax.cn / 国际 agent.minimax.io,协议同形)
358
+ const upstreamUrl = minimaxEndpointsOf(account).messagesUrl;
355
359
  const sendUpstream = async (tok) => {
356
360
  const headers = {
357
361
  'Content-Type': 'application/json',
@@ -359,7 +363,7 @@ export async function handleGateway(req, res) {
359
363
  Authorization: tok.startsWith('Bearer ') ? tok : `Bearer ${tok}`,
360
364
  'anthropic-version': '2023-06-01',
361
365
  };
362
- return fetchJsonRace(MINIMAX_MESSAGES_URL, {
366
+ return fetchJsonRace(upstreamUrl, {
363
367
  method: 'POST',
364
368
  headers,
365
369
  body: rawBody,
@@ -396,6 +400,7 @@ export async function handleGateway(req, res) {
396
400
 
397
401
  if (upstream.ok) {
398
402
  stats.lastAccount = label;
403
+ stats.lastAccountAt = Date.now();
399
404
  resetCoolingStreak(account.id); // 成功一次即清零连续 429 计数
400
405
  logger.info('MINIMAX-GW', '{label} 补全成功 ({status})', { label, status: upstream.status });
401
406
  try {
@@ -481,7 +486,7 @@ export async function handleGateway(req, res) {
481
486
 
482
487
  export async function gatewayStatus() {
483
488
  const enabled = await gatewayEnabled();
484
- const all = (await loadAccounts()).filter((a) => a.provider === 'minimax');
489
+ const all = (await loadAccounts()).filter((a) => a.provider === 'minimax' || a.provider === 'minimax-global');
485
490
  const now = Date.now();
486
491
  const settings = await loadSettings();
487
492
 
@@ -494,6 +499,7 @@ export async function gatewayStatus() {
494
499
  lastCallAt: stats.lastCallAt,
495
500
  calls: stats.calls,
496
501
  lastAccount: stats.lastAccount,
502
+ lastAccountAt: stats.lastAccountAt,
497
503
  },
498
504
  accounts: all.length,
499
505
  // cooling 保持字符串数组(历史形状);冷却细节走 coolingDetail(与 zcodeGateway 同款)