adhdev 0.9.71 → 0.9.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -3176,8 +3176,8 @@ async function detectIDEs(providerLoader) {
3176
3176
  if ((0, import_fs4.existsSync)(bundledCli)) resolvedCli = bundledCli;
3177
3177
  }
3178
3178
  if (!resolvedCli && appPath && os31 === "win32") {
3179
- const { dirname: dirname11 } = await import("path");
3180
- const appDir = dirname11(appPath);
3179
+ const { dirname: dirname12 } = await import("path");
3180
+ const appDir = dirname12(appPath);
3181
3181
  const candidates = [
3182
3182
  `${appDir}\\\\bin\\\\${def.cli}.cmd`,
3183
3183
  `${appDir}\\\\bin\\\\${def.cli}`,
@@ -3249,19 +3249,19 @@ function resolveCommandPath(command) {
3249
3249
  return null;
3250
3250
  }
3251
3251
  function execAsync(cmd, timeoutMs = 5e3) {
3252
- return new Promise((resolve22) => {
3252
+ return new Promise((resolve23) => {
3253
3253
  const child = (0, import_child_process2.exec)(cmd, {
3254
3254
  encoding: "utf-8",
3255
3255
  timeout: timeoutMs,
3256
3256
  ...process.platform === "win32" ? { windowsHide: true } : {}
3257
3257
  }, (err, stdout) => {
3258
3258
  if (err || !stdout?.trim()) {
3259
- resolve22(null);
3259
+ resolve23(null);
3260
3260
  } else {
3261
- resolve22(stdout.trim());
3261
+ resolve23(stdout.trim());
3262
3262
  }
3263
3263
  });
3264
- child.on("error", () => resolve22(null));
3264
+ child.on("error", () => resolve23(null));
3265
3265
  });
3266
3266
  }
3267
3267
  async function detectCLIs(providerLoader, options) {
@@ -3873,7 +3873,7 @@ var init_manager = __esm({
3873
3873
  * Returns multiple entries if multiple IDE windows are open on same port
3874
3874
  */
3875
3875
  static listAllTargets(port) {
3876
- return new Promise((resolve22) => {
3876
+ return new Promise((resolve23) => {
3877
3877
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
3878
3878
  let data = "";
3879
3879
  res.on("data", (chunk) => data += chunk.toString());
@@ -3889,16 +3889,16 @@ var init_manager = __esm({
3889
3889
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
3890
3890
  );
3891
3891
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
3892
- resolve22(mainPages.length > 0 ? mainPages : fallbackPages);
3892
+ resolve23(mainPages.length > 0 ? mainPages : fallbackPages);
3893
3893
  } catch {
3894
- resolve22([]);
3894
+ resolve23([]);
3895
3895
  }
3896
3896
  });
3897
3897
  });
3898
- req.on("error", () => resolve22([]));
3898
+ req.on("error", () => resolve23([]));
3899
3899
  req.setTimeout(2e3, () => {
3900
3900
  req.destroy();
3901
- resolve22([]);
3901
+ resolve23([]);
3902
3902
  });
3903
3903
  });
3904
3904
  }
@@ -3938,7 +3938,7 @@ var init_manager = __esm({
3938
3938
  }
3939
3939
  }
3940
3940
  findTargetOnPort(port) {
3941
- return new Promise((resolve22) => {
3941
+ return new Promise((resolve23) => {
3942
3942
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
3943
3943
  let data = "";
3944
3944
  res.on("data", (chunk) => data += chunk.toString());
@@ -3949,7 +3949,7 @@ var init_manager = __esm({
3949
3949
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
3950
3950
  );
3951
3951
  if (pages.length === 0) {
3952
- resolve22(targets.find((t) => t.webSocketDebuggerUrl) || null);
3952
+ resolve23(targets.find((t) => t.webSocketDebuggerUrl) || null);
3953
3953
  return;
3954
3954
  }
3955
3955
  const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -3968,25 +3968,25 @@ var init_manager = __esm({
3968
3968
  this._targetId = selected.target.id;
3969
3969
  }
3970
3970
  this._pageTitle = selected.target.title || "";
3971
- resolve22(selected.target);
3971
+ resolve23(selected.target);
3972
3972
  return;
3973
3973
  }
3974
3974
  if (previousTargetId) {
3975
3975
  this.log(`[CDP] Target ${previousTargetId} not found in page list`);
3976
- resolve22(null);
3976
+ resolve23(null);
3977
3977
  return;
3978
3978
  }
3979
3979
  this._pageTitle = list[0]?.title || "";
3980
- resolve22(list[0]);
3980
+ resolve23(list[0]);
3981
3981
  } catch {
3982
- resolve22(null);
3982
+ resolve23(null);
3983
3983
  }
3984
3984
  });
3985
3985
  });
3986
- req.on("error", () => resolve22(null));
3986
+ req.on("error", () => resolve23(null));
3987
3987
  req.setTimeout(2e3, () => {
3988
3988
  req.destroy();
3989
- resolve22(null);
3989
+ resolve23(null);
3990
3990
  });
3991
3991
  });
3992
3992
  }
@@ -3997,7 +3997,7 @@ var init_manager = __esm({
3997
3997
  this.extensionProviders = providers;
3998
3998
  }
3999
3999
  connectToTarget(wsUrl) {
4000
- return new Promise((resolve22) => {
4000
+ return new Promise((resolve23) => {
4001
4001
  this.ws = new import_ws.default(wsUrl);
4002
4002
  this.ws.on("open", async () => {
4003
4003
  this._connected = true;
@@ -4007,17 +4007,17 @@ var init_manager = __esm({
4007
4007
  }
4008
4008
  this.connectBrowserWs().catch(() => {
4009
4009
  });
4010
- resolve22(true);
4010
+ resolve23(true);
4011
4011
  });
4012
4012
  this.ws.on("message", (data) => {
4013
4013
  try {
4014
4014
  const msg = JSON.parse(data.toString());
4015
4015
  if (msg.id && this.pending.has(msg.id)) {
4016
- const { resolve: resolve23, reject } = this.pending.get(msg.id);
4016
+ const { resolve: resolve24, reject } = this.pending.get(msg.id);
4017
4017
  this.pending.delete(msg.id);
4018
4018
  this.failureCount = 0;
4019
4019
  if (msg.error) reject(new Error(msg.error.message));
4020
- else resolve23(msg.result);
4020
+ else resolve24(msg.result);
4021
4021
  } else if (msg.method === "Runtime.executionContextCreated") {
4022
4022
  this.contexts.add(msg.params.context.id);
4023
4023
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -4040,7 +4040,7 @@ var init_manager = __esm({
4040
4040
  this.ws.on("error", (err) => {
4041
4041
  this.log(`[CDP] WebSocket error: ${err.message}`);
4042
4042
  this._connected = false;
4043
- resolve22(false);
4043
+ resolve23(false);
4044
4044
  });
4045
4045
  });
4046
4046
  }
@@ -4054,7 +4054,7 @@ var init_manager = __esm({
4054
4054
  return;
4055
4055
  }
4056
4056
  this.log(`[CDP] Connecting browser WS for target discovery...`);
4057
- await new Promise((resolve22, reject) => {
4057
+ await new Promise((resolve23, reject) => {
4058
4058
  this.browserWs = new import_ws.default(browserWsUrl);
4059
4059
  this.browserWs.on("open", async () => {
4060
4060
  this._browserConnected = true;
@@ -4064,16 +4064,16 @@ var init_manager = __esm({
4064
4064
  } catch (e) {
4065
4065
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
4066
4066
  }
4067
- resolve22();
4067
+ resolve23();
4068
4068
  });
4069
4069
  this.browserWs.on("message", (data) => {
4070
4070
  try {
4071
4071
  const msg = JSON.parse(data.toString());
4072
4072
  if (msg.id && this.browserPending.has(msg.id)) {
4073
- const { resolve: resolve23, reject: reject2 } = this.browserPending.get(msg.id);
4073
+ const { resolve: resolve24, reject: reject2 } = this.browserPending.get(msg.id);
4074
4074
  this.browserPending.delete(msg.id);
4075
4075
  if (msg.error) reject2(new Error(msg.error.message));
4076
- else resolve23(msg.result);
4076
+ else resolve24(msg.result);
4077
4077
  }
4078
4078
  } catch {
4079
4079
  }
@@ -4093,31 +4093,31 @@ var init_manager = __esm({
4093
4093
  }
4094
4094
  }
4095
4095
  getBrowserWsUrl() {
4096
- return new Promise((resolve22) => {
4096
+ return new Promise((resolve23) => {
4097
4097
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
4098
4098
  let data = "";
4099
4099
  res.on("data", (chunk) => data += chunk.toString());
4100
4100
  res.on("end", () => {
4101
4101
  try {
4102
4102
  const info = JSON.parse(data);
4103
- resolve22(info.webSocketDebuggerUrl || null);
4103
+ resolve23(info.webSocketDebuggerUrl || null);
4104
4104
  } catch {
4105
- resolve22(null);
4105
+ resolve23(null);
4106
4106
  }
4107
4107
  });
4108
4108
  });
4109
- req.on("error", () => resolve22(null));
4109
+ req.on("error", () => resolve23(null));
4110
4110
  req.setTimeout(3e3, () => {
4111
4111
  req.destroy();
4112
- resolve22(null);
4112
+ resolve23(null);
4113
4113
  });
4114
4114
  });
4115
4115
  }
4116
4116
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
4117
- return new Promise((resolve22, reject) => {
4117
+ return new Promise((resolve23, reject) => {
4118
4118
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
4119
4119
  const id = this.browserMsgId++;
4120
- this.browserPending.set(id, { resolve: resolve22, reject });
4120
+ this.browserPending.set(id, { resolve: resolve23, reject });
4121
4121
  this.browserWs.send(JSON.stringify({ id, method, params }));
4122
4122
  setTimeout(() => {
4123
4123
  if (this.browserPending.has(id)) {
@@ -4157,11 +4157,11 @@ var init_manager = __esm({
4157
4157
  }
4158
4158
  // ─── CDP Protocol ────────────────────────────────────────
4159
4159
  sendInternal(method, params = {}, timeoutMs = 15e3) {
4160
- return new Promise((resolve22, reject) => {
4160
+ return new Promise((resolve23, reject) => {
4161
4161
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
4162
4162
  if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
4163
4163
  const id = this.msgId++;
4164
- this.pending.set(id, { resolve: resolve22, reject });
4164
+ this.pending.set(id, { resolve: resolve23, reject });
4165
4165
  this.ws.send(JSON.stringify({ id, method, params }));
4166
4166
  setTimeout(() => {
4167
4167
  if (this.pending.has(id)) {
@@ -4410,7 +4410,7 @@ var init_manager = __esm({
4410
4410
  const browserWs = this.browserWs;
4411
4411
  let msgId = this.browserMsgId;
4412
4412
  const sendWs = (method, params = {}, sessionId) => {
4413
- return new Promise((resolve22, reject) => {
4413
+ return new Promise((resolve23, reject) => {
4414
4414
  const mid = msgId++;
4415
4415
  this.browserMsgId = msgId;
4416
4416
  const handler = (raw) => {
@@ -4419,7 +4419,7 @@ var init_manager = __esm({
4419
4419
  if (msg.id === mid) {
4420
4420
  browserWs.removeListener("message", handler);
4421
4421
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
4422
- else resolve22(msg.result);
4422
+ else resolve23(msg.result);
4423
4423
  }
4424
4424
  } catch {
4425
4425
  }
@@ -4620,14 +4620,14 @@ var init_manager = __esm({
4620
4620
  if (!ws || ws.readyState !== import_ws.default.OPEN) {
4621
4621
  throw new Error("CDP not connected");
4622
4622
  }
4623
- return new Promise((resolve22, reject) => {
4623
+ return new Promise((resolve23, reject) => {
4624
4624
  const id = getNextId();
4625
4625
  pendingMap.set(id, {
4626
4626
  resolve: (result) => {
4627
4627
  if (result?.result?.subtype === "error") {
4628
4628
  reject(new Error(result.result.description));
4629
4629
  } else {
4630
- resolve22(result?.result?.value);
4630
+ resolve23(result?.result?.value);
4631
4631
  }
4632
4632
  },
4633
4633
  reject
@@ -4659,10 +4659,10 @@ var init_manager = __esm({
4659
4659
  throw new Error("CDP not connected");
4660
4660
  }
4661
4661
  const sendViaSession = (method, params = {}) => {
4662
- return new Promise((resolve22, reject) => {
4662
+ return new Promise((resolve23, reject) => {
4663
4663
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
4664
4664
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
4665
- pendingMap.set(id, { resolve: resolve22, reject });
4665
+ pendingMap.set(id, { resolve: resolve23, reject });
4666
4666
  ws.send(JSON.stringify({ id, sessionId, method, params }));
4667
4667
  setTimeout(() => {
4668
4668
  if (pendingMap.has(id)) {
@@ -10047,7 +10047,7 @@ function getCliVisibleTranscriptCount(adapter) {
10047
10047
  async function getStableExtensionBaseline(h) {
10048
10048
  const first = await readExtensionChatState(h);
10049
10049
  if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
10050
- await new Promise((resolve22) => setTimeout(resolve22, 150));
10050
+ await new Promise((resolve23) => setTimeout(resolve23, 150));
10051
10051
  const second = await readExtensionChatState(h);
10052
10052
  return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
10053
10053
  }
@@ -10055,7 +10055,7 @@ async function verifyExtensionSendObserved(h, before) {
10055
10055
  const beforeCount = getStateMessageCount(before);
10056
10056
  const beforeSignature = getStateLastSignature(before);
10057
10057
  for (let attempt = 0; attempt < 12; attempt += 1) {
10058
- await new Promise((resolve22) => setTimeout(resolve22, 250));
10058
+ await new Promise((resolve23) => setTimeout(resolve23, 250));
10059
10059
  const state = await readExtensionChatState(h);
10060
10060
  if (state?.status === "waiting_approval") return true;
10061
10061
  const afterCount = getStateMessageCount(state);
@@ -11727,7 +11727,7 @@ async function executeProviderScript(h, args, scriptName) {
11727
11727
  const enterCount = cliCommand.enterCount || 1;
11728
11728
  await adapter.writeRaw(cliCommand.text + "\r");
11729
11729
  for (let i = 1; i < enterCount; i += 1) {
11730
- await new Promise((resolve22) => setTimeout(resolve22, 50));
11730
+ await new Promise((resolve23) => setTimeout(resolve23, 50));
11731
11731
  await adapter.writeRaw("\r");
11732
11732
  }
11733
11733
  }
@@ -12443,7 +12443,7 @@ var init_handler = __esm({
12443
12443
  try {
12444
12444
  const http3 = await import("http");
12445
12445
  const postData = JSON.stringify(body);
12446
- const result = await new Promise((resolve22, reject) => {
12446
+ const result = await new Promise((resolve23, reject) => {
12447
12447
  const req = http3.request({
12448
12448
  hostname: "127.0.0.1",
12449
12449
  port: 19280,
@@ -12455,9 +12455,9 @@ var init_handler = __esm({
12455
12455
  res.on("data", (chunk) => data += chunk);
12456
12456
  res.on("end", () => {
12457
12457
  try {
12458
- resolve22(JSON.parse(data));
12458
+ resolve23(JSON.parse(data));
12459
12459
  } catch {
12460
- resolve22({ raw: data });
12460
+ resolve23({ raw: data });
12461
12461
  }
12462
12462
  });
12463
12463
  });
@@ -12475,15 +12475,15 @@ var init_handler = __esm({
12475
12475
  if (!providerType) return { success: false, error: "providerType required" };
12476
12476
  try {
12477
12477
  const http3 = await import("http");
12478
- const result = await new Promise((resolve22, reject) => {
12478
+ const result = await new Promise((resolve23, reject) => {
12479
12479
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
12480
12480
  let data = "";
12481
12481
  res.on("data", (chunk) => data += chunk);
12482
12482
  res.on("end", () => {
12483
12483
  try {
12484
- resolve22(JSON.parse(data));
12484
+ resolve23(JSON.parse(data));
12485
12485
  } catch {
12486
- resolve22({ raw: data });
12486
+ resolve23({ raw: data });
12487
12487
  }
12488
12488
  });
12489
12489
  }).on("error", reject);
@@ -12497,7 +12497,7 @@ var init_handler = __esm({
12497
12497
  try {
12498
12498
  const http3 = await import("http");
12499
12499
  const postData = JSON.stringify(args || {});
12500
- const result = await new Promise((resolve22, reject) => {
12500
+ const result = await new Promise((resolve23, reject) => {
12501
12501
  const req = http3.request({
12502
12502
  hostname: "127.0.0.1",
12503
12503
  port: 19280,
@@ -12509,9 +12509,9 @@ var init_handler = __esm({
12509
12509
  res.on("data", (chunk) => data += chunk);
12510
12510
  res.on("end", () => {
12511
12511
  try {
12512
- resolve22(JSON.parse(data));
12512
+ resolve23(JSON.parse(data));
12513
12513
  } catch {
12514
- resolve22({ raw: data });
12514
+ resolve23({ raw: data });
12515
12515
  }
12516
12516
  });
12517
12517
  });
@@ -13893,8 +13893,8 @@ var init_dist = __esm({
13893
13893
  } catch {
13894
13894
  }
13895
13895
  });
13896
- await new Promise((resolve22, reject) => {
13897
- socket.once("connect", () => resolve22());
13896
+ await new Promise((resolve23, reject) => {
13897
+ socket.once("connect", () => resolve23());
13898
13898
  socket.once("error", reject);
13899
13899
  });
13900
13900
  }
@@ -13913,7 +13913,7 @@ var init_dist = __esm({
13913
13913
  requestId,
13914
13914
  request
13915
13915
  };
13916
- const response = await new Promise((resolve22, reject) => {
13916
+ const response = await new Promise((resolve23, reject) => {
13917
13917
  const timeout = setTimeout(() => {
13918
13918
  this.requestWaiters.delete(requestId);
13919
13919
  reject(new Error(`Session host request timed out after 30s (${request.type})`));
@@ -13921,7 +13921,7 @@ var init_dist = __esm({
13921
13921
  this.requestWaiters.set(requestId, {
13922
13922
  resolve: (value) => {
13923
13923
  clearTimeout(timeout);
13924
- resolve22(value);
13924
+ resolve23(value);
13925
13925
  },
13926
13926
  reject: (error48) => {
13927
13927
  clearTimeout(timeout);
@@ -13940,12 +13940,12 @@ var init_dist = __esm({
13940
13940
  waiter.reject(new Error("Session host client closed"));
13941
13941
  }
13942
13942
  this.requestWaiters.clear();
13943
- await new Promise((resolve22) => {
13943
+ await new Promise((resolve23) => {
13944
13944
  let settled = false;
13945
13945
  const done = () => {
13946
13946
  if (settled) return;
13947
13947
  settled = true;
13948
- resolve22();
13948
+ resolve23();
13949
13949
  };
13950
13950
  socket.once("close", done);
13951
13951
  socket.end();
@@ -15095,7 +15095,7 @@ var init_provider_cli_adapter = __esm({
15095
15095
  `[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
15096
15096
  );
15097
15097
  }
15098
- await new Promise((resolve22) => setTimeout(resolve22, 50));
15098
+ await new Promise((resolve23) => setTimeout(resolve23, 50));
15099
15099
  }
15100
15100
  const finalScreenText = this.terminalScreen.getText() || "";
15101
15101
  LOG.warn(
@@ -16005,7 +16005,7 @@ var init_provider_cli_adapter = __esm({
16005
16005
  const deadline = Date.now() + 1e4;
16006
16006
  while (this.startupParseGate && Date.now() < deadline) {
16007
16007
  this.resolveStartupState("send_wait");
16008
- await new Promise((resolve22) => setTimeout(resolve22, 50));
16008
+ await new Promise((resolve23) => setTimeout(resolve23, 50));
16009
16009
  }
16010
16010
  }
16011
16011
  if (!allowInterventionPrompt) {
@@ -16081,13 +16081,13 @@ var init_provider_cli_adapter = __esm({
16081
16081
  }
16082
16082
  this.responseEpoch += 1;
16083
16083
  this.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
16084
- await new Promise((resolve22, reject) => {
16084
+ await new Promise((resolve23, reject) => {
16085
16085
  let resolved = false;
16086
16086
  const completion = {
16087
16087
  resolveOnce: () => {
16088
16088
  if (resolved) return;
16089
16089
  resolved = true;
16090
- resolve22();
16090
+ resolve23();
16091
16091
  },
16092
16092
  rejectOnce: (error48) => {
16093
16093
  if (resolved) return;
@@ -16245,17 +16245,17 @@ var init_provider_cli_adapter = __esm({
16245
16245
  }
16246
16246
  }
16247
16247
  waitForStopped(timeoutMs) {
16248
- return new Promise((resolve22) => {
16248
+ return new Promise((resolve23) => {
16249
16249
  const startedAt = Date.now();
16250
16250
  const timer = setInterval(() => {
16251
16251
  if (!this.ptyProcess || this.currentStatus === "stopped") {
16252
16252
  clearInterval(timer);
16253
- resolve22(true);
16253
+ resolve23(true);
16254
16254
  return;
16255
16255
  }
16256
16256
  if (Date.now() - startedAt >= timeoutMs) {
16257
16257
  clearInterval(timer);
16258
- resolve22(false);
16258
+ resolve23(false);
16259
16259
  }
16260
16260
  }, 100);
16261
16261
  });
@@ -16593,7 +16593,7 @@ async function waitForCliAdapterReady(adapter, options) {
16593
16593
  if (status === "stopped") {
16594
16594
  throw new Error("CLI runtime stopped before it became ready");
16595
16595
  }
16596
- await new Promise((resolve22) => setTimeout(resolve22, pollMs));
16596
+ await new Promise((resolve23) => setTimeout(resolve23, pollMs));
16597
16597
  }
16598
16598
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
16599
16599
  }
@@ -16958,7 +16958,7 @@ var init_cli_provider_instance = __esm({
16958
16958
  const enterCount = cliCommand.enterCount || 1;
16959
16959
  await this.adapter.writeRaw(cliCommand.text + "\r");
16960
16960
  for (let i = 1; i < enterCount; i += 1) {
16961
- await new Promise((resolve22) => setTimeout(resolve22, 50));
16961
+ await new Promise((resolve23) => setTimeout(resolve23, 50));
16962
16962
  await this.adapter.writeRaw("\r");
16963
16963
  }
16964
16964
  }
@@ -33540,8 +33540,8 @@ var init_acp = __esm({
33540
33540
  this.#requestHandler = requestHandler;
33541
33541
  this.#notificationHandler = notificationHandler;
33542
33542
  this.#stream = stream;
33543
- this.#closedPromise = new Promise((resolve22) => {
33544
- this.#abortController.signal.addEventListener("abort", () => resolve22());
33543
+ this.#closedPromise = new Promise((resolve23) => {
33544
+ this.#abortController.signal.addEventListener("abort", () => resolve23());
33545
33545
  });
33546
33546
  this.#receive();
33547
33547
  }
@@ -33690,8 +33690,8 @@ var init_acp = __esm({
33690
33690
  }
33691
33691
  async sendRequest(method, params) {
33692
33692
  const id = this.#nextRequestId++;
33693
- const responsePromise = new Promise((resolve22, reject) => {
33694
- this.#pendingResponses.set(id, { resolve: resolve22, reject });
33693
+ const responsePromise = new Promise((resolve23, reject) => {
33694
+ this.#pendingResponses.set(id, { resolve: resolve23, reject });
33695
33695
  });
33696
33696
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
33697
33697
  return responsePromise;
@@ -34375,13 +34375,13 @@ var init_acp_provider_instance = __esm({
34375
34375
  }
34376
34376
  this.currentStatus = "waiting_approval";
34377
34377
  this.detectStatusTransition();
34378
- const approved = await new Promise((resolve22) => {
34379
- this.permissionResolvers.push(resolve22);
34378
+ const approved = await new Promise((resolve23) => {
34379
+ this.permissionResolvers.push(resolve23);
34380
34380
  setTimeout(() => {
34381
- const idx = this.permissionResolvers.indexOf(resolve22);
34381
+ const idx = this.permissionResolvers.indexOf(resolve23);
34382
34382
  if (idx >= 0) {
34383
34383
  this.permissionResolvers.splice(idx, 1);
34384
- resolve22(false);
34384
+ resolve23(false);
34385
34385
  }
34386
34386
  }, 3e5);
34387
34387
  });
@@ -36516,9 +36516,9 @@ var init_handler2 = __esm({
36516
36516
  if (this.fsw.closed) {
36517
36517
  return;
36518
36518
  }
36519
- const dirname11 = sp.dirname(file2);
36519
+ const dirname12 = sp.dirname(file2);
36520
36520
  const basename10 = sp.basename(file2);
36521
- const parent = this.fsw._getWatchedDir(dirname11);
36521
+ const parent = this.fsw._getWatchedDir(dirname12);
36522
36522
  let prevStats = stats;
36523
36523
  if (parent.has(basename10))
36524
36524
  return;
@@ -36545,7 +36545,7 @@ var init_handler2 = __esm({
36545
36545
  prevStats = newStats2;
36546
36546
  }
36547
36547
  } catch (error48) {
36548
- this.fsw._remove(dirname11, basename10);
36548
+ this.fsw._remove(dirname12, basename10);
36549
36549
  }
36550
36550
  } else if (parent.has(basename10)) {
36551
36551
  const at = newStats.atimeMs;
@@ -36642,7 +36642,7 @@ var init_handler2 = __esm({
36642
36642
  this._addToNodeFs(path40, initialAdd, wh, depth + 1);
36643
36643
  }
36644
36644
  }).on(EV.ERROR, this._boundHandleError);
36645
- return new Promise((resolve22, reject) => {
36645
+ return new Promise((resolve23, reject) => {
36646
36646
  if (!stream)
36647
36647
  return reject();
36648
36648
  stream.once(STR_END, () => {
@@ -36651,7 +36651,7 @@ var init_handler2 = __esm({
36651
36651
  return;
36652
36652
  }
36653
36653
  const wasThrottled = throttler ? throttler.clear() : false;
36654
- resolve22(void 0);
36654
+ resolve23(void 0);
36655
36655
  previous.getChildren().filter((item) => {
36656
36656
  return item !== directory && !current.has(item);
36657
36657
  }).forEach((item) => {
@@ -38751,7 +38751,7 @@ var init_provider_loader = __esm({
38751
38751
  return { updated: false };
38752
38752
  }
38753
38753
  try {
38754
- const etag = await new Promise((resolve22, reject) => {
38754
+ const etag = await new Promise((resolve23, reject) => {
38755
38755
  const options = {
38756
38756
  method: "HEAD",
38757
38757
  hostname: "github.com",
@@ -38769,7 +38769,7 @@ var init_provider_loader = __esm({
38769
38769
  headers: { "User-Agent": "adhdev-launcher" },
38770
38770
  timeout: 1e4
38771
38771
  }, (res2) => {
38772
- resolve22(res2.headers.etag || res2.headers["last-modified"] || "");
38772
+ resolve23(res2.headers.etag || res2.headers["last-modified"] || "");
38773
38773
  });
38774
38774
  req2.on("error", reject);
38775
38775
  req2.on("timeout", () => {
@@ -38778,7 +38778,7 @@ var init_provider_loader = __esm({
38778
38778
  });
38779
38779
  req2.end();
38780
38780
  } else {
38781
- resolve22(res.headers.etag || res.headers["last-modified"] || "");
38781
+ resolve23(res.headers.etag || res.headers["last-modified"] || "");
38782
38782
  }
38783
38783
  });
38784
38784
  req.on("error", reject);
@@ -38842,7 +38842,7 @@ var init_provider_loader = __esm({
38842
38842
  downloadFile(url2, destPath) {
38843
38843
  const https = require("https");
38844
38844
  const http3 = require("http");
38845
- return new Promise((resolve22, reject) => {
38845
+ return new Promise((resolve23, reject) => {
38846
38846
  const doRequest = (reqUrl, redirectCount = 0) => {
38847
38847
  if (redirectCount > 5) {
38848
38848
  reject(new Error("Too many redirects"));
@@ -38862,7 +38862,7 @@ var init_provider_loader = __esm({
38862
38862
  res.pipe(ws);
38863
38863
  ws.on("finish", () => {
38864
38864
  ws.close();
38865
- resolve22();
38865
+ resolve23();
38866
38866
  });
38867
38867
  ws.on("error", reject);
38868
38868
  });
@@ -39447,17 +39447,17 @@ async function findFreePort(ports) {
39447
39447
  throw new Error("No free port found");
39448
39448
  }
39449
39449
  function checkPortFree(port) {
39450
- return new Promise((resolve22) => {
39450
+ return new Promise((resolve23) => {
39451
39451
  const server = net2.createServer();
39452
39452
  server.unref();
39453
- server.on("error", () => resolve22(false));
39453
+ server.on("error", () => resolve23(false));
39454
39454
  server.listen(port, "127.0.0.1", () => {
39455
- server.close(() => resolve22(true));
39455
+ server.close(() => resolve23(true));
39456
39456
  });
39457
39457
  });
39458
39458
  }
39459
39459
  async function isCdpActive(port) {
39460
- return new Promise((resolve22) => {
39460
+ return new Promise((resolve23) => {
39461
39461
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
39462
39462
  timeout: 2e3
39463
39463
  }, (res) => {
@@ -39466,16 +39466,16 @@ async function isCdpActive(port) {
39466
39466
  res.on("end", () => {
39467
39467
  try {
39468
39468
  const info = JSON.parse(data);
39469
- resolve22(!!info["WebKit-Version"] || !!info["Browser"]);
39469
+ resolve23(!!info["WebKit-Version"] || !!info["Browser"]);
39470
39470
  } catch {
39471
- resolve22(false);
39471
+ resolve23(false);
39472
39472
  }
39473
39473
  });
39474
39474
  });
39475
- req.on("error", () => resolve22(false));
39475
+ req.on("error", () => resolve23(false));
39476
39476
  req.on("timeout", () => {
39477
39477
  req.destroy();
39478
- resolve22(false);
39478
+ resolve23(false);
39479
39479
  });
39480
39480
  });
39481
39481
  }
@@ -39986,11 +39986,23 @@ function resolveMeshCoordinatorSetup(options) {
39986
39986
  if (!path40) {
39987
39987
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
39988
39988
  }
39989
+ const mcpServer = resolveAdhdevMcpServerLaunch({
39990
+ meshId,
39991
+ nodeExecutable: options.nodeExecutable,
39992
+ adhdevMcpEntryPath: options.adhdevMcpEntryPath
39993
+ });
39994
+ if (!mcpServer) {
39995
+ return {
39996
+ kind: "unsupported",
39997
+ reason: "Could not resolve the ADHDev MCP server entrypoint without relying on a PATH bin shim"
39998
+ };
39999
+ }
39989
40000
  return {
39990
40001
  kind: "auto_import",
39991
40002
  serverName,
39992
- configPath: (0, import_path4.join)(workspace, path40),
39993
- configFormat: mcpConfig.format
40003
+ configPath: (0, import_node_path2.join)(workspace, path40),
40004
+ configFormat: mcpConfig.format,
40005
+ mcpServer
39994
40006
  };
39995
40007
  }
39996
40008
  if (mcpConfig.mode === "manual") {
@@ -40022,11 +40034,60 @@ function resolveMeshCoordinatorSetup(options) {
40022
40034
  function renderMeshCoordinatorTemplate(template, values) {
40023
40035
  return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_2, key) => values[key] || "");
40024
40036
  }
40025
- var import_path4, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND;
40037
+ function resolveAdhdevMcpServerLaunch(options) {
40038
+ const entryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath);
40039
+ if (!entryPath) return null;
40040
+ return {
40041
+ command: options.nodeExecutable?.trim() || process.execPath,
40042
+ args: [entryPath, "--repo-mesh", options.meshId]
40043
+ };
40044
+ }
40045
+ function resolveAdhdevMcpEntryPath(explicitPath) {
40046
+ const explicit = explicitPath?.trim();
40047
+ if (explicit) return normalizeExistingPath(explicit) || explicit;
40048
+ const envPath = process.env.ADHDEV_MCP_SERVER_PATH?.trim();
40049
+ if (envPath) return normalizeExistingPath(envPath) || envPath;
40050
+ const candidates = [];
40051
+ const addCandidate = (candidate) => {
40052
+ if (!candidates.includes(candidate)) candidates.push(candidate);
40053
+ };
40054
+ const addPackagedCandidates = (baseFile) => {
40055
+ if (!baseFile) return;
40056
+ const realBase = normalizeExistingPath(baseFile) || baseFile;
40057
+ const dir = (0, import_node_path2.dirname)(realBase);
40058
+ addCandidate((0, import_node_path2.resolve)(dir, "../vendor/mcp-server/index.js"));
40059
+ addCandidate((0, import_node_path2.resolve)(dir, "../../vendor/mcp-server/index.js"));
40060
+ addCandidate((0, import_node_path2.resolve)(dir, "../../../vendor/mcp-server/index.js"));
40061
+ };
40062
+ addPackagedCandidates(process.argv[1]);
40063
+ for (const candidate of candidates) {
40064
+ const normalized = normalizeExistingPath(candidate);
40065
+ if (normalized) return normalized;
40066
+ }
40067
+ try {
40068
+ const requireBase = process.argv[1] ? normalizeExistingPath(process.argv[1]) || process.argv[1] : (0, import_node_path2.join)(process.cwd(), "adhdev-daemon.js");
40069
+ const req = (0, import_node_module2.createRequire)(requireBase);
40070
+ const resolvedModule = req.resolve("@adhdev/mcp-server");
40071
+ return normalizeExistingPath(resolvedModule) || resolvedModule;
40072
+ } catch {
40073
+ return null;
40074
+ }
40075
+ }
40076
+ function normalizeExistingPath(filePath) {
40077
+ try {
40078
+ if (!(0, import_node_fs4.existsSync)(filePath)) return null;
40079
+ return import_node_fs4.realpathSync.native(filePath);
40080
+ } catch {
40081
+ return null;
40082
+ }
40083
+ }
40084
+ var import_node_fs4, import_node_module2, import_node_path2, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND;
40026
40085
  var init_mesh_coordinator = __esm({
40027
40086
  "../../oss/packages/daemon-core/src/commands/mesh-coordinator.ts"() {
40028
40087
  "use strict";
40029
- import_path4 = require("path");
40088
+ import_node_fs4 = require("fs");
40089
+ import_node_module2 = require("module");
40090
+ import_node_path2 = require("path");
40030
40091
  DEFAULT_SERVER_NAME = "adhdev-mesh";
40031
40092
  DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
40032
40093
  }
@@ -40545,7 +40606,7 @@ async function waitForPidExit(pid, timeoutMs) {
40545
40606
  while (Date.now() - start < timeoutMs) {
40546
40607
  try {
40547
40608
  process.kill(pid, 0);
40548
- await new Promise((resolve22) => setTimeout(resolve22, 250));
40609
+ await new Promise((resolve23) => setTimeout(resolve23, 250));
40549
40610
  } catch {
40550
40611
  return;
40551
40612
  }
@@ -40656,7 +40717,7 @@ async function runDaemonUpgradeHelper(payload) {
40656
40717
  appendUpgradeLog(installOutput.trim());
40657
40718
  }
40658
40719
  if (process.platform === "win32") {
40659
- await new Promise((resolve22) => setTimeout(resolve22, 500));
40720
+ await new Promise((resolve23) => setTimeout(resolve23, 500));
40660
40721
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
40661
40722
  appendUpgradeLog("Post-install staging cleanup complete");
40662
40723
  }
@@ -41542,7 +41603,20 @@ var init_router = __esm({
41542
41603
  }
41543
41604
  if (!mesh) return { success: false, error: "Mesh not found" };
41544
41605
  if (!Array.isArray(mesh.nodes) || mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
41545
- const workspace = mesh.nodes[0].workspace;
41606
+ const requestedCoordinatorNodeId = typeof args?.coordinatorNodeId === "string" ? args.coordinatorNodeId.trim() : "";
41607
+ const preferredCoordinatorNodeId = requestedCoordinatorNodeId || (typeof mesh.coordinator?.preferredNodeId === "string" ? mesh.coordinator.preferredNodeId.trim() : "");
41608
+ const coordinatorNode = preferredCoordinatorNodeId ? mesh.nodes.find((node) => node?.id === preferredCoordinatorNodeId || node?.nodeId === preferredCoordinatorNodeId) : mesh.nodes[0];
41609
+ if (!coordinatorNode) {
41610
+ return {
41611
+ success: false,
41612
+ code: "mesh_coordinator_node_not_found",
41613
+ error: `Coordinator node ${preferredCoordinatorNodeId} was not found in mesh`,
41614
+ meshId,
41615
+ cliType
41616
+ };
41617
+ }
41618
+ const workspace = typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "";
41619
+ if (!workspace) return { success: false, error: "Coordinator node workspace required", meshId, cliType };
41546
41620
  const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
41547
41621
  const coordinatorSetup = resolveMeshCoordinatorSetup({
41548
41622
  provider: providerMeta,
@@ -41580,9 +41654,9 @@ var init_router = __esm({
41580
41654
  workspace
41581
41655
  };
41582
41656
  }
41583
- const { existsSync: existsSync28, readFileSync: readFileSync21, writeFileSync: writeFileSync15, copyFileSync: copyFileSync4 } = await import("fs");
41657
+ const { existsSync: existsSync29, readFileSync: readFileSync21, writeFileSync: writeFileSync15, copyFileSync: copyFileSync4 } = await import("fs");
41584
41658
  const mcpConfigPath = coordinatorSetup.configPath;
41585
- const hadExistingMcpConfig = existsSync28(mcpConfigPath);
41659
+ const hadExistingMcpConfig = existsSync29(mcpConfigPath);
41586
41660
  let existingMcpConfig = {};
41587
41661
  if (hadExistingMcpConfig) {
41588
41662
  try {
@@ -41596,8 +41670,8 @@ var init_router = __esm({
41596
41670
  mcpServers: {
41597
41671
  ...existingMcpConfig.mcpServers || {},
41598
41672
  [coordinatorSetup.serverName]: {
41599
- command: "adhdev-mcp",
41600
- args: ["--repo-mesh", meshId]
41673
+ command: coordinatorSetup.mcpServer.command,
41674
+ args: coordinatorSetup.mcpServer.args
41601
41675
  }
41602
41676
  }
41603
41677
  };
@@ -42283,7 +42357,7 @@ var init_provider_adapter = __esm({
42283
42357
  const beforeCount = this.messageCount(before);
42284
42358
  const beforeSignature = this.lastMessageSignature(before);
42285
42359
  for (let attempt = 0; attempt < 12; attempt += 1) {
42286
- await new Promise((resolve22) => setTimeout(resolve22, 250));
42360
+ await new Promise((resolve23) => setTimeout(resolve23, 250));
42287
42361
  let state;
42288
42362
  try {
42289
42363
  state = await this.readChat(evaluate);
@@ -42305,7 +42379,7 @@ var init_provider_adapter = __esm({
42305
42379
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
42306
42380
  return first;
42307
42381
  }
42308
- await new Promise((resolve22) => setTimeout(resolve22, 150));
42382
+ await new Promise((resolve23) => setTimeout(resolve23, 150));
42309
42383
  const second = await this.readChat(evaluate);
42310
42384
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
42311
42385
  }
@@ -42456,7 +42530,7 @@ var init_provider_adapter = __esm({
42456
42530
  if (typeof data.error === "string" && data.error.trim()) return false;
42457
42531
  }
42458
42532
  for (let attempt = 0; attempt < 6; attempt += 1) {
42459
- await new Promise((resolve22) => setTimeout(resolve22, 250));
42533
+ await new Promise((resolve23) => setTimeout(resolve23, 250));
42460
42534
  const state = await this.readChat(evaluate);
42461
42535
  const title = this.getStateTitle(state);
42462
42536
  if (this.titlesMatch(title, sessionId)) return true;
@@ -45103,7 +45177,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
45103
45177
  return { target, instance, adapter };
45104
45178
  }
45105
45179
  function sleep(ms) {
45106
- return new Promise((resolve22) => setTimeout(resolve22, ms));
45180
+ return new Promise((resolve23) => setTimeout(resolve23, ms));
45107
45181
  }
45108
45182
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
45109
45183
  const startedAt = Date.now();
@@ -47383,15 +47457,15 @@ var init_dev_server = __esm({
47383
47457
  this.json(res, 500, { error: e.message });
47384
47458
  }
47385
47459
  });
47386
- return new Promise((resolve22, reject) => {
47460
+ return new Promise((resolve23, reject) => {
47387
47461
  this.server.listen(port, "127.0.0.1", () => {
47388
47462
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
47389
- resolve22();
47463
+ resolve23();
47390
47464
  });
47391
47465
  this.server.on("error", (e) => {
47392
47466
  if (e.code === "EADDRINUSE") {
47393
47467
  this.log(`Port ${port} in use, skipping dev server`);
47394
- resolve22();
47468
+ resolve23();
47395
47469
  } else {
47396
47470
  reject(e);
47397
47471
  }
@@ -47473,20 +47547,20 @@ var init_dev_server = __esm({
47473
47547
  child.stderr?.on("data", (d) => {
47474
47548
  stderr += d.toString().slice(0, 2e3);
47475
47549
  });
47476
- await new Promise((resolve22) => {
47550
+ await new Promise((resolve23) => {
47477
47551
  const timer = setTimeout(() => {
47478
47552
  child.kill();
47479
- resolve22();
47553
+ resolve23();
47480
47554
  }, 3e3);
47481
47555
  child.on("exit", () => {
47482
47556
  clearTimeout(timer);
47483
- resolve22();
47557
+ resolve23();
47484
47558
  });
47485
47559
  child.stdout?.once("data", () => {
47486
47560
  setTimeout(() => {
47487
47561
  child.kill();
47488
47562
  clearTimeout(timer);
47489
- resolve22();
47563
+ resolve23();
47490
47564
  }, 500);
47491
47565
  });
47492
47566
  });
@@ -47989,14 +48063,14 @@ var init_dev_server = __esm({
47989
48063
  child.stderr?.on("data", (d) => {
47990
48064
  stderr += d.toString();
47991
48065
  });
47992
- await new Promise((resolve22) => {
48066
+ await new Promise((resolve23) => {
47993
48067
  const timer = setTimeout(() => {
47994
48068
  child.kill();
47995
- resolve22();
48069
+ resolve23();
47996
48070
  }, timeout);
47997
48071
  child.on("exit", () => {
47998
48072
  clearTimeout(timer);
47999
- resolve22();
48073
+ resolve23();
48000
48074
  });
48001
48075
  });
48002
48076
  const elapsed = Date.now() - start;
@@ -48666,14 +48740,14 @@ data: ${JSON.stringify(msg.data)}
48666
48740
  res.end(JSON.stringify(data, null, 2));
48667
48741
  }
48668
48742
  async readBody(req) {
48669
- return new Promise((resolve22) => {
48743
+ return new Promise((resolve23) => {
48670
48744
  let body = "";
48671
48745
  req.on("data", (chunk) => body += chunk);
48672
48746
  req.on("end", () => {
48673
48747
  try {
48674
- resolve22(JSON.parse(body));
48748
+ resolve23(JSON.parse(body));
48675
48749
  } catch {
48676
- resolve22({});
48750
+ resolve23({});
48677
48751
  }
48678
48752
  });
48679
48753
  });
@@ -49190,7 +49264,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
49190
49264
  const deadline = Date.now() + timeoutMs;
49191
49265
  while (Date.now() < deadline) {
49192
49266
  if (await canConnect(endpoint)) return;
49193
- await new Promise((resolve22) => setTimeout(resolve22, STARTUP_POLL_MS));
49267
+ await new Promise((resolve23) => setTimeout(resolve23, STARTUP_POLL_MS));
49194
49268
  }
49195
49269
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
49196
49270
  }
@@ -49296,10 +49370,10 @@ async function installExtension(ide, extension) {
49296
49370
  const buffer = Buffer.from(await res.arrayBuffer());
49297
49371
  const fs24 = await import("fs");
49298
49372
  fs24.writeFileSync(vsixPath, buffer);
49299
- return new Promise((resolve22) => {
49373
+ return new Promise((resolve23) => {
49300
49374
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
49301
49375
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
49302
- resolve22({
49376
+ resolve23({
49303
49377
  extensionId: extension.id,
49304
49378
  marketplaceId: extension.marketplaceId,
49305
49379
  success: !error48,
@@ -49312,11 +49386,11 @@ async function installExtension(ide, extension) {
49312
49386
  } catch (e) {
49313
49387
  }
49314
49388
  }
49315
- return new Promise((resolve22) => {
49389
+ return new Promise((resolve23) => {
49316
49390
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
49317
49391
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
49318
49392
  if (error48) {
49319
- resolve22({
49393
+ resolve23({
49320
49394
  extensionId: extension.id,
49321
49395
  marketplaceId: extension.marketplaceId,
49322
49396
  success: false,
@@ -49324,7 +49398,7 @@ async function installExtension(ide, extension) {
49324
49398
  error: stderr || error48.message
49325
49399
  });
49326
49400
  } else {
49327
- resolve22({
49401
+ resolve23({
49328
49402
  extensionId: extension.id,
49329
49403
  marketplaceId: extension.marketplaceId,
49330
49404
  success: true,
@@ -50085,7 +50159,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
50085
50159
  const resolvedPort = resolveDaemonCommandPort(port);
50086
50160
  const WebSocket4 = (await import("ws")).default;
50087
50161
  const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
50088
- return new Promise((resolve22, reject) => {
50162
+ return new Promise((resolve23, reject) => {
50089
50163
  const wsUrl = `ws://127.0.0.1:${resolvedPort}${DAEMON_WS_PATH2 || "/daemon"}`;
50090
50164
  const ws = new WebSocket4(wsUrl);
50091
50165
  const requestId = `cli-${Date.now()}`;
@@ -50126,7 +50200,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
50126
50200
  if (msg.type === "ext:command_result" && msg.payload?.requestId === requestId || msg.type === "daemon:command_result" || msg.type === "command_result") {
50127
50201
  clearTimeout(timeout);
50128
50202
  ws.close();
50129
- resolve22(msg.payload?.result || msg.payload || msg);
50203
+ resolve23(msg.payload?.result || msg.payload || msg);
50130
50204
  }
50131
50205
  } catch {
50132
50206
  }
@@ -50145,13 +50219,13 @@ This command needs a running local daemon with IPC enabled. Start with: adhdev d
50145
50219
  }
50146
50220
  async function directCdpEval(expression, port = 9222) {
50147
50221
  const http3 = await import("http");
50148
- const targets = await new Promise((resolve22, reject) => {
50222
+ const targets = await new Promise((resolve23, reject) => {
50149
50223
  http3.get(`http://127.0.0.1:${port}/json`, (res) => {
50150
50224
  let data = "";
50151
50225
  res.on("data", (c) => data += c);
50152
50226
  res.on("end", () => {
50153
50227
  try {
50154
- resolve22(JSON.parse(data));
50228
+ resolve23(JSON.parse(data));
50155
50229
  } catch {
50156
50230
  reject(new Error("Invalid JSON"));
50157
50231
  }
@@ -50164,7 +50238,7 @@ async function directCdpEval(expression, port = 9222) {
50164
50238
  const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
50165
50239
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
50166
50240
  const WebSocket4 = (await import("ws")).default;
50167
- return new Promise((resolve22, reject) => {
50241
+ return new Promise((resolve23, reject) => {
50168
50242
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
50169
50243
  const timeout = setTimeout(() => {
50170
50244
  ws.close();
@@ -50186,11 +50260,11 @@ async function directCdpEval(expression, port = 9222) {
50186
50260
  clearTimeout(timeout);
50187
50261
  ws.close();
50188
50262
  if (msg.result?.result?.value !== void 0) {
50189
- resolve22(msg.result.result.value);
50263
+ resolve23(msg.result.result.value);
50190
50264
  } else if (msg.result?.exceptionDetails) {
50191
50265
  reject(new Error(msg.result.exceptionDetails.text));
50192
50266
  } else {
50193
- resolve22(msg.result);
50267
+ resolve23(msg.result);
50194
50268
  }
50195
50269
  }
50196
50270
  });
@@ -50726,14 +50800,14 @@ var require_run_async = __commonJS({
50726
50800
  return function() {
50727
50801
  var args = arguments;
50728
50802
  var originalThis = this;
50729
- var promise2 = new Promise(function(resolve22, reject) {
50803
+ var promise2 = new Promise(function(resolve23, reject) {
50730
50804
  var resolved = false;
50731
50805
  const wrappedResolve = function(value) {
50732
50806
  if (resolved) {
50733
50807
  console.warn("Run-async promise already resolved.");
50734
50808
  }
50735
50809
  resolved = true;
50736
- resolve22(value);
50810
+ resolve23(value);
50737
50811
  };
50738
50812
  var rejected = false;
50739
50813
  const wrappedReject = function(value) {
@@ -51524,7 +51598,7 @@ var require_Observable = __commonJS({
51524
51598
  Observable2.prototype.forEach = function(next, promiseCtor) {
51525
51599
  var _this = this;
51526
51600
  promiseCtor = getPromiseCtor(promiseCtor);
51527
- return new promiseCtor(function(resolve22, reject) {
51601
+ return new promiseCtor(function(resolve23, reject) {
51528
51602
  var subscriber = new Subscriber_1.SafeSubscriber({
51529
51603
  next: function(value) {
51530
51604
  try {
@@ -51535,7 +51609,7 @@ var require_Observable = __commonJS({
51535
51609
  }
51536
51610
  },
51537
51611
  error: reject,
51538
- complete: resolve22
51612
+ complete: resolve23
51539
51613
  });
51540
51614
  _this.subscribe(subscriber);
51541
51615
  });
@@ -51557,14 +51631,14 @@ var require_Observable = __commonJS({
51557
51631
  Observable2.prototype.toPromise = function(promiseCtor) {
51558
51632
  var _this = this;
51559
51633
  promiseCtor = getPromiseCtor(promiseCtor);
51560
- return new promiseCtor(function(resolve22, reject) {
51634
+ return new promiseCtor(function(resolve23, reject) {
51561
51635
  var value;
51562
51636
  _this.subscribe(function(x) {
51563
51637
  return value = x;
51564
51638
  }, function(err) {
51565
51639
  return reject(err);
51566
51640
  }, function() {
51567
- return resolve22(value);
51641
+ return resolve23(value);
51568
51642
  });
51569
51643
  });
51570
51644
  };
@@ -53660,11 +53734,11 @@ var require_innerFrom = __commonJS({
53660
53734
  "use strict";
53661
53735
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
53662
53736
  function adopt(value) {
53663
- return value instanceof P ? value : new P(function(resolve22) {
53664
- resolve22(value);
53737
+ return value instanceof P ? value : new P(function(resolve23) {
53738
+ resolve23(value);
53665
53739
  });
53666
53740
  }
53667
- return new (P || (P = Promise))(function(resolve22, reject) {
53741
+ return new (P || (P = Promise))(function(resolve23, reject) {
53668
53742
  function fulfilled(value) {
53669
53743
  try {
53670
53744
  step(generator.next(value));
@@ -53680,7 +53754,7 @@ var require_innerFrom = __commonJS({
53680
53754
  }
53681
53755
  }
53682
53756
  function step(result) {
53683
- result.done ? resolve22(result.value) : adopt(result.value).then(fulfilled, rejected);
53757
+ result.done ? resolve23(result.value) : adopt(result.value).then(fulfilled, rejected);
53684
53758
  }
53685
53759
  step((generator = generator.apply(thisArg, _arguments || [])).next());
53686
53760
  });
@@ -53762,14 +53836,14 @@ var require_innerFrom = __commonJS({
53762
53836
  }, i);
53763
53837
  function verb(n) {
53764
53838
  i[n] = o[n] && function(v) {
53765
- return new Promise(function(resolve22, reject) {
53766
- v = o[n](v), settle(resolve22, reject, v.done, v.value);
53839
+ return new Promise(function(resolve23, reject) {
53840
+ v = o[n](v), settle(resolve23, reject, v.done, v.value);
53767
53841
  });
53768
53842
  };
53769
53843
  }
53770
- function settle(resolve22, reject, d, v) {
53844
+ function settle(resolve23, reject, d, v) {
53771
53845
  Promise.resolve(v).then(function(v2) {
53772
- resolve22({ value: v2, done: d });
53846
+ resolve23({ value: v2, done: d });
53773
53847
  }, reject);
53774
53848
  }
53775
53849
  };
@@ -54388,7 +54462,7 @@ var require_lastValueFrom = __commonJS({
54388
54462
  var EmptyError_1 = require_EmptyError();
54389
54463
  function lastValueFrom(source, config2) {
54390
54464
  var hasConfig = typeof config2 === "object";
54391
- return new Promise(function(resolve22, reject) {
54465
+ return new Promise(function(resolve23, reject) {
54392
54466
  var _hasValue = false;
54393
54467
  var _value;
54394
54468
  source.subscribe({
@@ -54399,9 +54473,9 @@ var require_lastValueFrom = __commonJS({
54399
54473
  error: reject,
54400
54474
  complete: function() {
54401
54475
  if (_hasValue) {
54402
- resolve22(_value);
54476
+ resolve23(_value);
54403
54477
  } else if (hasConfig) {
54404
- resolve22(config2.defaultValue);
54478
+ resolve23(config2.defaultValue);
54405
54479
  } else {
54406
54480
  reject(new EmptyError_1.EmptyError());
54407
54481
  }
@@ -54423,16 +54497,16 @@ var require_firstValueFrom = __commonJS({
54423
54497
  var Subscriber_1 = require_Subscriber();
54424
54498
  function firstValueFrom(source, config2) {
54425
54499
  var hasConfig = typeof config2 === "object";
54426
- return new Promise(function(resolve22, reject) {
54500
+ return new Promise(function(resolve23, reject) {
54427
54501
  var subscriber = new Subscriber_1.SafeSubscriber({
54428
54502
  next: function(value) {
54429
- resolve22(value);
54503
+ resolve23(value);
54430
54504
  subscriber.unsubscribe();
54431
54505
  },
54432
54506
  error: reject,
54433
54507
  complete: function() {
54434
54508
  if (hasConfig) {
54435
- resolve22(config2.defaultValue);
54509
+ resolve23(config2.defaultValue);
54436
54510
  } else {
54437
54511
  reject(new EmptyError_1.EmptyError());
54438
54512
  }
@@ -66238,14 +66312,14 @@ var require_async_iterator = __commonJS({
66238
66312
  };
66239
66313
  }
66240
66314
  function readAndResolve(iter) {
66241
- var resolve22 = iter[kLastResolve];
66242
- if (resolve22 !== null) {
66315
+ var resolve23 = iter[kLastResolve];
66316
+ if (resolve23 !== null) {
66243
66317
  var data = iter[kStream].read();
66244
66318
  if (data !== null) {
66245
66319
  iter[kLastPromise] = null;
66246
66320
  iter[kLastResolve] = null;
66247
66321
  iter[kLastReject] = null;
66248
- resolve22(createIterResult(data, false));
66322
+ resolve23(createIterResult(data, false));
66249
66323
  }
66250
66324
  }
66251
66325
  }
@@ -66253,13 +66327,13 @@ var require_async_iterator = __commonJS({
66253
66327
  process.nextTick(readAndResolve, iter);
66254
66328
  }
66255
66329
  function wrapForNext(lastPromise, iter) {
66256
- return function(resolve22, reject) {
66330
+ return function(resolve23, reject) {
66257
66331
  lastPromise.then(function() {
66258
66332
  if (iter[kEnded]) {
66259
- resolve22(createIterResult(void 0, true));
66333
+ resolve23(createIterResult(void 0, true));
66260
66334
  return;
66261
66335
  }
66262
- iter[kHandlePromise](resolve22, reject);
66336
+ iter[kHandlePromise](resolve23, reject);
66263
66337
  }, reject);
66264
66338
  };
66265
66339
  }
@@ -66279,12 +66353,12 @@ var require_async_iterator = __commonJS({
66279
66353
  return Promise.resolve(createIterResult(void 0, true));
66280
66354
  }
66281
66355
  if (this[kStream].destroyed) {
66282
- return new Promise(function(resolve22, reject) {
66356
+ return new Promise(function(resolve23, reject) {
66283
66357
  process.nextTick(function() {
66284
66358
  if (_this[kError]) {
66285
66359
  reject(_this[kError]);
66286
66360
  } else {
66287
- resolve22(createIterResult(void 0, true));
66361
+ resolve23(createIterResult(void 0, true));
66288
66362
  }
66289
66363
  });
66290
66364
  });
@@ -66307,13 +66381,13 @@ var require_async_iterator = __commonJS({
66307
66381
  return this;
66308
66382
  }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
66309
66383
  var _this2 = this;
66310
- return new Promise(function(resolve22, reject) {
66384
+ return new Promise(function(resolve23, reject) {
66311
66385
  _this2[kStream].destroy(null, function(err) {
66312
66386
  if (err) {
66313
66387
  reject(err);
66314
66388
  return;
66315
66389
  }
66316
- resolve22(createIterResult(void 0, true));
66390
+ resolve23(createIterResult(void 0, true));
66317
66391
  });
66318
66392
  });
66319
66393
  }), _Object$setPrototypeO), AsyncIteratorPrototype);
@@ -66335,15 +66409,15 @@ var require_async_iterator = __commonJS({
66335
66409
  value: stream._readableState.endEmitted,
66336
66410
  writable: true
66337
66411
  }), _defineProperty(_Object$create, kHandlePromise, {
66338
- value: function value(resolve22, reject) {
66412
+ value: function value(resolve23, reject) {
66339
66413
  var data = iterator[kStream].read();
66340
66414
  if (data) {
66341
66415
  iterator[kLastPromise] = null;
66342
66416
  iterator[kLastResolve] = null;
66343
66417
  iterator[kLastReject] = null;
66344
- resolve22(createIterResult(data, false));
66418
+ resolve23(createIterResult(data, false));
66345
66419
  } else {
66346
- iterator[kLastResolve] = resolve22;
66420
+ iterator[kLastResolve] = resolve23;
66347
66421
  iterator[kLastReject] = reject;
66348
66422
  }
66349
66423
  },
@@ -66362,12 +66436,12 @@ var require_async_iterator = __commonJS({
66362
66436
  iterator[kError] = err;
66363
66437
  return;
66364
66438
  }
66365
- var resolve22 = iterator[kLastResolve];
66366
- if (resolve22 !== null) {
66439
+ var resolve23 = iterator[kLastResolve];
66440
+ if (resolve23 !== null) {
66367
66441
  iterator[kLastPromise] = null;
66368
66442
  iterator[kLastResolve] = null;
66369
66443
  iterator[kLastReject] = null;
66370
- resolve22(createIterResult(void 0, true));
66444
+ resolve23(createIterResult(void 0, true));
66371
66445
  }
66372
66446
  iterator[kEnded] = true;
66373
66447
  });
@@ -66382,7 +66456,7 @@ var require_async_iterator = __commonJS({
66382
66456
  var require_from2 = __commonJS({
66383
66457
  "../../node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
66384
66458
  "use strict";
66385
- function asyncGeneratorStep(gen, resolve22, reject, _next, _throw, key, arg) {
66459
+ function asyncGeneratorStep(gen, resolve23, reject, _next, _throw, key, arg) {
66386
66460
  try {
66387
66461
  var info = gen[key](arg);
66388
66462
  var value = info.value;
@@ -66391,7 +66465,7 @@ var require_from2 = __commonJS({
66391
66465
  return;
66392
66466
  }
66393
66467
  if (info.done) {
66394
- resolve22(value);
66468
+ resolve23(value);
66395
66469
  } else {
66396
66470
  Promise.resolve(value).then(_next, _throw);
66397
66471
  }
@@ -66399,13 +66473,13 @@ var require_from2 = __commonJS({
66399
66473
  function _asyncToGenerator(fn) {
66400
66474
  return function() {
66401
66475
  var self2 = this, args = arguments;
66402
- return new Promise(function(resolve22, reject) {
66476
+ return new Promise(function(resolve23, reject) {
66403
66477
  var gen = fn.apply(self2, args);
66404
66478
  function _next(value) {
66405
- asyncGeneratorStep(gen, resolve22, reject, _next, _throw, "next", value);
66479
+ asyncGeneratorStep(gen, resolve23, reject, _next, _throw, "next", value);
66406
66480
  }
66407
66481
  function _throw(err) {
66408
- asyncGeneratorStep(gen, resolve22, reject, _next, _throw, "throw", err);
66482
+ asyncGeneratorStep(gen, resolve23, reject, _next, _throw, "throw", err);
66409
66483
  }
66410
66484
  _next(void 0);
66411
66485
  });
@@ -68344,9 +68418,9 @@ var init_base = __esm({
68344
68418
  * @return {Promise}
68345
68419
  */
68346
68420
  run() {
68347
- return new Promise((resolve22, reject) => {
68421
+ return new Promise((resolve23, reject) => {
68348
68422
  this._run(
68349
- (value) => resolve22(value),
68423
+ (value) => resolve23(value),
68350
68424
  (error48) => reject(error48)
68351
68425
  );
68352
68426
  });
@@ -74978,7 +75052,7 @@ var require_lib = __commonJS({
74978
75052
  return matches;
74979
75053
  };
74980
75054
  exports2.analyse = analyse;
74981
- var detectFile = (filepath, opts = {}) => new Promise((resolve22, reject) => {
75055
+ var detectFile = (filepath, opts = {}) => new Promise((resolve23, reject) => {
74982
75056
  let fd;
74983
75057
  const fs24 = (0, node_1.default)();
74984
75058
  const handler = (err, buffer) => {
@@ -74988,7 +75062,7 @@ var require_lib = __commonJS({
74988
75062
  if (err) {
74989
75063
  reject(err);
74990
75064
  } else if (buffer) {
74991
- resolve22((0, exports2.detect)(buffer));
75065
+ resolve23((0, exports2.detect)(buffer));
74992
75066
  } else {
74993
75067
  reject(new Error("No error and no buffer received"));
74994
75068
  }
@@ -78916,14 +78990,14 @@ function splitStringBySpace(str) {
78916
78990
  }
78917
78991
  return pieces;
78918
78992
  }
78919
- var import_chardet, import_child_process12, import_fs7, import_node_path2, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
78993
+ var import_chardet, import_child_process12, import_fs7, import_node_path3, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
78920
78994
  var init_esm2 = __esm({
78921
78995
  "../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
78922
78996
  "use strict";
78923
78997
  import_chardet = __toESM(require_lib(), 1);
78924
78998
  import_child_process12 = require("child_process");
78925
78999
  import_fs7 = require("fs");
78926
- import_node_path2 = __toESM(require("path"), 1);
79000
+ import_node_path3 = __toESM(require("path"), 1);
78927
79001
  import_node_os4 = __toESM(require("os"), 1);
78928
79002
  import_node_crypto2 = require("crypto");
78929
79003
  import_iconv_lite = __toESM(require_lib2(), 1);
@@ -78988,8 +79062,8 @@ var init_esm2 = __esm({
78988
79062
  const prefix = sanitizeAffix(this.fileOptions.prefix);
78989
79063
  const postfix = sanitizeAffix(this.fileOptions.postfix);
78990
79064
  const filename = `${prefix}${id}${postfix}`;
78991
- const candidate = import_node_path2.default.resolve(baseDir, filename);
78992
- const baseResolved = import_node_path2.default.resolve(baseDir) + import_node_path2.default.sep;
79065
+ const candidate = import_node_path3.default.resolve(baseDir, filename);
79066
+ const baseResolved = import_node_path3.default.resolve(baseDir) + import_node_path3.default.sep;
78993
79067
  if (!candidate.startsWith(baseResolved)) {
78994
79068
  throw new Error("Resolved temporary file escaped the base directory");
78995
79069
  }
@@ -80723,9 +80797,9 @@ function resolvePackageVersion(options) {
80723
80797
  const injectedVersion = options?.injectedVersion || "unknown";
80724
80798
  const dir = options?.dirname || __dirname;
80725
80799
  const possiblePaths = [
80726
- (0, import_path5.join)(dir, "..", "..", "package.json"),
80727
- (0, import_path5.join)(dir, "..", "package.json"),
80728
- (0, import_path5.join)(dir, "package.json")
80800
+ (0, import_path4.join)(dir, "..", "..", "package.json"),
80801
+ (0, import_path4.join)(dir, "..", "package.json"),
80802
+ (0, import_path4.join)(dir, "package.json")
80729
80803
  ];
80730
80804
  for (const p of possiblePaths) {
80731
80805
  try {
@@ -80736,12 +80810,12 @@ function resolvePackageVersion(options) {
80736
80810
  }
80737
80811
  return injectedVersion;
80738
80812
  }
80739
- var import_fs8, import_path5;
80813
+ var import_fs8, import_path4;
80740
80814
  var init_version = __esm({
80741
80815
  "src/version.ts"() {
80742
80816
  "use strict";
80743
80817
  import_fs8 = require("fs");
80744
- import_path5 = require("path");
80818
+ import_path4 = require("path");
80745
80819
  }
80746
80820
  });
80747
80821
 
@@ -80858,7 +80932,7 @@ var init_server_connection = __esm({
80858
80932
  * Returns the command result or throws on timeout / auth failure.
80859
80933
  */
80860
80934
  sendMeshCommand(targetDaemonId, command, args = {}, timeoutMs = 3e4) {
80861
- return new Promise((resolve22, reject) => {
80935
+ return new Promise((resolve23, reject) => {
80862
80936
  const requestId = `mesh_${crypto.randomUUID()}`;
80863
80937
  const timer = setTimeout(() => {
80864
80938
  this.off("daemon_mesh_result", handler);
@@ -80871,7 +80945,7 @@ var init_server_connection = __esm({
80871
80945
  if (msg.payload?.success === false) {
80872
80946
  reject(new Error(msg.payload?.error ?? "Mesh command failed"));
80873
80947
  } else {
80874
- resolve22(msg.payload?.result);
80948
+ resolve23(msg.payload?.result);
80875
80949
  }
80876
80950
  };
80877
80951
  this.on("daemon_mesh_result", handler);
@@ -82178,19 +82252,19 @@ var init_peer_connection_manager = __esm({
82178
82252
  });
82179
82253
 
82180
82254
  // src/daemon-p2p/index.ts
82181
- var fs16, path29, import_node_module2, esmRequire, DaemonP2PSender;
82255
+ var fs16, path29, import_node_module3, esmRequire, DaemonP2PSender;
82182
82256
  var init_daemon_p2p = __esm({
82183
82257
  "src/daemon-p2p/index.ts"() {
82184
82258
  "use strict";
82185
82259
  fs16 = __toESM(require("fs"));
82186
82260
  path29 = __toESM(require("path"));
82187
- import_node_module2 = require("module");
82261
+ import_node_module3 = require("module");
82188
82262
  init_src();
82189
82263
  init_data_channel_router();
82190
82264
  init_screenshot_sender();
82191
82265
  init_peer_connection_manager();
82192
82266
  init_log();
82193
- esmRequire = (0, import_node_module2.createRequire)(__filename);
82267
+ esmRequire = (0, import_node_module3.createRequire)(__filename);
82194
82268
  DaemonP2PSender = class {
82195
82269
  serverConn;
82196
82270
  peers = /* @__PURE__ */ new Map();
@@ -82667,14 +82741,14 @@ var require_filesystem = __commonJS({
82667
82741
  });
82668
82742
  return buffer.subarray(0, bytesRead);
82669
82743
  };
82670
- var readFile2 = (path40) => new Promise((resolve22, reject) => {
82744
+ var readFile2 = (path40) => new Promise((resolve23, reject) => {
82671
82745
  fs24.open(path40, "r", (err, fd) => {
82672
82746
  if (err) {
82673
82747
  reject(err);
82674
82748
  } else {
82675
82749
  const buffer = Buffer.alloc(MAX_LENGTH);
82676
82750
  fs24.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
82677
- resolve22(buffer.subarray(0, bytesRead));
82751
+ resolve23(buffer.subarray(0, bytesRead));
82678
82752
  fs24.close(fd, () => {
82679
82753
  });
82680
82754
  });
@@ -82742,10 +82816,10 @@ var require_detect_libc = __commonJS({
82742
82816
  var commandOut = "";
82743
82817
  var safeCommand = () => {
82744
82818
  if (!commandOut) {
82745
- return new Promise((resolve22) => {
82819
+ return new Promise((resolve23) => {
82746
82820
  childProcess.exec(command, (err, out) => {
82747
82821
  commandOut = err ? " " : out;
82748
- resolve22(commandOut);
82822
+ resolve23(commandOut);
82749
82823
  });
82750
82824
  });
82751
82825
  }
@@ -85425,14 +85499,14 @@ var require_input = __commonJS({
85425
85499
  return this;
85426
85500
  } else {
85427
85501
  if (this._isStreamInput()) {
85428
- return new Promise((resolve22, reject) => {
85502
+ return new Promise((resolve23, reject) => {
85429
85503
  const finished = () => {
85430
85504
  this._flattenBufferIn();
85431
85505
  sharp.metadata(this.options, (err, metadata2) => {
85432
85506
  if (err) {
85433
85507
  reject(is.nativeError(err, stack));
85434
85508
  } else {
85435
- resolve22(metadata2);
85509
+ resolve23(metadata2);
85436
85510
  }
85437
85511
  });
85438
85512
  };
@@ -85443,12 +85517,12 @@ var require_input = __commonJS({
85443
85517
  }
85444
85518
  });
85445
85519
  } else {
85446
- return new Promise((resolve22, reject) => {
85520
+ return new Promise((resolve23, reject) => {
85447
85521
  sharp.metadata(this.options, (err, metadata2) => {
85448
85522
  if (err) {
85449
85523
  reject(is.nativeError(err, stack));
85450
85524
  } else {
85451
- resolve22(metadata2);
85525
+ resolve23(metadata2);
85452
85526
  }
85453
85527
  });
85454
85528
  });
@@ -85481,25 +85555,25 @@ var require_input = __commonJS({
85481
85555
  return this;
85482
85556
  } else {
85483
85557
  if (this._isStreamInput()) {
85484
- return new Promise((resolve22, reject) => {
85558
+ return new Promise((resolve23, reject) => {
85485
85559
  this.on("finish", function() {
85486
85560
  this._flattenBufferIn();
85487
85561
  sharp.stats(this.options, (err, stats2) => {
85488
85562
  if (err) {
85489
85563
  reject(is.nativeError(err, stack));
85490
85564
  } else {
85491
- resolve22(stats2);
85565
+ resolve23(stats2);
85492
85566
  }
85493
85567
  });
85494
85568
  });
85495
85569
  });
85496
85570
  } else {
85497
- return new Promise((resolve22, reject) => {
85571
+ return new Promise((resolve23, reject) => {
85498
85572
  sharp.stats(this.options, (err, stats2) => {
85499
85573
  if (err) {
85500
85574
  reject(is.nativeError(err, stack));
85501
85575
  } else {
85502
- resolve22(stats2);
85576
+ resolve23(stats2);
85503
85577
  }
85504
85578
  });
85505
85579
  });
@@ -88921,7 +88995,7 @@ var require_output = __commonJS({
88921
88995
  return this;
88922
88996
  } else {
88923
88997
  if (this._isStreamInput()) {
88924
- return new Promise((resolve22, reject) => {
88998
+ return new Promise((resolve23, reject) => {
88925
88999
  this.once("finish", () => {
88926
89000
  this._flattenBufferIn();
88927
89001
  sharp.pipeline(this.options, (err, data, info) => {
@@ -88929,24 +89003,24 @@ var require_output = __commonJS({
88929
89003
  reject(is.nativeError(err, stack));
88930
89004
  } else {
88931
89005
  if (this.options.resolveWithObject) {
88932
- resolve22({ data, info });
89006
+ resolve23({ data, info });
88933
89007
  } else {
88934
- resolve22(data);
89008
+ resolve23(data);
88935
89009
  }
88936
89010
  }
88937
89011
  });
88938
89012
  });
88939
89013
  });
88940
89014
  } else {
88941
- return new Promise((resolve22, reject) => {
89015
+ return new Promise((resolve23, reject) => {
88942
89016
  sharp.pipeline(this.options, (err, data, info) => {
88943
89017
  if (err) {
88944
89018
  reject(is.nativeError(err, stack));
88945
89019
  } else {
88946
89020
  if (this.options.resolveWithObject) {
88947
- resolve22({ data, info });
89021
+ resolve23({ data, info });
88948
89022
  } else {
88949
- resolve22(data);
89023
+ resolve23(data);
88950
89024
  }
88951
89025
  }
88952
89026
  });
@@ -90178,7 +90252,7 @@ var init_adhdev_daemon = __esm({
90178
90252
  init_version();
90179
90253
  init_src();
90180
90254
  init_runtime_defaults();
90181
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.71" });
90255
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.73" });
90182
90256
  AdhdevDaemon = class _AdhdevDaemon {
90183
90257
  localHttpServer = null;
90184
90258
  localWss = null;
@@ -90994,7 +91068,7 @@ ${err?.stack || ""}`);
90994
91068
  try {
90995
91069
  const statusResult = await Promise.race([
90996
91070
  this.components.router.execute("git_status", { workspace }, "mesh"),
90997
- new Promise((resolve22) => setTimeout(() => resolve22(null), 4e3))
91071
+ new Promise((resolve23) => setTimeout(() => resolve23(null), 4e3))
90998
91072
  ]);
90999
91073
  const s = statusResult?.status ?? statusResult;
91000
91074
  if (s?.isGitRepo) {
@@ -91177,7 +91251,7 @@ ${err?.stack || ""}`);
91177
91251
  this.localWss.emit("connection", ws, req);
91178
91252
  });
91179
91253
  });
91180
- await new Promise((resolve22, reject) => {
91254
+ await new Promise((resolve23, reject) => {
91181
91255
  const cleanup = () => {
91182
91256
  this.localHttpServer?.off("error", onError);
91183
91257
  this.localHttpServer?.off("listening", onListening);
@@ -91188,7 +91262,7 @@ ${err?.stack || ""}`);
91188
91262
  };
91189
91263
  const onListening = () => {
91190
91264
  cleanup();
91191
- resolve22();
91265
+ resolve23();
91192
91266
  };
91193
91267
  this.localHttpServer.once("error", onError);
91194
91268
  this.localHttpServer.once("listening", onListening);
@@ -91362,12 +91436,12 @@ ${err?.stack || ""}`);
91362
91436
  this.localClients.clear();
91363
91437
  this.localWss?.close();
91364
91438
  this.localWss = null;
91365
- await new Promise((resolve22) => {
91439
+ await new Promise((resolve23) => {
91366
91440
  if (!this.localHttpServer) {
91367
- resolve22();
91441
+ resolve23();
91368
91442
  return;
91369
91443
  }
91370
- this.localHttpServer.close(() => resolve22());
91444
+ this.localHttpServer.close(() => resolve23());
91371
91445
  this.localHttpServer = null;
91372
91446
  });
91373
91447
  } catch {
@@ -92822,7 +92896,7 @@ init_source();
92822
92896
  init_src();
92823
92897
 
92824
92898
  // src/cli/setup-commands.ts
92825
- var import_node_path3 = __toESM(require("path"));
92899
+ var import_node_path4 = __toESM(require("path"));
92826
92900
  init_source();
92827
92901
  init_src();
92828
92902
 
@@ -92975,7 +93049,7 @@ function parsePositiveInteger(value, fallback2) {
92975
93049
  return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback2;
92976
93050
  }
92977
93051
  function buildHistoryResumeLaunchPayload(cliType, session, overrideDir) {
92978
- const dir = typeof overrideDir === "string" && overrideDir.trim() ? import_node_path3.default.resolve(overrideDir.trim()) : typeof session.workspace === "string" && session.workspace.trim() ? import_node_path3.default.resolve(session.workspace.trim()) : "";
93052
+ const dir = typeof overrideDir === "string" && overrideDir.trim() ? import_node_path4.default.resolve(overrideDir.trim()) : typeof session.workspace === "string" && session.workspace.trim() ? import_node_path4.default.resolve(session.workspace.trim()) : "";
92979
93053
  if (!dir) {
92980
93054
  throw new Error(`Saved history ${session.providerSessionId} is missing workspace metadata. Pass --dir to resume it explicitly.`);
92981
93055
  }
@@ -93095,7 +93169,7 @@ function registerSetupCommands(program2, getProviderLoader2) {
93095
93169
  console.log(source_default.gray(" Then run: adhdev launch " + targetArg));
93096
93170
  process.exit(1);
93097
93171
  }
93098
- const resolvedDir = import_node_path3.default.resolve(workingDir);
93172
+ const resolvedDir = import_node_path4.default.resolve(workingDir);
93099
93173
  const result = await sendDaemonCommand("launch_cli", {
93100
93174
  cliType,
93101
93175
  dir: resolvedDir
@@ -93852,14 +93926,14 @@ async function requestSessionHostDirect(request) {
93852
93926
  }
93853
93927
  async function runRuntimeLaunchSpec(spec) {
93854
93928
  const { spawn: spawn7 } = await import("child_process");
93855
- return await new Promise((resolve22, reject) => {
93929
+ return await new Promise((resolve23, reject) => {
93856
93930
  const child = spawn7(spec.command, spec.args, {
93857
93931
  stdio: "inherit",
93858
93932
  env: spec.env,
93859
93933
  shell: process.platform === "win32" && spec.command !== process.execPath
93860
93934
  });
93861
93935
  child.on("error", reject);
93862
- child.on("exit", (code) => resolve22(code ?? 0));
93936
+ child.on("exit", (code) => resolve23(code ?? 0));
93863
93937
  });
93864
93938
  }
93865
93939
  async function resolveRuntimeSessionId(target, options) {
@@ -94093,7 +94167,7 @@ async function handleTraceCommand(options) {
94093
94167
  }
94094
94168
  }
94095
94169
  while (!stopped) {
94096
- await new Promise((resolve22) => setTimeout(resolve22, intervalMs));
94170
+ await new Promise((resolve23) => setTimeout(resolve23, intervalMs));
94097
94171
  if (stopped) break;
94098
94172
  const nextTrace = await fetchTrace(buildDebugTraceFollowPollArgs(baseArgs, cursor));
94099
94173
  const nextBatch = collectFreshDebugTraceEntries(nextTrace, cursor);
@@ -94915,33 +94989,33 @@ function buildDoctorAdvice(input) {
94915
94989
  }
94916
94990
 
94917
94991
  // src/cli/service-commands.ts
94918
- var import_node_fs4 = __toESM(require("fs"));
94919
- var import_node_path4 = __toESM(require("path"));
94992
+ var import_node_fs5 = __toESM(require("fs"));
94993
+ var import_node_path5 = __toESM(require("path"));
94920
94994
  var import_node_os5 = __toESM(require("os"));
94921
94995
  var import_node_child_process2 = require("child_process");
94922
94996
  init_source();
94923
94997
  init_src();
94924
94998
  var DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS3 = 1500;
94925
94999
  var LAUNCHD_LABEL = "dev.adhf.daemon";
94926
- var ADHDEV_DIR = import_node_path4.default.join(import_node_os5.default.homedir(), ".adhdev");
94927
- var LOG_OUT = import_node_path4.default.join(ADHDEV_DIR, "daemon-launchd.out");
94928
- var LOG_ERR = import_node_path4.default.join(ADHDEV_DIR, "daemon-launchd.err");
95000
+ var ADHDEV_DIR = import_node_path5.default.join(import_node_os5.default.homedir(), ".adhdev");
95001
+ var LOG_OUT = import_node_path5.default.join(ADHDEV_DIR, "daemon-launchd.out");
95002
+ var LOG_ERR = import_node_path5.default.join(ADHDEV_DIR, "daemon-launchd.err");
94929
95003
  var MAX_LOG_SIZE2 = 10 * 1024 * 1024;
94930
95004
  function getDarwinPlistPath() {
94931
- return import_node_path4.default.join(import_node_os5.default.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
95005
+ return import_node_path5.default.join(import_node_os5.default.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
94932
95006
  }
94933
95007
  function getWindowsStartupDir() {
94934
- const appData = process.env.APPDATA || import_node_path4.default.join(import_node_os5.default.homedir(), "AppData", "Roaming");
94935
- return import_node_path4.default.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup");
95008
+ const appData = process.env.APPDATA || import_node_path5.default.join(import_node_os5.default.homedir(), "AppData", "Roaming");
95009
+ return import_node_path5.default.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup");
94936
95010
  }
94937
95011
  function getWindowsVbsPath() {
94938
- return import_node_path4.default.join(getWindowsStartupDir(), "adhdev-daemon.vbs");
95012
+ return import_node_path5.default.join(getWindowsStartupDir(), "adhdev-daemon.vbs");
94939
95013
  }
94940
95014
  function resolveCliPath() {
94941
- return import_node_fs4.default.realpathSync(process.argv[1]);
95015
+ return import_node_fs5.default.realpathSync(process.argv[1]);
94942
95016
  }
94943
95017
  function ensureDir(dir) {
94944
- if (!import_node_fs4.default.existsSync(dir)) import_node_fs4.default.mkdirSync(dir, { recursive: true });
95018
+ if (!import_node_fs5.default.existsSync(dir)) import_node_fs5.default.mkdirSync(dir, { recursive: true });
94945
95019
  }
94946
95020
  async function fetchHealth() {
94947
95021
  const controller = new AbortController();
@@ -94983,13 +95057,13 @@ function formatElapsed(etime) {
94983
95057
  }
94984
95058
  function rotateLogIfNeeded(logPath) {
94985
95059
  try {
94986
- if (!import_node_fs4.default.existsSync(logPath)) return;
94987
- const stat5 = import_node_fs4.default.statSync(logPath);
95060
+ if (!import_node_fs5.default.existsSync(logPath)) return;
95061
+ const stat5 = import_node_fs5.default.statSync(logPath);
94988
95062
  if (stat5.size > MAX_LOG_SIZE2) {
94989
95063
  const rotated = logPath + ".old";
94990
- if (import_node_fs4.default.existsSync(rotated)) import_node_fs4.default.unlinkSync(rotated);
94991
- import_node_fs4.default.renameSync(logPath, rotated);
94992
- import_node_fs4.default.writeFileSync(logPath, `[log rotated at ${(/* @__PURE__ */ new Date()).toISOString()}]
95064
+ if (import_node_fs5.default.existsSync(rotated)) import_node_fs5.default.unlinkSync(rotated);
95065
+ import_node_fs5.default.renameSync(logPath, rotated);
95066
+ import_node_fs5.default.writeFileSync(logPath, `[log rotated at ${(/* @__PURE__ */ new Date()).toISOString()}]
94993
95067
  `, "utf-8");
94994
95068
  }
94995
95069
  } catch {
@@ -95000,8 +95074,8 @@ function rotateLogs() {
95000
95074
  rotateLogIfNeeded(LOG_ERR);
95001
95075
  }
95002
95076
  function buildPlist(nodeExe, cliExe) {
95003
- const brewPrefix = import_node_fs4.default.existsSync("/opt/homebrew/bin") ? "/opt/homebrew/bin" : "/usr/local/bin";
95004
- const nodeDir = import_node_path4.default.dirname(nodeExe);
95077
+ const brewPrefix = import_node_fs5.default.existsSync("/opt/homebrew/bin") ? "/opt/homebrew/bin" : "/usr/local/bin";
95078
+ const nodeDir = import_node_path5.default.dirname(nodeExe);
95005
95079
  const pathEntries = /* @__PURE__ */ new Set([nodeDir, brewPrefix, "/usr/local/bin", "/usr/bin", "/bin", "/usr/sbin", "/sbin"]);
95006
95080
  const pathValue = Array.from(pathEntries).join(":");
95007
95081
  return `<?xml version="1.0" encoding="UTF-8"?>
@@ -95040,8 +95114,8 @@ function buildPlist(nodeExe, cliExe) {
95040
95114
  function installDarwin(nodeExe, cliExe) {
95041
95115
  const plistPath = getDarwinPlistPath();
95042
95116
  ensureDir(ADHDEV_DIR);
95043
- ensureDir(import_node_path4.default.dirname(plistPath));
95044
- import_node_fs4.default.writeFileSync(plistPath, buildPlist(nodeExe, cliExe), "utf-8");
95117
+ ensureDir(import_node_path5.default.dirname(plistPath));
95118
+ import_node_fs5.default.writeFileSync(plistPath, buildPlist(nodeExe, cliExe), "utf-8");
95045
95119
  console.log(source_default.gray(` Plist: ${plistPath}`));
95046
95120
  try {
95047
95121
  (0, import_node_child_process2.execSync)(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
@@ -95058,7 +95132,7 @@ function installDarwin(nodeExe, cliExe) {
95058
95132
  }
95059
95133
  function uninstallDarwin() {
95060
95134
  const plistPath = getDarwinPlistPath();
95061
- if (!import_node_fs4.default.existsSync(plistPath)) {
95135
+ if (!import_node_fs5.default.existsSync(plistPath)) {
95062
95136
  console.log(source_default.yellow("\n \u26A0 Service is not installed."));
95063
95137
  return;
95064
95138
  }
@@ -95066,14 +95140,14 @@ function uninstallDarwin() {
95066
95140
  (0, import_node_child_process2.execSync)(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
95067
95141
  } catch {
95068
95142
  }
95069
- import_node_fs4.default.unlinkSync(plistPath);
95143
+ import_node_fs5.default.unlinkSync(plistPath);
95070
95144
  console.log(source_default.green("\n \u2713 Removed LaunchAgent. Daemon will no longer auto-start."));
95071
95145
  }
95072
95146
  function isInstalledDarwin() {
95073
- return import_node_fs4.default.existsSync(getDarwinPlistPath());
95147
+ return import_node_fs5.default.existsSync(getDarwinPlistPath());
95074
95148
  }
95075
95149
  function buildVbs(nodeExe, cliExe) {
95076
- const logFile = import_node_path4.default.join(ADHDEV_DIR, "daemon-service.log").replace(/\\/g, "\\\\");
95150
+ const logFile = import_node_path5.default.join(ADHDEV_DIR, "daemon-service.log").replace(/\\/g, "\\\\");
95077
95151
  const escapedNodeExe = nodeExe.replace(/\\/g, "\\\\");
95078
95152
  const escapedCliExe = cliExe.replace(/\\/g, "\\\\");
95079
95153
  return `' ADHDev Daemon Auto-Start (generated by adhdev service install)
@@ -95084,25 +95158,25 @@ WshShell.Run "cmd.exe /c """"${escapedNodeExe}"""" """"${escapedCliExe}"""" daem
95084
95158
  function installWindows(nodeExe, cliExe) {
95085
95159
  const vbsPath = getWindowsVbsPath();
95086
95160
  ensureDir(ADHDEV_DIR);
95087
- ensureDir(import_node_path4.default.dirname(vbsPath));
95088
- import_node_fs4.default.writeFileSync(vbsPath, buildVbs(nodeExe, cliExe), "utf-8");
95161
+ ensureDir(import_node_path5.default.dirname(vbsPath));
95162
+ import_node_fs5.default.writeFileSync(vbsPath, buildVbs(nodeExe, cliExe), "utf-8");
95089
95163
  console.log(source_default.gray(` Startup script: ${vbsPath}`));
95090
95164
  console.log(source_default.green("\n \u2713 Registered in Startup folder \u2014 daemon will start on login (hidden)."));
95091
- console.log(source_default.gray(` Logs: ${import_node_path4.default.join(ADHDEV_DIR, "daemon-service.log")}`));
95165
+ console.log(source_default.gray(` Logs: ${import_node_path5.default.join(ADHDEV_DIR, "daemon-service.log")}`));
95092
95166
  console.log(source_default.gray(" To start now without rebooting, run: adhdev daemon"));
95093
95167
  }
95094
95168
  function uninstallWindows() {
95095
95169
  const vbsPath = getWindowsVbsPath();
95096
- if (!import_node_fs4.default.existsSync(vbsPath)) {
95170
+ if (!import_node_fs5.default.existsSync(vbsPath)) {
95097
95171
  console.log(source_default.yellow("\n \u26A0 Service is not installed."));
95098
95172
  return;
95099
95173
  }
95100
- import_node_fs4.default.unlinkSync(vbsPath);
95174
+ import_node_fs5.default.unlinkSync(vbsPath);
95101
95175
  console.log(source_default.green("\n \u2713 Removed Startup script. Daemon will no longer auto-start."));
95102
95176
  console.log(source_default.gray(" Note: a currently running daemon is not affected. Stop with: adhdev daemon:stop"));
95103
95177
  }
95104
95178
  function isInstalledWindows() {
95105
- return import_node_fs4.default.existsSync(getWindowsVbsPath());
95179
+ return import_node_fs5.default.existsSync(getWindowsVbsPath());
95106
95180
  }
95107
95181
  function registerServiceCommands(program2) {
95108
95182
  const svc = program2.command("service").description("\u{1F50C} Manage ADHDev as an OS background auto-start service");
@@ -95158,8 +95232,8 @@ function registerServiceCommands(program2) {
95158
95232
  } else {
95159
95233
  console.log(source_default.yellow(" \u2717 Daemon is not running."));
95160
95234
  }
95161
- const outSize = import_node_fs4.default.existsSync(LOG_OUT) ? import_node_fs4.default.statSync(LOG_OUT).size : 0;
95162
- const errSize = import_node_fs4.default.existsSync(LOG_ERR) ? import_node_fs4.default.statSync(LOG_ERR).size : 0;
95235
+ const outSize = import_node_fs5.default.existsSync(LOG_OUT) ? import_node_fs5.default.statSync(LOG_OUT).size : 0;
95236
+ const errSize = import_node_fs5.default.existsSync(LOG_ERR) ? import_node_fs5.default.statSync(LOG_ERR).size : 0;
95163
95237
  if (outSize > 0 || errSize > 0) {
95164
95238
  console.log(source_default.gray(` Logs: stdout ${formatBytes(outSize)}, stderr ${formatBytes(errSize)}`));
95165
95239
  }
@@ -95168,13 +95242,13 @@ function registerServiceCommands(program2) {
95168
95242
  svc.command("logs").description("View daemon service logs").option("--err", "Show stderr log instead of stdout").option("--clear", "Truncate all log files").option("-n, --lines <count>", "Number of lines to show", "30").action(async (options) => {
95169
95243
  if (options.clear) {
95170
95244
  for (const f of [LOG_OUT, LOG_ERR]) {
95171
- if (import_node_fs4.default.existsSync(f)) import_node_fs4.default.writeFileSync(f, "", "utf-8");
95245
+ if (import_node_fs5.default.existsSync(f)) import_node_fs5.default.writeFileSync(f, "", "utf-8");
95172
95246
  }
95173
95247
  console.log(source_default.green("\n \u2713 Logs cleared.\n"));
95174
95248
  return;
95175
95249
  }
95176
95250
  const logFile = options.err ? LOG_ERR : LOG_OUT;
95177
- if (!import_node_fs4.default.existsSync(logFile)) {
95251
+ if (!import_node_fs5.default.existsSync(logFile)) {
95178
95252
  console.log(source_default.gray(`
95179
95253
  No log file found: ${logFile}
95180
95254
  `));
@@ -95184,20 +95258,20 @@ function registerServiceCommands(program2) {
95184
95258
  console.log(source_default.gray(`
95185
95259
  \u2500\u2500 ${options.err ? "stderr" : "stdout"}: ${logFile} (last ${lines} lines) \u2500\u2500
95186
95260
  `));
95187
- const content = import_node_fs4.default.readFileSync(logFile, "utf-8");
95261
+ const content = import_node_fs5.default.readFileSync(logFile, "utf-8");
95188
95262
  const allLines = content.split("\n");
95189
95263
  const lastLines = allLines.slice(-lines).join("\n");
95190
95264
  if (lastLines.trim()) console.log(lastLines);
95191
95265
  console.log(source_default.gray("\n (watching for new output, Ctrl+C to stop)\n"));
95192
95266
  let offset = Buffer.byteLength(content, "utf-8");
95193
- const watcher = import_node_fs4.default.watchFile(logFile, { interval: 500 }, () => {
95267
+ const watcher = import_node_fs5.default.watchFile(logFile, { interval: 500 }, () => {
95194
95268
  try {
95195
- const stat5 = import_node_fs4.default.statSync(logFile);
95269
+ const stat5 = import_node_fs5.default.statSync(logFile);
95196
95270
  if (stat5.size > offset) {
95197
- const fd = import_node_fs4.default.openSync(logFile, "r");
95271
+ const fd = import_node_fs5.default.openSync(logFile, "r");
95198
95272
  const buf = Buffer.alloc(stat5.size - offset);
95199
- import_node_fs4.default.readSync(fd, buf, 0, buf.length, offset);
95200
- import_node_fs4.default.closeSync(fd);
95273
+ import_node_fs5.default.readSync(fd, buf, 0, buf.length, offset);
95274
+ import_node_fs5.default.closeSync(fd);
95201
95275
  process.stdout.write(buf.toString("utf-8"));
95202
95276
  offset = stat5.size;
95203
95277
  } else if (stat5.size < offset) {
@@ -95207,7 +95281,7 @@ function registerServiceCommands(program2) {
95207
95281
  }
95208
95282
  });
95209
95283
  const cleanup = () => {
95210
- import_node_fs4.default.unwatchFile(logFile);
95284
+ import_node_fs5.default.unwatchFile(logFile);
95211
95285
  process.exit(0);
95212
95286
  };
95213
95287
  process.on("SIGINT", cleanup);
@@ -95248,7 +95322,7 @@ function registerServiceCommands(program2) {
95248
95322
  await new Promise((r) => setTimeout(r, 2e3));
95249
95323
  if (platform12 === "win32") {
95250
95324
  const vbsPath = getWindowsVbsPath();
95251
- if (import_node_fs4.default.existsSync(vbsPath)) {
95325
+ if (import_node_fs5.default.existsSync(vbsPath)) {
95252
95326
  try {
95253
95327
  (0, import_node_child_process2.execSync)(`wscript.exe "${vbsPath}"`, { stdio: "ignore", windowsHide: true });
95254
95328
  } catch {
@@ -95859,7 +95933,7 @@ function registerProviderCommands(program2) {
95859
95933
  } catch {
95860
95934
  try {
95861
95935
  const http3 = await import("http");
95862
- const result = await new Promise((resolve22, reject) => {
95936
+ const result = await new Promise((resolve23, reject) => {
95863
95937
  const req = http3.request({
95864
95938
  hostname: "127.0.0.1",
95865
95939
  port: DEV_SERVER_PORT3,
@@ -95871,9 +95945,9 @@ function registerProviderCommands(program2) {
95871
95945
  res.on("data", (c) => data += c);
95872
95946
  res.on("end", () => {
95873
95947
  try {
95874
- resolve22(JSON.parse(data));
95948
+ resolve23(JSON.parse(data));
95875
95949
  } catch {
95876
- resolve22({ raw: data });
95950
+ resolve23({ raw: data });
95877
95951
  }
95878
95952
  });
95879
95953
  });
@@ -95975,12 +96049,12 @@ function registerProviderCommands(program2) {
95975
96049
  console.log(source_default.yellow("Invalid port number."));
95976
96050
  continue;
95977
96051
  }
95978
- const isFree = await new Promise((resolve22) => {
96052
+ const isFree = await new Promise((resolve23) => {
95979
96053
  const server = net3.createServer();
95980
96054
  server.unref();
95981
- server.on("error", () => resolve22(false));
96055
+ server.on("error", () => resolve23(false));
95982
96056
  server.listen(port, "127.0.0.1", () => {
95983
- server.close(() => resolve22(true));
96057
+ server.close(() => resolve23(true));
95984
96058
  });
95985
96059
  });
95986
96060
  if (!isFree) {
@@ -95995,7 +96069,7 @@ function registerProviderCommands(program2) {
95995
96069
  rl.close();
95996
96070
  const location = options.builtin ? "builtin" : "user";
95997
96071
  const http3 = await import("http");
95998
- const result = await new Promise((resolve22, reject) => {
96072
+ const result = await new Promise((resolve23, reject) => {
95999
96073
  const postData = JSON.stringify({ type, name, category, location, cdpPorts, osPaths, processNames });
96000
96074
  const req = http3.request({
96001
96075
  hostname: "127.0.0.1",
@@ -96008,9 +96082,9 @@ function registerProviderCommands(program2) {
96008
96082
  res.on("data", (c) => data += c);
96009
96083
  res.on("end", () => {
96010
96084
  try {
96011
- resolve22(JSON.parse(data));
96085
+ resolve23(JSON.parse(data));
96012
96086
  } catch {
96013
- resolve22({ raw: data });
96087
+ resolve23({ raw: data });
96014
96088
  }
96015
96089
  });
96016
96090
  });
@@ -96209,7 +96283,7 @@ function registerProviderCommands(program2) {
96209
96283
  reference,
96210
96284
  ...verification ? { verification } : {}
96211
96285
  });
96212
- const startResult = await new Promise((resolve22, reject) => {
96286
+ const startResult = await new Promise((resolve23, reject) => {
96213
96287
  const req = http3.request({
96214
96288
  hostname: "127.0.0.1",
96215
96289
  port: DEV_SERVER_PORT3,
@@ -96221,9 +96295,9 @@ function registerProviderCommands(program2) {
96221
96295
  res.on("data", (c) => data += c);
96222
96296
  res.on("end", () => {
96223
96297
  try {
96224
- resolve22(JSON.parse(data));
96298
+ resolve23(JSON.parse(data));
96225
96299
  } catch {
96226
- resolve22({ raw: data });
96300
+ resolve23({ raw: data });
96227
96301
  }
96228
96302
  });
96229
96303
  });
@@ -96257,7 +96331,7 @@ function registerProviderCommands(program2) {
96257
96331
  fsMock.writeFileSync(logFile, `=== Auto-Impl Started ===
96258
96332
  `);
96259
96333
  console.log(source_default.gray(` Agent logs: ${logFile}`));
96260
- await new Promise((resolve22, reject) => {
96334
+ await new Promise((resolve23, reject) => {
96261
96335
  http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}${startResult.sseUrl}`, (res) => {
96262
96336
  let buffer = "";
96263
96337
  res.on("data", (chunk) => {
@@ -96294,7 +96368,7 @@ function registerProviderCommands(program2) {
96294
96368
  if (currentData.success === false) {
96295
96369
  reject(new Error(`Agent failed to implement scripts properly (exit: ${currentData.exitCode})`));
96296
96370
  } else {
96297
- resolve22();
96371
+ resolve23();
96298
96372
  }
96299
96373
  } else if (currentEvent === "error") {
96300
96374
  fsMock.appendFileSync(logFile, `
@@ -96305,7 +96379,7 @@ function registerProviderCommands(program2) {
96305
96379
  }
96306
96380
  }
96307
96381
  });
96308
- res.on("end", resolve22);
96382
+ res.on("end", resolve23);
96309
96383
  }).on("error", reject);
96310
96384
  });
96311
96385
  console.log(source_default.green(`
@@ -96364,7 +96438,7 @@ function registerProviderCommands(program2) {
96364
96438
  ideType: type,
96365
96439
  params: options.param ? { text: options.param, sessionId: options.param, buttonText: options.param } : {}
96366
96440
  });
96367
- const result = await new Promise((resolve22, reject) => {
96441
+ const result = await new Promise((resolve23, reject) => {
96368
96442
  const req = http3.request({
96369
96443
  hostname: "127.0.0.1",
96370
96444
  port: DEV_SERVER_PORT3,
@@ -96376,9 +96450,9 @@ function registerProviderCommands(program2) {
96376
96450
  res.on("data", (c) => data += c);
96377
96451
  res.on("end", () => {
96378
96452
  try {
96379
- resolve22(JSON.parse(data));
96453
+ resolve23(JSON.parse(data));
96380
96454
  } catch {
96381
- resolve22({ raw: data });
96455
+ resolve23({ raw: data });
96382
96456
  }
96383
96457
  });
96384
96458
  });
@@ -96414,15 +96488,15 @@ function registerProviderCommands(program2) {
96414
96488
  provider.command("source <type>").description("View source code of a provider").action(async (type) => {
96415
96489
  try {
96416
96490
  const http3 = await import("http");
96417
- const result = await new Promise((resolve22, reject) => {
96491
+ const result = await new Promise((resolve23, reject) => {
96418
96492
  http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}/api/providers/${type}/source`, (res) => {
96419
96493
  let data = "";
96420
96494
  res.on("data", (c) => data += c);
96421
96495
  res.on("end", () => {
96422
96496
  try {
96423
- resolve22(JSON.parse(data));
96497
+ resolve23(JSON.parse(data));
96424
96498
  } catch {
96425
- resolve22({ raw: data });
96499
+ resolve23({ raw: data });
96426
96500
  }
96427
96501
  });
96428
96502
  }).on("error", () => {
@@ -96470,7 +96544,7 @@ function registerProviderCommands(program2) {
96470
96544
  try {
96471
96545
  const http3 = await import("http");
96472
96546
  const postData = JSON.stringify({ script: "readChat", params: {} });
96473
- const result = await new Promise((resolve22, reject) => {
96547
+ const result = await new Promise((resolve23, reject) => {
96474
96548
  const req = http3.request({
96475
96549
  hostname: "127.0.0.1",
96476
96550
  port: DEV_SERVER_PORT3,
@@ -96482,9 +96556,9 @@ function registerProviderCommands(program2) {
96482
96556
  res2.on("data", (c) => data += c);
96483
96557
  res2.on("end", () => {
96484
96558
  try {
96485
- resolve22(JSON.parse(data));
96559
+ resolve23(JSON.parse(data));
96486
96560
  } catch {
96487
- resolve22({ raw: data });
96561
+ resolve23({ raw: data });
96488
96562
  }
96489
96563
  });
96490
96564
  });
@@ -96725,13 +96799,13 @@ function registerCdpCommands(program2) {
96725
96799
  cdp.command("screenshot").description("Capture IDE screenshot").option("-p, --port <port>", "CDP port", "9222").option("-o, --output <file>", "Output file path", "/tmp/cdp_screenshot.jpg").action(async (options) => {
96726
96800
  try {
96727
96801
  const http3 = await import("http");
96728
- const targets = await new Promise((resolve22, reject) => {
96802
+ const targets = await new Promise((resolve23, reject) => {
96729
96803
  http3.get(`http://127.0.0.1:${options.port}/json`, (res) => {
96730
96804
  let data = "";
96731
96805
  res.on("data", (c) => data += c);
96732
96806
  res.on("end", () => {
96733
96807
  try {
96734
- resolve22(JSON.parse(data));
96808
+ resolve23(JSON.parse(data));
96735
96809
  } catch {
96736
96810
  reject(new Error("Invalid JSON"));
96737
96811
  }
@@ -96745,7 +96819,7 @@ function registerCdpCommands(program2) {
96745
96819
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target");
96746
96820
  const WebSocket4 = (await import("ws")).default;
96747
96821
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
96748
- await new Promise((resolve22, reject) => {
96822
+ await new Promise((resolve23, reject) => {
96749
96823
  ws.on("open", () => {
96750
96824
  ws.send(JSON.stringify({ id: 1, method: "Page.captureScreenshot", params: { format: "jpeg", quality: 50 } }));
96751
96825
  });
@@ -96758,7 +96832,7 @@ function registerCdpCommands(program2) {
96758
96832
  \u2713 Screenshot saved to ${options.output}
96759
96833
  `));
96760
96834
  ws.close();
96761
- resolve22();
96835
+ resolve23();
96762
96836
  }
96763
96837
  });
96764
96838
  ws.on("error", (e) => reject(e));
@@ -96775,7 +96849,7 @@ function registerCdpCommands(program2) {
96775
96849
  // src/cli/mcp-commands.ts
96776
96850
  var import_node_child_process3 = require("child_process");
96777
96851
  var fs23 = __toESM(require("fs"));
96778
- var import_node_module3 = require("module");
96852
+ var import_node_module4 = require("module");
96779
96853
  var path39 = __toESM(require("path"));
96780
96854
  init_source();
96781
96855
  function registerMcpCommands(program2) {
@@ -96835,7 +96909,7 @@ function resolveMcpBin() {
96835
96909
  }
96836
96910
  }
96837
96911
  try {
96838
- const req = (0, import_node_module3.createRequire)(__filename);
96912
+ const req = (0, import_node_module4.createRequire)(__filename);
96839
96913
  return req.resolve("@adhdev/mcp-server");
96840
96914
  } catch {
96841
96915
  return null;