@adhdev/daemon-core 0.9.82-rc.129 → 0.9.82-rc.130
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 +174 -121
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +178 -125
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +85 -6
package/dist/index.mjs
CHANGED
|
@@ -2151,19 +2151,19 @@ function resolveCommandPath(command) {
|
|
|
2151
2151
|
return null;
|
|
2152
2152
|
}
|
|
2153
2153
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
2154
|
-
return new Promise((
|
|
2154
|
+
return new Promise((resolve18) => {
|
|
2155
2155
|
const child = exec(cmd, {
|
|
2156
2156
|
encoding: "utf-8",
|
|
2157
2157
|
timeout: timeoutMs,
|
|
2158
2158
|
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
2159
2159
|
}, (err, stdout) => {
|
|
2160
2160
|
if (err || !stdout?.trim()) {
|
|
2161
|
-
|
|
2161
|
+
resolve18(null);
|
|
2162
2162
|
} else {
|
|
2163
|
-
|
|
2163
|
+
resolve18(stdout.trim());
|
|
2164
2164
|
}
|
|
2165
2165
|
});
|
|
2166
|
-
child.on("error", () =>
|
|
2166
|
+
child.on("error", () => resolve18(null));
|
|
2167
2167
|
});
|
|
2168
2168
|
}
|
|
2169
2169
|
async function detectCLIs(providerLoader, options) {
|
|
@@ -5379,7 +5379,7 @@ ${lastSnapshot}`;
|
|
|
5379
5379
|
`[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
|
|
5380
5380
|
);
|
|
5381
5381
|
}
|
|
5382
|
-
await new Promise((
|
|
5382
|
+
await new Promise((resolve18) => setTimeout(resolve18, 50));
|
|
5383
5383
|
}
|
|
5384
5384
|
const finalScreenText = this.terminalScreen.getText() || "";
|
|
5385
5385
|
LOG.warn(
|
|
@@ -6624,7 +6624,7 @@ ${lastSnapshot}`;
|
|
|
6624
6624
|
const deadline = Date.now() + 1e4;
|
|
6625
6625
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
6626
6626
|
this.resolveStartupState("send_wait");
|
|
6627
|
-
await new Promise((
|
|
6627
|
+
await new Promise((resolve18) => setTimeout(resolve18, 50));
|
|
6628
6628
|
}
|
|
6629
6629
|
}
|
|
6630
6630
|
const parsedStatusBeforeSend = !allowInputDuringGeneration ? (() => {
|
|
@@ -6721,13 +6721,13 @@ ${lastSnapshot}`;
|
|
|
6721
6721
|
}
|
|
6722
6722
|
this.responseEpoch += 1;
|
|
6723
6723
|
this.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
|
|
6724
|
-
await new Promise((
|
|
6724
|
+
await new Promise((resolve18, reject) => {
|
|
6725
6725
|
let resolved = false;
|
|
6726
6726
|
const completion = {
|
|
6727
6727
|
resolveOnce: () => {
|
|
6728
6728
|
if (resolved) return;
|
|
6729
6729
|
resolved = true;
|
|
6730
|
-
|
|
6730
|
+
resolve18();
|
|
6731
6731
|
},
|
|
6732
6732
|
rejectOnce: (error) => {
|
|
6733
6733
|
if (resolved) return;
|
|
@@ -6885,17 +6885,17 @@ ${lastSnapshot}`;
|
|
|
6885
6885
|
}
|
|
6886
6886
|
}
|
|
6887
6887
|
waitForStopped(timeoutMs) {
|
|
6888
|
-
return new Promise((
|
|
6888
|
+
return new Promise((resolve18) => {
|
|
6889
6889
|
const startedAt = Date.now();
|
|
6890
6890
|
const timer = setInterval(() => {
|
|
6891
6891
|
if (!this.ptyProcess || this.currentStatus === "stopped") {
|
|
6892
6892
|
clearInterval(timer);
|
|
6893
|
-
|
|
6893
|
+
resolve18(true);
|
|
6894
6894
|
return;
|
|
6895
6895
|
}
|
|
6896
6896
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
6897
6897
|
clearInterval(timer);
|
|
6898
|
-
|
|
6898
|
+
resolve18(false);
|
|
6899
6899
|
}
|
|
6900
6900
|
}, 100);
|
|
6901
6901
|
});
|
|
@@ -10760,7 +10760,7 @@ var DaemonCdpManager = class {
|
|
|
10760
10760
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
10761
10761
|
*/
|
|
10762
10762
|
static listAllTargets(port) {
|
|
10763
|
-
return new Promise((
|
|
10763
|
+
return new Promise((resolve18) => {
|
|
10764
10764
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
10765
10765
|
let data = "";
|
|
10766
10766
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -10776,16 +10776,16 @@ var DaemonCdpManager = class {
|
|
|
10776
10776
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
10777
10777
|
);
|
|
10778
10778
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
10779
|
-
|
|
10779
|
+
resolve18(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
10780
10780
|
} catch {
|
|
10781
|
-
|
|
10781
|
+
resolve18([]);
|
|
10782
10782
|
}
|
|
10783
10783
|
});
|
|
10784
10784
|
});
|
|
10785
|
-
req.on("error", () =>
|
|
10785
|
+
req.on("error", () => resolve18([]));
|
|
10786
10786
|
req.setTimeout(2e3, () => {
|
|
10787
10787
|
req.destroy();
|
|
10788
|
-
|
|
10788
|
+
resolve18([]);
|
|
10789
10789
|
});
|
|
10790
10790
|
});
|
|
10791
10791
|
}
|
|
@@ -10825,7 +10825,7 @@ var DaemonCdpManager = class {
|
|
|
10825
10825
|
}
|
|
10826
10826
|
}
|
|
10827
10827
|
findTargetOnPort(port) {
|
|
10828
|
-
return new Promise((
|
|
10828
|
+
return new Promise((resolve18) => {
|
|
10829
10829
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
10830
10830
|
let data = "";
|
|
10831
10831
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -10836,7 +10836,7 @@ var DaemonCdpManager = class {
|
|
|
10836
10836
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
10837
10837
|
);
|
|
10838
10838
|
if (pages.length === 0) {
|
|
10839
|
-
|
|
10839
|
+
resolve18(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
10840
10840
|
return;
|
|
10841
10841
|
}
|
|
10842
10842
|
const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -10855,25 +10855,25 @@ var DaemonCdpManager = class {
|
|
|
10855
10855
|
this._targetId = selected.target.id;
|
|
10856
10856
|
}
|
|
10857
10857
|
this._pageTitle = selected.target.title || "";
|
|
10858
|
-
|
|
10858
|
+
resolve18(selected.target);
|
|
10859
10859
|
return;
|
|
10860
10860
|
}
|
|
10861
10861
|
if (previousTargetId) {
|
|
10862
10862
|
this.log(`[CDP] Target ${previousTargetId} not found in page list`);
|
|
10863
|
-
|
|
10863
|
+
resolve18(null);
|
|
10864
10864
|
return;
|
|
10865
10865
|
}
|
|
10866
10866
|
this._pageTitle = list[0]?.title || "";
|
|
10867
|
-
|
|
10867
|
+
resolve18(list[0]);
|
|
10868
10868
|
} catch {
|
|
10869
|
-
|
|
10869
|
+
resolve18(null);
|
|
10870
10870
|
}
|
|
10871
10871
|
});
|
|
10872
10872
|
});
|
|
10873
|
-
req.on("error", () =>
|
|
10873
|
+
req.on("error", () => resolve18(null));
|
|
10874
10874
|
req.setTimeout(2e3, () => {
|
|
10875
10875
|
req.destroy();
|
|
10876
|
-
|
|
10876
|
+
resolve18(null);
|
|
10877
10877
|
});
|
|
10878
10878
|
});
|
|
10879
10879
|
}
|
|
@@ -10884,7 +10884,7 @@ var DaemonCdpManager = class {
|
|
|
10884
10884
|
this.extensionProviders = providers;
|
|
10885
10885
|
}
|
|
10886
10886
|
connectToTarget(wsUrl) {
|
|
10887
|
-
return new Promise((
|
|
10887
|
+
return new Promise((resolve18) => {
|
|
10888
10888
|
this.ws = new WebSocket(wsUrl);
|
|
10889
10889
|
this.ws.on("open", async () => {
|
|
10890
10890
|
this._connected = true;
|
|
@@ -10894,17 +10894,17 @@ var DaemonCdpManager = class {
|
|
|
10894
10894
|
}
|
|
10895
10895
|
this.connectBrowserWs().catch(() => {
|
|
10896
10896
|
});
|
|
10897
|
-
|
|
10897
|
+
resolve18(true);
|
|
10898
10898
|
});
|
|
10899
10899
|
this.ws.on("message", (data) => {
|
|
10900
10900
|
try {
|
|
10901
10901
|
const msg = JSON.parse(data.toString());
|
|
10902
10902
|
if (msg.id && this.pending.has(msg.id)) {
|
|
10903
|
-
const { resolve:
|
|
10903
|
+
const { resolve: resolve19, reject } = this.pending.get(msg.id);
|
|
10904
10904
|
this.pending.delete(msg.id);
|
|
10905
10905
|
this.failureCount = 0;
|
|
10906
10906
|
if (msg.error) reject(new Error(msg.error.message));
|
|
10907
|
-
else
|
|
10907
|
+
else resolve19(msg.result);
|
|
10908
10908
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
10909
10909
|
this.contexts.add(msg.params.context.id);
|
|
10910
10910
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -10927,7 +10927,7 @@ var DaemonCdpManager = class {
|
|
|
10927
10927
|
this.ws.on("error", (err) => {
|
|
10928
10928
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
10929
10929
|
this._connected = false;
|
|
10930
|
-
|
|
10930
|
+
resolve18(false);
|
|
10931
10931
|
});
|
|
10932
10932
|
});
|
|
10933
10933
|
}
|
|
@@ -10941,7 +10941,7 @@ var DaemonCdpManager = class {
|
|
|
10941
10941
|
return;
|
|
10942
10942
|
}
|
|
10943
10943
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
10944
|
-
await new Promise((
|
|
10944
|
+
await new Promise((resolve18, reject) => {
|
|
10945
10945
|
this.browserWs = new WebSocket(browserWsUrl);
|
|
10946
10946
|
this.browserWs.on("open", async () => {
|
|
10947
10947
|
this._browserConnected = true;
|
|
@@ -10951,16 +10951,16 @@ var DaemonCdpManager = class {
|
|
|
10951
10951
|
} catch (e) {
|
|
10952
10952
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
10953
10953
|
}
|
|
10954
|
-
|
|
10954
|
+
resolve18();
|
|
10955
10955
|
});
|
|
10956
10956
|
this.browserWs.on("message", (data) => {
|
|
10957
10957
|
try {
|
|
10958
10958
|
const msg = JSON.parse(data.toString());
|
|
10959
10959
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
10960
|
-
const { resolve:
|
|
10960
|
+
const { resolve: resolve19, reject: reject2 } = this.browserPending.get(msg.id);
|
|
10961
10961
|
this.browserPending.delete(msg.id);
|
|
10962
10962
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
10963
|
-
else
|
|
10963
|
+
else resolve19(msg.result);
|
|
10964
10964
|
}
|
|
10965
10965
|
} catch {
|
|
10966
10966
|
}
|
|
@@ -10980,31 +10980,31 @@ var DaemonCdpManager = class {
|
|
|
10980
10980
|
}
|
|
10981
10981
|
}
|
|
10982
10982
|
getBrowserWsUrl() {
|
|
10983
|
-
return new Promise((
|
|
10983
|
+
return new Promise((resolve18) => {
|
|
10984
10984
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
10985
10985
|
let data = "";
|
|
10986
10986
|
res.on("data", (chunk) => data += chunk.toString());
|
|
10987
10987
|
res.on("end", () => {
|
|
10988
10988
|
try {
|
|
10989
10989
|
const info = JSON.parse(data);
|
|
10990
|
-
|
|
10990
|
+
resolve18(info.webSocketDebuggerUrl || null);
|
|
10991
10991
|
} catch {
|
|
10992
|
-
|
|
10992
|
+
resolve18(null);
|
|
10993
10993
|
}
|
|
10994
10994
|
});
|
|
10995
10995
|
});
|
|
10996
|
-
req.on("error", () =>
|
|
10996
|
+
req.on("error", () => resolve18(null));
|
|
10997
10997
|
req.setTimeout(3e3, () => {
|
|
10998
10998
|
req.destroy();
|
|
10999
|
-
|
|
10999
|
+
resolve18(null);
|
|
11000
11000
|
});
|
|
11001
11001
|
});
|
|
11002
11002
|
}
|
|
11003
11003
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
11004
|
-
return new Promise((
|
|
11004
|
+
return new Promise((resolve18, reject) => {
|
|
11005
11005
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
11006
11006
|
const id = this.browserMsgId++;
|
|
11007
|
-
this.browserPending.set(id, { resolve:
|
|
11007
|
+
this.browserPending.set(id, { resolve: resolve18, reject });
|
|
11008
11008
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
11009
11009
|
setTimeout(() => {
|
|
11010
11010
|
if (this.browserPending.has(id)) {
|
|
@@ -11044,11 +11044,11 @@ var DaemonCdpManager = class {
|
|
|
11044
11044
|
}
|
|
11045
11045
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
11046
11046
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
11047
|
-
return new Promise((
|
|
11047
|
+
return new Promise((resolve18, reject) => {
|
|
11048
11048
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
11049
11049
|
if (this.ws.readyState !== WebSocket.OPEN) return reject(new Error("WebSocket not open"));
|
|
11050
11050
|
const id = this.msgId++;
|
|
11051
|
-
this.pending.set(id, { resolve:
|
|
11051
|
+
this.pending.set(id, { resolve: resolve18, reject });
|
|
11052
11052
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
11053
11053
|
setTimeout(() => {
|
|
11054
11054
|
if (this.pending.has(id)) {
|
|
@@ -11297,7 +11297,7 @@ var DaemonCdpManager = class {
|
|
|
11297
11297
|
const browserWs = this.browserWs;
|
|
11298
11298
|
let msgId = this.browserMsgId;
|
|
11299
11299
|
const sendWs = (method, params = {}, sessionId) => {
|
|
11300
|
-
return new Promise((
|
|
11300
|
+
return new Promise((resolve18, reject) => {
|
|
11301
11301
|
const mid = msgId++;
|
|
11302
11302
|
this.browserMsgId = msgId;
|
|
11303
11303
|
const handler = (raw) => {
|
|
@@ -11306,7 +11306,7 @@ var DaemonCdpManager = class {
|
|
|
11306
11306
|
if (msg.id === mid) {
|
|
11307
11307
|
browserWs.removeListener("message", handler);
|
|
11308
11308
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
11309
|
-
else
|
|
11309
|
+
else resolve18(msg.result);
|
|
11310
11310
|
}
|
|
11311
11311
|
} catch {
|
|
11312
11312
|
}
|
|
@@ -11507,14 +11507,14 @@ var DaemonCdpManager = class {
|
|
|
11507
11507
|
if (!ws || ws.readyState !== WebSocket.OPEN) {
|
|
11508
11508
|
throw new Error("CDP not connected");
|
|
11509
11509
|
}
|
|
11510
|
-
return new Promise((
|
|
11510
|
+
return new Promise((resolve18, reject) => {
|
|
11511
11511
|
const id = getNextId();
|
|
11512
11512
|
pendingMap.set(id, {
|
|
11513
11513
|
resolve: (result) => {
|
|
11514
11514
|
if (result?.result?.subtype === "error") {
|
|
11515
11515
|
reject(new Error(result.result.description));
|
|
11516
11516
|
} else {
|
|
11517
|
-
|
|
11517
|
+
resolve18(result?.result?.value);
|
|
11518
11518
|
}
|
|
11519
11519
|
},
|
|
11520
11520
|
reject
|
|
@@ -11546,10 +11546,10 @@ var DaemonCdpManager = class {
|
|
|
11546
11546
|
throw new Error("CDP not connected");
|
|
11547
11547
|
}
|
|
11548
11548
|
const sendViaSession = (method, params = {}) => {
|
|
11549
|
-
return new Promise((
|
|
11549
|
+
return new Promise((resolve18, reject) => {
|
|
11550
11550
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
11551
11551
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
11552
|
-
pendingMap.set(id, { resolve:
|
|
11552
|
+
pendingMap.set(id, { resolve: resolve18, reject });
|
|
11553
11553
|
ws.send(JSON.stringify({ id, sessionId, method, params }));
|
|
11554
11554
|
setTimeout(() => {
|
|
11555
11555
|
if (pendingMap.has(id)) {
|
|
@@ -16655,7 +16655,7 @@ function getSendChatInputEnvelope(args) {
|
|
|
16655
16655
|
return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
|
|
16656
16656
|
}
|
|
16657
16657
|
function sleep(ms) {
|
|
16658
|
-
return new Promise((
|
|
16658
|
+
return new Promise((resolve18) => setTimeout(resolve18, ms));
|
|
16659
16659
|
}
|
|
16660
16660
|
async function waitOnceForFreshHermesCliStart(adapter, log) {
|
|
16661
16661
|
if (adapter.cliType !== "hermes-cli") return;
|
|
@@ -16895,6 +16895,39 @@ function readExactRuntimeMirrorMessages(args) {
|
|
|
16895
16895
|
return historySessionId === targetSessionId || instanceId === targetSessionId;
|
|
16896
16896
|
});
|
|
16897
16897
|
}
|
|
16898
|
+
function normalizeComparableWorkspace(value) {
|
|
16899
|
+
const text = typeof value === "string" ? value.trim() : "";
|
|
16900
|
+
if (!text) return "";
|
|
16901
|
+
return path12.resolve(text);
|
|
16902
|
+
}
|
|
16903
|
+
function isCurrentRuntimePtySafelyAttributed(args) {
|
|
16904
|
+
if (args.adapter.cliType !== "codex-cli") return false;
|
|
16905
|
+
if (!Array.isArray(args.ptyMessages) || args.ptyMessages.length === 0) return false;
|
|
16906
|
+
const targetSessionId = typeof args.readChatArgs?.targetSessionId === "string" ? args.readChatArgs.targetSessionId.trim() : "";
|
|
16907
|
+
const currentSession = args.helpers.currentSession;
|
|
16908
|
+
const currentSessionId = typeof currentSession?.sessionId === "string" ? currentSession.sessionId.trim() : "";
|
|
16909
|
+
if (!targetSessionId || !currentSessionId || targetSessionId !== currentSessionId) return false;
|
|
16910
|
+
const runtimeMeta = typeof args.adapter.getRuntimeMetadata === "function" ? args.adapter.getRuntimeMetadata() : null;
|
|
16911
|
+
const runtimeId = typeof runtimeMeta?.runtimeId === "string" ? runtimeMeta.runtimeId.trim() : "";
|
|
16912
|
+
if (!runtimeId || runtimeId !== targetSessionId) return false;
|
|
16913
|
+
const surfaceKind = typeof runtimeMeta?.surfaceKind === "string" ? runtimeMeta.surfaceKind : "";
|
|
16914
|
+
if (surfaceKind === "inactive_record" || surfaceKind === "recovery_snapshot") return false;
|
|
16915
|
+
const sessionWorkspace = normalizeComparableWorkspace(args.sessionWorkspace);
|
|
16916
|
+
const adapterWorkspace = normalizeComparableWorkspace(args.adapter.workingDir);
|
|
16917
|
+
if (!sessionWorkspace || !adapterWorkspace || sessionWorkspace !== adapterWorkspace) return false;
|
|
16918
|
+
const intendedWorkspace = normalizeComparableWorkspace(args.intendedWorkspace);
|
|
16919
|
+
if (intendedWorkspace && intendedWorkspace !== sessionWorkspace) return false;
|
|
16920
|
+
const registryEntry = args.helpers.ctx?.sessionRegistry?.get?.(targetSessionId);
|
|
16921
|
+
const registryInstanceKey = typeof registryEntry?.adapterKey === "string" && registryEntry.adapterKey.trim() ? registryEntry.adapterKey.trim() : typeof registryEntry?.instanceKey === "string" && registryEntry.instanceKey.trim() ? registryEntry.instanceKey.trim() : "";
|
|
16922
|
+
if (registryInstanceKey) {
|
|
16923
|
+
const targetInstance = args.helpers.ctx?.instanceManager?.getInstance?.(registryInstanceKey);
|
|
16924
|
+
if (targetInstance) {
|
|
16925
|
+
const instanceType = typeof targetInstance.type === "string" ? targetInstance.type : "";
|
|
16926
|
+
if (instanceType && instanceType !== args.adapter.cliType) return false;
|
|
16927
|
+
}
|
|
16928
|
+
}
|
|
16929
|
+
return true;
|
|
16930
|
+
}
|
|
16898
16931
|
function supportsCliNativeTranscript(providerType, provider) {
|
|
16899
16932
|
if (CLI_NATIVE_TRANSCRIPT_PROVIDERS.has(providerType)) return true;
|
|
16900
16933
|
return provider?.category === "cli" && isNativeSourceCanonicalHistory(provider?.canonicalHistory);
|
|
@@ -17512,7 +17545,7 @@ function getCliVisibleTranscriptCount(adapter) {
|
|
|
17512
17545
|
async function getStableExtensionBaseline(h) {
|
|
17513
17546
|
const first = await readExtensionChatState(h);
|
|
17514
17547
|
if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
|
|
17515
|
-
await new Promise((
|
|
17548
|
+
await new Promise((resolve18) => setTimeout(resolve18, 150));
|
|
17516
17549
|
const second = await readExtensionChatState(h);
|
|
17517
17550
|
return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
|
|
17518
17551
|
}
|
|
@@ -17520,7 +17553,7 @@ async function verifyExtensionSendObserved(h, before) {
|
|
|
17520
17553
|
const beforeCount = getStateMessageCount(before);
|
|
17521
17554
|
const beforeSignature = getStateLastSignature(before);
|
|
17522
17555
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
17523
|
-
await new Promise((
|
|
17556
|
+
await new Promise((resolve18) => setTimeout(resolve18, 250));
|
|
17524
17557
|
const state = await readExtensionChatState(h);
|
|
17525
17558
|
if (state?.status === "waiting_approval") return true;
|
|
17526
17559
|
const afterCount = getStateMessageCount(state);
|
|
@@ -17743,8 +17776,16 @@ async function handleReadChat(h, args) {
|
|
|
17743
17776
|
freshEnough
|
|
17744
17777
|
});
|
|
17745
17778
|
const unsafeNativeFallback = adapter.cliType === "codex-cli" && isUnsafeNativeTranscriptFallback(fallbackReason);
|
|
17746
|
-
const
|
|
17747
|
-
|
|
17779
|
+
const safeCurrentRuntimePtyMessages = unsafeNativeFallback && isCurrentRuntimePtySafelyAttributed({
|
|
17780
|
+
adapter,
|
|
17781
|
+
helpers: h,
|
|
17782
|
+
readChatArgs: args,
|
|
17783
|
+
sessionWorkspace,
|
|
17784
|
+
intendedWorkspace,
|
|
17785
|
+
ptyMessages: returnedMessages
|
|
17786
|
+
});
|
|
17787
|
+
const safeRuntimeAckMessages = unsafeNativeFallback && !safeCurrentRuntimePtyMessages ? selectRuntimeInputAckMessages(returnedMessages) : [];
|
|
17788
|
+
const exactRuntimeMirrorMessages = unsafeNativeFallback && !safeCurrentRuntimePtyMessages && safeRuntimeAckMessages.length === 0 ? readExactRuntimeMirrorMessages({
|
|
17748
17789
|
providerType,
|
|
17749
17790
|
targetSessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId : void 0,
|
|
17750
17791
|
currentSessionId: typeof h.currentSession?.sessionId === "string" ? h.currentSession.sessionId : void 0,
|
|
@@ -17753,10 +17794,17 @@ async function handleReadChat(h, args) {
|
|
|
17753
17794
|
}) : [];
|
|
17754
17795
|
const safeDaemonMessages = safeRuntimeAckMessages.length > 0 ? safeRuntimeAckMessages : exactRuntimeMirrorMessages;
|
|
17755
17796
|
if (unsafeNativeFallback) {
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
|
|
17797
|
+
if (safeCurrentRuntimePtyMessages) {
|
|
17798
|
+
selectedMessages = returnedMessages;
|
|
17799
|
+
selectedTranscriptAuthority = "daemon";
|
|
17800
|
+
selectedCoverage = coverage || "current-turn";
|
|
17801
|
+
selectedStatus = returnedStatus;
|
|
17802
|
+
} else {
|
|
17803
|
+
selectedMessages = safeDaemonMessages;
|
|
17804
|
+
selectedTranscriptAuthority = safeDaemonMessages.length > 0 ? "daemon" : void 0;
|
|
17805
|
+
selectedCoverage = safeDaemonMessages.length > 0 ? "tail" : void 0;
|
|
17806
|
+
selectedStatus = coerceUnsafeNativeFallbackStatus(returnedStatus, activeModal);
|
|
17807
|
+
}
|
|
17760
17808
|
}
|
|
17761
17809
|
messageSource = buildCliMessageSourceProvenance({
|
|
17762
17810
|
selected: "pty-parser",
|
|
@@ -17774,11 +17822,16 @@ async function handleReadChat(h, args) {
|
|
|
17774
17822
|
unavailableReason,
|
|
17775
17823
|
nativeMessages,
|
|
17776
17824
|
ptyMessages: returnedMessages,
|
|
17777
|
-
returnedMessages: unsafeNativeFallback ? safeDaemonMessages : returnedMessages,
|
|
17825
|
+
returnedMessages: unsafeNativeFallback && !safeCurrentRuntimePtyMessages ? safeDaemonMessages : returnedMessages,
|
|
17778
17826
|
safeMapping,
|
|
17779
17827
|
freshEnough,
|
|
17780
|
-
ptyStatusApprovalOnly: unsafeNativeFallback
|
|
17828
|
+
ptyStatusApprovalOnly: unsafeNativeFallback && !safeCurrentRuntimePtyMessages
|
|
17781
17829
|
});
|
|
17830
|
+
if (safeCurrentRuntimePtyMessages) {
|
|
17831
|
+
messageSource.selectedDaemonSource = "current-runtime-pty";
|
|
17832
|
+
messageSource.transcriptAuthority = "daemon";
|
|
17833
|
+
messageSource.runtimeMappingSafe = true;
|
|
17834
|
+
}
|
|
17782
17835
|
if (unsafeNativeFallback && exactRuntimeMirrorMessages.length > 0) {
|
|
17783
17836
|
messageSource.selectedDaemonSource = "exact-runtime-mirror";
|
|
17784
17837
|
messageSource.transcriptAuthority = "daemon";
|
|
@@ -19461,7 +19514,7 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
19461
19514
|
const enterCount = cliCommand.enterCount || 1;
|
|
19462
19515
|
await adapter.writeRaw(cliCommand.text + "\r");
|
|
19463
19516
|
for (let i = 1; i < enterCount; i += 1) {
|
|
19464
|
-
await new Promise((
|
|
19517
|
+
await new Promise((resolve18) => setTimeout(resolve18, 50));
|
|
19465
19518
|
await adapter.writeRaw("\r");
|
|
19466
19519
|
}
|
|
19467
19520
|
}
|
|
@@ -20150,7 +20203,7 @@ var DaemonCommandHandler = class {
|
|
|
20150
20203
|
try {
|
|
20151
20204
|
const http3 = await import("http");
|
|
20152
20205
|
const postData = JSON.stringify(body);
|
|
20153
|
-
const result = await new Promise((
|
|
20206
|
+
const result = await new Promise((resolve18, reject) => {
|
|
20154
20207
|
const req = http3.request({
|
|
20155
20208
|
hostname: "127.0.0.1",
|
|
20156
20209
|
port: 19280,
|
|
@@ -20162,9 +20215,9 @@ var DaemonCommandHandler = class {
|
|
|
20162
20215
|
res.on("data", (chunk) => data += chunk);
|
|
20163
20216
|
res.on("end", () => {
|
|
20164
20217
|
try {
|
|
20165
|
-
|
|
20218
|
+
resolve18(JSON.parse(data));
|
|
20166
20219
|
} catch {
|
|
20167
|
-
|
|
20220
|
+
resolve18({ raw: data });
|
|
20168
20221
|
}
|
|
20169
20222
|
});
|
|
20170
20223
|
});
|
|
@@ -20182,15 +20235,15 @@ var DaemonCommandHandler = class {
|
|
|
20182
20235
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
20183
20236
|
try {
|
|
20184
20237
|
const http3 = await import("http");
|
|
20185
|
-
const result = await new Promise((
|
|
20238
|
+
const result = await new Promise((resolve18, reject) => {
|
|
20186
20239
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
20187
20240
|
let data = "";
|
|
20188
20241
|
res.on("data", (chunk) => data += chunk);
|
|
20189
20242
|
res.on("end", () => {
|
|
20190
20243
|
try {
|
|
20191
|
-
|
|
20244
|
+
resolve18(JSON.parse(data));
|
|
20192
20245
|
} catch {
|
|
20193
|
-
|
|
20246
|
+
resolve18({ raw: data });
|
|
20194
20247
|
}
|
|
20195
20248
|
});
|
|
20196
20249
|
}).on("error", reject);
|
|
@@ -20204,7 +20257,7 @@ var DaemonCommandHandler = class {
|
|
|
20204
20257
|
try {
|
|
20205
20258
|
const http3 = await import("http");
|
|
20206
20259
|
const postData = JSON.stringify(args || {});
|
|
20207
|
-
const result = await new Promise((
|
|
20260
|
+
const result = await new Promise((resolve18, reject) => {
|
|
20208
20261
|
const req = http3.request({
|
|
20209
20262
|
hostname: "127.0.0.1",
|
|
20210
20263
|
port: 19280,
|
|
@@ -20216,9 +20269,9 @@ var DaemonCommandHandler = class {
|
|
|
20216
20269
|
res.on("data", (chunk) => data += chunk);
|
|
20217
20270
|
res.on("end", () => {
|
|
20218
20271
|
try {
|
|
20219
|
-
|
|
20272
|
+
resolve18(JSON.parse(data));
|
|
20220
20273
|
} catch {
|
|
20221
|
-
|
|
20274
|
+
resolve18({ raw: data });
|
|
20222
20275
|
}
|
|
20223
20276
|
});
|
|
20224
20277
|
});
|
|
@@ -20462,7 +20515,7 @@ async function waitForCliAdapterReady(adapter, options) {
|
|
|
20462
20515
|
if (status === "stopped") {
|
|
20463
20516
|
throw new Error("CLI runtime stopped before it became ready");
|
|
20464
20517
|
}
|
|
20465
|
-
await new Promise((
|
|
20518
|
+
await new Promise((resolve18) => setTimeout(resolve18, pollMs));
|
|
20466
20519
|
}
|
|
20467
20520
|
throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
|
|
20468
20521
|
}
|
|
@@ -20860,7 +20913,7 @@ var CliProviderInstance = class {
|
|
|
20860
20913
|
const enterCount = cliCommand.enterCount || 1;
|
|
20861
20914
|
await this.adapter.writeRaw(cliCommand.text + "\r");
|
|
20862
20915
|
for (let i = 1; i < enterCount; i += 1) {
|
|
20863
|
-
await new Promise((
|
|
20916
|
+
await new Promise((resolve18) => setTimeout(resolve18, 50));
|
|
20864
20917
|
await this.adapter.writeRaw("\r");
|
|
20865
20918
|
}
|
|
20866
20919
|
}
|
|
@@ -22302,13 +22355,13 @@ var AcpProviderInstance = class {
|
|
|
22302
22355
|
}
|
|
22303
22356
|
this.currentStatus = "waiting_approval";
|
|
22304
22357
|
this.detectStatusTransition();
|
|
22305
|
-
const approved = await new Promise((
|
|
22306
|
-
this.permissionResolvers.push(
|
|
22358
|
+
const approved = await new Promise((resolve18) => {
|
|
22359
|
+
this.permissionResolvers.push(resolve18);
|
|
22307
22360
|
setTimeout(() => {
|
|
22308
|
-
const idx = this.permissionResolvers.indexOf(
|
|
22361
|
+
const idx = this.permissionResolvers.indexOf(resolve18);
|
|
22309
22362
|
if (idx >= 0) {
|
|
22310
22363
|
this.permissionResolvers.splice(idx, 1);
|
|
22311
|
-
|
|
22364
|
+
resolve18(false);
|
|
22312
22365
|
}
|
|
22313
22366
|
}, 3e5);
|
|
22314
22367
|
});
|
|
@@ -23017,7 +23070,7 @@ async function waitForZeroMessageStartingLaunch(adapter) {
|
|
|
23017
23070
|
} catch {
|
|
23018
23071
|
return false;
|
|
23019
23072
|
}
|
|
23020
|
-
await new Promise((
|
|
23073
|
+
await new Promise((resolve18) => setTimeout(resolve18, ZERO_MESSAGE_STARTING_SEND_WAIT_MS));
|
|
23021
23074
|
try {
|
|
23022
23075
|
return hasZeroMessageStartingLaunch(adapter);
|
|
23023
23076
|
} catch {
|
|
@@ -25117,7 +25170,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25117
25170
|
return { updated: false };
|
|
25118
25171
|
}
|
|
25119
25172
|
try {
|
|
25120
|
-
const etag = await new Promise((
|
|
25173
|
+
const etag = await new Promise((resolve18, reject) => {
|
|
25121
25174
|
const options = {
|
|
25122
25175
|
method: "HEAD",
|
|
25123
25176
|
hostname: "github.com",
|
|
@@ -25135,7 +25188,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25135
25188
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
25136
25189
|
timeout: 1e4
|
|
25137
25190
|
}, (res2) => {
|
|
25138
|
-
|
|
25191
|
+
resolve18(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
25139
25192
|
});
|
|
25140
25193
|
req2.on("error", reject);
|
|
25141
25194
|
req2.on("timeout", () => {
|
|
@@ -25144,7 +25197,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25144
25197
|
});
|
|
25145
25198
|
req2.end();
|
|
25146
25199
|
} else {
|
|
25147
|
-
|
|
25200
|
+
resolve18(res.headers.etag || res.headers["last-modified"] || "");
|
|
25148
25201
|
}
|
|
25149
25202
|
});
|
|
25150
25203
|
req.on("error", reject);
|
|
@@ -25208,7 +25261,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25208
25261
|
downloadFile(url, destPath) {
|
|
25209
25262
|
const https = __require("https");
|
|
25210
25263
|
const http3 = __require("http");
|
|
25211
|
-
return new Promise((
|
|
25264
|
+
return new Promise((resolve18, reject) => {
|
|
25212
25265
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
25213
25266
|
if (redirectCount > 5) {
|
|
25214
25267
|
reject(new Error("Too many redirects"));
|
|
@@ -25228,7 +25281,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
25228
25281
|
res.pipe(ws);
|
|
25229
25282
|
ws.on("finish", () => {
|
|
25230
25283
|
ws.close();
|
|
25231
|
-
|
|
25284
|
+
resolve18();
|
|
25232
25285
|
});
|
|
25233
25286
|
ws.on("error", reject);
|
|
25234
25287
|
});
|
|
@@ -25731,10 +25784,10 @@ function findMacAppProcessPids(psOutput, appPaths) {
|
|
|
25731
25784
|
|
|
25732
25785
|
// src/launch.ts
|
|
25733
25786
|
async function execQuiet(command, options = {}) {
|
|
25734
|
-
return new Promise((
|
|
25787
|
+
return new Promise((resolve18) => {
|
|
25735
25788
|
exec4(command, options, (error, stdout) => {
|
|
25736
|
-
if (error) return
|
|
25737
|
-
|
|
25789
|
+
if (error) return resolve18("");
|
|
25790
|
+
resolve18(stdout.toString());
|
|
25738
25791
|
});
|
|
25739
25792
|
});
|
|
25740
25793
|
}
|
|
@@ -25815,17 +25868,17 @@ async function findFreePort(ports) {
|
|
|
25815
25868
|
throw new Error("No free port found");
|
|
25816
25869
|
}
|
|
25817
25870
|
function checkPortFree(port) {
|
|
25818
|
-
return new Promise((
|
|
25871
|
+
return new Promise((resolve18) => {
|
|
25819
25872
|
const server = net.createServer();
|
|
25820
25873
|
server.unref();
|
|
25821
|
-
server.on("error", () =>
|
|
25874
|
+
server.on("error", () => resolve18(false));
|
|
25822
25875
|
server.listen(port, "127.0.0.1", () => {
|
|
25823
|
-
server.close(() =>
|
|
25876
|
+
server.close(() => resolve18(true));
|
|
25824
25877
|
});
|
|
25825
25878
|
});
|
|
25826
25879
|
}
|
|
25827
25880
|
async function isCdpActive(port) {
|
|
25828
|
-
return new Promise((
|
|
25881
|
+
return new Promise((resolve18) => {
|
|
25829
25882
|
const req = __require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
25830
25883
|
timeout: 2e3
|
|
25831
25884
|
}, (res) => {
|
|
@@ -25834,16 +25887,16 @@ async function isCdpActive(port) {
|
|
|
25834
25887
|
res.on("end", () => {
|
|
25835
25888
|
try {
|
|
25836
25889
|
const info = JSON.parse(data);
|
|
25837
|
-
|
|
25890
|
+
resolve18(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
25838
25891
|
} catch {
|
|
25839
|
-
|
|
25892
|
+
resolve18(false);
|
|
25840
25893
|
}
|
|
25841
25894
|
});
|
|
25842
25895
|
});
|
|
25843
|
-
req.on("error", () =>
|
|
25896
|
+
req.on("error", () => resolve18(false));
|
|
25844
25897
|
req.on("timeout", () => {
|
|
25845
25898
|
req.destroy();
|
|
25846
|
-
|
|
25899
|
+
resolve18(false);
|
|
25847
25900
|
});
|
|
25848
25901
|
});
|
|
25849
25902
|
}
|
|
@@ -26323,7 +26376,7 @@ import * as yaml3 from "js-yaml";
|
|
|
26323
26376
|
// src/commands/mesh-coordinator.ts
|
|
26324
26377
|
import { createHash as createHash4 } from "crypto";
|
|
26325
26378
|
import * as os17 from "os";
|
|
26326
|
-
import { isAbsolute as isAbsolute11, join as join23, resolve as
|
|
26379
|
+
import { isAbsolute as isAbsolute11, join as join23, resolve as resolve14 } from "path";
|
|
26327
26380
|
var DEFAULT_SERVER_NAME = "adhdev-mesh";
|
|
26328
26381
|
var DEFAULT_ADHDEV_MCP_COMMAND = "adhdev";
|
|
26329
26382
|
var HERMES_CLI_TYPE = "hermes-cli";
|
|
@@ -26463,7 +26516,7 @@ function renderMeshCoordinatorTemplate(template, values) {
|
|
|
26463
26516
|
}
|
|
26464
26517
|
function resolveHermesCoordinatorHome(meshId, workspace) {
|
|
26465
26518
|
const key = `${meshId || "mesh"}
|
|
26466
|
-
${
|
|
26519
|
+
${resolve14(workspace || os17.tmpdir())}`;
|
|
26467
26520
|
const hash = createHash4("sha256").update(key).digest("hex").slice(0, 16);
|
|
26468
26521
|
return join23(os17.tmpdir(), `adhdev-hermes-mesh-coordinator-${hash}`);
|
|
26469
26522
|
}
|
|
@@ -26508,7 +26561,7 @@ init_mesh_host_ownership();
|
|
|
26508
26561
|
// src/mesh/preview-freshness.ts
|
|
26509
26562
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
26510
26563
|
import { existsSync as existsSync20, readFileSync as readFileSync13 } from "fs";
|
|
26511
|
-
import { resolve as
|
|
26564
|
+
import { resolve as resolve15 } from "path";
|
|
26512
26565
|
var PREVIEW_DEPLOY_RECORD = ".adhdev/preview-deploy.json";
|
|
26513
26566
|
function runGit2(repoRoot, args) {
|
|
26514
26567
|
try {
|
|
@@ -26523,7 +26576,7 @@ function runGit2(repoRoot, args) {
|
|
|
26523
26576
|
}
|
|
26524
26577
|
}
|
|
26525
26578
|
function readRecord3(repoRoot) {
|
|
26526
|
-
const path28 =
|
|
26579
|
+
const path28 = resolve15(repoRoot, PREVIEW_DEPLOY_RECORD);
|
|
26527
26580
|
if (!existsSync20(path28)) return null;
|
|
26528
26581
|
try {
|
|
26529
26582
|
const parsed = JSON.parse(readFileSync13(path28, "utf8"));
|
|
@@ -27093,7 +27146,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
27093
27146
|
while (Date.now() - start < timeoutMs) {
|
|
27094
27147
|
try {
|
|
27095
27148
|
process.kill(pid, 0);
|
|
27096
|
-
await new Promise((
|
|
27149
|
+
await new Promise((resolve18) => setTimeout(resolve18, 250));
|
|
27097
27150
|
} catch {
|
|
27098
27151
|
return;
|
|
27099
27152
|
}
|
|
@@ -27204,7 +27257,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
27204
27257
|
appendUpgradeLog(installOutput.trim());
|
|
27205
27258
|
}
|
|
27206
27259
|
if (process.platform === "win32") {
|
|
27207
|
-
await new Promise((
|
|
27260
|
+
await new Promise((resolve18) => setTimeout(resolve18, 500));
|
|
27208
27261
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
27209
27262
|
appendUpgradeLog("Post-install staging cleanup complete");
|
|
27210
27263
|
}
|
|
@@ -31402,7 +31455,7 @@ var DaemonCommandRouter = class {
|
|
|
31402
31455
|
const setupPromise = finishWorktreeSetup();
|
|
31403
31456
|
const setupResult = await Promise.race([
|
|
31404
31457
|
setupPromise.then((value) => ({ completed: true, value })),
|
|
31405
|
-
new Promise((
|
|
31458
|
+
new Promise((resolve18) => setTimeout(() => resolve18({ completed: false }), setupWaitMs))
|
|
31406
31459
|
]);
|
|
31407
31460
|
if (!setupResult.completed) {
|
|
31408
31461
|
setupPromise.catch((error) => {
|
|
@@ -32800,7 +32853,7 @@ var ProviderStreamAdapter = class {
|
|
|
32800
32853
|
const beforeCount = this.messageCount(before);
|
|
32801
32854
|
const beforeSignature = this.lastMessageSignature(before);
|
|
32802
32855
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
32803
|
-
await new Promise((
|
|
32856
|
+
await new Promise((resolve18) => setTimeout(resolve18, 250));
|
|
32804
32857
|
let state;
|
|
32805
32858
|
try {
|
|
32806
32859
|
state = await this.readChat(evaluate);
|
|
@@ -32822,7 +32875,7 @@ var ProviderStreamAdapter = class {
|
|
|
32822
32875
|
if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
|
|
32823
32876
|
return first;
|
|
32824
32877
|
}
|
|
32825
|
-
await new Promise((
|
|
32878
|
+
await new Promise((resolve18) => setTimeout(resolve18, 150));
|
|
32826
32879
|
const second = await this.readChat(evaluate);
|
|
32827
32880
|
return this.messageCount(second) >= this.messageCount(first) ? second : first;
|
|
32828
32881
|
}
|
|
@@ -32973,7 +33026,7 @@ var ProviderStreamAdapter = class {
|
|
|
32973
33026
|
if (typeof data.error === "string" && data.error.trim()) return false;
|
|
32974
33027
|
}
|
|
32975
33028
|
for (let attempt = 0; attempt < 6; attempt += 1) {
|
|
32976
|
-
await new Promise((
|
|
33029
|
+
await new Promise((resolve18) => setTimeout(resolve18, 250));
|
|
32977
33030
|
const state = await this.readChat(evaluate);
|
|
32978
33031
|
const title = this.getStateTitle(state);
|
|
32979
33032
|
if (this.titlesMatch(title, sessionId)) return true;
|
|
@@ -33901,13 +33954,13 @@ var VersionArchive = class {
|
|
|
33901
33954
|
}
|
|
33902
33955
|
};
|
|
33903
33956
|
async function runCommand(cmd, timeout = 1e4) {
|
|
33904
|
-
return new Promise((
|
|
33957
|
+
return new Promise((resolve18) => {
|
|
33905
33958
|
exec5(cmd, {
|
|
33906
33959
|
encoding: "utf-8",
|
|
33907
33960
|
timeout
|
|
33908
33961
|
}, (error, stdout) => {
|
|
33909
|
-
if (error) return
|
|
33910
|
-
|
|
33962
|
+
if (error) return resolve18(null);
|
|
33963
|
+
resolve18(stdout.trim());
|
|
33911
33964
|
});
|
|
33912
33965
|
});
|
|
33913
33966
|
}
|
|
@@ -35596,7 +35649,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
|
|
|
35596
35649
|
return { target, instance, adapter };
|
|
35597
35650
|
}
|
|
35598
35651
|
function sleep2(ms) {
|
|
35599
|
-
return new Promise((
|
|
35652
|
+
return new Promise((resolve18) => setTimeout(resolve18, ms));
|
|
35600
35653
|
}
|
|
35601
35654
|
async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
|
|
35602
35655
|
const startedAt = Date.now();
|
|
@@ -37851,15 +37904,15 @@ var DevServer = class _DevServer {
|
|
|
37851
37904
|
this.json(res, 500, { error: e.message });
|
|
37852
37905
|
}
|
|
37853
37906
|
});
|
|
37854
|
-
return new Promise((
|
|
37907
|
+
return new Promise((resolve18, reject) => {
|
|
37855
37908
|
this.server.listen(port, "127.0.0.1", () => {
|
|
37856
37909
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
37857
|
-
|
|
37910
|
+
resolve18();
|
|
37858
37911
|
});
|
|
37859
37912
|
this.server.on("error", (e) => {
|
|
37860
37913
|
if (e.code === "EADDRINUSE") {
|
|
37861
37914
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
37862
|
-
|
|
37915
|
+
resolve18();
|
|
37863
37916
|
} else {
|
|
37864
37917
|
reject(e);
|
|
37865
37918
|
}
|
|
@@ -37941,20 +37994,20 @@ var DevServer = class _DevServer {
|
|
|
37941
37994
|
child.stderr?.on("data", (d) => {
|
|
37942
37995
|
stderr += d.toString().slice(0, 2e3);
|
|
37943
37996
|
});
|
|
37944
|
-
await new Promise((
|
|
37997
|
+
await new Promise((resolve18) => {
|
|
37945
37998
|
const timer = setTimeout(() => {
|
|
37946
37999
|
child.kill();
|
|
37947
|
-
|
|
38000
|
+
resolve18();
|
|
37948
38001
|
}, 3e3);
|
|
37949
38002
|
child.on("exit", () => {
|
|
37950
38003
|
clearTimeout(timer);
|
|
37951
|
-
|
|
38004
|
+
resolve18();
|
|
37952
38005
|
});
|
|
37953
38006
|
child.stdout?.once("data", () => {
|
|
37954
38007
|
setTimeout(() => {
|
|
37955
38008
|
child.kill();
|
|
37956
38009
|
clearTimeout(timer);
|
|
37957
|
-
|
|
38010
|
+
resolve18();
|
|
37958
38011
|
}, 500);
|
|
37959
38012
|
});
|
|
37960
38013
|
});
|
|
@@ -38457,14 +38510,14 @@ var DevServer = class _DevServer {
|
|
|
38457
38510
|
child.stderr?.on("data", (d) => {
|
|
38458
38511
|
stderr += d.toString();
|
|
38459
38512
|
});
|
|
38460
|
-
await new Promise((
|
|
38513
|
+
await new Promise((resolve18) => {
|
|
38461
38514
|
const timer = setTimeout(() => {
|
|
38462
38515
|
child.kill();
|
|
38463
|
-
|
|
38516
|
+
resolve18();
|
|
38464
38517
|
}, timeout);
|
|
38465
38518
|
child.on("exit", () => {
|
|
38466
38519
|
clearTimeout(timer);
|
|
38467
|
-
|
|
38520
|
+
resolve18();
|
|
38468
38521
|
});
|
|
38469
38522
|
});
|
|
38470
38523
|
const elapsed = Date.now() - start;
|
|
@@ -39134,14 +39187,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
39134
39187
|
res.end(JSON.stringify(data, null, 2));
|
|
39135
39188
|
}
|
|
39136
39189
|
async readBody(req) {
|
|
39137
|
-
return new Promise((
|
|
39190
|
+
return new Promise((resolve18) => {
|
|
39138
39191
|
let body = "";
|
|
39139
39192
|
req.on("data", (chunk) => body += chunk);
|
|
39140
39193
|
req.on("end", () => {
|
|
39141
39194
|
try {
|
|
39142
|
-
|
|
39195
|
+
resolve18(JSON.parse(body));
|
|
39143
39196
|
} catch {
|
|
39144
|
-
|
|
39197
|
+
resolve18({});
|
|
39145
39198
|
}
|
|
39146
39199
|
});
|
|
39147
39200
|
});
|
|
@@ -39684,7 +39737,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS, requiredRe
|
|
|
39684
39737
|
const deadline = Date.now() + timeoutMs;
|
|
39685
39738
|
while (Date.now() < deadline) {
|
|
39686
39739
|
if (await canConnect(endpoint, requiredRequestTypes)) return;
|
|
39687
|
-
await new Promise((
|
|
39740
|
+
await new Promise((resolve18) => setTimeout(resolve18, STARTUP_POLL_MS));
|
|
39688
39741
|
}
|
|
39689
39742
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
39690
39743
|
}
|
|
@@ -39864,10 +39917,10 @@ async function installExtension(ide, extension) {
|
|
|
39864
39917
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
39865
39918
|
const fs17 = await import("fs");
|
|
39866
39919
|
fs17.writeFileSync(vsixPath, buffer);
|
|
39867
|
-
return new Promise((
|
|
39920
|
+
return new Promise((resolve18) => {
|
|
39868
39921
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
39869
39922
|
exec6(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
|
|
39870
|
-
|
|
39923
|
+
resolve18({
|
|
39871
39924
|
extensionId: extension.id,
|
|
39872
39925
|
marketplaceId: extension.marketplaceId,
|
|
39873
39926
|
success: !error,
|
|
@@ -39880,11 +39933,11 @@ async function installExtension(ide, extension) {
|
|
|
39880
39933
|
} catch (e) {
|
|
39881
39934
|
}
|
|
39882
39935
|
}
|
|
39883
|
-
return new Promise((
|
|
39936
|
+
return new Promise((resolve18) => {
|
|
39884
39937
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
39885
39938
|
exec6(cmd, { timeout: 6e4 }, (error, stdout, stderr) => {
|
|
39886
39939
|
if (error) {
|
|
39887
|
-
|
|
39940
|
+
resolve18({
|
|
39888
39941
|
extensionId: extension.id,
|
|
39889
39942
|
marketplaceId: extension.marketplaceId,
|
|
39890
39943
|
success: false,
|
|
@@ -39892,7 +39945,7 @@ async function installExtension(ide, extension) {
|
|
|
39892
39945
|
error: stderr || error.message
|
|
39893
39946
|
});
|
|
39894
39947
|
} else {
|
|
39895
|
-
|
|
39948
|
+
resolve18({
|
|
39896
39949
|
extensionId: extension.id,
|
|
39897
39950
|
marketplaceId: extension.marketplaceId,
|
|
39898
39951
|
success: true,
|