@rayadesu/dsh-client-ui-billing 0.1.0-rc.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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +30 -0
- package/README.zh.md +30 -0
- package/lib/client.js +4466 -0
- package/lib/index.js +11 -0
- package/lib/invariant.js +25 -0
- package/lib/types/client/BalanceBadge.d.ts +33 -0
- package/lib/types/client/index.d.ts +20 -0
- package/lib/types/client/locales.d.ts +26 -0
- package/lib/types/index.d.ts +9 -0
- package/lib/types/invariant.d.ts +16 -0
- package/package.json +76 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region lib/types/index.js
|
|
2
|
+
/**
|
|
3
|
+
* Account-balance badge plugin, node half. Pure UI plugin: the empty apply
|
|
4
|
+
* exists so the plugin appears in the host cordis.yml / Loader; the browser
|
|
5
|
+
* half ships via exports["./client"], discovered through the package.json
|
|
6
|
+
* dshClient declaration.
|
|
7
|
+
*/
|
|
8
|
+
/** Host plugin body — no host-side behavior for this source plugin. */
|
|
9
|
+
function apply() {}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { apply };
|
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
/**
|
|
3
|
+
* Package-owned invariant companion for `@rayadesu/dsh-client-ui-billing`.
|
|
4
|
+
* @module @rayadesu/dsh-client-ui-billing/invariant
|
|
5
|
+
*/
|
|
6
|
+
const PACKAGE_NAME = "@rayadesu/dsh-client-ui-billing";
|
|
7
|
+
/** Cordis companion plugin name. */
|
|
8
|
+
const name = "client-ui-billing-invariant";
|
|
9
|
+
/** Service required before the companion can reserve package ownership. */
|
|
10
|
+
const inject = ["invariants"];
|
|
11
|
+
/**
|
|
12
|
+
* No runtime invariant: this package is a read-only projection of one Remote
|
|
13
|
+
* snapshot onto one header slot entry. It emits no cordis events, owns no
|
|
14
|
+
* cross-plugin mutable state, and its single slot registration proves disposal
|
|
15
|
+
* through the HMR-safety spec.
|
|
16
|
+
*/
|
|
17
|
+
const install = () => {};
|
|
18
|
+
/**
|
|
19
|
+
* Register this package's invariant companion.
|
|
20
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
21
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
22
|
+
*/
|
|
23
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
24
|
+
//#endregion
|
|
25
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Session-header billing badge: balance plus the current conversation's billed spend. */
|
|
2
|
+
import type { DeepSeekBalance, DeepSeekSessionSpend, DeepSeekTodaySpend } from '@rayadesu/dsh-llm-billing/types';
|
|
3
|
+
import type { SessionId } from '@deepseek-ai/dsh-client-runtime/client';
|
|
4
|
+
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
5
|
+
import { NS } from './locales.ts';
|
|
6
|
+
/** Registration-side Remote face used by the header badge. */
|
|
7
|
+
export interface BalanceBadgeInjected {
|
|
8
|
+
/** Read the account balance; rejects with the Remote error message. */
|
|
9
|
+
getBalance: () => Promise<DeepSeekBalance>;
|
|
10
|
+
/** Read one session's billed spend; rejects with the Remote error message. */
|
|
11
|
+
getSessionSpend: (sessionId: SessionId) => Promise<DeepSeekSessionSpend>;
|
|
12
|
+
/** Read today's billed spend across every session; rejects with the Remote error message. */
|
|
13
|
+
getTodaySpend: () => Promise<DeepSeekTodaySpend>;
|
|
14
|
+
}
|
|
15
|
+
/** Full props assembled by the header utilities slot renderer. */
|
|
16
|
+
export type BalanceBadgeProps = PropsRuntime<'conversation.session.header.utilities'> & InjectFace<BalanceBadgeInjected> & PropsLocale<typeof NS>;
|
|
17
|
+
/**
|
|
18
|
+
* Render the billing badge in the session-header utilities row. The trigger
|
|
19
|
+
* shows the remaining balance and this conversation's billed spend and opens
|
|
20
|
+
* a label box with the amount, this session's spend with its cache-hit /
|
|
21
|
+
* cache-miss-input / output cost breakdown per model, today's spend across
|
|
22
|
+
* every session, a refresh action, and a spend disclaimer. Refreshing keeps
|
|
23
|
+
* the last values visible rather than blanking them.
|
|
24
|
+
*
|
|
25
|
+
* The spend follows the conversation: a new message in the current session
|
|
26
|
+
* recomputes only the (local, network-free) session spend and today's spend
|
|
27
|
+
* through `getSessionSpend` / `getTodaySpend`; the balance stays a
|
|
28
|
+
* manual-refresh snapshot and is never refetched on its own.
|
|
29
|
+
* @param props - Remote face, locale, and the standard session-header runtime share.
|
|
30
|
+
* @returns the badge, or null until the first balance fetch settles.
|
|
31
|
+
*/
|
|
32
|
+
export declare function BalanceBadge({ getBalance, getSessionSpend, getTodaySpend, sessionId, useSession, t }: BalanceBadgeProps): import("react").JSX.Element | null;
|
|
33
|
+
//# sourceMappingURL=BalanceBadge.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** DeepSeek account-balance badge, browser half: one session-header utility entry. */
|
|
2
|
+
import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
|
|
3
|
+
import { type BillingKey } from './locales.ts';
|
|
4
|
+
export type { BalanceBadgeInjected, BalanceBadgeProps } from './BalanceBadge.tsx';
|
|
5
|
+
export type { BillingKey } from './locales.ts';
|
|
6
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
7
|
+
interface LocaleNamespaceMap {
|
|
8
|
+
/** DeepSeek account-balance copy. */
|
|
9
|
+
'billing': BillingKey;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Services required for locale registration, the Remote face, and the header slot. */
|
|
13
|
+
export declare const inject: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Client plugin body: mount the `billing` Remote, register the dictionaries,
|
|
16
|
+
* and contribute the header utility badge.
|
|
17
|
+
* @param ctx - client root context.
|
|
18
|
+
*/
|
|
19
|
+
export declare function apply(ctx: ClientContext): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** `billing` namespace dictionaries. */
|
|
2
|
+
/** Dictionary namespace owned by this plugin. */
|
|
3
|
+
export declare const NS = "billing";
|
|
4
|
+
/** Simplified Chinese dictionary (the key-set source of truth). */
|
|
5
|
+
export declare const zh: {
|
|
6
|
+
readonly 'trigger.balance': "剩余额度:{amount}";
|
|
7
|
+
readonly 'trigger.conversationSpend': "本轮对话花费:{amount}";
|
|
8
|
+
readonly 'label.amount': "API 剩余金额:{amount}";
|
|
9
|
+
readonly 'label.sessionSpend': "本会话花费:{amount}";
|
|
10
|
+
readonly 'label.todaySpend': "今日共花费:{amount}";
|
|
11
|
+
readonly 'label.cost.hit': "缓存命中 {amount}";
|
|
12
|
+
readonly 'label.cost.input': "未命中输入 {amount}";
|
|
13
|
+
readonly 'label.cost.output': "输出 {amount}";
|
|
14
|
+
readonly 'stat.none': "暂无消耗记录";
|
|
15
|
+
readonly 'state.unavailable': "额度不可用";
|
|
16
|
+
readonly 'action.refresh': "刷新";
|
|
17
|
+
readonly 'info.aria': "花费说明";
|
|
18
|
+
readonly 'info.hint': "仅能预估 DeepSeek 相关模型。本会话花费按每条消息的发生时刻(北京时间)所在峰谷时段单价计费:缓存命中输入、未命中输入(含缓存写入)、输出(含推理)分别计价。费用按 8 月 17 日实行的标准。";
|
|
19
|
+
readonly 'badge.aria': "DeepSeek 额度:{amount}";
|
|
20
|
+
readonly 'panel.aria': "DeepSeek 额度详情";
|
|
21
|
+
};
|
|
22
|
+
/** English dictionary, key-identical to the Chinese source of truth. */
|
|
23
|
+
export declare const en: Record<BillingKey, string>;
|
|
24
|
+
/** Key domain of the `billing` namespace (zh is the source of truth). */
|
|
25
|
+
export type BillingKey = keyof typeof zh;
|
|
26
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account-balance badge plugin, node half. Pure UI plugin: the empty apply
|
|
3
|
+
* exists so the plugin appears in the host cordis.yml / Loader; the browser
|
|
4
|
+
* half ships via exports["./client"], discovered through the package.json
|
|
5
|
+
* dshClient declaration.
|
|
6
|
+
*/
|
|
7
|
+
/** Host plugin body — no host-side behavior for this source plugin. */
|
|
8
|
+
export declare function apply(): void;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `@rayadesu/dsh-client-ui-billing`.
|
|
3
|
+
* @module @rayadesu/dsh-client-ui-billing/invariant
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
/** Cordis companion plugin name. */
|
|
7
|
+
export declare const name = "client-ui-billing-invariant";
|
|
8
|
+
/** Service required before the companion can reserve package ownership. */
|
|
9
|
+
export declare const inject: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Register this package's invariant companion.
|
|
12
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
+
*/
|
|
15
|
+
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
+
//# sourceMappingURL=invariant.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rayadesu/dsh-client-ui-billing",
|
|
3
|
+
"description": "Session-header DeepSeek account-balance and conversation-spend badge over the billing Remote",
|
|
4
|
+
"version": "0.1.0-rc.10",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./invariant": {
|
|
14
|
+
"types": "./lib/types/invariant.d.ts",
|
|
15
|
+
"default": "./lib/invariant.js"
|
|
16
|
+
},
|
|
17
|
+
"./client": {
|
|
18
|
+
"types": "./lib/types/client/index.d.ts",
|
|
19
|
+
"default": "./lib/client.js"
|
|
20
|
+
},
|
|
21
|
+
"./src/*": "./src/*",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"dsh": {
|
|
25
|
+
"client": {
|
|
26
|
+
"inject": [
|
|
27
|
+
"@deepseek-ai/dsh-client-locale",
|
|
28
|
+
"@deepseek-ai/dsh-client-runtime",
|
|
29
|
+
"@deepseek-ai/dsh-client-ui-conversation"
|
|
30
|
+
],
|
|
31
|
+
"platform": "web"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/rayadesune/DeepSeek-Harness-chat-billing.git",
|
|
38
|
+
"directory": "packages/ui-billing"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@rayadesu/dsh-llm-billing": "^0.1.0-rc.8",
|
|
45
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.0-rc.8",
|
|
46
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.8",
|
|
47
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.0-rc.8",
|
|
48
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.8",
|
|
49
|
+
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.8",
|
|
50
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@rayadesu/dsh-llm-billing": "^0.1.0-rc.8",
|
|
54
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.0-rc.8",
|
|
55
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.8",
|
|
56
|
+
"@deepseek-ai/dsh-client-test-runtime": "^0.1.0-rc.8",
|
|
57
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.0-rc.8",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.8",
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.8",
|
|
60
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.8",
|
|
61
|
+
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.8",
|
|
62
|
+
"@types/react": "~18.3.1",
|
|
63
|
+
"react": "^18.2.0",
|
|
64
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
65
|
+
},
|
|
66
|
+
"files": [
|
|
67
|
+
"lib/index.js",
|
|
68
|
+
"lib/invariant.js",
|
|
69
|
+
"lib/client.js",
|
|
70
|
+
"lib/types/**/*.d.ts"
|
|
71
|
+
],
|
|
72
|
+
"scripts": {
|
|
73
|
+
"bundle": "tsdown",
|
|
74
|
+
"watch": "tsdown --watch"
|
|
75
|
+
}
|
|
76
|
+
}
|