@cortexkit/opencode-antigravity-auth 3.0.20 → 3.0.22
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 +354 -278
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +66 -21
- package/dist/index.js +841 -392
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +123 -28
- package/dist/server.js +860 -411
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/custody.js +25 -0
- package/dist/src/common-auth-embedded/claustrum/hub.js +20 -1
- package/dist/src/common-auth-embedded/claustrum/insula.js +6 -0
- 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.d.ts +86 -0
- package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +654 -0
- 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 +69 -29
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +2 -2
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/src/plugin/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 +36 -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/tui/quota-layout.d.ts +4 -58
- package/dist/src/tui/quota-layout.d.ts.map +1 -1
- package/dist/src/tui/quota-layout.js +4 -90
- package/dist/src/tui/quota-layout.js.map +1 -1
- package/dist/src/tui/sidebar-frame.d.ts +4 -34
- package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
- package/dist/src/tui/sidebar-frame.js +93 -167
- package/dist/src/tui/sidebar-frame.js.map +1 -1
- package/dist/src/tui.js +2 -2
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +31 -17
- package/dist/tui-ga-build-map.json +32 -17
- 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 +36 -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/package.json +2 -2
- package/src/common-auth-embedded/claustrum/custody.js +25 -0
- package/src/common-auth-embedded/claustrum/hub.js +20 -1
- package/src/common-auth-embedded/claustrum/insula.js +6 -0
- 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.d.ts +86 -0
- package/src/common-auth-embedded/quota-sidebar/index.tsx +654 -0
- 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 +69 -29
- package/src/tui-compiled/common-auth-embedded/quota/format.js +45 -26
- package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +683 -0
- package/src/tui-compiled/tui/quota-layout.js +5 -330
- package/src/tui-compiled/tui/sidebar-frame.js +243 -467
- package/src/tui-compiled/tui.js +2 -2
- package/src/tui-ga-compiled/host-ga.js +2 -2
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +45 -26
- package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +243 -467
- package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +5 -330
- package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +683 -0
- package/src/tui-ga-raw/host-ga.tsx +2 -2
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +45 -26
- package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +214 -400
- package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +10 -301
- package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +654 -0
- package/src/tui-raw/common-auth-embedded/quota/format.js +45 -26
- package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +654 -0
- package/src/tui-raw/tui/quota-layout.tsx +10 -301
- package/src/tui-raw/tui/sidebar-frame.tsx +214 -400
- package/src/tui-raw/tui.tsx +2 -2
- package/src/tui.tsx +2 -2
package/dist/index.js
CHANGED
|
@@ -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((resolve27) => setTimeout(resolve27, 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((resolve27) => {
|
|
7871
|
+
lostResolve = resolve27;
|
|
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 resolve27 = lostResolve;
|
|
7882
7882
|
lostResolve = null;
|
|
7883
|
-
|
|
7883
|
+
resolve27?.();
|
|
7884
7884
|
};
|
|
7885
7885
|
const setupRenew = () => {
|
|
7886
7886
|
if (options.renew === false)
|
|
@@ -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((resolve27) => setTimeout(resolve27, 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((resolve27) => setTimeout(resolve27, 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((resolve27, reject) => {
|
|
9757
|
+
this.savePromiseResolvers.push({ resolve: resolve27, 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: resolve27 } of resolvers)
|
|
9801
|
+
resolve27();
|
|
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: resolve27 } of resolvers) {
|
|
9816
|
+
resolve27();
|
|
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: resolve27 } of resolvers) {
|
|
9824
|
+
resolve27();
|
|
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((resolve27, 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(() => resolve27({ 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((resolve27, 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
|
+
resolve27();
|
|
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((resolve27, 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
|
+
resolve27(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((resolve27, 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
|
+
resolve27(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((resolve27) => {
|
|
12511
|
+
resolveLoss = resolve27;
|
|
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((resolve27) => setTimeout(resolve27, 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((resolve27) => setTimeout(resolve27, 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((resolve27) => setTimeout(resolve27, 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((resolve27) => setTimeout(resolve27, 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);
|
|
@@ -16361,7 +16393,7 @@ function createEngine(options) {
|
|
|
16361
16393
|
});
|
|
16362
16394
|
}, 500);
|
|
16363
16395
|
}
|
|
16364
|
-
function emit(
|
|
16396
|
+
function emit(channel3, level, message, data) {
|
|
16365
16397
|
if (logFileSource === void 0 && captureSink === void 0)
|
|
16366
16398
|
return;
|
|
16367
16399
|
try {
|
|
@@ -16374,10 +16406,10 @@ function createEngine(options) {
|
|
|
16374
16406
|
} catch {
|
|
16375
16407
|
scrubbedData = "[unserializable]";
|
|
16376
16408
|
}
|
|
16377
|
-
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${
|
|
16409
|
+
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize(scrubbedData)) + "\n";
|
|
16378
16410
|
try {
|
|
16379
16411
|
captureSink?.({
|
|
16380
|
-
channel,
|
|
16412
|
+
channel: channel3,
|
|
16381
16413
|
level,
|
|
16382
16414
|
message: scrubbedMessage,
|
|
16383
16415
|
data: scrubbedData
|
|
@@ -16397,13 +16429,13 @@ function createEngine(options) {
|
|
|
16397
16429
|
} catch {
|
|
16398
16430
|
}
|
|
16399
16431
|
}
|
|
16400
|
-
function createLogger5(
|
|
16432
|
+
function createLogger5(channel3) {
|
|
16401
16433
|
return {
|
|
16402
|
-
error: (m, d) => emit(
|
|
16403
|
-
warn: (m, d) => emit(
|
|
16404
|
-
info: (m, d) => emit(
|
|
16405
|
-
debug: (m, d) => emit(
|
|
16406
|
-
trace: (m, d) => emit(
|
|
16434
|
+
error: (m, d) => emit(channel3, "error", m, d),
|
|
16435
|
+
warn: (m, d) => emit(channel3, "warn", m, d),
|
|
16436
|
+
info: (m, d) => emit(channel3, "info", m, d),
|
|
16437
|
+
debug: (m, d) => emit(channel3, "debug", m, d),
|
|
16438
|
+
trace: (m, d) => emit(channel3, "trace", m, d)
|
|
16407
16439
|
};
|
|
16408
16440
|
}
|
|
16409
16441
|
function reset() {
|
|
@@ -16441,8 +16473,8 @@ function setLogLevel(l) {
|
|
|
16441
16473
|
function flushLogs() {
|
|
16442
16474
|
return defaultEngine.flushLogs();
|
|
16443
16475
|
}
|
|
16444
|
-
function createLogger2(
|
|
16445
|
-
return defaultEngine.createLogger(
|
|
16476
|
+
function createLogger2(channel3) {
|
|
16477
|
+
return defaultEngine.createLogger(channel3);
|
|
16446
16478
|
}
|
|
16447
16479
|
async function flushForTest() {
|
|
16448
16480
|
return defaultEngine.flushLogs();
|
|
@@ -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((resolve27) => {
|
|
16594
16626
|
const done = () => {
|
|
16595
16627
|
clearTimeout(timer);
|
|
16596
16628
|
this.wake.delete(done);
|
|
16597
|
-
|
|
16629
|
+
resolve27();
|
|
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((resolve27) => {
|
|
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
|
+
resolve27(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
|
+
resolve27(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 shared3 = sources.get(key);
|
|
20402
20434
|
if (!shared3) {
|
|
@@ -20650,6 +20682,8 @@ var init_insula = __esm({
|
|
|
20650
20682
|
...typeof entry.source === "string" && { source: entry.source }
|
|
20651
20683
|
}
|
|
20652
20684
|
};
|
|
20685
|
+
if (entry.stale !== void 0 && (!record2(entry.stale) || entry.stale.class !== "local_source_unavailable"))
|
|
20686
|
+
return { miss: "upstream-failed", reading };
|
|
20653
20687
|
return now >= fetchedAt + MAX_AGE || entry.stale !== void 0 ? { miss: "stale", reading } : { reading };
|
|
20654
20688
|
}
|
|
20655
20689
|
if (this.#completeProviders.has(provider2))
|
|
@@ -20708,7 +20742,7 @@ var init_any_signal = __esm({
|
|
|
20708
20742
|
import { createHash as createHash6, randomBytes as randomBytes4, randomUUID as randomUUID12 } from "node:crypto";
|
|
20709
20743
|
import { constants as fsConstants } from "node:fs";
|
|
20710
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";
|
|
20711
|
-
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";
|
|
20712
20746
|
import { ClaustrumCredentialError as ClaustrumCredentialError2, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
|
|
20713
20747
|
function classifyEnrollmentError(error) {
|
|
20714
20748
|
if (!(error instanceof ClaustrumCredentialError2))
|
|
@@ -20734,7 +20768,7 @@ function getClaustrumEnrollmentPaths(tokenPath) {
|
|
|
20734
20768
|
const extension = extname(tokenPath) || ".json";
|
|
20735
20769
|
const stem = basename3(tokenPath, extname(tokenPath));
|
|
20736
20770
|
return {
|
|
20737
|
-
statePath:
|
|
20771
|
+
statePath: join7(dirname9(tokenPath), `${stem}-state${extension}`),
|
|
20738
20772
|
tokenPath
|
|
20739
20773
|
};
|
|
20740
20774
|
}
|
|
@@ -20742,7 +20776,7 @@ function hostEnrollmentPaths(input2) {
|
|
|
20742
20776
|
const override = input2.override?.trim();
|
|
20743
20777
|
if (override && !isAbsolute2(override) && !input2.cwd)
|
|
20744
20778
|
throw new ClaustrumConsumerError("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
20745
|
-
const tokenPath = override ? isAbsolute2(override) ? override :
|
|
20779
|
+
const tokenPath = override ? isAbsolute2(override) ? override : resolve7(input2.cwd, override) : join7(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
20746
20780
|
return getClaustrumEnrollmentPaths(tokenPath);
|
|
20747
20781
|
}
|
|
20748
20782
|
function isRecord6(value) {
|
|
@@ -20975,7 +21009,7 @@ async function writeStateAtomic(path5, state, ancestorOptions = {}) {
|
|
|
20975
21009
|
}
|
|
20976
21010
|
if (windowsPrivateFiles)
|
|
20977
21011
|
return writePrivateAtomic(path5, bytes);
|
|
20978
|
-
const temporary =
|
|
21012
|
+
const temporary = join7(parent, `.${basename3(path5)}.${process.pid}.${randomUUID12()}.tmp`);
|
|
20979
21013
|
let descriptor;
|
|
20980
21014
|
let created = false;
|
|
20981
21015
|
try {
|
|
@@ -21471,10 +21505,10 @@ async function drainShutdown(pending, onTimeout) {
|
|
|
21471
21505
|
try {
|
|
21472
21506
|
await Promise.race([
|
|
21473
21507
|
drained,
|
|
21474
|
-
new Promise((
|
|
21508
|
+
new Promise((resolve27) => {
|
|
21475
21509
|
timer = setTimeout(() => {
|
|
21476
21510
|
expired = true;
|
|
21477
|
-
|
|
21511
|
+
resolve27();
|
|
21478
21512
|
}, 2e3);
|
|
21479
21513
|
})
|
|
21480
21514
|
]);
|
|
@@ -21492,6 +21526,7 @@ var init_shutdown = __esm({
|
|
|
21492
21526
|
});
|
|
21493
21527
|
|
|
21494
21528
|
// ../core/dist/common-auth-embedded/claustrum/custody.js
|
|
21529
|
+
import { channel } from "node:diagnostics_channel";
|
|
21495
21530
|
import { ClaustrumCredentialError as ClaustrumCredentialError3 } from "@cortexkit/claustrum-client";
|
|
21496
21531
|
function isScopedCredentialRotation(served, current) {
|
|
21497
21532
|
return current !== void 0 && !current.fromKeptReceipt && !served.fromKeptReceipt && current.credentialId === served.credentialId && current.accountIdentity === served.accountIdentity && current.recordVersion !== served.recordVersion;
|
|
@@ -21605,7 +21640,7 @@ function grantReachOf(listed) {
|
|
|
21605
21640
|
tuples: Object.freeze(grantTuples.map(({ selectorKind, selector, operation }) => Object.freeze({ selectorKind, selector, operation })))
|
|
21606
21641
|
});
|
|
21607
21642
|
}
|
|
21608
|
-
var defaultLogger, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, ClaustrumScopedCustody;
|
|
21643
|
+
var defaultLogger, phaseDiagnostics, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, ClaustrumScopedCustody;
|
|
21609
21644
|
var init_custody = __esm({
|
|
21610
21645
|
"../core/dist/common-auth-embedded/claustrum/custody.js"() {
|
|
21611
21646
|
"use strict";
|
|
@@ -21617,6 +21652,7 @@ var init_custody = __esm({
|
|
|
21617
21652
|
init_shutdown();
|
|
21618
21653
|
init_watch();
|
|
21619
21654
|
defaultLogger = createLogger2("claustrum");
|
|
21655
|
+
phaseDiagnostics = channel("common-auth.claustrum.phases");
|
|
21620
21656
|
SERVING_MARGIN_MS = 3e5;
|
|
21621
21657
|
KEPT_RECEIPT_MARGIN_MS = 6e4;
|
|
21622
21658
|
ClaustrumScopedCustody = class {
|
|
@@ -21720,6 +21756,11 @@ var init_custody = __esm({
|
|
|
21720
21756
|
}
|
|
21721
21757
|
async #token(signal) {
|
|
21722
21758
|
this.#check(signal);
|
|
21759
|
+
if (phaseDiagnostics.hasSubscribers)
|
|
21760
|
+
phaseDiagnostics.publish({
|
|
21761
|
+
logger: this.#logger,
|
|
21762
|
+
phase: "token read begin"
|
|
21763
|
+
});
|
|
21723
21764
|
const pending = this.#readToken();
|
|
21724
21765
|
this.#tokenReads.add(pending);
|
|
21725
21766
|
let value;
|
|
@@ -21727,6 +21768,11 @@ var init_custody = __esm({
|
|
|
21727
21768
|
value = await pending;
|
|
21728
21769
|
} finally {
|
|
21729
21770
|
this.#tokenReads.delete(pending);
|
|
21771
|
+
if (phaseDiagnostics.hasSubscribers)
|
|
21772
|
+
phaseDiagnostics.publish({
|
|
21773
|
+
logger: this.#logger,
|
|
21774
|
+
phase: "token read end"
|
|
21775
|
+
});
|
|
21730
21776
|
}
|
|
21731
21777
|
this.#check(signal);
|
|
21732
21778
|
if (!/^[0-9a-f]{64}$/.test(value.token) || !Number.isSafeInteger(value.token_generation) || value.token_generation < 1) {
|
|
@@ -21788,11 +21834,22 @@ var init_custody = __esm({
|
|
|
21788
21834
|
this.#kept.clear();
|
|
21789
21835
|
throw error;
|
|
21790
21836
|
}
|
|
21837
|
+
if (phaseDiagnostics.hasSubscribers)
|
|
21838
|
+
phaseDiagnostics.publish({
|
|
21839
|
+
logger: this.#logger,
|
|
21840
|
+
phase: "list scoped begin"
|
|
21841
|
+
});
|
|
21791
21842
|
try {
|
|
21792
21843
|
inventory = await this.#call(() => this.#client.listScoped(token), signal);
|
|
21793
21844
|
} catch (error) {
|
|
21794
21845
|
this.listFailed(error);
|
|
21795
21846
|
throw error;
|
|
21847
|
+
} finally {
|
|
21848
|
+
if (phaseDiagnostics.hasSubscribers)
|
|
21849
|
+
phaseDiagnostics.publish({
|
|
21850
|
+
logger: this.#logger,
|
|
21851
|
+
phase: "list scoped end"
|
|
21852
|
+
});
|
|
21796
21853
|
}
|
|
21797
21854
|
const skipped = [];
|
|
21798
21855
|
const refused2 = [];
|
|
@@ -22221,7 +22278,7 @@ var init_interlock = __esm({
|
|
|
22221
22278
|
// ../core/dist/common-auth-embedded/claustrum/roster.js
|
|
22222
22279
|
import { createHash as createHash7 } from "node:crypto";
|
|
22223
22280
|
import { stat as stat5 } from "node:fs/promises";
|
|
22224
|
-
import { resolve as
|
|
22281
|
+
import { resolve as resolve8 } from "node:path";
|
|
22225
22282
|
function vaultRosterSeed(roster) {
|
|
22226
22283
|
return {
|
|
22227
22284
|
declined: roster.declined.map((entry) => ({ ...entry })),
|
|
@@ -22608,16 +22665,16 @@ function applyVaultQuota(current, input2) {
|
|
|
22608
22665
|
};
|
|
22609
22666
|
}
|
|
22610
22667
|
function forgetPendingVaultDiscovery(path5) {
|
|
22611
|
-
pendingDiscoveries.delete(
|
|
22668
|
+
pendingDiscoveries.delete(resolve8(path5));
|
|
22612
22669
|
}
|
|
22613
22670
|
function isVaultRosterLockRefusal(path5, error) {
|
|
22614
|
-
const target =
|
|
22671
|
+
const target = resolve8(path5);
|
|
22615
22672
|
if (error instanceof ClaustrumConsumerError)
|
|
22616
22673
|
return error.kind === "roster-busy";
|
|
22617
22674
|
if (error instanceof LockContentionError || error instanceof LockOwnershipError)
|
|
22618
|
-
return
|
|
22675
|
+
return resolve8(error.details.target) === target;
|
|
22619
22676
|
if (error instanceof PrivateFileError) {
|
|
22620
|
-
const failed =
|
|
22677
|
+
const failed = resolve8(error.path);
|
|
22621
22678
|
return [WRITE_LOCK.name, DISCOVERY_LEASE.name].some((name) => {
|
|
22622
22679
|
const lock = lockPathFor(target, name);
|
|
22623
22680
|
return failed === lock || failed.startsWith(`${lock}.`);
|
|
@@ -22678,7 +22735,7 @@ async function refreshVaultRoster(options) {
|
|
|
22678
22735
|
throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
|
|
22679
22736
|
return persisted;
|
|
22680
22737
|
}
|
|
22681
|
-
const key =
|
|
22738
|
+
const key = resolve8(options.path);
|
|
22682
22739
|
const listedOver = options.listedOver;
|
|
22683
22740
|
let discovered;
|
|
22684
22741
|
try {
|
|
@@ -22798,9 +22855,9 @@ var init_roster = __esm({
|
|
|
22798
22855
|
});
|
|
22799
22856
|
|
|
22800
22857
|
// ../core/dist/common-auth-embedded/claustrum/quota-writer.js
|
|
22801
|
-
import { resolve as
|
|
22858
|
+
import { resolve as resolve9 } from "node:path";
|
|
22802
22859
|
function writerFor(path5, clock2 = quotaCommitTimer) {
|
|
22803
|
-
const key =
|
|
22860
|
+
const key = resolve9(path5);
|
|
22804
22861
|
let writer = writers.get(key);
|
|
22805
22862
|
if (!writer) {
|
|
22806
22863
|
writer = {
|
|
@@ -22864,7 +22921,7 @@ function orderedFields(pending) {
|
|
|
22864
22921
|
return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
|
|
22865
22922
|
}
|
|
22866
22923
|
function pendingVaultQuota(path5, roster) {
|
|
22867
|
-
const writer = writers.get(
|
|
22924
|
+
const writer = writers.get(resolve9(path5));
|
|
22868
22925
|
if (writer) {
|
|
22869
22926
|
for (const field of orderedFields(writer.pending)) {
|
|
22870
22927
|
if (field.priorReading)
|
|
@@ -22875,7 +22932,7 @@ function pendingVaultQuota(path5, roster) {
|
|
|
22875
22932
|
return roster;
|
|
22876
22933
|
}
|
|
22877
22934
|
function hasPendingVaultQuota(path5) {
|
|
22878
|
-
return !!writers.get(
|
|
22935
|
+
return !!writers.get(resolve9(path5))?.pending.size;
|
|
22879
22936
|
}
|
|
22880
22937
|
function schedule(writer, delay3) {
|
|
22881
22938
|
if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
|
|
@@ -22940,7 +22997,7 @@ function flush(writer) {
|
|
|
22940
22997
|
return writer.running;
|
|
22941
22998
|
}
|
|
22942
22999
|
async function drainVaultQuota(path5, timeoutMs = 1e3) {
|
|
22943
|
-
const key =
|
|
23000
|
+
const key = resolve9(path5);
|
|
22944
23001
|
const writer = writers.get(key);
|
|
22945
23002
|
if (!writer)
|
|
22946
23003
|
return;
|
|
@@ -23085,7 +23142,7 @@ var init_consumer = __esm({
|
|
|
23085
23142
|
this.#shutdown.signal,
|
|
23086
23143
|
...signal ? [signal] : []
|
|
23087
23144
|
]);
|
|
23088
|
-
return new Promise((
|
|
23145
|
+
return new Promise((resolve27, reject) => {
|
|
23089
23146
|
const cleanup2 = () => {
|
|
23090
23147
|
combined.signal.removeEventListener("abort", abort);
|
|
23091
23148
|
combined.dispose();
|
|
@@ -23100,7 +23157,7 @@ var init_consumer = __esm({
|
|
|
23100
23157
|
if (combined.signal.aborted)
|
|
23101
23158
|
reject(combined.signal.reason);
|
|
23102
23159
|
else
|
|
23103
|
-
|
|
23160
|
+
resolve27(value);
|
|
23104
23161
|
}, (error) => {
|
|
23105
23162
|
cleanup2();
|
|
23106
23163
|
reject(error);
|
|
@@ -23812,8 +23869,9 @@ var init_consumer = __esm({
|
|
|
23812
23869
|
|
|
23813
23870
|
// ../core/dist/common-auth-embedded/claustrum/hub.js
|
|
23814
23871
|
import { createHash as createHash8 } from "node:crypto";
|
|
23872
|
+
import { channel as channel2 } from "node:diagnostics_channel";
|
|
23815
23873
|
import { readdir, stat as stat6 } from "node:fs/promises";
|
|
23816
|
-
import { dirname as dirname10, join as
|
|
23874
|
+
import { dirname as dirname10, join as join8, resolve as resolve10 } from "node:path";
|
|
23817
23875
|
function canonicalJson3(value, path5 = /* @__PURE__ */ new Set()) {
|
|
23818
23876
|
if (value === null)
|
|
23819
23877
|
return "null";
|
|
@@ -23874,12 +23932,12 @@ function unreachableConnect2() {
|
|
|
23874
23932
|
return new ClaustrumUnreachableError();
|
|
23875
23933
|
}
|
|
23876
23934
|
function untilAborted(pending, signal) {
|
|
23877
|
-
return new Promise((
|
|
23935
|
+
return new Promise((resolve27, reject) => {
|
|
23878
23936
|
const abort = () => reject(signal.reason);
|
|
23879
23937
|
signal.addEventListener("abort", abort, { once: true });
|
|
23880
23938
|
pending.then((value) => {
|
|
23881
23939
|
signal.removeEventListener("abort", abort);
|
|
23882
|
-
|
|
23940
|
+
resolve27(value);
|
|
23883
23941
|
}, (error) => {
|
|
23884
23942
|
signal.removeEventListener("abort", abort);
|
|
23885
23943
|
reject(error);
|
|
@@ -23949,13 +24007,13 @@ var init_hub = __esm({
|
|
|
23949
24007
|
this.#options = options;
|
|
23950
24008
|
this.#logger = options.logger ?? createLogger2("claustrum");
|
|
23951
24009
|
this.#warnShutdown = shutdownWarning(this.#logger, this.#shutdown.signal);
|
|
23952
|
-
this.#generationDirectory =
|
|
24010
|
+
this.#generationDirectory = join8(options.stateDir, "rosters", hostGeneration);
|
|
23953
24011
|
this.#key = rosterFingerprint(options, providers);
|
|
23954
|
-
const directory =
|
|
24012
|
+
const directory = join8(this.#generationDirectory, this.#key);
|
|
23955
24013
|
for (const provider2 of providers)
|
|
23956
24014
|
this.#members.set(provider2, {
|
|
23957
24015
|
provider: provider2,
|
|
23958
|
-
path:
|
|
24016
|
+
path: join8(directory, `${provider2}.json`),
|
|
23959
24017
|
closed: false
|
|
23960
24018
|
});
|
|
23961
24019
|
}
|
|
@@ -24036,7 +24094,7 @@ var init_hub = __esm({
|
|
|
24036
24094
|
};
|
|
24037
24095
|
const { consumer, hooks } = createHubMember(port, consumerOptions);
|
|
24038
24096
|
entry.hooks = hooks;
|
|
24039
|
-
const path5 =
|
|
24097
|
+
const path5 = resolve10(entry.path);
|
|
24040
24098
|
const subscribers = sharedRosters.get(path5) ?? /* @__PURE__ */ new Set();
|
|
24041
24099
|
const install = (roster) => {
|
|
24042
24100
|
if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
|
|
@@ -24067,7 +24125,7 @@ var init_hub = __esm({
|
|
|
24067
24125
|
return;
|
|
24068
24126
|
entry.seen = JSON.stringify(decodedVaultRoster(roster));
|
|
24069
24127
|
entry.hooks?.install(roster);
|
|
24070
|
-
for (const install of sharedRosters.get(
|
|
24128
|
+
for (const install of sharedRosters.get(resolve10(entry.path)) ?? []) {
|
|
24071
24129
|
if (!this.#live(generation))
|
|
24072
24130
|
return;
|
|
24073
24131
|
if (install !== entry.receiveRoster)
|
|
@@ -24478,7 +24536,24 @@ var init_hub = __esm({
|
|
|
24478
24536
|
throw closed("Claustrum hub member has no base view");
|
|
24479
24537
|
if (base instanceof Error)
|
|
24480
24538
|
throw base;
|
|
24481
|
-
|
|
24539
|
+
let seed;
|
|
24540
|
+
if (!base.file) {
|
|
24541
|
+
const phaseDiagnostics2 = channel2("common-auth.claustrum.phases");
|
|
24542
|
+
if (phaseDiagnostics2.hasSubscribers)
|
|
24543
|
+
phaseDiagnostics2.publish({
|
|
24544
|
+
logger: this.#logger,
|
|
24545
|
+
phase: `seed read ${entry.provider} begin`
|
|
24546
|
+
});
|
|
24547
|
+
try {
|
|
24548
|
+
seed = await this.#seed(entry);
|
|
24549
|
+
} finally {
|
|
24550
|
+
if (phaseDiagnostics2.hasSubscribers)
|
|
24551
|
+
phaseDiagnostics2.publish({
|
|
24552
|
+
logger: this.#logger,
|
|
24553
|
+
phase: `seed read ${entry.provider} end`
|
|
24554
|
+
});
|
|
24555
|
+
}
|
|
24556
|
+
}
|
|
24482
24557
|
const roster = await refreshVaultRoster({
|
|
24483
24558
|
path: entry.path,
|
|
24484
24559
|
custody: { discover: async () => share },
|
|
@@ -24506,7 +24581,7 @@ var init_hub = __esm({
|
|
|
24506
24581
|
for (const directory of [
|
|
24507
24582
|
dirname10(this.#generationDirectory),
|
|
24508
24583
|
this.#generationDirectory,
|
|
24509
|
-
|
|
24584
|
+
join8(this.#generationDirectory, this.#key)
|
|
24510
24585
|
])
|
|
24511
24586
|
await ensureClaustrumPrivateDirectory(directory, {}, "roster directory");
|
|
24512
24587
|
}
|
|
@@ -24518,11 +24593,11 @@ var init_hub = __esm({
|
|
|
24518
24593
|
*/
|
|
24519
24594
|
async #seed(entry) {
|
|
24520
24595
|
const name = `${entry.provider}.json`;
|
|
24521
|
-
const candidates = [
|
|
24596
|
+
const candidates = [join8(this.#generationDirectory, name)];
|
|
24522
24597
|
try {
|
|
24523
24598
|
for (const key of await readdir(this.#generationDirectory))
|
|
24524
24599
|
if (key !== this.#key && FINGERPRINT.test(key))
|
|
24525
|
-
candidates.push(
|
|
24600
|
+
candidates.push(join8(this.#generationDirectory, key, name));
|
|
24526
24601
|
} catch {
|
|
24527
24602
|
}
|
|
24528
24603
|
let newest;
|
|
@@ -25095,7 +25170,7 @@ var init_lock = __esm({
|
|
|
25095
25170
|
import { createHash as createHash9 } from "node:crypto";
|
|
25096
25171
|
import { constants as constants2 } from "node:fs";
|
|
25097
25172
|
import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
|
|
25098
|
-
import { dirname as dirname11, resolve as
|
|
25173
|
+
import { dirname as dirname11, resolve as resolve11 } from "node:path";
|
|
25099
25174
|
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
25100
25175
|
function rootSpans(text2) {
|
|
25101
25176
|
let i = text2.indexOf("{") + 1;
|
|
@@ -25296,8 +25371,8 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
25296
25371
|
if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
|
|
25297
25372
|
throw new PiSlotError("invalid-options");
|
|
25298
25373
|
}
|
|
25299
|
-
const authPath =
|
|
25300
|
-
const stashPath =
|
|
25374
|
+
const authPath = resolve11(options.authPath);
|
|
25375
|
+
const stashPath = resolve11(options.stashPath);
|
|
25301
25376
|
if (authPath === stashPath || stashPath === `${authPath}.lock`) {
|
|
25302
25377
|
throw new PiSlotError("invalid-options");
|
|
25303
25378
|
}
|
|
@@ -25730,15 +25805,15 @@ var init_model_types = __esm({
|
|
|
25730
25805
|
|
|
25731
25806
|
// ../core/dist/pi-paths.js
|
|
25732
25807
|
import { homedir } from "node:os";
|
|
25733
|
-
import { dirname as dirname12, join as
|
|
25808
|
+
import { dirname as dirname12, join as join9 } from "node:path";
|
|
25734
25809
|
function getPiConfigDir() {
|
|
25735
|
-
return process.env.PI_AGENT_DIR?.trim() ||
|
|
25810
|
+
return process.env.PI_AGENT_DIR?.trim() || join9(homedir(), ".pi", "agent");
|
|
25736
25811
|
}
|
|
25737
25812
|
function getPiAntigravityAuthFile() {
|
|
25738
|
-
return process.env.PI_ANTIGRAVITY_AUTH_FILE?.trim() ||
|
|
25813
|
+
return process.env.PI_ANTIGRAVITY_AUTH_FILE?.trim() || join9(getPiConfigDir(), "antigravity-accounts.json");
|
|
25739
25814
|
}
|
|
25740
25815
|
function getPiAntigravityVaultDir() {
|
|
25741
|
-
return
|
|
25816
|
+
return join9(dirname12(getPiAntigravityAuthFile()), "antigravity-auth-vault");
|
|
25742
25817
|
}
|
|
25743
25818
|
var init_pi_paths = __esm({
|
|
25744
25819
|
"../core/dist/pi-paths.js"() {
|
|
@@ -25920,8 +25995,8 @@ function getDefaultTierId(allowedTiers) {
|
|
|
25920
25995
|
return allowedTiers[0]?.id;
|
|
25921
25996
|
}
|
|
25922
25997
|
function wait(ms) {
|
|
25923
|
-
return new Promise((
|
|
25924
|
-
setTimeout(
|
|
25998
|
+
return new Promise((resolve27) => {
|
|
25999
|
+
setTimeout(resolve27, ms);
|
|
25925
26000
|
});
|
|
25926
26001
|
}
|
|
25927
26002
|
function extractManagedProjectId(payload) {
|
|
@@ -28243,12 +28318,12 @@ var init_vault_provider_state = __esm({
|
|
|
28243
28318
|
function untilAborted2(pending, signal) {
|
|
28244
28319
|
if (!signal)
|
|
28245
28320
|
return pending;
|
|
28246
|
-
return new Promise((
|
|
28321
|
+
return new Promise((resolve27, reject) => {
|
|
28247
28322
|
const abort = () => reject(signal.reason);
|
|
28248
28323
|
signal.addEventListener("abort", abort, { once: true });
|
|
28249
28324
|
if (signal.aborted)
|
|
28250
28325
|
abort();
|
|
28251
|
-
pending.then(
|
|
28326
|
+
pending.then(resolve27, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
28252
28327
|
});
|
|
28253
28328
|
}
|
|
28254
28329
|
async function resolveClaustrumConnectionPath(explicit) {
|
|
@@ -28722,7 +28797,7 @@ var init_capture_sink2 = __esm({
|
|
|
28722
28797
|
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
28723
28798
|
import { lstat as lstat6, readFile as readFile8, rename as rename8, unlink as unlink8 } from "node:fs/promises";
|
|
28724
28799
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
28725
|
-
import { dirname as dirname13, join as
|
|
28800
|
+
import { dirname as dirname13, join as join10, resolve as resolve12 } from "node:path";
|
|
28726
28801
|
function ioCode2(detail) {
|
|
28727
28802
|
if (detail?.reason === "io-error") {
|
|
28728
28803
|
if (detail.win32Code === 2 || detail.win32Code === 3)
|
|
@@ -28743,7 +28818,7 @@ function isUnavailable2(api, error) {
|
|
|
28743
28818
|
}
|
|
28744
28819
|
async function assertNativeAddonLoads2(api) {
|
|
28745
28820
|
try {
|
|
28746
|
-
await api.verifyPrivatePath(
|
|
28821
|
+
await api.verifyPrivatePath(join10(tmpdir2(), `.common-auth-private-files-probe-${randomUUID13()}`), "file");
|
|
28747
28822
|
} catch (error) {
|
|
28748
28823
|
if (isUnavailable2(api, error))
|
|
28749
28824
|
throw privateFilesUnavailable2(error);
|
|
@@ -28769,7 +28844,7 @@ async function privateOperation2(path5, stage, operation) {
|
|
|
28769
28844
|
}
|
|
28770
28845
|
}
|
|
28771
28846
|
async function verifySafeDirectory2(path5, options) {
|
|
28772
|
-
path5 =
|
|
28847
|
+
path5 = resolve12(path5);
|
|
28773
28848
|
options ??= safeParentOptionsForTest2;
|
|
28774
28849
|
await privateOperation2(path5, "safe-parent", async () => {
|
|
28775
28850
|
const result = await (await loadBackend2()).verifySafeParent(path5, options);
|
|
@@ -28784,7 +28859,7 @@ async function verifySafeDirectory2(path5, options) {
|
|
|
28784
28859
|
});
|
|
28785
28860
|
}
|
|
28786
28861
|
async function verifyPrivate2(path5, kind, migrate = false) {
|
|
28787
|
-
path5 =
|
|
28862
|
+
path5 = resolve12(path5);
|
|
28788
28863
|
if (kind === "directory")
|
|
28789
28864
|
return verifySafeDirectory2(path5);
|
|
28790
28865
|
await privateOperation2(path5, "verify", async () => {
|
|
@@ -28819,7 +28894,7 @@ async function verifyPrivate2(path5, kind, migrate = false) {
|
|
|
28819
28894
|
});
|
|
28820
28895
|
}
|
|
28821
28896
|
async function ensurePrivateDirectory2(path5, _migrate = false, options) {
|
|
28822
|
-
path5 =
|
|
28897
|
+
path5 = resolve12(path5);
|
|
28823
28898
|
await privateOperation2(path5, "directory", async () => {
|
|
28824
28899
|
const api = await loadBackend2();
|
|
28825
28900
|
try {
|
|
@@ -28850,7 +28925,7 @@ async function readPrivateText2(path5, migrate = false) {
|
|
|
28850
28925
|
async function readPrivateBuffer2(path5, migrate = false) {
|
|
28851
28926
|
if (!windowsPrivateFiles2)
|
|
28852
28927
|
return readFile8(path5);
|
|
28853
|
-
path5 =
|
|
28928
|
+
path5 = resolve12(path5);
|
|
28854
28929
|
if (migrate) {
|
|
28855
28930
|
await verifySafeDirectory2(dirname13(path5));
|
|
28856
28931
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -28858,20 +28933,20 @@ async function readPrivateBuffer2(path5, migrate = false) {
|
|
|
28858
28933
|
return privateOperation2(path5, "read", async () => (await loadBackend2()).readOwnerOnly(path5));
|
|
28859
28934
|
}
|
|
28860
28935
|
async function createPrivateBytes2(path5, bytes) {
|
|
28861
|
-
await verifySafeDirectory2(dirname13(
|
|
28936
|
+
await verifySafeDirectory2(dirname13(resolve12(path5)));
|
|
28862
28937
|
await privateOperation2(path5, "create", async () => {
|
|
28863
|
-
await (await loadBackend2()).createPrivateFile(
|
|
28938
|
+
await (await loadBackend2()).createPrivateFile(resolve12(path5), bytes);
|
|
28864
28939
|
});
|
|
28865
28940
|
}
|
|
28866
28941
|
async function createPrivateDirectoryExclusive2(path5) {
|
|
28867
|
-
await verifySafeDirectory2(dirname13(
|
|
28942
|
+
await verifySafeDirectory2(dirname13(resolve12(path5)));
|
|
28868
28943
|
await privateOperation2(path5, "directory-create", async () => {
|
|
28869
|
-
await (await loadBackend2()).createOwnerOnly(
|
|
28944
|
+
await (await loadBackend2()).createOwnerOnly(resolve12(path5), { kind: "dir" });
|
|
28870
28945
|
});
|
|
28871
28946
|
}
|
|
28872
28947
|
async function replaceWindowsFile2(from, to, options = {}) {
|
|
28873
|
-
from =
|
|
28874
|
-
to =
|
|
28948
|
+
from = resolve12(from);
|
|
28949
|
+
to = resolve12(to);
|
|
28875
28950
|
const now = options.now ?? (() => performance.now());
|
|
28876
28951
|
const start = now();
|
|
28877
28952
|
const leaseDeadline = options.deadline ?? Infinity;
|
|
@@ -28914,7 +28989,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
|
|
|
28914
28989
|
throw error;
|
|
28915
28990
|
}
|
|
28916
28991
|
async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
28917
|
-
path5 =
|
|
28992
|
+
path5 = resolve12(path5);
|
|
28918
28993
|
await ensurePrivateDirectory2(dirname13(path5));
|
|
28919
28994
|
try {
|
|
28920
28995
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -28922,7 +28997,7 @@ async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
|
28922
28997
|
if (error.code !== "ENOENT")
|
|
28923
28998
|
throw error;
|
|
28924
28999
|
}
|
|
28925
|
-
const stage =
|
|
29000
|
+
const stage = resolve12(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
|
|
28926
29001
|
if (dirname13(stage) !== dirname13(path5))
|
|
28927
29002
|
throw new PrivateFileError2(path5, "stage-directory", { code: "EXDEV" });
|
|
28928
29003
|
let created = false;
|
|
@@ -29088,7 +29163,7 @@ var init_redact2 = __esm({
|
|
|
29088
29163
|
// src/common-auth-embedded/logger/engine.js
|
|
29089
29164
|
import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
|
|
29090
29165
|
import { open as open8 } from "node:fs/promises";
|
|
29091
|
-
import { dirname as dirname14, resolve as
|
|
29166
|
+
import { dirname as dirname14, resolve as resolve13 } from "node:path";
|
|
29092
29167
|
function chmodPrivate2(path5) {
|
|
29093
29168
|
try {
|
|
29094
29169
|
chmodSync2(path5, 384);
|
|
@@ -29139,7 +29214,7 @@ async function openWindowsFile2(sink, file) {
|
|
|
29139
29214
|
return sink.handle;
|
|
29140
29215
|
}
|
|
29141
29216
|
async function flushWindowsFile2(sink, file, text2) {
|
|
29142
|
-
file =
|
|
29217
|
+
file = resolve13(file);
|
|
29143
29218
|
try {
|
|
29144
29219
|
if (sink.file !== file)
|
|
29145
29220
|
await closeWindowsFile2(sink);
|
|
@@ -29286,7 +29361,7 @@ function createEngine2(options) {
|
|
|
29286
29361
|
});
|
|
29287
29362
|
}, 500);
|
|
29288
29363
|
}
|
|
29289
|
-
function emit(
|
|
29364
|
+
function emit(channel3, level, message, data) {
|
|
29290
29365
|
if (logFileSource === void 0 && captureSink === void 0)
|
|
29291
29366
|
return;
|
|
29292
29367
|
try {
|
|
@@ -29299,10 +29374,10 @@ function createEngine2(options) {
|
|
|
29299
29374
|
} catch {
|
|
29300
29375
|
scrubbedData = "[unserializable]";
|
|
29301
29376
|
}
|
|
29302
|
-
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${
|
|
29377
|
+
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize2(scrubbedData)) + "\n";
|
|
29303
29378
|
try {
|
|
29304
29379
|
captureSink?.({
|
|
29305
|
-
channel,
|
|
29380
|
+
channel: channel3,
|
|
29306
29381
|
level,
|
|
29307
29382
|
message: scrubbedMessage,
|
|
29308
29383
|
data: scrubbedData
|
|
@@ -29322,13 +29397,13 @@ function createEngine2(options) {
|
|
|
29322
29397
|
} catch {
|
|
29323
29398
|
}
|
|
29324
29399
|
}
|
|
29325
|
-
function createLogger5(
|
|
29400
|
+
function createLogger5(channel3) {
|
|
29326
29401
|
return {
|
|
29327
|
-
error: (m, d) => emit(
|
|
29328
|
-
warn: (m, d) => emit(
|
|
29329
|
-
info: (m, d) => emit(
|
|
29330
|
-
debug: (m, d) => emit(
|
|
29331
|
-
trace: (m, d) => emit(
|
|
29402
|
+
error: (m, d) => emit(channel3, "error", m, d),
|
|
29403
|
+
warn: (m, d) => emit(channel3, "warn", m, d),
|
|
29404
|
+
info: (m, d) => emit(channel3, "info", m, d),
|
|
29405
|
+
debug: (m, d) => emit(channel3, "debug", m, d),
|
|
29406
|
+
trace: (m, d) => emit(channel3, "trace", m, d)
|
|
29332
29407
|
};
|
|
29333
29408
|
}
|
|
29334
29409
|
function reset() {
|
|
@@ -29424,6 +29499,10 @@ function createVaultRequestCredentials(source, onAdmitted) {
|
|
|
29424
29499
|
const issued = /* @__PURE__ */ new WeakMap();
|
|
29425
29500
|
return {
|
|
29426
29501
|
domain: "vault",
|
|
29502
|
+
routingCandidate: (row) => ({
|
|
29503
|
+
accountId: row.route.accountIdentity,
|
|
29504
|
+
credentialId: row.route.credentialId
|
|
29505
|
+
}),
|
|
29427
29506
|
...source.retryAfter401 && {
|
|
29428
29507
|
retryAfter401(served, current, site) {
|
|
29429
29508
|
const original = issued.get(served);
|
|
@@ -29935,7 +30014,7 @@ var init_vault_insula_quota = __esm({
|
|
|
29935
30014
|
|
|
29936
30015
|
// src/plugin/vault-custody.ts
|
|
29937
30016
|
import { chmod as chmod3, mkdir as mkdir11, readFile as readFile9, stat as stat8 } from "node:fs/promises";
|
|
29938
|
-
import { join as
|
|
30017
|
+
import { join as join11 } from "node:path";
|
|
29939
30018
|
async function enrollmentFilesIdentity(paths) {
|
|
29940
30019
|
const takenAt = performance.now();
|
|
29941
30020
|
let coarse = process.platform === "win32";
|
|
@@ -29959,9 +30038,9 @@ function openCodeVaultPaths(vaultDir) {
|
|
|
29959
30038
|
const dir = vaultDir;
|
|
29960
30039
|
return {
|
|
29961
30040
|
dir,
|
|
29962
|
-
modeFile:
|
|
29963
|
-
rosterFile:
|
|
29964
|
-
stateFile:
|
|
30041
|
+
modeFile: join11(dir, "opencode-mode.json"),
|
|
30042
|
+
rosterFile: join11(dir, "opencode-roster.json"),
|
|
30043
|
+
stateFile: join11(dir, "opencode-state.json")
|
|
29965
30044
|
};
|
|
29966
30045
|
}
|
|
29967
30046
|
async function ensureVaultDir(dir) {
|
|
@@ -30198,11 +30277,11 @@ function createOpenCodeVaultCustody(options) {
|
|
|
30198
30277
|
].join("\n");
|
|
30199
30278
|
const waitForApproval = async () => {
|
|
30200
30279
|
while (!closed2) {
|
|
30201
|
-
await new Promise((
|
|
30280
|
+
await new Promise((resolve27) => {
|
|
30202
30281
|
const done = () => {
|
|
30203
30282
|
clearTimeout(timer);
|
|
30204
30283
|
cancelWait = void 0;
|
|
30205
|
-
|
|
30284
|
+
resolve27();
|
|
30206
30285
|
};
|
|
30207
30286
|
const timer = setTimeout(done, 2e3);
|
|
30208
30287
|
timer.unref?.();
|
|
@@ -30589,20 +30668,20 @@ import { randomUUID as randomUUID14 } from "node:crypto";
|
|
|
30589
30668
|
import { realpathSync, rmSync } from "node:fs";
|
|
30590
30669
|
import { chmod as chmod4, mkdir as mkdir12, readFile as readFile10, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
|
|
30591
30670
|
import { homedir as homedir2 } from "node:os";
|
|
30592
|
-
import { join as
|
|
30671
|
+
import { join as join12, resolve as resolve14 } from "node:path";
|
|
30593
30672
|
function processHeartbeatDir() {
|
|
30594
|
-
const base = process.env.XDG_STATE_HOME ||
|
|
30595
|
-
return
|
|
30673
|
+
const base = process.env.XDG_STATE_HOME || join12(homedir2(), ".local", "state");
|
|
30674
|
+
return join12(base, "cortexkit", "antigravity-auth", "processes");
|
|
30596
30675
|
}
|
|
30597
30676
|
function processHeartbeatPath(pid = process.pid, dir = processHeartbeatDir()) {
|
|
30598
|
-
return
|
|
30677
|
+
return join12(dir, `${pid}.json`);
|
|
30599
30678
|
}
|
|
30600
30679
|
function processConfigFolderKey() {
|
|
30601
30680
|
const folder = getConfigDir();
|
|
30602
30681
|
try {
|
|
30603
30682
|
return realpathSync.native(folder);
|
|
30604
30683
|
} catch {
|
|
30605
|
-
return
|
|
30684
|
+
return resolve14(folder);
|
|
30606
30685
|
}
|
|
30607
30686
|
}
|
|
30608
30687
|
function processHasOlderGeneration() {
|
|
@@ -30840,15 +30919,15 @@ var init_process_heartbeat = __esm({
|
|
|
30840
30919
|
// src/version-fence.ts
|
|
30841
30920
|
import { readdir as readdir2, readFile as readFile11 } from "node:fs/promises";
|
|
30842
30921
|
import { homedir as homedir3 } from "node:os";
|
|
30843
|
-
import { join as
|
|
30922
|
+
import { join as join13 } from "node:path";
|
|
30844
30923
|
function defaultStateHome() {
|
|
30845
|
-
return process.env.XDG_STATE_HOME ||
|
|
30924
|
+
return process.env.XDG_STATE_HOME || join13(homedir3(), ".local", "state");
|
|
30846
30925
|
}
|
|
30847
30926
|
function processHeartbeatDir2(stateHome = defaultStateHome()) {
|
|
30848
|
-
return
|
|
30927
|
+
return join13(stateHome, "cortexkit", "antigravity-auth", "processes");
|
|
30849
30928
|
}
|
|
30850
30929
|
function rpcStateRoot(stateHome = defaultStateHome()) {
|
|
30851
|
-
return
|
|
30930
|
+
return join13(stateHome, "cortexkit", "antigravity-auth", "rpc");
|
|
30852
30931
|
}
|
|
30853
30932
|
function isRpcProjectDir(name) {
|
|
30854
30933
|
return /^[0-9a-f]{16}$/.test(name);
|
|
@@ -30963,7 +31042,7 @@ async function versionFenceOpen(options) {
|
|
|
30963
31042
|
for (const name of heartbeats.ok ? heartbeats.names : []) {
|
|
30964
31043
|
const pid = pidFrom(name, /^(\d+)\.json$/);
|
|
30965
31044
|
if (pid === void 0 || pid === self) continue;
|
|
30966
|
-
const path5 =
|
|
31045
|
+
const path5 = join13(heartbeatDir, name);
|
|
30967
31046
|
const heartbeat = await readProcessRecord(path5, pid);
|
|
30968
31047
|
if (heartbeat.kind === "gone") continue;
|
|
30969
31048
|
if (!alive(pid)) continue;
|
|
@@ -30987,7 +31066,7 @@ async function versionFenceOpen(options) {
|
|
|
30987
31066
|
block({ pid: "unknown", version: "unknown", detail: projects.error });
|
|
30988
31067
|
for (const project2 of projects.ok ? projects.names : []) {
|
|
30989
31068
|
if (!isRpcProjectDir(project2)) continue;
|
|
30990
|
-
const dir =
|
|
31069
|
+
const dir = join13(rpcRoot, project2);
|
|
30991
31070
|
const ports = await list2(dir);
|
|
30992
31071
|
if (!ports.ok) {
|
|
30993
31072
|
if (ports.code === "ENOTDIR") continue;
|
|
@@ -30997,7 +31076,7 @@ async function versionFenceOpen(options) {
|
|
|
30997
31076
|
for (const name of ports.names) {
|
|
30998
31077
|
const pid = pidFrom(name, /^port-(\d+)\.json$/);
|
|
30999
31078
|
if (pid === void 0 || pid === self || !alive(pid)) continue;
|
|
31000
|
-
const path5 =
|
|
31079
|
+
const path5 = join13(dir, name);
|
|
31001
31080
|
const port = await readProcessRecord(path5, pid);
|
|
31002
31081
|
if (port.kind === "gone") continue;
|
|
31003
31082
|
const version = port.kind === "ok" ? port.version : "unknown";
|
|
@@ -31048,7 +31127,7 @@ import {
|
|
|
31048
31127
|
stat as stat9,
|
|
31049
31128
|
unlink as unlink9
|
|
31050
31129
|
} from "node:fs/promises";
|
|
31051
|
-
import { basename as basename4, dirname as dirname15, join as
|
|
31130
|
+
import { basename as basename4, dirname as dirname15, join as join14, resolve as resolve15 } from "node:path";
|
|
31052
31131
|
function refusalMessage(stateDir, errorClass2) {
|
|
31053
31132
|
if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
|
|
31054
31133
|
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.`;
|
|
@@ -31135,7 +31214,7 @@ function prepareRuntimeLayout(options) {
|
|
|
31135
31214
|
async function decide(location, options) {
|
|
31136
31215
|
const log16 = options.log ?? createLogger4("runtime-layout");
|
|
31137
31216
|
const stateDir = location.stateHomeDir;
|
|
31138
|
-
const markerPath =
|
|
31217
|
+
const markerPath = join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
|
|
31139
31218
|
const files = layoutFiles(location, options.accountFile);
|
|
31140
31219
|
const fence = options.fence ?? defaultFence(options.version);
|
|
31141
31220
|
const stateHome = async () => {
|
|
@@ -31147,7 +31226,7 @@ async function decide(location, options) {
|
|
|
31147
31226
|
if (marker?.oldFilesRemoved) {
|
|
31148
31227
|
await refuseReappearedFiles(location, files);
|
|
31149
31228
|
const manifestLeft = await exists2(
|
|
31150
|
-
|
|
31229
|
+
join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
|
|
31151
31230
|
).catch(() => true);
|
|
31152
31231
|
if (!manifestLeft) {
|
|
31153
31232
|
await settleVault(location, options, "state-home", log16);
|
|
@@ -31313,7 +31392,7 @@ async function prepareAccountStore(options) {
|
|
|
31313
31392
|
await ensureOwnerOnlyDir(location.stateHomeDir);
|
|
31314
31393
|
const lock = await takeLock(
|
|
31315
31394
|
RUNTIME_LAYOUT_LOCK_NAME,
|
|
31316
|
-
|
|
31395
|
+
join14(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
31317
31396
|
options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
|
|
31318
31397
|
log16
|
|
31319
31398
|
);
|
|
@@ -31427,7 +31506,7 @@ async function recordAnchor(location, options, anchor, log16) {
|
|
|
31427
31506
|
}
|
|
31428
31507
|
async function storeMovePathResolves(stateAnchor, location, log16) {
|
|
31429
31508
|
if (folderResolvesToItself(
|
|
31430
|
-
|
|
31509
|
+
join14(location.stateHomeDir, "antigravity-accounts.json")
|
|
31431
31510
|
))
|
|
31432
31511
|
return true;
|
|
31433
31512
|
logOnce(
|
|
@@ -31795,7 +31874,7 @@ async function removeLeftoverManifest(location, layoutLock, steps, log16) {
|
|
|
31795
31874
|
}
|
|
31796
31875
|
}
|
|
31797
31876
|
async function removeManifestOwned(stateDir, layoutLock, steps) {
|
|
31798
|
-
const path5 =
|
|
31877
|
+
const path5 = join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE);
|
|
31799
31878
|
if (!await exists2(path5)) return;
|
|
31800
31879
|
await beforeRemove(path5, layoutLock, steps);
|
|
31801
31880
|
await removeManifest(stateDir);
|
|
@@ -31835,7 +31914,7 @@ async function takeDataLocks(files, log16) {
|
|
|
31835
31914
|
locks.push(
|
|
31836
31915
|
await takeLock(
|
|
31837
31916
|
lock.name,
|
|
31838
|
-
|
|
31917
|
+
join14(files.vault.old, lock.file),
|
|
31839
31918
|
lock.waitMs,
|
|
31840
31919
|
log16
|
|
31841
31920
|
)
|
|
@@ -31862,8 +31941,8 @@ function sha256(bytes) {
|
|
|
31862
31941
|
}
|
|
31863
31942
|
function vaultStateFile(files) {
|
|
31864
31943
|
return {
|
|
31865
|
-
old:
|
|
31866
|
-
next:
|
|
31944
|
+
old: join14(files.vault.old, VAULT_ENROLLMENT_STATE_FILE),
|
|
31945
|
+
next: join14(files.vault.next, VAULT_ENROLLMENT_STATE_FILE)
|
|
31867
31946
|
};
|
|
31868
31947
|
}
|
|
31869
31948
|
async function keepableVaultState(files, present5) {
|
|
@@ -31903,10 +31982,10 @@ async function isVaultShapedKeptState(files) {
|
|
|
31903
31982
|
async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
|
|
31904
31983
|
const location = runtimeLayoutLocation();
|
|
31905
31984
|
const files = layoutFiles(location, accountFile);
|
|
31906
|
-
if (
|
|
31985
|
+
if (resolve15(vaultDir) !== resolve15(files.vault.next)) return;
|
|
31907
31986
|
const stateDir = location.stateHomeDir;
|
|
31908
31987
|
const marker = await readMarker(
|
|
31909
|
-
|
|
31988
|
+
join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
31910
31989
|
stateDir,
|
|
31911
31990
|
files.vault.old
|
|
31912
31991
|
);
|
|
@@ -31935,13 +32014,13 @@ async function vaultFiles(dir) {
|
|
|
31935
32014
|
}
|
|
31936
32015
|
async function presentOldFiles(files) {
|
|
31937
32016
|
return (await vaultFiles(files.vault.old)).map((name) => ({
|
|
31938
|
-
old:
|
|
31939
|
-
next:
|
|
32017
|
+
old: join14(files.vault.old, name),
|
|
32018
|
+
next: join14(files.vault.next, name)
|
|
31940
32019
|
}));
|
|
31941
32020
|
}
|
|
31942
32021
|
async function destinationFiles(files) {
|
|
31943
32022
|
return (await vaultFiles(files.vault.next)).map(
|
|
31944
|
-
(name) =>
|
|
32023
|
+
(name) => join14(files.vault.next, name)
|
|
31945
32024
|
);
|
|
31946
32025
|
}
|
|
31947
32026
|
async function physicalAliases(location, files) {
|
|
@@ -31950,7 +32029,7 @@ async function physicalAliases(location, files) {
|
|
|
31950
32029
|
[files.vault.old, files.vault.next]
|
|
31951
32030
|
];
|
|
31952
32031
|
for (const name of VAULT_FILE_NAMES)
|
|
31953
|
-
pairs.push([
|
|
32032
|
+
pairs.push([join14(files.vault.old, name), join14(files.vault.next, name)]);
|
|
31954
32033
|
const aliased = [];
|
|
31955
32034
|
for (const [old, next] of pairs)
|
|
31956
32035
|
if (await samePhysical(old, next)) aliased.push(old);
|
|
@@ -32062,11 +32141,11 @@ async function unlinkIfIdentical(file, stateDir, guard) {
|
|
|
32062
32141
|
async function refuseReappearedFiles(location, files) {
|
|
32063
32142
|
const keptState = vaultStateFile(files).old;
|
|
32064
32143
|
for (const name of await vaultFiles(files.vault.old)) {
|
|
32065
|
-
const old =
|
|
32144
|
+
const old = join14(files.vault.old, name);
|
|
32066
32145
|
if (old === keptState && await isVaultShapedKeptState(files)) continue;
|
|
32067
32146
|
throw credentialConflict(location.stateHomeDir, {
|
|
32068
32147
|
old,
|
|
32069
|
-
next:
|
|
32148
|
+
next: join14(files.vault.next, name)
|
|
32070
32149
|
});
|
|
32071
32150
|
}
|
|
32072
32151
|
}
|
|
@@ -32108,13 +32187,13 @@ async function assertOwnFolder(location, marker, files) {
|
|
|
32108
32187
|
const stateDir = location.stateHomeDir;
|
|
32109
32188
|
if (marker?.oldDir !== void 0 && marker.oldDir !== location.key)
|
|
32110
32189
|
throw foreignMarker(
|
|
32111
|
-
|
|
32190
|
+
join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
32112
32191
|
location.key,
|
|
32113
32192
|
files.vault.old
|
|
32114
32193
|
);
|
|
32115
32194
|
let text2;
|
|
32116
32195
|
try {
|
|
32117
|
-
text2 = await readFile12(
|
|
32196
|
+
text2 = await readFile12(join14(stateDir, RUNTIME_CONFIG_DIR_NOTE_FILE), "utf8");
|
|
32118
32197
|
} catch (error) {
|
|
32119
32198
|
const code2 = error.code;
|
|
32120
32199
|
if (code2 === "ENOENT" || code2 === "ENOTDIR") return;
|
|
@@ -32128,7 +32207,7 @@ async function assertOwnFolder(location, marker, files) {
|
|
|
32128
32207
|
if (owner !== location.key) throw foreignFolder(stateDir, location.key);
|
|
32129
32208
|
}
|
|
32130
32209
|
async function writeOwnerNote(location) {
|
|
32131
|
-
const path5 =
|
|
32210
|
+
const path5 = join14(location.stateHomeDir, RUNTIME_CONFIG_DIR_NOTE_FILE);
|
|
32132
32211
|
if (await exists2(path5)) return;
|
|
32133
32212
|
await writePrivateText(
|
|
32134
32213
|
path5,
|
|
@@ -32139,7 +32218,7 @@ async function writeOwnerNote(location) {
|
|
|
32139
32218
|
async function readManifest(stateDir) {
|
|
32140
32219
|
let text2;
|
|
32141
32220
|
try {
|
|
32142
|
-
text2 = await readFile12(
|
|
32221
|
+
text2 = await readFile12(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE), "utf8");
|
|
32143
32222
|
} catch (error) {
|
|
32144
32223
|
if (error.code === "ENOENT") return /* @__PURE__ */ new Set();
|
|
32145
32224
|
throw error;
|
|
@@ -32156,13 +32235,13 @@ async function readManifest(stateDir) {
|
|
|
32156
32235
|
}
|
|
32157
32236
|
async function writeManifest(stateDir, paths) {
|
|
32158
32237
|
await writePrivateText(
|
|
32159
|
-
|
|
32238
|
+
join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE),
|
|
32160
32239
|
`${JSON.stringify({ version: 1, files: paths }, null, 2)}
|
|
32161
32240
|
`
|
|
32162
32241
|
);
|
|
32163
32242
|
}
|
|
32164
32243
|
async function removeManifest(stateDir) {
|
|
32165
|
-
await unlink9(
|
|
32244
|
+
await unlink9(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
|
|
32166
32245
|
(error) => {
|
|
32167
32246
|
if (error.code !== "ENOENT") throw error;
|
|
32168
32247
|
}
|
|
@@ -32331,9 +32410,9 @@ import {
|
|
|
32331
32410
|
writeFileSync
|
|
32332
32411
|
} from "node:fs";
|
|
32333
32412
|
import { homedir as homedir4 } from "node:os";
|
|
32334
|
-
import { dirname as dirname16, join as
|
|
32413
|
+
import { dirname as dirname16, join as join15, resolve as resolve16 } from "node:path";
|
|
32335
32414
|
async function ensureGitignore(configDir) {
|
|
32336
|
-
const gitignorePath =
|
|
32415
|
+
const gitignorePath = join15(configDir, ".gitignore");
|
|
32337
32416
|
try {
|
|
32338
32417
|
let content;
|
|
32339
32418
|
let existingLines = [];
|
|
@@ -32379,8 +32458,8 @@ async function ensureGitignore(configDir) {
|
|
|
32379
32458
|
}
|
|
32380
32459
|
}
|
|
32381
32460
|
function getLegacyWindowsConfigDir() {
|
|
32382
|
-
return
|
|
32383
|
-
process.env.APPDATA ||
|
|
32461
|
+
return join15(
|
|
32462
|
+
process.env.APPDATA || join15(homedir4(), "AppData", "Roaming"),
|
|
32384
32463
|
"opencode"
|
|
32385
32464
|
);
|
|
32386
32465
|
}
|
|
@@ -32388,15 +32467,15 @@ function getConfigDir() {
|
|
|
32388
32467
|
if (process.env.OPENCODE_CONFIG_DIR) {
|
|
32389
32468
|
return process.env.OPENCODE_CONFIG_DIR;
|
|
32390
32469
|
}
|
|
32391
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ||
|
|
32392
|
-
return
|
|
32470
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME || join15(homedir4(), ".config");
|
|
32471
|
+
return join15(xdgConfig2, "opencode");
|
|
32393
32472
|
}
|
|
32394
32473
|
function migrateLegacyWindowsConfig() {
|
|
32395
32474
|
if (process.platform !== "win32") {
|
|
32396
32475
|
return false;
|
|
32397
32476
|
}
|
|
32398
|
-
const newPath =
|
|
32399
|
-
const legacyPath =
|
|
32477
|
+
const newPath = join15(getConfigDir(), "antigravity-accounts.json");
|
|
32478
|
+
const legacyPath = join15(
|
|
32400
32479
|
getLegacyWindowsConfigDir(),
|
|
32401
32480
|
"antigravity-accounts.json"
|
|
32402
32481
|
);
|
|
@@ -32431,8 +32510,8 @@ function migrateLegacyWindowsConfig() {
|
|
|
32431
32510
|
}
|
|
32432
32511
|
}
|
|
32433
32512
|
function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
32434
|
-
const standard =
|
|
32435
|
-
const legacy =
|
|
32513
|
+
const standard = resolve16(newPath);
|
|
32514
|
+
const legacy = resolve16(legacyPath);
|
|
32436
32515
|
if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
|
|
32437
32516
|
const standardPointer = existsSync3(accountStorePointerPath(standard));
|
|
32438
32517
|
const legacyPointer = existsSync3(accountStorePointerPath(legacy));
|
|
@@ -32446,15 +32525,15 @@ function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
|
32446
32525
|
return newPath;
|
|
32447
32526
|
}
|
|
32448
32527
|
function getStoragePathWithMigration() {
|
|
32449
|
-
const newPath =
|
|
32528
|
+
const newPath = join15(getConfigDir(), "antigravity-accounts.json");
|
|
32450
32529
|
if (process.platform === "win32") {
|
|
32451
32530
|
migrateLegacyWindowsConfig();
|
|
32452
|
-
const legacyPath =
|
|
32531
|
+
const legacyPath = join15(
|
|
32453
32532
|
getLegacyWindowsConfigDir(),
|
|
32454
32533
|
"antigravity-accounts.json"
|
|
32455
32534
|
);
|
|
32456
32535
|
const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
|
|
32457
|
-
if (
|
|
32536
|
+
if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve16(anchored)))) {
|
|
32458
32537
|
log5.info("Using legacy Windows config path (migration failed)", {
|
|
32459
32538
|
legacyPath,
|
|
32460
32539
|
newPath
|
|
@@ -32468,20 +32547,20 @@ function stateHomeStoragePath() {
|
|
|
32468
32547
|
return stateHomeAccountFile(runtimeLayoutLocation());
|
|
32469
32548
|
}
|
|
32470
32549
|
function accountFileForVault(configDir = getConfigDir()) {
|
|
32471
|
-
const configured =
|
|
32550
|
+
const configured = join15(configDir, "antigravity-accounts.json");
|
|
32472
32551
|
if (process.platform !== "win32") return configured;
|
|
32473
32552
|
const legacyDir = getLegacyWindowsConfigDir();
|
|
32474
|
-
if (
|
|
32553
|
+
if (resolve16(configDir).toLowerCase() === resolve16(legacyDir).toLowerCase())
|
|
32475
32554
|
return configured;
|
|
32476
|
-
const configuredVault =
|
|
32477
|
-
const legacyVault =
|
|
32555
|
+
const configuredVault = join15(configDir, "antigravity-auth-vault");
|
|
32556
|
+
const legacyVault = join15(legacyDir, "antigravity-auth-vault");
|
|
32478
32557
|
const configuredPresent = existsSync3(configuredVault);
|
|
32479
32558
|
const legacyPresent = existsSync3(legacyVault);
|
|
32480
32559
|
if (configuredPresent && legacyPresent)
|
|
32481
32560
|
throw new Error(
|
|
32482
32561
|
`Two vault folders exist: ${configuredVault} and ${legacyVault}. Keep one vault enrollment before restarting OpenCode.`
|
|
32483
32562
|
);
|
|
32484
|
-
return legacyPresent ?
|
|
32563
|
+
return legacyPresent ? join15(legacyDir, "antigravity-accounts.json") : configured;
|
|
32485
32564
|
}
|
|
32486
32565
|
async function prepareLocalAccountStore() {
|
|
32487
32566
|
if (!decidedRuntimeLayout(runtimeLayoutLocation())) return;
|
|
@@ -32496,13 +32575,13 @@ function getStoragePath() {
|
|
|
32496
32575
|
if (anchor === "config") return getStoragePathWithMigration();
|
|
32497
32576
|
const location = runtimeLayoutLocation();
|
|
32498
32577
|
if (decidedRuntimeLayout(location))
|
|
32499
|
-
return
|
|
32578
|
+
return join15(location.configDir, "antigravity-accounts.json");
|
|
32500
32579
|
const configPath = getStoragePathWithMigration();
|
|
32501
32580
|
return readForwardedAccountStore(configPath)?.legacyPath ?? configPath;
|
|
32502
32581
|
}
|
|
32503
32582
|
async function assertLegacyPoolInUse(legacyPath) {
|
|
32504
32583
|
try {
|
|
32505
|
-
await assertLegacyAccountStorageWritable(
|
|
32584
|
+
await assertLegacyAccountStorageWritable(resolve16(legacyPath));
|
|
32506
32585
|
} catch (error) {
|
|
32507
32586
|
throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
|
|
32508
32587
|
}
|
|
@@ -32520,7 +32599,7 @@ function refusalMessage2(admission) {
|
|
|
32520
32599
|
async function bindingOf(options) {
|
|
32521
32600
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
32522
32601
|
const now = options.now ?? (() => Date.now());
|
|
32523
|
-
const legacyPath =
|
|
32602
|
+
const legacyPath = resolve16(options.legacyPath ?? getStoragePath());
|
|
32524
32603
|
return {
|
|
32525
32604
|
legacyPath,
|
|
32526
32605
|
now,
|
|
@@ -32589,7 +32668,7 @@ async function openAccountStore(options) {
|
|
|
32589
32668
|
async function initializeFreshAccountStoreFor(modules, options = {}) {
|
|
32590
32669
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
32591
32670
|
return initializeFreshAccountStore(modules, {
|
|
32592
|
-
legacyPath:
|
|
32671
|
+
legacyPath: resolve16(options.legacyPath ?? getStoragePath()),
|
|
32593
32672
|
now: options.now ?? (() => Date.now())
|
|
32594
32673
|
});
|
|
32595
32674
|
}
|
|
@@ -32667,12 +32746,12 @@ var init_storage = __esm({
|
|
|
32667
32746
|
import { createHash as createHash12 } from "node:crypto";
|
|
32668
32747
|
import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
32669
32748
|
import { homedir as homedir5 } from "node:os";
|
|
32670
|
-
import { dirname as dirname17, join as
|
|
32749
|
+
import { dirname as dirname17, join as join16, resolve as resolve17 } from "node:path";
|
|
32671
32750
|
function configDirIdentity(path5) {
|
|
32672
32751
|
try {
|
|
32673
32752
|
return realpathSync2.native(path5);
|
|
32674
32753
|
} catch {
|
|
32675
|
-
return
|
|
32754
|
+
return resolve17(path5);
|
|
32676
32755
|
}
|
|
32677
32756
|
}
|
|
32678
32757
|
function decisionKey(location) {
|
|
@@ -32680,18 +32759,18 @@ function decisionKey(location) {
|
|
|
32680
32759
|
}
|
|
32681
32760
|
function runtimeLayoutLocation(configDir = getConfigDir()) {
|
|
32682
32761
|
const stateHome = defaultStateHome();
|
|
32683
|
-
const homeConfig =
|
|
32762
|
+
const homeConfig = join16(homedir5(), ".config", "opencode");
|
|
32684
32763
|
const cacheKey = `${configDir}\0${homeConfig}\0${stateHome}`;
|
|
32685
32764
|
const cached = shared2.locations.get(cacheKey);
|
|
32686
32765
|
if (cached && shared2.decisions.has(decisionKey(cached))) return cached;
|
|
32687
32766
|
const key = configDirIdentity(configDir);
|
|
32688
32767
|
if (cached && cached.key === key) return cached;
|
|
32689
32768
|
const isDefaultConfigDir = key === configDirIdentity(homeConfig);
|
|
32690
|
-
const root =
|
|
32769
|
+
const root = join16(stateHome, "cortexkit", "antigravity-auth");
|
|
32691
32770
|
const location = {
|
|
32692
32771
|
key,
|
|
32693
32772
|
configDir,
|
|
32694
|
-
stateHomeDir: isDefaultConfigDir ?
|
|
32773
|
+
stateHomeDir: isDefaultConfigDir ? join16(root, "opencode") : join16(
|
|
32695
32774
|
root,
|
|
32696
32775
|
`opencode-${createHash12("sha256").update(key).digest("hex").slice(0, 16)}`
|
|
32697
32776
|
),
|
|
@@ -32713,49 +32792,49 @@ function decidedAccountStoreAnchor(location) {
|
|
|
32713
32792
|
return shared2.storeAnchors.get(`${location.stateHomeDir}\0${location.key}`);
|
|
32714
32793
|
}
|
|
32715
32794
|
function currentRuntimeLayout(location = runtimeLayoutLocation()) {
|
|
32716
|
-
return decidedRuntimeLayout(location) ?? (existsSync4(
|
|
32795
|
+
return decidedRuntimeLayout(location) ?? (existsSync4(join16(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE)) ? "state-home" : "legacy");
|
|
32717
32796
|
}
|
|
32718
32797
|
function legacyWindowsConfigDir() {
|
|
32719
|
-
return
|
|
32720
|
-
process.env.APPDATA ||
|
|
32798
|
+
return join16(
|
|
32799
|
+
process.env.APPDATA || join16(homedir5(), "AppData", "Roaming"),
|
|
32721
32800
|
"opencode"
|
|
32722
32801
|
);
|
|
32723
32802
|
}
|
|
32724
32803
|
function pluginStateDir() {
|
|
32725
|
-
return
|
|
32804
|
+
return join16(defaultStateHome(), "cortexkit", "antigravity-auth");
|
|
32726
32805
|
}
|
|
32727
32806
|
function stateHomeSignatureCacheFile() {
|
|
32728
|
-
return
|
|
32807
|
+
return join16(pluginStateDir(), SIGNATURE_CACHE_FILE_NAME);
|
|
32729
32808
|
}
|
|
32730
32809
|
function legacySignatureCacheFile() {
|
|
32731
|
-
const configHome = process.platform === "win32" ? legacyWindowsConfigDir() :
|
|
32732
|
-
process.env.XDG_CONFIG_HOME ||
|
|
32810
|
+
const configHome = process.platform === "win32" ? legacyWindowsConfigDir() : join16(
|
|
32811
|
+
process.env.XDG_CONFIG_HOME || join16(homedir5(), ".config"),
|
|
32733
32812
|
"opencode"
|
|
32734
32813
|
);
|
|
32735
|
-
return
|
|
32814
|
+
return join16(configHome, SIGNATURE_CACHE_FILE_NAME);
|
|
32736
32815
|
}
|
|
32737
32816
|
function stateHomeLogsDir() {
|
|
32738
|
-
return
|
|
32817
|
+
return join16(pluginStateDir(), "logs");
|
|
32739
32818
|
}
|
|
32740
32819
|
function legacyAccountFile(configDir = getConfigDir()) {
|
|
32741
|
-
const standard =
|
|
32820
|
+
const standard = join16(configDir, ACCOUNT_FILE_NAME);
|
|
32742
32821
|
if (process.platform !== "win32") return standard;
|
|
32743
32822
|
return resolveWindowsAccountAnchor(
|
|
32744
32823
|
standard,
|
|
32745
|
-
|
|
32824
|
+
join16(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
|
|
32746
32825
|
);
|
|
32747
32826
|
}
|
|
32748
32827
|
function legacyVaultDir(accountFile) {
|
|
32749
|
-
return
|
|
32828
|
+
return join16(dirname17(accountFile), VAULT_DIR_NAME);
|
|
32750
32829
|
}
|
|
32751
32830
|
function stateHomeVaultDir(location) {
|
|
32752
|
-
return
|
|
32831
|
+
return join16(location.stateHomeDir, VAULT_DIR_NAME);
|
|
32753
32832
|
}
|
|
32754
32833
|
function accountStorePointerPath2(accountFile) {
|
|
32755
32834
|
return `${accountFile}${ACCOUNT_STORE_POINTER_SUFFIX}`;
|
|
32756
32835
|
}
|
|
32757
32836
|
function stateHomeAccountFile(location) {
|
|
32758
|
-
return
|
|
32837
|
+
return join16(realPathOrSelf(location.stateHomeDir), ACCOUNT_FILE_NAME);
|
|
32759
32838
|
}
|
|
32760
32839
|
function realPathOrSelf(path5) {
|
|
32761
32840
|
try {
|
|
@@ -32999,7 +33078,7 @@ import {
|
|
|
32999
33078
|
statSync as statSync4,
|
|
33000
33079
|
unlinkSync as unlinkSync2
|
|
33001
33080
|
} from "node:fs";
|
|
33002
|
-
import { join as
|
|
33081
|
+
import { join as join17 } from "node:path";
|
|
33003
33082
|
import { env } from "node:process";
|
|
33004
33083
|
function getLogsDir(customLogDir) {
|
|
33005
33084
|
const logsDir = customLogDir || stateHomeLogsDir();
|
|
@@ -33018,9 +33097,9 @@ function createLogFilePath(customLogDir) {
|
|
|
33018
33097
|
const logsDir = getLogsDir(requestedLogDir(customLogDir));
|
|
33019
33098
|
cleanupOldLogs(logsDir, 25);
|
|
33020
33099
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
33021
|
-
let candidate =
|
|
33100
|
+
let candidate = join17(logsDir, `antigravity-debug-${timestamp}.log`);
|
|
33022
33101
|
for (let suffix = 2; liveLogFilePaths.has(candidate); suffix++) {
|
|
33023
|
-
candidate =
|
|
33102
|
+
candidate = join17(logsDir, `antigravity-debug-${timestamp}-${suffix}.log`);
|
|
33024
33103
|
}
|
|
33025
33104
|
return candidate;
|
|
33026
33105
|
}
|
|
@@ -33028,7 +33107,7 @@ function cleanupOldLogs(logsDir, maxFiles) {
|
|
|
33028
33107
|
try {
|
|
33029
33108
|
const files = readdirSync(logsDir).filter(
|
|
33030
33109
|
(file) => file.startsWith("antigravity-debug-") && file.endsWith(".log")
|
|
33031
|
-
).map((file) =>
|
|
33110
|
+
).map((file) => join17(logsDir, file));
|
|
33032
33111
|
if (files.length <= maxFiles) {
|
|
33033
33112
|
return;
|
|
33034
33113
|
}
|
|
@@ -33125,13 +33204,13 @@ function closeDebugStream(state) {
|
|
|
33125
33204
|
state.logWriter = () => {
|
|
33126
33205
|
};
|
|
33127
33206
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
33128
|
-
return new Promise((
|
|
33129
|
-
current.once("close", () =>
|
|
33130
|
-
current.once("error", () =>
|
|
33207
|
+
return new Promise((resolve27) => {
|
|
33208
|
+
current.once("close", () => resolve27());
|
|
33209
|
+
current.once("error", () => resolve27());
|
|
33131
33210
|
try {
|
|
33132
33211
|
current.end();
|
|
33133
33212
|
} catch {
|
|
33134
|
-
|
|
33213
|
+
resolve27();
|
|
33135
33214
|
}
|
|
33136
33215
|
});
|
|
33137
33216
|
}
|
|
@@ -33396,13 +33475,13 @@ function closeDebugLog() {
|
|
|
33396
33475
|
if (!state || !current) return Promise.resolve();
|
|
33397
33476
|
state.logStream = null;
|
|
33398
33477
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
33399
|
-
return new Promise((
|
|
33400
|
-
current.once("close", () =>
|
|
33401
|
-
current.once("error", () =>
|
|
33478
|
+
return new Promise((resolve27) => {
|
|
33479
|
+
current.once("close", () => resolve27());
|
|
33480
|
+
current.once("error", () => resolve27());
|
|
33402
33481
|
try {
|
|
33403
33482
|
current.end();
|
|
33404
33483
|
} catch {
|
|
33405
|
-
|
|
33484
|
+
resolve27();
|
|
33406
33485
|
}
|
|
33407
33486
|
});
|
|
33408
33487
|
}
|
|
@@ -33519,10 +33598,10 @@ function createLocationLogger(options) {
|
|
|
33519
33598
|
const engine = createLoggerInstance2({
|
|
33520
33599
|
level: () => configuredLevel,
|
|
33521
33600
|
extraSecretKeys: isProviderSecretKey,
|
|
33522
|
-
captureSink: ({ channel, level, message, data }) => {
|
|
33601
|
+
captureSink: ({ channel: channel3, level, message, data }) => {
|
|
33523
33602
|
const extra = data !== null && typeof data === "object" && !Array.isArray(data) ? Object.fromEntries(Object.entries(data)) : void 0;
|
|
33524
33603
|
emit({
|
|
33525
|
-
service:
|
|
33604
|
+
service: channel3,
|
|
33526
33605
|
level: level === "trace" ? "debug" : level,
|
|
33527
33606
|
message,
|
|
33528
33607
|
extra
|
|
@@ -33531,12 +33610,12 @@ function createLocationLogger(options) {
|
|
|
33531
33610
|
});
|
|
33532
33611
|
return {
|
|
33533
33612
|
createLogger(module) {
|
|
33534
|
-
const
|
|
33613
|
+
const channel3 = engine.createLogger(`antigravity.${module}`);
|
|
33535
33614
|
return {
|
|
33536
|
-
debug: (message, extra) =>
|
|
33537
|
-
info: (message, extra) =>
|
|
33538
|
-
warn: (message, extra) =>
|
|
33539
|
-
error: (message, extra) =>
|
|
33615
|
+
debug: (message, extra) => channel3.debug(message, extra),
|
|
33616
|
+
info: (message, extra) => channel3.info(message, extra),
|
|
33617
|
+
warn: (message, extra) => channel3.warn(message, extra),
|
|
33618
|
+
error: (message, extra) => channel3.error(message, extra)
|
|
33540
33619
|
};
|
|
33541
33620
|
},
|
|
33542
33621
|
setLevel(level) {
|
|
@@ -33577,10 +33656,10 @@ function initLogger3(client) {
|
|
|
33577
33656
|
setLogSink(getLegacyLogger().coreLogSink);
|
|
33578
33657
|
}
|
|
33579
33658
|
function createLogger4(module) {
|
|
33580
|
-
let
|
|
33659
|
+
let channel3;
|
|
33581
33660
|
const log16 = (level, message, extra) => {
|
|
33582
|
-
|
|
33583
|
-
|
|
33661
|
+
channel3 ??= getLegacyLogger().createLogger(module);
|
|
33662
|
+
channel3[level](message, extra);
|
|
33584
33663
|
};
|
|
33585
33664
|
return {
|
|
33586
33665
|
debug: (message, extra) => log16("debug", message, extra),
|
|
@@ -33613,13 +33692,13 @@ var init_logger4 = __esm({
|
|
|
33613
33692
|
// src/plugin/index.ts
|
|
33614
33693
|
init_dist();
|
|
33615
33694
|
import { createHash as createHash23, randomUUID as randomUUID21 } from "node:crypto";
|
|
33616
|
-
import { join as
|
|
33695
|
+
import { join as join39, resolve as resolve26 } from "node:path";
|
|
33617
33696
|
|
|
33618
33697
|
// src/cli.ts
|
|
33619
33698
|
init_dist();
|
|
33620
33699
|
import { execFile } from "node:child_process";
|
|
33621
33700
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
33622
|
-
import { resolve as
|
|
33701
|
+
import { resolve as resolve21 } from "node:path";
|
|
33623
33702
|
import { createInterface } from "node:readline/promises";
|
|
33624
33703
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
33625
33704
|
import { promisify } from "node:util";
|
|
@@ -33861,7 +33940,7 @@ init_atomic_write();
|
|
|
33861
33940
|
init_file_lock();
|
|
33862
33941
|
import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
33863
33942
|
import { homedir as homedir6 } from "node:os";
|
|
33864
|
-
import { dirname as dirname18, join as
|
|
33943
|
+
import { dirname as dirname18, join as join18 } from "node:path";
|
|
33865
33944
|
|
|
33866
33945
|
// ../../node_modules/.bun/xdg-basedir@5.1.0/node_modules/xdg-basedir/index.js
|
|
33867
33946
|
import os from "os";
|
|
@@ -33920,8 +33999,8 @@ async function emitMergeStep(step) {
|
|
|
33920
33999
|
function getSidebarStateFile() {
|
|
33921
34000
|
const override = process.env[SIDEBAR_STATE_ENV];
|
|
33922
34001
|
if (override && override.trim().length > 0) return override;
|
|
33923
|
-
const base = xdgState ??
|
|
33924
|
-
return
|
|
34002
|
+
const base = xdgState ?? join18(homedir6(), ".local", "state");
|
|
34003
|
+
return join18(base, SIDEBAR_STATE_DIR, SIDEBAR_STATE_FILENAME);
|
|
33925
34004
|
}
|
|
33926
34005
|
function readSidebarState(path5 = getSidebarStateFile()) {
|
|
33927
34006
|
let raw;
|
|
@@ -34270,7 +34349,7 @@ function drainSidebarWrites() {
|
|
|
34270
34349
|
return sidebarWriteChain;
|
|
34271
34350
|
}
|
|
34272
34351
|
async function sleep3(ms) {
|
|
34273
|
-
await new Promise((
|
|
34352
|
+
await new Promise((resolve27) => setTimeout(resolve27, ms));
|
|
34274
34353
|
}
|
|
34275
34354
|
async function acquireSidebarLockWithRetry(stateFile) {
|
|
34276
34355
|
const start = Date.now();
|
|
@@ -35122,14 +35201,14 @@ var LocalQuotaGrantStaleError = class extends Error {
|
|
|
35122
35201
|
name = "LocalQuotaGrantStaleError";
|
|
35123
35202
|
};
|
|
35124
35203
|
function untilQuotaAborted(pending, signal) {
|
|
35125
|
-
return new Promise((
|
|
35204
|
+
return new Promise((resolve27, reject) => {
|
|
35126
35205
|
const abort = () => reject(signal.reason);
|
|
35127
35206
|
if (signal.aborted) abort();
|
|
35128
35207
|
else signal.addEventListener("abort", abort, { once: true });
|
|
35129
35208
|
void pending.then(
|
|
35130
35209
|
(value) => {
|
|
35131
35210
|
signal.removeEventListener("abort", abort);
|
|
35132
|
-
|
|
35211
|
+
resolve27(value);
|
|
35133
35212
|
},
|
|
35134
35213
|
(error) => {
|
|
35135
35214
|
signal.removeEventListener("abort", abort);
|
|
@@ -35750,12 +35829,12 @@ async function startOAuthListener({
|
|
|
35750
35829
|
let resolveCallback;
|
|
35751
35830
|
let rejectCallback;
|
|
35752
35831
|
let timeoutHandle;
|
|
35753
|
-
const callbackPromise = new Promise((
|
|
35832
|
+
const callbackPromise = new Promise((resolve27, reject) => {
|
|
35754
35833
|
resolveCallback = (url) => {
|
|
35755
35834
|
if (settled) return;
|
|
35756
35835
|
settled = true;
|
|
35757
35836
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
35758
|
-
|
|
35837
|
+
resolve27(url);
|
|
35759
35838
|
};
|
|
35760
35839
|
rejectCallback = (error) => {
|
|
35761
35840
|
if (settled) return;
|
|
@@ -35914,7 +35993,7 @@ async function startOAuthListener({
|
|
|
35914
35993
|
});
|
|
35915
35994
|
});
|
|
35916
35995
|
const bindAddress = getBindAddress();
|
|
35917
|
-
await new Promise((
|
|
35996
|
+
await new Promise((resolve27, reject) => {
|
|
35918
35997
|
const handleError = (error) => {
|
|
35919
35998
|
server.off("error", handleError);
|
|
35920
35999
|
if (error.code === "EADDRINUSE") {
|
|
@@ -35930,7 +36009,7 @@ async function startOAuthListener({
|
|
|
35930
36009
|
server.once("error", handleError);
|
|
35931
36010
|
server.listen(port, bindAddress, () => {
|
|
35932
36011
|
server.off("error", handleError);
|
|
35933
|
-
|
|
36012
|
+
resolve27();
|
|
35934
36013
|
});
|
|
35935
36014
|
});
|
|
35936
36015
|
server.on("error", (error) => {
|
|
@@ -35938,7 +36017,7 @@ async function startOAuthListener({
|
|
|
35938
36017
|
});
|
|
35939
36018
|
return {
|
|
35940
36019
|
waitForCallback: () => callbackPromise,
|
|
35941
|
-
close: () => new Promise((
|
|
36020
|
+
close: () => new Promise((resolve27, reject) => {
|
|
35942
36021
|
server.close((error) => {
|
|
35943
36022
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
35944
36023
|
reject(error);
|
|
@@ -35947,7 +36026,7 @@ async function startOAuthListener({
|
|
|
35947
36026
|
if (!settled) {
|
|
35948
36027
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
35949
36028
|
}
|
|
35950
|
-
|
|
36029
|
+
resolve27();
|
|
35951
36030
|
});
|
|
35952
36031
|
})
|
|
35953
36032
|
};
|
|
@@ -35966,7 +36045,7 @@ init_runtime_paths();
|
|
|
35966
36045
|
// src/setup.ts
|
|
35967
36046
|
init_dist();
|
|
35968
36047
|
import { lstat as lstat9, readFile as readFile16 } from "node:fs/promises";
|
|
35969
|
-
import { join as
|
|
36048
|
+
import { join as join24, resolve as resolve20 } from "node:path";
|
|
35970
36049
|
|
|
35971
36050
|
// src/auth-method-labels.ts
|
|
35972
36051
|
var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
|
|
@@ -36138,7 +36217,7 @@ async function select2(terminal, items, options) {
|
|
|
36138
36217
|
writeLine("");
|
|
36139
36218
|
renderedLines = lines;
|
|
36140
36219
|
};
|
|
36141
|
-
return new Promise((
|
|
36220
|
+
return new Promise((resolve27) => {
|
|
36142
36221
|
const wasRaw = stdin.isRaw ?? false;
|
|
36143
36222
|
const cleanup2 = () => {
|
|
36144
36223
|
if (cleaned)
|
|
@@ -36158,7 +36237,7 @@ async function select2(terminal, items, options) {
|
|
|
36158
36237
|
};
|
|
36159
36238
|
const finish = (value) => {
|
|
36160
36239
|
cleanup2();
|
|
36161
|
-
|
|
36240
|
+
resolve27(value);
|
|
36162
36241
|
};
|
|
36163
36242
|
const onSignal = () => finish(null);
|
|
36164
36243
|
const onKey = (data) => {
|
|
@@ -36198,7 +36277,7 @@ async function select2(terminal, items, options) {
|
|
|
36198
36277
|
stdin.setRawMode(true);
|
|
36199
36278
|
} catch {
|
|
36200
36279
|
cleanup2();
|
|
36201
|
-
|
|
36280
|
+
resolve27(null);
|
|
36202
36281
|
return;
|
|
36203
36282
|
}
|
|
36204
36283
|
stdin.resume();
|
|
@@ -36212,12 +36291,12 @@ async function select2(terminal, items, options) {
|
|
|
36212
36291
|
import { createHash as createHash13, randomBytes as randomBytes5, randomUUID as randomUUID17 } from "node:crypto";
|
|
36213
36292
|
import { constants as fsConstants2 } from "node:fs";
|
|
36214
36293
|
import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as stat11, unlink as unlink10 } from "node:fs/promises";
|
|
36215
|
-
import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute3, join as
|
|
36294
|
+
import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute3, join as join20, resolve as resolve19 } from "node:path";
|
|
36216
36295
|
import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
36217
36296
|
|
|
36218
36297
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
36219
36298
|
import { lstat as lstat7 } from "node:fs/promises";
|
|
36220
|
-
import { resolve as
|
|
36299
|
+
import { resolve as resolve18 } from "node:path";
|
|
36221
36300
|
async function identity2(path5) {
|
|
36222
36301
|
try {
|
|
36223
36302
|
const metadata = await lstat7(path5);
|
|
@@ -36234,7 +36313,7 @@ function sameIdentity2(left, right) {
|
|
|
36234
36313
|
var FileReadCache2 = class {
|
|
36235
36314
|
#entries = /* @__PURE__ */ new Map();
|
|
36236
36315
|
async read(paths, read, validateHit) {
|
|
36237
|
-
const resolvedPaths = paths.map((path5) =>
|
|
36316
|
+
const resolvedPaths = paths.map((path5) => resolve18(path5));
|
|
36238
36317
|
const key = JSON.stringify(resolvedPaths);
|
|
36239
36318
|
const probed = await Promise.all(resolvedPaths.map(identity2));
|
|
36240
36319
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -36286,9 +36365,10 @@ init_private_files2();
|
|
|
36286
36365
|
init_private_files2();
|
|
36287
36366
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
36288
36367
|
import { lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as stat10 } from "node:fs/promises";
|
|
36289
|
-
import { dirname as dirname19, join as
|
|
36368
|
+
import { dirname as dirname19, join as join19 } from "node:path";
|
|
36290
36369
|
|
|
36291
36370
|
// src/common-auth-embedded/fs/with-lock.js
|
|
36371
|
+
init_private_files2();
|
|
36292
36372
|
function lockPathFor2(target, name) {
|
|
36293
36373
|
return `${target}.${name}.lock`;
|
|
36294
36374
|
}
|
|
@@ -36346,7 +36426,7 @@ function acquireRefreshFileLock2(options) {
|
|
|
36346
36426
|
}
|
|
36347
36427
|
async function acquireRefreshFileLockWithClock2(options) {
|
|
36348
36428
|
const lockPath = lockPathFor2(options.path, options.name);
|
|
36349
|
-
const legacyOwnerPath =
|
|
36429
|
+
const legacyOwnerPath = join19(lockPath, "owner.json");
|
|
36350
36430
|
const ownerId = randomUUID16();
|
|
36351
36431
|
const now = options.now ?? Date.now;
|
|
36352
36432
|
let renewTimer = null;
|
|
@@ -36354,8 +36434,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
36354
36434
|
let releaseConfirmed = false;
|
|
36355
36435
|
let loss;
|
|
36356
36436
|
let resolveLoss;
|
|
36357
|
-
const lostPromise = new Promise((
|
|
36358
|
-
resolveLoss =
|
|
36437
|
+
const lostPromise = new Promise((resolve27) => {
|
|
36438
|
+
resolveLoss = resolve27;
|
|
36359
36439
|
});
|
|
36360
36440
|
function notifyTimerStep(event) {
|
|
36361
36441
|
try {
|
|
@@ -36389,7 +36469,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
36389
36469
|
let terminalIOError;
|
|
36390
36470
|
let renewalInFlight = null;
|
|
36391
36471
|
const evictPath = `${lockPath}.evicting`;
|
|
36392
|
-
const evictOwnerPath =
|
|
36472
|
+
const evictOwnerPath = join19(evictPath, "owner.json");
|
|
36393
36473
|
const evictOwnerId = randomUUID16();
|
|
36394
36474
|
const EVICT_TTL = 5e3;
|
|
36395
36475
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
@@ -36516,7 +36596,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
36516
36596
|
}
|
|
36517
36597
|
}
|
|
36518
36598
|
async function backoff() {
|
|
36519
|
-
await new Promise((
|
|
36599
|
+
await new Promise((resolve27) => setTimeout(resolve27, Math.floor(Math.random() * 4)));
|
|
36520
36600
|
}
|
|
36521
36601
|
async function readLockState(notifyReady = true) {
|
|
36522
36602
|
if (notifyReady && options.onStep)
|
|
@@ -37006,7 +37086,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37006
37086
|
const remainingMs = deadline - performance.now();
|
|
37007
37087
|
if (remainingMs <= 0)
|
|
37008
37088
|
break;
|
|
37009
|
-
await new Promise((
|
|
37089
|
+
await new Promise((resolve27) => setTimeout(resolve27, Math.min(delayMs, remainingMs)));
|
|
37010
37090
|
delayMs = Math.min(delayMs * 2, 50);
|
|
37011
37091
|
}
|
|
37012
37092
|
if (windowsPrivateFiles2)
|
|
@@ -37071,7 +37151,7 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
|
|
|
37071
37151
|
const extension = extname2(tokenPath) || ".json";
|
|
37072
37152
|
const stem = basename5(tokenPath, extname2(tokenPath));
|
|
37073
37153
|
return {
|
|
37074
|
-
statePath:
|
|
37154
|
+
statePath: join20(dirname20(tokenPath), `${stem}-state${extension}`),
|
|
37075
37155
|
tokenPath
|
|
37076
37156
|
};
|
|
37077
37157
|
}
|
|
@@ -37079,7 +37159,7 @@ function hostEnrollmentPaths2(input2) {
|
|
|
37079
37159
|
const override = input2.override?.trim();
|
|
37080
37160
|
if (override && !isAbsolute3(override) && !input2.cwd)
|
|
37081
37161
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
37082
|
-
const tokenPath = override ? isAbsolute3(override) ? override :
|
|
37162
|
+
const tokenPath = override ? isAbsolute3(override) ? override : resolve19(input2.cwd, override) : join20(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
37083
37163
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
37084
37164
|
}
|
|
37085
37165
|
function isRecord11(value) {
|
|
@@ -37312,7 +37392,7 @@ async function writeStateAtomic2(path5, state, ancestorOptions = {}) {
|
|
|
37312
37392
|
}
|
|
37313
37393
|
if (windowsPrivateFiles2)
|
|
37314
37394
|
return writePrivateAtomic2(path5, bytes);
|
|
37315
|
-
const temporary =
|
|
37395
|
+
const temporary = join20(parent, `.${basename5(path5)}.${process.pid}.${randomUUID17()}.tmp`);
|
|
37316
37396
|
let descriptor;
|
|
37317
37397
|
let created = false;
|
|
37318
37398
|
try {
|
|
@@ -37707,7 +37787,7 @@ var ByteTail = class {
|
|
|
37707
37787
|
};
|
|
37708
37788
|
var defaultCommandRunner = {
|
|
37709
37789
|
run(file, args, options = {}) {
|
|
37710
|
-
return new Promise((
|
|
37790
|
+
return new Promise((resolve27) => {
|
|
37711
37791
|
const started = performance.now();
|
|
37712
37792
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
37713
37793
|
const stderr = new ByteTail();
|
|
@@ -37725,7 +37805,7 @@ var defaultCommandRunner = {
|
|
|
37725
37805
|
stdio: ["ignore", "pipe", "pipe"]
|
|
37726
37806
|
});
|
|
37727
37807
|
} catch {
|
|
37728
|
-
|
|
37808
|
+
resolve27({
|
|
37729
37809
|
exitCode: 1,
|
|
37730
37810
|
stdout: "",
|
|
37731
37811
|
stderr: "",
|
|
@@ -37760,7 +37840,7 @@ var defaultCommandRunner = {
|
|
|
37760
37840
|
settled = true;
|
|
37761
37841
|
if (timer)
|
|
37762
37842
|
clearTimeout(timer);
|
|
37763
|
-
|
|
37843
|
+
resolve27({
|
|
37764
37844
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
37765
37845
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
37766
37846
|
stderr: stderr.toString(),
|
|
@@ -37847,7 +37927,7 @@ function recordSetupEnrollment(failure2, enrollment) {
|
|
|
37847
37927
|
import { accessSync, constants as constants3, existsSync as existsSync6, readFileSync as readFileSync5, realpathSync as realpathSync3, statSync as statSync5 } from "node:fs";
|
|
37848
37928
|
import { mkdtemp, rm as rm7 } from "node:fs/promises";
|
|
37849
37929
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
37850
|
-
import { join as
|
|
37930
|
+
import { join as join21 } from "node:path";
|
|
37851
37931
|
import { parse } from "jsonc-parser";
|
|
37852
37932
|
|
|
37853
37933
|
// src/common-auth-embedded/setup/paths.js
|
|
@@ -38018,7 +38098,7 @@ async function detectHosts(plugin, io = {}) {
|
|
|
38018
38098
|
return null;
|
|
38019
38099
|
let root;
|
|
38020
38100
|
try {
|
|
38021
|
-
root = await mkdtemp(
|
|
38101
|
+
root = await mkdtemp(join21(tmpdir3(), "common-auth-setup-version-"));
|
|
38022
38102
|
const probeEnv = {
|
|
38023
38103
|
...env3,
|
|
38024
38104
|
HOME: root,
|
|
@@ -38603,7 +38683,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
|
|
|
38603
38683
|
// src/common-auth-embedded/setup/config-write.js
|
|
38604
38684
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
38605
38685
|
import { mkdir as mkdir16, open as open11, rename as rename13, stat as stat13, unlink as unlink11 } from "node:fs/promises";
|
|
38606
|
-
import { basename as basename6, dirname as dirname21, join as
|
|
38686
|
+
import { basename as basename6, dirname as dirname21, join as join22 } from "node:path";
|
|
38607
38687
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
38608
38688
|
async function writeHostConfigAtomic(file, content, options = {}) {
|
|
38609
38689
|
const windows2 = (options.platform ?? process.platform) === "win32";
|
|
@@ -38618,7 +38698,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
|
|
|
38618
38698
|
throw error;
|
|
38619
38699
|
}
|
|
38620
38700
|
}
|
|
38621
|
-
const stage =
|
|
38701
|
+
const stage = join22(parent, `.${basename6(file)}.${(options.stageName ?? randomUUID18)()}.tmp`);
|
|
38622
38702
|
let created = false;
|
|
38623
38703
|
try {
|
|
38624
38704
|
const handle = await open11(stage, "wx", mode ?? 438);
|
|
@@ -39038,11 +39118,11 @@ init_storage();
|
|
|
39038
39118
|
init_dist();
|
|
39039
39119
|
import { readFile as readFile15 } from "node:fs/promises";
|
|
39040
39120
|
import { homedir as homedir8 } from "node:os";
|
|
39041
|
-
import { join as
|
|
39121
|
+
import { join as join23 } from "node:path";
|
|
39042
39122
|
var V1_VAULT_ACTIVATION_LABEL = "Activate approved Antigravity vault";
|
|
39043
39123
|
function nativeOpenCodeAuthPath(env3 = process.env, home = homedir8()) {
|
|
39044
|
-
return
|
|
39045
|
-
env3.XDG_DATA_HOME ||
|
|
39124
|
+
return join23(
|
|
39125
|
+
env3.XDG_DATA_HOME || join23(home, ".local", "share"),
|
|
39046
39126
|
"opencode",
|
|
39047
39127
|
"auth.json"
|
|
39048
39128
|
);
|
|
@@ -39163,7 +39243,7 @@ function openCodeVaultDir(accountFile) {
|
|
|
39163
39243
|
return folder.vaultDir;
|
|
39164
39244
|
}
|
|
39165
39245
|
function nativeAuthPath(host, context) {
|
|
39166
|
-
return host === "opencode" ? nativeOpenCodeAuthPath() :
|
|
39246
|
+
return host === "opencode" ? nativeOpenCodeAuthPath() : join24(context.piAgentDir, "auth.json");
|
|
39167
39247
|
}
|
|
39168
39248
|
function provider(host) {
|
|
39169
39249
|
return host === "opencode" ? OPENCODE_VAULT_PROVIDER : ANTIGRAVITY_PROVIDER_ID;
|
|
@@ -39219,7 +39299,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
39219
39299
|
beforeRename: async () => {
|
|
39220
39300
|
await assertSetupHostsStopped();
|
|
39221
39301
|
const claustrum = await loadCommonAuthClaustrum();
|
|
39222
|
-
const stateDir = host === "opencode" ? openCodeVaultDir(
|
|
39302
|
+
const stateDir = host === "opencode" ? openCodeVaultDir(resolve20(accountFileForVault())) : getPiAntigravityVaultDir();
|
|
39223
39303
|
if (await claustrum.enrollmentAuthority(
|
|
39224
39304
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
39225
39305
|
`antigravity-auth-${host}`
|
|
@@ -39257,7 +39337,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
39257
39337
|
// `beforeSignIn`, which may move it after this plugin is built.
|
|
39258
39338
|
paths: {
|
|
39259
39339
|
get stateDir() {
|
|
39260
|
-
return openCodeVaultDir(
|
|
39340
|
+
return openCodeVaultDir(resolve20(accountFileForVault()));
|
|
39261
39341
|
},
|
|
39262
39342
|
host: "opencode"
|
|
39263
39343
|
}
|
|
@@ -39274,7 +39354,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
39274
39354
|
const assertLocal = async (host, context) => {
|
|
39275
39355
|
if (host === "opencode")
|
|
39276
39356
|
return assertLocalOpenCodeLogin(
|
|
39277
|
-
|
|
39357
|
+
resolve20(accountFileForVault()),
|
|
39278
39358
|
context.opencodeGeneration
|
|
39279
39359
|
);
|
|
39280
39360
|
if (await authority(host) !== "local")
|
|
@@ -39290,7 +39370,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
39290
39370
|
const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
|
|
39291
39371
|
if ((await openPiSlot2({
|
|
39292
39372
|
authPath: nativeAuthPath(host, context),
|
|
39293
|
-
stashPath:
|
|
39373
|
+
stashPath: join24(piDir, "google-login-stash.json"),
|
|
39294
39374
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
39295
39375
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
39296
39376
|
}).inspect()).slot === "placeholder")
|
|
@@ -39330,7 +39410,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
39330
39410
|
const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
|
|
39331
39411
|
const inspection = await openPiSlot2({
|
|
39332
39412
|
authPath: nativeAuthPath("pi", context),
|
|
39333
|
-
stashPath:
|
|
39413
|
+
stashPath: join24(piDir, "google-login-stash.json"),
|
|
39334
39414
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
39335
39415
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
39336
39416
|
}).inspect();
|
|
@@ -39449,7 +39529,7 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
39449
39529
|
await assertSetupHostsStopped();
|
|
39450
39530
|
await openPiSlot2({
|
|
39451
39531
|
authPath: nativeAuthPath(host, context),
|
|
39452
|
-
stashPath:
|
|
39532
|
+
stashPath: join24(piDir, "google-login-stash.json"),
|
|
39453
39533
|
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
39454
39534
|
placeholderKey: PI_PLACEHOLDER_KEY
|
|
39455
39535
|
}).enterVault();
|
|
@@ -39904,7 +39984,7 @@ async function runCliProcess(argv, deps) {
|
|
|
39904
39984
|
...deps,
|
|
39905
39985
|
prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
|
|
39906
39986
|
const folder = await prepareVaultFolder({
|
|
39907
|
-
accountFile:
|
|
39987
|
+
accountFile: resolve21(accountFileForVault()),
|
|
39908
39988
|
...options
|
|
39909
39989
|
});
|
|
39910
39990
|
if (folder.refusal) throw folder.refusal;
|
|
@@ -39950,11 +40030,11 @@ function createDefaultCliDependencies() {
|
|
|
39950
40030
|
);
|
|
39951
40031
|
if (host !== "pi")
|
|
39952
40032
|
await assertLocalOpenCodeLogin(
|
|
39953
|
-
|
|
40033
|
+
resolve21(accountFileForVault()),
|
|
39954
40034
|
context?.opencodeGeneration
|
|
39955
40035
|
);
|
|
39956
40036
|
const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
|
|
39957
|
-
|
|
40037
|
+
resolve21(getStoragePath()),
|
|
39958
40038
|
context?.opencodeGeneration
|
|
39959
40039
|
);
|
|
39960
40040
|
try {
|
|
@@ -39970,7 +40050,7 @@ function createDefaultCliDependencies() {
|
|
|
39970
40050
|
}
|
|
39971
40051
|
if (host === "opencode") await assertSetupHostsStopped();
|
|
39972
40052
|
await assertLocalOpenCodeLogin(
|
|
39973
|
-
|
|
40053
|
+
resolve21(accountFileForVault()),
|
|
39974
40054
|
context?.opencodeGeneration
|
|
39975
40055
|
);
|
|
39976
40056
|
await persistCliStoreLogin(
|
|
@@ -39990,7 +40070,7 @@ function createDefaultCliDependencies() {
|
|
|
39990
40070
|
};
|
|
39991
40071
|
}
|
|
39992
40072
|
async function prepareCliLoginStore(legacyPath, generation) {
|
|
39993
|
-
await assertLocalOpenCodeLogin(
|
|
40073
|
+
await assertLocalOpenCodeLogin(resolve21(accountFileForVault()), generation);
|
|
39994
40074
|
const modules = await loadCommonAuthStoreModules();
|
|
39995
40075
|
const options = {
|
|
39996
40076
|
legacyPath,
|
|
@@ -40115,7 +40195,7 @@ async function readAccountStore(legacyPath) {
|
|
|
40115
40195
|
function createDefaultAccountStoreOperations() {
|
|
40116
40196
|
const offline = { processesStopped: true };
|
|
40117
40197
|
return {
|
|
40118
|
-
legacyPath: () =>
|
|
40198
|
+
legacyPath: () => resolve21(
|
|
40119
40199
|
decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
|
|
40120
40200
|
),
|
|
40121
40201
|
migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
|
|
@@ -40146,7 +40226,7 @@ function createDefaultAccountStoreOperations() {
|
|
|
40146
40226
|
};
|
|
40147
40227
|
}
|
|
40148
40228
|
function samePath(left, right) {
|
|
40149
|
-
return process.platform === "win32" ?
|
|
40229
|
+
return process.platform === "win32" ? resolve21(left).toLowerCase() === resolve21(right).toLowerCase() : resolve21(left) === resolve21(right);
|
|
40150
40230
|
}
|
|
40151
40231
|
function isCliEntry() {
|
|
40152
40232
|
if (import.meta.main !== void 0) return import.meta.main;
|
|
@@ -40636,16 +40716,16 @@ function isTuiConnected(sessionId) {
|
|
|
40636
40716
|
// src/rpc/rpc-dir.ts
|
|
40637
40717
|
import { createHash as createHash14 } from "node:crypto";
|
|
40638
40718
|
import { homedir as homedir10, tmpdir as tmpdir4 } from "node:os";
|
|
40639
|
-
import { isAbsolute as isAbsolute4, join as
|
|
40719
|
+
import { isAbsolute as isAbsolute4, join as join28, resolve as resolve22 } from "node:path";
|
|
40640
40720
|
var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
|
|
40641
40721
|
function getRpcDir(projectDirectory) {
|
|
40642
40722
|
const override = process.env[RPC_DIR_ENV]?.trim();
|
|
40643
40723
|
if (override) {
|
|
40644
|
-
return isAbsolute4(override) ? override :
|
|
40724
|
+
return isAbsolute4(override) ? override : resolve22(projectDirectory, override);
|
|
40645
40725
|
}
|
|
40646
|
-
const projectHash = createHash14("sha256").update(
|
|
40647
|
-
const stateHome = process.env.XDG_STATE_HOME ??
|
|
40648
|
-
return
|
|
40726
|
+
const projectHash = createHash14("sha256").update(resolve22(projectDirectory)).digest("hex").slice(0, 16);
|
|
40727
|
+
const stateHome = process.env.XDG_STATE_HOME ?? join28(homedir10(), ".local", "state");
|
|
40728
|
+
return join28(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
|
|
40649
40729
|
}
|
|
40650
40730
|
|
|
40651
40731
|
// src/common-auth-embedded/rpc/notifications.js
|
|
@@ -40657,7 +40737,7 @@ function isSessionId(value) {
|
|
|
40657
40737
|
init_private_files2();
|
|
40658
40738
|
import { createHash as createHash15, randomUUID as randomUUID19 } from "node:crypto";
|
|
40659
40739
|
import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir4, rename as rename14, rmdir as rmdir3, stat as stat14, unlink as unlink12 } from "node:fs/promises";
|
|
40660
|
-
import { join as
|
|
40740
|
+
import { join as join29, resolve as resolve23 } from "node:path";
|
|
40661
40741
|
function isProbeablePid(pid) {
|
|
40662
40742
|
return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
|
|
40663
40743
|
}
|
|
@@ -40688,7 +40768,7 @@ async function removeCorruptPortFile(portFile, log16) {
|
|
|
40688
40768
|
}
|
|
40689
40769
|
async function writePortFile(dir, entry, options = {}) {
|
|
40690
40770
|
const writeOnce = async () => {
|
|
40691
|
-
const target =
|
|
40771
|
+
const target = join29(dir, `port-${entry.pid}.json`);
|
|
40692
40772
|
if (windowsPrivateFiles2) {
|
|
40693
40773
|
await ensurePrivateDirectory2(dir, options.secureDir ?? false);
|
|
40694
40774
|
await options.beforeWrite?.();
|
|
@@ -40744,12 +40824,12 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
40744
40824
|
return;
|
|
40745
40825
|
throw error;
|
|
40746
40826
|
}
|
|
40747
|
-
const active2 =
|
|
40827
|
+
const active2 = resolve23(activeDir);
|
|
40748
40828
|
for (const projectDir of projectDirs) {
|
|
40749
40829
|
if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
|
|
40750
40830
|
continue;
|
|
40751
40831
|
}
|
|
40752
|
-
const dir =
|
|
40832
|
+
const dir = join29(root, projectDir.name);
|
|
40753
40833
|
let names;
|
|
40754
40834
|
try {
|
|
40755
40835
|
names = await readdir4(dir);
|
|
@@ -40761,7 +40841,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
40761
40841
|
for (const name of names) {
|
|
40762
40842
|
if (!name.startsWith("port-") || !name.endsWith(".json"))
|
|
40763
40843
|
continue;
|
|
40764
|
-
const portFile =
|
|
40844
|
+
const portFile = join29(dir, name);
|
|
40765
40845
|
let raw;
|
|
40766
40846
|
try {
|
|
40767
40847
|
raw = await readPrivateText2(portFile);
|
|
@@ -40788,7 +40868,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
40788
40868
|
await unlink12(portFile).catch(() => {
|
|
40789
40869
|
});
|
|
40790
40870
|
}
|
|
40791
|
-
if (
|
|
40871
|
+
if (resolve23(dir) !== active2)
|
|
40792
40872
|
await rmdir3(dir).catch(() => {
|
|
40793
40873
|
});
|
|
40794
40874
|
}
|
|
@@ -40802,7 +40882,7 @@ init_private_files2();
|
|
|
40802
40882
|
import { randomBytes as randomBytes6, timingSafeEqual } from "node:crypto";
|
|
40803
40883
|
import { unlink as unlink13 } from "node:fs/promises";
|
|
40804
40884
|
import { createServer as createServer2 } from "node:http";
|
|
40805
|
-
import { join as
|
|
40885
|
+
import { join as join30 } from "node:path";
|
|
40806
40886
|
var RpcRequestError = class extends Error {
|
|
40807
40887
|
status;
|
|
40808
40888
|
constructor(status, message) {
|
|
@@ -40822,7 +40902,7 @@ var BodyTooLargeError = class extends Error {
|
|
|
40822
40902
|
}
|
|
40823
40903
|
};
|
|
40824
40904
|
function readBody(req) {
|
|
40825
|
-
return new Promise((
|
|
40905
|
+
return new Promise((resolve27, reject) => {
|
|
40826
40906
|
const tooLarge = (declaredOversize = false) => {
|
|
40827
40907
|
req.removeAllListeners("data");
|
|
40828
40908
|
req.on("data", () => {
|
|
@@ -40845,7 +40925,7 @@ function readBody(req) {
|
|
|
40845
40925
|
}
|
|
40846
40926
|
chunks.push(chunk);
|
|
40847
40927
|
});
|
|
40848
|
-
req.on("end", () =>
|
|
40928
|
+
req.on("end", () => resolve27(Buffer.concat(chunks).toString("utf8")));
|
|
40849
40929
|
req.on("error", reject);
|
|
40850
40930
|
});
|
|
40851
40931
|
}
|
|
@@ -41024,12 +41104,12 @@ async function startRpcServer(options) {
|
|
|
41024
41104
|
json(500, { error: "internal error" });
|
|
41025
41105
|
}
|
|
41026
41106
|
}
|
|
41027
|
-
const port = await new Promise((
|
|
41107
|
+
const port = await new Promise((resolve27, reject) => {
|
|
41028
41108
|
server.on("error", reject);
|
|
41029
41109
|
server.listen(0, "127.0.0.1", () => {
|
|
41030
41110
|
const addr = server.address();
|
|
41031
41111
|
if (addr && typeof addr === "object")
|
|
41032
|
-
|
|
41112
|
+
resolve27(addr.port);
|
|
41033
41113
|
else
|
|
41034
41114
|
reject(new Error("no port"));
|
|
41035
41115
|
});
|
|
@@ -41052,20 +41132,20 @@ async function startRpcServer(options) {
|
|
|
41052
41132
|
rpcPort: port
|
|
41053
41133
|
});
|
|
41054
41134
|
} catch (error) {
|
|
41055
|
-
await new Promise((
|
|
41135
|
+
await new Promise((resolve27) => server.close(() => resolve27()));
|
|
41056
41136
|
throw error;
|
|
41057
41137
|
}
|
|
41058
41138
|
return {
|
|
41059
41139
|
port,
|
|
41060
41140
|
token,
|
|
41061
41141
|
async stop() {
|
|
41062
|
-
await new Promise((
|
|
41142
|
+
await new Promise((resolve27) => {
|
|
41063
41143
|
server.closeAllConnections?.();
|
|
41064
|
-
server.close(() =>
|
|
41144
|
+
server.close(() => resolve27());
|
|
41065
41145
|
for (const socket of connections)
|
|
41066
41146
|
socket.destroy();
|
|
41067
41147
|
});
|
|
41068
|
-
const portFile =
|
|
41148
|
+
const portFile = join30(options.dir, `port-${process.pid}.json`);
|
|
41069
41149
|
const current = await readPrivateText2(portFile).then((raw) => JSON.parse(raw)).catch((error) => {
|
|
41070
41150
|
if (error instanceof PrivateFileError2 && error.code !== "ENOENT")
|
|
41071
41151
|
throw error;
|
|
@@ -42153,7 +42233,7 @@ import { createInterface as createInterface2 } from "node:readline/promises";
|
|
|
42153
42233
|
// src/plugin/config/updater.ts
|
|
42154
42234
|
import { existsSync as existsSync9, mkdirSync as mkdirSync4, readFileSync as readFileSync8, writeFileSync as writeFileSync4 } from "node:fs";
|
|
42155
42235
|
import { homedir as homedir11 } from "node:os";
|
|
42156
|
-
import { dirname as dirname23, join as
|
|
42236
|
+
import { dirname as dirname23, join as join31 } from "node:path";
|
|
42157
42237
|
|
|
42158
42238
|
// src/plugin/model-registry.ts
|
|
42159
42239
|
init_dist();
|
|
@@ -42170,13 +42250,13 @@ function stripJsonCommentsAndTrailingCommas(json) {
|
|
|
42170
42250
|
).replace(/,(\s*[}\]])/g, "$1");
|
|
42171
42251
|
}
|
|
42172
42252
|
function getOpencodeConfigDir() {
|
|
42173
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ||
|
|
42174
|
-
return
|
|
42253
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME || join31(homedir11(), ".config");
|
|
42254
|
+
return join31(xdgConfig2, "opencode");
|
|
42175
42255
|
}
|
|
42176
42256
|
function getOpencodeConfigPath() {
|
|
42177
42257
|
const configDir = getOpencodeConfigDir();
|
|
42178
|
-
const jsoncPath =
|
|
42179
|
-
const jsonPath =
|
|
42258
|
+
const jsoncPath = join31(configDir, OPENCODE_JSONC_FILENAME);
|
|
42259
|
+
const jsonPath = join31(configDir, OPENCODE_JSON_FILENAME);
|
|
42180
42260
|
if (existsSync9(jsoncPath)) {
|
|
42181
42261
|
return jsoncPath;
|
|
42182
42262
|
}
|
|
@@ -42435,7 +42515,7 @@ async function select3(items, options) {
|
|
|
42435
42515
|
}
|
|
42436
42516
|
renderedLines = linesWritten;
|
|
42437
42517
|
};
|
|
42438
|
-
return new Promise((
|
|
42518
|
+
return new Promise((resolve27) => {
|
|
42439
42519
|
const wasRaw = stdin.isRaw ?? false;
|
|
42440
42520
|
const cleanup2 = () => {
|
|
42441
42521
|
if (isCleanedUp) return;
|
|
@@ -42456,11 +42536,11 @@ async function select3(items, options) {
|
|
|
42456
42536
|
};
|
|
42457
42537
|
const onSignal = () => {
|
|
42458
42538
|
cleanup2();
|
|
42459
|
-
|
|
42539
|
+
resolve27(null);
|
|
42460
42540
|
};
|
|
42461
42541
|
const finishWithValue = (value) => {
|
|
42462
42542
|
cleanup2();
|
|
42463
|
-
|
|
42543
|
+
resolve27(value);
|
|
42464
42544
|
};
|
|
42465
42545
|
const findNextSelectable = (from, direction) => {
|
|
42466
42546
|
if (items.length === 0) return from;
|
|
@@ -42506,7 +42586,7 @@ async function select3(items, options) {
|
|
|
42506
42586
|
stdin.setRawMode(true);
|
|
42507
42587
|
} catch {
|
|
42508
42588
|
cleanup2();
|
|
42509
|
-
|
|
42589
|
+
resolve27(null);
|
|
42510
42590
|
return;
|
|
42511
42591
|
}
|
|
42512
42592
|
stdin.resume();
|
|
@@ -44918,7 +44998,7 @@ import {
|
|
|
44918
44998
|
writeFileSync as writeFileSync5
|
|
44919
44999
|
} from "node:fs";
|
|
44920
45000
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
44921
|
-
import { dirname as dirname24, join as
|
|
45001
|
+
import { dirname as dirname24, join as join32 } from "node:path";
|
|
44922
45002
|
function getSignatureCacheFilePath() {
|
|
44923
45003
|
return stateHomeSignatureCacheFile();
|
|
44924
45004
|
}
|
|
@@ -45202,7 +45282,7 @@ var SignatureCache = class {
|
|
|
45202
45282
|
last_write: now
|
|
45203
45283
|
}
|
|
45204
45284
|
};
|
|
45205
|
-
const tmpPath =
|
|
45285
|
+
const tmpPath = join32(
|
|
45206
45286
|
tmpdir5(),
|
|
45207
45287
|
`antigravity-cache-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`
|
|
45208
45288
|
);
|
|
@@ -45272,7 +45352,7 @@ init_runtime_paths();
|
|
|
45272
45352
|
init_logger4();
|
|
45273
45353
|
import { existsSync as existsSync11, readFileSync as readFileSync11, realpathSync as realpathSync5 } from "node:fs";
|
|
45274
45354
|
import { homedir as homedir12 } from "node:os";
|
|
45275
|
-
import { basename as basename7, dirname as dirname25, join as
|
|
45355
|
+
import { basename as basename7, dirname as dirname25, join as join33, resolve as resolve24 } from "node:path";
|
|
45276
45356
|
|
|
45277
45357
|
// src/plugin/config/schema.ts
|
|
45278
45358
|
import { z } from "zod";
|
|
@@ -45767,14 +45847,14 @@ function getConfigDir2() {
|
|
|
45767
45847
|
if (process.env.OPENCODE_CONFIG_DIR) {
|
|
45768
45848
|
return process.env.OPENCODE_CONFIG_DIR;
|
|
45769
45849
|
}
|
|
45770
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ||
|
|
45771
|
-
return
|
|
45850
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME || join33(homedir12(), ".config");
|
|
45851
|
+
return join33(xdgConfig2, "opencode");
|
|
45772
45852
|
}
|
|
45773
45853
|
function getUserConfigPath() {
|
|
45774
|
-
return
|
|
45854
|
+
return join33(getConfigDir2(), "antigravity.json");
|
|
45775
45855
|
}
|
|
45776
45856
|
function getProjectConfigPath(directory) {
|
|
45777
|
-
return
|
|
45857
|
+
return join33(directory, ".opencode", "antigravity.json");
|
|
45778
45858
|
}
|
|
45779
45859
|
function loadConfigFile(path5, log16) {
|
|
45780
45860
|
try {
|
|
@@ -45830,12 +45910,12 @@ function loadConfigWithLogger(directory, log16) {
|
|
|
45830
45910
|
return config;
|
|
45831
45911
|
}
|
|
45832
45912
|
function canonicalizeOwnedPath(path5) {
|
|
45833
|
-
const absolute =
|
|
45913
|
+
const absolute = resolve24(path5);
|
|
45834
45914
|
const missing = [];
|
|
45835
45915
|
let current = absolute;
|
|
45836
45916
|
for (; ; ) {
|
|
45837
45917
|
try {
|
|
45838
|
-
return
|
|
45918
|
+
return join33(realpathSync5(current), ...missing.reverse());
|
|
45839
45919
|
} catch {
|
|
45840
45920
|
const parent = dirname25(current);
|
|
45841
45921
|
if (parent === current) return absolute;
|
|
@@ -46141,9 +46221,9 @@ function clearSignatureCache(sessionId) {
|
|
|
46141
46221
|
// src/plugin/image-saver.ts
|
|
46142
46222
|
import { chmodSync as chmodSync4, existsSync as existsSync12, mkdirSync as mkdirSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
46143
46223
|
import { homedir as homedir13 } from "node:os";
|
|
46144
|
-
import { join as
|
|
46224
|
+
import { join as join34 } from "node:path";
|
|
46145
46225
|
function getImageOutputDir(outputDir) {
|
|
46146
|
-
const resolved = outputDir ??
|
|
46226
|
+
const resolved = outputDir ?? join34(homedir13(), ".opencode", "generated-images");
|
|
46147
46227
|
if (!existsSync12(resolved)) {
|
|
46148
46228
|
mkdirSync6(resolved, { recursive: true, mode: 448 });
|
|
46149
46229
|
}
|
|
@@ -46166,7 +46246,7 @@ function generateImageFilename(mimeType) {
|
|
|
46166
46246
|
function saveImageToDisk(base64Data, mimeType, outputDir) {
|
|
46167
46247
|
try {
|
|
46168
46248
|
const resolvedOutputDir = getImageOutputDir(outputDir);
|
|
46169
|
-
const filePath =
|
|
46249
|
+
const filePath = join34(resolvedOutputDir, generateImageFilename(mimeType));
|
|
46170
46250
|
writeFileSync6(filePath, Buffer.from(base64Data, "base64"), { mode: 384 });
|
|
46171
46251
|
chmodSync4(filePath, 384);
|
|
46172
46252
|
return filePath;
|
|
@@ -46607,10 +46687,10 @@ init_logging_utils();
|
|
|
46607
46687
|
import { createHash as createHash17 } from "node:crypto";
|
|
46608
46688
|
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync7, writeFileSync as writeFileSync7 } from "node:fs";
|
|
46609
46689
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
46610
|
-
import { join as
|
|
46690
|
+
import { join as join35 } from "node:path";
|
|
46611
46691
|
var DUMP_STATUS_TITLE = "## Gemini Dump Status";
|
|
46612
46692
|
var DUMP_DIR_ENV = "OPENCODE_ANTIGRAVITY_GEMINI_DUMP_DIR";
|
|
46613
|
-
var DEFAULT_DUMP_DIR =
|
|
46693
|
+
var DEFAULT_DUMP_DIR = join35(tmpdir6(), "opencode-antigravity-gemini-dumps");
|
|
46614
46694
|
var DUMP_DIR_MODE = 448;
|
|
46615
46695
|
var DUMP_FILE_MODE = 384;
|
|
46616
46696
|
var nextDumpId = 0;
|
|
@@ -46764,7 +46844,7 @@ function writeGeminiDump(input2) {
|
|
|
46764
46844
|
nextDumpId += 1;
|
|
46765
46845
|
const id = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${String(nextDumpId).padStart(5, "0")}-${input2.streaming ? "stream" : "json"}`;
|
|
46766
46846
|
const dumpDir = getGeminiDumpDirectory();
|
|
46767
|
-
const prefix =
|
|
46847
|
+
const prefix = join35(dumpDir, id);
|
|
46768
46848
|
mkdirSync7(dumpDir, { recursive: true, mode: DUMP_DIR_MODE });
|
|
46769
46849
|
const context = {
|
|
46770
46850
|
id,
|
|
@@ -46855,21 +46935,21 @@ import {
|
|
|
46855
46935
|
unlinkSync as unlinkSync4,
|
|
46856
46936
|
writeFileSync as writeFileSync8
|
|
46857
46937
|
} from "node:fs";
|
|
46858
|
-
import { join as
|
|
46938
|
+
import { join as join37 } from "node:path";
|
|
46859
46939
|
|
|
46860
46940
|
// src/plugin/recovery/constants.ts
|
|
46861
46941
|
import { homedir as homedir14 } from "node:os";
|
|
46862
|
-
import { join as
|
|
46942
|
+
import { join as join36 } from "node:path";
|
|
46863
46943
|
function getXdgData() {
|
|
46864
46944
|
const platform = process.platform;
|
|
46865
46945
|
if (platform === "win32") {
|
|
46866
|
-
return process.env.APPDATA ||
|
|
46946
|
+
return process.env.APPDATA || join36(homedir14(), "AppData", "Roaming");
|
|
46867
46947
|
}
|
|
46868
|
-
return process.env.XDG_DATA_HOME ||
|
|
46948
|
+
return process.env.XDG_DATA_HOME || join36(homedir14(), ".local", "share");
|
|
46869
46949
|
}
|
|
46870
|
-
var OPENCODE_STORAGE =
|
|
46871
|
-
var MESSAGE_STORAGE =
|
|
46872
|
-
var PART_STORAGE =
|
|
46950
|
+
var OPENCODE_STORAGE = join36(getXdgData(), "opencode", "storage");
|
|
46951
|
+
var MESSAGE_STORAGE = join36(OPENCODE_STORAGE, "message");
|
|
46952
|
+
var PART_STORAGE = join36(OPENCODE_STORAGE, "part");
|
|
46873
46953
|
var THINKING_TYPES = /* @__PURE__ */ new Set([
|
|
46874
46954
|
"thinking",
|
|
46875
46955
|
"redacted_thinking",
|
|
@@ -46879,13 +46959,13 @@ var THINKING_TYPES = /* @__PURE__ */ new Set([
|
|
|
46879
46959
|
// src/plugin/recovery/storage.ts
|
|
46880
46960
|
function getMessageDir(sessionID) {
|
|
46881
46961
|
if (!existsSync13(MESSAGE_STORAGE)) return "";
|
|
46882
|
-
const directPath =
|
|
46962
|
+
const directPath = join37(MESSAGE_STORAGE, sessionID);
|
|
46883
46963
|
if (existsSync13(directPath)) {
|
|
46884
46964
|
return directPath;
|
|
46885
46965
|
}
|
|
46886
46966
|
try {
|
|
46887
46967
|
for (const dir of readdirSync2(MESSAGE_STORAGE)) {
|
|
46888
|
-
const sessionPath =
|
|
46968
|
+
const sessionPath = join37(MESSAGE_STORAGE, dir, sessionID);
|
|
46889
46969
|
if (existsSync13(sessionPath)) {
|
|
46890
46970
|
return sessionPath;
|
|
46891
46971
|
}
|
|
@@ -46902,7 +46982,7 @@ function readMessages(sessionID) {
|
|
|
46902
46982
|
for (const file of readdirSync2(messageDir)) {
|
|
46903
46983
|
if (!file.endsWith(".json")) continue;
|
|
46904
46984
|
try {
|
|
46905
|
-
const content = readFileSync12(
|
|
46985
|
+
const content = readFileSync12(join37(messageDir, file), "utf-8");
|
|
46906
46986
|
messages.push(JSON.parse(content));
|
|
46907
46987
|
} catch {
|
|
46908
46988
|
}
|
|
@@ -46918,14 +46998,14 @@ function readMessages(sessionID) {
|
|
|
46918
46998
|
});
|
|
46919
46999
|
}
|
|
46920
47000
|
function readParts(messageID) {
|
|
46921
|
-
const partDir =
|
|
47001
|
+
const partDir = join37(PART_STORAGE, messageID);
|
|
46922
47002
|
if (!existsSync13(partDir)) return [];
|
|
46923
47003
|
const parts = [];
|
|
46924
47004
|
try {
|
|
46925
47005
|
for (const file of readdirSync2(partDir)) {
|
|
46926
47006
|
if (!file.endsWith(".json")) continue;
|
|
46927
47007
|
try {
|
|
46928
|
-
const content = readFileSync12(
|
|
47008
|
+
const content = readFileSync12(join37(partDir, file), "utf-8");
|
|
46929
47009
|
parts.push(JSON.parse(content));
|
|
46930
47010
|
} catch {
|
|
46931
47011
|
}
|
|
@@ -46967,7 +47047,7 @@ function findMessagesWithOrphanThinking(sessionID) {
|
|
|
46967
47047
|
return result;
|
|
46968
47048
|
}
|
|
46969
47049
|
function prependThinkingPart(sessionID, messageID) {
|
|
46970
|
-
const partDir =
|
|
47050
|
+
const partDir = join37(PART_STORAGE, messageID);
|
|
46971
47051
|
try {
|
|
46972
47052
|
if (!existsSync13(partDir)) {
|
|
46973
47053
|
mkdirSync8(partDir, { recursive: true });
|
|
@@ -46982,7 +47062,7 @@ function prependThinkingPart(sessionID, messageID) {
|
|
|
46982
47062
|
synthetic: true
|
|
46983
47063
|
};
|
|
46984
47064
|
writeFileSync8(
|
|
46985
|
-
|
|
47065
|
+
join37(partDir, `${partId}.json`),
|
|
46986
47066
|
JSON.stringify(part, null, 2)
|
|
46987
47067
|
);
|
|
46988
47068
|
return true;
|
|
@@ -46991,14 +47071,14 @@ function prependThinkingPart(sessionID, messageID) {
|
|
|
46991
47071
|
}
|
|
46992
47072
|
}
|
|
46993
47073
|
function stripThinkingParts(messageID) {
|
|
46994
|
-
const partDir =
|
|
47074
|
+
const partDir = join37(PART_STORAGE, messageID);
|
|
46995
47075
|
if (!existsSync13(partDir)) return false;
|
|
46996
47076
|
let anyRemoved = false;
|
|
46997
47077
|
try {
|
|
46998
47078
|
for (const file of readdirSync2(partDir)) {
|
|
46999
47079
|
if (!file.endsWith(".json")) continue;
|
|
47000
47080
|
try {
|
|
47001
|
-
const filePath =
|
|
47081
|
+
const filePath = join37(partDir, file);
|
|
47002
47082
|
const content = readFileSync12(filePath, "utf-8");
|
|
47003
47083
|
const part = JSON.parse(content);
|
|
47004
47084
|
if (THINKING_TYPES.has(part.type)) {
|
|
@@ -49805,6 +49885,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
49805
49885
|
headers.delete("x-parent-session-id");
|
|
49806
49886
|
headers.delete("x-opencode-session-id");
|
|
49807
49887
|
headers.delete("x-opencode-parent-session-id");
|
|
49888
|
+
headers.delete("x-antigravity-internal-request-purpose");
|
|
49808
49889
|
headers.delete("x-goog-user-project");
|
|
49809
49890
|
headers.delete("X-Goog-Api-Client");
|
|
49810
49891
|
headers.delete("Client-Metadata");
|
|
@@ -50768,10 +50849,10 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
50768
50849
|
cancellation.release();
|
|
50769
50850
|
throw error;
|
|
50770
50851
|
}
|
|
50771
|
-
let
|
|
50852
|
+
let resolve27 = () => {
|
|
50772
50853
|
};
|
|
50773
50854
|
const settled = new Promise((done) => {
|
|
50774
|
-
|
|
50855
|
+
resolve27 = done;
|
|
50775
50856
|
});
|
|
50776
50857
|
let stopping = false;
|
|
50777
50858
|
let finished = false;
|
|
@@ -50781,7 +50862,7 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
50781
50862
|
finished = true;
|
|
50782
50863
|
cancellation.signal.removeEventListener("abort", abort);
|
|
50783
50864
|
cancellation.release();
|
|
50784
|
-
|
|
50865
|
+
resolve27();
|
|
50785
50866
|
};
|
|
50786
50867
|
const abort = () => {
|
|
50787
50868
|
if (finished || stopping) return;
|
|
@@ -50850,8 +50931,8 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
50850
50931
|
let running = false;
|
|
50851
50932
|
let resolveCompletion = () => {
|
|
50852
50933
|
};
|
|
50853
|
-
const completion = new Promise((
|
|
50854
|
-
resolveCompletion =
|
|
50934
|
+
const completion = new Promise((resolve27) => {
|
|
50935
|
+
resolveCompletion = resolve27;
|
|
50855
50936
|
});
|
|
50856
50937
|
const finish = () => {
|
|
50857
50938
|
if (finished) return;
|
|
@@ -50898,14 +50979,14 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
50898
50979
|
};
|
|
50899
50980
|
}
|
|
50900
50981
|
function publishResponse(dispatch) {
|
|
50901
|
-
return new Promise((
|
|
50982
|
+
return new Promise((resolve27, reject) => {
|
|
50902
50983
|
let acknowledge;
|
|
50903
50984
|
void Promise.resolve().then(
|
|
50904
50985
|
() => dispatch((callback) => {
|
|
50905
50986
|
acknowledge = callback;
|
|
50906
50987
|
})
|
|
50907
50988
|
).then((response) => {
|
|
50908
|
-
|
|
50989
|
+
resolve27(response);
|
|
50909
50990
|
acknowledge?.();
|
|
50910
50991
|
}, reject);
|
|
50911
50992
|
});
|
|
@@ -52702,15 +52783,15 @@ init_debug();
|
|
|
52702
52783
|
// src/plugin/dependencies.ts
|
|
52703
52784
|
init_dist();
|
|
52704
52785
|
import { homedir as homedir15 } from "node:os";
|
|
52705
|
-
import { join as
|
|
52786
|
+
import { join as join38 } from "node:path";
|
|
52706
52787
|
function defaultFilesystemRoots() {
|
|
52707
|
-
const xdgConfig2 = process.env.XDG_CONFIG_HOME ??
|
|
52708
|
-
const xdgState2 = process.env.XDG_STATE_HOME ??
|
|
52788
|
+
const xdgConfig2 = process.env.XDG_CONFIG_HOME ?? join38(homedir15(), ".config");
|
|
52789
|
+
const xdgState2 = process.env.XDG_STATE_HOME ?? join38(homedir15(), ".local", "state");
|
|
52709
52790
|
return {
|
|
52710
52791
|
projectRoot: process.cwd(),
|
|
52711
|
-
userConfigRoot:
|
|
52712
|
-
sidebarStateRoot:
|
|
52713
|
-
rpcRoot:
|
|
52792
|
+
userConfigRoot: join38(xdgConfig2, "opencode"),
|
|
52793
|
+
sidebarStateRoot: join38(xdgState2, "cortexkit", "antigravity-auth"),
|
|
52794
|
+
rpcRoot: join38(xdgState2, "cortexkit", "antigravity-auth", "rpc")
|
|
52714
52795
|
};
|
|
52715
52796
|
}
|
|
52716
52797
|
function resolvePluginDependencies(overrides = {}) {
|
|
@@ -52739,10 +52820,10 @@ function resolvePluginDependencies(overrides = {}) {
|
|
|
52739
52820
|
}
|
|
52740
52821
|
async function defaultSleep(ms, signal) {
|
|
52741
52822
|
if (ms <= 0) return;
|
|
52742
|
-
await new Promise((
|
|
52823
|
+
await new Promise((resolve27, reject) => {
|
|
52743
52824
|
const timer = setTimeout(() => {
|
|
52744
52825
|
signal?.removeEventListener("abort", onAbort);
|
|
52745
|
-
|
|
52826
|
+
resolve27();
|
|
52746
52827
|
}, ms);
|
|
52747
52828
|
timer.unref?.();
|
|
52748
52829
|
const onAbort = () => {
|
|
@@ -52863,6 +52944,107 @@ init_logger4();
|
|
|
52863
52944
|
// src/plugin/shared/request-services.ts
|
|
52864
52945
|
init_dist();
|
|
52865
52946
|
|
|
52947
|
+
// src/common-auth-embedded/routing-accessor/index.js
|
|
52948
|
+
function isObject2(value) {
|
|
52949
|
+
return typeof value === "object" && value !== null;
|
|
52950
|
+
}
|
|
52951
|
+
function routingHandle(sessionId) {
|
|
52952
|
+
const routing = Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing"));
|
|
52953
|
+
if (typeof routing !== "function")
|
|
52954
|
+
return void 0;
|
|
52955
|
+
const handle = routing(sessionId);
|
|
52956
|
+
return isObject2(handle) ? handle : void 0;
|
|
52957
|
+
}
|
|
52958
|
+
function selectionFor(answer, candidates) {
|
|
52959
|
+
if (!isObject2(answer))
|
|
52960
|
+
return void 0;
|
|
52961
|
+
const accountId = answer.account_id;
|
|
52962
|
+
const credentialId = answer.credential_id;
|
|
52963
|
+
if (typeof accountId !== "string")
|
|
52964
|
+
return void 0;
|
|
52965
|
+
if (credentialId !== void 0 && typeof credentialId !== "string") {
|
|
52966
|
+
return void 0;
|
|
52967
|
+
}
|
|
52968
|
+
const candidate = candidates.find((route) => route.accountId === accountId && (credentialId === void 0 || route.credentialId === credentialId));
|
|
52969
|
+
if (!candidate)
|
|
52970
|
+
return void 0;
|
|
52971
|
+
const hold = answer.hold;
|
|
52972
|
+
const retryAfterMs = isObject2(hold) ? hold.retry_after_ms : void 0;
|
|
52973
|
+
if (typeof retryAfterMs === "number" && Number.isFinite(retryAfterMs) && retryAfterMs >= 0) {
|
|
52974
|
+
return { candidate, hold: { retry_after_ms: retryAfterMs } };
|
|
52975
|
+
}
|
|
52976
|
+
return { candidate };
|
|
52977
|
+
}
|
|
52978
|
+
async function askRouting(input2) {
|
|
52979
|
+
let timer;
|
|
52980
|
+
try {
|
|
52981
|
+
const handle = routingHandle(input2.sessionId);
|
|
52982
|
+
if (!handle)
|
|
52983
|
+
return void 0;
|
|
52984
|
+
const accountFor = handle.accountFor;
|
|
52985
|
+
if (typeof accountFor !== "function")
|
|
52986
|
+
return void 0;
|
|
52987
|
+
const requested = input2.deadlineMs ?? 500;
|
|
52988
|
+
const deadlineMs = Number.isNaN(requested) ? 500 : Math.min(2e3, Math.max(1, requested));
|
|
52989
|
+
const expired = new Promise((resolve27) => {
|
|
52990
|
+
timer = setTimeout(() => resolve27(void 0), deadlineMs);
|
|
52991
|
+
timer.unref();
|
|
52992
|
+
});
|
|
52993
|
+
const pending = accountFor.call(handle, { provider: input2.provider, modelId: input2.modelId }, { deadlineMs });
|
|
52994
|
+
if (!isObject2(pending) || typeof pending.then !== "function")
|
|
52995
|
+
return void 0;
|
|
52996
|
+
const answer = await Promise.race([pending, expired]);
|
|
52997
|
+
return selectionFor(answer, input2.candidates);
|
|
52998
|
+
} catch {
|
|
52999
|
+
return void 0;
|
|
53000
|
+
} finally {
|
|
53001
|
+
clearTimeout(timer);
|
|
53002
|
+
}
|
|
53003
|
+
}
|
|
53004
|
+
function reportRouting(input2) {
|
|
53005
|
+
try {
|
|
53006
|
+
const handle = routingHandle(input2.sessionId);
|
|
53007
|
+
if (!handle)
|
|
53008
|
+
return;
|
|
53009
|
+
const report = handle.report;
|
|
53010
|
+
if (typeof report !== "function")
|
|
53011
|
+
return;
|
|
53012
|
+
const identity3 = {
|
|
53013
|
+
account_id: input2.accountId,
|
|
53014
|
+
...input2.credentialId !== void 0 ? { credential_id: input2.credentialId } : {}
|
|
53015
|
+
};
|
|
53016
|
+
let payload;
|
|
53017
|
+
switch (input2.outcome) {
|
|
53018
|
+
case "served":
|
|
53019
|
+
payload = { ...identity3, outcome: "served", headers: input2.headers };
|
|
53020
|
+
break;
|
|
53021
|
+
case "exhausted": {
|
|
53022
|
+
const { window, pool } = input2;
|
|
53023
|
+
if (window !== "5h" && window !== "7d")
|
|
53024
|
+
return;
|
|
53025
|
+
if (pool !== void 0 && (typeof pool !== "string" || pool.length === 0 || pool.includes(":")))
|
|
53026
|
+
return;
|
|
53027
|
+
payload = {
|
|
53028
|
+
...identity3,
|
|
53029
|
+
outcome: "exhausted",
|
|
53030
|
+
window,
|
|
53031
|
+
...pool ? { pool } : {},
|
|
53032
|
+
...input2.resetsAt !== void 0 ? { resets_at: input2.resetsAt } : {}
|
|
53033
|
+
};
|
|
53034
|
+
break;
|
|
53035
|
+
}
|
|
53036
|
+
default:
|
|
53037
|
+
return;
|
|
53038
|
+
}
|
|
53039
|
+
const pending = report.call(handle, payload);
|
|
53040
|
+
if (isObject2(pending) && typeof pending.then === "function") {
|
|
53041
|
+
void Promise.resolve(pending).catch(() => {
|
|
53042
|
+
});
|
|
53043
|
+
}
|
|
53044
|
+
} catch {
|
|
53045
|
+
}
|
|
53046
|
+
}
|
|
53047
|
+
|
|
52866
53048
|
// src/plugin/errors.ts
|
|
52867
53049
|
var AntigravityKillswitchError = class extends Error {
|
|
52868
53050
|
family;
|
|
@@ -53328,7 +53510,7 @@ function throwIfAllKilled(input2) {
|
|
|
53328
53510
|
}
|
|
53329
53511
|
|
|
53330
53512
|
// src/plugin/session-context.ts
|
|
53331
|
-
import { resolve as
|
|
53513
|
+
import { resolve as resolve25 } from "node:path";
|
|
53332
53514
|
import { pathToFileURL } from "node:url";
|
|
53333
53515
|
var FALLBACK_SESSION_KEY = "__default__";
|
|
53334
53516
|
function extractOpenCodeSessionIdentity(headers) {
|
|
@@ -53342,7 +53524,7 @@ var AgySessionRegistry = class {
|
|
|
53342
53524
|
requestSessions;
|
|
53343
53525
|
parentSessionIds = /* @__PURE__ */ new Map();
|
|
53344
53526
|
constructor(directory, options = {}) {
|
|
53345
|
-
const workspaceUri = directory ? pathToFileURL(
|
|
53527
|
+
const workspaceUri = directory ? pathToFileURL(resolve25(directory)).href : "";
|
|
53346
53528
|
this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
|
|
53347
53529
|
}
|
|
53348
53530
|
getOrCreate(identity3) {
|
|
@@ -53394,6 +53576,192 @@ var AgySessionRegistry = class {
|
|
|
53394
53576
|
}
|
|
53395
53577
|
};
|
|
53396
53578
|
|
|
53579
|
+
// src/plugin/shared/vault-routing.ts
|
|
53580
|
+
var ROUTING_GROUP_SCOPED_EXHAUSTION = false;
|
|
53581
|
+
function hasVaultRoutingAccessor() {
|
|
53582
|
+
try {
|
|
53583
|
+
return typeof Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing")) === "function";
|
|
53584
|
+
} catch {
|
|
53585
|
+
return false;
|
|
53586
|
+
}
|
|
53587
|
+
}
|
|
53588
|
+
function routingQuotaScope(group, window) {
|
|
53589
|
+
const limitWindow = window === "5h" ? "five_hour" : window === "weekly" ? "seven_day" : void 0;
|
|
53590
|
+
return limitWindow ? { pool: group === "non-gemini" ? "3p" : group, limitWindow } : void 0;
|
|
53591
|
+
}
|
|
53592
|
+
function routingExhaustionFields(scope) {
|
|
53593
|
+
return {
|
|
53594
|
+
pool: scope.pool,
|
|
53595
|
+
window: scope.limitWindow === "five_hour" ? "5h" : "7d"
|
|
53596
|
+
};
|
|
53597
|
+
}
|
|
53598
|
+
function reportVaultExhaustion(input2, groupScopedExhaustion = ROUTING_GROUP_SCOPED_EXHAUSTION, report = reportRouting) {
|
|
53599
|
+
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())
|
|
53600
|
+
return;
|
|
53601
|
+
for (const window of input2.quota?.windows ?? []) {
|
|
53602
|
+
if (window.remainingFraction !== 0) continue;
|
|
53603
|
+
const scope = routingQuotaScope(input2.group, window.window);
|
|
53604
|
+
const resetsAt = Date.parse(window.resetTime);
|
|
53605
|
+
if (!scope || !Number.isFinite(resetsAt) || resetsAt <= Date.now()) continue;
|
|
53606
|
+
if (groupScopedExhaustion)
|
|
53607
|
+
report({
|
|
53608
|
+
...input2.identity,
|
|
53609
|
+
outcome: "exhausted",
|
|
53610
|
+
...routingExhaustionFields(scope),
|
|
53611
|
+
resetsAt
|
|
53612
|
+
});
|
|
53613
|
+
}
|
|
53614
|
+
}
|
|
53615
|
+
var RATE_LIMIT_HEADERS = [
|
|
53616
|
+
"retry-after",
|
|
53617
|
+
"retry-after-ms",
|
|
53618
|
+
"ratelimit-limit",
|
|
53619
|
+
"ratelimit-remaining",
|
|
53620
|
+
"ratelimit-reset",
|
|
53621
|
+
"ratelimit-policy",
|
|
53622
|
+
"x-ratelimit-limit",
|
|
53623
|
+
"x-ratelimit-remaining",
|
|
53624
|
+
"x-ratelimit-reset",
|
|
53625
|
+
"x-ratelimit-limit-requests",
|
|
53626
|
+
"x-ratelimit-remaining-requests",
|
|
53627
|
+
"x-ratelimit-reset-requests",
|
|
53628
|
+
"x-ratelimit-limit-tokens",
|
|
53629
|
+
"x-ratelimit-remaining-tokens",
|
|
53630
|
+
"x-ratelimit-reset-tokens"
|
|
53631
|
+
];
|
|
53632
|
+
function streamFailure(value) {
|
|
53633
|
+
if (!value || typeof value !== "object") return false;
|
|
53634
|
+
if (Array.isArray(value)) return value.some(streamFailure);
|
|
53635
|
+
const event = value;
|
|
53636
|
+
return event.error != null || event.type === "error" || event.type === "response.failed" || event.status === "failed" || streamFailure(event.response);
|
|
53637
|
+
}
|
|
53638
|
+
function observeVaultUpstream(response, signal) {
|
|
53639
|
+
if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
|
|
53640
|
+
return void 0;
|
|
53641
|
+
let completed = false;
|
|
53642
|
+
return {
|
|
53643
|
+
response: observeBody(response, () => {
|
|
53644
|
+
completed = !signal?.aborted;
|
|
53645
|
+
}),
|
|
53646
|
+
completedSuccessfully: () => completed
|
|
53647
|
+
};
|
|
53648
|
+
}
|
|
53649
|
+
function observeVaultServed(identity3, response, signal, upstream) {
|
|
53650
|
+
if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
|
|
53651
|
+
return response;
|
|
53652
|
+
const report = () => {
|
|
53653
|
+
if (signal?.aborted || upstream && !upstream.completedSuccessfully() || !hasVaultRoutingAccessor())
|
|
53654
|
+
return;
|
|
53655
|
+
const headers = {};
|
|
53656
|
+
for (const name of RATE_LIMIT_HEADERS) {
|
|
53657
|
+
const value = response.headers.get(name);
|
|
53658
|
+
if (value !== null) headers[name] = value;
|
|
53659
|
+
}
|
|
53660
|
+
reportRouting({ ...identity3, outcome: "served", headers });
|
|
53661
|
+
};
|
|
53662
|
+
return observeBody(response, report);
|
|
53663
|
+
}
|
|
53664
|
+
function observeBody(response, complete) {
|
|
53665
|
+
if (!response.body) {
|
|
53666
|
+
complete();
|
|
53667
|
+
return response;
|
|
53668
|
+
}
|
|
53669
|
+
const sse = response.headers.get("content-type")?.includes("text/event-stream");
|
|
53670
|
+
const reader = response.body.getReader();
|
|
53671
|
+
const decoder = new TextDecoder();
|
|
53672
|
+
let pending = "";
|
|
53673
|
+
let failed = false;
|
|
53674
|
+
const inspect = (line) => {
|
|
53675
|
+
if (line.length > 1024 * 1024) {
|
|
53676
|
+
failed = true;
|
|
53677
|
+
return;
|
|
53678
|
+
}
|
|
53679
|
+
if (line.startsWith("event:") && line.slice(6).trim() === "error")
|
|
53680
|
+
failed = true;
|
|
53681
|
+
if (!line.startsWith("data:") || !/"(?:error|response.failed|failed)"/.test(line))
|
|
53682
|
+
return;
|
|
53683
|
+
try {
|
|
53684
|
+
failed ||= streamFailure(JSON.parse(line.slice(5)));
|
|
53685
|
+
} catch {
|
|
53686
|
+
failed = true;
|
|
53687
|
+
}
|
|
53688
|
+
};
|
|
53689
|
+
const body = new ReadableStream(
|
|
53690
|
+
{
|
|
53691
|
+
async pull(controller) {
|
|
53692
|
+
try {
|
|
53693
|
+
const chunk = await reader.read();
|
|
53694
|
+
if (chunk.done) {
|
|
53695
|
+
if (sse) inspect(pending + decoder.decode());
|
|
53696
|
+
else if (/"(?:error|response.failed|failed)"/.test(pending)) {
|
|
53697
|
+
try {
|
|
53698
|
+
failed ||= streamFailure(JSON.parse(pending + decoder.decode()));
|
|
53699
|
+
} catch {
|
|
53700
|
+
failed = true;
|
|
53701
|
+
}
|
|
53702
|
+
}
|
|
53703
|
+
if (!failed) complete();
|
|
53704
|
+
controller.close();
|
|
53705
|
+
reader.releaseLock();
|
|
53706
|
+
return;
|
|
53707
|
+
}
|
|
53708
|
+
if (!failed) {
|
|
53709
|
+
pending += decoder.decode(chunk.value, { stream: true });
|
|
53710
|
+
if (sse) {
|
|
53711
|
+
let newline = pending.indexOf("\n");
|
|
53712
|
+
while (newline >= 0) {
|
|
53713
|
+
inspect(pending.slice(0, newline));
|
|
53714
|
+
pending = pending.slice(newline + 1);
|
|
53715
|
+
newline = pending.indexOf("\n");
|
|
53716
|
+
}
|
|
53717
|
+
}
|
|
53718
|
+
if (pending.length > 1024 * 1024) {
|
|
53719
|
+
failed = true;
|
|
53720
|
+
pending = "";
|
|
53721
|
+
}
|
|
53722
|
+
}
|
|
53723
|
+
controller.enqueue(chunk.value);
|
|
53724
|
+
} catch (error) {
|
|
53725
|
+
failed = true;
|
|
53726
|
+
controller.error(error);
|
|
53727
|
+
reader.releaseLock();
|
|
53728
|
+
}
|
|
53729
|
+
},
|
|
53730
|
+
async cancel(reason) {
|
|
53731
|
+
failed = true;
|
|
53732
|
+
try {
|
|
53733
|
+
await reader.cancel(reason);
|
|
53734
|
+
} finally {
|
|
53735
|
+
reader.releaseLock();
|
|
53736
|
+
}
|
|
53737
|
+
}
|
|
53738
|
+
},
|
|
53739
|
+
{ highWaterMark: 0 }
|
|
53740
|
+
);
|
|
53741
|
+
const observed = new Response(body, {
|
|
53742
|
+
status: response.status,
|
|
53743
|
+
statusText: response.statusText,
|
|
53744
|
+
headers: response.headers
|
|
53745
|
+
});
|
|
53746
|
+
Object.defineProperties(observed, {
|
|
53747
|
+
url: { value: response.url },
|
|
53748
|
+
redirected: { value: response.redirected }
|
|
53749
|
+
});
|
|
53750
|
+
return observed;
|
|
53751
|
+
}
|
|
53752
|
+
|
|
53753
|
+
// src/plugin/shared/vault-routing-purpose.ts
|
|
53754
|
+
var VAULT_ROUTING_PURPOSE_HEADER = "x-antigravity-internal-request-purpose";
|
|
53755
|
+
function createVaultRoutingHeaders(providerId) {
|
|
53756
|
+
return async (input2, output2) => {
|
|
53757
|
+
if (input2.model.providerID !== providerId) return;
|
|
53758
|
+
output2.headers[VAULT_ROUTING_PURPOSE_HEADER] = input2.agent === "build" || input2.agent === "plan" ? "primary" : "auxiliary";
|
|
53759
|
+
};
|
|
53760
|
+
}
|
|
53761
|
+
function isPrimaryVaultRequest(kind, headers) {
|
|
53762
|
+
return kind === void 0 ? new Headers(headers).get(VAULT_ROUTING_PURPOSE_HEADER) === "primary" : kind === "primary";
|
|
53763
|
+
}
|
|
53764
|
+
|
|
53397
53765
|
// src/plugin/shared/request-services.ts
|
|
53398
53766
|
var FIRST_RETRY_DELAY_MS = 1e3;
|
|
53399
53767
|
function prepareAgyWireRequest(wire, request) {
|
|
@@ -53490,7 +53858,7 @@ function formatWaitTime(ms) {
|
|
|
53490
53858
|
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
|
|
53491
53859
|
}
|
|
53492
53860
|
function sleep4(ms, signal) {
|
|
53493
|
-
return new Promise((
|
|
53861
|
+
return new Promise((resolve27, reject) => {
|
|
53494
53862
|
if (signal?.aborted) {
|
|
53495
53863
|
reject(
|
|
53496
53864
|
signal.reason instanceof Error ? signal.reason : new Error("Aborted")
|
|
@@ -53499,7 +53867,7 @@ function sleep4(ms, signal) {
|
|
|
53499
53867
|
}
|
|
53500
53868
|
const timeout = setTimeout(() => {
|
|
53501
53869
|
cleanup2();
|
|
53502
|
-
|
|
53870
|
+
resolve27();
|
|
53503
53871
|
}, ms);
|
|
53504
53872
|
const onAbort = () => {
|
|
53505
53873
|
cleanup2();
|
|
@@ -53585,7 +53953,7 @@ function createRequestExecutor(deps) {
|
|
|
53585
53953
|
log16.debug("send-admission-401-report-failed", { error: String(error) });
|
|
53586
53954
|
});
|
|
53587
53955
|
};
|
|
53588
|
-
const
|
|
53956
|
+
const reportRouting2 = (sessionId, entry) => {
|
|
53589
53957
|
if (!onRouting) return;
|
|
53590
53958
|
try {
|
|
53591
53959
|
onRouting(sessionId, entry);
|
|
@@ -53756,6 +54124,7 @@ function createRequestExecutor(deps) {
|
|
|
53756
54124
|
const maxWaitMs = (config.max_rate_limit_wait_seconds ?? 300) * 1e3;
|
|
53757
54125
|
let allAccountsBlockedAt;
|
|
53758
54126
|
const modelUnavailableIndexes = /* @__PURE__ */ new Set();
|
|
54127
|
+
let routingPlacementConsidered = false;
|
|
53759
54128
|
while (true) {
|
|
53760
54129
|
await assertAdmission();
|
|
53761
54130
|
checkAborted();
|
|
@@ -53839,6 +54208,11 @@ function createRequestExecutor(deps) {
|
|
|
53839
54208
|
}
|
|
53840
54209
|
}
|
|
53841
54210
|
const excludedIndexes = modelUnavailableIndexes.size === 0 ? killedIndexes : /* @__PURE__ */ new Set([...killedIndexes ?? [], ...modelUnavailableIndexes]);
|
|
54211
|
+
const routingPresent = credentials.domain === "vault" && hasVaultRoutingAccessor();
|
|
54212
|
+
const firstPlacement = routingPresent && !routingPlacementConsidered && accountSessionIdentity && !accountManager.getCurrentAccountForFamily(
|
|
54213
|
+
family,
|
|
54214
|
+
accountSessionIdentity
|
|
54215
|
+
);
|
|
53842
54216
|
let account = accountManager.getCurrentOrNextForFamily(
|
|
53843
54217
|
family,
|
|
53844
54218
|
model,
|
|
@@ -53849,6 +54223,50 @@ function createRequestExecutor(deps) {
|
|
|
53849
54223
|
accountSessionIdentity,
|
|
53850
54224
|
excludedIndexes
|
|
53851
54225
|
);
|
|
54226
|
+
if (account) {
|
|
54227
|
+
routingPlacementConsidered = true;
|
|
54228
|
+
if (firstPlacement && credentials.domain === "vault" && credentials.routingCandidate && model && isPrimaryVaultRequest(kind, init?.headers)) {
|
|
54229
|
+
const candidates = accountManager.getEnabledAccounts().filter(
|
|
54230
|
+
(row) => !excludedIndexes?.has(row.index) && !accountManager.isRateLimited(row, family, model) && !accountManager.isAccountCoolingDown(row) && !accountManager.isAccountOverSoftQuota(
|
|
54231
|
+
row,
|
|
54232
|
+
family,
|
|
54233
|
+
config.soft_quota_threshold_percent,
|
|
54234
|
+
softQuotaCacheTtlMs,
|
|
54235
|
+
model
|
|
54236
|
+
)
|
|
54237
|
+
).map((row) => ({
|
|
54238
|
+
...credentials.routingCandidate(row),
|
|
54239
|
+
index: row.index
|
|
54240
|
+
}));
|
|
54241
|
+
if (candidates.length > 0) {
|
|
54242
|
+
const answer = await deadline.wait(
|
|
54243
|
+
() => askRouting({
|
|
54244
|
+
sessionId: accountSessionIdentity.id,
|
|
54245
|
+
provider: "antigravity",
|
|
54246
|
+
modelId: model,
|
|
54247
|
+
candidates,
|
|
54248
|
+
deadlineMs: Math.min(500, deadline.remainingMs())
|
|
54249
|
+
})
|
|
54250
|
+
);
|
|
54251
|
+
checkAborted();
|
|
54252
|
+
if (answer && answer.candidate.index !== account.index) {
|
|
54253
|
+
account = accountManager.getCurrentOrNextForFamily(
|
|
54254
|
+
family,
|
|
54255
|
+
model,
|
|
54256
|
+
config.account_selection_strategy,
|
|
54257
|
+
config.pid_offset_enabled,
|
|
54258
|
+
config.soft_quota_threshold_percent,
|
|
54259
|
+
softQuotaCacheTtlMs,
|
|
54260
|
+
accountSessionIdentity,
|
|
54261
|
+
/* @__PURE__ */ new Set([
|
|
54262
|
+
...excludedIndexes ?? [],
|
|
54263
|
+
...accountManager.getAccounts().filter((row) => row.index !== answer.candidate.index).map((row) => row.index)
|
|
54264
|
+
])
|
|
54265
|
+
) ?? account;
|
|
54266
|
+
}
|
|
54267
|
+
}
|
|
54268
|
+
}
|
|
54269
|
+
}
|
|
53852
54270
|
if (account && eligibleIndexes !== null && !eligibleIndexes.has(account.index)) {
|
|
53853
54271
|
pushDebug(
|
|
53854
54272
|
`killswitch-excluded idx=${account.index} (precomputed eligible set)`
|
|
@@ -54508,7 +54926,7 @@ function createRequestExecutor(deps) {
|
|
|
54508
54926
|
strategy: config.account_selection_strategy,
|
|
54509
54927
|
updatedAt: Date.now()
|
|
54510
54928
|
};
|
|
54511
|
-
|
|
54929
|
+
reportRouting2(sessionKey, routingEntry);
|
|
54512
54930
|
}
|
|
54513
54931
|
if (response.status === 429 || response.status === 503 || response.status === 529) {
|
|
54514
54932
|
if (tokenConsumed) {
|
|
@@ -54543,6 +54961,26 @@ function createRequestExecutor(deps) {
|
|
|
54543
54961
|
reasonInfo.message,
|
|
54544
54962
|
response.status
|
|
54545
54963
|
);
|
|
54964
|
+
if (credentials.domain === "vault" && sendAdmission && sessionKey && hasVaultRoutingAccessor()) {
|
|
54965
|
+
const group = resolveQuotaGroup(
|
|
54966
|
+
family,
|
|
54967
|
+
model,
|
|
54968
|
+
account.cachedQuota
|
|
54969
|
+
);
|
|
54970
|
+
reportVaultExhaustion({
|
|
54971
|
+
identity: {
|
|
54972
|
+
sessionId: sessionKey,
|
|
54973
|
+
accountId: sendAdmission.accountIdentity,
|
|
54974
|
+
credentialId: sendAdmission.credentialId
|
|
54975
|
+
},
|
|
54976
|
+
status: response.status,
|
|
54977
|
+
reason: rateLimitReason,
|
|
54978
|
+
group,
|
|
54979
|
+
quota: account.cachedQuota?.[group],
|
|
54980
|
+
observedAt: account.cachedQuotaUpdatedAt,
|
|
54981
|
+
signal: abortSignal
|
|
54982
|
+
});
|
|
54983
|
+
}
|
|
54546
54984
|
if (rateLimitReason === "MODEL_CAPACITY_EXHAUSTED" || rateLimitReason === "SERVER_ERROR") {
|
|
54547
54985
|
totalCapacityRetries++;
|
|
54548
54986
|
if (isCapacityRetryBudgetExhausted(totalCapacityRetries)) {
|
|
@@ -54880,9 +55318,10 @@ function createRequestExecutor(deps) {
|
|
|
54880
55318
|
const _emptyAttemptKeyClean = `${prepared.sessionId ?? "none"}:${prepared.effectiveModel ?? "unknown"}`;
|
|
54881
55319
|
retryState.clearEmptyResponseAttempts();
|
|
54882
55320
|
}
|
|
55321
|
+
const routingObservation = credentials.domain === "vault" && sendAdmission && sessionKey && response.ok && hasVaultRoutingAccessor() ? observeVaultUpstream(response, abortSignal) : void 0;
|
|
54883
55322
|
const transformedResponse = await deadline.wait(
|
|
54884
55323
|
() => wire.transformResponse(
|
|
54885
|
-
response,
|
|
55324
|
+
routingObservation?.response ?? response,
|
|
54886
55325
|
prepared.streaming,
|
|
54887
55326
|
debugContext,
|
|
54888
55327
|
prepared.requestedModel,
|
|
@@ -54954,7 +55393,16 @@ function createRequestExecutor(deps) {
|
|
|
54954
55393
|
const refresh = credentials.refreshQuotaAfterSuccess;
|
|
54955
55394
|
waitPolicy.quota = (signal) => refresh(account, config.quota_refresh_interval_minutes, signal);
|
|
54956
55395
|
}
|
|
54957
|
-
return
|
|
55396
|
+
return routingObservation && credentials.domain === "vault" && sendAdmission && sessionKey && hasVaultRoutingAccessor() && response.ok ? observeVaultServed(
|
|
55397
|
+
{
|
|
55398
|
+
sessionId: sessionKey,
|
|
55399
|
+
accountId: sendAdmission.accountIdentity,
|
|
55400
|
+
credentialId: sendAdmission.credentialId
|
|
55401
|
+
},
|
|
55402
|
+
transformedResponse,
|
|
55403
|
+
abortSignal,
|
|
55404
|
+
routingObservation
|
|
55405
|
+
) : transformedResponse;
|
|
54958
55406
|
} catch (error) {
|
|
54959
55407
|
if (error instanceof PreResponseTimeoutError) throw error;
|
|
54960
55408
|
checkAborted();
|
|
@@ -55987,8 +56435,8 @@ function createPluginLifecycle(options) {
|
|
|
55987
56435
|
};
|
|
55988
56436
|
let failDisposal = () => {
|
|
55989
56437
|
};
|
|
55990
|
-
disposal = new Promise((
|
|
55991
|
-
finishDisposal =
|
|
56438
|
+
disposal = new Promise((resolve27, reject) => {
|
|
56439
|
+
finishDisposal = resolve27;
|
|
55992
56440
|
failDisposal = reject;
|
|
55993
56441
|
});
|
|
55994
56442
|
void (async () => {
|
|
@@ -56187,7 +56635,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
56187
56635
|
await drainSidebarWrites();
|
|
56188
56636
|
}
|
|
56189
56637
|
});
|
|
56190
|
-
const accountFile =
|
|
56638
|
+
const accountFile = resolve26(accountFileForVault());
|
|
56191
56639
|
const vaultFolder = await prepareVaultFolder({ accountFile });
|
|
56192
56640
|
const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
|
|
56193
56641
|
let vaultQuotaPoller;
|
|
@@ -56410,7 +56858,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
56410
56858
|
lifecycle.register(vaultQuotaPoller, "producer");
|
|
56411
56859
|
}
|
|
56412
56860
|
const operatorSettings = createOperatorSettingsController({
|
|
56413
|
-
projectConfigPath:
|
|
56861
|
+
projectConfigPath: join39(directory, ".opencode", "antigravity.json"),
|
|
56414
56862
|
// getUserConfigPath() already returns the full file path including
|
|
56415
56863
|
// 'antigravity.json' — do NOT join again or the path double-nests
|
|
56416
56864
|
// into <dir>/antigravity.json/antigravity.json.
|
|
@@ -56850,6 +57298,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
56850
57298
|
);
|
|
56851
57299
|
},
|
|
56852
57300
|
"command.execute.before": commandExecuteBefore,
|
|
57301
|
+
"chat.headers": createVaultRoutingHeaders(providerId),
|
|
56853
57302
|
event,
|
|
56854
57303
|
tool: { google_search: googleSearchTool },
|
|
56855
57304
|
auth: {
|