@adhdev/daemon-standalone 0.8.93 → 0.8.94
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/index.js +229 -112
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-42XeBRt-.js +79 -0
- package/public/assets/index-DHunFxdM.css +1 -0
- package/public/index.html +2 -2
- package/public/assets/index-B0yfK9dM.css +0 -1
- package/public/assets/index-BX2fAu2N.js +0 -79
package/dist/index.js
CHANGED
|
@@ -30353,7 +30353,7 @@ var require_dist2 = __commonJS({
|
|
|
30353
30353
|
`[${this.cliType}] Waiting for interactive prompt: hasPrompt=${hasPrompt} stableMs=${stableMs} recentOutputMs=${recentlyOutput} status=${status} startup=${startupLikelyActive} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
|
|
30354
30354
|
);
|
|
30355
30355
|
}
|
|
30356
|
-
await new Promise((
|
|
30356
|
+
await new Promise((resolve12) => setTimeout(resolve12, 50));
|
|
30357
30357
|
}
|
|
30358
30358
|
const finalScreenText = this.terminalScreen.getText() || "";
|
|
30359
30359
|
LOG2.warn(
|
|
@@ -30941,7 +30941,7 @@ var require_dist2 = __commonJS({
|
|
|
30941
30941
|
}
|
|
30942
30942
|
projectEffectiveStatus(startupModal = null) {
|
|
30943
30943
|
if (this.parseErrorMessage) return "error";
|
|
30944
|
-
if (startupModal) return "waiting_approval";
|
|
30944
|
+
if (startupModal || this.activeModal) return "waiting_approval";
|
|
30945
30945
|
if (this.isWaitingForResponse && this.currentTurnScope && this.currentStatus === "idle") return "generating";
|
|
30946
30946
|
return this.currentStatus;
|
|
30947
30947
|
}
|
|
@@ -30949,12 +30949,24 @@ var require_dist2 = __commonJS({
|
|
|
30949
30949
|
getStatus() {
|
|
30950
30950
|
const screenText = this.terminalScreen.getText() || "";
|
|
30951
30951
|
const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
|
|
30952
|
-
|
|
30952
|
+
let effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
30953
|
+
let effectiveModal = startupModal || this.activeModal;
|
|
30954
|
+
if (!startupModal && !effectiveModal && typeof this.cliScripts?.parseOutput === "function") {
|
|
30955
|
+
try {
|
|
30956
|
+
const parsed = this.getScriptParsedStatus();
|
|
30957
|
+
const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
|
|
30958
|
+
if (parsed?.status === "waiting_approval" && parsedModal) {
|
|
30959
|
+
effectiveStatus = "waiting_approval";
|
|
30960
|
+
effectiveModal = parsedModal;
|
|
30961
|
+
}
|
|
30962
|
+
} catch {
|
|
30963
|
+
}
|
|
30964
|
+
}
|
|
30953
30965
|
return {
|
|
30954
30966
|
status: effectiveStatus,
|
|
30955
30967
|
messages: [...this.committedMessages],
|
|
30956
30968
|
workingDir: this.workingDir,
|
|
30957
|
-
activeModal:
|
|
30969
|
+
activeModal: effectiveModal,
|
|
30958
30970
|
errorMessage: this.parseErrorMessage || void 0,
|
|
30959
30971
|
errorReason: this.parseErrorMessage ? "parse_error" : void 0
|
|
30960
30972
|
};
|
|
@@ -30990,6 +31002,15 @@ var require_dist2 = __commonJS({
|
|
|
30990
31002
|
this.currentTurnScope,
|
|
30991
31003
|
screenText
|
|
30992
31004
|
);
|
|
31005
|
+
const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
|
|
31006
|
+
if (parsedModal && parsed?.status === "waiting_approval") {
|
|
31007
|
+
this.activeModal = parsedModal;
|
|
31008
|
+
this.isWaitingForResponse = true;
|
|
31009
|
+
if (this.currentStatus !== "waiting_approval") {
|
|
31010
|
+
this.setStatus("waiting_approval", "parsed_waiting_approval");
|
|
31011
|
+
this.onStatusChange?.();
|
|
31012
|
+
}
|
|
31013
|
+
}
|
|
30993
31014
|
if (this.maybeCommitVisibleIdleTranscript(parsed)) {
|
|
30994
31015
|
return this.getScriptParsedStatus();
|
|
30995
31016
|
}
|
|
@@ -31194,7 +31215,7 @@ ${data.message || ""}`.trim();
|
|
|
31194
31215
|
const deadline = Date.now() + 1e4;
|
|
31195
31216
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
31196
31217
|
this.resolveStartupState("send_wait");
|
|
31197
|
-
await new Promise((
|
|
31218
|
+
await new Promise((resolve12) => setTimeout(resolve12, 50));
|
|
31198
31219
|
}
|
|
31199
31220
|
}
|
|
31200
31221
|
if (!allowInterventionPrompt) {
|
|
@@ -31286,12 +31307,12 @@ ${data.message || ""}`.trim();
|
|
|
31286
31307
|
if (this.isWaitingForResponse) this.finishResponse();
|
|
31287
31308
|
}, this.timeouts.maxResponse);
|
|
31288
31309
|
};
|
|
31289
|
-
await new Promise((
|
|
31310
|
+
await new Promise((resolve12) => {
|
|
31290
31311
|
let resolved = false;
|
|
31291
31312
|
const resolveOnce = () => {
|
|
31292
31313
|
if (resolved) return;
|
|
31293
31314
|
resolved = true;
|
|
31294
|
-
|
|
31315
|
+
resolve12();
|
|
31295
31316
|
};
|
|
31296
31317
|
const submit = () => {
|
|
31297
31318
|
if (!this.ptyProcess) {
|
|
@@ -31465,17 +31486,17 @@ ${data.message || ""}`.trim();
|
|
|
31465
31486
|
}
|
|
31466
31487
|
}
|
|
31467
31488
|
waitForStopped(timeoutMs) {
|
|
31468
|
-
return new Promise((
|
|
31489
|
+
return new Promise((resolve12) => {
|
|
31469
31490
|
const startedAt = Date.now();
|
|
31470
31491
|
const timer = setInterval(() => {
|
|
31471
31492
|
if (!this.ptyProcess || this.currentStatus === "stopped") {
|
|
31472
31493
|
clearInterval(timer);
|
|
31473
|
-
|
|
31494
|
+
resolve12(true);
|
|
31474
31495
|
return;
|
|
31475
31496
|
}
|
|
31476
31497
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
31477
31498
|
clearInterval(timer);
|
|
31478
|
-
|
|
31499
|
+
resolve12(false);
|
|
31479
31500
|
}
|
|
31480
31501
|
}, 100);
|
|
31481
31502
|
});
|
|
@@ -31640,7 +31661,22 @@ ${data.message || ""}`.trim();
|
|
|
31640
31661
|
}
|
|
31641
31662
|
resolveModal(buttonIndex) {
|
|
31642
31663
|
const screenText = this.terminalScreen.getText() || "";
|
|
31643
|
-
|
|
31664
|
+
let modal = this.activeModal || this.getStartupConfirmationModal(screenText);
|
|
31665
|
+
if (!modal && typeof this.cliScripts?.parseOutput === "function") {
|
|
31666
|
+
try {
|
|
31667
|
+
const parsed = this.getScriptParsedStatus();
|
|
31668
|
+
const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
|
|
31669
|
+
if (parsed?.status === "waiting_approval" && parsedModal) {
|
|
31670
|
+
modal = parsedModal;
|
|
31671
|
+
this.activeModal = parsedModal;
|
|
31672
|
+
if (this.currentStatus !== "waiting_approval") {
|
|
31673
|
+
this.setStatus("waiting_approval", "resolve_modal_parse");
|
|
31674
|
+
this.onStatusChange?.();
|
|
31675
|
+
}
|
|
31676
|
+
}
|
|
31677
|
+
} catch {
|
|
31678
|
+
}
|
|
31679
|
+
}
|
|
31644
31680
|
if (!this.ptyProcess || this.currentStatus !== "waiting_approval" && !modal) return;
|
|
31645
31681
|
this.clearIdleFinishCandidate("resolve_modal");
|
|
31646
31682
|
this.recordTrace("resolve_modal", {
|
|
@@ -32580,15 +32616,15 @@ ${data.message || ""}`.trim();
|
|
|
32580
32616
|
return null;
|
|
32581
32617
|
}
|
|
32582
32618
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
32583
|
-
return new Promise((
|
|
32619
|
+
return new Promise((resolve12) => {
|
|
32584
32620
|
const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
|
|
32585
32621
|
if (err || !stdout?.trim()) {
|
|
32586
|
-
|
|
32622
|
+
resolve12(null);
|
|
32587
32623
|
} else {
|
|
32588
|
-
|
|
32624
|
+
resolve12(stdout.trim());
|
|
32589
32625
|
}
|
|
32590
32626
|
});
|
|
32591
|
-
child.on("error", () =>
|
|
32627
|
+
child.on("error", () => resolve12(null));
|
|
32592
32628
|
});
|
|
32593
32629
|
}
|
|
32594
32630
|
async function detectCLIs(providerLoader, options) {
|
|
@@ -32940,7 +32976,7 @@ ${data.message || ""}`.trim();
|
|
|
32940
32976
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
32941
32977
|
*/
|
|
32942
32978
|
static listAllTargets(port) {
|
|
32943
|
-
return new Promise((
|
|
32979
|
+
return new Promise((resolve12) => {
|
|
32944
32980
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
32945
32981
|
let data = "";
|
|
32946
32982
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -32956,16 +32992,16 @@ ${data.message || ""}`.trim();
|
|
|
32956
32992
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
32957
32993
|
);
|
|
32958
32994
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
32959
|
-
|
|
32995
|
+
resolve12(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
32960
32996
|
} catch {
|
|
32961
|
-
|
|
32997
|
+
resolve12([]);
|
|
32962
32998
|
}
|
|
32963
32999
|
});
|
|
32964
33000
|
});
|
|
32965
|
-
req.on("error", () =>
|
|
33001
|
+
req.on("error", () => resolve12([]));
|
|
32966
33002
|
req.setTimeout(2e3, () => {
|
|
32967
33003
|
req.destroy();
|
|
32968
|
-
|
|
33004
|
+
resolve12([]);
|
|
32969
33005
|
});
|
|
32970
33006
|
});
|
|
32971
33007
|
}
|
|
@@ -33005,7 +33041,7 @@ ${data.message || ""}`.trim();
|
|
|
33005
33041
|
}
|
|
33006
33042
|
}
|
|
33007
33043
|
findTargetOnPort(port) {
|
|
33008
|
-
return new Promise((
|
|
33044
|
+
return new Promise((resolve12) => {
|
|
33009
33045
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
33010
33046
|
let data = "";
|
|
33011
33047
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -33016,7 +33052,7 @@ ${data.message || ""}`.trim();
|
|
|
33016
33052
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
33017
33053
|
);
|
|
33018
33054
|
if (pages.length === 0) {
|
|
33019
|
-
|
|
33055
|
+
resolve12(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
33020
33056
|
return;
|
|
33021
33057
|
}
|
|
33022
33058
|
const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -33035,25 +33071,25 @@ ${data.message || ""}`.trim();
|
|
|
33035
33071
|
this._targetId = selected.target.id;
|
|
33036
33072
|
}
|
|
33037
33073
|
this._pageTitle = selected.target.title || "";
|
|
33038
|
-
|
|
33074
|
+
resolve12(selected.target);
|
|
33039
33075
|
return;
|
|
33040
33076
|
}
|
|
33041
33077
|
if (previousTargetId) {
|
|
33042
33078
|
this.log(`[CDP] Target ${previousTargetId} not found in page list`);
|
|
33043
|
-
|
|
33079
|
+
resolve12(null);
|
|
33044
33080
|
return;
|
|
33045
33081
|
}
|
|
33046
33082
|
this._pageTitle = list[0]?.title || "";
|
|
33047
|
-
|
|
33083
|
+
resolve12(list[0]);
|
|
33048
33084
|
} catch {
|
|
33049
|
-
|
|
33085
|
+
resolve12(null);
|
|
33050
33086
|
}
|
|
33051
33087
|
});
|
|
33052
33088
|
});
|
|
33053
|
-
req.on("error", () =>
|
|
33089
|
+
req.on("error", () => resolve12(null));
|
|
33054
33090
|
req.setTimeout(2e3, () => {
|
|
33055
33091
|
req.destroy();
|
|
33056
|
-
|
|
33092
|
+
resolve12(null);
|
|
33057
33093
|
});
|
|
33058
33094
|
});
|
|
33059
33095
|
}
|
|
@@ -33064,7 +33100,7 @@ ${data.message || ""}`.trim();
|
|
|
33064
33100
|
this.extensionProviders = providers;
|
|
33065
33101
|
}
|
|
33066
33102
|
connectToTarget(wsUrl) {
|
|
33067
|
-
return new Promise((
|
|
33103
|
+
return new Promise((resolve12) => {
|
|
33068
33104
|
this.ws = new import_ws2.default(wsUrl);
|
|
33069
33105
|
this.ws.on("open", async () => {
|
|
33070
33106
|
this._connected = true;
|
|
@@ -33074,17 +33110,17 @@ ${data.message || ""}`.trim();
|
|
|
33074
33110
|
}
|
|
33075
33111
|
this.connectBrowserWs().catch(() => {
|
|
33076
33112
|
});
|
|
33077
|
-
|
|
33113
|
+
resolve12(true);
|
|
33078
33114
|
});
|
|
33079
33115
|
this.ws.on("message", (data) => {
|
|
33080
33116
|
try {
|
|
33081
33117
|
const msg = JSON.parse(data.toString());
|
|
33082
33118
|
if (msg.id && this.pending.has(msg.id)) {
|
|
33083
|
-
const { resolve:
|
|
33119
|
+
const { resolve: resolve13, reject } = this.pending.get(msg.id);
|
|
33084
33120
|
this.pending.delete(msg.id);
|
|
33085
33121
|
this.failureCount = 0;
|
|
33086
33122
|
if (msg.error) reject(new Error(msg.error.message));
|
|
33087
|
-
else
|
|
33123
|
+
else resolve13(msg.result);
|
|
33088
33124
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
33089
33125
|
this.contexts.add(msg.params.context.id);
|
|
33090
33126
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -33107,7 +33143,7 @@ ${data.message || ""}`.trim();
|
|
|
33107
33143
|
this.ws.on("error", (err) => {
|
|
33108
33144
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
33109
33145
|
this._connected = false;
|
|
33110
|
-
|
|
33146
|
+
resolve12(false);
|
|
33111
33147
|
});
|
|
33112
33148
|
});
|
|
33113
33149
|
}
|
|
@@ -33121,7 +33157,7 @@ ${data.message || ""}`.trim();
|
|
|
33121
33157
|
return;
|
|
33122
33158
|
}
|
|
33123
33159
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
33124
|
-
await new Promise((
|
|
33160
|
+
await new Promise((resolve12, reject) => {
|
|
33125
33161
|
this.browserWs = new import_ws2.default(browserWsUrl);
|
|
33126
33162
|
this.browserWs.on("open", async () => {
|
|
33127
33163
|
this._browserConnected = true;
|
|
@@ -33131,16 +33167,16 @@ ${data.message || ""}`.trim();
|
|
|
33131
33167
|
} catch (e) {
|
|
33132
33168
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
33133
33169
|
}
|
|
33134
|
-
|
|
33170
|
+
resolve12();
|
|
33135
33171
|
});
|
|
33136
33172
|
this.browserWs.on("message", (data) => {
|
|
33137
33173
|
try {
|
|
33138
33174
|
const msg = JSON.parse(data.toString());
|
|
33139
33175
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
33140
|
-
const { resolve:
|
|
33176
|
+
const { resolve: resolve13, reject: reject2 } = this.browserPending.get(msg.id);
|
|
33141
33177
|
this.browserPending.delete(msg.id);
|
|
33142
33178
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
33143
|
-
else
|
|
33179
|
+
else resolve13(msg.result);
|
|
33144
33180
|
}
|
|
33145
33181
|
} catch {
|
|
33146
33182
|
}
|
|
@@ -33160,31 +33196,31 @@ ${data.message || ""}`.trim();
|
|
|
33160
33196
|
}
|
|
33161
33197
|
}
|
|
33162
33198
|
getBrowserWsUrl() {
|
|
33163
|
-
return new Promise((
|
|
33199
|
+
return new Promise((resolve12) => {
|
|
33164
33200
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
33165
33201
|
let data = "";
|
|
33166
33202
|
res.on("data", (chunk) => data += chunk.toString());
|
|
33167
33203
|
res.on("end", () => {
|
|
33168
33204
|
try {
|
|
33169
33205
|
const info = JSON.parse(data);
|
|
33170
|
-
|
|
33206
|
+
resolve12(info.webSocketDebuggerUrl || null);
|
|
33171
33207
|
} catch {
|
|
33172
|
-
|
|
33208
|
+
resolve12(null);
|
|
33173
33209
|
}
|
|
33174
33210
|
});
|
|
33175
33211
|
});
|
|
33176
|
-
req.on("error", () =>
|
|
33212
|
+
req.on("error", () => resolve12(null));
|
|
33177
33213
|
req.setTimeout(3e3, () => {
|
|
33178
33214
|
req.destroy();
|
|
33179
|
-
|
|
33215
|
+
resolve12(null);
|
|
33180
33216
|
});
|
|
33181
33217
|
});
|
|
33182
33218
|
}
|
|
33183
33219
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
33184
|
-
return new Promise((
|
|
33220
|
+
return new Promise((resolve12, reject) => {
|
|
33185
33221
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
33186
33222
|
const id = this.browserMsgId++;
|
|
33187
|
-
this.browserPending.set(id, { resolve:
|
|
33223
|
+
this.browserPending.set(id, { resolve: resolve12, reject });
|
|
33188
33224
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
33189
33225
|
setTimeout(() => {
|
|
33190
33226
|
if (this.browserPending.has(id)) {
|
|
@@ -33224,11 +33260,11 @@ ${data.message || ""}`.trim();
|
|
|
33224
33260
|
}
|
|
33225
33261
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
33226
33262
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
33227
|
-
return new Promise((
|
|
33263
|
+
return new Promise((resolve12, reject) => {
|
|
33228
33264
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
33229
33265
|
if (this.ws.readyState !== import_ws2.default.OPEN) return reject(new Error("WebSocket not open"));
|
|
33230
33266
|
const id = this.msgId++;
|
|
33231
|
-
this.pending.set(id, { resolve:
|
|
33267
|
+
this.pending.set(id, { resolve: resolve12, reject });
|
|
33232
33268
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
33233
33269
|
setTimeout(() => {
|
|
33234
33270
|
if (this.pending.has(id)) {
|
|
@@ -33477,7 +33513,7 @@ ${data.message || ""}`.trim();
|
|
|
33477
33513
|
const browserWs = this.browserWs;
|
|
33478
33514
|
let msgId = this.browserMsgId;
|
|
33479
33515
|
const sendWs = (method, params = {}, sessionId) => {
|
|
33480
|
-
return new Promise((
|
|
33516
|
+
return new Promise((resolve12, reject) => {
|
|
33481
33517
|
const mid = msgId++;
|
|
33482
33518
|
this.browserMsgId = msgId;
|
|
33483
33519
|
const handler = (raw) => {
|
|
@@ -33486,7 +33522,7 @@ ${data.message || ""}`.trim();
|
|
|
33486
33522
|
if (msg.id === mid) {
|
|
33487
33523
|
browserWs.removeListener("message", handler);
|
|
33488
33524
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
33489
|
-
else
|
|
33525
|
+
else resolve12(msg.result);
|
|
33490
33526
|
}
|
|
33491
33527
|
} catch {
|
|
33492
33528
|
}
|
|
@@ -33687,14 +33723,14 @@ ${data.message || ""}`.trim();
|
|
|
33687
33723
|
if (!ws2 || ws2.readyState !== import_ws2.default.OPEN) {
|
|
33688
33724
|
throw new Error("CDP not connected");
|
|
33689
33725
|
}
|
|
33690
|
-
return new Promise((
|
|
33726
|
+
return new Promise((resolve12, reject) => {
|
|
33691
33727
|
const id = getNextId();
|
|
33692
33728
|
pendingMap.set(id, {
|
|
33693
33729
|
resolve: (result) => {
|
|
33694
33730
|
if (result?.result?.subtype === "error") {
|
|
33695
33731
|
reject(new Error(result.result.description));
|
|
33696
33732
|
} else {
|
|
33697
|
-
|
|
33733
|
+
resolve12(result?.result?.value);
|
|
33698
33734
|
}
|
|
33699
33735
|
},
|
|
33700
33736
|
reject
|
|
@@ -33726,10 +33762,10 @@ ${data.message || ""}`.trim();
|
|
|
33726
33762
|
throw new Error("CDP not connected");
|
|
33727
33763
|
}
|
|
33728
33764
|
const sendViaSession = (method, params = {}) => {
|
|
33729
|
-
return new Promise((
|
|
33765
|
+
return new Promise((resolve12, reject) => {
|
|
33730
33766
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
33731
33767
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
33732
|
-
pendingMap.set(id, { resolve:
|
|
33768
|
+
pendingMap.set(id, { resolve: resolve12, reject });
|
|
33733
33769
|
ws2.send(JSON.stringify({ id, sessionId, method, params }));
|
|
33734
33770
|
setTimeout(() => {
|
|
33735
33771
|
if (pendingMap.has(id)) {
|
|
@@ -37568,7 +37604,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
37568
37604
|
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
37569
37605
|
const sessionId = targetSessionId || h.currentSession?.sessionId || "";
|
|
37570
37606
|
if (!sessionId) return null;
|
|
37571
|
-
|
|
37607
|
+
const session = h.ctx.sessionRegistry?.get(sessionId);
|
|
37608
|
+
const instanceKey = session?.adapterKey || session?.instanceKey || sessionId;
|
|
37609
|
+
return h.ctx.instanceManager?.getInstance(instanceKey) || null;
|
|
37572
37610
|
}
|
|
37573
37611
|
function getTargetTransport(h, provider) {
|
|
37574
37612
|
if (h.currentSession?.transport) return h.currentSession.transport;
|
|
@@ -37865,7 +37903,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
37865
37903
|
async function getStableExtensionBaseline(h) {
|
|
37866
37904
|
const first = await readExtensionChatState(h);
|
|
37867
37905
|
if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
|
|
37868
|
-
await new Promise((
|
|
37906
|
+
await new Promise((resolve12) => setTimeout(resolve12, 150));
|
|
37869
37907
|
const second = await readExtensionChatState(h);
|
|
37870
37908
|
return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
|
|
37871
37909
|
}
|
|
@@ -37873,7 +37911,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
37873
37911
|
const beforeCount = getStateMessageCount(before);
|
|
37874
37912
|
const beforeSignature = getStateLastSignature(before);
|
|
37875
37913
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
37876
|
-
await new Promise((
|
|
37914
|
+
await new Promise((resolve12) => setTimeout(resolve12, 250));
|
|
37877
37915
|
const state = await readExtensionChatState(h);
|
|
37878
37916
|
if (state?.status === "waiting_approval") return true;
|
|
37879
37917
|
const afterCount = getStateMessageCount(state);
|
|
@@ -38637,10 +38675,17 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38637
38675
|
}
|
|
38638
38676
|
}
|
|
38639
38677
|
const status = adapter.getStatus();
|
|
38640
|
-
|
|
38678
|
+
const targetInstance = getTargetInstance(h, args);
|
|
38679
|
+
const targetState = targetInstance?.getState?.();
|
|
38680
|
+
const surfacedModal = targetState?.activeChat?.activeModal && Array.isArray(targetState.activeChat.activeModal.buttons) && targetState.activeChat.activeModal.buttons.some((candidate) => typeof candidate === "string" && candidate.trim()) ? targetState.activeChat.activeModal : null;
|
|
38681
|
+
const statusModal = status?.activeModal && Array.isArray(status.activeModal.buttons) && status.activeModal.buttons.some((candidate) => typeof candidate === "string" && candidate.trim()) ? status.activeModal : null;
|
|
38682
|
+
const effectiveModal = statusModal || surfacedModal;
|
|
38683
|
+
const effectiveStatus = status?.status === "waiting_approval" || targetState?.activeChat?.status === "waiting_approval" ? "waiting_approval" : status?.status;
|
|
38684
|
+
LOG2.info("Command", `[resolveAction] CLI PTY gate target=${String(args?.targetSessionId || "")} rawStatus=${String(status?.status || "")} effectiveStatus=${String(effectiveStatus || "")} statusModal=${statusModal ? "yes" : "no"} surfacedModal=${surfacedModal ? "yes" : "no"} instance=${targetInstance ? "yes" : "no"}`);
|
|
38685
|
+
if (effectiveStatus !== "waiting_approval" && !effectiveModal) {
|
|
38641
38686
|
return { success: false, error: "Not in approval state" };
|
|
38642
38687
|
}
|
|
38643
|
-
const buttons =
|
|
38688
|
+
const buttons = effectiveModal?.buttons || ["Allow once", "Always allow", "Deny"];
|
|
38644
38689
|
let buttonIndex = typeof args?.buttonIndex === "number" ? args.buttonIndex : -1;
|
|
38645
38690
|
if (buttonIndex < 0) {
|
|
38646
38691
|
const btnLower = button.toLowerCase();
|
|
@@ -40079,7 +40124,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40079
40124
|
try {
|
|
40080
40125
|
const http3 = await import("http");
|
|
40081
40126
|
const postData = JSON.stringify(body);
|
|
40082
|
-
const result = await new Promise((
|
|
40127
|
+
const result = await new Promise((resolve12, reject) => {
|
|
40083
40128
|
const req = http3.request({
|
|
40084
40129
|
hostname: "127.0.0.1",
|
|
40085
40130
|
port: 19280,
|
|
@@ -40091,9 +40136,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40091
40136
|
res.on("data", (chunk) => data += chunk);
|
|
40092
40137
|
res.on("end", () => {
|
|
40093
40138
|
try {
|
|
40094
|
-
|
|
40139
|
+
resolve12(JSON.parse(data));
|
|
40095
40140
|
} catch {
|
|
40096
|
-
|
|
40141
|
+
resolve12({ raw: data });
|
|
40097
40142
|
}
|
|
40098
40143
|
});
|
|
40099
40144
|
});
|
|
@@ -40111,15 +40156,15 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40111
40156
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
40112
40157
|
try {
|
|
40113
40158
|
const http3 = await import("http");
|
|
40114
|
-
const result = await new Promise((
|
|
40159
|
+
const result = await new Promise((resolve12, reject) => {
|
|
40115
40160
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
40116
40161
|
let data = "";
|
|
40117
40162
|
res.on("data", (chunk) => data += chunk);
|
|
40118
40163
|
res.on("end", () => {
|
|
40119
40164
|
try {
|
|
40120
|
-
|
|
40165
|
+
resolve12(JSON.parse(data));
|
|
40121
40166
|
} catch {
|
|
40122
|
-
|
|
40167
|
+
resolve12({ raw: data });
|
|
40123
40168
|
}
|
|
40124
40169
|
});
|
|
40125
40170
|
}).on("error", reject);
|
|
@@ -40133,7 +40178,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40133
40178
|
try {
|
|
40134
40179
|
const http3 = await import("http");
|
|
40135
40180
|
const postData = JSON.stringify(args || {});
|
|
40136
|
-
const result = await new Promise((
|
|
40181
|
+
const result = await new Promise((resolve12, reject) => {
|
|
40137
40182
|
const req = http3.request({
|
|
40138
40183
|
hostname: "127.0.0.1",
|
|
40139
40184
|
port: 19280,
|
|
@@ -40145,9 +40190,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40145
40190
|
res.on("data", (chunk) => data += chunk);
|
|
40146
40191
|
res.on("end", () => {
|
|
40147
40192
|
try {
|
|
40148
|
-
|
|
40193
|
+
resolve12(JSON.parse(data));
|
|
40149
40194
|
} catch {
|
|
40150
|
-
|
|
40195
|
+
resolve12({ raw: data });
|
|
40151
40196
|
}
|
|
40152
40197
|
});
|
|
40153
40198
|
});
|
|
@@ -40241,7 +40286,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40241
40286
|
if (status === "stopped") {
|
|
40242
40287
|
throw new Error("CLI runtime stopped before it became ready");
|
|
40243
40288
|
}
|
|
40244
|
-
await new Promise((
|
|
40289
|
+
await new Promise((resolve12) => setTimeout(resolve12, pollMs));
|
|
40245
40290
|
}
|
|
40246
40291
|
throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
|
|
40247
40292
|
}
|
|
@@ -41543,13 +41588,13 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41543
41588
|
}
|
|
41544
41589
|
this.currentStatus = "waiting_approval";
|
|
41545
41590
|
this.detectStatusTransition();
|
|
41546
|
-
const approved = await new Promise((
|
|
41547
|
-
this.permissionResolvers.push(
|
|
41591
|
+
const approved = await new Promise((resolve12) => {
|
|
41592
|
+
this.permissionResolvers.push(resolve12);
|
|
41548
41593
|
setTimeout(() => {
|
|
41549
|
-
const idx = this.permissionResolvers.indexOf(
|
|
41594
|
+
const idx = this.permissionResolvers.indexOf(resolve12);
|
|
41550
41595
|
if (idx >= 0) {
|
|
41551
41596
|
this.permissionResolvers.splice(idx, 1);
|
|
41552
|
-
|
|
41597
|
+
resolve12(false);
|
|
41553
41598
|
}
|
|
41554
41599
|
}, 3e5);
|
|
41555
41600
|
});
|
|
@@ -43077,10 +43122,75 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43077
43122
|
}
|
|
43078
43123
|
static GITHUB_TARBALL_URL = "https://github.com/vilmire/adhdev-providers/archive/refs/heads/main.tar.gz";
|
|
43079
43124
|
static META_FILE = ".meta.json";
|
|
43125
|
+
static REPO_PROVIDER_DIRNAME = "adhdev-providers";
|
|
43126
|
+
static SIBLING_MARKER_FILE = ".adhdev-provider-root";
|
|
43127
|
+
static SIBLING_ENV_VAR = "ADHDEV_USE_SIBLING_PROVIDERS";
|
|
43128
|
+
probeStarts = [];
|
|
43129
|
+
siblingLogged = false;
|
|
43130
|
+
userDirSource = "home-default";
|
|
43131
|
+
/** Process-level dedup for stderr sibling-adoption notices (shared across all ProviderLoader instances). */
|
|
43132
|
+
static siblingStderrLogged = /* @__PURE__ */ new Set();
|
|
43133
|
+
static looksLikeProviderRoot(candidate) {
|
|
43134
|
+
try {
|
|
43135
|
+
if (!fs6.existsSync(candidate) || !fs6.statSync(candidate).isDirectory()) return false;
|
|
43136
|
+
return ["ide", "extension", "cli", "acp"].some(
|
|
43137
|
+
(category) => fs6.existsSync(path13.join(candidate, category))
|
|
43138
|
+
);
|
|
43139
|
+
} catch {
|
|
43140
|
+
return false;
|
|
43141
|
+
}
|
|
43142
|
+
}
|
|
43143
|
+
static hasProviderRootMarker(candidate) {
|
|
43144
|
+
try {
|
|
43145
|
+
return fs6.existsSync(path13.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
43146
|
+
} catch {
|
|
43147
|
+
return false;
|
|
43148
|
+
}
|
|
43149
|
+
}
|
|
43150
|
+
detectDefaultUserDir() {
|
|
43151
|
+
const fallback = path13.join(os13.homedir(), ".adhdev", "providers");
|
|
43152
|
+
const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
|
|
43153
|
+
const visited = /* @__PURE__ */ new Set();
|
|
43154
|
+
for (const start of this.probeStarts) {
|
|
43155
|
+
let current = path13.resolve(start);
|
|
43156
|
+
while (!visited.has(current)) {
|
|
43157
|
+
visited.add(current);
|
|
43158
|
+
const siblingCandidate = path13.join(path13.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
|
|
43159
|
+
if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
|
|
43160
|
+
const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
|
|
43161
|
+
if (envOptIn || hasMarker) {
|
|
43162
|
+
const source = hasMarker ? "sibling-marker" : "sibling-env";
|
|
43163
|
+
if (!this.siblingLogged) {
|
|
43164
|
+
this.log(`Using sibling provider checkout (${source}): ${siblingCandidate}`);
|
|
43165
|
+
this.siblingLogged = true;
|
|
43166
|
+
}
|
|
43167
|
+
if (!_ProviderLoader.siblingStderrLogged.has(siblingCandidate)) {
|
|
43168
|
+
_ProviderLoader.siblingStderrLogged.add(siblingCandidate);
|
|
43169
|
+
try {
|
|
43170
|
+
process.stderr.write(
|
|
43171
|
+
`[adhdev] Using sibling adhdev-providers checkout (${source}): ${siblingCandidate}
|
|
43172
|
+
`
|
|
43173
|
+
);
|
|
43174
|
+
} catch {
|
|
43175
|
+
}
|
|
43176
|
+
}
|
|
43177
|
+
return { path: siblingCandidate, source };
|
|
43178
|
+
}
|
|
43179
|
+
}
|
|
43180
|
+
const parent = path13.dirname(current);
|
|
43181
|
+
if (parent === current) break;
|
|
43182
|
+
current = parent;
|
|
43183
|
+
}
|
|
43184
|
+
}
|
|
43185
|
+
return { path: fallback, source: "home-default" };
|
|
43186
|
+
}
|
|
43080
43187
|
constructor(options) {
|
|
43081
43188
|
this.logFn = options?.logFn || LOG2.forComponent("Provider").asLogFn();
|
|
43189
|
+
this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
|
|
43082
43190
|
this.defaultProvidersDir = path13.join(os13.homedir(), ".adhdev", "providers");
|
|
43083
|
-
|
|
43191
|
+
const detected = this.detectDefaultUserDir();
|
|
43192
|
+
this.userDir = detected.path;
|
|
43193
|
+
this.userDirSource = detected.source;
|
|
43084
43194
|
this.upstreamDir = path13.join(this.defaultProvidersDir, ".upstream");
|
|
43085
43195
|
this.disableUpstream = false;
|
|
43086
43196
|
this.applySourceConfig({
|
|
@@ -43118,6 +43228,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43118
43228
|
disableUpstream: this.disableUpstream,
|
|
43119
43229
|
explicitProviderDir: this.explicitProviderDir,
|
|
43120
43230
|
userDir: this.userDir,
|
|
43231
|
+
userDirSource: this.userDirSource,
|
|
43121
43232
|
upstreamDir: this.upstreamDir,
|
|
43122
43233
|
providerRoots: this.getProviderRoots()
|
|
43123
43234
|
};
|
|
@@ -43128,7 +43239,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43128
43239
|
this.explicitProviderDir = options.userDir?.trim() ? options.userDir : null;
|
|
43129
43240
|
}
|
|
43130
43241
|
this.sourceMode = nextSourceMode;
|
|
43131
|
-
|
|
43242
|
+
if (this.explicitProviderDir) {
|
|
43243
|
+
this.userDir = this.explicitProviderDir;
|
|
43244
|
+
this.userDirSource = "explicit";
|
|
43245
|
+
} else {
|
|
43246
|
+
const detected = this.detectDefaultUserDir();
|
|
43247
|
+
this.userDir = detected.path;
|
|
43248
|
+
this.userDirSource = detected.source;
|
|
43249
|
+
}
|
|
43132
43250
|
this.upstreamDir = path13.join(this.defaultProvidersDir, ".upstream");
|
|
43133
43251
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
43134
43252
|
if (this.explicitProviderDir) {
|
|
@@ -43722,7 +43840,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43722
43840
|
return { updated: false };
|
|
43723
43841
|
}
|
|
43724
43842
|
try {
|
|
43725
|
-
const etag = await new Promise((
|
|
43843
|
+
const etag = await new Promise((resolve12, reject) => {
|
|
43726
43844
|
const options = {
|
|
43727
43845
|
method: "HEAD",
|
|
43728
43846
|
hostname: "github.com",
|
|
@@ -43740,7 +43858,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43740
43858
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
43741
43859
|
timeout: 1e4
|
|
43742
43860
|
}, (res2) => {
|
|
43743
|
-
|
|
43861
|
+
resolve12(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
43744
43862
|
});
|
|
43745
43863
|
req2.on("error", reject);
|
|
43746
43864
|
req2.on("timeout", () => {
|
|
@@ -43749,7 +43867,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43749
43867
|
});
|
|
43750
43868
|
req2.end();
|
|
43751
43869
|
} else {
|
|
43752
|
-
|
|
43870
|
+
resolve12(res.headers.etag || res.headers["last-modified"] || "");
|
|
43753
43871
|
}
|
|
43754
43872
|
});
|
|
43755
43873
|
req.on("error", reject);
|
|
@@ -43813,7 +43931,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43813
43931
|
downloadFile(url2, destPath) {
|
|
43814
43932
|
const https = require("https");
|
|
43815
43933
|
const http3 = require("http");
|
|
43816
|
-
return new Promise((
|
|
43934
|
+
return new Promise((resolve12, reject) => {
|
|
43817
43935
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
43818
43936
|
if (redirectCount > 5) {
|
|
43819
43937
|
reject(new Error("Too many redirects"));
|
|
@@ -43833,7 +43951,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43833
43951
|
res.pipe(ws2);
|
|
43834
43952
|
ws2.on("finish", () => {
|
|
43835
43953
|
ws2.close();
|
|
43836
|
-
|
|
43954
|
+
resolve12();
|
|
43837
43955
|
});
|
|
43838
43956
|
ws2.on("error", reject);
|
|
43839
43957
|
});
|
|
@@ -44306,17 +44424,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44306
44424
|
throw new Error("No free port found");
|
|
44307
44425
|
}
|
|
44308
44426
|
function checkPortFree(port) {
|
|
44309
|
-
return new Promise((
|
|
44427
|
+
return new Promise((resolve12) => {
|
|
44310
44428
|
const server = net3.createServer();
|
|
44311
44429
|
server.unref();
|
|
44312
|
-
server.on("error", () =>
|
|
44430
|
+
server.on("error", () => resolve12(false));
|
|
44313
44431
|
server.listen(port, "127.0.0.1", () => {
|
|
44314
|
-
server.close(() =>
|
|
44432
|
+
server.close(() => resolve12(true));
|
|
44315
44433
|
});
|
|
44316
44434
|
});
|
|
44317
44435
|
}
|
|
44318
44436
|
async function isCdpActive(port) {
|
|
44319
|
-
return new Promise((
|
|
44437
|
+
return new Promise((resolve12) => {
|
|
44320
44438
|
const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
44321
44439
|
timeout: 2e3
|
|
44322
44440
|
}, (res) => {
|
|
@@ -44325,16 +44443,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44325
44443
|
res.on("end", () => {
|
|
44326
44444
|
try {
|
|
44327
44445
|
const info = JSON.parse(data);
|
|
44328
|
-
|
|
44446
|
+
resolve12(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
44329
44447
|
} catch {
|
|
44330
|
-
|
|
44448
|
+
resolve12(false);
|
|
44331
44449
|
}
|
|
44332
44450
|
});
|
|
44333
44451
|
});
|
|
44334
|
-
req.on("error", () =>
|
|
44452
|
+
req.on("error", () => resolve12(false));
|
|
44335
44453
|
req.on("timeout", () => {
|
|
44336
44454
|
req.destroy();
|
|
44337
|
-
|
|
44455
|
+
resolve12(false);
|
|
44338
44456
|
});
|
|
44339
44457
|
});
|
|
44340
44458
|
}
|
|
@@ -45116,7 +45234,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45116
45234
|
while (Date.now() - start < timeoutMs) {
|
|
45117
45235
|
try {
|
|
45118
45236
|
process.kill(pid, 0);
|
|
45119
|
-
await new Promise((
|
|
45237
|
+
await new Promise((resolve12) => setTimeout(resolve12, 250));
|
|
45120
45238
|
} catch {
|
|
45121
45239
|
return;
|
|
45122
45240
|
}
|
|
@@ -45231,7 +45349,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45231
45349
|
appendUpgradeLog(installOutput.trim());
|
|
45232
45350
|
}
|
|
45233
45351
|
if (process.platform === "win32") {
|
|
45234
|
-
await new Promise((
|
|
45352
|
+
await new Promise((resolve12) => setTimeout(resolve12, 500));
|
|
45235
45353
|
cleanupStaleGlobalInstallDirs(payload.packageName);
|
|
45236
45354
|
appendUpgradeLog("Post-install staging cleanup complete");
|
|
45237
45355
|
}
|
|
@@ -46559,7 +46677,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46559
46677
|
const beforeCount = this.messageCount(before);
|
|
46560
46678
|
const beforeSignature = this.lastMessageSignature(before);
|
|
46561
46679
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
46562
|
-
await new Promise((
|
|
46680
|
+
await new Promise((resolve12) => setTimeout(resolve12, 250));
|
|
46563
46681
|
let state;
|
|
46564
46682
|
try {
|
|
46565
46683
|
state = await this.readChat(evaluate);
|
|
@@ -46581,7 +46699,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46581
46699
|
if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
|
|
46582
46700
|
return first;
|
|
46583
46701
|
}
|
|
46584
|
-
await new Promise((
|
|
46702
|
+
await new Promise((resolve12) => setTimeout(resolve12, 150));
|
|
46585
46703
|
const second = await this.readChat(evaluate);
|
|
46586
46704
|
return this.messageCount(second) >= this.messageCount(first) ? second : first;
|
|
46587
46705
|
}
|
|
@@ -46732,7 +46850,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46732
46850
|
if (typeof data.error === "string" && data.error.trim()) return false;
|
|
46733
46851
|
}
|
|
46734
46852
|
for (let attempt = 0; attempt < 6; attempt += 1) {
|
|
46735
|
-
await new Promise((
|
|
46853
|
+
await new Promise((resolve12) => setTimeout(resolve12, 250));
|
|
46736
46854
|
const state = await this.readChat(evaluate);
|
|
46737
46855
|
const title = this.getStateTitle(state);
|
|
46738
46856
|
if (this.titlesMatch(title, sessionId)) return true;
|
|
@@ -49236,7 +49354,7 @@ async (params) => {
|
|
|
49236
49354
|
return { target, instance, adapter };
|
|
49237
49355
|
}
|
|
49238
49356
|
function sleep(ms2) {
|
|
49239
|
-
return new Promise((
|
|
49357
|
+
return new Promise((resolve12) => setTimeout(resolve12, ms2));
|
|
49240
49358
|
}
|
|
49241
49359
|
async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
|
|
49242
49360
|
const startedAt = Date.now();
|
|
@@ -51490,15 +51608,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
51490
51608
|
this.json(res, 500, { error: e.message });
|
|
51491
51609
|
}
|
|
51492
51610
|
});
|
|
51493
|
-
return new Promise((
|
|
51611
|
+
return new Promise((resolve12, reject) => {
|
|
51494
51612
|
this.server.listen(port, "127.0.0.1", () => {
|
|
51495
51613
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
51496
|
-
|
|
51614
|
+
resolve12();
|
|
51497
51615
|
});
|
|
51498
51616
|
this.server.on("error", (e) => {
|
|
51499
51617
|
if (e.code === "EADDRINUSE") {
|
|
51500
51618
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
51501
|
-
|
|
51619
|
+
resolve12();
|
|
51502
51620
|
} else {
|
|
51503
51621
|
reject(e);
|
|
51504
51622
|
}
|
|
@@ -51580,20 +51698,20 @@ data: ${JSON.stringify(msg.data)}
|
|
|
51580
51698
|
child.stderr?.on("data", (d) => {
|
|
51581
51699
|
stderr += d.toString().slice(0, 2e3);
|
|
51582
51700
|
});
|
|
51583
|
-
await new Promise((
|
|
51701
|
+
await new Promise((resolve12) => {
|
|
51584
51702
|
const timer = setTimeout(() => {
|
|
51585
51703
|
child.kill();
|
|
51586
|
-
|
|
51704
|
+
resolve12();
|
|
51587
51705
|
}, 3e3);
|
|
51588
51706
|
child.on("exit", () => {
|
|
51589
51707
|
clearTimeout(timer);
|
|
51590
|
-
|
|
51708
|
+
resolve12();
|
|
51591
51709
|
});
|
|
51592
51710
|
child.stdout?.once("data", () => {
|
|
51593
51711
|
setTimeout(() => {
|
|
51594
51712
|
child.kill();
|
|
51595
51713
|
clearTimeout(timer);
|
|
51596
|
-
|
|
51714
|
+
resolve12();
|
|
51597
51715
|
}, 500);
|
|
51598
51716
|
});
|
|
51599
51717
|
});
|
|
@@ -52109,14 +52227,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
52109
52227
|
child.stderr?.on("data", (d) => {
|
|
52110
52228
|
stderr += d.toString();
|
|
52111
52229
|
});
|
|
52112
|
-
await new Promise((
|
|
52230
|
+
await new Promise((resolve12) => {
|
|
52113
52231
|
const timer = setTimeout(() => {
|
|
52114
52232
|
child.kill();
|
|
52115
|
-
|
|
52233
|
+
resolve12();
|
|
52116
52234
|
}, timeout);
|
|
52117
52235
|
child.on("exit", () => {
|
|
52118
52236
|
clearTimeout(timer);
|
|
52119
|
-
|
|
52237
|
+
resolve12();
|
|
52120
52238
|
});
|
|
52121
52239
|
});
|
|
52122
52240
|
const elapsed = Date.now() - start;
|
|
@@ -52786,14 +52904,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
52786
52904
|
res.end(JSON.stringify(data, null, 2));
|
|
52787
52905
|
}
|
|
52788
52906
|
async readBody(req) {
|
|
52789
|
-
return new Promise((
|
|
52907
|
+
return new Promise((resolve12) => {
|
|
52790
52908
|
let body = "";
|
|
52791
52909
|
req.on("data", (chunk) => body += chunk);
|
|
52792
52910
|
req.on("end", () => {
|
|
52793
52911
|
try {
|
|
52794
|
-
|
|
52912
|
+
resolve12(JSON.parse(body));
|
|
52795
52913
|
} catch {
|
|
52796
|
-
|
|
52914
|
+
resolve12({});
|
|
52797
52915
|
}
|
|
52798
52916
|
});
|
|
52799
52917
|
});
|
|
@@ -53293,7 +53411,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53293
53411
|
const deadline = Date.now() + timeoutMs;
|
|
53294
53412
|
while (Date.now() < deadline) {
|
|
53295
53413
|
if (await canConnect(endpoint)) return;
|
|
53296
|
-
await new Promise((
|
|
53414
|
+
await new Promise((resolve12) => setTimeout(resolve12, STARTUP_POLL_MS));
|
|
53297
53415
|
}
|
|
53298
53416
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
53299
53417
|
}
|
|
@@ -53467,10 +53585,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53467
53585
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
53468
53586
|
const fs15 = await import("fs");
|
|
53469
53587
|
fs15.writeFileSync(vsixPath, buffer);
|
|
53470
|
-
return new Promise((
|
|
53588
|
+
return new Promise((resolve12) => {
|
|
53471
53589
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
53472
53590
|
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
53473
|
-
|
|
53591
|
+
resolve12({
|
|
53474
53592
|
extensionId: extension.id,
|
|
53475
53593
|
marketplaceId: extension.marketplaceId,
|
|
53476
53594
|
success: !error48,
|
|
@@ -53483,11 +53601,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53483
53601
|
} catch (e) {
|
|
53484
53602
|
}
|
|
53485
53603
|
}
|
|
53486
|
-
return new Promise((
|
|
53604
|
+
return new Promise((resolve12) => {
|
|
53487
53605
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
53488
53606
|
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
|
|
53489
53607
|
if (error48) {
|
|
53490
|
-
|
|
53608
|
+
resolve12({
|
|
53491
53609
|
extensionId: extension.id,
|
|
53492
53610
|
marketplaceId: extension.marketplaceId,
|
|
53493
53611
|
success: false,
|
|
@@ -53495,7 +53613,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53495
53613
|
error: stderr || error48.message
|
|
53496
53614
|
});
|
|
53497
53615
|
} else {
|
|
53498
|
-
|
|
53616
|
+
resolve12({
|
|
53499
53617
|
extensionId: extension.id,
|
|
53500
53618
|
marketplaceId: extension.marketplaceId,
|
|
53501
53619
|
success: true,
|
|
@@ -55332,7 +55450,6 @@ var StandaloneServer = class {
|
|
|
55332
55450
|
const status = this.getWsStatus(this.buildSharedSnapshot("live"));
|
|
55333
55451
|
this.lastWsStatusSignature = this.buildWsStatusSignature(status);
|
|
55334
55452
|
ws2.send(JSON.stringify({ type: "status", data: status }));
|
|
55335
|
-
void this.pushWsRuntimeSnapshots(ws2);
|
|
55336
55453
|
ws2.on("message", async (raw) => {
|
|
55337
55454
|
try {
|
|
55338
55455
|
const msg = JSON.parse(raw.toString());
|