@cortexkit/opencode-antigravity-auth 3.1.10 → 3.1.11
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 +357 -58
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +37 -32
- package/dist/index.js +986 -426
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +86 -63
- package/dist/server.js +1131 -551
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/cli.d.ts +3 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +19 -6
- package/dist/src/cli.js.map +1 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +20 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.js +32 -0
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +39 -1
- package/dist/src/common-auth-embedded/claustrum/custody.js +145 -8
- package/dist/src/common-auth-embedded/claustrum/host.js +8 -0
- package/dist/src/common-auth-embedded/claustrum/hub.d.ts +3 -2
- package/dist/src/common-auth-embedded/claustrum/hub.js +10 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/routing-accessor/index.js +5 -3
- package/dist/src/common-auth-embedded/source-output.json +35 -35
- package/dist/src/ga/rpc/protocol.d.ts +11 -5
- package/dist/src/ga/rpc/protocol.d.ts.map +1 -1
- package/dist/src/ga/rpc/protocol.js +11 -3
- package/dist/src/ga/rpc/protocol.js.map +1 -1
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +30 -14
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/ga/tui/host-ga.d.ts +2 -1
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +9 -4
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/src/plugin/account-access.d.ts +1 -0
- package/dist/src/plugin/account-access.d.ts.map +1 -1
- package/dist/src/plugin/account-access.js +28 -0
- package/dist/src/plugin/account-access.js.map +1 -1
- package/dist/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/src/plugin/auth-loader.js +21 -12
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/background-quota-refresh.d.ts +11 -24
- package/dist/src/plugin/background-quota-refresh.d.ts.map +1 -1
- package/dist/src/plugin/background-quota-refresh.js +54 -60
- package/dist/src/plugin/background-quota-refresh.js.map +1 -1
- package/dist/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
- package/dist/src/plugin/background-vault-quota-refresh.js +6 -3
- package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
- package/dist/src/plugin/cache/signature-cache.d.ts +3 -0
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
- package/dist/src/plugin/cache/signature-cache.js +73 -46
- package/dist/src/plugin/cache/signature-cache.js.map +1 -1
- package/dist/src/plugin/cache.d.ts.map +1 -1
- package/dist/src/plugin/cache.js +17 -7
- package/dist/src/plugin/cache.js.map +1 -1
- package/dist/src/plugin/core/streaming/displayed-thinking.d.ts +23 -0
- package/dist/src/plugin/core/streaming/displayed-thinking.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/displayed-thinking.js +58 -0
- package/dist/src/plugin/core/streaming/displayed-thinking.js.map +1 -0
- package/dist/src/plugin/fetch/warmup.d.ts +9 -2
- package/dist/src/plugin/fetch/warmup.d.ts.map +1 -1
- package/dist/src/plugin/fetch/warmup.js +22 -14
- package/dist/src/plugin/fetch/warmup.js.map +1 -1
- package/dist/src/plugin/quota.d.ts +10 -2
- package/dist/src/plugin/quota.d.ts.map +1 -1
- package/dist/src/plugin/quota.js +38 -10
- package/dist/src/plugin/quota.js.map +1 -1
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +51 -19
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/plugin/request.d.ts +12 -1
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +27 -42
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/shared/request-services.d.ts +4 -1
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +142 -24
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/runtime.d.ts +3 -4
- package/dist/src/plugin/shared/runtime.d.ts.map +1 -1
- package/dist/src/plugin/shared/runtime.js +2 -2
- package/dist/src/plugin/shared/runtime.js.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.d.ts +13 -7
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.js +24 -18
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
- package/dist/src/plugin/vault-sidebar-projection.d.ts.map +1 -1
- package/dist/src/setup.d.ts +3 -0
- package/dist/src/setup.d.ts.map +1 -1
- package/dist/src/setup.js +18 -6
- package/dist/src/setup.js.map +1 -1
- package/dist/src/sidebar-state.d.ts +20 -7
- package/dist/src/sidebar-state.d.ts.map +1 -1
- package/dist/src/sidebar-state.js +57 -8
- package/dist/src/sidebar-state.js.map +1 -1
- package/dist/src/tui.d.ts.map +1 -1
- package/dist/src/tui.js +43 -23
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +9 -9
- package/dist/tui-ga-build-map.json +5 -5
- package/dist/types/src/cli.d.ts +3 -1
- package/dist/types/src/cli.d.ts.map +1 -1
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +20 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +39 -1
- package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +3 -2
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/types/src/ga/rpc/protocol.d.ts +11 -5
- package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -1
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/account-access.d.ts +1 -0
- package/dist/types/src/plugin/account-access.d.ts.map +1 -1
- package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/types/src/plugin/background-quota-refresh.d.ts +11 -24
- package/dist/types/src/plugin/background-quota-refresh.d.ts.map +1 -1
- package/dist/types/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
- package/dist/types/src/plugin/cache/signature-cache.d.ts +3 -0
- package/dist/types/src/plugin/cache/signature-cache.d.ts.map +1 -1
- package/dist/types/src/plugin/cache.d.ts.map +1 -1
- package/dist/types/src/plugin/core/streaming/displayed-thinking.d.ts +23 -0
- package/dist/types/src/plugin/core/streaming/displayed-thinking.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch/warmup.d.ts +9 -2
- package/dist/types/src/plugin/fetch/warmup.d.ts.map +1 -1
- package/dist/types/src/plugin/quota.d.ts +10 -2
- package/dist/types/src/plugin/quota.d.ts.map +1 -1
- package/dist/types/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts +12 -1
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts +4 -1
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/runtime.d.ts +3 -4
- package/dist/types/src/plugin/shared/runtime.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +13 -7
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-sidebar-projection.d.ts.map +1 -1
- package/dist/types/src/setup.d.ts +3 -0
- package/dist/types/src/setup.d.ts.map +1 -1
- package/dist/types/src/sidebar-state.d.ts +20 -7
- package/dist/types/src/sidebar-state.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common-auth-embedded/claustrum/consumer.d.ts +20 -1
- package/src/common-auth-embedded/claustrum/consumer.js +32 -0
- package/src/common-auth-embedded/claustrum/custody.d.ts +39 -1
- package/src/common-auth-embedded/claustrum/custody.js +145 -8
- package/src/common-auth-embedded/claustrum/host.js +8 -0
- package/src/common-auth-embedded/claustrum/hub.d.ts +3 -2
- package/src/common-auth-embedded/claustrum/hub.js +10 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/src/common-auth-embedded/routing-accessor/index.js +5 -3
- package/src/common-auth-embedded/source-output.json +35 -35
- package/src/sidebar-state.ts +77 -8
- package/src/tui-compiled/sidebar-state.js +40 -1
- package/src/tui-compiled/tui.js +49 -24
- package/src/tui-ga-compiled/host-ga.js +11 -5
- package/src/tui-ga-raw/host-ga.tsx +17 -6
- package/src/tui-raw/sidebar-state.js +40 -1
- package/src/tui-raw/tui.tsx +40 -24
- package/src/tui.tsx +40 -24
package/dist/server.js
CHANGED
|
@@ -385,6 +385,11 @@ function mergeQuotaState(stored, observation) {
|
|
|
385
385
|
if (stored === void 0)
|
|
386
386
|
return incoming;
|
|
387
387
|
const prior = encodeQuotaState(decodeQuotaState(stored));
|
|
388
|
+
const previousAt = prior.cachedQuotaUpdatedAt;
|
|
389
|
+
const observedAt = incoming.cachedQuotaUpdatedAt;
|
|
390
|
+
if (typeof previousAt === "number" && typeof observedAt === "number" && observedAt < previousAt) {
|
|
391
|
+
throw new StaleQuotaObservationError();
|
|
392
|
+
}
|
|
388
393
|
return encodeQuotaState(decodeQuotaState({ ...prior, ...incoming }));
|
|
389
394
|
}
|
|
390
395
|
function decodeRoutingSettings(raw) {
|
|
@@ -420,7 +425,7 @@ function createProviderStateCodec(policy) {
|
|
|
420
425
|
}
|
|
421
426
|
};
|
|
422
427
|
}
|
|
423
|
-
var AccountCodecError, MAX_JSON_DEPTH, IDENTIFIER, jsonValue, string, nonEmptyString, finiteNumber, count, credentialEpoch, boolean, rowId, required, optional, EXTENSIONS, CREDENTIAL_REFUSAL, CREDENTIAL_KEYS, POOL_FIELD_REFUSAL, QUOTA_FIELD_REFUSAL, LEGACY_FIELD_REFUSAL, METADATA_FIELD_REFUSAL, clientMetadataCodec, fingerprintCodec, fingerprintVersionCodec, dailyRequestCountsCodec, metadataShape, quotaShape, metadataForbidden, quotaForbidden, metadataCodec, providerStateCodec, quotaCodec, rowRefCodec, routingCodec, QUOTA_CODEC;
|
|
428
|
+
var AccountCodecError, MAX_JSON_DEPTH, IDENTIFIER, jsonValue, string, nonEmptyString, finiteNumber, count, credentialEpoch, boolean, rowId, required, optional, EXTENSIONS, CREDENTIAL_REFUSAL, CREDENTIAL_KEYS, POOL_FIELD_REFUSAL, QUOTA_FIELD_REFUSAL, LEGACY_FIELD_REFUSAL, METADATA_FIELD_REFUSAL, clientMetadataCodec, fingerprintCodec, fingerprintVersionCodec, dailyRequestCountsCodec, metadataShape, quotaShape, metadataForbidden, quotaForbidden, metadataCodec, providerStateCodec, quotaCodec, rowRefCodec, routingCodec, StaleQuotaObservationError, QUOTA_CODEC;
|
|
424
429
|
var init_account_repository_codecs = __esm({
|
|
425
430
|
"../core/dist/account-repository-codecs.js"() {
|
|
426
431
|
"use strict";
|
|
@@ -590,6 +595,11 @@ var init_account_repository_codecs = __esm({
|
|
|
590
595
|
gemini: optional(nullable(rowRefCodec))
|
|
591
596
|
})))
|
|
592
597
|
}, { forbidden: CREDENTIAL_KEYS });
|
|
598
|
+
StaleQuotaObservationError = class extends Error {
|
|
599
|
+
constructor() {
|
|
600
|
+
super("A newer quota observation is already stored");
|
|
601
|
+
}
|
|
602
|
+
};
|
|
593
603
|
QUOTA_CODEC = {
|
|
594
604
|
validate: isValidQuotaState,
|
|
595
605
|
merge: mergeQuotaState
|
|
@@ -5058,9 +5068,7 @@ function reconcileRateLimitsFromReading(account, reading, now2) {
|
|
|
5058
5068
|
function quotaRetryAfter(account, family, model, reason, retryAfterMs, now2) {
|
|
5059
5069
|
if (reason !== "QUOTA_EXHAUSTED" || !(retryAfterMs && retryAfterMs > MAX_QUOTA_EXHAUSTED_BACKOFF_MS))
|
|
5060
5070
|
return retryAfterMs;
|
|
5061
|
-
|
|
5062
|
-
const group = resolveQuotaGroup(family, model, account.cachedQuota);
|
|
5063
|
-
return at !== void 0 && Number.isFinite(at) && at > 0 && at <= now2 && account.cachedQuota?.[group]?.remainingFraction === 0 ? retryAfterMs : void 0;
|
|
5071
|
+
return quotaExhaustedUntil(account, family, model, now2) > now2 ? retryAfterMs : void 0;
|
|
5064
5072
|
}
|
|
5065
5073
|
function quotaExhaustedUntil(account, family, model, now2) {
|
|
5066
5074
|
const at = account.cachedQuotaUpdatedAt;
|
|
@@ -7685,11 +7693,21 @@ var init_account_repository = __esm({
|
|
|
7685
7693
|
rowId: ref.id
|
|
7686
7694
|
});
|
|
7687
7695
|
}
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7696
|
+
try {
|
|
7697
|
+
await this.store.recordQuota(ref.id, credentialFenceOf(ref), encoded);
|
|
7698
|
+
} catch (error) {
|
|
7699
|
+
if (error instanceof StaleQuotaObservationError || error instanceof this.storeFailure && error.cause instanceof StaleQuotaObservationError)
|
|
7700
|
+
return;
|
|
7701
|
+
throw error;
|
|
7702
|
+
}
|
|
7703
|
+
await this.updateMetadata(ref, (metadata, row) => {
|
|
7704
|
+
if (!metadata || observation.cachedQuotaUpdatedAt == null || row.quota.status !== "present" || row.quota.quota.cachedQuotaUpdatedAt !== observation.cachedQuotaUpdatedAt)
|
|
7705
|
+
return { kind: "keep" };
|
|
7706
|
+
return {
|
|
7707
|
+
kind: "set",
|
|
7708
|
+
metadata: applyRateLimitReadingUpdate(metadata, rateLimitReadingUpdateOf(observation), this.now())
|
|
7709
|
+
};
|
|
7710
|
+
});
|
|
7693
7711
|
});
|
|
7694
7712
|
}
|
|
7695
7713
|
// ---- selection and roster ---------------------------------------------
|
|
@@ -8304,7 +8322,7 @@ async function rmEvictingDir(evictingPath) {
|
|
|
8304
8322
|
});
|
|
8305
8323
|
}
|
|
8306
8324
|
async function sleep(ms) {
|
|
8307
|
-
await new Promise((
|
|
8325
|
+
await new Promise((resolve35) => setTimeout(resolve35, ms));
|
|
8308
8326
|
}
|
|
8309
8327
|
async function acquireFencedFileLock(options) {
|
|
8310
8328
|
const lockPath = `${options.path}.${options.name}.lock`;
|
|
@@ -8420,8 +8438,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now2) {
|
|
|
8420
8438
|
let released = false;
|
|
8421
8439
|
let lost = false;
|
|
8422
8440
|
let lostResolve = null;
|
|
8423
|
-
let lostPromise = new Promise((
|
|
8424
|
-
lostResolve =
|
|
8441
|
+
let lostPromise = new Promise((resolve35) => {
|
|
8442
|
+
lostResolve = resolve35;
|
|
8425
8443
|
});
|
|
8426
8444
|
const markLost = () => {
|
|
8427
8445
|
if (lost)
|
|
@@ -8431,9 +8449,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now2) {
|
|
|
8431
8449
|
clearInterval(renewTimer);
|
|
8432
8450
|
renewTimer = null;
|
|
8433
8451
|
}
|
|
8434
|
-
const
|
|
8452
|
+
const resolve35 = lostResolve;
|
|
8435
8453
|
lostResolve = null;
|
|
8436
|
-
|
|
8454
|
+
resolve35?.();
|
|
8437
8455
|
};
|
|
8438
8456
|
const setupRenew = () => {
|
|
8439
8457
|
if (options.renew === false)
|
|
@@ -9056,7 +9074,7 @@ async function saveAccountStorageReplace(path5, incoming) {
|
|
|
9056
9074
|
return mutateAccountStorage(path5, () => incoming);
|
|
9057
9075
|
}
|
|
9058
9076
|
async function clearAccountStorage(path5) {
|
|
9059
|
-
const sleep5 = (ms) => new Promise((
|
|
9077
|
+
const sleep5 = (ms) => new Promise((resolve35) => setTimeout(resolve35, ms));
|
|
9060
9078
|
const lock = await acquireWithRetry(path5, sleep5);
|
|
9061
9079
|
try {
|
|
9062
9080
|
await assertLegacyAccountStorageWritable(path5);
|
|
@@ -9104,7 +9122,7 @@ var init_account_storage = __esm({
|
|
|
9104
9122
|
}
|
|
9105
9123
|
};
|
|
9106
9124
|
RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
|
|
9107
|
-
DEFAULT_SLEEP = (ms) => new Promise((
|
|
9125
|
+
DEFAULT_SLEEP = (ms) => new Promise((resolve35) => setTimeout(resolve35, ms));
|
|
9108
9126
|
DEFAULT_BUILD_BACKUP_PATH = (path5, now2) => `${path5}.corrupt-${now2.toISOString().replace(/[:.]/g, "-")}`;
|
|
9109
9127
|
}
|
|
9110
9128
|
});
|
|
@@ -9202,7 +9220,7 @@ function isStorageLockContention(error) {
|
|
|
9202
9220
|
function quotaAccountIdentity(refreshToken) {
|
|
9203
9221
|
return createHash3("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
9204
9222
|
}
|
|
9205
|
-
function applyPendingRowWrite(metadata, pending, now2) {
|
|
9223
|
+
function applyPendingRowWrite(metadata, pending, now2, storedReadingAt) {
|
|
9206
9224
|
let next = metadata;
|
|
9207
9225
|
const resets = {};
|
|
9208
9226
|
const cleared = [];
|
|
@@ -9224,7 +9242,7 @@ function applyPendingRowWrite(metadata, pending, now2) {
|
|
|
9224
9242
|
delete written[key2];
|
|
9225
9243
|
next = { ...next, rateLimitResetTimes: rates, rateLimitWrittenAt: written };
|
|
9226
9244
|
}
|
|
9227
|
-
if (pending.readingUpdate)
|
|
9245
|
+
if (storedReadingAt != null && pending.readingUpdate?.checkedAt === storedReadingAt)
|
|
9228
9246
|
next = applyRateLimitReadingUpdate(next, pending.readingUpdate, now2);
|
|
9229
9247
|
if (pending.cooldown !== void 0) {
|
|
9230
9248
|
next = applyCooldownObservation(next, pending.cooldown.value);
|
|
@@ -9979,7 +9997,7 @@ var init_account_manager = __esm({
|
|
|
9979
9997
|
for (const pending of rows) {
|
|
9980
9998
|
repository.updateMetadata(pending.ref, (current, row) => ({
|
|
9981
9999
|
kind: "set",
|
|
9982
|
-
metadata: applyPendingRowWrite(current ?? { addedAt: row.storeAddedAt ?? this.now(), lastUsed: 0 }, pending, this.now())
|
|
10000
|
+
metadata: applyPendingRowWrite(current ?? { addedAt: row.storeAddedAt ?? this.now(), lastUsed: 0 }, pending, this.now(), row.quota.status === "present" ? row.quota.quota.cachedQuotaUpdatedAt : void 0)
|
|
9983
10001
|
})).catch((error) => {
|
|
9984
10002
|
if (error instanceof AccountRepositoryError && error.failure.kind === "lock-contention" && !error.failure.ambiguous) {
|
|
9985
10003
|
this.requeueRowWrite(pending);
|
|
@@ -10358,8 +10376,8 @@ var init_account_manager = __esm({
|
|
|
10358
10376
|
await this.saveInFlight;
|
|
10359
10377
|
return;
|
|
10360
10378
|
}
|
|
10361
|
-
return new Promise((
|
|
10362
|
-
this.savePromiseResolvers.push({ resolve:
|
|
10379
|
+
return new Promise((resolve35, reject) => {
|
|
10380
|
+
this.savePromiseResolvers.push({ resolve: resolve35, reject });
|
|
10363
10381
|
});
|
|
10364
10382
|
}
|
|
10365
10383
|
async dispose() {
|
|
@@ -10402,8 +10420,8 @@ var init_account_manager = __esm({
|
|
|
10402
10420
|
reject(error);
|
|
10403
10421
|
throw error;
|
|
10404
10422
|
}
|
|
10405
|
-
for (const { resolve:
|
|
10406
|
-
|
|
10423
|
+
for (const { resolve: resolve35 } of resolvers)
|
|
10424
|
+
resolve35();
|
|
10407
10425
|
}
|
|
10408
10426
|
async executeSave() {
|
|
10409
10427
|
this.savePending = false;
|
|
@@ -10417,16 +10435,16 @@ var init_account_manager = __esm({
|
|
|
10417
10435
|
}
|
|
10418
10436
|
try {
|
|
10419
10437
|
await this.saveToDisk();
|
|
10420
|
-
for (const { resolve:
|
|
10421
|
-
|
|
10438
|
+
for (const { resolve: resolve35 } of resolvers) {
|
|
10439
|
+
resolve35();
|
|
10422
10440
|
}
|
|
10423
10441
|
} catch (error) {
|
|
10424
10442
|
if (isStorageLockContention(error)) {
|
|
10425
10443
|
this.onDiagnostic?.("Skipped account-state persist due to storage lock contention", {
|
|
10426
10444
|
error: String(error)
|
|
10427
10445
|
});
|
|
10428
|
-
for (const { resolve:
|
|
10429
|
-
|
|
10446
|
+
for (const { resolve: resolve35 } of resolvers) {
|
|
10447
|
+
resolve35();
|
|
10430
10448
|
}
|
|
10431
10449
|
return;
|
|
10432
10450
|
}
|
|
@@ -10464,13 +10482,13 @@ var init_account_manager = __esm({
|
|
|
10464
10482
|
getAccountFingerprintHistory(accountIndex) {
|
|
10465
10483
|
return this.selection.getAccountFingerprintHistory(accountIndex);
|
|
10466
10484
|
}
|
|
10467
|
-
updateQuotaCache(accountIndex, quotaGroups, expectedRefreshToken) {
|
|
10485
|
+
updateQuotaCache(accountIndex, quotaGroups, expectedRefreshToken, checkedAt = this.now()) {
|
|
10468
10486
|
const account = this.accounts[accountIndex];
|
|
10469
|
-
if (!account || account.parts.refreshToken !== expectedRefreshToken && expectedRefreshToken !== void 0)
|
|
10470
|
-
return;
|
|
10487
|
+
if (!account || account.parts.refreshToken !== expectedRefreshToken && expectedRefreshToken !== void 0 || !Number.isFinite(checkedAt) || account.cachedQuotaUpdatedAt !== void 0 && checkedAt < account.cachedQuotaUpdatedAt)
|
|
10488
|
+
return false;
|
|
10471
10489
|
account.cachedQuota = quotaGroups;
|
|
10472
10490
|
account.cachedQuotaAccountId = quotaAccountIdentity(account.parts.refreshToken);
|
|
10473
|
-
account.cachedQuotaUpdatedAt =
|
|
10491
|
+
account.cachedQuotaUpdatedAt = checkedAt;
|
|
10474
10492
|
this.selection.reconcileQuotaReading(account, this.repository === void 0);
|
|
10475
10493
|
const pending = account.ref ? this.pendingRowWrites.get(rowRefKey(account.ref)) : void 0;
|
|
10476
10494
|
if (pending)
|
|
@@ -10486,6 +10504,7 @@ var init_account_manager = __esm({
|
|
|
10486
10504
|
cachedQuotaUpdatedAt: account.cachedQuotaUpdatedAt
|
|
10487
10505
|
};
|
|
10488
10506
|
this.dispatch(account, "quota reading", (repository, ref) => repository.recordQuota(ref, reading));
|
|
10507
|
+
return true;
|
|
10489
10508
|
}
|
|
10490
10509
|
/**
|
|
10491
10510
|
* Apply a subset of fields from a quota-fetch `updatedAccount` result onto
|
|
@@ -10610,6 +10629,35 @@ var init_account_manager = __esm({
|
|
|
10610
10629
|
}
|
|
10611
10630
|
return targets;
|
|
10612
10631
|
}
|
|
10632
|
+
/** Fresh durable observations for poll admission, without flushing local writes. */
|
|
10633
|
+
async readAccountsForQuotaPoll() {
|
|
10634
|
+
if (!this.repository) {
|
|
10635
|
+
const accounts = new Map(this.accounts.map((a) => [a.parts.refreshToken, a]));
|
|
10636
|
+
return this.getAccountsForQuotaCheck().map((target) => {
|
|
10637
|
+
const account = accounts.get(target.refreshToken);
|
|
10638
|
+
return {
|
|
10639
|
+
...target,
|
|
10640
|
+
cachedQuotaUpdatedAt: account?.cachedQuota && account.cachedQuotaUpdatedAt
|
|
10641
|
+
};
|
|
10642
|
+
});
|
|
10643
|
+
}
|
|
10644
|
+
const read = await this.repository.read();
|
|
10645
|
+
if (read.status !== "ready")
|
|
10646
|
+
throw new Error("The account store is not ready for quota polling");
|
|
10647
|
+
const rows = new Map(read.rows.filter((row) => row.usable && row.enabled).map((row) => [rowRefKey(row.ref), row]));
|
|
10648
|
+
return this.getAccountsForQuotaCheck().flatMap((target) => {
|
|
10649
|
+
const row = target.rowRef && rows.get(rowRefKey(target.rowRef));
|
|
10650
|
+
if (!row)
|
|
10651
|
+
return [];
|
|
10652
|
+
const quota = row.quota.status === "present" ? row.quota.quota : void 0;
|
|
10653
|
+
return [
|
|
10654
|
+
{
|
|
10655
|
+
...target,
|
|
10656
|
+
cachedQuotaUpdatedAt: quota?.cachedQuota == null ? void 0 : quota.cachedQuotaUpdatedAt ?? void 0
|
|
10657
|
+
}
|
|
10658
|
+
];
|
|
10659
|
+
});
|
|
10660
|
+
}
|
|
10613
10661
|
getOldestQuotaCacheAge() {
|
|
10614
10662
|
return this.selection.getOldestQuotaCacheAge();
|
|
10615
10663
|
}
|
|
@@ -10688,6 +10736,14 @@ function orderAgyRequestPayloadInPlace(payload) {
|
|
|
10688
10736
|
function countAgyRequestSteps(payload) {
|
|
10689
10737
|
return Array.isArray(payload.contents) ? payload.contents.length : 0;
|
|
10690
10738
|
}
|
|
10739
|
+
function appendAgyContinuation(contents, wireModel) {
|
|
10740
|
+
const last = contents.at(-1);
|
|
10741
|
+
if (last?.role !== "model" && last?.role !== "assistant")
|
|
10742
|
+
return;
|
|
10743
|
+
if (last.role === "model" && wireModel.startsWith("gemini-") && Array.isArray(last.parts) && last.parts.length > 0 && last.parts.every((part) => part?.functionResponse))
|
|
10744
|
+
return;
|
|
10745
|
+
contents.push({ role: "user", parts: [{ text: "[Continue]" }] });
|
|
10746
|
+
}
|
|
10691
10747
|
function hasSecondUserTurn(payload) {
|
|
10692
10748
|
if (!Array.isArray(payload.contents))
|
|
10693
10749
|
return false;
|
|
@@ -10933,7 +10989,7 @@ function getHttpsProxy(url) {
|
|
|
10933
10989
|
}
|
|
10934
10990
|
}
|
|
10935
10991
|
function waitForHead(socket, timeoutMs, onTimeout) {
|
|
10936
|
-
return new Promise((
|
|
10992
|
+
return new Promise((resolve35, reject) => {
|
|
10937
10993
|
let buffer = Buffer3.alloc(0);
|
|
10938
10994
|
const timeout = setTimeout(() => {
|
|
10939
10995
|
onTimeout();
|
|
@@ -10956,7 +11012,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
|
|
|
10956
11012
|
return;
|
|
10957
11013
|
const head = buffer.subarray(0, marker).toString("latin1");
|
|
10958
11014
|
const leftover = buffer.subarray(marker + 4);
|
|
10959
|
-
cleanup2(() =>
|
|
11015
|
+
cleanup2(() => resolve35({ head, leftover }));
|
|
10960
11016
|
};
|
|
10961
11017
|
socket.on("data", onData);
|
|
10962
11018
|
socket.once("error", onError);
|
|
@@ -10970,7 +11026,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
10970
11026
|
port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
|
|
10971
11027
|
signal: signal ?? void 0
|
|
10972
11028
|
});
|
|
10973
|
-
await new Promise((
|
|
11029
|
+
await new Promise((resolve35, reject) => {
|
|
10974
11030
|
const timeout = setTimeout(() => {
|
|
10975
11031
|
onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
|
|
10976
11032
|
proxySocket.destroy();
|
|
@@ -10979,7 +11035,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
10979
11035
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10980
11036
|
proxySocket.once("connect", () => {
|
|
10981
11037
|
cleanup2();
|
|
10982
|
-
|
|
11038
|
+
resolve35();
|
|
10983
11039
|
});
|
|
10984
11040
|
proxySocket.once("error", (error) => {
|
|
10985
11041
|
cleanup2();
|
|
@@ -11004,7 +11060,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
11004
11060
|
if (leftover.length > 0) {
|
|
11005
11061
|
proxySocket.unshift(leftover);
|
|
11006
11062
|
}
|
|
11007
|
-
return await new Promise((
|
|
11063
|
+
return await new Promise((resolve35, reject) => {
|
|
11008
11064
|
const tlsOptions = {
|
|
11009
11065
|
socket: proxySocket,
|
|
11010
11066
|
servername: targetHost,
|
|
@@ -11020,7 +11076,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
11020
11076
|
const cleanup2 = () => clearTimeout(timeout);
|
|
11021
11077
|
tlsSocket.once("secureConnect", () => {
|
|
11022
11078
|
cleanup2();
|
|
11023
|
-
|
|
11079
|
+
resolve35(tlsSocket);
|
|
11024
11080
|
});
|
|
11025
11081
|
tlsSocket.once("error", (error) => {
|
|
11026
11082
|
cleanup2();
|
|
@@ -11029,7 +11085,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
11029
11085
|
});
|
|
11030
11086
|
}
|
|
11031
11087
|
async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
11032
|
-
return await new Promise((
|
|
11088
|
+
return await new Promise((resolve35, reject) => {
|
|
11033
11089
|
const tlsOptions = {
|
|
11034
11090
|
host: targetUrl.hostname,
|
|
11035
11091
|
port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
|
|
@@ -11046,7 +11102,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
|
11046
11102
|
const cleanup2 = () => clearTimeout(timeout);
|
|
11047
11103
|
socket.once("secureConnect", () => {
|
|
11048
11104
|
cleanup2();
|
|
11049
|
-
|
|
11105
|
+
resolve35(socket);
|
|
11050
11106
|
});
|
|
11051
11107
|
socket.once("error", (error) => {
|
|
11052
11108
|
cleanup2();
|
|
@@ -11132,15 +11188,24 @@ function buildResponseStream(socket, leftover, head, signal, idleTimeoutMs, onDe
|
|
|
11132
11188
|
source.write(leftover);
|
|
11133
11189
|
}
|
|
11134
11190
|
socket.pipe(source);
|
|
11191
|
+
const stages = [source];
|
|
11192
|
+
let framing;
|
|
11135
11193
|
let responseBody = source;
|
|
11136
11194
|
if (head.chunked) {
|
|
11137
|
-
|
|
11195
|
+
framing = new ChunkedDecodeStream();
|
|
11138
11196
|
} else if (typeof head.contentLength === "number") {
|
|
11139
|
-
|
|
11197
|
+
framing = new ContentLengthStream(head.contentLength);
|
|
11198
|
+
}
|
|
11199
|
+
if (framing) {
|
|
11200
|
+
responseBody = responseBody.pipe(framing);
|
|
11201
|
+
stages.push(framing);
|
|
11140
11202
|
}
|
|
11141
11203
|
if (head.gzip) {
|
|
11142
11204
|
responseBody = responseBody.pipe(createGunzip());
|
|
11205
|
+
stages.push(responseBody);
|
|
11143
11206
|
}
|
|
11207
|
+
let settled = false;
|
|
11208
|
+
let socketEnded = false;
|
|
11144
11209
|
let idleTimer;
|
|
11145
11210
|
const clearIdle = () => {
|
|
11146
11211
|
if (idleTimer) {
|
|
@@ -11154,31 +11219,55 @@ function buildResponseStream(socket, leftover, head, signal, idleTimeoutMs, onDe
|
|
|
11154
11219
|
clearIdle();
|
|
11155
11220
|
idleTimer = setTimeout(() => {
|
|
11156
11221
|
onDebug?.(`agy transport idle timeout after ${idleTimeoutMs}ms with no body data`);
|
|
11157
|
-
|
|
11222
|
+
settle(new Error("Antigravity response stalled: no body data within the limit"));
|
|
11158
11223
|
}, idleTimeoutMs);
|
|
11159
11224
|
};
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11225
|
+
const abort = () => settle(new DOMException("The operation was aborted", "AbortError"));
|
|
11226
|
+
const onSocketEnd = () => {
|
|
11227
|
+
socketEnded = true;
|
|
11228
|
+
};
|
|
11229
|
+
const onSocketClose = () => {
|
|
11230
|
+
if (!socketEnded && !framing?.complete) {
|
|
11231
|
+
settle(new Error("Antigravity response connection closed before the body ended"));
|
|
11232
|
+
}
|
|
11233
|
+
};
|
|
11234
|
+
const fail2 = (error) => settle(error instanceof Error ? error : new Error(String(error)));
|
|
11235
|
+
function settle(error) {
|
|
11236
|
+
if (settled)
|
|
11237
|
+
return;
|
|
11238
|
+
settled = true;
|
|
11164
11239
|
clearIdle();
|
|
11165
11240
|
socket.off("data", armIdle);
|
|
11241
|
+
socket.off("end", onSocketEnd);
|
|
11242
|
+
socket.off("close", onSocketClose);
|
|
11166
11243
|
signal?.removeEventListener("abort", abort);
|
|
11167
|
-
|
|
11244
|
+
socket.unpipe(source);
|
|
11245
|
+
socket.destroy();
|
|
11246
|
+
for (const stage of stages) {
|
|
11247
|
+
if (stage !== responseBody && !stage.destroyed)
|
|
11248
|
+
stage.destroy();
|
|
11249
|
+
}
|
|
11250
|
+
if (!responseBody.destroyed) {
|
|
11251
|
+
if (error)
|
|
11252
|
+
responseBody.destroy(error);
|
|
11253
|
+
else if (!responseBody.readableEnded)
|
|
11254
|
+
responseBody.destroy();
|
|
11255
|
+
}
|
|
11256
|
+
}
|
|
11257
|
+
socket.on("error", fail2);
|
|
11258
|
+
socket.on("data", armIdle);
|
|
11259
|
+
socket.once("end", onSocketEnd);
|
|
11260
|
+
socket.once("close", onSocketClose);
|
|
11261
|
+
for (const stage of stages)
|
|
11262
|
+
stage.on("error", fail2);
|
|
11263
|
+
responseBody.once("end", () => settle());
|
|
11264
|
+
responseBody.once("close", () => settle());
|
|
11265
|
+
armIdle();
|
|
11168
11266
|
if (signal?.aborted) {
|
|
11169
11267
|
abort();
|
|
11170
11268
|
} else {
|
|
11171
11269
|
signal?.addEventListener("abort", abort, { once: true });
|
|
11172
11270
|
}
|
|
11173
|
-
responseBody.once("end", () => {
|
|
11174
|
-
cleanup2();
|
|
11175
|
-
socket.destroy();
|
|
11176
|
-
});
|
|
11177
|
-
responseBody.once("error", () => {
|
|
11178
|
-
cleanup2();
|
|
11179
|
-
socket.destroy();
|
|
11180
|
-
});
|
|
11181
|
-
responseBody.once("close", cleanup2);
|
|
11182
11271
|
return Readable.toWeb(responseBody);
|
|
11183
11272
|
}
|
|
11184
11273
|
async function fetchWithAgyCliTransport(url, init = {}, options = {}) {
|
|
@@ -11236,6 +11325,11 @@ var init_agy_transport = __esm({
|
|
|
11236
11325
|
constructor(contentLength) {
|
|
11237
11326
|
super();
|
|
11238
11327
|
this.remaining = contentLength;
|
|
11328
|
+
if (this.remaining <= 0)
|
|
11329
|
+
this.push(null);
|
|
11330
|
+
}
|
|
11331
|
+
get complete() {
|
|
11332
|
+
return this.remaining <= 0;
|
|
11239
11333
|
}
|
|
11240
11334
|
_transform(chunk, _encoding, callback) {
|
|
11241
11335
|
if (this.remaining <= 0) {
|
|
@@ -11254,10 +11348,21 @@ var init_agy_transport = __esm({
|
|
|
11254
11348
|
}
|
|
11255
11349
|
callback();
|
|
11256
11350
|
}
|
|
11351
|
+
_flush(callback) {
|
|
11352
|
+
callback(this.remaining > 0 ? new Error("Antigravity response ended before its declared length") : null);
|
|
11353
|
+
}
|
|
11257
11354
|
};
|
|
11258
11355
|
ChunkedDecodeStream = class extends Transform {
|
|
11259
11356
|
buffer = Buffer3.alloc(0);
|
|
11357
|
+
finished = false;
|
|
11358
|
+
get complete() {
|
|
11359
|
+
return this.finished;
|
|
11360
|
+
}
|
|
11260
11361
|
_transform(chunk, _encoding, callback) {
|
|
11362
|
+
if (this.finished) {
|
|
11363
|
+
callback();
|
|
11364
|
+
return;
|
|
11365
|
+
}
|
|
11261
11366
|
this.buffer = Buffer3.concat([this.buffer, chunk]);
|
|
11262
11367
|
try {
|
|
11263
11368
|
this.flushAvailableChunks();
|
|
@@ -11268,8 +11373,9 @@ var init_agy_transport = __esm({
|
|
|
11268
11373
|
}
|
|
11269
11374
|
_flush(callback) {
|
|
11270
11375
|
try {
|
|
11271
|
-
this.
|
|
11272
|
-
|
|
11376
|
+
if (!this.finished)
|
|
11377
|
+
this.flushAvailableChunks();
|
|
11378
|
+
callback(this.finished ? null : new Error("Antigravity response ended before its final chunk"));
|
|
11273
11379
|
} catch (error) {
|
|
11274
11380
|
callback(error instanceof Error ? error : new Error(String(error)));
|
|
11275
11381
|
}
|
|
@@ -11285,16 +11391,19 @@ var init_agy_transport = __esm({
|
|
|
11285
11391
|
if (!Number.isFinite(size)) {
|
|
11286
11392
|
throw new Error(`Invalid chunk size: ${sizeLine}`);
|
|
11287
11393
|
}
|
|
11288
|
-
const chunkStart = lineEnd + 2;
|
|
11289
|
-
const chunkEnd = chunkStart + size;
|
|
11290
|
-
const nextOffset = chunkEnd + 2;
|
|
11291
|
-
if (this.buffer.length < nextOffset)
|
|
11292
|
-
return;
|
|
11293
11394
|
if (size === 0) {
|
|
11395
|
+
if (this.buffer.indexOf("\r\n\r\n", lineEnd) === -1)
|
|
11396
|
+
return;
|
|
11397
|
+
this.finished = true;
|
|
11294
11398
|
this.buffer = Buffer3.alloc(0);
|
|
11295
11399
|
this.push(null);
|
|
11296
11400
|
return;
|
|
11297
11401
|
}
|
|
11402
|
+
const chunkStart = lineEnd + 2;
|
|
11403
|
+
const chunkEnd = chunkStart + size;
|
|
11404
|
+
const nextOffset = chunkEnd + 2;
|
|
11405
|
+
if (this.buffer.length < nextOffset)
|
|
11406
|
+
return;
|
|
11298
11407
|
this.push(this.buffer.subarray(chunkStart, chunkEnd));
|
|
11299
11408
|
this.buffer = this.buffer.subarray(nextOffset);
|
|
11300
11409
|
}
|
|
@@ -13855,8 +13964,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13855
13964
|
let releaseConfirmed = false;
|
|
13856
13965
|
let loss;
|
|
13857
13966
|
let resolveLoss;
|
|
13858
|
-
const lostPromise = new Promise((
|
|
13859
|
-
resolveLoss =
|
|
13967
|
+
const lostPromise = new Promise((resolve35) => {
|
|
13968
|
+
resolveLoss = resolve35;
|
|
13860
13969
|
});
|
|
13861
13970
|
function notifyTimerStep(event) {
|
|
13862
13971
|
try {
|
|
@@ -14020,7 +14129,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
14020
14129
|
}
|
|
14021
14130
|
}
|
|
14022
14131
|
async function backoff() {
|
|
14023
|
-
await new Promise((
|
|
14132
|
+
await new Promise((resolve35) => setTimeout(resolve35, Math.floor(Math.random() * 4)));
|
|
14024
14133
|
}
|
|
14025
14134
|
async function readLockState(notifyReady = true) {
|
|
14026
14135
|
if (notifyReady && options.onStep)
|
|
@@ -14113,7 +14222,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
14113
14222
|
const remainingMs = deadline - performance.now();
|
|
14114
14223
|
if (remainingMs <= 0)
|
|
14115
14224
|
throw original;
|
|
14116
|
-
await new Promise((
|
|
14225
|
+
await new Promise((resolve35) => setTimeout(resolve35, Math.min(delayMs, remainingMs)));
|
|
14117
14226
|
if (performance.now() >= deadline)
|
|
14118
14227
|
throw original;
|
|
14119
14228
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -14616,7 +14725,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
14616
14725
|
const remainingMs = deadline - performance.now();
|
|
14617
14726
|
if (remainingMs <= 0)
|
|
14618
14727
|
break;
|
|
14619
|
-
await new Promise((
|
|
14728
|
+
await new Promise((resolve35) => setTimeout(resolve35, Math.min(delayMs, remainingMs)));
|
|
14620
14729
|
if (windowsPrivateFiles && performance.now() >= deadline)
|
|
14621
14730
|
break;
|
|
14622
14731
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -14701,7 +14810,7 @@ async function withLock(target, options, fn) {
|
|
|
14701
14810
|
timeoutMs: options.timeoutMs
|
|
14702
14811
|
});
|
|
14703
14812
|
}
|
|
14704
|
-
await new Promise((
|
|
14813
|
+
await new Promise((resolve35) => setTimeout(resolve35, Math.min(25, Math.ceil(remaining))));
|
|
14705
14814
|
}
|
|
14706
14815
|
}
|
|
14707
14816
|
var LockContentionError, LockOwnershipError;
|
|
@@ -14791,7 +14900,7 @@ async function acquirePoolLock(spec, defaults2, env3) {
|
|
|
14791
14900
|
});
|
|
14792
14901
|
}
|
|
14793
14902
|
const jitter = Math.floor(Math.random() * (options.retryMs + 1));
|
|
14794
|
-
await new Promise((
|
|
14903
|
+
await new Promise((resolve35) => setTimeout(resolve35, Math.min(options.retryMs + jitter, remaining)));
|
|
14795
14904
|
}
|
|
14796
14905
|
}
|
|
14797
14906
|
function definedOnly(spec) {
|
|
@@ -17704,11 +17813,11 @@ var init_quota_writer = __esm({
|
|
|
17704
17813
|
const left = deadline - performance.now();
|
|
17705
17814
|
if (left <= 0)
|
|
17706
17815
|
throw refusal2("pull", id, "lock-contention", `pool quota queue for ${id} is full (${POOL_QUOTA_QUEUE_LIMIT} readings) and the store locks stayed held`, true);
|
|
17707
|
-
await new Promise((
|
|
17816
|
+
await new Promise((resolve35) => {
|
|
17708
17817
|
const done = () => {
|
|
17709
17818
|
clearTimeout(timer);
|
|
17710
17819
|
this.wake.delete(done);
|
|
17711
|
-
|
|
17820
|
+
resolve35();
|
|
17712
17821
|
};
|
|
17713
17822
|
const timer = setTimeout(done, left);
|
|
17714
17823
|
this.wake.add(done);
|
|
@@ -20440,6 +20549,8 @@ async function request(operation) {
|
|
|
20440
20549
|
function wrapHostClient(client) {
|
|
20441
20550
|
const watchScoped = client.watchScoped?.bind(client);
|
|
20442
20551
|
const reportUsageScoped = client.reportUsageScoped?.bind(client);
|
|
20552
|
+
const reportCondition = client.reportCondition?.bind(client);
|
|
20553
|
+
const clearCondition = client.clearCondition?.bind(client);
|
|
20443
20554
|
return {
|
|
20444
20555
|
listScoped: (...args) => request(() => client.listScoped(...args)),
|
|
20445
20556
|
getScoped: (...args) => request(() => client.getScoped(...args)),
|
|
@@ -20460,6 +20571,12 @@ function wrapHostClient(client) {
|
|
|
20460
20571
|
...reportUsageScoped && {
|
|
20461
20572
|
reportUsageScoped: (...args) => request(() => reportUsageScoped(...args))
|
|
20462
20573
|
},
|
|
20574
|
+
...reportCondition && {
|
|
20575
|
+
reportCondition: (...args) => request(() => reportCondition(...args))
|
|
20576
|
+
},
|
|
20577
|
+
...clearCondition && {
|
|
20578
|
+
clearCondition: (...args) => request(() => clearCondition(...args))
|
|
20579
|
+
},
|
|
20463
20580
|
...client.insula && {
|
|
20464
20581
|
insula: wrapInsula(client.insula)
|
|
20465
20582
|
}
|
|
@@ -20831,7 +20948,7 @@ async function select(terminal, items, options) {
|
|
|
20831
20948
|
writeLine("");
|
|
20832
20949
|
renderedLines = lines;
|
|
20833
20950
|
};
|
|
20834
|
-
return new Promise((
|
|
20951
|
+
return new Promise((resolve35) => {
|
|
20835
20952
|
const wasRaw = stdin.isRaw ?? false;
|
|
20836
20953
|
const cleanup2 = () => {
|
|
20837
20954
|
if (cleaned)
|
|
@@ -20851,7 +20968,7 @@ async function select(terminal, items, options) {
|
|
|
20851
20968
|
};
|
|
20852
20969
|
const finish = (value) => {
|
|
20853
20970
|
cleanup2();
|
|
20854
|
-
|
|
20971
|
+
resolve35(value);
|
|
20855
20972
|
};
|
|
20856
20973
|
const onSignal = () => finish(null);
|
|
20857
20974
|
const onKey = (data) => {
|
|
@@ -20891,7 +21008,7 @@ async function select(terminal, items, options) {
|
|
|
20891
21008
|
stdin.setRawMode(true);
|
|
20892
21009
|
} catch {
|
|
20893
21010
|
cleanup2();
|
|
20894
|
-
|
|
21011
|
+
resolve35(null);
|
|
20895
21012
|
return;
|
|
20896
21013
|
}
|
|
20897
21014
|
stdin.resume();
|
|
@@ -22917,10 +23034,10 @@ async function drainShutdown(pending, onTimeout) {
|
|
|
22917
23034
|
try {
|
|
22918
23035
|
await Promise.race([
|
|
22919
23036
|
drained,
|
|
22920
|
-
new Promise((
|
|
23037
|
+
new Promise((resolve35) => {
|
|
22921
23038
|
timer = setTimeout(() => {
|
|
22922
23039
|
expired = true;
|
|
22923
|
-
|
|
23040
|
+
resolve35();
|
|
22924
23041
|
}, 2e3);
|
|
22925
23042
|
})
|
|
22926
23043
|
]);
|
|
@@ -23197,6 +23314,28 @@ function rowFactsOf(row, { includeProviderIds = true } = {}) {
|
|
|
23197
23314
|
authMethod: metadata.authMethod
|
|
23198
23315
|
};
|
|
23199
23316
|
}
|
|
23317
|
+
function isVaultConditionReason(reason) {
|
|
23318
|
+
return reason === "provider_verification_required" || reason === "provider_ineligible";
|
|
23319
|
+
}
|
|
23320
|
+
function vaultConditionOf(row) {
|
|
23321
|
+
const condition = row.condition;
|
|
23322
|
+
if (!condition)
|
|
23323
|
+
return void 0;
|
|
23324
|
+
const { reason, sinceMs } = condition;
|
|
23325
|
+
if (isVaultConditionReason(reason) && Number.isSafeInteger(sinceMs) && sinceMs > 0)
|
|
23326
|
+
return Object.freeze({ reason, sinceMs });
|
|
23327
|
+
return void 0;
|
|
23328
|
+
}
|
|
23329
|
+
function httpsActionUrl(actionUrl) {
|
|
23330
|
+
if (typeof actionUrl !== "string")
|
|
23331
|
+
return void 0;
|
|
23332
|
+
try {
|
|
23333
|
+
if (new URL(actionUrl).protocol === "https:")
|
|
23334
|
+
return actionUrl;
|
|
23335
|
+
} catch {
|
|
23336
|
+
}
|
|
23337
|
+
return void 0;
|
|
23338
|
+
}
|
|
23200
23339
|
function grantReachOf(listed) {
|
|
23201
23340
|
const { grants, grantTuples } = listed;
|
|
23202
23341
|
if (grants === void 0 || grantTuples === void 0)
|
|
@@ -23235,6 +23374,10 @@ var init_custody = __esm({
|
|
|
23235
23374
|
#logger;
|
|
23236
23375
|
#provenance = /* @__PURE__ */ new WeakMap();
|
|
23237
23376
|
#reports = /* @__PURE__ */ new WeakMap();
|
|
23377
|
+
#conditionReports = /* @__PURE__ */ new Map();
|
|
23378
|
+
#conditionClears = /* @__PURE__ */ new Map();
|
|
23379
|
+
#conditionsUnsupported = false;
|
|
23380
|
+
#pendingConditionCalls = 0;
|
|
23238
23381
|
#kept = /* @__PURE__ */ new Map();
|
|
23239
23382
|
#keptAttempts = /* @__PURE__ */ new WeakMap();
|
|
23240
23383
|
#usage;
|
|
@@ -23253,8 +23396,9 @@ var init_custody = __esm({
|
|
|
23253
23396
|
#closed = false;
|
|
23254
23397
|
/** The view of the last successful `discover()`, for `watchRoster`. */
|
|
23255
23398
|
#discoveredView;
|
|
23399
|
+
#discoveredConditions = /* @__PURE__ */ new Map();
|
|
23256
23400
|
#watches = /* @__PURE__ */ new Set();
|
|
23257
|
-
#
|
|
23401
|
+
#shutdownWork = /* @__PURE__ */ new Set();
|
|
23258
23402
|
#warnShutdown;
|
|
23259
23403
|
#onDrainTimeout;
|
|
23260
23404
|
#disposing;
|
|
@@ -23313,6 +23457,7 @@ var init_custody = __esm({
|
|
|
23313
23457
|
if (hasVaultHost() && !isVaultHostClient(next))
|
|
23314
23458
|
throw new ClaustrumUnreachableError();
|
|
23315
23459
|
this.#client = next;
|
|
23460
|
+
this.#conditionsUnsupported = false;
|
|
23316
23461
|
for (const watch2 of this.#watches)
|
|
23317
23462
|
watch2.restart();
|
|
23318
23463
|
}
|
|
@@ -23381,12 +23526,12 @@ var init_custody = __esm({
|
|
|
23381
23526
|
phase: "token read begin"
|
|
23382
23527
|
});
|
|
23383
23528
|
const pending = this.#readToken();
|
|
23384
|
-
this.#
|
|
23529
|
+
this.#shutdownWork.add(pending);
|
|
23385
23530
|
let value;
|
|
23386
23531
|
try {
|
|
23387
23532
|
value = await pending;
|
|
23388
23533
|
} finally {
|
|
23389
|
-
this.#
|
|
23534
|
+
this.#shutdownWork.delete(pending);
|
|
23390
23535
|
if (phaseDiagnostics.hasSubscribers)
|
|
23391
23536
|
phaseDiagnostics.publish({
|
|
23392
23537
|
logger: this.#logger,
|
|
@@ -23439,6 +23584,11 @@ var init_custody = __esm({
|
|
|
23439
23584
|
async discover(signal) {
|
|
23440
23585
|
const inventory = await this.#list(signal);
|
|
23441
23586
|
this.#discoveredView = inventory.view;
|
|
23587
|
+
this.#discoveredConditions.clear();
|
|
23588
|
+
for (const { credentialId, condition } of inventory.credentials) {
|
|
23589
|
+
if (condition)
|
|
23590
|
+
this.#discoveredConditions.set(credentialId, condition);
|
|
23591
|
+
}
|
|
23442
23592
|
return inventory;
|
|
23443
23593
|
}
|
|
23444
23594
|
async #list(signal) {
|
|
@@ -23512,6 +23662,7 @@ var init_custody = __esm({
|
|
|
23512
23662
|
});
|
|
23513
23663
|
continue;
|
|
23514
23664
|
}
|
|
23665
|
+
const condition = vaultConditionOf(row);
|
|
23515
23666
|
credentials.push(Object.freeze({
|
|
23516
23667
|
credentialId: row.id,
|
|
23517
23668
|
credentialType: type,
|
|
@@ -23521,7 +23672,8 @@ var init_custody = __esm({
|
|
|
23521
23672
|
},
|
|
23522
23673
|
state: row.state,
|
|
23523
23674
|
...row.email !== void 0 && { email: row.email },
|
|
23524
|
-
...row.orgName !== void 0 && { orgName: row.orgName }
|
|
23675
|
+
...row.orgName !== void 0 && { orgName: row.orgName },
|
|
23676
|
+
...condition && { condition }
|
|
23525
23677
|
}));
|
|
23526
23678
|
}
|
|
23527
23679
|
for (const record5 of skipped)
|
|
@@ -23729,7 +23881,7 @@ var init_custody = __esm({
|
|
|
23729
23881
|
}
|
|
23730
23882
|
#receiptBackoff(delay5, signal) {
|
|
23731
23883
|
this.#check(signal);
|
|
23732
|
-
return new Promise((
|
|
23884
|
+
return new Promise((resolve35, reject) => {
|
|
23733
23885
|
const abort = () => {
|
|
23734
23886
|
this.#clearTimeout(timer);
|
|
23735
23887
|
signal.removeEventListener("abort", abort);
|
|
@@ -23737,7 +23889,7 @@ var init_custody = __esm({
|
|
|
23737
23889
|
};
|
|
23738
23890
|
const timer = this.#setTimeout(() => {
|
|
23739
23891
|
signal.removeEventListener("abort", abort);
|
|
23740
|
-
|
|
23892
|
+
resolve35();
|
|
23741
23893
|
}, delay5);
|
|
23742
23894
|
timer.unref?.();
|
|
23743
23895
|
signal.addEventListener("abort", abort, { once: true });
|
|
@@ -23866,6 +24018,90 @@ var init_custody = __esm({
|
|
|
23866
24018
|
throw error;
|
|
23867
24019
|
}
|
|
23868
24020
|
}
|
|
24021
|
+
/**
|
|
24022
|
+
* Report a provider login condition as bookkeeping after handing back the
|
|
24023
|
+
* reply, never on the request path. Pass the receipt actually sent with it.
|
|
24024
|
+
*/
|
|
24025
|
+
reportCondition(attempt, input2) {
|
|
24026
|
+
const provenance = this.#provenance.get(attempt);
|
|
24027
|
+
if (!provenance)
|
|
24028
|
+
return Promise.reject(new ClaustrumConsumerError("no-receipt", "Claustrum condition report requires an original dispatch receipt"));
|
|
24029
|
+
const { reason, providerStatus } = input2 ?? {};
|
|
24030
|
+
if (this.#closed || this.#keptAttempts.has(attempt) || providerStatus !== 403 || !isVaultConditionReason(reason))
|
|
24031
|
+
return Promise.resolve("skipped");
|
|
24032
|
+
const { credentialId, recordVersion } = attempt;
|
|
24033
|
+
const actionUrl = reason === "provider_verification_required" ? httpsActionUrl(input2.actionUrl) : void 0;
|
|
24034
|
+
return this.#conditionOnce(this.#conditionReports, JSON.stringify([credentialId, recordVersion, reason]), { credentialId, recordVersion, reason }, (client) => client.reportCondition?.({
|
|
24035
|
+
credentialId,
|
|
24036
|
+
recordVersion,
|
|
24037
|
+
reason,
|
|
24038
|
+
providerStatus,
|
|
24039
|
+
...actionUrl !== void 0 && { actionUrl },
|
|
24040
|
+
enrollmentToken: provenance.token
|
|
24041
|
+
}));
|
|
24042
|
+
}
|
|
24043
|
+
/**
|
|
24044
|
+
* Clear a listed condition as bookkeeping after handing back a successful
|
|
24045
|
+
* reply, never on the request path. Pass the receipt actually sent with it.
|
|
24046
|
+
*/
|
|
24047
|
+
clearCondition(attempt) {
|
|
24048
|
+
const provenance = this.#provenance.get(attempt);
|
|
24049
|
+
if (!provenance)
|
|
24050
|
+
return Promise.reject(new ClaustrumConsumerError("no-receipt", "Claustrum condition clear requires an original dispatch receipt"));
|
|
24051
|
+
if (this.#closed || this.#keptAttempts.has(attempt))
|
|
24052
|
+
return Promise.resolve("skipped");
|
|
24053
|
+
const { credentialId, recordVersion } = attempt;
|
|
24054
|
+
const condition = this.#discoveredConditions.get(credentialId);
|
|
24055
|
+
if (!condition)
|
|
24056
|
+
return Promise.resolve("skipped");
|
|
24057
|
+
return this.#conditionOnce(this.#conditionClears, JSON.stringify([credentialId, condition.sinceMs]), { credentialId, recordVersion, reason: condition.reason }, (client) => client.clearCondition?.({
|
|
24058
|
+
credentialId,
|
|
24059
|
+
recordVersion,
|
|
24060
|
+
enrollmentToken: provenance.token
|
|
24061
|
+
}));
|
|
24062
|
+
}
|
|
24063
|
+
#conditionOnce(outcomes, key2, details, send) {
|
|
24064
|
+
const previous = outcomes.get(key2);
|
|
24065
|
+
if (previous)
|
|
24066
|
+
return previous;
|
|
24067
|
+
if (this.#conditionsUnsupported)
|
|
24068
|
+
return Promise.resolve("unsupported");
|
|
24069
|
+
const pending = Promise.resolve().then(async () => {
|
|
24070
|
+
const client = this.#client;
|
|
24071
|
+
if (this.#conditionsUnsupported)
|
|
24072
|
+
return "unsupported";
|
|
24073
|
+
try {
|
|
24074
|
+
const sent = send(client);
|
|
24075
|
+
if (!sent)
|
|
24076
|
+
return "unsupported";
|
|
24077
|
+
if (await sent === false)
|
|
24078
|
+
this.#debugCondition("scoped login condition not cleared", details);
|
|
24079
|
+
return "reported";
|
|
24080
|
+
} catch (error) {
|
|
24081
|
+
if (error instanceof ClaustrumCredentialError5 && error.code === "unknown_method") {
|
|
24082
|
+
if (client === this.#client)
|
|
24083
|
+
this.#conditionsUnsupported = true;
|
|
24084
|
+
return "unsupported";
|
|
24085
|
+
}
|
|
24086
|
+
this.#debugCondition("scoped login condition update failed", details);
|
|
24087
|
+
return "failed";
|
|
24088
|
+
}
|
|
24089
|
+
});
|
|
24090
|
+
outcomes.set(key2, pending);
|
|
24091
|
+
this.#pendingConditionCalls++;
|
|
24092
|
+
this.#shutdownWork.add(pending);
|
|
24093
|
+
void pending.then(() => {
|
|
24094
|
+
this.#pendingConditionCalls--;
|
|
24095
|
+
this.#shutdownWork.delete(pending);
|
|
24096
|
+
});
|
|
24097
|
+
return pending;
|
|
24098
|
+
}
|
|
24099
|
+
#debugCondition(message, details) {
|
|
24100
|
+
try {
|
|
24101
|
+
this.#logger.debug(message, details);
|
|
24102
|
+
} catch {
|
|
24103
|
+
}
|
|
24104
|
+
}
|
|
23869
24105
|
/**
|
|
23870
24106
|
* Watch this consumer's visible vault accounts instead of listing them on a
|
|
23871
24107
|
* short timer. Opens one `watchScoped` on this custody's client and calls
|
|
@@ -23981,15 +24217,17 @@ var init_custody = __esm({
|
|
|
23981
24217
|
this.#watches.clear();
|
|
23982
24218
|
this.#kept.clear();
|
|
23983
24219
|
const usage = this.#usage.close();
|
|
24220
|
+
const keepClientOpen = usage !== void 0 || this.#pendingConditionCalls > 0;
|
|
23984
24221
|
if (usage) {
|
|
23985
|
-
this.#
|
|
23986
|
-
void usage.then(() => this.#
|
|
23987
|
-
}
|
|
24222
|
+
this.#shutdownWork.add(usage);
|
|
24223
|
+
void usage.then(() => this.#shutdownWork.delete(usage));
|
|
24224
|
+
}
|
|
24225
|
+
if (!keepClientOpen)
|
|
23988
24226
|
this.#client.close();
|
|
23989
|
-
this.#disposing = drainShutdown(this.#
|
|
24227
|
+
this.#disposing = drainShutdown(this.#shutdownWork, (count4) => (this.#onDrainTimeout ?? this.#warnShutdown)(count4)).finally(() => {
|
|
23990
24228
|
this.#usage.drop();
|
|
23991
24229
|
this.#usageServed.clear();
|
|
23992
|
-
if (
|
|
24230
|
+
if (keepClientOpen)
|
|
23993
24231
|
this.#client.close();
|
|
23994
24232
|
});
|
|
23995
24233
|
}
|
|
@@ -24973,7 +25211,7 @@ var init_consumer = __esm({
|
|
|
24973
25211
|
this.#shutdown.signal,
|
|
24974
25212
|
...signal ? [signal] : []
|
|
24975
25213
|
]);
|
|
24976
|
-
return new Promise((
|
|
25214
|
+
return new Promise((resolve35, reject) => {
|
|
24977
25215
|
const cleanup2 = () => {
|
|
24978
25216
|
combined.signal.removeEventListener("abort", abort);
|
|
24979
25217
|
combined.dispose();
|
|
@@ -24988,7 +25226,7 @@ var init_consumer = __esm({
|
|
|
24988
25226
|
if (combined.signal.aborted)
|
|
24989
25227
|
reject(combined.signal.reason);
|
|
24990
25228
|
else
|
|
24991
|
-
|
|
25229
|
+
resolve35(value);
|
|
24992
25230
|
}, (error) => {
|
|
24993
25231
|
cleanup2();
|
|
24994
25232
|
reject(error);
|
|
@@ -25584,6 +25822,36 @@ var init_consumer = __esm({
|
|
|
25584
25822
|
throw new ClaustrumConsumerError("no-receipt", "Claustrum dispatch receipt has no active owner");
|
|
25585
25823
|
await this.#custody.reportFailure(attempt, status, source);
|
|
25586
25824
|
}
|
|
25825
|
+
/** The custody (or hub lease) that issued `attempt`, or a `no-receipt` refusal. */
|
|
25826
|
+
#issuingCustody(attempt) {
|
|
25827
|
+
const custody = this.#hub ? this.#issuedBy.get(attempt)?.custody : this.#custody;
|
|
25828
|
+
if (!custody)
|
|
25829
|
+
throw new ClaustrumConsumerError("no-receipt", "Claustrum dispatch receipt has no active owner");
|
|
25830
|
+
return custody;
|
|
25831
|
+
}
|
|
25832
|
+
/**
|
|
25833
|
+
* Report a provider login condition through the custody that issued the
|
|
25834
|
+
* receipt; see `ClaustrumScopedCustody.reportCondition`. Bookkeeping: call it
|
|
25835
|
+
* after handing back the reply, never on the request path. It resolves
|
|
25836
|
+
* `skipped` after shutdown and rejects only with `no-receipt` for a receipt
|
|
25837
|
+
* no live custody of this consumer issued.
|
|
25838
|
+
*/
|
|
25839
|
+
async reportCondition(attempt, input2) {
|
|
25840
|
+
if (this.#shutdown.signal.aborted)
|
|
25841
|
+
return "skipped";
|
|
25842
|
+
return this.#issuingCustody(attempt).reportCondition(attempt, input2);
|
|
25843
|
+
}
|
|
25844
|
+
/**
|
|
25845
|
+
* Clear a listed login condition through the custody that issued the
|
|
25846
|
+
* receipt; see `ClaustrumScopedCustody.clearCondition`. Safe to call after
|
|
25847
|
+
* every successful reply: it sends nothing unless the login is marked.
|
|
25848
|
+
* Same `skipped` and `no-receipt` rules as `reportCondition`.
|
|
25849
|
+
*/
|
|
25850
|
+
async clearCondition(attempt) {
|
|
25851
|
+
if (this.#shutdown.signal.aborted)
|
|
25852
|
+
return "skipped";
|
|
25853
|
+
return this.#issuingCustody(attempt).clearCondition(attempt);
|
|
25854
|
+
}
|
|
25587
25855
|
/**
|
|
25588
25856
|
* Send on a vault route. `dispatch` builds and sends the request with the
|
|
25589
25857
|
* receipt's token and may be called twice, so it must be able to rebuild
|
|
@@ -25794,12 +26062,12 @@ function unreachableConnect2() {
|
|
|
25794
26062
|
return new ClaustrumUnreachableError();
|
|
25795
26063
|
}
|
|
25796
26064
|
function untilAborted(pending, signal) {
|
|
25797
|
-
return new Promise((
|
|
26065
|
+
return new Promise((resolve35, reject) => {
|
|
25798
26066
|
const abort = () => reject(signal.reason);
|
|
25799
26067
|
signal.addEventListener("abort", abort, { once: true });
|
|
25800
26068
|
pending.then((value) => {
|
|
25801
26069
|
signal.removeEventListener("abort", abort);
|
|
25802
|
-
|
|
26070
|
+
resolve35(value);
|
|
25803
26071
|
}, (error) => {
|
|
25804
26072
|
signal.removeEventListener("abort", abort);
|
|
25805
26073
|
reject(error);
|
|
@@ -26190,6 +26458,16 @@ var init_hub = __esm({
|
|
|
26190
26458
|
check();
|
|
26191
26459
|
return custody.reportFailure(attempt, status, source);
|
|
26192
26460
|
},
|
|
26461
|
+
reportCondition: async (attempt, input2) => {
|
|
26462
|
+
if (state2.released || generation.ended)
|
|
26463
|
+
return "skipped";
|
|
26464
|
+
return custody.reportCondition(attempt, input2);
|
|
26465
|
+
},
|
|
26466
|
+
clearCondition: async (attempt) => {
|
|
26467
|
+
if (state2.released || generation.ended)
|
|
26468
|
+
return "skipped";
|
|
26469
|
+
return custody.clearCondition(attempt);
|
|
26470
|
+
},
|
|
26193
26471
|
reportUsage: (input2) => {
|
|
26194
26472
|
if (!state2.released && !generation.ended)
|
|
26195
26473
|
custody.reportUsage(input2);
|
|
@@ -27864,9 +28142,11 @@ var init_pre_response_deadline = __esm({
|
|
|
27864
28142
|
this.cancelTimer = void 0;
|
|
27865
28143
|
}
|
|
27866
28144
|
resume() {
|
|
28145
|
+
const paused = !this.active;
|
|
27867
28146
|
this.active = true;
|
|
27868
28147
|
this.check();
|
|
27869
|
-
|
|
28148
|
+
if (paused)
|
|
28149
|
+
this.arm();
|
|
27870
28150
|
}
|
|
27871
28151
|
/** Cancel a response that arrives after its sender lost the abort race. */
|
|
27872
28152
|
open(work) {
|
|
@@ -28079,8 +28359,8 @@ function getDefaultTierId(allowedTiers) {
|
|
|
28079
28359
|
return allowedTiers[0]?.id;
|
|
28080
28360
|
}
|
|
28081
28361
|
function wait(ms) {
|
|
28082
|
-
return new Promise((
|
|
28083
|
-
setTimeout(
|
|
28362
|
+
return new Promise((resolve35) => {
|
|
28363
|
+
setTimeout(resolve35, ms);
|
|
28084
28364
|
});
|
|
28085
28365
|
}
|
|
28086
28366
|
function extractManagedProjectId(payload) {
|
|
@@ -28121,7 +28401,7 @@ function invalidateProjectContextCache(refresh) {
|
|
|
28121
28401
|
function clearProvisionFailedKeys() {
|
|
28122
28402
|
provisionFailedKeys.clear();
|
|
28123
28403
|
}
|
|
28124
|
-
async function loadManagedProject(accessToken, _projectId) {
|
|
28404
|
+
async function loadManagedProject(accessToken, _projectId, admit2) {
|
|
28125
28405
|
const requestBody = buildBootstrapRequestBody();
|
|
28126
28406
|
const loadHeaders = buildAntigravityHarnessBootstrapHeaders(accessToken);
|
|
28127
28407
|
const loadEndpoints = Array.from(/* @__PURE__ */ new Set([
|
|
@@ -28129,6 +28409,8 @@ async function loadManagedProject(accessToken, _projectId) {
|
|
|
28129
28409
|
...ANTIGRAVITY_ENDPOINT_FALLBACKS
|
|
28130
28410
|
]));
|
|
28131
28411
|
for (const baseEndpoint of loadEndpoints) {
|
|
28412
|
+
if (admit2)
|
|
28413
|
+
await admit2();
|
|
28132
28414
|
try {
|
|
28133
28415
|
const response = await fetchWithAgyCliTransport(`${baseEndpoint}/v1internal:loadCodeAssist`, {
|
|
28134
28416
|
method: "POST",
|
|
@@ -28148,7 +28430,7 @@ async function loadManagedProject(accessToken, _projectId) {
|
|
|
28148
28430
|
}
|
|
28149
28431
|
return null;
|
|
28150
28432
|
}
|
|
28151
|
-
async function onboardManagedProject(accessToken, tierId, projectId, attempts2 = 10, delayMs = 5e3) {
|
|
28433
|
+
async function onboardManagedProject(accessToken, tierId, projectId, attempts2 = 10, delayMs = 5e3, admit2) {
|
|
28152
28434
|
const requestBody = { tierId };
|
|
28153
28435
|
const onboardEndpoints = Array.from(/* @__PURE__ */ new Set([
|
|
28154
28436
|
ANTIGRAVITY_ENDPOINT_PROD,
|
|
@@ -28157,6 +28439,8 @@ async function onboardManagedProject(accessToken, tierId, projectId, attempts2 =
|
|
|
28157
28439
|
]));
|
|
28158
28440
|
for (const baseEndpoint of onboardEndpoints) {
|
|
28159
28441
|
for (let attempt = 0; attempt < attempts2; attempt += 1) {
|
|
28442
|
+
if (admit2)
|
|
28443
|
+
await admit2();
|
|
28160
28444
|
try {
|
|
28161
28445
|
const response = await fetchWithAgyCliTransport(`${baseEndpoint}/v1internal:onboardUser`, {
|
|
28162
28446
|
method: "POST",
|
|
@@ -28191,7 +28475,7 @@ async function onboardManagedProject(accessToken, tierId, projectId, attempts2 =
|
|
|
28191
28475
|
}
|
|
28192
28476
|
return void 0;
|
|
28193
28477
|
}
|
|
28194
|
-
async function ensureProjectContext(auth) {
|
|
28478
|
+
async function ensureProjectContext(auth, admit2) {
|
|
28195
28479
|
const accessToken = auth.access;
|
|
28196
28480
|
if (!accessToken) {
|
|
28197
28481
|
return { auth, effectiveProjectId: "" };
|
|
@@ -28235,7 +28519,7 @@ async function ensureProjectContext(auth) {
|
|
|
28235
28519
|
capturedTier
|
|
28236
28520
|
};
|
|
28237
28521
|
};
|
|
28238
|
-
const loadPayload = await loadManagedProject(accessToken, parts.projectId ?? fallbackProjectId);
|
|
28522
|
+
const loadPayload = await loadManagedProject(accessToken, parts.projectId ?? fallbackProjectId, admit2);
|
|
28239
28523
|
const capturedTierId = loadPayload?.currentTier?.id;
|
|
28240
28524
|
const paidTierId = typeof loadPayload?.paidTier === "string" ? loadPayload.paidTier : loadPayload?.paidTier?.id;
|
|
28241
28525
|
const tierFromPayload = capturedTierId ? {
|
|
@@ -28252,7 +28536,7 @@ async function ensureProjectContext(auth) {
|
|
|
28252
28536
|
tierId,
|
|
28253
28537
|
projectId: parts.projectId
|
|
28254
28538
|
});
|
|
28255
|
-
const provisionedProjectId = await onboardManagedProject(accessToken, tierId, parts.projectId);
|
|
28539
|
+
const provisionedProjectId = await onboardManagedProject(accessToken, tierId, parts.projectId, void 0, void 0, admit2);
|
|
28256
28540
|
if (provisionedProjectId) {
|
|
28257
28541
|
log3.debug("Successfully provisioned managed project", {
|
|
28258
28542
|
provisionedProjectId
|
|
@@ -30492,12 +30776,12 @@ var init_vault_provider_state = __esm({
|
|
|
30492
30776
|
function untilAborted2(pending, signal) {
|
|
30493
30777
|
if (!signal)
|
|
30494
30778
|
return pending;
|
|
30495
|
-
return new Promise((
|
|
30779
|
+
return new Promise((resolve35, reject) => {
|
|
30496
30780
|
const abort = () => reject(signal.reason);
|
|
30497
30781
|
signal.addEventListener("abort", abort, { once: true });
|
|
30498
30782
|
if (signal.aborted)
|
|
30499
30783
|
abort();
|
|
30500
|
-
pending.then(
|
|
30784
|
+
pending.then(resolve35, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
30501
30785
|
});
|
|
30502
30786
|
}
|
|
30503
30787
|
async function resolveClaustrumConnectionPath(explicit) {
|
|
@@ -30679,6 +30963,8 @@ function createAntigravityVaultAccountSource(options) {
|
|
|
30679
30963
|
return response;
|
|
30680
30964
|
},
|
|
30681
30965
|
reportServedStatus,
|
|
30966
|
+
reportCondition: async (admission, input2) => consumer.reportCondition(issuedEntry(admission).receipt, input2),
|
|
30967
|
+
clearCondition: async (admission) => consumer.clearCondition(issuedEntry(admission).receipt),
|
|
30682
30968
|
attribution: (admission) => {
|
|
30683
30969
|
issuedEntry(admission);
|
|
30684
30970
|
return Object.freeze({
|
|
@@ -31681,10 +31967,7 @@ function createVaultRequestCredentials(source, onAdmitted) {
|
|
|
31681
31967
|
const admission = await source.admit(account.route, signal);
|
|
31682
31968
|
if (onAdmitted)
|
|
31683
31969
|
onAdmitted.admitted(account, onAdmitted.source.attribution(admission));
|
|
31684
|
-
const grant = new VaultSendGrant(
|
|
31685
|
-
admission,
|
|
31686
|
-
(status) => source.reportServedStatus(admission, status)
|
|
31687
|
-
);
|
|
31970
|
+
const grant = new VaultSendGrant(admission, source);
|
|
31688
31971
|
issued.set(grant, admission);
|
|
31689
31972
|
return grant;
|
|
31690
31973
|
}
|
|
@@ -32103,12 +32386,12 @@ function createVaultAccountPool(options) {
|
|
|
32103
32386
|
try {
|
|
32104
32387
|
return await Promise.race([
|
|
32105
32388
|
read.then(() => true),
|
|
32106
|
-
new Promise((
|
|
32389
|
+
new Promise((resolve35, reject) => {
|
|
32107
32390
|
const abort = () => reject(signal?.reason);
|
|
32108
32391
|
signal?.addEventListener("abort", abort, { once: true });
|
|
32109
32392
|
detachAbort = () => signal?.removeEventListener("abort", abort);
|
|
32110
32393
|
if (remaining !== void 0)
|
|
32111
|
-
cancelTimer2 = schedule2(() =>
|
|
32394
|
+
cancelTimer2 = schedule2(() => resolve35(false), remaining);
|
|
32112
32395
|
if (signal?.aborted) abort();
|
|
32113
32396
|
})
|
|
32114
32397
|
]);
|
|
@@ -32197,7 +32480,7 @@ function vaultQuotaState(quota, at) {
|
|
|
32197
32480
|
}
|
|
32198
32481
|
async function checkVaultQuota(input2) {
|
|
32199
32482
|
const state2 = input2.pool.state;
|
|
32200
|
-
const
|
|
32483
|
+
const routes = input2.routes ?? input2.pool.selector.rows.map((row) => row.route);
|
|
32201
32484
|
const now2 = input2.now ?? (() => Date.now());
|
|
32202
32485
|
const reportError = (error) => {
|
|
32203
32486
|
try {
|
|
@@ -32208,11 +32491,11 @@ async function checkVaultQuota(input2) {
|
|
|
32208
32491
|
let checked = 0;
|
|
32209
32492
|
if (state2 === void 0) input2.onOutcome?.("state-invalid");
|
|
32210
32493
|
const readings = [];
|
|
32211
|
-
for (const
|
|
32494
|
+
for (const route of routes) {
|
|
32212
32495
|
if (input2.signal.aborted || state2 === void 0) break;
|
|
32213
32496
|
try {
|
|
32214
32497
|
input2.onStage?.("fetch");
|
|
32215
|
-
const answer = await input2.fetchReading(
|
|
32498
|
+
const answer = await input2.fetchReading(route, input2.signal);
|
|
32216
32499
|
input2.signal.throwIfAborted();
|
|
32217
32500
|
if (answer === void 0) {
|
|
32218
32501
|
input2.onOutcome?.("fetch-failed");
|
|
@@ -32236,7 +32519,7 @@ async function checkVaultQuota(input2) {
|
|
|
32236
32519
|
}
|
|
32237
32520
|
}
|
|
32238
32521
|
if (state2 === void 0 || readings.length === 0 || input2.signal.aborted)
|
|
32239
|
-
return { checked, notChecked:
|
|
32522
|
+
return { checked, notChecked: routes.length - checked };
|
|
32240
32523
|
let results;
|
|
32241
32524
|
try {
|
|
32242
32525
|
input2.onStage?.("commit");
|
|
@@ -32244,8 +32527,11 @@ async function checkVaultQuota(input2) {
|
|
|
32244
32527
|
results = await state2.recordQuotas(readings, input2.signal);
|
|
32245
32528
|
} catch (error) {
|
|
32246
32529
|
for (const _ of readings) reportError(error);
|
|
32247
|
-
return { checked, notChecked:
|
|
32530
|
+
return { checked, notChecked: routes.length - checked };
|
|
32248
32531
|
}
|
|
32532
|
+
const liveByRoute = new Map(
|
|
32533
|
+
input2.pool.selector.rows.map((row) => [row.route.routeId, row])
|
|
32534
|
+
);
|
|
32249
32535
|
for (const [at, { attribution, quota: reading }] of readings.entries()) {
|
|
32250
32536
|
const result = results[at];
|
|
32251
32537
|
if (result === void 0 || result.status === "refused") {
|
|
@@ -32263,17 +32549,15 @@ async function checkVaultQuota(input2) {
|
|
|
32263
32549
|
}
|
|
32264
32550
|
checked += 1;
|
|
32265
32551
|
input2.onOutcome?.("recorded");
|
|
32266
|
-
const live =
|
|
32267
|
-
|
|
32268
|
-
);
|
|
32269
|
-
if (live !== void 0) {
|
|
32552
|
+
const live = liveByRoute.get(attribution.routeId);
|
|
32553
|
+
if (live?.route.credentialId === attribution.credentialId && live.route.accountIdentity === attribution.accountIdentity) {
|
|
32270
32554
|
const cached = cachedQuotaOf(reading);
|
|
32271
32555
|
if (cached !== void 0) live.cachedQuota = cached;
|
|
32272
32556
|
live.cachedQuotaUpdatedAt = reading.cachedQuotaUpdatedAt ?? void 0;
|
|
32273
32557
|
input2.pool.selector.reconcileQuotaReading(live);
|
|
32274
32558
|
}
|
|
32275
32559
|
}
|
|
32276
|
-
return { checked, notChecked:
|
|
32560
|
+
return { checked, notChecked: routes.length - checked };
|
|
32277
32561
|
}
|
|
32278
32562
|
var VaultSendGrant, VAULT_REFRESH_STALL_MS, VAULT_DISPLAY_ROSTER_WAIT_MS;
|
|
32279
32563
|
var init_vault_request_credentials = __esm({
|
|
@@ -32287,7 +32571,9 @@ var init_vault_request_credentials = __esm({
|
|
|
32287
32571
|
recordVersion;
|
|
32288
32572
|
projectId;
|
|
32289
32573
|
report401;
|
|
32290
|
-
|
|
32574
|
+
reportCondition;
|
|
32575
|
+
clearCondition;
|
|
32576
|
+
constructor(admission, source) {
|
|
32291
32577
|
Object.defineProperty(this, "accessToken", {
|
|
32292
32578
|
value: admission.accessToken,
|
|
32293
32579
|
enumerable: false
|
|
@@ -32297,7 +32583,9 @@ var init_vault_request_credentials = __esm({
|
|
|
32297
32583
|
this.recordVersion = admission.recordVersion;
|
|
32298
32584
|
this.projectId = admission.projectId;
|
|
32299
32585
|
this.fromKeptReceipt = admission.fromKeptReceipt;
|
|
32300
|
-
this.report401 =
|
|
32586
|
+
this.report401 = (status) => source.reportServedStatus(admission, status);
|
|
32587
|
+
this.reportCondition = source.reportCondition?.bind(source, admission);
|
|
32588
|
+
this.clearCondition = source.clearCondition?.bind(source, admission);
|
|
32301
32589
|
}
|
|
32302
32590
|
};
|
|
32303
32591
|
VAULT_REFRESH_STALL_MS = 3e4;
|
|
@@ -32634,11 +32922,11 @@ function createOpenCodeVaultCustody(options) {
|
|
|
32634
32922
|
].join("\n");
|
|
32635
32923
|
const waitForApproval = async () => {
|
|
32636
32924
|
while (!closed2) {
|
|
32637
|
-
await new Promise((
|
|
32925
|
+
await new Promise((resolve35) => {
|
|
32638
32926
|
const done = () => {
|
|
32639
32927
|
clearTimeout(timer);
|
|
32640
32928
|
cancelWait = void 0;
|
|
32641
|
-
|
|
32929
|
+
resolve35();
|
|
32642
32930
|
};
|
|
32643
32931
|
const timer = setTimeout(done, 2e3);
|
|
32644
32932
|
timer.unref?.();
|
|
@@ -35634,13 +35922,13 @@ function closeDebugStream(state2) {
|
|
|
35634
35922
|
state2.logWriter = () => {
|
|
35635
35923
|
};
|
|
35636
35924
|
if (state2.logFilePath) liveLogFilePaths.delete(state2.logFilePath);
|
|
35637
|
-
return new Promise((
|
|
35638
|
-
current.once("close", () =>
|
|
35639
|
-
current.once("error", () =>
|
|
35925
|
+
return new Promise((resolve35) => {
|
|
35926
|
+
current.once("close", () => resolve35());
|
|
35927
|
+
current.once("error", () => resolve35());
|
|
35640
35928
|
try {
|
|
35641
35929
|
current.end();
|
|
35642
35930
|
} catch {
|
|
35643
|
-
|
|
35931
|
+
resolve35();
|
|
35644
35932
|
}
|
|
35645
35933
|
});
|
|
35646
35934
|
}
|
|
@@ -35905,13 +36193,13 @@ function closeDebugLog() {
|
|
|
35905
36193
|
if (!state2 || !current) return Promise.resolve();
|
|
35906
36194
|
state2.logStream = null;
|
|
35907
36195
|
if (state2.logFilePath) liveLogFilePaths.delete(state2.logFilePath);
|
|
35908
|
-
return new Promise((
|
|
35909
|
-
current.once("close", () =>
|
|
35910
|
-
current.once("error", () =>
|
|
36196
|
+
return new Promise((resolve35) => {
|
|
36197
|
+
current.once("close", () => resolve35());
|
|
36198
|
+
current.once("error", () => resolve35());
|
|
35911
36199
|
try {
|
|
35912
36200
|
current.end();
|
|
35913
36201
|
} catch {
|
|
35914
|
-
|
|
36202
|
+
resolve35();
|
|
35915
36203
|
}
|
|
35916
36204
|
});
|
|
35917
36205
|
}
|
|
@@ -36435,12 +36723,12 @@ async function startOAuthListener({
|
|
|
36435
36723
|
let resolveCallback;
|
|
36436
36724
|
let rejectCallback;
|
|
36437
36725
|
let timeoutHandle;
|
|
36438
|
-
const callbackPromise = new Promise((
|
|
36726
|
+
const callbackPromise = new Promise((resolve35, reject) => {
|
|
36439
36727
|
resolveCallback = (url) => {
|
|
36440
36728
|
if (settled) return;
|
|
36441
36729
|
settled = true;
|
|
36442
36730
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
36443
|
-
|
|
36731
|
+
resolve35(url);
|
|
36444
36732
|
};
|
|
36445
36733
|
rejectCallback = (error) => {
|
|
36446
36734
|
if (settled) return;
|
|
@@ -36599,7 +36887,7 @@ async function startOAuthListener({
|
|
|
36599
36887
|
});
|
|
36600
36888
|
});
|
|
36601
36889
|
const bindAddress = getBindAddress();
|
|
36602
|
-
await new Promise((
|
|
36890
|
+
await new Promise((resolve35, reject) => {
|
|
36603
36891
|
const handleError = (error) => {
|
|
36604
36892
|
server.off("error", handleError);
|
|
36605
36893
|
if (error.code === "EADDRINUSE") {
|
|
@@ -36615,7 +36903,7 @@ async function startOAuthListener({
|
|
|
36615
36903
|
server.once("error", handleError);
|
|
36616
36904
|
server.listen(port, bindAddress, () => {
|
|
36617
36905
|
server.off("error", handleError);
|
|
36618
|
-
|
|
36906
|
+
resolve35();
|
|
36619
36907
|
});
|
|
36620
36908
|
});
|
|
36621
36909
|
server.on("error", (error) => {
|
|
@@ -36623,7 +36911,7 @@ async function startOAuthListener({
|
|
|
36623
36911
|
});
|
|
36624
36912
|
return {
|
|
36625
36913
|
waitForCallback: () => callbackPromise,
|
|
36626
|
-
close: () => new Promise((
|
|
36914
|
+
close: () => new Promise((resolve35, reject) => {
|
|
36627
36915
|
server.close((error) => {
|
|
36628
36916
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
36629
36917
|
reject(error);
|
|
@@ -36632,7 +36920,7 @@ async function startOAuthListener({
|
|
|
36632
36920
|
if (!settled) {
|
|
36633
36921
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
36634
36922
|
}
|
|
36635
|
-
|
|
36923
|
+
resolve35();
|
|
36636
36924
|
});
|
|
36637
36925
|
})
|
|
36638
36926
|
};
|
|
@@ -36648,11 +36936,11 @@ var GA_POOL_PASTE_METHOD_ID = "antigravity-auth-pool-paste";
|
|
|
36648
36936
|
var GA_POOL_RECONNECT_METHOD_ID = "antigravity-auth-pool-reconnect";
|
|
36649
36937
|
var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
|
|
36650
36938
|
function abortable(pending, signal) {
|
|
36651
|
-
return new Promise((
|
|
36939
|
+
return new Promise((resolve35, reject) => {
|
|
36652
36940
|
const abort = () => reject(signal.reason);
|
|
36653
36941
|
if (signal.aborted) abort();
|
|
36654
36942
|
else signal.addEventListener("abort", abort, { once: true });
|
|
36655
|
-
void pending.then(
|
|
36943
|
+
void pending.then(resolve35, reject).finally(() => {
|
|
36656
36944
|
signal.removeEventListener("abort", abort);
|
|
36657
36945
|
});
|
|
36658
36946
|
});
|
|
@@ -38656,7 +38944,7 @@ function openSettings(definition, options) {
|
|
|
38656
38944
|
loaded = windowsSeen.get(path5) !== content;
|
|
38657
38945
|
windowsSeen.set(path5, content);
|
|
38658
38946
|
};
|
|
38659
|
-
const
|
|
38947
|
+
const readFile24 = async ([path5]) => {
|
|
38660
38948
|
let text2;
|
|
38661
38949
|
try {
|
|
38662
38950
|
text2 = await SettingsFs.readFile(path5, "utf8");
|
|
@@ -38693,7 +38981,7 @@ function openSettings(definition, options) {
|
|
|
38693
38981
|
snapshot: buildSettingsSnapshot(definition, file, parsed)
|
|
38694
38982
|
} : { status: "unparseable" };
|
|
38695
38983
|
};
|
|
38696
|
-
const outcome = process.platform === "win32" ? await
|
|
38984
|
+
const outcome = process.platform === "win32" ? await readFile24([file.path]) : await cache.read([file.path], readFile24);
|
|
38697
38985
|
const key2 = JSON.stringify([file.kind, file.path]);
|
|
38698
38986
|
if (currentSequence <= (committedSequences.get(key2) ?? 0))
|
|
38699
38987
|
return;
|
|
@@ -39871,6 +40159,25 @@ function selectBestVerificationUrl(urls) {
|
|
|
39871
40159
|
unique.sort((a, b) => score(b) - score(a));
|
|
39872
40160
|
return unique[0];
|
|
39873
40161
|
}
|
|
40162
|
+
function structuredVerificationUrl(bodyText) {
|
|
40163
|
+
const urls = /* @__PURE__ */ new Set();
|
|
40164
|
+
const collect = (payload) => {
|
|
40165
|
+
try {
|
|
40166
|
+
JSON.parse(payload, (key2, value) => {
|
|
40167
|
+
if (typeof value === "string" && /^(?:validation_url|verify_url|verification_url|url)$/i.test(key2) && /^https:\/\//i.test(decodeEscapedText(value).trim()))
|
|
40168
|
+
urls.add(value);
|
|
40169
|
+
return value;
|
|
40170
|
+
});
|
|
40171
|
+
} catch {
|
|
40172
|
+
}
|
|
40173
|
+
};
|
|
40174
|
+
collect(bodyText);
|
|
40175
|
+
for (const rawLine of bodyText.split("\n")) {
|
|
40176
|
+
const line = rawLine.trim();
|
|
40177
|
+
if (line.startsWith("data:")) collect(line.slice(5));
|
|
40178
|
+
}
|
|
40179
|
+
return selectBestVerificationUrl([...urls]);
|
|
40180
|
+
}
|
|
39874
40181
|
function extractAccountAccessErrorDetails(bodyText) {
|
|
39875
40182
|
const decodedBody = decodeEscapedText(bodyText);
|
|
39876
40183
|
const lowerBody = decodedBody.toLowerCase();
|
|
@@ -39948,11 +40255,13 @@ function extractAccountAccessErrorDetails(bodyText) {
|
|
|
39948
40255
|
(line) => line && !line.startsWith("data:") && /(verify|validation|required|ineligible)/i.test(line)
|
|
39949
40256
|
);
|
|
39950
40257
|
}
|
|
40258
|
+
const structuredVerifyUrl = structuredVerificationUrl(bodyText);
|
|
39951
40259
|
return {
|
|
39952
40260
|
validationRequired,
|
|
39953
40261
|
accountIneligible,
|
|
39954
40262
|
message,
|
|
39955
|
-
verifyUrl: selectBestVerificationUrl([...verificationUrls])
|
|
40263
|
+
verifyUrl: selectBestVerificationUrl([...verificationUrls]),
|
|
40264
|
+
...structuredVerifyUrl && { structuredVerifyUrl }
|
|
39956
40265
|
};
|
|
39957
40266
|
}
|
|
39958
40267
|
function buildAccountAccessProbeRequest(projectId) {
|
|
@@ -41133,9 +41442,9 @@ init_dist();
|
|
|
41133
41442
|
import { resolve as resolve24 } from "node:path";
|
|
41134
41443
|
|
|
41135
41444
|
// src/sidebar-state.ts
|
|
41445
|
+
import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync8, statSync as statSync6 } from "node:fs";
|
|
41136
41446
|
init_atomic_write();
|
|
41137
41447
|
init_file_lock();
|
|
41138
|
-
import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync8 } from "node:fs";
|
|
41139
41448
|
import { homedir as homedir7 } from "node:os";
|
|
41140
41449
|
import { dirname as dirname25, join as join23 } from "node:path";
|
|
41141
41450
|
|
|
@@ -41206,6 +41515,9 @@ function readSidebarState(path5 = getSidebarStateFile()) {
|
|
|
41206
41515
|
} catch {
|
|
41207
41516
|
return { ...DEFAULT_SIDEBAR_STATE };
|
|
41208
41517
|
}
|
|
41518
|
+
return parseSidebarState(raw);
|
|
41519
|
+
}
|
|
41520
|
+
function parseSidebarState(raw) {
|
|
41209
41521
|
let parsed;
|
|
41210
41522
|
try {
|
|
41211
41523
|
parsed = JSON.parse(raw);
|
|
@@ -41546,7 +41858,7 @@ function drainSidebarWrites() {
|
|
|
41546
41858
|
return sidebarWriteChain;
|
|
41547
41859
|
}
|
|
41548
41860
|
async function sleep3(ms) {
|
|
41549
|
-
await new Promise((
|
|
41861
|
+
await new Promise((resolve35) => setTimeout(resolve35, ms));
|
|
41550
41862
|
}
|
|
41551
41863
|
async function acquireSidebarLockWithRetry(stateFile) {
|
|
41552
41864
|
const start = Date.now();
|
|
@@ -41793,7 +42105,8 @@ function withSidebarPushAfterRefresh(manager, push) {
|
|
|
41793
42105
|
refreshOptions
|
|
41794
42106
|
);
|
|
41795
42107
|
const lastAccount = accounts[accounts.length - 1];
|
|
41796
|
-
if (shouldPush &&
|
|
42108
|
+
if (shouldPush && refreshOptions.publishSidebar !== false && lastAccount)
|
|
42109
|
+
await pushAfterRefresh(lastAccount);
|
|
41797
42110
|
return results;
|
|
41798
42111
|
})()
|
|
41799
42112
|
);
|
|
@@ -41828,10 +42141,29 @@ async function checkAccountsQuotaStandalone(accounts, options) {
|
|
|
41828
42141
|
}
|
|
41829
42142
|
}));
|
|
41830
42143
|
}
|
|
41831
|
-
|
|
42144
|
+
const refused2 = new AbortController();
|
|
42145
|
+
const admit2 = options.assertAdmission;
|
|
42146
|
+
const assertAdmission = admit2 && (async () => {
|
|
42147
|
+
refused2.signal.throwIfAborted();
|
|
42148
|
+
try {
|
|
42149
|
+
await admit2();
|
|
42150
|
+
} catch (error) {
|
|
42151
|
+
refused2.abort(error);
|
|
42152
|
+
throw error;
|
|
42153
|
+
}
|
|
42154
|
+
refused2.signal.throwIfAborted();
|
|
42155
|
+
});
|
|
42156
|
+
const results = await checkAccountsQuotaWith(
|
|
41832
42157
|
accounts,
|
|
41833
|
-
makeFetchAccountQuota(
|
|
42158
|
+
makeFetchAccountQuota(
|
|
42159
|
+
void 0,
|
|
42160
|
+
ANTIGRAVITY_PROVIDER_ID,
|
|
42161
|
+
void 0,
|
|
42162
|
+
assertAdmission
|
|
42163
|
+
)
|
|
41834
42164
|
);
|
|
42165
|
+
refused2.signal.throwIfAborted();
|
|
42166
|
+
return results;
|
|
41835
42167
|
}
|
|
41836
42168
|
async function pushSidebarQuotaSnapshot(getAccounts, backoffUntil = 0, getActiveIndexByFamily, options = {}) {
|
|
41837
42169
|
const accounts = getAccounts();
|
|
@@ -42105,14 +42437,14 @@ var LocalQuotaGrantStaleError = class extends Error {
|
|
|
42105
42437
|
name = "LocalQuotaGrantStaleError";
|
|
42106
42438
|
};
|
|
42107
42439
|
function untilQuotaAborted(pending, signal) {
|
|
42108
|
-
return new Promise((
|
|
42440
|
+
return new Promise((resolve35, reject) => {
|
|
42109
42441
|
const abort = () => reject(signal.reason);
|
|
42110
42442
|
if (signal.aborted) abort();
|
|
42111
42443
|
else signal.addEventListener("abort", abort, { once: true });
|
|
42112
42444
|
void pending.then(
|
|
42113
42445
|
(value) => {
|
|
42114
42446
|
signal.removeEventListener("abort", abort);
|
|
42115
|
-
|
|
42447
|
+
resolve35(value);
|
|
42116
42448
|
},
|
|
42117
42449
|
(error) => {
|
|
42118
42450
|
signal.removeEventListener("abort", abort);
|
|
@@ -42210,7 +42542,7 @@ function createAuthorizedFetchAccountQuota(options) {
|
|
|
42210
42542
|
}
|
|
42211
42543
|
};
|
|
42212
42544
|
}
|
|
42213
|
-
function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
42545
|
+
function makeFetchAccountQuota(client, providerId, fetchVia, assertAdmission) {
|
|
42214
42546
|
return async (account, signal, purpose = "required") => {
|
|
42215
42547
|
const index = 0;
|
|
42216
42548
|
const disabled = account.enabled === false;
|
|
@@ -42292,6 +42624,8 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
42292
42624
|
}
|
|
42293
42625
|
try {
|
|
42294
42626
|
if (accessTokenExpired(auth)) {
|
|
42627
|
+
if (assertAdmission) await assertAdmission();
|
|
42628
|
+
signal.throwIfAborted();
|
|
42295
42629
|
const refreshed = await refreshAccessToken(
|
|
42296
42630
|
auth,
|
|
42297
42631
|
client,
|
|
@@ -42305,7 +42639,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
42305
42639
|
}
|
|
42306
42640
|
auth = refreshed;
|
|
42307
42641
|
}
|
|
42308
|
-
const projectContext = await ensureProjectContext(auth);
|
|
42642
|
+
const projectContext = await ensureProjectContext(auth, assertAdmission);
|
|
42309
42643
|
auth = projectContext.auth;
|
|
42310
42644
|
const updatedAccount = applyAccountUpdates(
|
|
42311
42645
|
account,
|
|
@@ -42320,11 +42654,20 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
42320
42654
|
let fellBackToLegacy = false;
|
|
42321
42655
|
const authParts = parseRefreshParts(auth.refresh);
|
|
42322
42656
|
const managedProjectId = authParts.managedProjectId ?? account.managedProjectId;
|
|
42657
|
+
const guarded = assertAdmission ? async (url, init, extra) => {
|
|
42658
|
+
await assertAdmission();
|
|
42659
|
+
signal.throwIfAborted();
|
|
42660
|
+
return fetchWithActiveTimeout(
|
|
42661
|
+
url,
|
|
42662
|
+
{ ...init, signal },
|
|
42663
|
+
{ timeoutMs: extra.timeoutMs }
|
|
42664
|
+
);
|
|
42665
|
+
} : fetchVia;
|
|
42323
42666
|
const payloads = await fetchQuotaPayloads({
|
|
42324
42667
|
accessToken: auth.access ?? "",
|
|
42325
42668
|
managedProjectId,
|
|
42326
42669
|
projectId: projectContext.effectiveProjectId,
|
|
42327
|
-
fetchVia,
|
|
42670
|
+
fetchVia: guarded,
|
|
42328
42671
|
logger: log9
|
|
42329
42672
|
});
|
|
42330
42673
|
quotaResult = payloads.quota;
|
|
@@ -42569,12 +42912,13 @@ function createStoreQuotaService(options) {
|
|
|
42569
42912
|
if (options.mayRun && !await options.mayRun())
|
|
42570
42913
|
return { status: "discarded", result };
|
|
42571
42914
|
const held2 = target.rowRef === void 0 ? void 0 : heldAccount(manager, target.rowRef);
|
|
42572
|
-
if (held2 === void 0
|
|
42573
|
-
manager.updateQuotaCache(
|
|
42915
|
+
if (held2 === void 0 || result.checkedAt === void 0 || !manager.updateQuotaCache(
|
|
42574
42916
|
held2.index,
|
|
42575
42917
|
result.quota.groups,
|
|
42576
|
-
held2.parts.refreshToken
|
|
42577
|
-
|
|
42918
|
+
held2.parts.refreshToken,
|
|
42919
|
+
result.checkedAt
|
|
42920
|
+
))
|
|
42921
|
+
return { status: "discarded", result };
|
|
42578
42922
|
return {
|
|
42579
42923
|
status: "recorded",
|
|
42580
42924
|
result,
|
|
@@ -42894,12 +43238,12 @@ var BackgroundVaultQuotaRefresh = class {
|
|
|
42894
43238
|
outcome.reason = "no-rows";
|
|
42895
43239
|
return;
|
|
42896
43240
|
}
|
|
42897
|
-
const
|
|
43241
|
+
const dueRoutes = pool.selector.rows.filter((row) => {
|
|
42898
43242
|
const quota = quotaReadingForVaultRoute(row.route, state2);
|
|
42899
43243
|
const at = quota?.cachedQuotaUpdatedAt;
|
|
42900
43244
|
return quota?.cachedQuota == null || typeof at !== "number" || !Number.isFinite(at) || at < 0 || now2 - at >= threshold;
|
|
42901
|
-
});
|
|
42902
|
-
if (
|
|
43245
|
+
}).map((row) => row.route);
|
|
43246
|
+
if (dueRoutes.length === 0) {
|
|
42903
43247
|
outcome.reason = "fresh";
|
|
42904
43248
|
return;
|
|
42905
43249
|
}
|
|
@@ -42908,6 +43252,7 @@ var BackgroundVaultQuotaRefresh = class {
|
|
|
42908
43252
|
const report = await checkAndPublishVaultQuota(
|
|
42909
43253
|
{
|
|
42910
43254
|
pool,
|
|
43255
|
+
routes: dueRoutes,
|
|
42911
43256
|
signal: controller.signal,
|
|
42912
43257
|
now: this.now,
|
|
42913
43258
|
onStage: (stage) => {
|
|
@@ -43322,20 +43667,20 @@ import crypto2 from "node:crypto";
|
|
|
43322
43667
|
import { createHash as createHash14 } from "node:crypto";
|
|
43323
43668
|
|
|
43324
43669
|
// src/plugin/cache/signature-cache.ts
|
|
43670
|
+
init_atomic_write();
|
|
43325
43671
|
init_runtime_paths();
|
|
43326
|
-
import {
|
|
43327
|
-
|
|
43328
|
-
|
|
43329
|
-
readFileSync as readFileSync9,
|
|
43330
|
-
renameSync as renameSync4,
|
|
43331
|
-
unlinkSync as unlinkSync3,
|
|
43332
|
-
writeFileSync as writeFileSync2
|
|
43333
|
-
} from "node:fs";
|
|
43334
|
-
import { tmpdir as tmpdir3 } from "node:os";
|
|
43335
|
-
import { dirname as dirname26, join as join24 } from "node:path";
|
|
43672
|
+
import { existsSync as existsSync9, readFileSync as readFileSync9 } from "node:fs";
|
|
43673
|
+
import { readFile as readFile16 } from "node:fs/promises";
|
|
43674
|
+
import { resolve as resolve25 } from "node:path";
|
|
43336
43675
|
function getSignatureCacheFilePath() {
|
|
43337
43676
|
return stateHomeSignatureCacheFile();
|
|
43338
43677
|
}
|
|
43678
|
+
var MAX_ENTRIES = 4096;
|
|
43679
|
+
function newestEntries(entries) {
|
|
43680
|
+
if (entries.length <= MAX_ENTRIES) return entries;
|
|
43681
|
+
return entries.sort(([, a], [, b]) => a.timestamp - b.timestamp).slice(-MAX_ENTRIES);
|
|
43682
|
+
}
|
|
43683
|
+
var pendingWrites = /* @__PURE__ */ new Map();
|
|
43339
43684
|
var SignatureCache = class {
|
|
43340
43685
|
// In-memory cache: key -> entry with signature and optional thinking text
|
|
43341
43686
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -43350,6 +43695,8 @@ var SignatureCache = class {
|
|
|
43350
43695
|
now;
|
|
43351
43696
|
// State
|
|
43352
43697
|
dirty = false;
|
|
43698
|
+
revision = 0;
|
|
43699
|
+
pendingWrite;
|
|
43353
43700
|
writeTimer = null;
|
|
43354
43701
|
cleanupTimer = null;
|
|
43355
43702
|
// Statistics
|
|
@@ -43386,11 +43733,10 @@ var SignatureCache = class {
|
|
|
43386
43733
|
*/
|
|
43387
43734
|
store(key2, signature) {
|
|
43388
43735
|
if (!this.enabled) return;
|
|
43389
|
-
this.
|
|
43736
|
+
this.storeEntry(key2, {
|
|
43390
43737
|
value: signature,
|
|
43391
43738
|
timestamp: this.now()
|
|
43392
43739
|
});
|
|
43393
|
-
this.dirty = true;
|
|
43394
43740
|
}
|
|
43395
43741
|
/**
|
|
43396
43742
|
* Retrieve a signature from the cache.
|
|
@@ -43441,13 +43787,29 @@ var SignatureCache = class {
|
|
|
43441
43787
|
*/
|
|
43442
43788
|
storeThinking(key2, thinkingText, signature, toolIds) {
|
|
43443
43789
|
if (!this.enabled || !thinkingText || !signature) return;
|
|
43444
|
-
this.
|
|
43790
|
+
this.storeEntry(key2, {
|
|
43445
43791
|
value: signature,
|
|
43446
43792
|
timestamp: this.now(),
|
|
43447
43793
|
thinkingText,
|
|
43448
43794
|
textPreview: thinkingText.slice(0, 100),
|
|
43449
43795
|
toolIds
|
|
43450
43796
|
});
|
|
43797
|
+
}
|
|
43798
|
+
storeEntry(key2, entry) {
|
|
43799
|
+
this.cache.delete(key2);
|
|
43800
|
+
this.cache.set(key2, entry);
|
|
43801
|
+
if (this.cache.size > MAX_ENTRIES) {
|
|
43802
|
+
let oldest;
|
|
43803
|
+
let oldestTimestamp = Number.POSITIVE_INFINITY;
|
|
43804
|
+
for (const [candidate, value] of this.cache) {
|
|
43805
|
+
if (oldest === void 0 || value.timestamp < oldestTimestamp) {
|
|
43806
|
+
oldest = candidate;
|
|
43807
|
+
oldestTimestamp = value.timestamp;
|
|
43808
|
+
}
|
|
43809
|
+
}
|
|
43810
|
+
if (oldest !== void 0) this.cache.delete(oldest);
|
|
43811
|
+
}
|
|
43812
|
+
this.revision++;
|
|
43451
43813
|
this.dirty = true;
|
|
43452
43814
|
}
|
|
43453
43815
|
/**
|
|
@@ -43516,7 +43878,17 @@ var SignatureCache = class {
|
|
|
43516
43878
|
*/
|
|
43517
43879
|
async flush() {
|
|
43518
43880
|
if (!this.enabled) return true;
|
|
43519
|
-
|
|
43881
|
+
const path5 = resolve25(this.cacheFilePath);
|
|
43882
|
+
const previous = pendingWrites.get(path5) ?? Promise.resolve(true);
|
|
43883
|
+
const writing = previous.then(() => this.saveToDisk());
|
|
43884
|
+
this.pendingWrite = writing;
|
|
43885
|
+
pendingWrites.set(path5, writing);
|
|
43886
|
+
try {
|
|
43887
|
+
return await writing;
|
|
43888
|
+
} finally {
|
|
43889
|
+
if (this.pendingWrite === writing) this.pendingWrite = void 0;
|
|
43890
|
+
if (pendingWrites.get(path5) === writing) pendingWrites.delete(path5);
|
|
43891
|
+
}
|
|
43520
43892
|
}
|
|
43521
43893
|
/**
|
|
43522
43894
|
* Graceful shutdown: stop timers and flush to disk.
|
|
@@ -43531,7 +43903,7 @@ var SignatureCache = class {
|
|
|
43531
43903
|
this.cleanupTimer = null;
|
|
43532
43904
|
}
|
|
43533
43905
|
if (this.dirty && this.enabled) {
|
|
43534
|
-
this.
|
|
43906
|
+
void this.flush();
|
|
43535
43907
|
}
|
|
43536
43908
|
}
|
|
43537
43909
|
// ===========================================================================
|
|
@@ -43566,6 +43938,9 @@ var SignatureCache = class {
|
|
|
43566
43938
|
_expired++;
|
|
43567
43939
|
}
|
|
43568
43940
|
}
|
|
43941
|
+
if (this.cache.size > MAX_ENTRIES) {
|
|
43942
|
+
this.cache = new Map(newestEntries([...this.cache]));
|
|
43943
|
+
}
|
|
43569
43944
|
} catch {
|
|
43570
43945
|
}
|
|
43571
43946
|
}
|
|
@@ -43573,22 +43948,17 @@ var SignatureCache = class {
|
|
|
43573
43948
|
* Save cache to disk with atomic write pattern.
|
|
43574
43949
|
* Merges with existing disk entries that haven't expired.
|
|
43575
43950
|
*/
|
|
43576
|
-
saveToDisk() {
|
|
43951
|
+
async saveToDisk() {
|
|
43577
43952
|
try {
|
|
43578
|
-
const dir = dirname26(this.cacheFilePath);
|
|
43579
|
-
if (!existsSync9(dir)) {
|
|
43580
|
-
mkdirSync4(dir, { recursive: true });
|
|
43581
|
-
}
|
|
43582
|
-
const now2 = this.now();
|
|
43583
43953
|
let existingEntries = {};
|
|
43584
|
-
|
|
43585
|
-
|
|
43586
|
-
|
|
43587
|
-
|
|
43588
|
-
|
|
43589
|
-
} catch {
|
|
43590
|
-
}
|
|
43954
|
+
try {
|
|
43955
|
+
const content = await readFile16(this.cacheFilePath, "utf-8");
|
|
43956
|
+
const data = JSON.parse(content);
|
|
43957
|
+
existingEntries = data.entries || {};
|
|
43958
|
+
} catch {
|
|
43591
43959
|
}
|
|
43960
|
+
const now2 = this.now();
|
|
43961
|
+
const revision = this.revision;
|
|
43592
43962
|
const validDiskEntries = {};
|
|
43593
43963
|
for (const [key2, entry] of Object.entries(existingEntries)) {
|
|
43594
43964
|
const age = now2 - entry.timestamp;
|
|
@@ -43607,7 +43977,9 @@ var SignatureCache = class {
|
|
|
43607
43977
|
version: "1.0",
|
|
43608
43978
|
memory_ttl_seconds: this.retentionMemoryTtlMs / 1e3,
|
|
43609
43979
|
disk_ttl_seconds: this.retentionDiskTtlMs / 1e3,
|
|
43610
|
-
entries:
|
|
43980
|
+
entries: Object.fromEntries(
|
|
43981
|
+
newestEntries(Object.entries(mergedEntries))
|
|
43982
|
+
),
|
|
43611
43983
|
statistics: {
|
|
43612
43984
|
memory_hits: this.stats.memoryHits,
|
|
43613
43985
|
disk_hits: this.stats.diskHits,
|
|
@@ -43616,22 +43988,9 @@ var SignatureCache = class {
|
|
|
43616
43988
|
last_write: now2
|
|
43617
43989
|
}
|
|
43618
43990
|
};
|
|
43619
|
-
|
|
43620
|
-
tmpdir3(),
|
|
43621
|
-
`antigravity-cache-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`
|
|
43622
|
-
);
|
|
43623
|
-
writeFileSync2(tmpPath, JSON.stringify(cacheData, null, 2), "utf-8");
|
|
43624
|
-
try {
|
|
43625
|
-
renameSync4(tmpPath, this.cacheFilePath);
|
|
43626
|
-
} catch {
|
|
43627
|
-
writeFileSync2(this.cacheFilePath, readFileSync9(tmpPath));
|
|
43628
|
-
try {
|
|
43629
|
-
unlinkSync3(tmpPath);
|
|
43630
|
-
} catch {
|
|
43631
|
-
}
|
|
43632
|
-
}
|
|
43991
|
+
await writeJsonAtomic(this.cacheFilePath, cacheData);
|
|
43633
43992
|
this.stats.writes++;
|
|
43634
|
-
this.dirty = false;
|
|
43993
|
+
if (revision === this.revision) this.dirty = false;
|
|
43635
43994
|
return true;
|
|
43636
43995
|
} catch {
|
|
43637
43996
|
return false;
|
|
@@ -43654,8 +44013,8 @@ var SignatureCache = class {
|
|
|
43654
44013
|
}
|
|
43655
44014
|
startWriteTimer() {
|
|
43656
44015
|
this.writeTimer = setInterval(() => {
|
|
43657
|
-
if (this.dirty) {
|
|
43658
|
-
this.
|
|
44016
|
+
if (this.dirty && !this.pendingWrite) {
|
|
44017
|
+
void this.flush();
|
|
43659
44018
|
}
|
|
43660
44019
|
}, this.writeIntervalMs);
|
|
43661
44020
|
}
|
|
@@ -43834,11 +44193,18 @@ function createSignatureProcessState(options = {}) {
|
|
|
43834
44193
|
updateRetention(shared4.path);
|
|
43835
44194
|
return;
|
|
43836
44195
|
}
|
|
43837
|
-
|
|
44196
|
+
const finalWrite = shared4.cache.flush();
|
|
44197
|
+
shared4.finalWrite = finalWrite;
|
|
43838
44198
|
try {
|
|
43839
|
-
await
|
|
44199
|
+
await finalWrite;
|
|
43840
44200
|
} finally {
|
|
43841
|
-
shared4.
|
|
44201
|
+
if (shared4.finalWrite === finalWrite) {
|
|
44202
|
+
shared4.finalWrite = void 0;
|
|
44203
|
+
if (shared4.owners.size === 0) {
|
|
44204
|
+
disks.delete(shared4.path);
|
|
44205
|
+
shared4.cache.shutdown();
|
|
44206
|
+
}
|
|
44207
|
+
}
|
|
43842
44208
|
}
|
|
43843
44209
|
};
|
|
43844
44210
|
return {
|
|
@@ -43863,7 +44229,10 @@ function createSignatureProcessState(options = {}) {
|
|
|
43863
44229
|
pathReaders.add(consumer);
|
|
43864
44230
|
updateRetention(path5);
|
|
43865
44231
|
}
|
|
43866
|
-
const readableCache = () =>
|
|
44232
|
+
const readableCache = () => {
|
|
44233
|
+
const current = shared4 ?? (path5 ? disks.get(path5) : void 0);
|
|
44234
|
+
if (current?.owners.size) return current.cache;
|
|
44235
|
+
};
|
|
43867
44236
|
const signatureStore = createSignatureStore();
|
|
43868
44237
|
let disposed = false;
|
|
43869
44238
|
return {
|
|
@@ -43971,13 +44340,13 @@ function clearSignatureCache(sessionId) {
|
|
|
43971
44340
|
}
|
|
43972
44341
|
|
|
43973
44342
|
// src/plugin/image-saver.ts
|
|
43974
|
-
import { chmodSync as chmodSync4, existsSync as existsSync10, mkdirSync as
|
|
44343
|
+
import { chmodSync as chmodSync4, existsSync as existsSync10, mkdirSync as mkdirSync4, writeFileSync as writeFileSync2 } from "node:fs";
|
|
43975
44344
|
import { homedir as homedir8 } from "node:os";
|
|
43976
|
-
import { join as
|
|
44345
|
+
import { join as join24 } from "node:path";
|
|
43977
44346
|
function getImageOutputDir(outputDir) {
|
|
43978
|
-
const resolved = outputDir ??
|
|
44347
|
+
const resolved = outputDir ?? join24(homedir8(), ".opencode", "generated-images");
|
|
43979
44348
|
if (!existsSync10(resolved)) {
|
|
43980
|
-
|
|
44349
|
+
mkdirSync4(resolved, { recursive: true, mode: 448 });
|
|
43981
44350
|
}
|
|
43982
44351
|
chmodSync4(resolved, 448);
|
|
43983
44352
|
return resolved;
|
|
@@ -43998,8 +44367,8 @@ function generateImageFilename(mimeType) {
|
|
|
43998
44367
|
function saveImageToDisk(base64Data, mimeType, outputDir) {
|
|
43999
44368
|
try {
|
|
44000
44369
|
const resolvedOutputDir = getImageOutputDir(outputDir);
|
|
44001
|
-
const filePath =
|
|
44002
|
-
|
|
44370
|
+
const filePath = join24(resolvedOutputDir, generateImageFilename(mimeType));
|
|
44371
|
+
writeFileSync2(filePath, Buffer.from(base64Data, "base64"), { mode: 384 });
|
|
44003
44372
|
chmodSync4(filePath, 384);
|
|
44004
44373
|
return filePath;
|
|
44005
44374
|
} catch (error) {
|
|
@@ -44442,6 +44811,49 @@ data: ${JSON.stringify(syntheticUsage)}
|
|
|
44442
44811
|
});
|
|
44443
44812
|
}
|
|
44444
44813
|
|
|
44814
|
+
// src/plugin/core/streaming/displayed-thinking.ts
|
|
44815
|
+
var MAX_DISPLAYED_THINKING_SESSIONS = 256;
|
|
44816
|
+
var MAX_DISPLAYED_THINKING_PER_SESSION = 512;
|
|
44817
|
+
var BoundedHashSet = class extends Set {
|
|
44818
|
+
constructor(limit) {
|
|
44819
|
+
super();
|
|
44820
|
+
this.limit = limit;
|
|
44821
|
+
}
|
|
44822
|
+
limit;
|
|
44823
|
+
add(value) {
|
|
44824
|
+
if (!this.has(value) && this.size >= this.limit) {
|
|
44825
|
+
const oldest = this.values().next().value;
|
|
44826
|
+
if (oldest !== void 0) this.delete(oldest);
|
|
44827
|
+
}
|
|
44828
|
+
return super.add(value);
|
|
44829
|
+
}
|
|
44830
|
+
};
|
|
44831
|
+
function createDisplayedThinkingRegistry(limits = {}) {
|
|
44832
|
+
const maxSessions = limits.sessions ?? MAX_DISPLAYED_THINKING_SESSIONS;
|
|
44833
|
+
const perSession = limits.perSession ?? MAX_DISPLAYED_THINKING_PER_SESSION;
|
|
44834
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
44835
|
+
return {
|
|
44836
|
+
forSession(sessionKey) {
|
|
44837
|
+
if (!sessionKey) return void 0;
|
|
44838
|
+
let hashes = sessions.get(sessionKey);
|
|
44839
|
+
if (hashes) {
|
|
44840
|
+
sessions.delete(sessionKey);
|
|
44841
|
+
} else {
|
|
44842
|
+
hashes = new BoundedHashSet(perSession);
|
|
44843
|
+
if (sessions.size >= maxSessions) {
|
|
44844
|
+
const oldest = sessions.keys().next().value;
|
|
44845
|
+
if (oldest !== void 0) sessions.delete(oldest);
|
|
44846
|
+
}
|
|
44847
|
+
}
|
|
44848
|
+
sessions.set(sessionKey, hashes);
|
|
44849
|
+
return hashes;
|
|
44850
|
+
},
|
|
44851
|
+
get sessionCount() {
|
|
44852
|
+
return sessions.size;
|
|
44853
|
+
}
|
|
44854
|
+
};
|
|
44855
|
+
}
|
|
44856
|
+
|
|
44445
44857
|
// src/plugin/request.ts
|
|
44446
44858
|
init_debug();
|
|
44447
44859
|
|
|
@@ -44449,12 +44861,12 @@ init_debug();
|
|
|
44449
44861
|
init_dist();
|
|
44450
44862
|
init_logging_utils();
|
|
44451
44863
|
import { createHash as createHash15 } from "node:crypto";
|
|
44452
|
-
import { appendFileSync as appendFileSync4, mkdirSync as
|
|
44453
|
-
import { tmpdir as
|
|
44454
|
-
import { join as
|
|
44864
|
+
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync5, writeFileSync as writeFileSync3 } from "node:fs";
|
|
44865
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
44866
|
+
import { join as join25 } from "node:path";
|
|
44455
44867
|
var DUMP_STATUS_TITLE = "## Gemini Dump Status";
|
|
44456
44868
|
var DUMP_DIR_ENV = "OPENCODE_ANTIGRAVITY_GEMINI_DUMP_DIR";
|
|
44457
|
-
var DEFAULT_DUMP_DIR =
|
|
44869
|
+
var DEFAULT_DUMP_DIR = join25(tmpdir3(), "opencode-antigravity-gemini-dumps");
|
|
44458
44870
|
var DUMP_DIR_MODE = 448;
|
|
44459
44871
|
var DUMP_FILE_MODE = 384;
|
|
44460
44872
|
var nextDumpId = 0;
|
|
@@ -44586,7 +44998,7 @@ function bodyStructureSummary(bodyText) {
|
|
|
44586
44998
|
};
|
|
44587
44999
|
}
|
|
44588
45000
|
function writeJson(path5, value) {
|
|
44589
|
-
|
|
45001
|
+
writeFileSync3(path5, `${JSON.stringify(value, null, 2)}
|
|
44590
45002
|
`, {
|
|
44591
45003
|
encoding: "utf8",
|
|
44592
45004
|
mode: DUMP_FILE_MODE
|
|
@@ -44608,8 +45020,8 @@ function writeGeminiDump(input2) {
|
|
|
44608
45020
|
nextDumpId += 1;
|
|
44609
45021
|
const id = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${String(nextDumpId).padStart(5, "0")}-${input2.streaming ? "stream" : "json"}`;
|
|
44610
45022
|
const dumpDir = getGeminiDumpDirectory();
|
|
44611
|
-
const prefix =
|
|
44612
|
-
|
|
45023
|
+
const prefix = join25(dumpDir, id);
|
|
45024
|
+
mkdirSync5(dumpDir, { recursive: true, mode: DUMP_DIR_MODE });
|
|
44613
45025
|
const context = {
|
|
44614
45026
|
id,
|
|
44615
45027
|
files: {
|
|
@@ -44637,11 +45049,11 @@ function writeGeminiDump(input2) {
|
|
|
44637
45049
|
}
|
|
44638
45050
|
}
|
|
44639
45051
|
};
|
|
44640
|
-
|
|
45052
|
+
writeFileSync3(context.files.request, redactJsonBodyString(input2.body), {
|
|
44641
45053
|
encoding: "utf8",
|
|
44642
45054
|
mode: DUMP_FILE_MODE
|
|
44643
45055
|
});
|
|
44644
|
-
|
|
45056
|
+
writeFileSync3(context.files.response, "", {
|
|
44645
45057
|
encoding: "utf8",
|
|
44646
45058
|
mode: DUMP_FILE_MODE
|
|
44647
45059
|
});
|
|
@@ -44693,27 +45105,27 @@ init_logger4();
|
|
|
44693
45105
|
// src/plugin/recovery/storage.ts
|
|
44694
45106
|
import {
|
|
44695
45107
|
existsSync as existsSync11,
|
|
44696
|
-
mkdirSync as
|
|
45108
|
+
mkdirSync as mkdirSync6,
|
|
44697
45109
|
readdirSync as readdirSync2,
|
|
44698
45110
|
readFileSync as readFileSync10,
|
|
44699
|
-
unlinkSync as
|
|
44700
|
-
writeFileSync as
|
|
45111
|
+
unlinkSync as unlinkSync3,
|
|
45112
|
+
writeFileSync as writeFileSync4
|
|
44701
45113
|
} from "node:fs";
|
|
44702
|
-
import { join as
|
|
45114
|
+
import { join as join27 } from "node:path";
|
|
44703
45115
|
|
|
44704
45116
|
// src/plugin/recovery/constants.ts
|
|
44705
45117
|
import { homedir as homedir9 } from "node:os";
|
|
44706
|
-
import { join as
|
|
45118
|
+
import { join as join26 } from "node:path";
|
|
44707
45119
|
function getXdgData() {
|
|
44708
45120
|
const platform = process.platform;
|
|
44709
45121
|
if (platform === "win32") {
|
|
44710
|
-
return process.env.APPDATA ||
|
|
45122
|
+
return process.env.APPDATA || join26(homedir9(), "AppData", "Roaming");
|
|
44711
45123
|
}
|
|
44712
|
-
return process.env.XDG_DATA_HOME ||
|
|
45124
|
+
return process.env.XDG_DATA_HOME || join26(homedir9(), ".local", "share");
|
|
44713
45125
|
}
|
|
44714
|
-
var OPENCODE_STORAGE =
|
|
44715
|
-
var MESSAGE_STORAGE =
|
|
44716
|
-
var PART_STORAGE =
|
|
45126
|
+
var OPENCODE_STORAGE = join26(getXdgData(), "opencode", "storage");
|
|
45127
|
+
var MESSAGE_STORAGE = join26(OPENCODE_STORAGE, "message");
|
|
45128
|
+
var PART_STORAGE = join26(OPENCODE_STORAGE, "part");
|
|
44717
45129
|
var THINKING_TYPES = /* @__PURE__ */ new Set([
|
|
44718
45130
|
"thinking",
|
|
44719
45131
|
"redacted_thinking",
|
|
@@ -44723,13 +45135,13 @@ var THINKING_TYPES = /* @__PURE__ */ new Set([
|
|
|
44723
45135
|
// src/plugin/recovery/storage.ts
|
|
44724
45136
|
function getMessageDir(sessionID) {
|
|
44725
45137
|
if (!existsSync11(MESSAGE_STORAGE)) return "";
|
|
44726
|
-
const directPath =
|
|
45138
|
+
const directPath = join27(MESSAGE_STORAGE, sessionID);
|
|
44727
45139
|
if (existsSync11(directPath)) {
|
|
44728
45140
|
return directPath;
|
|
44729
45141
|
}
|
|
44730
45142
|
try {
|
|
44731
45143
|
for (const dir of readdirSync2(MESSAGE_STORAGE)) {
|
|
44732
|
-
const sessionPath =
|
|
45144
|
+
const sessionPath = join27(MESSAGE_STORAGE, dir, sessionID);
|
|
44733
45145
|
if (existsSync11(sessionPath)) {
|
|
44734
45146
|
return sessionPath;
|
|
44735
45147
|
}
|
|
@@ -44746,7 +45158,7 @@ function readMessages(sessionID) {
|
|
|
44746
45158
|
for (const file of readdirSync2(messageDir)) {
|
|
44747
45159
|
if (!file.endsWith(".json")) continue;
|
|
44748
45160
|
try {
|
|
44749
|
-
const content = readFileSync10(
|
|
45161
|
+
const content = readFileSync10(join27(messageDir, file), "utf-8");
|
|
44750
45162
|
messages.push(JSON.parse(content));
|
|
44751
45163
|
} catch {
|
|
44752
45164
|
}
|
|
@@ -44762,14 +45174,14 @@ function readMessages(sessionID) {
|
|
|
44762
45174
|
});
|
|
44763
45175
|
}
|
|
44764
45176
|
function readParts(messageID) {
|
|
44765
|
-
const partDir =
|
|
45177
|
+
const partDir = join27(PART_STORAGE, messageID);
|
|
44766
45178
|
if (!existsSync11(partDir)) return [];
|
|
44767
45179
|
const parts = [];
|
|
44768
45180
|
try {
|
|
44769
45181
|
for (const file of readdirSync2(partDir)) {
|
|
44770
45182
|
if (!file.endsWith(".json")) continue;
|
|
44771
45183
|
try {
|
|
44772
|
-
const content = readFileSync10(
|
|
45184
|
+
const content = readFileSync10(join27(partDir, file), "utf-8");
|
|
44773
45185
|
parts.push(JSON.parse(content));
|
|
44774
45186
|
} catch {
|
|
44775
45187
|
}
|
|
@@ -44811,10 +45223,10 @@ function findMessagesWithOrphanThinking(sessionID) {
|
|
|
44811
45223
|
return result;
|
|
44812
45224
|
}
|
|
44813
45225
|
function prependThinkingPart(sessionID, messageID) {
|
|
44814
|
-
const partDir =
|
|
45226
|
+
const partDir = join27(PART_STORAGE, messageID);
|
|
44815
45227
|
try {
|
|
44816
45228
|
if (!existsSync11(partDir)) {
|
|
44817
|
-
|
|
45229
|
+
mkdirSync6(partDir, { recursive: true });
|
|
44818
45230
|
}
|
|
44819
45231
|
const partId = "prt_0000000000_thinking";
|
|
44820
45232
|
const part = {
|
|
@@ -44825,8 +45237,8 @@ function prependThinkingPart(sessionID, messageID) {
|
|
|
44825
45237
|
thinking: "",
|
|
44826
45238
|
synthetic: true
|
|
44827
45239
|
};
|
|
44828
|
-
|
|
44829
|
-
|
|
45240
|
+
writeFileSync4(
|
|
45241
|
+
join27(partDir, `${partId}.json`),
|
|
44830
45242
|
JSON.stringify(part, null, 2)
|
|
44831
45243
|
);
|
|
44832
45244
|
return true;
|
|
@@ -44835,18 +45247,18 @@ function prependThinkingPart(sessionID, messageID) {
|
|
|
44835
45247
|
}
|
|
44836
45248
|
}
|
|
44837
45249
|
function stripThinkingParts(messageID) {
|
|
44838
|
-
const partDir =
|
|
45250
|
+
const partDir = join27(PART_STORAGE, messageID);
|
|
44839
45251
|
if (!existsSync11(partDir)) return false;
|
|
44840
45252
|
let anyRemoved = false;
|
|
44841
45253
|
try {
|
|
44842
45254
|
for (const file of readdirSync2(partDir)) {
|
|
44843
45255
|
if (!file.endsWith(".json")) continue;
|
|
44844
45256
|
try {
|
|
44845
|
-
const filePath =
|
|
45257
|
+
const filePath = join27(partDir, file);
|
|
44846
45258
|
const content = readFileSync10(filePath, "utf-8");
|
|
44847
45259
|
const part = JSON.parse(content);
|
|
44848
45260
|
if (THINKING_TYPES.has(part.type)) {
|
|
44849
|
-
|
|
45261
|
+
unlinkSync3(filePath);
|
|
44850
45262
|
anyRemoved = true;
|
|
44851
45263
|
}
|
|
44852
45264
|
} catch {
|
|
@@ -46139,6 +46551,9 @@ function fixToolResponseGrouping(contents) {
|
|
|
46139
46551
|
const newContents = [];
|
|
46140
46552
|
const pendingGroups = [];
|
|
46141
46553
|
const collectedResponses = /* @__PURE__ */ new Map();
|
|
46554
|
+
const arrivalById = /* @__PURE__ */ new Map();
|
|
46555
|
+
let arrivals = 0;
|
|
46556
|
+
const idsByName = /* @__PURE__ */ new Map();
|
|
46142
46557
|
for (const content of contents) {
|
|
46143
46558
|
const role = content.role;
|
|
46144
46559
|
const parts = content.parts || [];
|
|
@@ -46148,6 +46563,15 @@ function fixToolResponseGrouping(contents) {
|
|
|
46148
46563
|
const respId = resp.functionResponse?.id || "";
|
|
46149
46564
|
if (respId && !collectedResponses.has(respId)) {
|
|
46150
46565
|
collectedResponses.set(respId, resp);
|
|
46566
|
+
const arrival = arrivals++;
|
|
46567
|
+
arrivalById.set(respId, arrival);
|
|
46568
|
+
const name = resp.functionResponse?.name || "";
|
|
46569
|
+
let queue2 = idsByName.get(name);
|
|
46570
|
+
if (!queue2) {
|
|
46571
|
+
queue2 = { entries: [], head: 0 };
|
|
46572
|
+
idsByName.set(name, queue2);
|
|
46573
|
+
}
|
|
46574
|
+
queue2.entries.push({ id: respId, arrival });
|
|
46151
46575
|
}
|
|
46152
46576
|
}
|
|
46153
46577
|
for (let i = pendingGroups.length - 1; i >= 0; i--) {
|
|
@@ -46185,7 +46609,20 @@ function fixToolResponseGrouping(contents) {
|
|
|
46185
46609
|
newContents.push(content);
|
|
46186
46610
|
}
|
|
46187
46611
|
}
|
|
46612
|
+
const firstCollectedNamed = (name) => {
|
|
46613
|
+
const queue2 = idsByName.get(name);
|
|
46614
|
+
if (!queue2) return null;
|
|
46615
|
+
while (queue2.head < queue2.entries.length) {
|
|
46616
|
+
const entry = queue2.entries[queue2.head];
|
|
46617
|
+
if (collectedResponses.has(entry.id) && arrivalById.get(entry.id) === entry.arrival) {
|
|
46618
|
+
return entry.id;
|
|
46619
|
+
}
|
|
46620
|
+
queue2.head++;
|
|
46621
|
+
}
|
|
46622
|
+
return null;
|
|
46623
|
+
};
|
|
46188
46624
|
pendingGroups.sort((a, b) => b.insertAfterIdx - a.insertAfterIdx);
|
|
46625
|
+
const insertedAfter = /* @__PURE__ */ new Map();
|
|
46189
46626
|
for (const group of pendingGroups) {
|
|
46190
46627
|
const groupResponses = [];
|
|
46191
46628
|
for (let i = 0; i < group.ids.length; i++) {
|
|
@@ -46196,20 +46633,9 @@ function fixToolResponseGrouping(contents) {
|
|
|
46196
46633
|
collectedResponses.delete(expectedId);
|
|
46197
46634
|
} else if (collectedResponses.size > 0) {
|
|
46198
46635
|
let matchedId = null;
|
|
46199
|
-
|
|
46200
|
-
const orphanName = orphanResp.functionResponse?.name || "";
|
|
46201
|
-
if (orphanName === expectedName) {
|
|
46202
|
-
matchedId = orphanId;
|
|
46203
|
-
break;
|
|
46204
|
-
}
|
|
46205
|
-
}
|
|
46636
|
+
matchedId = firstCollectedNamed(expectedName);
|
|
46206
46637
|
if (!matchedId) {
|
|
46207
|
-
|
|
46208
|
-
if (orphanResp.functionResponse?.name === "unknown_function") {
|
|
46209
|
-
matchedId = orphanId;
|
|
46210
|
-
break;
|
|
46211
|
-
}
|
|
46212
|
-
}
|
|
46638
|
+
matchedId = firstCollectedNamed("unknown_function");
|
|
46213
46639
|
}
|
|
46214
46640
|
if (!matchedId) {
|
|
46215
46641
|
matchedId = collectedResponses.keys().next().value ?? null;
|
|
@@ -46249,13 +46675,20 @@ function fixToolResponseGrouping(contents) {
|
|
|
46249
46675
|
}
|
|
46250
46676
|
}
|
|
46251
46677
|
if (groupResponses.length > 0) {
|
|
46252
|
-
|
|
46678
|
+
insertedAfter.set(group.insertAfterIdx, {
|
|
46253
46679
|
parts: groupResponses,
|
|
46254
46680
|
role: "user"
|
|
46255
46681
|
});
|
|
46256
46682
|
}
|
|
46257
46683
|
}
|
|
46258
|
-
return newContents;
|
|
46684
|
+
if (insertedAfter.size === 0) return newContents;
|
|
46685
|
+
const withRecovered = [];
|
|
46686
|
+
for (let i = 0; i < newContents.length; i++) {
|
|
46687
|
+
withRecovered.push(newContents[i]);
|
|
46688
|
+
const recovered = insertedAfter.get(i);
|
|
46689
|
+
if (recovered) withRecovered.push(recovered);
|
|
46690
|
+
}
|
|
46691
|
+
return withRecovered;
|
|
46259
46692
|
}
|
|
46260
46693
|
function findOrphanedToolUseIds(messages) {
|
|
46261
46694
|
const toolUseIds = /* @__PURE__ */ new Set();
|
|
@@ -47170,7 +47603,7 @@ init_dist();
|
|
|
47170
47603
|
var log11 = createLogger4("request");
|
|
47171
47604
|
var PLUGIN_SESSION_ID = `-${crypto2.randomUUID()}`;
|
|
47172
47605
|
var DEFAULT_AGY_REQUEST_SESSION = createAgyRequestSessionContext();
|
|
47173
|
-
var
|
|
47606
|
+
var openCode1DisplayedThinking = createDisplayedThinkingRegistry();
|
|
47174
47607
|
var MIN_SIGNATURE_LENGTH = 50;
|
|
47175
47608
|
var AGY_CLAUDE_THINKING_BUDGET = 1024;
|
|
47176
47609
|
var ANTIGRAVITY_ENVELOPE_FIELD_ORDER = [
|
|
@@ -47316,6 +47749,9 @@ function ensureThinkingFields(obj) {
|
|
|
47316
47749
|
ensureThinkingFields(val);
|
|
47317
47750
|
}
|
|
47318
47751
|
}
|
|
47752
|
+
function systemInstructionOf(request2) {
|
|
47753
|
+
return request2 && typeof request2 === "object" ? request2.systemInstruction : void 0;
|
|
47754
|
+
}
|
|
47319
47755
|
function safeStringify(obj) {
|
|
47320
47756
|
ensureThinkingFields(obj);
|
|
47321
47757
|
return JSON.stringify(obj, thinkingSafeReplacer);
|
|
@@ -47568,9 +48004,6 @@ function stripUnsupportedAntigravityFields(payload) {
|
|
|
47568
48004
|
}
|
|
47569
48005
|
}
|
|
47570
48006
|
}
|
|
47571
|
-
function isGeminiFunctionResponseTurn(content, wireModel) {
|
|
47572
|
-
return wireModel.startsWith("gemini-") && content?.role === "model" && Array.isArray(content.parts) && content.parts.length > 0 && content.parts.every((part) => part?.functionResponse);
|
|
47573
|
-
}
|
|
47574
48007
|
function configureAntigravityToolCalling(payload) {
|
|
47575
48008
|
delete payload.toolConfig;
|
|
47576
48009
|
if (Array.isArray(payload.tools)) {
|
|
@@ -47992,7 +48425,7 @@ var openCode1WireLocation = {
|
|
|
47992
48425
|
},
|
|
47993
48426
|
logger: log11,
|
|
47994
48427
|
sessionFingerprint: () => getSessionFingerprint(),
|
|
47995
|
-
|
|
48428
|
+
displayedThinking: openCode1DisplayedThinking,
|
|
47996
48429
|
cacheStats: { last: null }
|
|
47997
48430
|
};
|
|
47998
48431
|
function getLastCacheStats() {
|
|
@@ -48017,6 +48450,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
48017
48450
|
let sessionId;
|
|
48018
48451
|
let needsSignedThinkingWarmup = false;
|
|
48019
48452
|
let thinkingRecoveryMessage;
|
|
48453
|
+
let wireSystemInstruction;
|
|
48020
48454
|
if (!isGenerativeLanguageRequest(input2)) {
|
|
48021
48455
|
return {
|
|
48022
48456
|
request: input2,
|
|
@@ -48145,13 +48579,8 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
48145
48579
|
normalizeNativeFunctionResponseRoles(req, effectiveModel);
|
|
48146
48580
|
}
|
|
48147
48581
|
for (const req of requestObjects) {
|
|
48148
|
-
if (Array.isArray(req.contents))
|
|
48149
|
-
|
|
48150
|
-
const lastContent = contents[contents.length - 1];
|
|
48151
|
-
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel) || lastContent?.role === "assistant") {
|
|
48152
|
-
contents.push({ role: "user", parts: [{ text: "[Continue]" }] });
|
|
48153
|
-
}
|
|
48154
|
-
}
|
|
48582
|
+
if (Array.isArray(req.contents))
|
|
48583
|
+
appendAgyContinuation(req.contents, effectiveModel);
|
|
48155
48584
|
if (Array.isArray(req.messages)) {
|
|
48156
48585
|
const messages = req.messages;
|
|
48157
48586
|
const lastMessage = messages[messages.length - 1];
|
|
@@ -48201,6 +48630,10 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
48201
48630
|
}
|
|
48202
48631
|
}
|
|
48203
48632
|
body = safeStringify(orderAntigravityEnvelope(wrappedBody));
|
|
48633
|
+
wireSystemInstruction = {
|
|
48634
|
+
body,
|
|
48635
|
+
instruction: systemInstructionOf(wrappedBody.request)
|
|
48636
|
+
};
|
|
48204
48637
|
} else {
|
|
48205
48638
|
const requestPayload = { ...parsedBody };
|
|
48206
48639
|
if (isImageGenerationModel(effectiveModel) && isOpenCodeTitleGenerationRequest(requestPayload)) {
|
|
@@ -48587,15 +49020,8 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
48587
49020
|
wire.signatures.signatureStore.delete(signatureSessionKey);
|
|
48588
49021
|
}
|
|
48589
49022
|
}
|
|
48590
|
-
if (Array.isArray(requestPayload.contents))
|
|
48591
|
-
|
|
48592
|
-
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel) || lastContent?.role === "assistant") {
|
|
48593
|
-
requestPayload.contents.push({
|
|
48594
|
-
role: "user",
|
|
48595
|
-
parts: [{ text: "[Continue]" }]
|
|
48596
|
-
});
|
|
48597
|
-
}
|
|
48598
|
-
}
|
|
49023
|
+
if (Array.isArray(requestPayload.contents))
|
|
49024
|
+
appendAgyContinuation(requestPayload.contents, effectiveModel);
|
|
48599
49025
|
if (Array.isArray(requestPayload.messages)) {
|
|
48600
49026
|
const lastMessage = requestPayload.messages[requestPayload.messages.length - 1];
|
|
48601
49027
|
if (lastMessage?.role === "model" || lastMessage?.role === "assistant") {
|
|
@@ -48623,15 +49049,8 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
48623
49049
|
stripUnsupportedAntigravityFields(requestPayload);
|
|
48624
49050
|
configureAntigravityToolCalling(requestPayload);
|
|
48625
49051
|
normalizeNativeFunctionResponseRoles(requestPayload, effectiveModel);
|
|
48626
|
-
if (Array.isArray(requestPayload.contents))
|
|
48627
|
-
|
|
48628
|
-
if (lastContent?.role === "model" && !isGeminiFunctionResponseTurn(lastContent, effectiveModel)) {
|
|
48629
|
-
requestPayload.contents.push({
|
|
48630
|
-
role: "user",
|
|
48631
|
-
parts: [{ text: "[Continue]" }]
|
|
48632
|
-
});
|
|
48633
|
-
}
|
|
48634
|
-
}
|
|
49052
|
+
if (Array.isArray(requestPayload.contents))
|
|
49053
|
+
appendAgyContinuation(requestPayload.contents, effectiveModel);
|
|
48635
49054
|
}
|
|
48636
49055
|
const effectiveProjectId = projectId?.trim() || ANTIGRAVITY_DEFAULT_PROJECT_ID;
|
|
48637
49056
|
resolvedProjectId = effectiveProjectId;
|
|
@@ -48656,6 +49075,10 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
48656
49075
|
requestType: "agent"
|
|
48657
49076
|
};
|
|
48658
49077
|
body = safeStringify(orderAntigravityEnvelope(wrappedBody));
|
|
49078
|
+
wireSystemInstruction = {
|
|
49079
|
+
body,
|
|
49080
|
+
instruction: requestPayload.systemInstruction
|
|
49081
|
+
};
|
|
48659
49082
|
}
|
|
48660
49083
|
} catch {
|
|
48661
49084
|
throw new Error("Failed to build Antigravity request body");
|
|
@@ -48699,7 +49122,8 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
48699
49122
|
toolDebugSummary: toolDebugSummaries.slice(0, 20).join(" | "),
|
|
48700
49123
|
needsSignedThinkingWarmup,
|
|
48701
49124
|
headerStyle: "antigravity",
|
|
48702
|
-
thinkingRecoveryMessage
|
|
49125
|
+
thinkingRecoveryMessage,
|
|
49126
|
+
...wireSystemInstruction ? { wireSystemInstruction } : {}
|
|
48703
49127
|
};
|
|
48704
49128
|
}
|
|
48705
49129
|
function prepareAntigravityRequest(...args) {
|
|
@@ -48817,7 +49241,7 @@ async function transformAntigravityResponseIn(wire, response, streaming, debugCo
|
|
|
48817
49241
|
signatureSessionKey: sessionId,
|
|
48818
49242
|
debugText,
|
|
48819
49243
|
cacheSignatures,
|
|
48820
|
-
displayedThinkingHashes: effectiveModel && isGemini3Model(effectiveModel) ? wire.
|
|
49244
|
+
displayedThinkingHashes: effectiveModel && isGemini3Model(effectiveModel) ? wire.displayedThinking.forSession(sessionId) : void 0
|
|
48821
49245
|
// injectSyntheticThinking removed - keep_thinking now unified with debug via debugText
|
|
48822
49246
|
}
|
|
48823
49247
|
);
|
|
@@ -49316,10 +49740,10 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
49316
49740
|
cancellation.release();
|
|
49317
49741
|
throw error;
|
|
49318
49742
|
}
|
|
49319
|
-
let
|
|
49743
|
+
let resolve35 = () => {
|
|
49320
49744
|
};
|
|
49321
49745
|
const settled = new Promise((done) => {
|
|
49322
|
-
|
|
49746
|
+
resolve35 = done;
|
|
49323
49747
|
});
|
|
49324
49748
|
let stopping = false;
|
|
49325
49749
|
let finished = false;
|
|
@@ -49329,7 +49753,7 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
49329
49753
|
finished = true;
|
|
49330
49754
|
cancellation.signal.removeEventListener("abort", abort);
|
|
49331
49755
|
cancellation.release();
|
|
49332
|
-
|
|
49756
|
+
resolve35();
|
|
49333
49757
|
};
|
|
49334
49758
|
const abort = () => {
|
|
49335
49759
|
if (finished || stopping) return;
|
|
@@ -49614,8 +50038,6 @@ function candidateView(candidates) {
|
|
|
49614
50038
|
accounts.push({ account_id: accountId, credential_id: credentialId });
|
|
49615
50039
|
}
|
|
49616
50040
|
}
|
|
49617
|
-
if (accounts.length === 0)
|
|
49618
|
-
return void 0;
|
|
49619
50041
|
const lines = accounts.map(({ account_id, credential_id }) => Buffer.from(`${account_id} ${credential_id}
|
|
49620
50042
|
`, "utf8")).sort(Buffer.compare);
|
|
49621
50043
|
const hash2 = createHash16("sha256");
|
|
@@ -49692,8 +50114,8 @@ async function askRouting(input2) {
|
|
|
49692
50114
|
return void 0;
|
|
49693
50115
|
const requested = input2.deadlineMs ?? 1500;
|
|
49694
50116
|
const deadlineMs = Number.isNaN(requested) ? 1500 : Math.min(2e3, Math.max(1, requested));
|
|
49695
|
-
const expired = new Promise((
|
|
49696
|
-
timer = setTimeout(() =>
|
|
50117
|
+
const expired = new Promise((resolve35) => {
|
|
50118
|
+
timer = setTimeout(() => resolve35(void 0), deadlineMs);
|
|
49697
50119
|
timer.unref();
|
|
49698
50120
|
});
|
|
49699
50121
|
const cap = input2.holdWaitMaxS;
|
|
@@ -49707,7 +50129,7 @@ async function askRouting(input2) {
|
|
|
49707
50129
|
request2.warm_credential = warmCredentialId;
|
|
49708
50130
|
}
|
|
49709
50131
|
const candidates = candidateView(input2.candidates);
|
|
49710
|
-
if (candidates)
|
|
50132
|
+
if (candidates.accounts.length > 0 || request2.mode === "continue")
|
|
49711
50133
|
request2.candidates = candidates;
|
|
49712
50134
|
const pending = accountFor.call(handle, request2, { deadlineMs });
|
|
49713
50135
|
if (!isObject2(pending) || typeof pending.then !== "function")
|
|
@@ -50083,7 +50505,7 @@ function createRetryState() {
|
|
|
50083
50505
|
var MAX_WARMUP_SESSIONS = 1e3;
|
|
50084
50506
|
var MAX_WARMUP_RETRIES = 2;
|
|
50085
50507
|
function createWarmupState() {
|
|
50086
|
-
const
|
|
50508
|
+
const warmupAttemptCounts = /* @__PURE__ */ new Map();
|
|
50087
50509
|
const warmupSucceededSessionIds = /* @__PURE__ */ new Set();
|
|
50088
50510
|
let disposed = false;
|
|
50089
50511
|
function trackAttempt(sessionId) {
|
|
@@ -50091,22 +50513,22 @@ function createWarmupState() {
|
|
|
50091
50513
|
if (warmupSucceededSessionIds.has(sessionId)) {
|
|
50092
50514
|
return false;
|
|
50093
50515
|
}
|
|
50094
|
-
if (warmupAttemptedSessionIds.size >= MAX_WARMUP_SESSIONS) {
|
|
50095
|
-
const first = warmupAttemptedSessionIds.values().next().value;
|
|
50096
|
-
if (first) {
|
|
50097
|
-
warmupAttemptedSessionIds.delete(first);
|
|
50098
|
-
warmupSucceededSessionIds.delete(first);
|
|
50099
|
-
}
|
|
50100
|
-
}
|
|
50101
50516
|
const attempts2 = getAttemptCount(sessionId);
|
|
50102
50517
|
if (attempts2 >= MAX_WARMUP_RETRIES) {
|
|
50103
50518
|
return false;
|
|
50104
50519
|
}
|
|
50105
|
-
|
|
50520
|
+
if (attempts2 === 0 && warmupAttemptCounts.size >= MAX_WARMUP_SESSIONS) {
|
|
50521
|
+
const first = warmupAttemptCounts.keys().next().value;
|
|
50522
|
+
if (first !== void 0) {
|
|
50523
|
+
warmupAttemptCounts.delete(first);
|
|
50524
|
+
warmupSucceededSessionIds.delete(first);
|
|
50525
|
+
}
|
|
50526
|
+
}
|
|
50527
|
+
warmupAttemptCounts.set(sessionId, attempts2 + 1);
|
|
50106
50528
|
return true;
|
|
50107
50529
|
}
|
|
50108
50530
|
function getAttemptCount(sessionId) {
|
|
50109
|
-
return
|
|
50531
|
+
return warmupAttemptCounts.get(sessionId) ?? 0;
|
|
50110
50532
|
}
|
|
50111
50533
|
function markSuccess(sessionId) {
|
|
50112
50534
|
if (disposed) return;
|
|
@@ -50116,12 +50538,14 @@ function createWarmupState() {
|
|
|
50116
50538
|
if (first) warmupSucceededSessionIds.delete(first);
|
|
50117
50539
|
}
|
|
50118
50540
|
}
|
|
50119
|
-
function
|
|
50541
|
+
function refundAttempt(sessionId) {
|
|
50120
50542
|
if (disposed) return;
|
|
50121
|
-
|
|
50543
|
+
const attempts2 = getAttemptCount(sessionId);
|
|
50544
|
+
if (attempts2 <= 1) warmupAttemptCounts.delete(sessionId);
|
|
50545
|
+
else warmupAttemptCounts.set(sessionId, attempts2 - 1);
|
|
50122
50546
|
}
|
|
50123
50547
|
function clear() {
|
|
50124
|
-
|
|
50548
|
+
warmupAttemptCounts.clear();
|
|
50125
50549
|
warmupSucceededSessionIds.clear();
|
|
50126
50550
|
}
|
|
50127
50551
|
function dispose() {
|
|
@@ -50136,7 +50560,7 @@ function createWarmupState() {
|
|
|
50136
50560
|
trackAttempt,
|
|
50137
50561
|
getAttemptCount,
|
|
50138
50562
|
markSuccess,
|
|
50139
|
-
|
|
50563
|
+
refundAttempt,
|
|
50140
50564
|
clear,
|
|
50141
50565
|
dispose
|
|
50142
50566
|
};
|
|
@@ -50202,8 +50626,8 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
50202
50626
|
let running = false;
|
|
50203
50627
|
let resolveCompletion = () => {
|
|
50204
50628
|
};
|
|
50205
|
-
const completion = new Promise((
|
|
50206
|
-
resolveCompletion =
|
|
50629
|
+
const completion = new Promise((resolve35) => {
|
|
50630
|
+
resolveCompletion = resolve35;
|
|
50207
50631
|
});
|
|
50208
50632
|
const finish = () => {
|
|
50209
50633
|
if (finished) return;
|
|
@@ -50250,14 +50674,14 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
50250
50674
|
};
|
|
50251
50675
|
}
|
|
50252
50676
|
function publishResponse(dispatch) {
|
|
50253
|
-
return new Promise((
|
|
50677
|
+
return new Promise((resolve35, reject) => {
|
|
50254
50678
|
let acknowledge;
|
|
50255
50679
|
void Promise.resolve().then(
|
|
50256
50680
|
() => dispatch((callback) => {
|
|
50257
50681
|
acknowledge = callback;
|
|
50258
50682
|
})
|
|
50259
50683
|
).then((response) => {
|
|
50260
|
-
|
|
50684
|
+
resolve35(response);
|
|
50261
50685
|
acknowledge?.();
|
|
50262
50686
|
}, reject);
|
|
50263
50687
|
});
|
|
@@ -50637,6 +51061,7 @@ function isTitleVaultRequest(kind, headers) {
|
|
|
50637
51061
|
var FIRST_RETRY_DELAY_MS = 1e3;
|
|
50638
51062
|
var MODEL_UNAVAILABLE_TTL_MS = 60 * 60 * 1e3;
|
|
50639
51063
|
var ROUTING_ASK_DEADLINE_MS = 2e3;
|
|
51064
|
+
var FIRST_PLACEMENT_REFUSAL_MAX_RETRY_SECS = 5;
|
|
50640
51065
|
var REFUSAL_BODY_TIMEOUT_MS = 2e3;
|
|
50641
51066
|
var REFUSAL_BODY_MAX_BYTES = 64 * 1024;
|
|
50642
51067
|
async function readRefusalBody(response, deadline) {
|
|
@@ -50665,8 +51090,8 @@ async function readRefusalBody(response, deadline) {
|
|
|
50665
51090
|
return false;
|
|
50666
51091
|
}
|
|
50667
51092
|
})(),
|
|
50668
|
-
new Promise((
|
|
50669
|
-
timer = setTimeout(() =>
|
|
51093
|
+
new Promise((resolve35) => {
|
|
51094
|
+
timer = setTimeout(() => resolve35(false), REFUSAL_BODY_TIMEOUT_MS);
|
|
50670
51095
|
})
|
|
50671
51096
|
])
|
|
50672
51097
|
);
|
|
@@ -50782,7 +51207,7 @@ function formatWaitTime(ms) {
|
|
|
50782
51207
|
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
|
|
50783
51208
|
}
|
|
50784
51209
|
function sleep4(ms, signal) {
|
|
50785
|
-
return new Promise((
|
|
51210
|
+
return new Promise((resolve35, reject) => {
|
|
50786
51211
|
if (signal?.aborted) {
|
|
50787
51212
|
reject(
|
|
50788
51213
|
signal.reason instanceof Error ? signal.reason : new Error("Aborted")
|
|
@@ -50792,7 +51217,7 @@ function sleep4(ms, signal) {
|
|
|
50792
51217
|
const timerMs = Math.min(Math.max(0, Math.floor(ms)), 2147483647);
|
|
50793
51218
|
const timeout = setTimeout(() => {
|
|
50794
51219
|
cleanup2();
|
|
50795
|
-
|
|
51220
|
+
resolve35();
|
|
50796
51221
|
}, timerMs);
|
|
50797
51222
|
const onAbort = () => {
|
|
50798
51223
|
cleanup2();
|
|
@@ -50865,15 +51290,16 @@ function createLocalQuotaRefresh(accountManager, quotaManager, log19) {
|
|
|
50865
51290
|
...signal ? { signal } : {}
|
|
50866
51291
|
});
|
|
50867
51292
|
if (signal?.aborted) return;
|
|
50868
|
-
if (result.status === "ok" && result.quota?.groups) {
|
|
51293
|
+
if (result.status === "ok" && result.quota?.groups && result.checkedAt !== void 0) {
|
|
50869
51294
|
const currentIndex = accountManager.getAccounts().indexOf(account);
|
|
50870
51295
|
if (currentIndex === -1) return;
|
|
50871
|
-
accountManager.updateQuotaCache(
|
|
51296
|
+
if (accountManager.updateQuotaCache(
|
|
50872
51297
|
currentIndex,
|
|
50873
51298
|
result.quota.groups,
|
|
50874
|
-
expectedRefreshToken
|
|
50875
|
-
|
|
50876
|
-
|
|
51299
|
+
expectedRefreshToken,
|
|
51300
|
+
result.checkedAt
|
|
51301
|
+
))
|
|
51302
|
+
accountManager.requestSaveToDisk();
|
|
50877
51303
|
}
|
|
50878
51304
|
} catch (err) {
|
|
50879
51305
|
log19.debug(
|
|
@@ -50999,6 +51425,18 @@ function createRequestExecutor(deps) {
|
|
|
50999
51425
|
let retired = false;
|
|
51000
51426
|
let drainPromise;
|
|
51001
51427
|
let disposePromise;
|
|
51428
|
+
let warnedConditionReceipt = false;
|
|
51429
|
+
const runVaultCondition = (operation) => {
|
|
51430
|
+
void Promise.resolve().then(operation).catch((error) => {
|
|
51431
|
+
if (warnedConditionReceipt || !(error instanceof Error) || !("kind" in error) || error.kind !== "no-receipt")
|
|
51432
|
+
return;
|
|
51433
|
+
warnedConditionReceipt = true;
|
|
51434
|
+
try {
|
|
51435
|
+
log19.warn("vault-condition-no-receipt");
|
|
51436
|
+
} catch {
|
|
51437
|
+
}
|
|
51438
|
+
});
|
|
51439
|
+
};
|
|
51002
51440
|
const reportVault401 = (admission, status) => {
|
|
51003
51441
|
if (!admission || status !== 401) return;
|
|
51004
51442
|
void Promise.resolve().then(() => admission.report401(status)).catch((error) => {
|
|
@@ -51110,6 +51548,7 @@ function createRequestExecutor(deps) {
|
|
|
51110
51548
|
} : void 0;
|
|
51111
51549
|
const isChildRequest = requestSessionIdentity.parentSessionId !== null;
|
|
51112
51550
|
let physicalSendCount = 0;
|
|
51551
|
+
let emptyResponseAttempts = 0;
|
|
51113
51552
|
if (accountManager.getAccountCount() === 0) {
|
|
51114
51553
|
const urlString2 = typeof input2 === "string" ? input2 : toUrlString(input2);
|
|
51115
51554
|
const modelFromUrl = extractModelFromUrl(urlString2) ?? "unknown";
|
|
@@ -51222,6 +51661,7 @@ function createRequestExecutor(deps) {
|
|
|
51222
51661
|
}
|
|
51223
51662
|
};
|
|
51224
51663
|
let accountSwitchCount = 0;
|
|
51664
|
+
let capacityExhaustedSelections = 0;
|
|
51225
51665
|
let unconfirmedRetries = 0;
|
|
51226
51666
|
const maxAccountSwitches = config.max_account_switches ?? 2;
|
|
51227
51667
|
let previousAccountIndex = -1;
|
|
@@ -51233,6 +51673,7 @@ function createRequestExecutor(deps) {
|
|
|
51233
51673
|
let routingPlacementConsidered = false;
|
|
51234
51674
|
let routedCandidate;
|
|
51235
51675
|
let continueRouting;
|
|
51676
|
+
let continueOnlyLogin = false;
|
|
51236
51677
|
const refusedRoutes = /* @__PURE__ */ new Map();
|
|
51237
51678
|
let routingTitle = false;
|
|
51238
51679
|
let routingWaitMs = 0;
|
|
@@ -51300,10 +51741,12 @@ function createRequestExecutor(deps) {
|
|
|
51300
51741
|
const choice = routedCandidate;
|
|
51301
51742
|
routedCandidate = void 0;
|
|
51302
51743
|
const exhausted = continueRouting;
|
|
51744
|
+
const onlyLoginContinuation = continueOnlyLogin;
|
|
51303
51745
|
continueRouting = void 0;
|
|
51746
|
+
continueOnlyLogin = false;
|
|
51304
51747
|
if (exhausted) refusedRoutes.set(routingIdentityKey(exhausted), exhausted);
|
|
51305
51748
|
const accountCount = accountManager.getAccountCount();
|
|
51306
|
-
if (accountCount === 0) {
|
|
51749
|
+
if (accountCount === 0 && !onlyLoginContinuation) {
|
|
51307
51750
|
if (choice) return failedRoutedPick();
|
|
51308
51751
|
return createNoAccountResponse(
|
|
51309
51752
|
"No Antigravity accounts available. Run `opencode auth login`.",
|
|
@@ -51491,7 +51934,7 @@ function createRequestExecutor(deps) {
|
|
|
51491
51934
|
const canHold = !!holdCandidate && candidates.some(
|
|
51492
51935
|
(candidate) => routingIdentityKey(candidate) === holdCandidate
|
|
51493
51936
|
);
|
|
51494
|
-
const
|
|
51937
|
+
const ask = () => deadline.wait(() => {
|
|
51495
51938
|
const input3 = {
|
|
51496
51939
|
sessionId: accountSessionIdentity.id,
|
|
51497
51940
|
provider: "antigravity",
|
|
@@ -51513,9 +51956,21 @@ function createRequestExecutor(deps) {
|
|
|
51513
51956
|
} : input3
|
|
51514
51957
|
);
|
|
51515
51958
|
});
|
|
51959
|
+
let answer = await ask();
|
|
51960
|
+
const firstRefusal = !exhausted && answer && "refused" in answer ? answer.refused : void 0;
|
|
51961
|
+
if (firstRefusal?.code === "account_selection_refused" && firstRefusal.retryAfterSecs !== void 0 && firstRefusal.retryAfterSecs <= FIRST_PLACEMENT_REFUSAL_MAX_RETRY_SECS) {
|
|
51962
|
+
await routingSleep(
|
|
51963
|
+
firstRefusal.retryAfterSecs * 1e3,
|
|
51964
|
+
"account_free"
|
|
51965
|
+
);
|
|
51966
|
+
checkAborted();
|
|
51967
|
+
answer = await ask();
|
|
51968
|
+
}
|
|
51516
51969
|
checkAborted();
|
|
51517
51970
|
if (answer && "refused" in answer)
|
|
51518
51971
|
return routingRefusalResponse(answer.refused);
|
|
51972
|
+
if (!answer && onlyLoginContinuation && candidates.length === 0)
|
|
51973
|
+
return failedRoutedPick();
|
|
51519
51974
|
if (exhausted && answer?.hold) {
|
|
51520
51975
|
if (!canHold || routingIdentityKey(answer.candidate) !== holdCandidate)
|
|
51521
51976
|
return failedRoutedPick();
|
|
@@ -51988,12 +52443,14 @@ function createRequestExecutor(deps) {
|
|
|
51988
52443
|
streaming: true,
|
|
51989
52444
|
projectId
|
|
51990
52445
|
});
|
|
52446
|
+
let warmupDispatched = false;
|
|
51991
52447
|
try {
|
|
51992
52448
|
pushDebug("thinking-warmup: start");
|
|
51993
52449
|
const warmupSend = await credentialForAuxiliarySend(
|
|
51994
52450
|
warmupInit,
|
|
51995
52451
|
projectId
|
|
51996
52452
|
);
|
|
52453
|
+
warmupDispatched = true;
|
|
51997
52454
|
const warmupResponse = await sendPhysical(
|
|
51998
52455
|
warmupUrl,
|
|
51999
52456
|
warmupSend.init,
|
|
@@ -52018,7 +52475,7 @@ function createRequestExecutor(deps) {
|
|
|
52018
52475
|
warmupState.markSuccess(prepared.sessionId);
|
|
52019
52476
|
pushDebug("thinking-warmup: done");
|
|
52020
52477
|
} catch (error) {
|
|
52021
|
-
warmupState.
|
|
52478
|
+
if (!warmupDispatched) warmupState.refundAttempt(prepared.sessionId);
|
|
52022
52479
|
if (error instanceof PreResponseTimeoutError) throw error;
|
|
52023
52480
|
checkAborted();
|
|
52024
52481
|
if (isLocalGrantError(error)) throw error;
|
|
@@ -52351,9 +52808,9 @@ function createRequestExecutor(deps) {
|
|
|
52351
52808
|
const routed429 = response.status === 429 ? routedIdentity : void 0;
|
|
52352
52809
|
if (response.status === 429 && rateLimitReason === "UNKNOWN") {
|
|
52353
52810
|
await logResponseBody2(debugContext, response, 429);
|
|
52354
|
-
const
|
|
52811
|
+
const carried = prepared.wireSystemInstruction;
|
|
52355
52812
|
const recognised = systemInstructionHasHarnessIdentity(
|
|
52356
|
-
|
|
52813
|
+
carried && carried.body === prepared.init.body ? carried.instruction : JSON.parse(String(prepared.init.body)).request?.systemInstruction
|
|
52357
52814
|
);
|
|
52358
52815
|
if (recognised) {
|
|
52359
52816
|
void response.body?.cancel().catch(() => {
|
|
@@ -52477,10 +52934,19 @@ function createRequestExecutor(deps) {
|
|
|
52477
52934
|
i -= 1;
|
|
52478
52935
|
continue;
|
|
52479
52936
|
}
|
|
52937
|
+
retainHttpFailure(response);
|
|
52938
|
+
capacityExhaustedSelections++;
|
|
52939
|
+
if (capacityExhaustedSelections > 1) {
|
|
52940
|
+
pushDebug(
|
|
52941
|
+
`Total capacity retries (${MAX_TOTAL_CAPACITY_RETRIES}) exhausted again after one account switch, giving up`
|
|
52942
|
+
);
|
|
52943
|
+
return terminalMainAttemptFailure(
|
|
52944
|
+
"Antigravity has no capacity for this model right now"
|
|
52945
|
+
);
|
|
52946
|
+
}
|
|
52480
52947
|
pushDebug(
|
|
52481
52948
|
`Total capacity retries (${MAX_TOTAL_CAPACITY_RETRIES}) exhausted, switching account`
|
|
52482
52949
|
);
|
|
52483
|
-
retainHttpFailure(response);
|
|
52484
52950
|
shouldSwitchAccount = true;
|
|
52485
52951
|
break;
|
|
52486
52952
|
}
|
|
@@ -52626,6 +53092,10 @@ function createRequestExecutor(deps) {
|
|
|
52626
53092
|
i -= 1;
|
|
52627
53093
|
continue;
|
|
52628
53094
|
}
|
|
53095
|
+
if (routed429 && exhaustion) {
|
|
53096
|
+
const { accountId, credentialId } = routed429;
|
|
53097
|
+
continueRouting = { accountId, credentialId, ...exhaustion };
|
|
53098
|
+
}
|
|
52629
53099
|
const switchAccountDelayMs = config.switch_account_delay_ms ?? 500;
|
|
52630
53100
|
if (accountCount > 1) {
|
|
52631
53101
|
const quotaMsg = reasonInfo.quotaResetTime ? ` (quota resets ${reasonInfo.quotaResetTime})` : ``;
|
|
@@ -52634,7 +53104,7 @@ function createRequestExecutor(deps) {
|
|
|
52634
53104
|
"warning"
|
|
52635
53105
|
);
|
|
52636
53106
|
await sleep4(switchAccountDelayMs, abortSignal);
|
|
52637
|
-
} else {
|
|
53107
|
+
} else if (!continueRouting || isHardEligible(account)) {
|
|
52638
53108
|
const expBackoffMs = Math.min(
|
|
52639
53109
|
FIRST_RETRY_DELAY_MS * 2 ** (backoff.attempt - 1),
|
|
52640
53110
|
6e4
|
|
@@ -52651,10 +53121,6 @@ function createRequestExecutor(deps) {
|
|
|
52651
53121
|
);
|
|
52652
53122
|
}
|
|
52653
53123
|
retainHttpFailure(response);
|
|
52654
|
-
if (routed429 && exhaustion) {
|
|
52655
|
-
const { accountId, credentialId } = routed429;
|
|
52656
|
-
continueRouting = { accountId, credentialId, ...exhaustion };
|
|
52657
|
-
}
|
|
52658
53124
|
shouldSwitchAccount = true;
|
|
52659
53125
|
break;
|
|
52660
53126
|
}
|
|
@@ -52698,6 +53164,19 @@ function createRequestExecutor(deps) {
|
|
|
52698
53164
|
() => response.clone().text().catch(() => "")
|
|
52699
53165
|
);
|
|
52700
53166
|
const extracted = errorBodyText === void 0 ? void 0 : classifyAccessError(errorBodyText);
|
|
53167
|
+
const served2 = sendAdmission;
|
|
53168
|
+
const reportCondition = (reason) => {
|
|
53169
|
+
if (credentials.domain !== "vault" || !served2?.reportCondition)
|
|
53170
|
+
return;
|
|
53171
|
+
const actionUrl = extracted?.structuredVerifyUrl;
|
|
53172
|
+
waitPolicy.vaultConditions.push(
|
|
53173
|
+
() => served2.reportCondition?.({
|
|
53174
|
+
reason,
|
|
53175
|
+
providerStatus: 403,
|
|
53176
|
+
...actionUrl && { actionUrl }
|
|
53177
|
+
})
|
|
53178
|
+
);
|
|
53179
|
+
};
|
|
52701
53180
|
if (routedIdentity && (extracted?.accountIneligible || extracted?.validationRequired)) {
|
|
52702
53181
|
const { accountId, credentialId } = routedIdentity;
|
|
52703
53182
|
continueRouting = {
|
|
@@ -52727,6 +53206,7 @@ function createRequestExecutor(deps) {
|
|
|
52727
53206
|
trackers.health.recordFailure(account.index);
|
|
52728
53207
|
retainHttpFailure(response);
|
|
52729
53208
|
shouldSwitchAccount = true;
|
|
53209
|
+
reportCondition("provider_ineligible");
|
|
52730
53210
|
break;
|
|
52731
53211
|
}
|
|
52732
53212
|
if (extracted?.validationRequired) {
|
|
@@ -52762,6 +53242,7 @@ function createRequestExecutor(deps) {
|
|
|
52762
53242
|
trackers.health.recordFailure(account.index);
|
|
52763
53243
|
retainHttpFailure(response);
|
|
52764
53244
|
shouldSwitchAccount = true;
|
|
53245
|
+
reportCondition("provider_verification_required");
|
|
52765
53246
|
break;
|
|
52766
53247
|
}
|
|
52767
53248
|
}
|
|
@@ -52841,8 +53322,7 @@ function createRequestExecutor(deps) {
|
|
|
52841
53322
|
})
|
|
52842
53323
|
);
|
|
52843
53324
|
if (isEmptyResponseBody(bodyText)) {
|
|
52844
|
-
const
|
|
52845
|
-
const currentAttempts = retryState.recordEmptyResponseAttempt(emptyAttemptKey);
|
|
53325
|
+
const currentAttempts = ++emptyResponseAttempts;
|
|
52846
53326
|
pushDebug(
|
|
52847
53327
|
`empty-response: attempt ${currentAttempts}/${maxAttempts}`
|
|
52848
53328
|
);
|
|
@@ -52855,14 +53335,11 @@ function createRequestExecutor(deps) {
|
|
|
52855
53335
|
await sleep4(retryDelayMs, abortSignal);
|
|
52856
53336
|
continue;
|
|
52857
53337
|
}
|
|
52858
|
-
retryState.clearEmptyResponseAttempts();
|
|
52859
53338
|
return createNativeGoogleErrorResponse({
|
|
52860
53339
|
status: 502,
|
|
52861
53340
|
reason: "empty_response"
|
|
52862
53341
|
});
|
|
52863
53342
|
}
|
|
52864
|
-
const _emptyAttemptKeyClean = `${prepared.sessionId ?? "none"}:${prepared.effectiveModel ?? "unknown"}`;
|
|
52865
|
-
retryState.clearEmptyResponseAttempts();
|
|
52866
53343
|
}
|
|
52867
53344
|
const routingObservation = credentials.domain === "vault" && sendAdmission && sessionKey && response.ok && hasVaultRoutingAccessor() ? observeVaultUpstream(response, abortSignal) : void 0;
|
|
52868
53345
|
const transformedResponse = await deadline.wait(
|
|
@@ -52899,7 +53376,7 @@ function createRequestExecutor(deps) {
|
|
|
52899
53376
|
}
|
|
52900
53377
|
if (apiRequestCount > 1) {
|
|
52901
53378
|
pushDebug(
|
|
52902
|
-
`[Quota]
|
|
53379
|
+
`[Quota] Main-request responses on this account selection: ${apiRequestCount}`
|
|
52903
53380
|
);
|
|
52904
53381
|
}
|
|
52905
53382
|
const dailyCounts = accountManager.getDailyRequestCounts(
|
|
@@ -52939,6 +53416,9 @@ function createRequestExecutor(deps) {
|
|
|
52939
53416
|
const refresh = credentials.refreshQuotaAfterSuccess;
|
|
52940
53417
|
waitPolicy.quota = (signal) => refresh(account, config.quota_refresh_interval_minutes, signal);
|
|
52941
53418
|
}
|
|
53419
|
+
const served = sendAdmission;
|
|
53420
|
+
if (credentials.domain === "vault" && response.ok && transformedResponse.ok && served?.clearCondition)
|
|
53421
|
+
waitPolicy.vaultConditions.push(() => served.clearCondition?.());
|
|
52942
53422
|
return routingObservation && credentials.domain === "vault" && sendAdmission && sessionKey && hasVaultRoutingAccessor() && response.ok ? observeVaultServed(
|
|
52943
53423
|
{
|
|
52944
53424
|
sessionId: sessionKey,
|
|
@@ -52956,6 +53436,7 @@ function createRequestExecutor(deps) {
|
|
|
52956
53436
|
trackers.token.refund(account.index);
|
|
52957
53437
|
tokenConsumed = false;
|
|
52958
53438
|
}
|
|
53439
|
+
deadline.resume();
|
|
52959
53440
|
if (credentials.domain === "local" && localGrant?.captured.source === "store" && isLocalGrantError(error)) {
|
|
52960
53441
|
if (error instanceof LocalGrantSupersededError && !localRecaptureUsed) {
|
|
52961
53442
|
localRecaptureUsed = true;
|
|
@@ -53041,6 +53522,10 @@ function createRequestExecutor(deps) {
|
|
|
53041
53522
|
}
|
|
53042
53523
|
if (shouldSwitchAccount) {
|
|
53043
53524
|
if (switchedForUnconfirmed) continue;
|
|
53525
|
+
if (accountCount === 1 && continueRouting && (continueRouting.limitWindow === "signed_out" || !isHardEligible(account))) {
|
|
53526
|
+
continueOnlyLogin = true;
|
|
53527
|
+
continue;
|
|
53528
|
+
}
|
|
53044
53529
|
accountSwitchCount++;
|
|
53045
53530
|
if (accountSwitchCount > maxAccountSwitches) {
|
|
53046
53531
|
pushDebug(
|
|
@@ -53109,7 +53594,11 @@ function createRequestExecutor(deps) {
|
|
|
53109
53594
|
requestedSignal ? [requestedSignal, shutdown.signal] : [shutdown.signal],
|
|
53110
53595
|
() => log19.debug("post-response-advisory-work-failed")
|
|
53111
53596
|
);
|
|
53112
|
-
const waitPolicy = {};
|
|
53597
|
+
const waitPolicy = { vaultConditions: [] };
|
|
53598
|
+
const publishVaultConditions = () => {
|
|
53599
|
+
for (const operation of waitPolicy.vaultConditions.splice(0))
|
|
53600
|
+
runVaultCondition(operation);
|
|
53601
|
+
};
|
|
53113
53602
|
const selectedCredentials = /* @__PURE__ */ new Set();
|
|
53114
53603
|
const selectedProjectIds = /* @__PURE__ */ new Set();
|
|
53115
53604
|
const redactFailure = (error) => {
|
|
@@ -53182,7 +53671,21 @@ function createRequestExecutor(deps) {
|
|
|
53182
53671
|
cancellation.release();
|
|
53183
53672
|
throw redactFailure(error);
|
|
53184
53673
|
}
|
|
53185
|
-
).
|
|
53674
|
+
).then((response) => {
|
|
53675
|
+
if (waitPolicy.vaultConditions.length > 0) {
|
|
53676
|
+
if (requestOptions?.onResponseHandoff) {
|
|
53677
|
+
try {
|
|
53678
|
+
requestOptions.onResponseHandoff(publishVaultConditions);
|
|
53679
|
+
return response;
|
|
53680
|
+
} catch {
|
|
53681
|
+
}
|
|
53682
|
+
}
|
|
53683
|
+
setImmediate(publishVaultConditions);
|
|
53684
|
+
}
|
|
53685
|
+
return response;
|
|
53686
|
+
}).catch((error) => {
|
|
53687
|
+
if (waitPolicy.vaultConditions.length > 0)
|
|
53688
|
+
setImmediate(publishVaultConditions);
|
|
53186
53689
|
handoff.cancel();
|
|
53187
53690
|
deadline.dispose();
|
|
53188
53691
|
cancellation.release();
|
|
@@ -53269,13 +53772,13 @@ function extractRateLimitBodyInfo(body, status, headers) {
|
|
|
53269
53772
|
|
|
53270
53773
|
// src/plugin/shared/runtime.ts
|
|
53271
53774
|
init_dist();
|
|
53272
|
-
import { join as
|
|
53775
|
+
import { join as join31 } from "node:path";
|
|
53273
53776
|
|
|
53274
53777
|
// src/settings/runtime.ts
|
|
53275
53778
|
init_dist();
|
|
53276
|
-
import { readFile as
|
|
53779
|
+
import { readFile as readFile19, stat as stat14 } from "node:fs/promises";
|
|
53277
53780
|
import { homedir as homedir10 } from "node:os";
|
|
53278
|
-
import { basename as basename11, join as
|
|
53781
|
+
import { basename as basename11, join as join30 } from "node:path";
|
|
53279
53782
|
init_process_heartbeat();
|
|
53280
53783
|
init_version_fence();
|
|
53281
53784
|
|
|
@@ -53322,10 +53825,10 @@ async function resolveSettingsLocation(options) {
|
|
|
53322
53825
|
}
|
|
53323
53826
|
|
|
53324
53827
|
// src/settings/move.ts
|
|
53325
|
-
import { readFile as
|
|
53828
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
53326
53829
|
async function readIfPresent(path5) {
|
|
53327
53830
|
try {
|
|
53328
|
-
return await
|
|
53831
|
+
return await readFile17(path5, "utf8");
|
|
53329
53832
|
} catch {
|
|
53330
53833
|
return void 0;
|
|
53331
53834
|
}
|
|
@@ -53389,9 +53892,9 @@ async function runSettingsMove(input2) {
|
|
|
53389
53892
|
|
|
53390
53893
|
// src/settings/protection.ts
|
|
53391
53894
|
init_runtime_paths();
|
|
53392
|
-
import { join as
|
|
53895
|
+
import { join as join28 } from "node:path";
|
|
53393
53896
|
function defaultProtectionStatePath() {
|
|
53394
|
-
return
|
|
53897
|
+
return join28(pluginStateDir(), PROTECTION_STATE_FILE_NAME);
|
|
53395
53898
|
}
|
|
53396
53899
|
function createProtectionStore2(path5 = defaultProtectionStatePath()) {
|
|
53397
53900
|
return createProtectionStore(path5);
|
|
@@ -53400,19 +53903,19 @@ function createProtectionStore2(path5 = defaultProtectionStatePath()) {
|
|
|
53400
53903
|
// src/settings/report.ts
|
|
53401
53904
|
init_dist();
|
|
53402
53905
|
init_runtime_paths();
|
|
53403
|
-
import { mkdir as mkdir16, readFile as
|
|
53404
|
-
import { basename as basename10, dirname as
|
|
53906
|
+
import { mkdir as mkdir16, readFile as readFile18, rm as rm6 } from "node:fs/promises";
|
|
53907
|
+
import { basename as basename10, dirname as dirname26, join as join29 } from "node:path";
|
|
53405
53908
|
var MOVE_REPORT_FILE_NAME = "settings-move-report.json";
|
|
53406
53909
|
function defaultMoveReportPath() {
|
|
53407
|
-
return
|
|
53910
|
+
return join29(pluginStateDir(), MOVE_REPORT_FILE_NAME);
|
|
53408
53911
|
}
|
|
53409
53912
|
async function writeMoveReport(path5, report) {
|
|
53410
|
-
await mkdir16(
|
|
53913
|
+
await mkdir16(dirname26(path5), { recursive: true, mode: 448 });
|
|
53411
53914
|
await writeJsonAtomic(path5, { version: 1, ...report });
|
|
53412
53915
|
}
|
|
53413
53916
|
async function readMoveReport(path5) {
|
|
53414
53917
|
try {
|
|
53415
|
-
const parsed = JSON.parse(await
|
|
53918
|
+
const parsed = JSON.parse(await readFile18(path5, "utf8"));
|
|
53416
53919
|
if (parsed?.version !== 1 || !Array.isArray(parsed.unmapped))
|
|
53417
53920
|
return void 0;
|
|
53418
53921
|
return parsed;
|
|
@@ -53822,12 +54325,12 @@ function createSettingsRuntime(options) {
|
|
|
53822
54325
|
if (movedHere || moveReport) return [];
|
|
53823
54326
|
let text2;
|
|
53824
54327
|
try {
|
|
53825
|
-
text2 = await
|
|
54328
|
+
text2 = await readFile19(legacyUserFile, "utf8");
|
|
53826
54329
|
} catch {
|
|
53827
54330
|
return [];
|
|
53828
54331
|
}
|
|
53829
54332
|
try {
|
|
53830
|
-
const note = await
|
|
54333
|
+
const note = await readFile19(`${legacyUserFile}.MOVED_READPLEASE`, "utf8");
|
|
53831
54334
|
if (note.includes(file)) return [];
|
|
53832
54335
|
} catch {
|
|
53833
54336
|
}
|
|
@@ -53847,7 +54350,7 @@ function createSettingsRuntime(options) {
|
|
|
53847
54350
|
if (!handle) return [];
|
|
53848
54351
|
const projectFiles = /* @__PURE__ */ new Set([
|
|
53849
54352
|
getProjectConfigPath(entry.project),
|
|
53850
|
-
|
|
54353
|
+
join30(entry.project, ".cortexkit", "antigravity-auth.jsonc")
|
|
53851
54354
|
]);
|
|
53852
54355
|
return handle.report().filter(
|
|
53853
54356
|
(item) => item.file.kind === "user" && item.file.path === file || projectFiles.has(item.file.path)
|
|
@@ -54126,16 +54629,10 @@ var BackgroundQuotaRefresh = class {
|
|
|
54126
54629
|
if (this.timer.unref) this.timer.unref();
|
|
54127
54630
|
}
|
|
54128
54631
|
async runTick() {
|
|
54129
|
-
if (
|
|
54632
|
+
if (!await this.canRun()) {
|
|
54130
54633
|
if (!this.disposed) this.scheduleNext(this.jitteredInterval());
|
|
54131
54634
|
return;
|
|
54132
54635
|
}
|
|
54133
|
-
if (this.disposed) return;
|
|
54134
|
-
const freshnessThresholdMs = Math.max(
|
|
54135
|
-
this.intervalMs - MIN_INTERVAL_MS,
|
|
54136
|
-
Math.floor(this.intervalMs / 2)
|
|
54137
|
-
);
|
|
54138
|
-
const ageMs = this.now() - this.snapshots.lastCheckedAt();
|
|
54139
54636
|
const lockPath = this.snapshots.pollLockPath;
|
|
54140
54637
|
let lock = null;
|
|
54141
54638
|
try {
|
|
@@ -54153,9 +54650,7 @@ var BackgroundQuotaRefresh = class {
|
|
|
54153
54650
|
return;
|
|
54154
54651
|
}
|
|
54155
54652
|
try {
|
|
54156
|
-
if (
|
|
54157
|
-
if (ageMs >= freshnessThresholdMs) await this.refresh();
|
|
54158
|
-
else await this.refreshTierSlot();
|
|
54653
|
+
if (await this.canRun()) await this.refresh();
|
|
54159
54654
|
} finally {
|
|
54160
54655
|
await lock.release().catch(() => {
|
|
54161
54656
|
});
|
|
@@ -54164,22 +54659,36 @@ var BackgroundQuotaRefresh = class {
|
|
|
54164
54659
|
this.scheduleNext(this.jitteredInterval());
|
|
54165
54660
|
}
|
|
54166
54661
|
}
|
|
54662
|
+
async canRun() {
|
|
54663
|
+
return !this.disposed && (!this.mayRun || await this.mayRun()) && !this.disposed;
|
|
54664
|
+
}
|
|
54167
54665
|
async refresh() {
|
|
54168
54666
|
const refreshedQuota = await this.refreshQuota();
|
|
54169
|
-
if (
|
|
54170
|
-
|
|
54171
|
-
if (refreshedQuota) await this.pushSnapshot();
|
|
54667
|
+
if (await this.canRun()) await this.refreshTierSlot();
|
|
54668
|
+
if (refreshedQuota && await this.canRun()) await this.pushSnapshot();
|
|
54172
54669
|
}
|
|
54173
54670
|
async refreshQuota() {
|
|
54174
|
-
if (this.disposed || this.mayRun && !await this.mayRun()) return false;
|
|
54175
54671
|
const manager = this.getAccountManager();
|
|
54176
54672
|
if (!manager) return false;
|
|
54177
|
-
const
|
|
54673
|
+
const observed = await (manager.readAccountsForQuotaPoll?.() ?? this.localObservations(manager));
|
|
54674
|
+
if (!await this.canRun()) return false;
|
|
54675
|
+
const now2 = this.now();
|
|
54676
|
+
const freshnessThresholdMs = Math.max(
|
|
54677
|
+
this.intervalMs - MIN_INTERVAL_MS,
|
|
54678
|
+
Math.floor(this.intervalMs / 2)
|
|
54679
|
+
);
|
|
54680
|
+
const accounts = observed.filter(
|
|
54681
|
+
({ enabled, cachedQuotaUpdatedAt: at }) => enabled !== false && (at === void 0 || !Number.isFinite(at) || at <= 0 || at > now2 || now2 - at >= freshnessThresholdMs)
|
|
54682
|
+
);
|
|
54178
54683
|
if (accounts.length === 0) return false;
|
|
54179
54684
|
let results;
|
|
54180
54685
|
try {
|
|
54686
|
+
const indexes = new Map(
|
|
54687
|
+
accounts.map((account, index) => [account, index])
|
|
54688
|
+
);
|
|
54181
54689
|
results = await this.quotaManager.refreshAccounts(accounts, {
|
|
54182
|
-
indexFor: (account) =>
|
|
54690
|
+
indexFor: (account) => indexes.get(account),
|
|
54691
|
+
publishSidebar: false,
|
|
54183
54692
|
// Do not force: the quota manager's per-account dedup and backoff
|
|
54184
54693
|
// apply — an account that already refreshed recently is skipped.
|
|
54185
54694
|
force: false
|
|
@@ -54187,7 +54696,7 @@ var BackgroundQuotaRefresh = class {
|
|
|
54187
54696
|
} catch {
|
|
54188
54697
|
return false;
|
|
54189
54698
|
}
|
|
54190
|
-
if (this.
|
|
54699
|
+
if (!await this.canRun()) return false;
|
|
54191
54700
|
const liveAccounts = manager.getAccounts();
|
|
54192
54701
|
const liveIndexByToken = /* @__PURE__ */ new Map();
|
|
54193
54702
|
for (const entry of liveAccounts) {
|
|
@@ -54196,7 +54705,8 @@ var BackgroundQuotaRefresh = class {
|
|
|
54196
54705
|
let anyUpdated = false;
|
|
54197
54706
|
for (let i = 0; i < results.length; i++) {
|
|
54198
54707
|
const result = results[i];
|
|
54199
|
-
if (result?.status !== "ok" || !result.quota?.groups)
|
|
54708
|
+
if (result?.status !== "ok" || !result.quota?.groups || result.checkedAt === void 0)
|
|
54709
|
+
continue;
|
|
54200
54710
|
const candidateTokens = [
|
|
54201
54711
|
result.updatedAccount?.refreshToken,
|
|
54202
54712
|
accounts[i]?.refreshToken
|
|
@@ -54205,7 +54715,13 @@ var BackgroundQuotaRefresh = class {
|
|
|
54205
54715
|
if (liveIndex === void 0) continue;
|
|
54206
54716
|
const liveToken = liveAccounts[liveIndex]?.parts.refreshToken;
|
|
54207
54717
|
if (!liveToken) continue;
|
|
54208
|
-
manager.updateQuotaCache(
|
|
54718
|
+
if (manager.updateQuotaCache(
|
|
54719
|
+
liveIndex,
|
|
54720
|
+
result.quota.groups,
|
|
54721
|
+
liveToken,
|
|
54722
|
+
result.checkedAt
|
|
54723
|
+
) === false)
|
|
54724
|
+
continue;
|
|
54209
54725
|
const uaTier = toCapturedTier(result.updatedAccount ?? {});
|
|
54210
54726
|
if (uaTier !== void 0) {
|
|
54211
54727
|
manager.applyUpdatedAccount(
|
|
@@ -54221,9 +54737,24 @@ var BackgroundQuotaRefresh = class {
|
|
|
54221
54737
|
}
|
|
54222
54738
|
anyUpdated = true;
|
|
54223
54739
|
}
|
|
54224
|
-
if (anyUpdated
|
|
54740
|
+
if (anyUpdated && await this.canRun()) {
|
|
54741
|
+
if (manager.saveToDisk) await manager.saveToDisk();
|
|
54742
|
+
else manager.requestSaveToDisk();
|
|
54743
|
+
}
|
|
54225
54744
|
return true;
|
|
54226
54745
|
}
|
|
54746
|
+
localObservations(manager) {
|
|
54747
|
+
const accounts = new Map(
|
|
54748
|
+
manager.getAccounts().map((row) => [row.parts.refreshToken, row])
|
|
54749
|
+
);
|
|
54750
|
+
return manager.getAccountsForQuotaCheck().map((target) => {
|
|
54751
|
+
const row = accounts.get(target.refreshToken);
|
|
54752
|
+
return {
|
|
54753
|
+
...target,
|
|
54754
|
+
cachedQuotaUpdatedAt: row?.cachedQuota && row.cachedQuotaUpdatedAt
|
|
54755
|
+
};
|
|
54756
|
+
});
|
|
54757
|
+
}
|
|
54227
54758
|
async refreshTierSlot() {
|
|
54228
54759
|
if (this.disposed || !this.loadAccountTier) return;
|
|
54229
54760
|
const manager = this.getAccountManager();
|
|
@@ -54248,7 +54779,7 @@ var BackgroundQuotaRefresh = class {
|
|
|
54248
54779
|
if (!accountForTier) return;
|
|
54249
54780
|
try {
|
|
54250
54781
|
const tier = await this.loadAccountTier(accountForTier);
|
|
54251
|
-
if (tier === null || this.
|
|
54782
|
+
if (tier === null || !await this.canRun()) return;
|
|
54252
54783
|
const liveEntry = manager.getAccounts().find((entry) => entry.parts.refreshToken === refreshToken);
|
|
54253
54784
|
if (!liveEntry) return;
|
|
54254
54785
|
manager.applyUpdatedAccount(
|
|
@@ -54284,6 +54815,7 @@ var BackgroundQuotaRefresh = class {
|
|
|
54284
54815
|
enabled: entry.enabled,
|
|
54285
54816
|
coolingDownUntil: entry.coolingDownUntil,
|
|
54286
54817
|
cachedQuota: entry.cachedQuota,
|
|
54818
|
+
cachedQuotaUpdatedAt: entry.cachedQuotaUpdatedAt,
|
|
54287
54819
|
cachedQuotaAccountId: entry.cachedQuotaAccountId,
|
|
54288
54820
|
// An account reorder changes which cached reading occupies an index.
|
|
54289
54821
|
// Use a refresh-token-derived account ID to detect that mismatch
|
|
@@ -54688,7 +55220,7 @@ async function buildLocationRuntime(options, scope) {
|
|
|
54688
55220
|
directory: options.directory,
|
|
54689
55221
|
config: settings.config,
|
|
54690
55222
|
keepThinking: settings.config.keep_thinking,
|
|
54691
|
-
projectConfigPath: legacyConfig?.projectConfigPath ??
|
|
55223
|
+
projectConfigPath: legacyConfig?.projectConfigPath ?? join31(options.directory, ".cortexkit", "antigravity-auth.jsonc"),
|
|
54692
55224
|
userConfigPath: legacyConfig?.userConfigPath ?? settings.operator.sourcePath()
|
|
54693
55225
|
};
|
|
54694
55226
|
settingsLease.runtime.startMove();
|
|
@@ -54718,6 +55250,7 @@ async function buildLocationRuntime(options, scope) {
|
|
|
54718
55250
|
enabled: entry.enabled,
|
|
54719
55251
|
coolingDownUntil: entry.coolingDownUntil,
|
|
54720
55252
|
cachedQuota: entry.cachedQuota,
|
|
55253
|
+
cachedQuotaUpdatedAt: entry.cachedQuotaUpdatedAt,
|
|
54721
55254
|
cachedQuotaAccountId: entry.cachedQuotaAccountId,
|
|
54722
55255
|
...identity4 ? { currentQuotaAccountId: identity4(entry.parts.refreshToken) } : {},
|
|
54723
55256
|
tier: toCapturedTier(entry)
|
|
@@ -55292,7 +55825,7 @@ function createGaReauthorize(input2) {
|
|
|
55292
55825
|
const continuations = /* @__PURE__ */ new Set();
|
|
55293
55826
|
const shutdown = new AbortController();
|
|
55294
55827
|
let disposed = false;
|
|
55295
|
-
const waitForRedirect = (code2) => new Promise((
|
|
55828
|
+
const waitForRedirect = (code2) => new Promise((resolve35, reject) => {
|
|
55296
55829
|
const detach = () => shutdown.signal.removeEventListener("abort", abort);
|
|
55297
55830
|
const abort = () => {
|
|
55298
55831
|
detach();
|
|
@@ -55303,7 +55836,7 @@ function createGaReauthorize(input2) {
|
|
|
55303
55836
|
void code2.then(
|
|
55304
55837
|
(value) => {
|
|
55305
55838
|
detach();
|
|
55306
|
-
|
|
55839
|
+
resolve35(value);
|
|
55307
55840
|
},
|
|
55308
55841
|
(error) => {
|
|
55309
55842
|
detach();
|
|
@@ -56990,6 +57523,7 @@ var MAX_NOTIFICATIONS_PER_STATE = ANTIGRAVITY_RPC_LIMITS.notificationsPerState;
|
|
|
56990
57523
|
var ANTIGRAVITY_STATE_RESETS = [
|
|
56991
57524
|
"initial",
|
|
56992
57525
|
"generation-changed",
|
|
57526
|
+
"queue-changed",
|
|
56993
57527
|
"cursor-ahead"
|
|
56994
57528
|
];
|
|
56995
57529
|
var Issues = class {
|
|
@@ -57803,7 +58337,7 @@ function validateStateInput(value, issues) {
|
|
|
57803
58337
|
path5,
|
|
57804
58338
|
issues,
|
|
57805
58339
|
["version", "scope", "cursor"],
|
|
57806
|
-
["generation"]
|
|
58340
|
+
["generation", "queueID"]
|
|
57807
58341
|
)) {
|
|
57808
58342
|
return;
|
|
57809
58343
|
}
|
|
@@ -57814,6 +58348,8 @@ function validateStateInput(value, issues) {
|
|
|
57814
58348
|
}
|
|
57815
58349
|
if (present4(value, "scope")) checkScope(value.scope, ["scope"], issues);
|
|
57816
58350
|
if (present4(value, "cursor")) checkCursor(value.cursor, ["cursor"], issues);
|
|
58351
|
+
if (present4(value, "queueID") && value.queueID !== null)
|
|
58352
|
+
checkGeneration(value.queueID, ["queueID"], issues);
|
|
57817
58353
|
}
|
|
57818
58354
|
function validateApplyInput(value, issues) {
|
|
57819
58355
|
const path5 = [];
|
|
@@ -57910,7 +58446,7 @@ function validateStateOutput(value, issues) {
|
|
|
57910
58446
|
"status",
|
|
57911
58447
|
"settings"
|
|
57912
58448
|
],
|
|
57913
|
-
["reset", "route", "vaultHostStatus"]
|
|
58449
|
+
["reset", "route", "vaultHostStatus", "queueID"]
|
|
57914
58450
|
)) {
|
|
57915
58451
|
return;
|
|
57916
58452
|
}
|
|
@@ -57926,6 +58462,8 @@ function validateStateOutput(value, issues) {
|
|
|
57926
58462
|
checkLiteral(value.reset, ANTIGRAVITY_STATE_RESETS, ["reset"], issues);
|
|
57927
58463
|
}
|
|
57928
58464
|
if (present4(value, "cursor")) checkCursor(value.cursor, ["cursor"], issues);
|
|
58465
|
+
if (present4(value, "queueID"))
|
|
58466
|
+
checkGeneration(value.queueID, ["queueID"], issues);
|
|
57929
58467
|
if (present4(value, "dropped")) {
|
|
57930
58468
|
checkCursor(value.dropped, ["dropped"], issues);
|
|
57931
58469
|
}
|
|
@@ -58464,8 +59002,7 @@ async function startGaLoopbackBridge(options) {
|
|
|
58464
59002
|
response.end(JSON.stringify({ error: { message: "unknown job" } }));
|
|
58465
59003
|
return;
|
|
58466
59004
|
}
|
|
58467
|
-
|
|
58468
|
-
clearTimeout(entry.timer);
|
|
59005
|
+
entry.release();
|
|
58469
59006
|
const state2 = {
|
|
58470
59007
|
id,
|
|
58471
59008
|
failure: void 0,
|
|
@@ -58534,11 +59071,11 @@ async function startGaLoopbackBridge(options) {
|
|
|
58534
59071
|
}
|
|
58535
59072
|
}
|
|
58536
59073
|
};
|
|
58537
|
-
await new Promise((
|
|
59074
|
+
await new Promise((resolve35, reject) => {
|
|
58538
59075
|
server.once("error", reject);
|
|
58539
59076
|
server.listen(0, BRIDGE_HOST, () => {
|
|
58540
59077
|
server.off("error", reject);
|
|
58541
|
-
|
|
59078
|
+
resolve35();
|
|
58542
59079
|
});
|
|
58543
59080
|
});
|
|
58544
59081
|
server.unref();
|
|
@@ -58549,20 +59086,27 @@ async function startGaLoopbackBridge(options) {
|
|
|
58549
59086
|
origin,
|
|
58550
59087
|
rewrite(original, job, env3) {
|
|
58551
59088
|
if (closing) throw new Error("The Antigravity bridge is disposed");
|
|
59089
|
+
const signal = original.signal;
|
|
59090
|
+
signal.throwIfAborted();
|
|
58552
59091
|
const id = randomUUID21();
|
|
58553
59092
|
const target = `${origin}/agy/${id}`;
|
|
58554
59093
|
assertLoopbackProxyGuard({ env: env3, target });
|
|
58555
|
-
const
|
|
58556
|
-
queued.delete(id);
|
|
58557
|
-
}, GA_UNCLAIMED_JOB_TTL_MS);
|
|
58558
|
-
timer.unref?.();
|
|
58559
|
-
queued.set(id, { job, timer });
|
|
58560
|
-
return new Request(target, {
|
|
59094
|
+
const rewritten = new Request(target, {
|
|
58561
59095
|
method: "POST",
|
|
58562
59096
|
headers: { "content-type": "application/json" },
|
|
58563
59097
|
body: "{}",
|
|
58564
|
-
signal
|
|
59098
|
+
signal
|
|
58565
59099
|
});
|
|
59100
|
+
const release3 = () => {
|
|
59101
|
+
clearTimeout(timer);
|
|
59102
|
+
signal.removeEventListener("abort", release3);
|
|
59103
|
+
queued.delete(id);
|
|
59104
|
+
};
|
|
59105
|
+
const timer = setTimeout(release3, GA_UNCLAIMED_JOB_TTL_MS);
|
|
59106
|
+
timer.unref?.();
|
|
59107
|
+
queued.set(id, { job, release: release3 });
|
|
59108
|
+
signal.addEventListener("abort", release3, { once: true });
|
|
59109
|
+
return rewritten;
|
|
58566
59110
|
},
|
|
58567
59111
|
adaptResponse(request2, response) {
|
|
58568
59112
|
let url;
|
|
@@ -58640,10 +59184,9 @@ async function startGaLoopbackBridge(options) {
|
|
|
58640
59184
|
if (!disposal) {
|
|
58641
59185
|
closing = true;
|
|
58642
59186
|
disposal = (async () => {
|
|
58643
|
-
for (const
|
|
58644
|
-
|
|
58645
|
-
|
|
58646
|
-
server.close(() => resolve34());
|
|
59187
|
+
for (const entry of queued.values()) entry.release();
|
|
59188
|
+
const closed2 = new Promise((resolve35) => {
|
|
59189
|
+
server.close(() => resolve35());
|
|
58647
59190
|
});
|
|
58648
59191
|
for (const controller of running) {
|
|
58649
59192
|
controller.abort(
|
|
@@ -58710,9 +59253,14 @@ async function pipeResponse(upstream, response, onFailure, onHandoff) {
|
|
|
58710
59253
|
return;
|
|
58711
59254
|
}
|
|
58712
59255
|
if (!response.write(value) && !response.destroyed) {
|
|
58713
|
-
await new Promise((
|
|
58714
|
-
|
|
58715
|
-
|
|
59256
|
+
await new Promise((resolve35) => {
|
|
59257
|
+
const resume = () => {
|
|
59258
|
+
response.off("drain", resume);
|
|
59259
|
+
response.off("close", resume);
|
|
59260
|
+
resolve35();
|
|
59261
|
+
};
|
|
59262
|
+
response.once("drain", resume);
|
|
59263
|
+
response.once("close", resume);
|
|
58716
59264
|
});
|
|
58717
59265
|
}
|
|
58718
59266
|
if (response.destroyed) {
|
|
@@ -58842,6 +59390,7 @@ function createGaRpcActivation(options) {
|
|
|
58842
59390
|
scopes.delete(key2);
|
|
58843
59391
|
} else {
|
|
58844
59392
|
queue2 = {
|
|
59393
|
+
id: randomUUID21(),
|
|
58845
59394
|
lastIssued: 0,
|
|
58846
59395
|
evictedThrough: 0,
|
|
58847
59396
|
notifications: [],
|
|
@@ -58940,6 +59489,8 @@ function createGaRpcActivation(options) {
|
|
|
58940
59489
|
let reset = null;
|
|
58941
59490
|
if (request2.generation === null) reset = "initial";
|
|
58942
59491
|
else if (request2.generation !== generation) reset = "generation-changed";
|
|
59492
|
+
else if (request2.queueID !== void 0 && request2.queueID !== queue2.id && (request2.queueID !== null || request2.cursor !== 0))
|
|
59493
|
+
reset = "queue-changed";
|
|
58943
59494
|
else if (request2.cursor > queue2.lastIssued) reset = "cursor-ahead";
|
|
58944
59495
|
const acknowledged = reset === null ? request2.cursor : 0;
|
|
58945
59496
|
queue2.notifications = queue2.notifications.filter(
|
|
@@ -58960,6 +59511,7 @@ function createGaRpcActivation(options) {
|
|
|
58960
59511
|
scope: request2.scope,
|
|
58961
59512
|
reset,
|
|
58962
59513
|
cursor,
|
|
59514
|
+
...request2.queueID !== void 0 ? { queueID: queue2.id } : {},
|
|
58963
59515
|
dropped: Math.max(0, queue2.evictedThrough - acknowledged),
|
|
58964
59516
|
more: queue2.notifications.length > delivered.length,
|
|
58965
59517
|
notifications: delivered,
|
|
@@ -59419,13 +59971,13 @@ function createGaAntigravityPlugin(overrides = {}) {
|
|
|
59419
59971
|
init_dist();
|
|
59420
59972
|
init_runtime_layout();
|
|
59421
59973
|
import { createHash as createHash24, randomUUID as randomUUID26 } from "node:crypto";
|
|
59422
|
-
import { join as
|
|
59974
|
+
import { join as join46, resolve as resolve34 } from "node:path";
|
|
59423
59975
|
|
|
59424
59976
|
// src/cli.ts
|
|
59425
59977
|
init_dist();
|
|
59426
59978
|
import { execFile } from "node:child_process";
|
|
59427
59979
|
import { realpathSync as realpathSync6 } from "node:fs";
|
|
59428
|
-
import { resolve as
|
|
59980
|
+
import { resolve as resolve30 } from "node:path";
|
|
59429
59981
|
import { createInterface } from "node:readline/promises";
|
|
59430
59982
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
59431
59983
|
import { promisify } from "node:util";
|
|
@@ -59481,8 +60033,8 @@ init_runtime_paths();
|
|
|
59481
60033
|
|
|
59482
60034
|
// src/setup.ts
|
|
59483
60035
|
init_dist();
|
|
59484
|
-
import { lstat as lstat10, readFile as
|
|
59485
|
-
import { join as
|
|
60036
|
+
import { lstat as lstat10, readFile as readFile23 } from "node:fs/promises";
|
|
60037
|
+
import { join as join37, resolve as resolve29 } from "node:path";
|
|
59486
60038
|
|
|
59487
60039
|
// src/common-auth-embedded/auth-menu/ansi.js
|
|
59488
60040
|
var ANSI2 = {
|
|
@@ -59650,7 +60202,7 @@ async function select2(terminal, items, options) {
|
|
|
59650
60202
|
writeLine("");
|
|
59651
60203
|
renderedLines = lines;
|
|
59652
60204
|
};
|
|
59653
|
-
return new Promise((
|
|
60205
|
+
return new Promise((resolve35) => {
|
|
59654
60206
|
const wasRaw = stdin.isRaw ?? false;
|
|
59655
60207
|
const cleanup2 = () => {
|
|
59656
60208
|
if (cleaned)
|
|
@@ -59670,7 +60222,7 @@ async function select2(terminal, items, options) {
|
|
|
59670
60222
|
};
|
|
59671
60223
|
const finish = (value) => {
|
|
59672
60224
|
cleanup2();
|
|
59673
|
-
|
|
60225
|
+
resolve35(value);
|
|
59674
60226
|
};
|
|
59675
60227
|
const onSignal = () => finish(null);
|
|
59676
60228
|
const onKey = (data) => {
|
|
@@ -59710,7 +60262,7 @@ async function select2(terminal, items, options) {
|
|
|
59710
60262
|
stdin.setRawMode(true);
|
|
59711
60263
|
} catch {
|
|
59712
60264
|
cleanup2();
|
|
59713
|
-
|
|
60265
|
+
resolve35(null);
|
|
59714
60266
|
return;
|
|
59715
60267
|
}
|
|
59716
60268
|
stdin.resume();
|
|
@@ -59723,13 +60275,13 @@ async function select2(terminal, items, options) {
|
|
|
59723
60275
|
// src/common-auth-embedded/claustrum/enrollment.js
|
|
59724
60276
|
import { createHash as createHash19, randomBytes as randomBytes6, randomUUID as randomUUID23 } from "node:crypto";
|
|
59725
60277
|
import { constants as fsConstants2 } from "node:fs";
|
|
59726
|
-
import { chmod as chmod6, mkdir as mkdir18, open as open11, readFile as
|
|
59727
|
-
import { basename as basename13, dirname as
|
|
60278
|
+
import { chmod as chmod6, mkdir as mkdir18, open as open11, readFile as readFile21, realpath as realpath6, rename as rename13, stat as stat17, unlink as unlink14 } from "node:fs/promises";
|
|
60279
|
+
import { basename as basename13, dirname as dirname28, extname as extname2, isAbsolute as isAbsolute4, join as join33, resolve as resolve28 } from "node:path";
|
|
59728
60280
|
import { ClaustrumCredentialError as ClaustrumCredentialError9, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
59729
60281
|
|
|
59730
60282
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
59731
60283
|
import { lstat as lstat8, stat as stat15 } from "node:fs/promises";
|
|
59732
|
-
import { resolve as
|
|
60284
|
+
import { resolve as resolve26 } from "node:path";
|
|
59733
60285
|
async function identity3(path5, probe) {
|
|
59734
60286
|
try {
|
|
59735
60287
|
const metadata = await probe(path5);
|
|
@@ -59750,7 +60302,7 @@ var FileReadCache2 = class {
|
|
|
59750
60302
|
this.#probe = options.followSymlinks ? (path5) => (options.stat ?? stat15)(path5) : (path5) => (options.lstat ?? lstat8)(path5);
|
|
59751
60303
|
}
|
|
59752
60304
|
async read(paths, read, validateHit) {
|
|
59753
|
-
const resolvedPaths = paths.map((path5) =>
|
|
60305
|
+
const resolvedPaths = paths.map((path5) => resolve26(path5));
|
|
59754
60306
|
const key2 = JSON.stringify(resolvedPaths);
|
|
59755
60307
|
const probed = await Promise.all(resolvedPaths.map((path5) => identity3(path5, this.#probe)));
|
|
59756
60308
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -59801,12 +60353,12 @@ init_private_files2();
|
|
|
59801
60353
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
59802
60354
|
init_logger3();
|
|
59803
60355
|
import { randomUUID as randomUUID22 } from "node:crypto";
|
|
59804
|
-
import { link as link4, lstat as lstat9, mkdir as mkdir17, open as open10, readdir as readdir6, readFile as
|
|
59805
|
-
import { basename as basename12, dirname as
|
|
60356
|
+
import { link as link4, lstat as lstat9, mkdir as mkdir17, open as open10, readdir as readdir6, readFile as readFile20, rename as rename12, rm as rm7, stat as stat16, unlink as unlink13 } from "node:fs/promises";
|
|
60357
|
+
import { basename as basename12, dirname as dirname27, join as join32 } from "node:path";
|
|
59806
60358
|
|
|
59807
60359
|
// src/common-auth-embedded/fs/lock-record.js
|
|
59808
60360
|
init_private_files2();
|
|
59809
|
-
import { resolve as
|
|
60361
|
+
import { resolve as resolve27 } from "node:path";
|
|
59810
60362
|
var DisappearedLockRecordError2 = class extends Error {
|
|
59811
60363
|
path;
|
|
59812
60364
|
code = "ENOENT";
|
|
@@ -59816,10 +60368,10 @@ var DisappearedLockRecordError2 = class extends Error {
|
|
|
59816
60368
|
}
|
|
59817
60369
|
};
|
|
59818
60370
|
function isWindowsAccessDeniedRead2(error, paths) {
|
|
59819
|
-
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path5) =>
|
|
60371
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path5) => resolve27(path5) === error.path);
|
|
59820
60372
|
}
|
|
59821
60373
|
function isWindowsAccessDeniedCreate2(error, paths, stage) {
|
|
59822
|
-
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path5) =>
|
|
60374
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path5) => resolve27(path5) === error.path);
|
|
59823
60375
|
}
|
|
59824
60376
|
async function readLockRecord2(path5, read) {
|
|
59825
60377
|
try {
|
|
@@ -59961,14 +60513,14 @@ async function readStagedOwner2(path5) {
|
|
|
59961
60513
|
return { identity: before, expiresAt };
|
|
59962
60514
|
}
|
|
59963
60515
|
async function sweepAbandonedStaging2(lockPath, ttlMs, now2) {
|
|
59964
|
-
const directory =
|
|
60516
|
+
const directory = dirname27(lockPath);
|
|
59965
60517
|
const lockName = basename12(lockPath);
|
|
59966
60518
|
const hooks = stagingSweepTestHooks2;
|
|
59967
60519
|
const names = await (hooks?.readdir ?? readdir6)(directory);
|
|
59968
60520
|
const candidates = names.filter((name) => isStagingName2(name, lockName)).slice(0, STAGING_SWEEP_MAX_CANDIDATES2);
|
|
59969
60521
|
const marginMs = Math.max(Number.isFinite(ttlMs) ? ttlMs : 0, STAGING_SWEEP_MIN_AGE_MS2);
|
|
59970
60522
|
for (const name of candidates) {
|
|
59971
|
-
const path5 =
|
|
60523
|
+
const path5 = join32(directory, name);
|
|
59972
60524
|
try {
|
|
59973
60525
|
if (now2() - (await lstat9(path5)).mtimeMs < marginMs)
|
|
59974
60526
|
continue;
|
|
@@ -60014,7 +60566,7 @@ function acquireRefreshFileLock2(options) {
|
|
|
60014
60566
|
}
|
|
60015
60567
|
async function acquireRefreshFileLockWithClock2(options) {
|
|
60016
60568
|
const lockPath = lockPathFor2(options.path, options.name);
|
|
60017
|
-
const legacyOwnerPath =
|
|
60569
|
+
const legacyOwnerPath = join32(lockPath, "owner.json");
|
|
60018
60570
|
const ownerId = randomUUID22();
|
|
60019
60571
|
const now2 = options.now ?? Date.now;
|
|
60020
60572
|
let renewTimer = null;
|
|
@@ -60022,8 +60574,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
60022
60574
|
let releaseConfirmed = false;
|
|
60023
60575
|
let loss;
|
|
60024
60576
|
let resolveLoss;
|
|
60025
|
-
const lostPromise = new Promise((
|
|
60026
|
-
resolveLoss =
|
|
60577
|
+
const lostPromise = new Promise((resolve35) => {
|
|
60578
|
+
resolveLoss = resolve35;
|
|
60027
60579
|
});
|
|
60028
60580
|
function notifyTimerStep(event) {
|
|
60029
60581
|
try {
|
|
@@ -60057,7 +60609,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
60057
60609
|
let terminalIOError;
|
|
60058
60610
|
let renewalInFlight = null;
|
|
60059
60611
|
const evictPath = `${lockPath}.evicting`;
|
|
60060
|
-
const evictOwnerPath =
|
|
60612
|
+
const evictOwnerPath = join32(evictPath, "owner.json");
|
|
60061
60613
|
const evictOwnerId = randomUUID22();
|
|
60062
60614
|
const EVICT_TTL = 5e3;
|
|
60063
60615
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
@@ -60076,12 +60628,12 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
60076
60628
|
}
|
|
60077
60629
|
}
|
|
60078
60630
|
try {
|
|
60079
|
-
return JSON.parse(await
|
|
60631
|
+
return JSON.parse(await readFile20(lockPath, "utf8"));
|
|
60080
60632
|
} catch (error) {
|
|
60081
60633
|
const code2 = error.code;
|
|
60082
60634
|
if (code2 !== "EISDIR")
|
|
60083
60635
|
throw error;
|
|
60084
|
-
return JSON.parse(await
|
|
60636
|
+
return JSON.parse(await readFile20(legacyOwnerPath, "utf8"));
|
|
60085
60637
|
}
|
|
60086
60638
|
}
|
|
60087
60639
|
async function writeOwner() {
|
|
@@ -60161,7 +60713,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
60161
60713
|
}
|
|
60162
60714
|
async function tryAcquire() {
|
|
60163
60715
|
if (windowsPrivateFiles2)
|
|
60164
|
-
await ensurePrivateDirectory2(
|
|
60716
|
+
await ensurePrivateDirectory2(dirname27(lockPath));
|
|
60165
60717
|
try {
|
|
60166
60718
|
await createLease();
|
|
60167
60719
|
return true;
|
|
@@ -60171,9 +60723,9 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
60171
60723
|
return false;
|
|
60172
60724
|
if (code2 === "ENOENT") {
|
|
60173
60725
|
if (windowsPrivateFiles2)
|
|
60174
|
-
await ensurePrivateDirectory2(
|
|
60726
|
+
await ensurePrivateDirectory2(dirname27(lockPath));
|
|
60175
60727
|
else
|
|
60176
|
-
await mkdir17(
|
|
60728
|
+
await mkdir17(dirname27(lockPath), { recursive: true });
|
|
60177
60729
|
try {
|
|
60178
60730
|
await createLease();
|
|
60179
60731
|
return true;
|
|
@@ -60187,7 +60739,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
60187
60739
|
}
|
|
60188
60740
|
}
|
|
60189
60741
|
async function backoff() {
|
|
60190
|
-
await new Promise((
|
|
60742
|
+
await new Promise((resolve35) => setTimeout(resolve35, Math.floor(Math.random() * 4)));
|
|
60191
60743
|
}
|
|
60192
60744
|
async function readLockState(notifyReady = true) {
|
|
60193
60745
|
if (notifyReady && options.onStep)
|
|
@@ -60280,7 +60832,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
60280
60832
|
const remainingMs = deadline - performance.now();
|
|
60281
60833
|
if (remainingMs <= 0)
|
|
60282
60834
|
throw original;
|
|
60283
|
-
await new Promise((
|
|
60835
|
+
await new Promise((resolve35) => setTimeout(resolve35, Math.min(delayMs, remainingMs)));
|
|
60284
60836
|
if (performance.now() >= deadline)
|
|
60285
60837
|
throw original;
|
|
60286
60838
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -60783,7 +61335,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
60783
61335
|
const remainingMs = deadline - performance.now();
|
|
60784
61336
|
if (remainingMs <= 0)
|
|
60785
61337
|
break;
|
|
60786
|
-
await new Promise((
|
|
61338
|
+
await new Promise((resolve35) => setTimeout(resolve35, Math.min(delayMs, remainingMs)));
|
|
60787
61339
|
if (windowsPrivateFiles2 && performance.now() >= deadline)
|
|
60788
61340
|
break;
|
|
60789
61341
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -60864,7 +61416,7 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
|
|
|
60864
61416
|
const extension = extname2(tokenPath) || ".json";
|
|
60865
61417
|
const stem = basename13(tokenPath, extname2(tokenPath));
|
|
60866
61418
|
return {
|
|
60867
|
-
statePath:
|
|
61419
|
+
statePath: join33(dirname28(tokenPath), `${stem}-state${extension}`),
|
|
60868
61420
|
tokenPath
|
|
60869
61421
|
};
|
|
60870
61422
|
}
|
|
@@ -60872,7 +61424,7 @@ function hostEnrollmentPaths2(input2) {
|
|
|
60872
61424
|
const override = input2.override?.trim();
|
|
60873
61425
|
if (override && !isAbsolute4(override) && !input2.cwd)
|
|
60874
61426
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
60875
|
-
const tokenPath = override ? isAbsolute4(override) ? override :
|
|
61427
|
+
const tokenPath = override ? isAbsolute4(override) ? override : resolve28(input2.cwd, override) : join33(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
60876
61428
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
60877
61429
|
}
|
|
60878
61430
|
function isRecord11(value) {
|
|
@@ -60978,7 +61530,7 @@ function parseSecretJson2(text2) {
|
|
|
60978
61530
|
async function readBoundedJson2(path5) {
|
|
60979
61531
|
if (windowsPrivateFiles2) {
|
|
60980
61532
|
try {
|
|
60981
|
-
await ensurePrivateDirectory2(
|
|
61533
|
+
await ensurePrivateDirectory2(dirname28(path5));
|
|
60982
61534
|
const text2 = await readPrivateText2(path5, true);
|
|
60983
61535
|
if (Buffer.byteLength(text2) > ENROLLMENT_FILE_MAX_BYTES2) {
|
|
60984
61536
|
throw new ClaustrumConsumerError2("unsafe-file", "Claustrum enrollment file is too large");
|
|
@@ -61025,8 +61577,8 @@ function accountRecords2(text2, fields2) {
|
|
|
61025
61577
|
async function isPrivateGroup2(uid, gid, options) {
|
|
61026
61578
|
try {
|
|
61027
61579
|
const [passwdText, groupText] = await Promise.all([
|
|
61028
|
-
|
|
61029
|
-
|
|
61580
|
+
readFile21(options.passwdPath ?? "/etc/passwd", "utf8"),
|
|
61581
|
+
readFile21(options.groupPath ?? "/etc/group", "utf8")
|
|
61030
61582
|
]);
|
|
61031
61583
|
const users = accountRecords2(passwdText, 7);
|
|
61032
61584
|
const groups = accountRecords2(groupText, 4);
|
|
@@ -61048,7 +61600,7 @@ function ancestorPolicyOptions2(options) {
|
|
|
61048
61600
|
return void 0;
|
|
61049
61601
|
return {
|
|
61050
61602
|
fs: {
|
|
61051
|
-
readFile: (path5) =>
|
|
61603
|
+
readFile: (path5) => readFile21(path5 === "/etc/passwd" ? options.passwdPath ?? path5 : path5 === "/etc/group" ? options.groupPath ?? path5 : path5)
|
|
61052
61604
|
}
|
|
61053
61605
|
};
|
|
61054
61606
|
}
|
|
@@ -61075,7 +61627,7 @@ async function refuseWritableAncestor2(parent, options = {}) {
|
|
|
61075
61627
|
throw new ClaustrumConsumerError2("unsafe-file", `Claustrum enrollment path has a writable ancestor: ${component}. Another user could replace it. Run: chmod g-w,o-w ${component}`);
|
|
61076
61628
|
}
|
|
61077
61629
|
}
|
|
61078
|
-
const next =
|
|
61630
|
+
const next = dirname28(component);
|
|
61079
61631
|
if (next === component)
|
|
61080
61632
|
return;
|
|
61081
61633
|
component = next;
|
|
@@ -61104,7 +61656,7 @@ async function ensureClaustrumPrivateDirectory2(directory, options = {}, what =
|
|
|
61104
61656
|
await chmod6(directory, 448);
|
|
61105
61657
|
}
|
|
61106
61658
|
async function writeStateAtomic2(path5, state2, ancestorOptions = {}) {
|
|
61107
|
-
const parent =
|
|
61659
|
+
const parent = dirname28(path5);
|
|
61108
61660
|
await ensureClaustrumPrivateDirectory2(parent, ancestorOptions);
|
|
61109
61661
|
await refuseWritableAncestor2(parent, ancestorOptions);
|
|
61110
61662
|
const bytes = `${JSON.stringify(state2)}
|
|
@@ -61114,7 +61666,7 @@ async function writeStateAtomic2(path5, state2, ancestorOptions = {}) {
|
|
|
61114
61666
|
}
|
|
61115
61667
|
if (windowsPrivateFiles2)
|
|
61116
61668
|
return writePrivateAtomic2(path5, bytes);
|
|
61117
|
-
const temporary =
|
|
61669
|
+
const temporary = join33(parent, `.${basename13(path5)}.${process.pid}.${randomUUID23()}.tmp`);
|
|
61118
61670
|
let descriptor;
|
|
61119
61671
|
let created = false;
|
|
61120
61672
|
try {
|
|
@@ -61293,7 +61845,7 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
61293
61845
|
return statusFromState2(blocked);
|
|
61294
61846
|
}
|
|
61295
61847
|
async reconcile() {
|
|
61296
|
-
await ensureClaustrumPrivateDirectory2(
|
|
61848
|
+
await ensureClaustrumPrivateDirectory2(dirname28(this.#paths.statePath), this.#ancestorOptions);
|
|
61297
61849
|
const lock = await acquireRefreshFileLock2({
|
|
61298
61850
|
name: "ceremony",
|
|
61299
61851
|
path: this.#paths.statePath,
|
|
@@ -61446,8 +61998,8 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
61446
61998
|
await writeStateAtomic2(this.#paths.statePath, denied, this.#ancestorOptions);
|
|
61447
61999
|
return statusFromState2(denied);
|
|
61448
62000
|
}
|
|
61449
|
-
await ensureClaustrumPrivateDirectory2(
|
|
61450
|
-
await refuseWritableAncestor2(
|
|
62001
|
+
await ensureClaustrumPrivateDirectory2(dirname28(this.#paths.tokenPath), this.#ancestorOptions);
|
|
62002
|
+
await refuseWritableAncestor2(dirname28(this.#paths.tokenPath), this.#ancestorOptions);
|
|
61451
62003
|
await this.#writeTokenFile(this.#paths.tokenPath, {
|
|
61452
62004
|
token: outcome.token,
|
|
61453
62005
|
token_generation: outcome.tokenGeneration
|
|
@@ -61484,7 +62036,7 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
61484
62036
|
}
|
|
61485
62037
|
};
|
|
61486
62038
|
async function resetClaustrumEnrollmentState2(paths, proposedName) {
|
|
61487
|
-
await ensureClaustrumPrivateDirectory2(
|
|
62039
|
+
await ensureClaustrumPrivateDirectory2(dirname28(paths.statePath));
|
|
61488
62040
|
const lock = await acquireRefreshFileLock2({
|
|
61489
62041
|
name: "ceremony",
|
|
61490
62042
|
path: paths.statePath,
|
|
@@ -61566,7 +62118,7 @@ var ByteTail = class {
|
|
|
61566
62118
|
};
|
|
61567
62119
|
var defaultCommandRunner = {
|
|
61568
62120
|
run(file, args, options = {}) {
|
|
61569
|
-
return new Promise((
|
|
62121
|
+
return new Promise((resolve35) => {
|
|
61570
62122
|
const started = performance.now();
|
|
61571
62123
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
61572
62124
|
const stderr = new ByteTail();
|
|
@@ -61584,7 +62136,7 @@ var defaultCommandRunner = {
|
|
|
61584
62136
|
stdio: ["ignore", "pipe", "pipe"]
|
|
61585
62137
|
});
|
|
61586
62138
|
} catch {
|
|
61587
|
-
|
|
62139
|
+
resolve35({
|
|
61588
62140
|
exitCode: 1,
|
|
61589
62141
|
stdout: "",
|
|
61590
62142
|
stderr: "",
|
|
@@ -61619,7 +62171,7 @@ var defaultCommandRunner = {
|
|
|
61619
62171
|
settled = true;
|
|
61620
62172
|
if (timer)
|
|
61621
62173
|
clearTimeout(timer);
|
|
61622
|
-
|
|
62174
|
+
resolve35({
|
|
61623
62175
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
61624
62176
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
61625
62177
|
stderr: stderr.toString(),
|
|
@@ -61775,10 +62327,10 @@ function recordSetupEnrollment(failure2, enrollment) {
|
|
|
61775
62327
|
}
|
|
61776
62328
|
|
|
61777
62329
|
// src/common-auth-embedded/setup/detect.js
|
|
61778
|
-
import { accessSync, constants as constants3, existsSync as existsSync12, readFileSync as readFileSync11, realpathSync as realpathSync5, statSync as
|
|
62330
|
+
import { accessSync, constants as constants3, existsSync as existsSync12, readFileSync as readFileSync11, realpathSync as realpathSync5, statSync as statSync7 } from "node:fs";
|
|
61779
62331
|
import { mkdtemp, rm as rm8 } from "node:fs/promises";
|
|
61780
|
-
import { tmpdir as
|
|
61781
|
-
import { join as
|
|
62332
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
62333
|
+
import { join as join34 } from "node:path";
|
|
61782
62334
|
import { parse } from "jsonc-parser";
|
|
61783
62335
|
|
|
61784
62336
|
// src/common-auth-embedded/setup/paths.js
|
|
@@ -61815,7 +62367,7 @@ function setupPaths(io = {}) {
|
|
|
61815
62367
|
// src/common-auth-embedded/setup/detect.js
|
|
61816
62368
|
function stat18(path5, kind) {
|
|
61817
62369
|
try {
|
|
61818
|
-
return
|
|
62370
|
+
return statSync7(path5)[kind]();
|
|
61819
62371
|
} catch {
|
|
61820
62372
|
return false;
|
|
61821
62373
|
}
|
|
@@ -61949,7 +62501,7 @@ async function detectHosts(plugin2, io = {}) {
|
|
|
61949
62501
|
return null;
|
|
61950
62502
|
let root;
|
|
61951
62503
|
try {
|
|
61952
|
-
root = await mkdtemp(
|
|
62504
|
+
root = await mkdtemp(join34(tmpdir4(), "common-auth-setup-version-"));
|
|
61953
62505
|
const probeEnv = {
|
|
61954
62506
|
...env3,
|
|
61955
62507
|
HOME: root,
|
|
@@ -62016,14 +62568,14 @@ import { writeEnrollmentTokenFile as writeEnrollmentTokenFile3 } from "@cortexki
|
|
|
62016
62568
|
|
|
62017
62569
|
// src/common-auth-embedded/setup/process-fence.js
|
|
62018
62570
|
init_logger3();
|
|
62019
|
-
import { statSync as
|
|
62571
|
+
import { statSync as statSync8 } from "node:fs";
|
|
62020
62572
|
import { win32 as win325 } from "node:path";
|
|
62021
62573
|
var WINDOWS_CIM_TIMEOUT_MS = 45e3;
|
|
62022
62574
|
var log13 = createLogger3("setup-process-fence");
|
|
62023
62575
|
var WINDOWS_ARM_POWERSHELL_TIMEOUT_MS = 9e4;
|
|
62024
62576
|
function isFile(file) {
|
|
62025
62577
|
try {
|
|
62026
|
-
return
|
|
62578
|
+
return statSync8(file).isFile();
|
|
62027
62579
|
} catch {
|
|
62028
62580
|
return false;
|
|
62029
62581
|
}
|
|
@@ -62629,11 +63181,11 @@ import { applyEdits as applyEdits2, createScanner as createScanner2, findNodeAtL
|
|
|
62629
63181
|
// src/common-auth-embedded/setup/config-write.js
|
|
62630
63182
|
import { randomUUID as randomUUID24 } from "node:crypto";
|
|
62631
63183
|
import { mkdir as mkdir19, open as open12, rename as rename14, stat as stat19, unlink as unlink15 } from "node:fs/promises";
|
|
62632
|
-
import { basename as basename14, dirname as
|
|
63184
|
+
import { basename as basename14, dirname as dirname29, join as join35 } from "node:path";
|
|
62633
63185
|
import { setTimeout as delay3 } from "node:timers/promises";
|
|
62634
63186
|
async function writeHostConfigAtomic(file, content, options = {}) {
|
|
62635
63187
|
const windows2 = (options.platform ?? process.platform) === "win32";
|
|
62636
|
-
const parent =
|
|
63188
|
+
const parent = dirname29(file);
|
|
62637
63189
|
await mkdir19(parent, { recursive: true });
|
|
62638
63190
|
let mode;
|
|
62639
63191
|
if (!windows2) {
|
|
@@ -62644,7 +63196,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
|
|
|
62644
63196
|
throw error;
|
|
62645
63197
|
}
|
|
62646
63198
|
}
|
|
62647
|
-
const stage =
|
|
63199
|
+
const stage = join35(parent, `.${basename14(file)}.${(options.stageName ?? randomUUID24)()}.tmp`);
|
|
62648
63200
|
let created = false;
|
|
62649
63201
|
try {
|
|
62650
63202
|
const handle = await open12(stage, "wx", mode ?? 438);
|
|
@@ -63094,13 +63646,13 @@ init_storage();
|
|
|
63094
63646
|
|
|
63095
63647
|
// src/plugin/vault-activation.ts
|
|
63096
63648
|
init_dist();
|
|
63097
|
-
import { readFile as
|
|
63649
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
63098
63650
|
import { homedir as homedir12 } from "node:os";
|
|
63099
|
-
import { join as
|
|
63651
|
+
import { join as join36 } from "node:path";
|
|
63100
63652
|
var V1_VAULT_ACTIVATION_LABEL = "Activate approved Antigravity vault";
|
|
63101
63653
|
function nativeOpenCodeAuthPath(env3 = process.env, home = homedir12()) {
|
|
63102
|
-
return
|
|
63103
|
-
env3.XDG_DATA_HOME ||
|
|
63654
|
+
return join36(
|
|
63655
|
+
env3.XDG_DATA_HOME || join36(home, ".local", "share"),
|
|
63104
63656
|
"opencode",
|
|
63105
63657
|
"auth.json"
|
|
63106
63658
|
);
|
|
@@ -63119,7 +63671,7 @@ function createV1VaultActivationMethod(input2) {
|
|
|
63119
63671
|
return { type: "failed" };
|
|
63120
63672
|
try {
|
|
63121
63673
|
const value = JSON.parse(
|
|
63122
|
-
await
|
|
63674
|
+
await readFile22(
|
|
63123
63675
|
(input2.authFile ?? nativeOpenCodeAuthPath)(),
|
|
63124
63676
|
"utf8"
|
|
63125
63677
|
)
|
|
@@ -63171,7 +63723,7 @@ function openCodeVaultDir(accountFile) {
|
|
|
63171
63723
|
return folder.vaultDir;
|
|
63172
63724
|
}
|
|
63173
63725
|
function nativeAuthPath(host, context) {
|
|
63174
|
-
return host === "opencode" ? nativeOpenCodeAuthPath() :
|
|
63726
|
+
return host === "opencode" ? nativeOpenCodeAuthPath() : join37(context.piAgentDir, "auth.json");
|
|
63175
63727
|
}
|
|
63176
63728
|
function provider(host) {
|
|
63177
63729
|
return host === "opencode" ? OPENCODE_VAULT_PROVIDER : ANTIGRAVITY_PROVIDER_ID;
|
|
@@ -63184,7 +63736,7 @@ async function readNativeAuth(path5) {
|
|
|
63184
63736
|
const info = await lstat10(path5);
|
|
63185
63737
|
if (!info.isFile() || info.nlink !== 1)
|
|
63186
63738
|
throw new Error("Native auth must be a regular, unaliased file.");
|
|
63187
|
-
const value = JSON.parse(await
|
|
63739
|
+
const value = JSON.parse(await readFile23(path5, "utf8"));
|
|
63188
63740
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
63189
63741
|
throw new Error("Native auth is invalid; refusing to replace it.");
|
|
63190
63742
|
return value;
|
|
@@ -63193,19 +63745,31 @@ async function readNativeAuth(path5) {
|
|
|
63193
63745
|
throw error;
|
|
63194
63746
|
}
|
|
63195
63747
|
}
|
|
63748
|
+
async function readOpenCodeAuthority(legacyPath) {
|
|
63749
|
+
try {
|
|
63750
|
+
const claustrum = await loadCommonAuthClaustrum();
|
|
63751
|
+
if (claustrum.hasVaultHost()) return "host";
|
|
63752
|
+
return await vaultAuthority2(
|
|
63753
|
+
claustrum.hostEnrollmentPaths({
|
|
63754
|
+
stateDir: openCodeVaultDir(
|
|
63755
|
+
legacyPath ?? resolve29(accountFileForVault())
|
|
63756
|
+
),
|
|
63757
|
+
host: "opencode"
|
|
63758
|
+
}),
|
|
63759
|
+
OPENCODE_VAULT_ENROLLMENT_NAME,
|
|
63760
|
+
claustrum
|
|
63761
|
+
);
|
|
63762
|
+
} catch {
|
|
63763
|
+
return "unreadable";
|
|
63764
|
+
}
|
|
63765
|
+
}
|
|
63196
63766
|
async function assertLocalOpenCodeLogin(legacyPath, generation) {
|
|
63197
|
-
|
|
63198
|
-
if (await claustrum.vaultAuthority(
|
|
63199
|
-
claustrum.hostEnrollmentPaths({
|
|
63200
|
-
stateDir: openCodeVaultDir(legacyPath),
|
|
63201
|
-
host: "opencode"
|
|
63202
|
-
}),
|
|
63203
|
-
OPENCODE_VAULT_ENROLLMENT_NAME
|
|
63204
|
-
) !== "local")
|
|
63767
|
+
if (await readOpenCodeAuthority(legacyPath) !== "local")
|
|
63205
63768
|
throw new Error(
|
|
63206
63769
|
"Vault enrollment excludes local sign-in. Resolve vault access before choosing local setup."
|
|
63207
63770
|
);
|
|
63208
63771
|
if (generation === "2") return;
|
|
63772
|
+
const claustrum = await loadCommonAuthClaustrum();
|
|
63209
63773
|
claustrum.assertHostSlotMatchesMode({
|
|
63210
63774
|
mode: "local",
|
|
63211
63775
|
auth: (await readNativeAuth(nativeOpenCodeAuthPath()))[OPENCODE_VAULT_PROVIDER],
|
|
@@ -63227,7 +63791,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
63227
63791
|
beforeRename: async () => {
|
|
63228
63792
|
await assertSetupHostsStopped();
|
|
63229
63793
|
const claustrum = await loadCommonAuthClaustrum();
|
|
63230
|
-
const stateDir = host === "opencode" ? openCodeVaultDir(
|
|
63794
|
+
const stateDir = host === "opencode" ? openCodeVaultDir(resolve29(accountFileForVault())) : getPiAntigravityVaultDir();
|
|
63231
63795
|
if (await claustrum.vaultAuthority(
|
|
63232
63796
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
63233
63797
|
`antigravity-auth-${host}`
|
|
@@ -63272,7 +63836,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
63272
63836
|
// `beforeSignIn`, which may move it after this plugin is built.
|
|
63273
63837
|
paths: {
|
|
63274
63838
|
get stateDir() {
|
|
63275
|
-
return openCodeVaultDir(
|
|
63839
|
+
return openCodeVaultDir(resolve29(accountFileForVault()));
|
|
63276
63840
|
},
|
|
63277
63841
|
host: "opencode"
|
|
63278
63842
|
}
|
|
@@ -63296,7 +63860,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
63296
63860
|
const assertLocal = async (host, context) => {
|
|
63297
63861
|
if (host === "opencode")
|
|
63298
63862
|
return assertLocalOpenCodeLogin(
|
|
63299
|
-
|
|
63863
|
+
resolve29(accountFileForVault()),
|
|
63300
63864
|
context.opencodeGeneration
|
|
63301
63865
|
);
|
|
63302
63866
|
if (await authority(host) !== "local")
|
|
@@ -63312,7 +63876,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
63312
63876
|
const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
|
|
63313
63877
|
if ((await openPiSlot2({
|
|
63314
63878
|
authPath: nativeAuthPath(host, context),
|
|
63315
|
-
stashPath:
|
|
63879
|
+
stashPath: join37(piDir, "google-login-stash.json"),
|
|
63316
63880
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
63317
63881
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
63318
63882
|
}).inspect()).slot === "placeholder")
|
|
@@ -63330,7 +63894,7 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
63330
63894
|
);
|
|
63331
63895
|
};
|
|
63332
63896
|
const manifest = JSON.parse(
|
|
63333
|
-
await
|
|
63897
|
+
await readFile23(new URL("../package.json", import.meta.url), "utf8")
|
|
63334
63898
|
);
|
|
63335
63899
|
return {
|
|
63336
63900
|
packages: {
|
|
@@ -63359,7 +63923,7 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
63359
63923
|
const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
|
|
63360
63924
|
await openPiSlot2({
|
|
63361
63925
|
authPath: nativeAuthPath("pi", context),
|
|
63362
|
-
stashPath:
|
|
63926
|
+
stashPath: join37(piDir, "google-login-stash.json"),
|
|
63363
63927
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
63364
63928
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
63365
63929
|
}).inspect();
|
|
@@ -63472,7 +64036,7 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
63472
64036
|
await assertSetupHostsStopped();
|
|
63473
64037
|
await openPiSlot2({
|
|
63474
64038
|
authPath: nativeAuthPath(host, context),
|
|
63475
|
-
stashPath:
|
|
64039
|
+
stashPath: join37(piDir, "google-login-stash.json"),
|
|
63476
64040
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
63477
64041
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
63478
64042
|
}).enterVault();
|
|
@@ -63821,6 +64385,16 @@ async function runCli(argv, deps) {
|
|
|
63821
64385
|
return 0;
|
|
63822
64386
|
}
|
|
63823
64387
|
try {
|
|
64388
|
+
const assertLocalAccounts = async () => {
|
|
64389
|
+
const authority = await (deps.readAuthority ?? readOpenCodeAuthority)();
|
|
64390
|
+
if (authority === "local") return;
|
|
64391
|
+
const source2 = authority === "vault" ? "Accounts are served by the vault, not this computer's local sign-ins." : authority === "host" ? "Accounts are served by Thalamus, not this computer's local sign-ins." : "Account authority could not be read, so this computer's local sign-ins were not used.";
|
|
64392
|
+
throw new Error(
|
|
64393
|
+
`${source2} Use the /antigravity menu in OpenCode to see them and their quota.`
|
|
64394
|
+
);
|
|
64395
|
+
};
|
|
64396
|
+
if (parsed.value.command === "list" || parsed.value.command === "quota")
|
|
64397
|
+
await assertLocalAccounts();
|
|
63824
64398
|
if (parsed.value.command !== "setup") {
|
|
63825
64399
|
if (parsed.value.command === "login") await deps.prepareVaultFolder?.();
|
|
63826
64400
|
await deps.processHeartbeat?.();
|
|
@@ -63925,7 +64499,8 @@ async function runCli(argv, deps) {
|
|
|
63925
64499
|
return 0;
|
|
63926
64500
|
}
|
|
63927
64501
|
const results = await deps.getQuota(storage?.accounts ?? [], {
|
|
63928
|
-
refresh: parsed.value.refresh
|
|
64502
|
+
refresh: parsed.value.refresh,
|
|
64503
|
+
...parsed.value.refresh ? { assertAdmission: assertLocalAccounts } : {}
|
|
63929
64504
|
});
|
|
63930
64505
|
deps.stdout.write(
|
|
63931
64506
|
parsed.value.json ? `${JSON.stringify(quotaSummary(results))}
|
|
@@ -63948,7 +64523,7 @@ async function runCliProcess(argv, deps) {
|
|
|
63948
64523
|
...deps,
|
|
63949
64524
|
prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
|
|
63950
64525
|
const folder = await prepareVaultFolder({
|
|
63951
|
-
accountFile:
|
|
64526
|
+
accountFile: resolve30(accountFileForVault()),
|
|
63952
64527
|
...options
|
|
63953
64528
|
});
|
|
63954
64529
|
if (folder.refusal) throw folder.refusal;
|
|
@@ -63994,11 +64569,11 @@ function createDefaultCliDependencies() {
|
|
|
63994
64569
|
);
|
|
63995
64570
|
if (host !== "pi")
|
|
63996
64571
|
await assertLocalOpenCodeLogin(
|
|
63997
|
-
|
|
64572
|
+
resolve30(accountFileForVault()),
|
|
63998
64573
|
context?.opencodeGeneration
|
|
63999
64574
|
);
|
|
64000
64575
|
const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
|
|
64001
|
-
|
|
64576
|
+
resolve30(getStoragePath()),
|
|
64002
64577
|
context?.opencodeGeneration
|
|
64003
64578
|
);
|
|
64004
64579
|
try {
|
|
@@ -64014,7 +64589,7 @@ function createDefaultCliDependencies() {
|
|
|
64014
64589
|
}
|
|
64015
64590
|
if (host === "opencode") await assertSetupHostsStopped();
|
|
64016
64591
|
await assertLocalOpenCodeLogin(
|
|
64017
|
-
|
|
64592
|
+
resolve30(accountFileForVault()),
|
|
64018
64593
|
context?.opencodeGeneration
|
|
64019
64594
|
);
|
|
64020
64595
|
await persistCliStoreLogin(
|
|
@@ -64034,7 +64609,7 @@ function createDefaultCliDependencies() {
|
|
|
64034
64609
|
};
|
|
64035
64610
|
}
|
|
64036
64611
|
async function prepareCliLoginStore(legacyPath, generation) {
|
|
64037
|
-
await assertLocalOpenCodeLogin(
|
|
64612
|
+
await assertLocalOpenCodeLogin(resolve30(accountFileForVault()), generation);
|
|
64038
64613
|
const modules = await loadCommonAuthStoreModules();
|
|
64039
64614
|
const options = {
|
|
64040
64615
|
legacyPath,
|
|
@@ -64179,7 +64754,7 @@ async function readAccountStore(legacyPath) {
|
|
|
64179
64754
|
function createDefaultAccountStoreOperations() {
|
|
64180
64755
|
const offline = { processesStopped: true };
|
|
64181
64756
|
return {
|
|
64182
|
-
legacyPath: () =>
|
|
64757
|
+
legacyPath: () => resolve30(
|
|
64183
64758
|
decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
|
|
64184
64759
|
),
|
|
64185
64760
|
migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
|
|
@@ -64210,7 +64785,7 @@ function createDefaultAccountStoreOperations() {
|
|
|
64210
64785
|
};
|
|
64211
64786
|
}
|
|
64212
64787
|
function samePath(left, right) {
|
|
64213
|
-
return process.platform === "win32" ?
|
|
64788
|
+
return process.platform === "win32" ? resolve30(left).toLowerCase() === resolve30(right).toLowerCase() : resolve30(left) === resolve30(right);
|
|
64214
64789
|
}
|
|
64215
64790
|
function isCliEntry() {
|
|
64216
64791
|
if (import.meta.main !== void 0) return import.meta.main;
|
|
@@ -64699,17 +65274,17 @@ function isTuiConnected(sessionId) {
|
|
|
64699
65274
|
|
|
64700
65275
|
// src/rpc/rpc-dir.ts
|
|
64701
65276
|
import { createHash as createHash20 } from "node:crypto";
|
|
64702
|
-
import { homedir as homedir14, tmpdir as
|
|
64703
|
-
import { isAbsolute as isAbsolute5, join as
|
|
65277
|
+
import { homedir as homedir14, tmpdir as tmpdir5 } from "node:os";
|
|
65278
|
+
import { isAbsolute as isAbsolute5, join as join41, resolve as resolve31 } from "node:path";
|
|
64704
65279
|
var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
|
|
64705
65280
|
function getRpcDir(projectDirectory) {
|
|
64706
65281
|
const override = process.env[RPC_DIR_ENV]?.trim();
|
|
64707
65282
|
if (override) {
|
|
64708
|
-
return isAbsolute5(override) ? override :
|
|
65283
|
+
return isAbsolute5(override) ? override : resolve31(projectDirectory, override);
|
|
64709
65284
|
}
|
|
64710
|
-
const projectHash = createHash20("sha256").update(
|
|
64711
|
-
const stateHome = process.env.XDG_STATE_HOME ??
|
|
64712
|
-
return
|
|
65285
|
+
const projectHash = createHash20("sha256").update(resolve31(projectDirectory)).digest("hex").slice(0, 16);
|
|
65286
|
+
const stateHome = process.env.XDG_STATE_HOME ?? join41(homedir14(), ".local", "state");
|
|
65287
|
+
return join41(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
|
|
64713
65288
|
}
|
|
64714
65289
|
|
|
64715
65290
|
// src/common-auth-embedded/rpc/notifications.js
|
|
@@ -64722,7 +65297,7 @@ init_private_files2();
|
|
|
64722
65297
|
import { createHash as createHash21, randomUUID as randomUUID25 } from "node:crypto";
|
|
64723
65298
|
import { chmod as chmod7, mkdir as mkdir20, open as open13, readdir as readdir7, rename as rename16, rmdir as rmdir3, stat as stat20, unlink as unlink16 } from "node:fs/promises";
|
|
64724
65299
|
import { uptime as uptime2 } from "node:os";
|
|
64725
|
-
import { join as
|
|
65300
|
+
import { join as join42, resolve as resolve32 } from "node:path";
|
|
64726
65301
|
function staleBefore(clock2) {
|
|
64727
65302
|
return (clock2.now ?? Date.now)() - (clock2.uptime ?? uptime2)() * 1e3 - 3e5;
|
|
64728
65303
|
}
|
|
@@ -64775,7 +65350,7 @@ async function removeCorruptPortFile(portFile, log19) {
|
|
|
64775
65350
|
}
|
|
64776
65351
|
async function writePortFile(dir, entry, options = {}) {
|
|
64777
65352
|
const writeOnce = async () => {
|
|
64778
|
-
const target =
|
|
65353
|
+
const target = join42(dir, `port-${entry.pid}.json`);
|
|
64779
65354
|
if (windowsPrivateFiles2) {
|
|
64780
65355
|
await ensurePrivateDirectory2(dir, options.secureDir ?? false);
|
|
64781
65356
|
await options.beforeWrite?.();
|
|
@@ -64819,7 +65394,7 @@ async function writePortFile(dir, entry, options = {}) {
|
|
|
64819
65394
|
} catch (error) {
|
|
64820
65395
|
if (error.code !== "ENOENT" || attempt === 5)
|
|
64821
65396
|
throw error;
|
|
64822
|
-
await new Promise((
|
|
65397
|
+
await new Promise((resolve35) => setTimeout(resolve35, 25));
|
|
64823
65398
|
}
|
|
64824
65399
|
}
|
|
64825
65400
|
}
|
|
@@ -64833,15 +65408,15 @@ async function sweepRpcState(root, activeDir, isManagedDir, log19, options = {})
|
|
|
64833
65408
|
return;
|
|
64834
65409
|
throw error;
|
|
64835
65410
|
}
|
|
64836
|
-
const active2 =
|
|
65411
|
+
const active2 = resolve32(activeDir);
|
|
64837
65412
|
for (const projectDir of projectDirs) {
|
|
64838
65413
|
if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
|
|
64839
65414
|
continue;
|
|
64840
65415
|
}
|
|
64841
|
-
const dir =
|
|
65416
|
+
const dir = join42(root, projectDir.name);
|
|
64842
65417
|
if (!await sweepRpcDirectory(dir, log19, options, cutoff))
|
|
64843
65418
|
continue;
|
|
64844
|
-
if (
|
|
65419
|
+
if (resolve32(dir) !== active2)
|
|
64845
65420
|
await rmdir3(dir).catch(() => {
|
|
64846
65421
|
});
|
|
64847
65422
|
}
|
|
@@ -64858,7 +65433,7 @@ async function sweepRpcDirectory(dir, log19, options = {}, cutoff = staleBefore(
|
|
|
64858
65433
|
for (const name of names) {
|
|
64859
65434
|
if (!name.startsWith("port-") || !name.endsWith(".json"))
|
|
64860
65435
|
continue;
|
|
64861
|
-
const portFile =
|
|
65436
|
+
const portFile = join42(dir, name);
|
|
64862
65437
|
const info = await stat20(portFile).catch(() => void 0);
|
|
64863
65438
|
let raw;
|
|
64864
65439
|
try {
|
|
@@ -64899,11 +65474,11 @@ init_private_files2();
|
|
|
64899
65474
|
import { randomBytes as randomBytes7, timingSafeEqual } from "node:crypto";
|
|
64900
65475
|
import { unlink as unlink17 } from "node:fs/promises";
|
|
64901
65476
|
import { createServer as createServer3 } from "node:http";
|
|
64902
|
-
import { join as
|
|
65477
|
+
import { join as join43 } from "node:path";
|
|
64903
65478
|
|
|
64904
65479
|
// src/common-auth-embedded/rpc/startup-sweep.js
|
|
64905
65480
|
import { lstat as lstat11 } from "node:fs/promises";
|
|
64906
|
-
import { basename as basename15, dirname as
|
|
65481
|
+
import { basename as basename15, dirname as dirname31, resolve as resolve33 } from "node:path";
|
|
64907
65482
|
var globals = globalThis;
|
|
64908
65483
|
var key = /* @__PURE__ */ Symbol.for("common-auth.rpc.startup-sweep");
|
|
64909
65484
|
globals[key] ??= {};
|
|
@@ -64912,8 +65487,8 @@ var now = Date.now;
|
|
|
64912
65487
|
async function sweepRpcStateOnStart(root, activeDir, isManagedDir, log19) {
|
|
64913
65488
|
const time = now();
|
|
64914
65489
|
if (state.lastSweepAt !== void 0 && time - state.lastSweepAt < 6e4) {
|
|
64915
|
-
const active2 =
|
|
64916
|
-
if (
|
|
65490
|
+
const active2 = resolve33(activeDir);
|
|
65491
|
+
if (dirname31(active2) === resolve33(root) && isManagedDir(basename15(active2)) && (await lstat11(active2).catch((error) => {
|
|
64917
65492
|
if (error.code !== "ENOENT")
|
|
64918
65493
|
throw error;
|
|
64919
65494
|
return void 0;
|
|
@@ -64945,7 +65520,7 @@ var BodyTooLargeError = class extends Error {
|
|
|
64945
65520
|
}
|
|
64946
65521
|
};
|
|
64947
65522
|
function readBody(req) {
|
|
64948
|
-
return new Promise((
|
|
65523
|
+
return new Promise((resolve35, reject) => {
|
|
64949
65524
|
const tooLarge = (declaredOversize = false) => {
|
|
64950
65525
|
req.removeAllListeners("data");
|
|
64951
65526
|
req.on("data", () => {
|
|
@@ -64968,7 +65543,7 @@ function readBody(req) {
|
|
|
64968
65543
|
}
|
|
64969
65544
|
chunks.push(chunk);
|
|
64970
65545
|
});
|
|
64971
|
-
req.on("end", () =>
|
|
65546
|
+
req.on("end", () => resolve35(Buffer.concat(chunks).toString("utf8")));
|
|
64972
65547
|
req.on("error", reject);
|
|
64973
65548
|
});
|
|
64974
65549
|
}
|
|
@@ -65147,12 +65722,12 @@ async function startRpcServer(options) {
|
|
|
65147
65722
|
json(500, { error: "internal error" });
|
|
65148
65723
|
}
|
|
65149
65724
|
}
|
|
65150
|
-
const port = await new Promise((
|
|
65725
|
+
const port = await new Promise((resolve35, reject) => {
|
|
65151
65726
|
server.on("error", reject);
|
|
65152
65727
|
server.listen(0, "127.0.0.1", () => {
|
|
65153
65728
|
const addr = server.address();
|
|
65154
65729
|
if (addr && typeof addr === "object")
|
|
65155
|
-
|
|
65730
|
+
resolve35(addr.port);
|
|
65156
65731
|
else
|
|
65157
65732
|
reject(new Error("no port"));
|
|
65158
65733
|
});
|
|
@@ -65175,20 +65750,20 @@ async function startRpcServer(options) {
|
|
|
65175
65750
|
rpcPort: port
|
|
65176
65751
|
});
|
|
65177
65752
|
} catch (error) {
|
|
65178
|
-
await new Promise((
|
|
65753
|
+
await new Promise((resolve35) => server.close(() => resolve35()));
|
|
65179
65754
|
throw error;
|
|
65180
65755
|
}
|
|
65181
65756
|
return {
|
|
65182
65757
|
port,
|
|
65183
65758
|
token,
|
|
65184
65759
|
async stop() {
|
|
65185
|
-
await new Promise((
|
|
65760
|
+
await new Promise((resolve35) => {
|
|
65186
65761
|
server.closeAllConnections?.();
|
|
65187
|
-
server.close(() =>
|
|
65762
|
+
server.close(() => resolve35());
|
|
65188
65763
|
for (const socket of connections)
|
|
65189
65764
|
socket.destroy();
|
|
65190
65765
|
});
|
|
65191
|
-
const portFile =
|
|
65766
|
+
const portFile = join43(options.dir, `port-${process.pid}.json`);
|
|
65192
65767
|
const current = await readPrivateText2(portFile).then((raw) => JSON.parse(raw)).catch((error) => {
|
|
65193
65768
|
if (error instanceof PrivateFileError2 && error.code !== "ENOENT")
|
|
65194
65769
|
throw error;
|
|
@@ -65509,9 +66084,9 @@ import { stdin as input, stdout as output } from "node:process";
|
|
|
65509
66084
|
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
65510
66085
|
|
|
65511
66086
|
// src/plugin/config/updater.ts
|
|
65512
|
-
import { existsSync as existsSync15, mkdirSync as
|
|
66087
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync7, readFileSync as readFileSync14, writeFileSync as writeFileSync7 } from "node:fs";
|
|
65513
66088
|
import { homedir as homedir15 } from "node:os";
|
|
65514
|
-
import { dirname as
|
|
66089
|
+
import { dirname as dirname32, join as join44 } from "node:path";
|
|
65515
66090
|
|
|
65516
66091
|
// src/plugin/model-registry.ts
|
|
65517
66092
|
init_dist();
|
|
@@ -65544,13 +66119,13 @@ function stripJsonCommentsAndTrailingCommas(json) {
|
|
|
65544
66119
|
).replace(/,(\s*[}\]])/g, "$1");
|
|
65545
66120
|
}
|
|
65546
66121
|
function getOpencodeConfigDir() {
|
|
65547
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ||
|
|
65548
|
-
return
|
|
66122
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME || join44(homedir15(), ".config");
|
|
66123
|
+
return join44(xdgConfig2, "opencode");
|
|
65549
66124
|
}
|
|
65550
66125
|
function getOpencodeConfigPath() {
|
|
65551
66126
|
const configDir = getOpencodeConfigDir();
|
|
65552
|
-
const jsoncPath =
|
|
65553
|
-
const jsonPath =
|
|
66127
|
+
const jsoncPath = join44(configDir, OPENCODE_JSONC_FILENAME);
|
|
66128
|
+
const jsonPath = join44(configDir, OPENCODE_JSON_FILENAME);
|
|
65554
66129
|
if (existsSync15(jsoncPath)) {
|
|
65555
66130
|
return jsoncPath;
|
|
65556
66131
|
}
|
|
@@ -65595,11 +66170,11 @@ async function updateOpencodeConfig(options = {}) {
|
|
|
65595
66170
|
}
|
|
65596
66171
|
config.provider.google.models = getOpencode1ModelDefinitions();
|
|
65597
66172
|
config.provider.google.whitelist = getAntigravityOpencodeModelIds();
|
|
65598
|
-
const configDir =
|
|
66173
|
+
const configDir = dirname32(configPath);
|
|
65599
66174
|
if (!existsSync15(configDir)) {
|
|
65600
|
-
|
|
66175
|
+
mkdirSync7(configDir, { recursive: true });
|
|
65601
66176
|
}
|
|
65602
|
-
|
|
66177
|
+
writeFileSync7(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
65603
66178
|
return {
|
|
65604
66179
|
success: true,
|
|
65605
66180
|
configPath
|
|
@@ -65809,7 +66384,7 @@ async function select3(items, options) {
|
|
|
65809
66384
|
}
|
|
65810
66385
|
renderedLines = linesWritten;
|
|
65811
66386
|
};
|
|
65812
|
-
return new Promise((
|
|
66387
|
+
return new Promise((resolve35) => {
|
|
65813
66388
|
const wasRaw = stdin.isRaw ?? false;
|
|
65814
66389
|
const cleanup2 = () => {
|
|
65815
66390
|
if (isCleanedUp) return;
|
|
@@ -65830,11 +66405,11 @@ async function select3(items, options) {
|
|
|
65830
66405
|
};
|
|
65831
66406
|
const onSignal = () => {
|
|
65832
66407
|
cleanup2();
|
|
65833
|
-
|
|
66408
|
+
resolve35(null);
|
|
65834
66409
|
};
|
|
65835
66410
|
const finishWithValue = (value) => {
|
|
65836
66411
|
cleanup2();
|
|
65837
|
-
|
|
66412
|
+
resolve35(value);
|
|
65838
66413
|
};
|
|
65839
66414
|
const findNextSelectable = (from, direction) => {
|
|
65840
66415
|
if (items.length === 0) return from;
|
|
@@ -65880,7 +66455,7 @@ async function select3(items, options) {
|
|
|
65880
66455
|
stdin.setRawMode(true);
|
|
65881
66456
|
} catch {
|
|
65882
66457
|
cleanup2();
|
|
65883
|
-
|
|
66458
|
+
resolve35(null);
|
|
65884
66459
|
return;
|
|
65885
66460
|
}
|
|
65886
66461
|
stdin.resume();
|
|
@@ -68104,16 +68679,21 @@ function createAuthLoader({
|
|
|
68104
68679
|
};
|
|
68105
68680
|
let storeOpening = null;
|
|
68106
68681
|
const openStore = () => {
|
|
68107
|
-
|
|
68108
|
-
|
|
68109
|
-
|
|
68110
|
-
|
|
68111
|
-
|
|
68112
|
-
|
|
68113
|
-
|
|
68114
|
-
|
|
68115
|
-
|
|
68116
|
-
|
|
68682
|
+
if (!storeOpening) {
|
|
68683
|
+
const attempt = deps.openAccountStore().then((opening) => {
|
|
68684
|
+
if (opening.status === "ready") {
|
|
68685
|
+
lifecycle.register({
|
|
68686
|
+
async dispose() {
|
|
68687
|
+
await opening.repository.dispose();
|
|
68688
|
+
}
|
|
68689
|
+
});
|
|
68690
|
+
} else if (opening.status === "refused" && opening.admission.status === "busy" && opening.admission.retryable && storeOpening === attempt) {
|
|
68691
|
+
storeOpening = null;
|
|
68692
|
+
}
|
|
68693
|
+
return opening;
|
|
68694
|
+
});
|
|
68695
|
+
storeOpening = attempt;
|
|
68696
|
+
}
|
|
68117
68697
|
return storeOpening;
|
|
68118
68698
|
};
|
|
68119
68699
|
const initializeFreshStore = async () => {
|
|
@@ -68892,15 +69472,15 @@ init_debug();
|
|
|
68892
69472
|
// src/plugin/dependencies.ts
|
|
68893
69473
|
init_dist();
|
|
68894
69474
|
import { homedir as homedir16 } from "node:os";
|
|
68895
|
-
import { join as
|
|
69475
|
+
import { join as join45 } from "node:path";
|
|
68896
69476
|
function defaultFilesystemRoots() {
|
|
68897
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ??
|
|
68898
|
-
const xdgState2 = process.env.XDG_STATE_HOME ??
|
|
69477
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME ?? join45(homedir16(), ".config");
|
|
69478
|
+
const xdgState2 = process.env.XDG_STATE_HOME ?? join45(homedir16(), ".local", "state");
|
|
68899
69479
|
return {
|
|
68900
69480
|
projectRoot: process.cwd(),
|
|
68901
|
-
userConfigRoot:
|
|
68902
|
-
sidebarStateRoot:
|
|
68903
|
-
rpcRoot:
|
|
69481
|
+
userConfigRoot: join45(xdgConfig2, "opencode"),
|
|
69482
|
+
sidebarStateRoot: join45(xdgState2, "cortexkit", "antigravity-auth"),
|
|
69483
|
+
rpcRoot: join45(xdgState2, "cortexkit", "antigravity-auth", "rpc")
|
|
68904
69484
|
};
|
|
68905
69485
|
}
|
|
68906
69486
|
function resolvePluginDependencies(overrides = {}) {
|
|
@@ -68929,10 +69509,10 @@ function resolvePluginDependencies(overrides = {}) {
|
|
|
68929
69509
|
}
|
|
68930
69510
|
async function defaultSleep(ms, signal) {
|
|
68931
69511
|
if (ms <= 0) return;
|
|
68932
|
-
await new Promise((
|
|
69512
|
+
await new Promise((resolve35, reject) => {
|
|
68933
69513
|
const timer = setTimeout(() => {
|
|
68934
69514
|
signal?.removeEventListener("abort", onAbort);
|
|
68935
|
-
|
|
69515
|
+
resolve35();
|
|
68936
69516
|
}, ms);
|
|
68937
69517
|
timer.unref?.();
|
|
68938
69518
|
const onAbort = () => {
|
|
@@ -69664,8 +70244,8 @@ function createPluginLifecycle(options) {
|
|
|
69664
70244
|
};
|
|
69665
70245
|
let failDisposal = () => {
|
|
69666
70246
|
};
|
|
69667
|
-
disposal = new Promise((
|
|
69668
|
-
finishDisposal =
|
|
70247
|
+
disposal = new Promise((resolve35, reject) => {
|
|
70248
|
+
finishDisposal = resolve35;
|
|
69669
70249
|
failDisposal = reject;
|
|
69670
70250
|
});
|
|
69671
70251
|
void (async () => {
|
|
@@ -69771,7 +70351,7 @@ var createAntigravityPluginRuntime = (providerId, options = {}) => async (input2
|
|
|
69771
70351
|
// Diagnostics. Before the move they load from and write to the
|
|
69772
70352
|
// project or user antigravity.json through the operator writer.
|
|
69773
70353
|
operator: () => createOperatorSettingsController({
|
|
69774
|
-
projectConfigPath:
|
|
70354
|
+
projectConfigPath: join46(directory, ".opencode", "antigravity.json"),
|
|
69775
70355
|
// getUserConfigPath() already returns the full file path including
|
|
69776
70356
|
// 'antigravity.json' — do NOT join again or the path double-nests
|
|
69777
70357
|
// into <dir>/antigravity.json/antigravity.json.
|
|
@@ -69833,7 +70413,7 @@ var createAntigravityPluginRuntime = (providerId, options = {}) => async (input2
|
|
|
69833
70413
|
await drainSidebarWrites();
|
|
69834
70414
|
}
|
|
69835
70415
|
});
|
|
69836
|
-
const accountFile =
|
|
70416
|
+
const accountFile = resolve34(accountFileForVault());
|
|
69837
70417
|
const vaultFolder = await prepareVaultFolder({ accountFile });
|
|
69838
70418
|
const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
|
|
69839
70419
|
let vaultQuotaPoller;
|