@cortexkit/opencode-antigravity-auth 3.0.38 → 3.0.39
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 +1 -1
- package/dist/cli.js +602 -320
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +100 -32
- package/dist/index.js +807 -384
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +115 -39
- package/dist/server.js +828 -398
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/availability.d.ts +7 -1
- package/dist/src/common-auth-embedded/claustrum/availability.js +9 -1
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +11 -2
- package/dist/src/common-auth-embedded/claustrum/custody.js +89 -31
- package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +4 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.js +33 -2
- package/dist/src/common-auth-embedded/claustrum/host.js +11 -7
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/claustrum/index.js +1 -1
- package/dist/src/common-auth-embedded/fs/lock-record.js +55 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +148 -92
- package/dist/src/common-auth-embedded/fs/with-lock.js +19 -13
- package/dist/src/common-auth-embedded/quota-sidebar/index.d.ts +2 -36
- package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +49 -607
- package/dist/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +3 -0
- package/dist/src/common-auth-embedded/routing-accessor/cache-policy.js +11 -0
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +48 -5
- package/dist/src/common-auth-embedded/routing-accessor/index.js +136 -5
- package/dist/src/common-auth-embedded/setup/enroll.js +2 -1
- package/dist/src/common-auth-embedded/setup/types.d.ts +1 -0
- package/dist/src/common-auth-embedded/source-output.json +72 -64
- package/dist/src/ga/tui/host-ga.d.ts +20 -3
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +102 -25
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/release-model-ids.d.ts.map +1 -1
- package/dist/src/plugin/__fixtures__/release-model-ids.js +1 -0
- package/dist/src/plugin/__fixtures__/release-model-ids.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/src/plugin/ga-location-services.d.ts +1 -0
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +6 -0
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +3 -1
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/setup.d.ts.map +1 -1
- package/dist/src/setup.js +2 -0
- package/dist/src/setup.js.map +1 -1
- package/dist/tui-build-map.json +19 -5
- package/dist/tui-ga-build-map.json +23 -9
- package/dist/types/src/common-auth-embedded/claustrum/availability.d.ts +7 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +11 -2
- package/dist/types/src/common-auth-embedded/claustrum/enrollment.d.ts +4 -0
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +3 -0
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +48 -5
- package/dist/types/src/common-auth-embedded/setup/types.d.ts +1 -0
- package/dist/types/src/plugin/ga-location-services.d.ts +1 -0
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/setup.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/common-auth-embedded/claustrum/availability.d.ts +7 -1
- package/src/common-auth-embedded/claustrum/availability.js +9 -1
- package/src/common-auth-embedded/claustrum/custody.d.ts +11 -2
- package/src/common-auth-embedded/claustrum/custody.js +89 -31
- package/src/common-auth-embedded/claustrum/enrollment.d.ts +4 -0
- package/src/common-auth-embedded/claustrum/enrollment.js +33 -2
- package/src/common-auth-embedded/claustrum/host.js +11 -7
- package/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/src/common-auth-embedded/claustrum/index.js +1 -1
- package/src/common-auth-embedded/fs/lock-record.js +55 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.js +148 -92
- package/src/common-auth-embedded/fs/with-lock.js +19 -13
- package/src/common-auth-embedded/quota-sidebar/index.d.ts +2 -36
- package/src/common-auth-embedded/quota-sidebar/index.tsx +49 -607
- package/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +3 -0
- package/src/common-auth-embedded/routing-accessor/cache-policy.js +11 -0
- package/src/common-auth-embedded/routing-accessor/index.d.ts +48 -5
- package/src/common-auth-embedded/routing-accessor/index.js +136 -5
- package/src/common-auth-embedded/setup/enroll.js +2 -1
- package/src/common-auth-embedded/setup/types.d.ts +1 -0
- package/src/common-auth-embedded/source-output.json +72 -64
- package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +36 -674
- package/src/tui-compiled/shared/a75d0d866c227b3f-index.js +678 -0
- package/src/tui-ga-compiled/host-ga.js +86 -26
- package/src/tui-ga-compiled/shared/a75d0d866c227b3f-index.js +678 -0
- package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +36 -674
- package/src/tui-ga-raw/host-ga.tsx +122 -25
- package/src/tui-ga-raw/shared/a75d0d866c227b3f-index.tsx +681 -0
- package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +49 -607
- package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +49 -607
- package/src/tui-raw/shared/a75d0d866c227b3f-index.tsx +681 -0
package/dist/server.js
CHANGED
|
@@ -5933,6 +5933,8 @@ function getGemini38FlashAntigravityModel(tier) {
|
|
|
5933
5933
|
}
|
|
5934
5934
|
function getQuotaGroupForModel(modelId, hasArgonPool = false) {
|
|
5935
5935
|
const normalized = modelId.toLowerCase();
|
|
5936
|
+
if (isGeminiCarbonModel(normalized))
|
|
5937
|
+
return "gemini";
|
|
5936
5938
|
if (isGeminiArgonModel(normalized))
|
|
5937
5939
|
return hasArgonPool ? "gemini-argon" : void 0;
|
|
5938
5940
|
return QUOTA_GROUP_BY_MODEL_ID[normalized] ?? // Check Claude / GPT-OSS substrings BEFORE the `gemini` substring so
|
|
@@ -5945,6 +5947,19 @@ function getQuotaGroupForModel(modelId, hasArgonPool = false) {
|
|
|
5945
5947
|
function isGeminiArgonModel(model) {
|
|
5946
5948
|
return /^(?:antigravity-)?gemini-4-argon(?:-(?:low|medium|high))?$/.test(model.toLowerCase());
|
|
5947
5949
|
}
|
|
5950
|
+
function isGeminiCarbonModel(model) {
|
|
5951
|
+
return /^(?:antigravity-)?gemini-4-carbon(?:-(?:low|medium|high))?$/.test(model.toLowerCase());
|
|
5952
|
+
}
|
|
5953
|
+
function getGeminiCarbonAntigravityModel(tier) {
|
|
5954
|
+
return getTieredAntigravityModel({
|
|
5955
|
+
defaultModel: "gemini-4-carbon-medium",
|
|
5956
|
+
byTier: {
|
|
5957
|
+
low: "gemini-4-carbon-low",
|
|
5958
|
+
medium: "gemini-4-carbon-medium",
|
|
5959
|
+
high: "gemini-4-carbon-high"
|
|
5960
|
+
}
|
|
5961
|
+
}, tier);
|
|
5962
|
+
}
|
|
5948
5963
|
function getGeminiArgonAntigravityModel(tier) {
|
|
5949
5964
|
return getTieredAntigravityModel({
|
|
5950
5965
|
defaultModel: "gemini-4-argon-medium",
|
|
@@ -5967,6 +5982,33 @@ var init_model_registry = __esm({
|
|
|
5967
5982
|
DEFAULT_COST = { input: 0, output: 0 };
|
|
5968
5983
|
DEFAULT_OPTIONS = {};
|
|
5969
5984
|
AGY_NATIVE_MODEL_DEFINITIONS = {
|
|
5985
|
+
"gemini-4-carbon-low": {
|
|
5986
|
+
displayName: "Gemini 4 Carbon (Low)",
|
|
5987
|
+
maxTokens: 1048576,
|
|
5988
|
+
maxOutputTokens: 262144,
|
|
5989
|
+
model: "MODEL_PLACEHOLDER_M438",
|
|
5990
|
+
thinkingLevel: 1,
|
|
5991
|
+
thinkingBudget: -1,
|
|
5992
|
+
supportsThinking: true
|
|
5993
|
+
},
|
|
5994
|
+
"gemini-4-carbon-medium": {
|
|
5995
|
+
displayName: "Gemini 4 Carbon (Medium)",
|
|
5996
|
+
maxTokens: 1048576,
|
|
5997
|
+
maxOutputTokens: 262144,
|
|
5998
|
+
model: "MODEL_PLACEHOLDER_M437",
|
|
5999
|
+
thinkingLevel: 2,
|
|
6000
|
+
thinkingBudget: -1,
|
|
6001
|
+
supportsThinking: true
|
|
6002
|
+
},
|
|
6003
|
+
"gemini-4-carbon-high": {
|
|
6004
|
+
displayName: "Gemini 4 Carbon (High)",
|
|
6005
|
+
maxTokens: 1048576,
|
|
6006
|
+
maxOutputTokens: 262144,
|
|
6007
|
+
model: "MODEL_PLACEHOLDER_M427",
|
|
6008
|
+
thinkingLevel: 3,
|
|
6009
|
+
thinkingBudget: -1,
|
|
6010
|
+
supportsThinking: true
|
|
6011
|
+
},
|
|
5970
6012
|
"gemini-4-argon-low": {
|
|
5971
6013
|
displayName: "Gemini 4 Argon (Low)",
|
|
5972
6014
|
maxTokens: 1048576,
|
|
@@ -6105,6 +6147,17 @@ var init_model_registry = __esm({
|
|
|
6105
6147
|
high: { thinkingLevel: "high" }
|
|
6106
6148
|
}
|
|
6107
6149
|
}),
|
|
6150
|
+
"antigravity-gemini-4-carbon": defineModel("antigravity-gemini-4-carbon", {
|
|
6151
|
+
name: "Gemini 4 Carbon (Antigravity)",
|
|
6152
|
+
reasoning: true,
|
|
6153
|
+
limit: { context: 1048576, output: 262144 },
|
|
6154
|
+
modalities: DEFAULT_MODALITIES,
|
|
6155
|
+
variants: {
|
|
6156
|
+
low: { thinkingLevel: "low" },
|
|
6157
|
+
medium: { thinkingLevel: "medium" },
|
|
6158
|
+
high: { thinkingLevel: "high" }
|
|
6159
|
+
}
|
|
6160
|
+
}),
|
|
6108
6161
|
"antigravity-gemini-3.1-flash-image": defineModel("antigravity-gemini-3.1-flash-image", {
|
|
6109
6162
|
name: "Gemini 3.1 Flash Image (Antigravity)",
|
|
6110
6163
|
reasoning: false,
|
|
@@ -6152,6 +6205,9 @@ var init_model_registry = __esm({
|
|
|
6152
6205
|
})
|
|
6153
6206
|
};
|
|
6154
6207
|
RESOLVER_ALIASES = {
|
|
6208
|
+
"gemini-4-carbon-low": "gemini-4-carbon",
|
|
6209
|
+
"gemini-4-carbon-medium": "gemini-4-carbon",
|
|
6210
|
+
"gemini-4-carbon-high": "gemini-4-carbon",
|
|
6155
6211
|
"gemini-4-argon-low": "gemini-4-argon",
|
|
6156
6212
|
"gemini-4-argon-medium": "gemini-4-argon",
|
|
6157
6213
|
"gemini-4-argon-high": "gemini-4-argon",
|
|
@@ -6247,6 +6303,7 @@ var init_model_registry = __esm({
|
|
|
6247
6303
|
};
|
|
6248
6304
|
ANTIGRAVITY_OPENCODE_MODEL_IDS = [
|
|
6249
6305
|
"antigravity-gemini-4-argon",
|
|
6306
|
+
"antigravity-gemini-4-carbon",
|
|
6250
6307
|
"antigravity-gemini-3.8-flash",
|
|
6251
6308
|
"antigravity-gemini-3.1-flash-image",
|
|
6252
6309
|
"antigravity-claude-sonnet-5-5",
|
|
@@ -7883,7 +7940,7 @@ async function rmEvictingDir(evictingPath) {
|
|
|
7883
7940
|
});
|
|
7884
7941
|
}
|
|
7885
7942
|
async function sleep(ms) {
|
|
7886
|
-
await new Promise((
|
|
7943
|
+
await new Promise((resolve30) => setTimeout(resolve30, ms));
|
|
7887
7944
|
}
|
|
7888
7945
|
async function acquireFencedFileLock(options) {
|
|
7889
7946
|
const lockPath = `${options.path}.${options.name}.lock`;
|
|
@@ -7999,8 +8056,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
7999
8056
|
let released = false;
|
|
8000
8057
|
let lost = false;
|
|
8001
8058
|
let lostResolve = null;
|
|
8002
|
-
let lostPromise = new Promise((
|
|
8003
|
-
lostResolve =
|
|
8059
|
+
let lostPromise = new Promise((resolve30) => {
|
|
8060
|
+
lostResolve = resolve30;
|
|
8004
8061
|
});
|
|
8005
8062
|
const markLost = () => {
|
|
8006
8063
|
if (lost)
|
|
@@ -8010,9 +8067,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
8010
8067
|
clearInterval(renewTimer);
|
|
8011
8068
|
renewTimer = null;
|
|
8012
8069
|
}
|
|
8013
|
-
const
|
|
8070
|
+
const resolve30 = lostResolve;
|
|
8014
8071
|
lostResolve = null;
|
|
8015
|
-
|
|
8072
|
+
resolve30?.();
|
|
8016
8073
|
};
|
|
8017
8074
|
const setupRenew = () => {
|
|
8018
8075
|
if (options.renew === false)
|
|
@@ -8635,7 +8692,7 @@ async function saveAccountStorageReplace(path5, incoming) {
|
|
|
8635
8692
|
return mutateAccountStorage(path5, () => incoming);
|
|
8636
8693
|
}
|
|
8637
8694
|
async function clearAccountStorage(path5) {
|
|
8638
|
-
const sleep5 = (ms) => new Promise((
|
|
8695
|
+
const sleep5 = (ms) => new Promise((resolve30) => setTimeout(resolve30, ms));
|
|
8639
8696
|
const lock = await acquireWithRetry(path5, sleep5);
|
|
8640
8697
|
try {
|
|
8641
8698
|
await assertLegacyAccountStorageWritable(path5);
|
|
@@ -8683,7 +8740,7 @@ var init_account_storage = __esm({
|
|
|
8683
8740
|
}
|
|
8684
8741
|
};
|
|
8685
8742
|
RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
|
|
8686
|
-
DEFAULT_SLEEP = (ms) => new Promise((
|
|
8743
|
+
DEFAULT_SLEEP = (ms) => new Promise((resolve30) => setTimeout(resolve30, ms));
|
|
8687
8744
|
DEFAULT_BUILD_BACKUP_PATH = (path5, now) => `${path5}.corrupt-${now.toISOString().replace(/[:.]/g, "-")}`;
|
|
8688
8745
|
}
|
|
8689
8746
|
});
|
|
@@ -9901,8 +9958,8 @@ var init_account_manager = __esm({
|
|
|
9901
9958
|
await this.saveInFlight;
|
|
9902
9959
|
return;
|
|
9903
9960
|
}
|
|
9904
|
-
return new Promise((
|
|
9905
|
-
this.savePromiseResolvers.push({ resolve:
|
|
9961
|
+
return new Promise((resolve30, reject) => {
|
|
9962
|
+
this.savePromiseResolvers.push({ resolve: resolve30, reject });
|
|
9906
9963
|
});
|
|
9907
9964
|
}
|
|
9908
9965
|
async dispose() {
|
|
@@ -9945,8 +10002,8 @@ var init_account_manager = __esm({
|
|
|
9945
10002
|
reject(error);
|
|
9946
10003
|
throw error;
|
|
9947
10004
|
}
|
|
9948
|
-
for (const { resolve:
|
|
9949
|
-
|
|
10005
|
+
for (const { resolve: resolve30 } of resolvers)
|
|
10006
|
+
resolve30();
|
|
9950
10007
|
}
|
|
9951
10008
|
async executeSave() {
|
|
9952
10009
|
this.savePending = false;
|
|
@@ -9960,16 +10017,16 @@ var init_account_manager = __esm({
|
|
|
9960
10017
|
}
|
|
9961
10018
|
try {
|
|
9962
10019
|
await this.saveToDisk();
|
|
9963
|
-
for (const { resolve:
|
|
9964
|
-
|
|
10020
|
+
for (const { resolve: resolve30 } of resolvers) {
|
|
10021
|
+
resolve30();
|
|
9965
10022
|
}
|
|
9966
10023
|
} catch (error) {
|
|
9967
10024
|
if (isStorageLockContention(error)) {
|
|
9968
10025
|
this.onDiagnostic?.("Skipped account-state persist due to storage lock contention", {
|
|
9969
10026
|
error: String(error)
|
|
9970
10027
|
});
|
|
9971
|
-
for (const { resolve:
|
|
9972
|
-
|
|
10028
|
+
for (const { resolve: resolve30 } of resolvers) {
|
|
10029
|
+
resolve30();
|
|
9973
10030
|
}
|
|
9974
10031
|
return;
|
|
9975
10032
|
}
|
|
@@ -10470,7 +10527,7 @@ function getHttpsProxy(url) {
|
|
|
10470
10527
|
}
|
|
10471
10528
|
}
|
|
10472
10529
|
function waitForHead(socket, timeoutMs, onTimeout) {
|
|
10473
|
-
return new Promise((
|
|
10530
|
+
return new Promise((resolve30, reject) => {
|
|
10474
10531
|
let buffer = Buffer3.alloc(0);
|
|
10475
10532
|
const timeout = setTimeout(() => {
|
|
10476
10533
|
onTimeout();
|
|
@@ -10493,7 +10550,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
|
|
|
10493
10550
|
return;
|
|
10494
10551
|
const head = buffer.subarray(0, marker).toString("latin1");
|
|
10495
10552
|
const leftover = buffer.subarray(marker + 4);
|
|
10496
|
-
cleanup2(() =>
|
|
10553
|
+
cleanup2(() => resolve30({ head, leftover }));
|
|
10497
10554
|
};
|
|
10498
10555
|
socket.on("data", onData);
|
|
10499
10556
|
socket.once("error", onError);
|
|
@@ -10507,7 +10564,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
10507
10564
|
port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
|
|
10508
10565
|
signal: signal ?? void 0
|
|
10509
10566
|
});
|
|
10510
|
-
await new Promise((
|
|
10567
|
+
await new Promise((resolve30, reject) => {
|
|
10511
10568
|
const timeout = setTimeout(() => {
|
|
10512
10569
|
onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
|
|
10513
10570
|
proxySocket.destroy();
|
|
@@ -10516,7 +10573,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
10516
10573
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10517
10574
|
proxySocket.once("connect", () => {
|
|
10518
10575
|
cleanup2();
|
|
10519
|
-
|
|
10576
|
+
resolve30();
|
|
10520
10577
|
});
|
|
10521
10578
|
proxySocket.once("error", (error) => {
|
|
10522
10579
|
cleanup2();
|
|
@@ -10541,7 +10598,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10541
10598
|
if (leftover.length > 0) {
|
|
10542
10599
|
proxySocket.unshift(leftover);
|
|
10543
10600
|
}
|
|
10544
|
-
return await new Promise((
|
|
10601
|
+
return await new Promise((resolve30, reject) => {
|
|
10545
10602
|
const tlsOptions = {
|
|
10546
10603
|
socket: proxySocket,
|
|
10547
10604
|
servername: targetHost,
|
|
@@ -10556,7 +10613,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10556
10613
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10557
10614
|
tlsSocket.once("secureConnect", () => {
|
|
10558
10615
|
cleanup2();
|
|
10559
|
-
|
|
10616
|
+
resolve30(tlsSocket);
|
|
10560
10617
|
});
|
|
10561
10618
|
tlsSocket.once("error", (error) => {
|
|
10562
10619
|
cleanup2();
|
|
@@ -10565,7 +10622,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10565
10622
|
});
|
|
10566
10623
|
}
|
|
10567
10624
|
async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
10568
|
-
return await new Promise((
|
|
10625
|
+
return await new Promise((resolve30, reject) => {
|
|
10569
10626
|
const tlsOptions = {
|
|
10570
10627
|
host: targetUrl.hostname,
|
|
10571
10628
|
port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
|
|
@@ -10581,7 +10638,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
|
10581
10638
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10582
10639
|
socket.once("secureConnect", () => {
|
|
10583
10640
|
cleanup2();
|
|
10584
|
-
|
|
10641
|
+
resolve30(socket);
|
|
10585
10642
|
});
|
|
10586
10643
|
socket.once("error", (error) => {
|
|
10587
10644
|
cleanup2();
|
|
@@ -12658,6 +12715,45 @@ var init_atomic_write2 = __esm({
|
|
|
12658
12715
|
}
|
|
12659
12716
|
});
|
|
12660
12717
|
|
|
12718
|
+
// ../core/dist/common-auth-embedded/fs/lock-record.js
|
|
12719
|
+
import { resolve as resolve3 } from "node:path";
|
|
12720
|
+
function isWindowsAccessDeniedRead(error, paths) {
|
|
12721
|
+
return error instanceof PrivateFileError && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path5) => resolve3(path5) === error.path);
|
|
12722
|
+
}
|
|
12723
|
+
function isWindowsAccessDeniedCreate(error, paths, stage) {
|
|
12724
|
+
return error instanceof PrivateFileError && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path5) => resolve3(path5) === error.path);
|
|
12725
|
+
}
|
|
12726
|
+
async function readLockRecord(path5, read) {
|
|
12727
|
+
try {
|
|
12728
|
+
return await read();
|
|
12729
|
+
} catch (error) {
|
|
12730
|
+
if (!isWindowsAccessDeniedRead(error, [path5]))
|
|
12731
|
+
throw error;
|
|
12732
|
+
try {
|
|
12733
|
+
return await read();
|
|
12734
|
+
} catch (recheckError) {
|
|
12735
|
+
if (recheckError.code === "ENOENT")
|
|
12736
|
+
throw new DisappearedLockRecordError(path5, error);
|
|
12737
|
+
throw error;
|
|
12738
|
+
}
|
|
12739
|
+
}
|
|
12740
|
+
}
|
|
12741
|
+
var DisappearedLockRecordError;
|
|
12742
|
+
var init_lock_record = __esm({
|
|
12743
|
+
"../core/dist/common-auth-embedded/fs/lock-record.js"() {
|
|
12744
|
+
"use strict";
|
|
12745
|
+
init_private_files();
|
|
12746
|
+
DisappearedLockRecordError = class extends Error {
|
|
12747
|
+
path;
|
|
12748
|
+
code = "ENOENT";
|
|
12749
|
+
constructor(path5, cause) {
|
|
12750
|
+
super(`Lock record disappeared: ${path5}`, { cause });
|
|
12751
|
+
this.path = path5;
|
|
12752
|
+
}
|
|
12753
|
+
};
|
|
12754
|
+
}
|
|
12755
|
+
});
|
|
12756
|
+
|
|
12661
12757
|
// ../core/dist/common-auth-embedded/fs/refresh-file-lock.js
|
|
12662
12758
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
12663
12759
|
import { link as link2, lstat as lstat3, mkdir as mkdir7, open as open4, readFile as readFile5, rename as rename6, rm as rm4, stat as stat3 } from "node:fs/promises";
|
|
@@ -12740,8 +12836,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12740
12836
|
let releaseConfirmed = false;
|
|
12741
12837
|
let loss;
|
|
12742
12838
|
let resolveLoss;
|
|
12743
|
-
const lostPromise = new Promise((
|
|
12744
|
-
resolveLoss =
|
|
12839
|
+
const lostPromise = new Promise((resolve30) => {
|
|
12840
|
+
resolveLoss = resolve30;
|
|
12745
12841
|
});
|
|
12746
12842
|
function notifyTimerStep(event) {
|
|
12747
12843
|
try {
|
|
@@ -12779,15 +12875,18 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12779
12875
|
const evictOwnerId = randomUUID9();
|
|
12780
12876
|
const EVICT_TTL = 5e3;
|
|
12781
12877
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
12878
|
+
function isChangingLockCreate(error) {
|
|
12879
|
+
return windowsPrivateFiles && (isWindowsAccessDeniedCreate(error, [lockPath], "create") || isWindowsAccessDeniedCreate(error, [evictPath], "directory-create"));
|
|
12880
|
+
}
|
|
12782
12881
|
async function readOwner() {
|
|
12783
12882
|
if (windowsPrivateFiles) {
|
|
12784
12883
|
try {
|
|
12785
|
-
return JSON.parse(await readPrivateText(lockPath, true));
|
|
12884
|
+
return JSON.parse(await readLockRecord(lockPath, () => readPrivateText(lockPath, true)));
|
|
12786
12885
|
} catch (error) {
|
|
12787
12886
|
if (error.code !== "EISDIR" && error.reason !== "wrong-kind")
|
|
12788
12887
|
throw error;
|
|
12789
|
-
await verifyPrivate(lockPath, "directory", true);
|
|
12790
|
-
return JSON.parse(await readPrivateText(legacyOwnerPath, true));
|
|
12888
|
+
await readLockRecord(lockPath, () => verifyPrivate(lockPath, "directory", true));
|
|
12889
|
+
return JSON.parse(await readLockRecord(legacyOwnerPath, () => readPrivateText(legacyOwnerPath, true)));
|
|
12791
12890
|
}
|
|
12792
12891
|
}
|
|
12793
12892
|
try {
|
|
@@ -12863,8 +12962,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12863
12962
|
await options.onStep("lease-contention-read-ready");
|
|
12864
12963
|
try {
|
|
12865
12964
|
if (code2 === "EISDIR") {
|
|
12866
|
-
await verifyPrivate(lockPath, "directory", true);
|
|
12867
|
-
await readPrivateText(legacyOwnerPath, true);
|
|
12965
|
+
await readLockRecord(lockPath, () => verifyPrivate(lockPath, "directory", true));
|
|
12966
|
+
await readLockRecord(legacyOwnerPath, () => readPrivateText(legacyOwnerPath, true));
|
|
12868
12967
|
} else
|
|
12869
12968
|
await readOwner();
|
|
12870
12969
|
} catch (readError) {
|
|
@@ -12902,7 +13001,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12902
13001
|
}
|
|
12903
13002
|
}
|
|
12904
13003
|
async function backoff() {
|
|
12905
|
-
await new Promise((
|
|
13004
|
+
await new Promise((resolve30) => setTimeout(resolve30, Math.floor(Math.random() * 4)));
|
|
12906
13005
|
}
|
|
12907
13006
|
async function readLockState(notifyReady = true) {
|
|
12908
13007
|
if (notifyReady && options.onStep)
|
|
@@ -12911,6 +13010,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12911
13010
|
try {
|
|
12912
13011
|
owner = await readOwner();
|
|
12913
13012
|
} catch (error) {
|
|
13013
|
+
if (error instanceof DisappearedLockRecordError)
|
|
13014
|
+
return { status: "missing" };
|
|
12914
13015
|
if (windowsPrivateFiles && error.code !== "ENOENT")
|
|
12915
13016
|
throw error;
|
|
12916
13017
|
}
|
|
@@ -12958,7 +13059,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12958
13059
|
}
|
|
12959
13060
|
async function ownsEvictionMarker() {
|
|
12960
13061
|
try {
|
|
12961
|
-
const owner = JSON.parse(await readPrivateText(evictOwnerPath, windowsPrivateFiles));
|
|
13062
|
+
const owner = JSON.parse(await readLockRecord(evictOwnerPath, () => readPrivateText(evictOwnerPath, windowsPrivateFiles)));
|
|
12962
13063
|
return owner?.ownerId === evictOwnerId;
|
|
12963
13064
|
} catch (error) {
|
|
12964
13065
|
if (windowsPrivateFiles && error.code !== "ENOENT")
|
|
@@ -12993,7 +13094,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12993
13094
|
const remainingMs = deadline - performance.now();
|
|
12994
13095
|
if (remainingMs <= 0)
|
|
12995
13096
|
throw original;
|
|
12996
|
-
await new Promise((
|
|
13097
|
+
await new Promise((resolve30) => setTimeout(resolve30, Math.min(delayMs, remainingMs)));
|
|
12997
13098
|
if (performance.now() >= deadline)
|
|
12998
13099
|
throw original;
|
|
12999
13100
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -13097,7 +13198,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13097
13198
|
}
|
|
13098
13199
|
if (windowsPrivateFiles) {
|
|
13099
13200
|
try {
|
|
13100
|
-
await verifyPrivate(evictPath, "directory", true);
|
|
13201
|
+
await readLockRecord(evictPath, () => verifyPrivate(evictPath, "directory", true));
|
|
13101
13202
|
} catch (error) {
|
|
13102
13203
|
if (error.code === "ENOENT")
|
|
13103
13204
|
return "missing";
|
|
@@ -13152,8 +13253,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13152
13253
|
if (error.code === "EEXIST") {
|
|
13153
13254
|
if (windowsPrivateFiles) {
|
|
13154
13255
|
try {
|
|
13155
|
-
await verifyPrivate(evictPath, "directory", true);
|
|
13156
|
-
await readPrivateText(evictOwnerPath, true);
|
|
13256
|
+
await readLockRecord(evictPath, () => verifyPrivate(evictPath, "directory", true));
|
|
13257
|
+
await readLockRecord(evictOwnerPath, () => readPrivateText(evictOwnerPath, true));
|
|
13157
13258
|
} catch (ownerError) {
|
|
13158
13259
|
if (ownerError.code !== "ENOENT")
|
|
13159
13260
|
throw ownerError;
|
|
@@ -13174,7 +13275,11 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13174
13275
|
try {
|
|
13175
13276
|
await releaseEvictionMarker(deadline);
|
|
13176
13277
|
} catch (error) {
|
|
13177
|
-
if (isRetryableRemoval(actionError, lockPath)
|
|
13278
|
+
if ((isRetryableRemoval(actionError, lockPath) || isWindowsAccessDeniedRead(actionError, [
|
|
13279
|
+
lockPath,
|
|
13280
|
+
legacyOwnerPath,
|
|
13281
|
+
evictOwnerPath
|
|
13282
|
+
])) && (isRetryableRemoval(error, evictPath) || isWindowsAccessDeniedRead(error, [evictOwnerPath])))
|
|
13178
13283
|
throw actionError;
|
|
13179
13284
|
throw error;
|
|
13180
13285
|
}
|
|
@@ -13190,7 +13295,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13190
13295
|
try {
|
|
13191
13296
|
owner = await readOwner();
|
|
13192
13297
|
} catch (error) {
|
|
13193
|
-
if (windowsPrivateFiles)
|
|
13298
|
+
if (windowsPrivateFiles && !(error instanceof DisappearedLockRecordError))
|
|
13194
13299
|
throw error;
|
|
13195
13300
|
return;
|
|
13196
13301
|
}
|
|
@@ -13268,7 +13373,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13268
13373
|
await options.onStep("renewal-marker-unavailable");
|
|
13269
13374
|
}
|
|
13270
13375
|
} catch (error) {
|
|
13271
|
-
if (windowsPrivateFiles && error instanceof PrivateFileError) {
|
|
13376
|
+
if (windowsPrivateFiles && error instanceof PrivateFileError && !isChangingLockCreate(error)) {
|
|
13272
13377
|
terminalIOError = error;
|
|
13273
13378
|
recordLoss("renewal-failed");
|
|
13274
13379
|
shouldReschedule = false;
|
|
@@ -13314,72 +13419,90 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13314
13419
|
}
|
|
13315
13420
|
return null;
|
|
13316
13421
|
}
|
|
13317
|
-
let acquired =
|
|
13422
|
+
let acquired = false;
|
|
13423
|
+
let changingCreateError;
|
|
13424
|
+
try {
|
|
13425
|
+
acquired = await tryAcquire();
|
|
13426
|
+
} catch (error) {
|
|
13427
|
+
if (!isChangingLockCreate(error))
|
|
13428
|
+
throw error;
|
|
13429
|
+
changingCreateError = error;
|
|
13430
|
+
}
|
|
13318
13431
|
if (!acquired) {
|
|
13319
13432
|
for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
|
|
13320
|
-
acquired = await tryAcquire();
|
|
13321
|
-
if (acquired)
|
|
13322
|
-
break;
|
|
13323
|
-
const observed = await readLockState();
|
|
13324
|
-
if (observed.status === "live")
|
|
13325
|
-
return contended();
|
|
13326
|
-
if (observed.status === "missing")
|
|
13327
|
-
continue;
|
|
13328
|
-
if (options.onStep)
|
|
13329
|
-
await options.onStep("stale-lock-observed");
|
|
13330
13433
|
try {
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
const code2 = evictError.code;
|
|
13337
|
-
if (code2 !== "EEXIST")
|
|
13338
|
-
throw evictError;
|
|
13339
|
-
const recovered = await recoverStaleEvictionMarker();
|
|
13340
|
-
if (recovered === "fresh")
|
|
13341
|
-
return null;
|
|
13342
|
-
await backoff();
|
|
13343
|
-
continue;
|
|
13344
|
-
}
|
|
13345
|
-
try {
|
|
13346
|
-
const confirmed = await readLockState();
|
|
13347
|
-
if (confirmed.status === "live")
|
|
13434
|
+
acquired = await tryAcquire();
|
|
13435
|
+
if (acquired)
|
|
13436
|
+
break;
|
|
13437
|
+
const observed = await readLockState();
|
|
13438
|
+
if (observed.status === "live")
|
|
13348
13439
|
return contended();
|
|
13349
|
-
if (
|
|
13440
|
+
if (observed.status === "missing")
|
|
13350
13441
|
continue;
|
|
13351
|
-
if (!await ownsEvictionMarker())
|
|
13352
|
-
return null;
|
|
13353
13442
|
if (options.onStep)
|
|
13354
|
-
await options.onStep("stale-lock-
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
|
|
13443
|
+
await options.onStep("stale-lock-observed");
|
|
13444
|
+
try {
|
|
13445
|
+
if (!await tryAcquireEvictionMarker()) {
|
|
13446
|
+
await backoff();
|
|
13447
|
+
continue;
|
|
13448
|
+
}
|
|
13449
|
+
} catch (evictError) {
|
|
13450
|
+
const code2 = evictError.code;
|
|
13451
|
+
if (code2 !== "EEXIST")
|
|
13452
|
+
throw evictError;
|
|
13453
|
+
const recovered = await recoverStaleEvictionMarker();
|
|
13454
|
+
if (recovered === "fresh")
|
|
13455
|
+
return null;
|
|
13456
|
+
await backoff();
|
|
13359
13457
|
continue;
|
|
13360
|
-
await removeLeaseObject(lockPath);
|
|
13361
|
-
if (!await ownsEvictionMarker())
|
|
13362
|
-
return null;
|
|
13363
|
-
if (options.onStep)
|
|
13364
|
-
await options.onStep("stale-lock-removed");
|
|
13365
|
-
acquired = await tryAcquire();
|
|
13366
|
-
if (!acquired)
|
|
13367
|
-
return null;
|
|
13368
|
-
if (options.onStep)
|
|
13369
|
-
await options.onStep("stale-lock-recreated");
|
|
13370
|
-
if (!await ownsEvictionMarker()) {
|
|
13371
|
-
await relinquishLockAfterMarkerLoss();
|
|
13372
|
-
acquired = false;
|
|
13373
|
-
return null;
|
|
13374
13458
|
}
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13459
|
+
try {
|
|
13460
|
+
const confirmed = await readLockState();
|
|
13461
|
+
if (confirmed.status === "live")
|
|
13462
|
+
return contended();
|
|
13463
|
+
if (!sameStaleLock(observed.identity, confirmed))
|
|
13464
|
+
continue;
|
|
13465
|
+
if (!await ownsEvictionMarker())
|
|
13466
|
+
return null;
|
|
13467
|
+
if (options.onStep)
|
|
13468
|
+
await options.onStep("stale-lock-confirmed");
|
|
13469
|
+
if (!await ownsEvictionMarker())
|
|
13470
|
+
return null;
|
|
13471
|
+
const current = await readLockState(false);
|
|
13472
|
+
if (!sameStaleLock(observed.identity, current))
|
|
13473
|
+
continue;
|
|
13474
|
+
await removeLeaseObject(lockPath);
|
|
13475
|
+
if (!await ownsEvictionMarker())
|
|
13476
|
+
return null;
|
|
13477
|
+
if (options.onStep)
|
|
13478
|
+
await options.onStep("stale-lock-removed");
|
|
13479
|
+
acquired = await tryAcquire();
|
|
13480
|
+
if (!acquired)
|
|
13481
|
+
return null;
|
|
13482
|
+
if (options.onStep)
|
|
13483
|
+
await options.onStep("stale-lock-recreated");
|
|
13484
|
+
if (!await ownsEvictionMarker()) {
|
|
13485
|
+
await relinquishLockAfterMarkerLoss();
|
|
13486
|
+
acquired = false;
|
|
13487
|
+
return null;
|
|
13488
|
+
}
|
|
13489
|
+
break;
|
|
13490
|
+
} finally {
|
|
13491
|
+
await releaseEvictionMarker();
|
|
13492
|
+
}
|
|
13493
|
+
} catch (error) {
|
|
13494
|
+
if (!isChangingLockCreate(error))
|
|
13495
|
+
throw error;
|
|
13496
|
+
changingCreateError ??= error;
|
|
13497
|
+
await backoff();
|
|
13378
13498
|
}
|
|
13379
13499
|
}
|
|
13380
13500
|
}
|
|
13381
|
-
if (!acquired)
|
|
13501
|
+
if (!acquired) {
|
|
13502
|
+
if (changingCreateError)
|
|
13503
|
+
throw changingCreateError;
|
|
13382
13504
|
return null;
|
|
13505
|
+
}
|
|
13383
13506
|
scheduleRenewal();
|
|
13384
13507
|
return {
|
|
13385
13508
|
ownerId,
|
|
@@ -13417,6 +13540,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13417
13540
|
const deadline = performance.now() + EVICT_TTL + 1e3;
|
|
13418
13541
|
let delayMs = 5;
|
|
13419
13542
|
let removalError;
|
|
13543
|
+
let changingRecordError;
|
|
13420
13544
|
for (; ; ) {
|
|
13421
13545
|
try {
|
|
13422
13546
|
let removalConfirmed = false;
|
|
@@ -13442,6 +13566,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13442
13566
|
await removeLeaseObject(lockPath);
|
|
13443
13567
|
removalConfirmed = true;
|
|
13444
13568
|
}, deadline);
|
|
13569
|
+
changingRecordError = void 0;
|
|
13445
13570
|
if (markerAcquired) {
|
|
13446
13571
|
if (windowsPrivateFiles && !removalConfirmed)
|
|
13447
13572
|
throw new PrivateFileError(lockPath, "release-not-confirmed", {
|
|
@@ -13454,23 +13579,32 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13454
13579
|
return;
|
|
13455
13580
|
await recoverStaleEvictionMarker(deadline);
|
|
13456
13581
|
} catch (error) {
|
|
13457
|
-
|
|
13582
|
+
const changingRecord = windowsPrivateFiles && (isChangingLockCreate(error) || isWindowsAccessDeniedRead(error, [
|
|
13583
|
+
lockPath,
|
|
13584
|
+
legacyOwnerPath,
|
|
13585
|
+
evictPath,
|
|
13586
|
+
evictOwnerPath
|
|
13587
|
+
]));
|
|
13588
|
+
if (!isRetryableRemoval(error, lockPath) && !changingRecord) {
|
|
13458
13589
|
if (windowsPrivateFiles)
|
|
13459
13590
|
throw error;
|
|
13460
13591
|
return;
|
|
13461
13592
|
}
|
|
13462
|
-
|
|
13593
|
+
if (changingRecord)
|
|
13594
|
+
changingRecordError ??= error;
|
|
13595
|
+
else
|
|
13596
|
+
removalError ??= error;
|
|
13463
13597
|
}
|
|
13464
13598
|
const remainingMs = deadline - performance.now();
|
|
13465
13599
|
if (remainingMs <= 0)
|
|
13466
13600
|
break;
|
|
13467
|
-
await new Promise((
|
|
13601
|
+
await new Promise((resolve30) => setTimeout(resolve30, Math.min(delayMs, remainingMs)));
|
|
13468
13602
|
if (windowsPrivateFiles && performance.now() >= deadline)
|
|
13469
13603
|
break;
|
|
13470
13604
|
delayMs = Math.min(delayMs * 2, 50);
|
|
13471
13605
|
}
|
|
13472
13606
|
if (windowsPrivateFiles)
|
|
13473
|
-
throw removalError ?? new PrivateFileError(lockPath, "release-not-confirmed", {
|
|
13607
|
+
throw changingRecordError ?? removalError ?? new PrivateFileError(lockPath, "release-not-confirmed", {
|
|
13474
13608
|
code: "ETIMEDOUT"
|
|
13475
13609
|
});
|
|
13476
13610
|
}
|
|
@@ -13480,6 +13614,7 @@ var leaseCreationTestHooks, setRefreshLockRenewalTimeout, clearRefreshLockRenewa
|
|
|
13480
13614
|
var init_refresh_file_lock = __esm({
|
|
13481
13615
|
"../core/dist/common-auth-embedded/fs/refresh-file-lock.js"() {
|
|
13482
13616
|
"use strict";
|
|
13617
|
+
init_lock_record();
|
|
13483
13618
|
init_private_files();
|
|
13484
13619
|
init_with_lock();
|
|
13485
13620
|
setRefreshLockRenewalTimeout = globalThis.setTimeout.bind(globalThis);
|
|
@@ -13489,22 +13624,21 @@ var init_refresh_file_lock = __esm({
|
|
|
13489
13624
|
});
|
|
13490
13625
|
|
|
13491
13626
|
// ../core/dist/common-auth-embedded/fs/with-lock.js
|
|
13492
|
-
import { join as join6, resolve as
|
|
13627
|
+
import { join as join6, resolve as resolve4 } from "node:path";
|
|
13493
13628
|
function lockPathFor(target, name) {
|
|
13494
13629
|
return `${target}.${name}.lock`;
|
|
13495
13630
|
}
|
|
13496
|
-
function
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
return error.path === path5 || error.path === join6(path5, "owner.json");
|
|
13631
|
+
function isChangingLockRecord(error, target, name) {
|
|
13632
|
+
const path5 = resolve4(lockPathFor(target, name));
|
|
13633
|
+
const paths = [path5, join6(path5, "owner.json")];
|
|
13634
|
+
return (isWindowsSharingViolation(error) || isWindowsAccessDeniedRead(error, paths)) && (error.stage === "read" || error.stage === "verify") && paths.includes(error.path) || windowsPrivateFiles && (isWindowsAccessDeniedCreate(error, [path5], "create") || isWindowsAccessDeniedCreate(error, [`${path5}.evicting`], "directory-create"));
|
|
13501
13635
|
}
|
|
13502
13636
|
async function withLock(target, options, fn) {
|
|
13503
13637
|
const started = performance.now();
|
|
13638
|
+
let changingRecordError;
|
|
13504
13639
|
for (; ; ) {
|
|
13505
13640
|
options.signal?.throwIfAborted();
|
|
13506
13641
|
let lock;
|
|
13507
|
-
let changingReadError;
|
|
13508
13642
|
try {
|
|
13509
13643
|
lock = await acquireRefreshFileLock({
|
|
13510
13644
|
path: target,
|
|
@@ -13514,11 +13648,12 @@ async function withLock(target, options, fn) {
|
|
|
13514
13648
|
...options.onStep ? { onStep: options.onStep } : {},
|
|
13515
13649
|
...options.onRenewalTimer ? { onRenewalTimer: options.onRenewalTimer } : {}
|
|
13516
13650
|
});
|
|
13651
|
+
changingRecordError = void 0;
|
|
13517
13652
|
} catch (error) {
|
|
13518
|
-
if (!
|
|
13653
|
+
if (!isChangingLockRecord(error, target, options.name))
|
|
13519
13654
|
throw error;
|
|
13520
13655
|
lock = null;
|
|
13521
|
-
|
|
13656
|
+
changingRecordError ??= error;
|
|
13522
13657
|
}
|
|
13523
13658
|
if (lock) {
|
|
13524
13659
|
try {
|
|
@@ -13530,21 +13665,22 @@ async function withLock(target, options, fn) {
|
|
|
13530
13665
|
}
|
|
13531
13666
|
const remaining = options.timeoutMs - (performance.now() - started);
|
|
13532
13667
|
if (remaining <= 0) {
|
|
13533
|
-
if (
|
|
13534
|
-
throw
|
|
13668
|
+
if (changingRecordError)
|
|
13669
|
+
throw changingRecordError;
|
|
13535
13670
|
throw new LockContentionError({
|
|
13536
13671
|
target,
|
|
13537
13672
|
name: options.name,
|
|
13538
13673
|
timeoutMs: options.timeoutMs
|
|
13539
13674
|
});
|
|
13540
13675
|
}
|
|
13541
|
-
await new Promise((
|
|
13676
|
+
await new Promise((resolve30) => setTimeout(resolve30, Math.min(25, Math.ceil(remaining))));
|
|
13542
13677
|
}
|
|
13543
13678
|
}
|
|
13544
13679
|
var LockContentionError, LockOwnershipError;
|
|
13545
13680
|
var init_with_lock = __esm({
|
|
13546
13681
|
"../core/dist/common-auth-embedded/fs/with-lock.js"() {
|
|
13547
13682
|
"use strict";
|
|
13683
|
+
init_lock_record();
|
|
13548
13684
|
init_private_files();
|
|
13549
13685
|
init_refresh_file_lock();
|
|
13550
13686
|
LockContentionError = class extends Error {
|
|
@@ -13627,7 +13763,7 @@ async function acquirePoolLock(spec, defaults, env3) {
|
|
|
13627
13763
|
});
|
|
13628
13764
|
}
|
|
13629
13765
|
const jitter = Math.floor(Math.random() * (options.retryMs + 1));
|
|
13630
|
-
await new Promise((
|
|
13766
|
+
await new Promise((resolve30) => setTimeout(resolve30, Math.min(options.retryMs + jitter, remaining)));
|
|
13631
13767
|
}
|
|
13632
13768
|
}
|
|
13633
13769
|
function definedOnly(spec) {
|
|
@@ -16521,7 +16657,7 @@ var init_redact = __esm({
|
|
|
16521
16657
|
// ../core/dist/common-auth-embedded/logger/engine.js
|
|
16522
16658
|
import { appendFileSync, chmodSync, existsSync, renameSync, statSync } from "node:fs";
|
|
16523
16659
|
import { open as open5 } from "node:fs/promises";
|
|
16524
|
-
import { dirname as dirname8, resolve as
|
|
16660
|
+
import { dirname as dirname8, resolve as resolve5 } from "node:path";
|
|
16525
16661
|
function chmodPrivate(path5) {
|
|
16526
16662
|
try {
|
|
16527
16663
|
chmodSync(path5, 384);
|
|
@@ -16572,7 +16708,7 @@ async function openWindowsFile(sink, file) {
|
|
|
16572
16708
|
return sink.handle;
|
|
16573
16709
|
}
|
|
16574
16710
|
async function flushWindowsFile(sink, file, text2) {
|
|
16575
|
-
file =
|
|
16711
|
+
file = resolve5(file);
|
|
16576
16712
|
try {
|
|
16577
16713
|
if (sink.file !== file)
|
|
16578
16714
|
await closeWindowsFile(sink);
|
|
@@ -16948,11 +17084,11 @@ var init_quota_writer = __esm({
|
|
|
16948
17084
|
const left = deadline - performance.now();
|
|
16949
17085
|
if (left <= 0)
|
|
16950
17086
|
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);
|
|
16951
|
-
await new Promise((
|
|
17087
|
+
await new Promise((resolve30) => {
|
|
16952
17088
|
const done = () => {
|
|
16953
17089
|
clearTimeout(timer);
|
|
16954
17090
|
this.wake.delete(done);
|
|
16955
|
-
|
|
17091
|
+
resolve30();
|
|
16956
17092
|
};
|
|
16957
17093
|
const timer = setTimeout(done, left);
|
|
16958
17094
|
this.wake.add(done);
|
|
@@ -17345,7 +17481,7 @@ var init_refresh = __esm({
|
|
|
17345
17481
|
|
|
17346
17482
|
// ../core/dist/common-auth-embedded/fs/file-read-cache.js
|
|
17347
17483
|
import { lstat as lstat4, stat as stat4 } from "node:fs/promises";
|
|
17348
|
-
import { resolve as
|
|
17484
|
+
import { resolve as resolve6 } from "node:path";
|
|
17349
17485
|
async function identity(path5, followSymlinks) {
|
|
17350
17486
|
try {
|
|
17351
17487
|
const metadata = await (followSymlinks ? stat4(path5) : lstat4(path5));
|
|
@@ -17370,7 +17506,7 @@ var init_file_read_cache = __esm({
|
|
|
17370
17506
|
this.#followSymlinks = options.followSymlinks ?? false;
|
|
17371
17507
|
}
|
|
17372
17508
|
async read(paths, read, validateHit) {
|
|
17373
|
-
const resolvedPaths = paths.map((path5) =>
|
|
17509
|
+
const resolvedPaths = paths.map((path5) => resolve6(path5));
|
|
17374
17510
|
const key = JSON.stringify(resolvedPaths);
|
|
17375
17511
|
const probed = await Promise.all(resolvedPaths.map((path5) => identity(path5, this.#followSymlinks)));
|
|
17376
17512
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -19559,9 +19695,17 @@ var init_availability = __esm({
|
|
|
19559
19695
|
ERR_PRIVATE_FILES_SECURITY: "answered"
|
|
19560
19696
|
});
|
|
19561
19697
|
ClaustrumUnreachableError = class extends ClaustrumConsumerError {
|
|
19562
|
-
|
|
19698
|
+
/**
|
|
19699
|
+
* Non-secret host connection diagnostic. A missing accessor can recover
|
|
19700
|
+
* once the host bridge installs; a failed accessor could not provide a client.
|
|
19701
|
+
* Other unreachable failures leave this unset. Never use adapter error text.
|
|
19702
|
+
*/
|
|
19703
|
+
reason;
|
|
19704
|
+
constructor(reason) {
|
|
19563
19705
|
super("unavailable", "Claustrum scoped operation unavailable");
|
|
19564
19706
|
this.name = "ClaustrumUnreachableError";
|
|
19707
|
+
if (reason === "host-accessor-missing" || reason === "host-accessor-failed")
|
|
19708
|
+
this.reason = reason;
|
|
19565
19709
|
}
|
|
19566
19710
|
};
|
|
19567
19711
|
}
|
|
@@ -19582,7 +19726,7 @@ function hostError(error) {
|
|
|
19582
19726
|
if (typeof value.code === "string" && (value.class === "transient" || value.class === "permanent" || value.class === "auth_required" || value.class === "context_overflow") && (value.action === "gone" || value.action === "reauth" || value.action === "retry" || value.action === "reduce_and_retry"))
|
|
19583
19727
|
return new ClaustrumCredentialError2(value.code, value.class, value.action);
|
|
19584
19728
|
if (value.name === "ClaustrumUnreachableError" || typeof value.code === "string" && classifyVaultFailure(Object.assign(new Error(), { code: value.code })) === "unreachable")
|
|
19585
|
-
return new ClaustrumUnreachableError();
|
|
19729
|
+
return new ClaustrumUnreachableError(value.reason === "host-accessor-missing" || value.reason === "host-accessor-failed" ? value.reason : void 0);
|
|
19586
19730
|
return error;
|
|
19587
19731
|
}
|
|
19588
19732
|
function call(operation) {
|
|
@@ -19648,14 +19792,15 @@ function connectVaultHost(pluginId) {
|
|
|
19648
19792
|
throw new ClaustrumUnreachableError();
|
|
19649
19793
|
try {
|
|
19650
19794
|
const accessor = globalThis[/* @__PURE__ */ Symbol.for("cortexkit.vault")];
|
|
19651
|
-
if (typeof accessor
|
|
19652
|
-
|
|
19653
|
-
|
|
19654
|
-
|
|
19655
|
-
|
|
19795
|
+
if (typeof accessor === "function") {
|
|
19796
|
+
const client = wrapHostClient(accessor(pluginId));
|
|
19797
|
+
hostClients.add(client);
|
|
19798
|
+
return client;
|
|
19799
|
+
}
|
|
19656
19800
|
} catch {
|
|
19657
|
-
throw new ClaustrumUnreachableError();
|
|
19801
|
+
throw new ClaustrumUnreachableError("host-accessor-failed");
|
|
19658
19802
|
}
|
|
19803
|
+
throw new ClaustrumUnreachableError("host-accessor-missing");
|
|
19659
19804
|
}
|
|
19660
19805
|
var VAULT_HOST_STATUS, VAULT_HOST_CONNECT_REFUSAL, hostClients;
|
|
19661
19806
|
var init_host = __esm({
|
|
@@ -19991,7 +20136,7 @@ async function select(terminal, items, options) {
|
|
|
19991
20136
|
writeLine("");
|
|
19992
20137
|
renderedLines = lines;
|
|
19993
20138
|
};
|
|
19994
|
-
return new Promise((
|
|
20139
|
+
return new Promise((resolve30) => {
|
|
19995
20140
|
const wasRaw = stdin.isRaw ?? false;
|
|
19996
20141
|
const cleanup2 = () => {
|
|
19997
20142
|
if (cleaned)
|
|
@@ -20011,7 +20156,7 @@ async function select(terminal, items, options) {
|
|
|
20011
20156
|
};
|
|
20012
20157
|
const finish = (value) => {
|
|
20013
20158
|
cleanup2();
|
|
20014
|
-
|
|
20159
|
+
resolve30(value);
|
|
20015
20160
|
};
|
|
20016
20161
|
const onSignal = () => finish(null);
|
|
20017
20162
|
const onKey = (data) => {
|
|
@@ -20051,7 +20196,7 @@ async function select(terminal, items, options) {
|
|
|
20051
20196
|
stdin.setRawMode(true);
|
|
20052
20197
|
} catch {
|
|
20053
20198
|
cleanup2();
|
|
20054
|
-
|
|
20199
|
+
resolve30(null);
|
|
20055
20200
|
return;
|
|
20056
20201
|
}
|
|
20057
20202
|
stdin.resume();
|
|
@@ -20787,7 +20932,7 @@ var init_watch = __esm({
|
|
|
20787
20932
|
});
|
|
20788
20933
|
|
|
20789
20934
|
// ../core/dist/common-auth-embedded/claustrum/insula.js
|
|
20790
|
-
import { resolve as
|
|
20935
|
+
import { resolve as resolve7 } from "node:path";
|
|
20791
20936
|
import { storeIdentity } from "@cortexkit/claustrum-client";
|
|
20792
20937
|
import { SubcClient } from "@cortexkit/subc-client";
|
|
20793
20938
|
function insulaUsageTransport(options) {
|
|
@@ -20915,8 +21060,8 @@ function refusalCode(error) {
|
|
|
20915
21060
|
}
|
|
20916
21061
|
function acquireInsulaQuotaSource(transport, tokenPath) {
|
|
20917
21062
|
const key = JSON.stringify([
|
|
20918
|
-
|
|
20919
|
-
|
|
21063
|
+
resolve7(transport.connectionFile),
|
|
21064
|
+
resolve7(tokenPath)
|
|
20920
21065
|
]);
|
|
20921
21066
|
let shared4 = sources.get(key);
|
|
20922
21067
|
if (!shared4) {
|
|
@@ -21230,7 +21375,7 @@ var init_any_signal = __esm({
|
|
|
21230
21375
|
import { createHash as createHash6, randomBytes as randomBytes4, randomUUID as randomUUID12 } from "node:crypto";
|
|
21231
21376
|
import { constants as fsConstants } from "node:fs";
|
|
21232
21377
|
import { chmod as chmod2, mkdir as mkdir8, open as open6, readFile as readFile6, realpath as realpath3, rename as rename7, stat as stat5, unlink as unlink6 } from "node:fs/promises";
|
|
21233
|
-
import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as
|
|
21378
|
+
import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as resolve8 } from "node:path";
|
|
21234
21379
|
import { ClaustrumCredentialError as ClaustrumCredentialError3, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
|
|
21235
21380
|
function classifyEnrollmentError(error) {
|
|
21236
21381
|
if (!(error instanceof ClaustrumCredentialError3))
|
|
@@ -21249,6 +21394,10 @@ function enrollmentName(plugin2, host) {
|
|
|
21249
21394
|
throw new ClaustrumConsumerError("invalid-state", "Claustrum enrollment names use lowercase letters, digits and dashes");
|
|
21250
21395
|
return `${plugin2}-${host}`;
|
|
21251
21396
|
}
|
|
21397
|
+
function validEnrollmentDisplayName(displayName) {
|
|
21398
|
+
const length = Array.from(displayName).length;
|
|
21399
|
+
return length >= 1 && length <= 40 && !/[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\u200b-\u200d\u2060\ufeff]/u.test(displayName);
|
|
21400
|
+
}
|
|
21252
21401
|
function connectClaustrumEnrollmentClient(options) {
|
|
21253
21402
|
return ClaustrumWireClient.connect(options);
|
|
21254
21403
|
}
|
|
@@ -21264,7 +21413,7 @@ function hostEnrollmentPaths(input2) {
|
|
|
21264
21413
|
const override = input2.override?.trim();
|
|
21265
21414
|
if (override && !isAbsolute2(override) && !input2.cwd)
|
|
21266
21415
|
throw new ClaustrumConsumerError("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
21267
|
-
const tokenPath = override ? isAbsolute2(override) ? override :
|
|
21416
|
+
const tokenPath = override ? isAbsolute2(override) ? override : resolve8(input2.cwd, override) : join7(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
21268
21417
|
return getClaustrumEnrollmentPaths(tokenPath);
|
|
21269
21418
|
}
|
|
21270
21419
|
function isRecord6(value) {
|
|
@@ -21731,15 +21880,19 @@ var init_enrollment = __esm({
|
|
|
21731
21880
|
#client;
|
|
21732
21881
|
#paths;
|
|
21733
21882
|
#proposedName;
|
|
21883
|
+
#displayName;
|
|
21734
21884
|
#now;
|
|
21735
21885
|
#mintSecret;
|
|
21736
21886
|
#writeTokenFile;
|
|
21737
21887
|
#ancestorOptions;
|
|
21738
21888
|
constructor(options) {
|
|
21889
|
+
if (options.displayName !== void 0 && !validEnrollmentDisplayName(options.displayName))
|
|
21890
|
+
throw new ClaustrumConsumerError("invalid-state", "invalid Claustrum enrollment display name");
|
|
21739
21891
|
this.#ancestorOptions = options.ancestorOptions ?? {};
|
|
21740
21892
|
this.#client = options.client;
|
|
21741
21893
|
this.#paths = options.paths;
|
|
21742
21894
|
this.#proposedName = options.proposedName;
|
|
21895
|
+
this.#displayName = options.displayName;
|
|
21743
21896
|
this.#now = options.now ?? Date.now;
|
|
21744
21897
|
this.#mintSecret = options.mintSecret ?? (() => randomBytes4(32).toString("hex"));
|
|
21745
21898
|
this.#writeTokenFile = options.writeTokenFile ?? writeEnrollmentTokenFile;
|
|
@@ -21829,10 +21982,23 @@ var init_enrollment = __esm({
|
|
|
21829
21982
|
if (!state.requestId) {
|
|
21830
21983
|
try {
|
|
21831
21984
|
const requestSecretHash = createHash6("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
|
|
21832
|
-
const
|
|
21985
|
+
const proposal = {
|
|
21833
21986
|
name: state.proposedName,
|
|
21834
21987
|
requestSecretHash
|
|
21835
|
-
}
|
|
21988
|
+
};
|
|
21989
|
+
let proposed;
|
|
21990
|
+
try {
|
|
21991
|
+
proposed = await this.#client.enrollPropose({
|
|
21992
|
+
...proposal,
|
|
21993
|
+
...this.#displayName !== void 0 && {
|
|
21994
|
+
displayName: this.#displayName
|
|
21995
|
+
}
|
|
21996
|
+
});
|
|
21997
|
+
} catch (error) {
|
|
21998
|
+
if (this.#displayName === void 0 || !(error instanceof ClaustrumCredentialError3) || error.code !== "invalid_params")
|
|
21999
|
+
throw error;
|
|
22000
|
+
proposed = await this.#client.enrollPropose(proposal);
|
|
22001
|
+
}
|
|
21836
22002
|
state = {
|
|
21837
22003
|
...state,
|
|
21838
22004
|
requestId: proposed.requestId,
|
|
@@ -21999,10 +22165,10 @@ async function drainShutdown(pending, onTimeout) {
|
|
|
21999
22165
|
try {
|
|
22000
22166
|
await Promise.race([
|
|
22001
22167
|
drained,
|
|
22002
|
-
new Promise((
|
|
22168
|
+
new Promise((resolve30) => {
|
|
22003
22169
|
timer = setTimeout(() => {
|
|
22004
22170
|
expired = true;
|
|
22005
|
-
|
|
22171
|
+
resolve30();
|
|
22006
22172
|
}, 2e3);
|
|
22007
22173
|
})
|
|
22008
22174
|
]);
|
|
@@ -22346,8 +22512,15 @@ var init_custody = __esm({
|
|
|
22346
22512
|
this.#warnShutdown = shutdownWarning(this.#logger);
|
|
22347
22513
|
this.#setTimeout = options.setTimeoutImpl ?? setTimeout;
|
|
22348
22514
|
this.#clearTimeout = options.clearTimeoutImpl ?? clearTimeout;
|
|
22515
|
+
const currentClient = () => this.#client;
|
|
22349
22516
|
this.#usage = new ScopedUsageReporter({
|
|
22350
|
-
client:
|
|
22517
|
+
client: {
|
|
22518
|
+
// Queued readings follow a replacement without losing client capability checks.
|
|
22519
|
+
get reportUsageScoped() {
|
|
22520
|
+
const client = currentClient();
|
|
22521
|
+
return client.reportUsageScoped?.bind(client);
|
|
22522
|
+
}
|
|
22523
|
+
},
|
|
22351
22524
|
owns: (id) => this.#usageServed.has(id),
|
|
22352
22525
|
token: async () => hasVaultHost() ? "" : checkedEnrollmentToken(await this.#readToken()),
|
|
22353
22526
|
logger: this.#logger,
|
|
@@ -22355,12 +22528,30 @@ var init_custody = __esm({
|
|
|
22355
22528
|
clearTimeout: this.#clearTimeout
|
|
22356
22529
|
});
|
|
22357
22530
|
}
|
|
22531
|
+
/**
|
|
22532
|
+
* Replace the connection to the same vault without discarding receipts or
|
|
22533
|
+
* their enrollment tokens. Open roster watches restart on the new client;
|
|
22534
|
+
* their existing handles remain usable. Passing the current client does nothing.
|
|
22535
|
+
* Neither client is closed here: the caller closes the old one, and custody's
|
|
22536
|
+
* close()/dispose() still closes the client it holds at shutdown.
|
|
22537
|
+
* While hosted, next must come from connectVaultHost, as in the constructor.
|
|
22538
|
+
*/
|
|
22539
|
+
replaceClient(next) {
|
|
22540
|
+
this.#check();
|
|
22541
|
+
if (next === this.#client)
|
|
22542
|
+
return;
|
|
22543
|
+
if (hasVaultHost() && !isVaultHostClient(next))
|
|
22544
|
+
throw new ClaustrumUnreachableError();
|
|
22545
|
+
this.#client = next;
|
|
22546
|
+
for (const watch of this.#watches)
|
|
22547
|
+
watch.restart();
|
|
22548
|
+
}
|
|
22358
22549
|
/** A watch losing its transport is the same outage as an unreachable read. */
|
|
22359
22550
|
transportLost(error) {
|
|
22360
22551
|
if (this.#closed || this.#outage)
|
|
22361
22552
|
return;
|
|
22362
22553
|
this.#outage = true;
|
|
22363
|
-
this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError();
|
|
22554
|
+
this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
|
|
22364
22555
|
this.#logger.warn("serving kept vault receipt", { reason: "unreachable" });
|
|
22365
22556
|
this.#scheduleProbe();
|
|
22366
22557
|
}
|
|
@@ -22458,7 +22649,7 @@ var init_custody = __esm({
|
|
|
22458
22649
|
if (error instanceof ClaustrumCredentialError5)
|
|
22459
22650
|
throw error;
|
|
22460
22651
|
if (classifyVaultFailure(error) === "unreachable")
|
|
22461
|
-
throw new ClaustrumUnreachableError();
|
|
22652
|
+
throw new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
|
|
22462
22653
|
throw new ClaustrumConsumerError("unavailable", "Claustrum scoped operation unavailable");
|
|
22463
22654
|
} finally {
|
|
22464
22655
|
removeAbortListener?.();
|
|
@@ -22674,7 +22865,7 @@ var init_custody = __esm({
|
|
|
22674
22865
|
if (kept.since === null)
|
|
22675
22866
|
kept.since = this.#now();
|
|
22676
22867
|
const attempt = Object.freeze(Object.defineProperty({ ...kept.attempt, fromKeptReceipt: true }, "accessToken", { value: kept.attempt.accessToken, enumerable: false }));
|
|
22677
|
-
this.#provenance.set(attempt, this.#provenance.get(kept.attempt) ?? { token
|
|
22868
|
+
this.#provenance.set(attempt, this.#provenance.get(kept.attempt) ?? { token });
|
|
22678
22869
|
this.#keptAttempts.set(attempt, routeId);
|
|
22679
22870
|
return attempt;
|
|
22680
22871
|
}
|
|
@@ -22735,15 +22926,15 @@ var init_custody = __esm({
|
|
|
22735
22926
|
recordVersion: served.recordVersion,
|
|
22736
22927
|
expiresAtMs
|
|
22737
22928
|
}, "accessToken", { value: accessToken, enumerable: false }));
|
|
22738
|
-
this.#provenance.set(attempt, { token
|
|
22929
|
+
this.#provenance.set(attempt, { token });
|
|
22739
22930
|
return attempt;
|
|
22740
22931
|
}
|
|
22741
22932
|
/**
|
|
22742
22933
|
* Report that a send this consumer actually made was rejected. Only a 401
|
|
22743
22934
|
* is reported (the vault refuses 429, 402 and 5xx reports), addressed by
|
|
22744
22935
|
* credential id with the exact record version that send was served, and
|
|
22745
|
-
* sent through the client
|
|
22746
|
-
* this custody did not issue is refused rather than reported.
|
|
22936
|
+
* sent through the current client with the enrollment token that authorized
|
|
22937
|
+
* it. A receipt this custody did not issue is refused rather than reported.
|
|
22747
22938
|
*/
|
|
22748
22939
|
async reportFailure(attempt, status, reporterSource) {
|
|
22749
22940
|
if (status !== 401)
|
|
@@ -22767,7 +22958,7 @@ var init_custody = __esm({
|
|
|
22767
22958
|
const pending = this.#reports.get(attempt);
|
|
22768
22959
|
if (pending)
|
|
22769
22960
|
return pending;
|
|
22770
|
-
const report = this.#call(() =>
|
|
22961
|
+
const report = this.#call(() => this.#client.reportAuthFailureScoped({
|
|
22771
22962
|
credentialId: attempt.credentialId,
|
|
22772
22963
|
enrollmentToken: provenance.token,
|
|
22773
22964
|
providerStatus: 401,
|
|
@@ -22808,34 +22999,64 @@ var init_custody = __esm({
|
|
|
22808
22999
|
*/
|
|
22809
23000
|
watchRoster(options) {
|
|
22810
23001
|
this.#check();
|
|
22811
|
-
const
|
|
22812
|
-
|
|
22813
|
-
|
|
22814
|
-
|
|
22815
|
-
|
|
22816
|
-
|
|
22817
|
-
|
|
22818
|
-
|
|
22819
|
-
|
|
22820
|
-
|
|
23002
|
+
const currentView = options.view ?? (() => this.#discoveredView);
|
|
23003
|
+
let discovering;
|
|
23004
|
+
let watch;
|
|
23005
|
+
const create = (resubscribed = false) => {
|
|
23006
|
+
const opened = new ScopedRosterWatch({
|
|
23007
|
+
client: this.#client,
|
|
23008
|
+
enrollmentToken: () => this.#token(),
|
|
23009
|
+
// Nothing observed the gap between clients, even if the view is unchanged.
|
|
23010
|
+
view: () => resubscribed ? void 0 : currentView(),
|
|
23011
|
+
discover: async (view) => {
|
|
23012
|
+
while (discovering)
|
|
23013
|
+
await discovering.catch(() => {
|
|
23014
|
+
});
|
|
23015
|
+
if (watch !== opened)
|
|
23016
|
+
return;
|
|
23017
|
+
resubscribed = false;
|
|
23018
|
+
discovering = Promise.resolve().then(() => options.onView(view));
|
|
23019
|
+
try {
|
|
23020
|
+
await discovering;
|
|
23021
|
+
} finally {
|
|
23022
|
+
discovering = void 0;
|
|
23023
|
+
}
|
|
23024
|
+
},
|
|
23025
|
+
onRefused: (error) => {
|
|
23026
|
+
this.listFailed(error);
|
|
23027
|
+
options.onRefused?.(error);
|
|
23028
|
+
},
|
|
23029
|
+
onTransportLost: () => this.transportLost(),
|
|
23030
|
+
onReachable: () => this.reachable(),
|
|
23031
|
+
onError: options.onError,
|
|
23032
|
+
onMode: options.onMode,
|
|
23033
|
+
logger: this.#logger,
|
|
23034
|
+
now: this.#now,
|
|
23035
|
+
setTimeoutImpl: this.#setTimeout,
|
|
23036
|
+
clearTimeoutImpl: this.#clearTimeout
|
|
23037
|
+
});
|
|
23038
|
+
return opened;
|
|
23039
|
+
};
|
|
23040
|
+
watch = create();
|
|
23041
|
+
const tracked = {
|
|
23042
|
+
restart: () => {
|
|
23043
|
+
const previousMode = watch.mode;
|
|
23044
|
+
watch.stop();
|
|
23045
|
+
watch = create(true);
|
|
23046
|
+
if (previousMode !== watch.mode)
|
|
23047
|
+
options.onMode?.(watch.mode);
|
|
23048
|
+
watch.start();
|
|
22821
23049
|
},
|
|
22822
|
-
|
|
22823
|
-
|
|
22824
|
-
|
|
22825
|
-
onMode: options.onMode,
|
|
22826
|
-
logger: this.#logger,
|
|
22827
|
-
now: this.#now,
|
|
22828
|
-
setTimeoutImpl: this.#setTimeout,
|
|
22829
|
-
clearTimeoutImpl: this.#clearTimeout
|
|
22830
|
-
});
|
|
22831
|
-
this.#watches.add(watch);
|
|
23050
|
+
stop: () => watch.stop()
|
|
23051
|
+
};
|
|
23052
|
+
this.#watches.add(tracked);
|
|
22832
23053
|
watch.start();
|
|
22833
23054
|
return {
|
|
22834
23055
|
get mode() {
|
|
22835
23056
|
return watch.mode;
|
|
22836
23057
|
},
|
|
22837
23058
|
close: () => {
|
|
22838
|
-
this.#watches.delete(
|
|
23059
|
+
this.#watches.delete(tracked);
|
|
22839
23060
|
watch.stop();
|
|
22840
23061
|
}
|
|
22841
23062
|
};
|
|
@@ -22975,7 +23196,7 @@ var init_interlock = __esm({
|
|
|
22975
23196
|
// ../core/dist/common-auth-embedded/claustrum/roster.js
|
|
22976
23197
|
import { createHash as createHash7 } from "node:crypto";
|
|
22977
23198
|
import { stat as stat6 } from "node:fs/promises";
|
|
22978
|
-
import { resolve as
|
|
23199
|
+
import { resolve as resolve9 } from "node:path";
|
|
22979
23200
|
function vaultRosterSeed(roster) {
|
|
22980
23201
|
return {
|
|
22981
23202
|
declined: roster.declined.map((entry) => ({ ...entry })),
|
|
@@ -23377,16 +23598,16 @@ function applyVaultQuota(current, input2) {
|
|
|
23377
23598
|
};
|
|
23378
23599
|
}
|
|
23379
23600
|
function forgetPendingVaultDiscovery(path5) {
|
|
23380
|
-
pendingDiscoveries.delete(
|
|
23601
|
+
pendingDiscoveries.delete(resolve9(path5));
|
|
23381
23602
|
}
|
|
23382
23603
|
function isVaultRosterLockRefusal(path5, error) {
|
|
23383
|
-
const target =
|
|
23604
|
+
const target = resolve9(path5);
|
|
23384
23605
|
if (error instanceof ClaustrumConsumerError)
|
|
23385
23606
|
return error.kind === "roster-busy";
|
|
23386
23607
|
if (error instanceof LockContentionError || error instanceof LockOwnershipError)
|
|
23387
|
-
return
|
|
23608
|
+
return resolve9(error.details.target) === target;
|
|
23388
23609
|
if (error instanceof PrivateFileError) {
|
|
23389
|
-
const failed =
|
|
23610
|
+
const failed = resolve9(error.path);
|
|
23390
23611
|
return [WRITE_LOCK.name, DISCOVERY_LEASE.name].some((name) => {
|
|
23391
23612
|
const lock = lockPathFor(target, name);
|
|
23392
23613
|
return failed === lock || failed.startsWith(`${lock}.`);
|
|
@@ -23447,7 +23668,7 @@ async function refreshVaultRoster(options) {
|
|
|
23447
23668
|
throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
|
|
23448
23669
|
return persisted;
|
|
23449
23670
|
}
|
|
23450
|
-
const key =
|
|
23671
|
+
const key = resolve9(options.path);
|
|
23451
23672
|
const listedOver = options.listedOver;
|
|
23452
23673
|
let discovered;
|
|
23453
23674
|
try {
|
|
@@ -23571,9 +23792,9 @@ var init_roster = __esm({
|
|
|
23571
23792
|
});
|
|
23572
23793
|
|
|
23573
23794
|
// ../core/dist/common-auth-embedded/claustrum/quota-writer.js
|
|
23574
|
-
import { resolve as
|
|
23795
|
+
import { resolve as resolve10 } from "node:path";
|
|
23575
23796
|
function writerFor(path5, clock2 = quotaCommitTimer) {
|
|
23576
|
-
const key =
|
|
23797
|
+
const key = resolve10(path5);
|
|
23577
23798
|
let writer = writers.get(key);
|
|
23578
23799
|
if (!writer) {
|
|
23579
23800
|
writer = {
|
|
@@ -23637,7 +23858,7 @@ function orderedFields(pending) {
|
|
|
23637
23858
|
return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
|
|
23638
23859
|
}
|
|
23639
23860
|
function pendingVaultQuota(path5, roster) {
|
|
23640
|
-
const writer = writers.get(
|
|
23861
|
+
const writer = writers.get(resolve10(path5));
|
|
23641
23862
|
if (writer) {
|
|
23642
23863
|
for (const field of orderedFields(writer.pending)) {
|
|
23643
23864
|
if (field.priorReading)
|
|
@@ -23648,7 +23869,7 @@ function pendingVaultQuota(path5, roster) {
|
|
|
23648
23869
|
return roster;
|
|
23649
23870
|
}
|
|
23650
23871
|
function hasPendingVaultQuota(path5) {
|
|
23651
|
-
return !!writers.get(
|
|
23872
|
+
return !!writers.get(resolve10(path5))?.pending.size;
|
|
23652
23873
|
}
|
|
23653
23874
|
function schedule(writer, delay3) {
|
|
23654
23875
|
if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
|
|
@@ -23713,7 +23934,7 @@ function flush(writer) {
|
|
|
23713
23934
|
return writer.running;
|
|
23714
23935
|
}
|
|
23715
23936
|
async function drainVaultQuota(path5, timeoutMs = 1e3) {
|
|
23716
|
-
const key =
|
|
23937
|
+
const key = resolve10(path5);
|
|
23717
23938
|
const writer = writers.get(key);
|
|
23718
23939
|
if (!writer)
|
|
23719
23940
|
return;
|
|
@@ -23861,7 +24082,7 @@ var init_consumer = __esm({
|
|
|
23861
24082
|
this.#shutdown.signal,
|
|
23862
24083
|
...signal ? [signal] : []
|
|
23863
24084
|
]);
|
|
23864
|
-
return new Promise((
|
|
24085
|
+
return new Promise((resolve30, reject) => {
|
|
23865
24086
|
const cleanup2 = () => {
|
|
23866
24087
|
combined.signal.removeEventListener("abort", abort);
|
|
23867
24088
|
combined.dispose();
|
|
@@ -23876,7 +24097,7 @@ var init_consumer = __esm({
|
|
|
23876
24097
|
if (combined.signal.aborted)
|
|
23877
24098
|
reject(combined.signal.reason);
|
|
23878
24099
|
else
|
|
23879
|
-
|
|
24100
|
+
resolve30(value);
|
|
23880
24101
|
}, (error) => {
|
|
23881
24102
|
cleanup2();
|
|
23882
24103
|
reject(error);
|
|
@@ -24621,7 +24842,7 @@ var init_consumer = __esm({
|
|
|
24621
24842
|
import { createHash as createHash8 } from "node:crypto";
|
|
24622
24843
|
import { channel as channel2 } from "node:diagnostics_channel";
|
|
24623
24844
|
import { readdir, stat as stat7 } from "node:fs/promises";
|
|
24624
|
-
import { dirname as dirname10, join as join8, resolve as
|
|
24845
|
+
import { dirname as dirname10, join as join8, resolve as resolve11 } from "node:path";
|
|
24625
24846
|
function canonicalJson3(value, path5 = /* @__PURE__ */ new Set()) {
|
|
24626
24847
|
if (value === null)
|
|
24627
24848
|
return "null";
|
|
@@ -24682,12 +24903,12 @@ function unreachableConnect2() {
|
|
|
24682
24903
|
return new ClaustrumUnreachableError();
|
|
24683
24904
|
}
|
|
24684
24905
|
function untilAborted(pending, signal) {
|
|
24685
|
-
return new Promise((
|
|
24906
|
+
return new Promise((resolve30, reject) => {
|
|
24686
24907
|
const abort = () => reject(signal.reason);
|
|
24687
24908
|
signal.addEventListener("abort", abort, { once: true });
|
|
24688
24909
|
pending.then((value) => {
|
|
24689
24910
|
signal.removeEventListener("abort", abort);
|
|
24690
|
-
|
|
24911
|
+
resolve30(value);
|
|
24691
24912
|
}, (error) => {
|
|
24692
24913
|
signal.removeEventListener("abort", abort);
|
|
24693
24914
|
reject(error);
|
|
@@ -24845,7 +25066,7 @@ var init_hub = __esm({
|
|
|
24845
25066
|
};
|
|
24846
25067
|
const { consumer, hooks } = createHubMember(port, consumerOptions);
|
|
24847
25068
|
entry.hooks = hooks;
|
|
24848
|
-
const path5 =
|
|
25069
|
+
const path5 = resolve11(entry.path);
|
|
24849
25070
|
const subscribers = sharedRosters.get(path5) ?? /* @__PURE__ */ new Set();
|
|
24850
25071
|
const install = (roster) => {
|
|
24851
25072
|
if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
|
|
@@ -24876,7 +25097,7 @@ var init_hub = __esm({
|
|
|
24876
25097
|
return;
|
|
24877
25098
|
entry.seen = JSON.stringify(decodedVaultRoster(roster));
|
|
24878
25099
|
entry.hooks?.install(roster);
|
|
24879
|
-
for (const install of sharedRosters.get(
|
|
25100
|
+
for (const install of sharedRosters.get(resolve11(entry.path)) ?? []) {
|
|
24880
25101
|
if (!this.#live(generation))
|
|
24881
25102
|
return;
|
|
24882
25103
|
if (install !== entry.receiveRoster)
|
|
@@ -25679,6 +25900,7 @@ __export(claustrum_exports, {
|
|
|
25679
25900
|
reorderVaultRoster: () => reorderVaultRoster,
|
|
25680
25901
|
resetClaustrumEnrollmentState: () => resetClaustrumEnrollmentState,
|
|
25681
25902
|
resolveVaultPrimary: () => resolveVaultPrimary,
|
|
25903
|
+
validEnrollmentDisplayName: () => validEnrollmentDisplayName,
|
|
25682
25904
|
vaultAuthority: () => vaultAuthority,
|
|
25683
25905
|
vaultRosterSeed: () => vaultRosterSeed,
|
|
25684
25906
|
vaultRoutingRows: () => vaultRoutingRows
|
|
@@ -25935,7 +26157,7 @@ var init_lock = __esm({
|
|
|
25935
26157
|
import { createHash as createHash9 } from "node:crypto";
|
|
25936
26158
|
import { constants as constants2 } from "node:fs";
|
|
25937
26159
|
import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
|
|
25938
|
-
import { dirname as dirname11, resolve as
|
|
26160
|
+
import { dirname as dirname11, resolve as resolve12 } from "node:path";
|
|
25939
26161
|
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
25940
26162
|
function rootSpans(text2) {
|
|
25941
26163
|
let i = text2.indexOf("{") + 1;
|
|
@@ -26136,8 +26358,8 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
26136
26358
|
if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
|
|
26137
26359
|
throw new PiSlotError("invalid-options");
|
|
26138
26360
|
}
|
|
26139
|
-
const authPath =
|
|
26140
|
-
const stashPath =
|
|
26361
|
+
const authPath = resolve12(options.authPath);
|
|
26362
|
+
const stashPath = resolve12(options.stashPath);
|
|
26141
26363
|
if (authPath === stashPath || stashPath === `${authPath}.lock`) {
|
|
26142
26364
|
throw new PiSlotError("invalid-options");
|
|
26143
26365
|
}
|
|
@@ -26760,8 +26982,8 @@ function getDefaultTierId(allowedTiers) {
|
|
|
26760
26982
|
return allowedTiers[0]?.id;
|
|
26761
26983
|
}
|
|
26762
26984
|
function wait(ms) {
|
|
26763
|
-
return new Promise((
|
|
26764
|
-
setTimeout(
|
|
26985
|
+
return new Promise((resolve30) => {
|
|
26986
|
+
setTimeout(resolve30, ms);
|
|
26765
26987
|
});
|
|
26766
26988
|
}
|
|
26767
26989
|
function extractManagedProjectId(payload) {
|
|
@@ -27580,7 +27802,7 @@ function applyAgyNativeGenerationConfig(wireModel, generationConfig) {
|
|
|
27580
27802
|
generationConfig.maxOutputTokens = output2;
|
|
27581
27803
|
}
|
|
27582
27804
|
delete generationConfig.max_output_tokens;
|
|
27583
|
-
if (isGeminiArgonModel(wireModel) && native.thinkingLevel !== void 0) {
|
|
27805
|
+
if ((isGeminiArgonModel(wireModel) || isGeminiCarbonModel(wireModel)) && native.thinkingLevel !== void 0) {
|
|
27584
27806
|
generationConfig.thinkingConfig = {
|
|
27585
27807
|
includeThoughts: true,
|
|
27586
27808
|
thinkingLevel: ADAPTIVE_LEVELS[native.thinkingLevel]
|
|
@@ -28339,7 +28561,7 @@ var init_cross_model_sanitizer = __esm({
|
|
|
28339
28561
|
// ../core/dist/transform/model-resolver.js
|
|
28340
28562
|
function supportsThinkingTiers(model) {
|
|
28341
28563
|
const lower = model.toLowerCase();
|
|
28342
|
-
return isGeminiArgonModel(lower) || lower.includes("gemini-3") || lower.includes("gemini-2.5") || lower.includes("claude") && (lower.includes("thinking") || /^claude-(opus|sonnet)-5-5/.test(lower));
|
|
28564
|
+
return isGeminiArgonModel(lower) || isGeminiCarbonModel(lower) || lower.includes("gemini-3") || lower.includes("gemini-2.5") || lower.includes("claude") && (lower.includes("thinking") || /^claude-(opus|sonnet)-5-5/.test(lower));
|
|
28343
28565
|
}
|
|
28344
28566
|
function extractThinkingTierFromModel(model) {
|
|
28345
28567
|
if (!supportsThinkingTiers(model)) {
|
|
@@ -28399,9 +28621,10 @@ function resolveModelWithTier(requestedModel) {
|
|
|
28399
28621
|
const baseName = tier ? modelWithoutQuota.replace(TIER_REGEX, "") : modelWithoutQuota;
|
|
28400
28622
|
const isImageModel = IMAGE_GENERATION_MODELS.test(modelWithoutQuota);
|
|
28401
28623
|
const isArgon = isGeminiArgonModel(modelWithoutQuota);
|
|
28402
|
-
|
|
28624
|
+
const isCarbon = isGeminiCarbonModel(modelWithoutQuota);
|
|
28625
|
+
if (isArgon || isCarbon) {
|
|
28403
28626
|
return {
|
|
28404
|
-
actualModel: getGeminiArgonAntigravityModel(tier),
|
|
28627
|
+
actualModel: isCarbon ? getGeminiCarbonAntigravityModel(tier) : getGeminiArgonAntigravityModel(tier),
|
|
28405
28628
|
thinkingLevel: tier ?? "medium",
|
|
28406
28629
|
tier: tier ?? "medium",
|
|
28407
28630
|
isThinkingModel: true
|
|
@@ -29083,12 +29306,12 @@ var init_vault_provider_state = __esm({
|
|
|
29083
29306
|
function untilAborted2(pending, signal) {
|
|
29084
29307
|
if (!signal)
|
|
29085
29308
|
return pending;
|
|
29086
|
-
return new Promise((
|
|
29309
|
+
return new Promise((resolve30, reject) => {
|
|
29087
29310
|
const abort = () => reject(signal.reason);
|
|
29088
29311
|
signal.addEventListener("abort", abort, { once: true });
|
|
29089
29312
|
if (signal.aborted)
|
|
29090
29313
|
abort();
|
|
29091
|
-
pending.then(
|
|
29314
|
+
pending.then(resolve30, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
29092
29315
|
});
|
|
29093
29316
|
}
|
|
29094
29317
|
async function resolveClaustrumConnectionPath(explicit) {
|
|
@@ -29556,7 +29779,7 @@ var init_dist = __esm({
|
|
|
29556
29779
|
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
29557
29780
|
import { lstat as lstat6, readFile as readFile8, rename as rename8, unlink as unlink8 } from "node:fs/promises";
|
|
29558
29781
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
29559
|
-
import { dirname as dirname13, join as join10, resolve as
|
|
29782
|
+
import { dirname as dirname13, join as join10, resolve as resolve13 } from "node:path";
|
|
29560
29783
|
function ioCode2(detail) {
|
|
29561
29784
|
if (detail?.reason === "io-error") {
|
|
29562
29785
|
if (detail.win32Code === 2 || detail.win32Code === 3)
|
|
@@ -29606,7 +29829,7 @@ async function privateOperation2(path5, stage, operation) {
|
|
|
29606
29829
|
}
|
|
29607
29830
|
}
|
|
29608
29831
|
async function verifySafeDirectory2(path5, options) {
|
|
29609
|
-
path5 =
|
|
29832
|
+
path5 = resolve13(path5);
|
|
29610
29833
|
options ??= safeParentOptionsForTest2;
|
|
29611
29834
|
await privateOperation2(path5, "safe-parent", async () => {
|
|
29612
29835
|
const result = await (await loadBackend2()).verifySafeParent(path5, options);
|
|
@@ -29621,7 +29844,7 @@ async function verifySafeDirectory2(path5, options) {
|
|
|
29621
29844
|
});
|
|
29622
29845
|
}
|
|
29623
29846
|
async function verifyPrivate2(path5, kind, migrate = false) {
|
|
29624
|
-
path5 =
|
|
29847
|
+
path5 = resolve13(path5);
|
|
29625
29848
|
if (kind === "directory")
|
|
29626
29849
|
return verifySafeDirectory2(path5);
|
|
29627
29850
|
await privateOperation2(path5, "verify", async () => {
|
|
@@ -29656,7 +29879,7 @@ async function verifyPrivate2(path5, kind, migrate = false) {
|
|
|
29656
29879
|
});
|
|
29657
29880
|
}
|
|
29658
29881
|
async function ensurePrivateDirectory2(path5, _migrate = false, options) {
|
|
29659
|
-
path5 =
|
|
29882
|
+
path5 = resolve13(path5);
|
|
29660
29883
|
await privateOperation2(path5, "directory", async () => {
|
|
29661
29884
|
const api = await loadBackend2();
|
|
29662
29885
|
try {
|
|
@@ -29687,7 +29910,7 @@ async function readPrivateText2(path5, migrate = false) {
|
|
|
29687
29910
|
async function readPrivateBuffer2(path5, migrate = false) {
|
|
29688
29911
|
if (!windowsPrivateFiles2)
|
|
29689
29912
|
return readFile8(path5);
|
|
29690
|
-
path5 =
|
|
29913
|
+
path5 = resolve13(path5);
|
|
29691
29914
|
if (migrate) {
|
|
29692
29915
|
await verifySafeDirectory2(dirname13(path5));
|
|
29693
29916
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -29695,20 +29918,20 @@ async function readPrivateBuffer2(path5, migrate = false) {
|
|
|
29695
29918
|
return privateOperation2(path5, "read", async () => (await loadBackend2()).readOwnerOnly(path5));
|
|
29696
29919
|
}
|
|
29697
29920
|
async function createPrivateBytes2(path5, bytes) {
|
|
29698
|
-
await verifySafeDirectory2(dirname13(
|
|
29921
|
+
await verifySafeDirectory2(dirname13(resolve13(path5)));
|
|
29699
29922
|
await privateOperation2(path5, "create", async () => {
|
|
29700
|
-
await (await loadBackend2()).createPrivateFile(
|
|
29923
|
+
await (await loadBackend2()).createPrivateFile(resolve13(path5), bytes);
|
|
29701
29924
|
});
|
|
29702
29925
|
}
|
|
29703
29926
|
async function createPrivateDirectoryExclusive2(path5) {
|
|
29704
|
-
await verifySafeDirectory2(dirname13(
|
|
29927
|
+
await verifySafeDirectory2(dirname13(resolve13(path5)));
|
|
29705
29928
|
await privateOperation2(path5, "directory-create", async () => {
|
|
29706
|
-
await (await loadBackend2()).createOwnerOnly(
|
|
29929
|
+
await (await loadBackend2()).createOwnerOnly(resolve13(path5), { kind: "dir" });
|
|
29707
29930
|
});
|
|
29708
29931
|
}
|
|
29709
29932
|
async function replaceWindowsFile2(from, to, options = {}) {
|
|
29710
|
-
from =
|
|
29711
|
-
to =
|
|
29933
|
+
from = resolve13(from);
|
|
29934
|
+
to = resolve13(to);
|
|
29712
29935
|
const now = options.now ?? (() => performance.now());
|
|
29713
29936
|
const start = now();
|
|
29714
29937
|
const leaseDeadline = options.deadline ?? Infinity;
|
|
@@ -29751,7 +29974,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
|
|
|
29751
29974
|
throw error;
|
|
29752
29975
|
}
|
|
29753
29976
|
async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
29754
|
-
path5 =
|
|
29977
|
+
path5 = resolve13(path5);
|
|
29755
29978
|
await ensurePrivateDirectory2(dirname13(path5));
|
|
29756
29979
|
try {
|
|
29757
29980
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -29759,7 +29982,7 @@ async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
|
29759
29982
|
if (error.code !== "ENOENT")
|
|
29760
29983
|
throw error;
|
|
29761
29984
|
}
|
|
29762
|
-
const stage =
|
|
29985
|
+
const stage = resolve13(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
|
|
29763
29986
|
if (dirname13(stage) !== dirname13(path5))
|
|
29764
29987
|
throw new PrivateFileError2(path5, "stage-directory", { code: "EXDEV" });
|
|
29765
29988
|
let created = false;
|
|
@@ -29932,7 +30155,7 @@ var init_redact2 = __esm({
|
|
|
29932
30155
|
// src/common-auth-embedded/logger/engine.js
|
|
29933
30156
|
import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync3, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
|
|
29934
30157
|
import { open as open8 } from "node:fs/promises";
|
|
29935
|
-
import { dirname as dirname14, resolve as
|
|
30158
|
+
import { dirname as dirname14, resolve as resolve14 } from "node:path";
|
|
29936
30159
|
function chmodPrivate2(path5) {
|
|
29937
30160
|
try {
|
|
29938
30161
|
chmodSync2(path5, 384);
|
|
@@ -29983,7 +30206,7 @@ async function openWindowsFile2(sink, file) {
|
|
|
29983
30206
|
return sink.handle;
|
|
29984
30207
|
}
|
|
29985
30208
|
async function flushWindowsFile2(sink, file, text2) {
|
|
29986
|
-
file =
|
|
30209
|
+
file = resolve14(file);
|
|
29987
30210
|
try {
|
|
29988
30211
|
if (sink.file !== file)
|
|
29989
30212
|
await closeWindowsFile2(sink);
|
|
@@ -30587,12 +30810,12 @@ function createVaultAccountPool(options) {
|
|
|
30587
30810
|
try {
|
|
30588
30811
|
return await Promise.race([
|
|
30589
30812
|
read.then(() => true),
|
|
30590
|
-
new Promise((
|
|
30813
|
+
new Promise((resolve30, reject) => {
|
|
30591
30814
|
const abort = () => reject(signal?.reason);
|
|
30592
30815
|
signal?.addEventListener("abort", abort, { once: true });
|
|
30593
30816
|
detachAbort = () => signal?.removeEventListener("abort", abort);
|
|
30594
30817
|
if (remaining !== void 0)
|
|
30595
|
-
cancelTimer2 = schedule2(() =>
|
|
30818
|
+
cancelTimer2 = schedule2(() => resolve30(false), remaining);
|
|
30596
30819
|
if (signal?.aborted) abort();
|
|
30597
30820
|
})
|
|
30598
30821
|
]);
|
|
@@ -31094,11 +31317,11 @@ function createOpenCodeVaultCustody(options) {
|
|
|
31094
31317
|
].join("\n");
|
|
31095
31318
|
const waitForApproval = async () => {
|
|
31096
31319
|
while (!closed2) {
|
|
31097
|
-
await new Promise((
|
|
31320
|
+
await new Promise((resolve30) => {
|
|
31098
31321
|
const done = () => {
|
|
31099
31322
|
clearTimeout(timer);
|
|
31100
31323
|
cancelWait = void 0;
|
|
31101
|
-
|
|
31324
|
+
resolve30();
|
|
31102
31325
|
};
|
|
31103
31326
|
const timer = setTimeout(done, 2e3);
|
|
31104
31327
|
timer.unref?.();
|
|
@@ -31498,7 +31721,7 @@ import { randomUUID as randomUUID14 } from "node:crypto";
|
|
|
31498
31721
|
import { realpathSync, rmSync } from "node:fs";
|
|
31499
31722
|
import { chmod as chmod4, mkdir as mkdir12, readFile as readFile10, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
|
|
31500
31723
|
import { homedir as homedir2 } from "node:os";
|
|
31501
|
-
import { join as join12, resolve as
|
|
31724
|
+
import { join as join12, resolve as resolve15 } from "node:path";
|
|
31502
31725
|
function processHeartbeatDir() {
|
|
31503
31726
|
const base = process.env.XDG_STATE_HOME || join12(homedir2(), ".local", "state");
|
|
31504
31727
|
return join12(base, "cortexkit", "antigravity-auth", "processes");
|
|
@@ -31511,7 +31734,7 @@ function processConfigFolderKey() {
|
|
|
31511
31734
|
try {
|
|
31512
31735
|
return realpathSync.native(folder);
|
|
31513
31736
|
} catch {
|
|
31514
|
-
return
|
|
31737
|
+
return resolve15(folder);
|
|
31515
31738
|
}
|
|
31516
31739
|
}
|
|
31517
31740
|
function processHasOlderGeneration() {
|
|
@@ -31999,7 +32222,7 @@ import {
|
|
|
31999
32222
|
stat as stat11,
|
|
32000
32223
|
unlink as unlink10
|
|
32001
32224
|
} from "node:fs/promises";
|
|
32002
|
-
import { basename as basename4, dirname as dirname15, join as join14, resolve as
|
|
32225
|
+
import { basename as basename4, dirname as dirname15, join as join14, resolve as resolve16 } from "node:path";
|
|
32003
32226
|
function refusalMessage(stateDir, errorClass2) {
|
|
32004
32227
|
if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
|
|
32005
32228
|
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.`;
|
|
@@ -32859,7 +33082,7 @@ async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
|
|
|
32859
33082
|
if (process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR) return;
|
|
32860
33083
|
const location = runtimeLayoutLocation();
|
|
32861
33084
|
const files = layoutFiles(location, accountFile);
|
|
32862
|
-
if (
|
|
33085
|
+
if (resolve16(vaultDir) !== resolve16(files.vault.next)) return;
|
|
32863
33086
|
const stateDir = location.stateHomeDir;
|
|
32864
33087
|
const marker = await readMarker(
|
|
32865
33088
|
join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
@@ -33288,7 +33511,7 @@ import {
|
|
|
33288
33511
|
writeFileSync
|
|
33289
33512
|
} from "node:fs";
|
|
33290
33513
|
import { homedir as homedir4 } from "node:os";
|
|
33291
|
-
import { dirname as dirname16, join as join15, resolve as
|
|
33514
|
+
import { dirname as dirname16, join as join15, resolve as resolve17 } from "node:path";
|
|
33292
33515
|
async function ensureGitignore(configDir) {
|
|
33293
33516
|
const gitignorePath = join15(configDir, ".gitignore");
|
|
33294
33517
|
try {
|
|
@@ -33388,8 +33611,8 @@ function migrateLegacyWindowsConfig() {
|
|
|
33388
33611
|
}
|
|
33389
33612
|
}
|
|
33390
33613
|
function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
33391
|
-
const standard =
|
|
33392
|
-
const legacy =
|
|
33614
|
+
const standard = resolve17(newPath);
|
|
33615
|
+
const legacy = resolve17(legacyPath);
|
|
33393
33616
|
if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
|
|
33394
33617
|
const standardPointer = existsSync4(accountStorePointerPath(standard));
|
|
33395
33618
|
const legacyPointer = existsSync4(accountStorePointerPath(legacy));
|
|
@@ -33411,7 +33634,7 @@ function getStoragePathWithMigration() {
|
|
|
33411
33634
|
"antigravity-accounts.json"
|
|
33412
33635
|
);
|
|
33413
33636
|
const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
|
|
33414
|
-
if (
|
|
33637
|
+
if (resolve17(anchored).toLowerCase() !== resolve17(newPath).toLowerCase() && !existsSync4(accountStorePointerPath(resolve17(anchored)))) {
|
|
33415
33638
|
log6.info("Using legacy Windows config path (migration failed)", {
|
|
33416
33639
|
legacyPath,
|
|
33417
33640
|
newPath
|
|
@@ -33428,7 +33651,7 @@ function accountFileForVault(configDir = getConfigDir()) {
|
|
|
33428
33651
|
const configured = join15(configDir, "antigravity-accounts.json");
|
|
33429
33652
|
if (process.platform !== "win32") return configured;
|
|
33430
33653
|
const legacyDir = getLegacyWindowsConfigDir();
|
|
33431
|
-
if (
|
|
33654
|
+
if (resolve17(configDir).toLowerCase() === resolve17(legacyDir).toLowerCase())
|
|
33432
33655
|
return configured;
|
|
33433
33656
|
const configuredVault = join15(configDir, "antigravity-auth-vault");
|
|
33434
33657
|
const legacyVault = join15(legacyDir, "antigravity-auth-vault");
|
|
@@ -33459,7 +33682,7 @@ function getStoragePath() {
|
|
|
33459
33682
|
}
|
|
33460
33683
|
async function assertLegacyPoolInUse(legacyPath) {
|
|
33461
33684
|
try {
|
|
33462
|
-
await assertLegacyAccountStorageWritable(
|
|
33685
|
+
await assertLegacyAccountStorageWritable(resolve17(legacyPath));
|
|
33463
33686
|
} catch (error) {
|
|
33464
33687
|
throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
|
|
33465
33688
|
}
|
|
@@ -33479,7 +33702,7 @@ function refusalMessage2(admission) {
|
|
|
33479
33702
|
async function bindingOf(options) {
|
|
33480
33703
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
33481
33704
|
const now = options.now ?? (() => Date.now());
|
|
33482
|
-
const legacyPath =
|
|
33705
|
+
const legacyPath = resolve17(options.legacyPath ?? getStoragePath());
|
|
33483
33706
|
return {
|
|
33484
33707
|
legacyPath,
|
|
33485
33708
|
now,
|
|
@@ -33548,7 +33771,7 @@ async function openAccountStore(options) {
|
|
|
33548
33771
|
async function initializeFreshAccountStoreFor(modules, options = {}) {
|
|
33549
33772
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
33550
33773
|
return initializeFreshAccountStore(modules, {
|
|
33551
|
-
legacyPath:
|
|
33774
|
+
legacyPath: resolve17(options.legacyPath ?? getStoragePath()),
|
|
33552
33775
|
now: options.now ?? (() => Date.now())
|
|
33553
33776
|
});
|
|
33554
33777
|
}
|
|
@@ -33626,12 +33849,12 @@ var init_storage = __esm({
|
|
|
33626
33849
|
import { createHash as createHash12 } from "node:crypto";
|
|
33627
33850
|
import { existsSync as existsSync5, promises as fs2, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
|
|
33628
33851
|
import { homedir as homedir5 } from "node:os";
|
|
33629
|
-
import { dirname as dirname17, join as join16, resolve as
|
|
33852
|
+
import { dirname as dirname17, join as join16, resolve as resolve18 } from "node:path";
|
|
33630
33853
|
function configDirIdentity(path5) {
|
|
33631
33854
|
try {
|
|
33632
33855
|
return realpathSync2.native(path5);
|
|
33633
33856
|
} catch {
|
|
33634
|
-
return
|
|
33857
|
+
return resolve18(path5);
|
|
33635
33858
|
}
|
|
33636
33859
|
}
|
|
33637
33860
|
function decisionKey(location) {
|
|
@@ -34084,13 +34307,13 @@ function closeDebugStream(state) {
|
|
|
34084
34307
|
state.logWriter = () => {
|
|
34085
34308
|
};
|
|
34086
34309
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34087
|
-
return new Promise((
|
|
34088
|
-
current.once("close", () =>
|
|
34089
|
-
current.once("error", () =>
|
|
34310
|
+
return new Promise((resolve30) => {
|
|
34311
|
+
current.once("close", () => resolve30());
|
|
34312
|
+
current.once("error", () => resolve30());
|
|
34090
34313
|
try {
|
|
34091
34314
|
current.end();
|
|
34092
34315
|
} catch {
|
|
34093
|
-
|
|
34316
|
+
resolve30();
|
|
34094
34317
|
}
|
|
34095
34318
|
});
|
|
34096
34319
|
}
|
|
@@ -34355,13 +34578,13 @@ function closeDebugLog() {
|
|
|
34355
34578
|
if (!state || !current) return Promise.resolve();
|
|
34356
34579
|
state.logStream = null;
|
|
34357
34580
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34358
|
-
return new Promise((
|
|
34359
|
-
current.once("close", () =>
|
|
34360
|
-
current.once("error", () =>
|
|
34581
|
+
return new Promise((resolve30) => {
|
|
34582
|
+
current.once("close", () => resolve30());
|
|
34583
|
+
current.once("error", () => resolve30());
|
|
34361
34584
|
try {
|
|
34362
34585
|
current.end();
|
|
34363
34586
|
} catch {
|
|
34364
|
-
|
|
34587
|
+
resolve30();
|
|
34365
34588
|
}
|
|
34366
34589
|
});
|
|
34367
34590
|
}
|
|
@@ -34874,12 +35097,12 @@ async function startOAuthListener({
|
|
|
34874
35097
|
let resolveCallback;
|
|
34875
35098
|
let rejectCallback;
|
|
34876
35099
|
let timeoutHandle;
|
|
34877
|
-
const callbackPromise = new Promise((
|
|
35100
|
+
const callbackPromise = new Promise((resolve30, reject) => {
|
|
34878
35101
|
resolveCallback = (url) => {
|
|
34879
35102
|
if (settled) return;
|
|
34880
35103
|
settled = true;
|
|
34881
35104
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
34882
|
-
|
|
35105
|
+
resolve30(url);
|
|
34883
35106
|
};
|
|
34884
35107
|
rejectCallback = (error) => {
|
|
34885
35108
|
if (settled) return;
|
|
@@ -35038,7 +35261,7 @@ async function startOAuthListener({
|
|
|
35038
35261
|
});
|
|
35039
35262
|
});
|
|
35040
35263
|
const bindAddress = getBindAddress();
|
|
35041
|
-
await new Promise((
|
|
35264
|
+
await new Promise((resolve30, reject) => {
|
|
35042
35265
|
const handleError = (error) => {
|
|
35043
35266
|
server.off("error", handleError);
|
|
35044
35267
|
if (error.code === "EADDRINUSE") {
|
|
@@ -35054,7 +35277,7 @@ async function startOAuthListener({
|
|
|
35054
35277
|
server.once("error", handleError);
|
|
35055
35278
|
server.listen(port, bindAddress, () => {
|
|
35056
35279
|
server.off("error", handleError);
|
|
35057
|
-
|
|
35280
|
+
resolve30();
|
|
35058
35281
|
});
|
|
35059
35282
|
});
|
|
35060
35283
|
server.on("error", (error) => {
|
|
@@ -35062,7 +35285,7 @@ async function startOAuthListener({
|
|
|
35062
35285
|
});
|
|
35063
35286
|
return {
|
|
35064
35287
|
waitForCallback: () => callbackPromise,
|
|
35065
|
-
close: () => new Promise((
|
|
35288
|
+
close: () => new Promise((resolve30, reject) => {
|
|
35066
35289
|
server.close((error) => {
|
|
35067
35290
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
35068
35291
|
reject(error);
|
|
@@ -35071,7 +35294,7 @@ async function startOAuthListener({
|
|
|
35071
35294
|
if (!settled) {
|
|
35072
35295
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
35073
35296
|
}
|
|
35074
|
-
|
|
35297
|
+
resolve30();
|
|
35075
35298
|
});
|
|
35076
35299
|
})
|
|
35077
35300
|
};
|
|
@@ -35087,11 +35310,11 @@ var GA_POOL_PASTE_METHOD_ID = "antigravity-auth-pool-paste";
|
|
|
35087
35310
|
var GA_POOL_RECONNECT_METHOD_ID = "antigravity-auth-pool-reconnect";
|
|
35088
35311
|
var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
|
|
35089
35312
|
function abortable(pending, signal) {
|
|
35090
|
-
return new Promise((
|
|
35313
|
+
return new Promise((resolve30, reject) => {
|
|
35091
35314
|
const abort = () => reject(signal.reason);
|
|
35092
35315
|
if (signal.aborted) abort();
|
|
35093
35316
|
else signal.addEventListener("abort", abort, { once: true });
|
|
35094
|
-
void pending.then(
|
|
35317
|
+
void pending.then(resolve30, reject).finally(() => {
|
|
35095
35318
|
signal.removeEventListener("abort", abort);
|
|
35096
35319
|
});
|
|
35097
35320
|
});
|
|
@@ -36409,7 +36632,7 @@ init_runtime_paths();
|
|
|
36409
36632
|
init_logger4();
|
|
36410
36633
|
import { existsSync as existsSync6, readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
36411
36634
|
import { homedir as homedir6 } from "node:os";
|
|
36412
|
-
import { basename as basename5, dirname as dirname18, join as join18, resolve as
|
|
36635
|
+
import { basename as basename5, dirname as dirname18, join as join18, resolve as resolve19 } from "node:path";
|
|
36413
36636
|
|
|
36414
36637
|
// src/plugin/config/schema.ts
|
|
36415
36638
|
import { z } from "zod";
|
|
@@ -36983,7 +37206,7 @@ function createLocationConfig(directory, options) {
|
|
|
36983
37206
|
};
|
|
36984
37207
|
}
|
|
36985
37208
|
function canonicalizeOwnedPath(path5) {
|
|
36986
|
-
const absolute =
|
|
37209
|
+
const absolute = resolve19(path5);
|
|
36987
37210
|
const missing = [];
|
|
36988
37211
|
let current = absolute;
|
|
36989
37212
|
for (; ; ) {
|
|
@@ -37362,7 +37585,7 @@ function createStoreAccountLimits(input2) {
|
|
|
37362
37585
|
|
|
37363
37586
|
// src/plugin/ga-shared-vault-custody.ts
|
|
37364
37587
|
init_dist();
|
|
37365
|
-
import { resolve as
|
|
37588
|
+
import { resolve as resolve20 } from "node:path";
|
|
37366
37589
|
|
|
37367
37590
|
// src/sidebar-state.ts
|
|
37368
37591
|
init_atomic_write();
|
|
@@ -37778,7 +38001,7 @@ function drainSidebarWrites() {
|
|
|
37778
38001
|
return sidebarWriteChain;
|
|
37779
38002
|
}
|
|
37780
38003
|
async function sleep3(ms) {
|
|
37781
|
-
await new Promise((
|
|
38004
|
+
await new Promise((resolve30) => setTimeout(resolve30, ms));
|
|
37782
38005
|
}
|
|
37783
38006
|
async function acquireSidebarLockWithRetry(stateFile) {
|
|
37784
38007
|
const start = Date.now();
|
|
@@ -38337,14 +38560,14 @@ var LocalQuotaGrantStaleError = class extends Error {
|
|
|
38337
38560
|
name = "LocalQuotaGrantStaleError";
|
|
38338
38561
|
};
|
|
38339
38562
|
function untilQuotaAborted(pending, signal) {
|
|
38340
|
-
return new Promise((
|
|
38563
|
+
return new Promise((resolve30, reject) => {
|
|
38341
38564
|
const abort = () => reject(signal.reason);
|
|
38342
38565
|
if (signal.aborted) abort();
|
|
38343
38566
|
else signal.addEventListener("abort", abort, { once: true });
|
|
38344
38567
|
void pending.then(
|
|
38345
38568
|
(value) => {
|
|
38346
38569
|
signal.removeEventListener("abort", abort);
|
|
38347
|
-
|
|
38570
|
+
resolve30(value);
|
|
38348
38571
|
},
|
|
38349
38572
|
(error) => {
|
|
38350
38573
|
signal.removeEventListener("abort", abort);
|
|
@@ -39239,7 +39462,7 @@ init_vault_request_credentials();
|
|
|
39239
39462
|
init_vault_custody();
|
|
39240
39463
|
var shared3 = /* @__PURE__ */ new Map();
|
|
39241
39464
|
function acquireGaVaultCustody(options) {
|
|
39242
|
-
const key = options.layoutRefusal === void 0 ?
|
|
39465
|
+
const key = options.layoutRefusal === void 0 ? resolve20(options.vaultDir) : `unsettled\0${resolve20(options.vaultDir)}`;
|
|
39243
39466
|
let entry = shared3.get(key);
|
|
39244
39467
|
if (!entry) {
|
|
39245
39468
|
const leases = /* @__PURE__ */ new Set();
|
|
@@ -43779,7 +44002,7 @@ function stripUnsupportedAntigravityFields(payload) {
|
|
|
43779
44002
|
}
|
|
43780
44003
|
}
|
|
43781
44004
|
function configureAntigravityToolCalling(payload, wireModel) {
|
|
43782
|
-
if (isGeminiArgonModel(wireModel) || !Array.isArray(payload.tools) || payload.tools.length === 0) {
|
|
44005
|
+
if (isGeminiArgonModel(wireModel) || isGeminiCarbonModel(wireModel) || !Array.isArray(payload.tools) || payload.tools.length === 0) {
|
|
43783
44006
|
delete payload.toolConfig;
|
|
43784
44007
|
return;
|
|
43785
44008
|
}
|
|
@@ -44402,7 +44625,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
44402
44625
|
`[ThinkingResolution] rawModel=${rawModel} resolvedModel=${effectiveModel} resolvedTier=${tierThinkingLevel ?? "none"} variantLevel=${variantConfig?.thinkingLevel ?? "none"} variantBudget=${variantConfig?.thinkingBudget ?? "none"} providerOptions.google=${JSON.stringify(requestPayload.providerOptions?.google ?? null)} generationConfig.thinkingConfig=${JSON.stringify(rawGenerationConfig?.thinkingConfig ?? null)}`
|
|
44403
44626
|
);
|
|
44404
44627
|
delete requestPayload.providerOptions;
|
|
44405
|
-
if (variantConfig?.thinkingLevel && (isGemini3 || isGeminiArgonModel(effectiveModel) || getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking)) {
|
|
44628
|
+
if (variantConfig?.thinkingLevel && (isGemini3 || isGeminiArgonModel(effectiveModel) || isGeminiCarbonModel(effectiveModel) || getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking)) {
|
|
44406
44629
|
const variantModelBase = rawModel.replace(/-preview-customtools$/i, "").replace(/-preview$/i, "").replace(/-(minimal|low|medium|high)$/i, "");
|
|
44407
44630
|
const variantResolved = resolveAntigravityModel(
|
|
44408
44631
|
`${variantModelBase}-${variantConfig.thinkingLevel}`
|
|
@@ -45311,7 +45534,7 @@ function transformAntigravityResponse(...args) {
|
|
|
45311
45534
|
}
|
|
45312
45535
|
|
|
45313
45536
|
// src/plugin/session-context.ts
|
|
45314
|
-
import { resolve as
|
|
45537
|
+
import { resolve as resolve21 } from "node:path";
|
|
45315
45538
|
import { pathToFileURL } from "node:url";
|
|
45316
45539
|
var FALLBACK_SESSION_KEY = "__default__";
|
|
45317
45540
|
function extractOpenCodeSessionIdentity(headers) {
|
|
@@ -45325,7 +45548,7 @@ var AgySessionRegistry = class {
|
|
|
45325
45548
|
requestSessions;
|
|
45326
45549
|
parentSessionIds = /* @__PURE__ */ new Map();
|
|
45327
45550
|
constructor(directory, options = {}) {
|
|
45328
|
-
const workspaceUri = directory ? pathToFileURL(
|
|
45551
|
+
const workspaceUri = directory ? pathToFileURL(resolve21(directory)).href : "";
|
|
45329
45552
|
this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
|
|
45330
45553
|
}
|
|
45331
45554
|
getOrCreate(identity3) {
|
|
@@ -45487,10 +45710,10 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
45487
45710
|
cancellation.release();
|
|
45488
45711
|
throw error;
|
|
45489
45712
|
}
|
|
45490
|
-
let
|
|
45713
|
+
let resolve30 = () => {
|
|
45491
45714
|
};
|
|
45492
45715
|
const settled = new Promise((done) => {
|
|
45493
|
-
|
|
45716
|
+
resolve30 = done;
|
|
45494
45717
|
});
|
|
45495
45718
|
let stopping = false;
|
|
45496
45719
|
let finished = false;
|
|
@@ -45500,7 +45723,7 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
45500
45723
|
finished = true;
|
|
45501
45724
|
cancellation.signal.removeEventListener("abort", abort);
|
|
45502
45725
|
cancellation.release();
|
|
45503
|
-
|
|
45726
|
+
resolve30();
|
|
45504
45727
|
};
|
|
45505
45728
|
const abort = () => {
|
|
45506
45729
|
if (finished || stopping) return;
|
|
@@ -45569,10 +45792,72 @@ function routingHandle(sessionId) {
|
|
|
45569
45792
|
return typeof handle === "object" && handle !== null ? handle : void 0;
|
|
45570
45793
|
}
|
|
45571
45794
|
|
|
45795
|
+
// src/common-auth-embedded/routing-accessor/cache-policy.js
|
|
45796
|
+
var CACHE_WARM_STOP_REASONS = [
|
|
45797
|
+
"cost-cap",
|
|
45798
|
+
"count-cap",
|
|
45799
|
+
"outside-hours",
|
|
45800
|
+
"session-ended",
|
|
45801
|
+
"unsupported"
|
|
45802
|
+
];
|
|
45803
|
+
function isCacheWarmStopReason(value) {
|
|
45804
|
+
return CACHE_WARM_STOP_REASONS.some((reason) => reason === value);
|
|
45805
|
+
}
|
|
45806
|
+
|
|
45572
45807
|
// src/common-auth-embedded/routing-accessor/index.js
|
|
45573
45808
|
function isObject2(value) {
|
|
45574
45809
|
return typeof value === "object" && value !== null;
|
|
45575
45810
|
}
|
|
45811
|
+
function isNonEmptyString(value) {
|
|
45812
|
+
return typeof value === "string" && value.length > 0;
|
|
45813
|
+
}
|
|
45814
|
+
function billingCache(value) {
|
|
45815
|
+
if (!isObject2(value) || Array.isArray(value))
|
|
45816
|
+
return;
|
|
45817
|
+
const { ttlMs, implicit, warming } = value;
|
|
45818
|
+
const cache = {};
|
|
45819
|
+
if (!(ttlMs !== void 0 && implicit !== void 0)) {
|
|
45820
|
+
if (typeof ttlMs === "number" && Number.isSafeInteger(ttlMs) && ttlMs > 0) {
|
|
45821
|
+
cache.ttl_ms = ttlMs;
|
|
45822
|
+
} else if (implicit === true) {
|
|
45823
|
+
cache.implicit = true;
|
|
45824
|
+
}
|
|
45825
|
+
}
|
|
45826
|
+
if (isObject2(warming) && !Array.isArray(warming)) {
|
|
45827
|
+
const { on, stopReason } = warming;
|
|
45828
|
+
if (typeof on === "boolean") {
|
|
45829
|
+
cache.warming = {
|
|
45830
|
+
on,
|
|
45831
|
+
...!on && isCacheWarmStopReason(stopReason) ? { stop_reason: stopReason } : {}
|
|
45832
|
+
};
|
|
45833
|
+
}
|
|
45834
|
+
}
|
|
45835
|
+
return Object.keys(cache).length > 0 ? cache : void 0;
|
|
45836
|
+
}
|
|
45837
|
+
function billingUsage(value) {
|
|
45838
|
+
if (!isObject2(value) || Array.isArray(value))
|
|
45839
|
+
return;
|
|
45840
|
+
const usage = {};
|
|
45841
|
+
for (const [inputKey, payloadKey] of [
|
|
45842
|
+
["input", "input"],
|
|
45843
|
+
["output", "output"],
|
|
45844
|
+
["cacheRead", "cache_read"],
|
|
45845
|
+
["cacheWrite", "cache_write"],
|
|
45846
|
+
["cacheWrite5m", "cache_write_5m"],
|
|
45847
|
+
["cacheWrite1h", "cache_write_1h"],
|
|
45848
|
+
["reasoning", "reasoning"]
|
|
45849
|
+
]) {
|
|
45850
|
+
const count3 = value[inputKey];
|
|
45851
|
+
if (typeof count3 === "number" && Number.isSafeInteger(count3) && count3 >= 0) {
|
|
45852
|
+
usage[payloadKey] = count3;
|
|
45853
|
+
}
|
|
45854
|
+
}
|
|
45855
|
+
const reasoningIncludedInOutput = value.reasoningIncludedInOutput;
|
|
45856
|
+
if (typeof reasoningIncludedInOutput === "boolean") {
|
|
45857
|
+
usage.reasoning_included_in_output = reasoningIncludedInOutput;
|
|
45858
|
+
}
|
|
45859
|
+
return Object.keys(usage).length > 0 ? usage : void 0;
|
|
45860
|
+
}
|
|
45576
45861
|
function selectionFor(answer, candidates) {
|
|
45577
45862
|
if (!isObject2(answer))
|
|
45578
45863
|
return void 0;
|
|
@@ -45604,8 +45889,8 @@ async function askRouting(input2) {
|
|
|
45604
45889
|
return void 0;
|
|
45605
45890
|
const requested = input2.deadlineMs ?? 500;
|
|
45606
45891
|
const deadlineMs = Number.isNaN(requested) ? 500 : Math.min(2e3, Math.max(1, requested));
|
|
45607
|
-
const expired = new Promise((
|
|
45608
|
-
timer = setTimeout(() =>
|
|
45892
|
+
const expired = new Promise((resolve30) => {
|
|
45893
|
+
timer = setTimeout(() => resolve30(void 0), deadlineMs);
|
|
45609
45894
|
timer.unref();
|
|
45610
45895
|
});
|
|
45611
45896
|
const request2 = {
|
|
@@ -45638,6 +45923,47 @@ function reportRouting(input2) {
|
|
|
45638
45923
|
let payload;
|
|
45639
45924
|
if ("kind" in input2) {
|
|
45640
45925
|
switch (input2.kind) {
|
|
45926
|
+
case "billing": {
|
|
45927
|
+
const { attemptId, requestKind, credentialId, provider: provider2, model, outcome, accountId, providerRequestId, providerResponseId, userMessageId, status, attempt, chargeBasis, usage: inputUsage, usageByModel: inputUsageByModel, cache: inputCache } = input2;
|
|
45928
|
+
if (!isNonEmptyString(attemptId) || !isNonEmptyString(credentialId) || !isNonEmptyString(provider2) || !isNonEmptyString(model) || requestKind !== "primary" && requestKind !== "title" && requestKind !== "compaction" && requestKind !== "generate" && requestKind !== "keep_warm" && requestKind !== "prime" || outcome !== "completed" && outcome !== "cut" && outcome !== "failed")
|
|
45929
|
+
return;
|
|
45930
|
+
const usage = billingUsage(inputUsage);
|
|
45931
|
+
const cache = billingCache(inputCache);
|
|
45932
|
+
const usageByModel = [];
|
|
45933
|
+
if (Array.isArray(inputUsageByModel)) {
|
|
45934
|
+
for (const entry of inputUsageByModel) {
|
|
45935
|
+
if (!isObject2(entry) || Array.isArray(entry))
|
|
45936
|
+
continue;
|
|
45937
|
+
const modelUsed = entry.modelUsed;
|
|
45938
|
+
if (!isNonEmptyString(modelUsed))
|
|
45939
|
+
continue;
|
|
45940
|
+
const modelUsage = billingUsage(entry.usage);
|
|
45941
|
+
if (!modelUsage)
|
|
45942
|
+
continue;
|
|
45943
|
+
usageByModel.push({ model_used: modelUsed, usage: modelUsage });
|
|
45944
|
+
}
|
|
45945
|
+
}
|
|
45946
|
+
payload = {
|
|
45947
|
+
kind: "billing",
|
|
45948
|
+
attempt_id: attemptId,
|
|
45949
|
+
request_kind: requestKind,
|
|
45950
|
+
credential_id: credentialId,
|
|
45951
|
+
provider: provider2,
|
|
45952
|
+
model,
|
|
45953
|
+
outcome,
|
|
45954
|
+
...isNonEmptyString(accountId) ? { account_id: accountId } : {},
|
|
45955
|
+
...isNonEmptyString(providerRequestId) ? { provider_request_id: providerRequestId } : {},
|
|
45956
|
+
...isNonEmptyString(providerResponseId) ? { provider_response_id: providerResponseId } : {},
|
|
45957
|
+
...isNonEmptyString(userMessageId) ? { user_message_id: userMessageId } : {},
|
|
45958
|
+
...typeof status === "number" && Number.isInteger(status) && status >= 0 ? { status } : {},
|
|
45959
|
+
...typeof attempt === "number" && Number.isInteger(attempt) && attempt >= 1 ? { attempt } : {},
|
|
45960
|
+
...chargeBasis === "subscription_included" || chargeBasis === "metered_api" ? { charge_basis: chargeBasis } : {},
|
|
45961
|
+
...usage ? { usage } : {},
|
|
45962
|
+
...usageByModel.length > 0 ? { usage_by_model: usageByModel } : {},
|
|
45963
|
+
...cache ? { cache } : {}
|
|
45964
|
+
};
|
|
45965
|
+
break;
|
|
45966
|
+
}
|
|
45641
45967
|
case "turn_notes_supported": {
|
|
45642
45968
|
const { model, supported } = input2;
|
|
45643
45969
|
if (typeof model !== "string" || model.length === 0 || typeof supported !== "boolean")
|
|
@@ -46177,8 +46503,8 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
46177
46503
|
let running = false;
|
|
46178
46504
|
let resolveCompletion = () => {
|
|
46179
46505
|
};
|
|
46180
|
-
const completion = new Promise((
|
|
46181
|
-
resolveCompletion =
|
|
46506
|
+
const completion = new Promise((resolve30) => {
|
|
46507
|
+
resolveCompletion = resolve30;
|
|
46182
46508
|
});
|
|
46183
46509
|
const finish = () => {
|
|
46184
46510
|
if (finished) return;
|
|
@@ -46225,14 +46551,14 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
46225
46551
|
};
|
|
46226
46552
|
}
|
|
46227
46553
|
function publishResponse(dispatch) {
|
|
46228
|
-
return new Promise((
|
|
46554
|
+
return new Promise((resolve30, reject) => {
|
|
46229
46555
|
let acknowledge;
|
|
46230
46556
|
void Promise.resolve().then(
|
|
46231
46557
|
() => dispatch((callback) => {
|
|
46232
46558
|
acknowledge = callback;
|
|
46233
46559
|
})
|
|
46234
46560
|
).then((response) => {
|
|
46235
|
-
|
|
46561
|
+
resolve30(response);
|
|
46236
46562
|
acknowledge?.();
|
|
46237
46563
|
}, reject);
|
|
46238
46564
|
});
|
|
@@ -46502,7 +46828,7 @@ function formatWaitTime(ms) {
|
|
|
46502
46828
|
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
|
|
46503
46829
|
}
|
|
46504
46830
|
function sleep4(ms, signal) {
|
|
46505
|
-
return new Promise((
|
|
46831
|
+
return new Promise((resolve30, reject) => {
|
|
46506
46832
|
if (signal?.aborted) {
|
|
46507
46833
|
reject(
|
|
46508
46834
|
signal.reason instanceof Error ? signal.reason : new Error("Aborted")
|
|
@@ -46512,7 +46838,7 @@ function sleep4(ms, signal) {
|
|
|
46512
46838
|
const timerMs = Math.min(Math.max(0, Math.floor(ms)), 2147483647);
|
|
46513
46839
|
const timeout = setTimeout(() => {
|
|
46514
46840
|
cleanup2();
|
|
46515
|
-
|
|
46841
|
+
resolve30();
|
|
46516
46842
|
}, timerMs);
|
|
46517
46843
|
const onAbort = () => {
|
|
46518
46844
|
cleanup2();
|
|
@@ -49717,6 +50043,10 @@ function createGaMenuCommandService(input2) {
|
|
|
49717
50043
|
);
|
|
49718
50044
|
if (signal.aborted) throw abortError(signal);
|
|
49719
50045
|
input2.notify(scope, payload);
|
|
50046
|
+
if (!input2.isConnected(scope))
|
|
50047
|
+
throw new Error(
|
|
50048
|
+
"No Antigravity window is showing this session\u2019s folder."
|
|
50049
|
+
);
|
|
49720
50050
|
}
|
|
49721
50051
|
};
|
|
49722
50052
|
}
|
|
@@ -49738,7 +50068,7 @@ function createGaReauthorize(input2) {
|
|
|
49738
50068
|
const continuations = /* @__PURE__ */ new Set();
|
|
49739
50069
|
const shutdown = new AbortController();
|
|
49740
50070
|
let disposed = false;
|
|
49741
|
-
const waitForRedirect = (code2) => new Promise((
|
|
50071
|
+
const waitForRedirect = (code2) => new Promise((resolve30, reject) => {
|
|
49742
50072
|
const detach = () => shutdown.signal.removeEventListener("abort", abort);
|
|
49743
50073
|
const abort = () => {
|
|
49744
50074
|
detach();
|
|
@@ -49749,7 +50079,7 @@ function createGaReauthorize(input2) {
|
|
|
49749
50079
|
void code2.then(
|
|
49750
50080
|
(value) => {
|
|
49751
50081
|
detach();
|
|
49752
|
-
|
|
50082
|
+
resolve30(value);
|
|
49753
50083
|
},
|
|
49754
50084
|
(error) => {
|
|
49755
50085
|
detach();
|
|
@@ -50470,6 +50800,7 @@ async function createGaVaultLocationServices(input2) {
|
|
|
50470
50800
|
commands: createGaMenuCommandService({
|
|
50471
50801
|
menu,
|
|
50472
50802
|
notify: start.notify,
|
|
50803
|
+
isConnected: start.isConnected,
|
|
50473
50804
|
afterApply: () => input2.afterApply ? input2.afterApply() : started.refreshAccounts()
|
|
50474
50805
|
})
|
|
50475
50806
|
};
|
|
@@ -50767,7 +51098,8 @@ function createGaLocationServicesFactory(bindings) {
|
|
|
50767
51098
|
},
|
|
50768
51099
|
commands: createGaMenuCommandService({
|
|
50769
51100
|
menu: recoveryMenu,
|
|
50770
|
-
notify: input2.notify
|
|
51101
|
+
notify: input2.notify,
|
|
51102
|
+
isConnected: input2.isConnected
|
|
50771
51103
|
})
|
|
50772
51104
|
};
|
|
50773
51105
|
const local = () => {
|
|
@@ -50926,6 +51258,7 @@ ${GA_POOL_PASTE_PROMPT}, or wait for the browser to finish.`;
|
|
|
50926
51258
|
commands: createGaMenuCommandService({
|
|
50927
51259
|
menu,
|
|
50928
51260
|
notify: input2.notify,
|
|
51261
|
+
isConnected: input2.isConnected,
|
|
50929
51262
|
afterApply: () => refreshSelectedSource()
|
|
50930
51263
|
}),
|
|
50931
51264
|
execute: started2.execute
|
|
@@ -52914,11 +53247,11 @@ async function startGaLoopbackBridge(options) {
|
|
|
52914
53247
|
}
|
|
52915
53248
|
}
|
|
52916
53249
|
};
|
|
52917
|
-
await new Promise((
|
|
53250
|
+
await new Promise((resolve30, reject) => {
|
|
52918
53251
|
server.once("error", reject);
|
|
52919
53252
|
server.listen(0, BRIDGE_HOST, () => {
|
|
52920
53253
|
server.off("error", reject);
|
|
52921
|
-
|
|
53254
|
+
resolve30();
|
|
52922
53255
|
});
|
|
52923
53256
|
});
|
|
52924
53257
|
server.unref();
|
|
@@ -53022,8 +53355,8 @@ async function startGaLoopbackBridge(options) {
|
|
|
53022
53355
|
disposal = (async () => {
|
|
53023
53356
|
for (const { timer } of queued.values()) clearTimeout(timer);
|
|
53024
53357
|
queued.clear();
|
|
53025
|
-
const closed2 = new Promise((
|
|
53026
|
-
server.close(() =>
|
|
53358
|
+
const closed2 = new Promise((resolve30) => {
|
|
53359
|
+
server.close(() => resolve30());
|
|
53027
53360
|
});
|
|
53028
53361
|
for (const controller of running) {
|
|
53029
53362
|
controller.abort(
|
|
@@ -53089,9 +53422,9 @@ async function pipeResponse(upstream, response, onFailure, onHandoff) {
|
|
|
53089
53422
|
return;
|
|
53090
53423
|
}
|
|
53091
53424
|
if (!response.write(value) && !response.destroyed) {
|
|
53092
|
-
await new Promise((
|
|
53093
|
-
response.once("drain",
|
|
53094
|
-
response.once("close",
|
|
53425
|
+
await new Promise((resolve30) => {
|
|
53426
|
+
response.once("drain", resolve30);
|
|
53427
|
+
response.once("close", resolve30);
|
|
53095
53428
|
});
|
|
53096
53429
|
}
|
|
53097
53430
|
if (response.destroyed) {
|
|
@@ -53769,13 +54102,13 @@ function createGaAntigravityPlugin(overrides = {}) {
|
|
|
53769
54102
|
// src/plugin/index.ts
|
|
53770
54103
|
init_dist();
|
|
53771
54104
|
import { createHash as createHash24, randomUUID as randomUUID22 } from "node:crypto";
|
|
53772
|
-
import { join as join39, resolve as
|
|
54105
|
+
import { join as join39, resolve as resolve29 } from "node:path";
|
|
53773
54106
|
|
|
53774
54107
|
// src/cli.ts
|
|
53775
54108
|
init_dist();
|
|
53776
54109
|
import { execFile } from "node:child_process";
|
|
53777
54110
|
import { realpathSync as realpathSync5 } from "node:fs";
|
|
53778
|
-
import { resolve as
|
|
54111
|
+
import { resolve as resolve26 } from "node:path";
|
|
53779
54112
|
import { createInterface } from "node:readline/promises";
|
|
53780
54113
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
53781
54114
|
import { promisify } from "node:util";
|
|
@@ -53832,7 +54165,7 @@ init_runtime_paths();
|
|
|
53832
54165
|
// src/setup.ts
|
|
53833
54166
|
init_dist();
|
|
53834
54167
|
import { lstat as lstat9, readFile as readFile16 } from "node:fs/promises";
|
|
53835
|
-
import { join as join30, resolve as
|
|
54168
|
+
import { join as join30, resolve as resolve25 } from "node:path";
|
|
53836
54169
|
|
|
53837
54170
|
// src/common-auth-embedded/auth-menu/ansi.js
|
|
53838
54171
|
var ANSI2 = {
|
|
@@ -54000,7 +54333,7 @@ async function select2(terminal, items, options) {
|
|
|
54000
54333
|
writeLine("");
|
|
54001
54334
|
renderedLines = lines;
|
|
54002
54335
|
};
|
|
54003
|
-
return new Promise((
|
|
54336
|
+
return new Promise((resolve30) => {
|
|
54004
54337
|
const wasRaw = stdin.isRaw ?? false;
|
|
54005
54338
|
const cleanup2 = () => {
|
|
54006
54339
|
if (cleaned)
|
|
@@ -54020,7 +54353,7 @@ async function select2(terminal, items, options) {
|
|
|
54020
54353
|
};
|
|
54021
54354
|
const finish = (value) => {
|
|
54022
54355
|
cleanup2();
|
|
54023
|
-
|
|
54356
|
+
resolve30(value);
|
|
54024
54357
|
};
|
|
54025
54358
|
const onSignal = () => finish(null);
|
|
54026
54359
|
const onKey = (data) => {
|
|
@@ -54060,7 +54393,7 @@ async function select2(terminal, items, options) {
|
|
|
54060
54393
|
stdin.setRawMode(true);
|
|
54061
54394
|
} catch {
|
|
54062
54395
|
cleanup2();
|
|
54063
|
-
|
|
54396
|
+
resolve30(null);
|
|
54064
54397
|
return;
|
|
54065
54398
|
}
|
|
54066
54399
|
stdin.resume();
|
|
@@ -54074,12 +54407,12 @@ async function select2(terminal, items, options) {
|
|
|
54074
54407
|
import { createHash as createHash19, randomBytes as randomBytes6, randomUUID as randomUUID19 } from "node:crypto";
|
|
54075
54408
|
import { constants as fsConstants2 } from "node:fs";
|
|
54076
54409
|
import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as stat14, unlink as unlink11 } from "node:fs/promises";
|
|
54077
|
-
import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute4, join as join26, resolve as
|
|
54410
|
+
import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute4, join as join26, resolve as resolve24 } from "node:path";
|
|
54078
54411
|
import { ClaustrumCredentialError as ClaustrumCredentialError9, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
54079
54412
|
|
|
54080
54413
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
54081
54414
|
import { lstat as lstat7, stat as stat12 } from "node:fs/promises";
|
|
54082
|
-
import { resolve as
|
|
54415
|
+
import { resolve as resolve22 } from "node:path";
|
|
54083
54416
|
async function identity2(path5, followSymlinks) {
|
|
54084
54417
|
try {
|
|
54085
54418
|
const metadata = await (followSymlinks ? stat12(path5) : lstat7(path5));
|
|
@@ -54100,7 +54433,7 @@ var FileReadCache2 = class {
|
|
|
54100
54433
|
this.#followSymlinks = options.followSymlinks ?? false;
|
|
54101
54434
|
}
|
|
54102
54435
|
async read(paths, read, validateHit) {
|
|
54103
|
-
const resolvedPaths = paths.map((path5) =>
|
|
54436
|
+
const resolvedPaths = paths.map((path5) => resolve22(path5));
|
|
54104
54437
|
const key = JSON.stringify(resolvedPaths);
|
|
54105
54438
|
const probed = await Promise.all(resolvedPaths.map((path5) => identity2(path5, this.#followSymlinks)));
|
|
54106
54439
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -54149,11 +54482,46 @@ var WRITER_LOCK_CONSTANTS2 = Object.freeze({
|
|
|
54149
54482
|
init_private_files2();
|
|
54150
54483
|
|
|
54151
54484
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
54152
|
-
init_private_files2();
|
|
54153
54485
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
54154
54486
|
import { link as link3, lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as stat13 } from "node:fs/promises";
|
|
54155
54487
|
import { dirname as dirname21, join as join25 } from "node:path";
|
|
54156
54488
|
|
|
54489
|
+
// src/common-auth-embedded/fs/lock-record.js
|
|
54490
|
+
init_private_files2();
|
|
54491
|
+
import { resolve as resolve23 } from "node:path";
|
|
54492
|
+
var DisappearedLockRecordError2 = class extends Error {
|
|
54493
|
+
path;
|
|
54494
|
+
code = "ENOENT";
|
|
54495
|
+
constructor(path5, cause) {
|
|
54496
|
+
super(`Lock record disappeared: ${path5}`, { cause });
|
|
54497
|
+
this.path = path5;
|
|
54498
|
+
}
|
|
54499
|
+
};
|
|
54500
|
+
function isWindowsAccessDeniedRead2(error, paths) {
|
|
54501
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path5) => resolve23(path5) === error.path);
|
|
54502
|
+
}
|
|
54503
|
+
function isWindowsAccessDeniedCreate2(error, paths, stage) {
|
|
54504
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path5) => resolve23(path5) === error.path);
|
|
54505
|
+
}
|
|
54506
|
+
async function readLockRecord2(path5, read) {
|
|
54507
|
+
try {
|
|
54508
|
+
return await read();
|
|
54509
|
+
} catch (error) {
|
|
54510
|
+
if (!isWindowsAccessDeniedRead2(error, [path5]))
|
|
54511
|
+
throw error;
|
|
54512
|
+
try {
|
|
54513
|
+
return await read();
|
|
54514
|
+
} catch (recheckError) {
|
|
54515
|
+
if (recheckError.code === "ENOENT")
|
|
54516
|
+
throw new DisappearedLockRecordError2(path5, error);
|
|
54517
|
+
throw error;
|
|
54518
|
+
}
|
|
54519
|
+
}
|
|
54520
|
+
}
|
|
54521
|
+
|
|
54522
|
+
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
54523
|
+
init_private_files2();
|
|
54524
|
+
|
|
54157
54525
|
// src/common-auth-embedded/fs/with-lock.js
|
|
54158
54526
|
init_private_files2();
|
|
54159
54527
|
function lockPathFor2(target, name) {
|
|
@@ -54252,8 +54620,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54252
54620
|
let releaseConfirmed = false;
|
|
54253
54621
|
let loss;
|
|
54254
54622
|
let resolveLoss;
|
|
54255
|
-
const lostPromise = new Promise((
|
|
54256
|
-
resolveLoss =
|
|
54623
|
+
const lostPromise = new Promise((resolve30) => {
|
|
54624
|
+
resolveLoss = resolve30;
|
|
54257
54625
|
});
|
|
54258
54626
|
function notifyTimerStep(event) {
|
|
54259
54627
|
try {
|
|
@@ -54291,15 +54659,18 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54291
54659
|
const evictOwnerId = randomUUID18();
|
|
54292
54660
|
const EVICT_TTL = 5e3;
|
|
54293
54661
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
54662
|
+
function isChangingLockCreate(error) {
|
|
54663
|
+
return windowsPrivateFiles2 && (isWindowsAccessDeniedCreate2(error, [lockPath], "create") || isWindowsAccessDeniedCreate2(error, [evictPath], "directory-create"));
|
|
54664
|
+
}
|
|
54294
54665
|
async function readOwner() {
|
|
54295
54666
|
if (windowsPrivateFiles2) {
|
|
54296
54667
|
try {
|
|
54297
|
-
return JSON.parse(await readPrivateText2(lockPath, true));
|
|
54668
|
+
return JSON.parse(await readLockRecord2(lockPath, () => readPrivateText2(lockPath, true)));
|
|
54298
54669
|
} catch (error) {
|
|
54299
54670
|
if (error.code !== "EISDIR" && error.reason !== "wrong-kind")
|
|
54300
54671
|
throw error;
|
|
54301
|
-
await verifyPrivate2(lockPath, "directory", true);
|
|
54302
|
-
return JSON.parse(await readPrivateText2(legacyOwnerPath, true));
|
|
54672
|
+
await readLockRecord2(lockPath, () => verifyPrivate2(lockPath, "directory", true));
|
|
54673
|
+
return JSON.parse(await readLockRecord2(legacyOwnerPath, () => readPrivateText2(legacyOwnerPath, true)));
|
|
54303
54674
|
}
|
|
54304
54675
|
}
|
|
54305
54676
|
try {
|
|
@@ -54375,8 +54746,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54375
54746
|
await options.onStep("lease-contention-read-ready");
|
|
54376
54747
|
try {
|
|
54377
54748
|
if (code2 === "EISDIR") {
|
|
54378
|
-
await verifyPrivate2(lockPath, "directory", true);
|
|
54379
|
-
await readPrivateText2(legacyOwnerPath, true);
|
|
54749
|
+
await readLockRecord2(lockPath, () => verifyPrivate2(lockPath, "directory", true));
|
|
54750
|
+
await readLockRecord2(legacyOwnerPath, () => readPrivateText2(legacyOwnerPath, true));
|
|
54380
54751
|
} else
|
|
54381
54752
|
await readOwner();
|
|
54382
54753
|
} catch (readError) {
|
|
@@ -54414,7 +54785,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54414
54785
|
}
|
|
54415
54786
|
}
|
|
54416
54787
|
async function backoff() {
|
|
54417
|
-
await new Promise((
|
|
54788
|
+
await new Promise((resolve30) => setTimeout(resolve30, Math.floor(Math.random() * 4)));
|
|
54418
54789
|
}
|
|
54419
54790
|
async function readLockState(notifyReady = true) {
|
|
54420
54791
|
if (notifyReady && options.onStep)
|
|
@@ -54423,6 +54794,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54423
54794
|
try {
|
|
54424
54795
|
owner = await readOwner();
|
|
54425
54796
|
} catch (error) {
|
|
54797
|
+
if (error instanceof DisappearedLockRecordError2)
|
|
54798
|
+
return { status: "missing" };
|
|
54426
54799
|
if (windowsPrivateFiles2 && error.code !== "ENOENT")
|
|
54427
54800
|
throw error;
|
|
54428
54801
|
}
|
|
@@ -54470,7 +54843,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54470
54843
|
}
|
|
54471
54844
|
async function ownsEvictionMarker() {
|
|
54472
54845
|
try {
|
|
54473
|
-
const owner = JSON.parse(await readPrivateText2(evictOwnerPath, windowsPrivateFiles2));
|
|
54846
|
+
const owner = JSON.parse(await readLockRecord2(evictOwnerPath, () => readPrivateText2(evictOwnerPath, windowsPrivateFiles2)));
|
|
54474
54847
|
return owner?.ownerId === evictOwnerId;
|
|
54475
54848
|
} catch (error) {
|
|
54476
54849
|
if (windowsPrivateFiles2 && error.code !== "ENOENT")
|
|
@@ -54505,7 +54878,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54505
54878
|
const remainingMs = deadline - performance.now();
|
|
54506
54879
|
if (remainingMs <= 0)
|
|
54507
54880
|
throw original;
|
|
54508
|
-
await new Promise((
|
|
54881
|
+
await new Promise((resolve30) => setTimeout(resolve30, Math.min(delayMs, remainingMs)));
|
|
54509
54882
|
if (performance.now() >= deadline)
|
|
54510
54883
|
throw original;
|
|
54511
54884
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -54609,7 +54982,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54609
54982
|
}
|
|
54610
54983
|
if (windowsPrivateFiles2) {
|
|
54611
54984
|
try {
|
|
54612
|
-
await verifyPrivate2(evictPath, "directory", true);
|
|
54985
|
+
await readLockRecord2(evictPath, () => verifyPrivate2(evictPath, "directory", true));
|
|
54613
54986
|
} catch (error) {
|
|
54614
54987
|
if (error.code === "ENOENT")
|
|
54615
54988
|
return "missing";
|
|
@@ -54664,8 +55037,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54664
55037
|
if (error.code === "EEXIST") {
|
|
54665
55038
|
if (windowsPrivateFiles2) {
|
|
54666
55039
|
try {
|
|
54667
|
-
await verifyPrivate2(evictPath, "directory", true);
|
|
54668
|
-
await readPrivateText2(evictOwnerPath, true);
|
|
55040
|
+
await readLockRecord2(evictPath, () => verifyPrivate2(evictPath, "directory", true));
|
|
55041
|
+
await readLockRecord2(evictOwnerPath, () => readPrivateText2(evictOwnerPath, true));
|
|
54669
55042
|
} catch (ownerError) {
|
|
54670
55043
|
if (ownerError.code !== "ENOENT")
|
|
54671
55044
|
throw ownerError;
|
|
@@ -54686,7 +55059,11 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54686
55059
|
try {
|
|
54687
55060
|
await releaseEvictionMarker(deadline);
|
|
54688
55061
|
} catch (error) {
|
|
54689
|
-
if (isRetryableRemoval(actionError, lockPath)
|
|
55062
|
+
if ((isRetryableRemoval(actionError, lockPath) || isWindowsAccessDeniedRead2(actionError, [
|
|
55063
|
+
lockPath,
|
|
55064
|
+
legacyOwnerPath,
|
|
55065
|
+
evictOwnerPath
|
|
55066
|
+
])) && (isRetryableRemoval(error, evictPath) || isWindowsAccessDeniedRead2(error, [evictOwnerPath])))
|
|
54690
55067
|
throw actionError;
|
|
54691
55068
|
throw error;
|
|
54692
55069
|
}
|
|
@@ -54702,7 +55079,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54702
55079
|
try {
|
|
54703
55080
|
owner = await readOwner();
|
|
54704
55081
|
} catch (error) {
|
|
54705
|
-
if (windowsPrivateFiles2)
|
|
55082
|
+
if (windowsPrivateFiles2 && !(error instanceof DisappearedLockRecordError2))
|
|
54706
55083
|
throw error;
|
|
54707
55084
|
return;
|
|
54708
55085
|
}
|
|
@@ -54780,7 +55157,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54780
55157
|
await options.onStep("renewal-marker-unavailable");
|
|
54781
55158
|
}
|
|
54782
55159
|
} catch (error) {
|
|
54783
|
-
if (windowsPrivateFiles2 && error instanceof PrivateFileError2) {
|
|
55160
|
+
if (windowsPrivateFiles2 && error instanceof PrivateFileError2 && !isChangingLockCreate(error)) {
|
|
54784
55161
|
terminalIOError = error;
|
|
54785
55162
|
recordLoss("renewal-failed");
|
|
54786
55163
|
shouldReschedule = false;
|
|
@@ -54826,72 +55203,90 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54826
55203
|
}
|
|
54827
55204
|
return null;
|
|
54828
55205
|
}
|
|
54829
|
-
let acquired =
|
|
55206
|
+
let acquired = false;
|
|
55207
|
+
let changingCreateError;
|
|
55208
|
+
try {
|
|
55209
|
+
acquired = await tryAcquire();
|
|
55210
|
+
} catch (error) {
|
|
55211
|
+
if (!isChangingLockCreate(error))
|
|
55212
|
+
throw error;
|
|
55213
|
+
changingCreateError = error;
|
|
55214
|
+
}
|
|
54830
55215
|
if (!acquired) {
|
|
54831
55216
|
for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
|
|
54832
|
-
acquired = await tryAcquire();
|
|
54833
|
-
if (acquired)
|
|
54834
|
-
break;
|
|
54835
|
-
const observed = await readLockState();
|
|
54836
|
-
if (observed.status === "live")
|
|
54837
|
-
return contended();
|
|
54838
|
-
if (observed.status === "missing")
|
|
54839
|
-
continue;
|
|
54840
|
-
if (options.onStep)
|
|
54841
|
-
await options.onStep("stale-lock-observed");
|
|
54842
55217
|
try {
|
|
54843
|
-
|
|
54844
|
-
|
|
54845
|
-
|
|
54846
|
-
|
|
54847
|
-
|
|
54848
|
-
const code2 = evictError.code;
|
|
54849
|
-
if (code2 !== "EEXIST")
|
|
54850
|
-
throw evictError;
|
|
54851
|
-
const recovered = await recoverStaleEvictionMarker();
|
|
54852
|
-
if (recovered === "fresh")
|
|
54853
|
-
return null;
|
|
54854
|
-
await backoff();
|
|
54855
|
-
continue;
|
|
54856
|
-
}
|
|
54857
|
-
try {
|
|
54858
|
-
const confirmed = await readLockState();
|
|
54859
|
-
if (confirmed.status === "live")
|
|
55218
|
+
acquired = await tryAcquire();
|
|
55219
|
+
if (acquired)
|
|
55220
|
+
break;
|
|
55221
|
+
const observed = await readLockState();
|
|
55222
|
+
if (observed.status === "live")
|
|
54860
55223
|
return contended();
|
|
54861
|
-
if (
|
|
55224
|
+
if (observed.status === "missing")
|
|
54862
55225
|
continue;
|
|
54863
|
-
if (!await ownsEvictionMarker())
|
|
54864
|
-
return null;
|
|
54865
55226
|
if (options.onStep)
|
|
54866
|
-
await options.onStep("stale-lock-
|
|
54867
|
-
|
|
54868
|
-
|
|
54869
|
-
|
|
54870
|
-
|
|
55227
|
+
await options.onStep("stale-lock-observed");
|
|
55228
|
+
try {
|
|
55229
|
+
if (!await tryAcquireEvictionMarker()) {
|
|
55230
|
+
await backoff();
|
|
55231
|
+
continue;
|
|
55232
|
+
}
|
|
55233
|
+
} catch (evictError) {
|
|
55234
|
+
const code2 = evictError.code;
|
|
55235
|
+
if (code2 !== "EEXIST")
|
|
55236
|
+
throw evictError;
|
|
55237
|
+
const recovered = await recoverStaleEvictionMarker();
|
|
55238
|
+
if (recovered === "fresh")
|
|
55239
|
+
return null;
|
|
55240
|
+
await backoff();
|
|
54871
55241
|
continue;
|
|
54872
|
-
await removeLeaseObject(lockPath);
|
|
54873
|
-
if (!await ownsEvictionMarker())
|
|
54874
|
-
return null;
|
|
54875
|
-
if (options.onStep)
|
|
54876
|
-
await options.onStep("stale-lock-removed");
|
|
54877
|
-
acquired = await tryAcquire();
|
|
54878
|
-
if (!acquired)
|
|
54879
|
-
return null;
|
|
54880
|
-
if (options.onStep)
|
|
54881
|
-
await options.onStep("stale-lock-recreated");
|
|
54882
|
-
if (!await ownsEvictionMarker()) {
|
|
54883
|
-
await relinquishLockAfterMarkerLoss();
|
|
54884
|
-
acquired = false;
|
|
54885
|
-
return null;
|
|
54886
55242
|
}
|
|
54887
|
-
|
|
54888
|
-
|
|
54889
|
-
|
|
55243
|
+
try {
|
|
55244
|
+
const confirmed = await readLockState();
|
|
55245
|
+
if (confirmed.status === "live")
|
|
55246
|
+
return contended();
|
|
55247
|
+
if (!sameStaleLock(observed.identity, confirmed))
|
|
55248
|
+
continue;
|
|
55249
|
+
if (!await ownsEvictionMarker())
|
|
55250
|
+
return null;
|
|
55251
|
+
if (options.onStep)
|
|
55252
|
+
await options.onStep("stale-lock-confirmed");
|
|
55253
|
+
if (!await ownsEvictionMarker())
|
|
55254
|
+
return null;
|
|
55255
|
+
const current = await readLockState(false);
|
|
55256
|
+
if (!sameStaleLock(observed.identity, current))
|
|
55257
|
+
continue;
|
|
55258
|
+
await removeLeaseObject(lockPath);
|
|
55259
|
+
if (!await ownsEvictionMarker())
|
|
55260
|
+
return null;
|
|
55261
|
+
if (options.onStep)
|
|
55262
|
+
await options.onStep("stale-lock-removed");
|
|
55263
|
+
acquired = await tryAcquire();
|
|
55264
|
+
if (!acquired)
|
|
55265
|
+
return null;
|
|
55266
|
+
if (options.onStep)
|
|
55267
|
+
await options.onStep("stale-lock-recreated");
|
|
55268
|
+
if (!await ownsEvictionMarker()) {
|
|
55269
|
+
await relinquishLockAfterMarkerLoss();
|
|
55270
|
+
acquired = false;
|
|
55271
|
+
return null;
|
|
55272
|
+
}
|
|
55273
|
+
break;
|
|
55274
|
+
} finally {
|
|
55275
|
+
await releaseEvictionMarker();
|
|
55276
|
+
}
|
|
55277
|
+
} catch (error) {
|
|
55278
|
+
if (!isChangingLockCreate(error))
|
|
55279
|
+
throw error;
|
|
55280
|
+
changingCreateError ??= error;
|
|
55281
|
+
await backoff();
|
|
54890
55282
|
}
|
|
54891
55283
|
}
|
|
54892
55284
|
}
|
|
54893
|
-
if (!acquired)
|
|
55285
|
+
if (!acquired) {
|
|
55286
|
+
if (changingCreateError)
|
|
55287
|
+
throw changingCreateError;
|
|
54894
55288
|
return null;
|
|
55289
|
+
}
|
|
54895
55290
|
scheduleRenewal();
|
|
54896
55291
|
return {
|
|
54897
55292
|
ownerId,
|
|
@@ -54929,6 +55324,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54929
55324
|
const deadline = performance.now() + EVICT_TTL + 1e3;
|
|
54930
55325
|
let delayMs = 5;
|
|
54931
55326
|
let removalError;
|
|
55327
|
+
let changingRecordError;
|
|
54932
55328
|
for (; ; ) {
|
|
54933
55329
|
try {
|
|
54934
55330
|
let removalConfirmed = false;
|
|
@@ -54954,6 +55350,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54954
55350
|
await removeLeaseObject(lockPath);
|
|
54955
55351
|
removalConfirmed = true;
|
|
54956
55352
|
}, deadline);
|
|
55353
|
+
changingRecordError = void 0;
|
|
54957
55354
|
if (markerAcquired) {
|
|
54958
55355
|
if (windowsPrivateFiles2 && !removalConfirmed)
|
|
54959
55356
|
throw new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
@@ -54966,23 +55363,32 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54966
55363
|
return;
|
|
54967
55364
|
await recoverStaleEvictionMarker(deadline);
|
|
54968
55365
|
} catch (error) {
|
|
54969
|
-
|
|
55366
|
+
const changingRecord = windowsPrivateFiles2 && (isChangingLockCreate(error) || isWindowsAccessDeniedRead2(error, [
|
|
55367
|
+
lockPath,
|
|
55368
|
+
legacyOwnerPath,
|
|
55369
|
+
evictPath,
|
|
55370
|
+
evictOwnerPath
|
|
55371
|
+
]));
|
|
55372
|
+
if (!isRetryableRemoval(error, lockPath) && !changingRecord) {
|
|
54970
55373
|
if (windowsPrivateFiles2)
|
|
54971
55374
|
throw error;
|
|
54972
55375
|
return;
|
|
54973
55376
|
}
|
|
54974
|
-
|
|
55377
|
+
if (changingRecord)
|
|
55378
|
+
changingRecordError ??= error;
|
|
55379
|
+
else
|
|
55380
|
+
removalError ??= error;
|
|
54975
55381
|
}
|
|
54976
55382
|
const remainingMs = deadline - performance.now();
|
|
54977
55383
|
if (remainingMs <= 0)
|
|
54978
55384
|
break;
|
|
54979
|
-
await new Promise((
|
|
55385
|
+
await new Promise((resolve30) => setTimeout(resolve30, Math.min(delayMs, remainingMs)));
|
|
54980
55386
|
if (windowsPrivateFiles2 && performance.now() >= deadline)
|
|
54981
55387
|
break;
|
|
54982
55388
|
delayMs = Math.min(delayMs * 2, 50);
|
|
54983
55389
|
}
|
|
54984
55390
|
if (windowsPrivateFiles2)
|
|
54985
|
-
throw removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
55391
|
+
throw changingRecordError ?? removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
54986
55392
|
code: "ETIMEDOUT"
|
|
54987
55393
|
});
|
|
54988
55394
|
}
|
|
@@ -55122,6 +55528,10 @@ function classifyEnrollmentError2(error) {
|
|
|
55122
55528
|
disposition: error.action === "retry" ? "retry" : "terminal"
|
|
55123
55529
|
};
|
|
55124
55530
|
}
|
|
55531
|
+
function validEnrollmentDisplayName2(displayName) {
|
|
55532
|
+
const length = Array.from(displayName).length;
|
|
55533
|
+
return length >= 1 && length <= 40 && !/[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\u200b-\u200d\u2060\ufeff]/u.test(displayName);
|
|
55534
|
+
}
|
|
55125
55535
|
function connectClaustrumEnrollmentClient2(options) {
|
|
55126
55536
|
return ClaustrumWireClient2.connect(options);
|
|
55127
55537
|
}
|
|
@@ -55137,7 +55547,7 @@ function hostEnrollmentPaths2(input2) {
|
|
|
55137
55547
|
const override = input2.override?.trim();
|
|
55138
55548
|
if (override && !isAbsolute4(override) && !input2.cwd)
|
|
55139
55549
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
55140
|
-
const tokenPath = override ? isAbsolute4(override) ? override :
|
|
55550
|
+
const tokenPath = override ? isAbsolute4(override) ? override : resolve24(input2.cwd, override) : join26(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
55141
55551
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
55142
55552
|
}
|
|
55143
55553
|
function isRecord11(value) {
|
|
@@ -55498,15 +55908,19 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
55498
55908
|
#client;
|
|
55499
55909
|
#paths;
|
|
55500
55910
|
#proposedName;
|
|
55911
|
+
#displayName;
|
|
55501
55912
|
#now;
|
|
55502
55913
|
#mintSecret;
|
|
55503
55914
|
#writeTokenFile;
|
|
55504
55915
|
#ancestorOptions;
|
|
55505
55916
|
constructor(options) {
|
|
55917
|
+
if (options.displayName !== void 0 && !validEnrollmentDisplayName2(options.displayName))
|
|
55918
|
+
throw new ClaustrumConsumerError2("invalid-state", "invalid Claustrum enrollment display name");
|
|
55506
55919
|
this.#ancestorOptions = options.ancestorOptions ?? {};
|
|
55507
55920
|
this.#client = options.client;
|
|
55508
55921
|
this.#paths = options.paths;
|
|
55509
55922
|
this.#proposedName = options.proposedName;
|
|
55923
|
+
this.#displayName = options.displayName;
|
|
55510
55924
|
this.#now = options.now ?? Date.now;
|
|
55511
55925
|
this.#mintSecret = options.mintSecret ?? (() => randomBytes6(32).toString("hex"));
|
|
55512
55926
|
this.#writeTokenFile = options.writeTokenFile ?? writeEnrollmentTokenFile2;
|
|
@@ -55596,10 +56010,23 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
55596
56010
|
if (!state.requestId) {
|
|
55597
56011
|
try {
|
|
55598
56012
|
const requestSecretHash = createHash19("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
|
|
55599
|
-
const
|
|
56013
|
+
const proposal = {
|
|
55600
56014
|
name: state.proposedName,
|
|
55601
56015
|
requestSecretHash
|
|
55602
|
-
}
|
|
56016
|
+
};
|
|
56017
|
+
let proposed;
|
|
56018
|
+
try {
|
|
56019
|
+
proposed = await this.#client.enrollPropose({
|
|
56020
|
+
...proposal,
|
|
56021
|
+
...this.#displayName !== void 0 && {
|
|
56022
|
+
displayName: this.#displayName
|
|
56023
|
+
}
|
|
56024
|
+
});
|
|
56025
|
+
} catch (error) {
|
|
56026
|
+
if (this.#displayName === void 0 || !(error instanceof ClaustrumCredentialError9) || error.code !== "invalid_params")
|
|
56027
|
+
throw error;
|
|
56028
|
+
proposed = await this.#client.enrollPropose(proposal);
|
|
56029
|
+
}
|
|
55603
56030
|
state = {
|
|
55604
56031
|
...state,
|
|
55605
56032
|
requestId: proposed.requestId,
|
|
@@ -55770,7 +56197,7 @@ var ByteTail = class {
|
|
|
55770
56197
|
};
|
|
55771
56198
|
var defaultCommandRunner = {
|
|
55772
56199
|
run(file, args, options = {}) {
|
|
55773
|
-
return new Promise((
|
|
56200
|
+
return new Promise((resolve30) => {
|
|
55774
56201
|
const started = performance.now();
|
|
55775
56202
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
55776
56203
|
const stderr = new ByteTail();
|
|
@@ -55788,7 +56215,7 @@ var defaultCommandRunner = {
|
|
|
55788
56215
|
stdio: ["ignore", "pipe", "pipe"]
|
|
55789
56216
|
});
|
|
55790
56217
|
} catch {
|
|
55791
|
-
|
|
56218
|
+
resolve30({
|
|
55792
56219
|
exitCode: 1,
|
|
55793
56220
|
stdout: "",
|
|
55794
56221
|
stderr: "",
|
|
@@ -55823,7 +56250,7 @@ var defaultCommandRunner = {
|
|
|
55823
56250
|
settled = true;
|
|
55824
56251
|
if (timer)
|
|
55825
56252
|
clearTimeout(timer);
|
|
55826
|
-
|
|
56253
|
+
resolve30({
|
|
55827
56254
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
55828
56255
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
55829
56256
|
stderr: stderr.toString(),
|
|
@@ -56435,7 +56862,7 @@ function approveCommand(requestId, name) {
|
|
|
56435
56862
|
async function connectSetupHost(plugin2, host, io, terminal, fence) {
|
|
56436
56863
|
if (hasVaultHost2())
|
|
56437
56864
|
throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
|
|
56438
|
-
const { name, paths: input2 } = plugin2.vault.hosts[host];
|
|
56865
|
+
const { name, displayName, paths: input2 } = plugin2.vault.hosts[host];
|
|
56439
56866
|
const paths = hostEnrollmentPaths2(input2);
|
|
56440
56867
|
await fence();
|
|
56441
56868
|
const client = await (io.connect ?? connectClaustrumEnrollmentClient2)({
|
|
@@ -56449,6 +56876,7 @@ async function connectSetupHost(plugin2, host, io, terminal, fence) {
|
|
|
56449
56876
|
try {
|
|
56450
56877
|
const manager = new ClaustrumEnrollmentManager2({
|
|
56451
56878
|
proposedName: name,
|
|
56879
|
+
displayName,
|
|
56452
56880
|
paths,
|
|
56453
56881
|
// Each tick of the wait below checks the fence once, just before
|
|
56454
56882
|
// reconcile proposes or polls. Checking again inside every vault call
|
|
@@ -57242,7 +57670,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
57242
57670
|
beforeRename: async () => {
|
|
57243
57671
|
await assertSetupHostsStopped();
|
|
57244
57672
|
const claustrum = await loadCommonAuthClaustrum();
|
|
57245
|
-
const stateDir = host === "opencode" ? openCodeVaultDir(
|
|
57673
|
+
const stateDir = host === "opencode" ? openCodeVaultDir(resolve25(accountFileForVault())) : getPiAntigravityVaultDir();
|
|
57246
57674
|
if (await claustrum.vaultAuthority(
|
|
57247
57675
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
57248
57676
|
`antigravity-auth-${host}`
|
|
@@ -57276,17 +57704,19 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
57276
57704
|
const hosts = {
|
|
57277
57705
|
opencode: {
|
|
57278
57706
|
name: OPENCODE_VAULT_ENROLLMENT_NAME,
|
|
57707
|
+
displayName: "Antigravity sign-in for OpenCode",
|
|
57279
57708
|
// Read at each use: a real run settles the vault folder in
|
|
57280
57709
|
// `beforeSignIn`, which may move it after this plugin is built.
|
|
57281
57710
|
paths: {
|
|
57282
57711
|
get stateDir() {
|
|
57283
|
-
return openCodeVaultDir(
|
|
57712
|
+
return openCodeVaultDir(resolve25(accountFileForVault()));
|
|
57284
57713
|
},
|
|
57285
57714
|
host: "opencode"
|
|
57286
57715
|
}
|
|
57287
57716
|
},
|
|
57288
57717
|
pi: {
|
|
57289
57718
|
name: "antigravity-auth-pi",
|
|
57719
|
+
displayName: "Antigravity sign-in for Pi",
|
|
57290
57720
|
paths: { stateDir: piDir, host: "pi" }
|
|
57291
57721
|
}
|
|
57292
57722
|
};
|
|
@@ -57297,7 +57727,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
57297
57727
|
const assertLocal = async (host, context) => {
|
|
57298
57728
|
if (host === "opencode")
|
|
57299
57729
|
return assertLocalOpenCodeLogin(
|
|
57300
|
-
|
|
57730
|
+
resolve25(accountFileForVault()),
|
|
57301
57731
|
context.opencodeGeneration
|
|
57302
57732
|
);
|
|
57303
57733
|
if (await authority(host) !== "local")
|
|
@@ -57957,7 +58387,7 @@ async function runCliProcess(argv, deps) {
|
|
|
57957
58387
|
...deps,
|
|
57958
58388
|
prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
|
|
57959
58389
|
const folder = await prepareVaultFolder({
|
|
57960
|
-
accountFile:
|
|
58390
|
+
accountFile: resolve26(accountFileForVault()),
|
|
57961
58391
|
...options
|
|
57962
58392
|
});
|
|
57963
58393
|
if (folder.refusal) throw folder.refusal;
|
|
@@ -58003,11 +58433,11 @@ function createDefaultCliDependencies() {
|
|
|
58003
58433
|
);
|
|
58004
58434
|
if (host !== "pi")
|
|
58005
58435
|
await assertLocalOpenCodeLogin(
|
|
58006
|
-
|
|
58436
|
+
resolve26(accountFileForVault()),
|
|
58007
58437
|
context?.opencodeGeneration
|
|
58008
58438
|
);
|
|
58009
58439
|
const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
|
|
58010
|
-
|
|
58440
|
+
resolve26(getStoragePath()),
|
|
58011
58441
|
context?.opencodeGeneration
|
|
58012
58442
|
);
|
|
58013
58443
|
try {
|
|
@@ -58023,7 +58453,7 @@ function createDefaultCliDependencies() {
|
|
|
58023
58453
|
}
|
|
58024
58454
|
if (host === "opencode") await assertSetupHostsStopped();
|
|
58025
58455
|
await assertLocalOpenCodeLogin(
|
|
58026
|
-
|
|
58456
|
+
resolve26(accountFileForVault()),
|
|
58027
58457
|
context?.opencodeGeneration
|
|
58028
58458
|
);
|
|
58029
58459
|
await persistCliStoreLogin(
|
|
@@ -58043,7 +58473,7 @@ function createDefaultCliDependencies() {
|
|
|
58043
58473
|
};
|
|
58044
58474
|
}
|
|
58045
58475
|
async function prepareCliLoginStore(legacyPath, generation) {
|
|
58046
|
-
await assertLocalOpenCodeLogin(
|
|
58476
|
+
await assertLocalOpenCodeLogin(resolve26(accountFileForVault()), generation);
|
|
58047
58477
|
const modules = await loadCommonAuthStoreModules();
|
|
58048
58478
|
const options = {
|
|
58049
58479
|
legacyPath,
|
|
@@ -58188,7 +58618,7 @@ async function readAccountStore(legacyPath) {
|
|
|
58188
58618
|
function createDefaultAccountStoreOperations() {
|
|
58189
58619
|
const offline = { processesStopped: true };
|
|
58190
58620
|
return {
|
|
58191
|
-
legacyPath: () =>
|
|
58621
|
+
legacyPath: () => resolve26(
|
|
58192
58622
|
decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
|
|
58193
58623
|
),
|
|
58194
58624
|
migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
|
|
@@ -58219,7 +58649,7 @@ function createDefaultAccountStoreOperations() {
|
|
|
58219
58649
|
};
|
|
58220
58650
|
}
|
|
58221
58651
|
function samePath(left, right) {
|
|
58222
|
-
return process.platform === "win32" ?
|
|
58652
|
+
return process.platform === "win32" ? resolve26(left).toLowerCase() === resolve26(right).toLowerCase() : resolve26(left) === resolve26(right);
|
|
58223
58653
|
}
|
|
58224
58654
|
function isCliEntry() {
|
|
58225
58655
|
if (import.meta.main !== void 0) return import.meta.main;
|
|
@@ -58709,14 +59139,14 @@ function isTuiConnected(sessionId) {
|
|
|
58709
59139
|
// src/rpc/rpc-dir.ts
|
|
58710
59140
|
import { createHash as createHash20 } from "node:crypto";
|
|
58711
59141
|
import { homedir as homedir13, tmpdir as tmpdir6 } from "node:os";
|
|
58712
|
-
import { isAbsolute as isAbsolute5, join as join34, resolve as
|
|
59142
|
+
import { isAbsolute as isAbsolute5, join as join34, resolve as resolve27 } from "node:path";
|
|
58713
59143
|
var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
|
|
58714
59144
|
function getRpcDir(projectDirectory) {
|
|
58715
59145
|
const override = process.env[RPC_DIR_ENV]?.trim();
|
|
58716
59146
|
if (override) {
|
|
58717
|
-
return isAbsolute5(override) ? override :
|
|
59147
|
+
return isAbsolute5(override) ? override : resolve27(projectDirectory, override);
|
|
58718
59148
|
}
|
|
58719
|
-
const projectHash = createHash20("sha256").update(
|
|
59149
|
+
const projectHash = createHash20("sha256").update(resolve27(projectDirectory)).digest("hex").slice(0, 16);
|
|
58720
59150
|
const stateHome = process.env.XDG_STATE_HOME ?? join34(homedir13(), ".local", "state");
|
|
58721
59151
|
return join34(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
|
|
58722
59152
|
}
|
|
@@ -58731,7 +59161,7 @@ init_private_files2();
|
|
|
58731
59161
|
import { createHash as createHash21, randomUUID as randomUUID21 } from "node:crypto";
|
|
58732
59162
|
import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir4, rename as rename14, rmdir as rmdir3, stat as stat17, unlink as unlink13 } from "node:fs/promises";
|
|
58733
59163
|
import { uptime as uptime2 } from "node:os";
|
|
58734
|
-
import { join as join35, resolve as
|
|
59164
|
+
import { join as join35, resolve as resolve28 } from "node:path";
|
|
58735
59165
|
function staleBefore(clock2) {
|
|
58736
59166
|
return (clock2.now ?? Date.now)() - (clock2.uptime ?? uptime2)() * 1e3 - 3e5;
|
|
58737
59167
|
}
|
|
@@ -58841,7 +59271,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log17, options = {})
|
|
|
58841
59271
|
return;
|
|
58842
59272
|
throw error;
|
|
58843
59273
|
}
|
|
58844
|
-
const active2 =
|
|
59274
|
+
const active2 = resolve28(activeDir);
|
|
58845
59275
|
for (const projectDir of projectDirs) {
|
|
58846
59276
|
if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
|
|
58847
59277
|
continue;
|
|
@@ -58888,7 +59318,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log17, options = {})
|
|
|
58888
59318
|
else if (isStalePortFile(entry, info, cutoff))
|
|
58889
59319
|
await removeStalePortFile(portFile, raw, info, options.beforeRemove);
|
|
58890
59320
|
}
|
|
58891
|
-
if (
|
|
59321
|
+
if (resolve28(dir) !== active2)
|
|
58892
59322
|
await rmdir3(dir).catch(() => {
|
|
58893
59323
|
});
|
|
58894
59324
|
}
|
|
@@ -58922,7 +59352,7 @@ var BodyTooLargeError = class extends Error {
|
|
|
58922
59352
|
}
|
|
58923
59353
|
};
|
|
58924
59354
|
function readBody(req) {
|
|
58925
|
-
return new Promise((
|
|
59355
|
+
return new Promise((resolve30, reject) => {
|
|
58926
59356
|
const tooLarge = (declaredOversize = false) => {
|
|
58927
59357
|
req.removeAllListeners("data");
|
|
58928
59358
|
req.on("data", () => {
|
|
@@ -58945,7 +59375,7 @@ function readBody(req) {
|
|
|
58945
59375
|
}
|
|
58946
59376
|
chunks.push(chunk);
|
|
58947
59377
|
});
|
|
58948
|
-
req.on("end", () =>
|
|
59378
|
+
req.on("end", () => resolve30(Buffer.concat(chunks).toString("utf8")));
|
|
58949
59379
|
req.on("error", reject);
|
|
58950
59380
|
});
|
|
58951
59381
|
}
|
|
@@ -59124,12 +59554,12 @@ async function startRpcServer(options) {
|
|
|
59124
59554
|
json(500, { error: "internal error" });
|
|
59125
59555
|
}
|
|
59126
59556
|
}
|
|
59127
|
-
const port = await new Promise((
|
|
59557
|
+
const port = await new Promise((resolve30, reject) => {
|
|
59128
59558
|
server.on("error", reject);
|
|
59129
59559
|
server.listen(0, "127.0.0.1", () => {
|
|
59130
59560
|
const addr = server.address();
|
|
59131
59561
|
if (addr && typeof addr === "object")
|
|
59132
|
-
|
|
59562
|
+
resolve30(addr.port);
|
|
59133
59563
|
else
|
|
59134
59564
|
reject(new Error("no port"));
|
|
59135
59565
|
});
|
|
@@ -59152,16 +59582,16 @@ async function startRpcServer(options) {
|
|
|
59152
59582
|
rpcPort: port
|
|
59153
59583
|
});
|
|
59154
59584
|
} catch (error) {
|
|
59155
|
-
await new Promise((
|
|
59585
|
+
await new Promise((resolve30) => server.close(() => resolve30()));
|
|
59156
59586
|
throw error;
|
|
59157
59587
|
}
|
|
59158
59588
|
return {
|
|
59159
59589
|
port,
|
|
59160
59590
|
token,
|
|
59161
59591
|
async stop() {
|
|
59162
|
-
await new Promise((
|
|
59592
|
+
await new Promise((resolve30) => {
|
|
59163
59593
|
server.closeAllConnections?.();
|
|
59164
|
-
server.close(() =>
|
|
59594
|
+
server.close(() => resolve30());
|
|
59165
59595
|
for (const socket of connections)
|
|
59166
59596
|
socket.destroy();
|
|
59167
59597
|
});
|
|
@@ -59770,7 +60200,7 @@ async function select3(items, options) {
|
|
|
59770
60200
|
}
|
|
59771
60201
|
renderedLines = linesWritten;
|
|
59772
60202
|
};
|
|
59773
|
-
return new Promise((
|
|
60203
|
+
return new Promise((resolve30) => {
|
|
59774
60204
|
const wasRaw = stdin.isRaw ?? false;
|
|
59775
60205
|
const cleanup2 = () => {
|
|
59776
60206
|
if (isCleanedUp) return;
|
|
@@ -59791,11 +60221,11 @@ async function select3(items, options) {
|
|
|
59791
60221
|
};
|
|
59792
60222
|
const onSignal = () => {
|
|
59793
60223
|
cleanup2();
|
|
59794
|
-
|
|
60224
|
+
resolve30(null);
|
|
59795
60225
|
};
|
|
59796
60226
|
const finishWithValue = (value) => {
|
|
59797
60227
|
cleanup2();
|
|
59798
|
-
|
|
60228
|
+
resolve30(value);
|
|
59799
60229
|
};
|
|
59800
60230
|
const findNextSelectable = (from, direction) => {
|
|
59801
60231
|
if (items.length === 0) return from;
|
|
@@ -59841,7 +60271,7 @@ async function select3(items, options) {
|
|
|
59841
60271
|
stdin.setRawMode(true);
|
|
59842
60272
|
} catch {
|
|
59843
60273
|
cleanup2();
|
|
59844
|
-
|
|
60274
|
+
resolve30(null);
|
|
59845
60275
|
return;
|
|
59846
60276
|
}
|
|
59847
60277
|
stdin.resume();
|
|
@@ -62845,10 +63275,10 @@ function resolvePluginDependencies(overrides = {}) {
|
|
|
62845
63275
|
}
|
|
62846
63276
|
async function defaultSleep(ms, signal) {
|
|
62847
63277
|
if (ms <= 0) return;
|
|
62848
|
-
await new Promise((
|
|
63278
|
+
await new Promise((resolve30, reject) => {
|
|
62849
63279
|
const timer = setTimeout(() => {
|
|
62850
63280
|
signal?.removeEventListener("abort", onAbort);
|
|
62851
|
-
|
|
63281
|
+
resolve30();
|
|
62852
63282
|
}, ms);
|
|
62853
63283
|
timer.unref?.();
|
|
62854
63284
|
const onAbort = () => {
|
|
@@ -63570,8 +64000,8 @@ function createPluginLifecycle(options) {
|
|
|
63570
64000
|
};
|
|
63571
64001
|
let failDisposal = () => {
|
|
63572
64002
|
};
|
|
63573
|
-
disposal = new Promise((
|
|
63574
|
-
finishDisposal =
|
|
64003
|
+
disposal = new Promise((resolve30, reject) => {
|
|
64004
|
+
finishDisposal = resolve30;
|
|
63575
64005
|
failDisposal = reject;
|
|
63576
64006
|
});
|
|
63577
64007
|
void (async () => {
|
|
@@ -63720,7 +64150,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
63720
64150
|
await drainSidebarWrites();
|
|
63721
64151
|
}
|
|
63722
64152
|
});
|
|
63723
|
-
const accountFile =
|
|
64153
|
+
const accountFile = resolve29(accountFileForVault());
|
|
63724
64154
|
const vaultFolder = await prepareVaultFolder({ accountFile });
|
|
63725
64155
|
const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
|
|
63726
64156
|
let vaultQuotaPoller;
|