@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/cli.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",
|
|
@@ -4355,7 +4355,7 @@
|
|
|
4355
4355
|
"imports": [],
|
|
4356
4356
|
"exports": [],
|
|
4357
4357
|
"inputs": {},
|
|
4358
|
-
"bytes":
|
|
4358
|
+
"bytes": 3176325
|
|
4359
4359
|
},
|
|
4360
4360
|
"dist/cli.js": {
|
|
4361
4361
|
"imports": [
|
package/dist/index.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
|
});
|
|
@@ -54366,8 +54417,8 @@ function createRequestExecutor(deps) {
|
|
|
54366
54417
|
accountManager.getAccounts().map((entry) => entry.index).filter((index) => !eligibleIndexes.has(index))
|
|
54367
54418
|
);
|
|
54368
54419
|
if (modelUnavailableIndexes.size > 0) {
|
|
54369
|
-
const candidates = accountManager.
|
|
54370
|
-
(entry) => eligibleIndexes === null || eligibleIndexes.has(entry.index)
|
|
54420
|
+
const candidates = accountManager.getAccounts().filter(
|
|
54421
|
+
(entry) => entry.enabled !== false && !entry.accountIneligible && !entry.verificationRequired && (eligibleIndexes === null || eligibleIndexes.has(entry.index))
|
|
54371
54422
|
);
|
|
54372
54423
|
if (candidates.length > 0 && candidates.every((entry) => modelUnavailableIndexes.has(entry.index))) {
|
|
54373
54424
|
pushDebug(
|
|
@@ -54403,13 +54454,14 @@ function createRequestExecutor(deps) {
|
|
|
54403
54454
|
if (account) {
|
|
54404
54455
|
routingPlacementConsidered = true;
|
|
54405
54456
|
if (firstPlacement && credentials.domain === "vault" && credentials.routingCandidate && model && isPrimaryVaultRequest(kind, init?.headers)) {
|
|
54406
|
-
const candidates = accountManager.
|
|
54407
|
-
(row) => !excludedIndexes?.has(row.index) && !accountManager.isRateLimited(row, family, model) && !accountManager.isAccountCoolingDown(row) && !accountManager.isAccountOverSoftQuota(
|
|
54457
|
+
const candidates = accountManager.getAccounts().filter(
|
|
54458
|
+
(row) => row.enabled !== false && !row.accountIneligible && !row.verificationRequired && !excludedIndexes?.has(row.index) && !accountManager.isRateLimited(row, family, model) && !accountManager.isAccountCoolingDown(row) && !accountManager.isAccountOverSoftQuota(
|
|
54408
54459
|
row,
|
|
54409
54460
|
family,
|
|
54410
54461
|
config.soft_quota_threshold_percent,
|
|
54411
54462
|
softQuotaCacheTtlMs,
|
|
54412
|
-
model
|
|
54463
|
+
model,
|
|
54464
|
+
excludedIndexes
|
|
54413
54465
|
)
|
|
54414
54466
|
).map((row) => ({
|
|
54415
54467
|
...credentials.routingCandidate(row),
|
|
@@ -54455,10 +54507,11 @@ function createRequestExecutor(deps) {
|
|
|
54455
54507
|
const blockedSince = allAccountsBlockedAt;
|
|
54456
54508
|
const remainingWaitMs = () => maxWaitMs > 0 ? Math.max(0, maxWaitMs - (Date.now() - blockedSince)) : Number.POSITIVE_INFINITY;
|
|
54457
54509
|
const quotaWins = remainingWaitMs() <= deadline.remainingMs();
|
|
54510
|
+
const eligibleCandidates = accountManager.getAccounts().filter(
|
|
54511
|
+
(entry) => entry.enabled !== false && !entry.accountIneligible && !entry.verificationRequired && !excludedIndexes?.has(entry.index)
|
|
54512
|
+
);
|
|
54458
54513
|
const eligibleCandidateIndexes = new Set(
|
|
54459
|
-
|
|
54460
|
-
(entry) => entry.enabled !== false && !entry.accountIneligible && !entry.verificationRequired && !excludedIndexes?.has(entry.index)
|
|
54461
|
-
).map((entry) => entry.index)
|
|
54514
|
+
eligibleCandidates.map((entry) => entry.index)
|
|
54462
54515
|
);
|
|
54463
54516
|
if (eligibleCandidateIndexes.size === 0) {
|
|
54464
54517
|
waitPolicy.refusal = () => createNativeGoogleErrorResponse({
|
|
@@ -54467,28 +54520,55 @@ function createRequestExecutor(deps) {
|
|
|
54467
54520
|
});
|
|
54468
54521
|
return waitPolicy.refusal();
|
|
54469
54522
|
}
|
|
54470
|
-
|
|
54523
|
+
const threshold = config.soft_quota_threshold_percent;
|
|
54524
|
+
const combinedDelayMs = accountManager.getMinSelectableWaitTimeForFamily(
|
|
54471
54525
|
family,
|
|
54472
|
-
|
|
54526
|
+
threshold,
|
|
54473
54527
|
softQuotaCacheTtlMs,
|
|
54474
54528
|
model,
|
|
54475
54529
|
eligibleCandidateIndexes
|
|
54476
|
-
)
|
|
54477
|
-
|
|
54478
|
-
|
|
54530
|
+
);
|
|
54531
|
+
const waitMs = combinedDelayMs !== null && combinedDelayMs > 0 ? combinedDelayMs : 6e4;
|
|
54532
|
+
const allOverSoftQuota = accountManager.areAllAccountsOverSoftQuota(
|
|
54533
|
+
family,
|
|
54534
|
+
threshold,
|
|
54535
|
+
softQuotaCacheTtlMs,
|
|
54536
|
+
model,
|
|
54537
|
+
eligibleCandidateIndexes
|
|
54538
|
+
);
|
|
54539
|
+
const hasActiveCooldown = eligibleCandidates.some(
|
|
54540
|
+
(acc) => accountManager.isAccountCoolingDown(acc)
|
|
54541
|
+
);
|
|
54542
|
+
const applySoftQuota = eligibleCandidates.length > 1 && threshold < 100;
|
|
54543
|
+
const hasUnknownSoftReset = applySoftQuota && eligibleCandidates.some((acc) => {
|
|
54544
|
+
if (!accountManager.isAccountOverSoftQuota(
|
|
54545
|
+
acc,
|
|
54479
54546
|
family,
|
|
54480
54547
|
threshold,
|
|
54481
54548
|
softQuotaCacheTtlMs,
|
|
54482
54549
|
model,
|
|
54483
|
-
|
|
54484
|
-
)
|
|
54550
|
+
excludedIndexes
|
|
54551
|
+
)) {
|
|
54552
|
+
return false;
|
|
54553
|
+
}
|
|
54554
|
+
if (!model && family !== "claude") return true;
|
|
54555
|
+
const quotaGroup = resolveQuotaGroup(family, model, acc.cachedQuota);
|
|
54556
|
+
const groupData = acc.cachedQuota?.[quotaGroup];
|
|
54557
|
+
if (!groupData?.resetTime) return true;
|
|
54558
|
+
const ts = Date.parse(groupData.resetTime);
|
|
54559
|
+
return !Number.isFinite(ts) || ts <= Date.now();
|
|
54560
|
+
});
|
|
54561
|
+
const resetDeadline = !hasActiveCooldown && !hasUnknownSoftReset && combinedDelayMs !== null && combinedDelayMs > 0 ? Date.now() + combinedDelayMs : void 0;
|
|
54562
|
+
const remainingResetAfterMs = () => resetDeadline ? Math.max(0, resetDeadline - Date.now()) : void 0;
|
|
54563
|
+
if (allOverSoftQuota) {
|
|
54485
54564
|
waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
|
|
54486
54565
|
status: 412,
|
|
54487
54566
|
reason: "soft_quota",
|
|
54488
|
-
resetAfterMs:
|
|
54567
|
+
resetAfterMs: remainingResetAfterMs()
|
|
54489
54568
|
}) : void 0;
|
|
54490
|
-
if (
|
|
54491
|
-
const
|
|
54569
|
+
if (combinedDelayMs === null || remainingWaitMs() <= 0 || maxWaitMs > 0 && waitMs > maxWaitMs) {
|
|
54570
|
+
const resetAfterMs = remainingResetAfterMs();
|
|
54571
|
+
const waitTimeFormatted = resetAfterMs !== void 0 && resetAfterMs > 0 ? formatWaitTime(resetAfterMs) : "unknown";
|
|
54492
54572
|
await showToast(
|
|
54493
54573
|
`All accounts over ${threshold}% quota threshold. Resets in ${waitTimeFormatted}.`,
|
|
54494
54574
|
"error"
|
|
@@ -54496,33 +54576,26 @@ function createRequestExecutor(deps) {
|
|
|
54496
54576
|
return createNativeGoogleErrorResponse({
|
|
54497
54577
|
status: 412,
|
|
54498
54578
|
reason: "soft_quota",
|
|
54499
|
-
resetAfterMs:
|
|
54579
|
+
resetAfterMs: remainingResetAfterMs()
|
|
54500
54580
|
});
|
|
54501
54581
|
}
|
|
54502
54582
|
pushDebug(
|
|
54503
|
-
`all-over-soft-quota family=${family} accounts=${accountCount} waitMs=${
|
|
54583
|
+
`all-over-soft-quota family=${family} accounts=${accountCount} waitMs=${waitMs}`
|
|
54504
54584
|
);
|
|
54505
54585
|
if (!retryState.softQuotaToastShown()) {
|
|
54506
54586
|
await showToast(
|
|
54507
|
-
`All ${accountCount} account(s) over ${threshold}% quota. Waiting ${formatWaitTime(
|
|
54587
|
+
`All ${accountCount} account(s) over ${threshold}% quota. Waiting ${formatWaitTime(waitMs)}...`,
|
|
54508
54588
|
"warning"
|
|
54509
54589
|
);
|
|
54510
54590
|
retryState.markSoftQuotaToastShown();
|
|
54511
54591
|
}
|
|
54512
|
-
await sleep4(Math.min(
|
|
54592
|
+
await sleep4(Math.min(waitMs, remainingWaitMs()), abortSignal);
|
|
54513
54593
|
continue;
|
|
54514
54594
|
}
|
|
54515
|
-
const minWaitMs = accountManager.getMinWaitTimeForFamily(
|
|
54516
|
-
family,
|
|
54517
|
-
model,
|
|
54518
|
-
eligibleCandidateIndexes,
|
|
54519
|
-
true
|
|
54520
|
-
);
|
|
54521
|
-
const waitMs = minWaitMs || 6e4;
|
|
54522
54595
|
waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
|
|
54523
54596
|
status: 412,
|
|
54524
54597
|
reason: "pool_unavailable",
|
|
54525
|
-
resetAfterMs:
|
|
54598
|
+
resetAfterMs: remainingResetAfterMs()
|
|
54526
54599
|
}) : void 0;
|
|
54527
54600
|
pushDebug(
|
|
54528
54601
|
`all-rate-limited family=${family} accounts=${accountCount} waitMs=${waitMs}`
|
|
@@ -54547,9 +54620,8 @@ function createRequestExecutor(deps) {
|
|
|
54547
54620
|
return createNativeGoogleErrorResponse({
|
|
54548
54621
|
status: 412,
|
|
54549
54622
|
reason: "pool_unavailable",
|
|
54550
|
-
//
|
|
54551
|
-
|
|
54552
|
-
resetAfterMs: minWaitMs > 0 ? minWaitMs : void 0
|
|
54623
|
+
// Fallback sleep duration gets NO reset metadata.
|
|
54624
|
+
resetAfterMs: remainingResetAfterMs()
|
|
54553
54625
|
});
|
|
54554
54626
|
}
|
|
54555
54627
|
if (!retryState.rateLimitToastShown()) {
|