@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/cli.js
CHANGED
|
@@ -5851,6 +5851,8 @@ function getResolverAliasMap() {
|
|
|
5851
5851
|
}
|
|
5852
5852
|
function getQuotaGroupForModel(modelId, hasArgonPool = false) {
|
|
5853
5853
|
const normalized = modelId.toLowerCase();
|
|
5854
|
+
if (isGeminiCarbonModel(normalized))
|
|
5855
|
+
return "gemini";
|
|
5854
5856
|
if (isGeminiArgonModel(normalized))
|
|
5855
5857
|
return hasArgonPool ? "gemini-argon" : void 0;
|
|
5856
5858
|
return QUOTA_GROUP_BY_MODEL_ID[normalized] ?? // Check Claude / GPT-OSS substrings BEFORE the `gemini` substring so
|
|
@@ -5863,6 +5865,9 @@ function getQuotaGroupForModel(modelId, hasArgonPool = false) {
|
|
|
5863
5865
|
function isGeminiArgonModel(model) {
|
|
5864
5866
|
return /^(?:antigravity-)?gemini-4-argon(?:-(?:low|medium|high))?$/.test(model.toLowerCase());
|
|
5865
5867
|
}
|
|
5868
|
+
function isGeminiCarbonModel(model) {
|
|
5869
|
+
return /^(?:antigravity-)?gemini-4-carbon(?:-(?:low|medium|high))?$/.test(model.toLowerCase());
|
|
5870
|
+
}
|
|
5866
5871
|
var DEFAULT_MODALITIES, MODEL_RELEASE_DATE, DEFAULT_COST, DEFAULT_OPTIONS, ALL_MODEL_DEFINITIONS, RESOLVER_ALIASES, QUOTA_GROUP_BY_MODEL_ID, ANTIGRAVITY_OPENCODE_MODEL_IDS, OPENCODE_MODEL_DEFINITIONS;
|
|
5867
5872
|
var init_model_registry = __esm({
|
|
5868
5873
|
"../core/dist/model-registry.js"() {
|
|
@@ -5886,6 +5891,17 @@ var init_model_registry = __esm({
|
|
|
5886
5891
|
high: { thinkingLevel: "high" }
|
|
5887
5892
|
}
|
|
5888
5893
|
}),
|
|
5894
|
+
"antigravity-gemini-4-carbon": defineModel("antigravity-gemini-4-carbon", {
|
|
5895
|
+
name: "Gemini 4 Carbon (Antigravity)",
|
|
5896
|
+
reasoning: true,
|
|
5897
|
+
limit: { context: 1048576, output: 262144 },
|
|
5898
|
+
modalities: DEFAULT_MODALITIES,
|
|
5899
|
+
variants: {
|
|
5900
|
+
low: { thinkingLevel: "low" },
|
|
5901
|
+
medium: { thinkingLevel: "medium" },
|
|
5902
|
+
high: { thinkingLevel: "high" }
|
|
5903
|
+
}
|
|
5904
|
+
}),
|
|
5889
5905
|
"antigravity-gemini-3.1-flash-image": defineModel("antigravity-gemini-3.1-flash-image", {
|
|
5890
5906
|
name: "Gemini 3.1 Flash Image (Antigravity)",
|
|
5891
5907
|
reasoning: false,
|
|
@@ -5933,6 +5949,9 @@ var init_model_registry = __esm({
|
|
|
5933
5949
|
})
|
|
5934
5950
|
};
|
|
5935
5951
|
RESOLVER_ALIASES = {
|
|
5952
|
+
"gemini-4-carbon-low": "gemini-4-carbon",
|
|
5953
|
+
"gemini-4-carbon-medium": "gemini-4-carbon",
|
|
5954
|
+
"gemini-4-carbon-high": "gemini-4-carbon",
|
|
5936
5955
|
"gemini-4-argon-low": "gemini-4-argon",
|
|
5937
5956
|
"gemini-4-argon-medium": "gemini-4-argon",
|
|
5938
5957
|
"gemini-4-argon-high": "gemini-4-argon",
|
|
@@ -5994,6 +6013,7 @@ var init_model_registry = __esm({
|
|
|
5994
6013
|
};
|
|
5995
6014
|
ANTIGRAVITY_OPENCODE_MODEL_IDS = [
|
|
5996
6015
|
"antigravity-gemini-4-argon",
|
|
6016
|
+
"antigravity-gemini-4-carbon",
|
|
5997
6017
|
"antigravity-gemini-3.8-flash",
|
|
5998
6018
|
"antigravity-gemini-3.1-flash-image",
|
|
5999
6019
|
"antigravity-claude-sonnet-5-5",
|
|
@@ -6104,7 +6124,7 @@ async function rmEvictingDir(evictingPath) {
|
|
|
6104
6124
|
});
|
|
6105
6125
|
}
|
|
6106
6126
|
async function sleep(ms) {
|
|
6107
|
-
await new Promise((
|
|
6127
|
+
await new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
6108
6128
|
}
|
|
6109
6129
|
async function acquireFencedFileLock(options) {
|
|
6110
6130
|
const lockPath = `${options.path}.${options.name}.lock`;
|
|
@@ -6220,8 +6240,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
6220
6240
|
let released = false;
|
|
6221
6241
|
let lost = false;
|
|
6222
6242
|
let lostResolve = null;
|
|
6223
|
-
let lostPromise = new Promise((
|
|
6224
|
-
lostResolve =
|
|
6243
|
+
let lostPromise = new Promise((resolve24) => {
|
|
6244
|
+
lostResolve = resolve24;
|
|
6225
6245
|
});
|
|
6226
6246
|
const markLost = () => {
|
|
6227
6247
|
if (lost)
|
|
@@ -6231,9 +6251,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
|
|
|
6231
6251
|
clearInterval(renewTimer);
|
|
6232
6252
|
renewTimer = null;
|
|
6233
6253
|
}
|
|
6234
|
-
const
|
|
6254
|
+
const resolve24 = lostResolve;
|
|
6235
6255
|
lostResolve = null;
|
|
6236
|
-
|
|
6256
|
+
resolve24?.();
|
|
6237
6257
|
};
|
|
6238
6258
|
const setupRenew = () => {
|
|
6239
6259
|
if (options.renew === false)
|
|
@@ -6875,7 +6895,7 @@ var init_account_storage = __esm({
|
|
|
6875
6895
|
}
|
|
6876
6896
|
};
|
|
6877
6897
|
RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
|
|
6878
|
-
DEFAULT_SLEEP = (ms) => new Promise((
|
|
6898
|
+
DEFAULT_SLEEP = (ms) => new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
6879
6899
|
DEFAULT_BUILD_BACKUP_PATH = (path2, now) => `${path2}.corrupt-${now.toISOString().replace(/[:.]/g, "-")}`;
|
|
6880
6900
|
}
|
|
6881
6901
|
});
|
|
@@ -7043,7 +7063,7 @@ function getHttpsProxy(url) {
|
|
|
7043
7063
|
}
|
|
7044
7064
|
}
|
|
7045
7065
|
function waitForHead(socket, timeoutMs, onTimeout) {
|
|
7046
|
-
return new Promise((
|
|
7066
|
+
return new Promise((resolve24, reject) => {
|
|
7047
7067
|
let buffer = Buffer2.alloc(0);
|
|
7048
7068
|
const timeout = setTimeout(() => {
|
|
7049
7069
|
onTimeout();
|
|
@@ -7066,7 +7086,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
|
|
|
7066
7086
|
return;
|
|
7067
7087
|
const head = buffer.subarray(0, marker).toString("latin1");
|
|
7068
7088
|
const leftover = buffer.subarray(marker + 4);
|
|
7069
|
-
cleanup2(() =>
|
|
7089
|
+
cleanup2(() => resolve24({ head, leftover }));
|
|
7070
7090
|
};
|
|
7071
7091
|
socket.on("data", onData);
|
|
7072
7092
|
socket.once("error", onError);
|
|
@@ -7080,7 +7100,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
7080
7100
|
port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
|
|
7081
7101
|
signal: signal ?? void 0
|
|
7082
7102
|
});
|
|
7083
|
-
await new Promise((
|
|
7103
|
+
await new Promise((resolve24, reject) => {
|
|
7084
7104
|
const timeout = setTimeout(() => {
|
|
7085
7105
|
onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
|
|
7086
7106
|
proxySocket.destroy();
|
|
@@ -7089,7 +7109,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
|
|
|
7089
7109
|
const cleanup2 = () => clearTimeout(timeout);
|
|
7090
7110
|
proxySocket.once("connect", () => {
|
|
7091
7111
|
cleanup2();
|
|
7092
|
-
|
|
7112
|
+
resolve24();
|
|
7093
7113
|
});
|
|
7094
7114
|
proxySocket.once("error", (error) => {
|
|
7095
7115
|
cleanup2();
|
|
@@ -7114,7 +7134,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
7114
7134
|
if (leftover.length > 0) {
|
|
7115
7135
|
proxySocket.unshift(leftover);
|
|
7116
7136
|
}
|
|
7117
|
-
return await new Promise((
|
|
7137
|
+
return await new Promise((resolve24, reject) => {
|
|
7118
7138
|
const tlsOptions = {
|
|
7119
7139
|
socket: proxySocket,
|
|
7120
7140
|
servername: targetHost,
|
|
@@ -7129,7 +7149,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
7129
7149
|
const cleanup2 = () => clearTimeout(timeout);
|
|
7130
7150
|
tlsSocket.once("secureConnect", () => {
|
|
7131
7151
|
cleanup2();
|
|
7132
|
-
|
|
7152
|
+
resolve24(tlsSocket);
|
|
7133
7153
|
});
|
|
7134
7154
|
tlsSocket.once("error", (error) => {
|
|
7135
7155
|
cleanup2();
|
|
@@ -7138,7 +7158,7 @@ Host: ${targetHost}:${targetPort}\r
|
|
|
7138
7158
|
});
|
|
7139
7159
|
}
|
|
7140
7160
|
async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
7141
|
-
return await new Promise((
|
|
7161
|
+
return await new Promise((resolve24, reject) => {
|
|
7142
7162
|
const tlsOptions = {
|
|
7143
7163
|
host: targetUrl.hostname,
|
|
7144
7164
|
port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
|
|
@@ -7154,7 +7174,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
|
|
|
7154
7174
|
const cleanup2 = () => clearTimeout(timeout);
|
|
7155
7175
|
socket.once("secureConnect", () => {
|
|
7156
7176
|
cleanup2();
|
|
7157
|
-
|
|
7177
|
+
resolve24(socket);
|
|
7158
7178
|
});
|
|
7159
7179
|
socket.once("error", (error) => {
|
|
7160
7180
|
cleanup2();
|
|
@@ -8711,6 +8731,45 @@ var init_atomic_write2 = __esm({
|
|
|
8711
8731
|
}
|
|
8712
8732
|
});
|
|
8713
8733
|
|
|
8734
|
+
// ../core/dist/common-auth-embedded/fs/lock-record.js
|
|
8735
|
+
import { resolve as resolve3 } from "node:path";
|
|
8736
|
+
function isWindowsAccessDeniedRead(error, paths) {
|
|
8737
|
+
return error instanceof PrivateFileError && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path2) => resolve3(path2) === error.path);
|
|
8738
|
+
}
|
|
8739
|
+
function isWindowsAccessDeniedCreate(error, paths, stage) {
|
|
8740
|
+
return error instanceof PrivateFileError && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path2) => resolve3(path2) === error.path);
|
|
8741
|
+
}
|
|
8742
|
+
async function readLockRecord(path2, read) {
|
|
8743
|
+
try {
|
|
8744
|
+
return await read();
|
|
8745
|
+
} catch (error) {
|
|
8746
|
+
if (!isWindowsAccessDeniedRead(error, [path2]))
|
|
8747
|
+
throw error;
|
|
8748
|
+
try {
|
|
8749
|
+
return await read();
|
|
8750
|
+
} catch (recheckError) {
|
|
8751
|
+
if (recheckError.code === "ENOENT")
|
|
8752
|
+
throw new DisappearedLockRecordError(path2, error);
|
|
8753
|
+
throw error;
|
|
8754
|
+
}
|
|
8755
|
+
}
|
|
8756
|
+
}
|
|
8757
|
+
var DisappearedLockRecordError;
|
|
8758
|
+
var init_lock_record = __esm({
|
|
8759
|
+
"../core/dist/common-auth-embedded/fs/lock-record.js"() {
|
|
8760
|
+
"use strict";
|
|
8761
|
+
init_private_files();
|
|
8762
|
+
DisappearedLockRecordError = class extends Error {
|
|
8763
|
+
path;
|
|
8764
|
+
code = "ENOENT";
|
|
8765
|
+
constructor(path2, cause) {
|
|
8766
|
+
super(`Lock record disappeared: ${path2}`, { cause });
|
|
8767
|
+
this.path = path2;
|
|
8768
|
+
}
|
|
8769
|
+
};
|
|
8770
|
+
}
|
|
8771
|
+
});
|
|
8772
|
+
|
|
8714
8773
|
// ../core/dist/common-auth-embedded/fs/refresh-file-lock.js
|
|
8715
8774
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
8716
8775
|
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";
|
|
@@ -8793,8 +8852,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
8793
8852
|
let releaseConfirmed = false;
|
|
8794
8853
|
let loss;
|
|
8795
8854
|
let resolveLoss;
|
|
8796
|
-
const lostPromise = new Promise((
|
|
8797
|
-
resolveLoss =
|
|
8855
|
+
const lostPromise = new Promise((resolve24) => {
|
|
8856
|
+
resolveLoss = resolve24;
|
|
8798
8857
|
});
|
|
8799
8858
|
function notifyTimerStep(event) {
|
|
8800
8859
|
try {
|
|
@@ -8832,15 +8891,18 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
8832
8891
|
const evictOwnerId = randomUUID7();
|
|
8833
8892
|
const EVICT_TTL = 5e3;
|
|
8834
8893
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
8894
|
+
function isChangingLockCreate(error) {
|
|
8895
|
+
return windowsPrivateFiles && (isWindowsAccessDeniedCreate(error, [lockPath], "create") || isWindowsAccessDeniedCreate(error, [evictPath], "directory-create"));
|
|
8896
|
+
}
|
|
8835
8897
|
async function readOwner() {
|
|
8836
8898
|
if (windowsPrivateFiles) {
|
|
8837
8899
|
try {
|
|
8838
|
-
return JSON.parse(await readPrivateText(lockPath, true));
|
|
8900
|
+
return JSON.parse(await readLockRecord(lockPath, () => readPrivateText(lockPath, true)));
|
|
8839
8901
|
} catch (error) {
|
|
8840
8902
|
if (error.code !== "EISDIR" && error.reason !== "wrong-kind")
|
|
8841
8903
|
throw error;
|
|
8842
|
-
await verifyPrivate(lockPath, "directory", true);
|
|
8843
|
-
return JSON.parse(await readPrivateText(legacyOwnerPath, true));
|
|
8904
|
+
await readLockRecord(lockPath, () => verifyPrivate(lockPath, "directory", true));
|
|
8905
|
+
return JSON.parse(await readLockRecord(legacyOwnerPath, () => readPrivateText(legacyOwnerPath, true)));
|
|
8844
8906
|
}
|
|
8845
8907
|
}
|
|
8846
8908
|
try {
|
|
@@ -8916,8 +8978,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
8916
8978
|
await options.onStep("lease-contention-read-ready");
|
|
8917
8979
|
try {
|
|
8918
8980
|
if (code2 === "EISDIR") {
|
|
8919
|
-
await verifyPrivate(lockPath, "directory", true);
|
|
8920
|
-
await readPrivateText(legacyOwnerPath, true);
|
|
8981
|
+
await readLockRecord(lockPath, () => verifyPrivate(lockPath, "directory", true));
|
|
8982
|
+
await readLockRecord(legacyOwnerPath, () => readPrivateText(legacyOwnerPath, true));
|
|
8921
8983
|
} else
|
|
8922
8984
|
await readOwner();
|
|
8923
8985
|
} catch (readError) {
|
|
@@ -8955,7 +9017,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
8955
9017
|
}
|
|
8956
9018
|
}
|
|
8957
9019
|
async function backoff() {
|
|
8958
|
-
await new Promise((
|
|
9020
|
+
await new Promise((resolve24) => setTimeout(resolve24, Math.floor(Math.random() * 4)));
|
|
8959
9021
|
}
|
|
8960
9022
|
async function readLockState(notifyReady = true) {
|
|
8961
9023
|
if (notifyReady && options.onStep)
|
|
@@ -8964,6 +9026,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
8964
9026
|
try {
|
|
8965
9027
|
owner = await readOwner();
|
|
8966
9028
|
} catch (error) {
|
|
9029
|
+
if (error instanceof DisappearedLockRecordError)
|
|
9030
|
+
return { status: "missing" };
|
|
8967
9031
|
if (windowsPrivateFiles && error.code !== "ENOENT")
|
|
8968
9032
|
throw error;
|
|
8969
9033
|
}
|
|
@@ -9011,7 +9075,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9011
9075
|
}
|
|
9012
9076
|
async function ownsEvictionMarker() {
|
|
9013
9077
|
try {
|
|
9014
|
-
const owner = JSON.parse(await readPrivateText(evictOwnerPath, windowsPrivateFiles));
|
|
9078
|
+
const owner = JSON.parse(await readLockRecord(evictOwnerPath, () => readPrivateText(evictOwnerPath, windowsPrivateFiles)));
|
|
9015
9079
|
return owner?.ownerId === evictOwnerId;
|
|
9016
9080
|
} catch (error) {
|
|
9017
9081
|
if (windowsPrivateFiles && error.code !== "ENOENT")
|
|
@@ -9046,7 +9110,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9046
9110
|
const remainingMs = deadline - performance.now();
|
|
9047
9111
|
if (remainingMs <= 0)
|
|
9048
9112
|
throw original;
|
|
9049
|
-
await new Promise((
|
|
9113
|
+
await new Promise((resolve24) => setTimeout(resolve24, Math.min(delayMs, remainingMs)));
|
|
9050
9114
|
if (performance.now() >= deadline)
|
|
9051
9115
|
throw original;
|
|
9052
9116
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -9150,7 +9214,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9150
9214
|
}
|
|
9151
9215
|
if (windowsPrivateFiles) {
|
|
9152
9216
|
try {
|
|
9153
|
-
await verifyPrivate(evictPath, "directory", true);
|
|
9217
|
+
await readLockRecord(evictPath, () => verifyPrivate(evictPath, "directory", true));
|
|
9154
9218
|
} catch (error) {
|
|
9155
9219
|
if (error.code === "ENOENT")
|
|
9156
9220
|
return "missing";
|
|
@@ -9205,8 +9269,8 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9205
9269
|
if (error.code === "EEXIST") {
|
|
9206
9270
|
if (windowsPrivateFiles) {
|
|
9207
9271
|
try {
|
|
9208
|
-
await verifyPrivate(evictPath, "directory", true);
|
|
9209
|
-
await readPrivateText(evictOwnerPath, true);
|
|
9272
|
+
await readLockRecord(evictPath, () => verifyPrivate(evictPath, "directory", true));
|
|
9273
|
+
await readLockRecord(evictOwnerPath, () => readPrivateText(evictOwnerPath, true));
|
|
9210
9274
|
} catch (ownerError) {
|
|
9211
9275
|
if (ownerError.code !== "ENOENT")
|
|
9212
9276
|
throw ownerError;
|
|
@@ -9227,7 +9291,11 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9227
9291
|
try {
|
|
9228
9292
|
await releaseEvictionMarker(deadline);
|
|
9229
9293
|
} catch (error) {
|
|
9230
|
-
if (isRetryableRemoval(actionError, lockPath)
|
|
9294
|
+
if ((isRetryableRemoval(actionError, lockPath) || isWindowsAccessDeniedRead(actionError, [
|
|
9295
|
+
lockPath,
|
|
9296
|
+
legacyOwnerPath,
|
|
9297
|
+
evictOwnerPath
|
|
9298
|
+
])) && (isRetryableRemoval(error, evictPath) || isWindowsAccessDeniedRead(error, [evictOwnerPath])))
|
|
9231
9299
|
throw actionError;
|
|
9232
9300
|
throw error;
|
|
9233
9301
|
}
|
|
@@ -9243,7 +9311,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9243
9311
|
try {
|
|
9244
9312
|
owner = await readOwner();
|
|
9245
9313
|
} catch (error) {
|
|
9246
|
-
if (windowsPrivateFiles)
|
|
9314
|
+
if (windowsPrivateFiles && !(error instanceof DisappearedLockRecordError))
|
|
9247
9315
|
throw error;
|
|
9248
9316
|
return;
|
|
9249
9317
|
}
|
|
@@ -9321,7 +9389,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9321
9389
|
await options.onStep("renewal-marker-unavailable");
|
|
9322
9390
|
}
|
|
9323
9391
|
} catch (error) {
|
|
9324
|
-
if (windowsPrivateFiles && error instanceof PrivateFileError) {
|
|
9392
|
+
if (windowsPrivateFiles && error instanceof PrivateFileError && !isChangingLockCreate(error)) {
|
|
9325
9393
|
terminalIOError = error;
|
|
9326
9394
|
recordLoss("renewal-failed");
|
|
9327
9395
|
shouldReschedule = false;
|
|
@@ -9367,72 +9435,90 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9367
9435
|
}
|
|
9368
9436
|
return null;
|
|
9369
9437
|
}
|
|
9370
|
-
let acquired =
|
|
9438
|
+
let acquired = false;
|
|
9439
|
+
let changingCreateError;
|
|
9440
|
+
try {
|
|
9441
|
+
acquired = await tryAcquire();
|
|
9442
|
+
} catch (error) {
|
|
9443
|
+
if (!isChangingLockCreate(error))
|
|
9444
|
+
throw error;
|
|
9445
|
+
changingCreateError = error;
|
|
9446
|
+
}
|
|
9371
9447
|
if (!acquired) {
|
|
9372
9448
|
for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
|
|
9373
|
-
acquired = await tryAcquire();
|
|
9374
|
-
if (acquired)
|
|
9375
|
-
break;
|
|
9376
|
-
const observed = await readLockState();
|
|
9377
|
-
if (observed.status === "live")
|
|
9378
|
-
return contended();
|
|
9379
|
-
if (observed.status === "missing")
|
|
9380
|
-
continue;
|
|
9381
|
-
if (options.onStep)
|
|
9382
|
-
await options.onStep("stale-lock-observed");
|
|
9383
|
-
try {
|
|
9384
|
-
if (!await tryAcquireEvictionMarker()) {
|
|
9385
|
-
await backoff();
|
|
9386
|
-
continue;
|
|
9387
|
-
}
|
|
9388
|
-
} catch (evictError) {
|
|
9389
|
-
const code2 = evictError.code;
|
|
9390
|
-
if (code2 !== "EEXIST")
|
|
9391
|
-
throw evictError;
|
|
9392
|
-
const recovered = await recoverStaleEvictionMarker();
|
|
9393
|
-
if (recovered === "fresh")
|
|
9394
|
-
return null;
|
|
9395
|
-
await backoff();
|
|
9396
|
-
continue;
|
|
9397
|
-
}
|
|
9398
9449
|
try {
|
|
9399
|
-
|
|
9400
|
-
if (
|
|
9450
|
+
acquired = await tryAcquire();
|
|
9451
|
+
if (acquired)
|
|
9452
|
+
break;
|
|
9453
|
+
const observed = await readLockState();
|
|
9454
|
+
if (observed.status === "live")
|
|
9401
9455
|
return contended();
|
|
9402
|
-
if (
|
|
9456
|
+
if (observed.status === "missing")
|
|
9403
9457
|
continue;
|
|
9404
|
-
if (!await ownsEvictionMarker())
|
|
9405
|
-
return null;
|
|
9406
9458
|
if (options.onStep)
|
|
9407
|
-
await options.onStep("stale-lock-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9459
|
+
await options.onStep("stale-lock-observed");
|
|
9460
|
+
try {
|
|
9461
|
+
if (!await tryAcquireEvictionMarker()) {
|
|
9462
|
+
await backoff();
|
|
9463
|
+
continue;
|
|
9464
|
+
}
|
|
9465
|
+
} catch (evictError) {
|
|
9466
|
+
const code2 = evictError.code;
|
|
9467
|
+
if (code2 !== "EEXIST")
|
|
9468
|
+
throw evictError;
|
|
9469
|
+
const recovered = await recoverStaleEvictionMarker();
|
|
9470
|
+
if (recovered === "fresh")
|
|
9471
|
+
return null;
|
|
9472
|
+
await backoff();
|
|
9412
9473
|
continue;
|
|
9413
|
-
await removeLeaseObject(lockPath);
|
|
9414
|
-
if (!await ownsEvictionMarker())
|
|
9415
|
-
return null;
|
|
9416
|
-
if (options.onStep)
|
|
9417
|
-
await options.onStep("stale-lock-removed");
|
|
9418
|
-
acquired = await tryAcquire();
|
|
9419
|
-
if (!acquired)
|
|
9420
|
-
return null;
|
|
9421
|
-
if (options.onStep)
|
|
9422
|
-
await options.onStep("stale-lock-recreated");
|
|
9423
|
-
if (!await ownsEvictionMarker()) {
|
|
9424
|
-
await relinquishLockAfterMarkerLoss();
|
|
9425
|
-
acquired = false;
|
|
9426
|
-
return null;
|
|
9427
9474
|
}
|
|
9428
|
-
|
|
9429
|
-
|
|
9430
|
-
|
|
9475
|
+
try {
|
|
9476
|
+
const confirmed = await readLockState();
|
|
9477
|
+
if (confirmed.status === "live")
|
|
9478
|
+
return contended();
|
|
9479
|
+
if (!sameStaleLock(observed.identity, confirmed))
|
|
9480
|
+
continue;
|
|
9481
|
+
if (!await ownsEvictionMarker())
|
|
9482
|
+
return null;
|
|
9483
|
+
if (options.onStep)
|
|
9484
|
+
await options.onStep("stale-lock-confirmed");
|
|
9485
|
+
if (!await ownsEvictionMarker())
|
|
9486
|
+
return null;
|
|
9487
|
+
const current = await readLockState(false);
|
|
9488
|
+
if (!sameStaleLock(observed.identity, current))
|
|
9489
|
+
continue;
|
|
9490
|
+
await removeLeaseObject(lockPath);
|
|
9491
|
+
if (!await ownsEvictionMarker())
|
|
9492
|
+
return null;
|
|
9493
|
+
if (options.onStep)
|
|
9494
|
+
await options.onStep("stale-lock-removed");
|
|
9495
|
+
acquired = await tryAcquire();
|
|
9496
|
+
if (!acquired)
|
|
9497
|
+
return null;
|
|
9498
|
+
if (options.onStep)
|
|
9499
|
+
await options.onStep("stale-lock-recreated");
|
|
9500
|
+
if (!await ownsEvictionMarker()) {
|
|
9501
|
+
await relinquishLockAfterMarkerLoss();
|
|
9502
|
+
acquired = false;
|
|
9503
|
+
return null;
|
|
9504
|
+
}
|
|
9505
|
+
break;
|
|
9506
|
+
} finally {
|
|
9507
|
+
await releaseEvictionMarker();
|
|
9508
|
+
}
|
|
9509
|
+
} catch (error) {
|
|
9510
|
+
if (!isChangingLockCreate(error))
|
|
9511
|
+
throw error;
|
|
9512
|
+
changingCreateError ??= error;
|
|
9513
|
+
await backoff();
|
|
9431
9514
|
}
|
|
9432
9515
|
}
|
|
9433
9516
|
}
|
|
9434
|
-
if (!acquired)
|
|
9517
|
+
if (!acquired) {
|
|
9518
|
+
if (changingCreateError)
|
|
9519
|
+
throw changingCreateError;
|
|
9435
9520
|
return null;
|
|
9521
|
+
}
|
|
9436
9522
|
scheduleRenewal();
|
|
9437
9523
|
return {
|
|
9438
9524
|
ownerId,
|
|
@@ -9470,6 +9556,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9470
9556
|
const deadline = performance.now() + EVICT_TTL + 1e3;
|
|
9471
9557
|
let delayMs = 5;
|
|
9472
9558
|
let removalError;
|
|
9559
|
+
let changingRecordError;
|
|
9473
9560
|
for (; ; ) {
|
|
9474
9561
|
try {
|
|
9475
9562
|
let removalConfirmed = false;
|
|
@@ -9495,6 +9582,7 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9495
9582
|
await removeLeaseObject(lockPath);
|
|
9496
9583
|
removalConfirmed = true;
|
|
9497
9584
|
}, deadline);
|
|
9585
|
+
changingRecordError = void 0;
|
|
9498
9586
|
if (markerAcquired) {
|
|
9499
9587
|
if (windowsPrivateFiles && !removalConfirmed)
|
|
9500
9588
|
throw new PrivateFileError(lockPath, "release-not-confirmed", {
|
|
@@ -9507,23 +9595,32 @@ async function acquireRefreshFileLockWithClock(options) {
|
|
|
9507
9595
|
return;
|
|
9508
9596
|
await recoverStaleEvictionMarker(deadline);
|
|
9509
9597
|
} catch (error) {
|
|
9510
|
-
|
|
9598
|
+
const changingRecord = windowsPrivateFiles && (isChangingLockCreate(error) || isWindowsAccessDeniedRead(error, [
|
|
9599
|
+
lockPath,
|
|
9600
|
+
legacyOwnerPath,
|
|
9601
|
+
evictPath,
|
|
9602
|
+
evictOwnerPath
|
|
9603
|
+
]));
|
|
9604
|
+
if (!isRetryableRemoval(error, lockPath) && !changingRecord) {
|
|
9511
9605
|
if (windowsPrivateFiles)
|
|
9512
9606
|
throw error;
|
|
9513
9607
|
return;
|
|
9514
9608
|
}
|
|
9515
|
-
|
|
9609
|
+
if (changingRecord)
|
|
9610
|
+
changingRecordError ??= error;
|
|
9611
|
+
else
|
|
9612
|
+
removalError ??= error;
|
|
9516
9613
|
}
|
|
9517
9614
|
const remainingMs = deadline - performance.now();
|
|
9518
9615
|
if (remainingMs <= 0)
|
|
9519
9616
|
break;
|
|
9520
|
-
await new Promise((
|
|
9617
|
+
await new Promise((resolve24) => setTimeout(resolve24, Math.min(delayMs, remainingMs)));
|
|
9521
9618
|
if (windowsPrivateFiles && performance.now() >= deadline)
|
|
9522
9619
|
break;
|
|
9523
9620
|
delayMs = Math.min(delayMs * 2, 50);
|
|
9524
9621
|
}
|
|
9525
9622
|
if (windowsPrivateFiles)
|
|
9526
|
-
throw removalError ?? new PrivateFileError(lockPath, "release-not-confirmed", {
|
|
9623
|
+
throw changingRecordError ?? removalError ?? new PrivateFileError(lockPath, "release-not-confirmed", {
|
|
9527
9624
|
code: "ETIMEDOUT"
|
|
9528
9625
|
});
|
|
9529
9626
|
}
|
|
@@ -9533,6 +9630,7 @@ var leaseCreationTestHooks, setRefreshLockRenewalTimeout, clearRefreshLockRenewa
|
|
|
9533
9630
|
var init_refresh_file_lock = __esm({
|
|
9534
9631
|
"../core/dist/common-auth-embedded/fs/refresh-file-lock.js"() {
|
|
9535
9632
|
"use strict";
|
|
9633
|
+
init_lock_record();
|
|
9536
9634
|
init_private_files();
|
|
9537
9635
|
init_with_lock();
|
|
9538
9636
|
setRefreshLockRenewalTimeout = globalThis.setTimeout.bind(globalThis);
|
|
@@ -9542,22 +9640,21 @@ var init_refresh_file_lock = __esm({
|
|
|
9542
9640
|
});
|
|
9543
9641
|
|
|
9544
9642
|
// ../core/dist/common-auth-embedded/fs/with-lock.js
|
|
9545
|
-
import { join as join6, resolve as
|
|
9643
|
+
import { join as join6, resolve as resolve4 } from "node:path";
|
|
9546
9644
|
function lockPathFor(target, name) {
|
|
9547
9645
|
return `${target}.${name}.lock`;
|
|
9548
9646
|
}
|
|
9549
|
-
function
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
return error.path === path2 || error.path === join6(path2, "owner.json");
|
|
9647
|
+
function isChangingLockRecord(error, target, name) {
|
|
9648
|
+
const path2 = resolve4(lockPathFor(target, name));
|
|
9649
|
+
const paths = [path2, join6(path2, "owner.json")];
|
|
9650
|
+
return (isWindowsSharingViolation(error) || isWindowsAccessDeniedRead(error, paths)) && (error.stage === "read" || error.stage === "verify") && paths.includes(error.path) || windowsPrivateFiles && (isWindowsAccessDeniedCreate(error, [path2], "create") || isWindowsAccessDeniedCreate(error, [`${path2}.evicting`], "directory-create"));
|
|
9554
9651
|
}
|
|
9555
9652
|
async function withLock(target, options, fn) {
|
|
9556
9653
|
const started = performance.now();
|
|
9654
|
+
let changingRecordError;
|
|
9557
9655
|
for (; ; ) {
|
|
9558
9656
|
options.signal?.throwIfAborted();
|
|
9559
9657
|
let lock;
|
|
9560
|
-
let changingReadError;
|
|
9561
9658
|
try {
|
|
9562
9659
|
lock = await acquireRefreshFileLock({
|
|
9563
9660
|
path: target,
|
|
@@ -9567,11 +9664,12 @@ async function withLock(target, options, fn) {
|
|
|
9567
9664
|
...options.onStep ? { onStep: options.onStep } : {},
|
|
9568
9665
|
...options.onRenewalTimer ? { onRenewalTimer: options.onRenewalTimer } : {}
|
|
9569
9666
|
});
|
|
9667
|
+
changingRecordError = void 0;
|
|
9570
9668
|
} catch (error) {
|
|
9571
|
-
if (!
|
|
9669
|
+
if (!isChangingLockRecord(error, target, options.name))
|
|
9572
9670
|
throw error;
|
|
9573
9671
|
lock = null;
|
|
9574
|
-
|
|
9672
|
+
changingRecordError ??= error;
|
|
9575
9673
|
}
|
|
9576
9674
|
if (lock) {
|
|
9577
9675
|
try {
|
|
@@ -9583,21 +9681,22 @@ async function withLock(target, options, fn) {
|
|
|
9583
9681
|
}
|
|
9584
9682
|
const remaining = options.timeoutMs - (performance.now() - started);
|
|
9585
9683
|
if (remaining <= 0) {
|
|
9586
|
-
if (
|
|
9587
|
-
throw
|
|
9684
|
+
if (changingRecordError)
|
|
9685
|
+
throw changingRecordError;
|
|
9588
9686
|
throw new LockContentionError({
|
|
9589
9687
|
target,
|
|
9590
9688
|
name: options.name,
|
|
9591
9689
|
timeoutMs: options.timeoutMs
|
|
9592
9690
|
});
|
|
9593
9691
|
}
|
|
9594
|
-
await new Promise((
|
|
9692
|
+
await new Promise((resolve24) => setTimeout(resolve24, Math.min(25, Math.ceil(remaining))));
|
|
9595
9693
|
}
|
|
9596
9694
|
}
|
|
9597
9695
|
var LockContentionError, LockOwnershipError;
|
|
9598
9696
|
var init_with_lock = __esm({
|
|
9599
9697
|
"../core/dist/common-auth-embedded/fs/with-lock.js"() {
|
|
9600
9698
|
"use strict";
|
|
9699
|
+
init_lock_record();
|
|
9601
9700
|
init_private_files();
|
|
9602
9701
|
init_refresh_file_lock();
|
|
9603
9702
|
LockContentionError = class extends Error {
|
|
@@ -9680,7 +9779,7 @@ async function acquirePoolLock(spec, defaults, env3) {
|
|
|
9680
9779
|
});
|
|
9681
9780
|
}
|
|
9682
9781
|
const jitter = Math.floor(Math.random() * (options.retryMs + 1));
|
|
9683
|
-
await new Promise((
|
|
9782
|
+
await new Promise((resolve24) => setTimeout(resolve24, Math.min(options.retryMs + jitter, remaining)));
|
|
9684
9783
|
}
|
|
9685
9784
|
}
|
|
9686
9785
|
function definedOnly(spec) {
|
|
@@ -12574,7 +12673,7 @@ var init_redact = __esm({
|
|
|
12574
12673
|
// ../core/dist/common-auth-embedded/logger/engine.js
|
|
12575
12674
|
import { appendFileSync, chmodSync, existsSync, renameSync, statSync } from "node:fs";
|
|
12576
12675
|
import { open as open5 } from "node:fs/promises";
|
|
12577
|
-
import { dirname as dirname8, resolve as
|
|
12676
|
+
import { dirname as dirname8, resolve as resolve5 } from "node:path";
|
|
12578
12677
|
function chmodPrivate(path2) {
|
|
12579
12678
|
try {
|
|
12580
12679
|
chmodSync(path2, 384);
|
|
@@ -12625,7 +12724,7 @@ async function openWindowsFile(sink, file) {
|
|
|
12625
12724
|
return sink.handle;
|
|
12626
12725
|
}
|
|
12627
12726
|
async function flushWindowsFile(sink, file, text2) {
|
|
12628
|
-
file =
|
|
12727
|
+
file = resolve5(file);
|
|
12629
12728
|
try {
|
|
12630
12729
|
if (sink.file !== file)
|
|
12631
12730
|
await closeWindowsFile(sink);
|
|
@@ -13001,11 +13100,11 @@ var init_quota_writer = __esm({
|
|
|
13001
13100
|
const left = deadline - performance.now();
|
|
13002
13101
|
if (left <= 0)
|
|
13003
13102
|
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);
|
|
13004
|
-
await new Promise((
|
|
13103
|
+
await new Promise((resolve24) => {
|
|
13005
13104
|
const done = () => {
|
|
13006
13105
|
clearTimeout(timer);
|
|
13007
13106
|
this.wake.delete(done);
|
|
13008
|
-
|
|
13107
|
+
resolve24();
|
|
13009
13108
|
};
|
|
13010
13109
|
const timer = setTimeout(done, left);
|
|
13011
13110
|
this.wake.add(done);
|
|
@@ -13398,7 +13497,7 @@ var init_refresh = __esm({
|
|
|
13398
13497
|
|
|
13399
13498
|
// ../core/dist/common-auth-embedded/fs/file-read-cache.js
|
|
13400
13499
|
import { lstat as lstat4, stat as stat4 } from "node:fs/promises";
|
|
13401
|
-
import { resolve as
|
|
13500
|
+
import { resolve as resolve6 } from "node:path";
|
|
13402
13501
|
async function identity(path2, followSymlinks) {
|
|
13403
13502
|
try {
|
|
13404
13503
|
const metadata = await (followSymlinks ? stat4(path2) : lstat4(path2));
|
|
@@ -13423,7 +13522,7 @@ var init_file_read_cache = __esm({
|
|
|
13423
13522
|
this.#followSymlinks = options.followSymlinks ?? false;
|
|
13424
13523
|
}
|
|
13425
13524
|
async read(paths, read, validateHit) {
|
|
13426
|
-
const resolvedPaths = paths.map((path2) =>
|
|
13525
|
+
const resolvedPaths = paths.map((path2) => resolve6(path2));
|
|
13427
13526
|
const key = JSON.stringify(resolvedPaths);
|
|
13428
13527
|
const probed = await Promise.all(resolvedPaths.map((path2) => identity(path2, this.#followSymlinks)));
|
|
13429
13528
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -15612,9 +15711,17 @@ var init_availability = __esm({
|
|
|
15612
15711
|
ERR_PRIVATE_FILES_SECURITY: "answered"
|
|
15613
15712
|
});
|
|
15614
15713
|
ClaustrumUnreachableError = class extends ClaustrumConsumerError {
|
|
15615
|
-
|
|
15714
|
+
/**
|
|
15715
|
+
* Non-secret host connection diagnostic. A missing accessor can recover
|
|
15716
|
+
* once the host bridge installs; a failed accessor could not provide a client.
|
|
15717
|
+
* Other unreachable failures leave this unset. Never use adapter error text.
|
|
15718
|
+
*/
|
|
15719
|
+
reason;
|
|
15720
|
+
constructor(reason) {
|
|
15616
15721
|
super("unavailable", "Claustrum scoped operation unavailable");
|
|
15617
15722
|
this.name = "ClaustrumUnreachableError";
|
|
15723
|
+
if (reason === "host-accessor-missing" || reason === "host-accessor-failed")
|
|
15724
|
+
this.reason = reason;
|
|
15618
15725
|
}
|
|
15619
15726
|
};
|
|
15620
15727
|
}
|
|
@@ -15635,7 +15742,7 @@ function hostError(error) {
|
|
|
15635
15742
|
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"))
|
|
15636
15743
|
return new ClaustrumCredentialError2(value.code, value.class, value.action);
|
|
15637
15744
|
if (value.name === "ClaustrumUnreachableError" || typeof value.code === "string" && classifyVaultFailure(Object.assign(new Error(), { code: value.code })) === "unreachable")
|
|
15638
|
-
return new ClaustrumUnreachableError();
|
|
15745
|
+
return new ClaustrumUnreachableError(value.reason === "host-accessor-missing" || value.reason === "host-accessor-failed" ? value.reason : void 0);
|
|
15639
15746
|
return error;
|
|
15640
15747
|
}
|
|
15641
15748
|
function call(operation) {
|
|
@@ -15701,14 +15808,15 @@ function connectVaultHost(pluginId) {
|
|
|
15701
15808
|
throw new ClaustrumUnreachableError();
|
|
15702
15809
|
try {
|
|
15703
15810
|
const accessor = globalThis[/* @__PURE__ */ Symbol.for("cortexkit.vault")];
|
|
15704
|
-
if (typeof accessor
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
15811
|
+
if (typeof accessor === "function") {
|
|
15812
|
+
const client = wrapHostClient(accessor(pluginId));
|
|
15813
|
+
hostClients.add(client);
|
|
15814
|
+
return client;
|
|
15815
|
+
}
|
|
15709
15816
|
} catch {
|
|
15710
|
-
throw new ClaustrumUnreachableError();
|
|
15817
|
+
throw new ClaustrumUnreachableError("host-accessor-failed");
|
|
15711
15818
|
}
|
|
15819
|
+
throw new ClaustrumUnreachableError("host-accessor-missing");
|
|
15712
15820
|
}
|
|
15713
15821
|
var VAULT_HOST_STATUS, VAULT_HOST_CONNECT_REFUSAL, hostClients;
|
|
15714
15822
|
var init_host = __esm({
|
|
@@ -16044,7 +16152,7 @@ async function select(terminal, items, options) {
|
|
|
16044
16152
|
writeLine("");
|
|
16045
16153
|
renderedLines = lines;
|
|
16046
16154
|
};
|
|
16047
|
-
return new Promise((
|
|
16155
|
+
return new Promise((resolve24) => {
|
|
16048
16156
|
const wasRaw = stdin.isRaw ?? false;
|
|
16049
16157
|
const cleanup2 = () => {
|
|
16050
16158
|
if (cleaned)
|
|
@@ -16064,7 +16172,7 @@ async function select(terminal, items, options) {
|
|
|
16064
16172
|
};
|
|
16065
16173
|
const finish = (value) => {
|
|
16066
16174
|
cleanup2();
|
|
16067
|
-
|
|
16175
|
+
resolve24(value);
|
|
16068
16176
|
};
|
|
16069
16177
|
const onSignal = () => finish(null);
|
|
16070
16178
|
const onKey = (data) => {
|
|
@@ -16104,7 +16212,7 @@ async function select(terminal, items, options) {
|
|
|
16104
16212
|
stdin.setRawMode(true);
|
|
16105
16213
|
} catch {
|
|
16106
16214
|
cleanup2();
|
|
16107
|
-
|
|
16215
|
+
resolve24(null);
|
|
16108
16216
|
return;
|
|
16109
16217
|
}
|
|
16110
16218
|
stdin.resume();
|
|
@@ -16840,7 +16948,7 @@ var init_watch = __esm({
|
|
|
16840
16948
|
});
|
|
16841
16949
|
|
|
16842
16950
|
// ../core/dist/common-auth-embedded/claustrum/insula.js
|
|
16843
|
-
import { resolve as
|
|
16951
|
+
import { resolve as resolve7 } from "node:path";
|
|
16844
16952
|
import { storeIdentity } from "@cortexkit/claustrum-client";
|
|
16845
16953
|
import { SubcClient } from "@cortexkit/subc-client";
|
|
16846
16954
|
function insulaUsageTransport(options) {
|
|
@@ -16968,8 +17076,8 @@ function refusalCode(error) {
|
|
|
16968
17076
|
}
|
|
16969
17077
|
function acquireInsulaQuotaSource(transport, tokenPath) {
|
|
16970
17078
|
const key = JSON.stringify([
|
|
16971
|
-
|
|
16972
|
-
|
|
17079
|
+
resolve7(transport.connectionFile),
|
|
17080
|
+
resolve7(tokenPath)
|
|
16973
17081
|
]);
|
|
16974
17082
|
let shared3 = sources.get(key);
|
|
16975
17083
|
if (!shared3) {
|
|
@@ -17283,7 +17391,7 @@ var init_any_signal = __esm({
|
|
|
17283
17391
|
import { createHash as createHash5, randomBytes as randomBytes2, randomUUID as randomUUID10 } from "node:crypto";
|
|
17284
17392
|
import { constants as fsConstants } from "node:fs";
|
|
17285
17393
|
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";
|
|
17286
|
-
import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as
|
|
17394
|
+
import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as resolve8 } from "node:path";
|
|
17287
17395
|
import { ClaustrumCredentialError as ClaustrumCredentialError3, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
|
|
17288
17396
|
function classifyEnrollmentError(error) {
|
|
17289
17397
|
if (!(error instanceof ClaustrumCredentialError3))
|
|
@@ -17302,6 +17410,10 @@ function enrollmentName(plugin, host) {
|
|
|
17302
17410
|
throw new ClaustrumConsumerError("invalid-state", "Claustrum enrollment names use lowercase letters, digits and dashes");
|
|
17303
17411
|
return `${plugin}-${host}`;
|
|
17304
17412
|
}
|
|
17413
|
+
function validEnrollmentDisplayName(displayName) {
|
|
17414
|
+
const length = Array.from(displayName).length;
|
|
17415
|
+
return length >= 1 && length <= 40 && !/[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\u200b-\u200d\u2060\ufeff]/u.test(displayName);
|
|
17416
|
+
}
|
|
17305
17417
|
function connectClaustrumEnrollmentClient(options) {
|
|
17306
17418
|
return ClaustrumWireClient.connect(options);
|
|
17307
17419
|
}
|
|
@@ -17317,7 +17429,7 @@ function hostEnrollmentPaths(input) {
|
|
|
17317
17429
|
const override = input.override?.trim();
|
|
17318
17430
|
if (override && !isAbsolute2(override) && !input.cwd)
|
|
17319
17431
|
throw new ClaustrumConsumerError("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
17320
|
-
const tokenPath = override ? isAbsolute2(override) ? override :
|
|
17432
|
+
const tokenPath = override ? isAbsolute2(override) ? override : resolve8(input.cwd, override) : join7(input.stateDir, `${input.host}-enrollment.json`);
|
|
17321
17433
|
return getClaustrumEnrollmentPaths(tokenPath);
|
|
17322
17434
|
}
|
|
17323
17435
|
function isRecord6(value) {
|
|
@@ -17784,15 +17896,19 @@ var init_enrollment = __esm({
|
|
|
17784
17896
|
#client;
|
|
17785
17897
|
#paths;
|
|
17786
17898
|
#proposedName;
|
|
17899
|
+
#displayName;
|
|
17787
17900
|
#now;
|
|
17788
17901
|
#mintSecret;
|
|
17789
17902
|
#writeTokenFile;
|
|
17790
17903
|
#ancestorOptions;
|
|
17791
17904
|
constructor(options) {
|
|
17905
|
+
if (options.displayName !== void 0 && !validEnrollmentDisplayName(options.displayName))
|
|
17906
|
+
throw new ClaustrumConsumerError("invalid-state", "invalid Claustrum enrollment display name");
|
|
17792
17907
|
this.#ancestorOptions = options.ancestorOptions ?? {};
|
|
17793
17908
|
this.#client = options.client;
|
|
17794
17909
|
this.#paths = options.paths;
|
|
17795
17910
|
this.#proposedName = options.proposedName;
|
|
17911
|
+
this.#displayName = options.displayName;
|
|
17796
17912
|
this.#now = options.now ?? Date.now;
|
|
17797
17913
|
this.#mintSecret = options.mintSecret ?? (() => randomBytes2(32).toString("hex"));
|
|
17798
17914
|
this.#writeTokenFile = options.writeTokenFile ?? writeEnrollmentTokenFile;
|
|
@@ -17882,10 +17998,23 @@ var init_enrollment = __esm({
|
|
|
17882
17998
|
if (!state.requestId) {
|
|
17883
17999
|
try {
|
|
17884
18000
|
const requestSecretHash = createHash5("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
|
|
17885
|
-
const
|
|
18001
|
+
const proposal = {
|
|
17886
18002
|
name: state.proposedName,
|
|
17887
18003
|
requestSecretHash
|
|
17888
|
-
}
|
|
18004
|
+
};
|
|
18005
|
+
let proposed;
|
|
18006
|
+
try {
|
|
18007
|
+
proposed = await this.#client.enrollPropose({
|
|
18008
|
+
...proposal,
|
|
18009
|
+
...this.#displayName !== void 0 && {
|
|
18010
|
+
displayName: this.#displayName
|
|
18011
|
+
}
|
|
18012
|
+
});
|
|
18013
|
+
} catch (error) {
|
|
18014
|
+
if (this.#displayName === void 0 || !(error instanceof ClaustrumCredentialError3) || error.code !== "invalid_params")
|
|
18015
|
+
throw error;
|
|
18016
|
+
proposed = await this.#client.enrollPropose(proposal);
|
|
18017
|
+
}
|
|
17889
18018
|
state = {
|
|
17890
18019
|
...state,
|
|
17891
18020
|
requestId: proposed.requestId,
|
|
@@ -18052,10 +18181,10 @@ async function drainShutdown(pending, onTimeout) {
|
|
|
18052
18181
|
try {
|
|
18053
18182
|
await Promise.race([
|
|
18054
18183
|
drained,
|
|
18055
|
-
new Promise((
|
|
18184
|
+
new Promise((resolve24) => {
|
|
18056
18185
|
timer = setTimeout(() => {
|
|
18057
18186
|
expired = true;
|
|
18058
|
-
|
|
18187
|
+
resolve24();
|
|
18059
18188
|
}, 2e3);
|
|
18060
18189
|
})
|
|
18061
18190
|
]);
|
|
@@ -18399,8 +18528,15 @@ var init_custody = __esm({
|
|
|
18399
18528
|
this.#warnShutdown = shutdownWarning(this.#logger);
|
|
18400
18529
|
this.#setTimeout = options.setTimeoutImpl ?? setTimeout;
|
|
18401
18530
|
this.#clearTimeout = options.clearTimeoutImpl ?? clearTimeout;
|
|
18531
|
+
const currentClient = () => this.#client;
|
|
18402
18532
|
this.#usage = new ScopedUsageReporter({
|
|
18403
|
-
client:
|
|
18533
|
+
client: {
|
|
18534
|
+
// Queued readings follow a replacement without losing client capability checks.
|
|
18535
|
+
get reportUsageScoped() {
|
|
18536
|
+
const client = currentClient();
|
|
18537
|
+
return client.reportUsageScoped?.bind(client);
|
|
18538
|
+
}
|
|
18539
|
+
},
|
|
18404
18540
|
owns: (id) => this.#usageServed.has(id),
|
|
18405
18541
|
token: async () => hasVaultHost() ? "" : checkedEnrollmentToken(await this.#readToken()),
|
|
18406
18542
|
logger: this.#logger,
|
|
@@ -18408,12 +18544,30 @@ var init_custody = __esm({
|
|
|
18408
18544
|
clearTimeout: this.#clearTimeout
|
|
18409
18545
|
});
|
|
18410
18546
|
}
|
|
18547
|
+
/**
|
|
18548
|
+
* Replace the connection to the same vault without discarding receipts or
|
|
18549
|
+
* their enrollment tokens. Open roster watches restart on the new client;
|
|
18550
|
+
* their existing handles remain usable. Passing the current client does nothing.
|
|
18551
|
+
* Neither client is closed here: the caller closes the old one, and custody's
|
|
18552
|
+
* close()/dispose() still closes the client it holds at shutdown.
|
|
18553
|
+
* While hosted, next must come from connectVaultHost, as in the constructor.
|
|
18554
|
+
*/
|
|
18555
|
+
replaceClient(next) {
|
|
18556
|
+
this.#check();
|
|
18557
|
+
if (next === this.#client)
|
|
18558
|
+
return;
|
|
18559
|
+
if (hasVaultHost() && !isVaultHostClient(next))
|
|
18560
|
+
throw new ClaustrumUnreachableError();
|
|
18561
|
+
this.#client = next;
|
|
18562
|
+
for (const watch of this.#watches)
|
|
18563
|
+
watch.restart();
|
|
18564
|
+
}
|
|
18411
18565
|
/** A watch losing its transport is the same outage as an unreachable read. */
|
|
18412
18566
|
transportLost(error) {
|
|
18413
18567
|
if (this.#closed || this.#outage)
|
|
18414
18568
|
return;
|
|
18415
18569
|
this.#outage = true;
|
|
18416
|
-
this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError();
|
|
18570
|
+
this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
|
|
18417
18571
|
this.#logger.warn("serving kept vault receipt", { reason: "unreachable" });
|
|
18418
18572
|
this.#scheduleProbe();
|
|
18419
18573
|
}
|
|
@@ -18511,7 +18665,7 @@ var init_custody = __esm({
|
|
|
18511
18665
|
if (error instanceof ClaustrumCredentialError5)
|
|
18512
18666
|
throw error;
|
|
18513
18667
|
if (classifyVaultFailure(error) === "unreachable")
|
|
18514
|
-
throw new ClaustrumUnreachableError();
|
|
18668
|
+
throw new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
|
|
18515
18669
|
throw new ClaustrumConsumerError("unavailable", "Claustrum scoped operation unavailable");
|
|
18516
18670
|
} finally {
|
|
18517
18671
|
removeAbortListener?.();
|
|
@@ -18727,7 +18881,7 @@ var init_custody = __esm({
|
|
|
18727
18881
|
if (kept.since === null)
|
|
18728
18882
|
kept.since = this.#now();
|
|
18729
18883
|
const attempt = Object.freeze(Object.defineProperty({ ...kept.attempt, fromKeptReceipt: true }, "accessToken", { value: kept.attempt.accessToken, enumerable: false }));
|
|
18730
|
-
this.#provenance.set(attempt, this.#provenance.get(kept.attempt) ?? { token
|
|
18884
|
+
this.#provenance.set(attempt, this.#provenance.get(kept.attempt) ?? { token });
|
|
18731
18885
|
this.#keptAttempts.set(attempt, routeId);
|
|
18732
18886
|
return attempt;
|
|
18733
18887
|
}
|
|
@@ -18788,15 +18942,15 @@ var init_custody = __esm({
|
|
|
18788
18942
|
recordVersion: served.recordVersion,
|
|
18789
18943
|
expiresAtMs
|
|
18790
18944
|
}, "accessToken", { value: accessToken, enumerable: false }));
|
|
18791
|
-
this.#provenance.set(attempt, { token
|
|
18945
|
+
this.#provenance.set(attempt, { token });
|
|
18792
18946
|
return attempt;
|
|
18793
18947
|
}
|
|
18794
18948
|
/**
|
|
18795
18949
|
* Report that a send this consumer actually made was rejected. Only a 401
|
|
18796
18950
|
* is reported (the vault refuses 429, 402 and 5xx reports), addressed by
|
|
18797
18951
|
* credential id with the exact record version that send was served, and
|
|
18798
|
-
* sent through the client
|
|
18799
|
-
* this custody did not issue is refused rather than reported.
|
|
18952
|
+
* sent through the current client with the enrollment token that authorized
|
|
18953
|
+
* it. A receipt this custody did not issue is refused rather than reported.
|
|
18800
18954
|
*/
|
|
18801
18955
|
async reportFailure(attempt, status, reporterSource) {
|
|
18802
18956
|
if (status !== 401)
|
|
@@ -18820,7 +18974,7 @@ var init_custody = __esm({
|
|
|
18820
18974
|
const pending = this.#reports.get(attempt);
|
|
18821
18975
|
if (pending)
|
|
18822
18976
|
return pending;
|
|
18823
|
-
const report = this.#call(() =>
|
|
18977
|
+
const report = this.#call(() => this.#client.reportAuthFailureScoped({
|
|
18824
18978
|
credentialId: attempt.credentialId,
|
|
18825
18979
|
enrollmentToken: provenance.token,
|
|
18826
18980
|
providerStatus: 401,
|
|
@@ -18861,34 +19015,64 @@ var init_custody = __esm({
|
|
|
18861
19015
|
*/
|
|
18862
19016
|
watchRoster(options) {
|
|
18863
19017
|
this.#check();
|
|
18864
|
-
const
|
|
18865
|
-
|
|
18866
|
-
|
|
18867
|
-
|
|
18868
|
-
|
|
18869
|
-
|
|
18870
|
-
|
|
18871
|
-
|
|
18872
|
-
|
|
18873
|
-
|
|
19018
|
+
const currentView = options.view ?? (() => this.#discoveredView);
|
|
19019
|
+
let discovering;
|
|
19020
|
+
let watch;
|
|
19021
|
+
const create = (resubscribed = false) => {
|
|
19022
|
+
const opened = new ScopedRosterWatch({
|
|
19023
|
+
client: this.#client,
|
|
19024
|
+
enrollmentToken: () => this.#token(),
|
|
19025
|
+
// Nothing observed the gap between clients, even if the view is unchanged.
|
|
19026
|
+
view: () => resubscribed ? void 0 : currentView(),
|
|
19027
|
+
discover: async (view) => {
|
|
19028
|
+
while (discovering)
|
|
19029
|
+
await discovering.catch(() => {
|
|
19030
|
+
});
|
|
19031
|
+
if (watch !== opened)
|
|
19032
|
+
return;
|
|
19033
|
+
resubscribed = false;
|
|
19034
|
+
discovering = Promise.resolve().then(() => options.onView(view));
|
|
19035
|
+
try {
|
|
19036
|
+
await discovering;
|
|
19037
|
+
} finally {
|
|
19038
|
+
discovering = void 0;
|
|
19039
|
+
}
|
|
19040
|
+
},
|
|
19041
|
+
onRefused: (error) => {
|
|
19042
|
+
this.listFailed(error);
|
|
19043
|
+
options.onRefused?.(error);
|
|
19044
|
+
},
|
|
19045
|
+
onTransportLost: () => this.transportLost(),
|
|
19046
|
+
onReachable: () => this.reachable(),
|
|
19047
|
+
onError: options.onError,
|
|
19048
|
+
onMode: options.onMode,
|
|
19049
|
+
logger: this.#logger,
|
|
19050
|
+
now: this.#now,
|
|
19051
|
+
setTimeoutImpl: this.#setTimeout,
|
|
19052
|
+
clearTimeoutImpl: this.#clearTimeout
|
|
19053
|
+
});
|
|
19054
|
+
return opened;
|
|
19055
|
+
};
|
|
19056
|
+
watch = create();
|
|
19057
|
+
const tracked = {
|
|
19058
|
+
restart: () => {
|
|
19059
|
+
const previousMode = watch.mode;
|
|
19060
|
+
watch.stop();
|
|
19061
|
+
watch = create(true);
|
|
19062
|
+
if (previousMode !== watch.mode)
|
|
19063
|
+
options.onMode?.(watch.mode);
|
|
19064
|
+
watch.start();
|
|
18874
19065
|
},
|
|
18875
|
-
|
|
18876
|
-
|
|
18877
|
-
|
|
18878
|
-
onMode: options.onMode,
|
|
18879
|
-
logger: this.#logger,
|
|
18880
|
-
now: this.#now,
|
|
18881
|
-
setTimeoutImpl: this.#setTimeout,
|
|
18882
|
-
clearTimeoutImpl: this.#clearTimeout
|
|
18883
|
-
});
|
|
18884
|
-
this.#watches.add(watch);
|
|
19066
|
+
stop: () => watch.stop()
|
|
19067
|
+
};
|
|
19068
|
+
this.#watches.add(tracked);
|
|
18885
19069
|
watch.start();
|
|
18886
19070
|
return {
|
|
18887
19071
|
get mode() {
|
|
18888
19072
|
return watch.mode;
|
|
18889
19073
|
},
|
|
18890
19074
|
close: () => {
|
|
18891
|
-
this.#watches.delete(
|
|
19075
|
+
this.#watches.delete(tracked);
|
|
18892
19076
|
watch.stop();
|
|
18893
19077
|
}
|
|
18894
19078
|
};
|
|
@@ -19028,7 +19212,7 @@ var init_interlock = __esm({
|
|
|
19028
19212
|
// ../core/dist/common-auth-embedded/claustrum/roster.js
|
|
19029
19213
|
import { createHash as createHash6 } from "node:crypto";
|
|
19030
19214
|
import { stat as stat6 } from "node:fs/promises";
|
|
19031
|
-
import { resolve as
|
|
19215
|
+
import { resolve as resolve9 } from "node:path";
|
|
19032
19216
|
function vaultRosterSeed(roster) {
|
|
19033
19217
|
return {
|
|
19034
19218
|
declined: roster.declined.map((entry) => ({ ...entry })),
|
|
@@ -19430,16 +19614,16 @@ function applyVaultQuota(current, input) {
|
|
|
19430
19614
|
};
|
|
19431
19615
|
}
|
|
19432
19616
|
function forgetPendingVaultDiscovery(path2) {
|
|
19433
|
-
pendingDiscoveries.delete(
|
|
19617
|
+
pendingDiscoveries.delete(resolve9(path2));
|
|
19434
19618
|
}
|
|
19435
19619
|
function isVaultRosterLockRefusal(path2, error) {
|
|
19436
|
-
const target =
|
|
19620
|
+
const target = resolve9(path2);
|
|
19437
19621
|
if (error instanceof ClaustrumConsumerError)
|
|
19438
19622
|
return error.kind === "roster-busy";
|
|
19439
19623
|
if (error instanceof LockContentionError || error instanceof LockOwnershipError)
|
|
19440
|
-
return
|
|
19624
|
+
return resolve9(error.details.target) === target;
|
|
19441
19625
|
if (error instanceof PrivateFileError) {
|
|
19442
|
-
const failed =
|
|
19626
|
+
const failed = resolve9(error.path);
|
|
19443
19627
|
return [WRITE_LOCK.name, DISCOVERY_LEASE.name].some((name) => {
|
|
19444
19628
|
const lock = lockPathFor(target, name);
|
|
19445
19629
|
return failed === lock || failed.startsWith(`${lock}.`);
|
|
@@ -19500,7 +19684,7 @@ async function refreshVaultRoster(options) {
|
|
|
19500
19684
|
throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
|
|
19501
19685
|
return persisted;
|
|
19502
19686
|
}
|
|
19503
|
-
const key =
|
|
19687
|
+
const key = resolve9(options.path);
|
|
19504
19688
|
const listedOver = options.listedOver;
|
|
19505
19689
|
let discovered;
|
|
19506
19690
|
try {
|
|
@@ -19624,9 +19808,9 @@ var init_roster = __esm({
|
|
|
19624
19808
|
});
|
|
19625
19809
|
|
|
19626
19810
|
// ../core/dist/common-auth-embedded/claustrum/quota-writer.js
|
|
19627
|
-
import { resolve as
|
|
19811
|
+
import { resolve as resolve10 } from "node:path";
|
|
19628
19812
|
function writerFor(path2, clock = quotaCommitTimer) {
|
|
19629
|
-
const key =
|
|
19813
|
+
const key = resolve10(path2);
|
|
19630
19814
|
let writer = writers.get(key);
|
|
19631
19815
|
if (!writer) {
|
|
19632
19816
|
writer = {
|
|
@@ -19690,7 +19874,7 @@ function orderedFields(pending) {
|
|
|
19690
19874
|
return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
|
|
19691
19875
|
}
|
|
19692
19876
|
function pendingVaultQuota(path2, roster) {
|
|
19693
|
-
const writer = writers.get(
|
|
19877
|
+
const writer = writers.get(resolve10(path2));
|
|
19694
19878
|
if (writer) {
|
|
19695
19879
|
for (const field of orderedFields(writer.pending)) {
|
|
19696
19880
|
if (field.priorReading)
|
|
@@ -19701,7 +19885,7 @@ function pendingVaultQuota(path2, roster) {
|
|
|
19701
19885
|
return roster;
|
|
19702
19886
|
}
|
|
19703
19887
|
function hasPendingVaultQuota(path2) {
|
|
19704
|
-
return !!writers.get(
|
|
19888
|
+
return !!writers.get(resolve10(path2))?.pending.size;
|
|
19705
19889
|
}
|
|
19706
19890
|
function schedule(writer, delay3) {
|
|
19707
19891
|
if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
|
|
@@ -19766,7 +19950,7 @@ function flush(writer) {
|
|
|
19766
19950
|
return writer.running;
|
|
19767
19951
|
}
|
|
19768
19952
|
async function drainVaultQuota(path2, timeoutMs = 1e3) {
|
|
19769
|
-
const key =
|
|
19953
|
+
const key = resolve10(path2);
|
|
19770
19954
|
const writer = writers.get(key);
|
|
19771
19955
|
if (!writer)
|
|
19772
19956
|
return;
|
|
@@ -19914,7 +20098,7 @@ var init_consumer = __esm({
|
|
|
19914
20098
|
this.#shutdown.signal,
|
|
19915
20099
|
...signal ? [signal] : []
|
|
19916
20100
|
]);
|
|
19917
|
-
return new Promise((
|
|
20101
|
+
return new Promise((resolve24, reject) => {
|
|
19918
20102
|
const cleanup2 = () => {
|
|
19919
20103
|
combined.signal.removeEventListener("abort", abort);
|
|
19920
20104
|
combined.dispose();
|
|
@@ -19929,7 +20113,7 @@ var init_consumer = __esm({
|
|
|
19929
20113
|
if (combined.signal.aborted)
|
|
19930
20114
|
reject(combined.signal.reason);
|
|
19931
20115
|
else
|
|
19932
|
-
|
|
20116
|
+
resolve24(value);
|
|
19933
20117
|
}, (error) => {
|
|
19934
20118
|
cleanup2();
|
|
19935
20119
|
reject(error);
|
|
@@ -20674,7 +20858,7 @@ var init_consumer = __esm({
|
|
|
20674
20858
|
import { createHash as createHash7 } from "node:crypto";
|
|
20675
20859
|
import { channel as channel2 } from "node:diagnostics_channel";
|
|
20676
20860
|
import { readdir, stat as stat7 } from "node:fs/promises";
|
|
20677
|
-
import { dirname as dirname10, join as join8, resolve as
|
|
20861
|
+
import { dirname as dirname10, join as join8, resolve as resolve11 } from "node:path";
|
|
20678
20862
|
function canonicalJson3(value, path2 = /* @__PURE__ */ new Set()) {
|
|
20679
20863
|
if (value === null)
|
|
20680
20864
|
return "null";
|
|
@@ -20735,12 +20919,12 @@ function unreachableConnect2() {
|
|
|
20735
20919
|
return new ClaustrumUnreachableError();
|
|
20736
20920
|
}
|
|
20737
20921
|
function untilAborted(pending, signal) {
|
|
20738
|
-
return new Promise((
|
|
20922
|
+
return new Promise((resolve24, reject) => {
|
|
20739
20923
|
const abort = () => reject(signal.reason);
|
|
20740
20924
|
signal.addEventListener("abort", abort, { once: true });
|
|
20741
20925
|
pending.then((value) => {
|
|
20742
20926
|
signal.removeEventListener("abort", abort);
|
|
20743
|
-
|
|
20927
|
+
resolve24(value);
|
|
20744
20928
|
}, (error) => {
|
|
20745
20929
|
signal.removeEventListener("abort", abort);
|
|
20746
20930
|
reject(error);
|
|
@@ -20898,7 +21082,7 @@ var init_hub = __esm({
|
|
|
20898
21082
|
};
|
|
20899
21083
|
const { consumer, hooks } = createHubMember(port, consumerOptions);
|
|
20900
21084
|
entry.hooks = hooks;
|
|
20901
|
-
const path2 =
|
|
21085
|
+
const path2 = resolve11(entry.path);
|
|
20902
21086
|
const subscribers = sharedRosters.get(path2) ?? /* @__PURE__ */ new Set();
|
|
20903
21087
|
const install = (roster) => {
|
|
20904
21088
|
if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
|
|
@@ -20929,7 +21113,7 @@ var init_hub = __esm({
|
|
|
20929
21113
|
return;
|
|
20930
21114
|
entry.seen = JSON.stringify(decodedVaultRoster(roster));
|
|
20931
21115
|
entry.hooks?.install(roster);
|
|
20932
|
-
for (const install of sharedRosters.get(
|
|
21116
|
+
for (const install of sharedRosters.get(resolve11(entry.path)) ?? []) {
|
|
20933
21117
|
if (!this.#live(generation))
|
|
20934
21118
|
return;
|
|
20935
21119
|
if (install !== entry.receiveRoster)
|
|
@@ -21732,6 +21916,7 @@ __export(claustrum_exports, {
|
|
|
21732
21916
|
reorderVaultRoster: () => reorderVaultRoster,
|
|
21733
21917
|
resetClaustrumEnrollmentState: () => resetClaustrumEnrollmentState,
|
|
21734
21918
|
resolveVaultPrimary: () => resolveVaultPrimary,
|
|
21919
|
+
validEnrollmentDisplayName: () => validEnrollmentDisplayName,
|
|
21735
21920
|
vaultAuthority: () => vaultAuthority,
|
|
21736
21921
|
vaultRosterSeed: () => vaultRosterSeed,
|
|
21737
21922
|
vaultRoutingRows: () => vaultRoutingRows
|
|
@@ -21988,7 +22173,7 @@ var init_lock = __esm({
|
|
|
21988
22173
|
import { createHash as createHash8 } from "node:crypto";
|
|
21989
22174
|
import { constants as constants2 } from "node:fs";
|
|
21990
22175
|
import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
|
|
21991
|
-
import { dirname as dirname11, resolve as
|
|
22176
|
+
import { dirname as dirname11, resolve as resolve12 } from "node:path";
|
|
21992
22177
|
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
21993
22178
|
function rootSpans(text2) {
|
|
21994
22179
|
let i = text2.indexOf("{") + 1;
|
|
@@ -22189,8 +22374,8 @@ function createPiSlot(options, onStep, hooks) {
|
|
|
22189
22374
|
if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
|
|
22190
22375
|
throw new PiSlotError("invalid-options");
|
|
22191
22376
|
}
|
|
22192
|
-
const authPath =
|
|
22193
|
-
const stashPath =
|
|
22377
|
+
const authPath = resolve12(options.authPath);
|
|
22378
|
+
const stashPath = resolve12(options.stashPath);
|
|
22194
22379
|
if (authPath === stashPath || stashPath === `${authPath}.lock`) {
|
|
22195
22380
|
throw new PiSlotError("invalid-options");
|
|
22196
22381
|
}
|
|
@@ -22458,8 +22643,8 @@ function getDefaultTierId(allowedTiers) {
|
|
|
22458
22643
|
return allowedTiers[0]?.id;
|
|
22459
22644
|
}
|
|
22460
22645
|
function wait(ms) {
|
|
22461
|
-
return new Promise((
|
|
22462
|
-
setTimeout(
|
|
22646
|
+
return new Promise((resolve24) => {
|
|
22647
|
+
setTimeout(resolve24, ms);
|
|
22463
22648
|
});
|
|
22464
22649
|
}
|
|
22465
22650
|
function extractManagedProjectId(payload) {
|
|
@@ -23481,7 +23666,7 @@ var init_capture_sink2 = __esm({
|
|
|
23481
23666
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
23482
23667
|
import { lstat as lstat6, readFile as readFile7, rename as rename8, unlink as unlink8 } from "node:fs/promises";
|
|
23483
23668
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
23484
|
-
import { dirname as dirname13, join as join10, resolve as
|
|
23669
|
+
import { dirname as dirname13, join as join10, resolve as resolve13 } from "node:path";
|
|
23485
23670
|
function ioCode2(detail) {
|
|
23486
23671
|
if (detail?.reason === "io-error") {
|
|
23487
23672
|
if (detail.win32Code === 2 || detail.win32Code === 3)
|
|
@@ -23531,7 +23716,7 @@ async function privateOperation2(path2, stage, operation) {
|
|
|
23531
23716
|
}
|
|
23532
23717
|
}
|
|
23533
23718
|
async function verifySafeDirectory2(path2, options) {
|
|
23534
|
-
path2 =
|
|
23719
|
+
path2 = resolve13(path2);
|
|
23535
23720
|
options ??= safeParentOptionsForTest2;
|
|
23536
23721
|
await privateOperation2(path2, "safe-parent", async () => {
|
|
23537
23722
|
const result = await (await loadBackend2()).verifySafeParent(path2, options);
|
|
@@ -23546,7 +23731,7 @@ async function verifySafeDirectory2(path2, options) {
|
|
|
23546
23731
|
});
|
|
23547
23732
|
}
|
|
23548
23733
|
async function verifyPrivate2(path2, kind, migrate = false) {
|
|
23549
|
-
path2 =
|
|
23734
|
+
path2 = resolve13(path2);
|
|
23550
23735
|
if (kind === "directory")
|
|
23551
23736
|
return verifySafeDirectory2(path2);
|
|
23552
23737
|
await privateOperation2(path2, "verify", async () => {
|
|
@@ -23581,7 +23766,7 @@ async function verifyPrivate2(path2, kind, migrate = false) {
|
|
|
23581
23766
|
});
|
|
23582
23767
|
}
|
|
23583
23768
|
async function ensurePrivateDirectory2(path2, _migrate = false, options) {
|
|
23584
|
-
path2 =
|
|
23769
|
+
path2 = resolve13(path2);
|
|
23585
23770
|
await privateOperation2(path2, "directory", async () => {
|
|
23586
23771
|
const api = await loadBackend2();
|
|
23587
23772
|
try {
|
|
@@ -23612,7 +23797,7 @@ async function readPrivateText2(path2, migrate = false) {
|
|
|
23612
23797
|
async function readPrivateBuffer2(path2, migrate = false) {
|
|
23613
23798
|
if (!windowsPrivateFiles2)
|
|
23614
23799
|
return readFile7(path2);
|
|
23615
|
-
path2 =
|
|
23800
|
+
path2 = resolve13(path2);
|
|
23616
23801
|
if (migrate) {
|
|
23617
23802
|
await verifySafeDirectory2(dirname13(path2));
|
|
23618
23803
|
await verifyPrivate2(path2, "file", true);
|
|
@@ -23620,20 +23805,20 @@ async function readPrivateBuffer2(path2, migrate = false) {
|
|
|
23620
23805
|
return privateOperation2(path2, "read", async () => (await loadBackend2()).readOwnerOnly(path2));
|
|
23621
23806
|
}
|
|
23622
23807
|
async function createPrivateBytes2(path2, bytes) {
|
|
23623
|
-
await verifySafeDirectory2(dirname13(
|
|
23808
|
+
await verifySafeDirectory2(dirname13(resolve13(path2)));
|
|
23624
23809
|
await privateOperation2(path2, "create", async () => {
|
|
23625
|
-
await (await loadBackend2()).createPrivateFile(
|
|
23810
|
+
await (await loadBackend2()).createPrivateFile(resolve13(path2), bytes);
|
|
23626
23811
|
});
|
|
23627
23812
|
}
|
|
23628
23813
|
async function createPrivateDirectoryExclusive2(path2) {
|
|
23629
|
-
await verifySafeDirectory2(dirname13(
|
|
23814
|
+
await verifySafeDirectory2(dirname13(resolve13(path2)));
|
|
23630
23815
|
await privateOperation2(path2, "directory-create", async () => {
|
|
23631
|
-
await (await loadBackend2()).createOwnerOnly(
|
|
23816
|
+
await (await loadBackend2()).createOwnerOnly(resolve13(path2), { kind: "dir" });
|
|
23632
23817
|
});
|
|
23633
23818
|
}
|
|
23634
23819
|
async function replaceWindowsFile2(from, to, options = {}) {
|
|
23635
|
-
from =
|
|
23636
|
-
to =
|
|
23820
|
+
from = resolve13(from);
|
|
23821
|
+
to = resolve13(to);
|
|
23637
23822
|
const now = options.now ?? (() => performance.now());
|
|
23638
23823
|
const start = now();
|
|
23639
23824
|
const leaseDeadline = options.deadline ?? Infinity;
|
|
@@ -23676,7 +23861,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
|
|
|
23676
23861
|
throw error;
|
|
23677
23862
|
}
|
|
23678
23863
|
async function writePrivateAtomic2(path2, bytes, options = {}) {
|
|
23679
|
-
path2 =
|
|
23864
|
+
path2 = resolve13(path2);
|
|
23680
23865
|
await ensurePrivateDirectory2(dirname13(path2));
|
|
23681
23866
|
try {
|
|
23682
23867
|
await verifyPrivate2(path2, "file", true);
|
|
@@ -23684,7 +23869,7 @@ async function writePrivateAtomic2(path2, bytes, options = {}) {
|
|
|
23684
23869
|
if (error.code !== "ENOENT")
|
|
23685
23870
|
throw error;
|
|
23686
23871
|
}
|
|
23687
|
-
const stage =
|
|
23872
|
+
const stage = resolve13(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
|
|
23688
23873
|
if (dirname13(stage) !== dirname13(path2))
|
|
23689
23874
|
throw new PrivateFileError2(path2, "stage-directory", { code: "EXDEV" });
|
|
23690
23875
|
let created = false;
|
|
@@ -23850,7 +24035,7 @@ var init_redact2 = __esm({
|
|
|
23850
24035
|
// src/common-auth-embedded/logger/engine.js
|
|
23851
24036
|
import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
|
|
23852
24037
|
import { open as open8 } from "node:fs/promises";
|
|
23853
|
-
import { dirname as dirname14, resolve as
|
|
24038
|
+
import { dirname as dirname14, resolve as resolve14 } from "node:path";
|
|
23854
24039
|
function chmodPrivate2(path2) {
|
|
23855
24040
|
try {
|
|
23856
24041
|
chmodSync2(path2, 384);
|
|
@@ -23901,7 +24086,7 @@ async function openWindowsFile2(sink, file) {
|
|
|
23901
24086
|
return sink.handle;
|
|
23902
24087
|
}
|
|
23903
24088
|
async function flushWindowsFile2(sink, file, text2) {
|
|
23904
|
-
file =
|
|
24089
|
+
file = resolve14(file);
|
|
23905
24090
|
try {
|
|
23906
24091
|
if (sink.file !== file)
|
|
23907
24092
|
await closeWindowsFile2(sink);
|
|
@@ -24148,13 +24333,17 @@ var init_logger3 = __esm({
|
|
|
24148
24333
|
|
|
24149
24334
|
// src/logging/provider-key-policy.ts
|
|
24150
24335
|
function isProviderSecretKey(normalizedKey) {
|
|
24151
|
-
return /token|refresh|access|project|fingerprint|deviceid|sessionid|sessiontoken|secret|password|apikey|clientsecret/.test(
|
|
24336
|
+
return /token|refresh|access|project|fingerprint|deviceid|sessionid|sessiontoken|secret|password|apikey|clientsecret|callback|redirecturl|authorizationcode/.test(
|
|
24152
24337
|
normalizedKey
|
|
24153
24338
|
);
|
|
24154
24339
|
}
|
|
24340
|
+
var OAUTH_REDIRECT_VALUE_PATTERNS;
|
|
24155
24341
|
var init_provider_key_policy = __esm({
|
|
24156
24342
|
"src/logging/provider-key-policy.ts"() {
|
|
24157
24343
|
"use strict";
|
|
24344
|
+
OAUTH_REDIRECT_VALUE_PATTERNS = [
|
|
24345
|
+
/https?:\/\/[^\s<>"']*[?&](?:code|state)=[^\s<>"']*/gi
|
|
24346
|
+
];
|
|
24158
24347
|
}
|
|
24159
24348
|
});
|
|
24160
24349
|
|
|
@@ -24218,7 +24407,7 @@ import { randomUUID as randomUUID12 } from "node:crypto";
|
|
|
24218
24407
|
import { realpathSync, rmSync } from "node:fs";
|
|
24219
24408
|
import { chmod as chmod3, mkdir as mkdir11, readFile as readFile8, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
|
|
24220
24409
|
import { homedir as homedir2 } from "node:os";
|
|
24221
|
-
import { join as join11, resolve as
|
|
24410
|
+
import { join as join11, resolve as resolve15 } from "node:path";
|
|
24222
24411
|
function processHeartbeatDir() {
|
|
24223
24412
|
const base = process.env.XDG_STATE_HOME || join11(homedir2(), ".local", "state");
|
|
24224
24413
|
return join11(base, "cortexkit", "antigravity-auth", "processes");
|
|
@@ -24231,7 +24420,7 @@ function processConfigFolderKey() {
|
|
|
24231
24420
|
try {
|
|
24232
24421
|
return realpathSync.native(folder);
|
|
24233
24422
|
} catch {
|
|
24234
|
-
return
|
|
24423
|
+
return resolve15(folder);
|
|
24235
24424
|
}
|
|
24236
24425
|
}
|
|
24237
24426
|
function processHasOlderGeneration() {
|
|
@@ -24815,7 +25004,7 @@ import {
|
|
|
24815
25004
|
stat as stat10,
|
|
24816
25005
|
unlink as unlink10
|
|
24817
25006
|
} from "node:fs/promises";
|
|
24818
|
-
import { basename as basename4, dirname as dirname15, join as join13, resolve as
|
|
25007
|
+
import { basename as basename4, dirname as dirname15, join as join13, resolve as resolve16 } from "node:path";
|
|
24819
25008
|
function refusalMessage(stateDir, errorClass2) {
|
|
24820
25009
|
if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
|
|
24821
25010
|
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.`;
|
|
@@ -25675,7 +25864,7 @@ async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
|
|
|
25675
25864
|
if (process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR) return;
|
|
25676
25865
|
const location = runtimeLayoutLocation();
|
|
25677
25866
|
const files = layoutFiles(location, accountFile);
|
|
25678
|
-
if (
|
|
25867
|
+
if (resolve16(vaultDir) !== resolve16(files.vault.next)) return;
|
|
25679
25868
|
const stateDir = location.stateHomeDir;
|
|
25680
25869
|
const marker = await readMarker(
|
|
25681
25870
|
join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
|
|
@@ -26104,7 +26293,7 @@ import {
|
|
|
26104
26293
|
writeFileSync
|
|
26105
26294
|
} from "node:fs";
|
|
26106
26295
|
import { homedir as homedir4 } from "node:os";
|
|
26107
|
-
import { dirname as dirname16, join as join14, resolve as
|
|
26296
|
+
import { dirname as dirname16, join as join14, resolve as resolve17 } from "node:path";
|
|
26108
26297
|
async function ensureGitignore(configDir) {
|
|
26109
26298
|
const gitignorePath = join14(configDir, ".gitignore");
|
|
26110
26299
|
try {
|
|
@@ -26204,8 +26393,8 @@ function migrateLegacyWindowsConfig() {
|
|
|
26204
26393
|
}
|
|
26205
26394
|
}
|
|
26206
26395
|
function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
26207
|
-
const standard =
|
|
26208
|
-
const legacy =
|
|
26396
|
+
const standard = resolve17(newPath);
|
|
26397
|
+
const legacy = resolve17(legacyPath);
|
|
26209
26398
|
if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
|
|
26210
26399
|
const standardPointer = existsSync3(accountStorePointerPath(standard));
|
|
26211
26400
|
const legacyPointer = existsSync3(accountStorePointerPath(legacy));
|
|
@@ -26227,7 +26416,7 @@ function getStoragePathWithMigration() {
|
|
|
26227
26416
|
"antigravity-accounts.json"
|
|
26228
26417
|
);
|
|
26229
26418
|
const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
|
|
26230
|
-
if (
|
|
26419
|
+
if (resolve17(anchored).toLowerCase() !== resolve17(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve17(anchored)))) {
|
|
26231
26420
|
log6.info("Using legacy Windows config path (migration failed)", {
|
|
26232
26421
|
legacyPath,
|
|
26233
26422
|
newPath
|
|
@@ -26244,7 +26433,7 @@ function accountFileForVault(configDir = getConfigDir()) {
|
|
|
26244
26433
|
const configured = join14(configDir, "antigravity-accounts.json");
|
|
26245
26434
|
if (process.platform !== "win32") return configured;
|
|
26246
26435
|
const legacyDir = getLegacyWindowsConfigDir();
|
|
26247
|
-
if (
|
|
26436
|
+
if (resolve17(configDir).toLowerCase() === resolve17(legacyDir).toLowerCase())
|
|
26248
26437
|
return configured;
|
|
26249
26438
|
const configuredVault = join14(configDir, "antigravity-auth-vault");
|
|
26250
26439
|
const legacyVault = join14(legacyDir, "antigravity-auth-vault");
|
|
@@ -26275,7 +26464,7 @@ function getStoragePath() {
|
|
|
26275
26464
|
}
|
|
26276
26465
|
async function assertLegacyPoolInUse(legacyPath) {
|
|
26277
26466
|
try {
|
|
26278
|
-
await assertLegacyAccountStorageWritable(
|
|
26467
|
+
await assertLegacyAccountStorageWritable(resolve17(legacyPath));
|
|
26279
26468
|
} catch (error) {
|
|
26280
26469
|
throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
|
|
26281
26470
|
}
|
|
@@ -26295,7 +26484,7 @@ function refusalMessage2(admission) {
|
|
|
26295
26484
|
async function bindingOf(options) {
|
|
26296
26485
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
26297
26486
|
const now = options.now ?? (() => Date.now());
|
|
26298
|
-
const legacyPath =
|
|
26487
|
+
const legacyPath = resolve17(options.legacyPath ?? getStoragePath());
|
|
26299
26488
|
return {
|
|
26300
26489
|
legacyPath,
|
|
26301
26490
|
now,
|
|
@@ -26364,7 +26553,7 @@ async function openAccountStore(options) {
|
|
|
26364
26553
|
async function initializeFreshAccountStoreFor(modules, options = {}) {
|
|
26365
26554
|
if (options.legacyPath === void 0) await prepareLocalAccountStore();
|
|
26366
26555
|
return initializeFreshAccountStore(modules, {
|
|
26367
|
-
legacyPath:
|
|
26556
|
+
legacyPath: resolve17(options.legacyPath ?? getStoragePath()),
|
|
26368
26557
|
now: options.now ?? (() => Date.now())
|
|
26369
26558
|
});
|
|
26370
26559
|
}
|
|
@@ -26410,12 +26599,12 @@ var init_storage = __esm({
|
|
|
26410
26599
|
import { createHash as createHash11 } from "node:crypto";
|
|
26411
26600
|
import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
26412
26601
|
import { homedir as homedir5 } from "node:os";
|
|
26413
|
-
import { dirname as dirname17, join as join15, resolve as
|
|
26602
|
+
import { dirname as dirname17, join as join15, resolve as resolve18 } from "node:path";
|
|
26414
26603
|
function configDirIdentity(path2) {
|
|
26415
26604
|
try {
|
|
26416
26605
|
return realpathSync2.native(path2);
|
|
26417
26606
|
} catch {
|
|
26418
|
-
return
|
|
26607
|
+
return resolve18(path2);
|
|
26419
26608
|
}
|
|
26420
26609
|
}
|
|
26421
26610
|
function decisionKey(location) {
|
|
@@ -27077,13 +27266,13 @@ function closeDebugLog() {
|
|
|
27077
27266
|
if (!state || !current) return Promise.resolve();
|
|
27078
27267
|
state.logStream = null;
|
|
27079
27268
|
if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
|
|
27080
|
-
return new Promise((
|
|
27081
|
-
current.once("close", () =>
|
|
27082
|
-
current.once("error", () =>
|
|
27269
|
+
return new Promise((resolve24) => {
|
|
27270
|
+
current.once("close", () => resolve24());
|
|
27271
|
+
current.once("error", () => resolve24());
|
|
27083
27272
|
try {
|
|
27084
27273
|
current.end();
|
|
27085
27274
|
} catch {
|
|
27086
|
-
|
|
27275
|
+
resolve24();
|
|
27087
27276
|
}
|
|
27088
27277
|
});
|
|
27089
27278
|
}
|
|
@@ -27141,6 +27330,7 @@ function createLocationLogger(options) {
|
|
|
27141
27330
|
const engine = createLoggerInstance2({
|
|
27142
27331
|
level: () => configuredLevel,
|
|
27143
27332
|
extraSecretKeys: isProviderSecretKey,
|
|
27333
|
+
extraValuePatterns: OAUTH_REDIRECT_VALUE_PATTERNS,
|
|
27144
27334
|
captureSink: ({ channel: channel3, level, message, data }) => {
|
|
27145
27335
|
const extra = data !== null && typeof data === "object" && !Array.isArray(data) ? Object.fromEntries(Object.entries(data)) : void 0;
|
|
27146
27336
|
emit({
|
|
@@ -27229,7 +27419,7 @@ var init_logger4 = __esm({
|
|
|
27229
27419
|
init_dist();
|
|
27230
27420
|
import { execFile } from "node:child_process";
|
|
27231
27421
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
27232
|
-
import { resolve as
|
|
27422
|
+
import { resolve as resolve23 } from "node:path";
|
|
27233
27423
|
import { createInterface } from "node:readline/promises";
|
|
27234
27424
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
27235
27425
|
import { promisify } from "node:util";
|
|
@@ -27637,14 +27827,14 @@ async function fetchQuotaPayloads(options) {
|
|
|
27637
27827
|
};
|
|
27638
27828
|
}
|
|
27639
27829
|
function untilQuotaAborted(pending, signal) {
|
|
27640
|
-
return new Promise((
|
|
27830
|
+
return new Promise((resolve24, reject) => {
|
|
27641
27831
|
const abort = () => reject(signal.reason);
|
|
27642
27832
|
if (signal.aborted) abort();
|
|
27643
27833
|
else signal.addEventListener("abort", abort, { once: true });
|
|
27644
27834
|
void pending.then(
|
|
27645
27835
|
(value) => {
|
|
27646
27836
|
signal.removeEventListener("abort", abort);
|
|
27647
|
-
|
|
27837
|
+
resolve24(value);
|
|
27648
27838
|
},
|
|
27649
27839
|
(error) => {
|
|
27650
27840
|
signal.removeEventListener("abort", abort);
|
|
@@ -27926,12 +28116,12 @@ async function startOAuthListener({
|
|
|
27926
28116
|
let resolveCallback;
|
|
27927
28117
|
let rejectCallback;
|
|
27928
28118
|
let timeoutHandle;
|
|
27929
|
-
const callbackPromise = new Promise((
|
|
28119
|
+
const callbackPromise = new Promise((resolve24, reject) => {
|
|
27930
28120
|
resolveCallback = (url) => {
|
|
27931
28121
|
if (settled) return;
|
|
27932
28122
|
settled = true;
|
|
27933
28123
|
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
27934
|
-
|
|
28124
|
+
resolve24(url);
|
|
27935
28125
|
};
|
|
27936
28126
|
rejectCallback = (error) => {
|
|
27937
28127
|
if (settled) return;
|
|
@@ -28090,7 +28280,7 @@ async function startOAuthListener({
|
|
|
28090
28280
|
});
|
|
28091
28281
|
});
|
|
28092
28282
|
const bindAddress = getBindAddress();
|
|
28093
|
-
await new Promise((
|
|
28283
|
+
await new Promise((resolve24, reject) => {
|
|
28094
28284
|
const handleError = (error) => {
|
|
28095
28285
|
server.off("error", handleError);
|
|
28096
28286
|
if (error.code === "EADDRINUSE") {
|
|
@@ -28106,7 +28296,7 @@ async function startOAuthListener({
|
|
|
28106
28296
|
server.once("error", handleError);
|
|
28107
28297
|
server.listen(port, bindAddress, () => {
|
|
28108
28298
|
server.off("error", handleError);
|
|
28109
|
-
|
|
28299
|
+
resolve24();
|
|
28110
28300
|
});
|
|
28111
28301
|
});
|
|
28112
28302
|
server.on("error", (error) => {
|
|
@@ -28114,7 +28304,7 @@ async function startOAuthListener({
|
|
|
28114
28304
|
});
|
|
28115
28305
|
return {
|
|
28116
28306
|
waitForCallback: () => callbackPromise,
|
|
28117
|
-
close: () => new Promise((
|
|
28307
|
+
close: () => new Promise((resolve24, reject) => {
|
|
28118
28308
|
server.close((error) => {
|
|
28119
28309
|
if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
|
|
28120
28310
|
reject(error);
|
|
@@ -28123,7 +28313,7 @@ async function startOAuthListener({
|
|
|
28123
28313
|
if (!settled) {
|
|
28124
28314
|
rejectCallback(new Error("OAuth listener closed before callback"));
|
|
28125
28315
|
}
|
|
28126
|
-
|
|
28316
|
+
resolve24();
|
|
28127
28317
|
});
|
|
28128
28318
|
})
|
|
28129
28319
|
};
|
|
@@ -28142,7 +28332,7 @@ init_runtime_paths();
|
|
|
28142
28332
|
// src/setup.ts
|
|
28143
28333
|
init_dist();
|
|
28144
28334
|
import { lstat as lstat9, readFile as readFile13 } from "node:fs/promises";
|
|
28145
|
-
import { join as join22, resolve as
|
|
28335
|
+
import { join as join22, resolve as resolve22 } from "node:path";
|
|
28146
28336
|
|
|
28147
28337
|
// src/auth-method-labels.ts
|
|
28148
28338
|
var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
|
|
@@ -28315,7 +28505,7 @@ async function select2(terminal, items, options) {
|
|
|
28315
28505
|
writeLine("");
|
|
28316
28506
|
renderedLines = lines;
|
|
28317
28507
|
};
|
|
28318
|
-
return new Promise((
|
|
28508
|
+
return new Promise((resolve24) => {
|
|
28319
28509
|
const wasRaw = stdin.isRaw ?? false;
|
|
28320
28510
|
const cleanup2 = () => {
|
|
28321
28511
|
if (cleaned)
|
|
@@ -28335,7 +28525,7 @@ async function select2(terminal, items, options) {
|
|
|
28335
28525
|
};
|
|
28336
28526
|
const finish = (value) => {
|
|
28337
28527
|
cleanup2();
|
|
28338
|
-
|
|
28528
|
+
resolve24(value);
|
|
28339
28529
|
};
|
|
28340
28530
|
const onSignal = () => finish(null);
|
|
28341
28531
|
const onKey = (data) => {
|
|
@@ -28375,7 +28565,7 @@ async function select2(terminal, items, options) {
|
|
|
28375
28565
|
stdin.setRawMode(true);
|
|
28376
28566
|
} catch {
|
|
28377
28567
|
cleanup2();
|
|
28378
|
-
|
|
28568
|
+
resolve24(null);
|
|
28379
28569
|
return;
|
|
28380
28570
|
}
|
|
28381
28571
|
stdin.resume();
|
|
@@ -28389,12 +28579,12 @@ async function select2(terminal, items, options) {
|
|
|
28389
28579
|
import { createHash as createHash12, randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
|
|
28390
28580
|
import { constants as fsConstants2 } from "node:fs";
|
|
28391
28581
|
import { chmod as chmod5, mkdir as mkdir14, open as open10, readFile as readFile12, realpath as realpath4, rename as rename12, stat as stat13, unlink as unlink11 } from "node:fs/promises";
|
|
28392
|
-
import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute4, join as join18, resolve as
|
|
28582
|
+
import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute4, join as join18, resolve as resolve21 } from "node:path";
|
|
28393
28583
|
import { ClaustrumCredentialError as ClaustrumCredentialError9, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
28394
28584
|
|
|
28395
28585
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
28396
28586
|
import { lstat as lstat7, stat as stat11 } from "node:fs/promises";
|
|
28397
|
-
import { resolve as
|
|
28587
|
+
import { resolve as resolve19 } from "node:path";
|
|
28398
28588
|
async function identity2(path2, followSymlinks) {
|
|
28399
28589
|
try {
|
|
28400
28590
|
const metadata = await (followSymlinks ? stat11(path2) : lstat7(path2));
|
|
@@ -28415,7 +28605,7 @@ var FileReadCache2 = class {
|
|
|
28415
28605
|
this.#followSymlinks = options.followSymlinks ?? false;
|
|
28416
28606
|
}
|
|
28417
28607
|
async read(paths, read, validateHit) {
|
|
28418
|
-
const resolvedPaths = paths.map((path2) =>
|
|
28608
|
+
const resolvedPaths = paths.map((path2) => resolve19(path2));
|
|
28419
28609
|
const key = JSON.stringify(resolvedPaths);
|
|
28420
28610
|
const probed = await Promise.all(resolvedPaths.map((path2) => identity2(path2, this.#followSymlinks)));
|
|
28421
28611
|
const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
|
|
@@ -28464,11 +28654,46 @@ var WRITER_LOCK_CONSTANTS2 = Object.freeze({
|
|
|
28464
28654
|
init_private_files2();
|
|
28465
28655
|
|
|
28466
28656
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
28467
|
-
init_private_files2();
|
|
28468
28657
|
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
28469
28658
|
import { link as link3, lstat as lstat8, mkdir as mkdir13, open as open9, readFile as readFile11, rename as rename11, rm as rm6, stat as stat12 } from "node:fs/promises";
|
|
28470
28659
|
import { dirname as dirname18, join as join17 } from "node:path";
|
|
28471
28660
|
|
|
28661
|
+
// src/common-auth-embedded/fs/lock-record.js
|
|
28662
|
+
init_private_files2();
|
|
28663
|
+
import { resolve as resolve20 } from "node:path";
|
|
28664
|
+
var DisappearedLockRecordError2 = class extends Error {
|
|
28665
|
+
path;
|
|
28666
|
+
code = "ENOENT";
|
|
28667
|
+
constructor(path2, cause) {
|
|
28668
|
+
super(`Lock record disappeared: ${path2}`, { cause });
|
|
28669
|
+
this.path = path2;
|
|
28670
|
+
}
|
|
28671
|
+
};
|
|
28672
|
+
function isWindowsAccessDeniedRead2(error, paths) {
|
|
28673
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path2) => resolve20(path2) === error.path);
|
|
28674
|
+
}
|
|
28675
|
+
function isWindowsAccessDeniedCreate2(error, paths, stage) {
|
|
28676
|
+
return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path2) => resolve20(path2) === error.path);
|
|
28677
|
+
}
|
|
28678
|
+
async function readLockRecord2(path2, read) {
|
|
28679
|
+
try {
|
|
28680
|
+
return await read();
|
|
28681
|
+
} catch (error) {
|
|
28682
|
+
if (!isWindowsAccessDeniedRead2(error, [path2]))
|
|
28683
|
+
throw error;
|
|
28684
|
+
try {
|
|
28685
|
+
return await read();
|
|
28686
|
+
} catch (recheckError) {
|
|
28687
|
+
if (recheckError.code === "ENOENT")
|
|
28688
|
+
throw new DisappearedLockRecordError2(path2, error);
|
|
28689
|
+
throw error;
|
|
28690
|
+
}
|
|
28691
|
+
}
|
|
28692
|
+
}
|
|
28693
|
+
|
|
28694
|
+
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
28695
|
+
init_private_files2();
|
|
28696
|
+
|
|
28472
28697
|
// src/common-auth-embedded/fs/with-lock.js
|
|
28473
28698
|
init_private_files2();
|
|
28474
28699
|
function lockPathFor2(target, name) {
|
|
@@ -28567,8 +28792,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
28567
28792
|
let releaseConfirmed = false;
|
|
28568
28793
|
let loss;
|
|
28569
28794
|
let resolveLoss;
|
|
28570
|
-
const lostPromise = new Promise((
|
|
28571
|
-
resolveLoss =
|
|
28795
|
+
const lostPromise = new Promise((resolve24) => {
|
|
28796
|
+
resolveLoss = resolve24;
|
|
28572
28797
|
});
|
|
28573
28798
|
function notifyTimerStep(event) {
|
|
28574
28799
|
try {
|
|
@@ -28606,15 +28831,18 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
28606
28831
|
const evictOwnerId = randomUUID14();
|
|
28607
28832
|
const EVICT_TTL = 5e3;
|
|
28608
28833
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
28834
|
+
function isChangingLockCreate(error) {
|
|
28835
|
+
return windowsPrivateFiles2 && (isWindowsAccessDeniedCreate2(error, [lockPath], "create") || isWindowsAccessDeniedCreate2(error, [evictPath], "directory-create"));
|
|
28836
|
+
}
|
|
28609
28837
|
async function readOwner() {
|
|
28610
28838
|
if (windowsPrivateFiles2) {
|
|
28611
28839
|
try {
|
|
28612
|
-
return JSON.parse(await readPrivateText2(lockPath, true));
|
|
28840
|
+
return JSON.parse(await readLockRecord2(lockPath, () => readPrivateText2(lockPath, true)));
|
|
28613
28841
|
} catch (error) {
|
|
28614
28842
|
if (error.code !== "EISDIR" && error.reason !== "wrong-kind")
|
|
28615
28843
|
throw error;
|
|
28616
|
-
await verifyPrivate2(lockPath, "directory", true);
|
|
28617
|
-
return JSON.parse(await readPrivateText2(legacyOwnerPath, true));
|
|
28844
|
+
await readLockRecord2(lockPath, () => verifyPrivate2(lockPath, "directory", true));
|
|
28845
|
+
return JSON.parse(await readLockRecord2(legacyOwnerPath, () => readPrivateText2(legacyOwnerPath, true)));
|
|
28618
28846
|
}
|
|
28619
28847
|
}
|
|
28620
28848
|
try {
|
|
@@ -28690,8 +28918,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
28690
28918
|
await options.onStep("lease-contention-read-ready");
|
|
28691
28919
|
try {
|
|
28692
28920
|
if (code2 === "EISDIR") {
|
|
28693
|
-
await verifyPrivate2(lockPath, "directory", true);
|
|
28694
|
-
await readPrivateText2(legacyOwnerPath, true);
|
|
28921
|
+
await readLockRecord2(lockPath, () => verifyPrivate2(lockPath, "directory", true));
|
|
28922
|
+
await readLockRecord2(legacyOwnerPath, () => readPrivateText2(legacyOwnerPath, true));
|
|
28695
28923
|
} else
|
|
28696
28924
|
await readOwner();
|
|
28697
28925
|
} catch (readError) {
|
|
@@ -28729,7 +28957,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
28729
28957
|
}
|
|
28730
28958
|
}
|
|
28731
28959
|
async function backoff() {
|
|
28732
|
-
await new Promise((
|
|
28960
|
+
await new Promise((resolve24) => setTimeout(resolve24, Math.floor(Math.random() * 4)));
|
|
28733
28961
|
}
|
|
28734
28962
|
async function readLockState(notifyReady = true) {
|
|
28735
28963
|
if (notifyReady && options.onStep)
|
|
@@ -28738,6 +28966,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
28738
28966
|
try {
|
|
28739
28967
|
owner = await readOwner();
|
|
28740
28968
|
} catch (error) {
|
|
28969
|
+
if (error instanceof DisappearedLockRecordError2)
|
|
28970
|
+
return { status: "missing" };
|
|
28741
28971
|
if (windowsPrivateFiles2 && error.code !== "ENOENT")
|
|
28742
28972
|
throw error;
|
|
28743
28973
|
}
|
|
@@ -28785,7 +29015,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
28785
29015
|
}
|
|
28786
29016
|
async function ownsEvictionMarker() {
|
|
28787
29017
|
try {
|
|
28788
|
-
const owner = JSON.parse(await readPrivateText2(evictOwnerPath, windowsPrivateFiles2));
|
|
29018
|
+
const owner = JSON.parse(await readLockRecord2(evictOwnerPath, () => readPrivateText2(evictOwnerPath, windowsPrivateFiles2)));
|
|
28789
29019
|
return owner?.ownerId === evictOwnerId;
|
|
28790
29020
|
} catch (error) {
|
|
28791
29021
|
if (windowsPrivateFiles2 && error.code !== "ENOENT")
|
|
@@ -28820,7 +29050,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
28820
29050
|
const remainingMs = deadline - performance.now();
|
|
28821
29051
|
if (remainingMs <= 0)
|
|
28822
29052
|
throw original;
|
|
28823
|
-
await new Promise((
|
|
29053
|
+
await new Promise((resolve24) => setTimeout(resolve24, Math.min(delayMs, remainingMs)));
|
|
28824
29054
|
if (performance.now() >= deadline)
|
|
28825
29055
|
throw original;
|
|
28826
29056
|
delayMs = Math.min(delayMs * 2, 50);
|
|
@@ -28924,7 +29154,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
28924
29154
|
}
|
|
28925
29155
|
if (windowsPrivateFiles2) {
|
|
28926
29156
|
try {
|
|
28927
|
-
await verifyPrivate2(evictPath, "directory", true);
|
|
29157
|
+
await readLockRecord2(evictPath, () => verifyPrivate2(evictPath, "directory", true));
|
|
28928
29158
|
} catch (error) {
|
|
28929
29159
|
if (error.code === "ENOENT")
|
|
28930
29160
|
return "missing";
|
|
@@ -28979,8 +29209,8 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
28979
29209
|
if (error.code === "EEXIST") {
|
|
28980
29210
|
if (windowsPrivateFiles2) {
|
|
28981
29211
|
try {
|
|
28982
|
-
await verifyPrivate2(evictPath, "directory", true);
|
|
28983
|
-
await readPrivateText2(evictOwnerPath, true);
|
|
29212
|
+
await readLockRecord2(evictPath, () => verifyPrivate2(evictPath, "directory", true));
|
|
29213
|
+
await readLockRecord2(evictOwnerPath, () => readPrivateText2(evictOwnerPath, true));
|
|
28984
29214
|
} catch (ownerError) {
|
|
28985
29215
|
if (ownerError.code !== "ENOENT")
|
|
28986
29216
|
throw ownerError;
|
|
@@ -29001,7 +29231,11 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
29001
29231
|
try {
|
|
29002
29232
|
await releaseEvictionMarker(deadline);
|
|
29003
29233
|
} catch (error) {
|
|
29004
|
-
if (isRetryableRemoval(actionError, lockPath)
|
|
29234
|
+
if ((isRetryableRemoval(actionError, lockPath) || isWindowsAccessDeniedRead2(actionError, [
|
|
29235
|
+
lockPath,
|
|
29236
|
+
legacyOwnerPath,
|
|
29237
|
+
evictOwnerPath
|
|
29238
|
+
])) && (isRetryableRemoval(error, evictPath) || isWindowsAccessDeniedRead2(error, [evictOwnerPath])))
|
|
29005
29239
|
throw actionError;
|
|
29006
29240
|
throw error;
|
|
29007
29241
|
}
|
|
@@ -29017,7 +29251,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
29017
29251
|
try {
|
|
29018
29252
|
owner = await readOwner();
|
|
29019
29253
|
} catch (error) {
|
|
29020
|
-
if (windowsPrivateFiles2)
|
|
29254
|
+
if (windowsPrivateFiles2 && !(error instanceof DisappearedLockRecordError2))
|
|
29021
29255
|
throw error;
|
|
29022
29256
|
return;
|
|
29023
29257
|
}
|
|
@@ -29095,7 +29329,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
29095
29329
|
await options.onStep("renewal-marker-unavailable");
|
|
29096
29330
|
}
|
|
29097
29331
|
} catch (error) {
|
|
29098
|
-
if (windowsPrivateFiles2 && error instanceof PrivateFileError2) {
|
|
29332
|
+
if (windowsPrivateFiles2 && error instanceof PrivateFileError2 && !isChangingLockCreate(error)) {
|
|
29099
29333
|
terminalIOError = error;
|
|
29100
29334
|
recordLoss("renewal-failed");
|
|
29101
29335
|
shouldReschedule = false;
|
|
@@ -29141,72 +29375,90 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
29141
29375
|
}
|
|
29142
29376
|
return null;
|
|
29143
29377
|
}
|
|
29144
|
-
let acquired =
|
|
29378
|
+
let acquired = false;
|
|
29379
|
+
let changingCreateError;
|
|
29380
|
+
try {
|
|
29381
|
+
acquired = await tryAcquire();
|
|
29382
|
+
} catch (error) {
|
|
29383
|
+
if (!isChangingLockCreate(error))
|
|
29384
|
+
throw error;
|
|
29385
|
+
changingCreateError = error;
|
|
29386
|
+
}
|
|
29145
29387
|
if (!acquired) {
|
|
29146
29388
|
for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
|
|
29147
|
-
acquired = await tryAcquire();
|
|
29148
|
-
if (acquired)
|
|
29149
|
-
break;
|
|
29150
|
-
const observed = await readLockState();
|
|
29151
|
-
if (observed.status === "live")
|
|
29152
|
-
return contended();
|
|
29153
|
-
if (observed.status === "missing")
|
|
29154
|
-
continue;
|
|
29155
|
-
if (options.onStep)
|
|
29156
|
-
await options.onStep("stale-lock-observed");
|
|
29157
|
-
try {
|
|
29158
|
-
if (!await tryAcquireEvictionMarker()) {
|
|
29159
|
-
await backoff();
|
|
29160
|
-
continue;
|
|
29161
|
-
}
|
|
29162
|
-
} catch (evictError) {
|
|
29163
|
-
const code2 = evictError.code;
|
|
29164
|
-
if (code2 !== "EEXIST")
|
|
29165
|
-
throw evictError;
|
|
29166
|
-
const recovered = await recoverStaleEvictionMarker();
|
|
29167
|
-
if (recovered === "fresh")
|
|
29168
|
-
return null;
|
|
29169
|
-
await backoff();
|
|
29170
|
-
continue;
|
|
29171
|
-
}
|
|
29172
29389
|
try {
|
|
29173
|
-
|
|
29174
|
-
if (
|
|
29390
|
+
acquired = await tryAcquire();
|
|
29391
|
+
if (acquired)
|
|
29392
|
+
break;
|
|
29393
|
+
const observed = await readLockState();
|
|
29394
|
+
if (observed.status === "live")
|
|
29175
29395
|
return contended();
|
|
29176
|
-
if (
|
|
29396
|
+
if (observed.status === "missing")
|
|
29177
29397
|
continue;
|
|
29178
|
-
if (!await ownsEvictionMarker())
|
|
29179
|
-
return null;
|
|
29180
29398
|
if (options.onStep)
|
|
29181
|
-
await options.onStep("stale-lock-
|
|
29182
|
-
|
|
29183
|
-
|
|
29184
|
-
|
|
29185
|
-
|
|
29399
|
+
await options.onStep("stale-lock-observed");
|
|
29400
|
+
try {
|
|
29401
|
+
if (!await tryAcquireEvictionMarker()) {
|
|
29402
|
+
await backoff();
|
|
29403
|
+
continue;
|
|
29404
|
+
}
|
|
29405
|
+
} catch (evictError) {
|
|
29406
|
+
const code2 = evictError.code;
|
|
29407
|
+
if (code2 !== "EEXIST")
|
|
29408
|
+
throw evictError;
|
|
29409
|
+
const recovered = await recoverStaleEvictionMarker();
|
|
29410
|
+
if (recovered === "fresh")
|
|
29411
|
+
return null;
|
|
29412
|
+
await backoff();
|
|
29186
29413
|
continue;
|
|
29187
|
-
await removeLeaseObject(lockPath);
|
|
29188
|
-
if (!await ownsEvictionMarker())
|
|
29189
|
-
return null;
|
|
29190
|
-
if (options.onStep)
|
|
29191
|
-
await options.onStep("stale-lock-removed");
|
|
29192
|
-
acquired = await tryAcquire();
|
|
29193
|
-
if (!acquired)
|
|
29194
|
-
return null;
|
|
29195
|
-
if (options.onStep)
|
|
29196
|
-
await options.onStep("stale-lock-recreated");
|
|
29197
|
-
if (!await ownsEvictionMarker()) {
|
|
29198
|
-
await relinquishLockAfterMarkerLoss();
|
|
29199
|
-
acquired = false;
|
|
29200
|
-
return null;
|
|
29201
29414
|
}
|
|
29202
|
-
|
|
29203
|
-
|
|
29204
|
-
|
|
29415
|
+
try {
|
|
29416
|
+
const confirmed = await readLockState();
|
|
29417
|
+
if (confirmed.status === "live")
|
|
29418
|
+
return contended();
|
|
29419
|
+
if (!sameStaleLock(observed.identity, confirmed))
|
|
29420
|
+
continue;
|
|
29421
|
+
if (!await ownsEvictionMarker())
|
|
29422
|
+
return null;
|
|
29423
|
+
if (options.onStep)
|
|
29424
|
+
await options.onStep("stale-lock-confirmed");
|
|
29425
|
+
if (!await ownsEvictionMarker())
|
|
29426
|
+
return null;
|
|
29427
|
+
const current = await readLockState(false);
|
|
29428
|
+
if (!sameStaleLock(observed.identity, current))
|
|
29429
|
+
continue;
|
|
29430
|
+
await removeLeaseObject(lockPath);
|
|
29431
|
+
if (!await ownsEvictionMarker())
|
|
29432
|
+
return null;
|
|
29433
|
+
if (options.onStep)
|
|
29434
|
+
await options.onStep("stale-lock-removed");
|
|
29435
|
+
acquired = await tryAcquire();
|
|
29436
|
+
if (!acquired)
|
|
29437
|
+
return null;
|
|
29438
|
+
if (options.onStep)
|
|
29439
|
+
await options.onStep("stale-lock-recreated");
|
|
29440
|
+
if (!await ownsEvictionMarker()) {
|
|
29441
|
+
await relinquishLockAfterMarkerLoss();
|
|
29442
|
+
acquired = false;
|
|
29443
|
+
return null;
|
|
29444
|
+
}
|
|
29445
|
+
break;
|
|
29446
|
+
} finally {
|
|
29447
|
+
await releaseEvictionMarker();
|
|
29448
|
+
}
|
|
29449
|
+
} catch (error) {
|
|
29450
|
+
if (!isChangingLockCreate(error))
|
|
29451
|
+
throw error;
|
|
29452
|
+
changingCreateError ??= error;
|
|
29453
|
+
await backoff();
|
|
29205
29454
|
}
|
|
29206
29455
|
}
|
|
29207
29456
|
}
|
|
29208
|
-
if (!acquired)
|
|
29457
|
+
if (!acquired) {
|
|
29458
|
+
if (changingCreateError)
|
|
29459
|
+
throw changingCreateError;
|
|
29209
29460
|
return null;
|
|
29461
|
+
}
|
|
29210
29462
|
scheduleRenewal();
|
|
29211
29463
|
return {
|
|
29212
29464
|
ownerId,
|
|
@@ -29244,6 +29496,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
29244
29496
|
const deadline = performance.now() + EVICT_TTL + 1e3;
|
|
29245
29497
|
let delayMs = 5;
|
|
29246
29498
|
let removalError;
|
|
29499
|
+
let changingRecordError;
|
|
29247
29500
|
for (; ; ) {
|
|
29248
29501
|
try {
|
|
29249
29502
|
let removalConfirmed = false;
|
|
@@ -29269,6 +29522,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
29269
29522
|
await removeLeaseObject(lockPath);
|
|
29270
29523
|
removalConfirmed = true;
|
|
29271
29524
|
}, deadline);
|
|
29525
|
+
changingRecordError = void 0;
|
|
29272
29526
|
if (markerAcquired) {
|
|
29273
29527
|
if (windowsPrivateFiles2 && !removalConfirmed)
|
|
29274
29528
|
throw new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
@@ -29281,23 +29535,32 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
29281
29535
|
return;
|
|
29282
29536
|
await recoverStaleEvictionMarker(deadline);
|
|
29283
29537
|
} catch (error) {
|
|
29284
|
-
|
|
29538
|
+
const changingRecord = windowsPrivateFiles2 && (isChangingLockCreate(error) || isWindowsAccessDeniedRead2(error, [
|
|
29539
|
+
lockPath,
|
|
29540
|
+
legacyOwnerPath,
|
|
29541
|
+
evictPath,
|
|
29542
|
+
evictOwnerPath
|
|
29543
|
+
]));
|
|
29544
|
+
if (!isRetryableRemoval(error, lockPath) && !changingRecord) {
|
|
29285
29545
|
if (windowsPrivateFiles2)
|
|
29286
29546
|
throw error;
|
|
29287
29547
|
return;
|
|
29288
29548
|
}
|
|
29289
|
-
|
|
29549
|
+
if (changingRecord)
|
|
29550
|
+
changingRecordError ??= error;
|
|
29551
|
+
else
|
|
29552
|
+
removalError ??= error;
|
|
29290
29553
|
}
|
|
29291
29554
|
const remainingMs = deadline - performance.now();
|
|
29292
29555
|
if (remainingMs <= 0)
|
|
29293
29556
|
break;
|
|
29294
|
-
await new Promise((
|
|
29557
|
+
await new Promise((resolve24) => setTimeout(resolve24, Math.min(delayMs, remainingMs)));
|
|
29295
29558
|
if (windowsPrivateFiles2 && performance.now() >= deadline)
|
|
29296
29559
|
break;
|
|
29297
29560
|
delayMs = Math.min(delayMs * 2, 50);
|
|
29298
29561
|
}
|
|
29299
29562
|
if (windowsPrivateFiles2)
|
|
29300
|
-
throw removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
29563
|
+
throw changingRecordError ?? removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
|
|
29301
29564
|
code: "ETIMEDOUT"
|
|
29302
29565
|
});
|
|
29303
29566
|
}
|
|
@@ -29437,6 +29700,10 @@ function classifyEnrollmentError2(error) {
|
|
|
29437
29700
|
disposition: error.action === "retry" ? "retry" : "terminal"
|
|
29438
29701
|
};
|
|
29439
29702
|
}
|
|
29703
|
+
function validEnrollmentDisplayName2(displayName) {
|
|
29704
|
+
const length = Array.from(displayName).length;
|
|
29705
|
+
return length >= 1 && length <= 40 && !/[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\u200b-\u200d\u2060\ufeff]/u.test(displayName);
|
|
29706
|
+
}
|
|
29440
29707
|
function connectClaustrumEnrollmentClient2(options) {
|
|
29441
29708
|
return ClaustrumWireClient2.connect(options);
|
|
29442
29709
|
}
|
|
@@ -29452,7 +29719,7 @@ function hostEnrollmentPaths2(input) {
|
|
|
29452
29719
|
const override = input.override?.trim();
|
|
29453
29720
|
if (override && !isAbsolute4(override) && !input.cwd)
|
|
29454
29721
|
throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
|
|
29455
|
-
const tokenPath = override ? isAbsolute4(override) ? override :
|
|
29722
|
+
const tokenPath = override ? isAbsolute4(override) ? override : resolve21(input.cwd, override) : join18(input.stateDir, `${input.host}-enrollment.json`);
|
|
29456
29723
|
return getClaustrumEnrollmentPaths2(tokenPath);
|
|
29457
29724
|
}
|
|
29458
29725
|
function isRecord10(value) {
|
|
@@ -29813,15 +30080,19 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
29813
30080
|
#client;
|
|
29814
30081
|
#paths;
|
|
29815
30082
|
#proposedName;
|
|
30083
|
+
#displayName;
|
|
29816
30084
|
#now;
|
|
29817
30085
|
#mintSecret;
|
|
29818
30086
|
#writeTokenFile;
|
|
29819
30087
|
#ancestorOptions;
|
|
29820
30088
|
constructor(options) {
|
|
30089
|
+
if (options.displayName !== void 0 && !validEnrollmentDisplayName2(options.displayName))
|
|
30090
|
+
throw new ClaustrumConsumerError2("invalid-state", "invalid Claustrum enrollment display name");
|
|
29821
30091
|
this.#ancestorOptions = options.ancestorOptions ?? {};
|
|
29822
30092
|
this.#client = options.client;
|
|
29823
30093
|
this.#paths = options.paths;
|
|
29824
30094
|
this.#proposedName = options.proposedName;
|
|
30095
|
+
this.#displayName = options.displayName;
|
|
29825
30096
|
this.#now = options.now ?? Date.now;
|
|
29826
30097
|
this.#mintSecret = options.mintSecret ?? (() => randomBytes3(32).toString("hex"));
|
|
29827
30098
|
this.#writeTokenFile = options.writeTokenFile ?? writeEnrollmentTokenFile2;
|
|
@@ -29911,10 +30182,23 @@ var ClaustrumEnrollmentManager2 = class {
|
|
|
29911
30182
|
if (!state.requestId) {
|
|
29912
30183
|
try {
|
|
29913
30184
|
const requestSecretHash = createHash12("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
|
|
29914
|
-
const
|
|
30185
|
+
const proposal = {
|
|
29915
30186
|
name: state.proposedName,
|
|
29916
30187
|
requestSecretHash
|
|
29917
|
-
}
|
|
30188
|
+
};
|
|
30189
|
+
let proposed;
|
|
30190
|
+
try {
|
|
30191
|
+
proposed = await this.#client.enrollPropose({
|
|
30192
|
+
...proposal,
|
|
30193
|
+
...this.#displayName !== void 0 && {
|
|
30194
|
+
displayName: this.#displayName
|
|
30195
|
+
}
|
|
30196
|
+
});
|
|
30197
|
+
} catch (error) {
|
|
30198
|
+
if (this.#displayName === void 0 || !(error instanceof ClaustrumCredentialError9) || error.code !== "invalid_params")
|
|
30199
|
+
throw error;
|
|
30200
|
+
proposed = await this.#client.enrollPropose(proposal);
|
|
30201
|
+
}
|
|
29918
30202
|
state = {
|
|
29919
30203
|
...state,
|
|
29920
30204
|
requestId: proposed.requestId,
|
|
@@ -30085,7 +30369,7 @@ var ByteTail = class {
|
|
|
30085
30369
|
};
|
|
30086
30370
|
var defaultCommandRunner = {
|
|
30087
30371
|
run(file, args, options = {}) {
|
|
30088
|
-
return new Promise((
|
|
30372
|
+
return new Promise((resolve24) => {
|
|
30089
30373
|
const started = performance.now();
|
|
30090
30374
|
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
30091
30375
|
const stderr = new ByteTail();
|
|
@@ -30103,7 +30387,7 @@ var defaultCommandRunner = {
|
|
|
30103
30387
|
stdio: ["ignore", "pipe", "pipe"]
|
|
30104
30388
|
});
|
|
30105
30389
|
} catch {
|
|
30106
|
-
|
|
30390
|
+
resolve24({
|
|
30107
30391
|
exitCode: 1,
|
|
30108
30392
|
stdout: "",
|
|
30109
30393
|
stderr: "",
|
|
@@ -30138,7 +30422,7 @@ var defaultCommandRunner = {
|
|
|
30138
30422
|
settled = true;
|
|
30139
30423
|
if (timer)
|
|
30140
30424
|
clearTimeout(timer);
|
|
30141
|
-
|
|
30425
|
+
resolve24({
|
|
30142
30426
|
exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
|
|
30143
30427
|
stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
|
|
30144
30428
|
stderr: stderr.toString(),
|
|
@@ -30750,7 +31034,7 @@ function approveCommand(requestId, name) {
|
|
|
30750
31034
|
async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
30751
31035
|
if (hasVaultHost2())
|
|
30752
31036
|
throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
|
|
30753
|
-
const { name, paths: input } = plugin.vault.hosts[host];
|
|
31037
|
+
const { name, displayName, paths: input } = plugin.vault.hosts[host];
|
|
30754
31038
|
const paths = hostEnrollmentPaths2(input);
|
|
30755
31039
|
await fence();
|
|
30756
31040
|
const client = await (io.connect ?? connectClaustrumEnrollmentClient2)({
|
|
@@ -30764,6 +31048,7 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
30764
31048
|
try {
|
|
30765
31049
|
const manager = new ClaustrumEnrollmentManager2({
|
|
30766
31050
|
proposedName: name,
|
|
31051
|
+
displayName,
|
|
30767
31052
|
paths,
|
|
30768
31053
|
// Each tick of the wait below checks the fence once, just before
|
|
30769
31054
|
// reconcile proposes or polls. Checking again inside every vault call
|
|
@@ -31510,7 +31795,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
31510
31795
|
beforeRename: async () => {
|
|
31511
31796
|
await assertSetupHostsStopped();
|
|
31512
31797
|
const claustrum = await loadCommonAuthClaustrum();
|
|
31513
|
-
const stateDir = host === "opencode" ? openCodeVaultDir(
|
|
31798
|
+
const stateDir = host === "opencode" ? openCodeVaultDir(resolve22(accountFileForVault())) : getPiAntigravityVaultDir();
|
|
31514
31799
|
if (await claustrum.vaultAuthority(
|
|
31515
31800
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
31516
31801
|
`antigravity-auth-${host}`
|
|
@@ -31544,17 +31829,19 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
31544
31829
|
const hosts = {
|
|
31545
31830
|
opencode: {
|
|
31546
31831
|
name: OPENCODE_VAULT_ENROLLMENT_NAME,
|
|
31832
|
+
displayName: "Antigravity sign-in for OpenCode",
|
|
31547
31833
|
// Read at each use: a real run settles the vault folder in
|
|
31548
31834
|
// `beforeSignIn`, which may move it after this plugin is built.
|
|
31549
31835
|
paths: {
|
|
31550
31836
|
get stateDir() {
|
|
31551
|
-
return openCodeVaultDir(
|
|
31837
|
+
return openCodeVaultDir(resolve22(accountFileForVault()));
|
|
31552
31838
|
},
|
|
31553
31839
|
host: "opencode"
|
|
31554
31840
|
}
|
|
31555
31841
|
},
|
|
31556
31842
|
pi: {
|
|
31557
31843
|
name: "antigravity-auth-pi",
|
|
31844
|
+
displayName: "Antigravity sign-in for Pi",
|
|
31558
31845
|
paths: { stateDir: piDir, host: "pi" }
|
|
31559
31846
|
}
|
|
31560
31847
|
};
|
|
@@ -31565,7 +31852,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
31565
31852
|
const assertLocal = async (host, context) => {
|
|
31566
31853
|
if (host === "opencode")
|
|
31567
31854
|
return assertLocalOpenCodeLogin(
|
|
31568
|
-
|
|
31855
|
+
resolve22(accountFileForVault()),
|
|
31569
31856
|
context.opencodeGeneration
|
|
31570
31857
|
);
|
|
31571
31858
|
if (await authority(host) !== "local")
|
|
@@ -32225,7 +32512,7 @@ async function runCliProcess(argv, deps) {
|
|
|
32225
32512
|
...deps,
|
|
32226
32513
|
prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
|
|
32227
32514
|
const folder = await prepareVaultFolder({
|
|
32228
|
-
accountFile:
|
|
32515
|
+
accountFile: resolve23(accountFileForVault()),
|
|
32229
32516
|
...options
|
|
32230
32517
|
});
|
|
32231
32518
|
if (folder.refusal) throw folder.refusal;
|
|
@@ -32271,11 +32558,11 @@ function createDefaultCliDependencies() {
|
|
|
32271
32558
|
);
|
|
32272
32559
|
if (host !== "pi")
|
|
32273
32560
|
await assertLocalOpenCodeLogin(
|
|
32274
|
-
|
|
32561
|
+
resolve23(accountFileForVault()),
|
|
32275
32562
|
context?.opencodeGeneration
|
|
32276
32563
|
);
|
|
32277
32564
|
const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
|
|
32278
|
-
|
|
32565
|
+
resolve23(getStoragePath()),
|
|
32279
32566
|
context?.opencodeGeneration
|
|
32280
32567
|
);
|
|
32281
32568
|
try {
|
|
@@ -32291,7 +32578,7 @@ function createDefaultCliDependencies() {
|
|
|
32291
32578
|
}
|
|
32292
32579
|
if (host === "opencode") await assertSetupHostsStopped();
|
|
32293
32580
|
await assertLocalOpenCodeLogin(
|
|
32294
|
-
|
|
32581
|
+
resolve23(accountFileForVault()),
|
|
32295
32582
|
context?.opencodeGeneration
|
|
32296
32583
|
);
|
|
32297
32584
|
await persistCliStoreLogin(
|
|
@@ -32311,7 +32598,7 @@ function createDefaultCliDependencies() {
|
|
|
32311
32598
|
};
|
|
32312
32599
|
}
|
|
32313
32600
|
async function prepareCliLoginStore(legacyPath, generation) {
|
|
32314
|
-
await assertLocalOpenCodeLogin(
|
|
32601
|
+
await assertLocalOpenCodeLogin(resolve23(accountFileForVault()), generation);
|
|
32315
32602
|
const modules = await loadCommonAuthStoreModules();
|
|
32316
32603
|
const options = {
|
|
32317
32604
|
legacyPath,
|
|
@@ -32456,7 +32743,7 @@ async function readAccountStore(legacyPath) {
|
|
|
32456
32743
|
function createDefaultAccountStoreOperations() {
|
|
32457
32744
|
const offline = { processesStopped: true };
|
|
32458
32745
|
return {
|
|
32459
|
-
legacyPath: () =>
|
|
32746
|
+
legacyPath: () => resolve23(
|
|
32460
32747
|
decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
|
|
32461
32748
|
),
|
|
32462
32749
|
migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
|
|
@@ -32487,7 +32774,7 @@ function createDefaultAccountStoreOperations() {
|
|
|
32487
32774
|
};
|
|
32488
32775
|
}
|
|
32489
32776
|
function samePath(left, right) {
|
|
32490
|
-
return process.platform === "win32" ?
|
|
32777
|
+
return process.platform === "win32" ? resolve23(left).toLowerCase() === resolve23(right).toLowerCase() : resolve23(left) === resolve23(right);
|
|
32491
32778
|
}
|
|
32492
32779
|
function isCliEntry() {
|
|
32493
32780
|
if (import.meta.main !== void 0) return import.meta.main;
|