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
@@ -1,11 +1,11 @@
1
- import type { AccountingMetric } from "./dashboard.js";
1
+ import type { AccountingMetric, AccountingResultType } from "./dashboard.js";
2
2
  /**
3
3
  * Identity seam (design spec §5, §8, R20).
4
4
  *
5
- * Contracts only carry the opaque id types and the stable row-key builder.
6
- * The server-side hash of (`providerId`, `identityKey`) lives in
7
- * `src/gui/identity.ts`: nothing here hashes, and raw ids never reach the
8
- * browser.
5
+ * Browser-safe contracts: the opaque id types and the stable row-key builder.
6
+ * The server-side card hash and entry-visibility helper live in
7
+ * `./quota-identity.ts` so neither the lib nor the GUI layer imports the other,
8
+ * and the browser bundle never pulls in `node:crypto`.
9
9
  */
10
10
  declare const cardIdBrand: unique symbol;
11
11
  declare const rowIdBrand: unique symbol;
@@ -33,9 +33,41 @@ export type RowKeyInput = AccountingMetric | {
33
33
  };
34
34
  /** Stable-`rowKey` builder type (no hashing; the card hash is server-side). */
35
35
  export type RowKeyBuilder = (input: RowKeyInput) => RowKey;
36
+ /** The minimal entry identity fields; real `QuotaToastEntry` values are assignable. */
37
+ export interface QuotaRowIdentityEntry {
38
+ readonly semantic?: {
39
+ readonly metric: AccountingMetric;
40
+ readonly prominence: "primary" | "supplementary";
41
+ };
42
+ readonly rowKey?: string;
43
+ readonly kind?: "percent" | "value" | "quantity" | "boolean";
44
+ readonly accounting: {
45
+ readonly resultType: AccountingResultType;
46
+ };
47
+ }
36
48
  /** Builds a deterministic row key from a typed semantic key. */
37
49
  export declare function buildRowKey(input: RowKeyInput): RowKey;
38
50
  /** Composes `rowId = cardId + "#" + rowKey` (R20). */
39
51
  export declare function composeRowId(cardId: CardId, rowKey: RowKey): RowId;
52
+ /**
53
+ * Stable typed row key: the entry's semantic metric (window/component/named) or
54
+ * its provider-supplied `rowKey`, plus the `resultType:kind` discriminator so
55
+ * rows that share a metric but mean different things stay distinct. Never a
56
+ * display label or an ordinal, so a rename cannot change a row id.
57
+ */
58
+ export declare function rowKeyForEntry(entry: QuotaRowIdentityEntry): RowKey;
59
+ /** `rowId = cardId + "#" + rowKey` (R20). */
60
+ export declare function rowIdForEntry(cardId: CardId, entry: QuotaRowIdentityEntry): RowId;
61
+ /**
62
+ * Row id for a declared optional field. `kind` must match the live row's
63
+ * render shape so hiding the Settings eye also hides the emitted row.
64
+ */
65
+ export declare function optionalRowId(cardId: CardId, rowKey: string, resultType: AccountingResultType, kind?: "percent" | "value" | "quantity" | "boolean"): RowId;
66
+ /**
67
+ * The typed field key inside a row id (`cardId#<field>|<resultType>:<kind>`).
68
+ * Used only to keep one Settings entry per field when a provider emits the same
69
+ * field in a different render shape than its declaration describes.
70
+ */
71
+ export declare function rowFieldKey(rowId: string): string;
40
72
  export {};
41
73
  //# sourceMappingURL=identity.d.ts.map
@@ -24,4 +24,47 @@ export function composeRowId(cardId, rowKey) {
24
24
  // SAFETY: RowId is the opaque brand of exactly `cardId + "#" + rowKey`.
25
25
  return `${cardId}#${rowKey}`;
26
26
  }
27
+ function baseRowKeyOf(entry) {
28
+ if (entry.semantic)
29
+ return buildRowKey(entry.semantic.metric);
30
+ if (entry.rowKey)
31
+ return buildRowKey({ kind: "explicit", key: entry.rowKey });
32
+ return buildRowKey({ kind: "aggregate" });
33
+ }
34
+ /**
35
+ * Stable typed row key: the entry's semantic metric (window/component/named) or
36
+ * its provider-supplied `rowKey`, plus the `resultType:kind` discriminator so
37
+ * rows that share a metric but mean different things stay distinct. Never a
38
+ * display label or an ordinal, so a rename cannot change a row id.
39
+ */
40
+ export function rowKeyForEntry(entry) {
41
+ const base = baseRowKeyOf(entry);
42
+ const kind = entry.kind === undefined || entry.kind === "percent" ? "percent" : entry.kind;
43
+ return buildRowKey({ kind: "explicit", key: `${base}|${entry.accounting.resultType}:${kind}` });
44
+ }
45
+ /** `rowId = cardId + "#" + rowKey` (R20). */
46
+ export function rowIdForEntry(cardId, entry) {
47
+ return composeRowId(cardId, rowKeyForEntry(entry));
48
+ }
49
+ /**
50
+ * Row id for a declared optional field. `kind` must match the live row's
51
+ * render shape so hiding the Settings eye also hides the emitted row.
52
+ */
53
+ export function optionalRowId(cardId, rowKey, resultType, kind = "value") {
54
+ const entry = kind === "percent"
55
+ ? { rowKey, accounting: { resultType } }
56
+ : { rowKey, kind, accounting: { resultType } };
57
+ return rowIdForEntry(cardId, entry);
58
+ }
59
+ /**
60
+ * The typed field key inside a row id (`cardId#<field>|<resultType>:<kind>`).
61
+ * Used only to keep one Settings entry per field when a provider emits the same
62
+ * field in a different render shape than its declaration describes.
63
+ */
64
+ export function rowFieldKey(rowId) {
65
+ const hash = rowId.indexOf("#");
66
+ const key = hash >= 0 ? rowId.slice(hash + 1) : rowId;
67
+ const discriminator = key.lastIndexOf("|");
68
+ return discriminator >= 0 ? key.slice(0, discriminator) : key;
69
+ }
27
70
  //# sourceMappingURL=identity.js.map
@@ -30,5 +30,8 @@ export declare const OPENAI_RESETS_ROW_LABEL = "Resets";
30
30
  export declare const OPENAI_CREDITS_ROW_LABEL = "Credits";
31
31
  /** Exact owner-approved info copy, shown immediately next to the row label. */
32
32
  export declare const OPENAI_RESETS_INFO = "Shown only when OpenAI reports one or more available banked resets.";
33
+ /** Claude Agent reuses the same Resets row; only its stable key and info copy differ. */
34
+ export declare const CLAUDE_AGENT_RESETS_ROW_KEY = "claude-agent:resets";
35
+ export declare const CLAUDE_AGENT_RESETS_INFO = "Shown only when Claude Agent reports one or more available saved resets.";
33
36
  export declare const OPENAI_CREDITS_INFO = "Shown only when OpenAI reports a positive credit balance or unlimited credits.";
34
37
  //# sourceMappingURL=openai-quota.d.ts.map
@@ -15,5 +15,8 @@ export const OPENAI_RESETS_ROW_LABEL = "Resets";
15
15
  export const OPENAI_CREDITS_ROW_LABEL = "Credits";
16
16
  /** Exact owner-approved info copy, shown immediately next to the row label. */
17
17
  export const OPENAI_RESETS_INFO = "Shown only when OpenAI reports one or more available banked resets.";
18
+ /** Claude Agent reuses the same Resets row; only its stable key and info copy differ. */
19
+ export const CLAUDE_AGENT_RESETS_ROW_KEY = "claude-agent:resets";
20
+ export const CLAUDE_AGENT_RESETS_INFO = "Shown only when Claude Agent reports one or more available saved resets.";
18
21
  export const OPENAI_CREDITS_INFO = "Shown only when OpenAI reports a positive credit balance or unlimited credits.";
19
22
  //# sourceMappingURL=openai-quota.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Providers that can supply auto-resume evidence, in provider-registration
3
+ * order. Settings help copy is browser-layer code and must not import the
4
+ * provider metadata module, so the labels are mirrored here for that one
5
+ * string. `tests/lib.provider-metadata.test.ts` fails if this list drifts from
6
+ * the registration metadata's `autoResume` bindings.
7
+ */
8
+ export declare const AUTO_RESUME_SUPPORTED_PROVIDER_LABELS: readonly ["Claude Agent", "Copilot", "OpenAI", "Synthetic", "Chutes", "Z.ai", "Zhipu", "NanoGPT", "MiniMax Token Plan", "MiniMax Token Plan (CN)", "xAI", "OpenCode Go", "OpenCode Zen", "Ollama Cloud"];
9
+ //# sourceMappingURL=provider-auto-resume.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Providers that can supply auto-resume evidence, in provider-registration
3
+ * order. Settings help copy is browser-layer code and must not import the
4
+ * provider metadata module, so the labels are mirrored here for that one
5
+ * string. `tests/lib.provider-metadata.test.ts` fails if this list drifts from
6
+ * the registration metadata's `autoResume` bindings.
7
+ */
8
+ export const AUTO_RESUME_SUPPORTED_PROVIDER_LABELS = [
9
+ "Claude Agent",
10
+ "Copilot",
11
+ "OpenAI",
12
+ "Synthetic",
13
+ "Chutes",
14
+ "Z.ai",
15
+ "Zhipu",
16
+ "NanoGPT",
17
+ "MiniMax Token Plan",
18
+ "MiniMax Token Plan (CN)",
19
+ "xAI",
20
+ "OpenCode Go",
21
+ "OpenCode Zen",
22
+ "Ollama Cloud",
23
+ ];
24
+ //# sourceMappingURL=provider-auto-resume.js.map
@@ -8,11 +8,33 @@
8
8
  export declare const PROVIDER_FAILURE_CATEGORIES: readonly ["provider_api", "credentials", "discovery", "local"];
9
9
  export type ProviderFailureCategory = (typeof PROVIDER_FAILURE_CATEGORIES)[number];
10
10
  export declare function isProviderFailureCategory(value: unknown): value is ProviderFailureCategory;
11
+ /**
12
+ * Failures a later poll can recover from without re-authenticating. The account is unchanged, so
13
+ * the last measured quota stays valid (marked stale) instead of being discarded.
14
+ */
15
+ export declare function isTransientProviderFailureCategory(value: ProviderFailureCategory | undefined): boolean;
11
16
  export type ProviderHttpFailureCategory = Extract<ProviderFailureCategory, "credentials" | "provider_api">;
17
+ /**
18
+ * The outcome of one provider attempt, separate from whether an older
19
+ * measurement is still displayable:
20
+ *
21
+ * - `fresh` the attempt completed and produced a new measurement;
22
+ * - `reuse` no request was made because a recent measurement is still
23
+ * within its reuse window; the measurement keeps its own time;
24
+ * - `cooldown` no request was made because this process is honoring an
25
+ * already-known rate-limit deadline; this is not a new failure;
26
+ * - `transient` the request was made and failed in a way a later poll may
27
+ * recover from;
28
+ * - `credentials` the request was rejected as unauthenticated/unauthorized.
29
+ */
30
+ declare const QUOTA_ATTEMPT_OUTCOMES: readonly ["fresh", "reuse", "cooldown", "transient", "credentials"];
31
+ export type QuotaAttemptOutcome = (typeof QUOTA_ATTEMPT_OUTCOMES)[number];
32
+ export declare function isQuotaAttemptOutcome(value: unknown): value is QuotaAttemptOutcome;
12
33
  /**
13
34
  * HTTP 401/403 is an authentication/authorization outcome; every other failed
14
35
  * response is a provider API failure. Callers must only use this at an actual
15
36
  * request/response boundary.
16
37
  */
17
38
  export declare function providerFailureCategoryForHttpStatus(status: number): ProviderHttpFailureCategory;
39
+ export {};
18
40
  //# sourceMappingURL=provider-failure.d.ts.map
@@ -12,7 +12,31 @@ export const PROVIDER_FAILURE_CATEGORIES = [
12
12
  "local",
13
13
  ];
14
14
  export function isProviderFailureCategory(value) {
15
- return (typeof value === "string" && PROVIDER_FAILURE_CATEGORIES.includes(value));
15
+ return PROVIDER_FAILURE_CATEGORIES.some((category) => category === value);
16
+ }
17
+ /**
18
+ * Failures a later poll can recover from without re-authenticating. The account is unchanged, so
19
+ * the last measured quota stays valid (marked stale) instead of being discarded.
20
+ */
21
+ export function isTransientProviderFailureCategory(value) {
22
+ return value === "provider_api" || value === "discovery" || value === "local";
23
+ }
24
+ /**
25
+ * The outcome of one provider attempt, separate from whether an older
26
+ * measurement is still displayable:
27
+ *
28
+ * - `fresh` the attempt completed and produced a new measurement;
29
+ * - `reuse` no request was made because a recent measurement is still
30
+ * within its reuse window; the measurement keeps its own time;
31
+ * - `cooldown` no request was made because this process is honoring an
32
+ * already-known rate-limit deadline; this is not a new failure;
33
+ * - `transient` the request was made and failed in a way a later poll may
34
+ * recover from;
35
+ * - `credentials` the request was rejected as unauthenticated/unauthorized.
36
+ */
37
+ const QUOTA_ATTEMPT_OUTCOMES = ["fresh", "reuse", "cooldown", "transient", "credentials"];
38
+ export function isQuotaAttemptOutcome(value) {
39
+ return QUOTA_ATTEMPT_OUTCOMES.some((outcome) => outcome === value);
16
40
  }
17
41
  /**
18
42
  * HTTP 401/403 is an authentication/authorization outcome; every other failed
@@ -0,0 +1,13 @@
1
+ import { type RowVisibilityControl } from "./row-visibility.js";
2
+ /**
3
+ * Returns a fresh row array ordered for presentation.
4
+ *
5
+ * - A non-empty saved order lists preferred rows first, in saved order; every
6
+ * other row (new, or never reordered) follows in stable input (emission)
7
+ * order. Unknown and duplicate preference ids are ignored.
8
+ * - An absent or empty saved order keeps stable input order.
9
+ * - With `controls`, a saved order saved under an alternate emitted shape and a
10
+ * row rendered in another shape resolve to the same stable control id.
11
+ */
12
+ export declare function orderRowsByPreference<T>(rows: readonly T[], rowOrder?: readonly string[], idOf?: (row: T) => string, controls?: readonly RowVisibilityControl[]): T[];
13
+ //# sourceMappingURL=row-order.d.ts.map
@@ -0,0 +1,34 @@
1
+ import { rankByIds, stableSortByRank } from "./card-order.js";
2
+ import { rowControlId, rowOrderForControls } from "./row-visibility.js";
3
+ /**
4
+ * Presentation-only row ordering shared by the backend card projection and the
5
+ * Settings visibility list.
6
+ *
7
+ * Like `card-order`, this module is dependency-free and opaque-id-only: it never
8
+ * interprets an id, never adds or removes a row, and never mutates its input.
9
+ * The caller assembles the real rows first, then asks for a display order, so a
10
+ * newly emitted row keeps its provider position after every listed row.
11
+ */
12
+ const UNKNOWN_RANK = Number.POSITIVE_INFINITY;
13
+ /**
14
+ * Returns a fresh row array ordered for presentation.
15
+ *
16
+ * - A non-empty saved order lists preferred rows first, in saved order; every
17
+ * other row (new, or never reordered) follows in stable input (emission)
18
+ * order. Unknown and duplicate preference ids are ignored.
19
+ * - An absent or empty saved order keeps stable input order.
20
+ * - With `controls`, a saved order saved under an alternate emitted shape and a
21
+ * row rendered in another shape resolve to the same stable control id.
22
+ */
23
+ export function orderRowsByPreference(rows, rowOrder,
24
+ // SAFETY: callers that omit idOf pass rows carrying a rowId field.
25
+ idOf = (row) => row.rowId, controls = []) {
26
+ if (rowOrder === undefined || rowOrder.length === 0)
27
+ return [...rows];
28
+ const order = rowOrderForControls(rowOrder, controls);
29
+ const ranks = rankByIds(order, new Set(rows.map((row) => rowControlId(idOf(row), controls))));
30
+ if (ranks.size === 0)
31
+ return [...rows];
32
+ return stableSortByRank(rows, (row) => ranks.get(rowControlId(idOf(row), controls)) ?? UNKNOWN_RANK);
33
+ }
34
+ //# sourceMappingURL=row-order.js.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Authoritative normalized row-visibility semantics.
3
+ *
4
+ * Browser-safe and shared by the UI, Settings, the native session header and
5
+ * the server-side quota notification detector.
6
+ *
7
+ * Before per-window semantics, providers without a stable semantic metric
8
+ * emitted every row under `aggregate|<resultType>:<kind>`. A saved hide for
9
+ * that provider therefore matched whichever such row was emitted first. Those
10
+ * providers now emit typed `window:*` / `component:*` / `named:*` row keys.
11
+ *
12
+ * A saved legacy aggregate id keeps its original meaning until the user makes
13
+ * a new explicit choice: it resolves to the first current row on the same card
14
+ * with the same `|<resultType>:<kind>` discriminator. `materialize...` rewrites
15
+ * it to that row's typed id when Settings toggles a row of that card.
16
+ */
17
+ /**
18
+ * One persistent row control: the stable declared id plus every emitted row id
19
+ * that renders the same field in another shape. Emitted ids never change; the
20
+ * alias set is how a hide or saved order follows the field across shapes.
21
+ */
22
+ export interface RowVisibilityControl {
23
+ rowId: string;
24
+ aliases?: readonly string[];
25
+ }
26
+ /** The stable control id that owns a row id (itself or one of its aliases). */
27
+ export declare function rowControlId(rowId: string, controls: readonly RowVisibilityControl[]): string;
28
+ /**
29
+ * Rewrites a saved row order to stable control ids, first occurrence wins.
30
+ * Unknown ids stay untouched so a later emission can still use them.
31
+ */
32
+ export declare function rowOrderForControls(rowOrder: readonly string[], controls: readonly RowVisibilityControl[]): string[];
33
+ /**
34
+ * Resolves configured row ids against the rows a card currently emits. Exact
35
+ * typed ids pass through untouched. A legacy aggregate id resolves to the
36
+ * first emitted row of that card with the same discriminator; when no such row
37
+ * exists yet it stays inert so it can match a later emission.
38
+ *
39
+ * A configured id that belongs to a control (its stable declared id or any
40
+ * alias) hides every id the control owns. That keeps one eye effective when the
41
+ * provider renders the same field in another shape, and keeps a hide saved
42
+ * under the previous shape working after the control gains a stable id.
43
+ */
44
+ export declare function effectiveHiddenRowIds(rowIds: readonly string[], hiddenRows: readonly string[], controls?: readonly RowVisibilityControl[]): Set<string>;
45
+ /**
46
+ * Rewrites every legacy aggregate id for `cardId` to the current row it
47
+ * resolves to, and drops ones that no longer resolve. Called only after an
48
+ * explicit Settings row toggle, so an untouched legacy choice keeps following
49
+ * whichever row is emitted first. Other cards and exact ids are preserved in
50
+ * order.
51
+ */
52
+ export declare function materializeLegacyHiddenRowsForCard(cardId: string, hiddenRows: readonly string[], rowIds: readonly string[]): string[];
53
+ //# sourceMappingURL=row-visibility.d.ts.map
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Authoritative normalized row-visibility semantics.
3
+ *
4
+ * Browser-safe and shared by the UI, Settings, the native session header and
5
+ * the server-side quota notification detector.
6
+ *
7
+ * Before per-window semantics, providers without a stable semantic metric
8
+ * emitted every row under `aggregate|<resultType>:<kind>`. A saved hide for
9
+ * that provider therefore matched whichever such row was emitted first. Those
10
+ * providers now emit typed `window:*` / `component:*` / `named:*` row keys.
11
+ *
12
+ * A saved legacy aggregate id keeps its original meaning until the user makes
13
+ * a new explicit choice: it resolves to the first current row on the same card
14
+ * with the same `|<resultType>:<kind>` discriminator. `materialize...` rewrites
15
+ * it to that row's typed id when Settings toggles a row of that card.
16
+ */
17
+ /** The stable control id that owns a row id (itself or one of its aliases). */
18
+ export function rowControlId(rowId, controls) {
19
+ for (const control of controls) {
20
+ if (control.rowId === rowId || control.aliases?.includes(rowId))
21
+ return control.rowId;
22
+ }
23
+ return rowId;
24
+ }
25
+ /**
26
+ * Rewrites a saved row order to stable control ids, first occurrence wins.
27
+ * Unknown ids stay untouched so a later emission can still use them.
28
+ */
29
+ export function rowOrderForControls(rowOrder, controls) {
30
+ const seen = new Set();
31
+ const next = [];
32
+ for (const id of rowOrder) {
33
+ const controlId = rowControlId(id, controls);
34
+ if (seen.has(controlId))
35
+ continue;
36
+ seen.add(controlId);
37
+ next.push(controlId);
38
+ }
39
+ return next;
40
+ }
41
+ function parseLegacyAggregateRowId(id) {
42
+ const separator = id.indexOf("#");
43
+ if (separator <= 0)
44
+ return undefined;
45
+ const match = /^aggregate\|(.+)$/u.exec(id.slice(separator + 1));
46
+ const discriminator = match?.[1];
47
+ if (!discriminator)
48
+ return undefined;
49
+ return { cardId: id.slice(0, separator), discriminator };
50
+ }
51
+ function belongsToCard(rowId, cardId) {
52
+ return rowId.startsWith(`${cardId}#`);
53
+ }
54
+ function matchesDiscriminator(rowId, discriminator) {
55
+ return rowId.endsWith(`|${discriminator}`);
56
+ }
57
+ function firstRowForLegacyId(rowIds, legacy) {
58
+ return rowIds.find((rowId) => belongsToCard(rowId, legacy.cardId) && matchesDiscriminator(rowId, legacy.discriminator));
59
+ }
60
+ /**
61
+ * Resolves configured row ids against the rows a card currently emits. Exact
62
+ * typed ids pass through untouched. A legacy aggregate id resolves to the
63
+ * first emitted row of that card with the same discriminator; when no such row
64
+ * exists yet it stays inert so it can match a later emission.
65
+ *
66
+ * A configured id that belongs to a control (its stable declared id or any
67
+ * alias) hides every id the control owns. That keeps one eye effective when the
68
+ * provider renders the same field in another shape, and keeps a hide saved
69
+ * under the previous shape working after the control gains a stable id.
70
+ */
71
+ export function effectiveHiddenRowIds(rowIds, hiddenRows, controls = []) {
72
+ const hidden = new Set(hiddenRows);
73
+ if (hidden.size === 0)
74
+ return hidden;
75
+ for (const id of hiddenRows) {
76
+ const legacy = parseLegacyAggregateRowId(id);
77
+ if (!legacy)
78
+ continue;
79
+ // A provider that still emits aggregate rows keeps an exact hide.
80
+ if (rowIds.includes(id))
81
+ continue;
82
+ const first = firstRowForLegacyId(rowIds, legacy);
83
+ if (first === undefined)
84
+ continue;
85
+ hidden.delete(id);
86
+ hidden.add(first);
87
+ }
88
+ for (const control of controls) {
89
+ const ids = [control.rowId, ...(control.aliases ?? [])];
90
+ if (!ids.some((id) => hidden.has(id)))
91
+ continue;
92
+ for (const id of ids)
93
+ hidden.add(id);
94
+ }
95
+ return hidden;
96
+ }
97
+ /**
98
+ * Rewrites every legacy aggregate id for `cardId` to the current row it
99
+ * resolves to, and drops ones that no longer resolve. Called only after an
100
+ * explicit Settings row toggle, so an untouched legacy choice keeps following
101
+ * whichever row is emitted first. Other cards and exact ids are preserved in
102
+ * order.
103
+ */
104
+ export function materializeLegacyHiddenRowsForCard(cardId, hiddenRows, rowIds) {
105
+ const next = [];
106
+ const seen = new Set();
107
+ const push = (id) => {
108
+ if (seen.has(id))
109
+ return;
110
+ seen.add(id);
111
+ next.push(id);
112
+ };
113
+ for (const id of hiddenRows) {
114
+ const legacy = parseLegacyAggregateRowId(id);
115
+ if (!legacy || legacy.cardId !== cardId) {
116
+ push(id);
117
+ continue;
118
+ }
119
+ // Keep an aggregate row that still exists as its own exact id.
120
+ if (rowIds.includes(id)) {
121
+ push(id);
122
+ continue;
123
+ }
124
+ const first = firstRowForLegacyId(rowIds, legacy);
125
+ if (first !== undefined)
126
+ push(first);
127
+ }
128
+ return next;
129
+ }
130
+ //# sourceMappingURL=row-visibility.js.map