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
package/dist/lib/config.js
CHANGED
|
@@ -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 {
|
|
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";
|
|
@@ -42,6 +43,7 @@ export const QUOTA_TOAST_SETTING_SOURCE_KEYS = [
|
|
|
42
43
|
"enableToast",
|
|
43
44
|
"resetNotifications.enabled",
|
|
44
45
|
"resetNotifications.windows",
|
|
46
|
+
"nativeQuotaNotifications",
|
|
45
47
|
"lowQuotaThresholdRemainingPercent",
|
|
46
48
|
"duplicateCooldownMinutes",
|
|
47
49
|
"tuiCommandDisplay",
|
|
@@ -53,6 +55,7 @@ export const QUOTA_TOAST_SETTING_SOURCE_KEYS = [
|
|
|
53
55
|
"resetTimeDecimals",
|
|
54
56
|
"resetTimeSpaced",
|
|
55
57
|
"minIntervalMs",
|
|
58
|
+
"claudeAgentPollIntervalMs",
|
|
56
59
|
"requestTimeoutMs",
|
|
57
60
|
"debug",
|
|
58
61
|
"enabledProviders",
|
|
@@ -72,6 +75,7 @@ export const QUOTA_TOAST_SETTING_SOURCE_KEYS = [
|
|
|
72
75
|
"toastDurationMs",
|
|
73
76
|
"onlyCurrentModel",
|
|
74
77
|
"waitForQuotaReset",
|
|
78
|
+
"autoResumeOnQuotaRecovery",
|
|
75
79
|
"showSessionTokens",
|
|
76
80
|
"sessionTokenScope",
|
|
77
81
|
"tuiSidebarPanel.enabled",
|
|
@@ -99,6 +103,7 @@ export const QUOTA_TOAST_SETTING_SOURCE_KEYS = [
|
|
|
99
103
|
"dashboard.hiddenRows",
|
|
100
104
|
"dashboard.providerOrder",
|
|
101
105
|
"dashboard.cardOrder",
|
|
106
|
+
"dashboard.rowOrder",
|
|
102
107
|
"dashboard.temporalProviderOverrides",
|
|
103
108
|
];
|
|
104
109
|
export function createLoadConfigMeta() {
|
|
@@ -118,6 +123,7 @@ const NETWORK_SETTING_SOURCE_KEYS = [
|
|
|
118
123
|
"enabledProviders",
|
|
119
124
|
"quotaProviders",
|
|
120
125
|
"minIntervalMs",
|
|
126
|
+
"claudeAgentPollIntervalMs",
|
|
121
127
|
"requestTimeoutMs",
|
|
122
128
|
"pricingSnapshot.source",
|
|
123
129
|
"pricingSnapshot.autoRefresh",
|
|
@@ -231,6 +237,16 @@ function cloneConfig(config) {
|
|
|
231
237
|
...config.resetNotifications,
|
|
232
238
|
windows: [...config.resetNotifications.windows],
|
|
233
239
|
},
|
|
240
|
+
nativeQuotaNotifications: {
|
|
241
|
+
...config.nativeQuotaNotifications,
|
|
242
|
+
low: { ...config.nativeQuotaNotifications.low },
|
|
243
|
+
exhausted: { ...config.nativeQuotaNotifications.exhausted },
|
|
244
|
+
reset: {
|
|
245
|
+
...config.nativeQuotaNotifications.reset,
|
|
246
|
+
windows: [...config.nativeQuotaNotifications.reset.windows],
|
|
247
|
+
},
|
|
248
|
+
providerError: { ...config.nativeQuotaNotifications.providerError },
|
|
249
|
+
},
|
|
234
250
|
opencodeGoWindows: [...config.opencodeGoWindows],
|
|
235
251
|
opencodeMonthlyLimit: config.opencodeMonthlyLimit,
|
|
236
252
|
pricingSnapshot: { ...config.pricingSnapshot },
|
|
@@ -249,6 +265,7 @@ function cloneConfig(config) {
|
|
|
249
265
|
hiddenRows: [...config.dashboard.hiddenRows],
|
|
250
266
|
providerOrder: [...config.dashboard.providerOrder],
|
|
251
267
|
cardOrder: [...config.dashboard.cardOrder],
|
|
268
|
+
rowOrder: Object.fromEntries(Object.entries(config.dashboard.rowOrder).map(([cardId, ids]) => [cardId, [...ids]])),
|
|
252
269
|
temporalProviderOverrides: { ...config.dashboard.temporalProviderOverrides },
|
|
253
270
|
},
|
|
254
271
|
};
|
|
@@ -291,6 +308,133 @@ function extractQuotaResetNotificationsPatch(value, reportIssue) {
|
|
|
291
308
|
}
|
|
292
309
|
return Object.keys(patch).length > 0 ? patch : undefined;
|
|
293
310
|
}
|
|
311
|
+
export function isValidNativeQuotaNotificationPolicy(value) {
|
|
312
|
+
if (!isPlainObject(value))
|
|
313
|
+
return false;
|
|
314
|
+
if (typeof value.enabled !== "boolean")
|
|
315
|
+
return false;
|
|
316
|
+
if (typeof value.modelChangeToastEnabled !== "boolean")
|
|
317
|
+
return false;
|
|
318
|
+
if (!isPlainObject(value.low) || typeof value.low.enabled !== "boolean")
|
|
319
|
+
return false;
|
|
320
|
+
if (!isValidLowQuotaThresholdRemainingPercent(value.low.thresholdRemainingPercent))
|
|
321
|
+
return false;
|
|
322
|
+
if (!isPlainObject(value.exhausted) || typeof value.exhausted.enabled !== "boolean")
|
|
323
|
+
return false;
|
|
324
|
+
if (!isPlainObject(value.reset) || typeof value.reset.enabled !== "boolean")
|
|
325
|
+
return false;
|
|
326
|
+
if (!Array.isArray(value.reset.windows) ||
|
|
327
|
+
!value.reset.windows.every((window) => QUOTA_RESET_WINDOWS.includes(window))) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
if (!isPlainObject(value.providerError) || typeof value.providerError.enabled !== "boolean") {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
return isValidDuplicateCooldownMinutes(value.duplicateCooldownMinutes);
|
|
334
|
+
}
|
|
335
|
+
function extractNativeQuotaNotificationPolicyPatch(value, reportIssue) {
|
|
336
|
+
if (!isPlainObject(value))
|
|
337
|
+
return undefined;
|
|
338
|
+
const patch = {};
|
|
339
|
+
if (hasOwnKey(value, "enabled")) {
|
|
340
|
+
if (typeof value.enabled === "boolean")
|
|
341
|
+
patch.enabled = value.enabled;
|
|
342
|
+
else
|
|
343
|
+
reportIssue?.("nativeQuotaNotifications.enabled", "expected boolean");
|
|
344
|
+
}
|
|
345
|
+
if (hasOwnKey(value, "modelChangeToastEnabled")) {
|
|
346
|
+
if (typeof value.modelChangeToastEnabled === "boolean") {
|
|
347
|
+
patch.modelChangeToastEnabled = value.modelChangeToastEnabled;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
reportIssue?.("nativeQuotaNotifications.modelChangeToastEnabled", "expected boolean");
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (hasOwnKey(value, "low")) {
|
|
354
|
+
if (!isPlainObject(value.low)) {
|
|
355
|
+
reportIssue?.("nativeQuotaNotifications.low", "expected object");
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
const low = {};
|
|
359
|
+
if (hasOwnKey(value.low, "enabled")) {
|
|
360
|
+
if (typeof value.low.enabled === "boolean")
|
|
361
|
+
low.enabled = value.low.enabled;
|
|
362
|
+
else
|
|
363
|
+
reportIssue?.("nativeQuotaNotifications.low.enabled", "expected boolean");
|
|
364
|
+
}
|
|
365
|
+
if (hasOwnKey(value.low, "thresholdRemainingPercent")) {
|
|
366
|
+
if (isValidLowQuotaThresholdRemainingPercent(value.low.thresholdRemainingPercent)) {
|
|
367
|
+
low.thresholdRemainingPercent = value.low.thresholdRemainingPercent;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
reportIssue?.("nativeQuotaNotifications.low.thresholdRemainingPercent", "expected an integer between 1 and 100");
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (Object.keys(low).length > 0)
|
|
374
|
+
patch.low = low;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (hasOwnKey(value, "exhausted")) {
|
|
378
|
+
if (!isPlainObject(value.exhausted)) {
|
|
379
|
+
reportIssue?.("nativeQuotaNotifications.exhausted", "expected object");
|
|
380
|
+
}
|
|
381
|
+
else if (hasOwnKey(value.exhausted, "enabled")) {
|
|
382
|
+
if (typeof value.exhausted.enabled === "boolean") {
|
|
383
|
+
patch.exhausted = { enabled: value.exhausted.enabled };
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
reportIssue?.("nativeQuotaNotifications.exhausted.enabled", "expected boolean");
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (hasOwnKey(value, "reset")) {
|
|
391
|
+
if (!isPlainObject(value.reset)) {
|
|
392
|
+
reportIssue?.("nativeQuotaNotifications.reset", "expected object");
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
const reset = {};
|
|
396
|
+
if (hasOwnKey(value.reset, "enabled")) {
|
|
397
|
+
if (typeof value.reset.enabled === "boolean")
|
|
398
|
+
reset.enabled = value.reset.enabled;
|
|
399
|
+
else
|
|
400
|
+
reportIssue?.("nativeQuotaNotifications.reset.enabled", "expected boolean");
|
|
401
|
+
}
|
|
402
|
+
if (hasOwnKey(value.reset, "windows")) {
|
|
403
|
+
if (Array.isArray(value.reset.windows) &&
|
|
404
|
+
value.reset.windows.every((window) => QUOTA_RESET_WINDOWS.includes(window))) {
|
|
405
|
+
reset.windows = dedupe(value.reset.windows);
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
reportIssue?.("nativeQuotaNotifications.reset.windows", `expected an array of: ${QUOTA_RESET_WINDOWS.join(", ")}`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (Object.keys(reset).length > 0)
|
|
412
|
+
patch.reset = reset;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (hasOwnKey(value, "providerError")) {
|
|
416
|
+
if (!isPlainObject(value.providerError)) {
|
|
417
|
+
reportIssue?.("nativeQuotaNotifications.providerError", "expected object");
|
|
418
|
+
}
|
|
419
|
+
else if (hasOwnKey(value.providerError, "enabled")) {
|
|
420
|
+
if (typeof value.providerError.enabled === "boolean") {
|
|
421
|
+
patch.providerError = { enabled: value.providerError.enabled };
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
reportIssue?.("nativeQuotaNotifications.providerError.enabled", "expected boolean");
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (hasOwnKey(value, "duplicateCooldownMinutes")) {
|
|
429
|
+
if (isValidDuplicateCooldownMinutes(value.duplicateCooldownMinutes)) {
|
|
430
|
+
patch.duplicateCooldownMinutes = value.duplicateCooldownMinutes;
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
reportIssue?.("nativeQuotaNotifications.duplicateCooldownMinutes", "expected an integer of 0 or more");
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return Object.keys(patch).length > 0 ? patch : undefined;
|
|
437
|
+
}
|
|
294
438
|
function describeInvalidProviderValue(value) {
|
|
295
439
|
return typeof value === "string" ? value : typeof value;
|
|
296
440
|
}
|
|
@@ -317,7 +461,7 @@ export function normalizeEnabledProviders(value) {
|
|
|
317
461
|
continue;
|
|
318
462
|
}
|
|
319
463
|
const normalized = normalizeQuotaProviderId(provider);
|
|
320
|
-
if (normalized &&
|
|
464
|
+
if (normalized && getQuotaProviderRegistration(normalized)) {
|
|
321
465
|
validProviders.push(normalized);
|
|
322
466
|
}
|
|
323
467
|
else {
|
|
@@ -483,6 +627,31 @@ function normalizeTemporalProviderOverrides(value) {
|
|
|
483
627
|
}
|
|
484
628
|
return Object.fromEntries(overrides);
|
|
485
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
|
+
}
|
|
486
655
|
function extractDashboardPatch(value, reportIssue) {
|
|
487
656
|
if (!isPlainObject(value)) {
|
|
488
657
|
return undefined;
|
|
@@ -523,6 +692,8 @@ function extractDashboardPatch(value, reportIssue) {
|
|
|
523
692
|
}
|
|
524
693
|
// A layer without a v2 marker owns legacy semantics: a full provider-scope
|
|
525
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.
|
|
526
697
|
patch[key] =
|
|
527
698
|
key === "hiddenCards" && value.hiddenCardsVersion !== DASHBOARD_HIDDEN_CARDS_VERSION
|
|
528
699
|
? normalizeLegacyDashboardHiddenCards(ids)
|
|
@@ -537,6 +708,15 @@ function extractDashboardPatch(value, reportIssue) {
|
|
|
537
708
|
patch.temporalProviderOverrides = overrides;
|
|
538
709
|
}
|
|
539
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
|
+
}
|
|
540
720
|
return Object.keys(patch).length > 0 ? patch : undefined;
|
|
541
721
|
}
|
|
542
722
|
function extractValidatedQuotaToastPatch(quotaToastConfig, reportIssue, options = {}) {
|
|
@@ -553,6 +733,11 @@ function extractValidatedQuotaToastPatch(quotaToastConfig, reportIssue, options
|
|
|
553
733
|
if (resetNotifications)
|
|
554
734
|
patch.resetNotifications = resetNotifications;
|
|
555
735
|
}
|
|
736
|
+
if (hasOwnKey(quotaToastConfig, "nativeQuotaNotifications")) {
|
|
737
|
+
const nativeQuotaNotifications = extractNativeQuotaNotificationPolicyPatch(quotaToastConfig.nativeQuotaNotifications, reportIssue);
|
|
738
|
+
if (nativeQuotaNotifications)
|
|
739
|
+
patch.nativeQuotaNotifications = nativeQuotaNotifications;
|
|
740
|
+
}
|
|
556
741
|
if (hasOwnKey(quotaToastConfig, "lowQuotaThresholdRemainingPercent")) {
|
|
557
742
|
if (isValidLowQuotaThresholdRemainingPercent(quotaToastConfig.lowQuotaThresholdRemainingPercent)) {
|
|
558
743
|
patch.lowQuotaThresholdRemainingPercent = quotaToastConfig.lowQuotaThresholdRemainingPercent;
|
|
@@ -617,6 +802,10 @@ function extractValidatedQuotaToastPatch(quotaToastConfig, reportIssue, options
|
|
|
617
802
|
isPositiveNumber(quotaToastConfig.minIntervalMs)) {
|
|
618
803
|
patch.minIntervalMs = quotaToastConfig.minIntervalMs;
|
|
619
804
|
}
|
|
805
|
+
if (hasOwnKey(quotaToastConfig, "claudeAgentPollIntervalMs") &&
|
|
806
|
+
isPositiveNumber(quotaToastConfig.claudeAgentPollIntervalMs)) {
|
|
807
|
+
patch.claudeAgentPollIntervalMs = Math.max(ANTHROPIC_OAUTH_MIN_POLL_INTERVAL_MS, quotaToastConfig.claudeAgentPollIntervalMs);
|
|
808
|
+
}
|
|
620
809
|
if (hasOwnKey(quotaToastConfig, "requestTimeoutMs") &&
|
|
621
810
|
isPositiveNumber(quotaToastConfig.requestTimeoutMs)) {
|
|
622
811
|
patch.requestTimeoutMs = quotaToastConfig.requestTimeoutMs;
|
|
@@ -705,6 +894,10 @@ function extractValidatedQuotaToastPatch(quotaToastConfig, reportIssue, options
|
|
|
705
894
|
typeof quotaToastConfig.waitForQuotaReset === "boolean") {
|
|
706
895
|
patch.waitForQuotaReset = quotaToastConfig.waitForQuotaReset;
|
|
707
896
|
}
|
|
897
|
+
if (hasOwnKey(quotaToastConfig, "autoResumeOnQuotaRecovery") &&
|
|
898
|
+
typeof quotaToastConfig.autoResumeOnQuotaRecovery === "boolean") {
|
|
899
|
+
patch.autoResumeOnQuotaRecovery = quotaToastConfig.autoResumeOnQuotaRecovery;
|
|
900
|
+
}
|
|
708
901
|
if (hasOwnKey(quotaToastConfig, "showSessionTokens") &&
|
|
709
902
|
typeof quotaToastConfig.showSessionTokens === "boolean") {
|
|
710
903
|
patch.showSessionTokens = quotaToastConfig.showSessionTokens;
|
|
@@ -770,7 +963,7 @@ function extractValidatedQuotaToastPatch(quotaToastConfig, reportIssue, options
|
|
|
770
963
|
function applySettingSource(settingSources, key, sourcePath) {
|
|
771
964
|
settingSources[key] = sourcePath;
|
|
772
965
|
}
|
|
773
|
-
function applyValidatedQuotaToastPatch(config, patch, sourcePath, settingSources) {
|
|
966
|
+
function applyValidatedQuotaToastPatch(config, patch, sourcePath, settingSources, nativeQuotaNotificationCanonicalFields = new Set()) {
|
|
774
967
|
if (hasOwnKey(patch, "enabled")) {
|
|
775
968
|
config.enabled = patch.enabled;
|
|
776
969
|
applySettingSource(settingSources, "enabled", sourcePath);
|
|
@@ -789,13 +982,60 @@ function applyValidatedQuotaToastPatch(config, patch, sourcePath, settingSources
|
|
|
789
982
|
applySettingSource(settingSources, "resetNotifications.windows", sourcePath);
|
|
790
983
|
}
|
|
791
984
|
}
|
|
985
|
+
if (patch.nativeQuotaNotifications) {
|
|
986
|
+
const policy = patch.nativeQuotaNotifications;
|
|
987
|
+
if (hasOwnKey(policy, "enabled")) {
|
|
988
|
+
config.nativeQuotaNotifications.enabled = policy.enabled;
|
|
989
|
+
}
|
|
990
|
+
if (hasOwnKey(policy, "modelChangeToastEnabled")) {
|
|
991
|
+
config.nativeQuotaNotifications.modelChangeToastEnabled = policy.modelChangeToastEnabled;
|
|
992
|
+
}
|
|
993
|
+
if (policy.low) {
|
|
994
|
+
if (hasOwnKey(policy.low, "enabled")) {
|
|
995
|
+
config.nativeQuotaNotifications.low.enabled = policy.low.enabled;
|
|
996
|
+
}
|
|
997
|
+
if (hasOwnKey(policy.low, "thresholdRemainingPercent")) {
|
|
998
|
+
config.nativeQuotaNotifications.low.thresholdRemainingPercent =
|
|
999
|
+
policy.low.thresholdRemainingPercent;
|
|
1000
|
+
nativeQuotaNotificationCanonicalFields.add("low.thresholdRemainingPercent");
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
if (policy.exhausted && hasOwnKey(policy.exhausted, "enabled")) {
|
|
1004
|
+
config.nativeQuotaNotifications.exhausted.enabled = policy.exhausted.enabled;
|
|
1005
|
+
}
|
|
1006
|
+
if (policy.reset) {
|
|
1007
|
+
if (hasOwnKey(policy.reset, "enabled")) {
|
|
1008
|
+
config.nativeQuotaNotifications.reset.enabled = policy.reset.enabled;
|
|
1009
|
+
}
|
|
1010
|
+
if (hasOwnKey(policy.reset, "windows")) {
|
|
1011
|
+
config.nativeQuotaNotifications.reset.windows = [...policy.reset.windows];
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
if (policy.providerError && hasOwnKey(policy.providerError, "enabled")) {
|
|
1015
|
+
config.nativeQuotaNotifications.providerError.enabled = policy.providerError.enabled;
|
|
1016
|
+
}
|
|
1017
|
+
if (hasOwnKey(policy, "duplicateCooldownMinutes")) {
|
|
1018
|
+
config.nativeQuotaNotifications.duplicateCooldownMinutes = policy.duplicateCooldownMinutes;
|
|
1019
|
+
nativeQuotaNotificationCanonicalFields.add("duplicateCooldownMinutes");
|
|
1020
|
+
}
|
|
1021
|
+
applySettingSource(settingSources, "nativeQuotaNotifications", sourcePath);
|
|
1022
|
+
}
|
|
792
1023
|
if (hasOwnKey(patch, "lowQuotaThresholdRemainingPercent")) {
|
|
793
1024
|
config.lowQuotaThresholdRemainingPercent = patch.lowQuotaThresholdRemainingPercent;
|
|
794
1025
|
applySettingSource(settingSources, "lowQuotaThresholdRemainingPercent", sourcePath);
|
|
1026
|
+
if (!nativeQuotaNotificationCanonicalFields.has("low.thresholdRemainingPercent")) {
|
|
1027
|
+
config.nativeQuotaNotifications.low.thresholdRemainingPercent =
|
|
1028
|
+
patch.lowQuotaThresholdRemainingPercent;
|
|
1029
|
+
applySettingSource(settingSources, "nativeQuotaNotifications", sourcePath);
|
|
1030
|
+
}
|
|
795
1031
|
}
|
|
796
1032
|
if (hasOwnKey(patch, "duplicateCooldownMinutes")) {
|
|
797
1033
|
config.duplicateCooldownMinutes = patch.duplicateCooldownMinutes;
|
|
798
1034
|
applySettingSource(settingSources, "duplicateCooldownMinutes", sourcePath);
|
|
1035
|
+
if (!nativeQuotaNotificationCanonicalFields.has("duplicateCooldownMinutes")) {
|
|
1036
|
+
config.nativeQuotaNotifications.duplicateCooldownMinutes = patch.duplicateCooldownMinutes;
|
|
1037
|
+
applySettingSource(settingSources, "nativeQuotaNotifications", sourcePath);
|
|
1038
|
+
}
|
|
799
1039
|
}
|
|
800
1040
|
if (hasOwnKey(patch, "tuiCommandDisplay")) {
|
|
801
1041
|
config.tuiCommandDisplay = patch.tuiCommandDisplay;
|
|
@@ -833,6 +1073,10 @@ function applyValidatedQuotaToastPatch(config, patch, sourcePath, settingSources
|
|
|
833
1073
|
config.minIntervalMs = patch.minIntervalMs;
|
|
834
1074
|
applySettingSource(settingSources, "minIntervalMs", sourcePath);
|
|
835
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
|
+
}
|
|
836
1080
|
if (hasOwnKey(patch, "requestTimeoutMs")) {
|
|
837
1081
|
config.requestTimeoutMs = patch.requestTimeoutMs;
|
|
838
1082
|
applySettingSource(settingSources, "requestTimeoutMs", sourcePath);
|
|
@@ -910,6 +1154,10 @@ function applyValidatedQuotaToastPatch(config, patch, sourcePath, settingSources
|
|
|
910
1154
|
config.waitForQuotaReset = patch.waitForQuotaReset;
|
|
911
1155
|
applySettingSource(settingSources, "waitForQuotaReset", sourcePath);
|
|
912
1156
|
}
|
|
1157
|
+
if (hasOwnKey(patch, "autoResumeOnQuotaRecovery")) {
|
|
1158
|
+
config.autoResumeOnQuotaRecovery = patch.autoResumeOnQuotaRecovery;
|
|
1159
|
+
applySettingSource(settingSources, "autoResumeOnQuotaRecovery", sourcePath);
|
|
1160
|
+
}
|
|
913
1161
|
if (hasOwnKey(patch, "showSessionTokens")) {
|
|
914
1162
|
config.showSessionTokens = patch.showSessionTokens;
|
|
915
1163
|
applySettingSource(settingSources, "showSessionTokens", sourcePath);
|
|
@@ -1032,6 +1280,10 @@ function applyValidatedQuotaToastPatch(config, patch, sourcePath, settingSources
|
|
|
1032
1280
|
config.dashboard.cardOrder = [...patch.dashboard.cardOrder];
|
|
1033
1281
|
applySettingSource(settingSources, "dashboard.cardOrder", sourcePath);
|
|
1034
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
|
+
}
|
|
1035
1287
|
if (patch.dashboard.temporalProviderOverrides) {
|
|
1036
1288
|
config.dashboard.temporalProviderOverrides = {
|
|
1037
1289
|
...patch.dashboard.temporalProviderOverrides,
|
|
@@ -1148,6 +1400,7 @@ export async function loadConfigLayered(client, meta, options) {
|
|
|
1148
1400
|
const globalConfigPaths = [];
|
|
1149
1401
|
const workspaceConfigPaths = [];
|
|
1150
1402
|
const settingSources = {};
|
|
1403
|
+
const nativeQuotaNotificationCanonicalFields = new Set();
|
|
1151
1404
|
const settingSourceLayers = {};
|
|
1152
1405
|
const configIssues = [];
|
|
1153
1406
|
const authoritativeSidecarRoots = new Set();
|
|
@@ -1212,7 +1465,7 @@ export async function loadConfigLayered(client, meta, options) {
|
|
|
1212
1465
|
}
|
|
1213
1466
|
applyValidatedQuotaToastPatch(config, extractValidatedQuotaToastPatch(extractedQuotaToast, (key, message) => {
|
|
1214
1467
|
configIssues.push({ path: sourcePath, key, message });
|
|
1215
|
-
}, { allowZeroMonthlyLimit: candidate.kind === "canonical" }), sourcePath, settingSources);
|
|
1468
|
+
}, { allowZeroMonthlyLimit: candidate.kind === "canonical" }), sourcePath, settingSources, nativeQuotaNotificationCanonicalFields);
|
|
1216
1469
|
if (hasOwnKey(extractedQuotaToast, "alibabaCodingPlanTier")) {
|
|
1217
1470
|
configIssues.push({
|
|
1218
1471
|
path: sourcePath,
|