@kenz1117/dsh-ui-usage-billing 1.4.9 → 1.4.10

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 CHANGED
@@ -278,6 +278,8 @@ npm publish --access public
278
278
  - [@ciphoo](https://github.com/ciphoo) — MiniMax 国内域 Token Plan 订阅额度支持(PR #5)、`minimax-cn` 订阅凭据接线(PR #12)、Windows 下账本并发写入 `MoveFileExW EPERM` 修复(PR #11)
279
279
  - [@fabulousyuann-tech](https://github.com/fabulousyuann-tech) — 会话删除后用量保留的持久 ledger 功能(PR #8)
280
280
  - [@hi-fangj](https://github.com/hi-fangj) — Token 每日图悬停精确明细(PR #21)、平价消耗胶囊开关(PR #22)、Token 每日图按模型视角与图例聚焦(PR #23)、性能面板按模型对比曲线(PR #24)
281
+ - [@aizhimoran](https://github.com/aizhimoran) — 峰谷分档支持中国法定节假日与调休:DeepSeek 按量分时把法定节假日全天按空闲时段计费(官方 2026-09-19 口径),含 10 天倒计时扫描窗(issue #73、PR #74)
282
+ - [@gitfangj](https://github.com/gitfangj) — `sync.sh` 在 macOS 缺省 bash 3.2 下的花括号变量兼容修复
281
283
 
282
284
  ## 📄 许可证
283
285
 
package/lib/index.js CHANGED
@@ -5185,6 +5185,21 @@ async function requestJson(url, init, timeoutMs) {
5185
5185
  maxDelayMs: 2e3
5186
5186
  });
5187
5187
  }
5188
+ /**
5189
+ * 订阅端点挂在服务 origin 下(/coding、/zen、/api、/alpha 前缀),而用户在
5190
+ * chat 路由上配置的 baseUrl 通常带路径前缀(如 CommandCode 网关的
5191
+ * `https://api.commandcode.ai/provider/v1`,issue #75)——整段拼接会把 chat
5192
+ * 前缀带进订阅端点导致 404。只取 origin;未配置回退官方默认,非法值同样
5193
+ * 回退(订阅查询走「未读出」兜底而非抛错)。
5194
+ */
5195
+ function subscriptionOrigin(configBaseUrl, fallback) {
5196
+ if (configBaseUrl === void 0 || configBaseUrl.trim() === "") return fallback;
5197
+ try {
5198
+ return new URL(configBaseUrl).origin;
5199
+ } catch {
5200
+ return fallback;
5201
+ }
5202
+ }
5188
5203
  /** Parse one Kimi limit window entry. */
5189
5204
  function kimiWindow(value, kind) {
5190
5205
  if (value === null || typeof value !== "object") return null;
@@ -5222,7 +5237,7 @@ function parseKimi(body) {
5222
5237
  /** Collect the Kimi For Coding quota. */
5223
5238
  async function collectKimi(keys, config, timeoutMs) {
5224
5239
  const apiKey = keys.kimiApiKey.trim();
5225
- const base = config.baseUrl ?? "https://api.kimi.com";
5240
+ const base = subscriptionOrigin(config.baseUrl, "https://api.kimi.com");
5226
5241
  if (apiKey === "") return {
5227
5242
  provider: config.provider,
5228
5243
  displayName: "Kimi For Coding",
@@ -5407,7 +5422,7 @@ function parseOpenCodeGoApi(body) {
5407
5422
  /** Collect the OpenCode Go quota. */
5408
5423
  async function collectOpenCodeGo(keys, config, timeoutMs) {
5409
5424
  const apiKey = keys.opencodeApiKey.trim();
5410
- const base = config.baseUrl ?? "https://opencode.ai";
5425
+ const base = subscriptionOrigin(config.baseUrl, "https://opencode.ai");
5411
5426
  if (apiKey === "") return {
5412
5427
  provider: config.provider,
5413
5428
  displayName: "OpenCode Go",
@@ -5480,12 +5495,14 @@ function parseMiniMaxRemains(body) {
5480
5495
  * Resolve the MiniMax API host based on the configured provider id.
5481
5496
  *
5482
5497
  * 国内开发者走 MiniMax(`api.minimaxi.com`),海外走 MiniMax(`minimaxi.com`)。
5483
- * User-explicit `config.baseUrl` wins when set, so deployments in either
5484
- * region can still override the auto-pick (e.g. proxies / staging).
5498
+ * User-explicit `config.baseUrl` wins by origin when set, so deployments in
5499
+ * either region can still override the auto-pick (e.g. proxies / staging);
5500
+ * chat path prefixes (e.g. `/v1`) are dropped — `miniMaxEndpoint` re-adds the
5501
+ * version segment itself.
5485
5502
  */
5486
5503
  function resolveMiniMaxBaseUrl(config) {
5487
- if (typeof config.baseUrl === "string" && config.baseUrl.trim() !== "") return config.baseUrl;
5488
- return config.provider === "minimax-cn" || config.provider === "minimax-token-plan-cn" ? "https://api.minimaxi.com" : "https://www.minimaxi.com";
5504
+ const fallback = config.provider === "minimax-cn" || config.provider === "minimax-token-plan-cn" ? "https://api.minimaxi.com" : "https://www.minimaxi.com";
5505
+ return subscriptionOrigin(config.baseUrl, fallback);
5489
5506
  }
5490
5507
  /** Display name for a MiniMax quota row, aligned with the display-name map. */
5491
5508
  function minmaxDisplayName(provider) {
@@ -5567,7 +5584,7 @@ function parseOpenRouterCredits(body) {
5567
5584
  /** Collect the OpenRouter prepaid credits usage. */
5568
5585
  async function collectOpenRouter(keys, config, timeoutMs) {
5569
5586
  const apiKey = keys.openrouterApiKey.trim();
5570
- const base = config.baseUrl ?? "https://openrouter.ai";
5587
+ const base = subscriptionOrigin(config.baseUrl, "https://openrouter.ai");
5571
5588
  if (apiKey === "") return {
5572
5589
  provider: config.provider,
5573
5590
  displayName: "OpenRouter",
@@ -5629,7 +5646,7 @@ function parseAnthropicUsage(body) {
5629
5646
  /** Collect the Claude Pro/Max subscription usage via the OAuth usage endpoint. */
5630
5647
  async function collectAnthropic(keys, config, timeoutMs) {
5631
5648
  const token = keys.anthropicApiKey.trim();
5632
- const base = config.baseUrl ?? "https://api.anthropic.com";
5649
+ const base = subscriptionOrigin(config.baseUrl, "https://api.anthropic.com");
5633
5650
  const displayName = "Claude (Anthropic)";
5634
5651
  if (token === "") return {
5635
5652
  provider: config.provider,
@@ -5693,7 +5710,7 @@ function parseCommandCodeCredits(body) {
5693
5710
  /** Collect the CommandCode quota (5h/weekly windows + monthly credits). */
5694
5711
  async function collectCommandCode(keys, config, timeoutMs) {
5695
5712
  const apiKey = keys.commandcodeApiKey.trim();
5696
- const base = config.baseUrl ?? "https://api.commandcode.ai";
5713
+ const base = subscriptionOrigin(config.baseUrl, "https://api.commandcode.ai");
5697
5714
  const displayName = SUBSCRIPTION_DISPLAY_NAMES["commandcode"] ?? "CommandCode";
5698
5715
  if (apiKey === "") return {
5699
5716
  provider: config.provider,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kenz1117/dsh-ui-usage-billing",
3
3
  "description": "Usage billing dashboard for DeepSeek Harness: sidebar cost metrics plus a full dashboard modal, priced from a current multi-provider catalog with real usage aggregated from session logs.",
4
- "version": "1.4.9",
4
+ "version": "1.4.10",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "deepseek",