dsh-cost-meter 1.7.0 → 1.7.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/README.en.md +5 -5
- package/README.md +5 -5
- package/lib/client.js +2 -2
- package/lib/index.js +13 -2
- package/lib/typert.host.js +9 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1214,10 +1214,21 @@ function createService(ctx, ledger) {
|
|
|
1214
1214
|
if ((ledger.config?.balance?.reconcile ?? true) === true && balanceCache.value.status === 'ok') {
|
|
1215
1215
|
const nowMs = Date.now()
|
|
1216
1216
|
const usd = v => '$' + Number(v).toFixed(4)
|
|
1217
|
+
// 币种符号一致(issue #81):对账警告同一句话里的两侧金额必须同币种——
|
|
1218
|
+
// 余额账户为 CNY 时,本地费用(美元口径)按展示汇率折算为 ¥ 显示并附
|
|
1219
|
+
// ≈USD 参考,与「变动」侧同币种可比;此前恒用 $,与右侧 ¥ 混排误导。
|
|
1220
|
+
const currencyOf = event => (String(event?.spentCurrency ?? '').toUpperCase() === 'CNY' ? 'CNY' : 'USD')
|
|
1221
|
+
const rate = Number(ledger.config?.exchangeRate)
|
|
1222
|
+
const exchangeRate = Number.isFinite(rate) && rate > 0 ? rate : 7.2
|
|
1223
|
+
const nativeCost = event => {
|
|
1224
|
+
if (currencyOf(event) !== 'CNY') return usd(event.todayCost)
|
|
1225
|
+
const cny = Number(event.todayCost) * exchangeRate
|
|
1226
|
+
return '¥' + cny.toFixed(4) + '(≈' + usd(event.todayCost) + ')'
|
|
1227
|
+
}
|
|
1217
1228
|
// 变动金额按余额条目的真实币种显示符号(CNY 余额账号此前被错标成 $),
|
|
1218
1229
|
// 并附 ≈USD 折算参考与本地账本同币种可比(zh/en 两份模板共用参数,不做字典改动)。
|
|
1219
1230
|
const nativeDelta = event => {
|
|
1220
|
-
const symbol =
|
|
1231
|
+
const symbol = currencyOf(event) === 'CNY' ? '¥' : '$'
|
|
1221
1232
|
const converted = Number.isFinite(event.spentUsd) && Math.abs(event.spentUsd - event.spent) > 0.005
|
|
1222
1233
|
? '(≈' + usd(event.spentUsd) + ')'
|
|
1223
1234
|
: ''
|
|
@@ -1229,7 +1240,7 @@ function createService(ctx, ledger) {
|
|
|
1229
1240
|
ledger.scheduleWrite()
|
|
1230
1241
|
}
|
|
1231
1242
|
reconcileNotice = event !== null && event.kind === 'drift'
|
|
1232
|
-
? { ok: false, message: tmsg(localeOf(ledger.config), 'reconcileWarn', { cost:
|
|
1243
|
+
? { ok: false, message: tmsg(localeOf(ledger.config), 'reconcileWarn', { cost: nativeCost(event), delta: nativeDelta(event) }) }
|
|
1233
1244
|
: { ok: true, message: '' }
|
|
1234
1245
|
}
|
|
1235
1246
|
}, error => {
|
package/lib/typert.host.js
CHANGED
|
@@ -463,8 +463,16 @@ export const TYPERT = {
|
|
|
463
463
|
method: 'refreshCustomBalance',
|
|
464
464
|
invocation: { kind: 'direct' },
|
|
465
465
|
// index(v1.7.0,issue #79):多配置形态下指定刷新的条目下标;缺省 = 全部刷新。
|
|
466
|
+
// acceptsUndefined(v1.7.1):网关按「期望 wire 字段是否在 args 中」判缺失——
|
|
467
|
+
// 无此标志的 json 参数缺省会以 arguments-invalid 拒绝调用;标志允许旧客户端
|
|
468
|
+
// 的无参调用(等价全量刷新)继续走通。codec 必须是 strict 对象(裸 zod schema
|
|
469
|
+
// 会被 typert-loader 以「parameter codec must use a strict codec」拒绝注册,
|
|
470
|
+
// v1.7.0 因此无法启动宿主——本版回归)。
|
|
466
471
|
parameters: [
|
|
467
|
-
{
|
|
472
|
+
{
|
|
473
|
+
name: 'index', wire: 'index', source: 'json', acceptsUndefined: true,
|
|
474
|
+
codec: { mode: 'strict', typeSymbol: 'dsh-cost-meter#CustomBalanceIndex', schema: z.number().int().min(0).max(7).optional() },
|
|
475
|
+
},
|
|
468
476
|
],
|
|
469
477
|
result: _fetch$codec,
|
|
470
478
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cost-meter",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "DeepSeek Harness 会话费用统计插件:本会话成本、当日费用、历史记录与官方价格同步,支持多厂商多模型价格计费(内置 90+ 模型价格目录与自动匹配)、主流 Coding Plan 订阅额度查询与显示(9 家,含 SCNet Token Plan 本地 Credits 计量与火山方舟 Volcano Ark Coding Plan AK/SK 签名查询)、自定义 Provider 余额查询(可配任意 HTTP 端点)与余额进度条、峰谷计价时段显示与切换前弹窗/系统通知提醒(位置/提前量/类型可配),界面中英双语。Session cost tracking plugin for DeepSeek Harness: per-conversation cost, daily totals, history and official price sync, with multi-vendor model pricing (built-in 90+ model catalog with auto-matching), Coding Plan quota queries & display for 9 vendors (incl. local credits metering for the SCNet Token Plan and Volcano Ark Coding Plan via AK/SK signature), plan/API dual-track billing with per-1% & full-window Token Plan usage estimates, custom provider balance lookup (configurable HTTP endpoint) and balance progress bar, plus peak/off-peak pricing display with pre-switch popup & system-notification alerts (position / lead time / type configurable), in a bilingual (Chinese/English) UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|