tuxevil-rotator 3.0.0 → 3.1.0

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/src/rotator.ts CHANGED
@@ -23,7 +23,6 @@ import {
23
23
  REQUEST_GOOG_API_CLIENT,
24
24
  REQUEST_CLIENT_METADATA,
25
25
  ANTIGRAVITY_ENDPOINTS,
26
- KICKSTART_MODEL_FOR_QUOTA_POOL,
27
26
  OLLAMA_TAGS_URL,
28
27
  OLLAMA_USER_AGENT,
29
28
  TAGS_CACHE_TTL_MS,
@@ -59,6 +58,14 @@ import {
59
58
  import type { QuotaFetchContext } from "./providers/adapter.js";
60
59
  import { logger } from "./logger.js";
61
60
  import { getAccountProxyDispatcher } from "./providers/proxy-dispatcher.js";
61
+ import {
62
+ fetchCodexCatalog,
63
+ getCodexModels,
64
+ isCodexRequestModel,
65
+ isCodexProviderModelId,
66
+ } from "./providers/openai-codex/catalog.js";
67
+ import { CodexOAuthError } from "./providers/openai-codex/oauth.js";
68
+ import { CODEX_QUOTA_MODEL_KEY } from "./providers/openai-codex/quota.js";
62
69
  import { getUpdateInfo } from "./version-check.js";
63
70
  import { getNotifications } from "./notification-poller.js";
64
71
  import { getConfiguredAdminToken } from "./admin-auth.js";
@@ -119,6 +126,7 @@ export class AccountRotator {
119
126
  private static readonly MAX_LATENCY_RECORDS = 200;
120
127
  private requestLog: StatusResponse["requestLog"] = [];
121
128
  private ollamaModels = new Set<string>();
129
+ private codexModels = new Set<string>(getCodexModels().map((model) => model.id));
122
130
  private readonly usagePredictor = new UsagePredictor();
123
131
  private lastOllamaCatalogFetch = 0;
124
132
 
@@ -130,6 +138,41 @@ export class AccountRotator {
130
138
  return [...this.ollamaModels];
131
139
  }
132
140
 
141
+ hasActiveProvider(providerId: string): boolean {
142
+ return this.accounts.some(
143
+ (account) =>
144
+ !account.disabled &&
145
+ !account.flagged &&
146
+ hasCredential(account.config, providerId),
147
+ );
148
+ }
149
+
150
+ setCodexModels(models: string[]): void {
151
+ this.codexModels = new Set(
152
+ models
153
+ .map((model) => model.trim())
154
+ .filter((model): model is string => isCodexProviderModelId(model)),
155
+ );
156
+ }
157
+
158
+ getCodexModels(): string[] {
159
+ return [...this.codexModels];
160
+ }
161
+
162
+ async primeCodexCatalog(): Promise<void> {
163
+ const account = this.accounts.find(
164
+ (candidate) => hasCredential(candidate.config, "openai-codex") && !candidate.disabled && !candidate.flagged,
165
+ );
166
+ if (!account) return;
167
+ try {
168
+ await this.ensureValidTokenForProvider(account, "openai-codex");
169
+ const models = await fetchCodexCatalog(account);
170
+ this.setCodexModels(models.map((model) => model.id));
171
+ } catch {
172
+ // The verified base allowlist stays active when discovery is unavailable.
173
+ }
174
+ }
175
+
133
176
  /** Fetch the Ollama Cloud catalog once at startup so provider-aware routing and /v1/models work before the first quota poll. */
134
177
  primeOllamaCatalog(): Promise<void> {
135
178
  return this.refreshOllamaCatalogOnce();
@@ -585,7 +628,7 @@ export class AccountRotator {
585
628
  private logConsolidatedPoll(account: AccountRuntime): void {
586
629
  const stash = account.lastPollByProvider;
587
630
  if (!stash) return;
588
- const ordered = ["google-antigravity", "ollama"]
631
+ const ordered = ["google-antigravity", "ollama", "openai-codex", "opencode-zen"]
589
632
  .filter((pid) => stash[pid])
590
633
  .map((pid) => `${pid}: ${stash[pid]}`);
591
634
  if (ordered.length > 0) {
@@ -602,13 +645,16 @@ export class AccountRotator {
602
645
  const available = this.accounts.filter((a) => !a.disabled && !a.flagged);
603
646
  for (const account of available) {
604
647
  try {
605
- await this.ensureValidToken(account);
606
648
  const quotaCtx: QuotaFetchContext = {
607
649
  log: (message) => this.log(message),
608
650
  markFlagged: (acc, reason, options) =>
609
651
  this.markFlagged(acc, reason, options),
610
652
  reportQuotaPollFlag: (acc, statusCode, errorText) =>
611
653
  this.reportQuotaPollFlag(acc, statusCode, errorText),
654
+ markProviderInvalid: (acc, providerId, reason) =>
655
+ this.markProviderInvalid(acc, providerId, reason),
656
+ setProviderCooldown: (acc, providerId, durationMs) =>
657
+ this.setProviderCooldown(acc, providerId, durationMs),
612
658
  };
613
659
  // Parent-account model: poll quota for every provider credential
614
660
  // the account holds (Google OAuth pools + Ollama usage pools).
@@ -617,7 +663,12 @@ export class AccountRotator {
617
663
  );
618
664
  if (providerIds.size === 0) providerIds.add(primaryProviderId(account.config));
619
665
  for (const pid of providerIds) {
620
- await getProviderAdapter(pid).fetchQuota(account, quotaCtx);
666
+ try {
667
+ await this.ensureValidTokenForProvider(account, pid);
668
+ await getProviderAdapter(pid).fetchQuota(account, quotaCtx);
669
+ } catch {
670
+ // One invalid provider credential must not suppress sibling pools.
671
+ }
621
672
  }
622
673
  } catch {
623
674
  // Token refresh or quota fetch failed, skip this account
@@ -633,20 +684,19 @@ export class AccountRotator {
633
684
  // pools (100% quota with resetTime very close to a full 5h or 7d window — timer exists but
634
685
  // untouched). Deduplicates by upstream model within this cycle.
635
686
  if (this.autoWarmupEnabled && account.allowFreshWindowStartsOverride) {
636
- const idlePools = account.quota.filter((q) => this.isQuotaIdleForKickstart(q));
687
+ const idlePools = account.quota.filter(
688
+ (q) =>
689
+ this.isQuotaIdleForKickstart(q) &&
690
+ this.getKickstartTarget(account, q.modelKey) !== null,
691
+ );
637
692
  if (idlePools.length > 0) {
638
693
  const alreadySent =
639
694
  this.warmupSentThisCycle.get(account.config.email) ?? new Set<string>();
640
695
  const upstreamToQuotaKey = new Map<string, string>();
641
696
  for (const q of idlePools) {
642
- // Dispatch warmup by pool owner: the session pool belongs to
643
- // Ollama; every other pool key is a Google OAuth pool.
644
- const warmupAdapter =
645
- q.modelKey === "session"
646
- ? getProviderAdapter("ollama")
647
- : getProviderForAccount(account.config);
648
- const upstream =
649
- warmupAdapter.getKickstartModelForPool(q.modelKey) ?? q.modelKey;
697
+ const target = this.getKickstartTarget(account, q.modelKey);
698
+ if (!target) continue;
699
+ const upstream = target.upstreamModel;
650
700
  if (!upstreamToQuotaKey.has(upstream)) {
651
701
  upstreamToQuotaKey.set(upstream, q.modelKey);
652
702
  }
@@ -739,7 +789,10 @@ export class AccountRotator {
739
789
 
740
790
  // Get quota % for a specific model on an account. Returns -1 if no data.
741
791
  private getModelQuota(account: AccountRuntime, modelKey: string): number {
742
- const q = account.quota.find((q) => q.modelKey === modelKey);
792
+ const q = account.quota.find((q) => q.modelKey === modelKey) ??
793
+ (modelKey.startsWith(`${CODEX_QUOTA_MODEL_KEY}:`)
794
+ ? account.quota.find((candidate) => candidate.modelKey === CODEX_QUOTA_MODEL_KEY)
795
+ : undefined);
743
796
  return q ? q.percentRemaining : -1;
744
797
  }
745
798
 
@@ -748,7 +801,10 @@ export class AccountRotator {
748
801
  account: AccountRuntime,
749
802
  modelKey: string,
750
803
  ): "fresh" | "5h" | "7d" {
751
- const q = account.quota.find((q) => q.modelKey === modelKey);
804
+ const q = account.quota.find((q) => q.modelKey === modelKey) ??
805
+ (modelKey.startsWith(`${CODEX_QUOTA_MODEL_KEY}:`)
806
+ ? account.quota.find((candidate) => candidate.modelKey === CODEX_QUOTA_MODEL_KEY)
807
+ : undefined);
752
808
  return q?.timerType ?? "fresh";
753
809
  }
754
810
 
@@ -765,6 +821,32 @@ export class AccountRotator {
765
821
  return within(5 * 3600 * 1000) || within(7 * 24 * 3600 * 1000);
766
822
  }
767
823
 
824
+ /**
825
+ * Resolve kickstart by quota-pool owner, never by the account's primary
826
+ * provider. Parent accounts may hold several credentials, and Codex pools
827
+ * deliberately have no kickstart implementation.
828
+ */
829
+ private getKickstartTarget(
830
+ account: AccountRuntime,
831
+ quotaModelKey: string,
832
+ ): { providerId: string; adapter: ReturnType<typeof getProviderAdapter>; upstreamModel: string } | null {
833
+ const quota = account.quota.find((candidate) => candidate.modelKey === quotaModelKey);
834
+ const providerId =
835
+ quota?.providerId ??
836
+ (quotaModelKey === "session"
837
+ ? "ollama"
838
+ : quotaModelKey === CODEX_QUOTA_MODEL_KEY ||
839
+ quotaModelKey.startsWith(`${CODEX_QUOTA_MODEL_KEY}:`)
840
+ ? "openai-codex"
841
+ : DEFAULT_PROVIDER);
842
+ if (!hasCredential(account.config, providerId)) return null;
843
+
844
+ const adapter = getProviderAdapter(providerId);
845
+ const upstreamModel = adapter.getKickstartModelForPool(quotaModelKey);
846
+ if (!upstreamModel) return null;
847
+ return { providerId, adapter, upstreamModel };
848
+ }
849
+
768
850
  // Timer priority for a specific model:
769
851
  // 1 (highest) = 5h timer -> only class with hard quota loss if underused before reset
770
852
  // 2 = 7d timer -> already ticking, keep those long windows moving
@@ -1483,13 +1565,18 @@ export class AccountRotator {
1483
1565
  }
1484
1566
 
1485
1567
  if (modelKey && state) {
1486
- const restored = await this.restorePreferredModelAccount(
1487
- modelKey,
1488
- now,
1489
- state,
1490
- idx,
1491
- );
1492
- if (restored) return restored;
1568
+ try {
1569
+ const restored = await this.restorePreferredModelAccount(
1570
+ modelKey,
1571
+ now,
1572
+ state,
1573
+ idx,
1574
+ );
1575
+ if (restored) return restored;
1576
+ } catch (error) {
1577
+ if (!this.isCodexPoolKey(modelKey)) throw error;
1578
+ return this.rotateModelForRequest(modelKey, now, idx);
1579
+ }
1493
1580
  }
1494
1581
 
1495
1582
  if (current && modelKey && !this.isProviderEligibleForKey(current, modelKey)) {
@@ -1551,12 +1638,15 @@ export class AccountRotator {
1551
1638
  }
1552
1639
  this.startRequest(current, modelKey ?? undefined);
1553
1640
  try {
1554
- await this.ensureValidToken(current);
1641
+ await this.ensureValidTokenForModel(current, modelKey);
1555
1642
  if (modelKey) this.countModelAssignment(modelKey);
1556
1643
  return current;
1557
1644
  } catch (err) {
1558
1645
  this.refundTokenBucket(current, Date.now());
1559
1646
  this.finishRequest(current, modelKey ?? undefined);
1647
+ if (modelKey && this.isCodexPoolKey(modelKey)) {
1648
+ return this.rotateModelForRequest(modelKey, now, idx);
1649
+ }
1560
1650
  throw err;
1561
1651
  }
1562
1652
  }
@@ -1642,7 +1732,15 @@ export class AccountRotator {
1642
1732
  this.log(
1643
1733
  `[${modelKey}] Rotated to ${best.config.label || best.config.email} [${timerType}] (quota: ${quota >= 0 ? quota + "%" : "unknown"})`,
1644
1734
  );
1645
- return this.activateModelAccount(modelKey, best, stickyAccountIndex);
1735
+ try {
1736
+ return await this.activateModelAccount(modelKey, best, stickyAccountIndex);
1737
+ } catch (error) {
1738
+ if (!this.isCodexPoolKey(modelKey)) throw error;
1739
+ // A bad Codex refresh token is provider-scoped. The failed account is
1740
+ // marked invalid by ensureValidTokenForProvider, so retry selection
1741
+ // with the next Codex account without touching Google/Ollama pools.
1742
+ return this.rotateModel(modelKey, now, this.accounts.indexOf(best));
1743
+ }
1646
1744
  }
1647
1745
 
1648
1746
  if (
@@ -1707,7 +1805,7 @@ export class AccountRotator {
1707
1805
  await this.saveState();
1708
1806
  this.startRequest(account, modelKey);
1709
1807
  try {
1710
- await this.ensureValidToken(account);
1808
+ await this.ensureValidTokenForModel(account, modelKey);
1711
1809
  return account;
1712
1810
  } catch (err) {
1713
1811
  this.refundTokenBucket(account, Date.now());
@@ -2303,8 +2401,11 @@ export class AccountRotator {
2303
2401
  ): void {
2304
2402
  const now = Date.now();
2305
2403
  const modelKey = model
2306
- ? (resolveQuotaModelKey(model) ?? "__default__")
2404
+ ? (this.resolvePoolKeyForModel(model) ?? resolveQuotaModelKey(model) ?? "__default__")
2307
2405
  : "__default__";
2406
+ if (model && (modelKey.startsWith(`${CODEX_QUOTA_MODEL_KEY}:`) || isCodexRequestModel(model))) {
2407
+ this.setProviderCooldown(account, "openai-codex", cooldownMs);
2408
+ }
2308
2409
  account.cooldownsByModel[modelKey] = now + cooldownMs;
2309
2410
  account.quotaExhaustedAt = now;
2310
2411
 
@@ -2323,6 +2424,10 @@ export class AccountRotator {
2323
2424
  providerResourceExhausted = false,
2324
2425
  ): void {
2325
2426
  const now = Date.now();
2427
+ if (model && isCodexRequestModel(model)) {
2428
+ this.setProviderCooldown(account, "openai-codex", cooldownMs);
2429
+ return;
2430
+ }
2326
2431
  if (providerResourceExhausted) {
2327
2432
  // Account-level daily/weekly quota exhaustion is not a model outage:
2328
2433
  // the account already gets an individual cooldown from markExhausted,
@@ -2331,7 +2436,7 @@ export class AccountRotator {
2331
2436
  return;
2332
2437
  }
2333
2438
  const modelKey = model
2334
- ? (resolveQuotaModelKey(model) ?? "__default__")
2439
+ ? (this.resolvePoolKeyForModel(model) ?? resolveQuotaModelKey(model) ?? "__default__")
2335
2440
  : "__default__";
2336
2441
  const windowMs =
2337
2442
  this.config.projectCircuitBreakerWindowMs ?? 10 * 60 * 1000;
@@ -2612,6 +2717,75 @@ export class AccountRotator {
2612
2717
  }
2613
2718
  }
2614
2719
 
2720
+ async ensureValidTokenForProvider(
2721
+ account: AccountRuntime,
2722
+ providerId: string,
2723
+ ): Promise<void> {
2724
+ const adapter = getProviderAdapter(providerId);
2725
+ try {
2726
+ await adapter.ensureValidToken(account);
2727
+ } catch (error) {
2728
+ if (
2729
+ providerId === "openai-codex" &&
2730
+ (error instanceof CodexOAuthError ||
2731
+ (typeof error === "object" && error !== null &&
2732
+ (error as { reloginRequired?: unknown }).reloginRequired === true))
2733
+ ) {
2734
+ const reason = error instanceof Error
2735
+ ? error.message
2736
+ : "Codex credential requires re-authentication";
2737
+ this.markProviderInvalid(account, providerId, reason);
2738
+ }
2739
+ throw error;
2740
+ }
2741
+ }
2742
+
2743
+ private isCodexPoolKey(modelKey: string): boolean {
2744
+ return modelKey.startsWith(`${CODEX_QUOTA_MODEL_KEY}:`);
2745
+ }
2746
+
2747
+ private async ensureValidTokenForModel(
2748
+ account: AccountRuntime,
2749
+ modelKey: string | null,
2750
+ ): Promise<void> {
2751
+ if (modelKey?.startsWith(`${CODEX_QUOTA_MODEL_KEY}:`)) {
2752
+ await this.ensureValidTokenForProvider(account, "openai-codex");
2753
+ return;
2754
+ }
2755
+ if (modelKey === "session") {
2756
+ await this.ensureValidTokenForProvider(account, "ollama");
2757
+ return;
2758
+ }
2759
+ await this.ensureValidToken(account);
2760
+ }
2761
+
2762
+ markProviderInvalid(
2763
+ account: AccountRuntime,
2764
+ providerId: string,
2765
+ reason: string,
2766
+ ): void {
2767
+ account.invalidProviders ??= {};
2768
+ account.invalidProviders[providerId] = reason;
2769
+ account.providerTokens ??= {};
2770
+ account.providerTokens[providerId] = { accessToken: null, tokenExpires: 0 };
2771
+ account.lastError = reason;
2772
+ this.log(`${account.config.email}: ${providerId} credential requires re-authentication`, "warn");
2773
+ this.scheduleStateSave();
2774
+ }
2775
+
2776
+ setProviderCooldown(
2777
+ account: AccountRuntime,
2778
+ providerId: string,
2779
+ durationMs: number,
2780
+ ): void {
2781
+ account.providerCooldowns ??= {};
2782
+ account.providerCooldowns[providerId] = Math.max(
2783
+ account.providerCooldowns[providerId] ?? 0,
2784
+ Date.now() + Math.max(0, durationMs),
2785
+ );
2786
+ this.scheduleStateSave();
2787
+ }
2788
+
2615
2789
  private isAvailable(account: AccountRuntime, now: number): boolean {
2616
2790
  if (account.disabled) return false;
2617
2791
  if (account.flagged) return false;
@@ -2626,6 +2800,10 @@ export class AccountRotator {
2626
2800
  now: number,
2627
2801
  ): boolean {
2628
2802
  if (!this.isAvailable(account, now)) return false;
2803
+ if (modelKey.startsWith(`${CODEX_QUOTA_MODEL_KEY}:`)) {
2804
+ if (account.invalidProviders?.["openai-codex"]) return false;
2805
+ if ((account.providerCooldowns?.["openai-codex"] ?? 0) > now) return false;
2806
+ }
2629
2807
  const modelCooldown = account.cooldownsByModel[modelKey] ?? 0;
2630
2808
  if (modelCooldown > now) return false;
2631
2809
  // Ollama Cloud (pool key "session") imposes no per-account concurrency
@@ -2701,6 +2879,11 @@ export class AccountRotator {
2701
2879
  account: AccountRuntime,
2702
2880
  modelKey: string,
2703
2881
  ): boolean {
2882
+ if (modelKey.startsWith(`${CODEX_QUOTA_MODEL_KEY}:`)) {
2883
+ return hasCredential(account.config, "openai-codex") &&
2884
+ !account.invalidProviders?.["openai-codex"] &&
2885
+ (account.providerCooldowns?.["openai-codex"] ?? 0) <= Date.now();
2886
+ }
2704
2887
  if (modelKey === "session") {
2705
2888
  return hasCredential(account.config, "ollama");
2706
2889
  }
@@ -2715,6 +2898,9 @@ export class AccountRotator {
2715
2898
  }
2716
2899
 
2717
2900
  private resolvePoolKeyForModel(model: string): string | null {
2901
+ if (this.codexModels.has(model) || isCodexRequestModel(model)) {
2902
+ return `${CODEX_QUOTA_MODEL_KEY}:${model}`;
2903
+ }
2718
2904
  if (this.ollamaModels.has(model)) return "session";
2719
2905
  return resolveQuotaModelKey(model) ?? null;
2720
2906
  }
@@ -2754,7 +2940,7 @@ export class AccountRotator {
2754
2940
  if (this.protectivePauseUntil > now)
2755
2941
  retryTimes.push(this.protectivePauseUntil);
2756
2942
  const modelKey = model
2757
- ? (resolveQuotaModelKey(model) ?? "__default__")
2943
+ ? (this.resolvePoolKeyForModel(model) ?? resolveQuotaModelKey(model) ?? "__default__")
2758
2944
  : "__default__";
2759
2945
  const dailyResetAt = nextUtcDayStartMs(now);
2760
2946
  const modelBreaker = this.modelBreakers[modelKey] ?? 0;
@@ -2837,6 +3023,8 @@ export class AccountRotator {
2837
3023
  lastError: a.lastError,
2838
3024
  consecutiveErrors: a.consecutiveErrors,
2839
3025
  hasValidToken: !!(a.accessToken && a.tokenExpires > now),
3026
+ invalidProviders: a.invalidProviders,
3027
+ providerCooldowns: a.providerCooldowns,
2840
3028
  quota: a.quota,
2841
3029
  inFlightRequests: a.inFlightRequests,
2842
3030
  inFlightByModel: a.inFlightByModel,
@@ -2939,6 +3127,7 @@ export class AccountRotator {
2939
3127
  notifications: getNotifications(),
2940
3128
  hostedOAuthConfigured: isHostedOAuthConfigured(),
2941
3129
  ollamaModels: this.getOllamaModels(),
3130
+ codexModels: this.getCodexModels(),
2942
3131
  modelTierAccess: this.accounts.some((a) =>
2943
3132
  hasCredential(a.config, "ollama"),
2944
3133
  )
@@ -3425,8 +3614,18 @@ export class AccountRotator {
3425
3614
  };
3426
3615
  }
3427
3616
 
3617
+ const target = this.getKickstartTarget(account, quotaModelKey);
3618
+ if (!target) {
3619
+ return {
3620
+ ok: false,
3621
+ status: 409,
3622
+ upstreamModel: "",
3623
+ error: "quota pool has no configured kickstart provider",
3624
+ };
3625
+ }
3626
+
3428
3627
  try {
3429
- await this.ensureValidToken(account);
3628
+ await this.ensureValidTokenForProvider(account, target.providerId);
3430
3629
  } catch (err) {
3431
3630
  return {
3432
3631
  ok: false,
@@ -3436,18 +3635,13 @@ export class AccountRotator {
3436
3635
  };
3437
3636
  }
3438
3637
 
3439
- const kickstartAdapter =
3440
- quotaModelKey === "session"
3441
- ? getProviderAdapter("ollama")
3442
- : getProviderForAccount(account.config);
3638
+ const kickstartAdapter = target.adapter;
3443
3639
  const isOllamaAccount = kickstartAdapter.id === "ollama";
3444
3640
  if (!account.accessToken && !isOllamaAccount) {
3445
3641
  return { ok: false, status: 401, upstreamModel: "", error: "no access token" };
3446
3642
  }
3447
3643
 
3448
- const upstreamModel =
3449
- kickstartAdapter.getKickstartModelForPool(quotaModelKey) ??
3450
- quotaModelKey;
3644
+ const upstreamModel = target.upstreamModel;
3451
3645
 
3452
3646
  const controller = new AbortController();
3453
3647
  const timeout = setTimeout(() => controller.abort(), 15_000);
@@ -3579,7 +3773,11 @@ export class AccountRotator {
3579
3773
  return { ok: false, error: "account not found", results: [] };
3580
3774
  }
3581
3775
 
3582
- const idlePools = account.quota.filter((q) => this.isQuotaIdleForKickstart(q));
3776
+ const idlePools = account.quota.filter(
3777
+ (q) =>
3778
+ this.isQuotaIdleForKickstart(q) &&
3779
+ this.getKickstartTarget(account, q.modelKey) !== null,
3780
+ );
3583
3781
  if (idlePools.length === 0) {
3584
3782
  return { ok: true, results: [] };
3585
3783
  }
@@ -3587,7 +3785,9 @@ export class AccountRotator {
3587
3785
  // Deduplicate: group quota pool keys by their upstream model
3588
3786
  const upstreamToQuotaPools = new Map<string, string[]>();
3589
3787
  for (const q of idlePools) {
3590
- const upstream = KICKSTART_MODEL_FOR_QUOTA_POOL[q.modelKey] ?? q.modelKey;
3788
+ const target = this.getKickstartTarget(account, q.modelKey);
3789
+ if (!target) continue;
3790
+ const upstream = target.upstreamModel;
3591
3791
  const list = upstreamToQuotaPools.get(upstream) ?? [];
3592
3792
  list.push(q.modelKey);
3593
3793
  upstreamToQuotaPools.set(upstream, list);