@cortexkit/opencode-antigravity-auth 3.0.18 → 3.0.20
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/README.md +3 -1
- package/dist/cli.js +202 -118
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +18 -18
- package/dist/index.js +263 -179
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +25 -25
- package/dist/server.js +276 -192
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.js +25 -0
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/dist/src/common-auth-embedded/claustrum/custody.js +20 -6
- package/dist/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/dist/src/common-auth-embedded/claustrum/hub.js +55 -5
- package/dist/src/common-auth-embedded/claustrum/roster.js +1 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
- package/dist/src/common-auth-embedded/fs/with-lock.js +1 -1
- package/dist/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/dist/src/common-auth-embedded/opencode2/install.js +144 -17
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +52 -1
- package/dist/src/common-auth-embedded/source-output.json +48 -48
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +0 -1
- 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/config/schema.js +4 -4
- package/dist/src/plugin/config/schema.js.map +1 -1
- package/dist/src/plugin/config/writer.d.ts +4 -5
- package/dist/src/plugin/config/writer.d.ts.map +1 -1
- package/dist/src/plugin/config/writer.js +4 -5
- package/dist/src/plugin/config/writer.js.map +1 -1
- package/dist/src/plugin/errors.js +1 -1
- package/dist/src/plugin/request-helpers.js +2 -2
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/server.d.ts +4 -4
- package/dist/src/server.js +4 -4
- package/dist/src/tui/sidebar-frame.d.ts +3 -4
- package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
- package/dist/src/tui/sidebar-frame.js +4 -8
- package/dist/src/tui/sidebar-frame.js.map +1 -1
- package/dist/src/tui.js +1 -1
- package/dist/tui-build-map.json +9 -9
- package/dist/tui-ga-build-map.json +9 -9
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +52 -1
- package/dist/types/src/plugin/config/writer.d.ts +4 -5
- package/dist/types/src/plugin/config/writer.d.ts.map +1 -1
- package/dist/types/src/server.d.ts +4 -4
- package/package.json +3 -3
- package/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/src/common-auth-embedded/claustrum/consumer.js +25 -0
- package/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/src/common-auth-embedded/claustrum/custody.js +20 -6
- package/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/src/common-auth-embedded/claustrum/hub.js +55 -5
- package/src/common-auth-embedded/claustrum/roster.js +1 -1
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
- package/src/common-auth-embedded/fs/with-lock.js +1 -1
- package/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/src/common-auth-embedded/opencode2/install.js +144 -17
- package/src/common-auth-embedded/opencode2/types.d.ts +52 -1
- package/src/common-auth-embedded/source-output.json +48 -48
- package/src/tui-compiled/tui/sidebar-frame.js +35 -72
- package/src/tui-compiled/tui.js +1 -1
- package/src/tui-ga-compiled/host-ga.js +0 -1
- package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +35 -72
- package/src/tui-ga-raw/host-ga.tsx +0 -1
- package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +7 -29
- package/src/tui-raw/tui/sidebar-frame.tsx +7 -29
- package/src/tui-raw/tui.tsx +1 -1
- package/src/tui.tsx +1 -1
package/dist/server.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();
|
|
@@ -12494,8 +12494,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12494
12494
|
let releaseConfirmed = false;
|
|
12495
12495
|
let loss;
|
|
12496
12496
|
let resolveLoss;
|
|
12497
|
-
const lostPromise = new Promise((
|
|
12498
|
-
resolveLoss =
|
|
12497
|
+
const lostPromise = new Promise((resolve27) => {
|
|
12498
|
+
resolveLoss = resolve27;
|
|
12499
12499
|
});
|
|
12500
12500
|
function notifyTimerStep(event) {
|
|
12501
12501
|
try {
|
|
@@ -12656,7 +12656,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12656
12656
|
}
|
|
12657
12657
|
}
|
|
12658
12658
|
async function backoff() {
|
|
12659
|
-
await new Promise((
|
|
12659
|
+
await new Promise((resolve27) => setTimeout(resolve27, Math.floor(Math.random() * 4)));
|
|
12660
12660
|
}
|
|
12661
12661
|
async function readLockState(notifyReady = true) {
|
|
12662
12662
|
if (notifyReady && options.onStep)
|
|
@@ -13094,7 +13094,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13094
13094
|
...typeof observed?.expiresAt === "number" ? { observedExpiresAt: observed.expiresAt } : {}
|
|
13095
13095
|
});
|
|
13096
13096
|
},
|
|
13097
|
-
release: async () => {
|
|
13097
|
+
release: async (signal) => {
|
|
13098
13098
|
if (windowsPrivateFiles && releaseConfirmed)
|
|
13099
13099
|
return;
|
|
13100
13100
|
released = true;
|
|
@@ -13135,6 +13135,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13135
13135
|
releaseConfirmed = removalConfirmed;
|
|
13136
13136
|
return;
|
|
13137
13137
|
}
|
|
13138
|
+
if (signal?.aborted)
|
|
13139
|
+
return;
|
|
13138
13140
|
await recoverStaleEvictionMarker();
|
|
13139
13141
|
} catch (error) {
|
|
13140
13142
|
if (windowsPrivateFiles)
|
|
@@ -13144,7 +13146,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13144
13146
|
const remainingMs = deadline - performance.now();
|
|
13145
13147
|
if (remainingMs <= 0)
|
|
13146
13148
|
break;
|
|
13147
|
-
await new Promise((
|
|
13149
|
+
await new Promise((resolve27) => setTimeout(resolve27, Math.min(delayMs, remainingMs)));
|
|
13148
13150
|
delayMs = Math.min(delayMs * 2, 50);
|
|
13149
13151
|
}
|
|
13150
13152
|
if (windowsPrivateFiles)
|
|
@@ -13187,7 +13189,7 @@ async function withLock(target, options, fn) {
|
|
|
13187
13189
|
options.signal?.throwIfAborted();
|
|
13188
13190
|
return await fn(lock);
|
|
13189
13191
|
} finally {
|
|
13190
|
-
await lock.release();
|
|
13192
|
+
await lock.release(options.signal);
|
|
13191
13193
|
}
|
|
13192
13194
|
}
|
|
13193
13195
|
const remaining = options.timeoutMs - (performance.now() - started);
|
|
@@ -13198,7 +13200,7 @@ async function withLock(target, options, fn) {
|
|
|
13198
13200
|
timeoutMs: options.timeoutMs
|
|
13199
13201
|
});
|
|
13200
13202
|
}
|
|
13201
|
-
await new Promise((
|
|
13203
|
+
await new Promise((resolve27) => setTimeout(resolve27, Math.min(25, Math.ceil(remaining))));
|
|
13202
13204
|
}
|
|
13203
13205
|
}
|
|
13204
13206
|
var LockContentionError, LockOwnershipError;
|
|
@@ -13317,7 +13319,7 @@ async function acquirePoolLock(spec, defaults, env3) {
|
|
|
13317
13319
|
});
|
|
13318
13320
|
}
|
|
13319
13321
|
const jitter = Math.floor(Math.random() * (options.retryMs + 1));
|
|
13320
|
-
await new Promise((
|
|
13322
|
+
await new Promise((resolve27) => setTimeout(resolve27, Math.min(options.retryMs + jitter, remaining)));
|
|
13321
13323
|
}
|
|
13322
13324
|
}
|
|
13323
13325
|
function definedOnly(spec) {
|
|
@@ -16588,11 +16590,11 @@ var init_quota_writer = __esm({
|
|
|
16588
16590
|
const left = deadline - performance.now();
|
|
16589
16591
|
if (left <= 0)
|
|
16590
16592
|
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);
|
|
16591
|
-
await new Promise((
|
|
16593
|
+
await new Promise((resolve27) => {
|
|
16592
16594
|
const done = () => {
|
|
16593
16595
|
clearTimeout(timer);
|
|
16594
16596
|
this.wake.delete(done);
|
|
16595
|
-
|
|
16597
|
+
resolve27();
|
|
16596
16598
|
};
|
|
16597
16599
|
const timer = setTimeout(done, left);
|
|
16598
16600
|
this.wake.add(done);
|
|
@@ -19363,7 +19365,7 @@ async function select(terminal, items, options) {
|
|
|
19363
19365
|
writeLine("");
|
|
19364
19366
|
renderedLines = lines;
|
|
19365
19367
|
};
|
|
19366
|
-
return new Promise((
|
|
19368
|
+
return new Promise((resolve27) => {
|
|
19367
19369
|
const wasRaw = stdin.isRaw ?? false;
|
|
19368
19370
|
const cleanup2 = () => {
|
|
19369
19371
|
if (cleaned)
|
|
@@ -19383,7 +19385,7 @@ async function select(terminal, items, options) {
|
|
|
19383
19385
|
};
|
|
19384
19386
|
const finish = (value) => {
|
|
19385
19387
|
cleanup2();
|
|
19386
|
-
|
|
19388
|
+
resolve27(value);
|
|
19387
19389
|
};
|
|
19388
19390
|
const onSignal = () => finish(null);
|
|
19389
19391
|
const onKey = (data) => {
|
|
@@ -19423,7 +19425,7 @@ async function select(terminal, items, options) {
|
|
|
19423
19425
|
stdin.setRawMode(true);
|
|
19424
19426
|
} catch {
|
|
19425
19427
|
cleanup2();
|
|
19426
|
-
|
|
19428
|
+
resolve27(null);
|
|
19427
19429
|
return;
|
|
19428
19430
|
}
|
|
19429
19431
|
stdin.resume();
|
|
@@ -21469,10 +21471,10 @@ async function drainShutdown(pending, onTimeout) {
|
|
|
21469
21471
|
try {
|
|
21470
21472
|
await Promise.race([
|
|
21471
21473
|
drained,
|
|
21472
|
-
new Promise((
|
|
21474
|
+
new Promise((resolve27) => {
|
|
21473
21475
|
timer = setTimeout(() => {
|
|
21474
21476
|
expired = true;
|
|
21475
|
-
|
|
21477
|
+
resolve27();
|
|
21476
21478
|
}, 2e3);
|
|
21477
21479
|
})
|
|
21478
21480
|
]);
|
|
@@ -21546,15 +21548,27 @@ function credentialTypeOf(row, family) {
|
|
|
21546
21548
|
return notMine;
|
|
21547
21549
|
if (!row.categories.includes(family.category))
|
|
21548
21550
|
return notMine;
|
|
21549
|
-
if (row.credentialType !== "oauth" && row.credentialType !== "api_key")
|
|
21550
|
-
return notMine;
|
|
21551
21551
|
if ("classify" in family) {
|
|
21552
|
+
const metadata = rowFactsOf(row);
|
|
21553
|
+
let type;
|
|
21554
|
+
switch (metadata.authMethod) {
|
|
21555
|
+
case "apikey":
|
|
21556
|
+
type = "api_key";
|
|
21557
|
+
break;
|
|
21558
|
+
case "chatgpt":
|
|
21559
|
+
case "antigravity":
|
|
21560
|
+
case "oauth":
|
|
21561
|
+
type = "oauth";
|
|
21562
|
+
break;
|
|
21563
|
+
default:
|
|
21564
|
+
return { kind: "refused", code: "unknown-auth-method" };
|
|
21565
|
+
}
|
|
21552
21566
|
const facts = {
|
|
21553
21567
|
credentialId: row.id,
|
|
21554
|
-
credentialType:
|
|
21568
|
+
credentialType: type,
|
|
21555
21569
|
categories: row.categories,
|
|
21556
21570
|
refreshAdapter: row.refreshAdapter,
|
|
21557
|
-
...
|
|
21571
|
+
...metadata
|
|
21558
21572
|
};
|
|
21559
21573
|
if (facts.providerIds === void 0)
|
|
21560
21574
|
return { kind: "refused", code: "unmapped" };
|
|
@@ -21563,13 +21577,15 @@ function credentialTypeOf(row, family) {
|
|
|
21563
21577
|
if (result.kind === "not-mine")
|
|
21564
21578
|
return notMine;
|
|
21565
21579
|
if (result.kind === "mine" && typeof result.member === "string")
|
|
21566
|
-
return { kind: "mine", type
|
|
21580
|
+
return { kind: "mine", type, member: result.member };
|
|
21567
21581
|
if (result.kind === "refused" && typeof result.code === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(result.code) && !result.code.includes("\n") && family.refusalCodes.includes(result.code))
|
|
21568
21582
|
return { kind: "refused", code: result.code };
|
|
21569
21583
|
} catch {
|
|
21570
21584
|
}
|
|
21571
21585
|
return { kind: "refused", code: "unclassified" };
|
|
21572
21586
|
}
|
|
21587
|
+
if (row.credentialType !== "oauth" && row.credentialType !== "api_key")
|
|
21588
|
+
return notMine;
|
|
21573
21589
|
if (row.credentialType === "oauth")
|
|
21574
21590
|
return row.refreshAdapter === family.refreshAdapter ? { kind: "mine", type: "oauth" } : notMine;
|
|
21575
21591
|
if (row.credentialType === "api_key" && family.apiKeys)
|
|
@@ -22716,7 +22732,7 @@ async function refreshVaultRoster(options) {
|
|
|
22716
22732
|
pendingDiscoveries.set(key, discovered);
|
|
22717
22733
|
throw error;
|
|
22718
22734
|
} finally {
|
|
22719
|
-
await lease.release();
|
|
22735
|
+
await lease.release(options.signal);
|
|
22720
22736
|
}
|
|
22721
22737
|
}
|
|
22722
22738
|
function resolveVaultPrimary(input2) {
|
|
@@ -23069,7 +23085,7 @@ var init_consumer = __esm({
|
|
|
23069
23085
|
this.#shutdown.signal,
|
|
23070
23086
|
...signal ? [signal] : []
|
|
23071
23087
|
]);
|
|
23072
|
-
return new Promise((
|
|
23088
|
+
return new Promise((resolve27, reject) => {
|
|
23073
23089
|
const cleanup2 = () => {
|
|
23074
23090
|
combined.signal.removeEventListener("abort", abort);
|
|
23075
23091
|
combined.dispose();
|
|
@@ -23084,7 +23100,7 @@ var init_consumer = __esm({
|
|
|
23084
23100
|
if (combined.signal.aborted)
|
|
23085
23101
|
reject(combined.signal.reason);
|
|
23086
23102
|
else
|
|
23087
|
-
|
|
23103
|
+
resolve27(value);
|
|
23088
23104
|
}, (error) => {
|
|
23089
23105
|
cleanup2();
|
|
23090
23106
|
reject(error);
|
|
@@ -23258,8 +23274,16 @@ var init_consumer = __esm({
|
|
|
23258
23274
|
this.#refreshing = void 0;
|
|
23259
23275
|
});
|
|
23260
23276
|
this.#track(this.#refreshing);
|
|
23277
|
+
this.#notifyDiscovery(this.#refreshing);
|
|
23261
23278
|
return this.#refreshing;
|
|
23262
23279
|
}
|
|
23280
|
+
#notifyDiscovery(promise) {
|
|
23281
|
+
try {
|
|
23282
|
+
this.#options.onDiscovery?.(promise);
|
|
23283
|
+
} catch (error) {
|
|
23284
|
+
this.#options.onError?.(error);
|
|
23285
|
+
}
|
|
23286
|
+
}
|
|
23263
23287
|
/**
|
|
23264
23288
|
* Poll in the background and open the vault and insula watches. Until the
|
|
23265
23289
|
* vault watch is accepted, and whenever it is unavailable, every tick lists
|
|
@@ -23489,6 +23513,13 @@ var init_consumer = __esm({
|
|
|
23489
23513
|
/** The hub's handle on this member's memory. */
|
|
23490
23514
|
#hubHooks() {
|
|
23491
23515
|
return {
|
|
23516
|
+
discovery: (promise) => {
|
|
23517
|
+
const hub = this.#hub;
|
|
23518
|
+
if (!hub || !this.#options.onDiscovery || this.#shutdown.signal.aborted)
|
|
23519
|
+
return;
|
|
23520
|
+
const discovery = this.#track(promise.then((outcome) => this.#hubOutcome(hub, outcome)));
|
|
23521
|
+
this.#notifyDiscovery(discovery);
|
|
23522
|
+
},
|
|
23492
23523
|
install: (roster) => {
|
|
23493
23524
|
if (this.#shutdown.signal.aborted)
|
|
23494
23525
|
return;
|
|
@@ -23523,6 +23554,9 @@ var init_consumer = __esm({
|
|
|
23523
23554
|
*/
|
|
23524
23555
|
async #hubRefresh(hub) {
|
|
23525
23556
|
const outcome = await hub.refresh();
|
|
23557
|
+
return this.#hubOutcome(hub, outcome);
|
|
23558
|
+
}
|
|
23559
|
+
#hubOutcome(hub, outcome) {
|
|
23526
23560
|
this.#assertOpen();
|
|
23527
23561
|
if (!outcome)
|
|
23528
23562
|
return void 0;
|
|
@@ -23677,6 +23711,8 @@ var init_consumer = __esm({
|
|
|
23677
23711
|
this.#assertOpen();
|
|
23678
23712
|
await declineVaultRoute(this.#options.rosterPath, routeId);
|
|
23679
23713
|
this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
23714
|
+
if (this.#roster)
|
|
23715
|
+
this.#hub?.publishRoster(this.#roster);
|
|
23680
23716
|
if (this.#hub)
|
|
23681
23717
|
this.#hub.retainUnion();
|
|
23682
23718
|
else
|
|
@@ -23686,6 +23722,8 @@ var init_consumer = __esm({
|
|
|
23686
23722
|
this.#assertOpen();
|
|
23687
23723
|
await acceptVaultRoute(this.#options.rosterPath, routeId);
|
|
23688
23724
|
this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
23725
|
+
if (this.#roster)
|
|
23726
|
+
this.#hub?.publishRoster(this.#roster);
|
|
23689
23727
|
}
|
|
23690
23728
|
/**
|
|
23691
23729
|
* Set the order vault accounts are tried in (`reorderVaultRoster`), then
|
|
@@ -23696,6 +23734,8 @@ var init_consumer = __esm({
|
|
|
23696
23734
|
this.#assertOpen();
|
|
23697
23735
|
const result = await reorderVaultRoster(this.#options.rosterPath, routeIds);
|
|
23698
23736
|
this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
23737
|
+
if (this.#roster)
|
|
23738
|
+
this.#hub?.publishRoster(this.#roster);
|
|
23699
23739
|
return result;
|
|
23700
23740
|
}
|
|
23701
23741
|
/**
|
|
@@ -23773,7 +23813,7 @@ var init_consumer = __esm({
|
|
|
23773
23813
|
// ../core/dist/common-auth-embedded/claustrum/hub.js
|
|
23774
23814
|
import { createHash as createHash8 } from "node:crypto";
|
|
23775
23815
|
import { readdir, stat as stat6 } from "node:fs/promises";
|
|
23776
|
-
import { dirname as dirname10, join as join7 } from "node:path";
|
|
23816
|
+
import { dirname as dirname10, join as join7, resolve as resolve9 } from "node:path";
|
|
23777
23817
|
function canonicalJson3(value, path5 = /* @__PURE__ */ new Set()) {
|
|
23778
23818
|
if (value === null)
|
|
23779
23819
|
return "null";
|
|
@@ -23834,12 +23874,12 @@ function unreachableConnect2() {
|
|
|
23834
23874
|
return new ClaustrumUnreachableError();
|
|
23835
23875
|
}
|
|
23836
23876
|
function untilAborted(pending, signal) {
|
|
23837
|
-
return new Promise((
|
|
23877
|
+
return new Promise((resolve27, reject) => {
|
|
23838
23878
|
const abort = () => reject(signal.reason);
|
|
23839
23879
|
signal.addEventListener("abort", abort, { once: true });
|
|
23840
23880
|
pending.then((value) => {
|
|
23841
23881
|
signal.removeEventListener("abort", abort);
|
|
23842
|
-
|
|
23882
|
+
resolve27(value);
|
|
23843
23883
|
}, (error) => {
|
|
23844
23884
|
signal.removeEventListener("abort", abort);
|
|
23845
23885
|
reject(error);
|
|
@@ -23851,7 +23891,7 @@ function untilAborted(pending, signal) {
|
|
|
23851
23891
|
function enabledRows(roster) {
|
|
23852
23892
|
return JSON.stringify((roster?.rows ?? []).map((row) => [row.credentialId, row.enabled]));
|
|
23853
23893
|
}
|
|
23854
|
-
var FILE_ID, WINDOWS_DEVICE, FINGERPRINT, PENDING_EVERY_TICK, ClaustrumDiscoveryHub;
|
|
23894
|
+
var sharedRosters, FILE_ID, WINDOWS_DEVICE, FINGERPRINT, PENDING_EVERY_TICK, ClaustrumDiscoveryHub;
|
|
23855
23895
|
var init_hub = __esm({
|
|
23856
23896
|
"../core/dist/common-auth-embedded/claustrum/hub.js"() {
|
|
23857
23897
|
"use strict";
|
|
@@ -23865,6 +23905,7 @@ var init_hub = __esm({
|
|
|
23865
23905
|
init_roster();
|
|
23866
23906
|
init_shutdown();
|
|
23867
23907
|
init_watch();
|
|
23908
|
+
sharedRosters = /* @__PURE__ */ new Map();
|
|
23868
23909
|
FILE_ID = /^[a-z0-9][a-z0-9._-]{0,63}$/;
|
|
23869
23910
|
WINDOWS_DEVICE = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\.|$)/;
|
|
23870
23911
|
FINGERPRINT = /^[0-9a-f]{16}$/;
|
|
@@ -23971,9 +24012,11 @@ var init_hub = __esm({
|
|
|
23971
24012
|
watchMode: () => this.watchState(),
|
|
23972
24013
|
keptReceiptState: () => this.keptReceiptState(),
|
|
23973
24014
|
retainUnion: () => this.#retainUnion(),
|
|
24015
|
+
publishRoster: (roster) => this.#publishRoster(entry, roster),
|
|
23974
24016
|
forget: (credentialId) => this.#current?.custody?.forget(credentialId),
|
|
23975
24017
|
detach: () => {
|
|
23976
24018
|
entry.closed = true;
|
|
24019
|
+
entry.releaseRoster?.();
|
|
23977
24020
|
}
|
|
23978
24021
|
};
|
|
23979
24022
|
const consumerOptions = {
|
|
@@ -23986,14 +24029,51 @@ var init_hub = __esm({
|
|
|
23986
24029
|
},
|
|
23987
24030
|
...this.#options.mapAccount && { mapAccount: this.#options.mapAccount },
|
|
23988
24031
|
...options.onRoster && { onRoster: options.onRoster },
|
|
24032
|
+
...options.onDiscovery && { onDiscovery: options.onDiscovery },
|
|
23989
24033
|
...options.onError && { onError: options.onError },
|
|
23990
24034
|
logger: options.logger ?? this.#logger,
|
|
23991
24035
|
...this.#options.now && { now: this.#options.now }
|
|
23992
24036
|
};
|
|
23993
24037
|
const { consumer, hooks } = createHubMember(port, consumerOptions);
|
|
23994
24038
|
entry.hooks = hooks;
|
|
24039
|
+
const path5 = resolve9(entry.path);
|
|
24040
|
+
const subscribers = sharedRosters.get(path5) ?? /* @__PURE__ */ new Set();
|
|
24041
|
+
const install = (roster) => {
|
|
24042
|
+
if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
|
|
24043
|
+
return;
|
|
24044
|
+
entry.seen = JSON.stringify(decodedVaultRoster(roster));
|
|
24045
|
+
hooks.install(roster);
|
|
24046
|
+
if (roster.view !== this.#committed?.view)
|
|
24047
|
+
entry.pending ??= { failures: 0, wait: 0 };
|
|
24048
|
+
this.#retainUnion();
|
|
24049
|
+
};
|
|
24050
|
+
subscribers.add(install);
|
|
24051
|
+
entry.receiveRoster = install;
|
|
24052
|
+
sharedRosters.set(path5, subscribers);
|
|
24053
|
+
let subscribed = true;
|
|
24054
|
+
entry.releaseRoster = () => {
|
|
24055
|
+
if (!subscribed)
|
|
24056
|
+
return;
|
|
24057
|
+
subscribed = false;
|
|
24058
|
+
subscribers.delete(install);
|
|
24059
|
+
if (!subscribers.size)
|
|
24060
|
+
sharedRosters.delete(path5);
|
|
24061
|
+
};
|
|
23995
24062
|
return consumer;
|
|
23996
24063
|
}
|
|
24064
|
+
#publishRoster(entry, roster) {
|
|
24065
|
+
const generation = this.#current;
|
|
24066
|
+
if (entry.closed || !generation || !this.#live(generation))
|
|
24067
|
+
return;
|
|
24068
|
+
entry.seen = JSON.stringify(decodedVaultRoster(roster));
|
|
24069
|
+
entry.hooks?.install(roster);
|
|
24070
|
+
for (const install of sharedRosters.get(resolve9(entry.path)) ?? []) {
|
|
24071
|
+
if (!this.#live(generation))
|
|
24072
|
+
return;
|
|
24073
|
+
if (install !== entry.receiveRoster)
|
|
24074
|
+
install(roster);
|
|
24075
|
+
}
|
|
24076
|
+
}
|
|
23997
24077
|
// --- leases ---
|
|
23998
24078
|
#startGeneration() {
|
|
23999
24079
|
const generation = {
|
|
@@ -24289,6 +24369,8 @@ var init_hub = __esm({
|
|
|
24289
24369
|
}));
|
|
24290
24370
|
run.promise = promise;
|
|
24291
24371
|
this.#run = run;
|
|
24372
|
+
for (const entry of this.#open())
|
|
24373
|
+
entry.hooks?.discovery(promise);
|
|
24292
24374
|
return promise;
|
|
24293
24375
|
}
|
|
24294
24376
|
/**
|
|
@@ -24365,9 +24447,7 @@ var init_hub = __esm({
|
|
|
24365
24447
|
this.#markPending(entry);
|
|
24366
24448
|
continue;
|
|
24367
24449
|
}
|
|
24368
|
-
entry
|
|
24369
|
-
if (!entry.closed)
|
|
24370
|
-
hooks.install(roster);
|
|
24450
|
+
this.#publishRoster(entry, roster);
|
|
24371
24451
|
}
|
|
24372
24452
|
if (!this.#live(generation))
|
|
24373
24453
|
return void 0;
|
|
@@ -24522,7 +24602,7 @@ var init_hub = __esm({
|
|
|
24522
24602
|
}
|
|
24523
24603
|
const before = enabledRows(memory);
|
|
24524
24604
|
entry.seen = content;
|
|
24525
|
-
|
|
24605
|
+
this.#publishRoster(entry, file);
|
|
24526
24606
|
if (enabledRows(hooks.roster()) !== before)
|
|
24527
24607
|
this.#retainUnion();
|
|
24528
24608
|
}
|
|
@@ -24679,6 +24759,8 @@ var init_hub = __esm({
|
|
|
24679
24759
|
if (this.#shutdown.signal.aborted)
|
|
24680
24760
|
return;
|
|
24681
24761
|
this.#shutdown.abort(closed("Claustrum discovery hub is closed"));
|
|
24762
|
+
for (const entry of this.#members.values())
|
|
24763
|
+
entry.releaseRoster?.();
|
|
24682
24764
|
if (this.#timer)
|
|
24683
24765
|
(this.#options.clearTimeoutImpl ?? clearTimeout)(this.#timer);
|
|
24684
24766
|
this.#timer = void 0;
|
|
@@ -25013,7 +25095,7 @@ var init_lock = __esm({
|
|
|
25013
25095
|
import { createHash as createHash9 } from "node:crypto";
|
|
25014
25096
|
import { constants as constants2 } from "node:fs";
|
|
25015
25097
|
import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
|
|
25016
|
-
import { dirname as dirname11, resolve as
|
|
25098
|
+
import { dirname as dirname11, resolve as resolve10 } from "node:path";
|
|
25017
25099
|
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
25018
25100
|
function rootSpans(text2) {
|
|
25019
25101
|
let i = text2.indexOf("{") + 1;
|
|
@@ -25214,8 +25296,8 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
25214
25296
|
if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
|
|
25215
25297
|
throw new PiSlotError("invalid-options");
|
|
25216
25298
|
}
|
|
25217
|
-
const authPath =
|
|
25218
|
-
const stashPath =
|
|
25299
|
+
const authPath = resolve10(options.authPath);
|
|
25300
|
+
const stashPath = resolve10(options.stashPath);
|
|
25219
25301
|
if (authPath === stashPath || stashPath === `${authPath}.lock`) {
|
|
25220
25302
|
throw new PiSlotError("invalid-options");
|
|
25221
25303
|
}
|
|
@@ -25838,8 +25920,8 @@ function getDefaultTierId(allowedTiers) {
|
|
|
25838
25920
|
return allowedTiers[0]?.id;
|
|
25839
25921
|
}
|
|
25840
25922
|
function wait(ms) {
|
|
25841
|
-
return new Promise((
|
|
25842
|
-
setTimeout(
|
|
25923
|
+
return new Promise((resolve27) => {
|
|
25924
|
+
setTimeout(resolve27, ms);
|
|
25843
25925
|
});
|
|
25844
25926
|
}
|
|
25845
25927
|
function extractManagedProjectId(payload) {
|
|
@@ -28161,12 +28243,12 @@ var init_vault_provider_state = __esm({
|
|
|
28161
28243
|
function untilAborted2(pending, signal) {
|
|
28162
28244
|
if (!signal)
|
|
28163
28245
|
return pending;
|
|
28164
|
-
return new Promise((
|
|
28246
|
+
return new Promise((resolve27, reject) => {
|
|
28165
28247
|
const abort = () => reject(signal.reason);
|
|
28166
28248
|
signal.addEventListener("abort", abort, { once: true });
|
|
28167
28249
|
if (signal.aborted)
|
|
28168
28250
|
abort();
|
|
28169
|
-
pending.then(
|
|
28251
|
+
pending.then(resolve27, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
28170
28252
|
});
|
|
28171
28253
|
}
|
|
28172
28254
|
async function resolveClaustrumConnectionPath(explicit) {
|
|
@@ -28640,7 +28722,7 @@ var init_capture_sink2 = __esm({
|
|
|
28640
28722
|
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
28641
28723
|
import { lstat as lstat6, readFile as readFile8, rename as rename8, unlink as unlink8 } from "node:fs/promises";
|
|
28642
28724
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
28643
|
-
import { dirname as dirname13, join as join9, resolve as
|
|
28725
|
+
import { dirname as dirname13, join as join9, resolve as resolve11 } from "node:path";
|
|
28644
28726
|
function ioCode2(detail) {
|
|
28645
28727
|
if (detail?.reason === "io-error") {
|
|
28646
28728
|
if (detail.win32Code === 2 || detail.win32Code === 3)
|
|
@@ -28687,7 +28769,7 @@ async function privateOperation2(path5, stage, operation) {
|
|
|
28687
28769
|
}
|
|
28688
28770
|
}
|
|
28689
28771
|
async function verifySafeDirectory2(path5, options) {
|
|
28690
|
-
path5 =
|
|
28772
|
+
path5 = resolve11(path5);
|
|
28691
28773
|
options ??= safeParentOptionsForTest2;
|
|
28692
28774
|
await privateOperation2(path5, "safe-parent", async () => {
|
|
28693
28775
|
const result = await (await loadBackend2()).verifySafeParent(path5, options);
|
|
@@ -28702,7 +28784,7 @@ async function verifySafeDirectory2(path5, options) {
|
|
|
28702
28784
|
});
|
|
28703
28785
|
}
|
|
28704
28786
|
async function verifyPrivate2(path5, kind, migrate = false) {
|
|
28705
|
-
path5 =
|
|
28787
|
+
path5 = resolve11(path5);
|
|
28706
28788
|
if (kind === "directory")
|
|
28707
28789
|
return verifySafeDirectory2(path5);
|
|
28708
28790
|
await privateOperation2(path5, "verify", async () => {
|
|
@@ -28737,7 +28819,7 @@ async function verifyPrivate2(path5, kind, migrate = false) {
|
|
|
28737
28819
|
});
|
|
28738
28820
|
}
|
|
28739
28821
|
async function ensurePrivateDirectory2(path5, _migrate = false, options) {
|
|
28740
|
-
path5 =
|
|
28822
|
+
path5 = resolve11(path5);
|
|
28741
28823
|
await privateOperation2(path5, "directory", async () => {
|
|
28742
28824
|
const api = await loadBackend2();
|
|
28743
28825
|
try {
|
|
@@ -28768,7 +28850,7 @@ async function readPrivateText2(path5, migrate = false) {
|
|
|
28768
28850
|
async function readPrivateBuffer2(path5, migrate = false) {
|
|
28769
28851
|
if (!windowsPrivateFiles2)
|
|
28770
28852
|
return readFile8(path5);
|
|
28771
|
-
path5 =
|
|
28853
|
+
path5 = resolve11(path5);
|
|
28772
28854
|
if (migrate) {
|
|
28773
28855
|
await verifySafeDirectory2(dirname13(path5));
|
|
28774
28856
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -28776,20 +28858,20 @@ async function readPrivateBuffer2(path5, migrate = false) {
|
|
|
28776
28858
|
return privateOperation2(path5, "read", async () => (await loadBackend2()).readOwnerOnly(path5));
|
|
28777
28859
|
}
|
|
28778
28860
|
async function createPrivateBytes2(path5, bytes) {
|
|
28779
|
-
await verifySafeDirectory2(dirname13(
|
|
28861
|
+
await verifySafeDirectory2(dirname13(resolve11(path5)));
|
|
28780
28862
|
await privateOperation2(path5, "create", async () => {
|
|
28781
|
-
await (await loadBackend2()).createPrivateFile(
|
|
28863
|
+
await (await loadBackend2()).createPrivateFile(resolve11(path5), bytes);
|
|
28782
28864
|
});
|
|
28783
28865
|
}
|
|
28784
28866
|
async function createPrivateDirectoryExclusive2(path5) {
|
|
28785
|
-
await verifySafeDirectory2(dirname13(
|
|
28867
|
+
await verifySafeDirectory2(dirname13(resolve11(path5)));
|
|
28786
28868
|
await privateOperation2(path5, "directory-create", async () => {
|
|
28787
|
-
await (await loadBackend2()).createOwnerOnly(
|
|
28869
|
+
await (await loadBackend2()).createOwnerOnly(resolve11(path5), { kind: "dir" });
|
|
28788
28870
|
});
|
|
28789
28871
|
}
|
|
28790
28872
|
async function replaceWindowsFile2(from, to, options = {}) {
|
|
28791
|
-
from =
|
|
28792
|
-
to =
|
|
28873
|
+
from = resolve11(from);
|
|
28874
|
+
to = resolve11(to);
|
|
28793
28875
|
const now = options.now ?? (() => performance.now());
|
|
28794
28876
|
const start = now();
|
|
28795
28877
|
const leaseDeadline = options.deadline ?? Infinity;
|
|
@@ -28832,7 +28914,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
|
|
|
28832
28914
|
throw error;
|
|
28833
28915
|
}
|
|
28834
28916
|
async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
28835
|
-
path5 =
|
|
28917
|
+
path5 = resolve11(path5);
|
|
28836
28918
|
await ensurePrivateDirectory2(dirname13(path5));
|
|
28837
28919
|
try {
|
|
28838
28920
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -28840,7 +28922,7 @@ async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
|
28840
28922
|
if (error.code !== "ENOENT")
|
|
28841
28923
|
throw error;
|
|
28842
28924
|
}
|
|
28843
|
-
const stage =
|
|
28925
|
+
const stage = resolve11(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
|
|
28844
28926
|
if (dirname13(stage) !== dirname13(path5))
|
|
28845
28927
|
throw new PrivateFileError2(path5, "stage-directory", { code: "EXDEV" });
|
|
28846
28928
|
let created = false;
|
|
@@ -29006,7 +29088,7 @@ var init_redact2 = __esm({
|
|
|
29006
29088
|
// src/common-auth-embedded/logger/engine.js
|
|
29007
29089
|
import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
|
|
29008
29090
|
import { open as open8 } from "node:fs/promises";
|
|
29009
|
-
import { dirname as dirname14, resolve as
|
|
29091
|
+
import { dirname as dirname14, resolve as resolve12 } from "node:path";
|
|
29010
29092
|
function chmodPrivate2(path5) {
|
|
29011
29093
|
try {
|
|
29012
29094
|
chmodSync2(path5, 384);
|
|
@@ -29057,7 +29139,7 @@ async function openWindowsFile2(sink, file) {
|
|
|
29057
29139
|
return sink.handle;
|
|
29058
29140
|
}
|
|
29059
29141
|
async function flushWindowsFile2(sink, file, text2) {
|
|
29060
|
-
file =
|
|
29142
|
+
file = resolve12(file);
|
|
29061
29143
|
try {
|
|
29062
29144
|
if (sink.file !== file)
|
|
29063
29145
|
await closeWindowsFile2(sink);
|
|
@@ -30116,11 +30198,11 @@ function createOpenCodeVaultCustody(options) {
|
|
|
30116
30198
|
].join("\n");
|
|
30117
30199
|
const waitForApproval = async () => {
|
|
30118
30200
|
while (!closed2) {
|
|
30119
|
-
await new Promise((
|
|
30201
|
+
await new Promise((resolve27) => {
|
|
30120
30202
|
const done = () => {
|
|
30121
30203
|
clearTimeout(timer);
|
|
30122
30204
|
cancelWait = void 0;
|
|
30123
|
-
|
|
30205
|
+
resolve27();
|
|
30124
30206
|
};
|
|
30125
30207
|
const timer = setTimeout(done, 2e3);
|
|
30126
30208
|
timer.unref?.();
|
|
@@ -30507,7 +30589,7 @@ import { randomUUID as randomUUID14 } from "node:crypto";
|
|
|
30507
30589
|
import { realpathSync, rmSync } from "node:fs";
|
|
30508
30590
|
import { chmod as chmod4, mkdir as mkdir12, readFile as readFile10, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
|
|
30509
30591
|
import { homedir as homedir2 } from "node:os";
|
|
30510
|
-
import { join as join11, resolve as
|
|
30592
|
+
import { join as join11, resolve as resolve13 } from "node:path";
|
|
30511
30593
|
function processHeartbeatDir() {
|
|
30512
30594
|
const base = process.env.XDG_STATE_HOME || join11(homedir2(), ".local", "state");
|
|
30513
30595
|
return join11(base, "cortexkit", "antigravity-auth", "processes");
|
|
@@ -30520,7 +30602,7 @@ function processConfigFolderKey() {
|
|
|
30520
30602
|
try {
|
|
30521
30603
|
return realpathSync.native(folder);
|
|
30522
30604
|
} catch {
|
|
30523
|
-
return
|
|
30605
|
+
return resolve13(folder);
|
|
30524
30606
|
}
|
|
30525
30607
|
}
|
|
30526
30608
|
function processHasOlderGeneration() {
|
|
@@ -30966,7 +31048,7 @@ import {
|
|
|
30966
31048
|
stat as stat9,
|
|
30967
31049
|
unlink as unlink9
|
|
30968
31050
|
} from "node:fs/promises";
|
|
30969
|
-
import { basename as basename4, dirname as dirname15, join as join13, resolve as
|
|
31051
|
+
import { basename as basename4, dirname as dirname15, join as join13, resolve as resolve14 } from "node:path";
|
|
30970
31052
|
function refusalMessage(stateDir, errorClass2) {
|
|
30971
31053
|
if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
|
|
30972
31054
|
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.`;
|
|
@@ -31821,7 +31903,7 @@ async function isVaultShapedKeptState(files) {
|
|
|
31821
31903
|
async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
|
|
31822
31904
|
const location = runtimeLayoutLocation();
|
|
31823
31905
|
const files = layoutFiles(location, accountFile);
|
|
31824
|
-
if (
|
|
31906
|
+
if (resolve14(vaultDir) !== resolve14(files.vault.next)) return;
|
|
31825
31907
|
const stateDir = location.stateHomeDir;
|
|
31826
31908
|
const marker = await readMarker(
|
|
31827
31909
|
join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
@@ -32249,7 +32331,7 @@ import {
|
|
|
32249
32331
|
writeFileSync
|
|
32250
32332
|
} from "node:fs";
|
|
32251
32333
|
import { homedir as homedir4 } from "node:os";
|
|
32252
|
-
import { dirname as dirname16, join as join14, resolve as
|
|
32334
|
+
import { dirname as dirname16, join as join14, resolve as resolve15 } from "node:path";
|
|
32253
32335
|
async function ensureGitignore(configDir) {
|
|
32254
32336
|
const gitignorePath = join14(configDir, ".gitignore");
|
|
32255
32337
|
try {
|
|
@@ -32349,8 +32431,8 @@ function migrateLegacyWindowsConfig() {
|
|
|
32349
32431
|
}
|
|
32350
32432
|
}
|
|
32351
32433
|
function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
32352
|
-
const standard =
|
|
32353
|
-
const legacy =
|
|
32434
|
+
const standard = resolve15(newPath);
|
|
32435
|
+
const legacy = resolve15(legacyPath);
|
|
32354
32436
|
if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
|
|
32355
32437
|
const standardPointer = existsSync3(accountStorePointerPath(standard));
|
|
32356
32438
|
const legacyPointer = existsSync3(accountStorePointerPath(legacy));
|
|
@@ -32372,7 +32454,7 @@ function getStoragePathWithMigration() {
|
|
|
32372
32454
|
"antigravity-accounts.json"
|
|
32373
32455
|
);
|
|
32374
32456
|
const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
|
|
32375
|
-
if (
|
|
32457
|
+
if (resolve15(anchored).toLowerCase() !== resolve15(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve15(anchored)))) {
|
|
32376
32458
|
log5.info("Using legacy Windows config path (migration failed)", {
|
|
32377
32459
|
legacyPath,
|
|
32378
32460
|
newPath
|
|
@@ -32389,7 +32471,7 @@ function accountFileForVault(configDir = getConfigDir()) {
|
|
|
32389
32471
|
const configured = join14(configDir, "antigravity-accounts.json");
|
|
32390
32472
|
if (process.platform !== "win32") return configured;
|
|
32391
32473
|
const legacyDir = getLegacyWindowsConfigDir();
|
|
32392
|
-
if (
|
|
32474
|
+
if (resolve15(configDir).toLowerCase() === resolve15(legacyDir).toLowerCase())
|
|
32393
32475
|
return configured;
|
|
32394
32476
|
const configuredVault = join14(configDir, "antigravity-auth-vault");
|
|
32395
32477
|
const legacyVault = join14(legacyDir, "antigravity-auth-vault");
|
|
@@ -32420,7 +32502,7 @@ function getStoragePath() {
|
|
|
32420
32502
|
}
|
|
32421
32503
|
async function assertLegacyPoolInUse(legacyPath) {
|
|
32422
32504
|
try {
|
|
32423
|
-
await assertLegacyAccountStorageWritable(
|
|
32505
|
+
await assertLegacyAccountStorageWritable(resolve15(legacyPath));
|
|
32424
32506
|
} catch (error) {
|
|
32425
32507
|
throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
|
|
32426
32508
|
}
|
|
@@ -32438,7 +32520,7 @@ function refusalMessage2(admission) {
|
|
|
32438
32520
|
async function bindingOf(options) {
|
|
32439
32521
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
32440
32522
|
const now = options.now ?? (() => Date.now());
|
|
32441
|
-
const legacyPath =
|
|
32523
|
+
const legacyPath = resolve15(options.legacyPath ?? getStoragePath());
|
|
32442
32524
|
return {
|
|
32443
32525
|
legacyPath,
|
|
32444
32526
|
now,
|
|
@@ -32507,7 +32589,7 @@ async function openAccountStore(options) {
|
|
|
32507
32589
|
async function initializeFreshAccountStoreFor(modules, options = {}) {
|
|
32508
32590
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
32509
32591
|
return initializeFreshAccountStore(modules, {
|
|
32510
|
-
legacyPath:
|
|
32592
|
+
legacyPath: resolve15(options.legacyPath ?? getStoragePath()),
|
|
32511
32593
|
now: options.now ?? (() => Date.now())
|
|
32512
32594
|
});
|
|
32513
32595
|
}
|
|
@@ -32585,12 +32667,12 @@ var init_storage = __esm({
|
|
|
32585
32667
|
import { createHash as createHash12 } from "node:crypto";
|
|
32586
32668
|
import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
32587
32669
|
import { homedir as homedir5 } from "node:os";
|
|
32588
|
-
import { dirname as dirname17, join as join15, resolve as
|
|
32670
|
+
import { dirname as dirname17, join as join15, resolve as resolve16 } from "node:path";
|
|
32589
32671
|
function configDirIdentity(path5) {
|
|
32590
32672
|
try {
|
|
32591
32673
|
return realpathSync2.native(path5);
|
|
32592
32674
|
} catch {
|
|
32593
|
-
return
|
|
32675
|
+
return resolve16(path5);
|
|
32594
32676
|
}
|
|
32595
32677
|
}
|
|
32596
32678
|
function decisionKey(location) {
|
|
@@ -33043,13 +33125,13 @@ function closeDebugStream(state) {
|
|
|
33043
33125
|
state.logWriter = () => {
|
|
33044
33126
|
};
|
|
33045
33127
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
33046
|
-
return new Promise((
|
|
33047
|
-
current.once("close", () =>
|
|
33048
|
-
current.once("error", () =>
|
|
33128
|
+
return new Promise((resolve27) => {
|
|
33129
|
+
current.once("close", () => resolve27());
|
|
33130
|
+
current.once("error", () => resolve27());
|
|
33049
33131
|
try {
|
|
33050
33132
|
current.end();
|
|
33051
33133
|
} catch {
|
|
33052
|
-
|
|
33134
|
+
resolve27();
|
|
33053
33135
|
}
|
|
33054
33136
|
});
|
|
33055
33137
|
}
|
|
@@ -33314,13 +33396,13 @@ function closeDebugLog() {
|
|
|
33314
33396
|
if (!state || !current) return Promise.resolve();
|
|
33315
33397
|
state.logStream = null;
|
|
33316
33398
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
33317
|
-
return new Promise((
|
|
33318
|
-
current.once("close", () =>
|
|
33319
|
-
current.once("error", () =>
|
|
33399
|
+
return new Promise((resolve27) => {
|
|
33400
|
+
current.once("close", () => resolve27());
|
|
33401
|
+
current.once("error", () => resolve27());
|
|
33320
33402
|
try {
|
|
33321
33403
|
current.end();
|
|
33322
33404
|
} catch {
|
|
33323
|
-
|
|
33405
|
+
resolve27();
|
|
33324
33406
|
}
|
|
33325
33407
|
});
|
|
33326
33408
|
}
|
|
@@ -34787,7 +34869,7 @@ init_runtime_paths();
|
|
|
34787
34869
|
init_logger4();
|
|
34788
34870
|
import { existsSync as existsSync5, readFileSync as readFileSync3, realpathSync as realpathSync3 } from "node:fs";
|
|
34789
34871
|
import { homedir as homedir6 } from "node:os";
|
|
34790
|
-
import { basename as basename5, dirname as dirname18, join as join17, resolve as
|
|
34872
|
+
import { basename as basename5, dirname as dirname18, join as join17, resolve as resolve17 } from "node:path";
|
|
34791
34873
|
|
|
34792
34874
|
// src/plugin/config/schema.ts
|
|
34793
34875
|
import { z } from "zod";
|
|
@@ -35109,12 +35191,12 @@ var AntigravityConfigSchema = z.object({
|
|
|
35109
35191
|
* When an account's quota usage reaches this percentage, skip it during
|
|
35110
35192
|
* account selection (same as if it were rate-limited).
|
|
35111
35193
|
*
|
|
35194
|
+
* Disabled by default (100). Set a lower threshold to opt in to a reserve.
|
|
35112
35195
|
* Example: 80 means skip account when 80% of quota is used (20% remaining).
|
|
35113
|
-
* Set to 100 to disable soft quota protection.
|
|
35114
35196
|
*
|
|
35115
|
-
* @default
|
|
35197
|
+
* @default 100
|
|
35116
35198
|
*/
|
|
35117
|
-
soft_quota_threshold_percent: z.number().min(1).max(100).default(
|
|
35199
|
+
soft_quota_threshold_percent: z.number().min(1).max(100).default(100),
|
|
35118
35200
|
/**
|
|
35119
35201
|
* How often to refresh quota data in the background (in minutes).
|
|
35120
35202
|
* Quota is refreshed opportunistically after successful API requests.
|
|
@@ -35243,7 +35325,7 @@ var DEFAULT_CONFIG = {
|
|
|
35243
35325
|
max_backoff_seconds: 60,
|
|
35244
35326
|
request_jitter_max_ms: 0,
|
|
35245
35327
|
switch_account_delay_ms: 500,
|
|
35246
|
-
soft_quota_threshold_percent:
|
|
35328
|
+
soft_quota_threshold_percent: 100,
|
|
35247
35329
|
quota_refresh_interval_minutes: 30,
|
|
35248
35330
|
soft_quota_cache_ttl_minutes: "auto",
|
|
35249
35331
|
proactive_rotation_threshold_percent: 20,
|
|
@@ -35361,7 +35443,7 @@ function createLocationConfig(directory, options) {
|
|
|
35361
35443
|
};
|
|
35362
35444
|
}
|
|
35363
35445
|
function canonicalizeOwnedPath(path5) {
|
|
35364
|
-
const absolute =
|
|
35446
|
+
const absolute = resolve17(path5);
|
|
35365
35447
|
const missing = [];
|
|
35366
35448
|
let current = absolute;
|
|
35367
35449
|
for (; ; ) {
|
|
@@ -35740,7 +35822,7 @@ function createStoreAccountLimits(input2) {
|
|
|
35740
35822
|
|
|
35741
35823
|
// src/plugin/ga-shared-vault-custody.ts
|
|
35742
35824
|
init_dist();
|
|
35743
|
-
import { resolve as
|
|
35825
|
+
import { resolve as resolve18 } from "node:path";
|
|
35744
35826
|
|
|
35745
35827
|
// src/sidebar-state.ts
|
|
35746
35828
|
init_atomic_write();
|
|
@@ -36156,7 +36238,7 @@ function drainSidebarWrites() {
|
|
|
36156
36238
|
return sidebarWriteChain;
|
|
36157
36239
|
}
|
|
36158
36240
|
async function sleep3(ms) {
|
|
36159
|
-
await new Promise((
|
|
36241
|
+
await new Promise((resolve27) => setTimeout(resolve27, ms));
|
|
36160
36242
|
}
|
|
36161
36243
|
async function acquireSidebarLockWithRetry(stateFile) {
|
|
36162
36244
|
const start = Date.now();
|
|
@@ -36715,14 +36797,14 @@ var LocalQuotaGrantStaleError = class extends Error {
|
|
|
36715
36797
|
name = "LocalQuotaGrantStaleError";
|
|
36716
36798
|
};
|
|
36717
36799
|
function untilQuotaAborted(pending, signal) {
|
|
36718
|
-
return new Promise((
|
|
36800
|
+
return new Promise((resolve27, reject) => {
|
|
36719
36801
|
const abort = () => reject(signal.reason);
|
|
36720
36802
|
if (signal.aborted) abort();
|
|
36721
36803
|
else signal.addEventListener("abort", abort, { once: true });
|
|
36722
36804
|
void pending.then(
|
|
36723
36805
|
(value) => {
|
|
36724
36806
|
signal.removeEventListener("abort", abort);
|
|
36725
|
-
|
|
36807
|
+
resolve27(value);
|
|
36726
36808
|
},
|
|
36727
36809
|
(error) => {
|
|
36728
36810
|
signal.removeEventListener("abort", abort);
|
|
@@ -37617,7 +37699,7 @@ init_vault_request_credentials();
|
|
|
37617
37699
|
init_vault_custody();
|
|
37618
37700
|
var shared3 = /* @__PURE__ */ new Map();
|
|
37619
37701
|
function acquireGaVaultCustody(options) {
|
|
37620
|
-
const key = options.layoutRefusal === void 0 ?
|
|
37702
|
+
const key = options.layoutRefusal === void 0 ? resolve18(options.vaultDir) : `unsettled\0${resolve18(options.vaultDir)}`;
|
|
37621
37703
|
let entry = shared3.get(key);
|
|
37622
37704
|
if (!entry) {
|
|
37623
37705
|
const leases = /* @__PURE__ */ new Set();
|
|
@@ -41204,8 +41286,8 @@ function createSyntheticTextResponse(text2, extraHeaders = {}) {
|
|
|
41204
41286
|
});
|
|
41205
41287
|
}
|
|
41206
41288
|
var NATIVE_GOOGLE_ERROR_MESSAGES = {
|
|
41207
|
-
operator_policy: "Antigravity account pool is unavailable under the operator quota policy. Adjust /antigravity
|
|
41208
|
-
soft_quota:
|
|
41289
|
+
operator_policy: "Antigravity account pool is unavailable under the operator quota policy. Adjust the quota floor in /antigravity \u2192 Limits or refresh quota.",
|
|
41290
|
+
soft_quota: 'Antigravity account pool is unavailable under the quota protection policy. Add accounts, wait for quota reset, or turn off soft quota protection with `"soft_quota_threshold_percent": 100` in antigravity.json.',
|
|
41209
41291
|
pool_unavailable: "Antigravity account pool has no account available within the configured wait limit. Add accounts with `opencode auth login` or wait for quota reset.",
|
|
41210
41292
|
model_unavailable: "The requested Antigravity model is not available to the configured accounts. Choose another model.",
|
|
41211
41293
|
missing_access_token: "Missing access token. Run `opencode auth login` to reauthenticate.",
|
|
@@ -43249,12 +43331,12 @@ async function startOAuthListener({
|
|
|
43249
43331
|
let resolveCallback;
|
|
43250
43332
|
let rejectCallback;
|
|
43251
43333
|
let timeoutHandle;
|
|
43252
|
-
const callbackPromise = new Promise((
|
|
43334
|
+
const callbackPromise = new Promise((resolve27, reject) => {
|
|
43253
43335
|
resolveCallback = (url) => {
|
|
43254
43336
|
if (settled) return;
|
|
43255
43337
|
settled = true;
|
|
43256
43338
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
43257
|
-
|
|
43339
|
+
resolve27(url);
|
|
43258
43340
|
};
|
|
43259
43341
|
rejectCallback = (error) => {
|
|
43260
43342
|
if (settled) return;
|
|
@@ -43413,7 +43495,7 @@ async function startOAuthListener({
|
|
|
43413
43495
|
});
|
|
43414
43496
|
});
|
|
43415
43497
|
const bindAddress = getBindAddress();
|
|
43416
|
-
await new Promise((
|
|
43498
|
+
await new Promise((resolve27, reject) => {
|
|
43417
43499
|
const handleError = (error) => {
|
|
43418
43500
|
server.off("error", handleError);
|
|
43419
43501
|
if (error.code === "EADDRINUSE") {
|
|
@@ -43429,7 +43511,7 @@ async function startOAuthListener({
|
|
|
43429
43511
|
server.once("error", handleError);
|
|
43430
43512
|
server.listen(port, bindAddress, () => {
|
|
43431
43513
|
server.off("error", handleError);
|
|
43432
|
-
|
|
43514
|
+
resolve27();
|
|
43433
43515
|
});
|
|
43434
43516
|
});
|
|
43435
43517
|
server.on("error", (error) => {
|
|
@@ -43437,7 +43519,7 @@ async function startOAuthListener({
|
|
|
43437
43519
|
});
|
|
43438
43520
|
return {
|
|
43439
43521
|
waitForCallback: () => callbackPromise,
|
|
43440
|
-
close: () => new Promise((
|
|
43522
|
+
close: () => new Promise((resolve27, reject) => {
|
|
43441
43523
|
server.close((error) => {
|
|
43442
43524
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
43443
43525
|
reject(error);
|
|
@@ -43446,7 +43528,7 @@ async function startOAuthListener({
|
|
|
43446
43528
|
if (!settled) {
|
|
43447
43529
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
43448
43530
|
}
|
|
43449
|
-
|
|
43531
|
+
resolve27();
|
|
43450
43532
|
});
|
|
43451
43533
|
})
|
|
43452
43534
|
};
|
|
@@ -43457,7 +43539,7 @@ async function startOAuthListener({
|
|
|
43457
43539
|
}
|
|
43458
43540
|
|
|
43459
43541
|
// src/plugin/session-context.ts
|
|
43460
|
-
import { resolve as
|
|
43542
|
+
import { resolve as resolve19 } from "node:path";
|
|
43461
43543
|
import { pathToFileURL } from "node:url";
|
|
43462
43544
|
var FALLBACK_SESSION_KEY = "__default__";
|
|
43463
43545
|
function extractOpenCodeSessionIdentity(headers) {
|
|
@@ -43471,7 +43553,7 @@ var AgySessionRegistry = class {
|
|
|
43471
43553
|
requestSessions;
|
|
43472
43554
|
parentSessionIds = /* @__PURE__ */ new Map();
|
|
43473
43555
|
constructor(directory, options = {}) {
|
|
43474
|
-
const workspaceUri = directory ? pathToFileURL(
|
|
43556
|
+
const workspaceUri = directory ? pathToFileURL(resolve19(directory)).href : "";
|
|
43475
43557
|
this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
|
|
43476
43558
|
}
|
|
43477
43559
|
getOrCreate(identity3) {
|
|
@@ -43608,7 +43690,7 @@ var AntigravityKillswitchError = class extends Error {
|
|
|
43608
43690
|
summaries;
|
|
43609
43691
|
constructor(input2) {
|
|
43610
43692
|
super(
|
|
43611
|
-
input2.message ?? `Antigravity killswitch: all ${input2.summaries.length} account(s) under ${input2.thresholdPercent}% quota for ${input2.family}. Refresh quota or
|
|
43693
|
+
input2.message ?? `Antigravity killswitch: all ${input2.summaries.length} account(s) under ${input2.thresholdPercent}% quota for ${input2.family}. Refresh quota or adjust the quota floor in /antigravity \u2192 Limits.`
|
|
43612
43694
|
);
|
|
43613
43695
|
this.name = "AntigravityKillswitchError";
|
|
43614
43696
|
this.family = input2.family;
|
|
@@ -44100,10 +44182,10 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
44100
44182
|
cancellation.release();
|
|
44101
44183
|
throw error;
|
|
44102
44184
|
}
|
|
44103
|
-
let
|
|
44185
|
+
let resolve27 = () => {
|
|
44104
44186
|
};
|
|
44105
44187
|
const settled = new Promise((done) => {
|
|
44106
|
-
|
|
44188
|
+
resolve27 = done;
|
|
44107
44189
|
});
|
|
44108
44190
|
let stopping = false;
|
|
44109
44191
|
let finished = false;
|
|
@@ -44113,7 +44195,7 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
44113
44195
|
finished = true;
|
|
44114
44196
|
cancellation.signal.removeEventListener("abort", abort);
|
|
44115
44197
|
cancellation.release();
|
|
44116
|
-
|
|
44198
|
+
resolve27();
|
|
44117
44199
|
};
|
|
44118
44200
|
const abort = () => {
|
|
44119
44201
|
if (finished || stopping) return;
|
|
@@ -44182,8 +44264,8 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
44182
44264
|
let running = false;
|
|
44183
44265
|
let resolveCompletion = () => {
|
|
44184
44266
|
};
|
|
44185
|
-
const completion = new Promise((
|
|
44186
|
-
resolveCompletion =
|
|
44267
|
+
const completion = new Promise((resolve27) => {
|
|
44268
|
+
resolveCompletion = resolve27;
|
|
44187
44269
|
});
|
|
44188
44270
|
const finish = () => {
|
|
44189
44271
|
if (finished) return;
|
|
@@ -44230,14 +44312,14 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
44230
44312
|
};
|
|
44231
44313
|
}
|
|
44232
44314
|
function publishResponse(dispatch) {
|
|
44233
|
-
return new Promise((
|
|
44315
|
+
return new Promise((resolve27, reject) => {
|
|
44234
44316
|
let acknowledge;
|
|
44235
44317
|
void Promise.resolve().then(
|
|
44236
44318
|
() => dispatch((callback) => {
|
|
44237
44319
|
acknowledge = callback;
|
|
44238
44320
|
})
|
|
44239
44321
|
).then((response) => {
|
|
44240
|
-
|
|
44322
|
+
resolve27(response);
|
|
44241
44323
|
acknowledge?.();
|
|
44242
44324
|
}, reject);
|
|
44243
44325
|
});
|
|
@@ -44339,7 +44421,7 @@ function formatWaitTime(ms) {
|
|
|
44339
44421
|
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
|
|
44340
44422
|
}
|
|
44341
44423
|
function sleep4(ms, signal) {
|
|
44342
|
-
return new Promise((
|
|
44424
|
+
return new Promise((resolve27, reject) => {
|
|
44343
44425
|
if (signal?.aborted) {
|
|
44344
44426
|
reject(
|
|
44345
44427
|
signal.reason instanceof Error ? signal.reason : new Error("Aborted")
|
|
@@ -44348,7 +44430,7 @@ function sleep4(ms, signal) {
|
|
|
44348
44430
|
}
|
|
44349
44431
|
const timeout = setTimeout(() => {
|
|
44350
44432
|
cleanup2();
|
|
44351
|
-
|
|
44433
|
+
resolve27();
|
|
44352
44434
|
}, ms);
|
|
44353
44435
|
const onAbort = () => {
|
|
44354
44436
|
cleanup2();
|
|
@@ -47431,7 +47513,7 @@ function createGaReauthorize(input2) {
|
|
|
47431
47513
|
const continuations = /* @__PURE__ */ new Set();
|
|
47432
47514
|
const shutdown = new AbortController();
|
|
47433
47515
|
let disposed = false;
|
|
47434
|
-
const waitForRedirect = (code2) => new Promise((
|
|
47516
|
+
const waitForRedirect = (code2) => new Promise((resolve27, reject) => {
|
|
47435
47517
|
const detach = () => shutdown.signal.removeEventListener("abort", abort);
|
|
47436
47518
|
const abort = () => {
|
|
47437
47519
|
detach();
|
|
@@ -47442,7 +47524,7 @@ function createGaReauthorize(input2) {
|
|
|
47442
47524
|
void code2.then(
|
|
47443
47525
|
(value) => {
|
|
47444
47526
|
detach();
|
|
47445
|
-
|
|
47527
|
+
resolve27(value);
|
|
47446
47528
|
},
|
|
47447
47529
|
(error) => {
|
|
47448
47530
|
detach();
|
|
@@ -50103,11 +50185,11 @@ init_dist();
|
|
|
50103
50185
|
var GA_POOL_METHOD_ID = "antigravity-auth-pool-browser";
|
|
50104
50186
|
var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
|
|
50105
50187
|
function abortable(pending, signal) {
|
|
50106
|
-
return new Promise((
|
|
50188
|
+
return new Promise((resolve27, reject) => {
|
|
50107
50189
|
const abort = () => reject(signal.reason);
|
|
50108
50190
|
if (signal.aborted) abort();
|
|
50109
50191
|
else signal.addEventListener("abort", abort, { once: true });
|
|
50110
|
-
void pending.then(
|
|
50192
|
+
void pending.then(resolve27, reject).finally(() => {
|
|
50111
50193
|
signal.removeEventListener("abort", abort);
|
|
50112
50194
|
});
|
|
50113
50195
|
});
|
|
@@ -50477,11 +50559,11 @@ async function startGaLoopbackBridge(options) {
|
|
|
50477
50559
|
}
|
|
50478
50560
|
}
|
|
50479
50561
|
};
|
|
50480
|
-
await new Promise((
|
|
50562
|
+
await new Promise((resolve27, reject) => {
|
|
50481
50563
|
server.once("error", reject);
|
|
50482
50564
|
server.listen(0, BRIDGE_HOST, () => {
|
|
50483
50565
|
server.off("error", reject);
|
|
50484
|
-
|
|
50566
|
+
resolve27();
|
|
50485
50567
|
});
|
|
50486
50568
|
});
|
|
50487
50569
|
server.unref();
|
|
@@ -50585,8 +50667,8 @@ async function startGaLoopbackBridge(options) {
|
|
|
50585
50667
|
disposal = (async () => {
|
|
50586
50668
|
for (const { timer } of queued.values()) clearTimeout(timer);
|
|
50587
50669
|
queued.clear();
|
|
50588
|
-
const closed2 = new Promise((
|
|
50589
|
-
server.close(() =>
|
|
50670
|
+
const closed2 = new Promise((resolve27) => {
|
|
50671
|
+
server.close(() => resolve27());
|
|
50590
50672
|
});
|
|
50591
50673
|
for (const controller of running) {
|
|
50592
50674
|
controller.abort(
|
|
@@ -50650,9 +50732,9 @@ async function pipeResponse(upstream, response, onFailure, onHandoff) {
|
|
|
50650
50732
|
return;
|
|
50651
50733
|
}
|
|
50652
50734
|
if (!response.write(value) && !response.destroyed) {
|
|
50653
|
-
await new Promise((
|
|
50654
|
-
response.once("drain",
|
|
50655
|
-
response.once("close",
|
|
50735
|
+
await new Promise((resolve27) => {
|
|
50736
|
+
response.once("drain", resolve27);
|
|
50737
|
+
response.once("close", resolve27);
|
|
50656
50738
|
});
|
|
50657
50739
|
}
|
|
50658
50740
|
if (response.destroyed) {
|
|
@@ -51323,13 +51405,13 @@ function createGaAntigravityPlugin(overrides = {}) {
|
|
|
51323
51405
|
// src/plugin/index.ts
|
|
51324
51406
|
init_dist();
|
|
51325
51407
|
import { createHash as createHash23, randomUUID as randomUUID22 } from "node:crypto";
|
|
51326
|
-
import { join as join38, resolve as
|
|
51408
|
+
import { join as join38, resolve as resolve26 } from "node:path";
|
|
51327
51409
|
|
|
51328
51410
|
// src/cli.ts
|
|
51329
51411
|
init_dist();
|
|
51330
51412
|
import { execFile } from "node:child_process";
|
|
51331
51413
|
import { realpathSync as realpathSync5 } from "node:fs";
|
|
51332
|
-
import { resolve as
|
|
51414
|
+
import { resolve as resolve23 } from "node:path";
|
|
51333
51415
|
import { createInterface } from "node:readline/promises";
|
|
51334
51416
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
51335
51417
|
import { promisify } from "node:util";
|
|
@@ -51386,7 +51468,7 @@ init_runtime_paths();
|
|
|
51386
51468
|
// src/setup.ts
|
|
51387
51469
|
init_dist();
|
|
51388
51470
|
import { lstat as lstat9, readFile as readFile16 } from "node:fs/promises";
|
|
51389
|
-
import { join as join29, resolve as
|
|
51471
|
+
import { join as join29, resolve as resolve22 } from "node:path";
|
|
51390
51472
|
|
|
51391
51473
|
// src/common-auth-embedded/auth-menu/ansi.js
|
|
51392
51474
|
var ANSI2 = {
|
|
@@ -51554,7 +51636,7 @@ async function select2(terminal, items, options) {
|
|
|
51554
51636
|
writeLine("");
|
|
51555
51637
|
renderedLines = lines;
|
|
51556
51638
|
};
|
|
51557
|
-
return new Promise((
|
|
51639
|
+
return new Promise((resolve27) => {
|
|
51558
51640
|
const wasRaw = stdin.isRaw ?? false;
|
|
51559
51641
|
const cleanup2 = () => {
|
|
51560
51642
|
if (cleaned)
|
|
@@ -51574,7 +51656,7 @@ async function select2(terminal, items, options) {
|
|
|
51574
51656
|
};
|
|
51575
51657
|
const finish = (value) => {
|
|
51576
51658
|
cleanup2();
|
|
51577
|
-
|
|
51659
|
+
resolve27(value);
|
|
51578
51660
|
};
|
|
51579
51661
|
const onSignal = () => finish(null);
|
|
51580
51662
|
const onKey = (data) => {
|
|
@@ -51614,7 +51696,7 @@ async function select2(terminal, items, options) {
|
|
|
51614
51696
|
stdin.setRawMode(true);
|
|
51615
51697
|
} catch {
|
|
51616
51698
|
cleanup2();
|
|
51617
|
-
|
|
51699
|
+
resolve27(null);
|
|
51618
51700
|
return;
|
|
51619
51701
|
}
|
|
51620
51702
|
stdin.resume();
|
|
@@ -51628,12 +51710,12 @@ async function select2(terminal, items, options) {
|
|
|
51628
51710
|
import { createHash as createHash18, randomBytes as randomBytes6, randomUUID as randomUUID19 } from "node:crypto";
|
|
51629
51711
|
import { constants as fsConstants2 } from "node:fs";
|
|
51630
51712
|
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";
|
|
51631
|
-
import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute3, join as join25, resolve as
|
|
51713
|
+
import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute3, join as join25, resolve as resolve21 } from "node:path";
|
|
51632
51714
|
import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
51633
51715
|
|
|
51634
51716
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
51635
51717
|
import { lstat as lstat7 } from "node:fs/promises";
|
|
51636
|
-
import { resolve as
|
|
51718
|
+
import { resolve as resolve20 } from "node:path";
|
|
51637
51719
|
async function identity2(path5) {
|
|
51638
51720
|
try {
|
|
51639
51721
|
const metadata = await lstat7(path5);
|
|
@@ -51650,7 +51732,7 @@ function sameIdentity2(left, right) {
|
|
|
51650
51732
|
var FileReadCache2 = class {
|
|
51651
51733
|
#entries = /* @__PURE__ */ new Map();
|
|
51652
51734
|
async read(paths, read, validateHit) {
|
|
51653
|
-
const resolvedPaths = paths.map((path5) =>
|
|
51735
|
+
const resolvedPaths = paths.map((path5) => resolve20(path5));
|
|
51654
51736
|
const key = JSON.stringify(resolvedPaths);
|
|
51655
51737
|
const probed = await Promise.all(resolvedPaths.map(identity2));
|
|
51656
51738
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -51770,8 +51852,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
51770
51852
|
let releaseConfirmed = false;
|
|
51771
51853
|
let loss;
|
|
51772
51854
|
let resolveLoss;
|
|
51773
|
-
const lostPromise = new Promise((
|
|
51774
|
-
resolveLoss =
|
|
51855
|
+
const lostPromise = new Promise((resolve27) => {
|
|
51856
|
+
resolveLoss = resolve27;
|
|
51775
51857
|
});
|
|
51776
51858
|
function notifyTimerStep(event) {
|
|
51777
51859
|
try {
|
|
@@ -51932,7 +52014,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
51932
52014
|
}
|
|
51933
52015
|
}
|
|
51934
52016
|
async function backoff() {
|
|
51935
|
-
await new Promise((
|
|
52017
|
+
await new Promise((resolve27) => setTimeout(resolve27, Math.floor(Math.random() * 4)));
|
|
51936
52018
|
}
|
|
51937
52019
|
async function readLockState(notifyReady = true) {
|
|
51938
52020
|
if (notifyReady && options.onStep)
|
|
@@ -52370,7 +52452,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
52370
52452
|
...typeof observed?.expiresAt === "number" ? { observedExpiresAt: observed.expiresAt } : {}
|
|
52371
52453
|
});
|
|
52372
52454
|
},
|
|
52373
|
-
release: async () => {
|
|
52455
|
+
release: async (signal) => {
|
|
52374
52456
|
if (windowsPrivateFiles2 && releaseConfirmed)
|
|
52375
52457
|
return;
|
|
52376
52458
|
released = true;
|
|
@@ -52411,6 +52493,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
52411
52493
|
releaseConfirmed = removalConfirmed;
|
|
52412
52494
|
return;
|
|
52413
52495
|
}
|
|
52496
|
+
if (signal?.aborted)
|
|
52497
|
+
return;
|
|
52414
52498
|
await recoverStaleEvictionMarker();
|
|
52415
52499
|
} catch (error) {
|
|
52416
52500
|
if (windowsPrivateFiles2)
|
|
@@ -52420,7 +52504,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
52420
52504
|
const remainingMs = deadline - performance.now();
|
|
52421
52505
|
if (remainingMs <= 0)
|
|
52422
52506
|
break;
|
|
52423
|
-
await new Promise((
|
|
52507
|
+
await new Promise((resolve27) => setTimeout(resolve27, Math.min(delayMs, remainingMs)));
|
|
52424
52508
|
delayMs = Math.min(delayMs * 2, 50);
|
|
52425
52509
|
}
|
|
52426
52510
|
if (windowsPrivateFiles2)
|
|
@@ -52493,7 +52577,7 @@ function hostEnrollmentPaths2(input2) {
|
|
|
52493
52577
|
const override = input2.override?.trim();
|
|
52494
52578
|
if (override && !isAbsolute3(override) && !input2.cwd)
|
|
52495
52579
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
52496
|
-
const tokenPath = override ? isAbsolute3(override) ? override :
|
|
52580
|
+
const tokenPath = override ? isAbsolute3(override) ? override : resolve21(input2.cwd, override) : join25(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
52497
52581
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
52498
52582
|
}
|
|
52499
52583
|
function isRecord11(value) {
|
|
@@ -53121,7 +53205,7 @@ var ByteTail = class {
|
|
|
53121
53205
|
};
|
|
53122
53206
|
var defaultCommandRunner = {
|
|
53123
53207
|
run(file, args, options = {}) {
|
|
53124
|
-
return new Promise((
|
|
53208
|
+
return new Promise((resolve27) => {
|
|
53125
53209
|
const started = performance.now();
|
|
53126
53210
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
53127
53211
|
const stderr = new ByteTail();
|
|
@@ -53139,7 +53223,7 @@ var defaultCommandRunner = {
|
|
|
53139
53223
|
stdio: ["ignore", "pipe", "pipe"]
|
|
53140
53224
|
});
|
|
53141
53225
|
} catch {
|
|
53142
|
-
|
|
53226
|
+
resolve27({
|
|
53143
53227
|
exitCode: 1,
|
|
53144
53228
|
stdout: "",
|
|
53145
53229
|
stderr: "",
|
|
@@ -53174,7 +53258,7 @@ var defaultCommandRunner = {
|
|
|
53174
53258
|
settled = true;
|
|
53175
53259
|
if (timer)
|
|
53176
53260
|
clearTimeout(timer);
|
|
53177
|
-
|
|
53261
|
+
resolve27({
|
|
53178
53262
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
53179
53263
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
53180
53264
|
stderr: stderr.toString(),
|
|
@@ -54576,7 +54660,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
54576
54660
|
beforeRename: async () => {
|
|
54577
54661
|
await assertSetupHostsStopped();
|
|
54578
54662
|
const claustrum = await loadCommonAuthClaustrum();
|
|
54579
|
-
const stateDir = host === "opencode" ? openCodeVaultDir(
|
|
54663
|
+
const stateDir = host === "opencode" ? openCodeVaultDir(resolve22(accountFileForVault())) : getPiAntigravityVaultDir();
|
|
54580
54664
|
if (await claustrum.enrollmentAuthority(
|
|
54581
54665
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
54582
54666
|
`antigravity-auth-${host}`
|
|
@@ -54614,7 +54698,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
54614
54698
|
// `beforeSignIn`, which may move it after this plugin is built.
|
|
54615
54699
|
paths: {
|
|
54616
54700
|
get stateDir() {
|
|
54617
|
-
return openCodeVaultDir(
|
|
54701
|
+
return openCodeVaultDir(resolve22(accountFileForVault()));
|
|
54618
54702
|
},
|
|
54619
54703
|
host: "opencode"
|
|
54620
54704
|
}
|
|
@@ -54631,7 +54715,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
54631
54715
|
const assertLocal = async (host, context) => {
|
|
54632
54716
|
if (host === "opencode")
|
|
54633
54717
|
return assertLocalOpenCodeLogin(
|
|
54634
|
-
|
|
54718
|
+
resolve22(accountFileForVault()),
|
|
54635
54719
|
context.opencodeGeneration
|
|
54636
54720
|
);
|
|
54637
54721
|
if (await authority(host) !== "local")
|
|
@@ -55261,7 +55345,7 @@ async function runCliProcess(argv, deps) {
|
|
|
55261
55345
|
...deps,
|
|
55262
55346
|
prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
|
|
55263
55347
|
const folder = await prepareVaultFolder({
|
|
55264
|
-
accountFile:
|
|
55348
|
+
accountFile: resolve23(accountFileForVault()),
|
|
55265
55349
|
...options
|
|
55266
55350
|
});
|
|
55267
55351
|
if (folder.refusal) throw folder.refusal;
|
|
@@ -55307,11 +55391,11 @@ function createDefaultCliDependencies() {
|
|
|
55307
55391
|
);
|
|
55308
55392
|
if (host !== "pi")
|
|
55309
55393
|
await assertLocalOpenCodeLogin(
|
|
55310
|
-
|
|
55394
|
+
resolve23(accountFileForVault()),
|
|
55311
55395
|
context?.opencodeGeneration
|
|
55312
55396
|
);
|
|
55313
55397
|
const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
|
|
55314
|
-
|
|
55398
|
+
resolve23(getStoragePath()),
|
|
55315
55399
|
context?.opencodeGeneration
|
|
55316
55400
|
);
|
|
55317
55401
|
try {
|
|
@@ -55327,7 +55411,7 @@ function createDefaultCliDependencies() {
|
|
|
55327
55411
|
}
|
|
55328
55412
|
if (host === "opencode") await assertSetupHostsStopped();
|
|
55329
55413
|
await assertLocalOpenCodeLogin(
|
|
55330
|
-
|
|
55414
|
+
resolve23(accountFileForVault()),
|
|
55331
55415
|
context?.opencodeGeneration
|
|
55332
55416
|
);
|
|
55333
55417
|
await persistCliStoreLogin(
|
|
@@ -55347,7 +55431,7 @@ function createDefaultCliDependencies() {
|
|
|
55347
55431
|
};
|
|
55348
55432
|
}
|
|
55349
55433
|
async function prepareCliLoginStore(legacyPath, generation) {
|
|
55350
|
-
await assertLocalOpenCodeLogin(
|
|
55434
|
+
await assertLocalOpenCodeLogin(resolve23(accountFileForVault()), generation);
|
|
55351
55435
|
const modules = await loadCommonAuthStoreModules();
|
|
55352
55436
|
const options = {
|
|
55353
55437
|
legacyPath,
|
|
@@ -55472,7 +55556,7 @@ async function readAccountStore(legacyPath) {
|
|
|
55472
55556
|
function createDefaultAccountStoreOperations() {
|
|
55473
55557
|
const offline = { processesStopped: true };
|
|
55474
55558
|
return {
|
|
55475
|
-
legacyPath: () =>
|
|
55559
|
+
legacyPath: () => resolve23(
|
|
55476
55560
|
decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
|
|
55477
55561
|
),
|
|
55478
55562
|
migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
|
|
@@ -55503,7 +55587,7 @@ function createDefaultAccountStoreOperations() {
|
|
|
55503
55587
|
};
|
|
55504
55588
|
}
|
|
55505
55589
|
function samePath(left, right) {
|
|
55506
|
-
return process.platform === "win32" ?
|
|
55590
|
+
return process.platform === "win32" ? resolve23(left).toLowerCase() === resolve23(right).toLowerCase() : resolve23(left) === resolve23(right);
|
|
55507
55591
|
}
|
|
55508
55592
|
function isCliEntry() {
|
|
55509
55593
|
if (import.meta.main !== void 0) return import.meta.main;
|
|
@@ -55993,14 +56077,14 @@ function isTuiConnected(sessionId) {
|
|
|
55993
56077
|
// src/rpc/rpc-dir.ts
|
|
55994
56078
|
import { createHash as createHash19 } from "node:crypto";
|
|
55995
56079
|
import { homedir as homedir13, tmpdir as tmpdir6 } from "node:os";
|
|
55996
|
-
import { isAbsolute as isAbsolute4, join as join33, resolve as
|
|
56080
|
+
import { isAbsolute as isAbsolute4, join as join33, resolve as resolve24 } from "node:path";
|
|
55997
56081
|
var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
|
|
55998
56082
|
function getRpcDir(projectDirectory) {
|
|
55999
56083
|
const override = process.env[RPC_DIR_ENV]?.trim();
|
|
56000
56084
|
if (override) {
|
|
56001
|
-
return isAbsolute4(override) ? override :
|
|
56085
|
+
return isAbsolute4(override) ? override : resolve24(projectDirectory, override);
|
|
56002
56086
|
}
|
|
56003
|
-
const projectHash = createHash19("sha256").update(
|
|
56087
|
+
const projectHash = createHash19("sha256").update(resolve24(projectDirectory)).digest("hex").slice(0, 16);
|
|
56004
56088
|
const stateHome = process.env.XDG_STATE_HOME ?? join33(homedir13(), ".local", "state");
|
|
56005
56089
|
return join33(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
|
|
56006
56090
|
}
|
|
@@ -56014,7 +56098,7 @@ function isSessionId(value) {
|
|
|
56014
56098
|
init_private_files2();
|
|
56015
56099
|
import { createHash as createHash20, randomUUID as randomUUID21 } from "node:crypto";
|
|
56016
56100
|
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";
|
|
56017
|
-
import { join as join34, resolve as
|
|
56101
|
+
import { join as join34, resolve as resolve25 } from "node:path";
|
|
56018
56102
|
function isProbeablePid(pid) {
|
|
56019
56103
|
return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
|
|
56020
56104
|
}
|
|
@@ -56101,7 +56185,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
56101
56185
|
return;
|
|
56102
56186
|
throw error;
|
|
56103
56187
|
}
|
|
56104
|
-
const active2 =
|
|
56188
|
+
const active2 = resolve25(activeDir);
|
|
56105
56189
|
for (const projectDir of projectDirs) {
|
|
56106
56190
|
if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
|
|
56107
56191
|
continue;
|
|
@@ -56145,7 +56229,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
|
|
|
56145
56229
|
await unlink12(portFile).catch(() => {
|
|
56146
56230
|
});
|
|
56147
56231
|
}
|
|
56148
|
-
if (
|
|
56232
|
+
if (resolve25(dir) !== active2)
|
|
56149
56233
|
await rmdir3(dir).catch(() => {
|
|
56150
56234
|
});
|
|
56151
56235
|
}
|
|
@@ -56179,7 +56263,7 @@ var BodyTooLargeError = class extends Error {
|
|
|
56179
56263
|
}
|
|
56180
56264
|
};
|
|
56181
56265
|
function readBody(req) {
|
|
56182
|
-
return new Promise((
|
|
56266
|
+
return new Promise((resolve27, reject) => {
|
|
56183
56267
|
const tooLarge = (declaredOversize = false) => {
|
|
56184
56268
|
req.removeAllListeners("data");
|
|
56185
56269
|
req.on("data", () => {
|
|
@@ -56202,7 +56286,7 @@ function readBody(req) {
|
|
|
56202
56286
|
}
|
|
56203
56287
|
chunks.push(chunk);
|
|
56204
56288
|
});
|
|
56205
|
-
req.on("end", () =>
|
|
56289
|
+
req.on("end", () => resolve27(Buffer.concat(chunks).toString("utf8")));
|
|
56206
56290
|
req.on("error", reject);
|
|
56207
56291
|
});
|
|
56208
56292
|
}
|
|
@@ -56381,12 +56465,12 @@ async function startRpcServer(options) {
|
|
|
56381
56465
|
json(500, { error: "internal error" });
|
|
56382
56466
|
}
|
|
56383
56467
|
}
|
|
56384
|
-
const port = await new Promise((
|
|
56468
|
+
const port = await new Promise((resolve27, reject) => {
|
|
56385
56469
|
server.on("error", reject);
|
|
56386
56470
|
server.listen(0, "127.0.0.1", () => {
|
|
56387
56471
|
const addr = server.address();
|
|
56388
56472
|
if (addr && typeof addr === "object")
|
|
56389
|
-
|
|
56473
|
+
resolve27(addr.port);
|
|
56390
56474
|
else
|
|
56391
56475
|
reject(new Error("no port"));
|
|
56392
56476
|
});
|
|
@@ -56409,16 +56493,16 @@ async function startRpcServer(options) {
|
|
|
56409
56493
|
rpcPort: port
|
|
56410
56494
|
});
|
|
56411
56495
|
} catch (error) {
|
|
56412
|
-
await new Promise((
|
|
56496
|
+
await new Promise((resolve27) => server.close(() => resolve27()));
|
|
56413
56497
|
throw error;
|
|
56414
56498
|
}
|
|
56415
56499
|
return {
|
|
56416
56500
|
port,
|
|
56417
56501
|
token,
|
|
56418
56502
|
async stop() {
|
|
56419
|
-
await new Promise((
|
|
56503
|
+
await new Promise((resolve27) => {
|
|
56420
56504
|
server.closeAllConnections?.();
|
|
56421
|
-
server.close(() =>
|
|
56505
|
+
server.close(() => resolve27());
|
|
56422
56506
|
for (const socket of connections)
|
|
56423
56507
|
socket.destroy();
|
|
56424
56508
|
});
|
|
@@ -57024,7 +57108,7 @@ async function select3(items, options) {
|
|
|
57024
57108
|
}
|
|
57025
57109
|
renderedLines = linesWritten;
|
|
57026
57110
|
};
|
|
57027
|
-
return new Promise((
|
|
57111
|
+
return new Promise((resolve27) => {
|
|
57028
57112
|
const wasRaw = stdin.isRaw ?? false;
|
|
57029
57113
|
const cleanup2 = () => {
|
|
57030
57114
|
if (isCleanedUp) return;
|
|
@@ -57045,11 +57129,11 @@ async function select3(items, options) {
|
|
|
57045
57129
|
};
|
|
57046
57130
|
const onSignal = () => {
|
|
57047
57131
|
cleanup2();
|
|
57048
|
-
|
|
57132
|
+
resolve27(null);
|
|
57049
57133
|
};
|
|
57050
57134
|
const finishWithValue = (value) => {
|
|
57051
57135
|
cleanup2();
|
|
57052
|
-
|
|
57136
|
+
resolve27(value);
|
|
57053
57137
|
};
|
|
57054
57138
|
const findNextSelectable = (from, direction) => {
|
|
57055
57139
|
if (items.length === 0) return from;
|
|
@@ -57095,7 +57179,7 @@ async function select3(items, options) {
|
|
|
57095
57179
|
stdin.setRawMode(true);
|
|
57096
57180
|
} catch {
|
|
57097
57181
|
cleanup2();
|
|
57098
|
-
|
|
57182
|
+
resolve27(null);
|
|
57099
57183
|
return;
|
|
57100
57184
|
}
|
|
57101
57185
|
stdin.resume();
|
|
@@ -60099,10 +60183,10 @@ function resolvePluginDependencies(overrides = {}) {
|
|
|
60099
60183
|
}
|
|
60100
60184
|
async function defaultSleep(ms, signal) {
|
|
60101
60185
|
if (ms <= 0) return;
|
|
60102
|
-
await new Promise((
|
|
60186
|
+
await new Promise((resolve27, reject) => {
|
|
60103
60187
|
const timer = setTimeout(() => {
|
|
60104
60188
|
signal?.removeEventListener("abort", onAbort);
|
|
60105
|
-
|
|
60189
|
+
resolve27();
|
|
60106
60190
|
}, ms);
|
|
60107
60191
|
timer.unref?.();
|
|
60108
60192
|
const onAbort = () => {
|
|
@@ -60822,8 +60906,8 @@ function createPluginLifecycle(options) {
|
|
|
60822
60906
|
};
|
|
60823
60907
|
let failDisposal = () => {
|
|
60824
60908
|
};
|
|
60825
|
-
disposal = new Promise((
|
|
60826
|
-
finishDisposal =
|
|
60909
|
+
disposal = new Promise((resolve27, reject) => {
|
|
60910
|
+
finishDisposal = resolve27;
|
|
60827
60911
|
failDisposal = reject;
|
|
60828
60912
|
});
|
|
60829
60913
|
void (async () => {
|
|
@@ -60972,7 +61056,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
60972
61056
|
await drainSidebarWrites();
|
|
60973
61057
|
}
|
|
60974
61058
|
});
|
|
60975
|
-
const accountFile =
|
|
61059
|
+
const accountFile = resolve26(accountFileForVault());
|
|
60976
61060
|
const vaultFolder = await prepareVaultFolder({ accountFile });
|
|
60977
61061
|
const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
|
|
60978
61062
|
let vaultQuotaPoller;
|