adhdev 0.7.17 → 0.7.19

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 CHANGED
@@ -565,15 +565,15 @@ function parseVersion(raw) {
565
565
  return match ? match[1] : raw.split("\n")[0].slice(0, 100);
566
566
  }
567
567
  function execAsync(cmd, timeoutMs = 5e3) {
568
- return new Promise((resolve11) => {
568
+ return new Promise((resolve12) => {
569
569
  const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
570
570
  if (err || !stdout?.trim()) {
571
- resolve11(null);
571
+ resolve12(null);
572
572
  } else {
573
- resolve11(stdout.trim());
573
+ resolve12(stdout.trim());
574
574
  }
575
575
  });
576
- child.on("error", () => resolve11(null));
576
+ child.on("error", () => resolve12(null));
577
577
  });
578
578
  }
579
579
  async function detectCLIs(providerLoader) {
@@ -967,7 +967,7 @@ var init_manager = __esm({
967
967
  * Returns multiple entries if multiple IDE windows are open on same port
968
968
  */
969
969
  static listAllTargets(port) {
970
- return new Promise((resolve11) => {
970
+ return new Promise((resolve12) => {
971
971
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
972
972
  let data = "";
973
973
  res.on("data", (chunk) => data += chunk.toString());
@@ -983,16 +983,16 @@ var init_manager = __esm({
983
983
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
984
984
  );
985
985
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
986
- resolve11(mainPages.length > 0 ? mainPages : fallbackPages);
986
+ resolve12(mainPages.length > 0 ? mainPages : fallbackPages);
987
987
  } catch {
988
- resolve11([]);
988
+ resolve12([]);
989
989
  }
990
990
  });
991
991
  });
992
- req.on("error", () => resolve11([]));
992
+ req.on("error", () => resolve12([]));
993
993
  req.setTimeout(2e3, () => {
994
994
  req.destroy();
995
- resolve11([]);
995
+ resolve12([]);
996
996
  });
997
997
  });
998
998
  }
@@ -1032,7 +1032,7 @@ var init_manager = __esm({
1032
1032
  }
1033
1033
  }
1034
1034
  findTargetOnPort(port) {
1035
- return new Promise((resolve11) => {
1035
+ return new Promise((resolve12) => {
1036
1036
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
1037
1037
  let data = "";
1038
1038
  res.on("data", (chunk) => data += chunk.toString());
@@ -1043,7 +1043,7 @@ var init_manager = __esm({
1043
1043
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
1044
1044
  );
1045
1045
  if (pages.length === 0) {
1046
- resolve11(targets.find((t) => t.webSocketDebuggerUrl) || null);
1046
+ resolve12(targets.find((t) => t.webSocketDebuggerUrl) || null);
1047
1047
  return;
1048
1048
  }
1049
1049
  const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -1053,24 +1053,24 @@ var init_manager = __esm({
1053
1053
  const specific = list.find((t) => t.id === this._targetId);
1054
1054
  if (specific) {
1055
1055
  this._pageTitle = specific.title || "";
1056
- resolve11(specific);
1056
+ resolve12(specific);
1057
1057
  } else {
1058
1058
  this.log(`[CDP] Target ${this._targetId} not found in page list`);
1059
- resolve11(null);
1059
+ resolve12(null);
1060
1060
  }
1061
1061
  return;
1062
1062
  }
1063
1063
  this._pageTitle = list[0]?.title || "";
1064
- resolve11(list[0]);
1064
+ resolve12(list[0]);
1065
1065
  } catch {
1066
- resolve11(null);
1066
+ resolve12(null);
1067
1067
  }
1068
1068
  });
1069
1069
  });
1070
- req.on("error", () => resolve11(null));
1070
+ req.on("error", () => resolve12(null));
1071
1071
  req.setTimeout(2e3, () => {
1072
1072
  req.destroy();
1073
- resolve11(null);
1073
+ resolve12(null);
1074
1074
  });
1075
1075
  });
1076
1076
  }
@@ -1081,7 +1081,7 @@ var init_manager = __esm({
1081
1081
  this.extensionProviders = providers;
1082
1082
  }
1083
1083
  connectToTarget(wsUrl) {
1084
- return new Promise((resolve11) => {
1084
+ return new Promise((resolve12) => {
1085
1085
  this.ws = new import_ws.default(wsUrl);
1086
1086
  this.ws.on("open", async () => {
1087
1087
  this._connected = true;
@@ -1091,17 +1091,17 @@ var init_manager = __esm({
1091
1091
  }
1092
1092
  this.connectBrowserWs().catch(() => {
1093
1093
  });
1094
- resolve11(true);
1094
+ resolve12(true);
1095
1095
  });
1096
1096
  this.ws.on("message", (data) => {
1097
1097
  try {
1098
1098
  const msg = JSON.parse(data.toString());
1099
1099
  if (msg.id && this.pending.has(msg.id)) {
1100
- const { resolve: resolve12, reject } = this.pending.get(msg.id);
1100
+ const { resolve: resolve13, reject } = this.pending.get(msg.id);
1101
1101
  this.pending.delete(msg.id);
1102
1102
  this.failureCount = 0;
1103
1103
  if (msg.error) reject(new Error(msg.error.message));
1104
- else resolve12(msg.result);
1104
+ else resolve13(msg.result);
1105
1105
  } else if (msg.method === "Runtime.executionContextCreated") {
1106
1106
  this.contexts.add(msg.params.context.id);
1107
1107
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -1124,7 +1124,7 @@ var init_manager = __esm({
1124
1124
  this.ws.on("error", (err) => {
1125
1125
  this.log(`[CDP] WebSocket error: ${err.message}`);
1126
1126
  this._connected = false;
1127
- resolve11(false);
1127
+ resolve12(false);
1128
1128
  });
1129
1129
  });
1130
1130
  }
@@ -1138,7 +1138,7 @@ var init_manager = __esm({
1138
1138
  return;
1139
1139
  }
1140
1140
  this.log(`[CDP] Connecting browser WS for target discovery...`);
1141
- await new Promise((resolve11, reject) => {
1141
+ await new Promise((resolve12, reject) => {
1142
1142
  this.browserWs = new import_ws.default(browserWsUrl);
1143
1143
  this.browserWs.on("open", async () => {
1144
1144
  this._browserConnected = true;
@@ -1148,16 +1148,16 @@ var init_manager = __esm({
1148
1148
  } catch (e) {
1149
1149
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
1150
1150
  }
1151
- resolve11();
1151
+ resolve12();
1152
1152
  });
1153
1153
  this.browserWs.on("message", (data) => {
1154
1154
  try {
1155
1155
  const msg = JSON.parse(data.toString());
1156
1156
  if (msg.id && this.browserPending.has(msg.id)) {
1157
- const { resolve: resolve12, reject: reject2 } = this.browserPending.get(msg.id);
1157
+ const { resolve: resolve13, reject: reject2 } = this.browserPending.get(msg.id);
1158
1158
  this.browserPending.delete(msg.id);
1159
1159
  if (msg.error) reject2(new Error(msg.error.message));
1160
- else resolve12(msg.result);
1160
+ else resolve13(msg.result);
1161
1161
  }
1162
1162
  } catch {
1163
1163
  }
@@ -1177,31 +1177,31 @@ var init_manager = __esm({
1177
1177
  }
1178
1178
  }
1179
1179
  getBrowserWsUrl() {
1180
- return new Promise((resolve11) => {
1180
+ return new Promise((resolve12) => {
1181
1181
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
1182
1182
  let data = "";
1183
1183
  res.on("data", (chunk) => data += chunk.toString());
1184
1184
  res.on("end", () => {
1185
1185
  try {
1186
1186
  const info = JSON.parse(data);
1187
- resolve11(info.webSocketDebuggerUrl || null);
1187
+ resolve12(info.webSocketDebuggerUrl || null);
1188
1188
  } catch {
1189
- resolve11(null);
1189
+ resolve12(null);
1190
1190
  }
1191
1191
  });
1192
1192
  });
1193
- req.on("error", () => resolve11(null));
1193
+ req.on("error", () => resolve12(null));
1194
1194
  req.setTimeout(3e3, () => {
1195
1195
  req.destroy();
1196
- resolve11(null);
1196
+ resolve12(null);
1197
1197
  });
1198
1198
  });
1199
1199
  }
1200
1200
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
1201
- return new Promise((resolve11, reject) => {
1201
+ return new Promise((resolve12, reject) => {
1202
1202
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
1203
1203
  const id = this.browserMsgId++;
1204
- this.browserPending.set(id, { resolve: resolve11, reject });
1204
+ this.browserPending.set(id, { resolve: resolve12, reject });
1205
1205
  this.browserWs.send(JSON.stringify({ id, method, params }));
1206
1206
  setTimeout(() => {
1207
1207
  if (this.browserPending.has(id)) {
@@ -1241,11 +1241,11 @@ var init_manager = __esm({
1241
1241
  }
1242
1242
  // ─── CDP Protocol ────────────────────────────────────────
1243
1243
  sendInternal(method, params = {}, timeoutMs = 15e3) {
1244
- return new Promise((resolve11, reject) => {
1244
+ return new Promise((resolve12, reject) => {
1245
1245
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
1246
1246
  if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
1247
1247
  const id = this.msgId++;
1248
- this.pending.set(id, { resolve: resolve11, reject });
1248
+ this.pending.set(id, { resolve: resolve12, reject });
1249
1249
  this.ws.send(JSON.stringify({ id, method, params }));
1250
1250
  setTimeout(() => {
1251
1251
  if (this.pending.has(id)) {
@@ -1494,7 +1494,7 @@ var init_manager = __esm({
1494
1494
  const browserWs = this.browserWs;
1495
1495
  let msgId = this.browserMsgId;
1496
1496
  const sendWs = (method, params = {}, sessionId) => {
1497
- return new Promise((resolve11, reject) => {
1497
+ return new Promise((resolve12, reject) => {
1498
1498
  const mid = msgId++;
1499
1499
  this.browserMsgId = msgId;
1500
1500
  const handler = (raw) => {
@@ -1503,7 +1503,7 @@ var init_manager = __esm({
1503
1503
  if (msg.id === mid) {
1504
1504
  browserWs.removeListener("message", handler);
1505
1505
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
1506
- else resolve11(msg.result);
1506
+ else resolve12(msg.result);
1507
1507
  }
1508
1508
  } catch {
1509
1509
  }
@@ -1694,14 +1694,14 @@ var init_manager = __esm({
1694
1694
  if (!ws2 || ws2.readyState !== import_ws.default.OPEN) {
1695
1695
  throw new Error("CDP not connected");
1696
1696
  }
1697
- return new Promise((resolve11, reject) => {
1697
+ return new Promise((resolve12, reject) => {
1698
1698
  const id = getNextId();
1699
1699
  pendingMap.set(id, {
1700
1700
  resolve: (result) => {
1701
1701
  if (result?.result?.subtype === "error") {
1702
1702
  reject(new Error(result.result.description));
1703
1703
  } else {
1704
- resolve11(result?.result?.value);
1704
+ resolve12(result?.result?.value);
1705
1705
  }
1706
1706
  },
1707
1707
  reject
@@ -1733,10 +1733,10 @@ var init_manager = __esm({
1733
1733
  throw new Error("CDP not connected");
1734
1734
  }
1735
1735
  const sendViaSession = (method, params = {}) => {
1736
- return new Promise((resolve11, reject) => {
1736
+ return new Promise((resolve12, reject) => {
1737
1737
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
1738
1738
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
1739
- pendingMap.set(id, { resolve: resolve11, reject });
1739
+ pendingMap.set(id, { resolve: resolve12, reject });
1740
1740
  ws2.send(JSON.stringify({ id, sessionId, method, params }));
1741
1741
  setTimeout(() => {
1742
1742
  if (pendingMap.has(id)) {
@@ -5475,7 +5475,7 @@ var init_handler = __esm({
5475
5475
  try {
5476
5476
  const http3 = await import("http");
5477
5477
  const postData = JSON.stringify(body);
5478
- const result = await new Promise((resolve11, reject) => {
5478
+ const result = await new Promise((resolve12, reject) => {
5479
5479
  const req = http3.request({
5480
5480
  hostname: "127.0.0.1",
5481
5481
  port: 19280,
@@ -5487,9 +5487,9 @@ var init_handler = __esm({
5487
5487
  res.on("data", (chunk) => data += chunk);
5488
5488
  res.on("end", () => {
5489
5489
  try {
5490
- resolve11(JSON.parse(data));
5490
+ resolve12(JSON.parse(data));
5491
5491
  } catch {
5492
- resolve11({ raw: data });
5492
+ resolve12({ raw: data });
5493
5493
  }
5494
5494
  });
5495
5495
  });
@@ -5507,15 +5507,15 @@ var init_handler = __esm({
5507
5507
  if (!providerType) return { success: false, error: "providerType required" };
5508
5508
  try {
5509
5509
  const http3 = await import("http");
5510
- const result = await new Promise((resolve11, reject) => {
5510
+ const result = await new Promise((resolve12, reject) => {
5511
5511
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
5512
5512
  let data = "";
5513
5513
  res.on("data", (chunk) => data += chunk);
5514
5514
  res.on("end", () => {
5515
5515
  try {
5516
- resolve11(JSON.parse(data));
5516
+ resolve12(JSON.parse(data));
5517
5517
  } catch {
5518
- resolve11({ raw: data });
5518
+ resolve12({ raw: data });
5519
5519
  }
5520
5520
  });
5521
5521
  }).on("error", reject);
@@ -5529,7 +5529,7 @@ var init_handler = __esm({
5529
5529
  try {
5530
5530
  const http3 = await import("http");
5531
5531
  const postData = JSON.stringify(args || {});
5532
- const result = await new Promise((resolve11, reject) => {
5532
+ const result = await new Promise((resolve12, reject) => {
5533
5533
  const req = http3.request({
5534
5534
  hostname: "127.0.0.1",
5535
5535
  port: 19280,
@@ -5541,9 +5541,9 @@ var init_handler = __esm({
5541
5541
  res.on("data", (chunk) => data += chunk);
5542
5542
  res.on("end", () => {
5543
5543
  try {
5544
- resolve11(JSON.parse(data));
5544
+ resolve12(JSON.parse(data));
5545
5545
  } catch {
5546
- resolve11({ raw: data });
5546
+ resolve12({ raw: data });
5547
5547
  }
5548
5548
  });
5549
5549
  });
@@ -5664,7 +5664,7 @@ var init_readdirp = __esm({
5664
5664
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
5665
5665
  const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
5666
5666
  if (wantBigintFsStats) {
5667
- this._stat = (path17) => statMethod(path17, { bigint: true });
5667
+ this._stat = (path18) => statMethod(path18, { bigint: true });
5668
5668
  } else {
5669
5669
  this._stat = statMethod;
5670
5670
  }
@@ -5689,8 +5689,8 @@ var init_readdirp = __esm({
5689
5689
  const par = this.parent;
5690
5690
  const fil = par && par.files;
5691
5691
  if (fil && fil.length > 0) {
5692
- const { path: path17, depth } = par;
5693
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path17));
5692
+ const { path: path18, depth } = par;
5693
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path18));
5694
5694
  const awaited = await Promise.all(slice);
5695
5695
  for (const entry of awaited) {
5696
5696
  if (!entry)
@@ -5730,20 +5730,20 @@ var init_readdirp = __esm({
5730
5730
  this.reading = false;
5731
5731
  }
5732
5732
  }
5733
- async _exploreDir(path17, depth) {
5733
+ async _exploreDir(path18, depth) {
5734
5734
  let files;
5735
5735
  try {
5736
- files = await (0, import_promises.readdir)(path17, this._rdOptions);
5736
+ files = await (0, import_promises.readdir)(path18, this._rdOptions);
5737
5737
  } catch (error48) {
5738
5738
  this._onError(error48);
5739
5739
  }
5740
- return { files, depth, path: path17 };
5740
+ return { files, depth, path: path18 };
5741
5741
  }
5742
- async _formatEntry(dirent, path17) {
5742
+ async _formatEntry(dirent, path18) {
5743
5743
  let entry;
5744
5744
  const basename7 = this._isDirent ? dirent.name : dirent;
5745
5745
  try {
5746
- const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path17, basename7));
5746
+ const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path18, basename7));
5747
5747
  entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
5748
5748
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
5749
5749
  } catch (err) {
@@ -5800,16 +5800,16 @@ var init_readdirp = __esm({
5800
5800
  });
5801
5801
 
5802
5802
  // ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
5803
- function createFsWatchInstance(path17, options, listener, errHandler, emitRaw) {
5803
+ function createFsWatchInstance(path18, options, listener, errHandler, emitRaw) {
5804
5804
  const handleEvent = (rawEvent, evPath) => {
5805
- listener(path17);
5806
- emitRaw(rawEvent, evPath, { watchedPath: path17 });
5807
- if (evPath && path17 !== evPath) {
5808
- fsWatchBroadcast(sp.resolve(path17, evPath), KEY_LISTENERS, sp.join(path17, evPath));
5805
+ listener(path18);
5806
+ emitRaw(rawEvent, evPath, { watchedPath: path18 });
5807
+ if (evPath && path18 !== evPath) {
5808
+ fsWatchBroadcast(sp.resolve(path18, evPath), KEY_LISTENERS, sp.join(path18, evPath));
5809
5809
  }
5810
5810
  };
5811
5811
  try {
5812
- return (0, import_node_fs.watch)(path17, {
5812
+ return (0, import_node_fs.watch)(path18, {
5813
5813
  persistent: options.persistent
5814
5814
  }, handleEvent);
5815
5815
  } catch (error48) {
@@ -6158,12 +6158,12 @@ var init_handler2 = __esm({
6158
6158
  listener(val1, val2, val3);
6159
6159
  });
6160
6160
  };
6161
- setFsWatchListener = (path17, fullPath, options, handlers) => {
6161
+ setFsWatchListener = (path18, fullPath, options, handlers) => {
6162
6162
  const { listener, errHandler, rawEmitter } = handlers;
6163
6163
  let cont = FsWatchInstances.get(fullPath);
6164
6164
  let watcher;
6165
6165
  if (!options.persistent) {
6166
- watcher = createFsWatchInstance(path17, options, listener, errHandler, rawEmitter);
6166
+ watcher = createFsWatchInstance(path18, options, listener, errHandler, rawEmitter);
6167
6167
  if (!watcher)
6168
6168
  return;
6169
6169
  return watcher.close.bind(watcher);
@@ -6174,7 +6174,7 @@ var init_handler2 = __esm({
6174
6174
  addAndConvert(cont, KEY_RAW, rawEmitter);
6175
6175
  } else {
6176
6176
  watcher = createFsWatchInstance(
6177
- path17,
6177
+ path18,
6178
6178
  options,
6179
6179
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
6180
6180
  errHandler,
@@ -6189,7 +6189,7 @@ var init_handler2 = __esm({
6189
6189
  cont.watcherUnusable = true;
6190
6190
  if (isWindows && error48.code === "EPERM") {
6191
6191
  try {
6192
- const fd = await (0, import_promises2.open)(path17, "r");
6192
+ const fd = await (0, import_promises2.open)(path18, "r");
6193
6193
  await fd.close();
6194
6194
  broadcastErr(error48);
6195
6195
  } catch (err) {
@@ -6220,7 +6220,7 @@ var init_handler2 = __esm({
6220
6220
  };
6221
6221
  };
6222
6222
  FsWatchFileInstances = /* @__PURE__ */ new Map();
6223
- setFsWatchFileListener = (path17, fullPath, options, handlers) => {
6223
+ setFsWatchFileListener = (path18, fullPath, options, handlers) => {
6224
6224
  const { listener, rawEmitter } = handlers;
6225
6225
  let cont = FsWatchFileInstances.get(fullPath);
6226
6226
  const copts = cont && cont.options;
@@ -6242,7 +6242,7 @@ var init_handler2 = __esm({
6242
6242
  });
6243
6243
  const currmtime = curr.mtimeMs;
6244
6244
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
6245
- foreach(cont.listeners, (listener2) => listener2(path17, curr));
6245
+ foreach(cont.listeners, (listener2) => listener2(path18, curr));
6246
6246
  }
6247
6247
  })
6248
6248
  };
@@ -6272,13 +6272,13 @@ var init_handler2 = __esm({
6272
6272
  * @param listener on fs change
6273
6273
  * @returns closer for the watcher instance
6274
6274
  */
6275
- _watchWithNodeFs(path17, listener) {
6275
+ _watchWithNodeFs(path18, listener) {
6276
6276
  const opts = this.fsw.options;
6277
- const directory = sp.dirname(path17);
6278
- const basename7 = sp.basename(path17);
6277
+ const directory = sp.dirname(path18);
6278
+ const basename7 = sp.basename(path18);
6279
6279
  const parent = this.fsw._getWatchedDir(directory);
6280
6280
  parent.add(basename7);
6281
- const absolutePath = sp.resolve(path17);
6281
+ const absolutePath = sp.resolve(path18);
6282
6282
  const options = {
6283
6283
  persistent: opts.persistent
6284
6284
  };
@@ -6288,12 +6288,12 @@ var init_handler2 = __esm({
6288
6288
  if (opts.usePolling) {
6289
6289
  const enableBin = opts.interval !== opts.binaryInterval;
6290
6290
  options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
6291
- closer = setFsWatchFileListener(path17, absolutePath, options, {
6291
+ closer = setFsWatchFileListener(path18, absolutePath, options, {
6292
6292
  listener,
6293
6293
  rawEmitter: this.fsw._emitRaw
6294
6294
  });
6295
6295
  } else {
6296
- closer = setFsWatchListener(path17, absolutePath, options, {
6296
+ closer = setFsWatchListener(path18, absolutePath, options, {
6297
6297
  listener,
6298
6298
  errHandler: this._boundHandleError,
6299
6299
  rawEmitter: this.fsw._emitRaw
@@ -6315,7 +6315,7 @@ var init_handler2 = __esm({
6315
6315
  let prevStats = stats;
6316
6316
  if (parent.has(basename7))
6317
6317
  return;
6318
- const listener = async (path17, newStats) => {
6318
+ const listener = async (path18, newStats) => {
6319
6319
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
6320
6320
  return;
6321
6321
  if (!newStats || newStats.mtimeMs === 0) {
@@ -6329,11 +6329,11 @@ var init_handler2 = __esm({
6329
6329
  this.fsw._emit(EV.CHANGE, file2, newStats2);
6330
6330
  }
6331
6331
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
6332
- this.fsw._closeFile(path17);
6332
+ this.fsw._closeFile(path18);
6333
6333
  prevStats = newStats2;
6334
6334
  const closer2 = this._watchWithNodeFs(file2, listener);
6335
6335
  if (closer2)
6336
- this.fsw._addPathCloser(path17, closer2);
6336
+ this.fsw._addPathCloser(path18, closer2);
6337
6337
  } else {
6338
6338
  prevStats = newStats2;
6339
6339
  }
@@ -6365,7 +6365,7 @@ var init_handler2 = __esm({
6365
6365
  * @param item basename of this item
6366
6366
  * @returns true if no more processing is needed for this entry.
6367
6367
  */
6368
- async _handleSymlink(entry, directory, path17, item) {
6368
+ async _handleSymlink(entry, directory, path18, item) {
6369
6369
  if (this.fsw.closed) {
6370
6370
  return;
6371
6371
  }
@@ -6375,7 +6375,7 @@ var init_handler2 = __esm({
6375
6375
  this.fsw._incrReadyCount();
6376
6376
  let linkPath;
6377
6377
  try {
6378
- linkPath = await (0, import_promises2.realpath)(path17);
6378
+ linkPath = await (0, import_promises2.realpath)(path18);
6379
6379
  } catch (e) {
6380
6380
  this.fsw._emitReady();
6381
6381
  return true;
@@ -6385,12 +6385,12 @@ var init_handler2 = __esm({
6385
6385
  if (dir.has(item)) {
6386
6386
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
6387
6387
  this.fsw._symlinkPaths.set(full, linkPath);
6388
- this.fsw._emit(EV.CHANGE, path17, entry.stats);
6388
+ this.fsw._emit(EV.CHANGE, path18, entry.stats);
6389
6389
  }
6390
6390
  } else {
6391
6391
  dir.add(item);
6392
6392
  this.fsw._symlinkPaths.set(full, linkPath);
6393
- this.fsw._emit(EV.ADD, path17, entry.stats);
6393
+ this.fsw._emit(EV.ADD, path18, entry.stats);
6394
6394
  }
6395
6395
  this.fsw._emitReady();
6396
6396
  return true;
@@ -6420,9 +6420,9 @@ var init_handler2 = __esm({
6420
6420
  return;
6421
6421
  }
6422
6422
  const item = entry.path;
6423
- let path17 = sp.join(directory, item);
6423
+ let path18 = sp.join(directory, item);
6424
6424
  current.add(item);
6425
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path17, item)) {
6425
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path18, item)) {
6426
6426
  return;
6427
6427
  }
6428
6428
  if (this.fsw.closed) {
@@ -6431,11 +6431,11 @@ var init_handler2 = __esm({
6431
6431
  }
6432
6432
  if (item === target || !target && !previous.has(item)) {
6433
6433
  this.fsw._incrReadyCount();
6434
- path17 = sp.join(dir, sp.relative(dir, path17));
6435
- this._addToNodeFs(path17, initialAdd, wh, depth + 1);
6434
+ path18 = sp.join(dir, sp.relative(dir, path18));
6435
+ this._addToNodeFs(path18, initialAdd, wh, depth + 1);
6436
6436
  }
6437
6437
  }).on(EV.ERROR, this._boundHandleError);
6438
- return new Promise((resolve11, reject) => {
6438
+ return new Promise((resolve12, reject) => {
6439
6439
  if (!stream)
6440
6440
  return reject();
6441
6441
  stream.once(STR_END, () => {
@@ -6444,7 +6444,7 @@ var init_handler2 = __esm({
6444
6444
  return;
6445
6445
  }
6446
6446
  const wasThrottled = throttler ? throttler.clear() : false;
6447
- resolve11(void 0);
6447
+ resolve12(void 0);
6448
6448
  previous.getChildren().filter((item) => {
6449
6449
  return item !== directory && !current.has(item);
6450
6450
  }).forEach((item) => {
@@ -6501,13 +6501,13 @@ var init_handler2 = __esm({
6501
6501
  * @param depth Child path actually targeted for watch
6502
6502
  * @param target Child path actually targeted for watch
6503
6503
  */
6504
- async _addToNodeFs(path17, initialAdd, priorWh, depth, target) {
6504
+ async _addToNodeFs(path18, initialAdd, priorWh, depth, target) {
6505
6505
  const ready = this.fsw._emitReady;
6506
- if (this.fsw._isIgnored(path17) || this.fsw.closed) {
6506
+ if (this.fsw._isIgnored(path18) || this.fsw.closed) {
6507
6507
  ready();
6508
6508
  return false;
6509
6509
  }
6510
- const wh = this.fsw._getWatchHelpers(path17);
6510
+ const wh = this.fsw._getWatchHelpers(path18);
6511
6511
  if (priorWh) {
6512
6512
  wh.filterPath = (entry) => priorWh.filterPath(entry);
6513
6513
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -6523,8 +6523,8 @@ var init_handler2 = __esm({
6523
6523
  const follow = this.fsw.options.followSymlinks;
6524
6524
  let closer;
6525
6525
  if (stats.isDirectory()) {
6526
- const absPath = sp.resolve(path17);
6527
- const targetPath = follow ? await (0, import_promises2.realpath)(path17) : path17;
6526
+ const absPath = sp.resolve(path18);
6527
+ const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
6528
6528
  if (this.fsw.closed)
6529
6529
  return;
6530
6530
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -6534,29 +6534,29 @@ var init_handler2 = __esm({
6534
6534
  this.fsw._symlinkPaths.set(absPath, targetPath);
6535
6535
  }
6536
6536
  } else if (stats.isSymbolicLink()) {
6537
- const targetPath = follow ? await (0, import_promises2.realpath)(path17) : path17;
6537
+ const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
6538
6538
  if (this.fsw.closed)
6539
6539
  return;
6540
6540
  const parent = sp.dirname(wh.watchPath);
6541
6541
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
6542
6542
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
6543
- closer = await this._handleDir(parent, stats, initialAdd, depth, path17, wh, targetPath);
6543
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path18, wh, targetPath);
6544
6544
  if (this.fsw.closed)
6545
6545
  return;
6546
6546
  if (targetPath !== void 0) {
6547
- this.fsw._symlinkPaths.set(sp.resolve(path17), targetPath);
6547
+ this.fsw._symlinkPaths.set(sp.resolve(path18), targetPath);
6548
6548
  }
6549
6549
  } else {
6550
6550
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
6551
6551
  }
6552
6552
  ready();
6553
6553
  if (closer)
6554
- this.fsw._addPathCloser(path17, closer);
6554
+ this.fsw._addPathCloser(path18, closer);
6555
6555
  return false;
6556
6556
  } catch (error48) {
6557
6557
  if (this.fsw._handleError(error48)) {
6558
6558
  ready();
6559
- return path17;
6559
+ return path18;
6560
6560
  }
6561
6561
  }
6562
6562
  }
@@ -6591,24 +6591,24 @@ function createPattern(matcher) {
6591
6591
  }
6592
6592
  return () => false;
6593
6593
  }
6594
- function normalizePath(path17) {
6595
- if (typeof path17 !== "string")
6594
+ function normalizePath(path18) {
6595
+ if (typeof path18 !== "string")
6596
6596
  throw new Error("string expected");
6597
- path17 = sp2.normalize(path17);
6598
- path17 = path17.replace(/\\/g, "/");
6597
+ path18 = sp2.normalize(path18);
6598
+ path18 = path18.replace(/\\/g, "/");
6599
6599
  let prepend = false;
6600
- if (path17.startsWith("//"))
6600
+ if (path18.startsWith("//"))
6601
6601
  prepend = true;
6602
- path17 = path17.replace(DOUBLE_SLASH_RE, "/");
6602
+ path18 = path18.replace(DOUBLE_SLASH_RE, "/");
6603
6603
  if (prepend)
6604
- path17 = "/" + path17;
6605
- return path17;
6604
+ path18 = "/" + path18;
6605
+ return path18;
6606
6606
  }
6607
6607
  function matchPatterns(patterns, testString, stats) {
6608
- const path17 = normalizePath(testString);
6608
+ const path18 = normalizePath(testString);
6609
6609
  for (let index = 0; index < patterns.length; index++) {
6610
6610
  const pattern = patterns[index];
6611
- if (pattern(path17, stats)) {
6611
+ if (pattern(path18, stats)) {
6612
6612
  return true;
6613
6613
  }
6614
6614
  }
@@ -6671,19 +6671,19 @@ var init_chokidar = __esm({
6671
6671
  }
6672
6672
  return str;
6673
6673
  };
6674
- normalizePathToUnix = (path17) => toUnix(sp2.normalize(toUnix(path17)));
6675
- normalizeIgnored = (cwd = "") => (path17) => {
6676
- if (typeof path17 === "string") {
6677
- return normalizePathToUnix(sp2.isAbsolute(path17) ? path17 : sp2.join(cwd, path17));
6674
+ normalizePathToUnix = (path18) => toUnix(sp2.normalize(toUnix(path18)));
6675
+ normalizeIgnored = (cwd = "") => (path18) => {
6676
+ if (typeof path18 === "string") {
6677
+ return normalizePathToUnix(sp2.isAbsolute(path18) ? path18 : sp2.join(cwd, path18));
6678
6678
  } else {
6679
- return path17;
6679
+ return path18;
6680
6680
  }
6681
6681
  };
6682
- getAbsolutePath = (path17, cwd) => {
6683
- if (sp2.isAbsolute(path17)) {
6684
- return path17;
6682
+ getAbsolutePath = (path18, cwd) => {
6683
+ if (sp2.isAbsolute(path18)) {
6684
+ return path18;
6685
6685
  }
6686
- return sp2.join(cwd, path17);
6686
+ return sp2.join(cwd, path18);
6687
6687
  };
6688
6688
  EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
6689
6689
  DirEntry = class {
@@ -6748,10 +6748,10 @@ var init_chokidar = __esm({
6748
6748
  dirParts;
6749
6749
  followSymlinks;
6750
6750
  statMethod;
6751
- constructor(path17, follow, fsw) {
6751
+ constructor(path18, follow, fsw) {
6752
6752
  this.fsw = fsw;
6753
- const watchPath = path17;
6754
- this.path = path17 = path17.replace(REPLACER_RE, "");
6753
+ const watchPath = path18;
6754
+ this.path = path18 = path18.replace(REPLACER_RE, "");
6755
6755
  this.watchPath = watchPath;
6756
6756
  this.fullWatchPath = sp2.resolve(watchPath);
6757
6757
  this.dirParts = [];
@@ -6891,20 +6891,20 @@ var init_chokidar = __esm({
6891
6891
  this._closePromise = void 0;
6892
6892
  let paths = unifyPaths(paths_);
6893
6893
  if (cwd) {
6894
- paths = paths.map((path17) => {
6895
- const absPath = getAbsolutePath(path17, cwd);
6894
+ paths = paths.map((path18) => {
6895
+ const absPath = getAbsolutePath(path18, cwd);
6896
6896
  return absPath;
6897
6897
  });
6898
6898
  }
6899
- paths.forEach((path17) => {
6900
- this._removeIgnoredPath(path17);
6899
+ paths.forEach((path18) => {
6900
+ this._removeIgnoredPath(path18);
6901
6901
  });
6902
6902
  this._userIgnored = void 0;
6903
6903
  if (!this._readyCount)
6904
6904
  this._readyCount = 0;
6905
6905
  this._readyCount += paths.length;
6906
- Promise.all(paths.map(async (path17) => {
6907
- const res = await this._nodeFsHandler._addToNodeFs(path17, !_internal, void 0, 0, _origAdd);
6906
+ Promise.all(paths.map(async (path18) => {
6907
+ const res = await this._nodeFsHandler._addToNodeFs(path18, !_internal, void 0, 0, _origAdd);
6908
6908
  if (res)
6909
6909
  this._emitReady();
6910
6910
  return res;
@@ -6926,17 +6926,17 @@ var init_chokidar = __esm({
6926
6926
  return this;
6927
6927
  const paths = unifyPaths(paths_);
6928
6928
  const { cwd } = this.options;
6929
- paths.forEach((path17) => {
6930
- if (!sp2.isAbsolute(path17) && !this._closers.has(path17)) {
6929
+ paths.forEach((path18) => {
6930
+ if (!sp2.isAbsolute(path18) && !this._closers.has(path18)) {
6931
6931
  if (cwd)
6932
- path17 = sp2.join(cwd, path17);
6933
- path17 = sp2.resolve(path17);
6932
+ path18 = sp2.join(cwd, path18);
6933
+ path18 = sp2.resolve(path18);
6934
6934
  }
6935
- this._closePath(path17);
6936
- this._addIgnoredPath(path17);
6937
- if (this._watched.has(path17)) {
6935
+ this._closePath(path18);
6936
+ this._addIgnoredPath(path18);
6937
+ if (this._watched.has(path18)) {
6938
6938
  this._addIgnoredPath({
6939
- path: path17,
6939
+ path: path18,
6940
6940
  recursive: true
6941
6941
  });
6942
6942
  }
@@ -7000,38 +7000,38 @@ var init_chokidar = __esm({
7000
7000
  * @param stats arguments to be passed with event
7001
7001
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
7002
7002
  */
7003
- async _emit(event, path17, stats) {
7003
+ async _emit(event, path18, stats) {
7004
7004
  if (this.closed)
7005
7005
  return;
7006
7006
  const opts = this.options;
7007
7007
  if (isWindows)
7008
- path17 = sp2.normalize(path17);
7008
+ path18 = sp2.normalize(path18);
7009
7009
  if (opts.cwd)
7010
- path17 = sp2.relative(opts.cwd, path17);
7011
- const args = [path17];
7010
+ path18 = sp2.relative(opts.cwd, path18);
7011
+ const args = [path18];
7012
7012
  if (stats != null)
7013
7013
  args.push(stats);
7014
7014
  const awf = opts.awaitWriteFinish;
7015
7015
  let pw;
7016
- if (awf && (pw = this._pendingWrites.get(path17))) {
7016
+ if (awf && (pw = this._pendingWrites.get(path18))) {
7017
7017
  pw.lastChange = /* @__PURE__ */ new Date();
7018
7018
  return this;
7019
7019
  }
7020
7020
  if (opts.atomic) {
7021
7021
  if (event === EVENTS.UNLINK) {
7022
- this._pendingUnlinks.set(path17, [event, ...args]);
7022
+ this._pendingUnlinks.set(path18, [event, ...args]);
7023
7023
  setTimeout(() => {
7024
- this._pendingUnlinks.forEach((entry, path18) => {
7024
+ this._pendingUnlinks.forEach((entry, path19) => {
7025
7025
  this.emit(...entry);
7026
7026
  this.emit(EVENTS.ALL, ...entry);
7027
- this._pendingUnlinks.delete(path18);
7027
+ this._pendingUnlinks.delete(path19);
7028
7028
  });
7029
7029
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
7030
7030
  return this;
7031
7031
  }
7032
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path17)) {
7032
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path18)) {
7033
7033
  event = EVENTS.CHANGE;
7034
- this._pendingUnlinks.delete(path17);
7034
+ this._pendingUnlinks.delete(path18);
7035
7035
  }
7036
7036
  }
7037
7037
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -7049,16 +7049,16 @@ var init_chokidar = __esm({
7049
7049
  this.emitWithAll(event, args);
7050
7050
  }
7051
7051
  };
7052
- this._awaitWriteFinish(path17, awf.stabilityThreshold, event, awfEmit);
7052
+ this._awaitWriteFinish(path18, awf.stabilityThreshold, event, awfEmit);
7053
7053
  return this;
7054
7054
  }
7055
7055
  if (event === EVENTS.CHANGE) {
7056
- const isThrottled = !this._throttle(EVENTS.CHANGE, path17, 50);
7056
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path18, 50);
7057
7057
  if (isThrottled)
7058
7058
  return this;
7059
7059
  }
7060
7060
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
7061
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path17) : path17;
7061
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path18) : path18;
7062
7062
  let stats2;
7063
7063
  try {
7064
7064
  stats2 = await (0, import_promises3.stat)(fullPath);
@@ -7089,23 +7089,23 @@ var init_chokidar = __esm({
7089
7089
  * @param timeout duration of time to suppress duplicate actions
7090
7090
  * @returns tracking object or false if action should be suppressed
7091
7091
  */
7092
- _throttle(actionType, path17, timeout) {
7092
+ _throttle(actionType, path18, timeout) {
7093
7093
  if (!this._throttled.has(actionType)) {
7094
7094
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
7095
7095
  }
7096
7096
  const action = this._throttled.get(actionType);
7097
7097
  if (!action)
7098
7098
  throw new Error("invalid throttle");
7099
- const actionPath = action.get(path17);
7099
+ const actionPath = action.get(path18);
7100
7100
  if (actionPath) {
7101
7101
  actionPath.count++;
7102
7102
  return false;
7103
7103
  }
7104
7104
  let timeoutObject;
7105
7105
  const clear = () => {
7106
- const item = action.get(path17);
7106
+ const item = action.get(path18);
7107
7107
  const count = item ? item.count : 0;
7108
- action.delete(path17);
7108
+ action.delete(path18);
7109
7109
  clearTimeout(timeoutObject);
7110
7110
  if (item)
7111
7111
  clearTimeout(item.timeoutObject);
@@ -7113,7 +7113,7 @@ var init_chokidar = __esm({
7113
7113
  };
7114
7114
  timeoutObject = setTimeout(clear, timeout);
7115
7115
  const thr = { timeoutObject, clear, count: 0 };
7116
- action.set(path17, thr);
7116
+ action.set(path18, thr);
7117
7117
  return thr;
7118
7118
  }
7119
7119
  _incrReadyCount() {
@@ -7127,44 +7127,44 @@ var init_chokidar = __esm({
7127
7127
  * @param event
7128
7128
  * @param awfEmit Callback to be called when ready for event to be emitted.
7129
7129
  */
7130
- _awaitWriteFinish(path17, threshold, event, awfEmit) {
7130
+ _awaitWriteFinish(path18, threshold, event, awfEmit) {
7131
7131
  const awf = this.options.awaitWriteFinish;
7132
7132
  if (typeof awf !== "object")
7133
7133
  return;
7134
7134
  const pollInterval = awf.pollInterval;
7135
7135
  let timeoutHandler;
7136
- let fullPath = path17;
7137
- if (this.options.cwd && !sp2.isAbsolute(path17)) {
7138
- fullPath = sp2.join(this.options.cwd, path17);
7136
+ let fullPath = path18;
7137
+ if (this.options.cwd && !sp2.isAbsolute(path18)) {
7138
+ fullPath = sp2.join(this.options.cwd, path18);
7139
7139
  }
7140
7140
  const now = /* @__PURE__ */ new Date();
7141
7141
  const writes = this._pendingWrites;
7142
7142
  function awaitWriteFinishFn(prevStat) {
7143
7143
  (0, import_node_fs2.stat)(fullPath, (err, curStat) => {
7144
- if (err || !writes.has(path17)) {
7144
+ if (err || !writes.has(path18)) {
7145
7145
  if (err && err.code !== "ENOENT")
7146
7146
  awfEmit(err);
7147
7147
  return;
7148
7148
  }
7149
7149
  const now2 = Number(/* @__PURE__ */ new Date());
7150
7150
  if (prevStat && curStat.size !== prevStat.size) {
7151
- writes.get(path17).lastChange = now2;
7151
+ writes.get(path18).lastChange = now2;
7152
7152
  }
7153
- const pw = writes.get(path17);
7153
+ const pw = writes.get(path18);
7154
7154
  const df = now2 - pw.lastChange;
7155
7155
  if (df >= threshold) {
7156
- writes.delete(path17);
7156
+ writes.delete(path18);
7157
7157
  awfEmit(void 0, curStat);
7158
7158
  } else {
7159
7159
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
7160
7160
  }
7161
7161
  });
7162
7162
  }
7163
- if (!writes.has(path17)) {
7164
- writes.set(path17, {
7163
+ if (!writes.has(path18)) {
7164
+ writes.set(path18, {
7165
7165
  lastChange: now,
7166
7166
  cancelWait: () => {
7167
- writes.delete(path17);
7167
+ writes.delete(path18);
7168
7168
  clearTimeout(timeoutHandler);
7169
7169
  return event;
7170
7170
  }
@@ -7175,8 +7175,8 @@ var init_chokidar = __esm({
7175
7175
  /**
7176
7176
  * Determines whether user has asked to ignore this path.
7177
7177
  */
7178
- _isIgnored(path17, stats) {
7179
- if (this.options.atomic && DOT_RE.test(path17))
7178
+ _isIgnored(path18, stats) {
7179
+ if (this.options.atomic && DOT_RE.test(path18))
7180
7180
  return true;
7181
7181
  if (!this._userIgnored) {
7182
7182
  const { cwd } = this.options;
@@ -7186,17 +7186,17 @@ var init_chokidar = __esm({
7186
7186
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
7187
7187
  this._userIgnored = anymatch(list, void 0);
7188
7188
  }
7189
- return this._userIgnored(path17, stats);
7189
+ return this._userIgnored(path18, stats);
7190
7190
  }
7191
- _isntIgnored(path17, stat4) {
7192
- return !this._isIgnored(path17, stat4);
7191
+ _isntIgnored(path18, stat4) {
7192
+ return !this._isIgnored(path18, stat4);
7193
7193
  }
7194
7194
  /**
7195
7195
  * Provides a set of common helpers and properties relating to symlink handling.
7196
7196
  * @param path file or directory pattern being watched
7197
7197
  */
7198
- _getWatchHelpers(path17) {
7199
- return new WatchHelper(path17, this.options.followSymlinks, this);
7198
+ _getWatchHelpers(path18) {
7199
+ return new WatchHelper(path18, this.options.followSymlinks, this);
7200
7200
  }
7201
7201
  // Directory helpers
7202
7202
  // -----------------
@@ -7228,63 +7228,63 @@ var init_chokidar = __esm({
7228
7228
  * @param item base path of item/directory
7229
7229
  */
7230
7230
  _remove(directory, item, isDirectory) {
7231
- const path17 = sp2.join(directory, item);
7232
- const fullPath = sp2.resolve(path17);
7233
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path17) || this._watched.has(fullPath);
7234
- if (!this._throttle("remove", path17, 100))
7231
+ const path18 = sp2.join(directory, item);
7232
+ const fullPath = sp2.resolve(path18);
7233
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path18) || this._watched.has(fullPath);
7234
+ if (!this._throttle("remove", path18, 100))
7235
7235
  return;
7236
7236
  if (!isDirectory && this._watched.size === 1) {
7237
7237
  this.add(directory, item, true);
7238
7238
  }
7239
- const wp = this._getWatchedDir(path17);
7239
+ const wp = this._getWatchedDir(path18);
7240
7240
  const nestedDirectoryChildren = wp.getChildren();
7241
- nestedDirectoryChildren.forEach((nested) => this._remove(path17, nested));
7241
+ nestedDirectoryChildren.forEach((nested) => this._remove(path18, nested));
7242
7242
  const parent = this._getWatchedDir(directory);
7243
7243
  const wasTracked = parent.has(item);
7244
7244
  parent.remove(item);
7245
7245
  if (this._symlinkPaths.has(fullPath)) {
7246
7246
  this._symlinkPaths.delete(fullPath);
7247
7247
  }
7248
- let relPath = path17;
7248
+ let relPath = path18;
7249
7249
  if (this.options.cwd)
7250
- relPath = sp2.relative(this.options.cwd, path17);
7250
+ relPath = sp2.relative(this.options.cwd, path18);
7251
7251
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
7252
7252
  const event = this._pendingWrites.get(relPath).cancelWait();
7253
7253
  if (event === EVENTS.ADD)
7254
7254
  return;
7255
7255
  }
7256
- this._watched.delete(path17);
7256
+ this._watched.delete(path18);
7257
7257
  this._watched.delete(fullPath);
7258
7258
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
7259
- if (wasTracked && !this._isIgnored(path17))
7260
- this._emit(eventName, path17);
7261
- this._closePath(path17);
7259
+ if (wasTracked && !this._isIgnored(path18))
7260
+ this._emit(eventName, path18);
7261
+ this._closePath(path18);
7262
7262
  }
7263
7263
  /**
7264
7264
  * Closes all watchers for a path
7265
7265
  */
7266
- _closePath(path17) {
7267
- this._closeFile(path17);
7268
- const dir = sp2.dirname(path17);
7269
- this._getWatchedDir(dir).remove(sp2.basename(path17));
7266
+ _closePath(path18) {
7267
+ this._closeFile(path18);
7268
+ const dir = sp2.dirname(path18);
7269
+ this._getWatchedDir(dir).remove(sp2.basename(path18));
7270
7270
  }
7271
7271
  /**
7272
7272
  * Closes only file-specific watchers
7273
7273
  */
7274
- _closeFile(path17) {
7275
- const closers = this._closers.get(path17);
7274
+ _closeFile(path18) {
7275
+ const closers = this._closers.get(path18);
7276
7276
  if (!closers)
7277
7277
  return;
7278
7278
  closers.forEach((closer) => closer());
7279
- this._closers.delete(path17);
7279
+ this._closers.delete(path18);
7280
7280
  }
7281
- _addPathCloser(path17, closer) {
7281
+ _addPathCloser(path18, closer) {
7282
7282
  if (!closer)
7283
7283
  return;
7284
- let list = this._closers.get(path17);
7284
+ let list = this._closers.get(path18);
7285
7285
  if (!list) {
7286
7286
  list = [];
7287
- this._closers.set(path17, list);
7287
+ this._closers.set(path18, list);
7288
7288
  }
7289
7289
  list.push(closer);
7290
7290
  }
@@ -7864,7 +7864,7 @@ var init_provider_loader = __esm({
7864
7864
  return { updated: false };
7865
7865
  }
7866
7866
  try {
7867
- const etag = await new Promise((resolve11, reject) => {
7867
+ const etag = await new Promise((resolve12, reject) => {
7868
7868
  const options = {
7869
7869
  method: "HEAD",
7870
7870
  hostname: "github.com",
@@ -7882,7 +7882,7 @@ var init_provider_loader = __esm({
7882
7882
  headers: { "User-Agent": "adhdev-launcher" },
7883
7883
  timeout: 1e4
7884
7884
  }, (res2) => {
7885
- resolve11(res2.headers.etag || res2.headers["last-modified"] || "");
7885
+ resolve12(res2.headers.etag || res2.headers["last-modified"] || "");
7886
7886
  });
7887
7887
  req2.on("error", reject);
7888
7888
  req2.on("timeout", () => {
@@ -7891,7 +7891,7 @@ var init_provider_loader = __esm({
7891
7891
  });
7892
7892
  req2.end();
7893
7893
  } else {
7894
- resolve11(res.headers.etag || res.headers["last-modified"] || "");
7894
+ resolve12(res.headers.etag || res.headers["last-modified"] || "");
7895
7895
  }
7896
7896
  });
7897
7897
  req.on("error", reject);
@@ -7955,7 +7955,7 @@ var init_provider_loader = __esm({
7955
7955
  downloadFile(url2, destPath) {
7956
7956
  const https = require("https");
7957
7957
  const http3 = require("http");
7958
- return new Promise((resolve11, reject) => {
7958
+ return new Promise((resolve12, reject) => {
7959
7959
  const doRequest = (reqUrl, redirectCount = 0) => {
7960
7960
  if (redirectCount > 5) {
7961
7961
  reject(new Error("Too many redirects"));
@@ -7975,7 +7975,7 @@ var init_provider_loader = __esm({
7975
7975
  res.pipe(ws2);
7976
7976
  ws2.on("finish", () => {
7977
7977
  ws2.close();
7978
- resolve11();
7978
+ resolve12();
7979
7979
  });
7980
7980
  ws2.on("error", reject);
7981
7981
  });
@@ -8341,17 +8341,17 @@ async function findFreePort(ports) {
8341
8341
  throw new Error("No free port found");
8342
8342
  }
8343
8343
  function checkPortFree(port) {
8344
- return new Promise((resolve11) => {
8344
+ return new Promise((resolve12) => {
8345
8345
  const server = net.createServer();
8346
8346
  server.unref();
8347
- server.on("error", () => resolve11(false));
8347
+ server.on("error", () => resolve12(false));
8348
8348
  server.listen(port, "127.0.0.1", () => {
8349
- server.close(() => resolve11(true));
8349
+ server.close(() => resolve12(true));
8350
8350
  });
8351
8351
  });
8352
8352
  }
8353
8353
  async function isCdpActive(port) {
8354
- return new Promise((resolve11) => {
8354
+ return new Promise((resolve12) => {
8355
8355
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
8356
8356
  timeout: 2e3
8357
8357
  }, (res) => {
@@ -8360,16 +8360,16 @@ async function isCdpActive(port) {
8360
8360
  res.on("end", () => {
8361
8361
  try {
8362
8362
  const info = JSON.parse(data);
8363
- resolve11(!!info["WebKit-Version"] || !!info["Browser"]);
8363
+ resolve12(!!info["WebKit-Version"] || !!info["Browser"]);
8364
8364
  } catch {
8365
- resolve11(false);
8365
+ resolve12(false);
8366
8366
  }
8367
8367
  });
8368
8368
  });
8369
- req.on("error", () => resolve11(false));
8369
+ req.on("error", () => resolve12(false));
8370
8370
  req.on("timeout", () => {
8371
8371
  req.destroy();
8372
- resolve11(false);
8372
+ resolve12(false);
8373
8373
  });
8374
8374
  });
8375
8375
  }
@@ -9020,14 +9020,14 @@ var init_router = __esm({
9020
9020
  setTimeout(() => {
9021
9021
  LOG.info("Upgrade", "Restarting daemon with new version...");
9022
9022
  try {
9023
- const path17 = require("path");
9023
+ const path18 = require("path");
9024
9024
  const fs15 = require("fs");
9025
- const pidFile = path17.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
9025
+ const pidFile = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
9026
9026
  if (fs15.existsSync(pidFile)) fs15.unlinkSync(pidFile);
9027
9027
  } catch {
9028
9028
  }
9029
- const { spawn: spawn3 } = require("child_process");
9030
- const child = spawn3(process.execPath, process.argv.slice(1), {
9029
+ const { spawn: spawn4 } = require("child_process");
9030
+ const child = spawn4(process.execPath, process.argv.slice(1), {
9031
9031
  detached: true,
9032
9032
  stdio: "ignore",
9033
9033
  env: { ...process.env }
@@ -19522,7 +19522,7 @@ ${data.message || ""}`.trim();
19522
19522
  if (this.startupParseGate) {
19523
19523
  const deadline = Date.now() + 1e4;
19524
19524
  while (this.startupParseGate && Date.now() < deadline) {
19525
- await new Promise((resolve11) => setTimeout(resolve11, 50));
19525
+ await new Promise((resolve12) => setTimeout(resolve12, 50));
19526
19526
  }
19527
19527
  }
19528
19528
  if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
@@ -19690,17 +19690,17 @@ ${data.message || ""}`.trim();
19690
19690
  }
19691
19691
  }
19692
19692
  waitForStopped(timeoutMs) {
19693
- return new Promise((resolve11) => {
19693
+ return new Promise((resolve12) => {
19694
19694
  const startedAt = Date.now();
19695
19695
  const timer = setInterval(() => {
19696
19696
  if (!this.ptyProcess || this.currentStatus === "stopped") {
19697
19697
  clearInterval(timer);
19698
- resolve11(true);
19698
+ resolve12(true);
19699
19699
  return;
19700
19700
  }
19701
19701
  if (Date.now() - startedAt >= timeoutMs) {
19702
19702
  clearInterval(timer);
19703
- resolve11(false);
19703
+ resolve12(false);
19704
19704
  }
19705
19705
  }, 100);
19706
19706
  });
@@ -20386,10 +20386,10 @@ function mergeDefs(...defs) {
20386
20386
  function cloneDef(schema) {
20387
20387
  return mergeDefs(schema._zod.def);
20388
20388
  }
20389
- function getElementAtPath(obj, path17) {
20390
- if (!path17)
20389
+ function getElementAtPath(obj, path18) {
20390
+ if (!path18)
20391
20391
  return obj;
20392
- return path17.reduce((acc, key) => acc?.[key], obj);
20392
+ return path18.reduce((acc, key) => acc?.[key], obj);
20393
20393
  }
20394
20394
  function promiseAllObject(promisesObj) {
20395
20395
  const keys = Object.keys(promisesObj);
@@ -20701,11 +20701,11 @@ function aborted(x, startIndex = 0) {
20701
20701
  }
20702
20702
  return false;
20703
20703
  }
20704
- function prefixIssues(path17, issues) {
20704
+ function prefixIssues(path18, issues) {
20705
20705
  return issues.map((iss) => {
20706
20706
  var _a2;
20707
20707
  (_a2 = iss).path ?? (_a2.path = []);
20708
- iss.path.unshift(path17);
20708
+ iss.path.unshift(path18);
20709
20709
  return iss;
20710
20710
  });
20711
20711
  }
@@ -20948,7 +20948,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
20948
20948
  }
20949
20949
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
20950
20950
  const result = { errors: [] };
20951
- const processError = (error49, path17 = []) => {
20951
+ const processError = (error49, path18 = []) => {
20952
20952
  var _a2, _b;
20953
20953
  for (const issue2 of error49.issues) {
20954
20954
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -20958,7 +20958,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
20958
20958
  } else if (issue2.code === "invalid_element") {
20959
20959
  processError({ issues: issue2.issues }, issue2.path);
20960
20960
  } else {
20961
- const fullpath = [...path17, ...issue2.path];
20961
+ const fullpath = [...path18, ...issue2.path];
20962
20962
  if (fullpath.length === 0) {
20963
20963
  result.errors.push(mapper(issue2));
20964
20964
  continue;
@@ -20990,8 +20990,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
20990
20990
  }
20991
20991
  function toDotPath(_path) {
20992
20992
  const segs = [];
20993
- const path17 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
20994
- for (const seg of path17) {
20993
+ const path18 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
20994
+ for (const seg of path18) {
20995
20995
  if (typeof seg === "number")
20996
20996
  segs.push(`[${seg}]`);
20997
20997
  else if (typeof seg === "symbol")
@@ -33755,13 +33755,13 @@ function resolveRef(ref, ctx) {
33755
33755
  if (!ref.startsWith("#")) {
33756
33756
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
33757
33757
  }
33758
- const path17 = ref.slice(1).split("/").filter(Boolean);
33759
- if (path17.length === 0) {
33758
+ const path18 = ref.slice(1).split("/").filter(Boolean);
33759
+ if (path18.length === 0) {
33760
33760
  return ctx.rootSchema;
33761
33761
  }
33762
33762
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
33763
- if (path17[0] === defsKey) {
33764
- const key = path17[1];
33763
+ if (path18[0] === defsKey) {
33764
+ const key = path18[1];
33765
33765
  if (!key || !ctx.defs[key]) {
33766
33766
  throw new Error(`Reference not found: ${ref}`);
33767
33767
  }
@@ -36188,8 +36188,8 @@ var init_acp = __esm({
36188
36188
  this.#requestHandler = requestHandler;
36189
36189
  this.#notificationHandler = notificationHandler;
36190
36190
  this.#stream = stream;
36191
- this.#closedPromise = new Promise((resolve11) => {
36192
- this.#abortController.signal.addEventListener("abort", () => resolve11());
36191
+ this.#closedPromise = new Promise((resolve12) => {
36192
+ this.#abortController.signal.addEventListener("abort", () => resolve12());
36193
36193
  });
36194
36194
  this.#receive();
36195
36195
  }
@@ -36338,8 +36338,8 @@ var init_acp = __esm({
36338
36338
  }
36339
36339
  async sendRequest(method, params) {
36340
36340
  const id = this.#nextRequestId++;
36341
- const responsePromise = new Promise((resolve11, reject) => {
36342
- this.#pendingResponses.set(id, { resolve: resolve11, reject });
36341
+ const responsePromise = new Promise((resolve12, reject) => {
36342
+ this.#pendingResponses.set(id, { resolve: resolve12, reject });
36343
36343
  });
36344
36344
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
36345
36345
  return responsePromise;
@@ -36874,13 +36874,13 @@ var init_acp_provider_instance = __esm({
36874
36874
  }
36875
36875
  this.currentStatus = "waiting_approval";
36876
36876
  this.detectStatusTransition();
36877
- const approved = await new Promise((resolve11) => {
36878
- this.permissionResolvers.push(resolve11);
36877
+ const approved = await new Promise((resolve12) => {
36878
+ this.permissionResolvers.push(resolve12);
36879
36879
  setTimeout(() => {
36880
- const idx = this.permissionResolvers.indexOf(resolve11);
36880
+ const idx = this.permissionResolvers.indexOf(resolve12);
36881
36881
  if (idx >= 0) {
36882
36882
  this.permissionResolvers.splice(idx, 1);
36883
- resolve11(false);
36883
+ resolve12(false);
36884
36884
  }
36885
36885
  }, 3e5);
36886
36886
  });
@@ -40529,8 +40529,8 @@ async function handleAutoImplement(ctx, type, req, res) {
40529
40529
  fs11.writeFileSync(promptFile, prompt, "utf-8");
40530
40530
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
40531
40531
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
40532
- const spawn3 = agentProvider?.spawn;
40533
- if (!spawn3?.command) {
40532
+ const spawn4 = agentProvider?.spawn;
40533
+ if (!spawn4?.command) {
40534
40534
  try {
40535
40535
  fs11.unlinkSync(promptFile);
40536
40536
  } catch {
@@ -40540,21 +40540,21 @@ async function handleAutoImplement(ctx, type, req, res) {
40540
40540
  }
40541
40541
  const agentCategory = agentProvider?.category;
40542
40542
  if (agentCategory === "acp") {
40543
- sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn3.command} ${(spawn3.args || []).join(" ")}` } });
40543
+ sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn4.command} ${(spawn4.args || []).join(" ")}` } });
40544
40544
  ctx.autoImplStatus = { running: true, type, progress: [] };
40545
40545
  const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2, PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
40546
40546
  const { Readable: Readable3, Writable: Writable2 } = await import("stream");
40547
40547
  const { spawn: spawnFn2 } = await import("child_process");
40548
- const acpArgs = [...spawn3.args || []];
40548
+ const acpArgs = [...spawn4.args || []];
40549
40549
  if (model) {
40550
40550
  acpArgs.push("--model", model);
40551
40551
  ctx.log(`Auto-implement ACP using model: ${model}`);
40552
40552
  }
40553
- const child2 = spawnFn2(spawn3.command, acpArgs, {
40553
+ const child2 = spawnFn2(spawn4.command, acpArgs, {
40554
40554
  cwd: providerDir,
40555
40555
  stdio: ["pipe", "pipe", "pipe"],
40556
- shell: spawn3.shell ?? false,
40557
- env: { ...process.env, ...spawn3.env || {} }
40556
+ shell: spawn4.shell ?? false,
40557
+ env: { ...process.env, ...spawn4.env || {} }
40558
40558
  });
40559
40559
  ctx.autoImplProcess = child2;
40560
40560
  child2.stderr?.on("data", (d) => {
@@ -40664,7 +40664,7 @@ async function handleAutoImplement(ctx, type, req, res) {
40664
40664
  ctx.json(res, 202, {
40665
40665
  started: true,
40666
40666
  type,
40667
- agent: spawn3.command,
40667
+ agent: spawn4.command,
40668
40668
  functions,
40669
40669
  providerDir,
40670
40670
  message: "ACP Auto-implement started. Connect to SSE for progress.",
@@ -40672,9 +40672,9 @@ async function handleAutoImplement(ctx, type, req, res) {
40672
40672
  });
40673
40673
  return;
40674
40674
  }
40675
- const command = spawn3.command;
40675
+ const command = spawn4.command;
40676
40676
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
40677
- const baseArgs = [...spawn3.args || []].filter((a) => !interactiveFlags.includes(a));
40677
+ const baseArgs = [...spawn4.args || []].filter((a) => !interactiveFlags.includes(a));
40678
40678
  let shellCmd;
40679
40679
  if (command === "claude") {
40680
40680
  const args = [...baseArgs, "--dangerously-skip-permissions"];
@@ -40718,7 +40718,7 @@ async function handleAutoImplement(ctx, type, req, res) {
40718
40718
  cols: 120,
40719
40719
  rows: 40,
40720
40720
  cwd: providerDir,
40721
- env: { ...process.env, ...spawn3.env || {} }
40721
+ env: { ...process.env, ...spawn4.env || {} }
40722
40722
  });
40723
40723
  isPty = true;
40724
40724
  } catch (err) {
@@ -40730,7 +40730,7 @@ async function handleAutoImplement(ctx, type, req, res) {
40730
40730
  stdio: ["pipe", "pipe", "pipe"],
40731
40731
  env: {
40732
40732
  ...process.env,
40733
- ...spawn3.env || {},
40733
+ ...spawn4.env || {},
40734
40734
  ...command === "gemini" ? { SANDBOX: "1", GEMINI_CLI_NO_RELAUNCH: "1" } : {}
40735
40735
  }
40736
40736
  });
@@ -41480,8 +41480,8 @@ var init_dev_server = __esm({
41480
41480
  }
41481
41481
  getEndpointList() {
41482
41482
  return this.routes.map((r) => {
41483
- const path17 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
41484
- return `${r.method.padEnd(5)} ${path17}`;
41483
+ const path18 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
41484
+ return `${r.method.padEnd(5)} ${path18}`;
41485
41485
  });
41486
41486
  }
41487
41487
  async start(port = DEV_SERVER_PORT) {
@@ -41512,15 +41512,15 @@ var init_dev_server = __esm({
41512
41512
  this.json(res, 500, { error: e.message });
41513
41513
  }
41514
41514
  });
41515
- return new Promise((resolve11, reject) => {
41515
+ return new Promise((resolve12, reject) => {
41516
41516
  this.server.listen(port, "127.0.0.1", () => {
41517
41517
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
41518
- resolve11();
41518
+ resolve12();
41519
41519
  });
41520
41520
  this.server.on("error", (e) => {
41521
41521
  if (e.code === "EADDRINUSE") {
41522
41522
  this.log(`Port ${port} in use, skipping dev server`);
41523
- resolve11();
41523
+ resolve12();
41524
41524
  } else {
41525
41525
  reject(e);
41526
41526
  }
@@ -41582,16 +41582,16 @@ var init_dev_server = __esm({
41582
41582
  this.json(res, 404, { error: `Provider not found: ${type}` });
41583
41583
  return;
41584
41584
  }
41585
- const spawn3 = provider.spawn;
41586
- if (!spawn3) {
41585
+ const spawn4 = provider.spawn;
41586
+ if (!spawn4) {
41587
41587
  this.json(res, 400, { error: `Provider ${type} has no spawn config` });
41588
41588
  return;
41589
41589
  }
41590
41590
  const { spawn: spawnFn } = await import("child_process");
41591
41591
  const start = Date.now();
41592
41592
  try {
41593
- const child = spawnFn(spawn3.command, [...spawn3.args || []], {
41594
- shell: spawn3.shell ?? false,
41593
+ const child = spawnFn(spawn4.command, [...spawn4.args || []], {
41594
+ shell: spawn4.shell ?? false,
41595
41595
  timeout: 5e3,
41596
41596
  stdio: ["pipe", "pipe", "pipe"]
41597
41597
  });
@@ -41603,27 +41603,27 @@ var init_dev_server = __esm({
41603
41603
  child.stderr?.on("data", (d) => {
41604
41604
  stderr += d.toString().slice(0, 2e3);
41605
41605
  });
41606
- await new Promise((resolve11) => {
41606
+ await new Promise((resolve12) => {
41607
41607
  const timer = setTimeout(() => {
41608
41608
  child.kill();
41609
- resolve11();
41609
+ resolve12();
41610
41610
  }, 3e3);
41611
41611
  child.on("exit", () => {
41612
41612
  clearTimeout(timer);
41613
- resolve11();
41613
+ resolve12();
41614
41614
  });
41615
41615
  child.stdout?.once("data", () => {
41616
41616
  setTimeout(() => {
41617
41617
  child.kill();
41618
41618
  clearTimeout(timer);
41619
- resolve11();
41619
+ resolve12();
41620
41620
  }, 500);
41621
41621
  });
41622
41622
  });
41623
41623
  const elapsed = Date.now() - start;
41624
41624
  this.json(res, 200, {
41625
41625
  success: true,
41626
- command: `${spawn3.command} ${(spawn3.args || []).join(" ")}`,
41626
+ command: `${spawn4.command} ${(spawn4.args || []).join(" ")}`,
41627
41627
  elapsed,
41628
41628
  stdout: stdout.trim(),
41629
41629
  stderr: stderr.trim(),
@@ -41633,7 +41633,7 @@ var init_dev_server = __esm({
41633
41633
  const elapsed = Date.now() - start;
41634
41634
  this.json(res, 200, {
41635
41635
  success: false,
41636
- command: `${spawn3.command} ${(spawn3.args || []).join(" ")}`,
41636
+ command: `${spawn4.command} ${(spawn4.args || []).join(" ")}`,
41637
41637
  elapsed,
41638
41638
  error: e.message
41639
41639
  });
@@ -42102,20 +42102,20 @@ var init_dev_server = __esm({
42102
42102
  this.json(res, 404, { error: `Provider not found: ${type}` });
42103
42103
  return;
42104
42104
  }
42105
- const spawn3 = provider.spawn;
42106
- if (!spawn3) {
42105
+ const spawn4 = provider.spawn;
42106
+ if (!spawn4) {
42107
42107
  this.json(res, 400, { error: `Provider ${type} has no spawn config` });
42108
42108
  return;
42109
42109
  }
42110
42110
  const { spawn: spawnFn } = await import("child_process");
42111
42111
  const start = Date.now();
42112
42112
  try {
42113
- const args = [...spawn3.args || [], message];
42114
- const child = spawnFn(spawn3.command, args, {
42115
- shell: spawn3.shell ?? false,
42113
+ const args = [...spawn4.args || [], message];
42114
+ const child = spawnFn(spawn4.command, args, {
42115
+ shell: spawn4.shell ?? false,
42116
42116
  timeout,
42117
42117
  stdio: ["pipe", "pipe", "pipe"],
42118
- env: { ...process.env, ...spawn3.env || {} }
42118
+ env: { ...process.env, ...spawn4.env || {} }
42119
42119
  });
42120
42120
  let stdout = "";
42121
42121
  let stderr = "";
@@ -42125,14 +42125,14 @@ var init_dev_server = __esm({
42125
42125
  child.stderr?.on("data", (d) => {
42126
42126
  stderr += d.toString();
42127
42127
  });
42128
- await new Promise((resolve11) => {
42128
+ await new Promise((resolve12) => {
42129
42129
  const timer = setTimeout(() => {
42130
42130
  child.kill();
42131
- resolve11();
42131
+ resolve12();
42132
42132
  }, timeout);
42133
42133
  child.on("exit", () => {
42134
42134
  clearTimeout(timer);
42135
- resolve11();
42135
+ resolve12();
42136
42136
  });
42137
42137
  });
42138
42138
  const elapsed = Date.now() - start;
@@ -42788,14 +42788,14 @@ data: ${JSON.stringify(msg.data)}
42788
42788
  res.end(JSON.stringify(data, null, 2));
42789
42789
  }
42790
42790
  async readBody(req) {
42791
- return new Promise((resolve11) => {
42791
+ return new Promise((resolve12) => {
42792
42792
  let body = "";
42793
42793
  req.on("data", (chunk) => body += chunk);
42794
42794
  req.on("end", () => {
42795
42795
  try {
42796
- resolve11(JSON.parse(body));
42796
+ resolve12(JSON.parse(body));
42797
42797
  } catch {
42798
- resolve11({});
42798
+ resolve12({});
42799
42799
  }
42800
42800
  });
42801
42801
  });
@@ -42919,8 +42919,8 @@ var init_dist = __esm({
42919
42919
  }
42920
42920
  this.requestWaiters.clear();
42921
42921
  });
42922
- await new Promise((resolve11, reject) => {
42923
- socket.once("connect", () => resolve11());
42922
+ await new Promise((resolve12, reject) => {
42923
+ socket.once("connect", () => resolve12());
42924
42924
  socket.once("error", reject);
42925
42925
  });
42926
42926
  }
@@ -42939,8 +42939,8 @@ var init_dist = __esm({
42939
42939
  requestId,
42940
42940
  request
42941
42941
  };
42942
- const response = await new Promise((resolve11, reject) => {
42943
- this.requestWaiters.set(requestId, { resolve: resolve11, reject });
42942
+ const response = await new Promise((resolve12, reject) => {
42943
+ this.requestWaiters.set(requestId, { resolve: resolve12, reject });
42944
42944
  this.socket?.write(serializeEnvelope(envelope));
42945
42945
  });
42946
42946
  return response;
@@ -42953,12 +42953,12 @@ var init_dist = __esm({
42953
42953
  waiter.reject(new Error("Session host client closed"));
42954
42954
  }
42955
42955
  this.requestWaiters.clear();
42956
- await new Promise((resolve11) => {
42956
+ await new Promise((resolve12) => {
42957
42957
  let settled = false;
42958
42958
  const done = () => {
42959
42959
  if (settled) return;
42960
42960
  settled = true;
42961
- resolve11();
42961
+ resolve12();
42962
42962
  };
42963
42963
  socket.once("close", done);
42964
42964
  socket.end();
@@ -43320,6 +43320,68 @@ var init_session_host_transport = __esm({
43320
43320
  }
43321
43321
  });
43322
43322
 
43323
+ // ../../oss/packages/daemon-core/src/session-host/runtime-support.ts
43324
+ async function canConnect(endpoint) {
43325
+ const client = new SessionHostClient({ endpoint });
43326
+ try {
43327
+ await client.connect();
43328
+ await client.close();
43329
+ return true;
43330
+ } catch {
43331
+ return false;
43332
+ }
43333
+ }
43334
+ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
43335
+ const deadline = Date.now() + timeoutMs;
43336
+ while (Date.now() < deadline) {
43337
+ if (await canConnect(endpoint)) return;
43338
+ await new Promise((resolve12) => setTimeout(resolve12, STARTUP_POLL_MS));
43339
+ }
43340
+ throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
43341
+ }
43342
+ async function ensureSessionHostReady(options) {
43343
+ const endpoint = getDefaultSessionHostEndpoint(options.appName || "adhdev");
43344
+ if (await canConnect(endpoint)) return endpoint;
43345
+ options.spawnHost();
43346
+ await waitForReady(endpoint, options.timeoutMs);
43347
+ return endpoint;
43348
+ }
43349
+ async function listHostedCliRuntimes(endpoint) {
43350
+ const client = new SessionHostClient({ endpoint });
43351
+ try {
43352
+ const response = await client.request({
43353
+ type: "list_sessions",
43354
+ payload: {}
43355
+ });
43356
+ if (!response.success || !response.result) {
43357
+ return [];
43358
+ }
43359
+ return response.result.filter((record2) => record2.category === "cli" && ["running", "interrupted"].includes(record2.lifecycle)).sort((a, b2) => b2.lastActivityAt - a.lastActivityAt).map((record2) => ({
43360
+ runtimeId: record2.sessionId,
43361
+ runtimeKey: record2.runtimeKey,
43362
+ displayName: record2.displayName,
43363
+ workspaceLabel: record2.workspaceLabel,
43364
+ lifecycle: record2.lifecycle,
43365
+ recoveryState: typeof record2.meta?.runtimeRecoveryState === "string" ? String(record2.meta.runtimeRecoveryState) : null,
43366
+ cliType: record2.providerType,
43367
+ workspace: record2.workspace,
43368
+ cliArgs: Array.isArray(record2.meta?.cliArgs) ? record2.meta.cliArgs : []
43369
+ }));
43370
+ } finally {
43371
+ await client.close().catch(() => {
43372
+ });
43373
+ }
43374
+ }
43375
+ var STARTUP_TIMEOUT_MS, STARTUP_POLL_MS;
43376
+ var init_runtime_support = __esm({
43377
+ "../../oss/packages/daemon-core/src/session-host/runtime-support.ts"() {
43378
+ "use strict";
43379
+ init_dist();
43380
+ STARTUP_TIMEOUT_MS = 8e3;
43381
+ STARTUP_POLL_MS = 200;
43382
+ }
43383
+ });
43384
+
43323
43385
  // ../../oss/packages/daemon-core/src/installer.ts
43324
43386
  function isExtensionInstalled(ide, marketplaceId) {
43325
43387
  if (!ide.cliCommand) return false;
@@ -43363,10 +43425,10 @@ async function installExtension(ide, extension) {
43363
43425
  const buffer = Buffer.from(await res.arrayBuffer());
43364
43426
  const fs15 = await import("fs");
43365
43427
  fs15.writeFileSync(vsixPath, buffer);
43366
- return new Promise((resolve11) => {
43428
+ return new Promise((resolve12) => {
43367
43429
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
43368
43430
  (0, import_child_process8.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
43369
- resolve11({
43431
+ resolve12({
43370
43432
  extensionId: extension.id,
43371
43433
  marketplaceId: extension.marketplaceId,
43372
43434
  success: !error48,
@@ -43379,11 +43441,11 @@ async function installExtension(ide, extension) {
43379
43441
  } catch (e) {
43380
43442
  }
43381
43443
  }
43382
- return new Promise((resolve11) => {
43444
+ return new Promise((resolve12) => {
43383
43445
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
43384
43446
  (0, import_child_process8.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
43385
43447
  if (error48) {
43386
- resolve11({
43448
+ resolve12({
43387
43449
  extensionId: extension.id,
43388
43450
  marketplaceId: extension.marketplaceId,
43389
43451
  success: false,
@@ -43391,7 +43453,7 @@ async function installExtension(ide, extension) {
43391
43453
  error: stderr || error48.message
43392
43454
  });
43393
43455
  } else {
43394
- resolve11({
43456
+ resolve12({
43395
43457
  extensionId: extension.id,
43396
43458
  marketplaceId: extension.marketplaceId,
43397
43459
  success: true,
@@ -43808,6 +43870,7 @@ __export(src_exports, {
43808
43870
  detectAllVersions: () => detectAllVersions,
43809
43871
  detectCLIs: () => detectCLIs,
43810
43872
  detectIDEs: () => detectIDEs,
43873
+ ensureSessionHostReady: () => ensureSessionHostReady,
43811
43874
  findCdpManager: () => findCdpManager,
43812
43875
  forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
43813
43876
  getAIExtensions: () => getAIExtensions,
@@ -43831,6 +43894,7 @@ __export(src_exports, {
43831
43894
  killIdeProcess: () => killIdeProcess,
43832
43895
  launchIDE: () => launchIDE,
43833
43896
  launchWithCdp: () => launchWithCdp,
43897
+ listHostedCliRuntimes: () => listHostedCliRuntimes,
43834
43898
  loadConfig: () => loadConfig,
43835
43899
  logCommand: () => logCommand,
43836
43900
  markSetupComplete: () => markSetupComplete,
@@ -43886,6 +43950,7 @@ var init_src = __esm({
43886
43950
  init_provider_cli_adapter();
43887
43951
  init_pty_transport();
43888
43952
  init_session_host_transport();
43953
+ init_runtime_support();
43889
43954
  init_installer();
43890
43955
  init_daemon_lifecycle();
43891
43956
  }
@@ -44083,9 +44148,9 @@ var init_server_connection = __esm({
44083
44148
  LOG.info("Server", `[ServerConn] Run 'adhdev setup' to re-authenticate.`);
44084
44149
  this.setState("disconnected");
44085
44150
  try {
44086
- const path17 = require("path");
44151
+ const path18 = require("path");
44087
44152
  const fs15 = require("fs");
44088
- const configPath = path17.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
44153
+ const configPath = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
44089
44154
  if (fs15.existsSync(configPath)) {
44090
44155
  fs15.unlinkSync(configPath);
44091
44156
  LOG.info("Server", `[ServerConn] Config file removed. Re-run 'adhdev setup'.`);
@@ -44370,13 +44435,13 @@ ${e?.stack || ""}`);
44370
44435
  } catch {
44371
44436
  }
44372
44437
  const http3 = esmRequire("https");
44373
- const data = await new Promise((resolve11, reject) => {
44438
+ const data = await new Promise((resolve12, reject) => {
44374
44439
  const req = http3.get(`${serverUrl}/api/v1/turn/credentials`, {
44375
44440
  headers: { "Authorization": `Bearer ${token}` }
44376
44441
  }, (res) => {
44377
44442
  let d = "";
44378
44443
  res.on("data", (c) => d += c);
44379
- res.on("end", () => resolve11(d));
44444
+ res.on("end", () => resolve12(d));
44380
44445
  });
44381
44446
  req.on("error", reject);
44382
44447
  req.setTimeout(5e3, () => {
@@ -45205,6 +45270,52 @@ var init_screenshot_controller = __esm({
45205
45270
  }
45206
45271
  });
45207
45272
 
45273
+ // src/session-host.ts
45274
+ function resolveSessionHostEntry() {
45275
+ const localCandidates = [
45276
+ path16.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
45277
+ path16.resolve(__dirname, "../../vendor/session-host-daemon/index.js"),
45278
+ path16.resolve(__dirname, "../../../oss/packages/session-host-daemon/dist/index.js")
45279
+ ];
45280
+ for (const candidate of localCandidates) {
45281
+ if (require("fs").existsSync(candidate)) {
45282
+ return candidate;
45283
+ }
45284
+ }
45285
+ return require.resolve("@adhdev/session-host-daemon");
45286
+ }
45287
+ async function ensureSessionHostReady2() {
45288
+ return ensureSessionHostReady({
45289
+ appName: SESSION_HOST_APP_NAME,
45290
+ spawnHost: () => {
45291
+ const entry = resolveSessionHostEntry();
45292
+ const child = (0, import_child_process9.spawn)(process.execPath, [entry], {
45293
+ detached: true,
45294
+ stdio: "ignore",
45295
+ windowsHide: true,
45296
+ env: {
45297
+ ...process.env,
45298
+ ADHDEV_SESSION_HOST_NAME: SESSION_HOST_APP_NAME
45299
+ }
45300
+ });
45301
+ child.unref();
45302
+ }
45303
+ });
45304
+ }
45305
+ async function listHostedCliRuntimes2(endpoint) {
45306
+ return listHostedCliRuntimes(endpoint);
45307
+ }
45308
+ var import_child_process9, path16, SESSION_HOST_APP_NAME;
45309
+ var init_session_host = __esm({
45310
+ "src/session-host.ts"() {
45311
+ "use strict";
45312
+ import_child_process9 = require("child_process");
45313
+ path16 = __toESM(require("path"));
45314
+ init_src();
45315
+ SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
45316
+ }
45317
+ });
45318
+
45208
45319
  // src/adhdev-daemon.ts
45209
45320
  var adhdev_daemon_exports = {};
45210
45321
  __export(adhdev_daemon_exports, {
@@ -45213,9 +45324,9 @@ __export(adhdev_daemon_exports, {
45213
45324
  stopDaemon: () => stopDaemon
45214
45325
  });
45215
45326
  function getDaemonPidFile() {
45216
- const dir = path16.join(os19.homedir(), ".adhdev");
45327
+ const dir = path17.join(os19.homedir(), ".adhdev");
45217
45328
  if (!fs14.existsSync(dir)) fs14.mkdirSync(dir, { recursive: true });
45218
- return path16.join(dir, "daemon.pid");
45329
+ return path17.join(dir, "daemon.pid");
45219
45330
  }
45220
45331
  function writeDaemonPid(pid) {
45221
45332
  fs14.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
@@ -45251,7 +45362,7 @@ function stopDaemon() {
45251
45362
  return false;
45252
45363
  }
45253
45364
  }
45254
- var os19, fs14, path16, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
45365
+ var os19, fs14, path17, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
45255
45366
  var init_adhdev_daemon = __esm({
45256
45367
  "src/adhdev-daemon.ts"() {
45257
45368
  "use strict";
@@ -45259,16 +45370,17 @@ var init_adhdev_daemon = __esm({
45259
45370
  init_src();
45260
45371
  init_daemon_p2p();
45261
45372
  init_screenshot_controller();
45373
+ init_session_host();
45262
45374
  os19 = __toESM(require("os"));
45263
45375
  fs14 = __toESM(require("fs"));
45264
- path16 = __toESM(require("path"));
45376
+ path17 = __toESM(require("path"));
45265
45377
  import_chalk2 = __toESM(require("chalk"));
45266
- pkgVersion = "0.7.17";
45378
+ pkgVersion = "0.7.19";
45267
45379
  if (pkgVersion === "unknown") {
45268
45380
  try {
45269
45381
  const possiblePaths = [
45270
- path16.join(__dirname, "..", "package.json"),
45271
- path16.join(__dirname, "package.json")
45382
+ path17.join(__dirname, "..", "package.json"),
45383
+ path17.join(__dirname, "package.json")
45272
45384
  ];
45273
45385
  for (const p of possiblePaths) {
45274
45386
  try {
@@ -45339,13 +45451,27 @@ ${err?.stack || ""}`);
45339
45451
  console.log(import_chalk2.default.gray(" Run `adhdev setup` first.\n"));
45340
45452
  process.exit(1);
45341
45453
  }
45454
+ const sessionHostEndpoint = await ensureSessionHostReady2();
45342
45455
  this.components = await initDaemonComponents({
45343
45456
  providerLogFn: LOG.forComponent("Provider").asLogFn(),
45344
45457
  cliManagerDeps: {
45345
45458
  getServerConn: () => this.serverConn,
45346
45459
  getP2p: () => this.p2p,
45347
45460
  onStatusChange: () => this.statusReporter?.onStatusChange(),
45348
- removeAgentTracking: (key) => this.statusReporter?.removeAgentTracking(key)
45461
+ removeAgentTracking: (key) => this.statusReporter?.removeAgentTracking(key),
45462
+ createPtyTransportFactory: ({ runtimeId, providerType, workspace, cliArgs, attachExisting }) => new SessionHostPtyTransportFactory({
45463
+ endpoint: sessionHostEndpoint,
45464
+ clientId: `daemon_${config2.machineId}`,
45465
+ runtimeId,
45466
+ providerType,
45467
+ workspace,
45468
+ appName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev",
45469
+ meta: {
45470
+ cliArgs
45471
+ },
45472
+ attachExisting
45473
+ }),
45474
+ listHostedCliRuntimes: async () => listHostedCliRuntimes2(sessionHostEndpoint)
45349
45475
  },
45350
45476
  enabledIdes: config2.enabledIdes,
45351
45477
  onStatusChange: () => this.statusReporter?.onStatusChange(),
@@ -45362,6 +45488,7 @@ ${err?.stack || ""}`);
45362
45488
  forwardAgentStreamsToIdeInstance(this.components.instanceManager, ideType, streams);
45363
45489
  }
45364
45490
  });
45491
+ await this.components.cliManager.restoreHostedSessions();
45365
45492
  this.components.providerLoader.fetchLatest().then(({ updated }) => {
45366
45493
  if (updated) {
45367
45494
  this.components.providerLoader.reload();
@@ -45902,8 +46029,8 @@ async function startDaemonFlow() {
45902
46029
  const daemon = new AdhdevDaemon2();
45903
46030
  const { execSync: execSync7 } = await import("child_process");
45904
46031
  const os20 = await import("os");
45905
- const path17 = await import("path");
45906
- const logPath = path17.join(os20.homedir(), ".adhdev", "daemon.log");
46032
+ const path18 = await import("path");
46033
+ const logPath = path18.join(os20.homedir(), ".adhdev", "daemon.log");
45907
46034
  const platform11 = os20.platform();
45908
46035
  try {
45909
46036
  if (platform11 === "win32") {
@@ -46066,7 +46193,7 @@ __export(cdp_utils_exports, {
46066
46193
  async function sendDaemonCommand(cmd, args = {}, port = 19222) {
46067
46194
  const WebSocket3 = (await import("ws")).default;
46068
46195
  const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
46069
- return new Promise((resolve11, reject) => {
46196
+ return new Promise((resolve12, reject) => {
46070
46197
  const wsUrl = `ws://127.0.0.1:${port}${DAEMON_WS_PATH2 || "/daemon"}`;
46071
46198
  const ws2 = new WebSocket3(wsUrl);
46072
46199
  const timeout = setTimeout(() => {
@@ -46097,7 +46224,7 @@ async function sendDaemonCommand(cmd, args = {}, port = 19222) {
46097
46224
  if (msg.type === "daemon:command_result" || msg.type === "command_result") {
46098
46225
  clearTimeout(timeout);
46099
46226
  ws2.close();
46100
- resolve11(msg.payload?.result || msg.payload || msg);
46227
+ resolve12(msg.payload?.result || msg.payload || msg);
46101
46228
  }
46102
46229
  } catch {
46103
46230
  }
@@ -46114,13 +46241,13 @@ Is 'adhdev daemon' running?`));
46114
46241
  }
46115
46242
  async function directCdpEval(expression, port = 9222) {
46116
46243
  const http3 = await import("http");
46117
- const targets = await new Promise((resolve11, reject) => {
46244
+ const targets = await new Promise((resolve12, reject) => {
46118
46245
  http3.get(`http://127.0.0.1:${port}/json`, (res) => {
46119
46246
  let data = "";
46120
46247
  res.on("data", (c) => data += c);
46121
46248
  res.on("end", () => {
46122
46249
  try {
46123
- resolve11(JSON.parse(data));
46250
+ resolve12(JSON.parse(data));
46124
46251
  } catch {
46125
46252
  reject(new Error("Invalid JSON"));
46126
46253
  }
@@ -46133,7 +46260,7 @@ async function directCdpEval(expression, port = 9222) {
46133
46260
  const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
46134
46261
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
46135
46262
  const WebSocket3 = (await import("ws")).default;
46136
- return new Promise((resolve11, reject) => {
46263
+ return new Promise((resolve12, reject) => {
46137
46264
  const ws2 = new WebSocket3(target.webSocketDebuggerUrl);
46138
46265
  const timeout = setTimeout(() => {
46139
46266
  ws2.close();
@@ -46155,11 +46282,11 @@ async function directCdpEval(expression, port = 9222) {
46155
46282
  clearTimeout(timeout);
46156
46283
  ws2.close();
46157
46284
  if (msg.result?.result?.value !== void 0) {
46158
- resolve11(msg.result.result.value);
46285
+ resolve12(msg.result.result.value);
46159
46286
  } else if (msg.result?.exceptionDetails) {
46160
46287
  reject(new Error(msg.result.exceptionDetails.text));
46161
46288
  } else {
46162
- resolve11(msg.result);
46289
+ resolve12(msg.result);
46163
46290
  }
46164
46291
  }
46165
46292
  });
@@ -46542,7 +46669,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
46542
46669
  });
46543
46670
  });
46544
46671
  program2.command("standalone").description("\u{1F5A5}\uFE0F Start ADHDev Standalone Server (Local Dashboard & Embedded Daemon)").option("-p, --port <port>", "Local HTTP/WS server port", "3847").option("--host <host>", "Bind to specific host (use 0.0.0.0 for LAN access)").option("--no-open", "Prevent opening browser automatically").option("--token <token>", "Require token authentication").option("--dev", "Enable Dev Mode").action(async (options) => {
46545
- const { spawn: spawn3, execSync: execSync7 } = await import("child_process");
46672
+ const { spawn: spawn4, execSync: execSync7 } = await import("child_process");
46546
46673
  console.log(import_chalk5.default.cyan("\n Starting ADHDev Standalone Server..."));
46547
46674
  const args = [];
46548
46675
  if (options.port) args.push("--port", options.port);
@@ -46560,7 +46687,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
46560
46687
  console.log(import_chalk5.default.gray(" Downloading and running via npx (this may take a moment)..."));
46561
46688
  }
46562
46689
  const spawnArgs = bin === "npx" ? npxArgs : args;
46563
- const child = spawn3(bin, spawnArgs, {
46690
+ const child = spawn4(bin, spawnArgs, {
46564
46691
  stdio: "inherit",
46565
46692
  shell: process.platform === "win32"
46566
46693
  });
@@ -46596,7 +46723,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
46596
46723
  }));
46597
46724
  hideCommand(program2.command("daemon:restart").description("Restart ADHDev Daemon (stop \u2192 start)").option("-p, --port <port>", "Local WS server port", "19222").option("--server <url>", "Override server URL").option("--dev", "Enable Dev Mode").action(async (options) => {
46598
46725
  const { stopDaemon: stopDaemon2, isDaemonRunning: isDaemonRunning2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
46599
- const { spawn: spawn3 } = await import("child_process");
46726
+ const { spawn: spawn4 } = await import("child_process");
46600
46727
  if (isDaemonRunning2()) {
46601
46728
  console.log(import_chalk5.default.yellow("\n Stopping existing daemon..."));
46602
46729
  stopDaemon2();
@@ -46606,7 +46733,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
46606
46733
  const args = ["daemon", "-p", options.port || "19222"];
46607
46734
  if (options.server) args.push("--server", options.server);
46608
46735
  if (options.dev) args.push("--dev");
46609
- const child = spawn3(process.execPath, [process.argv[1], ...args], {
46736
+ const child = spawn4(process.execPath, [process.argv[1], ...args], {
46610
46737
  detached: true,
46611
46738
  stdio: "ignore",
46612
46739
  env: { ...process.env }
@@ -46624,7 +46751,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
46624
46751
  }));
46625
46752
  hideCommand(program2.command("daemon:upgrade").description("Upgrade ADHDev to latest version and restart daemon").option("--no-restart", "Upgrade only, skip daemon restart").action(async (options) => {
46626
46753
  const { isDaemonRunning: isDaemonRunning2, stopDaemon: stopDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
46627
- const { execSync: execSync7, spawn: spawn3 } = await import("child_process");
46754
+ const { execSync: execSync7, spawn: spawn4 } = await import("child_process");
46628
46755
  const fsMod = await import("fs");
46629
46756
  const pathMod = await import("path");
46630
46757
  console.log(import_chalk5.default.bold("\n \u{1F504} ADHDev Upgrade\n"));
@@ -46680,7 +46807,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
46680
46807
  console.log(import_chalk5.default.yellow("\n Restarting daemon..."));
46681
46808
  stopDaemon2();
46682
46809
  await new Promise((r) => setTimeout(r, 2e3));
46683
- const child = spawn3(process.execPath, [process.argv[1], "daemon", "-p", "19222"], {
46810
+ const child = spawn4(process.execPath, [process.argv[1], "daemon", "-p", "19222"], {
46684
46811
  detached: true,
46685
46812
  stdio: "ignore",
46686
46813
  env: { ...process.env }
@@ -46815,7 +46942,7 @@ function registerProviderCommands(program2) {
46815
46942
  } catch {
46816
46943
  try {
46817
46944
  const http3 = await import("http");
46818
- const result = await new Promise((resolve11, reject) => {
46945
+ const result = await new Promise((resolve12, reject) => {
46819
46946
  const req = http3.request({
46820
46947
  hostname: "127.0.0.1",
46821
46948
  port: 19280,
@@ -46827,9 +46954,9 @@ function registerProviderCommands(program2) {
46827
46954
  res.on("data", (c) => data += c);
46828
46955
  res.on("end", () => {
46829
46956
  try {
46830
- resolve11(JSON.parse(data));
46957
+ resolve12(JSON.parse(data));
46831
46958
  } catch {
46832
- resolve11({ raw: data });
46959
+ resolve12({ raw: data });
46833
46960
  }
46834
46961
  });
46835
46962
  });
@@ -46891,7 +47018,7 @@ function registerProviderCommands(program2) {
46891
47018
  let processNames = {};
46892
47019
  if (category === "ide") {
46893
47020
  const fs15 = await import("fs");
46894
- const path17 = await import("path");
47021
+ const path18 = await import("path");
46895
47022
  const os20 = await import("os");
46896
47023
  if (os20.platform() === "darwin") {
46897
47024
  while (true) {
@@ -46904,7 +47031,7 @@ function registerProviderCommands(program2) {
46904
47031
  }
46905
47032
  console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
46906
47033
  osPaths["darwin"] = [p];
46907
- processNames["darwin"] = path17.basename(p, ".app");
47034
+ processNames["darwin"] = path18.basename(p, ".app");
46908
47035
  break;
46909
47036
  }
46910
47037
  } else if (os20.platform() === "win32") {
@@ -46918,7 +47045,7 @@ function registerProviderCommands(program2) {
46918
47045
  }
46919
47046
  console.log(import_chalk6.default.green(` \u2713 Path verified: ${p}`));
46920
47047
  osPaths["win32"] = [p];
46921
- processNames["win32"] = path17.basename(p, ".exe");
47048
+ processNames["win32"] = path18.basename(p, ".exe");
46922
47049
  break;
46923
47050
  }
46924
47051
  }
@@ -46932,12 +47059,12 @@ function registerProviderCommands(program2) {
46932
47059
  console.log(import_chalk6.default.yellow("Invalid port number."));
46933
47060
  continue;
46934
47061
  }
46935
- const isFree = await new Promise((resolve11) => {
47062
+ const isFree = await new Promise((resolve12) => {
46936
47063
  const server = net3.createServer();
46937
47064
  server.unref();
46938
- server.on("error", () => resolve11(false));
47065
+ server.on("error", () => resolve12(false));
46939
47066
  server.listen(port, "127.0.0.1", () => {
46940
- server.close(() => resolve11(true));
47067
+ server.close(() => resolve12(true));
46941
47068
  });
46942
47069
  });
46943
47070
  if (!isFree) {
@@ -46952,7 +47079,7 @@ function registerProviderCommands(program2) {
46952
47079
  rl.close();
46953
47080
  const location = options.builtin ? "builtin" : "user";
46954
47081
  const http3 = await import("http");
46955
- const result = await new Promise((resolve11, reject) => {
47082
+ const result = await new Promise((resolve12, reject) => {
46956
47083
  const postData = JSON.stringify({ type, name, category, location, cdpPorts, osPaths, processNames });
46957
47084
  const req = http3.request({
46958
47085
  hostname: "127.0.0.1",
@@ -46965,9 +47092,9 @@ function registerProviderCommands(program2) {
46965
47092
  res.on("data", (c) => data += c);
46966
47093
  res.on("end", () => {
46967
47094
  try {
46968
- resolve11(JSON.parse(data));
47095
+ resolve12(JSON.parse(data));
46969
47096
  } catch {
46970
- resolve11({ raw: data });
47097
+ resolve12({ raw: data });
46971
47098
  }
46972
47099
  });
46973
47100
  });
@@ -47166,7 +47293,7 @@ function registerProviderCommands(program2) {
47166
47293
  ...userComment ? { comment: userComment } : {},
47167
47294
  reference
47168
47295
  });
47169
- const startResult = await new Promise((resolve11, reject) => {
47296
+ const startResult = await new Promise((resolve12, reject) => {
47170
47297
  const req = http3.request({
47171
47298
  hostname: "127.0.0.1",
47172
47299
  port: 19280,
@@ -47178,9 +47305,9 @@ function registerProviderCommands(program2) {
47178
47305
  res.on("data", (c) => data += c);
47179
47306
  res.on("end", () => {
47180
47307
  try {
47181
- resolve11(JSON.parse(data));
47308
+ resolve12(JSON.parse(data));
47182
47309
  } catch {
47183
- resolve11({ raw: data });
47310
+ resolve12({ raw: data });
47184
47311
  }
47185
47312
  });
47186
47313
  });
@@ -47206,7 +47333,7 @@ function registerProviderCommands(program2) {
47206
47333
  fsMock.writeFileSync(logFile2, `=== Auto-Impl Started ===
47207
47334
  `);
47208
47335
  console.log(import_chalk6.default.gray(` Agent logs: ${logFile2}`));
47209
- await new Promise((resolve11, reject) => {
47336
+ await new Promise((resolve12, reject) => {
47210
47337
  http3.get(`http://127.0.0.1:19280${startResult.sseUrl}`, (res) => {
47211
47338
  let buffer = "";
47212
47339
  res.on("data", (chunk) => {
@@ -47243,7 +47370,7 @@ function registerProviderCommands(program2) {
47243
47370
  if (currentData.success === false) {
47244
47371
  reject(new Error(`Agent failed to implement scripts properly (exit: ${currentData.exitCode})`));
47245
47372
  } else {
47246
- resolve11();
47373
+ resolve12();
47247
47374
  }
47248
47375
  } else if (currentEvent === "error") {
47249
47376
  fsMock.appendFileSync(logFile2, `
@@ -47254,7 +47381,7 @@ function registerProviderCommands(program2) {
47254
47381
  }
47255
47382
  }
47256
47383
  });
47257
- res.on("end", resolve11);
47384
+ res.on("end", resolve12);
47258
47385
  }).on("error", reject);
47259
47386
  });
47260
47387
  console.log(import_chalk6.default.green(`
@@ -47313,7 +47440,7 @@ function registerProviderCommands(program2) {
47313
47440
  ideType: type,
47314
47441
  params: options.param ? { text: options.param, sessionId: options.param, buttonText: options.param } : {}
47315
47442
  });
47316
- const result = await new Promise((resolve11, reject) => {
47443
+ const result = await new Promise((resolve12, reject) => {
47317
47444
  const req = http3.request({
47318
47445
  hostname: "127.0.0.1",
47319
47446
  port: 19280,
@@ -47325,9 +47452,9 @@ function registerProviderCommands(program2) {
47325
47452
  res.on("data", (c) => data += c);
47326
47453
  res.on("end", () => {
47327
47454
  try {
47328
- resolve11(JSON.parse(data));
47455
+ resolve12(JSON.parse(data));
47329
47456
  } catch {
47330
- resolve11({ raw: data });
47457
+ resolve12({ raw: data });
47331
47458
  }
47332
47459
  });
47333
47460
  });
@@ -47363,15 +47490,15 @@ function registerProviderCommands(program2) {
47363
47490
  provider.command("source <type>").description("View source code of a provider").action(async (type) => {
47364
47491
  try {
47365
47492
  const http3 = await import("http");
47366
- const result = await new Promise((resolve11, reject) => {
47493
+ const result = await new Promise((resolve12, reject) => {
47367
47494
  http3.get(`http://127.0.0.1:19280/api/providers/${type}/source`, (res) => {
47368
47495
  let data = "";
47369
47496
  res.on("data", (c) => data += c);
47370
47497
  res.on("end", () => {
47371
47498
  try {
47372
- resolve11(JSON.parse(data));
47499
+ resolve12(JSON.parse(data));
47373
47500
  } catch {
47374
- resolve11({ raw: data });
47501
+ resolve12({ raw: data });
47375
47502
  }
47376
47503
  });
47377
47504
  }).on("error", () => {
@@ -47417,7 +47544,7 @@ function registerProviderCommands(program2) {
47417
47544
  try {
47418
47545
  const http3 = await import("http");
47419
47546
  const postData = JSON.stringify({ script: "readChat", params: {} });
47420
- const result = await new Promise((resolve11, reject) => {
47547
+ const result = await new Promise((resolve12, reject) => {
47421
47548
  const req = http3.request({
47422
47549
  hostname: "127.0.0.1",
47423
47550
  port: 19280,
@@ -47429,9 +47556,9 @@ function registerProviderCommands(program2) {
47429
47556
  res2.on("data", (c) => data += c);
47430
47557
  res2.on("end", () => {
47431
47558
  try {
47432
- resolve11(JSON.parse(data));
47559
+ resolve12(JSON.parse(data));
47433
47560
  } catch {
47434
- resolve11({ raw: data });
47561
+ resolve12({ raw: data });
47435
47562
  }
47436
47563
  });
47437
47564
  });
@@ -47672,13 +47799,13 @@ function registerCdpCommands(program2) {
47672
47799
  cdp.command("screenshot").description("Capture IDE screenshot").option("-p, --port <port>", "CDP port", "9222").option("-o, --output <file>", "Output file path", "/tmp/cdp_screenshot.jpg").action(async (options) => {
47673
47800
  try {
47674
47801
  const http3 = await import("http");
47675
- const targets = await new Promise((resolve11, reject) => {
47802
+ const targets = await new Promise((resolve12, reject) => {
47676
47803
  http3.get(`http://127.0.0.1:${options.port}/json`, (res) => {
47677
47804
  let data = "";
47678
47805
  res.on("data", (c) => data += c);
47679
47806
  res.on("end", () => {
47680
47807
  try {
47681
- resolve11(JSON.parse(data));
47808
+ resolve12(JSON.parse(data));
47682
47809
  } catch {
47683
47810
  reject(new Error("Invalid JSON"));
47684
47811
  }
@@ -47692,7 +47819,7 @@ function registerCdpCommands(program2) {
47692
47819
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target");
47693
47820
  const WebSocket3 = (await import("ws")).default;
47694
47821
  const ws2 = new WebSocket3(target.webSocketDebuggerUrl);
47695
- await new Promise((resolve11, reject) => {
47822
+ await new Promise((resolve12, reject) => {
47696
47823
  ws2.on("open", () => {
47697
47824
  ws2.send(JSON.stringify({ id: 1, method: "Page.captureScreenshot", params: { format: "jpeg", quality: 50 } }));
47698
47825
  });
@@ -47705,7 +47832,7 @@ function registerCdpCommands(program2) {
47705
47832
  \u2713 Screenshot saved to ${options.output}
47706
47833
  `));
47707
47834
  ws2.close();
47708
- resolve11();
47835
+ resolve12();
47709
47836
  }
47710
47837
  });
47711
47838
  ws2.on("error", (e) => reject(e));