@kenz1117/dsh-ui-usage-billing 1.0.10 → 1.0.12
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 +1 -1
- package/lib/client.js +3 -3
- package/lib/types/aggregate.d.ts +3 -1
- package/lib/types/client/apply.d.ts +2 -2
- package/lib/types/client/budget-store.d.ts +1 -1
- package/lib/types/client/completion-notify.d.ts +2 -2
- package/lib/types/client/live-cost.d.ts +9 -9
- package/lib/types/client/vendor-logos.d.ts +7 -4
- package/package.json +5 -2
package/lib/types/aggregate.d.ts
CHANGED
|
@@ -220,6 +220,8 @@ export interface UsageStatsDocument {
|
|
|
220
220
|
* 以 step/start 为起点估算并计 estimated。
|
|
221
221
|
*/
|
|
222
222
|
perf?: PerfStats;
|
|
223
|
+
/** 只存在于账本、且缺 foldVersion 的旧会话数;无旧行时省略。 */
|
|
224
|
+
staleLedgerSessions?: number;
|
|
223
225
|
}
|
|
224
226
|
/** 按角色费用归因:user / tool 为输入成本的启发式摊分,assistant 为输出成本实测。 */
|
|
225
227
|
export interface RoleCost {
|
|
@@ -472,7 +474,7 @@ export declare function messageTextLength(message: unknown): number;
|
|
|
472
474
|
export declare function foldSession(events: readonly {
|
|
473
475
|
type: string;
|
|
474
476
|
time: number;
|
|
475
|
-
data:
|
|
477
|
+
data: unknown;
|
|
476
478
|
seq?: number;
|
|
477
479
|
}[], subscriptionProviders: ReadonlySet<string>, officialProviderIds?: ReadonlySet<string>, routes?: Readonly<Record<string, ProviderRouteView>>, searchCallEstimateCny?: number): SessionFold;
|
|
478
480
|
/**
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*(billing.dashboard.decor)并注册计费指标服务(ctx.billingMetrics),主题
|
|
11
11
|
* 插件主动注入装饰视觉、消费费用数据——billing 不反向依赖任何主题包。
|
|
12
12
|
*/
|
|
13
|
-
import type {
|
|
13
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
14
14
|
import { type UsageBillingKey } from './locales.ts';
|
|
15
15
|
import { type BillingMetricsService } from './billing-service.ts';
|
|
16
16
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
@@ -51,5 +51,5 @@ export declare const inject: string[];
|
|
|
51
51
|
* Client plugin body: the UsageBilling entry in the sidebar footer.
|
|
52
52
|
* @param ctx - client root context.
|
|
53
53
|
*/
|
|
54
|
-
export declare function apply(ctx:
|
|
54
|
+
export declare function apply(ctx: Context): void;
|
|
55
55
|
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* store 引擎持久化到 localStorage(persist key 即存储身份),重启后保留。
|
|
6
6
|
* 宿主 Config 的 monthlyBudget 仅作为金额未设置时的默认值,用户输入优先。
|
|
7
7
|
*/
|
|
8
|
-
import { type EngineStoreHandle } from '@deepseek-ai/dsh-client-
|
|
8
|
+
import { type EngineStoreHandle } from '@deepseek-ai/dsh-client-store';
|
|
9
9
|
/** 预算偏好状态。 */
|
|
10
10
|
export interface BudgetPrefsState {
|
|
11
11
|
/** 预算条开关:关 = 只显示标题行与开关,不显示进度。 */
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* 可选:跨 tab 只保留一个提醒 leader(Web Locks 优先,降级 localStorage 租约),
|
|
6
6
|
* 避免多窗口同时弹同一条。配置持久化在 localStorage(默认关闭,用户在面板设置开启)。
|
|
7
7
|
*/
|
|
8
|
-
import type { SessionListState } from '@deepseek-ai/dsh-
|
|
9
|
-
import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-
|
|
8
|
+
import type { SessionListState } from '@deepseek-ai/dsh-api-session-controller/client';
|
|
9
|
+
import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store';
|
|
10
10
|
/** 配置持久化 key:开启/关闭 + 提醒持续模式(0=常驻,其余=秒后自动关)。 */
|
|
11
11
|
export declare const COMPLETION_NOTIFY_KEY = "dsh-billing-completion-notify-v1";
|
|
12
12
|
export interface CompletionNotifyConfig {
|
|
@@ -6,17 +6,16 @@
|
|
|
6
6
|
* composer card, same posture as ui-conversation's own StatsLine), so it stays
|
|
7
7
|
* visible while working without opening the full dashboard. Data comes from the
|
|
8
8
|
* same `/api/billing/usage-stats` endpoint the dashboard polls; the bar reads
|
|
9
|
-
* the current session id
|
|
10
|
-
* `
|
|
11
|
-
*
|
|
9
|
+
* the current session id from the session-scope standard kit and matches
|
|
10
|
+
* `bySession` (session total) and `byTurn` (latest turn cost). Rendering is a
|
|
11
|
+
* pure function of props and polled data, never a side effect.
|
|
12
12
|
*
|
|
13
13
|
* The bar also carries two ambient signals: the current peak/off-peak pricing
|
|
14
14
|
* tier with a switch countdown (DeepSeek time-of-day pricing), and quota chips
|
|
15
15
|
* for subscription plans running low (≤20% remaining), so cost pressure is
|
|
16
16
|
* visible without opening the dashboard.
|
|
17
17
|
*/
|
|
18
|
-
import type {
|
|
19
|
-
import type { ConversationSnapshot } from '@deepseek-ai/dsh-client-runtime/client';
|
|
18
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
20
19
|
import type { UsageBillingKey } from './locales.ts';
|
|
21
20
|
/** The usage-stats shape the composer bar needs (a thin slice, not the whole doc). */
|
|
22
21
|
export interface LiveStats {
|
|
@@ -67,15 +66,16 @@ export declare function lowQuotaChips(quotas: readonly QuotaSlice[], threshold?:
|
|
|
67
66
|
kind: string;
|
|
68
67
|
pct: number;
|
|
69
68
|
}[];
|
|
70
|
-
/** Props: the session
|
|
69
|
+
/** Props: the framework's session identity plus the owning dock's locale seat. */
|
|
71
70
|
export interface LiveCostBarProps {
|
|
72
|
-
|
|
71
|
+
/** Current Session identity supplied by the session-scope standard kit. */
|
|
72
|
+
sessionId: SessionId;
|
|
73
73
|
/** The owning dock's locale seat (bound to the billing NS). */
|
|
74
74
|
t: (key: UsageBillingKey) => string;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Render the live cost ticker for the current session.
|
|
78
|
-
* @param props - framework session
|
|
78
|
+
* @param props - framework session identity and locale.
|
|
79
79
|
*/
|
|
80
|
-
export declare function LiveCostBar({
|
|
80
|
+
export declare function LiveCostBar({ sessionId, t }: LiveCostBarProps): React.ReactNode;
|
|
81
81
|
//# sourceMappingURL=live-cost.d.ts.map
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Vendor logos: inlined data URIs fetched from models.dev /logos/{id}.svg.
|
|
3
|
+
* Kept to the highest-traffic providers only to hold the client bundle under the
|
|
4
|
+
* DSH Store 256 KiB single-file cap. Every other provider falls back to a
|
|
5
|
+
* brand-color letter badge in the UI (see VendorLogo in UsageBilling.tsx), so no
|
|
6
|
+
* external asset or copyright risk is introduced for unlisted vendors. 月之暗面 is
|
|
7
|
+
* a hand-redrawn minimal crescent — its official SVG is a multi-thousand-node path
|
|
8
|
+
* that alone cost ~6.8 KiB.
|
|
6
9
|
*/
|
|
7
10
|
export declare const VENDOR_LOGOS: Readonly<Record<string, string>>;
|
|
8
11
|
export declare function vendorLogoOf(provider: string): string | undefined;
|
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.0.
|
|
4
|
+
"version": "1.0.12",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -83,11 +83,14 @@
|
|
|
83
83
|
"clsx": "^2.1.1"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
+
"@deepseek-ai/dsh-api-remotes": "*",
|
|
87
|
+
"@deepseek-ai/dsh-api-session-controller": "*",
|
|
86
88
|
"@deepseek-ai/dsh-client-locale": "*",
|
|
87
|
-
"@deepseek-ai/dsh-client-
|
|
89
|
+
"@deepseek-ai/dsh-client-store": "*",
|
|
88
90
|
"@deepseek-ai/dsh-client-test-runtime": "*",
|
|
89
91
|
"@deepseek-ai/dsh-client-ui-conversation": "*",
|
|
90
92
|
"@deepseek-ai/dsh-client-ui-primitives": "*",
|
|
93
|
+
"@deepseek-ai/dsh-client-ui-renderer": "*",
|
|
91
94
|
"@deepseek-ai/dsh-client-ui-slots": "*",
|
|
92
95
|
"@deepseek-ai/dsh-invariants": "*",
|
|
93
96
|
"@testing-library/react": "^16.1.0",
|