adhdev 0.9.70 → 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
@@ -2656,8 +2656,8 @@ async function detectIDEs(providerLoader) {
2656
2656
  if ((0, import_fs4.existsSync)(bundledCli)) resolvedCli = bundledCli;
2657
2657
  }
2658
2658
  if (!resolvedCli && appPath && os29 === "win32") {
2659
- const { dirname: dirname10 } = await import("path");
2660
- const appDir = dirname10(appPath);
2659
+ const { dirname: dirname11 } = await import("path");
2660
+ const appDir = dirname11(appPath);
2661
2661
  const candidates = [
2662
2662
  `${appDir}\\\\bin\\\\${def.cli}.cmd`,
2663
2663
  `${appDir}\\\\bin\\\\${def.cli}`,
@@ -2729,19 +2729,19 @@ function resolveCommandPath(command) {
2729
2729
  return null;
2730
2730
  }
2731
2731
  function execAsync(cmd, timeoutMs = 5e3) {
2732
- return new Promise((resolve19) => {
2732
+ return new Promise((resolve20) => {
2733
2733
  const child = (0, import_child_process2.exec)(cmd, {
2734
2734
  encoding: "utf-8",
2735
2735
  timeout: timeoutMs,
2736
2736
  ...process.platform === "win32" ? { windowsHide: true } : {}
2737
2737
  }, (err, stdout) => {
2738
2738
  if (err || !stdout?.trim()) {
2739
- resolve19(null);
2739
+ resolve20(null);
2740
2740
  } else {
2741
- resolve19(stdout.trim());
2741
+ resolve20(stdout.trim());
2742
2742
  }
2743
2743
  });
2744
- child.on("error", () => resolve19(null));
2744
+ child.on("error", () => resolve20(null));
2745
2745
  });
2746
2746
  }
2747
2747
  async function detectCLIs(providerLoader, options) {
@@ -3353,7 +3353,7 @@ var init_manager = __esm({
3353
3353
  * Returns multiple entries if multiple IDE windows are open on same port
3354
3354
  */
3355
3355
  static listAllTargets(port) {
3356
- return new Promise((resolve19) => {
3356
+ return new Promise((resolve20) => {
3357
3357
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
3358
3358
  let data = "";
3359
3359
  res.on("data", (chunk) => data += chunk.toString());
@@ -3369,16 +3369,16 @@ var init_manager = __esm({
3369
3369
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
3370
3370
  );
3371
3371
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
3372
- resolve19(mainPages.length > 0 ? mainPages : fallbackPages);
3372
+ resolve20(mainPages.length > 0 ? mainPages : fallbackPages);
3373
3373
  } catch {
3374
- resolve19([]);
3374
+ resolve20([]);
3375
3375
  }
3376
3376
  });
3377
3377
  });
3378
- req.on("error", () => resolve19([]));
3378
+ req.on("error", () => resolve20([]));
3379
3379
  req.setTimeout(2e3, () => {
3380
3380
  req.destroy();
3381
- resolve19([]);
3381
+ resolve20([]);
3382
3382
  });
3383
3383
  });
3384
3384
  }
@@ -3418,7 +3418,7 @@ var init_manager = __esm({
3418
3418
  }
3419
3419
  }
3420
3420
  findTargetOnPort(port) {
3421
- return new Promise((resolve19) => {
3421
+ return new Promise((resolve20) => {
3422
3422
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
3423
3423
  let data = "";
3424
3424
  res.on("data", (chunk) => data += chunk.toString());
@@ -3429,7 +3429,7 @@ var init_manager = __esm({
3429
3429
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
3430
3430
  );
3431
3431
  if (pages.length === 0) {
3432
- resolve19(targets.find((t) => t.webSocketDebuggerUrl) || null);
3432
+ resolve20(targets.find((t) => t.webSocketDebuggerUrl) || null);
3433
3433
  return;
3434
3434
  }
3435
3435
  const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -3448,25 +3448,25 @@ var init_manager = __esm({
3448
3448
  this._targetId = selected.target.id;
3449
3449
  }
3450
3450
  this._pageTitle = selected.target.title || "";
3451
- resolve19(selected.target);
3451
+ resolve20(selected.target);
3452
3452
  return;
3453
3453
  }
3454
3454
  if (previousTargetId) {
3455
3455
  this.log(`[CDP] Target ${previousTargetId} not found in page list`);
3456
- resolve19(null);
3456
+ resolve20(null);
3457
3457
  return;
3458
3458
  }
3459
3459
  this._pageTitle = list[0]?.title || "";
3460
- resolve19(list[0]);
3460
+ resolve20(list[0]);
3461
3461
  } catch {
3462
- resolve19(null);
3462
+ resolve20(null);
3463
3463
  }
3464
3464
  });
3465
3465
  });
3466
- req.on("error", () => resolve19(null));
3466
+ req.on("error", () => resolve20(null));
3467
3467
  req.setTimeout(2e3, () => {
3468
3468
  req.destroy();
3469
- resolve19(null);
3469
+ resolve20(null);
3470
3470
  });
3471
3471
  });
3472
3472
  }
@@ -3477,7 +3477,7 @@ var init_manager = __esm({
3477
3477
  this.extensionProviders = providers;
3478
3478
  }
3479
3479
  connectToTarget(wsUrl) {
3480
- return new Promise((resolve19) => {
3480
+ return new Promise((resolve20) => {
3481
3481
  this.ws = new import_ws.default(wsUrl);
3482
3482
  this.ws.on("open", async () => {
3483
3483
  this._connected = true;
@@ -3487,17 +3487,17 @@ var init_manager = __esm({
3487
3487
  }
3488
3488
  this.connectBrowserWs().catch(() => {
3489
3489
  });
3490
- resolve19(true);
3490
+ resolve20(true);
3491
3491
  });
3492
3492
  this.ws.on("message", (data) => {
3493
3493
  try {
3494
3494
  const msg = JSON.parse(data.toString());
3495
3495
  if (msg.id && this.pending.has(msg.id)) {
3496
- const { resolve: resolve20, reject } = this.pending.get(msg.id);
3496
+ const { resolve: resolve21, reject } = this.pending.get(msg.id);
3497
3497
  this.pending.delete(msg.id);
3498
3498
  this.failureCount = 0;
3499
3499
  if (msg.error) reject(new Error(msg.error.message));
3500
- else resolve20(msg.result);
3500
+ else resolve21(msg.result);
3501
3501
  } else if (msg.method === "Runtime.executionContextCreated") {
3502
3502
  this.contexts.add(msg.params.context.id);
3503
3503
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -3520,7 +3520,7 @@ var init_manager = __esm({
3520
3520
  this.ws.on("error", (err) => {
3521
3521
  this.log(`[CDP] WebSocket error: ${err.message}`);
3522
3522
  this._connected = false;
3523
- resolve19(false);
3523
+ resolve20(false);
3524
3524
  });
3525
3525
  });
3526
3526
  }
@@ -3534,7 +3534,7 @@ var init_manager = __esm({
3534
3534
  return;
3535
3535
  }
3536
3536
  this.log(`[CDP] Connecting browser WS for target discovery...`);
3537
- await new Promise((resolve19, reject) => {
3537
+ await new Promise((resolve20, reject) => {
3538
3538
  this.browserWs = new import_ws.default(browserWsUrl);
3539
3539
  this.browserWs.on("open", async () => {
3540
3540
  this._browserConnected = true;
@@ -3544,16 +3544,16 @@ var init_manager = __esm({
3544
3544
  } catch (e) {
3545
3545
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
3546
3546
  }
3547
- resolve19();
3547
+ resolve20();
3548
3548
  });
3549
3549
  this.browserWs.on("message", (data) => {
3550
3550
  try {
3551
3551
  const msg = JSON.parse(data.toString());
3552
3552
  if (msg.id && this.browserPending.has(msg.id)) {
3553
- const { resolve: resolve20, reject: reject2 } = this.browserPending.get(msg.id);
3553
+ const { resolve: resolve21, reject: reject2 } = this.browserPending.get(msg.id);
3554
3554
  this.browserPending.delete(msg.id);
3555
3555
  if (msg.error) reject2(new Error(msg.error.message));
3556
- else resolve20(msg.result);
3556
+ else resolve21(msg.result);
3557
3557
  }
3558
3558
  } catch {
3559
3559
  }
@@ -3573,31 +3573,31 @@ var init_manager = __esm({
3573
3573
  }
3574
3574
  }
3575
3575
  getBrowserWsUrl() {
3576
- return new Promise((resolve19) => {
3576
+ return new Promise((resolve20) => {
3577
3577
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
3578
3578
  let data = "";
3579
3579
  res.on("data", (chunk) => data += chunk.toString());
3580
3580
  res.on("end", () => {
3581
3581
  try {
3582
3582
  const info = JSON.parse(data);
3583
- resolve19(info.webSocketDebuggerUrl || null);
3583
+ resolve20(info.webSocketDebuggerUrl || null);
3584
3584
  } catch {
3585
- resolve19(null);
3585
+ resolve20(null);
3586
3586
  }
3587
3587
  });
3588
3588
  });
3589
- req.on("error", () => resolve19(null));
3589
+ req.on("error", () => resolve20(null));
3590
3590
  req.setTimeout(3e3, () => {
3591
3591
  req.destroy();
3592
- resolve19(null);
3592
+ resolve20(null);
3593
3593
  });
3594
3594
  });
3595
3595
  }
3596
3596
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
3597
- return new Promise((resolve19, reject) => {
3597
+ return new Promise((resolve20, reject) => {
3598
3598
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
3599
3599
  const id = this.browserMsgId++;
3600
- this.browserPending.set(id, { resolve: resolve19, reject });
3600
+ this.browserPending.set(id, { resolve: resolve20, reject });
3601
3601
  this.browserWs.send(JSON.stringify({ id, method, params }));
3602
3602
  setTimeout(() => {
3603
3603
  if (this.browserPending.has(id)) {
@@ -3637,11 +3637,11 @@ var init_manager = __esm({
3637
3637
  }
3638
3638
  // ─── CDP Protocol ────────────────────────────────────────
3639
3639
  sendInternal(method, params = {}, timeoutMs = 15e3) {
3640
- return new Promise((resolve19, reject) => {
3640
+ return new Promise((resolve20, reject) => {
3641
3641
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
3642
3642
  if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
3643
3643
  const id = this.msgId++;
3644
- this.pending.set(id, { resolve: resolve19, reject });
3644
+ this.pending.set(id, { resolve: resolve20, reject });
3645
3645
  this.ws.send(JSON.stringify({ id, method, params }));
3646
3646
  setTimeout(() => {
3647
3647
  if (this.pending.has(id)) {
@@ -3890,7 +3890,7 @@ var init_manager = __esm({
3890
3890
  const browserWs = this.browserWs;
3891
3891
  let msgId = this.browserMsgId;
3892
3892
  const sendWs = (method, params = {}, sessionId) => {
3893
- return new Promise((resolve19, reject) => {
3893
+ return new Promise((resolve20, reject) => {
3894
3894
  const mid = msgId++;
3895
3895
  this.browserMsgId = msgId;
3896
3896
  const handler = (raw) => {
@@ -3899,7 +3899,7 @@ var init_manager = __esm({
3899
3899
  if (msg.id === mid) {
3900
3900
  browserWs.removeListener("message", handler);
3901
3901
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
3902
- else resolve19(msg.result);
3902
+ else resolve20(msg.result);
3903
3903
  }
3904
3904
  } catch {
3905
3905
  }
@@ -4100,14 +4100,14 @@ var init_manager = __esm({
4100
4100
  if (!ws || ws.readyState !== import_ws.default.OPEN) {
4101
4101
  throw new Error("CDP not connected");
4102
4102
  }
4103
- return new Promise((resolve19, reject) => {
4103
+ return new Promise((resolve20, reject) => {
4104
4104
  const id = getNextId();
4105
4105
  pendingMap.set(id, {
4106
4106
  resolve: (result) => {
4107
4107
  if (result?.result?.subtype === "error") {
4108
4108
  reject(new Error(result.result.description));
4109
4109
  } else {
4110
- resolve19(result?.result?.value);
4110
+ resolve20(result?.result?.value);
4111
4111
  }
4112
4112
  },
4113
4113
  reject
@@ -4139,10 +4139,10 @@ var init_manager = __esm({
4139
4139
  throw new Error("CDP not connected");
4140
4140
  }
4141
4141
  const sendViaSession = (method, params = {}) => {
4142
- return new Promise((resolve19, reject) => {
4142
+ return new Promise((resolve20, reject) => {
4143
4143
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
4144
4144
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
4145
- pendingMap.set(id, { resolve: resolve19, reject });
4145
+ pendingMap.set(id, { resolve: resolve20, reject });
4146
4146
  ws.send(JSON.stringify({ id, sessionId, method, params }));
4147
4147
  setTimeout(() => {
4148
4148
  if (pendingMap.has(id)) {
@@ -8464,7 +8464,8 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
8464
8464
  },
8465
8465
  errorMessage: state.errorMessage,
8466
8466
  errorReason: state.errorReason,
8467
- lastUpdated: state.lastUpdated
8467
+ lastUpdated: state.lastUpdated,
8468
+ settings: state.settings
8468
8469
  };
8469
8470
  }
8470
8471
  function buildExtensionAgentSession(parent, ext, options) {
@@ -8499,7 +8500,8 @@ function buildExtensionAgentSession(parent, ext, options) {
8499
8500
  },
8500
8501
  errorMessage: ext.errorMessage,
8501
8502
  errorReason: ext.errorReason,
8502
- lastUpdated: ext.lastUpdated
8503
+ lastUpdated: ext.lastUpdated,
8504
+ settings: ext.settings
8503
8505
  };
8504
8506
  }
8505
8507
  function shouldIncludeExtensionSession(ext) {
@@ -8565,7 +8567,8 @@ function buildCliSession(state, options) {
8565
8567
  },
8566
8568
  errorMessage: state.errorMessage,
8567
8569
  errorReason: state.errorReason,
8568
- lastUpdated: state.lastUpdated
8570
+ lastUpdated: state.lastUpdated,
8571
+ settings: state.settings
8569
8572
  };
8570
8573
  }
8571
8574
  function buildAcpSession(state, options) {
@@ -8599,7 +8602,8 @@ function buildAcpSession(state, options) {
8599
8602
  },
8600
8603
  errorMessage: state.errorMessage,
8601
8604
  errorReason: state.errorReason,
8602
- lastUpdated: state.lastUpdated
8605
+ lastUpdated: state.lastUpdated,
8606
+ settings: state.settings
8603
8607
  };
8604
8608
  }
8605
8609
  function buildSessionEntries(allStates, cdpManagers, options = {}) {
@@ -9063,6 +9067,8 @@ function getSendChatInputEnvelope(args) {
9063
9067
  function getHistorySessionId(h, args) {
9064
9068
  const explicit = typeof args?.historySessionId === "string" ? args.historySessionId.trim() : "";
9065
9069
  if (explicit) return explicit;
9070
+ const explicitProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : "";
9071
+ if (explicitProviderSessionId) return explicitProviderSessionId;
9066
9072
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
9067
9073
  if (!targetSessionId) return void 0;
9068
9074
  const instance = h.ctx.instanceManager?.getInstance(targetSessionId);
@@ -9521,7 +9527,7 @@ function getCliVisibleTranscriptCount(adapter) {
9521
9527
  async function getStableExtensionBaseline(h) {
9522
9528
  const first = await readExtensionChatState(h);
9523
9529
  if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
9524
- await new Promise((resolve19) => setTimeout(resolve19, 150));
9530
+ await new Promise((resolve20) => setTimeout(resolve20, 150));
9525
9531
  const second = await readExtensionChatState(h);
9526
9532
  return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
9527
9533
  }
@@ -9529,7 +9535,7 @@ async function verifyExtensionSendObserved(h, before) {
9529
9535
  const beforeCount = getStateMessageCount(before);
9530
9536
  const beforeSignature = getStateLastSignature(before);
9531
9537
  for (let attempt = 0; attempt < 12; attempt += 1) {
9532
- await new Promise((resolve19) => setTimeout(resolve19, 250));
9538
+ await new Promise((resolve20) => setTimeout(resolve20, 250));
9533
9539
  const state = await readExtensionChatState(h);
9534
9540
  if (state?.status === "waiting_approval") return true;
9535
9541
  const afterCount = getStateMessageCount(state);
@@ -9619,7 +9625,32 @@ async function handleReadChat(h, args) {
9619
9625
  ...coverage ? { coverage } : {}
9620
9626
  }, args);
9621
9627
  }
9622
- return { success: false, error: `${transport} adapter not found` };
9628
+ const historyLimit = normalizeReadChatTailLimit(args);
9629
+ try {
9630
+ const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
9631
+ const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
9632
+ const history = readProviderChatHistory(agentStr, {
9633
+ canonicalHistory: provider?.canonicalHistory,
9634
+ historySessionId,
9635
+ workspace,
9636
+ offset: 0,
9637
+ limit: historyLimit,
9638
+ excludeRecentCount: 0,
9639
+ historyBehavior: provider?.historyBehavior,
9640
+ scripts: provider?.scripts
9641
+ });
9642
+ const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : historySessionId;
9643
+ return buildReadChatCommandResult({
9644
+ messages: Array.isArray(history?.messages) ? history.messages : [],
9645
+ status: "idle",
9646
+ ...typeof history?.title === "string" ? { title: history.title } : {},
9647
+ ...historyProviderSessionId ? { providerSessionId: historyProviderSessionId } : {},
9648
+ ...provider?.historyBehavior?.transcriptAuthority === "provider" || provider?.historyBehavior?.transcriptAuthority === "daemon" ? { transcriptAuthority: (provider?.historyBehavior).transcriptAuthority } : {},
9649
+ coverage: "tail"
9650
+ }, args);
9651
+ } catch (error48) {
9652
+ return { success: false, error: error48?.message || `${transport} adapter not found` };
9653
+ }
9623
9654
  }
9624
9655
  if (isExtensionTransport(transport)) {
9625
9656
  let extensionReadChatError = "";
@@ -11176,7 +11207,7 @@ async function executeProviderScript(h, args, scriptName) {
11176
11207
  const enterCount = cliCommand.enterCount || 1;
11177
11208
  await adapter.writeRaw(cliCommand.text + "\r");
11178
11209
  for (let i = 1; i < enterCount; i += 1) {
11179
- await new Promise((resolve19) => setTimeout(resolve19, 50));
11210
+ await new Promise((resolve20) => setTimeout(resolve20, 50));
11180
11211
  await adapter.writeRaw("\r");
11181
11212
  }
11182
11213
  }
@@ -11892,7 +11923,7 @@ var init_handler = __esm({
11892
11923
  try {
11893
11924
  const http3 = await import("http");
11894
11925
  const postData = JSON.stringify(body);
11895
- const result = await new Promise((resolve19, reject) => {
11926
+ const result = await new Promise((resolve20, reject) => {
11896
11927
  const req = http3.request({
11897
11928
  hostname: "127.0.0.1",
11898
11929
  port: 19280,
@@ -11904,9 +11935,9 @@ var init_handler = __esm({
11904
11935
  res.on("data", (chunk) => data += chunk);
11905
11936
  res.on("end", () => {
11906
11937
  try {
11907
- resolve19(JSON.parse(data));
11938
+ resolve20(JSON.parse(data));
11908
11939
  } catch {
11909
- resolve19({ raw: data });
11940
+ resolve20({ raw: data });
11910
11941
  }
11911
11942
  });
11912
11943
  });
@@ -11924,15 +11955,15 @@ var init_handler = __esm({
11924
11955
  if (!providerType) return { success: false, error: "providerType required" };
11925
11956
  try {
11926
11957
  const http3 = await import("http");
11927
- const result = await new Promise((resolve19, reject) => {
11958
+ const result = await new Promise((resolve20, reject) => {
11928
11959
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
11929
11960
  let data = "";
11930
11961
  res.on("data", (chunk) => data += chunk);
11931
11962
  res.on("end", () => {
11932
11963
  try {
11933
- resolve19(JSON.parse(data));
11964
+ resolve20(JSON.parse(data));
11934
11965
  } catch {
11935
- resolve19({ raw: data });
11966
+ resolve20({ raw: data });
11936
11967
  }
11937
11968
  });
11938
11969
  }).on("error", reject);
@@ -11946,7 +11977,7 @@ var init_handler = __esm({
11946
11977
  try {
11947
11978
  const http3 = await import("http");
11948
11979
  const postData = JSON.stringify(args || {});
11949
- const result = await new Promise((resolve19, reject) => {
11980
+ const result = await new Promise((resolve20, reject) => {
11950
11981
  const req = http3.request({
11951
11982
  hostname: "127.0.0.1",
11952
11983
  port: 19280,
@@ -11958,9 +11989,9 @@ var init_handler = __esm({
11958
11989
  res.on("data", (chunk) => data += chunk);
11959
11990
  res.on("end", () => {
11960
11991
  try {
11961
- resolve19(JSON.parse(data));
11992
+ resolve20(JSON.parse(data));
11962
11993
  } catch {
11963
- resolve19({ raw: data });
11994
+ resolve20({ raw: data });
11964
11995
  }
11965
11996
  });
11966
11997
  });
@@ -14107,7 +14138,7 @@ var init_provider_cli_adapter = __esm({
14107
14138
  `[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
14108
14139
  );
14109
14140
  }
14110
- await new Promise((resolve19) => setTimeout(resolve19, 50));
14141
+ await new Promise((resolve20) => setTimeout(resolve20, 50));
14111
14142
  }
14112
14143
  const finalScreenText = this.terminalScreen.getText() || "";
14113
14144
  LOG.warn(
@@ -15017,7 +15048,7 @@ var init_provider_cli_adapter = __esm({
15017
15048
  const deadline = Date.now() + 1e4;
15018
15049
  while (this.startupParseGate && Date.now() < deadline) {
15019
15050
  this.resolveStartupState("send_wait");
15020
- await new Promise((resolve19) => setTimeout(resolve19, 50));
15051
+ await new Promise((resolve20) => setTimeout(resolve20, 50));
15021
15052
  }
15022
15053
  }
15023
15054
  if (!allowInterventionPrompt) {
@@ -15093,13 +15124,13 @@ var init_provider_cli_adapter = __esm({
15093
15124
  }
15094
15125
  this.responseEpoch += 1;
15095
15126
  this.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
15096
- await new Promise((resolve19, reject) => {
15127
+ await new Promise((resolve20, reject) => {
15097
15128
  let resolved = false;
15098
15129
  const completion = {
15099
15130
  resolveOnce: () => {
15100
15131
  if (resolved) return;
15101
15132
  resolved = true;
15102
- resolve19();
15133
+ resolve20();
15103
15134
  },
15104
15135
  rejectOnce: (error48) => {
15105
15136
  if (resolved) return;
@@ -15257,17 +15288,17 @@ var init_provider_cli_adapter = __esm({
15257
15288
  }
15258
15289
  }
15259
15290
  waitForStopped(timeoutMs) {
15260
- return new Promise((resolve19) => {
15291
+ return new Promise((resolve20) => {
15261
15292
  const startedAt = Date.now();
15262
15293
  const timer = setInterval(() => {
15263
15294
  if (!this.ptyProcess || this.currentStatus === "stopped") {
15264
15295
  clearInterval(timer);
15265
- resolve19(true);
15296
+ resolve20(true);
15266
15297
  return;
15267
15298
  }
15268
15299
  if (Date.now() - startedAt >= timeoutMs) {
15269
15300
  clearInterval(timer);
15270
- resolve19(false);
15301
+ resolve20(false);
15271
15302
  }
15272
15303
  }, 100);
15273
15304
  });
@@ -15410,11 +15441,22 @@ var init_provider_cli_adapter = __esm({
15410
15441
  }
15411
15442
  }
15412
15443
  }
15444
+ getParsedDebugState() {
15445
+ if (this.startupParseGate || typeof this.cliScripts?.parseSession !== "function") return null;
15446
+ try {
15447
+ const parsed = this.getScriptParsedStatus();
15448
+ return parsed && typeof parsed === "object" ? parsed : null;
15449
+ } catch {
15450
+ return null;
15451
+ }
15452
+ }
15413
15453
  getDebugState() {
15414
15454
  const screenText = sanitizeTerminalText(this.terminalScreen.getText());
15415
15455
  const startupModal = this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
15416
15456
  const effectiveStatus = this.projectEffectiveStatus(startupModal);
15417
15457
  const effectiveReady = this.ready || !!startupModal;
15458
+ const parsedDebugState = this.getParsedDebugState();
15459
+ const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
15418
15460
  return {
15419
15461
  type: this.cliType,
15420
15462
  name: this.cliName,
@@ -15427,8 +15469,18 @@ var init_provider_cli_adapter = __esm({
15427
15469
  startupParseGate: this.startupParseGate,
15428
15470
  spawnAt: this.spawnAt,
15429
15471
  workingDir: this.workingDir,
15430
- messages: [],
15431
- messageCount: 0,
15472
+ messages: parsedMessages,
15473
+ messageCount: parsedMessages.length,
15474
+ parsedStatus: parsedDebugState ? {
15475
+ id: parsedDebugState.id,
15476
+ status: parsedDebugState.status,
15477
+ title: parsedDebugState.title,
15478
+ providerSessionId: parsedDebugState.providerSessionId,
15479
+ transcriptAuthority: parsedDebugState.transcriptAuthority,
15480
+ coverage: parsedDebugState.coverage,
15481
+ activeModal: parsedDebugState.activeModal,
15482
+ messageCount: parsedMessages.length
15483
+ } : null,
15432
15484
  screenText: screenText.slice(-4e3),
15433
15485
  currentTurnScope: this.currentTurnScope,
15434
15486
  startupBuffer: this.startupBuffer.slice(-4e3),
@@ -15584,7 +15636,7 @@ async function waitForCliAdapterReady(adapter, options) {
15584
15636
  if (status === "stopped") {
15585
15637
  throw new Error("CLI runtime stopped before it became ready");
15586
15638
  }
15587
- await new Promise((resolve19) => setTimeout(resolve19, pollMs));
15639
+ await new Promise((resolve20) => setTimeout(resolve20, pollMs));
15588
15640
  }
15589
15641
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
15590
15642
  }
@@ -15762,7 +15814,7 @@ var init_cli_provider_instance = __esm({
15762
15814
  this.errorMessage = void 0;
15763
15815
  this.errorReason = void 0;
15764
15816
  }
15765
- const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
15817
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
15766
15818
  const visibleStatus = parseErrorMessage ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
15767
15819
  const parsedProviderSessionId = normalizeProviderSessionId(
15768
15820
  this.provider,
@@ -15949,18 +16001,14 @@ var init_cli_provider_instance = __esm({
15949
16001
  const enterCount = cliCommand.enterCount || 1;
15950
16002
  await this.adapter.writeRaw(cliCommand.text + "\r");
15951
16003
  for (let i = 1; i < enterCount; i += 1) {
15952
- await new Promise((resolve19) => setTimeout(resolve19, 50));
16004
+ await new Promise((resolve20) => setTimeout(resolve20, 50));
15953
16005
  await this.adapter.writeRaw("\r");
15954
16006
  }
15955
16007
  }
15956
16008
  this.applyProviderResponse(parsed.payload, { phase: "immediate" });
15957
16009
  }
15958
- detectStatusTransition() {
15959
- const now = Date.now();
15960
- const adapterStatus = this.adapter.getStatus({ allowParse: false });
15961
- const parsedStatus = null;
15962
- const rawStatus = adapterStatus.status;
15963
- const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
16010
+ maybeAutoApproveStatus(adapterStatus, now = Date.now()) {
16011
+ const autoApproveActive = adapterStatus?.status === "waiting_approval" && this.shouldAutoApprove();
15964
16012
  if (autoApproveActive && !this.autoApproveBusy) {
15965
16013
  this.autoApproveBusy = true;
15966
16014
  if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
@@ -15968,12 +16016,21 @@ var init_cli_provider_instance = __esm({
15968
16016
  this.autoApproveBusy = false;
15969
16017
  this.autoApproveBusyTimer = null;
15970
16018
  }, 2e3);
15971
- const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(adapterStatus.activeModal?.buttons, this.provider);
15972
- this.recordAutoApproval(adapterStatus.activeModal?.message, buttonLabel, now);
16019
+ const modal = adapterStatus.activeModal;
16020
+ const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(modal?.buttons, this.provider);
16021
+ this.recordAutoApproval(modal?.message, buttonLabel, now);
15973
16022
  setTimeout(() => {
15974
16023
  this.adapter.resolveModal(buttonIndex);
15975
16024
  }, 0);
15976
16025
  }
16026
+ return autoApproveActive;
16027
+ }
16028
+ detectStatusTransition() {
16029
+ const now = Date.now();
16030
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
16031
+ const parsedStatus = null;
16032
+ const rawStatus = adapterStatus.status;
16033
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, now);
15977
16034
  const newStatus = autoApproveActive ? "generating" : rawStatus;
15978
16035
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
15979
16036
  const chatTitle = `${this.provider.name} \xB7 ${dirName}`;
@@ -32526,8 +32583,8 @@ var init_acp = __esm({
32526
32583
  this.#requestHandler = requestHandler;
32527
32584
  this.#notificationHandler = notificationHandler;
32528
32585
  this.#stream = stream;
32529
- this.#closedPromise = new Promise((resolve19) => {
32530
- this.#abortController.signal.addEventListener("abort", () => resolve19());
32586
+ this.#closedPromise = new Promise((resolve20) => {
32587
+ this.#abortController.signal.addEventListener("abort", () => resolve20());
32531
32588
  });
32532
32589
  this.#receive();
32533
32590
  }
@@ -32676,8 +32733,8 @@ var init_acp = __esm({
32676
32733
  }
32677
32734
  async sendRequest(method, params) {
32678
32735
  const id = this.#nextRequestId++;
32679
- const responsePromise = new Promise((resolve19, reject) => {
32680
- this.#pendingResponses.set(id, { resolve: resolve19, reject });
32736
+ const responsePromise = new Promise((resolve20, reject) => {
32737
+ this.#pendingResponses.set(id, { resolve: resolve20, reject });
32681
32738
  });
32682
32739
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
32683
32740
  return responsePromise;
@@ -33361,13 +33418,13 @@ var init_acp_provider_instance = __esm({
33361
33418
  }
33362
33419
  this.currentStatus = "waiting_approval";
33363
33420
  this.detectStatusTransition();
33364
- const approved = await new Promise((resolve19) => {
33365
- this.permissionResolvers.push(resolve19);
33421
+ const approved = await new Promise((resolve20) => {
33422
+ this.permissionResolvers.push(resolve20);
33366
33423
  setTimeout(() => {
33367
- const idx = this.permissionResolvers.indexOf(resolve19);
33424
+ const idx = this.permissionResolvers.indexOf(resolve20);
33368
33425
  if (idx >= 0) {
33369
33426
  this.permissionResolvers.splice(idx, 1);
33370
- resolve19(false);
33427
+ resolve20(false);
33371
33428
  }
33372
33429
  }, 3e5);
33373
33430
  });
@@ -34379,7 +34436,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
34379
34436
  resolvedDir,
34380
34437
  resolvedCliArgs,
34381
34438
  resolvedProvider,
34382
- this.providerLoader.getSettings(normalizedType),
34439
+ { ...this.providerLoader.getSettings(normalizedType), ...options?.settingsOverride || {} },
34383
34440
  false,
34384
34441
  {
34385
34442
  providerSessionId: sessionBinding.providerSessionId,
@@ -34633,7 +34690,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
34633
34690
  dir,
34634
34691
  args?.cliArgs,
34635
34692
  args?.initialModel,
34636
- { resumeSessionId: args?.resumeSessionId }
34693
+ { resumeSessionId: args?.resumeSessionId, settingsOverride: args?.settings }
34637
34694
  );
34638
34695
  return {
34639
34696
  success: true,
@@ -35502,9 +35559,9 @@ var init_handler2 = __esm({
35502
35559
  if (this.fsw.closed) {
35503
35560
  return;
35504
35561
  }
35505
- const dirname10 = sp.dirname(file2);
35562
+ const dirname11 = sp.dirname(file2);
35506
35563
  const basename9 = sp.basename(file2);
35507
- const parent = this.fsw._getWatchedDir(dirname10);
35564
+ const parent = this.fsw._getWatchedDir(dirname11);
35508
35565
  let prevStats = stats;
35509
35566
  if (parent.has(basename9))
35510
35567
  return;
@@ -35531,7 +35588,7 @@ var init_handler2 = __esm({
35531
35588
  prevStats = newStats2;
35532
35589
  }
35533
35590
  } catch (error48) {
35534
- this.fsw._remove(dirname10, basename9);
35591
+ this.fsw._remove(dirname11, basename9);
35535
35592
  }
35536
35593
  } else if (parent.has(basename9)) {
35537
35594
  const at = newStats.atimeMs;
@@ -35628,7 +35685,7 @@ var init_handler2 = __esm({
35628
35685
  this._addToNodeFs(path33, initialAdd, wh, depth + 1);
35629
35686
  }
35630
35687
  }).on(EV.ERROR, this._boundHandleError);
35631
- return new Promise((resolve19, reject) => {
35688
+ return new Promise((resolve20, reject) => {
35632
35689
  if (!stream)
35633
35690
  return reject();
35634
35691
  stream.once(STR_END, () => {
@@ -35637,7 +35694,7 @@ var init_handler2 = __esm({
35637
35694
  return;
35638
35695
  }
35639
35696
  const wasThrottled = throttler ? throttler.clear() : false;
35640
- resolve19(void 0);
35697
+ resolve20(void 0);
35641
35698
  previous.getChildren().filter((item) => {
35642
35699
  return item !== directory && !current.has(item);
35643
35700
  }).forEach((item) => {
@@ -37737,7 +37794,7 @@ var init_provider_loader = __esm({
37737
37794
  return { updated: false };
37738
37795
  }
37739
37796
  try {
37740
- const etag = await new Promise((resolve19, reject) => {
37797
+ const etag = await new Promise((resolve20, reject) => {
37741
37798
  const options = {
37742
37799
  method: "HEAD",
37743
37800
  hostname: "github.com",
@@ -37755,7 +37812,7 @@ var init_provider_loader = __esm({
37755
37812
  headers: { "User-Agent": "adhdev-launcher" },
37756
37813
  timeout: 1e4
37757
37814
  }, (res2) => {
37758
- resolve19(res2.headers.etag || res2.headers["last-modified"] || "");
37815
+ resolve20(res2.headers.etag || res2.headers["last-modified"] || "");
37759
37816
  });
37760
37817
  req2.on("error", reject);
37761
37818
  req2.on("timeout", () => {
@@ -37764,7 +37821,7 @@ var init_provider_loader = __esm({
37764
37821
  });
37765
37822
  req2.end();
37766
37823
  } else {
37767
- resolve19(res.headers.etag || res.headers["last-modified"] || "");
37824
+ resolve20(res.headers.etag || res.headers["last-modified"] || "");
37768
37825
  }
37769
37826
  });
37770
37827
  req.on("error", reject);
@@ -37828,7 +37885,7 @@ var init_provider_loader = __esm({
37828
37885
  downloadFile(url2, destPath) {
37829
37886
  const https = require("https");
37830
37887
  const http3 = require("http");
37831
- return new Promise((resolve19, reject) => {
37888
+ return new Promise((resolve20, reject) => {
37832
37889
  const doRequest = (reqUrl, redirectCount = 0) => {
37833
37890
  if (redirectCount > 5) {
37834
37891
  reject(new Error("Too many redirects"));
@@ -37848,7 +37905,7 @@ var init_provider_loader = __esm({
37848
37905
  res.pipe(ws);
37849
37906
  ws.on("finish", () => {
37850
37907
  ws.close();
37851
- resolve19();
37908
+ resolve20();
37852
37909
  });
37853
37910
  ws.on("error", reject);
37854
37911
  });
@@ -38433,17 +38490,17 @@ async function findFreePort(ports) {
38433
38490
  throw new Error("No free port found");
38434
38491
  }
38435
38492
  function checkPortFree(port) {
38436
- return new Promise((resolve19) => {
38493
+ return new Promise((resolve20) => {
38437
38494
  const server = net2.createServer();
38438
38495
  server.unref();
38439
- server.on("error", () => resolve19(false));
38496
+ server.on("error", () => resolve20(false));
38440
38497
  server.listen(port, "127.0.0.1", () => {
38441
- server.close(() => resolve19(true));
38498
+ server.close(() => resolve20(true));
38442
38499
  });
38443
38500
  });
38444
38501
  }
38445
38502
  async function isCdpActive(port) {
38446
- return new Promise((resolve19) => {
38503
+ return new Promise((resolve20) => {
38447
38504
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
38448
38505
  timeout: 2e3
38449
38506
  }, (res) => {
@@ -38452,16 +38509,16 @@ async function isCdpActive(port) {
38452
38509
  res.on("end", () => {
38453
38510
  try {
38454
38511
  const info = JSON.parse(data);
38455
- resolve19(!!info["WebKit-Version"] || !!info["Browser"]);
38512
+ resolve20(!!info["WebKit-Version"] || !!info["Browser"]);
38456
38513
  } catch {
38457
- resolve19(false);
38514
+ resolve20(false);
38458
38515
  }
38459
38516
  });
38460
38517
  });
38461
- req.on("error", () => resolve19(false));
38518
+ req.on("error", () => resolve20(false));
38462
38519
  req.on("timeout", () => {
38463
38520
  req.destroy();
38464
- resolve19(false);
38521
+ resolve20(false);
38465
38522
  });
38466
38523
  });
38467
38524
  }
@@ -38972,11 +39029,23 @@ function resolveMeshCoordinatorSetup(options) {
38972
39029
  if (!path33) {
38973
39030
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
38974
39031
  }
39032
+ const mcpServer = resolveAdhdevMcpServerLaunch({
39033
+ meshId,
39034
+ nodeExecutable: options.nodeExecutable,
39035
+ adhdevMcpEntryPath: options.adhdevMcpEntryPath
39036
+ });
39037
+ if (!mcpServer) {
39038
+ return {
39039
+ kind: "unsupported",
39040
+ reason: "Could not resolve the ADHDev MCP server entrypoint without relying on a PATH bin shim"
39041
+ };
39042
+ }
38975
39043
  return {
38976
39044
  kind: "auto_import",
38977
39045
  serverName,
38978
- configPath: (0, import_path4.join)(workspace, path33),
38979
- configFormat: mcpConfig.format
39046
+ configPath: (0, import_node_path2.join)(workspace, path33),
39047
+ configFormat: mcpConfig.format,
39048
+ mcpServer
38980
39049
  };
38981
39050
  }
38982
39051
  if (mcpConfig.mode === "manual") {
@@ -39008,11 +39077,60 @@ function resolveMeshCoordinatorSetup(options) {
39008
39077
  function renderMeshCoordinatorTemplate(template, values) {
39009
39078
  return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_2, key) => values[key] || "");
39010
39079
  }
39011
- var import_path4, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND;
39080
+ function resolveAdhdevMcpServerLaunch(options) {
39081
+ const entryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath);
39082
+ if (!entryPath) return null;
39083
+ return {
39084
+ command: options.nodeExecutable?.trim() || process.execPath,
39085
+ args: [entryPath, "--repo-mesh", options.meshId]
39086
+ };
39087
+ }
39088
+ function resolveAdhdevMcpEntryPath(explicitPath) {
39089
+ const explicit = explicitPath?.trim();
39090
+ if (explicit) return normalizeExistingPath(explicit) || explicit;
39091
+ const envPath = process.env.ADHDEV_MCP_SERVER_PATH?.trim();
39092
+ if (envPath) return normalizeExistingPath(envPath) || envPath;
39093
+ const candidates = [];
39094
+ const addCandidate = (candidate) => {
39095
+ if (!candidates.includes(candidate)) candidates.push(candidate);
39096
+ };
39097
+ const addPackagedCandidates = (baseFile) => {
39098
+ if (!baseFile) return;
39099
+ const realBase = normalizeExistingPath(baseFile) || baseFile;
39100
+ const dir = (0, import_node_path2.dirname)(realBase);
39101
+ addCandidate((0, import_node_path2.resolve)(dir, "../vendor/mcp-server/index.js"));
39102
+ addCandidate((0, import_node_path2.resolve)(dir, "../../vendor/mcp-server/index.js"));
39103
+ addCandidate((0, import_node_path2.resolve)(dir, "../../../vendor/mcp-server/index.js"));
39104
+ };
39105
+ addPackagedCandidates(process.argv[1]);
39106
+ for (const candidate of candidates) {
39107
+ const normalized = normalizeExistingPath(candidate);
39108
+ if (normalized) return normalized;
39109
+ }
39110
+ try {
39111
+ const requireBase = process.argv[1] ? normalizeExistingPath(process.argv[1]) || process.argv[1] : (0, import_node_path2.join)(process.cwd(), "adhdev-daemon.js");
39112
+ const req = (0, import_node_module2.createRequire)(requireBase);
39113
+ const resolvedModule = req.resolve("@adhdev/mcp-server");
39114
+ return normalizeExistingPath(resolvedModule) || resolvedModule;
39115
+ } catch {
39116
+ return null;
39117
+ }
39118
+ }
39119
+ function normalizeExistingPath(filePath) {
39120
+ try {
39121
+ if (!(0, import_node_fs4.existsSync)(filePath)) return null;
39122
+ return import_node_fs4.realpathSync.native(filePath);
39123
+ } catch {
39124
+ return null;
39125
+ }
39126
+ }
39127
+ var import_node_fs4, import_node_module2, import_node_path2, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND;
39012
39128
  var init_mesh_coordinator = __esm({
39013
39129
  "../../oss/packages/daemon-core/src/commands/mesh-coordinator.ts"() {
39014
39130
  "use strict";
39015
- import_path4 = require("path");
39131
+ import_node_fs4 = require("fs");
39132
+ import_node_module2 = require("module");
39133
+ import_node_path2 = require("path");
39016
39134
  DEFAULT_SERVER_NAME = "adhdev-mesh";
39017
39135
  DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
39018
39136
  }
@@ -39531,7 +39649,7 @@ async function waitForPidExit(pid, timeoutMs) {
39531
39649
  while (Date.now() - start < timeoutMs) {
39532
39650
  try {
39533
39651
  process.kill(pid, 0);
39534
- await new Promise((resolve19) => setTimeout(resolve19, 250));
39652
+ await new Promise((resolve20) => setTimeout(resolve20, 250));
39535
39653
  } catch {
39536
39654
  return;
39537
39655
  }
@@ -39642,7 +39760,7 @@ async function runDaemonUpgradeHelper(payload) {
39642
39760
  appendUpgradeLog(installOutput.trim());
39643
39761
  }
39644
39762
  if (process.platform === "win32") {
39645
- await new Promise((resolve19) => setTimeout(resolve19, 500));
39763
+ await new Promise((resolve20) => setTimeout(resolve20, 500));
39646
39764
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
39647
39765
  appendUpgradeLog("Post-install staging cleanup complete");
39648
39766
  }
@@ -40518,11 +40636,16 @@ var init_router = __esm({
40518
40636
  const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
40519
40637
  if (!meshId) return { success: false, error: "meshId required" };
40520
40638
  try {
40521
- const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40522
40639
  const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
40523
- const mesh = getMesh3(meshId);
40640
+ let mesh;
40641
+ if (args?.inlineMesh && typeof args.inlineMesh === "object") {
40642
+ mesh = args.inlineMesh;
40643
+ } else {
40644
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
40645
+ mesh = getMesh3(meshId);
40646
+ }
40524
40647
  if (!mesh) return { success: false, error: "Mesh not found" };
40525
- if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
40648
+ if (!Array.isArray(mesh.nodes) || mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
40526
40649
  const workspace = mesh.nodes[0].workspace;
40527
40650
  const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
40528
40651
  const coordinatorSetup = resolveMeshCoordinatorSetup({
@@ -40561,9 +40684,9 @@ var init_router = __esm({
40561
40684
  workspace
40562
40685
  };
40563
40686
  }
40564
- const { existsSync: existsSync25, readFileSync: readFileSync20, writeFileSync: writeFileSync14, copyFileSync: copyFileSync4 } = await import("fs");
40687
+ const { existsSync: existsSync26, readFileSync: readFileSync20, writeFileSync: writeFileSync14, copyFileSync: copyFileSync4 } = await import("fs");
40565
40688
  const mcpConfigPath = coordinatorSetup.configPath;
40566
- const hadExistingMcpConfig = existsSync25(mcpConfigPath);
40689
+ const hadExistingMcpConfig = existsSync26(mcpConfigPath);
40567
40690
  let existingMcpConfig = {};
40568
40691
  if (hadExistingMcpConfig) {
40569
40692
  try {
@@ -40577,8 +40700,8 @@ var init_router = __esm({
40577
40700
  mcpServers: {
40578
40701
  ...existingMcpConfig.mcpServers || {},
40579
40702
  [coordinatorSetup.serverName]: {
40580
- command: "adhdev-mcp",
40581
- args: ["--repo-mesh", meshId]
40703
+ command: coordinatorSetup.mcpServer.command,
40704
+ args: coordinatorSetup.mcpServer.args
40582
40705
  }
40583
40706
  }
40584
40707
  };
@@ -40590,10 +40713,20 @@ var init_router = __esm({
40590
40713
  } catch {
40591
40714
  systemPrompt = `You are a Repo Mesh Coordinator for "${mesh.name}". Use the adhdev-mesh MCP tools (mesh_status, mesh_list_nodes, mesh_send_task, mesh_read_chat, mesh_launch_session, etc.) to orchestrate work across ${mesh.nodes.length} node(s).`;
40592
40715
  }
40716
+ const cliArgs = [];
40717
+ if (systemPrompt) {
40718
+ cliArgs.push("--append-system-prompt", systemPrompt);
40719
+ }
40720
+ if (cliType === "claude-cli") {
40721
+ cliArgs.push("--mcp-config", coordinatorSetup.configPath);
40722
+ }
40593
40723
  const launchResult = await this.deps.cliManager.handleCliCommand("launch_cli", {
40594
40724
  cliType,
40595
40725
  dir: workspace,
40596
- initialPrompt: systemPrompt
40726
+ cliArgs: cliArgs.length > 0 ? cliArgs : void 0,
40727
+ settings: {
40728
+ meshCoordinatorFor: meshId
40729
+ }
40597
40730
  });
40598
40731
  if (!launchResult?.success) {
40599
40732
  return { success: false, error: launchResult?.error || "Failed to launch CLI session" };
@@ -40904,7 +41037,8 @@ var init_reporter = __esm({
40904
41037
  workspace: session.workspace ?? null,
40905
41038
  title: session.title,
40906
41039
  cdpConnected: session.cdpConnected,
40907
- summaryMetadata: session.summaryMetadata
41040
+ summaryMetadata: session.summaryMetadata,
41041
+ settings: session.settings
40908
41042
  })),
40909
41043
  p2p: payload.p2p,
40910
41044
  timestamp: now
@@ -41253,7 +41387,7 @@ var init_provider_adapter = __esm({
41253
41387
  const beforeCount = this.messageCount(before);
41254
41388
  const beforeSignature = this.lastMessageSignature(before);
41255
41389
  for (let attempt = 0; attempt < 12; attempt += 1) {
41256
- await new Promise((resolve19) => setTimeout(resolve19, 250));
41390
+ await new Promise((resolve20) => setTimeout(resolve20, 250));
41257
41391
  let state;
41258
41392
  try {
41259
41393
  state = await this.readChat(evaluate);
@@ -41275,7 +41409,7 @@ var init_provider_adapter = __esm({
41275
41409
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
41276
41410
  return first;
41277
41411
  }
41278
- await new Promise((resolve19) => setTimeout(resolve19, 150));
41412
+ await new Promise((resolve20) => setTimeout(resolve20, 150));
41279
41413
  const second = await this.readChat(evaluate);
41280
41414
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
41281
41415
  }
@@ -41426,7 +41560,7 @@ var init_provider_adapter = __esm({
41426
41560
  if (typeof data.error === "string" && data.error.trim()) return false;
41427
41561
  }
41428
41562
  for (let attempt = 0; attempt < 6; attempt += 1) {
41429
- await new Promise((resolve19) => setTimeout(resolve19, 250));
41563
+ await new Promise((resolve20) => setTimeout(resolve20, 250));
41430
41564
  const state = await this.readChat(evaluate);
41431
41565
  const title = this.getStateTitle(state);
41432
41566
  if (this.titlesMatch(title, sessionId)) return true;
@@ -44073,7 +44207,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
44073
44207
  return { target, instance, adapter };
44074
44208
  }
44075
44209
  function sleep(ms) {
44076
- return new Promise((resolve19) => setTimeout(resolve19, ms));
44210
+ return new Promise((resolve20) => setTimeout(resolve20, ms));
44077
44211
  }
44078
44212
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
44079
44213
  const startedAt = Date.now();
@@ -46353,15 +46487,15 @@ var init_dev_server = __esm({
46353
46487
  this.json(res, 500, { error: e.message });
46354
46488
  }
46355
46489
  });
46356
- return new Promise((resolve19, reject) => {
46490
+ return new Promise((resolve20, reject) => {
46357
46491
  this.server.listen(port, "127.0.0.1", () => {
46358
46492
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
46359
- resolve19();
46493
+ resolve20();
46360
46494
  });
46361
46495
  this.server.on("error", (e) => {
46362
46496
  if (e.code === "EADDRINUSE") {
46363
46497
  this.log(`Port ${port} in use, skipping dev server`);
46364
- resolve19();
46498
+ resolve20();
46365
46499
  } else {
46366
46500
  reject(e);
46367
46501
  }
@@ -46443,20 +46577,20 @@ var init_dev_server = __esm({
46443
46577
  child.stderr?.on("data", (d) => {
46444
46578
  stderr += d.toString().slice(0, 2e3);
46445
46579
  });
46446
- await new Promise((resolve19) => {
46580
+ await new Promise((resolve20) => {
46447
46581
  const timer = setTimeout(() => {
46448
46582
  child.kill();
46449
- resolve19();
46583
+ resolve20();
46450
46584
  }, 3e3);
46451
46585
  child.on("exit", () => {
46452
46586
  clearTimeout(timer);
46453
- resolve19();
46587
+ resolve20();
46454
46588
  });
46455
46589
  child.stdout?.once("data", () => {
46456
46590
  setTimeout(() => {
46457
46591
  child.kill();
46458
46592
  clearTimeout(timer);
46459
- resolve19();
46593
+ resolve20();
46460
46594
  }, 500);
46461
46595
  });
46462
46596
  });
@@ -46959,14 +47093,14 @@ var init_dev_server = __esm({
46959
47093
  child.stderr?.on("data", (d) => {
46960
47094
  stderr += d.toString();
46961
47095
  });
46962
- await new Promise((resolve19) => {
47096
+ await new Promise((resolve20) => {
46963
47097
  const timer = setTimeout(() => {
46964
47098
  child.kill();
46965
- resolve19();
47099
+ resolve20();
46966
47100
  }, timeout);
46967
47101
  child.on("exit", () => {
46968
47102
  clearTimeout(timer);
46969
- resolve19();
47103
+ resolve20();
46970
47104
  });
46971
47105
  });
46972
47106
  const elapsed = Date.now() - start;
@@ -47636,14 +47770,14 @@ data: ${JSON.stringify(msg.data)}
47636
47770
  res.end(JSON.stringify(data, null, 2));
47637
47771
  }
47638
47772
  async readBody(req) {
47639
- return new Promise((resolve19) => {
47773
+ return new Promise((resolve20) => {
47640
47774
  let body = "";
47641
47775
  req.on("data", (chunk) => body += chunk);
47642
47776
  req.on("end", () => {
47643
47777
  try {
47644
- resolve19(JSON.parse(body));
47778
+ resolve20(JSON.parse(body));
47645
47779
  } catch {
47646
- resolve19({});
47780
+ resolve20({});
47647
47781
  }
47648
47782
  });
47649
47783
  });
@@ -48160,7 +48294,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
48160
48294
  const deadline = Date.now() + timeoutMs;
48161
48295
  while (Date.now() < deadline) {
48162
48296
  if (await canConnect(endpoint)) return;
48163
- await new Promise((resolve19) => setTimeout(resolve19, STARTUP_POLL_MS));
48297
+ await new Promise((resolve20) => setTimeout(resolve20, STARTUP_POLL_MS));
48164
48298
  }
48165
48299
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
48166
48300
  }
@@ -48266,10 +48400,10 @@ async function installExtension(ide, extension) {
48266
48400
  const buffer = Buffer.from(await res.arrayBuffer());
48267
48401
  const fs20 = await import("fs");
48268
48402
  fs20.writeFileSync(vsixPath, buffer);
48269
- return new Promise((resolve19) => {
48403
+ return new Promise((resolve20) => {
48270
48404
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
48271
48405
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
48272
- resolve19({
48406
+ resolve20({
48273
48407
  extensionId: extension.id,
48274
48408
  marketplaceId: extension.marketplaceId,
48275
48409
  success: !error48,
@@ -48282,11 +48416,11 @@ async function installExtension(ide, extension) {
48282
48416
  } catch (e) {
48283
48417
  }
48284
48418
  }
48285
- return new Promise((resolve19) => {
48419
+ return new Promise((resolve20) => {
48286
48420
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
48287
48421
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
48288
48422
  if (error48) {
48289
- resolve19({
48423
+ resolve20({
48290
48424
  extensionId: extension.id,
48291
48425
  marketplaceId: extension.marketplaceId,
48292
48426
  success: false,
@@ -48294,7 +48428,7 @@ async function installExtension(ide, extension) {
48294
48428
  error: stderr || error48.message
48295
48429
  });
48296
48430
  } else {
48297
- resolve19({
48431
+ resolve20({
48298
48432
  extensionId: extension.id,
48299
48433
  marketplaceId: extension.marketplaceId,
48300
48434
  success: true,
@@ -48484,6 +48618,51 @@ var init_registry = __esm({
48484
48618
  }
48485
48619
  });
48486
48620
 
48621
+ // ../../oss/packages/daemon-core/src/mesh/mesh-events.ts
48622
+ function setupMeshEventForwarding(components) {
48623
+ components.instanceManager.onEvent((event) => {
48624
+ if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
48625
+ const instanceId = event.instanceId;
48626
+ if (!instanceId) return;
48627
+ const sourceInstance = components.instanceManager.getInstance(instanceId);
48628
+ if (!sourceInstance || sourceInstance.category !== "cli") return;
48629
+ const state = sourceInstance.getState();
48630
+ const workspace = state.workspace;
48631
+ if (!workspace) return;
48632
+ const mesh = getMeshByRepo(workspace);
48633
+ if (!mesh) return;
48634
+ const allInstances = components.instanceManager.getByCategory("cli");
48635
+ const coordinatorInstances = allInstances.filter((inst) => {
48636
+ const instState = inst.getState();
48637
+ if (instState.settings?.meshCoordinatorFor !== mesh.id) return false;
48638
+ if (instState.instanceId === instanceId) return false;
48639
+ return true;
48640
+ });
48641
+ if (coordinatorInstances.length === 0) return;
48642
+ const targetNode = mesh.nodes.find((n) => n.workspace === workspace);
48643
+ const nodeLabel = targetNode ? `Node '${targetNode.id}'` : `Agent at ${workspace}`;
48644
+ let messageText = "";
48645
+ if (event.event === "agent:generating_completed") {
48646
+ messageText = `[System] ${nodeLabel} has completed its task and is now idle. You may use mesh_read_chat to review its progress.`;
48647
+ } else if (event.event === "agent:waiting_approval") {
48648
+ messageText = `[System] ${nodeLabel} is waiting for approval to proceed. You may use mesh_read_chat and mesh_approve to handle it.`;
48649
+ }
48650
+ if (!messageText) return;
48651
+ for (const coord of coordinatorInstances) {
48652
+ const coordState = coord.getState();
48653
+ LOG.info("MeshEvents", `Forwarding event from ${workspace} to coordinator ${coordState.instanceId}`);
48654
+ coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
48655
+ }
48656
+ });
48657
+ }
48658
+ var init_mesh_events = __esm({
48659
+ "../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
48660
+ "use strict";
48661
+ init_mesh_config();
48662
+ init_logger();
48663
+ }
48664
+ });
48665
+
48487
48666
  // ../../oss/packages/daemon-core/src/boot/daemon-lifecycle.ts
48488
48667
  async function initDaemonComponents(config2) {
48489
48668
  installGlobalInterceptor();
@@ -48642,7 +48821,7 @@ async function initDaemonComponents(config2) {
48642
48821
  });
48643
48822
  poller.start();
48644
48823
  instanceManager.startTicking(config2.tickIntervalMs ?? 5e3);
48645
- return {
48824
+ const components = {
48646
48825
  providerLoader,
48647
48826
  instanceManager,
48648
48827
  cliManager,
@@ -48656,6 +48835,8 @@ async function initDaemonComponents(config2) {
48656
48835
  detectedIdes: detectedIdesRef,
48657
48836
  refreshProviderAvailability
48658
48837
  };
48838
+ setupMeshEventForwarding(components);
48839
+ return components;
48659
48840
  }
48660
48841
  async function startDaemonDevSupport(options) {
48661
48842
  const devServer = new DevServer({
@@ -48731,6 +48912,7 @@ var init_daemon_lifecycle = __esm({
48731
48912
  init_runtime_defaults();
48732
48913
  init_config();
48733
48914
  init_git_commands();
48915
+ init_mesh_events();
48734
48916
  }
48735
48917
  });
48736
48918
 
@@ -49101,7 +49283,7 @@ var init_server_connection = __esm({
49101
49283
  * Returns the command result or throws on timeout / auth failure.
49102
49284
  */
49103
49285
  sendMeshCommand(targetDaemonId, command, args = {}, timeoutMs = 3e4) {
49104
- return new Promise((resolve19, reject) => {
49286
+ return new Promise((resolve20, reject) => {
49105
49287
  const requestId = `mesh_${crypto.randomUUID()}`;
49106
49288
  const timer = setTimeout(() => {
49107
49289
  this.off("daemon_mesh_result", handler);
@@ -49114,7 +49296,7 @@ var init_server_connection = __esm({
49114
49296
  if (msg.payload?.success === false) {
49115
49297
  reject(new Error(msg.payload?.error ?? "Mesh command failed"));
49116
49298
  } else {
49117
- resolve19(msg.payload?.result);
49299
+ resolve20(msg.payload?.result);
49118
49300
  }
49119
49301
  };
49120
49302
  this.on("daemon_mesh_result", handler);
@@ -50421,19 +50603,19 @@ var init_peer_connection_manager = __esm({
50421
50603
  });
50422
50604
 
50423
50605
  // src/daemon-p2p/index.ts
50424
- var fs16, path27, import_node_module2, esmRequire, DaemonP2PSender;
50606
+ var fs16, path27, import_node_module3, esmRequire, DaemonP2PSender;
50425
50607
  var init_daemon_p2p = __esm({
50426
50608
  "src/daemon-p2p/index.ts"() {
50427
50609
  "use strict";
50428
50610
  fs16 = __toESM(require("fs"));
50429
50611
  path27 = __toESM(require("path"));
50430
- import_node_module2 = require("module");
50612
+ import_node_module3 = require("module");
50431
50613
  init_src();
50432
50614
  init_data_channel_router();
50433
50615
  init_screenshot_sender();
50434
50616
  init_peer_connection_manager();
50435
50617
  init_log();
50436
- esmRequire = (0, import_node_module2.createRequire)(__filename);
50618
+ esmRequire = (0, import_node_module3.createRequire)(__filename);
50437
50619
  DaemonP2PSender = class {
50438
50620
  serverConn;
50439
50621
  peers = /* @__PURE__ */ new Map();
@@ -50910,14 +51092,14 @@ var require_filesystem = __commonJS({
50910
51092
  });
50911
51093
  return buffer.subarray(0, bytesRead);
50912
51094
  };
50913
- var readFile2 = (path33) => new Promise((resolve19, reject) => {
51095
+ var readFile2 = (path33) => new Promise((resolve20, reject) => {
50914
51096
  fs20.open(path33, "r", (err, fd) => {
50915
51097
  if (err) {
50916
51098
  reject(err);
50917
51099
  } else {
50918
51100
  const buffer = Buffer.alloc(MAX_LENGTH);
50919
51101
  fs20.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
50920
- resolve19(buffer.subarray(0, bytesRead));
51102
+ resolve20(buffer.subarray(0, bytesRead));
50921
51103
  fs20.close(fd, () => {
50922
51104
  });
50923
51105
  });
@@ -50985,10 +51167,10 @@ var require_detect_libc = __commonJS({
50985
51167
  var commandOut = "";
50986
51168
  var safeCommand = () => {
50987
51169
  if (!commandOut) {
50988
- return new Promise((resolve19) => {
51170
+ return new Promise((resolve20) => {
50989
51171
  childProcess.exec(command, (err, out) => {
50990
51172
  commandOut = err ? " " : out;
50991
- resolve19(commandOut);
51173
+ resolve20(commandOut);
50992
51174
  });
50993
51175
  });
50994
51176
  }
@@ -53668,14 +53850,14 @@ var require_input = __commonJS({
53668
53850
  return this;
53669
53851
  } else {
53670
53852
  if (this._isStreamInput()) {
53671
- return new Promise((resolve19, reject) => {
53853
+ return new Promise((resolve20, reject) => {
53672
53854
  const finished = () => {
53673
53855
  this._flattenBufferIn();
53674
53856
  sharp.metadata(this.options, (err, metadata2) => {
53675
53857
  if (err) {
53676
53858
  reject(is.nativeError(err, stack));
53677
53859
  } else {
53678
- resolve19(metadata2);
53860
+ resolve20(metadata2);
53679
53861
  }
53680
53862
  });
53681
53863
  };
@@ -53686,12 +53868,12 @@ var require_input = __commonJS({
53686
53868
  }
53687
53869
  });
53688
53870
  } else {
53689
- return new Promise((resolve19, reject) => {
53871
+ return new Promise((resolve20, reject) => {
53690
53872
  sharp.metadata(this.options, (err, metadata2) => {
53691
53873
  if (err) {
53692
53874
  reject(is.nativeError(err, stack));
53693
53875
  } else {
53694
- resolve19(metadata2);
53876
+ resolve20(metadata2);
53695
53877
  }
53696
53878
  });
53697
53879
  });
@@ -53724,25 +53906,25 @@ var require_input = __commonJS({
53724
53906
  return this;
53725
53907
  } else {
53726
53908
  if (this._isStreamInput()) {
53727
- return new Promise((resolve19, reject) => {
53909
+ return new Promise((resolve20, reject) => {
53728
53910
  this.on("finish", function() {
53729
53911
  this._flattenBufferIn();
53730
53912
  sharp.stats(this.options, (err, stats2) => {
53731
53913
  if (err) {
53732
53914
  reject(is.nativeError(err, stack));
53733
53915
  } else {
53734
- resolve19(stats2);
53916
+ resolve20(stats2);
53735
53917
  }
53736
53918
  });
53737
53919
  });
53738
53920
  });
53739
53921
  } else {
53740
- return new Promise((resolve19, reject) => {
53922
+ return new Promise((resolve20, reject) => {
53741
53923
  sharp.stats(this.options, (err, stats2) => {
53742
53924
  if (err) {
53743
53925
  reject(is.nativeError(err, stack));
53744
53926
  } else {
53745
- resolve19(stats2);
53927
+ resolve20(stats2);
53746
53928
  }
53747
53929
  });
53748
53930
  });
@@ -57164,7 +57346,7 @@ var require_output = __commonJS({
57164
57346
  return this;
57165
57347
  } else {
57166
57348
  if (this._isStreamInput()) {
57167
- return new Promise((resolve19, reject) => {
57349
+ return new Promise((resolve20, reject) => {
57168
57350
  this.once("finish", () => {
57169
57351
  this._flattenBufferIn();
57170
57352
  sharp.pipeline(this.options, (err, data, info) => {
@@ -57172,24 +57354,24 @@ var require_output = __commonJS({
57172
57354
  reject(is.nativeError(err, stack));
57173
57355
  } else {
57174
57356
  if (this.options.resolveWithObject) {
57175
- resolve19({ data, info });
57357
+ resolve20({ data, info });
57176
57358
  } else {
57177
- resolve19(data);
57359
+ resolve20(data);
57178
57360
  }
57179
57361
  }
57180
57362
  });
57181
57363
  });
57182
57364
  });
57183
57365
  } else {
57184
- return new Promise((resolve19, reject) => {
57366
+ return new Promise((resolve20, reject) => {
57185
57367
  sharp.pipeline(this.options, (err, data, info) => {
57186
57368
  if (err) {
57187
57369
  reject(is.nativeError(err, stack));
57188
57370
  } else {
57189
57371
  if (this.options.resolveWithObject) {
57190
- resolve19({ data, info });
57372
+ resolve20({ data, info });
57191
57373
  } else {
57192
- resolve19(data);
57374
+ resolve20(data);
57193
57375
  }
57194
57376
  }
57195
57377
  });
@@ -58568,9 +58750,9 @@ function resolvePackageVersion(options) {
58568
58750
  const injectedVersion = options?.injectedVersion || "unknown";
58569
58751
  const dir = options?.dirname || __dirname;
58570
58752
  const possiblePaths = [
58571
- (0, import_path5.join)(dir, "..", "..", "package.json"),
58572
- (0, import_path5.join)(dir, "..", "package.json"),
58573
- (0, import_path5.join)(dir, "package.json")
58753
+ (0, import_path4.join)(dir, "..", "..", "package.json"),
58754
+ (0, import_path4.join)(dir, "..", "package.json"),
58755
+ (0, import_path4.join)(dir, "package.json")
58574
58756
  ];
58575
58757
  for (const p of possiblePaths) {
58576
58758
  try {
@@ -58581,12 +58763,12 @@ function resolvePackageVersion(options) {
58581
58763
  }
58582
58764
  return injectedVersion;
58583
58765
  }
58584
- var import_fs7, import_path5;
58766
+ var import_fs7, import_path4;
58585
58767
  var init_version = __esm({
58586
58768
  "src/version.ts"() {
58587
58769
  "use strict";
58588
58770
  import_fs7 = require("fs");
58589
- import_path5 = require("path");
58771
+ import_path4 = require("path");
58590
58772
  }
58591
58773
  });
58592
58774
 
@@ -58915,7 +59097,7 @@ var init_adhdev_daemon = __esm({
58915
59097
  init_version();
58916
59098
  init_src();
58917
59099
  init_runtime_defaults();
58918
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.70" });
59100
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.72" });
58919
59101
  AdhdevDaemon = class _AdhdevDaemon {
58920
59102
  localHttpServer = null;
58921
59103
  localWss = null;
@@ -59731,7 +59913,7 @@ ${err?.stack || ""}`);
59731
59913
  try {
59732
59914
  const statusResult = await Promise.race([
59733
59915
  this.components.router.execute("git_status", { workspace }, "mesh"),
59734
- new Promise((resolve19) => setTimeout(() => resolve19(null), 4e3))
59916
+ new Promise((resolve20) => setTimeout(() => resolve20(null), 4e3))
59735
59917
  ]);
59736
59918
  const s = statusResult?.status ?? statusResult;
59737
59919
  if (s?.isGitRepo) {
@@ -59914,7 +60096,7 @@ ${err?.stack || ""}`);
59914
60096
  this.localWss.emit("connection", ws, req);
59915
60097
  });
59916
60098
  });
59917
- await new Promise((resolve19, reject) => {
60099
+ await new Promise((resolve20, reject) => {
59918
60100
  const cleanup = () => {
59919
60101
  this.localHttpServer?.off("error", onError);
59920
60102
  this.localHttpServer?.off("listening", onListening);
@@ -59925,7 +60107,7 @@ ${err?.stack || ""}`);
59925
60107
  };
59926
60108
  const onListening = () => {
59927
60109
  cleanup();
59928
- resolve19();
60110
+ resolve20();
59929
60111
  };
59930
60112
  this.localHttpServer.once("error", onError);
59931
60113
  this.localHttpServer.once("listening", onListening);
@@ -60099,12 +60281,12 @@ ${err?.stack || ""}`);
60099
60281
  this.localClients.clear();
60100
60282
  this.localWss?.close();
60101
60283
  this.localWss = null;
60102
- await new Promise((resolve19) => {
60284
+ await new Promise((resolve20) => {
60103
60285
  if (!this.localHttpServer) {
60104
- resolve19();
60286
+ resolve20();
60105
60287
  return;
60106
60288
  }
60107
- this.localHttpServer.close(() => resolve19());
60289
+ this.localHttpServer.close(() => resolve20());
60108
60290
  this.localHttpServer = null;
60109
60291
  });
60110
60292
  } catch {
@@ -60652,14 +60834,14 @@ var require_run_async = __commonJS({
60652
60834
  return function() {
60653
60835
  var args = arguments;
60654
60836
  var originalThis = this;
60655
- var promise2 = new Promise(function(resolve19, reject) {
60837
+ var promise2 = new Promise(function(resolve20, reject) {
60656
60838
  var resolved = false;
60657
60839
  const wrappedResolve = function(value) {
60658
60840
  if (resolved) {
60659
60841
  console.warn("Run-async promise already resolved.");
60660
60842
  }
60661
60843
  resolved = true;
60662
- resolve19(value);
60844
+ resolve20(value);
60663
60845
  };
60664
60846
  var rejected = false;
60665
60847
  const wrappedReject = function(value) {
@@ -61450,7 +61632,7 @@ var require_Observable = __commonJS({
61450
61632
  Observable2.prototype.forEach = function(next, promiseCtor) {
61451
61633
  var _this = this;
61452
61634
  promiseCtor = getPromiseCtor(promiseCtor);
61453
- return new promiseCtor(function(resolve19, reject) {
61635
+ return new promiseCtor(function(resolve20, reject) {
61454
61636
  var subscriber = new Subscriber_1.SafeSubscriber({
61455
61637
  next: function(value) {
61456
61638
  try {
@@ -61461,7 +61643,7 @@ var require_Observable = __commonJS({
61461
61643
  }
61462
61644
  },
61463
61645
  error: reject,
61464
- complete: resolve19
61646
+ complete: resolve20
61465
61647
  });
61466
61648
  _this.subscribe(subscriber);
61467
61649
  });
@@ -61483,14 +61665,14 @@ var require_Observable = __commonJS({
61483
61665
  Observable2.prototype.toPromise = function(promiseCtor) {
61484
61666
  var _this = this;
61485
61667
  promiseCtor = getPromiseCtor(promiseCtor);
61486
- return new promiseCtor(function(resolve19, reject) {
61668
+ return new promiseCtor(function(resolve20, reject) {
61487
61669
  var value;
61488
61670
  _this.subscribe(function(x) {
61489
61671
  return value = x;
61490
61672
  }, function(err) {
61491
61673
  return reject(err);
61492
61674
  }, function() {
61493
- return resolve19(value);
61675
+ return resolve20(value);
61494
61676
  });
61495
61677
  });
61496
61678
  };
@@ -63586,11 +63768,11 @@ var require_innerFrom = __commonJS({
63586
63768
  "use strict";
63587
63769
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
63588
63770
  function adopt(value) {
63589
- return value instanceof P ? value : new P(function(resolve19) {
63590
- resolve19(value);
63771
+ return value instanceof P ? value : new P(function(resolve20) {
63772
+ resolve20(value);
63591
63773
  });
63592
63774
  }
63593
- return new (P || (P = Promise))(function(resolve19, reject) {
63775
+ return new (P || (P = Promise))(function(resolve20, reject) {
63594
63776
  function fulfilled(value) {
63595
63777
  try {
63596
63778
  step(generator.next(value));
@@ -63606,7 +63788,7 @@ var require_innerFrom = __commonJS({
63606
63788
  }
63607
63789
  }
63608
63790
  function step(result) {
63609
- result.done ? resolve19(result.value) : adopt(result.value).then(fulfilled, rejected);
63791
+ result.done ? resolve20(result.value) : adopt(result.value).then(fulfilled, rejected);
63610
63792
  }
63611
63793
  step((generator = generator.apply(thisArg, _arguments || [])).next());
63612
63794
  });
@@ -63688,14 +63870,14 @@ var require_innerFrom = __commonJS({
63688
63870
  }, i);
63689
63871
  function verb(n) {
63690
63872
  i[n] = o[n] && function(v) {
63691
- return new Promise(function(resolve19, reject) {
63692
- v = o[n](v), settle(resolve19, reject, v.done, v.value);
63873
+ return new Promise(function(resolve20, reject) {
63874
+ v = o[n](v), settle(resolve20, reject, v.done, v.value);
63693
63875
  });
63694
63876
  };
63695
63877
  }
63696
- function settle(resolve19, reject, d, v) {
63878
+ function settle(resolve20, reject, d, v) {
63697
63879
  Promise.resolve(v).then(function(v2) {
63698
- resolve19({ value: v2, done: d });
63880
+ resolve20({ value: v2, done: d });
63699
63881
  }, reject);
63700
63882
  }
63701
63883
  };
@@ -64314,7 +64496,7 @@ var require_lastValueFrom = __commonJS({
64314
64496
  var EmptyError_1 = require_EmptyError();
64315
64497
  function lastValueFrom(source, config2) {
64316
64498
  var hasConfig = typeof config2 === "object";
64317
- return new Promise(function(resolve19, reject) {
64499
+ return new Promise(function(resolve20, reject) {
64318
64500
  var _hasValue = false;
64319
64501
  var _value;
64320
64502
  source.subscribe({
@@ -64325,9 +64507,9 @@ var require_lastValueFrom = __commonJS({
64325
64507
  error: reject,
64326
64508
  complete: function() {
64327
64509
  if (_hasValue) {
64328
- resolve19(_value);
64510
+ resolve20(_value);
64329
64511
  } else if (hasConfig) {
64330
- resolve19(config2.defaultValue);
64512
+ resolve20(config2.defaultValue);
64331
64513
  } else {
64332
64514
  reject(new EmptyError_1.EmptyError());
64333
64515
  }
@@ -64349,16 +64531,16 @@ var require_firstValueFrom = __commonJS({
64349
64531
  var Subscriber_1 = require_Subscriber();
64350
64532
  function firstValueFrom(source, config2) {
64351
64533
  var hasConfig = typeof config2 === "object";
64352
- return new Promise(function(resolve19, reject) {
64534
+ return new Promise(function(resolve20, reject) {
64353
64535
  var subscriber = new Subscriber_1.SafeSubscriber({
64354
64536
  next: function(value) {
64355
- resolve19(value);
64537
+ resolve20(value);
64356
64538
  subscriber.unsubscribe();
64357
64539
  },
64358
64540
  error: reject,
64359
64541
  complete: function() {
64360
64542
  if (hasConfig) {
64361
- resolve19(config2.defaultValue);
64543
+ resolve20(config2.defaultValue);
64362
64544
  } else {
64363
64545
  reject(new EmptyError_1.EmptyError());
64364
64546
  }
@@ -76164,14 +76346,14 @@ var require_async_iterator = __commonJS({
76164
76346
  };
76165
76347
  }
76166
76348
  function readAndResolve(iter) {
76167
- var resolve19 = iter[kLastResolve];
76168
- if (resolve19 !== null) {
76349
+ var resolve20 = iter[kLastResolve];
76350
+ if (resolve20 !== null) {
76169
76351
  var data = iter[kStream].read();
76170
76352
  if (data !== null) {
76171
76353
  iter[kLastPromise] = null;
76172
76354
  iter[kLastResolve] = null;
76173
76355
  iter[kLastReject] = null;
76174
- resolve19(createIterResult(data, false));
76356
+ resolve20(createIterResult(data, false));
76175
76357
  }
76176
76358
  }
76177
76359
  }
@@ -76179,13 +76361,13 @@ var require_async_iterator = __commonJS({
76179
76361
  process.nextTick(readAndResolve, iter);
76180
76362
  }
76181
76363
  function wrapForNext(lastPromise, iter) {
76182
- return function(resolve19, reject) {
76364
+ return function(resolve20, reject) {
76183
76365
  lastPromise.then(function() {
76184
76366
  if (iter[kEnded]) {
76185
- resolve19(createIterResult(void 0, true));
76367
+ resolve20(createIterResult(void 0, true));
76186
76368
  return;
76187
76369
  }
76188
- iter[kHandlePromise](resolve19, reject);
76370
+ iter[kHandlePromise](resolve20, reject);
76189
76371
  }, reject);
76190
76372
  };
76191
76373
  }
@@ -76205,12 +76387,12 @@ var require_async_iterator = __commonJS({
76205
76387
  return Promise.resolve(createIterResult(void 0, true));
76206
76388
  }
76207
76389
  if (this[kStream].destroyed) {
76208
- return new Promise(function(resolve19, reject) {
76390
+ return new Promise(function(resolve20, reject) {
76209
76391
  process.nextTick(function() {
76210
76392
  if (_this[kError]) {
76211
76393
  reject(_this[kError]);
76212
76394
  } else {
76213
- resolve19(createIterResult(void 0, true));
76395
+ resolve20(createIterResult(void 0, true));
76214
76396
  }
76215
76397
  });
76216
76398
  });
@@ -76233,13 +76415,13 @@ var require_async_iterator = __commonJS({
76233
76415
  return this;
76234
76416
  }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
76235
76417
  var _this2 = this;
76236
- return new Promise(function(resolve19, reject) {
76418
+ return new Promise(function(resolve20, reject) {
76237
76419
  _this2[kStream].destroy(null, function(err) {
76238
76420
  if (err) {
76239
76421
  reject(err);
76240
76422
  return;
76241
76423
  }
76242
- resolve19(createIterResult(void 0, true));
76424
+ resolve20(createIterResult(void 0, true));
76243
76425
  });
76244
76426
  });
76245
76427
  }), _Object$setPrototypeO), AsyncIteratorPrototype);
@@ -76261,15 +76443,15 @@ var require_async_iterator = __commonJS({
76261
76443
  value: stream._readableState.endEmitted,
76262
76444
  writable: true
76263
76445
  }), _defineProperty(_Object$create, kHandlePromise, {
76264
- value: function value(resolve19, reject) {
76446
+ value: function value(resolve20, reject) {
76265
76447
  var data = iterator[kStream].read();
76266
76448
  if (data) {
76267
76449
  iterator[kLastPromise] = null;
76268
76450
  iterator[kLastResolve] = null;
76269
76451
  iterator[kLastReject] = null;
76270
- resolve19(createIterResult(data, false));
76452
+ resolve20(createIterResult(data, false));
76271
76453
  } else {
76272
- iterator[kLastResolve] = resolve19;
76454
+ iterator[kLastResolve] = resolve20;
76273
76455
  iterator[kLastReject] = reject;
76274
76456
  }
76275
76457
  },
@@ -76288,12 +76470,12 @@ var require_async_iterator = __commonJS({
76288
76470
  iterator[kError] = err;
76289
76471
  return;
76290
76472
  }
76291
- var resolve19 = iterator[kLastResolve];
76292
- if (resolve19 !== null) {
76473
+ var resolve20 = iterator[kLastResolve];
76474
+ if (resolve20 !== null) {
76293
76475
  iterator[kLastPromise] = null;
76294
76476
  iterator[kLastResolve] = null;
76295
76477
  iterator[kLastReject] = null;
76296
- resolve19(createIterResult(void 0, true));
76478
+ resolve20(createIterResult(void 0, true));
76297
76479
  }
76298
76480
  iterator[kEnded] = true;
76299
76481
  });
@@ -76308,7 +76490,7 @@ var require_async_iterator = __commonJS({
76308
76490
  var require_from2 = __commonJS({
76309
76491
  "../../node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
76310
76492
  "use strict";
76311
- function asyncGeneratorStep(gen, resolve19, reject, _next, _throw, key, arg) {
76493
+ function asyncGeneratorStep(gen, resolve20, reject, _next, _throw, key, arg) {
76312
76494
  try {
76313
76495
  var info = gen[key](arg);
76314
76496
  var value = info.value;
@@ -76317,7 +76499,7 @@ var require_from2 = __commonJS({
76317
76499
  return;
76318
76500
  }
76319
76501
  if (info.done) {
76320
- resolve19(value);
76502
+ resolve20(value);
76321
76503
  } else {
76322
76504
  Promise.resolve(value).then(_next, _throw);
76323
76505
  }
@@ -76325,13 +76507,13 @@ var require_from2 = __commonJS({
76325
76507
  function _asyncToGenerator(fn) {
76326
76508
  return function() {
76327
76509
  var self2 = this, args = arguments;
76328
- return new Promise(function(resolve19, reject) {
76510
+ return new Promise(function(resolve20, reject) {
76329
76511
  var gen = fn.apply(self2, args);
76330
76512
  function _next(value) {
76331
- asyncGeneratorStep(gen, resolve19, reject, _next, _throw, "next", value);
76513
+ asyncGeneratorStep(gen, resolve20, reject, _next, _throw, "next", value);
76332
76514
  }
76333
76515
  function _throw(err) {
76334
- asyncGeneratorStep(gen, resolve19, reject, _next, _throw, "throw", err);
76516
+ asyncGeneratorStep(gen, resolve20, reject, _next, _throw, "throw", err);
76335
76517
  }
76336
76518
  _next(void 0);
76337
76519
  });
@@ -78270,9 +78452,9 @@ var init_base = __esm({
78270
78452
  * @return {Promise}
78271
78453
  */
78272
78454
  run() {
78273
- return new Promise((resolve19, reject) => {
78455
+ return new Promise((resolve20, reject) => {
78274
78456
  this._run(
78275
- (value) => resolve19(value),
78457
+ (value) => resolve20(value),
78276
78458
  (error48) => reject(error48)
78277
78459
  );
78278
78460
  });
@@ -84904,7 +85086,7 @@ var require_lib2 = __commonJS({
84904
85086
  return matches;
84905
85087
  };
84906
85088
  exports2.analyse = analyse;
84907
- var detectFile = (filepath, opts = {}) => new Promise((resolve19, reject) => {
85089
+ var detectFile = (filepath, opts = {}) => new Promise((resolve20, reject) => {
84908
85090
  let fd;
84909
85091
  const fs20 = (0, node_1.default)();
84910
85092
  const handler = (err, buffer) => {
@@ -84914,7 +85096,7 @@ var require_lib2 = __commonJS({
84914
85096
  if (err) {
84915
85097
  reject(err);
84916
85098
  } else if (buffer) {
84917
- resolve19((0, exports2.detect)(buffer));
85099
+ resolve20((0, exports2.detect)(buffer));
84918
85100
  } else {
84919
85101
  reject(new Error("No error and no buffer received"));
84920
85102
  }
@@ -88842,14 +89024,14 @@ function splitStringBySpace(str) {
88842
89024
  }
88843
89025
  return pieces;
88844
89026
  }
88845
- var import_chardet, import_child_process14, import_fs8, import_node_path2, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
89027
+ var import_chardet, import_child_process14, import_fs8, import_node_path3, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
88846
89028
  var init_esm2 = __esm({
88847
89029
  "../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
88848
89030
  "use strict";
88849
89031
  import_chardet = __toESM(require_lib2(), 1);
88850
89032
  import_child_process14 = require("child_process");
88851
89033
  import_fs8 = require("fs");
88852
- import_node_path2 = __toESM(require("path"), 1);
89034
+ import_node_path3 = __toESM(require("path"), 1);
88853
89035
  import_node_os4 = __toESM(require("os"), 1);
88854
89036
  import_node_crypto2 = require("crypto");
88855
89037
  import_iconv_lite = __toESM(require_lib3(), 1);
@@ -88914,8 +89096,8 @@ var init_esm2 = __esm({
88914
89096
  const prefix = sanitizeAffix(this.fileOptions.prefix);
88915
89097
  const postfix = sanitizeAffix(this.fileOptions.postfix);
88916
89098
  const filename = `${prefix}${id}${postfix}`;
88917
- const candidate = import_node_path2.default.resolve(baseDir, filename);
88918
- const baseResolved = import_node_path2.default.resolve(baseDir) + import_node_path2.default.sep;
89099
+ const candidate = import_node_path3.default.resolve(baseDir, filename);
89100
+ const baseResolved = import_node_path3.default.resolve(baseDir) + import_node_path3.default.sep;
88919
89101
  if (!candidate.startsWith(baseResolved)) {
88920
89102
  throw new Error("Resolved temporary file escaped the base directory");
88921
89103
  }