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
@@ -464,6 +464,33 @@ export function createCacheObserverIngestor(options = {}) {
464
464
  applyObservedTtl(event.data);
465
465
  return;
466
466
  }
467
+ if (isRecord(event) && event.type === "session.cache.warming") {
468
+ if (source === "live" && isRecord(event.data)) {
469
+ const data = event.data;
470
+ const sessionId = nonEmptyString(data.sessionID);
471
+ const state = sessionId === undefined ? undefined : states.get(sessionId);
472
+ const latest = state?.invocations.at(-1);
473
+ const estimate = sessionId === undefined ? undefined : query(sessionId)?.ttlEstimate;
474
+ if (sessionId !== undefined &&
475
+ state !== undefined &&
476
+ latest !== undefined &&
477
+ estimate?.deadlineAtMs !== undefined &&
478
+ typeof data.dispatchMs === "number" &&
479
+ Number.isFinite(data.dispatchMs) &&
480
+ data.dispatchMs > (latest.warmingAnchorAtMs ?? latest.dispatchAtMs ?? Infinity) &&
481
+ data.evidence === "warming-inferred") {
482
+ states.set(sessionId, {
483
+ ...state,
484
+ invocations: [
485
+ ...state.invocations.slice(0, -1),
486
+ { ...latest, warmingAnchorAtMs: data.dispatchMs },
487
+ ],
488
+ });
489
+ notify(sessionId);
490
+ }
491
+ }
492
+ return;
493
+ }
467
494
  const started = startedStepFromDto(event);
468
495
  if (started !== undefined) {
469
496
  const key = startedStepKey(started.sessionId, started.messageId);
@@ -58,6 +58,7 @@ export interface CacheInvocationObservation {
58
58
  connectionMethod?: "oauth" | "key" | "external";
59
59
  /** Claude Agent only: this exact invocation's cache writes were observed as 1-hour-only. */
60
60
  observedTtlMs?: 3_600_000;
61
+ warmingAnchorAtMs?: number;
61
62
  }
62
63
  /** Host-configured retention values the observer accepts for a configurable route. */
63
64
  export type CacheConfiguredTtlMs = 300_000 | 3_600_000;
@@ -86,6 +87,8 @@ export interface CacheTtlEstimate {
86
87
  dispatchAtMs?: number;
87
88
  /** Estimated boundary only; this is not proof of physical eviction. */
88
89
  deadlineAtMs?: number;
90
+ anchor?: "warming-inferred";
91
+ anchorAtMs?: number;
89
92
  }
90
93
  export interface CacheObserverScope {
91
94
  /** Each child session is classified independently; no tree roll-up occurs. */
@@ -65,9 +65,15 @@ export function classifyCacheObserverState(state, nowMs, routeConfiguration = {}
65
65
  return { color: "gray", reason: "dispatch-time-unavailable", ttlEstimate, ...reported };
66
66
  }
67
67
  const dispatchAtMs = latest.dispatchAtMs;
68
- const deadlineAtMs = dispatchAtMs + policy.ttlMs;
69
- const warningAtMs = dispatchAtMs + Math.floor(policy.ttlMs * 0.8);
70
- const estimate = { ...ttlEstimate, dispatchAtMs, deadlineAtMs };
68
+ const anchorAtMs = latest.warmingAnchorAtMs ?? dispatchAtMs;
69
+ const deadlineAtMs = anchorAtMs + policy.ttlMs;
70
+ const warningAtMs = anchorAtMs + Math.floor(policy.ttlMs * 0.8);
71
+ const estimate = {
72
+ ...ttlEstimate,
73
+ dispatchAtMs,
74
+ deadlineAtMs,
75
+ ...(latest.warmingAnchorAtMs === undefined ? {} : { anchor: "warming-inferred", anchorAtMs }),
76
+ };
71
77
  if (deadlineAtMs <= nowMs) {
72
78
  return { color: "red", reason: "estimated-ttl-expired", ttlEstimate: estimate, ...reported };
73
79
  }
@@ -14,6 +14,11 @@ export declare function resolveCliRoots(cwd: string): {
14
14
  export declare function createCliQuotaClient(params: {
15
15
  configRootDir: string;
16
16
  }): QuotaRuntimeClient;
17
+ /**
18
+ * Resolve an explicit `--provider` value. An unknown id is reported to stderr
19
+ * and returns null so the command exits 1; absent means no provider filter.
20
+ */
21
+ export declare function resolveCliProviderId(requested: string | undefined, stderr: Pick<NodeJS.WriteStream, "write">): string | undefined | null;
17
22
  /**
18
23
  * Builds one `show` or `status` report in this process, for the folder the command runs in,
19
24
  * and prints it. It works with OpenCode closed: logins are read read-only from OpenCode's
@@ -6,7 +6,7 @@ import { DEFAULT_KIMI_AUTH_CACHE_MAX_AGE_MS, resolveKimiCnAuthCached, resolveKim
6
6
  import { bindCredentialSource } from "./opencode-auth.js";
7
7
  import { createSqliteCredentialSource } from "./opencode-auth-sqlite.js";
8
8
  import { loadConfiguredOpenCodeConfig, loadConfiguredProviderIds, } from "./opencode-config-providers.js";
9
- import { getQuotaProviderShape } from "./provider-metadata.js";
9
+ import { getQuotaProviderRegistration } from "./provider-metadata.js";
10
10
  import { resolveQuotaRuntimeContext } from "./quota-runtime-context.js";
11
11
  const SHOW_USAGE = [
12
12
  "Usage:",
@@ -155,6 +155,19 @@ export function createCliQuotaClient(params) {
155
155
  function writeLine(stream, message) {
156
156
  stream.write(message.endsWith("\n") ? message : `${message}\n`);
157
157
  }
158
+ /**
159
+ * Resolve an explicit `--provider` value. An unknown id is reported to stderr
160
+ * and returns null so the command exits 1; absent means no provider filter.
161
+ */
162
+ export function resolveCliProviderId(requested, stderr) {
163
+ if (requested === undefined)
164
+ return undefined;
165
+ const resolved = getQuotaProviderRegistration(requested)?.id;
166
+ if (resolved !== undefined)
167
+ return resolved;
168
+ writeLine(stderr, `Unknown provider: ${requested}`);
169
+ return null;
170
+ }
158
171
  /**
159
172
  * Builds one `show` or `status` report in this process, for the folder the command runs in,
160
173
  * and prints it. It works with OpenCode closed: logins are read read-only from OpenCode's
@@ -197,11 +210,9 @@ export async function runCliShowCommand(options = {}) {
197
210
  writeLine(stdout, SHOW_USAGE);
198
211
  return 0;
199
212
  }
200
- const providerId = parsed.providerId ? getQuotaProviderShape(parsed.providerId)?.id : undefined;
201
- if (parsed.providerId && !providerId) {
202
- writeLine(stderr, `Unknown provider: ${parsed.providerId}`);
213
+ const providerId = resolveCliProviderId(parsed.providerId, stderr);
214
+ if (providerId === null)
203
215
  return 1;
204
- }
205
216
  return runCliReport({
206
217
  cwd: options.cwd ?? process.cwd(),
207
218
  failurePrefix: "Failed to show quota",
@@ -1,6 +1,5 @@
1
1
  import { buildCliStatus } from "./cli-reports.js";
2
- import { runCliReport } from "./cli-show.js";
3
- import { getQuotaProviderShape } from "./provider-metadata.js";
2
+ import { resolveCliProviderId, runCliReport } from "./cli-show.js";
4
3
  const STATUS_USAGE = [
5
4
  "Usage:",
6
5
  " npx opencode-quota-gui status [--provider <provider-id>] [--json]",
@@ -82,11 +81,9 @@ export async function runCliStatusCommand(options = {}) {
82
81
  writeLine(stdout, STATUS_USAGE);
83
82
  return 0;
84
83
  }
85
- const providerId = parsed.providerId ? getQuotaProviderShape(parsed.providerId)?.id : undefined;
86
- if (parsed.providerId && !providerId) {
87
- writeLine(stderr, `Unknown provider: ${parsed.providerId}`);
84
+ const providerId = resolveCliProviderId(parsed.providerId, stderr);
85
+ if (providerId === null)
88
86
  return 1;
89
- }
90
87
  return runCliReport({
91
88
  cwd: options.cwd ?? process.cwd(),
92
89
  failurePrefix: "Failed to generate quota status",
@@ -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", "nativeQuotaNotifications", "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"];
24
+ export declare const QUOTA_TOAST_SETTING_SOURCE_KEYS: readonly ["enabled", "enableToast", "resetNotifications.enabled", "resetNotifications.windows", "nativeQuotaNotifications", "lowQuotaThresholdRemainingPercent", "duplicateCooldownMinutes", "tuiCommandDisplay", "formatStyle", "percentDisplayMode", "quotaProjection", "percentLabelStyle", "accountingDetail", "resetTimeDecimals", "resetTimeSpaced", "minIntervalMs", "claudeAgentPollIntervalMs", "requestTimeoutMs", "debug", "enabledProviders", "quotaProviders", "anthropicBinaryPath", "cursorPlan", "cursorIncludedApiUsd", "cursorBillingCycleStartDay", "opencodeGoWindows", "opencodeMonthlyLimit", "pricingSnapshot.source", "pricingSnapshot.autoRefresh", "showOnIdle", "showOnQuestion", "showOnCompact", "showOnBothFail", "toastDurationMs", "onlyCurrentModel", "waitForQuotaReset", "autoResumeOnQuotaRecovery", "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.rowOrder", "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 {
@@ -10,11 +10,12 @@
10
10
  */
11
11
  import { existsSync, realpathSync } from "fs";
12
12
  import { join } from "path";
13
+ import { ANTHROPIC_OAUTH_MIN_POLL_INTERVAL_MS } from "./anthropic-oauth-throttle.js";
13
14
  import { DASHBOARD_HIDDEN_CARDS_VERSION, normalizeLegacyDashboardHiddenCards, } from "./dashboard-visibility.js";
14
15
  import { isResetTimeDecimals } from "./format-utils.js";
15
16
  import { buildOpenCodeConfigCandidates, readOpenCodeConfigCandidate, } from "./opencode-config-read.js";
16
17
  import { getOpencodeRuntimeDirs } from "./opencode-runtime-paths.js";
17
- import { getQuotaProviderShape, normalizeQuotaProviderId } from "./provider-metadata.js";
18
+ import { getQuotaProviderRegistration, normalizeQuotaProviderId } from "./provider-metadata.js";
18
19
  import { isQuotaFormatStyle, resolveQuotaFormatStyle } from "./quota-format-style.js";
19
20
  import { cloneQuotaProviders, validateQuotaProviders } from "./quota-providers.js";
20
21
  import { DASHBOARD_HIDDEN_ID_LIMIT, DEFAULT_CONFIG } from "./types.js";
@@ -54,6 +55,7 @@ export const QUOTA_TOAST_SETTING_SOURCE_KEYS = [
54
55
  "resetTimeDecimals",
55
56
  "resetTimeSpaced",
56
57
  "minIntervalMs",
58
+ "claudeAgentPollIntervalMs",
57
59
  "requestTimeoutMs",
58
60
  "debug",
59
61
  "enabledProviders",
@@ -73,6 +75,7 @@ export const QUOTA_TOAST_SETTING_SOURCE_KEYS = [
73
75
  "toastDurationMs",
74
76
  "onlyCurrentModel",
75
77
  "waitForQuotaReset",
78
+ "autoResumeOnQuotaRecovery",
76
79
  "showSessionTokens",
77
80
  "sessionTokenScope",
78
81
  "tuiSidebarPanel.enabled",
@@ -100,6 +103,7 @@ export const QUOTA_TOAST_SETTING_SOURCE_KEYS = [
100
103
  "dashboard.hiddenRows",
101
104
  "dashboard.providerOrder",
102
105
  "dashboard.cardOrder",
106
+ "dashboard.rowOrder",
103
107
  "dashboard.temporalProviderOverrides",
104
108
  ];
105
109
  export function createLoadConfigMeta() {
@@ -119,6 +123,7 @@ const NETWORK_SETTING_SOURCE_KEYS = [
119
123
  "enabledProviders",
120
124
  "quotaProviders",
121
125
  "minIntervalMs",
126
+ "claudeAgentPollIntervalMs",
122
127
  "requestTimeoutMs",
123
128
  "pricingSnapshot.source",
124
129
  "pricingSnapshot.autoRefresh",
@@ -260,6 +265,7 @@ function cloneConfig(config) {
260
265
  hiddenRows: [...config.dashboard.hiddenRows],
261
266
  providerOrder: [...config.dashboard.providerOrder],
262
267
  cardOrder: [...config.dashboard.cardOrder],
268
+ rowOrder: Object.fromEntries(Object.entries(config.dashboard.rowOrder).map(([cardId, ids]) => [cardId, [...ids]])),
263
269
  temporalProviderOverrides: { ...config.dashboard.temporalProviderOverrides },
264
270
  },
265
271
  };
@@ -455,7 +461,7 @@ export function normalizeEnabledProviders(value) {
455
461
  continue;
456
462
  }
457
463
  const normalized = normalizeQuotaProviderId(provider);
458
- if (normalized && getQuotaProviderShape(normalized)) {
464
+ if (normalized && getQuotaProviderRegistration(normalized)) {
459
465
  validProviders.push(normalized);
460
466
  }
461
467
  else {
@@ -621,6 +627,31 @@ function normalizeTemporalProviderOverrides(value) {
621
627
  }
622
628
  return Object.fromEntries(overrides);
623
629
  }
630
+ /**
631
+ * Sparse card → ordered row-id list. Each list is deduped and capped like the
632
+ * flat dashboard id lists; one malformed entry rejects the whole map, matching
633
+ * the temporal override semantics.
634
+ */
635
+ function normalizeRowOrder(value) {
636
+ if (!isPlainObject(value))
637
+ return undefined;
638
+ const entries = Object.entries(value);
639
+ if (entries.length > DASHBOARD_HIDDEN_ID_LIMIT)
640
+ return undefined;
641
+ const rowOrder = [];
642
+ for (const [cardId, ids] of entries) {
643
+ if (cardId.length === 0 || cardId.length > 512 || !Array.isArray(ids))
644
+ return undefined;
645
+ const normalized = [];
646
+ for (const id of ids) {
647
+ if (typeof id !== "string" || id.length === 0 || id.length > 512)
648
+ return undefined;
649
+ normalized.push(id);
650
+ }
651
+ rowOrder.push([cardId, dedupe(normalized).slice(0, DASHBOARD_HIDDEN_ID_LIMIT)]);
652
+ }
653
+ return Object.fromEntries(rowOrder);
654
+ }
624
655
  function extractDashboardPatch(value, reportIssue) {
625
656
  if (!isPlainObject(value)) {
626
657
  return undefined;
@@ -661,6 +692,8 @@ function extractDashboardPatch(value, reportIssue) {
661
692
  }
662
693
  // A layer without a v2 marker owns legacy semantics: a full provider-scope
663
694
  // card id meant the whole provider group. Version 2 preserves exact ids.
695
+ // Legacy aggregate row ids stay verbatim and resolve at render/notification
696
+ // time to the card's first emitted row, until Settings rewrites them.
664
697
  patch[key] =
665
698
  key === "hiddenCards" && value.hiddenCardsVersion !== DASHBOARD_HIDDEN_CARDS_VERSION
666
699
  ? normalizeLegacyDashboardHiddenCards(ids)
@@ -675,6 +708,15 @@ function extractDashboardPatch(value, reportIssue) {
675
708
  patch.temporalProviderOverrides = overrides;
676
709
  }
677
710
  }
711
+ if (hasOwnKey(value, "rowOrder")) {
712
+ const rowOrder = normalizeRowOrder(value.rowOrder);
713
+ if (rowOrder === undefined) {
714
+ reportIssue?.("dashboard.rowOrder", "expected an object of card ids mapped to row-id lists");
715
+ }
716
+ else {
717
+ patch.rowOrder = rowOrder;
718
+ }
719
+ }
678
720
  return Object.keys(patch).length > 0 ? patch : undefined;
679
721
  }
680
722
  function extractValidatedQuotaToastPatch(quotaToastConfig, reportIssue, options = {}) {
@@ -760,6 +802,10 @@ function extractValidatedQuotaToastPatch(quotaToastConfig, reportIssue, options
760
802
  isPositiveNumber(quotaToastConfig.minIntervalMs)) {
761
803
  patch.minIntervalMs = quotaToastConfig.minIntervalMs;
762
804
  }
805
+ if (hasOwnKey(quotaToastConfig, "claudeAgentPollIntervalMs") &&
806
+ isPositiveNumber(quotaToastConfig.claudeAgentPollIntervalMs)) {
807
+ patch.claudeAgentPollIntervalMs = Math.max(ANTHROPIC_OAUTH_MIN_POLL_INTERVAL_MS, quotaToastConfig.claudeAgentPollIntervalMs);
808
+ }
763
809
  if (hasOwnKey(quotaToastConfig, "requestTimeoutMs") &&
764
810
  isPositiveNumber(quotaToastConfig.requestTimeoutMs)) {
765
811
  patch.requestTimeoutMs = quotaToastConfig.requestTimeoutMs;
@@ -848,6 +894,10 @@ function extractValidatedQuotaToastPatch(quotaToastConfig, reportIssue, options
848
894
  typeof quotaToastConfig.waitForQuotaReset === "boolean") {
849
895
  patch.waitForQuotaReset = quotaToastConfig.waitForQuotaReset;
850
896
  }
897
+ if (hasOwnKey(quotaToastConfig, "autoResumeOnQuotaRecovery") &&
898
+ typeof quotaToastConfig.autoResumeOnQuotaRecovery === "boolean") {
899
+ patch.autoResumeOnQuotaRecovery = quotaToastConfig.autoResumeOnQuotaRecovery;
900
+ }
851
901
  if (hasOwnKey(quotaToastConfig, "showSessionTokens") &&
852
902
  typeof quotaToastConfig.showSessionTokens === "boolean") {
853
903
  patch.showSessionTokens = quotaToastConfig.showSessionTokens;
@@ -1023,6 +1073,10 @@ function applyValidatedQuotaToastPatch(config, patch, sourcePath, settingSources
1023
1073
  config.minIntervalMs = patch.minIntervalMs;
1024
1074
  applySettingSource(settingSources, "minIntervalMs", sourcePath);
1025
1075
  }
1076
+ if (hasOwnKey(patch, "claudeAgentPollIntervalMs")) {
1077
+ config.claudeAgentPollIntervalMs = Math.max(ANTHROPIC_OAUTH_MIN_POLL_INTERVAL_MS, patch.claudeAgentPollIntervalMs);
1078
+ applySettingSource(settingSources, "claudeAgentPollIntervalMs", sourcePath);
1079
+ }
1026
1080
  if (hasOwnKey(patch, "requestTimeoutMs")) {
1027
1081
  config.requestTimeoutMs = patch.requestTimeoutMs;
1028
1082
  applySettingSource(settingSources, "requestTimeoutMs", sourcePath);
@@ -1100,6 +1154,10 @@ function applyValidatedQuotaToastPatch(config, patch, sourcePath, settingSources
1100
1154
  config.waitForQuotaReset = patch.waitForQuotaReset;
1101
1155
  applySettingSource(settingSources, "waitForQuotaReset", sourcePath);
1102
1156
  }
1157
+ if (hasOwnKey(patch, "autoResumeOnQuotaRecovery")) {
1158
+ config.autoResumeOnQuotaRecovery = patch.autoResumeOnQuotaRecovery;
1159
+ applySettingSource(settingSources, "autoResumeOnQuotaRecovery", sourcePath);
1160
+ }
1103
1161
  if (hasOwnKey(patch, "showSessionTokens")) {
1104
1162
  config.showSessionTokens = patch.showSessionTokens;
1105
1163
  applySettingSource(settingSources, "showSessionTokens", sourcePath);
@@ -1222,6 +1280,10 @@ function applyValidatedQuotaToastPatch(config, patch, sourcePath, settingSources
1222
1280
  config.dashboard.cardOrder = [...patch.dashboard.cardOrder];
1223
1281
  applySettingSource(settingSources, "dashboard.cardOrder", sourcePath);
1224
1282
  }
1283
+ if (patch.dashboard.rowOrder) {
1284
+ config.dashboard.rowOrder = Object.fromEntries(Object.entries(patch.dashboard.rowOrder).map(([cardId, ids]) => [cardId, [...ids]]));
1285
+ applySettingSource(settingSources, "dashboard.rowOrder", sourcePath);
1286
+ }
1225
1287
  if (patch.dashboard.temporalProviderOverrides) {
1226
1288
  config.dashboard.temporalProviderOverrides = {
1227
1289
  ...patch.dashboard.temporalProviderOverrides,
@@ -10,4 +10,9 @@ export declare function dashboardProviderScopeHash(providerId: string): string;
10
10
  export declare function legacyProviderIdForScopeCardId(id: string): string | undefined;
11
11
  /** Deterministic legacy (v1) hiddenCards normalization, preserving first-seen order. */
12
12
  export declare function normalizeLegacyDashboardHiddenCards(ids: readonly string[]): string[];
13
+ /**
14
+ * Row ids saved before per-window semantics are resolved against the live card
15
+ * at render/notification time in `src/contracts/row-visibility.ts`. They are
16
+ * intentionally preserved verbatim here until an explicit Settings toggle.
17
+ */
13
18
  //# sourceMappingURL=dashboard-visibility.d.ts.map
@@ -1,23 +1,19 @@
1
1
  /**
2
- * Persisted semantics for `dashboard.hiddenCards` (backend-only helpers).
2
+ * Persisted semantics for `dashboard.hiddenCards` and `dashboard.hiddenRows`
3
+ * (backend-only helpers).
3
4
  *
4
5
  * Version 1 (implicit, no marker) treated a provider-scope card id as a
5
6
  * provider-wide hide. Version 2 treats every hiddenCards entry as an exact card
6
7
  * id, while a plain provider id and the legacy bare provider-scope hash remain
7
- * provider-wide forms. The domain and identity-key literals below are pinned to
8
- * `src/gui/identity.ts` by the backend tests; importing GUI identity (and its
9
- * node:crypto hash) from this layer would couple config loading to the GUI.
8
+ * provider-wide forms. The card/row identity helpers live in
9
+ * `src/contracts/identity.ts` so this layer and the GUI share one hash.
10
10
  */
11
- import { createHash } from "node:crypto";
11
+ import { hashQuotaCardIdentity, PROVIDER_SCOPE_IDENTITY_KEY } from "./quota-identity.js";
12
12
  export const DASHBOARD_HIDDEN_CARDS_VERSION = 2;
13
- const CARD_HASH_DOMAIN = "ocq-card-v1";
14
- const PROVIDER_SCOPE_IDENTITY_KEY = "provider";
15
13
  const CARD_HASH_RE = /^[0-9a-f]{64}$/u;
16
14
  /** The provider-scope hash exactly as `buildProviderScopeCardId` derives it. */
17
15
  export function dashboardProviderScopeHash(providerId) {
18
- return createHash("sha256")
19
- .update(`${CARD_HASH_DOMAIN}\0${providerId}\0${PROVIDER_SCOPE_IDENTITY_KEY}`, "utf8")
20
- .digest("hex");
16
+ return hashQuotaCardIdentity(providerId, PROVIDER_SCOPE_IDENTITY_KEY);
21
17
  }
22
18
  /**
23
19
  * Converts one legacy provider-scope card id to its provider id. Only a full
@@ -48,4 +44,9 @@ export function normalizeLegacyDashboardHiddenCards(ids) {
48
44
  }
49
45
  return normalized;
50
46
  }
47
+ /**
48
+ * Row ids saved before per-window semantics are resolved against the live card
49
+ * at render/notification time in `src/contracts/row-visibility.ts`. They are
50
+ * intentionally preserved verbatim here until an explicit Settings toggle.
51
+ */
51
52
  //# sourceMappingURL=dashboard-visibility.js.map
@@ -104,6 +104,7 @@ export function sanitizeQuotaToastError(error) {
104
104
  label: sanitizeDisplayText(error.label),
105
105
  message: sanitizeDisplayText(error.message),
106
106
  ...(error.retryAtMs !== undefined ? { retryAtMs: error.retryAtMs } : {}),
107
+ ...(error.attemptOutcome !== undefined ? { attemptOutcome: error.attemptOutcome } : {}),
107
108
  ...(error.retryable === true ? { retryable: true } : {}),
108
109
  ...(error.failureCategory !== undefined ? { failureCategory: error.failureCategory } : {}),
109
110
  ...(error.kind ? { kind: error.kind } : {}),
@@ -1,5 +1,5 @@
1
1
  import type { BankedResetAvailability } from "../contracts/openai-quota.js";
2
- import type { ProviderFailureCategory } from "../contracts/provider-failure.js";
2
+ import type { ProviderFailureCategory, QuotaAttemptOutcome } from "../contracts/provider-failure.js";
3
3
  import type { QuotaProviderDefinition } from "./quota-providers.js";
4
4
  import type { QuotaTelemetryToken } from "./quota-telemetry.js";
5
5
  import type { ResolvedAuthIdentity } from "./resolved-auth-identity.js";
@@ -162,6 +162,8 @@ export declare function isPercentEntry(e: QuotaToastEntry): e is QuotaPercentEnt
162
162
  export declare function cloneAccountingUnit(unit: AccountingUnit): AccountingUnit;
163
163
  export declare function cloneAccountingQuantity(quantity: AccountingQuantity): AccountingQuantity;
164
164
  export declare function cloneAccountingSemantic(semantic: AccountingSemantic): AccountingSemantic;
165
+ /** The one typed-window semantic builder every provider window mapping must use. */
166
+ export declare function windowSemantic(window: AccountingWindow, prominence?: AccountingProminence): AccountingSemantic;
165
167
  export declare function cloneAccountingBasisFact(fact: AccountingBasisFact): AccountingBasisFact;
166
168
  export declare function cloneAccountingPercentageBasis(basis: AccountingPercentageBasis): AccountingPercentageBasis;
167
169
  export declare function cloneBankedResetAvailability(bankedResets: BankedResetAvailability): BankedResetAvailability;
@@ -169,6 +171,11 @@ export declare function cloneQuotaToastEntry(entry: QuotaToastEntry): QuotaToast
169
171
  export interface QuotaToastError {
170
172
  /** Deadline observed in an upstream Retry-After response. */
171
173
  retryAtMs?: number;
174
+ /**
175
+ * Outcome of the attempt that produced this error. A `cooldown` skip made no
176
+ * request, so it is not a failure observation. Absence means unknown.
177
+ */
178
+ attemptOutcome?: QuotaAttemptOutcome;
172
179
  /** Short label that will be rendered as "label: message". */
173
180
  label: string;
174
181
  message: string;
@@ -335,6 +342,8 @@ export interface QuotaProviderContext {
335
342
  workspaceRoot: string;
336
343
  config: {
337
344
  anthropicBinaryPath?: string;
345
+ /** Minimum spacing between Claude Agent usage requests, shared by processes. */
346
+ claudeAgentPollIntervalMs?: number;
338
347
  cursorPlan: CursorQuotaPlan;
339
348
  cursorIncludedApiUsd?: number;
340
349
  cursorBillingCycleStartDay?: number;
@@ -29,6 +29,10 @@ export function cloneAccountingQuantity(quantity) {
29
29
  export function cloneAccountingSemantic(semantic) {
30
30
  return { metric: { ...semantic.metric }, prominence: semantic.prominence };
31
31
  }
32
+ /** The one typed-window semantic builder every provider window mapping must use. */
33
+ export function windowSemantic(window, prominence = "primary") {
34
+ return { metric: { kind: "window", window }, prominence };
35
+ }
32
36
  export function cloneAccountingBasisFact(fact) {
33
37
  return { quantity: cloneAccountingQuantity(fact.quantity), authority: fact.authority };
34
38
  }
@@ -58,7 +58,7 @@ function normalizeGroupedQuotaEntry(entry, target) {
58
58
  return {
59
59
  ...normalized,
60
60
  group: owned.name.trim(),
61
- ...(target === "quota" ? { label: label ?? "Status:" } : {}),
61
+ ...(target === "quota" && !owned.semantic ? { label: label ?? "Status:" } : {}),
62
62
  };
63
63
  }
64
64
  function sortLegacyEntries(entries) {
@@ -1,4 +1,4 @@
1
- import { getQuotaProviderShape, normalizeQuotaProviderId, } from "./provider-metadata.js";
1
+ import { getQuotaProviderRegistration, normalizeQuotaProviderId, } from "./provider-metadata.js";
2
2
  export const BUNDLED_MAINTAINER_ANNOUNCEMENTS = [
3
3
  {
4
4
  id: "opencode-ecosystem-listing-support",
@@ -38,7 +38,7 @@ function normalizedProviderIds(providerIds) {
38
38
  const out = [];
39
39
  const seen = new Set();
40
40
  for (const providerId of providerIds) {
41
- const shape = getQuotaProviderShape(normalizeQuotaProviderId(providerId));
41
+ const shape = getQuotaProviderRegistration(normalizeQuotaProviderId(providerId));
42
42
  if (!shape || seen.has(shape.id)) {
43
43
  continue;
44
44
  }
@@ -52,16 +52,44 @@ export type PricingSnapshotHealth = {
52
52
  maxAgeMs: number;
53
53
  stale: boolean;
54
54
  };
55
+ /**
56
+ * One recorded models.dev request. Automatic entries consume the rolling 24h
57
+ * budget; manual `force` refreshes are recorded but stay outside it.
58
+ */
59
+ export interface PricingRefreshAttempt {
60
+ at: number;
61
+ automatic: boolean;
62
+ /** Distinguishes reservations made in the same millisecond. */
63
+ id?: string;
64
+ }
55
65
  export interface PricingRefreshStateV1 {
56
66
  version: 1;
57
67
  updatedAt: number;
58
68
  lastAttemptAt?: number;
59
69
  lastSuccessAt?: number;
60
70
  lastFailureAt?: number;
61
- lastResult?: "success" | "not_modified" | "skipped_fresh" | "skipped_throttled" | "failed";
71
+ lastResult?: "success" | "not_modified" | "skipped_fresh" | "skipped_throttled" | "skipped_budget" | "failed";
62
72
  lastError?: string;
63
73
  etag?: string;
64
74
  lastModified?: string;
75
+ /** Every automatic and manual network request inside the rolling 24h. */
76
+ attempts24h?: PricingRefreshAttempt[];
77
+ /**
78
+ * Unpriced routes already checked against the catalog identity in `key`.
79
+ * A route missing here for the current identity may bypass the minimum
80
+ * automatic attempt interval once; the rolling 24h budget still applies.
81
+ */
82
+ unpricedChecked?: PricingRouteChecks;
83
+ /**
84
+ * Unpriced routes that already spent their one throttle bypass for the
85
+ * catalog identity in `key`. A failed attempt still counts, so retries obey
86
+ * the ordinary minimum interval instead of burning the daily budget.
87
+ */
88
+ unpricedBypassUsed?: PricingRouteChecks;
89
+ }
90
+ export interface PricingRouteChecks {
91
+ key: string;
92
+ routes: string[];
65
93
  }
66
94
  export interface PricingRefreshPolicy {
67
95
  enabled: boolean;
@@ -70,7 +98,7 @@ export interface PricingRefreshPolicy {
70
98
  timeoutMs: number;
71
99
  }
72
100
  export interface PricingRefreshOptions {
73
- reason?: "init" | "tokens" | "status" | "manual";
101
+ reason?: "init" | "tokens" | "status" | "manual" | "unpriced";
74
102
  force?: boolean;
75
103
  nowMs?: number;
76
104
  maxAgeMs?: number;
@@ -83,6 +111,20 @@ export interface PricingRefreshOptions {
83
111
  providerAllowlist?: string[];
84
112
  snapshotSelection?: PricingSnapshotSource;
85
113
  allowRefreshWhenSelectionBundled?: boolean;
114
+ /**
115
+ * Skip the max-age check for an unpriced-triggered attempt. The rolling
116
+ * budget always applies; the 6h throttle applies unless `unpricedRouteKeys`
117
+ * contains a route not yet checked against the current catalog identity.
118
+ */
119
+ refreshEvenIfFresh?: boolean;
120
+ /**
121
+ * Unpriced routes (see `pricingRouteKey`) the caller observed. A route with
122
+ * no recorded check and no spent throttle bypass for the current catalog
123
+ * identity may skip the 6h throttle once; later observations stay throttled.
124
+ */
125
+ unpricedRouteKeys?: readonly string[];
126
+ /** Cross-process budget-lock wait; expired means skip the attempt. */
127
+ lockTimeoutMs?: number;
86
128
  }
87
129
  export interface PricingRefreshResult {
88
130
  attempted: boolean;
@@ -95,8 +137,38 @@ export declare function getPricingRefreshPolicy(): PricingRefreshPolicy;
95
137
  export declare function setPricingSnapshotAutoRefresh(days: number): void;
96
138
  export declare function getRuntimePricingSnapshotPath(runtimeDirs?: OpencodeRuntimeDirs): string;
97
139
  export declare function getRuntimePricingRefreshStatePath(runtimeDirs?: OpencodeRuntimeDirs): string;
140
+ /**
141
+ * Adopt a runtime snapshot rewritten by another process (the plugin host, or
142
+ * this worker's own refresh). A fresh `_meta` object is what invalidates the
143
+ * analytics pricing fingerprint and its derived presentation caches.
144
+ */
145
+ export declare function reloadPricingSnapshotFromDisk(params?: {
146
+ runtimeDirs?: OpencodeRuntimeDirs;
147
+ bootstrapSnapshotOverride?: PricingSnapshot;
148
+ }): void;
98
149
  export declare function readPricingRefreshState(runtimeDirs?: OpencodeRuntimeDirs): Promise<PricingRefreshStateV1 | null>;
150
+ export type PricingRoute = {
151
+ providerID?: string;
152
+ modelID?: string;
153
+ };
99
154
  export declare function maybeRefreshPricingSnapshot(opts?: PricingRefreshOptions): Promise<PricingRefreshResult>;
155
+ /**
156
+ * Event-driven analytics pricing upkeep: adopt an externally refreshed runtime
157
+ * snapshot, run the normal freshness refresh, and give one extra attempt when a
158
+ * route used by Analytics is still unpriced or unknown. A route not yet checked
159
+ * against the current catalog identity gets one throttle bypass per identity;
160
+ * every attempt still obeys the rolling 24h automatic request budget, and a
161
+ * bundled selection never refreshes. Cheap re-entry: unchanged unpriced routes
162
+ * inside the check interval do no I/O.
163
+ */
164
+ export declare function refreshAnalyticsPricing(opts?: {
165
+ routes?: readonly PricingRoute[];
166
+ nowMs?: number;
167
+ runtimeDirs?: OpencodeRuntimeDirs;
168
+ fetchFn?: typeof fetch;
169
+ bootstrapSnapshotOverride?: PricingSnapshot;
170
+ snapshotSelection?: PricingSnapshotSource;
171
+ }): Promise<PricingRefreshResult | undefined>;
100
172
  export declare function setPricingSnapshotSelection(selection: PricingSnapshotSource): void;
101
173
  export declare function getPricingSnapshotSelection(): PricingSnapshotSource;
102
174
  export declare function getPricingSnapshotMeta(): PricingSnapshot["_meta"];