dsh-cost-meter 1.7.37 → 1.7.39
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.md +7 -6
- package/README.zh-CN.md +7 -6
- package/docs/external-usage.md +61 -0
- package/lib/aliyun-balance.js +7 -3
- package/lib/client.js +5 -5
- package/lib/custom-balance.js +5 -3
- package/lib/external-usage.js +111 -0
- package/lib/index.js +122 -44
- package/lib/store.js +3 -0
- package/lib/typert.host.js +9 -0
- package/lib/usage-dedup.js +9 -5
- package/package.json +3 -2
package/lib/usage-dedup.js
CHANGED
|
@@ -59,12 +59,16 @@ export function createUsageDeduper({ windowMs = USAGE_DEDUP_WINDOW_MS, now = Dat
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
const pruneIfNeeded =
|
|
62
|
+
// 不再访问的会话也要清理过期指纹。登记本次调用后再裁剪,避免把尚未
|
|
63
|
+
// 写入指纹的新会话当作空条目删除,使超过阈值后的转发对重复入账。
|
|
64
|
+
let nextPruneAt = 0
|
|
65
|
+
const pruneIfNeeded = t => {
|
|
66
66
|
if (sessions.size <= 1024) return
|
|
67
|
+
if (t < nextPruneAt) return
|
|
68
|
+
nextPruneAt = t + windowMs
|
|
67
69
|
for (const [key, entry] of sessions) {
|
|
70
|
+
sweep(entry.plain, t)
|
|
71
|
+
sweep(entry.remapped, t)
|
|
68
72
|
if (entry.plain.size === 0 && entry.remapped.size === 0) sessions.delete(key)
|
|
69
73
|
}
|
|
70
74
|
}
|
|
@@ -94,13 +98,13 @@ export function createUsageDeduper({ windowMs = USAGE_DEDUP_WINDOW_MS, now = Dat
|
|
|
94
98
|
}
|
|
95
99
|
sweep(entry.plain, t)
|
|
96
100
|
sweep(entry.remapped, t)
|
|
97
|
-
pruneIfNeeded()
|
|
98
101
|
const book = wrapped ? entry.remapped : entry.plain
|
|
99
102
|
// 包装样本与普通样本、改挂样本都互斥;普通样本只与改挂样本互斥。
|
|
100
103
|
if (wrapped ? (entry.plain.has(fp) || entry.remapped.has(fp)) : entry.remapped.has(fp)) {
|
|
101
104
|
return null
|
|
102
105
|
}
|
|
103
106
|
book.set(fp, t)
|
|
107
|
+
pruneIfNeeded(t)
|
|
104
108
|
if (book.size > maxEntries) {
|
|
105
109
|
// 容量护栏:淘汰最旧条目(窗口语义只关心最近的转发对)。
|
|
106
110
|
let oldestFp = null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cost-meter",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.39",
|
|
4
4
|
"description": "DeepSeek Harness 会话费用统计插件:本会话成本、当日费用、历史记录与官方价格同步,支持多厂商多模型价格计费(内置 90+ 模型价格目录与自动匹配)、主流 Coding Plan 订阅额度查询与显示(11 家,含小米 MiMo Token Plan 控制台 Cookie 查询、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 11 vendors (incl. Xiaomi MiMo Token Plan via console cookie, 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",
|
|
@@ -84,7 +84,8 @@
|
|
|
84
84
|
"files": [
|
|
85
85
|
"lib",
|
|
86
86
|
"cordis.patch.yml",
|
|
87
|
-
"docs/provider-pricing.json"
|
|
87
|
+
"docs/provider-pricing.json",
|
|
88
|
+
"docs/external-usage.md"
|
|
88
89
|
],
|
|
89
90
|
"dependencies": {
|
|
90
91
|
"zod": "4.5.1"
|