dsh-cost-meter 1.9.76 → 1.9.77

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.
@@ -40,6 +40,7 @@ import { queryBaiduTokenPlan, BAIDU_TOKEN_PLAN_URL } from './baidu-token-plan.js
40
40
  import { createHash, createHmac } from 'node:crypto'
41
41
 
42
42
  import { fetchWithRetry, readJsonBounded } from './net.js'
43
+ import { balanceNumber } from './balance-expression.js'
43
44
  import { queryFactoryQuota, FACTORY_QUOTA_URL } from './factory-quota.js'
44
45
  import { queryOpenDesignQuota, OPENDESIGN_API } from './opendesign.js'
45
46
  import { fetchWorkBuddyConnectCredits, fetchWorkBuddyCredits, isWorkBuddyTokenExpired, resolveWorkBuddyCredential, workbuddyBillingBase } from './workbuddy.js'
@@ -479,19 +480,14 @@ export function parseMiniMaxRemains(data) {
479
480
 
480
481
  /**
481
482
  * 解析 Kimi / Moonshot 余额响应(GET https://api.moonshot.cn/v1/users/me/balance)。
482
- * 官方返回形如 { available_balance: <分> }(人民币分),兼容 cached/total 变体与元单位形态。
483
- * 输出文本窗口(余额无总量,不适合百分比进度条)。
483
+ * 官方 data.available_balance 的单位是人民币元。文本窗口只保留金额,界面负责翻译标签。
484
484
  */
485
485
  export function parseKimiBalance(data) {
486
486
  if (data === null || typeof data !== 'object') return null
487
- const raw = data.available_balance ?? data.balance ?? data.cash_balance ?? data.data?.available_balance
488
- const n = Number(raw)
487
+ const raw = data.data?.available_balance ?? data.available_balance ?? data.balance ?? data.cash_balance
488
+ const n = balanceNumber(raw)
489
489
  if (!Number.isFinite(n) || n < 0) return null
490
- // 官方单位为人民币分;数值 <100 视为已是元(兼容变体)。
491
- const cny = n >= 100 ? n / 100 : n
492
- const text = '余额 ¥' + (Math.round(cny * 100) / 100).toFixed(2)
493
- const win = textWindowOf(text)
494
- return win === null ? null : { balance: win }
490
+ return { balance: textWindowOf('¥' + n.toFixed(2)) }
495
491
  }
496
492
 
497
493
  /**