@kenz1117/dsh-ui-usage-billing 1.8.0-alpha.1 → 1.8.0-alpha.2
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.en.md +6 -9
- package/README.md +6 -9
- package/lib/client.js +5 -5
- package/lib/index.js +65 -15
- package/lib/types/client/PeakAlertBanner.d.ts +1 -1
- package/lib/types/client/TaskQueuePanel.d.ts +8 -0
- package/lib/types/client/api/task-queue.d.ts +5 -1
- package/lib/types/client/domain/types.d.ts +1 -1
- package/lib/types/client/live-cost.d.ts +1 -8
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/client/peak-alert.d.ts +6 -0
- package/lib/types/task-queue-shared.d.ts +14 -0
- package/lib/types/task-queue.d.ts +5 -7
- package/package.json +1 -3
- package/lib/types/client/context-store.d.ts +0 -68
package/README.en.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
### Demo GIF
|
|
32
32
|
|
|
33
|
-
The eight dashboard tabs in turn (Overview / Billing / Usage / Trends /
|
|
33
|
+
The eight dashboard tabs in turn (Overview / Queue / Billing / Usage / Trends / Agents / Rates / Settings):
|
|
34
34
|
|
|
35
35
|

|
|
36
36
|
|
|
@@ -56,11 +56,10 @@ The billing channel is detected from the current session's model: DeepSeek meter
|
|
|
56
56
|
- A performance panel: per-model TTFT mean/P50/P90 and generation speed.
|
|
57
57
|
- Uncatalogued models are explicitly marked and never silently billed 0; one alias entry prices an out-of-catalog model.
|
|
58
58
|
- An optional `usage_stats` tool lets the model answer "what did I spend today" or "which site used the most".
|
|
59
|
-
- **Off-peak task queue (preview)**: nothing is queued until the user explicitly chooses a workspace, a built-in DeepSeek official model and a Prompt. Tasks run FIFO in independent Sessions, start only in the official off-peak window, continue across peak once admitted, and become "Needs review" without automatic replay after failures or unknown outcomes. Relay mirrors are excluded; hosts without Session control fall back to read-only and never create placeholder tasks.
|
|
59
|
+
- **Off-peak task queue (preview)**: nothing is queued until the user explicitly chooses a workspace, a built-in DeepSeek official model and a Prompt. JSON files can be imported in batches; the whole batch is validated before one atomic enqueue, so any invalid item means zero writes. Tasks run FIFO in independent Sessions, start only in the official off-peak window, continue across peak once admitted, and become "Needs review" without automatic replay after failures or unknown outcomes. Relay mirrors are excluded; hosts without Session control fall back to read-only and never create placeholder tasks.
|
|
60
60
|
- Zero tools registered by default: the single read-only `usage_stats` tool is registered **only** after the user explicitly turns on "inject usage query" in the settings (off by default). No system-prompt injection.
|
|
61
61
|
- Chinese / English and ¥ / ≈$ toggles; no chart library, no external CDN, offline & self-contained.
|
|
62
62
|
- **Jump from a session row**: click a session title in the dashboard to open that conversation in the host (both generations of the host's session-selection channel are probed; hosts without one show a readable notice instead of silently doing nothing).
|
|
63
|
-
- **Context occupancy**: the overview shows the current session's context occupancy, window capacity, and composition (system / tools / messages), read from the host's official context projections. Sessions without a projection hide the whole card — it never shows a fabricated 0.
|
|
64
63
|
- **In-conversation entry**: the `/usage` command opens the billing dashboard directly (hosts without that capability degrade silently and leave the dashboard untouched).
|
|
65
64
|
|
|
66
65
|
## 📊 Dashboard
|
|
@@ -69,16 +68,14 @@ The billing channel is detected from the current session's model: DeepSeek meter
|
|
|
69
68
|
|
|
70
69
|

|
|
71
70
|
|
|
72
|
-
- **
|
|
73
|
-
- **Queue section**: shows the current price band and switch countdown, queued / starting / running / needs-review / completed tasks and their host Session links. Queued tasks can be removed and finished history cleared; admitted tasks cannot be removed through the queue. A queue file, file lock and owner lease prevent duplicate submission by multiple instances sharing one `DSH_HOME`.
|
|
74
|
-
- **Context section**: an occupancy bar plus next-request / last-request occupancy, window capacity and the composition split (system / tools / messages). The figures come from the host's official context projections; a session without one hides the whole section rather than showing a fabricated 0.
|
|
71
|
+
- **Eight-tab dashboard**: Overview / Queue / Billing / Usage / Trends / Agents / Rates / Settings — hero figures + comparisons + month projection + KPIs (hover for the metric definition) + usage heatmap, trends switchable between cost and tokens over 7/30 days, model price table, budgets (global + per model) and peak/off-peak alerts all live here; the settings page supports full-text search (zh/en keywords, empty state when nothing matches); tabs carry names only — no status badges.
|
|
72
|
+
- **Queue section**: shows the current price band and switch countdown, queued / starting / running / needs-review / completed tasks and their host Session links. JSON batch import accepts up to 50 tasks; one invalid item rejects the entire batch without writes. Queued tasks can be removed and finished history cleared; admitted tasks cannot be removed through the queue. A queue file, file lock and owner lease prevent duplicate submission by multiple instances sharing one `DSH_HOME`.
|
|
75
73
|
- **Agents section**: the agent network rebuilt from delegation relations — a parent conversation → sub-agent tree where each row carries its call count, own cost and **chain total** (itself + all descendants), which directly answers "which delegation was the most expensive".
|
|
76
74
|
|
|
77
75
|

|
|
78
|
-

|
|
79
76
|

|
|
80
77
|
- **Live cost bar**: persistent "this turn / session" cost with three positions (composer toolbar row / above / below, toolbar by default); the peak/off-peak tier & countdown section appears only when the current model involves peak/off-peak pricing; subscription low-quota chips appear at ≤20% remaining, red at ≤10%; hideable via the settings-tab toggle (display-only preference persisted locally; stats and alerts unaffected).
|
|
81
|
-
- **Peak/off-peak switch alert**: a popover plus an optional system notification before a switch; lead time / position / mode / preview configurable; copy differs by billing channel (DeepSeek price halves, Zhipu credits at 50%).
|
|
78
|
+
- **Peak/off-peak switch alert**: a popover plus an optional system notification before a switch; lead time / position / mode / preview configurable; copy differs by billing channel (DeepSeek price halves, Zhipu credits at 50%). When tasks are queued, the alert also explains that they wait for the next off-peak window, start FIFO during off-peak, and continue across peak once started; it never automatically pauses or replays them.
|
|
82
79
|
- **Session completion notification**: an optional system notification when a session transitions running → completed (off by default, enable it in the panel); multi-window / multi-instance dedup through the claim endpoint, so each session notifies once.
|
|
83
80
|
- **Plugin info card**: a persistent "About" card in the Settings tab — version read server-side from the package's `package.json` (single source of truth, correct on publish), author / repo / npm / license one click away.
|
|
84
81
|
|
|
@@ -239,7 +236,7 @@ To add a model: append an entry to `BUILTIN_MODEL_CATALOG` in `src/builtin-catal
|
|
|
239
236
|
|
|
240
237
|
## 🔌 HTTP API
|
|
241
238
|
|
|
242
|
-
The public HTTP endpoints and field definitions are documented in source, including usage, pricing, balances, subscriptions, relay quotas
|
|
239
|
+
The public HTTP endpoints and field definitions are documented in source, including usage, pricing, balances, subscriptions, relay quotas, `GET/POST /api/billing/task-queue` and `GET /api/billing/task-queue-summary` (see `src/index.ts`, `src/aggregate.ts`, `src/relay.ts`, `src/routes/task-queue.ts`). The queue returns host capability, workspaces, official models and durable tasks; mutations are `enqueue` / `enqueueMany`, remove-not-started and clear-finished. The summary returns only the price-band state and queued count, never Prompts. All endpoints accept loopback requests only; queue writes additionally require a loopback Origin, JSON Content-Type and a body no larger than 10 MiB.
|
|
243
240
|
|
|
244
241
|
## ⚙️ Configuration
|
|
245
242
|
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
### 演示动图
|
|
32
32
|
|
|
33
|
-
新版仪表盘八个分区逐个切换(概览 / 账单 / 用量 / 趋势 /
|
|
33
|
+
新版仪表盘八个分区逐个切换(概览 / 队列 / 账单 / 用量 / 趋势 / 智能体 / 费率 / 设置):
|
|
34
34
|
|
|
35
35
|

|
|
36
36
|
|
|
@@ -57,11 +57,10 @@ DeepSeek / Kimi / 智谱 GLM / 腾讯云 TokenHub 等 7 家官方余额、Coding
|
|
|
57
57
|
- 性能面板:各模型首字延时(TTFT)均值 / P50 / P90 与生成速度,同类少有。
|
|
58
58
|
- 未收录模型显著标注「未收录」、绝不静默计 0;目录外模型配一条别名即完成识别与计价。
|
|
59
59
|
- 可选的 `usage_stats` 工具让模型直接回答「今天花了多少」「哪个站点用得最多」。
|
|
60
|
-
- **低谷任务队列(预览)**:用户显式选择工作区、内置 DeepSeek 官方模型并提交 Prompt
|
|
60
|
+
- **低谷任务队列(预览)**:用户显式选择工作区、内置 DeepSeek 官方模型并提交 Prompt 后,任务才持久化入队;支持 JSON 文件批量导入,整批校验后一次原子入队,任一无效则零写入。FIFO 串行、每任务独立会话,只在官方低谷启动,已提交任务跨峰继续,失败或结果未知标「需核对」且绝不自动重放。中转站同名模型不参与;宿主缺少会话控制能力时只读降级,不创建假任务。
|
|
61
61
|
- 默认零工具注入:**仅**当用户在设置里显式开启「注入用量查询」后,才向模型注册 `usage_stats` 这一个只读工具(默认关闭);不注入系统提示。
|
|
62
62
|
- 中文 / English 语言切换,¥ / ≈$ / ≈€ 币种切换(二者独立);无图表库、无外部 CDN、离线自包含。
|
|
63
63
|
- **会话行可跳转**:面板里的会话标题点一下直接打开宿主对话(双代会话选择通道自动探测;宿主不支持时给出可读提示,不静默无反应)。
|
|
64
|
-
- **上下文占用维度**:概览页显示当前会话的上下文占用率、窗口上限与构成拆解(系统 / 工具 / 消息)——数据取自宿主官方的 context 投影,**没有投影的会话整块不显示**(不拿 0 冒充)。
|
|
65
64
|
- **对话内入口**:`/usage` 命令直接拉起计费仪表盘(宿主无该能力时静默降级,不影响面板)。
|
|
66
65
|
|
|
67
66
|
## 📊 仪表盘
|
|
@@ -70,16 +69,14 @@ DeepSeek / Kimi / 智谱 GLM / 腾讯云 TokenHub 等 7 家官方余额、Coding
|
|
|
70
69
|
|
|
71
70
|

|
|
72
71
|
|
|
73
|
-
-
|
|
74
|
-
- **队列分区**:显示当前峰谷与切换倒计时、待执行 / 执行中 / 需核对 /
|
|
75
|
-
- **上下文分区**:占用率进度条 + 下一次 / 最近一次请求占用 + 窗口上限 + 构成拆解(系统 / 工具 / 消息)。数据取自宿主官方 context 投影;**没有投影的会话整块不显示**,不拿 0 冒充。
|
|
72
|
+
- **八区仪表盘**:概览 / 队列 / 账单 / 用量 / 趋势 / 智能体 / 费率 / 设置——Hero 大数字 + 环比 + 本月预计 + KPI(悬停显示口径说明)+ 用量热力图,趋势 7/30 天可切费用 / Token,模型单价表、预算(全局 + 按模型)与峰谷提醒都在;设置页支持全文搜索(中英关键词过滤分区,全不命中显示空态);克制冷调、深浅主题自适应。Tab 只保留名称,不再挂状态徽标(信息都在各自分区里)。
|
|
73
|
+
- **队列分区**:显示当前峰谷与切换倒计时、待执行 / 执行中 / 需核对 / 已完成任务及宿主会话入口;支持 JSON 批量导入(单批最多 50 条),任一条目无效则整批不写入。可移除尚未启动的任务或清除已结束历史,执行中的任务不可从队列删除。队列文件与文件锁 / 租约防止同一 `DSH_HOME` 的多实例重复提交。
|
|
76
74
|
- **智能体分区**:按委派关系还原的智能体网络——父对话 → 子智能体的层级树,每行给调用数、自身费用与**链合计**(自身 + 全部后代),直接回答「哪次委派最贵」。
|
|
77
75
|
|
|
78
76
|

|
|
79
|
-

|
|
80
77
|

|
|
81
78
|
- **即时代费用条**:常驻「本轮 / 会话」费用,位置三档可选(输入框内部工具行 / 上方 / 下方,默认工具行);峰谷档位与切换倒计时只在当前模型涉及峰谷时出现;订阅额度预警 chips 剩余 ≤20% 浮现、≤10% 标红;可在设置 Tab 整条隐藏(偏好本地持久化,统计与提醒不受影响)。
|
|
82
|
-
- **峰 / 谷切换提醒**:切档前弹窗 + 可选系统通知,提前量 / 位置 / 模式 / 预览均可配;文案按计费通道区分(DeepSeek 价格减半、智谱积分 5
|
|
79
|
+
- **峰 / 谷切换提醒**:切档前弹窗 + 可选系统通知,提前量 / 位置 / 模式 / 预览均可配;文案按计费通道区分(DeepSeek 价格减半、智谱积分 5 折)。有待执行任务时补充队列说明:排队任务等待下一低谷、低谷按顺序启动、已开始任务跨峰继续;不自动暂停或重放任务。
|
|
83
80
|
- **会话完成提醒**:会话 running → completed 时弹系统通知(默认关闭,面板设置开启);多窗口 / 多实例按认领端点去重,同一会话只提醒一次。
|
|
84
81
|
- **插件信息卡**:设置 Tab 常驻「关于」卡——版本号服务端读自包 `package.json`(单一来源,发布自动正确),作者 / 仓库 / npm / 许可证一键可达。
|
|
85
82
|
|
|
@@ -248,7 +245,7 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
|
|
|
248
245
|
|
|
249
246
|
## 🔌 HTTP API
|
|
250
247
|
|
|
251
|
-
对外 HTTP 接口与字段定义详见源码:`GET /api/billing/pricing`、`/api/billing/balance`、`/api/billing/usage-stats`、`/api/billing/subscriptions`、`/api/billing/relay-quotas`、`GET/POST /api/billing/task-queue` 等(见 `src/index.ts`、`src/aggregate.ts`、`src/relay.ts`、`src/routes/task-queue.ts`)。其中 `usage-stats` 返回的 `bySite` 字段为按中转站归组后的用量分布,`relay-quotas` 返回额度与路由诊断;`task-queue`
|
|
248
|
+
对外 HTTP 接口与字段定义详见源码:`GET /api/billing/pricing`、`/api/billing/balance`、`/api/billing/usage-stats`、`/api/billing/subscriptions`、`/api/billing/relay-quotas`、`GET/POST /api/billing/task-queue`、`GET /api/billing/task-queue-summary` 等(见 `src/index.ts`、`src/aggregate.ts`、`src/relay.ts`、`src/routes/task-queue.ts`)。其中 `usage-stats` 返回的 `bySite` 字段为按中转站归组后的用量分布,`relay-quotas` 返回额度与路由诊断;`task-queue` 返回能力、工作区、官方模型和持久任务快照,写操作为 `enqueue` / `enqueueMany`、移除未启动任务与清理已结束历史;`task-queue-summary` 只返回峰谷状态与待执行数量,不返回 Prompt。全部端点仅接受回环请求;队列写操作另校验回环 Origin、JSON Content-Type 与 10 MiB body 上限。
|
|
252
249
|
|
|
253
250
|
## ⚙️ 配置
|
|
254
251
|
|