opencode-quota-gui 1.1.0 → 1.3.0

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 (533) hide show
  1. package/README.md +96 -34
  2. package/dist/bin/opencode-quota-gui.js +0 -0
  3. package/dist/contracts/analytics-entity.d.ts +6 -1
  4. package/dist/contracts/analytics-entity.js +27 -10
  5. package/dist/contracts/analytics-temporal.d.ts +39 -0
  6. package/dist/contracts/analytics-temporal.js +11 -0
  7. package/dist/contracts/build-identity.js +1 -1
  8. package/dist/contracts/card-visibility.d.ts +21 -0
  9. package/dist/contracts/card-visibility.js +19 -0
  10. package/dist/contracts/dashboard.d.ts +40 -0
  11. package/dist/contracts/dashboard.js +2 -0
  12. package/dist/contracts/dto-guards.d.ts +24 -0
  13. package/dist/contracts/dto-guards.js +592 -0
  14. package/dist/contracts/provider-failure.d.ts +18 -0
  15. package/dist/contracts/provider-failure.js +25 -0
  16. package/dist/contracts/temporal.d.ts +126 -0
  17. package/dist/contracts/temporal.js +10 -0
  18. package/dist/data/modelsdev-temporal.min.json +3075 -0
  19. package/dist/gui/aggregation.js +3 -0
  20. package/dist/gui/analytics-engine.js +30 -0
  21. package/dist/gui/analytics-model.js +181 -1
  22. package/dist/gui/analytics-pricing-revision.d.ts +43 -0
  23. package/dist/gui/analytics-pricing-revision.js +160 -0
  24. package/dist/gui/analytics-state.d.ts +7 -2
  25. package/dist/gui/analytics-state.js +14 -2
  26. package/dist/gui/config.d.ts +20 -3
  27. package/dist/gui/config.js +60 -3
  28. package/dist/gui/dashboard-errors.d.ts +32 -0
  29. package/dist/gui/dashboard-errors.js +97 -0
  30. package/dist/gui/lifecycle.d.ts +44 -11
  31. package/dist/gui/lifecycle.js +214 -36
  32. package/dist/gui/primary-quota-windows.d.ts +28 -0
  33. package/dist/gui/primary-quota-windows.js +147 -0
  34. package/dist/gui/provider-cards.d.ts +1 -1
  35. package/dist/gui/provider-cards.js +40 -16
  36. package/dist/gui/quota-notification-detector.d.ts +151 -0
  37. package/dist/gui/quota-notification-detector.js +284 -0
  38. package/dist/gui/quota-notification-observer.d.ts +55 -0
  39. package/dist/gui/quota-notification-observer.js +363 -0
  40. package/dist/gui/rpc.d.ts +59 -0
  41. package/dist/gui/rpc.js +302 -0
  42. package/dist/gui/server.d.ts +15 -27
  43. package/dist/gui/server.js +23 -121
  44. package/dist/gui/snapshot-service.d.ts +31 -4
  45. package/dist/gui/snapshot-service.js +177 -54
  46. package/dist/gui/sources.d.ts +1 -1
  47. package/dist/gui/sources.js +28 -0
  48. package/dist/gui/temporal-quota-policy-data.d.ts +24 -0
  49. package/dist/gui/temporal-quota-policy-data.js +43 -0
  50. package/dist/gui/temporal-quota-policy.d.ts +38 -0
  51. package/dist/gui/temporal-quota-policy.js +182 -0
  52. package/dist/gui/temporal-status.d.ts +53 -0
  53. package/dist/gui/temporal-status.js +815 -0
  54. package/dist/gui-experimental.cjs +1756 -0
  55. package/dist/lib/anthropic.d.ts +5 -0
  56. package/dist/lib/anthropic.js +18 -1
  57. package/dist/lib/chutes.js +19 -2
  58. package/dist/lib/config.d.ts +5 -1
  59. package/dist/lib/config.js +81 -0
  60. package/dist/lib/copilot.js +42 -14
  61. package/dist/lib/dashboard-web-policy.d.ts +35 -0
  62. package/dist/lib/dashboard-web-policy.js +24 -0
  63. package/dist/lib/deepseek.js +12 -1
  64. package/dist/lib/display-sanitize.js +2 -0
  65. package/dist/lib/entries.d.ts +3 -0
  66. package/dist/lib/format-utils.d.ts +1 -1
  67. package/dist/lib/format-utils.js +2 -2
  68. package/dist/lib/glm-coding-plan.js +14 -4
  69. package/dist/lib/google-agy.js +59 -14
  70. package/dist/lib/google-gemini-cli.js +58 -14
  71. package/dist/lib/init-installer.js +25 -4
  72. package/dist/lib/kilo.js +29 -40
  73. package/dist/lib/kimi.js +13 -1
  74. package/dist/lib/mimo.d.ts +2 -0
  75. package/dist/lib/mimo.js +9 -1
  76. package/dist/lib/modelsdev-temporal.d.ts +143 -0
  77. package/dist/lib/modelsdev-temporal.js +896 -0
  78. package/dist/lib/nanogpt.d.ts +2 -0
  79. package/dist/lib/nanogpt.js +24 -3
  80. package/dist/lib/ollama-cloud.js +9 -0
  81. package/dist/lib/openai.js +6 -2
  82. package/dist/lib/opencode-auth.d.ts +3 -2
  83. package/dist/lib/opencode-auth.js +8 -1
  84. package/dist/lib/opencode-go.js +24 -3
  85. package/dist/lib/opencode-version.d.ts +21 -0
  86. package/dist/lib/opencode-version.js +53 -5
  87. package/dist/lib/opencode-zen.d.ts +9 -1
  88. package/dist/lib/opencode-zen.js +27 -7
  89. package/dist/lib/quota-providers-remote.d.ts +2 -0
  90. package/dist/lib/quota-providers-remote.js +78 -19
  91. package/dist/lib/quota-reset-notifications.d.ts +17 -0
  92. package/dist/lib/quota-reset-notifications.js +11 -2
  93. package/dist/lib/quota-state-codec.js +3 -1
  94. package/dist/lib/quota-stats.d.ts +22 -1
  95. package/dist/lib/quota-stats.js +111 -15
  96. package/dist/lib/synthetic.js +8 -0
  97. package/dist/lib/types.d.ts +24 -0
  98. package/dist/lib/types.js +4 -0
  99. package/dist/lib/xai.js +16 -2
  100. package/dist/plugin.d.ts +4 -3
  101. package/dist/plugin.js +33 -4
  102. package/dist/providers/alibaba-coding-plan.js +3 -1
  103. package/dist/providers/alibaba-token-plan.js +17 -0
  104. package/dist/providers/anthropic.js +12 -3
  105. package/dist/providers/copilot.js +10 -2
  106. package/dist/providers/glm-coding-plan-provider.d.ts +2 -0
  107. package/dist/providers/glm-coding-plan-provider.js +5 -1
  108. package/dist/providers/google-account-format.js +1 -0
  109. package/dist/providers/google-agy.js +12 -2
  110. package/dist/providers/google-gemini-cli.js +12 -2
  111. package/dist/providers/kilo.js +9 -1
  112. package/dist/providers/kimi-code.js +11 -6
  113. package/dist/providers/mimo.js +8 -2
  114. package/dist/providers/minimax-coding-plan.js +28 -5
  115. package/dist/providers/nanogpt.js +3 -0
  116. package/dist/providers/ollama-cloud.js +3 -0
  117. package/dist/providers/openai.js +1 -0
  118. package/dist/providers/opencode-go.js +8 -1
  119. package/dist/providers/opencode-zen.js +30 -3
  120. package/dist/providers/openrouter.js +3 -0
  121. package/dist/providers/quota-providers.js +30 -4
  122. package/dist/providers/result-helpers.d.ts +4 -0
  123. package/dist/providers/result-helpers.js +16 -2
  124. package/dist/rpc.d.ts +327 -4
  125. package/dist/rpc.js +315 -2
  126. package/dist/ui/assets/index-DLHeXYff.js +9 -0
  127. package/dist/ui/assets/{index-BZwMJ6Ax.css → index-cDd9jUVY.css} +1 -1
  128. package/dist/ui/assets/popover-BGkgv9s0.js +1 -0
  129. package/dist/ui/assets/popover-mkHTmNjv.css +1 -0
  130. package/dist/ui/index.html +2 -2
  131. package/package.json +49 -39
  132. package/dist/bin/opencode-quota-gui.d.ts.map +0 -1
  133. package/dist/bin/opencode-quota-gui.js.map +0 -1
  134. package/dist/contracts/analytics-entity.d.ts.map +0 -1
  135. package/dist/contracts/analytics-entity.js.map +0 -1
  136. package/dist/contracts/build-identity.d.ts.map +0 -1
  137. package/dist/contracts/card-order.d.ts.map +0 -1
  138. package/dist/contracts/card-order.js.map +0 -1
  139. package/dist/contracts/collision-safe-key.d.ts.map +0 -1
  140. package/dist/contracts/collision-safe-key.js.map +0 -1
  141. package/dist/contracts/dashboard.d.ts.map +0 -1
  142. package/dist/contracts/dashboard.js.map +0 -1
  143. package/dist/contracts/guards.d.ts.map +0 -1
  144. package/dist/contracts/guards.js.map +0 -1
  145. package/dist/contracts/identity.d.ts.map +0 -1
  146. package/dist/contracts/identity.js.map +0 -1
  147. package/dist/contracts/openai-quota.d.ts.map +0 -1
  148. package/dist/contracts/openai-quota.js.map +0 -1
  149. package/dist/contracts/ranges.d.ts.map +0 -1
  150. package/dist/contracts/ranges.js.map +0 -1
  151. package/dist/contracts/settings.d.ts.map +0 -1
  152. package/dist/contracts/settings.js.map +0 -1
  153. package/dist/contracts/time-zone.d.ts.map +0 -1
  154. package/dist/contracts/time-zone.js.map +0 -1
  155. package/dist/gui/aggregation.d.ts.map +0 -1
  156. package/dist/gui/aggregation.js.map +0 -1
  157. package/dist/gui/analytics-bridge.d.ts.map +0 -1
  158. package/dist/gui/analytics-bridge.js.map +0 -1
  159. package/dist/gui/analytics-engine.d.ts.map +0 -1
  160. package/dist/gui/analytics-engine.js.map +0 -1
  161. package/dist/gui/analytics-indexes.d.ts.map +0 -1
  162. package/dist/gui/analytics-indexes.js.map +0 -1
  163. package/dist/gui/analytics-model.d.ts.map +0 -1
  164. package/dist/gui/analytics-model.js.map +0 -1
  165. package/dist/gui/analytics-protocol.d.ts.map +0 -1
  166. package/dist/gui/analytics-protocol.js.map +0 -1
  167. package/dist/gui/analytics-reader.d.ts.map +0 -1
  168. package/dist/gui/analytics-reader.js.map +0 -1
  169. package/dist/gui/analytics-service.d.ts.map +0 -1
  170. package/dist/gui/analytics-service.js.map +0 -1
  171. package/dist/gui/analytics-state.d.ts.map +0 -1
  172. package/dist/gui/analytics-state.js.map +0 -1
  173. package/dist/gui/analytics-worker-runtime.d.ts.map +0 -1
  174. package/dist/gui/analytics-worker-runtime.js.map +0 -1
  175. package/dist/gui/analytics-worker.d.ts.map +0 -1
  176. package/dist/gui/analytics-worker.js.map +0 -1
  177. package/dist/gui/config.d.ts.map +0 -1
  178. package/dist/gui/config.js.map +0 -1
  179. package/dist/gui/identity.d.ts.map +0 -1
  180. package/dist/gui/identity.js.map +0 -1
  181. package/dist/gui/lifecycle.d.ts.map +0 -1
  182. package/dist/gui/lifecycle.js.map +0 -1
  183. package/dist/gui/log.d.ts.map +0 -1
  184. package/dist/gui/log.js.map +0 -1
  185. package/dist/gui/provider-cards.d.ts.map +0 -1
  186. package/dist/gui/provider-cards.js.map +0 -1
  187. package/dist/gui/server.d.ts.map +0 -1
  188. package/dist/gui/server.js.map +0 -1
  189. package/dist/gui/settings-file-opener.d.ts.map +0 -1
  190. package/dist/gui/settings-file-opener.js.map +0 -1
  191. package/dist/gui/snapshot-service.d.ts.map +0 -1
  192. package/dist/gui/snapshot-service.js.map +0 -1
  193. package/dist/gui/sources.d.ts.map +0 -1
  194. package/dist/gui/sources.js.map +0 -1
  195. package/dist/gui/sse.d.ts.map +0 -1
  196. package/dist/gui/sse.js.map +0 -1
  197. package/dist/gui/time-zone.d.ts.map +0 -1
  198. package/dist/gui/time-zone.js.map +0 -1
  199. package/dist/index.d.ts.map +0 -1
  200. package/dist/index.js.map +0 -1
  201. package/dist/lib/accounting-format.d.ts.map +0 -1
  202. package/dist/lib/accounting-format.js.map +0 -1
  203. package/dist/lib/alibaba-auth.d.ts.map +0 -1
  204. package/dist/lib/alibaba-auth.js.map +0 -1
  205. package/dist/lib/alibaba-coding-plan-local-quota.d.ts.map +0 -1
  206. package/dist/lib/alibaba-coding-plan-local-quota.js.map +0 -1
  207. package/dist/lib/alibaba-token-plan.d.ts.map +0 -1
  208. package/dist/lib/alibaba-token-plan.js.map +0 -1
  209. package/dist/lib/anthropic-auth.d.ts.map +0 -1
  210. package/dist/lib/anthropic-auth.js.map +0 -1
  211. package/dist/lib/anthropic.d.ts.map +0 -1
  212. package/dist/lib/anthropic.js.map +0 -1
  213. package/dist/lib/api-key-resolver.d.ts.map +0 -1
  214. package/dist/lib/api-key-resolver.js.map +0 -1
  215. package/dist/lib/atomic-json.d.ts.map +0 -1
  216. package/dist/lib/atomic-json.js.map +0 -1
  217. package/dist/lib/chutes-config.d.ts.map +0 -1
  218. package/dist/lib/chutes-config.js.map +0 -1
  219. package/dist/lib/chutes.d.ts.map +0 -1
  220. package/dist/lib/chutes.js.map +0 -1
  221. package/dist/lib/cli-reports.d.ts.map +0 -1
  222. package/dist/lib/cli-reports.js.map +0 -1
  223. package/dist/lib/cli-show.d.ts.map +0 -1
  224. package/dist/lib/cli-show.js.map +0 -1
  225. package/dist/lib/cli-status.d.ts.map +0 -1
  226. package/dist/lib/cli-status.js.map +0 -1
  227. package/dist/lib/command-parsing.d.ts.map +0 -1
  228. package/dist/lib/command-parsing.js.map +0 -1
  229. package/dist/lib/config-file-utils.d.ts.map +0 -1
  230. package/dist/lib/config-file-utils.js.map +0 -1
  231. package/dist/lib/config-write-target.d.ts.map +0 -1
  232. package/dist/lib/config-write-target.js.map +0 -1
  233. package/dist/lib/config.d.ts.map +0 -1
  234. package/dist/lib/config.js.map +0 -1
  235. package/dist/lib/copilot.d.ts.map +0 -1
  236. package/dist/lib/copilot.js.map +0 -1
  237. package/dist/lib/cursor-detection.d.ts.map +0 -1
  238. package/dist/lib/cursor-detection.js.map +0 -1
  239. package/dist/lib/cursor-pricing.d.ts.map +0 -1
  240. package/dist/lib/cursor-pricing.js.map +0 -1
  241. package/dist/lib/cursor-usage.d.ts.map +0 -1
  242. package/dist/lib/cursor-usage.js.map +0 -1
  243. package/dist/lib/dashboard-visibility.d.ts.map +0 -1
  244. package/dist/lib/dashboard-visibility.js.map +0 -1
  245. package/dist/lib/deepseek-auth.d.ts.map +0 -1
  246. package/dist/lib/deepseek-auth.js.map +0 -1
  247. package/dist/lib/deepseek.d.ts.map +0 -1
  248. package/dist/lib/deepseek.js.map +0 -1
  249. package/dist/lib/display-sanitize.d.ts.map +0 -1
  250. package/dist/lib/display-sanitize.js.map +0 -1
  251. package/dist/lib/entries.d.ts.map +0 -1
  252. package/dist/lib/entries.js.map +0 -1
  253. package/dist/lib/env-template.d.ts.map +0 -1
  254. package/dist/lib/env-template.js.map +0 -1
  255. package/dist/lib/format-utils.d.ts.map +0 -1
  256. package/dist/lib/format-utils.js.map +0 -1
  257. package/dist/lib/format.d.ts.map +0 -1
  258. package/dist/lib/format.js.map +0 -1
  259. package/dist/lib/glm-coding-plan.d.ts.map +0 -1
  260. package/dist/lib/glm-coding-plan.js.map +0 -1
  261. package/dist/lib/google-agy-companion.d.ts.map +0 -1
  262. package/dist/lib/google-agy-companion.js.map +0 -1
  263. package/dist/lib/google-agy.d.ts.map +0 -1
  264. package/dist/lib/google-agy.js.map +0 -1
  265. package/dist/lib/google-companion-credentials.d.ts.map +0 -1
  266. package/dist/lib/google-companion-credentials.js.map +0 -1
  267. package/dist/lib/google-gemini-cli-companion.d.ts.map +0 -1
  268. package/dist/lib/google-gemini-cli-companion.js.map +0 -1
  269. package/dist/lib/google-gemini-cli.d.ts.map +0 -1
  270. package/dist/lib/google-gemini-cli.js.map +0 -1
  271. package/dist/lib/google-token-cache.d.ts.map +0 -1
  272. package/dist/lib/google-token-cache.js.map +0 -1
  273. package/dist/lib/grouped-entry-normalization.d.ts.map +0 -1
  274. package/dist/lib/grouped-entry-normalization.js.map +0 -1
  275. package/dist/lib/grouped-header-format.d.ts.map +0 -1
  276. package/dist/lib/grouped-header-format.js.map +0 -1
  277. package/dist/lib/gui-config-target.d.ts.map +0 -1
  278. package/dist/lib/gui-config-target.js.map +0 -1
  279. package/dist/lib/home-dir-display.d.ts.map +0 -1
  280. package/dist/lib/home-dir-display.js.map +0 -1
  281. package/dist/lib/http.d.ts.map +0 -1
  282. package/dist/lib/http.js.map +0 -1
  283. package/dist/lib/init-installer.d.ts.map +0 -1
  284. package/dist/lib/init-installer.js.map +0 -1
  285. package/dist/lib/jsonc.d.ts.map +0 -1
  286. package/dist/lib/jsonc.js.map +0 -1
  287. package/dist/lib/kilo-config.d.ts.map +0 -1
  288. package/dist/lib/kilo-config.js.map +0 -1
  289. package/dist/lib/kilo.d.ts.map +0 -1
  290. package/dist/lib/kilo.js.map +0 -1
  291. package/dist/lib/kimi-auth.d.ts.map +0 -1
  292. package/dist/lib/kimi-auth.js.map +0 -1
  293. package/dist/lib/kimi-endpoints.d.ts.map +0 -1
  294. package/dist/lib/kimi-endpoints.js.map +0 -1
  295. package/dist/lib/kimi.d.ts.map +0 -1
  296. package/dist/lib/kimi.js.map +0 -1
  297. package/dist/lib/maintainer-announcements.d.ts.map +0 -1
  298. package/dist/lib/maintainer-announcements.js.map +0 -1
  299. package/dist/lib/map-with-concurrency.d.ts.map +0 -1
  300. package/dist/lib/map-with-concurrency.js.map +0 -1
  301. package/dist/lib/markdown-table.d.ts.map +0 -1
  302. package/dist/lib/markdown-table.js.map +0 -1
  303. package/dist/lib/mimo-config.d.ts.map +0 -1
  304. package/dist/lib/mimo-config.js.map +0 -1
  305. package/dist/lib/mimo.d.ts.map +0 -1
  306. package/dist/lib/mimo.js.map +0 -1
  307. package/dist/lib/minimax-auth.d.ts.map +0 -1
  308. package/dist/lib/minimax-auth.js.map +0 -1
  309. package/dist/lib/minimax-endpoints.d.ts.map +0 -1
  310. package/dist/lib/minimax-endpoints.js.map +0 -1
  311. package/dist/lib/modelsdev-pricing.d.ts.map +0 -1
  312. package/dist/lib/modelsdev-pricing.js.map +0 -1
  313. package/dist/lib/nanogpt-config.d.ts.map +0 -1
  314. package/dist/lib/nanogpt-config.js.map +0 -1
  315. package/dist/lib/nanogpt.d.ts.map +0 -1
  316. package/dist/lib/nanogpt.js.map +0 -1
  317. package/dist/lib/ollama-cloud-config.d.ts.map +0 -1
  318. package/dist/lib/ollama-cloud-config.js.map +0 -1
  319. package/dist/lib/ollama-cloud.d.ts.map +0 -1
  320. package/dist/lib/ollama-cloud.js.map +0 -1
  321. package/dist/lib/openai.d.ts.map +0 -1
  322. package/dist/lib/openai.js.map +0 -1
  323. package/dist/lib/opencode-auth-sqlite.d.ts.map +0 -1
  324. package/dist/lib/opencode-auth-sqlite.js.map +0 -1
  325. package/dist/lib/opencode-auth.d.ts.map +0 -1
  326. package/dist/lib/opencode-auth.js.map +0 -1
  327. package/dist/lib/opencode-config-editor.d.ts.map +0 -1
  328. package/dist/lib/opencode-config-editor.js.map +0 -1
  329. package/dist/lib/opencode-config-providers.d.ts.map +0 -1
  330. package/dist/lib/opencode-config-providers.js.map +0 -1
  331. package/dist/lib/opencode-config-read.d.ts.map +0 -1
  332. package/dist/lib/opencode-config-read.js.map +0 -1
  333. package/dist/lib/opencode-console-auth.d.ts.map +0 -1
  334. package/dist/lib/opencode-console-auth.js.map +0 -1
  335. package/dist/lib/opencode-db-path.d.ts.map +0 -1
  336. package/dist/lib/opencode-db-path.js.map +0 -1
  337. package/dist/lib/opencode-go-auth.d.ts.map +0 -1
  338. package/dist/lib/opencode-go-auth.js.map +0 -1
  339. package/dist/lib/opencode-go.d.ts.map +0 -1
  340. package/dist/lib/opencode-go.js.map +0 -1
  341. package/dist/lib/opencode-runtime-paths.d.ts.map +0 -1
  342. package/dist/lib/opencode-runtime-paths.js.map +0 -1
  343. package/dist/lib/opencode-sqlite.d.ts.map +0 -1
  344. package/dist/lib/opencode-sqlite.js.map +0 -1
  345. package/dist/lib/opencode-storage.d.ts.map +0 -1
  346. package/dist/lib/opencode-storage.js.map +0 -1
  347. package/dist/lib/opencode-version.d.ts.map +0 -1
  348. package/dist/lib/opencode-version.js.map +0 -1
  349. package/dist/lib/opencode-zen.d.ts.map +0 -1
  350. package/dist/lib/opencode-zen.js.map +0 -1
  351. package/dist/lib/openrouter.d.ts.map +0 -1
  352. package/dist/lib/openrouter.js.map +0 -1
  353. package/dist/lib/private-state-paths.d.ts.map +0 -1
  354. package/dist/lib/private-state-paths.js.map +0 -1
  355. package/dist/lib/provider-add-command.d.ts.map +0 -1
  356. package/dist/lib/provider-add-command.js.map +0 -1
  357. package/dist/lib/provider-add-json-v1-questionnaire.d.ts.map +0 -1
  358. package/dist/lib/provider-add-json-v1-questionnaire.js.map +0 -1
  359. package/dist/lib/provider-add.d.ts.map +0 -1
  360. package/dist/lib/provider-add.js.map +0 -1
  361. package/dist/lib/provider-availability.d.ts.map +0 -1
  362. package/dist/lib/provider-availability.js.map +0 -1
  363. package/dist/lib/provider-metadata.d.ts.map +0 -1
  364. package/dist/lib/provider-metadata.js.map +0 -1
  365. package/dist/lib/provider-model-matching.d.ts.map +0 -1
  366. package/dist/lib/provider-model-matching.js.map +0 -1
  367. package/dist/lib/provider-registration.d.ts.map +0 -1
  368. package/dist/lib/provider-registration.js.map +0 -1
  369. package/dist/lib/quota-accounting-projection.d.ts.map +0 -1
  370. package/dist/lib/quota-accounting-projection.js.map +0 -1
  371. package/dist/lib/quota-columns.d.ts.map +0 -1
  372. package/dist/lib/quota-columns.js.map +0 -1
  373. package/dist/lib/quota-command-format.d.ts.map +0 -1
  374. package/dist/lib/quota-command-format.js.map +0 -1
  375. package/dist/lib/quota-dialog-command-specs.d.ts.map +0 -1
  376. package/dist/lib/quota-dialog-command-specs.js.map +0 -1
  377. package/dist/lib/quota-dialog-commands.d.ts.map +0 -1
  378. package/dist/lib/quota-dialog-commands.js.map +0 -1
  379. package/dist/lib/quota-entry-display.d.ts.map +0 -1
  380. package/dist/lib/quota-entry-display.js.map +0 -1
  381. package/dist/lib/quota-exhaustion-projection.d.ts.map +0 -1
  382. package/dist/lib/quota-exhaustion-projection.js.map +0 -1
  383. package/dist/lib/quota-export-types.d.ts.map +0 -1
  384. package/dist/lib/quota-export-types.js.map +0 -1
  385. package/dist/lib/quota-export.d.ts.map +0 -1
  386. package/dist/lib/quota-export.js.map +0 -1
  387. package/dist/lib/quota-format-style.d.ts.map +0 -1
  388. package/dist/lib/quota-format-style.js.map +0 -1
  389. package/dist/lib/quota-providers-local.d.ts.map +0 -1
  390. package/dist/lib/quota-providers-local.js.map +0 -1
  391. package/dist/lib/quota-providers-remote.d.ts.map +0 -1
  392. package/dist/lib/quota-providers-remote.js.map +0 -1
  393. package/dist/lib/quota-providers.d.ts.map +0 -1
  394. package/dist/lib/quota-providers.js.map +0 -1
  395. package/dist/lib/quota-render-data.d.ts.map +0 -1
  396. package/dist/lib/quota-render-data.js.map +0 -1
  397. package/dist/lib/quota-report-message.d.ts.map +0 -1
  398. package/dist/lib/quota-report-message.js.map +0 -1
  399. package/dist/lib/quota-reset-notifications.d.ts.map +0 -1
  400. package/dist/lib/quota-reset-notifications.js.map +0 -1
  401. package/dist/lib/quota-retry-wait.d.ts.map +0 -1
  402. package/dist/lib/quota-retry-wait.js.map +0 -1
  403. package/dist/lib/quota-runtime-context.d.ts.map +0 -1
  404. package/dist/lib/quota-runtime-context.js.map +0 -1
  405. package/dist/lib/quota-state-codec.d.ts.map +0 -1
  406. package/dist/lib/quota-state-codec.js.map +0 -1
  407. package/dist/lib/quota-state.d.ts.map +0 -1
  408. package/dist/lib/quota-state.js.map +0 -1
  409. package/dist/lib/quota-stats-format.d.ts.map +0 -1
  410. package/dist/lib/quota-stats-format.js.map +0 -1
  411. package/dist/lib/quota-stats.d.ts.map +0 -1
  412. package/dist/lib/quota-stats.js.map +0 -1
  413. package/dist/lib/quota-status.d.ts.map +0 -1
  414. package/dist/lib/quota-status.js.map +0 -1
  415. package/dist/lib/quota-surface-data.d.ts.map +0 -1
  416. package/dist/lib/quota-surface-data.js.map +0 -1
  417. package/dist/lib/quota-telemetry.d.ts.map +0 -1
  418. package/dist/lib/quota-telemetry.js.map +0 -1
  419. package/dist/lib/report-document.d.ts.map +0 -1
  420. package/dist/lib/report-document.js.map +0 -1
  421. package/dist/lib/resolved-auth-identity.d.ts.map +0 -1
  422. package/dist/lib/resolved-auth-identity.js.map +0 -1
  423. package/dist/lib/runtime-provider-ids.d.ts.map +0 -1
  424. package/dist/lib/runtime-provider-ids.js.map +0 -1
  425. package/dist/lib/scoped-query-chunks.d.ts.map +0 -1
  426. package/dist/lib/scoped-query-chunks.js.map +0 -1
  427. package/dist/lib/scoped-update-migration.d.ts.map +0 -1
  428. package/dist/lib/scoped-update-migration.js.map +0 -1
  429. package/dist/lib/scoped-update.d.ts.map +0 -1
  430. package/dist/lib/scoped-update.js.map +0 -1
  431. package/dist/lib/session-tokens-format.d.ts.map +0 -1
  432. package/dist/lib/session-tokens-format.js.map +0 -1
  433. package/dist/lib/session-tokens.d.ts.map +0 -1
  434. package/dist/lib/session-tokens.js.map +0 -1
  435. package/dist/lib/synthetic-config.d.ts.map +0 -1
  436. package/dist/lib/synthetic-config.js.map +0 -1
  437. package/dist/lib/synthetic.d.ts.map +0 -1
  438. package/dist/lib/synthetic.js.map +0 -1
  439. package/dist/lib/toast-format-grouped.d.ts.map +0 -1
  440. package/dist/lib/toast-format-grouped.js.map +0 -1
  441. package/dist/lib/token-buckets.d.ts.map +0 -1
  442. package/dist/lib/token-buckets.js.map +0 -1
  443. package/dist/lib/token-cost.d.ts.map +0 -1
  444. package/dist/lib/token-cost.js.map +0 -1
  445. package/dist/lib/tui-compact-format.d.ts.map +0 -1
  446. package/dist/lib/tui-compact-format.js.map +0 -1
  447. package/dist/lib/tui-panel-state.d.ts.map +0 -1
  448. package/dist/lib/tui-panel-state.js.map +0 -1
  449. package/dist/lib/tui-prompt-bar-format.d.ts.map +0 -1
  450. package/dist/lib/tui-prompt-bar-format.js.map +0 -1
  451. package/dist/lib/tui-sidebar-format.d.ts.map +0 -1
  452. package/dist/lib/tui-sidebar-format.js.map +0 -1
  453. package/dist/lib/types.d.ts.map +0 -1
  454. package/dist/lib/types.js.map +0 -1
  455. package/dist/lib/usage-ownership.d.ts.map +0 -1
  456. package/dist/lib/usage-ownership.js.map +0 -1
  457. package/dist/lib/version.d.ts.map +0 -1
  458. package/dist/lib/version.js.map +0 -1
  459. package/dist/lib/xai.d.ts.map +0 -1
  460. package/dist/lib/xai.js.map +0 -1
  461. package/dist/lib/zai-auth.d.ts.map +0 -1
  462. package/dist/lib/zai-auth.js.map +0 -1
  463. package/dist/lib/zai.d.ts.map +0 -1
  464. package/dist/lib/zai.js.map +0 -1
  465. package/dist/lib/zhipu-auth.d.ts.map +0 -1
  466. package/dist/lib/zhipu-auth.js.map +0 -1
  467. package/dist/lib/zhipu.d.ts.map +0 -1
  468. package/dist/lib/zhipu.js.map +0 -1
  469. package/dist/plugin.d.ts.map +0 -1
  470. package/dist/plugin.js.map +0 -1
  471. package/dist/providers/accounting-decimal.d.ts.map +0 -1
  472. package/dist/providers/accounting-decimal.js.map +0 -1
  473. package/dist/providers/alibaba-coding-plan.d.ts.map +0 -1
  474. package/dist/providers/alibaba-coding-plan.js.map +0 -1
  475. package/dist/providers/alibaba-token-plan.d.ts.map +0 -1
  476. package/dist/providers/alibaba-token-plan.js.map +0 -1
  477. package/dist/providers/anthropic.d.ts.map +0 -1
  478. package/dist/providers/anthropic.js.map +0 -1
  479. package/dist/providers/cache-policies.d.ts.map +0 -1
  480. package/dist/providers/cache-policies.js.map +0 -1
  481. package/dist/providers/chutes.d.ts.map +0 -1
  482. package/dist/providers/chutes.js.map +0 -1
  483. package/dist/providers/copilot.d.ts.map +0 -1
  484. package/dist/providers/copilot.js.map +0 -1
  485. package/dist/providers/cursor.d.ts.map +0 -1
  486. package/dist/providers/cursor.js.map +0 -1
  487. package/dist/providers/deepseek.d.ts.map +0 -1
  488. package/dist/providers/deepseek.js.map +0 -1
  489. package/dist/providers/glm-coding-plan-provider.d.ts.map +0 -1
  490. package/dist/providers/glm-coding-plan-provider.js.map +0 -1
  491. package/dist/providers/google-account-format.d.ts.map +0 -1
  492. package/dist/providers/google-account-format.js.map +0 -1
  493. package/dist/providers/google-agy.d.ts.map +0 -1
  494. package/dist/providers/google-agy.js.map +0 -1
  495. package/dist/providers/google-gemini-cli.d.ts.map +0 -1
  496. package/dist/providers/google-gemini-cli.js.map +0 -1
  497. package/dist/providers/kilo.d.ts.map +0 -1
  498. package/dist/providers/kilo.js.map +0 -1
  499. package/dist/providers/kimi-code.d.ts.map +0 -1
  500. package/dist/providers/kimi-code.js.map +0 -1
  501. package/dist/providers/mimo.d.ts.map +0 -1
  502. package/dist/providers/mimo.js.map +0 -1
  503. package/dist/providers/minimax-coding-plan.d.ts.map +0 -1
  504. package/dist/providers/minimax-coding-plan.js.map +0 -1
  505. package/dist/providers/nanogpt.d.ts.map +0 -1
  506. package/dist/providers/nanogpt.js.map +0 -1
  507. package/dist/providers/ollama-cloud.d.ts.map +0 -1
  508. package/dist/providers/ollama-cloud.js.map +0 -1
  509. package/dist/providers/openai.d.ts.map +0 -1
  510. package/dist/providers/openai.js.map +0 -1
  511. package/dist/providers/opencode-go.d.ts.map +0 -1
  512. package/dist/providers/opencode-go.js.map +0 -1
  513. package/dist/providers/opencode-zen.d.ts.map +0 -1
  514. package/dist/providers/opencode-zen.js.map +0 -1
  515. package/dist/providers/openrouter.d.ts.map +0 -1
  516. package/dist/providers/openrouter.js.map +0 -1
  517. package/dist/providers/quota-providers.d.ts.map +0 -1
  518. package/dist/providers/quota-providers.js.map +0 -1
  519. package/dist/providers/registry.d.ts.map +0 -1
  520. package/dist/providers/registry.js.map +0 -1
  521. package/dist/providers/result-helpers.d.ts.map +0 -1
  522. package/dist/providers/result-helpers.js.map +0 -1
  523. package/dist/providers/synthetic.d.ts.map +0 -1
  524. package/dist/providers/synthetic.js.map +0 -1
  525. package/dist/providers/xai.d.ts.map +0 -1
  526. package/dist/providers/xai.js.map +0 -1
  527. package/dist/providers/zai.d.ts.map +0 -1
  528. package/dist/providers/zai.js.map +0 -1
  529. package/dist/providers/zhipu.d.ts.map +0 -1
  530. package/dist/providers/zhipu.js.map +0 -1
  531. package/dist/rpc.d.ts.map +0 -1
  532. package/dist/rpc.js.map +0 -1
  533. package/dist/ui/assets/index-CjNjqsse.js +0 -8
@@ -1,3 +1,4 @@
1
+ import { providerFailureCategoryForHttpStatus, } from "../contracts/provider-failure.js";
1
2
  import { createProviderApiKeyResolver, getApiKeyCheckedPaths, getGlobalOpencodeConfigCandidatePaths, } from "./api-key-resolver.js";
2
3
  import { sanitizeSingleLineDisplayText } from "./display-sanitize.js";
3
4
  import { getCredentialDatabasePaths, readAuthFile } from "./opencode-auth.js";
@@ -138,10 +139,10 @@ function parseQuotaV1(source, body) {
138
139
  !hasOnlyKeys(body, ["version", "entries"]) ||
139
140
  body.version !== "quota-v1" ||
140
141
  !Array.isArray(body.entries)) {
141
- return { success: false, error: "Invalid quota-v1 response" };
142
+ return { success: false, error: "Invalid quota-v1 response", failureCategory: "provider_api" };
142
143
  }
143
144
  if (body.entries.length < 1 || body.entries.length > QUOTA_PROVIDER_MAX_REMOTE_ROWS) {
144
- return { success: false, error: "Invalid quota-v1 response" };
145
+ return { success: false, error: "Invalid quota-v1 response", failureCategory: "provider_api" };
145
146
  }
146
147
  const entries = [];
147
148
  for (const raw of body.entries) {
@@ -157,7 +158,11 @@ function parseQuotaV1(source, body) {
157
158
  "resetTimeIso",
158
159
  "observedAtIso",
159
160
  ])) {
160
- return { success: false, error: "Invalid quota-v1 response" };
161
+ return {
162
+ success: false,
163
+ error: "Invalid quota-v1 response",
164
+ failureCategory: "provider_api",
165
+ };
161
166
  }
162
167
  const name = boundedDisplayText(raw.name, 80);
163
168
  const resultType = typeof raw.resultType === "string" && RESULT_TYPES.has(raw.resultType)
@@ -181,7 +186,11 @@ function parseQuotaV1(source, body) {
181
186
  (raw.right !== undefined && right === null) ||
182
187
  resetTimeIso === null ||
183
188
  observedAtIso === null) {
184
- return { success: false, error: "Invalid quota-v1 response" };
189
+ return {
190
+ success: false,
191
+ error: "Invalid quota-v1 response",
192
+ failureCategory: "provider_api",
193
+ };
185
194
  }
186
195
  const common = {
187
196
  accounting: accountingMetadata(resultType, observedAtIso),
@@ -205,7 +214,7 @@ function parseQuotaV1(source, body) {
205
214
  entries.push({ ...common, kind: "value", value });
206
215
  continue;
207
216
  }
208
- return { success: false, error: "Invalid quota-v1 response" };
217
+ return { success: false, error: "Invalid quota-v1 response", failureCategory: "provider_api" };
209
218
  }
210
219
  return { success: true, entries };
211
220
  }
@@ -495,6 +504,7 @@ function parseJsonV1(source, body) {
495
504
  const invalid = (message) => ({
496
505
  success: false,
497
506
  error: `Invalid json-v1 response: ${message}`,
507
+ failureCategory: "provider_api",
498
508
  });
499
509
  if (!isJsonV1ResponseDepthValid(body)) {
500
510
  return invalid(`nesting depth exceeded ${JSON_V1_MAX_RESPONSE_DEPTH}`);
@@ -617,18 +627,30 @@ function openRouterKeyLimitEntry(source, limit, percentRemaining, usedUsd) {
617
627
  }
618
628
  function parseOpenRouterKeyV1(source, body) {
619
629
  if (!isRecord(body) || !isRecord(body.data)) {
620
- return { success: false, error: "Invalid openrouter-key-v1 response" };
630
+ return {
631
+ success: false,
632
+ error: "Invalid openrouter-key-v1 response",
633
+ failureCategory: "provider_api",
634
+ };
621
635
  }
622
636
  const data = body.data;
623
637
  const usage = data.usage;
624
638
  if (typeof usage !== "number" || !Number.isFinite(usage) || usage < 0) {
625
- return { success: false, error: "Invalid openrouter-key-v1 response" };
639
+ return {
640
+ success: false,
641
+ error: "Invalid openrouter-key-v1 response",
642
+ failureCategory: "provider_api",
643
+ };
626
644
  }
627
645
  const rawLimit = data.limit;
628
646
  if (rawLimit !== null &&
629
647
  rawLimit !== undefined &&
630
648
  (typeof rawLimit !== "number" || !Number.isFinite(rawLimit) || rawLimit < 0)) {
631
- return { success: false, error: "Invalid openrouter-key-v1 response" };
649
+ return {
650
+ success: false,
651
+ error: "Invalid openrouter-key-v1 response",
652
+ failureCategory: "provider_api",
653
+ };
632
654
  }
633
655
  // A key limit is a cap only when it is positive. Zero and null mean unlimited.
634
656
  const limit = typeof rawLimit === "number" && rawLimit > 0 ? rawLimit : null;
@@ -636,15 +658,27 @@ function parseOpenRouterKeyV1(source, body) {
636
658
  if (rawRemaining !== null &&
637
659
  rawRemaining !== undefined &&
638
660
  (typeof rawRemaining !== "number" || !Number.isFinite(rawRemaining))) {
639
- return { success: false, error: "Invalid openrouter-key-v1 response" };
661
+ return {
662
+ success: false,
663
+ error: "Invalid openrouter-key-v1 response",
664
+ failureCategory: "provider_api",
665
+ };
640
666
  }
641
667
  // `limit_remaining` is capacity left on the key, never an account balance.
642
668
  if (rawRemaining === null && limit !== null) {
643
- return { success: false, error: "Invalid openrouter-key-v1 response" };
669
+ return {
670
+ success: false,
671
+ error: "Invalid openrouter-key-v1 response",
672
+ failureCategory: "provider_api",
673
+ };
644
674
  }
645
675
  const remaining = typeof rawRemaining === "number" ? rawRemaining : null;
646
676
  if (limit !== null && remaining !== null && remaining > limit) {
647
- return { success: false, error: "Invalid openrouter-key-v1 response" };
677
+ return {
678
+ success: false,
679
+ error: "Invalid openrouter-key-v1 response",
680
+ failureCategory: "provider_api",
681
+ };
648
682
  }
649
683
  const rawReset = data.limit_reset;
650
684
  let reset;
@@ -652,7 +686,11 @@ function parseOpenRouterKeyV1(source, body) {
652
686
  reset = null;
653
687
  }
654
688
  else if (typeof rawReset !== "string") {
655
- return { success: false, error: "Invalid openrouter-key-v1 response" };
689
+ return {
690
+ success: false,
691
+ error: "Invalid openrouter-key-v1 response",
692
+ failureCategory: "provider_api",
693
+ };
656
694
  }
657
695
  else {
658
696
  reset = OPENROUTER_LIMIT_RESETS.has(rawReset) ? rawReset : "unknown";
@@ -662,7 +700,11 @@ function parseOpenRouterKeyV1(source, body) {
662
700
  if (value === null || value === undefined)
663
701
  continue;
664
702
  if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
665
- return { success: false, error: "Invalid openrouter-key-v1 response" };
703
+ return {
704
+ success: false,
705
+ error: "Invalid openrouter-key-v1 response",
706
+ failureCategory: "provider_api",
707
+ };
666
708
  }
667
709
  }
668
710
  if (limit !== null) {
@@ -673,11 +715,19 @@ function parseOpenRouterKeyV1(source, body) {
673
715
  const remainingValue = remaining !== null ? remaining : windowUsage !== null ? limit - windowUsage : null;
674
716
  if (remainingValue !== null) {
675
717
  if (remainingValue > limit) {
676
- return { success: false, error: "Invalid openrouter-key-v1 response" };
718
+ return {
719
+ success: false,
720
+ error: "Invalid openrouter-key-v1 response",
721
+ failureCategory: "provider_api",
722
+ };
677
723
  }
678
724
  const percentRemaining = (remainingValue / limit) * 100;
679
725
  if (!Number.isFinite(percentRemaining)) {
680
- return { success: false, error: "Invalid openrouter-key-v1 response" };
726
+ return {
727
+ success: false,
728
+ error: "Invalid openrouter-key-v1 response",
729
+ failureCategory: "provider_api",
730
+ };
681
731
  }
682
732
  const usedUsd = limit - remainingValue;
683
733
  return {
@@ -718,10 +768,14 @@ export async function fetchRemoteQuotaProvider(source, apiKey, requestTimeoutMs)
718
768
  },
719
769
  });
720
770
  if (response.redirected || (response.status >= 300 && response.status < 400)) {
721
- return { success: false, error: "Redirect rejected" };
771
+ return { success: false, error: "Redirect rejected", failureCategory: "provider_api" };
722
772
  }
723
773
  if (!response.ok) {
724
- return { success: false, error: `HTTP ${response.status}` };
774
+ return {
775
+ success: false,
776
+ error: `HTTP ${response.status}`,
777
+ failureCategory: providerFailureCategoryForHttpStatus(response.status),
778
+ };
725
779
  }
726
780
  const body = await readBoundedJson(response);
727
781
  switch (source.format) {
@@ -738,6 +792,7 @@ export async function fetchRemoteQuotaProvider(source, apiKey, requestTimeoutMs)
738
792
  return {
739
793
  success: false,
740
794
  error: `Request timeout after ${Math.round(timeoutMs / 1000)}s`,
795
+ failureCategory: "provider_api",
741
796
  };
742
797
  }
743
798
  if (error instanceof Error &&
@@ -746,9 +801,13 @@ export async function fetchRemoteQuotaProvider(source, apiKey, requestTimeoutMs)
746
801
  "Expected a JSON response",
747
802
  "Invalid JSON response",
748
803
  ].includes(error.message)) {
749
- return { success: false, error: error.message };
804
+ return { success: false, error: error.message, failureCategory: "provider_api" };
750
805
  }
751
- return { success: false, error: "Failed to read accounting data" };
806
+ return {
807
+ success: false,
808
+ error: "Failed to read accounting data",
809
+ failureCategory: "provider_api",
810
+ };
752
811
  }
753
812
  finally {
754
813
  clearTimeout(timeoutId);
@@ -1,5 +1,14 @@
1
1
  import { type QuotaProviderResult } from "./entries.js";
2
2
  import type { QuotaResetWindow } from "./types.js";
3
+ /** Pure shared reset-transition age limit. */
4
+ export declare const MAX_TRANSITION_AGE_MS: number;
5
+ /** One pure reset observation, shared with the native notification detector. */
6
+ export type ResetObservation = {
7
+ resetAtMs: number;
8
+ percentRemaining: number;
9
+ observedAtMs: number;
10
+ notifiedResetAtMs?: number;
11
+ };
3
12
  export type QuotaResetProviderResult = {
4
13
  providerId: string;
5
14
  result: QuotaProviderResult;
@@ -10,6 +19,14 @@ export type QuotaResetNotice = {
10
19
  window: QuotaResetWindow;
11
20
  percentRemaining: number;
12
21
  };
22
+ /**
23
+ * Pure reset observation update. Exported for the native quota notification
24
+ * detector; keep these exact semantics for the legacy notifier.
25
+ */
26
+ export declare function updateObservation(previous: ResetObservation | undefined, current: ResetObservation, nowMs: number): {
27
+ observation: ResetObservation;
28
+ notify: boolean;
29
+ };
13
30
  export declare function observeQuotaResetNotifications(params: {
14
31
  providers: QuotaResetProviderResult[];
15
32
  windows: readonly QuotaResetWindow[];
@@ -8,7 +8,8 @@ import { getQuotaResetNotificationsStatePath } from "./private-state-paths.js";
8
8
  import { getQuotaProviderDisplayLabel } from "./provider-metadata.js";
9
9
  import { classifyQuotaWindowText } from "./quota-entry-display.js";
10
10
  const STATE_VERSION = 2;
11
- const MAX_TRANSITION_AGE_MS = 24 * 60 * 60 * 1000;
11
+ /** Pure shared reset-transition age limit. */
12
+ export const MAX_TRANSITION_AGE_MS = 24 * 60 * 60 * 1000;
12
13
  const MAX_OBSERVATION_AGE_MS = 30 * 24 * 60 * 60 * 1000;
13
14
  const LOCK_RETRY_DELAY_MS = 20;
14
15
  const LOCK_TIMEOUT_MS = 2_000;
@@ -207,6 +208,10 @@ async function acquireStateLock(statePath) {
207
208
  await delay(LOCK_RETRY_DELAY_MS);
208
209
  }
209
210
  }
211
+ /**
212
+ * Pure reset proof. The legacy notifier depends on this exact predicate, so do
213
+ * not fork it.
214
+ */
210
215
  function didReset(previous, current, nowMs) {
211
216
  const transitionAge = nowMs - previous.resetAtMs;
212
217
  return (previous.observedAtMs <= previous.resetAtMs &&
@@ -218,7 +223,11 @@ function didReset(previous, current, nowMs) {
218
223
  previous.percentRemaining < 100 &&
219
224
  previous.notifiedResetAtMs !== previous.resetAtMs);
220
225
  }
221
- function updateObservation(previous, current, nowMs) {
226
+ /**
227
+ * Pure reset observation update. Exported for the native quota notification
228
+ * detector; keep these exact semantics for the legacy notifier.
229
+ */
230
+ export function updateObservation(previous, current, nowMs) {
222
231
  if (!previous)
223
232
  return { observation: current, notify: false };
224
233
  if (current.resetAtMs < previous.resetAtMs || current.observedAtMs < previous.observedAtMs) {
@@ -1,3 +1,4 @@
1
+ import { isProviderFailureCategory } from "../contracts/provider-failure.js";
1
2
  import { accountingUnitsEqual, isCanonicalAccountingDecimal } from "./accounting-format.js";
2
3
  import { sanitizeQuotaProviderResult, sanitizeSingleLineDisplayText } from "./display-sanitize.js";
3
4
  import { cloneQuotaToastEntry } from "./entries.js";
@@ -264,10 +265,11 @@ function isQuotaToastEntry(value, safeText) {
264
265
  function isQuotaToastError(value) {
265
266
  if (!isRecord(value))
266
267
  return false;
267
- return (hasOnlyKeys(value, ["label", "message", "retryable", "kind", "sourceId"]) &&
268
+ return (hasOnlyKeys(value, ["label", "message", "retryable", "failureCategory", "kind", "sourceId"]) &&
268
269
  typeof value.label === "string" &&
269
270
  typeof value.message === "string" &&
270
271
  (value.retryable === undefined || typeof value.retryable === "boolean") &&
272
+ (value.failureCategory === undefined || isProviderFailureCategory(value.failureCategory)) &&
271
273
  (value.kind === undefined || value.kind === "intentional-filter") &&
272
274
  (value.sourceId === undefined || typeof value.sourceId === "string"));
273
275
  }
@@ -111,7 +111,7 @@ export declare function resolvePricingKey(source: {
111
111
  providerID?: string;
112
112
  modelID?: string;
113
113
  }): PricingResolution;
114
- /** Existing per-message cost calculation (P3 reuses it unchanged). */
114
+ /** Per-message cost calculation; temporal rates apply only when `atMs` is supplied. */
115
115
  export declare function calculateCostUsd(params: {
116
116
  provider: string;
117
117
  model: string;
@@ -122,6 +122,18 @@ export declare function calculateCostUsd(params: {
122
122
  * rates apply and no tier is claimed as applied.
123
123
  */
124
124
  contextTokens?: number;
125
+ /**
126
+ * Optional physical completion instant. When supplied, an exact
127
+ * provider/model temporal policy is applied; unresolved rules fail closed
128
+ * rather than charging base rates.
129
+ */
130
+ atMs?: number;
131
+ /**
132
+ * Verified exact temporal route. Callers resolving from source metadata pass
133
+ * a key only when the source provider/model exactly match it; `null`
134
+ * suppresses temporal pricing for inferred/aliased routes.
135
+ */
136
+ temporalRoute?: PricedKey | null;
125
137
  }): {
126
138
  ok: true;
127
139
  costUsd: number;
@@ -130,6 +142,7 @@ export declare function calculateCostUsd(params: {
130
142
  contextTierSize?: number;
131
143
  } | {
132
144
  ok: false;
145
+ reason?: string;
133
146
  };
134
147
  /** Classify a resolved model as unpriced when the snapshot or catalog knows it without rates. */
135
148
  export declare function classifyMissingPricing(params: {
@@ -174,6 +187,12 @@ export type TokenPricingOutcome = {
174
187
  * and the GUI aggregation call this; neither resolves keys, computes cost, or
175
188
  * classifies missing pricing on its own.
176
189
  *
190
+ * `atMs` is the physical assistant completion instant for one row. When it is
191
+ * supplied, temporal pricing applies only if the raw source provider/model
192
+ * exactly match the resolved priced route; inferred providers, model aliases,
193
+ * and prefix guesses keep base pricing. When `atMs` is absent, callers keep the
194
+ * existing non-temporal pricing behavior.
195
+ *
177
196
  * `cache` is optional and keyed by a collision-safe tuple of the exact raw
178
197
  * source ids, so a caller can reuse key resolution across many messages of the
179
198
  * same source without conflating delimiter-bearing or missing ids.
@@ -184,6 +203,8 @@ export declare function priceTokenBuckets(params: {
184
203
  tokens: TokenBuckets;
185
204
  /** Optional context override; otherwise prompt token buckets select a tier. */
186
205
  contextTokens?: number;
206
+ /** Optional physical completion instant for exact historical temporal rates. */
207
+ atMs?: number;
187
208
  cache?: Map<string, PricingResolution>;
188
209
  }): TokenPricingOutcome;
189
210
  export declare function resolveSessionTree(rootSessionID: string): Promise<SessionTreeNode[]>;
@@ -1,6 +1,7 @@
1
1
  import { encodeIdentityKey } from "../contracts/collision-safe-key.js";
2
2
  import { isCursorModelId, isCursorProviderId, lookupCursorLocalCost, resolveCursorModel, } from "./cursor-pricing.js";
3
3
  import { hasCatalogModel, hasCost, hasModel, hasProvider, isModelsDevProviderId, listProvidersForModelId, lookupCost, selectCostAtContext, } from "./modelsdev-pricing.js";
4
+ import { getTemporalPolicy, resolveTemporalRates } from "./modelsdev-temporal.js";
4
5
  import { getOpenCodeDbPath } from "./opencode-db-path.js";
5
6
  import { iterAssistantMessages, iterAssistantMessagesForSession, iterAssistantMessagesForSessions, readAllSessionsIndex, SessionNotFoundError, } from "./opencode-storage.js";
6
7
  import { addTokenBuckets, emptyTokenBuckets, tokenBucketsFromMessage } from "./token-buckets.js";
@@ -526,34 +527,107 @@ function calculateKnownCost(rates, tokens) {
526
527
  }
527
528
  /**
528
529
  * Resolve the rates that apply to one priced key, including context-tier
529
- * selection. Shared by `calculateCostUsd` and `aggregateUsage` so bucket
530
- * splitting and cost calculation never disagree about which rates applied.
530
+ * selection and, when a completion instant is supplied, the exact
531
+ * provider/model temporal policy. Shared by `calculateCostUsd` and
532
+ * `aggregateUsage` so bucket splitting and cost calculation never disagree
533
+ * about which rates applied.
534
+ *
535
+ * Temporal pricing is opt-in per call: without `atMs`, existing callers keep
536
+ * using base rates unchanged. With `atMs`, only a verified exact provider/model
537
+ * route participates (never a provider inference, model alias, or prefix
538
+ * guess), and an unresolved/unsupported rule fails closed instead of silently
539
+ * charging base rates.
531
540
  */
532
541
  function selectTokenRates(params) {
542
+ let base;
543
+ let contextTierSize;
533
544
  if (params.provider === "cursor") {
534
545
  const cursorCost = lookupCursorLocalCost(params.model);
535
- return cursorCost ? { ok: true, rates: cursorCost } : { ok: false };
546
+ if (!cursorCost)
547
+ return { ok: false };
548
+ base = cursorCost;
536
549
  }
537
- const cost = lookupCost(params.provider, params.model);
538
- if (!cost)
539
- return { ok: false };
540
- const hasExplicitContext = typeof params.contextTokens === "number" && Number.isFinite(params.contextTokens);
541
- if (!cost.tiers?.length && !hasExplicitContext) {
542
- return { ok: true, rates: cost };
550
+ else {
551
+ const cost = lookupCost(params.provider, params.model);
552
+ if (!cost)
553
+ return { ok: false };
554
+ const hasExplicitContext = typeof params.contextTokens === "number" && Number.isFinite(params.contextTokens);
555
+ if (!cost.tiers?.length && !hasExplicitContext) {
556
+ base = cost;
557
+ }
558
+ else {
559
+ const contextTokens = hasExplicitContext
560
+ ? params.contextTokens
561
+ : promptTokenCount(params.tokens);
562
+ const selected = selectCostAtContext(cost, contextTokens);
563
+ base = selected.rates;
564
+ contextTierSize = selected.tierSize;
565
+ }
543
566
  }
544
- const contextTokens = hasExplicitContext ? params.contextTokens : promptTokenCount(params.tokens);
545
- const selected = selectCostAtContext(cost, contextTokens);
567
+ if (params.temporalRoute === null) {
568
+ return {
569
+ ok: true,
570
+ rates: base,
571
+ ...(contextTierSize !== undefined ? { contextTierSize } : {}),
572
+ };
573
+ }
574
+ const temporalProvider = params.temporalRoute?.provider ?? params.provider;
575
+ const temporalModel = params.temporalRoute?.model ?? params.model;
576
+ const temporal = applyTemporalRates(temporalProvider, temporalModel, base, params.atMs);
577
+ if (!temporal.ok)
578
+ return temporal;
546
579
  return {
547
580
  ok: true,
548
- rates: selected.rates,
549
- ...(selected.tierSize !== undefined ? { contextTierSize: selected.tierSize } : {}),
581
+ rates: temporal.rates,
582
+ ...(contextTierSize !== undefined ? { contextTierSize } : {}),
550
583
  };
551
584
  }
552
- /** Existing per-message cost calculation (P3 reuses it unchanged). */
585
+ /**
586
+ * Apply a model's temporal rates at one physical completion instant. Callers
587
+ * must pass a verified exact source provider/model route; this function never
588
+ * derives one from a pricing key, alias, or model-family guess.
589
+ */
590
+ function applyTemporalRates(provider, model, rates, atMs) {
591
+ if (atMs === undefined)
592
+ return { ok: true, rates };
593
+ if (getTemporalPolicy(provider, model) === null)
594
+ return { ok: true, rates };
595
+ if (!Number.isFinite(atMs)) {
596
+ return { ok: false, reason: "temporal pricing requires a finite completion timestamp" };
597
+ }
598
+ const resolved = resolveTemporalRates(provider, model, atMs, rates);
599
+ if (resolved.status !== "resolved" || resolved.rates === null) {
600
+ const detail = resolved.reason ? `: ${resolved.reason}` : "";
601
+ return {
602
+ ok: false,
603
+ reason: `temporal pricing is ${resolved.status} for ${provider}/${model}${detail}`,
604
+ };
605
+ }
606
+ return { ok: true, rates: resolved.rates };
607
+ }
608
+ /**
609
+ * Temporal corrections require a verified exact source route. A pricing key
610
+ * inferred from a model id, an alias, or a prefix is not evidence that the
611
+ * source actually came from that provider/model, so it must keep base pricing.
612
+ */
613
+ function verifiedTemporalRoute(sourceProviderID, sourceModelID, key) {
614
+ if (typeof sourceProviderID !== "string" || typeof sourceModelID !== "string")
615
+ return null;
616
+ const provider = sourceProviderID.trim();
617
+ const model = sourceModelID.trim();
618
+ if (!provider || !model)
619
+ return null;
620
+ if (provider.toLowerCase() !== key.provider.toLowerCase())
621
+ return null;
622
+ if (model !== key.model)
623
+ return null;
624
+ return { provider: key.provider, model: key.model };
625
+ }
626
+ /** Per-message cost calculation; temporal rates apply only when `atMs` is supplied. */
553
627
  export function calculateCostUsd(params) {
554
628
  const selected = selectTokenRates(params);
555
629
  if (!selected.ok)
556
- return { ok: false };
630
+ return selected;
557
631
  const known = calculateKnownCost(selected.rates, params.tokens);
558
632
  if (!known.ok)
559
633
  return known;
@@ -590,6 +664,12 @@ export function classifyMissingPricing(params) {
590
664
  * and the GUI aggregation call this; neither resolves keys, computes cost, or
591
665
  * classifies missing pricing on its own.
592
666
  *
667
+ * `atMs` is the physical assistant completion instant for one row. When it is
668
+ * supplied, temporal pricing applies only if the raw source provider/model
669
+ * exactly match the resolved priced route; inferred providers, model aliases,
670
+ * and prefix guesses keep base pricing. When `atMs` is absent, callers keep the
671
+ * existing non-temporal pricing behavior.
672
+ *
593
673
  * `cache` is optional and keyed by a collision-safe tuple of the exact raw
594
674
  * source ids, so a caller can reuse key resolution across many messages of the
595
675
  * same source without conflating delimiter-bearing or missing ids.
@@ -608,11 +688,14 @@ export function priceTokenBuckets(params) {
608
688
  return { status: "unknown", unknown: resolution.unknown };
609
689
  }
610
690
  const key = resolution.key;
691
+ const temporalRoute = verifiedTemporalRoute(params.providerID, params.modelID, key);
611
692
  const priced = calculateCostUsd({
612
693
  provider: key.provider,
613
694
  model: key.model,
614
695
  tokens: params.tokens,
615
696
  contextTokens: params.contextTokens,
697
+ atMs: params.atMs,
698
+ temporalRoute,
616
699
  });
617
700
  if (priced.ok) {
618
701
  const contextTier = priced.contextTierSize !== undefined ? { contextTierSize: priced.contextTierSize } : {};
@@ -632,6 +715,11 @@ export function priceTokenBuckets(params) {
632
715
  ...contextTier,
633
716
  };
634
717
  }
718
+ // A temporal policy that cannot be resolved is not a missing catalog price:
719
+ // report the token count as unpriced without falling back to base rates.
720
+ if (priced.reason !== undefined) {
721
+ return { status: "unpriced", key, reason: priced.reason };
722
+ }
635
723
  const classification = classifyMissingPricing({
636
724
  mappedProvider: key.provider,
637
725
  mappedModel: key.model,
@@ -704,6 +792,11 @@ export async function resolveSessionTree(rootSessionID) {
704
792
  visit(root, 0);
705
793
  return tree;
706
794
  }
795
+ /** Physical completion instant of one message, or undefined when absent/invalid. */
796
+ function messageCompletedAtMs(message) {
797
+ const completed = message.time?.completed;
798
+ return typeof completed === "number" && Number.isFinite(completed) ? completed : undefined;
799
+ }
707
800
  export async function aggregateUsage(params) {
708
801
  if (params.sessionID && params.sessionIDs?.length) {
709
802
  throw new Error("aggregateUsage received both sessionID and sessionIDs");
@@ -744,6 +837,7 @@ export async function aggregateUsage(params) {
744
837
  for (const msg of messages) {
745
838
  const tokens = tokenBucketsFromMessage(msg);
746
839
  const sid = msg.sessionID;
840
+ const atMs = messageCompletedAtMs(msg);
747
841
  const sessionTitle = sessionsIdx[sid]?.title;
748
842
  const existingSessionRow = bySession.get(sid);
749
843
  if (existingSessionRow) {
@@ -763,6 +857,7 @@ export async function aggregateUsage(params) {
763
857
  providerID: msg.providerID,
764
858
  modelID: msg.modelID,
765
859
  tokens,
860
+ atMs,
766
861
  cache: resolutionCache,
767
862
  });
768
863
  if (outcome.status === "unknown") {
@@ -815,6 +910,7 @@ export async function aggregateUsage(params) {
815
910
  provider: outcome.key.provider,
816
911
  model: outcome.key.model,
817
912
  tokens,
913
+ atMs,
818
914
  });
819
915
  if (selected.ok) {
820
916
  const split = splitTokenBucketsByRate(selected.rates, tokens);
@@ -4,6 +4,7 @@
4
4
  * Resolves API key from multiple sources and queries:
5
5
  * https://api.synthetic.new/v2/quotas
6
6
  */
7
+ import { providerFailureCategoryForHttpStatus } from "../contracts/provider-failure.js";
7
8
  import { sanitizeDisplaySnippet, sanitizeDisplayText } from "./display-sanitize.js";
8
9
  import { clampPercent } from "./format-utils.js";
9
10
  import { fetchWithTimeout } from "./http.js";
@@ -24,6 +25,7 @@ function invalidSyntheticResponse(message) {
24
25
  return {
25
26
  success: false,
26
27
  error: message,
28
+ failureCategory: "provider_api",
27
29
  };
28
30
  }
29
31
  function normalizeResetTimeIso(value) {
@@ -119,6 +121,7 @@ export async function querySyntheticQuota(options = {}) {
119
121
  const resolved = await resolveSyntheticApiKey();
120
122
  if (!resolved)
121
123
  return null;
124
+ let responseStatus;
122
125
  try {
123
126
  return await fetchWithTimeout(SYNTHETIC_QUOTA_URL, {
124
127
  request: {
@@ -130,11 +133,13 @@ export async function querySyntheticQuota(options = {}) {
130
133
  },
131
134
  timeoutMs: options.requestTimeoutMs,
132
135
  consume: async (resp) => {
136
+ responseStatus = resp.status;
133
137
  if (!resp.ok) {
134
138
  const text = await resp.text();
135
139
  return {
136
140
  success: false,
137
141
  error: `Synthetic API error ${resp.status}: ${sanitizeDisplaySnippet(text, 120)}`,
142
+ failureCategory: providerFailureCategoryForHttpStatus(resp.status),
138
143
  };
139
144
  }
140
145
  const data = (await resp.json());
@@ -167,6 +172,9 @@ export async function querySyntheticQuota(options = {}) {
167
172
  return {
168
173
  success: false,
169
174
  error: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
175
+ failureCategory: responseStatus === undefined
176
+ ? "provider_api"
177
+ : providerFailureCategoryForHttpStatus(responseStatus),
170
178
  };
171
179
  }
172
180
  }
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Type definitions for the opencode-quota-gui product.
3
3
  */
4
+ import type { ProviderFailureCategory } from "../contracts/provider-failure.js";
4
5
  import type { QuotaFormatStyle } from "./quota-format-style.js";
5
6
  import type { QuotaProviderDefinition } from "./quota-providers.js";
6
7
  export type GeminiCliAuthSourceKey = "google-gemini-cli" | "gemini-cli" | "opencode-gemini-auth" | "gemini" | "google";
@@ -60,6 +61,12 @@ export interface QuotaTelemetryConfig {
60
61
  * `opencode-quota-gui/config.jsonc` layer (spec §5.4, §7).
61
62
  */
62
63
  export interface QuotaDashboardConfig {
64
+ /**
65
+ * Whether the optional browser web transport starts. Defaults to `false`,
66
+ * including for an upgraded config that has no explicit value; only an
67
+ * explicit `true` enables the existing fixed loopback port.
68
+ */
69
+ enabled: boolean;
63
70
  /**
64
71
  * Loopback dashboard port (integer 1–65535). Read-only in the GUI: changing it
65
72
  * takes effect on restart and there is no fallback when it is occupied.
@@ -89,6 +96,12 @@ export interface QuotaDashboardConfig {
89
96
  * only; providerOrder remains the legacy fallback when this is empty.
90
97
  */
91
98
  cardOrder: string[];
99
+ /**
100
+ * Explicit temporal chip visibility per provider. Sparse by design: an
101
+ * absent provider follows account discovery, while a present boolean keeps
102
+ * the user's explicit on/off choice.
103
+ */
104
+ temporalProviderOverrides: Record<string, boolean>;
92
105
  }
93
106
  /** Default dashboard port (spec §5.4); never falls back to another port. */
94
107
  export declare const DEFAULT_DASHBOARD_PORT = 4144;
@@ -115,6 +128,14 @@ export interface QuotaToastConfig {
115
128
  enableToast: boolean;
116
129
  /** Opt-in, persisted notifications when selected quota windows reset. */
117
130
  resetNotifications: QuotaResetNotificationsConfig;
131
+ /**
132
+ * Percent of a quota window remaining at or below which quota is considered
133
+ * low. Stored as remaining even when the UI displays used percentages.
134
+ * Default: 10.
135
+ */
136
+ lowQuotaThresholdRemainingPercent: number;
137
+ /** Minutes before an identical quota alert may repeat. Default: 30. */
138
+ duplicateCooldownMinutes: number;
118
139
  /**
119
140
  * Where TUI quota slash command reports appear: "dialog" shows only the popup,
120
141
  * "inline" keeps the report in the chat. Web and Desktop always show it in the chat.
@@ -578,6 +599,7 @@ export interface CopilotEnterpriseUsageResult {
578
599
  export interface GoogleAccountError {
579
600
  email: string;
580
601
  error: string;
602
+ failureCategory?: ProviderFailureCategory;
581
603
  }
582
604
  export interface GeminiCliQuotaBucket {
583
605
  modelId: string;
@@ -641,6 +663,8 @@ export interface QuotaError {
641
663
  error: string;
642
664
  /** Whether retrying later may succeed without changing credentials or configuration. */
643
665
  retryable?: boolean;
666
+ /** Source-assigned safe category; absence means unknown and consumers fail closed. */
667
+ failureCategory?: ProviderFailureCategory;
644
668
  }
645
669
  /** Combined quota result */
646
670
  export type CopilotResult = CopilotQuotaResult | CopilotPlanResult | CopilotOrganizationUsageResult | CopilotEnterpriseUsageResult | QuotaError | null;