@cortexkit/opencode-antigravity-auth 3.0.24 → 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.map +1 -1
- package/dist/cli.meta.json +3 -3
- package/dist/index.js +111 -39
- package/dist/index.js.map +2 -2
- package/dist/index.meta.json +8 -8
- package/dist/server.js +111 -39
- package/dist/server.js.map +2 -2
- package/dist/server.meta.json +1 -1
- package/dist/src/plugin/shared/request-services.d.ts +1 -0
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +60 -26
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts +1 -0
- package/dist/types/src/plugin/shared/request-services.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": 61373,
|
|
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": 68562,
|
|
289
289
|
"imports": [
|
|
290
290
|
{
|
|
291
291
|
"path": "node:crypto",
|
|
@@ -5952,7 +5952,7 @@
|
|
|
5952
5952
|
"format": "esm"
|
|
5953
5953
|
},
|
|
5954
5954
|
"src/plugin/shared/request-services.ts": {
|
|
5955
|
-
"bytes":
|
|
5955
|
+
"bytes": 124754,
|
|
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": 4735409
|
|
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": 53453
|
|
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": 61818
|
|
7719
7719
|
},
|
|
7720
7720
|
"../core/dist/account-types.js": {
|
|
7721
7721
|
"bytesInOutput": 97
|
|
@@ -8426,7 +8426,7 @@
|
|
|
8426
8426
|
"bytesInOutput": 7610
|
|
8427
8427
|
},
|
|
8428
8428
|
"src/plugin/shared/request-services.ts": {
|
|
8429
|
-
"bytesInOutput":
|
|
8429
|
+
"bytesInOutput": 84545
|
|
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": 2143708
|
|
8484
8484
|
}
|
|
8485
8485
|
}
|
|
8486
8486
|
}
|
package/dist/server.js
CHANGED
|
@@ -7184,6 +7184,9 @@ var init_account_selector = __esm({
|
|
|
7184
7184
|
const candidates = this.preferAccountOutsideParent(this.accounts.filter((acc) => {
|
|
7185
7185
|
if (acc.enabled === false)
|
|
7186
7186
|
return false;
|
|
7187
|
+
if (acc.accountIneligible === true || acc.verificationRequired === true) {
|
|
7188
|
+
return false;
|
|
7189
|
+
}
|
|
7187
7190
|
if (acc.index === currentIndex)
|
|
7188
7191
|
return false;
|
|
7189
7192
|
clearExpiredRateLimits(acc, this.now);
|
|
@@ -7431,7 +7434,9 @@ var init_account_selector = __esm({
|
|
|
7431
7434
|
*
|
|
7432
7435
|
* Note: Returning `0` can mean either:
|
|
7433
7436
|
* 1. No eligible candidates exist in the pool, OR
|
|
7434
|
-
* 2. At least one eligible candidate is
|
|
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).
|
|
7435
7440
|
* Callers must distinguish "no eligible candidates" from "zero wait time"
|
|
7436
7441
|
* by inspecting candidate pool availability / eligibility directly.
|
|
7437
7442
|
*
|
|
@@ -7439,7 +7444,7 @@ var init_account_selector = __esm({
|
|
|
7439
7444
|
* @param model Optional model name for per-model rate limits
|
|
7440
7445
|
* @param eligibleIndexes Optional set of account indexes permitted for this request
|
|
7441
7446
|
* @param includeCooldown Whether to factor in `coolingDownUntil` alongside quota rate limits
|
|
7442
|
-
* @returns Minimum wait duration in milliseconds, or 0 if
|
|
7447
|
+
* @returns Minimum wait duration in milliseconds, or 0 if hard/cooldown-ready or no candidates
|
|
7443
7448
|
*/
|
|
7444
7449
|
getMinWaitTimeForFamily(family, model, eligibleIndexes, includeCooldown = false) {
|
|
7445
7450
|
const now = this.now();
|
|
@@ -7637,8 +7642,51 @@ var init_account_selector = __esm({
|
|
|
7637
7642
|
perAccount: perAccount.sort((a, b) => b.claude + b.gemini - (a.claude + a.gemini))
|
|
7638
7643
|
};
|
|
7639
7644
|
}
|
|
7640
|
-
isAccountOverSoftQuota(account, family, thresholdPercent, cacheTtlMs, model) {
|
|
7641
|
-
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);
|
|
7642
7690
|
}
|
|
7643
7691
|
getOldestQuotaCacheAge() {
|
|
7644
7692
|
let oldest = null;
|
|
@@ -10020,8 +10068,8 @@ var init_account_manager = __esm({
|
|
|
10020
10068
|
getSessionSummary() {
|
|
10021
10069
|
return this.selection.getSessionSummary();
|
|
10022
10070
|
}
|
|
10023
|
-
isAccountOverSoftQuota(account, family, thresholdPercent, cacheTtlMs, model) {
|
|
10024
|
-
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);
|
|
10025
10073
|
}
|
|
10026
10074
|
/**
|
|
10027
10075
|
* The accounts a quota check should cover. For a repository-backed
|
|
@@ -10071,6 +10119,9 @@ var init_account_manager = __esm({
|
|
|
10071
10119
|
getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
10072
10120
|
return this.selection.getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes);
|
|
10073
10121
|
}
|
|
10122
|
+
getMinSelectableWaitTimeForFamily(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
|
|
10123
|
+
return this.selection.getMinSelectableWaitTimeForFamily(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes);
|
|
10124
|
+
}
|
|
10074
10125
|
};
|
|
10075
10126
|
}
|
|
10076
10127
|
});
|
|
@@ -45265,8 +45316,8 @@ function createRequestExecutor(deps) {
|
|
|
45265
45316
|
accountManager.getAccounts().map((entry) => entry.index).filter((index) => !eligibleIndexes.has(index))
|
|
45266
45317
|
);
|
|
45267
45318
|
if (modelUnavailableIndexes.size > 0) {
|
|
45268
|
-
const candidates = accountManager.
|
|
45269
|
-
(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))
|
|
45270
45321
|
);
|
|
45271
45322
|
if (candidates.length > 0 && candidates.every((entry) => modelUnavailableIndexes.has(entry.index))) {
|
|
45272
45323
|
pushDebug(
|
|
@@ -45302,13 +45353,14 @@ function createRequestExecutor(deps) {
|
|
|
45302
45353
|
if (account) {
|
|
45303
45354
|
routingPlacementConsidered = true;
|
|
45304
45355
|
if (firstPlacement && credentials.domain === "vault" && credentials.routingCandidate && model && isPrimaryVaultRequest(kind, init?.headers)) {
|
|
45305
|
-
const candidates = accountManager.
|
|
45306
|
-
(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(
|
|
45307
45358
|
row,
|
|
45308
45359
|
family,
|
|
45309
45360
|
config.soft_quota_threshold_percent,
|
|
45310
45361
|
softQuotaCacheTtlMs,
|
|
45311
|
-
model
|
|
45362
|
+
model,
|
|
45363
|
+
excludedIndexes
|
|
45312
45364
|
)
|
|
45313
45365
|
).map((row) => ({
|
|
45314
45366
|
...credentials.routingCandidate(row),
|
|
@@ -45354,10 +45406,11 @@ function createRequestExecutor(deps) {
|
|
|
45354
45406
|
const blockedSince = allAccountsBlockedAt;
|
|
45355
45407
|
const remainingWaitMs = () => maxWaitMs > 0 ? Math.max(0, maxWaitMs - (Date.now() - blockedSince)) : Number.POSITIVE_INFINITY;
|
|
45356
45408
|
const quotaWins = remainingWaitMs() <= deadline.remainingMs();
|
|
45409
|
+
const eligibleCandidates = accountManager.getAccounts().filter(
|
|
45410
|
+
(entry) => entry.enabled !== false && !entry.accountIneligible && !entry.verificationRequired && !excludedIndexes?.has(entry.index)
|
|
45411
|
+
);
|
|
45357
45412
|
const eligibleCandidateIndexes = new Set(
|
|
45358
|
-
|
|
45359
|
-
(entry) => entry.enabled !== false && !entry.accountIneligible && !entry.verificationRequired && !excludedIndexes?.has(entry.index)
|
|
45360
|
-
).map((entry) => entry.index)
|
|
45413
|
+
eligibleCandidates.map((entry) => entry.index)
|
|
45361
45414
|
);
|
|
45362
45415
|
if (eligibleCandidateIndexes.size === 0) {
|
|
45363
45416
|
waitPolicy.refusal = () => createNativeGoogleErrorResponse({
|
|
@@ -45366,28 +45419,55 @@ function createRequestExecutor(deps) {
|
|
|
45366
45419
|
});
|
|
45367
45420
|
return waitPolicy.refusal();
|
|
45368
45421
|
}
|
|
45369
|
-
|
|
45422
|
+
const threshold = config.soft_quota_threshold_percent;
|
|
45423
|
+
const combinedDelayMs = accountManager.getMinSelectableWaitTimeForFamily(
|
|
45370
45424
|
family,
|
|
45371
|
-
|
|
45425
|
+
threshold,
|
|
45372
45426
|
softQuotaCacheTtlMs,
|
|
45373
45427
|
model,
|
|
45374
45428
|
eligibleCandidateIndexes
|
|
45375
|
-
)
|
|
45376
|
-
|
|
45377
|
-
|
|
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,
|
|
45378
45445
|
family,
|
|
45379
45446
|
threshold,
|
|
45380
45447
|
softQuotaCacheTtlMs,
|
|
45381
45448
|
model,
|
|
45382
|
-
|
|
45383
|
-
)
|
|
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) {
|
|
45384
45463
|
waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
|
|
45385
45464
|
status: 412,
|
|
45386
45465
|
reason: "soft_quota",
|
|
45387
|
-
resetAfterMs:
|
|
45466
|
+
resetAfterMs: remainingResetAfterMs()
|
|
45388
45467
|
}) : void 0;
|
|
45389
|
-
if (
|
|
45390
|
-
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";
|
|
45391
45471
|
await showToast(
|
|
45392
45472
|
`All accounts over ${threshold}% quota threshold. Resets in ${waitTimeFormatted}.`,
|
|
45393
45473
|
"error"
|
|
@@ -45395,33 +45475,26 @@ function createRequestExecutor(deps) {
|
|
|
45395
45475
|
return createNativeGoogleErrorResponse({
|
|
45396
45476
|
status: 412,
|
|
45397
45477
|
reason: "soft_quota",
|
|
45398
|
-
resetAfterMs:
|
|
45478
|
+
resetAfterMs: remainingResetAfterMs()
|
|
45399
45479
|
});
|
|
45400
45480
|
}
|
|
45401
45481
|
pushDebug(
|
|
45402
|
-
`all-over-soft-quota family=${family} accounts=${accountCount} waitMs=${
|
|
45482
|
+
`all-over-soft-quota family=${family} accounts=${accountCount} waitMs=${waitMs}`
|
|
45403
45483
|
);
|
|
45404
45484
|
if (!retryState.softQuotaToastShown()) {
|
|
45405
45485
|
await showToast(
|
|
45406
|
-
`All ${accountCount} account(s) over ${threshold}% quota. Waiting ${formatWaitTime(
|
|
45486
|
+
`All ${accountCount} account(s) over ${threshold}% quota. Waiting ${formatWaitTime(waitMs)}...`,
|
|
45407
45487
|
"warning"
|
|
45408
45488
|
);
|
|
45409
45489
|
retryState.markSoftQuotaToastShown();
|
|
45410
45490
|
}
|
|
45411
|
-
await sleep4(Math.min(
|
|
45491
|
+
await sleep4(Math.min(waitMs, remainingWaitMs()), abortSignal);
|
|
45412
45492
|
continue;
|
|
45413
45493
|
}
|
|
45414
|
-
const minWaitMs = accountManager.getMinWaitTimeForFamily(
|
|
45415
|
-
family,
|
|
45416
|
-
model,
|
|
45417
|
-
eligibleCandidateIndexes,
|
|
45418
|
-
true
|
|
45419
|
-
);
|
|
45420
|
-
const waitMs = minWaitMs || 6e4;
|
|
45421
45494
|
waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
|
|
45422
45495
|
status: 412,
|
|
45423
45496
|
reason: "pool_unavailable",
|
|
45424
|
-
resetAfterMs:
|
|
45497
|
+
resetAfterMs: remainingResetAfterMs()
|
|
45425
45498
|
}) : void 0;
|
|
45426
45499
|
pushDebug(
|
|
45427
45500
|
`all-rate-limited family=${family} accounts=${accountCount} waitMs=${waitMs}`
|
|
@@ -45446,9 +45519,8 @@ function createRequestExecutor(deps) {
|
|
|
45446
45519
|
return createNativeGoogleErrorResponse({
|
|
45447
45520
|
status: 412,
|
|
45448
45521
|
reason: "pool_unavailable",
|
|
45449
|
-
//
|
|
45450
|
-
|
|
45451
|
-
resetAfterMs: minWaitMs > 0 ? minWaitMs : void 0
|
|
45522
|
+
// Fallback sleep duration gets NO reset metadata.
|
|
45523
|
+
resetAfterMs: remainingResetAfterMs()
|
|
45452
45524
|
});
|
|
45453
45525
|
}
|
|
45454
45526
|
if (!retryState.rateLimitToastShown()) {
|