dsh-ds-balance 1.0.0
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.md +81 -0
- package/README_en.md +81 -0
- package/cordis.patch.yml +9 -0
- package/lib/adapters/console-logger.d.ts +25 -0
- package/lib/adapters/console-logger.js +35 -0
- package/lib/adapters/domain-core-store.d.ts +104 -0
- package/lib/adapters/domain-core-store.js +184 -0
- package/lib/adapters/http-deepseek-client.d.ts +36 -0
- package/lib/adapters/http-deepseek-client.js +101 -0
- package/lib/adapters/memory-metrics.d.ts +30 -0
- package/lib/adapters/memory-metrics.js +67 -0
- package/lib/adapters/salt-file.d.ts +32 -0
- package/lib/adapters/salt-file.js +40 -0
- package/lib/client.js +2120 -0
- package/lib/config.d.ts +127 -0
- package/lib/config.js +112 -0
- package/lib/domain/balance.d.ts +70 -0
- package/lib/domain/balance.js +8 -0
- package/lib/domain/errors.d.ts +84 -0
- package/lib/domain/errors.js +136 -0
- package/lib/domain/money.d.ts +39 -0
- package/lib/domain/money.js +74 -0
- package/lib/domain/normalize.d.ts +38 -0
- package/lib/domain/normalize.js +120 -0
- package/lib/domain/select.d.ts +26 -0
- package/lib/domain/select.js +51 -0
- package/lib/domain/severity.d.ts +34 -0
- package/lib/domain/severity.js +44 -0
- package/lib/http/handlers.d.ts +47 -0
- package/lib/http/handlers.js +261 -0
- package/lib/http/routes.d.ts +63 -0
- package/lib/http/routes.js +61 -0
- package/lib/http/wire.d.ts +82 -0
- package/lib/http/wire.js +68 -0
- package/lib/index.d.ts +36 -0
- package/lib/index.js +210 -0
- package/lib/ports/clock.d.ts +12 -0
- package/lib/ports/clock.js +6 -0
- package/lib/ports/core-store.d.ts +28 -0
- package/lib/ports/core-store.js +6 -0
- package/lib/ports/credentials.d.ts +30 -0
- package/lib/ports/credentials.js +9 -0
- package/lib/ports/deepseek-client.d.ts +47 -0
- package/lib/ports/deepseek-client.js +7 -0
- package/lib/ports/logger.d.ts +12 -0
- package/lib/ports/logger.js +6 -0
- package/lib/ports/metrics.d.ts +36 -0
- package/lib/ports/metrics.js +11 -0
- package/lib/services/account-tag.d.ts +24 -0
- package/lib/services/account-tag.js +29 -0
- package/lib/services/balance-service.d.ts +121 -0
- package/lib/services/balance-service.js +220 -0
- package/lib/services/config-service.d.ts +52 -0
- package/lib/services/config-service.js +51 -0
- package/lib/services/key-resolver.d.ts +42 -0
- package/lib/services/key-resolver.js +62 -0
- package/lib/services/scheduler.d.ts +93 -0
- package/lib/services/scheduler.js +142 -0
- package/lib/types/client/api-types.d.ts +54 -0
- package/lib/types/client/data.d.ts +103 -0
- package/lib/types/client/index.d.ts +18 -0
- package/lib/types/client/locales.d.ts +98 -0
- package/lib/types/client/mock/index.d.ts +36 -0
- package/lib/types/client/mock/scenarios.d.ts +51 -0
- package/lib/types/client/model.d.ts +93 -0
- package/lib/types/client/settings/BalanceSettingsCard.d.ts +22 -0
- package/lib/types/client/settings/fields.d.ts +191 -0
- package/lib/types/client/settings/use-config-form.d.ts +212 -0
- package/lib/types/client/settings/use-credential-state.d.ts +36 -0
- package/lib/types/client/sidebar/BalancePopover.d.ts +46 -0
- package/lib/types/client/sidebar/PercentRing.d.ts +36 -0
- package/lib/types/client/sidebar/SidebarBalance.d.ts +44 -0
- package/lib/version.d.ts +12 -0
- package/lib/version.js +12 -0
- package/package.json +112 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 侧栏左下角的余额条目。
|
|
3
|
+
*
|
|
4
|
+
* 两个形态共用同一个状态圆环:展开态是「圆环 + 金额」,折叠态是轨道里居中一个圆环。
|
|
5
|
+
* 点击条目弹出余额浮层,Escape 或点击外部关闭(刻意不做悬停即开:浮层向上展开,
|
|
6
|
+
* 会盖住左邻条目;悬停时指针只是路过我们这一行,邻居的图标就被顶开了)。
|
|
7
|
+
*
|
|
8
|
+
* 数据默认走真实端点(`GET /api/v1/balance`,按 `clientPollSeconds` 轮询);
|
|
9
|
+
* 只有 URL 参数或 localStorage 明确选过场景时才切到 mock 旁路。
|
|
10
|
+
* 颜色仍只由 `dotStateOf(severity)` 决定。弧长是唯一读阈值的去处,且只当刻度:
|
|
11
|
+
* 由 `ringRatioOf` 算好交给圆环。组件内不做配色判断、不读 ctx。
|
|
12
|
+
* @module dsh-ds-balance/client/sidebar/SidebarBalance
|
|
13
|
+
*/
|
|
14
|
+
import { type LocaleKey } from '../locales.ts';
|
|
15
|
+
/** 条目属性。 */
|
|
16
|
+
export interface SidebarBalanceProps {
|
|
17
|
+
/** 侧栏是否展开(false = 56px 轨道)。 */
|
|
18
|
+
wide: boolean;
|
|
19
|
+
/** 词典函数。 */
|
|
20
|
+
t: (key: LocaleKey) => string;
|
|
21
|
+
/** 本组件消费的配置切片。 */
|
|
22
|
+
config: {
|
|
23
|
+
displayCurrency: string;
|
|
24
|
+
manualRefreshCooldownSeconds: number;
|
|
25
|
+
/** 浏览器来取缓存的节奏(秒)。 */
|
|
26
|
+
clientPollSeconds: number;
|
|
27
|
+
/**
|
|
28
|
+
* 配置指纹。任何一项设置改动都会换一个值,用来**立刻**重问一次后端缓存 ——
|
|
29
|
+
* 改了阈值圆环要当场变,不该等下一轮轮询。
|
|
30
|
+
*/
|
|
31
|
+
configSignature: string;
|
|
32
|
+
/**
|
|
33
|
+
* 读某个币种的 warn 阈值。**只用来定弧长**,颜色不走这里。
|
|
34
|
+
* 没配的币种给 `undefined`,由 `ringRatioOf` 退回按 severity 定性。
|
|
35
|
+
*/
|
|
36
|
+
warnThresholdOf: (currency: string) => number | undefined;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 渲染侧栏左下角的余额条目。
|
|
41
|
+
* @param props - 展开态、词典与配置切片。
|
|
42
|
+
* @returns 条目元素。
|
|
43
|
+
*/
|
|
44
|
+
export declare function SidebarBalance({ wide, t, config }: SidebarBalanceProps): JSX.Element | null;
|
package/lib/version.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 版本常量。
|
|
3
|
+
*
|
|
4
|
+
* `PLUGIN_VERSION` 必须与 `package.json` 的 `version` 逐字一致 —— 由
|
|
5
|
+
* `test/version.test.ts` 兜底。抄成两份必然漂,所以让它可校验。
|
|
6
|
+
* @module dsh-ds-balance/version
|
|
7
|
+
*/
|
|
8
|
+
/** 线上 schema 版本。响应里逐条回传,消费方据此判断兼容性。 */
|
|
9
|
+
export declare const SCHEMA_VERSION = 1;
|
|
10
|
+
/** 插件版本。与 `package.json` 的 `version` 一致(有测试兜底)。 */
|
|
11
|
+
export declare const PLUGIN_VERSION = "1.0.0";
|
|
12
|
+
//# sourceMappingURL=version.d.ts.map
|
package/lib/version.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 版本常量。
|
|
3
|
+
*
|
|
4
|
+
* `PLUGIN_VERSION` 必须与 `package.json` 的 `version` 逐字一致 —— 由
|
|
5
|
+
* `test/version.test.ts` 兜底。抄成两份必然漂,所以让它可校验。
|
|
6
|
+
* @module dsh-ds-balance/version
|
|
7
|
+
*/
|
|
8
|
+
/** 线上 schema 版本。响应里逐条回传,消费方据此判断兼容性。 */
|
|
9
|
+
export const SCHEMA_VERSION = 1;
|
|
10
|
+
/** 插件版本。与 `package.json` 的 `version` 一致(有测试兜底)。 */
|
|
11
|
+
export const PLUGIN_VERSION = '1.0.0';
|
|
12
|
+
//# sourceMappingURL=version.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-ds-balance",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "DSH plugin: shows the DeepSeek account balance at the bottom of the sidebar, with a configuration card in settings.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dsh",
|
|
7
|
+
"deepseek-harness",
|
|
8
|
+
"dsh-plugin",
|
|
9
|
+
"deepseek",
|
|
10
|
+
"balance",
|
|
11
|
+
"usage"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "zlZayn",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/zlZayn/dsh-ds-balance.git"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/zlZayn/dsh-ds-balance/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/zlZayn/dsh-ds-balance#readme",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "./lib/index.js",
|
|
25
|
+
"types": "./lib/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./lib/index.d.ts",
|
|
29
|
+
"import": "./lib/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./client": {
|
|
32
|
+
"types": "./lib/types/client/index.d.ts",
|
|
33
|
+
"default": "./lib/client.js"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"lib",
|
|
39
|
+
"!lib/**/*.map",
|
|
40
|
+
"cordis.patch.yml",
|
|
41
|
+
"README.md",
|
|
42
|
+
"README_en.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
],
|
|
45
|
+
"engines": {
|
|
46
|
+
"dsh": "^0.1.6-alpha.1",
|
|
47
|
+
"node": ">=20"
|
|
48
|
+
},
|
|
49
|
+
"dsh": {
|
|
50
|
+
"bundle": {
|
|
51
|
+
"patch": "./cordis.patch.yml"
|
|
52
|
+
},
|
|
53
|
+
"client": {
|
|
54
|
+
"platform": "web",
|
|
55
|
+
"inject": [
|
|
56
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsc && tsc -p tsconfig.client.json && node scripts/build-client.mjs",
|
|
62
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.client.json --noEmit && tsc -p tsconfig.test.json",
|
|
63
|
+
"test": "npm run build && vitest run",
|
|
64
|
+
"test:watch": "vitest",
|
|
65
|
+
"test:contract": "vitest run --config vitest.contract.config.ts",
|
|
66
|
+
"check:release": "node scripts/check-release.mjs"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
70
|
+
"@deepseek-ai/dsh-client-connection": "^0.1.6-alpha.1",
|
|
71
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.6-alpha.1",
|
|
72
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.6-alpha.1",
|
|
73
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.1.6-alpha.1",
|
|
74
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.6-alpha.1",
|
|
75
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.6-alpha.1",
|
|
76
|
+
"@deepseek-ai/dsh-credentials": "^0.1.6-alpha.1",
|
|
77
|
+
"@deepseek-ai/dsh-home-paths": "^0.1.6-alpha.1",
|
|
78
|
+
"@deepseek-ai/dsh-settings": "^0.1.6-alpha.1",
|
|
79
|
+
"@deepseek-ai/dsh-storage-domain": "^0.1.6-alpha.1",
|
|
80
|
+
"@deepseek-ai/schemastery": "^3.18.2",
|
|
81
|
+
"react": "^18.3.1",
|
|
82
|
+
"react-dom": "^18.3.1"
|
|
83
|
+
},
|
|
84
|
+
"devDependencies": {
|
|
85
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
86
|
+
"@deepseek-ai/dsh-client-connection": "^0.1.6-alpha.1",
|
|
87
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.6-alpha.1",
|
|
88
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.6-alpha.1",
|
|
89
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.6-alpha.1",
|
|
90
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.1.6-alpha.1",
|
|
91
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.6-alpha.1",
|
|
92
|
+
"@deepseek-ai/dsh-client-ui-sidebar": "^0.1.6-alpha.1",
|
|
93
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.6-alpha.1",
|
|
94
|
+
"@deepseek-ai/dsh-credentials": "^0.1.6-alpha.1",
|
|
95
|
+
"@deepseek-ai/dsh-home-paths": "^0.1.6-alpha.1",
|
|
96
|
+
"@deepseek-ai/dsh-settings": "^0.1.6-alpha.1",
|
|
97
|
+
"@deepseek-ai/dsh-storage-domain": "^0.1.6-alpha.1",
|
|
98
|
+
"@deepseek-ai/schemastery": "^3.18.2",
|
|
99
|
+
"@types/node": "^20.0.0",
|
|
100
|
+
"@types/react": "~18.3.1",
|
|
101
|
+
"@types/react-dom": "~18.3.1",
|
|
102
|
+
"clsx": "^2.1.1",
|
|
103
|
+
"esbuild": "^0.21.5",
|
|
104
|
+
"react": "^18.3.1",
|
|
105
|
+
"react-dom": "^18.3.1",
|
|
106
|
+
"typescript": "^5.4.0",
|
|
107
|
+
"vitest": "^2.0.0"
|
|
108
|
+
},
|
|
109
|
+
"dependencies": {
|
|
110
|
+
"zod": "^4.6.5"
|
|
111
|
+
}
|
|
112
|
+
}
|