@kenz1117/dsh-ui-usage-billing 1.6.1 → 1.6.3

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.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 宿主 llm-pi-ai 新代际的路由 key 约定(订阅额度 / 余额 / 中转站 / 声明端点共用)。
3
+ *
4
+ * 新版宿主设置页把路由 key 直接存成凭据 refs(命名 = 路由 id 大写下划线 +
5
+ * `_API_KEY`),providers 配置里只剩 models 列表;chat 认证走 pi-ai 目录路由的
6
+ * ambient 发现,不再需要显式 `apiKeyEnv`。插件侧所有「按路由取 key」的读取口
7
+ * 共用本模块的候选名推导与顺序解析——显式引用优先,约定名补后。
8
+ */
9
+ /** 候选 ref 名:路由 id 约定名(`<ROUTE 大写下划线>_API_KEY`)优先,其后补宿主
10
+ * pi-ai 目录的 ambient env 名(仅当与约定名不同——目录把 kimi-coding 指到
11
+ * KIMI_API_KEY、opencode-go 与 opencode 同用 OPENCODE_API_KEY)。 */
12
+ export declare function routeKeyRefCandidates(route: string): readonly string[];
13
+ /** 宽容的凭据解析口:ref 名 → 非空值;未配置 / 解析失败返回 undefined。 */
14
+ export type RefResolver = (name: string) => Promise<string | undefined>;
15
+ /** 依次解析候选 ref,返回第一个解析出非空值的 ref 与值;全部落空返回 undefined。 */
16
+ export declare function firstResolvedRef(refs: readonly string[], resolveRef: RefResolver): Promise<{
17
+ ref: string;
18
+ value: string;
19
+ } | undefined>;
20
+ //# sourceMappingURL=route-keys.d.ts.map
@@ -9,7 +9,11 @@
9
9
  * other subscription providers the harness recognizes (volcengine / baidu /
10
10
  * qwen / xiaomi token plans, agent plans…) are identified and listed with a
11
11
  * "no quota API" marker rather than hidden. API keys come from the `llm-pi-ai`
12
- * settings namespace (`apiKeyEnv` refs) resolved through the credentials seam.
12
+ * settings namespace resolved through the credentials seam: the classic
13
+ * `apiKeyEnv` refs, or — on hosts whose settings UI stores route keys as
14
+ * credentials refs named after the route (`<ROUTE>_API_KEY`, catalog ambient
15
+ * names as fallback) — the conventional refs, matched against the same
16
+ * subscription-class route ids.
13
17
  */
14
18
  import type { SubscriptionPlanConfig, SubscriptionQuota, SubscriptionWindow } from './pricing-shared.ts';
15
19
  /** 订阅适配器需要的凭据(来自 llm-pi-ai 设置命名空间)。 */
@@ -46,6 +50,17 @@ export interface SubscriptionKeys {
46
50
  export declare function parseOpenCodeAuthDocument(document: unknown): string;
47
51
  /** 空凭据:全部未配置时的初始值。 */
48
52
  export declare const EMPTY_SUBSCRIPTION_KEYS: SubscriptionKeys;
53
+ /**
54
+ * key 解析的可测核心(无文件 I/O):先显式 `apiKeyEnv`(旧口径,优先),key 仍缺
55
+ * 时按约定 ref 名解析(新版宿主的存放形态,见 route-keys.ts)。`keyConfigured`
56
+ * 回报每条路由的 key 是否解析成功,供识别层作为第三配置信号(refResolved)。
57
+ * @param providers - llm-pi-ai 的 providers 视图。
58
+ * @param resolveRef - 凭据 seam:ref 名 → 非空 key 值;未配置/失败返回 undefined。
59
+ */
60
+ export declare function resolveSubscriptionAccess(providers: Readonly<Record<string, SubscriptionRouteConfigView | undefined>>, resolveRef: (name: string) => Promise<string | undefined>): Promise<{
61
+ keys: SubscriptionKeys;
62
+ keyConfigured: ReadonlySet<string>;
63
+ }>;
49
64
  /** 已识别的一个订阅套餐(用户在 llm-pi-ai 里配置了 key 的订阅类 provider)。 */
50
65
  export interface IdentifiedSubscriptionPlan {
51
66
  /** llm-pi-ai 的 provider id(如 kimi-coding、xiaomi-token-plan-cn)。 */
@@ -57,16 +72,28 @@ export interface IdentifiedSubscriptionPlan {
57
72
  /** 适配器区域覆盖:两个 Z.ai 路由各自固定区域,互不跟随 keys.zaiRegion。 */
58
73
  region?: 'global' | 'bigmodel-cn';
59
74
  }
75
+ /**
76
+ * 一条 llm-pi-ai 路由的订阅识别视图:三个「已配置」信号任一为真即识别。
77
+ * 新版宿主(内置目录 + ambient 发现)把路由 key 存进凭据 refs,providers 配置里
78
+ * 只剩 models 列表——`apiKeyEnv` 不再是唯一的配置信号。
79
+ */
80
+ export interface SubscriptionRouteConfigView {
81
+ /** 显式凭据引用(旧口径)。 */
82
+ apiKeyEnv?: string;
83
+ /** 路由声明了非空 models 列表(新版设置页保存的配置形态)。 */
84
+ hasModels?: boolean;
85
+ /** 路由约定 ref(`<ROUTE>_API_KEY` / 目录 ambient 名)解析出了非空 key。 */
86
+ refResolved?: boolean;
87
+ }
60
88
  /** 是否是订阅类 provider id(如 kimi-coding、xiaomi-token-plan-cn)。 */
61
89
  export declare function isSubscriptionProviderId(providerId: string): boolean;
62
90
  /**
63
- * 从 llm-pi-ai 设置里识别订阅套餐:带订阅类 id 且配置了 apiKeyEnv 的 provider。
91
+ * 从 llm-pi-ai 设置里识别订阅套餐:带订阅类 id 且任一配置信号成立的 provider
92
+ * (显式 apiKeyEnv / models 已配置 / 约定 ref 解析出了 key)。
64
93
  * @param providers - the `providers` map of the llm-pi-ai settings namespace.
65
94
  * @returns identified plans in configuration order.
66
95
  */
67
- export declare function identifySubscriptionPlans(providers: Record<string, {
68
- apiKeyEnv?: string;
69
- } | undefined> | undefined): IdentifiedSubscriptionPlan[];
96
+ export declare function identifySubscriptionPlans(providers: Record<string, SubscriptionRouteConfigView | undefined> | undefined): IdentifiedSubscriptionPlan[];
70
97
  /**
71
98
  * 解析 MiniMax Token Plan `/v1/token_plan/remains` 响应。取 general(或 MiniMax-M*)
72
99
  * 一行抽出 5h/7d 窗口(total_count 常为 0,以 remaining_percent 为准),不按模型拆条。
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.6.1",
4
+ "version": "1.6.3",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "deepseek",