adhdev 0.9.71 → 0.9.72

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
  }
@@ -41580,9 +41641,9 @@ var init_router = __esm({
41580
41641
  workspace
41581
41642
  };
41582
41643
  }
41583
- const { existsSync: existsSync28, readFileSync: readFileSync21, writeFileSync: writeFileSync15, copyFileSync: copyFileSync4 } = await import("fs");
41644
+ const { existsSync: existsSync29, readFileSync: readFileSync21, writeFileSync: writeFileSync15, copyFileSync: copyFileSync4 } = await import("fs");
41584
41645
  const mcpConfigPath = coordinatorSetup.configPath;
41585
- const hadExistingMcpConfig = existsSync28(mcpConfigPath);
41646
+ const hadExistingMcpConfig = existsSync29(mcpConfigPath);
41586
41647
  let existingMcpConfig = {};
41587
41648
  if (hadExistingMcpConfig) {
41588
41649
  try {
@@ -41596,8 +41657,8 @@ var init_router = __esm({
41596
41657
  mcpServers: {
41597
41658
  ...existingMcpConfig.mcpServers || {},
41598
41659
  [coordinatorSetup.serverName]: {
41599
- command: "adhdev-mcp",
41600
- args: ["--repo-mesh", meshId]
41660
+ command: coordinatorSetup.mcpServer.command,
41661
+ args: coordinatorSetup.mcpServer.args
41601
41662
  }
41602
41663
  }
41603
41664
  };
@@ -42283,7 +42344,7 @@ var init_provider_adapter = __esm({
42283
42344
  const beforeCount = this.messageCount(before);
42284
42345
  const beforeSignature = this.lastMessageSignature(before);
42285
42346
  for (let attempt = 0; attempt < 12; attempt += 1) {
42286
- await new Promise((resolve22) => setTimeout(resolve22, 250));
42347
+ await new Promise((resolve23) => setTimeout(resolve23, 250));
42287
42348
  let state;
42288
42349
  try {
42289
42350
  state = await this.readChat(evaluate);
@@ -42305,7 +42366,7 @@ var init_provider_adapter = __esm({
42305
42366
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
42306
42367
  return first;
42307
42368
  }
42308
- await new Promise((resolve22) => setTimeout(resolve22, 150));
42369
+ await new Promise((resolve23) => setTimeout(resolve23, 150));
42309
42370
  const second = await this.readChat(evaluate);
42310
42371
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
42311
42372
  }
@@ -42456,7 +42517,7 @@ var init_provider_adapter = __esm({
42456
42517
  if (typeof data.error === "string" && data.error.trim()) return false;
42457
42518
  }
42458
42519
  for (let attempt = 0; attempt < 6; attempt += 1) {
42459
- await new Promise((resolve22) => setTimeout(resolve22, 250));
42520
+ await new Promise((resolve23) => setTimeout(resolve23, 250));
42460
42521
  const state = await this.readChat(evaluate);
42461
42522
  const title = this.getStateTitle(state);
42462
42523
  if (this.titlesMatch(title, sessionId)) return true;
@@ -45103,7 +45164,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
45103
45164
  return { target, instance, adapter };
45104
45165
  }
45105
45166
  function sleep(ms) {
45106
- return new Promise((resolve22) => setTimeout(resolve22, ms));
45167
+ return new Promise((resolve23) => setTimeout(resolve23, ms));
45107
45168
  }
45108
45169
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
45109
45170
  const startedAt = Date.now();
@@ -47383,15 +47444,15 @@ var init_dev_server = __esm({
47383
47444
  this.json(res, 500, { error: e.message });
47384
47445
  }
47385
47446
  });
47386
- return new Promise((resolve22, reject) => {
47447
+ return new Promise((resolve23, reject) => {
47387
47448
  this.server.listen(port, "127.0.0.1", () => {
47388
47449
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
47389
- resolve22();
47450
+ resolve23();
47390
47451
  });
47391
47452
  this.server.on("error", (e) => {
47392
47453
  if (e.code === "EADDRINUSE") {
47393
47454
  this.log(`Port ${port} in use, skipping dev server`);
47394
- resolve22();
47455
+ resolve23();
47395
47456
  } else {
47396
47457
  reject(e);
47397
47458
  }
@@ -47473,20 +47534,20 @@ var init_dev_server = __esm({
47473
47534
  child.stderr?.on("data", (d) => {
47474
47535
  stderr += d.toString().slice(0, 2e3);
47475
47536
  });
47476
- await new Promise((resolve22) => {
47537
+ await new Promise((resolve23) => {
47477
47538
  const timer = setTimeout(() => {
47478
47539
  child.kill();
47479
- resolve22();
47540
+ resolve23();
47480
47541
  }, 3e3);
47481
47542
  child.on("exit", () => {
47482
47543
  clearTimeout(timer);
47483
- resolve22();
47544
+ resolve23();
47484
47545
  });
47485
47546
  child.stdout?.once("data", () => {
47486
47547
  setTimeout(() => {
47487
47548
  child.kill();
47488
47549
  clearTimeout(timer);
47489
- resolve22();
47550
+ resolve23();
47490
47551
  }, 500);
47491
47552
  });
47492
47553
  });
@@ -47989,14 +48050,14 @@ var init_dev_server = __esm({
47989
48050
  child.stderr?.on("data", (d) => {
47990
48051
  stderr += d.toString();
47991
48052
  });
47992
- await new Promise((resolve22) => {
48053
+ await new Promise((resolve23) => {
47993
48054
  const timer = setTimeout(() => {
47994
48055
  child.kill();
47995
- resolve22();
48056
+ resolve23();
47996
48057
  }, timeout);
47997
48058
  child.on("exit", () => {
47998
48059
  clearTimeout(timer);
47999
- resolve22();
48060
+ resolve23();
48000
48061
  });
48001
48062
  });
48002
48063
  const elapsed = Date.now() - start;
@@ -48666,14 +48727,14 @@ data: ${JSON.stringify(msg.data)}
48666
48727
  res.end(JSON.stringify(data, null, 2));
48667
48728
  }
48668
48729
  async readBody(req) {
48669
- return new Promise((resolve22) => {
48730
+ return new Promise((resolve23) => {
48670
48731
  let body = "";
48671
48732
  req.on("data", (chunk) => body += chunk);
48672
48733
  req.on("end", () => {
48673
48734
  try {
48674
- resolve22(JSON.parse(body));
48735
+ resolve23(JSON.parse(body));
48675
48736
  } catch {
48676
- resolve22({});
48737
+ resolve23({});
48677
48738
  }
48678
48739
  });
48679
48740
  });
@@ -49190,7 +49251,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
49190
49251
  const deadline = Date.now() + timeoutMs;
49191
49252
  while (Date.now() < deadline) {
49192
49253
  if (await canConnect(endpoint)) return;
49193
- await new Promise((resolve22) => setTimeout(resolve22, STARTUP_POLL_MS));
49254
+ await new Promise((resolve23) => setTimeout(resolve23, STARTUP_POLL_MS));
49194
49255
  }
49195
49256
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
49196
49257
  }
@@ -49296,10 +49357,10 @@ async function installExtension(ide, extension) {
49296
49357
  const buffer = Buffer.from(await res.arrayBuffer());
49297
49358
  const fs24 = await import("fs");
49298
49359
  fs24.writeFileSync(vsixPath, buffer);
49299
- return new Promise((resolve22) => {
49360
+ return new Promise((resolve23) => {
49300
49361
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
49301
49362
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
49302
- resolve22({
49363
+ resolve23({
49303
49364
  extensionId: extension.id,
49304
49365
  marketplaceId: extension.marketplaceId,
49305
49366
  success: !error48,
@@ -49312,11 +49373,11 @@ async function installExtension(ide, extension) {
49312
49373
  } catch (e) {
49313
49374
  }
49314
49375
  }
49315
- return new Promise((resolve22) => {
49376
+ return new Promise((resolve23) => {
49316
49377
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
49317
49378
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
49318
49379
  if (error48) {
49319
- resolve22({
49380
+ resolve23({
49320
49381
  extensionId: extension.id,
49321
49382
  marketplaceId: extension.marketplaceId,
49322
49383
  success: false,
@@ -49324,7 +49385,7 @@ async function installExtension(ide, extension) {
49324
49385
  error: stderr || error48.message
49325
49386
  });
49326
49387
  } else {
49327
- resolve22({
49388
+ resolve23({
49328
49389
  extensionId: extension.id,
49329
49390
  marketplaceId: extension.marketplaceId,
49330
49391
  success: true,
@@ -50085,7 +50146,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
50085
50146
  const resolvedPort = resolveDaemonCommandPort(port);
50086
50147
  const WebSocket4 = (await import("ws")).default;
50087
50148
  const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
50088
- return new Promise((resolve22, reject) => {
50149
+ return new Promise((resolve23, reject) => {
50089
50150
  const wsUrl = `ws://127.0.0.1:${resolvedPort}${DAEMON_WS_PATH2 || "/daemon"}`;
50090
50151
  const ws = new WebSocket4(wsUrl);
50091
50152
  const requestId = `cli-${Date.now()}`;
@@ -50126,7 +50187,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
50126
50187
  if (msg.type === "ext:command_result" && msg.payload?.requestId === requestId || msg.type === "daemon:command_result" || msg.type === "command_result") {
50127
50188
  clearTimeout(timeout);
50128
50189
  ws.close();
50129
- resolve22(msg.payload?.result || msg.payload || msg);
50190
+ resolve23(msg.payload?.result || msg.payload || msg);
50130
50191
  }
50131
50192
  } catch {
50132
50193
  }
@@ -50145,13 +50206,13 @@ This command needs a running local daemon with IPC enabled. Start with: adhdev d
50145
50206
  }
50146
50207
  async function directCdpEval(expression, port = 9222) {
50147
50208
  const http3 = await import("http");
50148
- const targets = await new Promise((resolve22, reject) => {
50209
+ const targets = await new Promise((resolve23, reject) => {
50149
50210
  http3.get(`http://127.0.0.1:${port}/json`, (res) => {
50150
50211
  let data = "";
50151
50212
  res.on("data", (c) => data += c);
50152
50213
  res.on("end", () => {
50153
50214
  try {
50154
- resolve22(JSON.parse(data));
50215
+ resolve23(JSON.parse(data));
50155
50216
  } catch {
50156
50217
  reject(new Error("Invalid JSON"));
50157
50218
  }
@@ -50164,7 +50225,7 @@ async function directCdpEval(expression, port = 9222) {
50164
50225
  const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
50165
50226
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
50166
50227
  const WebSocket4 = (await import("ws")).default;
50167
- return new Promise((resolve22, reject) => {
50228
+ return new Promise((resolve23, reject) => {
50168
50229
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
50169
50230
  const timeout = setTimeout(() => {
50170
50231
  ws.close();
@@ -50186,11 +50247,11 @@ async function directCdpEval(expression, port = 9222) {
50186
50247
  clearTimeout(timeout);
50187
50248
  ws.close();
50188
50249
  if (msg.result?.result?.value !== void 0) {
50189
- resolve22(msg.result.result.value);
50250
+ resolve23(msg.result.result.value);
50190
50251
  } else if (msg.result?.exceptionDetails) {
50191
50252
  reject(new Error(msg.result.exceptionDetails.text));
50192
50253
  } else {
50193
- resolve22(msg.result);
50254
+ resolve23(msg.result);
50194
50255
  }
50195
50256
  }
50196
50257
  });
@@ -50726,14 +50787,14 @@ var require_run_async = __commonJS({
50726
50787
  return function() {
50727
50788
  var args = arguments;
50728
50789
  var originalThis = this;
50729
- var promise2 = new Promise(function(resolve22, reject) {
50790
+ var promise2 = new Promise(function(resolve23, reject) {
50730
50791
  var resolved = false;
50731
50792
  const wrappedResolve = function(value) {
50732
50793
  if (resolved) {
50733
50794
  console.warn("Run-async promise already resolved.");
50734
50795
  }
50735
50796
  resolved = true;
50736
- resolve22(value);
50797
+ resolve23(value);
50737
50798
  };
50738
50799
  var rejected = false;
50739
50800
  const wrappedReject = function(value) {
@@ -51524,7 +51585,7 @@ var require_Observable = __commonJS({
51524
51585
  Observable2.prototype.forEach = function(next, promiseCtor) {
51525
51586
  var _this = this;
51526
51587
  promiseCtor = getPromiseCtor(promiseCtor);
51527
- return new promiseCtor(function(resolve22, reject) {
51588
+ return new promiseCtor(function(resolve23, reject) {
51528
51589
  var subscriber = new Subscriber_1.SafeSubscriber({
51529
51590
  next: function(value) {
51530
51591
  try {
@@ -51535,7 +51596,7 @@ var require_Observable = __commonJS({
51535
51596
  }
51536
51597
  },
51537
51598
  error: reject,
51538
- complete: resolve22
51599
+ complete: resolve23
51539
51600
  });
51540
51601
  _this.subscribe(subscriber);
51541
51602
  });
@@ -51557,14 +51618,14 @@ var require_Observable = __commonJS({
51557
51618
  Observable2.prototype.toPromise = function(promiseCtor) {
51558
51619
  var _this = this;
51559
51620
  promiseCtor = getPromiseCtor(promiseCtor);
51560
- return new promiseCtor(function(resolve22, reject) {
51621
+ return new promiseCtor(function(resolve23, reject) {
51561
51622
  var value;
51562
51623
  _this.subscribe(function(x) {
51563
51624
  return value = x;
51564
51625
  }, function(err) {
51565
51626
  return reject(err);
51566
51627
  }, function() {
51567
- return resolve22(value);
51628
+ return resolve23(value);
51568
51629
  });
51569
51630
  });
51570
51631
  };
@@ -53660,11 +53721,11 @@ var require_innerFrom = __commonJS({
53660
53721
  "use strict";
53661
53722
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
53662
53723
  function adopt(value) {
53663
- return value instanceof P ? value : new P(function(resolve22) {
53664
- resolve22(value);
53724
+ return value instanceof P ? value : new P(function(resolve23) {
53725
+ resolve23(value);
53665
53726
  });
53666
53727
  }
53667
- return new (P || (P = Promise))(function(resolve22, reject) {
53728
+ return new (P || (P = Promise))(function(resolve23, reject) {
53668
53729
  function fulfilled(value) {
53669
53730
  try {
53670
53731
  step(generator.next(value));
@@ -53680,7 +53741,7 @@ var require_innerFrom = __commonJS({
53680
53741
  }
53681
53742
  }
53682
53743
  function step(result) {
53683
- result.done ? resolve22(result.value) : adopt(result.value).then(fulfilled, rejected);
53744
+ result.done ? resolve23(result.value) : adopt(result.value).then(fulfilled, rejected);
53684
53745
  }
53685
53746
  step((generator = generator.apply(thisArg, _arguments || [])).next());
53686
53747
  });
@@ -53762,14 +53823,14 @@ var require_innerFrom = __commonJS({
53762
53823
  }, i);
53763
53824
  function verb(n) {
53764
53825
  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);
53826
+ return new Promise(function(resolve23, reject) {
53827
+ v = o[n](v), settle(resolve23, reject, v.done, v.value);
53767
53828
  });
53768
53829
  };
53769
53830
  }
53770
- function settle(resolve22, reject, d, v) {
53831
+ function settle(resolve23, reject, d, v) {
53771
53832
  Promise.resolve(v).then(function(v2) {
53772
- resolve22({ value: v2, done: d });
53833
+ resolve23({ value: v2, done: d });
53773
53834
  }, reject);
53774
53835
  }
53775
53836
  };
@@ -54388,7 +54449,7 @@ var require_lastValueFrom = __commonJS({
54388
54449
  var EmptyError_1 = require_EmptyError();
54389
54450
  function lastValueFrom(source, config2) {
54390
54451
  var hasConfig = typeof config2 === "object";
54391
- return new Promise(function(resolve22, reject) {
54452
+ return new Promise(function(resolve23, reject) {
54392
54453
  var _hasValue = false;
54393
54454
  var _value;
54394
54455
  source.subscribe({
@@ -54399,9 +54460,9 @@ var require_lastValueFrom = __commonJS({
54399
54460
  error: reject,
54400
54461
  complete: function() {
54401
54462
  if (_hasValue) {
54402
- resolve22(_value);
54463
+ resolve23(_value);
54403
54464
  } else if (hasConfig) {
54404
- resolve22(config2.defaultValue);
54465
+ resolve23(config2.defaultValue);
54405
54466
  } else {
54406
54467
  reject(new EmptyError_1.EmptyError());
54407
54468
  }
@@ -54423,16 +54484,16 @@ var require_firstValueFrom = __commonJS({
54423
54484
  var Subscriber_1 = require_Subscriber();
54424
54485
  function firstValueFrom(source, config2) {
54425
54486
  var hasConfig = typeof config2 === "object";
54426
- return new Promise(function(resolve22, reject) {
54487
+ return new Promise(function(resolve23, reject) {
54427
54488
  var subscriber = new Subscriber_1.SafeSubscriber({
54428
54489
  next: function(value) {
54429
- resolve22(value);
54490
+ resolve23(value);
54430
54491
  subscriber.unsubscribe();
54431
54492
  },
54432
54493
  error: reject,
54433
54494
  complete: function() {
54434
54495
  if (hasConfig) {
54435
- resolve22(config2.defaultValue);
54496
+ resolve23(config2.defaultValue);
54436
54497
  } else {
54437
54498
  reject(new EmptyError_1.EmptyError());
54438
54499
  }
@@ -66238,14 +66299,14 @@ var require_async_iterator = __commonJS({
66238
66299
  };
66239
66300
  }
66240
66301
  function readAndResolve(iter) {
66241
- var resolve22 = iter[kLastResolve];
66242
- if (resolve22 !== null) {
66302
+ var resolve23 = iter[kLastResolve];
66303
+ if (resolve23 !== null) {
66243
66304
  var data = iter[kStream].read();
66244
66305
  if (data !== null) {
66245
66306
  iter[kLastPromise] = null;
66246
66307
  iter[kLastResolve] = null;
66247
66308
  iter[kLastReject] = null;
66248
- resolve22(createIterResult(data, false));
66309
+ resolve23(createIterResult(data, false));
66249
66310
  }
66250
66311
  }
66251
66312
  }
@@ -66253,13 +66314,13 @@ var require_async_iterator = __commonJS({
66253
66314
  process.nextTick(readAndResolve, iter);
66254
66315
  }
66255
66316
  function wrapForNext(lastPromise, iter) {
66256
- return function(resolve22, reject) {
66317
+ return function(resolve23, reject) {
66257
66318
  lastPromise.then(function() {
66258
66319
  if (iter[kEnded]) {
66259
- resolve22(createIterResult(void 0, true));
66320
+ resolve23(createIterResult(void 0, true));
66260
66321
  return;
66261
66322
  }
66262
- iter[kHandlePromise](resolve22, reject);
66323
+ iter[kHandlePromise](resolve23, reject);
66263
66324
  }, reject);
66264
66325
  };
66265
66326
  }
@@ -66279,12 +66340,12 @@ var require_async_iterator = __commonJS({
66279
66340
  return Promise.resolve(createIterResult(void 0, true));
66280
66341
  }
66281
66342
  if (this[kStream].destroyed) {
66282
- return new Promise(function(resolve22, reject) {
66343
+ return new Promise(function(resolve23, reject) {
66283
66344
  process.nextTick(function() {
66284
66345
  if (_this[kError]) {
66285
66346
  reject(_this[kError]);
66286
66347
  } else {
66287
- resolve22(createIterResult(void 0, true));
66348
+ resolve23(createIterResult(void 0, true));
66288
66349
  }
66289
66350
  });
66290
66351
  });
@@ -66307,13 +66368,13 @@ var require_async_iterator = __commonJS({
66307
66368
  return this;
66308
66369
  }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
66309
66370
  var _this2 = this;
66310
- return new Promise(function(resolve22, reject) {
66371
+ return new Promise(function(resolve23, reject) {
66311
66372
  _this2[kStream].destroy(null, function(err) {
66312
66373
  if (err) {
66313
66374
  reject(err);
66314
66375
  return;
66315
66376
  }
66316
- resolve22(createIterResult(void 0, true));
66377
+ resolve23(createIterResult(void 0, true));
66317
66378
  });
66318
66379
  });
66319
66380
  }), _Object$setPrototypeO), AsyncIteratorPrototype);
@@ -66335,15 +66396,15 @@ var require_async_iterator = __commonJS({
66335
66396
  value: stream._readableState.endEmitted,
66336
66397
  writable: true
66337
66398
  }), _defineProperty(_Object$create, kHandlePromise, {
66338
- value: function value(resolve22, reject) {
66399
+ value: function value(resolve23, reject) {
66339
66400
  var data = iterator[kStream].read();
66340
66401
  if (data) {
66341
66402
  iterator[kLastPromise] = null;
66342
66403
  iterator[kLastResolve] = null;
66343
66404
  iterator[kLastReject] = null;
66344
- resolve22(createIterResult(data, false));
66405
+ resolve23(createIterResult(data, false));
66345
66406
  } else {
66346
- iterator[kLastResolve] = resolve22;
66407
+ iterator[kLastResolve] = resolve23;
66347
66408
  iterator[kLastReject] = reject;
66348
66409
  }
66349
66410
  },
@@ -66362,12 +66423,12 @@ var require_async_iterator = __commonJS({
66362
66423
  iterator[kError] = err;
66363
66424
  return;
66364
66425
  }
66365
- var resolve22 = iterator[kLastResolve];
66366
- if (resolve22 !== null) {
66426
+ var resolve23 = iterator[kLastResolve];
66427
+ if (resolve23 !== null) {
66367
66428
  iterator[kLastPromise] = null;
66368
66429
  iterator[kLastResolve] = null;
66369
66430
  iterator[kLastReject] = null;
66370
- resolve22(createIterResult(void 0, true));
66431
+ resolve23(createIterResult(void 0, true));
66371
66432
  }
66372
66433
  iterator[kEnded] = true;
66373
66434
  });
@@ -66382,7 +66443,7 @@ var require_async_iterator = __commonJS({
66382
66443
  var require_from2 = __commonJS({
66383
66444
  "../../node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
66384
66445
  "use strict";
66385
- function asyncGeneratorStep(gen, resolve22, reject, _next, _throw, key, arg) {
66446
+ function asyncGeneratorStep(gen, resolve23, reject, _next, _throw, key, arg) {
66386
66447
  try {
66387
66448
  var info = gen[key](arg);
66388
66449
  var value = info.value;
@@ -66391,7 +66452,7 @@ var require_from2 = __commonJS({
66391
66452
  return;
66392
66453
  }
66393
66454
  if (info.done) {
66394
- resolve22(value);
66455
+ resolve23(value);
66395
66456
  } else {
66396
66457
  Promise.resolve(value).then(_next, _throw);
66397
66458
  }
@@ -66399,13 +66460,13 @@ var require_from2 = __commonJS({
66399
66460
  function _asyncToGenerator(fn) {
66400
66461
  return function() {
66401
66462
  var self2 = this, args = arguments;
66402
- return new Promise(function(resolve22, reject) {
66463
+ return new Promise(function(resolve23, reject) {
66403
66464
  var gen = fn.apply(self2, args);
66404
66465
  function _next(value) {
66405
- asyncGeneratorStep(gen, resolve22, reject, _next, _throw, "next", value);
66466
+ asyncGeneratorStep(gen, resolve23, reject, _next, _throw, "next", value);
66406
66467
  }
66407
66468
  function _throw(err) {
66408
- asyncGeneratorStep(gen, resolve22, reject, _next, _throw, "throw", err);
66469
+ asyncGeneratorStep(gen, resolve23, reject, _next, _throw, "throw", err);
66409
66470
  }
66410
66471
  _next(void 0);
66411
66472
  });
@@ -68344,9 +68405,9 @@ var init_base = __esm({
68344
68405
  * @return {Promise}
68345
68406
  */
68346
68407
  run() {
68347
- return new Promise((resolve22, reject) => {
68408
+ return new Promise((resolve23, reject) => {
68348
68409
  this._run(
68349
- (value) => resolve22(value),
68410
+ (value) => resolve23(value),
68350
68411
  (error48) => reject(error48)
68351
68412
  );
68352
68413
  });
@@ -74978,7 +75039,7 @@ var require_lib = __commonJS({
74978
75039
  return matches;
74979
75040
  };
74980
75041
  exports2.analyse = analyse;
74981
- var detectFile = (filepath, opts = {}) => new Promise((resolve22, reject) => {
75042
+ var detectFile = (filepath, opts = {}) => new Promise((resolve23, reject) => {
74982
75043
  let fd;
74983
75044
  const fs24 = (0, node_1.default)();
74984
75045
  const handler = (err, buffer) => {
@@ -74988,7 +75049,7 @@ var require_lib = __commonJS({
74988
75049
  if (err) {
74989
75050
  reject(err);
74990
75051
  } else if (buffer) {
74991
- resolve22((0, exports2.detect)(buffer));
75052
+ resolve23((0, exports2.detect)(buffer));
74992
75053
  } else {
74993
75054
  reject(new Error("No error and no buffer received"));
74994
75055
  }
@@ -78916,14 +78977,14 @@ function splitStringBySpace(str) {
78916
78977
  }
78917
78978
  return pieces;
78918
78979
  }
78919
- var import_chardet, import_child_process12, import_fs7, import_node_path2, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
78980
+ var import_chardet, import_child_process12, import_fs7, import_node_path3, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
78920
78981
  var init_esm2 = __esm({
78921
78982
  "../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
78922
78983
  "use strict";
78923
78984
  import_chardet = __toESM(require_lib(), 1);
78924
78985
  import_child_process12 = require("child_process");
78925
78986
  import_fs7 = require("fs");
78926
- import_node_path2 = __toESM(require("path"), 1);
78987
+ import_node_path3 = __toESM(require("path"), 1);
78927
78988
  import_node_os4 = __toESM(require("os"), 1);
78928
78989
  import_node_crypto2 = require("crypto");
78929
78990
  import_iconv_lite = __toESM(require_lib2(), 1);
@@ -78988,8 +79049,8 @@ var init_esm2 = __esm({
78988
79049
  const prefix = sanitizeAffix(this.fileOptions.prefix);
78989
79050
  const postfix = sanitizeAffix(this.fileOptions.postfix);
78990
79051
  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;
79052
+ const candidate = import_node_path3.default.resolve(baseDir, filename);
79053
+ const baseResolved = import_node_path3.default.resolve(baseDir) + import_node_path3.default.sep;
78993
79054
  if (!candidate.startsWith(baseResolved)) {
78994
79055
  throw new Error("Resolved temporary file escaped the base directory");
78995
79056
  }
@@ -80723,9 +80784,9 @@ function resolvePackageVersion(options) {
80723
80784
  const injectedVersion = options?.injectedVersion || "unknown";
80724
80785
  const dir = options?.dirname || __dirname;
80725
80786
  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")
80787
+ (0, import_path4.join)(dir, "..", "..", "package.json"),
80788
+ (0, import_path4.join)(dir, "..", "package.json"),
80789
+ (0, import_path4.join)(dir, "package.json")
80729
80790
  ];
80730
80791
  for (const p of possiblePaths) {
80731
80792
  try {
@@ -80736,12 +80797,12 @@ function resolvePackageVersion(options) {
80736
80797
  }
80737
80798
  return injectedVersion;
80738
80799
  }
80739
- var import_fs8, import_path5;
80800
+ var import_fs8, import_path4;
80740
80801
  var init_version = __esm({
80741
80802
  "src/version.ts"() {
80742
80803
  "use strict";
80743
80804
  import_fs8 = require("fs");
80744
- import_path5 = require("path");
80805
+ import_path4 = require("path");
80745
80806
  }
80746
80807
  });
80747
80808
 
@@ -80858,7 +80919,7 @@ var init_server_connection = __esm({
80858
80919
  * Returns the command result or throws on timeout / auth failure.
80859
80920
  */
80860
80921
  sendMeshCommand(targetDaemonId, command, args = {}, timeoutMs = 3e4) {
80861
- return new Promise((resolve22, reject) => {
80922
+ return new Promise((resolve23, reject) => {
80862
80923
  const requestId = `mesh_${crypto.randomUUID()}`;
80863
80924
  const timer = setTimeout(() => {
80864
80925
  this.off("daemon_mesh_result", handler);
@@ -80871,7 +80932,7 @@ var init_server_connection = __esm({
80871
80932
  if (msg.payload?.success === false) {
80872
80933
  reject(new Error(msg.payload?.error ?? "Mesh command failed"));
80873
80934
  } else {
80874
- resolve22(msg.payload?.result);
80935
+ resolve23(msg.payload?.result);
80875
80936
  }
80876
80937
  };
80877
80938
  this.on("daemon_mesh_result", handler);
@@ -82178,19 +82239,19 @@ var init_peer_connection_manager = __esm({
82178
82239
  });
82179
82240
 
82180
82241
  // src/daemon-p2p/index.ts
82181
- var fs16, path29, import_node_module2, esmRequire, DaemonP2PSender;
82242
+ var fs16, path29, import_node_module3, esmRequire, DaemonP2PSender;
82182
82243
  var init_daemon_p2p = __esm({
82183
82244
  "src/daemon-p2p/index.ts"() {
82184
82245
  "use strict";
82185
82246
  fs16 = __toESM(require("fs"));
82186
82247
  path29 = __toESM(require("path"));
82187
- import_node_module2 = require("module");
82248
+ import_node_module3 = require("module");
82188
82249
  init_src();
82189
82250
  init_data_channel_router();
82190
82251
  init_screenshot_sender();
82191
82252
  init_peer_connection_manager();
82192
82253
  init_log();
82193
- esmRequire = (0, import_node_module2.createRequire)(__filename);
82254
+ esmRequire = (0, import_node_module3.createRequire)(__filename);
82194
82255
  DaemonP2PSender = class {
82195
82256
  serverConn;
82196
82257
  peers = /* @__PURE__ */ new Map();
@@ -82667,14 +82728,14 @@ var require_filesystem = __commonJS({
82667
82728
  });
82668
82729
  return buffer.subarray(0, bytesRead);
82669
82730
  };
82670
- var readFile2 = (path40) => new Promise((resolve22, reject) => {
82731
+ var readFile2 = (path40) => new Promise((resolve23, reject) => {
82671
82732
  fs24.open(path40, "r", (err, fd) => {
82672
82733
  if (err) {
82673
82734
  reject(err);
82674
82735
  } else {
82675
82736
  const buffer = Buffer.alloc(MAX_LENGTH);
82676
82737
  fs24.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
82677
- resolve22(buffer.subarray(0, bytesRead));
82738
+ resolve23(buffer.subarray(0, bytesRead));
82678
82739
  fs24.close(fd, () => {
82679
82740
  });
82680
82741
  });
@@ -82742,10 +82803,10 @@ var require_detect_libc = __commonJS({
82742
82803
  var commandOut = "";
82743
82804
  var safeCommand = () => {
82744
82805
  if (!commandOut) {
82745
- return new Promise((resolve22) => {
82806
+ return new Promise((resolve23) => {
82746
82807
  childProcess.exec(command, (err, out) => {
82747
82808
  commandOut = err ? " " : out;
82748
- resolve22(commandOut);
82809
+ resolve23(commandOut);
82749
82810
  });
82750
82811
  });
82751
82812
  }
@@ -85425,14 +85486,14 @@ var require_input = __commonJS({
85425
85486
  return this;
85426
85487
  } else {
85427
85488
  if (this._isStreamInput()) {
85428
- return new Promise((resolve22, reject) => {
85489
+ return new Promise((resolve23, reject) => {
85429
85490
  const finished = () => {
85430
85491
  this._flattenBufferIn();
85431
85492
  sharp.metadata(this.options, (err, metadata2) => {
85432
85493
  if (err) {
85433
85494
  reject(is.nativeError(err, stack));
85434
85495
  } else {
85435
- resolve22(metadata2);
85496
+ resolve23(metadata2);
85436
85497
  }
85437
85498
  });
85438
85499
  };
@@ -85443,12 +85504,12 @@ var require_input = __commonJS({
85443
85504
  }
85444
85505
  });
85445
85506
  } else {
85446
- return new Promise((resolve22, reject) => {
85507
+ return new Promise((resolve23, reject) => {
85447
85508
  sharp.metadata(this.options, (err, metadata2) => {
85448
85509
  if (err) {
85449
85510
  reject(is.nativeError(err, stack));
85450
85511
  } else {
85451
- resolve22(metadata2);
85512
+ resolve23(metadata2);
85452
85513
  }
85453
85514
  });
85454
85515
  });
@@ -85481,25 +85542,25 @@ var require_input = __commonJS({
85481
85542
  return this;
85482
85543
  } else {
85483
85544
  if (this._isStreamInput()) {
85484
- return new Promise((resolve22, reject) => {
85545
+ return new Promise((resolve23, reject) => {
85485
85546
  this.on("finish", function() {
85486
85547
  this._flattenBufferIn();
85487
85548
  sharp.stats(this.options, (err, stats2) => {
85488
85549
  if (err) {
85489
85550
  reject(is.nativeError(err, stack));
85490
85551
  } else {
85491
- resolve22(stats2);
85552
+ resolve23(stats2);
85492
85553
  }
85493
85554
  });
85494
85555
  });
85495
85556
  });
85496
85557
  } else {
85497
- return new Promise((resolve22, reject) => {
85558
+ return new Promise((resolve23, reject) => {
85498
85559
  sharp.stats(this.options, (err, stats2) => {
85499
85560
  if (err) {
85500
85561
  reject(is.nativeError(err, stack));
85501
85562
  } else {
85502
- resolve22(stats2);
85563
+ resolve23(stats2);
85503
85564
  }
85504
85565
  });
85505
85566
  });
@@ -88921,7 +88982,7 @@ var require_output = __commonJS({
88921
88982
  return this;
88922
88983
  } else {
88923
88984
  if (this._isStreamInput()) {
88924
- return new Promise((resolve22, reject) => {
88985
+ return new Promise((resolve23, reject) => {
88925
88986
  this.once("finish", () => {
88926
88987
  this._flattenBufferIn();
88927
88988
  sharp.pipeline(this.options, (err, data, info) => {
@@ -88929,24 +88990,24 @@ var require_output = __commonJS({
88929
88990
  reject(is.nativeError(err, stack));
88930
88991
  } else {
88931
88992
  if (this.options.resolveWithObject) {
88932
- resolve22({ data, info });
88993
+ resolve23({ data, info });
88933
88994
  } else {
88934
- resolve22(data);
88995
+ resolve23(data);
88935
88996
  }
88936
88997
  }
88937
88998
  });
88938
88999
  });
88939
89000
  });
88940
89001
  } else {
88941
- return new Promise((resolve22, reject) => {
89002
+ return new Promise((resolve23, reject) => {
88942
89003
  sharp.pipeline(this.options, (err, data, info) => {
88943
89004
  if (err) {
88944
89005
  reject(is.nativeError(err, stack));
88945
89006
  } else {
88946
89007
  if (this.options.resolveWithObject) {
88947
- resolve22({ data, info });
89008
+ resolve23({ data, info });
88948
89009
  } else {
88949
- resolve22(data);
89010
+ resolve23(data);
88950
89011
  }
88951
89012
  }
88952
89013
  });
@@ -90178,7 +90239,7 @@ var init_adhdev_daemon = __esm({
90178
90239
  init_version();
90179
90240
  init_src();
90180
90241
  init_runtime_defaults();
90181
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.71" });
90242
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.72" });
90182
90243
  AdhdevDaemon = class _AdhdevDaemon {
90183
90244
  localHttpServer = null;
90184
90245
  localWss = null;
@@ -90994,7 +91055,7 @@ ${err?.stack || ""}`);
90994
91055
  try {
90995
91056
  const statusResult = await Promise.race([
90996
91057
  this.components.router.execute("git_status", { workspace }, "mesh"),
90997
- new Promise((resolve22) => setTimeout(() => resolve22(null), 4e3))
91058
+ new Promise((resolve23) => setTimeout(() => resolve23(null), 4e3))
90998
91059
  ]);
90999
91060
  const s = statusResult?.status ?? statusResult;
91000
91061
  if (s?.isGitRepo) {
@@ -91177,7 +91238,7 @@ ${err?.stack || ""}`);
91177
91238
  this.localWss.emit("connection", ws, req);
91178
91239
  });
91179
91240
  });
91180
- await new Promise((resolve22, reject) => {
91241
+ await new Promise((resolve23, reject) => {
91181
91242
  const cleanup = () => {
91182
91243
  this.localHttpServer?.off("error", onError);
91183
91244
  this.localHttpServer?.off("listening", onListening);
@@ -91188,7 +91249,7 @@ ${err?.stack || ""}`);
91188
91249
  };
91189
91250
  const onListening = () => {
91190
91251
  cleanup();
91191
- resolve22();
91252
+ resolve23();
91192
91253
  };
91193
91254
  this.localHttpServer.once("error", onError);
91194
91255
  this.localHttpServer.once("listening", onListening);
@@ -91362,12 +91423,12 @@ ${err?.stack || ""}`);
91362
91423
  this.localClients.clear();
91363
91424
  this.localWss?.close();
91364
91425
  this.localWss = null;
91365
- await new Promise((resolve22) => {
91426
+ await new Promise((resolve23) => {
91366
91427
  if (!this.localHttpServer) {
91367
- resolve22();
91428
+ resolve23();
91368
91429
  return;
91369
91430
  }
91370
- this.localHttpServer.close(() => resolve22());
91431
+ this.localHttpServer.close(() => resolve23());
91371
91432
  this.localHttpServer = null;
91372
91433
  });
91373
91434
  } catch {
@@ -92822,7 +92883,7 @@ init_source();
92822
92883
  init_src();
92823
92884
 
92824
92885
  // src/cli/setup-commands.ts
92825
- var import_node_path3 = __toESM(require("path"));
92886
+ var import_node_path4 = __toESM(require("path"));
92826
92887
  init_source();
92827
92888
  init_src();
92828
92889
 
@@ -92975,7 +93036,7 @@ function parsePositiveInteger(value, fallback2) {
92975
93036
  return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback2;
92976
93037
  }
92977
93038
  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()) : "";
93039
+ 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
93040
  if (!dir) {
92980
93041
  throw new Error(`Saved history ${session.providerSessionId} is missing workspace metadata. Pass --dir to resume it explicitly.`);
92981
93042
  }
@@ -93095,7 +93156,7 @@ function registerSetupCommands(program2, getProviderLoader2) {
93095
93156
  console.log(source_default.gray(" Then run: adhdev launch " + targetArg));
93096
93157
  process.exit(1);
93097
93158
  }
93098
- const resolvedDir = import_node_path3.default.resolve(workingDir);
93159
+ const resolvedDir = import_node_path4.default.resolve(workingDir);
93099
93160
  const result = await sendDaemonCommand("launch_cli", {
93100
93161
  cliType,
93101
93162
  dir: resolvedDir
@@ -93852,14 +93913,14 @@ async function requestSessionHostDirect(request) {
93852
93913
  }
93853
93914
  async function runRuntimeLaunchSpec(spec) {
93854
93915
  const { spawn: spawn7 } = await import("child_process");
93855
- return await new Promise((resolve22, reject) => {
93916
+ return await new Promise((resolve23, reject) => {
93856
93917
  const child = spawn7(spec.command, spec.args, {
93857
93918
  stdio: "inherit",
93858
93919
  env: spec.env,
93859
93920
  shell: process.platform === "win32" && spec.command !== process.execPath
93860
93921
  });
93861
93922
  child.on("error", reject);
93862
- child.on("exit", (code) => resolve22(code ?? 0));
93923
+ child.on("exit", (code) => resolve23(code ?? 0));
93863
93924
  });
93864
93925
  }
93865
93926
  async function resolveRuntimeSessionId(target, options) {
@@ -94093,7 +94154,7 @@ async function handleTraceCommand(options) {
94093
94154
  }
94094
94155
  }
94095
94156
  while (!stopped) {
94096
- await new Promise((resolve22) => setTimeout(resolve22, intervalMs));
94157
+ await new Promise((resolve23) => setTimeout(resolve23, intervalMs));
94097
94158
  if (stopped) break;
94098
94159
  const nextTrace = await fetchTrace(buildDebugTraceFollowPollArgs(baseArgs, cursor));
94099
94160
  const nextBatch = collectFreshDebugTraceEntries(nextTrace, cursor);
@@ -94915,33 +94976,33 @@ function buildDoctorAdvice(input) {
94915
94976
  }
94916
94977
 
94917
94978
  // src/cli/service-commands.ts
94918
- var import_node_fs4 = __toESM(require("fs"));
94919
- var import_node_path4 = __toESM(require("path"));
94979
+ var import_node_fs5 = __toESM(require("fs"));
94980
+ var import_node_path5 = __toESM(require("path"));
94920
94981
  var import_node_os5 = __toESM(require("os"));
94921
94982
  var import_node_child_process2 = require("child_process");
94922
94983
  init_source();
94923
94984
  init_src();
94924
94985
  var DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS3 = 1500;
94925
94986
  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");
94987
+ var ADHDEV_DIR = import_node_path5.default.join(import_node_os5.default.homedir(), ".adhdev");
94988
+ var LOG_OUT = import_node_path5.default.join(ADHDEV_DIR, "daemon-launchd.out");
94989
+ var LOG_ERR = import_node_path5.default.join(ADHDEV_DIR, "daemon-launchd.err");
94929
94990
  var MAX_LOG_SIZE2 = 10 * 1024 * 1024;
94930
94991
  function getDarwinPlistPath() {
94931
- return import_node_path4.default.join(import_node_os5.default.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
94992
+ return import_node_path5.default.join(import_node_os5.default.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
94932
94993
  }
94933
94994
  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");
94995
+ const appData = process.env.APPDATA || import_node_path5.default.join(import_node_os5.default.homedir(), "AppData", "Roaming");
94996
+ return import_node_path5.default.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup");
94936
94997
  }
94937
94998
  function getWindowsVbsPath() {
94938
- return import_node_path4.default.join(getWindowsStartupDir(), "adhdev-daemon.vbs");
94999
+ return import_node_path5.default.join(getWindowsStartupDir(), "adhdev-daemon.vbs");
94939
95000
  }
94940
95001
  function resolveCliPath() {
94941
- return import_node_fs4.default.realpathSync(process.argv[1]);
95002
+ return import_node_fs5.default.realpathSync(process.argv[1]);
94942
95003
  }
94943
95004
  function ensureDir(dir) {
94944
- if (!import_node_fs4.default.existsSync(dir)) import_node_fs4.default.mkdirSync(dir, { recursive: true });
95005
+ if (!import_node_fs5.default.existsSync(dir)) import_node_fs5.default.mkdirSync(dir, { recursive: true });
94945
95006
  }
94946
95007
  async function fetchHealth() {
94947
95008
  const controller = new AbortController();
@@ -94983,13 +95044,13 @@ function formatElapsed(etime) {
94983
95044
  }
94984
95045
  function rotateLogIfNeeded(logPath) {
94985
95046
  try {
94986
- if (!import_node_fs4.default.existsSync(logPath)) return;
94987
- const stat5 = import_node_fs4.default.statSync(logPath);
95047
+ if (!import_node_fs5.default.existsSync(logPath)) return;
95048
+ const stat5 = import_node_fs5.default.statSync(logPath);
94988
95049
  if (stat5.size > MAX_LOG_SIZE2) {
94989
95050
  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()}]
95051
+ if (import_node_fs5.default.existsSync(rotated)) import_node_fs5.default.unlinkSync(rotated);
95052
+ import_node_fs5.default.renameSync(logPath, rotated);
95053
+ import_node_fs5.default.writeFileSync(logPath, `[log rotated at ${(/* @__PURE__ */ new Date()).toISOString()}]
94993
95054
  `, "utf-8");
94994
95055
  }
94995
95056
  } catch {
@@ -95000,8 +95061,8 @@ function rotateLogs() {
95000
95061
  rotateLogIfNeeded(LOG_ERR);
95001
95062
  }
95002
95063
  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);
95064
+ const brewPrefix = import_node_fs5.default.existsSync("/opt/homebrew/bin") ? "/opt/homebrew/bin" : "/usr/local/bin";
95065
+ const nodeDir = import_node_path5.default.dirname(nodeExe);
95005
95066
  const pathEntries = /* @__PURE__ */ new Set([nodeDir, brewPrefix, "/usr/local/bin", "/usr/bin", "/bin", "/usr/sbin", "/sbin"]);
95006
95067
  const pathValue = Array.from(pathEntries).join(":");
95007
95068
  return `<?xml version="1.0" encoding="UTF-8"?>
@@ -95040,8 +95101,8 @@ function buildPlist(nodeExe, cliExe) {
95040
95101
  function installDarwin(nodeExe, cliExe) {
95041
95102
  const plistPath = getDarwinPlistPath();
95042
95103
  ensureDir(ADHDEV_DIR);
95043
- ensureDir(import_node_path4.default.dirname(plistPath));
95044
- import_node_fs4.default.writeFileSync(plistPath, buildPlist(nodeExe, cliExe), "utf-8");
95104
+ ensureDir(import_node_path5.default.dirname(plistPath));
95105
+ import_node_fs5.default.writeFileSync(plistPath, buildPlist(nodeExe, cliExe), "utf-8");
95045
95106
  console.log(source_default.gray(` Plist: ${plistPath}`));
95046
95107
  try {
95047
95108
  (0, import_node_child_process2.execSync)(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
@@ -95058,7 +95119,7 @@ function installDarwin(nodeExe, cliExe) {
95058
95119
  }
95059
95120
  function uninstallDarwin() {
95060
95121
  const plistPath = getDarwinPlistPath();
95061
- if (!import_node_fs4.default.existsSync(plistPath)) {
95122
+ if (!import_node_fs5.default.existsSync(plistPath)) {
95062
95123
  console.log(source_default.yellow("\n \u26A0 Service is not installed."));
95063
95124
  return;
95064
95125
  }
@@ -95066,14 +95127,14 @@ function uninstallDarwin() {
95066
95127
  (0, import_node_child_process2.execSync)(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
95067
95128
  } catch {
95068
95129
  }
95069
- import_node_fs4.default.unlinkSync(plistPath);
95130
+ import_node_fs5.default.unlinkSync(plistPath);
95070
95131
  console.log(source_default.green("\n \u2713 Removed LaunchAgent. Daemon will no longer auto-start."));
95071
95132
  }
95072
95133
  function isInstalledDarwin() {
95073
- return import_node_fs4.default.existsSync(getDarwinPlistPath());
95134
+ return import_node_fs5.default.existsSync(getDarwinPlistPath());
95074
95135
  }
95075
95136
  function buildVbs(nodeExe, cliExe) {
95076
- const logFile = import_node_path4.default.join(ADHDEV_DIR, "daemon-service.log").replace(/\\/g, "\\\\");
95137
+ const logFile = import_node_path5.default.join(ADHDEV_DIR, "daemon-service.log").replace(/\\/g, "\\\\");
95077
95138
  const escapedNodeExe = nodeExe.replace(/\\/g, "\\\\");
95078
95139
  const escapedCliExe = cliExe.replace(/\\/g, "\\\\");
95079
95140
  return `' ADHDev Daemon Auto-Start (generated by adhdev service install)
@@ -95084,25 +95145,25 @@ WshShell.Run "cmd.exe /c """"${escapedNodeExe}"""" """"${escapedCliExe}"""" daem
95084
95145
  function installWindows(nodeExe, cliExe) {
95085
95146
  const vbsPath = getWindowsVbsPath();
95086
95147
  ensureDir(ADHDEV_DIR);
95087
- ensureDir(import_node_path4.default.dirname(vbsPath));
95088
- import_node_fs4.default.writeFileSync(vbsPath, buildVbs(nodeExe, cliExe), "utf-8");
95148
+ ensureDir(import_node_path5.default.dirname(vbsPath));
95149
+ import_node_fs5.default.writeFileSync(vbsPath, buildVbs(nodeExe, cliExe), "utf-8");
95089
95150
  console.log(source_default.gray(` Startup script: ${vbsPath}`));
95090
95151
  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")}`));
95152
+ console.log(source_default.gray(` Logs: ${import_node_path5.default.join(ADHDEV_DIR, "daemon-service.log")}`));
95092
95153
  console.log(source_default.gray(" To start now without rebooting, run: adhdev daemon"));
95093
95154
  }
95094
95155
  function uninstallWindows() {
95095
95156
  const vbsPath = getWindowsVbsPath();
95096
- if (!import_node_fs4.default.existsSync(vbsPath)) {
95157
+ if (!import_node_fs5.default.existsSync(vbsPath)) {
95097
95158
  console.log(source_default.yellow("\n \u26A0 Service is not installed."));
95098
95159
  return;
95099
95160
  }
95100
- import_node_fs4.default.unlinkSync(vbsPath);
95161
+ import_node_fs5.default.unlinkSync(vbsPath);
95101
95162
  console.log(source_default.green("\n \u2713 Removed Startup script. Daemon will no longer auto-start."));
95102
95163
  console.log(source_default.gray(" Note: a currently running daemon is not affected. Stop with: adhdev daemon:stop"));
95103
95164
  }
95104
95165
  function isInstalledWindows() {
95105
- return import_node_fs4.default.existsSync(getWindowsVbsPath());
95166
+ return import_node_fs5.default.existsSync(getWindowsVbsPath());
95106
95167
  }
95107
95168
  function registerServiceCommands(program2) {
95108
95169
  const svc = program2.command("service").description("\u{1F50C} Manage ADHDev as an OS background auto-start service");
@@ -95158,8 +95219,8 @@ function registerServiceCommands(program2) {
95158
95219
  } else {
95159
95220
  console.log(source_default.yellow(" \u2717 Daemon is not running."));
95160
95221
  }
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;
95222
+ const outSize = import_node_fs5.default.existsSync(LOG_OUT) ? import_node_fs5.default.statSync(LOG_OUT).size : 0;
95223
+ const errSize = import_node_fs5.default.existsSync(LOG_ERR) ? import_node_fs5.default.statSync(LOG_ERR).size : 0;
95163
95224
  if (outSize > 0 || errSize > 0) {
95164
95225
  console.log(source_default.gray(` Logs: stdout ${formatBytes(outSize)}, stderr ${formatBytes(errSize)}`));
95165
95226
  }
@@ -95168,13 +95229,13 @@ function registerServiceCommands(program2) {
95168
95229
  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
95230
  if (options.clear) {
95170
95231
  for (const f of [LOG_OUT, LOG_ERR]) {
95171
- if (import_node_fs4.default.existsSync(f)) import_node_fs4.default.writeFileSync(f, "", "utf-8");
95232
+ if (import_node_fs5.default.existsSync(f)) import_node_fs5.default.writeFileSync(f, "", "utf-8");
95172
95233
  }
95173
95234
  console.log(source_default.green("\n \u2713 Logs cleared.\n"));
95174
95235
  return;
95175
95236
  }
95176
95237
  const logFile = options.err ? LOG_ERR : LOG_OUT;
95177
- if (!import_node_fs4.default.existsSync(logFile)) {
95238
+ if (!import_node_fs5.default.existsSync(logFile)) {
95178
95239
  console.log(source_default.gray(`
95179
95240
  No log file found: ${logFile}
95180
95241
  `));
@@ -95184,20 +95245,20 @@ function registerServiceCommands(program2) {
95184
95245
  console.log(source_default.gray(`
95185
95246
  \u2500\u2500 ${options.err ? "stderr" : "stdout"}: ${logFile} (last ${lines} lines) \u2500\u2500
95186
95247
  `));
95187
- const content = import_node_fs4.default.readFileSync(logFile, "utf-8");
95248
+ const content = import_node_fs5.default.readFileSync(logFile, "utf-8");
95188
95249
  const allLines = content.split("\n");
95189
95250
  const lastLines = allLines.slice(-lines).join("\n");
95190
95251
  if (lastLines.trim()) console.log(lastLines);
95191
95252
  console.log(source_default.gray("\n (watching for new output, Ctrl+C to stop)\n"));
95192
95253
  let offset = Buffer.byteLength(content, "utf-8");
95193
- const watcher = import_node_fs4.default.watchFile(logFile, { interval: 500 }, () => {
95254
+ const watcher = import_node_fs5.default.watchFile(logFile, { interval: 500 }, () => {
95194
95255
  try {
95195
- const stat5 = import_node_fs4.default.statSync(logFile);
95256
+ const stat5 = import_node_fs5.default.statSync(logFile);
95196
95257
  if (stat5.size > offset) {
95197
- const fd = import_node_fs4.default.openSync(logFile, "r");
95258
+ const fd = import_node_fs5.default.openSync(logFile, "r");
95198
95259
  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);
95260
+ import_node_fs5.default.readSync(fd, buf, 0, buf.length, offset);
95261
+ import_node_fs5.default.closeSync(fd);
95201
95262
  process.stdout.write(buf.toString("utf-8"));
95202
95263
  offset = stat5.size;
95203
95264
  } else if (stat5.size < offset) {
@@ -95207,7 +95268,7 @@ function registerServiceCommands(program2) {
95207
95268
  }
95208
95269
  });
95209
95270
  const cleanup = () => {
95210
- import_node_fs4.default.unwatchFile(logFile);
95271
+ import_node_fs5.default.unwatchFile(logFile);
95211
95272
  process.exit(0);
95212
95273
  };
95213
95274
  process.on("SIGINT", cleanup);
@@ -95248,7 +95309,7 @@ function registerServiceCommands(program2) {
95248
95309
  await new Promise((r) => setTimeout(r, 2e3));
95249
95310
  if (platform12 === "win32") {
95250
95311
  const vbsPath = getWindowsVbsPath();
95251
- if (import_node_fs4.default.existsSync(vbsPath)) {
95312
+ if (import_node_fs5.default.existsSync(vbsPath)) {
95252
95313
  try {
95253
95314
  (0, import_node_child_process2.execSync)(`wscript.exe "${vbsPath}"`, { stdio: "ignore", windowsHide: true });
95254
95315
  } catch {
@@ -95859,7 +95920,7 @@ function registerProviderCommands(program2) {
95859
95920
  } catch {
95860
95921
  try {
95861
95922
  const http3 = await import("http");
95862
- const result = await new Promise((resolve22, reject) => {
95923
+ const result = await new Promise((resolve23, reject) => {
95863
95924
  const req = http3.request({
95864
95925
  hostname: "127.0.0.1",
95865
95926
  port: DEV_SERVER_PORT3,
@@ -95871,9 +95932,9 @@ function registerProviderCommands(program2) {
95871
95932
  res.on("data", (c) => data += c);
95872
95933
  res.on("end", () => {
95873
95934
  try {
95874
- resolve22(JSON.parse(data));
95935
+ resolve23(JSON.parse(data));
95875
95936
  } catch {
95876
- resolve22({ raw: data });
95937
+ resolve23({ raw: data });
95877
95938
  }
95878
95939
  });
95879
95940
  });
@@ -95975,12 +96036,12 @@ function registerProviderCommands(program2) {
95975
96036
  console.log(source_default.yellow("Invalid port number."));
95976
96037
  continue;
95977
96038
  }
95978
- const isFree = await new Promise((resolve22) => {
96039
+ const isFree = await new Promise((resolve23) => {
95979
96040
  const server = net3.createServer();
95980
96041
  server.unref();
95981
- server.on("error", () => resolve22(false));
96042
+ server.on("error", () => resolve23(false));
95982
96043
  server.listen(port, "127.0.0.1", () => {
95983
- server.close(() => resolve22(true));
96044
+ server.close(() => resolve23(true));
95984
96045
  });
95985
96046
  });
95986
96047
  if (!isFree) {
@@ -95995,7 +96056,7 @@ function registerProviderCommands(program2) {
95995
96056
  rl.close();
95996
96057
  const location = options.builtin ? "builtin" : "user";
95997
96058
  const http3 = await import("http");
95998
- const result = await new Promise((resolve22, reject) => {
96059
+ const result = await new Promise((resolve23, reject) => {
95999
96060
  const postData = JSON.stringify({ type, name, category, location, cdpPorts, osPaths, processNames });
96000
96061
  const req = http3.request({
96001
96062
  hostname: "127.0.0.1",
@@ -96008,9 +96069,9 @@ function registerProviderCommands(program2) {
96008
96069
  res.on("data", (c) => data += c);
96009
96070
  res.on("end", () => {
96010
96071
  try {
96011
- resolve22(JSON.parse(data));
96072
+ resolve23(JSON.parse(data));
96012
96073
  } catch {
96013
- resolve22({ raw: data });
96074
+ resolve23({ raw: data });
96014
96075
  }
96015
96076
  });
96016
96077
  });
@@ -96209,7 +96270,7 @@ function registerProviderCommands(program2) {
96209
96270
  reference,
96210
96271
  ...verification ? { verification } : {}
96211
96272
  });
96212
- const startResult = await new Promise((resolve22, reject) => {
96273
+ const startResult = await new Promise((resolve23, reject) => {
96213
96274
  const req = http3.request({
96214
96275
  hostname: "127.0.0.1",
96215
96276
  port: DEV_SERVER_PORT3,
@@ -96221,9 +96282,9 @@ function registerProviderCommands(program2) {
96221
96282
  res.on("data", (c) => data += c);
96222
96283
  res.on("end", () => {
96223
96284
  try {
96224
- resolve22(JSON.parse(data));
96285
+ resolve23(JSON.parse(data));
96225
96286
  } catch {
96226
- resolve22({ raw: data });
96287
+ resolve23({ raw: data });
96227
96288
  }
96228
96289
  });
96229
96290
  });
@@ -96257,7 +96318,7 @@ function registerProviderCommands(program2) {
96257
96318
  fsMock.writeFileSync(logFile, `=== Auto-Impl Started ===
96258
96319
  `);
96259
96320
  console.log(source_default.gray(` Agent logs: ${logFile}`));
96260
- await new Promise((resolve22, reject) => {
96321
+ await new Promise((resolve23, reject) => {
96261
96322
  http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}${startResult.sseUrl}`, (res) => {
96262
96323
  let buffer = "";
96263
96324
  res.on("data", (chunk) => {
@@ -96294,7 +96355,7 @@ function registerProviderCommands(program2) {
96294
96355
  if (currentData.success === false) {
96295
96356
  reject(new Error(`Agent failed to implement scripts properly (exit: ${currentData.exitCode})`));
96296
96357
  } else {
96297
- resolve22();
96358
+ resolve23();
96298
96359
  }
96299
96360
  } else if (currentEvent === "error") {
96300
96361
  fsMock.appendFileSync(logFile, `
@@ -96305,7 +96366,7 @@ function registerProviderCommands(program2) {
96305
96366
  }
96306
96367
  }
96307
96368
  });
96308
- res.on("end", resolve22);
96369
+ res.on("end", resolve23);
96309
96370
  }).on("error", reject);
96310
96371
  });
96311
96372
  console.log(source_default.green(`
@@ -96364,7 +96425,7 @@ function registerProviderCommands(program2) {
96364
96425
  ideType: type,
96365
96426
  params: options.param ? { text: options.param, sessionId: options.param, buttonText: options.param } : {}
96366
96427
  });
96367
- const result = await new Promise((resolve22, reject) => {
96428
+ const result = await new Promise((resolve23, reject) => {
96368
96429
  const req = http3.request({
96369
96430
  hostname: "127.0.0.1",
96370
96431
  port: DEV_SERVER_PORT3,
@@ -96376,9 +96437,9 @@ function registerProviderCommands(program2) {
96376
96437
  res.on("data", (c) => data += c);
96377
96438
  res.on("end", () => {
96378
96439
  try {
96379
- resolve22(JSON.parse(data));
96440
+ resolve23(JSON.parse(data));
96380
96441
  } catch {
96381
- resolve22({ raw: data });
96442
+ resolve23({ raw: data });
96382
96443
  }
96383
96444
  });
96384
96445
  });
@@ -96414,15 +96475,15 @@ function registerProviderCommands(program2) {
96414
96475
  provider.command("source <type>").description("View source code of a provider").action(async (type) => {
96415
96476
  try {
96416
96477
  const http3 = await import("http");
96417
- const result = await new Promise((resolve22, reject) => {
96478
+ const result = await new Promise((resolve23, reject) => {
96418
96479
  http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}/api/providers/${type}/source`, (res) => {
96419
96480
  let data = "";
96420
96481
  res.on("data", (c) => data += c);
96421
96482
  res.on("end", () => {
96422
96483
  try {
96423
- resolve22(JSON.parse(data));
96484
+ resolve23(JSON.parse(data));
96424
96485
  } catch {
96425
- resolve22({ raw: data });
96486
+ resolve23({ raw: data });
96426
96487
  }
96427
96488
  });
96428
96489
  }).on("error", () => {
@@ -96470,7 +96531,7 @@ function registerProviderCommands(program2) {
96470
96531
  try {
96471
96532
  const http3 = await import("http");
96472
96533
  const postData = JSON.stringify({ script: "readChat", params: {} });
96473
- const result = await new Promise((resolve22, reject) => {
96534
+ const result = await new Promise((resolve23, reject) => {
96474
96535
  const req = http3.request({
96475
96536
  hostname: "127.0.0.1",
96476
96537
  port: DEV_SERVER_PORT3,
@@ -96482,9 +96543,9 @@ function registerProviderCommands(program2) {
96482
96543
  res2.on("data", (c) => data += c);
96483
96544
  res2.on("end", () => {
96484
96545
  try {
96485
- resolve22(JSON.parse(data));
96546
+ resolve23(JSON.parse(data));
96486
96547
  } catch {
96487
- resolve22({ raw: data });
96548
+ resolve23({ raw: data });
96488
96549
  }
96489
96550
  });
96490
96551
  });
@@ -96725,13 +96786,13 @@ function registerCdpCommands(program2) {
96725
96786
  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
96787
  try {
96727
96788
  const http3 = await import("http");
96728
- const targets = await new Promise((resolve22, reject) => {
96789
+ const targets = await new Promise((resolve23, reject) => {
96729
96790
  http3.get(`http://127.0.0.1:${options.port}/json`, (res) => {
96730
96791
  let data = "";
96731
96792
  res.on("data", (c) => data += c);
96732
96793
  res.on("end", () => {
96733
96794
  try {
96734
- resolve22(JSON.parse(data));
96795
+ resolve23(JSON.parse(data));
96735
96796
  } catch {
96736
96797
  reject(new Error("Invalid JSON"));
96737
96798
  }
@@ -96745,7 +96806,7 @@ function registerCdpCommands(program2) {
96745
96806
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target");
96746
96807
  const WebSocket4 = (await import("ws")).default;
96747
96808
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
96748
- await new Promise((resolve22, reject) => {
96809
+ await new Promise((resolve23, reject) => {
96749
96810
  ws.on("open", () => {
96750
96811
  ws.send(JSON.stringify({ id: 1, method: "Page.captureScreenshot", params: { format: "jpeg", quality: 50 } }));
96751
96812
  });
@@ -96758,7 +96819,7 @@ function registerCdpCommands(program2) {
96758
96819
  \u2713 Screenshot saved to ${options.output}
96759
96820
  `));
96760
96821
  ws.close();
96761
- resolve22();
96822
+ resolve23();
96762
96823
  }
96763
96824
  });
96764
96825
  ws.on("error", (e) => reject(e));
@@ -96775,7 +96836,7 @@ function registerCdpCommands(program2) {
96775
96836
  // src/cli/mcp-commands.ts
96776
96837
  var import_node_child_process3 = require("child_process");
96777
96838
  var fs23 = __toESM(require("fs"));
96778
- var import_node_module3 = require("module");
96839
+ var import_node_module4 = require("module");
96779
96840
  var path39 = __toESM(require("path"));
96780
96841
  init_source();
96781
96842
  function registerMcpCommands(program2) {
@@ -96835,7 +96896,7 @@ function resolveMcpBin() {
96835
96896
  }
96836
96897
  }
96837
96898
  try {
96838
- const req = (0, import_node_module3.createRequire)(__filename);
96899
+ const req = (0, import_node_module4.createRequire)(__filename);
96839
96900
  return req.resolve("@adhdev/mcp-server");
96840
96901
  } catch {
96841
96902
  return null;