@adhdev/daemon-core 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
@@ -2226,7 +2226,7 @@ var init_provider_cli_adapter = __esm({
2226
2226
  `[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
2227
2227
  );
2228
2228
  }
2229
- await new Promise((resolve15) => setTimeout(resolve15, 50));
2229
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
2230
2230
  }
2231
2231
  const finalScreenText = this.terminalScreen.getText() || "";
2232
2232
  LOG.warn(
@@ -3136,7 +3136,7 @@ var init_provider_cli_adapter = __esm({
3136
3136
  const deadline = Date.now() + 1e4;
3137
3137
  while (this.startupParseGate && Date.now() < deadline) {
3138
3138
  this.resolveStartupState("send_wait");
3139
- await new Promise((resolve15) => setTimeout(resolve15, 50));
3139
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
3140
3140
  }
3141
3141
  }
3142
3142
  if (!allowInterventionPrompt) {
@@ -3212,13 +3212,13 @@ var init_provider_cli_adapter = __esm({
3212
3212
  }
3213
3213
  this.responseEpoch += 1;
3214
3214
  this.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
3215
- await new Promise((resolve15, reject) => {
3215
+ await new Promise((resolve16, reject) => {
3216
3216
  let resolved = false;
3217
3217
  const completion = {
3218
3218
  resolveOnce: () => {
3219
3219
  if (resolved) return;
3220
3220
  resolved = true;
3221
- resolve15();
3221
+ resolve16();
3222
3222
  },
3223
3223
  rejectOnce: (error) => {
3224
3224
  if (resolved) return;
@@ -3376,17 +3376,17 @@ var init_provider_cli_adapter = __esm({
3376
3376
  }
3377
3377
  }
3378
3378
  waitForStopped(timeoutMs) {
3379
- return new Promise((resolve15) => {
3379
+ return new Promise((resolve16) => {
3380
3380
  const startedAt = Date.now();
3381
3381
  const timer = setInterval(() => {
3382
3382
  if (!this.ptyProcess || this.currentStatus === "stopped") {
3383
3383
  clearInterval(timer);
3384
- resolve15(true);
3384
+ resolve16(true);
3385
3385
  return;
3386
3386
  }
3387
3387
  if (Date.now() - startedAt >= timeoutMs) {
3388
3388
  clearInterval(timer);
3389
- resolve15(false);
3389
+ resolve16(false);
3390
3390
  }
3391
3391
  }, 100);
3392
3392
  });
@@ -5825,8 +5825,8 @@ async function detectIDEs(providerLoader) {
5825
5825
  if ((0, import_fs4.existsSync)(bundledCli)) resolvedCli = bundledCli;
5826
5826
  }
5827
5827
  if (!resolvedCli && appPath && os21 === "win32") {
5828
- const { dirname: dirname7 } = await import("path");
5829
- const appDir = dirname7(appPath);
5828
+ const { dirname: dirname8 } = await import("path");
5829
+ const appDir = dirname8(appPath);
5830
5830
  const candidates = [
5831
5831
  `${appDir}\\\\bin\\\\${def.cli}.cmd`,
5832
5832
  `${appDir}\\\\bin\\\\${def.cli}`,
@@ -5890,19 +5890,19 @@ function resolveCommandPath(command) {
5890
5890
  return null;
5891
5891
  }
5892
5892
  function execAsync(cmd, timeoutMs = 5e3) {
5893
- return new Promise((resolve15) => {
5893
+ return new Promise((resolve16) => {
5894
5894
  const child = (0, import_child_process2.exec)(cmd, {
5895
5895
  encoding: "utf-8",
5896
5896
  timeout: timeoutMs,
5897
5897
  ...process.platform === "win32" ? { windowsHide: true } : {}
5898
5898
  }, (err, stdout) => {
5899
5899
  if (err || !stdout?.trim()) {
5900
- resolve15(null);
5900
+ resolve16(null);
5901
5901
  } else {
5902
- resolve15(stdout.trim());
5902
+ resolve16(stdout.trim());
5903
5903
  }
5904
5904
  });
5905
- child.on("error", () => resolve15(null));
5905
+ child.on("error", () => resolve16(null));
5906
5906
  });
5907
5907
  }
5908
5908
  async function detectCLIs(providerLoader, options) {
@@ -6267,7 +6267,7 @@ var DaemonCdpManager = class {
6267
6267
  * Returns multiple entries if multiple IDE windows are open on same port
6268
6268
  */
6269
6269
  static listAllTargets(port) {
6270
- return new Promise((resolve15) => {
6270
+ return new Promise((resolve16) => {
6271
6271
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
6272
6272
  let data = "";
6273
6273
  res.on("data", (chunk) => data += chunk.toString());
@@ -6283,16 +6283,16 @@ var DaemonCdpManager = class {
6283
6283
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
6284
6284
  );
6285
6285
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
6286
- resolve15(mainPages.length > 0 ? mainPages : fallbackPages);
6286
+ resolve16(mainPages.length > 0 ? mainPages : fallbackPages);
6287
6287
  } catch {
6288
- resolve15([]);
6288
+ resolve16([]);
6289
6289
  }
6290
6290
  });
6291
6291
  });
6292
- req.on("error", () => resolve15([]));
6292
+ req.on("error", () => resolve16([]));
6293
6293
  req.setTimeout(2e3, () => {
6294
6294
  req.destroy();
6295
- resolve15([]);
6295
+ resolve16([]);
6296
6296
  });
6297
6297
  });
6298
6298
  }
@@ -6332,7 +6332,7 @@ var DaemonCdpManager = class {
6332
6332
  }
6333
6333
  }
6334
6334
  findTargetOnPort(port) {
6335
- return new Promise((resolve15) => {
6335
+ return new Promise((resolve16) => {
6336
6336
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
6337
6337
  let data = "";
6338
6338
  res.on("data", (chunk) => data += chunk.toString());
@@ -6343,7 +6343,7 @@ var DaemonCdpManager = class {
6343
6343
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
6344
6344
  );
6345
6345
  if (pages.length === 0) {
6346
- resolve15(targets.find((t) => t.webSocketDebuggerUrl) || null);
6346
+ resolve16(targets.find((t) => t.webSocketDebuggerUrl) || null);
6347
6347
  return;
6348
6348
  }
6349
6349
  const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -6362,25 +6362,25 @@ var DaemonCdpManager = class {
6362
6362
  this._targetId = selected.target.id;
6363
6363
  }
6364
6364
  this._pageTitle = selected.target.title || "";
6365
- resolve15(selected.target);
6365
+ resolve16(selected.target);
6366
6366
  return;
6367
6367
  }
6368
6368
  if (previousTargetId) {
6369
6369
  this.log(`[CDP] Target ${previousTargetId} not found in page list`);
6370
- resolve15(null);
6370
+ resolve16(null);
6371
6371
  return;
6372
6372
  }
6373
6373
  this._pageTitle = list[0]?.title || "";
6374
- resolve15(list[0]);
6374
+ resolve16(list[0]);
6375
6375
  } catch {
6376
- resolve15(null);
6376
+ resolve16(null);
6377
6377
  }
6378
6378
  });
6379
6379
  });
6380
- req.on("error", () => resolve15(null));
6380
+ req.on("error", () => resolve16(null));
6381
6381
  req.setTimeout(2e3, () => {
6382
6382
  req.destroy();
6383
- resolve15(null);
6383
+ resolve16(null);
6384
6384
  });
6385
6385
  });
6386
6386
  }
@@ -6391,7 +6391,7 @@ var DaemonCdpManager = class {
6391
6391
  this.extensionProviders = providers;
6392
6392
  }
6393
6393
  connectToTarget(wsUrl) {
6394
- return new Promise((resolve15) => {
6394
+ return new Promise((resolve16) => {
6395
6395
  this.ws = new import_ws.default(wsUrl);
6396
6396
  this.ws.on("open", async () => {
6397
6397
  this._connected = true;
@@ -6401,17 +6401,17 @@ var DaemonCdpManager = class {
6401
6401
  }
6402
6402
  this.connectBrowserWs().catch(() => {
6403
6403
  });
6404
- resolve15(true);
6404
+ resolve16(true);
6405
6405
  });
6406
6406
  this.ws.on("message", (data) => {
6407
6407
  try {
6408
6408
  const msg = JSON.parse(data.toString());
6409
6409
  if (msg.id && this.pending.has(msg.id)) {
6410
- const { resolve: resolve16, reject } = this.pending.get(msg.id);
6410
+ const { resolve: resolve17, reject } = this.pending.get(msg.id);
6411
6411
  this.pending.delete(msg.id);
6412
6412
  this.failureCount = 0;
6413
6413
  if (msg.error) reject(new Error(msg.error.message));
6414
- else resolve16(msg.result);
6414
+ else resolve17(msg.result);
6415
6415
  } else if (msg.method === "Runtime.executionContextCreated") {
6416
6416
  this.contexts.add(msg.params.context.id);
6417
6417
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -6434,7 +6434,7 @@ var DaemonCdpManager = class {
6434
6434
  this.ws.on("error", (err) => {
6435
6435
  this.log(`[CDP] WebSocket error: ${err.message}`);
6436
6436
  this._connected = false;
6437
- resolve15(false);
6437
+ resolve16(false);
6438
6438
  });
6439
6439
  });
6440
6440
  }
@@ -6448,7 +6448,7 @@ var DaemonCdpManager = class {
6448
6448
  return;
6449
6449
  }
6450
6450
  this.log(`[CDP] Connecting browser WS for target discovery...`);
6451
- await new Promise((resolve15, reject) => {
6451
+ await new Promise((resolve16, reject) => {
6452
6452
  this.browserWs = new import_ws.default(browserWsUrl);
6453
6453
  this.browserWs.on("open", async () => {
6454
6454
  this._browserConnected = true;
@@ -6458,16 +6458,16 @@ var DaemonCdpManager = class {
6458
6458
  } catch (e) {
6459
6459
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
6460
6460
  }
6461
- resolve15();
6461
+ resolve16();
6462
6462
  });
6463
6463
  this.browserWs.on("message", (data) => {
6464
6464
  try {
6465
6465
  const msg = JSON.parse(data.toString());
6466
6466
  if (msg.id && this.browserPending.has(msg.id)) {
6467
- const { resolve: resolve16, reject: reject2 } = this.browserPending.get(msg.id);
6467
+ const { resolve: resolve17, reject: reject2 } = this.browserPending.get(msg.id);
6468
6468
  this.browserPending.delete(msg.id);
6469
6469
  if (msg.error) reject2(new Error(msg.error.message));
6470
- else resolve16(msg.result);
6470
+ else resolve17(msg.result);
6471
6471
  }
6472
6472
  } catch {
6473
6473
  }
@@ -6487,31 +6487,31 @@ var DaemonCdpManager = class {
6487
6487
  }
6488
6488
  }
6489
6489
  getBrowserWsUrl() {
6490
- return new Promise((resolve15) => {
6490
+ return new Promise((resolve16) => {
6491
6491
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
6492
6492
  let data = "";
6493
6493
  res.on("data", (chunk) => data += chunk.toString());
6494
6494
  res.on("end", () => {
6495
6495
  try {
6496
6496
  const info = JSON.parse(data);
6497
- resolve15(info.webSocketDebuggerUrl || null);
6497
+ resolve16(info.webSocketDebuggerUrl || null);
6498
6498
  } catch {
6499
- resolve15(null);
6499
+ resolve16(null);
6500
6500
  }
6501
6501
  });
6502
6502
  });
6503
- req.on("error", () => resolve15(null));
6503
+ req.on("error", () => resolve16(null));
6504
6504
  req.setTimeout(3e3, () => {
6505
6505
  req.destroy();
6506
- resolve15(null);
6506
+ resolve16(null);
6507
6507
  });
6508
6508
  });
6509
6509
  }
6510
6510
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
6511
- return new Promise((resolve15, reject) => {
6511
+ return new Promise((resolve16, reject) => {
6512
6512
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
6513
6513
  const id = this.browserMsgId++;
6514
- this.browserPending.set(id, { resolve: resolve15, reject });
6514
+ this.browserPending.set(id, { resolve: resolve16, reject });
6515
6515
  this.browserWs.send(JSON.stringify({ id, method, params }));
6516
6516
  setTimeout(() => {
6517
6517
  if (this.browserPending.has(id)) {
@@ -6551,11 +6551,11 @@ var DaemonCdpManager = class {
6551
6551
  }
6552
6552
  // ─── CDP Protocol ────────────────────────────────────────
6553
6553
  sendInternal(method, params = {}, timeoutMs = 15e3) {
6554
- return new Promise((resolve15, reject) => {
6554
+ return new Promise((resolve16, reject) => {
6555
6555
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
6556
6556
  if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
6557
6557
  const id = this.msgId++;
6558
- this.pending.set(id, { resolve: resolve15, reject });
6558
+ this.pending.set(id, { resolve: resolve16, reject });
6559
6559
  this.ws.send(JSON.stringify({ id, method, params }));
6560
6560
  setTimeout(() => {
6561
6561
  if (this.pending.has(id)) {
@@ -6804,7 +6804,7 @@ var DaemonCdpManager = class {
6804
6804
  const browserWs = this.browserWs;
6805
6805
  let msgId = this.browserMsgId;
6806
6806
  const sendWs = (method, params = {}, sessionId) => {
6807
- return new Promise((resolve15, reject) => {
6807
+ return new Promise((resolve16, reject) => {
6808
6808
  const mid = msgId++;
6809
6809
  this.browserMsgId = msgId;
6810
6810
  const handler = (raw) => {
@@ -6813,7 +6813,7 @@ var DaemonCdpManager = class {
6813
6813
  if (msg.id === mid) {
6814
6814
  browserWs.removeListener("message", handler);
6815
6815
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
6816
- else resolve15(msg.result);
6816
+ else resolve16(msg.result);
6817
6817
  }
6818
6818
  } catch {
6819
6819
  }
@@ -7014,14 +7014,14 @@ var DaemonCdpManager = class {
7014
7014
  if (!ws || ws.readyState !== import_ws.default.OPEN) {
7015
7015
  throw new Error("CDP not connected");
7016
7016
  }
7017
- return new Promise((resolve15, reject) => {
7017
+ return new Promise((resolve16, reject) => {
7018
7018
  const id = getNextId();
7019
7019
  pendingMap.set(id, {
7020
7020
  resolve: (result) => {
7021
7021
  if (result?.result?.subtype === "error") {
7022
7022
  reject(new Error(result.result.description));
7023
7023
  } else {
7024
- resolve15(result?.result?.value);
7024
+ resolve16(result?.result?.value);
7025
7025
  }
7026
7026
  },
7027
7027
  reject
@@ -7053,10 +7053,10 @@ var DaemonCdpManager = class {
7053
7053
  throw new Error("CDP not connected");
7054
7054
  }
7055
7055
  const sendViaSession = (method, params = {}) => {
7056
- return new Promise((resolve15, reject) => {
7056
+ return new Promise((resolve16, reject) => {
7057
7057
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
7058
7058
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
7059
- pendingMap.set(id, { resolve: resolve15, reject });
7059
+ pendingMap.set(id, { resolve: resolve16, reject });
7060
7060
  ws.send(JSON.stringify({ id, sessionId, method, params }));
7061
7061
  setTimeout(() => {
7062
7062
  if (pendingMap.has(id)) {
@@ -12241,7 +12241,7 @@ function getCliVisibleTranscriptCount(adapter) {
12241
12241
  async function getStableExtensionBaseline(h) {
12242
12242
  const first = await readExtensionChatState(h);
12243
12243
  if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
12244
- await new Promise((resolve15) => setTimeout(resolve15, 150));
12244
+ await new Promise((resolve16) => setTimeout(resolve16, 150));
12245
12245
  const second = await readExtensionChatState(h);
12246
12246
  return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
12247
12247
  }
@@ -12249,7 +12249,7 @@ async function verifyExtensionSendObserved(h, before) {
12249
12249
  const beforeCount = getStateMessageCount(before);
12250
12250
  const beforeSignature = getStateLastSignature(before);
12251
12251
  for (let attempt = 0; attempt < 12; attempt += 1) {
12252
- await new Promise((resolve15) => setTimeout(resolve15, 250));
12252
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
12253
12253
  const state = await readExtensionChatState(h);
12254
12254
  if (state?.status === "waiting_approval") return true;
12255
12255
  const afterCount = getStateMessageCount(state);
@@ -13882,7 +13882,7 @@ async function executeProviderScript(h, args, scriptName) {
13882
13882
  const enterCount = cliCommand.enterCount || 1;
13883
13883
  await adapter.writeRaw(cliCommand.text + "\r");
13884
13884
  for (let i = 1; i < enterCount; i += 1) {
13885
- await new Promise((resolve15) => setTimeout(resolve15, 50));
13885
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
13886
13886
  await adapter.writeRaw("\r");
13887
13887
  }
13888
13888
  }
@@ -14567,7 +14567,7 @@ var DaemonCommandHandler = class {
14567
14567
  try {
14568
14568
  const http3 = await import("http");
14569
14569
  const postData = JSON.stringify(body);
14570
- const result = await new Promise((resolve15, reject) => {
14570
+ const result = await new Promise((resolve16, reject) => {
14571
14571
  const req = http3.request({
14572
14572
  hostname: "127.0.0.1",
14573
14573
  port: 19280,
@@ -14579,9 +14579,9 @@ var DaemonCommandHandler = class {
14579
14579
  res.on("data", (chunk) => data += chunk);
14580
14580
  res.on("end", () => {
14581
14581
  try {
14582
- resolve15(JSON.parse(data));
14582
+ resolve16(JSON.parse(data));
14583
14583
  } catch {
14584
- resolve15({ raw: data });
14584
+ resolve16({ raw: data });
14585
14585
  }
14586
14586
  });
14587
14587
  });
@@ -14599,15 +14599,15 @@ var DaemonCommandHandler = class {
14599
14599
  if (!providerType) return { success: false, error: "providerType required" };
14600
14600
  try {
14601
14601
  const http3 = await import("http");
14602
- const result = await new Promise((resolve15, reject) => {
14602
+ const result = await new Promise((resolve16, reject) => {
14603
14603
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
14604
14604
  let data = "";
14605
14605
  res.on("data", (chunk) => data += chunk);
14606
14606
  res.on("end", () => {
14607
14607
  try {
14608
- resolve15(JSON.parse(data));
14608
+ resolve16(JSON.parse(data));
14609
14609
  } catch {
14610
- resolve15({ raw: data });
14610
+ resolve16({ raw: data });
14611
14611
  }
14612
14612
  });
14613
14613
  }).on("error", reject);
@@ -14621,7 +14621,7 @@ var DaemonCommandHandler = class {
14621
14621
  try {
14622
14622
  const http3 = await import("http");
14623
14623
  const postData = JSON.stringify(args || {});
14624
- const result = await new Promise((resolve15, reject) => {
14624
+ const result = await new Promise((resolve16, reject) => {
14625
14625
  const req = http3.request({
14626
14626
  hostname: "127.0.0.1",
14627
14627
  port: 19280,
@@ -14633,9 +14633,9 @@ var DaemonCommandHandler = class {
14633
14633
  res.on("data", (chunk) => data += chunk);
14634
14634
  res.on("end", () => {
14635
14635
  try {
14636
- resolve15(JSON.parse(data));
14636
+ resolve16(JSON.parse(data));
14637
14637
  } catch {
14638
- resolve15({ raw: data });
14638
+ resolve16({ raw: data });
14639
14639
  }
14640
14640
  });
14641
14641
  });
@@ -14759,7 +14759,7 @@ async function waitForCliAdapterReady(adapter, options) {
14759
14759
  if (status === "stopped") {
14760
14760
  throw new Error("CLI runtime stopped before it became ready");
14761
14761
  }
14762
- await new Promise((resolve15) => setTimeout(resolve15, pollMs));
14762
+ await new Promise((resolve16) => setTimeout(resolve16, pollMs));
14763
14763
  }
14764
14764
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
14765
14765
  }
@@ -15102,7 +15102,7 @@ var CliProviderInstance = class {
15102
15102
  const enterCount = cliCommand.enterCount || 1;
15103
15103
  await this.adapter.writeRaw(cliCommand.text + "\r");
15104
15104
  for (let i = 1; i < enterCount; i += 1) {
15105
- await new Promise((resolve15) => setTimeout(resolve15, 50));
15105
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
15106
15106
  await this.adapter.writeRaw("\r");
15107
15107
  }
15108
15108
  }
@@ -16207,13 +16207,13 @@ var AcpProviderInstance = class {
16207
16207
  }
16208
16208
  this.currentStatus = "waiting_approval";
16209
16209
  this.detectStatusTransition();
16210
- const approved = await new Promise((resolve15) => {
16211
- this.permissionResolvers.push(resolve15);
16210
+ const approved = await new Promise((resolve16) => {
16211
+ this.permissionResolvers.push(resolve16);
16212
16212
  setTimeout(() => {
16213
- const idx = this.permissionResolvers.indexOf(resolve15);
16213
+ const idx = this.permissionResolvers.indexOf(resolve16);
16214
16214
  if (idx >= 0) {
16215
16215
  this.permissionResolvers.splice(idx, 1);
16216
- resolve15(false);
16216
+ resolve16(false);
16217
16217
  }
16218
16218
  }, 3e5);
16219
16219
  });
@@ -18799,7 +18799,7 @@ var ProviderLoader = class _ProviderLoader {
18799
18799
  return { updated: false };
18800
18800
  }
18801
18801
  try {
18802
- const etag = await new Promise((resolve15, reject) => {
18802
+ const etag = await new Promise((resolve16, reject) => {
18803
18803
  const options = {
18804
18804
  method: "HEAD",
18805
18805
  hostname: "github.com",
@@ -18817,7 +18817,7 @@ var ProviderLoader = class _ProviderLoader {
18817
18817
  headers: { "User-Agent": "adhdev-launcher" },
18818
18818
  timeout: 1e4
18819
18819
  }, (res2) => {
18820
- resolve15(res2.headers.etag || res2.headers["last-modified"] || "");
18820
+ resolve16(res2.headers.etag || res2.headers["last-modified"] || "");
18821
18821
  });
18822
18822
  req2.on("error", reject);
18823
18823
  req2.on("timeout", () => {
@@ -18826,7 +18826,7 @@ var ProviderLoader = class _ProviderLoader {
18826
18826
  });
18827
18827
  req2.end();
18828
18828
  } else {
18829
- resolve15(res.headers.etag || res.headers["last-modified"] || "");
18829
+ resolve16(res.headers.etag || res.headers["last-modified"] || "");
18830
18830
  }
18831
18831
  });
18832
18832
  req.on("error", reject);
@@ -18890,7 +18890,7 @@ var ProviderLoader = class _ProviderLoader {
18890
18890
  downloadFile(url, destPath) {
18891
18891
  const https = require("https");
18892
18892
  const http3 = require("http");
18893
- return new Promise((resolve15, reject) => {
18893
+ return new Promise((resolve16, reject) => {
18894
18894
  const doRequest = (reqUrl, redirectCount = 0) => {
18895
18895
  if (redirectCount > 5) {
18896
18896
  reject(new Error("Too many redirects"));
@@ -18910,7 +18910,7 @@ var ProviderLoader = class _ProviderLoader {
18910
18910
  res.pipe(ws);
18911
18911
  ws.on("finish", () => {
18912
18912
  ws.close();
18913
- resolve15();
18913
+ resolve16();
18914
18914
  });
18915
18915
  ws.on("error", reject);
18916
18916
  });
@@ -19489,17 +19489,17 @@ async function findFreePort(ports) {
19489
19489
  throw new Error("No free port found");
19490
19490
  }
19491
19491
  function checkPortFree(port) {
19492
- return new Promise((resolve15) => {
19492
+ return new Promise((resolve16) => {
19493
19493
  const server = net.createServer();
19494
19494
  server.unref();
19495
- server.on("error", () => resolve15(false));
19495
+ server.on("error", () => resolve16(false));
19496
19496
  server.listen(port, "127.0.0.1", () => {
19497
- server.close(() => resolve15(true));
19497
+ server.close(() => resolve16(true));
19498
19498
  });
19499
19499
  });
19500
19500
  }
19501
19501
  async function isCdpActive(port) {
19502
- return new Promise((resolve15) => {
19502
+ return new Promise((resolve16) => {
19503
19503
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
19504
19504
  timeout: 2e3
19505
19505
  }, (res) => {
@@ -19508,16 +19508,16 @@ async function isCdpActive(port) {
19508
19508
  res.on("end", () => {
19509
19509
  try {
19510
19510
  const info = JSON.parse(data);
19511
- resolve15(!!info["WebKit-Version"] || !!info["Browser"]);
19511
+ resolve16(!!info["WebKit-Version"] || !!info["Browser"]);
19512
19512
  } catch {
19513
- resolve15(false);
19513
+ resolve16(false);
19514
19514
  }
19515
19515
  });
19516
19516
  });
19517
- req.on("error", () => resolve15(false));
19517
+ req.on("error", () => resolve16(false));
19518
19518
  req.on("timeout", () => {
19519
19519
  req.destroy();
19520
- resolve15(false);
19520
+ resolve16(false);
19521
19521
  });
19522
19522
  });
19523
19523
  }
@@ -19993,7 +19993,9 @@ cleanOldFiles();
19993
19993
  init_logger();
19994
19994
 
19995
19995
  // src/commands/mesh-coordinator.ts
19996
- var import_path4 = require("path");
19996
+ var import_node_fs2 = require("fs");
19997
+ var import_node_module2 = require("module");
19998
+ var import_node_path = require("path");
19997
19999
  var DEFAULT_SERVER_NAME = "adhdev-mesh";
19998
20000
  var DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
19999
20001
  function resolveMeshCoordinatorSetup(options) {
@@ -20018,11 +20020,23 @@ function resolveMeshCoordinatorSetup(options) {
20018
20020
  if (!path26) {
20019
20021
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
20020
20022
  }
20023
+ const mcpServer = resolveAdhdevMcpServerLaunch({
20024
+ meshId,
20025
+ nodeExecutable: options.nodeExecutable,
20026
+ adhdevMcpEntryPath: options.adhdevMcpEntryPath
20027
+ });
20028
+ if (!mcpServer) {
20029
+ return {
20030
+ kind: "unsupported",
20031
+ reason: "Could not resolve the ADHDev MCP server entrypoint without relying on a PATH bin shim"
20032
+ };
20033
+ }
20021
20034
  return {
20022
20035
  kind: "auto_import",
20023
20036
  serverName,
20024
- configPath: (0, import_path4.join)(workspace, path26),
20025
- configFormat: mcpConfig.format
20037
+ configPath: (0, import_node_path.join)(workspace, path26),
20038
+ configFormat: mcpConfig.format,
20039
+ mcpServer
20026
20040
  };
20027
20041
  }
20028
20042
  if (mcpConfig.mode === "manual") {
@@ -20054,6 +20068,53 @@ function resolveMeshCoordinatorSetup(options) {
20054
20068
  function renderMeshCoordinatorTemplate(template, values) {
20055
20069
  return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_, key) => values[key] || "");
20056
20070
  }
20071
+ function resolveAdhdevMcpServerLaunch(options) {
20072
+ const entryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath);
20073
+ if (!entryPath) return null;
20074
+ return {
20075
+ command: options.nodeExecutable?.trim() || process.execPath,
20076
+ args: [entryPath, "--repo-mesh", options.meshId]
20077
+ };
20078
+ }
20079
+ function resolveAdhdevMcpEntryPath(explicitPath) {
20080
+ const explicit = explicitPath?.trim();
20081
+ if (explicit) return normalizeExistingPath(explicit) || explicit;
20082
+ const envPath = process.env.ADHDEV_MCP_SERVER_PATH?.trim();
20083
+ if (envPath) return normalizeExistingPath(envPath) || envPath;
20084
+ const candidates = [];
20085
+ const addCandidate = (candidate) => {
20086
+ if (!candidates.includes(candidate)) candidates.push(candidate);
20087
+ };
20088
+ const addPackagedCandidates = (baseFile) => {
20089
+ if (!baseFile) return;
20090
+ const realBase = normalizeExistingPath(baseFile) || baseFile;
20091
+ const dir = (0, import_node_path.dirname)(realBase);
20092
+ addCandidate((0, import_node_path.resolve)(dir, "../vendor/mcp-server/index.js"));
20093
+ addCandidate((0, import_node_path.resolve)(dir, "../../vendor/mcp-server/index.js"));
20094
+ addCandidate((0, import_node_path.resolve)(dir, "../../../vendor/mcp-server/index.js"));
20095
+ };
20096
+ addPackagedCandidates(process.argv[1]);
20097
+ for (const candidate of candidates) {
20098
+ const normalized = normalizeExistingPath(candidate);
20099
+ if (normalized) return normalized;
20100
+ }
20101
+ try {
20102
+ const requireBase = process.argv[1] ? normalizeExistingPath(process.argv[1]) || process.argv[1] : (0, import_node_path.join)(process.cwd(), "adhdev-daemon.js");
20103
+ const req = (0, import_node_module2.createRequire)(requireBase);
20104
+ const resolvedModule = req.resolve("@adhdev/mcp-server");
20105
+ return normalizeExistingPath(resolvedModule) || resolvedModule;
20106
+ } catch {
20107
+ return null;
20108
+ }
20109
+ }
20110
+ function normalizeExistingPath(filePath) {
20111
+ try {
20112
+ if (!(0, import_node_fs2.existsSync)(filePath)) return null;
20113
+ return import_node_fs2.realpathSync.native(filePath);
20114
+ } catch {
20115
+ return null;
20116
+ }
20117
+ }
20057
20118
 
20058
20119
  // src/status/snapshot.ts
20059
20120
  var os17 = __toESM(require("os"));
@@ -20561,7 +20622,7 @@ async function waitForPidExit(pid, timeoutMs) {
20561
20622
  while (Date.now() - start < timeoutMs) {
20562
20623
  try {
20563
20624
  process.kill(pid, 0);
20564
- await new Promise((resolve15) => setTimeout(resolve15, 250));
20625
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
20565
20626
  } catch {
20566
20627
  return;
20567
20628
  }
@@ -20672,7 +20733,7 @@ async function runDaemonUpgradeHelper(payload) {
20672
20733
  appendUpgradeLog(installOutput.trim());
20673
20734
  }
20674
20735
  if (process.platform === "win32") {
20675
- await new Promise((resolve15) => setTimeout(resolve15, 500));
20736
+ await new Promise((resolve16) => setTimeout(resolve16, 500));
20676
20737
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
20677
20738
  appendUpgradeLog("Post-install staging cleanup complete");
20678
20739
  }
@@ -21558,9 +21619,9 @@ var DaemonCommandRouter = class {
21558
21619
  workspace
21559
21620
  };
21560
21621
  }
21561
- const { existsSync: existsSync21, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
21622
+ const { existsSync: existsSync22, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
21562
21623
  const mcpConfigPath = coordinatorSetup.configPath;
21563
- const hadExistingMcpConfig = existsSync21(mcpConfigPath);
21624
+ const hadExistingMcpConfig = existsSync22(mcpConfigPath);
21564
21625
  let existingMcpConfig = {};
21565
21626
  if (hadExistingMcpConfig) {
21566
21627
  try {
@@ -21574,8 +21635,8 @@ var DaemonCommandRouter = class {
21574
21635
  mcpServers: {
21575
21636
  ...existingMcpConfig.mcpServers || {},
21576
21637
  [coordinatorSetup.serverName]: {
21577
- command: "adhdev-mcp",
21578
- args: ["--repo-mesh", meshId]
21638
+ command: coordinatorSetup.mcpServer.command,
21639
+ args: coordinatorSetup.mcpServer.args
21579
21640
  }
21580
21641
  }
21581
21642
  };
@@ -22229,7 +22290,7 @@ var ProviderStreamAdapter = class {
22229
22290
  const beforeCount = this.messageCount(before);
22230
22291
  const beforeSignature = this.lastMessageSignature(before);
22231
22292
  for (let attempt = 0; attempt < 12; attempt += 1) {
22232
- await new Promise((resolve15) => setTimeout(resolve15, 250));
22293
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
22233
22294
  let state;
22234
22295
  try {
22235
22296
  state = await this.readChat(evaluate);
@@ -22251,7 +22312,7 @@ var ProviderStreamAdapter = class {
22251
22312
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
22252
22313
  return first;
22253
22314
  }
22254
- await new Promise((resolve15) => setTimeout(resolve15, 150));
22315
+ await new Promise((resolve16) => setTimeout(resolve16, 150));
22255
22316
  const second = await this.readChat(evaluate);
22256
22317
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
22257
22318
  }
@@ -22402,7 +22463,7 @@ var ProviderStreamAdapter = class {
22402
22463
  if (typeof data.error === "string" && data.error.trim()) return false;
22403
22464
  }
22404
22465
  for (let attempt = 0; attempt < 6; attempt += 1) {
22405
- await new Promise((resolve15) => setTimeout(resolve15, 250));
22466
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
22406
22467
  const state = await this.readChat(evaluate);
22407
22468
  const title = this.getStateTitle(state);
22408
22469
  if (this.titlesMatch(title, sessionId)) return true;
@@ -24995,7 +25056,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
24995
25056
  return { target, instance, adapter };
24996
25057
  }
24997
25058
  function sleep(ms) {
24998
- return new Promise((resolve15) => setTimeout(resolve15, ms));
25059
+ return new Promise((resolve16) => setTimeout(resolve16, ms));
24999
25060
  }
25000
25061
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
25001
25062
  const startedAt = Date.now();
@@ -27241,15 +27302,15 @@ var DevServer = class _DevServer {
27241
27302
  this.json(res, 500, { error: e.message });
27242
27303
  }
27243
27304
  });
27244
- return new Promise((resolve15, reject) => {
27305
+ return new Promise((resolve16, reject) => {
27245
27306
  this.server.listen(port, "127.0.0.1", () => {
27246
27307
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
27247
- resolve15();
27308
+ resolve16();
27248
27309
  });
27249
27310
  this.server.on("error", (e) => {
27250
27311
  if (e.code === "EADDRINUSE") {
27251
27312
  this.log(`Port ${port} in use, skipping dev server`);
27252
- resolve15();
27313
+ resolve16();
27253
27314
  } else {
27254
27315
  reject(e);
27255
27316
  }
@@ -27331,20 +27392,20 @@ var DevServer = class _DevServer {
27331
27392
  child.stderr?.on("data", (d) => {
27332
27393
  stderr += d.toString().slice(0, 2e3);
27333
27394
  });
27334
- await new Promise((resolve15) => {
27395
+ await new Promise((resolve16) => {
27335
27396
  const timer = setTimeout(() => {
27336
27397
  child.kill();
27337
- resolve15();
27398
+ resolve16();
27338
27399
  }, 3e3);
27339
27400
  child.on("exit", () => {
27340
27401
  clearTimeout(timer);
27341
- resolve15();
27402
+ resolve16();
27342
27403
  });
27343
27404
  child.stdout?.once("data", () => {
27344
27405
  setTimeout(() => {
27345
27406
  child.kill();
27346
27407
  clearTimeout(timer);
27347
- resolve15();
27408
+ resolve16();
27348
27409
  }, 500);
27349
27410
  });
27350
27411
  });
@@ -27847,14 +27908,14 @@ var DevServer = class _DevServer {
27847
27908
  child.stderr?.on("data", (d) => {
27848
27909
  stderr += d.toString();
27849
27910
  });
27850
- await new Promise((resolve15) => {
27911
+ await new Promise((resolve16) => {
27851
27912
  const timer = setTimeout(() => {
27852
27913
  child.kill();
27853
- resolve15();
27914
+ resolve16();
27854
27915
  }, timeout);
27855
27916
  child.on("exit", () => {
27856
27917
  clearTimeout(timer);
27857
- resolve15();
27918
+ resolve16();
27858
27919
  });
27859
27920
  });
27860
27921
  const elapsed = Date.now() - start;
@@ -28524,14 +28585,14 @@ data: ${JSON.stringify(msg.data)}
28524
28585
  res.end(JSON.stringify(data, null, 2));
28525
28586
  }
28526
28587
  async readBody(req) {
28527
- return new Promise((resolve15) => {
28588
+ return new Promise((resolve16) => {
28528
28589
  let body = "";
28529
28590
  req.on("data", (chunk) => body += chunk);
28530
28591
  req.on("end", () => {
28531
28592
  try {
28532
- resolve15(JSON.parse(body));
28593
+ resolve16(JSON.parse(body));
28533
28594
  } catch {
28534
- resolve15({});
28595
+ resolve16({});
28535
28596
  }
28536
28597
  });
28537
28598
  });
@@ -29041,7 +29102,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
29041
29102
  const deadline = Date.now() + timeoutMs;
29042
29103
  while (Date.now() < deadline) {
29043
29104
  if (await canConnect(endpoint)) return;
29044
- await new Promise((resolve15) => setTimeout(resolve15, STARTUP_POLL_MS));
29105
+ await new Promise((resolve16) => setTimeout(resolve16, STARTUP_POLL_MS));
29045
29106
  }
29046
29107
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
29047
29108
  }
@@ -29219,10 +29280,10 @@ async function installExtension(ide, extension) {
29219
29280
  const buffer = Buffer.from(await res.arrayBuffer());
29220
29281
  const fs16 = await import("fs");
29221
29282
  fs16.writeFileSync(vsixPath, buffer);
29222
- return new Promise((resolve15) => {
29283
+ return new Promise((resolve16) => {
29223
29284
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
29224
29285
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
29225
- resolve15({
29286
+ resolve16({
29226
29287
  extensionId: extension.id,
29227
29288
  marketplaceId: extension.marketplaceId,
29228
29289
  success: !error,
@@ -29235,11 +29296,11 @@ async function installExtension(ide, extension) {
29235
29296
  } catch (e) {
29236
29297
  }
29237
29298
  }
29238
- return new Promise((resolve15) => {
29299
+ return new Promise((resolve16) => {
29239
29300
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
29240
29301
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error, stdout, stderr) => {
29241
29302
  if (error) {
29242
- resolve15({
29303
+ resolve16({
29243
29304
  extensionId: extension.id,
29244
29305
  marketplaceId: extension.marketplaceId,
29245
29306
  success: false,
@@ -29247,7 +29308,7 @@ async function installExtension(ide, extension) {
29247
29308
  error: stderr || error.message
29248
29309
  });
29249
29310
  } else {
29250
- resolve15({
29311
+ resolve16({
29251
29312
  extensionId: extension.id,
29252
29313
  marketplaceId: extension.marketplaceId,
29253
29314
  success: true,