opencode-quota-gui 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/README.md +34 -20
  2. package/dist/bin/opencode-quota-gui.js +0 -0
  3. package/dist/contracts/build-identity.js +1 -1
  4. package/dist/contracts/card-order.d.ts +2 -0
  5. package/dist/contracts/card-order.js +2 -2
  6. package/dist/contracts/card-visibility.d.ts +2 -1
  7. package/dist/contracts/card-visibility.js +2 -1
  8. package/dist/contracts/dashboard.d.ts +95 -6
  9. package/dist/contracts/dashboard.js +10 -0
  10. package/dist/contracts/dto-guards.d.ts +4 -0
  11. package/dist/contracts/dto-guards.js +31 -7
  12. package/dist/contracts/guards.js +3 -1
  13. package/dist/contracts/identity.d.ts +37 -5
  14. package/dist/contracts/identity.js +43 -0
  15. package/dist/contracts/openai-quota.d.ts +3 -0
  16. package/dist/contracts/openai-quota.js +3 -0
  17. package/dist/contracts/provider-auto-resume.d.ts +9 -0
  18. package/dist/contracts/provider-auto-resume.js +24 -0
  19. package/dist/contracts/provider-failure.d.ts +22 -0
  20. package/dist/contracts/provider-failure.js +25 -1
  21. package/dist/contracts/row-order.d.ts +13 -0
  22. package/dist/contracts/row-order.js +34 -0
  23. package/dist/contracts/row-visibility.d.ts +53 -0
  24. package/dist/contracts/row-visibility.js +130 -0
  25. package/dist/data/modelsdev-pricing.min.json +1 -1
  26. package/dist/data/modelsdev-temporal.min.json +60 -634
  27. package/dist/gui/aggregation.d.ts +29 -1
  28. package/dist/gui/aggregation.js +157 -4
  29. package/dist/gui/analytics-bridge.d.ts +8 -9
  30. package/dist/gui/analytics-bridge.js +197 -54
  31. package/dist/gui/analytics-engine.d.ts +7 -15
  32. package/dist/gui/analytics-engine.js +246 -106
  33. package/dist/gui/analytics-model.d.ts +7 -0
  34. package/dist/gui/analytics-model.js +75 -9
  35. package/dist/gui/analytics-pricing-upkeep.d.ts +21 -0
  36. package/dist/gui/analytics-pricing-upkeep.js +23 -0
  37. package/dist/gui/analytics-protocol.d.ts +17 -7
  38. package/dist/gui/analytics-protocol.js +1 -0
  39. package/dist/gui/analytics-service.d.ts +10 -0
  40. package/dist/gui/analytics-service.js +30 -9
  41. package/dist/gui/analytics-state.d.ts +30 -5
  42. package/dist/gui/analytics-state.js +46 -7
  43. package/dist/gui/analytics-worker-runtime.d.ts +5 -0
  44. package/dist/gui/analytics-worker-runtime.js +9 -1
  45. package/dist/gui/analytics-worker.js +11 -0
  46. package/dist/gui/config.d.ts +3 -3
  47. package/dist/gui/config.js +77 -7
  48. package/dist/gui/identity.d.ts +6 -20
  49. package/dist/gui/identity.js +6 -54
  50. package/dist/gui/lifecycle.d.ts +5 -3
  51. package/dist/gui/lifecycle.js +3 -3
  52. package/dist/gui/primary-quota-windows.js +67 -44
  53. package/dist/gui/provider-cards.d.ts +20 -8
  54. package/dist/gui/provider-cards.js +42 -55
  55. package/dist/gui/quota-notification-detector.d.ts +29 -6
  56. package/dist/gui/quota-notification-detector.js +136 -47
  57. package/dist/gui/quota-notification-observer.d.ts +3 -4
  58. package/dist/gui/quota-notification-observer.js +73 -20
  59. package/dist/gui/quota-observation.d.ts +4 -0
  60. package/dist/gui/quota-observation.js +18 -0
  61. package/dist/gui/rpc.d.ts +2 -0
  62. package/dist/gui/rpc.js +14 -3
  63. package/dist/gui/server.js +17 -3
  64. package/dist/gui/snapshot-service.d.ts +3 -15
  65. package/dist/gui/snapshot-service.js +281 -23
  66. package/dist/gui/sources.js +179 -64
  67. package/dist/gui/temporal-status.d.ts +3 -2
  68. package/dist/gui/temporal-status.js +10 -6
  69. package/dist/gui-experimental.cjs +230 -225
  70. package/dist/lib/accounting-format.d.ts +8 -0
  71. package/dist/lib/accounting-format.js +20 -2
  72. package/dist/lib/alibaba-coding-plan-cli.d.ts +79 -0
  73. package/dist/lib/alibaba-coding-plan-cli.js +539 -0
  74. package/dist/lib/anthropic-api-auth.d.ts +7 -0
  75. package/dist/lib/anthropic-api-auth.js +27 -0
  76. package/dist/lib/anthropic-api-rate-limits.d.ts +47 -0
  77. package/dist/lib/anthropic-api-rate-limits.js +92 -0
  78. package/dist/lib/anthropic-auth.d.ts +2 -3
  79. package/dist/lib/anthropic-auth.js +2 -3
  80. package/dist/lib/anthropic-oauth-throttle.d.ts +76 -0
  81. package/dist/lib/anthropic-oauth-throttle.js +379 -0
  82. package/dist/lib/anthropic.d.ts +68 -14
  83. package/dist/lib/anthropic.js +1016 -363
  84. package/dist/lib/api-key-retry-after.d.ts +7 -0
  85. package/dist/lib/api-key-retry-after.js +62 -0
  86. package/dist/lib/atomic-json.d.ts +2 -0
  87. package/dist/lib/atomic-json.js +1 -0
  88. package/dist/lib/cache-observer-ingestion.d.ts +90 -0
  89. package/dist/lib/cache-observer-ingestion.js +1008 -0
  90. package/dist/lib/cache-observer.d.ts +141 -0
  91. package/dist/lib/cache-observer.js +323 -0
  92. package/dist/lib/canonical-config-lock.d.ts +9 -0
  93. package/dist/lib/canonical-config-lock.js +36 -0
  94. package/dist/lib/chutes.js +62 -51
  95. package/dist/lib/claude-agent-transcript-ttl.d.ts +48 -0
  96. package/dist/lib/claude-agent-transcript-ttl.js +154 -0
  97. package/dist/lib/claude-agent-ttl-tracker.d.ts +21 -0
  98. package/dist/lib/claude-agent-ttl-tracker.js +152 -0
  99. package/dist/lib/cli-show.d.ts +5 -0
  100. package/dist/lib/cli-show.js +21 -8
  101. package/dist/lib/cli-status.js +3 -6
  102. package/dist/lib/config-write-target.d.ts +1 -1
  103. package/dist/lib/config-write-target.js +5 -2
  104. package/dist/lib/config.d.ts +2 -1
  105. package/dist/lib/config.js +257 -4
  106. package/dist/lib/copilot.js +171 -86
  107. package/dist/lib/dashboard-visibility.d.ts +5 -0
  108. package/dist/lib/dashboard-visibility.js +11 -10
  109. package/dist/lib/dashboard-web-policy.d.ts +4 -4
  110. package/dist/lib/dashboard-web-policy.js +2 -2
  111. package/dist/lib/deepseek.js +25 -13
  112. package/dist/lib/display-sanitize.js +2 -0
  113. package/dist/lib/entries.d.ts +33 -1
  114. package/dist/lib/entries.js +6 -0
  115. package/dist/lib/glm-coding-plan.js +98 -74
  116. package/dist/lib/google-agy.js +90 -12
  117. package/dist/lib/google-gemini-cli.js +84 -11
  118. package/dist/lib/grouped-entry-normalization.js +1 -1
  119. package/dist/lib/http.d.ts +4 -0
  120. package/dist/lib/http.js +16 -2
  121. package/dist/lib/init-installer.js +5 -3
  122. package/dist/lib/kilo.js +37 -18
  123. package/dist/lib/kimi.js +35 -18
  124. package/dist/lib/maintainer-announcements.js +2 -2
  125. package/dist/lib/mimo.d.ts +2 -0
  126. package/dist/lib/mimo.js +36 -0
  127. package/dist/lib/modelsdev-pricing.d.ts +74 -2
  128. package/dist/lib/modelsdev-pricing.js +457 -63
  129. package/dist/lib/modelsdev-temporal.d.ts +6 -0
  130. package/dist/lib/modelsdev-temporal.js +16 -2
  131. package/dist/lib/nanogpt.d.ts +1 -0
  132. package/dist/lib/nanogpt.js +26 -3
  133. package/dist/lib/ollama-cloud.d.ts +1 -1
  134. package/dist/lib/ollama-cloud.js +48 -35
  135. package/dist/lib/openai.js +84 -38
  136. package/dist/lib/opencode-auth-sqlite.d.ts +2 -2
  137. package/dist/lib/opencode-auth-sqlite.js +2 -2
  138. package/dist/lib/opencode-config-editor.d.ts +1 -0
  139. package/dist/lib/opencode-config-editor.js +6 -1
  140. package/dist/lib/opencode-config-providers.js +2 -2
  141. package/dist/lib/opencode-go.js +29 -2
  142. package/dist/lib/opencode-storage.d.ts +20 -0
  143. package/dist/lib/opencode-storage.js +89 -2
  144. package/dist/lib/opencode-version-core.d.ts +30 -0
  145. package/dist/lib/opencode-version-core.js +59 -0
  146. package/dist/lib/opencode-version.d.ts +2 -22
  147. package/dist/lib/opencode-version.js +4 -48
  148. package/dist/lib/opencode-warming-refresh.d.ts +19 -0
  149. package/dist/lib/opencode-warming-refresh.js +95 -0
  150. package/dist/lib/opencode-zen.d.ts +3 -0
  151. package/dist/lib/opencode-zen.js +71 -5
  152. package/dist/lib/provider-add.js +5 -2
  153. package/dist/lib/provider-metadata.d.ts +11 -3
  154. package/dist/lib/provider-metadata.js +20 -2
  155. package/dist/lib/provider-registration.d.ts +358 -9
  156. package/dist/lib/provider-registration.js +423 -30
  157. package/dist/lib/quota-auto-resume.d.ts +74 -0
  158. package/dist/lib/quota-auto-resume.js +539 -0
  159. package/dist/lib/quota-command-format.js +23 -10
  160. package/dist/lib/quota-exhaustion-projection.d.ts +11 -0
  161. package/dist/lib/quota-exhaustion-projection.js +25 -0
  162. package/dist/lib/quota-identity.d.ts +64 -0
  163. package/dist/lib/quota-identity.js +111 -0
  164. package/dist/lib/quota-providers-remote.d.ts +2 -1
  165. package/dist/lib/quota-providers-remote.js +59 -3
  166. package/dist/lib/quota-providers.d.ts +1 -1
  167. package/dist/lib/quota-providers.js +14 -37
  168. package/dist/lib/quota-render-data.d.ts +6 -0
  169. package/dist/lib/quota-render-data.js +45 -19
  170. package/dist/lib/quota-reset-notifications.js +11 -155
  171. package/dist/lib/quota-retry-wait.d.ts +106 -5
  172. package/dist/lib/quota-retry-wait.js +301 -34
  173. package/dist/lib/quota-runtime-context.js +1 -0
  174. package/dist/lib/quota-state-codec.d.ts +2 -0
  175. package/dist/lib/quota-state-codec.js +31 -2
  176. package/dist/lib/quota-state.d.ts +8 -2
  177. package/dist/lib/quota-state.js +253 -47
  178. package/dist/lib/quota-stats.d.ts +26 -0
  179. package/dist/lib/quota-stats.js +40 -1
  180. package/dist/lib/quota-status.js +3 -51
  181. package/dist/lib/quota-surface-data.js +18 -3
  182. package/dist/lib/quota-telemetry.js +2 -2
  183. package/dist/lib/resolved-auth-identity.d.ts +19 -0
  184. package/dist/lib/resolved-auth-identity.js +44 -0
  185. package/dist/lib/scoped-update.d.ts +1 -1
  186. package/dist/lib/state-file-lock.d.ts +26 -0
  187. package/dist/lib/state-file-lock.js +205 -0
  188. package/dist/lib/synthetic.js +65 -54
  189. package/dist/lib/toast-format-grouped.js +7 -4
  190. package/dist/lib/tui-compact-format.js +29 -16
  191. package/dist/lib/types.d.ts +51 -1
  192. package/dist/lib/types.js +17 -1
  193. package/dist/lib/xai.js +48 -22
  194. package/dist/plugin.js +328 -14
  195. package/dist/provider-logos/NOTICE.md +1 -1
  196. package/dist/provider-logos/OPENCODE-NOTICE.md +4 -3
  197. package/dist/providers/alibaba-coding-plan.js +125 -104
  198. package/dist/providers/alibaba-token-plan.js +9 -5
  199. package/dist/providers/anthropic.d.ts +16 -3
  200. package/dist/providers/anthropic.js +172 -220
  201. package/dist/providers/cache-policies.d.ts +11 -4
  202. package/dist/providers/cache-policies.js +19 -13
  203. package/dist/providers/chutes.js +2 -0
  204. package/dist/providers/claude-agent.d.ts +19 -0
  205. package/dist/providers/claude-agent.js +215 -0
  206. package/dist/providers/copilot.js +7 -4
  207. package/dist/providers/glm-coding-plan-provider.d.ts +1 -0
  208. package/dist/providers/glm-coding-plan-provider.js +30 -23
  209. package/dist/providers/google-account-format.js +1 -0
  210. package/dist/providers/google-agy.d.ts +6 -5
  211. package/dist/providers/google-agy.js +43 -15
  212. package/dist/providers/google-gemini-cli.js +1 -0
  213. package/dist/providers/kilo.js +1 -0
  214. package/dist/providers/kimi-code.js +2 -0
  215. package/dist/providers/mimo.js +1 -0
  216. package/dist/providers/nanogpt.js +1 -0
  217. package/dist/providers/ollama-cloud.js +10 -0
  218. package/dist/providers/openai.js +24 -23
  219. package/dist/providers/opencode-go.js +10 -6
  220. package/dist/providers/opencode-zen.js +3 -1
  221. package/dist/providers/openrouter.js +1 -0
  222. package/dist/providers/quota-providers.js +16 -5
  223. package/dist/providers/registry.js +2 -0
  224. package/dist/providers/result-helpers.d.ts +6 -2
  225. package/dist/providers/result-helpers.js +7 -1
  226. package/dist/providers/synthetic.js +4 -0
  227. package/dist/providers/xai.js +9 -8
  228. package/dist/rpc.d.ts +129 -8
  229. package/dist/rpc.js +219 -14
  230. package/dist/ui/assets/{index-cDd9jUVY.css → index-6_g1FHs-.css} +1 -1
  231. package/dist/ui/assets/index-sZnGUuML.js +10 -0
  232. package/dist/ui/assets/{popover-BGkgv9s0.js → popover-C4ZLYe9E.js} +1 -1
  233. package/dist/ui/assets/providers/claude-agent.svg +3 -0
  234. package/dist/ui/index.html +2 -2
  235. package/package.json +45 -46
  236. package/dist/lib/alibaba-coding-plan-local-quota.d.ts +0 -47
  237. package/dist/lib/alibaba-coding-plan-local-quota.js +0 -146
  238. package/dist/ui/assets/index-DLHeXYff.js +0 -9
@@ -7,6 +7,11 @@ import { type AnalyticsEngine } from "./analytics-engine.js";
7
7
  import type { AnalyticsInitOptions, AnalyticsWorkerCommand, AnalyticsWorkerResult } from "./analytics-protocol.js";
8
8
  export interface AnalyticsWorkerRuntime {
9
9
  handle(command: AnalyticsWorkerCommand): Promise<AnalyticsWorkerResult>;
10
+ /** Routes the live model could not price, for the worker's pricing upkeep. */
11
+ unpricedRoutes(): Array<{
12
+ providerID?: string;
13
+ modelID?: string;
14
+ }>;
10
15
  close(): Promise<void>;
11
16
  }
12
17
  export declare function createAnalyticsWorkerRuntime(options?: {
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { isAnalyticsGroupQuery } from "../contracts/analytics-entity.js";
7
7
  import { isRangeKey } from "../contracts/ranges.js";
8
+ import { setPricingSnapshotAutoRefresh, setPricingSnapshotSelection, } from "../lib/modelsdev-pricing.js";
8
9
  import { createAnalyticsEngine } from "./analytics-engine.js";
9
10
  import { AnalyticsReadError } from "./analytics-protocol.js";
10
11
  const ERROR_CODES = new Set([
@@ -38,6 +39,10 @@ export function createAnalyticsWorkerRuntime(options = {}) {
38
39
  let closed = false;
39
40
  async function handle(command) {
40
41
  if (command.kind === "init") {
42
+ if (command.options.pricingSnapshot) {
43
+ setPricingSnapshotAutoRefresh(command.options.pricingSnapshot.autoRefresh);
44
+ setPricingSnapshotSelection(command.options.pricingSnapshot.source);
45
+ }
41
46
  if (!engine)
42
47
  engine = createEngine(command.options);
43
48
  return undefined;
@@ -54,7 +59,7 @@ export function createAnalyticsWorkerRuntime(options = {}) {
54
59
  if (command.kind === "home") {
55
60
  if (!isRangeKey(command.range))
56
61
  throw new AnalyticsReadError("bad-request");
57
- return await engine.home(command.range);
62
+ return await engine.home(command.range, command.exact);
58
63
  }
59
64
  if (command.kind === "project") {
60
65
  if (!isRangeKey(command.range) || !command.projectId) {
@@ -93,6 +98,9 @@ export function createAnalyticsWorkerRuntime(options = {}) {
93
98
  throw new AnalyticsReadError(errorCodeOf(error));
94
99
  }
95
100
  },
101
+ unpricedRoutes() {
102
+ return engine?.unpricedRoutes() ?? [];
103
+ },
96
104
  async close() {
97
105
  closed = true;
98
106
  if (engine)
@@ -5,6 +5,7 @@
5
5
  * It owns all storage reads, the compact index, persistence, and aggregation;
6
6
  * only protocol frames and finished DTOs cross back to the host.
7
7
  */
8
+ import { createAnalyticsPricingUpkeep } from "./analytics-pricing-upkeep.js";
8
9
  import { AnalyticsReadError } from "./analytics-protocol.js";
9
10
  import { createAnalyticsWorkerRuntime } from "./analytics-worker-runtime.js";
10
11
  function isRequest(value) {
@@ -37,10 +38,20 @@ async function main() {
37
38
  port.postMessage({ type: "analytics-generation", generation });
38
39
  },
39
40
  });
41
+ const pricingUpkeep = createAnalyticsPricingUpkeep({
42
+ postMessage: (message) => port.postMessage(message),
43
+ routes: () => runtime.unpricedRoutes(),
44
+ });
40
45
  const respond = (request) => {
41
46
  void (async () => {
42
47
  try {
43
48
  const result = await runtime.handle(request.command);
49
+ const upkeep = request.command.kind !== "init" && request.command.kind !== "close"
50
+ ? pricingUpkeep
51
+ : null;
52
+ // Advertise upkeep before the reply frame: the refresh itself starts
53
+ // after it, so a slow models.dev response never delays the read path.
54
+ upkeep?.begin();
44
55
  port.postMessage({ id: request.id, ok: true, result });
45
56
  }
46
57
  catch (error) {
@@ -10,17 +10,17 @@
10
10
  * write helpers.
11
11
  */
12
12
  import type { GuiSettingsStore } from "../contracts/dashboard.js";
13
- import type { OpenCodeVersion } from "../lib/opencode-version.js";
13
+ import type { OpenCodeVersion } from "../lib/opencode-version-core.js";
14
14
  import { type SettingsFileOpener } from "./settings-file-opener.js";
15
15
  /** Writable GUI settings keys (spec §5.4 table order plus the web switch; port excluded). */
16
- export declare const GUI_SETTINGS_WRITABLE_KEYS: readonly ["formatStyle", "percentDisplayMode", "percentLabelStyle", "quotaProjection", "resetTimeDecimals", "resetTimeSpaced", "waitForQuotaReset", "enabledProviders", "minIntervalMs", "requestTimeoutMs", "accountingDetail", "lowQuotaThresholdRemainingPercent", "duplicateCooldownMinutes", "opencodeGoWindows", "opencodeMonthlyLimit", "dashboard.hiddenCards", "dashboard.hiddenRows", "dashboard.providerOrder", "dashboard.cardOrder", "dashboard.temporalProviderOverrides", "dashboard.enabled"];
16
+ export declare const GUI_SETTINGS_WRITABLE_KEYS: readonly ["formatStyle", "percentDisplayMode", "percentLabelStyle", "quotaProjection", "resetTimeDecimals", "resetTimeSpaced", "waitForQuotaReset", "autoResumeOnQuotaRecovery", "enabledProviders", "minIntervalMs", "claudeAgentPollIntervalMs", "requestTimeoutMs", "accountingDetail", "lowQuotaThresholdRemainingPercent", "duplicateCooldownMinutes", "nativeQuotaNotifications", "opencodeGoWindows", "opencodeMonthlyLimit", "dashboard.hiddenCards", "dashboard.hiddenRows", "dashboard.providerOrder", "dashboard.cardOrder", "dashboard.rowOrder", "dashboard.temporalProviderOverrides", "dashboard.enabled"];
17
17
  /**
18
18
  * Read-only GUI settings keys: the port needs a restart, and the hidden-card
19
19
  * semantics marker is server-managed after an automatic write stamp.
20
20
  */
21
21
  export declare const GUI_SETTINGS_READ_ONLY_KEYS: readonly ["dashboard.port", "dashboard.hiddenCardsVersion"];
22
22
  /** Every GUI-exposed settings key (spec §5.4), in table order. */
23
- export declare const GUI_SETTINGS_KEYS: readonly ["formatStyle", "percentDisplayMode", "percentLabelStyle", "quotaProjection", "resetTimeDecimals", "resetTimeSpaced", "waitForQuotaReset", "enabledProviders", "minIntervalMs", "requestTimeoutMs", "accountingDetail", "lowQuotaThresholdRemainingPercent", "duplicateCooldownMinutes", "opencodeGoWindows", "opencodeMonthlyLimit", "dashboard.hiddenCards", "dashboard.hiddenRows", "dashboard.providerOrder", "dashboard.cardOrder", "dashboard.temporalProviderOverrides", "dashboard.enabled", "dashboard.port", "dashboard.hiddenCardsVersion"];
23
+ export declare const GUI_SETTINGS_KEYS: readonly ["formatStyle", "percentDisplayMode", "percentLabelStyle", "quotaProjection", "resetTimeDecimals", "resetTimeSpaced", "waitForQuotaReset", "autoResumeOnQuotaRecovery", "enabledProviders", "minIntervalMs", "claudeAgentPollIntervalMs", "requestTimeoutMs", "accountingDetail", "lowQuotaThresholdRemainingPercent", "duplicateCooldownMinutes", "nativeQuotaNotifications", "opencodeGoWindows", "opencodeMonthlyLimit", "dashboard.hiddenCards", "dashboard.hiddenRows", "dashboard.providerOrder", "dashboard.cardOrder", "dashboard.rowOrder", "dashboard.temporalProviderOverrides", "dashboard.enabled", "dashboard.port", "dashboard.hiddenCardsVersion"];
24
24
  export type GuiSettingsKey = (typeof GUI_SETTINGS_KEYS)[number];
25
25
  export type GuiSettingsErrorCode = "config-read-error" | "config-changed" | "config-target-error" | "config-write-error" | "unknown-setting" | "invalid-setting";
26
26
  export interface GuiSettingsErrorDetails {
@@ -13,8 +13,11 @@ import { createHash } from "node:crypto";
13
13
  import { existsSync } from "node:fs";
14
14
  import { readFile } from "node:fs/promises";
15
15
  import { resolve } from "node:path";
16
+ import { isRecord, isText } from "../contracts/dto-guards.js";
16
17
  import { LEGACY_IMPORT_KEYS } from "../contracts/settings.js";
17
- import { buildConfigLayerCandidates, createLoadConfigMeta, GUI_CONFIG_RELATIVE_PATH, GUI_CONFIG_SIBLING_JSON_RELATIVE_PATH, getGuiConfigPath, getGuiConfigSiblingJsonPath, isPositiveNumber, isValidDuplicateCooldownMinutes, isValidLowQuotaThresholdRemainingPercent, isValidOpenCodeGoWindows, loadConfig, loadConfigLayered, normalizeEnabledProviders, } from "../lib/config.js";
18
+ import { ANTHROPIC_OAUTH_MIN_POLL_INTERVAL_MS } from "../lib/anthropic-oauth-throttle.js";
19
+ import { withCanonicalConfigLock } from "../lib/canonical-config-lock.js";
20
+ import { buildConfigLayerCandidates, createLoadConfigMeta, GUI_CONFIG_RELATIVE_PATH, GUI_CONFIG_SIBLING_JSON_RELATIVE_PATH, getGuiConfigPath, getGuiConfigSiblingJsonPath, isPositiveNumber, isValidDuplicateCooldownMinutes, isValidLowQuotaThresholdRemainingPercent, isValidNativeQuotaNotificationPolicy, isValidOpenCodeGoWindows, loadConfig, loadConfigLayered, normalizeEnabledProviders, } from "../lib/config.js";
18
21
  import { ConfigWriteTargetError, } from "../lib/config-write-target.js";
19
22
  import { DASHBOARD_HIDDEN_CARDS_VERSION } from "../lib/dashboard-visibility.js";
20
23
  import { getDashboardEnabledSetting, hasInvalidDashboardWebConfig, resolveDashboardWebEnabled, } from "../lib/dashboard-web-policy.js";
@@ -33,18 +36,22 @@ export const GUI_SETTINGS_WRITABLE_KEYS = [
33
36
  "resetTimeDecimals",
34
37
  "resetTimeSpaced",
35
38
  "waitForQuotaReset",
39
+ "autoResumeOnQuotaRecovery",
36
40
  "enabledProviders",
37
41
  "minIntervalMs",
42
+ "claudeAgentPollIntervalMs",
38
43
  "requestTimeoutMs",
39
44
  "accountingDetail",
40
45
  "lowQuotaThresholdRemainingPercent",
41
46
  "duplicateCooldownMinutes",
47
+ "nativeQuotaNotifications",
42
48
  "opencodeGoWindows",
43
49
  "opencodeMonthlyLimit",
44
50
  "dashboard.hiddenCards",
45
51
  "dashboard.hiddenRows",
46
52
  "dashboard.providerOrder",
47
53
  "dashboard.cardOrder",
54
+ "dashboard.rowOrder",
48
55
  "dashboard.temporalProviderOverrides",
49
56
  "dashboard.enabled",
50
57
  ];
@@ -110,9 +117,6 @@ export function getGuiDashboardEnabled(config) {
110
117
  export function resolveGuiDashboardUrl(port) {
111
118
  return `http://127.0.0.1:${getGuiDashboardPort({ dashboard: { port } })}`;
112
119
  }
113
- function isPlainObject(value) {
114
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
115
- }
116
120
  /** Strict finite-number check: `Number.isFinite` coerces nothing, so it implies a number primitive. */
117
121
  function isFiniteNumber(value) {
118
122
  return Number.isFinite(value);
@@ -164,7 +168,8 @@ export function createGuiSettingsStore(options) {
164
168
  let previewedRevision;
165
169
  /** One serialized queue for all writers: the loser's stale revision yields 409. */
166
170
  function withLock(run) {
167
- const next = lockTail.then(run, run);
171
+ const write = () => withCanonicalConfigLock(canonicalPath, run);
172
+ const next = lockTail.then(write, write);
168
173
  lockTail = next.then(() => undefined, () => undefined);
169
174
  return next;
170
175
  }
@@ -208,12 +213,16 @@ export function createGuiSettingsStore(options) {
208
213
  return config.resetTimeSpaced ?? null;
209
214
  case "waitForQuotaReset":
210
215
  return config.waitForQuotaReset;
216
+ case "autoResumeOnQuotaRecovery":
217
+ return config.autoResumeOnQuotaRecovery;
211
218
  case "enabledProviders":
212
219
  return Array.isArray(config.enabledProviders)
213
220
  ? [...config.enabledProviders]
214
221
  : config.enabledProviders;
215
222
  case "minIntervalMs":
216
223
  return config.minIntervalMs;
224
+ case "claudeAgentPollIntervalMs":
225
+ return config.claudeAgentPollIntervalMs;
217
226
  case "requestTimeoutMs":
218
227
  return config.requestTimeoutMs;
219
228
  case "accountingDetail":
@@ -222,6 +231,19 @@ export function createGuiSettingsStore(options) {
222
231
  return config.lowQuotaThresholdRemainingPercent;
223
232
  case "duplicateCooldownMinutes":
224
233
  return config.duplicateCooldownMinutes;
234
+ case "nativeQuotaNotifications":
235
+ return {
236
+ enabled: config.nativeQuotaNotifications.enabled,
237
+ modelChangeToastEnabled: config.nativeQuotaNotifications.modelChangeToastEnabled,
238
+ low: { ...config.nativeQuotaNotifications.low },
239
+ exhausted: { ...config.nativeQuotaNotifications.exhausted },
240
+ reset: {
241
+ ...config.nativeQuotaNotifications.reset,
242
+ windows: [...config.nativeQuotaNotifications.reset.windows],
243
+ },
244
+ providerError: { ...config.nativeQuotaNotifications.providerError },
245
+ duplicateCooldownMinutes: config.nativeQuotaNotifications.duplicateCooldownMinutes,
246
+ };
225
247
  case "opencodeGoWindows":
226
248
  return [...config.opencodeGoWindows];
227
249
  case "opencodeMonthlyLimit":
@@ -236,6 +258,8 @@ export function createGuiSettingsStore(options) {
236
258
  return [...config.dashboard.providerOrder];
237
259
  case "dashboard.cardOrder":
238
260
  return [...config.dashboard.cardOrder];
261
+ case "dashboard.rowOrder":
262
+ return Object.fromEntries(Object.entries(config.dashboard.rowOrder).map(([cardId, ids]) => [cardId, [...ids]]));
239
263
  case "dashboard.temporalProviderOverrides":
240
264
  return { ...config.dashboard.temporalProviderOverrides };
241
265
  case "dashboard.enabled":
@@ -376,6 +400,7 @@ export function createGuiSettingsStore(options) {
376
400
  return value;
377
401
  case "resetTimeSpaced":
378
402
  case "waitForQuotaReset":
403
+ case "autoResumeOnQuotaRecovery":
379
404
  if (value !== true && value !== false) {
380
405
  throw invalidSetting(key, "expected boolean");
381
406
  }
@@ -402,6 +427,11 @@ export function createGuiSettingsStore(options) {
402
427
  throw invalidSetting(key, "expected a finite number greater than 0");
403
428
  }
404
429
  return value;
430
+ case "claudeAgentPollIntervalMs":
431
+ if (!isPositiveNumber(value) || value < ANTHROPIC_OAUTH_MIN_POLL_INTERVAL_MS) {
432
+ throw invalidSetting(key, `expected a finite number of at least ${ANTHROPIC_OAUTH_MIN_POLL_INTERVAL_MS}`);
433
+ }
434
+ return value;
405
435
  case "accountingDetail":
406
436
  if (value !== "summary" && value !== "detailed") {
407
437
  throw invalidSetting(key, 'expected "summary" or "detailed"');
@@ -417,6 +447,19 @@ export function createGuiSettingsStore(options) {
417
447
  throw invalidSetting(key, "expected an integer of 0 or more");
418
448
  }
419
449
  return value;
450
+ case "nativeQuotaNotifications":
451
+ if (!isValidNativeQuotaNotificationPolicy(value)) {
452
+ throw invalidSetting(key, "expected a complete Native quota notification policy");
453
+ }
454
+ return {
455
+ enabled: value.enabled,
456
+ modelChangeToastEnabled: value.modelChangeToastEnabled,
457
+ low: { ...value.low },
458
+ exhausted: { ...value.exhausted },
459
+ reset: { ...value.reset, windows: [...new Set(value.reset.windows)] },
460
+ providerError: { ...value.providerError },
461
+ duplicateCooldownMinutes: value.duplicateCooldownMinutes,
462
+ };
420
463
  case "opencodeGoWindows":
421
464
  if (!isValidOpenCodeGoWindows(value)) {
422
465
  throw invalidSetting(key, 'expected a non-empty subset of "rolling", "weekly", "monthly"');
@@ -447,7 +490,7 @@ export function createGuiSettingsStore(options) {
447
490
  return [...new Set(ids)];
448
491
  }
449
492
  case "dashboard.temporalProviderOverrides": {
450
- if (!isPlainObject(value)) {
493
+ if (!isRecord(value)) {
451
494
  throw invalidSetting(key, "expected an object of provider ids mapped to booleans");
452
495
  }
453
496
  const entries = Object.entries(value);
@@ -461,6 +504,33 @@ export function createGuiSettingsStore(options) {
461
504
  }
462
505
  return Object.fromEntries(entries);
463
506
  }
507
+ case "dashboard.rowOrder": {
508
+ if (!isRecord(value)) {
509
+ throw invalidSetting(key, "expected an object of card ids mapped to row-id lists");
510
+ }
511
+ const entries = Object.entries(value);
512
+ if (entries.length > DASHBOARD_HIDDEN_ID_LIMIT) {
513
+ throw invalidSetting(key, `expected at most ${DASHBOARD_HIDDEN_ID_LIMIT} cards`);
514
+ }
515
+ const rowOrder = [];
516
+ for (const [cardId, ids] of entries) {
517
+ if (cardId.length === 0 || cardId.length > 512 || !Array.isArray(ids)) {
518
+ throw invalidSetting(key, "expected an object of card ids mapped to row-id lists");
519
+ }
520
+ const normalized = [];
521
+ for (const id of ids) {
522
+ if (!isText(id) || id.length === 0 || id.length > 512) {
523
+ throw invalidSetting(key, "expected an object of card ids mapped to row-id lists");
524
+ }
525
+ normalized.push(id);
526
+ }
527
+ if (normalized.length > DASHBOARD_HIDDEN_ID_LIMIT) {
528
+ throw invalidSetting(key, `expected at most ${DASHBOARD_HIDDEN_ID_LIMIT} row ids per card`);
529
+ }
530
+ rowOrder.push([cardId, [...new Set(normalized)]]);
531
+ }
532
+ return Object.fromEntries(rowOrder);
533
+ }
464
534
  case "dashboard.port":
465
535
  throw invalidSetting(key, "this setting is read-only; edit the canonical file and restart");
466
536
  case "dashboard.enabled":
@@ -513,7 +583,7 @@ export function createGuiSettingsStore(options) {
513
583
  let node = target;
514
584
  for (const part of parts.slice(0, -1)) {
515
585
  const child = node[part];
516
- if (isPlainObject(child)) {
586
+ if (isRecord(child)) {
517
587
  node = child;
518
588
  }
519
589
  else {
@@ -1,23 +1,9 @@
1
- import type { CardId, RowId, RowKey } from "../contracts/identity.js";
2
- import type { QuotaToastEntry } from "../lib/entries.js";
3
1
  /**
4
- * Reserved identity key for the provider-scope card (entries/errors that no
5
- * discovered account owns). It is a scope marker, never an account id.
2
+ * Compatibility re-export. The shared identity helpers live in
3
+ * `src/contracts/identity.ts` (pure) and `src/contracts/quota-identity.ts`
4
+ * (server-side hash + visibility) so the lib and GUI layers share one
5
+ * implementation without importing each other.
6
6
  */
7
- export declare const PROVIDER_SCOPE_IDENTITY_KEY = "provider";
8
- /** Deterministic sha256 hex of the domain-separated (providerId, identityKey) pair. */
9
- export declare function hashQuotaCardIdentity(providerId: string, identityKey: string): string;
10
- /** Opaque card id: provider namespace + server-side hash; raw identities never appear. */
11
- export declare function buildCardId(providerId: string, identityKey: string): CardId;
12
- /** The provider-scope card id (unscoped rows/errors, or no discovered accounts). */
13
- export declare function buildProviderScopeCardId(providerId: string): CardId;
14
- /**
15
- * Stable typed row key: the entry's semantic metric (window/component/named) or
16
- * its provider-supplied `rowKey`, plus the `resultType:kind` discriminator so
17
- * rows that share a metric but mean different things stay distinct. Never a
18
- * display label or an ordinal, so a rename cannot change a row id.
19
- */
20
- export declare function rowKeyForEntry(entry: QuotaToastEntry): RowKey;
21
- /** `rowId = cardId + "#" + rowKey` (R20). */
22
- export declare function rowIdForEntry(cardId: CardId, entry: QuotaToastEntry): RowId;
7
+ export { rowIdForEntry, rowKeyForEntry } from "../contracts/identity.js";
8
+ export { buildCardId, buildProviderScopeCardId, hashQuotaCardIdentity, PROVIDER_SCOPE_IDENTITY_KEY, } from "../lib/quota-identity.js";
23
9
  //# sourceMappingURL=identity.d.ts.map
@@ -1,57 +1,9 @@
1
1
  /**
2
- * Server-side card/row identity (design spec §8 R20, plan P3 step 1).
3
- *
4
- * The only place raw account identities are hashed: `CardId` is
5
- * `<providerId>:<sha256>` and `RowId` is `cardId + "#" + rowKey`. Raw source
6
- * ids, identity keys, and `rai1_` values are hash inputs and never outputs;
7
- * nothing here is imported by the browser (`src/contracts/identity.ts` holds
8
- * the opaque types only).
2
+ * Compatibility re-export. The shared identity helpers live in
3
+ * `src/contracts/identity.ts` (pure) and `src/contracts/quota-identity.ts`
4
+ * (server-side hash + visibility) so the lib and GUI layers share one
5
+ * implementation without importing each other.
9
6
  */
10
- import { createHash } from "node:crypto";
11
- import { buildRowKey, composeRowId } from "../contracts/identity.js";
12
- import { isPercentEntry } from "../lib/entries.js";
13
- /**
14
- * Reserved identity key for the provider-scope card (entries/errors that no
15
- * discovered account owns). It is a scope marker, never an account id.
16
- */
17
- export const PROVIDER_SCOPE_IDENTITY_KEY = "provider";
18
- const CARD_HASH_DOMAIN = "ocq-card-v1";
19
- /** Deterministic sha256 hex of the domain-separated (providerId, identityKey) pair. */
20
- export function hashQuotaCardIdentity(providerId, identityKey) {
21
- return createHash("sha256")
22
- .update(`${CARD_HASH_DOMAIN}\0${providerId}\0${identityKey}`, "utf8")
23
- .digest("hex");
24
- }
25
- /** Opaque card id: provider namespace + server-side hash; raw identities never appear. */
26
- export function buildCardId(providerId, identityKey) {
27
- // SAFETY: CardId is the opaque brand of exactly `<providerId>:<sha256>`; this
28
- // builder is its only producer and the hash covers both raw inputs.
29
- return `${providerId}:${hashQuotaCardIdentity(providerId, identityKey)}`;
30
- }
31
- /** The provider-scope card id (unscoped rows/errors, or no discovered accounts). */
32
- export function buildProviderScopeCardId(providerId) {
33
- return buildCardId(providerId, PROVIDER_SCOPE_IDENTITY_KEY);
34
- }
35
- function baseRowKeyOf(entry) {
36
- if (entry.semantic)
37
- return buildRowKey(entry.semantic.metric);
38
- if (entry.rowKey)
39
- return buildRowKey({ kind: "explicit", key: entry.rowKey });
40
- return buildRowKey({ kind: "aggregate" });
41
- }
42
- /**
43
- * Stable typed row key: the entry's semantic metric (window/component/named) or
44
- * its provider-supplied `rowKey`, plus the `resultType:kind` discriminator so
45
- * rows that share a metric but mean different things stay distinct. Never a
46
- * display label or an ordinal, so a rename cannot change a row id.
47
- */
48
- export function rowKeyForEntry(entry) {
49
- const base = baseRowKeyOf(entry);
50
- const kind = isPercentEntry(entry) ? "percent" : entry.kind;
51
- return buildRowKey({ kind: "explicit", key: `${base}|${entry.accounting.resultType}:${kind}` });
52
- }
53
- /** `rowId = cardId + "#" + rowKey` (R20). */
54
- export function rowIdForEntry(cardId, entry) {
55
- return composeRowId(cardId, rowKeyForEntry(entry));
56
- }
7
+ export { rowIdForEntry, rowKeyForEntry } from "../contracts/identity.js";
8
+ export { buildCardId, buildProviderScopeCardId, hashQuotaCardIdentity, PROVIDER_SCOPE_IDENTITY_KEY, } from "../lib/quota-identity.js";
57
9
  //# sourceMappingURL=identity.js.map
@@ -12,7 +12,7 @@
12
12
  * shared by every transport attached to that host. The host closes with the
13
13
  * last lease, releasing the snapshot service and every source it created. The
14
14
  * web transport is optional and follows the host version when `dashboard.enabled`
15
- * is absent (on below OpenCode 2.2.0, off from 2.2.0): when it is off, or when
15
+ * is absent (on below OpenCode 2.2.1, off from 2.2.1): when it is off, or when
16
16
  * its fixed port cannot bind, the shared runtime stays available for the
17
17
  * remaining leases and no HTTP/SSE/static surface is started.
18
18
  *
@@ -29,7 +29,7 @@
29
29
  */
30
30
  import type { DashboardDataSource, GuiSettingsStore, QuotaSnapshot } from "../contracts/dashboard.js";
31
31
  import type { QuotaProviderContext } from "../lib/entries.js";
32
- import { type OpenCodeVersion } from "../lib/opencode-version.js";
32
+ import type { OpenCodeVersion } from "../lib/opencode-version-core.js";
33
33
  import { type GuiSettingsStoreOptions } from "./config.js";
34
34
  import { type GuiLogger } from "./log.js";
35
35
  import { type QuotaNotificationObserver } from "./quota-notification-observer.js";
@@ -42,7 +42,9 @@ import { type SnapshotService, type SnapshotServiceOptions } from "./snapshot-se
42
42
  export type DashboardClient = QuotaProviderContext["client"];
43
43
  /** The read side of the dashboard source this lifecycle needs (P3 producer). */
44
44
  export type DashboardReadSource = Pick<DashboardDataSource, "home" | "project" | "session" | "groups"> & {
45
- quota?(): Promise<QuotaSnapshot>;
45
+ quota?(input?: {
46
+ refresh?: boolean;
47
+ }): Promise<QuotaSnapshot>;
46
48
  /** One shared analytics refresh per transport tick, when the owner loaded analytics. */
47
49
  refreshAnalytics?(): Promise<void>;
48
50
  /** Owner dispose / host close: releases lazily created analytics resources. */
@@ -12,7 +12,7 @@
12
12
  * shared by every transport attached to that host. The host closes with the
13
13
  * last lease, releasing the snapshot service and every source it created. The
14
14
  * web transport is optional and follows the host version when `dashboard.enabled`
15
- * is absent (on below OpenCode 2.2.0, off from 2.2.0): when it is off, or when
15
+ * is absent (on below OpenCode 2.2.1, off from 2.2.1): when it is off, or when
16
16
  * its fixed port cannot bind, the shared runtime stays available for the
17
17
  * remaining leases and no HTTP/SSE/static surface is started.
18
18
  *
@@ -213,7 +213,7 @@ function createDelegatingSource(delegation, logger, observation) {
213
213
  project: async (input) => (await requireSource()).project(input),
214
214
  session: async (input) => (await requireSource()).session(input),
215
215
  groups: async (query) => (await requireSource()).groups(query),
216
- quota: async () => {
216
+ quota: async (input) => {
217
217
  // Capture the source generation before resolving the owner and before the
218
218
  // asynchronous provider read. A handoff during either step changes the
219
219
  // token, and the observer drops the old source's snapshot instead of
@@ -225,7 +225,7 @@ function createDelegatingSource(delegation, logger, observation) {
225
225
  // Mirrors `SnapshotService`: a source without quota answers as unavailable.
226
226
  if (!source.quota)
227
227
  throw new Error("Quota source unavailable");
228
- const snapshot = await source.quota();
228
+ const snapshot = await source.quota(input);
229
229
  if (observer !== undefined && delegation.activeOwner === owner) {
230
230
  observer.observe(snapshot, epoch);
231
231
  }
@@ -1,4 +1,25 @@
1
1
  import { isPercentEntry } from "../lib/entries.js";
2
+ const ANTHROPIC_SUBSCRIPTION_WINDOWS = {
3
+ ...windowRule([
4
+ ["five_hour", 0],
5
+ ["week", 1],
6
+ ]),
7
+ namedMetrics: [{ value: "Fable weekly", slot: 2 }],
8
+ };
9
+ /**
10
+ * One typed window list generates both identities: the semantic window the
11
+ * provider emits now and the explicit `rowKey` an entry cached before that
12
+ * migration still carries.
13
+ */
14
+ function windowRule(windows, extraRowKeys = []) {
15
+ return {
16
+ rowKeys: [
17
+ ...windows.map(([value, slot]) => ({ value: `window:${value}`, slot })),
18
+ ...extraRowKeys,
19
+ ],
20
+ windows: windows.map(([value, slot]) => ({ value, slot })),
21
+ };
22
+ }
2
23
  /**
3
24
  * Explicit, evidence-backed mapping. Omitted providers intentionally have no
4
25
  * defensible primary/auxiliary split in their current source (see the Stage 6
@@ -6,49 +27,47 @@ import { isPercentEntry } from "../lib/entries.js";
6
27
  */
7
28
  const PRIMARY_QUOTA_WINDOW_RULES = {
8
29
  // 5h, weekly, and the provider's explicit Fable weekly slot; `window:month`
9
- // is Usage Credits (`src/providers/anthropic.ts` 160-195, 240-274).
10
- anthropic: {
11
- rowKeys: [
12
- { value: "window:five_hour", slot: 0 },
13
- { value: "window:week", slot: 1 },
14
- ],
15
- namedMetrics: [{ value: "Fable weekly", slot: 2 }],
16
- },
30
+ // is Usage Credits (`anthropicQuotaEntries` in `src/providers/anthropic.ts`).
31
+ anthropic: ANTHROPIC_SUBSCRIPTION_WINDOWS,
32
+ // Claude Agent emits the same subscription rows from its Claude CLI login.
33
+ "claude-agent": ANTHROPIC_SUBSCRIPTION_WINDOWS,
17
34
  // 5h/weekly/monthly ChatGPT windows; Code Review is a special secondary
18
- // window (`src/providers/openai.ts` 56-75, 239-261).
35
+ // window. `rowKeys` stays for entries cached before typed window semantics.
19
36
  openai: {
20
- rowKeys: [
21
- { value: "window:five_hour", slot: 0 },
22
- { value: "window:week", slot: 1 },
23
- { value: "window:month", slot: 2 },
24
- ],
37
+ ...windowRule([
38
+ ["five_hour", 0],
39
+ ["week", 1],
40
+ ["month", 2],
41
+ ]),
25
42
  },
26
43
  // GLM five-hour/weekly plan windows; MCP is a tool-specific allowance
27
- // (`src/providers/glm-coding-plan-provider.ts` 40-79).
44
+ // (`src/providers/glm-coding-plan-provider.ts`).
28
45
  zai: {
29
- rowKeys: [
30
- { value: "window:five_hour", slot: 0 },
31
- { value: "window:week", slot: 1 },
32
- ],
46
+ ...windowRule([
47
+ ["five_hour", 0],
48
+ ["week", 1],
49
+ ]),
33
50
  },
34
51
  zhipu: {
35
- rowKeys: [
36
- { value: "window:five_hour", slot: 0 },
37
- { value: "window:week", slot: 1 },
38
- ],
52
+ ...windowRule([
53
+ ["five_hour", 0],
54
+ ["week", 1],
55
+ ]),
39
56
  },
40
- // Rolling/weekly/monthly Go plan windows (`src/providers/opencode-go.ts` 44-55).
57
+ // Rolling/weekly/monthly Go plan windows (`src/providers/opencode-go.ts`).
41
58
  "opencode-go": {
42
- rowKeys: [
43
- { value: "window:five_hour", slot: 0 },
44
- { value: "window:week", slot: 1 },
45
- { value: "window:month", slot: 2 },
46
- ],
59
+ ...windowRule([
60
+ ["five_hour", 0],
61
+ ["week", 1],
62
+ ["month", 2],
63
+ ]),
47
64
  },
48
65
  // The plan entitlement is Copilot's only primary window, so it occupies the
49
66
  // outer slot; the additional-usage row is a budget percent
50
- // (`src/providers/copilot.ts` 109-142, 185-215).
51
- copilot: { rowKeys: [{ value: "window:month", slot: 0 }] },
67
+ // (`src/providers/copilot.ts`).
68
+ copilot: {
69
+ ...windowRule([["month", 0]]),
70
+ },
52
71
  // Daily/monthly subscription limits are the provider's two-window family in
53
72
  // full-card order (`src/providers/nanogpt.ts` 70-105).
54
73
  nanogpt: {
@@ -81,21 +100,25 @@ const PRIMARY_QUOTA_WINDOW_RULES = {
81
100
  kilo: { components: [{ value: "remaining_credits", slot: 0 }] },
82
101
  // xAI always emits exactly one provider-supplied period row, so any valid
83
102
  // period identity occupies the same outer slot even when the response-defined
84
- // period changes (`src/providers/xai.ts` 29-40, 92-153).
103
+ // period changes (`src/providers/xai.ts`).
85
104
  xai: {
86
- rowKeys: [
87
- { value: "window:day", slot: 0 },
88
- { value: "window:week", slot: 0 },
89
- { value: "window:month", slot: 0 },
90
- { value: "named:period", slot: 0 },
91
- ],
105
+ ...windowRule([
106
+ ["day", 0],
107
+ ["week", 0],
108
+ ["month", 0],
109
+ ], [{ value: "named:period", slot: 0 }]),
110
+ namedMetrics: [{ value: "period", slot: 0 }],
111
+ },
112
+ // Zen's monthly budget/quota is the subscription's primary window; spend,
113
+ // balance and auto-reload stay supplementary (`src/providers/opencode-zen.ts`).
114
+ opencode: {
115
+ ...windowRule([["month", 0]]),
92
116
  },
93
- // These providers always emit the same single surviving row, so its window
94
- // meaning cannot move with availability. Synthetic always emits 5h then
95
- // weekly; Alibaba Coding Plan always emits 5h/weekly/monthly in that order;
96
- // Chutes emits one daily-reset quota window (`src/providers/synthetic.ts`
97
- // 84-103, `src/providers/alibaba-coding-plan.ts` 116-159,
98
- // `src/providers/chutes.ts` 43-55).
117
+ // These provider cards compact their quota entries into one aggregate row.
118
+ // Synthetic returns 5h before weekly; Bailian CLI Coding Plan may return any
119
+ // of 5h/weekly/monthly in that order; Chutes returns one daily-reset window
120
+ // (`src/providers/synthetic.ts` 84-103, `src/providers/alibaba-coding-plan.ts`
121
+ // 116-159, `src/providers/chutes.ts` 43-55).
99
122
  //
100
123
  // Deliberately omitted untyped providers:
101
124
  // - Alibaba Token Plan emits optional 5h/weekly