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
@@ -4,10 +4,11 @@
4
4
  * Uses the local Claude CLI/runtime to detect install/auth state first. When
5
5
  * Claude auth is confirmed but local quota windows are missing, it falls back
6
6
  * to Anthropic's OAuth usage endpoint using the first usable OAuth access
7
- * token: OpenCode's own Anthropic login, then Claude OAuth credentials (macOS
8
- * Keychain first, then the local credentials file).
7
+ * token from Claude OAuth credentials (macOS Keychain first, then the local credentials file).
9
8
  */
10
- import type { ProviderFailureCategory } from "../contracts/provider-failure.js";
9
+ import type { BankedResetAvailability } from "../contracts/openai-quota.js";
10
+ import { type ProviderFailureCategory, type QuotaAttemptOutcome } from "../contracts/provider-failure.js";
11
+ import type { FixedWindowProjectionEvidence } from "./entries.js";
11
12
  import { type ResolvedAuthIdentity } from "./resolved-auth-identity.js";
12
13
  export interface AnthropicQuotaWindow {
13
14
  utilization?: number;
@@ -27,31 +28,41 @@ export interface AnthropicExtraUsage {
27
28
  utilization?: number;
28
29
  }
29
30
  export interface AnthropicUsageResponse {
30
- five_hour: AnthropicQuotaWindow;
31
- seven_day: AnthropicQuotaWindow;
31
+ five_hour?: AnthropicQuotaWindow | null;
32
+ seven_day?: AnthropicQuotaWindow | null;
32
33
  extra_usage?: AnthropicExtraUsage;
33
34
  limits?: unknown[];
34
35
  }
35
36
  export interface AnthropicQuotaResult {
36
37
  success: true;
37
- five_hour: {
38
+ five_hour?: {
38
39
  percentRemaining: number;
39
40
  resetTimeIso?: string;
41
+ fixedWindow?: FixedWindowProjectionEvidence;
40
42
  };
41
- seven_day: {
43
+ seven_day?: {
42
44
  percentRemaining: number;
43
45
  resetTimeIso?: string;
46
+ fixedWindow?: FixedWindowProjectionEvidence;
44
47
  };
45
48
  extra_usage?: {
46
49
  percentRemaining: number;
47
50
  };
51
+ /**
52
+ * The Fable scope is `weekly_scoped` with a reset time only. No fixed cycle or duration is
53
+ * supplied, so it carries no fixed-window evidence and gets no runway.
54
+ */
48
55
  fable_weekly?: {
49
56
  percentRemaining: number;
50
57
  resetTimeIso?: string;
51
58
  };
59
+ /** Eligible, active, unpaused saved resets; only counts and expiry. Absent means none or unknown. */
60
+ saved_resets?: BankedResetAvailability;
52
61
  }
53
62
  export interface AnthropicUsageParseOptions {
54
63
  includeExtraUsage?: boolean;
64
+ /** When the usage payload was observed; defaults to now. Used only for fixed-window evidence. */
65
+ observedAtMs?: number;
55
66
  }
56
67
  export interface AnthropicQuotaError {
57
68
  success: false;
@@ -61,7 +72,7 @@ export interface AnthropicQuotaError {
61
72
  }
62
73
  export type AnthropicResult = AnthropicQuotaResult | AnthropicQuotaError | null;
63
74
  export type AnthropicAuthStatus = "authenticated" | "unauthenticated" | "unknown";
64
- export type AnthropicQuotaSource = "claude-auth-status-json" | "claude-credentials-oauth-api" | "opencode-auth-oauth-api" | "none";
75
+ export type AnthropicQuotaSource = "claude-auth-status-json" | "claude-credentials-oauth-api" | "none";
65
76
  export interface AnthropicDiagnostics {
66
77
  installed: boolean;
67
78
  version: string | null;
@@ -79,31 +90,74 @@ export interface AnthropicDiagnostics {
79
90
  message?: string;
80
91
  /** Source-assigned category for a failed OAuth usage request; absent otherwise. */
81
92
  failureCategory?: ProviderFailureCategory;
93
+ /** Outcome of this attempt; never inferred from display text. */
94
+ attemptOutcome?: QuotaAttemptOutcome;
95
+ /**
96
+ * When the returned quota was actually measured. Absent when no quota is
97
+ * returned. A reused measurement keeps its original time.
98
+ */
99
+ quotaMeasuredAtMs?: number;
100
+ /** True when the CLI probe itself did not complete (timeout or unusable output). */
101
+ probeFailure?: true;
102
+ /** Epoch ms when a rate-limited usage request may be retried; absent otherwise. */
103
+ retryAtMs?: number;
104
+ /** True when the usage request returned 401 and the stored token's own expiry is in the past. */
105
+ storedAccessTokenExpired?: true;
82
106
  quota?: AnthropicQuotaResult;
107
+ /** sha256 of the OAuth token bound to this probe, when a CLI token was used. */
108
+ credentialFingerprint?: string;
109
+ /** Display-only plan (e.g. `Claude (Max)`) of the verified Claude CLI login that answered the quota probe. */
110
+ planLabel?: string;
83
111
  }
84
112
  export interface AnthropicProbeOptions {
85
113
  binaryPath?: string;
114
+ operationCache?: Map<symbol, unknown>;
115
+ forceRefresh?: boolean;
86
116
  requestTimeoutMs?: number;
117
+ /** Minimum spacing between Anthropic usage requests for Claude Agent. */
118
+ pollIntervalMs?: number;
87
119
  }
88
120
  export type ClaudeCommandInvocation = {
89
121
  file: string;
90
122
  args: string[];
91
123
  display: string;
124
+ /** Set for cmd.exe bridges: the command line is already quoted, so Node must not re-quote it. */
125
+ windowsVerbatimArguments?: boolean;
92
126
  };
93
127
  /** Which credential store provided the OAuth access token used for the usage probe. */
94
- export type AnthropicCredentialSource = "opencode-auth" | "claude-credentials";
128
+ export type AnthropicCredentialSource = "claude-credentials";
95
129
  export declare function resolveAnthropicBinaryPath(binaryPath?: string): string;
96
130
  export declare function buildClaudeCommandInvocation(binaryPath: string, args: string[], runtime?: {
97
131
  platform?: NodeJS.Platform;
98
132
  comspec?: string;
99
133
  }): ClaudeCommandInvocation;
100
134
  declare function parseUsageResponse(data: unknown, options?: AnthropicUsageParseOptions): AnthropicQuotaResult | null;
101
- declare function parseOAuthUsageResponse(data: unknown): AnthropicQuotaResult | null;
102
- export declare function queryAnthropicQuotaWithOAuth(accessToken: string, requestTimeoutMs?: number): Promise<AnthropicResult>;
135
+ declare function parseOAuthUsageResponse(data: unknown, observedAtMs?: number): AnthropicQuotaResult | null;
136
+ /**
137
+ * Parses one candidate config directory. `undefined` means the value is absent, which is not an
138
+ * error. `null` means it is present but cannot name a directory (not a string, empty, padded with
139
+ * whitespace, or relative), so the caller must fail closed rather than read another login.
140
+ */
141
+ export declare function parseClaudeConfigDirectoryCandidate(value: unknown): string | null | undefined;
142
+ export declare function fingerprintAccessToken(accessToken: string): string;
143
+ export declare function queryAnthropicQuotaWithOAuth(accessToken: string, requestTimeoutMs?: number, forcedOperationCache?: Map<symbol, unknown>): Promise<AnthropicResult>;
103
144
  export declare function clearAnthropicDiagnosticsCacheForTests(): void;
104
145
  export declare function getAnthropicDiagnostics(options?: AnthropicProbeOptions): Promise<AnthropicDiagnostics>;
105
- export declare function hasAnthropicCredentialsConfigured(options?: AnthropicProbeOptions): Promise<boolean>;
106
- export declare function resolveAnthropicAuthIdentity(options?: AnthropicProbeOptions): Promise<ResolvedAuthIdentity | null>;
107
- export declare function queryAnthropicQuota(options?: AnthropicProbeOptions): Promise<AnthropicResult>;
146
+ export declare function hasAnthropicCredentialsConfigured(options?: AnthropicProbeOptions, availability?: {
147
+ treatUnverifiedAsConfigured?: boolean;
148
+ }): Promise<boolean>;
149
+ /**
150
+ * Identity of the Claude Agent provider's single Claude CLI login. It is account-specific:
151
+ * the readable first-party token keys it, otherwise the CLI's own user-specific account evidence
152
+ * (email or account/user id) does. An organization id alone is shared by its members, so it never
153
+ * keys a scope. Without user-specific evidence, null keeps another account's last-good from being
154
+ * reused.
155
+ */
156
+ export declare function resolveClaudeAgentAccountIdentity(params: {
157
+ binaryPath?: string;
158
+ operationCache?: Map<symbol, unknown>;
159
+ onlyCurrentModel: boolean;
160
+ runtimeDetected: boolean;
161
+ }): Promise<ResolvedAuthIdentity | null>;
108
162
  export { parseOAuthUsageResponse, parseUsageResponse };
109
163
  //# sourceMappingURL=anthropic.d.ts.map