dsh-token-receipt 1.0.0 → 1.1.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.
@@ -1,10 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="360" height="520" viewBox="0 0 360 520">
2
- <filter id="paper-grain" x="-10%" y="-10%" width="120%" height="120%" color-interpolation-filters="sRGB">
3
- <feTurbulence type="fractalNoise" baseFrequency="0.012 0.02" numOctaves="3" seed="42" stitchTiles="stitch" />
4
- <feColorMatrix type="saturate" values="0" />
5
- <feComponentTransfer>
6
- <feFuncA type="table" tableValues="0 0.22" />
7
- </feComponentTransfer>
8
- </filter>
9
- <rect width="100%" height="100%" filter="url(#paper-grain)" opacity="0.35" />
10
- </svg>
@@ -1,10 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="180" height="180" viewBox="0 0 180 180">
2
- <filter id="plastic-grain" x="-10%" y="-10%" width="120%" height="120%" color-interpolation-filters="sRGB">
3
- <feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="2" seed="9" stitchTiles="stitch" />
4
- <feColorMatrix type="saturate" values="0" />
5
- <feComponentTransfer>
6
- <feFuncA type="table" tableValues="0 0.18" />
7
- </feComponentTransfer>
8
- </filter>
9
- <rect width="100%" height="100%" filter="url(#plastic-grain)" opacity="0.55" />
10
- </svg>
package/docs/FONTS.md DELETED
@@ -1,11 +0,0 @@
1
- # Bundled fonts
2
-
3
- The Token receipt bundle embeds two open-source font files in `client.js` as
4
- base64 data URLs so the receipt looks the same on every machine:
5
-
6
- - **Inter** — Copyright (c) 2016 The Inter Project Authors. SIL Open Font License 1.1.
7
- License text: [licenses/Inter-OFL.txt](licenses/Inter-OFL.txt)
8
- - **JetBrains Mono** — Copyright 2020 The JetBrains Mono Project Authors. SIL Open Font License 1.1.
9
- License text: [licenses/JetBrainsMono-OFL.txt](licenses/JetBrainsMono-OFL.txt)
10
-
11
- Both fonts permit embedding and redistribution under the SIL Open Font License 1.1.
package/docs/PRICING.md DELETED
@@ -1,94 +0,0 @@
1
- # Estimated token costs / Token 费用估算
2
-
3
- The receipt uses public **models.dev reference prices**, not your provider's invoice. Session text, model usage and provider credentials are never uploaded. The Host fetches only the public catalogue at https://models.dev/api.json.
4
-
5
- ## Formula
6
-
7
- All calculations use USD per one million tokens:
8
-
9
- ```text
10
- USD = (inputTokens × inputRate
11
- + cacheReadTokens × cacheReadRate
12
- + cacheWriteTokens × cacheWriteRate
13
- + outputTokens × outputRate) / 1,000,000
14
- ```
15
-
16
- DSH's `inputTokens` is used as the uncached input bucket, consistent with dsh-context. Cache tokens are separate; do not subtract them again. `reasoningTokens` is retained as usage information but not charged a second time on top of output.
17
-
18
- A missing cache-read or cache-write rate falls back to that model's input rate. An explicit zero remains zero. Entries without a finite, nonnegative input and output rate cannot be priced.
19
-
20
- Usage is priced per provider, full model ID and event time before any display rows combine. Day, week and month select different time windows; they use the same pricing formula.
21
-
22
- ## Catalogue and matching
23
-
24
- The catalogue is cached for one hour. Requests are deduplicated, have an eight-second timeout, and use a thirty-second backoff after an initial failure. A previously downloaded catalogue remains usable after a refresh failure and is marked stale. A failure to fetch prices does not erase usage or turn the estimate into a zero-cost bill.
25
-
26
- Provider-specific prices take precedence. Matching follows dsh-context's provider aliases, provider-local normalized forms, organization IDs, canonical maker hints, model families and unambiguous global matches. Different candidate prices produce an unpriced result, not an arbitrary selection. Subscription `coding-plan`, `code-plan` and `token-plan` branches are excluded from the per-token index; a maker reference may still be available.
27
-
28
- ### WorkBuddy override
29
-
30
- The requested exception is explicit:
31
-
32
- ```text
33
- workbuddy / deepseek-v4.1-flash
34
- → deepseek / deepseek-v4-flash
35
- ```
36
-
37
- This route uses the official Flash reference rates even when normal matching would be ambiguous. Both a direct WorkBuddy provider and a gateway model ID such as `magpie / workbuddy/deepseek-v4.1-flash` identify the same explicit override. It is marked `user-override` in the API response; source and override annotations are omitted from the receipt. If the official entry is unavailable, the route remains unpriced; no bundled or invented rate is substituted.
38
-
39
- The override uses the same peak-time policy as the official DeepSeek route. Ordinary third-party channels retain their own provider price and are not silently repriced to DeepSeek.
40
-
41
- ## Peak periods
42
-
43
- As in the referenced dsh-context implementation, official DeepSeek providers (`deepseek`, `deepseek-official`, `deepseek-account`) and the WorkBuddy override use a factor of **2** during these Beijing / UTC+8 windows:
44
-
45
- - Monday–Friday, 09:00 inclusive to 12:00 exclusive.
46
- - Monday–Friday, 14:00 inclusive to 18:00 exclusive.
47
-
48
- Other hours and weekends use factor 1. Each message is classified at its recorded event time, so weekly and monthly bills can contain both peak and off-peak usage. This policy checks weekdays, not a public-holiday or adjusted-working-day calendar.
49
-
50
- ## Currency and display
51
-
52
- The default is **Follow language**: Chinese uses CNY, English uses USD, and Japanese uses JPY. Automatic mode updates when the interface language changes. Selecting USD, CNY or JPY manually keeps that selection for the current panel, even when the language changes; selecting Follow language restores automatic behavior. Reopening the panel starts in automatic mode.
53
-
54
- All prices and API amounts remain unrounded USD. Display conversion uses these fixed reference rates:
55
-
56
- ```text
57
- USD = USD
58
- CNY = USD / 0.15 (1 USD ≈ 6.67 CNY, retained from dsh-context)
59
- JPY = USD × 160 (2026-11-13 reference quote)
60
- ```
61
-
62
- The JPY rate was verified against the [Frankfurter historical USD/JPY quote](https://api.frankfurter.dev/v1/2026-11-13?base=USD&symbols=JPY). It is a dated reference, not a live exchange rate. The JPY receipt note includes the rate and date. No extra FX network request is made while printing.
63
-
64
- USD and CNY normally show two decimal places; JPY normally shows whole yen. Small positive estimates retain up to six decimal places (below one cent for USD/CNY and below one yen for JPY). A positive amount below 0.000001 of the display currency is shown as `<$0.000001` or `<¥0.000001`, so a nonzero charge is never rounded into a free bill. The receipt also prints the currency code, distinguishing CNY and JPY even though both use the ¥ symbol.
65
-
66
- - **Estimated total**: every request has a matched price.
67
- - **Priced subtotal**: only matched requests are included; the receipt reports how many remain unpriced.
68
- - **— / Prices unavailable**: no usable estimate; this is not zero.
69
- - **$0.00**: an empty period or an explicitly free matched price.
70
-
71
- Model lines may combine the same short model name for readability, but their monetary amounts have already been calculated independently on the Host. A partially priced combined line is marked with `≈`. PNG and print output use the same receipt data and display currency.
72
-
73
- ## Limits
74
-
75
- This is a reference estimate. Private contracts, subscriptions, credits, reseller discounts, taxes and payment fees are not inferred. The four-rate model does not implement all catalogue conditions: long-context tiers, cache TTL variants, service-tier/region multipliers and tool-side charges may differ. The inherited DeepSeek weekday policy also omits Chinese public-holiday exclusions, and nonofficial providers such as OpenCode Go may have their own multipliers that are not implemented here.
76
-
77
- Prices are fetched from the currently available catalogue. The plugin does not keep a historical price ledger, so older usage can be re-estimated at newer prices. Keep a saved receipt if you need a fixed record of an estimate.
78
-
79
- ## 中文摘要
80
-
81
- - 金额由未缓存输入、缓存读、缓存写和输出四类 Token 分别计算,单位是美元/百万 Token。
82
- - 按供应商、完整模型 ID 和消息时间计费后再汇总,日/周/月沿用同一规则。
83
- - `workbuddy / deepseek-v4.1-flash` 按你的要求使用 `deepseek / deepseek-v4-flash` 官方参考价,并沿用官方峰谷倍率;回退记录保留在 API 中,小票不显示来源及回退说明。
84
- - 默认币种跟随语言:中文 CNY、英文 USD、日文 JPY;手动选定币种后保留当前选择,选「跟随语言」恢复自动,重新打开面板默认自动。
85
- - USD 为计算基准;CNY 固定按 `USD / 0.15` 换算,JPY 按 2026-11-13 的参考汇率 `USD × 160` 换算。两者都不是实时汇率。缺价不记成免费,部分计价显示为小计。
86
- - 用量和会话始终保留在本机,仅联网获取公开价格目录。金额是参考估算,不是实付账单;阶梯价、订阅优惠、税费等不在当前模型内。
87
-
88
- ## References and attribution
89
-
90
- - [dsh-context model pricing design](https://github.com/bowenliang123/dsh-context/blob/d81325ec6bab9dae9bf83e7a866ac74119504e18/docs/model-pricing-mapping.md)
91
- - [dsh-context pricing source](https://github.com/bowenliang123/dsh-context/blob/d81325ec6bab9dae9bf83e7a866ac74119504e18/src/shared/pricing.ts)
92
- - [models.dev catalogue](https://models.dev/api.json)
93
- - [Receipt Printer visual reference](https://www.dqnamo.com/experiments/receipt-printer)
94
- - [Third-party notices](../THIRD_PARTY_NOTICES.md)
Binary file
Binary file
File without changes
File without changes
File without changes
File without changes
File without changes