opencode-quota-gui 1.3.0 → 1.3.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.
Files changed (238) hide show
  1. package/README.md +34 -20
  2. package/dist/bin/opencode-quota-gui.js +0 -0
  3. package/dist/contracts/build-identity.js +1 -1
  4. package/dist/contracts/card-order.d.ts +2 -0
  5. package/dist/contracts/card-order.js +2 -2
  6. package/dist/contracts/card-visibility.d.ts +2 -1
  7. package/dist/contracts/card-visibility.js +2 -1
  8. package/dist/contracts/dashboard.d.ts +95 -6
  9. package/dist/contracts/dashboard.js +10 -0
  10. package/dist/contracts/dto-guards.d.ts +4 -0
  11. package/dist/contracts/dto-guards.js +31 -7
  12. package/dist/contracts/guards.js +3 -1
  13. package/dist/contracts/identity.d.ts +37 -5
  14. package/dist/contracts/identity.js +43 -0
  15. package/dist/contracts/openai-quota.d.ts +3 -0
  16. package/dist/contracts/openai-quota.js +3 -0
  17. package/dist/contracts/provider-auto-resume.d.ts +9 -0
  18. package/dist/contracts/provider-auto-resume.js +24 -0
  19. package/dist/contracts/provider-failure.d.ts +22 -0
  20. package/dist/contracts/provider-failure.js +25 -1
  21. package/dist/contracts/row-order.d.ts +13 -0
  22. package/dist/contracts/row-order.js +34 -0
  23. package/dist/contracts/row-visibility.d.ts +53 -0
  24. package/dist/contracts/row-visibility.js +130 -0
  25. package/dist/data/modelsdev-pricing.min.json +1 -1
  26. package/dist/data/modelsdev-temporal.min.json +60 -634
  27. package/dist/gui/aggregation.d.ts +29 -1
  28. package/dist/gui/aggregation.js +157 -4
  29. package/dist/gui/analytics-bridge.d.ts +8 -9
  30. package/dist/gui/analytics-bridge.js +197 -54
  31. package/dist/gui/analytics-engine.d.ts +7 -15
  32. package/dist/gui/analytics-engine.js +246 -106
  33. package/dist/gui/analytics-model.d.ts +7 -0
  34. package/dist/gui/analytics-model.js +75 -9
  35. package/dist/gui/analytics-pricing-upkeep.d.ts +21 -0
  36. package/dist/gui/analytics-pricing-upkeep.js +23 -0
  37. package/dist/gui/analytics-protocol.d.ts +17 -7
  38. package/dist/gui/analytics-protocol.js +1 -0
  39. package/dist/gui/analytics-service.d.ts +10 -0
  40. package/dist/gui/analytics-service.js +30 -9
  41. package/dist/gui/analytics-state.d.ts +30 -5
  42. package/dist/gui/analytics-state.js +46 -7
  43. package/dist/gui/analytics-worker-runtime.d.ts +5 -0
  44. package/dist/gui/analytics-worker-runtime.js +9 -1
  45. package/dist/gui/analytics-worker.js +11 -0
  46. package/dist/gui/config.d.ts +3 -3
  47. package/dist/gui/config.js +77 -7
  48. package/dist/gui/identity.d.ts +6 -20
  49. package/dist/gui/identity.js +6 -54
  50. package/dist/gui/lifecycle.d.ts +5 -3
  51. package/dist/gui/lifecycle.js +3 -3
  52. package/dist/gui/primary-quota-windows.js +67 -44
  53. package/dist/gui/provider-cards.d.ts +20 -8
  54. package/dist/gui/provider-cards.js +42 -55
  55. package/dist/gui/quota-notification-detector.d.ts +29 -6
  56. package/dist/gui/quota-notification-detector.js +136 -47
  57. package/dist/gui/quota-notification-observer.d.ts +3 -4
  58. package/dist/gui/quota-notification-observer.js +73 -20
  59. package/dist/gui/quota-observation.d.ts +4 -0
  60. package/dist/gui/quota-observation.js +18 -0
  61. package/dist/gui/rpc.d.ts +2 -0
  62. package/dist/gui/rpc.js +14 -3
  63. package/dist/gui/server.js +17 -3
  64. package/dist/gui/snapshot-service.d.ts +3 -15
  65. package/dist/gui/snapshot-service.js +281 -23
  66. package/dist/gui/sources.js +179 -64
  67. package/dist/gui/temporal-status.d.ts +3 -2
  68. package/dist/gui/temporal-status.js +10 -6
  69. package/dist/gui-experimental.cjs +230 -225
  70. package/dist/lib/accounting-format.d.ts +8 -0
  71. package/dist/lib/accounting-format.js +20 -2
  72. package/dist/lib/alibaba-coding-plan-cli.d.ts +79 -0
  73. package/dist/lib/alibaba-coding-plan-cli.js +539 -0
  74. package/dist/lib/anthropic-api-auth.d.ts +7 -0
  75. package/dist/lib/anthropic-api-auth.js +27 -0
  76. package/dist/lib/anthropic-api-rate-limits.d.ts +47 -0
  77. package/dist/lib/anthropic-api-rate-limits.js +92 -0
  78. package/dist/lib/anthropic-auth.d.ts +2 -3
  79. package/dist/lib/anthropic-auth.js +2 -3
  80. package/dist/lib/anthropic-oauth-throttle.d.ts +76 -0
  81. package/dist/lib/anthropic-oauth-throttle.js +379 -0
  82. package/dist/lib/anthropic.d.ts +68 -14
  83. package/dist/lib/anthropic.js +1016 -363
  84. package/dist/lib/api-key-retry-after.d.ts +7 -0
  85. package/dist/lib/api-key-retry-after.js +62 -0
  86. package/dist/lib/atomic-json.d.ts +2 -0
  87. package/dist/lib/atomic-json.js +1 -0
  88. package/dist/lib/cache-observer-ingestion.d.ts +90 -0
  89. package/dist/lib/cache-observer-ingestion.js +1008 -0
  90. package/dist/lib/cache-observer.d.ts +141 -0
  91. package/dist/lib/cache-observer.js +323 -0
  92. package/dist/lib/canonical-config-lock.d.ts +9 -0
  93. package/dist/lib/canonical-config-lock.js +36 -0
  94. package/dist/lib/chutes.js +62 -51
  95. package/dist/lib/claude-agent-transcript-ttl.d.ts +48 -0
  96. package/dist/lib/claude-agent-transcript-ttl.js +154 -0
  97. package/dist/lib/claude-agent-ttl-tracker.d.ts +21 -0
  98. package/dist/lib/claude-agent-ttl-tracker.js +152 -0
  99. package/dist/lib/cli-show.d.ts +5 -0
  100. package/dist/lib/cli-show.js +21 -8
  101. package/dist/lib/cli-status.js +3 -6
  102. package/dist/lib/config-write-target.d.ts +1 -1
  103. package/dist/lib/config-write-target.js +5 -2
  104. package/dist/lib/config.d.ts +2 -1
  105. package/dist/lib/config.js +257 -4
  106. package/dist/lib/copilot.js +171 -86
  107. package/dist/lib/dashboard-visibility.d.ts +5 -0
  108. package/dist/lib/dashboard-visibility.js +11 -10
  109. package/dist/lib/dashboard-web-policy.d.ts +4 -4
  110. package/dist/lib/dashboard-web-policy.js +2 -2
  111. package/dist/lib/deepseek.js +25 -13
  112. package/dist/lib/display-sanitize.js +2 -0
  113. package/dist/lib/entries.d.ts +33 -1
  114. package/dist/lib/entries.js +6 -0
  115. package/dist/lib/glm-coding-plan.js +98 -74
  116. package/dist/lib/google-agy.js +90 -12
  117. package/dist/lib/google-gemini-cli.js +84 -11
  118. package/dist/lib/grouped-entry-normalization.js +1 -1
  119. package/dist/lib/http.d.ts +4 -0
  120. package/dist/lib/http.js +16 -2
  121. package/dist/lib/init-installer.js +5 -3
  122. package/dist/lib/kilo.js +37 -18
  123. package/dist/lib/kimi.js +35 -18
  124. package/dist/lib/maintainer-announcements.js +2 -2
  125. package/dist/lib/mimo.d.ts +2 -0
  126. package/dist/lib/mimo.js +36 -0
  127. package/dist/lib/modelsdev-pricing.d.ts +74 -2
  128. package/dist/lib/modelsdev-pricing.js +457 -63
  129. package/dist/lib/modelsdev-temporal.d.ts +6 -0
  130. package/dist/lib/modelsdev-temporal.js +16 -2
  131. package/dist/lib/nanogpt.d.ts +1 -0
  132. package/dist/lib/nanogpt.js +26 -3
  133. package/dist/lib/ollama-cloud.d.ts +1 -1
  134. package/dist/lib/ollama-cloud.js +48 -35
  135. package/dist/lib/openai.js +84 -38
  136. package/dist/lib/opencode-auth-sqlite.d.ts +2 -2
  137. package/dist/lib/opencode-auth-sqlite.js +2 -2
  138. package/dist/lib/opencode-config-editor.d.ts +1 -0
  139. package/dist/lib/opencode-config-editor.js +6 -1
  140. package/dist/lib/opencode-config-providers.js +2 -2
  141. package/dist/lib/opencode-go.js +29 -2
  142. package/dist/lib/opencode-storage.d.ts +20 -0
  143. package/dist/lib/opencode-storage.js +89 -2
  144. package/dist/lib/opencode-version-core.d.ts +30 -0
  145. package/dist/lib/opencode-version-core.js +59 -0
  146. package/dist/lib/opencode-version.d.ts +2 -22
  147. package/dist/lib/opencode-version.js +4 -48
  148. package/dist/lib/opencode-warming-refresh.d.ts +19 -0
  149. package/dist/lib/opencode-warming-refresh.js +95 -0
  150. package/dist/lib/opencode-zen.d.ts +3 -0
  151. package/dist/lib/opencode-zen.js +71 -5
  152. package/dist/lib/provider-add.js +5 -2
  153. package/dist/lib/provider-metadata.d.ts +11 -3
  154. package/dist/lib/provider-metadata.js +20 -2
  155. package/dist/lib/provider-registration.d.ts +358 -9
  156. package/dist/lib/provider-registration.js +423 -30
  157. package/dist/lib/quota-auto-resume.d.ts +74 -0
  158. package/dist/lib/quota-auto-resume.js +539 -0
  159. package/dist/lib/quota-command-format.js +23 -10
  160. package/dist/lib/quota-exhaustion-projection.d.ts +11 -0
  161. package/dist/lib/quota-exhaustion-projection.js +25 -0
  162. package/dist/lib/quota-identity.d.ts +64 -0
  163. package/dist/lib/quota-identity.js +111 -0
  164. package/dist/lib/quota-providers-remote.d.ts +2 -1
  165. package/dist/lib/quota-providers-remote.js +59 -3
  166. package/dist/lib/quota-providers.d.ts +1 -1
  167. package/dist/lib/quota-providers.js +14 -37
  168. package/dist/lib/quota-render-data.d.ts +6 -0
  169. package/dist/lib/quota-render-data.js +45 -19
  170. package/dist/lib/quota-reset-notifications.js +11 -155
  171. package/dist/lib/quota-retry-wait.d.ts +106 -5
  172. package/dist/lib/quota-retry-wait.js +301 -34
  173. package/dist/lib/quota-runtime-context.js +1 -0
  174. package/dist/lib/quota-state-codec.d.ts +2 -0
  175. package/dist/lib/quota-state-codec.js +31 -2
  176. package/dist/lib/quota-state.d.ts +8 -2
  177. package/dist/lib/quota-state.js +253 -47
  178. package/dist/lib/quota-stats.d.ts +26 -0
  179. package/dist/lib/quota-stats.js +40 -1
  180. package/dist/lib/quota-status.js +3 -51
  181. package/dist/lib/quota-surface-data.js +18 -3
  182. package/dist/lib/quota-telemetry.js +2 -2
  183. package/dist/lib/resolved-auth-identity.d.ts +19 -0
  184. package/dist/lib/resolved-auth-identity.js +44 -0
  185. package/dist/lib/scoped-update.d.ts +1 -1
  186. package/dist/lib/state-file-lock.d.ts +26 -0
  187. package/dist/lib/state-file-lock.js +205 -0
  188. package/dist/lib/synthetic.js +65 -54
  189. package/dist/lib/toast-format-grouped.js +7 -4
  190. package/dist/lib/tui-compact-format.js +29 -16
  191. package/dist/lib/types.d.ts +51 -1
  192. package/dist/lib/types.js +17 -1
  193. package/dist/lib/xai.js +48 -22
  194. package/dist/plugin.js +328 -14
  195. package/dist/provider-logos/NOTICE.md +1 -1
  196. package/dist/provider-logos/OPENCODE-NOTICE.md +4 -3
  197. package/dist/providers/alibaba-coding-plan.js +125 -104
  198. package/dist/providers/alibaba-token-plan.js +9 -5
  199. package/dist/providers/anthropic.d.ts +16 -3
  200. package/dist/providers/anthropic.js +172 -220
  201. package/dist/providers/cache-policies.d.ts +11 -4
  202. package/dist/providers/cache-policies.js +19 -13
  203. package/dist/providers/chutes.js +2 -0
  204. package/dist/providers/claude-agent.d.ts +19 -0
  205. package/dist/providers/claude-agent.js +215 -0
  206. package/dist/providers/copilot.js +7 -4
  207. package/dist/providers/glm-coding-plan-provider.d.ts +1 -0
  208. package/dist/providers/glm-coding-plan-provider.js +30 -23
  209. package/dist/providers/google-account-format.js +1 -0
  210. package/dist/providers/google-agy.d.ts +6 -5
  211. package/dist/providers/google-agy.js +43 -15
  212. package/dist/providers/google-gemini-cli.js +1 -0
  213. package/dist/providers/kilo.js +1 -0
  214. package/dist/providers/kimi-code.js +2 -0
  215. package/dist/providers/mimo.js +1 -0
  216. package/dist/providers/nanogpt.js +1 -0
  217. package/dist/providers/ollama-cloud.js +10 -0
  218. package/dist/providers/openai.js +24 -23
  219. package/dist/providers/opencode-go.js +10 -6
  220. package/dist/providers/opencode-zen.js +3 -1
  221. package/dist/providers/openrouter.js +1 -0
  222. package/dist/providers/quota-providers.js +16 -5
  223. package/dist/providers/registry.js +2 -0
  224. package/dist/providers/result-helpers.d.ts +6 -2
  225. package/dist/providers/result-helpers.js +7 -1
  226. package/dist/providers/synthetic.js +4 -0
  227. package/dist/providers/xai.js +9 -8
  228. package/dist/rpc.d.ts +129 -8
  229. package/dist/rpc.js +219 -14
  230. package/dist/ui/assets/{index-cDd9jUVY.css → index-6_g1FHs-.css} +1 -1
  231. package/dist/ui/assets/index-sZnGUuML.js +10 -0
  232. package/dist/ui/assets/{popover-BGkgv9s0.js → popover-C4ZLYe9E.js} +1 -1
  233. package/dist/ui/assets/providers/claude-agent.svg +3 -0
  234. package/dist/ui/index.html +2 -2
  235. package/package.json +45 -46
  236. package/dist/lib/alibaba-coding-plan-local-quota.d.ts +0 -47
  237. package/dist/lib/alibaba-coding-plan-local-quota.js +0 -146
  238. package/dist/ui/assets/index-DLHeXYff.js +0 -9
package/README.md CHANGED
@@ -13,9 +13,9 @@ Quota, token usage, and analytics inside OpenCode Desktop. OpenCode Quota GUI ad
13
13
 
14
14
  ## Native OpenCode Desktop
15
15
 
16
- The Native panel is the primary experience in **v1.3.0**. Open **Quota & Usage** for Quota, Analytics, Models, and their detail pages; OpenCode Settings includes the plugin's **Quota & analytics** page. The session header shows a compact quota slot with a combined preview.
16
+ The Native panel is the primary experience in **v1.3.2**. Open **Quota & Usage** for Quota, Analytics, Models, and their detail pages; OpenCode Settings includes the plugin's **Quota & analytics** page. The session header shows a compact quota slot with a combined preview.
17
17
 
18
- The Native integration ships from **v1.3.0** and requires **OpenCode Desktop 2.2.0 or newer**.
18
+ The full Native integration ships from **v1.3.0** and requires **OpenCode Desktop 2.2.1 or newer**.
19
19
 
20
20
  <p align="center">
21
21
  <img src="images/opencode-quota-gui_quota.png" alt="OpenCode Desktop with the native Quota & Usage side panel showing provider account cards, remaining quota windows, and reset countdowns" />
@@ -24,9 +24,9 @@ The Native integration ships from **v1.3.0** and requires **OpenCode Desktop 2.2
24
24
  <table>
25
25
  <tr>
26
26
  <td width="50%" valign="top">
27
- <img src="images/opencode-quota-gui_session.png" alt="Session analytics in the native panel with per-step context and cumulative token charts across a session tree, compaction markers, and a session tree table" />
27
+ <img src="images/opencode-quota-gui_session.png" alt="Session analytics in the native panel showing scoped context, cumulative and cache-rate series with user-prompt markers, longest idle and high-reuse gaps, and a session tree listing each session's agent, model, cache rate and tokens" />
28
28
  <br />
29
- <sub><strong>Session analytics</strong> — per-session and whole-tree usage, compaction markers, and the session tree.</sub>
29
+ <sub><strong>Session analytics</strong> - scoped context, cumulative and cache-rate series with prompt markers, and a session tree with model and cache columns.</sub>
30
30
  </td>
31
31
  <td width="50%" valign="top">
32
32
  <img src="images/opencode-quota-gui_providers.png" alt="Models analytics grouped by provider with a stacked token chart, an API-equivalent cost line, and a cost and token breakdown by provider and model" />
@@ -46,18 +46,25 @@ The Native integration ships from **v1.3.0** and requires **OpenCode Desktop 2.2
46
46
  <sub><strong>Header Slot</strong> — at-a-glance quota rings with the combined preview open.</sub>
47
47
  </td>
48
48
  </tr>
49
+ <tr>
50
+ <td colspan="2" align="center" valign="top">
51
+ <img src="https://raw.githubusercontent.com/PVLPM/opencode-quota-gui/main/images/opencode-quota-gui_composer_pill.png" alt="OpenCode composer cache observation popover showing per-session cache reuse and estimated TTL" width="320" />
52
+ <br />
53
+ <sub><strong>Composer cache observation (v1.3.1)</strong> — measured cache-read share, estimated TTL, and recent session or agent observations. TTL is not a provider-confirmed expiry.</sub>
54
+ </td>
55
+ </tr>
49
56
  </table>
50
57
 
51
58
  ## What you get
52
59
 
53
- The Native panel is the primary surface in v1.3.0. Every feature below is available there, and the optional browser dashboard mirrors the same views as a fallback.
60
+ The Native panel is the primary surface in v1.3.2. Every feature below is available there, and the optional browser dashboard mirrors the same views as a fallback.
54
61
 
55
62
  ## Features
56
63
 
57
64
  - **Native panel:** Quota, Analytics, Models, and Settings live in OpenCode Desktop, with project, session, provider, and model drilldowns in the same side panel.
58
65
  - **Header quota slot:** compact rings for quota windows with a stable identity, plus a combined preview of every visible provider and account.
59
66
  - **Native notifications:** low quota, exhausted quota, quota reset, and provider or API failures. A focused window shows an in-app toast; a background window asks OpenCode to notify you. Set the low-quota threshold and duplicate cooldown in Settings.
60
- - **Quota by provider account:** provider logos with plan, account, or workspace labels, and one card per signed-in account, seat, API key, or workspace. Multiple logins for one provider each get their own card. Cards show the quota and rate-limit windows, reset countdowns, and balance, spend, budget, or status rows the integration supports. OpenAI cards can add banked resets and credits; Cursor and Alibaba can estimate from local history; the active login is marked `(active)`.
67
+ - **Quota by provider account:** provider logos with plan, account, or workspace labels, and one card per signed-in account, seat, API key, or workspace. Multiple logins for one provider each get their own card. Cards show the quota and rate-limit windows, reset countdowns, and balance, spend, budget, or status rows the integration supports. OpenAI cards can add banked resets and credits; Claude Agent cards can show read-only saved resets; Cursor can estimate from local history; Alibaba Coding Plan reads quota from the Bailian CLI. The active login is marked `(active)`.
61
68
  - **Peak and off-peak pricing:** for providers whose published rules define time-of-day pricing, the Quota header shows **Peak**, **Off-peak**, or **Mixed** with the next change, a per-model schedule in your local time, and holiday exceptions. Model detail pages split each provider route's historical tokens and API-equivalent cost into Peak and Off-peak rows.
62
69
  - **Analytics:** token usage over `24h`, `7d`, `30d`, or `lifetime`; a stacked daily token chart for cache read, input, reasoning, and output; a cache hit rate line; and projects you can sort by activity or tokens.
63
70
  - **Models:** stacked token charts grouped by provider or model, with an API-equivalent cost line and a sortable cost/token breakdown. Open a provider to see its models or a model to see its providers.
@@ -65,7 +72,7 @@ The Native panel is the primary surface in v1.3.0. Every feature below is availa
65
72
  - **Session detail:** per-step context and cumulative own-session and whole-tree token charts, compaction markers, and a nested session tree with steps and totals.
66
73
  - **API-equivalent estimates:** list-price estimates for recorded tokens, using the peak or off-peak rate that applied when each step completed, shown beside token totals in Analytics, Models, projects, providers, and models. They are estimates, not subscription spend.
67
74
  - **Customization:** used or remaining percentages, label style, row detail, provider selection, refresh interval, request timeout, card order, per-card or per-row visibility, and which providers show peak and off-peak status. Custom quota providers and pricing fallbacks live in the canonical config.
68
- - **Local-first operation:** no cloud account and no hosted sync; the plugin reads OpenCode data on this machine. The optional browser dashboard binds only to `127.0.0.1`. Reset-aware retry can hold a request until the provider's used-up quota window resets; turn it off with `waitForQuotaReset: false`.
75
+ - **Local-first operation:** no cloud account and no hosted sync; the plugin reads OpenCode data on this machine. The optional browser dashboard binds only to `127.0.0.1`. Reset-aware retry can hold a request until the provider's used-up quota window resets; turn it off with `waitForQuotaReset: false`. Opt-in auto-resume can instead send one `continue` after a quota-limited session's window resets.
69
76
 
70
77
  ## Quick start
71
78
 
@@ -86,9 +93,9 @@ That adds this entry to your OpenCode configuration, keeping the other plugins t
86
93
 
87
94
  OpenCode installs the configured npm plugin itself; you do not need a separate `npm install`. If you prefer to edit the config manually, add the same `opencode-quota-gui` entry to the plural `plugins` array in `~/.config/opencode/opencode.json(c)` or a project `opencode.json(c)`.
88
95
 
89
- Then open **Quota & Usage** in OpenCode Desktop. The Native panel is available from **v1.3.0** and requires **OpenCode Desktop 2.2.0 or newer**.
96
+ Then open **Quota & Usage** in OpenCode Desktop. The full Native panel is available from **v1.3.0** and requires **OpenCode Desktop 2.2.1 or newer**.
90
97
 
91
- The browser dashboard default follows the OpenCode host version. On hosts below **2.2.0**, it is on by default because the Native panel is unavailable there; at **2.2.0 or newer** it is off by default. An explicit `dashboard.enabled` value in the canonical settings always wins. When it runs, it is served on `127.0.0.1` at `dashboard.port` (default `4144`). To pin the behavior either way, edit the canonical settings file and restart OpenCode:
98
+ The browser dashboard default follows the OpenCode host version. On supported hosts below **2.2.1** (including **2.2.0**), it is on by default because the full Native panel is unavailable there; at **2.2.1 or newer** it is off by default. An explicit `dashboard.enabled` value in the canonical settings always wins. When it runs, it is served on `127.0.0.1` at `dashboard.port` (default `4144`). To pin the behavior either way, edit the canonical settings file and restart OpenCode:
92
99
 
93
100
  ```jsonc
94
101
  {
@@ -101,11 +108,11 @@ The browser dashboard default follows the OpenCode host version. On hosts below
101
108
 
102
109
  `true` forces web access on and `false` keeps it off. Then open <http://localhost:4144/quota>. The first page may show an empty dashboard until OpenCode has loaded the plugin and discovered a provider account. The path and platform overrides are in [Configuration](docs/readme/configuration.md#web-dashboard).
103
110
 
104
- Requirements: OpenCode `>= 2.0.16 < 2.3.0` and Node.js `22.13+` or `23.4+`. The Native Desktop integration ships from v1.3.0 and requires OpenCode Desktop 2.2.0+. This package does not support OpenCode 1.
111
+ Requirements: OpenCode `>= 2.0.16 < 2.5.0` and Node.js `22.13+` or `23.4+`. The full Native Desktop integration ships from v1.3.0 and requires OpenCode Desktop 2.2.1+. On supported older hosts, the browser dashboard is the automatic fallback. This package does not support OpenCode 1.
105
112
 
106
113
  ## Native panel
107
114
 
108
- In OpenCode Desktop 2.2.0+, **Quota & Usage** opens the product in the side panel, and OpenCode Settings includes the plugin's **Quota & analytics** page. The session header shows compact quota rings; select the slot for the combined preview.
115
+ In OpenCode Desktop 2.2.1+, **Quota & Usage** opens the product in the side panel, and OpenCode Settings includes the plugin's **Quota & analytics** page. The session header shows compact quota rings; select the slot for the combined preview.
109
116
 
110
117
  - **Quota:** cards for discovered provider accounts, ordered and grouped by provider. Each card shows the provider mark, plan and account or workspace labels, the rows the integration supports, a compact percentage bar for percentage rows, reset countdowns, and card-local errors. OpenAI cards can include banked resets and credits. Multiple logins for one provider get their own cards, and the active login is marked `(active)`. For providers with time-based pricing, the header shows live peak and off-peak status; open a status for its schedule, next change, and holiday exceptions.
111
118
  - **Analytics:** total tokens and API-equivalent estimate for the selected range, a stacked token chart with cache hit rate, and projects ordered by activity or tokens. Open a project for its own token chart, worktree label, and root sessions.
@@ -115,11 +122,15 @@ In OpenCode Desktop 2.2.0+, **Quota & Usage** opens the product in the side pane
115
122
 
116
123
  The panel follows you between sessions: switching sessions reuses the same shared quota and analytics state instead of starting over, and header quota indicators stay in place across OpenCode Desktop's normal dashboard watch rotations.
117
124
 
118
- Native notifications cover low quota, exhausted quota, quota reset, and provider or API failures. The low-quota threshold and duplicate cooldown are configurable in Settings. A focused window shows an in-app toast; a background window asks OpenCode to notify you. Delivery is best effort, not exactly once.
125
+ The Native composer also shows **Cache observation**, for example `TTL ~4m 30s · Cache 99.70% · Hit`. Its percentage is the cache-read share of the last completed primary call with reliable usage data, not a session average, labelled by how much of the prompt was reused: `Low reuse` (above 0% up to 50%), `Partial reuse` (above 50% to under 90%) and `Hit` (90% or more). These are reuse-efficiency bands, not provider cache-hit semantics, so a small positive cache read is technically a cache hit but shows `Low reuse`. `Miss` is reserved for an independently confirmed zero. `Unknown` means the usage data was missing or invalid, or the share is zero: OpenCode reports a missing cache-read count as zero, so a plain zero is never shown as a confirmed `Miss`. The `~` marks the TTL countdown as an estimate; it is not an authoritative expiry, and no supported OpenCode host exposes one. For Claude Agent, a call whose cache writes are recorded as 1-hour-only with zero cache reads in its session record is estimated at 60 minutes instead of 5; an observed 1-hour write does not prove that earlier cached segments last an hour. See [Cache TTL evidence](docs/readme/cache-ttl-evidence.md) for what is and is not observable per route. Green means cache reuse is likely within an estimated retention window; yellow means the estimate is uncertain or in its final 20%; red means estimated expiry, observed invalidation, or a model change; gray means there is insufficient reliable information. An active session with confirmed prior cache reads may also show yellow when its retention is unknown, without a countdown. Colors estimate future reuse and do not guarantee the next hit or prove what a provider retained. Select a session row to open its Session Analytics in the panel without switching the active chat; its breadcrumbs link back to parent sessions.
126
+
127
+ For eligible quota windows, hover or focus the percentage or progress bar to see a linear runway estimate. It is available only when the provider data supports a reliable window projection; a reset timestamp alone is not enough. In particular, OpenCode Go's rolling five-hour window does not establish a fixed window start.
128
+
129
+ Native notifications cover low quota, exhausted quota, quota reset, and provider or API failures. The low-quota threshold and duplicate cooldown are configurable in Settings. A focused window shows an in-app toast; a background window asks OpenCode to notify you. The model-change toast has its own Settings toggle and does not control cache mismatch detection. Delivery is best effort, not exactly once.
119
130
 
120
131
  ## Optional browser dashboard
121
132
 
122
- The browser dashboard is a fallback for browser access, not the primary surface. Its default follows the OpenCode host version: on hosts below **2.2.0** it is on by default, because the Native panel requires 2.2.0 or newer; at **2.2.0 or newer** it is off by default. An explicit `dashboard.enabled: true` or `false` in the canonical settings always wins. When it runs, it is served on `127.0.0.1` at the fixed `dashboard.port` (default `4144`) only. It does not listen on network interfaces, does not fall back to another port, and has no cloud component. Local port forwarding, proxy configuration, or another process running on the same machine is outside this guarantee.
133
+ The browser dashboard is a fallback for browser access, not the primary surface. Its default follows the OpenCode host version: on supported hosts below **2.2.1**, including **2.2.0**, it is on by default because the full Native panel requires 2.2.1 or newer; at **2.2.1 or newer** it is off by default. An explicit `dashboard.enabled: true` or `false` in the canonical settings always wins. If the host version is missing or unparseable, the automatic fallback fails closed; a valid explicit setting still applies. A malformed canonical config or invalid setting also fails closed. When it runs, it is served on `127.0.0.1` at the fixed `dashboard.port` (default `4144`) only. It does not listen on network interfaces, does not fall back to another port, and has no cloud component. Local port forwarding, proxy configuration, or another process running on the same machine is outside this guarantee.
123
134
 
124
135
  The browser view exposes the same product areas:
125
136
 
@@ -143,8 +154,8 @@ The routes are real URLs, so reload and browser back/forward work:
143
154
  - **Tokens are not quota.** Quota cards show provider-reported quota, rate-limit, balance, spend, budget, or status values, plus documented local estimates for some providers. Analytics shows token activity recorded by OpenCode on this machine. A token total does not measure remaining quota, and a quota reset does not clear token history. Provider quota can include usage from outside OpenCode, while local analytics cannot see that usage.
144
155
  - **Cost estimates are not bills.** The API-equivalent figure applies list prices to recorded tokens. It is not subscription spend, an invoice, or a reconciliation of what a provider charged; plan pricing, credits, discounts, taxes, and provider billing adjustments are not applied.
145
156
  - **`Free`, `Unpriced`, and unknown tokens are distinct.** `Free` appears only for a non-empty total whose every token has an explicit zero list price. Unpriced or unknown tokens are excluded from the estimate; a mixed total is marked `Partial estimate`, and a non-empty total with no priced tokens is `Unpriced`, never `Free` or `USD 0`. A model with a missing or unrecognized identity or price can make a total partial or unpriced.
146
- - **Coverage is local and provider-limited.** Analytics covers completed steps in the local OpenCode database; other machines, other clients, deleted sessions, and activity not recorded as completed steps are absent. Historical provider/model attribution depends on the raw identities OpenCode stored. Provider coverage and plan support vary: some APIs expose only balance, spend, budget, or status, and a card cannot invent quota that the provider does not return. Cursor and Alibaba cards that use local history are estimates, not official provider totals.
147
- - **Native and browser surfaces.** The Native panel requires OpenCode Desktop 2.2.0+ and ships from v1.3.0. The optional browser dashboard binds to `127.0.0.1`; it is not a hosted service, and the package has no TUI.
157
+ - **Coverage is local and provider-limited.** Analytics covers completed steps in the local OpenCode database; other machines, other clients, deleted sessions, and activity not recorded as completed steps are absent. Historical provider/model attribution depends on the raw identities OpenCode stored. Provider coverage and plan support vary: some APIs expose only balance, spend, budget, or status, and a card cannot invent quota that the provider does not return. Cursor's local-history billing-cycle estimate is not an official provider total. Alibaba Coding Plan uses quota reported by the Bailian CLI.
158
+ - **Native and browser surfaces.** The full Native panel requires OpenCode Desktop 2.2.1+ and ships from v1.3.0. The optional browser dashboard binds to `127.0.0.1`; it is not a hosted service, and the package has no TUI.
148
159
 
149
160
  ## Providers
150
161
 
@@ -157,7 +168,8 @@ Most providers work automatically once you log in through OpenCode. A **Needs se
157
168
 
158
169
  | Provider | Auth/setup | Data from | Reports |
159
170
  | ------------------ | -------------------------------------------------------------- | ------------------ | ------------------ |
160
- | Anthropic (Claude) | [Needs setup](docs/readme/providers.md#anthropic-claude) | Local CLI/OAuth | Quota |
171
+ | Anthropic | [API key](docs/readme/providers.md#anthropic) | Observed headers | Rate limits |
172
+ | Claude Agent | [Needs setup](docs/readme/providers.md#claude-agent) | Local CLI/OAuth | Quota |
161
173
  | Chutes AI | Automatic | Remote API | Quota |
162
174
  | Cursor | [Needs setup](docs/readme/providers.md#cursor) | Local estimate | Budget and spend |
163
175
  | GitHub Copilot | Automatic | Remote API | Budget and usage |
@@ -179,7 +191,8 @@ Most providers work automatically once you log in through OpenCode. A **Needs se
179
191
 
180
192
  | Provider | Auth/setup | Data from | Reports |
181
193
  | ----------------------- | -------------------------------------------------------------- | ------------------ | ------------------ |
182
- | Anthropic (Claude) | [Needs setup](docs/readme/providers.md#anthropic-claude) | Local CLI/OAuth | Quota |
194
+ | Anthropic | [API key](docs/readme/providers.md#anthropic) | Observed headers | Rate limits |
195
+ | Claude Agent | [Needs setup](docs/readme/providers.md#claude-agent) | Local CLI/OAuth | Quota |
183
196
  | Chutes AI | Automatic | Remote API | Quota |
184
197
  | Cursor | [Needs setup](docs/readme/providers.md#cursor) | Local estimate | Budget and spend |
185
198
  | Gemini CLI | [Needs setup](docs/readme/providers.md#gemini-cli) | Remote API | Quota |
@@ -203,7 +216,7 @@ Gemini CLI works only with Gemini Code Assist Standard or Enterprise (organizati
203
216
 
204
217
  | Provider | Auth/setup | Data from | Reports |
205
218
  | ----------------------------- | ---------------------------------------------------------------------------- | -------------- | ------------------ |
206
- | Alibaba Coding Plan | Automatic | Local estimate | Quota |
219
+ | Alibaba Coding Plan | [Needs setup](docs/readme/providers.md#alibaba-coding-plan) | Official CLI | Quota |
207
220
  | Alibaba Personal Token Plan | [Needs setup](docs/readme/providers.md#alibaba-personal-token-plan) | Official CLI | Quota |
208
221
  | DeepSeek | Automatic | Remote API | Balance and status |
209
222
  | Kimi Code | Automatic | Remote API | Quota |
@@ -246,9 +259,10 @@ The plugin reads only the canonical file at runtime:
246
259
  `$XDG_CONFIG_HOME/opencode` replaces `~/.config/opencode` when `XDG_CONFIG_HOME` is set, and `OPENCODE_CONFIG_DIR` replaces the global OpenCode config folder. The sibling `config.json` is not read, converted, or imported; it is preserved unchanged. Changes made in `Settings` write to this canonical file. Settings values, source labels, the port, and visibility lists come only from the canonical file and defaults, regardless of whether OpenCode uses `opencode.json` or `opencode.jsonc`. Selecting a project install in `init` adds only the project OpenCode plugin entry; behavior settings remain global. Inherited legacy values are available only through the separate import preview.
247
260
 
248
261
  - **Legacy import:** when a global legacy OpenCode Quota source exists, Settings can preview and copy seven compatible keys: `percentDisplayMode`, `percentLabelStyle`, `enabledProviders`, `minIntervalMs`, `requestTimeoutMs`, `accountingDetail`, and `waitForQuotaReset`. The import is read-only for the source; files stay byte-for-byte untouched. Custom provider definitions are not imported, so copy `quotaProviders` into the canonical file yourself.
262
+ - **Auto-resume on quota recovery:** off by default (`autoResumeOnQuotaRecovery`). When on, a session that terminally fails on a provider quota limit gets one `continue` prompt after the failed route's exhausted primary window is observed as reset, following two minutes of inactivity (temporary check failures keep it pending; they never authorize it), and only if the session is still failed, idle and on the same model. It appears as a user message, never replays tool actions, and is dropped if OpenCode or the plugin restarts. One resume is consumed per user-initiated execution; a quota failure after that `continue` waits for a fresh user prompt. Evidence must be bound to one verified identity: an active OpenCode account row, or, for a route whose adapter exposes no account rows, the provider cache identity. Supported: Claude Agent, Copilot, OpenAI, Synthetic, Chutes, Z.ai, Zhipu, NanoGPT, MiniMax Token Plan, MiniMax Token Plan (CN), xAI, OpenCode Go, OpenCode Zen, Ollama Cloud. A route whose provider registration has no auto-resume contract is rejected before the live quota probe and is not polled. Claude Agent's known untyped five-hour and weekly subscription-limit messages are recognized, but only the independent observation of the applicable window exhausted for the same Claude identity can authorize the continuation; native retry is unchanged. The full eligibility matrix and exclusions are in [configuration](docs/readme/configuration.md#auto-resume-on-quota-recovery).
249
263
  - **Visibility:** hiding a provider or row is presentation only and never changes polling or provider data. Opaque card and row IDs in `dashboard.hiddenCards` and `dashboard.hiddenRows` are internal identifiers: use **Settings → Visibility** to manage them instead of editing or deriving IDs by hand.
250
264
  - **Temporal pricing:** `dashboard.temporalProviderOverrides` stores sparse per-provider on/off choices for the live peak and off-peak status in the Quota header. A provider with a discovered account is shown by default; an explicit choice wins. Hiding a status is presentation only and never changes polling, quota values, or recorded usage.
251
- - **Web dashboard (optional fallback):** on by default below OpenCode 2.2.0 and off by default at 2.2.0 and newer. An explicit `"dashboard": { "enabled": true }` or `"dashboard": { "enabled": false }` in the canonical file always wins. When enabled, the browser UI is served on `127.0.0.1` at `dashboard.port` (default `4144`), and the server never falls back to another port. Changes apply after an OpenCode restart.
265
+ - **Web dashboard (optional fallback):** on by default below OpenCode 2.2.1 (including 2.2.0) and off by default at 2.2.1 and newer. An explicit `"dashboard": { "enabled": true }` or `"dashboard": { "enabled": false }` in the canonical file always wins. When enabled, the browser UI is served on `127.0.0.1` at `dashboard.port` (default `4144`), and the server never falls back to another port. Missing/unparseable host versions and malformed or invalid canonical settings fail closed when the switch is absent. Changes apply after an OpenCode restart.
252
266
  - **Browser storage:** the dashboard uses browser-local storage for display state such as the selected range and a visibility-catalog cache. It does not use cross-site cookies.
253
267
  - **Local data:** the plugin reads OpenCode's local configuration and login data through OpenCode, plus OpenCode's local session database for usage and session views. Provider quota checks use the provider's API or the documented local CLI or companion plugin. Token pricing can come from the bundled snapshot or `models.dev` at runtime. Peak and off-peak rules ship in the bundled snapshot and are evaluated locally.
254
268
  - **OpenTelemetry (optional):** off by default. Set `"telemetry": { "enabled": true }` in the canonical file to publish two gauges, `opencode.quota.consumed` and `opencode.quota.cache.age`, through the `@opentelemetry/api` global `MeterProvider` that your host process configures. The plugin does not create a `MeterProvider`, exporter, collector, or metrics endpoint, sends no metrics by itself, and makes no extra provider requests for telemetry. Metric names and attributes are not a public API. See [External integration](docs/readme/external-integration.md#optional-opentelemetry-advanced-host-owned).
@@ -279,7 +293,7 @@ This project has no TUI panel, terminal quota interface or reports, slash comman
279
293
 
280
294
  It is independent of the upstream `@slkiser/opencode-quota` package. The two packages may be configured at the same time, and there is no dependency or conflict guard between them. Each owns its configuration and private state; this package writes under the `opencode-quota-gui` namespace and does not migrate, rewrite, or delete upstream configuration, cache, or credential files.
281
295
 
282
- The browser dashboard default follows the OpenCode host version: it is on by default below 2.2.0, where the Native panel does not exist, and off by default at 2.2.0 and newer. An explicit `dashboard.enabled` value in the canonical settings always wins. Either way, the server stays loopback-only on `127.0.0.1`.
296
+ The browser dashboard default follows the OpenCode host version: it is on by default below 2.2.1 (including 2.2.0), where the full Native panel is unavailable, and off by default at 2.2.1 and newer. An explicit `dashboard.enabled` value in the canonical settings always wins. Either way, the server stays loopback-only on `127.0.0.1`.
283
297
 
284
298
  Use the upstream project if you want its terminal surfaces. Use this project if you want quota and usage inside OpenCode Desktop. See [Updating safely](docs/readme/updating.md) for migration and coexistence details.
285
299
 
File without changes
@@ -1 +1 @@
1
- export const BUILD_IDENTITY = Object.freeze({"version":"1.3.0","build":"fea4e867c45c"});
1
+ export const BUILD_IDENTITY = Object.freeze({"version":"1.3.2","build":"c6a0d0f63ee7"});
@@ -7,6 +7,8 @@
7
7
  * The caller assembles the real cards first, then asks for a display order, so
8
8
  * same-provider siblings are ordered independently.
9
9
  */
10
+ export declare function rankByIds(preference: readonly string[] | undefined, knownIds: ReadonlySet<string>): Map<string, number>;
11
+ export declare function stableSortByRank<T>(cards: readonly T[], rankOf: (card: T) => number): T[];
10
12
  /**
11
13
  * Returns a fresh card array ordered for presentation.
12
14
  *
@@ -8,7 +8,7 @@
8
8
  * same-provider siblings are ordered independently.
9
9
  */
10
10
  const UNKNOWN_RANK = Number.POSITIVE_INFINITY;
11
- function rankByIds(preference, knownIds) {
11
+ export function rankByIds(preference, knownIds) {
12
12
  const ranks = new Map();
13
13
  if (preference === undefined)
14
14
  return ranks;
@@ -19,7 +19,7 @@ function rankByIds(preference, knownIds) {
19
19
  }
20
20
  return ranks;
21
21
  }
22
- function stableSortByRank(cards, rankOf) {
22
+ export function stableSortByRank(cards, rankOf) {
23
23
  return cards
24
24
  .map((card, index) => ({ card, index, rank: rankOf(card) }))
25
25
  .sort((left, right) => left.rank === right.rank ? left.index - right.index : left.rank - right.rank)
@@ -6,7 +6,8 @@
6
6
  * exact `cardId`, its `providerId`, or its authoritative bare provider-scope
7
7
  * hash. Effective server settings normalize legacy full scope ids to
8
8
  * `providerId`; every full card id is now an exact hide. Row hiding is a
9
- * separate, exact `rowId` check and is not affected by this helper.
9
+ * separate check in `row-visibility.ts`, which resolves pre-window aggregate
10
+ * row ids against the card's first emitted typed row.
10
11
  */
11
12
  export interface ProviderVisibilityIdentity {
12
13
  providerId: string;
@@ -6,7 +6,8 @@
6
6
  * exact `cardId`, its `providerId`, or its authoritative bare provider-scope
7
7
  * hash. Effective server settings normalize legacy full scope ids to
8
8
  * `providerId`; every full card id is now an exact hide. Row hiding is a
9
- * separate, exact `rowId` check and is not affected by this helper.
9
+ * separate check in `row-visibility.ts`, which resolves pre-window aggregate
10
+ * row ids against the card's first emitted typed row.
10
11
  */
11
12
  /** Consume normalized settings; never guess old semantics from the current catalog. */
12
13
  export function isLegacyProviderHidden(card, hidden) {
@@ -1,7 +1,7 @@
1
1
  import type { AnalyticsTemporalBreakdown } from "./analytics-temporal.js";
2
2
  import type { CardId, RowId } from "./identity.js";
3
3
  import type { BankedResetAvailability } from "./openai-quota.js";
4
- import type { ProviderFailureCategory } from "./provider-failure.js";
4
+ import type { ProviderFailureCategory, QuotaAttemptOutcome } from "./provider-failure.js";
5
5
  import type { BucketUnit, RangeKey, RangeWindow } from "./ranges.js";
6
6
  import type { TemporalStatusSnapshot } from "./temporal.js";
7
7
  /**
@@ -70,6 +70,16 @@ export interface CostedTokens extends TokenStack {
70
70
  apiEquivalentCostUsd: number | null;
71
71
  unpricedTokens: number;
72
72
  unknownTokens: number;
73
+ /**
74
+ * Portion of `apiEquivalentCostUsd` that came from OpenCode's recorded
75
+ * per-message cost because models.dev could not price the route.
76
+ */
77
+ recordedCostUsd?: number;
78
+ /**
79
+ * Tokens priced by that recorded-cost fallback. They are already included in
80
+ * the priced total and are never counted as unpriced/unknown tokens.
81
+ */
82
+ recordedCostTokens?: number;
73
83
  }
74
84
  export interface Bucket {
75
85
  startMs: number;
@@ -282,6 +292,8 @@ export interface PrimaryQuotaWindowRef {
282
292
  slot: PrimaryQuotaWindowSlot;
283
293
  }
284
294
  export interface ProviderCard {
295
+ /** Rows are retained from the last successful measurement. */
296
+ stale?: true;
285
297
  cardId: CardId;
286
298
  providerId: string;
287
299
  providerLabel: string;
@@ -311,6 +323,13 @@ export interface ProviderCard {
311
323
  label: string;
312
324
  message: string;
313
325
  retryable?: boolean;
326
+ retryAtMs?: number;
327
+ /**
328
+ * Outcome of the attempt behind this error. A `cooldown` skip made no
329
+ * request, so it is displayed as a muted retry notice, never a failure.
330
+ */
331
+ attemptOutcome?: QuotaAttemptOutcome;
332
+ kind?: "intentional-filter";
314
333
  /** Source-assigned safe category; absence means unknown and consumers fail closed. */
315
334
  failureCategory?: ProviderFailureCategory;
316
335
  }[];
@@ -323,11 +342,14 @@ export interface ProviderCard {
323
342
  /**
324
343
  * Persistent optional-row choices (additive): stable ids and labels exist
325
344
  * even when runtime values are absent. Never synthetic zero data rows.
345
+ * `rowId` is the stable declared field id; `aliases` lists the emitted row
346
+ * ids that render the same field in another shape.
326
347
  */
327
348
  visibilityRows?: {
328
349
  rowId: RowId;
329
350
  label: string;
330
351
  info?: string;
352
+ aliases?: RowId[];
331
353
  }[];
332
354
  }
333
355
  export interface ProjectActivityRow {
@@ -341,6 +363,14 @@ export interface HomeSnapshot {
341
363
  generatedAtMs: number;
342
364
  range: RangeKey;
343
365
  stale: boolean;
366
+ provisional?: true;
367
+ /**
368
+ * Additive: the exact replacement behind a provisional paint failed. The
369
+ * provisional data stays visible; the UI clears its pending ring and offers
370
+ * a retry. Absent while the exact read is pending or after it succeeds.
371
+ */
372
+ exactError?: string;
373
+ /** `polledAtMs` is a poll time, not a guarantee that every provider succeeded. */
344
374
  providers: {
345
375
  cards: ProviderCard[];
346
376
  enabledProviders: string[] | "auto";
@@ -349,6 +379,14 @@ export interface HomeSnapshot {
349
379
  usage: Usage;
350
380
  projects: ProjectActivityRow[];
351
381
  }
382
+ /** Positional analytics reads shared by the engine and worker transport. */
383
+ export interface AnalyticsRangeReader {
384
+ home(range: RangeKey, exact?: boolean, background?: boolean): Promise<HomeSnapshot>;
385
+ project(projectId: string, range: RangeKey): Promise<ProjectSnapshot>;
386
+ session(sessionId: string): Promise<SessionSnapshot>;
387
+ groups(query: AnalyticsGroupQuery): Promise<AnalyticsGroupSnapshot>;
388
+ refresh(): Promise<void>;
389
+ }
352
390
  /**
353
391
  * Independent quota/provider read (transport contract). Analytics never waits
354
392
  * on this; a quota viewer never starts the analytics worker.
@@ -399,20 +437,50 @@ export interface SessionNode {
399
437
  stepCount: number;
400
438
  subtreeNodeCount: number;
401
439
  latestActivityAtMs: number;
440
+ /**
441
+ * Distinct provider/model/effort identities this session itself used,
442
+ * deduplicated by the complete identity and ordered by most recent actual
443
+ * use. `models[0]` is the last used identity; empty when none was recorded.
444
+ */
445
+ models: ModelIdentity[];
446
+ /**
447
+ * Own steps whose stored message lacked a cache-read or cache-write counter.
448
+ * Their 0 is unknown, so the session's cache rate is unknown when this is
449
+ * positive. Omitted when every own step recorded both counters.
450
+ */
451
+ cacheUnknownSteps?: number;
452
+ }
453
+ /** Provider/model plus the reasoning effort only when OpenCode recorded one. */
454
+ export interface ModelIdentity {
455
+ providerId: string;
456
+ modelId: string;
457
+ effort?: string;
402
458
  }
403
459
  export interface StepPoint {
404
460
  sessionId: string;
405
461
  messageId: string;
462
+ /** Completion time of the assistant message (the step's chart position). */
406
463
  atMs: number;
464
+ /**
465
+ * OpenCode's stored assistant-message creation time. Not a request-start
466
+ * timestamp; absent when it was not recorded as a positive number.
467
+ */
468
+ createdAtMs?: number;
407
469
  branch: number;
408
470
  stack: TokenStack;
409
471
  contextTokens: number;
410
472
  totalTokens: number;
411
- model?: {
412
- providerId: string;
413
- modelId: string;
414
- };
473
+ model?: ModelIdentity;
415
474
  agent?: string;
475
+ /** The message stored no cache-read counter: `stack.cacheRead` 0 is unknown, not observed. */
476
+ cacheReadUnknown?: true;
477
+ /** Same for the cache-write counter. */
478
+ cacheWriteUnknown?: true;
479
+ /**
480
+ * The first assistant step after a user-role message in this step's own
481
+ * session. Position only: the DTO never carries prompt text.
482
+ */
483
+ inputMarker?: true;
416
484
  }
417
485
  export interface SessionSnapshot {
418
486
  focusSessionId: string;
@@ -433,6 +501,13 @@ export interface SessionSnapshot {
433
501
  atMs: number;
434
502
  messageId: string;
435
503
  }[];
504
+ /**
505
+ * Positions (creation time, else completion time) of the focus session's own
506
+ * completed assistant messages that are NOT in `steps` (zero-token rows,
507
+ * fork copies owned elsewhere). A gap spanning one is never bridged.
508
+ * Omitted when there are none.
509
+ */
510
+ unobservedAtMs?: number[];
436
511
  ownSummary: CostedTokens & {
437
512
  stepCount: number;
438
513
  };
@@ -510,8 +585,12 @@ export interface DashboardDataSource {
510
585
  health(): Promise<DashboardHealth>;
511
586
  home(input: {
512
587
  range: RangeKey;
588
+ exact?: boolean;
589
+ background?: boolean;
513
590
  }): Promise<HomeSnapshot>;
514
- quota(): Promise<QuotaSnapshot>;
591
+ quota(input?: {
592
+ refresh?: boolean;
593
+ }): Promise<QuotaSnapshot>;
515
594
  project(input: {
516
595
  projectId: string;
517
596
  range: RangeKey;
@@ -544,4 +623,14 @@ export interface DashboardDataSource {
544
623
  }
545
624
  /** Read/write config seam for the GUI server (P2 store satisfies this Pick). */
546
625
  export type GuiSettingsStore = Pick<DashboardDataSource, "settings" | "saveSettings" | "saveVisibility" | "importPreview" | "importApply" | "openSettingsFile">;
626
+ /**
627
+ * Cold 7d/30d/lifetime analytics catch-up reads the full source store and can
628
+ * legitimately take tens of seconds on a slow local disk; a foreground request
629
+ * queued behind one can add its own scoped read. The old 90 s budget retired
630
+ * healthy workers mid-read on measured sources. Keep a finite budget above the
631
+ * measured worst request (112.9 s on the reported source), so genuinely stuck
632
+ * workers are still retired and recovered on the next request. The Analytics
633
+ * view also stops re-joining a host-timed-out read after this long.
634
+ */
635
+ export declare const ANALYTICS_DEFAULT_REQUEST_TIMEOUT_MS = 180000;
547
636
  //# sourceMappingURL=dashboard.d.ts.map
@@ -2,4 +2,14 @@
2
2
  export const DASHBOARD_CONTRACT_VERSION = 2;
3
3
  /** Approved maximum number of primary quota-window references per card. */
4
4
  export const PRIMARY_QUOTA_WINDOW_LIMIT = 3;
5
+ /**
6
+ * Cold 7d/30d/lifetime analytics catch-up reads the full source store and can
7
+ * legitimately take tens of seconds on a slow local disk; a foreground request
8
+ * queued behind one can add its own scoped read. The old 90 s budget retired
9
+ * healthy workers mid-read on measured sources. Keep a finite budget above the
10
+ * measured worst request (112.9 s on the reported source), so genuinely stuck
11
+ * workers are still retired and recovered on the next request. The Analytics
12
+ * view also stops re-joining a host-timed-out read after this long.
13
+ */
14
+ export const ANALYTICS_DEFAULT_REQUEST_TIMEOUT_MS = 180_000;
5
15
  //# sourceMappingURL=dashboard.js.map
@@ -9,6 +9,9 @@
9
9
  * reused rather than re-implemented.
10
10
  */
11
11
  import type { AnalyticsGroupQuery, AnalyticsGroupSnapshot, DashboardHealth, HomeSnapshot, ImportPreview, JsonValue, ProjectSnapshot, QuotaSnapshot, SessionSnapshot, SettingsSnapshot, SettingsWriteResult } from "./dashboard.js";
12
+ type RecordValue = Record<string, unknown>;
13
+ export declare function isRecord(value: unknown): value is RecordValue;
14
+ export declare function isText(value: unknown): value is string;
12
15
  export declare function isJsonValue(value: unknown, depth?: number): value is JsonValue;
13
16
  export declare function isDashboardHealth(value: unknown): value is DashboardHealth;
14
17
  export declare function isQuotaSnapshot(value: unknown): value is QuotaSnapshot;
@@ -21,4 +24,5 @@ export declare function isSessionSnapshot(value: unknown): value is SessionSnaps
21
24
  export declare function isSettingsSnapshot(value: unknown): value is SettingsSnapshot;
22
25
  export declare function isSettingsWriteResult(value: unknown): value is SettingsWriteResult;
23
26
  export declare function isImportPreview(value: unknown): value is ImportPreview;
27
+ export {};
24
28
  //# sourceMappingURL=dto-guards.d.ts.map
@@ -10,7 +10,7 @@
10
10
  */
11
11
  import { PRIMARY_QUOTA_WINDOW_LIMIT } from "./dashboard.js";
12
12
  import { isCostedTokens, isTokenStack } from "./guards.js";
13
- import { isProviderFailureCategory } from "./provider-failure.js";
13
+ import { isProviderFailureCategory, isQuotaAttemptOutcome, } from "./provider-failure.js";
14
14
  import { isRangeKey } from "./ranges.js";
15
15
  const RESULT_TYPES = [
16
16
  "quota",
@@ -31,10 +31,10 @@ const TEMPORAL_EFFECT_DIRECTIONS = ["peak", "offpeak", "unchanged"];
31
31
  const TEMPORAL_EFFECT_UNITS = ["api_price", "quota_points"];
32
32
  const TEMPORAL_HOLIDAYS = ["CN", "US", "CA"];
33
33
  const TEMPORAL_WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
34
- function isRecord(value) {
34
+ export function isRecord(value) {
35
35
  return typeof value === "object" && value !== null && !Array.isArray(value);
36
36
  }
37
- function isText(value) {
37
+ export function isText(value) {
38
38
  return typeof value === "string";
39
39
  }
40
40
  function isBoolean(value) {
@@ -201,6 +201,8 @@ function isProviderCard(value) {
201
201
  return false;
202
202
  if (!isOptional(value.accountLabel, isText))
203
203
  return false;
204
+ if (!isOptional(value.stale, (stale) => stale === true))
205
+ return false;
204
206
  if (!isOptional(value.providerScopeId, isText))
205
207
  return false;
206
208
  if (!isOptional(value.providerScopeHash, isText))
@@ -211,13 +213,20 @@ function isProviderCard(value) {
211
213
  isText(entry.label) &&
212
214
  isText(entry.message) &&
213
215
  isOptional(entry.retryable, isBoolean) &&
216
+ isOptional(entry.retryAtMs, isFiniteNumber) &&
217
+ isOptional(entry.attemptOutcome, isQuotaAttemptOutcome) &&
218
+ isOptional(entry.kind, (kind) => kind === "intentional-filter") &&
214
219
  isOptional(entry.failureCategory, isProviderFailureCategory)))) {
215
220
  return false;
216
221
  }
217
222
  if (!isOptional(value.details, (details) => isArrayOf(details, (entry) => isRecord(entry) && isText(entry.label) && isText(entry.value)))) {
218
223
  return false;
219
224
  }
220
- if (!isOptional(value.visibilityRows, (rows) => isArrayOf(rows, (row) => isRecord(row) && isText(row.rowId) && isText(row.label) && isOptional(row.info, isText)))) {
225
+ if (!isOptional(value.visibilityRows, (rows) => isArrayOf(rows, (row) => isRecord(row) &&
226
+ isText(row.rowId) &&
227
+ isText(row.label) &&
228
+ isOptional(row.info, isText) &&
229
+ isOptional(row.aliases, (aliases) => isArrayOf(aliases, isText))))) {
221
230
  return false;
222
231
  }
223
232
  const rowsById = new Map(value.rows.map((row) => [row.rowId, row]));
@@ -388,6 +397,8 @@ export function isHomeSnapshot(value) {
388
397
  isFiniteNumber(value.generatedAtMs) &&
389
398
  isRangeKey(value.range) &&
390
399
  isBoolean(value.stale) &&
400
+ isOptional(value.provisional, (provisional) => provisional === true) &&
401
+ isOptional(value.exactError, isText) &&
391
402
  isProviders(value.providers) &&
392
403
  isUsage(value.usage) &&
393
404
  isArrayOf(value.projects, isProjectActivityRow));
@@ -489,6 +500,12 @@ export function isProjectSnapshot(value) {
489
500
  function isSessionBreadcrumb(value) {
490
501
  return (isRecord(value) && isText(value.sessionId) && isText(value.title) && isBoolean(value.isFocus));
491
502
  }
503
+ function isModelIdentity(value) {
504
+ return (isRecord(value) &&
505
+ isText(value.providerId) &&
506
+ isText(value.modelId) &&
507
+ isOptional(value.effort, isText));
508
+ }
492
509
  function isSessionNode(value) {
493
510
  return (isRecord(value) &&
494
511
  isText(value.sessionId) &&
@@ -502,19 +519,25 @@ function isSessionNode(value) {
502
519
  isCostedTokens(value.subtreeTokens) &&
503
520
  isFiniteNumber(value.stepCount) &&
504
521
  isFiniteNumber(value.subtreeNodeCount) &&
505
- isFiniteNumber(value.latestActivityAtMs));
522
+ isFiniteNumber(value.latestActivityAtMs) &&
523
+ isArrayOf(value.models, isModelIdentity) &&
524
+ isOptional(value.cacheUnknownSteps, isFiniteNumber));
506
525
  }
507
526
  function isStepPoint(value) {
508
527
  return (isRecord(value) &&
509
528
  isText(value.sessionId) &&
510
529
  isText(value.messageId) &&
511
530
  isFiniteNumber(value.atMs) &&
531
+ isOptional(value.createdAtMs, isFiniteNumber) &&
512
532
  isFiniteNumber(value.branch) &&
513
533
  isTokenStack(value.stack) &&
514
534
  isFiniteNumber(value.contextTokens) &&
515
535
  isFiniteNumber(value.totalTokens) &&
516
- isOptional(value.model, (model) => isRecord(model) && isText(model.providerId) && isText(model.modelId)) &&
517
- isOptional(value.agent, isText));
536
+ isOptional(value.model, isModelIdentity) &&
537
+ isOptional(value.agent, isText) &&
538
+ isOptional(value.cacheReadUnknown, (flag) => flag === true) &&
539
+ isOptional(value.cacheWriteUnknown, (flag) => flag === true) &&
540
+ isOptional(value.inputMarker, (flag) => flag === true));
518
541
  }
519
542
  function isCompactionMarker(value) {
520
543
  return (isRecord(value) &&
@@ -533,6 +556,7 @@ export function isSessionSnapshot(value) {
533
556
  isArrayOf(value.nodes, isSessionNode) &&
534
557
  isArrayOf(value.steps, isStepPoint) &&
535
558
  isArrayOf(value.compactionMarkers, isCompactionMarker) &&
559
+ isOptional(value.unobservedAtMs, (list) => isArrayOf(list, isFiniteNumber)) &&
536
560
  isCostedTokens(value.ownSummary) &&
537
561
  isFiniteNumber(value.ownSummary.stepCount) &&
538
562
  isCostedTokens(value.treeTotals) &&
@@ -41,7 +41,9 @@ export function isCostedTokens(value) {
41
41
  (value.apiEquivalentCostUsd === null ||
42
42
  isNonNegativeFiniteNumber(value.apiEquivalentCostUsd)) &&
43
43
  isNonNegativeFiniteNumber(value.unpricedTokens) &&
44
- isNonNegativeFiniteNumber(value.unknownTokens));
44
+ isNonNegativeFiniteNumber(value.unknownTokens) &&
45
+ (value.recordedCostUsd === undefined || isNonNegativeFiniteNumber(value.recordedCostUsd)) &&
46
+ (value.recordedCostTokens === undefined || isNonNegativeFiniteNumber(value.recordedCostTokens)));
45
47
  }
46
48
  export function isDashboardEvent(value) {
47
49
  if (!isRecord(value))