opencode-quota-gui 1.3.1 → 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 (155) hide show
  1. package/README.md +16 -12
  2. package/dist/contracts/build-identity.js +1 -1
  3. package/dist/contracts/card-order.d.ts +2 -0
  4. package/dist/contracts/card-order.js +2 -2
  5. package/dist/contracts/card-visibility.d.ts +2 -1
  6. package/dist/contracts/card-visibility.js +2 -1
  7. package/dist/contracts/dashboard.d.ts +87 -5
  8. package/dist/contracts/dashboard.js +10 -0
  9. package/dist/contracts/dto-guards.d.ts +4 -0
  10. package/dist/contracts/dto-guards.js +29 -7
  11. package/dist/contracts/guards.js +3 -1
  12. package/dist/contracts/identity.d.ts +37 -5
  13. package/dist/contracts/identity.js +43 -0
  14. package/dist/contracts/provider-auto-resume.d.ts +9 -0
  15. package/dist/contracts/provider-auto-resume.js +24 -0
  16. package/dist/contracts/provider-failure.d.ts +22 -0
  17. package/dist/contracts/provider-failure.js +25 -1
  18. package/dist/contracts/row-order.d.ts +13 -0
  19. package/dist/contracts/row-order.js +34 -0
  20. package/dist/contracts/row-visibility.d.ts +53 -0
  21. package/dist/contracts/row-visibility.js +130 -0
  22. package/dist/data/modelsdev-pricing.min.json +1 -1
  23. package/dist/data/modelsdev-temporal.min.json +3 -634
  24. package/dist/gui/aggregation.d.ts +29 -1
  25. package/dist/gui/aggregation.js +157 -4
  26. package/dist/gui/analytics-bridge.d.ts +8 -9
  27. package/dist/gui/analytics-bridge.js +197 -54
  28. package/dist/gui/analytics-engine.d.ts +7 -15
  29. package/dist/gui/analytics-engine.js +246 -106
  30. package/dist/gui/analytics-model.d.ts +7 -0
  31. package/dist/gui/analytics-model.js +75 -9
  32. package/dist/gui/analytics-pricing-upkeep.d.ts +21 -0
  33. package/dist/gui/analytics-pricing-upkeep.js +23 -0
  34. package/dist/gui/analytics-protocol.d.ts +17 -7
  35. package/dist/gui/analytics-protocol.js +1 -0
  36. package/dist/gui/analytics-service.d.ts +10 -0
  37. package/dist/gui/analytics-service.js +30 -9
  38. package/dist/gui/analytics-state.d.ts +30 -5
  39. package/dist/gui/analytics-state.js +46 -7
  40. package/dist/gui/analytics-worker-runtime.d.ts +5 -0
  41. package/dist/gui/analytics-worker-runtime.js +9 -1
  42. package/dist/gui/analytics-worker.js +11 -0
  43. package/dist/gui/config.d.ts +2 -2
  44. package/dist/gui/config.js +46 -5
  45. package/dist/gui/identity.d.ts +6 -20
  46. package/dist/gui/identity.js +6 -54
  47. package/dist/gui/primary-quota-windows.js +55 -34
  48. package/dist/gui/provider-cards.d.ts +12 -8
  49. package/dist/gui/provider-cards.js +12 -53
  50. package/dist/gui/quota-notification-detector.d.ts +25 -2
  51. package/dist/gui/quota-notification-detector.js +60 -5
  52. package/dist/gui/quota-notification-observer.d.ts +1 -1
  53. package/dist/gui/quota-notification-observer.js +5 -1
  54. package/dist/gui/quota-observation.d.ts +4 -0
  55. package/dist/gui/quota-observation.js +18 -0
  56. package/dist/gui/rpc.js +3 -0
  57. package/dist/gui/server.js +6 -1
  58. package/dist/gui/snapshot-service.d.ts +3 -17
  59. package/dist/gui/snapshot-service.js +159 -9
  60. package/dist/gui/sources.js +84 -11
  61. package/dist/gui/temporal-status.d.ts +3 -2
  62. package/dist/gui/temporal-status.js +10 -6
  63. package/dist/gui-experimental.cjs +228 -228
  64. package/dist/lib/accounting-format.d.ts +8 -0
  65. package/dist/lib/accounting-format.js +12 -2
  66. package/dist/lib/anthropic-api-auth.d.ts +7 -0
  67. package/dist/lib/anthropic-api-auth.js +27 -0
  68. package/dist/lib/anthropic-api-rate-limits.d.ts +47 -0
  69. package/dist/lib/anthropic-api-rate-limits.js +92 -0
  70. package/dist/lib/anthropic-oauth-throttle.d.ts +76 -0
  71. package/dist/lib/anthropic-oauth-throttle.js +379 -0
  72. package/dist/lib/anthropic.d.ts +22 -4
  73. package/dist/lib/anthropic.js +498 -180
  74. package/dist/lib/cache-observer-ingestion.js +27 -0
  75. package/dist/lib/cache-observer.d.ts +3 -0
  76. package/dist/lib/cache-observer.js +9 -3
  77. package/dist/lib/cli-show.d.ts +5 -0
  78. package/dist/lib/cli-show.js +16 -5
  79. package/dist/lib/cli-status.js +3 -6
  80. package/dist/lib/config.d.ts +1 -1
  81. package/dist/lib/config.js +64 -2
  82. package/dist/lib/dashboard-visibility.d.ts +5 -0
  83. package/dist/lib/dashboard-visibility.js +11 -10
  84. package/dist/lib/display-sanitize.js +1 -0
  85. package/dist/lib/entries.d.ts +10 -1
  86. package/dist/lib/entries.js +4 -0
  87. package/dist/lib/grouped-entry-normalization.js +1 -1
  88. package/dist/lib/maintainer-announcements.js +2 -2
  89. package/dist/lib/modelsdev-pricing.d.ts +74 -2
  90. package/dist/lib/modelsdev-pricing.js +457 -63
  91. package/dist/lib/modelsdev-temporal.d.ts +6 -0
  92. package/dist/lib/modelsdev-temporal.js +16 -2
  93. package/dist/lib/opencode-config-providers.js +2 -2
  94. package/dist/lib/opencode-storage.d.ts +20 -0
  95. package/dist/lib/opencode-storage.js +89 -2
  96. package/dist/lib/opencode-version-core.d.ts +7 -0
  97. package/dist/lib/opencode-version-core.js +10 -0
  98. package/dist/lib/opencode-warming-refresh.d.ts +19 -0
  99. package/dist/lib/opencode-warming-refresh.js +95 -0
  100. package/dist/lib/provider-metadata.d.ts +11 -3
  101. package/dist/lib/provider-metadata.js +20 -2
  102. package/dist/lib/provider-registration.d.ts +342 -3
  103. package/dist/lib/provider-registration.js +409 -27
  104. package/dist/lib/quota-auto-resume.d.ts +74 -0
  105. package/dist/lib/quota-auto-resume.js +539 -0
  106. package/dist/lib/quota-command-format.js +22 -9
  107. package/dist/lib/quota-identity.d.ts +64 -0
  108. package/dist/lib/quota-identity.js +111 -0
  109. package/dist/lib/quota-providers.js +2 -2
  110. package/dist/lib/quota-render-data.js +2 -2
  111. package/dist/lib/quota-reset-notifications.js +11 -155
  112. package/dist/lib/quota-retry-wait.d.ts +106 -5
  113. package/dist/lib/quota-retry-wait.js +301 -34
  114. package/dist/lib/quota-runtime-context.js +1 -0
  115. package/dist/lib/quota-state-codec.d.ts +2 -0
  116. package/dist/lib/quota-state-codec.js +14 -1
  117. package/dist/lib/quota-state.d.ts +1 -1
  118. package/dist/lib/quota-state.js +60 -28
  119. package/dist/lib/quota-stats.d.ts +26 -0
  120. package/dist/lib/quota-stats.js +19 -1
  121. package/dist/lib/quota-surface-data.js +18 -3
  122. package/dist/lib/quota-telemetry.js +2 -2
  123. package/dist/lib/resolved-auth-identity.d.ts +19 -0
  124. package/dist/lib/resolved-auth-identity.js +44 -0
  125. package/dist/lib/state-file-lock.d.ts +26 -0
  126. package/dist/lib/state-file-lock.js +205 -0
  127. package/dist/lib/toast-format-grouped.js +7 -4
  128. package/dist/lib/tui-compact-format.js +29 -16
  129. package/dist/lib/types.d.ts +20 -0
  130. package/dist/lib/types.js +4 -1
  131. package/dist/plugin.js +67 -1
  132. package/dist/providers/alibaba-coding-plan.js +21 -3
  133. package/dist/providers/alibaba-token-plan.js +9 -5
  134. package/dist/providers/anthropic.d.ts +6 -2
  135. package/dist/providers/anthropic.js +123 -14
  136. package/dist/providers/chutes.js +2 -0
  137. package/dist/providers/claude-agent.js +24 -5
  138. package/dist/providers/copilot.js +5 -4
  139. package/dist/providers/glm-coding-plan-provider.js +30 -23
  140. package/dist/providers/ollama-cloud.js +10 -0
  141. package/dist/providers/openai.js +24 -23
  142. package/dist/providers/opencode-go.js +7 -6
  143. package/dist/providers/opencode-zen.js +1 -1
  144. package/dist/providers/result-helpers.d.ts +4 -2
  145. package/dist/providers/result-helpers.js +5 -1
  146. package/dist/providers/synthetic.js +4 -0
  147. package/dist/providers/xai.js +9 -8
  148. package/dist/rpc.d.ts +8 -0
  149. package/dist/rpc.js +15 -2
  150. package/dist/ui/assets/{index-BcueIm3Z.css → index-6_g1FHs-.css} +1 -1
  151. package/dist/ui/assets/index-sZnGUuML.js +10 -0
  152. package/dist/ui/assets/{popover-4bFSvRZ7.js → popover-C4ZLYe9E.js} +1 -1
  153. package/dist/ui/index.html +2 -2
  154. package/package.json +3 -3
  155. package/dist/ui/assets/index-C6qRSoh8.js +0 -10
@@ -4,6 +4,7 @@
4
4
  * Queries the Ollama Cloud balance API and reports included credits or
5
5
  * session/weekly limits, plus purchased credits.
6
6
  */
7
+ import { windowSemantic } from "../lib/entries.js";
7
8
  import { queryOllamaCloudQuota } from "../lib/ollama-cloud.js";
8
9
  import { getOllamaCloudKeyDiagnostics, hasOllamaCloudApiKey } from "../lib/ollama-cloud-config.js";
9
10
  import { modelProviderMatchesRuntimeId } from "../lib/provider-model-matching.js";
@@ -25,6 +26,9 @@ function mapOllamaCloudSuccess(result) {
25
26
  name: `${OLLAMA_CLOUD_PROVIDER_LABEL} Session`,
26
27
  group: OLLAMA_CLOUD_PROVIDER_LABEL,
27
28
  label: "Session:",
29
+ // The API calls this a "session" limit without a documented fixed
30
+ // window, so it gets a stable named identity but stays reset-ineligible.
31
+ semantic: { metric: { kind: "named", name: "Session" }, prominence: "primary" },
28
32
  percentRemaining: result.session.percentRemaining,
29
33
  ...(result.session.resetTimeIso ? { resetTimeIso: result.session.resetTimeIso } : {}),
30
34
  });
@@ -38,6 +42,7 @@ function mapOllamaCloudSuccess(result) {
38
42
  name: `${OLLAMA_CLOUD_PROVIDER_LABEL} Weekly`,
39
43
  group: OLLAMA_CLOUD_PROVIDER_LABEL,
40
44
  label: "Weekly:",
45
+ semantic: windowSemantic("week"),
41
46
  percentRemaining: result.weekly.percentRemaining,
42
47
  ...(result.weekly.resetTimeIso ? { resetTimeIso: result.weekly.resetTimeIso } : {}),
43
48
  });
@@ -53,6 +58,7 @@ function mapOllamaCloudSuccess(result) {
53
58
  name: `${OLLAMA_CLOUD_PROVIDER_LABEL} Monthly`,
54
59
  group: OLLAMA_CLOUD_PROVIDER_LABEL,
55
60
  label: "Monthly:",
61
+ semantic: windowSemantic("month"),
56
62
  percentRemaining: included.percentRemaining,
57
63
  ...(included.resetTimeIso ? { resetTimeIso: included.resetTimeIso } : {}),
58
64
  });
@@ -68,6 +74,10 @@ function mapOllamaCloudSuccess(result) {
68
74
  name: `${OLLAMA_CLOUD_PROVIDER_LABEL} Purchased`,
69
75
  group: OLLAMA_CLOUD_PROVIDER_LABEL,
70
76
  label: "Purchased:",
77
+ semantic: {
78
+ metric: { kind: "component", component: "remaining_credits" },
79
+ prominence: "supplementary",
80
+ },
71
81
  value: `$${result.purchasedUsd.toFixed(2)} left`,
72
82
  });
73
83
  }
@@ -2,6 +2,7 @@
2
2
  * OpenAI (Plus/Pro) provider wrapper.
3
3
  */
4
4
  import { OPENAI_CREDITS_ROW_KEY, OPENAI_CREDITS_ROW_LABEL, OPENAI_CREDITS_ROW_RESULT_TYPE, OPENAI_RESETS_ROW_KEY, OPENAI_RESETS_ROW_LABEL, OPENAI_RESETS_ROW_RESULT_TYPE, } from "../contracts/openai-quota.js";
5
+ import { windowSemantic } from "../lib/entries.js";
5
6
  import { DEFAULT_OPENAI_AUTH_CACHE_MAX_AGE_MS, hasOpenAIOAuthCached, OPENAI_AUTH_SOURCE_KEYS, queryOpenAIQuota, resolveOpenAIOAuth, } from "../lib/openai.js";
6
7
  import { credentialRowAuthEntry, formatCredentialDisplayNames, readCredentialRows, } from "../lib/opencode-auth.js";
7
8
  import { isCanonicalProviderAvailable } from "../lib/provider-availability.js";
@@ -17,23 +18,6 @@ const TOKEN_SHARING_METHOD_ID = "chatgpt-token-sharing";
17
18
  function isTokenSharingLogin(row) {
18
19
  return row.value.methodID === TOKEN_SHARING_METHOD_ID;
19
20
  }
20
- const OPENAI_WINDOW_ROW_KEYS = {
21
- "5h:": "window:five_hour",
22
- "Weekly:": "window:week",
23
- "Monthly:": "window:month",
24
- "Code Review:": "window:code_review",
25
- };
26
- /**
27
- * Percent-only window rows carry no typed `semantic`, so they get stable
28
- * explicit `rowKey`s by window (the fallback aggregate row when no window
29
- * exists); labels themselves are never used as ids.
30
- */
31
- function withOpenAiWindowRowKeys(entries) {
32
- return entries.map((entry) => ({
33
- ...entry,
34
- rowKey: (entry.label ? OPENAI_WINDOW_ROW_KEYS[entry.label] : undefined) ?? "aggregate",
35
- }));
36
- }
37
21
  const OPENAI_OPTIONAL_ACCOUNTING = {
38
22
  acquisitionMethod: "remote_api",
39
23
  ownership: "maintained",
@@ -172,7 +156,7 @@ export const openaiProvider = {
172
156
  credits: result.credits,
173
157
  bankedResets: result.bankedResets,
174
158
  });
175
- const windowEntries = withOpenAiWindowRowKeys(groupedPercentWindowEntries({
159
+ const windowEntries = groupedPercentWindowEntries({
176
160
  group,
177
161
  accounting: {
178
162
  resultType: "rate_limit",
@@ -182,17 +166,34 @@ export const openaiProvider = {
182
166
  ...(options.sourceId ? { sourceId: options.sourceId } : {}),
183
167
  },
184
168
  windows: [
185
- { window: result.windows.hourly, suffix: "5h", label: "5h:" },
186
- { window: result.windows.weekly, suffix: "Weekly", label: "Weekly:" },
187
- { window: result.windows.monthly, suffix: "Monthly", label: "Monthly:" },
169
+ {
170
+ window: result.windows.hourly,
171
+ suffix: "5h",
172
+ label: "5h:",
173
+ semantic: windowSemantic("five_hour"),
174
+ },
175
+ {
176
+ window: result.windows.weekly,
177
+ suffix: "Weekly",
178
+ label: "Weekly:",
179
+ semantic: windowSemantic("week"),
180
+ },
181
+ {
182
+ window: result.windows.monthly,
183
+ suffix: "Monthly",
184
+ label: "Monthly:",
185
+ semantic: windowSemantic("month"),
186
+ },
188
187
  {
189
188
  window: result.windows.codeReview,
190
189
  suffix: "Code Review",
191
190
  label: "Code Review:",
191
+ semantic: windowSemantic("code_review"),
192
192
  },
193
193
  ],
194
- fallbackWhenEmpty: optionalEntries.length === 0,
195
- }));
194
+ // A successful response with no reported window is not a 0% quota.
195
+ fallbackWhenEmpty: false,
196
+ });
196
197
  return attemptedResult([...windowEntries, ...optionalEntries], [], {
197
198
  singleWindowDisplayName: group,
198
199
  });
@@ -1,4 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { windowSemantic } from "../lib/entries.js";
2
3
  import { credentialRowAuthEntry, formatCredentialDisplayNames, readCredentialRows, scrubCredentialErrorText, selectConnectionCredentialRows, } from "../lib/opencode-auth.js";
3
4
  import { consoleBaseUrl, consoleUnexpectedErrorText, resolveOpenCodeConsoleAuthAccounts, } from "../lib/opencode-console-auth.js";
4
5
  import { queryOpenCodeGoConsoleStatus, queryOpenCodeGoQuota } from "../lib/opencode-go.js";
@@ -13,11 +14,11 @@ const OPENCODE_GO_WINDOW_LABELS = {
13
14
  weekly: { name: `${OPENCODE_GO_PROVIDER_LABEL} Weekly`, label: "Weekly:" },
14
15
  monthly: { name: `${OPENCODE_GO_PROVIDER_LABEL} Monthly`, label: "Monthly:" },
15
16
  };
16
- /** Stable explicit row keys (metric + window) for the percent-only window rows. */
17
- const OPENCODE_GO_WINDOW_ROW_KEYS = {
18
- rolling: "window:five_hour",
19
- weekly: "window:week",
20
- monthly: "window:month",
17
+ /** Typed window metrics for the percent-only window rows. */
18
+ const OPENCODE_GO_WINDOW_METRICS = {
19
+ rolling: "five_hour",
20
+ weekly: "week",
21
+ monthly: "month",
21
22
  };
22
23
  const notSubscribedCredentialFingerprints = new Set();
23
24
  export function __resetOpenCodeGoNotSubscribedForTests() {
@@ -60,7 +61,7 @@ function buildOpenCodeGoEntries(result, selectedWindows, group = OPENCODE_GO_PRO
60
61
  name: `${group} ${labels.label.slice(0, -1)}`,
61
62
  group,
62
63
  label: labels.label,
63
- rowKey: OPENCODE_GO_WINDOW_ROW_KEYS[window],
64
+ semantic: windowSemantic(OPENCODE_GO_WINDOW_METRICS[window]),
64
65
  percentRemaining: usage.percentRemaining,
65
66
  ...(usage.resetTimeIso !== undefined ? { resetTimeIso: usage.resetTimeIso } : {}),
66
67
  });
@@ -98,7 +98,7 @@ function buildZenEntries(params) {
98
98
  info: "Workspace monthly spend (includes Go API equivalent)",
99
99
  semantic: {
100
100
  metric: { kind: "window", window: "month" },
101
- prominence: "primary",
101
+ prominence: "supplementary",
102
102
  },
103
103
  quantity: { decimal: zenUsdDecimal(monthlyUsageUsd), unit: USD_UNIT },
104
104
  });
@@ -1,11 +1,12 @@
1
- import type { ProviderFailureCategory } from "../contracts/provider-failure.js";
2
- import type { AccountingMetadata, FixedWindowProjectionEvidence, QuotaProviderPresentation, QuotaProviderResult, QuotaProviderStatusDetail, QuotaToastEntry, QuotaToastError } from "../lib/entries.js";
1
+ import type { ProviderFailureCategory, QuotaAttemptOutcome } from "../contracts/provider-failure.js";
2
+ import type { AccountingMetadata, AccountingSemantic, FixedWindowProjectionEvidence, QuotaProviderPresentation, QuotaProviderResult, QuotaProviderStatusDetail, QuotaToastEntry, QuotaToastError } from "../lib/entries.js";
3
3
  export declare function notAttemptedResult(): QuotaProviderResult;
4
4
  export declare function attemptedResult(entries: QuotaToastEntry[], errors?: QuotaToastError[], presentation?: QuotaProviderPresentation): QuotaProviderResult;
5
5
  export declare function attemptedErrorResult(label: string, message: string, options?: {
6
6
  retryable?: boolean;
7
7
  failureCategory?: ProviderFailureCategory;
8
8
  retryAtMs?: number;
9
+ attemptOutcome?: QuotaAttemptOutcome;
9
10
  }): QuotaProviderResult;
10
11
  export declare function statusDetailsFromRecord(values: Readonly<Record<string, string | undefined>>): QuotaProviderStatusDetail[];
11
12
  export declare function configStatusDetails(diagnostics: {
@@ -61,6 +62,7 @@ export declare function groupedPercentWindowEntries(params: {
61
62
  };
62
63
  suffix: string;
63
64
  label: string;
65
+ semantic?: AccountingSemantic;
64
66
  }>;
65
67
  fallbackWhenEmpty?: boolean;
66
68
  }): QuotaToastEntry[];
@@ -18,6 +18,7 @@ export function attemptedErrorResult(label, message, options = {}) {
18
18
  message,
19
19
  ...(options.retryable === true ? { retryable: true } : {}),
20
20
  ...(options.retryAtMs !== undefined ? { retryAtMs: options.retryAtMs } : {}),
21
+ ...(options.attemptOutcome !== undefined ? { attemptOutcome: options.attemptOutcome } : {}),
21
22
  ...(options.failureCategory !== undefined
22
23
  ? { failureCategory: options.failureCategory }
23
24
  : {}),
@@ -108,7 +109,7 @@ export function mapNullableProviderResult(result, params) {
108
109
  }
109
110
  export function groupedPercentWindowEntries(params) {
110
111
  const entries = [];
111
- for (const { window, suffix, label } of params.windows) {
112
+ for (const { window, suffix, label, semantic } of params.windows) {
112
113
  if (!window)
113
114
  continue;
114
115
  entries.push({
@@ -116,6 +117,9 @@ export function groupedPercentWindowEntries(params) {
116
117
  name: `${params.group} ${suffix}`,
117
118
  group: params.group,
118
119
  label,
120
+ ...(semantic
121
+ ? { semantic: { metric: { ...semantic.metric }, prominence: semantic.prominence } }
122
+ : {}),
119
123
  percentRemaining: window.percentRemaining,
120
124
  resetTimeIso: window.resetTimeIso,
121
125
  ...(window.fixedWindow ? { fixedWindow: { ...window.fixedWindow } } : {}),
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Synthetic provider wrapper.
3
3
  */
4
+ import { windowSemantic } from "../lib/entries.js";
4
5
  import { isCanonicalProviderAvailable } from "../lib/provider-availability.js";
5
6
  import { modelProviderIncludesAny } from "../lib/provider-model-matching.js";
6
7
  import { getSyntheticKeyDiagnostics, hasSyntheticApiKeyConfigured, querySyntheticQuota, } from "../lib/synthetic.js";
@@ -27,6 +28,7 @@ function toSyntheticEntry(params) {
27
28
  name: `Synthetic ${params.suffix}`,
28
29
  group: "Synthetic",
29
30
  label: params.label,
31
+ semantic: windowSemantic(params.semanticWindow),
30
32
  percentRemaining: params.window.percentRemaining,
31
33
  right,
32
34
  resetTimeIso: params.window.resetTimeIso,
@@ -61,11 +63,13 @@ export const syntheticProvider = {
61
63
  window: result.windows.fiveHour,
62
64
  suffix: "5h",
63
65
  label: "5h:",
66
+ semanticWindow: "five_hour",
64
67
  }),
65
68
  toSyntheticEntry({
66
69
  window: result.windows.weekly,
67
70
  suffix: "Weekly",
68
71
  label: "Weekly:",
72
+ semanticWindow: "week",
69
73
  currency: true,
70
74
  }),
71
75
  ], [], {
@@ -1,22 +1,23 @@
1
1
  /**
2
2
  * xAI SuperGrok provider wrapper.
3
3
  */
4
+ import { windowSemantic } from "../lib/entries.js";
4
5
  import { credentialRowAuthEntry, formatCredentialDisplayNames, readCredentialRows, } from "../lib/opencode-auth.js";
5
6
  import { isCanonicalProviderAvailable } from "../lib/provider-availability.js";
6
7
  import { modelProviderMatchesRuntimeId } from "../lib/provider-model-matching.js";
7
8
  import { DEFAULT_XAI_AUTH_CACHE_MAX_AGE_MS, hasXaiOAuthCached, periodKindLabel, queryXaiQuota, resolveXaiOAuth, } from "../lib/xai.js";
8
9
  import { attemptedResult, mapNullableProviderResult } from "./result-helpers.js";
9
- /** Stable explicit row key for the single percent row (never the display label). */
10
- function xaiWindowRowKey(kind) {
10
+ /** Typed identity for the single provider-defined period row (never its label). */
11
+ function xaiWindowSemantic(kind) {
11
12
  switch (kind) {
12
13
  case "weekly":
13
- return "window:week";
14
+ return windowSemantic("week");
14
15
  case "monthly":
15
- return "window:month";
16
+ return windowSemantic("month");
16
17
  case "daily":
17
- return "window:day";
18
+ return windowSemantic("day");
18
19
  default:
19
- return "named:period";
20
+ return { metric: { kind: "named", name: "period" }, prominence: "primary" };
20
21
  }
21
22
  }
22
23
  export const xaiProvider = {
@@ -79,7 +80,7 @@ export const xaiProvider = {
79
80
  name: `${group} ${period}`,
80
81
  group,
81
82
  label: `${period}:`,
82
- rowKey: xaiWindowRowKey(result.window.kind),
83
+ semantic: xaiWindowSemantic(result.window.kind),
83
84
  percentRemaining: result.window.percentRemaining,
84
85
  resetTimeIso: result.window.resetTimeIso,
85
86
  },
@@ -107,7 +108,7 @@ export const xaiProvider = {
107
108
  name: `${result.label} ${period}`,
108
109
  group: result.label,
109
110
  label: `${period}:`,
110
- rowKey: xaiWindowRowKey(result.window.kind),
111
+ semantic: xaiWindowSemantic(result.window.kind),
111
112
  percentRemaining: result.window.percentRemaining,
112
113
  resetTimeIso: result.window.resetTimeIso,
113
114
  ...(result.window.fixedWindow
package/dist/rpc.d.ts CHANGED
@@ -157,6 +157,13 @@ export type DashboardRpcCacheObserverEvent = {
157
157
  assistantMessageID: string;
158
158
  ttlMs: 3_600_000;
159
159
  };
160
+ } | {
161
+ type: "session.cache.warming";
162
+ data: {
163
+ sessionID: string;
164
+ dispatchMs: number;
165
+ evidence: "warming-inferred";
166
+ };
160
167
  } | {
161
168
  type: "session.created";
162
169
  data: {
@@ -309,6 +316,7 @@ export declare const DashboardRpc: {
309
316
  home: {
310
317
  input: QuotaRpcSchema<{
311
318
  range: RangeKey;
319
+ background?: boolean;
312
320
  }>;
313
321
  output: QuotaRpcSchema<import("./contracts/dashboard.js").HomeSnapshot>;
314
322
  errors: {
package/dist/rpc.js CHANGED
@@ -256,8 +256,10 @@ export const DashboardRpc = {
256
256
  },
257
257
  home: {
258
258
  input: schema((value) => {
259
- if (!isObject(value) || !hasExactKeys(value, ["range"])) {
260
- return "input must contain only range";
259
+ if (!isObject(value) ||
260
+ !hasOnlyKeys(value, ["range", "background"]) ||
261
+ (value.background !== undefined && typeof value.background !== "boolean")) {
262
+ return "input must contain range and optional boolean background";
261
263
  }
262
264
  return checkRange(value);
263
265
  }),
@@ -490,6 +492,17 @@ export function isDashboardRpcCacheObserverEvent(value) {
490
492
  return false;
491
493
  return [tokens.cache.read, tokens.cache.write].every((count) => count === undefined || (Number.isFinite(count) && count >= 0));
492
494
  }
495
+ if (value.type === "session.cache.warming") {
496
+ return (hasExactKeys(value, ["type", "data"]) &&
497
+ isObject(value.data) &&
498
+ hasExactKeys(value.data, ["sessionID", "dispatchMs", "evidence"]) &&
499
+ typeof value.data.sessionID === "string" &&
500
+ isValidResourceId(value.data.sessionID) &&
501
+ typeof value.data.dispatchMs === "number" &&
502
+ Number.isFinite(value.data.dispatchMs) &&
503
+ value.data.dispatchMs >= 0 &&
504
+ value.data.evidence === "warming-inferred");
505
+ }
493
506
  if (value.type === "session.cache.ttl") {
494
507
  return (hasExactKeys(value, ["type", "created", "data"]) &&
495
508
  Number.isFinite(value.created) &&