@rayadesu/dsh-client-ui-billing 0.2.4 → 0.3.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/LICENSE +21 -0
- package/README.i18n.yaml +2 -2
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/client.js +69 -18
- package/lib/types/client/TurnCostAction.d.ts +7 -5
- package/lib/types/client/locales.d.ts +1 -1
- package/package.json +9 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WilliamLIiii
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# last confirmed-consistent state. Both languages carry equal authority; after
|
|
3
3
|
# editing either side, bring the other along and re-record both hashes with:
|
|
4
4
|
# git hash-object README.md README.zh.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 7d0fbbf1aac701d3c0a8bdaa6be7ad2f1b2775bb
|
|
6
|
+
README.zh.md: 77ceda46ac61f1ed1bf2cb869bad7b2bb40598f3
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Web billing feature owner: contributes one entry to `conversation.session.header
|
|
|
6
6
|
|
|
7
7
|
The trigger shows two lines — the remaining balance and this conversation's billed spend ("本轮对话花费 ¥X") — and renders nothing while the first fetch is in flight. Clicking it opens a label box with the remaining amount, this session's billed spend (本会话花费, priced per message at the official peak/off-peak rate — peak windows apply weekdays Mon–Fri only, weekends are off-peak) with today's all-session spend beside it (今日共花费), one priced row per model with the cache-hit / cache-miss-input / output cost breakdown ("缓存命中 ¥X · 未命中输入 ¥Y · 输出 ¥Z"), a manual refresh action, and a spend disclaimer. Below the model rows the panel ends with the **today session-spend ranking** (`今日会话花费`): sessions sorted by today's cost, highest first, each row carrying the session's durable title (renames sync automatically) and its amount; at most `SESSION_RANKING_LIMIT` (10) rows render, with a "…还有 N 个会话" hint for the rest. Refreshing keeps the last values visible rather than blanking them, and a refresh failure retains the last good value. A session or day without priced usage shows a "no usage recorded" word rather than a fabricated figure. A failure — no API key configured, a rejected credential, a transport error — renders a muted "Balance unavailable" word whose tooltip carries the Remote's own error message.
|
|
8
8
|
|
|
9
|
-
The package also contributes the **turn-cost entry** (`billing-turn-cost`, order 20) to ui-chat's `conversation.chat.assistant-actions` list slot — the same strip `ui-message-feedback` uses, so entries coexist. For each completed turn's closing assistant message, the entry reads `billing/getTurnSpend` (memoized per session + message, since settled turns never change) and renders
|
|
9
|
+
The package also contributes the **turn-cost entry** (`billing-turn-cost`, order 20) to ui-chat's `conversation.chat.assistant-actions` list slot — the same strip `ui-message-feedback` uses, so entries coexist; the entry uses flex `order: -1` to sit at the **front** of the actions row (before the copy control). For each completed turn's closing assistant message, the entry reads `billing/getTurnSpend` (memoized per session + message, since settled turns never change) and renders `本轮花费 ¥X` — the "本轮花费" word in the usage-card title tone and the amount in the summary tone, **always visible** (the hover rule only targets the clock text). Turns that priced to zero (no DeepSeek usage) and failed loads render nothing, so a Remote outage never clutters the row.
|
|
10
10
|
|
|
11
11
|
The badge is account-level even though the slot is session-scoped: the header utilities row is simply the one always-visible title-bar seat the shell offers, and the balance it shows does not vary by session — but the spend lines do, because they price the current session's own token usage through `billing/getSessionSpend` and every session's usage through `billing/getTodaySpend`. Copy goes through the package's own `billing` locale namespace; styling uses tokens only.
|
|
12
12
|
|
package/README.zh.md
CHANGED
|
@@ -6,7 +6,7 @@ Web 额度特性的归属方:向 `conversation.session.header.utilities` 贡
|
|
|
6
6
|
|
|
7
7
|
触发器显示两行——剩余额度与本轮对话的计费花费(「本轮对话花费 ¥X」)——首个请求在途时不渲染任何东西。点击后展开一个标签框:剩余金额、本会话的计费花费(本会话花费,按官方峰/谷单价逐条消息计价——高峰窗口仅周一至周五适用,周末按低谷价——右侧并列今日所有会话的合计「今日共花费」)、每个模型一行的花费及其缓存命中/未命中输入/输出分项(「缓存命中 ¥X · 未命中输入 ¥Y · 输出 ¥Z」)、手动刷新按钮与花费说明。模型行下方是**今日会话花费排行**(`今日会话花费`):按今日花费从高到低排列的会话列表,每行带会话的持久标题(重命名自动同步)与金额;最多渲染 `SESSION_RANKING_LIMIT`(10)行,其余以「…还有 N 个会话」提示。刷新时旧值不消失,刷新失败保留上一次有效值。没有可计价消耗的会话或日子显示「暂无消耗记录」而不是编造数字。失败——未配置 API key、凭据被拒绝、传输错误——渲染弱化的「额度不可用」,其提示携带 Remote 自己的错误信息。
|
|
8
8
|
|
|
9
|
-
本包还贡献**本轮花费条目**(`billing-turn-cost`,order 20)到 ui-chat 的 `conversation.chat.assistant-actions` list slot——与 `ui-message-feedback`
|
|
9
|
+
本包还贡献**本轮花费条目**(`billing-turn-cost`,order 20)到 ui-chat 的 `conversation.chat.assistant-actions` list slot——与 `ui-message-feedback` 同一条操作条,多条目共存;条目经 CSS `order: -1` 排到操作行**最前**(复制按钮之前)。对每条已完成回合的收尾助手消息,条目通过 `billing/getTurnSpend` 读取花费(按会话 + 消息 memo,回合落定后不再变化),渲染「本轮花费 ¥X」——「本轮花费」用卡片标题色、金额用卡片摘要色,**始终显示**(悬停规则只作用于时钟文本)。回合没有 DeepSeek 用量(花费为 0)或加载失败时不渲染,Remote 故障不会污染操作行。
|
|
10
10
|
|
|
11
11
|
角标是账户级的,尽管插槽是会话作用域:顶栏工具行不过是外壳提供的那个始终可见的标题栏席位,余额并不随会话变化——但花费行会,因为它通过 `billing/getSessionSpend` 按当前会话自己的 token 用量计价、通过 `billing/getTodaySpend` 按所有会话的用量计价。文案走本包自己的 `billing` locale 命名空间;样式只用 token。
|
|
12
12
|
|
package/lib/client.js
CHANGED
|
@@ -4298,7 +4298,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4298
4298
|
};
|
|
4299
4299
|
//#endregion
|
|
4300
4300
|
//#region \0dsh-css:C:\Users\admin\Desktop\me\code\DeepSeek-Harness-chat-billing\packages\ui-billing\src\client\BalanceBadge.module.css.mjs
|
|
4301
|
-
const css$1 = "._4_Wqcq_root{position:relative}._4_Wqcq_trigger{background:var(--dsw-alias-fill-l2);min-height:32px;color:var(--dsw-alias-label-secondary);cursor:pointer;border:0;border-radius:8px;align-items:center;gap:4px;padding:4px 8px;display:inline-flex}._4_Wqcq_trigger:hover,._4_Wqcq_trigger:focus-visible{color:var(--dsw-alias-label-primary)}._4_Wqcq_trigger svg{transition:transform .12s}._4_Wqcq_chevronOpen{transform:rotate(180deg)}._4_Wqcq_triggerLines{text-align:left;flex-direction:column;align-items:flex-start;gap:0;display:flex}._4_Wqcq_linePrimary{font-variant-numeric:tabular-nums;font-size:12px;line-height:16px}._4_Wqcq_lineSecondary{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:11px;line-height:15px}._4_Wqcq_unavailable{color:var(--dsw-alias-label-tertiary)}._4_Wqcq_inlineIcon{color:var(--dsw-alias-label-tertiary);flex:none}._4_Wqcq_spinning{color:var(--dsw-alias-label-tertiary);flex:none;animation:.8s linear infinite _4_Wqcq_spin}@keyframes _4_Wqcq_spin{to{transform:rotate(360deg)}}._4_Wqcq_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-specific-menu);width:336px;max-width:min(360px,100vw - 32px);box-shadow:var(--dsw-shadow-lv3);border-radius:12px;flex-direction:column;gap:2px;padding:6px;display:flex;position:absolute;top:calc(100% + 6px);right:0}._4_Wqcq_amountRow{border-radius:8px;justify-content:space-between;align-items:center;gap:8px;padding:6px 8px;display:flex}._4_Wqcq_amountLabel{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-size:13px;line-height:18px}._4_Wqcq_spendRow{border-top:1px solid var(--dsw-alias-border-l2);border-radius:0;justify-content:space-between;align-items:center;gap:8px;padding:6px 8px;display:flex}._4_Wqcq_costRow{align-items:center;padding:2px 8px 6px;display:flex}._4_Wqcq_costBreakdown{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:11px;line-height:16px}._4_Wqcq_amountActions{align-items:center;gap:2px;display:inline-flex}._4_Wqcq_infoButton,._4_Wqcq_refreshButton{width:24px;height:24px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}._4_Wqcq_infoButton:hover,._4_Wqcq_infoButton:focus-visible,._4_Wqcq_refreshButton:hover,._4_Wqcq_refreshButton:focus-visible{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-fill-l2)}._4_Wqcq_modelRow{border-radius:8px;justify-content:space-between;align-items:baseline;gap:8px;padding:6px 8px;display:flex}._4_Wqcq_modelName{color:var(--dsw-alias-label-secondary);flex:none;font-size:12px;line-height:18px}._4_Wqcq_tasks{text-align:right;min-width:0;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;overflow-wrap:anywhere;font-size:12px;line-height:18px}._4_Wqcq_ranking{border-top:1px solid var(--dsw-alias-border-l2);flex-direction:column;gap:0;padding-top:2px;display:flex}._4_Wqcq_rankingTitle{color:var(--dsw-alias-label-
|
|
4301
|
+
const css$1 = "._4_Wqcq_root{position:relative}._4_Wqcq_trigger{background:var(--dsw-alias-fill-l2);min-height:32px;color:var(--dsw-alias-label-secondary);cursor:pointer;border:0;border-radius:8px;align-items:center;gap:4px;padding:4px 8px;display:inline-flex}._4_Wqcq_trigger:hover,._4_Wqcq_trigger:focus-visible{color:var(--dsw-alias-label-primary)}._4_Wqcq_trigger svg{transition:transform .12s}._4_Wqcq_chevronOpen{transform:rotate(180deg)}._4_Wqcq_triggerLines{text-align:left;flex-direction:column;align-items:flex-start;gap:0;display:flex}._4_Wqcq_linePrimary{font-variant-numeric:tabular-nums;font-size:12px;line-height:16px}._4_Wqcq_lineSecondary{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:11px;line-height:15px}._4_Wqcq_unavailable{color:var(--dsw-alias-label-tertiary)}._4_Wqcq_inlineIcon{color:var(--dsw-alias-label-tertiary);flex:none}._4_Wqcq_spinning{color:var(--dsw-alias-label-tertiary);flex:none;animation:.8s linear infinite _4_Wqcq_spin}@keyframes _4_Wqcq_spin{to{transform:rotate(360deg)}}._4_Wqcq_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-specific-menu);width:336px;max-width:min(360px,100vw - 32px);box-shadow:var(--dsw-shadow-lv3);border-radius:12px;flex-direction:column;gap:2px;padding:6px;display:flex;position:absolute;top:calc(100% + 6px);right:0}._4_Wqcq_amountRow{border-radius:8px;justify-content:space-between;align-items:center;gap:8px;padding:6px 8px;display:flex}._4_Wqcq_amountLabel{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-size:13px;line-height:18px}._4_Wqcq_spendRow{border-top:1px solid var(--dsw-alias-border-l2);border-radius:0;justify-content:space-between;align-items:center;gap:8px;padding:6px 8px;display:flex}._4_Wqcq_costRow{align-items:center;padding:2px 8px 6px;display:flex}._4_Wqcq_costBreakdown{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:11px;line-height:16px}._4_Wqcq_amountActions{align-items:center;gap:2px;display:inline-flex}._4_Wqcq_infoButton,._4_Wqcq_refreshButton{width:24px;height:24px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}._4_Wqcq_infoButton:hover,._4_Wqcq_infoButton:focus-visible,._4_Wqcq_refreshButton:hover,._4_Wqcq_refreshButton:focus-visible{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-fill-l2)}._4_Wqcq_modelRow{border-radius:8px;justify-content:space-between;align-items:baseline;gap:8px;padding:6px 8px;display:flex}._4_Wqcq_modelName{color:var(--dsw-alias-label-secondary);flex:none;font-size:12px;line-height:18px}._4_Wqcq_tasks{text-align:right;min-width:0;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;overflow-wrap:anywhere;font-size:12px;line-height:18px}._4_Wqcq_ranking{border-top:1px solid var(--dsw-alias-border-l2);flex-direction:column;gap:0;padding-top:2px;display:flex}._4_Wqcq_rankingTitle{color:var(--dsw-alias-label-secondary);padding:6px 8px 2px;font-size:12px;line-height:18px}._4_Wqcq_rankingRow{border-radius:8px;align-items:baseline;gap:8px;min-width:0;padding:3px 8px;display:flex}._4_Wqcq_rankingRow:hover{background:var(--dsw-alias-fill-l2)}._4_Wqcq_rankingIndex{width:16px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;text-align:right;flex:none;font-size:11px;line-height:16px}._4_Wqcq_rankingName{min-width:0;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;text-overflow:ellipsis;white-space:nowrap;flex:1;font-size:11px;line-height:16px;overflow:hidden}._4_Wqcq_rankingAmount{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;flex:none;font-size:11px;line-height:16px}._4_Wqcq_rankingMore{color:var(--dsw-alias-label-tertiary);padding:2px 8px 4px;font-size:11px;line-height:16px}";
|
|
4302
4302
|
const tagId$1 = "@rayadesu/dsh-client-ui-billing/BalanceBadge.module.css";
|
|
4303
4303
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
4304
4304
|
const tag = document.createElement("style");
|
|
@@ -4615,7 +4615,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4615
4615
|
}
|
|
4616
4616
|
//#endregion
|
|
4617
4617
|
//#region \0dsh-css:C:\Users\admin\Desktop\me\code\DeepSeek-Harness-chat-billing\packages\ui-billing\src\client\TurnCostAction.module.css.mjs
|
|
4618
|
-
const css = ".l2XZIa_cost{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;white-space:nowrap;flex:none;font-
|
|
4618
|
+
const css = ".l2XZIa_cost{min-width:0;color:var(--dsw-alias-label-tertiary);font-size:var(--dsh-content-font-size-secondary,13px);font-variant-numeric:tabular-nums;line-height:calc(24px + var(--dsh-content-font-delta,0px));text-overflow:ellipsis;white-space:nowrap;flex:none;order:-1;align-items:center;margin-left:6px;display:inline-flex;overflow:hidden}.l2XZIa_leading{width:calc(16px + var(--dsh-content-font-delta,0px));height:calc(16px + var(--dsh-content-font-delta,0px));color:var(--dsw-alias-label-tertiary);flex:none;justify-content:center;align-items:center;margin-right:6px;display:inline-flex}.l2XZIa_leading svg{width:16px;height:16px}.l2XZIa_costLabel{color:var(--dsw-alias-label-secondary);flex:none}.l2XZIa_separator{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.l2XZIa_costValue{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}";
|
|
4619
4619
|
const tagId = "@rayadesu/dsh-client-ui-billing/TurnCostAction.module.css";
|
|
4620
4620
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
4621
4621
|
const tag = document.createElement("style");
|
|
@@ -4624,10 +4624,42 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4624
4624
|
tag.textContent = css;
|
|
4625
4625
|
document.head.appendChild(tag);
|
|
4626
4626
|
}
|
|
4627
|
-
var TurnCostAction_module_css_default = {
|
|
4627
|
+
var TurnCostAction_module_css_default = {
|
|
4628
|
+
"cost": "l2XZIa_cost",
|
|
4629
|
+
"costLabel": "l2XZIa_costLabel",
|
|
4630
|
+
"costValue": "l2XZIa_costValue",
|
|
4631
|
+
"leading": "l2XZIa_leading",
|
|
4632
|
+
"separator": "l2XZIa_separator"
|
|
4633
|
+
};
|
|
4628
4634
|
//#endregion
|
|
4629
4635
|
//#region lib/types/client/TurnCostAction.js
|
|
4630
4636
|
/** Per-turn billed-cost label in the closing assistant message's actions row. */
|
|
4637
|
+
/**
|
|
4638
|
+
* In-house money-bag glyph in the hollow-outline style (16px viewBox, stroke
|
|
4639
|
+
* currentColor, fill none), referencing the 💰 emoji: a bag outline with a
|
|
4640
|
+
* tie knot at the neck and a centered yuan mark on the body. The drawing
|
|
4641
|
+
* fills the 16px box like the other glyphs.
|
|
4642
|
+
* @param props - optional size and class (the leading slot scales it to 14px).
|
|
4643
|
+
* @returns the money-bag icon.
|
|
4644
|
+
*/
|
|
4645
|
+
function WalletIcon({ size = 16, className }) {
|
|
4646
|
+
return (0, react_jsx_runtime.jsx)("svg", {
|
|
4647
|
+
width: size,
|
|
4648
|
+
height: size,
|
|
4649
|
+
className,
|
|
4650
|
+
viewBox: "0 0 16 16",
|
|
4651
|
+
fill: "none",
|
|
4652
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4653
|
+
children: (0, react_jsx_runtime.jsx)("path", {
|
|
4654
|
+
d: "M4.8 2.7 L5.2 5.2 C2.4 6.6 1.6 9.0 2.7 11.2 C3.4 12.8 5.5 13.6 8 13.6 C10.5 13.6 12.6 12.8 13.3 11.2 C14.4 9.0 13.6 6.6 10.8 5.2 L11.2 2.7 M6.6 1.4 L9.4 2.4 M9.4 1.4 L6.6 2.4 M5.6 5.5 L8 8.2 L10.4 5.5 M8 8.2 V12.4 M5.8 9.2 H10.2 M5.8 10.9 H10.2",
|
|
4655
|
+
stroke: "currentColor",
|
|
4656
|
+
strokeWidth: 1.4,
|
|
4657
|
+
strokeLinecap: "round",
|
|
4658
|
+
strokeLinejoin: "round",
|
|
4659
|
+
fill: "none"
|
|
4660
|
+
})
|
|
4661
|
+
});
|
|
4662
|
+
}
|
|
4631
4663
|
/** CNY amount, up to four decimals with trailing zeros trimmed. */
|
|
4632
4664
|
function formatSpend(amount) {
|
|
4633
4665
|
return `¥${amount.toFixed(4).replace(/\.?0+$/, "")}`;
|
|
@@ -4638,17 +4670,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4638
4670
|
const key = `${sessionId}\0${messageId}`;
|
|
4639
4671
|
const cached = turnCostCache.get(key);
|
|
4640
4672
|
if (cached !== void 0) return cached;
|
|
4641
|
-
const
|
|
4673
|
+
const spend = await getTurnSpend(sessionId, messageId);
|
|
4642
4674
|
if (turnCostCache.size >= TURN_COST_CACHE_LIMIT) turnCostCache.clear();
|
|
4643
|
-
turnCostCache.set(key,
|
|
4644
|
-
return
|
|
4675
|
+
turnCostCache.set(key, spend);
|
|
4676
|
+
return spend;
|
|
4645
4677
|
}
|
|
4646
4678
|
/**
|
|
4647
|
-
* Render one Turn's billed cost
|
|
4648
|
-
*
|
|
4649
|
-
*
|
|
4650
|
-
* the
|
|
4651
|
-
*
|
|
4679
|
+
* Render one Turn's billed cost inside the closing message's actions row,
|
|
4680
|
+
* before the built-in copy control (flex `order: -1`). The "本轮花费" word
|
|
4681
|
+
* uses the usage-card title tone and the amount the summary tone; unlike the
|
|
4682
|
+
* clock, the label stays visible without hover (the hover rule only targets
|
|
4683
|
+
* the time labels). It appears only after the Remote settles and hides again
|
|
4684
|
+
* when the Turn priced to zero (no DeepSeek usage); a failed fetch stays
|
|
4685
|
+
* hidden so a Remote outage never clutters the row.
|
|
4652
4686
|
* @param props - the closing message id, the session runtime share, and the injected cost reader.
|
|
4653
4687
|
* @returns the cost label, or null while loading, on failure, or for zero cost.
|
|
4654
4688
|
*/
|
|
@@ -4656,8 +4690,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4656
4690
|
const [cost, setCost] = (0, react.useState)(null);
|
|
4657
4691
|
(0, react.useEffect)(() => {
|
|
4658
4692
|
let current = true;
|
|
4659
|
-
Promise.resolve().then(() => cachedTurnCost(sessionId, messageId, getTurnSpend)).then((
|
|
4660
|
-
if (current) setCost(
|
|
4693
|
+
Promise.resolve().then(() => cachedTurnCost(sessionId, messageId, getTurnSpend)).then((value) => {
|
|
4694
|
+
if (current) setCost(value);
|
|
4661
4695
|
}, () => {
|
|
4662
4696
|
if (current) setCost(null);
|
|
4663
4697
|
});
|
|
@@ -4669,11 +4703,28 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4669
4703
|
messageId,
|
|
4670
4704
|
sessionId
|
|
4671
4705
|
]);
|
|
4672
|
-
if (cost === null || cost <= 0) return null;
|
|
4673
|
-
return (0, react_jsx_runtime.
|
|
4706
|
+
if (cost === null || cost.total <= 0) return null;
|
|
4707
|
+
return (0, react_jsx_runtime.jsxs)("span", {
|
|
4674
4708
|
className: TurnCostAction_module_css_default.cost,
|
|
4675
4709
|
"data-turn-cost": true,
|
|
4676
|
-
children:
|
|
4710
|
+
children: [
|
|
4711
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
4712
|
+
className: TurnCostAction_module_css_default.leading,
|
|
4713
|
+
children: (0, react_jsx_runtime.jsx)(WalletIcon, {})
|
|
4714
|
+
}),
|
|
4715
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
4716
|
+
className: TurnCostAction_module_css_default.costLabel,
|
|
4717
|
+
children: t("turnCost.label")
|
|
4718
|
+
}),
|
|
4719
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
4720
|
+
className: TurnCostAction_module_css_default.separator,
|
|
4721
|
+
"aria-hidden": true
|
|
4722
|
+
}),
|
|
4723
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
4724
|
+
className: TurnCostAction_module_css_default.costValue,
|
|
4725
|
+
children: formatSpend(cost.total)
|
|
4726
|
+
})
|
|
4727
|
+
]
|
|
4677
4728
|
});
|
|
4678
4729
|
}
|
|
4679
4730
|
//#endregion
|
|
@@ -4699,7 +4750,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4699
4750
|
"info.hint": "仅能预估 DeepSeek 相关模型。本会话花费按每条消息的发生时刻(北京时间)所在峰谷时段单价计费:缓存命中输入、未命中输入(含缓存写入)、输出(含推理)分别计价。费率按 8 月 17 日实行的标准,高峰时段为北京时间周一至周五 9:00–12:00、14:00–18:00,周末全天按低谷价计费。",
|
|
4700
4751
|
"badge.aria": "DeepSeek 额度:{amount}",
|
|
4701
4752
|
"panel.aria": "DeepSeek 额度详情",
|
|
4702
|
-
"turnCost": "
|
|
4753
|
+
"turnCost.label": "本轮花费",
|
|
4703
4754
|
"label.sessionRanking": "今日会话花费",
|
|
4704
4755
|
"label.sessionRanking.more": "…还有 {count} 个会话"
|
|
4705
4756
|
};
|
|
@@ -4721,7 +4772,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4721
4772
|
"info.hint": "Only DeepSeek models are estimated. This session's spend is priced per message at the rate of its Beijing-time peak/off-peak hour: cache-hit input, cache-miss input (including cache writes), and output (including reasoning) are billed separately. Rates follow the August 17 pricing; peak hours are Beijing time Monday–Friday 09:00–12:00 and 14:00–18:00, and weekends are billed at off-peak prices all day.",
|
|
4722
4773
|
"badge.aria": "DeepSeek balance {amount}",
|
|
4723
4774
|
"panel.aria": "DeepSeek balance details",
|
|
4724
|
-
"turnCost": "This turn
|
|
4775
|
+
"turnCost.label": "This turn",
|
|
4725
4776
|
"label.sessionRanking": "Today session spend",
|
|
4726
4777
|
"label.sessionRanking.more": "…{count} more sessions"
|
|
4727
4778
|
};
|
|
@@ -16,11 +16,13 @@ export interface TurnCostActionInjected {
|
|
|
16
16
|
*/
|
|
17
17
|
export type TurnCostActionProps = PropsRuntime<'conversation.chat.assistant-actions'> & InjectFace<TurnCostActionInjected> & PropsLocale<typeof NS>;
|
|
18
18
|
/**
|
|
19
|
-
* Render one Turn's billed cost
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* the
|
|
23
|
-
*
|
|
19
|
+
* Render one Turn's billed cost inside the closing message's actions row,
|
|
20
|
+
* before the built-in copy control (flex `order: -1`). The "本轮花费" word
|
|
21
|
+
* uses the usage-card title tone and the amount the summary tone; unlike the
|
|
22
|
+
* clock, the label stays visible without hover (the hover rule only targets
|
|
23
|
+
* the time labels). It appears only after the Remote settles and hides again
|
|
24
|
+
* when the Turn priced to zero (no DeepSeek usage); a failed fetch stays
|
|
25
|
+
* hidden so a Remote outage never clutters the row.
|
|
24
26
|
* @param props - the closing message id, the session runtime share, and the injected cost reader.
|
|
25
27
|
* @returns the cost label, or null while loading, on failure, or for zero cost.
|
|
26
28
|
*/
|
|
@@ -19,7 +19,7 @@ export declare const zh: {
|
|
|
19
19
|
readonly 'info.hint': "仅能预估 DeepSeek 相关模型。本会话花费按每条消息的发生时刻(北京时间)所在峰谷时段单价计费:缓存命中输入、未命中输入(含缓存写入)、输出(含推理)分别计价。费率按 8 月 17 日实行的标准,高峰时段为北京时间周一至周五 9:00–12:00、14:00–18:00,周末全天按低谷价计费。";
|
|
20
20
|
readonly 'badge.aria': "DeepSeek 额度:{amount}";
|
|
21
21
|
readonly 'panel.aria': "DeepSeek 额度详情";
|
|
22
|
-
readonly turnCost: "
|
|
22
|
+
readonly 'turnCost.label': "本轮花费";
|
|
23
23
|
readonly 'label.sessionRanking': "今日会话花费";
|
|
24
24
|
readonly 'label.sessionRanking.more': "…还有 {count} 个会话";
|
|
25
25
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rayadesu/dsh-client-ui-billing",
|
|
3
3
|
"description": "Session-header DeepSeek account-balance and conversation-spend badge over the billing Remote",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/types/index.d.ts",
|
|
@@ -32,11 +32,6 @@
|
|
|
32
32
|
"platform": "web"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"bundle": "tsdown",
|
|
37
|
-
"watch": "tsdown --watch",
|
|
38
|
-
"prepublishOnly": "node ../../scripts/verify-packages.mjs"
|
|
39
|
-
},
|
|
40
35
|
"license": "MIT",
|
|
41
36
|
"repository": {
|
|
42
37
|
"type": "git",
|
|
@@ -47,7 +42,7 @@
|
|
|
47
42
|
"access": "public"
|
|
48
43
|
},
|
|
49
44
|
"peerDependencies": {
|
|
50
|
-
"@rayadesu/dsh-llm-billing": "^0.
|
|
45
|
+
"@rayadesu/dsh-llm-billing": "^0.3.0",
|
|
51
46
|
"@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2",
|
|
52
47
|
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.1-rc.2",
|
|
53
48
|
"@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.2",
|
|
@@ -58,7 +53,7 @@
|
|
|
58
53
|
"@deepseek-ai/dsh-session": "^0.1.1-rc.2"
|
|
59
54
|
},
|
|
60
55
|
"devDependencies": {
|
|
61
|
-
"@rayadesu/dsh-llm-billing": "^0.
|
|
56
|
+
"@rayadesu/dsh-llm-billing": "^0.3.0",
|
|
62
57
|
"@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2",
|
|
63
58
|
"@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.2",
|
|
64
59
|
"@deepseek-ai/dsh-client-test-runtime": "^0.1.1-rc.2",
|
|
@@ -83,5 +78,9 @@
|
|
|
83
78
|
"lib/invariant.js",
|
|
84
79
|
"lib/client.js",
|
|
85
80
|
"lib/types/**/*.d.ts"
|
|
86
|
-
]
|
|
87
|
-
|
|
81
|
+
],
|
|
82
|
+
"scripts": {
|
|
83
|
+
"bundle": "tsdown",
|
|
84
|
+
"watch": "tsdown --watch"
|
|
85
|
+
}
|
|
86
|
+
}
|