@cortexkit/opencode-antigravity-auth 3.0.23 → 3.0.25
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/dist/cli.js +32 -3
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +8 -8
- package/dist/index.js +247 -68
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +12 -12
- package/dist/server.js +380 -98
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/auth-method-labels.d.ts +1 -0
- package/dist/src/auth-method-labels.d.ts.map +1 -1
- package/dist/src/auth-method-labels.js +1 -0
- package/dist/src/auth-method-labels.js.map +1 -1
- package/dist/src/ga/server/auth.d.ts.map +1 -1
- package/dist/src/ga/server/auth.js +63 -21
- package/dist/src/ga/server/auth.js.map +1 -1
- package/dist/src/ga/server/pool-login.d.ts +4 -0
- package/dist/src/ga/server/pool-login.d.ts.map +1 -1
- package/dist/src/ga/server/pool-login.js +22 -1
- package/dist/src/ga/server/pool-login.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +42 -4
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/shared/request-services.d.ts +4 -0
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +71 -23
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/setup.d.ts.map +1 -1
- package/dist/src/setup.js +38 -4
- package/dist/src/setup.js.map +1 -1
- package/dist/types/src/auth-method-labels.d.ts +1 -0
- package/dist/types/src/auth-method-labels.d.ts.map +1 -1
- package/dist/types/src/ga/server/auth.d.ts.map +1 -1
- package/dist/types/src/ga/server/pool-login.d.ts +4 -0
- package/dist/types/src/ga/server/pool-login.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts +4 -0
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/setup.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -6870,8 +6870,11 @@ var init_account_selector = __esm({
|
|
|
6870
6870
|
rateLimitResetTimes: { ...a.rateLimitResetTimes }
|
|
6871
6871
|
}));
|
|
6872
6872
|
}
|
|
6873
|
-
|
|
6874
|
-
return this.
|
|
6873
|
+
getEligibleAccounts(excludeIndexes) {
|
|
6874
|
+
return this.accounts.filter((a) => a.enabled !== false && a.accountIneligible !== true && a.verificationRequired !== true && !excludeIndexes?.has(a.index));
|
|
6875
|
+
}
|
|
6876
|
+
getEffectiveSoftQuotaThreshold(thresholdPercent, excludeIndexes) {
|
|
6877
|
+
return this.getEligibleAccounts(excludeIndexes).length > 1 ? thresholdPercent : 100;
|
|
6875
6878
|
}
|
|
6876
6879
|
getRequestSessionState(identity3) {
|
|
6877
6880
|
const now = this.now();
|
|
@@ -6974,7 +6977,7 @@ var init_account_selector = __esm({
|
|
|
6974
6977
|
const currentIndex = this.getActiveIndex(family, identity3);
|
|
6975
6978
|
if (currentIndex >= 0 && currentIndex < this.accounts.length) {
|
|
6976
6979
|
const account = this.accounts[currentIndex] ?? null;
|
|
6977
|
-
if (account && account.enabled !== false) {
|
|
6980
|
+
if (account && account.enabled !== false && account.accountIneligible !== true && account.verificationRequired !== true) {
|
|
6978
6981
|
return account;
|
|
6979
6982
|
}
|
|
6980
6983
|
}
|
|
@@ -7017,7 +7020,7 @@ var init_account_selector = __esm({
|
|
|
7017
7020
|
}
|
|
7018
7021
|
getCurrentOrNextForFamily(family, model, strategy = "sticky", pidOffsetEnabled = false, softQuotaThresholdPercent = 100, softQuotaCacheTtlMs = 10 * 60 * 1e3, identity3, excludeIndexes) {
|
|
7019
7022
|
const quotaKey = getQuotaKey(family, model);
|
|
7020
|
-
const effectiveSoftQuotaThreshold = this.getEffectiveSoftQuotaThreshold(softQuotaThresholdPercent);
|
|
7023
|
+
const effectiveSoftQuotaThreshold = this.getEffectiveSoftQuotaThreshold(softQuotaThresholdPercent, excludeIndexes);
|
|
7021
7024
|
if (identity3) {
|
|
7022
7025
|
const pinned = this.getCurrentAccountForFamily(family, identity3);
|
|
7023
7026
|
if (pinned) {
|
|
@@ -7040,7 +7043,7 @@ var init_account_selector = __esm({
|
|
|
7040
7043
|
if (strategy === "hybrid") {
|
|
7041
7044
|
const healthTracker = this.healthTracker;
|
|
7042
7045
|
const tokenTracker = this.tokenTracker;
|
|
7043
|
-
const eligibleAccounts = this.preferAccountOutsideParent(this.accounts.filter((acc) => acc.enabled !== false && !excludeIndexes?.has(acc.index)), family, identity3);
|
|
7046
|
+
const eligibleAccounts = this.preferAccountOutsideParent(this.accounts.filter((acc) => acc.enabled !== false && acc.accountIneligible !== true && acc.verificationRequired !== true && !excludeIndexes?.has(acc.index)), family, identity3);
|
|
7044
7047
|
const accountsWithMetrics = eligibleAccounts.map((acc) => {
|
|
7045
7048
|
clearExpiredRateLimits(acc, this.now);
|
|
7046
7049
|
return {
|
|
@@ -7097,10 +7100,10 @@ var init_account_selector = __esm({
|
|
|
7097
7100
|
return next;
|
|
7098
7101
|
}
|
|
7099
7102
|
getNextForFamily(family, model, softQuotaThresholdPercent = 100, softQuotaCacheTtlMs = 10 * 60 * 1e3, identity3, excludeIndexes) {
|
|
7100
|
-
const effectiveSoftQuotaThreshold = this.getEffectiveSoftQuotaThreshold(softQuotaThresholdPercent);
|
|
7103
|
+
const effectiveSoftQuotaThreshold = this.getEffectiveSoftQuotaThreshold(softQuotaThresholdPercent, excludeIndexes);
|
|
7101
7104
|
const allAvailable = this.accounts.filter((account2) => {
|
|
7102
7105
|
clearExpiredRateLimits(account2, this.now);
|
|
7103
|
-
return account2.enabled !== false && !excludeIndexes?.has(account2.index) && !isRateLimitedForFamily(account2, family, this.now, model) && !isOverSoftQuotaThreshold(account2, family, effectiveSoftQuotaThreshold, softQuotaCacheTtlMs, this.now, model) && !this.isAccountCoolingDown(account2);
|
|
7106
|
+
return account2.enabled !== false && account2.accountIneligible !== true && account2.verificationRequired !== true && !excludeIndexes?.has(account2.index) && !isRateLimitedForFamily(account2, family, this.now, model) && !isOverSoftQuotaThreshold(account2, family, effectiveSoftQuotaThreshold, softQuotaCacheTtlMs, this.now, model) && !this.isAccountCoolingDown(account2);
|
|
7104
7107
|
});
|
|
7105
7108
|
const available = this.preferAccountOutsideParent(allAvailable, family, identity3);
|
|
7106
7109
|
if (available.length === 0) {
|
|
@@ -7181,6 +7184,9 @@ var init_account_selector = __esm({
|
|
|
7181
7184
|
const candidates = this.preferAccountOutsideParent(this.accounts.filter((acc) => {
|
|
7182
7185
|
if (acc.enabled === false)
|
|
7183
7186
|
return false;
|
|
7187
|
+
if (acc.accountIneligible === true || acc.verificationRequired === true) {
|
|
7188
|
+
return false;
|
|
7189
|
+
}
|
|
7184
7190
|
if (acc.index === currentIndex)
|
|
7185
7191
|
return false;
|
|
7186
7192
|
clearExpiredRateLimits(acc, this.now);
|
|
@@ -7286,7 +7292,7 @@ var init_account_selector = __esm({
|
|
|
7286
7292
|
getFreshAccountsForQuota(quotaKey, family, model) {
|
|
7287
7293
|
return this.accounts.filter((acc) => {
|
|
7288
7294
|
clearExpiredRateLimits(acc, this.now);
|
|
7289
|
-
return acc.enabled !== false && this.isFreshForQuota(acc, quotaKey) && !isRateLimitedForFamily(acc, family, this.now, model) && !this.isAccountCoolingDown(acc);
|
|
7295
|
+
return acc.enabled !== false && acc.accountIneligible !== true && acc.verificationRequired !== true && this.isFreshForQuota(acc, quotaKey) && !isRateLimitedForFamily(acc, family, this.now, model) && !this.isAccountCoolingDown(acc);
|
|
7290
7296
|
});
|
|
7291
7297
|
}
|
|
7292
7298
|
isRateLimited(account, family, model) {
|
|
@@ -7422,12 +7428,42 @@ var init_account_selector = __esm({
|
|
|
7422
7428
|
}
|
|
7423
7429
|
return true;
|
|
7424
7430
|
}
|
|
7425
|
-
|
|
7431
|
+
/**
|
|
7432
|
+
* Calculates the minimum wait time in milliseconds across eligible accounts
|
|
7433
|
+
* for a given model family (and optional model).
|
|
7434
|
+
*
|
|
7435
|
+
* Note: Returning `0` can mean either:
|
|
7436
|
+
* 1. No eligible candidates exist in the pool, OR
|
|
7437
|
+
* 2. At least one eligible candidate is hard/cooldown-ready without waiting
|
|
7438
|
+
* (this does not imply the candidate is fully selectable, as soft quota
|
|
7439
|
+
* or session-level policies may still apply).
|
|
7440
|
+
* Callers must distinguish "no eligible candidates" from "zero wait time"
|
|
7441
|
+
* by inspecting candidate pool availability / eligibility directly.
|
|
7442
|
+
*
|
|
7443
|
+
* @param family Model family (e.g., 'claude', 'gemini')
|
|
7444
|
+
* @param model Optional model name for per-model rate limits
|
|
7445
|
+
* @param eligibleIndexes Optional set of account indexes permitted for this request
|
|
7446
|
+
* @param includeCooldown Whether to factor in `coolingDownUntil` alongside quota rate limits
|
|
7447
|
+
* @returns Minimum wait duration in milliseconds, or 0 if hard/cooldown-ready or no candidates
|
|
7448
|
+
*/
|
|
7449
|
+
getMinWaitTimeForFamily(family, model, eligibleIndexes, includeCooldown = false) {
|
|
7426
7450
|
const now = this.now();
|
|
7427
|
-
const waits = this.accounts.filter((a) =>
|
|
7451
|
+
const waits = this.accounts.filter((a) => {
|
|
7452
|
+
if (a.enabled === false)
|
|
7453
|
+
return false;
|
|
7454
|
+
if (a.accountIneligible === true || a.verificationRequired === true) {
|
|
7455
|
+
return false;
|
|
7456
|
+
}
|
|
7457
|
+
if (eligibleIndexes !== void 0 && eligibleIndexes !== null) {
|
|
7458
|
+
if (!eligibleIndexes.has(a.index))
|
|
7459
|
+
return false;
|
|
7460
|
+
}
|
|
7461
|
+
return true;
|
|
7462
|
+
}).map((a) => {
|
|
7428
7463
|
clearExpiredRateLimits(a, this.now);
|
|
7429
7464
|
const modelReset = model ? a.rateLimitResetTimes[getQuotaKey(family, model)] : void 0;
|
|
7430
|
-
|
|
7465
|
+
const cooldownWait = includeCooldown && a.coolingDownUntil !== void 0 && a.coolingDownUntil > now ? a.coolingDownUntil - now : 0;
|
|
7466
|
+
return Math.max(0, (a.rateLimitResetTimes[family] ?? now) - now, (modelReset ?? now) - now, cooldownWait);
|
|
7431
7467
|
});
|
|
7432
7468
|
return waits.length > 0 ? Math.min(...waits) : 0;
|
|
7433
7469
|
}
|
|
@@ -7606,8 +7642,51 @@ var init_account_selector = __esm({
|
|
|
7606
7642
|
perAccount: perAccount.sort((a, b) => b.claude + b.gemini - (a.claude + a.gemini))
|
|
7607
7643
|
};
|
|
7608
7644
|
}
|
|
7609
|
-
isAccountOverSoftQuota(account, family, thresholdPercent, cacheTtlMs, model) {
|
|
7610
|
-
return isOverSoftQuotaThreshold(account, family, this.getEffectiveSoftQuotaThreshold(thresholdPercent), cacheTtlMs, this.now, model);
|
|
7645
|
+
isAccountOverSoftQuota(account, family, thresholdPercent, cacheTtlMs, model, excludeIndexes) {
|
|
7646
|
+
return isOverSoftQuotaThreshold(account, family, this.getEffectiveSoftQuotaThreshold(thresholdPercent, excludeIndexes), cacheTtlMs, this.now, model);
|
|
7647
|
+
}
|
|
7648
|
+
/**
|
|
7649
|
+
* Calculates the minimum wait duration across eligible accounts until at least
|
|
7650
|
+
* one candidate becomes selectable.
|
|
7651
|
+
*
|
|
7652
|
+
* For each eligible account:
|
|
7653
|
+
* accountWait = max(hardCooldownWait, applicableSoftResetDelay)
|
|
7654
|
+
* where hardCooldownWait uses getMinWaitTimeForFamily(..., includeCooldown=true).
|
|
7655
|
+
* Soft quota is applicable if and only if eligible.length > 1 and thresholdPercent < 100.
|
|
7656
|
+
* Unknown soft reset renders that account an unknown candidate.
|
|
7657
|
+
* Returns minimum known accountWait, or null if no eligible candidates or all unknown.
|
|
7658
|
+
*/
|
|
7659
|
+
getMinSelectableWaitTimeForFamily(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
7660
|
+
const eligible = this.accounts.filter((a) => a.enabled !== false && a.accountIneligible !== true && a.verificationRequired !== true && (eligibleIndexes == null || eligibleIndexes.has(a.index)));
|
|
7661
|
+
if (eligible.length === 0)
|
|
7662
|
+
return null;
|
|
7663
|
+
const now = this.now();
|
|
7664
|
+
const applySoftQuota = eligible.length > 1 && thresholdPercent < 100;
|
|
7665
|
+
const knownWaits = [];
|
|
7666
|
+
for (const acc of eligible) {
|
|
7667
|
+
const hardCooldownWait = this.getMinWaitTimeForFamily(family, model, /* @__PURE__ */ new Set([acc.index]), true);
|
|
7668
|
+
if (applySoftQuota && isOverSoftQuotaThreshold(acc, family, thresholdPercent, cacheTtlMs, this.now, model)) {
|
|
7669
|
+
if (!model && family !== "claude") {
|
|
7670
|
+
continue;
|
|
7671
|
+
}
|
|
7672
|
+
const quotaGroup = resolveQuotaGroup(family, model, acc.cachedQuota);
|
|
7673
|
+
const groupData = acc.cachedQuota?.[quotaGroup];
|
|
7674
|
+
if (!groupData?.resetTime) {
|
|
7675
|
+
continue;
|
|
7676
|
+
}
|
|
7677
|
+
const resetTimestamp = Date.parse(groupData.resetTime);
|
|
7678
|
+
if (!Number.isFinite(resetTimestamp) || resetTimestamp <= now) {
|
|
7679
|
+
continue;
|
|
7680
|
+
}
|
|
7681
|
+
const softResetDelay = resetTimestamp - now;
|
|
7682
|
+
knownWaits.push(Math.max(hardCooldownWait, softResetDelay));
|
|
7683
|
+
} else {
|
|
7684
|
+
knownWaits.push(hardCooldownWait);
|
|
7685
|
+
}
|
|
7686
|
+
}
|
|
7687
|
+
if (knownWaits.length === 0)
|
|
7688
|
+
return null;
|
|
7689
|
+
return Math.min(...knownWaits);
|
|
7611
7690
|
}
|
|
7612
7691
|
getOldestQuotaCacheAge() {
|
|
7613
7692
|
let oldest = null;
|
|
@@ -7622,36 +7701,42 @@ var init_account_selector = __esm({
|
|
|
7622
7701
|
}
|
|
7623
7702
|
return oldest;
|
|
7624
7703
|
}
|
|
7625
|
-
|
|
7704
|
+
/**
|
|
7705
|
+
* Check whether all eligible accounts (more than 1) are currently over the soft-quota threshold.
|
|
7706
|
+
* Returns false if thresholdPercent >= 100 or if <= 1 eligible account remains.
|
|
7707
|
+
*/
|
|
7708
|
+
areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
7626
7709
|
if (thresholdPercent >= 100)
|
|
7627
7710
|
return false;
|
|
7628
|
-
const
|
|
7629
|
-
if (
|
|
7711
|
+
const eligible = this.accounts.filter((a) => a.enabled !== false && a.accountIneligible !== true && a.verificationRequired !== true && (eligibleIndexes == null || eligibleIndexes.has(a.index)));
|
|
7712
|
+
if (eligible.length <= 1)
|
|
7630
7713
|
return false;
|
|
7631
|
-
return
|
|
7714
|
+
return eligible.every((a) => isOverSoftQuotaThreshold(a, family, thresholdPercent, cacheTtlMs, this.now, model));
|
|
7632
7715
|
}
|
|
7633
7716
|
/**
|
|
7634
|
-
* Get minimum wait time until any account's soft quota resets.
|
|
7635
|
-
*
|
|
7636
|
-
*
|
|
7637
|
-
* Returns null if no resetTime data is available.
|
|
7717
|
+
* Get minimum wait time until any eligible account's soft quota resets.
|
|
7718
|
+
* Operates over the eligible subset (enabled, non-ineligible, non-verification-required,
|
|
7719
|
+
* and present in `eligibleIndexes` when provided).
|
|
7720
|
+
* Returns null if no eligible accounts remain or no resetTime data is available.
|
|
7721
|
+
* Returns 0 if only 1 eligible account exists or any eligible account is below threshold.
|
|
7722
|
+
* Returns the minimum resetTime across all over-threshold eligible accounts.
|
|
7638
7723
|
*/
|
|
7639
|
-
getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model) {
|
|
7724
|
+
getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
7640
7725
|
if (thresholdPercent >= 100)
|
|
7641
7726
|
return 0;
|
|
7642
|
-
const
|
|
7643
|
-
if (
|
|
7727
|
+
const eligible = this.accounts.filter((a) => a.enabled !== false && a.accountIneligible !== true && a.verificationRequired !== true && (eligibleIndexes == null || eligibleIndexes.has(a.index)));
|
|
7728
|
+
if (eligible.length === 0)
|
|
7644
7729
|
return null;
|
|
7645
|
-
if (
|
|
7730
|
+
if (eligible.length === 1)
|
|
7646
7731
|
return 0;
|
|
7647
|
-
const available =
|
|
7732
|
+
const available = eligible.filter((a) => !isOverSoftQuotaThreshold(a, family, thresholdPercent, cacheTtlMs, this.now, model));
|
|
7648
7733
|
if (available.length > 0)
|
|
7649
7734
|
return 0;
|
|
7650
7735
|
if (!model && family !== "claude")
|
|
7651
7736
|
return null;
|
|
7652
7737
|
const now = this.now();
|
|
7653
7738
|
const waitTimes = [];
|
|
7654
|
-
for (const acc of
|
|
7739
|
+
for (const acc of eligible) {
|
|
7655
7740
|
const quotaGroup = resolveQuotaGroup(family, model, acc.cachedQuota);
|
|
7656
7741
|
const groupData = acc.cachedQuota?.[quotaGroup];
|
|
7657
7742
|
if (groupData?.resetTime) {
|
|
@@ -9656,8 +9741,24 @@ var init_account_manager = __esm({
|
|
|
9656
9741
|
expires: account.expires
|
|
9657
9742
|
};
|
|
9658
9743
|
}
|
|
9659
|
-
|
|
9660
|
-
|
|
9744
|
+
/**
|
|
9745
|
+
* Calculates the minimum wait time in milliseconds across eligible accounts
|
|
9746
|
+
* for a given model family (and optional model).
|
|
9747
|
+
*
|
|
9748
|
+
* Note: Returning `0` can mean either:
|
|
9749
|
+
* 1. No eligible candidates exist in the pool, OR
|
|
9750
|
+
* 2. At least one eligible candidate is immediately usable without waiting.
|
|
9751
|
+
* Callers must distinguish "no eligible candidates" from "zero wait time"
|
|
9752
|
+
* by inspecting candidate pool availability / eligibility directly.
|
|
9753
|
+
*
|
|
9754
|
+
* @param family Model family (e.g., 'claude', 'gemini')
|
|
9755
|
+
* @param model Optional model name for per-model rate limits
|
|
9756
|
+
* @param eligibleIndexes Optional set of account indexes permitted for this request
|
|
9757
|
+
* @param includeCooldown Whether to factor in `coolingDownUntil` alongside quota rate limits
|
|
9758
|
+
* @returns Minimum wait duration in milliseconds, or 0 if immediately usable or no candidates
|
|
9759
|
+
*/
|
|
9760
|
+
getMinWaitTimeForFamily(family, model, eligibleIndexes, includeCooldown = false) {
|
|
9761
|
+
return this.selection.getMinWaitTimeForFamily(family, model, eligibleIndexes, includeCooldown);
|
|
9661
9762
|
}
|
|
9662
9763
|
getAccounts() {
|
|
9663
9764
|
return this.selection.getAccounts();
|
|
@@ -9967,8 +10068,8 @@ var init_account_manager = __esm({
|
|
|
9967
10068
|
getSessionSummary() {
|
|
9968
10069
|
return this.selection.getSessionSummary();
|
|
9969
10070
|
}
|
|
9970
|
-
isAccountOverSoftQuota(account, family, thresholdPercent, cacheTtlMs, model) {
|
|
9971
|
-
return this.selection.isAccountOverSoftQuota(account, family, thresholdPercent, cacheTtlMs, model);
|
|
10071
|
+
isAccountOverSoftQuota(account, family, thresholdPercent, cacheTtlMs, model, excludeIndexes) {
|
|
10072
|
+
return this.selection.isAccountOverSoftQuota(account, family, thresholdPercent, cacheTtlMs, model, excludeIndexes);
|
|
9972
10073
|
}
|
|
9973
10074
|
/**
|
|
9974
10075
|
* The accounts a quota check should cover. For a repository-backed
|
|
@@ -10000,17 +10101,26 @@ var init_account_manager = __esm({
|
|
|
10000
10101
|
getOldestQuotaCacheAge() {
|
|
10001
10102
|
return this.selection.getOldestQuotaCacheAge();
|
|
10002
10103
|
}
|
|
10003
|
-
|
|
10004
|
-
|
|
10104
|
+
/**
|
|
10105
|
+
* Check whether all eligible accounts (more than 1) are currently over the soft-quota threshold.
|
|
10106
|
+
* Returns false if thresholdPercent >= 100 or if <= 1 eligible account remains.
|
|
10107
|
+
*/
|
|
10108
|
+
areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
10109
|
+
return this.selection.areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes);
|
|
10005
10110
|
}
|
|
10006
10111
|
/**
|
|
10007
|
-
* Get minimum wait time until any account's soft quota resets.
|
|
10008
|
-
*
|
|
10009
|
-
*
|
|
10010
|
-
* Returns null if no resetTime data is available.
|
|
10112
|
+
* Get minimum wait time until any eligible account's soft quota resets.
|
|
10113
|
+
* Operates over the eligible subset (enabled, non-ineligible, non-verification-required,
|
|
10114
|
+
* and present in `eligibleIndexes` when provided).
|
|
10115
|
+
* Returns null if no eligible accounts remain or no resetTime data is available.
|
|
10116
|
+
* Returns 0 if only 1 eligible account exists or any eligible account is below threshold.
|
|
10117
|
+
* Returns the minimum resetTime across all over-threshold eligible accounts.
|
|
10011
10118
|
*/
|
|
10012
|
-
getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model) {
|
|
10013
|
-
return this.selection.getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model);
|
|
10119
|
+
getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
10120
|
+
return this.selection.getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes);
|
|
10121
|
+
}
|
|
10122
|
+
getMinSelectableWaitTimeForFamily(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
10123
|
+
return this.selection.getMinSelectableWaitTimeForFamily(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes);
|
|
10014
10124
|
}
|
|
10015
10125
|
};
|
|
10016
10126
|
}
|
|
@@ -45206,8 +45316,8 @@ function createRequestExecutor(deps) {
|
|
|
45206
45316
|
accountManager.getAccounts().map((entry) => entry.index).filter((index) => !eligibleIndexes.has(index))
|
|
45207
45317
|
);
|
|
45208
45318
|
if (modelUnavailableIndexes.size > 0) {
|
|
45209
|
-
const candidates = accountManager.
|
|
45210
|
-
(entry) => eligibleIndexes === null || eligibleIndexes.has(entry.index)
|
|
45319
|
+
const candidates = accountManager.getAccounts().filter(
|
|
45320
|
+
(entry) => entry.enabled !== false && !entry.accountIneligible && !entry.verificationRequired && (eligibleIndexes === null || eligibleIndexes.has(entry.index))
|
|
45211
45321
|
);
|
|
45212
45322
|
if (candidates.length > 0 && candidates.every((entry) => modelUnavailableIndexes.has(entry.index))) {
|
|
45213
45323
|
pushDebug(
|
|
@@ -45243,13 +45353,14 @@ function createRequestExecutor(deps) {
|
|
|
45243
45353
|
if (account) {
|
|
45244
45354
|
routingPlacementConsidered = true;
|
|
45245
45355
|
if (firstPlacement && credentials.domain === "vault" && credentials.routingCandidate && model && isPrimaryVaultRequest(kind, init?.headers)) {
|
|
45246
|
-
const candidates = accountManager.
|
|
45247
|
-
(row) => !excludedIndexes?.has(row.index) && !accountManager.isRateLimited(row, family, model) && !accountManager.isAccountCoolingDown(row) && !accountManager.isAccountOverSoftQuota(
|
|
45356
|
+
const candidates = accountManager.getAccounts().filter(
|
|
45357
|
+
(row) => row.enabled !== false && !row.accountIneligible && !row.verificationRequired && !excludedIndexes?.has(row.index) && !accountManager.isRateLimited(row, family, model) && !accountManager.isAccountCoolingDown(row) && !accountManager.isAccountOverSoftQuota(
|
|
45248
45358
|
row,
|
|
45249
45359
|
family,
|
|
45250
45360
|
config.soft_quota_threshold_percent,
|
|
45251
45361
|
softQuotaCacheTtlMs,
|
|
45252
|
-
model
|
|
45362
|
+
model,
|
|
45363
|
+
excludedIndexes
|
|
45253
45364
|
)
|
|
45254
45365
|
).map((row) => ({
|
|
45255
45366
|
...credentials.routingCandidate(row),
|
|
@@ -45295,26 +45406,68 @@ function createRequestExecutor(deps) {
|
|
|
45295
45406
|
const blockedSince = allAccountsBlockedAt;
|
|
45296
45407
|
const remainingWaitMs = () => maxWaitMs > 0 ? Math.max(0, maxWaitMs - (Date.now() - blockedSince)) : Number.POSITIVE_INFINITY;
|
|
45297
45408
|
const quotaWins = remainingWaitMs() <= deadline.remainingMs();
|
|
45298
|
-
|
|
45409
|
+
const eligibleCandidates = accountManager.getAccounts().filter(
|
|
45410
|
+
(entry) => entry.enabled !== false && !entry.accountIneligible && !entry.verificationRequired && !excludedIndexes?.has(entry.index)
|
|
45411
|
+
);
|
|
45412
|
+
const eligibleCandidateIndexes = new Set(
|
|
45413
|
+
eligibleCandidates.map((entry) => entry.index)
|
|
45414
|
+
);
|
|
45415
|
+
if (eligibleCandidateIndexes.size === 0) {
|
|
45416
|
+
waitPolicy.refusal = () => createNativeGoogleErrorResponse({
|
|
45417
|
+
status: 412,
|
|
45418
|
+
reason: "pool_unavailable"
|
|
45419
|
+
});
|
|
45420
|
+
return waitPolicy.refusal();
|
|
45421
|
+
}
|
|
45422
|
+
const threshold = config.soft_quota_threshold_percent;
|
|
45423
|
+
const combinedDelayMs = accountManager.getMinSelectableWaitTimeForFamily(
|
|
45299
45424
|
family,
|
|
45300
|
-
|
|
45425
|
+
threshold,
|
|
45301
45426
|
softQuotaCacheTtlMs,
|
|
45302
|
-
model
|
|
45303
|
-
|
|
45304
|
-
|
|
45305
|
-
|
|
45427
|
+
model,
|
|
45428
|
+
eligibleCandidateIndexes
|
|
45429
|
+
);
|
|
45430
|
+
const waitMs = combinedDelayMs !== null && combinedDelayMs > 0 ? combinedDelayMs : 6e4;
|
|
45431
|
+
const allOverSoftQuota = accountManager.areAllAccountsOverSoftQuota(
|
|
45432
|
+
family,
|
|
45433
|
+
threshold,
|
|
45434
|
+
softQuotaCacheTtlMs,
|
|
45435
|
+
model,
|
|
45436
|
+
eligibleCandidateIndexes
|
|
45437
|
+
);
|
|
45438
|
+
const hasActiveCooldown = eligibleCandidates.some(
|
|
45439
|
+
(acc) => accountManager.isAccountCoolingDown(acc)
|
|
45440
|
+
);
|
|
45441
|
+
const applySoftQuota = eligibleCandidates.length > 1 && threshold < 100;
|
|
45442
|
+
const hasUnknownSoftReset = applySoftQuota && eligibleCandidates.some((acc) => {
|
|
45443
|
+
if (!accountManager.isAccountOverSoftQuota(
|
|
45444
|
+
acc,
|
|
45306
45445
|
family,
|
|
45307
45446
|
threshold,
|
|
45308
45447
|
softQuotaCacheTtlMs,
|
|
45309
|
-
model
|
|
45310
|
-
|
|
45448
|
+
model,
|
|
45449
|
+
excludedIndexes
|
|
45450
|
+
)) {
|
|
45451
|
+
return false;
|
|
45452
|
+
}
|
|
45453
|
+
if (!model && family !== "claude") return true;
|
|
45454
|
+
const quotaGroup = resolveQuotaGroup(family, model, acc.cachedQuota);
|
|
45455
|
+
const groupData = acc.cachedQuota?.[quotaGroup];
|
|
45456
|
+
if (!groupData?.resetTime) return true;
|
|
45457
|
+
const ts = Date.parse(groupData.resetTime);
|
|
45458
|
+
return !Number.isFinite(ts) || ts <= Date.now();
|
|
45459
|
+
});
|
|
45460
|
+
const resetDeadline = !hasActiveCooldown && !hasUnknownSoftReset && combinedDelayMs !== null && combinedDelayMs > 0 ? Date.now() + combinedDelayMs : void 0;
|
|
45461
|
+
const remainingResetAfterMs = () => resetDeadline ? Math.max(0, resetDeadline - Date.now()) : void 0;
|
|
45462
|
+
if (allOverSoftQuota) {
|
|
45311
45463
|
waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
|
|
45312
45464
|
status: 412,
|
|
45313
45465
|
reason: "soft_quota",
|
|
45314
|
-
resetAfterMs:
|
|
45466
|
+
resetAfterMs: remainingResetAfterMs()
|
|
45315
45467
|
}) : void 0;
|
|
45316
|
-
if (
|
|
45317
|
-
const
|
|
45468
|
+
if (combinedDelayMs === null || remainingWaitMs() <= 0 || maxWaitMs > 0 && waitMs > maxWaitMs) {
|
|
45469
|
+
const resetAfterMs = remainingResetAfterMs();
|
|
45470
|
+
const waitTimeFormatted = resetAfterMs !== void 0 && resetAfterMs > 0 ? formatWaitTime(resetAfterMs) : "unknown";
|
|
45318
45471
|
await showToast(
|
|
45319
45472
|
`All accounts over ${threshold}% quota threshold. Resets in ${waitTimeFormatted}.`,
|
|
45320
45473
|
"error"
|
|
@@ -45322,28 +45475,26 @@ function createRequestExecutor(deps) {
|
|
|
45322
45475
|
return createNativeGoogleErrorResponse({
|
|
45323
45476
|
status: 412,
|
|
45324
45477
|
reason: "soft_quota",
|
|
45325
|
-
resetAfterMs:
|
|
45478
|
+
resetAfterMs: remainingResetAfterMs()
|
|
45326
45479
|
});
|
|
45327
45480
|
}
|
|
45328
45481
|
pushDebug(
|
|
45329
|
-
`all-over-soft-quota family=${family} accounts=${accountCount} waitMs=${
|
|
45482
|
+
`all-over-soft-quota family=${family} accounts=${accountCount} waitMs=${waitMs}`
|
|
45330
45483
|
);
|
|
45331
45484
|
if (!retryState.softQuotaToastShown()) {
|
|
45332
45485
|
await showToast(
|
|
45333
|
-
`All ${accountCount} account(s) over ${threshold}% quota. Waiting ${formatWaitTime(
|
|
45486
|
+
`All ${accountCount} account(s) over ${threshold}% quota. Waiting ${formatWaitTime(waitMs)}...`,
|
|
45334
45487
|
"warning"
|
|
45335
45488
|
);
|
|
45336
45489
|
retryState.markSoftQuotaToastShown();
|
|
45337
45490
|
}
|
|
45338
|
-
await sleep4(Math.min(
|
|
45491
|
+
await sleep4(Math.min(waitMs, remainingWaitMs()), abortSignal);
|
|
45339
45492
|
continue;
|
|
45340
45493
|
}
|
|
45341
|
-
const minWaitMs = accountManager.getMinWaitTimeForFamily(family, model);
|
|
45342
|
-
const waitMs = minWaitMs || 6e4;
|
|
45343
45494
|
waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
|
|
45344
45495
|
status: 412,
|
|
45345
45496
|
reason: "pool_unavailable",
|
|
45346
|
-
resetAfterMs:
|
|
45497
|
+
resetAfterMs: remainingResetAfterMs()
|
|
45347
45498
|
}) : void 0;
|
|
45348
45499
|
pushDebug(
|
|
45349
45500
|
`all-rate-limited family=${family} accounts=${accountCount} waitMs=${waitMs}`
|
|
@@ -45368,9 +45519,8 @@ function createRequestExecutor(deps) {
|
|
|
45368
45519
|
return createNativeGoogleErrorResponse({
|
|
45369
45520
|
status: 412,
|
|
45370
45521
|
reason: "pool_unavailable",
|
|
45371
|
-
//
|
|
45372
|
-
|
|
45373
|
-
resetAfterMs: minWaitMs > 0 ? minWaitMs : void 0
|
|
45522
|
+
// Fallback sleep duration gets NO reset metadata.
|
|
45523
|
+
resetAfterMs: remainingResetAfterMs()
|
|
45374
45524
|
});
|
|
45375
45525
|
}
|
|
45376
45526
|
if (!retryState.rateLimitToastShown()) {
|
|
@@ -48794,6 +48944,7 @@ function createGaLocationServicesFactory(bindings) {
|
|
|
48794
48944
|
let started = false;
|
|
48795
48945
|
let disposal;
|
|
48796
48946
|
let repositoryPromise;
|
|
48947
|
+
let repositoryPromiseLogin = false;
|
|
48797
48948
|
let servingRepository;
|
|
48798
48949
|
let localPromise;
|
|
48799
48950
|
let vaultPromise;
|
|
@@ -48845,15 +48996,22 @@ function createGaLocationServicesFactory(bindings) {
|
|
|
48845
48996
|
};
|
|
48846
48997
|
const getRepository = async (login) => {
|
|
48847
48998
|
await assertLocal();
|
|
48848
|
-
repositoryPromise
|
|
48849
|
-
|
|
48850
|
-
|
|
48851
|
-
|
|
48852
|
-
login
|
|
48853
|
-
|
|
48854
|
-
|
|
48855
|
-
|
|
48856
|
-
|
|
48999
|
+
if (login && repositoryPromise && !repositoryPromiseLogin) {
|
|
49000
|
+
await repositoryPromise.catch(() => void 0);
|
|
49001
|
+
}
|
|
49002
|
+
if (!repositoryPromise) {
|
|
49003
|
+
repositoryPromiseLogin = Boolean(login);
|
|
49004
|
+
repositoryPromise = openLocationRepository(
|
|
49005
|
+
directory,
|
|
49006
|
+
bindings,
|
|
49007
|
+
overrides,
|
|
49008
|
+
login
|
|
49009
|
+
).catch((error) => {
|
|
49010
|
+
repositoryPromise = void 0;
|
|
49011
|
+
repositoryPromiseLogin = false;
|
|
49012
|
+
throw error;
|
|
49013
|
+
});
|
|
49014
|
+
}
|
|
48857
49015
|
const repository = (await repositoryPromise).repository;
|
|
48858
49016
|
if (!servingRepository) {
|
|
48859
49017
|
const methods = /* @__PURE__ */ new Map();
|
|
@@ -48930,6 +49088,30 @@ function createGaLocationServicesFactory(bindings) {
|
|
|
48930
49088
|
runtime,
|
|
48931
49089
|
localLogin: {
|
|
48932
49090
|
assertAdmission: assertLocal,
|
|
49091
|
+
async assertExistingPool(admit2) {
|
|
49092
|
+
await assertLocal();
|
|
49093
|
+
await admit2();
|
|
49094
|
+
const repository = await getRepository();
|
|
49095
|
+
await admit2();
|
|
49096
|
+
const opened = await repositoryPromise;
|
|
49097
|
+
await admit2();
|
|
49098
|
+
if (!opened)
|
|
49099
|
+
throw new Error("The local repository was not constructed");
|
|
49100
|
+
await assertServingAdmission(opened, bindings.now);
|
|
49101
|
+
await admit2();
|
|
49102
|
+
const read = await repository.read();
|
|
49103
|
+
await admit2();
|
|
49104
|
+
if (read.status !== "ready" || !read.rows.some(
|
|
49105
|
+
(row) => row.enabled && row.usable && row.credential !== void 0 && !row.torn && !row.unbound && row.invalid === void 0 && row.metadata.status === "present" && accessBlockOf2(row).kind === "none"
|
|
49106
|
+
))
|
|
49107
|
+
throw new Error(
|
|
49108
|
+
"The existing local Antigravity pool is unavailable"
|
|
49109
|
+
);
|
|
49110
|
+
await assertServingAdmission(opened, bindings.now);
|
|
49111
|
+
await admit2();
|
|
49112
|
+
await assertLocal();
|
|
49113
|
+
await admit2();
|
|
49114
|
+
},
|
|
48933
49115
|
async persist(result, admit2) {
|
|
48934
49116
|
await assertLocal();
|
|
48935
49117
|
await admit2();
|
|
@@ -50710,6 +50892,7 @@ init_dist();
|
|
|
50710
50892
|
// src/auth-method-labels.ts
|
|
50711
50893
|
var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
|
|
50712
50894
|
var OPENCODE2_VAULT_AUTH_LABEL = "Use approved Antigravity vault";
|
|
50895
|
+
var OPENCODE2_POOL_RECONNECT_LABEL = "Use existing local Antigravity pool";
|
|
50713
50896
|
|
|
50714
50897
|
// src/ga/server/auth.ts
|
|
50715
50898
|
init_storage();
|
|
@@ -50719,6 +50902,7 @@ init_vault_folder();
|
|
|
50719
50902
|
// src/ga/server/pool-login.ts
|
|
50720
50903
|
init_dist();
|
|
50721
50904
|
var GA_POOL_METHOD_ID = "antigravity-auth-pool-browser";
|
|
50905
|
+
var GA_POOL_RECONNECT_METHOD_ID = "antigravity-auth-pool-reconnect";
|
|
50722
50906
|
var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
|
|
50723
50907
|
function abortable(pending, signal) {
|
|
50724
50908
|
return new Promise((resolve28, reject) => {
|
|
@@ -50842,6 +51026,26 @@ function createGaPoolLogin(input2) {
|
|
|
50842
51026
|
};
|
|
50843
51027
|
return {
|
|
50844
51028
|
method,
|
|
51029
|
+
connectExisting: () => track(
|
|
51030
|
+
(async () => {
|
|
51031
|
+
try {
|
|
51032
|
+
await admit2();
|
|
51033
|
+
if (!input2.local?.assertExistingPool) throw new Error(LOGIN_FAILED);
|
|
51034
|
+
await abortable(
|
|
51035
|
+
track(input2.local.assertExistingPool(admit2)),
|
|
51036
|
+
shutdown.signal
|
|
51037
|
+
);
|
|
51038
|
+
await admit2();
|
|
51039
|
+
return placeholderCredential({
|
|
51040
|
+
integrationID: ANTIGRAVITY_PROVIDER_ID,
|
|
51041
|
+
methodID: GA_POOL_RECONNECT_METHOD_ID,
|
|
51042
|
+
now: Date.now()
|
|
51043
|
+
});
|
|
51044
|
+
} catch {
|
|
51045
|
+
throw new Error(LOGIN_FAILED);
|
|
51046
|
+
}
|
|
51047
|
+
})()
|
|
51048
|
+
),
|
|
50845
51049
|
onLogin: (result) => track(
|
|
50846
51050
|
(async () => {
|
|
50847
51051
|
try {
|
|
@@ -50875,33 +51079,83 @@ async function readAuthority() {
|
|
|
50875
51079
|
}
|
|
50876
51080
|
async function registerGaAuthMethods(context, authority = readAuthority, input2 = {}) {
|
|
50877
51081
|
const pool = createGaPoolLogin(input2);
|
|
50878
|
-
const
|
|
50879
|
-
|
|
50880
|
-
|
|
50881
|
-
|
|
50882
|
-
|
|
50883
|
-
|
|
50884
|
-
|
|
50885
|
-
|
|
50886
|
-
|
|
50887
|
-
|
|
50888
|
-
|
|
50889
|
-
|
|
50890
|
-
|
|
50891
|
-
|
|
50892
|
-
|
|
50893
|
-
|
|
50894
|
-
|
|
50895
|
-
|
|
50896
|
-
|
|
50897
|
-
|
|
51082
|
+
const registrations = [];
|
|
51083
|
+
try {
|
|
51084
|
+
registrations.push(
|
|
51085
|
+
await registerOpenCode2AuthMethods(context, {
|
|
51086
|
+
integrationID: ANTIGRAVITY_PROVIDER_ID,
|
|
51087
|
+
methods: [pool.method],
|
|
51088
|
+
onLogin: pool.onLogin,
|
|
51089
|
+
vault: {
|
|
51090
|
+
method: {
|
|
51091
|
+
id: GA_VAULT_METHOD_ID,
|
|
51092
|
+
type: "oauth",
|
|
51093
|
+
label: OPENCODE2_VAULT_AUTH_LABEL
|
|
51094
|
+
},
|
|
51095
|
+
async activate() {
|
|
51096
|
+
if (await authority() !== "vault") {
|
|
51097
|
+
throw new Error(
|
|
51098
|
+
"Approve Antigravity vault access before activating this connection"
|
|
51099
|
+
);
|
|
51100
|
+
}
|
|
51101
|
+
}
|
|
51102
|
+
},
|
|
51103
|
+
label: "Antigravity"
|
|
51104
|
+
})
|
|
51105
|
+
);
|
|
51106
|
+
if (input2.local?.assertExistingPool) {
|
|
51107
|
+
registrations.push(
|
|
51108
|
+
await context.integration.transform((editor) => {
|
|
51109
|
+
editor.method.update({
|
|
51110
|
+
integrationID: ANTIGRAVITY_PROVIDER_ID,
|
|
51111
|
+
method: {
|
|
51112
|
+
id: GA_POOL_RECONNECT_METHOD_ID,
|
|
51113
|
+
type: "oauth",
|
|
51114
|
+
label: OPENCODE2_POOL_RECONNECT_LABEL
|
|
51115
|
+
},
|
|
51116
|
+
authorize: async () => {
|
|
51117
|
+
const callback = pool.connectExisting();
|
|
51118
|
+
void callback.catch(() => {
|
|
51119
|
+
});
|
|
51120
|
+
return {
|
|
51121
|
+
mode: "auto",
|
|
51122
|
+
url: "",
|
|
51123
|
+
instructions: "No browser sign-in needed: connect the existing local Antigravity pool without changing its accounts.",
|
|
51124
|
+
callback
|
|
51125
|
+
};
|
|
51126
|
+
},
|
|
51127
|
+
refresh: async (credential) => {
|
|
51128
|
+
if (!isPlaceholderCredential(credential, ANTIGRAVITY_PROVIDER_ID) || credential.methodID !== GA_POOL_RECONNECT_METHOD_ID) {
|
|
51129
|
+
throw new Error(
|
|
51130
|
+
"This login method refreshes only its existing local pool placeholder."
|
|
51131
|
+
);
|
|
51132
|
+
}
|
|
51133
|
+
return pool.connectExisting();
|
|
51134
|
+
},
|
|
51135
|
+
label: () => "Antigravity"
|
|
51136
|
+
});
|
|
51137
|
+
})
|
|
51138
|
+
);
|
|
51139
|
+
}
|
|
51140
|
+
} catch (error) {
|
|
51141
|
+
const stopping = pool.dispose();
|
|
51142
|
+
await Promise.allSettled(
|
|
51143
|
+
registrations.map((registration) => registration.dispose())
|
|
51144
|
+
);
|
|
51145
|
+
await stopping;
|
|
51146
|
+
throw error;
|
|
51147
|
+
}
|
|
50898
51148
|
let disposal;
|
|
50899
51149
|
return {
|
|
50900
51150
|
dispose() {
|
|
50901
51151
|
disposal ??= (async () => {
|
|
50902
51152
|
const stopping = pool.dispose();
|
|
50903
51153
|
try {
|
|
50904
|
-
await
|
|
51154
|
+
const results = await Promise.allSettled(
|
|
51155
|
+
registrations.map((registration) => registration.dispose())
|
|
51156
|
+
);
|
|
51157
|
+
const failure2 = results.find((result) => result.status === "rejected");
|
|
51158
|
+
if (failure2?.status === "rejected") throw failure2.reason;
|
|
50905
51159
|
} finally {
|
|
50906
51160
|
await stopping;
|
|
50907
51161
|
}
|
|
@@ -55279,6 +55533,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
55279
55533
|
}
|
|
55280
55534
|
};
|
|
55281
55535
|
let openCodeLogin;
|
|
55536
|
+
let hasLocalPool = false;
|
|
55282
55537
|
const manifest = JSON.parse(
|
|
55283
55538
|
await readFile16(new URL("../package.json", import.meta.url), "utf8")
|
|
55284
55539
|
);
|
|
@@ -55334,7 +55589,23 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
55334
55589
|
},
|
|
55335
55590
|
signInLocal: async (host, context) => {
|
|
55336
55591
|
await assertLocal(host, context);
|
|
55337
|
-
if (host === "opencode" && context.opencodeGeneration === "2")
|
|
55592
|
+
if (host === "opencode" && context.opencodeGeneration === "2") {
|
|
55593
|
+
if (!forceLogin) {
|
|
55594
|
+
try {
|
|
55595
|
+
const source2 = await deps.accountStore.read(
|
|
55596
|
+
deps.accountStore.legacyPath()
|
|
55597
|
+
);
|
|
55598
|
+
const candidateAccounts = source2.kind === "store" ? source2.accounts : source2.kind === "legacy" ? (await deps.loadAccounts())?.accounts ?? [] : [];
|
|
55599
|
+
if (candidateAccounts.some(
|
|
55600
|
+
(account) => account.enabled !== false && account.accountIneligible !== true && account.verificationRequired !== true && typeof account.refreshToken === "string" && account.refreshToken.length > 0
|
|
55601
|
+
)) {
|
|
55602
|
+
hasLocalPool = true;
|
|
55603
|
+
}
|
|
55604
|
+
} catch {
|
|
55605
|
+
}
|
|
55606
|
+
}
|
|
55607
|
+
return;
|
|
55608
|
+
}
|
|
55338
55609
|
const slot = (await nativeAuth(host, context))[provider(host)];
|
|
55339
55610
|
const source = host === "opencode" ? await deps.accountStore.read(deps.accountStore.legacyPath()) : void 0;
|
|
55340
55611
|
if (source?.kind === "unavailable") throw new Error(source.reason);
|
|
@@ -55346,6 +55617,11 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
55346
55617
|
`Using existing local Antigravity login for ${host}.
|
|
55347
55618
|
`
|
|
55348
55619
|
);
|
|
55620
|
+
if (host === "opencode" && accounts.some(
|
|
55621
|
+
(account) => account.enabled !== false && account.accountIneligible !== true && account.verificationRequired !== true && typeof account.refreshToken === "string" && account.refreshToken.length > 0
|
|
55622
|
+
)) {
|
|
55623
|
+
hasLocalPool = true;
|
|
55624
|
+
}
|
|
55349
55625
|
if (host === "opencode" && claustrum.classifyHostSlot(slot, provider(host)) !== "login") {
|
|
55350
55626
|
const account = accounts[0];
|
|
55351
55627
|
await writeNativeSlot(
|
|
@@ -55376,7 +55652,10 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
55376
55652
|
host,
|
|
55377
55653
|
context
|
|
55378
55654
|
);
|
|
55379
|
-
if (host === "opencode")
|
|
55655
|
+
if (host === "opencode") {
|
|
55656
|
+
openCodeLogin = result;
|
|
55657
|
+
hasLocalPool = true;
|
|
55658
|
+
}
|
|
55380
55659
|
},
|
|
55381
55660
|
beforeRegister: async (host, mode, context) => {
|
|
55382
55661
|
const needsOpenCode2 = host === "opencode" && context.opencodeGeneration !== "1";
|
|
@@ -55400,7 +55679,10 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
55400
55679
|
},
|
|
55401
55680
|
context
|
|
55402
55681
|
);
|
|
55403
|
-
if (needsOpenCode2)
|
|
55682
|
+
if (needsOpenCode2)
|
|
55683
|
+
nativeNextStep(
|
|
55684
|
+
hasLocalPool ? OPENCODE2_POOL_RECONNECT_LABEL : OPENCODE2_POOL_AUTH_LABEL
|
|
55685
|
+
);
|
|
55404
55686
|
return;
|
|
55405
55687
|
}
|
|
55406
55688
|
if (await authority(host) !== "vault")
|