dsh-cost-meter 1.9.13 → 1.9.15

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.
@@ -19,6 +19,9 @@
19
19
  * - SiliconFlow 用户信息端点 api.siliconflow.cn/v1/user/info 存活(30014 Token is invalid);
20
20
  * - CommandCode(commandcode.ai)billing credits 端点存活(401 unauthorized;issue #30):
21
21
  * GET api.commandcode.ai/alpha/billing/credits,窗口(fiveHour/weekly)+ 月度 Credits 余额;
22
+ * - Cline Pass(cline.bot)额度端点存活(401 unauthorized;2026-10 实测):
23
+ * GET api.cline.bot/api/v1/users/me/plan/usage-limits,5 小时/周/月三窗口 percentUsed(已用%)
24
+ * 与 resetsAt;网关只报已用百分比,没有绝对额度字段;
22
25
  * - SCNet(超算互联网)Token Plan 仅有 sk-tp- 专属推理端点(api.scnet.cn),额度用量只在控制台
23
26
  * 「模型服务 → Token Plan → 我的订阅/Token 用量」可见,无 API-Key 化查询端点——以本地
24
27
  * Credits 计量接入(官方抵扣表折算,见 SCNET_CREDIT_RATES;issue #26);
@@ -86,6 +89,11 @@ export const CODING_PLAN_PROVIDERS = {
86
89
  credentialEnvs: ['COMMANDCODE_API_KEY'],
87
90
  keyHint: 'commandcode.ai API Key(user_*;显示 5 小时/周窗口用量% 与月度 Credits 余额)',
88
91
  },
92
+ clinepass: {
93
+ label: 'Cline Pass',
94
+ credentialEnvs: ['CLINE_PASS_API_KEY'],
95
+ keyHint: 'Cline Pass API Key(sk_*;显示 5 小时/周/月三窗口用量%)',
96
+ },
89
97
  scnet: {
90
98
  label: 'SCNet 超算互联网 Token Plan',
91
99
  credentialEnvs: [],
@@ -610,6 +618,37 @@ export function parseCommandCodeCredits(data) {
610
618
  return Object.keys(windows).length > 0 ? windows : null
611
619
  }
612
620
 
621
+ /**
622
+ * 解析 Cline Pass(cline.bot)额度响应(2026-10 实测,
623
+ * GET https://api.cline.bot/api/v1/users/me/plan/usage-limits)。
624
+ * 官方返回 { data: { limits: [{ type: 'five_hour' | 'weekly' | 'monthly', percentUsed, resetsAt }] } }:
625
+ * percentUsed 已是 0-100 的**已用**百分比,直接 clampPct,不走 normalizePercent 的
626
+ * 0-1 猜测(否则 1% 会被放大成 100%);type 未知或百分比非法的窗口跳过,至少一个可用窗口才返回。
627
+ */
628
+ export function parseClinePassUsage(data) {
629
+ if (data === null || typeof data !== 'object') return null
630
+ const body = data.data
631
+ const limits = body !== null && typeof body === 'object' ? body.limits : undefined
632
+ if (!Array.isArray(limits)) return null
633
+ const names = new Map([['five_hour', 'fiveHour'], ['weekly', 'weekly'], ['monthly', 'monthly']])
634
+ const windows = {}
635
+ for (const entry of limits) {
636
+ if (entry === null || typeof entry !== 'object' || Array.isArray(entry)) continue
637
+ const name = names.get(entry.type)
638
+ // 只接受有限数字或非空数字字符串:Number(null)/Number('')/Number(false)/Number([]) 都是 0,
639
+ // Number(true) 是 1,直接转换会把「缺失/未知」伪装成「已用 0% / 1%」。
640
+ const raw = entry.percentUsed
641
+ const percent = typeof raw === 'number'
642
+ ? raw
643
+ : typeof raw === 'string' && /^[+-]?(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?$/.test(raw.trim())
644
+ ? Number(raw)
645
+ : Number.NaN
646
+ if (name === undefined || !Number.isFinite(percent) || percent < 0) continue
647
+ windows[name] = { percent: clampPct(percent), resetsAt: normalizeResetAt(entry.resetsAt) }
648
+ }
649
+ return Object.keys(windows).length > 0 ? windows : null
650
+ }
651
+
613
652
  // ── 小米 MiMo Token Plan ─────────────────────────────────────────────
614
653
 
615
654
  /**
@@ -1199,6 +1238,7 @@ export const CODING_PLAN_ENDPOINTS = {
1199
1238
  openrouter: ['https://openrouter.ai/api/v1/credits'],
1200
1239
  siliconflow: ['https://api.siliconflow.cn/v1/user/info'],
1201
1240
  commandcode: ['https://api.commandcode.ai/alpha/billing/credits'],
1241
+ clinepass: ['https://api.cline.bot/api/v1/users/me/plan/usage-limits'],
1202
1242
  // SCNet 无 API-Key 化额度端点:本地 Credits 计量(见 scnetTokenPlanWindows),不走网络。
1203
1243
  scnet: [],
1204
1244
  // 千问由本地估算或 qwen-cli.js 调用官方 CLI;插件不托管 CLI 登录凭据。
@@ -1220,6 +1260,7 @@ const CODING_PLAN_PARSERS = {
1220
1260
  openrouter: parseOpenRouterCredits,
1221
1261
  siliconflow: parseSiliconFlowInfo,
1222
1262
  commandcode: parseCommandCodeCredits,
1263
+ clinepass: parseClinePassUsage,
1223
1264
  volcengine: parseVolcengineUsage,
1224
1265
  mimo: parseMimoTokenPlanUsage,
1225
1266
  }
package/lib/index.js CHANGED
@@ -3080,6 +3080,7 @@ const SECRET_REF_MAP_FALLBACK = {
3080
3080
  'codingPlans.opendesign': 'OPENDESIGN_CONTROL_KEY',
3081
3081
  'codingPlans.siliconflow': 'SILICONFLOW_API_KEY',
3082
3082
  'codingPlans.commandcode': 'COMMANDCODE_API_KEY',
3083
+ 'codingPlans.clinepass': 'CLINE_PASS_API_KEY',
3083
3084
  'codingPlans.volcengine.ak': 'VOLC_ACCESSKEY',
3084
3085
  'codingPlans.volcengine.sk': 'VOLC_SECRETKEY',
3085
3086
  }
@@ -40,6 +40,7 @@ export const PLAN_PROVIDER_ALIASES = {
40
40
  minimax: ['minimax', 'minimax-code'],
41
41
  kimi: ['kimi', 'kimi-code'],
42
42
  commandcode: ['commandcode', 'command-code'],
43
+ clinepass: ['clinepass', 'cline-pass'],
43
44
  workbuddy: ['workbuddy', 'workbuddy-subscription'],
44
45
  antigravity: ['antigravity'],
45
46
  stepfun: ['stepfun', 'step-code'],
@@ -63,6 +64,7 @@ export const DEFAULT_PLAN_PROVIDER_CLASS = {
63
64
  openrouter: 'api',
64
65
  siliconflow: 'api',
65
66
  commandcode: 'auto',
67
+ clinepass: 'auto',
66
68
  scnet: 'auto',
67
69
  volcengine: 'auto',
68
70
  qwen: 'auto',
@@ -5,7 +5,7 @@ export const PLAN_NAME_HINTS = {
5
5
  'tencent-coding': 'tencent|tokenhub|腾讯',
6
6
  anthropic: 'anthropic|claude', zai: 'z[._-]?ai|zhipu|glm|智谱', minimax: 'minimax|海螺',
7
7
  kimi: 'kimi|moonshot|moonshotai|月之暗面', openrouter: 'openrouter', siliconflow: 'siliconflow|硅基',
8
- commandcode: 'commandcode', scnet: 'scnet|sugon|超算',
8
+ commandcode: 'commandcode', clinepass: 'cline[._-]?pass|clinepass', scnet: 'scnet|sugon|超算',
9
9
  volcengine: 'volcengine|volcano|volc|ark|火山|方舟', qwen: 'qwen|qianwen|千问|通义',
10
10
  mimo: 'mimo|xiaomi|小米', factory: 'factory|droid', go: 'opencode(?:[-_\\s]?go)?|zen|go',
11
11
  }
package/lib/store.js CHANGED
@@ -166,6 +166,7 @@ export function defaultConfig() {
166
166
  hideSessionCostDock: false,
167
167
  hideTurnCost: false,
168
168
  sessionCostCompact: false, // 输入区下方会话费用行只显示金额(悬停 title 与费用明细弹窗保留完整分项)
169
+ followSkinTransparency: false, // 跟随皮肤透明度;默认保留不透明遮挡面。
169
170
  contextCostsEnabled: false,
170
171
  contextCostsPromptSeen: false,
171
172
  statisticsBasis: 'auto', // 未选择时沿用全局 API / 含 Plan 口径。
@@ -175,7 +176,7 @@ export function defaultConfig() {
175
176
  codexQuotaEnabled: false, // Codex 额度按需开启,避免未使用 Codex 时显示卡片或查询。
176
177
  codexQuotaSidebar: true, // 独立控制侧栏卡片,保留会话额度条。
177
178
  codexQuotaStrip: true, // 独立控制输入区额度条,旧配置保留原显示。
178
- codexQuotaSource: 'auto', // Codex 额度数据源:auto 自动探测 | connect dsh-codex-connect | subscription dsh-codex-subscription。
179
+ codexQuotaSource: 'auto', // Codex 额度数据源:auto | connect | subscription | chatgpt。
179
180
  // dsh-codex-subscription 兼容:一次性历史归类提示是否已永久关闭 / 历史归类完成时刻 ms(0 = 未应用)。
180
181
  codexCompatPromptDismissed: false,
181
182
  codexCompatHistoryAppliedAt: 0,
@@ -223,6 +224,7 @@ export function defaultConfig() {
223
224
  openrouter: { enabled: false, display: 'settings', refreshMinutes: 15, apiKey: '' },
224
225
  siliconflow: { enabled: false, display: 'settings', refreshMinutes: 15, apiKey: '' },
225
226
  commandcode: { enabled: false, display: 'settings', refreshMinutes: 15, apiKey: '' },
227
+ clinepass: { enabled: false, display: 'settings', refreshMinutes: 15, apiKey: '' },
226
228
  // SCNet Token Plan 无 API 额度端点:按官方 Credits 抵扣表本地估算(issue #26)。
227
229
  // planCredits=月度 Credits 额度;planStart=订阅起始日(空 = 自然月)。
228
230
  scnet: { enabled: false, display: 'settings', refreshMinutes: 15, apiKey: '', planCredits: 240000, planStart: '' },
@@ -797,7 +799,7 @@ const VALIDATION_MESSAGES = {
797
799
  codexQuotaEnabled: 'codexQuotaEnabled 必须是布尔值',
798
800
  codexQuotaSidebar: 'codexQuotaSidebar 必须是布尔值',
799
801
  codexQuotaStrip: 'codexQuotaStrip 必须是布尔值',
800
- codexQuotaSource: 'codexQuotaSource 必须是 auto / connect / subscription',
802
+ codexQuotaSource: 'codexQuotaSource 必须是 auto / connect / subscription / chatgpt',
801
803
  codexCompatPromptDismissed: 'codexCompatPromptDismissed 必须是布尔值',
802
804
  codexCompatHistoryAppliedAt: 'codexCompatHistoryAppliedAt 必须是非负数',
803
805
  sidebarSimple: '简化显示设置必须是布尔值',
@@ -908,7 +910,7 @@ const VALIDATION_MESSAGES = {
908
910
  codexQuotaEnabled: 'codexQuotaEnabled must be a boolean',
909
911
  codexQuotaSidebar: 'codexQuotaSidebar must be a boolean',
910
912
  codexQuotaStrip: 'codexQuotaStrip must be a boolean',
911
- codexQuotaSource: 'codexQuotaSource must be auto / connect / subscription',
913
+ codexQuotaSource: 'codexQuotaSource must be auto / connect / subscription / chatgpt',
912
914
  codexCompatPromptDismissed: 'codexCompatPromptDismissed must be a boolean',
913
915
  codexCompatHistoryAppliedAt: 'codexCompatHistoryAppliedAt must be a non-negative number',
914
916
  sidebarSimple: 'Simple display settings must be boolean',
@@ -1225,7 +1227,7 @@ export function applyConfigPatch(current, rawPatch) {
1225
1227
  if (candidate.hideBudget !== undefined && typeof candidate.hideBudget !== 'boolean') errors.push(vmsg(locale, 'hideBudget'))
1226
1228
  if (candidate.hideTodayCost !== undefined && typeof candidate.hideTodayCost !== 'boolean') errors.push(vmsg(locale, 'hideTodayCost'))
1227
1229
  if (!validModelStatistics(candidate.modelStatistics)) errors.push(locale === 'en' ? 'Invalid per-model statistics switches' : '模型统计开关无效')
1228
- for (const key of ['hideSessionCostHeader', 'hideSessionCostDock', 'hideTurnCost']) {
1230
+ for (const key of ['hideSessionCostHeader', 'hideSessionCostDock', 'hideTurnCost', 'followSkinTransparency']) {
1229
1231
  if (candidate[key] !== undefined && typeof candidate[key] !== 'boolean') errors.push(locale === 'en' ? `${key} must be a boolean` : `${key} 必须是布尔值`)
1230
1232
  }
1231
1233
  // 会话费用行紧凑模式:布尔,可缺省(默认关)。
@@ -1238,8 +1240,8 @@ export function applyConfigPatch(current, rawPatch) {
1238
1240
  for (const field of ['includeSubagentCost', 'codexQuotaEnabled', 'codexQuotaSidebar', 'codexQuotaStrip', 'codexCompatPromptDismissed']) {
1239
1241
  if (candidate[field] !== undefined && typeof candidate[field] !== 'boolean') errors.push(vmsg(locale, field))
1240
1242
  }
1241
- // Codex 额度数据源:auto 自动探测(优先 subscription,失败回退 connect) | connect | subscription。
1242
- if (candidate.codexQuotaSource !== undefined && !['auto', 'connect', 'subscription'].includes(candidate.codexQuotaSource)) errors.push(vmsg(locale, 'codexQuotaSource'))
1243
+ // Codex 额度数据源:auto 依次探测 subscription、chatgpt、connect,或固定一种来源。
1244
+ if (candidate.codexQuotaSource !== undefined && !['auto', 'connect', 'subscription', 'chatgpt'].includes(candidate.codexQuotaSource)) errors.push(vmsg(locale, 'codexQuotaSource'))
1243
1245
  // dsh-codex-subscription 兼容:历史归类应用时刻为非负有限数(0 = 尚未应用)。
1244
1246
  if (candidate.codexCompatHistoryAppliedAt !== undefined
1245
1247
  && (typeof candidate.codexCompatHistoryAppliedAt !== 'number' || !Number.isFinite(candidate.codexCompatHistoryAppliedAt) || candidate.codexCompatHistoryAppliedAt < 0)) errors.push(vmsg(locale, 'codexCompatHistoryAppliedAt'))
@@ -1606,7 +1608,7 @@ export function sanitizeConfig(raw) {
1606
1608
  out.hideBudget = out.hideBudget === true
1607
1609
  out.hideTodayCost = out.hideTodayCost === true
1608
1610
  out.modelStatistics = normalizeModelStatistics(out.modelStatistics)
1609
- for (const key of ['hideSessionCostHeader', 'hideSessionCostDock', 'hideTurnCost']) out[key] = out[key] === true
1611
+ for (const key of ['hideSessionCostHeader', 'hideSessionCostDock', 'hideTurnCost', 'followSkinTransparency']) out[key] = out[key] === true
1610
1612
  out.sessionCostCompact = out.sessionCostCompact === true
1611
1613
  out.contextCostsEnabled = out.contextCostsEnabled === true
1612
1614
  out.contextCostsPromptSeen = out.contextCostsPromptSeen === true
@@ -1617,7 +1619,7 @@ export function sanitizeConfig(raw) {
1617
1619
  out.codexQuotaEnabled = out.codexQuotaEnabled === true
1618
1620
  out.codexQuotaSidebar = out.codexQuotaSidebar !== false
1619
1621
  out.codexQuotaStrip = out.codexQuotaStrip !== false
1620
- out.codexQuotaSource = oneOf(out.codexQuotaSource, ['auto', 'connect', 'subscription'], 'auto')
1622
+ out.codexQuotaSource = oneOf(out.codexQuotaSource, ['auto', 'connect', 'subscription', 'chatgpt'], 'auto')
1621
1623
  // dsh-codex-subscription 兼容:提示关闭标记收敛为布尔;历史归类完成时刻非法/非正一律归 0。
1622
1624
  out.codexCompatPromptDismissed = out.codexCompatPromptDismissed === true
1623
1625
  out.codexCompatHistoryAppliedAt = Number.isFinite(out.codexCompatHistoryAppliedAt) && out.codexCompatHistoryAppliedAt > 0 ? out.codexCompatHistoryAppliedAt : 0
@@ -1898,6 +1900,7 @@ const SECRET_REF_MAP = {
1898
1900
  'codingPlans.openrouter': 'OPENROUTER_API_KEY',
1899
1901
  'codingPlans.siliconflow': 'SILICONFLOW_API_KEY',
1900
1902
  'codingPlans.commandcode': 'COMMANDCODE_API_KEY',
1903
+ 'codingPlans.clinepass': 'CLINE_PASS_API_KEY',
1901
1904
  'codingPlans.volcengine.ak': 'VOLC_ACCESSKEY',
1902
1905
  'codingPlans.volcengine.sk': 'VOLC_SECRETKEY',
1903
1906
  'codingPlans.mimo': 'MIMO_COOKIE',
@@ -243,6 +243,7 @@ const configSchema = z.object({
243
243
  hideSessionCostDock: z.boolean().optional(),
244
244
  hideTurnCost: z.boolean().optional(),
245
245
  sessionCostCompact: z.boolean().optional(),
246
+ followSkinTransparency: z.boolean().optional(),
246
247
  contextCostsEnabled: z.boolean().optional(),
247
248
  contextCostsPromptSeen: z.boolean().optional(),
248
249
  sidebarTodayMetric: z.enum(['cost', 'tokens']).optional(),
@@ -253,7 +254,7 @@ const configSchema = z.object({
253
254
  codexQuotaEnabled: z.boolean().optional(),
254
255
  codexQuotaSidebar: z.boolean().optional(),
255
256
  codexQuotaStrip: z.boolean().optional(),
256
- codexQuotaSource: z.enum(['auto', 'connect', 'subscription']).optional(),
257
+ codexQuotaSource: z.enum(['auto', 'connect', 'subscription', 'chatgpt']).optional(),
257
258
  // dsh-codex-subscription 兼容:一次性历史归类提示是否永久关闭 / 历史归类完成时刻 ms(0 = 未应用)。
258
259
  codexCompatPromptDismissed: z.boolean().optional(),
259
260
  codexCompatHistoryAppliedAt: num.optional(),
@@ -423,7 +424,7 @@ const configSchema = z.object({
423
424
  planBilling: z.object({
424
425
  providers: z.record(z.string(), z.enum(['auto', 'plan', 'api'])),
425
426
  models: z.record(z.string(), z.enum(['plan', 'api'])),
426
- modelPlans: z.record(z.string(), z.enum(['opendesign', 'anthropic', 'zai', 'minimax', 'kimi', 'openrouter', 'siliconflow', 'commandcode', 'scnet', 'volcengine', 'qwen', 'mimo', 'factory', 'workbuddy', 'go', 'codex', 'volcengine-agent', 'tencent-coding', 'tencent-token', 'baidu-coding'])).optional(),
427
+ modelPlans: z.record(z.string(), z.enum(['opendesign', 'anthropic', 'zai', 'minimax', 'kimi', 'openrouter', 'siliconflow', 'commandcode', 'clinepass', 'scnet', 'volcengine', 'qwen', 'mimo', 'factory', 'workbuddy', 'go', 'codex', 'volcengine-agent', 'tencent-coding', 'tencent-token', 'baidu-coding'])).optional(),
427
428
  }).optional(),
428
429
  historyDays: num,
429
430
  fetchedAt: z.union([z.string(), z.null()]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cost-meter",
3
- "version": "1.9.13",
3
+ "version": "1.9.15",
4
4
  "description": "DeepSeek Harness 会话费用统计插件:本会话成本、当日费用、历史记录与官方价格同步,支持多厂商多模型价格计费(内置 170+ 模型 ID 价格目录与自动匹配)、主流 Coding Plan 订阅额度查询与显示(14 家,含 WorkBuddy 官方积分、OpenDesign 工作区查询、含小米 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 170+ model-ID catalog with auto-matching), Coding Plan quota queries & display for 14 vendors (incl. WorkBuddy official credits, OpenDesign workspace queries, 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/bootstrap.js",
@@ -78,6 +78,7 @@
78
78
  "https://openrouter.ai",
79
79
  "https://api.siliconflow.cn",
80
80
  "https://api.commandcode.ai",
81
+ "https://api.cline.bot",
81
82
  "https://api.factory.ai",
82
83
  "https://ax.ac.sugon.com",
83
84
  "https://platform.qianwenai.com",
@@ -153,7 +154,9 @@
153
154
  "docs/update-notes-1.9.10.md",
154
155
  "docs/update-notes-1.9.11.md",
155
156
  "docs/update-notes-1.9.12.md",
156
- "docs/update-notes-1.9.13.md"
157
+ "docs/update-notes-1.9.13.md",
158
+ "docs/update-notes-1.9.14.md",
159
+ "docs/update-notes-1.9.15.md"
157
160
  ],
158
161
  "dependencies": {
159
162
  "acorn": "8.15.0",