@buildautomaton/cli 0.1.79 → 0.1.81
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/dist/cli.js +822 -524
- package/dist/cli.js.map +4 -4
- package/dist/index.js +656 -358
- package/dist/index.js.map +4 -4
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4208,8 +4208,8 @@ var init_parseUtil = __esm({
|
|
|
4208
4208
|
init_errors();
|
|
4209
4209
|
init_en();
|
|
4210
4210
|
makeIssue = (params) => {
|
|
4211
|
-
const { data, path:
|
|
4212
|
-
const fullPath = [...
|
|
4211
|
+
const { data, path: path86, errorMaps, issueData } = params;
|
|
4212
|
+
const fullPath = [...path86, ...issueData.path || []];
|
|
4213
4213
|
const fullIssue = {
|
|
4214
4214
|
...issueData,
|
|
4215
4215
|
path: fullPath
|
|
@@ -4517,11 +4517,11 @@ var init_types = __esm({
|
|
|
4517
4517
|
init_parseUtil();
|
|
4518
4518
|
init_util();
|
|
4519
4519
|
ParseInputLazyPath = class {
|
|
4520
|
-
constructor(parent, value,
|
|
4520
|
+
constructor(parent, value, path86, key) {
|
|
4521
4521
|
this._cachedPath = [];
|
|
4522
4522
|
this.parent = parent;
|
|
4523
4523
|
this.data = value;
|
|
4524
|
-
this._path =
|
|
4524
|
+
this._path = path86;
|
|
4525
4525
|
this._key = key;
|
|
4526
4526
|
}
|
|
4527
4527
|
get path() {
|
|
@@ -8182,10 +8182,10 @@ function assignProp(target, prop, value) {
|
|
|
8182
8182
|
configurable: true
|
|
8183
8183
|
});
|
|
8184
8184
|
}
|
|
8185
|
-
function getElementAtPath(obj,
|
|
8186
|
-
if (!
|
|
8185
|
+
function getElementAtPath(obj, path86) {
|
|
8186
|
+
if (!path86)
|
|
8187
8187
|
return obj;
|
|
8188
|
-
return
|
|
8188
|
+
return path86.reduce((acc, key) => acc?.[key], obj);
|
|
8189
8189
|
}
|
|
8190
8190
|
function promiseAllObject(promisesObj) {
|
|
8191
8191
|
const keys = Object.keys(promisesObj);
|
|
@@ -8434,11 +8434,11 @@ function aborted(x, startIndex = 0) {
|
|
|
8434
8434
|
}
|
|
8435
8435
|
return false;
|
|
8436
8436
|
}
|
|
8437
|
-
function prefixIssues(
|
|
8437
|
+
function prefixIssues(path86, issues) {
|
|
8438
8438
|
return issues.map((iss) => {
|
|
8439
8439
|
var _a2;
|
|
8440
8440
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
8441
|
-
iss.path.unshift(
|
|
8441
|
+
iss.path.unshift(path86);
|
|
8442
8442
|
return iss;
|
|
8443
8443
|
});
|
|
8444
8444
|
}
|
|
@@ -8627,7 +8627,7 @@ function treeifyError(error40, _mapper) {
|
|
|
8627
8627
|
return issue2.message;
|
|
8628
8628
|
};
|
|
8629
8629
|
const result = { errors: [] };
|
|
8630
|
-
const processError = (error41,
|
|
8630
|
+
const processError = (error41, path86 = []) => {
|
|
8631
8631
|
var _a2, _b;
|
|
8632
8632
|
for (const issue2 of error41.issues) {
|
|
8633
8633
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -8637,7 +8637,7 @@ function treeifyError(error40, _mapper) {
|
|
|
8637
8637
|
} else if (issue2.code === "invalid_element") {
|
|
8638
8638
|
processError({ issues: issue2.issues }, issue2.path);
|
|
8639
8639
|
} else {
|
|
8640
|
-
const fullpath = [...
|
|
8640
|
+
const fullpath = [...path86, ...issue2.path];
|
|
8641
8641
|
if (fullpath.length === 0) {
|
|
8642
8642
|
result.errors.push(mapper(issue2));
|
|
8643
8643
|
continue;
|
|
@@ -8667,9 +8667,9 @@ function treeifyError(error40, _mapper) {
|
|
|
8667
8667
|
processError(error40);
|
|
8668
8668
|
return result;
|
|
8669
8669
|
}
|
|
8670
|
-
function toDotPath(
|
|
8670
|
+
function toDotPath(path86) {
|
|
8671
8671
|
const segs = [];
|
|
8672
|
-
for (const seg of
|
|
8672
|
+
for (const seg of path86) {
|
|
8673
8673
|
if (typeof seg === "number")
|
|
8674
8674
|
segs.push(`[${seg}]`);
|
|
8675
8675
|
else if (typeof seg === "symbol")
|
|
@@ -21132,8 +21132,8 @@ var init_acp = __esm({
|
|
|
21132
21132
|
this.#requestHandler = requestHandler;
|
|
21133
21133
|
this.#notificationHandler = notificationHandler;
|
|
21134
21134
|
this.#stream = stream;
|
|
21135
|
-
this.#closedPromise = new Promise((
|
|
21136
|
-
this.#abortController.signal.addEventListener("abort", () =>
|
|
21135
|
+
this.#closedPromise = new Promise((resolve36) => {
|
|
21136
|
+
this.#abortController.signal.addEventListener("abort", () => resolve36());
|
|
21137
21137
|
});
|
|
21138
21138
|
this.#receive();
|
|
21139
21139
|
}
|
|
@@ -21282,8 +21282,8 @@ var init_acp = __esm({
|
|
|
21282
21282
|
}
|
|
21283
21283
|
async sendRequest(method, params) {
|
|
21284
21284
|
const id = this.#nextRequestId++;
|
|
21285
|
-
const responsePromise = new Promise((
|
|
21286
|
-
this.#pendingResponses.set(id, { resolve:
|
|
21285
|
+
const responsePromise = new Promise((resolve36, reject) => {
|
|
21286
|
+
this.#pendingResponses.set(id, { resolve: resolve36, reject });
|
|
21287
21287
|
});
|
|
21288
21288
|
await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
|
|
21289
21289
|
return responsePromise;
|
|
@@ -21651,7 +21651,7 @@ var init_activity_tracker = __esm({
|
|
|
21651
21651
|
|
|
21652
21652
|
// src/runtime/yield-to-event-loop.ts
|
|
21653
21653
|
function yieldToEventLoop() {
|
|
21654
|
-
return new Promise((
|
|
21654
|
+
return new Promise((resolve36) => setImmediate(resolve36));
|
|
21655
21655
|
}
|
|
21656
21656
|
var init_yield_to_event_loop = __esm({
|
|
21657
21657
|
"src/runtime/yield-to-event-loop.ts"() {
|
|
@@ -21692,7 +21692,7 @@ async function yieldUntilFileBrowserReadsIdle(pollMs = 5) {
|
|
|
21692
21692
|
while (getFileBrowserInFlightReadCount() > 0) {
|
|
21693
21693
|
await yieldToEventLoop();
|
|
21694
21694
|
if (getFileBrowserInFlightReadCount() > 0) {
|
|
21695
|
-
await new Promise((
|
|
21695
|
+
await new Promise((resolve36) => setTimeout(resolve36, pollMs));
|
|
21696
21696
|
}
|
|
21697
21697
|
}
|
|
21698
21698
|
}
|
|
@@ -21702,7 +21702,7 @@ async function yieldUntilFileBrowserBrowseIdle(pollMs = 5) {
|
|
|
21702
21702
|
const browseCooldownDone = lastActivityAt === 0 || Date.now() - lastActivityAt >= BROWSE_INDEX_COOLDOWN_MS;
|
|
21703
21703
|
if (inFlightRequests2 === 0 && browseCooldownDone) return;
|
|
21704
21704
|
await yieldToEventLoop();
|
|
21705
|
-
await new Promise((
|
|
21705
|
+
await new Promise((resolve36) => setTimeout(resolve36, pollMs));
|
|
21706
21706
|
}
|
|
21707
21707
|
}
|
|
21708
21708
|
async function yieldUntilFileBrowserIdle(pollMs = 5) {
|
|
@@ -21879,8 +21879,8 @@ function createRequestId(prefix) {
|
|
|
21879
21879
|
}
|
|
21880
21880
|
function waitForWorkerReady() {
|
|
21881
21881
|
if (workerReady) return Promise.resolve();
|
|
21882
|
-
return new Promise((
|
|
21883
|
-
workerReadyWaiters.push(
|
|
21882
|
+
return new Promise((resolve36) => {
|
|
21883
|
+
workerReadyWaiters.push(resolve36);
|
|
21884
21884
|
});
|
|
21885
21885
|
}
|
|
21886
21886
|
function registerWorkerReadyListener(listener) {
|
|
@@ -21892,7 +21892,7 @@ function registerWorkerReadyListener(listener) {
|
|
|
21892
21892
|
}
|
|
21893
21893
|
function markWorkerReady() {
|
|
21894
21894
|
workerReady = true;
|
|
21895
|
-
for (const
|
|
21895
|
+
for (const resolve36 of workerReadyWaiters) resolve36();
|
|
21896
21896
|
workerReadyWaiters = [];
|
|
21897
21897
|
workerReadyListener?.();
|
|
21898
21898
|
}
|
|
@@ -22039,7 +22039,7 @@ async function waitForOuterCodeNavCacheAccessAsync() {
|
|
|
22039
22039
|
if (isCliImmediateShutdownRequested() || isSymbolIndexWorkerShutdownRequested()) {
|
|
22040
22040
|
throw new CliSqliteInterrupted();
|
|
22041
22041
|
}
|
|
22042
|
-
await new Promise((
|
|
22042
|
+
await new Promise((resolve36) => setTimeout(resolve36, 5));
|
|
22043
22043
|
await yieldToEventLoop();
|
|
22044
22044
|
}
|
|
22045
22045
|
}
|
|
@@ -22376,7 +22376,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
|
|
|
22376
22376
|
join2(moduleDir, "..", sub, filename),
|
|
22377
22377
|
join2(moduleDir, "..", "..", "dist", sub, filename)
|
|
22378
22378
|
]);
|
|
22379
|
-
const resolved = candidates.find((
|
|
22379
|
+
const resolved = candidates.find((path86) => existsSync(path86));
|
|
22380
22380
|
if (!resolved) {
|
|
22381
22381
|
throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
|
|
22382
22382
|
}
|
|
@@ -23454,7 +23454,7 @@ var require_ignore = __commonJS({
|
|
|
23454
23454
|
// path matching.
|
|
23455
23455
|
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
23456
23456
|
// @returns {TestResult} true if a file is ignored
|
|
23457
|
-
test(
|
|
23457
|
+
test(path86, checkUnignored, mode) {
|
|
23458
23458
|
let ignored = false;
|
|
23459
23459
|
let unignored = false;
|
|
23460
23460
|
let matchedRule;
|
|
@@ -23463,7 +23463,7 @@ var require_ignore = __commonJS({
|
|
|
23463
23463
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
23464
23464
|
return;
|
|
23465
23465
|
}
|
|
23466
|
-
const matched = rule[mode].test(
|
|
23466
|
+
const matched = rule[mode].test(path86);
|
|
23467
23467
|
if (!matched) {
|
|
23468
23468
|
return;
|
|
23469
23469
|
}
|
|
@@ -23484,17 +23484,17 @@ var require_ignore = __commonJS({
|
|
|
23484
23484
|
var throwError = (message, Ctor) => {
|
|
23485
23485
|
throw new Ctor(message);
|
|
23486
23486
|
};
|
|
23487
|
-
var checkPath = (
|
|
23488
|
-
if (!isString(
|
|
23487
|
+
var checkPath = (path86, originalPath, doThrow) => {
|
|
23488
|
+
if (!isString(path86)) {
|
|
23489
23489
|
return doThrow(
|
|
23490
23490
|
`path must be a string, but got \`${originalPath}\``,
|
|
23491
23491
|
TypeError
|
|
23492
23492
|
);
|
|
23493
23493
|
}
|
|
23494
|
-
if (!
|
|
23494
|
+
if (!path86) {
|
|
23495
23495
|
return doThrow(`path must not be empty`, TypeError);
|
|
23496
23496
|
}
|
|
23497
|
-
if (checkPath.isNotRelative(
|
|
23497
|
+
if (checkPath.isNotRelative(path86)) {
|
|
23498
23498
|
const r = "`path.relative()`d";
|
|
23499
23499
|
return doThrow(
|
|
23500
23500
|
`path should be a ${r} string, but got "${originalPath}"`,
|
|
@@ -23503,7 +23503,7 @@ var require_ignore = __commonJS({
|
|
|
23503
23503
|
}
|
|
23504
23504
|
return true;
|
|
23505
23505
|
};
|
|
23506
|
-
var isNotRelative = (
|
|
23506
|
+
var isNotRelative = (path86) => REGEX_TEST_INVALID_PATH.test(path86);
|
|
23507
23507
|
checkPath.isNotRelative = isNotRelative;
|
|
23508
23508
|
checkPath.convert = (p) => p;
|
|
23509
23509
|
var Ignore = class {
|
|
@@ -23533,19 +23533,19 @@ var require_ignore = __commonJS({
|
|
|
23533
23533
|
}
|
|
23534
23534
|
// @returns {TestResult}
|
|
23535
23535
|
_test(originalPath, cache2, checkUnignored, slices) {
|
|
23536
|
-
const
|
|
23536
|
+
const path86 = originalPath && checkPath.convert(originalPath);
|
|
23537
23537
|
checkPath(
|
|
23538
|
-
|
|
23538
|
+
path86,
|
|
23539
23539
|
originalPath,
|
|
23540
23540
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
23541
23541
|
);
|
|
23542
|
-
return this._t(
|
|
23542
|
+
return this._t(path86, cache2, checkUnignored, slices);
|
|
23543
23543
|
}
|
|
23544
|
-
checkIgnore(
|
|
23545
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(
|
|
23546
|
-
return this.test(
|
|
23544
|
+
checkIgnore(path86) {
|
|
23545
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path86)) {
|
|
23546
|
+
return this.test(path86);
|
|
23547
23547
|
}
|
|
23548
|
-
const slices =
|
|
23548
|
+
const slices = path86.split(SLASH).filter(Boolean);
|
|
23549
23549
|
slices.pop();
|
|
23550
23550
|
if (slices.length) {
|
|
23551
23551
|
const parent = this._t(
|
|
@@ -23558,18 +23558,18 @@ var require_ignore = __commonJS({
|
|
|
23558
23558
|
return parent;
|
|
23559
23559
|
}
|
|
23560
23560
|
}
|
|
23561
|
-
return this._rules.test(
|
|
23561
|
+
return this._rules.test(path86, false, MODE_CHECK_IGNORE);
|
|
23562
23562
|
}
|
|
23563
|
-
_t(
|
|
23564
|
-
if (
|
|
23565
|
-
return cache2[
|
|
23563
|
+
_t(path86, cache2, checkUnignored, slices) {
|
|
23564
|
+
if (path86 in cache2) {
|
|
23565
|
+
return cache2[path86];
|
|
23566
23566
|
}
|
|
23567
23567
|
if (!slices) {
|
|
23568
|
-
slices =
|
|
23568
|
+
slices = path86.split(SLASH).filter(Boolean);
|
|
23569
23569
|
}
|
|
23570
23570
|
slices.pop();
|
|
23571
23571
|
if (!slices.length) {
|
|
23572
|
-
return cache2[
|
|
23572
|
+
return cache2[path86] = this._rules.test(path86, checkUnignored, MODE_IGNORE);
|
|
23573
23573
|
}
|
|
23574
23574
|
const parent = this._t(
|
|
23575
23575
|
slices.join(SLASH) + SLASH,
|
|
@@ -23577,29 +23577,29 @@ var require_ignore = __commonJS({
|
|
|
23577
23577
|
checkUnignored,
|
|
23578
23578
|
slices
|
|
23579
23579
|
);
|
|
23580
|
-
return cache2[
|
|
23580
|
+
return cache2[path86] = parent.ignored ? parent : this._rules.test(path86, checkUnignored, MODE_IGNORE);
|
|
23581
23581
|
}
|
|
23582
|
-
ignores(
|
|
23583
|
-
return this._test(
|
|
23582
|
+
ignores(path86) {
|
|
23583
|
+
return this._test(path86, this._ignoreCache, false).ignored;
|
|
23584
23584
|
}
|
|
23585
23585
|
createFilter() {
|
|
23586
|
-
return (
|
|
23586
|
+
return (path86) => !this.ignores(path86);
|
|
23587
23587
|
}
|
|
23588
23588
|
filter(paths) {
|
|
23589
23589
|
return makeArray(paths).filter(this.createFilter());
|
|
23590
23590
|
}
|
|
23591
23591
|
// @returns {TestResult}
|
|
23592
|
-
test(
|
|
23593
|
-
return this._test(
|
|
23592
|
+
test(path86) {
|
|
23593
|
+
return this._test(path86, this._testCache, true);
|
|
23594
23594
|
}
|
|
23595
23595
|
};
|
|
23596
23596
|
var factory = (options) => new Ignore(options);
|
|
23597
|
-
var isPathValid = (
|
|
23597
|
+
var isPathValid = (path86) => checkPath(path86 && checkPath.convert(path86), path86, RETURN_FALSE);
|
|
23598
23598
|
var setupWindows = () => {
|
|
23599
23599
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
23600
23600
|
checkPath.convert = makePosix;
|
|
23601
23601
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
23602
|
-
checkPath.isNotRelative = (
|
|
23602
|
+
checkPath.isNotRelative = (path86) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path86) || isNotRelative(path86);
|
|
23603
23603
|
};
|
|
23604
23604
|
if (
|
|
23605
23605
|
// Detect `process` so that it can run in browsers.
|
|
@@ -26790,7 +26790,7 @@ var init_setup_handlers = __esm({
|
|
|
26790
26790
|
// src/code-nav/symbol-index/worker/handle-message.ts
|
|
26791
26791
|
async function waitForActiveWorkerHandlersIdle(pollMs = 10) {
|
|
26792
26792
|
while (activeWorkerHandlers > 0) {
|
|
26793
|
-
await new Promise((
|
|
26793
|
+
await new Promise((resolve36) => setTimeout(resolve36, pollMs));
|
|
26794
26794
|
}
|
|
26795
26795
|
}
|
|
26796
26796
|
async function handleRequestMessage(port, msg) {
|
|
@@ -27033,9 +27033,9 @@ async function requestWorker(message) {
|
|
|
27033
27033
|
}
|
|
27034
27034
|
ensureWorkerStarted();
|
|
27035
27035
|
await ensureWorkerReadyForRequests();
|
|
27036
|
-
return new Promise((
|
|
27036
|
+
return new Promise((resolve36, reject) => {
|
|
27037
27037
|
pendingRequests.set(message.requestId, {
|
|
27038
|
-
resolve: (value) =>
|
|
27038
|
+
resolve: (value) => resolve36(value),
|
|
27039
27039
|
reject
|
|
27040
27040
|
});
|
|
27041
27041
|
postToWorker(message);
|
|
@@ -27061,37 +27061,37 @@ async function shutdownWorkerThread() {
|
|
|
27061
27061
|
if (activeWorker != null) {
|
|
27062
27062
|
setWorker(null);
|
|
27063
27063
|
await Promise.race([
|
|
27064
|
-
new Promise((
|
|
27064
|
+
new Promise((resolve36) => {
|
|
27065
27065
|
const onMessage = (message) => {
|
|
27066
27066
|
if (message.type !== "shutdownComplete") return;
|
|
27067
27067
|
activeWorker.off("message", onMessage);
|
|
27068
|
-
|
|
27068
|
+
resolve36();
|
|
27069
27069
|
};
|
|
27070
27070
|
activeWorker.on("message", onMessage);
|
|
27071
27071
|
try {
|
|
27072
27072
|
activeWorker.postMessage({ type: "shutdown" });
|
|
27073
27073
|
} catch {
|
|
27074
27074
|
activeWorker.off("message", onMessage);
|
|
27075
|
-
|
|
27075
|
+
resolve36();
|
|
27076
27076
|
}
|
|
27077
27077
|
}),
|
|
27078
|
-
new Promise((
|
|
27078
|
+
new Promise((resolve36) => setTimeout(resolve36, WORKER_SHUTDOWN_GRACE_MS))
|
|
27079
27079
|
]);
|
|
27080
27080
|
await activeWorker.terminate();
|
|
27081
27081
|
} else {
|
|
27082
27082
|
const inProcess = getInProcessBridge();
|
|
27083
27083
|
if (inProcess != null) {
|
|
27084
27084
|
await Promise.race([
|
|
27085
|
-
new Promise((
|
|
27085
|
+
new Promise((resolve36) => {
|
|
27086
27086
|
const onMessage = (message) => {
|
|
27087
27087
|
if (message.type !== "shutdownComplete") return;
|
|
27088
27088
|
inProcess.off("message", onMessage);
|
|
27089
|
-
|
|
27089
|
+
resolve36();
|
|
27090
27090
|
};
|
|
27091
27091
|
inProcess.on("message", onMessage);
|
|
27092
27092
|
inProcess.postMessage({ type: "shutdown" });
|
|
27093
27093
|
}),
|
|
27094
|
-
new Promise((
|
|
27094
|
+
new Promise((resolve36) => setTimeout(resolve36, WORKER_SHUTDOWN_GRACE_MS))
|
|
27095
27095
|
]);
|
|
27096
27096
|
}
|
|
27097
27097
|
}
|
|
@@ -27169,6 +27169,16 @@ async function awaitSymbolIndexWorkerShutdown() {
|
|
|
27169
27169
|
await terminateSymbolIndexWorker2();
|
|
27170
27170
|
}
|
|
27171
27171
|
}
|
|
27172
|
+
async function clearCliImmediateShutdown() {
|
|
27173
|
+
if (symbolIndexShutdownPromise != null) {
|
|
27174
|
+
try {
|
|
27175
|
+
await symbolIndexShutdownPromise;
|
|
27176
|
+
} catch {
|
|
27177
|
+
}
|
|
27178
|
+
}
|
|
27179
|
+
cliImmediateShutdownRequested = false;
|
|
27180
|
+
symbolIndexShutdownPromise = null;
|
|
27181
|
+
}
|
|
27172
27182
|
function resetCliImmediateShutdownForTests() {
|
|
27173
27183
|
cliImmediateShutdownRequested = false;
|
|
27174
27184
|
symbolIndexShutdownPromise = null;
|
|
@@ -27967,10 +27977,10 @@ var require_src2 = __commonJS({
|
|
|
27967
27977
|
var fs_1 = __require("fs");
|
|
27968
27978
|
var debug_1 = __importDefault(require_src());
|
|
27969
27979
|
var log2 = debug_1.default("@kwsites/file-exists");
|
|
27970
|
-
function check2(
|
|
27971
|
-
log2(`checking %s`,
|
|
27980
|
+
function check2(path86, isFile, isDirectory) {
|
|
27981
|
+
log2(`checking %s`, path86);
|
|
27972
27982
|
try {
|
|
27973
|
-
const stat2 = fs_1.statSync(
|
|
27983
|
+
const stat2 = fs_1.statSync(path86);
|
|
27974
27984
|
if (stat2.isFile() && isFile) {
|
|
27975
27985
|
log2(`[OK] path represents a file`);
|
|
27976
27986
|
return true;
|
|
@@ -27990,8 +28000,8 @@ var require_src2 = __commonJS({
|
|
|
27990
28000
|
throw e;
|
|
27991
28001
|
}
|
|
27992
28002
|
}
|
|
27993
|
-
function exists2(
|
|
27994
|
-
return check2(
|
|
28003
|
+
function exists2(path86, type = exports.READABLE) {
|
|
28004
|
+
return check2(path86, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
27995
28005
|
}
|
|
27996
28006
|
exports.exists = exists2;
|
|
27997
28007
|
exports.FILE = 1;
|
|
@@ -28122,6 +28132,29 @@ function safeSendWebSocketBinary(ws, data) {
|
|
|
28122
28132
|
}
|
|
28123
28133
|
}
|
|
28124
28134
|
|
|
28135
|
+
// src/connection/create-ws-bridge-options.ts
|
|
28136
|
+
var BRIDGE_AUTH_ERROR_HEADER = "x-bridge-auth-error";
|
|
28137
|
+
var BRIDGE_AUTH_ERROR_TOKEN_INVALID = "token_invalid";
|
|
28138
|
+
|
|
28139
|
+
// src/connection/dispatch-ws-inbound-message.ts
|
|
28140
|
+
function dispatchWsInboundMessage(raw, ws, onMessage, isActiveSocket) {
|
|
28141
|
+
if (isActiveSocket && !isActiveSocket(ws)) return;
|
|
28142
|
+
try {
|
|
28143
|
+
let data;
|
|
28144
|
+
if (typeof raw === "string") {
|
|
28145
|
+
data = JSON.parse(raw);
|
|
28146
|
+
} else if (Buffer.isBuffer(raw) || raw instanceof ArrayBuffer) {
|
|
28147
|
+
const str = Buffer.isBuffer(raw) ? raw.toString("utf8") : Buffer.from(raw).toString("utf8");
|
|
28148
|
+
data = JSON.parse(str);
|
|
28149
|
+
} else {
|
|
28150
|
+
data = raw;
|
|
28151
|
+
}
|
|
28152
|
+
onMessage?.(data, ws);
|
|
28153
|
+
} catch {
|
|
28154
|
+
onMessage?.(raw, ws);
|
|
28155
|
+
}
|
|
28156
|
+
}
|
|
28157
|
+
|
|
28125
28158
|
// src/connection/parse-compact-heartbeat-ack.ts
|
|
28126
28159
|
function tryParseCompactHeartbeatAck(raw) {
|
|
28127
28160
|
let str = null;
|
|
@@ -28149,8 +28182,6 @@ function tryParseCompactHeartbeatAck(raw) {
|
|
|
28149
28182
|
}
|
|
28150
28183
|
|
|
28151
28184
|
// src/connection/create-ws-bridge.ts
|
|
28152
|
-
var BRIDGE_AUTH_ERROR_HEADER = "x-bridge-auth-error";
|
|
28153
|
-
var BRIDGE_AUTH_ERROR_TOKEN_INVALID = "token_invalid";
|
|
28154
28185
|
function createWsBridge(options) {
|
|
28155
28186
|
const {
|
|
28156
28187
|
url: url2,
|
|
@@ -28161,15 +28192,16 @@ function createWsBridge(options) {
|
|
|
28161
28192
|
onAuthInvalid,
|
|
28162
28193
|
clientPingIntervalMs,
|
|
28163
28194
|
onCompactHeartbeatAck,
|
|
28164
|
-
isActiveSocket
|
|
28195
|
+
isActiveSocket,
|
|
28196
|
+
deferInboundMessages = true
|
|
28165
28197
|
} = options;
|
|
28166
28198
|
const ws = new wrapper_default(url2, buildCliWebSocketClientOptions(url2));
|
|
28167
28199
|
let clearClientPing = null;
|
|
28168
|
-
|
|
28200
|
+
const disposeClientPing = () => {
|
|
28169
28201
|
clearClientPing?.();
|
|
28170
28202
|
clearClientPing = null;
|
|
28171
|
-
}
|
|
28172
|
-
ws.on("unexpected-response", (
|
|
28203
|
+
};
|
|
28204
|
+
ws.on("unexpected-response", (_request, response) => {
|
|
28173
28205
|
const status = response?.statusCode ?? 0;
|
|
28174
28206
|
const headers = response?.headers ?? {};
|
|
28175
28207
|
const errCode = (headers[BRIDGE_AUTH_ERROR_HEADER] ?? headers["X-Bridge-Auth-Error"] ?? "").toLowerCase();
|
|
@@ -28190,23 +28222,11 @@ function createWsBridge(options) {
|
|
|
28190
28222
|
onCompactHeartbeatAck?.(ackSeq);
|
|
28191
28223
|
return;
|
|
28192
28224
|
}
|
|
28193
|
-
|
|
28194
|
-
|
|
28195
|
-
|
|
28196
|
-
|
|
28197
|
-
|
|
28198
|
-
data = JSON.parse(raw);
|
|
28199
|
-
} else if (Buffer.isBuffer(raw) || raw instanceof ArrayBuffer) {
|
|
28200
|
-
const str = Buffer.isBuffer(raw) ? raw.toString("utf8") : Buffer.from(raw).toString("utf8");
|
|
28201
|
-
data = JSON.parse(str);
|
|
28202
|
-
} else {
|
|
28203
|
-
data = raw;
|
|
28204
|
-
}
|
|
28205
|
-
onMessage?.(data, ws);
|
|
28206
|
-
} catch {
|
|
28207
|
-
onMessage?.(raw, ws);
|
|
28208
|
-
}
|
|
28209
|
-
});
|
|
28225
|
+
if (deferInboundMessages) {
|
|
28226
|
+
setImmediate(() => dispatchWsInboundMessage(raw, ws, onMessage, isActiveSocket));
|
|
28227
|
+
return;
|
|
28228
|
+
}
|
|
28229
|
+
dispatchWsInboundMessage(raw, ws, onMessage, isActiveSocket);
|
|
28210
28230
|
});
|
|
28211
28231
|
ws.on("close", (code, reason) => {
|
|
28212
28232
|
disposeClientPing();
|
|
@@ -28320,10 +28340,10 @@ async function killChildProcessTreeGracefully(child, graceMs = ACP_PROCESS_TREE_
|
|
|
28320
28340
|
}
|
|
28321
28341
|
await killProcessTree(pid, "SIGTERM");
|
|
28322
28342
|
if (graceMs <= 0) return;
|
|
28323
|
-
const exited = new Promise((
|
|
28324
|
-
child.once("exit", () =>
|
|
28343
|
+
const exited = new Promise((resolve36) => {
|
|
28344
|
+
child.once("exit", () => resolve36());
|
|
28325
28345
|
});
|
|
28326
|
-
await Promise.race([exited, new Promise((
|
|
28346
|
+
await Promise.race([exited, new Promise((resolve36) => setTimeout(resolve36, graceMs))]);
|
|
28327
28347
|
if (child.exitCode == null && child.signalCode == null) {
|
|
28328
28348
|
await killProcessTree(pid, "SIGKILL");
|
|
28329
28349
|
}
|
|
@@ -28340,8 +28360,8 @@ async function gracefulAcpSubprocessDisconnect(params) {
|
|
|
28340
28360
|
await transport.closeSession?.(sessionId);
|
|
28341
28361
|
} catch {
|
|
28342
28362
|
}
|
|
28343
|
-
await new Promise((
|
|
28344
|
-
const timer = setTimeout(
|
|
28363
|
+
await new Promise((resolve36) => {
|
|
28364
|
+
const timer = setTimeout(resolve36, ACP_GRACEFUL_SESSION_CLOSE_WAIT_MS);
|
|
28345
28365
|
timer.unref?.();
|
|
28346
28366
|
});
|
|
28347
28367
|
}
|
|
@@ -29491,11 +29511,11 @@ function createSdkStdioExtNotificationHandler(options) {
|
|
|
29491
29511
|
// src/agents/acp/clients/sdk/sdk-stdio-permission-request-handshake.ts
|
|
29492
29512
|
function awaitSdkStdioPermissionRequestHandshake(params) {
|
|
29493
29513
|
const { requestId, paramsRecord, pending: pending2, onRequest } = params;
|
|
29494
|
-
return new Promise((
|
|
29495
|
-
pending2.set(requestId, { resolve:
|
|
29514
|
+
return new Promise((resolve36) => {
|
|
29515
|
+
pending2.set(requestId, { resolve: resolve36, params: paramsRecord });
|
|
29496
29516
|
if (onRequest == null) {
|
|
29497
29517
|
pending2.delete(requestId);
|
|
29498
|
-
|
|
29518
|
+
resolve36({ outcome: { outcome: "denied" } });
|
|
29499
29519
|
return;
|
|
29500
29520
|
}
|
|
29501
29521
|
try {
|
|
@@ -30007,10 +30027,10 @@ function createSdkStdioInitSettle(child) {
|
|
|
30007
30027
|
forceAcpSubprocessDisconnect(child);
|
|
30008
30028
|
reject(err);
|
|
30009
30029
|
},
|
|
30010
|
-
settleResolve(
|
|
30030
|
+
settleResolve(resolve36, handle) {
|
|
30011
30031
|
if (initSettled) return;
|
|
30012
30032
|
initSettled = true;
|
|
30013
|
-
|
|
30033
|
+
resolve36(handle);
|
|
30014
30034
|
}
|
|
30015
30035
|
};
|
|
30016
30036
|
}
|
|
@@ -30099,7 +30119,7 @@ async function createSdkStdioAcpClient(options) {
|
|
|
30099
30119
|
onFileChange,
|
|
30100
30120
|
stderrCapture
|
|
30101
30121
|
});
|
|
30102
|
-
return new Promise((
|
|
30122
|
+
return new Promise((resolve36, reject) => {
|
|
30103
30123
|
const init = createSdkStdioInitSettle(child);
|
|
30104
30124
|
child.on("error", (err) => {
|
|
30105
30125
|
init.settleReject(reject, new Error(formatSpawnError(err, command[0])));
|
|
@@ -30124,7 +30144,7 @@ async function createSdkStdioAcpClient(options) {
|
|
|
30124
30144
|
protocolVersion: PROTOCOL_VERSION2
|
|
30125
30145
|
});
|
|
30126
30146
|
init.settleResolve(
|
|
30127
|
-
|
|
30147
|
+
resolve36,
|
|
30128
30148
|
createSdkStdioHandle({
|
|
30129
30149
|
child,
|
|
30130
30150
|
sessionId: established.sessionId,
|
|
@@ -30260,19 +30280,19 @@ function buildLocalHttpRequestOptions(built) {
|
|
|
30260
30280
|
}
|
|
30261
30281
|
function runLocalHttpRequestOnce(mod, built) {
|
|
30262
30282
|
const opts = buildLocalHttpRequestOptions(built);
|
|
30263
|
-
return new Promise((
|
|
30283
|
+
return new Promise((resolve36) => {
|
|
30264
30284
|
const req = mod.request(opts, (res) => {
|
|
30265
30285
|
const chunks = [];
|
|
30266
30286
|
res.on("data", (chunk) => chunks.push(chunk));
|
|
30267
30287
|
res.on("end", () => {
|
|
30268
|
-
|
|
30288
|
+
resolve36({
|
|
30269
30289
|
statusCode: res.statusCode ?? 0,
|
|
30270
30290
|
headers: incomingMessageHeaders(res),
|
|
30271
30291
|
body: Buffer.concat(chunks)
|
|
30272
30292
|
});
|
|
30273
30293
|
});
|
|
30274
30294
|
res.on("error", (err) => {
|
|
30275
|
-
|
|
30295
|
+
resolve36({
|
|
30276
30296
|
statusCode: 0,
|
|
30277
30297
|
headers: {},
|
|
30278
30298
|
body: Buffer.alloc(0),
|
|
@@ -30284,7 +30304,7 @@ function runLocalHttpRequestOnce(mod, built) {
|
|
|
30284
30304
|
req.destroy(new Error(`Local preview request timed out after ${LOCAL_PROXY_REQUEST_TIMEOUT_MS}ms`));
|
|
30285
30305
|
});
|
|
30286
30306
|
req.on("error", (err) => {
|
|
30287
|
-
|
|
30307
|
+
resolve36({
|
|
30288
30308
|
statusCode: 0,
|
|
30289
30309
|
headers: {},
|
|
30290
30310
|
body: Buffer.alloc(0),
|
|
@@ -30340,14 +30360,14 @@ async function proxyToLocalStreaming(request, callbacks) {
|
|
|
30340
30360
|
const isHttps = request.url.startsWith("https:");
|
|
30341
30361
|
const mod = await loadHttpModule(isHttps);
|
|
30342
30362
|
const opts = buildLocalHttpRequestOptions(built);
|
|
30343
|
-
await new Promise((
|
|
30363
|
+
await new Promise((resolve36) => {
|
|
30344
30364
|
const req = mod.request(opts, (res) => {
|
|
30345
30365
|
try {
|
|
30346
30366
|
callbacks.onStart(res.statusCode ?? 0, incomingMessageHeaders(res));
|
|
30347
30367
|
} catch (err) {
|
|
30348
30368
|
req.destroy();
|
|
30349
30369
|
callbacks.onError(err instanceof Error ? err.message : String(err));
|
|
30350
|
-
|
|
30370
|
+
resolve36();
|
|
30351
30371
|
return;
|
|
30352
30372
|
}
|
|
30353
30373
|
res.on("data", (chunk) => {
|
|
@@ -30360,11 +30380,11 @@ async function proxyToLocalStreaming(request, callbacks) {
|
|
|
30360
30380
|
});
|
|
30361
30381
|
res.on("end", () => {
|
|
30362
30382
|
callbacks.onEnd();
|
|
30363
|
-
|
|
30383
|
+
resolve36();
|
|
30364
30384
|
});
|
|
30365
30385
|
res.on("error", (err) => {
|
|
30366
30386
|
callbacks.onError(err.message);
|
|
30367
|
-
|
|
30387
|
+
resolve36();
|
|
30368
30388
|
});
|
|
30369
30389
|
});
|
|
30370
30390
|
req.setTimeout(LOCAL_PROXY_REQUEST_TIMEOUT_MS, () => {
|
|
@@ -30372,7 +30392,7 @@ async function proxyToLocalStreaming(request, callbacks) {
|
|
|
30372
30392
|
});
|
|
30373
30393
|
req.on("error", (err) => {
|
|
30374
30394
|
callbacks.onError(err.message);
|
|
30375
|
-
|
|
30395
|
+
resolve36();
|
|
30376
30396
|
});
|
|
30377
30397
|
if (built.sendingBody && built.body != null) {
|
|
30378
30398
|
req.write(built.body);
|
|
@@ -30402,8 +30422,8 @@ function randomSecret() {
|
|
|
30402
30422
|
}
|
|
30403
30423
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
30404
30424
|
}
|
|
30405
|
-
async function requestPreviewApi(port, secret, method,
|
|
30406
|
-
const url2 = `http://127.0.0.1:${port}${
|
|
30425
|
+
async function requestPreviewApi(port, secret, method, path86, body) {
|
|
30426
|
+
const url2 = `http://127.0.0.1:${port}${path86}`;
|
|
30407
30427
|
const headers = {
|
|
30408
30428
|
[PREVIEW_SECRET_HEADER]: secret,
|
|
30409
30429
|
"Content-Type": "application/json"
|
|
@@ -30415,7 +30435,7 @@ async function requestPreviewApi(port, secret, method, path84, body) {
|
|
|
30415
30435
|
});
|
|
30416
30436
|
const data = await res.json().catch(() => ({}));
|
|
30417
30437
|
if (!res.ok) {
|
|
30418
|
-
throw new Error(data?.error ?? `Preview API ${method} ${
|
|
30438
|
+
throw new Error(data?.error ?? `Preview API ${method} ${path86}: ${res.status}`);
|
|
30419
30439
|
}
|
|
30420
30440
|
return data;
|
|
30421
30441
|
}
|
|
@@ -30637,14 +30657,8 @@ function installBridgeProcessResilience() {
|
|
|
30637
30657
|
});
|
|
30638
30658
|
}
|
|
30639
30659
|
|
|
30640
|
-
// src/
|
|
30641
|
-
|
|
30642
|
-
|
|
30643
|
-
// src/connection/heartbeat/constants.ts
|
|
30644
|
-
var BRIDGE_APP_HEARTBEAT_INTERVAL_MS = 1e4;
|
|
30645
|
-
var BRIDGE_HEARTBEAT_SEQ_MAX = 2147483646;
|
|
30646
|
-
var BRIDGE_HEARTBEAT_MISSED_ACKS_BEFORE_RECONNECT = 4;
|
|
30647
|
-
var BRIDGE_HEARTBEAT_RTT_SAMPLE_MAX = 5;
|
|
30660
|
+
// src/auth/pending/run-pending-auth.ts
|
|
30661
|
+
init_log();
|
|
30648
30662
|
|
|
30649
30663
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
30650
30664
|
import process7 from "node:process";
|
|
@@ -31079,14 +31093,14 @@ var baseOpen = async (options) => {
|
|
|
31079
31093
|
}
|
|
31080
31094
|
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
31081
31095
|
if (options.wait) {
|
|
31082
|
-
return new Promise((
|
|
31096
|
+
return new Promise((resolve36, reject) => {
|
|
31083
31097
|
subprocess.once("error", reject);
|
|
31084
31098
|
subprocess.once("close", (exitCode) => {
|
|
31085
31099
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
31086
31100
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
31087
31101
|
return;
|
|
31088
31102
|
}
|
|
31089
|
-
|
|
31103
|
+
resolve36(subprocess);
|
|
31090
31104
|
});
|
|
31091
31105
|
});
|
|
31092
31106
|
}
|
|
@@ -31199,8 +31213,16 @@ async function openBrowser(connectionId, initialWorkspaceId, preferredBridgeName
|
|
|
31199
31213
|
}
|
|
31200
31214
|
}
|
|
31201
31215
|
|
|
31202
|
-
// src/auth/
|
|
31203
|
-
|
|
31216
|
+
// src/auth/pending/constants.ts
|
|
31217
|
+
var PENDING_KEEPALIVE_MS = 25e3;
|
|
31218
|
+
var BROWSER_OPEN_FALLBACK_MS = 4e3;
|
|
31219
|
+
|
|
31220
|
+
// src/auth/pending/build-pending-bridge-url.ts
|
|
31221
|
+
function buildPendingBridgeUrl(apiUrl, connectionId) {
|
|
31222
|
+
const base = apiUrl.startsWith("https") ? apiUrl.replace(/^https/, "wss") : apiUrl.replace(/^http/, "ws");
|
|
31223
|
+
const params = new URLSearchParams({ connectionId });
|
|
31224
|
+
return `${base}/ws/bridge/pending?${params.toString()}`;
|
|
31225
|
+
}
|
|
31204
31226
|
|
|
31205
31227
|
// src/connection/reconnect/constants.ts
|
|
31206
31228
|
var RECONNECT_QUIET_MS = 2e3;
|
|
@@ -31531,6 +31553,12 @@ function scheduleMainBridgeReconnect(state, connect, log2, closeMeta) {
|
|
|
31531
31553
|
});
|
|
31532
31554
|
}
|
|
31533
31555
|
|
|
31556
|
+
// src/connection/heartbeat/constants.ts
|
|
31557
|
+
var BRIDGE_APP_HEARTBEAT_INTERVAL_MS = 1e4;
|
|
31558
|
+
var BRIDGE_HEARTBEAT_SEQ_MAX = 2147483646;
|
|
31559
|
+
var BRIDGE_HEARTBEAT_MISSED_ACKS_BEFORE_RECONNECT = 4;
|
|
31560
|
+
var BRIDGE_HEARTBEAT_RTT_SAMPLE_MAX = 5;
|
|
31561
|
+
|
|
31534
31562
|
// src/connection/reconnect/duplicate-bridge-connection-detect.ts
|
|
31535
31563
|
var BRIDGE_SUPERSEDED_CLOSE_REASON_SNIPPET = "superseded";
|
|
31536
31564
|
var DUPLICATE_BRIDGE_SHORT_SESSION_MS = 25e3;
|
|
@@ -31615,145 +31643,180 @@ function clearFirehoseReconnectQuietOnOpen(ctx, log2) {
|
|
|
31615
31643
|
});
|
|
31616
31644
|
}
|
|
31617
31645
|
|
|
31618
|
-
// src/auth/
|
|
31619
|
-
|
|
31620
|
-
|
|
31621
|
-
|
|
31622
|
-
|
|
31623
|
-
|
|
31624
|
-
|
|
31625
|
-
}
|
|
31626
|
-
|
|
31627
|
-
const { apiUrl, initialWorkspaceId, preferredBridgeName, onAuth } = options;
|
|
31628
|
-
const logFn = options.log ?? log;
|
|
31629
|
-
let ws = null;
|
|
31630
|
-
let reconnectTimeout = null;
|
|
31631
|
-
let keepaliveInterval = null;
|
|
31632
|
-
let browserFallback = null;
|
|
31633
|
-
const connectionId = crypto.randomUUID();
|
|
31634
|
-
let hasOpenedBrowser = false;
|
|
31635
|
-
let resolved = false;
|
|
31636
|
-
let resolveAuth;
|
|
31637
|
-
const authPromise = new Promise((resolve35) => {
|
|
31638
|
-
resolveAuth = resolve35;
|
|
31639
|
-
});
|
|
31640
|
-
let reconnectAttempt = 0;
|
|
31641
|
-
const signInQuiet = createEmptyReconnectQuietSlot();
|
|
31642
|
-
function clearQuietOnOpen() {
|
|
31643
|
-
clearReconnectQuietOnSuccessfulConnection(
|
|
31644
|
-
signInQuiet,
|
|
31645
|
-
logFn,
|
|
31646
|
-
"[Bridge service] Sign-in connection restored."
|
|
31647
|
-
);
|
|
31648
|
-
reconnectAttempt = 0;
|
|
31649
|
-
}
|
|
31650
|
-
function beginDeferredPendingCloseLog(code, reason) {
|
|
31646
|
+
// src/auth/pending/pending-auth-on-close.ts
|
|
31647
|
+
function createPendingAuthOnClose(params) {
|
|
31648
|
+
const { session, log: log2, connect } = params;
|
|
31649
|
+
return (code, reason) => {
|
|
31650
|
+
if (session.keepaliveInterval) {
|
|
31651
|
+
clearInterval(session.keepaliveInterval);
|
|
31652
|
+
session.keepaliveInterval = null;
|
|
31653
|
+
}
|
|
31654
|
+
if (session.resolved) return;
|
|
31651
31655
|
beginDeferredDisconnectForReconnect({
|
|
31652
|
-
isClosedByUser: () => resolved,
|
|
31653
|
-
quiet: signInQuiet,
|
|
31656
|
+
isClosedByUser: () => session.resolved,
|
|
31657
|
+
quiet: session.signInQuiet,
|
|
31654
31658
|
code,
|
|
31655
31659
|
reason,
|
|
31656
31660
|
willReconnect: true,
|
|
31657
|
-
log:
|
|
31661
|
+
log: log2,
|
|
31658
31662
|
serviceLabel: "[Bridge service]",
|
|
31659
31663
|
shutdownDetail: "Not reconnecting (shutting down).",
|
|
31660
31664
|
reconnectingDetail: "Waiting for browser sign-in; reconnecting\u2026",
|
|
31661
|
-
shouldAbortQuietWindow: () => ws != null && ws.readyState === wrapper_default.OPEN
|
|
31665
|
+
shouldAbortQuietWindow: () => session.ws != null && session.ws.readyState === wrapper_default.OPEN
|
|
31662
31666
|
});
|
|
31663
|
-
|
|
31664
|
-
|
|
31665
|
-
|
|
31666
|
-
|
|
31667
|
-
|
|
31668
|
-
|
|
31669
|
-
|
|
31670
|
-
if (browserFallback) {
|
|
31671
|
-
clearTimeout(browserFallback);
|
|
31672
|
-
browserFallback = null;
|
|
31673
|
-
}
|
|
31674
|
-
if (keepaliveInterval) {
|
|
31675
|
-
clearInterval(keepaliveInterval);
|
|
31676
|
-
keepaliveInterval = null;
|
|
31677
|
-
}
|
|
31678
|
-
if (ws) {
|
|
31679
|
-
const w = ws;
|
|
31680
|
-
ws = null;
|
|
31681
|
-
safeCloseWebSocket(w);
|
|
31667
|
+
const delay4 = pendingAuthReconnectDelayMs(session.reconnectAttempt);
|
|
31668
|
+
session.reconnectAttempt += 1;
|
|
31669
|
+
if (session.signInQuiet.verboseLogs) {
|
|
31670
|
+
const delayLabel = formatReconnectDelayForLog(delay4);
|
|
31671
|
+
log2(
|
|
31672
|
+
`[Bridge service] Next sign-in connection attempt in ${delayLabel} (attempt ${session.reconnectAttempt}).`
|
|
31673
|
+
);
|
|
31682
31674
|
}
|
|
31675
|
+
session.reconnectTimeout = setTimeout(() => {
|
|
31676
|
+
session.reconnectTimeout = null;
|
|
31677
|
+
connect();
|
|
31678
|
+
}, delay4);
|
|
31679
|
+
};
|
|
31680
|
+
}
|
|
31681
|
+
|
|
31682
|
+
// src/auth/pending/pending-auth-session.ts
|
|
31683
|
+
function createPendingAuthSession() {
|
|
31684
|
+
let resolveAuth;
|
|
31685
|
+
const authPromise = new Promise((resolve36) => {
|
|
31686
|
+
resolveAuth = resolve36;
|
|
31687
|
+
});
|
|
31688
|
+
return {
|
|
31689
|
+
ws: null,
|
|
31690
|
+
reconnectTimeout: null,
|
|
31691
|
+
keepaliveInterval: null,
|
|
31692
|
+
browserFallback: null,
|
|
31693
|
+
connectionId: crypto.randomUUID(),
|
|
31694
|
+
hasOpenedBrowser: false,
|
|
31695
|
+
resolved: false,
|
|
31696
|
+
resolveAuth,
|
|
31697
|
+
reconnectAttempt: 0,
|
|
31698
|
+
signInQuiet: createEmptyReconnectQuietSlot(),
|
|
31699
|
+
authPromise
|
|
31700
|
+
};
|
|
31701
|
+
}
|
|
31702
|
+
function cleanupPendingAuthSession(session) {
|
|
31703
|
+
clearReconnectQuietTimer(session.signInQuiet);
|
|
31704
|
+
if (session.reconnectTimeout) {
|
|
31705
|
+
clearTimeout(session.reconnectTimeout);
|
|
31706
|
+
session.reconnectTimeout = null;
|
|
31683
31707
|
}
|
|
31684
|
-
|
|
31685
|
-
|
|
31686
|
-
|
|
31687
|
-
ws = createWsBridge({
|
|
31688
|
-
url: url2,
|
|
31689
|
-
onOpen: () => {
|
|
31690
|
-
clearQuietOnOpen();
|
|
31691
|
-
pendingHbSeq = -1;
|
|
31692
|
-
sendWsMessage(ws, { type: "identify", role: "cli", cliVersion: CLI_VERSION });
|
|
31693
|
-
keepaliveInterval = setInterval(() => {
|
|
31694
|
-
if (resolved || !ws || ws.readyState !== 1) return;
|
|
31695
|
-
pendingHbSeq = pendingHbSeq >= BRIDGE_HEARTBEAT_SEQ_MAX ? 0 : pendingHbSeq + 1;
|
|
31696
|
-
const hb = { t: "h", s: pendingHbSeq };
|
|
31697
|
-
sendWsMessage(ws, hb);
|
|
31698
|
-
}, PENDING_KEEPALIVE_MS);
|
|
31699
|
-
if (browserFallback) {
|
|
31700
|
-
clearTimeout(browserFallback);
|
|
31701
|
-
browserFallback = null;
|
|
31702
|
-
}
|
|
31703
|
-
if (!hasOpenedBrowser) {
|
|
31704
|
-
hasOpenedBrowser = true;
|
|
31705
|
-
void openBrowser(connectionId, initialWorkspaceId, preferredBridgeName, apiUrl, logFn);
|
|
31706
|
-
}
|
|
31707
|
-
},
|
|
31708
|
-
onClose: (code, reason) => {
|
|
31709
|
-
if (keepaliveInterval) {
|
|
31710
|
-
clearInterval(keepaliveInterval);
|
|
31711
|
-
keepaliveInterval = null;
|
|
31712
|
-
}
|
|
31713
|
-
if (resolved) return;
|
|
31714
|
-
beginDeferredPendingCloseLog(code, reason);
|
|
31715
|
-
const delay4 = pendingAuthReconnectDelayMs(reconnectAttempt);
|
|
31716
|
-
reconnectAttempt += 1;
|
|
31717
|
-
if (signInQuiet.verboseLogs) {
|
|
31718
|
-
const delayLabel = formatReconnectDelayForLog(delay4);
|
|
31719
|
-
logFn(
|
|
31720
|
-
`[Bridge service] Next sign-in connection attempt in ${delayLabel} (attempt ${reconnectAttempt}).`
|
|
31721
|
-
);
|
|
31722
|
-
}
|
|
31723
|
-
reconnectTimeout = setTimeout(() => {
|
|
31724
|
-
reconnectTimeout = null;
|
|
31725
|
-
connect();
|
|
31726
|
-
}, delay4);
|
|
31727
|
-
},
|
|
31728
|
-
onError: (err) => logCliWebSocketError(logFn, "[Bridge service]", err, "while waiting for sign-in"),
|
|
31729
|
-
onMessage: (data) => {
|
|
31730
|
-
const msg = data;
|
|
31731
|
-
if (msg.type === "auth_token" && typeof msg.token === "string") {
|
|
31732
|
-
resolved = true;
|
|
31733
|
-
const workspaceId = typeof msg.workspaceId === "string" ? msg.workspaceId : "";
|
|
31734
|
-
cleanup();
|
|
31735
|
-
const refreshToken = typeof msg.refreshToken === "string" ? msg.refreshToken : void 0;
|
|
31736
|
-
const result = { workspaceId, token: msg.token, refreshToken };
|
|
31737
|
-
resolveAuth(result);
|
|
31738
|
-
onAuth(result);
|
|
31739
|
-
}
|
|
31740
|
-
}
|
|
31741
|
-
});
|
|
31708
|
+
if (session.browserFallback) {
|
|
31709
|
+
clearTimeout(session.browserFallback);
|
|
31710
|
+
session.browserFallback = null;
|
|
31742
31711
|
}
|
|
31743
|
-
|
|
31744
|
-
|
|
31745
|
-
|
|
31746
|
-
|
|
31747
|
-
|
|
31712
|
+
if (session.keepaliveInterval) {
|
|
31713
|
+
clearInterval(session.keepaliveInterval);
|
|
31714
|
+
session.keepaliveInterval = null;
|
|
31715
|
+
}
|
|
31716
|
+
if (session.ws) {
|
|
31717
|
+
const w = session.ws;
|
|
31718
|
+
session.ws = null;
|
|
31719
|
+
safeCloseWebSocket(w);
|
|
31720
|
+
}
|
|
31721
|
+
}
|
|
31722
|
+
|
|
31723
|
+
// src/auth/pending/pending-auth-on-message.ts
|
|
31724
|
+
function createPendingAuthOnMessage(params) {
|
|
31725
|
+
const { session, onAuth } = params;
|
|
31726
|
+
return (data) => {
|
|
31727
|
+
const msg = data;
|
|
31728
|
+
if (msg.type !== "auth_token" || typeof msg.token !== "string") return;
|
|
31729
|
+
session.resolved = true;
|
|
31730
|
+
const workspaceId = typeof msg.workspaceId === "string" ? msg.workspaceId : "";
|
|
31731
|
+
const refreshToken = typeof msg.refreshToken === "string" ? msg.refreshToken : void 0;
|
|
31732
|
+
const result = { workspaceId, token: msg.token, refreshToken };
|
|
31733
|
+
session.resolveAuth(result);
|
|
31734
|
+
onAuth(result);
|
|
31735
|
+
cleanupPendingAuthSession(session);
|
|
31736
|
+
};
|
|
31737
|
+
}
|
|
31738
|
+
|
|
31739
|
+
// src/cli-version.ts
|
|
31740
|
+
var CLI_VERSION = "0.1.81".length > 0 ? "0.1.81" : "0.0.0-dev";
|
|
31741
|
+
|
|
31742
|
+
// src/auth/pending/pending-auth-on-open.ts
|
|
31743
|
+
function createPendingAuthOnOpen(params) {
|
|
31744
|
+
const { session, apiUrl, initialWorkspaceId, preferredBridgeName, log: log2 } = params;
|
|
31745
|
+
let pendingHbSeq = -1;
|
|
31746
|
+
return () => {
|
|
31747
|
+
clearReconnectQuietOnSuccessfulConnection(
|
|
31748
|
+
session.signInQuiet,
|
|
31749
|
+
log2,
|
|
31750
|
+
"[Bridge service] Sign-in connection restored."
|
|
31751
|
+
);
|
|
31752
|
+
session.reconnectAttempt = 0;
|
|
31753
|
+
pendingHbSeq = -1;
|
|
31754
|
+
sendWsMessage(session.ws, { type: "identify", role: "cli", cliVersion: CLI_VERSION });
|
|
31755
|
+
session.keepaliveInterval = setInterval(() => {
|
|
31756
|
+
if (session.resolved || !session.ws || session.ws.readyState !== 1) return;
|
|
31757
|
+
pendingHbSeq = pendingHbSeq >= BRIDGE_HEARTBEAT_SEQ_MAX ? 0 : pendingHbSeq + 1;
|
|
31758
|
+
const hb = { t: "h", s: pendingHbSeq };
|
|
31759
|
+
sendWsMessage(session.ws, hb);
|
|
31760
|
+
}, PENDING_KEEPALIVE_MS);
|
|
31761
|
+
if (session.browserFallback) {
|
|
31762
|
+
clearTimeout(session.browserFallback);
|
|
31763
|
+
session.browserFallback = null;
|
|
31764
|
+
}
|
|
31765
|
+
if (!session.hasOpenedBrowser) {
|
|
31766
|
+
session.hasOpenedBrowser = true;
|
|
31767
|
+
void openBrowser(session.connectionId, initialWorkspaceId, preferredBridgeName, apiUrl, log2);
|
|
31768
|
+
}
|
|
31769
|
+
};
|
|
31770
|
+
}
|
|
31771
|
+
|
|
31772
|
+
// src/auth/pending/connect-pending-auth.ts
|
|
31773
|
+
function connectPendingAuth(params) {
|
|
31774
|
+
const { session, apiUrl, initialWorkspaceId, preferredBridgeName, onAuth, log: log2 } = params;
|
|
31775
|
+
const connect = () => {
|
|
31776
|
+
session.ws = createWsBridge({
|
|
31777
|
+
url: buildPendingBridgeUrl(apiUrl, session.connectionId),
|
|
31778
|
+
deferInboundMessages: false,
|
|
31779
|
+
onOpen: createPendingAuthOnOpen({
|
|
31780
|
+
session,
|
|
31781
|
+
apiUrl,
|
|
31782
|
+
initialWorkspaceId,
|
|
31783
|
+
preferredBridgeName,
|
|
31784
|
+
log: log2
|
|
31785
|
+
}),
|
|
31786
|
+
onClose: createPendingAuthOnClose({ session, log: log2, connect }),
|
|
31787
|
+
onError: (err) => logCliWebSocketError(log2, "[Bridge service]", err, "while waiting for sign-in"),
|
|
31788
|
+
onMessage: createPendingAuthOnMessage({ session, onAuth })
|
|
31789
|
+
});
|
|
31790
|
+
};
|
|
31791
|
+
connect();
|
|
31792
|
+
}
|
|
31793
|
+
|
|
31794
|
+
// src/auth/pending/run-pending-auth.ts
|
|
31795
|
+
function runPendingAuth(options) {
|
|
31796
|
+
const { apiUrl, initialWorkspaceId, preferredBridgeName, onAuth } = options;
|
|
31797
|
+
const logFn = options.log ?? log;
|
|
31798
|
+
const session = createPendingAuthSession();
|
|
31799
|
+
session.browserFallback = setTimeout(() => {
|
|
31800
|
+
session.browserFallback = null;
|
|
31801
|
+
if (!session.hasOpenedBrowser) {
|
|
31802
|
+
session.hasOpenedBrowser = true;
|
|
31803
|
+
void openBrowser(session.connectionId, initialWorkspaceId, preferredBridgeName, apiUrl, logFn);
|
|
31748
31804
|
}
|
|
31749
31805
|
}, BROWSER_OPEN_FALLBACK_MS);
|
|
31750
|
-
|
|
31806
|
+
connectPendingAuth({
|
|
31807
|
+
session,
|
|
31808
|
+
apiUrl,
|
|
31809
|
+
initialWorkspaceId,
|
|
31810
|
+
preferredBridgeName,
|
|
31811
|
+
onAuth,
|
|
31812
|
+
log: logFn
|
|
31813
|
+
});
|
|
31751
31814
|
return {
|
|
31752
31815
|
close: () => {
|
|
31753
|
-
if (!resolved) resolveAuth(null);
|
|
31754
|
-
|
|
31816
|
+
if (!session.resolved) session.resolveAuth(null);
|
|
31817
|
+
cleanupPendingAuthSession(session);
|
|
31755
31818
|
},
|
|
31756
|
-
authPromise
|
|
31819
|
+
authPromise: session.authPromise
|
|
31757
31820
|
};
|
|
31758
31821
|
}
|
|
31759
31822
|
|
|
@@ -33712,7 +33775,7 @@ async function createCursorAcpClient(options) {
|
|
|
33712
33775
|
onFileChange,
|
|
33713
33776
|
stderrCapture
|
|
33714
33777
|
});
|
|
33715
|
-
return new Promise((
|
|
33778
|
+
return new Promise((resolve36, reject) => {
|
|
33716
33779
|
child.on("error", (err) => {
|
|
33717
33780
|
killChildProcessTree(child, "SIGKILL");
|
|
33718
33781
|
reject(new Error(formatSpawnError(err, command[0])));
|
|
@@ -33725,7 +33788,7 @@ async function createCursorAcpClient(options) {
|
|
|
33725
33788
|
skipBrowserAuthenticate,
|
|
33726
33789
|
incomingDeps: { dbgFs, sessionCtx, onSessionUpdate, onRequest }
|
|
33727
33790
|
});
|
|
33728
|
-
|
|
33791
|
+
resolve36(
|
|
33729
33792
|
createCursorAcpHandle({
|
|
33730
33793
|
child,
|
|
33731
33794
|
sessionId: established.sessionId,
|
|
@@ -35164,8 +35227,8 @@ async function runGitTask(fn) {
|
|
|
35164
35227
|
}
|
|
35165
35228
|
async function yieldToEventLoop2() {
|
|
35166
35229
|
throwIfGitShutdownRequested();
|
|
35167
|
-
await new Promise((
|
|
35168
|
-
setImmediate(
|
|
35230
|
+
await new Promise((resolve36) => {
|
|
35231
|
+
setImmediate(resolve36);
|
|
35169
35232
|
});
|
|
35170
35233
|
throwIfGitShutdownRequested();
|
|
35171
35234
|
}
|
|
@@ -35202,8 +35265,8 @@ async function execGitFile(args, options) {
|
|
|
35202
35265
|
}
|
|
35203
35266
|
|
|
35204
35267
|
// src/git/changes/parse/normalize-git-diff-path.ts
|
|
35205
|
-
function normalizeGitDiffPath(
|
|
35206
|
-
return
|
|
35268
|
+
function normalizeGitDiffPath(path86) {
|
|
35269
|
+
return path86.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
|
|
35207
35270
|
}
|
|
35208
35271
|
|
|
35209
35272
|
// src/git/changes/parse/parse-name-status-entries.ts
|
|
@@ -36692,11 +36755,11 @@ function isServerNotRunningError(err) {
|
|
|
36692
36755
|
}
|
|
36693
36756
|
function closeHttpServer(server) {
|
|
36694
36757
|
if (!server) return Promise.resolve();
|
|
36695
|
-
return new Promise((
|
|
36758
|
+
return new Promise((resolve36) => {
|
|
36696
36759
|
server.close((err) => {
|
|
36697
36760
|
if (err && !isServerNotRunningError(err)) {
|
|
36698
36761
|
}
|
|
36699
|
-
|
|
36762
|
+
resolve36();
|
|
36700
36763
|
});
|
|
36701
36764
|
});
|
|
36702
36765
|
}
|
|
@@ -36709,7 +36772,7 @@ var RequestBodyTooLargeError = class extends Error {
|
|
|
36709
36772
|
}
|
|
36710
36773
|
};
|
|
36711
36774
|
function readJsonBody(req) {
|
|
36712
|
-
return new Promise((
|
|
36775
|
+
return new Promise((resolve36, reject) => {
|
|
36713
36776
|
const chunks = [];
|
|
36714
36777
|
let total = 0;
|
|
36715
36778
|
let tooLarge = false;
|
|
@@ -36729,11 +36792,11 @@ function readJsonBody(req) {
|
|
|
36729
36792
|
try {
|
|
36730
36793
|
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
36731
36794
|
if (!raw) {
|
|
36732
|
-
|
|
36795
|
+
resolve36({});
|
|
36733
36796
|
return;
|
|
36734
36797
|
}
|
|
36735
36798
|
const parsed = JSON.parse(raw);
|
|
36736
|
-
|
|
36799
|
+
resolve36(parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {});
|
|
36737
36800
|
} catch (e) {
|
|
36738
36801
|
reject(e);
|
|
36739
36802
|
}
|
|
@@ -36791,7 +36854,7 @@ function createBridgeAccessRequestHandler(registry2) {
|
|
|
36791
36854
|
// src/mcp/bridge-access/start-server.ts
|
|
36792
36855
|
function startBridgeAccessServer(registry2) {
|
|
36793
36856
|
const server = http.createServer(createBridgeAccessRequestHandler(registry2));
|
|
36794
|
-
return new Promise((
|
|
36857
|
+
return new Promise((resolve36, reject) => {
|
|
36795
36858
|
server.once("error", reject);
|
|
36796
36859
|
server.listen(0, "127.0.0.1", () => {
|
|
36797
36860
|
const addr = server.address();
|
|
@@ -36799,7 +36862,7 @@ function startBridgeAccessServer(registry2) {
|
|
|
36799
36862
|
reject(new Error("Bridge access server did not bind"));
|
|
36800
36863
|
return;
|
|
36801
36864
|
}
|
|
36802
|
-
|
|
36865
|
+
resolve36({
|
|
36803
36866
|
port: addr.port,
|
|
36804
36867
|
close: () => closeHttpServer(server)
|
|
36805
36868
|
});
|
|
@@ -39406,8 +39469,8 @@ function pathspec(...paths) {
|
|
|
39406
39469
|
cache.set(key, paths);
|
|
39407
39470
|
return key;
|
|
39408
39471
|
}
|
|
39409
|
-
function isPathSpec(
|
|
39410
|
-
return
|
|
39472
|
+
function isPathSpec(path86) {
|
|
39473
|
+
return path86 instanceof String && cache.has(path86);
|
|
39411
39474
|
}
|
|
39412
39475
|
function toPaths(pathSpec) {
|
|
39413
39476
|
return cache.get(pathSpec) || [];
|
|
@@ -39496,8 +39559,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
39496
39559
|
function forEachLineWithContent(input, callback) {
|
|
39497
39560
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
39498
39561
|
}
|
|
39499
|
-
function folderExists(
|
|
39500
|
-
return (0, import_file_exists.exists)(
|
|
39562
|
+
function folderExists(path86) {
|
|
39563
|
+
return (0, import_file_exists.exists)(path86, import_file_exists.FOLDER);
|
|
39501
39564
|
}
|
|
39502
39565
|
function append(target, item) {
|
|
39503
39566
|
if (Array.isArray(target)) {
|
|
@@ -39901,8 +39964,8 @@ function checkIsRepoRootTask() {
|
|
|
39901
39964
|
commands,
|
|
39902
39965
|
format: "utf-8",
|
|
39903
39966
|
onError,
|
|
39904
|
-
parser(
|
|
39905
|
-
return /^\.(git)?$/.test(
|
|
39967
|
+
parser(path86) {
|
|
39968
|
+
return /^\.(git)?$/.test(path86.trim());
|
|
39906
39969
|
}
|
|
39907
39970
|
};
|
|
39908
39971
|
}
|
|
@@ -40336,11 +40399,11 @@ function parseGrep(grep) {
|
|
|
40336
40399
|
const paths = /* @__PURE__ */ new Set();
|
|
40337
40400
|
const results = {};
|
|
40338
40401
|
forEachLineWithContent(grep, (input) => {
|
|
40339
|
-
const [
|
|
40340
|
-
paths.add(
|
|
40341
|
-
(results[
|
|
40402
|
+
const [path86, line, preview] = input.split(NULL);
|
|
40403
|
+
paths.add(path86);
|
|
40404
|
+
(results[path86] = results[path86] || []).push({
|
|
40342
40405
|
line: asNumber(line),
|
|
40343
|
-
path:
|
|
40406
|
+
path: path86,
|
|
40344
40407
|
preview
|
|
40345
40408
|
});
|
|
40346
40409
|
});
|
|
@@ -41105,14 +41168,14 @@ var init_hash_object = __esm2({
|
|
|
41105
41168
|
init_task();
|
|
41106
41169
|
}
|
|
41107
41170
|
});
|
|
41108
|
-
function parseInit(bare,
|
|
41171
|
+
function parseInit(bare, path86, text) {
|
|
41109
41172
|
const response = String(text).trim();
|
|
41110
41173
|
let result;
|
|
41111
41174
|
if (result = initResponseRegex.exec(response)) {
|
|
41112
|
-
return new InitSummary(bare,
|
|
41175
|
+
return new InitSummary(bare, path86, false, result[1]);
|
|
41113
41176
|
}
|
|
41114
41177
|
if (result = reInitResponseRegex.exec(response)) {
|
|
41115
|
-
return new InitSummary(bare,
|
|
41178
|
+
return new InitSummary(bare, path86, true, result[1]);
|
|
41116
41179
|
}
|
|
41117
41180
|
let gitDir = "";
|
|
41118
41181
|
const tokens = response.split(" ");
|
|
@@ -41123,7 +41186,7 @@ function parseInit(bare, path84, text) {
|
|
|
41123
41186
|
break;
|
|
41124
41187
|
}
|
|
41125
41188
|
}
|
|
41126
|
-
return new InitSummary(bare,
|
|
41189
|
+
return new InitSummary(bare, path86, /^re/i.test(response), gitDir);
|
|
41127
41190
|
}
|
|
41128
41191
|
var InitSummary;
|
|
41129
41192
|
var initResponseRegex;
|
|
@@ -41132,9 +41195,9 @@ var init_InitSummary = __esm2({
|
|
|
41132
41195
|
"src/lib/responses/InitSummary.ts"() {
|
|
41133
41196
|
"use strict";
|
|
41134
41197
|
InitSummary = class {
|
|
41135
|
-
constructor(bare,
|
|
41198
|
+
constructor(bare, path86, existing, gitDir) {
|
|
41136
41199
|
this.bare = bare;
|
|
41137
|
-
this.path =
|
|
41200
|
+
this.path = path86;
|
|
41138
41201
|
this.existing = existing;
|
|
41139
41202
|
this.gitDir = gitDir;
|
|
41140
41203
|
}
|
|
@@ -41146,7 +41209,7 @@ var init_InitSummary = __esm2({
|
|
|
41146
41209
|
function hasBareCommand(command) {
|
|
41147
41210
|
return command.includes(bareCommand);
|
|
41148
41211
|
}
|
|
41149
|
-
function initTask(bare = false,
|
|
41212
|
+
function initTask(bare = false, path86, customArgs) {
|
|
41150
41213
|
const commands = ["init", ...customArgs];
|
|
41151
41214
|
if (bare && !hasBareCommand(commands)) {
|
|
41152
41215
|
commands.splice(1, 0, bareCommand);
|
|
@@ -41155,7 +41218,7 @@ function initTask(bare = false, path84, customArgs) {
|
|
|
41155
41218
|
commands,
|
|
41156
41219
|
format: "utf-8",
|
|
41157
41220
|
parser(text) {
|
|
41158
|
-
return parseInit(commands.includes("--bare"),
|
|
41221
|
+
return parseInit(commands.includes("--bare"), path86, text);
|
|
41159
41222
|
}
|
|
41160
41223
|
};
|
|
41161
41224
|
}
|
|
@@ -41971,12 +42034,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
41971
42034
|
"use strict";
|
|
41972
42035
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
41973
42036
|
FileStatusSummary = class {
|
|
41974
|
-
constructor(
|
|
41975
|
-
this.path =
|
|
42037
|
+
constructor(path86, index, working_dir) {
|
|
42038
|
+
this.path = path86;
|
|
41976
42039
|
this.index = index;
|
|
41977
42040
|
this.working_dir = working_dir;
|
|
41978
42041
|
if (index === "R" || working_dir === "R") {
|
|
41979
|
-
const detail = fromPathRegex.exec(
|
|
42042
|
+
const detail = fromPathRegex.exec(path86) || [null, path86, path86];
|
|
41980
42043
|
this.from = detail[2] || "";
|
|
41981
42044
|
this.path = detail[1] || "";
|
|
41982
42045
|
}
|
|
@@ -42007,14 +42070,14 @@ function splitLine(result, lineStr) {
|
|
|
42007
42070
|
default:
|
|
42008
42071
|
return;
|
|
42009
42072
|
}
|
|
42010
|
-
function data(index, workingDir,
|
|
42073
|
+
function data(index, workingDir, path86) {
|
|
42011
42074
|
const raw = `${index}${workingDir}`;
|
|
42012
42075
|
const handler = parsers6.get(raw);
|
|
42013
42076
|
if (handler) {
|
|
42014
|
-
handler(result,
|
|
42077
|
+
handler(result, path86);
|
|
42015
42078
|
}
|
|
42016
42079
|
if (raw !== "##" && raw !== "!!") {
|
|
42017
|
-
result.files.push(new FileStatusSummary(
|
|
42080
|
+
result.files.push(new FileStatusSummary(path86, index, workingDir));
|
|
42018
42081
|
}
|
|
42019
42082
|
}
|
|
42020
42083
|
}
|
|
@@ -42323,9 +42386,9 @@ var init_simple_git_api = __esm2({
|
|
|
42323
42386
|
next
|
|
42324
42387
|
);
|
|
42325
42388
|
}
|
|
42326
|
-
hashObject(
|
|
42389
|
+
hashObject(path86, write) {
|
|
42327
42390
|
return this._runTask(
|
|
42328
|
-
hashObjectTask(
|
|
42391
|
+
hashObjectTask(path86, write === true),
|
|
42329
42392
|
trailingFunctionArgument(arguments)
|
|
42330
42393
|
);
|
|
42331
42394
|
}
|
|
@@ -42678,8 +42741,8 @@ var init_branch = __esm2({
|
|
|
42678
42741
|
}
|
|
42679
42742
|
});
|
|
42680
42743
|
function toPath(input) {
|
|
42681
|
-
const
|
|
42682
|
-
return
|
|
42744
|
+
const path86 = input.trim().replace(/^["']|["']$/g, "");
|
|
42745
|
+
return path86 && normalize3(path86);
|
|
42683
42746
|
}
|
|
42684
42747
|
var parseCheckIgnore;
|
|
42685
42748
|
var init_CheckIgnore = __esm2({
|
|
@@ -42993,8 +43056,8 @@ __export2(sub_module_exports, {
|
|
|
42993
43056
|
subModuleTask: () => subModuleTask,
|
|
42994
43057
|
updateSubModuleTask: () => updateSubModuleTask
|
|
42995
43058
|
});
|
|
42996
|
-
function addSubModuleTask(repo,
|
|
42997
|
-
return subModuleTask(["add", repo,
|
|
43059
|
+
function addSubModuleTask(repo, path86) {
|
|
43060
|
+
return subModuleTask(["add", repo, path86]);
|
|
42998
43061
|
}
|
|
42999
43062
|
function initSubModuleTask(customArgs) {
|
|
43000
43063
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -43327,8 +43390,8 @@ var require_git = __commonJS2({
|
|
|
43327
43390
|
}
|
|
43328
43391
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
43329
43392
|
};
|
|
43330
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
43331
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
43393
|
+
Git2.prototype.submoduleAdd = function(repo, path86, then) {
|
|
43394
|
+
return this._runTask(addSubModuleTask2(repo, path86), trailingFunctionArgument2(arguments));
|
|
43332
43395
|
};
|
|
43333
43396
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
43334
43397
|
return this._runTask(
|
|
@@ -44067,8 +44130,8 @@ function parseNumstatEntries(lines) {
|
|
|
44067
44130
|
}
|
|
44068
44131
|
function parseNumstat(lines) {
|
|
44069
44132
|
const m = /* @__PURE__ */ new Map();
|
|
44070
|
-
for (const [
|
|
44071
|
-
m.set(
|
|
44133
|
+
for (const [path86, entry] of parseNumstatEntries(lines)) {
|
|
44134
|
+
m.set(path86, { additions: entry.additions, deletions: entry.deletions });
|
|
44072
44135
|
}
|
|
44073
44136
|
return m;
|
|
44074
44137
|
}
|
|
@@ -48156,7 +48219,7 @@ init_symbol_index_file_ready();
|
|
|
48156
48219
|
var CODE_NAV_INDEX_READY_WAIT_MS = 75;
|
|
48157
48220
|
var CODE_NAV_INDEX_READY_POLL_MS = 15;
|
|
48158
48221
|
function delay2(ms) {
|
|
48159
|
-
return new Promise((
|
|
48222
|
+
return new Promise((resolve36) => setTimeout(resolve36, ms));
|
|
48160
48223
|
}
|
|
48161
48224
|
async function waitForSymbolIndexReady(sessionParentPath, reqPath, maxWaitMs = CODE_NAV_INDEX_READY_WAIT_MS) {
|
|
48162
48225
|
const deadline = Date.now() + maxWaitMs;
|
|
@@ -48288,12 +48351,12 @@ function parseOptionalInt2(raw) {
|
|
|
48288
48351
|
return Number.isInteger(parsed) ? parsed : void 0;
|
|
48289
48352
|
}
|
|
48290
48353
|
function parseCodeNavParams(url2) {
|
|
48291
|
-
const
|
|
48354
|
+
const path86 = url2.searchParams.get("path") ?? "";
|
|
48292
48355
|
const opRaw = url2.searchParams.get("op")?.trim();
|
|
48293
48356
|
const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
|
|
48294
48357
|
const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
|
|
48295
48358
|
const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
|
|
48296
|
-
return { path:
|
|
48359
|
+
return { path: path86, op, line, column };
|
|
48297
48360
|
}
|
|
48298
48361
|
function parseCodeNavPath(url2) {
|
|
48299
48362
|
const raw = url2.searchParams.get("path")?.trim();
|
|
@@ -48469,7 +48532,7 @@ function createLocalShortcutRequestHandler(ctx) {
|
|
|
48469
48532
|
var RESTART_DELAY_MS = 250;
|
|
48470
48533
|
var MAX_RESTART_ATTEMPTS = 5;
|
|
48471
48534
|
function listenOnPort(server, port) {
|
|
48472
|
-
return new Promise((
|
|
48535
|
+
return new Promise((resolve36, reject) => {
|
|
48473
48536
|
server.once("error", reject);
|
|
48474
48537
|
server.listen(port, "127.0.0.1", () => {
|
|
48475
48538
|
const addr = server.address();
|
|
@@ -48477,12 +48540,12 @@ function listenOnPort(server, port) {
|
|
|
48477
48540
|
reject(new Error("Local shortcut server did not bind"));
|
|
48478
48541
|
return;
|
|
48479
48542
|
}
|
|
48480
|
-
|
|
48543
|
+
resolve36(addr.port);
|
|
48481
48544
|
});
|
|
48482
48545
|
});
|
|
48483
48546
|
}
|
|
48484
48547
|
function delay3(ms) {
|
|
48485
|
-
return new Promise((
|
|
48548
|
+
return new Promise((resolve36) => setTimeout(resolve36, ms));
|
|
48486
48549
|
}
|
|
48487
48550
|
function startLocalShortcutServer(ctx) {
|
|
48488
48551
|
let closed = false;
|
|
@@ -48682,7 +48745,8 @@ var API_TO_BRIDGE_MESSAGE_TYPES = [
|
|
|
48682
48745
|
"install_agent",
|
|
48683
48746
|
"refresh_local_skills",
|
|
48684
48747
|
"bridge_git_context_request",
|
|
48685
|
-
"list_repo_branches_request"
|
|
48748
|
+
"list_repo_branches_request",
|
|
48749
|
+
"bridge_git_checkout_request"
|
|
48686
48750
|
];
|
|
48687
48751
|
var API_TO_BRIDGE_TYPE_SET = new Set(API_TO_BRIDGE_MESSAGE_TYPES);
|
|
48688
48752
|
function parseApiToBridgeMessage(data, log2) {
|
|
@@ -49375,10 +49439,10 @@ async function awaitGitStatePreparation(options) {
|
|
|
49375
49439
|
try {
|
|
49376
49440
|
return await Promise.race([
|
|
49377
49441
|
work,
|
|
49378
|
-
new Promise((
|
|
49442
|
+
new Promise((resolve36) => {
|
|
49379
49443
|
timer = setTimeout(() => {
|
|
49380
49444
|
log2(`[Agent] ${label} exceeded ${timeoutMs}ms; continuing without it.`);
|
|
49381
|
-
|
|
49445
|
+
resolve36(fallback);
|
|
49382
49446
|
}, timeoutMs);
|
|
49383
49447
|
timer.unref?.();
|
|
49384
49448
|
})
|
|
@@ -50037,7 +50101,7 @@ var handleInstallSkillsMessage = (msg, deps) => {
|
|
|
50037
50101
|
import { spawn as spawn11 } from "node:child_process";
|
|
50038
50102
|
import * as readline3 from "node:readline";
|
|
50039
50103
|
function runStreamingCommand(command, args, options) {
|
|
50040
|
-
return new Promise((
|
|
50104
|
+
return new Promise((resolve36, reject) => {
|
|
50041
50105
|
const child = spawn11(command, args, {
|
|
50042
50106
|
env: options.env,
|
|
50043
50107
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -50070,7 +50134,7 @@ function runStreamingCommand(command, args, options) {
|
|
|
50070
50134
|
if (timer) clearTimeout(timer);
|
|
50071
50135
|
if (!settled) {
|
|
50072
50136
|
settled = true;
|
|
50073
|
-
|
|
50137
|
+
resolve36({ code, signal });
|
|
50074
50138
|
}
|
|
50075
50139
|
});
|
|
50076
50140
|
});
|
|
@@ -50509,6 +50573,23 @@ async function listRepoBranchRefs(repoPath) {
|
|
|
50509
50573
|
}
|
|
50510
50574
|
}
|
|
50511
50575
|
|
|
50576
|
+
// src/git/checkout/pending-checkouts.ts
|
|
50577
|
+
var pendingByRelPath = /* @__PURE__ */ new Map();
|
|
50578
|
+
function beginPendingCheckout(row) {
|
|
50579
|
+
const relPath = row.relPath.trim() || ".";
|
|
50580
|
+
pendingByRelPath.set(relPath, {
|
|
50581
|
+
relPath,
|
|
50582
|
+
folderName: row.folderName.trim() || (relPath === "." ? "repo" : relPath),
|
|
50583
|
+
remoteUrl: row.remoteUrl
|
|
50584
|
+
});
|
|
50585
|
+
}
|
|
50586
|
+
function endPendingCheckout(relPath) {
|
|
50587
|
+
pendingByRelPath.delete(relPath.trim() || ".");
|
|
50588
|
+
}
|
|
50589
|
+
function listPendingCheckouts() {
|
|
50590
|
+
return [...pendingByRelPath.values()];
|
|
50591
|
+
}
|
|
50592
|
+
|
|
50512
50593
|
// src/git/bridge-git-context.ts
|
|
50513
50594
|
function folderNameForRelPath(relPath, bridgeRoot) {
|
|
50514
50595
|
if (relPath === "." || relPath === "") {
|
|
@@ -50545,7 +50626,23 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
|
50545
50626
|
relPath,
|
|
50546
50627
|
folderName: folderNameForRelPath(relPath, bridgeResolved),
|
|
50547
50628
|
currentBranch,
|
|
50548
|
-
remoteUrl
|
|
50629
|
+
remoteUrl,
|
|
50630
|
+
cloning: false
|
|
50631
|
+
});
|
|
50632
|
+
}
|
|
50633
|
+
const seen = new Set(rows.map((r) => r.relPath));
|
|
50634
|
+
for (const pending2 of listPendingCheckouts()) {
|
|
50635
|
+
if (seen.has(pending2.relPath)) {
|
|
50636
|
+
const row = rows.find((r) => r.relPath === pending2.relPath);
|
|
50637
|
+
if (row) row.cloning = true;
|
|
50638
|
+
continue;
|
|
50639
|
+
}
|
|
50640
|
+
rows.push({
|
|
50641
|
+
relPath: pending2.relPath,
|
|
50642
|
+
folderName: pending2.folderName,
|
|
50643
|
+
currentBranch: null,
|
|
50644
|
+
remoteUrl: pending2.remoteUrl,
|
|
50645
|
+
cloning: true
|
|
50549
50646
|
});
|
|
50550
50647
|
}
|
|
50551
50648
|
rows.sort((a, b) => a.relPath.localeCompare(b.relPath));
|
|
@@ -50605,6 +50702,143 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
|
|
|
50605
50702
|
})();
|
|
50606
50703
|
}
|
|
50607
50704
|
|
|
50705
|
+
// src/git/checkout/bridge-git-checkout.ts
|
|
50706
|
+
import * as fs64 from "node:fs/promises";
|
|
50707
|
+
import * as path85 from "node:path";
|
|
50708
|
+
|
|
50709
|
+
// src/git/checkout/normalize-clone-url.ts
|
|
50710
|
+
function normalizeCloneUrl(url2) {
|
|
50711
|
+
const u = url2.trim();
|
|
50712
|
+
if (!u.startsWith("http://") && !u.startsWith("https://")) {
|
|
50713
|
+
throw new Error("Only http(s) git remote URLs are supported");
|
|
50714
|
+
}
|
|
50715
|
+
return u.endsWith(".git") ? u : `${u}.git`;
|
|
50716
|
+
}
|
|
50717
|
+
function cloneUrlWithHttpsAuth(url2, auth) {
|
|
50718
|
+
const normalized = normalizeCloneUrl(url2);
|
|
50719
|
+
if (!auth) return normalized;
|
|
50720
|
+
const parsed = new URL(normalized);
|
|
50721
|
+
parsed.username = auth.username;
|
|
50722
|
+
parsed.password = auth.password;
|
|
50723
|
+
return parsed.toString();
|
|
50724
|
+
}
|
|
50725
|
+
|
|
50726
|
+
// src/git/checkout/resolve-checkout-target.ts
|
|
50727
|
+
import * as fs63 from "node:fs/promises";
|
|
50728
|
+
import * as path84 from "node:path";
|
|
50729
|
+
var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
50730
|
+
async function pathExists(p) {
|
|
50731
|
+
try {
|
|
50732
|
+
await fs63.access(p);
|
|
50733
|
+
return true;
|
|
50734
|
+
} catch {
|
|
50735
|
+
return false;
|
|
50736
|
+
}
|
|
50737
|
+
}
|
|
50738
|
+
async function resolveCheckoutTarget(opts) {
|
|
50739
|
+
const bridgeRoot = getBridgeRoot();
|
|
50740
|
+
if (opts.layout === "monorepo") {
|
|
50741
|
+
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
50742
|
+
throw new Error("Bridge root is already a git repository");
|
|
50743
|
+
}
|
|
50744
|
+
const entries = await fs63.readdir(bridgeRoot).catch(() => []);
|
|
50745
|
+
if (entries.length > 0) {
|
|
50746
|
+
throw new Error("Bridge root must be empty to initialize a monorepo checkout");
|
|
50747
|
+
}
|
|
50748
|
+
return { targetDir: bridgeRoot, relPath: "." };
|
|
50749
|
+
}
|
|
50750
|
+
const folder = (opts.folderName ?? "").trim();
|
|
50751
|
+
if (!folder || folder === "." || folder === ".." || !FOLDER_NAME_RE.test(folder)) {
|
|
50752
|
+
throw new Error("folderName must be a single path segment (letters, numbers, . _ -)");
|
|
50753
|
+
}
|
|
50754
|
+
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
50755
|
+
throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
|
|
50756
|
+
}
|
|
50757
|
+
const targetDir = path84.resolve(bridgeRoot, folder);
|
|
50758
|
+
if (!targetDir.startsWith(bridgeRoot + path84.sep)) {
|
|
50759
|
+
throw new Error("Invalid folderName");
|
|
50760
|
+
}
|
|
50761
|
+
if (await pathExists(targetDir)) {
|
|
50762
|
+
throw new Error(`Folder already exists: ${folder}`);
|
|
50763
|
+
}
|
|
50764
|
+
return { targetDir, relPath: folder };
|
|
50765
|
+
}
|
|
50766
|
+
|
|
50767
|
+
// src/git/checkout/bridge-git-checkout.ts
|
|
50768
|
+
async function bridgeGitCheckout(params) {
|
|
50769
|
+
const cloneUrl = (params.cloneUrl ?? "").trim();
|
|
50770
|
+
if (!cloneUrl) throw new Error("cloneUrl required");
|
|
50771
|
+
const { targetDir, relPath } = await resolveCheckoutTarget({
|
|
50772
|
+
layout: params.layout,
|
|
50773
|
+
folderName: params.folderName
|
|
50774
|
+
});
|
|
50775
|
+
const folderName = relPath === "." ? "repo" : relPath;
|
|
50776
|
+
beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
|
|
50777
|
+
const parent = path85.dirname(targetDir);
|
|
50778
|
+
await fs64.mkdir(parent, { recursive: true });
|
|
50779
|
+
if (relPath !== ".") {
|
|
50780
|
+
await fs64.mkdir(targetDir, { recursive: true });
|
|
50781
|
+
}
|
|
50782
|
+
const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
|
|
50783
|
+
try {
|
|
50784
|
+
await execGitFile(["clone", "--", url2, targetDir], {
|
|
50785
|
+
cwd: parent,
|
|
50786
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
|
|
50787
|
+
});
|
|
50788
|
+
return { relPath, folderName };
|
|
50789
|
+
} catch (e) {
|
|
50790
|
+
if (relPath !== ".") {
|
|
50791
|
+
await fs64.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
|
|
50792
|
+
}
|
|
50793
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
50794
|
+
throw new Error(
|
|
50795
|
+
msg.includes("Authentication") || msg.includes("403") || msg.includes("401") ? `Clone failed (auth?): ${msg}` : `Clone failed: ${msg}`
|
|
50796
|
+
);
|
|
50797
|
+
} finally {
|
|
50798
|
+
endPendingCheckout(relPath);
|
|
50799
|
+
}
|
|
50800
|
+
}
|
|
50801
|
+
|
|
50802
|
+
// src/routing/handlers/bridge-git-checkout-messages.ts
|
|
50803
|
+
function handleBridgeGitCheckoutRequestMessage(msg, getWs) {
|
|
50804
|
+
void (async () => {
|
|
50805
|
+
const socket = getWs();
|
|
50806
|
+
if (!socket) return;
|
|
50807
|
+
const layout = msg.layout === "multi_repo" ? "multi_repo" : msg.layout === "monorepo" ? "monorepo" : null;
|
|
50808
|
+
if (!layout) {
|
|
50809
|
+
sendWsMessage(socket, {
|
|
50810
|
+
type: "bridge_git_checkout_response",
|
|
50811
|
+
id: msg.id,
|
|
50812
|
+
error: "layout must be monorepo or multi_repo"
|
|
50813
|
+
});
|
|
50814
|
+
return;
|
|
50815
|
+
}
|
|
50816
|
+
try {
|
|
50817
|
+
const user = typeof msg.authUsername === "string" ? msg.authUsername : "";
|
|
50818
|
+
const pass = typeof msg.authPassword === "string" ? msg.authPassword : "";
|
|
50819
|
+
const result = await bridgeGitCheckout({
|
|
50820
|
+
layout,
|
|
50821
|
+
folderName: msg.folderName,
|
|
50822
|
+
cloneUrl: msg.cloneUrl ?? "",
|
|
50823
|
+
auth: user && pass ? { username: user, password: pass } : null
|
|
50824
|
+
});
|
|
50825
|
+
sendWsMessage(socket, {
|
|
50826
|
+
type: "bridge_git_checkout_response",
|
|
50827
|
+
id: msg.id,
|
|
50828
|
+
ok: true,
|
|
50829
|
+
relPath: result.relPath,
|
|
50830
|
+
folderName: result.folderName
|
|
50831
|
+
});
|
|
50832
|
+
} catch (e) {
|
|
50833
|
+
sendWsMessage(socket, {
|
|
50834
|
+
type: "bridge_git_checkout_response",
|
|
50835
|
+
id: msg.id,
|
|
50836
|
+
error: e instanceof Error ? e.message : String(e)
|
|
50837
|
+
});
|
|
50838
|
+
}
|
|
50839
|
+
})();
|
|
50840
|
+
}
|
|
50841
|
+
|
|
50608
50842
|
// src/routing/dispatch/file-browser.ts
|
|
50609
50843
|
function dispatchBridgeFileBrowserMessage(msg, deps) {
|
|
50610
50844
|
switch (msg.type) {
|
|
@@ -50623,6 +50857,9 @@ function dispatchBridgeFileBrowserMessage(msg, deps) {
|
|
|
50623
50857
|
case "list_repo_branches_request":
|
|
50624
50858
|
handleListRepoBranchesRequestMessage(msg, deps.getWs);
|
|
50625
50859
|
break;
|
|
50860
|
+
case "bridge_git_checkout_request":
|
|
50861
|
+
handleBridgeGitCheckoutRequestMessage(msg, deps.getWs);
|
|
50862
|
+
break;
|
|
50626
50863
|
}
|
|
50627
50864
|
}
|
|
50628
50865
|
|
|
@@ -50663,6 +50900,7 @@ function dispatchBridgeMessage(msg, deps) {
|
|
|
50663
50900
|
case "code_nav":
|
|
50664
50901
|
case "bridge_git_context_request":
|
|
50665
50902
|
case "list_repo_branches_request":
|
|
50903
|
+
case "bridge_git_checkout_request":
|
|
50666
50904
|
dispatchBridgeFileBrowserMessage(msg, deps);
|
|
50667
50905
|
break;
|
|
50668
50906
|
}
|
|
@@ -51046,32 +51284,42 @@ async function openE2eCertificateImportUrl({
|
|
|
51046
51284
|
}
|
|
51047
51285
|
}
|
|
51048
51286
|
|
|
51049
|
-
// src/run-bridge-
|
|
51287
|
+
// src/run-bridge-e2ee-key-command.ts
|
|
51288
|
+
function installConnectedBridgeE2eeKeyCommand(params) {
|
|
51289
|
+
let openingCertificate = false;
|
|
51290
|
+
return installE2eCertificateKeyCommand({
|
|
51291
|
+
log: params.log,
|
|
51292
|
+
onInterrupt: params.onInterrupt,
|
|
51293
|
+
onOpenCertificate: () => {
|
|
51294
|
+
if (openingCertificate) return;
|
|
51295
|
+
openingCertificate = true;
|
|
51296
|
+
void openE2eCertificateImportUrl({
|
|
51297
|
+
apiUrl: params.apiUrl,
|
|
51298
|
+
workspaceId: params.workspaceId,
|
|
51299
|
+
certificate: params.e2eCertificate,
|
|
51300
|
+
log: params.log
|
|
51301
|
+
}).finally(() => {
|
|
51302
|
+
openingCertificate = false;
|
|
51303
|
+
});
|
|
51304
|
+
}
|
|
51305
|
+
});
|
|
51306
|
+
}
|
|
51307
|
+
|
|
51308
|
+
// src/run-bridge-connected-signals.ts
|
|
51309
|
+
init_log();
|
|
51050
51310
|
init_cli_process_interrupt();
|
|
51051
|
-
|
|
51052
|
-
async function runConnectedBridge(options, restartWithoutAuth) {
|
|
51053
|
-
const {
|
|
51054
|
-
apiUrl,
|
|
51055
|
-
workspaceId,
|
|
51056
|
-
authToken,
|
|
51057
|
-
refreshToken,
|
|
51058
|
-
justAuthenticated,
|
|
51059
|
-
worktreesRootPath,
|
|
51060
|
-
e2eCertificate
|
|
51061
|
-
} = options;
|
|
51062
|
-
const firehoseServerUrl = options.firehoseServerUrl ?? options.proxyServerUrl;
|
|
51063
|
-
let cleanupKeyCommand;
|
|
51064
|
-
let bridgeClose = null;
|
|
51311
|
+
function installConnectedBridgeSignals(params) {
|
|
51065
51312
|
let shutdownStarted = false;
|
|
51066
51313
|
const onSignal = (kind) => {
|
|
51067
51314
|
requestCliImmediateShutdown();
|
|
51068
51315
|
abortActiveGitChildProcesses();
|
|
51069
|
-
cleanupKeyCommand
|
|
51316
|
+
params.cleanupKeyCommand();
|
|
51070
51317
|
if (shutdownStarted) return;
|
|
51071
51318
|
shutdownStarted = true;
|
|
51072
51319
|
logImmediate(
|
|
51073
51320
|
kind === "interrupt" ? "Keyboard interrupt (Ctrl+C) \u2014 stopping\u2026" : "Stop requested \u2014 shutting down\u2026"
|
|
51074
51321
|
);
|
|
51322
|
+
const bridgeClose = params.getBridgeClose();
|
|
51075
51323
|
if (bridgeClose) {
|
|
51076
51324
|
void bridgeClose().finally(() => process.exit(0));
|
|
51077
51325
|
return;
|
|
@@ -51082,9 +51330,56 @@ async function runConnectedBridge(options, restartWithoutAuth) {
|
|
|
51082
51330
|
const onSigTerm = () => onSignal("stop");
|
|
51083
51331
|
process.on("SIGINT", onSigInt);
|
|
51084
51332
|
process.on("SIGTERM", onSigTerm);
|
|
51085
|
-
|
|
51333
|
+
return {
|
|
51334
|
+
onSigInt,
|
|
51335
|
+
remove: () => {
|
|
51336
|
+
process.off("SIGINT", onSigInt);
|
|
51337
|
+
process.off("SIGTERM", onSigTerm);
|
|
51338
|
+
}
|
|
51339
|
+
};
|
|
51340
|
+
}
|
|
51341
|
+
|
|
51342
|
+
// src/run-bridge-on-auth-invalid.ts
|
|
51343
|
+
init_cli_process_interrupt();
|
|
51344
|
+
async function closeBridgeForReauth(params) {
|
|
51345
|
+
params.log("[Bridge service] Access token invalid or revoked; re-authenticating\u2026");
|
|
51346
|
+
clearConfigForApi(params.apiUrl);
|
|
51347
|
+
await params.close();
|
|
51348
|
+
params.removeSignalHandlers();
|
|
51349
|
+
await clearCliImmediateShutdown();
|
|
51350
|
+
params.endConnectedSession();
|
|
51351
|
+
}
|
|
51352
|
+
|
|
51353
|
+
// src/run-bridge-connected.ts
|
|
51354
|
+
init_cli_database();
|
|
51355
|
+
async function runConnectedBridge(options, restartWithoutAuth) {
|
|
51356
|
+
const {
|
|
51357
|
+
apiUrl,
|
|
51358
|
+
workspaceId,
|
|
51359
|
+
authToken,
|
|
51360
|
+
refreshToken,
|
|
51361
|
+
justAuthenticated,
|
|
51362
|
+
worktreesRootPath,
|
|
51363
|
+
e2eCertificate
|
|
51364
|
+
} = options;
|
|
51365
|
+
const firehoseServerUrl = options.firehoseServerUrl ?? options.proxyServerUrl;
|
|
51366
|
+
let cleanupKeyCommand;
|
|
51367
|
+
let bridgeClose = null;
|
|
51368
|
+
let endConnectedSession;
|
|
51369
|
+
const sessionDone = new Promise((resolve36) => {
|
|
51370
|
+
endConnectedSession = resolve36;
|
|
51371
|
+
});
|
|
51372
|
+
let resolveHandleReady;
|
|
51373
|
+
const handleReady = new Promise((resolve36) => {
|
|
51374
|
+
resolveHandleReady = resolve36;
|
|
51375
|
+
});
|
|
51376
|
+
const handleRef = { current: null };
|
|
51377
|
+
const signals = installConnectedBridgeSignals({
|
|
51378
|
+
getBridgeClose: () => bridgeClose,
|
|
51379
|
+
cleanupKeyCommand: () => cleanupKeyCommand?.()
|
|
51380
|
+
});
|
|
51086
51381
|
try {
|
|
51087
|
-
handle = await createBridgeConnection({
|
|
51382
|
+
const handle = await createBridgeConnection({
|
|
51088
51383
|
apiUrl,
|
|
51089
51384
|
workspaceId,
|
|
51090
51385
|
authToken,
|
|
@@ -51103,41 +51398,40 @@ async function runConnectedBridge(options, restartWithoutAuth) {
|
|
|
51103
51398
|
},
|
|
51104
51399
|
onAuthInvalid: () => {
|
|
51105
51400
|
cleanupKeyCommand?.();
|
|
51106
|
-
|
|
51107
|
-
|
|
51108
|
-
|
|
51109
|
-
|
|
51110
|
-
|
|
51401
|
+
void (async () => {
|
|
51402
|
+
await handleReady;
|
|
51403
|
+
await closeBridgeForReauth({
|
|
51404
|
+
apiUrl,
|
|
51405
|
+
log,
|
|
51406
|
+
close: async () => {
|
|
51407
|
+
if (handleRef.current) await handleRef.current.close();
|
|
51408
|
+
},
|
|
51409
|
+
removeSignalHandlers: signals.remove,
|
|
51410
|
+
endConnectedSession
|
|
51411
|
+
});
|
|
51412
|
+
})();
|
|
51111
51413
|
}
|
|
51112
51414
|
});
|
|
51113
|
-
|
|
51114
|
-
|
|
51115
|
-
|
|
51116
|
-
|
|
51117
|
-
|
|
51415
|
+
handleRef.current = handle;
|
|
51416
|
+
bridgeClose = () => handle.close();
|
|
51417
|
+
if (e2eCertificate) {
|
|
51418
|
+
cleanupKeyCommand = installConnectedBridgeE2eeKeyCommand({
|
|
51419
|
+
apiUrl,
|
|
51420
|
+
workspaceId,
|
|
51421
|
+
e2eCertificate,
|
|
51422
|
+
log,
|
|
51423
|
+
onInterrupt: signals.onSigInt
|
|
51424
|
+
});
|
|
51118
51425
|
}
|
|
51426
|
+
} catch (e) {
|
|
51427
|
+
signals.remove();
|
|
51428
|
+
if (e instanceof CliSqliteInterrupted) process.exit(0);
|
|
51119
51429
|
throw e;
|
|
51430
|
+
} finally {
|
|
51431
|
+
resolveHandleReady();
|
|
51120
51432
|
}
|
|
51121
|
-
|
|
51122
|
-
|
|
51123
|
-
let openingCertificate = false;
|
|
51124
|
-
cleanupKeyCommand = installE2eCertificateKeyCommand({
|
|
51125
|
-
log,
|
|
51126
|
-
onInterrupt: onSigInt,
|
|
51127
|
-
onOpenCertificate: () => {
|
|
51128
|
-
if (openingCertificate) return;
|
|
51129
|
-
openingCertificate = true;
|
|
51130
|
-
void openE2eCertificateImportUrl({
|
|
51131
|
-
apiUrl,
|
|
51132
|
-
workspaceId,
|
|
51133
|
-
certificate: e2eCertificate,
|
|
51134
|
-
log
|
|
51135
|
-
}).finally(() => {
|
|
51136
|
-
openingCertificate = false;
|
|
51137
|
-
});
|
|
51138
|
-
}
|
|
51139
|
-
});
|
|
51140
|
-
}
|
|
51433
|
+
await sessionDone;
|
|
51434
|
+
await restartWithoutAuth({ apiUrl, firehoseServerUrl, worktreesRootPath, e2eCertificate });
|
|
51141
51435
|
}
|
|
51142
51436
|
|
|
51143
51437
|
// src/run-bridge.ts
|
|
@@ -51181,12 +51475,16 @@ async function runBridge(options) {
|
|
|
51181
51475
|
process.off("SIGINT", onSigInt);
|
|
51182
51476
|
process.off("SIGTERM", onSigTerm);
|
|
51183
51477
|
handle.close();
|
|
51184
|
-
if (!auth)
|
|
51478
|
+
if (!auth) {
|
|
51479
|
+
log("Sign-in ended before a token was received.");
|
|
51480
|
+
return;
|
|
51481
|
+
}
|
|
51185
51482
|
writeConfigForApi(apiUrl, {
|
|
51186
51483
|
workspaceId: auth.workspaceId,
|
|
51187
51484
|
token: auth.token,
|
|
51188
51485
|
refreshToken: auth.refreshToken
|
|
51189
51486
|
});
|
|
51487
|
+
log("Link established. Connecting with the new token\u2026");
|
|
51190
51488
|
await runBridge({
|
|
51191
51489
|
apiUrl,
|
|
51192
51490
|
workspaceId: auth.workspaceId,
|