adhdev 0.7.35 → 0.7.37
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/index.js +1146 -754
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +1100 -710
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -164,8 +164,17 @@ function findWorkspaceByPath(config2, rawPath) {
|
|
|
164
164
|
if (!abs) return void 0;
|
|
165
165
|
return (config2.workspaces || []).find((w) => path.resolve(expandPath(w.path)) === abs);
|
|
166
166
|
}
|
|
167
|
-
function addWorkspaceEntry(config2, rawPath, label) {
|
|
167
|
+
function addWorkspaceEntry(config2, rawPath, label, options) {
|
|
168
168
|
const abs = expandPath(rawPath);
|
|
169
|
+
const createIfMissing = options?.createIfMissing === true;
|
|
170
|
+
if (!abs) return { error: "Path required" };
|
|
171
|
+
if (!fs.existsSync(abs) && createIfMissing) {
|
|
172
|
+
try {
|
|
173
|
+
fs.mkdirSync(abs, { recursive: true });
|
|
174
|
+
} catch (e) {
|
|
175
|
+
return { error: e?.message || "Could not create directory" };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
169
178
|
const v2 = validateWorkspacePath(abs);
|
|
170
179
|
if (!v2.ok) return { error: v2.error };
|
|
171
180
|
const list = [...config2.workspaces || []];
|
|
@@ -395,6 +404,8 @@ var init_config = __esm({
|
|
|
395
404
|
workspaces: [],
|
|
396
405
|
defaultWorkspaceId: null,
|
|
397
406
|
recentWorkspaceActivity: [],
|
|
407
|
+
recentActivity: [],
|
|
408
|
+
recentSessionReads: {},
|
|
398
409
|
machineNickname: null,
|
|
399
410
|
machineId: void 0,
|
|
400
411
|
machineSecret: null,
|
|
@@ -454,6 +465,58 @@ var init_workspace_activity = __esm({
|
|
|
454
465
|
}
|
|
455
466
|
});
|
|
456
467
|
|
|
468
|
+
// ../../oss/packages/daemon-core/src/config/recent-activity.ts
|
|
469
|
+
function normalizeWorkspace(workspace) {
|
|
470
|
+
if (!workspace) return "";
|
|
471
|
+
try {
|
|
472
|
+
return path3.resolve(expandPath(workspace));
|
|
473
|
+
} catch {
|
|
474
|
+
return path3.resolve(workspace);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function buildRecentActivityKey(entry) {
|
|
478
|
+
return `${entry.kind}:${entry.providerType}:${normalizeWorkspace(entry.workspace)}`;
|
|
479
|
+
}
|
|
480
|
+
function appendRecentActivity(config2, entry) {
|
|
481
|
+
const nextEntry = {
|
|
482
|
+
...entry,
|
|
483
|
+
workspace: entry.workspace ? normalizeWorkspace(entry.workspace) : void 0,
|
|
484
|
+
id: buildRecentActivityKey(entry),
|
|
485
|
+
lastUsedAt: entry.lastUsedAt || Date.now()
|
|
486
|
+
};
|
|
487
|
+
const filtered = (config2.recentActivity || []).filter((item) => item.id !== nextEntry.id);
|
|
488
|
+
return {
|
|
489
|
+
...config2,
|
|
490
|
+
recentActivity: [nextEntry, ...filtered].slice(0, MAX_ACTIVITY2)
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
function getRecentActivity(config2, limit = 20) {
|
|
494
|
+
return [...config2.recentActivity || []].sort((a, b2) => b2.lastUsedAt - a.lastUsedAt).slice(0, limit);
|
|
495
|
+
}
|
|
496
|
+
function getRecentSessionSeenAt(config2, recentKey) {
|
|
497
|
+
return config2.recentSessionReads?.[recentKey] || 0;
|
|
498
|
+
}
|
|
499
|
+
function markRecentSessionSeen(config2, recentKey, seenAt = Date.now()) {
|
|
500
|
+
const prev = config2.recentSessionReads || {};
|
|
501
|
+
const nextSeenAt = Math.max(prev[recentKey] || 0, seenAt);
|
|
502
|
+
return {
|
|
503
|
+
...config2,
|
|
504
|
+
recentSessionReads: {
|
|
505
|
+
...prev,
|
|
506
|
+
[recentKey]: nextSeenAt
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
var path3, MAX_ACTIVITY2;
|
|
511
|
+
var init_recent_activity = __esm({
|
|
512
|
+
"../../oss/packages/daemon-core/src/config/recent-activity.ts"() {
|
|
513
|
+
"use strict";
|
|
514
|
+
path3 = __toESM(require("path"));
|
|
515
|
+
init_workspaces();
|
|
516
|
+
MAX_ACTIVITY2 = 30;
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
|
|
457
520
|
// ../../oss/packages/daemon-core/src/detection/ide-detector.ts
|
|
458
521
|
function registerIDEDefinition(def) {
|
|
459
522
|
registeredIDEs.set(def.id, def);
|
|
@@ -565,15 +628,15 @@ function parseVersion(raw) {
|
|
|
565
628
|
return match ? match[1] : raw.split("\n")[0].slice(0, 100);
|
|
566
629
|
}
|
|
567
630
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
568
|
-
return new Promise((
|
|
631
|
+
return new Promise((resolve13) => {
|
|
569
632
|
const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
|
|
570
633
|
if (err || !stdout?.trim()) {
|
|
571
|
-
|
|
634
|
+
resolve13(null);
|
|
572
635
|
} else {
|
|
573
|
-
|
|
636
|
+
resolve13(stdout.trim());
|
|
574
637
|
}
|
|
575
638
|
});
|
|
576
|
-
child.on("error", () =>
|
|
639
|
+
child.on("error", () => resolve13(null));
|
|
577
640
|
});
|
|
578
641
|
}
|
|
579
642
|
async function detectCLIs(providerLoader) {
|
|
@@ -688,7 +751,7 @@ function checkDateRotation() {
|
|
|
688
751
|
const today = getDateStr();
|
|
689
752
|
if (today !== currentDate) {
|
|
690
753
|
currentDate = today;
|
|
691
|
-
currentLogFile =
|
|
754
|
+
currentLogFile = path4.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
692
755
|
cleanOldLogs();
|
|
693
756
|
}
|
|
694
757
|
}
|
|
@@ -702,7 +765,7 @@ function cleanOldLogs() {
|
|
|
702
765
|
const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
|
|
703
766
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
704
767
|
try {
|
|
705
|
-
fs2.unlinkSync(
|
|
768
|
+
fs2.unlinkSync(path4.join(LOG_DIR, file2));
|
|
706
769
|
} catch {
|
|
707
770
|
}
|
|
708
771
|
}
|
|
@@ -819,17 +882,17 @@ function installGlobalInterceptor() {
|
|
|
819
882
|
writeToFile(`Log file: ${currentLogFile}`);
|
|
820
883
|
writeToFile(`Log level: ${currentLevel}`);
|
|
821
884
|
}
|
|
822
|
-
var fs2,
|
|
885
|
+
var fs2, path4, os4, LEVEL_NUM, LEVEL_LABEL, currentLevel, LOG_DIR, MAX_LOG_SIZE, MAX_LOG_DAYS, currentDate, currentLogFile, writeCount, RING_BUFFER_SIZE, ringBuffer, origConsoleLog, origConsoleError, origConsoleWarn, LOG, interceptorInstalled, LOG_PATH;
|
|
823
886
|
var init_logger = __esm({
|
|
824
887
|
"../../oss/packages/daemon-core/src/logging/logger.ts"() {
|
|
825
888
|
"use strict";
|
|
826
889
|
fs2 = __toESM(require("fs"));
|
|
827
|
-
|
|
890
|
+
path4 = __toESM(require("path"));
|
|
828
891
|
os4 = __toESM(require("os"));
|
|
829
892
|
LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
830
893
|
LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
|
|
831
894
|
currentLevel = "info";
|
|
832
|
-
LOG_DIR = process.platform === "win32" ?
|
|
895
|
+
LOG_DIR = process.platform === "win32" ? path4.join(process.env.LOCALAPPDATA || process.env.APPDATA || path4.join(os4.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path4.join(os4.homedir(), "Library", "Logs", "adhdev") : path4.join(os4.homedir(), ".local", "share", "adhdev", "logs");
|
|
833
896
|
MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
834
897
|
MAX_LOG_DAYS = 7;
|
|
835
898
|
try {
|
|
@@ -837,16 +900,16 @@ var init_logger = __esm({
|
|
|
837
900
|
} catch {
|
|
838
901
|
}
|
|
839
902
|
currentDate = getDateStr();
|
|
840
|
-
currentLogFile =
|
|
903
|
+
currentLogFile = path4.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
841
904
|
cleanOldLogs();
|
|
842
905
|
try {
|
|
843
|
-
const oldLog =
|
|
906
|
+
const oldLog = path4.join(LOG_DIR, "daemon.log");
|
|
844
907
|
if (fs2.existsSync(oldLog)) {
|
|
845
908
|
const stat4 = fs2.statSync(oldLog);
|
|
846
909
|
const oldDate = stat4.mtime.toISOString().slice(0, 10);
|
|
847
|
-
fs2.renameSync(oldLog,
|
|
910
|
+
fs2.renameSync(oldLog, path4.join(LOG_DIR, `daemon-${oldDate}.log`));
|
|
848
911
|
}
|
|
849
|
-
const oldLogBackup =
|
|
912
|
+
const oldLogBackup = path4.join(LOG_DIR, "daemon.log.old");
|
|
850
913
|
if (fs2.existsSync(oldLogBackup)) {
|
|
851
914
|
fs2.unlinkSync(oldLogBackup);
|
|
852
915
|
}
|
|
@@ -878,7 +941,7 @@ var init_logger = __esm({
|
|
|
878
941
|
}
|
|
879
942
|
};
|
|
880
943
|
interceptorInstalled = false;
|
|
881
|
-
LOG_PATH =
|
|
944
|
+
LOG_PATH = path4.join(LOG_DIR, `daemon-${getDateStr()}.log`);
|
|
882
945
|
}
|
|
883
946
|
});
|
|
884
947
|
|
|
@@ -967,7 +1030,7 @@ var init_manager = __esm({
|
|
|
967
1030
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
968
1031
|
*/
|
|
969
1032
|
static listAllTargets(port) {
|
|
970
|
-
return new Promise((
|
|
1033
|
+
return new Promise((resolve13) => {
|
|
971
1034
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
972
1035
|
let data = "";
|
|
973
1036
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -983,16 +1046,16 @@ var init_manager = __esm({
|
|
|
983
1046
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
984
1047
|
);
|
|
985
1048
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
986
|
-
|
|
1049
|
+
resolve13(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
987
1050
|
} catch {
|
|
988
|
-
|
|
1051
|
+
resolve13([]);
|
|
989
1052
|
}
|
|
990
1053
|
});
|
|
991
1054
|
});
|
|
992
|
-
req.on("error", () =>
|
|
1055
|
+
req.on("error", () => resolve13([]));
|
|
993
1056
|
req.setTimeout(2e3, () => {
|
|
994
1057
|
req.destroy();
|
|
995
|
-
|
|
1058
|
+
resolve13([]);
|
|
996
1059
|
});
|
|
997
1060
|
});
|
|
998
1061
|
}
|
|
@@ -1032,7 +1095,7 @@ var init_manager = __esm({
|
|
|
1032
1095
|
}
|
|
1033
1096
|
}
|
|
1034
1097
|
findTargetOnPort(port) {
|
|
1035
|
-
return new Promise((
|
|
1098
|
+
return new Promise((resolve13) => {
|
|
1036
1099
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
1037
1100
|
let data = "";
|
|
1038
1101
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -1043,7 +1106,7 @@ var init_manager = __esm({
|
|
|
1043
1106
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
1044
1107
|
);
|
|
1045
1108
|
if (pages.length === 0) {
|
|
1046
|
-
|
|
1109
|
+
resolve13(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
1047
1110
|
return;
|
|
1048
1111
|
}
|
|
1049
1112
|
const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -1053,24 +1116,24 @@ var init_manager = __esm({
|
|
|
1053
1116
|
const specific = list.find((t) => t.id === this._targetId);
|
|
1054
1117
|
if (specific) {
|
|
1055
1118
|
this._pageTitle = specific.title || "";
|
|
1056
|
-
|
|
1119
|
+
resolve13(specific);
|
|
1057
1120
|
} else {
|
|
1058
1121
|
this.log(`[CDP] Target ${this._targetId} not found in page list`);
|
|
1059
|
-
|
|
1122
|
+
resolve13(null);
|
|
1060
1123
|
}
|
|
1061
1124
|
return;
|
|
1062
1125
|
}
|
|
1063
1126
|
this._pageTitle = list[0]?.title || "";
|
|
1064
|
-
|
|
1127
|
+
resolve13(list[0]);
|
|
1065
1128
|
} catch {
|
|
1066
|
-
|
|
1129
|
+
resolve13(null);
|
|
1067
1130
|
}
|
|
1068
1131
|
});
|
|
1069
1132
|
});
|
|
1070
|
-
req.on("error", () =>
|
|
1133
|
+
req.on("error", () => resolve13(null));
|
|
1071
1134
|
req.setTimeout(2e3, () => {
|
|
1072
1135
|
req.destroy();
|
|
1073
|
-
|
|
1136
|
+
resolve13(null);
|
|
1074
1137
|
});
|
|
1075
1138
|
});
|
|
1076
1139
|
}
|
|
@@ -1081,7 +1144,7 @@ var init_manager = __esm({
|
|
|
1081
1144
|
this.extensionProviders = providers;
|
|
1082
1145
|
}
|
|
1083
1146
|
connectToTarget(wsUrl) {
|
|
1084
|
-
return new Promise((
|
|
1147
|
+
return new Promise((resolve13) => {
|
|
1085
1148
|
this.ws = new import_ws.default(wsUrl);
|
|
1086
1149
|
this.ws.on("open", async () => {
|
|
1087
1150
|
this._connected = true;
|
|
@@ -1091,17 +1154,17 @@ var init_manager = __esm({
|
|
|
1091
1154
|
}
|
|
1092
1155
|
this.connectBrowserWs().catch(() => {
|
|
1093
1156
|
});
|
|
1094
|
-
|
|
1157
|
+
resolve13(true);
|
|
1095
1158
|
});
|
|
1096
1159
|
this.ws.on("message", (data) => {
|
|
1097
1160
|
try {
|
|
1098
1161
|
const msg = JSON.parse(data.toString());
|
|
1099
1162
|
if (msg.id && this.pending.has(msg.id)) {
|
|
1100
|
-
const { resolve:
|
|
1163
|
+
const { resolve: resolve14, reject } = this.pending.get(msg.id);
|
|
1101
1164
|
this.pending.delete(msg.id);
|
|
1102
1165
|
this.failureCount = 0;
|
|
1103
1166
|
if (msg.error) reject(new Error(msg.error.message));
|
|
1104
|
-
else
|
|
1167
|
+
else resolve14(msg.result);
|
|
1105
1168
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
1106
1169
|
this.contexts.add(msg.params.context.id);
|
|
1107
1170
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -1124,7 +1187,7 @@ var init_manager = __esm({
|
|
|
1124
1187
|
this.ws.on("error", (err) => {
|
|
1125
1188
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
1126
1189
|
this._connected = false;
|
|
1127
|
-
|
|
1190
|
+
resolve13(false);
|
|
1128
1191
|
});
|
|
1129
1192
|
});
|
|
1130
1193
|
}
|
|
@@ -1138,7 +1201,7 @@ var init_manager = __esm({
|
|
|
1138
1201
|
return;
|
|
1139
1202
|
}
|
|
1140
1203
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
1141
|
-
await new Promise((
|
|
1204
|
+
await new Promise((resolve13, reject) => {
|
|
1142
1205
|
this.browserWs = new import_ws.default(browserWsUrl);
|
|
1143
1206
|
this.browserWs.on("open", async () => {
|
|
1144
1207
|
this._browserConnected = true;
|
|
@@ -1148,16 +1211,16 @@ var init_manager = __esm({
|
|
|
1148
1211
|
} catch (e) {
|
|
1149
1212
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
1150
1213
|
}
|
|
1151
|
-
|
|
1214
|
+
resolve13();
|
|
1152
1215
|
});
|
|
1153
1216
|
this.browserWs.on("message", (data) => {
|
|
1154
1217
|
try {
|
|
1155
1218
|
const msg = JSON.parse(data.toString());
|
|
1156
1219
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
1157
|
-
const { resolve:
|
|
1220
|
+
const { resolve: resolve14, reject: reject2 } = this.browserPending.get(msg.id);
|
|
1158
1221
|
this.browserPending.delete(msg.id);
|
|
1159
1222
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
1160
|
-
else
|
|
1223
|
+
else resolve14(msg.result);
|
|
1161
1224
|
}
|
|
1162
1225
|
} catch {
|
|
1163
1226
|
}
|
|
@@ -1177,31 +1240,31 @@ var init_manager = __esm({
|
|
|
1177
1240
|
}
|
|
1178
1241
|
}
|
|
1179
1242
|
getBrowserWsUrl() {
|
|
1180
|
-
return new Promise((
|
|
1243
|
+
return new Promise((resolve13) => {
|
|
1181
1244
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
1182
1245
|
let data = "";
|
|
1183
1246
|
res.on("data", (chunk) => data += chunk.toString());
|
|
1184
1247
|
res.on("end", () => {
|
|
1185
1248
|
try {
|
|
1186
1249
|
const info = JSON.parse(data);
|
|
1187
|
-
|
|
1250
|
+
resolve13(info.webSocketDebuggerUrl || null);
|
|
1188
1251
|
} catch {
|
|
1189
|
-
|
|
1252
|
+
resolve13(null);
|
|
1190
1253
|
}
|
|
1191
1254
|
});
|
|
1192
1255
|
});
|
|
1193
|
-
req.on("error", () =>
|
|
1256
|
+
req.on("error", () => resolve13(null));
|
|
1194
1257
|
req.setTimeout(3e3, () => {
|
|
1195
1258
|
req.destroy();
|
|
1196
|
-
|
|
1259
|
+
resolve13(null);
|
|
1197
1260
|
});
|
|
1198
1261
|
});
|
|
1199
1262
|
}
|
|
1200
1263
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
1201
|
-
return new Promise((
|
|
1264
|
+
return new Promise((resolve13, reject) => {
|
|
1202
1265
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
1203
1266
|
const id = this.browserMsgId++;
|
|
1204
|
-
this.browserPending.set(id, { resolve:
|
|
1267
|
+
this.browserPending.set(id, { resolve: resolve13, reject });
|
|
1205
1268
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
1206
1269
|
setTimeout(() => {
|
|
1207
1270
|
if (this.browserPending.has(id)) {
|
|
@@ -1241,11 +1304,11 @@ var init_manager = __esm({
|
|
|
1241
1304
|
}
|
|
1242
1305
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
1243
1306
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
1244
|
-
return new Promise((
|
|
1307
|
+
return new Promise((resolve13, reject) => {
|
|
1245
1308
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
1246
1309
|
if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
|
|
1247
1310
|
const id = this.msgId++;
|
|
1248
|
-
this.pending.set(id, { resolve:
|
|
1311
|
+
this.pending.set(id, { resolve: resolve13, reject });
|
|
1249
1312
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
1250
1313
|
setTimeout(() => {
|
|
1251
1314
|
if (this.pending.has(id)) {
|
|
@@ -1494,7 +1557,7 @@ var init_manager = __esm({
|
|
|
1494
1557
|
const browserWs = this.browserWs;
|
|
1495
1558
|
let msgId = this.browserMsgId;
|
|
1496
1559
|
const sendWs = (method, params = {}, sessionId) => {
|
|
1497
|
-
return new Promise((
|
|
1560
|
+
return new Promise((resolve13, reject) => {
|
|
1498
1561
|
const mid = msgId++;
|
|
1499
1562
|
this.browserMsgId = msgId;
|
|
1500
1563
|
const handler = (raw) => {
|
|
@@ -1503,7 +1566,7 @@ var init_manager = __esm({
|
|
|
1503
1566
|
if (msg.id === mid) {
|
|
1504
1567
|
browserWs.removeListener("message", handler);
|
|
1505
1568
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
1506
|
-
else
|
|
1569
|
+
else resolve13(msg.result);
|
|
1507
1570
|
}
|
|
1508
1571
|
} catch {
|
|
1509
1572
|
}
|
|
@@ -1694,14 +1757,14 @@ var init_manager = __esm({
|
|
|
1694
1757
|
if (!ws2 || ws2.readyState !== import_ws.default.OPEN) {
|
|
1695
1758
|
throw new Error("CDP not connected");
|
|
1696
1759
|
}
|
|
1697
|
-
return new Promise((
|
|
1760
|
+
return new Promise((resolve13, reject) => {
|
|
1698
1761
|
const id = getNextId();
|
|
1699
1762
|
pendingMap.set(id, {
|
|
1700
1763
|
resolve: (result) => {
|
|
1701
1764
|
if (result?.result?.subtype === "error") {
|
|
1702
1765
|
reject(new Error(result.result.description));
|
|
1703
1766
|
} else {
|
|
1704
|
-
|
|
1767
|
+
resolve13(result?.result?.value);
|
|
1705
1768
|
}
|
|
1706
1769
|
},
|
|
1707
1770
|
reject
|
|
@@ -1733,10 +1796,10 @@ var init_manager = __esm({
|
|
|
1733
1796
|
throw new Error("CDP not connected");
|
|
1734
1797
|
}
|
|
1735
1798
|
const sendViaSession = (method, params = {}) => {
|
|
1736
|
-
return new Promise((
|
|
1799
|
+
return new Promise((resolve13, reject) => {
|
|
1737
1800
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
1738
1801
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
1739
|
-
pendingMap.set(id, { resolve:
|
|
1802
|
+
pendingMap.set(id, { resolve: resolve13, reject });
|
|
1740
1803
|
ws2.send(JSON.stringify({ id, sessionId, method, params }));
|
|
1741
1804
|
setTimeout(() => {
|
|
1742
1805
|
if (pendingMap.has(id)) {
|
|
@@ -2304,6 +2367,7 @@ var init_extension_provider_instance = __esm({
|
|
|
2304
2367
|
activeModal = null;
|
|
2305
2368
|
currentModel = "";
|
|
2306
2369
|
currentMode = "";
|
|
2370
|
+
controlValues = {};
|
|
2307
2371
|
lastAgentStatus = "idle";
|
|
2308
2372
|
generatingStartedAt = 0;
|
|
2309
2373
|
monitor;
|
|
@@ -2349,6 +2413,8 @@ var init_extension_provider_instance = __esm({
|
|
|
2349
2413
|
} : null,
|
|
2350
2414
|
currentModel: this.currentModel || void 0,
|
|
2351
2415
|
currentPlan: this.currentMode || void 0,
|
|
2416
|
+
controlValues: this.controlValues,
|
|
2417
|
+
providerControls: this.provider.controls,
|
|
2352
2418
|
agentStreams: this.agentStreams,
|
|
2353
2419
|
instanceId: this.instanceId,
|
|
2354
2420
|
lastUpdated: Date.now(),
|
|
@@ -2363,6 +2429,7 @@ var init_extension_provider_instance = __esm({
|
|
|
2363
2429
|
if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
|
|
2364
2430
|
if (data?.model) this.currentModel = data.model;
|
|
2365
2431
|
if (data?.mode) this.currentMode = data.mode;
|
|
2432
|
+
if (data?.controlValues) this.controlValues = data.controlValues;
|
|
2366
2433
|
if (typeof data?.sessionId === "string" && data.sessionId.trim()) this.chatId = data.sessionId;
|
|
2367
2434
|
if (typeof data?.title === "string" && data.title.trim()) this.chatTitle = data.title;
|
|
2368
2435
|
if (typeof data?.agentName === "string" && data.agentName.trim()) this.agentName = data.agentName;
|
|
@@ -2459,7 +2526,7 @@ var init_extension_provider_instance = __esm({
|
|
|
2459
2526
|
function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
2460
2527
|
try {
|
|
2461
2528
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2462
|
-
const dir =
|
|
2529
|
+
const dir = path5.join(HISTORY_DIR, sanitized);
|
|
2463
2530
|
if (!fs3.existsSync(dir)) return { messages: [], hasMore: false };
|
|
2464
2531
|
const sanitizedInstance = instanceId?.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2465
2532
|
const files = fs3.readdirSync(dir).filter((f) => {
|
|
@@ -2473,7 +2540,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
|
2473
2540
|
const needed = offset + limit + 1;
|
|
2474
2541
|
for (const file2 of files) {
|
|
2475
2542
|
if (allMessages.length >= needed) break;
|
|
2476
|
-
const filePath =
|
|
2543
|
+
const filePath = path5.join(dir, file2);
|
|
2477
2544
|
const content = fs3.readFileSync(filePath, "utf-8");
|
|
2478
2545
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
2479
2546
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
@@ -2492,14 +2559,14 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
|
2492
2559
|
return { messages: [], hasMore: false };
|
|
2493
2560
|
}
|
|
2494
2561
|
}
|
|
2495
|
-
var fs3,
|
|
2562
|
+
var fs3, path5, os5, HISTORY_DIR, RETAIN_DAYS, ChatHistoryWriter;
|
|
2496
2563
|
var init_chat_history = __esm({
|
|
2497
2564
|
"../../oss/packages/daemon-core/src/config/chat-history.ts"() {
|
|
2498
2565
|
"use strict";
|
|
2499
2566
|
fs3 = __toESM(require("fs"));
|
|
2500
|
-
|
|
2567
|
+
path5 = __toESM(require("path"));
|
|
2501
2568
|
os5 = __toESM(require("os"));
|
|
2502
|
-
HISTORY_DIR =
|
|
2569
|
+
HISTORY_DIR = path5.join(os5.homedir(), ".adhdev", "history");
|
|
2503
2570
|
RETAIN_DAYS = 30;
|
|
2504
2571
|
ChatHistoryWriter = class {
|
|
2505
2572
|
/** Last seen message count per agent (deduplication) */
|
|
@@ -2542,11 +2609,11 @@ var init_chat_history = __esm({
|
|
|
2542
2609
|
});
|
|
2543
2610
|
}
|
|
2544
2611
|
if (newMessages.length === 0) return;
|
|
2545
|
-
const dir =
|
|
2612
|
+
const dir = path5.join(HISTORY_DIR, this.sanitize(agentType));
|
|
2546
2613
|
fs3.mkdirSync(dir, { recursive: true });
|
|
2547
2614
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2548
2615
|
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
2549
|
-
const filePath =
|
|
2616
|
+
const filePath = path5.join(dir, `${filePrefix}${date5}.jsonl`);
|
|
2550
2617
|
const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
|
|
2551
2618
|
fs3.appendFileSync(filePath, lines, "utf-8");
|
|
2552
2619
|
const prevCount = this.lastSeenCounts.get(dedupKey) || 0;
|
|
@@ -2590,11 +2657,11 @@ ${next}`;
|
|
|
2590
2657
|
this.lastSeenTerminal.set(dedupKey, next);
|
|
2591
2658
|
return;
|
|
2592
2659
|
}
|
|
2593
|
-
const dir =
|
|
2660
|
+
const dir = path5.join(HISTORY_DIR, this.sanitize(agentType));
|
|
2594
2661
|
fs3.mkdirSync(dir, { recursive: true });
|
|
2595
2662
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2596
2663
|
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
2597
|
-
const filePath =
|
|
2664
|
+
const filePath = path5.join(dir, `${filePrefix}${date5}.terminal.log`);
|
|
2598
2665
|
fs3.appendFileSync(filePath, delta, "utf-8");
|
|
2599
2666
|
this.lastSeenTerminal.set(dedupKey, next);
|
|
2600
2667
|
if (!this.rotated) {
|
|
@@ -2618,10 +2685,10 @@ ${next}`;
|
|
|
2618
2685
|
const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
|
|
2619
2686
|
const agentDirs = fs3.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
2620
2687
|
for (const dir of agentDirs) {
|
|
2621
|
-
const dirPath =
|
|
2688
|
+
const dirPath = path5.join(HISTORY_DIR, dir.name);
|
|
2622
2689
|
const files = fs3.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
|
|
2623
2690
|
for (const file2 of files) {
|
|
2624
|
-
const filePath =
|
|
2691
|
+
const filePath = path5.join(dirPath, file2);
|
|
2625
2692
|
const stat4 = fs3.statSync(filePath);
|
|
2626
2693
|
if (stat4.mtimeMs < cutoff) {
|
|
2627
2694
|
fs3.unlinkSync(filePath);
|
|
@@ -2736,6 +2803,8 @@ var init_ide_provider_instance = __esm({
|
|
|
2736
2803
|
currentModel: this.cachedChat?.model || void 0,
|
|
2737
2804
|
currentPlan: this.cachedChat?.mode || void 0,
|
|
2738
2805
|
currentAutoApprove: this.cachedChat?.autoApprove || void 0,
|
|
2806
|
+
controlValues: this.cachedChat?.controlValues || void 0,
|
|
2807
|
+
providerControls: this.provider.controls,
|
|
2739
2808
|
instanceId: this.instanceId,
|
|
2740
2809
|
lastUpdated: Date.now(),
|
|
2741
2810
|
settings: this.settings,
|
|
@@ -3502,6 +3571,50 @@ function isCdpConnected(cdpManagers, key) {
|
|
|
3502
3571
|
const m = findCdpManager(cdpManagers, key);
|
|
3503
3572
|
return m?.isConnected ?? false;
|
|
3504
3573
|
}
|
|
3574
|
+
function buildFallbackControls(providerControls, serverModel, serverMode, acpConfigOptions, acpModes) {
|
|
3575
|
+
if (providerControls && providerControls.length > 0) return providerControls;
|
|
3576
|
+
const controls = [];
|
|
3577
|
+
const isAcp = !!(acpConfigOptions || acpModes);
|
|
3578
|
+
const modelFromAcp = acpConfigOptions?.find((c) => c.category === "model");
|
|
3579
|
+
if (!isAcp || modelFromAcp) {
|
|
3580
|
+
controls.push({
|
|
3581
|
+
id: "model",
|
|
3582
|
+
type: "select",
|
|
3583
|
+
label: "Model",
|
|
3584
|
+
icon: "\u{1F916}",
|
|
3585
|
+
placement: "bar",
|
|
3586
|
+
dynamic: !modelFromAcp,
|
|
3587
|
+
listScript: "listModels",
|
|
3588
|
+
setScript: "setModel",
|
|
3589
|
+
readFrom: "model",
|
|
3590
|
+
...modelFromAcp && {
|
|
3591
|
+
options: modelFromAcp.options.map((o) => ({ value: o.value, label: o.name || o.value }))
|
|
3592
|
+
}
|
|
3593
|
+
});
|
|
3594
|
+
}
|
|
3595
|
+
const modeFromAcp = acpModes && acpModes.length > 0;
|
|
3596
|
+
const thoughtFromAcp = !modeFromAcp && acpConfigOptions?.find((c) => c.category !== "model");
|
|
3597
|
+
if (!isAcp || modeFromAcp || thoughtFromAcp) {
|
|
3598
|
+
controls.push({
|
|
3599
|
+
id: "mode",
|
|
3600
|
+
type: thoughtFromAcp ? "cycle" : "select",
|
|
3601
|
+
label: thoughtFromAcp ? "Thinking" : "Mode",
|
|
3602
|
+
icon: thoughtFromAcp ? "\u{1F9E0}" : "\u26A1",
|
|
3603
|
+
placement: "bar",
|
|
3604
|
+
dynamic: !modeFromAcp && !thoughtFromAcp,
|
|
3605
|
+
listScript: "listModes",
|
|
3606
|
+
setScript: thoughtFromAcp ? "setThinkingLevel" : "setMode",
|
|
3607
|
+
readFrom: "mode",
|
|
3608
|
+
...modeFromAcp && {
|
|
3609
|
+
options: acpModes.map((m) => ({ value: m.id, label: m.name || m.id }))
|
|
3610
|
+
},
|
|
3611
|
+
...thoughtFromAcp && {
|
|
3612
|
+
options: thoughtFromAcp.options.map((o) => ({ value: o.value, label: o.name || o.value }))
|
|
3613
|
+
}
|
|
3614
|
+
});
|
|
3615
|
+
}
|
|
3616
|
+
return controls;
|
|
3617
|
+
}
|
|
3505
3618
|
function buildIdeWorkspaceSession(state, cdpManagers) {
|
|
3506
3619
|
const activeChat = normalizeActiveChatData(state.activeChat);
|
|
3507
3620
|
const title = activeChat?.title || state.name;
|
|
@@ -3523,8 +3636,15 @@ function buildIdeWorkspaceSession(state, cdpManagers) {
|
|
|
3523
3636
|
currentModel: state.currentModel,
|
|
3524
3637
|
currentPlan: state.currentPlan,
|
|
3525
3638
|
currentAutoApprove: state.currentAutoApprove,
|
|
3639
|
+
controlValues: state.controlValues,
|
|
3640
|
+
providerControls: buildFallbackControls(
|
|
3641
|
+
state.providerControls,
|
|
3642
|
+
state.currentModel,
|
|
3643
|
+
state.currentPlan
|
|
3644
|
+
),
|
|
3526
3645
|
errorMessage: state.errorMessage,
|
|
3527
|
-
errorReason: state.errorReason
|
|
3646
|
+
errorReason: state.errorReason,
|
|
3647
|
+
lastUpdated: state.lastUpdated
|
|
3528
3648
|
};
|
|
3529
3649
|
}
|
|
3530
3650
|
function buildExtensionAgentSession(parent, ext) {
|
|
@@ -3545,8 +3665,15 @@ function buildExtensionAgentSession(parent, ext) {
|
|
|
3545
3665
|
capabilities: EXTENSION_SESSION_CAPABILITIES,
|
|
3546
3666
|
currentModel: ext.currentModel,
|
|
3547
3667
|
currentPlan: ext.currentPlan,
|
|
3668
|
+
controlValues: ext.controlValues,
|
|
3669
|
+
providerControls: buildFallbackControls(
|
|
3670
|
+
ext.providerControls,
|
|
3671
|
+
ext.currentModel,
|
|
3672
|
+
ext.currentPlan
|
|
3673
|
+
),
|
|
3548
3674
|
errorMessage: ext.errorMessage,
|
|
3549
|
-
errorReason: ext.errorReason
|
|
3675
|
+
errorReason: ext.errorReason,
|
|
3676
|
+
lastUpdated: ext.lastUpdated
|
|
3550
3677
|
};
|
|
3551
3678
|
}
|
|
3552
3679
|
function buildCliSession(state) {
|
|
@@ -3571,8 +3698,13 @@ function buildCliSession(state) {
|
|
|
3571
3698
|
resume: state.resume,
|
|
3572
3699
|
activeChat,
|
|
3573
3700
|
capabilities: PTY_SESSION_CAPABILITIES,
|
|
3701
|
+
controlValues: state.controlValues,
|
|
3702
|
+
providerControls: buildFallbackControls(
|
|
3703
|
+
state.providerControls
|
|
3704
|
+
),
|
|
3574
3705
|
errorMessage: state.errorMessage,
|
|
3575
|
-
errorReason: state.errorReason
|
|
3706
|
+
errorReason: state.errorReason,
|
|
3707
|
+
lastUpdated: state.lastUpdated
|
|
3576
3708
|
};
|
|
3577
3709
|
}
|
|
3578
3710
|
function buildAcpSession(state) {
|
|
@@ -3595,8 +3727,17 @@ function buildAcpSession(state) {
|
|
|
3595
3727
|
currentPlan: state.currentPlan,
|
|
3596
3728
|
acpConfigOptions: state.acpConfigOptions,
|
|
3597
3729
|
acpModes: state.acpModes,
|
|
3730
|
+
controlValues: state.controlValues,
|
|
3731
|
+
providerControls: buildFallbackControls(
|
|
3732
|
+
state.providerControls,
|
|
3733
|
+
state.currentModel,
|
|
3734
|
+
state.currentPlan,
|
|
3735
|
+
state.acpConfigOptions,
|
|
3736
|
+
state.acpModes
|
|
3737
|
+
),
|
|
3598
3738
|
errorMessage: state.errorMessage,
|
|
3599
|
-
errorReason: state.errorReason
|
|
3739
|
+
errorReason: state.errorReason,
|
|
3740
|
+
lastUpdated: state.lastUpdated
|
|
3600
3741
|
};
|
|
3601
3742
|
}
|
|
3602
3743
|
function buildSessionEntries(allStates, cdpManagers) {
|
|
@@ -4685,11 +4826,11 @@ function resolveSafePath(requestedPath) {
|
|
|
4685
4826
|
const home = os6.homedir();
|
|
4686
4827
|
let resolved;
|
|
4687
4828
|
if (requestedPath.startsWith("~")) {
|
|
4688
|
-
resolved =
|
|
4689
|
-
} else if (
|
|
4829
|
+
resolved = path6.join(home, requestedPath.slice(1));
|
|
4830
|
+
} else if (path6.isAbsolute(requestedPath)) {
|
|
4690
4831
|
resolved = requestedPath;
|
|
4691
4832
|
} else {
|
|
4692
|
-
resolved =
|
|
4833
|
+
resolved = path6.resolve(requestedPath);
|
|
4693
4834
|
}
|
|
4694
4835
|
return resolved;
|
|
4695
4836
|
}
|
|
@@ -4705,7 +4846,7 @@ async function handleFileRead(h, args) {
|
|
|
4705
4846
|
async function handleFileWrite(h, args) {
|
|
4706
4847
|
try {
|
|
4707
4848
|
const filePath = resolveSafePath(args?.path);
|
|
4708
|
-
fs4.mkdirSync(
|
|
4849
|
+
fs4.mkdirSync(path6.dirname(filePath), { recursive: true });
|
|
4709
4850
|
fs4.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
4710
4851
|
return { success: true, path: filePath };
|
|
4711
4852
|
} catch (e) {
|
|
@@ -4719,7 +4860,7 @@ async function handleFileList(h, args) {
|
|
|
4719
4860
|
const files = entries.map((e) => ({
|
|
4720
4861
|
name: e.name,
|
|
4721
4862
|
type: e.isDirectory() ? "directory" : "file",
|
|
4722
|
-
size: e.isFile() ? fs4.statSync(
|
|
4863
|
+
size: e.isFile() ? fs4.statSync(path6.join(dirPath, e.name)).size : void 0
|
|
4723
4864
|
}));
|
|
4724
4865
|
return { success: true, files, path: dirPath };
|
|
4725
4866
|
} catch (e) {
|
|
@@ -4729,12 +4870,12 @@ async function handleFileList(h, args) {
|
|
|
4729
4870
|
async function handleFileListBrowse(h, args) {
|
|
4730
4871
|
return handleFileList(h, args);
|
|
4731
4872
|
}
|
|
4732
|
-
var fs4,
|
|
4873
|
+
var fs4, path6, os6, KEY_TO_VK;
|
|
4733
4874
|
var init_cdp_commands = __esm({
|
|
4734
4875
|
"../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
|
|
4735
4876
|
"use strict";
|
|
4736
4877
|
fs4 = __toESM(require("fs"));
|
|
4737
|
-
|
|
4878
|
+
path6 = __toESM(require("path"));
|
|
4738
4879
|
os6 = __toESM(require("os"));
|
|
4739
4880
|
KEY_TO_VK = {
|
|
4740
4881
|
Backspace: 8,
|
|
@@ -4988,9 +5129,10 @@ function handleWorkspaceList() {
|
|
|
4988
5129
|
function handleWorkspaceAdd(args) {
|
|
4989
5130
|
const rawPath = (args?.path || args?.dir || "").trim();
|
|
4990
5131
|
const label = (args?.label || "").trim() || void 0;
|
|
5132
|
+
const createIfMissing = args?.createIfMissing === true;
|
|
4991
5133
|
if (!rawPath) return { success: false, error: "path required" };
|
|
4992
5134
|
const config2 = loadConfig();
|
|
4993
|
-
const result = addWorkspaceEntry(config2, rawPath, label);
|
|
5135
|
+
const result = addWorkspaceEntry(config2, rawPath, label, { createIfMissing });
|
|
4994
5136
|
if ("error" in result) return { success: false, error: result.error };
|
|
4995
5137
|
let cfg = appendWorkspaceActivity(result.config, result.entry.path, {});
|
|
4996
5138
|
saveConfig(cfg);
|
|
@@ -5506,7 +5648,7 @@ var init_handler = __esm({
|
|
|
5506
5648
|
try {
|
|
5507
5649
|
const http3 = await import("http");
|
|
5508
5650
|
const postData = JSON.stringify(body);
|
|
5509
|
-
const result = await new Promise((
|
|
5651
|
+
const result = await new Promise((resolve13, reject) => {
|
|
5510
5652
|
const req = http3.request({
|
|
5511
5653
|
hostname: "127.0.0.1",
|
|
5512
5654
|
port: 19280,
|
|
@@ -5518,9 +5660,9 @@ var init_handler = __esm({
|
|
|
5518
5660
|
res.on("data", (chunk) => data += chunk);
|
|
5519
5661
|
res.on("end", () => {
|
|
5520
5662
|
try {
|
|
5521
|
-
|
|
5663
|
+
resolve13(JSON.parse(data));
|
|
5522
5664
|
} catch {
|
|
5523
|
-
|
|
5665
|
+
resolve13({ raw: data });
|
|
5524
5666
|
}
|
|
5525
5667
|
});
|
|
5526
5668
|
});
|
|
@@ -5538,15 +5680,15 @@ var init_handler = __esm({
|
|
|
5538
5680
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
5539
5681
|
try {
|
|
5540
5682
|
const http3 = await import("http");
|
|
5541
|
-
const result = await new Promise((
|
|
5683
|
+
const result = await new Promise((resolve13, reject) => {
|
|
5542
5684
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
5543
5685
|
let data = "";
|
|
5544
5686
|
res.on("data", (chunk) => data += chunk);
|
|
5545
5687
|
res.on("end", () => {
|
|
5546
5688
|
try {
|
|
5547
|
-
|
|
5689
|
+
resolve13(JSON.parse(data));
|
|
5548
5690
|
} catch {
|
|
5549
|
-
|
|
5691
|
+
resolve13({ raw: data });
|
|
5550
5692
|
}
|
|
5551
5693
|
});
|
|
5552
5694
|
}).on("error", reject);
|
|
@@ -5560,7 +5702,7 @@ var init_handler = __esm({
|
|
|
5560
5702
|
try {
|
|
5561
5703
|
const http3 = await import("http");
|
|
5562
5704
|
const postData = JSON.stringify(args || {});
|
|
5563
|
-
const result = await new Promise((
|
|
5705
|
+
const result = await new Promise((resolve13, reject) => {
|
|
5564
5706
|
const req = http3.request({
|
|
5565
5707
|
hostname: "127.0.0.1",
|
|
5566
5708
|
port: 19280,
|
|
@@ -5572,9 +5714,9 @@ var init_handler = __esm({
|
|
|
5572
5714
|
res.on("data", (chunk) => data += chunk);
|
|
5573
5715
|
res.on("end", () => {
|
|
5574
5716
|
try {
|
|
5575
|
-
|
|
5717
|
+
resolve13(JSON.parse(data));
|
|
5576
5718
|
} catch {
|
|
5577
|
-
|
|
5719
|
+
resolve13({ raw: data });
|
|
5578
5720
|
}
|
|
5579
5721
|
});
|
|
5580
5722
|
});
|
|
@@ -5695,7 +5837,7 @@ var init_readdirp = __esm({
|
|
|
5695
5837
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
5696
5838
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
5697
5839
|
if (wantBigintFsStats) {
|
|
5698
|
-
this._stat = (
|
|
5840
|
+
this._stat = (path19) => statMethod(path19, { bigint: true });
|
|
5699
5841
|
} else {
|
|
5700
5842
|
this._stat = statMethod;
|
|
5701
5843
|
}
|
|
@@ -5720,8 +5862,8 @@ var init_readdirp = __esm({
|
|
|
5720
5862
|
const par = this.parent;
|
|
5721
5863
|
const fil = par && par.files;
|
|
5722
5864
|
if (fil && fil.length > 0) {
|
|
5723
|
-
const { path:
|
|
5724
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
5865
|
+
const { path: path19, depth } = par;
|
|
5866
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path19));
|
|
5725
5867
|
const awaited = await Promise.all(slice);
|
|
5726
5868
|
for (const entry of awaited) {
|
|
5727
5869
|
if (!entry)
|
|
@@ -5761,20 +5903,20 @@ var init_readdirp = __esm({
|
|
|
5761
5903
|
this.reading = false;
|
|
5762
5904
|
}
|
|
5763
5905
|
}
|
|
5764
|
-
async _exploreDir(
|
|
5906
|
+
async _exploreDir(path19, depth) {
|
|
5765
5907
|
let files;
|
|
5766
5908
|
try {
|
|
5767
|
-
files = await (0, import_promises.readdir)(
|
|
5909
|
+
files = await (0, import_promises.readdir)(path19, this._rdOptions);
|
|
5768
5910
|
} catch (error48) {
|
|
5769
5911
|
this._onError(error48);
|
|
5770
5912
|
}
|
|
5771
|
-
return { files, depth, path:
|
|
5913
|
+
return { files, depth, path: path19 };
|
|
5772
5914
|
}
|
|
5773
|
-
async _formatEntry(dirent,
|
|
5915
|
+
async _formatEntry(dirent, path19) {
|
|
5774
5916
|
let entry;
|
|
5775
5917
|
const basename7 = this._isDirent ? dirent.name : dirent;
|
|
5776
5918
|
try {
|
|
5777
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
5919
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path19, basename7));
|
|
5778
5920
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
|
|
5779
5921
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
5780
5922
|
} catch (err) {
|
|
@@ -5831,16 +5973,16 @@ var init_readdirp = __esm({
|
|
|
5831
5973
|
});
|
|
5832
5974
|
|
|
5833
5975
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
5834
|
-
function createFsWatchInstance(
|
|
5976
|
+
function createFsWatchInstance(path19, options, listener, errHandler, emitRaw) {
|
|
5835
5977
|
const handleEvent = (rawEvent, evPath) => {
|
|
5836
|
-
listener(
|
|
5837
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
5838
|
-
if (evPath &&
|
|
5839
|
-
fsWatchBroadcast(sp.resolve(
|
|
5978
|
+
listener(path19);
|
|
5979
|
+
emitRaw(rawEvent, evPath, { watchedPath: path19 });
|
|
5980
|
+
if (evPath && path19 !== evPath) {
|
|
5981
|
+
fsWatchBroadcast(sp.resolve(path19, evPath), KEY_LISTENERS, sp.join(path19, evPath));
|
|
5840
5982
|
}
|
|
5841
5983
|
};
|
|
5842
5984
|
try {
|
|
5843
|
-
return (0, import_node_fs.watch)(
|
|
5985
|
+
return (0, import_node_fs.watch)(path19, {
|
|
5844
5986
|
persistent: options.persistent
|
|
5845
5987
|
}, handleEvent);
|
|
5846
5988
|
} catch (error48) {
|
|
@@ -6189,12 +6331,12 @@ var init_handler2 = __esm({
|
|
|
6189
6331
|
listener(val1, val2, val3);
|
|
6190
6332
|
});
|
|
6191
6333
|
};
|
|
6192
|
-
setFsWatchListener = (
|
|
6334
|
+
setFsWatchListener = (path19, fullPath, options, handlers) => {
|
|
6193
6335
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
6194
6336
|
let cont = FsWatchInstances.get(fullPath);
|
|
6195
6337
|
let watcher;
|
|
6196
6338
|
if (!options.persistent) {
|
|
6197
|
-
watcher = createFsWatchInstance(
|
|
6339
|
+
watcher = createFsWatchInstance(path19, options, listener, errHandler, rawEmitter);
|
|
6198
6340
|
if (!watcher)
|
|
6199
6341
|
return;
|
|
6200
6342
|
return watcher.close.bind(watcher);
|
|
@@ -6205,7 +6347,7 @@ var init_handler2 = __esm({
|
|
|
6205
6347
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
6206
6348
|
} else {
|
|
6207
6349
|
watcher = createFsWatchInstance(
|
|
6208
|
-
|
|
6350
|
+
path19,
|
|
6209
6351
|
options,
|
|
6210
6352
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
6211
6353
|
errHandler,
|
|
@@ -6220,7 +6362,7 @@ var init_handler2 = __esm({
|
|
|
6220
6362
|
cont.watcherUnusable = true;
|
|
6221
6363
|
if (isWindows && error48.code === "EPERM") {
|
|
6222
6364
|
try {
|
|
6223
|
-
const fd = await (0, import_promises2.open)(
|
|
6365
|
+
const fd = await (0, import_promises2.open)(path19, "r");
|
|
6224
6366
|
await fd.close();
|
|
6225
6367
|
broadcastErr(error48);
|
|
6226
6368
|
} catch (err) {
|
|
@@ -6251,7 +6393,7 @@ var init_handler2 = __esm({
|
|
|
6251
6393
|
};
|
|
6252
6394
|
};
|
|
6253
6395
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
6254
|
-
setFsWatchFileListener = (
|
|
6396
|
+
setFsWatchFileListener = (path19, fullPath, options, handlers) => {
|
|
6255
6397
|
const { listener, rawEmitter } = handlers;
|
|
6256
6398
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
6257
6399
|
const copts = cont && cont.options;
|
|
@@ -6273,7 +6415,7 @@ var init_handler2 = __esm({
|
|
|
6273
6415
|
});
|
|
6274
6416
|
const currmtime = curr.mtimeMs;
|
|
6275
6417
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
6276
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
6418
|
+
foreach(cont.listeners, (listener2) => listener2(path19, curr));
|
|
6277
6419
|
}
|
|
6278
6420
|
})
|
|
6279
6421
|
};
|
|
@@ -6303,13 +6445,13 @@ var init_handler2 = __esm({
|
|
|
6303
6445
|
* @param listener on fs change
|
|
6304
6446
|
* @returns closer for the watcher instance
|
|
6305
6447
|
*/
|
|
6306
|
-
_watchWithNodeFs(
|
|
6448
|
+
_watchWithNodeFs(path19, listener) {
|
|
6307
6449
|
const opts = this.fsw.options;
|
|
6308
|
-
const directory = sp.dirname(
|
|
6309
|
-
const basename7 = sp.basename(
|
|
6450
|
+
const directory = sp.dirname(path19);
|
|
6451
|
+
const basename7 = sp.basename(path19);
|
|
6310
6452
|
const parent = this.fsw._getWatchedDir(directory);
|
|
6311
6453
|
parent.add(basename7);
|
|
6312
|
-
const absolutePath = sp.resolve(
|
|
6454
|
+
const absolutePath = sp.resolve(path19);
|
|
6313
6455
|
const options = {
|
|
6314
6456
|
persistent: opts.persistent
|
|
6315
6457
|
};
|
|
@@ -6319,12 +6461,12 @@ var init_handler2 = __esm({
|
|
|
6319
6461
|
if (opts.usePolling) {
|
|
6320
6462
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
6321
6463
|
options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
|
|
6322
|
-
closer = setFsWatchFileListener(
|
|
6464
|
+
closer = setFsWatchFileListener(path19, absolutePath, options, {
|
|
6323
6465
|
listener,
|
|
6324
6466
|
rawEmitter: this.fsw._emitRaw
|
|
6325
6467
|
});
|
|
6326
6468
|
} else {
|
|
6327
|
-
closer = setFsWatchListener(
|
|
6469
|
+
closer = setFsWatchListener(path19, absolutePath, options, {
|
|
6328
6470
|
listener,
|
|
6329
6471
|
errHandler: this._boundHandleError,
|
|
6330
6472
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -6346,7 +6488,7 @@ var init_handler2 = __esm({
|
|
|
6346
6488
|
let prevStats = stats;
|
|
6347
6489
|
if (parent.has(basename7))
|
|
6348
6490
|
return;
|
|
6349
|
-
const listener = async (
|
|
6491
|
+
const listener = async (path19, newStats) => {
|
|
6350
6492
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
6351
6493
|
return;
|
|
6352
6494
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -6360,11 +6502,11 @@ var init_handler2 = __esm({
|
|
|
6360
6502
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
6361
6503
|
}
|
|
6362
6504
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
6363
|
-
this.fsw._closeFile(
|
|
6505
|
+
this.fsw._closeFile(path19);
|
|
6364
6506
|
prevStats = newStats2;
|
|
6365
6507
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
6366
6508
|
if (closer2)
|
|
6367
|
-
this.fsw._addPathCloser(
|
|
6509
|
+
this.fsw._addPathCloser(path19, closer2);
|
|
6368
6510
|
} else {
|
|
6369
6511
|
prevStats = newStats2;
|
|
6370
6512
|
}
|
|
@@ -6396,7 +6538,7 @@ var init_handler2 = __esm({
|
|
|
6396
6538
|
* @param item basename of this item
|
|
6397
6539
|
* @returns true if no more processing is needed for this entry.
|
|
6398
6540
|
*/
|
|
6399
|
-
async _handleSymlink(entry, directory,
|
|
6541
|
+
async _handleSymlink(entry, directory, path19, item) {
|
|
6400
6542
|
if (this.fsw.closed) {
|
|
6401
6543
|
return;
|
|
6402
6544
|
}
|
|
@@ -6406,7 +6548,7 @@ var init_handler2 = __esm({
|
|
|
6406
6548
|
this.fsw._incrReadyCount();
|
|
6407
6549
|
let linkPath;
|
|
6408
6550
|
try {
|
|
6409
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
6551
|
+
linkPath = await (0, import_promises2.realpath)(path19);
|
|
6410
6552
|
} catch (e) {
|
|
6411
6553
|
this.fsw._emitReady();
|
|
6412
6554
|
return true;
|
|
@@ -6416,12 +6558,12 @@ var init_handler2 = __esm({
|
|
|
6416
6558
|
if (dir.has(item)) {
|
|
6417
6559
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
6418
6560
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6419
|
-
this.fsw._emit(EV.CHANGE,
|
|
6561
|
+
this.fsw._emit(EV.CHANGE, path19, entry.stats);
|
|
6420
6562
|
}
|
|
6421
6563
|
} else {
|
|
6422
6564
|
dir.add(item);
|
|
6423
6565
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6424
|
-
this.fsw._emit(EV.ADD,
|
|
6566
|
+
this.fsw._emit(EV.ADD, path19, entry.stats);
|
|
6425
6567
|
}
|
|
6426
6568
|
this.fsw._emitReady();
|
|
6427
6569
|
return true;
|
|
@@ -6451,9 +6593,9 @@ var init_handler2 = __esm({
|
|
|
6451
6593
|
return;
|
|
6452
6594
|
}
|
|
6453
6595
|
const item = entry.path;
|
|
6454
|
-
let
|
|
6596
|
+
let path19 = sp.join(directory, item);
|
|
6455
6597
|
current.add(item);
|
|
6456
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
6598
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path19, item)) {
|
|
6457
6599
|
return;
|
|
6458
6600
|
}
|
|
6459
6601
|
if (this.fsw.closed) {
|
|
@@ -6462,11 +6604,11 @@ var init_handler2 = __esm({
|
|
|
6462
6604
|
}
|
|
6463
6605
|
if (item === target || !target && !previous.has(item)) {
|
|
6464
6606
|
this.fsw._incrReadyCount();
|
|
6465
|
-
|
|
6466
|
-
this._addToNodeFs(
|
|
6607
|
+
path19 = sp.join(dir, sp.relative(dir, path19));
|
|
6608
|
+
this._addToNodeFs(path19, initialAdd, wh, depth + 1);
|
|
6467
6609
|
}
|
|
6468
6610
|
}).on(EV.ERROR, this._boundHandleError);
|
|
6469
|
-
return new Promise((
|
|
6611
|
+
return new Promise((resolve13, reject) => {
|
|
6470
6612
|
if (!stream)
|
|
6471
6613
|
return reject();
|
|
6472
6614
|
stream.once(STR_END, () => {
|
|
@@ -6475,7 +6617,7 @@ var init_handler2 = __esm({
|
|
|
6475
6617
|
return;
|
|
6476
6618
|
}
|
|
6477
6619
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
6478
|
-
|
|
6620
|
+
resolve13(void 0);
|
|
6479
6621
|
previous.getChildren().filter((item) => {
|
|
6480
6622
|
return item !== directory && !current.has(item);
|
|
6481
6623
|
}).forEach((item) => {
|
|
@@ -6532,13 +6674,13 @@ var init_handler2 = __esm({
|
|
|
6532
6674
|
* @param depth Child path actually targeted for watch
|
|
6533
6675
|
* @param target Child path actually targeted for watch
|
|
6534
6676
|
*/
|
|
6535
|
-
async _addToNodeFs(
|
|
6677
|
+
async _addToNodeFs(path19, initialAdd, priorWh, depth, target) {
|
|
6536
6678
|
const ready = this.fsw._emitReady;
|
|
6537
|
-
if (this.fsw._isIgnored(
|
|
6679
|
+
if (this.fsw._isIgnored(path19) || this.fsw.closed) {
|
|
6538
6680
|
ready();
|
|
6539
6681
|
return false;
|
|
6540
6682
|
}
|
|
6541
|
-
const wh = this.fsw._getWatchHelpers(
|
|
6683
|
+
const wh = this.fsw._getWatchHelpers(path19);
|
|
6542
6684
|
if (priorWh) {
|
|
6543
6685
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
6544
6686
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -6554,8 +6696,8 @@ var init_handler2 = __esm({
|
|
|
6554
6696
|
const follow = this.fsw.options.followSymlinks;
|
|
6555
6697
|
let closer;
|
|
6556
6698
|
if (stats.isDirectory()) {
|
|
6557
|
-
const absPath = sp.resolve(
|
|
6558
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6699
|
+
const absPath = sp.resolve(path19);
|
|
6700
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
|
|
6559
6701
|
if (this.fsw.closed)
|
|
6560
6702
|
return;
|
|
6561
6703
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -6565,29 +6707,29 @@ var init_handler2 = __esm({
|
|
|
6565
6707
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
6566
6708
|
}
|
|
6567
6709
|
} else if (stats.isSymbolicLink()) {
|
|
6568
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6710
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
|
|
6569
6711
|
if (this.fsw.closed)
|
|
6570
6712
|
return;
|
|
6571
6713
|
const parent = sp.dirname(wh.watchPath);
|
|
6572
6714
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
6573
6715
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
6574
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
6716
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path19, wh, targetPath);
|
|
6575
6717
|
if (this.fsw.closed)
|
|
6576
6718
|
return;
|
|
6577
6719
|
if (targetPath !== void 0) {
|
|
6578
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
6720
|
+
this.fsw._symlinkPaths.set(sp.resolve(path19), targetPath);
|
|
6579
6721
|
}
|
|
6580
6722
|
} else {
|
|
6581
6723
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
6582
6724
|
}
|
|
6583
6725
|
ready();
|
|
6584
6726
|
if (closer)
|
|
6585
|
-
this.fsw._addPathCloser(
|
|
6727
|
+
this.fsw._addPathCloser(path19, closer);
|
|
6586
6728
|
return false;
|
|
6587
6729
|
} catch (error48) {
|
|
6588
6730
|
if (this.fsw._handleError(error48)) {
|
|
6589
6731
|
ready();
|
|
6590
|
-
return
|
|
6732
|
+
return path19;
|
|
6591
6733
|
}
|
|
6592
6734
|
}
|
|
6593
6735
|
}
|
|
@@ -6622,24 +6764,24 @@ function createPattern(matcher) {
|
|
|
6622
6764
|
}
|
|
6623
6765
|
return () => false;
|
|
6624
6766
|
}
|
|
6625
|
-
function normalizePath(
|
|
6626
|
-
if (typeof
|
|
6767
|
+
function normalizePath(path19) {
|
|
6768
|
+
if (typeof path19 !== "string")
|
|
6627
6769
|
throw new Error("string expected");
|
|
6628
|
-
|
|
6629
|
-
|
|
6770
|
+
path19 = sp2.normalize(path19);
|
|
6771
|
+
path19 = path19.replace(/\\/g, "/");
|
|
6630
6772
|
let prepend = false;
|
|
6631
|
-
if (
|
|
6773
|
+
if (path19.startsWith("//"))
|
|
6632
6774
|
prepend = true;
|
|
6633
|
-
|
|
6775
|
+
path19 = path19.replace(DOUBLE_SLASH_RE, "/");
|
|
6634
6776
|
if (prepend)
|
|
6635
|
-
|
|
6636
|
-
return
|
|
6777
|
+
path19 = "/" + path19;
|
|
6778
|
+
return path19;
|
|
6637
6779
|
}
|
|
6638
6780
|
function matchPatterns(patterns, testString, stats) {
|
|
6639
|
-
const
|
|
6781
|
+
const path19 = normalizePath(testString);
|
|
6640
6782
|
for (let index = 0; index < patterns.length; index++) {
|
|
6641
6783
|
const pattern = patterns[index];
|
|
6642
|
-
if (pattern(
|
|
6784
|
+
if (pattern(path19, stats)) {
|
|
6643
6785
|
return true;
|
|
6644
6786
|
}
|
|
6645
6787
|
}
|
|
@@ -6702,19 +6844,19 @@ var init_chokidar = __esm({
|
|
|
6702
6844
|
}
|
|
6703
6845
|
return str;
|
|
6704
6846
|
};
|
|
6705
|
-
normalizePathToUnix = (
|
|
6706
|
-
normalizeIgnored = (cwd = "") => (
|
|
6707
|
-
if (typeof
|
|
6708
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
6847
|
+
normalizePathToUnix = (path19) => toUnix(sp2.normalize(toUnix(path19)));
|
|
6848
|
+
normalizeIgnored = (cwd = "") => (path19) => {
|
|
6849
|
+
if (typeof path19 === "string") {
|
|
6850
|
+
return normalizePathToUnix(sp2.isAbsolute(path19) ? path19 : sp2.join(cwd, path19));
|
|
6709
6851
|
} else {
|
|
6710
|
-
return
|
|
6852
|
+
return path19;
|
|
6711
6853
|
}
|
|
6712
6854
|
};
|
|
6713
|
-
getAbsolutePath = (
|
|
6714
|
-
if (sp2.isAbsolute(
|
|
6715
|
-
return
|
|
6855
|
+
getAbsolutePath = (path19, cwd) => {
|
|
6856
|
+
if (sp2.isAbsolute(path19)) {
|
|
6857
|
+
return path19;
|
|
6716
6858
|
}
|
|
6717
|
-
return sp2.join(cwd,
|
|
6859
|
+
return sp2.join(cwd, path19);
|
|
6718
6860
|
};
|
|
6719
6861
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
6720
6862
|
DirEntry = class {
|
|
@@ -6779,10 +6921,10 @@ var init_chokidar = __esm({
|
|
|
6779
6921
|
dirParts;
|
|
6780
6922
|
followSymlinks;
|
|
6781
6923
|
statMethod;
|
|
6782
|
-
constructor(
|
|
6924
|
+
constructor(path19, follow, fsw) {
|
|
6783
6925
|
this.fsw = fsw;
|
|
6784
|
-
const watchPath =
|
|
6785
|
-
this.path =
|
|
6926
|
+
const watchPath = path19;
|
|
6927
|
+
this.path = path19 = path19.replace(REPLACER_RE, "");
|
|
6786
6928
|
this.watchPath = watchPath;
|
|
6787
6929
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
6788
6930
|
this.dirParts = [];
|
|
@@ -6922,20 +7064,20 @@ var init_chokidar = __esm({
|
|
|
6922
7064
|
this._closePromise = void 0;
|
|
6923
7065
|
let paths = unifyPaths(paths_);
|
|
6924
7066
|
if (cwd) {
|
|
6925
|
-
paths = paths.map((
|
|
6926
|
-
const absPath = getAbsolutePath(
|
|
7067
|
+
paths = paths.map((path19) => {
|
|
7068
|
+
const absPath = getAbsolutePath(path19, cwd);
|
|
6927
7069
|
return absPath;
|
|
6928
7070
|
});
|
|
6929
7071
|
}
|
|
6930
|
-
paths.forEach((
|
|
6931
|
-
this._removeIgnoredPath(
|
|
7072
|
+
paths.forEach((path19) => {
|
|
7073
|
+
this._removeIgnoredPath(path19);
|
|
6932
7074
|
});
|
|
6933
7075
|
this._userIgnored = void 0;
|
|
6934
7076
|
if (!this._readyCount)
|
|
6935
7077
|
this._readyCount = 0;
|
|
6936
7078
|
this._readyCount += paths.length;
|
|
6937
|
-
Promise.all(paths.map(async (
|
|
6938
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
7079
|
+
Promise.all(paths.map(async (path19) => {
|
|
7080
|
+
const res = await this._nodeFsHandler._addToNodeFs(path19, !_internal, void 0, 0, _origAdd);
|
|
6939
7081
|
if (res)
|
|
6940
7082
|
this._emitReady();
|
|
6941
7083
|
return res;
|
|
@@ -6957,17 +7099,17 @@ var init_chokidar = __esm({
|
|
|
6957
7099
|
return this;
|
|
6958
7100
|
const paths = unifyPaths(paths_);
|
|
6959
7101
|
const { cwd } = this.options;
|
|
6960
|
-
paths.forEach((
|
|
6961
|
-
if (!sp2.isAbsolute(
|
|
7102
|
+
paths.forEach((path19) => {
|
|
7103
|
+
if (!sp2.isAbsolute(path19) && !this._closers.has(path19)) {
|
|
6962
7104
|
if (cwd)
|
|
6963
|
-
|
|
6964
|
-
|
|
7105
|
+
path19 = sp2.join(cwd, path19);
|
|
7106
|
+
path19 = sp2.resolve(path19);
|
|
6965
7107
|
}
|
|
6966
|
-
this._closePath(
|
|
6967
|
-
this._addIgnoredPath(
|
|
6968
|
-
if (this._watched.has(
|
|
7108
|
+
this._closePath(path19);
|
|
7109
|
+
this._addIgnoredPath(path19);
|
|
7110
|
+
if (this._watched.has(path19)) {
|
|
6969
7111
|
this._addIgnoredPath({
|
|
6970
|
-
path:
|
|
7112
|
+
path: path19,
|
|
6971
7113
|
recursive: true
|
|
6972
7114
|
});
|
|
6973
7115
|
}
|
|
@@ -7031,38 +7173,38 @@ var init_chokidar = __esm({
|
|
|
7031
7173
|
* @param stats arguments to be passed with event
|
|
7032
7174
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
7033
7175
|
*/
|
|
7034
|
-
async _emit(event,
|
|
7176
|
+
async _emit(event, path19, stats) {
|
|
7035
7177
|
if (this.closed)
|
|
7036
7178
|
return;
|
|
7037
7179
|
const opts = this.options;
|
|
7038
7180
|
if (isWindows)
|
|
7039
|
-
|
|
7181
|
+
path19 = sp2.normalize(path19);
|
|
7040
7182
|
if (opts.cwd)
|
|
7041
|
-
|
|
7042
|
-
const args = [
|
|
7183
|
+
path19 = sp2.relative(opts.cwd, path19);
|
|
7184
|
+
const args = [path19];
|
|
7043
7185
|
if (stats != null)
|
|
7044
7186
|
args.push(stats);
|
|
7045
7187
|
const awf = opts.awaitWriteFinish;
|
|
7046
7188
|
let pw;
|
|
7047
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
7189
|
+
if (awf && (pw = this._pendingWrites.get(path19))) {
|
|
7048
7190
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
7049
7191
|
return this;
|
|
7050
7192
|
}
|
|
7051
7193
|
if (opts.atomic) {
|
|
7052
7194
|
if (event === EVENTS.UNLINK) {
|
|
7053
|
-
this._pendingUnlinks.set(
|
|
7195
|
+
this._pendingUnlinks.set(path19, [event, ...args]);
|
|
7054
7196
|
setTimeout(() => {
|
|
7055
|
-
this._pendingUnlinks.forEach((entry,
|
|
7197
|
+
this._pendingUnlinks.forEach((entry, path20) => {
|
|
7056
7198
|
this.emit(...entry);
|
|
7057
7199
|
this.emit(EVENTS.ALL, ...entry);
|
|
7058
|
-
this._pendingUnlinks.delete(
|
|
7200
|
+
this._pendingUnlinks.delete(path20);
|
|
7059
7201
|
});
|
|
7060
7202
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
7061
7203
|
return this;
|
|
7062
7204
|
}
|
|
7063
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
7205
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path19)) {
|
|
7064
7206
|
event = EVENTS.CHANGE;
|
|
7065
|
-
this._pendingUnlinks.delete(
|
|
7207
|
+
this._pendingUnlinks.delete(path19);
|
|
7066
7208
|
}
|
|
7067
7209
|
}
|
|
7068
7210
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -7080,16 +7222,16 @@ var init_chokidar = __esm({
|
|
|
7080
7222
|
this.emitWithAll(event, args);
|
|
7081
7223
|
}
|
|
7082
7224
|
};
|
|
7083
|
-
this._awaitWriteFinish(
|
|
7225
|
+
this._awaitWriteFinish(path19, awf.stabilityThreshold, event, awfEmit);
|
|
7084
7226
|
return this;
|
|
7085
7227
|
}
|
|
7086
7228
|
if (event === EVENTS.CHANGE) {
|
|
7087
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
7229
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path19, 50);
|
|
7088
7230
|
if (isThrottled)
|
|
7089
7231
|
return this;
|
|
7090
7232
|
}
|
|
7091
7233
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
7092
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
7234
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path19) : path19;
|
|
7093
7235
|
let stats2;
|
|
7094
7236
|
try {
|
|
7095
7237
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -7120,23 +7262,23 @@ var init_chokidar = __esm({
|
|
|
7120
7262
|
* @param timeout duration of time to suppress duplicate actions
|
|
7121
7263
|
* @returns tracking object or false if action should be suppressed
|
|
7122
7264
|
*/
|
|
7123
|
-
_throttle(actionType,
|
|
7265
|
+
_throttle(actionType, path19, timeout) {
|
|
7124
7266
|
if (!this._throttled.has(actionType)) {
|
|
7125
7267
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
7126
7268
|
}
|
|
7127
7269
|
const action = this._throttled.get(actionType);
|
|
7128
7270
|
if (!action)
|
|
7129
7271
|
throw new Error("invalid throttle");
|
|
7130
|
-
const actionPath = action.get(
|
|
7272
|
+
const actionPath = action.get(path19);
|
|
7131
7273
|
if (actionPath) {
|
|
7132
7274
|
actionPath.count++;
|
|
7133
7275
|
return false;
|
|
7134
7276
|
}
|
|
7135
7277
|
let timeoutObject;
|
|
7136
7278
|
const clear = () => {
|
|
7137
|
-
const item = action.get(
|
|
7279
|
+
const item = action.get(path19);
|
|
7138
7280
|
const count = item ? item.count : 0;
|
|
7139
|
-
action.delete(
|
|
7281
|
+
action.delete(path19);
|
|
7140
7282
|
clearTimeout(timeoutObject);
|
|
7141
7283
|
if (item)
|
|
7142
7284
|
clearTimeout(item.timeoutObject);
|
|
@@ -7144,7 +7286,7 @@ var init_chokidar = __esm({
|
|
|
7144
7286
|
};
|
|
7145
7287
|
timeoutObject = setTimeout(clear, timeout);
|
|
7146
7288
|
const thr = { timeoutObject, clear, count: 0 };
|
|
7147
|
-
action.set(
|
|
7289
|
+
action.set(path19, thr);
|
|
7148
7290
|
return thr;
|
|
7149
7291
|
}
|
|
7150
7292
|
_incrReadyCount() {
|
|
@@ -7158,44 +7300,44 @@ var init_chokidar = __esm({
|
|
|
7158
7300
|
* @param event
|
|
7159
7301
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
7160
7302
|
*/
|
|
7161
|
-
_awaitWriteFinish(
|
|
7303
|
+
_awaitWriteFinish(path19, threshold, event, awfEmit) {
|
|
7162
7304
|
const awf = this.options.awaitWriteFinish;
|
|
7163
7305
|
if (typeof awf !== "object")
|
|
7164
7306
|
return;
|
|
7165
7307
|
const pollInterval = awf.pollInterval;
|
|
7166
7308
|
let timeoutHandler;
|
|
7167
|
-
let fullPath =
|
|
7168
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
7169
|
-
fullPath = sp2.join(this.options.cwd,
|
|
7309
|
+
let fullPath = path19;
|
|
7310
|
+
if (this.options.cwd && !sp2.isAbsolute(path19)) {
|
|
7311
|
+
fullPath = sp2.join(this.options.cwd, path19);
|
|
7170
7312
|
}
|
|
7171
7313
|
const now = /* @__PURE__ */ new Date();
|
|
7172
7314
|
const writes = this._pendingWrites;
|
|
7173
7315
|
function awaitWriteFinishFn(prevStat) {
|
|
7174
7316
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
7175
|
-
if (err || !writes.has(
|
|
7317
|
+
if (err || !writes.has(path19)) {
|
|
7176
7318
|
if (err && err.code !== "ENOENT")
|
|
7177
7319
|
awfEmit(err);
|
|
7178
7320
|
return;
|
|
7179
7321
|
}
|
|
7180
7322
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
7181
7323
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
7182
|
-
writes.get(
|
|
7324
|
+
writes.get(path19).lastChange = now2;
|
|
7183
7325
|
}
|
|
7184
|
-
const pw = writes.get(
|
|
7326
|
+
const pw = writes.get(path19);
|
|
7185
7327
|
const df = now2 - pw.lastChange;
|
|
7186
7328
|
if (df >= threshold) {
|
|
7187
|
-
writes.delete(
|
|
7329
|
+
writes.delete(path19);
|
|
7188
7330
|
awfEmit(void 0, curStat);
|
|
7189
7331
|
} else {
|
|
7190
7332
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
7191
7333
|
}
|
|
7192
7334
|
});
|
|
7193
7335
|
}
|
|
7194
|
-
if (!writes.has(
|
|
7195
|
-
writes.set(
|
|
7336
|
+
if (!writes.has(path19)) {
|
|
7337
|
+
writes.set(path19, {
|
|
7196
7338
|
lastChange: now,
|
|
7197
7339
|
cancelWait: () => {
|
|
7198
|
-
writes.delete(
|
|
7340
|
+
writes.delete(path19);
|
|
7199
7341
|
clearTimeout(timeoutHandler);
|
|
7200
7342
|
return event;
|
|
7201
7343
|
}
|
|
@@ -7206,8 +7348,8 @@ var init_chokidar = __esm({
|
|
|
7206
7348
|
/**
|
|
7207
7349
|
* Determines whether user has asked to ignore this path.
|
|
7208
7350
|
*/
|
|
7209
|
-
_isIgnored(
|
|
7210
|
-
if (this.options.atomic && DOT_RE.test(
|
|
7351
|
+
_isIgnored(path19, stats) {
|
|
7352
|
+
if (this.options.atomic && DOT_RE.test(path19))
|
|
7211
7353
|
return true;
|
|
7212
7354
|
if (!this._userIgnored) {
|
|
7213
7355
|
const { cwd } = this.options;
|
|
@@ -7217,17 +7359,17 @@ var init_chokidar = __esm({
|
|
|
7217
7359
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
7218
7360
|
this._userIgnored = anymatch(list, void 0);
|
|
7219
7361
|
}
|
|
7220
|
-
return this._userIgnored(
|
|
7362
|
+
return this._userIgnored(path19, stats);
|
|
7221
7363
|
}
|
|
7222
|
-
_isntIgnored(
|
|
7223
|
-
return !this._isIgnored(
|
|
7364
|
+
_isntIgnored(path19, stat4) {
|
|
7365
|
+
return !this._isIgnored(path19, stat4);
|
|
7224
7366
|
}
|
|
7225
7367
|
/**
|
|
7226
7368
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
7227
7369
|
* @param path file or directory pattern being watched
|
|
7228
7370
|
*/
|
|
7229
|
-
_getWatchHelpers(
|
|
7230
|
-
return new WatchHelper(
|
|
7371
|
+
_getWatchHelpers(path19) {
|
|
7372
|
+
return new WatchHelper(path19, this.options.followSymlinks, this);
|
|
7231
7373
|
}
|
|
7232
7374
|
// Directory helpers
|
|
7233
7375
|
// -----------------
|
|
@@ -7259,63 +7401,63 @@ var init_chokidar = __esm({
|
|
|
7259
7401
|
* @param item base path of item/directory
|
|
7260
7402
|
*/
|
|
7261
7403
|
_remove(directory, item, isDirectory) {
|
|
7262
|
-
const
|
|
7263
|
-
const fullPath = sp2.resolve(
|
|
7264
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
7265
|
-
if (!this._throttle("remove",
|
|
7404
|
+
const path19 = sp2.join(directory, item);
|
|
7405
|
+
const fullPath = sp2.resolve(path19);
|
|
7406
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path19) || this._watched.has(fullPath);
|
|
7407
|
+
if (!this._throttle("remove", path19, 100))
|
|
7266
7408
|
return;
|
|
7267
7409
|
if (!isDirectory && this._watched.size === 1) {
|
|
7268
7410
|
this.add(directory, item, true);
|
|
7269
7411
|
}
|
|
7270
|
-
const wp = this._getWatchedDir(
|
|
7412
|
+
const wp = this._getWatchedDir(path19);
|
|
7271
7413
|
const nestedDirectoryChildren = wp.getChildren();
|
|
7272
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
7414
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path19, nested));
|
|
7273
7415
|
const parent = this._getWatchedDir(directory);
|
|
7274
7416
|
const wasTracked = parent.has(item);
|
|
7275
7417
|
parent.remove(item);
|
|
7276
7418
|
if (this._symlinkPaths.has(fullPath)) {
|
|
7277
7419
|
this._symlinkPaths.delete(fullPath);
|
|
7278
7420
|
}
|
|
7279
|
-
let relPath =
|
|
7421
|
+
let relPath = path19;
|
|
7280
7422
|
if (this.options.cwd)
|
|
7281
|
-
relPath = sp2.relative(this.options.cwd,
|
|
7423
|
+
relPath = sp2.relative(this.options.cwd, path19);
|
|
7282
7424
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
7283
7425
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
7284
7426
|
if (event === EVENTS.ADD)
|
|
7285
7427
|
return;
|
|
7286
7428
|
}
|
|
7287
|
-
this._watched.delete(
|
|
7429
|
+
this._watched.delete(path19);
|
|
7288
7430
|
this._watched.delete(fullPath);
|
|
7289
7431
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
7290
|
-
if (wasTracked && !this._isIgnored(
|
|
7291
|
-
this._emit(eventName,
|
|
7292
|
-
this._closePath(
|
|
7432
|
+
if (wasTracked && !this._isIgnored(path19))
|
|
7433
|
+
this._emit(eventName, path19);
|
|
7434
|
+
this._closePath(path19);
|
|
7293
7435
|
}
|
|
7294
7436
|
/**
|
|
7295
7437
|
* Closes all watchers for a path
|
|
7296
7438
|
*/
|
|
7297
|
-
_closePath(
|
|
7298
|
-
this._closeFile(
|
|
7299
|
-
const dir = sp2.dirname(
|
|
7300
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
7439
|
+
_closePath(path19) {
|
|
7440
|
+
this._closeFile(path19);
|
|
7441
|
+
const dir = sp2.dirname(path19);
|
|
7442
|
+
this._getWatchedDir(dir).remove(sp2.basename(path19));
|
|
7301
7443
|
}
|
|
7302
7444
|
/**
|
|
7303
7445
|
* Closes only file-specific watchers
|
|
7304
7446
|
*/
|
|
7305
|
-
_closeFile(
|
|
7306
|
-
const closers = this._closers.get(
|
|
7447
|
+
_closeFile(path19) {
|
|
7448
|
+
const closers = this._closers.get(path19);
|
|
7307
7449
|
if (!closers)
|
|
7308
7450
|
return;
|
|
7309
7451
|
closers.forEach((closer) => closer());
|
|
7310
|
-
this._closers.delete(
|
|
7452
|
+
this._closers.delete(path19);
|
|
7311
7453
|
}
|
|
7312
|
-
_addPathCloser(
|
|
7454
|
+
_addPathCloser(path19, closer) {
|
|
7313
7455
|
if (!closer)
|
|
7314
7456
|
return;
|
|
7315
|
-
let list = this._closers.get(
|
|
7457
|
+
let list = this._closers.get(path19);
|
|
7316
7458
|
if (!list) {
|
|
7317
7459
|
list = [];
|
|
7318
|
-
this._closers.set(
|
|
7460
|
+
this._closers.set(path19, list);
|
|
7319
7461
|
}
|
|
7320
7462
|
list.push(closer);
|
|
7321
7463
|
}
|
|
@@ -7341,12 +7483,12 @@ var init_chokidar = __esm({
|
|
|
7341
7483
|
});
|
|
7342
7484
|
|
|
7343
7485
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
7344
|
-
var fs5,
|
|
7486
|
+
var fs5, path7, os7, ProviderLoader;
|
|
7345
7487
|
var init_provider_loader = __esm({
|
|
7346
7488
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
7347
7489
|
"use strict";
|
|
7348
7490
|
fs5 = __toESM(require("fs"));
|
|
7349
|
-
|
|
7491
|
+
path7 = __toESM(require("path"));
|
|
7350
7492
|
os7 = __toESM(require("os"));
|
|
7351
7493
|
init_chokidar();
|
|
7352
7494
|
init_ide_detector();
|
|
@@ -7368,12 +7510,12 @@ var init_provider_loader = __esm({
|
|
|
7368
7510
|
static META_FILE = ".meta.json";
|
|
7369
7511
|
constructor(options) {
|
|
7370
7512
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
7371
|
-
const defaultProvidersDir =
|
|
7513
|
+
const defaultProvidersDir = path7.join(os7.homedir(), ".adhdev", "providers");
|
|
7372
7514
|
if (options?.userDir) {
|
|
7373
7515
|
this.userDir = options.userDir;
|
|
7374
7516
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
7375
7517
|
} else {
|
|
7376
|
-
const localRepoPath =
|
|
7518
|
+
const localRepoPath = path7.resolve(__dirname, "../../../../../adhdev-providers");
|
|
7377
7519
|
if (fs5.existsSync(localRepoPath)) {
|
|
7378
7520
|
this.userDir = localRepoPath;
|
|
7379
7521
|
this.log(`Auto-detected local public repository: ${this.userDir} (Dev workspace speedup)`);
|
|
@@ -7382,7 +7524,7 @@ var init_provider_loader = __esm({
|
|
|
7382
7524
|
this.log(`Using default user providers directory: ${this.userDir}`);
|
|
7383
7525
|
}
|
|
7384
7526
|
}
|
|
7385
|
-
this.upstreamDir =
|
|
7527
|
+
this.upstreamDir = path7.join(defaultProvidersDir, ".upstream");
|
|
7386
7528
|
this.disableUpstream = options?.disableUpstream ?? false;
|
|
7387
7529
|
}
|
|
7388
7530
|
log(msg) {
|
|
@@ -7412,7 +7554,7 @@ var init_provider_loader = __esm({
|
|
|
7412
7554
|
* Canonical provider directory shape for a given root.
|
|
7413
7555
|
*/
|
|
7414
7556
|
getProviderDir(root, category, type) {
|
|
7415
|
-
return
|
|
7557
|
+
return path7.join(root, category, type);
|
|
7416
7558
|
}
|
|
7417
7559
|
/**
|
|
7418
7560
|
* Canonical user override directory for a provider.
|
|
@@ -7439,7 +7581,7 @@ var init_provider_loader = __esm({
|
|
|
7439
7581
|
resolveProviderFile(type, ...segments) {
|
|
7440
7582
|
const dir = this.findProviderDirInternal(type);
|
|
7441
7583
|
if (!dir) return null;
|
|
7442
|
-
return
|
|
7584
|
+
return path7.join(dir, ...segments);
|
|
7443
7585
|
}
|
|
7444
7586
|
/**
|
|
7445
7587
|
* Load all providers (3-tier priority)
|
|
@@ -7477,7 +7619,7 @@ var init_provider_loader = __esm({
|
|
|
7477
7619
|
if (!fs5.existsSync(this.upstreamDir)) return false;
|
|
7478
7620
|
try {
|
|
7479
7621
|
return fs5.readdirSync(this.upstreamDir).some(
|
|
7480
|
-
(d) => fs5.statSync(
|
|
7622
|
+
(d) => fs5.statSync(path7.join(this.upstreamDir, d)).isDirectory()
|
|
7481
7623
|
);
|
|
7482
7624
|
} catch {
|
|
7483
7625
|
return false;
|
|
@@ -7769,14 +7911,14 @@ var init_provider_loader = __esm({
|
|
|
7769
7911
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
7770
7912
|
return null;
|
|
7771
7913
|
}
|
|
7772
|
-
const dir =
|
|
7914
|
+
const dir = path7.join(providerDir, scriptDir);
|
|
7773
7915
|
if (!fs5.existsSync(dir)) {
|
|
7774
7916
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
7775
7917
|
return null;
|
|
7776
7918
|
}
|
|
7777
7919
|
const cached2 = this.scriptsCache.get(dir);
|
|
7778
7920
|
if (cached2) return cached2;
|
|
7779
|
-
const scriptsJs =
|
|
7921
|
+
const scriptsJs = path7.join(dir, "scripts.js");
|
|
7780
7922
|
if (fs5.existsSync(scriptsJs)) {
|
|
7781
7923
|
try {
|
|
7782
7924
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -7815,7 +7957,7 @@ var init_provider_loader = __esm({
|
|
|
7815
7957
|
});
|
|
7816
7958
|
const handleChange = (filePath) => {
|
|
7817
7959
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
7818
|
-
this.log(`File changed: ${
|
|
7960
|
+
this.log(`File changed: ${path7.basename(filePath)}, reloading...`);
|
|
7819
7961
|
this.reload();
|
|
7820
7962
|
}
|
|
7821
7963
|
};
|
|
@@ -7870,7 +8012,7 @@ var init_provider_loader = __esm({
|
|
|
7870
8012
|
}
|
|
7871
8013
|
const https = require("https");
|
|
7872
8014
|
const { execSync: execSync7 } = require("child_process");
|
|
7873
|
-
const metaPath =
|
|
8015
|
+
const metaPath = path7.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
7874
8016
|
let prevEtag = "";
|
|
7875
8017
|
let prevTimestamp = 0;
|
|
7876
8018
|
try {
|
|
@@ -7887,7 +8029,7 @@ var init_provider_loader = __esm({
|
|
|
7887
8029
|
return { updated: false };
|
|
7888
8030
|
}
|
|
7889
8031
|
try {
|
|
7890
|
-
const etag = await new Promise((
|
|
8032
|
+
const etag = await new Promise((resolve13, reject) => {
|
|
7891
8033
|
const options = {
|
|
7892
8034
|
method: "HEAD",
|
|
7893
8035
|
hostname: "github.com",
|
|
@@ -7905,7 +8047,7 @@ var init_provider_loader = __esm({
|
|
|
7905
8047
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
7906
8048
|
timeout: 1e4
|
|
7907
8049
|
}, (res2) => {
|
|
7908
|
-
|
|
8050
|
+
resolve13(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
7909
8051
|
});
|
|
7910
8052
|
req2.on("error", reject);
|
|
7911
8053
|
req2.on("timeout", () => {
|
|
@@ -7914,7 +8056,7 @@ var init_provider_loader = __esm({
|
|
|
7914
8056
|
});
|
|
7915
8057
|
req2.end();
|
|
7916
8058
|
} else {
|
|
7917
|
-
|
|
8059
|
+
resolve13(res.headers.etag || res.headers["last-modified"] || "");
|
|
7918
8060
|
}
|
|
7919
8061
|
});
|
|
7920
8062
|
req.on("error", reject);
|
|
@@ -7930,17 +8072,17 @@ var init_provider_loader = __esm({
|
|
|
7930
8072
|
return { updated: false };
|
|
7931
8073
|
}
|
|
7932
8074
|
this.log("Downloading latest providers from GitHub...");
|
|
7933
|
-
const tmpTar =
|
|
7934
|
-
const tmpExtract =
|
|
8075
|
+
const tmpTar = path7.join(os7.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
8076
|
+
const tmpExtract = path7.join(os7.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
7935
8077
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
7936
8078
|
fs5.mkdirSync(tmpExtract, { recursive: true });
|
|
7937
8079
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
7938
8080
|
const extracted = fs5.readdirSync(tmpExtract);
|
|
7939
8081
|
const rootDir = extracted.find(
|
|
7940
|
-
(d) => fs5.statSync(
|
|
8082
|
+
(d) => fs5.statSync(path7.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
7941
8083
|
);
|
|
7942
8084
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
7943
|
-
const sourceDir =
|
|
8085
|
+
const sourceDir = path7.join(tmpExtract, rootDir);
|
|
7944
8086
|
const backupDir = this.upstreamDir + ".bak";
|
|
7945
8087
|
if (fs5.existsSync(this.upstreamDir)) {
|
|
7946
8088
|
if (fs5.existsSync(backupDir)) fs5.rmSync(backupDir, { recursive: true, force: true });
|
|
@@ -7978,7 +8120,7 @@ var init_provider_loader = __esm({
|
|
|
7978
8120
|
downloadFile(url2, destPath) {
|
|
7979
8121
|
const https = require("https");
|
|
7980
8122
|
const http3 = require("http");
|
|
7981
|
-
return new Promise((
|
|
8123
|
+
return new Promise((resolve13, reject) => {
|
|
7982
8124
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
7983
8125
|
if (redirectCount > 5) {
|
|
7984
8126
|
reject(new Error("Too many redirects"));
|
|
@@ -7998,7 +8140,7 @@ var init_provider_loader = __esm({
|
|
|
7998
8140
|
res.pipe(ws2);
|
|
7999
8141
|
ws2.on("finish", () => {
|
|
8000
8142
|
ws2.close();
|
|
8001
|
-
|
|
8143
|
+
resolve13();
|
|
8002
8144
|
});
|
|
8003
8145
|
ws2.on("error", reject);
|
|
8004
8146
|
});
|
|
@@ -8015,8 +8157,8 @@ var init_provider_loader = __esm({
|
|
|
8015
8157
|
copyDirRecursive(src, dest) {
|
|
8016
8158
|
fs5.mkdirSync(dest, { recursive: true });
|
|
8017
8159
|
for (const entry of fs5.readdirSync(src, { withFileTypes: true })) {
|
|
8018
|
-
const srcPath =
|
|
8019
|
-
const destPath =
|
|
8160
|
+
const srcPath = path7.join(src, entry.name);
|
|
8161
|
+
const destPath = path7.join(dest, entry.name);
|
|
8020
8162
|
if (entry.isDirectory()) {
|
|
8021
8163
|
this.copyDirRecursive(srcPath, destPath);
|
|
8022
8164
|
} else {
|
|
@@ -8027,7 +8169,7 @@ var init_provider_loader = __esm({
|
|
|
8027
8169
|
/** .meta.json save */
|
|
8028
8170
|
writeMeta(metaPath, etag, timestamp) {
|
|
8029
8171
|
try {
|
|
8030
|
-
fs5.mkdirSync(
|
|
8172
|
+
fs5.mkdirSync(path7.dirname(metaPath), { recursive: true });
|
|
8031
8173
|
fs5.writeFileSync(metaPath, JSON.stringify({
|
|
8032
8174
|
etag,
|
|
8033
8175
|
timestamp,
|
|
@@ -8044,7 +8186,7 @@ var init_provider_loader = __esm({
|
|
|
8044
8186
|
const scan = (d) => {
|
|
8045
8187
|
try {
|
|
8046
8188
|
for (const entry of fs5.readdirSync(d, { withFileTypes: true })) {
|
|
8047
|
-
if (entry.isDirectory()) scan(
|
|
8189
|
+
if (entry.isDirectory()) scan(path7.join(d, entry.name));
|
|
8048
8190
|
else if (entry.name === "provider.json") count++;
|
|
8049
8191
|
}
|
|
8050
8192
|
} catch {
|
|
@@ -8143,17 +8285,17 @@ var init_provider_loader = __esm({
|
|
|
8143
8285
|
for (const root of searchRoots) {
|
|
8144
8286
|
if (!fs5.existsSync(root)) continue;
|
|
8145
8287
|
const candidate = this.getProviderDir(root, cat, type);
|
|
8146
|
-
if (fs5.existsSync(
|
|
8147
|
-
const catDir =
|
|
8288
|
+
if (fs5.existsSync(path7.join(candidate, "provider.json"))) return candidate;
|
|
8289
|
+
const catDir = path7.join(root, cat);
|
|
8148
8290
|
if (fs5.existsSync(catDir)) {
|
|
8149
8291
|
try {
|
|
8150
8292
|
for (const entry of fs5.readdirSync(catDir, { withFileTypes: true })) {
|
|
8151
8293
|
if (!entry.isDirectory()) continue;
|
|
8152
|
-
const jsonPath =
|
|
8294
|
+
const jsonPath = path7.join(catDir, entry.name, "provider.json");
|
|
8153
8295
|
if (fs5.existsSync(jsonPath)) {
|
|
8154
8296
|
try {
|
|
8155
8297
|
const data = JSON.parse(fs5.readFileSync(jsonPath, "utf-8"));
|
|
8156
|
-
if (data.type === type) return
|
|
8298
|
+
if (data.type === type) return path7.join(catDir, entry.name);
|
|
8157
8299
|
} catch {
|
|
8158
8300
|
}
|
|
8159
8301
|
}
|
|
@@ -8170,7 +8312,7 @@ var init_provider_loader = __esm({
|
|
|
8170
8312
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
8171
8313
|
*/
|
|
8172
8314
|
buildScriptWrappersFromDir(dir) {
|
|
8173
|
-
const scriptsJs =
|
|
8315
|
+
const scriptsJs = path7.join(dir, "scripts.js");
|
|
8174
8316
|
if (fs5.existsSync(scriptsJs)) {
|
|
8175
8317
|
try {
|
|
8176
8318
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -8184,7 +8326,7 @@ var init_provider_loader = __esm({
|
|
|
8184
8326
|
for (const file2 of fs5.readdirSync(dir)) {
|
|
8185
8327
|
if (!file2.endsWith(".js")) continue;
|
|
8186
8328
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
8187
|
-
const filePath =
|
|
8329
|
+
const filePath = path7.join(dir, file2);
|
|
8188
8330
|
result[scriptName] = (...args) => {
|
|
8189
8331
|
try {
|
|
8190
8332
|
let content = fs5.readFileSync(filePath, "utf-8");
|
|
@@ -8244,7 +8386,7 @@ var init_provider_loader = __esm({
|
|
|
8244
8386
|
}
|
|
8245
8387
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
8246
8388
|
if (hasJson) {
|
|
8247
|
-
const jsonPath =
|
|
8389
|
+
const jsonPath = path7.join(d, "provider.json");
|
|
8248
8390
|
try {
|
|
8249
8391
|
const raw = fs5.readFileSync(jsonPath, "utf-8");
|
|
8250
8392
|
const mod = JSON.parse(raw);
|
|
@@ -8257,7 +8399,7 @@ var init_provider_loader = __esm({
|
|
|
8257
8399
|
delete mod.extensionIdPattern_flags;
|
|
8258
8400
|
}
|
|
8259
8401
|
const hasCompatibility = Array.isArray(mod.compatibility);
|
|
8260
|
-
const scriptsPath =
|
|
8402
|
+
const scriptsPath = path7.join(d, "scripts.js");
|
|
8261
8403
|
if (!hasCompatibility && fs5.existsSync(scriptsPath)) {
|
|
8262
8404
|
try {
|
|
8263
8405
|
delete require.cache[require.resolve(scriptsPath)];
|
|
@@ -8283,7 +8425,7 @@ var init_provider_loader = __esm({
|
|
|
8283
8425
|
if (!entry.isDirectory()) continue;
|
|
8284
8426
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
8285
8427
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
8286
|
-
scan(
|
|
8428
|
+
scan(path7.join(d, entry.name));
|
|
8287
8429
|
}
|
|
8288
8430
|
}
|
|
8289
8431
|
};
|
|
@@ -8364,17 +8506,17 @@ async function findFreePort(ports) {
|
|
|
8364
8506
|
throw new Error("No free port found");
|
|
8365
8507
|
}
|
|
8366
8508
|
function checkPortFree(port) {
|
|
8367
|
-
return new Promise((
|
|
8509
|
+
return new Promise((resolve13) => {
|
|
8368
8510
|
const server = net.createServer();
|
|
8369
8511
|
server.unref();
|
|
8370
|
-
server.on("error", () =>
|
|
8512
|
+
server.on("error", () => resolve13(false));
|
|
8371
8513
|
server.listen(port, "127.0.0.1", () => {
|
|
8372
|
-
server.close(() =>
|
|
8514
|
+
server.close(() => resolve13(true));
|
|
8373
8515
|
});
|
|
8374
8516
|
});
|
|
8375
8517
|
}
|
|
8376
8518
|
async function isCdpActive(port) {
|
|
8377
|
-
return new Promise((
|
|
8519
|
+
return new Promise((resolve13) => {
|
|
8378
8520
|
const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
8379
8521
|
timeout: 2e3
|
|
8380
8522
|
}, (res) => {
|
|
@@ -8383,16 +8525,16 @@ async function isCdpActive(port) {
|
|
|
8383
8525
|
res.on("end", () => {
|
|
8384
8526
|
try {
|
|
8385
8527
|
const info = JSON.parse(data);
|
|
8386
|
-
|
|
8528
|
+
resolve13(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
8387
8529
|
} catch {
|
|
8388
|
-
|
|
8530
|
+
resolve13(false);
|
|
8389
8531
|
}
|
|
8390
8532
|
});
|
|
8391
8533
|
});
|
|
8392
|
-
req.on("error", () =>
|
|
8534
|
+
req.on("error", () => resolve13(false));
|
|
8393
8535
|
req.on("timeout", () => {
|
|
8394
8536
|
req.destroy();
|
|
8395
|
-
|
|
8537
|
+
resolve13(false);
|
|
8396
8538
|
});
|
|
8397
8539
|
});
|
|
8398
8540
|
}
|
|
@@ -8511,8 +8653,8 @@ function detectCurrentWorkspace(ideId) {
|
|
|
8511
8653
|
const appNameMap = getMacAppIdentifiers();
|
|
8512
8654
|
const appName = appNameMap[ideId];
|
|
8513
8655
|
if (appName) {
|
|
8514
|
-
const storagePath =
|
|
8515
|
-
process.env.APPDATA ||
|
|
8656
|
+
const storagePath = path8.join(
|
|
8657
|
+
process.env.APPDATA || path8.join(os8.homedir(), "AppData", "Roaming"),
|
|
8516
8658
|
appName,
|
|
8517
8659
|
"storage.json"
|
|
8518
8660
|
);
|
|
@@ -8678,14 +8820,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
8678
8820
|
function getAvailableIdeIds() {
|
|
8679
8821
|
return getProviderLoader().getAvailableIdeTypes();
|
|
8680
8822
|
}
|
|
8681
|
-
var import_child_process4, net, os8,
|
|
8823
|
+
var import_child_process4, net, os8, path8, _providerLoader;
|
|
8682
8824
|
var init_launch = __esm({
|
|
8683
8825
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
8684
8826
|
"use strict";
|
|
8685
8827
|
import_child_process4 = require("child_process");
|
|
8686
8828
|
net = __toESM(require("net"));
|
|
8687
8829
|
os8 = __toESM(require("os"));
|
|
8688
|
-
|
|
8830
|
+
path8 = __toESM(require("path"));
|
|
8689
8831
|
init_ide_detector();
|
|
8690
8832
|
init_provider_loader();
|
|
8691
8833
|
_providerLoader = null;
|
|
@@ -8716,7 +8858,7 @@ function checkRotation() {
|
|
|
8716
8858
|
const today = getDateStr2();
|
|
8717
8859
|
if (today !== currentDate2) {
|
|
8718
8860
|
currentDate2 = today;
|
|
8719
|
-
currentFile =
|
|
8861
|
+
currentFile = path9.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
8720
8862
|
cleanOldFiles();
|
|
8721
8863
|
}
|
|
8722
8864
|
}
|
|
@@ -8730,7 +8872,7 @@ function cleanOldFiles() {
|
|
|
8730
8872
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
8731
8873
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
8732
8874
|
try {
|
|
8733
|
-
fs6.unlinkSync(
|
|
8875
|
+
fs6.unlinkSync(path9.join(LOG_DIR2, file2));
|
|
8734
8876
|
} catch {
|
|
8735
8877
|
}
|
|
8736
8878
|
}
|
|
@@ -8797,14 +8939,14 @@ function getRecentCommands(count = 50) {
|
|
|
8797
8939
|
return [];
|
|
8798
8940
|
}
|
|
8799
8941
|
}
|
|
8800
|
-
var fs6,
|
|
8942
|
+
var fs6, path9, os9, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
8801
8943
|
var init_command_log = __esm({
|
|
8802
8944
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
8803
8945
|
"use strict";
|
|
8804
8946
|
fs6 = __toESM(require("fs"));
|
|
8805
|
-
|
|
8947
|
+
path9 = __toESM(require("path"));
|
|
8806
8948
|
os9 = __toESM(require("os"));
|
|
8807
|
-
LOG_DIR2 = process.platform === "win32" ?
|
|
8949
|
+
LOG_DIR2 = process.platform === "win32" ? path9.join(process.env.LOCALAPPDATA || process.env.APPDATA || path9.join(os9.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path9.join(os9.homedir(), "Library", "Logs", "adhdev") : path9.join(os9.homedir(), ".local", "share", "adhdev", "logs");
|
|
8808
8950
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
8809
8951
|
MAX_DAYS = 7;
|
|
8810
8952
|
try {
|
|
@@ -8823,7 +8965,7 @@ var init_command_log = __esm({
|
|
|
8823
8965
|
"text"
|
|
8824
8966
|
]);
|
|
8825
8967
|
currentDate2 = getDateStr2();
|
|
8826
|
-
currentFile =
|
|
8968
|
+
currentFile = path9.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
8827
8969
|
writeCount2 = 0;
|
|
8828
8970
|
SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
8829
8971
|
"heartbeat",
|
|
@@ -8845,6 +8987,7 @@ var init_router = __esm({
|
|
|
8845
8987
|
init_workspaces();
|
|
8846
8988
|
init_workspace_activity();
|
|
8847
8989
|
init_config();
|
|
8990
|
+
init_recent_activity();
|
|
8848
8991
|
init_ide_detector();
|
|
8849
8992
|
init_logger();
|
|
8850
8993
|
init_command_log();
|
|
@@ -9003,9 +9146,27 @@ var init_router = __esm({
|
|
|
9003
9146
|
this.deps.onIdeConnected?.();
|
|
9004
9147
|
if (result.success && resolvedWorkspace) {
|
|
9005
9148
|
try {
|
|
9006
|
-
|
|
9149
|
+
let next = appendWorkspaceActivity(loadConfig(), resolvedWorkspace, {
|
|
9007
9150
|
kind: "ide",
|
|
9008
9151
|
agentType: result.ideId
|
|
9152
|
+
});
|
|
9153
|
+
next = appendRecentActivity(next, {
|
|
9154
|
+
kind: "ide",
|
|
9155
|
+
providerType: result.ideId || ideKey,
|
|
9156
|
+
providerName: result.ideId || ideKey,
|
|
9157
|
+
workspace: resolvedWorkspace,
|
|
9158
|
+
title: result.ideId || ideKey
|
|
9159
|
+
});
|
|
9160
|
+
saveConfig(next);
|
|
9161
|
+
} catch {
|
|
9162
|
+
}
|
|
9163
|
+
} else if (result.success && (result.ideId || ideKey)) {
|
|
9164
|
+
try {
|
|
9165
|
+
saveConfig(appendRecentActivity(loadConfig(), {
|
|
9166
|
+
kind: "ide",
|
|
9167
|
+
providerType: result.ideId || ideKey,
|
|
9168
|
+
providerName: result.ideId || ideKey,
|
|
9169
|
+
title: result.ideId || ideKey
|
|
9009
9170
|
}));
|
|
9010
9171
|
} catch {
|
|
9011
9172
|
}
|
|
@@ -9025,6 +9186,30 @@ var init_router = __esm({
|
|
|
9025
9186
|
updateConfig({ userName: name });
|
|
9026
9187
|
return { success: true, userName: name };
|
|
9027
9188
|
}
|
|
9189
|
+
case "mark_recent_seen": {
|
|
9190
|
+
const kind = args?.kind;
|
|
9191
|
+
const providerType = args?.providerType;
|
|
9192
|
+
if (!kind || !providerType) {
|
|
9193
|
+
return { success: false, error: "kind and providerType are required" };
|
|
9194
|
+
}
|
|
9195
|
+
const recentKey = args?.recentKey || buildRecentActivityKey({
|
|
9196
|
+
kind,
|
|
9197
|
+
providerType,
|
|
9198
|
+
workspace: args?.workspace || null
|
|
9199
|
+
});
|
|
9200
|
+
const next = markRecentSessionSeen(
|
|
9201
|
+
loadConfig(),
|
|
9202
|
+
recentKey,
|
|
9203
|
+
typeof args?.seenAt === "number" ? args.seenAt : Date.now()
|
|
9204
|
+
);
|
|
9205
|
+
saveConfig(next);
|
|
9206
|
+
this.deps.onStatusChange?.();
|
|
9207
|
+
return {
|
|
9208
|
+
success: true,
|
|
9209
|
+
recentKey,
|
|
9210
|
+
seenAt: next.recentSessionReads?.[recentKey] || Date.now()
|
|
9211
|
+
};
|
|
9212
|
+
}
|
|
9028
9213
|
// ─── Daemon Self-Upgrade ───
|
|
9029
9214
|
case "daemon_upgrade": {
|
|
9030
9215
|
LOG.info("Upgrade", "Remote upgrade requested from dashboard");
|
|
@@ -9043,9 +9228,9 @@ var init_router = __esm({
|
|
|
9043
9228
|
setTimeout(() => {
|
|
9044
9229
|
LOG.info("Upgrade", "Restarting daemon with new version...");
|
|
9045
9230
|
try {
|
|
9046
|
-
const
|
|
9231
|
+
const path19 = require("path");
|
|
9047
9232
|
const fs16 = require("fs");
|
|
9048
|
-
const pidFile =
|
|
9233
|
+
const pidFile = path19.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
|
|
9049
9234
|
if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
|
|
9050
9235
|
} catch {
|
|
9051
9236
|
}
|
|
@@ -9139,263 +9324,6 @@ var init_router = __esm({
|
|
|
9139
9324
|
}
|
|
9140
9325
|
});
|
|
9141
9326
|
|
|
9142
|
-
// ../../oss/packages/daemon-core/src/status/snapshot.ts
|
|
9143
|
-
function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
|
|
9144
|
-
return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
|
|
9145
|
-
id: ide.id,
|
|
9146
|
-
type: ide.id,
|
|
9147
|
-
name: ide.displayName || ide.name || ide.id,
|
|
9148
|
-
running: isCdpConnected(cdpManagers, ide.id),
|
|
9149
|
-
...ide.path ? { path: ide.path } : {}
|
|
9150
|
-
}));
|
|
9151
|
-
}
|
|
9152
|
-
function buildAvailableProviders(providerLoader) {
|
|
9153
|
-
return providerLoader.getAll().map((provider) => ({
|
|
9154
|
-
type: provider.type,
|
|
9155
|
-
name: provider.displayName || provider.type,
|
|
9156
|
-
displayName: provider.displayName || provider.type,
|
|
9157
|
-
icon: provider.icon || "\u{1F4BB}",
|
|
9158
|
-
category: provider.category
|
|
9159
|
-
}));
|
|
9160
|
-
}
|
|
9161
|
-
function buildStatusSnapshot(options) {
|
|
9162
|
-
const cfg = loadConfig();
|
|
9163
|
-
const wsState = getWorkspaceState(cfg);
|
|
9164
|
-
const memSnap = getHostMemorySnapshot();
|
|
9165
|
-
const sessions = buildSessionEntries(
|
|
9166
|
-
options.allStates,
|
|
9167
|
-
options.cdpManagers
|
|
9168
|
-
);
|
|
9169
|
-
return {
|
|
9170
|
-
instanceId: options.instanceId,
|
|
9171
|
-
version: options.version,
|
|
9172
|
-
daemonMode: options.daemonMode,
|
|
9173
|
-
machine: {
|
|
9174
|
-
hostname: os10.hostname(),
|
|
9175
|
-
platform: os10.platform(),
|
|
9176
|
-
arch: os10.arch(),
|
|
9177
|
-
cpus: os10.cpus().length,
|
|
9178
|
-
totalMem: memSnap.totalMem,
|
|
9179
|
-
freeMem: memSnap.freeMem,
|
|
9180
|
-
availableMem: memSnap.availableMem,
|
|
9181
|
-
loadavg: os10.loadavg(),
|
|
9182
|
-
uptime: os10.uptime(),
|
|
9183
|
-
release: os10.release()
|
|
9184
|
-
},
|
|
9185
|
-
machineNickname: options.machineNickname ?? cfg.machineNickname ?? null,
|
|
9186
|
-
timestamp: options.timestamp ?? Date.now(),
|
|
9187
|
-
detectedIdes: buildDetectedIdeInfos(options.detectedIdes, options.cdpManagers),
|
|
9188
|
-
...options.p2p ? { p2p: options.p2p } : {},
|
|
9189
|
-
sessions,
|
|
9190
|
-
workspaces: wsState.workspaces,
|
|
9191
|
-
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
9192
|
-
defaultWorkspacePath: wsState.defaultWorkspacePath,
|
|
9193
|
-
workspaceActivity: getWorkspaceActivity(cfg, 15),
|
|
9194
|
-
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
9195
|
-
};
|
|
9196
|
-
}
|
|
9197
|
-
var os10;
|
|
9198
|
-
var init_snapshot = __esm({
|
|
9199
|
-
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
9200
|
-
"use strict";
|
|
9201
|
-
os10 = __toESM(require("os"));
|
|
9202
|
-
init_config();
|
|
9203
|
-
init_workspaces();
|
|
9204
|
-
init_workspace_activity();
|
|
9205
|
-
init_host_memory();
|
|
9206
|
-
init_builders();
|
|
9207
|
-
}
|
|
9208
|
-
});
|
|
9209
|
-
|
|
9210
|
-
// ../../oss/packages/daemon-core/src/status/reporter.ts
|
|
9211
|
-
var DaemonStatusReporter;
|
|
9212
|
-
var init_reporter = __esm({
|
|
9213
|
-
"../../oss/packages/daemon-core/src/status/reporter.ts"() {
|
|
9214
|
-
"use strict";
|
|
9215
|
-
init_logger();
|
|
9216
|
-
init_builders();
|
|
9217
|
-
init_snapshot();
|
|
9218
|
-
DaemonStatusReporter = class {
|
|
9219
|
-
deps;
|
|
9220
|
-
log;
|
|
9221
|
-
lastStatusSentAt = 0;
|
|
9222
|
-
statusPendingThrottle = false;
|
|
9223
|
-
lastP2PStatusHash = "";
|
|
9224
|
-
lastStatusSummary = "";
|
|
9225
|
-
statusTimer = null;
|
|
9226
|
-
p2pTimer = null;
|
|
9227
|
-
constructor(deps, opts) {
|
|
9228
|
-
this.deps = deps;
|
|
9229
|
-
this.log = opts?.logFn || LOG.forComponent("Status").asLogFn();
|
|
9230
|
-
}
|
|
9231
|
-
// ─── Lifecycle ───────────────────────────────────
|
|
9232
|
-
startReporting() {
|
|
9233
|
-
setTimeout(() => {
|
|
9234
|
-
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Initial report failed: ${e?.message}`));
|
|
9235
|
-
}, 2e3);
|
|
9236
|
-
const scheduleServerReport = () => {
|
|
9237
|
-
this.statusTimer = setTimeout(() => {
|
|
9238
|
-
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Periodic report failed: ${e?.message}`));
|
|
9239
|
-
scheduleServerReport();
|
|
9240
|
-
}, 3e4);
|
|
9241
|
-
};
|
|
9242
|
-
scheduleServerReport();
|
|
9243
|
-
this.p2pTimer = setInterval(() => {
|
|
9244
|
-
if (this.deps.p2p?.isConnected) {
|
|
9245
|
-
this.sendUnifiedStatusReport({ p2pOnly: true }).catch((e) => LOG.warn("Status", `P2P status send failed: ${e?.message}`));
|
|
9246
|
-
}
|
|
9247
|
-
}, 5e3);
|
|
9248
|
-
}
|
|
9249
|
-
stopReporting() {
|
|
9250
|
-
if (this.statusTimer) {
|
|
9251
|
-
clearTimeout(this.statusTimer);
|
|
9252
|
-
this.statusTimer = null;
|
|
9253
|
-
}
|
|
9254
|
-
if (this.p2pTimer) {
|
|
9255
|
-
clearInterval(this.p2pTimer);
|
|
9256
|
-
this.p2pTimer = null;
|
|
9257
|
-
}
|
|
9258
|
-
}
|
|
9259
|
-
onStatusChange() {
|
|
9260
|
-
this.throttledReport();
|
|
9261
|
-
}
|
|
9262
|
-
throttledReport() {
|
|
9263
|
-
const now = Date.now();
|
|
9264
|
-
const elapsed = now - this.lastStatusSentAt;
|
|
9265
|
-
if (elapsed >= 5e3) {
|
|
9266
|
-
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Throttled report failed: ${e?.message}`));
|
|
9267
|
-
} else if (!this.statusPendingThrottle) {
|
|
9268
|
-
this.statusPendingThrottle = true;
|
|
9269
|
-
setTimeout(() => {
|
|
9270
|
-
this.statusPendingThrottle = false;
|
|
9271
|
-
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Deferred report failed: ${e?.message}`));
|
|
9272
|
-
}, 5e3 - elapsed);
|
|
9273
|
-
}
|
|
9274
|
-
}
|
|
9275
|
-
emitStatusEvent(event) {
|
|
9276
|
-
LOG.info("StatusEvent", `${event.event} (${event.providerType || event.ideType || ""})`);
|
|
9277
|
-
this.deps.serverConn?.sendMessage("status_event", event);
|
|
9278
|
-
}
|
|
9279
|
-
removeAgentTracking(_key) {
|
|
9280
|
-
}
|
|
9281
|
-
// (agent-stream polling backward compat)
|
|
9282
|
-
updateAgentStreams(_ideType, _streams) {
|
|
9283
|
-
}
|
|
9284
|
-
/** Reset P2P dedup hash — forces next send to transmit even if content unchanged */
|
|
9285
|
-
resetP2PHash() {
|
|
9286
|
-
this.lastP2PStatusHash = "";
|
|
9287
|
-
}
|
|
9288
|
-
// ─── Core ────────────────────────────────────────
|
|
9289
|
-
ts() {
|
|
9290
|
-
return (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
9291
|
-
}
|
|
9292
|
-
async sendUnifiedStatusReport(opts) {
|
|
9293
|
-
const { serverConn, p2p } = this.deps;
|
|
9294
|
-
if (!serverConn?.isConnected()) return;
|
|
9295
|
-
this.lastStatusSentAt = Date.now();
|
|
9296
|
-
const now = this.lastStatusSentAt;
|
|
9297
|
-
const target = opts?.p2pOnly ? "P2P" : "P2P+Server";
|
|
9298
|
-
const allStates = this.deps.instanceManager.collectAllStates();
|
|
9299
|
-
const ideStates = allStates.filter((s15) => s15.category === "ide");
|
|
9300
|
-
const cliStates = allStates.filter((s15) => s15.category === "cli");
|
|
9301
|
-
const acpStates = allStates.filter((s15) => s15.category === "acp");
|
|
9302
|
-
const ideSummary = ideStates.map((s15) => {
|
|
9303
|
-
const msgs = s15.activeChat?.messages?.length || 0;
|
|
9304
|
-
const exts = s15.extensions.length;
|
|
9305
|
-
return `${s15.type}(${s15.status},${msgs}msg,${exts}ext${s15.currentModel ? ",model=" + s15.currentModel : ""})`;
|
|
9306
|
-
}).join(", ");
|
|
9307
|
-
const cliSummary = cliStates.map((s15) => `${s15.type}(${s15.status})`).join(", ");
|
|
9308
|
-
const acpSummary = acpStates.map((s15) => `${s15.type}(${s15.status})`).join(", ");
|
|
9309
|
-
const logLevel = opts?.p2pOnly ? "debug" : "info";
|
|
9310
|
-
const baseSummary = `IDE: ${ideStates.length} [${ideSummary}] CLI: ${cliStates.length} [${cliSummary}] ACP: ${acpStates.length} [${acpSummary}]`;
|
|
9311
|
-
const summaryChanged = baseSummary !== this.lastStatusSummary;
|
|
9312
|
-
if (summaryChanged) {
|
|
9313
|
-
this.lastStatusSummary = baseSummary;
|
|
9314
|
-
if (logLevel === "debug") {
|
|
9315
|
-
LOG.debug("StatusReport", `\u2192${target} ${baseSummary}`);
|
|
9316
|
-
} else {
|
|
9317
|
-
LOG.info("StatusReport", `\u2192${target} ${baseSummary}`);
|
|
9318
|
-
}
|
|
9319
|
-
}
|
|
9320
|
-
const sessions = buildSessionEntries(
|
|
9321
|
-
allStates,
|
|
9322
|
-
this.deps.cdpManagers
|
|
9323
|
-
);
|
|
9324
|
-
const payload = {
|
|
9325
|
-
...buildStatusSnapshot({
|
|
9326
|
-
allStates,
|
|
9327
|
-
cdpManagers: this.deps.cdpManagers,
|
|
9328
|
-
providerLoader: this.deps.providerLoader,
|
|
9329
|
-
detectedIdes: this.deps.detectedIdes || [],
|
|
9330
|
-
instanceId: this.deps.instanceId,
|
|
9331
|
-
version: this.deps.daemonVersion || "unknown",
|
|
9332
|
-
daemonMode: true,
|
|
9333
|
-
timestamp: now,
|
|
9334
|
-
p2p: {
|
|
9335
|
-
available: p2p?.isAvailable || false,
|
|
9336
|
-
state: p2p?.connectionState || "unavailable",
|
|
9337
|
-
peers: p2p?.connectedPeerCount || 0,
|
|
9338
|
-
screenshotActive: p2p?.screenshotActive || false
|
|
9339
|
-
}
|
|
9340
|
-
}),
|
|
9341
|
-
screenshotUsage: this.deps.getScreenshotUsage?.() || null,
|
|
9342
|
-
connectedExtensions: []
|
|
9343
|
-
};
|
|
9344
|
-
const p2pSent = this.sendP2PPayload(payload);
|
|
9345
|
-
if (p2pSent) {
|
|
9346
|
-
LOG.debug("P2P", `sent (${JSON.stringify(payload).length} bytes)`);
|
|
9347
|
-
}
|
|
9348
|
-
if (opts?.p2pOnly) return;
|
|
9349
|
-
const wsPayload = {
|
|
9350
|
-
daemonMode: true,
|
|
9351
|
-
sessions: sessions.map((session) => ({
|
|
9352
|
-
id: session.id,
|
|
9353
|
-
parentId: session.parentId,
|
|
9354
|
-
providerType: session.providerType,
|
|
9355
|
-
providerName: session.providerName,
|
|
9356
|
-
kind: session.kind,
|
|
9357
|
-
transport: session.transport,
|
|
9358
|
-
status: session.status,
|
|
9359
|
-
workspace: session.workspace,
|
|
9360
|
-
title: session.title,
|
|
9361
|
-
cdpConnected: session.cdpConnected,
|
|
9362
|
-
currentModel: session.currentModel,
|
|
9363
|
-
currentPlan: session.currentPlan,
|
|
9364
|
-
currentAutoApprove: session.currentAutoApprove
|
|
9365
|
-
})),
|
|
9366
|
-
p2p: payload.p2p,
|
|
9367
|
-
timestamp: now
|
|
9368
|
-
};
|
|
9369
|
-
serverConn.sendMessage("status_report", wsPayload);
|
|
9370
|
-
LOG.debug("Server", `sent status_report (${JSON.stringify(wsPayload).length} bytes)`);
|
|
9371
|
-
}
|
|
9372
|
-
// ─── P2P ─────────────────────────────────────────
|
|
9373
|
-
sendP2PPayload(payload) {
|
|
9374
|
-
const { timestamp: _ts, system: _sys, ...hashTarget } = payload;
|
|
9375
|
-
if (hashTarget.machine) {
|
|
9376
|
-
const { freeMem: _f, availableMem: _a2, loadavg: _l2, uptime: _u, ...stableMachine } = hashTarget.machine;
|
|
9377
|
-
hashTarget.machine = stableMachine;
|
|
9378
|
-
}
|
|
9379
|
-
const h = this.simpleHash(JSON.stringify(hashTarget));
|
|
9380
|
-
if (h !== this.lastP2PStatusHash) {
|
|
9381
|
-
this.lastP2PStatusHash = h;
|
|
9382
|
-
this.deps.p2p?.sendStatus(payload);
|
|
9383
|
-
return true;
|
|
9384
|
-
}
|
|
9385
|
-
return false;
|
|
9386
|
-
}
|
|
9387
|
-
simpleHash(s15) {
|
|
9388
|
-
let h = 2166136261;
|
|
9389
|
-
for (let i = 0; i < s15.length; i++) {
|
|
9390
|
-
h ^= s15.charCodeAt(i);
|
|
9391
|
-
h = h * 16777619 >>> 0;
|
|
9392
|
-
}
|
|
9393
|
-
return h.toString(36);
|
|
9394
|
-
}
|
|
9395
|
-
};
|
|
9396
|
-
}
|
|
9397
|
-
});
|
|
9398
|
-
|
|
9399
9327
|
// ../../oss/packages/daemon-core/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts
|
|
9400
9328
|
function isModuleNotFoundError(error48, ref) {
|
|
9401
9329
|
if (!(error48 instanceof Error)) return false;
|
|
@@ -10223,7 +10151,7 @@ function Ec(s15, t) {
|
|
|
10223
10151
|
function Tc(s15) {
|
|
10224
10152
|
return s15.keyCode === 16 || s15.keyCode === 17 || s15.keyCode === 18;
|
|
10225
10153
|
}
|
|
10226
|
-
var zs, Rl, Ll, M, S, Gs, mi, $s, _i, er, tr, ir, we, De, rt, q, js, Hn, Fn, F, rr, ge, Zs, xt, nr, H, sr, Js, Be, wt, nt, ae, Dt, ce, Qs, or, Re, lr, Wn, Bl, Un, bi, ar, Rt, cr, ro, so, At, lo, ao, oo, ur, zn, Wl, dt, hr, dr, Ee, D, ye, fe, kt, G, Ct, zl, mr, Gl, fo, $l, $, Mt, $n, po, br, Vn, gi, qn, Yn, Vl, Pt, ql, Yl, _r, v, jn, gr, Si, Eu, Tu, Ot, Ei, Bt, Ti, Sr, Iu, yu, vr, Nt, yr, xr, Ii, Zl, vo, go, Jl, Ql, ea, ta, Tr, Ir, bo, ia, $e, Ve, xe, So, ra, Xn, wr, Te, Zn, Dr, na, xu, Fe, st, sa, oa, Eo, la, wu, Du, Ru, Lu, ot, aa, yi, Jn, To, Io, yo, Qn, Rr, es, ua, ha, da, fa, ft, wo, Lr, qe, xi, Do, ma, ts2, Ye, kr, ba, Ar, va, _e, Cr, Bh, be, Nh, Fh, Hh, Oo, Wh, Uh, No, Kh, zh, ss,
|
|
10154
|
+
var zs, Rl, Ll, M, S, Gs, mi, $s, _i, er, tr, ir, we, De, rt, q, js, Hn, Fn, F, rr, ge, Zs, xt, nr, H, sr, Js, Be, wt, nt, ae, Dt, ce, Qs, or, Re, lr, Wn, Bl, Un, bi, ar, Rt, cr, ro, so, At, lo, ao, oo, ur, zn, Wl, dt, hr, dr, Ee, D, ye, fe, kt, G, Ct, zl, mr, Gl, fo, $l, $, Mt, $n, po, br, Vn, gi, qn, Yn, Vl, Pt, ql, Yl, _r, v, jn, gr, Si, Eu, Tu, Ot, Ei, Bt, Ti, Sr, Iu, yu, vr, Nt, yr, xr, Ii, Zl, vo, go, Jl, Ql, ea, ta, Tr, Ir, bo, ia, $e, Ve, xe, So, ra, Xn, wr, Te, Zn, Dr, na, xu, Fe, st, sa, oa, Eo, la, wu, Du, Ru, Lu, ot, aa, yi, Jn, To, Io, yo, Qn, Rr, es, ua, ha, da, fa, ft, wo, Lr, qe, xi, Do, ma, ts2, Ye, kr, ba, Ar, va, _e, Cr, Bh, be, Nh, Fh, Hh, Oo, Wh, Uh, No, Kh, zh, ss, os10, wa, mt, Mr, Di, pt, Gh, Y, Da, ls, Wt, He, Q, Pr, lt, Uo, Or, cs, Ri, Br, Nr, Fr, Ca, Ut, Kt, Wr, Ur, Ma, Ko, zo, us, zr, hs, ds, Kr, zt, Gt, Gr, We, at, Li, bt, b, Ai, fs8, $t, ue, he, de, J, ps, j, U, z, ve, $r, Vr, ct, Vt, Yr, ms, _s, Le, jr, jo, ki, Xr, Na, Yt, jt, Zr, bs, vs, Jr, gs, Qr, Xt, en, tn, Mi, Pi, Oi, Ss, Fa, Zo, Zt, Wa, Ua, Es, Bi, Ts, rn, Is, ys, Jt, nn, Qt, xs, on, Ds, Ya, ja, Xa, Za, Ja, ei, Hi, Wi, re, St, Ki, tl, il, Ui, Qa, ti, Rs, ln, ec, tc, ii, ic, zi, B, X, an, Ls, Ze, un, cn, ne, Je, cl, $i, hn, ks, Cs, ni, si, nc, dn, ul, hl, li, dl, Ps, fl, ai, Os, ac, se, fn, Ae, pn, Vi, uc, ci, qi, mn, pe, Yi, _n, ji, Xi, Fs, ke, hc, bn, dc, fc, mc, ut, _l, vl, gl, vn, Zi, _c, El, bc, gn, ui, Tl, Sn, gc, ee, En, Us, yl, Tn, Ks, Sc, In, xl, wl, Tt, hi, yn, xn, wn, Ji, Dn, Rn, Ln, Ic, Ue, Dl;
|
|
10227
10155
|
var init_xterm = __esm({
|
|
10228
10156
|
"../../oss/node_modules/@xterm/xterm/lib/xterm.mjs"() {
|
|
10229
10157
|
"use strict";
|
|
@@ -12271,7 +12199,7 @@ ${h.join(`
|
|
|
12271
12199
|
this._handler && (this._node.removeEventListener(this._type, this._handler, this._options), this._node = null, this._handler = null);
|
|
12272
12200
|
}
|
|
12273
12201
|
};
|
|
12274
|
-
|
|
12202
|
+
os10 = function(t, e, i, r) {
|
|
12275
12203
|
let n = i;
|
|
12276
12204
|
return e === "click" || e === "mousedown" || e === "contextmenu" ? n = ya(be(t), i) : (e === "keydown" || e === "keypress" || e === "keyup") && (n = xa(i)), L(t, e, n, r);
|
|
12277
12205
|
};
|
|
@@ -12699,7 +12627,7 @@ ${h.join(`
|
|
|
12699
12627
|
Uo = 11;
|
|
12700
12628
|
Or = class extends lt {
|
|
12701
12629
|
constructor(t) {
|
|
12702
|
-
super(), this._onActivate = t.onActivate, this.bgDomNode = document.createElement("div"), this.bgDomNode.className = "arrow-background", this.bgDomNode.style.position = "absolute", this.bgDomNode.style.width = t.bgWidth + "px", this.bgDomNode.style.height = t.bgHeight + "px", typeof t.top < "u" && (this.bgDomNode.style.top = "0px"), typeof t.left < "u" && (this.bgDomNode.style.left = "0px"), typeof t.bottom < "u" && (this.bgDomNode.style.bottom = "0px"), typeof t.right < "u" && (this.bgDomNode.style.right = "0px"), this.domNode = document.createElement("div"), this.domNode.className = t.className, this.domNode.style.position = "absolute", this.domNode.style.width = Uo + "px", this.domNode.style.height = Uo + "px", typeof t.top < "u" && (this.domNode.style.top = t.top + "px"), typeof t.left < "u" && (this.domNode.style.left = t.left + "px"), typeof t.bottom < "u" && (this.domNode.style.bottom = t.bottom + "px"), typeof t.right < "u" && (this.domNode.style.right = t.right + "px"), this._pointerMoveMonitor = this._register(new Wt()), this._register(
|
|
12630
|
+
super(), this._onActivate = t.onActivate, this.bgDomNode = document.createElement("div"), this.bgDomNode.className = "arrow-background", this.bgDomNode.style.position = "absolute", this.bgDomNode.style.width = t.bgWidth + "px", this.bgDomNode.style.height = t.bgHeight + "px", typeof t.top < "u" && (this.bgDomNode.style.top = "0px"), typeof t.left < "u" && (this.bgDomNode.style.left = "0px"), typeof t.bottom < "u" && (this.bgDomNode.style.bottom = "0px"), typeof t.right < "u" && (this.bgDomNode.style.right = "0px"), this.domNode = document.createElement("div"), this.domNode.className = t.className, this.domNode.style.position = "absolute", this.domNode.style.width = Uo + "px", this.domNode.style.height = Uo + "px", typeof t.top < "u" && (this.domNode.style.top = t.top + "px"), typeof t.left < "u" && (this.domNode.style.left = t.left + "px"), typeof t.bottom < "u" && (this.domNode.style.bottom = t.bottom + "px"), typeof t.right < "u" && (this.domNode.style.right = t.right + "px"), this._pointerMoveMonitor = this._register(new Wt()), this._register(os10(this.bgDomNode, Y.POINTER_DOWN, (e) => this._arrowPointerDown(e))), this._register(os10(this.domNode, Y.POINTER_DOWN, (e) => this._arrowPointerDown(e))), this._pointerdownRepeatTimer = this._register(new Mr()), this._pointerdownScheduleRepeatTimer = this._register(new Ye());
|
|
12703
12631
|
}
|
|
12704
12632
|
_arrowPointerDown(t) {
|
|
12705
12633
|
if (!t.target || !(t.target instanceof Element)) return;
|
|
@@ -18652,6 +18580,12 @@ var init_xterm_backend = __esm({
|
|
|
18652
18580
|
});
|
|
18653
18581
|
|
|
18654
18582
|
// ../../oss/packages/daemon-core/src/cli-adapters/terminal-screen.ts
|
|
18583
|
+
function getTerminalBackendRuntimeStatus() {
|
|
18584
|
+
const preference = resolveTerminalBackendPreference();
|
|
18585
|
+
const ghosttyAvailable = isGhosttyVtBackendAvailable();
|
|
18586
|
+
const backend = preference === "ghostty-vt" || preference === "auto" && ghosttyAvailable ? "ghostty-vt" : "xterm";
|
|
18587
|
+
return { backend, preference, ghosttyAvailable };
|
|
18588
|
+
}
|
|
18655
18589
|
function createTerminalBackend(options, preference) {
|
|
18656
18590
|
const ghosttyAvailable = isGhosttyVtBackendAvailable();
|
|
18657
18591
|
if (preference === "ghostty-vt") {
|
|
@@ -18730,6 +18664,388 @@ var init_terminal_screen = __esm({
|
|
|
18730
18664
|
}
|
|
18731
18665
|
});
|
|
18732
18666
|
|
|
18667
|
+
// ../../oss/packages/daemon-core/src/status/snapshot.ts
|
|
18668
|
+
function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
|
|
18669
|
+
return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
|
|
18670
|
+
id: ide.id,
|
|
18671
|
+
type: ide.id,
|
|
18672
|
+
name: ide.displayName || ide.name || ide.id,
|
|
18673
|
+
running: isCdpConnected(cdpManagers, ide.id),
|
|
18674
|
+
...ide.path ? { path: ide.path } : {}
|
|
18675
|
+
}));
|
|
18676
|
+
}
|
|
18677
|
+
function buildAvailableProviders(providerLoader) {
|
|
18678
|
+
return providerLoader.getAll().map((provider) => ({
|
|
18679
|
+
type: provider.type,
|
|
18680
|
+
name: provider.displayName || provider.type,
|
|
18681
|
+
displayName: provider.displayName || provider.type,
|
|
18682
|
+
icon: provider.icon || "\u{1F4BB}",
|
|
18683
|
+
category: provider.category
|
|
18684
|
+
}));
|
|
18685
|
+
}
|
|
18686
|
+
function parseMessageTime(value) {
|
|
18687
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
18688
|
+
if (typeof value === "string") {
|
|
18689
|
+
const parsed = Date.parse(value);
|
|
18690
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
18691
|
+
}
|
|
18692
|
+
return 0;
|
|
18693
|
+
}
|
|
18694
|
+
function getSessionMessageUpdatedAt(session) {
|
|
18695
|
+
const lastMessage = session.activeChat?.messages?.at?.(-1);
|
|
18696
|
+
if (!lastMessage) return 0;
|
|
18697
|
+
return parseMessageTime(lastMessage.timestamp) || parseMessageTime(lastMessage.receivedAt) || parseMessageTime(lastMessage.createdAt) || 0;
|
|
18698
|
+
}
|
|
18699
|
+
function getSessionLastUsedAt(session) {
|
|
18700
|
+
return getSessionMessageUpdatedAt(session) || session.lastUpdated || Date.now();
|
|
18701
|
+
}
|
|
18702
|
+
function getSessionKind(session) {
|
|
18703
|
+
return session.transport === "cdp-page" || session.transport === "cdp-webview" ? "ide" : session.transport === "acp" ? "acp" : "cli";
|
|
18704
|
+
}
|
|
18705
|
+
function getLastMessageRole(session) {
|
|
18706
|
+
const role = session.activeChat?.messages?.at?.(-1)?.role;
|
|
18707
|
+
return typeof role === "string" ? role : "";
|
|
18708
|
+
}
|
|
18709
|
+
function getUnreadState(hasContentChange, status, lastUsedAt, lastSeenAt, lastRole) {
|
|
18710
|
+
if (status === "waiting_approval") {
|
|
18711
|
+
return { unread: false, inboxBucket: "needs_attention" };
|
|
18712
|
+
}
|
|
18713
|
+
if (status === "generating" || status === "starting") {
|
|
18714
|
+
return { unread: false, inboxBucket: "working" };
|
|
18715
|
+
}
|
|
18716
|
+
const unread = hasContentChange && lastUsedAt > lastSeenAt && lastRole !== "user" && lastRole !== "human";
|
|
18717
|
+
return { unread, inboxBucket: unread ? "task_complete" : "idle" };
|
|
18718
|
+
}
|
|
18719
|
+
function buildRecentSessions(sessions, recentActivity, readState) {
|
|
18720
|
+
const live = sessions.filter((session) => !session.parentId && session.status !== "stopped").map((session) => {
|
|
18721
|
+
const kind = getSessionKind(session);
|
|
18722
|
+
const recentKey = buildRecentActivityKey({
|
|
18723
|
+
kind,
|
|
18724
|
+
providerType: session.providerType,
|
|
18725
|
+
workspace: session.workspace
|
|
18726
|
+
});
|
|
18727
|
+
const lastSeenAt = readState[recentKey] || 0;
|
|
18728
|
+
const lastUsedAt = getSessionLastUsedAt(session);
|
|
18729
|
+
const { unread, inboxBucket } = getUnreadState(
|
|
18730
|
+
getSessionMessageUpdatedAt(session) > 0,
|
|
18731
|
+
session.status,
|
|
18732
|
+
lastUsedAt,
|
|
18733
|
+
lastSeenAt,
|
|
18734
|
+
getLastMessageRole(session)
|
|
18735
|
+
);
|
|
18736
|
+
return {
|
|
18737
|
+
id: session.id,
|
|
18738
|
+
recentKey,
|
|
18739
|
+
sessionId: session.id,
|
|
18740
|
+
providerType: session.providerType,
|
|
18741
|
+
providerName: session.providerName,
|
|
18742
|
+
kind,
|
|
18743
|
+
title: session.activeChat?.title || session.title || session.providerName,
|
|
18744
|
+
workspace: session.workspace,
|
|
18745
|
+
currentModel: session.currentModel,
|
|
18746
|
+
status: session.status,
|
|
18747
|
+
lastUsedAt,
|
|
18748
|
+
unread,
|
|
18749
|
+
lastSeenAt,
|
|
18750
|
+
inboxBucket
|
|
18751
|
+
};
|
|
18752
|
+
});
|
|
18753
|
+
const seen = new Set(live.map((item) => `${item.kind}:${item.providerType}:${item.workspace || ""}`));
|
|
18754
|
+
const persisted = recentActivity.filter((item) => !seen.has(`${item.kind}:${item.providerType}:${item.workspace || ""}`)).map((item) => {
|
|
18755
|
+
const lastSeenAt = readState[item.id] || 0;
|
|
18756
|
+
const unread = item.lastUsedAt > lastSeenAt;
|
|
18757
|
+
return {
|
|
18758
|
+
id: item.id,
|
|
18759
|
+
recentKey: item.id,
|
|
18760
|
+
sessionId: item.sessionId || null,
|
|
18761
|
+
providerType: item.providerType,
|
|
18762
|
+
providerName: item.providerName,
|
|
18763
|
+
kind: item.kind,
|
|
18764
|
+
title: item.title || item.providerName,
|
|
18765
|
+
workspace: item.workspace,
|
|
18766
|
+
currentModel: item.currentModel,
|
|
18767
|
+
lastUsedAt: item.lastUsedAt,
|
|
18768
|
+
unread,
|
|
18769
|
+
lastSeenAt,
|
|
18770
|
+
inboxBucket: unread ? "task_complete" : "idle"
|
|
18771
|
+
};
|
|
18772
|
+
});
|
|
18773
|
+
return [...live, ...persisted].sort((a, b2) => b2.lastUsedAt - a.lastUsedAt).slice(0, 12);
|
|
18774
|
+
}
|
|
18775
|
+
function buildStatusSnapshot(options) {
|
|
18776
|
+
const cfg = loadConfig();
|
|
18777
|
+
const wsState = getWorkspaceState(cfg);
|
|
18778
|
+
const memSnap = getHostMemorySnapshot();
|
|
18779
|
+
const recentActivity = getRecentActivity(cfg, 20);
|
|
18780
|
+
const sessions = buildSessionEntries(
|
|
18781
|
+
options.allStates,
|
|
18782
|
+
options.cdpManagers
|
|
18783
|
+
);
|
|
18784
|
+
const readState = cfg.recentSessionReads || {};
|
|
18785
|
+
for (const session of sessions) {
|
|
18786
|
+
const kind = getSessionKind(session);
|
|
18787
|
+
const recentKey = buildRecentActivityKey({
|
|
18788
|
+
kind,
|
|
18789
|
+
providerType: session.providerType,
|
|
18790
|
+
workspace: session.workspace
|
|
18791
|
+
});
|
|
18792
|
+
const lastSeenAt = getRecentSessionSeenAt(cfg, recentKey);
|
|
18793
|
+
const lastUsedAt = getSessionLastUsedAt(session);
|
|
18794
|
+
const { unread, inboxBucket } = getUnreadState(
|
|
18795
|
+
getSessionMessageUpdatedAt(session) > 0,
|
|
18796
|
+
session.status,
|
|
18797
|
+
lastUsedAt,
|
|
18798
|
+
lastSeenAt,
|
|
18799
|
+
getLastMessageRole(session)
|
|
18800
|
+
);
|
|
18801
|
+
session.recentKey = recentKey;
|
|
18802
|
+
session.lastSeenAt = lastSeenAt;
|
|
18803
|
+
session.unread = unread;
|
|
18804
|
+
session.inboxBucket = inboxBucket;
|
|
18805
|
+
}
|
|
18806
|
+
const terminalBackend = getTerminalBackendRuntimeStatus();
|
|
18807
|
+
return {
|
|
18808
|
+
instanceId: options.instanceId,
|
|
18809
|
+
version: options.version,
|
|
18810
|
+
daemonMode: options.daemonMode,
|
|
18811
|
+
machine: {
|
|
18812
|
+
hostname: os11.hostname(),
|
|
18813
|
+
platform: os11.platform(),
|
|
18814
|
+
arch: os11.arch(),
|
|
18815
|
+
cpus: os11.cpus().length,
|
|
18816
|
+
totalMem: memSnap.totalMem,
|
|
18817
|
+
freeMem: memSnap.freeMem,
|
|
18818
|
+
availableMem: memSnap.availableMem,
|
|
18819
|
+
loadavg: os11.loadavg(),
|
|
18820
|
+
uptime: os11.uptime(),
|
|
18821
|
+
release: os11.release()
|
|
18822
|
+
},
|
|
18823
|
+
machineNickname: options.machineNickname ?? cfg.machineNickname ?? null,
|
|
18824
|
+
timestamp: options.timestamp ?? Date.now(),
|
|
18825
|
+
detectedIdes: buildDetectedIdeInfos(options.detectedIdes, options.cdpManagers),
|
|
18826
|
+
...options.p2p ? { p2p: options.p2p } : {},
|
|
18827
|
+
sessions,
|
|
18828
|
+
workspaces: wsState.workspaces,
|
|
18829
|
+
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
18830
|
+
defaultWorkspacePath: wsState.defaultWorkspacePath,
|
|
18831
|
+
workspaceActivity: getWorkspaceActivity(cfg, 15),
|
|
18832
|
+
recentSessions: buildRecentSessions(sessions, recentActivity, readState),
|
|
18833
|
+
terminalBackend,
|
|
18834
|
+
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
18835
|
+
};
|
|
18836
|
+
}
|
|
18837
|
+
var os11;
|
|
18838
|
+
var init_snapshot = __esm({
|
|
18839
|
+
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
18840
|
+
"use strict";
|
|
18841
|
+
os11 = __toESM(require("os"));
|
|
18842
|
+
init_config();
|
|
18843
|
+
init_recent_activity();
|
|
18844
|
+
init_workspaces();
|
|
18845
|
+
init_workspace_activity();
|
|
18846
|
+
init_host_memory();
|
|
18847
|
+
init_terminal_screen();
|
|
18848
|
+
init_builders();
|
|
18849
|
+
}
|
|
18850
|
+
});
|
|
18851
|
+
|
|
18852
|
+
// ../../oss/packages/daemon-core/src/status/reporter.ts
|
|
18853
|
+
var DaemonStatusReporter;
|
|
18854
|
+
var init_reporter = __esm({
|
|
18855
|
+
"../../oss/packages/daemon-core/src/status/reporter.ts"() {
|
|
18856
|
+
"use strict";
|
|
18857
|
+
init_logger();
|
|
18858
|
+
init_builders();
|
|
18859
|
+
init_snapshot();
|
|
18860
|
+
DaemonStatusReporter = class {
|
|
18861
|
+
deps;
|
|
18862
|
+
log;
|
|
18863
|
+
lastStatusSentAt = 0;
|
|
18864
|
+
statusPendingThrottle = false;
|
|
18865
|
+
lastP2PStatusHash = "";
|
|
18866
|
+
lastStatusSummary = "";
|
|
18867
|
+
statusTimer = null;
|
|
18868
|
+
p2pTimer = null;
|
|
18869
|
+
constructor(deps, opts) {
|
|
18870
|
+
this.deps = deps;
|
|
18871
|
+
this.log = opts?.logFn || LOG.forComponent("Status").asLogFn();
|
|
18872
|
+
}
|
|
18873
|
+
// ─── Lifecycle ───────────────────────────────────
|
|
18874
|
+
startReporting() {
|
|
18875
|
+
setTimeout(() => {
|
|
18876
|
+
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Initial report failed: ${e?.message}`));
|
|
18877
|
+
}, 2e3);
|
|
18878
|
+
const scheduleServerReport = () => {
|
|
18879
|
+
this.statusTimer = setTimeout(() => {
|
|
18880
|
+
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Periodic report failed: ${e?.message}`));
|
|
18881
|
+
scheduleServerReport();
|
|
18882
|
+
}, 3e4);
|
|
18883
|
+
};
|
|
18884
|
+
scheduleServerReport();
|
|
18885
|
+
this.p2pTimer = setInterval(() => {
|
|
18886
|
+
if (this.deps.p2p?.isConnected) {
|
|
18887
|
+
this.sendUnifiedStatusReport({ p2pOnly: true }).catch((e) => LOG.warn("Status", `P2P status send failed: ${e?.message}`));
|
|
18888
|
+
}
|
|
18889
|
+
}, 5e3);
|
|
18890
|
+
}
|
|
18891
|
+
stopReporting() {
|
|
18892
|
+
if (this.statusTimer) {
|
|
18893
|
+
clearTimeout(this.statusTimer);
|
|
18894
|
+
this.statusTimer = null;
|
|
18895
|
+
}
|
|
18896
|
+
if (this.p2pTimer) {
|
|
18897
|
+
clearInterval(this.p2pTimer);
|
|
18898
|
+
this.p2pTimer = null;
|
|
18899
|
+
}
|
|
18900
|
+
}
|
|
18901
|
+
onStatusChange() {
|
|
18902
|
+
this.throttledReport();
|
|
18903
|
+
}
|
|
18904
|
+
throttledReport() {
|
|
18905
|
+
const now = Date.now();
|
|
18906
|
+
const elapsed = now - this.lastStatusSentAt;
|
|
18907
|
+
if (elapsed >= 5e3) {
|
|
18908
|
+
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Throttled report failed: ${e?.message}`));
|
|
18909
|
+
} else if (!this.statusPendingThrottle) {
|
|
18910
|
+
this.statusPendingThrottle = true;
|
|
18911
|
+
setTimeout(() => {
|
|
18912
|
+
this.statusPendingThrottle = false;
|
|
18913
|
+
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Deferred report failed: ${e?.message}`));
|
|
18914
|
+
}, 5e3 - elapsed);
|
|
18915
|
+
}
|
|
18916
|
+
}
|
|
18917
|
+
emitStatusEvent(event) {
|
|
18918
|
+
LOG.info("StatusEvent", `${event.event} (${event.providerType || event.ideType || ""})`);
|
|
18919
|
+
this.deps.serverConn?.sendMessage("status_event", event);
|
|
18920
|
+
}
|
|
18921
|
+
removeAgentTracking(_key) {
|
|
18922
|
+
}
|
|
18923
|
+
// (agent-stream polling backward compat)
|
|
18924
|
+
updateAgentStreams(_ideType, _streams) {
|
|
18925
|
+
}
|
|
18926
|
+
/** Reset P2P dedup hash — forces next send to transmit even if content unchanged */
|
|
18927
|
+
resetP2PHash() {
|
|
18928
|
+
this.lastP2PStatusHash = "";
|
|
18929
|
+
}
|
|
18930
|
+
// ─── Core ────────────────────────────────────────
|
|
18931
|
+
ts() {
|
|
18932
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
18933
|
+
}
|
|
18934
|
+
async sendUnifiedStatusReport(opts) {
|
|
18935
|
+
const { serverConn, p2p } = this.deps;
|
|
18936
|
+
if (!serverConn?.isConnected()) return;
|
|
18937
|
+
this.lastStatusSentAt = Date.now();
|
|
18938
|
+
const now = this.lastStatusSentAt;
|
|
18939
|
+
const target = opts?.p2pOnly ? "P2P" : "P2P+Server";
|
|
18940
|
+
const allStates = this.deps.instanceManager.collectAllStates();
|
|
18941
|
+
const ideStates = allStates.filter((s15) => s15.category === "ide");
|
|
18942
|
+
const cliStates = allStates.filter((s15) => s15.category === "cli");
|
|
18943
|
+
const acpStates = allStates.filter((s15) => s15.category === "acp");
|
|
18944
|
+
const ideSummary = ideStates.map((s15) => {
|
|
18945
|
+
const msgs = s15.activeChat?.messages?.length || 0;
|
|
18946
|
+
const exts = s15.extensions.length;
|
|
18947
|
+
return `${s15.type}(${s15.status},${msgs}msg,${exts}ext${s15.currentModel ? ",model=" + s15.currentModel : ""})`;
|
|
18948
|
+
}).join(", ");
|
|
18949
|
+
const cliSummary = cliStates.map((s15) => `${s15.type}(${s15.status})`).join(", ");
|
|
18950
|
+
const acpSummary = acpStates.map((s15) => `${s15.type}(${s15.status})`).join(", ");
|
|
18951
|
+
const logLevel = opts?.p2pOnly ? "debug" : "info";
|
|
18952
|
+
const baseSummary = `IDE: ${ideStates.length} [${ideSummary}] CLI: ${cliStates.length} [${cliSummary}] ACP: ${acpStates.length} [${acpSummary}]`;
|
|
18953
|
+
const summaryChanged = baseSummary !== this.lastStatusSummary;
|
|
18954
|
+
if (summaryChanged) {
|
|
18955
|
+
this.lastStatusSummary = baseSummary;
|
|
18956
|
+
if (logLevel === "debug") {
|
|
18957
|
+
LOG.debug("StatusReport", `\u2192${target} ${baseSummary}`);
|
|
18958
|
+
} else {
|
|
18959
|
+
LOG.info("StatusReport", `\u2192${target} ${baseSummary}`);
|
|
18960
|
+
}
|
|
18961
|
+
}
|
|
18962
|
+
const sessions = buildSessionEntries(
|
|
18963
|
+
allStates,
|
|
18964
|
+
this.deps.cdpManagers
|
|
18965
|
+
);
|
|
18966
|
+
const payload = {
|
|
18967
|
+
...buildStatusSnapshot({
|
|
18968
|
+
allStates,
|
|
18969
|
+
cdpManagers: this.deps.cdpManagers,
|
|
18970
|
+
providerLoader: this.deps.providerLoader,
|
|
18971
|
+
detectedIdes: this.deps.detectedIdes || [],
|
|
18972
|
+
instanceId: this.deps.instanceId,
|
|
18973
|
+
version: this.deps.daemonVersion || "unknown",
|
|
18974
|
+
daemonMode: true,
|
|
18975
|
+
timestamp: now,
|
|
18976
|
+
p2p: {
|
|
18977
|
+
available: p2p?.isAvailable || false,
|
|
18978
|
+
state: p2p?.connectionState || "unavailable",
|
|
18979
|
+
peers: p2p?.connectedPeerCount || 0,
|
|
18980
|
+
screenshotActive: p2p?.screenshotActive || false
|
|
18981
|
+
}
|
|
18982
|
+
}),
|
|
18983
|
+
screenshotUsage: this.deps.getScreenshotUsage?.() || null,
|
|
18984
|
+
connectedExtensions: []
|
|
18985
|
+
};
|
|
18986
|
+
const p2pSent = this.sendP2PPayload(payload);
|
|
18987
|
+
if (p2pSent) {
|
|
18988
|
+
LOG.debug("P2P", `sent (${JSON.stringify(payload).length} bytes)`);
|
|
18989
|
+
}
|
|
18990
|
+
if (opts?.p2pOnly) return;
|
|
18991
|
+
const wsPayload = {
|
|
18992
|
+
daemonMode: true,
|
|
18993
|
+
sessions: sessions.map((session) => ({
|
|
18994
|
+
id: session.id,
|
|
18995
|
+
parentId: session.parentId,
|
|
18996
|
+
providerType: session.providerType,
|
|
18997
|
+
providerName: session.providerName,
|
|
18998
|
+
kind: session.kind,
|
|
18999
|
+
transport: session.transport,
|
|
19000
|
+
status: session.status,
|
|
19001
|
+
workspace: session.workspace,
|
|
19002
|
+
title: session.title,
|
|
19003
|
+
cdpConnected: session.cdpConnected,
|
|
19004
|
+
currentModel: session.currentModel,
|
|
19005
|
+
currentPlan: session.currentPlan,
|
|
19006
|
+
currentAutoApprove: session.currentAutoApprove,
|
|
19007
|
+
recentKey: session.recentKey,
|
|
19008
|
+
unread: session.unread,
|
|
19009
|
+
lastSeenAt: session.lastSeenAt,
|
|
19010
|
+
inboxBucket: session.inboxBucket,
|
|
19011
|
+
controlValues: session.controlValues,
|
|
19012
|
+
providerControls: session.providerControls,
|
|
19013
|
+
acpConfigOptions: session.acpConfigOptions,
|
|
19014
|
+
acpModes: session.acpModes
|
|
19015
|
+
})),
|
|
19016
|
+
p2p: payload.p2p,
|
|
19017
|
+
timestamp: now
|
|
19018
|
+
};
|
|
19019
|
+
serverConn.sendMessage("status_report", wsPayload);
|
|
19020
|
+
LOG.debug("Server", `sent status_report (${JSON.stringify(wsPayload).length} bytes)`);
|
|
19021
|
+
}
|
|
19022
|
+
// ─── P2P ─────────────────────────────────────────
|
|
19023
|
+
sendP2PPayload(payload) {
|
|
19024
|
+
const { timestamp: _ts, system: _sys, ...hashTarget } = payload;
|
|
19025
|
+
if (hashTarget.machine) {
|
|
19026
|
+
const { freeMem: _f, availableMem: _a2, loadavg: _l2, uptime: _u, ...stableMachine } = hashTarget.machine;
|
|
19027
|
+
hashTarget.machine = stableMachine;
|
|
19028
|
+
}
|
|
19029
|
+
const h = this.simpleHash(JSON.stringify(hashTarget));
|
|
19030
|
+
if (h !== this.lastP2PStatusHash) {
|
|
19031
|
+
this.lastP2PStatusHash = h;
|
|
19032
|
+
this.deps.p2p?.sendStatus(payload);
|
|
19033
|
+
return true;
|
|
19034
|
+
}
|
|
19035
|
+
return false;
|
|
19036
|
+
}
|
|
19037
|
+
simpleHash(s15) {
|
|
19038
|
+
let h = 2166136261;
|
|
19039
|
+
for (let i = 0; i < s15.length; i++) {
|
|
19040
|
+
h ^= s15.charCodeAt(i);
|
|
19041
|
+
h = h * 16777619 >>> 0;
|
|
19042
|
+
}
|
|
19043
|
+
return h.toString(36);
|
|
19044
|
+
}
|
|
19045
|
+
};
|
|
19046
|
+
}
|
|
19047
|
+
});
|
|
19048
|
+
|
|
18733
19049
|
// ../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts
|
|
18734
19050
|
var os12, pty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
18735
19051
|
var init_pty_transport = __esm({
|
|
@@ -18809,7 +19125,7 @@ function findBinary(name) {
|
|
|
18809
19125
|
}
|
|
18810
19126
|
}
|
|
18811
19127
|
function isScriptBinary(binaryPath) {
|
|
18812
|
-
if (!
|
|
19128
|
+
if (!path10.isAbsolute(binaryPath)) return false;
|
|
18813
19129
|
try {
|
|
18814
19130
|
const fs16 = require("fs");
|
|
18815
19131
|
const resolved = fs16.realpathSync(binaryPath);
|
|
@@ -18825,7 +19141,7 @@ function isScriptBinary(binaryPath) {
|
|
|
18825
19141
|
}
|
|
18826
19142
|
}
|
|
18827
19143
|
function looksLikeMachOOrElf(filePath) {
|
|
18828
|
-
if (!
|
|
19144
|
+
if (!path10.isAbsolute(filePath)) return false;
|
|
18829
19145
|
try {
|
|
18830
19146
|
const fs16 = require("fs");
|
|
18831
19147
|
const resolved = fs16.realpathSync(filePath);
|
|
@@ -18939,12 +19255,12 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
18939
19255
|
}
|
|
18940
19256
|
};
|
|
18941
19257
|
}
|
|
18942
|
-
var os13,
|
|
19258
|
+
var os13, path10, import_child_process5, pty2, ProviderCliAdapter;
|
|
18943
19259
|
var init_provider_cli_adapter = __esm({
|
|
18944
19260
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
|
|
18945
19261
|
"use strict";
|
|
18946
19262
|
os13 = __toESM(require("os"));
|
|
18947
|
-
|
|
19263
|
+
path10 = __toESM(require("path"));
|
|
18948
19264
|
import_child_process5 = require("child_process");
|
|
18949
19265
|
init_logger();
|
|
18950
19266
|
init_terminal_screen();
|
|
@@ -18954,9 +19270,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
18954
19270
|
if (os13.platform() !== "win32") {
|
|
18955
19271
|
try {
|
|
18956
19272
|
const fs16 = require("fs");
|
|
18957
|
-
const ptyDir =
|
|
19273
|
+
const ptyDir = path10.resolve(path10.dirname(require.resolve("node-pty")), "..");
|
|
18958
19274
|
const platformArch = `${os13.platform()}-${os13.arch()}`;
|
|
18959
|
-
const helper =
|
|
19275
|
+
const helper = path10.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
18960
19276
|
if (fs16.existsSync(helper)) {
|
|
18961
19277
|
const stat4 = fs16.statSync(helper);
|
|
18962
19278
|
if (!(stat4.mode & 73)) {
|
|
@@ -19145,7 +19461,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
19145
19461
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
19146
19462
|
let shellCmd;
|
|
19147
19463
|
let shellArgs;
|
|
19148
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
19464
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
19149
19465
|
const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
|
|
19150
19466
|
if (useShell) {
|
|
19151
19467
|
if (!spawnConfig.shell && !isWin) {
|
|
@@ -19570,7 +19886,7 @@ ${data.message || ""}`.trim();
|
|
|
19570
19886
|
if (this.startupParseGate) {
|
|
19571
19887
|
const deadline = Date.now() + 1e4;
|
|
19572
19888
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
19573
|
-
await new Promise((
|
|
19889
|
+
await new Promise((resolve13) => setTimeout(resolve13, 50));
|
|
19574
19890
|
}
|
|
19575
19891
|
}
|
|
19576
19892
|
if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
|
|
@@ -19738,17 +20054,17 @@ ${data.message || ""}`.trim();
|
|
|
19738
20054
|
}
|
|
19739
20055
|
}
|
|
19740
20056
|
waitForStopped(timeoutMs) {
|
|
19741
|
-
return new Promise((
|
|
20057
|
+
return new Promise((resolve13) => {
|
|
19742
20058
|
const startedAt = Date.now();
|
|
19743
20059
|
const timer = setInterval(() => {
|
|
19744
20060
|
if (!this.ptyProcess || this.currentStatus === "stopped") {
|
|
19745
20061
|
clearInterval(timer);
|
|
19746
|
-
|
|
20062
|
+
resolve13(true);
|
|
19747
20063
|
return;
|
|
19748
20064
|
}
|
|
19749
20065
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
19750
20066
|
clearInterval(timer);
|
|
19751
|
-
|
|
20067
|
+
resolve13(false);
|
|
19752
20068
|
}
|
|
19753
20069
|
}, 100);
|
|
19754
20070
|
});
|
|
@@ -20035,7 +20351,10 @@ var init_cli_provider_instance = __esm({
|
|
|
20035
20351
|
writeOwner: runtime.writeOwner || null,
|
|
20036
20352
|
attachedClients: runtime.attachedClients || []
|
|
20037
20353
|
} : void 0,
|
|
20038
|
-
resume: this.provider.resume
|
|
20354
|
+
resume: this.provider.resume,
|
|
20355
|
+
controlValues: void 0,
|
|
20356
|
+
// CLI controls not yet wired from stream
|
|
20357
|
+
providerControls: this.provider.controls
|
|
20039
20358
|
};
|
|
20040
20359
|
}
|
|
20041
20360
|
onEvent(event, data) {
|
|
@@ -20434,10 +20753,10 @@ function mergeDefs(...defs) {
|
|
|
20434
20753
|
function cloneDef(schema) {
|
|
20435
20754
|
return mergeDefs(schema._zod.def);
|
|
20436
20755
|
}
|
|
20437
|
-
function getElementAtPath(obj,
|
|
20438
|
-
if (!
|
|
20756
|
+
function getElementAtPath(obj, path19) {
|
|
20757
|
+
if (!path19)
|
|
20439
20758
|
return obj;
|
|
20440
|
-
return
|
|
20759
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
20441
20760
|
}
|
|
20442
20761
|
function promiseAllObject(promisesObj) {
|
|
20443
20762
|
const keys = Object.keys(promisesObj);
|
|
@@ -20749,11 +21068,11 @@ function aborted(x, startIndex = 0) {
|
|
|
20749
21068
|
}
|
|
20750
21069
|
return false;
|
|
20751
21070
|
}
|
|
20752
|
-
function prefixIssues(
|
|
21071
|
+
function prefixIssues(path19, issues) {
|
|
20753
21072
|
return issues.map((iss) => {
|
|
20754
21073
|
var _a2;
|
|
20755
21074
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
20756
|
-
iss.path.unshift(
|
|
21075
|
+
iss.path.unshift(path19);
|
|
20757
21076
|
return iss;
|
|
20758
21077
|
});
|
|
20759
21078
|
}
|
|
@@ -20996,7 +21315,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
20996
21315
|
}
|
|
20997
21316
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
20998
21317
|
const result = { errors: [] };
|
|
20999
|
-
const processError = (error49,
|
|
21318
|
+
const processError = (error49, path19 = []) => {
|
|
21000
21319
|
var _a2, _b;
|
|
21001
21320
|
for (const issue2 of error49.issues) {
|
|
21002
21321
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -21006,7 +21325,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21006
21325
|
} else if (issue2.code === "invalid_element") {
|
|
21007
21326
|
processError({ issues: issue2.issues }, issue2.path);
|
|
21008
21327
|
} else {
|
|
21009
|
-
const fullpath = [...
|
|
21328
|
+
const fullpath = [...path19, ...issue2.path];
|
|
21010
21329
|
if (fullpath.length === 0) {
|
|
21011
21330
|
result.errors.push(mapper(issue2));
|
|
21012
21331
|
continue;
|
|
@@ -21038,8 +21357,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
21038
21357
|
}
|
|
21039
21358
|
function toDotPath(_path) {
|
|
21040
21359
|
const segs = [];
|
|
21041
|
-
const
|
|
21042
|
-
for (const seg of
|
|
21360
|
+
const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
21361
|
+
for (const seg of path19) {
|
|
21043
21362
|
if (typeof seg === "number")
|
|
21044
21363
|
segs.push(`[${seg}]`);
|
|
21045
21364
|
else if (typeof seg === "symbol")
|
|
@@ -33803,13 +34122,13 @@ function resolveRef(ref, ctx) {
|
|
|
33803
34122
|
if (!ref.startsWith("#")) {
|
|
33804
34123
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
33805
34124
|
}
|
|
33806
|
-
const
|
|
33807
|
-
if (
|
|
34125
|
+
const path19 = ref.slice(1).split("/").filter(Boolean);
|
|
34126
|
+
if (path19.length === 0) {
|
|
33808
34127
|
return ctx.rootSchema;
|
|
33809
34128
|
}
|
|
33810
34129
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
33811
|
-
if (
|
|
33812
|
-
const key =
|
|
34130
|
+
if (path19[0] === defsKey) {
|
|
34131
|
+
const key = path19[1];
|
|
33813
34132
|
if (!key || !ctx.defs[key]) {
|
|
33814
34133
|
throw new Error(`Reference not found: ${ref}`);
|
|
33815
34134
|
}
|
|
@@ -36236,8 +36555,8 @@ var init_acp = __esm({
|
|
|
36236
36555
|
this.#requestHandler = requestHandler;
|
|
36237
36556
|
this.#notificationHandler = notificationHandler;
|
|
36238
36557
|
this.#stream = stream;
|
|
36239
|
-
this.#closedPromise = new Promise((
|
|
36240
|
-
this.#abortController.signal.addEventListener("abort", () =>
|
|
36558
|
+
this.#closedPromise = new Promise((resolve13) => {
|
|
36559
|
+
this.#abortController.signal.addEventListener("abort", () => resolve13());
|
|
36241
36560
|
});
|
|
36242
36561
|
this.#receive();
|
|
36243
36562
|
}
|
|
@@ -36386,8 +36705,8 @@ var init_acp = __esm({
|
|
|
36386
36705
|
}
|
|
36387
36706
|
async sendRequest(method, params) {
|
|
36388
36707
|
const id = this.#nextRequestId++;
|
|
36389
|
-
const responsePromise = new Promise((
|
|
36390
|
-
this.#pendingResponses.set(id, { resolve:
|
|
36708
|
+
const responsePromise = new Promise((resolve13, reject) => {
|
|
36709
|
+
this.#pendingResponses.set(id, { resolve: resolve13, reject });
|
|
36391
36710
|
});
|
|
36392
36711
|
await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
|
|
36393
36712
|
return responsePromise;
|
|
@@ -36623,7 +36942,12 @@ var init_acp_provider_instance = __esm({
|
|
|
36623
36942
|
acpModes: this.availableModes,
|
|
36624
36943
|
// Error details for dashboard display
|
|
36625
36944
|
errorMessage: this.errorMessage || void 0,
|
|
36626
|
-
errorReason: this.errorReason || void 0
|
|
36945
|
+
errorReason: this.errorReason || void 0,
|
|
36946
|
+
controlValues: {
|
|
36947
|
+
...this.currentModel ? { model: this.currentModel } : {},
|
|
36948
|
+
...this.currentMode ? { mode: this.currentMode } : {}
|
|
36949
|
+
},
|
|
36950
|
+
providerControls: this.provider.controls
|
|
36627
36951
|
};
|
|
36628
36952
|
}
|
|
36629
36953
|
onEvent(event, data) {
|
|
@@ -36922,13 +37246,13 @@ var init_acp_provider_instance = __esm({
|
|
|
36922
37246
|
}
|
|
36923
37247
|
this.currentStatus = "waiting_approval";
|
|
36924
37248
|
this.detectStatusTransition();
|
|
36925
|
-
const approved = await new Promise((
|
|
36926
|
-
this.permissionResolvers.push(
|
|
37249
|
+
const approved = await new Promise((resolve13) => {
|
|
37250
|
+
this.permissionResolvers.push(resolve13);
|
|
36927
37251
|
setTimeout(() => {
|
|
36928
|
-
const idx = this.permissionResolvers.indexOf(
|
|
37252
|
+
const idx = this.permissionResolvers.indexOf(resolve13);
|
|
36929
37253
|
if (idx >= 0) {
|
|
36930
37254
|
this.permissionResolvers.splice(idx, 1);
|
|
36931
|
-
|
|
37255
|
+
resolve13(false);
|
|
36932
37256
|
}
|
|
36933
37257
|
}, 3e5);
|
|
36934
37258
|
});
|
|
@@ -37390,12 +37714,12 @@ function colorize(color, text) {
|
|
|
37390
37714
|
const fn2 = chalkApi?.[color];
|
|
37391
37715
|
return typeof fn2 === "function" ? fn2(text) : text;
|
|
37392
37716
|
}
|
|
37393
|
-
var os14,
|
|
37717
|
+
var os14, path11, crypto4, import_chalk, chalkApi, DaemonCliManager;
|
|
37394
37718
|
var init_cli_manager = __esm({
|
|
37395
37719
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
37396
37720
|
"use strict";
|
|
37397
37721
|
os14 = __toESM(require("os"));
|
|
37398
|
-
|
|
37722
|
+
path11 = __toESM(require("path"));
|
|
37399
37723
|
crypto4 = __toESM(require("crypto"));
|
|
37400
37724
|
import_chalk = __toESM(require("chalk"));
|
|
37401
37725
|
init_provider_cli_adapter();
|
|
@@ -37403,6 +37727,7 @@ var init_cli_manager = __esm({
|
|
|
37403
37727
|
init_config();
|
|
37404
37728
|
init_workspaces();
|
|
37405
37729
|
init_workspace_activity();
|
|
37730
|
+
init_recent_activity();
|
|
37406
37731
|
init_cli_provider_instance();
|
|
37407
37732
|
init_acp_provider_instance();
|
|
37408
37733
|
init_logger();
|
|
@@ -37438,6 +37763,13 @@ var init_cli_manager = __esm({
|
|
|
37438
37763
|
console.error(colorize("red", ` \u2717 Failed to save recent workspace: ${e}`));
|
|
37439
37764
|
}
|
|
37440
37765
|
}
|
|
37766
|
+
persistRecentActivity(entry) {
|
|
37767
|
+
try {
|
|
37768
|
+
saveConfig(appendRecentActivity(loadConfig(), entry));
|
|
37769
|
+
} catch (e) {
|
|
37770
|
+
console.error(colorize("red", ` \u2717 Failed to save recent activity: ${e}`));
|
|
37771
|
+
}
|
|
37772
|
+
}
|
|
37441
37773
|
getTransportFactory(runtimeId, providerType, workspace, cliArgs, attachExisting = false) {
|
|
37442
37774
|
return this.deps.createPtyTransportFactory?.({
|
|
37443
37775
|
runtimeId,
|
|
@@ -37520,7 +37852,7 @@ var init_cli_manager = __esm({
|
|
|
37520
37852
|
async startSession(cliType, workingDir, cliArgs, initialModel) {
|
|
37521
37853
|
const trimmed = (workingDir || "").trim();
|
|
37522
37854
|
if (!trimmed) throw new Error("working directory required");
|
|
37523
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) :
|
|
37855
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) : path11.resolve(trimmed);
|
|
37524
37856
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
37525
37857
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
37526
37858
|
const key = crypto4.randomUUID();
|
|
@@ -37596,6 +37928,15 @@ ${installInfo}`
|
|
|
37596
37928
|
} catch (e) {
|
|
37597
37929
|
LOG.warn("CLI", `ACP history save failed: ${e?.message}`);
|
|
37598
37930
|
}
|
|
37931
|
+
this.persistRecentActivity({
|
|
37932
|
+
kind: "acp",
|
|
37933
|
+
providerType: normalizedType,
|
|
37934
|
+
providerName: provider.displayName || provider.name || normalizedType,
|
|
37935
|
+
workspace: resolvedDir,
|
|
37936
|
+
currentModel: initialModel,
|
|
37937
|
+
sessionId,
|
|
37938
|
+
title: provider.displayName || provider.name || normalizedType
|
|
37939
|
+
});
|
|
37599
37940
|
this.deps.onStatusChange();
|
|
37600
37941
|
return;
|
|
37601
37942
|
}
|
|
@@ -37658,6 +37999,15 @@ ${installInfo}`
|
|
|
37658
37999
|
} catch (e) {
|
|
37659
38000
|
LOG.warn("CLI", `CLI history save failed: ${e?.message}`);
|
|
37660
38001
|
}
|
|
38002
|
+
this.persistRecentActivity({
|
|
38003
|
+
kind: "cli",
|
|
38004
|
+
providerType: normalizedType,
|
|
38005
|
+
providerName: provider?.displayName || provider?.name || normalizedType,
|
|
38006
|
+
workspace: resolvedDir,
|
|
38007
|
+
currentModel: initialModel,
|
|
38008
|
+
sessionId: key,
|
|
38009
|
+
title: provider?.displayName || provider?.name || normalizedType
|
|
38010
|
+
});
|
|
37661
38011
|
this.deps.onStatusChange();
|
|
37662
38012
|
}
|
|
37663
38013
|
async stopSession(key) {
|
|
@@ -37915,11 +38265,24 @@ var init_provider_adapter = __esm({
|
|
|
37915
38265
|
hasScript(name) {
|
|
37916
38266
|
return typeof this.provider.scripts?.[name] === "function";
|
|
37917
38267
|
}
|
|
38268
|
+
summarizeRaw(raw) {
|
|
38269
|
+
try {
|
|
38270
|
+
if (typeof raw === "string") return raw.replace(/\s+/g, " ").trim().slice(0, 240);
|
|
38271
|
+
if (raw == null) return String(raw);
|
|
38272
|
+
return JSON.stringify(raw).replace(/\s+/g, " ").trim().slice(0, 240);
|
|
38273
|
+
} catch {
|
|
38274
|
+
return Object.prototype.toString.call(raw);
|
|
38275
|
+
}
|
|
38276
|
+
}
|
|
38277
|
+
isTransportError(reason) {
|
|
38278
|
+
return /Session with given id not found/i.test(reason) || /CDP not connected/i.test(reason) || /Target closed/i.test(reason) || /WebSocket not open/i.test(reason) || /not connected/i.test(reason) || /execution context/i.test(reason) || /Cannot find context with specified id/i.test(reason);
|
|
38279
|
+
}
|
|
37918
38280
|
async readChat(evaluate) {
|
|
37919
38281
|
const script = this.callScript("readChat");
|
|
37920
38282
|
if (!script) return this.errorState("readChat script not available");
|
|
38283
|
+
let raw = null;
|
|
37921
38284
|
try {
|
|
37922
|
-
|
|
38285
|
+
raw = await evaluate(script);
|
|
37923
38286
|
const data = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
37924
38287
|
if (data?.error) {
|
|
37925
38288
|
const state2 = this.errorState(data.error);
|
|
@@ -37939,12 +38302,31 @@ var init_provider_adapter = __esm({
|
|
|
37939
38302
|
mode: data.mode,
|
|
37940
38303
|
activeModal: data.activeModal
|
|
37941
38304
|
};
|
|
38305
|
+
if (this.provider.controls?.length) {
|
|
38306
|
+
const cv = {};
|
|
38307
|
+
for (const ctrl of this.provider.controls) {
|
|
38308
|
+
if (!ctrl.readFrom) continue;
|
|
38309
|
+
const val = data[ctrl.readFrom];
|
|
38310
|
+
if (val !== void 0 && val !== null) {
|
|
38311
|
+
cv[ctrl.id] = typeof val === "object" ? val.name || val.id || String(val) : val;
|
|
38312
|
+
}
|
|
38313
|
+
}
|
|
38314
|
+
if (data.model && !cv["model"]) cv["model"] = data.model;
|
|
38315
|
+
if (data.mode && !cv["mode"]) cv["mode"] = data.mode;
|
|
38316
|
+
if (Object.keys(cv).length > 0) state.controlValues = cv;
|
|
38317
|
+
}
|
|
37942
38318
|
if (state.messages.length > 0) {
|
|
37943
38319
|
this.lastSuccessState = state;
|
|
37944
38320
|
}
|
|
37945
38321
|
return state;
|
|
37946
|
-
} catch {
|
|
37947
|
-
const
|
|
38322
|
+
} catch (error48) {
|
|
38323
|
+
const reason = error48 instanceof Error ? error48.message : String(error48);
|
|
38324
|
+
if (this.isTransportError(reason)) {
|
|
38325
|
+
throw error48 instanceof Error ? error48 : new Error(reason);
|
|
38326
|
+
}
|
|
38327
|
+
const preview = this.summarizeRaw(raw);
|
|
38328
|
+
const detail = preview ? ` (reason=${reason}; raw=${preview})` : ` (reason=${reason})`;
|
|
38329
|
+
const state = this.errorState(`Failed to parse ${this.agentName} state${detail}`);
|
|
37948
38330
|
if (this.lastSuccessState?.messages?.length) {
|
|
37949
38331
|
state.messages = this.lastSuccessState.messages;
|
|
37950
38332
|
}
|
|
@@ -38048,6 +38430,9 @@ var init_manager2 = __esm({
|
|
|
38048
38430
|
getActiveSessionId(parentSessionId) {
|
|
38049
38431
|
return this.activeSessionIdByParent.get(parentSessionId) || null;
|
|
38050
38432
|
}
|
|
38433
|
+
isRecoverableSessionError(message) {
|
|
38434
|
+
return message.includes("timeout") || message.includes("not connected") || message.includes("Session") || message.includes("Target closed") || message.includes("execution context") || message.includes("context with specified id");
|
|
38435
|
+
}
|
|
38051
38436
|
getSessionTarget(sessionId) {
|
|
38052
38437
|
return this.sessionRegistry?.get(sessionId);
|
|
38053
38438
|
}
|
|
@@ -38149,6 +38534,10 @@ var init_manager2 = __esm({
|
|
|
38149
38534
|
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.cdpSessionId, expr, timeout);
|
|
38150
38535
|
const state = await agent.adapter.readChat(evaluate);
|
|
38151
38536
|
LOG.debug("AgentStream", `[AgentStream] readChat(${type}) result: status=${state.status} msgs=${state.messages?.length || 0} model=${state.model || ""}${state.status === "error" ? " error=" + JSON.stringify(state.error || state._error || "unknown") : ""}`);
|
|
38537
|
+
const stateError = String(state.error || state._error || "");
|
|
38538
|
+
if (state.status === "error" && this.isRecoverableSessionError(stateError)) {
|
|
38539
|
+
throw new Error(stateError);
|
|
38540
|
+
}
|
|
38152
38541
|
agent.lastState = state;
|
|
38153
38542
|
agent.lastError = null;
|
|
38154
38543
|
if (state.status === "panel_hidden") {
|
|
@@ -38159,7 +38548,7 @@ var init_manager2 = __esm({
|
|
|
38159
38548
|
const errorMsg = e?.message || String(e);
|
|
38160
38549
|
this.logFn(`[AgentStream] readChat(${type}) error: ${errorMsg.slice(0, 200)}`);
|
|
38161
38550
|
agent.lastError = errorMsg;
|
|
38162
|
-
if (
|
|
38551
|
+
if (this.isRecoverableSessionError(errorMsg)) {
|
|
38163
38552
|
try {
|
|
38164
38553
|
await cdp.detachAgent(agent.cdpSessionId);
|
|
38165
38554
|
} catch {
|
|
@@ -38719,7 +39108,7 @@ function checkPathExists2(paths) {
|
|
|
38719
39108
|
for (const p of paths) {
|
|
38720
39109
|
if (p.includes("*")) {
|
|
38721
39110
|
const home = os15.homedir();
|
|
38722
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
39111
|
+
const resolved = p.replace(/\*/g, home.split(path12.sep).pop() || "");
|
|
38723
39112
|
if (fs9.existsSync(resolved)) return resolved;
|
|
38724
39113
|
} else {
|
|
38725
39114
|
if (fs9.existsSync(p)) return p;
|
|
@@ -38729,7 +39118,7 @@ function checkPathExists2(paths) {
|
|
|
38729
39118
|
}
|
|
38730
39119
|
function getMacAppVersion(appPath) {
|
|
38731
39120
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
38732
|
-
const plistPath =
|
|
39121
|
+
const plistPath = path12.join(appPath, "Contents", "Info.plist");
|
|
38733
39122
|
if (!fs9.existsSync(plistPath)) return null;
|
|
38734
39123
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
38735
39124
|
return raw || null;
|
|
@@ -38756,7 +39145,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
38756
39145
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
38757
39146
|
let resolvedBin = cliBin;
|
|
38758
39147
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
38759
|
-
const bundled =
|
|
39148
|
+
const bundled = path12.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
38760
39149
|
if (provider.cli && fs9.existsSync(bundled)) resolvedBin = bundled;
|
|
38761
39150
|
}
|
|
38762
39151
|
info.installed = !!(appPath || resolvedBin);
|
|
@@ -38793,16 +39182,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
38793
39182
|
}
|
|
38794
39183
|
return results;
|
|
38795
39184
|
}
|
|
38796
|
-
var fs9,
|
|
39185
|
+
var fs9, path12, os15, import_child_process7, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
38797
39186
|
var init_version_archive = __esm({
|
|
38798
39187
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
38799
39188
|
"use strict";
|
|
38800
39189
|
fs9 = __toESM(require("fs"));
|
|
38801
|
-
|
|
39190
|
+
path12 = __toESM(require("path"));
|
|
38802
39191
|
os15 = __toESM(require("os"));
|
|
38803
39192
|
import_child_process7 = require("child_process");
|
|
38804
39193
|
import_os3 = require("os");
|
|
38805
|
-
ARCHIVE_PATH =
|
|
39194
|
+
ARCHIVE_PATH = path12.join(os15.homedir(), ".adhdev", "version-history.json");
|
|
38806
39195
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
38807
39196
|
VersionArchive = class {
|
|
38808
39197
|
history = {};
|
|
@@ -38849,7 +39238,7 @@ var init_version_archive = __esm({
|
|
|
38849
39238
|
}
|
|
38850
39239
|
save() {
|
|
38851
39240
|
try {
|
|
38852
|
-
fs9.mkdirSync(
|
|
39241
|
+
fs9.mkdirSync(path12.dirname(ARCHIVE_PATH), { recursive: true });
|
|
38853
39242
|
fs9.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
38854
39243
|
} catch {
|
|
38855
39244
|
}
|
|
@@ -39370,17 +39759,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
39370
39759
|
return;
|
|
39371
39760
|
}
|
|
39372
39761
|
let scriptsPath = "";
|
|
39373
|
-
const directScripts =
|
|
39762
|
+
const directScripts = path13.join(dir, "scripts.js");
|
|
39374
39763
|
if (fs10.existsSync(directScripts)) {
|
|
39375
39764
|
scriptsPath = directScripts;
|
|
39376
39765
|
} else {
|
|
39377
|
-
const scriptsDir =
|
|
39766
|
+
const scriptsDir = path13.join(dir, "scripts");
|
|
39378
39767
|
if (fs10.existsSync(scriptsDir)) {
|
|
39379
39768
|
const versions = fs10.readdirSync(scriptsDir).filter((d) => {
|
|
39380
|
-
return fs10.statSync(
|
|
39769
|
+
return fs10.statSync(path13.join(scriptsDir, d)).isDirectory();
|
|
39381
39770
|
}).sort().reverse();
|
|
39382
39771
|
for (const ver of versions) {
|
|
39383
|
-
const p =
|
|
39772
|
+
const p = path13.join(scriptsDir, ver, "scripts.js");
|
|
39384
39773
|
if (fs10.existsSync(p)) {
|
|
39385
39774
|
scriptsPath = p;
|
|
39386
39775
|
break;
|
|
@@ -40196,12 +40585,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
40196
40585
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
40197
40586
|
}
|
|
40198
40587
|
}
|
|
40199
|
-
var fs10,
|
|
40588
|
+
var fs10, path13;
|
|
40200
40589
|
var init_dev_cdp_handlers = __esm({
|
|
40201
40590
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
40202
40591
|
"use strict";
|
|
40203
40592
|
fs10 = __toESM(require("fs"));
|
|
40204
|
-
|
|
40593
|
+
path13 = __toESM(require("path"));
|
|
40205
40594
|
init_logger();
|
|
40206
40595
|
}
|
|
40207
40596
|
});
|
|
@@ -40466,22 +40855,22 @@ function getLatestScriptVersionDir(scriptsDir) {
|
|
|
40466
40855
|
if (!fs11.existsSync(scriptsDir)) return null;
|
|
40467
40856
|
const versions = fs11.readdirSync(scriptsDir).filter((d) => {
|
|
40468
40857
|
try {
|
|
40469
|
-
return fs11.statSync(
|
|
40858
|
+
return fs11.statSync(path14.join(scriptsDir, d)).isDirectory();
|
|
40470
40859
|
} catch {
|
|
40471
40860
|
return false;
|
|
40472
40861
|
}
|
|
40473
40862
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
40474
40863
|
if (versions.length === 0) return null;
|
|
40475
|
-
return
|
|
40864
|
+
return path14.join(scriptsDir, versions[0]);
|
|
40476
40865
|
}
|
|
40477
40866
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
40478
|
-
const canonicalUserDir =
|
|
40479
|
-
const desiredDir = requestedDir ?
|
|
40480
|
-
const upstreamRoot =
|
|
40481
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
40867
|
+
const canonicalUserDir = path14.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
40868
|
+
const desiredDir = requestedDir ? path14.resolve(requestedDir) : canonicalUserDir;
|
|
40869
|
+
const upstreamRoot = path14.resolve(ctx.providerLoader.getUpstreamDir());
|
|
40870
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path14.sep}`)) {
|
|
40482
40871
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
40483
40872
|
}
|
|
40484
|
-
if (
|
|
40873
|
+
if (path14.basename(desiredDir) !== type) {
|
|
40485
40874
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
40486
40875
|
}
|
|
40487
40876
|
const sourceDir = ctx.findProviderDir(type);
|
|
@@ -40489,11 +40878,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
40489
40878
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
40490
40879
|
}
|
|
40491
40880
|
if (!fs11.existsSync(desiredDir)) {
|
|
40492
|
-
fs11.mkdirSync(
|
|
40881
|
+
fs11.mkdirSync(path14.dirname(desiredDir), { recursive: true });
|
|
40493
40882
|
fs11.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
40494
40883
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
40495
40884
|
}
|
|
40496
|
-
const providerJson =
|
|
40885
|
+
const providerJson = path14.join(desiredDir, "provider.json");
|
|
40497
40886
|
if (!fs11.existsSync(providerJson)) {
|
|
40498
40887
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
40499
40888
|
}
|
|
@@ -40516,13 +40905,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
|
40516
40905
|
const refDir = ctx.findProviderDir(referenceType);
|
|
40517
40906
|
if (!refDir || !fs11.existsSync(refDir)) return {};
|
|
40518
40907
|
const referenceScripts = {};
|
|
40519
|
-
const scriptsDir =
|
|
40908
|
+
const scriptsDir = path14.join(refDir, "scripts");
|
|
40520
40909
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
40521
40910
|
if (!latestDir) return referenceScripts;
|
|
40522
40911
|
for (const file2 of fs11.readdirSync(latestDir)) {
|
|
40523
40912
|
if (!file2.endsWith(".js")) continue;
|
|
40524
40913
|
try {
|
|
40525
|
-
referenceScripts[file2] = fs11.readFileSync(
|
|
40914
|
+
referenceScripts[file2] = fs11.readFileSync(path14.join(latestDir, file2), "utf-8");
|
|
40526
40915
|
} catch {
|
|
40527
40916
|
}
|
|
40528
40917
|
}
|
|
@@ -40573,9 +40962,9 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
40573
40962
|
});
|
|
40574
40963
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
40575
40964
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference);
|
|
40576
|
-
const tmpDir =
|
|
40965
|
+
const tmpDir = path14.join(os16.tmpdir(), "adhdev-autoimpl");
|
|
40577
40966
|
if (!fs11.existsSync(tmpDir)) fs11.mkdirSync(tmpDir, { recursive: true });
|
|
40578
|
-
const promptFile =
|
|
40967
|
+
const promptFile = path14.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
40579
40968
|
fs11.writeFileSync(promptFile, prompt, "utf-8");
|
|
40580
40969
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
40581
40970
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
@@ -40946,7 +41335,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40946
41335
|
setMode: "set_mode.js"
|
|
40947
41336
|
};
|
|
40948
41337
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
40949
|
-
const scriptsDir =
|
|
41338
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
40950
41339
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
40951
41340
|
if (latestScriptsDir) {
|
|
40952
41341
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -40957,7 +41346,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40957
41346
|
for (const file2 of fs11.readdirSync(latestScriptsDir)) {
|
|
40958
41347
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
40959
41348
|
try {
|
|
40960
|
-
const content = fs11.readFileSync(
|
|
41349
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
40961
41350
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
40962
41351
|
lines.push("```javascript");
|
|
40963
41352
|
lines.push(content);
|
|
@@ -40974,7 +41363,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40974
41363
|
lines.push("");
|
|
40975
41364
|
for (const file2 of refFiles) {
|
|
40976
41365
|
try {
|
|
40977
|
-
const content = fs11.readFileSync(
|
|
41366
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
40978
41367
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
40979
41368
|
lines.push("```javascript");
|
|
40980
41369
|
lines.push(content);
|
|
@@ -41015,10 +41404,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
41015
41404
|
lines.push("");
|
|
41016
41405
|
}
|
|
41017
41406
|
}
|
|
41018
|
-
const docsDir =
|
|
41407
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
41019
41408
|
const loadGuide = (name) => {
|
|
41020
41409
|
try {
|
|
41021
|
-
const p =
|
|
41410
|
+
const p = path14.join(docsDir, name);
|
|
41022
41411
|
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
41023
41412
|
} catch {
|
|
41024
41413
|
}
|
|
@@ -41192,7 +41581,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41192
41581
|
parseApproval: "parse_approval.js"
|
|
41193
41582
|
};
|
|
41194
41583
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
41195
|
-
const scriptsDir =
|
|
41584
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
41196
41585
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
41197
41586
|
if (latestScriptsDir) {
|
|
41198
41587
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41204,7 +41593,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41204
41593
|
if (!file2.endsWith(".js")) continue;
|
|
41205
41594
|
if (!targetFileNames.has(file2)) continue;
|
|
41206
41595
|
try {
|
|
41207
|
-
const content = fs11.readFileSync(
|
|
41596
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41208
41597
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41209
41598
|
lines.push("```javascript");
|
|
41210
41599
|
lines.push(content);
|
|
@@ -41220,7 +41609,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41220
41609
|
lines.push("");
|
|
41221
41610
|
for (const file2 of refFiles) {
|
|
41222
41611
|
try {
|
|
41223
|
-
const content = fs11.readFileSync(
|
|
41612
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41224
41613
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41225
41614
|
lines.push("```javascript");
|
|
41226
41615
|
lines.push(content);
|
|
@@ -41253,10 +41642,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41253
41642
|
lines.push("");
|
|
41254
41643
|
}
|
|
41255
41644
|
}
|
|
41256
|
-
const docsDir =
|
|
41645
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
41257
41646
|
const loadGuide = (name) => {
|
|
41258
41647
|
try {
|
|
41259
|
-
const p =
|
|
41648
|
+
const p = path14.join(docsDir, name);
|
|
41260
41649
|
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
41261
41650
|
} catch {
|
|
41262
41651
|
}
|
|
@@ -41420,25 +41809,25 @@ data: ${JSON.stringify(msg.data)}
|
|
|
41420
41809
|
}
|
|
41421
41810
|
}
|
|
41422
41811
|
}
|
|
41423
|
-
var fs11,
|
|
41812
|
+
var fs11, path14, os16;
|
|
41424
41813
|
var init_dev_auto_implement = __esm({
|
|
41425
41814
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
41426
41815
|
"use strict";
|
|
41427
41816
|
fs11 = __toESM(require("fs"));
|
|
41428
|
-
|
|
41817
|
+
path14 = __toESM(require("path"));
|
|
41429
41818
|
os16 = __toESM(require("os"));
|
|
41430
41819
|
init_dev_server();
|
|
41431
41820
|
}
|
|
41432
41821
|
});
|
|
41433
41822
|
|
|
41434
41823
|
// ../../oss/packages/daemon-core/src/daemon/dev-server.ts
|
|
41435
|
-
var http2, fs12,
|
|
41824
|
+
var http2, fs12, path15, DEV_SERVER_PORT, DevServer;
|
|
41436
41825
|
var init_dev_server = __esm({
|
|
41437
41826
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
41438
41827
|
"use strict";
|
|
41439
41828
|
http2 = __toESM(require("http"));
|
|
41440
41829
|
fs12 = __toESM(require("fs"));
|
|
41441
|
-
|
|
41830
|
+
path15 = __toESM(require("path"));
|
|
41442
41831
|
init_scaffold_template();
|
|
41443
41832
|
init_version_archive();
|
|
41444
41833
|
init_logger();
|
|
@@ -41537,8 +41926,8 @@ var init_dev_server = __esm({
|
|
|
41537
41926
|
}
|
|
41538
41927
|
getEndpointList() {
|
|
41539
41928
|
return this.routes.map((r) => {
|
|
41540
|
-
const
|
|
41541
|
-
return `${r.method.padEnd(5)} ${
|
|
41929
|
+
const path19 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
41930
|
+
return `${r.method.padEnd(5)} ${path19}`;
|
|
41542
41931
|
});
|
|
41543
41932
|
}
|
|
41544
41933
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -41569,15 +41958,15 @@ var init_dev_server = __esm({
|
|
|
41569
41958
|
this.json(res, 500, { error: e.message });
|
|
41570
41959
|
}
|
|
41571
41960
|
});
|
|
41572
|
-
return new Promise((
|
|
41961
|
+
return new Promise((resolve13, reject) => {
|
|
41573
41962
|
this.server.listen(port, "127.0.0.1", () => {
|
|
41574
41963
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
41575
|
-
|
|
41964
|
+
resolve13();
|
|
41576
41965
|
});
|
|
41577
41966
|
this.server.on("error", (e) => {
|
|
41578
41967
|
if (e.code === "EADDRINUSE") {
|
|
41579
41968
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
41580
|
-
|
|
41969
|
+
resolve13();
|
|
41581
41970
|
} else {
|
|
41582
41971
|
reject(e);
|
|
41583
41972
|
}
|
|
@@ -41660,20 +42049,20 @@ var init_dev_server = __esm({
|
|
|
41660
42049
|
child.stderr?.on("data", (d) => {
|
|
41661
42050
|
stderr += d.toString().slice(0, 2e3);
|
|
41662
42051
|
});
|
|
41663
|
-
await new Promise((
|
|
42052
|
+
await new Promise((resolve13) => {
|
|
41664
42053
|
const timer = setTimeout(() => {
|
|
41665
42054
|
child.kill();
|
|
41666
|
-
|
|
42055
|
+
resolve13();
|
|
41667
42056
|
}, 3e3);
|
|
41668
42057
|
child.on("exit", () => {
|
|
41669
42058
|
clearTimeout(timer);
|
|
41670
|
-
|
|
42059
|
+
resolve13();
|
|
41671
42060
|
});
|
|
41672
42061
|
child.stdout?.once("data", () => {
|
|
41673
42062
|
setTimeout(() => {
|
|
41674
42063
|
child.kill();
|
|
41675
42064
|
clearTimeout(timer);
|
|
41676
|
-
|
|
42065
|
+
resolve13();
|
|
41677
42066
|
}, 500);
|
|
41678
42067
|
});
|
|
41679
42068
|
});
|
|
@@ -41820,12 +42209,12 @@ var init_dev_server = __esm({
|
|
|
41820
42209
|
// ─── DevConsole SPA ───
|
|
41821
42210
|
getConsoleDistDir() {
|
|
41822
42211
|
const candidates = [
|
|
41823
|
-
|
|
41824
|
-
|
|
41825
|
-
|
|
42212
|
+
path15.resolve(__dirname, "../../web-devconsole/dist"),
|
|
42213
|
+
path15.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
42214
|
+
path15.join(process.cwd(), "packages/web-devconsole/dist")
|
|
41826
42215
|
];
|
|
41827
42216
|
for (const dir of candidates) {
|
|
41828
|
-
if (fs12.existsSync(
|
|
42217
|
+
if (fs12.existsSync(path15.join(dir, "index.html"))) return dir;
|
|
41829
42218
|
}
|
|
41830
42219
|
return null;
|
|
41831
42220
|
}
|
|
@@ -41835,7 +42224,7 @@ var init_dev_server = __esm({
|
|
|
41835
42224
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
41836
42225
|
return;
|
|
41837
42226
|
}
|
|
41838
|
-
const htmlPath =
|
|
42227
|
+
const htmlPath = path15.join(distDir, "index.html");
|
|
41839
42228
|
try {
|
|
41840
42229
|
const html = fs12.readFileSync(htmlPath, "utf-8");
|
|
41841
42230
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -41860,15 +42249,15 @@ var init_dev_server = __esm({
|
|
|
41860
42249
|
this.json(res, 404, { error: "Not found" });
|
|
41861
42250
|
return;
|
|
41862
42251
|
}
|
|
41863
|
-
const safePath =
|
|
41864
|
-
const filePath =
|
|
42252
|
+
const safePath = path15.normalize(pathname).replace(/^\.\.\//, "");
|
|
42253
|
+
const filePath = path15.join(distDir, safePath);
|
|
41865
42254
|
if (!filePath.startsWith(distDir)) {
|
|
41866
42255
|
this.json(res, 403, { error: "Forbidden" });
|
|
41867
42256
|
return;
|
|
41868
42257
|
}
|
|
41869
42258
|
try {
|
|
41870
42259
|
const content = fs12.readFileSync(filePath);
|
|
41871
|
-
const ext =
|
|
42260
|
+
const ext = path15.extname(filePath);
|
|
41872
42261
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
41873
42262
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
41874
42263
|
res.end(content);
|
|
@@ -41981,9 +42370,9 @@ var init_dev_server = __esm({
|
|
|
41981
42370
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
41982
42371
|
if (entry.isDirectory()) {
|
|
41983
42372
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
41984
|
-
scan(
|
|
42373
|
+
scan(path15.join(d, entry.name), rel);
|
|
41985
42374
|
} else {
|
|
41986
|
-
const stat4 = fs12.statSync(
|
|
42375
|
+
const stat4 = fs12.statSync(path15.join(d, entry.name));
|
|
41987
42376
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
41988
42377
|
}
|
|
41989
42378
|
}
|
|
@@ -42006,7 +42395,7 @@ var init_dev_server = __esm({
|
|
|
42006
42395
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42007
42396
|
return;
|
|
42008
42397
|
}
|
|
42009
|
-
const fullPath =
|
|
42398
|
+
const fullPath = path15.resolve(dir, path15.normalize(filePath));
|
|
42010
42399
|
if (!fullPath.startsWith(dir)) {
|
|
42011
42400
|
this.json(res, 403, { error: "Forbidden" });
|
|
42012
42401
|
return;
|
|
@@ -42031,14 +42420,14 @@ var init_dev_server = __esm({
|
|
|
42031
42420
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
42032
42421
|
return;
|
|
42033
42422
|
}
|
|
42034
|
-
const fullPath =
|
|
42423
|
+
const fullPath = path15.resolve(dir, path15.normalize(filePath));
|
|
42035
42424
|
if (!fullPath.startsWith(dir)) {
|
|
42036
42425
|
this.json(res, 403, { error: "Forbidden" });
|
|
42037
42426
|
return;
|
|
42038
42427
|
}
|
|
42039
42428
|
try {
|
|
42040
42429
|
if (fs12.existsSync(fullPath)) fs12.copyFileSync(fullPath, fullPath + ".bak");
|
|
42041
|
-
fs12.mkdirSync(
|
|
42430
|
+
fs12.mkdirSync(path15.dirname(fullPath), { recursive: true });
|
|
42042
42431
|
fs12.writeFileSync(fullPath, content, "utf-8");
|
|
42043
42432
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
42044
42433
|
this.providerLoader.reload();
|
|
@@ -42055,7 +42444,7 @@ var init_dev_server = __esm({
|
|
|
42055
42444
|
return;
|
|
42056
42445
|
}
|
|
42057
42446
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
42058
|
-
const p =
|
|
42447
|
+
const p = path15.join(dir, name);
|
|
42059
42448
|
if (fs12.existsSync(p)) {
|
|
42060
42449
|
const source = fs12.readFileSync(p, "utf-8");
|
|
42061
42450
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
@@ -42076,8 +42465,8 @@ var init_dev_server = __esm({
|
|
|
42076
42465
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
42077
42466
|
return;
|
|
42078
42467
|
}
|
|
42079
|
-
const target = fs12.existsSync(
|
|
42080
|
-
const targetPath =
|
|
42468
|
+
const target = fs12.existsSync(path15.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
42469
|
+
const targetPath = path15.join(dir, target);
|
|
42081
42470
|
try {
|
|
42082
42471
|
if (fs12.existsSync(targetPath)) fs12.copyFileSync(targetPath, targetPath + ".bak");
|
|
42083
42472
|
fs12.writeFileSync(targetPath, source, "utf-8");
|
|
@@ -42182,14 +42571,14 @@ var init_dev_server = __esm({
|
|
|
42182
42571
|
child.stderr?.on("data", (d) => {
|
|
42183
42572
|
stderr += d.toString();
|
|
42184
42573
|
});
|
|
42185
|
-
await new Promise((
|
|
42574
|
+
await new Promise((resolve13) => {
|
|
42186
42575
|
const timer = setTimeout(() => {
|
|
42187
42576
|
child.kill();
|
|
42188
|
-
|
|
42577
|
+
resolve13();
|
|
42189
42578
|
}, timeout);
|
|
42190
42579
|
child.on("exit", () => {
|
|
42191
42580
|
clearTimeout(timer);
|
|
42192
|
-
|
|
42581
|
+
resolve13();
|
|
42193
42582
|
});
|
|
42194
42583
|
});
|
|
42195
42584
|
const elapsed = Date.now() - start;
|
|
@@ -42237,7 +42626,7 @@ var init_dev_server = __esm({
|
|
|
42237
42626
|
}
|
|
42238
42627
|
let targetDir;
|
|
42239
42628
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
42240
|
-
const jsonPath =
|
|
42629
|
+
const jsonPath = path15.join(targetDir, "provider.json");
|
|
42241
42630
|
if (fs12.existsSync(jsonPath)) {
|
|
42242
42631
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
42243
42632
|
return;
|
|
@@ -42249,8 +42638,8 @@ var init_dev_server = __esm({
|
|
|
42249
42638
|
const createdFiles = ["provider.json"];
|
|
42250
42639
|
if (result.files) {
|
|
42251
42640
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
42252
|
-
const fullPath =
|
|
42253
|
-
fs12.mkdirSync(
|
|
42641
|
+
const fullPath = path15.join(targetDir, relPath);
|
|
42642
|
+
fs12.mkdirSync(path15.dirname(fullPath), { recursive: true });
|
|
42254
42643
|
fs12.writeFileSync(fullPath, content, "utf-8");
|
|
42255
42644
|
createdFiles.push(relPath);
|
|
42256
42645
|
}
|
|
@@ -42303,22 +42692,22 @@ var init_dev_server = __esm({
|
|
|
42303
42692
|
if (!fs12.existsSync(scriptsDir)) return null;
|
|
42304
42693
|
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
42305
42694
|
try {
|
|
42306
|
-
return fs12.statSync(
|
|
42695
|
+
return fs12.statSync(path15.join(scriptsDir, d)).isDirectory();
|
|
42307
42696
|
} catch {
|
|
42308
42697
|
return false;
|
|
42309
42698
|
}
|
|
42310
42699
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
42311
42700
|
if (versions.length === 0) return null;
|
|
42312
|
-
return
|
|
42701
|
+
return path15.join(scriptsDir, versions[0]);
|
|
42313
42702
|
}
|
|
42314
42703
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
42315
|
-
const canonicalUserDir =
|
|
42316
|
-
const desiredDir = requestedDir ?
|
|
42317
|
-
const upstreamRoot =
|
|
42318
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
42704
|
+
const canonicalUserDir = path15.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
42705
|
+
const desiredDir = requestedDir ? path15.resolve(requestedDir) : canonicalUserDir;
|
|
42706
|
+
const upstreamRoot = path15.resolve(this.providerLoader.getUpstreamDir());
|
|
42707
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path15.sep}`)) {
|
|
42319
42708
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
42320
42709
|
}
|
|
42321
|
-
if (
|
|
42710
|
+
if (path15.basename(desiredDir) !== type) {
|
|
42322
42711
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
42323
42712
|
}
|
|
42324
42713
|
const sourceDir = this.findProviderDir(type);
|
|
@@ -42326,11 +42715,11 @@ var init_dev_server = __esm({
|
|
|
42326
42715
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
42327
42716
|
}
|
|
42328
42717
|
if (!fs12.existsSync(desiredDir)) {
|
|
42329
|
-
fs12.mkdirSync(
|
|
42718
|
+
fs12.mkdirSync(path15.dirname(desiredDir), { recursive: true });
|
|
42330
42719
|
fs12.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
42331
42720
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
42332
42721
|
}
|
|
42333
|
-
const providerJson =
|
|
42722
|
+
const providerJson = path15.join(desiredDir, "provider.json");
|
|
42334
42723
|
if (!fs12.existsSync(providerJson)) {
|
|
42335
42724
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
42336
42725
|
}
|
|
@@ -42378,7 +42767,7 @@ var init_dev_server = __esm({
|
|
|
42378
42767
|
setMode: "set_mode.js"
|
|
42379
42768
|
};
|
|
42380
42769
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
42381
|
-
const scriptsDir =
|
|
42770
|
+
const scriptsDir = path15.join(providerDir, "scripts");
|
|
42382
42771
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
42383
42772
|
if (latestScriptsDir) {
|
|
42384
42773
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -42389,7 +42778,7 @@ var init_dev_server = __esm({
|
|
|
42389
42778
|
for (const file2 of fs12.readdirSync(latestScriptsDir)) {
|
|
42390
42779
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
42391
42780
|
try {
|
|
42392
|
-
const content = fs12.readFileSync(
|
|
42781
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42393
42782
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
42394
42783
|
lines.push("```javascript");
|
|
42395
42784
|
lines.push(content);
|
|
@@ -42406,7 +42795,7 @@ var init_dev_server = __esm({
|
|
|
42406
42795
|
lines.push("");
|
|
42407
42796
|
for (const file2 of refFiles) {
|
|
42408
42797
|
try {
|
|
42409
|
-
const content = fs12.readFileSync(
|
|
42798
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42410
42799
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
42411
42800
|
lines.push("```javascript");
|
|
42412
42801
|
lines.push(content);
|
|
@@ -42447,10 +42836,10 @@ var init_dev_server = __esm({
|
|
|
42447
42836
|
lines.push("");
|
|
42448
42837
|
}
|
|
42449
42838
|
}
|
|
42450
|
-
const docsDir =
|
|
42839
|
+
const docsDir = path15.join(providerDir, "../../docs");
|
|
42451
42840
|
const loadGuide = (name) => {
|
|
42452
42841
|
try {
|
|
42453
|
-
const p =
|
|
42842
|
+
const p = path15.join(docsDir, name);
|
|
42454
42843
|
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
42455
42844
|
} catch {
|
|
42456
42845
|
}
|
|
@@ -42624,7 +43013,7 @@ var init_dev_server = __esm({
|
|
|
42624
43013
|
parseApproval: "parse_approval.js"
|
|
42625
43014
|
};
|
|
42626
43015
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
42627
|
-
const scriptsDir =
|
|
43016
|
+
const scriptsDir = path15.join(providerDir, "scripts");
|
|
42628
43017
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
42629
43018
|
if (latestScriptsDir) {
|
|
42630
43019
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -42636,7 +43025,7 @@ var init_dev_server = __esm({
|
|
|
42636
43025
|
if (!file2.endsWith(".js")) continue;
|
|
42637
43026
|
if (!targetFileNames.has(file2)) continue;
|
|
42638
43027
|
try {
|
|
42639
|
-
const content = fs12.readFileSync(
|
|
43028
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42640
43029
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
42641
43030
|
lines.push("```javascript");
|
|
42642
43031
|
lines.push(content);
|
|
@@ -42652,7 +43041,7 @@ var init_dev_server = __esm({
|
|
|
42652
43041
|
lines.push("");
|
|
42653
43042
|
for (const file2 of refFiles) {
|
|
42654
43043
|
try {
|
|
42655
|
-
const content = fs12.readFileSync(
|
|
43044
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42656
43045
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
42657
43046
|
lines.push("```javascript");
|
|
42658
43047
|
lines.push(content);
|
|
@@ -42685,10 +43074,10 @@ var init_dev_server = __esm({
|
|
|
42685
43074
|
lines.push("");
|
|
42686
43075
|
}
|
|
42687
43076
|
}
|
|
42688
|
-
const docsDir =
|
|
43077
|
+
const docsDir = path15.join(providerDir, "../../docs");
|
|
42689
43078
|
const loadGuide = (name) => {
|
|
42690
43079
|
try {
|
|
42691
|
-
const p =
|
|
43080
|
+
const p = path15.join(docsDir, name);
|
|
42692
43081
|
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
42693
43082
|
} catch {
|
|
42694
43083
|
}
|
|
@@ -42845,14 +43234,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
42845
43234
|
res.end(JSON.stringify(data, null, 2));
|
|
42846
43235
|
}
|
|
42847
43236
|
async readBody(req) {
|
|
42848
|
-
return new Promise((
|
|
43237
|
+
return new Promise((resolve13) => {
|
|
42849
43238
|
let body = "";
|
|
42850
43239
|
req.on("data", (chunk) => body += chunk);
|
|
42851
43240
|
req.on("end", () => {
|
|
42852
43241
|
try {
|
|
42853
|
-
|
|
43242
|
+
resolve13(JSON.parse(body));
|
|
42854
43243
|
} catch {
|
|
42855
|
-
|
|
43244
|
+
resolve13({});
|
|
42856
43245
|
}
|
|
42857
43246
|
});
|
|
42858
43247
|
});
|
|
@@ -42976,8 +43365,8 @@ var init_dist = __esm({
|
|
|
42976
43365
|
}
|
|
42977
43366
|
this.requestWaiters.clear();
|
|
42978
43367
|
});
|
|
42979
|
-
await new Promise((
|
|
42980
|
-
socket.once("connect", () =>
|
|
43368
|
+
await new Promise((resolve13, reject) => {
|
|
43369
|
+
socket.once("connect", () => resolve13());
|
|
42981
43370
|
socket.once("error", reject);
|
|
42982
43371
|
});
|
|
42983
43372
|
}
|
|
@@ -42996,7 +43385,7 @@ var init_dist = __esm({
|
|
|
42996
43385
|
requestId,
|
|
42997
43386
|
request
|
|
42998
43387
|
};
|
|
42999
|
-
const response = await new Promise((
|
|
43388
|
+
const response = await new Promise((resolve13, reject) => {
|
|
43000
43389
|
const timeout = setTimeout(() => {
|
|
43001
43390
|
this.requestWaiters.delete(requestId);
|
|
43002
43391
|
reject(new Error(`Session host request timed out after 30s (${request.type})`));
|
|
@@ -43004,7 +43393,7 @@ var init_dist = __esm({
|
|
|
43004
43393
|
this.requestWaiters.set(requestId, {
|
|
43005
43394
|
resolve: (value) => {
|
|
43006
43395
|
clearTimeout(timeout);
|
|
43007
|
-
|
|
43396
|
+
resolve13(value);
|
|
43008
43397
|
},
|
|
43009
43398
|
reject: (error48) => {
|
|
43010
43399
|
clearTimeout(timeout);
|
|
@@ -43023,12 +43412,12 @@ var init_dist = __esm({
|
|
|
43023
43412
|
waiter.reject(new Error("Session host client closed"));
|
|
43024
43413
|
}
|
|
43025
43414
|
this.requestWaiters.clear();
|
|
43026
|
-
await new Promise((
|
|
43415
|
+
await new Promise((resolve13) => {
|
|
43027
43416
|
let settled = false;
|
|
43028
43417
|
const done = () => {
|
|
43029
43418
|
if (settled) return;
|
|
43030
43419
|
settled = true;
|
|
43031
|
-
|
|
43420
|
+
resolve13();
|
|
43032
43421
|
};
|
|
43033
43422
|
socket.once("close", done);
|
|
43034
43423
|
socket.end();
|
|
@@ -43405,7 +43794,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
|
|
|
43405
43794
|
const deadline = Date.now() + timeoutMs;
|
|
43406
43795
|
while (Date.now() < deadline) {
|
|
43407
43796
|
if (await canConnect(endpoint)) return;
|
|
43408
|
-
await new Promise((
|
|
43797
|
+
await new Promise((resolve13) => setTimeout(resolve13, STARTUP_POLL_MS));
|
|
43409
43798
|
}
|
|
43410
43799
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
43411
43800
|
}
|
|
@@ -43495,10 +43884,10 @@ async function installExtension(ide, extension) {
|
|
|
43495
43884
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
43496
43885
|
const fs16 = await import("fs");
|
|
43497
43886
|
fs16.writeFileSync(vsixPath, buffer);
|
|
43498
|
-
return new Promise((
|
|
43887
|
+
return new Promise((resolve13) => {
|
|
43499
43888
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
43500
43889
|
(0, import_child_process8.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
43501
|
-
|
|
43890
|
+
resolve13({
|
|
43502
43891
|
extensionId: extension.id,
|
|
43503
43892
|
marketplaceId: extension.marketplaceId,
|
|
43504
43893
|
success: !error48,
|
|
@@ -43511,11 +43900,11 @@ async function installExtension(ide, extension) {
|
|
|
43511
43900
|
} catch (e) {
|
|
43512
43901
|
}
|
|
43513
43902
|
}
|
|
43514
|
-
return new Promise((
|
|
43903
|
+
return new Promise((resolve13) => {
|
|
43515
43904
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
43516
43905
|
(0, import_child_process8.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
|
|
43517
43906
|
if (error48) {
|
|
43518
|
-
|
|
43907
|
+
resolve13({
|
|
43519
43908
|
extensionId: extension.id,
|
|
43520
43909
|
marketplaceId: extension.marketplaceId,
|
|
43521
43910
|
success: false,
|
|
@@ -43523,7 +43912,7 @@ async function installExtension(ide, extension) {
|
|
|
43523
43912
|
error: stderr || error48.message
|
|
43524
43913
|
});
|
|
43525
43914
|
} else {
|
|
43526
|
-
|
|
43915
|
+
resolve13({
|
|
43527
43916
|
extensionId: extension.id,
|
|
43528
43917
|
marketplaceId: extension.marketplaceId,
|
|
43529
43918
|
success: true,
|
|
@@ -43934,6 +44323,7 @@ __export(src_exports, {
|
|
|
43934
44323
|
SessionHostPtyTransportFactory: () => SessionHostPtyTransportFactory,
|
|
43935
44324
|
VersionArchive: () => VersionArchive,
|
|
43936
44325
|
addCliHistory: () => addCliHistory,
|
|
44326
|
+
appendRecentActivity: () => appendRecentActivity,
|
|
43937
44327
|
buildSessionEntries: () => buildSessionEntries,
|
|
43938
44328
|
buildStatusSnapshot: () => buildStatusSnapshot,
|
|
43939
44329
|
connectCdpManager: () => connectCdpManager,
|
|
@@ -43947,6 +44337,7 @@ __export(src_exports, {
|
|
|
43947
44337
|
getAvailableIdeIds: () => getAvailableIdeIds,
|
|
43948
44338
|
getHostMemorySnapshot: () => getHostMemorySnapshot,
|
|
43949
44339
|
getLogLevel: () => getLogLevel,
|
|
44340
|
+
getRecentActivity: () => getRecentActivity,
|
|
43950
44341
|
getRecentCommands: () => getRecentCommands,
|
|
43951
44342
|
getRecentLogs: () => getRecentLogs,
|
|
43952
44343
|
getWorkspaceActivity: () => getWorkspaceActivity,
|
|
@@ -43987,6 +44378,7 @@ var init_src = __esm({
|
|
|
43987
44378
|
init_config();
|
|
43988
44379
|
init_workspaces();
|
|
43989
44380
|
init_workspace_activity();
|
|
44381
|
+
init_recent_activity();
|
|
43990
44382
|
init_ide_detector();
|
|
43991
44383
|
init_cli_detector();
|
|
43992
44384
|
init_host_memory();
|
|
@@ -44218,9 +44610,9 @@ var init_server_connection = __esm({
|
|
|
44218
44610
|
LOG.info("Server", `[ServerConn] Run 'adhdev setup' to re-authenticate.`);
|
|
44219
44611
|
this.setState("disconnected");
|
|
44220
44612
|
try {
|
|
44221
|
-
const
|
|
44613
|
+
const path19 = require("path");
|
|
44222
44614
|
const fs16 = require("fs");
|
|
44223
|
-
const configPath =
|
|
44615
|
+
const configPath = path19.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
|
|
44224
44616
|
if (fs16.existsSync(configPath)) {
|
|
44225
44617
|
fs16.unlinkSync(configPath);
|
|
44226
44618
|
LOG.info("Server", `[ServerConn] Config file removed. Re-run 'adhdev setup'.`);
|
|
@@ -44331,17 +44723,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
|
|
|
44331
44723
|
return false;
|
|
44332
44724
|
}
|
|
44333
44725
|
}
|
|
44334
|
-
var fs13,
|
|
44726
|
+
var fs13, path16, os18, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
|
|
44335
44727
|
var init_daemon_p2p = __esm({
|
|
44336
44728
|
"src/daemon-p2p.ts"() {
|
|
44337
44729
|
"use strict";
|
|
44338
44730
|
fs13 = __toESM(require("fs"));
|
|
44339
44731
|
init_src();
|
|
44340
|
-
|
|
44732
|
+
path16 = __toESM(require("path"));
|
|
44341
44733
|
os18 = __toESM(require("os"));
|
|
44342
44734
|
import_node_module = require("module");
|
|
44343
44735
|
esmRequire = (0, import_node_module.createRequire)(__filename);
|
|
44344
|
-
logFile =
|
|
44736
|
+
logFile = path16.join(os18.tmpdir(), "adhdev_daemon_p2p.log");
|
|
44345
44737
|
log = (msg) => {
|
|
44346
44738
|
LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
|
|
44347
44739
|
};
|
|
@@ -44409,15 +44801,15 @@ ${e?.stack || ""}`);
|
|
|
44409
44801
|
const prebuildKey = `${platform11}-${arch3}`;
|
|
44410
44802
|
try {
|
|
44411
44803
|
const candidates = [
|
|
44412
|
-
|
|
44413
|
-
|
|
44414
|
-
|
|
44804
|
+
path16.join(__dirname, "node_modules", "node-datachannel"),
|
|
44805
|
+
path16.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
44806
|
+
path16.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
44415
44807
|
];
|
|
44416
44808
|
for (const candidate of candidates) {
|
|
44417
|
-
const prebuildPath =
|
|
44809
|
+
const prebuildPath = path16.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
|
|
44418
44810
|
if (fs13.existsSync(prebuildPath)) {
|
|
44419
|
-
const targetDir =
|
|
44420
|
-
const targetPath =
|
|
44811
|
+
const targetDir = path16.join(candidate, "build", "Release");
|
|
44812
|
+
const targetPath = path16.join(targetDir, "node_datachannel.node");
|
|
44421
44813
|
fs13.mkdirSync(targetDir, { recursive: true });
|
|
44422
44814
|
fs13.copyFileSync(prebuildPath, targetPath);
|
|
44423
44815
|
try {
|
|
@@ -44493,7 +44885,7 @@ ${e?.stack || ""}`);
|
|
|
44493
44885
|
async fetchTurnCredentials() {
|
|
44494
44886
|
try {
|
|
44495
44887
|
const serverUrl = process.env.ADHDEV_SERVER_URL || "https://api.adhf.dev";
|
|
44496
|
-
const configPath =
|
|
44888
|
+
const configPath = path16.join(os18.homedir(), ".adhdev", "config.json");
|
|
44497
44889
|
let token = "";
|
|
44498
44890
|
try {
|
|
44499
44891
|
const config2 = JSON.parse(fs13.readFileSync(configPath, "utf-8"));
|
|
@@ -44501,13 +44893,13 @@ ${e?.stack || ""}`);
|
|
|
44501
44893
|
} catch {
|
|
44502
44894
|
}
|
|
44503
44895
|
const http3 = esmRequire("https");
|
|
44504
|
-
const data = await new Promise((
|
|
44896
|
+
const data = await new Promise((resolve13, reject) => {
|
|
44505
44897
|
const req = http3.get(`${serverUrl}/api/v1/turn/credentials`, {
|
|
44506
44898
|
headers: { "Authorization": `Bearer ${token}` }
|
|
44507
44899
|
}, (res) => {
|
|
44508
44900
|
let d = "";
|
|
44509
44901
|
res.on("data", (c) => d += c);
|
|
44510
|
-
res.on("end", () =>
|
|
44902
|
+
res.on("end", () => resolve13(d));
|
|
44511
44903
|
});
|
|
44512
44904
|
req.on("error", reject);
|
|
44513
44905
|
req.setTimeout(5e3, () => {
|
|
@@ -45320,8 +45712,8 @@ __export(session_host_exports, {
|
|
|
45320
45712
|
});
|
|
45321
45713
|
function resolveSessionHostEntry() {
|
|
45322
45714
|
const packagedCandidates = [
|
|
45323
|
-
|
|
45324
|
-
|
|
45715
|
+
path17.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
45716
|
+
path17.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
45325
45717
|
];
|
|
45326
45718
|
for (const candidate of packagedCandidates) {
|
|
45327
45719
|
if (fs14.existsSync(candidate)) {
|
|
@@ -45331,7 +45723,7 @@ function resolveSessionHostEntry() {
|
|
|
45331
45723
|
return require.resolve("@adhdev/session-host-daemon");
|
|
45332
45724
|
}
|
|
45333
45725
|
function getSessionHostPidFile() {
|
|
45334
|
-
return
|
|
45726
|
+
return path17.join(os19.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
45335
45727
|
}
|
|
45336
45728
|
function killPid(pid) {
|
|
45337
45729
|
try {
|
|
@@ -45397,14 +45789,14 @@ async function ensureSessionHostReady2() {
|
|
|
45397
45789
|
async function listHostedCliRuntimes2(endpoint) {
|
|
45398
45790
|
return listHostedCliRuntimes(endpoint);
|
|
45399
45791
|
}
|
|
45400
|
-
var import_child_process9, fs14, os19,
|
|
45792
|
+
var import_child_process9, fs14, os19, path17, SESSION_HOST_APP_NAME;
|
|
45401
45793
|
var init_session_host = __esm({
|
|
45402
45794
|
"src/session-host.ts"() {
|
|
45403
45795
|
"use strict";
|
|
45404
45796
|
import_child_process9 = require("child_process");
|
|
45405
45797
|
fs14 = __toESM(require("fs"));
|
|
45406
45798
|
os19 = __toESM(require("os"));
|
|
45407
|
-
|
|
45799
|
+
path17 = __toESM(require("path"));
|
|
45408
45800
|
init_src();
|
|
45409
45801
|
SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
45410
45802
|
}
|
|
@@ -45418,9 +45810,9 @@ __export(adhdev_daemon_exports, {
|
|
|
45418
45810
|
stopDaemon: () => stopDaemon
|
|
45419
45811
|
});
|
|
45420
45812
|
function getDaemonPidFile() {
|
|
45421
|
-
const dir =
|
|
45813
|
+
const dir = path18.join(os20.homedir(), ".adhdev");
|
|
45422
45814
|
if (!fs15.existsSync(dir)) fs15.mkdirSync(dir, { recursive: true });
|
|
45423
|
-
return
|
|
45815
|
+
return path18.join(dir, "daemon.pid");
|
|
45424
45816
|
}
|
|
45425
45817
|
function writeDaemonPid(pid) {
|
|
45426
45818
|
fs15.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
|
|
@@ -45456,7 +45848,7 @@ function stopDaemon() {
|
|
|
45456
45848
|
return false;
|
|
45457
45849
|
}
|
|
45458
45850
|
}
|
|
45459
|
-
var os20, fs15,
|
|
45851
|
+
var os20, fs15, path18, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
45460
45852
|
var init_adhdev_daemon = __esm({
|
|
45461
45853
|
"src/adhdev-daemon.ts"() {
|
|
45462
45854
|
"use strict";
|
|
@@ -45468,14 +45860,14 @@ var init_adhdev_daemon = __esm({
|
|
|
45468
45860
|
init_dist();
|
|
45469
45861
|
os20 = __toESM(require("os"));
|
|
45470
45862
|
fs15 = __toESM(require("fs"));
|
|
45471
|
-
|
|
45863
|
+
path18 = __toESM(require("path"));
|
|
45472
45864
|
import_chalk2 = __toESM(require("chalk"));
|
|
45473
|
-
pkgVersion = "0.7.
|
|
45865
|
+
pkgVersion = "0.7.37";
|
|
45474
45866
|
if (pkgVersion === "unknown") {
|
|
45475
45867
|
try {
|
|
45476
45868
|
const possiblePaths = [
|
|
45477
|
-
|
|
45478
|
-
|
|
45869
|
+
path18.join(__dirname, "..", "package.json"),
|
|
45870
|
+
path18.join(__dirname, "package.json")
|
|
45479
45871
|
];
|
|
45480
45872
|
for (const p of possiblePaths) {
|
|
45481
45873
|
try {
|
|
@@ -46155,8 +46547,8 @@ async function startDaemonFlow() {
|
|
|
46155
46547
|
const daemon = new AdhdevDaemon2();
|
|
46156
46548
|
const { execSync: execSync7 } = await import("child_process");
|
|
46157
46549
|
const os21 = await import("os");
|
|
46158
|
-
const
|
|
46159
|
-
const logPath =
|
|
46550
|
+
const path19 = await import("path");
|
|
46551
|
+
const logPath = path19.join(os21.homedir(), ".adhdev", "daemon.log");
|
|
46160
46552
|
const platform11 = os21.platform();
|
|
46161
46553
|
try {
|
|
46162
46554
|
if (platform11 === "win32") {
|
|
@@ -46319,7 +46711,7 @@ __export(cdp_utils_exports, {
|
|
|
46319
46711
|
async function sendDaemonCommand(cmd, args = {}, port = 19222) {
|
|
46320
46712
|
const WebSocket3 = (await import("ws")).default;
|
|
46321
46713
|
const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
46322
|
-
return new Promise((
|
|
46714
|
+
return new Promise((resolve13, reject) => {
|
|
46323
46715
|
const wsUrl = `ws://127.0.0.1:${port}${DAEMON_WS_PATH2 || "/daemon"}`;
|
|
46324
46716
|
const ws2 = new WebSocket3(wsUrl);
|
|
46325
46717
|
const timeout = setTimeout(() => {
|
|
@@ -46350,7 +46742,7 @@ async function sendDaemonCommand(cmd, args = {}, port = 19222) {
|
|
|
46350
46742
|
if (msg.type === "daemon:command_result" || msg.type === "command_result") {
|
|
46351
46743
|
clearTimeout(timeout);
|
|
46352
46744
|
ws2.close();
|
|
46353
|
-
|
|
46745
|
+
resolve13(msg.payload?.result || msg.payload || msg);
|
|
46354
46746
|
}
|
|
46355
46747
|
} catch {
|
|
46356
46748
|
}
|
|
@@ -46367,13 +46759,13 @@ Is 'adhdev daemon' running?`));
|
|
|
46367
46759
|
}
|
|
46368
46760
|
async function directCdpEval(expression, port = 9222) {
|
|
46369
46761
|
const http3 = await import("http");
|
|
46370
|
-
const targets = await new Promise((
|
|
46762
|
+
const targets = await new Promise((resolve13, reject) => {
|
|
46371
46763
|
http3.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
46372
46764
|
let data = "";
|
|
46373
46765
|
res.on("data", (c) => data += c);
|
|
46374
46766
|
res.on("end", () => {
|
|
46375
46767
|
try {
|
|
46376
|
-
|
|
46768
|
+
resolve13(JSON.parse(data));
|
|
46377
46769
|
} catch {
|
|
46378
46770
|
reject(new Error("Invalid JSON"));
|
|
46379
46771
|
}
|
|
@@ -46386,7 +46778,7 @@ async function directCdpEval(expression, port = 9222) {
|
|
|
46386
46778
|
const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
|
|
46387
46779
|
if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
|
|
46388
46780
|
const WebSocket3 = (await import("ws")).default;
|
|
46389
|
-
return new Promise((
|
|
46781
|
+
return new Promise((resolve13, reject) => {
|
|
46390
46782
|
const ws2 = new WebSocket3(target.webSocketDebuggerUrl);
|
|
46391
46783
|
const timeout = setTimeout(() => {
|
|
46392
46784
|
ws2.close();
|
|
@@ -46408,11 +46800,11 @@ async function directCdpEval(expression, port = 9222) {
|
|
|
46408
46800
|
clearTimeout(timeout);
|
|
46409
46801
|
ws2.close();
|
|
46410
46802
|
if (msg.result?.result?.value !== void 0) {
|
|
46411
|
-
|
|
46803
|
+
resolve13(msg.result.result.value);
|
|
46412
46804
|
} else if (msg.result?.exceptionDetails) {
|
|
46413
46805
|
reject(new Error(msg.result.exceptionDetails.text));
|
|
46414
46806
|
} else {
|
|
46415
|
-
|
|
46807
|
+
resolve13(msg.result);
|
|
46416
46808
|
}
|
|
46417
46809
|
}
|
|
46418
46810
|
});
|
|
@@ -47074,7 +47466,7 @@ function registerProviderCommands(program2) {
|
|
|
47074
47466
|
} catch {
|
|
47075
47467
|
try {
|
|
47076
47468
|
const http3 = await import("http");
|
|
47077
|
-
const result = await new Promise((
|
|
47469
|
+
const result = await new Promise((resolve13, reject) => {
|
|
47078
47470
|
const req = http3.request({
|
|
47079
47471
|
hostname: "127.0.0.1",
|
|
47080
47472
|
port: 19280,
|
|
@@ -47086,9 +47478,9 @@ function registerProviderCommands(program2) {
|
|
|
47086
47478
|
res.on("data", (c) => data += c);
|
|
47087
47479
|
res.on("end", () => {
|
|
47088
47480
|
try {
|
|
47089
|
-
|
|
47481
|
+
resolve13(JSON.parse(data));
|
|
47090
47482
|
} catch {
|
|
47091
|
-
|
|
47483
|
+
resolve13({ raw: data });
|
|
47092
47484
|
}
|
|
47093
47485
|
});
|
|
47094
47486
|
});
|
|
@@ -47149,7 +47541,7 @@ function registerProviderCommands(program2) {
|
|
|
47149
47541
|
let processNames = {};
|
|
47150
47542
|
if (category === "ide") {
|
|
47151
47543
|
const fs16 = await import("fs");
|
|
47152
|
-
const
|
|
47544
|
+
const path19 = await import("path");
|
|
47153
47545
|
const os21 = await import("os");
|
|
47154
47546
|
if (os21.platform() === "darwin") {
|
|
47155
47547
|
while (true) {
|
|
@@ -47162,7 +47554,7 @@ function registerProviderCommands(program2) {
|
|
|
47162
47554
|
}
|
|
47163
47555
|
console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
|
|
47164
47556
|
osPaths["darwin"] = [p];
|
|
47165
|
-
processNames["darwin"] =
|
|
47557
|
+
processNames["darwin"] = path19.basename(p, ".app");
|
|
47166
47558
|
break;
|
|
47167
47559
|
}
|
|
47168
47560
|
} else if (os21.platform() === "win32") {
|
|
@@ -47176,7 +47568,7 @@ function registerProviderCommands(program2) {
|
|
|
47176
47568
|
}
|
|
47177
47569
|
console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
|
|
47178
47570
|
osPaths["win32"] = [p];
|
|
47179
|
-
processNames["win32"] =
|
|
47571
|
+
processNames["win32"] = path19.basename(p, ".exe");
|
|
47180
47572
|
break;
|
|
47181
47573
|
}
|
|
47182
47574
|
}
|
|
@@ -47190,12 +47582,12 @@ function registerProviderCommands(program2) {
|
|
|
47190
47582
|
console.log(import_chalk6.default.yellow("Invalid port number."));
|
|
47191
47583
|
continue;
|
|
47192
47584
|
}
|
|
47193
|
-
const isFree = await new Promise((
|
|
47585
|
+
const isFree = await new Promise((resolve13) => {
|
|
47194
47586
|
const server = net3.createServer();
|
|
47195
47587
|
server.unref();
|
|
47196
|
-
server.on("error", () =>
|
|
47588
|
+
server.on("error", () => resolve13(false));
|
|
47197
47589
|
server.listen(port, "127.0.0.1", () => {
|
|
47198
|
-
server.close(() =>
|
|
47590
|
+
server.close(() => resolve13(true));
|
|
47199
47591
|
});
|
|
47200
47592
|
});
|
|
47201
47593
|
if (!isFree) {
|
|
@@ -47210,7 +47602,7 @@ function registerProviderCommands(program2) {
|
|
|
47210
47602
|
rl.close();
|
|
47211
47603
|
const location = options.builtin ? "builtin" : "user";
|
|
47212
47604
|
const http3 = await import("http");
|
|
47213
|
-
const result = await new Promise((
|
|
47605
|
+
const result = await new Promise((resolve13, reject) => {
|
|
47214
47606
|
const postData = JSON.stringify({ type, name, category, location, cdpPorts, osPaths, processNames });
|
|
47215
47607
|
const req = http3.request({
|
|
47216
47608
|
hostname: "127.0.0.1",
|
|
@@ -47223,9 +47615,9 @@ function registerProviderCommands(program2) {
|
|
|
47223
47615
|
res.on("data", (c) => data += c);
|
|
47224
47616
|
res.on("end", () => {
|
|
47225
47617
|
try {
|
|
47226
|
-
|
|
47618
|
+
resolve13(JSON.parse(data));
|
|
47227
47619
|
} catch {
|
|
47228
|
-
|
|
47620
|
+
resolve13({ raw: data });
|
|
47229
47621
|
}
|
|
47230
47622
|
});
|
|
47231
47623
|
});
|
|
@@ -47423,7 +47815,7 @@ function registerProviderCommands(program2) {
|
|
|
47423
47815
|
...userComment ? { comment: userComment } : {},
|
|
47424
47816
|
reference
|
|
47425
47817
|
});
|
|
47426
|
-
const startResult = await new Promise((
|
|
47818
|
+
const startResult = await new Promise((resolve13, reject) => {
|
|
47427
47819
|
const req = http3.request({
|
|
47428
47820
|
hostname: "127.0.0.1",
|
|
47429
47821
|
port: 19280,
|
|
@@ -47435,9 +47827,9 @@ function registerProviderCommands(program2) {
|
|
|
47435
47827
|
res.on("data", (c) => data += c);
|
|
47436
47828
|
res.on("end", () => {
|
|
47437
47829
|
try {
|
|
47438
|
-
|
|
47830
|
+
resolve13(JSON.parse(data));
|
|
47439
47831
|
} catch {
|
|
47440
|
-
|
|
47832
|
+
resolve13({ raw: data });
|
|
47441
47833
|
}
|
|
47442
47834
|
});
|
|
47443
47835
|
});
|
|
@@ -47463,7 +47855,7 @@ function registerProviderCommands(program2) {
|
|
|
47463
47855
|
fsMock.writeFileSync(logFile2, `=== Auto-Impl Started ===
|
|
47464
47856
|
`);
|
|
47465
47857
|
console.log(import_chalk6.default.gray(` Agent logs: ${logFile2}`));
|
|
47466
|
-
await new Promise((
|
|
47858
|
+
await new Promise((resolve13, reject) => {
|
|
47467
47859
|
http3.get(`http://127.0.0.1:19280${startResult.sseUrl}`, (res) => {
|
|
47468
47860
|
let buffer = "";
|
|
47469
47861
|
res.on("data", (chunk) => {
|
|
@@ -47500,7 +47892,7 @@ function registerProviderCommands(program2) {
|
|
|
47500
47892
|
if (currentData.success === false) {
|
|
47501
47893
|
reject(new Error(`Agent failed to implement scripts properly (exit: ${currentData.exitCode})`));
|
|
47502
47894
|
} else {
|
|
47503
|
-
|
|
47895
|
+
resolve13();
|
|
47504
47896
|
}
|
|
47505
47897
|
} else if (currentEvent === "error") {
|
|
47506
47898
|
fsMock.appendFileSync(logFile2, `
|
|
@@ -47511,7 +47903,7 @@ function registerProviderCommands(program2) {
|
|
|
47511
47903
|
}
|
|
47512
47904
|
}
|
|
47513
47905
|
});
|
|
47514
|
-
res.on("end",
|
|
47906
|
+
res.on("end", resolve13);
|
|
47515
47907
|
}).on("error", reject);
|
|
47516
47908
|
});
|
|
47517
47909
|
console.log(import_chalk6.default.green(`
|
|
@@ -47570,7 +47962,7 @@ function registerProviderCommands(program2) {
|
|
|
47570
47962
|
ideType: type,
|
|
47571
47963
|
params: options.param ? { text: options.param, sessionId: options.param, buttonText: options.param } : {}
|
|
47572
47964
|
});
|
|
47573
|
-
const result = await new Promise((
|
|
47965
|
+
const result = await new Promise((resolve13, reject) => {
|
|
47574
47966
|
const req = http3.request({
|
|
47575
47967
|
hostname: "127.0.0.1",
|
|
47576
47968
|
port: 19280,
|
|
@@ -47582,9 +47974,9 @@ function registerProviderCommands(program2) {
|
|
|
47582
47974
|
res.on("data", (c) => data += c);
|
|
47583
47975
|
res.on("end", () => {
|
|
47584
47976
|
try {
|
|
47585
|
-
|
|
47977
|
+
resolve13(JSON.parse(data));
|
|
47586
47978
|
} catch {
|
|
47587
|
-
|
|
47979
|
+
resolve13({ raw: data });
|
|
47588
47980
|
}
|
|
47589
47981
|
});
|
|
47590
47982
|
});
|
|
@@ -47620,15 +48012,15 @@ function registerProviderCommands(program2) {
|
|
|
47620
48012
|
provider.command("source <type>").description("View source code of a provider").action(async (type) => {
|
|
47621
48013
|
try {
|
|
47622
48014
|
const http3 = await import("http");
|
|
47623
|
-
const result = await new Promise((
|
|
48015
|
+
const result = await new Promise((resolve13, reject) => {
|
|
47624
48016
|
http3.get(`http://127.0.0.1:19280/api/providers/${type}/source`, (res) => {
|
|
47625
48017
|
let data = "";
|
|
47626
48018
|
res.on("data", (c) => data += c);
|
|
47627
48019
|
res.on("end", () => {
|
|
47628
48020
|
try {
|
|
47629
|
-
|
|
48021
|
+
resolve13(JSON.parse(data));
|
|
47630
48022
|
} catch {
|
|
47631
|
-
|
|
48023
|
+
resolve13({ raw: data });
|
|
47632
48024
|
}
|
|
47633
48025
|
});
|
|
47634
48026
|
}).on("error", () => {
|
|
@@ -47674,7 +48066,7 @@ function registerProviderCommands(program2) {
|
|
|
47674
48066
|
try {
|
|
47675
48067
|
const http3 = await import("http");
|
|
47676
48068
|
const postData = JSON.stringify({ script: "readChat", params: {} });
|
|
47677
|
-
const result = await new Promise((
|
|
48069
|
+
const result = await new Promise((resolve13, reject) => {
|
|
47678
48070
|
const req = http3.request({
|
|
47679
48071
|
hostname: "127.0.0.1",
|
|
47680
48072
|
port: 19280,
|
|
@@ -47686,9 +48078,9 @@ function registerProviderCommands(program2) {
|
|
|
47686
48078
|
res2.on("data", (c) => data += c);
|
|
47687
48079
|
res2.on("end", () => {
|
|
47688
48080
|
try {
|
|
47689
|
-
|
|
48081
|
+
resolve13(JSON.parse(data));
|
|
47690
48082
|
} catch {
|
|
47691
|
-
|
|
48083
|
+
resolve13({ raw: data });
|
|
47692
48084
|
}
|
|
47693
48085
|
});
|
|
47694
48086
|
});
|
|
@@ -47929,13 +48321,13 @@ function registerCdpCommands(program2) {
|
|
|
47929
48321
|
cdp.command("screenshot").description("Capture IDE screenshot").option("-p, --port <port>", "CDP port", "9222").option("-o, --output <file>", "Output file path", "/tmp/cdp_screenshot.jpg").action(async (options) => {
|
|
47930
48322
|
try {
|
|
47931
48323
|
const http3 = await import("http");
|
|
47932
|
-
const targets = await new Promise((
|
|
48324
|
+
const targets = await new Promise((resolve13, reject) => {
|
|
47933
48325
|
http3.get(`http://127.0.0.1:${options.port}/json`, (res) => {
|
|
47934
48326
|
let data = "";
|
|
47935
48327
|
res.on("data", (c) => data += c);
|
|
47936
48328
|
res.on("end", () => {
|
|
47937
48329
|
try {
|
|
47938
|
-
|
|
48330
|
+
resolve13(JSON.parse(data));
|
|
47939
48331
|
} catch {
|
|
47940
48332
|
reject(new Error("Invalid JSON"));
|
|
47941
48333
|
}
|
|
@@ -47949,7 +48341,7 @@ function registerCdpCommands(program2) {
|
|
|
47949
48341
|
if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target");
|
|
47950
48342
|
const WebSocket3 = (await import("ws")).default;
|
|
47951
48343
|
const ws2 = new WebSocket3(target.webSocketDebuggerUrl);
|
|
47952
|
-
await new Promise((
|
|
48344
|
+
await new Promise((resolve13, reject) => {
|
|
47953
48345
|
ws2.on("open", () => {
|
|
47954
48346
|
ws2.send(JSON.stringify({ id: 1, method: "Page.captureScreenshot", params: { format: "jpeg", quality: 50 } }));
|
|
47955
48347
|
});
|
|
@@ -47962,7 +48354,7 @@ function registerCdpCommands(program2) {
|
|
|
47962
48354
|
\u2713 Screenshot saved to ${options.output}
|
|
47963
48355
|
`));
|
|
47964
48356
|
ws2.close();
|
|
47965
|
-
|
|
48357
|
+
resolve13();
|
|
47966
48358
|
}
|
|
47967
48359
|
});
|
|
47968
48360
|
ws2.on("error", (e) => reject(e));
|