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.
@@ -305,7 +305,9 @@ export async function runQuotaPush({ endpoint, key, accounts, fetchImpl, onlySou
305
305
  };
306
306
 
307
307
  // 0. minimax-free(单账号单卡,minimax-code 同款单值卡:带签到徽章)
308
- const mmAccounts = (accounts || []).filter((a) => a.provider === 'minimax' && (a.token || a.refreshToken));
308
+ // 国内(minimax)与国际(minimax-global,#54)都推免费线卡——10R 的 minimax-free 挂 CD 网关
309
+ // 的免费体验线,订阅线额度卡由账号连接(#55 OAuth 通道)的同名认领接管,两者不冲突
310
+ const mmAccounts = (accounts || []).filter((a) => (a.provider === 'minimax' || a.provider === 'minimax-global') && (a.token || a.refreshToken));
309
311
  if (mmAccounts.length) {
310
312
  // 一次性清理:按账号单卡(6ebcc52)之前的版本把全部账号聚在 source「minimax-free」
311
313
  // 一张多行卡上;升级用户的那张旧卡没人再推(也不该再推),不删会挂到 7 天 TTL 自然过期,
@@ -527,5 +529,46 @@ export async function runQuotaPush({ endpoint, key, accounts, fetchImpl, onlySou
527
529
  }
528
530
  }
529
531
 
532
+ // 6. WPS 灵犀(issue #53:灵点余额卡)——kdocs 会话 cookie 读任务列表/余额接口;
533
+ // 单值储值卡(灵点只在灵犀界面消费,官方无 API,10R 卡仅展示余额数字)。
534
+ const lxAccounts = (accounts || []).filter((a) => (a.provider === 'lingxi' || a.meta?.cookieSiteId === 'lingxi') && (a.token || a.meta?.cookieSiteSession?.cookie));
535
+ if (lxAccounts.length) {
536
+ const { fetchLingxiStatus, buildLingxiQuotaPayload } = await import('./lingxiClient.js');
537
+ for (const a of lxAccounts) {
538
+ const { source } = buildLingxiQuotaPayload(a);
539
+ if (only && !only.includes(source)) continue;
540
+ const skipDead = !only && deadSkip(a);
541
+ let liveData = null;
542
+ if (skipDead) {
543
+ liveData = { error: '会话已失效(后台低频重试等待中,跳过本轮 live 拉取)', authInvalid: true };
544
+ } else {
545
+ try {
546
+ const cookie = a.meta?.cookieSiteSession?.cookie || a.token;
547
+ const st = await fetchLingxiStatus(cookie, { fetchImpl });
548
+ if (st.auth) {
549
+ liveData = { balance: st.balance };
550
+ if (Number.isFinite(st.balance)) {
551
+ persistLive(a, { quotaSnapshot: { used: 0, total: st.balance, isCreditBalance: true, at: new Date().toISOString() } });
552
+ }
553
+ } else liveData = liveError({ authExpired: true, error: '会话已失效' });
554
+ probeMark(a, st.auth, st.code);
555
+ } catch (err) {
556
+ liveData = { error: err.message };
557
+ probeMark(a, false, err.message);
558
+ }
559
+ }
560
+ const { payload } = buildLingxiQuotaPayload(a, liveData);
561
+ try {
562
+ assertScalarOnly(payload, source);
563
+ const r = await pushOne({ endpoint, key, source, payload, fetchImpl, refreshUrl: await rurl(source) });
564
+ results.push({ source, status: 'ok', entries: r.entries });
565
+ logger.info('10R', '额度卡已推送:{source}({n} 行)', { source, n: r.entries ?? (Object.keys(payload.quotas || {}).length || 0) });
566
+ } catch (e) {
567
+ results.push({ source, status: 'failed', error: e.message });
568
+ logger.warn('10R', '额度卡推送失败 {source}:{err}', { source, err: e.message });
569
+ }
570
+ }
571
+ }
572
+
530
573
  return { results };
531
574
  }