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.
- package/README.md +34 -20
- package/dist/bin/opencode-quota-gui.js +0 -0
- package/dist/contracts/build-identity.js +1 -1
- package/dist/contracts/card-order.d.ts +2 -0
- package/dist/contracts/card-order.js +2 -2
- package/dist/contracts/card-visibility.d.ts +2 -1
- package/dist/contracts/card-visibility.js +2 -1
- package/dist/contracts/dashboard.d.ts +95 -6
- package/dist/contracts/dashboard.js +10 -0
- package/dist/contracts/dto-guards.d.ts +4 -0
- package/dist/contracts/dto-guards.js +31 -7
- package/dist/contracts/guards.js +3 -1
- package/dist/contracts/identity.d.ts +37 -5
- package/dist/contracts/identity.js +43 -0
- package/dist/contracts/openai-quota.d.ts +3 -0
- package/dist/contracts/openai-quota.js +3 -0
- package/dist/contracts/provider-auto-resume.d.ts +9 -0
- package/dist/contracts/provider-auto-resume.js +24 -0
- package/dist/contracts/provider-failure.d.ts +22 -0
- package/dist/contracts/provider-failure.js +25 -1
- package/dist/contracts/row-order.d.ts +13 -0
- package/dist/contracts/row-order.js +34 -0
- package/dist/contracts/row-visibility.d.ts +53 -0
- package/dist/contracts/row-visibility.js +130 -0
- package/dist/data/modelsdev-pricing.min.json +1 -1
- package/dist/data/modelsdev-temporal.min.json +60 -634
- package/dist/gui/aggregation.d.ts +29 -1
- package/dist/gui/aggregation.js +157 -4
- package/dist/gui/analytics-bridge.d.ts +8 -9
- package/dist/gui/analytics-bridge.js +197 -54
- package/dist/gui/analytics-engine.d.ts +7 -15
- package/dist/gui/analytics-engine.js +246 -106
- package/dist/gui/analytics-model.d.ts +7 -0
- package/dist/gui/analytics-model.js +75 -9
- package/dist/gui/analytics-pricing-upkeep.d.ts +21 -0
- package/dist/gui/analytics-pricing-upkeep.js +23 -0
- package/dist/gui/analytics-protocol.d.ts +17 -7
- package/dist/gui/analytics-protocol.js +1 -0
- package/dist/gui/analytics-service.d.ts +10 -0
- package/dist/gui/analytics-service.js +30 -9
- package/dist/gui/analytics-state.d.ts +30 -5
- package/dist/gui/analytics-state.js +46 -7
- package/dist/gui/analytics-worker-runtime.d.ts +5 -0
- package/dist/gui/analytics-worker-runtime.js +9 -1
- package/dist/gui/analytics-worker.js +11 -0
- package/dist/gui/config.d.ts +3 -3
- package/dist/gui/config.js +77 -7
- package/dist/gui/identity.d.ts +6 -20
- package/dist/gui/identity.js +6 -54
- package/dist/gui/lifecycle.d.ts +5 -3
- package/dist/gui/lifecycle.js +3 -3
- package/dist/gui/primary-quota-windows.js +67 -44
- package/dist/gui/provider-cards.d.ts +20 -8
- package/dist/gui/provider-cards.js +42 -55
- package/dist/gui/quota-notification-detector.d.ts +29 -6
- package/dist/gui/quota-notification-detector.js +136 -47
- package/dist/gui/quota-notification-observer.d.ts +3 -4
- package/dist/gui/quota-notification-observer.js +73 -20
- package/dist/gui/quota-observation.d.ts +4 -0
- package/dist/gui/quota-observation.js +18 -0
- package/dist/gui/rpc.d.ts +2 -0
- package/dist/gui/rpc.js +14 -3
- package/dist/gui/server.js +17 -3
- package/dist/gui/snapshot-service.d.ts +3 -15
- package/dist/gui/snapshot-service.js +281 -23
- package/dist/gui/sources.js +179 -64
- package/dist/gui/temporal-status.d.ts +3 -2
- package/dist/gui/temporal-status.js +10 -6
- package/dist/gui-experimental.cjs +230 -225
- package/dist/lib/accounting-format.d.ts +8 -0
- package/dist/lib/accounting-format.js +20 -2
- package/dist/lib/alibaba-coding-plan-cli.d.ts +79 -0
- package/dist/lib/alibaba-coding-plan-cli.js +539 -0
- package/dist/lib/anthropic-api-auth.d.ts +7 -0
- package/dist/lib/anthropic-api-auth.js +27 -0
- package/dist/lib/anthropic-api-rate-limits.d.ts +47 -0
- package/dist/lib/anthropic-api-rate-limits.js +92 -0
- package/dist/lib/anthropic-auth.d.ts +2 -3
- package/dist/lib/anthropic-auth.js +2 -3
- package/dist/lib/anthropic-oauth-throttle.d.ts +76 -0
- package/dist/lib/anthropic-oauth-throttle.js +379 -0
- package/dist/lib/anthropic.d.ts +68 -14
- package/dist/lib/anthropic.js +1016 -363
- package/dist/lib/api-key-retry-after.d.ts +7 -0
- package/dist/lib/api-key-retry-after.js +62 -0
- package/dist/lib/atomic-json.d.ts +2 -0
- package/dist/lib/atomic-json.js +1 -0
- package/dist/lib/cache-observer-ingestion.d.ts +90 -0
- package/dist/lib/cache-observer-ingestion.js +1008 -0
- package/dist/lib/cache-observer.d.ts +141 -0
- package/dist/lib/cache-observer.js +323 -0
- package/dist/lib/canonical-config-lock.d.ts +9 -0
- package/dist/lib/canonical-config-lock.js +36 -0
- package/dist/lib/chutes.js +62 -51
- package/dist/lib/claude-agent-transcript-ttl.d.ts +48 -0
- package/dist/lib/claude-agent-transcript-ttl.js +154 -0
- package/dist/lib/claude-agent-ttl-tracker.d.ts +21 -0
- package/dist/lib/claude-agent-ttl-tracker.js +152 -0
- package/dist/lib/cli-show.d.ts +5 -0
- package/dist/lib/cli-show.js +21 -8
- package/dist/lib/cli-status.js +3 -6
- package/dist/lib/config-write-target.d.ts +1 -1
- package/dist/lib/config-write-target.js +5 -2
- package/dist/lib/config.d.ts +2 -1
- package/dist/lib/config.js +257 -4
- package/dist/lib/copilot.js +171 -86
- package/dist/lib/dashboard-visibility.d.ts +5 -0
- package/dist/lib/dashboard-visibility.js +11 -10
- package/dist/lib/dashboard-web-policy.d.ts +4 -4
- package/dist/lib/dashboard-web-policy.js +2 -2
- package/dist/lib/deepseek.js +25 -13
- package/dist/lib/display-sanitize.js +2 -0
- package/dist/lib/entries.d.ts +33 -1
- package/dist/lib/entries.js +6 -0
- package/dist/lib/glm-coding-plan.js +98 -74
- package/dist/lib/google-agy.js +90 -12
- package/dist/lib/google-gemini-cli.js +84 -11
- package/dist/lib/grouped-entry-normalization.js +1 -1
- package/dist/lib/http.d.ts +4 -0
- package/dist/lib/http.js +16 -2
- package/dist/lib/init-installer.js +5 -3
- package/dist/lib/kilo.js +37 -18
- package/dist/lib/kimi.js +35 -18
- package/dist/lib/maintainer-announcements.js +2 -2
- package/dist/lib/mimo.d.ts +2 -0
- package/dist/lib/mimo.js +36 -0
- package/dist/lib/modelsdev-pricing.d.ts +74 -2
- package/dist/lib/modelsdev-pricing.js +457 -63
- package/dist/lib/modelsdev-temporal.d.ts +6 -0
- package/dist/lib/modelsdev-temporal.js +16 -2
- package/dist/lib/nanogpt.d.ts +1 -0
- package/dist/lib/nanogpt.js +26 -3
- package/dist/lib/ollama-cloud.d.ts +1 -1
- package/dist/lib/ollama-cloud.js +48 -35
- package/dist/lib/openai.js +84 -38
- package/dist/lib/opencode-auth-sqlite.d.ts +2 -2
- package/dist/lib/opencode-auth-sqlite.js +2 -2
- package/dist/lib/opencode-config-editor.d.ts +1 -0
- package/dist/lib/opencode-config-editor.js +6 -1
- package/dist/lib/opencode-config-providers.js +2 -2
- package/dist/lib/opencode-go.js +29 -2
- package/dist/lib/opencode-storage.d.ts +20 -0
- package/dist/lib/opencode-storage.js +89 -2
- package/dist/lib/opencode-version-core.d.ts +30 -0
- package/dist/lib/opencode-version-core.js +59 -0
- package/dist/lib/opencode-version.d.ts +2 -22
- package/dist/lib/opencode-version.js +4 -48
- package/dist/lib/opencode-warming-refresh.d.ts +19 -0
- package/dist/lib/opencode-warming-refresh.js +95 -0
- package/dist/lib/opencode-zen.d.ts +3 -0
- package/dist/lib/opencode-zen.js +71 -5
- package/dist/lib/provider-add.js +5 -2
- package/dist/lib/provider-metadata.d.ts +11 -3
- package/dist/lib/provider-metadata.js +20 -2
- package/dist/lib/provider-registration.d.ts +358 -9
- package/dist/lib/provider-registration.js +423 -30
- package/dist/lib/quota-auto-resume.d.ts +74 -0
- package/dist/lib/quota-auto-resume.js +539 -0
- package/dist/lib/quota-command-format.js +23 -10
- package/dist/lib/quota-exhaustion-projection.d.ts +11 -0
- package/dist/lib/quota-exhaustion-projection.js +25 -0
- package/dist/lib/quota-identity.d.ts +64 -0
- package/dist/lib/quota-identity.js +111 -0
- package/dist/lib/quota-providers-remote.d.ts +2 -1
- package/dist/lib/quota-providers-remote.js +59 -3
- package/dist/lib/quota-providers.d.ts +1 -1
- package/dist/lib/quota-providers.js +14 -37
- package/dist/lib/quota-render-data.d.ts +6 -0
- package/dist/lib/quota-render-data.js +45 -19
- package/dist/lib/quota-reset-notifications.js +11 -155
- package/dist/lib/quota-retry-wait.d.ts +106 -5
- package/dist/lib/quota-retry-wait.js +301 -34
- package/dist/lib/quota-runtime-context.js +1 -0
- package/dist/lib/quota-state-codec.d.ts +2 -0
- package/dist/lib/quota-state-codec.js +31 -2
- package/dist/lib/quota-state.d.ts +8 -2
- package/dist/lib/quota-state.js +253 -47
- package/dist/lib/quota-stats.d.ts +26 -0
- package/dist/lib/quota-stats.js +40 -1
- package/dist/lib/quota-status.js +3 -51
- package/dist/lib/quota-surface-data.js +18 -3
- package/dist/lib/quota-telemetry.js +2 -2
- package/dist/lib/resolved-auth-identity.d.ts +19 -0
- package/dist/lib/resolved-auth-identity.js +44 -0
- package/dist/lib/scoped-update.d.ts +1 -1
- package/dist/lib/state-file-lock.d.ts +26 -0
- package/dist/lib/state-file-lock.js +205 -0
- package/dist/lib/synthetic.js +65 -54
- package/dist/lib/toast-format-grouped.js +7 -4
- package/dist/lib/tui-compact-format.js +29 -16
- package/dist/lib/types.d.ts +51 -1
- package/dist/lib/types.js +17 -1
- package/dist/lib/xai.js +48 -22
- package/dist/plugin.js +328 -14
- package/dist/provider-logos/NOTICE.md +1 -1
- package/dist/provider-logos/OPENCODE-NOTICE.md +4 -3
- package/dist/providers/alibaba-coding-plan.js +125 -104
- package/dist/providers/alibaba-token-plan.js +9 -5
- package/dist/providers/anthropic.d.ts +16 -3
- package/dist/providers/anthropic.js +172 -220
- package/dist/providers/cache-policies.d.ts +11 -4
- package/dist/providers/cache-policies.js +19 -13
- package/dist/providers/chutes.js +2 -0
- package/dist/providers/claude-agent.d.ts +19 -0
- package/dist/providers/claude-agent.js +215 -0
- package/dist/providers/copilot.js +7 -4
- package/dist/providers/glm-coding-plan-provider.d.ts +1 -0
- package/dist/providers/glm-coding-plan-provider.js +30 -23
- package/dist/providers/google-account-format.js +1 -0
- package/dist/providers/google-agy.d.ts +6 -5
- package/dist/providers/google-agy.js +43 -15
- package/dist/providers/google-gemini-cli.js +1 -0
- package/dist/providers/kilo.js +1 -0
- package/dist/providers/kimi-code.js +2 -0
- package/dist/providers/mimo.js +1 -0
- package/dist/providers/nanogpt.js +1 -0
- package/dist/providers/ollama-cloud.js +10 -0
- package/dist/providers/openai.js +24 -23
- package/dist/providers/opencode-go.js +10 -6
- package/dist/providers/opencode-zen.js +3 -1
- package/dist/providers/openrouter.js +1 -0
- package/dist/providers/quota-providers.js +16 -5
- package/dist/providers/registry.js +2 -0
- package/dist/providers/result-helpers.d.ts +6 -2
- package/dist/providers/result-helpers.js +7 -1
- package/dist/providers/synthetic.js +4 -0
- package/dist/providers/xai.js +9 -8
- package/dist/rpc.d.ts +129 -8
- package/dist/rpc.js +219 -14
- package/dist/ui/assets/{index-cDd9jUVY.css → index-6_g1FHs-.css} +1 -1
- package/dist/ui/assets/index-sZnGUuML.js +10 -0
- package/dist/ui/assets/{popover-BGkgv9s0.js → popover-C4ZLYe9E.js} +1 -1
- package/dist/ui/assets/providers/claude-agent.svg +3 -0
- package/dist/ui/index.html +2 -2
- package/package.json +45 -46
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts +0 -47
- package/dist/lib/alibaba-coding-plan-local-quota.js +0 -146
- package/dist/ui/assets/index-DLHeXYff.js +0 -9
|
@@ -93,7 +93,7 @@ function formatCompactPercentGroupSegment(group, windows = group.windows) {
|
|
|
93
93
|
const separator = windows.every((window) => window.label && !window.isWindow) ? ": " : " ";
|
|
94
94
|
return compactText(`${group.provider}${separator}${summary}`);
|
|
95
95
|
}
|
|
96
|
-
function buildSemanticCandidate(entry, percentDisplayMode, accountingDetail, resetTimeSpaced) {
|
|
96
|
+
function buildSemanticCandidate(entry, order, percentDisplayMode, accountingDetail, resetTimeSpaced) {
|
|
97
97
|
if (!entry.semantic)
|
|
98
98
|
return null;
|
|
99
99
|
const shouldRequestBasis = accountingDetail === "detailed" &&
|
|
@@ -113,8 +113,10 @@ function buildSemanticCandidate(entry, percentDisplayMode, accountingDetail, res
|
|
|
113
113
|
if (!value)
|
|
114
114
|
return null;
|
|
115
115
|
const provider = getProviderName(entry);
|
|
116
|
-
const
|
|
117
|
-
const
|
|
116
|
+
const hasExplicitLabel = Boolean(entry.label?.trim() || entry.metricLabel?.trim());
|
|
117
|
+
const explicitLabel = hasExplicitLabel ? getWindowLabel(entry) : null;
|
|
118
|
+
const label = explicitLabel ? explicitLabel.text : compactText(interpretation.label);
|
|
119
|
+
const prefix = compactText([provider, label].filter(Boolean).join(explicitLabel?.isWindow ? " " : ": "));
|
|
118
120
|
const runway = isPercentEntry(entry) ? formatQuotaRunway(entry.runway) : "";
|
|
119
121
|
const displayValue = compactText([
|
|
120
122
|
value,
|
|
@@ -133,6 +135,7 @@ function buildSemanticCandidate(entry, percentDisplayMode, accountingDetail, res
|
|
|
133
135
|
return {
|
|
134
136
|
segment,
|
|
135
137
|
prominence: entry.semantic.prominence === "supplementary" ? 1 : 0,
|
|
138
|
+
order,
|
|
136
139
|
providerKey: provider.toLowerCase(),
|
|
137
140
|
...(isPercentEntry(entry) && entry.runway ? { runway: entry.runway } : {}),
|
|
138
141
|
...(detail ? { detail } : {}),
|
|
@@ -145,9 +148,9 @@ function formatCompactEntryCandidates(params) {
|
|
|
145
148
|
const semantic = [];
|
|
146
149
|
const groups = new Map();
|
|
147
150
|
const pendingLegacy = [];
|
|
148
|
-
for (const entry of params.entries) {
|
|
151
|
+
for (const [index, entry] of params.entries.entries()) {
|
|
149
152
|
if (entry.semantic) {
|
|
150
|
-
const candidate = buildSemanticCandidate(entry, params.percentDisplayMode, params.accountingDetail, params.resetTimeSpaced);
|
|
153
|
+
const candidate = buildSemanticCandidate(entry, index, params.percentDisplayMode, params.accountingDetail, params.resetTimeSpaced);
|
|
151
154
|
if (candidate)
|
|
152
155
|
semantic.push(candidate);
|
|
153
156
|
continue;
|
|
@@ -155,7 +158,12 @@ function formatCompactEntryCandidates(params) {
|
|
|
155
158
|
if (isValueEntry(entry)) {
|
|
156
159
|
const segment = formatCompactValueEntrySegment(entry, params.resetTimeSpaced);
|
|
157
160
|
if (segment) {
|
|
158
|
-
pendingLegacy.push({
|
|
161
|
+
pendingLegacy.push({
|
|
162
|
+
kind: "value",
|
|
163
|
+
segment,
|
|
164
|
+
provider: getProviderName(entry),
|
|
165
|
+
order: index,
|
|
166
|
+
});
|
|
159
167
|
}
|
|
160
168
|
continue;
|
|
161
169
|
}
|
|
@@ -174,7 +182,7 @@ function formatCompactEntryCandidates(params) {
|
|
|
174
182
|
const key = provider.toLowerCase();
|
|
175
183
|
let group = groups.get(key);
|
|
176
184
|
if (!group) {
|
|
177
|
-
group = { provider, windows: [] };
|
|
185
|
+
group = { provider, order: index, windows: [] };
|
|
178
186
|
groups.set(key, group);
|
|
179
187
|
pendingLegacy.push({ kind: "percent", key });
|
|
180
188
|
}
|
|
@@ -191,6 +199,7 @@ function formatCompactEntryCandidates(params) {
|
|
|
191
199
|
return {
|
|
192
200
|
segment: pending.segment,
|
|
193
201
|
prominence: 0,
|
|
202
|
+
order: pending.order,
|
|
194
203
|
providerKey: pending.provider.toLowerCase(),
|
|
195
204
|
};
|
|
196
205
|
}
|
|
@@ -213,6 +222,7 @@ function formatCompactEntryCandidates(params) {
|
|
|
213
222
|
return {
|
|
214
223
|
segment,
|
|
215
224
|
prominence: 0,
|
|
225
|
+
order: group.order,
|
|
216
226
|
providerKey: group.provider.toLowerCase(),
|
|
217
227
|
...(fallbackSegment && fallbackSegment !== segment && fallbackValue
|
|
218
228
|
? {
|
|
@@ -224,10 +234,7 @@ function formatCompactEntryCandidates(params) {
|
|
|
224
234
|
};
|
|
225
235
|
})
|
|
226
236
|
.filter((candidate) => Boolean(candidate));
|
|
227
|
-
return [...legacy, ...semantic]
|
|
228
|
-
.map((candidate, index) => ({ candidate, index }))
|
|
229
|
-
.sort((left, right) => left.candidate.prominence - right.candidate.prominence || left.index - right.index)
|
|
230
|
-
.map(({ candidate }) => candidate);
|
|
237
|
+
return [...legacy, ...semantic].sort((left, right) => left.prominence - right.prominence || left.order - right.order);
|
|
231
238
|
}
|
|
232
239
|
function fitAtomicCandidate(atomic, maxWidth) {
|
|
233
240
|
if (atomic.value.length > maxWidth)
|
|
@@ -373,7 +380,7 @@ function applyProviderOverflow(admitted, candidates, maxWidth) {
|
|
|
373
380
|
return current;
|
|
374
381
|
const withOverflow = (items, count) => [
|
|
375
382
|
...items,
|
|
376
|
-
{ segment: formatProviderOverflow(count), prominence: 0 },
|
|
383
|
+
{ segment: formatProviderOverflow(count), prominence: 0, order: Number.MAX_SAFE_INTEGER },
|
|
377
384
|
];
|
|
378
385
|
if (joinCompactSegments(withOverflow(current, omitted)).length <= maxWidth) {
|
|
379
386
|
return withOverflow(current, omitted);
|
|
@@ -400,12 +407,14 @@ function applyProviderOverflow(admitted, candidates, maxWidth) {
|
|
|
400
407
|
if (truncated) {
|
|
401
408
|
return [
|
|
402
409
|
{ ...first, segment: truncated },
|
|
403
|
-
{ segment: overflowText, prominence: 0 },
|
|
410
|
+
{ segment: overflowText, prominence: 0, order: Number.MAX_SAFE_INTEGER },
|
|
404
411
|
];
|
|
405
412
|
}
|
|
406
413
|
}
|
|
407
414
|
}
|
|
408
|
-
return overflowText.length <= maxWidth
|
|
415
|
+
return overflowText.length <= maxWidth
|
|
416
|
+
? [{ segment: overflowText, prominence: 0, order: Number.MAX_SAFE_INTEGER }]
|
|
417
|
+
: admitted;
|
|
409
418
|
}
|
|
410
419
|
function formatIssueCount(count) {
|
|
411
420
|
return `+${count} issue${count === 1 ? "" : "s"}`;
|
|
@@ -434,7 +443,11 @@ export function buildCompactQuotaStatusLine(params) {
|
|
|
434
443
|
});
|
|
435
444
|
const sessionTokensSegment = formatCompactSessionTokensSegment(data);
|
|
436
445
|
if (sessionTokensSegment) {
|
|
437
|
-
candidates.push({
|
|
446
|
+
candidates.push({
|
|
447
|
+
segment: sessionTokensSegment,
|
|
448
|
+
prominence: 0,
|
|
449
|
+
order: Number.MAX_SAFE_INTEGER,
|
|
450
|
+
});
|
|
438
451
|
}
|
|
439
452
|
const admitted = applyProviderOverflow(admitCompactCandidates(candidates, maxWidth), candidates, maxWidth);
|
|
440
453
|
const issues = data.errors.filter((error) => error.kind !== "intentional-filter");
|
|
@@ -449,7 +462,7 @@ export function buildCompactQuotaStatusLine(params) {
|
|
|
449
462
|
const issueSegment = formatIssueCount(issues.length);
|
|
450
463
|
const candidate = [...admitted.map((item) => item.segment), issueSegment].join(COMPACT_SEGMENT_SEPARATOR);
|
|
451
464
|
if (candidate.length <= maxWidth) {
|
|
452
|
-
admitted.push({ segment: issueSegment, prominence: 0 });
|
|
465
|
+
admitted.push({ segment: issueSegment, prominence: 0, order: Number.MAX_SAFE_INTEGER });
|
|
453
466
|
}
|
|
454
467
|
}
|
|
455
468
|
}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -17,9 +17,32 @@ export type QuotaResetWindow = "fiveHour" | "hourly" | "daily" | "weekly" | "mon
|
|
|
17
17
|
export interface QuotaResetNotificationsConfig {
|
|
18
18
|
/** Whether successful quota-window resets emit a one-shot toast. */
|
|
19
19
|
enabled: boolean;
|
|
20
|
-
/**
|
|
20
|
+
/** Windows whose verified reset transitions may produce a one-shot notification. */
|
|
21
21
|
windows: QuotaResetWindow[];
|
|
22
22
|
}
|
|
23
|
+
/** Canonical Native desktop notification policy; legacy `resetNotifications` is separate. */
|
|
24
|
+
export interface NativeQuotaNotificationPolicy {
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
/** Focused-window model mismatch toasts; independent of the quota alert master. */
|
|
27
|
+
modelChangeToastEnabled: boolean;
|
|
28
|
+
low: {
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
thresholdRemainingPercent: number;
|
|
31
|
+
};
|
|
32
|
+
exhausted: {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
};
|
|
35
|
+
reset: {
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
windows: QuotaResetWindow[];
|
|
38
|
+
};
|
|
39
|
+
providerError: {
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
};
|
|
42
|
+
/** Shared cooldown for every Native quota notification fingerprint. */
|
|
43
|
+
duplicateCooldownMinutes: number;
|
|
44
|
+
}
|
|
45
|
+
export declare const DEFAULT_NATIVE_QUOTA_NOTIFICATION_POLICY: NativeQuotaNotificationPolicy;
|
|
23
46
|
export interface PricingSnapshotConfig {
|
|
24
47
|
source: PricingSnapshotSource;
|
|
25
48
|
autoRefresh: number;
|
|
@@ -96,6 +119,13 @@ export interface QuotaDashboardConfig {
|
|
|
96
119
|
* only; providerOrder remains the legacy fallback when this is empty.
|
|
97
120
|
*/
|
|
98
121
|
cardOrder: string[];
|
|
122
|
+
/**
|
|
123
|
+
* Sparse per-card row display order: opaque card id -> ordered opaque row
|
|
124
|
+
* ids. A card absent from this map keeps provider emission order. Listed
|
|
125
|
+
* rows come first in saved order, and every unlisted/new row keeps emission
|
|
126
|
+
* order after them. Display order only; hiding stays in `hiddenRows`.
|
|
127
|
+
*/
|
|
128
|
+
rowOrder: Record<string, string[]>;
|
|
99
129
|
/**
|
|
100
130
|
* Explicit temporal chip visibility per provider. Sparse by design: an
|
|
101
131
|
* absent provider follows account discovery, while a present boolean keeps
|
|
@@ -128,6 +158,8 @@ export interface QuotaToastConfig {
|
|
|
128
158
|
enableToast: boolean;
|
|
129
159
|
/** Opt-in, persisted notifications when selected quota windows reset. */
|
|
130
160
|
resetNotifications: QuotaResetNotificationsConfig;
|
|
161
|
+
/** Master/category policy for Native quota notifications. */
|
|
162
|
+
nativeQuotaNotifications: NativeQuotaNotificationPolicy;
|
|
131
163
|
/**
|
|
132
164
|
* Percent of a quota window remaining at or below which quota is considered
|
|
133
165
|
* low. Stored as remaining even when the UI displays used percentages.
|
|
@@ -167,6 +199,12 @@ export interface QuotaToastConfig {
|
|
|
167
199
|
/** Whether exact multi-unit reset countdowns include spaces between units. Defaults to true. */
|
|
168
200
|
resetTimeSpaced?: boolean;
|
|
169
201
|
minIntervalMs: number;
|
|
202
|
+
/**
|
|
203
|
+
* Minimum spacing between Anthropic OAuth usage requests for Claude Agent,
|
|
204
|
+
* shared by every OpenCode process. Defaults to three minutes; never below
|
|
205
|
+
* one minute.
|
|
206
|
+
*/
|
|
207
|
+
claudeAgentPollIntervalMs: number;
|
|
170
208
|
/** Request timeout in milliseconds for remote provider API calls. */
|
|
171
209
|
requestTimeoutMs: number;
|
|
172
210
|
/**
|
|
@@ -218,6 +256,13 @@ export interface QuotaToastConfig {
|
|
|
218
256
|
* model's provider resets, instead of OpenCode's normal retry timing.
|
|
219
257
|
*/
|
|
220
258
|
waitForQuotaReset: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* If true, a session that terminally failed on a provider quota limit gets one `continue`
|
|
261
|
+
* prompt after the failed account's exhausted quota window is observed as reset and the
|
|
262
|
+
* session has stayed inactive for two minutes. Off by default; pending resumes are lost when
|
|
263
|
+
* the plugin process restarts.
|
|
264
|
+
*/
|
|
265
|
+
autoResumeOnQuotaRecovery: boolean;
|
|
221
266
|
/**
|
|
222
267
|
* If true, show the Session input/output tokens section in quota displays when session token data is available.
|
|
223
268
|
* "allWindows" keeps per-model rows on toast + sidebar; "singleWindow"
|
|
@@ -600,6 +645,10 @@ export interface GoogleAccountError {
|
|
|
600
645
|
email: string;
|
|
601
646
|
error: string;
|
|
602
647
|
failureCategory?: ProviderFailureCategory;
|
|
648
|
+
/** Deadline observed in an upstream Retry-After response. */
|
|
649
|
+
retryAtMs?: number;
|
|
650
|
+
/** Position of the failed account, matching its buckets' `accountIndex`. */
|
|
651
|
+
accountIndex?: number;
|
|
603
652
|
}
|
|
604
653
|
export interface GeminiCliQuotaBucket {
|
|
605
654
|
modelId: string;
|
|
@@ -661,6 +710,7 @@ export type GoogleAgyResult = GoogleAgyQuotaResult | QuotaError | null;
|
|
|
661
710
|
export interface QuotaError {
|
|
662
711
|
success: false;
|
|
663
712
|
error: string;
|
|
713
|
+
retryAtMs?: number;
|
|
664
714
|
/** Whether retrying later may succeed without changing credentials or configuration. */
|
|
665
715
|
retryable?: boolean;
|
|
666
716
|
/** Source-assigned safe category; absence means unknown and consumers fail closed. */
|
package/dist/lib/types.js
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
* Type definitions for the opencode-quota-gui product.
|
|
3
3
|
*/
|
|
4
4
|
import { DEFAULT_QUOTA_FORMAT_STYLE } from "./quota-format-style.js";
|
|
5
|
+
export const DEFAULT_NATIVE_QUOTA_NOTIFICATION_POLICY = {
|
|
6
|
+
enabled: true,
|
|
7
|
+
modelChangeToastEnabled: true,
|
|
8
|
+
low: { enabled: true, thresholdRemainingPercent: 10 },
|
|
9
|
+
exhausted: { enabled: true },
|
|
10
|
+
reset: {
|
|
11
|
+
enabled: true,
|
|
12
|
+
windows: ["fiveHour", "hourly", "daily", "weekly", "monthly", "yearly"],
|
|
13
|
+
},
|
|
14
|
+
providerError: { enabled: true },
|
|
15
|
+
duplicateCooldownMinutes: 30,
|
|
16
|
+
};
|
|
5
17
|
/** Default dashboard port (spec §5.4); never falls back to another port. */
|
|
6
18
|
export const DEFAULT_DASHBOARD_PORT = 4144;
|
|
7
19
|
/** Cap for opaque dashboard id-list settings (`hiddenCards`, `hiddenRows`, order lists). */
|
|
@@ -16,6 +28,7 @@ export const DEFAULT_CONFIG = {
|
|
|
16
28
|
enabled: false,
|
|
17
29
|
windows: ["weekly"],
|
|
18
30
|
},
|
|
31
|
+
nativeQuotaNotifications: DEFAULT_NATIVE_QUOTA_NOTIFICATION_POLICY,
|
|
19
32
|
lowQuotaThresholdRemainingPercent: 10,
|
|
20
33
|
duplicateCooldownMinutes: 30,
|
|
21
34
|
tuiCommandDisplay: "dialog",
|
|
@@ -24,6 +37,7 @@ export const DEFAULT_CONFIG = {
|
|
|
24
37
|
accountingDetail: "summary",
|
|
25
38
|
resetTimeSpaced: true,
|
|
26
39
|
minIntervalMs: 60000, // 1 minute
|
|
40
|
+
claudeAgentPollIntervalMs: 180000, // 3 minutes; shared by every OpenCode process
|
|
27
41
|
requestTimeoutMs: REQUEST_TIMEOUT_MS,
|
|
28
42
|
debug: false,
|
|
29
43
|
// Providers are auto-detected by default; set to explicit list to opt-in manually.
|
|
@@ -35,7 +49,7 @@ export const DEFAULT_CONFIG = {
|
|
|
35
49
|
opencodeMonthlyLimit: undefined,
|
|
36
50
|
pricingSnapshot: {
|
|
37
51
|
source: "auto",
|
|
38
|
-
autoRefresh:
|
|
52
|
+
autoRefresh: 1,
|
|
39
53
|
},
|
|
40
54
|
showOnIdle: true,
|
|
41
55
|
showOnQuestion: true,
|
|
@@ -44,6 +58,7 @@ export const DEFAULT_CONFIG = {
|
|
|
44
58
|
toastDurationMs: 9000,
|
|
45
59
|
onlyCurrentModel: false,
|
|
46
60
|
waitForQuotaReset: true,
|
|
61
|
+
autoResumeOnQuotaRecovery: false,
|
|
47
62
|
showSessionTokens: true,
|
|
48
63
|
sessionTokenScope: "current",
|
|
49
64
|
tuiSidebarPanel: {
|
|
@@ -78,6 +93,7 @@ export const DEFAULT_CONFIG = {
|
|
|
78
93
|
hiddenRows: [],
|
|
79
94
|
providerOrder: [],
|
|
80
95
|
cardOrder: [],
|
|
96
|
+
rowOrder: {},
|
|
81
97
|
temporalProviderOverrides: {},
|
|
82
98
|
},
|
|
83
99
|
layout: {
|
package/dist/lib/xai.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* OpenCode remains the sole owner of OAuth refresh and opencode.db persistence.
|
|
12
12
|
*/
|
|
13
13
|
import { providerFailureCategoryForHttpStatus, } from "../contracts/provider-failure.js";
|
|
14
|
+
import { createApiKeyRetryGuard, retryAfterDeadline } from "./api-key-retry-after.js";
|
|
14
15
|
import { sanitizeSingleLineDisplaySnippet } from "./display-sanitize.js";
|
|
15
16
|
import { clampPercent } from "./format-utils.js";
|
|
16
17
|
import { fetchWithTimeout } from "./http.js";
|
|
@@ -22,6 +23,16 @@ const SUBSCRIPTIONS_URL = "https://grok.com/rest/subscriptions";
|
|
|
22
23
|
const SUBSCRIPTIONS_TIMEOUT_MS = 2_000;
|
|
23
24
|
const HEAVY_OFFER_ID_RE = /^heavy-p\d+m-\d{1,2}-[a-z]{3}\d{4}$/i;
|
|
24
25
|
const USER_AGENT = "opencode-quota-gui/1.0";
|
|
26
|
+
const guard = createApiKeyRetryGuard((retryAtMs) => ({
|
|
27
|
+
success: false,
|
|
28
|
+
error: "xAI API error 429",
|
|
29
|
+
failureCategory: providerFailureCategoryForHttpStatus(429),
|
|
30
|
+
retryAtMs,
|
|
31
|
+
}));
|
|
32
|
+
const subscriptionGuard = createApiKeyRetryGuard((retryAtMs) => ({
|
|
33
|
+
success: false,
|
|
34
|
+
retryAtMs,
|
|
35
|
+
}));
|
|
25
36
|
function isRecord(value) {
|
|
26
37
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
27
38
|
}
|
|
@@ -176,23 +187,30 @@ function xaiLabelForTier(tier) {
|
|
|
176
187
|
}
|
|
177
188
|
}
|
|
178
189
|
async function queryXaiSubscriptionTier(accessToken, requestTimeoutMs) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
190
|
+
const result = await subscriptionGuard(accessToken, async () => {
|
|
191
|
+
try {
|
|
192
|
+
return await fetchWithTimeout(SUBSCRIPTIONS_URL, {
|
|
193
|
+
request: {
|
|
194
|
+
method: "GET",
|
|
195
|
+
headers: xaiHeaders(accessToken),
|
|
196
|
+
},
|
|
197
|
+
timeoutMs: Math.min(requestTimeoutMs ?? SUBSCRIPTIONS_TIMEOUT_MS, SUBSCRIPTIONS_TIMEOUT_MS),
|
|
198
|
+
consume: async (response) => {
|
|
199
|
+
if (!response.ok) {
|
|
200
|
+
const retryAtMs = retryAfterDeadline(response);
|
|
201
|
+
return retryAtMs === undefined
|
|
202
|
+
? { success: true, tier: null }
|
|
203
|
+
: { success: false, retryAtMs };
|
|
204
|
+
}
|
|
205
|
+
return { success: true, tier: parseXaiSubscriptionTier(await response.json()) };
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return { success: true, tier: null };
|
|
211
|
+
}
|
|
212
|
+
}, Math.min(requestTimeoutMs ?? SUBSCRIPTIONS_TIMEOUT_MS, SUBSCRIPTIONS_TIMEOUT_MS));
|
|
213
|
+
return result.success ? result.tier : null;
|
|
196
214
|
}
|
|
197
215
|
function safeErrorText(message, accessToken) {
|
|
198
216
|
const redacted = accessToken ? message.split(accessToken).join("[redacted]") : message;
|
|
@@ -219,22 +237,29 @@ export async function queryXaiQuota(options = {}) {
|
|
|
219
237
|
failureCategory: "credentials",
|
|
220
238
|
};
|
|
221
239
|
}
|
|
240
|
+
const accessToken = resolvedAuth.accessToken;
|
|
241
|
+
return guard(accessToken, () => fetchXaiQuota(accessToken, options.requestTimeoutMs), options.requestTimeoutMs);
|
|
242
|
+
}
|
|
243
|
+
async function fetchXaiQuota(accessToken, requestTimeoutMs) {
|
|
222
244
|
let responseStatus;
|
|
245
|
+
let retryAtMs;
|
|
223
246
|
try {
|
|
224
247
|
const creditsResult = await fetchWithTimeout(CREDITS_URL, {
|
|
225
248
|
request: {
|
|
226
249
|
method: "GET",
|
|
227
|
-
headers: xaiHeaders(
|
|
250
|
+
headers: xaiHeaders(accessToken),
|
|
228
251
|
},
|
|
229
|
-
timeoutMs:
|
|
252
|
+
timeoutMs: requestTimeoutMs,
|
|
230
253
|
consume: async (response) => {
|
|
231
254
|
responseStatus = response.status;
|
|
232
255
|
if (!response.ok) {
|
|
256
|
+
retryAtMs = retryAfterDeadline(response);
|
|
233
257
|
const body = await response.text();
|
|
234
258
|
return {
|
|
235
259
|
success: false,
|
|
236
|
-
error: `xAI API error ${response.status}: ${safeErrorText(body,
|
|
260
|
+
error: `xAI API error ${response.status}: ${safeErrorText(body, accessToken)}`,
|
|
237
261
|
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
262
|
+
...(retryAtMs !== undefined ? { retryAtMs } : {}),
|
|
238
263
|
};
|
|
239
264
|
}
|
|
240
265
|
const payload = await response.json();
|
|
@@ -251,16 +276,17 @@ export async function queryXaiQuota(options = {}) {
|
|
|
251
276
|
});
|
|
252
277
|
if (!creditsResult.success)
|
|
253
278
|
return creditsResult;
|
|
254
|
-
const tier = await queryXaiSubscriptionTier(
|
|
279
|
+
const tier = await queryXaiSubscriptionTier(accessToken, requestTimeoutMs);
|
|
255
280
|
return { success: true, label: xaiLabelForTier(tier), window: creditsResult.window };
|
|
256
281
|
}
|
|
257
282
|
catch (error) {
|
|
258
283
|
return {
|
|
259
284
|
success: false,
|
|
260
|
-
error: safeErrorText(error instanceof Error ? error.message : String(error),
|
|
285
|
+
error: safeErrorText(error instanceof Error ? error.message : String(error), accessToken),
|
|
261
286
|
failureCategory: responseStatus === undefined
|
|
262
287
|
? "provider_api"
|
|
263
288
|
: providerFailureCategoryForHttpStatus(responseStatus),
|
|
289
|
+
...(retryAtMs !== undefined ? { retryAtMs } : {}),
|
|
264
290
|
};
|
|
265
291
|
}
|
|
266
292
|
}
|