opencode-quota-gui 1.2.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 (523) hide show
  1. package/README.md +90 -30
  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/build-identity.js +1 -1
  6. package/dist/contracts/card-visibility.d.ts +21 -0
  7. package/dist/contracts/card-visibility.js +19 -0
  8. package/dist/contracts/dashboard.d.ts +27 -0
  9. package/dist/contracts/dashboard.js +2 -0
  10. package/dist/contracts/dto-guards.d.ts +24 -0
  11. package/dist/contracts/dto-guards.js +592 -0
  12. package/dist/contracts/provider-failure.d.ts +18 -0
  13. package/dist/contracts/provider-failure.js +25 -0
  14. package/dist/gui/config.d.ts +20 -3
  15. package/dist/gui/config.js +42 -3
  16. package/dist/gui/dashboard-errors.d.ts +32 -0
  17. package/dist/gui/dashboard-errors.js +97 -0
  18. package/dist/gui/lifecycle.d.ts +44 -11
  19. package/dist/gui/lifecycle.js +214 -36
  20. package/dist/gui/primary-quota-windows.d.ts +28 -0
  21. package/dist/gui/primary-quota-windows.js +147 -0
  22. package/dist/gui/provider-cards.d.ts +1 -1
  23. package/dist/gui/provider-cards.js +40 -16
  24. package/dist/gui/quota-notification-detector.d.ts +151 -0
  25. package/dist/gui/quota-notification-detector.js +284 -0
  26. package/dist/gui/quota-notification-observer.d.ts +55 -0
  27. package/dist/gui/quota-notification-observer.js +363 -0
  28. package/dist/gui/rpc.d.ts +59 -0
  29. package/dist/gui/rpc.js +302 -0
  30. package/dist/gui/server.d.ts +15 -27
  31. package/dist/gui/server.js +23 -121
  32. package/dist/gui/snapshot-service.d.ts +31 -4
  33. package/dist/gui/snapshot-service.js +177 -54
  34. package/dist/gui/sources.d.ts +1 -1
  35. package/dist/gui-experimental.cjs +1756 -0
  36. package/dist/lib/anthropic.d.ts +5 -0
  37. package/dist/lib/anthropic.js +18 -1
  38. package/dist/lib/chutes.js +19 -2
  39. package/dist/lib/config.d.ts +5 -1
  40. package/dist/lib/config.js +48 -0
  41. package/dist/lib/copilot.js +42 -14
  42. package/dist/lib/dashboard-web-policy.d.ts +35 -0
  43. package/dist/lib/dashboard-web-policy.js +24 -0
  44. package/dist/lib/deepseek.js +12 -1
  45. package/dist/lib/display-sanitize.js +2 -0
  46. package/dist/lib/entries.d.ts +3 -0
  47. package/dist/lib/format-utils.d.ts +1 -1
  48. package/dist/lib/format-utils.js +2 -2
  49. package/dist/lib/glm-coding-plan.js +14 -4
  50. package/dist/lib/google-agy.js +59 -14
  51. package/dist/lib/google-gemini-cli.js +58 -14
  52. package/dist/lib/init-installer.js +25 -4
  53. package/dist/lib/kilo.js +29 -40
  54. package/dist/lib/kimi.js +13 -1
  55. package/dist/lib/mimo.d.ts +2 -0
  56. package/dist/lib/mimo.js +9 -1
  57. package/dist/lib/nanogpt.d.ts +2 -0
  58. package/dist/lib/nanogpt.js +24 -3
  59. package/dist/lib/ollama-cloud.js +9 -0
  60. package/dist/lib/openai.js +6 -2
  61. package/dist/lib/opencode-auth.d.ts +3 -2
  62. package/dist/lib/opencode-auth.js +8 -1
  63. package/dist/lib/opencode-go.js +24 -3
  64. package/dist/lib/opencode-version.d.ts +21 -0
  65. package/dist/lib/opencode-version.js +53 -5
  66. package/dist/lib/opencode-zen.d.ts +9 -1
  67. package/dist/lib/opencode-zen.js +27 -7
  68. package/dist/lib/quota-providers-remote.d.ts +2 -0
  69. package/dist/lib/quota-providers-remote.js +78 -19
  70. package/dist/lib/quota-reset-notifications.d.ts +17 -0
  71. package/dist/lib/quota-reset-notifications.js +11 -2
  72. package/dist/lib/quota-state-codec.js +3 -1
  73. package/dist/lib/synthetic.js +8 -0
  74. package/dist/lib/types.d.ts +18 -0
  75. package/dist/lib/types.js +3 -0
  76. package/dist/lib/xai.js +16 -2
  77. package/dist/plugin.d.ts +4 -3
  78. package/dist/plugin.js +33 -4
  79. package/dist/providers/alibaba-coding-plan.js +3 -1
  80. package/dist/providers/alibaba-token-plan.js +17 -0
  81. package/dist/providers/anthropic.js +12 -3
  82. package/dist/providers/copilot.js +10 -2
  83. package/dist/providers/glm-coding-plan-provider.d.ts +2 -0
  84. package/dist/providers/glm-coding-plan-provider.js +5 -1
  85. package/dist/providers/google-account-format.js +1 -0
  86. package/dist/providers/google-agy.js +12 -2
  87. package/dist/providers/google-gemini-cli.js +12 -2
  88. package/dist/providers/kilo.js +9 -1
  89. package/dist/providers/kimi-code.js +11 -6
  90. package/dist/providers/mimo.js +8 -2
  91. package/dist/providers/minimax-coding-plan.js +28 -5
  92. package/dist/providers/nanogpt.js +3 -0
  93. package/dist/providers/ollama-cloud.js +3 -0
  94. package/dist/providers/openai.js +1 -0
  95. package/dist/providers/opencode-go.js +8 -1
  96. package/dist/providers/opencode-zen.js +30 -3
  97. package/dist/providers/openrouter.js +3 -0
  98. package/dist/providers/quota-providers.js +30 -4
  99. package/dist/providers/result-helpers.d.ts +4 -0
  100. package/dist/providers/result-helpers.js +16 -2
  101. package/dist/rpc.d.ts +327 -4
  102. package/dist/rpc.js +315 -2
  103. package/dist/ui/assets/index-DLHeXYff.js +9 -0
  104. package/dist/ui/assets/{index-Cs-nrywz.css → index-cDd9jUVY.css} +1 -1
  105. package/dist/ui/assets/{popover-DKRrwr_K.js → popover-BGkgv9s0.js} +1 -1
  106. package/dist/ui/index.html +2 -2
  107. package/package.json +49 -40
  108. package/dist/bin/opencode-quota-gui.d.ts.map +0 -1
  109. package/dist/bin/opencode-quota-gui.js.map +0 -1
  110. package/dist/contracts/analytics-entity.d.ts.map +0 -1
  111. package/dist/contracts/analytics-entity.js.map +0 -1
  112. package/dist/contracts/analytics-temporal.d.ts.map +0 -1
  113. package/dist/contracts/analytics-temporal.js.map +0 -1
  114. package/dist/contracts/build-identity.d.ts.map +0 -1
  115. package/dist/contracts/card-order.d.ts.map +0 -1
  116. package/dist/contracts/card-order.js.map +0 -1
  117. package/dist/contracts/collision-safe-key.d.ts.map +0 -1
  118. package/dist/contracts/collision-safe-key.js.map +0 -1
  119. package/dist/contracts/dashboard.d.ts.map +0 -1
  120. package/dist/contracts/dashboard.js.map +0 -1
  121. package/dist/contracts/guards.d.ts.map +0 -1
  122. package/dist/contracts/guards.js.map +0 -1
  123. package/dist/contracts/identity.d.ts.map +0 -1
  124. package/dist/contracts/identity.js.map +0 -1
  125. package/dist/contracts/openai-quota.d.ts.map +0 -1
  126. package/dist/contracts/openai-quota.js.map +0 -1
  127. package/dist/contracts/ranges.d.ts.map +0 -1
  128. package/dist/contracts/ranges.js.map +0 -1
  129. package/dist/contracts/settings.d.ts.map +0 -1
  130. package/dist/contracts/settings.js.map +0 -1
  131. package/dist/contracts/temporal.d.ts.map +0 -1
  132. package/dist/contracts/temporal.js.map +0 -1
  133. package/dist/contracts/time-zone.d.ts.map +0 -1
  134. package/dist/contracts/time-zone.js.map +0 -1
  135. package/dist/gui/aggregation.d.ts.map +0 -1
  136. package/dist/gui/aggregation.js.map +0 -1
  137. package/dist/gui/analytics-bridge.d.ts.map +0 -1
  138. package/dist/gui/analytics-bridge.js.map +0 -1
  139. package/dist/gui/analytics-engine.d.ts.map +0 -1
  140. package/dist/gui/analytics-engine.js.map +0 -1
  141. package/dist/gui/analytics-indexes.d.ts.map +0 -1
  142. package/dist/gui/analytics-indexes.js.map +0 -1
  143. package/dist/gui/analytics-model.d.ts.map +0 -1
  144. package/dist/gui/analytics-model.js.map +0 -1
  145. package/dist/gui/analytics-pricing-revision.d.ts.map +0 -1
  146. package/dist/gui/analytics-pricing-revision.js.map +0 -1
  147. package/dist/gui/analytics-protocol.d.ts.map +0 -1
  148. package/dist/gui/analytics-protocol.js.map +0 -1
  149. package/dist/gui/analytics-reader.d.ts.map +0 -1
  150. package/dist/gui/analytics-reader.js.map +0 -1
  151. package/dist/gui/analytics-service.d.ts.map +0 -1
  152. package/dist/gui/analytics-service.js.map +0 -1
  153. package/dist/gui/analytics-state.d.ts.map +0 -1
  154. package/dist/gui/analytics-state.js.map +0 -1
  155. package/dist/gui/analytics-worker-runtime.d.ts.map +0 -1
  156. package/dist/gui/analytics-worker-runtime.js.map +0 -1
  157. package/dist/gui/analytics-worker.d.ts.map +0 -1
  158. package/dist/gui/analytics-worker.js.map +0 -1
  159. package/dist/gui/config.d.ts.map +0 -1
  160. package/dist/gui/config.js.map +0 -1
  161. package/dist/gui/identity.d.ts.map +0 -1
  162. package/dist/gui/identity.js.map +0 -1
  163. package/dist/gui/lifecycle.d.ts.map +0 -1
  164. package/dist/gui/lifecycle.js.map +0 -1
  165. package/dist/gui/log.d.ts.map +0 -1
  166. package/dist/gui/log.js.map +0 -1
  167. package/dist/gui/provider-cards.d.ts.map +0 -1
  168. package/dist/gui/provider-cards.js.map +0 -1
  169. package/dist/gui/server.d.ts.map +0 -1
  170. package/dist/gui/server.js.map +0 -1
  171. package/dist/gui/settings-file-opener.d.ts.map +0 -1
  172. package/dist/gui/settings-file-opener.js.map +0 -1
  173. package/dist/gui/snapshot-service.d.ts.map +0 -1
  174. package/dist/gui/snapshot-service.js.map +0 -1
  175. package/dist/gui/sources.d.ts.map +0 -1
  176. package/dist/gui/sources.js.map +0 -1
  177. package/dist/gui/sse.d.ts.map +0 -1
  178. package/dist/gui/sse.js.map +0 -1
  179. package/dist/gui/temporal-quota-policy-data.d.ts.map +0 -1
  180. package/dist/gui/temporal-quota-policy-data.js.map +0 -1
  181. package/dist/gui/temporal-quota-policy.d.ts.map +0 -1
  182. package/dist/gui/temporal-quota-policy.js.map +0 -1
  183. package/dist/gui/temporal-status.d.ts.map +0 -1
  184. package/dist/gui/temporal-status.js.map +0 -1
  185. package/dist/gui/time-zone.d.ts.map +0 -1
  186. package/dist/gui/time-zone.js.map +0 -1
  187. package/dist/index.d.ts.map +0 -1
  188. package/dist/index.js.map +0 -1
  189. package/dist/lib/accounting-format.d.ts.map +0 -1
  190. package/dist/lib/accounting-format.js.map +0 -1
  191. package/dist/lib/alibaba-auth.d.ts.map +0 -1
  192. package/dist/lib/alibaba-auth.js.map +0 -1
  193. package/dist/lib/alibaba-coding-plan-local-quota.d.ts.map +0 -1
  194. package/dist/lib/alibaba-coding-plan-local-quota.js.map +0 -1
  195. package/dist/lib/alibaba-token-plan.d.ts.map +0 -1
  196. package/dist/lib/alibaba-token-plan.js.map +0 -1
  197. package/dist/lib/anthropic-auth.d.ts.map +0 -1
  198. package/dist/lib/anthropic-auth.js.map +0 -1
  199. package/dist/lib/anthropic.d.ts.map +0 -1
  200. package/dist/lib/anthropic.js.map +0 -1
  201. package/dist/lib/api-key-resolver.d.ts.map +0 -1
  202. package/dist/lib/api-key-resolver.js.map +0 -1
  203. package/dist/lib/atomic-json.d.ts.map +0 -1
  204. package/dist/lib/atomic-json.js.map +0 -1
  205. package/dist/lib/chutes-config.d.ts.map +0 -1
  206. package/dist/lib/chutes-config.js.map +0 -1
  207. package/dist/lib/chutes.d.ts.map +0 -1
  208. package/dist/lib/chutes.js.map +0 -1
  209. package/dist/lib/cli-reports.d.ts.map +0 -1
  210. package/dist/lib/cli-reports.js.map +0 -1
  211. package/dist/lib/cli-show.d.ts.map +0 -1
  212. package/dist/lib/cli-show.js.map +0 -1
  213. package/dist/lib/cli-status.d.ts.map +0 -1
  214. package/dist/lib/cli-status.js.map +0 -1
  215. package/dist/lib/command-parsing.d.ts.map +0 -1
  216. package/dist/lib/command-parsing.js.map +0 -1
  217. package/dist/lib/config-file-utils.d.ts.map +0 -1
  218. package/dist/lib/config-file-utils.js.map +0 -1
  219. package/dist/lib/config-write-target.d.ts.map +0 -1
  220. package/dist/lib/config-write-target.js.map +0 -1
  221. package/dist/lib/config.d.ts.map +0 -1
  222. package/dist/lib/config.js.map +0 -1
  223. package/dist/lib/copilot.d.ts.map +0 -1
  224. package/dist/lib/copilot.js.map +0 -1
  225. package/dist/lib/cursor-detection.d.ts.map +0 -1
  226. package/dist/lib/cursor-detection.js.map +0 -1
  227. package/dist/lib/cursor-pricing.d.ts.map +0 -1
  228. package/dist/lib/cursor-pricing.js.map +0 -1
  229. package/dist/lib/cursor-usage.d.ts.map +0 -1
  230. package/dist/lib/cursor-usage.js.map +0 -1
  231. package/dist/lib/dashboard-visibility.d.ts.map +0 -1
  232. package/dist/lib/dashboard-visibility.js.map +0 -1
  233. package/dist/lib/deepseek-auth.d.ts.map +0 -1
  234. package/dist/lib/deepseek-auth.js.map +0 -1
  235. package/dist/lib/deepseek.d.ts.map +0 -1
  236. package/dist/lib/deepseek.js.map +0 -1
  237. package/dist/lib/display-sanitize.d.ts.map +0 -1
  238. package/dist/lib/display-sanitize.js.map +0 -1
  239. package/dist/lib/entries.d.ts.map +0 -1
  240. package/dist/lib/entries.js.map +0 -1
  241. package/dist/lib/env-template.d.ts.map +0 -1
  242. package/dist/lib/env-template.js.map +0 -1
  243. package/dist/lib/format-utils.d.ts.map +0 -1
  244. package/dist/lib/format-utils.js.map +0 -1
  245. package/dist/lib/format.d.ts.map +0 -1
  246. package/dist/lib/format.js.map +0 -1
  247. package/dist/lib/glm-coding-plan.d.ts.map +0 -1
  248. package/dist/lib/glm-coding-plan.js.map +0 -1
  249. package/dist/lib/google-agy-companion.d.ts.map +0 -1
  250. package/dist/lib/google-agy-companion.js.map +0 -1
  251. package/dist/lib/google-agy.d.ts.map +0 -1
  252. package/dist/lib/google-agy.js.map +0 -1
  253. package/dist/lib/google-companion-credentials.d.ts.map +0 -1
  254. package/dist/lib/google-companion-credentials.js.map +0 -1
  255. package/dist/lib/google-gemini-cli-companion.d.ts.map +0 -1
  256. package/dist/lib/google-gemini-cli-companion.js.map +0 -1
  257. package/dist/lib/google-gemini-cli.d.ts.map +0 -1
  258. package/dist/lib/google-gemini-cli.js.map +0 -1
  259. package/dist/lib/google-token-cache.d.ts.map +0 -1
  260. package/dist/lib/google-token-cache.js.map +0 -1
  261. package/dist/lib/grouped-entry-normalization.d.ts.map +0 -1
  262. package/dist/lib/grouped-entry-normalization.js.map +0 -1
  263. package/dist/lib/grouped-header-format.d.ts.map +0 -1
  264. package/dist/lib/grouped-header-format.js.map +0 -1
  265. package/dist/lib/gui-config-target.d.ts.map +0 -1
  266. package/dist/lib/gui-config-target.js.map +0 -1
  267. package/dist/lib/home-dir-display.d.ts.map +0 -1
  268. package/dist/lib/home-dir-display.js.map +0 -1
  269. package/dist/lib/http.d.ts.map +0 -1
  270. package/dist/lib/http.js.map +0 -1
  271. package/dist/lib/init-installer.d.ts.map +0 -1
  272. package/dist/lib/init-installer.js.map +0 -1
  273. package/dist/lib/jsonc.d.ts.map +0 -1
  274. package/dist/lib/jsonc.js.map +0 -1
  275. package/dist/lib/kilo-config.d.ts.map +0 -1
  276. package/dist/lib/kilo-config.js.map +0 -1
  277. package/dist/lib/kilo.d.ts.map +0 -1
  278. package/dist/lib/kilo.js.map +0 -1
  279. package/dist/lib/kimi-auth.d.ts.map +0 -1
  280. package/dist/lib/kimi-auth.js.map +0 -1
  281. package/dist/lib/kimi-endpoints.d.ts.map +0 -1
  282. package/dist/lib/kimi-endpoints.js.map +0 -1
  283. package/dist/lib/kimi.d.ts.map +0 -1
  284. package/dist/lib/kimi.js.map +0 -1
  285. package/dist/lib/maintainer-announcements.d.ts.map +0 -1
  286. package/dist/lib/maintainer-announcements.js.map +0 -1
  287. package/dist/lib/map-with-concurrency.d.ts.map +0 -1
  288. package/dist/lib/map-with-concurrency.js.map +0 -1
  289. package/dist/lib/markdown-table.d.ts.map +0 -1
  290. package/dist/lib/markdown-table.js.map +0 -1
  291. package/dist/lib/mimo-config.d.ts.map +0 -1
  292. package/dist/lib/mimo-config.js.map +0 -1
  293. package/dist/lib/mimo.d.ts.map +0 -1
  294. package/dist/lib/mimo.js.map +0 -1
  295. package/dist/lib/minimax-auth.d.ts.map +0 -1
  296. package/dist/lib/minimax-auth.js.map +0 -1
  297. package/dist/lib/minimax-endpoints.d.ts.map +0 -1
  298. package/dist/lib/minimax-endpoints.js.map +0 -1
  299. package/dist/lib/modelsdev-pricing.d.ts.map +0 -1
  300. package/dist/lib/modelsdev-pricing.js.map +0 -1
  301. package/dist/lib/modelsdev-temporal.d.ts.map +0 -1
  302. package/dist/lib/modelsdev-temporal.js.map +0 -1
  303. package/dist/lib/nanogpt-config.d.ts.map +0 -1
  304. package/dist/lib/nanogpt-config.js.map +0 -1
  305. package/dist/lib/nanogpt.d.ts.map +0 -1
  306. package/dist/lib/nanogpt.js.map +0 -1
  307. package/dist/lib/ollama-cloud-config.d.ts.map +0 -1
  308. package/dist/lib/ollama-cloud-config.js.map +0 -1
  309. package/dist/lib/ollama-cloud.d.ts.map +0 -1
  310. package/dist/lib/ollama-cloud.js.map +0 -1
  311. package/dist/lib/openai.d.ts.map +0 -1
  312. package/dist/lib/openai.js.map +0 -1
  313. package/dist/lib/opencode-auth-sqlite.d.ts.map +0 -1
  314. package/dist/lib/opencode-auth-sqlite.js.map +0 -1
  315. package/dist/lib/opencode-auth.d.ts.map +0 -1
  316. package/dist/lib/opencode-auth.js.map +0 -1
  317. package/dist/lib/opencode-config-editor.d.ts.map +0 -1
  318. package/dist/lib/opencode-config-editor.js.map +0 -1
  319. package/dist/lib/opencode-config-providers.d.ts.map +0 -1
  320. package/dist/lib/opencode-config-providers.js.map +0 -1
  321. package/dist/lib/opencode-config-read.d.ts.map +0 -1
  322. package/dist/lib/opencode-config-read.js.map +0 -1
  323. package/dist/lib/opencode-console-auth.d.ts.map +0 -1
  324. package/dist/lib/opencode-console-auth.js.map +0 -1
  325. package/dist/lib/opencode-db-path.d.ts.map +0 -1
  326. package/dist/lib/opencode-db-path.js.map +0 -1
  327. package/dist/lib/opencode-go-auth.d.ts.map +0 -1
  328. package/dist/lib/opencode-go-auth.js.map +0 -1
  329. package/dist/lib/opencode-go.d.ts.map +0 -1
  330. package/dist/lib/opencode-go.js.map +0 -1
  331. package/dist/lib/opencode-runtime-paths.d.ts.map +0 -1
  332. package/dist/lib/opencode-runtime-paths.js.map +0 -1
  333. package/dist/lib/opencode-sqlite.d.ts.map +0 -1
  334. package/dist/lib/opencode-sqlite.js.map +0 -1
  335. package/dist/lib/opencode-storage.d.ts.map +0 -1
  336. package/dist/lib/opencode-storage.js.map +0 -1
  337. package/dist/lib/opencode-version.d.ts.map +0 -1
  338. package/dist/lib/opencode-version.js.map +0 -1
  339. package/dist/lib/opencode-zen.d.ts.map +0 -1
  340. package/dist/lib/opencode-zen.js.map +0 -1
  341. package/dist/lib/openrouter.d.ts.map +0 -1
  342. package/dist/lib/openrouter.js.map +0 -1
  343. package/dist/lib/private-state-paths.d.ts.map +0 -1
  344. package/dist/lib/private-state-paths.js.map +0 -1
  345. package/dist/lib/provider-add-command.d.ts.map +0 -1
  346. package/dist/lib/provider-add-command.js.map +0 -1
  347. package/dist/lib/provider-add-json-v1-questionnaire.d.ts.map +0 -1
  348. package/dist/lib/provider-add-json-v1-questionnaire.js.map +0 -1
  349. package/dist/lib/provider-add.d.ts.map +0 -1
  350. package/dist/lib/provider-add.js.map +0 -1
  351. package/dist/lib/provider-availability.d.ts.map +0 -1
  352. package/dist/lib/provider-availability.js.map +0 -1
  353. package/dist/lib/provider-metadata.d.ts.map +0 -1
  354. package/dist/lib/provider-metadata.js.map +0 -1
  355. package/dist/lib/provider-model-matching.d.ts.map +0 -1
  356. package/dist/lib/provider-model-matching.js.map +0 -1
  357. package/dist/lib/provider-registration.d.ts.map +0 -1
  358. package/dist/lib/provider-registration.js.map +0 -1
  359. package/dist/lib/quota-accounting-projection.d.ts.map +0 -1
  360. package/dist/lib/quota-accounting-projection.js.map +0 -1
  361. package/dist/lib/quota-columns.d.ts.map +0 -1
  362. package/dist/lib/quota-columns.js.map +0 -1
  363. package/dist/lib/quota-command-format.d.ts.map +0 -1
  364. package/dist/lib/quota-command-format.js.map +0 -1
  365. package/dist/lib/quota-dialog-command-specs.d.ts.map +0 -1
  366. package/dist/lib/quota-dialog-command-specs.js.map +0 -1
  367. package/dist/lib/quota-dialog-commands.d.ts.map +0 -1
  368. package/dist/lib/quota-dialog-commands.js.map +0 -1
  369. package/dist/lib/quota-entry-display.d.ts.map +0 -1
  370. package/dist/lib/quota-entry-display.js.map +0 -1
  371. package/dist/lib/quota-exhaustion-projection.d.ts.map +0 -1
  372. package/dist/lib/quota-exhaustion-projection.js.map +0 -1
  373. package/dist/lib/quota-export-types.d.ts.map +0 -1
  374. package/dist/lib/quota-export-types.js.map +0 -1
  375. package/dist/lib/quota-export.d.ts.map +0 -1
  376. package/dist/lib/quota-export.js.map +0 -1
  377. package/dist/lib/quota-format-style.d.ts.map +0 -1
  378. package/dist/lib/quota-format-style.js.map +0 -1
  379. package/dist/lib/quota-providers-local.d.ts.map +0 -1
  380. package/dist/lib/quota-providers-local.js.map +0 -1
  381. package/dist/lib/quota-providers-remote.d.ts.map +0 -1
  382. package/dist/lib/quota-providers-remote.js.map +0 -1
  383. package/dist/lib/quota-providers.d.ts.map +0 -1
  384. package/dist/lib/quota-providers.js.map +0 -1
  385. package/dist/lib/quota-render-data.d.ts.map +0 -1
  386. package/dist/lib/quota-render-data.js.map +0 -1
  387. package/dist/lib/quota-report-message.d.ts.map +0 -1
  388. package/dist/lib/quota-report-message.js.map +0 -1
  389. package/dist/lib/quota-reset-notifications.d.ts.map +0 -1
  390. package/dist/lib/quota-reset-notifications.js.map +0 -1
  391. package/dist/lib/quota-retry-wait.d.ts.map +0 -1
  392. package/dist/lib/quota-retry-wait.js.map +0 -1
  393. package/dist/lib/quota-runtime-context.d.ts.map +0 -1
  394. package/dist/lib/quota-runtime-context.js.map +0 -1
  395. package/dist/lib/quota-state-codec.d.ts.map +0 -1
  396. package/dist/lib/quota-state-codec.js.map +0 -1
  397. package/dist/lib/quota-state.d.ts.map +0 -1
  398. package/dist/lib/quota-state.js.map +0 -1
  399. package/dist/lib/quota-stats-format.d.ts.map +0 -1
  400. package/dist/lib/quota-stats-format.js.map +0 -1
  401. package/dist/lib/quota-stats.d.ts.map +0 -1
  402. package/dist/lib/quota-stats.js.map +0 -1
  403. package/dist/lib/quota-status.d.ts.map +0 -1
  404. package/dist/lib/quota-status.js.map +0 -1
  405. package/dist/lib/quota-surface-data.d.ts.map +0 -1
  406. package/dist/lib/quota-surface-data.js.map +0 -1
  407. package/dist/lib/quota-telemetry.d.ts.map +0 -1
  408. package/dist/lib/quota-telemetry.js.map +0 -1
  409. package/dist/lib/report-document.d.ts.map +0 -1
  410. package/dist/lib/report-document.js.map +0 -1
  411. package/dist/lib/resolved-auth-identity.d.ts.map +0 -1
  412. package/dist/lib/resolved-auth-identity.js.map +0 -1
  413. package/dist/lib/runtime-provider-ids.d.ts.map +0 -1
  414. package/dist/lib/runtime-provider-ids.js.map +0 -1
  415. package/dist/lib/scoped-query-chunks.d.ts.map +0 -1
  416. package/dist/lib/scoped-query-chunks.js.map +0 -1
  417. package/dist/lib/scoped-update-migration.d.ts.map +0 -1
  418. package/dist/lib/scoped-update-migration.js.map +0 -1
  419. package/dist/lib/scoped-update.d.ts.map +0 -1
  420. package/dist/lib/scoped-update.js.map +0 -1
  421. package/dist/lib/session-tokens-format.d.ts.map +0 -1
  422. package/dist/lib/session-tokens-format.js.map +0 -1
  423. package/dist/lib/session-tokens.d.ts.map +0 -1
  424. package/dist/lib/session-tokens.js.map +0 -1
  425. package/dist/lib/synthetic-config.d.ts.map +0 -1
  426. package/dist/lib/synthetic-config.js.map +0 -1
  427. package/dist/lib/synthetic.d.ts.map +0 -1
  428. package/dist/lib/synthetic.js.map +0 -1
  429. package/dist/lib/toast-format-grouped.d.ts.map +0 -1
  430. package/dist/lib/toast-format-grouped.js.map +0 -1
  431. package/dist/lib/token-buckets.d.ts.map +0 -1
  432. package/dist/lib/token-buckets.js.map +0 -1
  433. package/dist/lib/token-cost.d.ts.map +0 -1
  434. package/dist/lib/token-cost.js.map +0 -1
  435. package/dist/lib/tui-compact-format.d.ts.map +0 -1
  436. package/dist/lib/tui-compact-format.js.map +0 -1
  437. package/dist/lib/tui-panel-state.d.ts.map +0 -1
  438. package/dist/lib/tui-panel-state.js.map +0 -1
  439. package/dist/lib/tui-prompt-bar-format.d.ts.map +0 -1
  440. package/dist/lib/tui-prompt-bar-format.js.map +0 -1
  441. package/dist/lib/tui-sidebar-format.d.ts.map +0 -1
  442. package/dist/lib/tui-sidebar-format.js.map +0 -1
  443. package/dist/lib/types.d.ts.map +0 -1
  444. package/dist/lib/types.js.map +0 -1
  445. package/dist/lib/usage-ownership.d.ts.map +0 -1
  446. package/dist/lib/usage-ownership.js.map +0 -1
  447. package/dist/lib/version.d.ts.map +0 -1
  448. package/dist/lib/version.js.map +0 -1
  449. package/dist/lib/xai.d.ts.map +0 -1
  450. package/dist/lib/xai.js.map +0 -1
  451. package/dist/lib/zai-auth.d.ts.map +0 -1
  452. package/dist/lib/zai-auth.js.map +0 -1
  453. package/dist/lib/zai.d.ts.map +0 -1
  454. package/dist/lib/zai.js.map +0 -1
  455. package/dist/lib/zhipu-auth.d.ts.map +0 -1
  456. package/dist/lib/zhipu-auth.js.map +0 -1
  457. package/dist/lib/zhipu.d.ts.map +0 -1
  458. package/dist/lib/zhipu.js.map +0 -1
  459. package/dist/plugin.d.ts.map +0 -1
  460. package/dist/plugin.js.map +0 -1
  461. package/dist/providers/accounting-decimal.d.ts.map +0 -1
  462. package/dist/providers/accounting-decimal.js.map +0 -1
  463. package/dist/providers/alibaba-coding-plan.d.ts.map +0 -1
  464. package/dist/providers/alibaba-coding-plan.js.map +0 -1
  465. package/dist/providers/alibaba-token-plan.d.ts.map +0 -1
  466. package/dist/providers/alibaba-token-plan.js.map +0 -1
  467. package/dist/providers/anthropic.d.ts.map +0 -1
  468. package/dist/providers/anthropic.js.map +0 -1
  469. package/dist/providers/cache-policies.d.ts.map +0 -1
  470. package/dist/providers/cache-policies.js.map +0 -1
  471. package/dist/providers/chutes.d.ts.map +0 -1
  472. package/dist/providers/chutes.js.map +0 -1
  473. package/dist/providers/copilot.d.ts.map +0 -1
  474. package/dist/providers/copilot.js.map +0 -1
  475. package/dist/providers/cursor.d.ts.map +0 -1
  476. package/dist/providers/cursor.js.map +0 -1
  477. package/dist/providers/deepseek.d.ts.map +0 -1
  478. package/dist/providers/deepseek.js.map +0 -1
  479. package/dist/providers/glm-coding-plan-provider.d.ts.map +0 -1
  480. package/dist/providers/glm-coding-plan-provider.js.map +0 -1
  481. package/dist/providers/google-account-format.d.ts.map +0 -1
  482. package/dist/providers/google-account-format.js.map +0 -1
  483. package/dist/providers/google-agy.d.ts.map +0 -1
  484. package/dist/providers/google-agy.js.map +0 -1
  485. package/dist/providers/google-gemini-cli.d.ts.map +0 -1
  486. package/dist/providers/google-gemini-cli.js.map +0 -1
  487. package/dist/providers/kilo.d.ts.map +0 -1
  488. package/dist/providers/kilo.js.map +0 -1
  489. package/dist/providers/kimi-code.d.ts.map +0 -1
  490. package/dist/providers/kimi-code.js.map +0 -1
  491. package/dist/providers/mimo.d.ts.map +0 -1
  492. package/dist/providers/mimo.js.map +0 -1
  493. package/dist/providers/minimax-coding-plan.d.ts.map +0 -1
  494. package/dist/providers/minimax-coding-plan.js.map +0 -1
  495. package/dist/providers/nanogpt.d.ts.map +0 -1
  496. package/dist/providers/nanogpt.js.map +0 -1
  497. package/dist/providers/ollama-cloud.d.ts.map +0 -1
  498. package/dist/providers/ollama-cloud.js.map +0 -1
  499. package/dist/providers/openai.d.ts.map +0 -1
  500. package/dist/providers/openai.js.map +0 -1
  501. package/dist/providers/opencode-go.d.ts.map +0 -1
  502. package/dist/providers/opencode-go.js.map +0 -1
  503. package/dist/providers/opencode-zen.d.ts.map +0 -1
  504. package/dist/providers/opencode-zen.js.map +0 -1
  505. package/dist/providers/openrouter.d.ts.map +0 -1
  506. package/dist/providers/openrouter.js.map +0 -1
  507. package/dist/providers/quota-providers.d.ts.map +0 -1
  508. package/dist/providers/quota-providers.js.map +0 -1
  509. package/dist/providers/registry.d.ts.map +0 -1
  510. package/dist/providers/registry.js.map +0 -1
  511. package/dist/providers/result-helpers.d.ts.map +0 -1
  512. package/dist/providers/result-helpers.js.map +0 -1
  513. package/dist/providers/synthetic.d.ts.map +0 -1
  514. package/dist/providers/synthetic.js.map +0 -1
  515. package/dist/providers/xai.d.ts.map +0 -1
  516. package/dist/providers/xai.js.map +0 -1
  517. package/dist/providers/zai.d.ts.map +0 -1
  518. package/dist/providers/zai.js.map +0 -1
  519. package/dist/providers/zhipu.d.ts.map +0 -1
  520. package/dist/providers/zhipu.js.map +0 -1
  521. package/dist/rpc.d.ts.map +0 -1
  522. package/dist/rpc.js.map +0 -1
  523. package/dist/ui/assets/index-D9lFKhSN.js +0 -9
@@ -7,6 +7,7 @@
7
7
  * token: OpenCode's own Anthropic login, then Claude OAuth credentials (macOS
8
8
  * Keychain first, then the local credentials file).
9
9
  */
10
+ import type { ProviderFailureCategory } from "../contracts/provider-failure.js";
10
11
  import { type ResolvedAuthIdentity } from "./resolved-auth-identity.js";
11
12
  export interface AnthropicQuotaWindow {
12
13
  utilization?: number;
@@ -55,6 +56,8 @@ export interface AnthropicUsageParseOptions {
55
56
  export interface AnthropicQuotaError {
56
57
  success: false;
57
58
  error: string;
59
+ /** Source-assigned safe category; absence means unknown and consumers fail closed. */
60
+ failureCategory?: ProviderFailureCategory;
58
61
  }
59
62
  export type AnthropicResult = AnthropicQuotaResult | AnthropicQuotaError | null;
60
63
  export type AnthropicAuthStatus = "authenticated" | "unauthenticated" | "unknown";
@@ -74,6 +77,8 @@ export interface AnthropicDiagnostics {
74
77
  binaryPath: string | null;
75
78
  checkedCommands: string[];
76
79
  message?: string;
80
+ /** Source-assigned category for a failed OAuth usage request; absent otherwise. */
81
+ failureCategory?: ProviderFailureCategory;
77
82
  quota?: AnthropicQuotaResult;
78
83
  }
79
84
  export interface AnthropicProbeOptions {
@@ -541,6 +541,7 @@ async function performAnthropicOAuthUsageRequest(accessToken, tokenFingerprint,
541
541
  return {
542
542
  state: "unavailable",
543
543
  detail: `${errorDetail} ${getAnthropicOAuthCooldownMessage(durationMs)}`,
544
+ failureCategory: "provider_api",
544
545
  };
545
546
  }
546
547
  anthropicOAuthCooldowns.delete(tokenFingerprint);
@@ -561,6 +562,7 @@ async function performAnthropicOAuthUsageRequest(accessToken, tokenFingerprint,
561
562
  ? `Anthropic API error ${response.status}: ${detail}`
562
563
  : `Anthropic API returned ${response.status}`,
563
564
  ...(authenticationFailure ? { failureKind: "authentication" } : {}),
565
+ failureCategory: authenticationFailure ? "credentials" : "provider_api",
564
566
  };
565
567
  }
566
568
  let data;
@@ -573,6 +575,7 @@ async function performAnthropicOAuthUsageRequest(accessToken, tokenFingerprint,
573
575
  return {
574
576
  state: "unavailable",
575
577
  detail: "Failed to parse Anthropic quota response",
578
+ failureCategory: "provider_api",
576
579
  };
577
580
  }
578
581
  const quota = parseOAuthUsageResponse(data);
@@ -580,6 +583,7 @@ async function performAnthropicOAuthUsageRequest(accessToken, tokenFingerprint,
580
583
  return {
581
584
  state: "unavailable",
582
585
  detail: "Unexpected Anthropic quota response shape",
586
+ failureCategory: "provider_api",
583
587
  };
584
588
  }
585
589
  return {
@@ -593,6 +597,7 @@ async function performAnthropicOAuthUsageRequest(accessToken, tokenFingerprint,
593
597
  return {
594
598
  state: "unavailable",
595
599
  detail: sanitizeAnthropicRequestError(error instanceof Error ? error.message : String(error), accessToken),
600
+ failureCategory: "provider_api",
596
601
  };
597
602
  }
598
603
  }
@@ -626,7 +631,13 @@ export async function queryAnthropicQuotaWithOAuth(accessToken, requestTimeoutMs
626
631
  const result = await queryAnthropicQuotaFromOAuthAccessToken(accessToken, requestTimeoutMs);
627
632
  return result.state === "success"
628
633
  ? result.quota
629
- : { success: false, error: result.detail ?? "Anthropic OAuth quota unavailable" };
634
+ : {
635
+ success: false,
636
+ error: result.detail ?? "Anthropic OAuth quota unavailable",
637
+ ...(result.failureCategory !== undefined
638
+ ? { failureCategory: result.failureCategory }
639
+ : {}),
640
+ };
630
641
  }
631
642
  function extractAuthBoolean(data) {
632
643
  const record = asRecord(data);
@@ -1009,6 +1020,9 @@ export async function getAnthropicDiagnostics(options = {}) {
1009
1020
  binaryPath: localDiagnostics.binaryPath,
1010
1021
  checkedCommands: localDiagnostics.checkedCommands,
1011
1022
  message: buildAnthropicNoQuotaDiagnosticsMessage(fallbackQuota.detail),
1023
+ ...(fallbackQuota.failureCategory !== undefined
1024
+ ? { failureCategory: fallbackQuota.failureCategory }
1025
+ : {}),
1012
1026
  };
1013
1027
  return diagnostics;
1014
1028
  }
@@ -1119,6 +1133,9 @@ export async function queryAnthropicQuota(options = {}) {
1119
1133
  return {
1120
1134
  success: false,
1121
1135
  error: diagnostics.message,
1136
+ ...(diagnostics.failureCategory !== undefined
1137
+ ? { failureCategory: diagnostics.failureCategory }
1138
+ : {}),
1122
1139
  };
1123
1140
  }
1124
1141
  return null;
@@ -4,6 +4,7 @@
4
4
  * Resolves API key from multiple sources and queries:
5
5
  * https://api.chutes.ai/users/me/quota_usage/me
6
6
  */
7
+ import { providerFailureCategoryForHttpStatus } from "../contracts/provider-failure.js";
7
8
  import { resolveChutesApiKey, } from "./chutes-config.js";
8
9
  import { sanitizeDisplaySnippet, sanitizeDisplayText } from "./display-sanitize.js";
9
10
  import { clampPercent } from "./format-utils.js";
@@ -19,6 +20,7 @@ export async function queryChutesQuota(options = {}) {
19
20
  const resolved = await resolveChutesApiKey();
20
21
  if (!resolved)
21
22
  return null;
23
+ let responseStatus;
22
24
  try {
23
25
  return await fetchWithTimeout(CHUTES_QUOTA_URL, {
24
26
  request: {
@@ -30,17 +32,29 @@ export async function queryChutesQuota(options = {}) {
30
32
  },
31
33
  timeoutMs: options.requestTimeoutMs,
32
34
  consume: async (resp) => {
35
+ responseStatus = resp.status;
33
36
  if (!resp.ok) {
34
37
  const text = await resp.text();
35
38
  return {
36
39
  success: false,
37
40
  error: `Chutes API error ${resp.status}: ${sanitizeDisplaySnippet(text, 120)}`,
41
+ failureCategory: providerFailureCategoryForHttpStatus(resp.status),
38
42
  };
39
43
  }
40
44
  const data = (await resp.json());
45
+ if (typeof data.used !== "number" ||
46
+ !Number.isFinite(data.used) ||
47
+ typeof data.quota !== "number" ||
48
+ !Number.isFinite(data.quota)) {
49
+ return {
50
+ success: false,
51
+ error: "Chutes API response returned an unexpected response shape",
52
+ failureCategory: "provider_api",
53
+ };
54
+ }
41
55
  // Chutes returns used and quota.
42
- const used = typeof data.used === "number" ? data.used : 0;
43
- const quota = typeof data.quota === "number" ? data.quota : 0;
56
+ const used = data.used;
57
+ const quota = data.quota;
44
58
  const percentRemaining = quota > 0 ? clampPercent(((quota - used) / quota) * 100) : 0;
45
59
  return {
46
60
  success: true,
@@ -54,6 +68,9 @@ export async function queryChutesQuota(options = {}) {
54
68
  return {
55
69
  success: false,
56
70
  error: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
71
+ failureCategory: responseStatus === undefined
72
+ ? "provider_api"
73
+ : providerFailureCategoryForHttpStatus(responseStatus),
57
74
  };
58
75
  }
59
76
  }
@@ -21,7 +21,7 @@ export declare const GUI_CONFIG_RELATIVE_PATH = "opencode-quota-gui/config.jsonc
21
21
  export declare const GUI_CONFIG_SIBLING_JSON_RELATIVE_PATH = "opencode-quota-gui/config.json";
22
22
  export declare function getGuiConfigPath(configDir: string): string;
23
23
  export declare function getGuiConfigSiblingJsonPath(configDir: string): string;
24
- export declare const QUOTA_TOAST_SETTING_SOURCE_KEYS: readonly ["enabled", "enableToast", "resetNotifications.enabled", "resetNotifications.windows", "tuiCommandDisplay", "formatStyle", "percentDisplayMode", "quotaProjection", "percentLabelStyle", "accountingDetail", "resetTimeDecimals", "resetTimeSpaced", "minIntervalMs", "requestTimeoutMs", "debug", "enabledProviders", "quotaProviders", "anthropicBinaryPath", "cursorPlan", "cursorIncludedApiUsd", "cursorBillingCycleStartDay", "opencodeGoWindows", "opencodeMonthlyLimit", "pricingSnapshot.source", "pricingSnapshot.autoRefresh", "showOnIdle", "showOnQuestion", "showOnCompact", "showOnBothFail", "toastDurationMs", "onlyCurrentModel", "waitForQuotaReset", "showSessionTokens", "sessionTokenScope", "tuiSidebarPanel.enabled", "tuiSidebarPanel.formatStyle", "tuiSidebarPanel.opencodeGoPreferredWindow", "tuiCompactStatus.enabled", "tuiCompactStatus.homeBottom", "tuiCompactStatus.sessionPrompt", "tuiCompactStatus.maxWidth", "tuiCompactStatus.formatStyle", "tuiPromptBar.enabled", "maintainerAnnouncements.enabled", "maintainerAnnouncements.home", "maintainerAnnouncements.homeFrequency", "layout.maxWidth", "layout.narrowAt", "layout.tinyAt", "export.enabled", "export.path", "telemetry.enabled", "dashboard.port", "dashboard.hiddenCards", "dashboard.hiddenCardsVersion", "dashboard.hiddenRows", "dashboard.providerOrder", "dashboard.cardOrder", "dashboard.temporalProviderOverrides"];
24
+ export declare const QUOTA_TOAST_SETTING_SOURCE_KEYS: readonly ["enabled", "enableToast", "resetNotifications.enabled", "resetNotifications.windows", "lowQuotaThresholdRemainingPercent", "duplicateCooldownMinutes", "tuiCommandDisplay", "formatStyle", "percentDisplayMode", "quotaProjection", "percentLabelStyle", "accountingDetail", "resetTimeDecimals", "resetTimeSpaced", "minIntervalMs", "requestTimeoutMs", "debug", "enabledProviders", "quotaProviders", "anthropicBinaryPath", "cursorPlan", "cursorIncludedApiUsd", "cursorBillingCycleStartDay", "opencodeGoWindows", "opencodeMonthlyLimit", "pricingSnapshot.source", "pricingSnapshot.autoRefresh", "showOnIdle", "showOnQuestion", "showOnCompact", "showOnBothFail", "toastDurationMs", "onlyCurrentModel", "waitForQuotaReset", "showSessionTokens", "sessionTokenScope", "tuiSidebarPanel.enabled", "tuiSidebarPanel.formatStyle", "tuiSidebarPanel.opencodeGoPreferredWindow", "tuiCompactStatus.enabled", "tuiCompactStatus.homeBottom", "tuiCompactStatus.sessionPrompt", "tuiCompactStatus.maxWidth", "tuiCompactStatus.formatStyle", "tuiPromptBar.enabled", "maintainerAnnouncements.enabled", "maintainerAnnouncements.home", "maintainerAnnouncements.homeFrequency", "layout.maxWidth", "layout.narrowAt", "layout.tinyAt", "export.enabled", "export.path", "telemetry.enabled", "dashboard.enabled", "dashboard.port", "dashboard.hiddenCards", "dashboard.hiddenCardsVersion", "dashboard.hiddenRows", "dashboard.providerOrder", "dashboard.cardOrder", "dashboard.temporalProviderOverrides"];
25
25
  export type QuotaToastSettingSourceKey = (typeof QUOTA_TOAST_SETTING_SOURCE_KEYS)[number];
26
26
  export type QuotaToastSettingSources = Partial<Record<QuotaToastSettingSourceKey, string>>;
27
27
  export interface LoadConfigIssue {
@@ -66,6 +66,10 @@ export declare function getQuotaToastConfigPath(configRootDir: string, format?:
66
66
  export declare function resolveQuotaToastConfigPath(configRootDir: string): string;
67
67
  export declare function isPositiveNumber(value: unknown): value is number;
68
68
  export declare function isValidOpenCodeGoWindows(value: unknown): value is Array<"rolling" | "weekly" | "monthly">;
69
+ /** Quota alert threshold: a whole percent remaining, from 1 through 100. */
70
+ export declare function isValidLowQuotaThresholdRemainingPercent(value: unknown): value is number;
71
+ /** Duplicate alert cooldown: a whole number of minutes, zero or more. */
72
+ export declare function isValidDuplicateCooldownMinutes(value: unknown): value is number;
69
73
  type NormalizedEnabledProviders = {
70
74
  value?: string[] | "auto";
71
75
  issues: string[];
@@ -42,6 +42,8 @@ export const QUOTA_TOAST_SETTING_SOURCE_KEYS = [
42
42
  "enableToast",
43
43
  "resetNotifications.enabled",
44
44
  "resetNotifications.windows",
45
+ "lowQuotaThresholdRemainingPercent",
46
+ "duplicateCooldownMinutes",
45
47
  "tuiCommandDisplay",
46
48
  "formatStyle",
47
49
  "percentDisplayMode",
@@ -90,6 +92,7 @@ export const QUOTA_TOAST_SETTING_SOURCE_KEYS = [
90
92
  "export.enabled",
91
93
  "export.path",
92
94
  "telemetry.enabled",
95
+ "dashboard.enabled",
93
96
  "dashboard.port",
94
97
  "dashboard.hiddenCards",
95
98
  "dashboard.hiddenCardsVersion",
@@ -239,6 +242,7 @@ function cloneConfig(config) {
239
242
  export: { ...config.export },
240
243
  telemetry: { ...config.telemetry },
241
244
  dashboard: {
245
+ enabled: config.dashboard.enabled,
242
246
  port: config.dashboard.port,
243
247
  hiddenCards: [...config.dashboard.hiddenCards],
244
248
  hiddenCardsVersion: config.dashboard.hiddenCardsVersion,
@@ -257,6 +261,14 @@ const QUOTA_RESET_WINDOWS = [
257
261
  "monthly",
258
262
  "yearly",
259
263
  ];
264
+ /** Quota alert threshold: a whole percent remaining, from 1 through 100. */
265
+ export function isValidLowQuotaThresholdRemainingPercent(value) {
266
+ return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 100;
267
+ }
268
+ /** Duplicate alert cooldown: a whole number of minutes, zero or more. */
269
+ export function isValidDuplicateCooldownMinutes(value) {
270
+ return typeof value === "number" && Number.isInteger(value) && value >= 0;
271
+ }
260
272
  function extractQuotaResetNotificationsPatch(value, reportIssue) {
261
273
  if (!isPlainObject(value))
262
274
  return undefined;
@@ -476,6 +488,14 @@ function extractDashboardPatch(value, reportIssue) {
476
488
  return undefined;
477
489
  }
478
490
  const patch = {};
491
+ if (hasOwnKey(value, "enabled")) {
492
+ if (typeof value.enabled === "boolean") {
493
+ patch.enabled = value.enabled;
494
+ }
495
+ else {
496
+ reportIssue?.("dashboard.enabled", "expected boolean");
497
+ }
498
+ }
479
499
  if (hasOwnKey(value, "port")) {
480
500
  if (isValidDashboardPort(value.port)) {
481
501
  patch.port = value.port;
@@ -533,6 +553,22 @@ function extractValidatedQuotaToastPatch(quotaToastConfig, reportIssue, options
533
553
  if (resetNotifications)
534
554
  patch.resetNotifications = resetNotifications;
535
555
  }
556
+ if (hasOwnKey(quotaToastConfig, "lowQuotaThresholdRemainingPercent")) {
557
+ if (isValidLowQuotaThresholdRemainingPercent(quotaToastConfig.lowQuotaThresholdRemainingPercent)) {
558
+ patch.lowQuotaThresholdRemainingPercent = quotaToastConfig.lowQuotaThresholdRemainingPercent;
559
+ }
560
+ else {
561
+ reportIssue?.("lowQuotaThresholdRemainingPercent", "expected an integer between 1 and 100");
562
+ }
563
+ }
564
+ if (hasOwnKey(quotaToastConfig, "duplicateCooldownMinutes")) {
565
+ if (isValidDuplicateCooldownMinutes(quotaToastConfig.duplicateCooldownMinutes)) {
566
+ patch.duplicateCooldownMinutes = quotaToastConfig.duplicateCooldownMinutes;
567
+ }
568
+ else {
569
+ reportIssue?.("duplicateCooldownMinutes", "expected an integer of 0 or more");
570
+ }
571
+ }
536
572
  if (hasOwnKey(quotaToastConfig, "tuiCommandDisplay")) {
537
573
  if (isValidTuiCommandDisplay(quotaToastConfig.tuiCommandDisplay)) {
538
574
  patch.tuiCommandDisplay = quotaToastConfig.tuiCommandDisplay;
@@ -753,6 +789,14 @@ function applyValidatedQuotaToastPatch(config, patch, sourcePath, settingSources
753
789
  applySettingSource(settingSources, "resetNotifications.windows", sourcePath);
754
790
  }
755
791
  }
792
+ if (hasOwnKey(patch, "lowQuotaThresholdRemainingPercent")) {
793
+ config.lowQuotaThresholdRemainingPercent = patch.lowQuotaThresholdRemainingPercent;
794
+ applySettingSource(settingSources, "lowQuotaThresholdRemainingPercent", sourcePath);
795
+ }
796
+ if (hasOwnKey(patch, "duplicateCooldownMinutes")) {
797
+ config.duplicateCooldownMinutes = patch.duplicateCooldownMinutes;
798
+ applySettingSource(settingSources, "duplicateCooldownMinutes", sourcePath);
799
+ }
756
800
  if (hasOwnKey(patch, "tuiCommandDisplay")) {
757
801
  config.tuiCommandDisplay = patch.tuiCommandDisplay;
758
802
  applySettingSource(settingSources, "tuiCommandDisplay", sourcePath);
@@ -960,6 +1004,10 @@ function applyValidatedQuotaToastPatch(config, patch, sourcePath, settingSources
960
1004
  applySettingSource(settingSources, "telemetry.enabled", sourcePath);
961
1005
  }
962
1006
  if (patch.dashboard) {
1007
+ if (hasOwnKey(patch.dashboard, "enabled")) {
1008
+ config.dashboard.enabled = patch.dashboard.enabled;
1009
+ applySettingSource(settingSources, "dashboard.enabled", sourcePath);
1010
+ }
963
1011
  if (hasOwnKey(patch.dashboard, "port")) {
964
1012
  config.dashboard.port = patch.dashboard.port;
965
1013
  applySettingSource(settingSources, "dashboard.port", sourcePath);
@@ -463,6 +463,17 @@ function redactGitHubErrorText(text, secrets) {
463
463
  }
464
464
  return sanitized;
465
465
  }
466
+ class CopilotRequestError extends Error {
467
+ failureCategory;
468
+ constructor(message, failureCategory) {
469
+ super(message);
470
+ this.failureCategory = failureCategory;
471
+ this.name = "CopilotRequestError";
472
+ }
473
+ }
474
+ function requestFailureCategory(error) {
475
+ return error instanceof CopilotRequestError ? error.failureCategory : "provider_api";
476
+ }
466
477
  async function readGitHubRestErrorMessage(response, secrets) {
467
478
  const text = await response.text();
468
479
  try {
@@ -480,23 +491,36 @@ async function readGitHubRestErrorMessage(response, secrets) {
480
491
  }
481
492
  return sanitizeDisplaySnippet(redactGitHubErrorText(text, secrets), 160);
482
493
  }
494
+ /**
495
+ * Keeps the HTTP status available for classification when the error body
496
+ * cannot be read at all.
497
+ */
498
+ async function readGitHubRestErrorMessageForClassification(response, secrets) {
499
+ try {
500
+ return await readGitHubRestErrorMessage(response, secrets);
501
+ }
502
+ catch {
503
+ return "response body could not be read";
504
+ }
505
+ }
483
506
  async function fetchGitHubRestJson(url, token, requestTimeoutMs) {
484
507
  return await fetchWithTimeout(url, {
485
508
  request: { headers: buildGitHubRestHeaders(token) },
486
509
  timeoutMs: requestTimeoutMs,
487
510
  consume: async (response) => {
488
511
  if (!response.ok) {
489
- const message = await readGitHubRestErrorMessage(response, [token]);
490
- const rateLimit = response.status === 403 && response.headers.get("x-ratelimit-remaining") === "0"
491
- ? " (GitHub API rate limit exhausted)"
492
- : "";
493
- throw new Error(`GitHub API error ${response.status}: ${message}${rateLimit}`);
512
+ const message = await readGitHubRestErrorMessageForClassification(response, [token]);
513
+ const rateLimited = response.status === 403 && response.headers.get("x-ratelimit-remaining") === "0";
514
+ const rateLimit = rateLimited ? " (GitHub API rate limit exhausted)" : "";
515
+ throw new CopilotRequestError(`GitHub API error ${response.status}: ${message}${rateLimit}`, response.status === 401 || (response.status === 403 && !rateLimited)
516
+ ? "credentials"
517
+ : "provider_api");
494
518
  }
495
519
  try {
496
520
  return (await response.json());
497
521
  }
498
522
  catch {
499
- throw new Error("GitHub API returned malformed JSON");
523
+ throw new CopilotRequestError("GitHub API returned malformed JSON", "provider_api");
500
524
  }
501
525
  },
502
526
  });
@@ -837,8 +861,12 @@ function toLegacyResult(response, config) {
837
861
  resetTimeIso: getApproxNextResetIso(),
838
862
  };
839
863
  }
840
- function toQuotaError(message) {
841
- return { success: false, error: message };
864
+ function toQuotaError(message, failureCategory) {
865
+ return {
866
+ success: false,
867
+ error: message,
868
+ ...(failureCategory !== undefined ? { failureCategory } : {}),
869
+ };
842
870
  }
843
871
  function buildCopilotInternalHeaders(token) {
844
872
  return {
@@ -961,18 +989,18 @@ async function fetchCopilotInternalUser(params) {
961
989
  timeoutMs: params.requestTimeoutMs,
962
990
  consume: async (response) => {
963
991
  if (!response.ok) {
964
- const message = await readGitHubRestErrorMessage(response, [params.token]);
965
- throw new Error(`GitHub Copilot API error ${response.status}: ${message}`);
992
+ const message = await readGitHubRestErrorMessageForClassification(response, [params.token]);
993
+ throw new CopilotRequestError(`GitHub Copilot API error ${response.status}: ${message}`, response.status === 401 || response.status === 403 ? "credentials" : "provider_api");
966
994
  }
967
995
  let parsed;
968
996
  try {
969
997
  parsed = (await response.json());
970
998
  }
971
999
  catch {
972
- throw new Error("GitHub Copilot API returned malformed JSON");
1000
+ throw new CopilotRequestError("GitHub Copilot API returned malformed JSON", "provider_api");
973
1001
  }
974
1002
  if (!parsed || typeof parsed !== "object") {
975
- throw new Error("GitHub Copilot API returned malformed JSON");
1003
+ throw new CopilotRequestError("GitHub Copilot API returned malformed JSON", "provider_api");
976
1004
  }
977
1005
  return parseCopilotInternalUser(parsed);
978
1006
  },
@@ -1009,7 +1037,7 @@ export async function queryCopilotQuota(options = {}) {
1009
1037
  });
1010
1038
  }
1011
1039
  catch (error) {
1012
- return toQuotaError(error instanceof Error ? error.message : String(error));
1040
+ return toQuotaError(error instanceof Error ? error.message : String(error), requestFailureCategory(error));
1013
1041
  }
1014
1042
  }
1015
1043
  const resolved = resolvePatBillingTarget(pat.config);
@@ -1040,7 +1068,7 @@ export async function queryCopilotQuota(options = {}) {
1040
1068
  });
1041
1069
  }
1042
1070
  catch (error) {
1043
- return toQuotaError(error instanceof Error ? error.message : String(error));
1071
+ return toQuotaError(error instanceof Error ? error.message : String(error), requestFailureCategory(error));
1044
1072
  }
1045
1073
  }
1046
1074
  export async function resolveCopilotAuthIdentity() {
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Effective localhost web dashboard switch.
3
+ *
4
+ * The Native GUI is the primary surface from OpenCode 2.2.0, so the compatibility
5
+ * web transport follows the host version when the canonical key is absent:
6
+ * hosts below 2.2.0 keep it on (the only GUI they have), and 2.2.0+ keeps it off.
7
+ * An explicit `dashboard.enabled` value always wins. Missing or unparseable host
8
+ * versions, a malformed canonical file, and an invalid `dashboard.enabled` value
9
+ * all fail closed. The listener itself stays loopback-only at `dashboard.port`.
10
+ */
11
+ import type { LoadConfigMeta } from "./config.js";
12
+ import { type OpenCodeVersion } from "./opencode-version.js";
13
+ export interface DashboardWebPolicyInput {
14
+ /** Canonical `dashboard.enabled` when the key is present and valid. */
15
+ explicitEnabled?: boolean;
16
+ /** Running OpenCode host version; missing or unparseable fails closed. */
17
+ hostVersion?: string | OpenCodeVersion;
18
+ /** A malformed canonical file or an invalid `dashboard.enabled` fails closed. */
19
+ invalidConfig?: boolean;
20
+ }
21
+ /** Explicit config wins; otherwise only a parseable pre-2.2.0 host defaults on. */
22
+ export declare function resolveDashboardWebEnabled(input: DashboardWebPolicyInput): boolean;
23
+ /**
24
+ * The canonical value when the loader actually applied it. The setting-source
25
+ * map is the explicit-presence proof: an absent or invalid value records no
26
+ * source, which keeps the version default in charge.
27
+ */
28
+ export declare function getDashboardEnabledSetting(config: {
29
+ dashboard?: {
30
+ enabled?: unknown;
31
+ };
32
+ } | null | undefined, meta: Pick<LoadConfigMeta, "settingSources">): boolean | undefined;
33
+ /** A malformed root or an invalid `dashboard.enabled` value must not enable web. */
34
+ export declare function hasInvalidDashboardWebConfig(meta: Pick<LoadConfigMeta, "configIssues">): boolean;
35
+ //# sourceMappingURL=dashboard-web-policy.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { isPreNativeGuiVersion } from "./opencode-version.js";
2
+ /** Explicit config wins; otherwise only a parseable pre-2.2.0 host defaults on. */
3
+ export function resolveDashboardWebEnabled(input) {
4
+ if (input.invalidConfig)
5
+ return false;
6
+ if (input.explicitEnabled !== undefined)
7
+ return input.explicitEnabled;
8
+ return isPreNativeGuiVersion(input.hostVersion);
9
+ }
10
+ /**
11
+ * The canonical value when the loader actually applied it. The setting-source
12
+ * map is the explicit-presence proof: an absent or invalid value records no
13
+ * source, which keeps the version default in charge.
14
+ */
15
+ export function getDashboardEnabledSetting(config, meta) {
16
+ if (meta.settingSources["dashboard.enabled"] === undefined)
17
+ return undefined;
18
+ return config?.dashboard?.enabled === true;
19
+ }
20
+ /** A malformed root or an invalid `dashboard.enabled` value must not enable web. */
21
+ export function hasInvalidDashboardWebConfig(meta) {
22
+ return meta.configIssues.some((issue) => issue.key === "$root" || issue.key === "dashboard.enabled");
23
+ }
24
+ //# sourceMappingURL=dashboard-web-policy.js.map
@@ -4,6 +4,7 @@
4
4
  * Queries: GET https://api.deepseek.com/user/balance
5
5
  * Auth: Bearer token in Authorization header.
6
6
  */
7
+ import { providerFailureCategoryForHttpStatus, } from "../contracts/provider-failure.js";
7
8
  import { isCanonicalAccountingDecimal } from "./accounting-format.js";
8
9
  import { resolveDeepSeekApiKey } from "./deepseek-auth.js";
9
10
  import { sanitizeDisplaySnippet, sanitizeDisplayText } from "./display-sanitize.js";
@@ -62,6 +63,7 @@ function parseDeepSeekBalance(payload) {
62
63
  return { isAvailable, balanceInfos, parseIssues };
63
64
  }
64
65
  async function fetchDeepSeekBalance(apiKey, requestTimeoutMs) {
66
+ let responseStatus;
65
67
  try {
66
68
  return await fetchWithTimeout(DEEPSEEK_BALANCE_URL, {
67
69
  request: {
@@ -73,11 +75,13 @@ async function fetchDeepSeekBalance(apiKey, requestTimeoutMs) {
73
75
  },
74
76
  timeoutMs: requestTimeoutMs,
75
77
  consume: async (response) => {
78
+ responseStatus = response.status;
76
79
  if (!response.ok) {
77
80
  const text = await response.text();
78
81
  return {
79
82
  success: false,
80
83
  message: `DeepSeek API error ${response.status}: ${sanitizeDisplaySnippet(text, 120)}`,
84
+ failureCategory: providerFailureCategoryForHttpStatus(response.status),
81
85
  };
82
86
  }
83
87
  return {
@@ -91,6 +95,9 @@ async function fetchDeepSeekBalance(apiKey, requestTimeoutMs) {
91
95
  return {
92
96
  success: false,
93
97
  message: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
98
+ failureCategory: responseStatus === undefined
99
+ ? "provider_api"
100
+ : providerFailureCategoryForHttpStatus(responseStatus),
94
101
  };
95
102
  }
96
103
  }
@@ -105,7 +112,11 @@ export async function queryDeepSeekBalance(options = {}) {
105
112
  return null;
106
113
  const result = await fetchDeepSeekBalance(resolved.key, options.requestTimeoutMs);
107
114
  if (!result.success) {
108
- return { success: false, error: result.message };
115
+ return {
116
+ success: false,
117
+ error: result.message,
118
+ failureCategory: result.failureCategory,
119
+ };
109
120
  }
110
121
  return {
111
122
  success: true,
@@ -104,7 +104,9 @@ export function sanitizeQuotaToastError(error) {
104
104
  label: sanitizeDisplayText(error.label),
105
105
  message: sanitizeDisplayText(error.message),
106
106
  ...(error.retryable === true ? { retryable: true } : {}),
107
+ ...(error.failureCategory !== undefined ? { failureCategory: error.failureCategory } : {}),
107
108
  ...(error.kind ? { kind: error.kind } : {}),
109
+ ...(error.sourceId !== undefined ? { sourceId: error.sourceId } : {}),
108
110
  };
109
111
  }
110
112
  export function sanitizeQuotaProviderResult(result) {
@@ -1,4 +1,5 @@
1
1
  import type { BankedResetAvailability } from "../contracts/openai-quota.js";
2
+ import type { ProviderFailureCategory } from "../contracts/provider-failure.js";
2
3
  import type { QuotaProviderDefinition } from "./quota-providers.js";
3
4
  import type { QuotaTelemetryToken } from "./quota-telemetry.js";
4
5
  import type { ResolvedAuthIdentity } from "./resolved-auth-identity.js";
@@ -171,6 +172,8 @@ export interface QuotaToastError {
171
172
  message: string;
172
173
  /** Whether a later refresh may succeed without user action. */
173
174
  retryable?: boolean;
175
+ /** Source-assigned safe category; absence means unknown and consumers fail closed. */
176
+ failureCategory?: ProviderFailureCategory;
174
177
  /** Intentional diagnostics remain verbose but do not count as compact-status issues. */
175
178
  kind?: "intentional-filter";
176
179
  /**
@@ -83,7 +83,7 @@ export interface FormatResetCountdownOptions {
83
83
  * Returns a precise-to-minute value like "2d 5h 14m", "3h 45m", or "14m".
84
84
  * When reset time is in the past or invalid, returns "reset".
85
85
  */
86
- export declare function formatResetCountdown(iso?: string, opts?: FormatResetCountdownOptions): string;
86
+ export declare function formatResetCountdown(iso?: string, opts?: FormatResetCountdownOptions, nowMs?: number): string;
87
87
  export declare const MAX_RESET_TIME_DECIMALS = 4;
88
88
  export declare function isResetTimeDecimals(value: unknown): value is number;
89
89
  //# sourceMappingURL=format-utils.d.ts.map
@@ -158,11 +158,11 @@ const MS_PER_HOUR = 3_600_000;
158
158
  * Returns a precise-to-minute value like "2d 5h 14m", "3h 45m", or "14m".
159
159
  * When reset time is in the past or invalid, returns "reset".
160
160
  */
161
- export function formatResetCountdown(iso, opts) {
161
+ export function formatResetCountdown(iso, opts, nowMs) {
162
162
  if (!iso)
163
163
  return opts?.missing ?? "";
164
164
  const resetDate = new Date(iso);
165
- const now = new Date();
165
+ const now = nowMs === undefined ? new Date() : new Date(nowMs);
166
166
  const diffMs = resetDate.getTime() - now.getTime();
167
167
  if (!Number.isFinite(diffMs) || diffMs <= 0)
168
168
  return "reset";
@@ -1,3 +1,4 @@
1
+ import { providerFailureCategoryForHttpStatus } from "../contracts/provider-failure.js";
1
2
  import { sanitizeDisplaySnippet, sanitizeDisplayText } from "./display-sanitize.js";
2
3
  import { clampPercent } from "./format-utils.js";
3
4
  import { fetchWithTimeout } from "./http.js";
@@ -7,8 +8,10 @@ export async function queryGlmCodingPlanQuota(descriptor, options = {}) {
7
8
  : await descriptor.resolveAuth();
8
9
  if (auth.state === "none")
9
10
  return null;
10
- if (auth.state === "invalid")
11
- return { success: false, error: auth.error };
11
+ if (auth.state === "invalid") {
12
+ return { success: false, error: auth.error, failureCategory: "credentials" };
13
+ }
14
+ let responseStatus;
12
15
  try {
13
16
  return await fetchWithTimeout(descriptor.endpoint, {
14
17
  request: {
@@ -20,11 +23,13 @@ export async function queryGlmCodingPlanQuota(descriptor, options = {}) {
20
23
  },
21
24
  timeoutMs: options.requestTimeoutMs,
22
25
  consume: async (response) => {
26
+ responseStatus = response.status;
23
27
  if (!response.ok) {
24
28
  const body = sanitizeDisplaySnippet(await response.text(), 120);
25
29
  return {
26
30
  success: false,
27
31
  error: `${descriptor.httpErrorPrefix} ${response.status}: ${body}`,
32
+ failureCategory: providerFailureCategoryForHttpStatus(response.status),
28
33
  };
29
34
  }
30
35
  const body = (await response.json());
@@ -37,11 +42,13 @@ export async function queryGlmCodingPlanQuota(descriptor, options = {}) {
37
42
  (typeof body.code === "number"
38
43
  ? `${descriptor.apiErrorPrefix} ${body.code}`
39
44
  : descriptor.apiErrorPrefix),
45
+ failureCategory: "provider_api",
40
46
  };
41
47
  }
42
48
  const limits = descriptor.envelope === "zai" ? (body.data?.limits ?? body.limits) : body.data?.limits;
43
- if (!Array.isArray(limits))
44
- return { success: false, error: "Invalid quota data" };
49
+ if (!Array.isArray(limits)) {
50
+ return { success: false, error: "Invalid quota data", failureCategory: "provider_api" };
51
+ }
45
52
  const windows = {};
46
53
  for (const limit of limits) {
47
54
  const resetDate = limit.nextResetTime ? new Date(Math.round(limit.nextResetTime)) : null;
@@ -75,6 +82,9 @@ export async function queryGlmCodingPlanQuota(descriptor, options = {}) {
75
82
  return {
76
83
  success: false,
77
84
  error: sanitizeDisplayText(error instanceof Error ? error.message : String(error)),
85
+ failureCategory: responseStatus === undefined
86
+ ? "provider_api"
87
+ : providerFailureCategoryForHttpStatus(responseStatus),
78
88
  };
79
89
  }
80
90
  }