@adhdev/daemon-standalone 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/index.js CHANGED
@@ -30095,7 +30095,7 @@ ${rules.join("\n")}`;
30095
30095
  `[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
30096
30096
  );
30097
30097
  }
30098
- await new Promise((resolve15) => setTimeout(resolve15, 50));
30098
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
30099
30099
  }
30100
30100
  const finalScreenText = this.terminalScreen.getText() || "";
30101
30101
  LOG2.warn(
@@ -31005,7 +31005,7 @@ ${rules.join("\n")}`;
31005
31005
  const deadline = Date.now() + 1e4;
31006
31006
  while (this.startupParseGate && Date.now() < deadline) {
31007
31007
  this.resolveStartupState("send_wait");
31008
- await new Promise((resolve15) => setTimeout(resolve15, 50));
31008
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
31009
31009
  }
31010
31010
  }
31011
31011
  if (!allowInterventionPrompt) {
@@ -31081,13 +31081,13 @@ ${rules.join("\n")}`;
31081
31081
  }
31082
31082
  this.responseEpoch += 1;
31083
31083
  this.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
31084
- await new Promise((resolve15, reject) => {
31084
+ await new Promise((resolve16, reject) => {
31085
31085
  let resolved = false;
31086
31086
  const completion = {
31087
31087
  resolveOnce: () => {
31088
31088
  if (resolved) return;
31089
31089
  resolved = true;
31090
- resolve15();
31090
+ resolve16();
31091
31091
  },
31092
31092
  rejectOnce: (error48) => {
31093
31093
  if (resolved) return;
@@ -31245,17 +31245,17 @@ ${rules.join("\n")}`;
31245
31245
  }
31246
31246
  }
31247
31247
  waitForStopped(timeoutMs) {
31248
- return new Promise((resolve15) => {
31248
+ return new Promise((resolve16) => {
31249
31249
  const startedAt = Date.now();
31250
31250
  const timer = setInterval(() => {
31251
31251
  if (!this.ptyProcess || this.currentStatus === "stopped") {
31252
31252
  clearInterval(timer);
31253
- resolve15(true);
31253
+ resolve16(true);
31254
31254
  return;
31255
31255
  }
31256
31256
  if (Date.now() - startedAt >= timeoutMs) {
31257
31257
  clearInterval(timer);
31258
- resolve15(false);
31258
+ resolve16(false);
31259
31259
  }
31260
31260
  }, 100);
31261
31261
  });
@@ -33656,8 +33656,8 @@ ${rules.join("\n")}`;
33656
33656
  if ((0, import_fs4.existsSync)(bundledCli)) resolvedCli = bundledCli;
33657
33657
  }
33658
33658
  if (!resolvedCli && appPath && os21 === "win32") {
33659
- const { dirname: dirname7 } = await import("path");
33660
- const appDir = dirname7(appPath);
33659
+ const { dirname: dirname8 } = await import("path");
33660
+ const appDir = dirname8(appPath);
33661
33661
  const candidates = [
33662
33662
  `${appDir}\\\\bin\\\\${def.cli}.cmd`,
33663
33663
  `${appDir}\\\\bin\\\\${def.cli}`,
@@ -33719,19 +33719,19 @@ ${rules.join("\n")}`;
33719
33719
  return null;
33720
33720
  }
33721
33721
  function execAsync(cmd, timeoutMs = 5e3) {
33722
- return new Promise((resolve15) => {
33722
+ return new Promise((resolve16) => {
33723
33723
  const child = (0, import_child_process2.exec)(cmd, {
33724
33724
  encoding: "utf-8",
33725
33725
  timeout: timeoutMs,
33726
33726
  ...process.platform === "win32" ? { windowsHide: true } : {}
33727
33727
  }, (err, stdout) => {
33728
33728
  if (err || !stdout?.trim()) {
33729
- resolve15(null);
33729
+ resolve16(null);
33730
33730
  } else {
33731
- resolve15(stdout.trim());
33731
+ resolve16(stdout.trim());
33732
33732
  }
33733
33733
  });
33734
- child.on("error", () => resolve15(null));
33734
+ child.on("error", () => resolve16(null));
33735
33735
  });
33736
33736
  }
33737
33737
  async function detectCLIs(providerLoader, options) {
@@ -34088,7 +34088,7 @@ ${rules.join("\n")}`;
34088
34088
  * Returns multiple entries if multiple IDE windows are open on same port
34089
34089
  */
34090
34090
  static listAllTargets(port) {
34091
- return new Promise((resolve15) => {
34091
+ return new Promise((resolve16) => {
34092
34092
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
34093
34093
  let data = "";
34094
34094
  res.on("data", (chunk) => data += chunk.toString());
@@ -34104,16 +34104,16 @@ ${rules.join("\n")}`;
34104
34104
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
34105
34105
  );
34106
34106
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
34107
- resolve15(mainPages.length > 0 ? mainPages : fallbackPages);
34107
+ resolve16(mainPages.length > 0 ? mainPages : fallbackPages);
34108
34108
  } catch {
34109
- resolve15([]);
34109
+ resolve16([]);
34110
34110
  }
34111
34111
  });
34112
34112
  });
34113
- req.on("error", () => resolve15([]));
34113
+ req.on("error", () => resolve16([]));
34114
34114
  req.setTimeout(2e3, () => {
34115
34115
  req.destroy();
34116
- resolve15([]);
34116
+ resolve16([]);
34117
34117
  });
34118
34118
  });
34119
34119
  }
@@ -34153,7 +34153,7 @@ ${rules.join("\n")}`;
34153
34153
  }
34154
34154
  }
34155
34155
  findTargetOnPort(port) {
34156
- return new Promise((resolve15) => {
34156
+ return new Promise((resolve16) => {
34157
34157
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
34158
34158
  let data = "";
34159
34159
  res.on("data", (chunk) => data += chunk.toString());
@@ -34164,7 +34164,7 @@ ${rules.join("\n")}`;
34164
34164
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
34165
34165
  );
34166
34166
  if (pages.length === 0) {
34167
- resolve15(targets.find((t) => t.webSocketDebuggerUrl) || null);
34167
+ resolve16(targets.find((t) => t.webSocketDebuggerUrl) || null);
34168
34168
  return;
34169
34169
  }
34170
34170
  const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -34183,25 +34183,25 @@ ${rules.join("\n")}`;
34183
34183
  this._targetId = selected.target.id;
34184
34184
  }
34185
34185
  this._pageTitle = selected.target.title || "";
34186
- resolve15(selected.target);
34186
+ resolve16(selected.target);
34187
34187
  return;
34188
34188
  }
34189
34189
  if (previousTargetId) {
34190
34190
  this.log(`[CDP] Target ${previousTargetId} not found in page list`);
34191
- resolve15(null);
34191
+ resolve16(null);
34192
34192
  return;
34193
34193
  }
34194
34194
  this._pageTitle = list[0]?.title || "";
34195
- resolve15(list[0]);
34195
+ resolve16(list[0]);
34196
34196
  } catch {
34197
- resolve15(null);
34197
+ resolve16(null);
34198
34198
  }
34199
34199
  });
34200
34200
  });
34201
- req.on("error", () => resolve15(null));
34201
+ req.on("error", () => resolve16(null));
34202
34202
  req.setTimeout(2e3, () => {
34203
34203
  req.destroy();
34204
- resolve15(null);
34204
+ resolve16(null);
34205
34205
  });
34206
34206
  });
34207
34207
  }
@@ -34212,7 +34212,7 @@ ${rules.join("\n")}`;
34212
34212
  this.extensionProviders = providers;
34213
34213
  }
34214
34214
  connectToTarget(wsUrl) {
34215
- return new Promise((resolve15) => {
34215
+ return new Promise((resolve16) => {
34216
34216
  this.ws = new import_ws2.default(wsUrl);
34217
34217
  this.ws.on("open", async () => {
34218
34218
  this._connected = true;
@@ -34222,17 +34222,17 @@ ${rules.join("\n")}`;
34222
34222
  }
34223
34223
  this.connectBrowserWs().catch(() => {
34224
34224
  });
34225
- resolve15(true);
34225
+ resolve16(true);
34226
34226
  });
34227
34227
  this.ws.on("message", (data) => {
34228
34228
  try {
34229
34229
  const msg = JSON.parse(data.toString());
34230
34230
  if (msg.id && this.pending.has(msg.id)) {
34231
- const { resolve: resolve16, reject } = this.pending.get(msg.id);
34231
+ const { resolve: resolve17, reject } = this.pending.get(msg.id);
34232
34232
  this.pending.delete(msg.id);
34233
34233
  this.failureCount = 0;
34234
34234
  if (msg.error) reject(new Error(msg.error.message));
34235
- else resolve16(msg.result);
34235
+ else resolve17(msg.result);
34236
34236
  } else if (msg.method === "Runtime.executionContextCreated") {
34237
34237
  this.contexts.add(msg.params.context.id);
34238
34238
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -34255,7 +34255,7 @@ ${rules.join("\n")}`;
34255
34255
  this.ws.on("error", (err) => {
34256
34256
  this.log(`[CDP] WebSocket error: ${err.message}`);
34257
34257
  this._connected = false;
34258
- resolve15(false);
34258
+ resolve16(false);
34259
34259
  });
34260
34260
  });
34261
34261
  }
@@ -34269,7 +34269,7 @@ ${rules.join("\n")}`;
34269
34269
  return;
34270
34270
  }
34271
34271
  this.log(`[CDP] Connecting browser WS for target discovery...`);
34272
- await new Promise((resolve15, reject) => {
34272
+ await new Promise((resolve16, reject) => {
34273
34273
  this.browserWs = new import_ws2.default(browserWsUrl);
34274
34274
  this.browserWs.on("open", async () => {
34275
34275
  this._browserConnected = true;
@@ -34279,16 +34279,16 @@ ${rules.join("\n")}`;
34279
34279
  } catch (e) {
34280
34280
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
34281
34281
  }
34282
- resolve15();
34282
+ resolve16();
34283
34283
  });
34284
34284
  this.browserWs.on("message", (data) => {
34285
34285
  try {
34286
34286
  const msg = JSON.parse(data.toString());
34287
34287
  if (msg.id && this.browserPending.has(msg.id)) {
34288
- const { resolve: resolve16, reject: reject2 } = this.browserPending.get(msg.id);
34288
+ const { resolve: resolve17, reject: reject2 } = this.browserPending.get(msg.id);
34289
34289
  this.browserPending.delete(msg.id);
34290
34290
  if (msg.error) reject2(new Error(msg.error.message));
34291
- else resolve16(msg.result);
34291
+ else resolve17(msg.result);
34292
34292
  }
34293
34293
  } catch {
34294
34294
  }
@@ -34308,31 +34308,31 @@ ${rules.join("\n")}`;
34308
34308
  }
34309
34309
  }
34310
34310
  getBrowserWsUrl() {
34311
- return new Promise((resolve15) => {
34311
+ return new Promise((resolve16) => {
34312
34312
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
34313
34313
  let data = "";
34314
34314
  res.on("data", (chunk) => data += chunk.toString());
34315
34315
  res.on("end", () => {
34316
34316
  try {
34317
34317
  const info = JSON.parse(data);
34318
- resolve15(info.webSocketDebuggerUrl || null);
34318
+ resolve16(info.webSocketDebuggerUrl || null);
34319
34319
  } catch {
34320
- resolve15(null);
34320
+ resolve16(null);
34321
34321
  }
34322
34322
  });
34323
34323
  });
34324
- req.on("error", () => resolve15(null));
34324
+ req.on("error", () => resolve16(null));
34325
34325
  req.setTimeout(3e3, () => {
34326
34326
  req.destroy();
34327
- resolve15(null);
34327
+ resolve16(null);
34328
34328
  });
34329
34329
  });
34330
34330
  }
34331
34331
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
34332
- return new Promise((resolve15, reject) => {
34332
+ return new Promise((resolve16, reject) => {
34333
34333
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
34334
34334
  const id = this.browserMsgId++;
34335
- this.browserPending.set(id, { resolve: resolve15, reject });
34335
+ this.browserPending.set(id, { resolve: resolve16, reject });
34336
34336
  this.browserWs.send(JSON.stringify({ id, method, params }));
34337
34337
  setTimeout(() => {
34338
34338
  if (this.browserPending.has(id)) {
@@ -34372,11 +34372,11 @@ ${rules.join("\n")}`;
34372
34372
  }
34373
34373
  // ─── CDP Protocol ────────────────────────────────────────
34374
34374
  sendInternal(method, params = {}, timeoutMs = 15e3) {
34375
- return new Promise((resolve15, reject) => {
34375
+ return new Promise((resolve16, reject) => {
34376
34376
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
34377
34377
  if (this.ws.readyState !== import_ws2.default.OPEN) return reject(new Error("WebSocket not open"));
34378
34378
  const id = this.msgId++;
34379
- this.pending.set(id, { resolve: resolve15, reject });
34379
+ this.pending.set(id, { resolve: resolve16, reject });
34380
34380
  this.ws.send(JSON.stringify({ id, method, params }));
34381
34381
  setTimeout(() => {
34382
34382
  if (this.pending.has(id)) {
@@ -34625,7 +34625,7 @@ ${rules.join("\n")}`;
34625
34625
  const browserWs = this.browserWs;
34626
34626
  let msgId = this.browserMsgId;
34627
34627
  const sendWs = (method, params = {}, sessionId) => {
34628
- return new Promise((resolve15, reject) => {
34628
+ return new Promise((resolve16, reject) => {
34629
34629
  const mid = msgId++;
34630
34630
  this.browserMsgId = msgId;
34631
34631
  const handler = (raw) => {
@@ -34634,7 +34634,7 @@ ${rules.join("\n")}`;
34634
34634
  if (msg.id === mid) {
34635
34635
  browserWs.removeListener("message", handler);
34636
34636
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
34637
- else resolve15(msg.result);
34637
+ else resolve16(msg.result);
34638
34638
  }
34639
34639
  } catch {
34640
34640
  }
@@ -34835,14 +34835,14 @@ ${rules.join("\n")}`;
34835
34835
  if (!ws2 || ws2.readyState !== import_ws2.default.OPEN) {
34836
34836
  throw new Error("CDP not connected");
34837
34837
  }
34838
- return new Promise((resolve15, reject) => {
34838
+ return new Promise((resolve16, reject) => {
34839
34839
  const id = getNextId();
34840
34840
  pendingMap.set(id, {
34841
34841
  resolve: (result) => {
34842
34842
  if (result?.result?.subtype === "error") {
34843
34843
  reject(new Error(result.result.description));
34844
34844
  } else {
34845
- resolve15(result?.result?.value);
34845
+ resolve16(result?.result?.value);
34846
34846
  }
34847
34847
  },
34848
34848
  reject
@@ -34874,10 +34874,10 @@ ${rules.join("\n")}`;
34874
34874
  throw new Error("CDP not connected");
34875
34875
  }
34876
34876
  const sendViaSession = (method, params = {}) => {
34877
- return new Promise((resolve15, reject) => {
34877
+ return new Promise((resolve16, reject) => {
34878
34878
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
34879
34879
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
34880
- pendingMap.set(id, { resolve: resolve15, reject });
34880
+ pendingMap.set(id, { resolve: resolve16, reject });
34881
34881
  ws2.send(JSON.stringify({ id, sessionId, method, params }));
34882
34882
  setTimeout(() => {
34883
34883
  if (pendingMap.has(id)) {
@@ -40000,7 +40000,7 @@ ${effect.notification.body || ""}`.trim();
40000
40000
  async function getStableExtensionBaseline(h) {
40001
40001
  const first = await readExtensionChatState(h);
40002
40002
  if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
40003
- await new Promise((resolve15) => setTimeout(resolve15, 150));
40003
+ await new Promise((resolve16) => setTimeout(resolve16, 150));
40004
40004
  const second = await readExtensionChatState(h);
40005
40005
  return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
40006
40006
  }
@@ -40008,7 +40008,7 @@ ${effect.notification.body || ""}`.trim();
40008
40008
  const beforeCount = getStateMessageCount(before);
40009
40009
  const beforeSignature = getStateLastSignature(before);
40010
40010
  for (let attempt = 0; attempt < 12; attempt += 1) {
40011
- await new Promise((resolve15) => setTimeout(resolve15, 250));
40011
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
40012
40012
  const state = await readExtensionChatState(h);
40013
40013
  if (state?.status === "waiting_approval") return true;
40014
40014
  const afterCount = getStateMessageCount(state);
@@ -41631,7 +41631,7 @@ ${effect.notification.body || ""}`.trim();
41631
41631
  const enterCount = cliCommand.enterCount || 1;
41632
41632
  await adapter.writeRaw(cliCommand.text + "\r");
41633
41633
  for (let i = 1; i < enterCount; i += 1) {
41634
- await new Promise((resolve15) => setTimeout(resolve15, 50));
41634
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
41635
41635
  await adapter.writeRaw("\r");
41636
41636
  }
41637
41637
  }
@@ -42312,7 +42312,7 @@ ${effect.notification.body || ""}`.trim();
42312
42312
  try {
42313
42313
  const http3 = await import("http");
42314
42314
  const postData = JSON.stringify(body);
42315
- const result = await new Promise((resolve15, reject) => {
42315
+ const result = await new Promise((resolve16, reject) => {
42316
42316
  const req = http3.request({
42317
42317
  hostname: "127.0.0.1",
42318
42318
  port: 19280,
@@ -42324,9 +42324,9 @@ ${effect.notification.body || ""}`.trim();
42324
42324
  res.on("data", (chunk) => data += chunk);
42325
42325
  res.on("end", () => {
42326
42326
  try {
42327
- resolve15(JSON.parse(data));
42327
+ resolve16(JSON.parse(data));
42328
42328
  } catch {
42329
- resolve15({ raw: data });
42329
+ resolve16({ raw: data });
42330
42330
  }
42331
42331
  });
42332
42332
  });
@@ -42344,15 +42344,15 @@ ${effect.notification.body || ""}`.trim();
42344
42344
  if (!providerType) return { success: false, error: "providerType required" };
42345
42345
  try {
42346
42346
  const http3 = await import("http");
42347
- const result = await new Promise((resolve15, reject) => {
42347
+ const result = await new Promise((resolve16, reject) => {
42348
42348
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
42349
42349
  let data = "";
42350
42350
  res.on("data", (chunk) => data += chunk);
42351
42351
  res.on("end", () => {
42352
42352
  try {
42353
- resolve15(JSON.parse(data));
42353
+ resolve16(JSON.parse(data));
42354
42354
  } catch {
42355
- resolve15({ raw: data });
42355
+ resolve16({ raw: data });
42356
42356
  }
42357
42357
  });
42358
42358
  }).on("error", reject);
@@ -42366,7 +42366,7 @@ ${effect.notification.body || ""}`.trim();
42366
42366
  try {
42367
42367
  const http3 = await import("http");
42368
42368
  const postData = JSON.stringify(args || {});
42369
- const result = await new Promise((resolve15, reject) => {
42369
+ const result = await new Promise((resolve16, reject) => {
42370
42370
  const req = http3.request({
42371
42371
  hostname: "127.0.0.1",
42372
42372
  port: 19280,
@@ -42378,9 +42378,9 @@ ${effect.notification.body || ""}`.trim();
42378
42378
  res.on("data", (chunk) => data += chunk);
42379
42379
  res.on("end", () => {
42380
42380
  try {
42381
- resolve15(JSON.parse(data));
42381
+ resolve16(JSON.parse(data));
42382
42382
  } catch {
42383
- resolve15({ raw: data });
42383
+ resolve16({ raw: data });
42384
42384
  }
42385
42385
  });
42386
42386
  });
@@ -42496,7 +42496,7 @@ ${effect.notification.body || ""}`.trim();
42496
42496
  if (status === "stopped") {
42497
42497
  throw new Error("CLI runtime stopped before it became ready");
42498
42498
  }
42499
- await new Promise((resolve15) => setTimeout(resolve15, pollMs));
42499
+ await new Promise((resolve16) => setTimeout(resolve16, pollMs));
42500
42500
  }
42501
42501
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
42502
42502
  }
@@ -42839,7 +42839,7 @@ ${effect.notification.body || ""}`.trim();
42839
42839
  const enterCount = cliCommand.enterCount || 1;
42840
42840
  await this.adapter.writeRaw(cliCommand.text + "\r");
42841
42841
  for (let i = 1; i < enterCount; i += 1) {
42842
- await new Promise((resolve15) => setTimeout(resolve15, 50));
42842
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
42843
42843
  await this.adapter.writeRaw("\r");
42844
42844
  }
42845
42845
  }
@@ -43942,13 +43942,13 @@ ${effect.notification.body || ""}`.trim();
43942
43942
  }
43943
43943
  this.currentStatus = "waiting_approval";
43944
43944
  this.detectStatusTransition();
43945
- const approved = await new Promise((resolve15) => {
43946
- this.permissionResolvers.push(resolve15);
43945
+ const approved = await new Promise((resolve16) => {
43946
+ this.permissionResolvers.push(resolve16);
43947
43947
  setTimeout(() => {
43948
- const idx = this.permissionResolvers.indexOf(resolve15);
43948
+ const idx = this.permissionResolvers.indexOf(resolve16);
43949
43949
  if (idx >= 0) {
43950
43950
  this.permissionResolvers.splice(idx, 1);
43951
- resolve15(false);
43951
+ resolve16(false);
43952
43952
  }
43953
43953
  }, 3e5);
43954
43954
  });
@@ -46520,7 +46520,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46520
46520
  return { updated: false };
46521
46521
  }
46522
46522
  try {
46523
- const etag = await new Promise((resolve15, reject) => {
46523
+ const etag = await new Promise((resolve16, reject) => {
46524
46524
  const options = {
46525
46525
  method: "HEAD",
46526
46526
  hostname: "github.com",
@@ -46538,7 +46538,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46538
46538
  headers: { "User-Agent": "adhdev-launcher" },
46539
46539
  timeout: 1e4
46540
46540
  }, (res2) => {
46541
- resolve15(res2.headers.etag || res2.headers["last-modified"] || "");
46541
+ resolve16(res2.headers.etag || res2.headers["last-modified"] || "");
46542
46542
  });
46543
46543
  req2.on("error", reject);
46544
46544
  req2.on("timeout", () => {
@@ -46547,7 +46547,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46547
46547
  });
46548
46548
  req2.end();
46549
46549
  } else {
46550
- resolve15(res.headers.etag || res.headers["last-modified"] || "");
46550
+ resolve16(res.headers.etag || res.headers["last-modified"] || "");
46551
46551
  }
46552
46552
  });
46553
46553
  req.on("error", reject);
@@ -46611,7 +46611,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46611
46611
  downloadFile(url2, destPath) {
46612
46612
  const https = require("https");
46613
46613
  const http3 = require("http");
46614
- return new Promise((resolve15, reject) => {
46614
+ return new Promise((resolve16, reject) => {
46615
46615
  const doRequest = (reqUrl, redirectCount = 0) => {
46616
46616
  if (redirectCount > 5) {
46617
46617
  reject(new Error("Too many redirects"));
@@ -46631,7 +46631,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46631
46631
  res.pipe(ws2);
46632
46632
  ws2.on("finish", () => {
46633
46633
  ws2.close();
46634
- resolve15();
46634
+ resolve16();
46635
46635
  });
46636
46636
  ws2.on("error", reject);
46637
46637
  });
@@ -47206,17 +47206,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
47206
47206
  throw new Error("No free port found");
47207
47207
  }
47208
47208
  function checkPortFree(port) {
47209
- return new Promise((resolve15) => {
47209
+ return new Promise((resolve16) => {
47210
47210
  const server = net3.createServer();
47211
47211
  server.unref();
47212
- server.on("error", () => resolve15(false));
47212
+ server.on("error", () => resolve16(false));
47213
47213
  server.listen(port, "127.0.0.1", () => {
47214
- server.close(() => resolve15(true));
47214
+ server.close(() => resolve16(true));
47215
47215
  });
47216
47216
  });
47217
47217
  }
47218
47218
  async function isCdpActive(port) {
47219
- return new Promise((resolve15) => {
47219
+ return new Promise((resolve16) => {
47220
47220
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
47221
47221
  timeout: 2e3
47222
47222
  }, (res) => {
@@ -47225,16 +47225,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
47225
47225
  res.on("end", () => {
47226
47226
  try {
47227
47227
  const info = JSON.parse(data);
47228
- resolve15(!!info["WebKit-Version"] || !!info["Browser"]);
47228
+ resolve16(!!info["WebKit-Version"] || !!info["Browser"]);
47229
47229
  } catch {
47230
- resolve15(false);
47230
+ resolve16(false);
47231
47231
  }
47232
47232
  });
47233
47233
  });
47234
- req.on("error", () => resolve15(false));
47234
+ req.on("error", () => resolve16(false));
47235
47235
  req.on("timeout", () => {
47236
47236
  req.destroy();
47237
- resolve15(false);
47237
+ resolve16(false);
47238
47238
  });
47239
47239
  });
47240
47240
  }
@@ -47702,7 +47702,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
47702
47702
  }
47703
47703
  cleanOldFiles();
47704
47704
  init_logger();
47705
- var import_path4 = require("path");
47705
+ var import_node_fs22 = require("fs");
47706
+ var import_node_module2 = require("module");
47707
+ var import_node_path2 = require("path");
47706
47708
  var DEFAULT_SERVER_NAME = "adhdev-mesh";
47707
47709
  var DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
47708
47710
  function resolveMeshCoordinatorSetup(options) {
@@ -47727,11 +47729,23 @@ Run 'adhdev doctor' for detailed diagnostics.`
47727
47729
  if (!path26) {
47728
47730
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
47729
47731
  }
47732
+ const mcpServer = resolveAdhdevMcpServerLaunch({
47733
+ meshId,
47734
+ nodeExecutable: options.nodeExecutable,
47735
+ adhdevMcpEntryPath: options.adhdevMcpEntryPath
47736
+ });
47737
+ if (!mcpServer) {
47738
+ return {
47739
+ kind: "unsupported",
47740
+ reason: "Could not resolve the ADHDev MCP server entrypoint without relying on a PATH bin shim"
47741
+ };
47742
+ }
47730
47743
  return {
47731
47744
  kind: "auto_import",
47732
47745
  serverName,
47733
- configPath: (0, import_path4.join)(workspace, path26),
47734
- configFormat: mcpConfig.format
47746
+ configPath: (0, import_node_path2.join)(workspace, path26),
47747
+ configFormat: mcpConfig.format,
47748
+ mcpServer
47735
47749
  };
47736
47750
  }
47737
47751
  if (mcpConfig.mode === "manual") {
@@ -47763,6 +47777,53 @@ Run 'adhdev doctor' for detailed diagnostics.`
47763
47777
  function renderMeshCoordinatorTemplate(template, values) {
47764
47778
  return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_, key) => values[key] || "");
47765
47779
  }
47780
+ function resolveAdhdevMcpServerLaunch(options) {
47781
+ const entryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath);
47782
+ if (!entryPath) return null;
47783
+ return {
47784
+ command: options.nodeExecutable?.trim() || process.execPath,
47785
+ args: [entryPath, "--repo-mesh", options.meshId]
47786
+ };
47787
+ }
47788
+ function resolveAdhdevMcpEntryPath(explicitPath) {
47789
+ const explicit = explicitPath?.trim();
47790
+ if (explicit) return normalizeExistingPath(explicit) || explicit;
47791
+ const envPath = process.env.ADHDEV_MCP_SERVER_PATH?.trim();
47792
+ if (envPath) return normalizeExistingPath(envPath) || envPath;
47793
+ const candidates = [];
47794
+ const addCandidate = (candidate) => {
47795
+ if (!candidates.includes(candidate)) candidates.push(candidate);
47796
+ };
47797
+ const addPackagedCandidates = (baseFile) => {
47798
+ if (!baseFile) return;
47799
+ const realBase = normalizeExistingPath(baseFile) || baseFile;
47800
+ const dir = (0, import_node_path2.dirname)(realBase);
47801
+ addCandidate((0, import_node_path2.resolve)(dir, "../vendor/mcp-server/index.js"));
47802
+ addCandidate((0, import_node_path2.resolve)(dir, "../../vendor/mcp-server/index.js"));
47803
+ addCandidate((0, import_node_path2.resolve)(dir, "../../../vendor/mcp-server/index.js"));
47804
+ };
47805
+ addPackagedCandidates(process.argv[1]);
47806
+ for (const candidate of candidates) {
47807
+ const normalized = normalizeExistingPath(candidate);
47808
+ if (normalized) return normalized;
47809
+ }
47810
+ try {
47811
+ const requireBase = process.argv[1] ? normalizeExistingPath(process.argv[1]) || process.argv[1] : (0, import_node_path2.join)(process.cwd(), "adhdev-daemon.js");
47812
+ const req = (0, import_node_module2.createRequire)(requireBase);
47813
+ const resolvedModule = req.resolve("@adhdev/mcp-server");
47814
+ return normalizeExistingPath(resolvedModule) || resolvedModule;
47815
+ } catch {
47816
+ return null;
47817
+ }
47818
+ }
47819
+ function normalizeExistingPath(filePath) {
47820
+ try {
47821
+ if (!(0, import_node_fs22.existsSync)(filePath)) return null;
47822
+ return import_node_fs22.realpathSync.native(filePath);
47823
+ } catch {
47824
+ return null;
47825
+ }
47826
+ }
47766
47827
  var os17 = __toESM2(require("os"));
47767
47828
  init_config();
47768
47829
  init_terminal_screen();
@@ -48266,7 +48327,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
48266
48327
  while (Date.now() - start < timeoutMs) {
48267
48328
  try {
48268
48329
  process.kill(pid, 0);
48269
- await new Promise((resolve15) => setTimeout(resolve15, 250));
48330
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
48270
48331
  } catch {
48271
48332
  return;
48272
48333
  }
@@ -48377,7 +48438,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
48377
48438
  appendUpgradeLog(installOutput.trim());
48378
48439
  }
48379
48440
  if (process.platform === "win32") {
48380
- await new Promise((resolve15) => setTimeout(resolve15, 500));
48441
+ await new Promise((resolve16) => setTimeout(resolve16, 500));
48381
48442
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
48382
48443
  appendUpgradeLog("Post-install staging cleanup complete");
48383
48444
  }
@@ -49261,9 +49322,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
49261
49322
  workspace
49262
49323
  };
49263
49324
  }
49264
- const { existsSync: existsSync21, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
49325
+ const { existsSync: existsSync22, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
49265
49326
  const mcpConfigPath = coordinatorSetup.configPath;
49266
- const hadExistingMcpConfig = existsSync21(mcpConfigPath);
49327
+ const hadExistingMcpConfig = existsSync22(mcpConfigPath);
49267
49328
  let existingMcpConfig = {};
49268
49329
  if (hadExistingMcpConfig) {
49269
49330
  try {
@@ -49277,8 +49338,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
49277
49338
  mcpServers: {
49278
49339
  ...existingMcpConfig.mcpServers || {},
49279
49340
  [coordinatorSetup.serverName]: {
49280
- command: "adhdev-mcp",
49281
- args: ["--repo-mesh", meshId]
49341
+ command: coordinatorSetup.mcpServer.command,
49342
+ args: coordinatorSetup.mcpServer.args
49282
49343
  }
49283
49344
  }
49284
49345
  };
@@ -49920,7 +49981,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
49920
49981
  const beforeCount = this.messageCount(before);
49921
49982
  const beforeSignature = this.lastMessageSignature(before);
49922
49983
  for (let attempt = 0; attempt < 12; attempt += 1) {
49923
- await new Promise((resolve15) => setTimeout(resolve15, 250));
49984
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
49924
49985
  let state;
49925
49986
  try {
49926
49987
  state = await this.readChat(evaluate);
@@ -49942,7 +50003,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
49942
50003
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
49943
50004
  return first;
49944
50005
  }
49945
- await new Promise((resolve15) => setTimeout(resolve15, 150));
50006
+ await new Promise((resolve16) => setTimeout(resolve16, 150));
49946
50007
  const second = await this.readChat(evaluate);
49947
50008
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
49948
50009
  }
@@ -50093,7 +50154,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
50093
50154
  if (typeof data.error === "string" && data.error.trim()) return false;
50094
50155
  }
50095
50156
  for (let attempt = 0; attempt < 6; attempt += 1) {
50096
- await new Promise((resolve15) => setTimeout(resolve15, 250));
50157
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
50097
50158
  const state = await this.readChat(evaluate);
50098
50159
  const title = this.getStateTitle(state);
50099
50160
  if (this.titlesMatch(title, sessionId)) return true;
@@ -52666,7 +52727,7 @@ async (params) => {
52666
52727
  return { target, instance, adapter };
52667
52728
  }
52668
52729
  function sleep(ms2) {
52669
- return new Promise((resolve15) => setTimeout(resolve15, ms2));
52730
+ return new Promise((resolve16) => setTimeout(resolve16, ms2));
52670
52731
  }
52671
52732
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
52672
52733
  const startedAt = Date.now();
@@ -54908,15 +54969,15 @@ data: ${JSON.stringify(msg.data)}
54908
54969
  this.json(res, 500, { error: e.message });
54909
54970
  }
54910
54971
  });
54911
- return new Promise((resolve15, reject) => {
54972
+ return new Promise((resolve16, reject) => {
54912
54973
  this.server.listen(port, "127.0.0.1", () => {
54913
54974
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
54914
- resolve15();
54975
+ resolve16();
54915
54976
  });
54916
54977
  this.server.on("error", (e) => {
54917
54978
  if (e.code === "EADDRINUSE") {
54918
54979
  this.log(`Port ${port} in use, skipping dev server`);
54919
- resolve15();
54980
+ resolve16();
54920
54981
  } else {
54921
54982
  reject(e);
54922
54983
  }
@@ -54998,20 +55059,20 @@ data: ${JSON.stringify(msg.data)}
54998
55059
  child.stderr?.on("data", (d) => {
54999
55060
  stderr += d.toString().slice(0, 2e3);
55000
55061
  });
55001
- await new Promise((resolve15) => {
55062
+ await new Promise((resolve16) => {
55002
55063
  const timer = setTimeout(() => {
55003
55064
  child.kill();
55004
- resolve15();
55065
+ resolve16();
55005
55066
  }, 3e3);
55006
55067
  child.on("exit", () => {
55007
55068
  clearTimeout(timer);
55008
- resolve15();
55069
+ resolve16();
55009
55070
  });
55010
55071
  child.stdout?.once("data", () => {
55011
55072
  setTimeout(() => {
55012
55073
  child.kill();
55013
55074
  clearTimeout(timer);
55014
- resolve15();
55075
+ resolve16();
55015
55076
  }, 500);
55016
55077
  });
55017
55078
  });
@@ -55514,14 +55575,14 @@ data: ${JSON.stringify(msg.data)}
55514
55575
  child.stderr?.on("data", (d) => {
55515
55576
  stderr += d.toString();
55516
55577
  });
55517
- await new Promise((resolve15) => {
55578
+ await new Promise((resolve16) => {
55518
55579
  const timer = setTimeout(() => {
55519
55580
  child.kill();
55520
- resolve15();
55581
+ resolve16();
55521
55582
  }, timeout);
55522
55583
  child.on("exit", () => {
55523
55584
  clearTimeout(timer);
55524
- resolve15();
55585
+ resolve16();
55525
55586
  });
55526
55587
  });
55527
55588
  const elapsed = Date.now() - start;
@@ -56191,14 +56252,14 @@ data: ${JSON.stringify(msg.data)}
56191
56252
  res.end(JSON.stringify(data, null, 2));
56192
56253
  }
56193
56254
  async readBody(req) {
56194
- return new Promise((resolve15) => {
56255
+ return new Promise((resolve16) => {
56195
56256
  let body = "";
56196
56257
  req.on("data", (chunk) => body += chunk);
56197
56258
  req.on("end", () => {
56198
56259
  try {
56199
- resolve15(JSON.parse(body));
56260
+ resolve16(JSON.parse(body));
56200
56261
  } catch {
56201
- resolve15({});
56262
+ resolve16({});
56202
56263
  }
56203
56264
  });
56204
56265
  });
@@ -56700,7 +56761,7 @@ data: ${JSON.stringify(msg.data)}
56700
56761
  const deadline = Date.now() + timeoutMs;
56701
56762
  while (Date.now() < deadline) {
56702
56763
  if (await canConnect(endpoint)) return;
56703
- await new Promise((resolve15) => setTimeout(resolve15, STARTUP_POLL_MS));
56764
+ await new Promise((resolve16) => setTimeout(resolve16, STARTUP_POLL_MS));
56704
56765
  }
56705
56766
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
56706
56767
  }
@@ -56874,10 +56935,10 @@ data: ${JSON.stringify(msg.data)}
56874
56935
  const buffer = Buffer.from(await res.arrayBuffer());
56875
56936
  const fs16 = await import("fs");
56876
56937
  fs16.writeFileSync(vsixPath, buffer);
56877
- return new Promise((resolve15) => {
56938
+ return new Promise((resolve16) => {
56878
56939
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
56879
56940
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
56880
- resolve15({
56941
+ resolve16({
56881
56942
  extensionId: extension.id,
56882
56943
  marketplaceId: extension.marketplaceId,
56883
56944
  success: !error48,
@@ -56890,11 +56951,11 @@ data: ${JSON.stringify(msg.data)}
56890
56951
  } catch (e) {
56891
56952
  }
56892
56953
  }
56893
- return new Promise((resolve15) => {
56954
+ return new Promise((resolve16) => {
56894
56955
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
56895
56956
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
56896
56957
  if (error48) {
56897
- resolve15({
56958
+ resolve16({
56898
56959
  extensionId: extension.id,
56899
56960
  marketplaceId: extension.marketplaceId,
56900
56961
  success: false,
@@ -56902,7 +56963,7 @@ data: ${JSON.stringify(msg.data)}
56902
56963
  error: stderr || error48.message
56903
56964
  });
56904
56965
  } else {
56905
- resolve15({
56966
+ resolve16({
56906
56967
  extensionId: extension.id,
56907
56968
  marketplaceId: extension.marketplaceId,
56908
56969
  success: true,