@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/server.js
CHANGED
|
@@ -5933,6 +5933,8 @@ function getGemini38FlashAntigravityModel(tier) {
|
|
|
5933
5933
|
}
|
|
5934
5934
|
function getQuotaGroupForModel(modelId, hasArgonPool = false) {
|
|
5935
5935
|
const normalized = modelId.toLowerCase();
|
|
5936
|
+
if (isGeminiCarbonModel(normalized))
|
|
5937
|
+
return "gemini";
|
|
5936
5938
|
if (isGeminiArgonModel(normalized))
|
|
5937
5939
|
return hasArgonPool ? "gemini-argon" : void 0;
|
|
5938
5940
|
return QUOTA_GROUP_BY_MODEL_ID[normalized] ?? // Check Claude / GPT-OSS substrings BEFORE the `gemini` substring so
|
|
@@ -5945,6 +5947,19 @@ function getQuotaGroupForModel(modelId, hasArgonPool = false) {
|
|
|
5945
5947
|
function isGeminiArgonModel(model) {
|
|
5946
5948
|
return /^(?:antigravity-)?gemini-4-argon(?:-(?:low|medium|high))?$/.test(model.toLowerCase());
|
|
5947
5949
|
}
|
|
5950
|
+
function isGeminiCarbonModel(model) {
|
|
5951
|
+
return /^(?:antigravity-)?gemini-4-carbon(?:-(?:low|medium|high))?$/.test(model.toLowerCase());
|
|
5952
|
+
}
|
|
5953
|
+
function getGeminiCarbonAntigravityModel(tier) {
|
|
5954
|
+
return getTieredAntigravityModel({
|
|
5955
|
+
defaultModel: "gemini-4-carbon-medium",
|
|
5956
|
+
byTier: {
|
|
5957
|
+
low: "gemini-4-carbon-low",
|
|
5958
|
+
medium: "gemini-4-carbon-medium",
|
|
5959
|
+
high: "gemini-4-carbon-high"
|
|
5960
|
+
}
|
|
5961
|
+
}, tier);
|
|
5962
|
+
}
|
|
5948
5963
|
function getGeminiArgonAntigravityModel(tier) {
|
|
5949
5964
|
return getTieredAntigravityModel({
|
|
5950
5965
|
defaultModel: "gemini-4-argon-medium",
|
|
@@ -5967,6 +5982,33 @@ var init_model_registry = __esm({
|
|
|
5967
5982
|
DEFAULT_COST = { input: 0, output: 0 };
|
|
5968
5983
|
DEFAULT_OPTIONS = {};
|
|
5969
5984
|
AGY_NATIVE_MODEL_DEFINITIONS = {
|
|
5985
|
+
"gemini-4-carbon-low": {
|
|
5986
|
+
displayName: "Gemini 4 Carbon (Low)",
|
|
5987
|
+
maxTokens: 1048576,
|
|
5988
|
+
maxOutputTokens: 262144,
|
|
5989
|
+
model: "MODEL_PLACEHOLDER_M438",
|
|
5990
|
+
thinkingLevel: 1,
|
|
5991
|
+
thinkingBudget: -1,
|
|
5992
|
+
supportsThinking: true
|
|
5993
|
+
},
|
|
5994
|
+
"gemini-4-carbon-medium": {
|
|
5995
|
+
displayName: "Gemini 4 Carbon (Medium)",
|
|
5996
|
+
maxTokens: 1048576,
|
|
5997
|
+
maxOutputTokens: 262144,
|
|
5998
|
+
model: "MODEL_PLACEHOLDER_M437",
|
|
5999
|
+
thinkingLevel: 2,
|
|
6000
|
+
thinkingBudget: -1,
|
|
6001
|
+
supportsThinking: true
|
|
6002
|
+
},
|
|
6003
|
+
"gemini-4-carbon-high": {
|
|
6004
|
+
displayName: "Gemini 4 Carbon (High)",
|
|
6005
|
+
maxTokens: 1048576,
|
|
6006
|
+
maxOutputTokens: 262144,
|
|
6007
|
+
model: "MODEL_PLACEHOLDER_M427",
|
|
6008
|
+
thinkingLevel: 3,
|
|
6009
|
+
thinkingBudget: -1,
|
|
6010
|
+
supportsThinking: true
|
|
6011
|
+
},
|
|
5970
6012
|
"gemini-4-argon-low": {
|
|
5971
6013
|
displayName: "Gemini 4 Argon (Low)",
|
|
5972
6014
|
maxTokens: 1048576,
|
|
@@ -6105,6 +6147,17 @@ var init_model_registry = __esm({
|
|
|
6105
6147
|
high: { thinkingLevel: "high" }
|
|
6106
6148
|
}
|
|
6107
6149
|
}),
|
|
6150
|
+
"antigravity-gemini-4-carbon": defineModel("antigravity-gemini-4-carbon", {
|
|
6151
|
+
name: "Gemini 4 Carbon (Antigravity)",
|
|
6152
|
+
reasoning: true,
|
|
6153
|
+
limit: { context: 1048576, output: 262144 },
|
|
6154
|
+
modalities: DEFAULT_MODALITIES,
|
|
6155
|
+
variants: {
|
|
6156
|
+
low: { thinkingLevel: "low" },
|
|
6157
|
+
medium: { thinkingLevel: "medium" },
|
|
6158
|
+
high: { thinkingLevel: "high" }
|
|
6159
|
+
}
|
|
6160
|
+
}),
|
|
6108
6161
|
"antigravity-gemini-3.1-flash-image": defineModel("antigravity-gemini-3.1-flash-image", {
|
|
6109
6162
|
name: "Gemini 3.1 Flash Image (Antigravity)",
|
|
6110
6163
|
reasoning: false,
|
|
@@ -6152,6 +6205,9 @@ var init_model_registry = __esm({
|
|
|
6152
6205
|
})
|
|
6153
6206
|
};
|
|
6154
6207
|
RESOLVER_ALIASES = {
|
|
6208
|
+
"gemini-4-carbon-low": "gemini-4-carbon",
|
|
6209
|
+
"gemini-4-carbon-medium": "gemini-4-carbon",
|
|
6210
|
+
"gemini-4-carbon-high": "gemini-4-carbon",
|
|
6155
6211
|
"gemini-4-argon-low": "gemini-4-argon",
|
|
6156
6212
|
"gemini-4-argon-medium": "gemini-4-argon",
|
|
6157
6213
|
"gemini-4-argon-high": "gemini-4-argon",
|
|
@@ -6247,6 +6303,7 @@ var init_model_registry = __esm({
|
|
|
6247
6303
|
};
|
|
6248
6304
|
ANTIGRAVITY_OPENCODE_MODEL_IDS = [
|
|
6249
6305
|
"antigravity-gemini-4-argon",
|
|
6306
|
+
"antigravity-gemini-4-carbon",
|
|
6250
6307
|
"antigravity-gemini-3.8-flash",
|
|
6251
6308
|
"antigravity-gemini-3.1-flash-image",
|
|
6252
6309
|
"antigravity-claude-sonnet-5-5",
|
|
@@ -7883,7 +7940,7 @@ async function rmEvictingDir(evictingPath) {
|
|
|
7883
7940
|
});
|
|
7884
7941
|
}
|
|
7885
7942
|
async function sleep(ms) {
|
|
7886
|
-
await new Promise((
|
|
7943
|
+
await new Promise((resolve30) => setTimeout(resolve30, ms));
|
|
7887
7944
|
}
|
|
7888
7945
|
async function acquireFencedFileLock(options) {
|
|
7889
7946
|
const lockPath = `${options.path}.${options.name}.lock`;
|
|
@@ -7999,8 +8056,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
7999
8056
|
let released = false;
|
|
8000
8057
|
let lost = false;
|
|
8001
8058
|
let lostResolve = null;
|
|
8002
|
-
let lostPromise = new Promise((
|
|
8003
|
-
lostResolve =
|
|
8059
|
+
let lostPromise = new Promise((resolve30) => {
|
|
8060
|
+
lostResolve = resolve30;
|
|
8004
8061
|
});
|
|
8005
8062
|
const markLost = () => {
|
|
8006
8063
|
if (lost)
|
|
@@ -8010,9 +8067,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
8010
8067
|
clearInterval(renewTimer);
|
|
8011
8068
|
renewTimer = null;
|
|
8012
8069
|
}
|
|
8013
|
-
const
|
|
8070
|
+
const resolve30 = lostResolve;
|
|
8014
8071
|
lostResolve = null;
|
|
8015
|
-
|
|
8072
|
+
resolve30?.();
|
|
8016
8073
|
};
|
|
8017
8074
|
const setupRenew = () => {
|
|
8018
8075
|
if (options.renew === false)
|
|
@@ -8635,7 +8692,7 @@ async function saveAccountStorageReplace(path5, incoming) {
|
|
|
8635
8692
|
return mutateAccountStorage(path5, () => incoming);
|
|
8636
8693
|
}
|
|
8637
8694
|
async function clearAccountStorage(path5) {
|
|
8638
|
-
const sleep5 = (ms) => new Promise((
|
|
8695
|
+
const sleep5 = (ms) => new Promise((resolve30) => setTimeout(resolve30, ms));
|
|
8639
8696
|
const lock = await acquireWithRetry(path5, sleep5);
|
|
8640
8697
|
try {
|
|
8641
8698
|
await assertLegacyAccountStorageWritable(path5);
|
|
@@ -8683,7 +8740,7 @@ var init_account_storage = __esm({
|
|
|
8683
8740
|
}
|
|
8684
8741
|
};
|
|
8685
8742
|
RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
|
|
8686
|
-
DEFAULT_SLEEP = (ms) => new Promise((
|
|
8743
|
+
DEFAULT_SLEEP = (ms) => new Promise((resolve30) => setTimeout(resolve30, ms));
|
|
8687
8744
|
DEFAULT_BUILD_BACKUP_PATH = (path5, now) => `${path5}.corrupt-${now.toISOString().replace(/[:.]/g, "-")}`;
|
|
8688
8745
|
}
|
|
8689
8746
|
});
|
|
@@ -9901,8 +9958,8 @@ var init_account_manager = __esm({
|
|
|
9901
9958
|
await this.saveInFlight;
|
|
9902
9959
|
return;
|
|
9903
9960
|
}
|
|
9904
|
-
return new Promise((
|
|
9905
|
-
this.savePromiseResolvers.push({ resolve:
|
|
9961
|
+
return new Promise((resolve30, reject) => {
|
|
9962
|
+
this.savePromiseResolvers.push({ resolve: resolve30, reject });
|
|
9906
9963
|
});
|
|
9907
9964
|
}
|
|
9908
9965
|
async dispose() {
|
|
@@ -9945,8 +10002,8 @@ var init_account_manager = __esm({
|
|
|
9945
10002
|
reject(error);
|
|
9946
10003
|
throw error;
|
|
9947
10004
|
}
|
|
9948
|
-
for (const { resolve:
|
|
9949
|
-
|
|
10005
|
+
for (const { resolve: resolve30 } of resolvers)
|
|
10006
|
+
resolve30();
|
|
9950
10007
|
}
|
|
9951
10008
|
async executeSave() {
|
|
9952
10009
|
this.savePending = false;
|
|
@@ -9960,16 +10017,16 @@ var init_account_manager = __esm({
|
|
|
9960
10017
|
}
|
|
9961
10018
|
try {
|
|
9962
10019
|
await this.saveToDisk();
|
|
9963
|
-
for (const { resolve:
|
|
9964
|
-
|
|
10020
|
+
for (const { resolve: resolve30 } of resolvers) {
|
|
10021
|
+
resolve30();
|
|
9965
10022
|
}
|
|
9966
10023
|
} catch (error) {
|
|
9967
10024
|
if (isStorageLockContention(error)) {
|
|
9968
10025
|
this.onDiagnostic?.("Skipped account-state persist due to storage lock contention", {
|
|
9969
10026
|
error: String(error)
|
|
9970
10027
|
});
|
|
9971
|
-
for (const { resolve:
|
|
9972
|
-
|
|
10028
|
+
for (const { resolve: resolve30 } of resolvers) {
|
|
10029
|
+
resolve30();
|
|
9973
10030
|
}
|
|
9974
10031
|
return;
|
|
9975
10032
|
}
|
|
@@ -10470,7 +10527,7 @@ function getHttpsProxy(url) {
|
|
|
10470
10527
|
}
|
|
10471
10528
|
}
|
|
10472
10529
|
function waitForHead(socket, timeoutMs, onTimeout) {
|
|
10473
|
-
return new Promise((
|
|
10530
|
+
return new Promise((resolve30, reject) => {
|
|
10474
10531
|
let buffer = Buffer3.alloc(0);
|
|
10475
10532
|
const timeout = setTimeout(() => {
|
|
10476
10533
|
onTimeout();
|
|
@@ -10493,7 +10550,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
|
|
|
10493
10550
|
return;
|
|
10494
10551
|
const head = buffer.subarray(0, marker).toString("latin1");
|
|
10495
10552
|
const leftover = buffer.subarray(marker + 4);
|
|
10496
|
-
cleanup2(() =>
|
|
10553
|
+
cleanup2(() => resolve30({ head, leftover }));
|
|
10497
10554
|
};
|
|
10498
10555
|
socket.on("data", onData);
|
|
10499
10556
|
socket.once("error", onError);
|
|
@@ -10507,7 +10564,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
10507
10564
|
port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
|
|
10508
10565
|
signal: signal ?? void 0
|
|
10509
10566
|
});
|
|
10510
|
-
await new Promise((
|
|
10567
|
+
await new Promise((resolve30, reject) => {
|
|
10511
10568
|
const timeout = setTimeout(() => {
|
|
10512
10569
|
onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
|
|
10513
10570
|
proxySocket.destroy();
|
|
@@ -10516,7 +10573,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
10516
10573
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10517
10574
|
proxySocket.once("connect", () => {
|
|
10518
10575
|
cleanup2();
|
|
10519
|
-
|
|
10576
|
+
resolve30();
|
|
10520
10577
|
});
|
|
10521
10578
|
proxySocket.once("error", (error) => {
|
|
10522
10579
|
cleanup2();
|
|
@@ -10541,7 +10598,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10541
10598
|
if (leftover.length > 0) {
|
|
10542
10599
|
proxySocket.unshift(leftover);
|
|
10543
10600
|
}
|
|
10544
|
-
return await new Promise((
|
|
10601
|
+
return await new Promise((resolve30, reject) => {
|
|
10545
10602
|
const tlsOptions = {
|
|
10546
10603
|
socket: proxySocket,
|
|
10547
10604
|
servername: targetHost,
|
|
@@ -10556,7 +10613,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10556
10613
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10557
10614
|
tlsSocket.once("secureConnect", () => {
|
|
10558
10615
|
cleanup2();
|
|
10559
|
-
|
|
10616
|
+
resolve30(tlsSocket);
|
|
10560
10617
|
});
|
|
10561
10618
|
tlsSocket.once("error", (error) => {
|
|
10562
10619
|
cleanup2();
|
|
@@ -10565,7 +10622,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
10565
10622
|
});
|
|
10566
10623
|
}
|
|
10567
10624
|
async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
10568
|
-
return await new Promise((
|
|
10625
|
+
return await new Promise((resolve30, reject) => {
|
|
10569
10626
|
const tlsOptions = {
|
|
10570
10627
|
host: targetUrl.hostname,
|
|
10571
10628
|
port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
|
|
@@ -10581,7 +10638,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
|
10581
10638
|
const cleanup2 = () => clearTimeout(timeout);
|
|
10582
10639
|
socket.once("secureConnect", () => {
|
|
10583
10640
|
cleanup2();
|
|
10584
|
-
|
|
10641
|
+
resolve30(socket);
|
|
10585
10642
|
});
|
|
10586
10643
|
socket.once("error", (error) => {
|
|
10587
10644
|
cleanup2();
|
|
@@ -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((resolve30) => {
|
|
12840
|
+
resolveLoss = resolve30;
|
|
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((resolve30) => setTimeout(resolve30, 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((resolve30) => setTimeout(resolve30, 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((resolve30) => setTimeout(resolve30, 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((resolve30) => setTimeout(resolve30, 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((resolve30) => setTimeout(resolve30, 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((resolve30) => {
|
|
16951
17088
|
const done = () => {
|
|
16952
17089
|
clearTimeout(timer);
|
|
16953
17090
|
this.wake.delete(done);
|
|
16954
|
-
|
|
17091
|
+
resolve30();
|
|
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((resolve30) => {
|
|
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
|
+
resolve30(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
|
+
resolve30(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 shared4 = sources.get(key);
|
|
20921
21067
|
if (!shared4) {
|
|
@@ -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(plugin2, host) {
|
|
|
21248
21394
|
throw new ClaustrumConsumerError("invalid-state", "Claustrum enrollment names use lowercase letters, digits and dashes");
|
|
21249
21395
|
return `${plugin2}-${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((resolve30) => {
|
|
22002
22169
|
timer = setTimeout(() => {
|
|
22003
22170
|
expired = true;
|
|
22004
|
-
|
|
22171
|
+
resolve30();
|
|
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((resolve30, 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
|
+
resolve30(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((resolve30, 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
|
+
resolve30(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((resolve30) => {
|
|
26986
|
+
setTimeout(resolve30, 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((resolve30, 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(resolve30, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
29091
29315
|
});
|
|
29092
29316
|
}
|
|
29093
29317
|
async function resolveClaustrumConnectionPath(explicit) {
|
|
@@ -29555,7 +29779,7 @@ var init_dist = __esm({
|
|
|
29555
29779
|
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
29556
29780
|
import { lstat as lstat6, readFile as readFile8, rename as rename8, unlink as unlink8 } from "node:fs/promises";
|
|
29557
29781
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
29558
|
-
import { dirname as dirname13, join as join10, resolve as
|
|
29782
|
+
import { dirname as dirname13, join as join10, resolve as resolve13 } from "node:path";
|
|
29559
29783
|
function ioCode2(detail) {
|
|
29560
29784
|
if (detail?.reason === "io-error") {
|
|
29561
29785
|
if (detail.win32Code === 2 || detail.win32Code === 3)
|
|
@@ -29605,7 +29829,7 @@ async function privateOperation2(path5, stage, operation) {
|
|
|
29605
29829
|
}
|
|
29606
29830
|
}
|
|
29607
29831
|
async function verifySafeDirectory2(path5, options) {
|
|
29608
|
-
path5 =
|
|
29832
|
+
path5 = resolve13(path5);
|
|
29609
29833
|
options ??= safeParentOptionsForTest2;
|
|
29610
29834
|
await privateOperation2(path5, "safe-parent", async () => {
|
|
29611
29835
|
const result = await (await loadBackend2()).verifySafeParent(path5, options);
|
|
@@ -29620,7 +29844,7 @@ async function verifySafeDirectory2(path5, options) {
|
|
|
29620
29844
|
});
|
|
29621
29845
|
}
|
|
29622
29846
|
async function verifyPrivate2(path5, kind, migrate = false) {
|
|
29623
|
-
path5 =
|
|
29847
|
+
path5 = resolve13(path5);
|
|
29624
29848
|
if (kind === "directory")
|
|
29625
29849
|
return verifySafeDirectory2(path5);
|
|
29626
29850
|
await privateOperation2(path5, "verify", async () => {
|
|
@@ -29655,7 +29879,7 @@ async function verifyPrivate2(path5, kind, migrate = false) {
|
|
|
29655
29879
|
});
|
|
29656
29880
|
}
|
|
29657
29881
|
async function ensurePrivateDirectory2(path5, _migrate = false, options) {
|
|
29658
|
-
path5 =
|
|
29882
|
+
path5 = resolve13(path5);
|
|
29659
29883
|
await privateOperation2(path5, "directory", async () => {
|
|
29660
29884
|
const api = await loadBackend2();
|
|
29661
29885
|
try {
|
|
@@ -29686,7 +29910,7 @@ async function readPrivateText2(path5, migrate = false) {
|
|
|
29686
29910
|
async function readPrivateBuffer2(path5, migrate = false) {
|
|
29687
29911
|
if (!windowsPrivateFiles2)
|
|
29688
29912
|
return readFile8(path5);
|
|
29689
|
-
path5 =
|
|
29913
|
+
path5 = resolve13(path5);
|
|
29690
29914
|
if (migrate) {
|
|
29691
29915
|
await verifySafeDirectory2(dirname13(path5));
|
|
29692
29916
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -29694,20 +29918,20 @@ async function readPrivateBuffer2(path5, migrate = false) {
|
|
|
29694
29918
|
return privateOperation2(path5, "read", async () => (await loadBackend2()).readOwnerOnly(path5));
|
|
29695
29919
|
}
|
|
29696
29920
|
async function createPrivateBytes2(path5, bytes) {
|
|
29697
|
-
await verifySafeDirectory2(dirname13(
|
|
29921
|
+
await verifySafeDirectory2(dirname13(resolve13(path5)));
|
|
29698
29922
|
await privateOperation2(path5, "create", async () => {
|
|
29699
|
-
await (await loadBackend2()).createPrivateFile(
|
|
29923
|
+
await (await loadBackend2()).createPrivateFile(resolve13(path5), bytes);
|
|
29700
29924
|
});
|
|
29701
29925
|
}
|
|
29702
29926
|
async function createPrivateDirectoryExclusive2(path5) {
|
|
29703
|
-
await verifySafeDirectory2(dirname13(
|
|
29927
|
+
await verifySafeDirectory2(dirname13(resolve13(path5)));
|
|
29704
29928
|
await privateOperation2(path5, "directory-create", async () => {
|
|
29705
|
-
await (await loadBackend2()).createOwnerOnly(
|
|
29929
|
+
await (await loadBackend2()).createOwnerOnly(resolve13(path5), { kind: "dir" });
|
|
29706
29930
|
});
|
|
29707
29931
|
}
|
|
29708
29932
|
async function replaceWindowsFile2(from, to, options = {}) {
|
|
29709
|
-
from =
|
|
29710
|
-
to =
|
|
29933
|
+
from = resolve13(from);
|
|
29934
|
+
to = resolve13(to);
|
|
29711
29935
|
const now = options.now ?? (() => performance.now());
|
|
29712
29936
|
const start = now();
|
|
29713
29937
|
const leaseDeadline = options.deadline ?? Infinity;
|
|
@@ -29750,7 +29974,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
|
|
|
29750
29974
|
throw error;
|
|
29751
29975
|
}
|
|
29752
29976
|
async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
29753
|
-
path5 =
|
|
29977
|
+
path5 = resolve13(path5);
|
|
29754
29978
|
await ensurePrivateDirectory2(dirname13(path5));
|
|
29755
29979
|
try {
|
|
29756
29980
|
await verifyPrivate2(path5, "file", true);
|
|
@@ -29758,7 +29982,7 @@ async function writePrivateAtomic2(path5, bytes, options = {}) {
|
|
|
29758
29982
|
if (error.code !== "ENOENT")
|
|
29759
29983
|
throw error;
|
|
29760
29984
|
}
|
|
29761
|
-
const stage =
|
|
29985
|
+
const stage = resolve13(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
|
|
29762
29986
|
if (dirname13(stage) !== dirname13(path5))
|
|
29763
29987
|
throw new PrivateFileError2(path5, "stage-directory", { code: "EXDEV" });
|
|
29764
29988
|
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 existsSync3, 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((resolve30, 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(() => resolve30(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((resolve30) => {
|
|
31093
31321
|
const done = () => {
|
|
31094
31322
|
clearTimeout(timer);
|
|
31095
31323
|
cancelWait = void 0;
|
|
31096
|
-
|
|
31324
|
+
resolve30();
|
|
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() {
|
|
@@ -31994,7 +32222,7 @@ import {
|
|
|
31994
32222
|
stat as stat11,
|
|
31995
32223
|
unlink as unlink10
|
|
31996
32224
|
} from "node:fs/promises";
|
|
31997
|
-
import { basename as basename4, dirname as dirname15, join as join14, resolve as
|
|
32225
|
+
import { basename as basename4, dirname as dirname15, join as join14, resolve as resolve16 } from "node:path";
|
|
31998
32226
|
function refusalMessage(stateDir, errorClass2) {
|
|
31999
32227
|
if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
|
|
32000
32228
|
return `antigravity-auth cannot start: ${stateDir} is not a folder only your user can access, or it is a link, so the plugin will not use it (${errorClass2}). Replace it with a plain folder of your own, then restart OpenCode.`;
|
|
@@ -32854,7 +33082,7 @@ async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
|
|
|
32854
33082
|
if (process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR) return;
|
|
32855
33083
|
const location = runtimeLayoutLocation();
|
|
32856
33084
|
const files = layoutFiles(location, accountFile);
|
|
32857
|
-
if (
|
|
33085
|
+
if (resolve16(vaultDir) !== resolve16(files.vault.next)) return;
|
|
32858
33086
|
const stateDir = location.stateHomeDir;
|
|
32859
33087
|
const marker = await readMarker(
|
|
32860
33088
|
join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
@@ -33283,7 +33511,7 @@ import {
|
|
|
33283
33511
|
writeFileSync
|
|
33284
33512
|
} from "node:fs";
|
|
33285
33513
|
import { homedir as homedir4 } from "node:os";
|
|
33286
|
-
import { dirname as dirname16, join as join15, resolve as
|
|
33514
|
+
import { dirname as dirname16, join as join15, resolve as resolve17 } from "node:path";
|
|
33287
33515
|
async function ensureGitignore(configDir) {
|
|
33288
33516
|
const gitignorePath = join15(configDir, ".gitignore");
|
|
33289
33517
|
try {
|
|
@@ -33383,8 +33611,8 @@ function migrateLegacyWindowsConfig() {
|
|
|
33383
33611
|
}
|
|
33384
33612
|
}
|
|
33385
33613
|
function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
33386
|
-
const standard =
|
|
33387
|
-
const legacy =
|
|
33614
|
+
const standard = resolve17(newPath);
|
|
33615
|
+
const legacy = resolve17(legacyPath);
|
|
33388
33616
|
if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
|
|
33389
33617
|
const standardPointer = existsSync4(accountStorePointerPath(standard));
|
|
33390
33618
|
const legacyPointer = existsSync4(accountStorePointerPath(legacy));
|
|
@@ -33406,7 +33634,7 @@ function getStoragePathWithMigration() {
|
|
|
33406
33634
|
"antigravity-accounts.json"
|
|
33407
33635
|
);
|
|
33408
33636
|
const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
|
|
33409
|
-
if (
|
|
33637
|
+
if (resolve17(anchored).toLowerCase() !== resolve17(newPath).toLowerCase() && !existsSync4(accountStorePointerPath(resolve17(anchored)))) {
|
|
33410
33638
|
log6.info("Using legacy Windows config path (migration failed)", {
|
|
33411
33639
|
legacyPath,
|
|
33412
33640
|
newPath
|
|
@@ -33423,7 +33651,7 @@ function accountFileForVault(configDir = getConfigDir()) {
|
|
|
33423
33651
|
const configured = join15(configDir, "antigravity-accounts.json");
|
|
33424
33652
|
if (process.platform !== "win32") return configured;
|
|
33425
33653
|
const legacyDir = getLegacyWindowsConfigDir();
|
|
33426
|
-
if (
|
|
33654
|
+
if (resolve17(configDir).toLowerCase() === resolve17(legacyDir).toLowerCase())
|
|
33427
33655
|
return configured;
|
|
33428
33656
|
const configuredVault = join15(configDir, "antigravity-auth-vault");
|
|
33429
33657
|
const legacyVault = join15(legacyDir, "antigravity-auth-vault");
|
|
@@ -33454,7 +33682,7 @@ function getStoragePath() {
|
|
|
33454
33682
|
}
|
|
33455
33683
|
async function assertLegacyPoolInUse(legacyPath) {
|
|
33456
33684
|
try {
|
|
33457
|
-
await assertLegacyAccountStorageWritable(
|
|
33685
|
+
await assertLegacyAccountStorageWritable(resolve17(legacyPath));
|
|
33458
33686
|
} catch (error) {
|
|
33459
33687
|
throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
|
|
33460
33688
|
}
|
|
@@ -33474,7 +33702,7 @@ function refusalMessage2(admission) {
|
|
|
33474
33702
|
async function bindingOf(options) {
|
|
33475
33703
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
33476
33704
|
const now = options.now ?? (() => Date.now());
|
|
33477
|
-
const legacyPath =
|
|
33705
|
+
const legacyPath = resolve17(options.legacyPath ?? getStoragePath());
|
|
33478
33706
|
return {
|
|
33479
33707
|
legacyPath,
|
|
33480
33708
|
now,
|
|
@@ -33543,7 +33771,7 @@ async function openAccountStore(options) {
|
|
|
33543
33771
|
async function initializeFreshAccountStoreFor(modules, options = {}) {
|
|
33544
33772
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
33545
33773
|
return initializeFreshAccountStore(modules, {
|
|
33546
|
-
legacyPath:
|
|
33774
|
+
legacyPath: resolve17(options.legacyPath ?? getStoragePath()),
|
|
33547
33775
|
now: options.now ?? (() => Date.now())
|
|
33548
33776
|
});
|
|
33549
33777
|
}
|
|
@@ -33621,12 +33849,12 @@ var init_storage = __esm({
|
|
|
33621
33849
|
import { createHash as createHash12 } from "node:crypto";
|
|
33622
33850
|
import { existsSync as existsSync5, promises as fs2, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
|
|
33623
33851
|
import { homedir as homedir5 } from "node:os";
|
|
33624
|
-
import { dirname as dirname17, join as join16, resolve as
|
|
33852
|
+
import { dirname as dirname17, join as join16, resolve as resolve18 } from "node:path";
|
|
33625
33853
|
function configDirIdentity(path5) {
|
|
33626
33854
|
try {
|
|
33627
33855
|
return realpathSync2.native(path5);
|
|
33628
33856
|
} catch {
|
|
33629
|
-
return
|
|
33857
|
+
return resolve18(path5);
|
|
33630
33858
|
}
|
|
33631
33859
|
}
|
|
33632
33860
|
function decisionKey(location) {
|
|
@@ -34079,13 +34307,13 @@ function closeDebugStream(state) {
|
|
|
34079
34307
|
state.logWriter = () => {
|
|
34080
34308
|
};
|
|
34081
34309
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34082
|
-
return new Promise((
|
|
34083
|
-
current.once("close", () =>
|
|
34084
|
-
current.once("error", () =>
|
|
34310
|
+
return new Promise((resolve30) => {
|
|
34311
|
+
current.once("close", () => resolve30());
|
|
34312
|
+
current.once("error", () => resolve30());
|
|
34085
34313
|
try {
|
|
34086
34314
|
current.end();
|
|
34087
34315
|
} catch {
|
|
34088
|
-
|
|
34316
|
+
resolve30();
|
|
34089
34317
|
}
|
|
34090
34318
|
});
|
|
34091
34319
|
}
|
|
@@ -34350,13 +34578,13 @@ function closeDebugLog() {
|
|
|
34350
34578
|
if (!state || !current) return Promise.resolve();
|
|
34351
34579
|
state.logStream = null;
|
|
34352
34580
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
34353
|
-
return new Promise((
|
|
34354
|
-
current.once("close", () =>
|
|
34355
|
-
current.once("error", () =>
|
|
34581
|
+
return new Promise((resolve30) => {
|
|
34582
|
+
current.once("close", () => resolve30());
|
|
34583
|
+
current.once("error", () => resolve30());
|
|
34356
34584
|
try {
|
|
34357
34585
|
current.end();
|
|
34358
34586
|
} catch {
|
|
34359
|
-
|
|
34587
|
+
resolve30();
|
|
34360
34588
|
}
|
|
34361
34589
|
});
|
|
34362
34590
|
}
|
|
@@ -34473,6 +34701,7 @@ function createLocationLogger(options) {
|
|
|
34473
34701
|
const engine = createLoggerInstance2({
|
|
34474
34702
|
level: () => configuredLevel,
|
|
34475
34703
|
extraSecretKeys: isProviderSecretKey,
|
|
34704
|
+
extraValuePatterns: OAUTH_REDIRECT_VALUE_PATTERNS,
|
|
34476
34705
|
captureSink: ({ channel: channel3, level, message, data }) => {
|
|
34477
34706
|
const extra = data !== null && typeof data === "object" && !Array.isArray(data) ? Object.fromEntries(Object.entries(data)) : void 0;
|
|
34478
34707
|
emit({
|
|
@@ -34778,14 +35007,16 @@ async function registerOpenCode2AuthMethods(ctx, options) {
|
|
|
34778
35007
|
init_dist();
|
|
34779
35008
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
34780
35009
|
|
|
34781
|
-
// src/ga/server/pool-login.ts
|
|
34782
|
-
init_dist();
|
|
34783
|
-
|
|
34784
35010
|
// src/auth-method-labels.ts
|
|
34785
35011
|
var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
|
|
35012
|
+
var OPENCODE2_POOL_PASTE_AUTH_LABEL = "Google (antigravity-auth pool, paste redirect URL)";
|
|
35013
|
+
var GA_POOL_PASTE_PROMPT = "Paste the redirect URL from your browser's address bar";
|
|
34786
35014
|
var OPENCODE2_VAULT_AUTH_LABEL = "Use approved Antigravity vault";
|
|
34787
35015
|
var OPENCODE2_POOL_RECONNECT_LABEL = "Use existing local Antigravity pool";
|
|
34788
35016
|
|
|
35017
|
+
// src/ga/server/pool-login.ts
|
|
35018
|
+
init_dist();
|
|
35019
|
+
|
|
34789
35020
|
// src/plugin/server.ts
|
|
34790
35021
|
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
34791
35022
|
import { createServer } from "node:http";
|
|
@@ -34866,12 +35097,12 @@ async function startOAuthListener({
|
|
|
34866
35097
|
let resolveCallback;
|
|
34867
35098
|
let rejectCallback;
|
|
34868
35099
|
let timeoutHandle;
|
|
34869
|
-
const callbackPromise = new Promise((
|
|
35100
|
+
const callbackPromise = new Promise((resolve30, reject) => {
|
|
34870
35101
|
resolveCallback = (url) => {
|
|
34871
35102
|
if (settled) return;
|
|
34872
35103
|
settled = true;
|
|
34873
35104
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
34874
|
-
|
|
35105
|
+
resolve30(url);
|
|
34875
35106
|
};
|
|
34876
35107
|
rejectCallback = (error) => {
|
|
34877
35108
|
if (settled) return;
|
|
@@ -35030,7 +35261,7 @@ async function startOAuthListener({
|
|
|
35030
35261
|
});
|
|
35031
35262
|
});
|
|
35032
35263
|
const bindAddress = getBindAddress();
|
|
35033
|
-
await new Promise((
|
|
35264
|
+
await new Promise((resolve30, reject) => {
|
|
35034
35265
|
const handleError = (error) => {
|
|
35035
35266
|
server.off("error", handleError);
|
|
35036
35267
|
if (error.code === "EADDRINUSE") {
|
|
@@ -35046,7 +35277,7 @@ async function startOAuthListener({
|
|
|
35046
35277
|
server.once("error", handleError);
|
|
35047
35278
|
server.listen(port, bindAddress, () => {
|
|
35048
35279
|
server.off("error", handleError);
|
|
35049
|
-
|
|
35280
|
+
resolve30();
|
|
35050
35281
|
});
|
|
35051
35282
|
});
|
|
35052
35283
|
server.on("error", (error) => {
|
|
@@ -35054,7 +35285,7 @@ async function startOAuthListener({
|
|
|
35054
35285
|
});
|
|
35055
35286
|
return {
|
|
35056
35287
|
waitForCallback: () => callbackPromise,
|
|
35057
|
-
close: () => new Promise((
|
|
35288
|
+
close: () => new Promise((resolve30, reject) => {
|
|
35058
35289
|
server.close((error) => {
|
|
35059
35290
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
35060
35291
|
reject(error);
|
|
@@ -35063,7 +35294,7 @@ async function startOAuthListener({
|
|
|
35063
35294
|
if (!settled) {
|
|
35064
35295
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
35065
35296
|
}
|
|
35066
|
-
|
|
35297
|
+
resolve30();
|
|
35067
35298
|
});
|
|
35068
35299
|
})
|
|
35069
35300
|
};
|
|
@@ -35075,14 +35306,15 @@ async function startOAuthListener({
|
|
|
35075
35306
|
|
|
35076
35307
|
// src/ga/server/pool-login.ts
|
|
35077
35308
|
var GA_POOL_METHOD_ID = "antigravity-auth-pool-browser";
|
|
35309
|
+
var GA_POOL_PASTE_METHOD_ID = "antigravity-auth-pool-paste";
|
|
35078
35310
|
var GA_POOL_RECONNECT_METHOD_ID = "antigravity-auth-pool-reconnect";
|
|
35079
35311
|
var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
|
|
35080
35312
|
function abortable(pending, signal) {
|
|
35081
|
-
return new Promise((
|
|
35313
|
+
return new Promise((resolve30, reject) => {
|
|
35082
35314
|
const abort = () => reject(signal.reason);
|
|
35083
35315
|
if (signal.aborted) abort();
|
|
35084
35316
|
else signal.addEventListener("abort", abort, { once: true });
|
|
35085
|
-
void pending.then(
|
|
35317
|
+
void pending.then(resolve30, reject).finally(() => {
|
|
35086
35318
|
signal.removeEventListener("abort", abort);
|
|
35087
35319
|
});
|
|
35088
35320
|
});
|
|
@@ -35116,89 +35348,154 @@ function createGaPoolLogin(input2) {
|
|
|
35116
35348
|
listeners.delete(listener);
|
|
35117
35349
|
}
|
|
35118
35350
|
};
|
|
35119
|
-
const
|
|
35120
|
-
|
|
35121
|
-
|
|
35122
|
-
|
|
35123
|
-
|
|
35124
|
-
|
|
35125
|
-
|
|
35126
|
-
|
|
35351
|
+
const start = (listen = true) => track(
|
|
35352
|
+
(async () => {
|
|
35353
|
+
await admit2();
|
|
35354
|
+
const authorization = await (async () => {
|
|
35355
|
+
try {
|
|
35356
|
+
return await abortable(
|
|
35357
|
+
(input2.oauth?.authorize ?? authorizeAntigravity)(),
|
|
35358
|
+
shutdown.signal
|
|
35359
|
+
);
|
|
35360
|
+
} catch {
|
|
35361
|
+
throw new Error(LOGIN_FAILED);
|
|
35362
|
+
}
|
|
35363
|
+
})();
|
|
35364
|
+
await admit2();
|
|
35365
|
+
const state = new URL(authorization.url).searchParams.get("state");
|
|
35366
|
+
if (!state) throw new Error(LOGIN_FAILED);
|
|
35367
|
+
const redirect = new URL(ANTIGRAVITY_REDIRECT_URI);
|
|
35368
|
+
const parse3 = (value) => {
|
|
35369
|
+
try {
|
|
35370
|
+
const url = new URL(value);
|
|
35371
|
+
const code3 = url.searchParams.get("code");
|
|
35372
|
+
if (url.origin !== redirect.origin || url.pathname !== redirect.pathname || url.username || url.password || url.hash || url.searchParams.has("error") || url.searchParams.getAll("state").length !== 1 || url.searchParams.get("state") !== state || url.searchParams.getAll("code").length !== 1 || !code3)
|
|
35373
|
+
throw new Error(LOGIN_FAILED);
|
|
35374
|
+
return code3;
|
|
35375
|
+
} catch {
|
|
35376
|
+
throw new Error(LOGIN_FAILED);
|
|
35377
|
+
}
|
|
35378
|
+
};
|
|
35379
|
+
let listener;
|
|
35380
|
+
const code2 = Promise.withResolvers();
|
|
35381
|
+
let claimed = false;
|
|
35382
|
+
const claim = (value) => {
|
|
35383
|
+
if (claimed) throw new Error(LOGIN_FAILED);
|
|
35384
|
+
claimed = true;
|
|
35385
|
+
code2.resolve(value);
|
|
35386
|
+
};
|
|
35387
|
+
const waitForCode = input2.oauth?.waitForCode;
|
|
35388
|
+
if (listen && waitForCode) {
|
|
35389
|
+
void Promise.resolve().then(() => waitForCode(state)).then(claim, code2.reject).catch(() => {
|
|
35390
|
+
});
|
|
35391
|
+
} else if (listen) {
|
|
35392
|
+
listener = await startOAuthListener();
|
|
35393
|
+
listeners.add(listener);
|
|
35394
|
+
void listener.waitForCallback().then((url) => claim(parse3(url.href)), code2.reject).catch(code2.reject);
|
|
35395
|
+
}
|
|
35396
|
+
void code2.promise.catch(() => {
|
|
35397
|
+
});
|
|
35398
|
+
try {
|
|
35127
35399
|
await admit2();
|
|
35128
|
-
|
|
35400
|
+
} catch (error) {
|
|
35401
|
+
if (listener) await close(listener);
|
|
35402
|
+
throw error;
|
|
35403
|
+
}
|
|
35404
|
+
const ownedListener = listener;
|
|
35405
|
+
const cancellation = new AbortController();
|
|
35406
|
+
const signal = AbortSignal.any([shutdown.signal, cancellation.signal]);
|
|
35407
|
+
const admitAttempt = async () => {
|
|
35408
|
+
signal.throwIfAborted();
|
|
35409
|
+
await admit2();
|
|
35410
|
+
signal.throwIfAborted();
|
|
35411
|
+
};
|
|
35412
|
+
const timeout = setTimeout(
|
|
35413
|
+
() => code2.reject(new Error(LOGIN_FAILED)),
|
|
35414
|
+
5 * 60 * 1e3
|
|
35415
|
+
);
|
|
35416
|
+
timeout.unref?.();
|
|
35417
|
+
const callback = track(
|
|
35418
|
+
(async () => {
|
|
35129
35419
|
try {
|
|
35130
|
-
|
|
35131
|
-
|
|
35132
|
-
|
|
35420
|
+
await admitAttempt();
|
|
35421
|
+
const value = await abortable(code2.promise, signal);
|
|
35422
|
+
if (ownedListener) await close(ownedListener);
|
|
35423
|
+
await admitAttempt();
|
|
35424
|
+
const result = await abortable(
|
|
35425
|
+
(input2.oauth?.exchange ?? exchangeAntigravity)(value, state, {
|
|
35426
|
+
signal,
|
|
35427
|
+
admit: admitAttempt
|
|
35428
|
+
}),
|
|
35429
|
+
signal
|
|
35133
35430
|
);
|
|
35431
|
+
await admitAttempt();
|
|
35432
|
+
if (result.type !== "success") throw new Error(LOGIN_FAILED);
|
|
35433
|
+
return result;
|
|
35134
35434
|
} catch {
|
|
35135
35435
|
throw new Error(LOGIN_FAILED);
|
|
35436
|
+
} finally {
|
|
35437
|
+
claimed = true;
|
|
35438
|
+
clearTimeout(timeout);
|
|
35439
|
+
if (ownedListener) await close(ownedListener);
|
|
35136
35440
|
}
|
|
35137
|
-
})()
|
|
35138
|
-
|
|
35139
|
-
|
|
35140
|
-
|
|
35141
|
-
|
|
35142
|
-
|
|
35143
|
-
|
|
35144
|
-
|
|
35145
|
-
|
|
35146
|
-
|
|
35147
|
-
|
|
35148
|
-
|
|
35149
|
-
|
|
35150
|
-
|
|
35151
|
-
|
|
35152
|
-
|
|
35153
|
-
|
|
35154
|
-
|
|
35155
|
-
});
|
|
35156
|
-
}
|
|
35157
|
-
void code2.catch(() => {
|
|
35158
|
-
});
|
|
35159
|
-
try {
|
|
35160
|
-
await admit2();
|
|
35161
|
-
} catch (error) {
|
|
35162
|
-
if (listener) await close(listener);
|
|
35163
|
-
throw error;
|
|
35441
|
+
})()
|
|
35442
|
+
);
|
|
35443
|
+
void callback.catch(() => {
|
|
35444
|
+
});
|
|
35445
|
+
return {
|
|
35446
|
+
url: authorization.url,
|
|
35447
|
+
completion: callback,
|
|
35448
|
+
async paste(value) {
|
|
35449
|
+
await admitAttempt();
|
|
35450
|
+
if (!value.trim()) return callback;
|
|
35451
|
+
claim(parse3(value));
|
|
35452
|
+
return callback;
|
|
35453
|
+
},
|
|
35454
|
+
async cancel() {
|
|
35455
|
+
claimed = true;
|
|
35456
|
+
cancellation.abort(new Error(LOGIN_FAILED));
|
|
35457
|
+
code2.reject(new Error(LOGIN_FAILED));
|
|
35458
|
+
if (ownedListener) await close(ownedListener);
|
|
35164
35459
|
}
|
|
35165
|
-
|
|
35166
|
-
|
|
35167
|
-
|
|
35168
|
-
|
|
35169
|
-
|
|
35170
|
-
|
|
35171
|
-
|
|
35172
|
-
|
|
35173
|
-
|
|
35174
|
-
|
|
35175
|
-
|
|
35176
|
-
|
|
35177
|
-
|
|
35178
|
-
|
|
35179
|
-
|
|
35180
|
-
|
|
35181
|
-
|
|
35182
|
-
|
|
35183
|
-
|
|
35184
|
-
|
|
35185
|
-
|
|
35186
|
-
|
|
35187
|
-
|
|
35188
|
-
|
|
35189
|
-
|
|
35190
|
-
|
|
35191
|
-
|
|
35192
|
-
|
|
35193
|
-
|
|
35194
|
-
|
|
35195
|
-
|
|
35196
|
-
|
|
35197
|
-
}
|
|
35198
|
-
|
|
35460
|
+
};
|
|
35461
|
+
})()
|
|
35462
|
+
);
|
|
35463
|
+
const method = {
|
|
35464
|
+
method: {
|
|
35465
|
+
id: GA_POOL_METHOD_ID,
|
|
35466
|
+
type: "oauth",
|
|
35467
|
+
label: OPENCODE2_POOL_AUTH_LABEL
|
|
35468
|
+
},
|
|
35469
|
+
async authorize() {
|
|
35470
|
+
const attempt = await start();
|
|
35471
|
+
return {
|
|
35472
|
+
mode: "auto",
|
|
35473
|
+
url: attempt.url,
|
|
35474
|
+
instructions: "Complete Google sign-in in your browser.",
|
|
35475
|
+
callback: attempt.completion
|
|
35476
|
+
};
|
|
35477
|
+
}
|
|
35478
|
+
};
|
|
35479
|
+
const pasteMethod = {
|
|
35480
|
+
method: {
|
|
35481
|
+
id: GA_POOL_PASTE_METHOD_ID,
|
|
35482
|
+
type: "oauth",
|
|
35483
|
+
label: OPENCODE2_POOL_PASTE_AUTH_LABEL
|
|
35484
|
+
},
|
|
35485
|
+
async authorize() {
|
|
35486
|
+
const attempt = await start(false);
|
|
35487
|
+
return {
|
|
35488
|
+
mode: "code",
|
|
35489
|
+
url: attempt.url,
|
|
35490
|
+
instructions: GA_POOL_PASTE_PROMPT,
|
|
35491
|
+
callback: (value) => attempt.paste(value)
|
|
35492
|
+
};
|
|
35493
|
+
}
|
|
35199
35494
|
};
|
|
35200
35495
|
return {
|
|
35201
35496
|
method,
|
|
35497
|
+
pasteMethod,
|
|
35498
|
+
start,
|
|
35202
35499
|
connectExisting: () => track(
|
|
35203
35500
|
(async () => {
|
|
35204
35501
|
let stage = "initial-admission";
|
|
@@ -36335,7 +36632,7 @@ init_runtime_paths();
|
|
|
36335
36632
|
init_logger4();
|
|
36336
36633
|
import { existsSync as existsSync6, readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
36337
36634
|
import { homedir as homedir6 } from "node:os";
|
|
36338
|
-
import { basename as basename5, dirname as dirname18, join as join18, resolve as
|
|
36635
|
+
import { basename as basename5, dirname as dirname18, join as join18, resolve as resolve19 } from "node:path";
|
|
36339
36636
|
|
|
36340
36637
|
// src/plugin/config/schema.ts
|
|
36341
36638
|
import { z } from "zod";
|
|
@@ -36909,7 +37206,7 @@ function createLocationConfig(directory, options) {
|
|
|
36909
37206
|
};
|
|
36910
37207
|
}
|
|
36911
37208
|
function canonicalizeOwnedPath(path5) {
|
|
36912
|
-
const absolute =
|
|
37209
|
+
const absolute = resolve19(path5);
|
|
36913
37210
|
const missing = [];
|
|
36914
37211
|
let current = absolute;
|
|
36915
37212
|
for (; ; ) {
|
|
@@ -37288,7 +37585,7 @@ function createStoreAccountLimits(input2) {
|
|
|
37288
37585
|
|
|
37289
37586
|
// src/plugin/ga-shared-vault-custody.ts
|
|
37290
37587
|
init_dist();
|
|
37291
|
-
import { resolve as
|
|
37588
|
+
import { resolve as resolve20 } from "node:path";
|
|
37292
37589
|
|
|
37293
37590
|
// src/sidebar-state.ts
|
|
37294
37591
|
init_atomic_write();
|
|
@@ -37704,7 +38001,7 @@ function drainSidebarWrites() {
|
|
|
37704
38001
|
return sidebarWriteChain;
|
|
37705
38002
|
}
|
|
37706
38003
|
async function sleep3(ms) {
|
|
37707
|
-
await new Promise((
|
|
38004
|
+
await new Promise((resolve30) => setTimeout(resolve30, ms));
|
|
37708
38005
|
}
|
|
37709
38006
|
async function acquireSidebarLockWithRetry(stateFile) {
|
|
37710
38007
|
const start = Date.now();
|
|
@@ -38263,14 +38560,14 @@ var LocalQuotaGrantStaleError = class extends Error {
|
|
|
38263
38560
|
name = "LocalQuotaGrantStaleError";
|
|
38264
38561
|
};
|
|
38265
38562
|
function untilQuotaAborted(pending, signal) {
|
|
38266
|
-
return new Promise((
|
|
38563
|
+
return new Promise((resolve30, reject) => {
|
|
38267
38564
|
const abort = () => reject(signal.reason);
|
|
38268
38565
|
if (signal.aborted) abort();
|
|
38269
38566
|
else signal.addEventListener("abort", abort, { once: true });
|
|
38270
38567
|
void pending.then(
|
|
38271
38568
|
(value) => {
|
|
38272
38569
|
signal.removeEventListener("abort", abort);
|
|
38273
|
-
|
|
38570
|
+
resolve30(value);
|
|
38274
38571
|
},
|
|
38275
38572
|
(error) => {
|
|
38276
38573
|
signal.removeEventListener("abort", abort);
|
|
@@ -39165,7 +39462,7 @@ init_vault_request_credentials();
|
|
|
39165
39462
|
init_vault_custody();
|
|
39166
39463
|
var shared3 = /* @__PURE__ */ new Map();
|
|
39167
39464
|
function acquireGaVaultCustody(options) {
|
|
39168
|
-
const key = options.layoutRefusal === void 0 ?
|
|
39465
|
+
const key = options.layoutRefusal === void 0 ? resolve20(options.vaultDir) : `unsettled\0${resolve20(options.vaultDir)}`;
|
|
39169
39466
|
let entry = shared3.get(key);
|
|
39170
39467
|
if (!entry) {
|
|
39171
39468
|
const leases = /* @__PURE__ */ new Set();
|
|
@@ -43705,7 +44002,7 @@ function stripUnsupportedAntigravityFields(payload) {
|
|
|
43705
44002
|
}
|
|
43706
44003
|
}
|
|
43707
44004
|
function configureAntigravityToolCalling(payload, wireModel) {
|
|
43708
|
-
if (isGeminiArgonModel(wireModel) || !Array.isArray(payload.tools) || payload.tools.length === 0) {
|
|
44005
|
+
if (isGeminiArgonModel(wireModel) || isGeminiCarbonModel(wireModel) || !Array.isArray(payload.tools) || payload.tools.length === 0) {
|
|
43709
44006
|
delete payload.toolConfig;
|
|
43710
44007
|
return;
|
|
43711
44008
|
}
|
|
@@ -44328,7 +44625,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
44328
44625
|
`[ThinkingResolution] rawModel=${rawModel} resolvedModel=${effectiveModel} resolvedTier=${tierThinkingLevel ?? "none"} variantLevel=${variantConfig?.thinkingLevel ?? "none"} variantBudget=${variantConfig?.thinkingBudget ?? "none"} providerOptions.google=${JSON.stringify(requestPayload.providerOptions?.google ?? null)} generationConfig.thinkingConfig=${JSON.stringify(rawGenerationConfig?.thinkingConfig ?? null)}`
|
|
44329
44626
|
);
|
|
44330
44627
|
delete requestPayload.providerOptions;
|
|
44331
|
-
if (variantConfig?.thinkingLevel && (isGemini3 || isGeminiArgonModel(effectiveModel) || getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking)) {
|
|
44628
|
+
if (variantConfig?.thinkingLevel && (isGemini3 || isGeminiArgonModel(effectiveModel) || isGeminiCarbonModel(effectiveModel) || getAgyNativeModel(effectiveModel)?.supportsAdaptiveThinking)) {
|
|
44332
44629
|
const variantModelBase = rawModel.replace(/-preview-customtools$/i, "").replace(/-preview$/i, "").replace(/-(minimal|low|medium|high)$/i, "");
|
|
44333
44630
|
const variantResolved = resolveAntigravityModel(
|
|
44334
44631
|
`${variantModelBase}-${variantConfig.thinkingLevel}`
|
|
@@ -45237,7 +45534,7 @@ function transformAntigravityResponse(...args) {
|
|
|
45237
45534
|
}
|
|
45238
45535
|
|
|
45239
45536
|
// src/plugin/session-context.ts
|
|
45240
|
-
import { resolve as
|
|
45537
|
+
import { resolve as resolve21 } from "node:path";
|
|
45241
45538
|
import { pathToFileURL } from "node:url";
|
|
45242
45539
|
var FALLBACK_SESSION_KEY = "__default__";
|
|
45243
45540
|
function extractOpenCodeSessionIdentity(headers) {
|
|
@@ -45251,7 +45548,7 @@ var AgySessionRegistry = class {
|
|
|
45251
45548
|
requestSessions;
|
|
45252
45549
|
parentSessionIds = /* @__PURE__ */ new Map();
|
|
45253
45550
|
constructor(directory, options = {}) {
|
|
45254
|
-
const workspaceUri = directory ? pathToFileURL(
|
|
45551
|
+
const workspaceUri = directory ? pathToFileURL(resolve21(directory)).href : "";
|
|
45255
45552
|
this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
|
|
45256
45553
|
}
|
|
45257
45554
|
getOrCreate(identity3) {
|
|
@@ -45413,10 +45710,10 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
45413
45710
|
cancellation.release();
|
|
45414
45711
|
throw error;
|
|
45415
45712
|
}
|
|
45416
|
-
let
|
|
45713
|
+
let resolve30 = () => {
|
|
45417
45714
|
};
|
|
45418
45715
|
const settled = new Promise((done) => {
|
|
45419
|
-
|
|
45716
|
+
resolve30 = done;
|
|
45420
45717
|
});
|
|
45421
45718
|
let stopping = false;
|
|
45422
45719
|
let finished = false;
|
|
@@ -45426,7 +45723,7 @@ async function retainResponseLifetime(response, cancellation) {
|
|
|
45426
45723
|
finished = true;
|
|
45427
45724
|
cancellation.signal.removeEventListener("abort", abort);
|
|
45428
45725
|
cancellation.release();
|
|
45429
|
-
|
|
45726
|
+
resolve30();
|
|
45430
45727
|
};
|
|
45431
45728
|
const abort = () => {
|
|
45432
45729
|
if (finished || stopping) return;
|
|
@@ -45495,10 +45792,72 @@ function routingHandle(sessionId) {
|
|
|
45495
45792
|
return typeof handle === "object" && handle !== null ? handle : void 0;
|
|
45496
45793
|
}
|
|
45497
45794
|
|
|
45795
|
+
// src/common-auth-embedded/routing-accessor/cache-policy.js
|
|
45796
|
+
var CACHE_WARM_STOP_REASONS = [
|
|
45797
|
+
"cost-cap",
|
|
45798
|
+
"count-cap",
|
|
45799
|
+
"outside-hours",
|
|
45800
|
+
"session-ended",
|
|
45801
|
+
"unsupported"
|
|
45802
|
+
];
|
|
45803
|
+
function isCacheWarmStopReason(value) {
|
|
45804
|
+
return CACHE_WARM_STOP_REASONS.some((reason) => reason === value);
|
|
45805
|
+
}
|
|
45806
|
+
|
|
45498
45807
|
// src/common-auth-embedded/routing-accessor/index.js
|
|
45499
45808
|
function isObject2(value) {
|
|
45500
45809
|
return typeof value === "object" && value !== null;
|
|
45501
45810
|
}
|
|
45811
|
+
function isNonEmptyString(value) {
|
|
45812
|
+
return typeof value === "string" && value.length > 0;
|
|
45813
|
+
}
|
|
45814
|
+
function billingCache(value) {
|
|
45815
|
+
if (!isObject2(value) || Array.isArray(value))
|
|
45816
|
+
return;
|
|
45817
|
+
const { ttlMs, implicit, warming } = value;
|
|
45818
|
+
const cache = {};
|
|
45819
|
+
if (!(ttlMs !== void 0 && implicit !== void 0)) {
|
|
45820
|
+
if (typeof ttlMs === "number" && Number.isSafeInteger(ttlMs) && ttlMs > 0) {
|
|
45821
|
+
cache.ttl_ms = ttlMs;
|
|
45822
|
+
} else if (implicit === true) {
|
|
45823
|
+
cache.implicit = true;
|
|
45824
|
+
}
|
|
45825
|
+
}
|
|
45826
|
+
if (isObject2(warming) && !Array.isArray(warming)) {
|
|
45827
|
+
const { on, stopReason } = warming;
|
|
45828
|
+
if (typeof on === "boolean") {
|
|
45829
|
+
cache.warming = {
|
|
45830
|
+
on,
|
|
45831
|
+
...!on && isCacheWarmStopReason(stopReason) ? { stop_reason: stopReason } : {}
|
|
45832
|
+
};
|
|
45833
|
+
}
|
|
45834
|
+
}
|
|
45835
|
+
return Object.keys(cache).length > 0 ? cache : void 0;
|
|
45836
|
+
}
|
|
45837
|
+
function billingUsage(value) {
|
|
45838
|
+
if (!isObject2(value) || Array.isArray(value))
|
|
45839
|
+
return;
|
|
45840
|
+
const usage = {};
|
|
45841
|
+
for (const [inputKey, payloadKey] of [
|
|
45842
|
+
["input", "input"],
|
|
45843
|
+
["output", "output"],
|
|
45844
|
+
["cacheRead", "cache_read"],
|
|
45845
|
+
["cacheWrite", "cache_write"],
|
|
45846
|
+
["cacheWrite5m", "cache_write_5m"],
|
|
45847
|
+
["cacheWrite1h", "cache_write_1h"],
|
|
45848
|
+
["reasoning", "reasoning"]
|
|
45849
|
+
]) {
|
|
45850
|
+
const count3 = value[inputKey];
|
|
45851
|
+
if (typeof count3 === "number" && Number.isSafeInteger(count3) && count3 >= 0) {
|
|
45852
|
+
usage[payloadKey] = count3;
|
|
45853
|
+
}
|
|
45854
|
+
}
|
|
45855
|
+
const reasoningIncludedInOutput = value.reasoningIncludedInOutput;
|
|
45856
|
+
if (typeof reasoningIncludedInOutput === "boolean") {
|
|
45857
|
+
usage.reasoning_included_in_output = reasoningIncludedInOutput;
|
|
45858
|
+
}
|
|
45859
|
+
return Object.keys(usage).length > 0 ? usage : void 0;
|
|
45860
|
+
}
|
|
45502
45861
|
function selectionFor(answer, candidates) {
|
|
45503
45862
|
if (!isObject2(answer))
|
|
45504
45863
|
return void 0;
|
|
@@ -45530,8 +45889,8 @@ async function askRouting(input2) {
|
|
|
45530
45889
|
return void 0;
|
|
45531
45890
|
const requested = input2.deadlineMs ?? 500;
|
|
45532
45891
|
const deadlineMs = Number.isNaN(requested) ? 500 : Math.min(2e3, Math.max(1, requested));
|
|
45533
|
-
const expired = new Promise((
|
|
45534
|
-
timer = setTimeout(() =>
|
|
45892
|
+
const expired = new Promise((resolve30) => {
|
|
45893
|
+
timer = setTimeout(() => resolve30(void 0), deadlineMs);
|
|
45535
45894
|
timer.unref();
|
|
45536
45895
|
});
|
|
45537
45896
|
const request2 = {
|
|
@@ -45564,6 +45923,47 @@ function reportRouting(input2) {
|
|
|
45564
45923
|
let payload;
|
|
45565
45924
|
if ("kind" in input2) {
|
|
45566
45925
|
switch (input2.kind) {
|
|
45926
|
+
case "billing": {
|
|
45927
|
+
const { attemptId, requestKind, credentialId, provider: provider2, model, outcome, accountId, providerRequestId, providerResponseId, userMessageId, status, attempt, chargeBasis, usage: inputUsage, usageByModel: inputUsageByModel, cache: inputCache } = input2;
|
|
45928
|
+
if (!isNonEmptyString(attemptId) || !isNonEmptyString(credentialId) || !isNonEmptyString(provider2) || !isNonEmptyString(model) || requestKind !== "primary" && requestKind !== "title" && requestKind !== "compaction" && requestKind !== "generate" && requestKind !== "keep_warm" && requestKind !== "prime" || outcome !== "completed" && outcome !== "cut" && outcome !== "failed")
|
|
45929
|
+
return;
|
|
45930
|
+
const usage = billingUsage(inputUsage);
|
|
45931
|
+
const cache = billingCache(inputCache);
|
|
45932
|
+
const usageByModel = [];
|
|
45933
|
+
if (Array.isArray(inputUsageByModel)) {
|
|
45934
|
+
for (const entry of inputUsageByModel) {
|
|
45935
|
+
if (!isObject2(entry) || Array.isArray(entry))
|
|
45936
|
+
continue;
|
|
45937
|
+
const modelUsed = entry.modelUsed;
|
|
45938
|
+
if (!isNonEmptyString(modelUsed))
|
|
45939
|
+
continue;
|
|
45940
|
+
const modelUsage = billingUsage(entry.usage);
|
|
45941
|
+
if (!modelUsage)
|
|
45942
|
+
continue;
|
|
45943
|
+
usageByModel.push({ model_used: modelUsed, usage: modelUsage });
|
|
45944
|
+
}
|
|
45945
|
+
}
|
|
45946
|
+
payload = {
|
|
45947
|
+
kind: "billing",
|
|
45948
|
+
attempt_id: attemptId,
|
|
45949
|
+
request_kind: requestKind,
|
|
45950
|
+
credential_id: credentialId,
|
|
45951
|
+
provider: provider2,
|
|
45952
|
+
model,
|
|
45953
|
+
outcome,
|
|
45954
|
+
...isNonEmptyString(accountId) ? { account_id: accountId } : {},
|
|
45955
|
+
...isNonEmptyString(providerRequestId) ? { provider_request_id: providerRequestId } : {},
|
|
45956
|
+
...isNonEmptyString(providerResponseId) ? { provider_response_id: providerResponseId } : {},
|
|
45957
|
+
...isNonEmptyString(userMessageId) ? { user_message_id: userMessageId } : {},
|
|
45958
|
+
...typeof status === "number" && Number.isInteger(status) && status >= 0 ? { status } : {},
|
|
45959
|
+
...typeof attempt === "number" && Number.isInteger(attempt) && attempt >= 1 ? { attempt } : {},
|
|
45960
|
+
...chargeBasis === "subscription_included" || chargeBasis === "metered_api" ? { charge_basis: chargeBasis } : {},
|
|
45961
|
+
...usage ? { usage } : {},
|
|
45962
|
+
...usageByModel.length > 0 ? { usage_by_model: usageByModel } : {},
|
|
45963
|
+
...cache ? { cache } : {}
|
|
45964
|
+
};
|
|
45965
|
+
break;
|
|
45966
|
+
}
|
|
45567
45967
|
case "turn_notes_supported": {
|
|
45568
45968
|
const { model, supported } = input2;
|
|
45569
45969
|
if (typeof model !== "string" || model.length === 0 || typeof supported !== "boolean")
|
|
@@ -46103,8 +46503,8 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
46103
46503
|
let running = false;
|
|
46104
46504
|
let resolveCompletion = () => {
|
|
46105
46505
|
};
|
|
46106
|
-
const completion = new Promise((
|
|
46107
|
-
resolveCompletion =
|
|
46506
|
+
const completion = new Promise((resolve30) => {
|
|
46507
|
+
resolveCompletion = resolve30;
|
|
46108
46508
|
});
|
|
46109
46509
|
const finish = () => {
|
|
46110
46510
|
if (finished) return;
|
|
@@ -46151,14 +46551,14 @@ function createAfterHandoff(work, signals, onFailure) {
|
|
|
46151
46551
|
};
|
|
46152
46552
|
}
|
|
46153
46553
|
function publishResponse(dispatch) {
|
|
46154
|
-
return new Promise((
|
|
46554
|
+
return new Promise((resolve30, reject) => {
|
|
46155
46555
|
let acknowledge;
|
|
46156
46556
|
void Promise.resolve().then(
|
|
46157
46557
|
() => dispatch((callback) => {
|
|
46158
46558
|
acknowledge = callback;
|
|
46159
46559
|
})
|
|
46160
46560
|
).then((response) => {
|
|
46161
|
-
|
|
46561
|
+
resolve30(response);
|
|
46162
46562
|
acknowledge?.();
|
|
46163
46563
|
}, reject);
|
|
46164
46564
|
});
|
|
@@ -46428,7 +46828,7 @@ function formatWaitTime(ms) {
|
|
|
46428
46828
|
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
|
|
46429
46829
|
}
|
|
46430
46830
|
function sleep4(ms, signal) {
|
|
46431
|
-
return new Promise((
|
|
46831
|
+
return new Promise((resolve30, reject) => {
|
|
46432
46832
|
if (signal?.aborted) {
|
|
46433
46833
|
reject(
|
|
46434
46834
|
signal.reason instanceof Error ? signal.reason : new Error("Aborted")
|
|
@@ -46438,7 +46838,7 @@ function sleep4(ms, signal) {
|
|
|
46438
46838
|
const timerMs = Math.min(Math.max(0, Math.floor(ms)), 2147483647);
|
|
46439
46839
|
const timeout = setTimeout(() => {
|
|
46440
46840
|
cleanup2();
|
|
46441
|
-
|
|
46841
|
+
resolve30();
|
|
46442
46842
|
}, timerMs);
|
|
46443
46843
|
const onAbort = () => {
|
|
46444
46844
|
cleanup2();
|
|
@@ -49643,6 +50043,10 @@ function createGaMenuCommandService(input2) {
|
|
|
49643
50043
|
);
|
|
49644
50044
|
if (signal.aborted) throw abortError(signal);
|
|
49645
50045
|
input2.notify(scope, payload);
|
|
50046
|
+
if (!input2.isConnected(scope))
|
|
50047
|
+
throw new Error(
|
|
50048
|
+
"No Antigravity window is showing this session\u2019s folder."
|
|
50049
|
+
);
|
|
49646
50050
|
}
|
|
49647
50051
|
};
|
|
49648
50052
|
}
|
|
@@ -49664,7 +50068,7 @@ function createGaReauthorize(input2) {
|
|
|
49664
50068
|
const continuations = /* @__PURE__ */ new Set();
|
|
49665
50069
|
const shutdown = new AbortController();
|
|
49666
50070
|
let disposed = false;
|
|
49667
|
-
const waitForRedirect = (code2) => new Promise((
|
|
50071
|
+
const waitForRedirect = (code2) => new Promise((resolve30, reject) => {
|
|
49668
50072
|
const detach = () => shutdown.signal.removeEventListener("abort", abort);
|
|
49669
50073
|
const abort = () => {
|
|
49670
50074
|
detach();
|
|
@@ -49675,7 +50079,7 @@ function createGaReauthorize(input2) {
|
|
|
49675
50079
|
void code2.then(
|
|
49676
50080
|
(value) => {
|
|
49677
50081
|
detach();
|
|
49678
|
-
|
|
50082
|
+
resolve30(value);
|
|
49679
50083
|
},
|
|
49680
50084
|
(error) => {
|
|
49681
50085
|
detach();
|
|
@@ -50396,6 +50800,7 @@ async function createGaVaultLocationServices(input2) {
|
|
|
50396
50800
|
commands: createGaMenuCommandService({
|
|
50397
50801
|
menu,
|
|
50398
50802
|
notify: start.notify,
|
|
50803
|
+
isConnected: start.isConnected,
|
|
50399
50804
|
afterApply: () => input2.afterApply ? input2.afterApply() : started.refreshAccounts()
|
|
50400
50805
|
})
|
|
50401
50806
|
};
|
|
@@ -50614,6 +51019,7 @@ function createGaLocationServicesFactory(bindings) {
|
|
|
50614
51019
|
oauth: overrides.oauth
|
|
50615
51020
|
});
|
|
50616
51021
|
const loginCompletions = /* @__PURE__ */ new Set();
|
|
51022
|
+
const drawerLogins = /* @__PURE__ */ new Map();
|
|
50617
51023
|
return {
|
|
50618
51024
|
runtime,
|
|
50619
51025
|
localLogin,
|
|
@@ -50692,7 +51098,8 @@ function createGaLocationServicesFactory(bindings) {
|
|
|
50692
51098
|
},
|
|
50693
51099
|
commands: createGaMenuCommandService({
|
|
50694
51100
|
menu: recoveryMenu,
|
|
50695
|
-
notify: input2.notify
|
|
51101
|
+
notify: input2.notify,
|
|
51102
|
+
isConnected: input2.isConnected
|
|
50696
51103
|
})
|
|
50697
51104
|
};
|
|
50698
51105
|
const local = () => {
|
|
@@ -50734,30 +51141,89 @@ function createGaLocationServicesFactory(bindings) {
|
|
|
50734
51141
|
runtime: location,
|
|
50735
51142
|
reauthorize: pendingReauthorization,
|
|
50736
51143
|
login: {
|
|
50737
|
-
|
|
50738
|
-
|
|
50739
|
-
|
|
50740
|
-
|
|
50741
|
-
|
|
50742
|
-
|
|
50743
|
-
|
|
51144
|
+
knobs: [
|
|
51145
|
+
{
|
|
51146
|
+
kind: "text",
|
|
51147
|
+
id: "callback",
|
|
51148
|
+
label: GA_POOL_PASTE_PROMPT,
|
|
51149
|
+
masked: true
|
|
51150
|
+
},
|
|
51151
|
+
{
|
|
51152
|
+
kind: "toggle",
|
|
51153
|
+
id: "cancel",
|
|
51154
|
+
label: "Cancel sign-in",
|
|
51155
|
+
value: false
|
|
51156
|
+
}
|
|
51157
|
+
],
|
|
51158
|
+
async run(invocation, values) {
|
|
51159
|
+
await assertLocal();
|
|
51160
|
+
const key = invocation.sessionId ?? "";
|
|
51161
|
+
const previous = drawerLogins.get(key);
|
|
51162
|
+
const failure2 = () => ({
|
|
51163
|
+
ok: false,
|
|
51164
|
+
text: "The Antigravity pool login could not be completed.",
|
|
51165
|
+
code: "refused"
|
|
51166
|
+
});
|
|
51167
|
+
if (values.cancel === true) {
|
|
51168
|
+
if (previous) {
|
|
51169
|
+
previous.cancelled = true;
|
|
51170
|
+
await previous.attempt.cancel();
|
|
51171
|
+
drawerLogins.delete(key);
|
|
51172
|
+
}
|
|
51173
|
+
return "Sign-in cancelled.";
|
|
51174
|
+
}
|
|
51175
|
+
if (typeof values.callback === "string") {
|
|
51176
|
+
if (!previous) return failure2();
|
|
51177
|
+
try {
|
|
51178
|
+
await previous.attempt.paste(values.callback);
|
|
51179
|
+
return await previous.completion ? "Account added." : failure2();
|
|
51180
|
+
} catch {
|
|
51181
|
+
return failure2();
|
|
51182
|
+
}
|
|
51183
|
+
}
|
|
51184
|
+
if (previous) {
|
|
51185
|
+
previous.cancelled = true;
|
|
51186
|
+
await previous.attempt.cancel();
|
|
51187
|
+
}
|
|
51188
|
+
const attempt = await menuLogin.start();
|
|
51189
|
+
const entry = {
|
|
51190
|
+
attempt,
|
|
51191
|
+
cancelled: false,
|
|
51192
|
+
completion: Promise.resolve(false)
|
|
51193
|
+
};
|
|
51194
|
+
entry.completion = attempt.completion.then((result) => {
|
|
51195
|
+
if (entry.cancelled)
|
|
51196
|
+
throw new Error(
|
|
51197
|
+
"The Antigravity pool login could not be completed."
|
|
51198
|
+
);
|
|
51199
|
+
return menuLogin.onLogin(result);
|
|
51200
|
+
}).then(
|
|
50744
51201
|
() => {
|
|
50745
|
-
|
|
51202
|
+
if (!entry.cancelled)
|
|
51203
|
+
invocation.notify("Account added.", "info");
|
|
51204
|
+
return true;
|
|
50746
51205
|
},
|
|
50747
51206
|
() => {
|
|
50748
|
-
|
|
50749
|
-
|
|
50750
|
-
|
|
50751
|
-
|
|
51207
|
+
if (!entry.cancelled)
|
|
51208
|
+
invocation.notify(
|
|
51209
|
+
"The Antigravity pool login could not be completed.",
|
|
51210
|
+
"error"
|
|
51211
|
+
);
|
|
51212
|
+
return false;
|
|
50752
51213
|
}
|
|
50753
|
-
).
|
|
51214
|
+
).finally(() => {
|
|
51215
|
+
if (drawerLogins.get(key) === entry)
|
|
51216
|
+
drawerLogins.delete(key);
|
|
51217
|
+
});
|
|
51218
|
+
drawerLogins.set(key, entry);
|
|
51219
|
+
const completion = entry.completion.then(() => {
|
|
50754
51220
|
});
|
|
50755
51221
|
loginCompletions.add(completion);
|
|
50756
51222
|
void completion.finally(
|
|
50757
51223
|
() => loginCompletions.delete(completion)
|
|
50758
51224
|
);
|
|
50759
|
-
return `Open ${
|
|
50760
|
-
|
|
51225
|
+
return `Open ${attempt.url} in your browser and sign in.
|
|
51226
|
+
${GA_POOL_PASTE_PROMPT}, or wait for the browser to finish.`;
|
|
50761
51227
|
}
|
|
50762
51228
|
},
|
|
50763
51229
|
...custody ? { vault: custody.menuSection() } : {},
|
|
@@ -50792,6 +51258,7 @@ The account is added when the browser returns here; there is nothing to paste.`;
|
|
|
50792
51258
|
commands: createGaMenuCommandService({
|
|
50793
51259
|
menu,
|
|
50794
51260
|
notify: input2.notify,
|
|
51261
|
+
isConnected: input2.isConnected,
|
|
50795
51262
|
afterApply: () => refreshSelectedSource()
|
|
50796
51263
|
}),
|
|
50797
51264
|
execute: started2.execute
|
|
@@ -52437,7 +52904,7 @@ async function registerGaAuthMethods(context, authority = readAuthority, input2
|
|
|
52437
52904
|
registrations.push(
|
|
52438
52905
|
await registerOpenCode2AuthMethods(context, {
|
|
52439
52906
|
integrationID: ANTIGRAVITY_PROVIDER_ID,
|
|
52440
|
-
methods: [pool.method],
|
|
52907
|
+
methods: [pool.method, pool.pasteMethod],
|
|
52441
52908
|
onLogin: pool.onLogin,
|
|
52442
52909
|
vault: {
|
|
52443
52910
|
method: {
|
|
@@ -52780,11 +53247,11 @@ async function startGaLoopbackBridge(options) {
|
|
|
52780
53247
|
}
|
|
52781
53248
|
}
|
|
52782
53249
|
};
|
|
52783
|
-
await new Promise((
|
|
53250
|
+
await new Promise((resolve30, reject) => {
|
|
52784
53251
|
server.once("error", reject);
|
|
52785
53252
|
server.listen(0, BRIDGE_HOST, () => {
|
|
52786
53253
|
server.off("error", reject);
|
|
52787
|
-
|
|
53254
|
+
resolve30();
|
|
52788
53255
|
});
|
|
52789
53256
|
});
|
|
52790
53257
|
server.unref();
|
|
@@ -52888,8 +53355,8 @@ async function startGaLoopbackBridge(options) {
|
|
|
52888
53355
|
disposal = (async () => {
|
|
52889
53356
|
for (const { timer } of queued.values()) clearTimeout(timer);
|
|
52890
53357
|
queued.clear();
|
|
52891
|
-
const closed2 = new Promise((
|
|
52892
|
-
server.close(() =>
|
|
53358
|
+
const closed2 = new Promise((resolve30) => {
|
|
53359
|
+
server.close(() => resolve30());
|
|
52893
53360
|
});
|
|
52894
53361
|
for (const controller of running) {
|
|
52895
53362
|
controller.abort(
|
|
@@ -52955,9 +53422,9 @@ async function pipeResponse(upstream, response, onFailure, onHandoff) {
|
|
|
52955
53422
|
return;
|
|
52956
53423
|
}
|
|
52957
53424
|
if (!response.write(value) && !response.destroyed) {
|
|
52958
|
-
await new Promise((
|
|
52959
|
-
response.once("drain",
|
|
52960
|
-
response.once("close",
|
|
53425
|
+
await new Promise((resolve30) => {
|
|
53426
|
+
response.once("drain", resolve30);
|
|
53427
|
+
response.once("close", resolve30);
|
|
52961
53428
|
});
|
|
52962
53429
|
}
|
|
52963
53430
|
if (response.destroyed) {
|
|
@@ -53635,13 +54102,13 @@ function createGaAntigravityPlugin(overrides = {}) {
|
|
|
53635
54102
|
// src/plugin/index.ts
|
|
53636
54103
|
init_dist();
|
|
53637
54104
|
import { createHash as createHash24, randomUUID as randomUUID22 } from "node:crypto";
|
|
53638
|
-
import { join as join39, resolve as
|
|
54105
|
+
import { join as join39, resolve as resolve29 } from "node:path";
|
|
53639
54106
|
|
|
53640
54107
|
// src/cli.ts
|
|
53641
54108
|
init_dist();
|
|
53642
54109
|
import { execFile } from "node:child_process";
|
|
53643
54110
|
import { realpathSync as realpathSync5 } from "node:fs";
|
|
53644
|
-
import { resolve as
|
|
54111
|
+
import { resolve as resolve26 } from "node:path";
|
|
53645
54112
|
import { createInterface } from "node:readline/promises";
|
|
53646
54113
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
53647
54114
|
import { promisify } from "node:util";
|
|
@@ -53698,7 +54165,7 @@ init_runtime_paths();
|
|
|
53698
54165
|
// src/setup.ts
|
|
53699
54166
|
init_dist();
|
|
53700
54167
|
import { lstat as lstat9, readFile as readFile16 } from "node:fs/promises";
|
|
53701
|
-
import { join as join30, resolve as
|
|
54168
|
+
import { join as join30, resolve as resolve25 } from "node:path";
|
|
53702
54169
|
|
|
53703
54170
|
// src/common-auth-embedded/auth-menu/ansi.js
|
|
53704
54171
|
var ANSI2 = {
|
|
@@ -53866,7 +54333,7 @@ async function select2(terminal, items, options) {
|
|
|
53866
54333
|
writeLine("");
|
|
53867
54334
|
renderedLines = lines;
|
|
53868
54335
|
};
|
|
53869
|
-
return new Promise((
|
|
54336
|
+
return new Promise((resolve30) => {
|
|
53870
54337
|
const wasRaw = stdin.isRaw ?? false;
|
|
53871
54338
|
const cleanup2 = () => {
|
|
53872
54339
|
if (cleaned)
|
|
@@ -53886,7 +54353,7 @@ async function select2(terminal, items, options) {
|
|
|
53886
54353
|
};
|
|
53887
54354
|
const finish = (value) => {
|
|
53888
54355
|
cleanup2();
|
|
53889
|
-
|
|
54356
|
+
resolve30(value);
|
|
53890
54357
|
};
|
|
53891
54358
|
const onSignal = () => finish(null);
|
|
53892
54359
|
const onKey = (data) => {
|
|
@@ -53926,7 +54393,7 @@ async function select2(terminal, items, options) {
|
|
|
53926
54393
|
stdin.setRawMode(true);
|
|
53927
54394
|
} catch {
|
|
53928
54395
|
cleanup2();
|
|
53929
|
-
|
|
54396
|
+
resolve30(null);
|
|
53930
54397
|
return;
|
|
53931
54398
|
}
|
|
53932
54399
|
stdin.resume();
|
|
@@ -53940,12 +54407,12 @@ async function select2(terminal, items, options) {
|
|
|
53940
54407
|
import { createHash as createHash19, randomBytes as randomBytes6, randomUUID as randomUUID19 } from "node:crypto";
|
|
53941
54408
|
import { constants as fsConstants2 } from "node:fs";
|
|
53942
54409
|
import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as stat14, unlink as unlink11 } from "node:fs/promises";
|
|
53943
|
-
import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute4, join as join26, resolve as
|
|
54410
|
+
import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute4, join as join26, resolve as resolve24 } from "node:path";
|
|
53944
54411
|
import { ClaustrumCredentialError as ClaustrumCredentialError9, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
53945
54412
|
|
|
53946
54413
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
53947
54414
|
import { lstat as lstat7, stat as stat12 } from "node:fs/promises";
|
|
53948
|
-
import { resolve as
|
|
54415
|
+
import { resolve as resolve22 } from "node:path";
|
|
53949
54416
|
async function identity2(path5, followSymlinks) {
|
|
53950
54417
|
try {
|
|
53951
54418
|
const metadata = await (followSymlinks ? stat12(path5) : lstat7(path5));
|
|
@@ -53966,7 +54433,7 @@ var FileReadCache2 = class {
|
|
|
53966
54433
|
this.#followSymlinks = options.followSymlinks ?? false;
|
|
53967
54434
|
}
|
|
53968
54435
|
async read(paths, read, validateHit) {
|
|
53969
|
-
const resolvedPaths = paths.map((path5) =>
|
|
54436
|
+
const resolvedPaths = paths.map((path5) => resolve22(path5));
|
|
53970
54437
|
const key = JSON.stringify(resolvedPaths);
|
|
53971
54438
|
const probed = await Promise.all(resolvedPaths.map((path5) => identity2(path5, this.#followSymlinks)));
|
|
53972
54439
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -54015,11 +54482,46 @@ var WRITER_LOCK_CONSTANTS2 = Object.freeze({
|
|
|
54015
54482
|
init_private_files2();
|
|
54016
54483
|
|
|
54017
54484
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
54018
|
-
init_private_files2();
|
|
54019
54485
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
54020
54486
|
import { link as link3, lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as stat13 } from "node:fs/promises";
|
|
54021
54487
|
import { dirname as dirname21, join as join25 } from "node:path";
|
|
54022
54488
|
|
|
54489
|
+
// src/common-auth-embedded/fs/lock-record.js
|
|
54490
|
+
init_private_files2();
|
|
54491
|
+
import { resolve as resolve23 } from "node:path";
|
|
54492
|
+
var DisappearedLockRecordError2 = class extends Error {
|
|
54493
|
+
path;
|
|
54494
|
+
code = "ENOENT";
|
|
54495
|
+
constructor(path5, cause) {
|
|
54496
|
+
super(`Lock record disappeared: ${path5}`, { cause });
|
|
54497
|
+
this.path = path5;
|
|
54498
|
+
}
|
|
54499
|
+
};
|
|
54500
|
+
function isWindowsAccessDeniedRead2(error, paths) {
|
|
54501
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path5) => resolve23(path5) === error.path);
|
|
54502
|
+
}
|
|
54503
|
+
function isWindowsAccessDeniedCreate2(error, paths, stage) {
|
|
54504
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path5) => resolve23(path5) === error.path);
|
|
54505
|
+
}
|
|
54506
|
+
async function readLockRecord2(path5, read) {
|
|
54507
|
+
try {
|
|
54508
|
+
return await read();
|
|
54509
|
+
} catch (error) {
|
|
54510
|
+
if (!isWindowsAccessDeniedRead2(error, [path5]))
|
|
54511
|
+
throw error;
|
|
54512
|
+
try {
|
|
54513
|
+
return await read();
|
|
54514
|
+
} catch (recheckError) {
|
|
54515
|
+
if (recheckError.code === "ENOENT")
|
|
54516
|
+
throw new DisappearedLockRecordError2(path5, error);
|
|
54517
|
+
throw error;
|
|
54518
|
+
}
|
|
54519
|
+
}
|
|
54520
|
+
}
|
|
54521
|
+
|
|
54522
|
+
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
54523
|
+
init_private_files2();
|
|
54524
|
+
|
|
54023
54525
|
// src/common-auth-embedded/fs/with-lock.js
|
|
54024
54526
|
init_private_files2();
|
|
54025
54527
|
function lockPathFor2(target, name) {
|
|
@@ -54118,8 +54620,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54118
54620
|
let releaseConfirmed = false;
|
|
54119
54621
|
let loss;
|
|
54120
54622
|
let resolveLoss;
|
|
54121
|
-
const lostPromise = new Promise((
|
|
54122
|
-
resolveLoss =
|
|
54623
|
+
const lostPromise = new Promise((resolve30) => {
|
|
54624
|
+
resolveLoss = resolve30;
|
|
54123
54625
|
});
|
|
54124
54626
|
function notifyTimerStep(event) {
|
|
54125
54627
|
try {
|
|
@@ -54157,15 +54659,18 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54157
54659
|
const evictOwnerId = randomUUID18();
|
|
54158
54660
|
const EVICT_TTL = 5e3;
|
|
54159
54661
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
54662
|
+
function isChangingLockCreate(error) {
|
|
54663
|
+
return windowsPrivateFiles2 && (isWindowsAccessDeniedCreate2(error, [lockPath], "create") || isWindowsAccessDeniedCreate2(error, [evictPath], "directory-create"));
|
|
54664
|
+
}
|
|
54160
54665
|
async function readOwner() {
|
|
54161
54666
|
if (windowsPrivateFiles2) {
|
|
54162
54667
|
try {
|
|
54163
|
-
return JSON.parse(await readPrivateText2(lockPath, true));
|
|
54668
|
+
return JSON.parse(await readLockRecord2(lockPath, () => readPrivateText2(lockPath, true)));
|
|
54164
54669
|
} catch (error) {
|
|
54165
54670
|
if (error.code !== "EISDIR" && error.reason !== "wrong-kind")
|
|
54166
54671
|
throw error;
|
|
54167
|
-
await verifyPrivate2(lockPath, "directory", true);
|
|
54168
|
-
return JSON.parse(await readPrivateText2(legacyOwnerPath, true));
|
|
54672
|
+
await readLockRecord2(lockPath, () => verifyPrivate2(lockPath, "directory", true));
|
|
54673
|
+
return JSON.parse(await readLockRecord2(legacyOwnerPath, () => readPrivateText2(legacyOwnerPath, true)));
|
|
54169
54674
|
}
|
|
54170
54675
|
}
|
|
54171
54676
|
try {
|
|
@@ -54241,8 +54746,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54241
54746
|
await options.onStep("lease-contention-read-ready");
|
|
54242
54747
|
try {
|
|
54243
54748
|
if (code2 === "EISDIR") {
|
|
54244
|
-
await verifyPrivate2(lockPath, "directory", true);
|
|
54245
|
-
await readPrivateText2(legacyOwnerPath, true);
|
|
54749
|
+
await readLockRecord2(lockPath, () => verifyPrivate2(lockPath, "directory", true));
|
|
54750
|
+
await readLockRecord2(legacyOwnerPath, () => readPrivateText2(legacyOwnerPath, true));
|
|
54246
54751
|
} else
|
|
54247
54752
|
await readOwner();
|
|
54248
54753
|
} catch (readError) {
|
|
@@ -54280,7 +54785,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54280
54785
|
}
|
|
54281
54786
|
}
|
|
54282
54787
|
async function backoff() {
|
|
54283
|
-
await new Promise((
|
|
54788
|
+
await new Promise((resolve30) => setTimeout(resolve30, Math.floor(Math.random() * 4)));
|
|
54284
54789
|
}
|
|
54285
54790
|
async function readLockState(notifyReady = true) {
|
|
54286
54791
|
if (notifyReady && options.onStep)
|
|
@@ -54289,6 +54794,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54289
54794
|
try {
|
|
54290
54795
|
owner = await readOwner();
|
|
54291
54796
|
} catch (error) {
|
|
54797
|
+
if (error instanceof DisappearedLockRecordError2)
|
|
54798
|
+
return { status: "missing" };
|
|
54292
54799
|
if (windowsPrivateFiles2 && error.code !== "ENOENT")
|
|
54293
54800
|
throw error;
|
|
54294
54801
|
}
|
|
@@ -54336,7 +54843,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54336
54843
|
}
|
|
54337
54844
|
async function ownsEvictionMarker() {
|
|
54338
54845
|
try {
|
|
54339
|
-
const owner = JSON.parse(await readPrivateText2(evictOwnerPath, windowsPrivateFiles2));
|
|
54846
|
+
const owner = JSON.parse(await readLockRecord2(evictOwnerPath, () => readPrivateText2(evictOwnerPath, windowsPrivateFiles2)));
|
|
54340
54847
|
return owner?.ownerId === evictOwnerId;
|
|
54341
54848
|
} catch (error) {
|
|
54342
54849
|
if (windowsPrivateFiles2 && error.code !== "ENOENT")
|
|
@@ -54371,7 +54878,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54371
54878
|
const remainingMs = deadline - performance.now();
|
|
54372
54879
|
if (remainingMs <= 0)
|
|
54373
54880
|
throw original;
|
|
54374
|
-
await new Promise((
|
|
54881
|
+
await new Promise((resolve30) => setTimeout(resolve30, Math.min(delayMs, remainingMs)));
|
|
54375
54882
|
if (performance.now() >= deadline)
|
|
54376
54883
|
throw original;
|
|
54377
54884
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -54475,7 +54982,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54475
54982
|
}
|
|
54476
54983
|
if (windowsPrivateFiles2) {
|
|
54477
54984
|
try {
|
|
54478
|
-
await verifyPrivate2(evictPath, "directory", true);
|
|
54985
|
+
await readLockRecord2(evictPath, () => verifyPrivate2(evictPath, "directory", true));
|
|
54479
54986
|
} catch (error) {
|
|
54480
54987
|
if (error.code === "ENOENT")
|
|
54481
54988
|
return "missing";
|
|
@@ -54530,8 +55037,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54530
55037
|
if (error.code === "EEXIST") {
|
|
54531
55038
|
if (windowsPrivateFiles2) {
|
|
54532
55039
|
try {
|
|
54533
|
-
await verifyPrivate2(evictPath, "directory", true);
|
|
54534
|
-
await readPrivateText2(evictOwnerPath, true);
|
|
55040
|
+
await readLockRecord2(evictPath, () => verifyPrivate2(evictPath, "directory", true));
|
|
55041
|
+
await readLockRecord2(evictOwnerPath, () => readPrivateText2(evictOwnerPath, true));
|
|
54535
55042
|
} catch (ownerError) {
|
|
54536
55043
|
if (ownerError.code !== "ENOENT")
|
|
54537
55044
|
throw ownerError;
|
|
@@ -54552,7 +55059,11 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54552
55059
|
try {
|
|
54553
55060
|
await releaseEvictionMarker(deadline);
|
|
54554
55061
|
} catch (error) {
|
|
54555
|
-
if (isRetryableRemoval(actionError, lockPath)
|
|
55062
|
+
if ((isRetryableRemoval(actionError, lockPath) || isWindowsAccessDeniedRead2(actionError, [
|
|
55063
|
+
lockPath,
|
|
55064
|
+
legacyOwnerPath,
|
|
55065
|
+
evictOwnerPath
|
|
55066
|
+
])) && (isRetryableRemoval(error, evictPath) || isWindowsAccessDeniedRead2(error, [evictOwnerPath])))
|
|
54556
55067
|
throw actionError;
|
|
54557
55068
|
throw error;
|
|
54558
55069
|
}
|
|
@@ -54568,7 +55079,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54568
55079
|
try {
|
|
54569
55080
|
owner = await readOwner();
|
|
54570
55081
|
} catch (error) {
|
|
54571
|
-
if (windowsPrivateFiles2)
|
|
55082
|
+
if (windowsPrivateFiles2 && !(error instanceof DisappearedLockRecordError2))
|
|
54572
55083
|
throw error;
|
|
54573
55084
|
return;
|
|
54574
55085
|
}
|
|
@@ -54646,7 +55157,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54646
55157
|
await options.onStep("renewal-marker-unavailable");
|
|
54647
55158
|
}
|
|
54648
55159
|
} catch (error) {
|
|
54649
|
-
if (windowsPrivateFiles2 && error instanceof PrivateFileError2) {
|
|
55160
|
+
if (windowsPrivateFiles2 && error instanceof PrivateFileError2 && !isChangingLockCreate(error)) {
|
|
54650
55161
|
terminalIOError = error;
|
|
54651
55162
|
recordLoss("renewal-failed");
|
|
54652
55163
|
shouldReschedule = false;
|
|
@@ -54692,72 +55203,90 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54692
55203
|
}
|
|
54693
55204
|
return null;
|
|
54694
55205
|
}
|
|
54695
|
-
let acquired =
|
|
55206
|
+
let acquired = false;
|
|
55207
|
+
let changingCreateError;
|
|
55208
|
+
try {
|
|
55209
|
+
acquired = await tryAcquire();
|
|
55210
|
+
} catch (error) {
|
|
55211
|
+
if (!isChangingLockCreate(error))
|
|
55212
|
+
throw error;
|
|
55213
|
+
changingCreateError = error;
|
|
55214
|
+
}
|
|
54696
55215
|
if (!acquired) {
|
|
54697
55216
|
for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
|
|
54698
|
-
acquired = await tryAcquire();
|
|
54699
|
-
if (acquired)
|
|
54700
|
-
break;
|
|
54701
|
-
const observed = await readLockState();
|
|
54702
|
-
if (observed.status === "live")
|
|
54703
|
-
return contended();
|
|
54704
|
-
if (observed.status === "missing")
|
|
54705
|
-
continue;
|
|
54706
|
-
if (options.onStep)
|
|
54707
|
-
await options.onStep("stale-lock-observed");
|
|
54708
55217
|
try {
|
|
54709
|
-
|
|
54710
|
-
|
|
54711
|
-
|
|
54712
|
-
|
|
54713
|
-
|
|
54714
|
-
const code2 = evictError.code;
|
|
54715
|
-
if (code2 !== "EEXIST")
|
|
54716
|
-
throw evictError;
|
|
54717
|
-
const recovered = await recoverStaleEvictionMarker();
|
|
54718
|
-
if (recovered === "fresh")
|
|
54719
|
-
return null;
|
|
54720
|
-
await backoff();
|
|
54721
|
-
continue;
|
|
54722
|
-
}
|
|
54723
|
-
try {
|
|
54724
|
-
const confirmed = await readLockState();
|
|
54725
|
-
if (confirmed.status === "live")
|
|
55218
|
+
acquired = await tryAcquire();
|
|
55219
|
+
if (acquired)
|
|
55220
|
+
break;
|
|
55221
|
+
const observed = await readLockState();
|
|
55222
|
+
if (observed.status === "live")
|
|
54726
55223
|
return contended();
|
|
54727
|
-
if (
|
|
55224
|
+
if (observed.status === "missing")
|
|
54728
55225
|
continue;
|
|
54729
|
-
if (!await ownsEvictionMarker())
|
|
54730
|
-
return null;
|
|
54731
55226
|
if (options.onStep)
|
|
54732
|
-
await options.onStep("stale-lock-
|
|
54733
|
-
|
|
54734
|
-
|
|
54735
|
-
|
|
54736
|
-
|
|
55227
|
+
await options.onStep("stale-lock-observed");
|
|
55228
|
+
try {
|
|
55229
|
+
if (!await tryAcquireEvictionMarker()) {
|
|
55230
|
+
await backoff();
|
|
55231
|
+
continue;
|
|
55232
|
+
}
|
|
55233
|
+
} catch (evictError) {
|
|
55234
|
+
const code2 = evictError.code;
|
|
55235
|
+
if (code2 !== "EEXIST")
|
|
55236
|
+
throw evictError;
|
|
55237
|
+
const recovered = await recoverStaleEvictionMarker();
|
|
55238
|
+
if (recovered === "fresh")
|
|
55239
|
+
return null;
|
|
55240
|
+
await backoff();
|
|
54737
55241
|
continue;
|
|
54738
|
-
await removeLeaseObject(lockPath);
|
|
54739
|
-
if (!await ownsEvictionMarker())
|
|
54740
|
-
return null;
|
|
54741
|
-
if (options.onStep)
|
|
54742
|
-
await options.onStep("stale-lock-removed");
|
|
54743
|
-
acquired = await tryAcquire();
|
|
54744
|
-
if (!acquired)
|
|
54745
|
-
return null;
|
|
54746
|
-
if (options.onStep)
|
|
54747
|
-
await options.onStep("stale-lock-recreated");
|
|
54748
|
-
if (!await ownsEvictionMarker()) {
|
|
54749
|
-
await relinquishLockAfterMarkerLoss();
|
|
54750
|
-
acquired = false;
|
|
54751
|
-
return null;
|
|
54752
55242
|
}
|
|
54753
|
-
|
|
54754
|
-
|
|
54755
|
-
|
|
55243
|
+
try {
|
|
55244
|
+
const confirmed = await readLockState();
|
|
55245
|
+
if (confirmed.status === "live")
|
|
55246
|
+
return contended();
|
|
55247
|
+
if (!sameStaleLock(observed.identity, confirmed))
|
|
55248
|
+
continue;
|
|
55249
|
+
if (!await ownsEvictionMarker())
|
|
55250
|
+
return null;
|
|
55251
|
+
if (options.onStep)
|
|
55252
|
+
await options.onStep("stale-lock-confirmed");
|
|
55253
|
+
if (!await ownsEvictionMarker())
|
|
55254
|
+
return null;
|
|
55255
|
+
const current = await readLockState(false);
|
|
55256
|
+
if (!sameStaleLock(observed.identity, current))
|
|
55257
|
+
continue;
|
|
55258
|
+
await removeLeaseObject(lockPath);
|
|
55259
|
+
if (!await ownsEvictionMarker())
|
|
55260
|
+
return null;
|
|
55261
|
+
if (options.onStep)
|
|
55262
|
+
await options.onStep("stale-lock-removed");
|
|
55263
|
+
acquired = await tryAcquire();
|
|
55264
|
+
if (!acquired)
|
|
55265
|
+
return null;
|
|
55266
|
+
if (options.onStep)
|
|
55267
|
+
await options.onStep("stale-lock-recreated");
|
|
55268
|
+
if (!await ownsEvictionMarker()) {
|
|
55269
|
+
await relinquishLockAfterMarkerLoss();
|
|
55270
|
+
acquired = false;
|
|
55271
|
+
return null;
|
|
55272
|
+
}
|
|
55273
|
+
break;
|
|
55274
|
+
} finally {
|
|
55275
|
+
await releaseEvictionMarker();
|
|
55276
|
+
}
|
|
55277
|
+
} catch (error) {
|
|
55278
|
+
if (!isChangingLockCreate(error))
|
|
55279
|
+
throw error;
|
|
55280
|
+
changingCreateError ??= error;
|
|
55281
|
+
await backoff();
|
|
54756
55282
|
}
|
|
54757
55283
|
}
|
|
54758
55284
|
}
|
|
54759
|
-
if (!acquired)
|
|
55285
|
+
if (!acquired) {
|
|
55286
|
+
if (changingCreateError)
|
|
55287
|
+
throw changingCreateError;
|
|
54760
55288
|
return null;
|
|
55289
|
+
}
|
|
54761
55290
|
scheduleRenewal();
|
|
54762
55291
|
return {
|
|
54763
55292
|
ownerId,
|
|
@@ -54795,6 +55324,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54795
55324
|
const deadline = performance.now() + EVICT_TTL + 1e3;
|
|
54796
55325
|
let delayMs = 5;
|
|
54797
55326
|
let removalError;
|
|
55327
|
+
let changingRecordError;
|
|
54798
55328
|
for (; ; ) {
|
|
54799
55329
|
try {
|
|
54800
55330
|
let removalConfirmed = false;
|
|
@@ -54820,6 +55350,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54820
55350
|
await removeLeaseObject(lockPath);
|
|
54821
55351
|
removalConfirmed = true;
|
|
54822
55352
|
}, deadline);
|
|
55353
|
+
changingRecordError = void 0;
|
|
54823
55354
|
if (markerAcquired) {
|
|
54824
55355
|
if (windowsPrivateFiles2 && !removalConfirmed)
|
|
54825
55356
|
throw new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
@@ -54832,23 +55363,32 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
54832
55363
|
return;
|
|
54833
55364
|
await recoverStaleEvictionMarker(deadline);
|
|
54834
55365
|
} catch (error) {
|
|
54835
|
-
|
|
55366
|
+
const changingRecord = windowsPrivateFiles2 && (isChangingLockCreate(error) || isWindowsAccessDeniedRead2(error, [
|
|
55367
|
+
lockPath,
|
|
55368
|
+
legacyOwnerPath,
|
|
55369
|
+
evictPath,
|
|
55370
|
+
evictOwnerPath
|
|
55371
|
+
]));
|
|
55372
|
+
if (!isRetryableRemoval(error, lockPath) && !changingRecord) {
|
|
54836
55373
|
if (windowsPrivateFiles2)
|
|
54837
55374
|
throw error;
|
|
54838
55375
|
return;
|
|
54839
55376
|
}
|
|
54840
|
-
|
|
55377
|
+
if (changingRecord)
|
|
55378
|
+
changingRecordError ??= error;
|
|
55379
|
+
else
|
|
55380
|
+
removalError ??= error;
|
|
54841
55381
|
}
|
|
54842
55382
|
const remainingMs = deadline - performance.now();
|
|
54843
55383
|
if (remainingMs <= 0)
|
|
54844
55384
|
break;
|
|
54845
|
-
await new Promise((
|
|
55385
|
+
await new Promise((resolve30) => setTimeout(resolve30, Math.min(delayMs, remainingMs)));
|
|
54846
55386
|
if (windowsPrivateFiles2 && performance.now() >= deadline)
|
|
54847
55387
|
break;
|
|
54848
55388
|
delayMs = Math.min(delayMs * 2, 50);
|
|
54849
55389
|
}
|
|
54850
55390
|
if (windowsPrivateFiles2)
|
|
54851
|
-
throw removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
55391
|
+
throw changingRecordError ?? removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
54852
55392
|
code: "ETIMEDOUT"
|
|
54853
55393
|
});
|
|
54854
55394
|
}
|
|
@@ -54988,6 +55528,10 @@ function classifyEnrollmentError2(error) {
|
|
|
54988
55528
|
disposition: error.action === "retry" ? "retry" : "terminal"
|
|
54989
55529
|
};
|
|
54990
55530
|
}
|
|
55531
|
+
function validEnrollmentDisplayName2(displayName) {
|
|
55532
|
+
const length = Array.from(displayName).length;
|
|
55533
|
+
return length >= 1 && length <= 40 && !/[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\u200b-\u200d\u2060\ufeff]/u.test(displayName);
|
|
55534
|
+
}
|
|
54991
55535
|
function connectClaustrumEnrollmentClient2(options) {
|
|
54992
55536
|
return ClaustrumWireClient2.connect(options);
|
|
54993
55537
|
}
|
|
@@ -55003,7 +55547,7 @@ function hostEnrollmentPaths2(input2) {
|
|
|
55003
55547
|
const override = input2.override?.trim();
|
|
55004
55548
|
if (override && !isAbsolute4(override) && !input2.cwd)
|
|
55005
55549
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
55006
|
-
const tokenPath = override ? isAbsolute4(override) ? override :
|
|
55550
|
+
const tokenPath = override ? isAbsolute4(override) ? override : resolve24(input2.cwd, override) : join26(input2.stateDir, `${input2.host}-enrollment.json`);
|
|
55007
55551
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
55008
55552
|
}
|
|
55009
55553
|
function isRecord11(value) {
|
|
@@ -55364,15 +55908,19 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
55364
55908
|
#client;
|
|
55365
55909
|
#paths;
|
|
55366
55910
|
#proposedName;
|
|
55911
|
+
#displayName;
|
|
55367
55912
|
#now;
|
|
55368
55913
|
#mintSecret;
|
|
55369
55914
|
#writeTokenFile;
|
|
55370
55915
|
#ancestorOptions;
|
|
55371
55916
|
constructor(options) {
|
|
55917
|
+
if (options.displayName !== void 0 && !validEnrollmentDisplayName2(options.displayName))
|
|
55918
|
+
throw new ClaustrumConsumerError2("invalid-state", "invalid Claustrum enrollment display name");
|
|
55372
55919
|
this.#ancestorOptions = options.ancestorOptions ?? {};
|
|
55373
55920
|
this.#client = options.client;
|
|
55374
55921
|
this.#paths = options.paths;
|
|
55375
55922
|
this.#proposedName = options.proposedName;
|
|
55923
|
+
this.#displayName = options.displayName;
|
|
55376
55924
|
this.#now = options.now ?? Date.now;
|
|
55377
55925
|
this.#mintSecret = options.mintSecret ?? (() => randomBytes6(32).toString("hex"));
|
|
55378
55926
|
this.#writeTokenFile = options.writeTokenFile ?? writeEnrollmentTokenFile2;
|
|
@@ -55462,10 +56010,23 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
55462
56010
|
if (!state.requestId) {
|
|
55463
56011
|
try {
|
|
55464
56012
|
const requestSecretHash = createHash19("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
|
|
55465
|
-
const
|
|
56013
|
+
const proposal = {
|
|
55466
56014
|
name: state.proposedName,
|
|
55467
56015
|
requestSecretHash
|
|
55468
|
-
}
|
|
56016
|
+
};
|
|
56017
|
+
let proposed;
|
|
56018
|
+
try {
|
|
56019
|
+
proposed = await this.#client.enrollPropose({
|
|
56020
|
+
...proposal,
|
|
56021
|
+
...this.#displayName !== void 0 && {
|
|
56022
|
+
displayName: this.#displayName
|
|
56023
|
+
}
|
|
56024
|
+
});
|
|
56025
|
+
} catch (error) {
|
|
56026
|
+
if (this.#displayName === void 0 || !(error instanceof ClaustrumCredentialError9) || error.code !== "invalid_params")
|
|
56027
|
+
throw error;
|
|
56028
|
+
proposed = await this.#client.enrollPropose(proposal);
|
|
56029
|
+
}
|
|
55469
56030
|
state = {
|
|
55470
56031
|
...state,
|
|
55471
56032
|
requestId: proposed.requestId,
|
|
@@ -55636,7 +56197,7 @@ var ByteTail = class {
|
|
|
55636
56197
|
};
|
|
55637
56198
|
var defaultCommandRunner = {
|
|
55638
56199
|
run(file, args, options = {}) {
|
|
55639
|
-
return new Promise((
|
|
56200
|
+
return new Promise((resolve30) => {
|
|
55640
56201
|
const started = performance.now();
|
|
55641
56202
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
55642
56203
|
const stderr = new ByteTail();
|
|
@@ -55654,7 +56215,7 @@ var defaultCommandRunner = {
|
|
|
55654
56215
|
stdio: ["ignore", "pipe", "pipe"]
|
|
55655
56216
|
});
|
|
55656
56217
|
} catch {
|
|
55657
|
-
|
|
56218
|
+
resolve30({
|
|
55658
56219
|
exitCode: 1,
|
|
55659
56220
|
stdout: "",
|
|
55660
56221
|
stderr: "",
|
|
@@ -55689,7 +56250,7 @@ var defaultCommandRunner = {
|
|
|
55689
56250
|
settled = true;
|
|
55690
56251
|
if (timer)
|
|
55691
56252
|
clearTimeout(timer);
|
|
55692
|
-
|
|
56253
|
+
resolve30({
|
|
55693
56254
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
55694
56255
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
55695
56256
|
stderr: stderr.toString(),
|
|
@@ -56301,7 +56862,7 @@ function approveCommand(requestId, name) {
|
|
|
56301
56862
|
async function connectSetupHost(plugin2, host, io, terminal, fence) {
|
|
56302
56863
|
if (hasVaultHost2())
|
|
56303
56864
|
throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
|
|
56304
|
-
const { name, paths: input2 } = plugin2.vault.hosts[host];
|
|
56865
|
+
const { name, displayName, paths: input2 } = plugin2.vault.hosts[host];
|
|
56305
56866
|
const paths = hostEnrollmentPaths2(input2);
|
|
56306
56867
|
await fence();
|
|
56307
56868
|
const client = await (io.connect ?? connectClaustrumEnrollmentClient2)({
|
|
@@ -56315,6 +56876,7 @@ async function connectSetupHost(plugin2, host, io, terminal, fence) {
|
|
|
56315
56876
|
try {
|
|
56316
56877
|
const manager = new ClaustrumEnrollmentManager2({
|
|
56317
56878
|
proposedName: name,
|
|
56879
|
+
displayName,
|
|
56318
56880
|
paths,
|
|
56319
56881
|
// Each tick of the wait below checks the fence once, just before
|
|
56320
56882
|
// reconcile proposes or polls. Checking again inside every vault call
|
|
@@ -57108,7 +57670,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
57108
57670
|
beforeRename: async () => {
|
|
57109
57671
|
await assertSetupHostsStopped();
|
|
57110
57672
|
const claustrum = await loadCommonAuthClaustrum();
|
|
57111
|
-
const stateDir = host === "opencode" ? openCodeVaultDir(
|
|
57673
|
+
const stateDir = host === "opencode" ? openCodeVaultDir(resolve25(accountFileForVault())) : getPiAntigravityVaultDir();
|
|
57112
57674
|
if (await claustrum.vaultAuthority(
|
|
57113
57675
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
57114
57676
|
`antigravity-auth-${host}`
|
|
@@ -57142,17 +57704,19 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
57142
57704
|
const hosts = {
|
|
57143
57705
|
opencode: {
|
|
57144
57706
|
name: OPENCODE_VAULT_ENROLLMENT_NAME,
|
|
57707
|
+
displayName: "Antigravity sign-in for OpenCode",
|
|
57145
57708
|
// Read at each use: a real run settles the vault folder in
|
|
57146
57709
|
// `beforeSignIn`, which may move it after this plugin is built.
|
|
57147
57710
|
paths: {
|
|
57148
57711
|
get stateDir() {
|
|
57149
|
-
return openCodeVaultDir(
|
|
57712
|
+
return openCodeVaultDir(resolve25(accountFileForVault()));
|
|
57150
57713
|
},
|
|
57151
57714
|
host: "opencode"
|
|
57152
57715
|
}
|
|
57153
57716
|
},
|
|
57154
57717
|
pi: {
|
|
57155
57718
|
name: "antigravity-auth-pi",
|
|
57719
|
+
displayName: "Antigravity sign-in for Pi",
|
|
57156
57720
|
paths: { stateDir: piDir, host: "pi" }
|
|
57157
57721
|
}
|
|
57158
57722
|
};
|
|
@@ -57163,7 +57727,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
57163
57727
|
const assertLocal = async (host, context) => {
|
|
57164
57728
|
if (host === "opencode")
|
|
57165
57729
|
return assertLocalOpenCodeLogin(
|
|
57166
|
-
|
|
57730
|
+
resolve25(accountFileForVault()),
|
|
57167
57731
|
context.opencodeGeneration
|
|
57168
57732
|
);
|
|
57169
57733
|
if (await authority(host) !== "local")
|
|
@@ -57823,7 +58387,7 @@ async function runCliProcess(argv, deps) {
|
|
|
57823
58387
|
...deps,
|
|
57824
58388
|
prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
|
|
57825
58389
|
const folder = await prepareVaultFolder({
|
|
57826
|
-
accountFile:
|
|
58390
|
+
accountFile: resolve26(accountFileForVault()),
|
|
57827
58391
|
...options
|
|
57828
58392
|
});
|
|
57829
58393
|
if (folder.refusal) throw folder.refusal;
|
|
@@ -57869,11 +58433,11 @@ function createDefaultCliDependencies() {
|
|
|
57869
58433
|
);
|
|
57870
58434
|
if (host !== "pi")
|
|
57871
58435
|
await assertLocalOpenCodeLogin(
|
|
57872
|
-
|
|
58436
|
+
resolve26(accountFileForVault()),
|
|
57873
58437
|
context?.opencodeGeneration
|
|
57874
58438
|
);
|
|
57875
58439
|
const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
|
|
57876
|
-
|
|
58440
|
+
resolve26(getStoragePath()),
|
|
57877
58441
|
context?.opencodeGeneration
|
|
57878
58442
|
);
|
|
57879
58443
|
try {
|
|
@@ -57889,7 +58453,7 @@ function createDefaultCliDependencies() {
|
|
|
57889
58453
|
}
|
|
57890
58454
|
if (host === "opencode") await assertSetupHostsStopped();
|
|
57891
58455
|
await assertLocalOpenCodeLogin(
|
|
57892
|
-
|
|
58456
|
+
resolve26(accountFileForVault()),
|
|
57893
58457
|
context?.opencodeGeneration
|
|
57894
58458
|
);
|
|
57895
58459
|
await persistCliStoreLogin(
|
|
@@ -57909,7 +58473,7 @@ function createDefaultCliDependencies() {
|
|
|
57909
58473
|
};
|
|
57910
58474
|
}
|
|
57911
58475
|
async function prepareCliLoginStore(legacyPath, generation) {
|
|
57912
|
-
await assertLocalOpenCodeLogin(
|
|
58476
|
+
await assertLocalOpenCodeLogin(resolve26(accountFileForVault()), generation);
|
|
57913
58477
|
const modules = await loadCommonAuthStoreModules();
|
|
57914
58478
|
const options = {
|
|
57915
58479
|
legacyPath,
|
|
@@ -58054,7 +58618,7 @@ async function readAccountStore(legacyPath) {
|
|
|
58054
58618
|
function createDefaultAccountStoreOperations() {
|
|
58055
58619
|
const offline = { processesStopped: true };
|
|
58056
58620
|
return {
|
|
58057
|
-
legacyPath: () =>
|
|
58621
|
+
legacyPath: () => resolve26(
|
|
58058
58622
|
decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
|
|
58059
58623
|
),
|
|
58060
58624
|
migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
|
|
@@ -58085,7 +58649,7 @@ function createDefaultAccountStoreOperations() {
|
|
|
58085
58649
|
};
|
|
58086
58650
|
}
|
|
58087
58651
|
function samePath(left, right) {
|
|
58088
|
-
return process.platform === "win32" ?
|
|
58652
|
+
return process.platform === "win32" ? resolve26(left).toLowerCase() === resolve26(right).toLowerCase() : resolve26(left) === resolve26(right);
|
|
58089
58653
|
}
|
|
58090
58654
|
function isCliEntry() {
|
|
58091
58655
|
if (import.meta.main !== void 0) return import.meta.main;
|
|
@@ -58575,14 +59139,14 @@ function isTuiConnected(sessionId) {
|
|
|
58575
59139
|
// src/rpc/rpc-dir.ts
|
|
58576
59140
|
import { createHash as createHash20 } from "node:crypto";
|
|
58577
59141
|
import { homedir as homedir13, tmpdir as tmpdir6 } from "node:os";
|
|
58578
|
-
import { isAbsolute as isAbsolute5, join as join34, resolve as
|
|
59142
|
+
import { isAbsolute as isAbsolute5, join as join34, resolve as resolve27 } from "node:path";
|
|
58579
59143
|
var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
|
|
58580
59144
|
function getRpcDir(projectDirectory) {
|
|
58581
59145
|
const override = process.env[RPC_DIR_ENV]?.trim();
|
|
58582
59146
|
if (override) {
|
|
58583
|
-
return isAbsolute5(override) ? override :
|
|
59147
|
+
return isAbsolute5(override) ? override : resolve27(projectDirectory, override);
|
|
58584
59148
|
}
|
|
58585
|
-
const projectHash = createHash20("sha256").update(
|
|
59149
|
+
const projectHash = createHash20("sha256").update(resolve27(projectDirectory)).digest("hex").slice(0, 16);
|
|
58586
59150
|
const stateHome = process.env.XDG_STATE_HOME ?? join34(homedir13(), ".local", "state");
|
|
58587
59151
|
return join34(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
|
|
58588
59152
|
}
|
|
@@ -58597,7 +59161,7 @@ init_private_files2();
|
|
|
58597
59161
|
import { createHash as createHash21, randomUUID as randomUUID21 } from "node:crypto";
|
|
58598
59162
|
import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir4, rename as rename14, rmdir as rmdir3, stat as stat17, unlink as unlink13 } from "node:fs/promises";
|
|
58599
59163
|
import { uptime as uptime2 } from "node:os";
|
|
58600
|
-
import { join as join35, resolve as
|
|
59164
|
+
import { join as join35, resolve as resolve28 } from "node:path";
|
|
58601
59165
|
function staleBefore(clock2) {
|
|
58602
59166
|
return (clock2.now ?? Date.now)() - (clock2.uptime ?? uptime2)() * 1e3 - 3e5;
|
|
58603
59167
|
}
|
|
@@ -58707,7 +59271,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log17, options = {})
|
|
|
58707
59271
|
return;
|
|
58708
59272
|
throw error;
|
|
58709
59273
|
}
|
|
58710
|
-
const active2 =
|
|
59274
|
+
const active2 = resolve28(activeDir);
|
|
58711
59275
|
for (const projectDir of projectDirs) {
|
|
58712
59276
|
if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
|
|
58713
59277
|
continue;
|
|
@@ -58754,7 +59318,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log17, options = {})
|
|
|
58754
59318
|
else if (isStalePortFile(entry, info, cutoff))
|
|
58755
59319
|
await removeStalePortFile(portFile, raw, info, options.beforeRemove);
|
|
58756
59320
|
}
|
|
58757
|
-
if (
|
|
59321
|
+
if (resolve28(dir) !== active2)
|
|
58758
59322
|
await rmdir3(dir).catch(() => {
|
|
58759
59323
|
});
|
|
58760
59324
|
}
|
|
@@ -58788,7 +59352,7 @@ var BodyTooLargeError = class extends Error {
|
|
|
58788
59352
|
}
|
|
58789
59353
|
};
|
|
58790
59354
|
function readBody(req) {
|
|
58791
|
-
return new Promise((
|
|
59355
|
+
return new Promise((resolve30, reject) => {
|
|
58792
59356
|
const tooLarge = (declaredOversize = false) => {
|
|
58793
59357
|
req.removeAllListeners("data");
|
|
58794
59358
|
req.on("data", () => {
|
|
@@ -58811,7 +59375,7 @@ function readBody(req) {
|
|
|
58811
59375
|
}
|
|
58812
59376
|
chunks.push(chunk);
|
|
58813
59377
|
});
|
|
58814
|
-
req.on("end", () =>
|
|
59378
|
+
req.on("end", () => resolve30(Buffer.concat(chunks).toString("utf8")));
|
|
58815
59379
|
req.on("error", reject);
|
|
58816
59380
|
});
|
|
58817
59381
|
}
|
|
@@ -58990,12 +59554,12 @@ async function startRpcServer(options) {
|
|
|
58990
59554
|
json(500, { error: "internal error" });
|
|
58991
59555
|
}
|
|
58992
59556
|
}
|
|
58993
|
-
const port = await new Promise((
|
|
59557
|
+
const port = await new Promise((resolve30, reject) => {
|
|
58994
59558
|
server.on("error", reject);
|
|
58995
59559
|
server.listen(0, "127.0.0.1", () => {
|
|
58996
59560
|
const addr = server.address();
|
|
58997
59561
|
if (addr && typeof addr === "object")
|
|
58998
|
-
|
|
59562
|
+
resolve30(addr.port);
|
|
58999
59563
|
else
|
|
59000
59564
|
reject(new Error("no port"));
|
|
59001
59565
|
});
|
|
@@ -59018,16 +59582,16 @@ async function startRpcServer(options) {
|
|
|
59018
59582
|
rpcPort: port
|
|
59019
59583
|
});
|
|
59020
59584
|
} catch (error) {
|
|
59021
|
-
await new Promise((
|
|
59585
|
+
await new Promise((resolve30) => server.close(() => resolve30()));
|
|
59022
59586
|
throw error;
|
|
59023
59587
|
}
|
|
59024
59588
|
return {
|
|
59025
59589
|
port,
|
|
59026
59590
|
token,
|
|
59027
59591
|
async stop() {
|
|
59028
|
-
await new Promise((
|
|
59592
|
+
await new Promise((resolve30) => {
|
|
59029
59593
|
server.closeAllConnections?.();
|
|
59030
|
-
server.close(() =>
|
|
59594
|
+
server.close(() => resolve30());
|
|
59031
59595
|
for (const socket of connections)
|
|
59032
59596
|
socket.destroy();
|
|
59033
59597
|
});
|
|
@@ -59636,7 +60200,7 @@ async function select3(items, options) {
|
|
|
59636
60200
|
}
|
|
59637
60201
|
renderedLines = linesWritten;
|
|
59638
60202
|
};
|
|
59639
|
-
return new Promise((
|
|
60203
|
+
return new Promise((resolve30) => {
|
|
59640
60204
|
const wasRaw = stdin.isRaw ?? false;
|
|
59641
60205
|
const cleanup2 = () => {
|
|
59642
60206
|
if (isCleanedUp) return;
|
|
@@ -59657,11 +60221,11 @@ async function select3(items, options) {
|
|
|
59657
60221
|
};
|
|
59658
60222
|
const onSignal = () => {
|
|
59659
60223
|
cleanup2();
|
|
59660
|
-
|
|
60224
|
+
resolve30(null);
|
|
59661
60225
|
};
|
|
59662
60226
|
const finishWithValue = (value) => {
|
|
59663
60227
|
cleanup2();
|
|
59664
|
-
|
|
60228
|
+
resolve30(value);
|
|
59665
60229
|
};
|
|
59666
60230
|
const findNextSelectable = (from, direction) => {
|
|
59667
60231
|
if (items.length === 0) return from;
|
|
@@ -59707,7 +60271,7 @@ async function select3(items, options) {
|
|
|
59707
60271
|
stdin.setRawMode(true);
|
|
59708
60272
|
} catch {
|
|
59709
60273
|
cleanup2();
|
|
59710
|
-
|
|
60274
|
+
resolve30(null);
|
|
59711
60275
|
return;
|
|
59712
60276
|
}
|
|
59713
60277
|
stdin.resume();
|
|
@@ -62711,10 +63275,10 @@ function resolvePluginDependencies(overrides = {}) {
|
|
|
62711
63275
|
}
|
|
62712
63276
|
async function defaultSleep(ms, signal) {
|
|
62713
63277
|
if (ms <= 0) return;
|
|
62714
|
-
await new Promise((
|
|
63278
|
+
await new Promise((resolve30, reject) => {
|
|
62715
63279
|
const timer = setTimeout(() => {
|
|
62716
63280
|
signal?.removeEventListener("abort", onAbort);
|
|
62717
|
-
|
|
63281
|
+
resolve30();
|
|
62718
63282
|
}, ms);
|
|
62719
63283
|
timer.unref?.();
|
|
62720
63284
|
const onAbort = () => {
|
|
@@ -63436,8 +64000,8 @@ function createPluginLifecycle(options) {
|
|
|
63436
64000
|
};
|
|
63437
64001
|
let failDisposal = () => {
|
|
63438
64002
|
};
|
|
63439
|
-
disposal = new Promise((
|
|
63440
|
-
finishDisposal =
|
|
64003
|
+
disposal = new Promise((resolve30, reject) => {
|
|
64004
|
+
finishDisposal = resolve30;
|
|
63441
64005
|
failDisposal = reject;
|
|
63442
64006
|
});
|
|
63443
64007
|
void (async () => {
|
|
@@ -63586,7 +64150,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
63586
64150
|
await drainSidebarWrites();
|
|
63587
64151
|
}
|
|
63588
64152
|
});
|
|
63589
|
-
const accountFile =
|
|
64153
|
+
const accountFile = resolve29(accountFileForVault());
|
|
63590
64154
|
const vaultFolder = await prepareVaultFolder({ accountFile });
|
|
63591
64155
|
const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
|
|
63592
64156
|
let vaultQuotaPoller;
|