@cortexkit/opencode-antigravity-auth 3.0.37 → 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 +608 -321
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +106 -38
- package/dist/index.js +815 -386
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +122 -46
- package/dist/server.js +1056 -492
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/auth-method-labels.d.ts +2 -0
- package/dist/src/auth-method-labels.d.ts.map +1 -1
- package/dist/src/auth-method-labels.js +2 -0
- package/dist/src/auth-method-labels.js.map +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/server/auth.js +1 -1
- package/dist/src/ga/server/auth.js.map +1 -1
- package/dist/src/ga/server/pool-login.d.ts +9 -0
- package/dist/src/ga/server/pool-login.d.ts.map +1 -1
- package/dist/src/ga/server/pool-login.js +155 -73
- package/dist/src/ga/server/pool-login.js.map +1 -1
- package/dist/src/ga/tui/host-ga.d.ts +27 -3
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +168 -22
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/logging/provider-key-policy.d.ts +2 -0
- package/dist/src/logging/provider-key-policy.d.ts.map +1 -1
- package/dist/src/logging/provider-key-policy.js +5 -1
- package/dist/src/logging/provider-key-policy.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 +81 -10
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/logger.d.ts.map +1 -1
- package/dist/src/plugin/logger.js +2 -1
- package/dist/src/plugin/logger.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/src/tui/file-logger.d.ts.map +1 -1
- package/dist/src/tui/file-logger.js +2 -1
- package/dist/src/tui/file-logger.js.map +1 -1
- package/dist/tui-build-map.json +27 -13
- package/dist/tui-ga-build-map.json +23 -9
- package/dist/types/src/auth-method-labels.d.ts +2 -0
- package/dist/types/src/auth-method-labels.d.ts.map +1 -1
- 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/ga/server/pool-login.d.ts +9 -0
- package/dist/types/src/ga/server/pool-login.d.ts.map +1 -1
- package/dist/types/src/logging/provider-key-policy.d.ts +2 -0
- package/dist/types/src/logging/provider-key-policy.d.ts.map +1 -1
- 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/logger.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/file-logger.ts +5 -1
- package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +36 -674
- package/src/tui-compiled/logging/provider-key-policy.js +4 -1
- package/src/tui-compiled/shared/a75d0d866c227b3f-index.js +678 -0
- package/src/tui-compiled/tui/file-logger.js +5 -1
- package/src/tui-ga-compiled/host-ga.js +148 -23
- 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 +199 -24
- 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/logging/provider-key-policy.js +4 -1
- package/src/tui-raw/shared/a75d0d866c227b3f-index.tsx +681 -0
- package/src/tui-raw/tui/file-logger.js +5 -1
package/dist/index.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((resolve29) => setTimeout(resolve29, 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((resolve29) => {
|
|
8060
|
+
lostResolve = resolve29;
|
|
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 resolve29 = lostResolve;
|
|
8014
8071
|
lostResolve = null;
|
|
8015
|
-
|
|
8072
|
+
resolve29?.();
|
|
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((resolve29) => setTimeout(resolve29, 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((resolve29) => setTimeout(resolve29, 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((resolve29, reject) => {
|
|
9962
|
+
this.savePromiseResolvers.push({ resolve: resolve29, 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: resolve29 } of resolvers)
|
|
10006
|
+
resolve29();
|
|
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: resolve29 } of resolvers) {
|
|
10021
|
+
resolve29();
|
|
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: resolve29 } of resolvers) {
|
|
10029
|
+
resolve29();
|
|
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((resolve29, 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(() => resolve29({ 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((resolve29, 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
|
+
resolve29();
|
|
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((resolve29, 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
|
+
resolve29(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((resolve29, 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
|
+
resolve29(socket);
|
|
10585
10642
|
});
|
|
10586
10643
|
socket.once("error", (error) => {
|
|
10587
10644
|
cleanup2();
|
|
@@ -12137,7 +12194,8 @@ function accountsSection(options, ids, now) {
|
|
|
12137
12194
|
{
|
|
12138
12195
|
id: "add",
|
|
12139
12196
|
label: options.login.label ?? "Add account",
|
|
12140
|
-
|
|
12197
|
+
...options.login.knobs ? { knobs: options.login.knobs } : {},
|
|
12198
|
+
run: ({ invocation, values }) => options.login ? options.login.run(invocation, values) : Promise.resolve(failure("Login is unavailable.", "refused"))
|
|
12141
12199
|
}
|
|
12142
12200
|
] : [];
|
|
12143
12201
|
if (read.status !== "ready")
|
|
@@ -12657,6 +12715,45 @@ var init_atomic_write2 = __esm({
|
|
|
12657
12715
|
}
|
|
12658
12716
|
});
|
|
12659
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
|
+
|
|
12660
12757
|
// ../core/dist/common-auth-embedded/fs/refresh-file-lock.js
|
|
12661
12758
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
12662
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";
|
|
@@ -12739,8 +12836,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12739
12836
|
let releaseConfirmed = false;
|
|
12740
12837
|
let loss;
|
|
12741
12838
|
let resolveLoss;
|
|
12742
|
-
const lostPromise = new Promise((
|
|
12743
|
-
resolveLoss =
|
|
12839
|
+
const lostPromise = new Promise((resolve29) => {
|
|
12840
|
+
resolveLoss = resolve29;
|
|
12744
12841
|
});
|
|
12745
12842
|
function notifyTimerStep(event) {
|
|
12746
12843
|
try {
|
|
@@ -12778,15 +12875,18 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12778
12875
|
const evictOwnerId = randomUUID9();
|
|
12779
12876
|
const EVICT_TTL = 5e3;
|
|
12780
12877
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
12878
|
+
function isChangingLockCreate(error) {
|
|
12879
|
+
return windowsPrivateFiles && (isWindowsAccessDeniedCreate(error, [lockPath], "create") || isWindowsAccessDeniedCreate(error, [evictPath], "directory-create"));
|
|
12880
|
+
}
|
|
12781
12881
|
async function readOwner() {
|
|
12782
12882
|
if (windowsPrivateFiles) {
|
|
12783
12883
|
try {
|
|
12784
|
-
return JSON.parse(await readPrivateText(lockPath, true));
|
|
12884
|
+
return JSON.parse(await readLockRecord(lockPath, () => readPrivateText(lockPath, true)));
|
|
12785
12885
|
} catch (error) {
|
|
12786
12886
|
if (error.code !== "EISDIR" && error.reason !== "wrong-kind")
|
|
12787
12887
|
throw error;
|
|
12788
|
-
await verifyPrivate(lockPath, "directory", true);
|
|
12789
|
-
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)));
|
|
12790
12890
|
}
|
|
12791
12891
|
}
|
|
12792
12892
|
try {
|
|
@@ -12862,8 +12962,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12862
12962
|
await options.onStep("lease-contention-read-ready");
|
|
12863
12963
|
try {
|
|
12864
12964
|
if (code2 === "EISDIR") {
|
|
12865
|
-
await verifyPrivate(lockPath, "directory", true);
|
|
12866
|
-
await readPrivateText(legacyOwnerPath, true);
|
|
12965
|
+
await readLockRecord(lockPath, () => verifyPrivate(lockPath, "directory", true));
|
|
12966
|
+
await readLockRecord(legacyOwnerPath, () => readPrivateText(legacyOwnerPath, true));
|
|
12867
12967
|
} else
|
|
12868
12968
|
await readOwner();
|
|
12869
12969
|
} catch (readError) {
|
|
@@ -12901,7 +13001,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12901
13001
|
}
|
|
12902
13002
|
}
|
|
12903
13003
|
async function backoff() {
|
|
12904
|
-
await new Promise((
|
|
13004
|
+
await new Promise((resolve29) => setTimeout(resolve29, Math.floor(Math.random() * 4)));
|
|
12905
13005
|
}
|
|
12906
13006
|
async function readLockState(notifyReady = true) {
|
|
12907
13007
|
if (notifyReady && options.onStep)
|
|
@@ -12910,6 +13010,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12910
13010
|
try {
|
|
12911
13011
|
owner = await readOwner();
|
|
12912
13012
|
} catch (error) {
|
|
13013
|
+
if (error instanceof DisappearedLockRecordError)
|
|
13014
|
+
return { status: "missing" };
|
|
12913
13015
|
if (windowsPrivateFiles && error.code !== "ENOENT")
|
|
12914
13016
|
throw error;
|
|
12915
13017
|
}
|
|
@@ -12957,7 +13059,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12957
13059
|
}
|
|
12958
13060
|
async function ownsEvictionMarker() {
|
|
12959
13061
|
try {
|
|
12960
|
-
const owner = JSON.parse(await readPrivateText(evictOwnerPath, windowsPrivateFiles));
|
|
13062
|
+
const owner = JSON.parse(await readLockRecord(evictOwnerPath, () => readPrivateText(evictOwnerPath, windowsPrivateFiles)));
|
|
12961
13063
|
return owner?.ownerId === evictOwnerId;
|
|
12962
13064
|
} catch (error) {
|
|
12963
13065
|
if (windowsPrivateFiles && error.code !== "ENOENT")
|
|
@@ -12992,7 +13094,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
12992
13094
|
const remainingMs = deadline - performance.now();
|
|
12993
13095
|
if (remainingMs <= 0)
|
|
12994
13096
|
throw original;
|
|
12995
|
-
await new Promise((
|
|
13097
|
+
await new Promise((resolve29) => setTimeout(resolve29, Math.min(delayMs, remainingMs)));
|
|
12996
13098
|
if (performance.now() >= deadline)
|
|
12997
13099
|
throw original;
|
|
12998
13100
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -13096,7 +13198,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13096
13198
|
}
|
|
13097
13199
|
if (windowsPrivateFiles) {
|
|
13098
13200
|
try {
|
|
13099
|
-
await verifyPrivate(evictPath, "directory", true);
|
|
13201
|
+
await readLockRecord(evictPath, () => verifyPrivate(evictPath, "directory", true));
|
|
13100
13202
|
} catch (error) {
|
|
13101
13203
|
if (error.code === "ENOENT")
|
|
13102
13204
|
return "missing";
|
|
@@ -13151,8 +13253,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13151
13253
|
if (error.code === "EEXIST") {
|
|
13152
13254
|
if (windowsPrivateFiles) {
|
|
13153
13255
|
try {
|
|
13154
|
-
await verifyPrivate(evictPath, "directory", true);
|
|
13155
|
-
await readPrivateText(evictOwnerPath, true);
|
|
13256
|
+
await readLockRecord(evictPath, () => verifyPrivate(evictPath, "directory", true));
|
|
13257
|
+
await readLockRecord(evictOwnerPath, () => readPrivateText(evictOwnerPath, true));
|
|
13156
13258
|
} catch (ownerError) {
|
|
13157
13259
|
if (ownerError.code !== "ENOENT")
|
|
13158
13260
|
throw ownerError;
|
|
@@ -13173,7 +13275,11 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13173
13275
|
try {
|
|
13174
13276
|
await releaseEvictionMarker(deadline);
|
|
13175
13277
|
} catch (error) {
|
|
13176
|
-
if (isRetryableRemoval(actionError, lockPath)
|
|
13278
|
+
if ((isRetryableRemoval(actionError, lockPath) || isWindowsAccessDeniedRead(actionError, [
|
|
13279
|
+
lockPath,
|
|
13280
|
+
legacyOwnerPath,
|
|
13281
|
+
evictOwnerPath
|
|
13282
|
+
])) && (isRetryableRemoval(error, evictPath) || isWindowsAccessDeniedRead(error, [evictOwnerPath])))
|
|
13177
13283
|
throw actionError;
|
|
13178
13284
|
throw error;
|
|
13179
13285
|
}
|
|
@@ -13189,7 +13295,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13189
13295
|
try {
|
|
13190
13296
|
owner = await readOwner();
|
|
13191
13297
|
} catch (error) {
|
|
13192
|
-
if (windowsPrivateFiles)
|
|
13298
|
+
if (windowsPrivateFiles && !(error instanceof DisappearedLockRecordError))
|
|
13193
13299
|
throw error;
|
|
13194
13300
|
return;
|
|
13195
13301
|
}
|
|
@@ -13267,7 +13373,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13267
13373
|
await options.onStep("renewal-marker-unavailable");
|
|
13268
13374
|
}
|
|
13269
13375
|
} catch (error) {
|
|
13270
|
-
if (windowsPrivateFiles && error instanceof PrivateFileError) {
|
|
13376
|
+
if (windowsPrivateFiles && error instanceof PrivateFileError && !isChangingLockCreate(error)) {
|
|
13271
13377
|
terminalIOError = error;
|
|
13272
13378
|
recordLoss("renewal-failed");
|
|
13273
13379
|
shouldReschedule = false;
|
|
@@ -13313,72 +13419,90 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13313
13419
|
}
|
|
13314
13420
|
return null;
|
|
13315
13421
|
}
|
|
13316
|
-
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
|
+
}
|
|
13317
13431
|
if (!acquired) {
|
|
13318
13432
|
for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
|
|
13319
|
-
acquired = await tryAcquire();
|
|
13320
|
-
if (acquired)
|
|
13321
|
-
break;
|
|
13322
|
-
const observed = await readLockState();
|
|
13323
|
-
if (observed.status === "live")
|
|
13324
|
-
return contended();
|
|
13325
|
-
if (observed.status === "missing")
|
|
13326
|
-
continue;
|
|
13327
|
-
if (options.onStep)
|
|
13328
|
-
await options.onStep("stale-lock-observed");
|
|
13329
13433
|
try {
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
const code2 = evictError.code;
|
|
13336
|
-
if (code2 !== "EEXIST")
|
|
13337
|
-
throw evictError;
|
|
13338
|
-
const recovered = await recoverStaleEvictionMarker();
|
|
13339
|
-
if (recovered === "fresh")
|
|
13340
|
-
return null;
|
|
13341
|
-
await backoff();
|
|
13342
|
-
continue;
|
|
13343
|
-
}
|
|
13344
|
-
try {
|
|
13345
|
-
const confirmed = await readLockState();
|
|
13346
|
-
if (confirmed.status === "live")
|
|
13434
|
+
acquired = await tryAcquire();
|
|
13435
|
+
if (acquired)
|
|
13436
|
+
break;
|
|
13437
|
+
const observed = await readLockState();
|
|
13438
|
+
if (observed.status === "live")
|
|
13347
13439
|
return contended();
|
|
13348
|
-
if (
|
|
13440
|
+
if (observed.status === "missing")
|
|
13349
13441
|
continue;
|
|
13350
|
-
if (!await ownsEvictionMarker())
|
|
13351
|
-
return null;
|
|
13352
13442
|
if (options.onStep)
|
|
13353
|
-
await options.onStep("stale-lock-
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
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();
|
|
13358
13457
|
continue;
|
|
13359
|
-
await removeLeaseObject(lockPath);
|
|
13360
|
-
if (!await ownsEvictionMarker())
|
|
13361
|
-
return null;
|
|
13362
|
-
if (options.onStep)
|
|
13363
|
-
await options.onStep("stale-lock-removed");
|
|
13364
|
-
acquired = await tryAcquire();
|
|
13365
|
-
if (!acquired)
|
|
13366
|
-
return null;
|
|
13367
|
-
if (options.onStep)
|
|
13368
|
-
await options.onStep("stale-lock-recreated");
|
|
13369
|
-
if (!await ownsEvictionMarker()) {
|
|
13370
|
-
await relinquishLockAfterMarkerLoss();
|
|
13371
|
-
acquired = false;
|
|
13372
|
-
return null;
|
|
13373
13458
|
}
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
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();
|
|
13377
13498
|
}
|
|
13378
13499
|
}
|
|
13379
13500
|
}
|
|
13380
|
-
if (!acquired)
|
|
13501
|
+
if (!acquired) {
|
|
13502
|
+
if (changingCreateError)
|
|
13503
|
+
throw changingCreateError;
|
|
13381
13504
|
return null;
|
|
13505
|
+
}
|
|
13382
13506
|
scheduleRenewal();
|
|
13383
13507
|
return {
|
|
13384
13508
|
ownerId,
|
|
@@ -13416,6 +13540,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13416
13540
|
const deadline = performance.now() + EVICT_TTL + 1e3;
|
|
13417
13541
|
let delayMs = 5;
|
|
13418
13542
|
let removalError;
|
|
13543
|
+
let changingRecordError;
|
|
13419
13544
|
for (; ; ) {
|
|
13420
13545
|
try {
|
|
13421
13546
|
let removalConfirmed = false;
|
|
@@ -13441,6 +13566,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13441
13566
|
await removeLeaseObject(lockPath);
|
|
13442
13567
|
removalConfirmed = true;
|
|
13443
13568
|
}, deadline);
|
|
13569
|
+
changingRecordError = void 0;
|
|
13444
13570
|
if (markerAcquired) {
|
|
13445
13571
|
if (windowsPrivateFiles && !removalConfirmed)
|
|
13446
13572
|
throw new PrivateFileError(lockPath, "release-not-confirmed", {
|
|
@@ -13453,23 +13579,32 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
13453
13579
|
return;
|
|
13454
13580
|
await recoverStaleEvictionMarker(deadline);
|
|
13455
13581
|
} catch (error) {
|
|
13456
|
-
|
|
13582
|
+
const changingRecord = windowsPrivateFiles && (isChangingLockCreate(error) || isWindowsAccessDeniedRead(error, [
|
|
13583
|
+
lockPath,
|
|
13584
|
+
legacyOwnerPath,
|
|
13585
|
+
evictPath,
|
|
13586
|
+
evictOwnerPath
|
|
13587
|
+
]));
|
|
13588
|
+
if (!isRetryableRemoval(error, lockPath) && !changingRecord) {
|
|
13457
13589
|
if (windowsPrivateFiles)
|
|
13458
13590
|
throw error;
|
|
13459
13591
|
return;
|
|
13460
13592
|
}
|
|
13461
|
-
|
|
13593
|
+
if (changingRecord)
|
|
13594
|
+
changingRecordError ??= error;
|
|
13595
|
+
else
|
|
13596
|
+
removalError ??= error;
|
|
13462
13597
|
}
|
|
13463
13598
|
const remainingMs = deadline - performance.now();
|
|
13464
13599
|
if (remainingMs <= 0)
|
|
13465
13600
|
break;
|
|
13466
|
-
await new Promise((
|
|
13601
|
+
await new Promise((resolve29) => setTimeout(resolve29, Math.min(delayMs, remainingMs)));
|
|
13467
13602
|
if (windowsPrivateFiles && performance.now() >= deadline)
|
|
13468
13603
|
break;
|
|
13469
13604
|
delayMs = Math.min(delayMs * 2, 50);
|
|
13470
13605
|
}
|
|
13471
13606
|
if (windowsPrivateFiles)
|
|
13472
|
-
throw removalError ?? new PrivateFileError(lockPath, "release-not-confirmed", {
|
|
13607
|
+
throw changingRecordError ?? removalError ?? new PrivateFileError(lockPath, "release-not-confirmed", {
|
|
13473
13608
|
code: "ETIMEDOUT"
|
|
13474
13609
|
});
|
|
13475
13610
|
}
|
|
@@ -13479,6 +13614,7 @@ var leaseCreationTestHooks, setRefreshLockRenewalTimeout, clearRefreshLockRenewa
|
|
|
13479
13614
|
var init_refresh_file_lock = __esm({
|
|
13480
13615
|
"../core/dist/common-auth-embedded/fs/refresh-file-lock.js"() {
|
|
13481
13616
|
"use strict";
|
|
13617
|
+
init_lock_record();
|
|
13482
13618
|
init_private_files();
|
|
13483
13619
|
init_with_lock();
|
|
13484
13620
|
setRefreshLockRenewalTimeout = globalThis.setTimeout.bind(globalThis);
|
|
@@ -13488,22 +13624,21 @@ var init_refresh_file_lock = __esm({
|
|
|
13488
13624
|
});
|
|
13489
13625
|
|
|
13490
13626
|
// ../core/dist/common-auth-embedded/fs/with-lock.js
|
|
13491
|
-
import { join as join6, resolve as
|
|
13627
|
+
import { join as join6, resolve as resolve4 } from "node:path";
|
|
13492
13628
|
function lockPathFor(target, name) {
|
|
13493
13629
|
return `${target}.${name}.lock`;
|
|
13494
13630
|
}
|
|
13495
|
-
function
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
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"));
|
|
13500
13635
|
}
|
|
13501
13636
|
async function withLock(target, options, fn) {
|
|
13502
13637
|
const started = performance.now();
|
|
13638
|
+
let changingRecordError;
|
|
13503
13639
|
for (; ; ) {
|
|
13504
13640
|
options.signal?.throwIfAborted();
|
|
13505
13641
|
let lock;
|
|
13506
|
-
let changingReadError;
|
|
13507
13642
|
try {
|
|
13508
13643
|
lock = await acquireRefreshFileLock({
|
|
13509
13644
|
path: target,
|
|
@@ -13513,11 +13648,12 @@ async function withLock(target, options, fn) {
|
|
|
13513
13648
|
...options.onStep ? { onStep: options.onStep } : {},
|
|
13514
13649
|
...options.onRenewalTimer ? { onRenewalTimer: options.onRenewalTimer } : {}
|
|
13515
13650
|
});
|
|
13651
|
+
changingRecordError = void 0;
|
|
13516
13652
|
} catch (error) {
|
|
13517
|
-
if (!
|
|
13653
|
+
if (!isChangingLockRecord(error, target, options.name))
|
|
13518
13654
|
throw error;
|
|
13519
13655
|
lock = null;
|
|
13520
|
-
|
|
13656
|
+
changingRecordError ??= error;
|
|
13521
13657
|
}
|
|
13522
13658
|
if (lock) {
|
|
13523
13659
|
try {
|
|
@@ -13529,21 +13665,22 @@ async function withLock(target, options, fn) {
|
|
|
13529
13665
|
}
|
|
13530
13666
|
const remaining = options.timeoutMs - (performance.now() - started);
|
|
13531
13667
|
if (remaining <= 0) {
|
|
13532
|
-
if (
|
|
13533
|
-
throw
|
|
13668
|
+
if (changingRecordError)
|
|
13669
|
+
throw changingRecordError;
|
|
13534
13670
|
throw new LockContentionError({
|
|
13535
13671
|
target,
|
|
13536
13672
|
name: options.name,
|
|
13537
13673
|
timeoutMs: options.timeoutMs
|
|
13538
13674
|
});
|
|
13539
13675
|
}
|
|
13540
|
-
await new Promise((
|
|
13676
|
+
await new Promise((resolve29) => setTimeout(resolve29, Math.min(25, Math.ceil(remaining))));
|
|
13541
13677
|
}
|
|
13542
13678
|
}
|
|
13543
13679
|
var LockContentionError, LockOwnershipError;
|
|
13544
13680
|
var init_with_lock = __esm({
|
|
13545
13681
|
"../core/dist/common-auth-embedded/fs/with-lock.js"() {
|
|
13546
13682
|
"use strict";
|
|
13683
|
+
init_lock_record();
|
|
13547
13684
|
init_private_files();
|
|
13548
13685
|
init_refresh_file_lock();
|
|
13549
13686
|
LockContentionError = class extends Error {
|
|
@@ -13626,7 +13763,7 @@ async function acquirePoolLock(spec, defaults, env3) {
|
|
|
13626
13763
|
});
|
|
13627
13764
|
}
|
|
13628
13765
|
const jitter = Math.floor(Math.random() * (options.retryMs + 1));
|
|
13629
|
-
await new Promise((
|
|
13766
|
+
await new Promise((resolve29) => setTimeout(resolve29, Math.min(options.retryMs + jitter, remaining)));
|
|
13630
13767
|
}
|
|
13631
13768
|
}
|
|
13632
13769
|
function definedOnly(spec) {
|
|
@@ -16520,7 +16657,7 @@ var init_redact = __esm({
|
|
|
16520
16657
|
// ../core/dist/common-auth-embedded/logger/engine.js
|
|
16521
16658
|
import { appendFileSync, chmodSync, existsSync, renameSync, statSync } from "node:fs";
|
|
16522
16659
|
import { open as open5 } from "node:fs/promises";
|
|
16523
|
-
import { dirname as dirname8, resolve as
|
|
16660
|
+
import { dirname as dirname8, resolve as resolve5 } from "node:path";
|
|
16524
16661
|
function chmodPrivate(path5) {
|
|
16525
16662
|
try {
|
|
16526
16663
|
chmodSync(path5, 384);
|
|
@@ -16571,7 +16708,7 @@ async function openWindowsFile(sink, file) {
|
|
|
16571
16708
|
return sink.handle;
|
|
16572
16709
|
}
|
|
16573
16710
|
async function flushWindowsFile(sink, file, text2) {
|
|
16574
|
-
file =
|
|
16711
|
+
file = resolve5(file);
|
|
16575
16712
|
try {
|
|
16576
16713
|
if (sink.file !== file)
|
|
16577
16714
|
await closeWindowsFile(sink);
|
|
@@ -16947,11 +17084,11 @@ var init_quota_writer = __esm({
|
|
|
16947
17084
|
const left = deadline - performance.now();
|
|
16948
17085
|
if (left <= 0)
|
|
16949
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);
|
|
16950
|
-
await new Promise((
|
|
17087
|
+
await new Promise((resolve29) => {
|
|
16951
17088
|
const done = () => {
|
|
16952
17089
|
clearTimeout(timer);
|
|
16953
17090
|
this.wake.delete(done);
|
|
16954
|
-
|
|
17091
|
+
resolve29();
|
|
16955
17092
|
};
|
|
16956
17093
|
const timer = setTimeout(done, left);
|
|
16957
17094
|
this.wake.add(done);
|
|
@@ -17344,7 +17481,7 @@ var init_refresh = __esm({
|
|
|
17344
17481
|
|
|
17345
17482
|
// ../core/dist/common-auth-embedded/fs/file-read-cache.js
|
|
17346
17483
|
import { lstat as lstat4, stat as stat4 } from "node:fs/promises";
|
|
17347
|
-
import { resolve as
|
|
17484
|
+
import { resolve as resolve6 } from "node:path";
|
|
17348
17485
|
async function identity(path5, followSymlinks) {
|
|
17349
17486
|
try {
|
|
17350
17487
|
const metadata = await (followSymlinks ? stat4(path5) : lstat4(path5));
|
|
@@ -17369,7 +17506,7 @@ var init_file_read_cache = __esm({
|
|
|
17369
17506
|
this.#followSymlinks = options.followSymlinks ?? false;
|
|
17370
17507
|
}
|
|
17371
17508
|
async read(paths, read, validateHit) {
|
|
17372
|
-
const resolvedPaths = paths.map((path5) =>
|
|
17509
|
+
const resolvedPaths = paths.map((path5) => resolve6(path5));
|
|
17373
17510
|
const key = JSON.stringify(resolvedPaths);
|
|
17374
17511
|
const probed = await Promise.all(resolvedPaths.map((path5) => identity(path5, this.#followSymlinks)));
|
|
17375
17512
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -19558,9 +19695,17 @@ var init_availability = __esm({
|
|
|
19558
19695
|
ERR_PRIVATE_FILES_SECURITY: "answered"
|
|
19559
19696
|
});
|
|
19560
19697
|
ClaustrumUnreachableError = class extends ClaustrumConsumerError {
|
|
19561
|
-
|
|
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) {
|
|
19562
19705
|
super("unavailable", "Claustrum scoped operation unavailable");
|
|
19563
19706
|
this.name = "ClaustrumUnreachableError";
|
|
19707
|
+
if (reason === "host-accessor-missing" || reason === "host-accessor-failed")
|
|
19708
|
+
this.reason = reason;
|
|
19564
19709
|
}
|
|
19565
19710
|
};
|
|
19566
19711
|
}
|
|
@@ -19581,7 +19726,7 @@ function hostError(error) {
|
|
|
19581
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"))
|
|
19582
19727
|
return new ClaustrumCredentialError2(value.code, value.class, value.action);
|
|
19583
19728
|
if (value.name === "ClaustrumUnreachableError" || typeof value.code === "string" && classifyVaultFailure(Object.assign(new Error(), { code: value.code })) === "unreachable")
|
|
19584
|
-
return new ClaustrumUnreachableError();
|
|
19729
|
+
return new ClaustrumUnreachableError(value.reason === "host-accessor-missing" || value.reason === "host-accessor-failed" ? value.reason : void 0);
|
|
19585
19730
|
return error;
|
|
19586
19731
|
}
|
|
19587
19732
|
function call(operation) {
|
|
@@ -19647,14 +19792,15 @@ function connectVaultHost(pluginId) {
|
|
|
19647
19792
|
throw new ClaustrumUnreachableError();
|
|
19648
19793
|
try {
|
|
19649
19794
|
const accessor = globalThis[/* @__PURE__ */ Symbol.for("cortexkit.vault")];
|
|
19650
|
-
if (typeof accessor
|
|
19651
|
-
|
|
19652
|
-
|
|
19653
|
-
|
|
19654
|
-
|
|
19795
|
+
if (typeof accessor === "function") {
|
|
19796
|
+
const client = wrapHostClient(accessor(pluginId));
|
|
19797
|
+
hostClients.add(client);
|
|
19798
|
+
return client;
|
|
19799
|
+
}
|
|
19655
19800
|
} catch {
|
|
19656
|
-
throw new ClaustrumUnreachableError();
|
|
19801
|
+
throw new ClaustrumUnreachableError("host-accessor-failed");
|
|
19657
19802
|
}
|
|
19803
|
+
throw new ClaustrumUnreachableError("host-accessor-missing");
|
|
19658
19804
|
}
|
|
19659
19805
|
var VAULT_HOST_STATUS, VAULT_HOST_CONNECT_REFUSAL, hostClients;
|
|
19660
19806
|
var init_host = __esm({
|
|
@@ -19990,7 +20136,7 @@ async function select(terminal, items, options) {
|
|
|
19990
20136
|
writeLine("");
|
|
19991
20137
|
renderedLines = lines;
|
|
19992
20138
|
};
|
|
19993
|
-
return new Promise((
|
|
20139
|
+
return new Promise((resolve29) => {
|
|
19994
20140
|
const wasRaw = stdin.isRaw ?? false;
|
|
19995
20141
|
const cleanup2 = () => {
|
|
19996
20142
|
if (cleaned)
|
|
@@ -20010,7 +20156,7 @@ async function select(terminal, items, options) {
|
|
|
20010
20156
|
};
|
|
20011
20157
|
const finish = (value) => {
|
|
20012
20158
|
cleanup2();
|
|
20013
|
-
|
|
20159
|
+
resolve29(value);
|
|
20014
20160
|
};
|
|
20015
20161
|
const onSignal = () => finish(null);
|
|
20016
20162
|
const onKey = (data) => {
|
|
@@ -20050,7 +20196,7 @@ async function select(terminal, items, options) {
|
|
|
20050
20196
|
stdin.setRawMode(true);
|
|
20051
20197
|
} catch {
|
|
20052
20198
|
cleanup2();
|
|
20053
|
-
|
|
20199
|
+
resolve29(null);
|
|
20054
20200
|
return;
|
|
20055
20201
|
}
|
|
20056
20202
|
stdin.resume();
|
|
@@ -20786,7 +20932,7 @@ var init_watch = __esm({
|
|
|
20786
20932
|
});
|
|
20787
20933
|
|
|
20788
20934
|
// ../core/dist/common-auth-embedded/claustrum/insula.js
|
|
20789
|
-
import { resolve as
|
|
20935
|
+
import { resolve as resolve7 } from "node:path";
|
|
20790
20936
|
import { storeIdentity } from "@cortexkit/claustrum-client";
|
|
20791
20937
|
import { SubcClient } from "@cortexkit/subc-client";
|
|
20792
20938
|
function insulaUsageTransport(options) {
|
|
@@ -20914,8 +21060,8 @@ function refusalCode(error) {
|
|
|
20914
21060
|
}
|
|
20915
21061
|
function acquireInsulaQuotaSource(transport, tokenPath) {
|
|
20916
21062
|
const key = JSON.stringify([
|
|
20917
|
-
|
|
20918
|
-
|
|
21063
|
+
resolve7(transport.connectionFile),
|
|
21064
|
+
resolve7(tokenPath)
|
|
20919
21065
|
]);
|
|
20920
21066
|
let shared3 = sources.get(key);
|
|
20921
21067
|
if (!shared3) {
|
|
@@ -21229,7 +21375,7 @@ var init_any_signal = __esm({
|
|
|
21229
21375
|
import { createHash as createHash6, randomBytes as randomBytes4, randomUUID as randomUUID12 } from "node:crypto";
|
|
21230
21376
|
import { constants as fsConstants } from "node:fs";
|
|
21231
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";
|
|
21232
|
-
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";
|
|
21233
21379
|
import { ClaustrumCredentialError as ClaustrumCredentialError3, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
|
|
21234
21380
|
function classifyEnrollmentError(error) {
|
|
21235
21381
|
if (!(error instanceof ClaustrumCredentialError3))
|
|
@@ -21248,6 +21394,10 @@ function enrollmentName(plugin, host) {
|
|
|
21248
21394
|
throw new ClaustrumConsumerError("invalid-state", "Claustrum enrollment names use lowercase letters, digits and dashes");
|
|
21249
21395
|
return `${plugin}-${host}`;
|
|
21250
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
|
+
}
|
|
21251
21401
|
function connectClaustrumEnrollmentClient(options) {
|
|
21252
21402
|
return ClaustrumWireClient.connect(options);
|
|
21253
21403
|
}
|
|
@@ -21263,7 +21413,7 @@ function hostEnrollmentPaths(input2) {
|
|
|
21263
21413
|
const override = input2.override?.trim();
|
|
21264
21414
|
if (override && !isAbsolute2(override) && !input2.cwd)
|
|
21265
21415
|
throw new ClaustrumConsumerError("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
21266
|
-
const tokenPath = override ? isAbsolute2(override) ? override :
|
|
21416
|
+
const tokenPath = override ? isAbsolute2(override) ? override : resolve8(input2.cwd, override) : join7(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
21267
21417
|
return getClaustrumEnrollmentPaths(tokenPath);
|
|
21268
21418
|
}
|
|
21269
21419
|
function isRecord6(value) {
|
|
@@ -21730,15 +21880,19 @@ var init_enrollment = __esm({
|
|
|
21730
21880
|
#client;
|
|
21731
21881
|
#paths;
|
|
21732
21882
|
#proposedName;
|
|
21883
|
+
#displayName;
|
|
21733
21884
|
#now;
|
|
21734
21885
|
#mintSecret;
|
|
21735
21886
|
#writeTokenFile;
|
|
21736
21887
|
#ancestorOptions;
|
|
21737
21888
|
constructor(options) {
|
|
21889
|
+
if (options.displayName !== void 0 && !validEnrollmentDisplayName(options.displayName))
|
|
21890
|
+
throw new ClaustrumConsumerError("invalid-state", "invalid Claustrum enrollment display name");
|
|
21738
21891
|
this.#ancestorOptions = options.ancestorOptions ?? {};
|
|
21739
21892
|
this.#client = options.client;
|
|
21740
21893
|
this.#paths = options.paths;
|
|
21741
21894
|
this.#proposedName = options.proposedName;
|
|
21895
|
+
this.#displayName = options.displayName;
|
|
21742
21896
|
this.#now = options.now ?? Date.now;
|
|
21743
21897
|
this.#mintSecret = options.mintSecret ?? (() => randomBytes4(32).toString("hex"));
|
|
21744
21898
|
this.#writeTokenFile = options.writeTokenFile ?? writeEnrollmentTokenFile;
|
|
@@ -21828,10 +21982,23 @@ var init_enrollment = __esm({
|
|
|
21828
21982
|
if (!state.requestId) {
|
|
21829
21983
|
try {
|
|
21830
21984
|
const requestSecretHash = createHash6("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
|
|
21831
|
-
const
|
|
21985
|
+
const proposal = {
|
|
21832
21986
|
name: state.proposedName,
|
|
21833
21987
|
requestSecretHash
|
|
21834
|
-
}
|
|
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
|
+
}
|
|
21835
22002
|
state = {
|
|
21836
22003
|
...state,
|
|
21837
22004
|
requestId: proposed.requestId,
|
|
@@ -21998,10 +22165,10 @@ async function drainShutdown(pending, onTimeout) {
|
|
|
21998
22165
|
try {
|
|
21999
22166
|
await Promise.race([
|
|
22000
22167
|
drained,
|
|
22001
|
-
new Promise((
|
|
22168
|
+
new Promise((resolve29) => {
|
|
22002
22169
|
timer = setTimeout(() => {
|
|
22003
22170
|
expired = true;
|
|
22004
|
-
|
|
22171
|
+
resolve29();
|
|
22005
22172
|
}, 2e3);
|
|
22006
22173
|
})
|
|
22007
22174
|
]);
|
|
@@ -22345,8 +22512,15 @@ var init_custody = __esm({
|
|
|
22345
22512
|
this.#warnShutdown = shutdownWarning(this.#logger);
|
|
22346
22513
|
this.#setTimeout = options.setTimeoutImpl ?? setTimeout;
|
|
22347
22514
|
this.#clearTimeout = options.clearTimeoutImpl ?? clearTimeout;
|
|
22515
|
+
const currentClient = () => this.#client;
|
|
22348
22516
|
this.#usage = new ScopedUsageReporter({
|
|
22349
|
-
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
|
+
},
|
|
22350
22524
|
owns: (id) => this.#usageServed.has(id),
|
|
22351
22525
|
token: async () => hasVaultHost() ? "" : checkedEnrollmentToken(await this.#readToken()),
|
|
22352
22526
|
logger: this.#logger,
|
|
@@ -22354,12 +22528,30 @@ var init_custody = __esm({
|
|
|
22354
22528
|
clearTimeout: this.#clearTimeout
|
|
22355
22529
|
});
|
|
22356
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
|
+
}
|
|
22357
22549
|
/** A watch losing its transport is the same outage as an unreachable read. */
|
|
22358
22550
|
transportLost(error) {
|
|
22359
22551
|
if (this.#closed || this.#outage)
|
|
22360
22552
|
return;
|
|
22361
22553
|
this.#outage = true;
|
|
22362
|
-
this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError();
|
|
22554
|
+
this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
|
|
22363
22555
|
this.#logger.warn("serving kept vault receipt", { reason: "unreachable" });
|
|
22364
22556
|
this.#scheduleProbe();
|
|
22365
22557
|
}
|
|
@@ -22457,7 +22649,7 @@ var init_custody = __esm({
|
|
|
22457
22649
|
if (error instanceof ClaustrumCredentialError5)
|
|
22458
22650
|
throw error;
|
|
22459
22651
|
if (classifyVaultFailure(error) === "unreachable")
|
|
22460
|
-
throw new ClaustrumUnreachableError();
|
|
22652
|
+
throw new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
|
|
22461
22653
|
throw new ClaustrumConsumerError("unavailable", "Claustrum scoped operation unavailable");
|
|
22462
22654
|
} finally {
|
|
22463
22655
|
removeAbortListener?.();
|
|
@@ -22673,7 +22865,7 @@ var init_custody = __esm({
|
|
|
22673
22865
|
if (kept.since === null)
|
|
22674
22866
|
kept.since = this.#now();
|
|
22675
22867
|
const attempt = Object.freeze(Object.defineProperty({ ...kept.attempt, fromKeptReceipt: true }, "accessToken", { value: kept.attempt.accessToken, enumerable: false }));
|
|
22676
|
-
this.#provenance.set(attempt, this.#provenance.get(kept.attempt) ?? { token
|
|
22868
|
+
this.#provenance.set(attempt, this.#provenance.get(kept.attempt) ?? { token });
|
|
22677
22869
|
this.#keptAttempts.set(attempt, routeId);
|
|
22678
22870
|
return attempt;
|
|
22679
22871
|
}
|
|
@@ -22734,15 +22926,15 @@ var init_custody = __esm({
|
|
|
22734
22926
|
recordVersion: served.recordVersion,
|
|
22735
22927
|
expiresAtMs
|
|
22736
22928
|
}, "accessToken", { value: accessToken, enumerable: false }));
|
|
22737
|
-
this.#provenance.set(attempt, { token
|
|
22929
|
+
this.#provenance.set(attempt, { token });
|
|
22738
22930
|
return attempt;
|
|
22739
22931
|
}
|
|
22740
22932
|
/**
|
|
22741
22933
|
* Report that a send this consumer actually made was rejected. Only a 401
|
|
22742
22934
|
* is reported (the vault refuses 429, 402 and 5xx reports), addressed by
|
|
22743
22935
|
* credential id with the exact record version that send was served, and
|
|
22744
|
-
* sent through the client
|
|
22745
|
-
* 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.
|
|
22746
22938
|
*/
|
|
22747
22939
|
async reportFailure(attempt, status, reporterSource) {
|
|
22748
22940
|
if (status !== 401)
|
|
@@ -22766,7 +22958,7 @@ var init_custody = __esm({
|
|
|
22766
22958
|
const pending = this.#reports.get(attempt);
|
|
22767
22959
|
if (pending)
|
|
22768
22960
|
return pending;
|
|
22769
|
-
const report = this.#call(() =>
|
|
22961
|
+
const report = this.#call(() => this.#client.reportAuthFailureScoped({
|
|
22770
22962
|
credentialId: attempt.credentialId,
|
|
22771
22963
|
enrollmentToken: provenance.token,
|
|
22772
22964
|
providerStatus: 401,
|
|
@@ -22807,34 +22999,64 @@ var init_custody = __esm({
|
|
|
22807
22999
|
*/
|
|
22808
23000
|
watchRoster(options) {
|
|
22809
23001
|
this.#check();
|
|
22810
|
-
const
|
|
22811
|
-
|
|
22812
|
-
|
|
22813
|
-
|
|
22814
|
-
|
|
22815
|
-
|
|
22816
|
-
|
|
22817
|
-
|
|
22818
|
-
|
|
22819
|
-
|
|
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();
|
|
22820
23049
|
},
|
|
22821
|
-
|
|
22822
|
-
|
|
22823
|
-
|
|
22824
|
-
onMode: options.onMode,
|
|
22825
|
-
logger: this.#logger,
|
|
22826
|
-
now: this.#now,
|
|
22827
|
-
setTimeoutImpl: this.#setTimeout,
|
|
22828
|
-
clearTimeoutImpl: this.#clearTimeout
|
|
22829
|
-
});
|
|
22830
|
-
this.#watches.add(watch);
|
|
23050
|
+
stop: () => watch.stop()
|
|
23051
|
+
};
|
|
23052
|
+
this.#watches.add(tracked);
|
|
22831
23053
|
watch.start();
|
|
22832
23054
|
return {
|
|
22833
23055
|
get mode() {
|
|
22834
23056
|
return watch.mode;
|
|
22835
23057
|
},
|
|
22836
23058
|
close: () => {
|
|
22837
|
-
this.#watches.delete(
|
|
23059
|
+
this.#watches.delete(tracked);
|
|
22838
23060
|
watch.stop();
|
|
22839
23061
|
}
|
|
22840
23062
|
};
|
|
@@ -22974,7 +23196,7 @@ var init_interlock = __esm({
|
|
|
22974
23196
|
// ../core/dist/common-auth-embedded/claustrum/roster.js
|
|
22975
23197
|
import { createHash as createHash7 } from "node:crypto";
|
|
22976
23198
|
import { stat as stat6 } from "node:fs/promises";
|
|
22977
|
-
import { resolve as
|
|
23199
|
+
import { resolve as resolve9 } from "node:path";
|
|
22978
23200
|
function vaultRosterSeed(roster) {
|
|
22979
23201
|
return {
|
|
22980
23202
|
declined: roster.declined.map((entry) => ({ ...entry })),
|
|
@@ -23376,16 +23598,16 @@ function applyVaultQuota(current, input2) {
|
|
|
23376
23598
|
};
|
|
23377
23599
|
}
|
|
23378
23600
|
function forgetPendingVaultDiscovery(path5) {
|
|
23379
|
-
pendingDiscoveries.delete(
|
|
23601
|
+
pendingDiscoveries.delete(resolve9(path5));
|
|
23380
23602
|
}
|
|
23381
23603
|
function isVaultRosterLockRefusal(path5, error) {
|
|
23382
|
-
const target =
|
|
23604
|
+
const target = resolve9(path5);
|
|
23383
23605
|
if (error instanceof ClaustrumConsumerError)
|
|
23384
23606
|
return error.kind === "roster-busy";
|
|
23385
23607
|
if (error instanceof LockContentionError || error instanceof LockOwnershipError)
|
|
23386
|
-
return
|
|
23608
|
+
return resolve9(error.details.target) === target;
|
|
23387
23609
|
if (error instanceof PrivateFileError) {
|
|
23388
|
-
const failed =
|
|
23610
|
+
const failed = resolve9(error.path);
|
|
23389
23611
|
return [WRITE_LOCK.name, DISCOVERY_LEASE.name].some((name) => {
|
|
23390
23612
|
const lock = lockPathFor(target, name);
|
|
23391
23613
|
return failed === lock || failed.startsWith(`${lock}.`);
|
|
@@ -23446,7 +23668,7 @@ async function refreshVaultRoster(options) {
|
|
|
23446
23668
|
throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
|
|
23447
23669
|
return persisted;
|
|
23448
23670
|
}
|
|
23449
|
-
const key =
|
|
23671
|
+
const key = resolve9(options.path);
|
|
23450
23672
|
const listedOver = options.listedOver;
|
|
23451
23673
|
let discovered;
|
|
23452
23674
|
try {
|
|
@@ -23570,9 +23792,9 @@ var init_roster = __esm({
|
|
|
23570
23792
|
});
|
|
23571
23793
|
|
|
23572
23794
|
// ../core/dist/common-auth-embedded/claustrum/quota-writer.js
|
|
23573
|
-
import { resolve as
|
|
23795
|
+
import { resolve as resolve10 } from "node:path";
|
|
23574
23796
|
function writerFor(path5, clock2 = quotaCommitTimer) {
|
|
23575
|
-
const key =
|
|
23797
|
+
const key = resolve10(path5);
|
|
23576
23798
|
let writer = writers.get(key);
|
|
23577
23799
|
if (!writer) {
|
|
23578
23800
|
writer = {
|
|
@@ -23636,7 +23858,7 @@ function orderedFields(pending) {
|
|
|
23636
23858
|
return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
|
|
23637
23859
|
}
|
|
23638
23860
|
function pendingVaultQuota(path5, roster) {
|
|
23639
|
-
const writer = writers.get(
|
|
23861
|
+
const writer = writers.get(resolve10(path5));
|
|
23640
23862
|
if (writer) {
|
|
23641
23863
|
for (const field of orderedFields(writer.pending)) {
|
|
23642
23864
|
if (field.priorReading)
|
|
@@ -23647,7 +23869,7 @@ function pendingVaultQuota(path5, roster) {
|
|
|
23647
23869
|
return roster;
|
|
23648
23870
|
}
|
|
23649
23871
|
function hasPendingVaultQuota(path5) {
|
|
23650
|
-
return !!writers.get(
|
|
23872
|
+
return !!writers.get(resolve10(path5))?.pending.size;
|
|
23651
23873
|
}
|
|
23652
23874
|
function schedule(writer, delay3) {
|
|
23653
23875
|
if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
|
|
@@ -23712,7 +23934,7 @@ function flush(writer) {
|
|
|
23712
23934
|
return writer.running;
|
|
23713
23935
|
}
|
|
23714
23936
|
async function drainVaultQuota(path5, timeoutMs = 1e3) {
|
|
23715
|
-
const key =
|
|
23937
|
+
const key = resolve10(path5);
|
|
23716
23938
|
const writer = writers.get(key);
|
|
23717
23939
|
if (!writer)
|
|
23718
23940
|
return;
|
|
@@ -23860,7 +24082,7 @@ var init_consumer = __esm({
|
|
|
23860
24082
|
this.#shutdown.signal,
|
|
23861
24083
|
...signal ? [signal] : []
|
|
23862
24084
|
]);
|
|
23863
|
-
return new Promise((
|
|
24085
|
+
return new Promise((resolve29, reject) => {
|
|
23864
24086
|
const cleanup2 = () => {
|
|
23865
24087
|
combined.signal.removeEventListener("abort", abort);
|
|
23866
24088
|
combined.dispose();
|
|
@@ -23875,7 +24097,7 @@ var init_consumer = __esm({
|
|
|
23875
24097
|
if (combined.signal.aborted)
|
|
23876
24098
|
reject(combined.signal.reason);
|
|
23877
24099
|
else
|
|
23878
|
-
|
|
24100
|
+
resolve29(value);
|
|
23879
24101
|
}, (error) => {
|
|
23880
24102
|
cleanup2();
|
|
23881
24103
|
reject(error);
|
|
@@ -24620,7 +24842,7 @@ var init_consumer = __esm({
|
|
|
24620
24842
|
import { createHash as createHash8 } from "node:crypto";
|
|
24621
24843
|
import { channel as channel2 } from "node:diagnostics_channel";
|
|
24622
24844
|
import { readdir, stat as stat7 } from "node:fs/promises";
|
|
24623
|
-
import { dirname as dirname10, join as join8, resolve as
|
|
24845
|
+
import { dirname as dirname10, join as join8, resolve as resolve11 } from "node:path";
|
|
24624
24846
|
function canonicalJson3(value, path5 = /* @__PURE__ */ new Set()) {
|
|
24625
24847
|
if (value === null)
|
|
24626
24848
|
return "null";
|
|
@@ -24681,12 +24903,12 @@ function unreachableConnect2() {
|
|
|
24681
24903
|
return new ClaustrumUnreachableError();
|
|
24682
24904
|
}
|
|
24683
24905
|
function untilAborted(pending, signal) {
|
|
24684
|
-
return new Promise((
|
|
24906
|
+
return new Promise((resolve29, reject) => {
|
|
24685
24907
|
const abort = () => reject(signal.reason);
|
|
24686
24908
|
signal.addEventListener("abort", abort, { once: true });
|
|
24687
24909
|
pending.then((value) => {
|
|
24688
24910
|
signal.removeEventListener("abort", abort);
|
|
24689
|
-
|
|
24911
|
+
resolve29(value);
|
|
24690
24912
|
}, (error) => {
|
|
24691
24913
|
signal.removeEventListener("abort", abort);
|
|
24692
24914
|
reject(error);
|
|
@@ -24844,7 +25066,7 @@ var init_hub = __esm({
|
|
|
24844
25066
|
};
|
|
24845
25067
|
const { consumer, hooks } = createHubMember(port, consumerOptions);
|
|
24846
25068
|
entry.hooks = hooks;
|
|
24847
|
-
const path5 =
|
|
25069
|
+
const path5 = resolve11(entry.path);
|
|
24848
25070
|
const subscribers = sharedRosters.get(path5) ?? /* @__PURE__ */ new Set();
|
|
24849
25071
|
const install = (roster) => {
|
|
24850
25072
|
if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
|
|
@@ -24875,7 +25097,7 @@ var init_hub = __esm({
|
|
|
24875
25097
|
return;
|
|
24876
25098
|
entry.seen = JSON.stringify(decodedVaultRoster(roster));
|
|
24877
25099
|
entry.hooks?.install(roster);
|
|
24878
|
-
for (const install of sharedRosters.get(
|
|
25100
|
+
for (const install of sharedRosters.get(resolve11(entry.path)) ?? []) {
|
|
24879
25101
|
if (!this.#live(generation))
|
|
24880
25102
|
return;
|
|
24881
25103
|
if (install !== entry.receiveRoster)
|
|
@@ -25678,6 +25900,7 @@ __export(claustrum_exports, {
|
|
|
25678
25900
|
reorderVaultRoster: () => reorderVaultRoster,
|
|
25679
25901
|
resetClaustrumEnrollmentState: () => resetClaustrumEnrollmentState,
|
|
25680
25902
|
resolveVaultPrimary: () => resolveVaultPrimary,
|
|
25903
|
+
validEnrollmentDisplayName: () => validEnrollmentDisplayName,
|
|
25681
25904
|
vaultAuthority: () => vaultAuthority,
|
|
25682
25905
|
vaultRosterSeed: () => vaultRosterSeed,
|
|
25683
25906
|
vaultRoutingRows: () => vaultRoutingRows
|
|
@@ -25934,7 +26157,7 @@ var init_lock = __esm({
|
|
|
25934
26157
|
import { createHash as createHash9 } from "node:crypto";
|
|
25935
26158
|
import { constants as constants2 } from "node:fs";
|
|
25936
26159
|
import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
|
|
25937
|
-
import { dirname as dirname11, resolve as
|
|
26160
|
+
import { dirname as dirname11, resolve as resolve12 } from "node:path";
|
|
25938
26161
|
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
25939
26162
|
function rootSpans(text2) {
|
|
25940
26163
|
let i = text2.indexOf("{") + 1;
|
|
@@ -26135,8 +26358,8 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
26135
26358
|
if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
|
|
26136
26359
|
throw new PiSlotError("invalid-options");
|
|
26137
26360
|
}
|
|
26138
|
-
const authPath =
|
|
26139
|
-
const stashPath =
|
|
26361
|
+
const authPath = resolve12(options.authPath);
|
|
26362
|
+
const stashPath = resolve12(options.stashPath);
|
|
26140
26363
|
if (authPath === stashPath || stashPath === `${authPath}.lock`) {
|
|
26141
26364
|
throw new PiSlotError("invalid-options");
|
|
26142
26365
|
}
|
|
@@ -26759,8 +26982,8 @@ function getDefaultTierId(allowedTiers) {
|
|
|
26759
26982
|
return allowedTiers[0]?.id;
|
|
26760
26983
|
}
|
|
26761
26984
|
function wait(ms) {
|
|
26762
|
-
return new Promise((
|
|
26763
|
-
setTimeout(
|
|
26985
|
+
return new Promise((resolve29) => {
|
|
26986
|
+
setTimeout(resolve29, ms);
|
|
26764
26987
|
});
|
|
26765
26988
|
}
|
|
26766
26989
|
function extractManagedProjectId(payload) {
|
|
@@ -27579,7 +27802,7 @@ function applyAgyNativeGenerationConfig(wireModel, generationConfig) {
|
|
|
27579
27802
|
generationConfig.maxOutputTokens = output2;
|
|
27580
27803
|
}
|
|
27581
27804
|
delete generationConfig.max_output_tokens;
|
|
27582
|
-
if (isGeminiArgonModel(wireModel) && native.thinkingLevel !== void 0) {
|
|
27805
|
+
if ((isGeminiArgonModel(wireModel) || isGeminiCarbonModel(wireModel)) && native.thinkingLevel !== void 0) {
|
|
27583
27806
|
generationConfig.thinkingConfig = {
|
|
27584
27807
|
includeThoughts: true,
|
|
27585
27808
|
thinkingLevel: ADAPTIVE_LEVELS[native.thinkingLevel]
|
|
@@ -28338,7 +28561,7 @@ var init_cross_model_sanitizer = __esm({
|
|
|
28338
28561
|
// ../core/dist/transform/model-resolver.js
|
|
28339
28562
|
function supportsThinkingTiers(model) {
|
|
28340
28563
|
const lower = model.toLowerCase();
|
|
28341
|
-
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));
|
|
28342
28565
|
}
|
|
28343
28566
|
function extractThinkingTierFromModel(model) {
|
|
28344
28567
|
if (!supportsThinkingTiers(model)) {
|
|
@@ -28398,9 +28621,10 @@ function resolveModelWithTier(requestedModel) {
|
|
|
28398
28621
|
const baseName = tier ? modelWithoutQuota.replace(TIER_REGEX, "") : modelWithoutQuota;
|
|
28399
28622
|
const isImageModel = IMAGE_GENERATION_MODELS.test(modelWithoutQuota);
|
|
28400
28623
|
const isArgon = isGeminiArgonModel(modelWithoutQuota);
|
|
28401
|
-
|
|
28624
|
+
const isCarbon = isGeminiCarbonModel(modelWithoutQuota);
|
|
28625
|
+
if (isArgon || isCarbon) {
|
|
28402
28626
|
return {
|
|
28403
|
-
actualModel: getGeminiArgonAntigravityModel(tier),
|
|
28627
|
+
actualModel: isCarbon ? getGeminiCarbonAntigravityModel(tier) : getGeminiArgonAntigravityModel(tier),
|
|
28404
28628
|
thinkingLevel: tier ?? "medium",
|
|
28405
28629
|
tier: tier ?? "medium",
|
|
28406
28630
|
isThinkingModel: true
|
|
@@ -29082,12 +29306,12 @@ var init_vault_provider_state = __esm({
|
|
|
29082
29306
|
function untilAborted2(pending, signal) {
|
|
29083
29307
|
if (!signal)
|
|
29084
29308
|
return pending;
|
|
29085
|
-
return new Promise((
|
|
29309
|
+
return new Promise((resolve29, reject) => {
|
|
29086
29310
|
const abort = () => reject(signal.reason);
|
|
29087
29311
|
signal.addEventListener("abort", abort, { once: true });
|
|
29088
29312
|
if (signal.aborted)
|
|
29089
29313
|
abort();
|
|
29090
|
-
pending.then(
|
|
29314
|
+
pending.then(resolve29, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
29091
29315
|
});
|
|
29092
29316
|
}
|
|
29093
29317
|
async function resolveClaustrumConnectionPath(explicit) {
|
|
@@ -29562,7 +29786,7 @@ var init_capture_sink2 = __esm({
|
|
|
29562
29786
|
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
29563
29787
|
import { lstat as lstat6, readFile as readFile8, rename as rename8, unlink as unlink8 } from "node:fs/promises";
|
|
29564
29788
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
29565
|
-
import { dirname as dirname13, join as join10, resolve as
|
|
29789
|
+
import { dirname as dirname13, join as join10, resolve as resolve13 } from "node:path";
|
|
29566
29790
|
function ioCode2(detail) {
|
|
29567
29791
|
if (detail?.reason === "io-error") {
|
|
29568
29792
|
if (detail.win32Code === 2 || detail.win32Code === 3)
|
|
@@ -29612,7 +29836,7 @@ async function privateOperation2(path5, stage, operation) {
|
|
|
29612
29836
|
}
|
|
29613
29837
|
}
|
|
29614
29838
|
async function verifySafeDirectory2(path5, options) {
|
|
29615
|
-
path5 =
|
|
29839
|
+
path5 = resolve13(path5);
|
|
29616
29840
|
options ??= safeParentOptionsForTest2;
|
|
29617
29841
|
await privateOperation2(path5, "safe-parent", async () => {
|
|
29618
29842
|
const result = await (await loadBackend2()).verifySafeParent(path5, options);
|
|
@@ -29627,7 +29851,7 @@ async function verifySafeDirectory2(path5, options) {
|
|
|
29627
29851
|
});
|
|
29628
29852
|
}
|
|
29629
29853
|
async function verifyPrivate2(path5, kind, migrate = false) {
|
|
29630
|
-
path5 =
|
|
29854
|
+
path5 = resolve13(path5);
|
|
29631
29855
|
if (kind === "directory")
|
|
29632
29856
|
return verifySafeDirectory2(path5);
|
|
29633
29857
|
await privateOperation2(path5, "verify", async () => {
|
|
@@ -29662,7 +29886,7 @@ async function verifyPrivate2(path5, kind, migrate = false) {
|
|
|
29662
29886
|
});
|
|
29663
29887
|
}
|
|
29664
29888
|
async function ensurePrivateDirectory2(path5, _migrate = false, options) {
|
|
29665
|
-
path5 =
|
|
29889
|
+
path5 = resolve13(path5);
|
|
29666
29890
|
await privateOperation2(path5, "directory", async () => {
|
|
29667
29891
|
const api = await loadBackend2();
|
|
29668
29892
|
try {
|
|
@@ -29693,7 +29917,7 @@ async function readPrivateText2(path5, migrate = false) {
|
|
|
29693
29917
|
async function readPrivateBuffer2(path5, migrate = false) {
|
|
29694
29918
|
if (!windowsPrivateFiles2)
|
|
29695
29919
|
return readFile8(path5);
|
|
29696
|
-
path5 =
|
|
29920
|
+
path5 = resolve13(path5);
|
|
29697
29921
|
if (migrate) {
|
|
29698
29922
|
await verifySafeDirectory2(dirname13(path5));
|
|
29699
29923
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -29701,20 +29925,20 @@ async function readPrivateBuffer2(path5, migrate = false) {
|
|
|
29701
29925
|
return privateOperation2(path5, "read", async () => (await loadBackend2()).readOwnerOnly(path5));
|
|
29702
29926
|
}
|
|
29703
29927
|
async function createPrivateBytes2(path5, bytes) {
|
|
29704
|
-
await verifySafeDirectory2(dirname13(
|
|
29928
|
+
await verifySafeDirectory2(dirname13(resolve13(path5)));
|
|
29705
29929
|
await privateOperation2(path5, "create", async () => {
|
|
29706
|
-
await (await loadBackend2()).createPrivateFile(
|
|
29930
|
+
await (await loadBackend2()).createPrivateFile(resolve13(path5), bytes);
|
|
29707
29931
|
});
|
|
29708
29932
|
}
|
|
29709
29933
|
async function createPrivateDirectoryExclusive2(path5) {
|
|
29710
|
-
await verifySafeDirectory2(dirname13(
|
|
29934
|
+
await verifySafeDirectory2(dirname13(resolve13(path5)));
|
|
29711
29935
|
await privateOperation2(path5, "directory-create", async () => {
|
|
29712
|
-
await (await loadBackend2()).createOwnerOnly(
|
|
29936
|
+
await (await loadBackend2()).createOwnerOnly(resolve13(path5), { kind: "dir" });
|
|
29713
29937
|
});
|
|
29714
29938
|
}
|
|
29715
29939
|
async function replaceWindowsFile2(from, to, options = {}) {
|
|
29716
|
-
from =
|
|
29717
|
-
to =
|
|
29940
|
+
from = resolve13(from);
|
|
29941
|
+
to = resolve13(to);
|
|
29718
29942
|
const now = options.now ?? (() => performance.now());
|
|
29719
29943
|
const start = now();
|
|
29720
29944
|
const leaseDeadline = options.deadline ?? Infinity;
|
|
@@ -29757,7 +29981,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
|
|
|
29757
29981
|
throw error;
|
|
29758
29982
|
}
|
|
29759
29983
|
async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
29760
|
-
path5 =
|
|
29984
|
+
path5 = resolve13(path5);
|
|
29761
29985
|
await ensurePrivateDirectory2(dirname13(path5));
|
|
29762
29986
|
try {
|
|
29763
29987
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -29765,7 +29989,7 @@ async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
|
29765
29989
|
if (error.code !== "ENOENT")
|
|
29766
29990
|
throw error;
|
|
29767
29991
|
}
|
|
29768
|
-
const stage =
|
|
29992
|
+
const stage = resolve13(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
|
|
29769
29993
|
if (dirname13(stage) !== dirname13(path5))
|
|
29770
29994
|
throw new PrivateFileError2(path5, "stage-directory", { code: "EXDEV" });
|
|
29771
29995
|
let created = false;
|
|
@@ -29931,7 +30155,7 @@ var init_redact2 = __esm({
|
|
|
29931
30155
|
// src/common-auth-embedded/logger/engine.js
|
|
29932
30156
|
import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
|
|
29933
30157
|
import { open as open8 } from "node:fs/promises";
|
|
29934
|
-
import { dirname as dirname14, resolve as
|
|
30158
|
+
import { dirname as dirname14, resolve as resolve14 } from "node:path";
|
|
29935
30159
|
function chmodPrivate2(path5) {
|
|
29936
30160
|
try {
|
|
29937
30161
|
chmodSync2(path5, 384);
|
|
@@ -29982,7 +30206,7 @@ async function openWindowsFile2(sink, file) {
|
|
|
29982
30206
|
return sink.handle;
|
|
29983
30207
|
}
|
|
29984
30208
|
async function flushWindowsFile2(sink, file, text2) {
|
|
29985
|
-
file =
|
|
30209
|
+
file = resolve14(file);
|
|
29986
30210
|
try {
|
|
29987
30211
|
if (sink.file !== file)
|
|
29988
30212
|
await closeWindowsFile2(sink);
|
|
@@ -30229,13 +30453,17 @@ var init_logger3 = __esm({
|
|
|
30229
30453
|
|
|
30230
30454
|
// src/logging/provider-key-policy.ts
|
|
30231
30455
|
function isProviderSecretKey(normalizedKey2) {
|
|
30232
|
-
return /token|refresh|access|project|fingerprint|deviceid|sessionid|sessiontoken|secret|password|apikey|clientsecret/.test(
|
|
30456
|
+
return /token|refresh|access|project|fingerprint|deviceid|sessionid|sessiontoken|secret|password|apikey|clientsecret|callback|redirecturl|authorizationcode/.test(
|
|
30233
30457
|
normalizedKey2
|
|
30234
30458
|
);
|
|
30235
30459
|
}
|
|
30460
|
+
var OAUTH_REDIRECT_VALUE_PATTERNS;
|
|
30236
30461
|
var init_provider_key_policy = __esm({
|
|
30237
30462
|
"src/logging/provider-key-policy.ts"() {
|
|
30238
30463
|
"use strict";
|
|
30464
|
+
OAUTH_REDIRECT_VALUE_PATTERNS = [
|
|
30465
|
+
/https?:\/\/[^\s<>"']*[?&](?:code|state)=[^\s<>"']*/gi
|
|
30466
|
+
];
|
|
30239
30467
|
}
|
|
30240
30468
|
});
|
|
30241
30469
|
|
|
@@ -30582,12 +30810,12 @@ function createVaultAccountPool(options) {
|
|
|
30582
30810
|
try {
|
|
30583
30811
|
return await Promise.race([
|
|
30584
30812
|
read.then(() => true),
|
|
30585
|
-
new Promise((
|
|
30813
|
+
new Promise((resolve29, reject) => {
|
|
30586
30814
|
const abort = () => reject(signal?.reason);
|
|
30587
30815
|
signal?.addEventListener("abort", abort, { once: true });
|
|
30588
30816
|
detachAbort = () => signal?.removeEventListener("abort", abort);
|
|
30589
30817
|
if (remaining !== void 0)
|
|
30590
|
-
cancelTimer2 = schedule2(() =>
|
|
30818
|
+
cancelTimer2 = schedule2(() => resolve29(false), remaining);
|
|
30591
30819
|
if (signal?.aborted) abort();
|
|
30592
30820
|
})
|
|
30593
30821
|
]);
|
|
@@ -31089,11 +31317,11 @@ function createOpenCodeVaultCustody(options) {
|
|
|
31089
31317
|
].join("\n");
|
|
31090
31318
|
const waitForApproval = async () => {
|
|
31091
31319
|
while (!closed2) {
|
|
31092
|
-
await new Promise((
|
|
31320
|
+
await new Promise((resolve29) => {
|
|
31093
31321
|
const done = () => {
|
|
31094
31322
|
clearTimeout(timer);
|
|
31095
31323
|
cancelWait = void 0;
|
|
31096
|
-
|
|
31324
|
+
resolve29();
|
|
31097
31325
|
};
|
|
31098
31326
|
const timer = setTimeout(done, 2e3);
|
|
31099
31327
|
timer.unref?.();
|
|
@@ -31493,7 +31721,7 @@ import { randomUUID as randomUUID14 } from "node:crypto";
|
|
|
31493
31721
|
import { realpathSync, rmSync } from "node:fs";
|
|
31494
31722
|
import { chmod as chmod4, mkdir as mkdir12, readFile as readFile10, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
|
|
31495
31723
|
import { homedir as homedir2 } from "node:os";
|
|
31496
|
-
import { join as join12, resolve as
|
|
31724
|
+
import { join as join12, resolve as resolve15 } from "node:path";
|
|
31497
31725
|
function processHeartbeatDir() {
|
|
31498
31726
|
const base = process.env.XDG_STATE_HOME || join12(homedir2(), ".local", "state");
|
|
31499
31727
|
return join12(base, "cortexkit", "antigravity-auth", "processes");
|
|
@@ -31506,7 +31734,7 @@ function processConfigFolderKey() {
|
|
|
31506
31734
|
try {
|
|
31507
31735
|
return realpathSync.native(folder);
|
|
31508
31736
|
} catch {
|
|
31509
|
-
return
|
|
31737
|
+
return resolve15(folder);
|
|
31510
31738
|
}
|
|
31511
31739
|
}
|
|
31512
31740
|
function processHasOlderGeneration() {
|
|
@@ -32090,7 +32318,7 @@ import {
|
|
|
32090
32318
|
stat as stat11,
|
|
32091
32319
|
unlink as unlink10
|
|
32092
32320
|
} from "node:fs/promises";
|
|
32093
|
-
import { basename as basename4, dirname as dirname15, join as join14, resolve as
|
|
32321
|
+
import { basename as basename4, dirname as dirname15, join as join14, resolve as resolve16 } from "node:path";
|
|
32094
32322
|
function refusalMessage(stateDir, errorClass2) {
|
|
32095
32323
|
if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
|
|
32096
32324
|
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.`;
|
|
@@ -32950,7 +33178,7 @@ async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
|
|
|
32950
33178
|
if (process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR) return;
|
|
32951
33179
|
const location = runtimeLayoutLocation();
|
|
32952
33180
|
const files = layoutFiles(location, accountFile);
|
|
32953
|
-
if (
|
|
33181
|
+
if (resolve16(vaultDir) !== resolve16(files.vault.next)) return;
|
|
32954
33182
|
const stateDir = location.stateHomeDir;
|
|
32955
33183
|
const marker = await readMarker(
|
|
32956
33184
|
join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
@@ -33379,7 +33607,7 @@ import {
|
|
|
33379
33607
|
writeFileSync
|
|
33380
33608
|
} from "node:fs";
|
|
33381
33609
|
import { homedir as homedir4 } from "node:os";
|
|
33382
|
-
import { dirname as dirname16, join as join15, resolve as
|
|
33610
|
+
import { dirname as dirname16, join as join15, resolve as resolve17 } from "node:path";
|
|
33383
33611
|
async function ensureGitignore(configDir) {
|
|
33384
33612
|
const gitignorePath = join15(configDir, ".gitignore");
|
|
33385
33613
|
try {
|
|
@@ -33479,8 +33707,8 @@ function migrateLegacyWindowsConfig() {
|
|
|
33479
33707
|
}
|
|
33480
33708
|
}
|
|
33481
33709
|
function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
33482
|
-
const standard =
|
|
33483
|
-
const legacy =
|
|
33710
|
+
const standard = resolve17(newPath);
|
|
33711
|
+
const legacy = resolve17(legacyPath);
|
|
33484
33712
|
if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
|
|
33485
33713
|
const standardPointer = existsSync3(accountStorePointerPath(standard));
|
|
33486
33714
|
const legacyPointer = existsSync3(accountStorePointerPath(legacy));
|
|
@@ -33502,7 +33730,7 @@ function getStoragePathWithMigration() {
|
|
|
33502
33730
|
"antigravity-accounts.json"
|
|
33503
33731
|
);
|
|
33504
33732
|
const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
|
|
33505
|
-
if (
|
|
33733
|
+
if (resolve17(anchored).toLowerCase() !== resolve17(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve17(anchored)))) {
|
|
33506
33734
|
log6.info("Using legacy Windows config path (migration failed)", {
|
|
33507
33735
|
legacyPath,
|
|
33508
33736
|
newPath
|
|
@@ -33519,7 +33747,7 @@ function accountFileForVault(configDir = getConfigDir()) {
|
|
|
33519
33747
|
const configured = join15(configDir, "antigravity-accounts.json");
|
|
33520
33748
|
if (process.platform !== "win32") return configured;
|
|
33521
33749
|
const legacyDir = getLegacyWindowsConfigDir();
|
|
33522
|
-
if (
|
|
33750
|
+
if (resolve17(configDir).toLowerCase() === resolve17(legacyDir).toLowerCase())
|
|
33523
33751
|
return configured;
|
|
33524
33752
|
const configuredVault = join15(configDir, "antigravity-auth-vault");
|
|
33525
33753
|
const legacyVault = join15(legacyDir, "antigravity-auth-vault");
|
|
@@ -33550,7 +33778,7 @@ function getStoragePath() {
|
|
|
33550
33778
|
}
|
|
33551
33779
|
async function assertLegacyPoolInUse(legacyPath) {
|
|
33552
33780
|
try {
|
|
33553
|
-
await assertLegacyAccountStorageWritable(
|
|
33781
|
+
await assertLegacyAccountStorageWritable(resolve17(legacyPath));
|
|
33554
33782
|
} catch (error) {
|
|
33555
33783
|
throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
|
|
33556
33784
|
}
|
|
@@ -33570,7 +33798,7 @@ function refusalMessage2(admission) {
|
|
|
33570
33798
|
async function bindingOf(options) {
|
|
33571
33799
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
33572
33800
|
const now = options.now ?? (() => Date.now());
|
|
33573
|
-
const legacyPath =
|
|
33801
|
+
const legacyPath = resolve17(options.legacyPath ?? getStoragePath());
|
|
33574
33802
|
return {
|
|
33575
33803
|
legacyPath,
|
|
33576
33804
|
now,
|
|
@@ -33639,7 +33867,7 @@ async function openAccountStore(options) {
|
|
|
33639
33867
|
async function initializeFreshAccountStoreFor(modules, options = {}) {
|
|
33640
33868
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
33641
33869
|
return initializeFreshAccountStore(modules, {
|
|
33642
|
-
legacyPath:
|
|
33870
|
+
legacyPath: resolve17(options.legacyPath ?? getStoragePath()),
|
|
33643
33871
|
now: options.now ?? (() => Date.now())
|
|
33644
33872
|
});
|
|
33645
33873
|
}
|
|
@@ -33717,12 +33945,12 @@ var init_storage = __esm({
|
|
|
33717
33945
|
import { createHash as createHash12 } from "node:crypto";
|
|
33718
33946
|
import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
33719
33947
|
import { homedir as homedir5 } from "node:os";
|
|
33720
|
-
import { dirname as dirname17, join as join16, resolve as
|
|
33948
|
+
import { dirname as dirname17, join as join16, resolve as resolve18 } from "node:path";
|
|
33721
33949
|
function configDirIdentity(path5) {
|
|
33722
33950
|
try {
|
|
33723
33951
|
return realpathSync2.native(path5);
|
|
33724
33952
|
} catch {
|
|
33725
|
-
return
|
|
33953
|
+
return resolve18(path5);
|
|
33726
33954
|
}
|
|
33727
33955
|
}
|
|
33728
33956
|
function decisionKey(location) {
|
|
@@ -34175,13 +34403,13 @@ function closeDebugStream(state) {
|
|
|
34175
34403
|
state.logWriter = () => {
|
|
34176
34404
|
};
|
|
34177
34405
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34178
|
-
return new Promise((
|
|
34179
|
-
current.once("close", () =>
|
|
34180
|
-
current.once("error", () =>
|
|
34406
|
+
return new Promise((resolve29) => {
|
|
34407
|
+
current.once("close", () => resolve29());
|
|
34408
|
+
current.once("error", () => resolve29());
|
|
34181
34409
|
try {
|
|
34182
34410
|
current.end();
|
|
34183
34411
|
} catch {
|
|
34184
|
-
|
|
34412
|
+
resolve29();
|
|
34185
34413
|
}
|
|
34186
34414
|
});
|
|
34187
34415
|
}
|
|
@@ -34446,13 +34674,13 @@ function closeDebugLog() {
|
|
|
34446
34674
|
if (!state || !current) return Promise.resolve();
|
|
34447
34675
|
state.logStream = null;
|
|
34448
34676
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34449
|
-
return new Promise((
|
|
34450
|
-
current.once("close", () =>
|
|
34451
|
-
current.once("error", () =>
|
|
34677
|
+
return new Promise((resolve29) => {
|
|
34678
|
+
current.once("close", () => resolve29());
|
|
34679
|
+
current.once("error", () => resolve29());
|
|
34452
34680
|
try {
|
|
34453
34681
|
current.end();
|
|
34454
34682
|
} catch {
|
|
34455
|
-
|
|
34683
|
+
resolve29();
|
|
34456
34684
|
}
|
|
34457
34685
|
});
|
|
34458
34686
|
}
|
|
@@ -34569,6 +34797,7 @@ function createLocationLogger(options) {
|
|
|
34569
34797
|
const engine = createLoggerInstance2({
|
|
34570
34798
|
level: () => configuredLevel,
|
|
34571
34799
|
extraSecretKeys: isProviderSecretKey,
|
|
34800
|
+
extraValuePatterns: OAUTH_REDIRECT_VALUE_PATTERNS,
|
|
34572
34801
|
captureSink: ({ channel: channel3, level, message, data }) => {
|
|
34573
34802
|
const extra = data !== null && typeof data === "object" && !Array.isArray(data) ? Object.fromEntries(Object.entries(data)) : void 0;
|
|
34574
34803
|
emit({
|
|
@@ -34663,13 +34892,13 @@ var init_logger4 = __esm({
|
|
|
34663
34892
|
// src/plugin/index.ts
|
|
34664
34893
|
init_dist();
|
|
34665
34894
|
import { createHash as createHash24, randomUUID as randomUUID21 } from "node:crypto";
|
|
34666
|
-
import { join as join39, resolve as
|
|
34895
|
+
import { join as join39, resolve as resolve28 } from "node:path";
|
|
34667
34896
|
|
|
34668
34897
|
// src/cli.ts
|
|
34669
34898
|
init_dist();
|
|
34670
34899
|
import { execFile } from "node:child_process";
|
|
34671
34900
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
34672
|
-
import { resolve as
|
|
34901
|
+
import { resolve as resolve23 } from "node:path";
|
|
34673
34902
|
import { createInterface } from "node:readline/promises";
|
|
34674
34903
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
34675
34904
|
import { promisify } from "node:util";
|
|
@@ -35320,7 +35549,7 @@ function drainSidebarWrites() {
|
|
|
35320
35549
|
return sidebarWriteChain;
|
|
35321
35550
|
}
|
|
35322
35551
|
async function sleep3(ms) {
|
|
35323
|
-
await new Promise((
|
|
35552
|
+
await new Promise((resolve29) => setTimeout(resolve29, ms));
|
|
35324
35553
|
}
|
|
35325
35554
|
async function acquireSidebarLockWithRetry(stateFile) {
|
|
35326
35555
|
const start = Date.now();
|
|
@@ -36172,14 +36401,14 @@ var LocalQuotaGrantStaleError = class extends Error {
|
|
|
36172
36401
|
name = "LocalQuotaGrantStaleError";
|
|
36173
36402
|
};
|
|
36174
36403
|
function untilQuotaAborted(pending, signal) {
|
|
36175
|
-
return new Promise((
|
|
36404
|
+
return new Promise((resolve29, reject) => {
|
|
36176
36405
|
const abort = () => reject(signal.reason);
|
|
36177
36406
|
if (signal.aborted) abort();
|
|
36178
36407
|
else signal.addEventListener("abort", abort, { once: true });
|
|
36179
36408
|
void pending.then(
|
|
36180
36409
|
(value) => {
|
|
36181
36410
|
signal.removeEventListener("abort", abort);
|
|
36182
|
-
|
|
36411
|
+
resolve29(value);
|
|
36183
36412
|
},
|
|
36184
36413
|
(error) => {
|
|
36185
36414
|
signal.removeEventListener("abort", abort);
|
|
@@ -36800,12 +37029,12 @@ async function startOAuthListener({
|
|
|
36800
37029
|
let resolveCallback;
|
|
36801
37030
|
let rejectCallback;
|
|
36802
37031
|
let timeoutHandle;
|
|
36803
|
-
const callbackPromise = new Promise((
|
|
37032
|
+
const callbackPromise = new Promise((resolve29, reject) => {
|
|
36804
37033
|
resolveCallback = (url) => {
|
|
36805
37034
|
if (settled) return;
|
|
36806
37035
|
settled = true;
|
|
36807
37036
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
36808
|
-
|
|
37037
|
+
resolve29(url);
|
|
36809
37038
|
};
|
|
36810
37039
|
rejectCallback = (error) => {
|
|
36811
37040
|
if (settled) return;
|
|
@@ -36964,7 +37193,7 @@ async function startOAuthListener({
|
|
|
36964
37193
|
});
|
|
36965
37194
|
});
|
|
36966
37195
|
const bindAddress = getBindAddress();
|
|
36967
|
-
await new Promise((
|
|
37196
|
+
await new Promise((resolve29, reject) => {
|
|
36968
37197
|
const handleError = (error) => {
|
|
36969
37198
|
server.off("error", handleError);
|
|
36970
37199
|
if (error.code === "EADDRINUSE") {
|
|
@@ -36980,7 +37209,7 @@ async function startOAuthListener({
|
|
|
36980
37209
|
server.once("error", handleError);
|
|
36981
37210
|
server.listen(port, bindAddress, () => {
|
|
36982
37211
|
server.off("error", handleError);
|
|
36983
|
-
|
|
37212
|
+
resolve29();
|
|
36984
37213
|
});
|
|
36985
37214
|
});
|
|
36986
37215
|
server.on("error", (error) => {
|
|
@@ -36988,7 +37217,7 @@ async function startOAuthListener({
|
|
|
36988
37217
|
});
|
|
36989
37218
|
return {
|
|
36990
37219
|
waitForCallback: () => callbackPromise,
|
|
36991
|
-
close: () => new Promise((
|
|
37220
|
+
close: () => new Promise((resolve29, reject) => {
|
|
36992
37221
|
server.close((error) => {
|
|
36993
37222
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
36994
37223
|
reject(error);
|
|
@@ -36997,7 +37226,7 @@ async function startOAuthListener({
|
|
|
36997
37226
|
if (!settled) {
|
|
36998
37227
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
36999
37228
|
}
|
|
37000
|
-
|
|
37229
|
+
resolve29();
|
|
37001
37230
|
});
|
|
37002
37231
|
})
|
|
37003
37232
|
};
|
|
@@ -37016,7 +37245,7 @@ init_runtime_paths();
|
|
|
37016
37245
|
// src/setup.ts
|
|
37017
37246
|
init_dist();
|
|
37018
37247
|
import { lstat as lstat9, readFile as readFile16 } from "node:fs/promises";
|
|
37019
|
-
import { join as join24, resolve as
|
|
37248
|
+
import { join as join24, resolve as resolve22 } from "node:path";
|
|
37020
37249
|
|
|
37021
37250
|
// src/auth-method-labels.ts
|
|
37022
37251
|
var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
|
|
@@ -37189,7 +37418,7 @@ async function select2(terminal, items, options) {
|
|
|
37189
37418
|
writeLine("");
|
|
37190
37419
|
renderedLines = lines;
|
|
37191
37420
|
};
|
|
37192
|
-
return new Promise((
|
|
37421
|
+
return new Promise((resolve29) => {
|
|
37193
37422
|
const wasRaw = stdin.isRaw ?? false;
|
|
37194
37423
|
const cleanup2 = () => {
|
|
37195
37424
|
if (cleaned)
|
|
@@ -37209,7 +37438,7 @@ async function select2(terminal, items, options) {
|
|
|
37209
37438
|
};
|
|
37210
37439
|
const finish = (value) => {
|
|
37211
37440
|
cleanup2();
|
|
37212
|
-
|
|
37441
|
+
resolve29(value);
|
|
37213
37442
|
};
|
|
37214
37443
|
const onSignal = () => finish(null);
|
|
37215
37444
|
const onKey = (data) => {
|
|
@@ -37249,7 +37478,7 @@ async function select2(terminal, items, options) {
|
|
|
37249
37478
|
stdin.setRawMode(true);
|
|
37250
37479
|
} catch {
|
|
37251
37480
|
cleanup2();
|
|
37252
|
-
|
|
37481
|
+
resolve29(null);
|
|
37253
37482
|
return;
|
|
37254
37483
|
}
|
|
37255
37484
|
stdin.resume();
|
|
@@ -37263,12 +37492,12 @@ async function select2(terminal, items, options) {
|
|
|
37263
37492
|
import { createHash as createHash13, randomBytes as randomBytes5, randomUUID as randomUUID17 } from "node:crypto";
|
|
37264
37493
|
import { constants as fsConstants2 } from "node:fs";
|
|
37265
37494
|
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";
|
|
37266
|
-
import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute4, join as join20, resolve as
|
|
37495
|
+
import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute4, join as join20, resolve as resolve21 } from "node:path";
|
|
37267
37496
|
import { ClaustrumCredentialError as ClaustrumCredentialError9, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
37268
37497
|
|
|
37269
37498
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
37270
37499
|
import { lstat as lstat7, stat as stat12 } from "node:fs/promises";
|
|
37271
|
-
import { resolve as
|
|
37500
|
+
import { resolve as resolve19 } from "node:path";
|
|
37272
37501
|
async function identity2(path5, followSymlinks) {
|
|
37273
37502
|
try {
|
|
37274
37503
|
const metadata = await (followSymlinks ? stat12(path5) : lstat7(path5));
|
|
@@ -37289,7 +37518,7 @@ var FileReadCache2 = class {
|
|
|
37289
37518
|
this.#followSymlinks = options.followSymlinks ?? false;
|
|
37290
37519
|
}
|
|
37291
37520
|
async read(paths, read, validateHit) {
|
|
37292
|
-
const resolvedPaths = paths.map((path5) =>
|
|
37521
|
+
const resolvedPaths = paths.map((path5) => resolve19(path5));
|
|
37293
37522
|
const key = JSON.stringify(resolvedPaths);
|
|
37294
37523
|
const probed = await Promise.all(resolvedPaths.map((path5) => identity2(path5, this.#followSymlinks)));
|
|
37295
37524
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -37338,11 +37567,46 @@ var WRITER_LOCK_CONSTANTS2 = Object.freeze({
|
|
|
37338
37567
|
init_private_files2();
|
|
37339
37568
|
|
|
37340
37569
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
37341
|
-
init_private_files2();
|
|
37342
37570
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
37343
37571
|
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";
|
|
37344
37572
|
import { dirname as dirname19, join as join19 } from "node:path";
|
|
37345
37573
|
|
|
37574
|
+
// src/common-auth-embedded/fs/lock-record.js
|
|
37575
|
+
init_private_files2();
|
|
37576
|
+
import { resolve as resolve20 } from "node:path";
|
|
37577
|
+
var DisappearedLockRecordError2 = class extends Error {
|
|
37578
|
+
path;
|
|
37579
|
+
code = "ENOENT";
|
|
37580
|
+
constructor(path5, cause) {
|
|
37581
|
+
super(`Lock record disappeared: ${path5}`, { cause });
|
|
37582
|
+
this.path = path5;
|
|
37583
|
+
}
|
|
37584
|
+
};
|
|
37585
|
+
function isWindowsAccessDeniedRead2(error, paths) {
|
|
37586
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path5) => resolve20(path5) === error.path);
|
|
37587
|
+
}
|
|
37588
|
+
function isWindowsAccessDeniedCreate2(error, paths, stage) {
|
|
37589
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path5) => resolve20(path5) === error.path);
|
|
37590
|
+
}
|
|
37591
|
+
async function readLockRecord2(path5, read) {
|
|
37592
|
+
try {
|
|
37593
|
+
return await read();
|
|
37594
|
+
} catch (error) {
|
|
37595
|
+
if (!isWindowsAccessDeniedRead2(error, [path5]))
|
|
37596
|
+
throw error;
|
|
37597
|
+
try {
|
|
37598
|
+
return await read();
|
|
37599
|
+
} catch (recheckError) {
|
|
37600
|
+
if (recheckError.code === "ENOENT")
|
|
37601
|
+
throw new DisappearedLockRecordError2(path5, error);
|
|
37602
|
+
throw error;
|
|
37603
|
+
}
|
|
37604
|
+
}
|
|
37605
|
+
}
|
|
37606
|
+
|
|
37607
|
+
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
37608
|
+
init_private_files2();
|
|
37609
|
+
|
|
37346
37610
|
// src/common-auth-embedded/fs/with-lock.js
|
|
37347
37611
|
init_private_files2();
|
|
37348
37612
|
function lockPathFor2(target, name) {
|
|
@@ -37441,8 +37705,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37441
37705
|
let releaseConfirmed = false;
|
|
37442
37706
|
let loss;
|
|
37443
37707
|
let resolveLoss;
|
|
37444
|
-
const lostPromise = new Promise((
|
|
37445
|
-
resolveLoss =
|
|
37708
|
+
const lostPromise = new Promise((resolve29) => {
|
|
37709
|
+
resolveLoss = resolve29;
|
|
37446
37710
|
});
|
|
37447
37711
|
function notifyTimerStep(event) {
|
|
37448
37712
|
try {
|
|
@@ -37480,15 +37744,18 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37480
37744
|
const evictOwnerId = randomUUID16();
|
|
37481
37745
|
const EVICT_TTL = 5e3;
|
|
37482
37746
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
37747
|
+
function isChangingLockCreate(error) {
|
|
37748
|
+
return windowsPrivateFiles2 && (isWindowsAccessDeniedCreate2(error, [lockPath], "create") || isWindowsAccessDeniedCreate2(error, [evictPath], "directory-create"));
|
|
37749
|
+
}
|
|
37483
37750
|
async function readOwner() {
|
|
37484
37751
|
if (windowsPrivateFiles2) {
|
|
37485
37752
|
try {
|
|
37486
|
-
return JSON.parse(await readPrivateText2(lockPath, true));
|
|
37753
|
+
return JSON.parse(await readLockRecord2(lockPath, () => readPrivateText2(lockPath, true)));
|
|
37487
37754
|
} catch (error) {
|
|
37488
37755
|
if (error.code !== "EISDIR" && error.reason !== "wrong-kind")
|
|
37489
37756
|
throw error;
|
|
37490
|
-
await verifyPrivate2(lockPath, "directory", true);
|
|
37491
|
-
return JSON.parse(await readPrivateText2(legacyOwnerPath, true));
|
|
37757
|
+
await readLockRecord2(lockPath, () => verifyPrivate2(lockPath, "directory", true));
|
|
37758
|
+
return JSON.parse(await readLockRecord2(legacyOwnerPath, () => readPrivateText2(legacyOwnerPath, true)));
|
|
37492
37759
|
}
|
|
37493
37760
|
}
|
|
37494
37761
|
try {
|
|
@@ -37564,8 +37831,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37564
37831
|
await options.onStep("lease-contention-read-ready");
|
|
37565
37832
|
try {
|
|
37566
37833
|
if (code2 === "EISDIR") {
|
|
37567
|
-
await verifyPrivate2(lockPath, "directory", true);
|
|
37568
|
-
await readPrivateText2(legacyOwnerPath, true);
|
|
37834
|
+
await readLockRecord2(lockPath, () => verifyPrivate2(lockPath, "directory", true));
|
|
37835
|
+
await readLockRecord2(legacyOwnerPath, () => readPrivateText2(legacyOwnerPath, true));
|
|
37569
37836
|
} else
|
|
37570
37837
|
await readOwner();
|
|
37571
37838
|
} catch (readError) {
|
|
@@ -37603,7 +37870,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37603
37870
|
}
|
|
37604
37871
|
}
|
|
37605
37872
|
async function backoff() {
|
|
37606
|
-
await new Promise((
|
|
37873
|
+
await new Promise((resolve29) => setTimeout(resolve29, Math.floor(Math.random() * 4)));
|
|
37607
37874
|
}
|
|
37608
37875
|
async function readLockState(notifyReady = true) {
|
|
37609
37876
|
if (notifyReady && options.onStep)
|
|
@@ -37612,6 +37879,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37612
37879
|
try {
|
|
37613
37880
|
owner = await readOwner();
|
|
37614
37881
|
} catch (error) {
|
|
37882
|
+
if (error instanceof DisappearedLockRecordError2)
|
|
37883
|
+
return { status: "missing" };
|
|
37615
37884
|
if (windowsPrivateFiles2 && error.code !== "ENOENT")
|
|
37616
37885
|
throw error;
|
|
37617
37886
|
}
|
|
@@ -37659,7 +37928,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37659
37928
|
}
|
|
37660
37929
|
async function ownsEvictionMarker() {
|
|
37661
37930
|
try {
|
|
37662
|
-
const owner = JSON.parse(await readPrivateText2(evictOwnerPath, windowsPrivateFiles2));
|
|
37931
|
+
const owner = JSON.parse(await readLockRecord2(evictOwnerPath, () => readPrivateText2(evictOwnerPath, windowsPrivateFiles2)));
|
|
37663
37932
|
return owner?.ownerId === evictOwnerId;
|
|
37664
37933
|
} catch (error) {
|
|
37665
37934
|
if (windowsPrivateFiles2 && error.code !== "ENOENT")
|
|
@@ -37694,7 +37963,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37694
37963
|
const remainingMs = deadline - performance.now();
|
|
37695
37964
|
if (remainingMs <= 0)
|
|
37696
37965
|
throw original;
|
|
37697
|
-
await new Promise((
|
|
37966
|
+
await new Promise((resolve29) => setTimeout(resolve29, Math.min(delayMs, remainingMs)));
|
|
37698
37967
|
if (performance.now() >= deadline)
|
|
37699
37968
|
throw original;
|
|
37700
37969
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -37798,7 +38067,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37798
38067
|
}
|
|
37799
38068
|
if (windowsPrivateFiles2) {
|
|
37800
38069
|
try {
|
|
37801
|
-
await verifyPrivate2(evictPath, "directory", true);
|
|
38070
|
+
await readLockRecord2(evictPath, () => verifyPrivate2(evictPath, "directory", true));
|
|
37802
38071
|
} catch (error) {
|
|
37803
38072
|
if (error.code === "ENOENT")
|
|
37804
38073
|
return "missing";
|
|
@@ -37853,8 +38122,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37853
38122
|
if (error.code === "EEXIST") {
|
|
37854
38123
|
if (windowsPrivateFiles2) {
|
|
37855
38124
|
try {
|
|
37856
|
-
await verifyPrivate2(evictPath, "directory", true);
|
|
37857
|
-
await readPrivateText2(evictOwnerPath, true);
|
|
38125
|
+
await readLockRecord2(evictPath, () => verifyPrivate2(evictPath, "directory", true));
|
|
38126
|
+
await readLockRecord2(evictOwnerPath, () => readPrivateText2(evictOwnerPath, true));
|
|
37858
38127
|
} catch (ownerError) {
|
|
37859
38128
|
if (ownerError.code !== "ENOENT")
|
|
37860
38129
|
throw ownerError;
|
|
@@ -37875,7 +38144,11 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37875
38144
|
try {
|
|
37876
38145
|
await releaseEvictionMarker(deadline);
|
|
37877
38146
|
} catch (error) {
|
|
37878
|
-
if (isRetryableRemoval(actionError, lockPath)
|
|
38147
|
+
if ((isRetryableRemoval(actionError, lockPath) || isWindowsAccessDeniedRead2(actionError, [
|
|
38148
|
+
lockPath,
|
|
38149
|
+
legacyOwnerPath,
|
|
38150
|
+
evictOwnerPath
|
|
38151
|
+
])) && (isRetryableRemoval(error, evictPath) || isWindowsAccessDeniedRead2(error, [evictOwnerPath])))
|
|
37879
38152
|
throw actionError;
|
|
37880
38153
|
throw error;
|
|
37881
38154
|
}
|
|
@@ -37891,7 +38164,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37891
38164
|
try {
|
|
37892
38165
|
owner = await readOwner();
|
|
37893
38166
|
} catch (error) {
|
|
37894
|
-
if (windowsPrivateFiles2)
|
|
38167
|
+
if (windowsPrivateFiles2 && !(error instanceof DisappearedLockRecordError2))
|
|
37895
38168
|
throw error;
|
|
37896
38169
|
return;
|
|
37897
38170
|
}
|
|
@@ -37969,7 +38242,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37969
38242
|
await options.onStep("renewal-marker-unavailable");
|
|
37970
38243
|
}
|
|
37971
38244
|
} catch (error) {
|
|
37972
|
-
if (windowsPrivateFiles2 && error instanceof PrivateFileError2) {
|
|
38245
|
+
if (windowsPrivateFiles2 && error instanceof PrivateFileError2 && !isChangingLockCreate(error)) {
|
|
37973
38246
|
terminalIOError = error;
|
|
37974
38247
|
recordLoss("renewal-failed");
|
|
37975
38248
|
shouldReschedule = false;
|
|
@@ -38015,72 +38288,90 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38015
38288
|
}
|
|
38016
38289
|
return null;
|
|
38017
38290
|
}
|
|
38018
|
-
let acquired =
|
|
38291
|
+
let acquired = false;
|
|
38292
|
+
let changingCreateError;
|
|
38293
|
+
try {
|
|
38294
|
+
acquired = await tryAcquire();
|
|
38295
|
+
} catch (error) {
|
|
38296
|
+
if (!isChangingLockCreate(error))
|
|
38297
|
+
throw error;
|
|
38298
|
+
changingCreateError = error;
|
|
38299
|
+
}
|
|
38019
38300
|
if (!acquired) {
|
|
38020
38301
|
for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
|
|
38021
|
-
acquired = await tryAcquire();
|
|
38022
|
-
if (acquired)
|
|
38023
|
-
break;
|
|
38024
|
-
const observed = await readLockState();
|
|
38025
|
-
if (observed.status === "live")
|
|
38026
|
-
return contended();
|
|
38027
|
-
if (observed.status === "missing")
|
|
38028
|
-
continue;
|
|
38029
|
-
if (options.onStep)
|
|
38030
|
-
await options.onStep("stale-lock-observed");
|
|
38031
38302
|
try {
|
|
38032
|
-
|
|
38033
|
-
|
|
38034
|
-
|
|
38035
|
-
|
|
38036
|
-
|
|
38037
|
-
const code2 = evictError.code;
|
|
38038
|
-
if (code2 !== "EEXIST")
|
|
38039
|
-
throw evictError;
|
|
38040
|
-
const recovered = await recoverStaleEvictionMarker();
|
|
38041
|
-
if (recovered === "fresh")
|
|
38042
|
-
return null;
|
|
38043
|
-
await backoff();
|
|
38044
|
-
continue;
|
|
38045
|
-
}
|
|
38046
|
-
try {
|
|
38047
|
-
const confirmed = await readLockState();
|
|
38048
|
-
if (confirmed.status === "live")
|
|
38303
|
+
acquired = await tryAcquire();
|
|
38304
|
+
if (acquired)
|
|
38305
|
+
break;
|
|
38306
|
+
const observed = await readLockState();
|
|
38307
|
+
if (observed.status === "live")
|
|
38049
38308
|
return contended();
|
|
38050
|
-
if (
|
|
38309
|
+
if (observed.status === "missing")
|
|
38051
38310
|
continue;
|
|
38052
|
-
if (!await ownsEvictionMarker())
|
|
38053
|
-
return null;
|
|
38054
38311
|
if (options.onStep)
|
|
38055
|
-
await options.onStep("stale-lock-
|
|
38056
|
-
|
|
38057
|
-
|
|
38058
|
-
|
|
38059
|
-
|
|
38312
|
+
await options.onStep("stale-lock-observed");
|
|
38313
|
+
try {
|
|
38314
|
+
if (!await tryAcquireEvictionMarker()) {
|
|
38315
|
+
await backoff();
|
|
38316
|
+
continue;
|
|
38317
|
+
}
|
|
38318
|
+
} catch (evictError) {
|
|
38319
|
+
const code2 = evictError.code;
|
|
38320
|
+
if (code2 !== "EEXIST")
|
|
38321
|
+
throw evictError;
|
|
38322
|
+
const recovered = await recoverStaleEvictionMarker();
|
|
38323
|
+
if (recovered === "fresh")
|
|
38324
|
+
return null;
|
|
38325
|
+
await backoff();
|
|
38060
38326
|
continue;
|
|
38061
|
-
await removeLeaseObject(lockPath);
|
|
38062
|
-
if (!await ownsEvictionMarker())
|
|
38063
|
-
return null;
|
|
38064
|
-
if (options.onStep)
|
|
38065
|
-
await options.onStep("stale-lock-removed");
|
|
38066
|
-
acquired = await tryAcquire();
|
|
38067
|
-
if (!acquired)
|
|
38068
|
-
return null;
|
|
38069
|
-
if (options.onStep)
|
|
38070
|
-
await options.onStep("stale-lock-recreated");
|
|
38071
|
-
if (!await ownsEvictionMarker()) {
|
|
38072
|
-
await relinquishLockAfterMarkerLoss();
|
|
38073
|
-
acquired = false;
|
|
38074
|
-
return null;
|
|
38075
38327
|
}
|
|
38076
|
-
|
|
38077
|
-
|
|
38078
|
-
|
|
38328
|
+
try {
|
|
38329
|
+
const confirmed = await readLockState();
|
|
38330
|
+
if (confirmed.status === "live")
|
|
38331
|
+
return contended();
|
|
38332
|
+
if (!sameStaleLock(observed.identity, confirmed))
|
|
38333
|
+
continue;
|
|
38334
|
+
if (!await ownsEvictionMarker())
|
|
38335
|
+
return null;
|
|
38336
|
+
if (options.onStep)
|
|
38337
|
+
await options.onStep("stale-lock-confirmed");
|
|
38338
|
+
if (!await ownsEvictionMarker())
|
|
38339
|
+
return null;
|
|
38340
|
+
const current = await readLockState(false);
|
|
38341
|
+
if (!sameStaleLock(observed.identity, current))
|
|
38342
|
+
continue;
|
|
38343
|
+
await removeLeaseObject(lockPath);
|
|
38344
|
+
if (!await ownsEvictionMarker())
|
|
38345
|
+
return null;
|
|
38346
|
+
if (options.onStep)
|
|
38347
|
+
await options.onStep("stale-lock-removed");
|
|
38348
|
+
acquired = await tryAcquire();
|
|
38349
|
+
if (!acquired)
|
|
38350
|
+
return null;
|
|
38351
|
+
if (options.onStep)
|
|
38352
|
+
await options.onStep("stale-lock-recreated");
|
|
38353
|
+
if (!await ownsEvictionMarker()) {
|
|
38354
|
+
await relinquishLockAfterMarkerLoss();
|
|
38355
|
+
acquired = false;
|
|
38356
|
+
return null;
|
|
38357
|
+
}
|
|
38358
|
+
break;
|
|
38359
|
+
} finally {
|
|
38360
|
+
await releaseEvictionMarker();
|
|
38361
|
+
}
|
|
38362
|
+
} catch (error) {
|
|
38363
|
+
if (!isChangingLockCreate(error))
|
|
38364
|
+
throw error;
|
|
38365
|
+
changingCreateError ??= error;
|
|
38366
|
+
await backoff();
|
|
38079
38367
|
}
|
|
38080
38368
|
}
|
|
38081
38369
|
}
|
|
38082
|
-
if (!acquired)
|
|
38370
|
+
if (!acquired) {
|
|
38371
|
+
if (changingCreateError)
|
|
38372
|
+
throw changingCreateError;
|
|
38083
38373
|
return null;
|
|
38374
|
+
}
|
|
38084
38375
|
scheduleRenewal();
|
|
38085
38376
|
return {
|
|
38086
38377
|
ownerId,
|
|
@@ -38118,6 +38409,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38118
38409
|
const deadline = performance.now() + EVICT_TTL + 1e3;
|
|
38119
38410
|
let delayMs = 5;
|
|
38120
38411
|
let removalError;
|
|
38412
|
+
let changingRecordError;
|
|
38121
38413
|
for (; ; ) {
|
|
38122
38414
|
try {
|
|
38123
38415
|
let removalConfirmed = false;
|
|
@@ -38143,6 +38435,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38143
38435
|
await removeLeaseObject(lockPath);
|
|
38144
38436
|
removalConfirmed = true;
|
|
38145
38437
|
}, deadline);
|
|
38438
|
+
changingRecordError = void 0;
|
|
38146
38439
|
if (markerAcquired) {
|
|
38147
38440
|
if (windowsPrivateFiles2 && !removalConfirmed)
|
|
38148
38441
|
throw new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
@@ -38155,23 +38448,32 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
38155
38448
|
return;
|
|
38156
38449
|
await recoverStaleEvictionMarker(deadline);
|
|
38157
38450
|
} catch (error) {
|
|
38158
|
-
|
|
38451
|
+
const changingRecord = windowsPrivateFiles2 && (isChangingLockCreate(error) || isWindowsAccessDeniedRead2(error, [
|
|
38452
|
+
lockPath,
|
|
38453
|
+
legacyOwnerPath,
|
|
38454
|
+
evictPath,
|
|
38455
|
+
evictOwnerPath
|
|
38456
|
+
]));
|
|
38457
|
+
if (!isRetryableRemoval(error, lockPath) && !changingRecord) {
|
|
38159
38458
|
if (windowsPrivateFiles2)
|
|
38160
38459
|
throw error;
|
|
38161
38460
|
return;
|
|
38162
38461
|
}
|
|
38163
|
-
|
|
38462
|
+
if (changingRecord)
|
|
38463
|
+
changingRecordError ??= error;
|
|
38464
|
+
else
|
|
38465
|
+
removalError ??= error;
|
|
38164
38466
|
}
|
|
38165
38467
|
const remainingMs = deadline - performance.now();
|
|
38166
38468
|
if (remainingMs <= 0)
|
|
38167
38469
|
break;
|
|
38168
|
-
await new Promise((
|
|
38470
|
+
await new Promise((resolve29) => setTimeout(resolve29, Math.min(delayMs, remainingMs)));
|
|
38169
38471
|
if (windowsPrivateFiles2 && performance.now() >= deadline)
|
|
38170
38472
|
break;
|
|
38171
38473
|
delayMs = Math.min(delayMs * 2, 50);
|
|
38172
38474
|
}
|
|
38173
38475
|
if (windowsPrivateFiles2)
|
|
38174
|
-
throw removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
38476
|
+
throw changingRecordError ?? removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
38175
38477
|
code: "ETIMEDOUT"
|
|
38176
38478
|
});
|
|
38177
38479
|
}
|
|
@@ -38311,6 +38613,10 @@ function classifyEnrollmentError2(error) {
|
|
|
38311
38613
|
disposition: error.action === "retry" ? "retry" : "terminal"
|
|
38312
38614
|
};
|
|
38313
38615
|
}
|
|
38616
|
+
function validEnrollmentDisplayName2(displayName) {
|
|
38617
|
+
const length = Array.from(displayName).length;
|
|
38618
|
+
return length >= 1 && length <= 40 && !/[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\u200b-\u200d\u2060\ufeff]/u.test(displayName);
|
|
38619
|
+
}
|
|
38314
38620
|
function connectClaustrumEnrollmentClient2(options) {
|
|
38315
38621
|
return ClaustrumWireClient2.connect(options);
|
|
38316
38622
|
}
|
|
@@ -38326,7 +38632,7 @@ function hostEnrollmentPaths2(input2) {
|
|
|
38326
38632
|
const override = input2.override?.trim();
|
|
38327
38633
|
if (override && !isAbsolute4(override) && !input2.cwd)
|
|
38328
38634
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
38329
|
-
const tokenPath = override ? isAbsolute4(override) ? override :
|
|
38635
|
+
const tokenPath = override ? isAbsolute4(override) ? override : resolve21(input2.cwd, override) : join20(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
38330
38636
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
38331
38637
|
}
|
|
38332
38638
|
function isRecord11(value) {
|
|
@@ -38687,15 +38993,19 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
38687
38993
|
#client;
|
|
38688
38994
|
#paths;
|
|
38689
38995
|
#proposedName;
|
|
38996
|
+
#displayName;
|
|
38690
38997
|
#now;
|
|
38691
38998
|
#mintSecret;
|
|
38692
38999
|
#writeTokenFile;
|
|
38693
39000
|
#ancestorOptions;
|
|
38694
39001
|
constructor(options) {
|
|
39002
|
+
if (options.displayName !== void 0 && !validEnrollmentDisplayName2(options.displayName))
|
|
39003
|
+
throw new ClaustrumConsumerError2("invalid-state", "invalid Claustrum enrollment display name");
|
|
38695
39004
|
this.#ancestorOptions = options.ancestorOptions ?? {};
|
|
38696
39005
|
this.#client = options.client;
|
|
38697
39006
|
this.#paths = options.paths;
|
|
38698
39007
|
this.#proposedName = options.proposedName;
|
|
39008
|
+
this.#displayName = options.displayName;
|
|
38699
39009
|
this.#now = options.now ?? Date.now;
|
|
38700
39010
|
this.#mintSecret = options.mintSecret ?? (() => randomBytes5(32).toString("hex"));
|
|
38701
39011
|
this.#writeTokenFile = options.writeTokenFile ?? writeEnrollmentTokenFile2;
|
|
@@ -38785,10 +39095,23 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
38785
39095
|
if (!state.requestId) {
|
|
38786
39096
|
try {
|
|
38787
39097
|
const requestSecretHash = createHash13("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
|
|
38788
|
-
const
|
|
39098
|
+
const proposal = {
|
|
38789
39099
|
name: state.proposedName,
|
|
38790
39100
|
requestSecretHash
|
|
38791
|
-
}
|
|
39101
|
+
};
|
|
39102
|
+
let proposed;
|
|
39103
|
+
try {
|
|
39104
|
+
proposed = await this.#client.enrollPropose({
|
|
39105
|
+
...proposal,
|
|
39106
|
+
...this.#displayName !== void 0 && {
|
|
39107
|
+
displayName: this.#displayName
|
|
39108
|
+
}
|
|
39109
|
+
});
|
|
39110
|
+
} catch (error) {
|
|
39111
|
+
if (this.#displayName === void 0 || !(error instanceof ClaustrumCredentialError9) || error.code !== "invalid_params")
|
|
39112
|
+
throw error;
|
|
39113
|
+
proposed = await this.#client.enrollPropose(proposal);
|
|
39114
|
+
}
|
|
38792
39115
|
state = {
|
|
38793
39116
|
...state,
|
|
38794
39117
|
requestId: proposed.requestId,
|
|
@@ -38959,7 +39282,7 @@ var ByteTail = class {
|
|
|
38959
39282
|
};
|
|
38960
39283
|
var defaultCommandRunner = {
|
|
38961
39284
|
run(file, args, options = {}) {
|
|
38962
|
-
return new Promise((
|
|
39285
|
+
return new Promise((resolve29) => {
|
|
38963
39286
|
const started = performance.now();
|
|
38964
39287
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
38965
39288
|
const stderr = new ByteTail();
|
|
@@ -38977,7 +39300,7 @@ var defaultCommandRunner = {
|
|
|
38977
39300
|
stdio: ["ignore", "pipe", "pipe"]
|
|
38978
39301
|
});
|
|
38979
39302
|
} catch {
|
|
38980
|
-
|
|
39303
|
+
resolve29({
|
|
38981
39304
|
exitCode: 1,
|
|
38982
39305
|
stdout: "",
|
|
38983
39306
|
stderr: "",
|
|
@@ -39012,7 +39335,7 @@ var defaultCommandRunner = {
|
|
|
39012
39335
|
settled = true;
|
|
39013
39336
|
if (timer)
|
|
39014
39337
|
clearTimeout(timer);
|
|
39015
|
-
|
|
39338
|
+
resolve29({
|
|
39016
39339
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
39017
39340
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
39018
39341
|
stderr: stderr.toString(),
|
|
@@ -39624,7 +39947,7 @@ function approveCommand(requestId, name) {
|
|
|
39624
39947
|
async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
39625
39948
|
if (hasVaultHost2())
|
|
39626
39949
|
throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
|
|
39627
|
-
const { name, paths: input2 } = plugin.vault.hosts[host];
|
|
39950
|
+
const { name, displayName, paths: input2 } = plugin.vault.hosts[host];
|
|
39628
39951
|
const paths = hostEnrollmentPaths2(input2);
|
|
39629
39952
|
await fence();
|
|
39630
39953
|
const client = await (io.connect ?? connectClaustrumEnrollmentClient2)({
|
|
@@ -39638,6 +39961,7 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
39638
39961
|
try {
|
|
39639
39962
|
const manager = new ClaustrumEnrollmentManager2({
|
|
39640
39963
|
proposedName: name,
|
|
39964
|
+
displayName,
|
|
39641
39965
|
paths,
|
|
39642
39966
|
// Each tick of the wait below checks the fence once, just before
|
|
39643
39967
|
// reconcile proposes or polls. Checking again inside every vault call
|
|
@@ -40431,7 +40755,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
40431
40755
|
beforeRename: async () => {
|
|
40432
40756
|
await assertSetupHostsStopped();
|
|
40433
40757
|
const claustrum = await loadCommonAuthClaustrum();
|
|
40434
|
-
const stateDir = host === "opencode" ? openCodeVaultDir(
|
|
40758
|
+
const stateDir = host === "opencode" ? openCodeVaultDir(resolve22(accountFileForVault())) : getPiAntigravityVaultDir();
|
|
40435
40759
|
if (await claustrum.vaultAuthority(
|
|
40436
40760
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
40437
40761
|
`antigravity-auth-${host}`
|
|
@@ -40465,17 +40789,19 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
40465
40789
|
const hosts = {
|
|
40466
40790
|
opencode: {
|
|
40467
40791
|
name: OPENCODE_VAULT_ENROLLMENT_NAME,
|
|
40792
|
+
displayName: "Antigravity sign-in for OpenCode",
|
|
40468
40793
|
// Read at each use: a real run settles the vault folder in
|
|
40469
40794
|
// `beforeSignIn`, which may move it after this plugin is built.
|
|
40470
40795
|
paths: {
|
|
40471
40796
|
get stateDir() {
|
|
40472
|
-
return openCodeVaultDir(
|
|
40797
|
+
return openCodeVaultDir(resolve22(accountFileForVault()));
|
|
40473
40798
|
},
|
|
40474
40799
|
host: "opencode"
|
|
40475
40800
|
}
|
|
40476
40801
|
},
|
|
40477
40802
|
pi: {
|
|
40478
40803
|
name: "antigravity-auth-pi",
|
|
40804
|
+
displayName: "Antigravity sign-in for Pi",
|
|
40479
40805
|
paths: { stateDir: piDir, host: "pi" }
|
|
40480
40806
|
}
|
|
40481
40807
|
};
|
|
@@ -40486,7 +40812,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
40486
40812
|
const assertLocal = async (host, context) => {
|
|
40487
40813
|
if (host === "opencode")
|
|
40488
40814
|
return assertLocalOpenCodeLogin(
|
|
40489
|
-
|
|
40815
|
+
resolve22(accountFileForVault()),
|
|
40490
40816
|
context.opencodeGeneration
|
|
40491
40817
|
);
|
|
40492
40818
|
if (await authority(host) !== "local")
|
|
@@ -41146,7 +41472,7 @@ async function runCliProcess(argv, deps) {
|
|
|
41146
41472
|
...deps,
|
|
41147
41473
|
prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
|
|
41148
41474
|
const folder = await prepareVaultFolder({
|
|
41149
|
-
accountFile:
|
|
41475
|
+
accountFile: resolve23(accountFileForVault()),
|
|
41150
41476
|
...options
|
|
41151
41477
|
});
|
|
41152
41478
|
if (folder.refusal) throw folder.refusal;
|
|
@@ -41192,11 +41518,11 @@ function createDefaultCliDependencies() {
|
|
|
41192
41518
|
);
|
|
41193
41519
|
if (host !== "pi")
|
|
41194
41520
|
await assertLocalOpenCodeLogin(
|
|
41195
|
-
|
|
41521
|
+
resolve23(accountFileForVault()),
|
|
41196
41522
|
context?.opencodeGeneration
|
|
41197
41523
|
);
|
|
41198
41524
|
const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
|
|
41199
|
-
|
|
41525
|
+
resolve23(getStoragePath()),
|
|
41200
41526
|
context?.opencodeGeneration
|
|
41201
41527
|
);
|
|
41202
41528
|
try {
|
|
@@ -41212,7 +41538,7 @@ function createDefaultCliDependencies() {
|
|
|
41212
41538
|
}
|
|
41213
41539
|
if (host === "opencode") await assertSetupHostsStopped();
|
|
41214
41540
|
await assertLocalOpenCodeLogin(
|
|
41215
|
-
|
|
41541
|
+
resolve23(accountFileForVault()),
|
|
41216
41542
|
context?.opencodeGeneration
|
|
41217
41543
|
);
|
|
41218
41544
|
await persistCliStoreLogin(
|
|
@@ -41232,7 +41558,7 @@ function createDefaultCliDependencies() {
|
|
|
41232
41558
|
};
|
|
41233
41559
|
}
|
|
41234
41560
|
async function prepareCliLoginStore(legacyPath, generation) {
|
|
41235
|
-
await assertLocalOpenCodeLogin(
|
|
41561
|
+
await assertLocalOpenCodeLogin(resolve23(accountFileForVault()), generation);
|
|
41236
41562
|
const modules = await loadCommonAuthStoreModules();
|
|
41237
41563
|
const options = {
|
|
41238
41564
|
legacyPath,
|
|
@@ -41377,7 +41703,7 @@ async function readAccountStore(legacyPath) {
|
|
|
41377
41703
|
function createDefaultAccountStoreOperations() {
|
|
41378
41704
|
const offline = { processesStopped: true };
|
|
41379
41705
|
return {
|
|
41380
|
-
legacyPath: () =>
|
|
41706
|
+
legacyPath: () => resolve23(
|
|
41381
41707
|
decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
|
|
41382
41708
|
),
|
|
41383
41709
|
migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
|
|
@@ -41408,7 +41734,7 @@ function createDefaultAccountStoreOperations() {
|
|
|
41408
41734
|
};
|
|
41409
41735
|
}
|
|
41410
41736
|
function samePath(left, right) {
|
|
41411
|
-
return process.platform === "win32" ?
|
|
41737
|
+
return process.platform === "win32" ? resolve23(left).toLowerCase() === resolve23(right).toLowerCase() : resolve23(left) === resolve23(right);
|
|
41412
41738
|
}
|
|
41413
41739
|
function isCliEntry() {
|
|
41414
41740
|
if (import.meta.main !== void 0) return import.meta.main;
|
|
@@ -41898,14 +42224,14 @@ function isTuiConnected(sessionId) {
|
|
|
41898
42224
|
// src/rpc/rpc-dir.ts
|
|
41899
42225
|
import { createHash as createHash14 } from "node:crypto";
|
|
41900
42226
|
import { homedir as homedir10, tmpdir as tmpdir4 } from "node:os";
|
|
41901
|
-
import { isAbsolute as isAbsolute5, join as join28, resolve as
|
|
42227
|
+
import { isAbsolute as isAbsolute5, join as join28, resolve as resolve24 } from "node:path";
|
|
41902
42228
|
var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
|
|
41903
42229
|
function getRpcDir(projectDirectory) {
|
|
41904
42230
|
const override = process.env[RPC_DIR_ENV]?.trim();
|
|
41905
42231
|
if (override) {
|
|
41906
|
-
return isAbsolute5(override) ? override :
|
|
42232
|
+
return isAbsolute5(override) ? override : resolve24(projectDirectory, override);
|
|
41907
42233
|
}
|
|
41908
|
-
const projectHash = createHash14("sha256").update(
|
|
42234
|
+
const projectHash = createHash14("sha256").update(resolve24(projectDirectory)).digest("hex").slice(0, 16);
|
|
41909
42235
|
const stateHome = process.env.XDG_STATE_HOME ?? join28(homedir10(), ".local", "state");
|
|
41910
42236
|
return join28(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
|
|
41911
42237
|
}
|
|
@@ -41920,7 +42246,7 @@ init_private_files2();
|
|
|
41920
42246
|
import { createHash as createHash15, randomUUID as randomUUID19 } from "node:crypto";
|
|
41921
42247
|
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";
|
|
41922
42248
|
import { uptime as uptime2 } from "node:os";
|
|
41923
|
-
import { join as join29, resolve as
|
|
42249
|
+
import { join as join29, resolve as resolve25 } from "node:path";
|
|
41924
42250
|
function staleBefore(clock2) {
|
|
41925
42251
|
return (clock2.now ?? Date.now)() - (clock2.uptime ?? uptime2)() * 1e3 - 3e5;
|
|
41926
42252
|
}
|
|
@@ -42030,7 +42356,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log17, options = {})
|
|
|
42030
42356
|
return;
|
|
42031
42357
|
throw error;
|
|
42032
42358
|
}
|
|
42033
|
-
const active2 =
|
|
42359
|
+
const active2 = resolve25(activeDir);
|
|
42034
42360
|
for (const projectDir of projectDirs) {
|
|
42035
42361
|
if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
|
|
42036
42362
|
continue;
|
|
@@ -42077,7 +42403,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log17, options = {})
|
|
|
42077
42403
|
else if (isStalePortFile(entry, info, cutoff))
|
|
42078
42404
|
await removeStalePortFile(portFile, raw, info, options.beforeRemove);
|
|
42079
42405
|
}
|
|
42080
|
-
if (
|
|
42406
|
+
if (resolve25(dir) !== active2)
|
|
42081
42407
|
await rmdir3(dir).catch(() => {
|
|
42082
42408
|
});
|
|
42083
42409
|
}
|
|
@@ -42111,7 +42437,7 @@ var BodyTooLargeError = class extends Error {
|
|
|
42111
42437
|
}
|
|
42112
42438
|
};
|
|
42113
42439
|
function readBody(req) {
|
|
42114
|
-
return new Promise((
|
|
42440
|
+
return new Promise((resolve29, reject) => {
|
|
42115
42441
|
const tooLarge = (declaredOversize = false) => {
|
|
42116
42442
|
req.removeAllListeners("data");
|
|
42117
42443
|
req.on("data", () => {
|
|
@@ -42134,7 +42460,7 @@ function readBody(req) {
|
|
|
42134
42460
|
}
|
|
42135
42461
|
chunks.push(chunk);
|
|
42136
42462
|
});
|
|
42137
|
-
req.on("end", () =>
|
|
42463
|
+
req.on("end", () => resolve29(Buffer.concat(chunks).toString("utf8")));
|
|
42138
42464
|
req.on("error", reject);
|
|
42139
42465
|
});
|
|
42140
42466
|
}
|
|
@@ -42313,12 +42639,12 @@ async function startRpcServer(options) {
|
|
|
42313
42639
|
json(500, { error: "internal error" });
|
|
42314
42640
|
}
|
|
42315
42641
|
}
|
|
42316
|
-
const port = await new Promise((
|
|
42642
|
+
const port = await new Promise((resolve29, reject) => {
|
|
42317
42643
|
server.on("error", reject);
|
|
42318
42644
|
server.listen(0, "127.0.0.1", () => {
|
|
42319
42645
|
const addr = server.address();
|
|
42320
42646
|
if (addr && typeof addr === "object")
|
|
42321
|
-
|
|
42647
|
+
resolve29(addr.port);
|
|
42322
42648
|
else
|
|
42323
42649
|
reject(new Error("no port"));
|
|
42324
42650
|
});
|
|
@@ -42341,16 +42667,16 @@ async function startRpcServer(options) {
|
|
|
42341
42667
|
rpcPort: port
|
|
42342
42668
|
});
|
|
42343
42669
|
} catch (error) {
|
|
42344
|
-
await new Promise((
|
|
42670
|
+
await new Promise((resolve29) => server.close(() => resolve29()));
|
|
42345
42671
|
throw error;
|
|
42346
42672
|
}
|
|
42347
42673
|
return {
|
|
42348
42674
|
port,
|
|
42349
42675
|
token,
|
|
42350
42676
|
async stop() {
|
|
42351
|
-
await new Promise((
|
|
42677
|
+
await new Promise((resolve29) => {
|
|
42352
42678
|
server.closeAllConnections?.();
|
|
42353
|
-
server.close(() =>
|
|
42679
|
+
server.close(() => resolve29());
|
|
42354
42680
|
for (const socket of connections)
|
|
42355
42681
|
socket.destroy();
|
|
42356
42682
|
});
|
|
@@ -43727,7 +44053,7 @@ async function select3(items, options) {
|
|
|
43727
44053
|
}
|
|
43728
44054
|
renderedLines = linesWritten;
|
|
43729
44055
|
};
|
|
43730
|
-
return new Promise((
|
|
44056
|
+
return new Promise((resolve29) => {
|
|
43731
44057
|
const wasRaw = stdin.isRaw ?? false;
|
|
43732
44058
|
const cleanup2 = () => {
|
|
43733
44059
|
if (isCleanedUp) return;
|
|
@@ -43748,11 +44074,11 @@ async function select3(items, options) {
|
|
|
43748
44074
|
};
|
|
43749
44075
|
const onSignal = () => {
|
|
43750
44076
|
cleanup2();
|
|
43751
|
-
|
|
44077
|
+
resolve29(null);
|
|
43752
44078
|
};
|
|
43753
44079
|
const finishWithValue = (value) => {
|
|
43754
44080
|
cleanup2();
|
|
43755
|
-
|
|
44081
|
+
resolve29(value);
|
|
43756
44082
|
};
|
|
43757
44083
|
const findNextSelectable = (from, direction) => {
|
|
43758
44084
|
if (items.length === 0) return from;
|
|
@@ -43798,7 +44124,7 @@ async function select3(items, options) {
|
|
|
43798
44124
|
stdin.setRawMode(true);
|
|
43799
44125
|
} catch {
|
|
43800
44126
|
cleanup2();
|
|
43801
|
-
|
|
44127
|
+
resolve29(null);
|
|
43802
44128
|
return;
|
|
43803
44129
|
}
|
|
43804
44130
|
stdin.resume();
|
|
@@ -46564,7 +46890,7 @@ init_runtime_paths();
|
|
|
46564
46890
|
init_logger4();
|
|
46565
46891
|
import { existsSync as existsSync11, readFileSync as readFileSync11, realpathSync as realpathSync5 } from "node:fs";
|
|
46566
46892
|
import { homedir as homedir12 } from "node:os";
|
|
46567
|
-
import { basename as basename7, dirname as dirname25, join as join33, resolve as
|
|
46893
|
+
import { basename as basename7, dirname as dirname25, join as join33, resolve as resolve26 } from "node:path";
|
|
46568
46894
|
|
|
46569
46895
|
// src/plugin/config/schema.ts
|
|
46570
46896
|
import { z } from "zod";
|
|
@@ -47122,7 +47448,7 @@ function loadConfigWithLogger(directory, log17) {
|
|
|
47122
47448
|
return config;
|
|
47123
47449
|
}
|
|
47124
47450
|
function canonicalizeOwnedPath(path5) {
|
|
47125
|
-
const absolute =
|
|
47451
|
+
const absolute = resolve26(path5);
|
|
47126
47452
|
const missing = [];
|
|
47127
47453
|
let current = absolute;
|
|
47128
47454
|
for (; ; ) {
|
|
@@ -51007,7 +51333,7 @@ function stripUnsupportedAntigravityFields(payload) {
|
|
|
51007
51333
|
}
|
|
51008
51334
|
}
|
|
51009
51335
|
function configureAntigravityToolCalling(payload, wireModel) {
|
|
51010
|
-
if (isGeminiArgonModel(wireModel) || !Array.isArray(payload.tools) || payload.tools.length === 0) {
|
|
51336
|
+
if (isGeminiArgonModel(wireModel) || isGeminiCarbonModel(wireModel) || !Array.isArray(payload.tools) || payload.tools.length === 0) {
|
|
51011
51337
|
delete payload.toolConfig;
|
|
51012
51338
|
return;
|
|
51013
51339
|
}
|
|
@@ -51630,7 +51956,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
51630
51956
|
`[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)}`
|
|
51631
51957
|
);
|
|
51632
51958
|
delete requestPayload.providerOptions;
|
|
51633
|
-
if (variantConfig?.thinkingLevel && (isGemini3 || isGeminiArgonModel(effectiveModel) || getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking)) {
|
|
51959
|
+
if (variantConfig?.thinkingLevel && (isGemini3 || isGeminiArgonModel(effectiveModel) || isGeminiCarbonModel(effectiveModel) || getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking)) {
|
|
51634
51960
|
const variantModelBase = rawModel.replace(/-preview-customtools$/i, "").replace(/-preview$/i, "").replace(/-(minimal|low|medium|high)$/i, "");
|
|
51635
51961
|
const variantResolved = resolveAntigravityModel(
|
|
51636
51962
|
`${variantModelBase}-${variantConfig.thinkingLevel}`
|
|
@@ -52574,10 +52900,10 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
52574
52900
|
cancellation.release();
|
|
52575
52901
|
throw error;
|
|
52576
52902
|
}
|
|
52577
|
-
let
|
|
52903
|
+
let resolve29 = () => {
|
|
52578
52904
|
};
|
|
52579
52905
|
const settled = new Promise((done) => {
|
|
52580
|
-
|
|
52906
|
+
resolve29 = done;
|
|
52581
52907
|
});
|
|
52582
52908
|
let stopping = false;
|
|
52583
52909
|
let finished = false;
|
|
@@ -52587,7 +52913,7 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
52587
52913
|
finished = true;
|
|
52588
52914
|
cancellation.signal.removeEventListener("abort", abort);
|
|
52589
52915
|
cancellation.release();
|
|
52590
|
-
|
|
52916
|
+
resolve29();
|
|
52591
52917
|
};
|
|
52592
52918
|
const abort = () => {
|
|
52593
52919
|
if (finished || stopping) return;
|
|
@@ -52656,8 +52982,8 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
52656
52982
|
let running = false;
|
|
52657
52983
|
let resolveCompletion = () => {
|
|
52658
52984
|
};
|
|
52659
|
-
const completion = new Promise((
|
|
52660
|
-
resolveCompletion =
|
|
52985
|
+
const completion = new Promise((resolve29) => {
|
|
52986
|
+
resolveCompletion = resolve29;
|
|
52661
52987
|
});
|
|
52662
52988
|
const finish = () => {
|
|
52663
52989
|
if (finished) return;
|
|
@@ -52704,14 +53030,14 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
52704
53030
|
};
|
|
52705
53031
|
}
|
|
52706
53032
|
function publishResponse(dispatch) {
|
|
52707
|
-
return new Promise((
|
|
53033
|
+
return new Promise((resolve29, reject) => {
|
|
52708
53034
|
let acknowledge;
|
|
52709
53035
|
void Promise.resolve().then(
|
|
52710
53036
|
() => dispatch((callback) => {
|
|
52711
53037
|
acknowledge = callback;
|
|
52712
53038
|
})
|
|
52713
53039
|
).then((response) => {
|
|
52714
|
-
|
|
53040
|
+
resolve29(response);
|
|
52715
53041
|
acknowledge?.();
|
|
52716
53042
|
}, reject);
|
|
52717
53043
|
});
|
|
@@ -54545,10 +54871,10 @@ function resolvePluginDependencies(overrides = {}) {
|
|
|
54545
54871
|
}
|
|
54546
54872
|
async function defaultSleep(ms, signal) {
|
|
54547
54873
|
if (ms <= 0) return;
|
|
54548
|
-
await new Promise((
|
|
54874
|
+
await new Promise((resolve29, reject) => {
|
|
54549
54875
|
const timer = setTimeout(() => {
|
|
54550
54876
|
signal?.removeEventListener("abort", onAbort);
|
|
54551
|
-
|
|
54877
|
+
resolve29();
|
|
54552
54878
|
}, ms);
|
|
54553
54879
|
timer.unref?.();
|
|
54554
54880
|
const onAbort = () => {
|
|
@@ -54679,10 +55005,72 @@ function routingHandle(sessionId) {
|
|
|
54679
55005
|
return typeof handle === "object" && handle !== null ? handle : void 0;
|
|
54680
55006
|
}
|
|
54681
55007
|
|
|
55008
|
+
// src/common-auth-embedded/routing-accessor/cache-policy.js
|
|
55009
|
+
var CACHE_WARM_STOP_REASONS = [
|
|
55010
|
+
"cost-cap",
|
|
55011
|
+
"count-cap",
|
|
55012
|
+
"outside-hours",
|
|
55013
|
+
"session-ended",
|
|
55014
|
+
"unsupported"
|
|
55015
|
+
];
|
|
55016
|
+
function isCacheWarmStopReason(value) {
|
|
55017
|
+
return CACHE_WARM_STOP_REASONS.some((reason) => reason === value);
|
|
55018
|
+
}
|
|
55019
|
+
|
|
54682
55020
|
// src/common-auth-embedded/routing-accessor/index.js
|
|
54683
55021
|
function isObject2(value) {
|
|
54684
55022
|
return typeof value === "object" && value !== null;
|
|
54685
55023
|
}
|
|
55024
|
+
function isNonEmptyString(value) {
|
|
55025
|
+
return typeof value === "string" && value.length > 0;
|
|
55026
|
+
}
|
|
55027
|
+
function billingCache(value) {
|
|
55028
|
+
if (!isObject2(value) || Array.isArray(value))
|
|
55029
|
+
return;
|
|
55030
|
+
const { ttlMs, implicit, warming } = value;
|
|
55031
|
+
const cache = {};
|
|
55032
|
+
if (!(ttlMs !== void 0 && implicit !== void 0)) {
|
|
55033
|
+
if (typeof ttlMs === "number" && Number.isSafeInteger(ttlMs) && ttlMs > 0) {
|
|
55034
|
+
cache.ttl_ms = ttlMs;
|
|
55035
|
+
} else if (implicit === true) {
|
|
55036
|
+
cache.implicit = true;
|
|
55037
|
+
}
|
|
55038
|
+
}
|
|
55039
|
+
if (isObject2(warming) && !Array.isArray(warming)) {
|
|
55040
|
+
const { on, stopReason } = warming;
|
|
55041
|
+
if (typeof on === "boolean") {
|
|
55042
|
+
cache.warming = {
|
|
55043
|
+
on,
|
|
55044
|
+
...!on && isCacheWarmStopReason(stopReason) ? { stop_reason: stopReason } : {}
|
|
55045
|
+
};
|
|
55046
|
+
}
|
|
55047
|
+
}
|
|
55048
|
+
return Object.keys(cache).length > 0 ? cache : void 0;
|
|
55049
|
+
}
|
|
55050
|
+
function billingUsage(value) {
|
|
55051
|
+
if (!isObject2(value) || Array.isArray(value))
|
|
55052
|
+
return;
|
|
55053
|
+
const usage = {};
|
|
55054
|
+
for (const [inputKey, payloadKey] of [
|
|
55055
|
+
["input", "input"],
|
|
55056
|
+
["output", "output"],
|
|
55057
|
+
["cacheRead", "cache_read"],
|
|
55058
|
+
["cacheWrite", "cache_write"],
|
|
55059
|
+
["cacheWrite5m", "cache_write_5m"],
|
|
55060
|
+
["cacheWrite1h", "cache_write_1h"],
|
|
55061
|
+
["reasoning", "reasoning"]
|
|
55062
|
+
]) {
|
|
55063
|
+
const count3 = value[inputKey];
|
|
55064
|
+
if (typeof count3 === "number" && Number.isSafeInteger(count3) && count3 >= 0) {
|
|
55065
|
+
usage[payloadKey] = count3;
|
|
55066
|
+
}
|
|
55067
|
+
}
|
|
55068
|
+
const reasoningIncludedInOutput = value.reasoningIncludedInOutput;
|
|
55069
|
+
if (typeof reasoningIncludedInOutput === "boolean") {
|
|
55070
|
+
usage.reasoning_included_in_output = reasoningIncludedInOutput;
|
|
55071
|
+
}
|
|
55072
|
+
return Object.keys(usage).length > 0 ? usage : void 0;
|
|
55073
|
+
}
|
|
54686
55074
|
function selectionFor(answer, candidates) {
|
|
54687
55075
|
if (!isObject2(answer))
|
|
54688
55076
|
return void 0;
|
|
@@ -54714,8 +55102,8 @@ async function askRouting(input2) {
|
|
|
54714
55102
|
return void 0;
|
|
54715
55103
|
const requested = input2.deadlineMs ?? 500;
|
|
54716
55104
|
const deadlineMs = Number.isNaN(requested) ? 500 : Math.min(2e3, Math.max(1, requested));
|
|
54717
|
-
const expired = new Promise((
|
|
54718
|
-
timer = setTimeout(() =>
|
|
55105
|
+
const expired = new Promise((resolve29) => {
|
|
55106
|
+
timer = setTimeout(() => resolve29(void 0), deadlineMs);
|
|
54719
55107
|
timer.unref();
|
|
54720
55108
|
});
|
|
54721
55109
|
const request2 = {
|
|
@@ -54748,6 +55136,47 @@ function reportRouting(input2) {
|
|
|
54748
55136
|
let payload;
|
|
54749
55137
|
if ("kind" in input2) {
|
|
54750
55138
|
switch (input2.kind) {
|
|
55139
|
+
case "billing": {
|
|
55140
|
+
const { attemptId, requestKind, credentialId, provider: provider2, model, outcome, accountId, providerRequestId, providerResponseId, userMessageId, status, attempt, chargeBasis, usage: inputUsage, usageByModel: inputUsageByModel, cache: inputCache } = input2;
|
|
55141
|
+
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")
|
|
55142
|
+
return;
|
|
55143
|
+
const usage = billingUsage(inputUsage);
|
|
55144
|
+
const cache = billingCache(inputCache);
|
|
55145
|
+
const usageByModel = [];
|
|
55146
|
+
if (Array.isArray(inputUsageByModel)) {
|
|
55147
|
+
for (const entry of inputUsageByModel) {
|
|
55148
|
+
if (!isObject2(entry) || Array.isArray(entry))
|
|
55149
|
+
continue;
|
|
55150
|
+
const modelUsed = entry.modelUsed;
|
|
55151
|
+
if (!isNonEmptyString(modelUsed))
|
|
55152
|
+
continue;
|
|
55153
|
+
const modelUsage = billingUsage(entry.usage);
|
|
55154
|
+
if (!modelUsage)
|
|
55155
|
+
continue;
|
|
55156
|
+
usageByModel.push({ model_used: modelUsed, usage: modelUsage });
|
|
55157
|
+
}
|
|
55158
|
+
}
|
|
55159
|
+
payload = {
|
|
55160
|
+
kind: "billing",
|
|
55161
|
+
attempt_id: attemptId,
|
|
55162
|
+
request_kind: requestKind,
|
|
55163
|
+
credential_id: credentialId,
|
|
55164
|
+
provider: provider2,
|
|
55165
|
+
model,
|
|
55166
|
+
outcome,
|
|
55167
|
+
...isNonEmptyString(accountId) ? { account_id: accountId } : {},
|
|
55168
|
+
...isNonEmptyString(providerRequestId) ? { provider_request_id: providerRequestId } : {},
|
|
55169
|
+
...isNonEmptyString(providerResponseId) ? { provider_response_id: providerResponseId } : {},
|
|
55170
|
+
...isNonEmptyString(userMessageId) ? { user_message_id: userMessageId } : {},
|
|
55171
|
+
...typeof status === "number" && Number.isInteger(status) && status >= 0 ? { status } : {},
|
|
55172
|
+
...typeof attempt === "number" && Number.isInteger(attempt) && attempt >= 1 ? { attempt } : {},
|
|
55173
|
+
...chargeBasis === "subscription_included" || chargeBasis === "metered_api" ? { charge_basis: chargeBasis } : {},
|
|
55174
|
+
...usage ? { usage } : {},
|
|
55175
|
+
...usageByModel.length > 0 ? { usage_by_model: usageByModel } : {},
|
|
55176
|
+
...cache ? { cache } : {}
|
|
55177
|
+
};
|
|
55178
|
+
break;
|
|
55179
|
+
}
|
|
54751
55180
|
case "turn_notes_supported": {
|
|
54752
55181
|
const { model, supported } = input2;
|
|
54753
55182
|
if (typeof model !== "string" || model.length === 0 || typeof supported !== "boolean")
|
|
@@ -55275,7 +55704,7 @@ function throwIfAllKilled(input2) {
|
|
|
55275
55704
|
}
|
|
55276
55705
|
|
|
55277
55706
|
// src/plugin/session-context.ts
|
|
55278
|
-
import { resolve as
|
|
55707
|
+
import { resolve as resolve27 } from "node:path";
|
|
55279
55708
|
import { pathToFileURL } from "node:url";
|
|
55280
55709
|
var FALLBACK_SESSION_KEY = "__default__";
|
|
55281
55710
|
function extractOpenCodeSessionIdentity(headers) {
|
|
@@ -55289,7 +55718,7 @@ var AgySessionRegistry = class {
|
|
|
55289
55718
|
requestSessions;
|
|
55290
55719
|
parentSessionIds = /* @__PURE__ */ new Map();
|
|
55291
55720
|
constructor(directory, options = {}) {
|
|
55292
|
-
const workspaceUri = directory ? pathToFileURL(
|
|
55721
|
+
const workspaceUri = directory ? pathToFileURL(resolve27(directory)).href : "";
|
|
55293
55722
|
this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
|
|
55294
55723
|
}
|
|
55295
55724
|
getOrCreate(identity3) {
|
|
@@ -55605,7 +56034,7 @@ function formatWaitTime(ms) {
|
|
|
55605
56034
|
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
|
|
55606
56035
|
}
|
|
55607
56036
|
function sleep4(ms, signal) {
|
|
55608
|
-
return new Promise((
|
|
56037
|
+
return new Promise((resolve29, reject) => {
|
|
55609
56038
|
if (signal?.aborted) {
|
|
55610
56039
|
reject(
|
|
55611
56040
|
signal.reason instanceof Error ? signal.reason : new Error("Aborted")
|
|
@@ -55615,7 +56044,7 @@ function sleep4(ms, signal) {
|
|
|
55615
56044
|
const timerMs = Math.min(Math.max(0, Math.floor(ms)), 2147483647);
|
|
55616
56045
|
const timeout = setTimeout(() => {
|
|
55617
56046
|
cleanup2();
|
|
55618
|
-
|
|
56047
|
+
resolve29();
|
|
55619
56048
|
}, timerMs);
|
|
55620
56049
|
const onAbort = () => {
|
|
55621
56050
|
cleanup2();
|
|
@@ -58245,8 +58674,8 @@ function createPluginLifecycle(options) {
|
|
|
58245
58674
|
};
|
|
58246
58675
|
let failDisposal = () => {
|
|
58247
58676
|
};
|
|
58248
|
-
disposal = new Promise((
|
|
58249
|
-
finishDisposal =
|
|
58677
|
+
disposal = new Promise((resolve29, reject) => {
|
|
58678
|
+
finishDisposal = resolve29;
|
|
58250
58679
|
failDisposal = reject;
|
|
58251
58680
|
});
|
|
58252
58681
|
void (async () => {
|
|
@@ -58447,7 +58876,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
58447
58876
|
await drainSidebarWrites();
|
|
58448
58877
|
}
|
|
58449
58878
|
});
|
|
58450
|
-
const accountFile =
|
|
58879
|
+
const accountFile = resolve28(accountFileForVault());
|
|
58451
58880
|
const vaultFolder = await prepareVaultFolder({ accountFile });
|
|
58452
58881
|
const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
|
|
58453
58882
|
let vaultQuotaPoller;
|