@kenz1117/dsh-ui-usage-billing 1.8.12 → 1.8.14
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 +7 -4
- package/README.md +8 -5
- package/lib/client.js +5 -5
- package/lib/index.js +74 -18
- package/lib/types/balance.d.ts +20 -1
- package/lib/types/client/UsageBilling.d.ts +2 -0
- package/lib/types/client/UsageBillingMainPanel.d.ts +7 -0
- package/lib/types/client/UsageBillingPanelIcon.d.ts +5 -0
- package/lib/types/client/domain/types.d.ts +3 -0
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/client/panel-capability.d.ts +12 -0
- package/lib/types/client/queue-eligibility.d.ts +30 -0
- package/lib/types/client/task-queue-quick.d.ts +1 -1
- package/lib/types/client/usage-billing-settings.d.ts +14 -0
- package/lib/types/guard.d.ts +13 -3
- package/lib/types/pricing-shared.d.ts +14 -0
- package/lib/types/task-queue-shared.d.ts +12 -0
- package/package.json +3 -1
package/lib/index.js
CHANGED
|
@@ -4807,6 +4807,20 @@ const BALANCE_CLIENT_HEADERS = {
|
|
|
4807
4807
|
locale: "x-dsh-billing-client-locale",
|
|
4808
4808
|
timezone: "x-dsh-billing-client-timezone-offset"
|
|
4809
4809
|
};
|
|
4810
|
+
/**
|
|
4811
|
+
* 宿主内置的两条 DeepSeek 通道的路由 id(宿主包 `llm-deepseek-api-key` /
|
|
4812
|
+
* `llm-deepseek-account` 注册,`0.1.2-alpha.1` ~ `0.2.3-alpha.3` 全程稳定):
|
|
4813
|
+
*
|
|
4814
|
+
* - `deepseek-official`:平台 API key 通道,花的是用户自己的 DeepSeek 平台
|
|
4815
|
+
* 账户余额(凭据 ref 默认 `DEEPSEEK_API_KEY`);
|
|
4816
|
+
* - `deepseek-account`:登录账号通道,花的是宿主登录钱包的余额。
|
|
4817
|
+
*
|
|
4818
|
+
* 两条通道都**不在 llm-pi-ai 路由表里**(插件自造的 `deepseek` 路由 id 与它们
|
|
4819
|
+
* 不同)。钱包归属必须按宿主通道 id 认,否则内置通道的用量桶认不到任何钱包
|
|
4820
|
+
* (issue #141:悬浮卡显示「余额不可确认」)。
|
|
4821
|
+
*/
|
|
4822
|
+
const DEEPSEEK_PLATFORM_ROUTE = "deepseek-official";
|
|
4823
|
+
const DEEPSEEK_LOGIN_ROUTE = "deepseek-account";
|
|
4810
4824
|
function siteBucketKey(ref) {
|
|
4811
4825
|
if (ref.kind === "site" && ref.origin) return `site:${ref.origin}`;
|
|
4812
4826
|
if (ref.kind === "direct" && ref.provider) return `direct:${ref.provider}`;
|
|
@@ -7252,6 +7266,12 @@ const customGate = createCooldownGate({
|
|
|
7252
7266
|
});
|
|
7253
7267
|
/** DeepSeek 官方余额接口(官方文档 api-docs.deepseek.com/api/get-user-balance)。 */
|
|
7254
7268
|
const DEEPSEEK_BALANCE_URL = "https://api.deepseek.com/user/balance";
|
|
7269
|
+
/**
|
|
7270
|
+
* 宿主内置平台通道(路由 id `deepseek-official`)的默认凭据 ref——宿主包
|
|
7271
|
+
* `llm-deepseek-api-key` 的 `apiKeyEnv` 默认值(`0.1.2-alpha.1` ~ `0.2.3-alpha.3`)。
|
|
7272
|
+
* 内置通道不在 llm-pi-ai 路由表里,只能按这个约定 ref 找回它的 key。
|
|
7273
|
+
*/
|
|
7274
|
+
const DEEPSEEK_PLATFORM_KEY_REF = "DEEPSEEK_API_KEY";
|
|
7255
7275
|
/** Moonshot/Kimi 官方余额接口(platform.kimi.com/docs/api/balance)。 */
|
|
7256
7276
|
const MOONSHOT_BALANCE_URL = "https://api.moonshot.cn/v1/users/me/balance";
|
|
7257
7277
|
/** 阶跃星辰 StepFun 官方账户信息接口(platform.stepfun.com/docs/api-reference/accounts/get)。 */
|
|
@@ -7348,11 +7368,16 @@ function parseDeepSeekBalance(data) {
|
|
|
7348
7368
|
...isAvailable !== void 0 ? { isAvailable } : {}
|
|
7349
7369
|
};
|
|
7350
7370
|
}
|
|
7371
|
+
/**
|
|
7372
|
+
* 登录钱包(宿主 DeepSeek 账号通道):归属宿主内置的登录通道路由 id
|
|
7373
|
+
* `deepseek-account`(宿主包 `llm-deepseek-account` 注册)——它供的是登录通道,
|
|
7374
|
+
* 不是 API key 路由,两只钱包不能共认一条路由(issue #141)。
|
|
7375
|
+
*/
|
|
7351
7376
|
const ACCOUNT_WALLET = {
|
|
7352
7377
|
provider: "deepseek",
|
|
7353
7378
|
displayName: "DeepSeek",
|
|
7354
7379
|
sourceRoute: "deepseek",
|
|
7355
|
-
attributedRoutes: [
|
|
7380
|
+
attributedRoutes: [DEEPSEEK_LOGIN_ROUTE],
|
|
7356
7381
|
walletKind: "account"
|
|
7357
7382
|
};
|
|
7358
7383
|
const warnedAccountFailures = /* @__PURE__ */ new Set();
|
|
@@ -7577,6 +7602,14 @@ function bearer(route, displayName, endpoint, query) {
|
|
|
7577
7602
|
}
|
|
7578
7603
|
const QUERIERS = [
|
|
7579
7604
|
bearer("deepseek", "deepseek", DEEPSEEK_BALANCE_URL, queryDeepSeek),
|
|
7605
|
+
{
|
|
7606
|
+
route: DEEPSEEK_PLATFORM_ROUTE,
|
|
7607
|
+
displayName: "deepseek",
|
|
7608
|
+
endpoint: DEEPSEEK_BALANCE_URL,
|
|
7609
|
+
keyRefs: [DEEPSEEK_PLATFORM_KEY_REF],
|
|
7610
|
+
keyOnly: true,
|
|
7611
|
+
query: (key) => queryDeepSeek(DEEPSEEK_BALANCE_URL, key)
|
|
7612
|
+
},
|
|
7580
7613
|
bearer("moonshot", "月之暗面", MOONSHOT_BALANCE_URL, queryMoonshot),
|
|
7581
7614
|
bearer("stepfun", "阶跃星辰", STEPFUN_BALANCE_URL, queryStepFun),
|
|
7582
7615
|
bearer("siliconflow", "硅基流动", SILICONFLOW_BALANCE_URL, querySiliconFlow),
|
|
@@ -7614,9 +7647,11 @@ const QUERIERS = [
|
|
|
7614
7647
|
* dashboard shows a stable state instead of dropping the row.
|
|
7615
7648
|
* @param ctx - host context carrying the credentials seam.
|
|
7616
7649
|
* @param providers - the llm-pi-ai providers dict (`<route> → { apiKeyEnv? }`).
|
|
7650
|
+
* @param client - UI metadata for the host login wallet service.
|
|
7651
|
+
* @param options - extra credential candidates per route (plugin config).
|
|
7617
7652
|
* @returns the balance rows (one per provider).
|
|
7618
7653
|
*/
|
|
7619
|
-
async function queryBalances(ctx, providers, client) {
|
|
7654
|
+
async function queryBalances(ctx, providers, client, options) {
|
|
7620
7655
|
const resolveRef = async (name) => {
|
|
7621
7656
|
try {
|
|
7622
7657
|
const hit = await ctx.credentials.resolve(credentialRef(name));
|
|
@@ -7638,7 +7673,12 @@ async function queryBalances(ctx, providers, client) {
|
|
|
7638
7673
|
const resolved = await Promise.all(QUERIERS.map(async (spec) => {
|
|
7639
7674
|
const { route, endpoint } = spec;
|
|
7640
7675
|
const env = providers[route]?.apiKeyEnv;
|
|
7641
|
-
const hit = await firstResolvedRef([
|
|
7676
|
+
const hit = await firstResolvedRef([
|
|
7677
|
+
...env ? [env] : [],
|
|
7678
|
+
...spec.keyRefs ?? [],
|
|
7679
|
+
...options?.extraKeyRefs?.[route] ?? [],
|
|
7680
|
+
...routeKeyRefCandidates(route)
|
|
7681
|
+
], resolveRef);
|
|
7642
7682
|
const expectedOrigin = endpoint && new URL(endpoint).origin;
|
|
7643
7683
|
const configuredOrigin = origins.get(route);
|
|
7644
7684
|
const verified = configuredOrigin === void 0 || expectedOrigin !== void 0 && configuredOrigin === expectedOrigin;
|
|
@@ -7649,7 +7689,7 @@ async function queryBalances(ctx, providers, client) {
|
|
|
7649
7689
|
verified
|
|
7650
7690
|
};
|
|
7651
7691
|
}));
|
|
7652
|
-
const present = (item) => item.key !== void 0 || Object.hasOwn(providers, item.route);
|
|
7692
|
+
const present = (item) => item.key !== void 0 || !item.keyOnly && Object.hasOwn(providers, item.route);
|
|
7653
7693
|
const presentVendors = new Set(resolved.filter(present).map((item) => item.displayName));
|
|
7654
7694
|
const targets = [];
|
|
7655
7695
|
for (const item of resolved) {
|
|
@@ -10090,15 +10130,26 @@ function isLoopbackHost(req, trustedHosts = /* @__PURE__ */ new Set()) {
|
|
|
10090
10130
|
if (name === "localhost" || name === "::1" || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(name)) return true;
|
|
10091
10131
|
return name !== "" && trustedHosts.has(name);
|
|
10092
10132
|
}
|
|
10093
|
-
/** 校验 Origin
|
|
10133
|
+
/** 校验 Origin 头是否可信(写操作用,防止跨站表单/fetch 改写设置)。Origin 缺失
|
|
10094
10134
|
* (curl 或同源 fetch 不带)视为放行,交给下方的 Content-Type 校验兜底;Origin 存在
|
|
10095
|
-
*
|
|
10096
|
-
|
|
10135
|
+
* 但主机既非回环、也不在 trustedHosts 里则拒绝——跨站脚本发起的写请求必带攻击者
|
|
10136
|
+
* 域名的 Origin。
|
|
10137
|
+
*
|
|
10138
|
+
* 反向代理场景:浏览器把页面自身的地址写进 Origin(`https://dash.example.com`)。
|
|
10139
|
+
* Host 头因为同一域名被 trustedHosts 放行,Origin 却是同一个非回环域名——只认回环
|
|
10140
|
+
* 字面量会让「已显式信任的主机」在写操作上必然 403(读操作正常),表现为面板能
|
|
10141
|
+
* 打开、点任何保存/入队都报 `forbidden: loopback only`。因此 Origin 与 Host 共用
|
|
10142
|
+
* 同一份 trustedHosts:用户显式信任某个主机,就等于接受该主机的同源写请求。
|
|
10143
|
+
* @param origin - 原始 Origin 头(可能缺失)。
|
|
10144
|
+
* @param trustedHosts - 已归一化的可信主机名集合,与 {@link isLoopbackHost} 同口径。
|
|
10145
|
+
*/
|
|
10146
|
+
function isLoopbackOrigin(origin, trustedHosts = /* @__PURE__ */ new Set()) {
|
|
10097
10147
|
if (origin === void 0 || origin === "") return true;
|
|
10098
10148
|
try {
|
|
10099
10149
|
const raw = new URL(origin).hostname;
|
|
10100
10150
|
const host = raw.startsWith("[") && raw.endsWith("]") ? raw.slice(1, -1) : raw;
|
|
10101
|
-
|
|
10151
|
+
if (host === "localhost" || host === "::1" || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(host)) return true;
|
|
10152
|
+
return host !== "" && trustedHosts.has(host.toLowerCase());
|
|
10102
10153
|
} catch {
|
|
10103
10154
|
return false;
|
|
10104
10155
|
}
|
|
@@ -10302,7 +10353,7 @@ function registerPeakScheduleRoute(ctx, deps) {
|
|
|
10302
10353
|
if (!guardLoopback(req, res, deps.trustedHosts)) return;
|
|
10303
10354
|
let raw;
|
|
10304
10355
|
if (req.method === "POST") {
|
|
10305
|
-
if (!isLoopbackOrigin(req.headers.origin)) return reply(res, 403, {
|
|
10356
|
+
if (!isLoopbackOrigin(req.headers.origin, deps.trustedHosts)) return reply(res, 403, {
|
|
10306
10357
|
error: "forbidden: loopback only",
|
|
10307
10358
|
message: "仅限本机请求"
|
|
10308
10359
|
});
|
|
@@ -10477,7 +10528,7 @@ function registerNotifyClaimRoute(ctx, deps) {
|
|
|
10477
10528
|
res.end(JSON.stringify({ error: "method not allowed" }));
|
|
10478
10529
|
return;
|
|
10479
10530
|
}
|
|
10480
|
-
if (!isLoopbackOrigin(req.headers.origin) || !(req.headers["content-type"] ?? "").toLowerCase().includes("application/json")) {
|
|
10531
|
+
if (!isLoopbackOrigin(req.headers.origin, deps.trustedHosts) || !(req.headers["content-type"] ?? "").toLowerCase().includes("application/json")) {
|
|
10481
10532
|
res.writeHead(403, { "content-type": "application/json; charset=utf-8" });
|
|
10482
10533
|
res.end(JSON.stringify({ error: "forbidden: loopback only" }));
|
|
10483
10534
|
return;
|
|
@@ -10699,7 +10750,7 @@ function registerRefreshRoute(ctx, deps) {
|
|
|
10699
10750
|
res.end(JSON.stringify({ error: "method not allowed" }));
|
|
10700
10751
|
return;
|
|
10701
10752
|
}
|
|
10702
|
-
if (!isLoopbackOrigin(req.headers.origin)) {
|
|
10753
|
+
if (!isLoopbackOrigin(req.headers.origin, deps.trustedHosts)) {
|
|
10703
10754
|
res.writeHead(403, { "content-type": "application/json; charset=utf-8" });
|
|
10704
10755
|
res.end(JSON.stringify({ error: "forbidden: loopback only" }));
|
|
10705
10756
|
return;
|
|
@@ -10814,7 +10865,7 @@ function registerUsageToolRoute(ctx, deps) {
|
|
|
10814
10865
|
return;
|
|
10815
10866
|
}
|
|
10816
10867
|
if (req.method === "POST") {
|
|
10817
|
-
if (!isLoopbackOrigin(req.headers.origin)) {
|
|
10868
|
+
if (!isLoopbackOrigin(req.headers.origin, deps.trustedHosts)) {
|
|
10818
10869
|
res.writeHead(403, { "content-type": "application/json; charset=utf-8" });
|
|
10819
10870
|
res.end(JSON.stringify({ error: "forbidden: loopback only" }));
|
|
10820
10871
|
return;
|
|
@@ -11329,8 +11380,10 @@ var TaskQueueEngine = class {
|
|
|
11329
11380
|
if (!refresh && this.modelCache !== void 0 && this.now() - this.modelCache.at < OPTIONS_CACHE_MS) return this.modelCache;
|
|
11330
11381
|
const catalog = await controller.modelCatalog();
|
|
11331
11382
|
const models = [];
|
|
11383
|
+
let officialRoute = false;
|
|
11332
11384
|
for (const group of catalog.groups) {
|
|
11333
11385
|
if (group.id !== "deepseek-official") continue;
|
|
11386
|
+
officialRoute = true;
|
|
11334
11387
|
for (const model of group.models) {
|
|
11335
11388
|
if (rateChannelOf(model.id, false) !== "deepseek-metered") continue;
|
|
11336
11389
|
models.push({
|
|
@@ -11346,14 +11399,17 @@ var TaskQueueEngine = class {
|
|
|
11346
11399
|
provider: candidate.provider,
|
|
11347
11400
|
model: candidate.model
|
|
11348
11401
|
};
|
|
11402
|
+
const blockedReason = models.length > 0 ? void 0 : officialRoute ? "no-official-model" : "no-official-route";
|
|
11349
11403
|
this.modelCache = {
|
|
11350
11404
|
at: this.now(),
|
|
11351
11405
|
models,
|
|
11352
|
-
defaultModel
|
|
11406
|
+
defaultModel,
|
|
11407
|
+
blockedReason
|
|
11353
11408
|
};
|
|
11354
11409
|
return {
|
|
11355
11410
|
models,
|
|
11356
|
-
defaultModel
|
|
11411
|
+
defaultModel,
|
|
11412
|
+
blockedReason
|
|
11357
11413
|
};
|
|
11358
11414
|
}
|
|
11359
11415
|
async pump() {
|
|
@@ -11693,7 +11749,7 @@ function registerTaskQueueRoute(ctx, deps) {
|
|
|
11693
11749
|
return;
|
|
11694
11750
|
}
|
|
11695
11751
|
if (req.method === "POST") {
|
|
11696
|
-
if (!isLoopbackOrigin(req.headers.origin)) {
|
|
11752
|
+
if (!isLoopbackOrigin(req.headers.origin, deps.trustedHosts)) {
|
|
11697
11753
|
send(res, 403, { error: "forbidden: loopback only" });
|
|
11698
11754
|
return;
|
|
11699
11755
|
}
|
|
@@ -11867,8 +11923,8 @@ const QUOTA_RESPONSE_BUDGET_MS = 8e3;
|
|
|
11867
11923
|
* 取 5 分钟:与 usage-stats 的 30s 轮询 + 5 分钟快照节流同一量级。
|
|
11868
11924
|
*/
|
|
11869
11925
|
const RECONCILE_BASIS_MAX_AGE_MS = 3e5;
|
|
11870
|
-
/** DeepSeek
|
|
11871
|
-
const DEFAULT_BALANCE_API_KEY_ENV =
|
|
11926
|
+
/** DeepSeek 余额查询的默认凭据引用(与宿主内置平台通道的默认引用一致)。 */
|
|
11927
|
+
const DEFAULT_BALANCE_API_KEY_ENV = DEEPSEEK_PLATFORM_KEY_REF;
|
|
11872
11928
|
/**
|
|
11873
11929
|
* 本插件版本号:从包自身的 package.json 读取(单一来源),随 usage-stats
|
|
11874
11930
|
* 下发,供「设置 → 插件信息卡」展示。发布版 lib/index.js 相对包根解析。
|
|
@@ -12742,7 +12798,7 @@ function apply(ctx, config = {}) {
|
|
|
12742
12798
|
...providers["deepseek"],
|
|
12743
12799
|
apiKeyEnv: config.balanceApiKeyEnv ?? DEFAULT_BALANCE_API_KEY_ENV
|
|
12744
12800
|
};
|
|
12745
|
-
const balances = await queryBalances(ctx, providers, client);
|
|
12801
|
+
const balances = await queryBalances(ctx, providers, client, config.balanceApiKeyEnv === void 0 ? void 0 : { extraKeyRefs: { [DEEPSEEK_PLATFORM_ROUTE]: [config.balanceApiKeyEnv] } });
|
|
12746
12802
|
const custom = await queryCustomBalances(ctx, config.customBalances ?? []);
|
|
12747
12803
|
const declared = await queryDeclaredEndpoints(ctx, piProviders, config.declaredEndpoints ?? []);
|
|
12748
12804
|
for (const row of [
|
package/lib/types/balance.d.ts
CHANGED
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { Context } from '@deepseek-ai/cordis';
|
|
16
16
|
import { type BalanceClientMetadata, type CustomBalanceConfig, type CustomBalanceExtract, type ProviderBalance } from './pricing-shared.ts';
|
|
17
|
+
/**
|
|
18
|
+
* 宿主内置平台通道(路由 id `deepseek-official`)的默认凭据 ref——宿主包
|
|
19
|
+
* `llm-deepseek-api-key` 的 `apiKeyEnv` 默认值(`0.1.2-alpha.1` ~ `0.2.3-alpha.3`)。
|
|
20
|
+
* 内置通道不在 llm-pi-ai 路由表里,只能按这个约定 ref 找回它的 key。
|
|
21
|
+
*/
|
|
22
|
+
export declare const DEEPSEEK_PLATFORM_KEY_REF = "DEEPSEEK_API_KEY";
|
|
17
23
|
export declare function apiBalanceSource(row: ProviderBalance): string | undefined;
|
|
18
24
|
/**
|
|
19
25
|
* 从 TokenDance 余额响应提取剩余余额并换算为元。导出供测试:纯函数。
|
|
@@ -23,6 +29,17 @@ export declare function apiBalanceSource(row: ProviderBalance): string | undefin
|
|
|
23
29
|
* @returns 剩余余额(元);提取不到返回 undefined。
|
|
24
30
|
*/
|
|
25
31
|
export declare function pickTokenDanceBalanceCny(data: unknown): number | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* 余额查询的额外口径(插件配置进不来时的唯一入口)。
|
|
34
|
+
*/
|
|
35
|
+
export interface BalanceQueryOptions {
|
|
36
|
+
/**
|
|
37
|
+
* 额外的凭据候选(按路由 id):插件配置里的 `balanceApiKeyEnv` 之类。排在路由
|
|
38
|
+
* 约定名之前——宿主内置通道的 key 由宿主自己存(默认 ref 固定),插件配置的
|
|
39
|
+
* ref 只是后备。
|
|
40
|
+
*/
|
|
41
|
+
extraKeyRefs?: Readonly<Record<string, readonly string[]>>;
|
|
42
|
+
}
|
|
26
43
|
/**
|
|
27
44
|
* Query every configured provider's account balance. A provider is queried only
|
|
28
45
|
* when its llm-pi-ai route has a key: an explicit `apiKeyEnv`, or — on hosts
|
|
@@ -31,12 +48,14 @@ export declare function pickTokenDanceBalanceCny(data: unknown): number | undefi
|
|
|
31
48
|
* dashboard shows a stable state instead of dropping the row.
|
|
32
49
|
* @param ctx - host context carrying the credentials seam.
|
|
33
50
|
* @param providers - the llm-pi-ai providers dict (`<route> → { apiKeyEnv? }`).
|
|
51
|
+
* @param client - UI metadata for the host login wallet service.
|
|
52
|
+
* @param options - extra credential candidates per route (plugin config).
|
|
34
53
|
* @returns the balance rows (one per provider).
|
|
35
54
|
*/
|
|
36
55
|
export declare function queryBalances(ctx: Context, providers: Readonly<Record<string, {
|
|
37
56
|
apiKeyEnv?: string;
|
|
38
57
|
baseURL?: string;
|
|
39
|
-
}>>, client?: BalanceClientMetadata): Promise<readonly ProviderBalance[]>;
|
|
58
|
+
}>>, client?: BalanceClientMetadata, options?: BalanceQueryOptions): Promise<readonly ProviderBalance[]>;
|
|
40
59
|
/**
|
|
41
60
|
* 按 extract 规则从响应 JSON 求值。导出供测试:纯函数。
|
|
42
61
|
* @param rule - 提取规则(const / path / add / subtract / divide)。
|
|
@@ -25,6 +25,8 @@ type BillingBudgetStoreProps = PropsStore<ReturnType<typeof createBillingBudgetS
|
|
|
25
25
|
export type UsageBillingProps = PropsRuntime<'sidebar.footer.action'> & SidebarFooterActionOwnerProps & InjectFace<UsageBillingInjected> & PropsRenderSlots<'billing.dashboard.decor'> & BillingBudgetStoreProps & PropsLocale<typeof NS> & {
|
|
26
26
|
/** 原生设置页嵌入模式:只渲染完整设置分区,不渲染侧栏入口与弹窗外壳。 */
|
|
27
27
|
embeddedSettings?: boolean;
|
|
28
|
+
/** 宿主 main 主面板:渲染完整仪表盘内容,但不渲染触发器、Modal 与关闭按钮。 */
|
|
29
|
+
embeddedPanel?: boolean;
|
|
28
30
|
};
|
|
29
31
|
/**
|
|
30
32
|
* UsageBilling: sidebar trigger plus the billing dashboard modal.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** 宿主 main 主面板:复用完整仪表盘,不再套底部触发器或 Modal(issue #144)。 */
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { type UsageBillingProps } from './UsageBilling.tsx';
|
|
4
|
+
type UsageBillingMainPanelProps = Omit<UsageBillingProps, 'wide' | 'embeddedSettings' | 'embeddedPanel' | 'renderSlot' | '__renders'>;
|
|
5
|
+
export declare function UsageBillingMainPanel(props: UsageBillingMainPanelProps): ReactNode;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=UsageBillingMainPanel.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** sidebar.panellist 的纯导航图标;宿主拥有外层按钮与选中态。 */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import type { PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
4
|
+
export declare function UsageBillingPanelIcon({ size }: PropsRuntime<'sidebar.panellist'>): ReactNode;
|
|
5
|
+
//# sourceMappingURL=UsageBillingPanelIcon.d.ts.map
|
|
@@ -151,6 +151,9 @@ export interface UsageBillingInjected {
|
|
|
151
151
|
monthCost: number;
|
|
152
152
|
}) => void;
|
|
153
153
|
registerOpen: (handler: () => void) => () => void;
|
|
154
|
+
/** 宿主是否同时具备 main 与 sidebar.panellist;决定左侧入口能否安全独占(issue #144)。 */
|
|
155
|
+
leftPanelAvailable: () => boolean;
|
|
156
|
+
subscribeLeftPanelAvailable: (listener: () => void) => () => void;
|
|
154
157
|
/** 原生设置页或 /usage 是否至少一个可用;完全隐藏必须有恢复入口(issue #108 防锁死)。 */
|
|
155
158
|
recoveryEntryAvailable: boolean;
|
|
156
159
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Locale dictionaries for the usage billing surface. */
|
|
2
2
|
import { peakZh } from './peak-schedule-locales.ts';
|
|
3
|
-
export type UsageBillingKey = keyof typeof peakZh | 'title' | 'cost' | 'todayCost' | 'monthCost' | 'yearCost' | 'monthProjected' | 'monthProjectedHint' | 'liveTurn' | 'liveSession' | 'liveSessionSub' | 'calls' | 'cacheHitRate' | 'tokens' | 'inputTokens' | 'outputTokens' | 'avgCost' | 'kpiRange' | 'avgRangeToday' | 'avgRange7d' | 'avgRangeWeek' | 'avgRangeMonth' | 'avgRangeAll' | 'avgRangeCustom' | 'customRangeStart' | 'customRangeEnd' | 'trend' | 'trend7d' | 'trend30d' | 'trendMetric' | 'trendMetricCost' | 'trendMetricTokens' | 'pricingSearch' | 'bandPinHint' | 'trendEmpty' | 'trendTotal' | 'roundsUnit' | 'healthModelsLive' | 'healthVendorsDown' | 'healthVendorsUnavailable' | 'budget' | 'budgetRemain' | 'budgetAmount' | 'budgetSummary' | 'sessions' | 'sessionTitle' | 'lastActive' | 'sessionOverflow' | 'budgetTierBody' | 'models' | 'providerBilling' | 'channelUnknown' | 'directTag' | 'relayTag' | 'unknownTag' | 'unknownChannelHint' | 'planCountUnit' | 'actual' | 'pricing' | 'input' | 'output' | 'cacheHit' | 'peak' | 'offPeak' | 'flat' | 'band' | 'close' | 'footer' | 'footerCredit' | 'lastUpdated' | 'noData' | 'todayRate' | 'rateLive' | 'rateBuiltin' | 'pricingSyncedAt' | 'pricingSyncNow' | 'pricingSyncing' | 'promoBadge' | 'promoUntil' | 'promoOpenEnded' | 'pricingTip' | 'pricingUnit' | 'pricingNotes' | 'ubPeak' | 'ubOff' | 'ubStd' | 'peakBand' | 'pricingSource' | 'noteCache' | 'noteBand' | 'noteSource' | 'balance' | 'recharge' | 'rechargeHint' | 'balanceUnconfigured' | 'balanceUnauthorized' | 'walletLogin' | 'walletPlatform' | 'walletInvalid' | 'walletNoService' | 'walletNoMetadata' | 'walletSignedOut' | 'balanceUnreachable' | 'uncatalogued' | 'estimatedPricing' | 'balanceDays' | 'balanceLowBody' | 'reconcileDrift' | 'reconcileDismiss' | 'subscriptionNotConfigured' | 'subscriptionUnauthorized' | 'subscriptionUnavailable' | 'subscriptionInvalid' | 'subscriptionRateLimited' | 'subscriptionSession' | 'subscriptionWeekly' | 'subscriptionMonthly' | 'subscriptionBilling' | 'subscriptionRemaining' | 'subscriptionExhausted' | 'subscriptionReset' | 'subscriptionNoApi' | 'floatWindow' | 'floatModeCombined' | 'floatModeSubscription' | 'floatMode' | 'floatTargets' | 'floatWindowHint' | 'floatPrimaryToday' | 'floatPrimaryWeek' | 'floatPrimaryMonth' | 'floatNoTargets' | 'floatNoTargetsHint' | 'cardDisplay' | 'cardDisplayHint' | 'cardMode' | 'cardModeFull' | 'cardModeCompact' | 'cardModeHidden' | 'cardModeHiddenHint' | 'cardModeFallback' | 'nativeSettingsNav' | 'nativeSettingsIntro' | 'nativeSettingsHiddenHint' | 'shortcutOpenDashboard' | 'cardMetric' | 'cardMetricMoney' | 'cardMetricTokens' | 'cardSpan' | 'cardSpanDay' | 'cardSpanWeek' | 'cardSpanMonth' | 'cardDeltaBadge' | 'cardDeltaShow' | 'cardDeltaHide' | 'triggerMonthTokens' | 'triggerTodayTokens' | 'triggerWeekTokens' | 'subscriptionsStale' | 'balanceStaleNotice' | 'staleLedgerNotice' | 'staleSnapshotNotice' | 'statsLoadFailed' | 'unreadableNotice' | 'unreadableFormatNotice' | 'unreadableNoLedgerNotice' | 'tokenCacheWrite' | 'toolRank' | 'toolName' | 'userPrices' | 'userPricesHint' | 'userPriceSave' | 'priceSaved' | 'userPriceEditIdentity' | 'pricePicker' | 'priceModelsPartial' | 'priceModelsPending' | 'priceModelDefault' | 'priceIncomplete' | 'priceUnpriced' | 'userPriceModel' | 'userPriceSource' | 'userPriceSourceHint' | 'userPriceOffPeak' | 'userPriceNormal' | 'userPriceCurrency' | 'userPriceAdd' | 'userPriceRemoveSelected' | 'userPriceSelect' | 'sessionStaleBadge' | 'sessionUntitled' | 'sessionSubCost' | 'sessionSubCalls' | 'sessionSubRow' | 'heatmapLess' | 'heatmapMore' | 'currency' | 'currencyCny' | 'currencyUsd' | 'currencyEur' | 'language' | 'heatmap' | 'rounds' | 'roundsHint' | 'anomaly' | 'model' | 'thModel' | 'thInputMiss' | 'thInputHit' | 'costAbbr' | 'tabOverview' | 'tabTrends' | 'tabProviders' | 'tabPricing' | 'tabSettings' | 'budgetHint' | 'peakAlertHint' | 'peakAlertDescPeak' | 'peakAlertDescOff' | 'peakAlertDescPeakZhipu' | 'peakAlertDescOffZhipu' | 'peakAlertQueuePeak' | 'peakAlertQueueOff' | 'export' | 'exportCsvDay' | 'exportCsvSession' | 'exportJson' | 'peakShare' | 'peakSharePerCall' | 'offPeakSavings' | 'perfMax' | 'weekCost' | 'roleCost' | 'roleUser' | 'roleAssistant' | 'roleTool' | 'roleHint' | 'tierPeak' | 'tierOff' | 'tierToPeak' | 'tierToOff' | 'tierAlertEnterPeak' | 'tierAlertEnterOff' | 'tierAlertEnterPeakZhipu' | 'tierAlertEnterOffZhipu' | 'peakAlertTitlePeak' | 'peakAlertTitleOff' | 'peakAlert' | 'peakAlertLeadMin' | 'peakAlertPos' | 'peakAlertMode' | 'peakAlertPosCorner' | 'peakAlertPosCenter' | 'peakAlertModePeak' | 'peakAlertModeOff' | 'peakAlertModeBoth' | 'peakAlertWebNotify' | 'peakAlertPreview' | 'planTypeCode' | 'planTypeToken' | 'subscriptionFeePerMonth' | 'triggerToday' | 'triggerMonth' | 'subscriptionTag' | 'cellEstimateHint' | 'free' | 'perfSamples' | 'perfTtft' | 'perfP50' | 'perfP90' | 'perfTps' | 'perfLatency' | 'perfEstimated' | 'perfEmpty' | 'perfTpsUnit' | 'perfTitle' | 'perfHint' | 'perfAll' | 'perfChartEmpty' | 'heatmapYear' | 'heatmapHalf' | 'heatmapMonth' | 'metricCost' | 'metricTokens' | 'heatmapTotal' | 'activeDays' | 'streakDays' | 'subscriptionAutoDetect' | 'pluginAuthor' | 'pluginRepository' | 'pluginNpm' | 'pluginLicense' | 'tabToken' | 'tokenExport' | 'tokenExportCsv' | 'tokenReasoningShare' | 'tokenReasoningShort' | 'tokenIo' | 'tokenPeak' | 'densityLabel' | 'densityHint' | 'densityCompact' | 'densityDefault' | 'densityComfortable' | 'motionLabel' | 'motionHint' | 'motionOff' | 'motionSubtle' | 'motionRich' | 'settingsNavDisplayPref' | 'settingsNavBudget' | 'settingsNavAlert' | 'settingsNavDisplay' | 'settingsNavAdvanced' | 'settingsNavAbout' | 'settingsSearchPlaceholder' | 'settingsSearchEmpty' | 'sessionsViewAll' | 'sessionsViewTop' | 'sessionViewerSearch' | 'modelBudgetTitle' | 'modelBudgetHint' | 'modelBudgetBody' | 'modelBudgetPlaceholder' | 'moreWorksTitle' | 'adEngramName' | 'adEngramDesc' | 'adRainbowName' | 'adRainbowDesc' | 'kpiDescCacheHit' | 'kpiDescTokens' | 'kpiDescAvgCost' | 'kpiDescCalls' | 'kpiDescReasoning' | 'kpiDescIo' | 'kpiDescPeak' | 'healthDotLive' | 'healthDotFailed' | 'healthDotUnknown' | 'settingsSectionDisplay' | 'emptyHint' | 'tokenDaily' | 'tokenByModel' | 'tokenMiss' | 'tokenHit' | 'tokenOutput' | 'tokenViewStructure' | 'tokenViewModel' | 'tokenHitShort' | 'tokenMissShort' | 'tokenTotal' | 'tokenShare' | 'usageStatsTool' | 'usageStatsToolHint' | 'balanceGranted' | 'balanceTopped' | 'balanceDaily' | 'balanceDaysLong' | 'balanceDaysUnit' | 'popTodayModel' | 'popNoConsumption' | 'popTitle' | 'popBalanceUnavailable' | 'popQuotaUnavailable' | 'popSourceUnknown' | 'popPartialSource' | 'popMultipleSources' | 'popUnknownUnit' | 'popDirectLead' | 'popSubLead' | 'sourceEstimate' | 'unpricedHint' | 'channelVisibility' | 'channelVisibilityHint' | 'channelVisibilityShowAll' | 'channelVisibilityHidden' | 'channelVisibilityEmpty' | 'unpricedMore' | 'unpricedFix' | 'searchEstimateHint' | 'siteListDisplay' | 'siteListDisplayHint' | 'liveCostBar' | 'liveCostBarHint' | 'liveCostBarPosition' | 'liveCostBarPosBelow' | 'liveCostBarPosAbove' | 'liveCostBarPosToolbar' | 'exportCsvSite' | 'panelRelayQuota' | 'relayBalance' | 'relayNoQuota' | 'relayWindowUsed' | 'relayKindNewApi' | 'relayKindSub2Api' | 'relayKindUnknown' | 'expandAll' | 'collapseAll' | 'todayOnly' | 'todayNoConsumption' | 'commandUsageLabel' | 'commandUsageDescription' | 'sessionOpen' | 'sessionOpenFailed' | 'sessionOpenUnavailable' | 'tabAgents' | 'tabQueue' | 'queueSubtitle' | 'queueUntilPeak' | 'queueUntilOffPeak' | 'queueUnsupportedTitle' | 'queueUnsupportedBody' | 'queueSafety' | 'queueSafetyIsolated' | 'queueSafetyReuse' | 'queueReusePlanned' | 'queueReuseDone' | 'queueFallbackReason' | 'queueReuseModelNote' | 'queueWorkspace' | 'queueModel' | 'queueNoOptions' | 'queuePromptLabel' | 'queuePromptPlaceholder' | 'queuePrivacy' | 'queueEnqueue' | 'queueImport' | 'queueImportHint' | 'queueImported' | 'queueImportFormat' | 'queueImportTooLarge' | 'queueActive' | 'queueClearFinished' | 'queueEmpty' | 'queueLoading' | 'queueOpenSession' | 'queueRemoveQueued' | 'queueRemoveHistory' | 'queueStatusQueued' | 'queueStatusStarting' | 'queueStatusRunning' | 'queueStatusCompleted' | 'queueStatusFailed' | 'quickQueueToggle' | 'quickQueueEntry' | 'quickQueueEntryHint' | 'quickQueueReuseEntry' | 'quickQueueReuseEntryHint' | 'quickQueueEnqueue' | 'quickQueueEnqueueing' | 'quickQueueWaiting' | 'quickQueueClear' | 'quickQueueEnqueued' | 'quickQueueEmpty' | 'quickQueueBusy' | 'quickQueueAttachments' | 'quickQueueContext' | '
|
|
3
|
+
export type UsageBillingKey = keyof typeof peakZh | 'title' | 'cost' | 'todayCost' | 'monthCost' | 'yearCost' | 'monthProjected' | 'monthProjectedHint' | 'liveTurn' | 'liveSession' | 'liveSessionSub' | 'calls' | 'cacheHitRate' | 'tokens' | 'inputTokens' | 'outputTokens' | 'avgCost' | 'kpiRange' | 'avgRangeToday' | 'avgRange7d' | 'avgRangeWeek' | 'avgRangeMonth' | 'avgRangeAll' | 'avgRangeCustom' | 'customRangeStart' | 'customRangeEnd' | 'trend' | 'trend7d' | 'trend30d' | 'trendMetric' | 'trendMetricCost' | 'trendMetricTokens' | 'pricingSearch' | 'bandPinHint' | 'trendEmpty' | 'trendTotal' | 'roundsUnit' | 'healthModelsLive' | 'healthVendorsDown' | 'healthVendorsUnavailable' | 'budget' | 'budgetRemain' | 'budgetAmount' | 'budgetSummary' | 'sessions' | 'sessionTitle' | 'lastActive' | 'sessionOverflow' | 'budgetTierBody' | 'models' | 'providerBilling' | 'channelUnknown' | 'directTag' | 'relayTag' | 'unknownTag' | 'unknownChannelHint' | 'planCountUnit' | 'actual' | 'pricing' | 'input' | 'output' | 'cacheHit' | 'peak' | 'offPeak' | 'flat' | 'band' | 'close' | 'footer' | 'footerCredit' | 'lastUpdated' | 'noData' | 'todayRate' | 'rateLive' | 'rateBuiltin' | 'pricingSyncedAt' | 'pricingSyncNow' | 'pricingSyncing' | 'promoBadge' | 'promoUntil' | 'promoOpenEnded' | 'pricingTip' | 'pricingUnit' | 'pricingNotes' | 'ubPeak' | 'ubOff' | 'ubStd' | 'peakBand' | 'pricingSource' | 'noteCache' | 'noteBand' | 'noteSource' | 'balance' | 'recharge' | 'rechargeHint' | 'balanceUnconfigured' | 'balanceUnauthorized' | 'walletLogin' | 'walletPlatform' | 'walletInvalid' | 'walletNoService' | 'walletNoMetadata' | 'walletSignedOut' | 'balanceUnreachable' | 'uncatalogued' | 'estimatedPricing' | 'balanceDays' | 'balanceLowBody' | 'reconcileDrift' | 'reconcileDismiss' | 'subscriptionNotConfigured' | 'subscriptionUnauthorized' | 'subscriptionUnavailable' | 'subscriptionInvalid' | 'subscriptionRateLimited' | 'subscriptionSession' | 'subscriptionWeekly' | 'subscriptionMonthly' | 'subscriptionBilling' | 'subscriptionRemaining' | 'subscriptionExhausted' | 'subscriptionReset' | 'subscriptionNoApi' | 'floatWindow' | 'floatModeCombined' | 'floatModeSubscription' | 'floatMode' | 'floatTargets' | 'floatWindowHint' | 'floatPrimaryToday' | 'floatPrimaryWeek' | 'floatPrimaryMonth' | 'floatNoTargets' | 'floatNoTargetsHint' | 'cardDisplay' | 'cardDisplayHint' | 'displayPlacement' | 'displayPlacementFooter' | 'displayPlacementLeft' | 'displayPlacementBoth' | 'displayPlacementHint' | 'displayPlacementFallback' | 'cardMode' | 'cardModeFull' | 'cardModeFullHint' | 'cardModeCompact' | 'cardModeHidden' | 'cardModeHiddenHint' | 'cardModeFallback' | 'nativeSettingsNav' | 'nativeSettingsIntro' | 'nativeSettingsHiddenHint' | 'shortcutOpenDashboard' | 'cardMetric' | 'cardMetricMoney' | 'cardMetricTokens' | 'cardSpan' | 'cardSpanDay' | 'cardSpanWeek' | 'cardSpanMonth' | 'cardDeltaBadge' | 'cardDeltaShow' | 'cardDeltaHide' | 'triggerMonthTokens' | 'triggerTodayTokens' | 'triggerWeekTokens' | 'subscriptionsStale' | 'balanceStaleNotice' | 'staleLedgerNotice' | 'staleSnapshotNotice' | 'statsLoadFailed' | 'unreadableNotice' | 'unreadableFormatNotice' | 'unreadableNoLedgerNotice' | 'tokenCacheWrite' | 'toolRank' | 'toolName' | 'userPrices' | 'userPricesHint' | 'userPriceSave' | 'priceSaved' | 'userPriceEditIdentity' | 'pricePicker' | 'priceModelsPartial' | 'priceModelsPending' | 'priceModelDefault' | 'priceIncomplete' | 'priceUnpriced' | 'userPriceModel' | 'userPriceSource' | 'userPriceSourceHint' | 'userPriceOffPeak' | 'userPriceNormal' | 'userPriceCurrency' | 'userPriceAdd' | 'userPriceRemoveSelected' | 'userPriceSelect' | 'sessionStaleBadge' | 'sessionUntitled' | 'sessionSubCost' | 'sessionSubCalls' | 'sessionSubRow' | 'heatmapLess' | 'heatmapMore' | 'currency' | 'currencyCny' | 'currencyUsd' | 'currencyEur' | 'language' | 'heatmap' | 'rounds' | 'roundsHint' | 'anomaly' | 'model' | 'thModel' | 'thInputMiss' | 'thInputHit' | 'costAbbr' | 'tabOverview' | 'tabTrends' | 'tabProviders' | 'tabPricing' | 'tabSettings' | 'budgetHint' | 'peakAlertHint' | 'peakAlertDescPeak' | 'peakAlertDescOff' | 'peakAlertDescPeakZhipu' | 'peakAlertDescOffZhipu' | 'peakAlertQueuePeak' | 'peakAlertQueueOff' | 'export' | 'exportCsvDay' | 'exportCsvSession' | 'exportJson' | 'peakShare' | 'peakSharePerCall' | 'offPeakSavings' | 'perfMax' | 'weekCost' | 'roleCost' | 'roleUser' | 'roleAssistant' | 'roleTool' | 'roleHint' | 'tierPeak' | 'tierOff' | 'tierToPeak' | 'tierToOff' | 'tierAlertEnterPeak' | 'tierAlertEnterOff' | 'tierAlertEnterPeakZhipu' | 'tierAlertEnterOffZhipu' | 'peakAlertTitlePeak' | 'peakAlertTitleOff' | 'peakAlert' | 'peakAlertLeadMin' | 'peakAlertPos' | 'peakAlertMode' | 'peakAlertPosCorner' | 'peakAlertPosCenter' | 'peakAlertModePeak' | 'peakAlertModeOff' | 'peakAlertModeBoth' | 'peakAlertWebNotify' | 'peakAlertPreview' | 'planTypeCode' | 'planTypeToken' | 'subscriptionFeePerMonth' | 'triggerToday' | 'triggerMonth' | 'subscriptionTag' | 'cellEstimateHint' | 'free' | 'perfSamples' | 'perfTtft' | 'perfP50' | 'perfP90' | 'perfTps' | 'perfLatency' | 'perfEstimated' | 'perfEmpty' | 'perfTpsUnit' | 'perfTitle' | 'perfHint' | 'perfAll' | 'perfChartEmpty' | 'heatmapYear' | 'heatmapHalf' | 'heatmapMonth' | 'metricCost' | 'metricTokens' | 'heatmapTotal' | 'activeDays' | 'streakDays' | 'subscriptionAutoDetect' | 'pluginAuthor' | 'pluginRepository' | 'pluginNpm' | 'pluginLicense' | 'tabToken' | 'tokenExport' | 'tokenExportCsv' | 'tokenReasoningShare' | 'tokenReasoningShort' | 'tokenIo' | 'tokenPeak' | 'densityLabel' | 'densityHint' | 'densityCompact' | 'densityDefault' | 'densityComfortable' | 'motionLabel' | 'motionHint' | 'motionOff' | 'motionSubtle' | 'motionRich' | 'settingsNavDisplayPref' | 'settingsNavBudget' | 'settingsNavAlert' | 'settingsNavDisplay' | 'settingsNavAdvanced' | 'settingsNavAbout' | 'settingsSearchPlaceholder' | 'settingsSearchEmpty' | 'sessionsViewAll' | 'sessionsViewTop' | 'sessionViewerSearch' | 'modelBudgetTitle' | 'modelBudgetHint' | 'modelBudgetBody' | 'modelBudgetPlaceholder' | 'moreWorksTitle' | 'adEngramName' | 'adEngramDesc' | 'adRainbowName' | 'adRainbowDesc' | 'kpiDescCacheHit' | 'kpiDescTokens' | 'kpiDescAvgCost' | 'kpiDescCalls' | 'kpiDescReasoning' | 'kpiDescIo' | 'kpiDescPeak' | 'healthDotLive' | 'healthDotFailed' | 'healthDotUnknown' | 'settingsSectionDisplay' | 'emptyHint' | 'tokenDaily' | 'tokenByModel' | 'tokenMiss' | 'tokenHit' | 'tokenOutput' | 'tokenViewStructure' | 'tokenViewModel' | 'tokenHitShort' | 'tokenMissShort' | 'tokenTotal' | 'tokenShare' | 'usageStatsTool' | 'usageStatsToolHint' | 'balanceGranted' | 'balanceTopped' | 'balanceDaily' | 'balanceDaysLong' | 'balanceDaysUnit' | 'popTodayModel' | 'popNoConsumption' | 'popTitle' | 'popBalanceUnavailable' | 'popQuotaUnavailable' | 'popSourceUnknown' | 'popPartialSource' | 'popMultipleSources' | 'popUnknownUnit' | 'popDirectLead' | 'popSubLead' | 'sourceEstimate' | 'unpricedHint' | 'channelVisibility' | 'channelVisibilityHint' | 'channelVisibilityShowAll' | 'channelVisibilityHidden' | 'channelVisibilityEmpty' | 'unpricedMore' | 'unpricedFix' | 'searchEstimateHint' | 'siteListDisplay' | 'siteListDisplayHint' | 'liveCostBar' | 'liveCostBarHint' | 'liveCostBarPosition' | 'liveCostBarPosBelow' | 'liveCostBarPosAbove' | 'liveCostBarPosToolbar' | 'exportCsvSite' | 'panelRelayQuota' | 'relayBalance' | 'relayNoQuota' | 'relayWindowUsed' | 'relayKindNewApi' | 'relayKindSub2Api' | 'relayKindUnknown' | 'expandAll' | 'collapseAll' | 'todayOnly' | 'todayNoConsumption' | 'commandUsageLabel' | 'commandUsageDescription' | 'sessionOpen' | 'sessionOpenFailed' | 'sessionOpenUnavailable' | 'tabAgents' | 'tabQueue' | 'queueSubtitle' | 'queueUntilPeak' | 'queueUntilOffPeak' | 'queueUnsupportedTitle' | 'queueUnsupportedBody' | 'queueSafety' | 'queueSafetyIsolated' | 'queueSafetyReuse' | 'queueReusePlanned' | 'queueReuseDone' | 'queueFallbackReason' | 'queueReuseModelNote' | 'queueWorkspace' | 'queueModel' | 'queueNoOptions' | 'queueNoWorkspace' | 'queueNoOfficialRoute' | 'queueNoOfficialModel' | 'queuePromptLabel' | 'queuePromptPlaceholder' | 'queuePrivacy' | 'queueEnqueue' | 'queueImport' | 'queueImportHint' | 'queueImported' | 'queueImportFormat' | 'queueImportTooLarge' | 'queueActive' | 'queueClearFinished' | 'queueEmpty' | 'queueLoading' | 'queueOpenSession' | 'queueRemoveQueued' | 'queueRemoveHistory' | 'queueStatusQueued' | 'queueStatusStarting' | 'queueStatusRunning' | 'queueStatusCompleted' | 'queueStatusFailed' | 'quickQueueToggle' | 'quickQueueEntry' | 'quickQueueEntryHint' | 'quickQueueReuseEntry' | 'quickQueueReuseEntryHint' | 'quickQueueEnqueue' | 'quickQueueEnqueueing' | 'quickQueueWaiting' | 'quickQueueClear' | 'quickQueueEnqueued' | 'quickQueueEmpty' | 'quickQueueBusy' | 'quickQueueAttachments' | 'quickQueueContext' | 'quickQueueModelNotEligible' | 'quickQueueWorkspaceUnknown' | 'quickQueueDraftChanged' | 'quickQueueUnsupported' | 'quickQueueFailed' | 'agentsSummary' | 'agentsCount' | 'agentsDelegations' | 'agentsRoots' | 'agentsMostExpensive' | 'agentsChainTotal' | 'agentsNoData' | 'agentsSubagent' | 'agentsRoot';
|
|
4
4
|
export declare const NS = "usageBilling";
|
|
5
5
|
export declare const zh: Record<UsageBillingKey, string>;
|
|
6
6
|
export declare const en: Record<UsageBillingKey, string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** 左侧主面板双槽位(main + sidebar.panellist)的运行时能力(issue #144)。 */
|
|
2
|
+
export interface BillingPanelCapability {
|
|
3
|
+
/** 两个宿主槽位是否同时可用。 */
|
|
4
|
+
available: () => boolean;
|
|
5
|
+
/** 订阅能力变化;组件挂载时另读 available() 取初值。 */
|
|
6
|
+
subscribe: (listener: () => void) => () => void;
|
|
7
|
+
setMain: (present: boolean) => void;
|
|
8
|
+
setNavigation: (present: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
/** 只有双槽位同时存在才允许隐藏底部入口,避免单侧能力造成不可恢复的空白。 */
|
|
11
|
+
export declare function createBillingPanelCapability(): BillingPanelCapability;
|
|
12
|
+
//# sourceMappingURL=panel-capability.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 队列候选为空时的原因分层(issue #143)。
|
|
3
|
+
*
|
|
4
|
+
* 面板(队列 Tab)与会话入队入口共用这一份判定与文案来源:只说「模型不
|
|
5
|
+
* 支持」用户无从下手,必须分清「宿主没有官方通道」与「官方通道里没有可用
|
|
6
|
+
* 模型」——两者的下一步动作完全不同(配 API Key 通道 vs 看模型清单)。
|
|
7
|
+
*/
|
|
8
|
+
import type { TaskQueueBlockedReason } from '../task-queue-shared.ts';
|
|
9
|
+
import type { UsageBillingKey } from './locales.ts';
|
|
10
|
+
/** 判定所需的最小事实面(面板快照与会话入队读到的都是它的子集)。 */
|
|
11
|
+
export interface QueueEligibilityFacts {
|
|
12
|
+
/** 宿主登记的工作区。 */
|
|
13
|
+
readonly workspaces: readonly {
|
|
14
|
+
readonly path: string;
|
|
15
|
+
}[];
|
|
16
|
+
/** 官方峰谷候选模型。 */
|
|
17
|
+
readonly models: readonly {
|
|
18
|
+
readonly provider: string;
|
|
19
|
+
readonly id: string;
|
|
20
|
+
}[];
|
|
21
|
+
/** 服务端给出的根因(models 为空时才有值)。 */
|
|
22
|
+
readonly blockedReason?: TaskQueueBlockedReason | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 候选/工作区缺失时的提示键;一切就绪时返回 undefined。
|
|
26
|
+
* @param facts - 快照里的工作区、候选与根因。
|
|
27
|
+
* @returns 对应的文案键,或 undefined(无需提示)。
|
|
28
|
+
*/
|
|
29
|
+
export declare function queueBlockedKey(facts: QueueEligibilityFacts): UsageBillingKey | undefined;
|
|
30
|
+
//# sourceMappingURL=queue-eligibility.d.ts.map
|
|
@@ -11,7 +11,7 @@ import type { InputActions, InputState } from '@deepseek-ai/dsh-client-ui-conver
|
|
|
11
11
|
import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store';
|
|
12
12
|
import type { SessionProjectionMap } from '@deepseek-ai/dsh-api-session-controller/client';
|
|
13
13
|
import type { UsageBillingKey } from './locales.ts';
|
|
14
|
-
type Translate = (key: UsageBillingKey) => string;
|
|
14
|
+
type Translate = (key: UsageBillingKey, params?: Record<string, unknown>) => string;
|
|
15
15
|
type ProjectionKey = Extract<keyof SessionProjectionMap, string>;
|
|
16
16
|
/** Optional selector shape: old hosts may omit the standard input kit. */
|
|
17
17
|
type ReadInput = <S>(selector: (state: InputState) => S, eq?: (a: S, b: S) => boolean) => S | undefined;
|
|
@@ -41,6 +41,20 @@ export declare const FLOAT_WINDOW_STORAGE_KEY = "dsh.ui-usage-billing.float";
|
|
|
41
41
|
export declare function loadFloatWindowPrefs(): FloatWindowPrefs;
|
|
42
42
|
/** 写入浮窗偏好。失败静默(展示偏好非关键)。 */
|
|
43
43
|
export declare function saveFloatWindowPrefs(prefs: FloatWindowPrefs): void;
|
|
44
|
+
/** 仪表盘入口的挂载位置:底部触发器 / 左侧主面板 / 两者同时显示(issue #144)。 */
|
|
45
|
+
export type BillingDisplayPlacement = 'footer' | 'left' | 'both';
|
|
46
|
+
/** 默认保持既有底部入口,升级后不改变用户界面。 */
|
|
47
|
+
export declare const DEFAULT_BILLING_DISPLAY_PLACEMENT: BillingDisplayPlacement;
|
|
48
|
+
export declare const BILLING_DISPLAY_PLACEMENT_STORAGE_KEY = "dsh.ui-usage-billing.display-placement";
|
|
49
|
+
export declare const BILLING_DISPLAY_PLACEMENT_EVENT = "dsh.ui-usage-billing.display-placement-changed";
|
|
50
|
+
/** 读取展示位置;缺失与非法值一律回退底部。 */
|
|
51
|
+
export declare function loadBillingDisplayPlacement(): BillingDisplayPlacement;
|
|
52
|
+
/** 写入并广播展示位置,apply 的槽位注册与各 React 树共用同一份偏好。 */
|
|
53
|
+
export declare function saveBillingDisplayPlacement(placement: BillingDisplayPlacement): void;
|
|
54
|
+
/** 同文档跨 React 树 + 跨标签页同步。 */
|
|
55
|
+
export declare function subscribeBillingDisplayPlacement(listener: () => void): () => void;
|
|
56
|
+
/** 宿主没有左侧双槽位时不得把唯一入口藏掉;设置里另行显示降级原因。 */
|
|
57
|
+
export declare function resolveBillingDisplayPlacement(placement: BillingDisplayPlacement, leftPanelAvailable: boolean): BillingDisplayPlacement;
|
|
44
58
|
/** 左下角计费卡的主指标视角。 */
|
|
45
59
|
export type BillingCardMetric = 'money' | 'tokens';
|
|
46
60
|
/** 计费卡主数字的统计范围(单值卡面,issue #47 反馈)。 */
|
package/lib/types/guard.d.ts
CHANGED
|
@@ -34,10 +34,20 @@ export declare function normalizeTrustedHosts(hosts: readonly string[] | undefin
|
|
|
34
34
|
* 拒绝 `127.0.0.1.attacker.com` 这类以 `127.` 开头但解析到外部的 DNS rebinding 域名:
|
|
35
35
|
* 只用 `startsWith('127.')` 会被它穿透,必须精确匹配回环 IP 的字面量。 */
|
|
36
36
|
export declare function isLoopbackHost(req: IncomingMessage, trustedHosts?: ReadonlySet<string>): boolean;
|
|
37
|
-
/** 校验 Origin
|
|
37
|
+
/** 校验 Origin 头是否可信(写操作用,防止跨站表单/fetch 改写设置)。Origin 缺失
|
|
38
38
|
* (curl 或同源 fetch 不带)视为放行,交给下方的 Content-Type 校验兜底;Origin 存在
|
|
39
|
-
*
|
|
40
|
-
|
|
39
|
+
* 但主机既非回环、也不在 trustedHosts 里则拒绝——跨站脚本发起的写请求必带攻击者
|
|
40
|
+
* 域名的 Origin。
|
|
41
|
+
*
|
|
42
|
+
* 反向代理场景:浏览器把页面自身的地址写进 Origin(`https://dash.example.com`)。
|
|
43
|
+
* Host 头因为同一域名被 trustedHosts 放行,Origin 却是同一个非回环域名——只认回环
|
|
44
|
+
* 字面量会让「已显式信任的主机」在写操作上必然 403(读操作正常),表现为面板能
|
|
45
|
+
* 打开、点任何保存/入队都报 `forbidden: loopback only`。因此 Origin 与 Host 共用
|
|
46
|
+
* 同一份 trustedHosts:用户显式信任某个主机,就等于接受该主机的同源写请求。
|
|
47
|
+
* @param origin - 原始 Origin 头(可能缺失)。
|
|
48
|
+
* @param trustedHosts - 已归一化的可信主机名集合,与 {@link isLoopbackHost} 同口径。
|
|
49
|
+
*/
|
|
50
|
+
export declare function isLoopbackOrigin(origin: string | undefined, trustedHosts?: ReadonlySet<string>): boolean;
|
|
41
51
|
/**
|
|
42
52
|
* 路由准入声明(宿主 0.2.3-alpha.1 起必需)。
|
|
43
53
|
*
|
|
@@ -70,6 +70,20 @@ export declare const BALANCE_CLIENT_HEADERS: {
|
|
|
70
70
|
readonly locale: "x-dsh-billing-client-locale";
|
|
71
71
|
readonly timezone: "x-dsh-billing-client-timezone-offset";
|
|
72
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* 宿主内置的两条 DeepSeek 通道的路由 id(宿主包 `llm-deepseek-api-key` /
|
|
75
|
+
* `llm-deepseek-account` 注册,`0.1.2-alpha.1` ~ `0.2.3-alpha.3` 全程稳定):
|
|
76
|
+
*
|
|
77
|
+
* - `deepseek-official`:平台 API key 通道,花的是用户自己的 DeepSeek 平台
|
|
78
|
+
* 账户余额(凭据 ref 默认 `DEEPSEEK_API_KEY`);
|
|
79
|
+
* - `deepseek-account`:登录账号通道,花的是宿主登录钱包的余额。
|
|
80
|
+
*
|
|
81
|
+
* 两条通道都**不在 llm-pi-ai 路由表里**(插件自造的 `deepseek` 路由 id 与它们
|
|
82
|
+
* 不同)。钱包归属必须按宿主通道 id 认,否则内置通道的用量桶认不到任何钱包
|
|
83
|
+
* (issue #141:悬浮卡显示「余额不可确认」)。
|
|
84
|
+
*/
|
|
85
|
+
export declare const DEEPSEEK_PLATFORM_ROUTE = "deepseek-official";
|
|
86
|
+
export declare const DEEPSEEK_LOGIN_ROUTE = "deepseek-account";
|
|
73
87
|
/** Wire format shared by the aggregation buckets and their consumers. */
|
|
74
88
|
export type SiteKind = 'site' | 'direct' | 'unknown';
|
|
75
89
|
export interface SiteRef {
|
|
@@ -45,6 +45,16 @@ export interface TaskQueueModelSelection {
|
|
|
45
45
|
readonly provider: string;
|
|
46
46
|
readonly model: string;
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* 候选为空时的根因分层(issue #143):只说「模型不支持」用户无从下手,必须
|
|
50
|
+
* 分清「宿主没有官方通道」与「官方通道里没有可用模型」——两者的下一步动作
|
|
51
|
+
* 完全不同(配 API Key 通道 vs 看模型清单)。
|
|
52
|
+
*/
|
|
53
|
+
export type TaskQueueBlockedReason =
|
|
54
|
+
/** 宿主没有内置的 DeepSeek 官方按量通道(路由 id `deepseek-official`)。 */
|
|
55
|
+
'no-official-route'
|
|
56
|
+
/** 官方通道在,但其中没有任何带官方峰谷价的模型。 */
|
|
57
|
+
| 'no-official-model';
|
|
48
58
|
export interface TaskQueueSnapshot {
|
|
49
59
|
/** All required host Session-control methods are available. */
|
|
50
60
|
readonly supported: boolean;
|
|
@@ -55,6 +65,8 @@ export interface TaskQueueSnapshot {
|
|
|
55
65
|
readonly models: readonly TaskQueueModel[];
|
|
56
66
|
/** Host default route for an unconfigured Session; eligibility is checked separately. */
|
|
57
67
|
readonly defaultModel?: TaskQueueModelSelection | undefined;
|
|
68
|
+
/** 候选为空的根因(models 为空时才有值)。 */
|
|
69
|
+
readonly blockedReason?: TaskQueueBlockedReason | undefined;
|
|
58
70
|
readonly optionsError?: string;
|
|
59
71
|
}
|
|
60
72
|
/** Lightweight alert polling shape: never transports Prompt or Session content. */
|
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.8.
|
|
4
|
+
"version": "1.8.14",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
|
7
7
|
"deepseek",
|
|
@@ -122,6 +122,7 @@
|
|
|
122
122
|
"@deepseek-ai/dsh-client-store": "*",
|
|
123
123
|
"@deepseek-ai/dsh-client-ui-commands": "*",
|
|
124
124
|
"@deepseek-ai/dsh-client-ui-conversation": "*",
|
|
125
|
+
"@deepseek-ai/dsh-client-ui-layout": "*",
|
|
125
126
|
"@deepseek-ai/dsh-client-ui-primitives": "*",
|
|
126
127
|
"@deepseek-ai/dsh-client-ui-settings": "*",
|
|
127
128
|
"@deepseek-ai/dsh-client-ui-sidebar": "*",
|
|
@@ -163,6 +164,7 @@
|
|
|
163
164
|
"@deepseek-ai/dsh-client-store": "0.2.3-alpha.3",
|
|
164
165
|
"@deepseek-ai/dsh-client-ui-commands": "0.2.3-alpha.3",
|
|
165
166
|
"@deepseek-ai/dsh-client-ui-conversation": "0.2.3-alpha.3",
|
|
167
|
+
"@deepseek-ai/dsh-client-ui-layout": "0.2.3-alpha.3",
|
|
166
168
|
"@deepseek-ai/dsh-client-ui-primitives": "0.2.3-alpha.3",
|
|
167
169
|
"@deepseek-ai/dsh-client-ui-renderer": "0.2.3-alpha.3",
|
|
168
170
|
"@deepseek-ai/dsh-client-ui-settings": "0.2.3-alpha.3",
|