@cortexkit/opencode-antigravity-auth 3.0.28 → 3.0.29
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 +2 -2
- package/dist/cli.meta.json +2 -2
- package/dist/index.js +110 -8
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +16 -6
- package/dist/server.js +121 -19
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/plugin/shared/request-services.d.ts +14 -18
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +127 -7
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts +14 -18
- 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": 62829,
|
|
175
175
|
"imports": [
|
|
176
176
|
{
|
|
177
177
|
"path": "../core/dist/fingerprint.js",
|
|
@@ -4355,7 +4355,7 @@
|
|
|
4355
4355
|
"imports": [],
|
|
4356
4356
|
"exports": [],
|
|
4357
4357
|
"inputs": {},
|
|
4358
|
-
"bytes":
|
|
4358
|
+
"bytes": 3184742
|
|
4359
4359
|
},
|
|
4360
4360
|
"dist/cli.js": {
|
|
4361
4361
|
"imports": [
|
package/dist/index.js
CHANGED
|
@@ -6632,6 +6632,15 @@ function resolveQuotaGroup(family, model, cachedQuota) {
|
|
|
6632
6632
|
}
|
|
6633
6633
|
return family === "claude" ? "non-gemini" : "gemini";
|
|
6634
6634
|
}
|
|
6635
|
+
function reportsArgon(account) {
|
|
6636
|
+
return account.cachedQuotaUpdatedAt !== void 0 && account.cachedQuota?.["gemini-argon"] !== void 0;
|
|
6637
|
+
}
|
|
6638
|
+
function preferArgonAccounts(accounts, model) {
|
|
6639
|
+
if (!model || getQuotaGroupForModel(model, true) !== "gemini-argon")
|
|
6640
|
+
return accounts;
|
|
6641
|
+
const reporting = accounts.filter(reportsArgon);
|
|
6642
|
+
return reporting.length > 0 ? reporting : accounts;
|
|
6643
|
+
}
|
|
6635
6644
|
function isOverSoftQuotaThreshold(account, family, thresholdPercent, cacheTtlMs, now, model) {
|
|
6636
6645
|
if (thresholdPercent >= 100)
|
|
6637
6646
|
return false;
|
|
@@ -7106,7 +7115,10 @@ var init_account_selector = __esm({
|
|
|
7106
7115
|
};
|
|
7107
7116
|
});
|
|
7108
7117
|
const currentIndex = this.getActiveIndex(family, identity3);
|
|
7109
|
-
const
|
|
7118
|
+
const preferred2 = preferArgonAccounts(eligibleAccounts, model);
|
|
7119
|
+
const preferredIndexes = new Set(preferred2.map((row) => row.index));
|
|
7120
|
+
const select4 = (candidates) => selectHybridAccount(candidates, tokenTracker, currentIndex, 50, this.now);
|
|
7121
|
+
const selectedIndex = select4(accountsWithMetrics.filter((row) => preferredIndexes.has(row.index))) ?? select4(accountsWithMetrics);
|
|
7110
7122
|
if (selectedIndex !== null) {
|
|
7111
7123
|
const selected = this.accounts[selectedIndex];
|
|
7112
7124
|
if (selected) {
|
|
@@ -7134,7 +7146,8 @@ var init_account_selector = __esm({
|
|
|
7134
7146
|
offsetApplied[family] = true;
|
|
7135
7147
|
}
|
|
7136
7148
|
const current = this.getCurrentAccountForFamily(family, identity3);
|
|
7137
|
-
|
|
7149
|
+
const preferred = preferArgonAccounts(this.accounts.filter((row) => row.enabled !== false && !row.accountIneligible && !row.verificationRequired && !excludeIndexes?.has(row.index) && !isRateLimitedForFamily(row, family, this.now, model) && !this.isAccountCoolingDown(row) && !isOverSoftQuotaThreshold(row, family, effectiveSoftQuotaThreshold, softQuotaCacheTtlMs, this.now, model)), model);
|
|
7150
|
+
if (current && preferred.includes(current)) {
|
|
7138
7151
|
clearExpiredRateLimits(current, this.now);
|
|
7139
7152
|
const isLimitedForRequestedStyle = isRateLimitedForFamily(current, family, this.now, model);
|
|
7140
7153
|
const isOverThreshold = isOverSoftQuotaThreshold(current, family, effectiveSoftQuotaThreshold, softQuotaCacheTtlMs, this.now, model);
|
|
@@ -7156,7 +7169,7 @@ var init_account_selector = __esm({
|
|
|
7156
7169
|
clearExpiredRateLimits(account2, this.now);
|
|
7157
7170
|
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);
|
|
7158
7171
|
});
|
|
7159
|
-
const available = this.preferAccountOutsideParent(allAvailable, family, identity3);
|
|
7172
|
+
const available = this.preferAccountOutsideParent(preferArgonAccounts(allAvailable, model), family, identity3);
|
|
7160
7173
|
if (available.length === 0) {
|
|
7161
7174
|
return null;
|
|
7162
7175
|
}
|
|
@@ -34032,7 +34045,7 @@ var init_logger4 = __esm({
|
|
|
34032
34045
|
|
|
34033
34046
|
// src/plugin/index.ts
|
|
34034
34047
|
init_dist();
|
|
34035
|
-
import { createHash as
|
|
34048
|
+
import { createHash as createHash24, randomUUID as randomUUID21 } from "node:crypto";
|
|
34036
34049
|
import { join as join39, resolve as resolve26 } from "node:path";
|
|
34037
34050
|
|
|
34038
34051
|
// src/cli.ts
|
|
@@ -53774,6 +53787,7 @@ init_logger4();
|
|
|
53774
53787
|
|
|
53775
53788
|
// src/plugin/shared/request-services.ts
|
|
53776
53789
|
init_dist();
|
|
53790
|
+
import { createHash as createHash23 } from "node:crypto";
|
|
53777
53791
|
|
|
53778
53792
|
// src/common-auth-embedded/routing-accessor/index.js
|
|
53779
53793
|
function isObject2(value) {
|
|
@@ -54593,6 +54607,7 @@ function isPrimaryVaultRequest(kind, headers) {
|
|
|
54593
54607
|
|
|
54594
54608
|
// src/plugin/shared/request-services.ts
|
|
54595
54609
|
var FIRST_RETRY_DELAY_MS = 1e3;
|
|
54610
|
+
var MODEL_UNAVAILABLE_TTL_MS = 60 * 60 * 1e3;
|
|
54596
54611
|
function prepareAgyWireRequest(wire, request) {
|
|
54597
54612
|
return wire.prepare(
|
|
54598
54613
|
request.input,
|
|
@@ -54752,6 +54767,84 @@ function createRequestExecutor(deps) {
|
|
|
54752
54767
|
} = deps;
|
|
54753
54768
|
const retryState = createRetryState();
|
|
54754
54769
|
const warmupState = createWarmupState();
|
|
54770
|
+
const modelAvailabilityNow = deps.modelAvailabilityNow ?? Date.now;
|
|
54771
|
+
const unavailableModels = /* @__PURE__ */ new Map();
|
|
54772
|
+
const accountKey = (account) => {
|
|
54773
|
+
if (credentials.domain === "vault") {
|
|
54774
|
+
const route = account.route;
|
|
54775
|
+
return route ? JSON.stringify([
|
|
54776
|
+
"vault",
|
|
54777
|
+
route.routeId,
|
|
54778
|
+
route.credentialId,
|
|
54779
|
+
route.accountIdentity
|
|
54780
|
+
]) : account;
|
|
54781
|
+
}
|
|
54782
|
+
if (account.ref) {
|
|
54783
|
+
const ref = account.ref;
|
|
54784
|
+
return JSON.stringify([
|
|
54785
|
+
"local",
|
|
54786
|
+
ref.id,
|
|
54787
|
+
ref.credentialEpoch,
|
|
54788
|
+
ref.identity
|
|
54789
|
+
]);
|
|
54790
|
+
}
|
|
54791
|
+
const refresh = credentials.toAuthDetails(account).refresh;
|
|
54792
|
+
return JSON.stringify([
|
|
54793
|
+
"pool-file",
|
|
54794
|
+
account.email?.toLowerCase(),
|
|
54795
|
+
createHash23("sha256").update(parseRefreshParts(refresh).refreshToken).digest("hex")
|
|
54796
|
+
]);
|
|
54797
|
+
};
|
|
54798
|
+
const tierOf = (account) => JSON.stringify([account.capturedTierId, account.capturedPaidTierId]);
|
|
54799
|
+
const dropModel = (key, model, cause) => {
|
|
54800
|
+
const entries = unavailableModels.get(key);
|
|
54801
|
+
const entry = entries?.get(model);
|
|
54802
|
+
if (!entries || !entry) return;
|
|
54803
|
+
log17.debug("model-unavailable-memory-drop", {
|
|
54804
|
+
account: entry.label,
|
|
54805
|
+
model,
|
|
54806
|
+
cause
|
|
54807
|
+
});
|
|
54808
|
+
entries.delete(model);
|
|
54809
|
+
if (entries.size === 0) unavailableModels.delete(key);
|
|
54810
|
+
};
|
|
54811
|
+
const rememberedIndexes = (model) => {
|
|
54812
|
+
const rows = accountManager.getAccounts();
|
|
54813
|
+
const live = new Map(rows.map((row) => [accountKey(row), row]));
|
|
54814
|
+
const indexes = /* @__PURE__ */ new Set();
|
|
54815
|
+
for (const [key, entries] of unavailableModels) {
|
|
54816
|
+
const row = live.get(key);
|
|
54817
|
+
for (const [exactModel, entry] of entries) {
|
|
54818
|
+
const cause = !row ? "identity-replaced" : modelAvailabilityNow() - entry.recordedAt >= MODEL_UNAVAILABLE_TTL_MS ? "expired" : row.cachedQuotaUpdatedAt !== void 0 && row.cachedQuota?.["gemini-argon"] !== void 0 && (!entry.argonPool || row.cachedQuotaUpdatedAt !== entry.quotaUpdatedAt) ? "argon-pool" : row.cachedQuotaUpdatedAt !== void 0 && row.cachedQuotaUpdatedAt !== entry.quotaUpdatedAt ? "quota-reading" : tierOf(row) !== entry.tier ? "tier-changed" : void 0;
|
|
54819
|
+
if (cause) dropModel(key, exactModel, cause);
|
|
54820
|
+
else if (row && exactModel === model) indexes.add(row.index);
|
|
54821
|
+
}
|
|
54822
|
+
}
|
|
54823
|
+
return indexes;
|
|
54824
|
+
};
|
|
54825
|
+
const captureAvailability = (account) => ({
|
|
54826
|
+
key: accountKey(account),
|
|
54827
|
+
quotaUpdatedAt: account.cachedQuotaUpdatedAt,
|
|
54828
|
+
tier: tierOf(account),
|
|
54829
|
+
argonPool: account.cachedQuota?.["gemini-argon"] !== void 0,
|
|
54830
|
+
label: `Account ${account.index + 1}`
|
|
54831
|
+
});
|
|
54832
|
+
const rememberUnavailable = (snapshot2, model) => {
|
|
54833
|
+
const { key, ...entry } = snapshot2;
|
|
54834
|
+
let entries = unavailableModels.get(key);
|
|
54835
|
+
if (!entries) {
|
|
54836
|
+
entries = /* @__PURE__ */ new Map();
|
|
54837
|
+
unavailableModels.set(key, entries);
|
|
54838
|
+
}
|
|
54839
|
+
entries.set(model, {
|
|
54840
|
+
...entry,
|
|
54841
|
+
recordedAt: modelAvailabilityNow()
|
|
54842
|
+
});
|
|
54843
|
+
log17.debug("model-unavailable-memory-record", {
|
|
54844
|
+
account: entry.label,
|
|
54845
|
+
model
|
|
54846
|
+
});
|
|
54847
|
+
};
|
|
54755
54848
|
const shutdown = new AbortController();
|
|
54756
54849
|
const inFlight = /* @__PURE__ */ new Set();
|
|
54757
54850
|
const advisoryWork = /* @__PURE__ */ new Set();
|
|
@@ -55001,11 +55094,15 @@ function createRequestExecutor(deps) {
|
|
|
55001
55094
|
const killedIndexes = eligibleIndexes === null ? void 0 : new Set(
|
|
55002
55095
|
accountManager.getAccounts().map((entry) => entry.index).filter((index) => !eligibleIndexes.has(index))
|
|
55003
55096
|
);
|
|
55004
|
-
|
|
55097
|
+
const unavailableIndexes = /* @__PURE__ */ new Set([
|
|
55098
|
+
...modelUnavailableIndexes,
|
|
55099
|
+
...rememberedIndexes(model)
|
|
55100
|
+
]);
|
|
55101
|
+
if (unavailableIndexes.size > 0) {
|
|
55005
55102
|
const candidates = accountManager.getAccounts().filter(
|
|
55006
55103
|
(entry) => entry.enabled !== false && !entry.accountIneligible && !entry.verificationRequired && (eligibleIndexes === null || eligibleIndexes.has(entry.index))
|
|
55007
55104
|
);
|
|
55008
|
-
if (candidates.length > 0 && candidates.every((entry) =>
|
|
55105
|
+
if (candidates.length > 0 && candidates.every((entry) => unavailableIndexes.has(entry.index))) {
|
|
55009
55106
|
pushDebug(
|
|
55010
55107
|
`model-unavailable: all ${candidates.length} eligible account(s) skipped`
|
|
55011
55108
|
);
|
|
@@ -55020,7 +55117,7 @@ function createRequestExecutor(deps) {
|
|
|
55020
55117
|
});
|
|
55021
55118
|
}
|
|
55022
55119
|
}
|
|
55023
|
-
const excludedIndexes =
|
|
55120
|
+
const excludedIndexes = unavailableIndexes.size === 0 ? killedIndexes : /* @__PURE__ */ new Set([...killedIndexes ?? [], ...unavailableIndexes]);
|
|
55024
55121
|
const routingPresent = credentials.domain === "vault" && hasVaultRoutingAccessor();
|
|
55025
55122
|
const firstPlacement = routingPresent && !routingPlacementConsidered && accountSessionIdentity && !accountManager.getCurrentAccountForFamily(
|
|
55026
55123
|
family,
|
|
@@ -55611,6 +55708,7 @@ function createRequestExecutor(deps) {
|
|
|
55611
55708
|
let tokenConsumed = false;
|
|
55612
55709
|
let physicalAttemptStarted = false;
|
|
55613
55710
|
try {
|
|
55711
|
+
const availabilitySnapshot = captureAvailability(account);
|
|
55614
55712
|
let sendAdmission;
|
|
55615
55713
|
let sendAccessToken;
|
|
55616
55714
|
let sendProjectId;
|
|
@@ -56012,6 +56110,7 @@ function createRequestExecutor(deps) {
|
|
|
56012
56110
|
void response.body?.cancel().catch(() => {
|
|
56013
56111
|
});
|
|
56014
56112
|
modelUnavailableIndexes.add(account.index);
|
|
56113
|
+
if (model) rememberUnavailable(availabilitySnapshot, model);
|
|
56015
56114
|
skippedForModelUnavailable = true;
|
|
56016
56115
|
shouldSwitchAccount = true;
|
|
56017
56116
|
break;
|
|
@@ -56424,6 +56523,9 @@ function createRequestExecutor(deps) {
|
|
|
56424
56523
|
while (advisoryWork.size > 0) await Promise.allSettled([...advisoryWork]);
|
|
56425
56524
|
retryState.dispose();
|
|
56426
56525
|
warmupState.dispose();
|
|
56526
|
+
for (const [key, entries] of unavailableModels) {
|
|
56527
|
+
for (const model of entries.keys()) dropModel(key, model, "disposed");
|
|
56528
|
+
}
|
|
56427
56529
|
})();
|
|
56428
56530
|
return drainPromise;
|
|
56429
56531
|
}
|
|
@@ -57360,7 +57462,7 @@ init_storage();
|
|
|
57360
57462
|
init_vault_custody();
|
|
57361
57463
|
var logger2 = createLogger4("plugin");
|
|
57362
57464
|
function quotaAccountIdentity4(refreshToken) {
|
|
57363
|
-
return
|
|
57465
|
+
return createHash24("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
57364
57466
|
}
|
|
57365
57467
|
function registerQuotaManagerProducer(lifecycle, quotaManager) {
|
|
57366
57468
|
lifecycle.register({ dispose: () => quotaManager.dispose() }, "producer");
|