bowenliang123/dsh-context
bowenliang123/dsh-contextDSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
English | 中文
Live input/output token estimates and generation throughput for DSH Web. It feeds the built-in session status row: input and output token totals update while a response streams, and the generation throughput group (TPS 31.4 tok/s) renders right after the step counts, ahead of the billing groups:
1 turns · 3 steps TPS 31.4 tok/s Input ~7.9K tok · Output ~12 tok
~ marks a heuristic estimate. Provider usage replaces the estimate when it arrives; exact cache accounting continues to come from DSH's durable token-usage projection. A retry replaces the prior estimate for that step, and an aborted turn removes its unsettled estimate.
liveTokenUsage session projection (ctx.sessionProjections). The fold estimates input tokens from the surface log plus header/tool framing, estimates output tokens from streaming chunks, and replaces estimates with provider usage as soon as a usage chunk or final message lands. TPS is derived from output tokens over wall-clock time of the active step, and the rate is resident: once any step measured one, the projection keeps reporting it (falling back to the last measured value while a new step has not produced output yet, or after a rate-less step), so the row never flickers out.liveTokenUsage projection directly — so the client mounts nothing.Install the family aggregate package @linxin666/dsh-web-ui-all (all plugins and skins in one) or this plugin alone:
# Recommended: install directly from npm
dsh plugin --profile web add @linxin666/dsh-live-stats
# Or from the repository (development loop)
git clone https://github.com/zhu1090093659/dsh-web-ui.git
cd dsh-web-ui
pnpm install && pnpm -r build
dsh plugin --profile web add link:$(pwd)/packages/dsh-live-stats
Restart dsh web, and the TPS group appears in the session status line.
Alternatively, as a plain overlay row in the personal DSH overlay (~/.dsh/config.yaml), hot-reloaded on save:
- insert:
- id: live-stats
name: '@linxin666/dsh-live-stats'
config:
charsPerToken: 4
blockOverhead: 4
roleOverhead: 4
All three estimator values are optional (defaults shown).
| Key | Type | Default | Meaning |
|---|---|---|---|
charsPerToken | number | 4 | Approximate text characters represented by one token |
blockOverhead | number | 4 | Fixed framing tokens assigned to each content block |
roleOverhead | number | 4 | Fixed framing tokens assigned to each message or assistant response |
A function/namespace plugin: inject / Config / apply, no default export. The estimator (./estimator) and the projection fold (./projection) are pure and unit-tested; the client TpsLine renders through the runtime's projection hook. The invariant companion registers under ./invariant.
Nothing. The plugin injects no prompt sections, registers no tools, and emits no session events of its own — it only consumes the durable stream and the projection carrier's wire path.
Zero per request.
No system-prompt contribution, so no cache-stability effect.
~) until provider usage arrives; exact cache accounting always comes from DSH's durable token-usage projection.charsPerToken defaults to 4 characters, which undercounts CJK text and overcounts pure ASCII; tune it per deployment if estimates drift.