@expiren/opencode-antigravity-auth 1.6.42 → 1.6.44
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/index.js +77 -4
- package/dist/index.js.map +2 -2
- package/dist/src/plugin/accounts.d.ts +2 -0
- package/dist/src/plugin/accounts.d.ts.map +1 -1
- package/dist/src/plugin/accounts.js +50 -0
- package/dist/src/plugin/accounts.js.map +1 -1
- package/dist/src/plugin/config/schema.d.ts +1 -0
- package/dist/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/src/plugin/config/schema.js +15 -3
- package/dist/src/plugin/config/schema.js.map +1 -1
- package/dist/src/plugin.d.ts.map +1 -1
- package/dist/src/plugin.js +16 -3
- package/dist/src/plugin.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3500,9 +3500,21 @@ var AntigravityConfigSchema = z2.object({
|
|
|
3500
3500
|
z2.literal("auto"),
|
|
3501
3501
|
z2.number().min(1).max(120)
|
|
3502
3502
|
]).default("auto"),
|
|
3503
|
+
/**
|
|
3504
|
+
* Proactive rotation threshold percentage (0-100).
|
|
3505
|
+
* After a successful request, if the current account's remaining quota
|
|
3506
|
+
* drops below this percentage, proactively switch to a warm-cache account
|
|
3507
|
+
* before the next request — avoiding a forced 429 mid-conversation.
|
|
3508
|
+
*
|
|
3509
|
+
* Set to 0 to disable proactive rotation.
|
|
3510
|
+
*
|
|
3511
|
+
* @default 20
|
|
3512
|
+
* @env OPENCODE_ANTIGRAVITY_PROACTIVE_ROTATION_THRESHOLD
|
|
3513
|
+
*/
|
|
3514
|
+
proactive_rotation_threshold_percent: z2.number().min(0).max(100).default(20),
|
|
3503
3515
|
// =========================================================================
|
|
3504
3516
|
// Health Score (used by hybrid strategy)
|
|
3505
|
-
// =========================================================================
|
|
3517
|
+
// =========================================================================
|
|
3506
3518
|
health_score: z2.object({
|
|
3507
3519
|
initial: z2.number().min(0).max(100).default(70),
|
|
3508
3520
|
success_reward: z2.number().min(0).max(10).default(1),
|
|
@@ -3565,6 +3577,7 @@ var DEFAULT_CONFIG = {
|
|
|
3565
3577
|
soft_quota_threshold_percent: 90,
|
|
3566
3578
|
quota_refresh_interval_minutes: 30,
|
|
3567
3579
|
soft_quota_cache_ttl_minutes: "auto",
|
|
3580
|
+
proactive_rotation_threshold_percent: 20,
|
|
3568
3581
|
auto_update: true,
|
|
3569
3582
|
signature_cache: {
|
|
3570
3583
|
enabled: true,
|
|
@@ -9383,6 +9396,45 @@ var AccountManager = class _AccountManager {
|
|
|
9383
9396
|
wasUsedInSession(accountIndex) {
|
|
9384
9397
|
return this.sessionUsedAccounts.has(accountIndex);
|
|
9385
9398
|
}
|
|
9399
|
+
shouldProactivelyRotate(family, model, thresholdPercent, cacheTtlMs) {
|
|
9400
|
+
if (thresholdPercent <= 0) return false;
|
|
9401
|
+
const current = this.getCurrentAccountForFamily(family);
|
|
9402
|
+
if (!current || !current.cachedQuota || current.cachedQuotaUpdatedAt == null) return false;
|
|
9403
|
+
const age = nowMs() - current.cachedQuotaUpdatedAt;
|
|
9404
|
+
if (age > cacheTtlMs) return false;
|
|
9405
|
+
const quotaGroup = resolveQuotaGroup(family, model);
|
|
9406
|
+
const groupData = current.cachedQuota[quotaGroup];
|
|
9407
|
+
if (groupData?.remainingFraction == null) return false;
|
|
9408
|
+
const remainingPercent = Math.max(0, Math.min(100, groupData.remainingFraction * 100));
|
|
9409
|
+
return remainingPercent < thresholdPercent;
|
|
9410
|
+
}
|
|
9411
|
+
proactivelyRotateForFamily(family, model, headerStyle, softQuotaThresholdPercent, softQuotaCacheTtlMs) {
|
|
9412
|
+
const currentIndex = this.currentAccountIndexByFamily[family];
|
|
9413
|
+
const candidates = this.accounts.filter((acc) => {
|
|
9414
|
+
if (acc.enabled === false) return false;
|
|
9415
|
+
if (acc.index === currentIndex) return false;
|
|
9416
|
+
clearExpiredRateLimits(acc);
|
|
9417
|
+
if (isRateLimitedForHeaderStyle(acc, family, headerStyle, model)) return false;
|
|
9418
|
+
if (isOverSoftQuotaThreshold(acc, family, softQuotaThresholdPercent, softQuotaCacheTtlMs, model)) return false;
|
|
9419
|
+
if (this.isAccountCoolingDown(acc)) return false;
|
|
9420
|
+
return true;
|
|
9421
|
+
});
|
|
9422
|
+
if (candidates.length === 0) return null;
|
|
9423
|
+
const warmCandidates = candidates.filter((a) => this.sessionUsedAccounts.has(a.index));
|
|
9424
|
+
const pool = warmCandidates.length > 0 ? warmCandidates : candidates;
|
|
9425
|
+
const quotaGroup = resolveQuotaGroup(family, model);
|
|
9426
|
+
pool.sort((a, b) => {
|
|
9427
|
+
const aRemaining = a.cachedQuota?.[quotaGroup]?.remainingFraction ?? 0;
|
|
9428
|
+
const bRemaining = b.cachedQuota?.[quotaGroup]?.remainingFraction ?? 0;
|
|
9429
|
+
return bRemaining - aRemaining;
|
|
9430
|
+
});
|
|
9431
|
+
const selected = pool[0];
|
|
9432
|
+
if (!selected) return null;
|
|
9433
|
+
const quotaKey = getQuotaKey(family, headerStyle, model);
|
|
9434
|
+
this.markTouchedForQuota(selected, quotaKey);
|
|
9435
|
+
this.currentAccountIndexByFamily[family] = selected.index;
|
|
9436
|
+
return selected;
|
|
9437
|
+
}
|
|
9386
9438
|
markRateLimitedWithReason(account, family, headerStyle, model, reason, retryAfterMs, failureTtlMs = 36e5) {
|
|
9387
9439
|
const now = nowMs();
|
|
9388
9440
|
if (account.lastFailureTime !== void 0 && now - account.lastFailureTime > failureTtlMs) {
|
|
@@ -12684,12 +12736,12 @@ var createAntigravityPlugin = (providerId) => async ({ client, directory }) => {
|
|
|
12684
12736
|
const parsed = JSON.parse(bodyStr);
|
|
12685
12737
|
parsed.generationConfig = {
|
|
12686
12738
|
...parsed.generationConfig ?? {},
|
|
12687
|
-
maxOutputTokens: 1
|
|
12688
|
-
candidateCount: 1
|
|
12739
|
+
maxOutputTokens: 1
|
|
12689
12740
|
};
|
|
12741
|
+
delete parsed.generationConfig.candidateCount;
|
|
12690
12742
|
if (parsed.generationConfig.thinkingConfig) {
|
|
12691
12743
|
parsed.generationConfig.thinkingConfig = {
|
|
12692
|
-
thinkingBudget:
|
|
12744
|
+
thinkingBudget: 128
|
|
12693
12745
|
};
|
|
12694
12746
|
}
|
|
12695
12747
|
const probeHeaders = new Headers(prepared.init.headers ?? {});
|
|
@@ -13038,6 +13090,27 @@ var createAntigravityPlugin = (providerId) => async ({ client, directory }) => {
|
|
|
13038
13090
|
providerId,
|
|
13039
13091
|
config.quota_refresh_interval_minutes
|
|
13040
13092
|
);
|
|
13093
|
+
const proactiveThreshold = config.proactive_rotation_threshold_percent ?? 20;
|
|
13094
|
+
if (proactiveThreshold > 0 && accountManager.shouldProactivelyRotate(
|
|
13095
|
+
family,
|
|
13096
|
+
model,
|
|
13097
|
+
proactiveThreshold,
|
|
13098
|
+
softQuotaCacheTtlMs
|
|
13099
|
+
)) {
|
|
13100
|
+
const rotated = accountManager.proactivelyRotateForFamily(
|
|
13101
|
+
family,
|
|
13102
|
+
model,
|
|
13103
|
+
headerStyle,
|
|
13104
|
+
config.soft_quota_threshold_percent,
|
|
13105
|
+
softQuotaCacheTtlMs
|
|
13106
|
+
);
|
|
13107
|
+
if (rotated) {
|
|
13108
|
+
const remaining = account.cachedQuota?.[resolveQuotaGroup(family, model)]?.remainingFraction;
|
|
13109
|
+
const remainingPct = remaining != null ? `${(remaining * 100).toFixed(1)}%` : "?";
|
|
13110
|
+
pushDebug(`[ProactiveRotation] account ${account.index} quota ${remainingPct} < ${proactiveThreshold}%, pre-switched to account ${rotated.index} for next request`);
|
|
13111
|
+
pushDebug(`[ProactiveRotation] ${account.index} \u2192 ${rotated.index} (warm=${accountManager.wasUsedInSession(rotated.index)})`);
|
|
13112
|
+
}
|
|
13113
|
+
}
|
|
13041
13114
|
}
|
|
13042
13115
|
logAntigravityDebugResponse(debugContext, response, {
|
|
13043
13116
|
note: response.ok ? "Success" : `Error ${response.status}`
|