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/index.js CHANGED
@@ -505,18 +505,18 @@ function checkPathExists(paths) {
505
505
  return null;
506
506
  }
507
507
  async function detectIDEs() {
508
- const os19 = (0, import_os2.platform)();
508
+ const os20 = (0, import_os2.platform)();
509
509
  const results = [];
510
510
  for (const def of getMergedDefinitions()) {
511
511
  const cliPath = findCliCommand(def.cli);
512
- const appPath = checkPathExists(def.paths[os19] || []);
512
+ const appPath = checkPathExists(def.paths[os20] || []);
513
513
  const installed = !!(cliPath || appPath);
514
514
  let resolvedCli = cliPath;
515
- if (!resolvedCli && appPath && os19 === "darwin") {
515
+ if (!resolvedCli && appPath && os20 === "darwin") {
516
516
  const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
517
517
  if ((0, import_fs2.existsSync)(bundledCli)) resolvedCli = bundledCli;
518
518
  }
519
- if (!resolvedCli && appPath && os19 === "win32") {
519
+ if (!resolvedCli && appPath && os20 === "win32") {
520
520
  const { dirname: dirname9 } = await import("path");
521
521
  const appDir = dirname9(appPath);
522
522
  const candidates = [
@@ -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) {
@@ -960,7 +960,7 @@ var init_manager = __esm({
960
960
  * Returns multiple entries if multiple IDE windows are open on same port
961
961
  */
962
962
  static listAllTargets(port) {
963
- return new Promise((resolve11) => {
963
+ return new Promise((resolve12) => {
964
964
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
965
965
  let data = "";
966
966
  res.on("data", (chunk) => data += chunk.toString());
@@ -976,16 +976,16 @@ var init_manager = __esm({
976
976
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
977
977
  );
978
978
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
979
- resolve11(mainPages.length > 0 ? mainPages : fallbackPages);
979
+ resolve12(mainPages.length > 0 ? mainPages : fallbackPages);
980
980
  } catch {
981
- resolve11([]);
981
+ resolve12([]);
982
982
  }
983
983
  });
984
984
  });
985
- req.on("error", () => resolve11([]));
985
+ req.on("error", () => resolve12([]));
986
986
  req.setTimeout(2e3, () => {
987
987
  req.destroy();
988
- resolve11([]);
988
+ resolve12([]);
989
989
  });
990
990
  });
991
991
  }
@@ -1025,7 +1025,7 @@ var init_manager = __esm({
1025
1025
  }
1026
1026
  }
1027
1027
  findTargetOnPort(port) {
1028
- return new Promise((resolve11) => {
1028
+ return new Promise((resolve12) => {
1029
1029
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
1030
1030
  let data = "";
1031
1031
  res.on("data", (chunk) => data += chunk.toString());
@@ -1036,7 +1036,7 @@ var init_manager = __esm({
1036
1036
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
1037
1037
  );
1038
1038
  if (pages.length === 0) {
1039
- resolve11(targets.find((t) => t.webSocketDebuggerUrl) || null);
1039
+ resolve12(targets.find((t) => t.webSocketDebuggerUrl) || null);
1040
1040
  return;
1041
1041
  }
1042
1042
  const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -1046,24 +1046,24 @@ var init_manager = __esm({
1046
1046
  const specific = list.find((t) => t.id === this._targetId);
1047
1047
  if (specific) {
1048
1048
  this._pageTitle = specific.title || "";
1049
- resolve11(specific);
1049
+ resolve12(specific);
1050
1050
  } else {
1051
1051
  this.log(`[CDP] Target ${this._targetId} not found in page list`);
1052
- resolve11(null);
1052
+ resolve12(null);
1053
1053
  }
1054
1054
  return;
1055
1055
  }
1056
1056
  this._pageTitle = list[0]?.title || "";
1057
- resolve11(list[0]);
1057
+ resolve12(list[0]);
1058
1058
  } catch {
1059
- resolve11(null);
1059
+ resolve12(null);
1060
1060
  }
1061
1061
  });
1062
1062
  });
1063
- req.on("error", () => resolve11(null));
1063
+ req.on("error", () => resolve12(null));
1064
1064
  req.setTimeout(2e3, () => {
1065
1065
  req.destroy();
1066
- resolve11(null);
1066
+ resolve12(null);
1067
1067
  });
1068
1068
  });
1069
1069
  }
@@ -1074,7 +1074,7 @@ var init_manager = __esm({
1074
1074
  this.extensionProviders = providers;
1075
1075
  }
1076
1076
  connectToTarget(wsUrl) {
1077
- return new Promise((resolve11) => {
1077
+ return new Promise((resolve12) => {
1078
1078
  this.ws = new import_ws.default(wsUrl);
1079
1079
  this.ws.on("open", async () => {
1080
1080
  this._connected = true;
@@ -1084,17 +1084,17 @@ var init_manager = __esm({
1084
1084
  }
1085
1085
  this.connectBrowserWs().catch(() => {
1086
1086
  });
1087
- resolve11(true);
1087
+ resolve12(true);
1088
1088
  });
1089
1089
  this.ws.on("message", (data) => {
1090
1090
  try {
1091
1091
  const msg = JSON.parse(data.toString());
1092
1092
  if (msg.id && this.pending.has(msg.id)) {
1093
- const { resolve: resolve12, reject } = this.pending.get(msg.id);
1093
+ const { resolve: resolve13, reject } = this.pending.get(msg.id);
1094
1094
  this.pending.delete(msg.id);
1095
1095
  this.failureCount = 0;
1096
1096
  if (msg.error) reject(new Error(msg.error.message));
1097
- else resolve12(msg.result);
1097
+ else resolve13(msg.result);
1098
1098
  } else if (msg.method === "Runtime.executionContextCreated") {
1099
1099
  this.contexts.add(msg.params.context.id);
1100
1100
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -1117,7 +1117,7 @@ var init_manager = __esm({
1117
1117
  this.ws.on("error", (err) => {
1118
1118
  this.log(`[CDP] WebSocket error: ${err.message}`);
1119
1119
  this._connected = false;
1120
- resolve11(false);
1120
+ resolve12(false);
1121
1121
  });
1122
1122
  });
1123
1123
  }
@@ -1131,7 +1131,7 @@ var init_manager = __esm({
1131
1131
  return;
1132
1132
  }
1133
1133
  this.log(`[CDP] Connecting browser WS for target discovery...`);
1134
- await new Promise((resolve11, reject) => {
1134
+ await new Promise((resolve12, reject) => {
1135
1135
  this.browserWs = new import_ws.default(browserWsUrl);
1136
1136
  this.browserWs.on("open", async () => {
1137
1137
  this._browserConnected = true;
@@ -1141,16 +1141,16 @@ var init_manager = __esm({
1141
1141
  } catch (e) {
1142
1142
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
1143
1143
  }
1144
- resolve11();
1144
+ resolve12();
1145
1145
  });
1146
1146
  this.browserWs.on("message", (data) => {
1147
1147
  try {
1148
1148
  const msg = JSON.parse(data.toString());
1149
1149
  if (msg.id && this.browserPending.has(msg.id)) {
1150
- const { resolve: resolve12, reject: reject2 } = this.browserPending.get(msg.id);
1150
+ const { resolve: resolve13, reject: reject2 } = this.browserPending.get(msg.id);
1151
1151
  this.browserPending.delete(msg.id);
1152
1152
  if (msg.error) reject2(new Error(msg.error.message));
1153
- else resolve12(msg.result);
1153
+ else resolve13(msg.result);
1154
1154
  }
1155
1155
  } catch {
1156
1156
  }
@@ -1170,31 +1170,31 @@ var init_manager = __esm({
1170
1170
  }
1171
1171
  }
1172
1172
  getBrowserWsUrl() {
1173
- return new Promise((resolve11) => {
1173
+ return new Promise((resolve12) => {
1174
1174
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
1175
1175
  let data = "";
1176
1176
  res.on("data", (chunk) => data += chunk.toString());
1177
1177
  res.on("end", () => {
1178
1178
  try {
1179
1179
  const info = JSON.parse(data);
1180
- resolve11(info.webSocketDebuggerUrl || null);
1180
+ resolve12(info.webSocketDebuggerUrl || null);
1181
1181
  } catch {
1182
- resolve11(null);
1182
+ resolve12(null);
1183
1183
  }
1184
1184
  });
1185
1185
  });
1186
- req.on("error", () => resolve11(null));
1186
+ req.on("error", () => resolve12(null));
1187
1187
  req.setTimeout(3e3, () => {
1188
1188
  req.destroy();
1189
- resolve11(null);
1189
+ resolve12(null);
1190
1190
  });
1191
1191
  });
1192
1192
  }
1193
1193
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
1194
- return new Promise((resolve11, reject) => {
1194
+ return new Promise((resolve12, reject) => {
1195
1195
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
1196
1196
  const id = this.browserMsgId++;
1197
- this.browserPending.set(id, { resolve: resolve11, reject });
1197
+ this.browserPending.set(id, { resolve: resolve12, reject });
1198
1198
  this.browserWs.send(JSON.stringify({ id, method, params }));
1199
1199
  setTimeout(() => {
1200
1200
  if (this.browserPending.has(id)) {
@@ -1234,11 +1234,11 @@ var init_manager = __esm({
1234
1234
  }
1235
1235
  // ─── CDP Protocol ────────────────────────────────────────
1236
1236
  sendInternal(method, params = {}, timeoutMs = 15e3) {
1237
- return new Promise((resolve11, reject) => {
1237
+ return new Promise((resolve12, reject) => {
1238
1238
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
1239
1239
  if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
1240
1240
  const id = this.msgId++;
1241
- this.pending.set(id, { resolve: resolve11, reject });
1241
+ this.pending.set(id, { resolve: resolve12, reject });
1242
1242
  this.ws.send(JSON.stringify({ id, method, params }));
1243
1243
  setTimeout(() => {
1244
1244
  if (this.pending.has(id)) {
@@ -1487,7 +1487,7 @@ var init_manager = __esm({
1487
1487
  const browserWs = this.browserWs;
1488
1488
  let msgId = this.browserMsgId;
1489
1489
  const sendWs = (method, params = {}, sessionId) => {
1490
- return new Promise((resolve11, reject) => {
1490
+ return new Promise((resolve12, reject) => {
1491
1491
  const mid = msgId++;
1492
1492
  this.browserMsgId = msgId;
1493
1493
  const handler = (raw) => {
@@ -1496,7 +1496,7 @@ var init_manager = __esm({
1496
1496
  if (msg.id === mid) {
1497
1497
  browserWs.removeListener("message", handler);
1498
1498
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
1499
- else resolve11(msg.result);
1499
+ else resolve12(msg.result);
1500
1500
  }
1501
1501
  } catch {
1502
1502
  }
@@ -1687,14 +1687,14 @@ var init_manager = __esm({
1687
1687
  if (!ws2 || ws2.readyState !== import_ws.default.OPEN) {
1688
1688
  throw new Error("CDP not connected");
1689
1689
  }
1690
- return new Promise((resolve11, reject) => {
1690
+ return new Promise((resolve12, reject) => {
1691
1691
  const id = getNextId();
1692
1692
  pendingMap.set(id, {
1693
1693
  resolve: (result) => {
1694
1694
  if (result?.result?.subtype === "error") {
1695
1695
  reject(new Error(result.result.description));
1696
1696
  } else {
1697
- resolve11(result?.result?.value);
1697
+ resolve12(result?.result?.value);
1698
1698
  }
1699
1699
  },
1700
1700
  reject
@@ -1726,10 +1726,10 @@ var init_manager = __esm({
1726
1726
  throw new Error("CDP not connected");
1727
1727
  }
1728
1728
  const sendViaSession = (method, params = {}) => {
1729
- return new Promise((resolve11, reject) => {
1729
+ return new Promise((resolve12, reject) => {
1730
1730
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
1731
1731
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
1732
- pendingMap.set(id, { resolve: resolve11, reject });
1732
+ pendingMap.set(id, { resolve: resolve12, reject });
1733
1733
  ws2.send(JSON.stringify({ id, sessionId, method, params }));
1734
1734
  setTimeout(() => {
1735
1735
  if (pendingMap.has(id)) {
@@ -5301,7 +5301,7 @@ var init_handler = __esm({
5301
5301
  try {
5302
5302
  const http3 = await import("http");
5303
5303
  const postData = JSON.stringify(body);
5304
- const result = await new Promise((resolve11, reject) => {
5304
+ const result = await new Promise((resolve12, reject) => {
5305
5305
  const req = http3.request({
5306
5306
  hostname: "127.0.0.1",
5307
5307
  port: 19280,
@@ -5313,9 +5313,9 @@ var init_handler = __esm({
5313
5313
  res.on("data", (chunk) => data += chunk);
5314
5314
  res.on("end", () => {
5315
5315
  try {
5316
- resolve11(JSON.parse(data));
5316
+ resolve12(JSON.parse(data));
5317
5317
  } catch {
5318
- resolve11({ raw: data });
5318
+ resolve12({ raw: data });
5319
5319
  }
5320
5320
  });
5321
5321
  });
@@ -5333,15 +5333,15 @@ var init_handler = __esm({
5333
5333
  if (!providerType) return { success: false, error: "providerType required" };
5334
5334
  try {
5335
5335
  const http3 = await import("http");
5336
- const result = await new Promise((resolve11, reject) => {
5336
+ const result = await new Promise((resolve12, reject) => {
5337
5337
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
5338
5338
  let data = "";
5339
5339
  res.on("data", (chunk) => data += chunk);
5340
5340
  res.on("end", () => {
5341
5341
  try {
5342
- resolve11(JSON.parse(data));
5342
+ resolve12(JSON.parse(data));
5343
5343
  } catch {
5344
- resolve11({ raw: data });
5344
+ resolve12({ raw: data });
5345
5345
  }
5346
5346
  });
5347
5347
  }).on("error", reject);
@@ -5355,7 +5355,7 @@ var init_handler = __esm({
5355
5355
  try {
5356
5356
  const http3 = await import("http");
5357
5357
  const postData = JSON.stringify(args || {});
5358
- const result = await new Promise((resolve11, reject) => {
5358
+ const result = await new Promise((resolve12, reject) => {
5359
5359
  const req = http3.request({
5360
5360
  hostname: "127.0.0.1",
5361
5361
  port: 19280,
@@ -5367,9 +5367,9 @@ var init_handler = __esm({
5367
5367
  res.on("data", (chunk) => data += chunk);
5368
5368
  res.on("end", () => {
5369
5369
  try {
5370
- resolve11(JSON.parse(data));
5370
+ resolve12(JSON.parse(data));
5371
5371
  } catch {
5372
- resolve11({ raw: data });
5372
+ resolve12({ raw: data });
5373
5373
  }
5374
5374
  });
5375
5375
  });
@@ -5490,7 +5490,7 @@ var init_readdirp = __esm({
5490
5490
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
5491
5491
  const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
5492
5492
  if (wantBigintFsStats) {
5493
- this._stat = (path17) => statMethod(path17, { bigint: true });
5493
+ this._stat = (path18) => statMethod(path18, { bigint: true });
5494
5494
  } else {
5495
5495
  this._stat = statMethod;
5496
5496
  }
@@ -5515,8 +5515,8 @@ var init_readdirp = __esm({
5515
5515
  const par = this.parent;
5516
5516
  const fil = par && par.files;
5517
5517
  if (fil && fil.length > 0) {
5518
- const { path: path17, depth } = par;
5519
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path17));
5518
+ const { path: path18, depth } = par;
5519
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path18));
5520
5520
  const awaited = await Promise.all(slice);
5521
5521
  for (const entry of awaited) {
5522
5522
  if (!entry)
@@ -5556,20 +5556,20 @@ var init_readdirp = __esm({
5556
5556
  this.reading = false;
5557
5557
  }
5558
5558
  }
5559
- async _exploreDir(path17, depth) {
5559
+ async _exploreDir(path18, depth) {
5560
5560
  let files;
5561
5561
  try {
5562
- files = await (0, import_promises.readdir)(path17, this._rdOptions);
5562
+ files = await (0, import_promises.readdir)(path18, this._rdOptions);
5563
5563
  } catch (error48) {
5564
5564
  this._onError(error48);
5565
5565
  }
5566
- return { files, depth, path: path17 };
5566
+ return { files, depth, path: path18 };
5567
5567
  }
5568
- async _formatEntry(dirent, path17) {
5568
+ async _formatEntry(dirent, path18) {
5569
5569
  let entry;
5570
5570
  const basename7 = this._isDirent ? dirent.name : dirent;
5571
5571
  try {
5572
- const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path17, basename7));
5572
+ const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path18, basename7));
5573
5573
  entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename7 };
5574
5574
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
5575
5575
  } catch (err) {
@@ -5626,16 +5626,16 @@ var init_readdirp = __esm({
5626
5626
  });
5627
5627
 
5628
5628
  // ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
5629
- function createFsWatchInstance(path17, options, listener, errHandler, emitRaw) {
5629
+ function createFsWatchInstance(path18, options, listener, errHandler, emitRaw) {
5630
5630
  const handleEvent = (rawEvent, evPath) => {
5631
- listener(path17);
5632
- emitRaw(rawEvent, evPath, { watchedPath: path17 });
5633
- if (evPath && path17 !== evPath) {
5634
- fsWatchBroadcast(sp.resolve(path17, evPath), KEY_LISTENERS, sp.join(path17, evPath));
5631
+ listener(path18);
5632
+ emitRaw(rawEvent, evPath, { watchedPath: path18 });
5633
+ if (evPath && path18 !== evPath) {
5634
+ fsWatchBroadcast(sp.resolve(path18, evPath), KEY_LISTENERS, sp.join(path18, evPath));
5635
5635
  }
5636
5636
  };
5637
5637
  try {
5638
- return (0, import_node_fs.watch)(path17, {
5638
+ return (0, import_node_fs.watch)(path18, {
5639
5639
  persistent: options.persistent
5640
5640
  }, handleEvent);
5641
5641
  } catch (error48) {
@@ -5984,12 +5984,12 @@ var init_handler2 = __esm({
5984
5984
  listener(val1, val2, val3);
5985
5985
  });
5986
5986
  };
5987
- setFsWatchListener = (path17, fullPath, options, handlers) => {
5987
+ setFsWatchListener = (path18, fullPath, options, handlers) => {
5988
5988
  const { listener, errHandler, rawEmitter } = handlers;
5989
5989
  let cont = FsWatchInstances.get(fullPath);
5990
5990
  let watcher;
5991
5991
  if (!options.persistent) {
5992
- watcher = createFsWatchInstance(path17, options, listener, errHandler, rawEmitter);
5992
+ watcher = createFsWatchInstance(path18, options, listener, errHandler, rawEmitter);
5993
5993
  if (!watcher)
5994
5994
  return;
5995
5995
  return watcher.close.bind(watcher);
@@ -6000,7 +6000,7 @@ var init_handler2 = __esm({
6000
6000
  addAndConvert(cont, KEY_RAW, rawEmitter);
6001
6001
  } else {
6002
6002
  watcher = createFsWatchInstance(
6003
- path17,
6003
+ path18,
6004
6004
  options,
6005
6005
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
6006
6006
  errHandler,
@@ -6015,7 +6015,7 @@ var init_handler2 = __esm({
6015
6015
  cont.watcherUnusable = true;
6016
6016
  if (isWindows && error48.code === "EPERM") {
6017
6017
  try {
6018
- const fd = await (0, import_promises2.open)(path17, "r");
6018
+ const fd = await (0, import_promises2.open)(path18, "r");
6019
6019
  await fd.close();
6020
6020
  broadcastErr(error48);
6021
6021
  } catch (err) {
@@ -6046,7 +6046,7 @@ var init_handler2 = __esm({
6046
6046
  };
6047
6047
  };
6048
6048
  FsWatchFileInstances = /* @__PURE__ */ new Map();
6049
- setFsWatchFileListener = (path17, fullPath, options, handlers) => {
6049
+ setFsWatchFileListener = (path18, fullPath, options, handlers) => {
6050
6050
  const { listener, rawEmitter } = handlers;
6051
6051
  let cont = FsWatchFileInstances.get(fullPath);
6052
6052
  const copts = cont && cont.options;
@@ -6068,7 +6068,7 @@ var init_handler2 = __esm({
6068
6068
  });
6069
6069
  const currmtime = curr.mtimeMs;
6070
6070
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
6071
- foreach(cont.listeners, (listener2) => listener2(path17, curr));
6071
+ foreach(cont.listeners, (listener2) => listener2(path18, curr));
6072
6072
  }
6073
6073
  })
6074
6074
  };
@@ -6098,13 +6098,13 @@ var init_handler2 = __esm({
6098
6098
  * @param listener on fs change
6099
6099
  * @returns closer for the watcher instance
6100
6100
  */
6101
- _watchWithNodeFs(path17, listener) {
6101
+ _watchWithNodeFs(path18, listener) {
6102
6102
  const opts = this.fsw.options;
6103
- const directory = sp.dirname(path17);
6104
- const basename7 = sp.basename(path17);
6103
+ const directory = sp.dirname(path18);
6104
+ const basename7 = sp.basename(path18);
6105
6105
  const parent = this.fsw._getWatchedDir(directory);
6106
6106
  parent.add(basename7);
6107
- const absolutePath = sp.resolve(path17);
6107
+ const absolutePath = sp.resolve(path18);
6108
6108
  const options = {
6109
6109
  persistent: opts.persistent
6110
6110
  };
@@ -6114,12 +6114,12 @@ var init_handler2 = __esm({
6114
6114
  if (opts.usePolling) {
6115
6115
  const enableBin = opts.interval !== opts.binaryInterval;
6116
6116
  options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
6117
- closer = setFsWatchFileListener(path17, absolutePath, options, {
6117
+ closer = setFsWatchFileListener(path18, absolutePath, options, {
6118
6118
  listener,
6119
6119
  rawEmitter: this.fsw._emitRaw
6120
6120
  });
6121
6121
  } else {
6122
- closer = setFsWatchListener(path17, absolutePath, options, {
6122
+ closer = setFsWatchListener(path18, absolutePath, options, {
6123
6123
  listener,
6124
6124
  errHandler: this._boundHandleError,
6125
6125
  rawEmitter: this.fsw._emitRaw
@@ -6141,7 +6141,7 @@ var init_handler2 = __esm({
6141
6141
  let prevStats = stats;
6142
6142
  if (parent.has(basename7))
6143
6143
  return;
6144
- const listener = async (path17, newStats) => {
6144
+ const listener = async (path18, newStats) => {
6145
6145
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
6146
6146
  return;
6147
6147
  if (!newStats || newStats.mtimeMs === 0) {
@@ -6155,11 +6155,11 @@ var init_handler2 = __esm({
6155
6155
  this.fsw._emit(EV.CHANGE, file2, newStats2);
6156
6156
  }
6157
6157
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
6158
- this.fsw._closeFile(path17);
6158
+ this.fsw._closeFile(path18);
6159
6159
  prevStats = newStats2;
6160
6160
  const closer2 = this._watchWithNodeFs(file2, listener);
6161
6161
  if (closer2)
6162
- this.fsw._addPathCloser(path17, closer2);
6162
+ this.fsw._addPathCloser(path18, closer2);
6163
6163
  } else {
6164
6164
  prevStats = newStats2;
6165
6165
  }
@@ -6191,7 +6191,7 @@ var init_handler2 = __esm({
6191
6191
  * @param item basename of this item
6192
6192
  * @returns true if no more processing is needed for this entry.
6193
6193
  */
6194
- async _handleSymlink(entry, directory, path17, item) {
6194
+ async _handleSymlink(entry, directory, path18, item) {
6195
6195
  if (this.fsw.closed) {
6196
6196
  return;
6197
6197
  }
@@ -6201,7 +6201,7 @@ var init_handler2 = __esm({
6201
6201
  this.fsw._incrReadyCount();
6202
6202
  let linkPath;
6203
6203
  try {
6204
- linkPath = await (0, import_promises2.realpath)(path17);
6204
+ linkPath = await (0, import_promises2.realpath)(path18);
6205
6205
  } catch (e) {
6206
6206
  this.fsw._emitReady();
6207
6207
  return true;
@@ -6211,12 +6211,12 @@ var init_handler2 = __esm({
6211
6211
  if (dir.has(item)) {
6212
6212
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
6213
6213
  this.fsw._symlinkPaths.set(full, linkPath);
6214
- this.fsw._emit(EV.CHANGE, path17, entry.stats);
6214
+ this.fsw._emit(EV.CHANGE, path18, entry.stats);
6215
6215
  }
6216
6216
  } else {
6217
6217
  dir.add(item);
6218
6218
  this.fsw._symlinkPaths.set(full, linkPath);
6219
- this.fsw._emit(EV.ADD, path17, entry.stats);
6219
+ this.fsw._emit(EV.ADD, path18, entry.stats);
6220
6220
  }
6221
6221
  this.fsw._emitReady();
6222
6222
  return true;
@@ -6246,9 +6246,9 @@ var init_handler2 = __esm({
6246
6246
  return;
6247
6247
  }
6248
6248
  const item = entry.path;
6249
- let path17 = sp.join(directory, item);
6249
+ let path18 = sp.join(directory, item);
6250
6250
  current.add(item);
6251
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path17, item)) {
6251
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path18, item)) {
6252
6252
  return;
6253
6253
  }
6254
6254
  if (this.fsw.closed) {
@@ -6257,11 +6257,11 @@ var init_handler2 = __esm({
6257
6257
  }
6258
6258
  if (item === target || !target && !previous.has(item)) {
6259
6259
  this.fsw._incrReadyCount();
6260
- path17 = sp.join(dir, sp.relative(dir, path17));
6261
- this._addToNodeFs(path17, initialAdd, wh, depth + 1);
6260
+ path18 = sp.join(dir, sp.relative(dir, path18));
6261
+ this._addToNodeFs(path18, initialAdd, wh, depth + 1);
6262
6262
  }
6263
6263
  }).on(EV.ERROR, this._boundHandleError);
6264
- return new Promise((resolve11, reject) => {
6264
+ return new Promise((resolve12, reject) => {
6265
6265
  if (!stream)
6266
6266
  return reject();
6267
6267
  stream.once(STR_END, () => {
@@ -6270,7 +6270,7 @@ var init_handler2 = __esm({
6270
6270
  return;
6271
6271
  }
6272
6272
  const wasThrottled = throttler ? throttler.clear() : false;
6273
- resolve11(void 0);
6273
+ resolve12(void 0);
6274
6274
  previous.getChildren().filter((item) => {
6275
6275
  return item !== directory && !current.has(item);
6276
6276
  }).forEach((item) => {
@@ -6327,13 +6327,13 @@ var init_handler2 = __esm({
6327
6327
  * @param depth Child path actually targeted for watch
6328
6328
  * @param target Child path actually targeted for watch
6329
6329
  */
6330
- async _addToNodeFs(path17, initialAdd, priorWh, depth, target) {
6330
+ async _addToNodeFs(path18, initialAdd, priorWh, depth, target) {
6331
6331
  const ready = this.fsw._emitReady;
6332
- if (this.fsw._isIgnored(path17) || this.fsw.closed) {
6332
+ if (this.fsw._isIgnored(path18) || this.fsw.closed) {
6333
6333
  ready();
6334
6334
  return false;
6335
6335
  }
6336
- const wh = this.fsw._getWatchHelpers(path17);
6336
+ const wh = this.fsw._getWatchHelpers(path18);
6337
6337
  if (priorWh) {
6338
6338
  wh.filterPath = (entry) => priorWh.filterPath(entry);
6339
6339
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -6349,8 +6349,8 @@ var init_handler2 = __esm({
6349
6349
  const follow = this.fsw.options.followSymlinks;
6350
6350
  let closer;
6351
6351
  if (stats.isDirectory()) {
6352
- const absPath = sp.resolve(path17);
6353
- const targetPath = follow ? await (0, import_promises2.realpath)(path17) : path17;
6352
+ const absPath = sp.resolve(path18);
6353
+ const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
6354
6354
  if (this.fsw.closed)
6355
6355
  return;
6356
6356
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -6360,29 +6360,29 @@ var init_handler2 = __esm({
6360
6360
  this.fsw._symlinkPaths.set(absPath, targetPath);
6361
6361
  }
6362
6362
  } else if (stats.isSymbolicLink()) {
6363
- const targetPath = follow ? await (0, import_promises2.realpath)(path17) : path17;
6363
+ const targetPath = follow ? await (0, import_promises2.realpath)(path18) : path18;
6364
6364
  if (this.fsw.closed)
6365
6365
  return;
6366
6366
  const parent = sp.dirname(wh.watchPath);
6367
6367
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
6368
6368
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
6369
- closer = await this._handleDir(parent, stats, initialAdd, depth, path17, wh, targetPath);
6369
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path18, wh, targetPath);
6370
6370
  if (this.fsw.closed)
6371
6371
  return;
6372
6372
  if (targetPath !== void 0) {
6373
- this.fsw._symlinkPaths.set(sp.resolve(path17), targetPath);
6373
+ this.fsw._symlinkPaths.set(sp.resolve(path18), targetPath);
6374
6374
  }
6375
6375
  } else {
6376
6376
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
6377
6377
  }
6378
6378
  ready();
6379
6379
  if (closer)
6380
- this.fsw._addPathCloser(path17, closer);
6380
+ this.fsw._addPathCloser(path18, closer);
6381
6381
  return false;
6382
6382
  } catch (error48) {
6383
6383
  if (this.fsw._handleError(error48)) {
6384
6384
  ready();
6385
- return path17;
6385
+ return path18;
6386
6386
  }
6387
6387
  }
6388
6388
  }
@@ -6417,24 +6417,24 @@ function createPattern(matcher) {
6417
6417
  }
6418
6418
  return () => false;
6419
6419
  }
6420
- function normalizePath(path17) {
6421
- if (typeof path17 !== "string")
6420
+ function normalizePath(path18) {
6421
+ if (typeof path18 !== "string")
6422
6422
  throw new Error("string expected");
6423
- path17 = sp2.normalize(path17);
6424
- path17 = path17.replace(/\\/g, "/");
6423
+ path18 = sp2.normalize(path18);
6424
+ path18 = path18.replace(/\\/g, "/");
6425
6425
  let prepend = false;
6426
- if (path17.startsWith("//"))
6426
+ if (path18.startsWith("//"))
6427
6427
  prepend = true;
6428
- path17 = path17.replace(DOUBLE_SLASH_RE, "/");
6428
+ path18 = path18.replace(DOUBLE_SLASH_RE, "/");
6429
6429
  if (prepend)
6430
- path17 = "/" + path17;
6431
- return path17;
6430
+ path18 = "/" + path18;
6431
+ return path18;
6432
6432
  }
6433
6433
  function matchPatterns(patterns, testString, stats) {
6434
- const path17 = normalizePath(testString);
6434
+ const path18 = normalizePath(testString);
6435
6435
  for (let index = 0; index < patterns.length; index++) {
6436
6436
  const pattern = patterns[index];
6437
- if (pattern(path17, stats)) {
6437
+ if (pattern(path18, stats)) {
6438
6438
  return true;
6439
6439
  }
6440
6440
  }
@@ -6497,19 +6497,19 @@ var init_chokidar = __esm({
6497
6497
  }
6498
6498
  return str;
6499
6499
  };
6500
- normalizePathToUnix = (path17) => toUnix(sp2.normalize(toUnix(path17)));
6501
- normalizeIgnored = (cwd = "") => (path17) => {
6502
- if (typeof path17 === "string") {
6503
- return normalizePathToUnix(sp2.isAbsolute(path17) ? path17 : sp2.join(cwd, path17));
6500
+ normalizePathToUnix = (path18) => toUnix(sp2.normalize(toUnix(path18)));
6501
+ normalizeIgnored = (cwd = "") => (path18) => {
6502
+ if (typeof path18 === "string") {
6503
+ return normalizePathToUnix(sp2.isAbsolute(path18) ? path18 : sp2.join(cwd, path18));
6504
6504
  } else {
6505
- return path17;
6505
+ return path18;
6506
6506
  }
6507
6507
  };
6508
- getAbsolutePath = (path17, cwd) => {
6509
- if (sp2.isAbsolute(path17)) {
6510
- return path17;
6508
+ getAbsolutePath = (path18, cwd) => {
6509
+ if (sp2.isAbsolute(path18)) {
6510
+ return path18;
6511
6511
  }
6512
- return sp2.join(cwd, path17);
6512
+ return sp2.join(cwd, path18);
6513
6513
  };
6514
6514
  EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
6515
6515
  DirEntry = class {
@@ -6574,10 +6574,10 @@ var init_chokidar = __esm({
6574
6574
  dirParts;
6575
6575
  followSymlinks;
6576
6576
  statMethod;
6577
- constructor(path17, follow, fsw) {
6577
+ constructor(path18, follow, fsw) {
6578
6578
  this.fsw = fsw;
6579
- const watchPath = path17;
6580
- this.path = path17 = path17.replace(REPLACER_RE, "");
6579
+ const watchPath = path18;
6580
+ this.path = path18 = path18.replace(REPLACER_RE, "");
6581
6581
  this.watchPath = watchPath;
6582
6582
  this.fullWatchPath = sp2.resolve(watchPath);
6583
6583
  this.dirParts = [];
@@ -6717,20 +6717,20 @@ var init_chokidar = __esm({
6717
6717
  this._closePromise = void 0;
6718
6718
  let paths = unifyPaths(paths_);
6719
6719
  if (cwd) {
6720
- paths = paths.map((path17) => {
6721
- const absPath = getAbsolutePath(path17, cwd);
6720
+ paths = paths.map((path18) => {
6721
+ const absPath = getAbsolutePath(path18, cwd);
6722
6722
  return absPath;
6723
6723
  });
6724
6724
  }
6725
- paths.forEach((path17) => {
6726
- this._removeIgnoredPath(path17);
6725
+ paths.forEach((path18) => {
6726
+ this._removeIgnoredPath(path18);
6727
6727
  });
6728
6728
  this._userIgnored = void 0;
6729
6729
  if (!this._readyCount)
6730
6730
  this._readyCount = 0;
6731
6731
  this._readyCount += paths.length;
6732
- Promise.all(paths.map(async (path17) => {
6733
- const res = await this._nodeFsHandler._addToNodeFs(path17, !_internal, void 0, 0, _origAdd);
6732
+ Promise.all(paths.map(async (path18) => {
6733
+ const res = await this._nodeFsHandler._addToNodeFs(path18, !_internal, void 0, 0, _origAdd);
6734
6734
  if (res)
6735
6735
  this._emitReady();
6736
6736
  return res;
@@ -6752,17 +6752,17 @@ var init_chokidar = __esm({
6752
6752
  return this;
6753
6753
  const paths = unifyPaths(paths_);
6754
6754
  const { cwd } = this.options;
6755
- paths.forEach((path17) => {
6756
- if (!sp2.isAbsolute(path17) && !this._closers.has(path17)) {
6755
+ paths.forEach((path18) => {
6756
+ if (!sp2.isAbsolute(path18) && !this._closers.has(path18)) {
6757
6757
  if (cwd)
6758
- path17 = sp2.join(cwd, path17);
6759
- path17 = sp2.resolve(path17);
6758
+ path18 = sp2.join(cwd, path18);
6759
+ path18 = sp2.resolve(path18);
6760
6760
  }
6761
- this._closePath(path17);
6762
- this._addIgnoredPath(path17);
6763
- if (this._watched.has(path17)) {
6761
+ this._closePath(path18);
6762
+ this._addIgnoredPath(path18);
6763
+ if (this._watched.has(path18)) {
6764
6764
  this._addIgnoredPath({
6765
- path: path17,
6765
+ path: path18,
6766
6766
  recursive: true
6767
6767
  });
6768
6768
  }
@@ -6826,38 +6826,38 @@ var init_chokidar = __esm({
6826
6826
  * @param stats arguments to be passed with event
6827
6827
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
6828
6828
  */
6829
- async _emit(event, path17, stats) {
6829
+ async _emit(event, path18, stats) {
6830
6830
  if (this.closed)
6831
6831
  return;
6832
6832
  const opts = this.options;
6833
6833
  if (isWindows)
6834
- path17 = sp2.normalize(path17);
6834
+ path18 = sp2.normalize(path18);
6835
6835
  if (opts.cwd)
6836
- path17 = sp2.relative(opts.cwd, path17);
6837
- const args = [path17];
6836
+ path18 = sp2.relative(opts.cwd, path18);
6837
+ const args = [path18];
6838
6838
  if (stats != null)
6839
6839
  args.push(stats);
6840
6840
  const awf = opts.awaitWriteFinish;
6841
6841
  let pw;
6842
- if (awf && (pw = this._pendingWrites.get(path17))) {
6842
+ if (awf && (pw = this._pendingWrites.get(path18))) {
6843
6843
  pw.lastChange = /* @__PURE__ */ new Date();
6844
6844
  return this;
6845
6845
  }
6846
6846
  if (opts.atomic) {
6847
6847
  if (event === EVENTS.UNLINK) {
6848
- this._pendingUnlinks.set(path17, [event, ...args]);
6848
+ this._pendingUnlinks.set(path18, [event, ...args]);
6849
6849
  setTimeout(() => {
6850
- this._pendingUnlinks.forEach((entry, path18) => {
6850
+ this._pendingUnlinks.forEach((entry, path19) => {
6851
6851
  this.emit(...entry);
6852
6852
  this.emit(EVENTS.ALL, ...entry);
6853
- this._pendingUnlinks.delete(path18);
6853
+ this._pendingUnlinks.delete(path19);
6854
6854
  });
6855
6855
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
6856
6856
  return this;
6857
6857
  }
6858
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path17)) {
6858
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path18)) {
6859
6859
  event = EVENTS.CHANGE;
6860
- this._pendingUnlinks.delete(path17);
6860
+ this._pendingUnlinks.delete(path18);
6861
6861
  }
6862
6862
  }
6863
6863
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -6875,16 +6875,16 @@ var init_chokidar = __esm({
6875
6875
  this.emitWithAll(event, args);
6876
6876
  }
6877
6877
  };
6878
- this._awaitWriteFinish(path17, awf.stabilityThreshold, event, awfEmit);
6878
+ this._awaitWriteFinish(path18, awf.stabilityThreshold, event, awfEmit);
6879
6879
  return this;
6880
6880
  }
6881
6881
  if (event === EVENTS.CHANGE) {
6882
- const isThrottled = !this._throttle(EVENTS.CHANGE, path17, 50);
6882
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path18, 50);
6883
6883
  if (isThrottled)
6884
6884
  return this;
6885
6885
  }
6886
6886
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
6887
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path17) : path17;
6887
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path18) : path18;
6888
6888
  let stats2;
6889
6889
  try {
6890
6890
  stats2 = await (0, import_promises3.stat)(fullPath);
@@ -6915,23 +6915,23 @@ var init_chokidar = __esm({
6915
6915
  * @param timeout duration of time to suppress duplicate actions
6916
6916
  * @returns tracking object or false if action should be suppressed
6917
6917
  */
6918
- _throttle(actionType, path17, timeout) {
6918
+ _throttle(actionType, path18, timeout) {
6919
6919
  if (!this._throttled.has(actionType)) {
6920
6920
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
6921
6921
  }
6922
6922
  const action = this._throttled.get(actionType);
6923
6923
  if (!action)
6924
6924
  throw new Error("invalid throttle");
6925
- const actionPath = action.get(path17);
6925
+ const actionPath = action.get(path18);
6926
6926
  if (actionPath) {
6927
6927
  actionPath.count++;
6928
6928
  return false;
6929
6929
  }
6930
6930
  let timeoutObject;
6931
6931
  const clear = () => {
6932
- const item = action.get(path17);
6932
+ const item = action.get(path18);
6933
6933
  const count = item ? item.count : 0;
6934
- action.delete(path17);
6934
+ action.delete(path18);
6935
6935
  clearTimeout(timeoutObject);
6936
6936
  if (item)
6937
6937
  clearTimeout(item.timeoutObject);
@@ -6939,7 +6939,7 @@ var init_chokidar = __esm({
6939
6939
  };
6940
6940
  timeoutObject = setTimeout(clear, timeout);
6941
6941
  const thr = { timeoutObject, clear, count: 0 };
6942
- action.set(path17, thr);
6942
+ action.set(path18, thr);
6943
6943
  return thr;
6944
6944
  }
6945
6945
  _incrReadyCount() {
@@ -6953,44 +6953,44 @@ var init_chokidar = __esm({
6953
6953
  * @param event
6954
6954
  * @param awfEmit Callback to be called when ready for event to be emitted.
6955
6955
  */
6956
- _awaitWriteFinish(path17, threshold, event, awfEmit) {
6956
+ _awaitWriteFinish(path18, threshold, event, awfEmit) {
6957
6957
  const awf = this.options.awaitWriteFinish;
6958
6958
  if (typeof awf !== "object")
6959
6959
  return;
6960
6960
  const pollInterval = awf.pollInterval;
6961
6961
  let timeoutHandler;
6962
- let fullPath = path17;
6963
- if (this.options.cwd && !sp2.isAbsolute(path17)) {
6964
- fullPath = sp2.join(this.options.cwd, path17);
6962
+ let fullPath = path18;
6963
+ if (this.options.cwd && !sp2.isAbsolute(path18)) {
6964
+ fullPath = sp2.join(this.options.cwd, path18);
6965
6965
  }
6966
6966
  const now = /* @__PURE__ */ new Date();
6967
6967
  const writes = this._pendingWrites;
6968
6968
  function awaitWriteFinishFn(prevStat) {
6969
6969
  (0, import_node_fs2.stat)(fullPath, (err, curStat) => {
6970
- if (err || !writes.has(path17)) {
6970
+ if (err || !writes.has(path18)) {
6971
6971
  if (err && err.code !== "ENOENT")
6972
6972
  awfEmit(err);
6973
6973
  return;
6974
6974
  }
6975
6975
  const now2 = Number(/* @__PURE__ */ new Date());
6976
6976
  if (prevStat && curStat.size !== prevStat.size) {
6977
- writes.get(path17).lastChange = now2;
6977
+ writes.get(path18).lastChange = now2;
6978
6978
  }
6979
- const pw = writes.get(path17);
6979
+ const pw = writes.get(path18);
6980
6980
  const df = now2 - pw.lastChange;
6981
6981
  if (df >= threshold) {
6982
- writes.delete(path17);
6982
+ writes.delete(path18);
6983
6983
  awfEmit(void 0, curStat);
6984
6984
  } else {
6985
6985
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
6986
6986
  }
6987
6987
  });
6988
6988
  }
6989
- if (!writes.has(path17)) {
6990
- writes.set(path17, {
6989
+ if (!writes.has(path18)) {
6990
+ writes.set(path18, {
6991
6991
  lastChange: now,
6992
6992
  cancelWait: () => {
6993
- writes.delete(path17);
6993
+ writes.delete(path18);
6994
6994
  clearTimeout(timeoutHandler);
6995
6995
  return event;
6996
6996
  }
@@ -7001,8 +7001,8 @@ var init_chokidar = __esm({
7001
7001
  /**
7002
7002
  * Determines whether user has asked to ignore this path.
7003
7003
  */
7004
- _isIgnored(path17, stats) {
7005
- if (this.options.atomic && DOT_RE.test(path17))
7004
+ _isIgnored(path18, stats) {
7005
+ if (this.options.atomic && DOT_RE.test(path18))
7006
7006
  return true;
7007
7007
  if (!this._userIgnored) {
7008
7008
  const { cwd } = this.options;
@@ -7012,17 +7012,17 @@ var init_chokidar = __esm({
7012
7012
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
7013
7013
  this._userIgnored = anymatch(list, void 0);
7014
7014
  }
7015
- return this._userIgnored(path17, stats);
7015
+ return this._userIgnored(path18, stats);
7016
7016
  }
7017
- _isntIgnored(path17, stat4) {
7018
- return !this._isIgnored(path17, stat4);
7017
+ _isntIgnored(path18, stat4) {
7018
+ return !this._isIgnored(path18, stat4);
7019
7019
  }
7020
7020
  /**
7021
7021
  * Provides a set of common helpers and properties relating to symlink handling.
7022
7022
  * @param path file or directory pattern being watched
7023
7023
  */
7024
- _getWatchHelpers(path17) {
7025
- return new WatchHelper(path17, this.options.followSymlinks, this);
7024
+ _getWatchHelpers(path18) {
7025
+ return new WatchHelper(path18, this.options.followSymlinks, this);
7026
7026
  }
7027
7027
  // Directory helpers
7028
7028
  // -----------------
@@ -7054,63 +7054,63 @@ var init_chokidar = __esm({
7054
7054
  * @param item base path of item/directory
7055
7055
  */
7056
7056
  _remove(directory, item, isDirectory) {
7057
- const path17 = sp2.join(directory, item);
7058
- const fullPath = sp2.resolve(path17);
7059
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path17) || this._watched.has(fullPath);
7060
- if (!this._throttle("remove", path17, 100))
7057
+ const path18 = sp2.join(directory, item);
7058
+ const fullPath = sp2.resolve(path18);
7059
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path18) || this._watched.has(fullPath);
7060
+ if (!this._throttle("remove", path18, 100))
7061
7061
  return;
7062
7062
  if (!isDirectory && this._watched.size === 1) {
7063
7063
  this.add(directory, item, true);
7064
7064
  }
7065
- const wp = this._getWatchedDir(path17);
7065
+ const wp = this._getWatchedDir(path18);
7066
7066
  const nestedDirectoryChildren = wp.getChildren();
7067
- nestedDirectoryChildren.forEach((nested) => this._remove(path17, nested));
7067
+ nestedDirectoryChildren.forEach((nested) => this._remove(path18, nested));
7068
7068
  const parent = this._getWatchedDir(directory);
7069
7069
  const wasTracked = parent.has(item);
7070
7070
  parent.remove(item);
7071
7071
  if (this._symlinkPaths.has(fullPath)) {
7072
7072
  this._symlinkPaths.delete(fullPath);
7073
7073
  }
7074
- let relPath = path17;
7074
+ let relPath = path18;
7075
7075
  if (this.options.cwd)
7076
- relPath = sp2.relative(this.options.cwd, path17);
7076
+ relPath = sp2.relative(this.options.cwd, path18);
7077
7077
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
7078
7078
  const event = this._pendingWrites.get(relPath).cancelWait();
7079
7079
  if (event === EVENTS.ADD)
7080
7080
  return;
7081
7081
  }
7082
- this._watched.delete(path17);
7082
+ this._watched.delete(path18);
7083
7083
  this._watched.delete(fullPath);
7084
7084
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
7085
- if (wasTracked && !this._isIgnored(path17))
7086
- this._emit(eventName, path17);
7087
- this._closePath(path17);
7085
+ if (wasTracked && !this._isIgnored(path18))
7086
+ this._emit(eventName, path18);
7087
+ this._closePath(path18);
7088
7088
  }
7089
7089
  /**
7090
7090
  * Closes all watchers for a path
7091
7091
  */
7092
- _closePath(path17) {
7093
- this._closeFile(path17);
7094
- const dir = sp2.dirname(path17);
7095
- this._getWatchedDir(dir).remove(sp2.basename(path17));
7092
+ _closePath(path18) {
7093
+ this._closeFile(path18);
7094
+ const dir = sp2.dirname(path18);
7095
+ this._getWatchedDir(dir).remove(sp2.basename(path18));
7096
7096
  }
7097
7097
  /**
7098
7098
  * Closes only file-specific watchers
7099
7099
  */
7100
- _closeFile(path17) {
7101
- const closers = this._closers.get(path17);
7100
+ _closeFile(path18) {
7101
+ const closers = this._closers.get(path18);
7102
7102
  if (!closers)
7103
7103
  return;
7104
7104
  closers.forEach((closer) => closer());
7105
- this._closers.delete(path17);
7105
+ this._closers.delete(path18);
7106
7106
  }
7107
- _addPathCloser(path17, closer) {
7107
+ _addPathCloser(path18, closer) {
7108
7108
  if (!closer)
7109
7109
  return;
7110
- let list = this._closers.get(path17);
7110
+ let list = this._closers.get(path18);
7111
7111
  if (!list) {
7112
7112
  list = [];
7113
- this._closers.set(path17, list);
7113
+ this._closers.set(path18, list);
7114
7114
  }
7115
7115
  list.push(closer);
7116
7116
  }
@@ -7690,7 +7690,7 @@ var init_provider_loader = __esm({
7690
7690
  return { updated: false };
7691
7691
  }
7692
7692
  try {
7693
- const etag = await new Promise((resolve11, reject) => {
7693
+ const etag = await new Promise((resolve12, reject) => {
7694
7694
  const options = {
7695
7695
  method: "HEAD",
7696
7696
  hostname: "github.com",
@@ -7708,7 +7708,7 @@ var init_provider_loader = __esm({
7708
7708
  headers: { "User-Agent": "adhdev-launcher" },
7709
7709
  timeout: 1e4
7710
7710
  }, (res2) => {
7711
- resolve11(res2.headers.etag || res2.headers["last-modified"] || "");
7711
+ resolve12(res2.headers.etag || res2.headers["last-modified"] || "");
7712
7712
  });
7713
7713
  req2.on("error", reject);
7714
7714
  req2.on("timeout", () => {
@@ -7717,7 +7717,7 @@ var init_provider_loader = __esm({
7717
7717
  });
7718
7718
  req2.end();
7719
7719
  } else {
7720
- resolve11(res.headers.etag || res.headers["last-modified"] || "");
7720
+ resolve12(res.headers.etag || res.headers["last-modified"] || "");
7721
7721
  }
7722
7722
  });
7723
7723
  req.on("error", reject);
@@ -7781,7 +7781,7 @@ var init_provider_loader = __esm({
7781
7781
  downloadFile(url2, destPath) {
7782
7782
  const https = require("https");
7783
7783
  const http3 = require("http");
7784
- return new Promise((resolve11, reject) => {
7784
+ return new Promise((resolve12, reject) => {
7785
7785
  const doRequest = (reqUrl, redirectCount = 0) => {
7786
7786
  if (redirectCount > 5) {
7787
7787
  reject(new Error("Too many redirects"));
@@ -7801,7 +7801,7 @@ var init_provider_loader = __esm({
7801
7801
  res.pipe(ws2);
7802
7802
  ws2.on("finish", () => {
7803
7803
  ws2.close();
7804
- resolve11();
7804
+ resolve12();
7805
7805
  });
7806
7806
  ws2.on("error", reject);
7807
7807
  });
@@ -8167,17 +8167,17 @@ async function findFreePort(ports) {
8167
8167
  throw new Error("No free port found");
8168
8168
  }
8169
8169
  function checkPortFree(port) {
8170
- return new Promise((resolve11) => {
8170
+ return new Promise((resolve12) => {
8171
8171
  const server = net.createServer();
8172
8172
  server.unref();
8173
- server.on("error", () => resolve11(false));
8173
+ server.on("error", () => resolve12(false));
8174
8174
  server.listen(port, "127.0.0.1", () => {
8175
- server.close(() => resolve11(true));
8175
+ server.close(() => resolve12(true));
8176
8176
  });
8177
8177
  });
8178
8178
  }
8179
8179
  async function isCdpActive(port) {
8180
- return new Promise((resolve11) => {
8180
+ return new Promise((resolve12) => {
8181
8181
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
8182
8182
  timeout: 2e3
8183
8183
  }, (res) => {
@@ -8186,16 +8186,16 @@ async function isCdpActive(port) {
8186
8186
  res.on("end", () => {
8187
8187
  try {
8188
8188
  const info = JSON.parse(data);
8189
- resolve11(!!info["WebKit-Version"] || !!info["Browser"]);
8189
+ resolve12(!!info["WebKit-Version"] || !!info["Browser"]);
8190
8190
  } catch {
8191
- resolve11(false);
8191
+ resolve12(false);
8192
8192
  }
8193
8193
  });
8194
8194
  });
8195
- req.on("error", () => resolve11(false));
8195
+ req.on("error", () => resolve12(false));
8196
8196
  req.on("timeout", () => {
8197
8197
  req.destroy();
8198
- resolve11(false);
8198
+ resolve12(false);
8199
8199
  });
8200
8200
  });
8201
8201
  }
@@ -8818,14 +8818,14 @@ var init_router = __esm({
8818
8818
  setTimeout(() => {
8819
8819
  LOG.info("Upgrade", "Restarting daemon with new version...");
8820
8820
  try {
8821
- const path17 = require("path");
8821
+ const path18 = require("path");
8822
8822
  const fs15 = require("fs");
8823
- const pidFile = path17.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
8823
+ const pidFile = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
8824
8824
  if (fs15.existsSync(pidFile)) fs15.unlinkSync(pidFile);
8825
8825
  } catch {
8826
8826
  }
8827
- const { spawn: spawn3 } = require("child_process");
8828
- const child = spawn3(process.execPath, process.argv.slice(1), {
8827
+ const { spawn: spawn4 } = require("child_process");
8828
+ const child = spawn4(process.execPath, process.argv.slice(1), {
8829
8829
  detached: true,
8830
8830
  stdio: "ignore",
8831
8831
  env: { ...process.env }
@@ -19320,7 +19320,7 @@ ${data.message || ""}`.trim();
19320
19320
  if (this.startupParseGate) {
19321
19321
  const deadline = Date.now() + 1e4;
19322
19322
  while (this.startupParseGate && Date.now() < deadline) {
19323
- await new Promise((resolve11) => setTimeout(resolve11, 50));
19323
+ await new Promise((resolve12) => setTimeout(resolve12, 50));
19324
19324
  }
19325
19325
  }
19326
19326
  if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
@@ -19488,17 +19488,17 @@ ${data.message || ""}`.trim();
19488
19488
  }
19489
19489
  }
19490
19490
  waitForStopped(timeoutMs) {
19491
- return new Promise((resolve11) => {
19491
+ return new Promise((resolve12) => {
19492
19492
  const startedAt = Date.now();
19493
19493
  const timer = setInterval(() => {
19494
19494
  if (!this.ptyProcess || this.currentStatus === "stopped") {
19495
19495
  clearInterval(timer);
19496
- resolve11(true);
19496
+ resolve12(true);
19497
19497
  return;
19498
19498
  }
19499
19499
  if (Date.now() - startedAt >= timeoutMs) {
19500
19500
  clearInterval(timer);
19501
- resolve11(false);
19501
+ resolve12(false);
19502
19502
  }
19503
19503
  }, 100);
19504
19504
  });
@@ -20184,10 +20184,10 @@ function mergeDefs(...defs) {
20184
20184
  function cloneDef(schema) {
20185
20185
  return mergeDefs(schema._zod.def);
20186
20186
  }
20187
- function getElementAtPath(obj, path17) {
20188
- if (!path17)
20187
+ function getElementAtPath(obj, path18) {
20188
+ if (!path18)
20189
20189
  return obj;
20190
- return path17.reduce((acc, key) => acc?.[key], obj);
20190
+ return path18.reduce((acc, key) => acc?.[key], obj);
20191
20191
  }
20192
20192
  function promiseAllObject(promisesObj) {
20193
20193
  const keys = Object.keys(promisesObj);
@@ -20499,11 +20499,11 @@ function aborted(x, startIndex = 0) {
20499
20499
  }
20500
20500
  return false;
20501
20501
  }
20502
- function prefixIssues(path17, issues) {
20502
+ function prefixIssues(path18, issues) {
20503
20503
  return issues.map((iss) => {
20504
20504
  var _a2;
20505
20505
  (_a2 = iss).path ?? (_a2.path = []);
20506
- iss.path.unshift(path17);
20506
+ iss.path.unshift(path18);
20507
20507
  return iss;
20508
20508
  });
20509
20509
  }
@@ -20746,7 +20746,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
20746
20746
  }
20747
20747
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
20748
20748
  const result = { errors: [] };
20749
- const processError = (error49, path17 = []) => {
20749
+ const processError = (error49, path18 = []) => {
20750
20750
  var _a2, _b;
20751
20751
  for (const issue2 of error49.issues) {
20752
20752
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -20756,7 +20756,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
20756
20756
  } else if (issue2.code === "invalid_element") {
20757
20757
  processError({ issues: issue2.issues }, issue2.path);
20758
20758
  } else {
20759
- const fullpath = [...path17, ...issue2.path];
20759
+ const fullpath = [...path18, ...issue2.path];
20760
20760
  if (fullpath.length === 0) {
20761
20761
  result.errors.push(mapper(issue2));
20762
20762
  continue;
@@ -20788,8 +20788,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
20788
20788
  }
20789
20789
  function toDotPath(_path) {
20790
20790
  const segs = [];
20791
- const path17 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
20792
- for (const seg of path17) {
20791
+ const path18 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
20792
+ for (const seg of path18) {
20793
20793
  if (typeof seg === "number")
20794
20794
  segs.push(`[${seg}]`);
20795
20795
  else if (typeof seg === "symbol")
@@ -33553,13 +33553,13 @@ function resolveRef(ref, ctx) {
33553
33553
  if (!ref.startsWith("#")) {
33554
33554
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
33555
33555
  }
33556
- const path17 = ref.slice(1).split("/").filter(Boolean);
33557
- if (path17.length === 0) {
33556
+ const path18 = ref.slice(1).split("/").filter(Boolean);
33557
+ if (path18.length === 0) {
33558
33558
  return ctx.rootSchema;
33559
33559
  }
33560
33560
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
33561
- if (path17[0] === defsKey) {
33562
- const key = path17[1];
33561
+ if (path18[0] === defsKey) {
33562
+ const key = path18[1];
33563
33563
  if (!key || !ctx.defs[key]) {
33564
33564
  throw new Error(`Reference not found: ${ref}`);
33565
33565
  }
@@ -35986,8 +35986,8 @@ var init_acp = __esm({
35986
35986
  this.#requestHandler = requestHandler;
35987
35987
  this.#notificationHandler = notificationHandler;
35988
35988
  this.#stream = stream;
35989
- this.#closedPromise = new Promise((resolve11) => {
35990
- this.#abortController.signal.addEventListener("abort", () => resolve11());
35989
+ this.#closedPromise = new Promise((resolve12) => {
35990
+ this.#abortController.signal.addEventListener("abort", () => resolve12());
35991
35991
  });
35992
35992
  this.#receive();
35993
35993
  }
@@ -36136,8 +36136,8 @@ var init_acp = __esm({
36136
36136
  }
36137
36137
  async sendRequest(method, params) {
36138
36138
  const id = this.#nextRequestId++;
36139
- const responsePromise = new Promise((resolve11, reject) => {
36140
- this.#pendingResponses.set(id, { resolve: resolve11, reject });
36139
+ const responsePromise = new Promise((resolve12, reject) => {
36140
+ this.#pendingResponses.set(id, { resolve: resolve12, reject });
36141
36141
  });
36142
36142
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
36143
36143
  return responsePromise;
@@ -36672,13 +36672,13 @@ var init_acp_provider_instance = __esm({
36672
36672
  }
36673
36673
  this.currentStatus = "waiting_approval";
36674
36674
  this.detectStatusTransition();
36675
- const approved = await new Promise((resolve11) => {
36676
- this.permissionResolvers.push(resolve11);
36675
+ const approved = await new Promise((resolve12) => {
36676
+ this.permissionResolvers.push(resolve12);
36677
36677
  setTimeout(() => {
36678
- const idx = this.permissionResolvers.indexOf(resolve11);
36678
+ const idx = this.permissionResolvers.indexOf(resolve12);
36679
36679
  if (idx >= 0) {
36680
36680
  this.permissionResolvers.splice(idx, 1);
36681
- resolve11(false);
36681
+ resolve12(false);
36682
36682
  }
36683
36683
  }, 3e5);
36684
36684
  });
@@ -40326,8 +40326,8 @@ async function handleAutoImplement(ctx, type, req, res) {
40326
40326
  fs11.writeFileSync(promptFile, prompt, "utf-8");
40327
40327
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
40328
40328
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
40329
- const spawn3 = agentProvider?.spawn;
40330
- if (!spawn3?.command) {
40329
+ const spawn4 = agentProvider?.spawn;
40330
+ if (!spawn4?.command) {
40331
40331
  try {
40332
40332
  fs11.unlinkSync(promptFile);
40333
40333
  } catch {
@@ -40337,21 +40337,21 @@ async function handleAutoImplement(ctx, type, req, res) {
40337
40337
  }
40338
40338
  const agentCategory = agentProvider?.category;
40339
40339
  if (agentCategory === "acp") {
40340
- sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn3.command} ${(spawn3.args || []).join(" ")}` } });
40340
+ sendAutoImplSSE(ctx, { event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn4.command} ${(spawn4.args || []).join(" ")}` } });
40341
40341
  ctx.autoImplStatus = { running: true, type, progress: [] };
40342
40342
  const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2, PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
40343
40343
  const { Readable: Readable3, Writable: Writable2 } = await import("stream");
40344
40344
  const { spawn: spawnFn2 } = await import("child_process");
40345
- const acpArgs = [...spawn3.args || []];
40345
+ const acpArgs = [...spawn4.args || []];
40346
40346
  if (model) {
40347
40347
  acpArgs.push("--model", model);
40348
40348
  ctx.log(`Auto-implement ACP using model: ${model}`);
40349
40349
  }
40350
- const child2 = spawnFn2(spawn3.command, acpArgs, {
40350
+ const child2 = spawnFn2(spawn4.command, acpArgs, {
40351
40351
  cwd: providerDir,
40352
40352
  stdio: ["pipe", "pipe", "pipe"],
40353
- shell: spawn3.shell ?? false,
40354
- env: { ...process.env, ...spawn3.env || {} }
40353
+ shell: spawn4.shell ?? false,
40354
+ env: { ...process.env, ...spawn4.env || {} }
40355
40355
  });
40356
40356
  ctx.autoImplProcess = child2;
40357
40357
  child2.stderr?.on("data", (d) => {
@@ -40461,7 +40461,7 @@ async function handleAutoImplement(ctx, type, req, res) {
40461
40461
  ctx.json(res, 202, {
40462
40462
  started: true,
40463
40463
  type,
40464
- agent: spawn3.command,
40464
+ agent: spawn4.command,
40465
40465
  functions,
40466
40466
  providerDir,
40467
40467
  message: "ACP Auto-implement started. Connect to SSE for progress.",
@@ -40469,9 +40469,9 @@ async function handleAutoImplement(ctx, type, req, res) {
40469
40469
  });
40470
40470
  return;
40471
40471
  }
40472
- const command = spawn3.command;
40472
+ const command = spawn4.command;
40473
40473
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
40474
- const baseArgs = [...spawn3.args || []].filter((a) => !interactiveFlags.includes(a));
40474
+ const baseArgs = [...spawn4.args || []].filter((a) => !interactiveFlags.includes(a));
40475
40475
  let shellCmd;
40476
40476
  if (command === "claude") {
40477
40477
  const args = [...baseArgs, "--dangerously-skip-permissions"];
@@ -40515,7 +40515,7 @@ async function handleAutoImplement(ctx, type, req, res) {
40515
40515
  cols: 120,
40516
40516
  rows: 40,
40517
40517
  cwd: providerDir,
40518
- env: { ...process.env, ...spawn3.env || {} }
40518
+ env: { ...process.env, ...spawn4.env || {} }
40519
40519
  });
40520
40520
  isPty = true;
40521
40521
  } catch (err) {
@@ -40527,7 +40527,7 @@ async function handleAutoImplement(ctx, type, req, res) {
40527
40527
  stdio: ["pipe", "pipe", "pipe"],
40528
40528
  env: {
40529
40529
  ...process.env,
40530
- ...spawn3.env || {},
40530
+ ...spawn4.env || {},
40531
40531
  ...command === "gemini" ? { SANDBOX: "1", GEMINI_CLI_NO_RELAUNCH: "1" } : {}
40532
40532
  }
40533
40533
  });
@@ -41277,8 +41277,8 @@ var init_dev_server = __esm({
41277
41277
  }
41278
41278
  getEndpointList() {
41279
41279
  return this.routes.map((r) => {
41280
- const path17 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
41281
- return `${r.method.padEnd(5)} ${path17}`;
41280
+ const path18 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
41281
+ return `${r.method.padEnd(5)} ${path18}`;
41282
41282
  });
41283
41283
  }
41284
41284
  async start(port = DEV_SERVER_PORT) {
@@ -41309,15 +41309,15 @@ var init_dev_server = __esm({
41309
41309
  this.json(res, 500, { error: e.message });
41310
41310
  }
41311
41311
  });
41312
- return new Promise((resolve11, reject) => {
41312
+ return new Promise((resolve12, reject) => {
41313
41313
  this.server.listen(port, "127.0.0.1", () => {
41314
41314
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
41315
- resolve11();
41315
+ resolve12();
41316
41316
  });
41317
41317
  this.server.on("error", (e) => {
41318
41318
  if (e.code === "EADDRINUSE") {
41319
41319
  this.log(`Port ${port} in use, skipping dev server`);
41320
- resolve11();
41320
+ resolve12();
41321
41321
  } else {
41322
41322
  reject(e);
41323
41323
  }
@@ -41379,16 +41379,16 @@ var init_dev_server = __esm({
41379
41379
  this.json(res, 404, { error: `Provider not found: ${type}` });
41380
41380
  return;
41381
41381
  }
41382
- const spawn3 = provider.spawn;
41383
- if (!spawn3) {
41382
+ const spawn4 = provider.spawn;
41383
+ if (!spawn4) {
41384
41384
  this.json(res, 400, { error: `Provider ${type} has no spawn config` });
41385
41385
  return;
41386
41386
  }
41387
41387
  const { spawn: spawnFn } = await import("child_process");
41388
41388
  const start = Date.now();
41389
41389
  try {
41390
- const child = spawnFn(spawn3.command, [...spawn3.args || []], {
41391
- shell: spawn3.shell ?? false,
41390
+ const child = spawnFn(spawn4.command, [...spawn4.args || []], {
41391
+ shell: spawn4.shell ?? false,
41392
41392
  timeout: 5e3,
41393
41393
  stdio: ["pipe", "pipe", "pipe"]
41394
41394
  });
@@ -41400,27 +41400,27 @@ var init_dev_server = __esm({
41400
41400
  child.stderr?.on("data", (d) => {
41401
41401
  stderr += d.toString().slice(0, 2e3);
41402
41402
  });
41403
- await new Promise((resolve11) => {
41403
+ await new Promise((resolve12) => {
41404
41404
  const timer = setTimeout(() => {
41405
41405
  child.kill();
41406
- resolve11();
41406
+ resolve12();
41407
41407
  }, 3e3);
41408
41408
  child.on("exit", () => {
41409
41409
  clearTimeout(timer);
41410
- resolve11();
41410
+ resolve12();
41411
41411
  });
41412
41412
  child.stdout?.once("data", () => {
41413
41413
  setTimeout(() => {
41414
41414
  child.kill();
41415
41415
  clearTimeout(timer);
41416
- resolve11();
41416
+ resolve12();
41417
41417
  }, 500);
41418
41418
  });
41419
41419
  });
41420
41420
  const elapsed = Date.now() - start;
41421
41421
  this.json(res, 200, {
41422
41422
  success: true,
41423
- command: `${spawn3.command} ${(spawn3.args || []).join(" ")}`,
41423
+ command: `${spawn4.command} ${(spawn4.args || []).join(" ")}`,
41424
41424
  elapsed,
41425
41425
  stdout: stdout.trim(),
41426
41426
  stderr: stderr.trim(),
@@ -41430,7 +41430,7 @@ var init_dev_server = __esm({
41430
41430
  const elapsed = Date.now() - start;
41431
41431
  this.json(res, 200, {
41432
41432
  success: false,
41433
- command: `${spawn3.command} ${(spawn3.args || []).join(" ")}`,
41433
+ command: `${spawn4.command} ${(spawn4.args || []).join(" ")}`,
41434
41434
  elapsed,
41435
41435
  error: e.message
41436
41436
  });
@@ -41899,20 +41899,20 @@ var init_dev_server = __esm({
41899
41899
  this.json(res, 404, { error: `Provider not found: ${type}` });
41900
41900
  return;
41901
41901
  }
41902
- const spawn3 = provider.spawn;
41903
- if (!spawn3) {
41902
+ const spawn4 = provider.spawn;
41903
+ if (!spawn4) {
41904
41904
  this.json(res, 400, { error: `Provider ${type} has no spawn config` });
41905
41905
  return;
41906
41906
  }
41907
41907
  const { spawn: spawnFn } = await import("child_process");
41908
41908
  const start = Date.now();
41909
41909
  try {
41910
- const args = [...spawn3.args || [], message];
41911
- const child = spawnFn(spawn3.command, args, {
41912
- shell: spawn3.shell ?? false,
41910
+ const args = [...spawn4.args || [], message];
41911
+ const child = spawnFn(spawn4.command, args, {
41912
+ shell: spawn4.shell ?? false,
41913
41913
  timeout,
41914
41914
  stdio: ["pipe", "pipe", "pipe"],
41915
- env: { ...process.env, ...spawn3.env || {} }
41915
+ env: { ...process.env, ...spawn4.env || {} }
41916
41916
  });
41917
41917
  let stdout = "";
41918
41918
  let stderr = "";
@@ -41922,14 +41922,14 @@ var init_dev_server = __esm({
41922
41922
  child.stderr?.on("data", (d) => {
41923
41923
  stderr += d.toString();
41924
41924
  });
41925
- await new Promise((resolve11) => {
41925
+ await new Promise((resolve12) => {
41926
41926
  const timer = setTimeout(() => {
41927
41927
  child.kill();
41928
- resolve11();
41928
+ resolve12();
41929
41929
  }, timeout);
41930
41930
  child.on("exit", () => {
41931
41931
  clearTimeout(timer);
41932
- resolve11();
41932
+ resolve12();
41933
41933
  });
41934
41934
  });
41935
41935
  const elapsed = Date.now() - start;
@@ -42585,14 +42585,14 @@ data: ${JSON.stringify(msg.data)}
42585
42585
  res.end(JSON.stringify(data, null, 2));
42586
42586
  }
42587
42587
  async readBody(req) {
42588
- return new Promise((resolve11) => {
42588
+ return new Promise((resolve12) => {
42589
42589
  let body = "";
42590
42590
  req.on("data", (chunk) => body += chunk);
42591
42591
  req.on("end", () => {
42592
42592
  try {
42593
- resolve11(JSON.parse(body));
42593
+ resolve12(JSON.parse(body));
42594
42594
  } catch {
42595
- resolve11({});
42595
+ resolve12({});
42596
42596
  }
42597
42597
  });
42598
42598
  });
@@ -42646,18 +42646,536 @@ data: ${JSON.stringify(msg.data)}
42646
42646
  });
42647
42647
 
42648
42648
  // ../../oss/packages/session-host-core/dist/index.mjs
42649
+ function getDefaultSessionHostEndpoint(appName = "adhdev") {
42650
+ if (process.platform === "win32") {
42651
+ return {
42652
+ kind: "pipe",
42653
+ path: `\\\\.\\pipe\\${appName}-session-host`
42654
+ };
42655
+ }
42656
+ return {
42657
+ kind: "unix",
42658
+ path: path22.join(os17.tmpdir(), `${appName}-session-host.sock`)
42659
+ };
42660
+ }
42661
+ function serializeEnvelope(envelope) {
42662
+ return `${JSON.stringify(envelope)}
42663
+ `;
42664
+ }
42665
+ function createLineParser(onEnvelope) {
42666
+ let buffer = "";
42667
+ return (chunk) => {
42668
+ buffer += chunk.toString();
42669
+ let newlineIndex = buffer.indexOf("\n");
42670
+ while (newlineIndex >= 0) {
42671
+ const rawLine = buffer.slice(0, newlineIndex).trim();
42672
+ buffer = buffer.slice(newlineIndex + 1);
42673
+ if (rawLine) {
42674
+ onEnvelope(JSON.parse(rawLine));
42675
+ }
42676
+ newlineIndex = buffer.indexOf("\n");
42677
+ }
42678
+ };
42679
+ }
42680
+ var os17, path22, net2, import_crypto3, SessionHostClient;
42649
42681
  var init_dist = __esm({
42650
42682
  "../../oss/packages/session-host-core/dist/index.mjs"() {
42651
42683
  "use strict";
42684
+ os17 = __toESM(require("os"), 1);
42685
+ path22 = __toESM(require("path"), 1);
42686
+ net2 = __toESM(require("net"), 1);
42687
+ import_crypto3 = require("crypto");
42688
+ SessionHostClient = class {
42689
+ endpoint;
42690
+ socket = null;
42691
+ requestWaiters = /* @__PURE__ */ new Map();
42692
+ eventListeners = /* @__PURE__ */ new Set();
42693
+ constructor(options = {}) {
42694
+ this.endpoint = options.endpoint || getDefaultSessionHostEndpoint(options.appName || "adhdev");
42695
+ }
42696
+ async connect() {
42697
+ if (this.socket && !this.socket.destroyed) return;
42698
+ const socket = net2.createConnection(this.endpoint.path);
42699
+ this.socket = socket;
42700
+ socket.on("data", createLineParser((envelope) => {
42701
+ if (envelope.kind === "response") {
42702
+ const waiter = this.requestWaiters.get(envelope.requestId);
42703
+ if (waiter) {
42704
+ this.requestWaiters.delete(envelope.requestId);
42705
+ waiter.resolve(envelope.response);
42706
+ }
42707
+ return;
42708
+ }
42709
+ if (envelope.kind === "event") {
42710
+ for (const listener of this.eventListeners) listener(envelope.event);
42711
+ }
42712
+ }));
42713
+ socket.on("error", (error48) => {
42714
+ for (const waiter of this.requestWaiters.values()) {
42715
+ waiter.reject(error48);
42716
+ }
42717
+ this.requestWaiters.clear();
42718
+ });
42719
+ await new Promise((resolve12, reject) => {
42720
+ socket.once("connect", () => resolve12());
42721
+ socket.once("error", reject);
42722
+ });
42723
+ }
42724
+ onEvent(listener) {
42725
+ this.eventListeners.add(listener);
42726
+ return () => {
42727
+ this.eventListeners.delete(listener);
42728
+ };
42729
+ }
42730
+ async request(request) {
42731
+ await this.connect();
42732
+ if (!this.socket) throw new Error("Session host socket unavailable");
42733
+ const requestId = (0, import_crypto3.randomUUID)();
42734
+ const envelope = {
42735
+ kind: "request",
42736
+ requestId,
42737
+ request
42738
+ };
42739
+ const response = await new Promise((resolve12, reject) => {
42740
+ this.requestWaiters.set(requestId, { resolve: resolve12, reject });
42741
+ this.socket?.write(serializeEnvelope(envelope));
42742
+ });
42743
+ return response;
42744
+ }
42745
+ async close() {
42746
+ if (!this.socket) return;
42747
+ const socket = this.socket;
42748
+ this.socket = null;
42749
+ for (const waiter of this.requestWaiters.values()) {
42750
+ waiter.reject(new Error("Session host client closed"));
42751
+ }
42752
+ this.requestWaiters.clear();
42753
+ await new Promise((resolve12) => {
42754
+ let settled = false;
42755
+ const done = () => {
42756
+ if (settled) return;
42757
+ settled = true;
42758
+ resolve12();
42759
+ };
42760
+ socket.once("close", done);
42761
+ socket.end();
42762
+ socket.destroy();
42763
+ setTimeout(done, 50);
42764
+ });
42765
+ }
42766
+ };
42652
42767
  }
42653
42768
  });
42654
42769
 
42655
42770
  // ../../oss/packages/daemon-core/src/cli-adapters/session-host-transport.ts
42771
+ var SessionHostRuntimeTransport, SessionHostPtyTransportFactory;
42656
42772
  var init_session_host_transport = __esm({
42657
42773
  "../../oss/packages/daemon-core/src/cli-adapters/session-host-transport.ts"() {
42658
42774
  "use strict";
42659
42775
  init_dist();
42660
42776
  init_logger();
42777
+ SessionHostRuntimeTransport = class {
42778
+ constructor(options) {
42779
+ this.options = options;
42780
+ this.client = new SessionHostClient({
42781
+ endpoint: options.endpoint,
42782
+ appName: options.appName
42783
+ });
42784
+ this.ready = this.boot();
42785
+ }
42786
+ ready;
42787
+ client;
42788
+ dataCallbacks = /* @__PURE__ */ new Set();
42789
+ exitCallbacks = /* @__PURE__ */ new Set();
42790
+ pendingOutput = [];
42791
+ operationChain = Promise.resolve();
42792
+ unsubscribe = null;
42793
+ currentPid = 0;
42794
+ closed = false;
42795
+ metadata = null;
42796
+ get pid() {
42797
+ return this.currentPid;
42798
+ }
42799
+ getMetadata() {
42800
+ return this.metadata ? {
42801
+ ...this.metadata,
42802
+ writeOwner: this.metadata.writeOwner ? { ...this.metadata.writeOwner } : null,
42803
+ attachedClients: this.metadata.attachedClients?.map((client) => ({ ...client })) || []
42804
+ } : null;
42805
+ }
42806
+ onData(callback) {
42807
+ this.dataCallbacks.add(callback);
42808
+ if (this.pendingOutput.length > 0) {
42809
+ for (const chunk of this.pendingOutput.splice(0)) {
42810
+ callback(chunk);
42811
+ }
42812
+ }
42813
+ }
42814
+ onExit(callback) {
42815
+ this.exitCallbacks.add(callback);
42816
+ }
42817
+ write(data) {
42818
+ this.enqueue(async () => {
42819
+ let response = await this.client.request({
42820
+ type: "send_input",
42821
+ payload: {
42822
+ sessionId: this.options.runtimeId,
42823
+ clientId: this.options.clientId,
42824
+ data
42825
+ }
42826
+ });
42827
+ if (!response.success && response.error?.startsWith("Write owned by ")) {
42828
+ const ownerResponse = await this.client.request({
42829
+ type: "acquire_write",
42830
+ payload: {
42831
+ sessionId: this.options.runtimeId,
42832
+ clientId: this.options.clientId,
42833
+ ownerType: "user",
42834
+ force: true
42835
+ }
42836
+ });
42837
+ if (ownerResponse.success && ownerResponse.result) {
42838
+ this.updateMetadata(ownerResponse.result);
42839
+ response = await this.client.request({
42840
+ type: "send_input",
42841
+ payload: {
42842
+ sessionId: this.options.runtimeId,
42843
+ clientId: this.options.clientId,
42844
+ data
42845
+ }
42846
+ });
42847
+ }
42848
+ }
42849
+ if (!response.success) {
42850
+ throw new Error(response.error || `Failed to write to runtime ${this.options.runtimeId}`);
42851
+ }
42852
+ });
42853
+ }
42854
+ resize(cols, rows) {
42855
+ this.enqueue(async () => {
42856
+ await this.client.request({
42857
+ type: "resize_session",
42858
+ payload: {
42859
+ sessionId: this.options.runtimeId,
42860
+ cols,
42861
+ rows
42862
+ }
42863
+ });
42864
+ });
42865
+ }
42866
+ kill() {
42867
+ this.enqueue(async () => {
42868
+ await this.client.request({
42869
+ type: "stop_session",
42870
+ payload: { sessionId: this.options.runtimeId }
42871
+ });
42872
+ await this.closeClient(false);
42873
+ });
42874
+ }
42875
+ clearBuffer() {
42876
+ this.enqueue(async () => {
42877
+ const response = await this.client.request({
42878
+ type: "clear_session_buffer",
42879
+ payload: {
42880
+ sessionId: this.options.runtimeId
42881
+ }
42882
+ });
42883
+ if (!response.success) {
42884
+ throw new Error(response.error || `Failed to clear runtime buffer ${this.options.runtimeId}`);
42885
+ }
42886
+ if (response.result) {
42887
+ this.updateMetadata(response.result);
42888
+ }
42889
+ });
42890
+ }
42891
+ detach() {
42892
+ this.enqueue(async () => {
42893
+ await this.client.request({
42894
+ type: "release_write",
42895
+ payload: {
42896
+ sessionId: this.options.runtimeId,
42897
+ clientId: this.options.clientId
42898
+ }
42899
+ }).catch(() => ({ success: false }));
42900
+ await this.client.request({
42901
+ type: "detach_session",
42902
+ payload: {
42903
+ sessionId: this.options.runtimeId,
42904
+ clientId: this.options.clientId
42905
+ }
42906
+ }).catch(() => ({ success: false }));
42907
+ await this.closeClient(false);
42908
+ });
42909
+ }
42910
+ async boot() {
42911
+ await this.client.connect();
42912
+ this.unsubscribe = this.client.onEvent((event) => this.handleEvent(event));
42913
+ let record2 = null;
42914
+ if (this.options.attachExisting) {
42915
+ const existingRecords = await this.client.request({
42916
+ type: "list_sessions",
42917
+ payload: {}
42918
+ });
42919
+ const existingRecord = existingRecords.success && existingRecords.result ? existingRecords.result.find((item) => item.sessionId === this.options.runtimeId) || null : null;
42920
+ if (existingRecord?.lifecycle === "interrupted") {
42921
+ const resumeResponse = await this.client.request({
42922
+ type: "resume_session",
42923
+ payload: {
42924
+ sessionId: this.options.runtimeId
42925
+ }
42926
+ });
42927
+ if (!resumeResponse.success) {
42928
+ LOG.warn("CLI", `[session-host:${this.options.runtimeId}] resume failed: ${resumeResponse.error || "unknown error"}`);
42929
+ }
42930
+ }
42931
+ const attachResponse = await this.client.request({
42932
+ type: "attach_session",
42933
+ payload: {
42934
+ sessionId: this.options.runtimeId,
42935
+ clientId: this.options.clientId,
42936
+ clientType: "daemon",
42937
+ readOnly: false
42938
+ }
42939
+ });
42940
+ if (!attachResponse.success || !attachResponse.result) {
42941
+ throw new Error(attachResponse.error || `Failed to attach runtime ${this.options.runtimeId}`);
42942
+ }
42943
+ record2 = attachResponse.result;
42944
+ } else {
42945
+ const createResponse = await this.client.request({
42946
+ type: "create_session",
42947
+ payload: {
42948
+ sessionId: this.options.runtimeId,
42949
+ providerType: this.options.providerType,
42950
+ category: this.options.category || "cli",
42951
+ workspace: this.options.workspace,
42952
+ launchCommand: {
42953
+ command: this.options.command,
42954
+ args: this.options.args,
42955
+ env: this.options.spawnOptions.env
42956
+ },
42957
+ cols: this.options.spawnOptions.cols,
42958
+ rows: this.options.spawnOptions.rows,
42959
+ clientId: this.options.clientId,
42960
+ clientType: "daemon",
42961
+ meta: this.options.meta
42962
+ }
42963
+ });
42964
+ if (!createResponse.success || !createResponse.result) {
42965
+ throw new Error(createResponse.error || `Failed to create runtime ${this.options.runtimeId}`);
42966
+ }
42967
+ record2 = createResponse.result;
42968
+ }
42969
+ this.currentPid = record2.osPid || 0;
42970
+ this.updateMetadata(record2);
42971
+ const ownerResponse = await this.client.request({
42972
+ type: "acquire_write",
42973
+ payload: {
42974
+ sessionId: this.options.runtimeId,
42975
+ clientId: this.options.clientId,
42976
+ ownerType: "agent",
42977
+ force: !this.options.attachExisting
42978
+ }
42979
+ });
42980
+ if (!ownerResponse.success) {
42981
+ if (this.options.attachExisting && ownerResponse.error?.startsWith("Write owned by ")) {
42982
+ LOG.info("CLI", `[session-host:${this.options.runtimeId}] attached without write ownership (${ownerResponse.error})`);
42983
+ } else {
42984
+ throw new Error(ownerResponse.error || `Failed to acquire write owner for ${this.options.runtimeId}`);
42985
+ }
42986
+ } else if (ownerResponse.result) {
42987
+ this.updateMetadata(ownerResponse.result);
42988
+ }
42989
+ if (this.options.attachExisting) {
42990
+ const snapshotResponse = await this.client.request({
42991
+ type: "get_snapshot",
42992
+ payload: {
42993
+ sessionId: this.options.runtimeId
42994
+ }
42995
+ });
42996
+ if (!snapshotResponse.success) {
42997
+ throw new Error(snapshotResponse.error || `Failed to load snapshot for ${this.options.runtimeId}`);
42998
+ }
42999
+ const text = snapshotResponse.result?.text || "";
43000
+ if (text) {
43001
+ this.emitData(text);
43002
+ }
43003
+ }
43004
+ }
43005
+ handleEvent(event) {
43006
+ if (event.sessionId !== this.options.runtimeId) return;
43007
+ if ((event.type === "session_started" || event.type === "session_resumed") && typeof event.pid === "number") {
43008
+ this.currentPid = event.pid;
43009
+ return;
43010
+ }
43011
+ if (event.type === "write_owner_changed") {
43012
+ this.metadata = {
43013
+ ...this.metadata || { runtimeId: this.options.runtimeId },
43014
+ writeOwner: event.owner ? {
43015
+ clientId: event.owner.clientId,
43016
+ ownerType: event.owner.ownerType
43017
+ } : null
43018
+ };
43019
+ return;
43020
+ }
43021
+ if (event.type === "client_attached") {
43022
+ const nextClients = new Map(
43023
+ (this.metadata?.attachedClients || []).map((client) => [client.clientId, client])
43024
+ );
43025
+ nextClients.set(event.client.clientId, {
43026
+ clientId: event.client.clientId,
43027
+ type: event.client.type,
43028
+ readOnly: event.client.readOnly
43029
+ });
43030
+ this.metadata = {
43031
+ ...this.metadata || { runtimeId: this.options.runtimeId },
43032
+ attachedClients: Array.from(nextClients.values())
43033
+ };
43034
+ return;
43035
+ }
43036
+ if (event.type === "client_detached") {
43037
+ this.metadata = {
43038
+ ...this.metadata || { runtimeId: this.options.runtimeId },
43039
+ attachedClients: (this.metadata?.attachedClients || []).filter((client) => client.clientId !== event.clientId)
43040
+ };
43041
+ return;
43042
+ }
43043
+ if (event.type === "session_output") {
43044
+ this.emitData(event.data);
43045
+ return;
43046
+ }
43047
+ if (event.type === "session_cleared") {
43048
+ this.pendingOutput.length = 0;
43049
+ return;
43050
+ }
43051
+ if (event.type === "session_exit") {
43052
+ for (const callback of this.exitCallbacks) {
43053
+ callback({ exitCode: event.exitCode ?? 0 });
43054
+ }
43055
+ void this.closeClient(false);
43056
+ }
43057
+ }
43058
+ emitData(data) {
43059
+ if (this.dataCallbacks.size === 0) {
43060
+ this.pendingOutput.push(data);
43061
+ return;
43062
+ }
43063
+ for (const callback of this.dataCallbacks) {
43064
+ callback(data);
43065
+ }
43066
+ }
43067
+ updateMetadata(record2) {
43068
+ this.metadata = {
43069
+ runtimeId: record2.sessionId,
43070
+ runtimeKey: record2.runtimeKey,
43071
+ displayName: record2.displayName,
43072
+ workspaceLabel: record2.workspaceLabel,
43073
+ writeOwner: record2.writeOwner ? {
43074
+ clientId: record2.writeOwner.clientId,
43075
+ ownerType: record2.writeOwner.ownerType
43076
+ } : null,
43077
+ attachedClients: record2.attachedClients.map((client) => ({
43078
+ clientId: client.clientId,
43079
+ type: client.type,
43080
+ readOnly: client.readOnly
43081
+ }))
43082
+ };
43083
+ }
43084
+ enqueue(action) {
43085
+ this.operationChain = this.operationChain.then(() => this.ready).then(action).catch((error48) => {
43086
+ LOG.warn("CLI", `[session-host:${this.options.runtimeId}] ${error48?.message || error48}`);
43087
+ });
43088
+ }
43089
+ async closeClient(destroy = false) {
43090
+ if (this.closed) return;
43091
+ this.closed = true;
43092
+ try {
43093
+ this.unsubscribe?.();
43094
+ this.unsubscribe = null;
43095
+ } catch {
43096
+ }
43097
+ try {
43098
+ await this.client.close();
43099
+ } catch {
43100
+ if (destroy) throw new Error(`Failed to close session host client: ${this.options.runtimeId}`);
43101
+ }
43102
+ }
43103
+ };
43104
+ SessionHostPtyTransportFactory = class {
43105
+ constructor(options) {
43106
+ this.options = options;
43107
+ }
43108
+ spawn(command, args, spawnOptions) {
43109
+ return new SessionHostRuntimeTransport({
43110
+ ...this.options,
43111
+ command,
43112
+ args,
43113
+ spawnOptions
43114
+ });
43115
+ }
43116
+ };
43117
+ }
43118
+ });
43119
+
43120
+ // ../../oss/packages/daemon-core/src/session-host/runtime-support.ts
43121
+ async function canConnect(endpoint) {
43122
+ const client = new SessionHostClient({ endpoint });
43123
+ try {
43124
+ await client.connect();
43125
+ await client.close();
43126
+ return true;
43127
+ } catch {
43128
+ return false;
43129
+ }
43130
+ }
43131
+ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
43132
+ const deadline = Date.now() + timeoutMs;
43133
+ while (Date.now() < deadline) {
43134
+ if (await canConnect(endpoint)) return;
43135
+ await new Promise((resolve12) => setTimeout(resolve12, STARTUP_POLL_MS));
43136
+ }
43137
+ throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
43138
+ }
43139
+ async function ensureSessionHostReady(options) {
43140
+ const endpoint = getDefaultSessionHostEndpoint(options.appName || "adhdev");
43141
+ if (await canConnect(endpoint)) return endpoint;
43142
+ options.spawnHost();
43143
+ await waitForReady(endpoint, options.timeoutMs);
43144
+ return endpoint;
43145
+ }
43146
+ async function listHostedCliRuntimes(endpoint) {
43147
+ const client = new SessionHostClient({ endpoint });
43148
+ try {
43149
+ const response = await client.request({
43150
+ type: "list_sessions",
43151
+ payload: {}
43152
+ });
43153
+ if (!response.success || !response.result) {
43154
+ return [];
43155
+ }
43156
+ return response.result.filter((record2) => record2.category === "cli" && ["running", "interrupted"].includes(record2.lifecycle)).sort((a, b2) => b2.lastActivityAt - a.lastActivityAt).map((record2) => ({
43157
+ runtimeId: record2.sessionId,
43158
+ runtimeKey: record2.runtimeKey,
43159
+ displayName: record2.displayName,
43160
+ workspaceLabel: record2.workspaceLabel,
43161
+ lifecycle: record2.lifecycle,
43162
+ recoveryState: typeof record2.meta?.runtimeRecoveryState === "string" ? String(record2.meta.runtimeRecoveryState) : null,
43163
+ cliType: record2.providerType,
43164
+ workspace: record2.workspace,
43165
+ cliArgs: Array.isArray(record2.meta?.cliArgs) ? record2.meta.cliArgs : []
43166
+ }));
43167
+ } finally {
43168
+ await client.close().catch(() => {
43169
+ });
43170
+ }
43171
+ }
43172
+ var STARTUP_TIMEOUT_MS, STARTUP_POLL_MS;
43173
+ var init_runtime_support = __esm({
43174
+ "../../oss/packages/daemon-core/src/session-host/runtime-support.ts"() {
43175
+ "use strict";
43176
+ init_dist();
43177
+ STARTUP_TIMEOUT_MS = 8e3;
43178
+ STARTUP_POLL_MS = 200;
42661
43179
  }
42662
43180
  });
42663
43181
 
@@ -42966,6 +43484,7 @@ var init_src = __esm({
42966
43484
  init_provider_cli_adapter();
42967
43485
  init_pty_transport();
42968
43486
  init_session_host_transport();
43487
+ init_runtime_support();
42969
43488
  init_installer();
42970
43489
  init_daemon_lifecycle();
42971
43490
  }
@@ -43163,9 +43682,9 @@ var init_server_connection = __esm({
43163
43682
  LOG.info("Server", `[ServerConn] Run 'adhdev setup' to re-authenticate.`);
43164
43683
  this.setState("disconnected");
43165
43684
  try {
43166
- const path17 = require("path");
43685
+ const path18 = require("path");
43167
43686
  const fs15 = require("fs");
43168
- const configPath = path17.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
43687
+ const configPath = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
43169
43688
  if (fs15.existsSync(configPath)) {
43170
43689
  fs15.unlinkSync(configPath);
43171
43690
  LOG.info("Server", `[ServerConn] Config file removed. Re-run 'adhdev setup'.`);
@@ -43276,17 +43795,17 @@ function canPeerUsePrivilegedShareCommand(commandType, permission) {
43276
43795
  return false;
43277
43796
  }
43278
43797
  }
43279
- var fs13, path15, os17, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
43798
+ var fs13, path15, os18, import_node_module, esmRequire, logFile, log, logDebug, DaemonP2PSender;
43280
43799
  var init_daemon_p2p = __esm({
43281
43800
  "src/daemon-p2p.ts"() {
43282
43801
  "use strict";
43283
43802
  fs13 = __toESM(require("fs"));
43284
43803
  init_src();
43285
43804
  path15 = __toESM(require("path"));
43286
- os17 = __toESM(require("os"));
43805
+ os18 = __toESM(require("os"));
43287
43806
  import_node_module = require("module");
43288
43807
  esmRequire = (0, import_node_module.createRequire)(__filename);
43289
- logFile = path15.join(os17.tmpdir(), "adhdev_daemon_p2p.log");
43808
+ logFile = path15.join(os18.tmpdir(), "adhdev_daemon_p2p.log");
43290
43809
  log = (msg) => {
43291
43810
  LOG.info("P2P", `[${(/* @__PURE__ */ new Date()).toISOString()}] [P2P] ${msg}`);
43292
43811
  };
@@ -43442,7 +43961,7 @@ ${e?.stack || ""}`);
43442
43961
  async fetchTurnCredentials() {
43443
43962
  try {
43444
43963
  const serverUrl = process.env.ADHDEV_SERVER_URL || "https://api.adhf.dev";
43445
- const configPath = path15.join(os17.homedir(), ".adhdev", "config.json");
43964
+ const configPath = path15.join(os18.homedir(), ".adhdev", "config.json");
43446
43965
  let token = "";
43447
43966
  try {
43448
43967
  const config2 = JSON.parse(fs13.readFileSync(configPath, "utf-8"));
@@ -43450,13 +43969,13 @@ ${e?.stack || ""}`);
43450
43969
  } catch {
43451
43970
  }
43452
43971
  const http3 = esmRequire("https");
43453
- const data = await new Promise((resolve11, reject) => {
43972
+ const data = await new Promise((resolve12, reject) => {
43454
43973
  const req = http3.get(`${serverUrl}/api/v1/turn/credentials`, {
43455
43974
  headers: { "Authorization": `Bearer ${token}` }
43456
43975
  }, (res) => {
43457
43976
  let d = "";
43458
43977
  res.on("data", (c) => d += c);
43459
- res.on("end", () => resolve11(d));
43978
+ res.on("end", () => resolve12(d));
43460
43979
  });
43461
43980
  req.on("error", reject);
43462
43981
  req.setTimeout(5e3, () => {
@@ -44285,6 +44804,52 @@ var init_screenshot_controller = __esm({
44285
44804
  }
44286
44805
  });
44287
44806
 
44807
+ // src/session-host.ts
44808
+ function resolveSessionHostEntry() {
44809
+ const localCandidates = [
44810
+ path16.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
44811
+ path16.resolve(__dirname, "../../vendor/session-host-daemon/index.js"),
44812
+ path16.resolve(__dirname, "../../../oss/packages/session-host-daemon/dist/index.js")
44813
+ ];
44814
+ for (const candidate of localCandidates) {
44815
+ if (require("fs").existsSync(candidate)) {
44816
+ return candidate;
44817
+ }
44818
+ }
44819
+ return require.resolve("@adhdev/session-host-daemon");
44820
+ }
44821
+ async function ensureSessionHostReady2() {
44822
+ return ensureSessionHostReady({
44823
+ appName: SESSION_HOST_APP_NAME,
44824
+ spawnHost: () => {
44825
+ const entry = resolveSessionHostEntry();
44826
+ const child = (0, import_child_process8.spawn)(process.execPath, [entry], {
44827
+ detached: true,
44828
+ stdio: "ignore",
44829
+ windowsHide: true,
44830
+ env: {
44831
+ ...process.env,
44832
+ ADHDEV_SESSION_HOST_NAME: SESSION_HOST_APP_NAME
44833
+ }
44834
+ });
44835
+ child.unref();
44836
+ }
44837
+ });
44838
+ }
44839
+ async function listHostedCliRuntimes2(endpoint) {
44840
+ return listHostedCliRuntimes(endpoint);
44841
+ }
44842
+ var import_child_process8, path16, SESSION_HOST_APP_NAME;
44843
+ var init_session_host = __esm({
44844
+ "src/session-host.ts"() {
44845
+ "use strict";
44846
+ import_child_process8 = require("child_process");
44847
+ path16 = __toESM(require("path"));
44848
+ init_src();
44849
+ SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
44850
+ }
44851
+ });
44852
+
44288
44853
  // src/adhdev-daemon.ts
44289
44854
  var adhdev_daemon_exports = {};
44290
44855
  __export(adhdev_daemon_exports, {
@@ -44293,9 +44858,9 @@ __export(adhdev_daemon_exports, {
44293
44858
  stopDaemon: () => stopDaemon
44294
44859
  });
44295
44860
  function getDaemonPidFile() {
44296
- const dir = path16.join(os18.homedir(), ".adhdev");
44861
+ const dir = path17.join(os19.homedir(), ".adhdev");
44297
44862
  if (!fs14.existsSync(dir)) fs14.mkdirSync(dir, { recursive: true });
44298
- return path16.join(dir, "daemon.pid");
44863
+ return path17.join(dir, "daemon.pid");
44299
44864
  }
44300
44865
  function writeDaemonPid(pid) {
44301
44866
  fs14.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
@@ -44331,7 +44896,7 @@ function stopDaemon() {
44331
44896
  return false;
44332
44897
  }
44333
44898
  }
44334
- var os18, fs14, path16, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
44899
+ var os19, fs14, path17, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
44335
44900
  var init_adhdev_daemon = __esm({
44336
44901
  "src/adhdev-daemon.ts"() {
44337
44902
  "use strict";
@@ -44339,16 +44904,17 @@ var init_adhdev_daemon = __esm({
44339
44904
  init_src();
44340
44905
  init_daemon_p2p();
44341
44906
  init_screenshot_controller();
44342
- os18 = __toESM(require("os"));
44907
+ init_session_host();
44908
+ os19 = __toESM(require("os"));
44343
44909
  fs14 = __toESM(require("fs"));
44344
- path16 = __toESM(require("path"));
44910
+ path17 = __toESM(require("path"));
44345
44911
  import_chalk2 = __toESM(require("chalk"));
44346
- pkgVersion = "0.7.17";
44912
+ pkgVersion = "0.7.19";
44347
44913
  if (pkgVersion === "unknown") {
44348
44914
  try {
44349
44915
  const possiblePaths = [
44350
- path16.join(__dirname, "..", "package.json"),
44351
- path16.join(__dirname, "package.json")
44916
+ path17.join(__dirname, "..", "package.json"),
44917
+ path17.join(__dirname, "package.json")
44352
44918
  ];
44353
44919
  for (const p of possiblePaths) {
44354
44920
  try {
@@ -44419,13 +44985,27 @@ ${err?.stack || ""}`);
44419
44985
  console.log(import_chalk2.default.gray(" Run `adhdev setup` first.\n"));
44420
44986
  process.exit(1);
44421
44987
  }
44988
+ const sessionHostEndpoint = await ensureSessionHostReady2();
44422
44989
  this.components = await initDaemonComponents({
44423
44990
  providerLogFn: LOG.forComponent("Provider").asLogFn(),
44424
44991
  cliManagerDeps: {
44425
44992
  getServerConn: () => this.serverConn,
44426
44993
  getP2p: () => this.p2p,
44427
44994
  onStatusChange: () => this.statusReporter?.onStatusChange(),
44428
- removeAgentTracking: (key) => this.statusReporter?.removeAgentTracking(key)
44995
+ removeAgentTracking: (key) => this.statusReporter?.removeAgentTracking(key),
44996
+ createPtyTransportFactory: ({ runtimeId, providerType, workspace, cliArgs, attachExisting }) => new SessionHostPtyTransportFactory({
44997
+ endpoint: sessionHostEndpoint,
44998
+ clientId: `daemon_${config2.machineId}`,
44999
+ runtimeId,
45000
+ providerType,
45001
+ workspace,
45002
+ appName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev",
45003
+ meta: {
45004
+ cliArgs
45005
+ },
45006
+ attachExisting
45007
+ }),
45008
+ listHostedCliRuntimes: async () => listHostedCliRuntimes2(sessionHostEndpoint)
44429
45009
  },
44430
45010
  enabledIdes: config2.enabledIdes,
44431
45011
  onStatusChange: () => this.statusReporter?.onStatusChange(),
@@ -44442,6 +45022,7 @@ ${err?.stack || ""}`);
44442
45022
  forwardAgentStreamsToIdeInstance(this.components.instanceManager, ideType, streams);
44443
45023
  }
44444
45024
  });
45025
+ await this.components.cliManager.restoreHostedSessions();
44445
45026
  this.components.providerLoader.fetchLatest().then(({ updated }) => {
44446
45027
  if (updated) {
44447
45028
  this.components.providerLoader.reload();
@@ -44458,8 +45039,8 @@ ${err?.stack || ""}`);
44458
45039
  cliInfo: {
44459
45040
  type: "adhdev-daemon",
44460
45041
  version: pkgVersion,
44461
- platform: os18.platform(),
44462
- hostname: os18.hostname(),
45042
+ platform: os19.platform(),
45043
+ hostname: os19.hostname(),
44463
45044
  machineId: config2.machineId,
44464
45045
  instanceId
44465
45046
  }
@@ -44898,16 +45479,16 @@ async function loginFlow() {
44898
45479
  let verificationUrl;
44899
45480
  try {
44900
45481
  const config2 = loadConfig();
44901
- const os19 = await import("os");
45482
+ const os20 = await import("os");
44902
45483
  const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
44903
45484
  method: "POST",
44904
45485
  headers: { "Content-Type": "application/json" },
44905
45486
  body: JSON.stringify({
44906
45487
  clientMachineId: config2.machineId,
44907
45488
  registeredMachineId: config2.registeredMachineId,
44908
- hostname: os19.hostname(),
44909
- platform: os19.platform(),
44910
- arch: os19.arch()
45489
+ hostname: os20.hostname(),
45490
+ platform: os20.platform(),
45491
+ arch: os20.arch()
44911
45492
  })
44912
45493
  });
44913
45494
  if (!res.ok) {
@@ -45006,10 +45587,10 @@ async function startDaemonFlow() {
45006
45587
  const { AdhdevDaemon: AdhdevDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
45007
45588
  const daemon = new AdhdevDaemon2();
45008
45589
  const { execSync: execSync6 } = await import("child_process");
45009
- const os19 = await import("os");
45010
- const path17 = await import("path");
45011
- const logPath = path17.join(os19.homedir(), ".adhdev", "daemon.log");
45012
- const platform11 = os19.platform();
45590
+ const os20 = await import("os");
45591
+ const path18 = await import("path");
45592
+ const logPath = path18.join(os20.homedir(), ".adhdev", "daemon.log");
45593
+ const platform11 = os20.platform();
45013
45594
  try {
45014
45595
  if (platform11 === "win32") {
45015
45596
  execSync6(`start /B adhdev daemon > "${logPath}" 2>&1`, {