@cortexkit/opencode-antigravity-auth 3.0.23 → 3.0.24
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 +148 -41
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +12 -12
- package/dist/server.js +281 -71
- 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 +3 -0
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +17 -3
- 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 +3 -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/index.meta.json
CHANGED
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
"format": "esm"
|
|
172
172
|
},
|
|
173
173
|
"../core/dist/account-selector.js": {
|
|
174
|
-
"bytes":
|
|
174
|
+
"bytes": 58735,
|
|
175
175
|
"imports": [
|
|
176
176
|
{
|
|
177
177
|
"path": "../core/dist/fingerprint.js",
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
"format": "esm"
|
|
286
286
|
},
|
|
287
287
|
"../core/dist/account-manager.js": {
|
|
288
|
-
"bytes":
|
|
288
|
+
"bytes": 68295,
|
|
289
289
|
"imports": [
|
|
290
290
|
{
|
|
291
291
|
"path": "node:crypto",
|
|
@@ -3624,7 +3624,7 @@
|
|
|
3624
3624
|
"format": "esm"
|
|
3625
3625
|
},
|
|
3626
3626
|
"src/auth-method-labels.ts": {
|
|
3627
|
-
"bytes":
|
|
3627
|
+
"bytes": 404,
|
|
3628
3628
|
"imports": [],
|
|
3629
3629
|
"format": "esm"
|
|
3630
3630
|
},
|
|
@@ -4193,7 +4193,7 @@
|
|
|
4193
4193
|
"format": "esm"
|
|
4194
4194
|
},
|
|
4195
4195
|
"src/setup.ts": {
|
|
4196
|
-
"bytes":
|
|
4196
|
+
"bytes": 20353,
|
|
4197
4197
|
"imports": [
|
|
4198
4198
|
{
|
|
4199
4199
|
"path": "node:fs/promises",
|
|
@@ -5952,7 +5952,7 @@
|
|
|
5952
5952
|
"format": "esm"
|
|
5953
5953
|
},
|
|
5954
5954
|
"src/plugin/shared/request-services.ts": {
|
|
5955
|
-
"bytes":
|
|
5955
|
+
"bytes": 122841,
|
|
5956
5956
|
"imports": [
|
|
5957
5957
|
{
|
|
5958
5958
|
"path": "../core/dist/index.js",
|
|
@@ -6487,7 +6487,7 @@
|
|
|
6487
6487
|
"imports": [],
|
|
6488
6488
|
"exports": [],
|
|
6489
6489
|
"inputs": {},
|
|
6490
|
-
"bytes":
|
|
6490
|
+
"bytes": 4728397
|
|
6491
6491
|
},
|
|
6492
6492
|
"dist/index.js": {
|
|
6493
6493
|
"imports": [
|
|
@@ -7694,7 +7694,7 @@
|
|
|
7694
7694
|
"bytesInOutput": 11075
|
|
7695
7695
|
},
|
|
7696
7696
|
"../core/dist/account-selector.js": {
|
|
7697
|
-
"bytesInOutput":
|
|
7697
|
+
"bytesInOutput": 50935
|
|
7698
7698
|
},
|
|
7699
7699
|
"../core/dist/atomic-write.js": {
|
|
7700
7700
|
"bytesInOutput": 905
|
|
@@ -7715,7 +7715,7 @@
|
|
|
7715
7715
|
"bytesInOutput": 1325
|
|
7716
7716
|
},
|
|
7717
7717
|
"../core/dist/account-manager.js": {
|
|
7718
|
-
"bytesInOutput":
|
|
7718
|
+
"bytesInOutput": 61547
|
|
7719
7719
|
},
|
|
7720
7720
|
"../core/dist/account-types.js": {
|
|
7721
7721
|
"bytesInOutput": 97
|
|
@@ -8138,10 +8138,10 @@
|
|
|
8138
8138
|
"bytesInOutput": 8443
|
|
8139
8139
|
},
|
|
8140
8140
|
"src/setup.ts": {
|
|
8141
|
-
"bytesInOutput":
|
|
8141
|
+
"bytesInOutput": 15311
|
|
8142
8142
|
},
|
|
8143
8143
|
"src/auth-method-labels.ts": {
|
|
8144
|
-
"bytesInOutput":
|
|
8144
|
+
"bytesInOutput": 218
|
|
8145
8145
|
},
|
|
8146
8146
|
"src/common-auth-embedded/auth-menu/ansi.js": {
|
|
8147
8147
|
"bytesInOutput": 2404
|
|
@@ -8426,7 +8426,7 @@
|
|
|
8426
8426
|
"bytesInOutput": 7610
|
|
8427
8427
|
},
|
|
8428
8428
|
"src/plugin/shared/request-services.ts": {
|
|
8429
|
-
"bytesInOutput":
|
|
8429
|
+
"bytesInOutput": 83260
|
|
8430
8430
|
},
|
|
8431
8431
|
"src/common-auth-embedded/routing-accessor/index.js": {
|
|
8432
8432
|
"bytesInOutput": 3335
|
|
@@ -8480,7 +8480,7 @@
|
|
|
8480
8480
|
"bytesInOutput": 0
|
|
8481
8481
|
}
|
|
8482
8482
|
},
|
|
8483
|
-
"bytes":
|
|
8483
|
+
"bytes": 2139634
|
|
8484
8484
|
}
|
|
8485
8485
|
}
|
|
8486
8486
|
}
|
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) {
|
|
@@ -7286,7 +7289,7 @@ var init_account_selector = __esm({
|
|
|
7286
7289
|
getFreshAccountsForQuota(quotaKey, family, model) {
|
|
7287
7290
|
return this.accounts.filter((acc) => {
|
|
7288
7291
|
clearExpiredRateLimits(acc, this.now);
|
|
7289
|
-
return acc.enabled !== false && this.isFreshForQuota(acc, quotaKey) && !isRateLimitedForFamily(acc, family, this.now, model) && !this.isAccountCoolingDown(acc);
|
|
7292
|
+
return acc.enabled !== false && acc.accountIneligible !== true && acc.verificationRequired !== true && this.isFreshForQuota(acc, quotaKey) && !isRateLimitedForFamily(acc, family, this.now, model) && !this.isAccountCoolingDown(acc);
|
|
7290
7293
|
});
|
|
7291
7294
|
}
|
|
7292
7295
|
isRateLimited(account, family, model) {
|
|
@@ -7422,12 +7425,40 @@ var init_account_selector = __esm({
|
|
|
7422
7425
|
}
|
|
7423
7426
|
return true;
|
|
7424
7427
|
}
|
|
7425
|
-
|
|
7428
|
+
/**
|
|
7429
|
+
* Calculates the minimum wait time in milliseconds across eligible accounts
|
|
7430
|
+
* for a given model family (and optional model).
|
|
7431
|
+
*
|
|
7432
|
+
* Note: Returning `0` can mean either:
|
|
7433
|
+
* 1. No eligible candidates exist in the pool, OR
|
|
7434
|
+
* 2. At least one eligible candidate is immediately usable without waiting.
|
|
7435
|
+
* Callers must distinguish "no eligible candidates" from "zero wait time"
|
|
7436
|
+
* by inspecting candidate pool availability / eligibility directly.
|
|
7437
|
+
*
|
|
7438
|
+
* @param family Model family (e.g., 'claude', 'gemini')
|
|
7439
|
+
* @param model Optional model name for per-model rate limits
|
|
7440
|
+
* @param eligibleIndexes Optional set of account indexes permitted for this request
|
|
7441
|
+
* @param includeCooldown Whether to factor in `coolingDownUntil` alongside quota rate limits
|
|
7442
|
+
* @returns Minimum wait duration in milliseconds, or 0 if immediately usable or no candidates
|
|
7443
|
+
*/
|
|
7444
|
+
getMinWaitTimeForFamily(family, model, eligibleIndexes, includeCooldown = false) {
|
|
7426
7445
|
const now = this.now();
|
|
7427
|
-
const waits = this.accounts.filter((a) =>
|
|
7446
|
+
const waits = this.accounts.filter((a) => {
|
|
7447
|
+
if (a.enabled === false)
|
|
7448
|
+
return false;
|
|
7449
|
+
if (a.accountIneligible === true || a.verificationRequired === true) {
|
|
7450
|
+
return false;
|
|
7451
|
+
}
|
|
7452
|
+
if (eligibleIndexes !== void 0 && eligibleIndexes !== null) {
|
|
7453
|
+
if (!eligibleIndexes.has(a.index))
|
|
7454
|
+
return false;
|
|
7455
|
+
}
|
|
7456
|
+
return true;
|
|
7457
|
+
}).map((a) => {
|
|
7428
7458
|
clearExpiredRateLimits(a, this.now);
|
|
7429
7459
|
const modelReset = model ? a.rateLimitResetTimes[getQuotaKey(family, model)] : void 0;
|
|
7430
|
-
|
|
7460
|
+
const cooldownWait = includeCooldown && a.coolingDownUntil !== void 0 && a.coolingDownUntil > now ? a.coolingDownUntil - now : 0;
|
|
7461
|
+
return Math.max(0, (a.rateLimitResetTimes[family] ?? now) - now, (modelReset ?? now) - now, cooldownWait);
|
|
7431
7462
|
});
|
|
7432
7463
|
return waits.length > 0 ? Math.min(...waits) : 0;
|
|
7433
7464
|
}
|
|
@@ -7622,36 +7653,42 @@ var init_account_selector = __esm({
|
|
|
7622
7653
|
}
|
|
7623
7654
|
return oldest;
|
|
7624
7655
|
}
|
|
7625
|
-
|
|
7656
|
+
/**
|
|
7657
|
+
* Check whether all eligible accounts (more than 1) are currently over the soft-quota threshold.
|
|
7658
|
+
* Returns false if thresholdPercent >= 100 or if <= 1 eligible account remains.
|
|
7659
|
+
*/
|
|
7660
|
+
areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
7626
7661
|
if (thresholdPercent >= 100)
|
|
7627
7662
|
return false;
|
|
7628
|
-
const
|
|
7629
|
-
if (
|
|
7663
|
+
const eligible = this.accounts.filter((a) => a.enabled !== false && a.accountIneligible !== true && a.verificationRequired !== true && (eligibleIndexes == null || eligibleIndexes.has(a.index)));
|
|
7664
|
+
if (eligible.length <= 1)
|
|
7630
7665
|
return false;
|
|
7631
|
-
return
|
|
7666
|
+
return eligible.every((a) => isOverSoftQuotaThreshold(a, family, thresholdPercent, cacheTtlMs, this.now, model));
|
|
7632
7667
|
}
|
|
7633
7668
|
/**
|
|
7634
|
-
* Get minimum wait time until any account's soft quota resets.
|
|
7635
|
-
*
|
|
7636
|
-
*
|
|
7637
|
-
* Returns null if no resetTime data is available.
|
|
7669
|
+
* Get minimum wait time until any eligible account's soft quota resets.
|
|
7670
|
+
* Operates over the eligible subset (enabled, non-ineligible, non-verification-required,
|
|
7671
|
+
* and present in `eligibleIndexes` when provided).
|
|
7672
|
+
* Returns null if no eligible accounts remain or no resetTime data is available.
|
|
7673
|
+
* Returns 0 if only 1 eligible account exists or any eligible account is below threshold.
|
|
7674
|
+
* Returns the minimum resetTime across all over-threshold eligible accounts.
|
|
7638
7675
|
*/
|
|
7639
|
-
getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model) {
|
|
7676
|
+
getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
7640
7677
|
if (thresholdPercent >= 100)
|
|
7641
7678
|
return 0;
|
|
7642
|
-
const
|
|
7643
|
-
if (
|
|
7679
|
+
const eligible = this.accounts.filter((a) => a.enabled !== false && a.accountIneligible !== true && a.verificationRequired !== true && (eligibleIndexes == null || eligibleIndexes.has(a.index)));
|
|
7680
|
+
if (eligible.length === 0)
|
|
7644
7681
|
return null;
|
|
7645
|
-
if (
|
|
7682
|
+
if (eligible.length === 1)
|
|
7646
7683
|
return 0;
|
|
7647
|
-
const available =
|
|
7684
|
+
const available = eligible.filter((a) => !isOverSoftQuotaThreshold(a, family, thresholdPercent, cacheTtlMs, this.now, model));
|
|
7648
7685
|
if (available.length > 0)
|
|
7649
7686
|
return 0;
|
|
7650
7687
|
if (!model && family !== "claude")
|
|
7651
7688
|
return null;
|
|
7652
7689
|
const now = this.now();
|
|
7653
7690
|
const waitTimes = [];
|
|
7654
|
-
for (const acc of
|
|
7691
|
+
for (const acc of eligible) {
|
|
7655
7692
|
const quotaGroup = resolveQuotaGroup(family, model, acc.cachedQuota);
|
|
7656
7693
|
const groupData = acc.cachedQuota?.[quotaGroup];
|
|
7657
7694
|
if (groupData?.resetTime) {
|
|
@@ -9656,8 +9693,24 @@ var init_account_manager = __esm({
|
|
|
9656
9693
|
expires: account.expires
|
|
9657
9694
|
};
|
|
9658
9695
|
}
|
|
9659
|
-
|
|
9660
|
-
|
|
9696
|
+
/**
|
|
9697
|
+
* Calculates the minimum wait time in milliseconds across eligible accounts
|
|
9698
|
+
* for a given model family (and optional model).
|
|
9699
|
+
*
|
|
9700
|
+
* Note: Returning `0` can mean either:
|
|
9701
|
+
* 1. No eligible candidates exist in the pool, OR
|
|
9702
|
+
* 2. At least one eligible candidate is immediately usable without waiting.
|
|
9703
|
+
* Callers must distinguish "no eligible candidates" from "zero wait time"
|
|
9704
|
+
* by inspecting candidate pool availability / eligibility directly.
|
|
9705
|
+
*
|
|
9706
|
+
* @param family Model family (e.g., 'claude', 'gemini')
|
|
9707
|
+
* @param model Optional model name for per-model rate limits
|
|
9708
|
+
* @param eligibleIndexes Optional set of account indexes permitted for this request
|
|
9709
|
+
* @param includeCooldown Whether to factor in `coolingDownUntil` alongside quota rate limits
|
|
9710
|
+
* @returns Minimum wait duration in milliseconds, or 0 if immediately usable or no candidates
|
|
9711
|
+
*/
|
|
9712
|
+
getMinWaitTimeForFamily(family, model, eligibleIndexes, includeCooldown = false) {
|
|
9713
|
+
return this.selection.getMinWaitTimeForFamily(family, model, eligibleIndexes, includeCooldown);
|
|
9661
9714
|
}
|
|
9662
9715
|
getAccounts() {
|
|
9663
9716
|
return this.selection.getAccounts();
|
|
@@ -10000,17 +10053,23 @@ var init_account_manager = __esm({
|
|
|
10000
10053
|
getOldestQuotaCacheAge() {
|
|
10001
10054
|
return this.selection.getOldestQuotaCacheAge();
|
|
10002
10055
|
}
|
|
10003
|
-
|
|
10004
|
-
|
|
10056
|
+
/**
|
|
10057
|
+
* Check whether all eligible accounts (more than 1) are currently over the soft-quota threshold.
|
|
10058
|
+
* Returns false if thresholdPercent >= 100 or if <= 1 eligible account remains.
|
|
10059
|
+
*/
|
|
10060
|
+
areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
10061
|
+
return this.selection.areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes);
|
|
10005
10062
|
}
|
|
10006
10063
|
/**
|
|
10007
|
-
* Get minimum wait time until any account's soft quota resets.
|
|
10008
|
-
*
|
|
10009
|
-
*
|
|
10010
|
-
* Returns null if no resetTime data is available.
|
|
10064
|
+
* Get minimum wait time until any eligible account's soft quota resets.
|
|
10065
|
+
* Operates over the eligible subset (enabled, non-ineligible, non-verification-required,
|
|
10066
|
+
* and present in `eligibleIndexes` when provided).
|
|
10067
|
+
* Returns null if no eligible accounts remain or no resetTime data is available.
|
|
10068
|
+
* Returns 0 if only 1 eligible account exists or any eligible account is below threshold.
|
|
10069
|
+
* Returns the minimum resetTime across all over-threshold eligible accounts.
|
|
10011
10070
|
*/
|
|
10012
|
-
getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model) {
|
|
10013
|
-
return this.selection.getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model);
|
|
10071
|
+
getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
10072
|
+
return this.selection.getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes);
|
|
10014
10073
|
}
|
|
10015
10074
|
};
|
|
10016
10075
|
}
|
|
@@ -45295,18 +45354,32 @@ function createRequestExecutor(deps) {
|
|
|
45295
45354
|
const blockedSince = allAccountsBlockedAt;
|
|
45296
45355
|
const remainingWaitMs = () => maxWaitMs > 0 ? Math.max(0, maxWaitMs - (Date.now() - blockedSince)) : Number.POSITIVE_INFINITY;
|
|
45297
45356
|
const quotaWins = remainingWaitMs() <= deadline.remainingMs();
|
|
45357
|
+
const eligibleCandidateIndexes = new Set(
|
|
45358
|
+
accountManager.getAccounts().filter(
|
|
45359
|
+
(entry) => entry.enabled !== false && !entry.accountIneligible && !entry.verificationRequired && !excludedIndexes?.has(entry.index)
|
|
45360
|
+
).map((entry) => entry.index)
|
|
45361
|
+
);
|
|
45362
|
+
if (eligibleCandidateIndexes.size === 0) {
|
|
45363
|
+
waitPolicy.refusal = () => createNativeGoogleErrorResponse({
|
|
45364
|
+
status: 412,
|
|
45365
|
+
reason: "pool_unavailable"
|
|
45366
|
+
});
|
|
45367
|
+
return waitPolicy.refusal();
|
|
45368
|
+
}
|
|
45298
45369
|
if (accountManager.areAllAccountsOverSoftQuota(
|
|
45299
45370
|
family,
|
|
45300
45371
|
config.soft_quota_threshold_percent,
|
|
45301
45372
|
softQuotaCacheTtlMs,
|
|
45302
|
-
model
|
|
45373
|
+
model,
|
|
45374
|
+
eligibleCandidateIndexes
|
|
45303
45375
|
)) {
|
|
45304
45376
|
const threshold = config.soft_quota_threshold_percent;
|
|
45305
45377
|
const softQuotaWaitMs = accountManager.getMinWaitTimeForSoftQuota(
|
|
45306
45378
|
family,
|
|
45307
45379
|
threshold,
|
|
45308
45380
|
softQuotaCacheTtlMs,
|
|
45309
|
-
model
|
|
45381
|
+
model,
|
|
45382
|
+
eligibleCandidateIndexes
|
|
45310
45383
|
);
|
|
45311
45384
|
waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
|
|
45312
45385
|
status: 412,
|
|
@@ -45338,7 +45411,12 @@ function createRequestExecutor(deps) {
|
|
|
45338
45411
|
await sleep4(Math.min(softQuotaWaitMs, remainingWaitMs()), abortSignal);
|
|
45339
45412
|
continue;
|
|
45340
45413
|
}
|
|
45341
|
-
const minWaitMs = accountManager.getMinWaitTimeForFamily(
|
|
45414
|
+
const minWaitMs = accountManager.getMinWaitTimeForFamily(
|
|
45415
|
+
family,
|
|
45416
|
+
model,
|
|
45417
|
+
eligibleCandidateIndexes,
|
|
45418
|
+
true
|
|
45419
|
+
);
|
|
45342
45420
|
const waitMs = minWaitMs || 6e4;
|
|
45343
45421
|
waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
|
|
45344
45422
|
status: 412,
|
|
@@ -48794,6 +48872,7 @@ function createGaLocationServicesFactory(bindings) {
|
|
|
48794
48872
|
let started = false;
|
|
48795
48873
|
let disposal;
|
|
48796
48874
|
let repositoryPromise;
|
|
48875
|
+
let repositoryPromiseLogin = false;
|
|
48797
48876
|
let servingRepository;
|
|
48798
48877
|
let localPromise;
|
|
48799
48878
|
let vaultPromise;
|
|
@@ -48845,15 +48924,22 @@ function createGaLocationServicesFactory(bindings) {
|
|
|
48845
48924
|
};
|
|
48846
48925
|
const getRepository = async (login) => {
|
|
48847
48926
|
await assertLocal();
|
|
48848
|
-
repositoryPromise
|
|
48849
|
-
|
|
48850
|
-
|
|
48851
|
-
|
|
48852
|
-
login
|
|
48853
|
-
|
|
48854
|
-
|
|
48855
|
-
|
|
48856
|
-
|
|
48927
|
+
if (login && repositoryPromise && !repositoryPromiseLogin) {
|
|
48928
|
+
await repositoryPromise.catch(() => void 0);
|
|
48929
|
+
}
|
|
48930
|
+
if (!repositoryPromise) {
|
|
48931
|
+
repositoryPromiseLogin = Boolean(login);
|
|
48932
|
+
repositoryPromise = openLocationRepository(
|
|
48933
|
+
directory,
|
|
48934
|
+
bindings,
|
|
48935
|
+
overrides,
|
|
48936
|
+
login
|
|
48937
|
+
).catch((error) => {
|
|
48938
|
+
repositoryPromise = void 0;
|
|
48939
|
+
repositoryPromiseLogin = false;
|
|
48940
|
+
throw error;
|
|
48941
|
+
});
|
|
48942
|
+
}
|
|
48857
48943
|
const repository = (await repositoryPromise).repository;
|
|
48858
48944
|
if (!servingRepository) {
|
|
48859
48945
|
const methods = /* @__PURE__ */ new Map();
|
|
@@ -48930,6 +49016,30 @@ function createGaLocationServicesFactory(bindings) {
|
|
|
48930
49016
|
runtime,
|
|
48931
49017
|
localLogin: {
|
|
48932
49018
|
assertAdmission: assertLocal,
|
|
49019
|
+
async assertExistingPool(admit2) {
|
|
49020
|
+
await assertLocal();
|
|
49021
|
+
await admit2();
|
|
49022
|
+
const repository = await getRepository();
|
|
49023
|
+
await admit2();
|
|
49024
|
+
const opened = await repositoryPromise;
|
|
49025
|
+
await admit2();
|
|
49026
|
+
if (!opened)
|
|
49027
|
+
throw new Error("The local repository was not constructed");
|
|
49028
|
+
await assertServingAdmission(opened, bindings.now);
|
|
49029
|
+
await admit2();
|
|
49030
|
+
const read = await repository.read();
|
|
49031
|
+
await admit2();
|
|
49032
|
+
if (read.status !== "ready" || !read.rows.some(
|
|
49033
|
+
(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"
|
|
49034
|
+
))
|
|
49035
|
+
throw new Error(
|
|
49036
|
+
"The existing local Antigravity pool is unavailable"
|
|
49037
|
+
);
|
|
49038
|
+
await assertServingAdmission(opened, bindings.now);
|
|
49039
|
+
await admit2();
|
|
49040
|
+
await assertLocal();
|
|
49041
|
+
await admit2();
|
|
49042
|
+
},
|
|
48933
49043
|
async persist(result, admit2) {
|
|
48934
49044
|
await assertLocal();
|
|
48935
49045
|
await admit2();
|
|
@@ -50710,6 +50820,7 @@ init_dist();
|
|
|
50710
50820
|
// src/auth-method-labels.ts
|
|
50711
50821
|
var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
|
|
50712
50822
|
var OPENCODE2_VAULT_AUTH_LABEL = "Use approved Antigravity vault";
|
|
50823
|
+
var OPENCODE2_POOL_RECONNECT_LABEL = "Use existing local Antigravity pool";
|
|
50713
50824
|
|
|
50714
50825
|
// src/ga/server/auth.ts
|
|
50715
50826
|
init_storage();
|
|
@@ -50719,6 +50830,7 @@ init_vault_folder();
|
|
|
50719
50830
|
// src/ga/server/pool-login.ts
|
|
50720
50831
|
init_dist();
|
|
50721
50832
|
var GA_POOL_METHOD_ID = "antigravity-auth-pool-browser";
|
|
50833
|
+
var GA_POOL_RECONNECT_METHOD_ID = "antigravity-auth-pool-reconnect";
|
|
50722
50834
|
var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
|
|
50723
50835
|
function abortable(pending, signal) {
|
|
50724
50836
|
return new Promise((resolve28, reject) => {
|
|
@@ -50842,6 +50954,26 @@ function createGaPoolLogin(input2) {
|
|
|
50842
50954
|
};
|
|
50843
50955
|
return {
|
|
50844
50956
|
method,
|
|
50957
|
+
connectExisting: () => track(
|
|
50958
|
+
(async () => {
|
|
50959
|
+
try {
|
|
50960
|
+
await admit2();
|
|
50961
|
+
if (!input2.local?.assertExistingPool) throw new Error(LOGIN_FAILED);
|
|
50962
|
+
await abortable(
|
|
50963
|
+
track(input2.local.assertExistingPool(admit2)),
|
|
50964
|
+
shutdown.signal
|
|
50965
|
+
);
|
|
50966
|
+
await admit2();
|
|
50967
|
+
return placeholderCredential({
|
|
50968
|
+
integrationID: ANTIGRAVITY_PROVIDER_ID,
|
|
50969
|
+
methodID: GA_POOL_RECONNECT_METHOD_ID,
|
|
50970
|
+
now: Date.now()
|
|
50971
|
+
});
|
|
50972
|
+
} catch {
|
|
50973
|
+
throw new Error(LOGIN_FAILED);
|
|
50974
|
+
}
|
|
50975
|
+
})()
|
|
50976
|
+
),
|
|
50845
50977
|
onLogin: (result) => track(
|
|
50846
50978
|
(async () => {
|
|
50847
50979
|
try {
|
|
@@ -50875,33 +51007,83 @@ async function readAuthority() {
|
|
|
50875
51007
|
}
|
|
50876
51008
|
async function registerGaAuthMethods(context, authority = readAuthority, input2 = {}) {
|
|
50877
51009
|
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
|
-
|
|
51010
|
+
const registrations = [];
|
|
51011
|
+
try {
|
|
51012
|
+
registrations.push(
|
|
51013
|
+
await registerOpenCode2AuthMethods(context, {
|
|
51014
|
+
integrationID: ANTIGRAVITY_PROVIDER_ID,
|
|
51015
|
+
methods: [pool.method],
|
|
51016
|
+
onLogin: pool.onLogin,
|
|
51017
|
+
vault: {
|
|
51018
|
+
method: {
|
|
51019
|
+
id: GA_VAULT_METHOD_ID,
|
|
51020
|
+
type: "oauth",
|
|
51021
|
+
label: OPENCODE2_VAULT_AUTH_LABEL
|
|
51022
|
+
},
|
|
51023
|
+
async activate() {
|
|
51024
|
+
if (await authority() !== "vault") {
|
|
51025
|
+
throw new Error(
|
|
51026
|
+
"Approve Antigravity vault access before activating this connection"
|
|
51027
|
+
);
|
|
51028
|
+
}
|
|
51029
|
+
}
|
|
51030
|
+
},
|
|
51031
|
+
label: "Antigravity"
|
|
51032
|
+
})
|
|
51033
|
+
);
|
|
51034
|
+
if (input2.local?.assertExistingPool) {
|
|
51035
|
+
registrations.push(
|
|
51036
|
+
await context.integration.transform((editor) => {
|
|
51037
|
+
editor.method.update({
|
|
51038
|
+
integrationID: ANTIGRAVITY_PROVIDER_ID,
|
|
51039
|
+
method: {
|
|
51040
|
+
id: GA_POOL_RECONNECT_METHOD_ID,
|
|
51041
|
+
type: "oauth",
|
|
51042
|
+
label: OPENCODE2_POOL_RECONNECT_LABEL
|
|
51043
|
+
},
|
|
51044
|
+
authorize: async () => {
|
|
51045
|
+
const callback = pool.connectExisting();
|
|
51046
|
+
void callback.catch(() => {
|
|
51047
|
+
});
|
|
51048
|
+
return {
|
|
51049
|
+
mode: "auto",
|
|
51050
|
+
url: "",
|
|
51051
|
+
instructions: "No browser sign-in needed: connect the existing local Antigravity pool without changing its accounts.",
|
|
51052
|
+
callback
|
|
51053
|
+
};
|
|
51054
|
+
},
|
|
51055
|
+
refresh: async (credential) => {
|
|
51056
|
+
if (!isPlaceholderCredential(credential, ANTIGRAVITY_PROVIDER_ID) || credential.methodID !== GA_POOL_RECONNECT_METHOD_ID) {
|
|
51057
|
+
throw new Error(
|
|
51058
|
+
"This login method refreshes only its existing local pool placeholder."
|
|
51059
|
+
);
|
|
51060
|
+
}
|
|
51061
|
+
return pool.connectExisting();
|
|
51062
|
+
},
|
|
51063
|
+
label: () => "Antigravity"
|
|
51064
|
+
});
|
|
51065
|
+
})
|
|
51066
|
+
);
|
|
51067
|
+
}
|
|
51068
|
+
} catch (error) {
|
|
51069
|
+
const stopping = pool.dispose();
|
|
51070
|
+
await Promise.allSettled(
|
|
51071
|
+
registrations.map((registration) => registration.dispose())
|
|
51072
|
+
);
|
|
51073
|
+
await stopping;
|
|
51074
|
+
throw error;
|
|
51075
|
+
}
|
|
50898
51076
|
let disposal;
|
|
50899
51077
|
return {
|
|
50900
51078
|
dispose() {
|
|
50901
51079
|
disposal ??= (async () => {
|
|
50902
51080
|
const stopping = pool.dispose();
|
|
50903
51081
|
try {
|
|
50904
|
-
await
|
|
51082
|
+
const results = await Promise.allSettled(
|
|
51083
|
+
registrations.map((registration) => registration.dispose())
|
|
51084
|
+
);
|
|
51085
|
+
const failure2 = results.find((result) => result.status === "rejected");
|
|
51086
|
+
if (failure2?.status === "rejected") throw failure2.reason;
|
|
50905
51087
|
} finally {
|
|
50906
51088
|
await stopping;
|
|
50907
51089
|
}
|
|
@@ -55279,6 +55461,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
55279
55461
|
}
|
|
55280
55462
|
};
|
|
55281
55463
|
let openCodeLogin;
|
|
55464
|
+
let hasLocalPool = false;
|
|
55282
55465
|
const manifest = JSON.parse(
|
|
55283
55466
|
await readFile16(new URL("../package.json", import.meta.url), "utf8")
|
|
55284
55467
|
);
|
|
@@ -55334,7 +55517,23 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
55334
55517
|
},
|
|
55335
55518
|
signInLocal: async (host, context) => {
|
|
55336
55519
|
await assertLocal(host, context);
|
|
55337
|
-
if (host === "opencode" && context.opencodeGeneration === "2")
|
|
55520
|
+
if (host === "opencode" && context.opencodeGeneration === "2") {
|
|
55521
|
+
if (!forceLogin) {
|
|
55522
|
+
try {
|
|
55523
|
+
const source2 = await deps.accountStore.read(
|
|
55524
|
+
deps.accountStore.legacyPath()
|
|
55525
|
+
);
|
|
55526
|
+
const candidateAccounts = source2.kind === "store" ? source2.accounts : source2.kind === "legacy" ? (await deps.loadAccounts())?.accounts ?? [] : [];
|
|
55527
|
+
if (candidateAccounts.some(
|
|
55528
|
+
(account) => account.enabled !== false && account.accountIneligible !== true && account.verificationRequired !== true && typeof account.refreshToken === "string" && account.refreshToken.length > 0
|
|
55529
|
+
)) {
|
|
55530
|
+
hasLocalPool = true;
|
|
55531
|
+
}
|
|
55532
|
+
} catch {
|
|
55533
|
+
}
|
|
55534
|
+
}
|
|
55535
|
+
return;
|
|
55536
|
+
}
|
|
55338
55537
|
const slot = (await nativeAuth(host, context))[provider(host)];
|
|
55339
55538
|
const source = host === "opencode" ? await deps.accountStore.read(deps.accountStore.legacyPath()) : void 0;
|
|
55340
55539
|
if (source?.kind === "unavailable") throw new Error(source.reason);
|
|
@@ -55346,6 +55545,11 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
55346
55545
|
`Using existing local Antigravity login for ${host}.
|
|
55347
55546
|
`
|
|
55348
55547
|
);
|
|
55548
|
+
if (host === "opencode" && accounts.some(
|
|
55549
|
+
(account) => account.enabled !== false && account.accountIneligible !== true && account.verificationRequired !== true && typeof account.refreshToken === "string" && account.refreshToken.length > 0
|
|
55550
|
+
)) {
|
|
55551
|
+
hasLocalPool = true;
|
|
55552
|
+
}
|
|
55349
55553
|
if (host === "opencode" && claustrum.classifyHostSlot(slot, provider(host)) !== "login") {
|
|
55350
55554
|
const account = accounts[0];
|
|
55351
55555
|
await writeNativeSlot(
|
|
@@ -55376,7 +55580,10 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
55376
55580
|
host,
|
|
55377
55581
|
context
|
|
55378
55582
|
);
|
|
55379
|
-
if (host === "opencode")
|
|
55583
|
+
if (host === "opencode") {
|
|
55584
|
+
openCodeLogin = result;
|
|
55585
|
+
hasLocalPool = true;
|
|
55586
|
+
}
|
|
55380
55587
|
},
|
|
55381
55588
|
beforeRegister: async (host, mode, context) => {
|
|
55382
55589
|
const needsOpenCode2 = host === "opencode" && context.opencodeGeneration !== "1";
|
|
@@ -55400,7 +55607,10 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
55400
55607
|
},
|
|
55401
55608
|
context
|
|
55402
55609
|
);
|
|
55403
|
-
if (needsOpenCode2)
|
|
55610
|
+
if (needsOpenCode2)
|
|
55611
|
+
nativeNextStep(
|
|
55612
|
+
hasLocalPool ? OPENCODE2_POOL_RECONNECT_LABEL : OPENCODE2_POOL_AUTH_LABEL
|
|
55613
|
+
);
|
|
55404
55614
|
return;
|
|
55405
55615
|
}
|
|
55406
55616
|
if (await authority(host) !== "vault")
|