@pinkbanana/dsh-balance 0.3.2 → 0.4.1

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 CHANGED
@@ -2,28 +2,30 @@
2
2
 
3
3
  [简体中文](./README.md) | [English](./README_EN.md)
4
4
 
5
- DeepSeek Harness 设置插件,用于查询 API 余额和当前可用模型。API Key 仅由本机 Host 使用,不会发送到浏览器。
5
+ DeepSeek Harness 插件,用于查询 API 余额和当前可用模型。API Key 仅由本机 Host 使用,不会发送到浏览器。
6
6
 
7
- ![DeepSeek 余额插件界面](./docs/dsh-balance-settings.jpg)
7
+ ![DeepSeek 余额设置面板](./docs/dsh-balance-settings-v040.png)
8
8
 
9
- ![DeepSeek 模型插件界面](./docs/dsh-models-settings.jpg)
9
+ ![聊天框下方的 DeepSeek 余额](./docs/dsh-balance-composer-v040.png)
10
10
 
11
11
  ## 功能
12
12
 
13
13
  - 查看总余额、充值余额和赠送余额
14
+ - 在聊天框下方持续显示余额摘要
14
15
  - 查看当前 API Key 可用的模型
15
16
  - 缓存查询结果并支持手动刷新
17
+ - 依据 DeepSeek 峰谷定价,在高峰时段(北京时间 9:00–12:00、14:00–18:00)将聊天框下方的余额指示灯变为橙色
16
18
  - 原生支持简体中文和英文,并跟随 Harness 系统语言切换
17
19
  - 支持 Harness 已保存的 `DEEPSEEK_API_KEY`
18
20
 
19
21
  ## 安装
20
22
 
21
23
  ```bash
22
- dsh plugin --profile web add @pinkbanana/dsh-balance
24
+ dsh plugin --profile web add @pinkbanana/dsh-balance@latest
23
25
  dsh --profile web
24
26
  ```
25
27
 
26
- 打开 <http://127.0.0.1:3080/>,进入“设置 → 插件 → DeepSeek 余额 / DeepSeek 模型”。API Key 可在“设置 → 模型”中保存,或通过 `DEEPSEEK_API_KEY` 环境变量提供。
28
+ 打开 <http://127.0.0.1:3080/>,进入“设置 → DeepSeek 余额”。该入口位于“Agent 预设”下方,余额摘要也会显示在已有会话的聊天框下方。API Key 可在“设置 → 模型”中保存,或通过 `DEEPSEEK_API_KEY` 环境变量提供。
27
29
 
28
30
  ## 开发
29
31
 
package/README_EN.md CHANGED
@@ -2,28 +2,30 @@
2
2
 
3
3
  [简体中文](./README.md) | [English](./README_EN.md)
4
4
 
5
- A DeepSeek Harness Settings plugin for checking API balances and available models. The API key is used only by the local Host and is never sent to the browser.
5
+ A DeepSeek Harness plugin for checking API balances and available models. The API key is used only by the local Host and is never sent to the browser.
6
6
 
7
- ![DeepSeek balance settings](./docs/dsh-balance-settings.jpg)
7
+ ![DeepSeek balance settings panel](./docs/dsh-balance-settings-v040.png)
8
8
 
9
- ![DeepSeek models settings](./docs/dsh-models-settings.jpg)
9
+ ![DeepSeek balance below the chat composer](./docs/dsh-balance-composer-v040.png)
10
10
 
11
11
  ## Features
12
12
 
13
13
  - View total, topped-up, and granted balances
14
+ - Keep a compact balance summary below the chat composer
14
15
  - View models available to the current API key
15
16
  - Cache query results with manual refresh support
17
+ - Follows DeepSeek peak/off-peak pricing: the balance indicator below the composer turns orange during peak hours (09:00–12:00, 14:00–18:00 Beijing time)
16
18
  - Native Simplified Chinese and English that follows the Harness system language
17
19
  - Use the `DEEPSEEK_API_KEY` saved by Harness
18
20
 
19
21
  ## Install
20
22
 
21
23
  ```bash
22
- dsh plugin --profile web add @pinkbanana/dsh-balance
24
+ dsh plugin --profile web add @pinkbanana/dsh-balance@latest
23
25
  dsh --profile web
24
26
  ```
25
27
 
26
- Open <http://127.0.0.1:3080/> and go to Settings → Plugins → DeepSeek Balance / DeepSeek Models. Save the API key in Settings → Models or provide it through the `DEEPSEEK_API_KEY` environment variable.
28
+ Open <http://127.0.0.1:3080/> and go to Settings → DeepSeek Balance. The panel sits directly below Agent presets, and the balance summary also appears below the composer in existing sessions. Save the API key in Settings → Models or provide it through the `DEEPSEEK_API_KEY` environment variable.
27
29
 
28
30
  ## Development
29
31
 
package/lib/client.js CHANGED
@@ -12,13 +12,151 @@ window.__ModuleLoader__.load({
12
12
  /** The same-origin endpoint that proxies DeepSeek's `/models` API. */
13
13
  const MODELS_ROUTE = "/dsh-balance/api/models";
14
14
  //#endregion
15
+ //#region src/client/format.ts
16
+ function formatClockTime(date, locale) {
17
+ return new Intl.DateTimeFormat(locale, {
18
+ hour: "2-digit",
19
+ minute: "2-digit"
20
+ }).format(date);
21
+ }
22
+ function displayAmount(value, currency, locale) {
23
+ const amount = Number(value);
24
+ if (!Number.isFinite(amount)) return `${value} ${currency}`;
25
+ try {
26
+ return new Intl.NumberFormat(locale, {
27
+ style: "currency",
28
+ currency,
29
+ minimumFractionDigits: 2,
30
+ maximumFractionDigits: 8
31
+ }).format(amount);
32
+ } catch {
33
+ return `${value} ${currency}`;
34
+ }
35
+ }
36
+ //#endregion
37
+ //#region src/client/pricing.ts
38
+ /**
39
+ * DeepSeek API peak / off-peak pricing schedule.
40
+ *
41
+ * Official announcement (effective 2026-08-17, Beijing time):
42
+ * peak: 09:00–12:00 and 14:00–18:00 (UTC+8)
43
+ * off-peak: everything else, billed at half the peak price
44
+ *
45
+ * Windows are half-open: [09:00, 12:00) and [14:00, 18:00).
46
+ */
47
+ const BEIJING_OFFSET_MS = 288e5;
48
+ /** The scheme goes live at 00:00 Beijing time on 2026-08-17. */
49
+ const PEAK_EFFECTIVE_FROM = Date.parse("2026-08-17T00:00:00+08:00");
50
+ const PEAK_WINDOWS = [[9, 12], [14, 18]];
51
+ const DAY_MS = 864e5;
52
+ const BOUNDARY_SECONDS = [
53
+ 32400,
54
+ 43200,
55
+ 50400,
56
+ 64800
57
+ ];
58
+ /** Hour of day in Beijing time (UTC+8), 0–23. */
59
+ function beijingHour(date) {
60
+ return new Date(date.getTime() + BEIJING_OFFSET_MS).getUTCHours();
61
+ }
62
+ /** Whether the given instant falls inside a DeepSeek peak-pricing window. */
63
+ function isPeakHour(date) {
64
+ if (date.getTime() < PEAK_EFFECTIVE_FROM) return false;
65
+ const hour = beijingHour(date);
66
+ return PEAK_WINDOWS.some(([start, end]) => hour >= start && hour < end);
67
+ }
68
+ /** The next instant at which the current pricing period ends (Beijing time). */
69
+ function nextPeriodChange(date) {
70
+ const ms = date.getTime();
71
+ const beijing = new Date(ms + BEIJING_OFFSET_MS);
72
+ const secondsIntoDay = beijing.getUTCHours() * 3600 + beijing.getUTCMinutes() * 60 + beijing.getUTCSeconds();
73
+ let boundary = BOUNDARY_SECONDS.find((seconds) => secondsIntoDay < seconds);
74
+ if (boundary === void 0) boundary = 118800;
75
+ const dayStartMs = Math.floor(ms / DAY_MS) * DAY_MS;
76
+ return /* @__PURE__ */ new Date(dayStartMs + boundary * 1e3 - BEIJING_OFFSET_MS);
77
+ }
78
+ //#endregion
79
+ //#region src/client/BalanceDock.tsx
80
+ const REFRESH_INTERVAL_MS = 6e4;
81
+ const PEAK_TICK_MS = 3e4;
82
+ /** Compact ambient balance readout below the active-session composer card. */
83
+ function BalanceDock({ loadBalance, t }) {
84
+ const [result, setResult] = (0, react.useState)();
85
+ const [now, setNow] = (0, react.useState)(() => /* @__PURE__ */ new Date());
86
+ (0, react.useEffect)(() => {
87
+ const timer = window.setInterval(() => setNow(/* @__PURE__ */ new Date()), PEAK_TICK_MS);
88
+ return () => {
89
+ window.clearInterval(timer);
90
+ };
91
+ }, []);
92
+ (0, react.useEffect)(() => {
93
+ let controller;
94
+ const load = () => {
95
+ controller?.abort();
96
+ controller = new AbortController();
97
+ const signal = controller.signal;
98
+ loadBalance(false, signal).then((value) => {
99
+ if (!signal.aborted) setResult(value);
100
+ }).catch(() => {
101
+ if (!signal.aborted) setResult({
102
+ ok: false,
103
+ code: "UPSTREAM_UNAVAILABLE",
104
+ message: ""
105
+ });
106
+ });
107
+ };
108
+ load();
109
+ const timer = window.setInterval(load, REFRESH_INTERVAL_MS);
110
+ return () => {
111
+ window.clearInterval(timer);
112
+ controller?.abort();
113
+ };
114
+ }, [loadBalance]);
115
+ const summary = (0, react.useMemo)(() => {
116
+ if (result === void 0) return t("dock.loading");
117
+ if (!result.ok) return t("dock.unavailable");
118
+ if (result.balanceInfos.length === 0) return t("dock.empty");
119
+ return result.balanceInfos.map((info) => `${info.currency} ${displayAmount(info.totalBalance, info.currency, t("locale.tag"))}`).join(" · ");
120
+ }, [result, t]);
121
+ const state = result === void 0 ? "loading" : result.ok && result.isAvailable ? "available" : result.ok ? "empty" : "error";
122
+ const accessibleState = result?.ok === true ? t(result.isAvailable ? "balance.available" : "balance.unavailable") : void 0;
123
+ const pricingActive = now.getTime() >= PEAK_EFFECTIVE_FROM;
124
+ const isPeak = pricingActive && isPeakHour(now);
125
+ const periodLabel = pricingActive ? t(isPeak ? "pricing.peak" : "pricing.offPeak") : void 0;
126
+ const periodTitle = pricingActive ? t(isPeak ? "pricing.peakHint" : "pricing.offPeakHint", { time: formatClockTime(nextPeriodChange(now), t("locale.tag")) }) : void 0;
127
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
128
+ className: "dsh-balance-dock",
129
+ role: "status",
130
+ "aria-live": "polite",
131
+ title: periodTitle,
132
+ "aria-label": `${t("dock.label")}: ${summary}${accessibleState === void 0 ? "" : `. ${accessibleState}`}${periodLabel === void 0 ? "" : `. ${periodLabel}`}`,
133
+ children: [
134
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
135
+ className: "dsh-balance-dock-dot",
136
+ "data-state": state,
137
+ "data-peak": isPeak ? "true" : void 0,
138
+ "aria-hidden": "true"
139
+ }),
140
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("dock.label") }),
141
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
142
+ className: "dsh-balance-dock-separator",
143
+ "aria-hidden": "true",
144
+ children: "|"
145
+ }),
146
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
147
+ className: "dsh-balance-dock-value",
148
+ children: summary
149
+ })
150
+ ]
151
+ });
152
+ }
153
+ //#endregion
15
154
  //#region src/client/locales.ts
16
155
  const LOCALE_NS = "dsh-balance";
17
156
  /** Simplified Chinese dictionary and source of truth for the namespace key set. */
18
157
  const zh = {
19
158
  "locale.tag": "zh-CN",
20
- "tab.balance": "DeepSeek 余额",
21
- "tab.models": "DeepSeek 模型",
159
+ "nav.balance": "DeepSeek 余额",
22
160
  "action.loading": "查询中…",
23
161
  "balance.title": "DeepSeek API 余额",
24
162
  "balance.copy": "余额由本机 Host 使用已保存的 API 密钥查询,密钥不会发送到浏览器。",
@@ -29,6 +167,10 @@ window.__ModuleLoader__.load({
29
167
  "balance.empty": "DeepSeek 未返回任何币种余额。",
30
168
  "balance.toppedUp": "充值余额",
31
169
  "balance.granted": "赠送余额",
170
+ "dock.label": "DeepSeek 余额",
171
+ "dock.loading": "查询中…",
172
+ "dock.unavailable": "暂时无法获取",
173
+ "dock.empty": "暂无余额信息",
32
174
  "models.title": "DeepSeek 可用模型",
33
175
  "models.copy": "从 DeepSeek 官方 /models 接口读取当前 API Key 可访问的模型。",
34
176
  "models.refresh": "刷新模型",
@@ -36,6 +178,10 @@ window.__ModuleLoader__.load({
36
178
  "models.count": "当前可用 {count} 个模型",
37
179
  "models.empty": "DeepSeek 未返回任何可用模型。",
38
180
  "models.owner": "由 {owner} 提供",
181
+ "pricing.peak": "高峰时段",
182
+ "pricing.offPeak": "低谷时段",
183
+ "pricing.peakHint": "DeepSeek 高峰时段,API 价格为低谷的两倍,{time} 恢复低谷价",
184
+ "pricing.offPeakHint": "DeepSeek 低谷时段,API 价格为高峰的一半,{time} 进入高峰",
39
185
  "meta.updated": "更新于 {time}",
40
186
  "meta.cached": " · 缓存",
41
187
  "error.FORBIDDEN": "此查询仅允许从本机访问",
@@ -51,8 +197,7 @@ window.__ModuleLoader__.load({
51
197
  /** English dictionary, checked complete against the Chinese key set. */
52
198
  const en = {
53
199
  "locale.tag": "en-US",
54
- "tab.balance": "DeepSeek Balance",
55
- "tab.models": "DeepSeek Models",
200
+ "nav.balance": "DeepSeek Balance",
56
201
  "action.loading": "Loading…",
57
202
  "balance.title": "DeepSeek API Balance",
58
203
  "balance.copy": "The local Host queries your balance with the saved API key. The key is never sent to the browser.",
@@ -63,6 +208,10 @@ window.__ModuleLoader__.load({
63
208
  "balance.empty": "DeepSeek returned no currency balances.",
64
209
  "balance.toppedUp": "Topped-up balance",
65
210
  "balance.granted": "Granted balance",
211
+ "dock.label": "DeepSeek Balance",
212
+ "dock.loading": "Loading…",
213
+ "dock.unavailable": "Temporarily unavailable",
214
+ "dock.empty": "No balance information",
66
215
  "models.title": "Available DeepSeek Models",
67
216
  "models.copy": "Lists the models available to the current API key using the official DeepSeek /models endpoint.",
68
217
  "models.refresh": "Refresh models",
@@ -70,6 +219,10 @@ window.__ModuleLoader__.load({
70
219
  "models.count": "{count} models available",
71
220
  "models.empty": "DeepSeek returned no available models.",
72
221
  "models.owner": "Provided by {owner}",
222
+ "pricing.peak": "Peak hours",
223
+ "pricing.offPeak": "Off-peak hours",
224
+ "pricing.peakHint": "DeepSeek peak hours — API prices are double. Off-peak pricing resumes at {time}",
225
+ "pricing.offPeakHint": "DeepSeek off-peak hours — API prices are halved. Peak pricing starts at {time}",
73
226
  "meta.updated": "Updated {time}",
74
227
  "meta.cached": " · Cached",
75
228
  "error.FORBIDDEN": "This query is available only from the local machine",
@@ -87,20 +240,6 @@ window.__ModuleLoader__.load({
87
240
  }
88
241
  //#endregion
89
242
  //#region src/client/BalanceTab.tsx
90
- function displayAmount(value, currency, locale) {
91
- const amount = Number(value);
92
- if (!Number.isFinite(amount)) return `${value} ${currency}`;
93
- try {
94
- return new Intl.NumberFormat(locale, {
95
- style: "currency",
96
- currency,
97
- minimumFractionDigits: 2,
98
- maximumFractionDigits: 8
99
- }).format(amount);
100
- } catch {
101
- return `${value} ${currency}`;
102
- }
103
- }
104
243
  function BalanceCard({ info, t }) {
105
244
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
106
245
  className: "dsh-balance-card",
@@ -128,7 +267,7 @@ window.__ModuleLoader__.load({
128
267
  ]
129
268
  });
130
269
  }
131
- function BalanceTab({ loadBalance, t }) {
270
+ function BalanceSection({ loadBalance, t }) {
132
271
  const [result, setResult] = (0, react.useState)();
133
272
  const [loading, setLoading] = (0, react.useState)(true);
134
273
  const load = (0, react.useCallback)(async (forceRefresh, signal) => {
@@ -158,7 +297,7 @@ window.__ModuleLoader__.load({
158
297
  load(true, controller.signal);
159
298
  };
160
299
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
161
- className: "dsh-balance-tab",
300
+ className: "dsh-balance-section",
162
301
  "aria-labelledby": "dsh-balance-title",
163
302
  children: [
164
303
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -229,7 +368,7 @@ window.__ModuleLoader__.load({
229
368
  })]
230
369
  });
231
370
  }
232
- function ModelsTab({ loadModels, t }) {
371
+ function ModelsSection({ loadModels, t }) {
233
372
  const [result, setResult] = (0, react.useState)();
234
373
  const [loading, setLoading] = (0, react.useState)(true);
235
374
  const load = (0, react.useCallback)(async (forceRefresh, signal) => {
@@ -259,7 +398,7 @@ window.__ModuleLoader__.load({
259
398
  load(true, controller.signal);
260
399
  };
261
400
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
262
- className: "dsh-models-tab",
401
+ className: "dsh-models-section",
263
402
  "aria-labelledby": "dsh-models-title",
264
403
  children: [
265
404
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -316,30 +455,63 @@ window.__ModuleLoader__.load({
316
455
  });
317
456
  }
318
457
  //#endregion
458
+ //#region src/client/DeepSeekPanel.tsx
459
+ /** Standalone DeepSeek settings page, placed immediately after Agent presets. */
460
+ function DeepSeekPanel({ loadBalance, loadModels, t }) {
461
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
462
+ className: "dsh-deepseek-panel",
463
+ children: [
464
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BalanceSection, {
465
+ loadBalance,
466
+ t
467
+ }),
468
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
469
+ className: "dsh-deepseek-divider",
470
+ "aria-hidden": "true"
471
+ }),
472
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelsSection, {
473
+ loadModels,
474
+ t
475
+ })
476
+ ]
477
+ });
478
+ }
479
+ //#endregion
319
480
  //#region src/client/styles.ts
320
481
  const balanceStyles = `
321
- .dsh-balance-tab {
482
+ .dsh-deepseek-panel {
322
483
  display: flex;
323
484
  flex-direction: column;
324
- gap: 14px;
325
- max-width: 760px;
485
+ gap: 28px;
486
+ max-width: 720px;
326
487
  color: var(--dsw-alias-label-primary);
327
488
  }
489
+ .dsh-balance-section,
490
+ .dsh-models-section {
491
+ display: flex;
492
+ flex-direction: column;
493
+ gap: 14px;
494
+ }
495
+ .dsh-deepseek-divider {
496
+ height: 1px;
497
+ background: var(--dsw-alias-border-l2);
498
+ }
328
499
  .dsh-balance-summary {
329
500
  display: flex;
330
501
  align-items: center;
331
502
  justify-content: space-between;
332
503
  gap: 16px;
333
504
  }
334
- .dsh-balance-heading { margin: 0; font-size: 18px; font-weight: 600; }
505
+ .dsh-balance-heading { margin: 0; font-size: 18px; font-weight: 600; line-height: 24px; }
335
506
  .dsh-balance-copy { margin: 4px 0 0; color: var(--dsw-alias-label-tertiary); font-size: 13px; line-height: 1.5; }
336
507
  .dsh-balance-refresh {
337
508
  flex: none;
338
509
  appearance: none;
339
510
  border: 1px solid var(--dsw-alias-border-l2);
340
- border-radius: 8px;
341
- padding: 6px 13px;
342
- background: var(--dsw-alias-bg-layer-3);
511
+ border-radius: 16px;
512
+ min-height: 32px;
513
+ padding: 0 14px;
514
+ background: transparent;
343
515
  color: var(--dsw-alias-label-primary);
344
516
  font: inherit;
345
517
  font-size: 13px;
@@ -377,13 +549,6 @@ window.__ModuleLoader__.load({
377
549
  .dsh-balance-breakdown dt { color: var(--dsw-alias-label-tertiary); }
378
550
  .dsh-balance-breakdown dd { margin: 0; color: var(--dsw-alias-label-secondary); font-variant-numeric: tabular-nums; }
379
551
  .dsh-balance-meta { margin: 0; color: var(--dsw-alias-label-tertiary); font-size: 12px; }
380
- .dsh-models-tab {
381
- display: flex;
382
- flex-direction: column;
383
- gap: 14px;
384
- max-width: 760px;
385
- color: var(--dsw-alias-label-primary);
386
- }
387
552
  .dsh-model-count { display: flex; align-items: center; gap: 8px; font-size: 13px; }
388
553
  .dsh-model-count .dsh-balance-dot { background: var(--dsw-alias-state-success-primary); }
389
554
  .dsh-model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
@@ -404,6 +569,47 @@ window.__ModuleLoader__.load({
404
569
  overflow-wrap: anywhere;
405
570
  }
406
571
  .dsh-model-owner { color: var(--dsw-alias-label-tertiary); font-size: 12px; }
572
+ .dsh-balance-dock {
573
+ box-sizing: border-box;
574
+ display: block;
575
+ width: 100%;
576
+ max-width: var(--dsh-chat-content-width);
577
+ margin: 0 auto;
578
+ padding: 4px calc(var(--dsh-composer-side-clearance) + 16px) 0;
579
+ color: var(--dsw-alias-label-tertiary);
580
+ font-size: 12px;
581
+ line-height: 20px;
582
+ text-align: center;
583
+ white-space: nowrap;
584
+ overflow: hidden;
585
+ text-overflow: ellipsis;
586
+ }
587
+ .dsh-balance-dock-dot {
588
+ display: inline-block;
589
+ width: 6px;
590
+ height: 6px;
591
+ margin-right: 6px;
592
+ border-radius: 999px;
593
+ background: var(--dsw-alias-label-dimmed);
594
+ vertical-align: 1px;
595
+ }
596
+ .dsh-balance-dock-dot[data-state='available'] { background: var(--dsw-alias-state-success-primary); }
597
+ .dsh-balance-dock-dot[data-state='available'][data-peak='true'] { background: var(--dsw-alias-state-warn-primary); }
598
+ .dsh-balance-dock-dot[data-state='empty'],
599
+ .dsh-balance-dock-dot[data-state='error'] { background: var(--dsw-alias-state-error-primary); }
600
+ .dsh-balance-dock-separator {
601
+ margin: 0 10px;
602
+ color: var(--dsw-alias-separator-primary);
603
+ }
604
+ .dsh-balance-dock-value {
605
+ color: var(--dsw-alias-label-secondary);
606
+ font-variant-numeric: tabular-nums;
607
+ }
608
+ @media (max-width: 640px) {
609
+ .dsh-balance-summary { align-items: flex-start; }
610
+ .dsh-balance-grid,
611
+ .dsh-model-grid { grid-template-columns: 1fr; }
612
+ }
407
613
  `;
408
614
  //#endregion
409
615
  //#region src/client/index.tsx
@@ -428,7 +634,7 @@ window.__ModuleLoader__.load({
428
634
  if (typeof value !== "object" || value === null || !("ok" in value) || typeof value.ok !== "boolean") throw new Error("模型插件收到了无法识别的 Host 响应");
429
635
  return value;
430
636
  }
431
- /** Register one feature-owned page inside the existing Plugins settings section. */
637
+ /** Register a standalone Settings page and an ambient composer balance readout. */
432
638
  function apply(ctx) {
433
639
  ctx.effect(() => ctx.locale.register(LOCALE_NS, {
434
640
  zh,
@@ -445,22 +651,24 @@ window.__ModuleLoader__.load({
445
651
  style.remove();
446
652
  };
447
653
  }, "dsh-balance: styles");
448
- ctx.slots.inject("settings.plugins.tab", () => ctx.slots.register({
449
- name: "settings.plugins.tab",
654
+ ctx.slots.inject("settings.section", () => ctx.slots.register({
655
+ name: "settings.section",
450
656
  id: "deepseek-balance",
451
- order: 20,
452
- label: () => t("tab.balance"),
453
- locale: LOCALE_NS,
454
- inject: () => ({ loadBalance })
455
- }, BalanceTab));
456
- ctx.slots.inject("settings.plugins.tab", () => ctx.slots.register({
457
- name: "settings.plugins.tab",
458
- id: "deepseek-models",
459
657
  order: 21,
460
- label: () => t("tab.models"),
658
+ label: () => t("nav.balance"),
461
659
  locale: LOCALE_NS,
462
- inject: () => ({ loadModels })
463
- }, ModelsTab));
660
+ inject: () => ({
661
+ loadBalance,
662
+ loadModels
663
+ })
664
+ }, DeepSeekPanel));
665
+ ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({
666
+ name: "conversation.composer.dock",
667
+ id: "deepseek-balance",
668
+ order: 10,
669
+ locale: LOCALE_NS,
670
+ inject: () => ({ loadBalance })
671
+ }, BalanceDock));
464
672
  }
465
673
  //#endregion
466
674
  exports.apply = apply;
package/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["useState","useCallback","useState","useCallback"],"sources":["../src/types.ts","../src/client/locales.ts","../src/client/BalanceTab.tsx","../src/client/ModelsTab.tsx","../src/client/styles.ts","../src/client/index.tsx"],"sourcesContent":["/** The same-origin endpoint exposed by the plugin's Host half. */\nexport const BALANCE_ROUTE = '/dsh-balance/api/balance'\n\n/** The same-origin endpoint that proxies DeepSeek's `/models` API. */\nexport const MODELS_ROUTE = '/dsh-balance/api/models'\n\n/** One currency row returned by DeepSeek's `/user/balance` API. */\nexport interface BalanceInfo {\n currency: string\n totalBalance: string\n grantedBalance: string\n toppedUpBalance: string\n}\n\n/** A successful, browser-safe balance response. */\nexport interface BalanceSuccess {\n ok: true\n isAvailable: boolean\n balanceInfos: BalanceInfo[]\n fetchedAt: string\n source: 'live' | 'cache'\n}\n\nexport type DeepSeekApiErrorCode =\n | 'FORBIDDEN'\n | 'INVALID_API_KEY'\n | 'INVALID_RESPONSE'\n | 'METHOD_NOT_ALLOWED'\n | 'MISSING_API_KEY'\n | 'RATE_LIMITED'\n | 'UPSTREAM_ERROR'\n | 'UPSTREAM_TIMEOUT'\n | 'UPSTREAM_UNAVAILABLE'\n\n/** @deprecated Prefer the feature-neutral `DeepSeekApiErrorCode`. */\nexport type BalanceErrorCode = DeepSeekApiErrorCode\n\n/** A failed, browser-safe response. It intentionally contains no upstream body or credential. */\nexport interface BalanceFailure {\n ok: false\n code: DeepSeekApiErrorCode\n message: string\n}\n\nexport type BalanceApiResponse = BalanceSuccess | BalanceFailure\n\n/** One model returned by DeepSeek's `/models` API. */\nexport interface ModelInfo {\n id: string\n ownedBy: string\n}\n\n/** A successful, browser-safe model-list response. */\nexport interface ModelsSuccess {\n ok: true\n models: ModelInfo[]\n fetchedAt: string\n source: 'live' | 'cache'\n}\n\nexport type ModelsFailure = BalanceFailure\nexport type ModelsApiResponse = ModelsSuccess | ModelsFailure\n","import type { LocaleDictOf } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { DeepSeekApiErrorCode } from '../types.ts'\n\nexport const LOCALE_NS = 'dsh-balance'\n\n/** Simplified Chinese dictionary and source of truth for the namespace key set. */\nexport const zh = {\n 'locale.tag': 'zh-CN',\n 'tab.balance': 'DeepSeek 余额',\n 'tab.models': 'DeepSeek 模型',\n 'action.loading': '查询中…',\n 'balance.title': 'DeepSeek API 余额',\n 'balance.copy': '余额由本机 Host 使用已保存的 API 密钥查询,密钥不会发送到浏览器。',\n 'balance.refresh': '刷新余额',\n 'balance.loading': '正在查询 DeepSeek 账户余额…',\n 'balance.available': '当前账户有可用余额',\n 'balance.unavailable': '当前账户没有可用余额',\n 'balance.empty': 'DeepSeek 未返回任何币种余额。',\n 'balance.toppedUp': '充值余额',\n 'balance.granted': '赠送余额',\n 'models.title': 'DeepSeek 可用模型',\n 'models.copy': '从 DeepSeek 官方 /models 接口读取当前 API Key 可访问的模型。',\n 'models.refresh': '刷新模型',\n 'models.loading': '正在查询 DeepSeek 模型列表…',\n 'models.count': '当前可用 {count} 个模型',\n 'models.empty': 'DeepSeek 未返回任何可用模型。',\n 'models.owner': '由 {owner} 提供',\n 'meta.updated': '更新于 {time}',\n 'meta.cached': ' · 缓存',\n 'error.FORBIDDEN': '此查询仅允许从本机访问',\n 'error.INVALID_API_KEY': 'DeepSeek API 密钥无效或没有查询权限',\n 'error.INVALID_RESPONSE': 'DeepSeek 返回了无法识别的响应',\n 'error.METHOD_NOT_ALLOWED': '请求方法不受支持',\n 'error.MISSING_API_KEY': '未配置 DeepSeek API 密钥,请先在“模型”设置中保存',\n 'error.RATE_LIMITED': 'DeepSeek API 请求过于频繁,请稍后重试',\n 'error.UPSTREAM_ERROR': 'DeepSeek API 返回了错误',\n 'error.UPSTREAM_TIMEOUT': '查询 DeepSeek API 超时',\n 'error.UPSTREAM_UNAVAILABLE': '无法连接到 DeepSeek API',\n} as const\n\nexport type DshBalanceLocaleKey = keyof typeof zh\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** Balance and model-list settings copy owned by this plugin. */\n 'dsh-balance': DshBalanceLocaleKey\n }\n}\n\n/** English dictionary, checked complete against the Chinese key set. */\nexport const en: LocaleDictOf<typeof LOCALE_NS> = {\n 'locale.tag': 'en-US',\n 'tab.balance': 'DeepSeek Balance',\n 'tab.models': 'DeepSeek Models',\n 'action.loading': 'Loading…',\n 'balance.title': 'DeepSeek API Balance',\n 'balance.copy': 'The local Host queries your balance with the saved API key. The key is never sent to the browser.',\n 'balance.refresh': 'Refresh balance',\n 'balance.loading': 'Loading your DeepSeek API balance…',\n 'balance.available': 'This account has available balance',\n 'balance.unavailable': 'This account has no available balance',\n 'balance.empty': 'DeepSeek returned no currency balances.',\n 'balance.toppedUp': 'Topped-up balance',\n 'balance.granted': 'Granted balance',\n 'models.title': 'Available DeepSeek Models',\n 'models.copy': 'Lists the models available to the current API key using the official DeepSeek /models endpoint.',\n 'models.refresh': 'Refresh models',\n 'models.loading': 'Loading the DeepSeek model list…',\n 'models.count': '{count} models available',\n 'models.empty': 'DeepSeek returned no available models.',\n 'models.owner': 'Provided by {owner}',\n 'meta.updated': 'Updated {time}',\n 'meta.cached': ' · Cached',\n 'error.FORBIDDEN': 'This query is available only from the local machine',\n 'error.INVALID_API_KEY': 'The DeepSeek API key is invalid or lacks permission',\n 'error.INVALID_RESPONSE': 'DeepSeek returned an unrecognized response',\n 'error.METHOD_NOT_ALLOWED': 'This request method is not supported',\n 'error.MISSING_API_KEY': 'No DeepSeek API key is configured. Save one in Models settings first.',\n 'error.RATE_LIMITED': 'Too many DeepSeek API requests. Try again later.',\n 'error.UPSTREAM_ERROR': 'The DeepSeek API returned an error',\n 'error.UPSTREAM_TIMEOUT': 'The DeepSeek API request timed out',\n 'error.UPSTREAM_UNAVAILABLE': 'Could not connect to the DeepSeek API',\n}\n\nexport function errorLocaleKey(code: DeepSeekApiErrorCode): DshBalanceLocaleKey {\n return `error.${code}`\n}\n","import { useCallback, useEffect, useState } from 'react'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { BalanceApiResponse, BalanceInfo } from '../types.ts'\nimport { errorLocaleKey } from './locales.ts'\nimport type { LOCALE_NS } from './locales.ts'\n\nexport interface BalanceTabInjected {\n loadBalance: (forceRefresh: boolean, signal: AbortSignal) => Promise<BalanceApiResponse>\n}\n\nexport type BalanceTabProps = PropsRuntime<'settings.plugins.tab'> & InjectFace<BalanceTabInjected> & PropsLocale<typeof LOCALE_NS>\n\nfunction displayAmount(value: string, currency: string, locale: string): string {\n const amount = Number(value)\n if (!Number.isFinite(amount)) return `${value} ${currency}`\n try {\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n minimumFractionDigits: 2,\n maximumFractionDigits: 8,\n }).format(amount)\n } catch {\n return `${value} ${currency}`\n }\n}\n\nfunction BalanceCard({ info, t }: { info: BalanceInfo; t: BalanceTabProps['t'] }) {\n return (\n <article className=\"dsh-balance-card\">\n <div className=\"dsh-balance-card-head\">\n <span className=\"dsh-balance-currency\">{info.currency}</span>\n </div>\n <p className=\"dsh-balance-total\">{displayAmount(info.totalBalance, info.currency, t('locale.tag'))}</p>\n <dl className=\"dsh-balance-breakdown\">\n <dt>{t('balance.toppedUp')}</dt>\n <dd>{displayAmount(info.toppedUpBalance, info.currency, t('locale.tag'))}</dd>\n <dt>{t('balance.granted')}</dt>\n <dd>{displayAmount(info.grantedBalance, info.currency, t('locale.tag'))}</dd>\n </dl>\n </article>\n )\n}\n\nexport function BalanceTab({ loadBalance, t }: BalanceTabProps) {\n const [result, setResult] = useState<BalanceApiResponse>()\n const [loading, setLoading] = useState(true)\n\n const load = useCallback(async (forceRefresh: boolean, signal: AbortSignal) => {\n setLoading(true)\n try {\n setResult(await loadBalance(forceRefresh, signal))\n } catch (error) {\n if (signal.aborted) return\n setResult({\n ok: false,\n code: 'UPSTREAM_UNAVAILABLE',\n message: error instanceof Error ? error.message : '',\n })\n } finally {\n if (!signal.aborted) setLoading(false)\n }\n }, [loadBalance])\n\n useEffect(() => {\n const controller = new AbortController()\n void load(false, controller.signal)\n return () => { controller.abort() }\n }, [load])\n\n const refresh = () => {\n const controller = new AbortController()\n void load(true, controller.signal)\n }\n\n return (\n <section className=\"dsh-balance-tab\" aria-labelledby=\"dsh-balance-title\">\n <div className=\"dsh-balance-summary\">\n <div>\n <h2 id=\"dsh-balance-title\" className=\"dsh-balance-heading\">{t('balance.title')}</h2>\n <p className=\"dsh-balance-copy\">{t('balance.copy')}</p>\n </div>\n <button className=\"dsh-balance-refresh\" type=\"button\" disabled={loading} onClick={refresh}>\n {loading ? t('action.loading') : t('balance.refresh')}\n </button>\n </div>\n\n {loading && result === undefined ? <p className=\"dsh-balance-status\" role=\"status\">{t('balance.loading')}</p> : null}\n {result?.ok === false ? <p className=\"dsh-balance-error\" role=\"alert\">{t(errorLocaleKey(result.code))}</p> : null}\n {result?.ok === true ? (\n <>\n <div className=\"dsh-balance-availability\" data-available={String(result.isAvailable)}>\n <span className=\"dsh-balance-dot\" aria-hidden=\"true\" />\n <span>{t(result.isAvailable ? 'balance.available' : 'balance.unavailable')}</span>\n </div>\n {result.balanceInfos.length > 0\n ? <div className=\"dsh-balance-grid\">{result.balanceInfos.map(info => <BalanceCard key={info.currency} info={info} t={t} />)}</div>\n : <p className=\"dsh-balance-status\">{t('balance.empty')}</p>}\n <p className=\"dsh-balance-meta\">\n {t('meta.updated', { time: new Date(result.fetchedAt).toLocaleString(t('locale.tag')) })}{result.source === 'cache' ? t('meta.cached') : ''}\n </p>\n </>\n ) : null}\n </section>\n )\n}\n","import { useCallback, useEffect, useState } from 'react'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { ModelInfo, ModelsApiResponse } from '../types.ts'\nimport { errorLocaleKey } from './locales.ts'\nimport type { LOCALE_NS } from './locales.ts'\n\nexport interface ModelsTabInjected {\n loadModels: (forceRefresh: boolean, signal: AbortSignal) => Promise<ModelsApiResponse>\n}\n\nexport type ModelsTabProps = PropsRuntime<'settings.plugins.tab'> & InjectFace<ModelsTabInjected> & PropsLocale<typeof LOCALE_NS>\n\nfunction ModelCard({ model, t }: { model: ModelInfo; t: ModelsTabProps['t'] }) {\n return (\n <article className=\"dsh-model-card\">\n <code className=\"dsh-model-id\">{model.id}</code>\n <span className=\"dsh-model-owner\">{t('models.owner', { owner: model.ownedBy })}</span>\n </article>\n )\n}\n\nexport function ModelsTab({ loadModels, t }: ModelsTabProps) {\n const [result, setResult] = useState<ModelsApiResponse>()\n const [loading, setLoading] = useState(true)\n\n const load = useCallback(async (forceRefresh: boolean, signal: AbortSignal) => {\n setLoading(true)\n try {\n setResult(await loadModels(forceRefresh, signal))\n } catch (error) {\n if (signal.aborted) return\n setResult({\n ok: false,\n code: 'UPSTREAM_UNAVAILABLE',\n message: error instanceof Error ? error.message : '',\n })\n } finally {\n if (!signal.aborted) setLoading(false)\n }\n }, [loadModels])\n\n useEffect(() => {\n const controller = new AbortController()\n void load(false, controller.signal)\n return () => { controller.abort() }\n }, [load])\n\n const refresh = () => {\n const controller = new AbortController()\n void load(true, controller.signal)\n }\n\n return (\n <section className=\"dsh-models-tab\" aria-labelledby=\"dsh-models-title\">\n <div className=\"dsh-balance-summary\">\n <div>\n <h2 id=\"dsh-models-title\" className=\"dsh-balance-heading\">{t('models.title')}</h2>\n <p className=\"dsh-balance-copy\">{t('models.copy')}</p>\n </div>\n <button className=\"dsh-balance-refresh\" type=\"button\" disabled={loading} onClick={refresh}>\n {loading ? t('action.loading') : t('models.refresh')}\n </button>\n </div>\n\n {loading && result === undefined ? <p className=\"dsh-balance-status\" role=\"status\">{t('models.loading')}</p> : null}\n {result?.ok === false ? <p className=\"dsh-balance-error\" role=\"alert\">{t(errorLocaleKey(result.code))}</p> : null}\n {result?.ok === true ? (\n <>\n <div className=\"dsh-model-count\">\n <span className=\"dsh-balance-dot\" aria-hidden=\"true\" />\n <span>{t('models.count', { count: result.models.length })}</span>\n </div>\n {result.models.length > 0\n ? <div className=\"dsh-model-grid\">{result.models.map(model => <ModelCard key={model.id} model={model} t={t} />)}</div>\n : <p className=\"dsh-balance-status\">{t('models.empty')}</p>}\n <p className=\"dsh-balance-meta\">\n {t('meta.updated', { time: new Date(result.fetchedAt).toLocaleString(t('locale.tag')) })}{result.source === 'cache' ? t('meta.cached') : ''}\n </p>\n </>\n ) : null}\n </section>\n )\n}\n","export const balanceStyles = `\n.dsh-balance-tab {\n display: flex;\n flex-direction: column;\n gap: 14px;\n max-width: 760px;\n color: var(--dsw-alias-label-primary);\n}\n.dsh-balance-summary {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n}\n.dsh-balance-heading { margin: 0; font-size: 18px; font-weight: 600; }\n.dsh-balance-copy { margin: 4px 0 0; color: var(--dsw-alias-label-tertiary); font-size: 13px; line-height: 1.5; }\n.dsh-balance-refresh {\n flex: none;\n appearance: none;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 8px;\n padding: 6px 13px;\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-primary);\n font: inherit;\n font-size: 13px;\n cursor: pointer;\n}\n.dsh-balance-refresh:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-balance-refresh:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }\n.dsh-balance-refresh:disabled { cursor: default; opacity: .55; }\n.dsh-balance-status,\n.dsh-balance-error {\n margin: 0;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 18px;\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-secondary);\n font-size: 13px;\n line-height: 1.6;\n}\n.dsh-balance-error { color: var(--dsw-alias-state-error-primary); }\n.dsh-balance-availability { display: flex; align-items: center; gap: 8px; font-size: 13px; }\n.dsh-balance-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--dsw-alias-state-error-primary); }\n.dsh-balance-availability[data-available='true'] .dsh-balance-dot { background: var(--dsw-alias-state-success-primary); }\n.dsh-balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }\n.dsh-balance-card {\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 16px;\n background: var(--dsw-alias-bg-layer-3);\n}\n.dsh-balance-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }\n.dsh-balance-currency { color: var(--dsw-alias-label-tertiary); font-size: 12px; font-weight: 600; letter-spacing: .04em; }\n.dsh-balance-total { margin: 12px 0 16px; font-size: 28px; font-weight: 650; line-height: 1.15; }\n.dsh-balance-breakdown { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; margin: 0; font-size: 12px; }\n.dsh-balance-breakdown dt { color: var(--dsw-alias-label-tertiary); }\n.dsh-balance-breakdown dd { margin: 0; color: var(--dsw-alias-label-secondary); font-variant-numeric: tabular-nums; }\n.dsh-balance-meta { margin: 0; color: var(--dsw-alias-label-tertiary); font-size: 12px; }\n.dsh-models-tab {\n display: flex;\n flex-direction: column;\n gap: 14px;\n max-width: 760px;\n color: var(--dsw-alias-label-primary);\n}\n.dsh-model-count { display: flex; align-items: center; gap: 8px; font-size: 13px; }\n.dsh-model-count .dsh-balance-dot { background: var(--dsw-alias-state-success-primary); }\n.dsh-model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }\n.dsh-model-card {\n display: flex;\n flex-direction: column;\n gap: 10px;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 16px;\n background: var(--dsw-alias-bg-layer-3);\n}\n.dsh-model-id {\n color: var(--dsw-alias-label-primary);\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 15px;\n font-weight: 600;\n overflow-wrap: anywhere;\n}\n.dsh-model-owner { color: var(--dsw-alias-label-tertiary); font-size: 12px; }\n`\n","import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\nimport type { BalanceApiResponse, ModelsApiResponse } from '../types.ts'\nimport { BALANCE_ROUTE, MODELS_ROUTE } from '../types.ts'\nimport { BalanceTab } from './BalanceTab.tsx'\nimport type { BalanceTabInjected } from './BalanceTab.tsx'\nimport { ModelsTab } from './ModelsTab.tsx'\nimport type { ModelsTabInjected } from './ModelsTab.tsx'\nimport { en, LOCALE_NS, zh } from './locales.ts'\nimport { balanceStyles } from './styles.ts'\n\nexport type { BalanceTabInjected, BalanceTabProps } from './BalanceTab.tsx'\nexport type { ModelsTabInjected, ModelsTabProps } from './ModelsTab.tsx'\n\nexport const inject = ['slots', 'locale']\n\nasync function loadBalance(forceRefresh: boolean, signal: AbortSignal): Promise<BalanceApiResponse> {\n const url = forceRefresh ? `${BALANCE_ROUTE}?refresh=1` : BALANCE_ROUTE\n const response = await fetch(url, {\n method: 'GET',\n headers: { accept: 'application/json' },\n cache: 'no-store',\n signal,\n })\n const value: unknown = await response.json()\n if (typeof value !== 'object' || value === null || !('ok' in value) || typeof value.ok !== 'boolean') {\n throw new Error('余额插件收到了无法识别的 Host 响应')\n }\n return value as BalanceApiResponse\n}\n\nasync function loadModels(forceRefresh: boolean, signal: AbortSignal): Promise<ModelsApiResponse> {\n const url = forceRefresh ? `${MODELS_ROUTE}?refresh=1` : MODELS_ROUTE\n const response = await fetch(url, {\n method: 'GET',\n headers: { accept: 'application/json' },\n cache: 'no-store',\n signal,\n })\n const value: unknown = await response.json()\n if (typeof value !== 'object' || value === null || !('ok' in value) || typeof value.ok !== 'boolean') {\n throw new Error('模型插件收到了无法识别的 Host 响应')\n }\n return value as ModelsApiResponse\n}\n\n/** Register one feature-owned page inside the existing Plugins settings section. */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(\n () => ctx.locale.register(LOCALE_NS, { zh, en }),\n 'dsh-balance: dictionaries',\n )\n const t = ctx.locale.bind(LOCALE_NS)\n\n ctx.effect(() => {\n const style = document.createElement('style')\n style.dataset.plugin = 'dsh-balance'\n style.dataset.pluginCss = 'dsh-balance/styles'\n style.textContent = balanceStyles\n document.head.append(style)\n return () => { style.remove() }\n }, 'dsh-balance: styles')\n\n ctx.slots.inject('settings.plugins.tab', () => ctx.slots.register({\n name: 'settings.plugins.tab',\n id: 'deepseek-balance',\n order: 20,\n label: () => t('tab.balance'),\n locale: LOCALE_NS,\n inject: (): BalanceTabInjected => ({ loadBalance }),\n }, BalanceTab))\n ctx.slots.inject('settings.plugins.tab', () => ctx.slots.register({\n name: 'settings.plugins.tab',\n id: 'deepseek-models',\n order: 21,\n label: () => t('tab.models'),\n locale: LOCALE_NS,\n inject: (): ModelsTabInjected => ({ loadModels }),\n }, ModelsTab))\n}\n"],"mappings":";;;;;;;;;;EACA,MAAa,gBAAgB;;EAG7B,MAAa,eAAe;;;ECD5B,MAAa,YAAY;;EAGzB,MAAa,KAAK;GAChB,cAAc;GACd,eAAe;GACf,cAAc;GACd,kBAAkB;GAClB,iBAAiB;GACjB,gBAAgB;GAChB,mBAAmB;GACnB,mBAAmB;GACnB,qBAAqB;GACrB,uBAAuB;GACvB,iBAAiB;GACjB,oBAAoB;GACpB,mBAAmB;GACnB,gBAAgB;GAChB,eAAe;GACf,kBAAkB;GAClB,kBAAkB;GAClB,gBAAgB;GAChB,gBAAgB;GAChB,gBAAgB;GAChB,gBAAgB;GAChB,eAAe;GACf,mBAAmB;GACnB,yBAAyB;GACzB,0BAA0B;GAC1B,4BAA4B;GAC5B,yBAAyB;GACzB,sBAAsB;GACtB,wBAAwB;GACxB,0BAA0B;GAC1B,8BAA8B;EAChC;;EAYA,MAAa,KAAqC;GAChD,cAAc;GACd,eAAe;GACf,cAAc;GACd,kBAAkB;GAClB,iBAAiB;GACjB,gBAAgB;GAChB,mBAAmB;GACnB,mBAAmB;GACnB,qBAAqB;GACrB,uBAAuB;GACvB,iBAAiB;GACjB,oBAAoB;GACpB,mBAAmB;GACnB,gBAAgB;GAChB,eAAe;GACf,k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GAC3C,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,QAAQ,UAAU,OAAO,MAAM,OAAO,WACzF,MAAM,IAAI,MAAM,sBAAsB;GAExC,OAAO;EACT;EAEA,eAAe,WAAW,cAAuB,QAAiD;GAQhG,MAAM,QAAiB,OAAM,MANN,MADX,eAAe,GAAG,aAAa,cAAc,cACvB;IAChC,QAAQ;IACR,SAAS,EAAE,QAAQ,mBAAmB;IACtC,OAAO;IACP;GACF,CAAC,EAAA,CACqC,KAAK;GAC3C,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,QAAQ,UAAU,OAAO,MAAM,OAAO,WACzF,MAAM,IAAI,MAAM,sBAAsB;GAExC,OAAO;EACT;;EAGA,SAAgB,MAAM,KAA0B;GAC9C,IAAI,aACI,IAAI,OAAO,SAAS,WAAW;IAAE;IAAI;GAAG,CAAC,GAC/C,2BACF;GACA,MAAM,IAAI,IAAI,OAAO,KAAK,SAAS;GAEnC,IAAI,aAAa;IACf,MAAM,QAAQ,SAAS,cAAc,OAAO;IAC5C,MAAM,QAAQ,SAAS;IACvB,MAAM,QAAQ,YAAY;IAC1B,MAAM,cAAc;IACpB,SAAS,KAAK,OAAO,KAAK;IAC1B,aAAa;KAAE,MAAM,OAAO;IAAE;GAChC,GAAG,qBAAqB;GAExB,IAAI,MAAM,OAAO,8BAA8B,IAAI,MAAM,SAAS;IAChE,MAAM;IACN,IAAI;IACJ,OAAO;IACP,aAAa,EAAE,aAAa;IAC5B,QAAQ;IACR,eAAmC,EAAE,YAAY;GACnD,GAAG,UAAU,CAAC;GACd,IAAI,MAAM,OAAO,8BAA8B,IAAI,MAAM,SAAS;IAChE,MAAM;IACN,IAAI;IACJ,OAAO;IACP,aAAa,EAAE,YAAY;IAC3B,QAAQ;IACR,eAAkC,EAAE,WAAW;GACjD,GAAG,SAAS,CAAC;EACf"}
1
+ {"version":3,"file":"client.js","names":["useState","useMemo","useState","useCallback","useState","useCallback"],"sources":["../src/types.ts","../src/client/format.ts","../src/client/pricing.ts","../src/client/BalanceDock.tsx","../src/client/locales.ts","../src/client/BalanceTab.tsx","../src/client/ModelsTab.tsx","../src/client/DeepSeekPanel.tsx","../src/client/styles.ts","../src/client/index.tsx"],"sourcesContent":["/** The same-origin endpoint exposed by the plugin's Host half. */\nexport const BALANCE_ROUTE = '/dsh-balance/api/balance'\n\n/** The same-origin endpoint that proxies DeepSeek's `/models` API. */\nexport const MODELS_ROUTE = '/dsh-balance/api/models'\n\n/** One currency row returned by DeepSeek's `/user/balance` API. */\nexport interface BalanceInfo {\n currency: string\n totalBalance: string\n grantedBalance: string\n toppedUpBalance: string\n}\n\n/** A successful, browser-safe balance response. */\nexport interface BalanceSuccess {\n ok: true\n isAvailable: boolean\n balanceInfos: BalanceInfo[]\n fetchedAt: string\n source: 'live' | 'cache'\n}\n\nexport type DeepSeekApiErrorCode =\n | 'FORBIDDEN'\n | 'INVALID_API_KEY'\n | 'INVALID_RESPONSE'\n | 'METHOD_NOT_ALLOWED'\n | 'MISSING_API_KEY'\n | 'RATE_LIMITED'\n | 'UPSTREAM_ERROR'\n | 'UPSTREAM_TIMEOUT'\n | 'UPSTREAM_UNAVAILABLE'\n\n/** @deprecated Prefer the feature-neutral `DeepSeekApiErrorCode`. */\nexport type BalanceErrorCode = DeepSeekApiErrorCode\n\n/** A failed, browser-safe response. It intentionally contains no upstream body or credential. */\nexport interface BalanceFailure {\n ok: false\n code: DeepSeekApiErrorCode\n message: string\n}\n\nexport type BalanceApiResponse = BalanceSuccess | BalanceFailure\n\n/** One model returned by DeepSeek's `/models` API. */\nexport interface ModelInfo {\n id: string\n ownedBy: string\n}\n\n/** A successful, browser-safe model-list response. */\nexport interface ModelsSuccess {\n ok: true\n models: ModelInfo[]\n fetchedAt: string\n source: 'live' | 'cache'\n}\n\nexport type ModelsFailure = BalanceFailure\nexport type ModelsApiResponse = ModelsSuccess | ModelsFailure\n","export function formatClockTime(date: Date, locale: string): string {\n return new Intl.DateTimeFormat(locale, { hour: '2-digit', minute: '2-digit' }).format(date)\n}\n\nexport function displayAmount(value: string, currency: string, locale: string): string {\n const amount = Number(value)\n if (!Number.isFinite(amount)) return `${value} ${currency}`\n\n try {\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n minimumFractionDigits: 2,\n maximumFractionDigits: 8,\n }).format(amount)\n } catch {\n return `${value} ${currency}`\n }\n}\n","/**\n * DeepSeek API peak / off-peak pricing schedule.\n *\n * Official announcement (effective 2026-08-17, Beijing time):\n * peak: 09:00–12:00 and 14:00–18:00 (UTC+8)\n * off-peak: everything else, billed at half the peak price\n *\n * Windows are half-open: [09:00, 12:00) and [14:00, 18:00).\n */\n\nconst BEIJING_OFFSET_MS = 8 * 60 * 60 * 1000\n\n/** The scheme goes live at 00:00 Beijing time on 2026-08-17. */\nexport const PEAK_EFFECTIVE_FROM = Date.parse('2026-08-17T00:00:00+08:00')\n\nconst PEAK_WINDOWS: ReadonlyArray<readonly [number, number]> = [\n [9, 12],\n [14, 18],\n]\n\nconst HOUR_MS = 60 * 60 * 1000\nconst DAY_MS = 24 * HOUR_MS\nconst BOUNDARY_SECONDS = [9 * 3600, 12 * 3600, 14 * 3600, 18 * 3600] as const\n\n/** Hour of day in Beijing time (UTC+8), 0–23. */\nfunction beijingHour(date: Date): number {\n return new Date(date.getTime() + BEIJING_OFFSET_MS).getUTCHours()\n}\n\n/** Whether the given instant falls inside a DeepSeek peak-pricing window. */\nexport function isPeakHour(date: Date): boolean {\n if (date.getTime() < PEAK_EFFECTIVE_FROM) return false\n const hour = beijingHour(date)\n return PEAK_WINDOWS.some(([start, end]) => hour >= start && hour < end)\n}\n\n/** The next instant at which the current pricing period ends (Beijing time). */\nexport function nextPeriodChange(date: Date): Date {\n const ms = date.getTime()\n const beijing = new Date(ms + BEIJING_OFFSET_MS)\n const secondsIntoDay = beijing.getUTCHours() * 3600\n + beijing.getUTCMinutes() * 60\n + beijing.getUTCSeconds()\n\n let boundary = BOUNDARY_SECONDS.find(seconds => secondsIntoDay < seconds)\n if (boundary === undefined) {\n // After 18:00: the next boundary is tomorrow 09:00 Beijing time.\n boundary = 9 * 3600 + DAY_MS / 1000\n }\n\n const dayStartMs = Math.floor(ms / DAY_MS) * DAY_MS\n return new Date(dayStartMs + boundary * 1000 - BEIJING_OFFSET_MS)\n}\n","import { useEffect, useMemo, useState } from 'react'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { BalanceApiResponse } from '../types.ts'\nimport { displayAmount, formatClockTime } from './format.ts'\nimport type { LOCALE_NS } from './locales.ts'\nimport { isPeakHour, nextPeriodChange, PEAK_EFFECTIVE_FROM } from './pricing.ts'\n\nconst REFRESH_INTERVAL_MS = 60_000\nconst PEAK_TICK_MS = 30_000\n\nexport interface BalanceDockInjected {\n loadBalance: (forceRefresh: boolean, signal: AbortSignal) => Promise<BalanceApiResponse>\n}\n\nexport type BalanceDockProps = PropsRuntime<'conversation.composer.dock'>\n & InjectFace<BalanceDockInjected>\n & PropsLocale<typeof LOCALE_NS>\n\n/** Compact ambient balance readout below the active-session composer card. */\nexport function BalanceDock({ loadBalance, t }: BalanceDockProps) {\n const [result, setResult] = useState<BalanceApiResponse>()\n const [now, setNow] = useState(() => new Date())\n\n useEffect(() => {\n const timer = window.setInterval(() => setNow(new Date()), PEAK_TICK_MS)\n return () => { window.clearInterval(timer) }\n }, [])\n\n useEffect(() => {\n let controller: AbortController | undefined\n\n const load = () => {\n controller?.abort()\n controller = new AbortController()\n const signal = controller.signal\n void loadBalance(false, signal).then((value) => {\n if (!signal.aborted) setResult(value)\n }).catch(() => {\n if (!signal.aborted) {\n setResult({ ok: false, code: 'UPSTREAM_UNAVAILABLE', message: '' })\n }\n })\n }\n\n load()\n const timer = window.setInterval(load, REFRESH_INTERVAL_MS)\n return () => {\n window.clearInterval(timer)\n controller?.abort()\n }\n }, [loadBalance])\n\n const summary = useMemo(() => {\n if (result === undefined) return t('dock.loading')\n if (!result.ok) return t('dock.unavailable')\n if (result.balanceInfos.length === 0) return t('dock.empty')\n return result.balanceInfos\n .map(info => `${info.currency} ${displayAmount(info.totalBalance, info.currency, t('locale.tag'))}`)\n .join(' · ')\n }, [result, t])\n\n const state = result === undefined\n ? 'loading'\n : result.ok && result.isAvailable\n ? 'available'\n : result.ok\n ? 'empty'\n : 'error'\n\n const accessibleState = result?.ok === true\n ? t(result.isAvailable ? 'balance.available' : 'balance.unavailable')\n : undefined\n\n const pricingActive = now.getTime() >= PEAK_EFFECTIVE_FROM\n const isPeak = pricingActive && isPeakHour(now)\n const periodLabel = pricingActive ? t(isPeak ? 'pricing.peak' : 'pricing.offPeak') : undefined\n const periodTitle = pricingActive\n ? t(isPeak ? 'pricing.peakHint' : 'pricing.offPeakHint', {\n time: formatClockTime(nextPeriodChange(now), t('locale.tag')),\n })\n : undefined\n\n return (\n <div\n className=\"dsh-balance-dock\"\n role=\"status\"\n aria-live=\"polite\"\n title={periodTitle}\n aria-label={`${t('dock.label')}: ${summary}${accessibleState === undefined ? '' : `. ${accessibleState}`}${periodLabel === undefined ? '' : `. ${periodLabel}`}`}\n >\n <span className=\"dsh-balance-dock-dot\" data-state={state} data-peak={isPeak ? 'true' : undefined} aria-hidden=\"true\" />\n <span>{t('dock.label')}</span>\n <span className=\"dsh-balance-dock-separator\" aria-hidden=\"true\">|</span>\n <span className=\"dsh-balance-dock-value\">{summary}</span>\n </div>\n )\n}\n","import type { LocaleDictOf } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { DeepSeekApiErrorCode } from '../types.ts'\n\nexport const LOCALE_NS = 'dsh-balance'\n\n/** Simplified Chinese dictionary and source of truth for the namespace key set. */\nexport const zh = {\n 'locale.tag': 'zh-CN',\n 'nav.balance': 'DeepSeek 余额',\n 'action.loading': '查询中…',\n 'balance.title': 'DeepSeek API 余额',\n 'balance.copy': '余额由本机 Host 使用已保存的 API 密钥查询,密钥不会发送到浏览器。',\n 'balance.refresh': '刷新余额',\n 'balance.loading': '正在查询 DeepSeek 账户余额…',\n 'balance.available': '当前账户有可用余额',\n 'balance.unavailable': '当前账户没有可用余额',\n 'balance.empty': 'DeepSeek 未返回任何币种余额。',\n 'balance.toppedUp': '充值余额',\n 'balance.granted': '赠送余额',\n 'dock.label': 'DeepSeek 余额',\n 'dock.loading': '查询中…',\n 'dock.unavailable': '暂时无法获取',\n 'dock.empty': '暂无余额信息',\n 'models.title': 'DeepSeek 可用模型',\n 'models.copy': '从 DeepSeek 官方 /models 接口读取当前 API Key 可访问的模型。',\n 'models.refresh': '刷新模型',\n 'models.loading': '正在查询 DeepSeek 模型列表…',\n 'models.count': '当前可用 {count} 个模型',\n 'models.empty': 'DeepSeek 未返回任何可用模型。',\n 'models.owner': '由 {owner} 提供',\n 'pricing.peak': '高峰时段',\n 'pricing.offPeak': '低谷时段',\n 'pricing.peakHint': 'DeepSeek 高峰时段,API 价格为低谷的两倍,{time} 恢复低谷价',\n 'pricing.offPeakHint': 'DeepSeek 低谷时段,API 价格为高峰的一半,{time} 进入高峰',\n 'meta.updated': '更新于 {time}',\n 'meta.cached': ' · 缓存',\n 'error.FORBIDDEN': '此查询仅允许从本机访问',\n 'error.INVALID_API_KEY': 'DeepSeek API 密钥无效或没有查询权限',\n 'error.INVALID_RESPONSE': 'DeepSeek 返回了无法识别的响应',\n 'error.METHOD_NOT_ALLOWED': '请求方法不受支持',\n 'error.MISSING_API_KEY': '未配置 DeepSeek API 密钥,请先在“模型”设置中保存',\n 'error.RATE_LIMITED': 'DeepSeek API 请求过于频繁,请稍后重试',\n 'error.UPSTREAM_ERROR': 'DeepSeek API 返回了错误',\n 'error.UPSTREAM_TIMEOUT': '查询 DeepSeek API 超时',\n 'error.UPSTREAM_UNAVAILABLE': '无法连接到 DeepSeek API',\n} as const\n\nexport type DshBalanceLocaleKey = keyof typeof zh\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** Balance and model-list settings copy owned by this plugin. */\n 'dsh-balance': DshBalanceLocaleKey\n }\n}\n\n/** English dictionary, checked complete against the Chinese key set. */\nexport const en: LocaleDictOf<typeof LOCALE_NS> = {\n 'locale.tag': 'en-US',\n 'nav.balance': 'DeepSeek Balance',\n 'action.loading': 'Loading…',\n 'balance.title': 'DeepSeek API Balance',\n 'balance.copy': 'The local Host queries your balance with the saved API key. The key is never sent to the browser.',\n 'balance.refresh': 'Refresh balance',\n 'balance.loading': 'Loading your DeepSeek API balance…',\n 'balance.available': 'This account has available balance',\n 'balance.unavailable': 'This account has no available balance',\n 'balance.empty': 'DeepSeek returned no currency balances.',\n 'balance.toppedUp': 'Topped-up balance',\n 'balance.granted': 'Granted balance',\n 'dock.label': 'DeepSeek Balance',\n 'dock.loading': 'Loading…',\n 'dock.unavailable': 'Temporarily unavailable',\n 'dock.empty': 'No balance information',\n 'models.title': 'Available DeepSeek Models',\n 'models.copy': 'Lists the models available to the current API key using the official DeepSeek /models endpoint.',\n 'models.refresh': 'Refresh models',\n 'models.loading': 'Loading the DeepSeek model list…',\n 'models.count': '{count} models available',\n 'models.empty': 'DeepSeek returned no available models.',\n 'models.owner': 'Provided by {owner}',\n 'pricing.peak': 'Peak hours',\n 'pricing.offPeak': 'Off-peak hours',\n 'pricing.peakHint': 'DeepSeek peak hours — API prices are double. Off-peak pricing resumes at {time}',\n 'pricing.offPeakHint': 'DeepSeek off-peak hours — API prices are halved. Peak pricing starts at {time}',\n 'meta.updated': 'Updated {time}',\n 'meta.cached': ' · Cached',\n 'error.FORBIDDEN': 'This query is available only from the local machine',\n 'error.INVALID_API_KEY': 'The DeepSeek API key is invalid or lacks permission',\n 'error.INVALID_RESPONSE': 'DeepSeek returned an unrecognized response',\n 'error.METHOD_NOT_ALLOWED': 'This request method is not supported',\n 'error.MISSING_API_KEY': 'No DeepSeek API key is configured. Save one in Models settings first.',\n 'error.RATE_LIMITED': 'Too many DeepSeek API requests. Try again later.',\n 'error.UPSTREAM_ERROR': 'The DeepSeek API returned an error',\n 'error.UPSTREAM_TIMEOUT': 'The DeepSeek API request timed out',\n 'error.UPSTREAM_UNAVAILABLE': 'Could not connect to the DeepSeek API',\n}\n\nexport function errorLocaleKey(code: DeepSeekApiErrorCode): DshBalanceLocaleKey {\n return `error.${code}`\n}\n","import { useCallback, useEffect, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { BalanceApiResponse, BalanceInfo } from '../types.ts'\nimport { displayAmount } from './format.ts'\nimport { errorLocaleKey } from './locales.ts'\nimport type { LOCALE_NS } from './locales.ts'\n\nexport interface BalanceTabInjected {\n loadBalance: (forceRefresh: boolean, signal: AbortSignal) => Promise<BalanceApiResponse>\n}\n\nexport type BalanceTabProps = BalanceTabInjected & PropsLocale<typeof LOCALE_NS>\n\nfunction BalanceCard({ info, t }: { info: BalanceInfo; t: BalanceTabProps['t'] }) {\n return (\n <article className=\"dsh-balance-card\">\n <div className=\"dsh-balance-card-head\">\n <span className=\"dsh-balance-currency\">{info.currency}</span>\n </div>\n <p className=\"dsh-balance-total\">{displayAmount(info.totalBalance, info.currency, t('locale.tag'))}</p>\n <dl className=\"dsh-balance-breakdown\">\n <dt>{t('balance.toppedUp')}</dt>\n <dd>{displayAmount(info.toppedUpBalance, info.currency, t('locale.tag'))}</dd>\n <dt>{t('balance.granted')}</dt>\n <dd>{displayAmount(info.grantedBalance, info.currency, t('locale.tag'))}</dd>\n </dl>\n </article>\n )\n}\n\nexport function BalanceSection({ loadBalance, t }: BalanceTabProps) {\n const [result, setResult] = useState<BalanceApiResponse>()\n const [loading, setLoading] = useState(true)\n\n const load = useCallback(async (forceRefresh: boolean, signal: AbortSignal) => {\n setLoading(true)\n try {\n setResult(await loadBalance(forceRefresh, signal))\n } catch (error) {\n if (signal.aborted) return\n setResult({\n ok: false,\n code: 'UPSTREAM_UNAVAILABLE',\n message: error instanceof Error ? error.message : '',\n })\n } finally {\n if (!signal.aborted) setLoading(false)\n }\n }, [loadBalance])\n\n useEffect(() => {\n const controller = new AbortController()\n void load(false, controller.signal)\n return () => { controller.abort() }\n }, [load])\n\n const refresh = () => {\n const controller = new AbortController()\n void load(true, controller.signal)\n }\n\n return (\n <section className=\"dsh-balance-section\" aria-labelledby=\"dsh-balance-title\">\n <div className=\"dsh-balance-summary\">\n <div>\n <h2 id=\"dsh-balance-title\" className=\"dsh-balance-heading\">{t('balance.title')}</h2>\n <p className=\"dsh-balance-copy\">{t('balance.copy')}</p>\n </div>\n <button className=\"dsh-balance-refresh\" type=\"button\" disabled={loading} onClick={refresh}>\n {loading ? t('action.loading') : t('balance.refresh')}\n </button>\n </div>\n\n {loading && result === undefined ? <p className=\"dsh-balance-status\" role=\"status\">{t('balance.loading')}</p> : null}\n {result?.ok === false ? <p className=\"dsh-balance-error\" role=\"alert\">{t(errorLocaleKey(result.code))}</p> : null}\n {result?.ok === true ? (\n <>\n <div className=\"dsh-balance-availability\" data-available={String(result.isAvailable)}>\n <span className=\"dsh-balance-dot\" aria-hidden=\"true\" />\n <span>{t(result.isAvailable ? 'balance.available' : 'balance.unavailable')}</span>\n </div>\n {result.balanceInfos.length > 0\n ? <div className=\"dsh-balance-grid\">{result.balanceInfos.map(info => <BalanceCard key={info.currency} info={info} t={t} />)}</div>\n : <p className=\"dsh-balance-status\">{t('balance.empty')}</p>}\n <p className=\"dsh-balance-meta\">\n {t('meta.updated', { time: new Date(result.fetchedAt).toLocaleString(t('locale.tag')) })}{result.source === 'cache' ? t('meta.cached') : ''}\n </p>\n </>\n ) : null}\n </section>\n )\n}\n\n/** @deprecated The balance view is no longer rendered as a Plugins tab. */\nexport const BalanceTab = BalanceSection\n","import { useCallback, useEffect, useState } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { ModelInfo, ModelsApiResponse } from '../types.ts'\nimport { errorLocaleKey } from './locales.ts'\nimport type { LOCALE_NS } from './locales.ts'\n\nexport interface ModelsTabInjected {\n loadModels: (forceRefresh: boolean, signal: AbortSignal) => Promise<ModelsApiResponse>\n}\n\nexport type ModelsTabProps = ModelsTabInjected & PropsLocale<typeof LOCALE_NS>\n\nfunction ModelCard({ model, t }: { model: ModelInfo; t: ModelsTabProps['t'] }) {\n return (\n <article className=\"dsh-model-card\">\n <code className=\"dsh-model-id\">{model.id}</code>\n <span className=\"dsh-model-owner\">{t('models.owner', { owner: model.ownedBy })}</span>\n </article>\n )\n}\n\nexport function ModelsSection({ loadModels, t }: ModelsTabProps) {\n const [result, setResult] = useState<ModelsApiResponse>()\n const [loading, setLoading] = useState(true)\n\n const load = useCallback(async (forceRefresh: boolean, signal: AbortSignal) => {\n setLoading(true)\n try {\n setResult(await loadModels(forceRefresh, signal))\n } catch (error) {\n if (signal.aborted) return\n setResult({\n ok: false,\n code: 'UPSTREAM_UNAVAILABLE',\n message: error instanceof Error ? error.message : '',\n })\n } finally {\n if (!signal.aborted) setLoading(false)\n }\n }, [loadModels])\n\n useEffect(() => {\n const controller = new AbortController()\n void load(false, controller.signal)\n return () => { controller.abort() }\n }, [load])\n\n const refresh = () => {\n const controller = new AbortController()\n void load(true, controller.signal)\n }\n\n return (\n <section className=\"dsh-models-section\" aria-labelledby=\"dsh-models-title\">\n <div className=\"dsh-balance-summary\">\n <div>\n <h2 id=\"dsh-models-title\" className=\"dsh-balance-heading\">{t('models.title')}</h2>\n <p className=\"dsh-balance-copy\">{t('models.copy')}</p>\n </div>\n <button className=\"dsh-balance-refresh\" type=\"button\" disabled={loading} onClick={refresh}>\n {loading ? t('action.loading') : t('models.refresh')}\n </button>\n </div>\n\n {loading && result === undefined ? <p className=\"dsh-balance-status\" role=\"status\">{t('models.loading')}</p> : null}\n {result?.ok === false ? <p className=\"dsh-balance-error\" role=\"alert\">{t(errorLocaleKey(result.code))}</p> : null}\n {result?.ok === true ? (\n <>\n <div className=\"dsh-model-count\">\n <span className=\"dsh-balance-dot\" aria-hidden=\"true\" />\n <span>{t('models.count', { count: result.models.length })}</span>\n </div>\n {result.models.length > 0\n ? <div className=\"dsh-model-grid\">{result.models.map(model => <ModelCard key={model.id} model={model} t={t} />)}</div>\n : <p className=\"dsh-balance-status\">{t('models.empty')}</p>}\n <p className=\"dsh-balance-meta\">\n {t('meta.updated', { time: new Date(result.fetchedAt).toLocaleString(t('locale.tag')) })}{result.source === 'cache' ? t('meta.cached') : ''}\n </p>\n </>\n ) : null}\n </section>\n )\n}\n\n/** @deprecated The model view is now part of the standalone DeepSeek settings panel. */\nexport const ModelsTab = ModelsSection\n","import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport { BalanceSection } from './BalanceTab.tsx'\nimport type { BalanceTabInjected } from './BalanceTab.tsx'\nimport type { LOCALE_NS } from './locales.ts'\nimport { ModelsSection } from './ModelsTab.tsx'\nimport type { ModelsTabInjected } from './ModelsTab.tsx'\n\nexport interface DeepSeekPanelInjected extends BalanceTabInjected, ModelsTabInjected {}\n\nexport type DeepSeekPanelProps = PropsRuntime<'settings.section'>\n & InjectFace<DeepSeekPanelInjected>\n & PropsLocale<typeof LOCALE_NS>\n\n/** Standalone DeepSeek settings page, placed immediately after Agent presets. */\nexport function DeepSeekPanel({ loadBalance, loadModels, t }: DeepSeekPanelProps) {\n return (\n <div className=\"dsh-deepseek-panel\">\n <BalanceSection loadBalance={loadBalance} t={t} />\n <div className=\"dsh-deepseek-divider\" aria-hidden=\"true\" />\n <ModelsSection loadModels={loadModels} t={t} />\n </div>\n )\n}\n","export const balanceStyles = `\n.dsh-deepseek-panel {\n display: flex;\n flex-direction: column;\n gap: 28px;\n max-width: 720px;\n color: var(--dsw-alias-label-primary);\n}\n.dsh-balance-section,\n.dsh-models-section {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n.dsh-deepseek-divider {\n height: 1px;\n background: var(--dsw-alias-border-l2);\n}\n.dsh-balance-summary {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n}\n.dsh-balance-heading { margin: 0; font-size: 18px; font-weight: 600; line-height: 24px; }\n.dsh-balance-copy { margin: 4px 0 0; color: var(--dsw-alias-label-tertiary); font-size: 13px; line-height: 1.5; }\n.dsh-balance-refresh {\n flex: none;\n appearance: none;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 16px;\n min-height: 32px;\n padding: 0 14px;\n background: transparent;\n color: var(--dsw-alias-label-primary);\n font: inherit;\n font-size: 13px;\n cursor: pointer;\n}\n.dsh-balance-refresh:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-balance-refresh:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }\n.dsh-balance-refresh:disabled { cursor: default; opacity: .55; }\n.dsh-balance-status,\n.dsh-balance-error {\n margin: 0;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 18px;\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-secondary);\n font-size: 13px;\n line-height: 1.6;\n}\n.dsh-balance-error { color: var(--dsw-alias-state-error-primary); }\n.dsh-balance-availability { display: flex; align-items: center; gap: 8px; font-size: 13px; }\n.dsh-balance-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--dsw-alias-state-error-primary); }\n.dsh-balance-availability[data-available='true'] .dsh-balance-dot { background: var(--dsw-alias-state-success-primary); }\n.dsh-balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }\n.dsh-balance-card {\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 16px;\n background: var(--dsw-alias-bg-layer-3);\n}\n.dsh-balance-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }\n.dsh-balance-currency { color: var(--dsw-alias-label-tertiary); font-size: 12px; font-weight: 600; letter-spacing: .04em; }\n.dsh-balance-total { margin: 12px 0 16px; font-size: 28px; font-weight: 650; line-height: 1.15; }\n.dsh-balance-breakdown { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; margin: 0; font-size: 12px; }\n.dsh-balance-breakdown dt { color: var(--dsw-alias-label-tertiary); }\n.dsh-balance-breakdown dd { margin: 0; color: var(--dsw-alias-label-secondary); font-variant-numeric: tabular-nums; }\n.dsh-balance-meta { margin: 0; color: var(--dsw-alias-label-tertiary); font-size: 12px; }\n.dsh-model-count { display: flex; align-items: center; gap: 8px; font-size: 13px; }\n.dsh-model-count .dsh-balance-dot { background: var(--dsw-alias-state-success-primary); }\n.dsh-model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }\n.dsh-model-card {\n display: flex;\n flex-direction: column;\n gap: 10px;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 16px;\n background: var(--dsw-alias-bg-layer-3);\n}\n.dsh-model-id {\n color: var(--dsw-alias-label-primary);\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 15px;\n font-weight: 600;\n overflow-wrap: anywhere;\n}\n.dsh-model-owner { color: var(--dsw-alias-label-tertiary); font-size: 12px; }\n.dsh-balance-dock {\n box-sizing: border-box;\n display: block;\n width: 100%;\n max-width: var(--dsh-chat-content-width);\n margin: 0 auto;\n padding: 4px calc(var(--dsh-composer-side-clearance) + 16px) 0;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 20px;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.dsh-balance-dock-dot {\n display: inline-block;\n width: 6px;\n height: 6px;\n margin-right: 6px;\n border-radius: 999px;\n background: var(--dsw-alias-label-dimmed);\n vertical-align: 1px;\n}\n.dsh-balance-dock-dot[data-state='available'] { background: var(--dsw-alias-state-success-primary); }\n.dsh-balance-dock-dot[data-state='available'][data-peak='true'] { background: var(--dsw-alias-state-warn-primary); }\n.dsh-balance-dock-dot[data-state='empty'],\n.dsh-balance-dock-dot[data-state='error'] { background: var(--dsw-alias-state-error-primary); }\n.dsh-balance-dock-separator {\n margin: 0 10px;\n color: var(--dsw-alias-separator-primary);\n}\n.dsh-balance-dock-value {\n color: var(--dsw-alias-label-secondary);\n font-variant-numeric: tabular-nums;\n}\n@media (max-width: 640px) {\n .dsh-balance-summary { align-items: flex-start; }\n .dsh-balance-grid,\n .dsh-model-grid { grid-template-columns: 1fr; }\n}\n`\n","import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\nimport type { BalanceApiResponse, ModelsApiResponse } from '../types.ts'\nimport { BALANCE_ROUTE, MODELS_ROUTE } from '../types.ts'\nimport { BalanceDock } from './BalanceDock.tsx'\nimport type { BalanceDockInjected } from './BalanceDock.tsx'\nimport { DeepSeekPanel } from './DeepSeekPanel.tsx'\nimport type { DeepSeekPanelInjected } from './DeepSeekPanel.tsx'\nimport { en, LOCALE_NS, zh } from './locales.ts'\nimport { balanceStyles } from './styles.ts'\n\nexport type { BalanceTabInjected, BalanceTabProps } from './BalanceTab.tsx'\nexport type { BalanceDockInjected, BalanceDockProps } from './BalanceDock.tsx'\nexport type { DeepSeekPanelInjected, DeepSeekPanelProps } from './DeepSeekPanel.tsx'\nexport type { ModelsTabInjected, ModelsTabProps } from './ModelsTab.tsx'\n\nexport const inject = ['slots', 'locale']\n\nasync function loadBalance(forceRefresh: boolean, signal: AbortSignal): Promise<BalanceApiResponse> {\n const url = forceRefresh ? `${BALANCE_ROUTE}?refresh=1` : BALANCE_ROUTE\n const response = await fetch(url, {\n method: 'GET',\n headers: { accept: 'application/json' },\n cache: 'no-store',\n signal,\n })\n const value: unknown = await response.json()\n if (typeof value !== 'object' || value === null || !('ok' in value) || typeof value.ok !== 'boolean') {\n throw new Error('余额插件收到了无法识别的 Host 响应')\n }\n return value as BalanceApiResponse\n}\n\nasync function loadModels(forceRefresh: boolean, signal: AbortSignal): Promise<ModelsApiResponse> {\n const url = forceRefresh ? `${MODELS_ROUTE}?refresh=1` : MODELS_ROUTE\n const response = await fetch(url, {\n method: 'GET',\n headers: { accept: 'application/json' },\n cache: 'no-store',\n signal,\n })\n const value: unknown = await response.json()\n if (typeof value !== 'object' || value === null || !('ok' in value) || typeof value.ok !== 'boolean') {\n throw new Error('模型插件收到了无法识别的 Host 响应')\n }\n return value as ModelsApiResponse\n}\n\n/** Register a standalone Settings page and an ambient composer balance readout. */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(\n () => ctx.locale.register(LOCALE_NS, { zh, en }),\n 'dsh-balance: dictionaries',\n )\n const t = ctx.locale.bind(LOCALE_NS)\n\n ctx.effect(() => {\n const style = document.createElement('style')\n style.dataset.plugin = 'dsh-balance'\n style.dataset.pluginCss = 'dsh-balance/styles'\n style.textContent = balanceStyles\n document.head.append(style)\n return () => { style.remove() }\n }, 'dsh-balance: styles')\n\n ctx.slots.inject('settings.section', () => ctx.slots.register({\n name: 'settings.section',\n id: 'deepseek-balance',\n order: 21,\n label: () => t('nav.balance'),\n locale: LOCALE_NS,\n inject: (): DeepSeekPanelInjected => ({ loadBalance, loadModels }),\n }, DeepSeekPanel))\n\n ctx.slots.inject('conversation.composer.dock', () => ctx.slots.register({\n name: 'conversation.composer.dock',\n id: 'deepseek-balance',\n order: 10,\n locale: LOCALE_NS,\n inject: (): BalanceDockInjected => ({ loadBalance }),\n }, BalanceDock))\n}\n"],"mappings":";;;;;;;;;;EACA,MAAa,gBAAgB;;EAG7B,MAAa,eAAe;;;ECJ5B,SAAgB,gBAAgB,MAAY,QAAwB;GAClE,OAAO,IAAI,KAAK,eAAe,QAAQ;IAAE,MAAM;IAAW,QAAQ;GAAU,CAAC,CAAC,CAAC,OAAO,IAAI;EAC5F;EAEA,SAAgB,cAAc,OAAe,UAAkB,QAAwB;GACrF,MAAM,SAAS,OAAO,KAAK;GAC3B,IAAI,CAAC,OAAO,SAAS,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG;GAEjD,IAAI;IACF,OAAO,IAAI,KAAK,aAAa,QAAQ;KACnC,OAAO;KACP;KACA,uBAAuB;KACvB,uBA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I,IAAI,OAAO,KAAK,SAAS;GAEnC,IAAI,aAAa;IACf,MAAM,QAAQ,SAAS,cAAc,OAAO;IAC5C,MAAM,QAAQ,SAAS;IACvB,MAAM,QAAQ,YAAY;IAC1B,MAAM,cAAc;IACpB,SAAS,KAAK,OAAO,KAAK;IAC1B,aAAa;KAAE,MAAM,OAAO;IAAE;GAChC,GAAG,qBAAqB;GAExB,IAAI,MAAM,OAAO,0BAA0B,IAAI,MAAM,SAAS;IAC5D,MAAM;IACN,IAAI;IACJ,OAAO;IACP,aAAa,EAAE,aAAa;IAC5B,QAAQ;IACR,eAAsC;KAAE;KAAa;IAAW;GAClE,GAAG,aAAa,CAAC;GAEjB,IAAI,MAAM,OAAO,oCAAoC,IAAI,MAAM,SAAS;IACtE,MAAM;IACN,IAAI;IACJ,OAAO;IACP,QAAQ;IACR,eAAoC,EAAE,YAAY;GACpD,GAAG,WAAW,CAAC;EACjB"}
@@ -0,0 +1,9 @@
1
+ import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
2
+ import type { BalanceApiResponse } from '../types.ts';
3
+ import type { LOCALE_NS } from './locales.ts';
4
+ export interface BalanceDockInjected {
5
+ loadBalance: (forceRefresh: boolean, signal: AbortSignal) => Promise<BalanceApiResponse>;
6
+ }
7
+ export type BalanceDockProps = PropsRuntime<'conversation.composer.dock'> & InjectFace<BalanceDockInjected> & PropsLocale<typeof LOCALE_NS>;
8
+ /** Compact ambient balance readout below the active-session composer card. */
9
+ export declare function BalanceDock({ loadBalance, t }: BalanceDockProps): import("react").JSX.Element;
@@ -1,8 +1,10 @@
1
- import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
1
+ import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
2
2
  import type { BalanceApiResponse } from '../types.ts';
3
3
  import type { LOCALE_NS } from './locales.ts';
4
4
  export interface BalanceTabInjected {
5
5
  loadBalance: (forceRefresh: boolean, signal: AbortSignal) => Promise<BalanceApiResponse>;
6
6
  }
7
- export type BalanceTabProps = PropsRuntime<'settings.plugins.tab'> & InjectFace<BalanceTabInjected> & PropsLocale<typeof LOCALE_NS>;
8
- export declare function BalanceTab({ loadBalance, t }: BalanceTabProps): import("react").JSX.Element;
7
+ export type BalanceTabProps = BalanceTabInjected & PropsLocale<typeof LOCALE_NS>;
8
+ export declare function BalanceSection({ loadBalance, t }: BalanceTabProps): import("react").JSX.Element;
9
+ /** @deprecated The balance view is no longer rendered as a Plugins tab. */
10
+ export declare const BalanceTab: typeof BalanceSection;
@@ -0,0 +1,9 @@
1
+ import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
2
+ import type { BalanceTabInjected } from './BalanceTab.tsx';
3
+ import type { LOCALE_NS } from './locales.ts';
4
+ import type { ModelsTabInjected } from './ModelsTab.tsx';
5
+ export interface DeepSeekPanelInjected extends BalanceTabInjected, ModelsTabInjected {
6
+ }
7
+ export type DeepSeekPanelProps = PropsRuntime<'settings.section'> & InjectFace<DeepSeekPanelInjected> & PropsLocale<typeof LOCALE_NS>;
8
+ /** Standalone DeepSeek settings page, placed immediately after Agent presets. */
9
+ export declare function DeepSeekPanel({ loadBalance, loadModels, t }: DeepSeekPanelProps): import("react").JSX.Element;
@@ -1,8 +1,10 @@
1
- import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
1
+ import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
2
2
  import type { ModelsApiResponse } from '../types.ts';
3
3
  import type { LOCALE_NS } from './locales.ts';
4
4
  export interface ModelsTabInjected {
5
5
  loadModels: (forceRefresh: boolean, signal: AbortSignal) => Promise<ModelsApiResponse>;
6
6
  }
7
- export type ModelsTabProps = PropsRuntime<'settings.plugins.tab'> & InjectFace<ModelsTabInjected> & PropsLocale<typeof LOCALE_NS>;
8
- export declare function ModelsTab({ loadModels, t }: ModelsTabProps): import("react").JSX.Element;
7
+ export type ModelsTabProps = ModelsTabInjected & PropsLocale<typeof LOCALE_NS>;
8
+ export declare function ModelsSection({ loadModels, t }: ModelsTabProps): import("react").JSX.Element;
9
+ /** @deprecated The model view is now part of the standalone DeepSeek settings panel. */
10
+ export declare const ModelsTab: typeof ModelsSection;
@@ -0,0 +1,2 @@
1
+ export declare function formatClockTime(date: Date, locale: string): string;
2
+ export declare function displayAmount(value: string, currency: string, locale: string): string;
@@ -1,6 +1,8 @@
1
1
  import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
2
2
  export type { BalanceTabInjected, BalanceTabProps } from './BalanceTab.tsx';
3
+ export type { BalanceDockInjected, BalanceDockProps } from './BalanceDock.tsx';
4
+ export type { DeepSeekPanelInjected, DeepSeekPanelProps } from './DeepSeekPanel.tsx';
3
5
  export type { ModelsTabInjected, ModelsTabProps } from './ModelsTab.tsx';
4
6
  export declare const inject: string[];
5
- /** Register one feature-owned page inside the existing Plugins settings section. */
7
+ /** Register a standalone Settings page and an ambient composer balance readout. */
6
8
  export declare function apply(ctx: ClientContext): void;
@@ -4,8 +4,7 @@ export declare const LOCALE_NS = "dsh-balance";
4
4
  /** Simplified Chinese dictionary and source of truth for the namespace key set. */
5
5
  export declare const zh: {
6
6
  readonly 'locale.tag': "zh-CN";
7
- readonly 'tab.balance': "DeepSeek 余额";
8
- readonly 'tab.models': "DeepSeek 模型";
7
+ readonly 'nav.balance': "DeepSeek 余额";
9
8
  readonly 'action.loading': "查询中…";
10
9
  readonly 'balance.title': "DeepSeek API 余额";
11
10
  readonly 'balance.copy': "余额由本机 Host 使用已保存的 API 密钥查询,密钥不会发送到浏览器。";
@@ -16,6 +15,10 @@ export declare const zh: {
16
15
  readonly 'balance.empty': "DeepSeek 未返回任何币种余额。";
17
16
  readonly 'balance.toppedUp': "充值余额";
18
17
  readonly 'balance.granted': "赠送余额";
18
+ readonly 'dock.label': "DeepSeek 余额";
19
+ readonly 'dock.loading': "查询中…";
20
+ readonly 'dock.unavailable': "暂时无法获取";
21
+ readonly 'dock.empty': "暂无余额信息";
19
22
  readonly 'models.title': "DeepSeek 可用模型";
20
23
  readonly 'models.copy': "从 DeepSeek 官方 /models 接口读取当前 API Key 可访问的模型。";
21
24
  readonly 'models.refresh': "刷新模型";
@@ -23,6 +26,10 @@ export declare const zh: {
23
26
  readonly 'models.count': "当前可用 {count} 个模型";
24
27
  readonly 'models.empty': "DeepSeek 未返回任何可用模型。";
25
28
  readonly 'models.owner': "由 {owner} 提供";
29
+ readonly 'pricing.peak': "高峰时段";
30
+ readonly 'pricing.offPeak': "低谷时段";
31
+ readonly 'pricing.peakHint': "DeepSeek 高峰时段,API 价格为低谷的两倍,{time} 恢复低谷价";
32
+ readonly 'pricing.offPeakHint': "DeepSeek 低谷时段,API 价格为高峰的一半,{time} 进入高峰";
26
33
  readonly 'meta.updated': "更新于 {time}";
27
34
  readonly 'meta.cached': " · 缓存";
28
35
  readonly 'error.FORBIDDEN': "此查询仅允许从本机访问";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * DeepSeek API peak / off-peak pricing schedule.
3
+ *
4
+ * Official announcement (effective 2026-08-17, Beijing time):
5
+ * peak: 09:00–12:00 and 14:00–18:00 (UTC+8)
6
+ * off-peak: everything else, billed at half the peak price
7
+ *
8
+ * Windows are half-open: [09:00, 12:00) and [14:00, 18:00).
9
+ */
10
+ /** The scheme goes live at 00:00 Beijing time on 2026-08-17. */
11
+ export declare const PEAK_EFFECTIVE_FROM: number;
12
+ /** Whether the given instant falls inside a DeepSeek peak-pricing window. */
13
+ export declare function isPeakHour(date: Date): boolean;
14
+ /** The next instant at which the current pricing period ends (Beijing time). */
15
+ export declare function nextPeriodChange(date: Date): Date;
@@ -1 +1 @@
1
- export declare const balanceStyles = "\n.dsh-balance-tab {\n display: flex;\n flex-direction: column;\n gap: 14px;\n max-width: 760px;\n color: var(--dsw-alias-label-primary);\n}\n.dsh-balance-summary {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n}\n.dsh-balance-heading { margin: 0; font-size: 18px; font-weight: 600; }\n.dsh-balance-copy { margin: 4px 0 0; color: var(--dsw-alias-label-tertiary); font-size: 13px; line-height: 1.5; }\n.dsh-balance-refresh {\n flex: none;\n appearance: none;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 8px;\n padding: 6px 13px;\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-primary);\n font: inherit;\n font-size: 13px;\n cursor: pointer;\n}\n.dsh-balance-refresh:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-balance-refresh:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }\n.dsh-balance-refresh:disabled { cursor: default; opacity: .55; }\n.dsh-balance-status,\n.dsh-balance-error {\n margin: 0;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 18px;\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-secondary);\n font-size: 13px;\n line-height: 1.6;\n}\n.dsh-balance-error { color: var(--dsw-alias-state-error-primary); }\n.dsh-balance-availability { display: flex; align-items: center; gap: 8px; font-size: 13px; }\n.dsh-balance-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--dsw-alias-state-error-primary); }\n.dsh-balance-availability[data-available='true'] .dsh-balance-dot { background: var(--dsw-alias-state-success-primary); }\n.dsh-balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }\n.dsh-balance-card {\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 16px;\n background: var(--dsw-alias-bg-layer-3);\n}\n.dsh-balance-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }\n.dsh-balance-currency { color: var(--dsw-alias-label-tertiary); font-size: 12px; font-weight: 600; letter-spacing: .04em; }\n.dsh-balance-total { margin: 12px 0 16px; font-size: 28px; font-weight: 650; line-height: 1.15; }\n.dsh-balance-breakdown { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; margin: 0; font-size: 12px; }\n.dsh-balance-breakdown dt { color: var(--dsw-alias-label-tertiary); }\n.dsh-balance-breakdown dd { margin: 0; color: var(--dsw-alias-label-secondary); font-variant-numeric: tabular-nums; }\n.dsh-balance-meta { margin: 0; color: var(--dsw-alias-label-tertiary); font-size: 12px; }\n.dsh-models-tab {\n display: flex;\n flex-direction: column;\n gap: 14px;\n max-width: 760px;\n color: var(--dsw-alias-label-primary);\n}\n.dsh-model-count { display: flex; align-items: center; gap: 8px; font-size: 13px; }\n.dsh-model-count .dsh-balance-dot { background: var(--dsw-alias-state-success-primary); }\n.dsh-model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }\n.dsh-model-card {\n display: flex;\n flex-direction: column;\n gap: 10px;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 16px;\n background: var(--dsw-alias-bg-layer-3);\n}\n.dsh-model-id {\n color: var(--dsw-alias-label-primary);\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 15px;\n font-weight: 600;\n overflow-wrap: anywhere;\n}\n.dsh-model-owner { color: var(--dsw-alias-label-tertiary); font-size: 12px; }\n";
1
+ export declare const balanceStyles = "\n.dsh-deepseek-panel {\n display: flex;\n flex-direction: column;\n gap: 28px;\n max-width: 720px;\n color: var(--dsw-alias-label-primary);\n}\n.dsh-balance-section,\n.dsh-models-section {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n.dsh-deepseek-divider {\n height: 1px;\n background: var(--dsw-alias-border-l2);\n}\n.dsh-balance-summary {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n}\n.dsh-balance-heading { margin: 0; font-size: 18px; font-weight: 600; line-height: 24px; }\n.dsh-balance-copy { margin: 4px 0 0; color: var(--dsw-alias-label-tertiary); font-size: 13px; line-height: 1.5; }\n.dsh-balance-refresh {\n flex: none;\n appearance: none;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 16px;\n min-height: 32px;\n padding: 0 14px;\n background: transparent;\n color: var(--dsw-alias-label-primary);\n font: inherit;\n font-size: 13px;\n cursor: pointer;\n}\n.dsh-balance-refresh:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-balance-refresh:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }\n.dsh-balance-refresh:disabled { cursor: default; opacity: .55; }\n.dsh-balance-status,\n.dsh-balance-error {\n margin: 0;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 18px;\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-secondary);\n font-size: 13px;\n line-height: 1.6;\n}\n.dsh-balance-error { color: var(--dsw-alias-state-error-primary); }\n.dsh-balance-availability { display: flex; align-items: center; gap: 8px; font-size: 13px; }\n.dsh-balance-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--dsw-alias-state-error-primary); }\n.dsh-balance-availability[data-available='true'] .dsh-balance-dot { background: var(--dsw-alias-state-success-primary); }\n.dsh-balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }\n.dsh-balance-card {\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 16px;\n background: var(--dsw-alias-bg-layer-3);\n}\n.dsh-balance-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }\n.dsh-balance-currency { color: var(--dsw-alias-label-tertiary); font-size: 12px; font-weight: 600; letter-spacing: .04em; }\n.dsh-balance-total { margin: 12px 0 16px; font-size: 28px; font-weight: 650; line-height: 1.15; }\n.dsh-balance-breakdown { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; margin: 0; font-size: 12px; }\n.dsh-balance-breakdown dt { color: var(--dsw-alias-label-tertiary); }\n.dsh-balance-breakdown dd { margin: 0; color: var(--dsw-alias-label-secondary); font-variant-numeric: tabular-nums; }\n.dsh-balance-meta { margin: 0; color: var(--dsw-alias-label-tertiary); font-size: 12px; }\n.dsh-model-count { display: flex; align-items: center; gap: 8px; font-size: 13px; }\n.dsh-model-count .dsh-balance-dot { background: var(--dsw-alias-state-success-primary); }\n.dsh-model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }\n.dsh-model-card {\n display: flex;\n flex-direction: column;\n gap: 10px;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n padding: 16px;\n background: var(--dsw-alias-bg-layer-3);\n}\n.dsh-model-id {\n color: var(--dsw-alias-label-primary);\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 15px;\n font-weight: 600;\n overflow-wrap: anywhere;\n}\n.dsh-model-owner { color: var(--dsw-alias-label-tertiary); font-size: 12px; }\n.dsh-balance-dock {\n box-sizing: border-box;\n display: block;\n width: 100%;\n max-width: var(--dsh-chat-content-width);\n margin: 0 auto;\n padding: 4px calc(var(--dsh-composer-side-clearance) + 16px) 0;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 20px;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.dsh-balance-dock-dot {\n display: inline-block;\n width: 6px;\n height: 6px;\n margin-right: 6px;\n border-radius: 999px;\n background: var(--dsw-alias-label-dimmed);\n vertical-align: 1px;\n}\n.dsh-balance-dock-dot[data-state='available'] { background: var(--dsw-alias-state-success-primary); }\n.dsh-balance-dock-dot[data-state='available'][data-peak='true'] { background: var(--dsw-alias-state-warn-primary); }\n.dsh-balance-dock-dot[data-state='empty'],\n.dsh-balance-dock-dot[data-state='error'] { background: var(--dsw-alias-state-error-primary); }\n.dsh-balance-dock-separator {\n margin: 0 10px;\n color: var(--dsw-alias-separator-primary);\n}\n.dsh-balance-dock-value {\n color: var(--dsw-alias-label-secondary);\n font-variant-numeric: tabular-nums;\n}\n@media (max-width: 640px) {\n .dsh-balance-summary { align-items: flex-start; }\n .dsh-balance-grid,\n .dsh-model-grid { grid-template-columns: 1fr; }\n}\n";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pinkbanana/dsh-balance",
3
- "version": "0.3.2",
4
- "description": "DeepSeek Harness plugin that shows API balances and available models in Settings",
3
+ "version": "0.4.1",
4
+ "description": "DeepSeek Harness plugin that shows API balances and models in Settings, with balance below the chat composer",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/crazywoola/dsh-balance.git"
@@ -38,7 +38,7 @@
38
38
  "lib/client.js",
39
39
  "lib/client.js.map",
40
40
  "lib/types/**/*.d.ts",
41
- "docs/*.jpg",
41
+ "docs/*.png",
42
42
  "cordis.patch.yml",
43
43
  "LICENSE",
44
44
  "README.md",
@@ -52,14 +52,26 @@
52
52
  "platform": "web",
53
53
  "inject": [
54
54
  "@deepseek-ai/dsh-client-locale",
55
- "@deepseek-ai/dsh-client-ui-settings",
56
- "@deepseek-ai/dsh-client-ui-settings-plugins"
55
+ "@deepseek-ai/dsh-client-ui-conversation",
56
+ "@deepseek-ai/dsh-client-ui-settings"
57
57
  ]
58
58
  }
59
59
  },
60
+ "scripts": {
61
+ "build": "rimraf lib && tsc -p tsconfig.build.json && tsdown && node scripts/verify-client-bundle.mjs",
62
+ "check": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build",
63
+ "dev": "tsdown --watch",
64
+ "lint": "eslint .",
65
+ "pack:plugin": "pnpm pack",
66
+ "prepare": "pnpm run build",
67
+ "test": "vitest run",
68
+ "test:watch": "vitest",
69
+ "typecheck": "tsc --noEmit"
70
+ },
60
71
  "engines": {
61
72
  "node": ">=20"
62
73
  },
74
+ "packageManager": "pnpm@11.21.0",
63
75
  "publishConfig": {
64
76
  "access": "public"
65
77
  },
@@ -68,8 +80,8 @@
68
80
  "@deepseek-ai/cordis": "^4.0.1",
69
81
  "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.6",
70
82
  "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.6",
83
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.1.0-rc.6",
71
84
  "@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.6",
72
- "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.0-rc.6",
73
85
  "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.6",
74
86
  "@deepseek-ai/dsh-credentials": "^0.1.0-rc.6",
75
87
  "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.6",
@@ -82,8 +94,8 @@
82
94
  "@deepseek-ai/cordis": "^4.0.1",
83
95
  "@deepseek-ai/dsh-client-locale": "0.1.0-rc.6",
84
96
  "@deepseek-ai/dsh-client-runtime": "0.1.0-rc.6",
97
+ "@deepseek-ai/dsh-client-ui-conversation": "0.1.0-rc.6",
85
98
  "@deepseek-ai/dsh-client-ui-settings": "0.1.0-rc.6",
86
- "@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.0-rc.6",
87
99
  "@deepseek-ai/dsh-client-ui-slots": "0.1.0-rc.6",
88
100
  "@deepseek-ai/dsh-credentials": "0.1.0-rc.6",
89
101
  "@deepseek-ai/dsh-host-webserver": "0.1.0-rc.6",
@@ -98,15 +110,5 @@
98
110
  "typescript": "^5.9.3",
99
111
  "typescript-eslint": "^8.48.0",
100
112
  "vitest": "^4.0.15"
101
- },
102
- "scripts": {
103
- "build": "rimraf lib && tsc -p tsconfig.build.json && tsdown && node scripts/verify-client-bundle.mjs",
104
- "check": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build",
105
- "dev": "tsdown --watch",
106
- "lint": "eslint .",
107
- "pack:plugin": "pnpm pack",
108
- "test": "vitest run",
109
- "test:watch": "vitest",
110
- "typecheck": "tsc --noEmit"
111
113
  }
112
- }
114
+ }
Binary file
Binary file