@cortexkit/opencode-antigravity-auth 3.0.21 → 3.0.23
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 +565 -444
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +99 -49
- package/dist/index.js +1151 -656
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +156 -56
- package/dist/server.js +1180 -680
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
- package/dist/src/common-auth-embedded/fs/with-lock.js +37 -10
- package/dist/src/common-auth-embedded/quota/format.d.ts +9 -4
- package/dist/src/common-auth-embedded/quota/format.js +45 -26
- package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +56 -32
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
- package/dist/src/common-auth-embedded/routing-accessor/index.js +128 -0
- package/dist/src/common-auth-embedded/source-output.json +42 -22
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +2 -0
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +1 -0
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/shared/request-services.d.ts +6 -0
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +89 -2
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.js +4 -0
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
- package/dist/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
- package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
- package/dist/src/plugin/shared/vault-routing-purpose.js +18 -0
- package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -0
- package/dist/src/plugin/shared/vault-routing.d.ts +39 -0
- package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -0
- package/dist/src/plugin/shared/vault-routing.js +213 -0
- package/dist/src/plugin/shared/vault-routing.js.map +1 -0
- package/dist/src/plugin/types.d.ts +1 -0
- package/dist/src/plugin/types.d.ts.map +1 -1
- package/dist/src/runtime-layout.d.ts.map +1 -1
- package/dist/src/runtime-layout.js +14 -3
- package/dist/src/runtime-layout.js.map +1 -1
- package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
- package/dist/src/tui/sidebar-frame.js +18 -16
- package/dist/src/tui/sidebar-frame.js.map +1 -1
- package/dist/src/vault-folder.d.ts.map +1 -1
- package/dist/src/vault-folder.js +51 -14
- package/dist/src/vault-folder.js.map +1 -1
- package/dist/src/version-fence.d.ts +5 -0
- package/dist/src/version-fence.d.ts.map +1 -1
- package/dist/src/version-fence.js +64 -7
- package/dist/src/version-fence.js.map +1 -1
- package/dist/tui-build-map.json +13 -13
- package/dist/tui-ga-build-map.json +13 -13
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +9 -4
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts +6 -0
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
- package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/vault-routing.d.ts +39 -0
- package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -0
- package/dist/types/src/plugin/types.d.ts +1 -0
- package/dist/types/src/plugin/types.d.ts.map +1 -1
- package/dist/types/src/runtime-layout.d.ts.map +1 -1
- package/dist/types/src/vault-folder.d.ts.map +1 -1
- package/dist/types/src/version-fence.d.ts +5 -0
- package/dist/types/src/version-fence.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
- package/src/common-auth-embedded/fs/with-lock.js +37 -10
- package/src/common-auth-embedded/quota/format.d.ts +9 -4
- package/src/common-auth-embedded/quota/format.js +45 -26
- package/src/common-auth-embedded/quota-sidebar/index.tsx +56 -32
- package/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
- package/src/common-auth-embedded/routing-accessor/index.js +128 -0
- package/src/common-auth-embedded/source-output.json +42 -22
- package/src/tui-compiled/common-auth-embedded/quota/format.js +45 -26
- package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +165 -148
- package/src/tui-compiled/tui/sidebar-frame.js +17 -16
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +45 -26
- package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +17 -16
- package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +165 -148
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +45 -26
- package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +21 -19
- package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +56 -32
- package/src/tui-raw/common-auth-embedded/quota/format.js +45 -26
- package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +56 -32
- package/src/tui-raw/tui/sidebar-frame.tsx +21 -19
package/dist/server.js
CHANGED
|
@@ -1628,10 +1628,10 @@ async function privateDirectory(path5) {
|
|
|
1628
1628
|
if (errno(error) !== "EEXIST")
|
|
1629
1629
|
throw error;
|
|
1630
1630
|
}
|
|
1631
|
-
const
|
|
1632
|
-
if (!
|
|
1631
|
+
const stat16 = await lstat2(path5);
|
|
1632
|
+
if (!stat16.isDirectory() || stat16.isSymbolicLink())
|
|
1633
1633
|
throw new AccountMigrationError("successor directory is not a regular directory");
|
|
1634
|
-
privateMode(
|
|
1634
|
+
privateMode(stat16.mode, 448);
|
|
1635
1635
|
if (windowsPrivateFiles)
|
|
1636
1636
|
await verifySafeDirectory(path5);
|
|
1637
1637
|
if (!sameFilesystemPath(await realpath(path5), path5))
|
|
@@ -7751,7 +7751,7 @@ async function rmEvictingDir(evictingPath) {
|
|
|
7751
7751
|
});
|
|
7752
7752
|
}
|
|
7753
7753
|
async function sleep(ms) {
|
|
7754
|
-
await new Promise((
|
|
7754
|
+
await new Promise((resolve28) => setTimeout(resolve28, ms));
|
|
7755
7755
|
}
|
|
7756
7756
|
async function acquireFencedFileLock(options) {
|
|
7757
7757
|
const lockPath = `${options.path}.${options.name}.lock`;
|
|
@@ -7867,8 +7867,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
7867
7867
|
let released = false;
|
|
7868
7868
|
let lost = false;
|
|
7869
7869
|
let lostResolve = null;
|
|
7870
|
-
let lostPromise = new Promise((
|
|
7871
|
-
lostResolve =
|
|
7870
|
+
let lostPromise = new Promise((resolve28) => {
|
|
7871
|
+
lostResolve = resolve28;
|
|
7872
7872
|
});
|
|
7873
7873
|
const markLost = () => {
|
|
7874
7874
|
if (lost)
|
|
@@ -7878,9 +7878,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
7878
7878
|
clearInterval(renewTimer);
|
|
7879
7879
|
renewTimer = null;
|
|
7880
7880
|
}
|
|
7881
|
-
const
|
|
7881
|
+
const resolve28 = lostResolve;
|
|
7882
7882
|
lostResolve = null;
|
|
7883
|
-
|
|
7883
|
+
resolve28?.();
|
|
7884
7884
|
};
|
|
7885
7885
|
const setupRenew = () => {
|
|
7886
7886
|
if (options.renew === false)
|
|
@@ -8083,7 +8083,7 @@ function writeConsoleLog(level, ...args) {
|
|
|
8083
8083
|
}
|
|
8084
8084
|
function createLogger(module) {
|
|
8085
8085
|
const service = `antigravity.${module}`;
|
|
8086
|
-
const
|
|
8086
|
+
const log17 = (level, message, extra) => {
|
|
8087
8087
|
if (_sink) {
|
|
8088
8088
|
try {
|
|
8089
8089
|
_sink({ service, level, message, extra });
|
|
@@ -8097,10 +8097,10 @@ function createLogger(module) {
|
|
|
8097
8097
|
}
|
|
8098
8098
|
};
|
|
8099
8099
|
return {
|
|
8100
|
-
debug: (message, extra) =>
|
|
8101
|
-
info: (message, extra) =>
|
|
8102
|
-
warn: (message, extra) =>
|
|
8103
|
-
error: (message, extra) =>
|
|
8100
|
+
debug: (message, extra) => log17("debug", message, extra),
|
|
8101
|
+
info: (message, extra) => log17("info", message, extra),
|
|
8102
|
+
warn: (message, extra) => log17("warn", message, extra),
|
|
8103
|
+
error: (message, extra) => log17("error", message, extra)
|
|
8104
8104
|
};
|
|
8105
8105
|
}
|
|
8106
8106
|
var ENV_CONSOLE_LOG, _sink;
|
|
@@ -8503,7 +8503,7 @@ async function saveAccountStorageReplace(path5, incoming) {
|
|
|
8503
8503
|
return mutateAccountStorage(path5, () => incoming);
|
|
8504
8504
|
}
|
|
8505
8505
|
async function clearAccountStorage(path5) {
|
|
8506
|
-
const sleep5 = (ms) => new Promise((
|
|
8506
|
+
const sleep5 = (ms) => new Promise((resolve28) => setTimeout(resolve28, ms));
|
|
8507
8507
|
const lock = await acquireWithRetry(path5, sleep5);
|
|
8508
8508
|
try {
|
|
8509
8509
|
await assertLegacyAccountStorageWritable(path5);
|
|
@@ -8551,7 +8551,7 @@ var init_account_storage = __esm({
|
|
|
8551
8551
|
}
|
|
8552
8552
|
};
|
|
8553
8553
|
RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
|
|
8554
|
-
DEFAULT_SLEEP = (ms) => new Promise((
|
|
8554
|
+
DEFAULT_SLEEP = (ms) => new Promise((resolve28) => setTimeout(resolve28, ms));
|
|
8555
8555
|
DEFAULT_BUILD_BACKUP_PATH = (path5, now) => `${path5}.corrupt-${now.toISOString().replace(/[:.]/g, "-")}`;
|
|
8556
8556
|
}
|
|
8557
8557
|
});
|
|
@@ -9753,8 +9753,8 @@ var init_account_manager = __esm({
|
|
|
9753
9753
|
await this.saveInFlight;
|
|
9754
9754
|
return;
|
|
9755
9755
|
}
|
|
9756
|
-
return new Promise((
|
|
9757
|
-
this.savePromiseResolvers.push({ resolve:
|
|
9756
|
+
return new Promise((resolve28, reject) => {
|
|
9757
|
+
this.savePromiseResolvers.push({ resolve: resolve28, reject });
|
|
9758
9758
|
});
|
|
9759
9759
|
}
|
|
9760
9760
|
async dispose() {
|
|
@@ -9797,8 +9797,8 @@ var init_account_manager = __esm({
|
|
|
9797
9797
|
reject(error);
|
|
9798
9798
|
throw error;
|
|
9799
9799
|
}
|
|
9800
|
-
for (const { resolve:
|
|
9801
|
-
|
|
9800
|
+
for (const { resolve: resolve28 } of resolvers)
|
|
9801
|
+
resolve28();
|
|
9802
9802
|
}
|
|
9803
9803
|
async executeSave() {
|
|
9804
9804
|
this.savePending = false;
|
|
@@ -9812,16 +9812,16 @@ var init_account_manager = __esm({
|
|
|
9812
9812
|
}
|
|
9813
9813
|
try {
|
|
9814
9814
|
await this.saveToDisk();
|
|
9815
|
-
for (const { resolve:
|
|
9816
|
-
|
|
9815
|
+
for (const { resolve: resolve28 } of resolvers) {
|
|
9816
|
+
resolve28();
|
|
9817
9817
|
}
|
|
9818
9818
|
} catch (error) {
|
|
9819
9819
|
if (isStorageLockContention(error)) {
|
|
9820
9820
|
this.onDiagnostic?.("Skipped account-state persist due to storage lock contention", {
|
|
9821
9821
|
error: String(error)
|
|
9822
9822
|
});
|
|
9823
|
-
for (const { resolve:
|
|
9824
|
-
|
|
9823
|
+
for (const { resolve: resolve28 } of resolvers) {
|
|
9824
|
+
resolve28();
|
|
9825
9825
|
}
|
|
9826
9826
|
return;
|
|
9827
9827
|
}
|
|
@@ -10310,7 +10310,7 @@ function getHttpsProxy(url) {
|
|
|
10310
10310
|
}
|
|
10311
10311
|
}
|
|
10312
10312
|
function waitForHead(socket, timeoutMs, onTimeout) {
|
|
10313
|
-
return new Promise((
|
|
10313
|
+
return new Promise((resolve28, reject) => {
|
|
10314
10314
|
let buffer = Buffer3.alloc(0);
|
|
10315
10315
|
const timeout = setTimeout(() => {
|
|
10316
10316
|
onTimeout();
|
|
@@ -10333,7 +10333,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
|
|
|
10333
10333
|
return;
|
|
10334
10334
|
const head = buffer.subarray(0, marker).toString("latin1");
|
|
10335
10335
|
const leftover = buffer.subarray(marker + 4);
|
|
10336
|
-
cleanup2(() =>
|
|
10336
|
+
cleanup2(() => resolve28({ head, leftover }));
|
|
10337
10337
|
};
|
|
10338
10338
|
socket.on("data", onData);
|
|
10339
10339
|
socket.once("error", onError);
|
|
@@ -10347,7 +10347,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
10347
10347
|
port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
|
|
10348
10348
|
signal: signal ?? void 0
|
|
10349
10349
|
});
|
|
10350
|
-
await new Promise((
|
|
10350
|
+
await new Promise((resolve28, reject) => {
|
|
10351
10351
|
const timeout = setTimeout(() => {
|
|
10352
10352
|
onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
|
|
10353
10353
|
proxySocket.destroy();
|
|
@@ -10356,7 +10356,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
10356
10356
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10357
10357
|
proxySocket.once("connect", () => {
|
|
10358
10358
|
cleanup2();
|
|
10359
|
-
|
|
10359
|
+
resolve28();
|
|
10360
10360
|
});
|
|
10361
10361
|
proxySocket.once("error", (error) => {
|
|
10362
10362
|
cleanup2();
|
|
@@ -10381,7 +10381,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10381
10381
|
if (leftover.length > 0) {
|
|
10382
10382
|
proxySocket.unshift(leftover);
|
|
10383
10383
|
}
|
|
10384
|
-
return await new Promise((
|
|
10384
|
+
return await new Promise((resolve28, reject) => {
|
|
10385
10385
|
const tlsOptions = {
|
|
10386
10386
|
socket: proxySocket,
|
|
10387
10387
|
servername: targetHost,
|
|
@@ -10396,7 +10396,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10396
10396
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10397
10397
|
tlsSocket.once("secureConnect", () => {
|
|
10398
10398
|
cleanup2();
|
|
10399
|
-
|
|
10399
|
+
resolve28(tlsSocket);
|
|
10400
10400
|
});
|
|
10401
10401
|
tlsSocket.once("error", (error) => {
|
|
10402
10402
|
cleanup2();
|
|
@@ -10405,7 +10405,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10405
10405
|
});
|
|
10406
10406
|
}
|
|
10407
10407
|
async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
10408
|
-
return await new Promise((
|
|
10408
|
+
return await new Promise((resolve28, reject) => {
|
|
10409
10409
|
const tlsOptions = {
|
|
10410
10410
|
host: targetUrl.hostname,
|
|
10411
10411
|
port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
|
|
@@ -10421,7 +10421,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
|
10421
10421
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10422
10422
|
socket.once("secureConnect", () => {
|
|
10423
10423
|
cleanup2();
|
|
10424
|
-
|
|
10424
|
+
resolve28(socket);
|
|
10425
10425
|
});
|
|
10426
10426
|
socket.once("error", (error) => {
|
|
10427
10427
|
cleanup2();
|
|
@@ -11434,7 +11434,7 @@ function displayOrder(left, right) {
|
|
|
11434
11434
|
return left.label < right.label ? -1 : left.label > right.label ? 1 : 0;
|
|
11435
11435
|
}
|
|
11436
11436
|
function quotaWindowParts(quota, options) {
|
|
11437
|
-
const { windows: windows2, age } = scopedWindowParts(quota, options);
|
|
11437
|
+
const { windows: windows2, age } = scopedWindowParts(quota, options, true);
|
|
11438
11438
|
const parts = windows2.map(({ part }) => part);
|
|
11439
11439
|
return age === void 0 ? { windows: parts } : { windows: parts, age };
|
|
11440
11440
|
}
|
|
@@ -11445,25 +11445,36 @@ function withShortNames(windows2) {
|
|
|
11445
11445
|
}
|
|
11446
11446
|
return windows2;
|
|
11447
11447
|
}
|
|
11448
|
-
function
|
|
11448
|
+
function hasWindowReading(limit) {
|
|
11449
|
+
return Number.isFinite(limit.remainingPercent) && Number.isFinite(limit.checkedAt);
|
|
11450
|
+
}
|
|
11451
|
+
function scopedWindowParts(quota, options, includeUnknown = false) {
|
|
11449
11452
|
if (!quota)
|
|
11450
11453
|
return { windows: [] };
|
|
11451
11454
|
const { now } = options;
|
|
11452
|
-
const readings = quota.limits.filter((limit) => limit.kind === "reading" &&
|
|
11455
|
+
const readings = quota.limits.filter((limit) => limit.kind === "reading" && (includeUnknown || hasWindowReading(limit))).sort(displayOrder);
|
|
11453
11456
|
const windows2 = readings.map((limit) => {
|
|
11454
|
-
const
|
|
11457
|
+
const part = hasWindowReading(limit) ? {
|
|
11458
|
+
kind: "window",
|
|
11459
|
+
reading: "known",
|
|
11460
|
+
name: quotaWindowName(limit),
|
|
11461
|
+
short: "",
|
|
11462
|
+
figure: percentLeft(limit.remainingPercent),
|
|
11463
|
+
remainingPercent: clampPercent(limit.remainingPercent),
|
|
11464
|
+
checkedAt: limit.checkedAt,
|
|
11465
|
+
...resetDetails(limit.resetsAt, limit.checkedAt, now)
|
|
11466
|
+
} : {
|
|
11467
|
+
kind: "window",
|
|
11468
|
+
reading: "unknown",
|
|
11469
|
+
name: quotaWindowName(limit),
|
|
11470
|
+
short: "",
|
|
11471
|
+
figure: "no reading",
|
|
11472
|
+
resetSinceReading: false
|
|
11473
|
+
};
|
|
11455
11474
|
return {
|
|
11456
11475
|
scope: limit.scope,
|
|
11457
11476
|
...limit.windowMinutes === void 0 ? {} : { windowMinutes: limit.windowMinutes },
|
|
11458
|
-
part
|
|
11459
|
-
kind: "window",
|
|
11460
|
-
name: quotaWindowName(limit),
|
|
11461
|
-
short: "",
|
|
11462
|
-
figure: percentLeft(limit.remainingPercent ?? 0),
|
|
11463
|
-
remainingPercent,
|
|
11464
|
-
checkedAt: limit.checkedAt,
|
|
11465
|
-
...resetDetails(limit.resetsAt, limit.checkedAt, now)
|
|
11466
|
-
}
|
|
11477
|
+
part
|
|
11467
11478
|
};
|
|
11468
11479
|
});
|
|
11469
11480
|
const budget = quota.budget;
|
|
@@ -11475,6 +11486,7 @@ function scopedWindowParts(quota, options) {
|
|
|
11475
11486
|
spent: budget.reached,
|
|
11476
11487
|
part: {
|
|
11477
11488
|
kind: "budget",
|
|
11489
|
+
reading: "known",
|
|
11478
11490
|
name: "credits",
|
|
11479
11491
|
short: "",
|
|
11480
11492
|
figure,
|
|
@@ -11485,8 +11497,9 @@ function scopedWindowParts(quota, options) {
|
|
|
11485
11497
|
});
|
|
11486
11498
|
}
|
|
11487
11499
|
withShortNames(windows2);
|
|
11488
|
-
|
|
11489
|
-
|
|
11500
|
+
const readingTimes = windows2.flatMap(({ part }) => part.reading === "known" && part.checkedAt !== void 0 ? [part.checkedAt] : []);
|
|
11501
|
+
if (readingTimes.length > 0) {
|
|
11502
|
+
const age = now - Math.min(...readingTimes);
|
|
11490
11503
|
if (age > (options.staleAfterMs ?? QUOTA_STALE_AFTER_MS)) {
|
|
11491
11504
|
return { windows: windows2, age: `checked ${shortSpan(age)} ago` };
|
|
11492
11505
|
}
|
|
@@ -11585,13 +11598,13 @@ function narrowTextParts(quota, options) {
|
|
|
11585
11598
|
function quotaTextParts(quota, options) {
|
|
11586
11599
|
if (options.form === "narrow")
|
|
11587
11600
|
return narrowTextParts(quota, options);
|
|
11588
|
-
const
|
|
11601
|
+
const { windows: windows2, age } = scopedWindowParts(quota, options);
|
|
11589
11602
|
const full = (options.form ?? "full") === "full";
|
|
11590
|
-
const text2 =
|
|
11603
|
+
const text2 = windows2.map(({ part }) => {
|
|
11591
11604
|
const reset = full && part.resetIn ? `, resets ${part.resetIn}` : "";
|
|
11592
11605
|
return `${part.kind === "budget" ? "" : `${part.name} `}${part.figure}${reset}`;
|
|
11593
11606
|
});
|
|
11594
|
-
return
|
|
11607
|
+
return age === void 0 ? text2 : [...text2, age];
|
|
11595
11608
|
}
|
|
11596
11609
|
function formatQuota(quota, options) {
|
|
11597
11610
|
const parts = quotaTextParts(quota, options);
|
|
@@ -12494,8 +12507,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12494
12507
|
let releaseConfirmed = false;
|
|
12495
12508
|
let loss;
|
|
12496
12509
|
let resolveLoss;
|
|
12497
|
-
const lostPromise = new Promise((
|
|
12498
|
-
resolveLoss =
|
|
12510
|
+
const lostPromise = new Promise((resolve28) => {
|
|
12511
|
+
resolveLoss = resolve28;
|
|
12499
12512
|
});
|
|
12500
12513
|
function notifyTimerStep(event) {
|
|
12501
12514
|
try {
|
|
@@ -12656,7 +12669,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12656
12669
|
}
|
|
12657
12670
|
}
|
|
12658
12671
|
async function backoff() {
|
|
12659
|
-
await new Promise((
|
|
12672
|
+
await new Promise((resolve28) => setTimeout(resolve28, Math.floor(Math.random() * 4)));
|
|
12660
12673
|
}
|
|
12661
12674
|
async function readLockState(notifyReady = true) {
|
|
12662
12675
|
if (notifyReady && options.onStep)
|
|
@@ -13146,7 +13159,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13146
13159
|
const remainingMs = deadline - performance.now();
|
|
13147
13160
|
if (remainingMs <= 0)
|
|
13148
13161
|
break;
|
|
13149
|
-
await new Promise((
|
|
13162
|
+
await new Promise((resolve28) => setTimeout(resolve28, Math.min(delayMs, remainingMs)));
|
|
13150
13163
|
delayMs = Math.min(delayMs * 2, 50);
|
|
13151
13164
|
}
|
|
13152
13165
|
if (windowsPrivateFiles)
|
|
@@ -13169,21 +13182,37 @@ var init_refresh_file_lock = __esm({
|
|
|
13169
13182
|
});
|
|
13170
13183
|
|
|
13171
13184
|
// ../core/dist/common-auth-embedded/fs/with-lock.js
|
|
13185
|
+
import { join as join6, resolve as resolve3 } from "node:path";
|
|
13172
13186
|
function lockPathFor(target, name) {
|
|
13173
13187
|
return `${target}.${name}.lock`;
|
|
13174
13188
|
}
|
|
13189
|
+
function isChangingLockRead(error, target, name) {
|
|
13190
|
+
if (!windowsPrivateFiles || !(error instanceof PrivateFileError) || error.reason !== "io-error" || error.win32Code !== 32 && error.win32Code !== 303 || error.stage !== "read" && error.stage !== "verify")
|
|
13191
|
+
return false;
|
|
13192
|
+
const path5 = resolve3(lockPathFor(target, name));
|
|
13193
|
+
return error.path === path5 || error.path === join6(path5, "owner.json");
|
|
13194
|
+
}
|
|
13175
13195
|
async function withLock(target, options, fn) {
|
|
13176
13196
|
const started = performance.now();
|
|
13177
13197
|
for (; ; ) {
|
|
13178
13198
|
options.signal?.throwIfAborted();
|
|
13179
|
-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
|
|
13184
|
-
|
|
13185
|
-
|
|
13186
|
-
|
|
13199
|
+
let lock;
|
|
13200
|
+
let changingReadError;
|
|
13201
|
+
try {
|
|
13202
|
+
lock = await acquireRefreshFileLock({
|
|
13203
|
+
path: target,
|
|
13204
|
+
name: options.name,
|
|
13205
|
+
ttlMs: options.ttlMs,
|
|
13206
|
+
renew: options.renew ?? false,
|
|
13207
|
+
...options.onStep ? { onStep: options.onStep } : {},
|
|
13208
|
+
...options.onRenewalTimer ? { onRenewalTimer: options.onRenewalTimer } : {}
|
|
13209
|
+
});
|
|
13210
|
+
} catch (error) {
|
|
13211
|
+
if (!isChangingLockRead(error, target, options.name))
|
|
13212
|
+
throw error;
|
|
13213
|
+
lock = null;
|
|
13214
|
+
changingReadError = error;
|
|
13215
|
+
}
|
|
13187
13216
|
if (lock) {
|
|
13188
13217
|
try {
|
|
13189
13218
|
options.signal?.throwIfAborted();
|
|
@@ -13194,19 +13223,22 @@ async function withLock(target, options, fn) {
|
|
|
13194
13223
|
}
|
|
13195
13224
|
const remaining = options.timeoutMs - (performance.now() - started);
|
|
13196
13225
|
if (remaining <= 0) {
|
|
13226
|
+
if (changingReadError)
|
|
13227
|
+
throw changingReadError;
|
|
13197
13228
|
throw new LockContentionError({
|
|
13198
13229
|
target,
|
|
13199
13230
|
name: options.name,
|
|
13200
13231
|
timeoutMs: options.timeoutMs
|
|
13201
13232
|
});
|
|
13202
13233
|
}
|
|
13203
|
-
await new Promise((
|
|
13234
|
+
await new Promise((resolve28) => setTimeout(resolve28, Math.min(25, Math.ceil(remaining))));
|
|
13204
13235
|
}
|
|
13205
13236
|
}
|
|
13206
13237
|
var LockContentionError, LockOwnershipError;
|
|
13207
13238
|
var init_with_lock = __esm({
|
|
13208
13239
|
"../core/dist/common-auth-embedded/fs/with-lock.js"() {
|
|
13209
13240
|
"use strict";
|
|
13241
|
+
init_private_files();
|
|
13210
13242
|
init_refresh_file_lock();
|
|
13211
13243
|
LockContentionError = class extends Error {
|
|
13212
13244
|
details;
|
|
@@ -13319,7 +13351,7 @@ async function acquirePoolLock(spec, defaults, env3) {
|
|
|
13319
13351
|
});
|
|
13320
13352
|
}
|
|
13321
13353
|
const jitter = Math.floor(Math.random() * (options.retryMs + 1));
|
|
13322
|
-
await new Promise((
|
|
13354
|
+
await new Promise((resolve28) => setTimeout(resolve28, Math.min(options.retryMs + jitter, remaining)));
|
|
13323
13355
|
}
|
|
13324
13356
|
}
|
|
13325
13357
|
function definedOnly(spec) {
|
|
@@ -16163,7 +16195,7 @@ var init_redact = __esm({
|
|
|
16163
16195
|
// ../core/dist/common-auth-embedded/logger/engine.js
|
|
16164
16196
|
import { appendFileSync, chmodSync, existsSync, renameSync, statSync } from "node:fs";
|
|
16165
16197
|
import { open as open5 } from "node:fs/promises";
|
|
16166
|
-
import { dirname as dirname8, resolve as
|
|
16198
|
+
import { dirname as dirname8, resolve as resolve4 } from "node:path";
|
|
16167
16199
|
function chmodPrivate(path5) {
|
|
16168
16200
|
try {
|
|
16169
16201
|
chmodSync(path5, 384);
|
|
@@ -16214,7 +16246,7 @@ async function openWindowsFile(sink, file) {
|
|
|
16214
16246
|
return sink.handle;
|
|
16215
16247
|
}
|
|
16216
16248
|
async function flushWindowsFile(sink, file, text2) {
|
|
16217
|
-
file =
|
|
16249
|
+
file = resolve4(file);
|
|
16218
16250
|
try {
|
|
16219
16251
|
if (sink.file !== file)
|
|
16220
16252
|
await closeWindowsFile(sink);
|
|
@@ -16590,11 +16622,11 @@ var init_quota_writer = __esm({
|
|
|
16590
16622
|
const left = deadline - performance.now();
|
|
16591
16623
|
if (left <= 0)
|
|
16592
16624
|
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);
|
|
16593
|
-
await new Promise((
|
|
16625
|
+
await new Promise((resolve28) => {
|
|
16594
16626
|
const done = () => {
|
|
16595
16627
|
clearTimeout(timer);
|
|
16596
16628
|
this.wake.delete(done);
|
|
16597
|
-
|
|
16629
|
+
resolve28();
|
|
16598
16630
|
};
|
|
16599
16631
|
const timer = setTimeout(done, left);
|
|
16600
16632
|
this.wake.add(done);
|
|
@@ -16987,7 +17019,7 @@ var init_refresh = __esm({
|
|
|
16987
17019
|
|
|
16988
17020
|
// ../core/dist/common-auth-embedded/fs/file-read-cache.js
|
|
16989
17021
|
import { lstat as lstat4 } from "node:fs/promises";
|
|
16990
|
-
import { resolve as
|
|
17022
|
+
import { resolve as resolve5 } from "node:path";
|
|
16991
17023
|
async function identity(path5) {
|
|
16992
17024
|
try {
|
|
16993
17025
|
const metadata = await lstat4(path5);
|
|
@@ -17008,7 +17040,7 @@ var init_file_read_cache = __esm({
|
|
|
17008
17040
|
FileReadCache = class {
|
|
17009
17041
|
#entries = /* @__PURE__ */ new Map();
|
|
17010
17042
|
async read(paths, read, validateHit) {
|
|
17011
|
-
const resolvedPaths = paths.map((path5) =>
|
|
17043
|
+
const resolvedPaths = paths.map((path5) => resolve5(path5));
|
|
17012
17044
|
const key = JSON.stringify(resolvedPaths);
|
|
17013
17045
|
const probed = await Promise.all(resolvedPaths.map(identity));
|
|
17014
17046
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -19365,7 +19397,7 @@ async function select(terminal, items, options) {
|
|
|
19365
19397
|
writeLine("");
|
|
19366
19398
|
renderedLines = lines;
|
|
19367
19399
|
};
|
|
19368
|
-
return new Promise((
|
|
19400
|
+
return new Promise((resolve28) => {
|
|
19369
19401
|
const wasRaw = stdin.isRaw ?? false;
|
|
19370
19402
|
const cleanup2 = () => {
|
|
19371
19403
|
if (cleaned)
|
|
@@ -19385,7 +19417,7 @@ async function select(terminal, items, options) {
|
|
|
19385
19417
|
};
|
|
19386
19418
|
const finish = (value) => {
|
|
19387
19419
|
cleanup2();
|
|
19388
|
-
|
|
19420
|
+
resolve28(value);
|
|
19389
19421
|
};
|
|
19390
19422
|
const onSignal = () => finish(null);
|
|
19391
19423
|
const onKey = (data) => {
|
|
@@ -19425,7 +19457,7 @@ async function select(terminal, items, options) {
|
|
|
19425
19457
|
stdin.setRawMode(true);
|
|
19426
19458
|
} catch {
|
|
19427
19459
|
cleanup2();
|
|
19428
|
-
|
|
19460
|
+
resolve28(null);
|
|
19429
19461
|
return;
|
|
19430
19462
|
}
|
|
19431
19463
|
stdin.resume();
|
|
@@ -20267,7 +20299,7 @@ var init_watch = __esm({
|
|
|
20267
20299
|
});
|
|
20268
20300
|
|
|
20269
20301
|
// ../core/dist/common-auth-embedded/claustrum/insula.js
|
|
20270
|
-
import { resolve as
|
|
20302
|
+
import { resolve as resolve6 } from "node:path";
|
|
20271
20303
|
import { storeIdentity } from "@cortexkit/claustrum-client";
|
|
20272
20304
|
import { SubcClient } from "@cortexkit/subc-client";
|
|
20273
20305
|
function insulaUsageTransport(options) {
|
|
@@ -20395,8 +20427,8 @@ function refusalCode(error) {
|
|
|
20395
20427
|
}
|
|
20396
20428
|
function acquireInsulaQuotaSource(transport, tokenPath) {
|
|
20397
20429
|
const key = JSON.stringify([
|
|
20398
|
-
|
|
20399
|
-
|
|
20430
|
+
resolve6(transport.connectionFile),
|
|
20431
|
+
resolve6(tokenPath)
|
|
20400
20432
|
]);
|
|
20401
20433
|
let shared4 = sources.get(key);
|
|
20402
20434
|
if (!shared4) {
|
|
@@ -20710,7 +20742,7 @@ var init_any_signal = __esm({
|
|
|
20710
20742
|
import { createHash as createHash6, randomBytes as randomBytes4, randomUUID as randomUUID12 } from "node:crypto";
|
|
20711
20743
|
import { constants as fsConstants } from "node:fs";
|
|
20712
20744
|
import { chmod as chmod2, mkdir as mkdir8, open as open6, readFile as readFile6, realpath as realpath3, rename as rename7, stat as stat4, unlink as unlink6 } from "node:fs/promises";
|
|
20713
|
-
import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as
|
|
20745
|
+
import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as resolve7 } from "node:path";
|
|
20714
20746
|
import { ClaustrumCredentialError as ClaustrumCredentialError2, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
|
|
20715
20747
|
function classifyEnrollmentError(error) {
|
|
20716
20748
|
if (!(error instanceof ClaustrumCredentialError2))
|
|
@@ -20736,7 +20768,7 @@ function getClaustrumEnrollmentPaths(tokenPath) {
|
|
|
20736
20768
|
const extension = extname(tokenPath) || ".json";
|
|
20737
20769
|
const stem = basename3(tokenPath, extname(tokenPath));
|
|
20738
20770
|
return {
|
|
20739
|
-
statePath:
|
|
20771
|
+
statePath: join7(dirname9(tokenPath), `${stem}-state${extension}`),
|
|
20740
20772
|
tokenPath
|
|
20741
20773
|
};
|
|
20742
20774
|
}
|
|
@@ -20744,7 +20776,7 @@ function hostEnrollmentPaths(input2) {
|
|
|
20744
20776
|
const override = input2.override?.trim();
|
|
20745
20777
|
if (override && !isAbsolute2(override) && !input2.cwd)
|
|
20746
20778
|
throw new ClaustrumConsumerError("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
20747
|
-
const tokenPath = override ? isAbsolute2(override) ? override :
|
|
20779
|
+
const tokenPath = override ? isAbsolute2(override) ? override : resolve7(input2.cwd, override) : join7(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
20748
20780
|
return getClaustrumEnrollmentPaths(tokenPath);
|
|
20749
20781
|
}
|
|
20750
20782
|
function isRecord6(value) {
|
|
@@ -20977,7 +21009,7 @@ async function writeStateAtomic(path5, state, ancestorOptions = {}) {
|
|
|
20977
21009
|
}
|
|
20978
21010
|
if (windowsPrivateFiles)
|
|
20979
21011
|
return writePrivateAtomic(path5, bytes);
|
|
20980
|
-
const temporary =
|
|
21012
|
+
const temporary = join7(parent, `.${basename3(path5)}.${process.pid}.${randomUUID12()}.tmp`);
|
|
20981
21013
|
let descriptor;
|
|
20982
21014
|
let created = false;
|
|
20983
21015
|
try {
|
|
@@ -21473,10 +21505,10 @@ async function drainShutdown(pending, onTimeout) {
|
|
|
21473
21505
|
try {
|
|
21474
21506
|
await Promise.race([
|
|
21475
21507
|
drained,
|
|
21476
|
-
new Promise((
|
|
21508
|
+
new Promise((resolve28) => {
|
|
21477
21509
|
timer = setTimeout(() => {
|
|
21478
21510
|
expired = true;
|
|
21479
|
-
|
|
21511
|
+
resolve28();
|
|
21480
21512
|
}, 2e3);
|
|
21481
21513
|
})
|
|
21482
21514
|
]);
|
|
@@ -22246,7 +22278,7 @@ var init_interlock = __esm({
|
|
|
22246
22278
|
// ../core/dist/common-auth-embedded/claustrum/roster.js
|
|
22247
22279
|
import { createHash as createHash7 } from "node:crypto";
|
|
22248
22280
|
import { stat as stat5 } from "node:fs/promises";
|
|
22249
|
-
import { resolve as
|
|
22281
|
+
import { resolve as resolve8 } from "node:path";
|
|
22250
22282
|
function vaultRosterSeed(roster) {
|
|
22251
22283
|
return {
|
|
22252
22284
|
declined: roster.declined.map((entry) => ({ ...entry })),
|
|
@@ -22633,16 +22665,16 @@ function applyVaultQuota(current, input2) {
|
|
|
22633
22665
|
};
|
|
22634
22666
|
}
|
|
22635
22667
|
function forgetPendingVaultDiscovery(path5) {
|
|
22636
|
-
pendingDiscoveries.delete(
|
|
22668
|
+
pendingDiscoveries.delete(resolve8(path5));
|
|
22637
22669
|
}
|
|
22638
22670
|
function isVaultRosterLockRefusal(path5, error) {
|
|
22639
|
-
const target =
|
|
22671
|
+
const target = resolve8(path5);
|
|
22640
22672
|
if (error instanceof ClaustrumConsumerError)
|
|
22641
22673
|
return error.kind === "roster-busy";
|
|
22642
22674
|
if (error instanceof LockContentionError || error instanceof LockOwnershipError)
|
|
22643
|
-
return
|
|
22675
|
+
return resolve8(error.details.target) === target;
|
|
22644
22676
|
if (error instanceof PrivateFileError) {
|
|
22645
|
-
const failed =
|
|
22677
|
+
const failed = resolve8(error.path);
|
|
22646
22678
|
return [WRITE_LOCK.name, DISCOVERY_LEASE.name].some((name) => {
|
|
22647
22679
|
const lock = lockPathFor(target, name);
|
|
22648
22680
|
return failed === lock || failed.startsWith(`${lock}.`);
|
|
@@ -22703,7 +22735,7 @@ async function refreshVaultRoster(options) {
|
|
|
22703
22735
|
throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
|
|
22704
22736
|
return persisted;
|
|
22705
22737
|
}
|
|
22706
|
-
const key =
|
|
22738
|
+
const key = resolve8(options.path);
|
|
22707
22739
|
const listedOver = options.listedOver;
|
|
22708
22740
|
let discovered;
|
|
22709
22741
|
try {
|
|
@@ -22823,9 +22855,9 @@ var init_roster = __esm({
|
|
|
22823
22855
|
});
|
|
22824
22856
|
|
|
22825
22857
|
// ../core/dist/common-auth-embedded/claustrum/quota-writer.js
|
|
22826
|
-
import { resolve as
|
|
22858
|
+
import { resolve as resolve9 } from "node:path";
|
|
22827
22859
|
function writerFor(path5, clock2 = quotaCommitTimer) {
|
|
22828
|
-
const key =
|
|
22860
|
+
const key = resolve9(path5);
|
|
22829
22861
|
let writer = writers.get(key);
|
|
22830
22862
|
if (!writer) {
|
|
22831
22863
|
writer = {
|
|
@@ -22889,7 +22921,7 @@ function orderedFields(pending) {
|
|
|
22889
22921
|
return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
|
|
22890
22922
|
}
|
|
22891
22923
|
function pendingVaultQuota(path5, roster) {
|
|
22892
|
-
const writer = writers.get(
|
|
22924
|
+
const writer = writers.get(resolve9(path5));
|
|
22893
22925
|
if (writer) {
|
|
22894
22926
|
for (const field of orderedFields(writer.pending)) {
|
|
22895
22927
|
if (field.priorReading)
|
|
@@ -22900,7 +22932,7 @@ function pendingVaultQuota(path5, roster) {
|
|
|
22900
22932
|
return roster;
|
|
22901
22933
|
}
|
|
22902
22934
|
function hasPendingVaultQuota(path5) {
|
|
22903
|
-
return !!writers.get(
|
|
22935
|
+
return !!writers.get(resolve9(path5))?.pending.size;
|
|
22904
22936
|
}
|
|
22905
22937
|
function schedule(writer, delay3) {
|
|
22906
22938
|
if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
|
|
@@ -22965,7 +22997,7 @@ function flush(writer) {
|
|
|
22965
22997
|
return writer.running;
|
|
22966
22998
|
}
|
|
22967
22999
|
async function drainVaultQuota(path5, timeoutMs = 1e3) {
|
|
22968
|
-
const key =
|
|
23000
|
+
const key = resolve9(path5);
|
|
22969
23001
|
const writer = writers.get(key);
|
|
22970
23002
|
if (!writer)
|
|
22971
23003
|
return;
|
|
@@ -23110,7 +23142,7 @@ var init_consumer = __esm({
|
|
|
23110
23142
|
this.#shutdown.signal,
|
|
23111
23143
|
...signal ? [signal] : []
|
|
23112
23144
|
]);
|
|
23113
|
-
return new Promise((
|
|
23145
|
+
return new Promise((resolve28, reject) => {
|
|
23114
23146
|
const cleanup2 = () => {
|
|
23115
23147
|
combined.signal.removeEventListener("abort", abort);
|
|
23116
23148
|
combined.dispose();
|
|
@@ -23125,7 +23157,7 @@ var init_consumer = __esm({
|
|
|
23125
23157
|
if (combined.signal.aborted)
|
|
23126
23158
|
reject(combined.signal.reason);
|
|
23127
23159
|
else
|
|
23128
|
-
|
|
23160
|
+
resolve28(value);
|
|
23129
23161
|
}, (error) => {
|
|
23130
23162
|
cleanup2();
|
|
23131
23163
|
reject(error);
|
|
@@ -23839,7 +23871,7 @@ var init_consumer = __esm({
|
|
|
23839
23871
|
import { createHash as createHash8 } from "node:crypto";
|
|
23840
23872
|
import { channel as channel2 } from "node:diagnostics_channel";
|
|
23841
23873
|
import { readdir, stat as stat6 } from "node:fs/promises";
|
|
23842
|
-
import { dirname as dirname10, join as
|
|
23874
|
+
import { dirname as dirname10, join as join8, resolve as resolve10 } from "node:path";
|
|
23843
23875
|
function canonicalJson3(value, path5 = /* @__PURE__ */ new Set()) {
|
|
23844
23876
|
if (value === null)
|
|
23845
23877
|
return "null";
|
|
@@ -23900,12 +23932,12 @@ function unreachableConnect2() {
|
|
|
23900
23932
|
return new ClaustrumUnreachableError();
|
|
23901
23933
|
}
|
|
23902
23934
|
function untilAborted(pending, signal) {
|
|
23903
|
-
return new Promise((
|
|
23935
|
+
return new Promise((resolve28, reject) => {
|
|
23904
23936
|
const abort = () => reject(signal.reason);
|
|
23905
23937
|
signal.addEventListener("abort", abort, { once: true });
|
|
23906
23938
|
pending.then((value) => {
|
|
23907
23939
|
signal.removeEventListener("abort", abort);
|
|
23908
|
-
|
|
23940
|
+
resolve28(value);
|
|
23909
23941
|
}, (error) => {
|
|
23910
23942
|
signal.removeEventListener("abort", abort);
|
|
23911
23943
|
reject(error);
|
|
@@ -23975,13 +24007,13 @@ var init_hub = __esm({
|
|
|
23975
24007
|
this.#options = options;
|
|
23976
24008
|
this.#logger = options.logger ?? createLogger2("claustrum");
|
|
23977
24009
|
this.#warnShutdown = shutdownWarning(this.#logger, this.#shutdown.signal);
|
|
23978
|
-
this.#generationDirectory =
|
|
24010
|
+
this.#generationDirectory = join8(options.stateDir, "rosters", hostGeneration);
|
|
23979
24011
|
this.#key = rosterFingerprint(options, providers);
|
|
23980
|
-
const directory =
|
|
24012
|
+
const directory = join8(this.#generationDirectory, this.#key);
|
|
23981
24013
|
for (const provider2 of providers)
|
|
23982
24014
|
this.#members.set(provider2, {
|
|
23983
24015
|
provider: provider2,
|
|
23984
|
-
path:
|
|
24016
|
+
path: join8(directory, `${provider2}.json`),
|
|
23985
24017
|
closed: false
|
|
23986
24018
|
});
|
|
23987
24019
|
}
|
|
@@ -24062,7 +24094,7 @@ var init_hub = __esm({
|
|
|
24062
24094
|
};
|
|
24063
24095
|
const { consumer, hooks } = createHubMember(port, consumerOptions);
|
|
24064
24096
|
entry.hooks = hooks;
|
|
24065
|
-
const path5 =
|
|
24097
|
+
const path5 = resolve10(entry.path);
|
|
24066
24098
|
const subscribers = sharedRosters.get(path5) ?? /* @__PURE__ */ new Set();
|
|
24067
24099
|
const install = (roster) => {
|
|
24068
24100
|
if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
|
|
@@ -24093,7 +24125,7 @@ var init_hub = __esm({
|
|
|
24093
24125
|
return;
|
|
24094
24126
|
entry.seen = JSON.stringify(decodedVaultRoster(roster));
|
|
24095
24127
|
entry.hooks?.install(roster);
|
|
24096
|
-
for (const install of sharedRosters.get(
|
|
24128
|
+
for (const install of sharedRosters.get(resolve10(entry.path)) ?? []) {
|
|
24097
24129
|
if (!this.#live(generation))
|
|
24098
24130
|
return;
|
|
24099
24131
|
if (install !== entry.receiveRoster)
|
|
@@ -24549,7 +24581,7 @@ var init_hub = __esm({
|
|
|
24549
24581
|
for (const directory of [
|
|
24550
24582
|
dirname10(this.#generationDirectory),
|
|
24551
24583
|
this.#generationDirectory,
|
|
24552
|
-
|
|
24584
|
+
join8(this.#generationDirectory, this.#key)
|
|
24553
24585
|
])
|
|
24554
24586
|
await ensureClaustrumPrivateDirectory(directory, {}, "roster directory");
|
|
24555
24587
|
}
|
|
@@ -24561,11 +24593,11 @@ var init_hub = __esm({
|
|
|
24561
24593
|
*/
|
|
24562
24594
|
async #seed(entry) {
|
|
24563
24595
|
const name = `${entry.provider}.json`;
|
|
24564
|
-
const candidates = [
|
|
24596
|
+
const candidates = [join8(this.#generationDirectory, name)];
|
|
24565
24597
|
try {
|
|
24566
24598
|
for (const key of await readdir(this.#generationDirectory))
|
|
24567
24599
|
if (key !== this.#key && FINGERPRINT.test(key))
|
|
24568
|
-
candidates.push(
|
|
24600
|
+
candidates.push(join8(this.#generationDirectory, key, name));
|
|
24569
24601
|
} catch {
|
|
24570
24602
|
}
|
|
24571
24603
|
let newest;
|
|
@@ -25138,7 +25170,7 @@ var init_lock = __esm({
|
|
|
25138
25170
|
import { createHash as createHash9 } from "node:crypto";
|
|
25139
25171
|
import { constants as constants2 } from "node:fs";
|
|
25140
25172
|
import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
|
|
25141
|
-
import { dirname as dirname11, resolve as
|
|
25173
|
+
import { dirname as dirname11, resolve as resolve11 } from "node:path";
|
|
25142
25174
|
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
25143
25175
|
function rootSpans(text2) {
|
|
25144
25176
|
let i = text2.indexOf("{") + 1;
|
|
@@ -25235,13 +25267,13 @@ async function safeRead(path5, privateFile = false, afterReadCheck) {
|
|
|
25235
25267
|
let file;
|
|
25236
25268
|
try {
|
|
25237
25269
|
file = await open7(path5, constants2.O_RDONLY | constants2.O_NOFOLLOW);
|
|
25238
|
-
const
|
|
25239
|
-
if (!
|
|
25270
|
+
const stat16 = await file.stat();
|
|
25271
|
+
if (!stat16.isFile() || privateFile && (stat16.mode & 511) !== 384) {
|
|
25240
25272
|
throw new PiSlotError("unsafe-path");
|
|
25241
25273
|
}
|
|
25242
25274
|
await afterReadCheck?.(path5);
|
|
25243
25275
|
const current = await lstat5(path5);
|
|
25244
|
-
if (!current.isFile() || current.dev !==
|
|
25276
|
+
if (!current.isFile() || current.dev !== stat16.dev || current.ino !== stat16.ino) {
|
|
25245
25277
|
throw new PiSlotError("unsafe-path");
|
|
25246
25278
|
}
|
|
25247
25279
|
const bytes = await file.readFile();
|
|
@@ -25339,8 +25371,8 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
25339
25371
|
if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
|
|
25340
25372
|
throw new PiSlotError("invalid-options");
|
|
25341
25373
|
}
|
|
25342
|
-
const authPath =
|
|
25343
|
-
const stashPath =
|
|
25374
|
+
const authPath = resolve11(options.authPath);
|
|
25375
|
+
const stashPath = resolve11(options.stashPath);
|
|
25344
25376
|
if (authPath === stashPath || stashPath === `${authPath}.lock`) {
|
|
25345
25377
|
throw new PiSlotError("invalid-options");
|
|
25346
25378
|
}
|
|
@@ -25773,15 +25805,15 @@ var init_model_types = __esm({
|
|
|
25773
25805
|
|
|
25774
25806
|
// ../core/dist/pi-paths.js
|
|
25775
25807
|
import { homedir } from "node:os";
|
|
25776
|
-
import { dirname as dirname12, join as
|
|
25808
|
+
import { dirname as dirname12, join as join9 } from "node:path";
|
|
25777
25809
|
function getPiConfigDir() {
|
|
25778
|
-
return process.env.PI_AGENT_DIR?.trim() ||
|
|
25810
|
+
return process.env.PI_AGENT_DIR?.trim() || join9(homedir(), ".pi", "agent");
|
|
25779
25811
|
}
|
|
25780
25812
|
function getPiAntigravityAuthFile() {
|
|
25781
|
-
return process.env.PI_ANTIGRAVITY_AUTH_FILE?.trim() ||
|
|
25813
|
+
return process.env.PI_ANTIGRAVITY_AUTH_FILE?.trim() || join9(getPiConfigDir(), "antigravity-accounts.json");
|
|
25782
25814
|
}
|
|
25783
25815
|
function getPiAntigravityVaultDir() {
|
|
25784
|
-
return
|
|
25816
|
+
return join9(dirname12(getPiAntigravityAuthFile()), "antigravity-auth-vault");
|
|
25785
25817
|
}
|
|
25786
25818
|
var init_pi_paths = __esm({
|
|
25787
25819
|
"../core/dist/pi-paths.js"() {
|
|
@@ -25963,8 +25995,8 @@ function getDefaultTierId(allowedTiers) {
|
|
|
25963
25995
|
return allowedTiers[0]?.id;
|
|
25964
25996
|
}
|
|
25965
25997
|
function wait(ms) {
|
|
25966
|
-
return new Promise((
|
|
25967
|
-
setTimeout(
|
|
25998
|
+
return new Promise((resolve28) => {
|
|
25999
|
+
setTimeout(resolve28, ms);
|
|
25968
26000
|
});
|
|
25969
26001
|
}
|
|
25970
26002
|
function extractManagedProjectId(payload) {
|
|
@@ -28286,12 +28318,12 @@ var init_vault_provider_state = __esm({
|
|
|
28286
28318
|
function untilAborted2(pending, signal) {
|
|
28287
28319
|
if (!signal)
|
|
28288
28320
|
return pending;
|
|
28289
|
-
return new Promise((
|
|
28321
|
+
return new Promise((resolve28, reject) => {
|
|
28290
28322
|
const abort = () => reject(signal.reason);
|
|
28291
28323
|
signal.addEventListener("abort", abort, { once: true });
|
|
28292
28324
|
if (signal.aborted)
|
|
28293
28325
|
abort();
|
|
28294
|
-
pending.then(
|
|
28326
|
+
pending.then(resolve28, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
28295
28327
|
});
|
|
28296
28328
|
}
|
|
28297
28329
|
async function resolveClaustrumConnectionPath(explicit) {
|
|
@@ -28662,7 +28694,7 @@ function getAntigravityVersionResolution() {
|
|
|
28662
28694
|
return lastResolution ?? { version: getAntigravityVersion(), source: "fallback" };
|
|
28663
28695
|
}
|
|
28664
28696
|
async function initAntigravityVersion() {
|
|
28665
|
-
const
|
|
28697
|
+
const log17 = createLogger("version");
|
|
28666
28698
|
const fallback = getAntigravityVersion();
|
|
28667
28699
|
let version;
|
|
28668
28700
|
let source;
|
|
@@ -28676,15 +28708,15 @@ async function initAntigravityVersion() {
|
|
|
28676
28708
|
} else {
|
|
28677
28709
|
source = "fallback";
|
|
28678
28710
|
setAntigravityVersion(fallback);
|
|
28679
|
-
|
|
28711
|
+
log17.info("version-fetch-failed", { fallback });
|
|
28680
28712
|
lastResolution = { version: fallback, source };
|
|
28681
28713
|
return lastResolution;
|
|
28682
28714
|
}
|
|
28683
28715
|
}
|
|
28684
28716
|
if (version !== fallback) {
|
|
28685
|
-
|
|
28717
|
+
log17.info("version-updated", { version, source, previous: fallback });
|
|
28686
28718
|
} else {
|
|
28687
|
-
|
|
28719
|
+
log17.debug("version-unchanged", { version, source });
|
|
28688
28720
|
}
|
|
28689
28721
|
setAntigravityVersion(version);
|
|
28690
28722
|
lastResolution = { version, source };
|
|
@@ -28754,18 +28786,11 @@ var init_dist = __esm({
|
|
|
28754
28786
|
}
|
|
28755
28787
|
});
|
|
28756
28788
|
|
|
28757
|
-
// src/common-auth-embedded/logger/capture-sink.js
|
|
28758
|
-
var init_capture_sink2 = __esm({
|
|
28759
|
-
"src/common-auth-embedded/logger/capture-sink.js"() {
|
|
28760
|
-
"use strict";
|
|
28761
|
-
}
|
|
28762
|
-
});
|
|
28763
|
-
|
|
28764
28789
|
// src/common-auth-embedded/fs/private-files.js
|
|
28765
28790
|
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
28766
28791
|
import { lstat as lstat6, readFile as readFile8, rename as rename8, unlink as unlink8 } from "node:fs/promises";
|
|
28767
28792
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
28768
|
-
import { dirname as dirname13, join as
|
|
28793
|
+
import { dirname as dirname13, join as join10, resolve as resolve12 } from "node:path";
|
|
28769
28794
|
function ioCode2(detail) {
|
|
28770
28795
|
if (detail?.reason === "io-error") {
|
|
28771
28796
|
if (detail.win32Code === 2 || detail.win32Code === 3)
|
|
@@ -28786,7 +28811,7 @@ function isUnavailable2(api, error) {
|
|
|
28786
28811
|
}
|
|
28787
28812
|
async function assertNativeAddonLoads2(api) {
|
|
28788
28813
|
try {
|
|
28789
|
-
await api.verifyPrivatePath(
|
|
28814
|
+
await api.verifyPrivatePath(join10(tmpdir2(), `.common-auth-private-files-probe-${randomUUID13()}`), "file");
|
|
28790
28815
|
} catch (error) {
|
|
28791
28816
|
if (isUnavailable2(api, error))
|
|
28792
28817
|
throw privateFilesUnavailable2(error);
|
|
@@ -28812,7 +28837,7 @@ async function privateOperation2(path5, stage, operation) {
|
|
|
28812
28837
|
}
|
|
28813
28838
|
}
|
|
28814
28839
|
async function verifySafeDirectory2(path5, options) {
|
|
28815
|
-
path5 =
|
|
28840
|
+
path5 = resolve12(path5);
|
|
28816
28841
|
options ??= safeParentOptionsForTest2;
|
|
28817
28842
|
await privateOperation2(path5, "safe-parent", async () => {
|
|
28818
28843
|
const result = await (await loadBackend2()).verifySafeParent(path5, options);
|
|
@@ -28827,7 +28852,7 @@ async function verifySafeDirectory2(path5, options) {
|
|
|
28827
28852
|
});
|
|
28828
28853
|
}
|
|
28829
28854
|
async function verifyPrivate2(path5, kind, migrate = false) {
|
|
28830
|
-
path5 =
|
|
28855
|
+
path5 = resolve12(path5);
|
|
28831
28856
|
if (kind === "directory")
|
|
28832
28857
|
return verifySafeDirectory2(path5);
|
|
28833
28858
|
await privateOperation2(path5, "verify", async () => {
|
|
@@ -28862,7 +28887,7 @@ async function verifyPrivate2(path5, kind, migrate = false) {
|
|
|
28862
28887
|
});
|
|
28863
28888
|
}
|
|
28864
28889
|
async function ensurePrivateDirectory2(path5, _migrate = false, options) {
|
|
28865
|
-
path5 =
|
|
28890
|
+
path5 = resolve12(path5);
|
|
28866
28891
|
await privateOperation2(path5, "directory", async () => {
|
|
28867
28892
|
const api = await loadBackend2();
|
|
28868
28893
|
try {
|
|
@@ -28893,7 +28918,7 @@ async function readPrivateText2(path5, migrate = false) {
|
|
|
28893
28918
|
async function readPrivateBuffer2(path5, migrate = false) {
|
|
28894
28919
|
if (!windowsPrivateFiles2)
|
|
28895
28920
|
return readFile8(path5);
|
|
28896
|
-
path5 =
|
|
28921
|
+
path5 = resolve12(path5);
|
|
28897
28922
|
if (migrate) {
|
|
28898
28923
|
await verifySafeDirectory2(dirname13(path5));
|
|
28899
28924
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -28901,20 +28926,20 @@ async function readPrivateBuffer2(path5, migrate = false) {
|
|
|
28901
28926
|
return privateOperation2(path5, "read", async () => (await loadBackend2()).readOwnerOnly(path5));
|
|
28902
28927
|
}
|
|
28903
28928
|
async function createPrivateBytes2(path5, bytes) {
|
|
28904
|
-
await verifySafeDirectory2(dirname13(
|
|
28929
|
+
await verifySafeDirectory2(dirname13(resolve12(path5)));
|
|
28905
28930
|
await privateOperation2(path5, "create", async () => {
|
|
28906
|
-
await (await loadBackend2()).createPrivateFile(
|
|
28931
|
+
await (await loadBackend2()).createPrivateFile(resolve12(path5), bytes);
|
|
28907
28932
|
});
|
|
28908
28933
|
}
|
|
28909
28934
|
async function createPrivateDirectoryExclusive2(path5) {
|
|
28910
|
-
await verifySafeDirectory2(dirname13(
|
|
28935
|
+
await verifySafeDirectory2(dirname13(resolve12(path5)));
|
|
28911
28936
|
await privateOperation2(path5, "directory-create", async () => {
|
|
28912
|
-
await (await loadBackend2()).createOwnerOnly(
|
|
28937
|
+
await (await loadBackend2()).createOwnerOnly(resolve12(path5), { kind: "dir" });
|
|
28913
28938
|
});
|
|
28914
28939
|
}
|
|
28915
28940
|
async function replaceWindowsFile2(from, to, options = {}) {
|
|
28916
|
-
from =
|
|
28917
|
-
to =
|
|
28941
|
+
from = resolve12(from);
|
|
28942
|
+
to = resolve12(to);
|
|
28918
28943
|
const now = options.now ?? (() => performance.now());
|
|
28919
28944
|
const start = now();
|
|
28920
28945
|
const leaseDeadline = options.deadline ?? Infinity;
|
|
@@ -28957,7 +28982,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
|
|
|
28957
28982
|
throw error;
|
|
28958
28983
|
}
|
|
28959
28984
|
async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
28960
|
-
path5 =
|
|
28985
|
+
path5 = resolve12(path5);
|
|
28961
28986
|
await ensurePrivateDirectory2(dirname13(path5));
|
|
28962
28987
|
try {
|
|
28963
28988
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -28965,7 +28990,7 @@ async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
|
28965
28990
|
if (error.code !== "ENOENT")
|
|
28966
28991
|
throw error;
|
|
28967
28992
|
}
|
|
28968
|
-
const stage =
|
|
28993
|
+
const stage = resolve12(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
|
|
28969
28994
|
if (dirname13(stage) !== dirname13(path5))
|
|
28970
28995
|
throw new PrivateFileError2(path5, "stage-directory", { code: "EXDEV" });
|
|
28971
28996
|
let created = false;
|
|
@@ -29058,6 +29083,13 @@ var init_private_files2 = __esm({
|
|
|
29058
29083
|
}
|
|
29059
29084
|
});
|
|
29060
29085
|
|
|
29086
|
+
// src/common-auth-embedded/logger/capture-sink.js
|
|
29087
|
+
var init_capture_sink2 = __esm({
|
|
29088
|
+
"src/common-auth-embedded/logger/capture-sink.js"() {
|
|
29089
|
+
"use strict";
|
|
29090
|
+
}
|
|
29091
|
+
});
|
|
29092
|
+
|
|
29061
29093
|
// src/common-auth-embedded/logger/redact.js
|
|
29062
29094
|
function isError2(value) {
|
|
29063
29095
|
return value instanceof Error || Object.prototype.toString.call(value) === "[object Error]";
|
|
@@ -29131,7 +29163,7 @@ var init_redact2 = __esm({
|
|
|
29131
29163
|
// src/common-auth-embedded/logger/engine.js
|
|
29132
29164
|
import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
|
|
29133
29165
|
import { open as open8 } from "node:fs/promises";
|
|
29134
|
-
import { dirname as dirname14, resolve as
|
|
29166
|
+
import { dirname as dirname14, resolve as resolve13 } from "node:path";
|
|
29135
29167
|
function chmodPrivate2(path5) {
|
|
29136
29168
|
try {
|
|
29137
29169
|
chmodSync2(path5, 384);
|
|
@@ -29182,7 +29214,7 @@ async function openWindowsFile2(sink, file) {
|
|
|
29182
29214
|
return sink.handle;
|
|
29183
29215
|
}
|
|
29184
29216
|
async function flushWindowsFile2(sink, file, text2) {
|
|
29185
|
-
file =
|
|
29217
|
+
file = resolve13(file);
|
|
29186
29218
|
try {
|
|
29187
29219
|
if (sink.file !== file)
|
|
29188
29220
|
await closeWindowsFile2(sink);
|
|
@@ -29467,6 +29499,10 @@ function createVaultRequestCredentials(source, onAdmitted) {
|
|
|
29467
29499
|
const issued = /* @__PURE__ */ new WeakMap();
|
|
29468
29500
|
return {
|
|
29469
29501
|
domain: "vault",
|
|
29502
|
+
routingCandidate: (row) => ({
|
|
29503
|
+
accountId: row.route.accountIdentity,
|
|
29504
|
+
credentialId: row.route.credentialId
|
|
29505
|
+
}),
|
|
29470
29506
|
...source.retryAfter401 && {
|
|
29471
29507
|
retryAfter401(served, current, site) {
|
|
29472
29508
|
const original = issued.get(served);
|
|
@@ -29978,7 +30014,7 @@ var init_vault_insula_quota = __esm({
|
|
|
29978
30014
|
|
|
29979
30015
|
// src/plugin/vault-custody.ts
|
|
29980
30016
|
import { chmod as chmod3, mkdir as mkdir11, readFile as readFile9, stat as stat8 } from "node:fs/promises";
|
|
29981
|
-
import { join as
|
|
30017
|
+
import { join as join11 } from "node:path";
|
|
29982
30018
|
async function enrollmentFilesIdentity(paths) {
|
|
29983
30019
|
const takenAt = performance.now();
|
|
29984
30020
|
let coarse = process.platform === "win32";
|
|
@@ -30002,9 +30038,9 @@ function openCodeVaultPaths(vaultDir) {
|
|
|
30002
30038
|
const dir = vaultDir;
|
|
30003
30039
|
return {
|
|
30004
30040
|
dir,
|
|
30005
|
-
modeFile:
|
|
30006
|
-
rosterFile:
|
|
30007
|
-
stateFile:
|
|
30041
|
+
modeFile: join11(dir, "opencode-mode.json"),
|
|
30042
|
+
rosterFile: join11(dir, "opencode-roster.json"),
|
|
30043
|
+
stateFile: join11(dir, "opencode-state.json")
|
|
30008
30044
|
};
|
|
30009
30045
|
}
|
|
30010
30046
|
async function ensureVaultDir(dir) {
|
|
@@ -30241,11 +30277,11 @@ function createOpenCodeVaultCustody(options) {
|
|
|
30241
30277
|
].join("\n");
|
|
30242
30278
|
const waitForApproval = async () => {
|
|
30243
30279
|
while (!closed2) {
|
|
30244
|
-
await new Promise((
|
|
30280
|
+
await new Promise((resolve28) => {
|
|
30245
30281
|
const done = () => {
|
|
30246
30282
|
clearTimeout(timer);
|
|
30247
30283
|
cancelWait = void 0;
|
|
30248
|
-
|
|
30284
|
+
resolve28();
|
|
30249
30285
|
};
|
|
30250
30286
|
const timer = setTimeout(done, 2e3);
|
|
30251
30287
|
timer.unref?.();
|
|
@@ -30632,20 +30668,20 @@ import { randomUUID as randomUUID14 } from "node:crypto";
|
|
|
30632
30668
|
import { realpathSync, rmSync } from "node:fs";
|
|
30633
30669
|
import { chmod as chmod4, mkdir as mkdir12, readFile as readFile10, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
|
|
30634
30670
|
import { homedir as homedir2 } from "node:os";
|
|
30635
|
-
import { join as
|
|
30671
|
+
import { join as join12, resolve as resolve14 } from "node:path";
|
|
30636
30672
|
function processHeartbeatDir() {
|
|
30637
|
-
const base = process.env.XDG_STATE_HOME ||
|
|
30638
|
-
return
|
|
30673
|
+
const base = process.env.XDG_STATE_HOME || join12(homedir2(), ".local", "state");
|
|
30674
|
+
return join12(base, "cortexkit", "antigravity-auth", "processes");
|
|
30639
30675
|
}
|
|
30640
30676
|
function processHeartbeatPath(pid = process.pid, dir = processHeartbeatDir()) {
|
|
30641
|
-
return
|
|
30677
|
+
return join12(dir, `${pid}.json`);
|
|
30642
30678
|
}
|
|
30643
30679
|
function processConfigFolderKey() {
|
|
30644
30680
|
const folder = getConfigDir();
|
|
30645
30681
|
try {
|
|
30646
30682
|
return realpathSync.native(folder);
|
|
30647
30683
|
} catch {
|
|
30648
|
-
return
|
|
30684
|
+
return resolve14(folder);
|
|
30649
30685
|
}
|
|
30650
30686
|
}
|
|
30651
30687
|
function processHasOlderGeneration() {
|
|
@@ -30881,17 +30917,17 @@ var init_process_heartbeat = __esm({
|
|
|
30881
30917
|
});
|
|
30882
30918
|
|
|
30883
30919
|
// src/version-fence.ts
|
|
30884
|
-
import { readdir as readdir2, readFile as readFile11 } from "node:fs/promises";
|
|
30885
|
-
import { homedir as homedir3 } from "node:os";
|
|
30886
|
-
import { join as
|
|
30920
|
+
import { readdir as readdir2, readFile as readFile11, stat as stat9, unlink as unlink9 } from "node:fs/promises";
|
|
30921
|
+
import { homedir as homedir3, uptime } from "node:os";
|
|
30922
|
+
import { join as join13 } from "node:path";
|
|
30887
30923
|
function defaultStateHome() {
|
|
30888
|
-
return process.env.XDG_STATE_HOME ||
|
|
30924
|
+
return process.env.XDG_STATE_HOME || join13(homedir3(), ".local", "state");
|
|
30889
30925
|
}
|
|
30890
30926
|
function processHeartbeatDir2(stateHome = defaultStateHome()) {
|
|
30891
|
-
return
|
|
30927
|
+
return join13(stateHome, "cortexkit", "antigravity-auth", "processes");
|
|
30892
30928
|
}
|
|
30893
30929
|
function rpcStateRoot(stateHome = defaultStateHome()) {
|
|
30894
|
-
return
|
|
30930
|
+
return join13(stateHome, "cortexkit", "antigravity-auth", "rpc");
|
|
30895
30931
|
}
|
|
30896
30932
|
function isRpcProjectDir(name) {
|
|
30897
30933
|
return /^[0-9a-f]{16}$/.test(name);
|
|
@@ -30965,13 +31001,18 @@ async function readProcessRecord(path5, pid) {
|
|
|
30965
31001
|
return { kind: "gone" };
|
|
30966
31002
|
return { kind: "unreadable" };
|
|
30967
31003
|
}
|
|
31004
|
+
let startedAt;
|
|
30968
31005
|
try {
|
|
30969
31006
|
const value = JSON.parse(text2);
|
|
31007
|
+
if (isRecord10(value) && typeof value.startedAt === "number" && Number.isFinite(value.startedAt))
|
|
31008
|
+
startedAt = value.startedAt;
|
|
30970
31009
|
if (value !== null && typeof value === "object" && value.pid === pid && typeof value.version === "string") {
|
|
30971
31010
|
const layouts = value.layouts;
|
|
30972
31011
|
const stores = value.stores;
|
|
30973
31012
|
return {
|
|
30974
31013
|
kind: "ok",
|
|
31014
|
+
text: text2,
|
|
31015
|
+
startedAt,
|
|
30975
31016
|
version: value.version,
|
|
30976
31017
|
...isRecord10(layouts) ? { layouts } : {},
|
|
30977
31018
|
...isRecord10(stores) ? { stores } : {}
|
|
@@ -30979,14 +31020,45 @@ async function readProcessRecord(path5, pid) {
|
|
|
30979
31020
|
}
|
|
30980
31021
|
} catch {
|
|
30981
31022
|
}
|
|
30982
|
-
return { kind: "unreadable" };
|
|
31023
|
+
return { kind: "unreadable", text: text2, startedAt };
|
|
30983
31024
|
}
|
|
30984
31025
|
function isRecord10(value) {
|
|
30985
31026
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
30986
31027
|
}
|
|
31028
|
+
function bootTime(options) {
|
|
31029
|
+
try {
|
|
31030
|
+
return (options.now ?? Date.now)() - (options.uptimeSeconds ?? uptime)() * 1e3;
|
|
31031
|
+
} catch {
|
|
31032
|
+
return Number.NaN;
|
|
31033
|
+
}
|
|
31034
|
+
}
|
|
31035
|
+
async function staleRecord(path5, record3, boot, heartbeat) {
|
|
31036
|
+
if (record3.text === void 0 || !Number.isFinite(boot)) return false;
|
|
31037
|
+
let start = heartbeat ? record3.startedAt : void 0;
|
|
31038
|
+
if (start === void 0) {
|
|
31039
|
+
try {
|
|
31040
|
+
start = (await stat9(path5)).mtimeMs;
|
|
31041
|
+
} catch {
|
|
31042
|
+
return false;
|
|
31043
|
+
}
|
|
31044
|
+
}
|
|
31045
|
+
if (!Number.isFinite(start) || !(start < boot - BOOT_TIME_MARGIN_MS))
|
|
31046
|
+
return false;
|
|
31047
|
+
if (heartbeat) {
|
|
31048
|
+
try {
|
|
31049
|
+
if (await readFile11(path5, "utf8") === record3.text) {
|
|
31050
|
+
await unlink9(path5);
|
|
31051
|
+
log5.debug("Removed stale pre-boot heartbeat", { path: path5 });
|
|
31052
|
+
}
|
|
31053
|
+
} catch {
|
|
31054
|
+
}
|
|
31055
|
+
}
|
|
31056
|
+
return true;
|
|
31057
|
+
}
|
|
30987
31058
|
async function versionFenceOpen(options) {
|
|
30988
31059
|
const isAlive = options.isAlive ?? pidAlive;
|
|
30989
31060
|
const self = options.selfPid ?? process.pid;
|
|
31061
|
+
const boot = bootTime(options);
|
|
30990
31062
|
const blockers = /* @__PURE__ */ new Map();
|
|
30991
31063
|
const block = (entry) => {
|
|
30992
31064
|
const key = entry.pid === "unknown" ? `dir:${entry.detail}` : entry.pid;
|
|
@@ -31006,10 +31078,11 @@ async function versionFenceOpen(options) {
|
|
|
31006
31078
|
for (const name of heartbeats.ok ? heartbeats.names : []) {
|
|
31007
31079
|
const pid = pidFrom(name, /^(\d+)\.json$/);
|
|
31008
31080
|
if (pid === void 0 || pid === self) continue;
|
|
31009
|
-
const path5 =
|
|
31081
|
+
const path5 = join13(heartbeatDir, name);
|
|
31010
31082
|
const heartbeat = await readProcessRecord(path5, pid);
|
|
31011
31083
|
if (heartbeat.kind === "gone") continue;
|
|
31012
|
-
|
|
31084
|
+
const live = alive(pid);
|
|
31085
|
+
if (await staleRecord(path5, heartbeat, boot, true) || !live) continue;
|
|
31013
31086
|
if (heartbeat.kind === "unreadable") {
|
|
31014
31087
|
block({ pid, version: "unknown", detail: path5 });
|
|
31015
31088
|
continue;
|
|
@@ -31030,7 +31103,7 @@ async function versionFenceOpen(options) {
|
|
|
31030
31103
|
block({ pid: "unknown", version: "unknown", detail: projects.error });
|
|
31031
31104
|
for (const project3 of projects.ok ? projects.names : []) {
|
|
31032
31105
|
if (!isRpcProjectDir(project3)) continue;
|
|
31033
|
-
const dir =
|
|
31106
|
+
const dir = join13(rpcRoot, project3);
|
|
31034
31107
|
const ports = await list2(dir);
|
|
31035
31108
|
if (!ports.ok) {
|
|
31036
31109
|
if (ports.code === "ENOTDIR") continue;
|
|
@@ -31040,9 +31113,10 @@ async function versionFenceOpen(options) {
|
|
|
31040
31113
|
for (const name of ports.names) {
|
|
31041
31114
|
const pid = pidFrom(name, /^port-(\d+)\.json$/);
|
|
31042
31115
|
if (pid === void 0 || pid === self || !alive(pid)) continue;
|
|
31043
|
-
const path5 =
|
|
31116
|
+
const path5 = join13(dir, name);
|
|
31044
31117
|
const port = await readProcessRecord(path5, pid);
|
|
31045
31118
|
if (port.kind === "gone") continue;
|
|
31119
|
+
if (await staleRecord(path5, port, boot, false)) continue;
|
|
31046
31120
|
const version = port.kind === "ok" ? port.version : "unknown";
|
|
31047
31121
|
const order = compareVersions(version, options.currentVersion);
|
|
31048
31122
|
if (order === void 0 || order < 0)
|
|
@@ -31055,9 +31129,13 @@ async function versionFenceOpen(options) {
|
|
|
31055
31129
|
blockers: [...blockers.values()].sort((a, b) => rank(a) - rank(b))
|
|
31056
31130
|
};
|
|
31057
31131
|
}
|
|
31132
|
+
var log5, BOOT_TIME_MARGIN_MS;
|
|
31058
31133
|
var init_version_fence = __esm({
|
|
31059
31134
|
"src/version-fence.ts"() {
|
|
31060
31135
|
"use strict";
|
|
31136
|
+
init_logger4();
|
|
31137
|
+
log5 = createLogger4("version-fence");
|
|
31138
|
+
BOOT_TIME_MARGIN_MS = 3e5;
|
|
31061
31139
|
}
|
|
31062
31140
|
});
|
|
31063
31141
|
|
|
@@ -31088,10 +31166,10 @@ import {
|
|
|
31088
31166
|
readFile as readFile12,
|
|
31089
31167
|
rename as rename10,
|
|
31090
31168
|
rmdir as rmdir2,
|
|
31091
|
-
stat as
|
|
31092
|
-
unlink as
|
|
31169
|
+
stat as stat10,
|
|
31170
|
+
unlink as unlink10
|
|
31093
31171
|
} from "node:fs/promises";
|
|
31094
|
-
import { basename as basename4, dirname as dirname15, join as
|
|
31172
|
+
import { basename as basename4, dirname as dirname15, join as join14, resolve as resolve15 } from "node:path";
|
|
31095
31173
|
function refusalMessage(stateDir, errorClass2) {
|
|
31096
31174
|
if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
|
|
31097
31175
|
return `antigravity-auth cannot start: ${stateDir} is not a folder only your user can access, or it is a link, so the plugin will not use it (${errorClass2}). Replace it with a plain folder of your own, then restart OpenCode.`;
|
|
@@ -31144,10 +31222,10 @@ function errorFile(error) {
|
|
|
31144
31222
|
...typeof stage === "string" && stage ? { stage } : {}
|
|
31145
31223
|
};
|
|
31146
31224
|
}
|
|
31147
|
-
function logCleanupFailure(location,
|
|
31225
|
+
function logCleanupFailure(location, log17, step, error) {
|
|
31148
31226
|
logOnce(
|
|
31149
31227
|
`${location.key}\0cleanup`,
|
|
31150
|
-
() =>
|
|
31228
|
+
() => log17.warn(
|
|
31151
31229
|
"antigravity-auth could not finish removing its old vault files from OpenCode's config folder; it tries again at the next start",
|
|
31152
31230
|
{
|
|
31153
31231
|
configDir: location.configDir,
|
|
@@ -31176,13 +31254,13 @@ function prepareRuntimeLayout(options) {
|
|
|
31176
31254
|
return run;
|
|
31177
31255
|
}
|
|
31178
31256
|
async function decide(location, options) {
|
|
31179
|
-
const
|
|
31257
|
+
const log17 = options.log ?? createLogger4("runtime-layout");
|
|
31180
31258
|
const stateDir = location.stateHomeDir;
|
|
31181
|
-
const markerPath =
|
|
31259
|
+
const markerPath = join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
|
|
31182
31260
|
const files = layoutFiles(location, options.accountFile);
|
|
31183
31261
|
const fence = options.fence ?? defaultFence(options.version);
|
|
31184
31262
|
const stateHome = async () => {
|
|
31185
|
-
await settleVault(location, options, "state-home",
|
|
31263
|
+
await settleVault(location, options, "state-home", log17);
|
|
31186
31264
|
return "state-home";
|
|
31187
31265
|
};
|
|
31188
31266
|
let marker = await readMarker(markerPath, stateDir, files.vault.old);
|
|
@@ -31190,10 +31268,10 @@ async function decide(location, options) {
|
|
|
31190
31268
|
if (marker?.oldFilesRemoved) {
|
|
31191
31269
|
await refuseReappearedFiles(location, files);
|
|
31192
31270
|
const manifestLeft = await exists2(
|
|
31193
|
-
|
|
31271
|
+
join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
|
|
31194
31272
|
).catch(() => true);
|
|
31195
31273
|
if (!manifestLeft) {
|
|
31196
|
-
await settleVault(location, options, "state-home",
|
|
31274
|
+
await settleVault(location, options, "state-home", log17);
|
|
31197
31275
|
return stateHome();
|
|
31198
31276
|
}
|
|
31199
31277
|
}
|
|
@@ -31205,7 +31283,7 @@ async function decide(location, options) {
|
|
|
31205
31283
|
RUNTIME_LAYOUT_LOCK_NAME,
|
|
31206
31284
|
markerPath,
|
|
31207
31285
|
options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
|
|
31208
|
-
|
|
31286
|
+
log17
|
|
31209
31287
|
);
|
|
31210
31288
|
} catch (error) {
|
|
31211
31289
|
marker = await readMarker(markerPath, stateDir, files.vault.old);
|
|
@@ -31225,7 +31303,7 @@ async function decide(location, options) {
|
|
|
31225
31303
|
const legacy = async () => {
|
|
31226
31304
|
try {
|
|
31227
31305
|
await lock.assertOwned();
|
|
31228
|
-
await settleVault(location, options, "legacy",
|
|
31306
|
+
await settleVault(location, options, "legacy", log17);
|
|
31229
31307
|
} catch (error) {
|
|
31230
31308
|
throw new RuntimeLayoutRefusal(stateDir, errorClass(error));
|
|
31231
31309
|
}
|
|
@@ -31239,20 +31317,20 @@ async function decide(location, options) {
|
|
|
31239
31317
|
if (!marker.oldFilesRemoved && !aliased)
|
|
31240
31318
|
await finishOldFiles(location, files, markerPath, marker, lock, {
|
|
31241
31319
|
fence,
|
|
31242
|
-
log:
|
|
31320
|
+
log: log17,
|
|
31243
31321
|
steps: options.steps,
|
|
31244
31322
|
oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile()
|
|
31245
31323
|
});
|
|
31246
31324
|
else if (marker.oldFilesRemoved) {
|
|
31247
31325
|
await refuseReappearedFiles(location, files);
|
|
31248
|
-
await removeLeftoverManifest(location, lock, options.steps,
|
|
31326
|
+
await removeLeftoverManifest(location, lock, options.steps, log17);
|
|
31249
31327
|
}
|
|
31250
31328
|
return await stateHome();
|
|
31251
31329
|
}
|
|
31252
31330
|
if (aliased) {
|
|
31253
31331
|
logOnce(
|
|
31254
31332
|
`${location.key}\0aliased`,
|
|
31255
|
-
() =>
|
|
31333
|
+
() => log17.warn(
|
|
31256
31334
|
"antigravity-auth keeps its vault files in OpenCode's config folder: its state folder is that same folder",
|
|
31257
31335
|
{ configDir: location.configDir, stateDir }
|
|
31258
31336
|
)
|
|
@@ -31261,14 +31339,14 @@ async function decide(location, options) {
|
|
|
31261
31339
|
}
|
|
31262
31340
|
const gate = await fence();
|
|
31263
31341
|
if (!gate.open) {
|
|
31264
|
-
logDeferral(location, gate.blockers,
|
|
31342
|
+
logDeferral(location, gate.blockers, log17);
|
|
31265
31343
|
return await legacy();
|
|
31266
31344
|
}
|
|
31267
31345
|
let markerStarted = false;
|
|
31268
31346
|
try {
|
|
31269
31347
|
const outcome = await moveFiles(location, files, markerPath, lock, {
|
|
31270
31348
|
fence,
|
|
31271
|
-
log:
|
|
31349
|
+
log: log17,
|
|
31272
31350
|
steps: options.steps,
|
|
31273
31351
|
destinationPrivate: options.destinationPrivate ?? defaultDestinationPrivate,
|
|
31274
31352
|
oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile(),
|
|
@@ -31277,13 +31355,13 @@ async function decide(location, options) {
|
|
|
31277
31355
|
}
|
|
31278
31356
|
});
|
|
31279
31357
|
if (outcome.kind === "deferred") {
|
|
31280
|
-
logDeferral(location, outcome.blockers,
|
|
31358
|
+
logDeferral(location, outcome.blockers, log17);
|
|
31281
31359
|
return await legacy();
|
|
31282
31360
|
}
|
|
31283
31361
|
if (outcome.kind === "refused") {
|
|
31284
31362
|
logOnce(
|
|
31285
31363
|
`${location.key}\0refused`,
|
|
31286
|
-
() =>
|
|
31364
|
+
() => log17.warn(
|
|
31287
31365
|
outcome.reason === "destination-not-private" ? "antigravity-auth keeps its vault files in OpenCode's config folder: the vault folder in its state folder already exists and is not private to your user. It was left unchanged; remove it if it holds nothing you need, then restart OpenCode." : "antigravity-auth keeps its vault files in OpenCode's config folder: it will not move them",
|
|
31288
31366
|
{ reason: outcome.reason, paths: outcome.paths, stateDir }
|
|
31289
31367
|
)
|
|
@@ -31291,7 +31369,7 @@ async function decide(location, options) {
|
|
|
31291
31369
|
return await legacy();
|
|
31292
31370
|
}
|
|
31293
31371
|
if (outcome.moved)
|
|
31294
|
-
|
|
31372
|
+
log17.info(
|
|
31295
31373
|
"antigravity-auth moved its vault files out of OpenCode's config folder",
|
|
31296
31374
|
{ from: files.vault.old, to: files.vault.next }
|
|
31297
31375
|
);
|
|
@@ -31302,7 +31380,7 @@ async function decide(location, options) {
|
|
|
31302
31380
|
return await stateHome();
|
|
31303
31381
|
logOnce(
|
|
31304
31382
|
`${location.key}\0failed`,
|
|
31305
|
-
() =>
|
|
31383
|
+
() => log17.warn(
|
|
31306
31384
|
"antigravity-auth's vault files stay in OpenCode's config folder: moving them failed; the move is tried again at the next start",
|
|
31307
31385
|
{
|
|
31308
31386
|
configDir: location.configDir,
|
|
@@ -31331,8 +31409,12 @@ async function settleVault(location, options, layout, _log) {
|
|
|
31331
31409
|
}
|
|
31332
31410
|
async function localAccountStoreAuthorized() {
|
|
31333
31411
|
const location = runtimeLayoutLocation();
|
|
31412
|
+
const folder = process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR ? (await Promise.resolve().then(() => (init_vault_folder(), vault_folder_exports))).currentVaultFolder(
|
|
31413
|
+
accountFileForVault(location.configDir)
|
|
31414
|
+
) : void 0;
|
|
31415
|
+
if (folder?.refusal) return false;
|
|
31334
31416
|
const claustrum = await loadCommonAuthClaustrum();
|
|
31335
|
-
const vaultDir = decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
|
|
31417
|
+
const vaultDir = folder ? folder.vaultDir : decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
|
|
31336
31418
|
return await enrollmentAuthority2(
|
|
31337
31419
|
claustrum.hostEnrollmentPaths({
|
|
31338
31420
|
stateDir: vaultDir,
|
|
@@ -31347,7 +31429,7 @@ async function prepareAccountStore(options) {
|
|
|
31347
31429
|
if (!await localAccountStoreAuthorized()) return void 0;
|
|
31348
31430
|
const decided = decidedAccountStoreAnchor(location);
|
|
31349
31431
|
if (decided) return decided;
|
|
31350
|
-
const
|
|
31432
|
+
const log17 = options.log ?? createLogger4("runtime-layout");
|
|
31351
31433
|
const runKey = `${location.stateHomeDir}\0${location.key}`;
|
|
31352
31434
|
let run = processState.storeRuns.get(runKey);
|
|
31353
31435
|
if (!run) {
|
|
@@ -31356,14 +31438,14 @@ async function prepareAccountStore(options) {
|
|
|
31356
31438
|
await ensureOwnerOnlyDir(location.stateHomeDir);
|
|
31357
31439
|
const lock = await takeLock(
|
|
31358
31440
|
RUNTIME_LAYOUT_LOCK_NAME,
|
|
31359
|
-
|
|
31441
|
+
join14(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
31360
31442
|
options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
|
|
31361
|
-
|
|
31443
|
+
log17
|
|
31362
31444
|
);
|
|
31363
31445
|
try {
|
|
31364
31446
|
await lock.assertOwned();
|
|
31365
31447
|
if (!await localAccountStoreAuthorized()) return void 0;
|
|
31366
|
-
return await settleAccountStore(location, options,
|
|
31448
|
+
return await settleAccountStore(location, options, log17);
|
|
31367
31449
|
} finally {
|
|
31368
31450
|
await lock.release();
|
|
31369
31451
|
}
|
|
@@ -31374,20 +31456,20 @@ async function prepareAccountStore(options) {
|
|
|
31374
31456
|
}
|
|
31375
31457
|
return run;
|
|
31376
31458
|
}
|
|
31377
|
-
async function settleAccountStore(location, options,
|
|
31459
|
+
async function settleAccountStore(location, options, log17) {
|
|
31378
31460
|
const decided = decidedAccountStoreAnchor(location);
|
|
31379
31461
|
if (decided) return decided;
|
|
31380
|
-
const anchor = await decideAccountStore(location, options,
|
|
31462
|
+
const anchor = await decideAccountStore(location, options, log17);
|
|
31381
31463
|
setAccountStoreAnchor(location, anchor);
|
|
31382
31464
|
return anchor;
|
|
31383
31465
|
}
|
|
31384
|
-
async function decideAccountStore(location, options,
|
|
31385
|
-
const keepConfig = () => recordAnchor(location, options, "config",
|
|
31466
|
+
async function decideAccountStore(location, options, log17) {
|
|
31467
|
+
const keepConfig = () => recordAnchor(location, options, "config", log17);
|
|
31386
31468
|
if (processHasOlderGeneration()) {
|
|
31387
31469
|
logOnce(
|
|
31388
31470
|
"older-generation-account-store",
|
|
31389
31471
|
() => showLog(
|
|
31390
|
-
|
|
31472
|
+
log17,
|
|
31391
31473
|
"antigravity-auth keeps the account store in OpenCode's config folder until OpenCode restarts, because an older version of the plugin ran in this process.",
|
|
31392
31474
|
{ accountStore: "config" }
|
|
31393
31475
|
)
|
|
@@ -31401,7 +31483,7 @@ async function decideAccountStore(location, options, log16) {
|
|
|
31401
31483
|
if (!sameSpelling(forward.legacyPath, stateAnchor)) {
|
|
31402
31484
|
logOnce(
|
|
31403
31485
|
`${location.key}\0store-forward-elsewhere`,
|
|
31404
|
-
() =>
|
|
31486
|
+
() => log17.warn(
|
|
31405
31487
|
"the account store moved to another folder than this process resolved; check XDG_STATE_HOME",
|
|
31406
31488
|
{ movedTo: forward.legacyPath, expected: stateAnchor }
|
|
31407
31489
|
)
|
|
@@ -31412,9 +31494,9 @@ async function decideAccountStore(location, options, log16) {
|
|
|
31412
31494
|
options,
|
|
31413
31495
|
configAnchor,
|
|
31414
31496
|
stateAnchor,
|
|
31415
|
-
|
|
31497
|
+
log17
|
|
31416
31498
|
);
|
|
31417
|
-
return recordAnchor(location, options, "state-home",
|
|
31499
|
+
return recordAnchor(location, options, "state-home", log17);
|
|
31418
31500
|
}
|
|
31419
31501
|
if (decidedRuntimeLayout(location) === "legacy") return keepConfig();
|
|
31420
31502
|
const configStore = await presentAccountStore(configAnchor);
|
|
@@ -31426,9 +31508,9 @@ async function decideAccountStore(location, options, log16) {
|
|
|
31426
31508
|
`antigravity-auth cannot start: two account stores exist, one at ${configAnchor} and one at ${stateAnchor}, and neither is marked as moved. Keep the one you want and move the other one aside, then restart OpenCode.`
|
|
31427
31509
|
);
|
|
31428
31510
|
}
|
|
31429
|
-
if (stateStore) return recordAnchor(location, options, "state-home",
|
|
31511
|
+
if (stateStore) return recordAnchor(location, options, "state-home", log17);
|
|
31430
31512
|
if (configStore) {
|
|
31431
|
-
if (!await storeMovePathResolves(stateAnchor, location,
|
|
31513
|
+
if (!await storeMovePathResolves(stateAnchor, location, log17))
|
|
31432
31514
|
return keepConfig();
|
|
31433
31515
|
return moveStore(
|
|
31434
31516
|
location,
|
|
@@ -31436,21 +31518,21 @@ async function decideAccountStore(location, options, log16) {
|
|
|
31436
31518
|
configAnchor,
|
|
31437
31519
|
stateAnchor,
|
|
31438
31520
|
false,
|
|
31439
|
-
|
|
31521
|
+
log17,
|
|
31440
31522
|
false
|
|
31441
31523
|
);
|
|
31442
31524
|
}
|
|
31443
|
-
if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor,
|
|
31525
|
+
if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log17))
|
|
31444
31526
|
return keepConfig();
|
|
31445
|
-
if (!await storeMovePathResolves(stateAnchor, location,
|
|
31527
|
+
if (!await storeMovePathResolves(stateAnchor, location, log17))
|
|
31446
31528
|
return keepConfig();
|
|
31447
|
-
return initializeStore(location, options, stateAnchor,
|
|
31529
|
+
return initializeStore(location, options, stateAnchor, log17);
|
|
31448
31530
|
}
|
|
31449
|
-
function showLog(
|
|
31450
|
-
if (
|
|
31451
|
-
else
|
|
31531
|
+
function showLog(log17, message, meta) {
|
|
31532
|
+
if (log17.log) log17.log(message, meta);
|
|
31533
|
+
else log17.info(message, meta);
|
|
31452
31534
|
}
|
|
31453
|
-
async function recordAnchor(location, options, anchor,
|
|
31535
|
+
async function recordAnchor(location, options, anchor, log17) {
|
|
31454
31536
|
try {
|
|
31455
31537
|
await recordProcessAnchor({
|
|
31456
31538
|
key: location.key,
|
|
@@ -31462,32 +31544,32 @@ async function recordAnchor(location, options, anchor, log16) {
|
|
|
31462
31544
|
}
|
|
31463
31545
|
if (anchor === "state-home")
|
|
31464
31546
|
showLog(
|
|
31465
|
-
|
|
31547
|
+
log17,
|
|
31466
31548
|
"antigravity-auth keeps its account store in its state folder",
|
|
31467
31549
|
{ accountStore: anchor }
|
|
31468
31550
|
);
|
|
31469
31551
|
return anchor;
|
|
31470
31552
|
}
|
|
31471
|
-
async function storeMovePathResolves(stateAnchor, location,
|
|
31553
|
+
async function storeMovePathResolves(stateAnchor, location, log17) {
|
|
31472
31554
|
if (folderResolvesToItself(
|
|
31473
|
-
|
|
31555
|
+
join14(location.stateHomeDir, "antigravity-accounts.json")
|
|
31474
31556
|
))
|
|
31475
31557
|
return true;
|
|
31476
31558
|
logOnce(
|
|
31477
31559
|
`${location.key}\0store-linked-path`,
|
|
31478
|
-
() =>
|
|
31560
|
+
() => log17.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
|
|
31479
31561
|
accountStore: stateAnchor,
|
|
31480
31562
|
stateFolder: location.stateHomeDir
|
|
31481
31563
|
})
|
|
31482
31564
|
);
|
|
31483
31565
|
return false;
|
|
31484
31566
|
}
|
|
31485
|
-
async function storeFenceOpen(location, options,
|
|
31567
|
+
async function storeFenceOpen(location, options, log17) {
|
|
31486
31568
|
const gate = await (options.storeFence ?? defaultStoreFence(options.version))();
|
|
31487
31569
|
if (gate.open) return true;
|
|
31488
31570
|
logOnce(
|
|
31489
31571
|
`${location.key}\0store-version-fence`,
|
|
31490
|
-
() =>
|
|
31572
|
+
() => log17.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
|
|
31491
31573
|
configDir: location.configDir,
|
|
31492
31574
|
blockers: gate.blockers
|
|
31493
31575
|
})
|
|
@@ -31514,7 +31596,7 @@ async function storeArtefacts(anchor) {
|
|
|
31514
31596
|
(name) => name === store || name.startsWith(`${pool}.store.`) || name.startsWith(pool) && name.endsWith(".tmp")
|
|
31515
31597
|
).length;
|
|
31516
31598
|
}
|
|
31517
|
-
async function abandonUnpublishedStore(location, stateAnchor,
|
|
31599
|
+
async function abandonUnpublishedStore(location, stateAnchor, log17) {
|
|
31518
31600
|
const store = await loadCommonAuthStoreModules();
|
|
31519
31601
|
const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
|
|
31520
31602
|
if (binding.status === "bound") return false;
|
|
@@ -31523,9 +31605,9 @@ async function abandonUnpublishedStore(location, stateAnchor, log16) {
|
|
|
31523
31605
|
await rename10(folder, archived).catch((error) => {
|
|
31524
31606
|
if (error.code !== "ENOENT") throw error;
|
|
31525
31607
|
});
|
|
31526
|
-
await
|
|
31608
|
+
await unlink10(accountStorePointerPath(stateAnchor)).catch(() => {
|
|
31527
31609
|
});
|
|
31528
|
-
|
|
31610
|
+
log17.info(
|
|
31529
31611
|
"antigravity-auth set an unfinished account store aside before starting its move again",
|
|
31530
31612
|
{ configDir: location.configDir, archived }
|
|
31531
31613
|
);
|
|
@@ -31547,9 +31629,9 @@ async function runStoreMove(input2) {
|
|
|
31547
31629
|
return { status: "pending", reason: outcome.reason };
|
|
31548
31630
|
return { status: "cancelled" };
|
|
31549
31631
|
}
|
|
31550
|
-
async function moveStore(location, options, source, target, back,
|
|
31551
|
-
const keepConfig = () => recordAnchor(location, options, "config",
|
|
31552
|
-
if (!await storeFenceOpen(location, options,
|
|
31632
|
+
async function moveStore(location, options, source, target, back, log17, forwarded) {
|
|
31633
|
+
const keepConfig = () => recordAnchor(location, options, "config", log17);
|
|
31634
|
+
if (!await storeFenceOpen(location, options, log17)) return keepConfig();
|
|
31553
31635
|
try {
|
|
31554
31636
|
const result = await (options.relocate ?? runStoreMove)({
|
|
31555
31637
|
source,
|
|
@@ -31559,7 +31641,7 @@ async function moveStore(location, options, source, target, back, log16, forward
|
|
|
31559
31641
|
if (result.status !== "completed") {
|
|
31560
31642
|
logOnce(
|
|
31561
31643
|
`${location.key}\0store-move-unfinished`,
|
|
31562
|
-
() =>
|
|
31644
|
+
() => log17.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
|
|
31563
31645
|
configDir: location.configDir,
|
|
31564
31646
|
reason: result.status === "pending" ? result.reason : result.status
|
|
31565
31647
|
})
|
|
@@ -31567,14 +31649,14 @@ async function moveStore(location, options, source, target, back, log16, forward
|
|
|
31567
31649
|
return forwarded ? "state-home" : keepConfig();
|
|
31568
31650
|
}
|
|
31569
31651
|
showLog(
|
|
31570
|
-
|
|
31652
|
+
log17,
|
|
31571
31653
|
"antigravity-auth moved the account store out of OpenCode's config folder",
|
|
31572
31654
|
{ from: source, to: target, generation: result.id }
|
|
31573
31655
|
);
|
|
31574
31656
|
} catch (error) {
|
|
31575
31657
|
logOnce(
|
|
31576
31658
|
`${location.key}\0store-move-failed`,
|
|
31577
|
-
() =>
|
|
31659
|
+
() => log17.warn(
|
|
31578
31660
|
"antigravity-auth's account store stays in OpenCode's config folder: moving it failed; the move is tried again at the next start",
|
|
31579
31661
|
{
|
|
31580
31662
|
configDir: location.configDir,
|
|
@@ -31585,9 +31667,9 @@ async function moveStore(location, options, source, target, back, log16, forward
|
|
|
31585
31667
|
);
|
|
31586
31668
|
return forwarded ? "state-home" : keepConfig();
|
|
31587
31669
|
}
|
|
31588
|
-
return recordAnchor(location, options, "state-home",
|
|
31670
|
+
return recordAnchor(location, options, "state-home", log17);
|
|
31589
31671
|
}
|
|
31590
|
-
async function resumeForwardedStore(location, options, configAnchor, stateAnchor,
|
|
31672
|
+
async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log17) {
|
|
31591
31673
|
const store = await loadCommonAuthStoreModules();
|
|
31592
31674
|
const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
|
|
31593
31675
|
if (binding.status === "bound") return;
|
|
@@ -31598,13 +31680,13 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
|
|
|
31598
31680
|
configAnchor,
|
|
31599
31681
|
stateAnchor,
|
|
31600
31682
|
false,
|
|
31601
|
-
|
|
31683
|
+
log17,
|
|
31602
31684
|
true
|
|
31603
31685
|
);
|
|
31604
31686
|
} catch (error) {
|
|
31605
31687
|
logOnce(
|
|
31606
31688
|
`${location.key}\0store-resume-failed`,
|
|
31607
|
-
() =>
|
|
31689
|
+
() => log17.warn(
|
|
31608
31690
|
"antigravity-auth's account store is still moving; it could not be finished at this start",
|
|
31609
31691
|
{
|
|
31610
31692
|
configDir: location.configDir,
|
|
@@ -31615,9 +31697,9 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
|
|
|
31615
31697
|
);
|
|
31616
31698
|
}
|
|
31617
31699
|
}
|
|
31618
|
-
async function initializeStore(location, options, stateAnchor,
|
|
31619
|
-
const keepConfig = () => recordAnchor(location, options, "config",
|
|
31620
|
-
if (!await storeFenceOpen(location, options,
|
|
31700
|
+
async function initializeStore(location, options, stateAnchor, log17) {
|
|
31701
|
+
const keepConfig = () => recordAnchor(location, options, "config", log17);
|
|
31702
|
+
if (!await storeFenceOpen(location, options, log17)) return keepConfig();
|
|
31621
31703
|
try {
|
|
31622
31704
|
const store = await loadCommonAuthStoreModules();
|
|
31623
31705
|
const created = await initializeFreshAccountStore(store, {
|
|
@@ -31630,7 +31712,7 @@ async function initializeStore(location, options, stateAnchor, log16) {
|
|
|
31630
31712
|
} catch (error) {
|
|
31631
31713
|
logOnce(
|
|
31632
31714
|
`${location.key}\0store-init-failed`,
|
|
31633
|
-
() =>
|
|
31715
|
+
() => log17.warn(
|
|
31634
31716
|
"antigravity-auth's account store stays in OpenCode's config folder: creating it in its state folder failed; it is tried again at the next start",
|
|
31635
31717
|
{
|
|
31636
31718
|
configDir: location.configDir,
|
|
@@ -31642,13 +31724,13 @@ async function initializeStore(location, options, stateAnchor, log16) {
|
|
|
31642
31724
|
return keepConfig();
|
|
31643
31725
|
}
|
|
31644
31726
|
showLog(
|
|
31645
|
-
|
|
31727
|
+
log17,
|
|
31646
31728
|
"antigravity-auth created its account store in its state folder",
|
|
31647
31729
|
{
|
|
31648
31730
|
accountStore: stateAnchor
|
|
31649
31731
|
}
|
|
31650
31732
|
);
|
|
31651
|
-
return recordAnchor(location, options, "state-home",
|
|
31733
|
+
return recordAnchor(location, options, "state-home", log17);
|
|
31652
31734
|
}
|
|
31653
31735
|
async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacyAccountFile(runtimeLayoutLocation().configDir)) {
|
|
31654
31736
|
const forward = {
|
|
@@ -31663,10 +31745,10 @@ async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacy
|
|
|
31663
31745
|
durability: "file-only-on-windows"
|
|
31664
31746
|
});
|
|
31665
31747
|
}
|
|
31666
|
-
function logDeferral(location, blockers,
|
|
31748
|
+
function logDeferral(location, blockers, log17) {
|
|
31667
31749
|
logOnce(
|
|
31668
31750
|
`${location.key}\0deferred`,
|
|
31669
|
-
() =>
|
|
31751
|
+
() => log17.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
|
|
31670
31752
|
configDir: location.configDir,
|
|
31671
31753
|
blockers
|
|
31672
31754
|
})
|
|
@@ -31715,7 +31797,7 @@ async function moveFiles(location, files, markerPath, layoutLock, input2) {
|
|
|
31715
31797
|
for (const path5 of listed) {
|
|
31716
31798
|
if (wanted.has(path5)) continue;
|
|
31717
31799
|
await layoutLock.assertOwned();
|
|
31718
|
-
await
|
|
31800
|
+
await unlink10(path5).catch((error) => {
|
|
31719
31801
|
if (error.code !== "ENOENT") throw error;
|
|
31720
31802
|
});
|
|
31721
31803
|
}
|
|
@@ -31824,13 +31906,13 @@ async function finishOldFiles(location, files, markerPath, marker, layoutLock, i
|
|
|
31824
31906
|
if (done) await removeOldVaultFolder(files, layoutLock, input2.steps);
|
|
31825
31907
|
}
|
|
31826
31908
|
}
|
|
31827
|
-
async function removeLeftoverManifest(location, layoutLock, steps,
|
|
31909
|
+
async function removeLeftoverManifest(location, layoutLock, steps, log17) {
|
|
31828
31910
|
try {
|
|
31829
31911
|
await removeManifestOwned(location.stateHomeDir, layoutLock, steps);
|
|
31830
31912
|
} catch (error) {
|
|
31831
31913
|
logOnce(
|
|
31832
31914
|
`${location.key}\0manifest`,
|
|
31833
|
-
() =>
|
|
31915
|
+
() => log17.warn(
|
|
31834
31916
|
`antigravity-auth could not remove ${RUNTIME_LAYOUT_MANIFEST_FILE} from its state folder; it tries again at the next start`,
|
|
31835
31917
|
{ stateDir: location.stateHomeDir, errorClass: errorClass(error) }
|
|
31836
31918
|
)
|
|
@@ -31838,7 +31920,7 @@ async function removeLeftoverManifest(location, layoutLock, steps, log16) {
|
|
|
31838
31920
|
}
|
|
31839
31921
|
}
|
|
31840
31922
|
async function removeManifestOwned(stateDir, layoutLock, steps) {
|
|
31841
|
-
const path5 =
|
|
31923
|
+
const path5 = join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE);
|
|
31842
31924
|
if (!await exists2(path5)) return;
|
|
31843
31925
|
await beforeRemove(path5, layoutLock, steps);
|
|
31844
31926
|
await removeManifest(stateDir);
|
|
@@ -31850,16 +31932,16 @@ async function removeOldVaultFolder(files, layoutLock, steps) {
|
|
|
31850
31932
|
} catch {
|
|
31851
31933
|
}
|
|
31852
31934
|
}
|
|
31853
|
-
async function removeOldSignatureCache(location, path5, layoutLock, steps,
|
|
31935
|
+
async function removeOldSignatureCache(location, path5, layoutLock, steps, log17) {
|
|
31854
31936
|
try {
|
|
31855
31937
|
if (!await exists2(path5)) return;
|
|
31856
31938
|
await beforeRemove(path5, layoutLock, steps);
|
|
31857
|
-
await
|
|
31939
|
+
await unlink10(path5);
|
|
31858
31940
|
} catch (error) {
|
|
31859
31941
|
if (error?.code === "ENOENT") return;
|
|
31860
31942
|
logOnce(
|
|
31861
31943
|
`${location.key}\0signature-cache`,
|
|
31862
|
-
() =>
|
|
31944
|
+
() => log17.warn(
|
|
31863
31945
|
"antigravity-auth could not remove its old signature cache from OpenCode's config folder; it is no longer used and can be deleted",
|
|
31864
31946
|
{ path: path5, errorClass: errorClass(error) }
|
|
31865
31947
|
)
|
|
@@ -31870,7 +31952,7 @@ async function beforeRemove(path5, layoutLock, steps) {
|
|
|
31870
31952
|
await steps?.beforeRemove?.(path5);
|
|
31871
31953
|
await layoutLock.assertOwned();
|
|
31872
31954
|
}
|
|
31873
|
-
async function takeDataLocks(files,
|
|
31955
|
+
async function takeDataLocks(files, log17) {
|
|
31874
31956
|
const locks = [];
|
|
31875
31957
|
try {
|
|
31876
31958
|
if (await exists2(files.vault.old))
|
|
@@ -31878,9 +31960,9 @@ async function takeDataLocks(files, log16) {
|
|
|
31878
31960
|
locks.push(
|
|
31879
31961
|
await takeLock(
|
|
31880
31962
|
lock.name,
|
|
31881
|
-
|
|
31963
|
+
join14(files.vault.old, lock.file),
|
|
31882
31964
|
lock.waitMs,
|
|
31883
|
-
|
|
31965
|
+
log17
|
|
31884
31966
|
)
|
|
31885
31967
|
);
|
|
31886
31968
|
return locks;
|
|
@@ -31905,8 +31987,8 @@ function sha256(bytes) {
|
|
|
31905
31987
|
}
|
|
31906
31988
|
function vaultStateFile(files) {
|
|
31907
31989
|
return {
|
|
31908
|
-
old:
|
|
31909
|
-
next:
|
|
31990
|
+
old: join14(files.vault.old, VAULT_ENROLLMENT_STATE_FILE),
|
|
31991
|
+
next: join14(files.vault.next, VAULT_ENROLLMENT_STATE_FILE)
|
|
31910
31992
|
};
|
|
31911
31993
|
}
|
|
31912
31994
|
async function keepableVaultState(files, present6) {
|
|
@@ -31944,19 +32026,20 @@ async function isVaultShapedKeptState(files) {
|
|
|
31944
32026
|
return vaultShape && proposedName === OPENCODE_VAULT_ENROLLMENT_NAME;
|
|
31945
32027
|
}
|
|
31946
32028
|
async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
|
|
32029
|
+
if (process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR) return;
|
|
31947
32030
|
const location = runtimeLayoutLocation();
|
|
31948
32031
|
const files = layoutFiles(location, accountFile);
|
|
31949
|
-
if (
|
|
32032
|
+
if (resolve15(vaultDir) !== resolve15(files.vault.next)) return;
|
|
31950
32033
|
const stateDir = location.stateHomeDir;
|
|
31951
32034
|
const marker = await readMarker(
|
|
31952
|
-
|
|
32035
|
+
join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
31953
32036
|
stateDir,
|
|
31954
32037
|
files.vault.old
|
|
31955
32038
|
);
|
|
31956
32039
|
if (!marker?.oldDir || marker.oldDir !== location.key) return;
|
|
31957
32040
|
const leftover = vaultStateFile(files).old;
|
|
31958
32041
|
if (!await isVaultShapedKeptState(files)) return;
|
|
31959
|
-
await
|
|
32042
|
+
await unlink10(leftover).catch((error) => {
|
|
31960
32043
|
if (error.code !== "ENOENT") throw error;
|
|
31961
32044
|
});
|
|
31962
32045
|
await rmdir2(files.vault.old).catch(() => {
|
|
@@ -31978,13 +32061,13 @@ async function vaultFiles(dir) {
|
|
|
31978
32061
|
}
|
|
31979
32062
|
async function presentOldFiles(files) {
|
|
31980
32063
|
return (await vaultFiles(files.vault.old)).map((name) => ({
|
|
31981
|
-
old:
|
|
31982
|
-
next:
|
|
32064
|
+
old: join14(files.vault.old, name),
|
|
32065
|
+
next: join14(files.vault.next, name)
|
|
31983
32066
|
}));
|
|
31984
32067
|
}
|
|
31985
32068
|
async function destinationFiles(files) {
|
|
31986
32069
|
return (await vaultFiles(files.vault.next)).map(
|
|
31987
|
-
(name) =>
|
|
32070
|
+
(name) => join14(files.vault.next, name)
|
|
31988
32071
|
);
|
|
31989
32072
|
}
|
|
31990
32073
|
async function physicalAliases(location, files) {
|
|
@@ -31993,7 +32076,7 @@ async function physicalAliases(location, files) {
|
|
|
31993
32076
|
[files.vault.old, files.vault.next]
|
|
31994
32077
|
];
|
|
31995
32078
|
for (const name of VAULT_FILE_NAMES)
|
|
31996
|
-
pairs.push([
|
|
32079
|
+
pairs.push([join14(files.vault.old, name), join14(files.vault.next, name)]);
|
|
31997
32080
|
const aliased = [];
|
|
31998
32081
|
for (const [old, next] of pairs)
|
|
31999
32082
|
if (await samePhysical(old, next)) aliased.push(old);
|
|
@@ -32002,7 +32085,7 @@ async function physicalAliases(location, files) {
|
|
|
32002
32085
|
async function samePhysical(a, b) {
|
|
32003
32086
|
const id = async (path5) => {
|
|
32004
32087
|
try {
|
|
32005
|
-
const info = await
|
|
32088
|
+
const info = await stat10(path5, { bigint: true });
|
|
32006
32089
|
return info.ino === 0n ? void 0 : `${info.dev}:${info.ino}`;
|
|
32007
32090
|
} catch (error) {
|
|
32008
32091
|
const code2 = error.code;
|
|
@@ -32092,7 +32175,7 @@ async function unlinkIfIdentical(file, stateDir, guard) {
|
|
|
32092
32175
|
if (!same) throw credentialConflict(stateDir, file);
|
|
32093
32176
|
await guard();
|
|
32094
32177
|
try {
|
|
32095
|
-
await
|
|
32178
|
+
await unlink10(file.old);
|
|
32096
32179
|
return true;
|
|
32097
32180
|
} catch (error) {
|
|
32098
32181
|
if (error.code === "ENOENT") return true;
|
|
@@ -32105,11 +32188,11 @@ async function unlinkIfIdentical(file, stateDir, guard) {
|
|
|
32105
32188
|
async function refuseReappearedFiles(location, files) {
|
|
32106
32189
|
const keptState = vaultStateFile(files).old;
|
|
32107
32190
|
for (const name of await vaultFiles(files.vault.old)) {
|
|
32108
|
-
const old =
|
|
32191
|
+
const old = join14(files.vault.old, name);
|
|
32109
32192
|
if (old === keptState && await isVaultShapedKeptState(files)) continue;
|
|
32110
32193
|
throw credentialConflict(location.stateHomeDir, {
|
|
32111
32194
|
old,
|
|
32112
|
-
next:
|
|
32195
|
+
next: join14(files.vault.next, name)
|
|
32113
32196
|
});
|
|
32114
32197
|
}
|
|
32115
32198
|
}
|
|
@@ -32151,13 +32234,13 @@ async function assertOwnFolder(location, marker, files) {
|
|
|
32151
32234
|
const stateDir = location.stateHomeDir;
|
|
32152
32235
|
if (marker?.oldDir !== void 0 && marker.oldDir !== location.key)
|
|
32153
32236
|
throw foreignMarker(
|
|
32154
|
-
|
|
32237
|
+
join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
32155
32238
|
location.key,
|
|
32156
32239
|
files.vault.old
|
|
32157
32240
|
);
|
|
32158
32241
|
let text2;
|
|
32159
32242
|
try {
|
|
32160
|
-
text2 = await readFile12(
|
|
32243
|
+
text2 = await readFile12(join14(stateDir, RUNTIME_CONFIG_DIR_NOTE_FILE), "utf8");
|
|
32161
32244
|
} catch (error) {
|
|
32162
32245
|
const code2 = error.code;
|
|
32163
32246
|
if (code2 === "ENOENT" || code2 === "ENOTDIR") return;
|
|
@@ -32171,7 +32254,7 @@ async function assertOwnFolder(location, marker, files) {
|
|
|
32171
32254
|
if (owner !== location.key) throw foreignFolder(stateDir, location.key);
|
|
32172
32255
|
}
|
|
32173
32256
|
async function writeOwnerNote(location) {
|
|
32174
|
-
const path5 =
|
|
32257
|
+
const path5 = join14(location.stateHomeDir, RUNTIME_CONFIG_DIR_NOTE_FILE);
|
|
32175
32258
|
if (await exists2(path5)) return;
|
|
32176
32259
|
await writePrivateText(
|
|
32177
32260
|
path5,
|
|
@@ -32182,7 +32265,7 @@ async function writeOwnerNote(location) {
|
|
|
32182
32265
|
async function readManifest(stateDir) {
|
|
32183
32266
|
let text2;
|
|
32184
32267
|
try {
|
|
32185
|
-
text2 = await readFile12(
|
|
32268
|
+
text2 = await readFile12(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE), "utf8");
|
|
32186
32269
|
} catch (error) {
|
|
32187
32270
|
if (error.code === "ENOENT") return /* @__PURE__ */ new Set();
|
|
32188
32271
|
throw error;
|
|
@@ -32199,13 +32282,13 @@ async function readManifest(stateDir) {
|
|
|
32199
32282
|
}
|
|
32200
32283
|
async function writeManifest(stateDir, paths) {
|
|
32201
32284
|
await writePrivateText(
|
|
32202
|
-
|
|
32285
|
+
join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE),
|
|
32203
32286
|
`${JSON.stringify({ version: 1, files: paths }, null, 2)}
|
|
32204
32287
|
`
|
|
32205
32288
|
);
|
|
32206
32289
|
}
|
|
32207
32290
|
async function removeManifest(stateDir) {
|
|
32208
|
-
await
|
|
32291
|
+
await unlink10(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
|
|
32209
32292
|
(error) => {
|
|
32210
32293
|
if (error.code !== "ENOENT") throw error;
|
|
32211
32294
|
}
|
|
@@ -32229,7 +32312,7 @@ async function ensureOwnerOnlyDir(path5) {
|
|
|
32229
32312
|
await mkdir13(path5, { recursive: true, mode: 448 });
|
|
32230
32313
|
await chmod5(path5, 448);
|
|
32231
32314
|
}
|
|
32232
|
-
async function takeLock(name, path5, waitMs,
|
|
32315
|
+
async function takeLock(name, path5, waitMs, log17) {
|
|
32233
32316
|
const fs5 = await loadCommonAuthFs();
|
|
32234
32317
|
const started = performance.now();
|
|
32235
32318
|
let announced = false;
|
|
@@ -32254,7 +32337,7 @@ async function takeLock(name, path5, waitMs, log16) {
|
|
|
32254
32337
|
);
|
|
32255
32338
|
if (!announced && waited >= LOCK_WAIT_NOTICE_MS) {
|
|
32256
32339
|
announced = true;
|
|
32257
|
-
|
|
32340
|
+
log17.info(
|
|
32258
32341
|
`antigravity-auth is waiting up to ${Math.round(waitMs / 1e3)} s for the ${name} lock at ${path5}.${lockHolderText(name)}`,
|
|
32259
32342
|
{ lock: name, path: path5 }
|
|
32260
32343
|
);
|
|
@@ -32267,7 +32350,7 @@ function lockHolderText(name) {
|
|
|
32267
32350
|
}
|
|
32268
32351
|
async function exists2(path5) {
|
|
32269
32352
|
try {
|
|
32270
|
-
await
|
|
32353
|
+
await stat10(path5);
|
|
32271
32354
|
return true;
|
|
32272
32355
|
} catch (error) {
|
|
32273
32356
|
const code2 = error.code;
|
|
@@ -32374,9 +32457,9 @@ import {
|
|
|
32374
32457
|
writeFileSync
|
|
32375
32458
|
} from "node:fs";
|
|
32376
32459
|
import { homedir as homedir4 } from "node:os";
|
|
32377
|
-
import { dirname as dirname16, join as
|
|
32460
|
+
import { dirname as dirname16, join as join15, resolve as resolve16 } from "node:path";
|
|
32378
32461
|
async function ensureGitignore(configDir) {
|
|
32379
|
-
const gitignorePath =
|
|
32462
|
+
const gitignorePath = join15(configDir, ".gitignore");
|
|
32380
32463
|
try {
|
|
32381
32464
|
let content;
|
|
32382
32465
|
let existingLines = [];
|
|
@@ -32402,7 +32485,7 @@ async function ensureGitignore(configDir) {
|
|
|
32402
32485
|
`,
|
|
32403
32486
|
"utf-8"
|
|
32404
32487
|
);
|
|
32405
|
-
|
|
32488
|
+
log6.info("Created .gitignore in config directory");
|
|
32406
32489
|
} else {
|
|
32407
32490
|
const suffix = content.endsWith("\n") ? "" : "\n";
|
|
32408
32491
|
await fs.appendFile(
|
|
@@ -32411,19 +32494,19 @@ async function ensureGitignore(configDir) {
|
|
|
32411
32494
|
`,
|
|
32412
32495
|
"utf-8"
|
|
32413
32496
|
);
|
|
32414
|
-
|
|
32497
|
+
log6.info("Updated .gitignore with missing entries", {
|
|
32415
32498
|
added: missingEntries
|
|
32416
32499
|
});
|
|
32417
32500
|
}
|
|
32418
32501
|
} catch (error) {
|
|
32419
|
-
|
|
32502
|
+
log6.warn("Failed to update .gitignore with account storage entries", {
|
|
32420
32503
|
error: String(error)
|
|
32421
32504
|
});
|
|
32422
32505
|
}
|
|
32423
32506
|
}
|
|
32424
32507
|
function getLegacyWindowsConfigDir() {
|
|
32425
|
-
return
|
|
32426
|
-
process.env.APPDATA ||
|
|
32508
|
+
return join15(
|
|
32509
|
+
process.env.APPDATA || join15(homedir4(), "AppData", "Roaming"),
|
|
32427
32510
|
"opencode"
|
|
32428
32511
|
);
|
|
32429
32512
|
}
|
|
@@ -32431,15 +32514,15 @@ function getConfigDir() {
|
|
|
32431
32514
|
if (process.env.OPENCODE_CONFIG_DIR) {
|
|
32432
32515
|
return process.env.OPENCODE_CONFIG_DIR;
|
|
32433
32516
|
}
|
|
32434
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ||
|
|
32435
|
-
return
|
|
32517
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME || join15(homedir4(), ".config");
|
|
32518
|
+
return join15(xdgConfig2, "opencode");
|
|
32436
32519
|
}
|
|
32437
32520
|
function migrateLegacyWindowsConfig() {
|
|
32438
32521
|
if (process.platform !== "win32") {
|
|
32439
32522
|
return false;
|
|
32440
32523
|
}
|
|
32441
|
-
const newPath =
|
|
32442
|
-
const legacyPath =
|
|
32524
|
+
const newPath = join15(getConfigDir(), "antigravity-accounts.json");
|
|
32525
|
+
const legacyPath = join15(
|
|
32443
32526
|
getLegacyWindowsConfigDir(),
|
|
32444
32527
|
"antigravity-accounts.json"
|
|
32445
32528
|
);
|
|
@@ -32451,21 +32534,21 @@ function migrateLegacyWindowsConfig() {
|
|
|
32451
32534
|
mkdirSync(newConfigDir, { recursive: true });
|
|
32452
32535
|
try {
|
|
32453
32536
|
renameSync3(legacyPath, newPath);
|
|
32454
|
-
|
|
32537
|
+
log6.info("Migrated Windows config via rename", {
|
|
32455
32538
|
from: legacyPath,
|
|
32456
32539
|
to: newPath
|
|
32457
32540
|
});
|
|
32458
32541
|
} catch {
|
|
32459
32542
|
copyFileSync(legacyPath, newPath);
|
|
32460
32543
|
unlinkSync(legacyPath);
|
|
32461
|
-
|
|
32544
|
+
log6.info("Migrated Windows config via copy+delete", {
|
|
32462
32545
|
from: legacyPath,
|
|
32463
32546
|
to: newPath
|
|
32464
32547
|
});
|
|
32465
32548
|
}
|
|
32466
32549
|
return true;
|
|
32467
32550
|
} catch (error) {
|
|
32468
|
-
|
|
32551
|
+
log6.warn("Failed to migrate legacy Windows config, will use legacy path", {
|
|
32469
32552
|
legacyPath,
|
|
32470
32553
|
newPath,
|
|
32471
32554
|
error: String(error)
|
|
@@ -32474,8 +32557,8 @@ function migrateLegacyWindowsConfig() {
|
|
|
32474
32557
|
}
|
|
32475
32558
|
}
|
|
32476
32559
|
function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
32477
|
-
const standard =
|
|
32478
|
-
const legacy =
|
|
32560
|
+
const standard = resolve16(newPath);
|
|
32561
|
+
const legacy = resolve16(legacyPath);
|
|
32479
32562
|
if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
|
|
32480
32563
|
const standardPointer = existsSync3(accountStorePointerPath(standard));
|
|
32481
32564
|
const legacyPointer = existsSync3(accountStorePointerPath(legacy));
|
|
@@ -32489,16 +32572,16 @@ function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
|
32489
32572
|
return newPath;
|
|
32490
32573
|
}
|
|
32491
32574
|
function getStoragePathWithMigration() {
|
|
32492
|
-
const newPath =
|
|
32575
|
+
const newPath = join15(getConfigDir(), "antigravity-accounts.json");
|
|
32493
32576
|
if (process.platform === "win32") {
|
|
32494
32577
|
migrateLegacyWindowsConfig();
|
|
32495
|
-
const legacyPath =
|
|
32578
|
+
const legacyPath = join15(
|
|
32496
32579
|
getLegacyWindowsConfigDir(),
|
|
32497
32580
|
"antigravity-accounts.json"
|
|
32498
32581
|
);
|
|
32499
32582
|
const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
|
|
32500
|
-
if (
|
|
32501
|
-
|
|
32583
|
+
if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve16(anchored)))) {
|
|
32584
|
+
log6.info("Using legacy Windows config path (migration failed)", {
|
|
32502
32585
|
legacyPath,
|
|
32503
32586
|
newPath
|
|
32504
32587
|
});
|
|
@@ -32511,20 +32594,20 @@ function stateHomeStoragePath() {
|
|
|
32511
32594
|
return stateHomeAccountFile(runtimeLayoutLocation());
|
|
32512
32595
|
}
|
|
32513
32596
|
function accountFileForVault(configDir = getConfigDir()) {
|
|
32514
|
-
const configured =
|
|
32597
|
+
const configured = join15(configDir, "antigravity-accounts.json");
|
|
32515
32598
|
if (process.platform !== "win32") return configured;
|
|
32516
32599
|
const legacyDir = getLegacyWindowsConfigDir();
|
|
32517
|
-
if (
|
|
32600
|
+
if (resolve16(configDir).toLowerCase() === resolve16(legacyDir).toLowerCase())
|
|
32518
32601
|
return configured;
|
|
32519
|
-
const configuredVault =
|
|
32520
|
-
const legacyVault =
|
|
32602
|
+
const configuredVault = join15(configDir, "antigravity-auth-vault");
|
|
32603
|
+
const legacyVault = join15(legacyDir, "antigravity-auth-vault");
|
|
32521
32604
|
const configuredPresent = existsSync3(configuredVault);
|
|
32522
32605
|
const legacyPresent = existsSync3(legacyVault);
|
|
32523
32606
|
if (configuredPresent && legacyPresent)
|
|
32524
32607
|
throw new Error(
|
|
32525
32608
|
`Two vault folders exist: ${configuredVault} and ${legacyVault}. Keep one vault enrollment before restarting OpenCode.`
|
|
32526
32609
|
);
|
|
32527
|
-
return legacyPresent ?
|
|
32610
|
+
return legacyPresent ? join15(legacyDir, "antigravity-accounts.json") : configured;
|
|
32528
32611
|
}
|
|
32529
32612
|
async function prepareLocalAccountStore() {
|
|
32530
32613
|
if (!decidedRuntimeLayout(runtimeLayoutLocation())) return;
|
|
@@ -32539,13 +32622,13 @@ function getStoragePath() {
|
|
|
32539
32622
|
if (anchor === "config") return getStoragePathWithMigration();
|
|
32540
32623
|
const location = runtimeLayoutLocation();
|
|
32541
32624
|
if (decidedRuntimeLayout(location))
|
|
32542
|
-
return
|
|
32625
|
+
return join15(location.configDir, "antigravity-accounts.json");
|
|
32543
32626
|
const configPath = getStoragePathWithMigration();
|
|
32544
32627
|
return readForwardedAccountStore(configPath)?.legacyPath ?? configPath;
|
|
32545
32628
|
}
|
|
32546
32629
|
async function assertLegacyPoolInUse(legacyPath) {
|
|
32547
32630
|
try {
|
|
32548
|
-
await assertLegacyAccountStorageWritable(
|
|
32631
|
+
await assertLegacyAccountStorageWritable(resolve16(legacyPath));
|
|
32549
32632
|
} catch (error) {
|
|
32550
32633
|
throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
|
|
32551
32634
|
}
|
|
@@ -32563,7 +32646,7 @@ function refusalMessage2(admission) {
|
|
|
32563
32646
|
async function bindingOf(options) {
|
|
32564
32647
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
32565
32648
|
const now = options.now ?? (() => Date.now());
|
|
32566
|
-
const legacyPath =
|
|
32649
|
+
const legacyPath = resolve16(options.legacyPath ?? getStoragePath());
|
|
32567
32650
|
return {
|
|
32568
32651
|
legacyPath,
|
|
32569
32652
|
now,
|
|
@@ -32632,7 +32715,7 @@ async function openAccountStore(options) {
|
|
|
32632
32715
|
async function initializeFreshAccountStoreFor(modules, options = {}) {
|
|
32633
32716
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
32634
32717
|
return initializeFreshAccountStore(modules, {
|
|
32635
|
-
legacyPath:
|
|
32718
|
+
legacyPath: resolve16(options.legacyPath ?? getStoragePath()),
|
|
32636
32719
|
now: options.now ?? (() => Date.now())
|
|
32637
32720
|
});
|
|
32638
32721
|
}
|
|
@@ -32666,18 +32749,18 @@ async function clearAccounts() {
|
|
|
32666
32749
|
} catch (error) {
|
|
32667
32750
|
const code2 = error.code;
|
|
32668
32751
|
if (code2 !== "ENOENT") {
|
|
32669
|
-
|
|
32752
|
+
log6.error("Failed to clear account storage", { error: String(error) });
|
|
32670
32753
|
}
|
|
32671
32754
|
}
|
|
32672
32755
|
}
|
|
32673
|
-
var
|
|
32756
|
+
var log6, mutateAccountStorage2, GITIGNORE_ENTRIES, LegacyAccountPoolRetiredError, MIGRATE_COMMAND, UNMIGRATED_ACCOUNT_MESSAGE, ROLLBACK_COMMAND;
|
|
32674
32757
|
var init_storage = __esm({
|
|
32675
32758
|
"src/plugin/storage.ts"() {
|
|
32676
32759
|
"use strict";
|
|
32677
32760
|
init_dist();
|
|
32678
32761
|
init_runtime_paths();
|
|
32679
32762
|
init_logger4();
|
|
32680
|
-
|
|
32763
|
+
log6 = createLogger4("storage");
|
|
32681
32764
|
mutateAccountStorage2 = async (path5, mutate) => {
|
|
32682
32765
|
await assertLegacyPoolInUse(path5);
|
|
32683
32766
|
return mutateAccountStorage(path5, mutate);
|
|
@@ -32710,12 +32793,12 @@ var init_storage = __esm({
|
|
|
32710
32793
|
import { createHash as createHash12 } from "node:crypto";
|
|
32711
32794
|
import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
32712
32795
|
import { homedir as homedir5 } from "node:os";
|
|
32713
|
-
import { dirname as dirname17, join as
|
|
32796
|
+
import { dirname as dirname17, join as join16, resolve as resolve17 } from "node:path";
|
|
32714
32797
|
function configDirIdentity(path5) {
|
|
32715
32798
|
try {
|
|
32716
32799
|
return realpathSync2.native(path5);
|
|
32717
32800
|
} catch {
|
|
32718
|
-
return
|
|
32801
|
+
return resolve17(path5);
|
|
32719
32802
|
}
|
|
32720
32803
|
}
|
|
32721
32804
|
function decisionKey(location) {
|
|
@@ -32723,18 +32806,18 @@ function decisionKey(location) {
|
|
|
32723
32806
|
}
|
|
32724
32807
|
function runtimeLayoutLocation(configDir = getConfigDir()) {
|
|
32725
32808
|
const stateHome = defaultStateHome();
|
|
32726
|
-
const homeConfig =
|
|
32809
|
+
const homeConfig = join16(homedir5(), ".config", "opencode");
|
|
32727
32810
|
const cacheKey = `${configDir}\0${homeConfig}\0${stateHome}`;
|
|
32728
32811
|
const cached = shared2.locations.get(cacheKey);
|
|
32729
32812
|
if (cached && shared2.decisions.has(decisionKey(cached))) return cached;
|
|
32730
32813
|
const key = configDirIdentity(configDir);
|
|
32731
32814
|
if (cached && cached.key === key) return cached;
|
|
32732
32815
|
const isDefaultConfigDir = key === configDirIdentity(homeConfig);
|
|
32733
|
-
const root =
|
|
32816
|
+
const root = join16(stateHome, "cortexkit", "antigravity-auth");
|
|
32734
32817
|
const location = {
|
|
32735
32818
|
key,
|
|
32736
32819
|
configDir,
|
|
32737
|
-
stateHomeDir: isDefaultConfigDir ?
|
|
32820
|
+
stateHomeDir: isDefaultConfigDir ? join16(root, "opencode") : join16(
|
|
32738
32821
|
root,
|
|
32739
32822
|
`opencode-${createHash12("sha256").update(key).digest("hex").slice(0, 16)}`
|
|
32740
32823
|
),
|
|
@@ -32756,49 +32839,49 @@ function decidedAccountStoreAnchor(location) {
|
|
|
32756
32839
|
return shared2.storeAnchors.get(`${location.stateHomeDir}\0${location.key}`);
|
|
32757
32840
|
}
|
|
32758
32841
|
function currentRuntimeLayout(location = runtimeLayoutLocation()) {
|
|
32759
|
-
return decidedRuntimeLayout(location) ?? (existsSync4(
|
|
32842
|
+
return decidedRuntimeLayout(location) ?? (existsSync4(join16(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE)) ? "state-home" : "legacy");
|
|
32760
32843
|
}
|
|
32761
32844
|
function legacyWindowsConfigDir() {
|
|
32762
|
-
return
|
|
32763
|
-
process.env.APPDATA ||
|
|
32845
|
+
return join16(
|
|
32846
|
+
process.env.APPDATA || join16(homedir5(), "AppData", "Roaming"),
|
|
32764
32847
|
"opencode"
|
|
32765
32848
|
);
|
|
32766
32849
|
}
|
|
32767
32850
|
function pluginStateDir() {
|
|
32768
|
-
return
|
|
32851
|
+
return join16(defaultStateHome(), "cortexkit", "antigravity-auth");
|
|
32769
32852
|
}
|
|
32770
32853
|
function stateHomeSignatureCacheFile() {
|
|
32771
|
-
return
|
|
32854
|
+
return join16(pluginStateDir(), SIGNATURE_CACHE_FILE_NAME);
|
|
32772
32855
|
}
|
|
32773
32856
|
function legacySignatureCacheFile() {
|
|
32774
|
-
const configHome = process.platform === "win32" ? legacyWindowsConfigDir() :
|
|
32775
|
-
process.env.XDG_CONFIG_HOME ||
|
|
32857
|
+
const configHome = process.platform === "win32" ? legacyWindowsConfigDir() : join16(
|
|
32858
|
+
process.env.XDG_CONFIG_HOME || join16(homedir5(), ".config"),
|
|
32776
32859
|
"opencode"
|
|
32777
32860
|
);
|
|
32778
|
-
return
|
|
32861
|
+
return join16(configHome, SIGNATURE_CACHE_FILE_NAME);
|
|
32779
32862
|
}
|
|
32780
32863
|
function stateHomeLogsDir() {
|
|
32781
|
-
return
|
|
32864
|
+
return join16(pluginStateDir(), "logs");
|
|
32782
32865
|
}
|
|
32783
32866
|
function legacyAccountFile(configDir = getConfigDir()) {
|
|
32784
|
-
const standard =
|
|
32867
|
+
const standard = join16(configDir, ACCOUNT_FILE_NAME);
|
|
32785
32868
|
if (process.platform !== "win32") return standard;
|
|
32786
32869
|
return resolveWindowsAccountAnchor(
|
|
32787
32870
|
standard,
|
|
32788
|
-
|
|
32871
|
+
join16(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
|
|
32789
32872
|
);
|
|
32790
32873
|
}
|
|
32791
32874
|
function legacyVaultDir(accountFile) {
|
|
32792
|
-
return
|
|
32875
|
+
return join16(dirname17(accountFile), VAULT_DIR_NAME);
|
|
32793
32876
|
}
|
|
32794
32877
|
function stateHomeVaultDir(location) {
|
|
32795
|
-
return
|
|
32878
|
+
return join16(location.stateHomeDir, VAULT_DIR_NAME);
|
|
32796
32879
|
}
|
|
32797
32880
|
function accountStorePointerPath2(accountFile) {
|
|
32798
32881
|
return `${accountFile}${ACCOUNT_STORE_POINTER_SUFFIX}`;
|
|
32799
32882
|
}
|
|
32800
32883
|
function stateHomeAccountFile(location) {
|
|
32801
|
-
return
|
|
32884
|
+
return join16(realPathOrSelf(location.stateHomeDir), ACCOUNT_FILE_NAME);
|
|
32802
32885
|
}
|
|
32803
32886
|
function realPathOrSelf(path5) {
|
|
32804
32887
|
try {
|
|
@@ -33042,7 +33125,7 @@ import {
|
|
|
33042
33125
|
statSync as statSync4,
|
|
33043
33126
|
unlinkSync as unlinkSync2
|
|
33044
33127
|
} from "node:fs";
|
|
33045
|
-
import { join as
|
|
33128
|
+
import { join as join17 } from "node:path";
|
|
33046
33129
|
import { env } from "node:process";
|
|
33047
33130
|
function getLogsDir(customLogDir) {
|
|
33048
33131
|
const logsDir = customLogDir || stateHomeLogsDir();
|
|
@@ -33061,9 +33144,9 @@ function createLogFilePath(customLogDir) {
|
|
|
33061
33144
|
const logsDir = getLogsDir(requestedLogDir(customLogDir));
|
|
33062
33145
|
cleanupOldLogs(logsDir, 25);
|
|
33063
33146
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
33064
|
-
let candidate =
|
|
33147
|
+
let candidate = join17(logsDir, `antigravity-debug-${timestamp}.log`);
|
|
33065
33148
|
for (let suffix = 2; liveLogFilePaths.has(candidate); suffix++) {
|
|
33066
|
-
candidate =
|
|
33149
|
+
candidate = join17(logsDir, `antigravity-debug-${timestamp}-${suffix}.log`);
|
|
33067
33150
|
}
|
|
33068
33151
|
return candidate;
|
|
33069
33152
|
}
|
|
@@ -33071,7 +33154,7 @@ function cleanupOldLogs(logsDir, maxFiles) {
|
|
|
33071
33154
|
try {
|
|
33072
33155
|
const files = readdirSync(logsDir).filter(
|
|
33073
33156
|
(file) => file.startsWith("antigravity-debug-") && file.endsWith(".log")
|
|
33074
|
-
).map((file) =>
|
|
33157
|
+
).map((file) => join17(logsDir, file));
|
|
33075
33158
|
if (files.length <= maxFiles) {
|
|
33076
33159
|
return;
|
|
33077
33160
|
}
|
|
@@ -33168,13 +33251,13 @@ function closeDebugStream(state) {
|
|
|
33168
33251
|
state.logWriter = () => {
|
|
33169
33252
|
};
|
|
33170
33253
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
33171
|
-
return new Promise((
|
|
33172
|
-
current.once("close", () =>
|
|
33173
|
-
current.once("error", () =>
|
|
33254
|
+
return new Promise((resolve28) => {
|
|
33255
|
+
current.once("close", () => resolve28());
|
|
33256
|
+
current.once("error", () => resolve28());
|
|
33174
33257
|
try {
|
|
33175
33258
|
current.end();
|
|
33176
33259
|
} catch {
|
|
33177
|
-
|
|
33260
|
+
resolve28();
|
|
33178
33261
|
}
|
|
33179
33262
|
});
|
|
33180
33263
|
}
|
|
@@ -33439,13 +33522,13 @@ function closeDebugLog() {
|
|
|
33439
33522
|
if (!state || !current) return Promise.resolve();
|
|
33440
33523
|
state.logStream = null;
|
|
33441
33524
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
33442
|
-
return new Promise((
|
|
33443
|
-
current.once("close", () =>
|
|
33444
|
-
current.once("error", () =>
|
|
33525
|
+
return new Promise((resolve28) => {
|
|
33526
|
+
current.once("close", () => resolve28());
|
|
33527
|
+
current.once("error", () => resolve28());
|
|
33445
33528
|
try {
|
|
33446
33529
|
current.end();
|
|
33447
33530
|
} catch {
|
|
33448
|
-
|
|
33531
|
+
resolve28();
|
|
33449
33532
|
}
|
|
33450
33533
|
});
|
|
33451
33534
|
}
|
|
@@ -33621,15 +33704,15 @@ function initLogger3(client) {
|
|
|
33621
33704
|
}
|
|
33622
33705
|
function createLogger4(module) {
|
|
33623
33706
|
let channel3;
|
|
33624
|
-
const
|
|
33707
|
+
const log17 = (level, message, extra) => {
|
|
33625
33708
|
channel3 ??= getLegacyLogger().createLogger(module);
|
|
33626
33709
|
channel3[level](message, extra);
|
|
33627
33710
|
};
|
|
33628
33711
|
return {
|
|
33629
|
-
debug: (message, extra) =>
|
|
33630
|
-
info: (message, extra) =>
|
|
33631
|
-
warn: (message, extra) =>
|
|
33632
|
-
error: (message, extra) =>
|
|
33712
|
+
debug: (message, extra) => log17("debug", message, extra),
|
|
33713
|
+
info: (message, extra) => log17("info", message, extra),
|
|
33714
|
+
warn: (message, extra) => log17("warn", message, extra),
|
|
33715
|
+
error: (message, extra) => log17("error", message, extra)
|
|
33633
33716
|
};
|
|
33634
33717
|
}
|
|
33635
33718
|
var ENV_CONSOLE_LOG2, LOG_LEVEL_FROM_OPERATOR, legacyClient, legacyLogger;
|
|
@@ -33653,6 +33736,102 @@ var init_logger4 = __esm({
|
|
|
33653
33736
|
}
|
|
33654
33737
|
});
|
|
33655
33738
|
|
|
33739
|
+
// src/vault-folder.ts
|
|
33740
|
+
var vault_folder_exports = {};
|
|
33741
|
+
__export(vault_folder_exports, {
|
|
33742
|
+
__resetVaultFoldersForTest: () => __resetVaultFoldersForTest,
|
|
33743
|
+
currentVaultFolder: () => currentVaultFolder,
|
|
33744
|
+
prepareVaultFolder: () => prepareVaultFolder
|
|
33745
|
+
});
|
|
33746
|
+
import { isAbsolute as isAbsolute3 } from "node:path";
|
|
33747
|
+
function vaultOverride(accountFile) {
|
|
33748
|
+
const kept = refusals.get(overrideRefusalKey);
|
|
33749
|
+
if (kept) return { accountFile, vaultDir: kept.stateDir, refusal: kept };
|
|
33750
|
+
const vaultDir = process.env[OVERRIDE];
|
|
33751
|
+
if (!vaultDir) return void 0;
|
|
33752
|
+
if (isAbsolute3(vaultDir)) return { accountFile, vaultDir };
|
|
33753
|
+
const refusal3 = new RuntimeLayoutRefusal(
|
|
33754
|
+
vaultDir,
|
|
33755
|
+
"relative-vault-dir",
|
|
33756
|
+
`antigravity-auth cannot start: ${OVERRIDE} must be an absolute path. Correct it and restart OpenCode.`
|
|
33757
|
+
);
|
|
33758
|
+
refusals.set(overrideRefusalKey, refusal3);
|
|
33759
|
+
return { accountFile, vaultDir, refusal: refusal3 };
|
|
33760
|
+
}
|
|
33761
|
+
function locationKey() {
|
|
33762
|
+
const location = runtimeLayoutLocation();
|
|
33763
|
+
return `${location.stateHomeDir}\0${location.key}`;
|
|
33764
|
+
}
|
|
33765
|
+
function __resetVaultFoldersForTest() {
|
|
33766
|
+
refusals.clear();
|
|
33767
|
+
}
|
|
33768
|
+
async function prepareVaultFolder(options) {
|
|
33769
|
+
const { accountFile } = options;
|
|
33770
|
+
const override = vaultOverride(accountFile);
|
|
33771
|
+
if (override?.refusal) return override;
|
|
33772
|
+
const key = locationKey();
|
|
33773
|
+
const kept = refusals.get(key);
|
|
33774
|
+
if (kept)
|
|
33775
|
+
return override ? { ...override, refusal: kept } : refused(accountFile, kept);
|
|
33776
|
+
const log17 = options.log ?? createLogger4("runtime-layout");
|
|
33777
|
+
const version = options.version ?? await pluginPackageVersion().catch(() => "unknown");
|
|
33778
|
+
try {
|
|
33779
|
+
if (override) {
|
|
33780
|
+
await ensurePrivateDirectory2(override.vaultDir);
|
|
33781
|
+
} else
|
|
33782
|
+
await prepareRuntimeLayout({
|
|
33783
|
+
version,
|
|
33784
|
+
accountFile,
|
|
33785
|
+
log: log17,
|
|
33786
|
+
...options.layoutLockWaitMs === void 0 ? {} : { layoutLockWaitMs: options.layoutLockWaitMs }
|
|
33787
|
+
});
|
|
33788
|
+
if (options.accountStore !== false)
|
|
33789
|
+
await prepareAccountStore({ version, log: log17 });
|
|
33790
|
+
} catch (error) {
|
|
33791
|
+
const refusal3 = error instanceof RuntimeLayoutRefusal ? error : new RuntimeLayoutRefusal(
|
|
33792
|
+
override?.vaultDir ?? runtimeLayoutLocation().stateHomeDir,
|
|
33793
|
+
error instanceof Error ? error.name : typeof error
|
|
33794
|
+
);
|
|
33795
|
+
if (!refusals.has(key)) {
|
|
33796
|
+
refusals.set(key, refusal3);
|
|
33797
|
+
log17.warn(refusal3.message, {
|
|
33798
|
+
stateDir: refusal3.stateDir,
|
|
33799
|
+
errorClass: refusal3.errorClass
|
|
33800
|
+
});
|
|
33801
|
+
}
|
|
33802
|
+
return override ? { ...override, refusal: refusals.get(key) ?? refusal3 } : refused(accountFile, refusals.get(key) ?? refusal3);
|
|
33803
|
+
}
|
|
33804
|
+
return override ?? { accountFile, vaultDir: getVaultDir(accountFile) };
|
|
33805
|
+
}
|
|
33806
|
+
function currentVaultFolder(accountFile) {
|
|
33807
|
+
const override = vaultOverride(accountFile);
|
|
33808
|
+
if (override?.refusal) return override;
|
|
33809
|
+
const kept = refusals.get(locationKey());
|
|
33810
|
+
return kept ? override ? { ...override, refusal: kept } : refused(accountFile, kept) : override ?? { accountFile, vaultDir: getVaultDir(accountFile) };
|
|
33811
|
+
}
|
|
33812
|
+
function refused(accountFile, refusal3) {
|
|
33813
|
+
return { accountFile, vaultDir: getVaultDir(accountFile), refusal: refusal3 };
|
|
33814
|
+
}
|
|
33815
|
+
var refusalsKey, globalState3, refusals, OVERRIDE, overrideRefusalKey;
|
|
33816
|
+
var init_vault_folder = __esm({
|
|
33817
|
+
"src/vault-folder.ts"() {
|
|
33818
|
+
"use strict";
|
|
33819
|
+
init_private_files2();
|
|
33820
|
+
init_logger4();
|
|
33821
|
+
init_process_heartbeat();
|
|
33822
|
+
init_runtime_layout();
|
|
33823
|
+
init_runtime_paths();
|
|
33824
|
+
refusalsKey = /* @__PURE__ */ Symbol.for(
|
|
33825
|
+
"@cortexkit/antigravity-auth/vault-folder-refusals"
|
|
33826
|
+
);
|
|
33827
|
+
globalState3 = globalThis;
|
|
33828
|
+
refusals = globalState3[refusalsKey] ?? /* @__PURE__ */ new Map();
|
|
33829
|
+
globalState3[refusalsKey] = refusals;
|
|
33830
|
+
OVERRIDE = "OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR";
|
|
33831
|
+
overrideRefusalKey = "invalid-vault-dir-override";
|
|
33832
|
+
}
|
|
33833
|
+
});
|
|
33834
|
+
|
|
33656
33835
|
// src/ga/server/index.ts
|
|
33657
33836
|
init_dist();
|
|
33658
33837
|
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
@@ -33772,63 +33951,9 @@ var MAX_RETRY_HOLD_MS = 20 * 60 * 1e3;
|
|
|
33772
33951
|
|
|
33773
33952
|
// src/plugin/ga-location-services.ts
|
|
33774
33953
|
init_dist();
|
|
33954
|
+
init_vault_folder();
|
|
33775
33955
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
33776
33956
|
|
|
33777
|
-
// src/vault-folder.ts
|
|
33778
|
-
init_logger4();
|
|
33779
|
-
init_process_heartbeat();
|
|
33780
|
-
init_runtime_layout();
|
|
33781
|
-
init_runtime_paths();
|
|
33782
|
-
var refusalsKey = /* @__PURE__ */ Symbol.for(
|
|
33783
|
-
"@cortexkit/antigravity-auth/vault-folder-refusals"
|
|
33784
|
-
);
|
|
33785
|
-
var globalState3 = globalThis;
|
|
33786
|
-
var refusals = globalState3[refusalsKey] ?? /* @__PURE__ */ new Map();
|
|
33787
|
-
globalState3[refusalsKey] = refusals;
|
|
33788
|
-
function locationKey() {
|
|
33789
|
-
const location = runtimeLayoutLocation();
|
|
33790
|
-
return `${location.stateHomeDir}\0${location.key}`;
|
|
33791
|
-
}
|
|
33792
|
-
async function prepareVaultFolder(options) {
|
|
33793
|
-
const { accountFile } = options;
|
|
33794
|
-
const key = locationKey();
|
|
33795
|
-
const kept = refusals.get(key);
|
|
33796
|
-
if (kept) return refused(accountFile, kept);
|
|
33797
|
-
const log16 = options.log ?? createLogger4("runtime-layout");
|
|
33798
|
-
const version = options.version ?? await pluginPackageVersion().catch(() => "unknown");
|
|
33799
|
-
try {
|
|
33800
|
-
await prepareRuntimeLayout({
|
|
33801
|
-
version,
|
|
33802
|
-
accountFile,
|
|
33803
|
-
log: log16,
|
|
33804
|
-
...options.layoutLockWaitMs === void 0 ? {} : { layoutLockWaitMs: options.layoutLockWaitMs }
|
|
33805
|
-
});
|
|
33806
|
-
if (options.accountStore !== false)
|
|
33807
|
-
await prepareAccountStore({ version, log: log16 });
|
|
33808
|
-
} catch (error) {
|
|
33809
|
-
const refusal3 = error instanceof RuntimeLayoutRefusal ? error : new RuntimeLayoutRefusal(
|
|
33810
|
-
runtimeLayoutLocation().stateHomeDir,
|
|
33811
|
-
error instanceof Error ? error.name : typeof error
|
|
33812
|
-
);
|
|
33813
|
-
if (!refusals.has(key)) {
|
|
33814
|
-
refusals.set(key, refusal3);
|
|
33815
|
-
log16.warn(refusal3.message, {
|
|
33816
|
-
stateDir: refusal3.stateDir,
|
|
33817
|
-
errorClass: refusal3.errorClass
|
|
33818
|
-
});
|
|
33819
|
-
}
|
|
33820
|
-
return refused(accountFile, refusals.get(key) ?? refusal3);
|
|
33821
|
-
}
|
|
33822
|
-
return { accountFile, vaultDir: getVaultDir(accountFile) };
|
|
33823
|
-
}
|
|
33824
|
-
function currentVaultFolder(accountFile) {
|
|
33825
|
-
const kept = refusals.get(locationKey());
|
|
33826
|
-
return kept ? refused(accountFile, kept) : { accountFile, vaultDir: getVaultDir(accountFile) };
|
|
33827
|
-
}
|
|
33828
|
-
function refused(accountFile, refusal3) {
|
|
33829
|
-
return { accountFile, vaultDir: getVaultDir(accountFile), refusal: refusal3 };
|
|
33830
|
-
}
|
|
33831
|
-
|
|
33832
33957
|
// src/plugin/account-access.ts
|
|
33833
33958
|
init_dist();
|
|
33834
33959
|
|
|
@@ -33999,7 +34124,7 @@ init_logger4();
|
|
|
33999
34124
|
init_dist();
|
|
34000
34125
|
|
|
34001
34126
|
// src/plugin/token.ts
|
|
34002
|
-
var
|
|
34127
|
+
var log7 = createLogger4("token");
|
|
34003
34128
|
function parseOAuthErrorPayload(text2) {
|
|
34004
34129
|
if (!text2) {
|
|
34005
34130
|
return {};
|
|
@@ -34082,13 +34207,13 @@ async function exchangeRefreshToken(refreshToken, now) {
|
|
|
34082
34207
|
const details = [code2, description ?? errorText3].filter(Boolean).join(": ");
|
|
34083
34208
|
const baseMessage = `Antigravity token refresh failed (${response.status} ${response.statusText})`;
|
|
34084
34209
|
const message = details ? `${baseMessage} - ${details}` : baseMessage;
|
|
34085
|
-
|
|
34210
|
+
log7.warn("Token refresh failed", {
|
|
34086
34211
|
status: response.status,
|
|
34087
34212
|
code: code2,
|
|
34088
34213
|
details
|
|
34089
34214
|
});
|
|
34090
34215
|
if (code2 === "invalid_grant") {
|
|
34091
|
-
|
|
34216
|
+
log7.warn(
|
|
34092
34217
|
"Google revoked the stored refresh token - reauthentication required"
|
|
34093
34218
|
);
|
|
34094
34219
|
invalidateProjectContextCache(refreshToken);
|
|
@@ -34144,7 +34269,7 @@ async function refreshAccessToken(auth, _client, _providerId) {
|
|
|
34144
34269
|
if (error instanceof AntigravityTokenRefreshError) {
|
|
34145
34270
|
throw error;
|
|
34146
34271
|
}
|
|
34147
|
-
|
|
34272
|
+
log7.error("Unexpected token refresh error", { error: String(error) });
|
|
34148
34273
|
return void 0;
|
|
34149
34274
|
}
|
|
34150
34275
|
}
|
|
@@ -34912,7 +35037,7 @@ init_runtime_paths();
|
|
|
34912
35037
|
init_logger4();
|
|
34913
35038
|
import { existsSync as existsSync5, readFileSync as readFileSync3, realpathSync as realpathSync3 } from "node:fs";
|
|
34914
35039
|
import { homedir as homedir6 } from "node:os";
|
|
34915
|
-
import { basename as basename5, dirname as dirname18, join as
|
|
35040
|
+
import { basename as basename5, dirname as dirname18, join as join18, resolve as resolve18 } from "node:path";
|
|
34916
35041
|
|
|
34917
35042
|
// src/plugin/config/schema.ts
|
|
34918
35043
|
import { z } from "zod";
|
|
@@ -35407,16 +35532,16 @@ function getConfigDir2() {
|
|
|
35407
35532
|
if (process.env.OPENCODE_CONFIG_DIR) {
|
|
35408
35533
|
return process.env.OPENCODE_CONFIG_DIR;
|
|
35409
35534
|
}
|
|
35410
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ||
|
|
35411
|
-
return
|
|
35535
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME || join18(homedir6(), ".config");
|
|
35536
|
+
return join18(xdgConfig2, "opencode");
|
|
35412
35537
|
}
|
|
35413
35538
|
function getUserConfigPath() {
|
|
35414
|
-
return
|
|
35539
|
+
return join18(getConfigDir2(), "antigravity.json");
|
|
35415
35540
|
}
|
|
35416
35541
|
function getProjectConfigPath(directory) {
|
|
35417
|
-
return
|
|
35542
|
+
return join18(directory, ".opencode", "antigravity.json");
|
|
35418
35543
|
}
|
|
35419
|
-
function loadConfigFile(path5,
|
|
35544
|
+
function loadConfigFile(path5, log17) {
|
|
35420
35545
|
try {
|
|
35421
35546
|
if (!existsSync5(path5)) {
|
|
35422
35547
|
return null;
|
|
@@ -35425,7 +35550,7 @@ function loadConfigFile(path5, log16) {
|
|
|
35425
35550
|
const rawConfig = JSON.parse(content);
|
|
35426
35551
|
const result = AntigravityConfigSchema.partial().safeParse(rawConfig);
|
|
35427
35552
|
if (!result.success) {
|
|
35428
|
-
|
|
35553
|
+
log17.warn("Config validation error", {
|
|
35429
35554
|
path: path5,
|
|
35430
35555
|
issues: result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join(", ")
|
|
35431
35556
|
});
|
|
@@ -35434,9 +35559,9 @@ function loadConfigFile(path5, log16) {
|
|
|
35434
35559
|
return result.data;
|
|
35435
35560
|
} catch (error) {
|
|
35436
35561
|
if (error instanceof SyntaxError) {
|
|
35437
|
-
|
|
35562
|
+
log17.warn("Invalid JSON in config file", { path: path5, error: error.message });
|
|
35438
35563
|
} else {
|
|
35439
|
-
|
|
35564
|
+
log17.warn("Failed to load config file", { path: path5, error: String(error) });
|
|
35440
35565
|
}
|
|
35441
35566
|
return null;
|
|
35442
35567
|
}
|
|
@@ -35455,15 +35580,15 @@ function mergeConfigs(base, override) {
|
|
|
35455
35580
|
function loadConfig(directory) {
|
|
35456
35581
|
return loadConfigWithLogger(directory, legacyLog);
|
|
35457
35582
|
}
|
|
35458
|
-
function loadConfigWithLogger(directory,
|
|
35583
|
+
function loadConfigWithLogger(directory, log17) {
|
|
35459
35584
|
let config = structuredClone(DEFAULT_CONFIG);
|
|
35460
35585
|
const userConfigPath = getUserConfigPath();
|
|
35461
|
-
const userConfig = loadConfigFile(userConfigPath,
|
|
35586
|
+
const userConfig = loadConfigFile(userConfigPath, log17);
|
|
35462
35587
|
if (userConfig) {
|
|
35463
35588
|
config = mergeConfigs(config, userConfig);
|
|
35464
35589
|
}
|
|
35465
35590
|
const projectConfigPath = getProjectConfigPath(directory);
|
|
35466
|
-
const projectConfig = loadConfigFile(projectConfigPath,
|
|
35591
|
+
const projectConfig = loadConfigFile(projectConfigPath, log17);
|
|
35467
35592
|
if (projectConfig) {
|
|
35468
35593
|
config = mergeConfigs(config, projectConfig);
|
|
35469
35594
|
}
|
|
@@ -35486,12 +35611,12 @@ function createLocationConfig(directory, options) {
|
|
|
35486
35611
|
};
|
|
35487
35612
|
}
|
|
35488
35613
|
function canonicalizeOwnedPath(path5) {
|
|
35489
|
-
const absolute =
|
|
35614
|
+
const absolute = resolve18(path5);
|
|
35490
35615
|
const missing = [];
|
|
35491
35616
|
let current = absolute;
|
|
35492
35617
|
for (; ; ) {
|
|
35493
35618
|
try {
|
|
35494
|
-
return
|
|
35619
|
+
return join18(realpathSync3(current), ...missing.reverse());
|
|
35495
35620
|
} catch {
|
|
35496
35621
|
const parent = dirname18(current);
|
|
35497
35622
|
if (parent === current) return absolute;
|
|
@@ -35865,14 +35990,14 @@ function createStoreAccountLimits(input2) {
|
|
|
35865
35990
|
|
|
35866
35991
|
// src/plugin/ga-shared-vault-custody.ts
|
|
35867
35992
|
init_dist();
|
|
35868
|
-
import { resolve as
|
|
35993
|
+
import { resolve as resolve19 } from "node:path";
|
|
35869
35994
|
|
|
35870
35995
|
// src/sidebar-state.ts
|
|
35871
35996
|
init_atomic_write();
|
|
35872
35997
|
init_file_lock();
|
|
35873
35998
|
import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
35874
35999
|
import { homedir as homedir7 } from "node:os";
|
|
35875
|
-
import { dirname as dirname19, join as
|
|
36000
|
+
import { dirname as dirname19, join as join19 } from "node:path";
|
|
35876
36001
|
|
|
35877
36002
|
// ../../node_modules/.bun/xdg-basedir@5.1.0/node_modules/xdg-basedir/index.js
|
|
35878
36003
|
import os from "os";
|
|
@@ -35931,8 +36056,8 @@ async function emitMergeStep(step) {
|
|
|
35931
36056
|
function getSidebarStateFile() {
|
|
35932
36057
|
const override = process.env[SIDEBAR_STATE_ENV];
|
|
35933
36058
|
if (override && override.trim().length > 0) return override;
|
|
35934
|
-
const base = xdgState ??
|
|
35935
|
-
return
|
|
36059
|
+
const base = xdgState ?? join19(homedir7(), ".local", "state");
|
|
36060
|
+
return join19(base, SIDEBAR_STATE_DIR, SIDEBAR_STATE_FILENAME);
|
|
35936
36061
|
}
|
|
35937
36062
|
function readSidebarState(path5 = getSidebarStateFile()) {
|
|
35938
36063
|
let raw;
|
|
@@ -36281,7 +36406,7 @@ function drainSidebarWrites() {
|
|
|
36281
36406
|
return sidebarWriteChain;
|
|
36282
36407
|
}
|
|
36283
36408
|
async function sleep3(ms) {
|
|
36284
|
-
await new Promise((
|
|
36409
|
+
await new Promise((resolve28) => setTimeout(resolve28, ms));
|
|
36285
36410
|
}
|
|
36286
36411
|
async function acquireSidebarLockWithRetry(stateFile) {
|
|
36287
36412
|
const start = Date.now();
|
|
@@ -36412,7 +36537,7 @@ init_dist();
|
|
|
36412
36537
|
init_debug();
|
|
36413
36538
|
init_logger4();
|
|
36414
36539
|
init_dist();
|
|
36415
|
-
var
|
|
36540
|
+
var log8 = createLogger4("quota");
|
|
36416
36541
|
function createOpenCodeQuotaManager(client, providerId = ANTIGRAVITY_PROVIDER_ID, options = {}) {
|
|
36417
36542
|
const fetchPoolFileQuota = makeFetchAccountQuota(
|
|
36418
36543
|
client,
|
|
@@ -36603,7 +36728,7 @@ async function pushSidebarQuotaSnapshot(getAccounts, backoffUntil = 0, getActive
|
|
|
36603
36728
|
);
|
|
36604
36729
|
} catch (error) {
|
|
36605
36730
|
;
|
|
36606
|
-
(options.logger ??
|
|
36731
|
+
(options.logger ?? log8).debug("sidebar-quota-write-failed", {
|
|
36607
36732
|
error: String(error)
|
|
36608
36733
|
});
|
|
36609
36734
|
}
|
|
@@ -36840,14 +36965,14 @@ var LocalQuotaGrantStaleError = class extends Error {
|
|
|
36840
36965
|
name = "LocalQuotaGrantStaleError";
|
|
36841
36966
|
};
|
|
36842
36967
|
function untilQuotaAborted(pending, signal) {
|
|
36843
|
-
return new Promise((
|
|
36968
|
+
return new Promise((resolve28, reject) => {
|
|
36844
36969
|
const abort = () => reject(signal.reason);
|
|
36845
36970
|
if (signal.aborted) abort();
|
|
36846
36971
|
else signal.addEventListener("abort", abort, { once: true });
|
|
36847
36972
|
void pending.then(
|
|
36848
36973
|
(value) => {
|
|
36849
36974
|
signal.removeEventListener("abort", abort);
|
|
36850
|
-
|
|
36975
|
+
resolve28(value);
|
|
36851
36976
|
},
|
|
36852
36977
|
(error) => {
|
|
36853
36978
|
signal.removeEventListener("abort", abort);
|
|
@@ -36969,7 +37094,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
36969
37094
|
let rotatedRefresh;
|
|
36970
37095
|
if (purpose === "advisory") {
|
|
36971
37096
|
if (accessTokenExpired(auth)) {
|
|
36972
|
-
|
|
37097
|
+
log8.debug("advisory-quota-skipped-refresh-needed");
|
|
36973
37098
|
return {
|
|
36974
37099
|
index,
|
|
36975
37100
|
email: account.email,
|
|
@@ -36981,7 +37106,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
36981
37106
|
const managedProjectId = parts.managedProjectId ?? account.managedProjectId;
|
|
36982
37107
|
const projectId = managedProjectId ?? parts.projectId ?? account.projectId;
|
|
36983
37108
|
if (!projectId) {
|
|
36984
|
-
|
|
37109
|
+
log8.debug("advisory-quota-skipped-project-needed");
|
|
36985
37110
|
return {
|
|
36986
37111
|
index,
|
|
36987
37112
|
email: account.email,
|
|
@@ -37003,7 +37128,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
37003
37128
|
{ timeoutMs: extra.timeoutMs }
|
|
37004
37129
|
);
|
|
37005
37130
|
},
|
|
37006
|
-
logger:
|
|
37131
|
+
logger: log8
|
|
37007
37132
|
}),
|
|
37008
37133
|
signal
|
|
37009
37134
|
);
|
|
@@ -37060,7 +37185,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
37060
37185
|
managedProjectId,
|
|
37061
37186
|
projectId: projectContext.effectiveProjectId,
|
|
37062
37187
|
fetchVia,
|
|
37063
|
-
logger:
|
|
37188
|
+
logger: log8
|
|
37064
37189
|
});
|
|
37065
37190
|
quotaResult = payloads.quota;
|
|
37066
37191
|
if (quotaResult.error) throw new Error(quotaResult.error);
|
|
@@ -37742,7 +37867,7 @@ init_vault_request_credentials();
|
|
|
37742
37867
|
init_vault_custody();
|
|
37743
37868
|
var shared3 = /* @__PURE__ */ new Map();
|
|
37744
37869
|
function acquireGaVaultCustody(options) {
|
|
37745
|
-
const key = options.layoutRefusal === void 0 ?
|
|
37870
|
+
const key = options.layoutRefusal === void 0 ? resolve19(options.vaultDir) : `unsettled\0${resolve19(options.vaultDir)}`;
|
|
37746
37871
|
let entry = shared3.get(key);
|
|
37747
37872
|
if (!entry) {
|
|
37748
37873
|
const leases = /* @__PURE__ */ new Set();
|
|
@@ -38067,7 +38192,7 @@ import {
|
|
|
38067
38192
|
writeFileSync as writeFileSync2
|
|
38068
38193
|
} from "node:fs";
|
|
38069
38194
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
38070
|
-
import { dirname as dirname20, join as
|
|
38195
|
+
import { dirname as dirname20, join as join20 } from "node:path";
|
|
38071
38196
|
function getSignatureCacheFilePath() {
|
|
38072
38197
|
return stateHomeSignatureCacheFile();
|
|
38073
38198
|
}
|
|
@@ -38351,7 +38476,7 @@ var SignatureCache = class {
|
|
|
38351
38476
|
last_write: now
|
|
38352
38477
|
}
|
|
38353
38478
|
};
|
|
38354
|
-
const tmpPath =
|
|
38479
|
+
const tmpPath = join20(
|
|
38355
38480
|
tmpdir3(),
|
|
38356
38481
|
`antigravity-cache-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`
|
|
38357
38482
|
);
|
|
@@ -38708,9 +38833,9 @@ function clearSignatureCache(sessionId) {
|
|
|
38708
38833
|
// src/plugin/image-saver.ts
|
|
38709
38834
|
import { chmodSync as chmodSync4, existsSync as existsSync9, mkdirSync as mkdirSync5, writeFileSync as writeFileSync3 } from "node:fs";
|
|
38710
38835
|
import { homedir as homedir8 } from "node:os";
|
|
38711
|
-
import { join as
|
|
38836
|
+
import { join as join21 } from "node:path";
|
|
38712
38837
|
function getImageOutputDir(outputDir) {
|
|
38713
|
-
const resolved = outputDir ??
|
|
38838
|
+
const resolved = outputDir ?? join21(homedir8(), ".opencode", "generated-images");
|
|
38714
38839
|
if (!existsSync9(resolved)) {
|
|
38715
38840
|
mkdirSync5(resolved, { recursive: true, mode: 448 });
|
|
38716
38841
|
}
|
|
@@ -38733,7 +38858,7 @@ function generateImageFilename(mimeType) {
|
|
|
38733
38858
|
function saveImageToDisk(base64Data, mimeType, outputDir) {
|
|
38734
38859
|
try {
|
|
38735
38860
|
const resolvedOutputDir = getImageOutputDir(outputDir);
|
|
38736
|
-
const filePath =
|
|
38861
|
+
const filePath = join21(resolvedOutputDir, generateImageFilename(mimeType));
|
|
38737
38862
|
writeFileSync3(filePath, Buffer.from(base64Data, "base64"), { mode: 384 });
|
|
38738
38863
|
chmodSync4(filePath, 384);
|
|
38739
38864
|
return filePath;
|
|
@@ -39174,10 +39299,10 @@ init_logging_utils();
|
|
|
39174
39299
|
import { createHash as createHash15 } from "node:crypto";
|
|
39175
39300
|
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync6, writeFileSync as writeFileSync4 } from "node:fs";
|
|
39176
39301
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
39177
|
-
import { join as
|
|
39302
|
+
import { join as join22 } from "node:path";
|
|
39178
39303
|
var DUMP_STATUS_TITLE = "## Gemini Dump Status";
|
|
39179
39304
|
var DUMP_DIR_ENV = "OPENCODE_ANTIGRAVITY_GEMINI_DUMP_DIR";
|
|
39180
|
-
var DEFAULT_DUMP_DIR =
|
|
39305
|
+
var DEFAULT_DUMP_DIR = join22(tmpdir4(), "opencode-antigravity-gemini-dumps");
|
|
39181
39306
|
var DUMP_DIR_MODE = 448;
|
|
39182
39307
|
var DUMP_FILE_MODE = 384;
|
|
39183
39308
|
var nextDumpId = 0;
|
|
@@ -39331,7 +39456,7 @@ function writeGeminiDump(input2) {
|
|
|
39331
39456
|
nextDumpId += 1;
|
|
39332
39457
|
const id = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${String(nextDumpId).padStart(5, "0")}-${input2.streaming ? "stream" : "json"}`;
|
|
39333
39458
|
const dumpDir = getGeminiDumpDirectory();
|
|
39334
|
-
const prefix =
|
|
39459
|
+
const prefix = join22(dumpDir, id);
|
|
39335
39460
|
mkdirSync6(dumpDir, { recursive: true, mode: DUMP_DIR_MODE });
|
|
39336
39461
|
const context = {
|
|
39337
39462
|
id,
|
|
@@ -39422,21 +39547,21 @@ import {
|
|
|
39422
39547
|
unlinkSync as unlinkSync4,
|
|
39423
39548
|
writeFileSync as writeFileSync5
|
|
39424
39549
|
} from "node:fs";
|
|
39425
|
-
import { join as
|
|
39550
|
+
import { join as join24 } from "node:path";
|
|
39426
39551
|
|
|
39427
39552
|
// src/plugin/recovery/constants.ts
|
|
39428
39553
|
import { homedir as homedir9 } from "node:os";
|
|
39429
|
-
import { join as
|
|
39554
|
+
import { join as join23 } from "node:path";
|
|
39430
39555
|
function getXdgData() {
|
|
39431
39556
|
const platform = process.platform;
|
|
39432
39557
|
if (platform === "win32") {
|
|
39433
|
-
return process.env.APPDATA ||
|
|
39558
|
+
return process.env.APPDATA || join23(homedir9(), "AppData", "Roaming");
|
|
39434
39559
|
}
|
|
39435
|
-
return process.env.XDG_DATA_HOME ||
|
|
39560
|
+
return process.env.XDG_DATA_HOME || join23(homedir9(), ".local", "share");
|
|
39436
39561
|
}
|
|
39437
|
-
var OPENCODE_STORAGE =
|
|
39438
|
-
var MESSAGE_STORAGE =
|
|
39439
|
-
var PART_STORAGE =
|
|
39562
|
+
var OPENCODE_STORAGE = join23(getXdgData(), "opencode", "storage");
|
|
39563
|
+
var MESSAGE_STORAGE = join23(OPENCODE_STORAGE, "message");
|
|
39564
|
+
var PART_STORAGE = join23(OPENCODE_STORAGE, "part");
|
|
39440
39565
|
var THINKING_TYPES = /* @__PURE__ */ new Set([
|
|
39441
39566
|
"thinking",
|
|
39442
39567
|
"redacted_thinking",
|
|
@@ -39446,13 +39571,13 @@ var THINKING_TYPES = /* @__PURE__ */ new Set([
|
|
|
39446
39571
|
// src/plugin/recovery/storage.ts
|
|
39447
39572
|
function getMessageDir(sessionID) {
|
|
39448
39573
|
if (!existsSync10(MESSAGE_STORAGE)) return "";
|
|
39449
|
-
const directPath =
|
|
39574
|
+
const directPath = join24(MESSAGE_STORAGE, sessionID);
|
|
39450
39575
|
if (existsSync10(directPath)) {
|
|
39451
39576
|
return directPath;
|
|
39452
39577
|
}
|
|
39453
39578
|
try {
|
|
39454
39579
|
for (const dir of readdirSync2(MESSAGE_STORAGE)) {
|
|
39455
|
-
const sessionPath =
|
|
39580
|
+
const sessionPath = join24(MESSAGE_STORAGE, dir, sessionID);
|
|
39456
39581
|
if (existsSync10(sessionPath)) {
|
|
39457
39582
|
return sessionPath;
|
|
39458
39583
|
}
|
|
@@ -39469,7 +39594,7 @@ function readMessages(sessionID) {
|
|
|
39469
39594
|
for (const file of readdirSync2(messageDir)) {
|
|
39470
39595
|
if (!file.endsWith(".json")) continue;
|
|
39471
39596
|
try {
|
|
39472
|
-
const content = readFileSync8(
|
|
39597
|
+
const content = readFileSync8(join24(messageDir, file), "utf-8");
|
|
39473
39598
|
messages.push(JSON.parse(content));
|
|
39474
39599
|
} catch {
|
|
39475
39600
|
}
|
|
@@ -39485,14 +39610,14 @@ function readMessages(sessionID) {
|
|
|
39485
39610
|
});
|
|
39486
39611
|
}
|
|
39487
39612
|
function readParts(messageID) {
|
|
39488
|
-
const partDir =
|
|
39613
|
+
const partDir = join24(PART_STORAGE, messageID);
|
|
39489
39614
|
if (!existsSync10(partDir)) return [];
|
|
39490
39615
|
const parts = [];
|
|
39491
39616
|
try {
|
|
39492
39617
|
for (const file of readdirSync2(partDir)) {
|
|
39493
39618
|
if (!file.endsWith(".json")) continue;
|
|
39494
39619
|
try {
|
|
39495
|
-
const content = readFileSync8(
|
|
39620
|
+
const content = readFileSync8(join24(partDir, file), "utf-8");
|
|
39496
39621
|
parts.push(JSON.parse(content));
|
|
39497
39622
|
} catch {
|
|
39498
39623
|
}
|
|
@@ -39534,7 +39659,7 @@ function findMessagesWithOrphanThinking(sessionID) {
|
|
|
39534
39659
|
return result;
|
|
39535
39660
|
}
|
|
39536
39661
|
function prependThinkingPart(sessionID, messageID) {
|
|
39537
|
-
const partDir =
|
|
39662
|
+
const partDir = join24(PART_STORAGE, messageID);
|
|
39538
39663
|
try {
|
|
39539
39664
|
if (!existsSync10(partDir)) {
|
|
39540
39665
|
mkdirSync7(partDir, { recursive: true });
|
|
@@ -39549,7 +39674,7 @@ function prependThinkingPart(sessionID, messageID) {
|
|
|
39549
39674
|
synthetic: true
|
|
39550
39675
|
};
|
|
39551
39676
|
writeFileSync5(
|
|
39552
|
-
|
|
39677
|
+
join24(partDir, `${partId}.json`),
|
|
39553
39678
|
JSON.stringify(part, null, 2)
|
|
39554
39679
|
);
|
|
39555
39680
|
return true;
|
|
@@ -39558,14 +39683,14 @@ function prependThinkingPart(sessionID, messageID) {
|
|
|
39558
39683
|
}
|
|
39559
39684
|
}
|
|
39560
39685
|
function stripThinkingParts(messageID) {
|
|
39561
|
-
const partDir =
|
|
39686
|
+
const partDir = join24(PART_STORAGE, messageID);
|
|
39562
39687
|
if (!existsSync10(partDir)) return false;
|
|
39563
39688
|
let anyRemoved = false;
|
|
39564
39689
|
try {
|
|
39565
39690
|
for (const file of readdirSync2(partDir)) {
|
|
39566
39691
|
if (!file.endsWith(".json")) continue;
|
|
39567
39692
|
try {
|
|
39568
|
-
const filePath =
|
|
39693
|
+
const filePath = join24(partDir, file);
|
|
39569
39694
|
const content = readFileSync8(filePath, "utf-8");
|
|
39570
39695
|
const part = JSON.parse(content);
|
|
39571
39696
|
if (THINKING_TYPES.has(part.type)) {
|
|
@@ -39799,8 +39924,8 @@ function createSessionRecoveryHook(ctx, config) {
|
|
|
39799
39924
|
if (!sessionID) return false;
|
|
39800
39925
|
let assistantMsgID = info.id;
|
|
39801
39926
|
let msgs;
|
|
39802
|
-
const
|
|
39803
|
-
|
|
39927
|
+
const log17 = createLogger4("session-recovery");
|
|
39928
|
+
log17.debug("Recovery attempt started", {
|
|
39804
39929
|
errorType,
|
|
39805
39930
|
sessionID,
|
|
39806
39931
|
providedMsgID: assistantMsgID ?? "none"
|
|
@@ -39820,7 +39945,7 @@ function createSessionRecoveryHook(ctx, config) {
|
|
|
39820
39945
|
const m = msgs[i];
|
|
39821
39946
|
if (m && m.info?.role === "assistant" && m.info?.id) {
|
|
39822
39947
|
assistantMsgID = m.info.id;
|
|
39823
|
-
|
|
39948
|
+
log17.debug("Found assistant message ID from session messages", {
|
|
39824
39949
|
msgID: assistantMsgID,
|
|
39825
39950
|
msgIndex: i
|
|
39826
39951
|
});
|
|
@@ -39829,7 +39954,7 @@ function createSessionRecoveryHook(ctx, config) {
|
|
|
39829
39954
|
}
|
|
39830
39955
|
}
|
|
39831
39956
|
if (!assistantMsgID) {
|
|
39832
|
-
|
|
39957
|
+
log17.debug("No assistant message ID found, cannot recover");
|
|
39833
39958
|
return false;
|
|
39834
39959
|
}
|
|
39835
39960
|
if (processingErrors.has(assistantMsgID)) return false;
|
|
@@ -39873,7 +39998,7 @@ function createSessionRecoveryHook(ctx, config) {
|
|
|
39873
39998
|
}
|
|
39874
39999
|
return success;
|
|
39875
40000
|
} catch (err) {
|
|
39876
|
-
|
|
40001
|
+
log17.error("Recovery failed", { error: String(err) });
|
|
39877
40002
|
return false;
|
|
39878
40003
|
} finally {
|
|
39879
40004
|
processingErrors.delete(assistantMsgID);
|
|
@@ -39893,7 +40018,7 @@ function createSessionRecoveryHook(ctx, config) {
|
|
|
39893
40018
|
// src/plugin/request-helpers.ts
|
|
39894
40019
|
init_dist();
|
|
39895
40020
|
init_logger4();
|
|
39896
|
-
var
|
|
40021
|
+
var log9 = createLogger4("request-helpers");
|
|
39897
40022
|
var ANTIGRAVITY_PREVIEW_LINK = "https://goo.gle/enable-preview-features";
|
|
39898
40023
|
function appendDescriptionHint(schema, hint) {
|
|
39899
40024
|
if (!schema || typeof schema !== "object") {
|
|
@@ -40318,7 +40443,7 @@ function filterContentArray(contentArray, sessionId, getCachedSignatureFn, isCla
|
|
|
40318
40443
|
}
|
|
40319
40444
|
const existingSignature = item.signature || item.thoughtSignature;
|
|
40320
40445
|
const signatureInfo = existingSignature ? `foreign signature (${String(existingSignature).length} chars)` : "no signature";
|
|
40321
|
-
|
|
40446
|
+
log9.debug(
|
|
40322
40447
|
`Injecting plain text sentinel for last-message thinking block with ${signatureInfo}`
|
|
40323
40448
|
);
|
|
40324
40449
|
const sentinel2 = { text: "." };
|
|
@@ -40830,7 +40955,7 @@ function recursivelyParseJsonStrings(obj, skipParseKeys = SKIP_PARSE_KEYS, curre
|
|
|
40830
40955
|
if (lastBracket > 0) {
|
|
40831
40956
|
const cleaned = stripped.slice(0, lastBracket + 1);
|
|
40832
40957
|
const parsed = JSON.parse(cleaned);
|
|
40833
|
-
|
|
40958
|
+
log9.debug("Auto-corrected malformed JSON array", {
|
|
40834
40959
|
truncatedChars: stripped.length - cleaned.length
|
|
40835
40960
|
});
|
|
40836
40961
|
return recursivelyParseJsonStrings(parsed);
|
|
@@ -40844,7 +40969,7 @@ function recursivelyParseJsonStrings(obj, skipParseKeys = SKIP_PARSE_KEYS, curre
|
|
|
40844
40969
|
if (lastBrace > 0) {
|
|
40845
40970
|
const cleaned = stripped.slice(0, lastBrace + 1);
|
|
40846
40971
|
const parsed = JSON.parse(cleaned);
|
|
40847
|
-
|
|
40972
|
+
log9.debug("Auto-corrected malformed JSON object", {
|
|
40848
40973
|
truncatedChars: stripped.length - cleaned.length
|
|
40849
40974
|
});
|
|
40850
40975
|
return recursivelyParseJsonStrings(parsed);
|
|
@@ -40944,7 +41069,7 @@ function fixToolResponseGrouping(contents) {
|
|
|
40944
41069
|
if (orphanResp.functionResponse.name === "unknown_function" && expectedName) {
|
|
40945
41070
|
orphanResp.functionResponse.name = expectedName;
|
|
40946
41071
|
}
|
|
40947
|
-
|
|
41072
|
+
log9.debug("Auto-repaired tool ID mismatch", {
|
|
40948
41073
|
mappedFrom: matchedId,
|
|
40949
41074
|
mappedTo: expectedId,
|
|
40950
41075
|
functionName: expectedName
|
|
@@ -40964,7 +41089,7 @@ function fixToolResponseGrouping(contents) {
|
|
|
40964
41089
|
id: expectedId
|
|
40965
41090
|
}
|
|
40966
41091
|
};
|
|
40967
|
-
|
|
41092
|
+
log9.debug("Created placeholder response for missing tool", {
|
|
40968
41093
|
id: expectedId,
|
|
40969
41094
|
name: expectedName
|
|
40970
41095
|
});
|
|
@@ -41282,7 +41407,7 @@ function applyToolPairingFixes(payload, isClaude) {
|
|
|
41282
41407
|
);
|
|
41283
41408
|
payload.contents = fixToolResponseGrouping(contentsWithMatchedIds);
|
|
41284
41409
|
contentsFixed = true;
|
|
41285
|
-
|
|
41410
|
+
log9.debug("Applied tool pairing fixes to contents[]", {
|
|
41286
41411
|
originalLength: payload.contents.length
|
|
41287
41412
|
});
|
|
41288
41413
|
}
|
|
@@ -41291,7 +41416,7 @@ function applyToolPairingFixes(payload, isClaude) {
|
|
|
41291
41416
|
payload.messages
|
|
41292
41417
|
);
|
|
41293
41418
|
messagesFixed = true;
|
|
41294
|
-
|
|
41419
|
+
log9.debug("Applied tool pairing fixes to messages[]", {
|
|
41295
41420
|
originalLength: payload.messages.length
|
|
41296
41421
|
});
|
|
41297
41422
|
}
|
|
@@ -41530,7 +41655,7 @@ init_dist();
|
|
|
41530
41655
|
init_dist();
|
|
41531
41656
|
|
|
41532
41657
|
// src/plugin/request.ts
|
|
41533
|
-
var
|
|
41658
|
+
var log10 = createLogger4("request");
|
|
41534
41659
|
var PLUGIN_SESSION_ID = `-${crypto2.randomUUID()}`;
|
|
41535
41660
|
var DEFAULT_AGY_REQUEST_SESSION = createAgyRequestSessionContext("");
|
|
41536
41661
|
var sessionDisplayedThinkingHashes = /* @__PURE__ */ new Set();
|
|
@@ -42329,7 +42454,7 @@ var openCode1WireLocation = {
|
|
|
42329
42454
|
logAntigravityDebugResponse: (context, response, meta) => logAntigravityDebugResponse(context, response, meta),
|
|
42330
42455
|
logCacheStats: (model, cacheRead, cacheWrite, totalInput) => logCacheStats(model, cacheRead, cacheWrite, totalInput)
|
|
42331
42456
|
},
|
|
42332
|
-
logger:
|
|
42457
|
+
logger: log10,
|
|
42333
42458
|
sessionFingerprint: () => getSessionFingerprint(),
|
|
42334
42459
|
displayedThinkingHashes: sessionDisplayedThinkingHashes,
|
|
42335
42460
|
cacheStats: { last: null }
|
|
@@ -42372,6 +42497,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
42372
42497
|
headers.delete("x-parent-session-id");
|
|
42373
42498
|
headers.delete("x-opencode-session-id");
|
|
42374
42499
|
headers.delete("x-opencode-parent-session-id");
|
|
42500
|
+
headers.delete("x-antigravity-internal-request-purpose");
|
|
42375
42501
|
headers.delete("x-goog-user-project");
|
|
42376
42502
|
headers.delete("X-Goog-Api-Client");
|
|
42377
42503
|
headers.delete("Client-Metadata");
|
|
@@ -43374,12 +43500,12 @@ async function startOAuthListener({
|
|
|
43374
43500
|
let resolveCallback;
|
|
43375
43501
|
let rejectCallback;
|
|
43376
43502
|
let timeoutHandle;
|
|
43377
|
-
const callbackPromise = new Promise((
|
|
43503
|
+
const callbackPromise = new Promise((resolve28, reject) => {
|
|
43378
43504
|
resolveCallback = (url) => {
|
|
43379
43505
|
if (settled) return;
|
|
43380
43506
|
settled = true;
|
|
43381
43507
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
43382
|
-
|
|
43508
|
+
resolve28(url);
|
|
43383
43509
|
};
|
|
43384
43510
|
rejectCallback = (error) => {
|
|
43385
43511
|
if (settled) return;
|
|
@@ -43538,7 +43664,7 @@ async function startOAuthListener({
|
|
|
43538
43664
|
});
|
|
43539
43665
|
});
|
|
43540
43666
|
const bindAddress = getBindAddress();
|
|
43541
|
-
await new Promise((
|
|
43667
|
+
await new Promise((resolve28, reject) => {
|
|
43542
43668
|
const handleError = (error) => {
|
|
43543
43669
|
server.off("error", handleError);
|
|
43544
43670
|
if (error.code === "EADDRINUSE") {
|
|
@@ -43554,7 +43680,7 @@ async function startOAuthListener({
|
|
|
43554
43680
|
server.once("error", handleError);
|
|
43555
43681
|
server.listen(port, bindAddress, () => {
|
|
43556
43682
|
server.off("error", handleError);
|
|
43557
|
-
|
|
43683
|
+
resolve28();
|
|
43558
43684
|
});
|
|
43559
43685
|
});
|
|
43560
43686
|
server.on("error", (error) => {
|
|
@@ -43562,7 +43688,7 @@ async function startOAuthListener({
|
|
|
43562
43688
|
});
|
|
43563
43689
|
return {
|
|
43564
43690
|
waitForCallback: () => callbackPromise,
|
|
43565
|
-
close: () => new Promise((
|
|
43691
|
+
close: () => new Promise((resolve28, reject) => {
|
|
43566
43692
|
server.close((error) => {
|
|
43567
43693
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
43568
43694
|
reject(error);
|
|
@@ -43571,7 +43697,7 @@ async function startOAuthListener({
|
|
|
43571
43697
|
if (!settled) {
|
|
43572
43698
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
43573
43699
|
}
|
|
43574
|
-
|
|
43700
|
+
resolve28();
|
|
43575
43701
|
});
|
|
43576
43702
|
})
|
|
43577
43703
|
};
|
|
@@ -43582,7 +43708,7 @@ async function startOAuthListener({
|
|
|
43582
43708
|
}
|
|
43583
43709
|
|
|
43584
43710
|
// src/plugin/session-context.ts
|
|
43585
|
-
import { resolve as
|
|
43711
|
+
import { resolve as resolve20 } from "node:path";
|
|
43586
43712
|
import { pathToFileURL } from "node:url";
|
|
43587
43713
|
var FALLBACK_SESSION_KEY = "__default__";
|
|
43588
43714
|
function extractOpenCodeSessionIdentity(headers) {
|
|
@@ -43596,7 +43722,7 @@ var AgySessionRegistry = class {
|
|
|
43596
43722
|
requestSessions;
|
|
43597
43723
|
parentSessionIds = /* @__PURE__ */ new Map();
|
|
43598
43724
|
constructor(directory, options = {}) {
|
|
43599
|
-
const workspaceUri = directory ? pathToFileURL(
|
|
43725
|
+
const workspaceUri = directory ? pathToFileURL(resolve20(directory)).href : "";
|
|
43600
43726
|
this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
|
|
43601
43727
|
}
|
|
43602
43728
|
getOrCreate(identity3) {
|
|
@@ -43649,7 +43775,7 @@ var AgySessionRegistry = class {
|
|
|
43649
43775
|
};
|
|
43650
43776
|
|
|
43651
43777
|
// src/plugin/shared/advisory-repository.ts
|
|
43652
|
-
function createAdvisoryRepositoryOwner(repository,
|
|
43778
|
+
function createAdvisoryRepositoryOwner(repository, log17) {
|
|
43653
43779
|
const methods = /* @__PURE__ */ new Map();
|
|
43654
43780
|
const advisoryMethods = /* @__PURE__ */ new Set([
|
|
43655
43781
|
"updateMetadata",
|
|
@@ -43695,7 +43821,7 @@ function createAdvisoryRepositoryOwner(repository, log16) {
|
|
|
43695
43821
|
(reason) => !failures.has(reason)
|
|
43696
43822
|
);
|
|
43697
43823
|
for (const reason of absorbed) failures.delete(reason);
|
|
43698
|
-
|
|
43824
|
+
log17.debug("post-response-local-write-refused", {
|
|
43699
43825
|
count: absorbed.length
|
|
43700
43826
|
});
|
|
43701
43827
|
if (remaining.length > 0)
|
|
@@ -43725,6 +43851,107 @@ function isFlushReport(value) {
|
|
|
43725
43851
|
// src/plugin/shared/request-services.ts
|
|
43726
43852
|
init_dist();
|
|
43727
43853
|
|
|
43854
|
+
// src/common-auth-embedded/routing-accessor/index.js
|
|
43855
|
+
function isObject2(value) {
|
|
43856
|
+
return typeof value === "object" && value !== null;
|
|
43857
|
+
}
|
|
43858
|
+
function routingHandle(sessionId) {
|
|
43859
|
+
const routing = Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing"));
|
|
43860
|
+
if (typeof routing !== "function")
|
|
43861
|
+
return void 0;
|
|
43862
|
+
const handle = routing(sessionId);
|
|
43863
|
+
return isObject2(handle) ? handle : void 0;
|
|
43864
|
+
}
|
|
43865
|
+
function selectionFor(answer, candidates) {
|
|
43866
|
+
if (!isObject2(answer))
|
|
43867
|
+
return void 0;
|
|
43868
|
+
const accountId = answer.account_id;
|
|
43869
|
+
const credentialId = answer.credential_id;
|
|
43870
|
+
if (typeof accountId !== "string")
|
|
43871
|
+
return void 0;
|
|
43872
|
+
if (credentialId !== void 0 && typeof credentialId !== "string") {
|
|
43873
|
+
return void 0;
|
|
43874
|
+
}
|
|
43875
|
+
const candidate = candidates.find((route) => route.accountId === accountId && (credentialId === void 0 || route.credentialId === credentialId));
|
|
43876
|
+
if (!candidate)
|
|
43877
|
+
return void 0;
|
|
43878
|
+
const hold = answer.hold;
|
|
43879
|
+
const retryAfterMs = isObject2(hold) ? hold.retry_after_ms : void 0;
|
|
43880
|
+
if (typeof retryAfterMs === "number" && Number.isFinite(retryAfterMs) && retryAfterMs >= 0) {
|
|
43881
|
+
return { candidate, hold: { retry_after_ms: retryAfterMs } };
|
|
43882
|
+
}
|
|
43883
|
+
return { candidate };
|
|
43884
|
+
}
|
|
43885
|
+
async function askRouting(input2) {
|
|
43886
|
+
let timer;
|
|
43887
|
+
try {
|
|
43888
|
+
const handle = routingHandle(input2.sessionId);
|
|
43889
|
+
if (!handle)
|
|
43890
|
+
return void 0;
|
|
43891
|
+
const accountFor = handle.accountFor;
|
|
43892
|
+
if (typeof accountFor !== "function")
|
|
43893
|
+
return void 0;
|
|
43894
|
+
const requested = input2.deadlineMs ?? 500;
|
|
43895
|
+
const deadlineMs = Number.isNaN(requested) ? 500 : Math.min(2e3, Math.max(1, requested));
|
|
43896
|
+
const expired = new Promise((resolve28) => {
|
|
43897
|
+
timer = setTimeout(() => resolve28(void 0), deadlineMs);
|
|
43898
|
+
timer.unref();
|
|
43899
|
+
});
|
|
43900
|
+
const pending = accountFor.call(handle, { provider: input2.provider, modelId: input2.modelId }, { deadlineMs });
|
|
43901
|
+
if (!isObject2(pending) || typeof pending.then !== "function")
|
|
43902
|
+
return void 0;
|
|
43903
|
+
const answer = await Promise.race([pending, expired]);
|
|
43904
|
+
return selectionFor(answer, input2.candidates);
|
|
43905
|
+
} catch {
|
|
43906
|
+
return void 0;
|
|
43907
|
+
} finally {
|
|
43908
|
+
clearTimeout(timer);
|
|
43909
|
+
}
|
|
43910
|
+
}
|
|
43911
|
+
function reportRouting(input2) {
|
|
43912
|
+
try {
|
|
43913
|
+
const handle = routingHandle(input2.sessionId);
|
|
43914
|
+
if (!handle)
|
|
43915
|
+
return;
|
|
43916
|
+
const report = handle.report;
|
|
43917
|
+
if (typeof report !== "function")
|
|
43918
|
+
return;
|
|
43919
|
+
const identity3 = {
|
|
43920
|
+
account_id: input2.accountId,
|
|
43921
|
+
...input2.credentialId !== void 0 ? { credential_id: input2.credentialId } : {}
|
|
43922
|
+
};
|
|
43923
|
+
let payload;
|
|
43924
|
+
switch (input2.outcome) {
|
|
43925
|
+
case "served":
|
|
43926
|
+
payload = { ...identity3, outcome: "served", headers: input2.headers };
|
|
43927
|
+
break;
|
|
43928
|
+
case "exhausted": {
|
|
43929
|
+
const { window, pool } = input2;
|
|
43930
|
+
if (window !== "5h" && window !== "7d")
|
|
43931
|
+
return;
|
|
43932
|
+
if (pool !== void 0 && (typeof pool !== "string" || pool.length === 0 || pool.includes(":")))
|
|
43933
|
+
return;
|
|
43934
|
+
payload = {
|
|
43935
|
+
...identity3,
|
|
43936
|
+
outcome: "exhausted",
|
|
43937
|
+
window,
|
|
43938
|
+
...pool ? { pool } : {},
|
|
43939
|
+
...input2.resetsAt !== void 0 ? { resets_at: input2.resetsAt } : {}
|
|
43940
|
+
};
|
|
43941
|
+
break;
|
|
43942
|
+
}
|
|
43943
|
+
default:
|
|
43944
|
+
return;
|
|
43945
|
+
}
|
|
43946
|
+
const pending = report.call(handle, payload);
|
|
43947
|
+
if (isObject2(pending) && typeof pending.then === "function") {
|
|
43948
|
+
void Promise.resolve(pending).catch(() => {
|
|
43949
|
+
});
|
|
43950
|
+
}
|
|
43951
|
+
} catch {
|
|
43952
|
+
}
|
|
43953
|
+
}
|
|
43954
|
+
|
|
43728
43955
|
// src/plugin/errors.ts
|
|
43729
43956
|
var AntigravityKillswitchError = class extends Error {
|
|
43730
43957
|
family;
|
|
@@ -44225,10 +44452,10 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
44225
44452
|
cancellation.release();
|
|
44226
44453
|
throw error;
|
|
44227
44454
|
}
|
|
44228
|
-
let
|
|
44455
|
+
let resolve28 = () => {
|
|
44229
44456
|
};
|
|
44230
44457
|
const settled = new Promise((done) => {
|
|
44231
|
-
|
|
44458
|
+
resolve28 = done;
|
|
44232
44459
|
});
|
|
44233
44460
|
let stopping = false;
|
|
44234
44461
|
let finished = false;
|
|
@@ -44238,7 +44465,7 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
44238
44465
|
finished = true;
|
|
44239
44466
|
cancellation.signal.removeEventListener("abort", abort);
|
|
44240
44467
|
cancellation.release();
|
|
44241
|
-
|
|
44468
|
+
resolve28();
|
|
44242
44469
|
};
|
|
44243
44470
|
const abort = () => {
|
|
44244
44471
|
if (finished || stopping) return;
|
|
@@ -44307,8 +44534,8 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
44307
44534
|
let running = false;
|
|
44308
44535
|
let resolveCompletion = () => {
|
|
44309
44536
|
};
|
|
44310
|
-
const completion = new Promise((
|
|
44311
|
-
resolveCompletion =
|
|
44537
|
+
const completion = new Promise((resolve28) => {
|
|
44538
|
+
resolveCompletion = resolve28;
|
|
44312
44539
|
});
|
|
44313
44540
|
const finish = () => {
|
|
44314
44541
|
if (finished) return;
|
|
@@ -44355,19 +44582,203 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
44355
44582
|
};
|
|
44356
44583
|
}
|
|
44357
44584
|
function publishResponse(dispatch) {
|
|
44358
|
-
return new Promise((
|
|
44585
|
+
return new Promise((resolve28, reject) => {
|
|
44359
44586
|
let acknowledge;
|
|
44360
44587
|
void Promise.resolve().then(
|
|
44361
44588
|
() => dispatch((callback) => {
|
|
44362
44589
|
acknowledge = callback;
|
|
44363
44590
|
})
|
|
44364
44591
|
).then((response) => {
|
|
44365
|
-
|
|
44592
|
+
resolve28(response);
|
|
44366
44593
|
acknowledge?.();
|
|
44367
44594
|
}, reject);
|
|
44368
44595
|
});
|
|
44369
44596
|
}
|
|
44370
44597
|
|
|
44598
|
+
// src/plugin/shared/vault-routing.ts
|
|
44599
|
+
function hasVaultRoutingAccessor() {
|
|
44600
|
+
try {
|
|
44601
|
+
return typeof Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing")) === "function";
|
|
44602
|
+
} catch {
|
|
44603
|
+
return false;
|
|
44604
|
+
}
|
|
44605
|
+
}
|
|
44606
|
+
function routingQuotaScope(group, window) {
|
|
44607
|
+
const limitWindow = window === "5h" ? "five_hour" : window === "weekly" ? "seven_day" : void 0;
|
|
44608
|
+
return limitWindow ? { pool: group === "non-gemini" ? "3p" : group, limitWindow } : void 0;
|
|
44609
|
+
}
|
|
44610
|
+
function routingExhaustionFields(scope) {
|
|
44611
|
+
return {
|
|
44612
|
+
pool: scope.pool,
|
|
44613
|
+
window: scope.limitWindow === "five_hour" ? "5h" : "7d"
|
|
44614
|
+
};
|
|
44615
|
+
}
|
|
44616
|
+
function reportVaultExhaustion(input2, report = reportRouting) {
|
|
44617
|
+
if (!hasVaultRoutingAccessor() || input2.signal?.aborted || input2.status !== 429 || input2.reason !== "QUOTA_EXHAUSTED" || !Number.isFinite(input2.observedAt) || (input2.observedAt ?? 0) <= 0 || (input2.observedAt ?? Infinity) > Date.now())
|
|
44618
|
+
return;
|
|
44619
|
+
for (const window of input2.quota?.windows ?? []) {
|
|
44620
|
+
if (window.remainingFraction !== 0) continue;
|
|
44621
|
+
const scope = routingQuotaScope(input2.group, window.window);
|
|
44622
|
+
const resetsAt = Date.parse(window.resetTime);
|
|
44623
|
+
if (!scope || !Number.isFinite(resetsAt) || resetsAt <= Date.now()) continue;
|
|
44624
|
+
report({
|
|
44625
|
+
...input2.identity,
|
|
44626
|
+
outcome: "exhausted",
|
|
44627
|
+
...routingExhaustionFields(scope),
|
|
44628
|
+
resetsAt
|
|
44629
|
+
});
|
|
44630
|
+
}
|
|
44631
|
+
}
|
|
44632
|
+
var RATE_LIMIT_HEADERS = [
|
|
44633
|
+
"retry-after",
|
|
44634
|
+
"retry-after-ms",
|
|
44635
|
+
"ratelimit-limit",
|
|
44636
|
+
"ratelimit-remaining",
|
|
44637
|
+
"ratelimit-reset",
|
|
44638
|
+
"ratelimit-policy",
|
|
44639
|
+
"x-ratelimit-limit",
|
|
44640
|
+
"x-ratelimit-remaining",
|
|
44641
|
+
"x-ratelimit-reset",
|
|
44642
|
+
"x-ratelimit-limit-requests",
|
|
44643
|
+
"x-ratelimit-remaining-requests",
|
|
44644
|
+
"x-ratelimit-reset-requests",
|
|
44645
|
+
"x-ratelimit-limit-tokens",
|
|
44646
|
+
"x-ratelimit-remaining-tokens",
|
|
44647
|
+
"x-ratelimit-reset-tokens"
|
|
44648
|
+
];
|
|
44649
|
+
function streamFailure(value) {
|
|
44650
|
+
if (!value || typeof value !== "object") return false;
|
|
44651
|
+
if (Array.isArray(value)) return value.some(streamFailure);
|
|
44652
|
+
const event = value;
|
|
44653
|
+
return event.error != null || event.type === "error" || event.type === "response.failed" || event.status === "failed" || streamFailure(event.response);
|
|
44654
|
+
}
|
|
44655
|
+
function observeVaultUpstream(response, signal) {
|
|
44656
|
+
if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
|
|
44657
|
+
return void 0;
|
|
44658
|
+
let completed = false;
|
|
44659
|
+
return {
|
|
44660
|
+
response: observeBody(response, () => {
|
|
44661
|
+
completed = !signal?.aborted;
|
|
44662
|
+
}),
|
|
44663
|
+
completedSuccessfully: () => completed
|
|
44664
|
+
};
|
|
44665
|
+
}
|
|
44666
|
+
function observeVaultServed(identity3, response, signal, upstream) {
|
|
44667
|
+
if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
|
|
44668
|
+
return response;
|
|
44669
|
+
const report = () => {
|
|
44670
|
+
if (signal?.aborted || upstream && !upstream.completedSuccessfully() || !hasVaultRoutingAccessor())
|
|
44671
|
+
return;
|
|
44672
|
+
const headers = {};
|
|
44673
|
+
for (const name of RATE_LIMIT_HEADERS) {
|
|
44674
|
+
const value = response.headers.get(name);
|
|
44675
|
+
if (value !== null) headers[name] = value;
|
|
44676
|
+
}
|
|
44677
|
+
reportRouting({ ...identity3, outcome: "served", headers });
|
|
44678
|
+
};
|
|
44679
|
+
return observeBody(response, report);
|
|
44680
|
+
}
|
|
44681
|
+
function observeBody(response, complete) {
|
|
44682
|
+
if (!response.body) {
|
|
44683
|
+
complete();
|
|
44684
|
+
return response;
|
|
44685
|
+
}
|
|
44686
|
+
const sse = response.headers.get("content-type")?.includes("text/event-stream");
|
|
44687
|
+
const reader = response.body.getReader();
|
|
44688
|
+
const decoder = new TextDecoder();
|
|
44689
|
+
let pending = "";
|
|
44690
|
+
let failed = false;
|
|
44691
|
+
const inspect = (line) => {
|
|
44692
|
+
if (line.length > 1024 * 1024) {
|
|
44693
|
+
failed = true;
|
|
44694
|
+
return;
|
|
44695
|
+
}
|
|
44696
|
+
if (line.startsWith("event:") && line.slice(6).trim() === "error")
|
|
44697
|
+
failed = true;
|
|
44698
|
+
if (!line.startsWith("data:") || !/"(?:error|response.failed|failed)"/.test(line))
|
|
44699
|
+
return;
|
|
44700
|
+
try {
|
|
44701
|
+
failed ||= streamFailure(JSON.parse(line.slice(5)));
|
|
44702
|
+
} catch {
|
|
44703
|
+
failed = true;
|
|
44704
|
+
}
|
|
44705
|
+
};
|
|
44706
|
+
const body = new ReadableStream(
|
|
44707
|
+
{
|
|
44708
|
+
async pull(controller) {
|
|
44709
|
+
try {
|
|
44710
|
+
const chunk = await reader.read();
|
|
44711
|
+
if (chunk.done) {
|
|
44712
|
+
if (sse) inspect(pending + decoder.decode());
|
|
44713
|
+
else if (/"(?:error|response.failed|failed)"/.test(pending)) {
|
|
44714
|
+
try {
|
|
44715
|
+
failed ||= streamFailure(JSON.parse(pending + decoder.decode()));
|
|
44716
|
+
} catch {
|
|
44717
|
+
failed = true;
|
|
44718
|
+
}
|
|
44719
|
+
}
|
|
44720
|
+
if (!failed) complete();
|
|
44721
|
+
controller.close();
|
|
44722
|
+
reader.releaseLock();
|
|
44723
|
+
return;
|
|
44724
|
+
}
|
|
44725
|
+
if (!failed) {
|
|
44726
|
+
pending += decoder.decode(chunk.value, { stream: true });
|
|
44727
|
+
if (sse) {
|
|
44728
|
+
let newline = pending.indexOf("\n");
|
|
44729
|
+
while (newline >= 0) {
|
|
44730
|
+
inspect(pending.slice(0, newline));
|
|
44731
|
+
pending = pending.slice(newline + 1);
|
|
44732
|
+
newline = pending.indexOf("\n");
|
|
44733
|
+
}
|
|
44734
|
+
}
|
|
44735
|
+
if (pending.length > 1024 * 1024) {
|
|
44736
|
+
failed = true;
|
|
44737
|
+
pending = "";
|
|
44738
|
+
}
|
|
44739
|
+
}
|
|
44740
|
+
controller.enqueue(chunk.value);
|
|
44741
|
+
} catch (error) {
|
|
44742
|
+
failed = true;
|
|
44743
|
+
controller.error(error);
|
|
44744
|
+
reader.releaseLock();
|
|
44745
|
+
}
|
|
44746
|
+
},
|
|
44747
|
+
async cancel(reason) {
|
|
44748
|
+
failed = true;
|
|
44749
|
+
try {
|
|
44750
|
+
await reader.cancel(reason);
|
|
44751
|
+
} finally {
|
|
44752
|
+
reader.releaseLock();
|
|
44753
|
+
}
|
|
44754
|
+
}
|
|
44755
|
+
},
|
|
44756
|
+
{ highWaterMark: 0 }
|
|
44757
|
+
);
|
|
44758
|
+
const observed = new Response(body, {
|
|
44759
|
+
status: response.status,
|
|
44760
|
+
statusText: response.statusText,
|
|
44761
|
+
headers: response.headers
|
|
44762
|
+
});
|
|
44763
|
+
Object.defineProperties(observed, {
|
|
44764
|
+
url: { value: response.url },
|
|
44765
|
+
redirected: { value: response.redirected }
|
|
44766
|
+
});
|
|
44767
|
+
return observed;
|
|
44768
|
+
}
|
|
44769
|
+
|
|
44770
|
+
// src/plugin/shared/vault-routing-purpose.ts
|
|
44771
|
+
var VAULT_ROUTING_PURPOSE_HEADER = "x-antigravity-internal-request-purpose";
|
|
44772
|
+
function createVaultRoutingHeaders(providerId) {
|
|
44773
|
+
return async (input2, output2) => {
|
|
44774
|
+
if (input2.model.providerID !== providerId) return;
|
|
44775
|
+
output2.headers[VAULT_ROUTING_PURPOSE_HEADER] = input2.agent === "build" || input2.agent === "plan" ? "primary" : "auxiliary";
|
|
44776
|
+
};
|
|
44777
|
+
}
|
|
44778
|
+
function isPrimaryVaultRequest(kind, headers) {
|
|
44779
|
+
return kind === void 0 ? new Headers(headers).get(VAULT_ROUTING_PURPOSE_HEADER) === "primary" : kind === "primary";
|
|
44780
|
+
}
|
|
44781
|
+
|
|
44371
44782
|
// src/plugin/shared/request-services.ts
|
|
44372
44783
|
var FIRST_RETRY_DELAY_MS = 1e3;
|
|
44373
44784
|
function prepareAgyWireRequest(wire, request) {
|
|
@@ -44464,7 +44875,7 @@ function formatWaitTime(ms) {
|
|
|
44464
44875
|
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
|
|
44465
44876
|
}
|
|
44466
44877
|
function sleep4(ms, signal) {
|
|
44467
|
-
return new Promise((
|
|
44878
|
+
return new Promise((resolve28, reject) => {
|
|
44468
44879
|
if (signal?.aborted) {
|
|
44469
44880
|
reject(
|
|
44470
44881
|
signal.reason instanceof Error ? signal.reason : new Error("Aborted")
|
|
@@ -44473,7 +44884,7 @@ function sleep4(ms, signal) {
|
|
|
44473
44884
|
}
|
|
44474
44885
|
const timeout = setTimeout(() => {
|
|
44475
44886
|
cleanup2();
|
|
44476
|
-
|
|
44887
|
+
resolve28();
|
|
44477
44888
|
}, ms);
|
|
44478
44889
|
const onAbort = () => {
|
|
44479
44890
|
cleanup2();
|
|
@@ -44488,7 +44899,7 @@ function sleep4(ms, signal) {
|
|
|
44488
44899
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
44489
44900
|
});
|
|
44490
44901
|
}
|
|
44491
|
-
function createLocalQuotaRefresh(accountManager, quotaManager,
|
|
44902
|
+
function createLocalQuotaRefresh(accountManager, quotaManager, log17) {
|
|
44492
44903
|
return async function refreshQuotaAfterSuccess(account, intervalMinutes, signal) {
|
|
44493
44904
|
if (intervalMinutes <= 0) return;
|
|
44494
44905
|
const accountIndex = accountManager.getAccounts().indexOf(account);
|
|
@@ -44519,7 +44930,7 @@ function createLocalQuotaRefresh(accountManager, quotaManager, log16) {
|
|
|
44519
44930
|
accountManager.requestSaveToDisk();
|
|
44520
44931
|
}
|
|
44521
44932
|
} catch (err) {
|
|
44522
|
-
|
|
44933
|
+
log17.debug(
|
|
44523
44934
|
`quota-refresh-failed ${singleAccount ? quotaManager.hashedLogLabel("account", singleAccount) : `idx-${accountIndex}`}`,
|
|
44524
44935
|
{ error: String(err) }
|
|
44525
44936
|
);
|
|
@@ -44537,7 +44948,7 @@ function createRequestExecutor(deps) {
|
|
|
44537
44948
|
wire,
|
|
44538
44949
|
debug,
|
|
44539
44950
|
dump,
|
|
44540
|
-
logger:
|
|
44951
|
+
logger: log17,
|
|
44541
44952
|
trackers,
|
|
44542
44953
|
classifyAccessError,
|
|
44543
44954
|
notify,
|
|
@@ -44556,15 +44967,15 @@ function createRequestExecutor(deps) {
|
|
|
44556
44967
|
const reportVault401 = (admission, status) => {
|
|
44557
44968
|
if (!admission || status !== 401) return;
|
|
44558
44969
|
void Promise.resolve().then(() => admission.report401(status)).catch((error) => {
|
|
44559
|
-
|
|
44970
|
+
log17.debug("send-admission-401-report-failed", { error: String(error) });
|
|
44560
44971
|
});
|
|
44561
44972
|
};
|
|
44562
|
-
const
|
|
44973
|
+
const reportRouting2 = (sessionId, entry) => {
|
|
44563
44974
|
if (!onRouting) return;
|
|
44564
44975
|
try {
|
|
44565
44976
|
onRouting(sessionId, entry);
|
|
44566
44977
|
} catch (error) {
|
|
44567
|
-
|
|
44978
|
+
log17.debug("routing-report-failed", { sessionId, error: String(error) });
|
|
44568
44979
|
}
|
|
44569
44980
|
};
|
|
44570
44981
|
async function execute(input2, init, options, selectedCredentials, selectedProjectIds, deadline, waitPolicy) {
|
|
@@ -44695,7 +45106,7 @@ function createRequestExecutor(deps) {
|
|
|
44695
45106
|
const quietMode = config.quiet_mode;
|
|
44696
45107
|
const toastScope = config.toast_scope;
|
|
44697
45108
|
const showToast = async (message, variant2) => {
|
|
44698
|
-
|
|
45109
|
+
log17.debug("toast", {
|
|
44699
45110
|
message,
|
|
44700
45111
|
variant: variant2,
|
|
44701
45112
|
isChildSession: isChildRequest,
|
|
@@ -44704,7 +45115,7 @@ function createRequestExecutor(deps) {
|
|
|
44704
45115
|
if (quietMode) return;
|
|
44705
45116
|
if (abortSignal?.aborted) return;
|
|
44706
45117
|
if (toastScope === "root_only" && isChildRequest) {
|
|
44707
|
-
|
|
45118
|
+
log17.debug("toast-suppressed-child-session", {
|
|
44708
45119
|
message,
|
|
44709
45120
|
variant: variant2,
|
|
44710
45121
|
parentID: requestSessionIdentity.parentSessionId
|
|
@@ -44730,6 +45141,7 @@ function createRequestExecutor(deps) {
|
|
|
44730
45141
|
const maxWaitMs = (config.max_rate_limit_wait_seconds ?? 300) * 1e3;
|
|
44731
45142
|
let allAccountsBlockedAt;
|
|
44732
45143
|
const modelUnavailableIndexes = /* @__PURE__ */ new Set();
|
|
45144
|
+
let routingPlacementConsidered = false;
|
|
44733
45145
|
while (true) {
|
|
44734
45146
|
await assertAdmission();
|
|
44735
45147
|
checkAborted();
|
|
@@ -44776,7 +45188,7 @@ function createRequestExecutor(deps) {
|
|
|
44776
45188
|
});
|
|
44777
45189
|
} catch (error) {
|
|
44778
45190
|
if (error instanceof AntigravityKillswitchError) {
|
|
44779
|
-
|
|
45191
|
+
log17.warn("killswitch-all-excluded", {
|
|
44780
45192
|
family,
|
|
44781
45193
|
model,
|
|
44782
45194
|
threshold: error.thresholdPercent,
|
|
@@ -44801,7 +45213,7 @@ function createRequestExecutor(deps) {
|
|
|
44801
45213
|
pushDebug(
|
|
44802
45214
|
`model-unavailable: all ${candidates.length} eligible account(s) skipped`
|
|
44803
45215
|
);
|
|
44804
|
-
|
|
45216
|
+
log17.warn("model-unavailable-all-accounts", {
|
|
44805
45217
|
family,
|
|
44806
45218
|
model,
|
|
44807
45219
|
accounts: candidates.length
|
|
@@ -44813,6 +45225,11 @@ function createRequestExecutor(deps) {
|
|
|
44813
45225
|
}
|
|
44814
45226
|
}
|
|
44815
45227
|
const excludedIndexes = modelUnavailableIndexes.size === 0 ? killedIndexes : /* @__PURE__ */ new Set([...killedIndexes ?? [], ...modelUnavailableIndexes]);
|
|
45228
|
+
const routingPresent = credentials.domain === "vault" && hasVaultRoutingAccessor();
|
|
45229
|
+
const firstPlacement = routingPresent && !routingPlacementConsidered && accountSessionIdentity && !accountManager.getCurrentAccountForFamily(
|
|
45230
|
+
family,
|
|
45231
|
+
accountSessionIdentity
|
|
45232
|
+
);
|
|
44816
45233
|
let account = accountManager.getCurrentOrNextForFamily(
|
|
44817
45234
|
family,
|
|
44818
45235
|
model,
|
|
@@ -44823,6 +45240,50 @@ function createRequestExecutor(deps) {
|
|
|
44823
45240
|
accountSessionIdentity,
|
|
44824
45241
|
excludedIndexes
|
|
44825
45242
|
);
|
|
45243
|
+
if (account) {
|
|
45244
|
+
routingPlacementConsidered = true;
|
|
45245
|
+
if (firstPlacement && credentials.domain === "vault" && credentials.routingCandidate && model && isPrimaryVaultRequest(kind, init?.headers)) {
|
|
45246
|
+
const candidates = accountManager.getEnabledAccounts().filter(
|
|
45247
|
+
(row) => !excludedIndexes?.has(row.index) && !accountManager.isRateLimited(row, family, model) && !accountManager.isAccountCoolingDown(row) && !accountManager.isAccountOverSoftQuota(
|
|
45248
|
+
row,
|
|
45249
|
+
family,
|
|
45250
|
+
config.soft_quota_threshold_percent,
|
|
45251
|
+
softQuotaCacheTtlMs,
|
|
45252
|
+
model
|
|
45253
|
+
)
|
|
45254
|
+
).map((row) => ({
|
|
45255
|
+
...credentials.routingCandidate(row),
|
|
45256
|
+
index: row.index
|
|
45257
|
+
}));
|
|
45258
|
+
if (candidates.length > 0) {
|
|
45259
|
+
const answer = await deadline.wait(
|
|
45260
|
+
() => askRouting({
|
|
45261
|
+
sessionId: accountSessionIdentity.id,
|
|
45262
|
+
provider: "antigravity",
|
|
45263
|
+
modelId: model,
|
|
45264
|
+
candidates,
|
|
45265
|
+
deadlineMs: Math.min(500, deadline.remainingMs())
|
|
45266
|
+
})
|
|
45267
|
+
);
|
|
45268
|
+
checkAborted();
|
|
45269
|
+
if (answer && answer.candidate.index !== account.index) {
|
|
45270
|
+
account = accountManager.getCurrentOrNextForFamily(
|
|
45271
|
+
family,
|
|
45272
|
+
model,
|
|
45273
|
+
config.account_selection_strategy,
|
|
45274
|
+
config.pid_offset_enabled,
|
|
45275
|
+
config.soft_quota_threshold_percent,
|
|
45276
|
+
softQuotaCacheTtlMs,
|
|
45277
|
+
accountSessionIdentity,
|
|
45278
|
+
/* @__PURE__ */ new Set([
|
|
45279
|
+
...excludedIndexes ?? [],
|
|
45280
|
+
...accountManager.getAccounts().filter((row) => row.index !== answer.candidate.index).map((row) => row.index)
|
|
45281
|
+
])
|
|
45282
|
+
) ?? account;
|
|
45283
|
+
}
|
|
45284
|
+
}
|
|
45285
|
+
}
|
|
45286
|
+
}
|
|
44826
45287
|
if (account && eligibleIndexes !== null && !eligibleIndexes.has(account.index)) {
|
|
44827
45288
|
pushDebug(
|
|
44828
45289
|
`killswitch-excluded idx=${account.index} (precomputed eligible set)`
|
|
@@ -44991,7 +45452,7 @@ function createRequestExecutor(deps) {
|
|
|
44991
45452
|
await deadline.wait(() => credentials.saveToDisk());
|
|
44992
45453
|
} catch (error) {
|
|
44993
45454
|
checkAborted();
|
|
44994
|
-
|
|
45455
|
+
log17.error("Failed to persist project context", {
|
|
44995
45456
|
error: String(error)
|
|
44996
45457
|
});
|
|
44997
45458
|
}
|
|
@@ -45048,7 +45509,7 @@ function createRequestExecutor(deps) {
|
|
|
45048
45509
|
await deadline.wait(() => credentials.saveToDisk());
|
|
45049
45510
|
} catch (error) {
|
|
45050
45511
|
checkAborted();
|
|
45051
|
-
|
|
45512
|
+
log17.error("Failed to persist refreshed auth", {
|
|
45052
45513
|
error: String(error)
|
|
45053
45514
|
});
|
|
45054
45515
|
}
|
|
@@ -45057,14 +45518,14 @@ function createRequestExecutor(deps) {
|
|
|
45057
45518
|
if (credentials.isInvalidGrant(error)) {
|
|
45058
45519
|
const removed = credentials.removeAccount(account);
|
|
45059
45520
|
if (removed) {
|
|
45060
|
-
|
|
45521
|
+
log17.warn(
|
|
45061
45522
|
"Removed revoked account from pool - reauthenticate via `opencode auth login`"
|
|
45062
45523
|
);
|
|
45063
45524
|
try {
|
|
45064
45525
|
await deadline.wait(() => credentials.saveToDiskReplace());
|
|
45065
45526
|
} catch (persistError) {
|
|
45066
45527
|
checkAborted();
|
|
45067
|
-
|
|
45528
|
+
log17.error("Failed to persist revoked account removal", {
|
|
45068
45529
|
error: String(persistError)
|
|
45069
45530
|
});
|
|
45070
45531
|
}
|
|
@@ -45074,7 +45535,7 @@ function createRequestExecutor(deps) {
|
|
|
45074
45535
|
await deadline.wait(() => credentials.clearStoredAuth());
|
|
45075
45536
|
} catch (storeError) {
|
|
45076
45537
|
checkAborted();
|
|
45077
|
-
|
|
45538
|
+
log17.error(
|
|
45078
45539
|
"Failed to clear stored Antigravity OAuth credentials",
|
|
45079
45540
|
{
|
|
45080
45541
|
error: String(storeError)
|
|
@@ -45468,7 +45929,7 @@ function createRequestExecutor(deps) {
|
|
|
45468
45929
|
);
|
|
45469
45930
|
} catch (error) {
|
|
45470
45931
|
checkAborted();
|
|
45471
|
-
|
|
45932
|
+
log17.debug("send-admission-401-report-failed", {
|
|
45472
45933
|
error: String(error)
|
|
45473
45934
|
});
|
|
45474
45935
|
}
|
|
@@ -45482,7 +45943,7 @@ function createRequestExecutor(deps) {
|
|
|
45482
45943
|
strategy: config.account_selection_strategy,
|
|
45483
45944
|
updatedAt: Date.now()
|
|
45484
45945
|
};
|
|
45485
|
-
|
|
45946
|
+
reportRouting2(sessionKey, routingEntry);
|
|
45486
45947
|
}
|
|
45487
45948
|
if (response.status === 429 || response.status === 503 || response.status === 529) {
|
|
45488
45949
|
if (tokenConsumed) {
|
|
@@ -45517,6 +45978,26 @@ function createRequestExecutor(deps) {
|
|
|
45517
45978
|
reasonInfo.message,
|
|
45518
45979
|
response.status
|
|
45519
45980
|
);
|
|
45981
|
+
if (credentials.domain === "vault" && sendAdmission && sessionKey && hasVaultRoutingAccessor()) {
|
|
45982
|
+
const group = resolveQuotaGroup(
|
|
45983
|
+
family,
|
|
45984
|
+
model,
|
|
45985
|
+
account.cachedQuota
|
|
45986
|
+
);
|
|
45987
|
+
reportVaultExhaustion({
|
|
45988
|
+
identity: {
|
|
45989
|
+
sessionId: sessionKey,
|
|
45990
|
+
accountId: sendAdmission.accountIdentity,
|
|
45991
|
+
credentialId: sendAdmission.credentialId
|
|
45992
|
+
},
|
|
45993
|
+
status: response.status,
|
|
45994
|
+
reason: rateLimitReason,
|
|
45995
|
+
group,
|
|
45996
|
+
quota: account.cachedQuota?.[group],
|
|
45997
|
+
observedAt: account.cachedQuotaUpdatedAt,
|
|
45998
|
+
signal: abortSignal
|
|
45999
|
+
});
|
|
46000
|
+
}
|
|
45520
46001
|
if (rateLimitReason === "MODEL_CAPACITY_EXHAUSTED" || rateLimitReason === "SERVER_ERROR") {
|
|
45521
46002
|
totalCapacityRetries++;
|
|
45522
46003
|
if (isCapacityRetryBudgetExhausted(totalCapacityRetries)) {
|
|
@@ -45685,7 +46166,7 @@ function createRequestExecutor(deps) {
|
|
|
45685
46166
|
debug.logAntigravityDebugResponse(debugContext, response, {
|
|
45686
46167
|
note
|
|
45687
46168
|
});
|
|
45688
|
-
|
|
46169
|
+
log17.info("model-unavailable", {
|
|
45689
46170
|
accountIndex: account.index,
|
|
45690
46171
|
family,
|
|
45691
46172
|
model,
|
|
@@ -45854,9 +46335,10 @@ function createRequestExecutor(deps) {
|
|
|
45854
46335
|
const _emptyAttemptKeyClean = `${prepared.sessionId ?? "none"}:${prepared.effectiveModel ?? "unknown"}`;
|
|
45855
46336
|
retryState.clearEmptyResponseAttempts();
|
|
45856
46337
|
}
|
|
46338
|
+
const routingObservation = credentials.domain === "vault" && sendAdmission && sessionKey && response.ok && hasVaultRoutingAccessor() ? observeVaultUpstream(response, abortSignal) : void 0;
|
|
45857
46339
|
const transformedResponse = await deadline.wait(
|
|
45858
46340
|
() => wire.transformResponse(
|
|
45859
|
-
response,
|
|
46341
|
+
routingObservation?.response ?? response,
|
|
45860
46342
|
prepared.streaming,
|
|
45861
46343
|
debugContext,
|
|
45862
46344
|
prepared.requestedModel,
|
|
@@ -45928,7 +46410,16 @@ function createRequestExecutor(deps) {
|
|
|
45928
46410
|
const refresh = credentials.refreshQuotaAfterSuccess;
|
|
45929
46411
|
waitPolicy.quota = (signal) => refresh(account, config.quota_refresh_interval_minutes, signal);
|
|
45930
46412
|
}
|
|
45931
|
-
return
|
|
46413
|
+
return routingObservation && credentials.domain === "vault" && sendAdmission && sessionKey && hasVaultRoutingAccessor() && response.ok ? observeVaultServed(
|
|
46414
|
+
{
|
|
46415
|
+
sessionId: sessionKey,
|
|
46416
|
+
accountId: sendAdmission.accountIdentity,
|
|
46417
|
+
credentialId: sendAdmission.credentialId
|
|
46418
|
+
},
|
|
46419
|
+
transformedResponse,
|
|
46420
|
+
abortSignal,
|
|
46421
|
+
routingObservation
|
|
46422
|
+
) : transformedResponse;
|
|
45932
46423
|
} catch (error) {
|
|
45933
46424
|
if (error instanceof PreResponseTimeoutError) throw error;
|
|
45934
46425
|
checkAborted();
|
|
@@ -46130,11 +46621,11 @@ function createRequestExecutor(deps) {
|
|
|
46130
46621
|
cancellation.signal,
|
|
46131
46622
|
deps.preResponseClock
|
|
46132
46623
|
);
|
|
46133
|
-
|
|
46624
|
+
log17.debug("pre-response-start", { limitMs: PRE_RESPONSE_DEADLINE_MS });
|
|
46134
46625
|
const handoff = createAfterHandoff(
|
|
46135
46626
|
advisoryWork,
|
|
46136
46627
|
requestedSignal ? [requestedSignal, shutdown.signal] : [shutdown.signal],
|
|
46137
|
-
() =>
|
|
46628
|
+
() => log17.debug("post-response-advisory-work-failed")
|
|
46138
46629
|
);
|
|
46139
46630
|
const waitPolicy = {};
|
|
46140
46631
|
const selectedCredentials = /* @__PURE__ */ new Set();
|
|
@@ -46152,7 +46643,7 @@ function createRequestExecutor(deps) {
|
|
|
46152
46643
|
).catch((error) => {
|
|
46153
46644
|
cancellation.signal.throwIfAborted();
|
|
46154
46645
|
if (error instanceof PreResponseTimeoutError) {
|
|
46155
|
-
|
|
46646
|
+
log17.debug("pre-response-timeout", { reason: error.reason });
|
|
46156
46647
|
return waitPolicy.refusal?.() ?? preResponseTimeoutResponse();
|
|
46157
46648
|
}
|
|
46158
46649
|
throw error;
|
|
@@ -46646,7 +47137,7 @@ init_logger4();
|
|
|
46646
47137
|
|
|
46647
47138
|
// src/plugin/refresh-queue.ts
|
|
46648
47139
|
init_logger4();
|
|
46649
|
-
var
|
|
47140
|
+
var log11 = createLogger4("refresh-queue");
|
|
46650
47141
|
var DEFAULT_PROACTIVE_REFRESH_CONFIG = {
|
|
46651
47142
|
enabled: true,
|
|
46652
47143
|
bufferSeconds: 1800,
|
|
@@ -46686,7 +47177,7 @@ var ProactiveRefreshQueue = class {
|
|
|
46686
47177
|
"ProactiveRefreshQueue needs a host client or explicit dependencies"
|
|
46687
47178
|
);
|
|
46688
47179
|
}
|
|
46689
|
-
this.log =
|
|
47180
|
+
this.log = log11;
|
|
46690
47181
|
this.refresh = (auth) => refreshAccessToken(auth, client, providerId);
|
|
46691
47182
|
}
|
|
46692
47183
|
this.config = {
|
|
@@ -46995,7 +47486,7 @@ async function buildLocationRuntime(options, scope) {
|
|
|
46995
47486
|
sink: options.logSink,
|
|
46996
47487
|
sinkEnabled: () => config?.config.debug_tui === true
|
|
46997
47488
|
});
|
|
46998
|
-
const
|
|
47489
|
+
const log17 = logger3.createLogger("runtime");
|
|
46999
47490
|
config = createLocationConfig(options.directory, {
|
|
47000
47491
|
logger: logger3.createLogger("config")
|
|
47001
47492
|
});
|
|
@@ -47112,7 +47603,7 @@ async function buildLocationRuntime(options, scope) {
|
|
|
47112
47603
|
queue2.start();
|
|
47113
47604
|
});
|
|
47114
47605
|
accountChange = next.catch((error) => {
|
|
47115
|
-
|
|
47606
|
+
log17.warn("account view replacement failed", {
|
|
47116
47607
|
error: error instanceof Error ? error.message : String(error)
|
|
47117
47608
|
});
|
|
47118
47609
|
});
|
|
@@ -47556,7 +48047,7 @@ function createGaReauthorize(input2) {
|
|
|
47556
48047
|
const continuations = /* @__PURE__ */ new Set();
|
|
47557
48048
|
const shutdown = new AbortController();
|
|
47558
48049
|
let disposed = false;
|
|
47559
|
-
const waitForRedirect = (code2) => new Promise((
|
|
48050
|
+
const waitForRedirect = (code2) => new Promise((resolve28, reject) => {
|
|
47560
48051
|
const detach = () => shutdown.signal.removeEventListener("abort", abort);
|
|
47561
48052
|
const abort = () => {
|
|
47562
48053
|
detach();
|
|
@@ -47567,7 +48058,7 @@ function createGaReauthorize(input2) {
|
|
|
47567
48058
|
void code2.then(
|
|
47568
48059
|
(value) => {
|
|
47569
48060
|
detach();
|
|
47570
|
-
|
|
48061
|
+
resolve28(value);
|
|
47571
48062
|
},
|
|
47572
48063
|
(error) => {
|
|
47573
48064
|
detach();
|
|
@@ -48849,6 +49340,7 @@ var createGaLocationServices = (input2) => {
|
|
|
48849
49340
|
// src/ga/server/index.ts
|
|
48850
49341
|
init_storage();
|
|
48851
49342
|
init_process_heartbeat();
|
|
49343
|
+
init_vault_folder();
|
|
48852
49344
|
|
|
48853
49345
|
// src/ga/proxy-guard.ts
|
|
48854
49346
|
var DOCUMENTED_LOOPBACK_EXCLUSION = "NO_PROXY=127.0.0.1";
|
|
@@ -50222,17 +50714,18 @@ var OPENCODE2_VAULT_AUTH_LABEL = "Use approved Antigravity vault";
|
|
|
50222
50714
|
// src/ga/server/auth.ts
|
|
50223
50715
|
init_storage();
|
|
50224
50716
|
init_vault_custody();
|
|
50717
|
+
init_vault_folder();
|
|
50225
50718
|
|
|
50226
50719
|
// src/ga/server/pool-login.ts
|
|
50227
50720
|
init_dist();
|
|
50228
50721
|
var GA_POOL_METHOD_ID = "antigravity-auth-pool-browser";
|
|
50229
50722
|
var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
|
|
50230
50723
|
function abortable(pending, signal) {
|
|
50231
|
-
return new Promise((
|
|
50724
|
+
return new Promise((resolve28, reject) => {
|
|
50232
50725
|
const abort = () => reject(signal.reason);
|
|
50233
50726
|
if (signal.aborted) abort();
|
|
50234
50727
|
else signal.addEventListener("abort", abort, { once: true });
|
|
50235
|
-
void pending.then(
|
|
50728
|
+
void pending.then(resolve28, reject).finally(() => {
|
|
50236
50729
|
signal.removeEventListener("abort", abort);
|
|
50237
50730
|
});
|
|
50238
50731
|
});
|
|
@@ -50602,11 +51095,11 @@ async function startGaLoopbackBridge(options) {
|
|
|
50602
51095
|
}
|
|
50603
51096
|
}
|
|
50604
51097
|
};
|
|
50605
|
-
await new Promise((
|
|
51098
|
+
await new Promise((resolve28, reject) => {
|
|
50606
51099
|
server.once("error", reject);
|
|
50607
51100
|
server.listen(0, BRIDGE_HOST, () => {
|
|
50608
51101
|
server.off("error", reject);
|
|
50609
|
-
|
|
51102
|
+
resolve28();
|
|
50610
51103
|
});
|
|
50611
51104
|
});
|
|
50612
51105
|
server.unref();
|
|
@@ -50710,8 +51203,8 @@ async function startGaLoopbackBridge(options) {
|
|
|
50710
51203
|
disposal = (async () => {
|
|
50711
51204
|
for (const { timer } of queued.values()) clearTimeout(timer);
|
|
50712
51205
|
queued.clear();
|
|
50713
|
-
const closed2 = new Promise((
|
|
50714
|
-
server.close(() =>
|
|
51206
|
+
const closed2 = new Promise((resolve28) => {
|
|
51207
|
+
server.close(() => resolve28());
|
|
50715
51208
|
});
|
|
50716
51209
|
for (const controller of running) {
|
|
50717
51210
|
controller.abort(
|
|
@@ -50775,9 +51268,9 @@ async function pipeResponse(upstream, response, onFailure, onHandoff) {
|
|
|
50775
51268
|
return;
|
|
50776
51269
|
}
|
|
50777
51270
|
if (!response.write(value) && !response.destroyed) {
|
|
50778
|
-
await new Promise((
|
|
50779
|
-
response.once("drain",
|
|
50780
|
-
response.once("close",
|
|
51271
|
+
await new Promise((resolve28) => {
|
|
51272
|
+
response.once("drain", resolve28);
|
|
51273
|
+
response.once("close", resolve28);
|
|
50781
51274
|
});
|
|
50782
51275
|
}
|
|
50783
51276
|
if (response.destroyed) {
|
|
@@ -50818,30 +51311,30 @@ function classifyGaSetupContext(context) {
|
|
|
50818
51311
|
const location = record3.location;
|
|
50819
51312
|
if (session === void 0 && location === void 0) return "legacy";
|
|
50820
51313
|
const missing = [];
|
|
50821
|
-
if (!
|
|
51314
|
+
if (!isObject3(location) || typeof location.directory !== "string") {
|
|
50822
51315
|
missing.push("location.directory");
|
|
50823
51316
|
}
|
|
50824
|
-
if (!
|
|
51317
|
+
if (!isObject3(session) || typeof session.hook !== "function") {
|
|
50825
51318
|
missing.push("session.hook");
|
|
50826
51319
|
}
|
|
50827
51320
|
if (session !== void 0 && location !== void 0 && missing.length === 0) {
|
|
50828
51321
|
const rpc = record3.rpc;
|
|
50829
|
-
if (!
|
|
51322
|
+
if (!isObject3(rpc) && typeof rpc !== "function" || typeof Reflect.get(rpc, "register") !== "function") {
|
|
50830
51323
|
missing.push("rpc.register");
|
|
50831
51324
|
}
|
|
50832
51325
|
const provider2 = record3.provider;
|
|
50833
|
-
if (!
|
|
51326
|
+
if (!isObject3(provider2) || typeof provider2.transform !== "function") {
|
|
50834
51327
|
missing.push("provider.transform");
|
|
50835
51328
|
}
|
|
50836
51329
|
const command = record3.command;
|
|
50837
|
-
if (!
|
|
51330
|
+
if (!isObject3(command) || typeof command.transform !== "function") {
|
|
50838
51331
|
missing.push("command.transform");
|
|
50839
51332
|
}
|
|
50840
51333
|
}
|
|
50841
51334
|
if (missing.length > 0) throw new GaSetupContextError(missing);
|
|
50842
51335
|
return "ga";
|
|
50843
51336
|
}
|
|
50844
|
-
function
|
|
51337
|
+
function isObject3(value) {
|
|
50845
51338
|
return typeof value === "object" && value !== null;
|
|
50846
51339
|
}
|
|
50847
51340
|
function createGaGeneration() {
|
|
@@ -51448,13 +51941,13 @@ function createGaAntigravityPlugin(overrides = {}) {
|
|
|
51448
51941
|
// src/plugin/index.ts
|
|
51449
51942
|
init_dist();
|
|
51450
51943
|
import { createHash as createHash23, randomUUID as randomUUID22 } from "node:crypto";
|
|
51451
|
-
import { join as
|
|
51944
|
+
import { join as join39, resolve as resolve27 } from "node:path";
|
|
51452
51945
|
|
|
51453
51946
|
// src/cli.ts
|
|
51454
51947
|
init_dist();
|
|
51455
51948
|
import { execFile } from "node:child_process";
|
|
51456
51949
|
import { realpathSync as realpathSync5 } from "node:fs";
|
|
51457
|
-
import { resolve as
|
|
51950
|
+
import { resolve as resolve24 } from "node:path";
|
|
51458
51951
|
import { createInterface } from "node:readline/promises";
|
|
51459
51952
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
51460
51953
|
import { promisify } from "node:util";
|
|
@@ -51511,7 +52004,7 @@ init_runtime_paths();
|
|
|
51511
52004
|
// src/setup.ts
|
|
51512
52005
|
init_dist();
|
|
51513
52006
|
import { lstat as lstat9, readFile as readFile16 } from "node:fs/promises";
|
|
51514
|
-
import { join as
|
|
52007
|
+
import { join as join30, resolve as resolve23 } from "node:path";
|
|
51515
52008
|
|
|
51516
52009
|
// src/common-auth-embedded/auth-menu/ansi.js
|
|
51517
52010
|
var ANSI2 = {
|
|
@@ -51679,7 +52172,7 @@ async function select2(terminal, items, options) {
|
|
|
51679
52172
|
writeLine("");
|
|
51680
52173
|
renderedLines = lines;
|
|
51681
52174
|
};
|
|
51682
|
-
return new Promise((
|
|
52175
|
+
return new Promise((resolve28) => {
|
|
51683
52176
|
const wasRaw = stdin.isRaw ?? false;
|
|
51684
52177
|
const cleanup2 = () => {
|
|
51685
52178
|
if (cleaned)
|
|
@@ -51699,7 +52192,7 @@ async function select2(terminal, items, options) {
|
|
|
51699
52192
|
};
|
|
51700
52193
|
const finish = (value) => {
|
|
51701
52194
|
cleanup2();
|
|
51702
|
-
|
|
52195
|
+
resolve28(value);
|
|
51703
52196
|
};
|
|
51704
52197
|
const onSignal = () => finish(null);
|
|
51705
52198
|
const onKey = (data) => {
|
|
@@ -51739,7 +52232,7 @@ async function select2(terminal, items, options) {
|
|
|
51739
52232
|
stdin.setRawMode(true);
|
|
51740
52233
|
} catch {
|
|
51741
52234
|
cleanup2();
|
|
51742
|
-
|
|
52235
|
+
resolve28(null);
|
|
51743
52236
|
return;
|
|
51744
52237
|
}
|
|
51745
52238
|
stdin.resume();
|
|
@@ -51752,13 +52245,13 @@ async function select2(terminal, items, options) {
|
|
|
51752
52245
|
// src/common-auth-embedded/claustrum/enrollment.js
|
|
51753
52246
|
import { createHash as createHash18, randomBytes as randomBytes6, randomUUID as randomUUID19 } from "node:crypto";
|
|
51754
52247
|
import { constants as fsConstants2 } from "node:fs";
|
|
51755
|
-
import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as
|
|
51756
|
-
import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as
|
|
52248
|
+
import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as stat12, unlink as unlink11 } from "node:fs/promises";
|
|
52249
|
+
import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute4, join as join26, resolve as resolve22 } from "node:path";
|
|
51757
52250
|
import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
51758
52251
|
|
|
51759
52252
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
51760
52253
|
import { lstat as lstat7 } from "node:fs/promises";
|
|
51761
|
-
import { resolve as
|
|
52254
|
+
import { resolve as resolve21 } from "node:path";
|
|
51762
52255
|
async function identity2(path5) {
|
|
51763
52256
|
try {
|
|
51764
52257
|
const metadata = await lstat7(path5);
|
|
@@ -51775,7 +52268,7 @@ function sameIdentity2(left, right) {
|
|
|
51775
52268
|
var FileReadCache2 = class {
|
|
51776
52269
|
#entries = /* @__PURE__ */ new Map();
|
|
51777
52270
|
async read(paths, read, validateHit) {
|
|
51778
|
-
const resolvedPaths = paths.map((path5) =>
|
|
52271
|
+
const resolvedPaths = paths.map((path5) => resolve21(path5));
|
|
51779
52272
|
const key = JSON.stringify(resolvedPaths);
|
|
51780
52273
|
const probed = await Promise.all(resolvedPaths.map(identity2));
|
|
51781
52274
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -51826,10 +52319,11 @@ init_private_files2();
|
|
|
51826
52319
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
51827
52320
|
init_private_files2();
|
|
51828
52321
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
51829
|
-
import { lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as
|
|
51830
|
-
import { dirname as dirname21, join as
|
|
52322
|
+
import { lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as stat11 } from "node:fs/promises";
|
|
52323
|
+
import { dirname as dirname21, join as join25 } from "node:path";
|
|
51831
52324
|
|
|
51832
52325
|
// src/common-auth-embedded/fs/with-lock.js
|
|
52326
|
+
init_private_files2();
|
|
51833
52327
|
function lockPathFor2(target, name) {
|
|
51834
52328
|
return `${target}.${name}.lock`;
|
|
51835
52329
|
}
|
|
@@ -51887,7 +52381,7 @@ function acquireRefreshFileLock2(options) {
|
|
|
51887
52381
|
}
|
|
51888
52382
|
async function acquireRefreshFileLockWithClock2(options) {
|
|
51889
52383
|
const lockPath = lockPathFor2(options.path, options.name);
|
|
51890
|
-
const legacyOwnerPath =
|
|
52384
|
+
const legacyOwnerPath = join25(lockPath, "owner.json");
|
|
51891
52385
|
const ownerId = randomUUID18();
|
|
51892
52386
|
const now = options.now ?? Date.now;
|
|
51893
52387
|
let renewTimer = null;
|
|
@@ -51895,8 +52389,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
51895
52389
|
let releaseConfirmed = false;
|
|
51896
52390
|
let loss;
|
|
51897
52391
|
let resolveLoss;
|
|
51898
|
-
const lostPromise = new Promise((
|
|
51899
|
-
resolveLoss =
|
|
52392
|
+
const lostPromise = new Promise((resolve28) => {
|
|
52393
|
+
resolveLoss = resolve28;
|
|
51900
52394
|
});
|
|
51901
52395
|
function notifyTimerStep(event) {
|
|
51902
52396
|
try {
|
|
@@ -51930,7 +52424,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
51930
52424
|
let terminalIOError;
|
|
51931
52425
|
let renewalInFlight = null;
|
|
51932
52426
|
const evictPath = `${lockPath}.evicting`;
|
|
51933
|
-
const evictOwnerPath =
|
|
52427
|
+
const evictOwnerPath = join25(evictPath, "owner.json");
|
|
51934
52428
|
const evictOwnerId = randomUUID18();
|
|
51935
52429
|
const EVICT_TTL = 5e3;
|
|
51936
52430
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
@@ -52057,7 +52551,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
52057
52551
|
}
|
|
52058
52552
|
}
|
|
52059
52553
|
async function backoff() {
|
|
52060
|
-
await new Promise((
|
|
52554
|
+
await new Promise((resolve28) => setTimeout(resolve28, Math.floor(Math.random() * 4)));
|
|
52061
52555
|
}
|
|
52062
52556
|
async function readLockState(notifyReady = true) {
|
|
52063
52557
|
if (notifyReady && options.onStep)
|
|
@@ -52079,7 +52573,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
52079
52573
|
};
|
|
52080
52574
|
}
|
|
52081
52575
|
try {
|
|
52082
|
-
const current = await
|
|
52576
|
+
const current = await stat11(lockPath);
|
|
52083
52577
|
const legacyExpiry = Number.isFinite(expiresAt) ? expiresAt : current.mtimeMs + options.ttlMs;
|
|
52084
52578
|
if (legacyExpiry > now())
|
|
52085
52579
|
return { status: "live" };
|
|
@@ -52146,7 +52640,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
52146
52640
|
if (!sameMarkerDirectory2(created, current))
|
|
52147
52641
|
return false;
|
|
52148
52642
|
try {
|
|
52149
|
-
await
|
|
52643
|
+
await stat11(evictOwnerPath);
|
|
52150
52644
|
return true;
|
|
52151
52645
|
} catch (error) {
|
|
52152
52646
|
if (error.code !== "ENOENT")
|
|
@@ -52198,7 +52692,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
52198
52692
|
async function recoverStaleEvictionMarker() {
|
|
52199
52693
|
let evictStat;
|
|
52200
52694
|
try {
|
|
52201
|
-
evictStat = await
|
|
52695
|
+
evictStat = await stat11(evictPath);
|
|
52202
52696
|
} catch (error) {
|
|
52203
52697
|
if (error.code === "ENOENT")
|
|
52204
52698
|
return "missing";
|
|
@@ -52216,7 +52710,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
52216
52710
|
if (evictStat.mtimeMs + EVICT_TTL > now()) {
|
|
52217
52711
|
let hasOwner = true;
|
|
52218
52712
|
try {
|
|
52219
|
-
await
|
|
52713
|
+
await stat11(evictOwnerPath);
|
|
52220
52714
|
} catch (error) {
|
|
52221
52715
|
if (error.code === "ENOENT")
|
|
52222
52716
|
hasOwner = false;
|
|
@@ -52547,7 +53041,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
52547
53041
|
const remainingMs = deadline - performance.now();
|
|
52548
53042
|
if (remainingMs <= 0)
|
|
52549
53043
|
break;
|
|
52550
|
-
await new Promise((
|
|
53044
|
+
await new Promise((resolve28) => setTimeout(resolve28, Math.min(delayMs, remainingMs)));
|
|
52551
53045
|
delayMs = Math.min(delayMs * 2, 50);
|
|
52552
53046
|
}
|
|
52553
53047
|
if (windowsPrivateFiles2)
|
|
@@ -52612,15 +53106,15 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
|
|
|
52612
53106
|
const extension = extname2(tokenPath) || ".json";
|
|
52613
53107
|
const stem = basename6(tokenPath, extname2(tokenPath));
|
|
52614
53108
|
return {
|
|
52615
|
-
statePath:
|
|
53109
|
+
statePath: join26(dirname22(tokenPath), `${stem}-state${extension}`),
|
|
52616
53110
|
tokenPath
|
|
52617
53111
|
};
|
|
52618
53112
|
}
|
|
52619
53113
|
function hostEnrollmentPaths2(input2) {
|
|
52620
53114
|
const override = input2.override?.trim();
|
|
52621
|
-
if (override && !
|
|
53115
|
+
if (override && !isAbsolute4(override) && !input2.cwd)
|
|
52622
53116
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
52623
|
-
const tokenPath = override ?
|
|
53117
|
+
const tokenPath = override ? isAbsolute4(override) ? override : resolve22(input2.cwd, override) : join26(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
52624
53118
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
52625
53119
|
}
|
|
52626
53120
|
function isRecord11(value) {
|
|
@@ -52805,7 +53299,7 @@ async function refuseWritableAncestor2(parent, options = {}) {
|
|
|
52805
53299
|
}
|
|
52806
53300
|
let privateGroup;
|
|
52807
53301
|
for (; ; ) {
|
|
52808
|
-
const metadata = await
|
|
53302
|
+
const metadata = await stat12(component).catch(() => void 0);
|
|
52809
53303
|
if (metadata && (metadata.mode & 18) !== 0 && (metadata.mode & 512) === 0) {
|
|
52810
53304
|
if (privateGroup === void 0) {
|
|
52811
53305
|
privateGroup = gid !== void 0 && await isPrivateGroup2(uid, gid, options);
|
|
@@ -52834,7 +53328,7 @@ async function ensureClaustrumPrivateDirectory2(directory, options = {}, what =
|
|
|
52834
53328
|
return;
|
|
52835
53329
|
}
|
|
52836
53330
|
await mkdir15(directory, { recursive: true, mode: 448 });
|
|
52837
|
-
const metadata = await
|
|
53331
|
+
const metadata = await stat12(directory);
|
|
52838
53332
|
const uid = process.geteuid?.();
|
|
52839
53333
|
if (uid !== void 0 && metadata.uid !== uid) {
|
|
52840
53334
|
throw new ClaustrumConsumerError2("unsafe-file", `Claustrum ${what} must be owned by the current user`);
|
|
@@ -52853,7 +53347,7 @@ async function writeStateAtomic2(path5, state, ancestorOptions = {}) {
|
|
|
52853
53347
|
}
|
|
52854
53348
|
if (windowsPrivateFiles2)
|
|
52855
53349
|
return writePrivateAtomic2(path5, bytes);
|
|
52856
|
-
const temporary =
|
|
53350
|
+
const temporary = join26(parent, `.${basename6(path5)}.${process.pid}.${randomUUID19()}.tmp`);
|
|
52857
53351
|
let descriptor;
|
|
52858
53352
|
let created = false;
|
|
52859
53353
|
try {
|
|
@@ -52870,7 +53364,7 @@ async function writeStateAtomic2(path5, state, ancestorOptions = {}) {
|
|
|
52870
53364
|
await descriptor?.close().catch(() => {
|
|
52871
53365
|
});
|
|
52872
53366
|
if (created)
|
|
52873
|
-
await
|
|
53367
|
+
await unlink11(temporary).catch(() => {
|
|
52874
53368
|
});
|
|
52875
53369
|
}
|
|
52876
53370
|
}
|
|
@@ -53097,7 +53591,7 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
53097
53591
|
}
|
|
53098
53592
|
if (refusal3.code === UNSUPPORTED_ENROLLMENT_CODE2) {
|
|
53099
53593
|
await lock.assertOwned();
|
|
53100
|
-
await
|
|
53594
|
+
await unlink11(this.#paths.statePath).catch((cause) => {
|
|
53101
53595
|
if (cause.code !== "ENOENT")
|
|
53102
53596
|
throw cause;
|
|
53103
53597
|
});
|
|
@@ -53187,7 +53681,7 @@ async function resetClaustrumEnrollmentState2(paths, proposedName) {
|
|
|
53187
53681
|
if (state.phase === "pending")
|
|
53188
53682
|
return "refused-pending";
|
|
53189
53683
|
await lock.assertOwned();
|
|
53190
|
-
await
|
|
53684
|
+
await unlink11(paths.statePath);
|
|
53191
53685
|
return "reset";
|
|
53192
53686
|
} finally {
|
|
53193
53687
|
await lock.release();
|
|
@@ -53248,7 +53742,7 @@ var ByteTail = class {
|
|
|
53248
53742
|
};
|
|
53249
53743
|
var defaultCommandRunner = {
|
|
53250
53744
|
run(file, args, options = {}) {
|
|
53251
|
-
return new Promise((
|
|
53745
|
+
return new Promise((resolve28) => {
|
|
53252
53746
|
const started = performance.now();
|
|
53253
53747
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
53254
53748
|
const stderr = new ByteTail();
|
|
@@ -53266,7 +53760,7 @@ var defaultCommandRunner = {
|
|
|
53266
53760
|
stdio: ["ignore", "pipe", "pipe"]
|
|
53267
53761
|
});
|
|
53268
53762
|
} catch {
|
|
53269
|
-
|
|
53763
|
+
resolve28({
|
|
53270
53764
|
exitCode: 1,
|
|
53271
53765
|
stdout: "",
|
|
53272
53766
|
stderr: "",
|
|
@@ -53301,7 +53795,7 @@ var defaultCommandRunner = {
|
|
|
53301
53795
|
settled = true;
|
|
53302
53796
|
if (timer)
|
|
53303
53797
|
clearTimeout(timer);
|
|
53304
|
-
|
|
53798
|
+
resolve28({
|
|
53305
53799
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
53306
53800
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
53307
53801
|
stderr: stderr.toString(),
|
|
@@ -53388,7 +53882,7 @@ function recordSetupEnrollment(failure2, enrollment) {
|
|
|
53388
53882
|
import { accessSync, constants as constants3, existsSync as existsSync12, readFileSync as readFileSync10, realpathSync as realpathSync4, statSync as statSync5 } from "node:fs";
|
|
53389
53883
|
import { mkdtemp, rm as rm7 } from "node:fs/promises";
|
|
53390
53884
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
53391
|
-
import { join as
|
|
53885
|
+
import { join as join27 } from "node:path";
|
|
53392
53886
|
import { parse } from "jsonc-parser";
|
|
53393
53887
|
|
|
53394
53888
|
// src/common-auth-embedded/setup/paths.js
|
|
@@ -53423,7 +53917,7 @@ function setupPaths(io = {}) {
|
|
|
53423
53917
|
}
|
|
53424
53918
|
|
|
53425
53919
|
// src/common-auth-embedded/setup/detect.js
|
|
53426
|
-
function
|
|
53920
|
+
function stat13(path5, kind) {
|
|
53427
53921
|
try {
|
|
53428
53922
|
return statSync5(path5)[kind]();
|
|
53429
53923
|
} catch {
|
|
@@ -53432,12 +53926,12 @@ function stat12(path5, kind) {
|
|
|
53432
53926
|
}
|
|
53433
53927
|
var defaultSetupFileSystem = {
|
|
53434
53928
|
exists: existsSync12,
|
|
53435
|
-
isFile: (path5) =>
|
|
53436
|
-
isDirectory: (path5) =>
|
|
53929
|
+
isFile: (path5) => stat13(path5, "isFile"),
|
|
53930
|
+
isDirectory: (path5) => stat13(path5, "isDirectory"),
|
|
53437
53931
|
isExecutable(path5) {
|
|
53438
53932
|
try {
|
|
53439
53933
|
accessSync(path5, constants3.X_OK);
|
|
53440
|
-
return
|
|
53934
|
+
return stat13(path5, "isFile");
|
|
53441
53935
|
} catch {
|
|
53442
53936
|
return false;
|
|
53443
53937
|
}
|
|
@@ -53559,7 +54053,7 @@ async function detectHosts(plugin2, io = {}) {
|
|
|
53559
54053
|
return null;
|
|
53560
54054
|
let root;
|
|
53561
54055
|
try {
|
|
53562
|
-
root = await mkdtemp(
|
|
54056
|
+
root = await mkdtemp(join27(tmpdir5(), "common-auth-setup-version-"));
|
|
53563
54057
|
const probeEnv = {
|
|
53564
54058
|
...env3,
|
|
53565
54059
|
HOME: root,
|
|
@@ -54143,8 +54637,8 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
|
|
|
54143
54637
|
|
|
54144
54638
|
// src/common-auth-embedded/setup/config-write.js
|
|
54145
54639
|
import { randomUUID as randomUUID20 } from "node:crypto";
|
|
54146
|
-
import { mkdir as mkdir16, open as open11, rename as rename13, stat as
|
|
54147
|
-
import { basename as basename7, dirname as dirname23, join as
|
|
54640
|
+
import { mkdir as mkdir16, open as open11, rename as rename13, stat as stat14, unlink as unlink12 } from "node:fs/promises";
|
|
54641
|
+
import { basename as basename7, dirname as dirname23, join as join28 } from "node:path";
|
|
54148
54642
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
54149
54643
|
async function writeHostConfigAtomic(file, content, options = {}) {
|
|
54150
54644
|
const windows2 = (options.platform ?? process.platform) === "win32";
|
|
@@ -54153,13 +54647,13 @@ async function writeHostConfigAtomic(file, content, options = {}) {
|
|
|
54153
54647
|
let mode;
|
|
54154
54648
|
if (!windows2) {
|
|
54155
54649
|
try {
|
|
54156
|
-
mode = (await
|
|
54650
|
+
mode = (await stat14(file)).mode & 4095;
|
|
54157
54651
|
} catch (error) {
|
|
54158
54652
|
if (error.code !== "ENOENT")
|
|
54159
54653
|
throw error;
|
|
54160
54654
|
}
|
|
54161
54655
|
}
|
|
54162
|
-
const stage =
|
|
54656
|
+
const stage = join28(parent, `.${basename7(file)}.${(options.stageName ?? randomUUID20)()}.tmp`);
|
|
54163
54657
|
let created = false;
|
|
54164
54658
|
try {
|
|
54165
54659
|
const handle = await open11(stage, "wx", mode ?? 438);
|
|
@@ -54189,7 +54683,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
|
|
|
54189
54683
|
}
|
|
54190
54684
|
} finally {
|
|
54191
54685
|
if (created)
|
|
54192
|
-
await
|
|
54686
|
+
await unlink12(stage).catch(() => {
|
|
54193
54687
|
});
|
|
54194
54688
|
}
|
|
54195
54689
|
}
|
|
@@ -54579,11 +55073,11 @@ init_storage();
|
|
|
54579
55073
|
init_dist();
|
|
54580
55074
|
import { readFile as readFile15 } from "node:fs/promises";
|
|
54581
55075
|
import { homedir as homedir11 } from "node:os";
|
|
54582
|
-
import { join as
|
|
55076
|
+
import { join as join29 } from "node:path";
|
|
54583
55077
|
var V1_VAULT_ACTIVATION_LABEL = "Activate approved Antigravity vault";
|
|
54584
55078
|
function nativeOpenCodeAuthPath(env3 = process.env, home = homedir11()) {
|
|
54585
|
-
return
|
|
54586
|
-
env3.XDG_DATA_HOME ||
|
|
55079
|
+
return join29(
|
|
55080
|
+
env3.XDG_DATA_HOME || join29(home, ".local", "share"),
|
|
54587
55081
|
"opencode",
|
|
54588
55082
|
"auth.json"
|
|
54589
55083
|
);
|
|
@@ -54631,6 +55125,7 @@ function createV1VaultActivationMethod(input2) {
|
|
|
54631
55125
|
// src/setup.ts
|
|
54632
55126
|
init_vault_custody();
|
|
54633
55127
|
init_runtime_paths();
|
|
55128
|
+
init_vault_folder();
|
|
54634
55129
|
var PI_PLACEHOLDER_KEY = "antigravity-vault-custody";
|
|
54635
55130
|
async function storePresent(anchor) {
|
|
54636
55131
|
return await pathPresent(accountStorePointerPath(anchor)) || await pathPresent(anchor);
|
|
@@ -54647,7 +55142,7 @@ function openCodeVaultDir(accountFile) {
|
|
|
54647
55142
|
return folder.vaultDir;
|
|
54648
55143
|
}
|
|
54649
55144
|
function nativeAuthPath(host, context) {
|
|
54650
|
-
return host === "opencode" ? nativeOpenCodeAuthPath() :
|
|
55145
|
+
return host === "opencode" ? nativeOpenCodeAuthPath() : join30(context.piAgentDir, "auth.json");
|
|
54651
55146
|
}
|
|
54652
55147
|
function provider(host) {
|
|
54653
55148
|
return host === "opencode" ? OPENCODE_VAULT_PROVIDER : ANTIGRAVITY_PROVIDER_ID;
|
|
@@ -54703,7 +55198,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
54703
55198
|
beforeRename: async () => {
|
|
54704
55199
|
await assertSetupHostsStopped();
|
|
54705
55200
|
const claustrum = await loadCommonAuthClaustrum();
|
|
54706
|
-
const stateDir = host === "opencode" ? openCodeVaultDir(
|
|
55201
|
+
const stateDir = host === "opencode" ? openCodeVaultDir(resolve23(accountFileForVault())) : getPiAntigravityVaultDir();
|
|
54707
55202
|
if (await claustrum.enrollmentAuthority(
|
|
54708
55203
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
54709
55204
|
`antigravity-auth-${host}`
|
|
@@ -54741,7 +55236,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
54741
55236
|
// `beforeSignIn`, which may move it after this plugin is built.
|
|
54742
55237
|
paths: {
|
|
54743
55238
|
get stateDir() {
|
|
54744
|
-
return openCodeVaultDir(
|
|
55239
|
+
return openCodeVaultDir(resolve23(accountFileForVault()));
|
|
54745
55240
|
},
|
|
54746
55241
|
host: "opencode"
|
|
54747
55242
|
}
|
|
@@ -54758,7 +55253,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
54758
55253
|
const assertLocal = async (host, context) => {
|
|
54759
55254
|
if (host === "opencode")
|
|
54760
55255
|
return assertLocalOpenCodeLogin(
|
|
54761
|
-
|
|
55256
|
+
resolve23(accountFileForVault()),
|
|
54762
55257
|
context.opencodeGeneration
|
|
54763
55258
|
);
|
|
54764
55259
|
if (await authority(host) !== "local")
|
|
@@ -54774,7 +55269,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
54774
55269
|
const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
|
|
54775
55270
|
if ((await openPiSlot2({
|
|
54776
55271
|
authPath: nativeAuthPath(host, context),
|
|
54777
|
-
stashPath:
|
|
55272
|
+
stashPath: join30(piDir, "google-login-stash.json"),
|
|
54778
55273
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
54779
55274
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
54780
55275
|
}).inspect()).slot === "placeholder")
|
|
@@ -54814,7 +55309,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
54814
55309
|
const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
|
|
54815
55310
|
const inspection = await openPiSlot2({
|
|
54816
55311
|
authPath: nativeAuthPath("pi", context),
|
|
54817
|
-
stashPath:
|
|
55312
|
+
stashPath: join30(piDir, "google-login-stash.json"),
|
|
54818
55313
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
54819
55314
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
54820
55315
|
}).inspect();
|
|
@@ -54933,7 +55428,7 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
54933
55428
|
await assertSetupHostsStopped();
|
|
54934
55429
|
await openPiSlot2({
|
|
54935
55430
|
authPath: nativeAuthPath(host, context),
|
|
54936
|
-
stashPath:
|
|
55431
|
+
stashPath: join30(piDir, "google-login-stash.json"),
|
|
54937
55432
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
54938
55433
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
54939
55434
|
}).enterVault();
|
|
@@ -54999,6 +55494,7 @@ async function runPluginSetup(argv, deps, migrateOpenCode, io = {}) {
|
|
|
54999
55494
|
}
|
|
55000
55495
|
|
|
55001
55496
|
// src/cli.ts
|
|
55497
|
+
init_vault_folder();
|
|
55002
55498
|
var HELP = `Usage: antigravity-auth <command> [options]
|
|
55003
55499
|
|
|
55004
55500
|
Commands:
|
|
@@ -55388,7 +55884,7 @@ async function runCliProcess(argv, deps) {
|
|
|
55388
55884
|
...deps,
|
|
55389
55885
|
prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
|
|
55390
55886
|
const folder = await prepareVaultFolder({
|
|
55391
|
-
accountFile:
|
|
55887
|
+
accountFile: resolve24(accountFileForVault()),
|
|
55392
55888
|
...options
|
|
55393
55889
|
});
|
|
55394
55890
|
if (folder.refusal) throw folder.refusal;
|
|
@@ -55434,11 +55930,11 @@ function createDefaultCliDependencies() {
|
|
|
55434
55930
|
);
|
|
55435
55931
|
if (host !== "pi")
|
|
55436
55932
|
await assertLocalOpenCodeLogin(
|
|
55437
|
-
|
|
55933
|
+
resolve24(accountFileForVault()),
|
|
55438
55934
|
context?.opencodeGeneration
|
|
55439
55935
|
);
|
|
55440
55936
|
const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
|
|
55441
|
-
|
|
55937
|
+
resolve24(getStoragePath()),
|
|
55442
55938
|
context?.opencodeGeneration
|
|
55443
55939
|
);
|
|
55444
55940
|
try {
|
|
@@ -55454,7 +55950,7 @@ function createDefaultCliDependencies() {
|
|
|
55454
55950
|
}
|
|
55455
55951
|
if (host === "opencode") await assertSetupHostsStopped();
|
|
55456
55952
|
await assertLocalOpenCodeLogin(
|
|
55457
|
-
|
|
55953
|
+
resolve24(accountFileForVault()),
|
|
55458
55954
|
context?.opencodeGeneration
|
|
55459
55955
|
);
|
|
55460
55956
|
await persistCliStoreLogin(
|
|
@@ -55474,7 +55970,7 @@ function createDefaultCliDependencies() {
|
|
|
55474
55970
|
};
|
|
55475
55971
|
}
|
|
55476
55972
|
async function prepareCliLoginStore(legacyPath, generation) {
|
|
55477
|
-
await assertLocalOpenCodeLogin(
|
|
55973
|
+
await assertLocalOpenCodeLogin(resolve24(accountFileForVault()), generation);
|
|
55478
55974
|
const modules = await loadCommonAuthStoreModules();
|
|
55479
55975
|
const options = {
|
|
55480
55976
|
legacyPath,
|
|
@@ -55599,7 +56095,7 @@ async function readAccountStore(legacyPath) {
|
|
|
55599
56095
|
function createDefaultAccountStoreOperations() {
|
|
55600
56096
|
const offline = { processesStopped: true };
|
|
55601
56097
|
return {
|
|
55602
|
-
legacyPath: () =>
|
|
56098
|
+
legacyPath: () => resolve24(
|
|
55603
56099
|
decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
|
|
55604
56100
|
),
|
|
55605
56101
|
migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
|
|
@@ -55630,7 +56126,7 @@ function createDefaultAccountStoreOperations() {
|
|
|
55630
56126
|
};
|
|
55631
56127
|
}
|
|
55632
56128
|
function samePath(left, right) {
|
|
55633
|
-
return process.platform === "win32" ?
|
|
56129
|
+
return process.platform === "win32" ? resolve24(left).toLowerCase() === resolve24(right).toLowerCase() : resolve24(left) === resolve24(right);
|
|
55634
56130
|
}
|
|
55635
56131
|
function isCliEntry() {
|
|
55636
56132
|
if (import.meta.main !== void 0) return import.meta.main;
|
|
@@ -55809,8 +56305,8 @@ function getLocalDevPath(directory) {
|
|
|
55809
56305
|
}
|
|
55810
56306
|
function findPackageJsonUp(startPath) {
|
|
55811
56307
|
try {
|
|
55812
|
-
const
|
|
55813
|
-
let dir =
|
|
56308
|
+
const stat16 = fs4.statSync(startPath);
|
|
56309
|
+
let dir = stat16.isDirectory() ? startPath : path4.dirname(startPath);
|
|
55814
56310
|
for (let i = 0; i < 10; i++) {
|
|
55815
56311
|
const pkgPath = path4.join(dir, "package.json");
|
|
55816
56312
|
if (fs4.existsSync(pkgPath)) {
|
|
@@ -56120,16 +56616,16 @@ function isTuiConnected(sessionId) {
|
|
|
56120
56616
|
// src/rpc/rpc-dir.ts
|
|
56121
56617
|
import { createHash as createHash19 } from "node:crypto";
|
|
56122
56618
|
import { homedir as homedir13, tmpdir as tmpdir6 } from "node:os";
|
|
56123
|
-
import { isAbsolute as
|
|
56619
|
+
import { isAbsolute as isAbsolute5, join as join34, resolve as resolve25 } from "node:path";
|
|
56124
56620
|
var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
|
|
56125
56621
|
function getRpcDir(projectDirectory) {
|
|
56126
56622
|
const override = process.env[RPC_DIR_ENV]?.trim();
|
|
56127
56623
|
if (override) {
|
|
56128
|
-
return
|
|
56624
|
+
return isAbsolute5(override) ? override : resolve25(projectDirectory, override);
|
|
56129
56625
|
}
|
|
56130
|
-
const projectHash = createHash19("sha256").update(
|
|
56131
|
-
const stateHome = process.env.XDG_STATE_HOME ??
|
|
56132
|
-
return
|
|
56626
|
+
const projectHash = createHash19("sha256").update(resolve25(projectDirectory)).digest("hex").slice(0, 16);
|
|
56627
|
+
const stateHome = process.env.XDG_STATE_HOME ?? join34(homedir13(), ".local", "state");
|
|
56628
|
+
return join34(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
|
|
56133
56629
|
}
|
|
56134
56630
|
|
|
56135
56631
|
// src/common-auth-embedded/rpc/notifications.js
|
|
@@ -56140,8 +56636,8 @@ function isSessionId(value) {
|
|
|
56140
56636
|
// src/common-auth-embedded/rpc/port-file.js
|
|
56141
56637
|
init_private_files2();
|
|
56142
56638
|
import { createHash as createHash20, randomUUID as randomUUID21 } from "node:crypto";
|
|
56143
|
-
import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir4, rename as rename14, rmdir as rmdir3, stat as
|
|
56144
|
-
import { join as
|
|
56639
|
+
import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir4, rename as rename14, rmdir as rmdir3, stat as stat15, unlink as unlink13 } from "node:fs/promises";
|
|
56640
|
+
import { join as join35, resolve as resolve26 } from "node:path";
|
|
56145
56641
|
function isProbeablePid(pid) {
|
|
56146
56642
|
return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
|
|
56147
56643
|
}
|
|
@@ -56165,14 +56661,14 @@ function isUsablePortFileEntry(value, name) {
|
|
|
56165
56661
|
const { pid, port, token } = value;
|
|
56166
56662
|
return isProbeablePid(pid) && filenamePid(name) === pid && typeof port === "number" && Number.isInteger(port) && port >= 1 && port <= 65535 && typeof token === "string" && token.length > 0;
|
|
56167
56663
|
}
|
|
56168
|
-
async function removeCorruptPortFile(portFile,
|
|
56169
|
-
|
|
56170
|
-
await
|
|
56664
|
+
async function removeCorruptPortFile(portFile, log17) {
|
|
56665
|
+
log17?.debug("rpc corrupt port file", { pid: process.pid, portFile });
|
|
56666
|
+
await unlink13(portFile).catch(() => {
|
|
56171
56667
|
});
|
|
56172
56668
|
}
|
|
56173
56669
|
async function writePortFile(dir, entry, options = {}) {
|
|
56174
56670
|
const writeOnce = async () => {
|
|
56175
|
-
const target =
|
|
56671
|
+
const target = join35(dir, `port-${entry.pid}.json`);
|
|
56176
56672
|
if (windowsPrivateFiles2) {
|
|
56177
56673
|
await ensurePrivateDirectory2(dir, options.secureDir ?? false);
|
|
56178
56674
|
await options.beforeWrite?.();
|
|
@@ -56205,7 +56701,7 @@ async function writePortFile(dir, entry, options = {}) {
|
|
|
56205
56701
|
await handle?.close().catch(() => {
|
|
56206
56702
|
});
|
|
56207
56703
|
if (created)
|
|
56208
|
-
await
|
|
56704
|
+
await unlink13(tmp).catch(() => {
|
|
56209
56705
|
});
|
|
56210
56706
|
}
|
|
56211
56707
|
return target;
|
|
@@ -56219,7 +56715,7 @@ async function writePortFile(dir, entry, options = {}) {
|
|
|
56219
56715
|
throw error;
|
|
56220
56716
|
}
|
|
56221
56717
|
}
|
|
56222
|
-
async function sweepRpcState(root, activeDir, isManagedDir,
|
|
56718
|
+
async function sweepRpcState(root, activeDir, isManagedDir, log17) {
|
|
56223
56719
|
let projectDirs;
|
|
56224
56720
|
try {
|
|
56225
56721
|
projectDirs = await readdir4(root, { withFileTypes: true });
|
|
@@ -56228,12 +56724,12 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
56228
56724
|
return;
|
|
56229
56725
|
throw error;
|
|
56230
56726
|
}
|
|
56231
|
-
const active2 =
|
|
56727
|
+
const active2 = resolve26(activeDir);
|
|
56232
56728
|
for (const projectDir of projectDirs) {
|
|
56233
56729
|
if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
|
|
56234
56730
|
continue;
|
|
56235
56731
|
}
|
|
56236
|
-
const dir =
|
|
56732
|
+
const dir = join35(root, projectDir.name);
|
|
56237
56733
|
let names;
|
|
56238
56734
|
try {
|
|
56239
56735
|
names = await readdir4(dir);
|
|
@@ -56245,7 +56741,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
56245
56741
|
for (const name of names) {
|
|
56246
56742
|
if (!name.startsWith("port-") || !name.endsWith(".json"))
|
|
56247
56743
|
continue;
|
|
56248
|
-
const portFile =
|
|
56744
|
+
const portFile = join35(dir, name);
|
|
56249
56745
|
let raw;
|
|
56250
56746
|
try {
|
|
56251
56747
|
raw = await readPrivateText2(portFile);
|
|
@@ -56260,19 +56756,19 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
56260
56756
|
try {
|
|
56261
56757
|
parsed = JSON.parse(raw);
|
|
56262
56758
|
} catch {
|
|
56263
|
-
await removeCorruptPortFile(portFile,
|
|
56759
|
+
await removeCorruptPortFile(portFile, log17);
|
|
56264
56760
|
continue;
|
|
56265
56761
|
}
|
|
56266
56762
|
if (!isUsablePortFileEntry(parsed, name)) {
|
|
56267
|
-
await removeCorruptPortFile(portFile,
|
|
56763
|
+
await removeCorruptPortFile(portFile, log17);
|
|
56268
56764
|
continue;
|
|
56269
56765
|
}
|
|
56270
56766
|
const entry = parsed;
|
|
56271
56767
|
if (!pidAlive2(entry.pid))
|
|
56272
|
-
await
|
|
56768
|
+
await unlink13(portFile).catch(() => {
|
|
56273
56769
|
});
|
|
56274
56770
|
}
|
|
56275
|
-
if (
|
|
56771
|
+
if (resolve26(dir) !== active2)
|
|
56276
56772
|
await rmdir3(dir).catch(() => {
|
|
56277
56773
|
});
|
|
56278
56774
|
}
|
|
@@ -56284,9 +56780,9 @@ init_private_files2();
|
|
|
56284
56780
|
// src/common-auth-embedded/rpc/rpc-server.js
|
|
56285
56781
|
init_private_files2();
|
|
56286
56782
|
import { randomBytes as randomBytes7, timingSafeEqual } from "node:crypto";
|
|
56287
|
-
import { unlink as
|
|
56783
|
+
import { unlink as unlink14 } from "node:fs/promises";
|
|
56288
56784
|
import { createServer as createServer3 } from "node:http";
|
|
56289
|
-
import { join as
|
|
56785
|
+
import { join as join36 } from "node:path";
|
|
56290
56786
|
var RpcRequestError = class extends Error {
|
|
56291
56787
|
status;
|
|
56292
56788
|
constructor(status, message) {
|
|
@@ -56306,7 +56802,7 @@ var BodyTooLargeError = class extends Error {
|
|
|
56306
56802
|
}
|
|
56307
56803
|
};
|
|
56308
56804
|
function readBody(req) {
|
|
56309
|
-
return new Promise((
|
|
56805
|
+
return new Promise((resolve28, reject) => {
|
|
56310
56806
|
const tooLarge = (declaredOversize = false) => {
|
|
56311
56807
|
req.removeAllListeners("data");
|
|
56312
56808
|
req.on("data", () => {
|
|
@@ -56329,7 +56825,7 @@ function readBody(req) {
|
|
|
56329
56825
|
}
|
|
56330
56826
|
chunks.push(chunk);
|
|
56331
56827
|
});
|
|
56332
|
-
req.on("end", () =>
|
|
56828
|
+
req.on("end", () => resolve28(Buffer.concat(chunks).toString("utf8")));
|
|
56333
56829
|
req.on("error", reject);
|
|
56334
56830
|
});
|
|
56335
56831
|
}
|
|
@@ -56359,7 +56855,7 @@ function tokenOk(header, token) {
|
|
|
56359
56855
|
async function startRpcServer(options) {
|
|
56360
56856
|
if (typeof options.drain === "function" === (typeof options.drainAsync === "function"))
|
|
56361
56857
|
throw new TypeError("exactly one of drain or drainAsync must be provided");
|
|
56362
|
-
const
|
|
56858
|
+
const log17 = options.log ?? { warn() {
|
|
56363
56859
|
}, debug() {
|
|
56364
56860
|
} };
|
|
56365
56861
|
const token = randomBytes7(32).toString("hex");
|
|
@@ -56460,7 +56956,7 @@ async function startRpcServer(options) {
|
|
|
56460
56956
|
return json(400, { error: "session required" });
|
|
56461
56957
|
if (sessionId === void 0 && !warnedMissingNotificationSession) {
|
|
56462
56958
|
warnedMissingNotificationSession = true;
|
|
56463
|
-
|
|
56959
|
+
log17.warn("rpc notification drain missing session id", {
|
|
56464
56960
|
pid: process.pid
|
|
56465
56961
|
});
|
|
56466
56962
|
}
|
|
@@ -56469,7 +56965,7 @@ async function startRpcServer(options) {
|
|
|
56469
56965
|
try {
|
|
56470
56966
|
messages = await options.drainAsync(lastReceivedId, sessionId);
|
|
56471
56967
|
} catch (error) {
|
|
56472
|
-
|
|
56968
|
+
log17.warn("rpc notification drain failed", {
|
|
56473
56969
|
pid: process.pid,
|
|
56474
56970
|
error: error instanceof Error ? error.message : String(error)
|
|
56475
56971
|
});
|
|
@@ -56488,32 +56984,32 @@ async function startRpcServer(options) {
|
|
|
56488
56984
|
return json(404, { error: "unknown method" });
|
|
56489
56985
|
} catch (error) {
|
|
56490
56986
|
if (error instanceof RpcRequestError) {
|
|
56491
|
-
|
|
56987
|
+
log17.debug("rpc request refused", {
|
|
56492
56988
|
pid: process.pid,
|
|
56493
56989
|
status: error.status
|
|
56494
56990
|
});
|
|
56495
56991
|
return json(error.status, { error: error.message });
|
|
56496
56992
|
}
|
|
56497
56993
|
if (error instanceof ApplyDeadlineError) {
|
|
56498
|
-
|
|
56994
|
+
log17.warn("rpc apply deadline exceeded", {
|
|
56499
56995
|
pid: process.pid,
|
|
56500
56996
|
deadlineMs: options.applyDeadlineMs
|
|
56501
56997
|
});
|
|
56502
56998
|
return json(504, { error: "handler deadline exceeded" });
|
|
56503
56999
|
}
|
|
56504
|
-
|
|
57000
|
+
log17.warn("rpc request failed", {
|
|
56505
57001
|
pid: process.pid,
|
|
56506
57002
|
error: error instanceof Error ? error.message : String(error)
|
|
56507
57003
|
});
|
|
56508
57004
|
json(500, { error: "internal error" });
|
|
56509
57005
|
}
|
|
56510
57006
|
}
|
|
56511
|
-
const port = await new Promise((
|
|
57007
|
+
const port = await new Promise((resolve28, reject) => {
|
|
56512
57008
|
server.on("error", reject);
|
|
56513
57009
|
server.listen(0, "127.0.0.1", () => {
|
|
56514
57010
|
const addr = server.address();
|
|
56515
57011
|
if (addr && typeof addr === "object")
|
|
56516
|
-
|
|
57012
|
+
resolve28(addr.port);
|
|
56517
57013
|
else
|
|
56518
57014
|
reject(new Error("no port"));
|
|
56519
57015
|
});
|
|
@@ -56521,9 +57017,9 @@ async function startRpcServer(options) {
|
|
|
56521
57017
|
server.unref();
|
|
56522
57018
|
if (options.sweepRoot) {
|
|
56523
57019
|
try {
|
|
56524
|
-
await sweepRpcState(options.sweepRoot, options.dir, options.isManagedDir,
|
|
57020
|
+
await sweepRpcState(options.sweepRoot, options.dir, options.isManagedDir, log17);
|
|
56525
57021
|
} catch (error) {
|
|
56526
|
-
|
|
57022
|
+
log17.warn("rpc state sweep failed", {
|
|
56527
57023
|
pid: process.pid,
|
|
56528
57024
|
error: error instanceof Error ? error.message : String(error)
|
|
56529
57025
|
});
|
|
@@ -56531,32 +57027,32 @@ async function startRpcServer(options) {
|
|
|
56531
57027
|
}
|
|
56532
57028
|
try {
|
|
56533
57029
|
await writePortFile(options.dir, { port, token, pid: process.pid }, { secureDir: options.secureDir });
|
|
56534
|
-
|
|
57030
|
+
log17.debug("rpc server pid", {
|
|
56535
57031
|
pid: process.pid,
|
|
56536
57032
|
rpcPort: port
|
|
56537
57033
|
});
|
|
56538
57034
|
} catch (error) {
|
|
56539
|
-
await new Promise((
|
|
57035
|
+
await new Promise((resolve28) => server.close(() => resolve28()));
|
|
56540
57036
|
throw error;
|
|
56541
57037
|
}
|
|
56542
57038
|
return {
|
|
56543
57039
|
port,
|
|
56544
57040
|
token,
|
|
56545
57041
|
async stop() {
|
|
56546
|
-
await new Promise((
|
|
57042
|
+
await new Promise((resolve28) => {
|
|
56547
57043
|
server.closeAllConnections?.();
|
|
56548
|
-
server.close(() =>
|
|
57044
|
+
server.close(() => resolve28());
|
|
56549
57045
|
for (const socket of connections)
|
|
56550
57046
|
socket.destroy();
|
|
56551
57047
|
});
|
|
56552
|
-
const portFile =
|
|
57048
|
+
const portFile = join36(options.dir, `port-${process.pid}.json`);
|
|
56553
57049
|
const current = await readPrivateText2(portFile).then((raw) => JSON.parse(raw)).catch((error) => {
|
|
56554
57050
|
if (error instanceof PrivateFileError2 && error.code !== "ENOENT")
|
|
56555
57051
|
throw error;
|
|
56556
57052
|
return void 0;
|
|
56557
57053
|
});
|
|
56558
57054
|
if (current?.port === port && current.token === token)
|
|
56559
|
-
await
|
|
57055
|
+
await unlink14(portFile).catch(() => {
|
|
56560
57056
|
});
|
|
56561
57057
|
}
|
|
56562
57058
|
};
|
|
@@ -56631,6 +57127,9 @@ function parsePending(value) {
|
|
|
56631
57127
|
};
|
|
56632
57128
|
}
|
|
56633
57129
|
|
|
57130
|
+
// src/plugin/index.ts
|
|
57131
|
+
init_vault_folder();
|
|
57132
|
+
|
|
56634
57133
|
// src/plugin/oauth-methods.ts
|
|
56635
57134
|
init_dist();
|
|
56636
57135
|
import { exec } from "node:child_process";
|
|
@@ -56869,7 +57368,7 @@ import { createInterface as createInterface2 } from "node:readline/promises";
|
|
|
56869
57368
|
// src/plugin/config/updater.ts
|
|
56870
57369
|
import { existsSync as existsSync15, mkdirSync as mkdirSync8, readFileSync as readFileSync13, writeFileSync as writeFileSync8 } from "node:fs";
|
|
56871
57370
|
import { homedir as homedir14 } from "node:os";
|
|
56872
|
-
import { dirname as dirname25, join as
|
|
57371
|
+
import { dirname as dirname25, join as join37 } from "node:path";
|
|
56873
57372
|
|
|
56874
57373
|
// src/plugin/model-registry.ts
|
|
56875
57374
|
init_dist();
|
|
@@ -56886,13 +57385,13 @@ function stripJsonCommentsAndTrailingCommas(json) {
|
|
|
56886
57385
|
).replace(/,(\s*[}\]])/g, "$1");
|
|
56887
57386
|
}
|
|
56888
57387
|
function getOpencodeConfigDir() {
|
|
56889
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ||
|
|
56890
|
-
return
|
|
57388
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME || join37(homedir14(), ".config");
|
|
57389
|
+
return join37(xdgConfig2, "opencode");
|
|
56891
57390
|
}
|
|
56892
57391
|
function getOpencodeConfigPath() {
|
|
56893
57392
|
const configDir = getOpencodeConfigDir();
|
|
56894
|
-
const jsoncPath =
|
|
56895
|
-
const jsonPath =
|
|
57393
|
+
const jsoncPath = join37(configDir, OPENCODE_JSONC_FILENAME);
|
|
57394
|
+
const jsonPath = join37(configDir, OPENCODE_JSON_FILENAME);
|
|
56896
57395
|
if (existsSync15(jsoncPath)) {
|
|
56897
57396
|
return jsoncPath;
|
|
56898
57397
|
}
|
|
@@ -57151,7 +57650,7 @@ async function select3(items, options) {
|
|
|
57151
57650
|
}
|
|
57152
57651
|
renderedLines = linesWritten;
|
|
57153
57652
|
};
|
|
57154
|
-
return new Promise((
|
|
57653
|
+
return new Promise((resolve28) => {
|
|
57155
57654
|
const wasRaw = stdin.isRaw ?? false;
|
|
57156
57655
|
const cleanup2 = () => {
|
|
57157
57656
|
if (isCleanedUp) return;
|
|
@@ -57172,11 +57671,11 @@ async function select3(items, options) {
|
|
|
57172
57671
|
};
|
|
57173
57672
|
const onSignal = () => {
|
|
57174
57673
|
cleanup2();
|
|
57175
|
-
|
|
57674
|
+
resolve28(null);
|
|
57176
57675
|
};
|
|
57177
57676
|
const finishWithValue = (value) => {
|
|
57178
57677
|
cleanup2();
|
|
57179
|
-
|
|
57678
|
+
resolve28(value);
|
|
57180
57679
|
};
|
|
57181
57680
|
const findNextSelectable = (from, direction) => {
|
|
57182
57681
|
if (items.length === 0) return from;
|
|
@@ -57222,7 +57721,7 @@ async function select3(items, options) {
|
|
|
57222
57721
|
stdin.setRawMode(true);
|
|
57223
57722
|
} catch {
|
|
57224
57723
|
cleanup2();
|
|
57225
|
-
|
|
57724
|
+
resolve28(null);
|
|
57226
57725
|
return;
|
|
57227
57726
|
}
|
|
57228
57727
|
stdin.resume();
|
|
@@ -57912,10 +58411,10 @@ function toV1AuthCallbackResult(result) {
|
|
|
57912
58411
|
};
|
|
57913
58412
|
}
|
|
57914
58413
|
var MAX_OAUTH_ACCOUNTS = 10;
|
|
57915
|
-
var
|
|
57916
|
-
async function reportPersistenceFailure(error, client,
|
|
58414
|
+
var log12 = createLogger4("oauth-methods");
|
|
58415
|
+
async function reportPersistenceFailure(error, client, log17) {
|
|
57917
58416
|
const message = error instanceof AccountStorageUnreadableError ? `Account storage at ${error.details.path} is unreadable (${error.details.reason}: ${error.details.detail}).${error.details.backupPath ? ` A backup was written to ${error.details.backupPath}. Repair or remove the existing file before retrying.` : " A backup could not be written; repair or remove the existing file before retrying."}` : error instanceof Error ? error.message : String(error);
|
|
57918
|
-
|
|
58417
|
+
log17.error("OAuth login persistence failed; aborting login", {
|
|
57919
58418
|
error: message
|
|
57920
58419
|
});
|
|
57921
58420
|
try {
|
|
@@ -58752,7 +59251,7 @@ ${verifyUrl}
|
|
|
58752
59251
|
}
|
|
58753
59252
|
});
|
|
58754
59253
|
} catch (storeError) {
|
|
58755
|
-
|
|
59254
|
+
log12.error(
|
|
58756
59255
|
"Failed to update stored Antigravity OAuth credentials",
|
|
58757
59256
|
{ error: String(storeError) }
|
|
58758
59257
|
);
|
|
@@ -58777,7 +59276,7 @@ ${verifyUrl}
|
|
|
58777
59276
|
}
|
|
58778
59277
|
});
|
|
58779
59278
|
} catch (storeError) {
|
|
58780
|
-
|
|
59279
|
+
log12.error(
|
|
58781
59280
|
"Failed to clear stored Antigravity OAuth credentials",
|
|
58782
59281
|
{ error: String(storeError) }
|
|
58783
59282
|
);
|
|
@@ -58818,7 +59317,7 @@ Re-authenticating ${refreshEmail || "account"}...
|
|
|
58818
59317
|
}
|
|
58819
59318
|
});
|
|
58820
59319
|
} catch (storeError) {
|
|
58821
|
-
|
|
59320
|
+
log12.error(
|
|
58822
59321
|
"Failed to clear stored Antigravity OAuth credentials",
|
|
58823
59322
|
{ error: String(storeError) }
|
|
58824
59323
|
);
|
|
@@ -59157,7 +59656,7 @@ ${authorization2.url}
|
|
|
59157
59656
|
return await reportPersistenceFailure(
|
|
59158
59657
|
persistError,
|
|
59159
59658
|
client,
|
|
59160
|
-
|
|
59659
|
+
log12
|
|
59161
59660
|
);
|
|
59162
59661
|
}
|
|
59163
59662
|
const newTotal = existingCount + 1;
|
|
@@ -59201,7 +59700,7 @@ ${authorization2.url}
|
|
|
59201
59700
|
try {
|
|
59202
59701
|
await persistAccountPool2([result], false);
|
|
59203
59702
|
} catch (persistError) {
|
|
59204
|
-
return await reportPersistenceFailure(persistError, client,
|
|
59703
|
+
return await reportPersistenceFailure(persistError, client, log12);
|
|
59205
59704
|
}
|
|
59206
59705
|
const newTotal = existingCount + 1;
|
|
59207
59706
|
const toastMessage = existingCount > 0 ? `Added account${result.email ? ` (${result.email})` : ""} - ${newTotal} total` : `Authenticated${result.email ? ` (${result.email})` : ""}`;
|
|
@@ -59362,7 +59861,7 @@ import { createHash as createHash21 } from "node:crypto";
|
|
|
59362
59861
|
init_debug();
|
|
59363
59862
|
init_logger4();
|
|
59364
59863
|
init_storage();
|
|
59365
|
-
var
|
|
59864
|
+
var log13 = createLogger4("auth-loader");
|
|
59366
59865
|
function refreshTokenIdentity(refreshToken) {
|
|
59367
59866
|
return createHash21("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
59368
59867
|
}
|
|
@@ -59509,7 +60008,7 @@ function createAuthLoader({
|
|
|
59509
60008
|
});
|
|
59510
60009
|
refreshQueue = deps.createStoreRefreshQueue(
|
|
59511
60010
|
{
|
|
59512
|
-
logger:
|
|
60011
|
+
logger: log13,
|
|
59513
60012
|
refreshToken: (_auth, account) => credentials.refresh(account)
|
|
59514
60013
|
},
|
|
59515
60014
|
queueConfig
|
|
@@ -59617,7 +60116,7 @@ function createAuthLoader({
|
|
|
59617
60116
|
}
|
|
59618
60117
|
if (opening.status === "ready") {
|
|
59619
60118
|
if (!isOAuthAuth(auth) && !readAuthority2) {
|
|
59620
|
-
|
|
60119
|
+
log13.warn(
|
|
59621
60120
|
"The host holds no Antigravity sign-in; the account store is left untouched"
|
|
59622
60121
|
);
|
|
59623
60122
|
return {};
|
|
@@ -59630,7 +60129,7 @@ function createAuthLoader({
|
|
|
59630
60129
|
}
|
|
59631
60130
|
if (!usesPoolFile(opening)) {
|
|
59632
60131
|
const message = opening.status === "refused" || opening.status === "recovery-required" ? opening.message : "The Antigravity account store cannot be opened";
|
|
59633
|
-
|
|
60132
|
+
log13.error("Refusing to start: the account store cannot serve", {
|
|
59634
60133
|
message
|
|
59635
60134
|
});
|
|
59636
60135
|
try {
|
|
@@ -59647,7 +60146,7 @@ function createAuthLoader({
|
|
|
59647
60146
|
storedAccounts = await deps.loadAccounts();
|
|
59648
60147
|
} catch (error) {
|
|
59649
60148
|
if (error instanceof AccountStorageUnreadableError) {
|
|
59650
|
-
|
|
60149
|
+
log13.error("Refusing to start: account storage is unreadable", {
|
|
59651
60150
|
path: error.details.path,
|
|
59652
60151
|
reason: error.details.reason,
|
|
59653
60152
|
backupPath: error.details.backupPath
|
|
@@ -59679,12 +60178,12 @@ function createAuthLoader({
|
|
|
59679
60178
|
expires: auth.expires ?? 0
|
|
59680
60179
|
}
|
|
59681
60180
|
});
|
|
59682
|
-
|
|
60181
|
+
log13.info("Restored Antigravity OAuth auth from account storage", {
|
|
59683
60182
|
reason: drift.reason,
|
|
59684
60183
|
email: drift.account.email
|
|
59685
60184
|
});
|
|
59686
60185
|
} catch (error) {
|
|
59687
|
-
|
|
60186
|
+
log13.warn(
|
|
59688
60187
|
"Failed to restore Antigravity OAuth auth from account storage",
|
|
59689
60188
|
{ error: String(error) }
|
|
59690
60189
|
);
|
|
@@ -60189,15 +60688,15 @@ init_debug();
|
|
|
60189
60688
|
// src/plugin/dependencies.ts
|
|
60190
60689
|
init_dist();
|
|
60191
60690
|
import { homedir as homedir15 } from "node:os";
|
|
60192
|
-
import { join as
|
|
60691
|
+
import { join as join38 } from "node:path";
|
|
60193
60692
|
function defaultFilesystemRoots() {
|
|
60194
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ??
|
|
60195
|
-
const xdgState2 = process.env.XDG_STATE_HOME ??
|
|
60693
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME ?? join38(homedir15(), ".config");
|
|
60694
|
+
const xdgState2 = process.env.XDG_STATE_HOME ?? join38(homedir15(), ".local", "state");
|
|
60196
60695
|
return {
|
|
60197
60696
|
projectRoot: process.cwd(),
|
|
60198
|
-
userConfigRoot:
|
|
60199
|
-
sidebarStateRoot:
|
|
60200
|
-
rpcRoot:
|
|
60697
|
+
userConfigRoot: join38(xdgConfig2, "opencode"),
|
|
60698
|
+
sidebarStateRoot: join38(xdgState2, "cortexkit", "antigravity-auth"),
|
|
60699
|
+
rpcRoot: join38(xdgState2, "cortexkit", "antigravity-auth", "rpc")
|
|
60201
60700
|
};
|
|
60202
60701
|
}
|
|
60203
60702
|
function resolvePluginDependencies(overrides = {}) {
|
|
@@ -60226,10 +60725,10 @@ function resolvePluginDependencies(overrides = {}) {
|
|
|
60226
60725
|
}
|
|
60227
60726
|
async function defaultSleep(ms, signal) {
|
|
60228
60727
|
if (ms <= 0) return;
|
|
60229
|
-
await new Promise((
|
|
60728
|
+
await new Promise((resolve28, reject) => {
|
|
60230
60729
|
const timer = setTimeout(() => {
|
|
60231
60730
|
signal?.removeEventListener("abort", onAbort);
|
|
60232
|
-
|
|
60731
|
+
resolve28();
|
|
60233
60732
|
}, ms);
|
|
60234
60733
|
timer.unref?.();
|
|
60235
60734
|
const onAbort = () => {
|
|
@@ -60347,7 +60846,7 @@ init_dist();
|
|
|
60347
60846
|
init_debug();
|
|
60348
60847
|
init_logger4();
|
|
60349
60848
|
init_vault_request_credentials();
|
|
60350
|
-
var
|
|
60849
|
+
var log14 = createLogger4("fetch-interceptor");
|
|
60351
60850
|
var defaultAgyTransport = (url, init, options) => fetchWithAgyCliTransport(url, init, options);
|
|
60352
60851
|
var defaultFetchImpl = (input2, init) => globalThis.fetch(input2, init);
|
|
60353
60852
|
function poolFileCredentials(accountManager, client, providerId) {
|
|
@@ -60400,14 +60899,14 @@ function openCode1EngineCollaborators(common) {
|
|
|
60400
60899
|
// the engine calls.
|
|
60401
60900
|
debug: debug_exports,
|
|
60402
60901
|
dump: { dumpRequest: dumpGeminiRequest },
|
|
60403
|
-
logger:
|
|
60902
|
+
logger: log14,
|
|
60404
60903
|
classifyAccessError: extractAccountAccessErrorDetails,
|
|
60405
60904
|
notify: (message, variant) => client.tui.showToast({ body: { message, variant } }),
|
|
60406
60905
|
onRouting: common.onRouting ?? ((sessionId, entry) => {
|
|
60407
60906
|
void upsertSidebarActiveRouting(sessionId, entry, {
|
|
60408
60907
|
authoritative: true
|
|
60409
60908
|
}).catch((error) => {
|
|
60410
|
-
|
|
60909
|
+
log14.debug("sidebar-routing-upsert-failed", {
|
|
60411
60910
|
sessionId,
|
|
60412
60911
|
error: String(error)
|
|
60413
60912
|
});
|
|
@@ -60433,7 +60932,7 @@ function createFetchInterceptor(context) {
|
|
|
60433
60932
|
const refreshQuotaAfterSuccess = createLocalQuotaRefresh(
|
|
60434
60933
|
accountManager,
|
|
60435
60934
|
quotaManager,
|
|
60436
|
-
|
|
60935
|
+
log14
|
|
60437
60936
|
);
|
|
60438
60937
|
const executor = createRequestExecutor({
|
|
60439
60938
|
assertAdmission: context.assertAdmission,
|
|
@@ -60579,7 +61078,7 @@ init_logger4();
|
|
|
60579
61078
|
// src/plugin/search.ts
|
|
60580
61079
|
import crypto3 from "node:crypto";
|
|
60581
61080
|
init_logger4();
|
|
60582
|
-
var
|
|
61081
|
+
var log15 = createLogger4("search");
|
|
60583
61082
|
var sessionCounter = 0;
|
|
60584
61083
|
var sessionPrefix = `search-${Date.now().toString(36)}`;
|
|
60585
61084
|
function generateRequestId() {
|
|
@@ -60711,7 +61210,7 @@ ${urlList}`;
|
|
|
60711
61210
|
requestType: "agent"
|
|
60712
61211
|
};
|
|
60713
61212
|
const url = `${ANTIGRAVITY_ENDPOINT}/v1internal:generateContent`;
|
|
60714
|
-
|
|
61213
|
+
log15.debug("Executing search", {
|
|
60715
61214
|
query,
|
|
60716
61215
|
urlCount: urls?.length ?? 0,
|
|
60717
61216
|
thinking
|
|
@@ -60734,7 +61233,7 @@ ${urlList}`;
|
|
|
60734
61233
|
);
|
|
60735
61234
|
if (!response.ok) {
|
|
60736
61235
|
const errorText3 = await response.text();
|
|
60737
|
-
|
|
61236
|
+
log15.debug("Search API error", {
|
|
60738
61237
|
status: response.status,
|
|
60739
61238
|
error: errorText3
|
|
60740
61239
|
});
|
|
@@ -60747,14 +61246,14 @@ ${errorText3}
|
|
|
60747
61246
|
Please try again with a different query.`;
|
|
60748
61247
|
}
|
|
60749
61248
|
const data = await response.json();
|
|
60750
|
-
|
|
61249
|
+
log15.debug("Search response received", { hasResponse: !!data.response });
|
|
60751
61250
|
const result = parseSearchResponse(data);
|
|
60752
61251
|
const formatted = formatSearchResult(result);
|
|
60753
|
-
|
|
61252
|
+
log15.debug("Search response formatted", { resultLength: formatted.length });
|
|
60754
61253
|
return formatted;
|
|
60755
61254
|
} catch (error) {
|
|
60756
61255
|
const message = error instanceof Error ? error.message : String(error);
|
|
60757
|
-
|
|
61256
|
+
log15.debug("Search execution error", { error: message });
|
|
60758
61257
|
return `## Search Error
|
|
60759
61258
|
|
|
60760
61259
|
Failed to execute search: ${message}. Please try again with a different query.`;
|
|
@@ -60762,7 +61261,7 @@ Failed to execute search: ${message}. Please try again with a different query.`;
|
|
|
60762
61261
|
}
|
|
60763
61262
|
|
|
60764
61263
|
// src/plugin/google-search-tool.ts
|
|
60765
|
-
var
|
|
61264
|
+
var log16 = createLogger4("plugin");
|
|
60766
61265
|
function createGoogleSearchTool({
|
|
60767
61266
|
getAuth,
|
|
60768
61267
|
client,
|
|
@@ -60784,7 +61283,7 @@ function createGoogleSearchTool({
|
|
|
60784
61283
|
if (mayStartLocalWork && !await mayStartLocalWork()) {
|
|
60785
61284
|
return "Google Search is not available through local credentials while vault custody is active or unreadable.";
|
|
60786
61285
|
}
|
|
60787
|
-
|
|
61286
|
+
log16.debug("Google Search tool called", {
|
|
60788
61287
|
query: args.query,
|
|
60789
61288
|
urlCount: args.urls?.length ?? 0
|
|
60790
61289
|
});
|
|
@@ -60949,8 +61448,8 @@ function createPluginLifecycle(options) {
|
|
|
60949
61448
|
};
|
|
60950
61449
|
let failDisposal = () => {
|
|
60951
61450
|
};
|
|
60952
|
-
disposal = new Promise((
|
|
60953
|
-
finishDisposal =
|
|
61451
|
+
disposal = new Promise((resolve28, reject) => {
|
|
61452
|
+
finishDisposal = resolve28;
|
|
60954
61453
|
failDisposal = reject;
|
|
60955
61454
|
});
|
|
60956
61455
|
void (async () => {
|
|
@@ -61099,7 +61598,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
61099
61598
|
await drainSidebarWrites();
|
|
61100
61599
|
}
|
|
61101
61600
|
});
|
|
61102
|
-
const accountFile =
|
|
61601
|
+
const accountFile = resolve27(accountFileForVault());
|
|
61103
61602
|
const vaultFolder = await prepareVaultFolder({ accountFile });
|
|
61104
61603
|
const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
|
|
61105
61604
|
let vaultQuotaPoller;
|
|
@@ -61322,7 +61821,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
61322
61821
|
lifecycle.register(vaultQuotaPoller, "producer");
|
|
61323
61822
|
}
|
|
61324
61823
|
const operatorSettings = createOperatorSettingsController({
|
|
61325
|
-
projectConfigPath:
|
|
61824
|
+
projectConfigPath: join39(directory, ".opencode", "antigravity.json"),
|
|
61326
61825
|
// getUserConfigPath() already returns the full file path including
|
|
61327
61826
|
// 'antigravity.json' — do NOT join again or the path double-nests
|
|
61328
61827
|
// into <dir>/antigravity.json/antigravity.json.
|
|
@@ -61762,6 +62261,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
61762
62261
|
);
|
|
61763
62262
|
},
|
|
61764
62263
|
"command.execute.before": commandExecuteBefore,
|
|
62264
|
+
"chat.headers": createVaultRoutingHeaders(providerId),
|
|
61765
62265
|
event,
|
|
61766
62266
|
tool: { google_search: googleSearchTool },
|
|
61767
62267
|
auth: {
|