adhdev 0.7.33 → 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 +1264 -813
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +1135 -745
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/session-host-daemon/index.js +25 -4
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +25 -4
- package/vendor/session-host-daemon/index.mjs.map +1 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.d.mts +293 -0
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.d.ts +293 -0
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js +536 -0
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js.map +1 -0
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs +488 -0
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs.map +1 -0
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/package.json +7 -0
package/dist/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) {
|
|
@@ -681,7 +744,7 @@ function checkDateRotation() {
|
|
|
681
744
|
const today = getDateStr();
|
|
682
745
|
if (today !== currentDate) {
|
|
683
746
|
currentDate = today;
|
|
684
|
-
currentLogFile =
|
|
747
|
+
currentLogFile = path4.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
685
748
|
cleanOldLogs();
|
|
686
749
|
}
|
|
687
750
|
}
|
|
@@ -695,7 +758,7 @@ function cleanOldLogs() {
|
|
|
695
758
|
const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
|
|
696
759
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
697
760
|
try {
|
|
698
|
-
fs2.unlinkSync(
|
|
761
|
+
fs2.unlinkSync(path4.join(LOG_DIR, file2));
|
|
699
762
|
} catch {
|
|
700
763
|
}
|
|
701
764
|
}
|
|
@@ -812,17 +875,17 @@ function installGlobalInterceptor() {
|
|
|
812
875
|
writeToFile(`Log file: ${currentLogFile}`);
|
|
813
876
|
writeToFile(`Log level: ${currentLevel}`);
|
|
814
877
|
}
|
|
815
|
-
var fs2,
|
|
878
|
+
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;
|
|
816
879
|
var init_logger = __esm({
|
|
817
880
|
"../../oss/packages/daemon-core/src/logging/logger.ts"() {
|
|
818
881
|
"use strict";
|
|
819
882
|
fs2 = __toESM(require("fs"));
|
|
820
|
-
|
|
883
|
+
path4 = __toESM(require("path"));
|
|
821
884
|
os4 = __toESM(require("os"));
|
|
822
885
|
LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
823
886
|
LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
|
|
824
887
|
currentLevel = "info";
|
|
825
|
-
LOG_DIR = process.platform === "win32" ?
|
|
888
|
+
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");
|
|
826
889
|
MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
827
890
|
MAX_LOG_DAYS = 7;
|
|
828
891
|
try {
|
|
@@ -830,16 +893,16 @@ var init_logger = __esm({
|
|
|
830
893
|
} catch {
|
|
831
894
|
}
|
|
832
895
|
currentDate = getDateStr();
|
|
833
|
-
currentLogFile =
|
|
896
|
+
currentLogFile = path4.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
834
897
|
cleanOldLogs();
|
|
835
898
|
try {
|
|
836
|
-
const oldLog =
|
|
899
|
+
const oldLog = path4.join(LOG_DIR, "daemon.log");
|
|
837
900
|
if (fs2.existsSync(oldLog)) {
|
|
838
901
|
const stat4 = fs2.statSync(oldLog);
|
|
839
902
|
const oldDate = stat4.mtime.toISOString().slice(0, 10);
|
|
840
|
-
fs2.renameSync(oldLog,
|
|
903
|
+
fs2.renameSync(oldLog, path4.join(LOG_DIR, `daemon-${oldDate}.log`));
|
|
841
904
|
}
|
|
842
|
-
const oldLogBackup =
|
|
905
|
+
const oldLogBackup = path4.join(LOG_DIR, "daemon.log.old");
|
|
843
906
|
if (fs2.existsSync(oldLogBackup)) {
|
|
844
907
|
fs2.unlinkSync(oldLogBackup);
|
|
845
908
|
}
|
|
@@ -871,7 +934,7 @@ var init_logger = __esm({
|
|
|
871
934
|
}
|
|
872
935
|
};
|
|
873
936
|
interceptorInstalled = false;
|
|
874
|
-
LOG_PATH =
|
|
937
|
+
LOG_PATH = path4.join(LOG_DIR, `daemon-${getDateStr()}.log`);
|
|
875
938
|
}
|
|
876
939
|
});
|
|
877
940
|
|
|
@@ -960,7 +1023,7 @@ var init_manager = __esm({
|
|
|
960
1023
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
961
1024
|
*/
|
|
962
1025
|
static listAllTargets(port) {
|
|
963
|
-
return new Promise((
|
|
1026
|
+
return new Promise((resolve13) => {
|
|
964
1027
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
965
1028
|
let data = "";
|
|
966
1029
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -976,16 +1039,16 @@ var init_manager = __esm({
|
|
|
976
1039
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
977
1040
|
);
|
|
978
1041
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
979
|
-
|
|
1042
|
+
resolve13(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
980
1043
|
} catch {
|
|
981
|
-
|
|
1044
|
+
resolve13([]);
|
|
982
1045
|
}
|
|
983
1046
|
});
|
|
984
1047
|
});
|
|
985
|
-
req.on("error", () =>
|
|
1048
|
+
req.on("error", () => resolve13([]));
|
|
986
1049
|
req.setTimeout(2e3, () => {
|
|
987
1050
|
req.destroy();
|
|
988
|
-
|
|
1051
|
+
resolve13([]);
|
|
989
1052
|
});
|
|
990
1053
|
});
|
|
991
1054
|
}
|
|
@@ -1025,7 +1088,7 @@ var init_manager = __esm({
|
|
|
1025
1088
|
}
|
|
1026
1089
|
}
|
|
1027
1090
|
findTargetOnPort(port) {
|
|
1028
|
-
return new Promise((
|
|
1091
|
+
return new Promise((resolve13) => {
|
|
1029
1092
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
1030
1093
|
let data = "";
|
|
1031
1094
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -1036,7 +1099,7 @@ var init_manager = __esm({
|
|
|
1036
1099
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
1037
1100
|
);
|
|
1038
1101
|
if (pages.length === 0) {
|
|
1039
|
-
|
|
1102
|
+
resolve13(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
1040
1103
|
return;
|
|
1041
1104
|
}
|
|
1042
1105
|
const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -1046,24 +1109,24 @@ var init_manager = __esm({
|
|
|
1046
1109
|
const specific = list.find((t) => t.id === this._targetId);
|
|
1047
1110
|
if (specific) {
|
|
1048
1111
|
this._pageTitle = specific.title || "";
|
|
1049
|
-
|
|
1112
|
+
resolve13(specific);
|
|
1050
1113
|
} else {
|
|
1051
1114
|
this.log(`[CDP] Target ${this._targetId} not found in page list`);
|
|
1052
|
-
|
|
1115
|
+
resolve13(null);
|
|
1053
1116
|
}
|
|
1054
1117
|
return;
|
|
1055
1118
|
}
|
|
1056
1119
|
this._pageTitle = list[0]?.title || "";
|
|
1057
|
-
|
|
1120
|
+
resolve13(list[0]);
|
|
1058
1121
|
} catch {
|
|
1059
|
-
|
|
1122
|
+
resolve13(null);
|
|
1060
1123
|
}
|
|
1061
1124
|
});
|
|
1062
1125
|
});
|
|
1063
|
-
req.on("error", () =>
|
|
1126
|
+
req.on("error", () => resolve13(null));
|
|
1064
1127
|
req.setTimeout(2e3, () => {
|
|
1065
1128
|
req.destroy();
|
|
1066
|
-
|
|
1129
|
+
resolve13(null);
|
|
1067
1130
|
});
|
|
1068
1131
|
});
|
|
1069
1132
|
}
|
|
@@ -1074,7 +1137,7 @@ var init_manager = __esm({
|
|
|
1074
1137
|
this.extensionProviders = providers;
|
|
1075
1138
|
}
|
|
1076
1139
|
connectToTarget(wsUrl) {
|
|
1077
|
-
return new Promise((
|
|
1140
|
+
return new Promise((resolve13) => {
|
|
1078
1141
|
this.ws = new import_ws.default(wsUrl);
|
|
1079
1142
|
this.ws.on("open", async () => {
|
|
1080
1143
|
this._connected = true;
|
|
@@ -1084,17 +1147,17 @@ var init_manager = __esm({
|
|
|
1084
1147
|
}
|
|
1085
1148
|
this.connectBrowserWs().catch(() => {
|
|
1086
1149
|
});
|
|
1087
|
-
|
|
1150
|
+
resolve13(true);
|
|
1088
1151
|
});
|
|
1089
1152
|
this.ws.on("message", (data) => {
|
|
1090
1153
|
try {
|
|
1091
1154
|
const msg = JSON.parse(data.toString());
|
|
1092
1155
|
if (msg.id && this.pending.has(msg.id)) {
|
|
1093
|
-
const { resolve:
|
|
1156
|
+
const { resolve: resolve14, reject } = this.pending.get(msg.id);
|
|
1094
1157
|
this.pending.delete(msg.id);
|
|
1095
1158
|
this.failureCount = 0;
|
|
1096
1159
|
if (msg.error) reject(new Error(msg.error.message));
|
|
1097
|
-
else
|
|
1160
|
+
else resolve14(msg.result);
|
|
1098
1161
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
1099
1162
|
this.contexts.add(msg.params.context.id);
|
|
1100
1163
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -1117,7 +1180,7 @@ var init_manager = __esm({
|
|
|
1117
1180
|
this.ws.on("error", (err) => {
|
|
1118
1181
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
1119
1182
|
this._connected = false;
|
|
1120
|
-
|
|
1183
|
+
resolve13(false);
|
|
1121
1184
|
});
|
|
1122
1185
|
});
|
|
1123
1186
|
}
|
|
@@ -1131,7 +1194,7 @@ var init_manager = __esm({
|
|
|
1131
1194
|
return;
|
|
1132
1195
|
}
|
|
1133
1196
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
1134
|
-
await new Promise((
|
|
1197
|
+
await new Promise((resolve13, reject) => {
|
|
1135
1198
|
this.browserWs = new import_ws.default(browserWsUrl);
|
|
1136
1199
|
this.browserWs.on("open", async () => {
|
|
1137
1200
|
this._browserConnected = true;
|
|
@@ -1141,16 +1204,16 @@ var init_manager = __esm({
|
|
|
1141
1204
|
} catch (e) {
|
|
1142
1205
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
1143
1206
|
}
|
|
1144
|
-
|
|
1207
|
+
resolve13();
|
|
1145
1208
|
});
|
|
1146
1209
|
this.browserWs.on("message", (data) => {
|
|
1147
1210
|
try {
|
|
1148
1211
|
const msg = JSON.parse(data.toString());
|
|
1149
1212
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
1150
|
-
const { resolve:
|
|
1213
|
+
const { resolve: resolve14, reject: reject2 } = this.browserPending.get(msg.id);
|
|
1151
1214
|
this.browserPending.delete(msg.id);
|
|
1152
1215
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
1153
|
-
else
|
|
1216
|
+
else resolve14(msg.result);
|
|
1154
1217
|
}
|
|
1155
1218
|
} catch {
|
|
1156
1219
|
}
|
|
@@ -1170,31 +1233,31 @@ var init_manager = __esm({
|
|
|
1170
1233
|
}
|
|
1171
1234
|
}
|
|
1172
1235
|
getBrowserWsUrl() {
|
|
1173
|
-
return new Promise((
|
|
1236
|
+
return new Promise((resolve13) => {
|
|
1174
1237
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
1175
1238
|
let data = "";
|
|
1176
1239
|
res.on("data", (chunk) => data += chunk.toString());
|
|
1177
1240
|
res.on("end", () => {
|
|
1178
1241
|
try {
|
|
1179
1242
|
const info = JSON.parse(data);
|
|
1180
|
-
|
|
1243
|
+
resolve13(info.webSocketDebuggerUrl || null);
|
|
1181
1244
|
} catch {
|
|
1182
|
-
|
|
1245
|
+
resolve13(null);
|
|
1183
1246
|
}
|
|
1184
1247
|
});
|
|
1185
1248
|
});
|
|
1186
|
-
req.on("error", () =>
|
|
1249
|
+
req.on("error", () => resolve13(null));
|
|
1187
1250
|
req.setTimeout(3e3, () => {
|
|
1188
1251
|
req.destroy();
|
|
1189
|
-
|
|
1252
|
+
resolve13(null);
|
|
1190
1253
|
});
|
|
1191
1254
|
});
|
|
1192
1255
|
}
|
|
1193
1256
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
1194
|
-
return new Promise((
|
|
1257
|
+
return new Promise((resolve13, reject) => {
|
|
1195
1258
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
1196
1259
|
const id = this.browserMsgId++;
|
|
1197
|
-
this.browserPending.set(id, { resolve:
|
|
1260
|
+
this.browserPending.set(id, { resolve: resolve13, reject });
|
|
1198
1261
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
1199
1262
|
setTimeout(() => {
|
|
1200
1263
|
if (this.browserPending.has(id)) {
|
|
@@ -1234,11 +1297,11 @@ var init_manager = __esm({
|
|
|
1234
1297
|
}
|
|
1235
1298
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
1236
1299
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
1237
|
-
return new Promise((
|
|
1300
|
+
return new Promise((resolve13, reject) => {
|
|
1238
1301
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
1239
1302
|
if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
|
|
1240
1303
|
const id = this.msgId++;
|
|
1241
|
-
this.pending.set(id, { resolve:
|
|
1304
|
+
this.pending.set(id, { resolve: resolve13, reject });
|
|
1242
1305
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
1243
1306
|
setTimeout(() => {
|
|
1244
1307
|
if (this.pending.has(id)) {
|
|
@@ -1487,7 +1550,7 @@ var init_manager = __esm({
|
|
|
1487
1550
|
const browserWs = this.browserWs;
|
|
1488
1551
|
let msgId = this.browserMsgId;
|
|
1489
1552
|
const sendWs = (method, params = {}, sessionId) => {
|
|
1490
|
-
return new Promise((
|
|
1553
|
+
return new Promise((resolve13, reject) => {
|
|
1491
1554
|
const mid = msgId++;
|
|
1492
1555
|
this.browserMsgId = msgId;
|
|
1493
1556
|
const handler = (raw) => {
|
|
@@ -1496,7 +1559,7 @@ var init_manager = __esm({
|
|
|
1496
1559
|
if (msg.id === mid) {
|
|
1497
1560
|
browserWs.removeListener("message", handler);
|
|
1498
1561
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
1499
|
-
else
|
|
1562
|
+
else resolve13(msg.result);
|
|
1500
1563
|
}
|
|
1501
1564
|
} catch {
|
|
1502
1565
|
}
|
|
@@ -1687,14 +1750,14 @@ var init_manager = __esm({
|
|
|
1687
1750
|
if (!ws2 || ws2.readyState !== import_ws.default.OPEN) {
|
|
1688
1751
|
throw new Error("CDP not connected");
|
|
1689
1752
|
}
|
|
1690
|
-
return new Promise((
|
|
1753
|
+
return new Promise((resolve13, reject) => {
|
|
1691
1754
|
const id = getNextId();
|
|
1692
1755
|
pendingMap.set(id, {
|
|
1693
1756
|
resolve: (result) => {
|
|
1694
1757
|
if (result?.result?.subtype === "error") {
|
|
1695
1758
|
reject(new Error(result.result.description));
|
|
1696
1759
|
} else {
|
|
1697
|
-
|
|
1760
|
+
resolve13(result?.result?.value);
|
|
1698
1761
|
}
|
|
1699
1762
|
},
|
|
1700
1763
|
reject
|
|
@@ -1726,10 +1789,10 @@ var init_manager = __esm({
|
|
|
1726
1789
|
throw new Error("CDP not connected");
|
|
1727
1790
|
}
|
|
1728
1791
|
const sendViaSession = (method, params = {}) => {
|
|
1729
|
-
return new Promise((
|
|
1792
|
+
return new Promise((resolve13, reject) => {
|
|
1730
1793
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
1731
1794
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
1732
|
-
pendingMap.set(id, { resolve:
|
|
1795
|
+
pendingMap.set(id, { resolve: resolve13, reject });
|
|
1733
1796
|
ws2.send(JSON.stringify({ id, sessionId, method, params }));
|
|
1734
1797
|
setTimeout(() => {
|
|
1735
1798
|
if (pendingMap.has(id)) {
|
|
@@ -2297,6 +2360,7 @@ var init_extension_provider_instance = __esm({
|
|
|
2297
2360
|
activeModal = null;
|
|
2298
2361
|
currentModel = "";
|
|
2299
2362
|
currentMode = "";
|
|
2363
|
+
controlValues = {};
|
|
2300
2364
|
lastAgentStatus = "idle";
|
|
2301
2365
|
generatingStartedAt = 0;
|
|
2302
2366
|
monitor;
|
|
@@ -2342,6 +2406,8 @@ var init_extension_provider_instance = __esm({
|
|
|
2342
2406
|
} : null,
|
|
2343
2407
|
currentModel: this.currentModel || void 0,
|
|
2344
2408
|
currentPlan: this.currentMode || void 0,
|
|
2409
|
+
controlValues: this.controlValues,
|
|
2410
|
+
providerControls: this.provider.controls,
|
|
2345
2411
|
agentStreams: this.agentStreams,
|
|
2346
2412
|
instanceId: this.instanceId,
|
|
2347
2413
|
lastUpdated: Date.now(),
|
|
@@ -2356,6 +2422,7 @@ var init_extension_provider_instance = __esm({
|
|
|
2356
2422
|
if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
|
|
2357
2423
|
if (data?.model) this.currentModel = data.model;
|
|
2358
2424
|
if (data?.mode) this.currentMode = data.mode;
|
|
2425
|
+
if (data?.controlValues) this.controlValues = data.controlValues;
|
|
2359
2426
|
if (typeof data?.sessionId === "string" && data.sessionId.trim()) this.chatId = data.sessionId;
|
|
2360
2427
|
if (typeof data?.title === "string" && data.title.trim()) this.chatTitle = data.title;
|
|
2361
2428
|
if (typeof data?.agentName === "string" && data.agentName.trim()) this.agentName = data.agentName;
|
|
@@ -2452,7 +2519,7 @@ var init_extension_provider_instance = __esm({
|
|
|
2452
2519
|
function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
2453
2520
|
try {
|
|
2454
2521
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2455
|
-
const dir =
|
|
2522
|
+
const dir = path5.join(HISTORY_DIR, sanitized);
|
|
2456
2523
|
if (!fs3.existsSync(dir)) return { messages: [], hasMore: false };
|
|
2457
2524
|
const sanitizedInstance = instanceId?.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2458
2525
|
const files = fs3.readdirSync(dir).filter((f) => {
|
|
@@ -2466,7 +2533,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
|
2466
2533
|
const needed = offset + limit + 1;
|
|
2467
2534
|
for (const file2 of files) {
|
|
2468
2535
|
if (allMessages.length >= needed) break;
|
|
2469
|
-
const filePath =
|
|
2536
|
+
const filePath = path5.join(dir, file2);
|
|
2470
2537
|
const content = fs3.readFileSync(filePath, "utf-8");
|
|
2471
2538
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
2472
2539
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
@@ -2485,14 +2552,14 @@ function readChatHistory(agentType, offset = 0, limit = 30, instanceId) {
|
|
|
2485
2552
|
return { messages: [], hasMore: false };
|
|
2486
2553
|
}
|
|
2487
2554
|
}
|
|
2488
|
-
var fs3,
|
|
2555
|
+
var fs3, path5, os5, HISTORY_DIR, RETAIN_DAYS, ChatHistoryWriter;
|
|
2489
2556
|
var init_chat_history = __esm({
|
|
2490
2557
|
"../../oss/packages/daemon-core/src/config/chat-history.ts"() {
|
|
2491
2558
|
"use strict";
|
|
2492
2559
|
fs3 = __toESM(require("fs"));
|
|
2493
|
-
|
|
2560
|
+
path5 = __toESM(require("path"));
|
|
2494
2561
|
os5 = __toESM(require("os"));
|
|
2495
|
-
HISTORY_DIR =
|
|
2562
|
+
HISTORY_DIR = path5.join(os5.homedir(), ".adhdev", "history");
|
|
2496
2563
|
RETAIN_DAYS = 30;
|
|
2497
2564
|
ChatHistoryWriter = class {
|
|
2498
2565
|
/** Last seen message count per agent (deduplication) */
|
|
@@ -2535,11 +2602,11 @@ var init_chat_history = __esm({
|
|
|
2535
2602
|
});
|
|
2536
2603
|
}
|
|
2537
2604
|
if (newMessages.length === 0) return;
|
|
2538
|
-
const dir =
|
|
2605
|
+
const dir = path5.join(HISTORY_DIR, this.sanitize(agentType));
|
|
2539
2606
|
fs3.mkdirSync(dir, { recursive: true });
|
|
2540
2607
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2541
2608
|
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
2542
|
-
const filePath =
|
|
2609
|
+
const filePath = path5.join(dir, `${filePrefix}${date5}.jsonl`);
|
|
2543
2610
|
const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
|
|
2544
2611
|
fs3.appendFileSync(filePath, lines, "utf-8");
|
|
2545
2612
|
const prevCount = this.lastSeenCounts.get(dedupKey) || 0;
|
|
@@ -2583,11 +2650,11 @@ ${next}`;
|
|
|
2583
2650
|
this.lastSeenTerminal.set(dedupKey, next);
|
|
2584
2651
|
return;
|
|
2585
2652
|
}
|
|
2586
|
-
const dir =
|
|
2653
|
+
const dir = path5.join(HISTORY_DIR, this.sanitize(agentType));
|
|
2587
2654
|
fs3.mkdirSync(dir, { recursive: true });
|
|
2588
2655
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2589
2656
|
const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : "";
|
|
2590
|
-
const filePath =
|
|
2657
|
+
const filePath = path5.join(dir, `${filePrefix}${date5}.terminal.log`);
|
|
2591
2658
|
fs3.appendFileSync(filePath, delta, "utf-8");
|
|
2592
2659
|
this.lastSeenTerminal.set(dedupKey, next);
|
|
2593
2660
|
if (!this.rotated) {
|
|
@@ -2611,10 +2678,10 @@ ${next}`;
|
|
|
2611
2678
|
const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
|
|
2612
2679
|
const agentDirs = fs3.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
2613
2680
|
for (const dir of agentDirs) {
|
|
2614
|
-
const dirPath =
|
|
2681
|
+
const dirPath = path5.join(HISTORY_DIR, dir.name);
|
|
2615
2682
|
const files = fs3.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
|
|
2616
2683
|
for (const file2 of files) {
|
|
2617
|
-
const filePath =
|
|
2684
|
+
const filePath = path5.join(dirPath, file2);
|
|
2618
2685
|
const stat4 = fs3.statSync(filePath);
|
|
2619
2686
|
if (stat4.mtimeMs < cutoff) {
|
|
2620
2687
|
fs3.unlinkSync(filePath);
|
|
@@ -2729,6 +2796,8 @@ var init_ide_provider_instance = __esm({
|
|
|
2729
2796
|
currentModel: this.cachedChat?.model || void 0,
|
|
2730
2797
|
currentPlan: this.cachedChat?.mode || void 0,
|
|
2731
2798
|
currentAutoApprove: this.cachedChat?.autoApprove || void 0,
|
|
2799
|
+
controlValues: this.cachedChat?.controlValues || void 0,
|
|
2800
|
+
providerControls: this.provider.controls,
|
|
2732
2801
|
instanceId: this.instanceId,
|
|
2733
2802
|
lastUpdated: Date.now(),
|
|
2734
2803
|
settings: this.settings,
|
|
@@ -3328,6 +3397,50 @@ function isCdpConnected(cdpManagers, key) {
|
|
|
3328
3397
|
const m = findCdpManager(cdpManagers, key);
|
|
3329
3398
|
return m?.isConnected ?? false;
|
|
3330
3399
|
}
|
|
3400
|
+
function buildFallbackControls(providerControls, serverModel, serverMode, acpConfigOptions, acpModes) {
|
|
3401
|
+
if (providerControls && providerControls.length > 0) return providerControls;
|
|
3402
|
+
const controls = [];
|
|
3403
|
+
const isAcp = !!(acpConfigOptions || acpModes);
|
|
3404
|
+
const modelFromAcp = acpConfigOptions?.find((c) => c.category === "model");
|
|
3405
|
+
if (!isAcp || modelFromAcp) {
|
|
3406
|
+
controls.push({
|
|
3407
|
+
id: "model",
|
|
3408
|
+
type: "select",
|
|
3409
|
+
label: "Model",
|
|
3410
|
+
icon: "\u{1F916}",
|
|
3411
|
+
placement: "bar",
|
|
3412
|
+
dynamic: !modelFromAcp,
|
|
3413
|
+
listScript: "listModels",
|
|
3414
|
+
setScript: "setModel",
|
|
3415
|
+
readFrom: "model",
|
|
3416
|
+
...modelFromAcp && {
|
|
3417
|
+
options: modelFromAcp.options.map((o) => ({ value: o.value, label: o.name || o.value }))
|
|
3418
|
+
}
|
|
3419
|
+
});
|
|
3420
|
+
}
|
|
3421
|
+
const modeFromAcp = acpModes && acpModes.length > 0;
|
|
3422
|
+
const thoughtFromAcp = !modeFromAcp && acpConfigOptions?.find((c) => c.category !== "model");
|
|
3423
|
+
if (!isAcp || modeFromAcp || thoughtFromAcp) {
|
|
3424
|
+
controls.push({
|
|
3425
|
+
id: "mode",
|
|
3426
|
+
type: thoughtFromAcp ? "cycle" : "select",
|
|
3427
|
+
label: thoughtFromAcp ? "Thinking" : "Mode",
|
|
3428
|
+
icon: thoughtFromAcp ? "\u{1F9E0}" : "\u26A1",
|
|
3429
|
+
placement: "bar",
|
|
3430
|
+
dynamic: !modeFromAcp && !thoughtFromAcp,
|
|
3431
|
+
listScript: "listModes",
|
|
3432
|
+
setScript: thoughtFromAcp ? "setThinkingLevel" : "setMode",
|
|
3433
|
+
readFrom: "mode",
|
|
3434
|
+
...modeFromAcp && {
|
|
3435
|
+
options: acpModes.map((m) => ({ value: m.id, label: m.name || m.id }))
|
|
3436
|
+
},
|
|
3437
|
+
...thoughtFromAcp && {
|
|
3438
|
+
options: thoughtFromAcp.options.map((o) => ({ value: o.value, label: o.name || o.value }))
|
|
3439
|
+
}
|
|
3440
|
+
});
|
|
3441
|
+
}
|
|
3442
|
+
return controls;
|
|
3443
|
+
}
|
|
3331
3444
|
function buildIdeWorkspaceSession(state, cdpManagers) {
|
|
3332
3445
|
const activeChat = normalizeActiveChatData(state.activeChat);
|
|
3333
3446
|
const title = activeChat?.title || state.name;
|
|
@@ -3349,8 +3462,15 @@ function buildIdeWorkspaceSession(state, cdpManagers) {
|
|
|
3349
3462
|
currentModel: state.currentModel,
|
|
3350
3463
|
currentPlan: state.currentPlan,
|
|
3351
3464
|
currentAutoApprove: state.currentAutoApprove,
|
|
3465
|
+
controlValues: state.controlValues,
|
|
3466
|
+
providerControls: buildFallbackControls(
|
|
3467
|
+
state.providerControls,
|
|
3468
|
+
state.currentModel,
|
|
3469
|
+
state.currentPlan
|
|
3470
|
+
),
|
|
3352
3471
|
errorMessage: state.errorMessage,
|
|
3353
|
-
errorReason: state.errorReason
|
|
3472
|
+
errorReason: state.errorReason,
|
|
3473
|
+
lastUpdated: state.lastUpdated
|
|
3354
3474
|
};
|
|
3355
3475
|
}
|
|
3356
3476
|
function buildExtensionAgentSession(parent, ext) {
|
|
@@ -3371,8 +3491,15 @@ function buildExtensionAgentSession(parent, ext) {
|
|
|
3371
3491
|
capabilities: EXTENSION_SESSION_CAPABILITIES,
|
|
3372
3492
|
currentModel: ext.currentModel,
|
|
3373
3493
|
currentPlan: ext.currentPlan,
|
|
3494
|
+
controlValues: ext.controlValues,
|
|
3495
|
+
providerControls: buildFallbackControls(
|
|
3496
|
+
ext.providerControls,
|
|
3497
|
+
ext.currentModel,
|
|
3498
|
+
ext.currentPlan
|
|
3499
|
+
),
|
|
3374
3500
|
errorMessage: ext.errorMessage,
|
|
3375
|
-
errorReason: ext.errorReason
|
|
3501
|
+
errorReason: ext.errorReason,
|
|
3502
|
+
lastUpdated: ext.lastUpdated
|
|
3376
3503
|
};
|
|
3377
3504
|
}
|
|
3378
3505
|
function buildCliSession(state) {
|
|
@@ -3397,8 +3524,13 @@ function buildCliSession(state) {
|
|
|
3397
3524
|
resume: state.resume,
|
|
3398
3525
|
activeChat,
|
|
3399
3526
|
capabilities: PTY_SESSION_CAPABILITIES,
|
|
3527
|
+
controlValues: state.controlValues,
|
|
3528
|
+
providerControls: buildFallbackControls(
|
|
3529
|
+
state.providerControls
|
|
3530
|
+
),
|
|
3400
3531
|
errorMessage: state.errorMessage,
|
|
3401
|
-
errorReason: state.errorReason
|
|
3532
|
+
errorReason: state.errorReason,
|
|
3533
|
+
lastUpdated: state.lastUpdated
|
|
3402
3534
|
};
|
|
3403
3535
|
}
|
|
3404
3536
|
function buildAcpSession(state) {
|
|
@@ -3421,8 +3553,17 @@ function buildAcpSession(state) {
|
|
|
3421
3553
|
currentPlan: state.currentPlan,
|
|
3422
3554
|
acpConfigOptions: state.acpConfigOptions,
|
|
3423
3555
|
acpModes: state.acpModes,
|
|
3556
|
+
controlValues: state.controlValues,
|
|
3557
|
+
providerControls: buildFallbackControls(
|
|
3558
|
+
state.providerControls,
|
|
3559
|
+
state.currentModel,
|
|
3560
|
+
state.currentPlan,
|
|
3561
|
+
state.acpConfigOptions,
|
|
3562
|
+
state.acpModes
|
|
3563
|
+
),
|
|
3424
3564
|
errorMessage: state.errorMessage,
|
|
3425
|
-
errorReason: state.errorReason
|
|
3565
|
+
errorReason: state.errorReason,
|
|
3566
|
+
lastUpdated: state.lastUpdated
|
|
3426
3567
|
};
|
|
3427
3568
|
}
|
|
3428
3569
|
function buildSessionEntries(allStates, cdpManagers) {
|
|
@@ -4511,11 +4652,11 @@ function resolveSafePath(requestedPath) {
|
|
|
4511
4652
|
const home = os6.homedir();
|
|
4512
4653
|
let resolved;
|
|
4513
4654
|
if (requestedPath.startsWith("~")) {
|
|
4514
|
-
resolved =
|
|
4515
|
-
} else if (
|
|
4655
|
+
resolved = path6.join(home, requestedPath.slice(1));
|
|
4656
|
+
} else if (path6.isAbsolute(requestedPath)) {
|
|
4516
4657
|
resolved = requestedPath;
|
|
4517
4658
|
} else {
|
|
4518
|
-
resolved =
|
|
4659
|
+
resolved = path6.resolve(requestedPath);
|
|
4519
4660
|
}
|
|
4520
4661
|
return resolved;
|
|
4521
4662
|
}
|
|
@@ -4531,7 +4672,7 @@ async function handleFileRead(h, args) {
|
|
|
4531
4672
|
async function handleFileWrite(h, args) {
|
|
4532
4673
|
try {
|
|
4533
4674
|
const filePath = resolveSafePath(args?.path);
|
|
4534
|
-
fs4.mkdirSync(
|
|
4675
|
+
fs4.mkdirSync(path6.dirname(filePath), { recursive: true });
|
|
4535
4676
|
fs4.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
4536
4677
|
return { success: true, path: filePath };
|
|
4537
4678
|
} catch (e) {
|
|
@@ -4545,7 +4686,7 @@ async function handleFileList(h, args) {
|
|
|
4545
4686
|
const files = entries.map((e) => ({
|
|
4546
4687
|
name: e.name,
|
|
4547
4688
|
type: e.isDirectory() ? "directory" : "file",
|
|
4548
|
-
size: e.isFile() ? fs4.statSync(
|
|
4689
|
+
size: e.isFile() ? fs4.statSync(path6.join(dirPath, e.name)).size : void 0
|
|
4549
4690
|
}));
|
|
4550
4691
|
return { success: true, files, path: dirPath };
|
|
4551
4692
|
} catch (e) {
|
|
@@ -4555,12 +4696,12 @@ async function handleFileList(h, args) {
|
|
|
4555
4696
|
async function handleFileListBrowse(h, args) {
|
|
4556
4697
|
return handleFileList(h, args);
|
|
4557
4698
|
}
|
|
4558
|
-
var fs4,
|
|
4699
|
+
var fs4, path6, os6, KEY_TO_VK;
|
|
4559
4700
|
var init_cdp_commands = __esm({
|
|
4560
4701
|
"../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
|
|
4561
4702
|
"use strict";
|
|
4562
4703
|
fs4 = __toESM(require("fs"));
|
|
4563
|
-
|
|
4704
|
+
path6 = __toESM(require("path"));
|
|
4564
4705
|
os6 = __toESM(require("os"));
|
|
4565
4706
|
KEY_TO_VK = {
|
|
4566
4707
|
Backspace: 8,
|
|
@@ -4814,9 +4955,10 @@ function handleWorkspaceList() {
|
|
|
4814
4955
|
function handleWorkspaceAdd(args) {
|
|
4815
4956
|
const rawPath = (args?.path || args?.dir || "").trim();
|
|
4816
4957
|
const label = (args?.label || "").trim() || void 0;
|
|
4958
|
+
const createIfMissing = args?.createIfMissing === true;
|
|
4817
4959
|
if (!rawPath) return { success: false, error: "path required" };
|
|
4818
4960
|
const config2 = loadConfig();
|
|
4819
|
-
const result = addWorkspaceEntry(config2, rawPath, label);
|
|
4961
|
+
const result = addWorkspaceEntry(config2, rawPath, label, { createIfMissing });
|
|
4820
4962
|
if ("error" in result) return { success: false, error: result.error };
|
|
4821
4963
|
let cfg = appendWorkspaceActivity(result.config, result.entry.path, {});
|
|
4822
4964
|
saveConfig(cfg);
|
|
@@ -5332,7 +5474,7 @@ var init_handler = __esm({
|
|
|
5332
5474
|
try {
|
|
5333
5475
|
const http3 = await import("http");
|
|
5334
5476
|
const postData = JSON.stringify(body);
|
|
5335
|
-
const result = await new Promise((
|
|
5477
|
+
const result = await new Promise((resolve13, reject) => {
|
|
5336
5478
|
const req = http3.request({
|
|
5337
5479
|
hostname: "127.0.0.1",
|
|
5338
5480
|
port: 19280,
|
|
@@ -5344,9 +5486,9 @@ var init_handler = __esm({
|
|
|
5344
5486
|
res.on("data", (chunk) => data += chunk);
|
|
5345
5487
|
res.on("end", () => {
|
|
5346
5488
|
try {
|
|
5347
|
-
|
|
5489
|
+
resolve13(JSON.parse(data));
|
|
5348
5490
|
} catch {
|
|
5349
|
-
|
|
5491
|
+
resolve13({ raw: data });
|
|
5350
5492
|
}
|
|
5351
5493
|
});
|
|
5352
5494
|
});
|
|
@@ -5364,15 +5506,15 @@ var init_handler = __esm({
|
|
|
5364
5506
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
5365
5507
|
try {
|
|
5366
5508
|
const http3 = await import("http");
|
|
5367
|
-
const result = await new Promise((
|
|
5509
|
+
const result = await new Promise((resolve13, reject) => {
|
|
5368
5510
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
5369
5511
|
let data = "";
|
|
5370
5512
|
res.on("data", (chunk) => data += chunk);
|
|
5371
5513
|
res.on("end", () => {
|
|
5372
5514
|
try {
|
|
5373
|
-
|
|
5515
|
+
resolve13(JSON.parse(data));
|
|
5374
5516
|
} catch {
|
|
5375
|
-
|
|
5517
|
+
resolve13({ raw: data });
|
|
5376
5518
|
}
|
|
5377
5519
|
});
|
|
5378
5520
|
}).on("error", reject);
|
|
@@ -5386,7 +5528,7 @@ var init_handler = __esm({
|
|
|
5386
5528
|
try {
|
|
5387
5529
|
const http3 = await import("http");
|
|
5388
5530
|
const postData = JSON.stringify(args || {});
|
|
5389
|
-
const result = await new Promise((
|
|
5531
|
+
const result = await new Promise((resolve13, reject) => {
|
|
5390
5532
|
const req = http3.request({
|
|
5391
5533
|
hostname: "127.0.0.1",
|
|
5392
5534
|
port: 19280,
|
|
@@ -5398,9 +5540,9 @@ var init_handler = __esm({
|
|
|
5398
5540
|
res.on("data", (chunk) => data += chunk);
|
|
5399
5541
|
res.on("end", () => {
|
|
5400
5542
|
try {
|
|
5401
|
-
|
|
5543
|
+
resolve13(JSON.parse(data));
|
|
5402
5544
|
} catch {
|
|
5403
|
-
|
|
5545
|
+
resolve13({ raw: data });
|
|
5404
5546
|
}
|
|
5405
5547
|
});
|
|
5406
5548
|
});
|
|
@@ -5521,7 +5663,7 @@ var init_readdirp = __esm({
|
|
|
5521
5663
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
5522
5664
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
5523
5665
|
if (wantBigintFsStats) {
|
|
5524
|
-
this._stat = (
|
|
5666
|
+
this._stat = (path19) => statMethod(path19, { bigint: true });
|
|
5525
5667
|
} else {
|
|
5526
5668
|
this._stat = statMethod;
|
|
5527
5669
|
}
|
|
@@ -5546,8 +5688,8 @@ var init_readdirp = __esm({
|
|
|
5546
5688
|
const par = this.parent;
|
|
5547
5689
|
const fil = par && par.files;
|
|
5548
5690
|
if (fil && fil.length > 0) {
|
|
5549
|
-
const { path:
|
|
5550
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
5691
|
+
const { path: path19, depth } = par;
|
|
5692
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path19));
|
|
5551
5693
|
const awaited = await Promise.all(slice);
|
|
5552
5694
|
for (const entry of awaited) {
|
|
5553
5695
|
if (!entry)
|
|
@@ -5587,20 +5729,20 @@ var init_readdirp = __esm({
|
|
|
5587
5729
|
this.reading = false;
|
|
5588
5730
|
}
|
|
5589
5731
|
}
|
|
5590
|
-
async _exploreDir(
|
|
5732
|
+
async _exploreDir(path19, depth) {
|
|
5591
5733
|
let files;
|
|
5592
5734
|
try {
|
|
5593
|
-
files = await (0, import_promises.readdir)(
|
|
5735
|
+
files = await (0, import_promises.readdir)(path19, this._rdOptions);
|
|
5594
5736
|
} catch (error48) {
|
|
5595
5737
|
this._onError(error48);
|
|
5596
5738
|
}
|
|
5597
|
-
return { files, depth, path:
|
|
5739
|
+
return { files, depth, path: path19 };
|
|
5598
5740
|
}
|
|
5599
|
-
async _formatEntry(dirent,
|
|
5741
|
+
async _formatEntry(dirent, path19) {
|
|
5600
5742
|
let entry;
|
|
5601
5743
|
const basename7 = this._isDirent ? dirent.name : dirent;
|
|
5602
5744
|
try {
|
|
5603
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
5745
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path19, basename7));
|
|
5604
5746
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
|
|
5605
5747
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
5606
5748
|
} catch (err) {
|
|
@@ -5657,16 +5799,16 @@ var init_readdirp = __esm({
|
|
|
5657
5799
|
});
|
|
5658
5800
|
|
|
5659
5801
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
5660
|
-
function createFsWatchInstance(
|
|
5802
|
+
function createFsWatchInstance(path19, options, listener, errHandler, emitRaw) {
|
|
5661
5803
|
const handleEvent = (rawEvent, evPath) => {
|
|
5662
|
-
listener(
|
|
5663
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
5664
|
-
if (evPath &&
|
|
5665
|
-
fsWatchBroadcast(sp.resolve(
|
|
5804
|
+
listener(path19);
|
|
5805
|
+
emitRaw(rawEvent, evPath, { watchedPath: path19 });
|
|
5806
|
+
if (evPath && path19 !== evPath) {
|
|
5807
|
+
fsWatchBroadcast(sp.resolve(path19, evPath), KEY_LISTENERS, sp.join(path19, evPath));
|
|
5666
5808
|
}
|
|
5667
5809
|
};
|
|
5668
5810
|
try {
|
|
5669
|
-
return (0, import_node_fs.watch)(
|
|
5811
|
+
return (0, import_node_fs.watch)(path19, {
|
|
5670
5812
|
persistent: options.persistent
|
|
5671
5813
|
}, handleEvent);
|
|
5672
5814
|
} catch (error48) {
|
|
@@ -6015,12 +6157,12 @@ var init_handler2 = __esm({
|
|
|
6015
6157
|
listener(val1, val2, val3);
|
|
6016
6158
|
});
|
|
6017
6159
|
};
|
|
6018
|
-
setFsWatchListener = (
|
|
6160
|
+
setFsWatchListener = (path19, fullPath, options, handlers) => {
|
|
6019
6161
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
6020
6162
|
let cont = FsWatchInstances.get(fullPath);
|
|
6021
6163
|
let watcher;
|
|
6022
6164
|
if (!options.persistent) {
|
|
6023
|
-
watcher = createFsWatchInstance(
|
|
6165
|
+
watcher = createFsWatchInstance(path19, options, listener, errHandler, rawEmitter);
|
|
6024
6166
|
if (!watcher)
|
|
6025
6167
|
return;
|
|
6026
6168
|
return watcher.close.bind(watcher);
|
|
@@ -6031,7 +6173,7 @@ var init_handler2 = __esm({
|
|
|
6031
6173
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
6032
6174
|
} else {
|
|
6033
6175
|
watcher = createFsWatchInstance(
|
|
6034
|
-
|
|
6176
|
+
path19,
|
|
6035
6177
|
options,
|
|
6036
6178
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
6037
6179
|
errHandler,
|
|
@@ -6046,7 +6188,7 @@ var init_handler2 = __esm({
|
|
|
6046
6188
|
cont.watcherUnusable = true;
|
|
6047
6189
|
if (isWindows && error48.code === "EPERM") {
|
|
6048
6190
|
try {
|
|
6049
|
-
const fd = await (0, import_promises2.open)(
|
|
6191
|
+
const fd = await (0, import_promises2.open)(path19, "r");
|
|
6050
6192
|
await fd.close();
|
|
6051
6193
|
broadcastErr(error48);
|
|
6052
6194
|
} catch (err) {
|
|
@@ -6077,7 +6219,7 @@ var init_handler2 = __esm({
|
|
|
6077
6219
|
};
|
|
6078
6220
|
};
|
|
6079
6221
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
6080
|
-
setFsWatchFileListener = (
|
|
6222
|
+
setFsWatchFileListener = (path19, fullPath, options, handlers) => {
|
|
6081
6223
|
const { listener, rawEmitter } = handlers;
|
|
6082
6224
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
6083
6225
|
const copts = cont && cont.options;
|
|
@@ -6099,7 +6241,7 @@ var init_handler2 = __esm({
|
|
|
6099
6241
|
});
|
|
6100
6242
|
const currmtime = curr.mtimeMs;
|
|
6101
6243
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
6102
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
6244
|
+
foreach(cont.listeners, (listener2) => listener2(path19, curr));
|
|
6103
6245
|
}
|
|
6104
6246
|
})
|
|
6105
6247
|
};
|
|
@@ -6129,13 +6271,13 @@ var init_handler2 = __esm({
|
|
|
6129
6271
|
* @param listener on fs change
|
|
6130
6272
|
* @returns closer for the watcher instance
|
|
6131
6273
|
*/
|
|
6132
|
-
_watchWithNodeFs(
|
|
6274
|
+
_watchWithNodeFs(path19, listener) {
|
|
6133
6275
|
const opts = this.fsw.options;
|
|
6134
|
-
const directory = sp.dirname(
|
|
6135
|
-
const basename7 = sp.basename(
|
|
6276
|
+
const directory = sp.dirname(path19);
|
|
6277
|
+
const basename7 = sp.basename(path19);
|
|
6136
6278
|
const parent = this.fsw._getWatchedDir(directory);
|
|
6137
6279
|
parent.add(basename7);
|
|
6138
|
-
const absolutePath = sp.resolve(
|
|
6280
|
+
const absolutePath = sp.resolve(path19);
|
|
6139
6281
|
const options = {
|
|
6140
6282
|
persistent: opts.persistent
|
|
6141
6283
|
};
|
|
@@ -6145,12 +6287,12 @@ var init_handler2 = __esm({
|
|
|
6145
6287
|
if (opts.usePolling) {
|
|
6146
6288
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
6147
6289
|
options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
|
|
6148
|
-
closer = setFsWatchFileListener(
|
|
6290
|
+
closer = setFsWatchFileListener(path19, absolutePath, options, {
|
|
6149
6291
|
listener,
|
|
6150
6292
|
rawEmitter: this.fsw._emitRaw
|
|
6151
6293
|
});
|
|
6152
6294
|
} else {
|
|
6153
|
-
closer = setFsWatchListener(
|
|
6295
|
+
closer = setFsWatchListener(path19, absolutePath, options, {
|
|
6154
6296
|
listener,
|
|
6155
6297
|
errHandler: this._boundHandleError,
|
|
6156
6298
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -6172,7 +6314,7 @@ var init_handler2 = __esm({
|
|
|
6172
6314
|
let prevStats = stats;
|
|
6173
6315
|
if (parent.has(basename7))
|
|
6174
6316
|
return;
|
|
6175
|
-
const listener = async (
|
|
6317
|
+
const listener = async (path19, newStats) => {
|
|
6176
6318
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
6177
6319
|
return;
|
|
6178
6320
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -6186,11 +6328,11 @@ var init_handler2 = __esm({
|
|
|
6186
6328
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
6187
6329
|
}
|
|
6188
6330
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
6189
|
-
this.fsw._closeFile(
|
|
6331
|
+
this.fsw._closeFile(path19);
|
|
6190
6332
|
prevStats = newStats2;
|
|
6191
6333
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
6192
6334
|
if (closer2)
|
|
6193
|
-
this.fsw._addPathCloser(
|
|
6335
|
+
this.fsw._addPathCloser(path19, closer2);
|
|
6194
6336
|
} else {
|
|
6195
6337
|
prevStats = newStats2;
|
|
6196
6338
|
}
|
|
@@ -6222,7 +6364,7 @@ var init_handler2 = __esm({
|
|
|
6222
6364
|
* @param item basename of this item
|
|
6223
6365
|
* @returns true if no more processing is needed for this entry.
|
|
6224
6366
|
*/
|
|
6225
|
-
async _handleSymlink(entry, directory,
|
|
6367
|
+
async _handleSymlink(entry, directory, path19, item) {
|
|
6226
6368
|
if (this.fsw.closed) {
|
|
6227
6369
|
return;
|
|
6228
6370
|
}
|
|
@@ -6232,7 +6374,7 @@ var init_handler2 = __esm({
|
|
|
6232
6374
|
this.fsw._incrReadyCount();
|
|
6233
6375
|
let linkPath;
|
|
6234
6376
|
try {
|
|
6235
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
6377
|
+
linkPath = await (0, import_promises2.realpath)(path19);
|
|
6236
6378
|
} catch (e) {
|
|
6237
6379
|
this.fsw._emitReady();
|
|
6238
6380
|
return true;
|
|
@@ -6242,12 +6384,12 @@ var init_handler2 = __esm({
|
|
|
6242
6384
|
if (dir.has(item)) {
|
|
6243
6385
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
6244
6386
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6245
|
-
this.fsw._emit(EV.CHANGE,
|
|
6387
|
+
this.fsw._emit(EV.CHANGE, path19, entry.stats);
|
|
6246
6388
|
}
|
|
6247
6389
|
} else {
|
|
6248
6390
|
dir.add(item);
|
|
6249
6391
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
6250
|
-
this.fsw._emit(EV.ADD,
|
|
6392
|
+
this.fsw._emit(EV.ADD, path19, entry.stats);
|
|
6251
6393
|
}
|
|
6252
6394
|
this.fsw._emitReady();
|
|
6253
6395
|
return true;
|
|
@@ -6277,9 +6419,9 @@ var init_handler2 = __esm({
|
|
|
6277
6419
|
return;
|
|
6278
6420
|
}
|
|
6279
6421
|
const item = entry.path;
|
|
6280
|
-
let
|
|
6422
|
+
let path19 = sp.join(directory, item);
|
|
6281
6423
|
current.add(item);
|
|
6282
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
6424
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path19, item)) {
|
|
6283
6425
|
return;
|
|
6284
6426
|
}
|
|
6285
6427
|
if (this.fsw.closed) {
|
|
@@ -6288,11 +6430,11 @@ var init_handler2 = __esm({
|
|
|
6288
6430
|
}
|
|
6289
6431
|
if (item === target || !target && !previous.has(item)) {
|
|
6290
6432
|
this.fsw._incrReadyCount();
|
|
6291
|
-
|
|
6292
|
-
this._addToNodeFs(
|
|
6433
|
+
path19 = sp.join(dir, sp.relative(dir, path19));
|
|
6434
|
+
this._addToNodeFs(path19, initialAdd, wh, depth + 1);
|
|
6293
6435
|
}
|
|
6294
6436
|
}).on(EV.ERROR, this._boundHandleError);
|
|
6295
|
-
return new Promise((
|
|
6437
|
+
return new Promise((resolve13, reject) => {
|
|
6296
6438
|
if (!stream)
|
|
6297
6439
|
return reject();
|
|
6298
6440
|
stream.once(STR_END, () => {
|
|
@@ -6301,7 +6443,7 @@ var init_handler2 = __esm({
|
|
|
6301
6443
|
return;
|
|
6302
6444
|
}
|
|
6303
6445
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
6304
|
-
|
|
6446
|
+
resolve13(void 0);
|
|
6305
6447
|
previous.getChildren().filter((item) => {
|
|
6306
6448
|
return item !== directory && !current.has(item);
|
|
6307
6449
|
}).forEach((item) => {
|
|
@@ -6358,13 +6500,13 @@ var init_handler2 = __esm({
|
|
|
6358
6500
|
* @param depth Child path actually targeted for watch
|
|
6359
6501
|
* @param target Child path actually targeted for watch
|
|
6360
6502
|
*/
|
|
6361
|
-
async _addToNodeFs(
|
|
6503
|
+
async _addToNodeFs(path19, initialAdd, priorWh, depth, target) {
|
|
6362
6504
|
const ready = this.fsw._emitReady;
|
|
6363
|
-
if (this.fsw._isIgnored(
|
|
6505
|
+
if (this.fsw._isIgnored(path19) || this.fsw.closed) {
|
|
6364
6506
|
ready();
|
|
6365
6507
|
return false;
|
|
6366
6508
|
}
|
|
6367
|
-
const wh = this.fsw._getWatchHelpers(
|
|
6509
|
+
const wh = this.fsw._getWatchHelpers(path19);
|
|
6368
6510
|
if (priorWh) {
|
|
6369
6511
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
6370
6512
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -6380,8 +6522,8 @@ var init_handler2 = __esm({
|
|
|
6380
6522
|
const follow = this.fsw.options.followSymlinks;
|
|
6381
6523
|
let closer;
|
|
6382
6524
|
if (stats.isDirectory()) {
|
|
6383
|
-
const absPath = sp.resolve(
|
|
6384
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6525
|
+
const absPath = sp.resolve(path19);
|
|
6526
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
|
|
6385
6527
|
if (this.fsw.closed)
|
|
6386
6528
|
return;
|
|
6387
6529
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -6391,29 +6533,29 @@ var init_handler2 = __esm({
|
|
|
6391
6533
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
6392
6534
|
}
|
|
6393
6535
|
} else if (stats.isSymbolicLink()) {
|
|
6394
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
6536
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path19) : path19;
|
|
6395
6537
|
if (this.fsw.closed)
|
|
6396
6538
|
return;
|
|
6397
6539
|
const parent = sp.dirname(wh.watchPath);
|
|
6398
6540
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
6399
6541
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
6400
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
6542
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path19, wh, targetPath);
|
|
6401
6543
|
if (this.fsw.closed)
|
|
6402
6544
|
return;
|
|
6403
6545
|
if (targetPath !== void 0) {
|
|
6404
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
6546
|
+
this.fsw._symlinkPaths.set(sp.resolve(path19), targetPath);
|
|
6405
6547
|
}
|
|
6406
6548
|
} else {
|
|
6407
6549
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
6408
6550
|
}
|
|
6409
6551
|
ready();
|
|
6410
6552
|
if (closer)
|
|
6411
|
-
this.fsw._addPathCloser(
|
|
6553
|
+
this.fsw._addPathCloser(path19, closer);
|
|
6412
6554
|
return false;
|
|
6413
6555
|
} catch (error48) {
|
|
6414
6556
|
if (this.fsw._handleError(error48)) {
|
|
6415
6557
|
ready();
|
|
6416
|
-
return
|
|
6558
|
+
return path19;
|
|
6417
6559
|
}
|
|
6418
6560
|
}
|
|
6419
6561
|
}
|
|
@@ -6448,24 +6590,24 @@ function createPattern(matcher) {
|
|
|
6448
6590
|
}
|
|
6449
6591
|
return () => false;
|
|
6450
6592
|
}
|
|
6451
|
-
function normalizePath(
|
|
6452
|
-
if (typeof
|
|
6593
|
+
function normalizePath(path19) {
|
|
6594
|
+
if (typeof path19 !== "string")
|
|
6453
6595
|
throw new Error("string expected");
|
|
6454
|
-
|
|
6455
|
-
|
|
6596
|
+
path19 = sp2.normalize(path19);
|
|
6597
|
+
path19 = path19.replace(/\\/g, "/");
|
|
6456
6598
|
let prepend = false;
|
|
6457
|
-
if (
|
|
6599
|
+
if (path19.startsWith("//"))
|
|
6458
6600
|
prepend = true;
|
|
6459
|
-
|
|
6601
|
+
path19 = path19.replace(DOUBLE_SLASH_RE, "/");
|
|
6460
6602
|
if (prepend)
|
|
6461
|
-
|
|
6462
|
-
return
|
|
6603
|
+
path19 = "/" + path19;
|
|
6604
|
+
return path19;
|
|
6463
6605
|
}
|
|
6464
6606
|
function matchPatterns(patterns, testString, stats) {
|
|
6465
|
-
const
|
|
6607
|
+
const path19 = normalizePath(testString);
|
|
6466
6608
|
for (let index = 0; index < patterns.length; index++) {
|
|
6467
6609
|
const pattern = patterns[index];
|
|
6468
|
-
if (pattern(
|
|
6610
|
+
if (pattern(path19, stats)) {
|
|
6469
6611
|
return true;
|
|
6470
6612
|
}
|
|
6471
6613
|
}
|
|
@@ -6528,19 +6670,19 @@ var init_chokidar = __esm({
|
|
|
6528
6670
|
}
|
|
6529
6671
|
return str;
|
|
6530
6672
|
};
|
|
6531
|
-
normalizePathToUnix = (
|
|
6532
|
-
normalizeIgnored = (cwd = "") => (
|
|
6533
|
-
if (typeof
|
|
6534
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
6673
|
+
normalizePathToUnix = (path19) => toUnix(sp2.normalize(toUnix(path19)));
|
|
6674
|
+
normalizeIgnored = (cwd = "") => (path19) => {
|
|
6675
|
+
if (typeof path19 === "string") {
|
|
6676
|
+
return normalizePathToUnix(sp2.isAbsolute(path19) ? path19 : sp2.join(cwd, path19));
|
|
6535
6677
|
} else {
|
|
6536
|
-
return
|
|
6678
|
+
return path19;
|
|
6537
6679
|
}
|
|
6538
6680
|
};
|
|
6539
|
-
getAbsolutePath = (
|
|
6540
|
-
if (sp2.isAbsolute(
|
|
6541
|
-
return
|
|
6681
|
+
getAbsolutePath = (path19, cwd) => {
|
|
6682
|
+
if (sp2.isAbsolute(path19)) {
|
|
6683
|
+
return path19;
|
|
6542
6684
|
}
|
|
6543
|
-
return sp2.join(cwd,
|
|
6685
|
+
return sp2.join(cwd, path19);
|
|
6544
6686
|
};
|
|
6545
6687
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
6546
6688
|
DirEntry = class {
|
|
@@ -6605,10 +6747,10 @@ var init_chokidar = __esm({
|
|
|
6605
6747
|
dirParts;
|
|
6606
6748
|
followSymlinks;
|
|
6607
6749
|
statMethod;
|
|
6608
|
-
constructor(
|
|
6750
|
+
constructor(path19, follow, fsw) {
|
|
6609
6751
|
this.fsw = fsw;
|
|
6610
|
-
const watchPath =
|
|
6611
|
-
this.path =
|
|
6752
|
+
const watchPath = path19;
|
|
6753
|
+
this.path = path19 = path19.replace(REPLACER_RE, "");
|
|
6612
6754
|
this.watchPath = watchPath;
|
|
6613
6755
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
6614
6756
|
this.dirParts = [];
|
|
@@ -6748,20 +6890,20 @@ var init_chokidar = __esm({
|
|
|
6748
6890
|
this._closePromise = void 0;
|
|
6749
6891
|
let paths = unifyPaths(paths_);
|
|
6750
6892
|
if (cwd) {
|
|
6751
|
-
paths = paths.map((
|
|
6752
|
-
const absPath = getAbsolutePath(
|
|
6893
|
+
paths = paths.map((path19) => {
|
|
6894
|
+
const absPath = getAbsolutePath(path19, cwd);
|
|
6753
6895
|
return absPath;
|
|
6754
6896
|
});
|
|
6755
6897
|
}
|
|
6756
|
-
paths.forEach((
|
|
6757
|
-
this._removeIgnoredPath(
|
|
6898
|
+
paths.forEach((path19) => {
|
|
6899
|
+
this._removeIgnoredPath(path19);
|
|
6758
6900
|
});
|
|
6759
6901
|
this._userIgnored = void 0;
|
|
6760
6902
|
if (!this._readyCount)
|
|
6761
6903
|
this._readyCount = 0;
|
|
6762
6904
|
this._readyCount += paths.length;
|
|
6763
|
-
Promise.all(paths.map(async (
|
|
6764
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
6905
|
+
Promise.all(paths.map(async (path19) => {
|
|
6906
|
+
const res = await this._nodeFsHandler._addToNodeFs(path19, !_internal, void 0, 0, _origAdd);
|
|
6765
6907
|
if (res)
|
|
6766
6908
|
this._emitReady();
|
|
6767
6909
|
return res;
|
|
@@ -6783,17 +6925,17 @@ var init_chokidar = __esm({
|
|
|
6783
6925
|
return this;
|
|
6784
6926
|
const paths = unifyPaths(paths_);
|
|
6785
6927
|
const { cwd } = this.options;
|
|
6786
|
-
paths.forEach((
|
|
6787
|
-
if (!sp2.isAbsolute(
|
|
6928
|
+
paths.forEach((path19) => {
|
|
6929
|
+
if (!sp2.isAbsolute(path19) && !this._closers.has(path19)) {
|
|
6788
6930
|
if (cwd)
|
|
6789
|
-
|
|
6790
|
-
|
|
6931
|
+
path19 = sp2.join(cwd, path19);
|
|
6932
|
+
path19 = sp2.resolve(path19);
|
|
6791
6933
|
}
|
|
6792
|
-
this._closePath(
|
|
6793
|
-
this._addIgnoredPath(
|
|
6794
|
-
if (this._watched.has(
|
|
6934
|
+
this._closePath(path19);
|
|
6935
|
+
this._addIgnoredPath(path19);
|
|
6936
|
+
if (this._watched.has(path19)) {
|
|
6795
6937
|
this._addIgnoredPath({
|
|
6796
|
-
path:
|
|
6938
|
+
path: path19,
|
|
6797
6939
|
recursive: true
|
|
6798
6940
|
});
|
|
6799
6941
|
}
|
|
@@ -6857,38 +6999,38 @@ var init_chokidar = __esm({
|
|
|
6857
6999
|
* @param stats arguments to be passed with event
|
|
6858
7000
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
6859
7001
|
*/
|
|
6860
|
-
async _emit(event,
|
|
7002
|
+
async _emit(event, path19, stats) {
|
|
6861
7003
|
if (this.closed)
|
|
6862
7004
|
return;
|
|
6863
7005
|
const opts = this.options;
|
|
6864
7006
|
if (isWindows)
|
|
6865
|
-
|
|
7007
|
+
path19 = sp2.normalize(path19);
|
|
6866
7008
|
if (opts.cwd)
|
|
6867
|
-
|
|
6868
|
-
const args = [
|
|
7009
|
+
path19 = sp2.relative(opts.cwd, path19);
|
|
7010
|
+
const args = [path19];
|
|
6869
7011
|
if (stats != null)
|
|
6870
7012
|
args.push(stats);
|
|
6871
7013
|
const awf = opts.awaitWriteFinish;
|
|
6872
7014
|
let pw;
|
|
6873
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
7015
|
+
if (awf && (pw = this._pendingWrites.get(path19))) {
|
|
6874
7016
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
6875
7017
|
return this;
|
|
6876
7018
|
}
|
|
6877
7019
|
if (opts.atomic) {
|
|
6878
7020
|
if (event === EVENTS.UNLINK) {
|
|
6879
|
-
this._pendingUnlinks.set(
|
|
7021
|
+
this._pendingUnlinks.set(path19, [event, ...args]);
|
|
6880
7022
|
setTimeout(() => {
|
|
6881
|
-
this._pendingUnlinks.forEach((entry,
|
|
7023
|
+
this._pendingUnlinks.forEach((entry, path20) => {
|
|
6882
7024
|
this.emit(...entry);
|
|
6883
7025
|
this.emit(EVENTS.ALL, ...entry);
|
|
6884
|
-
this._pendingUnlinks.delete(
|
|
7026
|
+
this._pendingUnlinks.delete(path20);
|
|
6885
7027
|
});
|
|
6886
7028
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
6887
7029
|
return this;
|
|
6888
7030
|
}
|
|
6889
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
7031
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path19)) {
|
|
6890
7032
|
event = EVENTS.CHANGE;
|
|
6891
|
-
this._pendingUnlinks.delete(
|
|
7033
|
+
this._pendingUnlinks.delete(path19);
|
|
6892
7034
|
}
|
|
6893
7035
|
}
|
|
6894
7036
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -6906,16 +7048,16 @@ var init_chokidar = __esm({
|
|
|
6906
7048
|
this.emitWithAll(event, args);
|
|
6907
7049
|
}
|
|
6908
7050
|
};
|
|
6909
|
-
this._awaitWriteFinish(
|
|
7051
|
+
this._awaitWriteFinish(path19, awf.stabilityThreshold, event, awfEmit);
|
|
6910
7052
|
return this;
|
|
6911
7053
|
}
|
|
6912
7054
|
if (event === EVENTS.CHANGE) {
|
|
6913
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
7055
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path19, 50);
|
|
6914
7056
|
if (isThrottled)
|
|
6915
7057
|
return this;
|
|
6916
7058
|
}
|
|
6917
7059
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
6918
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
7060
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path19) : path19;
|
|
6919
7061
|
let stats2;
|
|
6920
7062
|
try {
|
|
6921
7063
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -6946,23 +7088,23 @@ var init_chokidar = __esm({
|
|
|
6946
7088
|
* @param timeout duration of time to suppress duplicate actions
|
|
6947
7089
|
* @returns tracking object or false if action should be suppressed
|
|
6948
7090
|
*/
|
|
6949
|
-
_throttle(actionType,
|
|
7091
|
+
_throttle(actionType, path19, timeout) {
|
|
6950
7092
|
if (!this._throttled.has(actionType)) {
|
|
6951
7093
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
6952
7094
|
}
|
|
6953
7095
|
const action = this._throttled.get(actionType);
|
|
6954
7096
|
if (!action)
|
|
6955
7097
|
throw new Error("invalid throttle");
|
|
6956
|
-
const actionPath = action.get(
|
|
7098
|
+
const actionPath = action.get(path19);
|
|
6957
7099
|
if (actionPath) {
|
|
6958
7100
|
actionPath.count++;
|
|
6959
7101
|
return false;
|
|
6960
7102
|
}
|
|
6961
7103
|
let timeoutObject;
|
|
6962
7104
|
const clear = () => {
|
|
6963
|
-
const item = action.get(
|
|
7105
|
+
const item = action.get(path19);
|
|
6964
7106
|
const count = item ? item.count : 0;
|
|
6965
|
-
action.delete(
|
|
7107
|
+
action.delete(path19);
|
|
6966
7108
|
clearTimeout(timeoutObject);
|
|
6967
7109
|
if (item)
|
|
6968
7110
|
clearTimeout(item.timeoutObject);
|
|
@@ -6970,7 +7112,7 @@ var init_chokidar = __esm({
|
|
|
6970
7112
|
};
|
|
6971
7113
|
timeoutObject = setTimeout(clear, timeout);
|
|
6972
7114
|
const thr = { timeoutObject, clear, count: 0 };
|
|
6973
|
-
action.set(
|
|
7115
|
+
action.set(path19, thr);
|
|
6974
7116
|
return thr;
|
|
6975
7117
|
}
|
|
6976
7118
|
_incrReadyCount() {
|
|
@@ -6984,44 +7126,44 @@ var init_chokidar = __esm({
|
|
|
6984
7126
|
* @param event
|
|
6985
7127
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
6986
7128
|
*/
|
|
6987
|
-
_awaitWriteFinish(
|
|
7129
|
+
_awaitWriteFinish(path19, threshold, event, awfEmit) {
|
|
6988
7130
|
const awf = this.options.awaitWriteFinish;
|
|
6989
7131
|
if (typeof awf !== "object")
|
|
6990
7132
|
return;
|
|
6991
7133
|
const pollInterval = awf.pollInterval;
|
|
6992
7134
|
let timeoutHandler;
|
|
6993
|
-
let fullPath =
|
|
6994
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
6995
|
-
fullPath = sp2.join(this.options.cwd,
|
|
7135
|
+
let fullPath = path19;
|
|
7136
|
+
if (this.options.cwd && !sp2.isAbsolute(path19)) {
|
|
7137
|
+
fullPath = sp2.join(this.options.cwd, path19);
|
|
6996
7138
|
}
|
|
6997
7139
|
const now = /* @__PURE__ */ new Date();
|
|
6998
7140
|
const writes = this._pendingWrites;
|
|
6999
7141
|
function awaitWriteFinishFn(prevStat) {
|
|
7000
7142
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
7001
|
-
if (err || !writes.has(
|
|
7143
|
+
if (err || !writes.has(path19)) {
|
|
7002
7144
|
if (err && err.code !== "ENOENT")
|
|
7003
7145
|
awfEmit(err);
|
|
7004
7146
|
return;
|
|
7005
7147
|
}
|
|
7006
7148
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
7007
7149
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
7008
|
-
writes.get(
|
|
7150
|
+
writes.get(path19).lastChange = now2;
|
|
7009
7151
|
}
|
|
7010
|
-
const pw = writes.get(
|
|
7152
|
+
const pw = writes.get(path19);
|
|
7011
7153
|
const df = now2 - pw.lastChange;
|
|
7012
7154
|
if (df >= threshold) {
|
|
7013
|
-
writes.delete(
|
|
7155
|
+
writes.delete(path19);
|
|
7014
7156
|
awfEmit(void 0, curStat);
|
|
7015
7157
|
} else {
|
|
7016
7158
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
7017
7159
|
}
|
|
7018
7160
|
});
|
|
7019
7161
|
}
|
|
7020
|
-
if (!writes.has(
|
|
7021
|
-
writes.set(
|
|
7162
|
+
if (!writes.has(path19)) {
|
|
7163
|
+
writes.set(path19, {
|
|
7022
7164
|
lastChange: now,
|
|
7023
7165
|
cancelWait: () => {
|
|
7024
|
-
writes.delete(
|
|
7166
|
+
writes.delete(path19);
|
|
7025
7167
|
clearTimeout(timeoutHandler);
|
|
7026
7168
|
return event;
|
|
7027
7169
|
}
|
|
@@ -7032,8 +7174,8 @@ var init_chokidar = __esm({
|
|
|
7032
7174
|
/**
|
|
7033
7175
|
* Determines whether user has asked to ignore this path.
|
|
7034
7176
|
*/
|
|
7035
|
-
_isIgnored(
|
|
7036
|
-
if (this.options.atomic && DOT_RE.test(
|
|
7177
|
+
_isIgnored(path19, stats) {
|
|
7178
|
+
if (this.options.atomic && DOT_RE.test(path19))
|
|
7037
7179
|
return true;
|
|
7038
7180
|
if (!this._userIgnored) {
|
|
7039
7181
|
const { cwd } = this.options;
|
|
@@ -7043,17 +7185,17 @@ var init_chokidar = __esm({
|
|
|
7043
7185
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
7044
7186
|
this._userIgnored = anymatch(list, void 0);
|
|
7045
7187
|
}
|
|
7046
|
-
return this._userIgnored(
|
|
7188
|
+
return this._userIgnored(path19, stats);
|
|
7047
7189
|
}
|
|
7048
|
-
_isntIgnored(
|
|
7049
|
-
return !this._isIgnored(
|
|
7190
|
+
_isntIgnored(path19, stat4) {
|
|
7191
|
+
return !this._isIgnored(path19, stat4);
|
|
7050
7192
|
}
|
|
7051
7193
|
/**
|
|
7052
7194
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
7053
7195
|
* @param path file or directory pattern being watched
|
|
7054
7196
|
*/
|
|
7055
|
-
_getWatchHelpers(
|
|
7056
|
-
return new WatchHelper(
|
|
7197
|
+
_getWatchHelpers(path19) {
|
|
7198
|
+
return new WatchHelper(path19, this.options.followSymlinks, this);
|
|
7057
7199
|
}
|
|
7058
7200
|
// Directory helpers
|
|
7059
7201
|
// -----------------
|
|
@@ -7085,63 +7227,63 @@ var init_chokidar = __esm({
|
|
|
7085
7227
|
* @param item base path of item/directory
|
|
7086
7228
|
*/
|
|
7087
7229
|
_remove(directory, item, isDirectory) {
|
|
7088
|
-
const
|
|
7089
|
-
const fullPath = sp2.resolve(
|
|
7090
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
7091
|
-
if (!this._throttle("remove",
|
|
7230
|
+
const path19 = sp2.join(directory, item);
|
|
7231
|
+
const fullPath = sp2.resolve(path19);
|
|
7232
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path19) || this._watched.has(fullPath);
|
|
7233
|
+
if (!this._throttle("remove", path19, 100))
|
|
7092
7234
|
return;
|
|
7093
7235
|
if (!isDirectory && this._watched.size === 1) {
|
|
7094
7236
|
this.add(directory, item, true);
|
|
7095
7237
|
}
|
|
7096
|
-
const wp = this._getWatchedDir(
|
|
7238
|
+
const wp = this._getWatchedDir(path19);
|
|
7097
7239
|
const nestedDirectoryChildren = wp.getChildren();
|
|
7098
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
7240
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path19, nested));
|
|
7099
7241
|
const parent = this._getWatchedDir(directory);
|
|
7100
7242
|
const wasTracked = parent.has(item);
|
|
7101
7243
|
parent.remove(item);
|
|
7102
7244
|
if (this._symlinkPaths.has(fullPath)) {
|
|
7103
7245
|
this._symlinkPaths.delete(fullPath);
|
|
7104
7246
|
}
|
|
7105
|
-
let relPath =
|
|
7247
|
+
let relPath = path19;
|
|
7106
7248
|
if (this.options.cwd)
|
|
7107
|
-
relPath = sp2.relative(this.options.cwd,
|
|
7249
|
+
relPath = sp2.relative(this.options.cwd, path19);
|
|
7108
7250
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
7109
7251
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
7110
7252
|
if (event === EVENTS.ADD)
|
|
7111
7253
|
return;
|
|
7112
7254
|
}
|
|
7113
|
-
this._watched.delete(
|
|
7255
|
+
this._watched.delete(path19);
|
|
7114
7256
|
this._watched.delete(fullPath);
|
|
7115
7257
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
7116
|
-
if (wasTracked && !this._isIgnored(
|
|
7117
|
-
this._emit(eventName,
|
|
7118
|
-
this._closePath(
|
|
7258
|
+
if (wasTracked && !this._isIgnored(path19))
|
|
7259
|
+
this._emit(eventName, path19);
|
|
7260
|
+
this._closePath(path19);
|
|
7119
7261
|
}
|
|
7120
7262
|
/**
|
|
7121
7263
|
* Closes all watchers for a path
|
|
7122
7264
|
*/
|
|
7123
|
-
_closePath(
|
|
7124
|
-
this._closeFile(
|
|
7125
|
-
const dir = sp2.dirname(
|
|
7126
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
7265
|
+
_closePath(path19) {
|
|
7266
|
+
this._closeFile(path19);
|
|
7267
|
+
const dir = sp2.dirname(path19);
|
|
7268
|
+
this._getWatchedDir(dir).remove(sp2.basename(path19));
|
|
7127
7269
|
}
|
|
7128
7270
|
/**
|
|
7129
7271
|
* Closes only file-specific watchers
|
|
7130
7272
|
*/
|
|
7131
|
-
_closeFile(
|
|
7132
|
-
const closers = this._closers.get(
|
|
7273
|
+
_closeFile(path19) {
|
|
7274
|
+
const closers = this._closers.get(path19);
|
|
7133
7275
|
if (!closers)
|
|
7134
7276
|
return;
|
|
7135
7277
|
closers.forEach((closer) => closer());
|
|
7136
|
-
this._closers.delete(
|
|
7278
|
+
this._closers.delete(path19);
|
|
7137
7279
|
}
|
|
7138
|
-
_addPathCloser(
|
|
7280
|
+
_addPathCloser(path19, closer) {
|
|
7139
7281
|
if (!closer)
|
|
7140
7282
|
return;
|
|
7141
|
-
let list = this._closers.get(
|
|
7283
|
+
let list = this._closers.get(path19);
|
|
7142
7284
|
if (!list) {
|
|
7143
7285
|
list = [];
|
|
7144
|
-
this._closers.set(
|
|
7286
|
+
this._closers.set(path19, list);
|
|
7145
7287
|
}
|
|
7146
7288
|
list.push(closer);
|
|
7147
7289
|
}
|
|
@@ -7167,12 +7309,12 @@ var init_chokidar = __esm({
|
|
|
7167
7309
|
});
|
|
7168
7310
|
|
|
7169
7311
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
7170
|
-
var fs5,
|
|
7312
|
+
var fs5, path7, os7, ProviderLoader;
|
|
7171
7313
|
var init_provider_loader = __esm({
|
|
7172
7314
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
7173
7315
|
"use strict";
|
|
7174
7316
|
fs5 = __toESM(require("fs"));
|
|
7175
|
-
|
|
7317
|
+
path7 = __toESM(require("path"));
|
|
7176
7318
|
os7 = __toESM(require("os"));
|
|
7177
7319
|
init_chokidar();
|
|
7178
7320
|
init_ide_detector();
|
|
@@ -7194,12 +7336,12 @@ var init_provider_loader = __esm({
|
|
|
7194
7336
|
static META_FILE = ".meta.json";
|
|
7195
7337
|
constructor(options) {
|
|
7196
7338
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
7197
|
-
const defaultProvidersDir =
|
|
7339
|
+
const defaultProvidersDir = path7.join(os7.homedir(), ".adhdev", "providers");
|
|
7198
7340
|
if (options?.userDir) {
|
|
7199
7341
|
this.userDir = options.userDir;
|
|
7200
7342
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
7201
7343
|
} else {
|
|
7202
|
-
const localRepoPath =
|
|
7344
|
+
const localRepoPath = path7.resolve(__dirname, "../../../../../adhdev-providers");
|
|
7203
7345
|
if (fs5.existsSync(localRepoPath)) {
|
|
7204
7346
|
this.userDir = localRepoPath;
|
|
7205
7347
|
this.log(`Auto-detected local public repository: ${this.userDir} (Dev workspace speedup)`);
|
|
@@ -7208,7 +7350,7 @@ var init_provider_loader = __esm({
|
|
|
7208
7350
|
this.log(`Using default user providers directory: ${this.userDir}`);
|
|
7209
7351
|
}
|
|
7210
7352
|
}
|
|
7211
|
-
this.upstreamDir =
|
|
7353
|
+
this.upstreamDir = path7.join(defaultProvidersDir, ".upstream");
|
|
7212
7354
|
this.disableUpstream = options?.disableUpstream ?? false;
|
|
7213
7355
|
}
|
|
7214
7356
|
log(msg) {
|
|
@@ -7238,7 +7380,7 @@ var init_provider_loader = __esm({
|
|
|
7238
7380
|
* Canonical provider directory shape for a given root.
|
|
7239
7381
|
*/
|
|
7240
7382
|
getProviderDir(root, category, type) {
|
|
7241
|
-
return
|
|
7383
|
+
return path7.join(root, category, type);
|
|
7242
7384
|
}
|
|
7243
7385
|
/**
|
|
7244
7386
|
* Canonical user override directory for a provider.
|
|
@@ -7265,7 +7407,7 @@ var init_provider_loader = __esm({
|
|
|
7265
7407
|
resolveProviderFile(type, ...segments) {
|
|
7266
7408
|
const dir = this.findProviderDirInternal(type);
|
|
7267
7409
|
if (!dir) return null;
|
|
7268
|
-
return
|
|
7410
|
+
return path7.join(dir, ...segments);
|
|
7269
7411
|
}
|
|
7270
7412
|
/**
|
|
7271
7413
|
* Load all providers (3-tier priority)
|
|
@@ -7303,7 +7445,7 @@ var init_provider_loader = __esm({
|
|
|
7303
7445
|
if (!fs5.existsSync(this.upstreamDir)) return false;
|
|
7304
7446
|
try {
|
|
7305
7447
|
return fs5.readdirSync(this.upstreamDir).some(
|
|
7306
|
-
(d) => fs5.statSync(
|
|
7448
|
+
(d) => fs5.statSync(path7.join(this.upstreamDir, d)).isDirectory()
|
|
7307
7449
|
);
|
|
7308
7450
|
} catch {
|
|
7309
7451
|
return false;
|
|
@@ -7595,14 +7737,14 @@ var init_provider_loader = __esm({
|
|
|
7595
7737
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
7596
7738
|
return null;
|
|
7597
7739
|
}
|
|
7598
|
-
const dir =
|
|
7740
|
+
const dir = path7.join(providerDir, scriptDir);
|
|
7599
7741
|
if (!fs5.existsSync(dir)) {
|
|
7600
7742
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
7601
7743
|
return null;
|
|
7602
7744
|
}
|
|
7603
7745
|
const cached2 = this.scriptsCache.get(dir);
|
|
7604
7746
|
if (cached2) return cached2;
|
|
7605
|
-
const scriptsJs =
|
|
7747
|
+
const scriptsJs = path7.join(dir, "scripts.js");
|
|
7606
7748
|
if (fs5.existsSync(scriptsJs)) {
|
|
7607
7749
|
try {
|
|
7608
7750
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -7641,7 +7783,7 @@ var init_provider_loader = __esm({
|
|
|
7641
7783
|
});
|
|
7642
7784
|
const handleChange = (filePath) => {
|
|
7643
7785
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
7644
|
-
this.log(`File changed: ${
|
|
7786
|
+
this.log(`File changed: ${path7.basename(filePath)}, reloading...`);
|
|
7645
7787
|
this.reload();
|
|
7646
7788
|
}
|
|
7647
7789
|
};
|
|
@@ -7696,7 +7838,7 @@ var init_provider_loader = __esm({
|
|
|
7696
7838
|
}
|
|
7697
7839
|
const https = require("https");
|
|
7698
7840
|
const { execSync: execSync6 } = require("child_process");
|
|
7699
|
-
const metaPath =
|
|
7841
|
+
const metaPath = path7.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
7700
7842
|
let prevEtag = "";
|
|
7701
7843
|
let prevTimestamp = 0;
|
|
7702
7844
|
try {
|
|
@@ -7713,7 +7855,7 @@ var init_provider_loader = __esm({
|
|
|
7713
7855
|
return { updated: false };
|
|
7714
7856
|
}
|
|
7715
7857
|
try {
|
|
7716
|
-
const etag = await new Promise((
|
|
7858
|
+
const etag = await new Promise((resolve13, reject) => {
|
|
7717
7859
|
const options = {
|
|
7718
7860
|
method: "HEAD",
|
|
7719
7861
|
hostname: "github.com",
|
|
@@ -7731,7 +7873,7 @@ var init_provider_loader = __esm({
|
|
|
7731
7873
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
7732
7874
|
timeout: 1e4
|
|
7733
7875
|
}, (res2) => {
|
|
7734
|
-
|
|
7876
|
+
resolve13(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
7735
7877
|
});
|
|
7736
7878
|
req2.on("error", reject);
|
|
7737
7879
|
req2.on("timeout", () => {
|
|
@@ -7740,7 +7882,7 @@ var init_provider_loader = __esm({
|
|
|
7740
7882
|
});
|
|
7741
7883
|
req2.end();
|
|
7742
7884
|
} else {
|
|
7743
|
-
|
|
7885
|
+
resolve13(res.headers.etag || res.headers["last-modified"] || "");
|
|
7744
7886
|
}
|
|
7745
7887
|
});
|
|
7746
7888
|
req.on("error", reject);
|
|
@@ -7756,17 +7898,17 @@ var init_provider_loader = __esm({
|
|
|
7756
7898
|
return { updated: false };
|
|
7757
7899
|
}
|
|
7758
7900
|
this.log("Downloading latest providers from GitHub...");
|
|
7759
|
-
const tmpTar =
|
|
7760
|
-
const tmpExtract =
|
|
7901
|
+
const tmpTar = path7.join(os7.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
7902
|
+
const tmpExtract = path7.join(os7.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
7761
7903
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
7762
7904
|
fs5.mkdirSync(tmpExtract, { recursive: true });
|
|
7763
7905
|
execSync6(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
7764
7906
|
const extracted = fs5.readdirSync(tmpExtract);
|
|
7765
7907
|
const rootDir = extracted.find(
|
|
7766
|
-
(d) => fs5.statSync(
|
|
7908
|
+
(d) => fs5.statSync(path7.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
7767
7909
|
);
|
|
7768
7910
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
7769
|
-
const sourceDir =
|
|
7911
|
+
const sourceDir = path7.join(tmpExtract, rootDir);
|
|
7770
7912
|
const backupDir = this.upstreamDir + ".bak";
|
|
7771
7913
|
if (fs5.existsSync(this.upstreamDir)) {
|
|
7772
7914
|
if (fs5.existsSync(backupDir)) fs5.rmSync(backupDir, { recursive: true, force: true });
|
|
@@ -7804,7 +7946,7 @@ var init_provider_loader = __esm({
|
|
|
7804
7946
|
downloadFile(url2, destPath) {
|
|
7805
7947
|
const https = require("https");
|
|
7806
7948
|
const http3 = require("http");
|
|
7807
|
-
return new Promise((
|
|
7949
|
+
return new Promise((resolve13, reject) => {
|
|
7808
7950
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
7809
7951
|
if (redirectCount > 5) {
|
|
7810
7952
|
reject(new Error("Too many redirects"));
|
|
@@ -7824,7 +7966,7 @@ var init_provider_loader = __esm({
|
|
|
7824
7966
|
res.pipe(ws2);
|
|
7825
7967
|
ws2.on("finish", () => {
|
|
7826
7968
|
ws2.close();
|
|
7827
|
-
|
|
7969
|
+
resolve13();
|
|
7828
7970
|
});
|
|
7829
7971
|
ws2.on("error", reject);
|
|
7830
7972
|
});
|
|
@@ -7841,8 +7983,8 @@ var init_provider_loader = __esm({
|
|
|
7841
7983
|
copyDirRecursive(src, dest) {
|
|
7842
7984
|
fs5.mkdirSync(dest, { recursive: true });
|
|
7843
7985
|
for (const entry of fs5.readdirSync(src, { withFileTypes: true })) {
|
|
7844
|
-
const srcPath =
|
|
7845
|
-
const destPath =
|
|
7986
|
+
const srcPath = path7.join(src, entry.name);
|
|
7987
|
+
const destPath = path7.join(dest, entry.name);
|
|
7846
7988
|
if (entry.isDirectory()) {
|
|
7847
7989
|
this.copyDirRecursive(srcPath, destPath);
|
|
7848
7990
|
} else {
|
|
@@ -7853,7 +7995,7 @@ var init_provider_loader = __esm({
|
|
|
7853
7995
|
/** .meta.json save */
|
|
7854
7996
|
writeMeta(metaPath, etag, timestamp) {
|
|
7855
7997
|
try {
|
|
7856
|
-
fs5.mkdirSync(
|
|
7998
|
+
fs5.mkdirSync(path7.dirname(metaPath), { recursive: true });
|
|
7857
7999
|
fs5.writeFileSync(metaPath, JSON.stringify({
|
|
7858
8000
|
etag,
|
|
7859
8001
|
timestamp,
|
|
@@ -7870,7 +8012,7 @@ var init_provider_loader = __esm({
|
|
|
7870
8012
|
const scan = (d) => {
|
|
7871
8013
|
try {
|
|
7872
8014
|
for (const entry of fs5.readdirSync(d, { withFileTypes: true })) {
|
|
7873
|
-
if (entry.isDirectory()) scan(
|
|
8015
|
+
if (entry.isDirectory()) scan(path7.join(d, entry.name));
|
|
7874
8016
|
else if (entry.name === "provider.json") count++;
|
|
7875
8017
|
}
|
|
7876
8018
|
} catch {
|
|
@@ -7969,17 +8111,17 @@ var init_provider_loader = __esm({
|
|
|
7969
8111
|
for (const root of searchRoots) {
|
|
7970
8112
|
if (!fs5.existsSync(root)) continue;
|
|
7971
8113
|
const candidate = this.getProviderDir(root, cat, type);
|
|
7972
|
-
if (fs5.existsSync(
|
|
7973
|
-
const catDir =
|
|
8114
|
+
if (fs5.existsSync(path7.join(candidate, "provider.json"))) return candidate;
|
|
8115
|
+
const catDir = path7.join(root, cat);
|
|
7974
8116
|
if (fs5.existsSync(catDir)) {
|
|
7975
8117
|
try {
|
|
7976
8118
|
for (const entry of fs5.readdirSync(catDir, { withFileTypes: true })) {
|
|
7977
8119
|
if (!entry.isDirectory()) continue;
|
|
7978
|
-
const jsonPath =
|
|
8120
|
+
const jsonPath = path7.join(catDir, entry.name, "provider.json");
|
|
7979
8121
|
if (fs5.existsSync(jsonPath)) {
|
|
7980
8122
|
try {
|
|
7981
8123
|
const data = JSON.parse(fs5.readFileSync(jsonPath, "utf-8"));
|
|
7982
|
-
if (data.type === type) return
|
|
8124
|
+
if (data.type === type) return path7.join(catDir, entry.name);
|
|
7983
8125
|
} catch {
|
|
7984
8126
|
}
|
|
7985
8127
|
}
|
|
@@ -7996,7 +8138,7 @@ var init_provider_loader = __esm({
|
|
|
7996
8138
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
7997
8139
|
*/
|
|
7998
8140
|
buildScriptWrappersFromDir(dir) {
|
|
7999
|
-
const scriptsJs =
|
|
8141
|
+
const scriptsJs = path7.join(dir, "scripts.js");
|
|
8000
8142
|
if (fs5.existsSync(scriptsJs)) {
|
|
8001
8143
|
try {
|
|
8002
8144
|
delete require.cache[require.resolve(scriptsJs)];
|
|
@@ -8010,7 +8152,7 @@ var init_provider_loader = __esm({
|
|
|
8010
8152
|
for (const file2 of fs5.readdirSync(dir)) {
|
|
8011
8153
|
if (!file2.endsWith(".js")) continue;
|
|
8012
8154
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
8013
|
-
const filePath =
|
|
8155
|
+
const filePath = path7.join(dir, file2);
|
|
8014
8156
|
result[scriptName] = (...args) => {
|
|
8015
8157
|
try {
|
|
8016
8158
|
let content = fs5.readFileSync(filePath, "utf-8");
|
|
@@ -8070,7 +8212,7 @@ var init_provider_loader = __esm({
|
|
|
8070
8212
|
}
|
|
8071
8213
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
8072
8214
|
if (hasJson) {
|
|
8073
|
-
const jsonPath =
|
|
8215
|
+
const jsonPath = path7.join(d, "provider.json");
|
|
8074
8216
|
try {
|
|
8075
8217
|
const raw = fs5.readFileSync(jsonPath, "utf-8");
|
|
8076
8218
|
const mod = JSON.parse(raw);
|
|
@@ -8083,7 +8225,7 @@ var init_provider_loader = __esm({
|
|
|
8083
8225
|
delete mod.extensionIdPattern_flags;
|
|
8084
8226
|
}
|
|
8085
8227
|
const hasCompatibility = Array.isArray(mod.compatibility);
|
|
8086
|
-
const scriptsPath =
|
|
8228
|
+
const scriptsPath = path7.join(d, "scripts.js");
|
|
8087
8229
|
if (!hasCompatibility && fs5.existsSync(scriptsPath)) {
|
|
8088
8230
|
try {
|
|
8089
8231
|
delete require.cache[require.resolve(scriptsPath)];
|
|
@@ -8109,7 +8251,7 @@ var init_provider_loader = __esm({
|
|
|
8109
8251
|
if (!entry.isDirectory()) continue;
|
|
8110
8252
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
8111
8253
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
8112
|
-
scan(
|
|
8254
|
+
scan(path7.join(d, entry.name));
|
|
8113
8255
|
}
|
|
8114
8256
|
}
|
|
8115
8257
|
};
|
|
@@ -8190,17 +8332,17 @@ async function findFreePort(ports) {
|
|
|
8190
8332
|
throw new Error("No free port found");
|
|
8191
8333
|
}
|
|
8192
8334
|
function checkPortFree(port) {
|
|
8193
|
-
return new Promise((
|
|
8335
|
+
return new Promise((resolve13) => {
|
|
8194
8336
|
const server = net.createServer();
|
|
8195
8337
|
server.unref();
|
|
8196
|
-
server.on("error", () =>
|
|
8338
|
+
server.on("error", () => resolve13(false));
|
|
8197
8339
|
server.listen(port, "127.0.0.1", () => {
|
|
8198
|
-
server.close(() =>
|
|
8340
|
+
server.close(() => resolve13(true));
|
|
8199
8341
|
});
|
|
8200
8342
|
});
|
|
8201
8343
|
}
|
|
8202
8344
|
async function isCdpActive(port) {
|
|
8203
|
-
return new Promise((
|
|
8345
|
+
return new Promise((resolve13) => {
|
|
8204
8346
|
const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
8205
8347
|
timeout: 2e3
|
|
8206
8348
|
}, (res) => {
|
|
@@ -8209,16 +8351,16 @@ async function isCdpActive(port) {
|
|
|
8209
8351
|
res.on("end", () => {
|
|
8210
8352
|
try {
|
|
8211
8353
|
const info = JSON.parse(data);
|
|
8212
|
-
|
|
8354
|
+
resolve13(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
8213
8355
|
} catch {
|
|
8214
|
-
|
|
8356
|
+
resolve13(false);
|
|
8215
8357
|
}
|
|
8216
8358
|
});
|
|
8217
8359
|
});
|
|
8218
|
-
req.on("error", () =>
|
|
8360
|
+
req.on("error", () => resolve13(false));
|
|
8219
8361
|
req.on("timeout", () => {
|
|
8220
8362
|
req.destroy();
|
|
8221
|
-
|
|
8363
|
+
resolve13(false);
|
|
8222
8364
|
});
|
|
8223
8365
|
});
|
|
8224
8366
|
}
|
|
@@ -8333,17 +8475,17 @@ function detectCurrentWorkspace(ideId) {
|
|
|
8333
8475
|
}
|
|
8334
8476
|
} else if (plat === "win32") {
|
|
8335
8477
|
try {
|
|
8336
|
-
const
|
|
8478
|
+
const fs16 = require("fs");
|
|
8337
8479
|
const appNameMap = getMacAppIdentifiers();
|
|
8338
8480
|
const appName = appNameMap[ideId];
|
|
8339
8481
|
if (appName) {
|
|
8340
|
-
const storagePath =
|
|
8341
|
-
process.env.APPDATA ||
|
|
8482
|
+
const storagePath = path8.join(
|
|
8483
|
+
process.env.APPDATA || path8.join(os8.homedir(), "AppData", "Roaming"),
|
|
8342
8484
|
appName,
|
|
8343
8485
|
"storage.json"
|
|
8344
8486
|
);
|
|
8345
|
-
if (
|
|
8346
|
-
const data = JSON.parse(
|
|
8487
|
+
if (fs16.existsSync(storagePath)) {
|
|
8488
|
+
const data = JSON.parse(fs16.readFileSync(storagePath, "utf-8"));
|
|
8347
8489
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
8348
8490
|
if (workspaces.length > 0) {
|
|
8349
8491
|
const recent = workspaces[0];
|
|
@@ -8501,14 +8643,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
8501
8643
|
if (workspace) args.push(workspace);
|
|
8502
8644
|
(0, import_child_process4.spawn)(cli, args, { detached: true, stdio: "ignore" }).unref();
|
|
8503
8645
|
}
|
|
8504
|
-
var import_child_process4, net, os8,
|
|
8646
|
+
var import_child_process4, net, os8, path8, _providerLoader;
|
|
8505
8647
|
var init_launch = __esm({
|
|
8506
8648
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
8507
8649
|
"use strict";
|
|
8508
8650
|
import_child_process4 = require("child_process");
|
|
8509
8651
|
net = __toESM(require("net"));
|
|
8510
8652
|
os8 = __toESM(require("os"));
|
|
8511
|
-
|
|
8653
|
+
path8 = __toESM(require("path"));
|
|
8512
8654
|
init_ide_detector();
|
|
8513
8655
|
init_provider_loader();
|
|
8514
8656
|
_providerLoader = null;
|
|
@@ -8539,7 +8681,7 @@ function checkRotation() {
|
|
|
8539
8681
|
const today = getDateStr2();
|
|
8540
8682
|
if (today !== currentDate2) {
|
|
8541
8683
|
currentDate2 = today;
|
|
8542
|
-
currentFile =
|
|
8684
|
+
currentFile = path9.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
8543
8685
|
cleanOldFiles();
|
|
8544
8686
|
}
|
|
8545
8687
|
}
|
|
@@ -8553,7 +8695,7 @@ function cleanOldFiles() {
|
|
|
8553
8695
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
8554
8696
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
8555
8697
|
try {
|
|
8556
|
-
fs6.unlinkSync(
|
|
8698
|
+
fs6.unlinkSync(path9.join(LOG_DIR2, file2));
|
|
8557
8699
|
} catch {
|
|
8558
8700
|
}
|
|
8559
8701
|
}
|
|
@@ -8595,14 +8737,14 @@ function logCommand(entry) {
|
|
|
8595
8737
|
} catch {
|
|
8596
8738
|
}
|
|
8597
8739
|
}
|
|
8598
|
-
var fs6,
|
|
8740
|
+
var fs6, path9, os9, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
8599
8741
|
var init_command_log = __esm({
|
|
8600
8742
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
8601
8743
|
"use strict";
|
|
8602
8744
|
fs6 = __toESM(require("fs"));
|
|
8603
|
-
|
|
8745
|
+
path9 = __toESM(require("path"));
|
|
8604
8746
|
os9 = __toESM(require("os"));
|
|
8605
|
-
LOG_DIR2 = process.platform === "win32" ?
|
|
8747
|
+
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");
|
|
8606
8748
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
8607
8749
|
MAX_DAYS = 7;
|
|
8608
8750
|
try {
|
|
@@ -8621,7 +8763,7 @@ var init_command_log = __esm({
|
|
|
8621
8763
|
"text"
|
|
8622
8764
|
]);
|
|
8623
8765
|
currentDate2 = getDateStr2();
|
|
8624
|
-
currentFile =
|
|
8766
|
+
currentFile = path9.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
8625
8767
|
writeCount2 = 0;
|
|
8626
8768
|
SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
8627
8769
|
"heartbeat",
|
|
@@ -8643,6 +8785,7 @@ var init_router = __esm({
|
|
|
8643
8785
|
init_workspaces();
|
|
8644
8786
|
init_workspace_activity();
|
|
8645
8787
|
init_config();
|
|
8788
|
+
init_recent_activity();
|
|
8646
8789
|
init_ide_detector();
|
|
8647
8790
|
init_logger();
|
|
8648
8791
|
init_command_log();
|
|
@@ -8801,9 +8944,27 @@ var init_router = __esm({
|
|
|
8801
8944
|
this.deps.onIdeConnected?.();
|
|
8802
8945
|
if (result.success && resolvedWorkspace) {
|
|
8803
8946
|
try {
|
|
8804
|
-
|
|
8947
|
+
let next = appendWorkspaceActivity(loadConfig(), resolvedWorkspace, {
|
|
8805
8948
|
kind: "ide",
|
|
8806
8949
|
agentType: result.ideId
|
|
8950
|
+
});
|
|
8951
|
+
next = appendRecentActivity(next, {
|
|
8952
|
+
kind: "ide",
|
|
8953
|
+
providerType: result.ideId || ideKey,
|
|
8954
|
+
providerName: result.ideId || ideKey,
|
|
8955
|
+
workspace: resolvedWorkspace,
|
|
8956
|
+
title: result.ideId || ideKey
|
|
8957
|
+
});
|
|
8958
|
+
saveConfig(next);
|
|
8959
|
+
} catch {
|
|
8960
|
+
}
|
|
8961
|
+
} else if (result.success && (result.ideId || ideKey)) {
|
|
8962
|
+
try {
|
|
8963
|
+
saveConfig(appendRecentActivity(loadConfig(), {
|
|
8964
|
+
kind: "ide",
|
|
8965
|
+
providerType: result.ideId || ideKey,
|
|
8966
|
+
providerName: result.ideId || ideKey,
|
|
8967
|
+
title: result.ideId || ideKey
|
|
8807
8968
|
}));
|
|
8808
8969
|
} catch {
|
|
8809
8970
|
}
|
|
@@ -8823,6 +8984,30 @@ var init_router = __esm({
|
|
|
8823
8984
|
updateConfig({ userName: name });
|
|
8824
8985
|
return { success: true, userName: name };
|
|
8825
8986
|
}
|
|
8987
|
+
case "mark_recent_seen": {
|
|
8988
|
+
const kind = args?.kind;
|
|
8989
|
+
const providerType = args?.providerType;
|
|
8990
|
+
if (!kind || !providerType) {
|
|
8991
|
+
return { success: false, error: "kind and providerType are required" };
|
|
8992
|
+
}
|
|
8993
|
+
const recentKey = args?.recentKey || buildRecentActivityKey({
|
|
8994
|
+
kind,
|
|
8995
|
+
providerType,
|
|
8996
|
+
workspace: args?.workspace || null
|
|
8997
|
+
});
|
|
8998
|
+
const next = markRecentSessionSeen(
|
|
8999
|
+
loadConfig(),
|
|
9000
|
+
recentKey,
|
|
9001
|
+
typeof args?.seenAt === "number" ? args.seenAt : Date.now()
|
|
9002
|
+
);
|
|
9003
|
+
saveConfig(next);
|
|
9004
|
+
this.deps.onStatusChange?.();
|
|
9005
|
+
return {
|
|
9006
|
+
success: true,
|
|
9007
|
+
recentKey,
|
|
9008
|
+
seenAt: next.recentSessionReads?.[recentKey] || Date.now()
|
|
9009
|
+
};
|
|
9010
|
+
}
|
|
8826
9011
|
// ─── Daemon Self-Upgrade ───
|
|
8827
9012
|
case "daemon_upgrade": {
|
|
8828
9013
|
LOG.info("Upgrade", "Remote upgrade requested from dashboard");
|
|
@@ -8841,10 +9026,10 @@ var init_router = __esm({
|
|
|
8841
9026
|
setTimeout(() => {
|
|
8842
9027
|
LOG.info("Upgrade", "Restarting daemon with new version...");
|
|
8843
9028
|
try {
|
|
8844
|
-
const
|
|
8845
|
-
const
|
|
8846
|
-
const pidFile =
|
|
8847
|
-
if (
|
|
9029
|
+
const path19 = require("path");
|
|
9030
|
+
const fs16 = require("fs");
|
|
9031
|
+
const pidFile = path19.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
|
|
9032
|
+
if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
|
|
8848
9033
|
} catch {
|
|
8849
9034
|
}
|
|
8850
9035
|
const { spawn: spawn4 } = require("child_process");
|
|
@@ -8937,263 +9122,6 @@ var init_router = __esm({
|
|
|
8937
9122
|
}
|
|
8938
9123
|
});
|
|
8939
9124
|
|
|
8940
|
-
// ../../oss/packages/daemon-core/src/status/snapshot.ts
|
|
8941
|
-
function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
|
|
8942
|
-
return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
|
|
8943
|
-
id: ide.id,
|
|
8944
|
-
type: ide.id,
|
|
8945
|
-
name: ide.displayName || ide.name || ide.id,
|
|
8946
|
-
running: isCdpConnected(cdpManagers, ide.id),
|
|
8947
|
-
...ide.path ? { path: ide.path } : {}
|
|
8948
|
-
}));
|
|
8949
|
-
}
|
|
8950
|
-
function buildAvailableProviders(providerLoader) {
|
|
8951
|
-
return providerLoader.getAll().map((provider) => ({
|
|
8952
|
-
type: provider.type,
|
|
8953
|
-
name: provider.displayName || provider.type,
|
|
8954
|
-
displayName: provider.displayName || provider.type,
|
|
8955
|
-
icon: provider.icon || "\u{1F4BB}",
|
|
8956
|
-
category: provider.category
|
|
8957
|
-
}));
|
|
8958
|
-
}
|
|
8959
|
-
function buildStatusSnapshot(options) {
|
|
8960
|
-
const cfg = loadConfig();
|
|
8961
|
-
const wsState = getWorkspaceState(cfg);
|
|
8962
|
-
const memSnap = getHostMemorySnapshot();
|
|
8963
|
-
const sessions = buildSessionEntries(
|
|
8964
|
-
options.allStates,
|
|
8965
|
-
options.cdpManagers
|
|
8966
|
-
);
|
|
8967
|
-
return {
|
|
8968
|
-
instanceId: options.instanceId,
|
|
8969
|
-
version: options.version,
|
|
8970
|
-
daemonMode: options.daemonMode,
|
|
8971
|
-
machine: {
|
|
8972
|
-
hostname: os10.hostname(),
|
|
8973
|
-
platform: os10.platform(),
|
|
8974
|
-
arch: os10.arch(),
|
|
8975
|
-
cpus: os10.cpus().length,
|
|
8976
|
-
totalMem: memSnap.totalMem,
|
|
8977
|
-
freeMem: memSnap.freeMem,
|
|
8978
|
-
availableMem: memSnap.availableMem,
|
|
8979
|
-
loadavg: os10.loadavg(),
|
|
8980
|
-
uptime: os10.uptime(),
|
|
8981
|
-
release: os10.release()
|
|
8982
|
-
},
|
|
8983
|
-
machineNickname: options.machineNickname ?? cfg.machineNickname ?? null,
|
|
8984
|
-
timestamp: options.timestamp ?? Date.now(),
|
|
8985
|
-
detectedIdes: buildDetectedIdeInfos(options.detectedIdes, options.cdpManagers),
|
|
8986
|
-
...options.p2p ? { p2p: options.p2p } : {},
|
|
8987
|
-
sessions,
|
|
8988
|
-
workspaces: wsState.workspaces,
|
|
8989
|
-
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
8990
|
-
defaultWorkspacePath: wsState.defaultWorkspacePath,
|
|
8991
|
-
workspaceActivity: getWorkspaceActivity(cfg, 15),
|
|
8992
|
-
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
8993
|
-
};
|
|
8994
|
-
}
|
|
8995
|
-
var os10;
|
|
8996
|
-
var init_snapshot = __esm({
|
|
8997
|
-
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
8998
|
-
"use strict";
|
|
8999
|
-
os10 = __toESM(require("os"));
|
|
9000
|
-
init_config();
|
|
9001
|
-
init_workspaces();
|
|
9002
|
-
init_workspace_activity();
|
|
9003
|
-
init_host_memory();
|
|
9004
|
-
init_builders();
|
|
9005
|
-
}
|
|
9006
|
-
});
|
|
9007
|
-
|
|
9008
|
-
// ../../oss/packages/daemon-core/src/status/reporter.ts
|
|
9009
|
-
var DaemonStatusReporter;
|
|
9010
|
-
var init_reporter = __esm({
|
|
9011
|
-
"../../oss/packages/daemon-core/src/status/reporter.ts"() {
|
|
9012
|
-
"use strict";
|
|
9013
|
-
init_logger();
|
|
9014
|
-
init_builders();
|
|
9015
|
-
init_snapshot();
|
|
9016
|
-
DaemonStatusReporter = class {
|
|
9017
|
-
deps;
|
|
9018
|
-
log;
|
|
9019
|
-
lastStatusSentAt = 0;
|
|
9020
|
-
statusPendingThrottle = false;
|
|
9021
|
-
lastP2PStatusHash = "";
|
|
9022
|
-
lastStatusSummary = "";
|
|
9023
|
-
statusTimer = null;
|
|
9024
|
-
p2pTimer = null;
|
|
9025
|
-
constructor(deps, opts) {
|
|
9026
|
-
this.deps = deps;
|
|
9027
|
-
this.log = opts?.logFn || LOG.forComponent("Status").asLogFn();
|
|
9028
|
-
}
|
|
9029
|
-
// ─── Lifecycle ───────────────────────────────────
|
|
9030
|
-
startReporting() {
|
|
9031
|
-
setTimeout(() => {
|
|
9032
|
-
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Initial report failed: ${e?.message}`));
|
|
9033
|
-
}, 2e3);
|
|
9034
|
-
const scheduleServerReport = () => {
|
|
9035
|
-
this.statusTimer = setTimeout(() => {
|
|
9036
|
-
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Periodic report failed: ${e?.message}`));
|
|
9037
|
-
scheduleServerReport();
|
|
9038
|
-
}, 3e4);
|
|
9039
|
-
};
|
|
9040
|
-
scheduleServerReport();
|
|
9041
|
-
this.p2pTimer = setInterval(() => {
|
|
9042
|
-
if (this.deps.p2p?.isConnected) {
|
|
9043
|
-
this.sendUnifiedStatusReport({ p2pOnly: true }).catch((e) => LOG.warn("Status", `P2P status send failed: ${e?.message}`));
|
|
9044
|
-
}
|
|
9045
|
-
}, 5e3);
|
|
9046
|
-
}
|
|
9047
|
-
stopReporting() {
|
|
9048
|
-
if (this.statusTimer) {
|
|
9049
|
-
clearTimeout(this.statusTimer);
|
|
9050
|
-
this.statusTimer = null;
|
|
9051
|
-
}
|
|
9052
|
-
if (this.p2pTimer) {
|
|
9053
|
-
clearInterval(this.p2pTimer);
|
|
9054
|
-
this.p2pTimer = null;
|
|
9055
|
-
}
|
|
9056
|
-
}
|
|
9057
|
-
onStatusChange() {
|
|
9058
|
-
this.throttledReport();
|
|
9059
|
-
}
|
|
9060
|
-
throttledReport() {
|
|
9061
|
-
const now = Date.now();
|
|
9062
|
-
const elapsed = now - this.lastStatusSentAt;
|
|
9063
|
-
if (elapsed >= 5e3) {
|
|
9064
|
-
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Throttled report failed: ${e?.message}`));
|
|
9065
|
-
} else if (!this.statusPendingThrottle) {
|
|
9066
|
-
this.statusPendingThrottle = true;
|
|
9067
|
-
setTimeout(() => {
|
|
9068
|
-
this.statusPendingThrottle = false;
|
|
9069
|
-
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Deferred report failed: ${e?.message}`));
|
|
9070
|
-
}, 5e3 - elapsed);
|
|
9071
|
-
}
|
|
9072
|
-
}
|
|
9073
|
-
emitStatusEvent(event) {
|
|
9074
|
-
LOG.info("StatusEvent", `${event.event} (${event.providerType || event.ideType || ""})`);
|
|
9075
|
-
this.deps.serverConn?.sendMessage("status_event", event);
|
|
9076
|
-
}
|
|
9077
|
-
removeAgentTracking(_key) {
|
|
9078
|
-
}
|
|
9079
|
-
// (agent-stream polling backward compat)
|
|
9080
|
-
updateAgentStreams(_ideType, _streams) {
|
|
9081
|
-
}
|
|
9082
|
-
/** Reset P2P dedup hash — forces next send to transmit even if content unchanged */
|
|
9083
|
-
resetP2PHash() {
|
|
9084
|
-
this.lastP2PStatusHash = "";
|
|
9085
|
-
}
|
|
9086
|
-
// ─── Core ────────────────────────────────────────
|
|
9087
|
-
ts() {
|
|
9088
|
-
return (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
9089
|
-
}
|
|
9090
|
-
async sendUnifiedStatusReport(opts) {
|
|
9091
|
-
const { serverConn, p2p } = this.deps;
|
|
9092
|
-
if (!serverConn?.isConnected()) return;
|
|
9093
|
-
this.lastStatusSentAt = Date.now();
|
|
9094
|
-
const now = this.lastStatusSentAt;
|
|
9095
|
-
const target = opts?.p2pOnly ? "P2P" : "P2P+Server";
|
|
9096
|
-
const allStates = this.deps.instanceManager.collectAllStates();
|
|
9097
|
-
const ideStates = allStates.filter((s15) => s15.category === "ide");
|
|
9098
|
-
const cliStates = allStates.filter((s15) => s15.category === "cli");
|
|
9099
|
-
const acpStates = allStates.filter((s15) => s15.category === "acp");
|
|
9100
|
-
const ideSummary = ideStates.map((s15) => {
|
|
9101
|
-
const msgs = s15.activeChat?.messages?.length || 0;
|
|
9102
|
-
const exts = s15.extensions.length;
|
|
9103
|
-
return `${s15.type}(${s15.status},${msgs}msg,${exts}ext${s15.currentModel ? ",model=" + s15.currentModel : ""})`;
|
|
9104
|
-
}).join(", ");
|
|
9105
|
-
const cliSummary = cliStates.map((s15) => `${s15.type}(${s15.status})`).join(", ");
|
|
9106
|
-
const acpSummary = acpStates.map((s15) => `${s15.type}(${s15.status})`).join(", ");
|
|
9107
|
-
const logLevel = opts?.p2pOnly ? "debug" : "info";
|
|
9108
|
-
const baseSummary = `IDE: ${ideStates.length} [${ideSummary}] CLI: ${cliStates.length} [${cliSummary}] ACP: ${acpStates.length} [${acpSummary}]`;
|
|
9109
|
-
const summaryChanged = baseSummary !== this.lastStatusSummary;
|
|
9110
|
-
if (summaryChanged) {
|
|
9111
|
-
this.lastStatusSummary = baseSummary;
|
|
9112
|
-
if (logLevel === "debug") {
|
|
9113
|
-
LOG.debug("StatusReport", `\u2192${target} ${baseSummary}`);
|
|
9114
|
-
} else {
|
|
9115
|
-
LOG.info("StatusReport", `\u2192${target} ${baseSummary}`);
|
|
9116
|
-
}
|
|
9117
|
-
}
|
|
9118
|
-
const sessions = buildSessionEntries(
|
|
9119
|
-
allStates,
|
|
9120
|
-
this.deps.cdpManagers
|
|
9121
|
-
);
|
|
9122
|
-
const payload = {
|
|
9123
|
-
...buildStatusSnapshot({
|
|
9124
|
-
allStates,
|
|
9125
|
-
cdpManagers: this.deps.cdpManagers,
|
|
9126
|
-
providerLoader: this.deps.providerLoader,
|
|
9127
|
-
detectedIdes: this.deps.detectedIdes || [],
|
|
9128
|
-
instanceId: this.deps.instanceId,
|
|
9129
|
-
version: this.deps.daemonVersion || "unknown",
|
|
9130
|
-
daemonMode: true,
|
|
9131
|
-
timestamp: now,
|
|
9132
|
-
p2p: {
|
|
9133
|
-
available: p2p?.isAvailable || false,
|
|
9134
|
-
state: p2p?.connectionState || "unavailable",
|
|
9135
|
-
peers: p2p?.connectedPeerCount || 0,
|
|
9136
|
-
screenshotActive: p2p?.screenshotActive || false
|
|
9137
|
-
}
|
|
9138
|
-
}),
|
|
9139
|
-
screenshotUsage: this.deps.getScreenshotUsage?.() || null,
|
|
9140
|
-
connectedExtensions: []
|
|
9141
|
-
};
|
|
9142
|
-
const p2pSent = this.sendP2PPayload(payload);
|
|
9143
|
-
if (p2pSent) {
|
|
9144
|
-
LOG.debug("P2P", `sent (${JSON.stringify(payload).length} bytes)`);
|
|
9145
|
-
}
|
|
9146
|
-
if (opts?.p2pOnly) return;
|
|
9147
|
-
const wsPayload = {
|
|
9148
|
-
daemonMode: true,
|
|
9149
|
-
sessions: sessions.map((session) => ({
|
|
9150
|
-
id: session.id,
|
|
9151
|
-
parentId: session.parentId,
|
|
9152
|
-
providerType: session.providerType,
|
|
9153
|
-
providerName: session.providerName,
|
|
9154
|
-
kind: session.kind,
|
|
9155
|
-
transport: session.transport,
|
|
9156
|
-
status: session.status,
|
|
9157
|
-
workspace: session.workspace,
|
|
9158
|
-
title: session.title,
|
|
9159
|
-
cdpConnected: session.cdpConnected,
|
|
9160
|
-
currentModel: session.currentModel,
|
|
9161
|
-
currentPlan: session.currentPlan,
|
|
9162
|
-
currentAutoApprove: session.currentAutoApprove
|
|
9163
|
-
})),
|
|
9164
|
-
p2p: payload.p2p,
|
|
9165
|
-
timestamp: now
|
|
9166
|
-
};
|
|
9167
|
-
serverConn.sendMessage("status_report", wsPayload);
|
|
9168
|
-
LOG.debug("Server", `sent status_report (${JSON.stringify(wsPayload).length} bytes)`);
|
|
9169
|
-
}
|
|
9170
|
-
// ─── P2P ─────────────────────────────────────────
|
|
9171
|
-
sendP2PPayload(payload) {
|
|
9172
|
-
const { timestamp: _ts, system: _sys, ...hashTarget } = payload;
|
|
9173
|
-
if (hashTarget.machine) {
|
|
9174
|
-
const { freeMem: _f, availableMem: _a2, loadavg: _l2, uptime: _u, ...stableMachine } = hashTarget.machine;
|
|
9175
|
-
hashTarget.machine = stableMachine;
|
|
9176
|
-
}
|
|
9177
|
-
const h = this.simpleHash(JSON.stringify(hashTarget));
|
|
9178
|
-
if (h !== this.lastP2PStatusHash) {
|
|
9179
|
-
this.lastP2PStatusHash = h;
|
|
9180
|
-
this.deps.p2p?.sendStatus(payload);
|
|
9181
|
-
return true;
|
|
9182
|
-
}
|
|
9183
|
-
return false;
|
|
9184
|
-
}
|
|
9185
|
-
simpleHash(s15) {
|
|
9186
|
-
let h = 2166136261;
|
|
9187
|
-
for (let i = 0; i < s15.length; i++) {
|
|
9188
|
-
h ^= s15.charCodeAt(i);
|
|
9189
|
-
h = h * 16777619 >>> 0;
|
|
9190
|
-
}
|
|
9191
|
-
return h.toString(36);
|
|
9192
|
-
}
|
|
9193
|
-
};
|
|
9194
|
-
}
|
|
9195
|
-
});
|
|
9196
|
-
|
|
9197
9125
|
// ../../oss/packages/daemon-core/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts
|
|
9198
9126
|
function isModuleNotFoundError(error48, ref) {
|
|
9199
9127
|
if (!(error48 instanceof Error)) return false;
|
|
@@ -10021,7 +9949,7 @@ function Ec(s15, t) {
|
|
|
10021
9949
|
function Tc(s15) {
|
|
10022
9950
|
return s15.keyCode === 16 || s15.keyCode === 17 || s15.keyCode === 18;
|
|
10023
9951
|
}
|
|
10024
|
-
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,
|
|
9952
|
+
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;
|
|
10025
9953
|
var init_xterm = __esm({
|
|
10026
9954
|
"../../oss/node_modules/@xterm/xterm/lib/xterm.mjs"() {
|
|
10027
9955
|
"use strict";
|
|
@@ -12069,7 +11997,7 @@ ${h.join(`
|
|
|
12069
11997
|
this._handler && (this._node.removeEventListener(this._type, this._handler, this._options), this._node = null, this._handler = null);
|
|
12070
11998
|
}
|
|
12071
11999
|
};
|
|
12072
|
-
|
|
12000
|
+
os10 = function(t, e, i, r) {
|
|
12073
12001
|
let n = i;
|
|
12074
12002
|
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);
|
|
12075
12003
|
};
|
|
@@ -12497,7 +12425,7 @@ ${h.join(`
|
|
|
12497
12425
|
Uo = 11;
|
|
12498
12426
|
Or = class extends lt {
|
|
12499
12427
|
constructor(t) {
|
|
12500
|
-
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(
|
|
12428
|
+
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());
|
|
12501
12429
|
}
|
|
12502
12430
|
_arrowPointerDown(t) {
|
|
12503
12431
|
if (!t.target || !(t.target instanceof Element)) return;
|
|
@@ -18450,6 +18378,12 @@ var init_xterm_backend = __esm({
|
|
|
18450
18378
|
});
|
|
18451
18379
|
|
|
18452
18380
|
// ../../oss/packages/daemon-core/src/cli-adapters/terminal-screen.ts
|
|
18381
|
+
function getTerminalBackendRuntimeStatus() {
|
|
18382
|
+
const preference = resolveTerminalBackendPreference();
|
|
18383
|
+
const ghosttyAvailable = isGhosttyVtBackendAvailable();
|
|
18384
|
+
const backend = preference === "ghostty-vt" || preference === "auto" && ghosttyAvailable ? "ghostty-vt" : "xterm";
|
|
18385
|
+
return { backend, preference, ghosttyAvailable };
|
|
18386
|
+
}
|
|
18453
18387
|
function createTerminalBackend(options, preference) {
|
|
18454
18388
|
const ghosttyAvailable = isGhosttyVtBackendAvailable();
|
|
18455
18389
|
if (preference === "ghostty-vt") {
|
|
@@ -18528,6 +18462,388 @@ var init_terminal_screen = __esm({
|
|
|
18528
18462
|
}
|
|
18529
18463
|
});
|
|
18530
18464
|
|
|
18465
|
+
// ../../oss/packages/daemon-core/src/status/snapshot.ts
|
|
18466
|
+
function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
|
|
18467
|
+
return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
|
|
18468
|
+
id: ide.id,
|
|
18469
|
+
type: ide.id,
|
|
18470
|
+
name: ide.displayName || ide.name || ide.id,
|
|
18471
|
+
running: isCdpConnected(cdpManagers, ide.id),
|
|
18472
|
+
...ide.path ? { path: ide.path } : {}
|
|
18473
|
+
}));
|
|
18474
|
+
}
|
|
18475
|
+
function buildAvailableProviders(providerLoader) {
|
|
18476
|
+
return providerLoader.getAll().map((provider) => ({
|
|
18477
|
+
type: provider.type,
|
|
18478
|
+
name: provider.displayName || provider.type,
|
|
18479
|
+
displayName: provider.displayName || provider.type,
|
|
18480
|
+
icon: provider.icon || "\u{1F4BB}",
|
|
18481
|
+
category: provider.category
|
|
18482
|
+
}));
|
|
18483
|
+
}
|
|
18484
|
+
function parseMessageTime(value) {
|
|
18485
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
18486
|
+
if (typeof value === "string") {
|
|
18487
|
+
const parsed = Date.parse(value);
|
|
18488
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
18489
|
+
}
|
|
18490
|
+
return 0;
|
|
18491
|
+
}
|
|
18492
|
+
function getSessionMessageUpdatedAt(session) {
|
|
18493
|
+
const lastMessage = session.activeChat?.messages?.at?.(-1);
|
|
18494
|
+
if (!lastMessage) return 0;
|
|
18495
|
+
return parseMessageTime(lastMessage.timestamp) || parseMessageTime(lastMessage.receivedAt) || parseMessageTime(lastMessage.createdAt) || 0;
|
|
18496
|
+
}
|
|
18497
|
+
function getSessionLastUsedAt(session) {
|
|
18498
|
+
return getSessionMessageUpdatedAt(session) || session.lastUpdated || Date.now();
|
|
18499
|
+
}
|
|
18500
|
+
function getSessionKind(session) {
|
|
18501
|
+
return session.transport === "cdp-page" || session.transport === "cdp-webview" ? "ide" : session.transport === "acp" ? "acp" : "cli";
|
|
18502
|
+
}
|
|
18503
|
+
function getLastMessageRole(session) {
|
|
18504
|
+
const role = session.activeChat?.messages?.at?.(-1)?.role;
|
|
18505
|
+
return typeof role === "string" ? role : "";
|
|
18506
|
+
}
|
|
18507
|
+
function getUnreadState(hasContentChange, status, lastUsedAt, lastSeenAt, lastRole) {
|
|
18508
|
+
if (status === "waiting_approval") {
|
|
18509
|
+
return { unread: false, inboxBucket: "needs_attention" };
|
|
18510
|
+
}
|
|
18511
|
+
if (status === "generating" || status === "starting") {
|
|
18512
|
+
return { unread: false, inboxBucket: "working" };
|
|
18513
|
+
}
|
|
18514
|
+
const unread = hasContentChange && lastUsedAt > lastSeenAt && lastRole !== "user" && lastRole !== "human";
|
|
18515
|
+
return { unread, inboxBucket: unread ? "task_complete" : "idle" };
|
|
18516
|
+
}
|
|
18517
|
+
function buildRecentSessions(sessions, recentActivity, readState) {
|
|
18518
|
+
const live = sessions.filter((session) => !session.parentId && session.status !== "stopped").map((session) => {
|
|
18519
|
+
const kind = getSessionKind(session);
|
|
18520
|
+
const recentKey = buildRecentActivityKey({
|
|
18521
|
+
kind,
|
|
18522
|
+
providerType: session.providerType,
|
|
18523
|
+
workspace: session.workspace
|
|
18524
|
+
});
|
|
18525
|
+
const lastSeenAt = readState[recentKey] || 0;
|
|
18526
|
+
const lastUsedAt = getSessionLastUsedAt(session);
|
|
18527
|
+
const { unread, inboxBucket } = getUnreadState(
|
|
18528
|
+
getSessionMessageUpdatedAt(session) > 0,
|
|
18529
|
+
session.status,
|
|
18530
|
+
lastUsedAt,
|
|
18531
|
+
lastSeenAt,
|
|
18532
|
+
getLastMessageRole(session)
|
|
18533
|
+
);
|
|
18534
|
+
return {
|
|
18535
|
+
id: session.id,
|
|
18536
|
+
recentKey,
|
|
18537
|
+
sessionId: session.id,
|
|
18538
|
+
providerType: session.providerType,
|
|
18539
|
+
providerName: session.providerName,
|
|
18540
|
+
kind,
|
|
18541
|
+
title: session.activeChat?.title || session.title || session.providerName,
|
|
18542
|
+
workspace: session.workspace,
|
|
18543
|
+
currentModel: session.currentModel,
|
|
18544
|
+
status: session.status,
|
|
18545
|
+
lastUsedAt,
|
|
18546
|
+
unread,
|
|
18547
|
+
lastSeenAt,
|
|
18548
|
+
inboxBucket
|
|
18549
|
+
};
|
|
18550
|
+
});
|
|
18551
|
+
const seen = new Set(live.map((item) => `${item.kind}:${item.providerType}:${item.workspace || ""}`));
|
|
18552
|
+
const persisted = recentActivity.filter((item) => !seen.has(`${item.kind}:${item.providerType}:${item.workspace || ""}`)).map((item) => {
|
|
18553
|
+
const lastSeenAt = readState[item.id] || 0;
|
|
18554
|
+
const unread = item.lastUsedAt > lastSeenAt;
|
|
18555
|
+
return {
|
|
18556
|
+
id: item.id,
|
|
18557
|
+
recentKey: item.id,
|
|
18558
|
+
sessionId: item.sessionId || null,
|
|
18559
|
+
providerType: item.providerType,
|
|
18560
|
+
providerName: item.providerName,
|
|
18561
|
+
kind: item.kind,
|
|
18562
|
+
title: item.title || item.providerName,
|
|
18563
|
+
workspace: item.workspace,
|
|
18564
|
+
currentModel: item.currentModel,
|
|
18565
|
+
lastUsedAt: item.lastUsedAt,
|
|
18566
|
+
unread,
|
|
18567
|
+
lastSeenAt,
|
|
18568
|
+
inboxBucket: unread ? "task_complete" : "idle"
|
|
18569
|
+
};
|
|
18570
|
+
});
|
|
18571
|
+
return [...live, ...persisted].sort((a, b2) => b2.lastUsedAt - a.lastUsedAt).slice(0, 12);
|
|
18572
|
+
}
|
|
18573
|
+
function buildStatusSnapshot(options) {
|
|
18574
|
+
const cfg = loadConfig();
|
|
18575
|
+
const wsState = getWorkspaceState(cfg);
|
|
18576
|
+
const memSnap = getHostMemorySnapshot();
|
|
18577
|
+
const recentActivity = getRecentActivity(cfg, 20);
|
|
18578
|
+
const sessions = buildSessionEntries(
|
|
18579
|
+
options.allStates,
|
|
18580
|
+
options.cdpManagers
|
|
18581
|
+
);
|
|
18582
|
+
const readState = cfg.recentSessionReads || {};
|
|
18583
|
+
for (const session of sessions) {
|
|
18584
|
+
const kind = getSessionKind(session);
|
|
18585
|
+
const recentKey = buildRecentActivityKey({
|
|
18586
|
+
kind,
|
|
18587
|
+
providerType: session.providerType,
|
|
18588
|
+
workspace: session.workspace
|
|
18589
|
+
});
|
|
18590
|
+
const lastSeenAt = getRecentSessionSeenAt(cfg, recentKey);
|
|
18591
|
+
const lastUsedAt = getSessionLastUsedAt(session);
|
|
18592
|
+
const { unread, inboxBucket } = getUnreadState(
|
|
18593
|
+
getSessionMessageUpdatedAt(session) > 0,
|
|
18594
|
+
session.status,
|
|
18595
|
+
lastUsedAt,
|
|
18596
|
+
lastSeenAt,
|
|
18597
|
+
getLastMessageRole(session)
|
|
18598
|
+
);
|
|
18599
|
+
session.recentKey = recentKey;
|
|
18600
|
+
session.lastSeenAt = lastSeenAt;
|
|
18601
|
+
session.unread = unread;
|
|
18602
|
+
session.inboxBucket = inboxBucket;
|
|
18603
|
+
}
|
|
18604
|
+
const terminalBackend = getTerminalBackendRuntimeStatus();
|
|
18605
|
+
return {
|
|
18606
|
+
instanceId: options.instanceId,
|
|
18607
|
+
version: options.version,
|
|
18608
|
+
daemonMode: options.daemonMode,
|
|
18609
|
+
machine: {
|
|
18610
|
+
hostname: os11.hostname(),
|
|
18611
|
+
platform: os11.platform(),
|
|
18612
|
+
arch: os11.arch(),
|
|
18613
|
+
cpus: os11.cpus().length,
|
|
18614
|
+
totalMem: memSnap.totalMem,
|
|
18615
|
+
freeMem: memSnap.freeMem,
|
|
18616
|
+
availableMem: memSnap.availableMem,
|
|
18617
|
+
loadavg: os11.loadavg(),
|
|
18618
|
+
uptime: os11.uptime(),
|
|
18619
|
+
release: os11.release()
|
|
18620
|
+
},
|
|
18621
|
+
machineNickname: options.machineNickname ?? cfg.machineNickname ?? null,
|
|
18622
|
+
timestamp: options.timestamp ?? Date.now(),
|
|
18623
|
+
detectedIdes: buildDetectedIdeInfos(options.detectedIdes, options.cdpManagers),
|
|
18624
|
+
...options.p2p ? { p2p: options.p2p } : {},
|
|
18625
|
+
sessions,
|
|
18626
|
+
workspaces: wsState.workspaces,
|
|
18627
|
+
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
18628
|
+
defaultWorkspacePath: wsState.defaultWorkspacePath,
|
|
18629
|
+
workspaceActivity: getWorkspaceActivity(cfg, 15),
|
|
18630
|
+
recentSessions: buildRecentSessions(sessions, recentActivity, readState),
|
|
18631
|
+
terminalBackend,
|
|
18632
|
+
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
18633
|
+
};
|
|
18634
|
+
}
|
|
18635
|
+
var os11;
|
|
18636
|
+
var init_snapshot = __esm({
|
|
18637
|
+
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
18638
|
+
"use strict";
|
|
18639
|
+
os11 = __toESM(require("os"));
|
|
18640
|
+
init_config();
|
|
18641
|
+
init_recent_activity();
|
|
18642
|
+
init_workspaces();
|
|
18643
|
+
init_workspace_activity();
|
|
18644
|
+
init_host_memory();
|
|
18645
|
+
init_terminal_screen();
|
|
18646
|
+
init_builders();
|
|
18647
|
+
}
|
|
18648
|
+
});
|
|
18649
|
+
|
|
18650
|
+
// ../../oss/packages/daemon-core/src/status/reporter.ts
|
|
18651
|
+
var DaemonStatusReporter;
|
|
18652
|
+
var init_reporter = __esm({
|
|
18653
|
+
"../../oss/packages/daemon-core/src/status/reporter.ts"() {
|
|
18654
|
+
"use strict";
|
|
18655
|
+
init_logger();
|
|
18656
|
+
init_builders();
|
|
18657
|
+
init_snapshot();
|
|
18658
|
+
DaemonStatusReporter = class {
|
|
18659
|
+
deps;
|
|
18660
|
+
log;
|
|
18661
|
+
lastStatusSentAt = 0;
|
|
18662
|
+
statusPendingThrottle = false;
|
|
18663
|
+
lastP2PStatusHash = "";
|
|
18664
|
+
lastStatusSummary = "";
|
|
18665
|
+
statusTimer = null;
|
|
18666
|
+
p2pTimer = null;
|
|
18667
|
+
constructor(deps, opts) {
|
|
18668
|
+
this.deps = deps;
|
|
18669
|
+
this.log = opts?.logFn || LOG.forComponent("Status").asLogFn();
|
|
18670
|
+
}
|
|
18671
|
+
// ─── Lifecycle ───────────────────────────────────
|
|
18672
|
+
startReporting() {
|
|
18673
|
+
setTimeout(() => {
|
|
18674
|
+
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Initial report failed: ${e?.message}`));
|
|
18675
|
+
}, 2e3);
|
|
18676
|
+
const scheduleServerReport = () => {
|
|
18677
|
+
this.statusTimer = setTimeout(() => {
|
|
18678
|
+
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Periodic report failed: ${e?.message}`));
|
|
18679
|
+
scheduleServerReport();
|
|
18680
|
+
}, 3e4);
|
|
18681
|
+
};
|
|
18682
|
+
scheduleServerReport();
|
|
18683
|
+
this.p2pTimer = setInterval(() => {
|
|
18684
|
+
if (this.deps.p2p?.isConnected) {
|
|
18685
|
+
this.sendUnifiedStatusReport({ p2pOnly: true }).catch((e) => LOG.warn("Status", `P2P status send failed: ${e?.message}`));
|
|
18686
|
+
}
|
|
18687
|
+
}, 5e3);
|
|
18688
|
+
}
|
|
18689
|
+
stopReporting() {
|
|
18690
|
+
if (this.statusTimer) {
|
|
18691
|
+
clearTimeout(this.statusTimer);
|
|
18692
|
+
this.statusTimer = null;
|
|
18693
|
+
}
|
|
18694
|
+
if (this.p2pTimer) {
|
|
18695
|
+
clearInterval(this.p2pTimer);
|
|
18696
|
+
this.p2pTimer = null;
|
|
18697
|
+
}
|
|
18698
|
+
}
|
|
18699
|
+
onStatusChange() {
|
|
18700
|
+
this.throttledReport();
|
|
18701
|
+
}
|
|
18702
|
+
throttledReport() {
|
|
18703
|
+
const now = Date.now();
|
|
18704
|
+
const elapsed = now - this.lastStatusSentAt;
|
|
18705
|
+
if (elapsed >= 5e3) {
|
|
18706
|
+
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Throttled report failed: ${e?.message}`));
|
|
18707
|
+
} else if (!this.statusPendingThrottle) {
|
|
18708
|
+
this.statusPendingThrottle = true;
|
|
18709
|
+
setTimeout(() => {
|
|
18710
|
+
this.statusPendingThrottle = false;
|
|
18711
|
+
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Deferred report failed: ${e?.message}`));
|
|
18712
|
+
}, 5e3 - elapsed);
|
|
18713
|
+
}
|
|
18714
|
+
}
|
|
18715
|
+
emitStatusEvent(event) {
|
|
18716
|
+
LOG.info("StatusEvent", `${event.event} (${event.providerType || event.ideType || ""})`);
|
|
18717
|
+
this.deps.serverConn?.sendMessage("status_event", event);
|
|
18718
|
+
}
|
|
18719
|
+
removeAgentTracking(_key) {
|
|
18720
|
+
}
|
|
18721
|
+
// (agent-stream polling backward compat)
|
|
18722
|
+
updateAgentStreams(_ideType, _streams) {
|
|
18723
|
+
}
|
|
18724
|
+
/** Reset P2P dedup hash — forces next send to transmit even if content unchanged */
|
|
18725
|
+
resetP2PHash() {
|
|
18726
|
+
this.lastP2PStatusHash = "";
|
|
18727
|
+
}
|
|
18728
|
+
// ─── Core ────────────────────────────────────────
|
|
18729
|
+
ts() {
|
|
18730
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
18731
|
+
}
|
|
18732
|
+
async sendUnifiedStatusReport(opts) {
|
|
18733
|
+
const { serverConn, p2p } = this.deps;
|
|
18734
|
+
if (!serverConn?.isConnected()) return;
|
|
18735
|
+
this.lastStatusSentAt = Date.now();
|
|
18736
|
+
const now = this.lastStatusSentAt;
|
|
18737
|
+
const target = opts?.p2pOnly ? "P2P" : "P2P+Server";
|
|
18738
|
+
const allStates = this.deps.instanceManager.collectAllStates();
|
|
18739
|
+
const ideStates = allStates.filter((s15) => s15.category === "ide");
|
|
18740
|
+
const cliStates = allStates.filter((s15) => s15.category === "cli");
|
|
18741
|
+
const acpStates = allStates.filter((s15) => s15.category === "acp");
|
|
18742
|
+
const ideSummary = ideStates.map((s15) => {
|
|
18743
|
+
const msgs = s15.activeChat?.messages?.length || 0;
|
|
18744
|
+
const exts = s15.extensions.length;
|
|
18745
|
+
return `${s15.type}(${s15.status},${msgs}msg,${exts}ext${s15.currentModel ? ",model=" + s15.currentModel : ""})`;
|
|
18746
|
+
}).join(", ");
|
|
18747
|
+
const cliSummary = cliStates.map((s15) => `${s15.type}(${s15.status})`).join(", ");
|
|
18748
|
+
const acpSummary = acpStates.map((s15) => `${s15.type}(${s15.status})`).join(", ");
|
|
18749
|
+
const logLevel = opts?.p2pOnly ? "debug" : "info";
|
|
18750
|
+
const baseSummary = `IDE: ${ideStates.length} [${ideSummary}] CLI: ${cliStates.length} [${cliSummary}] ACP: ${acpStates.length} [${acpSummary}]`;
|
|
18751
|
+
const summaryChanged = baseSummary !== this.lastStatusSummary;
|
|
18752
|
+
if (summaryChanged) {
|
|
18753
|
+
this.lastStatusSummary = baseSummary;
|
|
18754
|
+
if (logLevel === "debug") {
|
|
18755
|
+
LOG.debug("StatusReport", `\u2192${target} ${baseSummary}`);
|
|
18756
|
+
} else {
|
|
18757
|
+
LOG.info("StatusReport", `\u2192${target} ${baseSummary}`);
|
|
18758
|
+
}
|
|
18759
|
+
}
|
|
18760
|
+
const sessions = buildSessionEntries(
|
|
18761
|
+
allStates,
|
|
18762
|
+
this.deps.cdpManagers
|
|
18763
|
+
);
|
|
18764
|
+
const payload = {
|
|
18765
|
+
...buildStatusSnapshot({
|
|
18766
|
+
allStates,
|
|
18767
|
+
cdpManagers: this.deps.cdpManagers,
|
|
18768
|
+
providerLoader: this.deps.providerLoader,
|
|
18769
|
+
detectedIdes: this.deps.detectedIdes || [],
|
|
18770
|
+
instanceId: this.deps.instanceId,
|
|
18771
|
+
version: this.deps.daemonVersion || "unknown",
|
|
18772
|
+
daemonMode: true,
|
|
18773
|
+
timestamp: now,
|
|
18774
|
+
p2p: {
|
|
18775
|
+
available: p2p?.isAvailable || false,
|
|
18776
|
+
state: p2p?.connectionState || "unavailable",
|
|
18777
|
+
peers: p2p?.connectedPeerCount || 0,
|
|
18778
|
+
screenshotActive: p2p?.screenshotActive || false
|
|
18779
|
+
}
|
|
18780
|
+
}),
|
|
18781
|
+
screenshotUsage: this.deps.getScreenshotUsage?.() || null,
|
|
18782
|
+
connectedExtensions: []
|
|
18783
|
+
};
|
|
18784
|
+
const p2pSent = this.sendP2PPayload(payload);
|
|
18785
|
+
if (p2pSent) {
|
|
18786
|
+
LOG.debug("P2P", `sent (${JSON.stringify(payload).length} bytes)`);
|
|
18787
|
+
}
|
|
18788
|
+
if (opts?.p2pOnly) return;
|
|
18789
|
+
const wsPayload = {
|
|
18790
|
+
daemonMode: true,
|
|
18791
|
+
sessions: sessions.map((session) => ({
|
|
18792
|
+
id: session.id,
|
|
18793
|
+
parentId: session.parentId,
|
|
18794
|
+
providerType: session.providerType,
|
|
18795
|
+
providerName: session.providerName,
|
|
18796
|
+
kind: session.kind,
|
|
18797
|
+
transport: session.transport,
|
|
18798
|
+
status: session.status,
|
|
18799
|
+
workspace: session.workspace,
|
|
18800
|
+
title: session.title,
|
|
18801
|
+
cdpConnected: session.cdpConnected,
|
|
18802
|
+
currentModel: session.currentModel,
|
|
18803
|
+
currentPlan: session.currentPlan,
|
|
18804
|
+
currentAutoApprove: session.currentAutoApprove,
|
|
18805
|
+
recentKey: session.recentKey,
|
|
18806
|
+
unread: session.unread,
|
|
18807
|
+
lastSeenAt: session.lastSeenAt,
|
|
18808
|
+
inboxBucket: session.inboxBucket,
|
|
18809
|
+
controlValues: session.controlValues,
|
|
18810
|
+
providerControls: session.providerControls,
|
|
18811
|
+
acpConfigOptions: session.acpConfigOptions,
|
|
18812
|
+
acpModes: session.acpModes
|
|
18813
|
+
})),
|
|
18814
|
+
p2p: payload.p2p,
|
|
18815
|
+
timestamp: now
|
|
18816
|
+
};
|
|
18817
|
+
serverConn.sendMessage("status_report", wsPayload);
|
|
18818
|
+
LOG.debug("Server", `sent status_report (${JSON.stringify(wsPayload).length} bytes)`);
|
|
18819
|
+
}
|
|
18820
|
+
// ─── P2P ─────────────────────────────────────────
|
|
18821
|
+
sendP2PPayload(payload) {
|
|
18822
|
+
const { timestamp: _ts, system: _sys, ...hashTarget } = payload;
|
|
18823
|
+
if (hashTarget.machine) {
|
|
18824
|
+
const { freeMem: _f, availableMem: _a2, loadavg: _l2, uptime: _u, ...stableMachine } = hashTarget.machine;
|
|
18825
|
+
hashTarget.machine = stableMachine;
|
|
18826
|
+
}
|
|
18827
|
+
const h = this.simpleHash(JSON.stringify(hashTarget));
|
|
18828
|
+
if (h !== this.lastP2PStatusHash) {
|
|
18829
|
+
this.lastP2PStatusHash = h;
|
|
18830
|
+
this.deps.p2p?.sendStatus(payload);
|
|
18831
|
+
return true;
|
|
18832
|
+
}
|
|
18833
|
+
return false;
|
|
18834
|
+
}
|
|
18835
|
+
simpleHash(s15) {
|
|
18836
|
+
let h = 2166136261;
|
|
18837
|
+
for (let i = 0; i < s15.length; i++) {
|
|
18838
|
+
h ^= s15.charCodeAt(i);
|
|
18839
|
+
h = h * 16777619 >>> 0;
|
|
18840
|
+
}
|
|
18841
|
+
return h.toString(36);
|
|
18842
|
+
}
|
|
18843
|
+
};
|
|
18844
|
+
}
|
|
18845
|
+
});
|
|
18846
|
+
|
|
18531
18847
|
// ../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts
|
|
18532
18848
|
var os12, pty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
18533
18849
|
var init_pty_transport = __esm({
|
|
@@ -18607,14 +18923,14 @@ function findBinary(name) {
|
|
|
18607
18923
|
}
|
|
18608
18924
|
}
|
|
18609
18925
|
function isScriptBinary(binaryPath) {
|
|
18610
|
-
if (!
|
|
18926
|
+
if (!path10.isAbsolute(binaryPath)) return false;
|
|
18611
18927
|
try {
|
|
18612
|
-
const
|
|
18613
|
-
const resolved =
|
|
18928
|
+
const fs16 = require("fs");
|
|
18929
|
+
const resolved = fs16.realpathSync(binaryPath);
|
|
18614
18930
|
const head = Buffer.alloc(8);
|
|
18615
|
-
const fd =
|
|
18616
|
-
|
|
18617
|
-
|
|
18931
|
+
const fd = fs16.openSync(resolved, "r");
|
|
18932
|
+
fs16.readSync(fd, head, 0, 8, 0);
|
|
18933
|
+
fs16.closeSync(fd);
|
|
18618
18934
|
let i = 0;
|
|
18619
18935
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
18620
18936
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -18623,14 +18939,14 @@ function isScriptBinary(binaryPath) {
|
|
|
18623
18939
|
}
|
|
18624
18940
|
}
|
|
18625
18941
|
function looksLikeMachOOrElf(filePath) {
|
|
18626
|
-
if (!
|
|
18942
|
+
if (!path10.isAbsolute(filePath)) return false;
|
|
18627
18943
|
try {
|
|
18628
|
-
const
|
|
18629
|
-
const resolved =
|
|
18944
|
+
const fs16 = require("fs");
|
|
18945
|
+
const resolved = fs16.realpathSync(filePath);
|
|
18630
18946
|
const buf = Buffer.alloc(8);
|
|
18631
|
-
const fd =
|
|
18632
|
-
|
|
18633
|
-
|
|
18947
|
+
const fd = fs16.openSync(resolved, "r");
|
|
18948
|
+
fs16.readSync(fd, buf, 0, 8, 0);
|
|
18949
|
+
fs16.closeSync(fd);
|
|
18634
18950
|
let i = 0;
|
|
18635
18951
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
18636
18952
|
const b2 = buf.subarray(i);
|
|
@@ -18737,12 +19053,12 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
18737
19053
|
}
|
|
18738
19054
|
};
|
|
18739
19055
|
}
|
|
18740
|
-
var os13,
|
|
19056
|
+
var os13, path10, import_child_process5, pty2, ProviderCliAdapter;
|
|
18741
19057
|
var init_provider_cli_adapter = __esm({
|
|
18742
19058
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
|
|
18743
19059
|
"use strict";
|
|
18744
19060
|
os13 = __toESM(require("os"));
|
|
18745
|
-
|
|
19061
|
+
path10 = __toESM(require("path"));
|
|
18746
19062
|
import_child_process5 = require("child_process");
|
|
18747
19063
|
init_logger();
|
|
18748
19064
|
init_terminal_screen();
|
|
@@ -18751,14 +19067,14 @@ var init_provider_cli_adapter = __esm({
|
|
|
18751
19067
|
pty2 = require("node-pty");
|
|
18752
19068
|
if (os13.platform() !== "win32") {
|
|
18753
19069
|
try {
|
|
18754
|
-
const
|
|
18755
|
-
const ptyDir =
|
|
19070
|
+
const fs16 = require("fs");
|
|
19071
|
+
const ptyDir = path10.resolve(path10.dirname(require.resolve("node-pty")), "..");
|
|
18756
19072
|
const platformArch = `${os13.platform()}-${os13.arch()}`;
|
|
18757
|
-
const helper =
|
|
18758
|
-
if (
|
|
18759
|
-
const stat4 =
|
|
19073
|
+
const helper = path10.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
19074
|
+
if (fs16.existsSync(helper)) {
|
|
19075
|
+
const stat4 = fs16.statSync(helper);
|
|
18760
19076
|
if (!(stat4.mode & 73)) {
|
|
18761
|
-
|
|
19077
|
+
fs16.chmodSync(helper, stat4.mode | 493);
|
|
18762
19078
|
LOG.info("CLI", "[node-pty] Fixed spawn-helper permissions");
|
|
18763
19079
|
}
|
|
18764
19080
|
}
|
|
@@ -18943,7 +19259,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
18943
19259
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
18944
19260
|
let shellCmd;
|
|
18945
19261
|
let shellArgs;
|
|
18946
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
19262
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
18947
19263
|
const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
|
|
18948
19264
|
if (useShell) {
|
|
18949
19265
|
if (!spawnConfig.shell && !isWin) {
|
|
@@ -19368,7 +19684,7 @@ ${data.message || ""}`.trim();
|
|
|
19368
19684
|
if (this.startupParseGate) {
|
|
19369
19685
|
const deadline = Date.now() + 1e4;
|
|
19370
19686
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
19371
|
-
await new Promise((
|
|
19687
|
+
await new Promise((resolve13) => setTimeout(resolve13, 50));
|
|
19372
19688
|
}
|
|
19373
19689
|
}
|
|
19374
19690
|
if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
|
|
@@ -19536,17 +19852,17 @@ ${data.message || ""}`.trim();
|
|
|
19536
19852
|
}
|
|
19537
19853
|
}
|
|
19538
19854
|
waitForStopped(timeoutMs) {
|
|
19539
|
-
return new Promise((
|
|
19855
|
+
return new Promise((resolve13) => {
|
|
19540
19856
|
const startedAt = Date.now();
|
|
19541
19857
|
const timer = setInterval(() => {
|
|
19542
19858
|
if (!this.ptyProcess || this.currentStatus === "stopped") {
|
|
19543
19859
|
clearInterval(timer);
|
|
19544
|
-
|
|
19860
|
+
resolve13(true);
|
|
19545
19861
|
return;
|
|
19546
19862
|
}
|
|
19547
19863
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
19548
19864
|
clearInterval(timer);
|
|
19549
|
-
|
|
19865
|
+
resolve13(false);
|
|
19550
19866
|
}
|
|
19551
19867
|
}, 100);
|
|
19552
19868
|
});
|
|
@@ -19833,7 +20149,10 @@ var init_cli_provider_instance = __esm({
|
|
|
19833
20149
|
writeOwner: runtime.writeOwner || null,
|
|
19834
20150
|
attachedClients: runtime.attachedClients || []
|
|
19835
20151
|
} : void 0,
|
|
19836
|
-
resume: this.provider.resume
|
|
20152
|
+
resume: this.provider.resume,
|
|
20153
|
+
controlValues: void 0,
|
|
20154
|
+
// CLI controls not yet wired from stream
|
|
20155
|
+
providerControls: this.provider.controls
|
|
19837
20156
|
};
|
|
19838
20157
|
}
|
|
19839
20158
|
onEvent(event, data) {
|
|
@@ -20232,10 +20551,10 @@ function mergeDefs(...defs) {
|
|
|
20232
20551
|
function cloneDef(schema) {
|
|
20233
20552
|
return mergeDefs(schema._zod.def);
|
|
20234
20553
|
}
|
|
20235
|
-
function getElementAtPath(obj,
|
|
20236
|
-
if (!
|
|
20554
|
+
function getElementAtPath(obj, path19) {
|
|
20555
|
+
if (!path19)
|
|
20237
20556
|
return obj;
|
|
20238
|
-
return
|
|
20557
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
20239
20558
|
}
|
|
20240
20559
|
function promiseAllObject(promisesObj) {
|
|
20241
20560
|
const keys = Object.keys(promisesObj);
|
|
@@ -20547,11 +20866,11 @@ function aborted(x, startIndex = 0) {
|
|
|
20547
20866
|
}
|
|
20548
20867
|
return false;
|
|
20549
20868
|
}
|
|
20550
|
-
function prefixIssues(
|
|
20869
|
+
function prefixIssues(path19, issues) {
|
|
20551
20870
|
return issues.map((iss) => {
|
|
20552
20871
|
var _a2;
|
|
20553
20872
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
20554
|
-
iss.path.unshift(
|
|
20873
|
+
iss.path.unshift(path19);
|
|
20555
20874
|
return iss;
|
|
20556
20875
|
});
|
|
20557
20876
|
}
|
|
@@ -20794,7 +21113,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
20794
21113
|
}
|
|
20795
21114
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
20796
21115
|
const result = { errors: [] };
|
|
20797
|
-
const processError = (error49,
|
|
21116
|
+
const processError = (error49, path19 = []) => {
|
|
20798
21117
|
var _a2, _b;
|
|
20799
21118
|
for (const issue2 of error49.issues) {
|
|
20800
21119
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -20804,7 +21123,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
20804
21123
|
} else if (issue2.code === "invalid_element") {
|
|
20805
21124
|
processError({ issues: issue2.issues }, issue2.path);
|
|
20806
21125
|
} else {
|
|
20807
|
-
const fullpath = [...
|
|
21126
|
+
const fullpath = [...path19, ...issue2.path];
|
|
20808
21127
|
if (fullpath.length === 0) {
|
|
20809
21128
|
result.errors.push(mapper(issue2));
|
|
20810
21129
|
continue;
|
|
@@ -20836,8 +21155,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
20836
21155
|
}
|
|
20837
21156
|
function toDotPath(_path) {
|
|
20838
21157
|
const segs = [];
|
|
20839
|
-
const
|
|
20840
|
-
for (const seg of
|
|
21158
|
+
const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
21159
|
+
for (const seg of path19) {
|
|
20841
21160
|
if (typeof seg === "number")
|
|
20842
21161
|
segs.push(`[${seg}]`);
|
|
20843
21162
|
else if (typeof seg === "symbol")
|
|
@@ -33601,13 +33920,13 @@ function resolveRef(ref, ctx) {
|
|
|
33601
33920
|
if (!ref.startsWith("#")) {
|
|
33602
33921
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
33603
33922
|
}
|
|
33604
|
-
const
|
|
33605
|
-
if (
|
|
33923
|
+
const path19 = ref.slice(1).split("/").filter(Boolean);
|
|
33924
|
+
if (path19.length === 0) {
|
|
33606
33925
|
return ctx.rootSchema;
|
|
33607
33926
|
}
|
|
33608
33927
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
33609
|
-
if (
|
|
33610
|
-
const key =
|
|
33928
|
+
if (path19[0] === defsKey) {
|
|
33929
|
+
const key = path19[1];
|
|
33611
33930
|
if (!key || !ctx.defs[key]) {
|
|
33612
33931
|
throw new Error(`Reference not found: ${ref}`);
|
|
33613
33932
|
}
|
|
@@ -36034,8 +36353,8 @@ var init_acp = __esm({
|
|
|
36034
36353
|
this.#requestHandler = requestHandler;
|
|
36035
36354
|
this.#notificationHandler = notificationHandler;
|
|
36036
36355
|
this.#stream = stream;
|
|
36037
|
-
this.#closedPromise = new Promise((
|
|
36038
|
-
this.#abortController.signal.addEventListener("abort", () =>
|
|
36356
|
+
this.#closedPromise = new Promise((resolve13) => {
|
|
36357
|
+
this.#abortController.signal.addEventListener("abort", () => resolve13());
|
|
36039
36358
|
});
|
|
36040
36359
|
this.#receive();
|
|
36041
36360
|
}
|
|
@@ -36184,8 +36503,8 @@ var init_acp = __esm({
|
|
|
36184
36503
|
}
|
|
36185
36504
|
async sendRequest(method, params) {
|
|
36186
36505
|
const id = this.#nextRequestId++;
|
|
36187
|
-
const responsePromise = new Promise((
|
|
36188
|
-
this.#pendingResponses.set(id, { resolve:
|
|
36506
|
+
const responsePromise = new Promise((resolve13, reject) => {
|
|
36507
|
+
this.#pendingResponses.set(id, { resolve: resolve13, reject });
|
|
36189
36508
|
});
|
|
36190
36509
|
await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
|
|
36191
36510
|
return responsePromise;
|
|
@@ -36421,7 +36740,12 @@ var init_acp_provider_instance = __esm({
|
|
|
36421
36740
|
acpModes: this.availableModes,
|
|
36422
36741
|
// Error details for dashboard display
|
|
36423
36742
|
errorMessage: this.errorMessage || void 0,
|
|
36424
|
-
errorReason: this.errorReason || void 0
|
|
36743
|
+
errorReason: this.errorReason || void 0,
|
|
36744
|
+
controlValues: {
|
|
36745
|
+
...this.currentModel ? { model: this.currentModel } : {},
|
|
36746
|
+
...this.currentMode ? { mode: this.currentMode } : {}
|
|
36747
|
+
},
|
|
36748
|
+
providerControls: this.provider.controls
|
|
36425
36749
|
};
|
|
36426
36750
|
}
|
|
36427
36751
|
onEvent(event, data) {
|
|
@@ -36720,13 +37044,13 @@ var init_acp_provider_instance = __esm({
|
|
|
36720
37044
|
}
|
|
36721
37045
|
this.currentStatus = "waiting_approval";
|
|
36722
37046
|
this.detectStatusTransition();
|
|
36723
|
-
const approved = await new Promise((
|
|
36724
|
-
this.permissionResolvers.push(
|
|
37047
|
+
const approved = await new Promise((resolve13) => {
|
|
37048
|
+
this.permissionResolvers.push(resolve13);
|
|
36725
37049
|
setTimeout(() => {
|
|
36726
|
-
const idx = this.permissionResolvers.indexOf(
|
|
37050
|
+
const idx = this.permissionResolvers.indexOf(resolve13);
|
|
36727
37051
|
if (idx >= 0) {
|
|
36728
37052
|
this.permissionResolvers.splice(idx, 1);
|
|
36729
|
-
|
|
37053
|
+
resolve13(false);
|
|
36730
37054
|
}
|
|
36731
37055
|
}, 3e5);
|
|
36732
37056
|
});
|
|
@@ -37188,12 +37512,12 @@ function colorize(color, text) {
|
|
|
37188
37512
|
const fn2 = chalkApi?.[color];
|
|
37189
37513
|
return typeof fn2 === "function" ? fn2(text) : text;
|
|
37190
37514
|
}
|
|
37191
|
-
var os14,
|
|
37515
|
+
var os14, path11, crypto4, import_chalk, chalkApi, DaemonCliManager;
|
|
37192
37516
|
var init_cli_manager = __esm({
|
|
37193
37517
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
37194
37518
|
"use strict";
|
|
37195
37519
|
os14 = __toESM(require("os"));
|
|
37196
|
-
|
|
37520
|
+
path11 = __toESM(require("path"));
|
|
37197
37521
|
crypto4 = __toESM(require("crypto"));
|
|
37198
37522
|
import_chalk = __toESM(require("chalk"));
|
|
37199
37523
|
init_provider_cli_adapter();
|
|
@@ -37201,6 +37525,7 @@ var init_cli_manager = __esm({
|
|
|
37201
37525
|
init_config();
|
|
37202
37526
|
init_workspaces();
|
|
37203
37527
|
init_workspace_activity();
|
|
37528
|
+
init_recent_activity();
|
|
37204
37529
|
init_cli_provider_instance();
|
|
37205
37530
|
init_acp_provider_instance();
|
|
37206
37531
|
init_logger();
|
|
@@ -37236,6 +37561,13 @@ var init_cli_manager = __esm({
|
|
|
37236
37561
|
console.error(colorize("red", ` \u2717 Failed to save recent workspace: ${e}`));
|
|
37237
37562
|
}
|
|
37238
37563
|
}
|
|
37564
|
+
persistRecentActivity(entry) {
|
|
37565
|
+
try {
|
|
37566
|
+
saveConfig(appendRecentActivity(loadConfig(), entry));
|
|
37567
|
+
} catch (e) {
|
|
37568
|
+
console.error(colorize("red", ` \u2717 Failed to save recent activity: ${e}`));
|
|
37569
|
+
}
|
|
37570
|
+
}
|
|
37239
37571
|
getTransportFactory(runtimeId, providerType, workspace, cliArgs, attachExisting = false) {
|
|
37240
37572
|
return this.deps.createPtyTransportFactory?.({
|
|
37241
37573
|
runtimeId,
|
|
@@ -37318,7 +37650,7 @@ var init_cli_manager = __esm({
|
|
|
37318
37650
|
async startSession(cliType, workingDir, cliArgs, initialModel) {
|
|
37319
37651
|
const trimmed = (workingDir || "").trim();
|
|
37320
37652
|
if (!trimmed) throw new Error("working directory required");
|
|
37321
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) :
|
|
37653
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) : path11.resolve(trimmed);
|
|
37322
37654
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
37323
37655
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
37324
37656
|
const key = crypto4.randomUUID();
|
|
@@ -37394,6 +37726,15 @@ ${installInfo}`
|
|
|
37394
37726
|
} catch (e) {
|
|
37395
37727
|
LOG.warn("CLI", `ACP history save failed: ${e?.message}`);
|
|
37396
37728
|
}
|
|
37729
|
+
this.persistRecentActivity({
|
|
37730
|
+
kind: "acp",
|
|
37731
|
+
providerType: normalizedType,
|
|
37732
|
+
providerName: provider.displayName || provider.name || normalizedType,
|
|
37733
|
+
workspace: resolvedDir,
|
|
37734
|
+
currentModel: initialModel,
|
|
37735
|
+
sessionId,
|
|
37736
|
+
title: provider.displayName || provider.name || normalizedType
|
|
37737
|
+
});
|
|
37397
37738
|
this.deps.onStatusChange();
|
|
37398
37739
|
return;
|
|
37399
37740
|
}
|
|
@@ -37456,6 +37797,15 @@ ${installInfo}`
|
|
|
37456
37797
|
} catch (e) {
|
|
37457
37798
|
LOG.warn("CLI", `CLI history save failed: ${e?.message}`);
|
|
37458
37799
|
}
|
|
37800
|
+
this.persistRecentActivity({
|
|
37801
|
+
kind: "cli",
|
|
37802
|
+
providerType: normalizedType,
|
|
37803
|
+
providerName: provider?.displayName || provider?.name || normalizedType,
|
|
37804
|
+
workspace: resolvedDir,
|
|
37805
|
+
currentModel: initialModel,
|
|
37806
|
+
sessionId: key,
|
|
37807
|
+
title: provider?.displayName || provider?.name || normalizedType
|
|
37808
|
+
});
|
|
37459
37809
|
this.deps.onStatusChange();
|
|
37460
37810
|
}
|
|
37461
37811
|
async stopSession(key) {
|
|
@@ -37712,11 +38062,24 @@ var init_provider_adapter = __esm({
|
|
|
37712
38062
|
hasScript(name) {
|
|
37713
38063
|
return typeof this.provider.scripts?.[name] === "function";
|
|
37714
38064
|
}
|
|
38065
|
+
summarizeRaw(raw) {
|
|
38066
|
+
try {
|
|
38067
|
+
if (typeof raw === "string") return raw.replace(/\s+/g, " ").trim().slice(0, 240);
|
|
38068
|
+
if (raw == null) return String(raw);
|
|
38069
|
+
return JSON.stringify(raw).replace(/\s+/g, " ").trim().slice(0, 240);
|
|
38070
|
+
} catch {
|
|
38071
|
+
return Object.prototype.toString.call(raw);
|
|
38072
|
+
}
|
|
38073
|
+
}
|
|
38074
|
+
isTransportError(reason) {
|
|
38075
|
+
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);
|
|
38076
|
+
}
|
|
37715
38077
|
async readChat(evaluate) {
|
|
37716
38078
|
const script = this.callScript("readChat");
|
|
37717
38079
|
if (!script) return this.errorState("readChat script not available");
|
|
38080
|
+
let raw = null;
|
|
37718
38081
|
try {
|
|
37719
|
-
|
|
38082
|
+
raw = await evaluate(script);
|
|
37720
38083
|
const data = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
37721
38084
|
if (data?.error) {
|
|
37722
38085
|
const state2 = this.errorState(data.error);
|
|
@@ -37736,12 +38099,31 @@ var init_provider_adapter = __esm({
|
|
|
37736
38099
|
mode: data.mode,
|
|
37737
38100
|
activeModal: data.activeModal
|
|
37738
38101
|
};
|
|
38102
|
+
if (this.provider.controls?.length) {
|
|
38103
|
+
const cv = {};
|
|
38104
|
+
for (const ctrl of this.provider.controls) {
|
|
38105
|
+
if (!ctrl.readFrom) continue;
|
|
38106
|
+
const val = data[ctrl.readFrom];
|
|
38107
|
+
if (val !== void 0 && val !== null) {
|
|
38108
|
+
cv[ctrl.id] = typeof val === "object" ? val.name || val.id || String(val) : val;
|
|
38109
|
+
}
|
|
38110
|
+
}
|
|
38111
|
+
if (data.model && !cv["model"]) cv["model"] = data.model;
|
|
38112
|
+
if (data.mode && !cv["mode"]) cv["mode"] = data.mode;
|
|
38113
|
+
if (Object.keys(cv).length > 0) state.controlValues = cv;
|
|
38114
|
+
}
|
|
37739
38115
|
if (state.messages.length > 0) {
|
|
37740
38116
|
this.lastSuccessState = state;
|
|
37741
38117
|
}
|
|
37742
38118
|
return state;
|
|
37743
|
-
} catch {
|
|
37744
|
-
const
|
|
38119
|
+
} catch (error48) {
|
|
38120
|
+
const reason = error48 instanceof Error ? error48.message : String(error48);
|
|
38121
|
+
if (this.isTransportError(reason)) {
|
|
38122
|
+
throw error48 instanceof Error ? error48 : new Error(reason);
|
|
38123
|
+
}
|
|
38124
|
+
const preview = this.summarizeRaw(raw);
|
|
38125
|
+
const detail = preview ? ` (reason=${reason}; raw=${preview})` : ` (reason=${reason})`;
|
|
38126
|
+
const state = this.errorState(`Failed to parse ${this.agentName} state${detail}`);
|
|
37745
38127
|
if (this.lastSuccessState?.messages?.length) {
|
|
37746
38128
|
state.messages = this.lastSuccessState.messages;
|
|
37747
38129
|
}
|
|
@@ -37845,6 +38227,9 @@ var init_manager2 = __esm({
|
|
|
37845
38227
|
getActiveSessionId(parentSessionId) {
|
|
37846
38228
|
return this.activeSessionIdByParent.get(parentSessionId) || null;
|
|
37847
38229
|
}
|
|
38230
|
+
isRecoverableSessionError(message) {
|
|
38231
|
+
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");
|
|
38232
|
+
}
|
|
37848
38233
|
getSessionTarget(sessionId) {
|
|
37849
38234
|
return this.sessionRegistry?.get(sessionId);
|
|
37850
38235
|
}
|
|
@@ -37946,6 +38331,10 @@ var init_manager2 = __esm({
|
|
|
37946
38331
|
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.cdpSessionId, expr, timeout);
|
|
37947
38332
|
const state = await agent.adapter.readChat(evaluate);
|
|
37948
38333
|
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") : ""}`);
|
|
38334
|
+
const stateError = String(state.error || state._error || "");
|
|
38335
|
+
if (state.status === "error" && this.isRecoverableSessionError(stateError)) {
|
|
38336
|
+
throw new Error(stateError);
|
|
38337
|
+
}
|
|
37949
38338
|
agent.lastState = state;
|
|
37950
38339
|
agent.lastError = null;
|
|
37951
38340
|
if (state.status === "panel_hidden") {
|
|
@@ -37956,7 +38345,7 @@ var init_manager2 = __esm({
|
|
|
37956
38345
|
const errorMsg = e?.message || String(e);
|
|
37957
38346
|
this.logFn(`[AgentStream] readChat(${type}) error: ${errorMsg.slice(0, 200)}`);
|
|
37958
38347
|
agent.lastError = errorMsg;
|
|
37959
|
-
if (
|
|
38348
|
+
if (this.isRecoverableSessionError(errorMsg)) {
|
|
37960
38349
|
try {
|
|
37961
38350
|
await cdp.detachAgent(agent.cdpSessionId);
|
|
37962
38351
|
} catch {
|
|
@@ -38516,7 +38905,7 @@ function checkPathExists2(paths) {
|
|
|
38516
38905
|
for (const p of paths) {
|
|
38517
38906
|
if (p.includes("*")) {
|
|
38518
38907
|
const home = os15.homedir();
|
|
38519
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
38908
|
+
const resolved = p.replace(/\*/g, home.split(path12.sep).pop() || "");
|
|
38520
38909
|
if (fs9.existsSync(resolved)) return resolved;
|
|
38521
38910
|
} else {
|
|
38522
38911
|
if (fs9.existsSync(p)) return p;
|
|
@@ -38526,7 +38915,7 @@ function checkPathExists2(paths) {
|
|
|
38526
38915
|
}
|
|
38527
38916
|
function getMacAppVersion(appPath) {
|
|
38528
38917
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
38529
|
-
const plistPath =
|
|
38918
|
+
const plistPath = path12.join(appPath, "Contents", "Info.plist");
|
|
38530
38919
|
if (!fs9.existsSync(plistPath)) return null;
|
|
38531
38920
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
38532
38921
|
return raw || null;
|
|
@@ -38553,7 +38942,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
38553
38942
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
38554
38943
|
let resolvedBin = cliBin;
|
|
38555
38944
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
38556
|
-
const bundled =
|
|
38945
|
+
const bundled = path12.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
38557
38946
|
if (provider.cli && fs9.existsSync(bundled)) resolvedBin = bundled;
|
|
38558
38947
|
}
|
|
38559
38948
|
info.installed = !!(appPath || resolvedBin);
|
|
@@ -38590,16 +38979,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
38590
38979
|
}
|
|
38591
38980
|
return results;
|
|
38592
38981
|
}
|
|
38593
|
-
var fs9,
|
|
38982
|
+
var fs9, path12, os15, import_child_process7, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
38594
38983
|
var init_version_archive = __esm({
|
|
38595
38984
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
38596
38985
|
"use strict";
|
|
38597
38986
|
fs9 = __toESM(require("fs"));
|
|
38598
|
-
|
|
38987
|
+
path12 = __toESM(require("path"));
|
|
38599
38988
|
os15 = __toESM(require("os"));
|
|
38600
38989
|
import_child_process7 = require("child_process");
|
|
38601
38990
|
import_os3 = require("os");
|
|
38602
|
-
ARCHIVE_PATH =
|
|
38991
|
+
ARCHIVE_PATH = path12.join(os15.homedir(), ".adhdev", "version-history.json");
|
|
38603
38992
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
38604
38993
|
VersionArchive = class {
|
|
38605
38994
|
history = {};
|
|
@@ -38646,7 +39035,7 @@ var init_version_archive = __esm({
|
|
|
38646
39035
|
}
|
|
38647
39036
|
save() {
|
|
38648
39037
|
try {
|
|
38649
|
-
fs9.mkdirSync(
|
|
39038
|
+
fs9.mkdirSync(path12.dirname(ARCHIVE_PATH), { recursive: true });
|
|
38650
39039
|
fs9.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
38651
39040
|
} catch {
|
|
38652
39041
|
}
|
|
@@ -39167,17 +39556,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
39167
39556
|
return;
|
|
39168
39557
|
}
|
|
39169
39558
|
let scriptsPath = "";
|
|
39170
|
-
const directScripts =
|
|
39559
|
+
const directScripts = path13.join(dir, "scripts.js");
|
|
39171
39560
|
if (fs10.existsSync(directScripts)) {
|
|
39172
39561
|
scriptsPath = directScripts;
|
|
39173
39562
|
} else {
|
|
39174
|
-
const scriptsDir =
|
|
39563
|
+
const scriptsDir = path13.join(dir, "scripts");
|
|
39175
39564
|
if (fs10.existsSync(scriptsDir)) {
|
|
39176
39565
|
const versions = fs10.readdirSync(scriptsDir).filter((d) => {
|
|
39177
|
-
return fs10.statSync(
|
|
39566
|
+
return fs10.statSync(path13.join(scriptsDir, d)).isDirectory();
|
|
39178
39567
|
}).sort().reverse();
|
|
39179
39568
|
for (const ver of versions) {
|
|
39180
|
-
const p =
|
|
39569
|
+
const p = path13.join(scriptsDir, ver, "scripts.js");
|
|
39181
39570
|
if (fs10.existsSync(p)) {
|
|
39182
39571
|
scriptsPath = p;
|
|
39183
39572
|
break;
|
|
@@ -39993,12 +40382,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
39993
40382
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
39994
40383
|
}
|
|
39995
40384
|
}
|
|
39996
|
-
var fs10,
|
|
40385
|
+
var fs10, path13;
|
|
39997
40386
|
var init_dev_cdp_handlers = __esm({
|
|
39998
40387
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
39999
40388
|
"use strict";
|
|
40000
40389
|
fs10 = __toESM(require("fs"));
|
|
40001
|
-
|
|
40390
|
+
path13 = __toESM(require("path"));
|
|
40002
40391
|
init_logger();
|
|
40003
40392
|
}
|
|
40004
40393
|
});
|
|
@@ -40263,22 +40652,22 @@ function getLatestScriptVersionDir(scriptsDir) {
|
|
|
40263
40652
|
if (!fs11.existsSync(scriptsDir)) return null;
|
|
40264
40653
|
const versions = fs11.readdirSync(scriptsDir).filter((d) => {
|
|
40265
40654
|
try {
|
|
40266
|
-
return fs11.statSync(
|
|
40655
|
+
return fs11.statSync(path14.join(scriptsDir, d)).isDirectory();
|
|
40267
40656
|
} catch {
|
|
40268
40657
|
return false;
|
|
40269
40658
|
}
|
|
40270
40659
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
40271
40660
|
if (versions.length === 0) return null;
|
|
40272
|
-
return
|
|
40661
|
+
return path14.join(scriptsDir, versions[0]);
|
|
40273
40662
|
}
|
|
40274
40663
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
40275
|
-
const canonicalUserDir =
|
|
40276
|
-
const desiredDir = requestedDir ?
|
|
40277
|
-
const upstreamRoot =
|
|
40278
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
40664
|
+
const canonicalUserDir = path14.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
40665
|
+
const desiredDir = requestedDir ? path14.resolve(requestedDir) : canonicalUserDir;
|
|
40666
|
+
const upstreamRoot = path14.resolve(ctx.providerLoader.getUpstreamDir());
|
|
40667
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path14.sep}`)) {
|
|
40279
40668
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
40280
40669
|
}
|
|
40281
|
-
if (
|
|
40670
|
+
if (path14.basename(desiredDir) !== type) {
|
|
40282
40671
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
40283
40672
|
}
|
|
40284
40673
|
const sourceDir = ctx.findProviderDir(type);
|
|
@@ -40286,11 +40675,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
40286
40675
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
40287
40676
|
}
|
|
40288
40677
|
if (!fs11.existsSync(desiredDir)) {
|
|
40289
|
-
fs11.mkdirSync(
|
|
40678
|
+
fs11.mkdirSync(path14.dirname(desiredDir), { recursive: true });
|
|
40290
40679
|
fs11.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
40291
40680
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
40292
40681
|
}
|
|
40293
|
-
const providerJson =
|
|
40682
|
+
const providerJson = path14.join(desiredDir, "provider.json");
|
|
40294
40683
|
if (!fs11.existsSync(providerJson)) {
|
|
40295
40684
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
40296
40685
|
}
|
|
@@ -40313,13 +40702,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
|
40313
40702
|
const refDir = ctx.findProviderDir(referenceType);
|
|
40314
40703
|
if (!refDir || !fs11.existsSync(refDir)) return {};
|
|
40315
40704
|
const referenceScripts = {};
|
|
40316
|
-
const scriptsDir =
|
|
40705
|
+
const scriptsDir = path14.join(refDir, "scripts");
|
|
40317
40706
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
40318
40707
|
if (!latestDir) return referenceScripts;
|
|
40319
40708
|
for (const file2 of fs11.readdirSync(latestDir)) {
|
|
40320
40709
|
if (!file2.endsWith(".js")) continue;
|
|
40321
40710
|
try {
|
|
40322
|
-
referenceScripts[file2] = fs11.readFileSync(
|
|
40711
|
+
referenceScripts[file2] = fs11.readFileSync(path14.join(latestDir, file2), "utf-8");
|
|
40323
40712
|
} catch {
|
|
40324
40713
|
}
|
|
40325
40714
|
}
|
|
@@ -40370,9 +40759,9 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
40370
40759
|
});
|
|
40371
40760
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
40372
40761
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference);
|
|
40373
|
-
const tmpDir =
|
|
40762
|
+
const tmpDir = path14.join(os16.tmpdir(), "adhdev-autoimpl");
|
|
40374
40763
|
if (!fs11.existsSync(tmpDir)) fs11.mkdirSync(tmpDir, { recursive: true });
|
|
40375
|
-
const promptFile =
|
|
40764
|
+
const promptFile = path14.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
40376
40765
|
fs11.writeFileSync(promptFile, prompt, "utf-8");
|
|
40377
40766
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
40378
40767
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
@@ -40743,7 +41132,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40743
41132
|
setMode: "set_mode.js"
|
|
40744
41133
|
};
|
|
40745
41134
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
40746
|
-
const scriptsDir =
|
|
41135
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
40747
41136
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
40748
41137
|
if (latestScriptsDir) {
|
|
40749
41138
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -40754,7 +41143,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40754
41143
|
for (const file2 of fs11.readdirSync(latestScriptsDir)) {
|
|
40755
41144
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
40756
41145
|
try {
|
|
40757
|
-
const content = fs11.readFileSync(
|
|
41146
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
40758
41147
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
40759
41148
|
lines.push("```javascript");
|
|
40760
41149
|
lines.push(content);
|
|
@@ -40771,7 +41160,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40771
41160
|
lines.push("");
|
|
40772
41161
|
for (const file2 of refFiles) {
|
|
40773
41162
|
try {
|
|
40774
|
-
const content = fs11.readFileSync(
|
|
41163
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
40775
41164
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
40776
41165
|
lines.push("```javascript");
|
|
40777
41166
|
lines.push(content);
|
|
@@ -40812,10 +41201,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
40812
41201
|
lines.push("");
|
|
40813
41202
|
}
|
|
40814
41203
|
}
|
|
40815
|
-
const docsDir =
|
|
41204
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
40816
41205
|
const loadGuide = (name) => {
|
|
40817
41206
|
try {
|
|
40818
|
-
const p =
|
|
41207
|
+
const p = path14.join(docsDir, name);
|
|
40819
41208
|
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
40820
41209
|
} catch {
|
|
40821
41210
|
}
|
|
@@ -40989,7 +41378,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
40989
41378
|
parseApproval: "parse_approval.js"
|
|
40990
41379
|
};
|
|
40991
41380
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
40992
|
-
const scriptsDir =
|
|
41381
|
+
const scriptsDir = path14.join(providerDir, "scripts");
|
|
40993
41382
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
40994
41383
|
if (latestScriptsDir) {
|
|
40995
41384
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -41001,7 +41390,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41001
41390
|
if (!file2.endsWith(".js")) continue;
|
|
41002
41391
|
if (!targetFileNames.has(file2)) continue;
|
|
41003
41392
|
try {
|
|
41004
|
-
const content = fs11.readFileSync(
|
|
41393
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41005
41394
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
41006
41395
|
lines.push("```javascript");
|
|
41007
41396
|
lines.push(content);
|
|
@@ -41017,7 +41406,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41017
41406
|
lines.push("");
|
|
41018
41407
|
for (const file2 of refFiles) {
|
|
41019
41408
|
try {
|
|
41020
|
-
const content = fs11.readFileSync(
|
|
41409
|
+
const content = fs11.readFileSync(path14.join(latestScriptsDir, file2), "utf-8");
|
|
41021
41410
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
41022
41411
|
lines.push("```javascript");
|
|
41023
41412
|
lines.push(content);
|
|
@@ -41050,10 +41439,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
41050
41439
|
lines.push("");
|
|
41051
41440
|
}
|
|
41052
41441
|
}
|
|
41053
|
-
const docsDir =
|
|
41442
|
+
const docsDir = path14.join(providerDir, "../../docs");
|
|
41054
41443
|
const loadGuide = (name) => {
|
|
41055
41444
|
try {
|
|
41056
|
-
const p =
|
|
41445
|
+
const p = path14.join(docsDir, name);
|
|
41057
41446
|
if (fs11.existsSync(p)) return fs11.readFileSync(p, "utf-8");
|
|
41058
41447
|
} catch {
|
|
41059
41448
|
}
|
|
@@ -41217,25 +41606,25 @@ data: ${JSON.stringify(msg.data)}
|
|
|
41217
41606
|
}
|
|
41218
41607
|
}
|
|
41219
41608
|
}
|
|
41220
|
-
var fs11,
|
|
41609
|
+
var fs11, path14, os16;
|
|
41221
41610
|
var init_dev_auto_implement = __esm({
|
|
41222
41611
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
41223
41612
|
"use strict";
|
|
41224
41613
|
fs11 = __toESM(require("fs"));
|
|
41225
|
-
|
|
41614
|
+
path14 = __toESM(require("path"));
|
|
41226
41615
|
os16 = __toESM(require("os"));
|
|
41227
41616
|
init_dev_server();
|
|
41228
41617
|
}
|
|
41229
41618
|
});
|
|
41230
41619
|
|
|
41231
41620
|
// ../../oss/packages/daemon-core/src/daemon/dev-server.ts
|
|
41232
|
-
var http2, fs12,
|
|
41621
|
+
var http2, fs12, path15, DEV_SERVER_PORT, DevServer;
|
|
41233
41622
|
var init_dev_server = __esm({
|
|
41234
41623
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
41235
41624
|
"use strict";
|
|
41236
41625
|
http2 = __toESM(require("http"));
|
|
41237
41626
|
fs12 = __toESM(require("fs"));
|
|
41238
|
-
|
|
41627
|
+
path15 = __toESM(require("path"));
|
|
41239
41628
|
init_scaffold_template();
|
|
41240
41629
|
init_version_archive();
|
|
41241
41630
|
init_logger();
|
|
@@ -41334,8 +41723,8 @@ var init_dev_server = __esm({
|
|
|
41334
41723
|
}
|
|
41335
41724
|
getEndpointList() {
|
|
41336
41725
|
return this.routes.map((r) => {
|
|
41337
|
-
const
|
|
41338
|
-
return `${r.method.padEnd(5)} ${
|
|
41726
|
+
const path19 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
41727
|
+
return `${r.method.padEnd(5)} ${path19}`;
|
|
41339
41728
|
});
|
|
41340
41729
|
}
|
|
41341
41730
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -41366,15 +41755,15 @@ var init_dev_server = __esm({
|
|
|
41366
41755
|
this.json(res, 500, { error: e.message });
|
|
41367
41756
|
}
|
|
41368
41757
|
});
|
|
41369
|
-
return new Promise((
|
|
41758
|
+
return new Promise((resolve13, reject) => {
|
|
41370
41759
|
this.server.listen(port, "127.0.0.1", () => {
|
|
41371
41760
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
41372
|
-
|
|
41761
|
+
resolve13();
|
|
41373
41762
|
});
|
|
41374
41763
|
this.server.on("error", (e) => {
|
|
41375
41764
|
if (e.code === "EADDRINUSE") {
|
|
41376
41765
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
41377
|
-
|
|
41766
|
+
resolve13();
|
|
41378
41767
|
} else {
|
|
41379
41768
|
reject(e);
|
|
41380
41769
|
}
|
|
@@ -41457,20 +41846,20 @@ var init_dev_server = __esm({
|
|
|
41457
41846
|
child.stderr?.on("data", (d) => {
|
|
41458
41847
|
stderr += d.toString().slice(0, 2e3);
|
|
41459
41848
|
});
|
|
41460
|
-
await new Promise((
|
|
41849
|
+
await new Promise((resolve13) => {
|
|
41461
41850
|
const timer = setTimeout(() => {
|
|
41462
41851
|
child.kill();
|
|
41463
|
-
|
|
41852
|
+
resolve13();
|
|
41464
41853
|
}, 3e3);
|
|
41465
41854
|
child.on("exit", () => {
|
|
41466
41855
|
clearTimeout(timer);
|
|
41467
|
-
|
|
41856
|
+
resolve13();
|
|
41468
41857
|
});
|
|
41469
41858
|
child.stdout?.once("data", () => {
|
|
41470
41859
|
setTimeout(() => {
|
|
41471
41860
|
child.kill();
|
|
41472
41861
|
clearTimeout(timer);
|
|
41473
|
-
|
|
41862
|
+
resolve13();
|
|
41474
41863
|
}, 500);
|
|
41475
41864
|
});
|
|
41476
41865
|
});
|
|
@@ -41617,12 +42006,12 @@ var init_dev_server = __esm({
|
|
|
41617
42006
|
// ─── DevConsole SPA ───
|
|
41618
42007
|
getConsoleDistDir() {
|
|
41619
42008
|
const candidates = [
|
|
41620
|
-
|
|
41621
|
-
|
|
41622
|
-
|
|
42009
|
+
path15.resolve(__dirname, "../../web-devconsole/dist"),
|
|
42010
|
+
path15.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
42011
|
+
path15.join(process.cwd(), "packages/web-devconsole/dist")
|
|
41623
42012
|
];
|
|
41624
42013
|
for (const dir of candidates) {
|
|
41625
|
-
if (fs12.existsSync(
|
|
42014
|
+
if (fs12.existsSync(path15.join(dir, "index.html"))) return dir;
|
|
41626
42015
|
}
|
|
41627
42016
|
return null;
|
|
41628
42017
|
}
|
|
@@ -41632,7 +42021,7 @@ var init_dev_server = __esm({
|
|
|
41632
42021
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
41633
42022
|
return;
|
|
41634
42023
|
}
|
|
41635
|
-
const htmlPath =
|
|
42024
|
+
const htmlPath = path15.join(distDir, "index.html");
|
|
41636
42025
|
try {
|
|
41637
42026
|
const html = fs12.readFileSync(htmlPath, "utf-8");
|
|
41638
42027
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -41657,15 +42046,15 @@ var init_dev_server = __esm({
|
|
|
41657
42046
|
this.json(res, 404, { error: "Not found" });
|
|
41658
42047
|
return;
|
|
41659
42048
|
}
|
|
41660
|
-
const safePath =
|
|
41661
|
-
const filePath =
|
|
42049
|
+
const safePath = path15.normalize(pathname).replace(/^\.\.\//, "");
|
|
42050
|
+
const filePath = path15.join(distDir, safePath);
|
|
41662
42051
|
if (!filePath.startsWith(distDir)) {
|
|
41663
42052
|
this.json(res, 403, { error: "Forbidden" });
|
|
41664
42053
|
return;
|
|
41665
42054
|
}
|
|
41666
42055
|
try {
|
|
41667
42056
|
const content = fs12.readFileSync(filePath);
|
|
41668
|
-
const ext =
|
|
42057
|
+
const ext = path15.extname(filePath);
|
|
41669
42058
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
41670
42059
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
41671
42060
|
res.end(content);
|
|
@@ -41778,9 +42167,9 @@ var init_dev_server = __esm({
|
|
|
41778
42167
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
41779
42168
|
if (entry.isDirectory()) {
|
|
41780
42169
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
41781
|
-
scan(
|
|
42170
|
+
scan(path15.join(d, entry.name), rel);
|
|
41782
42171
|
} else {
|
|
41783
|
-
const stat4 = fs12.statSync(
|
|
42172
|
+
const stat4 = fs12.statSync(path15.join(d, entry.name));
|
|
41784
42173
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
41785
42174
|
}
|
|
41786
42175
|
}
|
|
@@ -41803,7 +42192,7 @@ var init_dev_server = __esm({
|
|
|
41803
42192
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
41804
42193
|
return;
|
|
41805
42194
|
}
|
|
41806
|
-
const fullPath =
|
|
42195
|
+
const fullPath = path15.resolve(dir, path15.normalize(filePath));
|
|
41807
42196
|
if (!fullPath.startsWith(dir)) {
|
|
41808
42197
|
this.json(res, 403, { error: "Forbidden" });
|
|
41809
42198
|
return;
|
|
@@ -41828,14 +42217,14 @@ var init_dev_server = __esm({
|
|
|
41828
42217
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
41829
42218
|
return;
|
|
41830
42219
|
}
|
|
41831
|
-
const fullPath =
|
|
42220
|
+
const fullPath = path15.resolve(dir, path15.normalize(filePath));
|
|
41832
42221
|
if (!fullPath.startsWith(dir)) {
|
|
41833
42222
|
this.json(res, 403, { error: "Forbidden" });
|
|
41834
42223
|
return;
|
|
41835
42224
|
}
|
|
41836
42225
|
try {
|
|
41837
42226
|
if (fs12.existsSync(fullPath)) fs12.copyFileSync(fullPath, fullPath + ".bak");
|
|
41838
|
-
fs12.mkdirSync(
|
|
42227
|
+
fs12.mkdirSync(path15.dirname(fullPath), { recursive: true });
|
|
41839
42228
|
fs12.writeFileSync(fullPath, content, "utf-8");
|
|
41840
42229
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
41841
42230
|
this.providerLoader.reload();
|
|
@@ -41852,7 +42241,7 @@ var init_dev_server = __esm({
|
|
|
41852
42241
|
return;
|
|
41853
42242
|
}
|
|
41854
42243
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
41855
|
-
const p =
|
|
42244
|
+
const p = path15.join(dir, name);
|
|
41856
42245
|
if (fs12.existsSync(p)) {
|
|
41857
42246
|
const source = fs12.readFileSync(p, "utf-8");
|
|
41858
42247
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
@@ -41873,8 +42262,8 @@ var init_dev_server = __esm({
|
|
|
41873
42262
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
41874
42263
|
return;
|
|
41875
42264
|
}
|
|
41876
|
-
const target = fs12.existsSync(
|
|
41877
|
-
const targetPath =
|
|
42265
|
+
const target = fs12.existsSync(path15.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
42266
|
+
const targetPath = path15.join(dir, target);
|
|
41878
42267
|
try {
|
|
41879
42268
|
if (fs12.existsSync(targetPath)) fs12.copyFileSync(targetPath, targetPath + ".bak");
|
|
41880
42269
|
fs12.writeFileSync(targetPath, source, "utf-8");
|
|
@@ -41979,14 +42368,14 @@ var init_dev_server = __esm({
|
|
|
41979
42368
|
child.stderr?.on("data", (d) => {
|
|
41980
42369
|
stderr += d.toString();
|
|
41981
42370
|
});
|
|
41982
|
-
await new Promise((
|
|
42371
|
+
await new Promise((resolve13) => {
|
|
41983
42372
|
const timer = setTimeout(() => {
|
|
41984
42373
|
child.kill();
|
|
41985
|
-
|
|
42374
|
+
resolve13();
|
|
41986
42375
|
}, timeout);
|
|
41987
42376
|
child.on("exit", () => {
|
|
41988
42377
|
clearTimeout(timer);
|
|
41989
|
-
|
|
42378
|
+
resolve13();
|
|
41990
42379
|
});
|
|
41991
42380
|
});
|
|
41992
42381
|
const elapsed = Date.now() - start;
|
|
@@ -42034,7 +42423,7 @@ var init_dev_server = __esm({
|
|
|
42034
42423
|
}
|
|
42035
42424
|
let targetDir;
|
|
42036
42425
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
42037
|
-
const jsonPath =
|
|
42426
|
+
const jsonPath = path15.join(targetDir, "provider.json");
|
|
42038
42427
|
if (fs12.existsSync(jsonPath)) {
|
|
42039
42428
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
42040
42429
|
return;
|
|
@@ -42046,8 +42435,8 @@ var init_dev_server = __esm({
|
|
|
42046
42435
|
const createdFiles = ["provider.json"];
|
|
42047
42436
|
if (result.files) {
|
|
42048
42437
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
42049
|
-
const fullPath =
|
|
42050
|
-
fs12.mkdirSync(
|
|
42438
|
+
const fullPath = path15.join(targetDir, relPath);
|
|
42439
|
+
fs12.mkdirSync(path15.dirname(fullPath), { recursive: true });
|
|
42051
42440
|
fs12.writeFileSync(fullPath, content, "utf-8");
|
|
42052
42441
|
createdFiles.push(relPath);
|
|
42053
42442
|
}
|
|
@@ -42100,22 +42489,22 @@ var init_dev_server = __esm({
|
|
|
42100
42489
|
if (!fs12.existsSync(scriptsDir)) return null;
|
|
42101
42490
|
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
42102
42491
|
try {
|
|
42103
|
-
return fs12.statSync(
|
|
42492
|
+
return fs12.statSync(path15.join(scriptsDir, d)).isDirectory();
|
|
42104
42493
|
} catch {
|
|
42105
42494
|
return false;
|
|
42106
42495
|
}
|
|
42107
42496
|
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
42108
42497
|
if (versions.length === 0) return null;
|
|
42109
|
-
return
|
|
42498
|
+
return path15.join(scriptsDir, versions[0]);
|
|
42110
42499
|
}
|
|
42111
42500
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
42112
|
-
const canonicalUserDir =
|
|
42113
|
-
const desiredDir = requestedDir ?
|
|
42114
|
-
const upstreamRoot =
|
|
42115
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
42501
|
+
const canonicalUserDir = path15.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
42502
|
+
const desiredDir = requestedDir ? path15.resolve(requestedDir) : canonicalUserDir;
|
|
42503
|
+
const upstreamRoot = path15.resolve(this.providerLoader.getUpstreamDir());
|
|
42504
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path15.sep}`)) {
|
|
42116
42505
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
42117
42506
|
}
|
|
42118
|
-
if (
|
|
42507
|
+
if (path15.basename(desiredDir) !== type) {
|
|
42119
42508
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
42120
42509
|
}
|
|
42121
42510
|
const sourceDir = this.findProviderDir(type);
|
|
@@ -42123,11 +42512,11 @@ var init_dev_server = __esm({
|
|
|
42123
42512
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
42124
42513
|
}
|
|
42125
42514
|
if (!fs12.existsSync(desiredDir)) {
|
|
42126
|
-
fs12.mkdirSync(
|
|
42515
|
+
fs12.mkdirSync(path15.dirname(desiredDir), { recursive: true });
|
|
42127
42516
|
fs12.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
42128
42517
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
42129
42518
|
}
|
|
42130
|
-
const providerJson =
|
|
42519
|
+
const providerJson = path15.join(desiredDir, "provider.json");
|
|
42131
42520
|
if (!fs12.existsSync(providerJson)) {
|
|
42132
42521
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
42133
42522
|
}
|
|
@@ -42175,7 +42564,7 @@ var init_dev_server = __esm({
|
|
|
42175
42564
|
setMode: "set_mode.js"
|
|
42176
42565
|
};
|
|
42177
42566
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
42178
|
-
const scriptsDir =
|
|
42567
|
+
const scriptsDir = path15.join(providerDir, "scripts");
|
|
42179
42568
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
42180
42569
|
if (latestScriptsDir) {
|
|
42181
42570
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -42186,7 +42575,7 @@ var init_dev_server = __esm({
|
|
|
42186
42575
|
for (const file2 of fs12.readdirSync(latestScriptsDir)) {
|
|
42187
42576
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
42188
42577
|
try {
|
|
42189
|
-
const content = fs12.readFileSync(
|
|
42578
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42190
42579
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
42191
42580
|
lines.push("```javascript");
|
|
42192
42581
|
lines.push(content);
|
|
@@ -42203,7 +42592,7 @@ var init_dev_server = __esm({
|
|
|
42203
42592
|
lines.push("");
|
|
42204
42593
|
for (const file2 of refFiles) {
|
|
42205
42594
|
try {
|
|
42206
|
-
const content = fs12.readFileSync(
|
|
42595
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42207
42596
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
42208
42597
|
lines.push("```javascript");
|
|
42209
42598
|
lines.push(content);
|
|
@@ -42244,10 +42633,10 @@ var init_dev_server = __esm({
|
|
|
42244
42633
|
lines.push("");
|
|
42245
42634
|
}
|
|
42246
42635
|
}
|
|
42247
|
-
const docsDir =
|
|
42636
|
+
const docsDir = path15.join(providerDir, "../../docs");
|
|
42248
42637
|
const loadGuide = (name) => {
|
|
42249
42638
|
try {
|
|
42250
|
-
const p =
|
|
42639
|
+
const p = path15.join(docsDir, name);
|
|
42251
42640
|
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
42252
42641
|
} catch {
|
|
42253
42642
|
}
|
|
@@ -42421,7 +42810,7 @@ var init_dev_server = __esm({
|
|
|
42421
42810
|
parseApproval: "parse_approval.js"
|
|
42422
42811
|
};
|
|
42423
42812
|
const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
|
|
42424
|
-
const scriptsDir =
|
|
42813
|
+
const scriptsDir = path15.join(providerDir, "scripts");
|
|
42425
42814
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
42426
42815
|
if (latestScriptsDir) {
|
|
42427
42816
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -42433,7 +42822,7 @@ var init_dev_server = __esm({
|
|
|
42433
42822
|
if (!file2.endsWith(".js")) continue;
|
|
42434
42823
|
if (!targetFileNames.has(file2)) continue;
|
|
42435
42824
|
try {
|
|
42436
|
-
const content = fs12.readFileSync(
|
|
42825
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42437
42826
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
42438
42827
|
lines.push("```javascript");
|
|
42439
42828
|
lines.push(content);
|
|
@@ -42449,7 +42838,7 @@ var init_dev_server = __esm({
|
|
|
42449
42838
|
lines.push("");
|
|
42450
42839
|
for (const file2 of refFiles) {
|
|
42451
42840
|
try {
|
|
42452
|
-
const content = fs12.readFileSync(
|
|
42841
|
+
const content = fs12.readFileSync(path15.join(latestScriptsDir, file2), "utf-8");
|
|
42453
42842
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
42454
42843
|
lines.push("```javascript");
|
|
42455
42844
|
lines.push(content);
|
|
@@ -42482,10 +42871,10 @@ var init_dev_server = __esm({
|
|
|
42482
42871
|
lines.push("");
|
|
42483
42872
|
}
|
|
42484
42873
|
}
|
|
42485
|
-
const docsDir =
|
|
42874
|
+
const docsDir = path15.join(providerDir, "../../docs");
|
|
42486
42875
|
const loadGuide = (name) => {
|
|
42487
42876
|
try {
|
|
42488
|
-
const p =
|
|
42877
|
+
const p = path15.join(docsDir, name);
|
|
42489
42878
|
if (fs12.existsSync(p)) return fs12.readFileSync(p, "utf-8");
|
|
42490
42879
|
} catch {
|
|
42491
42880
|
}
|
|
@@ -42642,14 +43031,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
42642
43031
|
res.end(JSON.stringify(data, null, 2));
|
|
42643
43032
|
}
|
|
42644
43033
|
async readBody(req) {
|
|
42645
|
-
return new Promise((
|
|
43034
|
+
return new Promise((resolve13) => {
|
|
42646
43035
|
let body = "";
|
|
42647
43036
|
req.on("data", (chunk) => body += chunk);
|
|
42648
43037
|
req.on("end", () => {
|
|
42649
43038
|
try {
|
|
42650
|
-
|
|
43039
|
+
resolve13(JSON.parse(body));
|
|
42651
43040
|
} catch {
|
|
42652
|
-
|
|
43041
|
+
resolve13({});
|
|
42653
43042
|
}
|
|
42654
43043
|
});
|
|
42655
43044
|
});
|
|
@@ -42773,8 +43162,8 @@ var init_dist = __esm({
|
|
|
42773
43162
|
}
|
|
42774
43163
|
this.requestWaiters.clear();
|
|
42775
43164
|
});
|
|
42776
|
-
await new Promise((
|
|
42777
|
-
socket.once("connect", () =>
|
|
43165
|
+
await new Promise((resolve13, reject) => {
|
|
43166
|
+
socket.once("connect", () => resolve13());
|
|
42778
43167
|
socket.once("error", reject);
|
|
42779
43168
|
});
|
|
42780
43169
|
}
|
|
@@ -42793,7 +43182,7 @@ var init_dist = __esm({
|
|
|
42793
43182
|
requestId,
|
|
42794
43183
|
request
|
|
42795
43184
|
};
|
|
42796
|
-
const response = await new Promise((
|
|
43185
|
+
const response = await new Promise((resolve13, reject) => {
|
|
42797
43186
|
const timeout = setTimeout(() => {
|
|
42798
43187
|
this.requestWaiters.delete(requestId);
|
|
42799
43188
|
reject(new Error(`Session host request timed out after 30s (${request.type})`));
|
|
@@ -42801,7 +43190,7 @@ var init_dist = __esm({
|
|
|
42801
43190
|
this.requestWaiters.set(requestId, {
|
|
42802
43191
|
resolve: (value) => {
|
|
42803
43192
|
clearTimeout(timeout);
|
|
42804
|
-
|
|
43193
|
+
resolve13(value);
|
|
42805
43194
|
},
|
|
42806
43195
|
reject: (error48) => {
|
|
42807
43196
|
clearTimeout(timeout);
|
|
@@ -42820,12 +43209,12 @@ var init_dist = __esm({
|
|
|
42820
43209
|
waiter.reject(new Error("Session host client closed"));
|
|
42821
43210
|
}
|
|
42822
43211
|
this.requestWaiters.clear();
|
|
42823
|
-
await new Promise((
|
|
43212
|
+
await new Promise((resolve13) => {
|
|
42824
43213
|
let settled = false;
|
|
42825
43214
|
const done = () => {
|
|
42826
43215
|
if (settled) return;
|
|
42827
43216
|
settled = true;
|
|
42828
|
-
|
|
43217
|
+
resolve13();
|
|
42829
43218
|
};
|
|
42830
43219
|
socket.once("close", done);
|
|
42831
43220
|
socket.end();
|
|
@@ -43202,7 +43591,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
|
|
|
43202
43591
|
const deadline = Date.now() + timeoutMs;
|
|
43203
43592
|
while (Date.now() < deadline) {
|
|
43204
43593
|
if (await canConnect(endpoint)) return;
|
|
43205
|
-
await new Promise((
|
|
43594
|
+
await new Promise((resolve13) => setTimeout(resolve13, STARTUP_POLL_MS));
|
|
43206
43595
|
}
|
|
43207
43596
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
43208
43597
|
}
|
|
@@ -43521,6 +43910,7 @@ var init_src = __esm({
|
|
|
43521
43910
|
init_config();
|
|
43522
43911
|
init_workspaces();
|
|
43523
43912
|
init_workspace_activity();
|
|
43913
|
+
init_recent_activity();
|
|
43524
43914
|
init_ide_detector();
|
|
43525
43915
|
init_cli_detector();
|
|
43526
43916
|
init_host_memory();
|
|
@@ -43752,11 +44142,11 @@ var init_server_connection = __esm({
|
|
|
43752
44142
|
LOG.info("Server", `[ServerConn] Run 'adhdev setup' to re-authenticate.`);
|
|
43753
44143
|
this.setState("disconnected");
|
|
43754
44144
|
try {
|
|
43755
|
-
const
|
|
43756
|
-
const
|
|
43757
|
-
const configPath =
|
|
43758
|
-
if (
|
|
43759
|
-
|
|
44145
|
+
const path19 = require("path");
|
|
44146
|
+
const fs16 = require("fs");
|
|
44147
|
+
const configPath = path19.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
|
|
44148
|
+
if (fs16.existsSync(configPath)) {
|
|
44149
|
+
fs16.unlinkSync(configPath);
|
|
43760
44150
|
LOG.info("Server", `[ServerConn] Config file removed. Re-run 'adhdev setup'.`);
|
|
43761
44151
|
}
|
|
43762
44152
|
} catch {
|
|
@@ -43865,17 +44255,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
|
|
|
43865
44255
|
return false;
|
|
43866
44256
|
}
|
|
43867
44257
|
}
|
|
43868
|
-
var fs13,
|
|
44258
|
+
var fs13, path16, os18, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
|
|
43869
44259
|
var init_daemon_p2p = __esm({
|
|
43870
44260
|
"src/daemon-p2p.ts"() {
|
|
43871
44261
|
"use strict";
|
|
43872
44262
|
fs13 = __toESM(require("fs"));
|
|
43873
44263
|
init_src();
|
|
43874
|
-
|
|
44264
|
+
path16 = __toESM(require("path"));
|
|
43875
44265
|
os18 = __toESM(require("os"));
|
|
43876
44266
|
import_node_module = require("module");
|
|
43877
44267
|
esmRequire = (0, import_node_module.createRequire)(__filename);
|
|
43878
|
-
logFile =
|
|
44268
|
+
logFile = path16.join(os18.tmpdir(), "adhdev_daemon_p2p.log");
|
|
43879
44269
|
log = (msg) => {
|
|
43880
44270
|
LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
|
|
43881
44271
|
};
|
|
@@ -43943,15 +44333,15 @@ ${e?.stack || ""}`);
|
|
|
43943
44333
|
const prebuildKey = `${platform11}-${arch3}`;
|
|
43944
44334
|
try {
|
|
43945
44335
|
const candidates = [
|
|
43946
|
-
|
|
43947
|
-
|
|
43948
|
-
|
|
44336
|
+
path16.join(__dirname, "node_modules", "node-datachannel"),
|
|
44337
|
+
path16.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
44338
|
+
path16.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
43949
44339
|
];
|
|
43950
44340
|
for (const candidate of candidates) {
|
|
43951
|
-
const prebuildPath =
|
|
44341
|
+
const prebuildPath = path16.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
|
|
43952
44342
|
if (fs13.existsSync(prebuildPath)) {
|
|
43953
|
-
const targetDir =
|
|
43954
|
-
const targetPath =
|
|
44343
|
+
const targetDir = path16.join(candidate, "build", "Release");
|
|
44344
|
+
const targetPath = path16.join(targetDir, "node_datachannel.node");
|
|
43955
44345
|
fs13.mkdirSync(targetDir, { recursive: true });
|
|
43956
44346
|
fs13.copyFileSync(prebuildPath, targetPath);
|
|
43957
44347
|
try {
|
|
@@ -44027,7 +44417,7 @@ ${e?.stack || ""}`);
|
|
|
44027
44417
|
async fetchTurnCredentials() {
|
|
44028
44418
|
try {
|
|
44029
44419
|
const serverUrl = process.env.ADHDEV_SERVER_URL || "https://api.adhf.dev";
|
|
44030
|
-
const configPath =
|
|
44420
|
+
const configPath = path16.join(os18.homedir(), ".adhdev", "config.json");
|
|
44031
44421
|
let token = "";
|
|
44032
44422
|
try {
|
|
44033
44423
|
const config2 = JSON.parse(fs13.readFileSync(configPath, "utf-8"));
|
|
@@ -44035,13 +44425,13 @@ ${e?.stack || ""}`);
|
|
|
44035
44425
|
} catch {
|
|
44036
44426
|
}
|
|
44037
44427
|
const http3 = esmRequire("https");
|
|
44038
|
-
const data = await new Promise((
|
|
44428
|
+
const data = await new Promise((resolve13, reject) => {
|
|
44039
44429
|
const req = http3.get(`${serverUrl}/api/v1/turn/credentials`, {
|
|
44040
44430
|
headers: { "Authorization": `Bearer ${token}` }
|
|
44041
44431
|
}, (res) => {
|
|
44042
44432
|
let d = "";
|
|
44043
44433
|
res.on("data", (c) => d += c);
|
|
44044
|
-
res.on("end", () =>
|
|
44434
|
+
res.on("end", () => resolve13(d));
|
|
44045
44435
|
});
|
|
44046
44436
|
req.on("error", reject);
|
|
44047
44437
|
req.setTimeout(5e3, () => {
|
|
@@ -44847,13 +45237,12 @@ var init_screenshot_controller = __esm({
|
|
|
44847
45237
|
|
|
44848
45238
|
// src/session-host.ts
|
|
44849
45239
|
function resolveSessionHostEntry() {
|
|
44850
|
-
const
|
|
44851
|
-
|
|
44852
|
-
|
|
44853
|
-
path16.resolve(__dirname, "../../../oss/packages/session-host-daemon/dist/index.js")
|
|
45240
|
+
const packagedCandidates = [
|
|
45241
|
+
path17.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
45242
|
+
path17.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
44854
45243
|
];
|
|
44855
|
-
for (const candidate of
|
|
44856
|
-
if (
|
|
45244
|
+
for (const candidate of packagedCandidates) {
|
|
45245
|
+
if (fs14.existsSync(candidate)) {
|
|
44857
45246
|
return candidate;
|
|
44858
45247
|
}
|
|
44859
45248
|
}
|
|
@@ -44880,12 +45269,13 @@ async function ensureSessionHostReady2() {
|
|
|
44880
45269
|
async function listHostedCliRuntimes2(endpoint) {
|
|
44881
45270
|
return listHostedCliRuntimes(endpoint);
|
|
44882
45271
|
}
|
|
44883
|
-
var import_child_process8,
|
|
45272
|
+
var import_child_process8, fs14, path17, SESSION_HOST_APP_NAME;
|
|
44884
45273
|
var init_session_host = __esm({
|
|
44885
45274
|
"src/session-host.ts"() {
|
|
44886
45275
|
"use strict";
|
|
44887
45276
|
import_child_process8 = require("child_process");
|
|
44888
|
-
|
|
45277
|
+
fs14 = __toESM(require("fs"));
|
|
45278
|
+
path17 = __toESM(require("path"));
|
|
44889
45279
|
init_src();
|
|
44890
45280
|
SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
|
|
44891
45281
|
}
|
|
@@ -44899,24 +45289,24 @@ __export(adhdev_daemon_exports, {
|
|
|
44899
45289
|
stopDaemon: () => stopDaemon
|
|
44900
45290
|
});
|
|
44901
45291
|
function getDaemonPidFile() {
|
|
44902
|
-
const dir =
|
|
44903
|
-
if (!
|
|
44904
|
-
return
|
|
45292
|
+
const dir = path18.join(os19.homedir(), ".adhdev");
|
|
45293
|
+
if (!fs15.existsSync(dir)) fs15.mkdirSync(dir, { recursive: true });
|
|
45294
|
+
return path18.join(dir, "daemon.pid");
|
|
44905
45295
|
}
|
|
44906
45296
|
function writeDaemonPid(pid) {
|
|
44907
|
-
|
|
45297
|
+
fs15.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
|
|
44908
45298
|
}
|
|
44909
45299
|
function removeDaemonPid() {
|
|
44910
45300
|
try {
|
|
44911
|
-
|
|
45301
|
+
fs15.unlinkSync(getDaemonPidFile());
|
|
44912
45302
|
} catch (e) {
|
|
44913
45303
|
}
|
|
44914
45304
|
}
|
|
44915
45305
|
function isDaemonRunning() {
|
|
44916
45306
|
const pidFile = getDaemonPidFile();
|
|
44917
45307
|
try {
|
|
44918
|
-
if (!
|
|
44919
|
-
const pid = parseInt(
|
|
45308
|
+
if (!fs15.existsSync(pidFile)) return false;
|
|
45309
|
+
const pid = parseInt(fs15.readFileSync(pidFile, "utf-8").trim());
|
|
44920
45310
|
process.kill(pid, 0);
|
|
44921
45311
|
return true;
|
|
44922
45312
|
} catch {
|
|
@@ -44927,8 +45317,8 @@ function isDaemonRunning() {
|
|
|
44927
45317
|
function stopDaemon() {
|
|
44928
45318
|
const pidFile = getDaemonPidFile();
|
|
44929
45319
|
try {
|
|
44930
|
-
if (!
|
|
44931
|
-
const pid = parseInt(
|
|
45320
|
+
if (!fs15.existsSync(pidFile)) return false;
|
|
45321
|
+
const pid = parseInt(fs15.readFileSync(pidFile, "utf-8").trim());
|
|
44932
45322
|
process.kill(pid, "SIGTERM");
|
|
44933
45323
|
removeDaemonPid();
|
|
44934
45324
|
return true;
|
|
@@ -44937,7 +45327,7 @@ function stopDaemon() {
|
|
|
44937
45327
|
return false;
|
|
44938
45328
|
}
|
|
44939
45329
|
}
|
|
44940
|
-
var os19,
|
|
45330
|
+
var os19, fs15, path18, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
44941
45331
|
var init_adhdev_daemon = __esm({
|
|
44942
45332
|
"src/adhdev-daemon.ts"() {
|
|
44943
45333
|
"use strict";
|
|
@@ -44948,19 +45338,19 @@ var init_adhdev_daemon = __esm({
|
|
|
44948
45338
|
init_session_host();
|
|
44949
45339
|
init_dist();
|
|
44950
45340
|
os19 = __toESM(require("os"));
|
|
44951
|
-
|
|
44952
|
-
|
|
45341
|
+
fs15 = __toESM(require("fs"));
|
|
45342
|
+
path18 = __toESM(require("path"));
|
|
44953
45343
|
import_chalk2 = __toESM(require("chalk"));
|
|
44954
|
-
pkgVersion = "0.7.
|
|
45344
|
+
pkgVersion = "0.7.37";
|
|
44955
45345
|
if (pkgVersion === "unknown") {
|
|
44956
45346
|
try {
|
|
44957
45347
|
const possiblePaths = [
|
|
44958
|
-
|
|
44959
|
-
|
|
45348
|
+
path18.join(__dirname, "..", "package.json"),
|
|
45349
|
+
path18.join(__dirname, "package.json")
|
|
44960
45350
|
];
|
|
44961
45351
|
for (const p of possiblePaths) {
|
|
44962
45352
|
try {
|
|
44963
|
-
const data = JSON.parse(
|
|
45353
|
+
const data = JSON.parse(fs15.readFileSync(p, "utf-8"));
|
|
44964
45354
|
if (data.version) {
|
|
44965
45355
|
pkgVersion = data.version;
|
|
44966
45356
|
break;
|
|
@@ -45661,8 +46051,8 @@ async function startDaemonFlow() {
|
|
|
45661
46051
|
const daemon = new AdhdevDaemon2();
|
|
45662
46052
|
const { execSync: execSync6 } = await import("child_process");
|
|
45663
46053
|
const os20 = await import("os");
|
|
45664
|
-
const
|
|
45665
|
-
const logPath =
|
|
46054
|
+
const path19 = await import("path");
|
|
46055
|
+
const logPath = path19.join(os20.homedir(), ".adhdev", "daemon.log");
|
|
45666
46056
|
const platform11 = os20.platform();
|
|
45667
46057
|
try {
|
|
45668
46058
|
if (platform11 === "win32") {
|