Token usage meter in the DSH sidebar footer that runs both data sources at once rather than picking one: the DeepSeek platform account's usage and cost endpoints, which cover every device on the account but only the official channel, and local session logs, which cover this machine in real time across every provider but carry no cost. The two are merged per day — the official channel takes the larger figure, since one call is recorded by both, and providers the platform cannot see are added on top. History is backfilled month by month from the platform, providers are classified by channel rather than model name, days follow the platform's UTC boundary, and no token has to be pasted because the platform figures reuse the DSH account you are already signed in to. Totals appear as all-time, current-project, today, week, month, last-7 and last-30 in a compact bar, an expand panel and a detail modal with calendar, chart, model, provider, year, month and day tabs.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:czk200518-hash/dsh-tlogs
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
English | 中文
tlogs keeps your token usage visible in the DSH desktop sidebar footer: a compact bar, an inline expand panel and a detail modal.
The compact bar lives in the footer:
Expanding it shows seven cards:
Shapes

| Shape | Content |
|---|---|
| Compact bar | total, today, requests. ↻ refresh, ▾ expand |
| Expand panel | total, current project, today, this week, this month, last 7 days, last 30 days |
| Detail modal | calendar, charts, breakdown, models, providers, performance, tools, sessions, years, months, days, settings |
Settings
Switch these in the Settings tab of the detail modal; each choice is stored in this browser and survives restarts.
Language
| Choice | Meaning |
|---|---|
| Follow system (default) | DSH UI language → browser language → Chinese |
| 中文 / English | always that language |
It only affects this plugin's UI, never DSH's own language.
Day boundary
| Choice | Meaning |
|---|---|
| Platform day (default) | The bill's UTC day, rolling over at 08:00 Beijing; includes other devices and money |
| Local day | Rolls over at local 00:00; this machine's session logs only, no money (days whose logs were cleaned up are missing) |
Applies to the Today / this week / this month cards. When the local basis is unavailable they fall back to the platform day, and the panel says so.
Detail data
The modal is organized by tabs. The three charts share one set of controls (range × source × metric × granularity) — changing any one changes all three:
The calendar tab lists per-day usage and cost for a month; click a day for that day's breakdown:
The breakdown tab shows composition: cached / uncached / output tokens and their cost shares, the cache hit rate and the output share, switchable between all time / this month / today, or any month and day. Below it is the per-project table on the local basis (platform billing has no project dimension, so no money there).
The performance tab shows process metrics: TTFT, TPOT, TPS, TPM / RPM (average and peak), plus steps, steps per turn, repeated calls, file edits and the tool-time share. The tools tab lists per-tool calls, failures, average / total time and argument / result sizes (top 40).
The sessions tab lists one row per session (the label is an irreversible short hash; no paths are kept): dates, calls, steps, tool calls, tokens and an estimated amount. Project amounts are estimated the same way — from the platform per-type unit price — and marked as estimates, because the bill has no project or conversation dimension.
Both tabs read session-log metadata only (timestamps, tool names, argument lengths, isError, background job status and timings) — never message bodies — and cover only the days whose logs still exist, same window as the providers tab.
Data sources
| Source | Coverage | Freshness | Cost |
|---|---|---|---|
| Platform billing | every device on the account, official channel only | 10–30 min behind | yes |
| Local session logs | this machine only, all providers | real time | no |
Merged per day: max(platform, local official channel) + local third-party providers. A single call is counted by both sources, so we take the max instead of adding them up.
- A card is marked
第三方(third-party) only when the window contains usage the platform cannot see; other details live in the card tooltips. - Past months and charts use platform figures. The models and providers tabs decide by channel, not by model name:
deepseek-v4-flashon Volcano Ark counts as third-party.
Install
Four ways: absolute path, tarball, npm package name, github:<user>/dsh-tlogs. lib/ is prebuilt, so installing does not build.
The desktop profile cannot install from the CLI — use Settings → Plugins → Install. Other profiles: dsh plugin --profile web add dsh-tlogs.
Restart DSH afterwards. Tested on DSH 0.2.0-rc.2 (desktop, web).
Credentials
| Order | Source |
|---|---|
| 1 | env DEEPSEEK_PLATFORM_USER_TOKEN |
| 2 | config platformUserToken (plain text) |
| 3 | DSH credential TLOGS_USER_TOKEN (filled in the panel) |
| 4 | reuse the signed-in DSH account |
| 5 | built-in login window (unavailable on desktop) |
The first three win over the automatic sources; signing out only clears #3.
Configuration
Full template: cordis.patch.yml.
| Option | Default | Meaning |
|---|---|---|
exposeUsageToModel |
false |
register the in-chat query tool |
useAccountSession |
true |
reuse the DSH account credential |
localUsage / localUsageScanDays |
true / 32 |
read session logs; days to scan |
enableProjectScope |
true |
current-project card |
persistHistory |
true |
persist history to disk |
autoRefreshSeconds |
300 |
refresh interval; 0 disables |
cacheTTL.total / .current |
1800 / 300 |
cache seconds |
startYear / startMonth |
2024 / 4 |
history start |
requestIntervalMs |
1000 |
delay between monthly requests |
numberFormat |
short |
full thousands / short K·M·B |
compactMetrics |
[total, today] |
compact-bar metrics |
cacheDir |
'' |
empty = <DSH_HOME>/tlogs |
compactMetrics accepts: total, today, week, month, last7, last30, cost_total, cost_today, cost_last7, cost_last30.
Environment: DEEPSEEK_PLATFORM_USER_TOKEN, TLOGS_CACHE_DIR, DSH_HOME.
Security
| Measure | Detail |
|---|---|
| Credentials | only getPlatformSession() is exposed; the session credential is held during refresh only; invalid markers keep a digest |
| Network | platform.deepseek.com only; no redirects; header allowlist is x- only |
| Model isolation | no tool by default; when enabled, project ids remain irreversible hashes |
| Session logs | read-only, counts plus provider/model only; on disk, paths are hashed |
| Release gate | npm run verify:secrets |
Least-privilege config:
exposeUsageToModel: false
useAccountSession: false
enableProjectScope: false
persistHistory: false
localUsage: false
Caveats
Architecture
- Other plugins in the same browser realm can call this plugin's RPC.
.credentials.yamlis readable by any process of the same user — the main local exposure, unrelated to this plugin.- The session credential can only be de-referenced, not physically erased (JS strings are immutable); whether DSH caches it internally is outside this plugin's boundary.
Trade-offs
- The panel shows project labels and the local source reads session logs; both can be turned off in config.
- Project snapshots start on the day the plugin was enabled; earlier history cannot be reconstructed.
Habits
- Pasting usage figures or screenshots into a conversation puts them into the model context.
Development
pnpm run check # secret gate, i18n check, comment gate, typecheck, build, tests
pnpm run verify:dsh # validate the plugin manifest with the local DSH parser
pnpm run golden # live end-to-end comparison; needs DEEPSEEK_PLATFORM_USER_TOKEN
test/golden.test.ts skips itself when the external Python reference script is missing; point TLOGS_REFERENCE_SCRIPT=<path> at it.
License
GPL-3.0-only. Full text in LICENSE.
Links
More in this category
bowenliang123/dsh-context★ 5628
DSH context insight panel: Context dashboard + /context command + Context browser — one-stop context lifecycle management with categorized composition, content details, evolution trends, compaction/injection events, and stats.
Han-1413141/dsh-cost-meter★ 774
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 291
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 207
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 193
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
PolinniZhong/dsh-personal-center★ 114
Personal center for DeepSeek Harness: cross-session usage statistics with per-provider and per-model breakdown (auto-discovers configured models), per-model cost estimation, global custom instructions, a data-driven desktop pet with bitmap & vector skins, and a conversation status overview, all local and offline.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.