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/cli/index.js CHANGED
@@ -3176,8 +3176,8 @@ async function detectIDEs(providerLoader) {
3176
3176
  if ((0, import_fs4.existsSync)(bundledCli)) resolvedCli = bundledCli;
3177
3177
  }
3178
3178
  if (!resolvedCli && appPath && os31 === "win32") {
3179
- const { dirname: dirname11 } = await import("path");
3180
- const appDir = dirname11(appPath);
3179
+ const { dirname: dirname12 } = await import("path");
3180
+ const appDir = dirname12(appPath);
3181
3181
  const candidates = [
3182
3182
  `${appDir}\\\\bin\\\\${def.cli}.cmd`,
3183
3183
  `${appDir}\\\\bin\\\\${def.cli}`,
@@ -3249,19 +3249,19 @@ function resolveCommandPath(command) {
3249
3249
  return null;
3250
3250
  }
3251
3251
  function execAsync(cmd, timeoutMs = 5e3) {
3252
- return new Promise((resolve22) => {
3252
+ return new Promise((resolve23) => {
3253
3253
  const child = (0, import_child_process2.exec)(cmd, {
3254
3254
  encoding: "utf-8",
3255
3255
  timeout: timeoutMs,
3256
3256
  ...process.platform === "win32" ? { windowsHide: true } : {}
3257
3257
  }, (err, stdout) => {
3258
3258
  if (err || !stdout?.trim()) {
3259
- resolve22(null);
3259
+ resolve23(null);
3260
3260
  } else {
3261
- resolve22(stdout.trim());
3261
+ resolve23(stdout.trim());
3262
3262
  }
3263
3263
  });
3264
- child.on("error", () => resolve22(null));
3264
+ child.on("error", () => resolve23(null));
3265
3265
  });
3266
3266
  }
3267
3267
  async function detectCLIs(providerLoader, options) {
@@ -3873,7 +3873,7 @@ var init_manager = __esm({
3873
3873
  * Returns multiple entries if multiple IDE windows are open on same port
3874
3874
  */
3875
3875
  static listAllTargets(port) {
3876
- return new Promise((resolve22) => {
3876
+ return new Promise((resolve23) => {
3877
3877
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
3878
3878
  let data = "";
3879
3879
  res.on("data", (chunk) => data += chunk.toString());
@@ -3889,16 +3889,16 @@ var init_manager = __esm({
3889
3889
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
3890
3890
  );
3891
3891
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
3892
- resolve22(mainPages.length > 0 ? mainPages : fallbackPages);
3892
+ resolve23(mainPages.length > 0 ? mainPages : fallbackPages);
3893
3893
  } catch {
3894
- resolve22([]);
3894
+ resolve23([]);
3895
3895
  }
3896
3896
  });
3897
3897
  });
3898
- req.on("error", () => resolve22([]));
3898
+ req.on("error", () => resolve23([]));
3899
3899
  req.setTimeout(2e3, () => {
3900
3900
  req.destroy();
3901
- resolve22([]);
3901
+ resolve23([]);
3902
3902
  });
3903
3903
  });
3904
3904
  }
@@ -3938,7 +3938,7 @@ var init_manager = __esm({
3938
3938
  }
3939
3939
  }
3940
3940
  findTargetOnPort(port) {
3941
- return new Promise((resolve22) => {
3941
+ return new Promise((resolve23) => {
3942
3942
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
3943
3943
  let data = "";
3944
3944
  res.on("data", (chunk) => data += chunk.toString());
@@ -3949,7 +3949,7 @@ var init_manager = __esm({
3949
3949
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
3950
3950
  );
3951
3951
  if (pages.length === 0) {
3952
- resolve22(targets.find((t) => t.webSocketDebuggerUrl) || null);
3952
+ resolve23(targets.find((t) => t.webSocketDebuggerUrl) || null);
3953
3953
  return;
3954
3954
  }
3955
3955
  const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -3968,25 +3968,25 @@ var init_manager = __esm({
3968
3968
  this._targetId = selected.target.id;
3969
3969
  }
3970
3970
  this._pageTitle = selected.target.title || "";
3971
- resolve22(selected.target);
3971
+ resolve23(selected.target);
3972
3972
  return;
3973
3973
  }
3974
3974
  if (previousTargetId) {
3975
3975
  this.log(`[CDP] Target ${previousTargetId} not found in page list`);
3976
- resolve22(null);
3976
+ resolve23(null);
3977
3977
  return;
3978
3978
  }
3979
3979
  this._pageTitle = list[0]?.title || "";
3980
- resolve22(list[0]);
3980
+ resolve23(list[0]);
3981
3981
  } catch {
3982
- resolve22(null);
3982
+ resolve23(null);
3983
3983
  }
3984
3984
  });
3985
3985
  });
3986
- req.on("error", () => resolve22(null));
3986
+ req.on("error", () => resolve23(null));
3987
3987
  req.setTimeout(2e3, () => {
3988
3988
  req.destroy();
3989
- resolve22(null);
3989
+ resolve23(null);
3990
3990
  });
3991
3991
  });
3992
3992
  }
@@ -3997,7 +3997,7 @@ var init_manager = __esm({
3997
3997
  this.extensionProviders = providers;
3998
3998
  }
3999
3999
  connectToTarget(wsUrl) {
4000
- return new Promise((resolve22) => {
4000
+ return new Promise((resolve23) => {
4001
4001
  this.ws = new import_ws.default(wsUrl);
4002
4002
  this.ws.on("open", async () => {
4003
4003
  this._connected = true;
@@ -4007,17 +4007,17 @@ var init_manager = __esm({
4007
4007
  }
4008
4008
  this.connectBrowserWs().catch(() => {
4009
4009
  });
4010
- resolve22(true);
4010
+ resolve23(true);
4011
4011
  });
4012
4012
  this.ws.on("message", (data) => {
4013
4013
  try {
4014
4014
  const msg = JSON.parse(data.toString());
4015
4015
  if (msg.id && this.pending.has(msg.id)) {
4016
- const { resolve: resolve23, reject } = this.pending.get(msg.id);
4016
+ const { resolve: resolve24, reject } = this.pending.get(msg.id);
4017
4017
  this.pending.delete(msg.id);
4018
4018
  this.failureCount = 0;
4019
4019
  if (msg.error) reject(new Error(msg.error.message));
4020
- else resolve23(msg.result);
4020
+ else resolve24(msg.result);
4021
4021
  } else if (msg.method === "Runtime.executionContextCreated") {
4022
4022
  this.contexts.add(msg.params.context.id);
4023
4023
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -4040,7 +4040,7 @@ var init_manager = __esm({
4040
4040
  this.ws.on("error", (err) => {
4041
4041
  this.log(`[CDP] WebSocket error: ${err.message}`);
4042
4042
  this._connected = false;
4043
- resolve22(false);
4043
+ resolve23(false);
4044
4044
  });
4045
4045
  });
4046
4046
  }
@@ -4054,7 +4054,7 @@ var init_manager = __esm({
4054
4054
  return;
4055
4055
  }
4056
4056
  this.log(`[CDP] Connecting browser WS for target discovery...`);
4057
- await new Promise((resolve22, reject) => {
4057
+ await new Promise((resolve23, reject) => {
4058
4058
  this.browserWs = new import_ws.default(browserWsUrl);
4059
4059
  this.browserWs.on("open", async () => {
4060
4060
  this._browserConnected = true;
@@ -4064,16 +4064,16 @@ var init_manager = __esm({
4064
4064
  } catch (e) {
4065
4065
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
4066
4066
  }
4067
- resolve22();
4067
+ resolve23();
4068
4068
  });
4069
4069
  this.browserWs.on("message", (data) => {
4070
4070
  try {
4071
4071
  const msg = JSON.parse(data.toString());
4072
4072
  if (msg.id && this.browserPending.has(msg.id)) {
4073
- const { resolve: resolve23, reject: reject2 } = this.browserPending.get(msg.id);
4073
+ const { resolve: resolve24, reject: reject2 } = this.browserPending.get(msg.id);
4074
4074
  this.browserPending.delete(msg.id);
4075
4075
  if (msg.error) reject2(new Error(msg.error.message));
4076
- else resolve23(msg.result);
4076
+ else resolve24(msg.result);
4077
4077
  }
4078
4078
  } catch {
4079
4079
  }
@@ -4093,31 +4093,31 @@ var init_manager = __esm({
4093
4093
  }
4094
4094
  }
4095
4095
  getBrowserWsUrl() {
4096
- return new Promise((resolve22) => {
4096
+ return new Promise((resolve23) => {
4097
4097
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
4098
4098
  let data = "";
4099
4099
  res.on("data", (chunk) => data += chunk.toString());
4100
4100
  res.on("end", () => {
4101
4101
  try {
4102
4102
  const info = JSON.parse(data);
4103
- resolve22(info.webSocketDebuggerUrl || null);
4103
+ resolve23(info.webSocketDebuggerUrl || null);
4104
4104
  } catch {
4105
- resolve22(null);
4105
+ resolve23(null);
4106
4106
  }
4107
4107
  });
4108
4108
  });
4109
- req.on("error", () => resolve22(null));
4109
+ req.on("error", () => resolve23(null));
4110
4110
  req.setTimeout(3e3, () => {
4111
4111
  req.destroy();
4112
- resolve22(null);
4112
+ resolve23(null);
4113
4113
  });
4114
4114
  });
4115
4115
  }
4116
4116
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
4117
- return new Promise((resolve22, reject) => {
4117
+ return new Promise((resolve23, reject) => {
4118
4118
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
4119
4119
  const id = this.browserMsgId++;
4120
- this.browserPending.set(id, { resolve: resolve22, reject });
4120
+ this.browserPending.set(id, { resolve: resolve23, reject });
4121
4121
  this.browserWs.send(JSON.stringify({ id, method, params }));
4122
4122
  setTimeout(() => {
4123
4123
  if (this.browserPending.has(id)) {
@@ -4157,11 +4157,11 @@ var init_manager = __esm({
4157
4157
  }
4158
4158
  // ─── CDP Protocol ────────────────────────────────────────
4159
4159
  sendInternal(method, params = {}, timeoutMs = 15e3) {
4160
- return new Promise((resolve22, reject) => {
4160
+ return new Promise((resolve23, reject) => {
4161
4161
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
4162
4162
  if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
4163
4163
  const id = this.msgId++;
4164
- this.pending.set(id, { resolve: resolve22, reject });
4164
+ this.pending.set(id, { resolve: resolve23, reject });
4165
4165
  this.ws.send(JSON.stringify({ id, method, params }));
4166
4166
  setTimeout(() => {
4167
4167
  if (this.pending.has(id)) {
@@ -4410,7 +4410,7 @@ var init_manager = __esm({
4410
4410
  const browserWs = this.browserWs;
4411
4411
  let msgId = this.browserMsgId;
4412
4412
  const sendWs = (method, params = {}, sessionId) => {
4413
- return new Promise((resolve22, reject) => {
4413
+ return new Promise((resolve23, reject) => {
4414
4414
  const mid = msgId++;
4415
4415
  this.browserMsgId = msgId;
4416
4416
  const handler = (raw) => {
@@ -4419,7 +4419,7 @@ var init_manager = __esm({
4419
4419
  if (msg.id === mid) {
4420
4420
  browserWs.removeListener("message", handler);
4421
4421
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
4422
- else resolve22(msg.result);
4422
+ else resolve23(msg.result);
4423
4423
  }
4424
4424
  } catch {
4425
4425
  }
@@ -4620,14 +4620,14 @@ var init_manager = __esm({
4620
4620
  if (!ws || ws.readyState !== import_ws.default.OPEN) {
4621
4621
  throw new Error("CDP not connected");
4622
4622
  }
4623
- return new Promise((resolve22, reject) => {
4623
+ return new Promise((resolve23, reject) => {
4624
4624
  const id = getNextId();
4625
4625
  pendingMap.set(id, {
4626
4626
  resolve: (result) => {
4627
4627
  if (result?.result?.subtype === "error") {
4628
4628
  reject(new Error(result.result.description));
4629
4629
  } else {
4630
- resolve22(result?.result?.value);
4630
+ resolve23(result?.result?.value);
4631
4631
  }
4632
4632
  },
4633
4633
  reject
@@ -4659,10 +4659,10 @@ var init_manager = __esm({
4659
4659
  throw new Error("CDP not connected");
4660
4660
  }
4661
4661
  const sendViaSession = (method, params = {}) => {
4662
- return new Promise((resolve22, reject) => {
4662
+ return new Promise((resolve23, reject) => {
4663
4663
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
4664
4664
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
4665
- pendingMap.set(id, { resolve: resolve22, reject });
4665
+ pendingMap.set(id, { resolve: resolve23, reject });
4666
4666
  ws.send(JSON.stringify({ id, sessionId, method, params }));
4667
4667
  setTimeout(() => {
4668
4668
  if (pendingMap.has(id)) {
@@ -8984,7 +8984,8 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
8984
8984
  },
8985
8985
  errorMessage: state.errorMessage,
8986
8986
  errorReason: state.errorReason,
8987
- lastUpdated: state.lastUpdated
8987
+ lastUpdated: state.lastUpdated,
8988
+ settings: state.settings
8988
8989
  };
8989
8990
  }
8990
8991
  function buildExtensionAgentSession(parent, ext, options) {
@@ -9019,7 +9020,8 @@ function buildExtensionAgentSession(parent, ext, options) {
9019
9020
  },
9020
9021
  errorMessage: ext.errorMessage,
9021
9022
  errorReason: ext.errorReason,
9022
- lastUpdated: ext.lastUpdated
9023
+ lastUpdated: ext.lastUpdated,
9024
+ settings: ext.settings
9023
9025
  };
9024
9026
  }
9025
9027
  function shouldIncludeExtensionSession(ext) {
@@ -9085,7 +9087,8 @@ function buildCliSession(state, options) {
9085
9087
  },
9086
9088
  errorMessage: state.errorMessage,
9087
9089
  errorReason: state.errorReason,
9088
- lastUpdated: state.lastUpdated
9090
+ lastUpdated: state.lastUpdated,
9091
+ settings: state.settings
9089
9092
  };
9090
9093
  }
9091
9094
  function buildAcpSession(state, options) {
@@ -9119,7 +9122,8 @@ function buildAcpSession(state, options) {
9119
9122
  },
9120
9123
  errorMessage: state.errorMessage,
9121
9124
  errorReason: state.errorReason,
9122
- lastUpdated: state.lastUpdated
9125
+ lastUpdated: state.lastUpdated,
9126
+ settings: state.settings
9123
9127
  };
9124
9128
  }
9125
9129
  function buildSessionEntries(allStates, cdpManagers, options = {}) {
@@ -9583,6 +9587,8 @@ function getSendChatInputEnvelope(args) {
9583
9587
  function getHistorySessionId(h, args) {
9584
9588
  const explicit = typeof args?.historySessionId === "string" ? args.historySessionId.trim() : "";
9585
9589
  if (explicit) return explicit;
9590
+ const explicitProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : "";
9591
+ if (explicitProviderSessionId) return explicitProviderSessionId;
9586
9592
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
9587
9593
  if (!targetSessionId) return void 0;
9588
9594
  const instance = h.ctx.instanceManager?.getInstance(targetSessionId);
@@ -10041,7 +10047,7 @@ function getCliVisibleTranscriptCount(adapter) {
10041
10047
  async function getStableExtensionBaseline(h) {
10042
10048
  const first = await readExtensionChatState(h);
10043
10049
  if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
10044
- await new Promise((resolve22) => setTimeout(resolve22, 150));
10050
+ await new Promise((resolve23) => setTimeout(resolve23, 150));
10045
10051
  const second = await readExtensionChatState(h);
10046
10052
  return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
10047
10053
  }
@@ -10049,7 +10055,7 @@ async function verifyExtensionSendObserved(h, before) {
10049
10055
  const beforeCount = getStateMessageCount(before);
10050
10056
  const beforeSignature = getStateLastSignature(before);
10051
10057
  for (let attempt = 0; attempt < 12; attempt += 1) {
10052
- await new Promise((resolve22) => setTimeout(resolve22, 250));
10058
+ await new Promise((resolve23) => setTimeout(resolve23, 250));
10053
10059
  const state = await readExtensionChatState(h);
10054
10060
  if (state?.status === "waiting_approval") return true;
10055
10061
  const afterCount = getStateMessageCount(state);
@@ -10139,7 +10145,32 @@ async function handleReadChat(h, args) {
10139
10145
  ...coverage ? { coverage } : {}
10140
10146
  }, args);
10141
10147
  }
10142
- return { success: false, error: `${transport} adapter not found` };
10148
+ const historyLimit = normalizeReadChatTailLimit(args);
10149
+ try {
10150
+ const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
10151
+ const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
10152
+ const history = readProviderChatHistory(agentStr, {
10153
+ canonicalHistory: provider?.canonicalHistory,
10154
+ historySessionId,
10155
+ workspace,
10156
+ offset: 0,
10157
+ limit: historyLimit,
10158
+ excludeRecentCount: 0,
10159
+ historyBehavior: provider?.historyBehavior,
10160
+ scripts: provider?.scripts
10161
+ });
10162
+ const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : historySessionId;
10163
+ return buildReadChatCommandResult({
10164
+ messages: Array.isArray(history?.messages) ? history.messages : [],
10165
+ status: "idle",
10166
+ ...typeof history?.title === "string" ? { title: history.title } : {},
10167
+ ...historyProviderSessionId ? { providerSessionId: historyProviderSessionId } : {},
10168
+ ...provider?.historyBehavior?.transcriptAuthority === "provider" || provider?.historyBehavior?.transcriptAuthority === "daemon" ? { transcriptAuthority: (provider?.historyBehavior).transcriptAuthority } : {},
10169
+ coverage: "tail"
10170
+ }, args);
10171
+ } catch (error48) {
10172
+ return { success: false, error: error48?.message || `${transport} adapter not found` };
10173
+ }
10143
10174
  }
10144
10175
  if (isExtensionTransport(transport)) {
10145
10176
  let extensionReadChatError = "";
@@ -11696,7 +11727,7 @@ async function executeProviderScript(h, args, scriptName) {
11696
11727
  const enterCount = cliCommand.enterCount || 1;
11697
11728
  await adapter.writeRaw(cliCommand.text + "\r");
11698
11729
  for (let i = 1; i < enterCount; i += 1) {
11699
- await new Promise((resolve22) => setTimeout(resolve22, 50));
11730
+ await new Promise((resolve23) => setTimeout(resolve23, 50));
11700
11731
  await adapter.writeRaw("\r");
11701
11732
  }
11702
11733
  }
@@ -12412,7 +12443,7 @@ var init_handler = __esm({
12412
12443
  try {
12413
12444
  const http3 = await import("http");
12414
12445
  const postData = JSON.stringify(body);
12415
- const result = await new Promise((resolve22, reject) => {
12446
+ const result = await new Promise((resolve23, reject) => {
12416
12447
  const req = http3.request({
12417
12448
  hostname: "127.0.0.1",
12418
12449
  port: 19280,
@@ -12424,9 +12455,9 @@ var init_handler = __esm({
12424
12455
  res.on("data", (chunk) => data += chunk);
12425
12456
  res.on("end", () => {
12426
12457
  try {
12427
- resolve22(JSON.parse(data));
12458
+ resolve23(JSON.parse(data));
12428
12459
  } catch {
12429
- resolve22({ raw: data });
12460
+ resolve23({ raw: data });
12430
12461
  }
12431
12462
  });
12432
12463
  });
@@ -12444,15 +12475,15 @@ var init_handler = __esm({
12444
12475
  if (!providerType) return { success: false, error: "providerType required" };
12445
12476
  try {
12446
12477
  const http3 = await import("http");
12447
- const result = await new Promise((resolve22, reject) => {
12478
+ const result = await new Promise((resolve23, reject) => {
12448
12479
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
12449
12480
  let data = "";
12450
12481
  res.on("data", (chunk) => data += chunk);
12451
12482
  res.on("end", () => {
12452
12483
  try {
12453
- resolve22(JSON.parse(data));
12484
+ resolve23(JSON.parse(data));
12454
12485
  } catch {
12455
- resolve22({ raw: data });
12486
+ resolve23({ raw: data });
12456
12487
  }
12457
12488
  });
12458
12489
  }).on("error", reject);
@@ -12466,7 +12497,7 @@ var init_handler = __esm({
12466
12497
  try {
12467
12498
  const http3 = await import("http");
12468
12499
  const postData = JSON.stringify(args || {});
12469
- const result = await new Promise((resolve22, reject) => {
12500
+ const result = await new Promise((resolve23, reject) => {
12470
12501
  const req = http3.request({
12471
12502
  hostname: "127.0.0.1",
12472
12503
  port: 19280,
@@ -12478,9 +12509,9 @@ var init_handler = __esm({
12478
12509
  res.on("data", (chunk) => data += chunk);
12479
12510
  res.on("end", () => {
12480
12511
  try {
12481
- resolve22(JSON.parse(data));
12512
+ resolve23(JSON.parse(data));
12482
12513
  } catch {
12483
- resolve22({ raw: data });
12514
+ resolve23({ raw: data });
12484
12515
  }
12485
12516
  });
12486
12517
  });
@@ -13862,8 +13893,8 @@ var init_dist = __esm({
13862
13893
  } catch {
13863
13894
  }
13864
13895
  });
13865
- await new Promise((resolve22, reject) => {
13866
- socket.once("connect", () => resolve22());
13896
+ await new Promise((resolve23, reject) => {
13897
+ socket.once("connect", () => resolve23());
13867
13898
  socket.once("error", reject);
13868
13899
  });
13869
13900
  }
@@ -13882,7 +13913,7 @@ var init_dist = __esm({
13882
13913
  requestId,
13883
13914
  request
13884
13915
  };
13885
- const response = await new Promise((resolve22, reject) => {
13916
+ const response = await new Promise((resolve23, reject) => {
13886
13917
  const timeout = setTimeout(() => {
13887
13918
  this.requestWaiters.delete(requestId);
13888
13919
  reject(new Error(`Session host request timed out after 30s (${request.type})`));
@@ -13890,7 +13921,7 @@ var init_dist = __esm({
13890
13921
  this.requestWaiters.set(requestId, {
13891
13922
  resolve: (value) => {
13892
13923
  clearTimeout(timeout);
13893
- resolve22(value);
13924
+ resolve23(value);
13894
13925
  },
13895
13926
  reject: (error48) => {
13896
13927
  clearTimeout(timeout);
@@ -13909,12 +13940,12 @@ var init_dist = __esm({
13909
13940
  waiter.reject(new Error("Session host client closed"));
13910
13941
  }
13911
13942
  this.requestWaiters.clear();
13912
- await new Promise((resolve22) => {
13943
+ await new Promise((resolve23) => {
13913
13944
  let settled = false;
13914
13945
  const done = () => {
13915
13946
  if (settled) return;
13916
13947
  settled = true;
13917
- resolve22();
13948
+ resolve23();
13918
13949
  };
13919
13950
  socket.once("close", done);
13920
13951
  socket.end();
@@ -15064,7 +15095,7 @@ var init_provider_cli_adapter = __esm({
15064
15095
  `[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
15065
15096
  );
15066
15097
  }
15067
- await new Promise((resolve22) => setTimeout(resolve22, 50));
15098
+ await new Promise((resolve23) => setTimeout(resolve23, 50));
15068
15099
  }
15069
15100
  const finalScreenText = this.terminalScreen.getText() || "";
15070
15101
  LOG.warn(
@@ -15974,7 +16005,7 @@ var init_provider_cli_adapter = __esm({
15974
16005
  const deadline = Date.now() + 1e4;
15975
16006
  while (this.startupParseGate && Date.now() < deadline) {
15976
16007
  this.resolveStartupState("send_wait");
15977
- await new Promise((resolve22) => setTimeout(resolve22, 50));
16008
+ await new Promise((resolve23) => setTimeout(resolve23, 50));
15978
16009
  }
15979
16010
  }
15980
16011
  if (!allowInterventionPrompt) {
@@ -16050,13 +16081,13 @@ var init_provider_cli_adapter = __esm({
16050
16081
  }
16051
16082
  this.responseEpoch += 1;
16052
16083
  this.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
16053
- await new Promise((resolve22, reject) => {
16084
+ await new Promise((resolve23, reject) => {
16054
16085
  let resolved = false;
16055
16086
  const completion = {
16056
16087
  resolveOnce: () => {
16057
16088
  if (resolved) return;
16058
16089
  resolved = true;
16059
- resolve22();
16090
+ resolve23();
16060
16091
  },
16061
16092
  rejectOnce: (error48) => {
16062
16093
  if (resolved) return;
@@ -16214,17 +16245,17 @@ var init_provider_cli_adapter = __esm({
16214
16245
  }
16215
16246
  }
16216
16247
  waitForStopped(timeoutMs) {
16217
- return new Promise((resolve22) => {
16248
+ return new Promise((resolve23) => {
16218
16249
  const startedAt = Date.now();
16219
16250
  const timer = setInterval(() => {
16220
16251
  if (!this.ptyProcess || this.currentStatus === "stopped") {
16221
16252
  clearInterval(timer);
16222
- resolve22(true);
16253
+ resolve23(true);
16223
16254
  return;
16224
16255
  }
16225
16256
  if (Date.now() - startedAt >= timeoutMs) {
16226
16257
  clearInterval(timer);
16227
- resolve22(false);
16258
+ resolve23(false);
16228
16259
  }
16229
16260
  }, 100);
16230
16261
  });
@@ -16367,11 +16398,22 @@ var init_provider_cli_adapter = __esm({
16367
16398
  }
16368
16399
  }
16369
16400
  }
16401
+ getParsedDebugState() {
16402
+ if (this.startupParseGate || typeof this.cliScripts?.parseSession !== "function") return null;
16403
+ try {
16404
+ const parsed = this.getScriptParsedStatus();
16405
+ return parsed && typeof parsed === "object" ? parsed : null;
16406
+ } catch {
16407
+ return null;
16408
+ }
16409
+ }
16370
16410
  getDebugState() {
16371
16411
  const screenText = sanitizeTerminalText(this.terminalScreen.getText());
16372
16412
  const startupModal = this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
16373
16413
  const effectiveStatus = this.projectEffectiveStatus(startupModal);
16374
16414
  const effectiveReady = this.ready || !!startupModal;
16415
+ const parsedDebugState = this.getParsedDebugState();
16416
+ const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
16375
16417
  return {
16376
16418
  type: this.cliType,
16377
16419
  name: this.cliName,
@@ -16384,8 +16426,18 @@ var init_provider_cli_adapter = __esm({
16384
16426
  startupParseGate: this.startupParseGate,
16385
16427
  spawnAt: this.spawnAt,
16386
16428
  workingDir: this.workingDir,
16387
- messages: [],
16388
- messageCount: 0,
16429
+ messages: parsedMessages,
16430
+ messageCount: parsedMessages.length,
16431
+ parsedStatus: parsedDebugState ? {
16432
+ id: parsedDebugState.id,
16433
+ status: parsedDebugState.status,
16434
+ title: parsedDebugState.title,
16435
+ providerSessionId: parsedDebugState.providerSessionId,
16436
+ transcriptAuthority: parsedDebugState.transcriptAuthority,
16437
+ coverage: parsedDebugState.coverage,
16438
+ activeModal: parsedDebugState.activeModal,
16439
+ messageCount: parsedMessages.length
16440
+ } : null,
16389
16441
  screenText: screenText.slice(-4e3),
16390
16442
  currentTurnScope: this.currentTurnScope,
16391
16443
  startupBuffer: this.startupBuffer.slice(-4e3),
@@ -16541,7 +16593,7 @@ async function waitForCliAdapterReady(adapter, options) {
16541
16593
  if (status === "stopped") {
16542
16594
  throw new Error("CLI runtime stopped before it became ready");
16543
16595
  }
16544
- await new Promise((resolve22) => setTimeout(resolve22, pollMs));
16596
+ await new Promise((resolve23) => setTimeout(resolve23, pollMs));
16545
16597
  }
16546
16598
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
16547
16599
  }
@@ -16719,7 +16771,7 @@ var init_cli_provider_instance = __esm({
16719
16771
  this.errorMessage = void 0;
16720
16772
  this.errorReason = void 0;
16721
16773
  }
16722
- const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
16774
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
16723
16775
  const visibleStatus = parseErrorMessage ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
16724
16776
  const parsedProviderSessionId = normalizeProviderSessionId(
16725
16777
  this.provider,
@@ -16906,18 +16958,14 @@ var init_cli_provider_instance = __esm({
16906
16958
  const enterCount = cliCommand.enterCount || 1;
16907
16959
  await this.adapter.writeRaw(cliCommand.text + "\r");
16908
16960
  for (let i = 1; i < enterCount; i += 1) {
16909
- await new Promise((resolve22) => setTimeout(resolve22, 50));
16961
+ await new Promise((resolve23) => setTimeout(resolve23, 50));
16910
16962
  await this.adapter.writeRaw("\r");
16911
16963
  }
16912
16964
  }
16913
16965
  this.applyProviderResponse(parsed.payload, { phase: "immediate" });
16914
16966
  }
16915
- detectStatusTransition() {
16916
- const now = Date.now();
16917
- const adapterStatus = this.adapter.getStatus({ allowParse: false });
16918
- const parsedStatus = null;
16919
- const rawStatus = adapterStatus.status;
16920
- const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
16967
+ maybeAutoApproveStatus(adapterStatus, now = Date.now()) {
16968
+ const autoApproveActive = adapterStatus?.status === "waiting_approval" && this.shouldAutoApprove();
16921
16969
  if (autoApproveActive && !this.autoApproveBusy) {
16922
16970
  this.autoApproveBusy = true;
16923
16971
  if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
@@ -16925,12 +16973,21 @@ var init_cli_provider_instance = __esm({
16925
16973
  this.autoApproveBusy = false;
16926
16974
  this.autoApproveBusyTimer = null;
16927
16975
  }, 2e3);
16928
- const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(adapterStatus.activeModal?.buttons, this.provider);
16929
- this.recordAutoApproval(adapterStatus.activeModal?.message, buttonLabel, now);
16976
+ const modal = adapterStatus.activeModal;
16977
+ const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(modal?.buttons, this.provider);
16978
+ this.recordAutoApproval(modal?.message, buttonLabel, now);
16930
16979
  setTimeout(() => {
16931
16980
  this.adapter.resolveModal(buttonIndex);
16932
16981
  }, 0);
16933
16982
  }
16983
+ return autoApproveActive;
16984
+ }
16985
+ detectStatusTransition() {
16986
+ const now = Date.now();
16987
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
16988
+ const parsedStatus = null;
16989
+ const rawStatus = adapterStatus.status;
16990
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, now);
16934
16991
  const newStatus = autoApproveActive ? "generating" : rawStatus;
16935
16992
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
16936
16993
  const chatTitle = `${this.provider.name} \xB7 ${dirName}`;
@@ -33483,8 +33540,8 @@ var init_acp = __esm({
33483
33540
  this.#requestHandler = requestHandler;
33484
33541
  this.#notificationHandler = notificationHandler;
33485
33542
  this.#stream = stream;
33486
- this.#closedPromise = new Promise((resolve22) => {
33487
- this.#abortController.signal.addEventListener("abort", () => resolve22());
33543
+ this.#closedPromise = new Promise((resolve23) => {
33544
+ this.#abortController.signal.addEventListener("abort", () => resolve23());
33488
33545
  });
33489
33546
  this.#receive();
33490
33547
  }
@@ -33633,8 +33690,8 @@ var init_acp = __esm({
33633
33690
  }
33634
33691
  async sendRequest(method, params) {
33635
33692
  const id = this.#nextRequestId++;
33636
- const responsePromise = new Promise((resolve22, reject) => {
33637
- this.#pendingResponses.set(id, { resolve: resolve22, reject });
33693
+ const responsePromise = new Promise((resolve23, reject) => {
33694
+ this.#pendingResponses.set(id, { resolve: resolve23, reject });
33638
33695
  });
33639
33696
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
33640
33697
  return responsePromise;
@@ -34318,13 +34375,13 @@ var init_acp_provider_instance = __esm({
34318
34375
  }
34319
34376
  this.currentStatus = "waiting_approval";
34320
34377
  this.detectStatusTransition();
34321
- const approved = await new Promise((resolve22) => {
34322
- this.permissionResolvers.push(resolve22);
34378
+ const approved = await new Promise((resolve23) => {
34379
+ this.permissionResolvers.push(resolve23);
34323
34380
  setTimeout(() => {
34324
- const idx = this.permissionResolvers.indexOf(resolve22);
34381
+ const idx = this.permissionResolvers.indexOf(resolve23);
34325
34382
  if (idx >= 0) {
34326
34383
  this.permissionResolvers.splice(idx, 1);
34327
- resolve22(false);
34384
+ resolve23(false);
34328
34385
  }
34329
34386
  }, 3e5);
34330
34387
  });
@@ -35336,7 +35393,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
35336
35393
  resolvedDir,
35337
35394
  resolvedCliArgs,
35338
35395
  resolvedProvider,
35339
- this.providerLoader.getSettings(normalizedType),
35396
+ { ...this.providerLoader.getSettings(normalizedType), ...options?.settingsOverride || {} },
35340
35397
  false,
35341
35398
  {
35342
35399
  providerSessionId: sessionBinding.providerSessionId,
@@ -35590,7 +35647,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
35590
35647
  dir,
35591
35648
  args?.cliArgs,
35592
35649
  args?.initialModel,
35593
- { resumeSessionId: args?.resumeSessionId }
35650
+ { resumeSessionId: args?.resumeSessionId, settingsOverride: args?.settings }
35594
35651
  );
35595
35652
  return {
35596
35653
  success: true,
@@ -36459,9 +36516,9 @@ var init_handler2 = __esm({
36459
36516
  if (this.fsw.closed) {
36460
36517
  return;
36461
36518
  }
36462
- const dirname11 = sp.dirname(file2);
36519
+ const dirname12 = sp.dirname(file2);
36463
36520
  const basename10 = sp.basename(file2);
36464
- const parent = this.fsw._getWatchedDir(dirname11);
36521
+ const parent = this.fsw._getWatchedDir(dirname12);
36465
36522
  let prevStats = stats;
36466
36523
  if (parent.has(basename10))
36467
36524
  return;
@@ -36488,7 +36545,7 @@ var init_handler2 = __esm({
36488
36545
  prevStats = newStats2;
36489
36546
  }
36490
36547
  } catch (error48) {
36491
- this.fsw._remove(dirname11, basename10);
36548
+ this.fsw._remove(dirname12, basename10);
36492
36549
  }
36493
36550
  } else if (parent.has(basename10)) {
36494
36551
  const at = newStats.atimeMs;
@@ -36585,7 +36642,7 @@ var init_handler2 = __esm({
36585
36642
  this._addToNodeFs(path40, initialAdd, wh, depth + 1);
36586
36643
  }
36587
36644
  }).on(EV.ERROR, this._boundHandleError);
36588
- return new Promise((resolve22, reject) => {
36645
+ return new Promise((resolve23, reject) => {
36589
36646
  if (!stream)
36590
36647
  return reject();
36591
36648
  stream.once(STR_END, () => {
@@ -36594,7 +36651,7 @@ var init_handler2 = __esm({
36594
36651
  return;
36595
36652
  }
36596
36653
  const wasThrottled = throttler ? throttler.clear() : false;
36597
- resolve22(void 0);
36654
+ resolve23(void 0);
36598
36655
  previous.getChildren().filter((item) => {
36599
36656
  return item !== directory && !current.has(item);
36600
36657
  }).forEach((item) => {
@@ -38694,7 +38751,7 @@ var init_provider_loader = __esm({
38694
38751
  return { updated: false };
38695
38752
  }
38696
38753
  try {
38697
- const etag = await new Promise((resolve22, reject) => {
38754
+ const etag = await new Promise((resolve23, reject) => {
38698
38755
  const options = {
38699
38756
  method: "HEAD",
38700
38757
  hostname: "github.com",
@@ -38712,7 +38769,7 @@ var init_provider_loader = __esm({
38712
38769
  headers: { "User-Agent": "adhdev-launcher" },
38713
38770
  timeout: 1e4
38714
38771
  }, (res2) => {
38715
- resolve22(res2.headers.etag || res2.headers["last-modified"] || "");
38772
+ resolve23(res2.headers.etag || res2.headers["last-modified"] || "");
38716
38773
  });
38717
38774
  req2.on("error", reject);
38718
38775
  req2.on("timeout", () => {
@@ -38721,7 +38778,7 @@ var init_provider_loader = __esm({
38721
38778
  });
38722
38779
  req2.end();
38723
38780
  } else {
38724
- resolve22(res.headers.etag || res.headers["last-modified"] || "");
38781
+ resolve23(res.headers.etag || res.headers["last-modified"] || "");
38725
38782
  }
38726
38783
  });
38727
38784
  req.on("error", reject);
@@ -38785,7 +38842,7 @@ var init_provider_loader = __esm({
38785
38842
  downloadFile(url2, destPath) {
38786
38843
  const https = require("https");
38787
38844
  const http3 = require("http");
38788
- return new Promise((resolve22, reject) => {
38845
+ return new Promise((resolve23, reject) => {
38789
38846
  const doRequest = (reqUrl, redirectCount = 0) => {
38790
38847
  if (redirectCount > 5) {
38791
38848
  reject(new Error("Too many redirects"));
@@ -38805,7 +38862,7 @@ var init_provider_loader = __esm({
38805
38862
  res.pipe(ws);
38806
38863
  ws.on("finish", () => {
38807
38864
  ws.close();
38808
- resolve22();
38865
+ resolve23();
38809
38866
  });
38810
38867
  ws.on("error", reject);
38811
38868
  });
@@ -39390,17 +39447,17 @@ async function findFreePort(ports) {
39390
39447
  throw new Error("No free port found");
39391
39448
  }
39392
39449
  function checkPortFree(port) {
39393
- return new Promise((resolve22) => {
39450
+ return new Promise((resolve23) => {
39394
39451
  const server = net2.createServer();
39395
39452
  server.unref();
39396
- server.on("error", () => resolve22(false));
39453
+ server.on("error", () => resolve23(false));
39397
39454
  server.listen(port, "127.0.0.1", () => {
39398
- server.close(() => resolve22(true));
39455
+ server.close(() => resolve23(true));
39399
39456
  });
39400
39457
  });
39401
39458
  }
39402
39459
  async function isCdpActive(port) {
39403
- return new Promise((resolve22) => {
39460
+ return new Promise((resolve23) => {
39404
39461
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
39405
39462
  timeout: 2e3
39406
39463
  }, (res) => {
@@ -39409,16 +39466,16 @@ async function isCdpActive(port) {
39409
39466
  res.on("end", () => {
39410
39467
  try {
39411
39468
  const info = JSON.parse(data);
39412
- resolve22(!!info["WebKit-Version"] || !!info["Browser"]);
39469
+ resolve23(!!info["WebKit-Version"] || !!info["Browser"]);
39413
39470
  } catch {
39414
- resolve22(false);
39471
+ resolve23(false);
39415
39472
  }
39416
39473
  });
39417
39474
  });
39418
- req.on("error", () => resolve22(false));
39475
+ req.on("error", () => resolve23(false));
39419
39476
  req.on("timeout", () => {
39420
39477
  req.destroy();
39421
- resolve22(false);
39478
+ resolve23(false);
39422
39479
  });
39423
39480
  });
39424
39481
  }
@@ -39929,11 +39986,23 @@ function resolveMeshCoordinatorSetup(options) {
39929
39986
  if (!path40) {
39930
39987
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
39931
39988
  }
39989
+ const mcpServer = resolveAdhdevMcpServerLaunch({
39990
+ meshId,
39991
+ nodeExecutable: options.nodeExecutable,
39992
+ adhdevMcpEntryPath: options.adhdevMcpEntryPath
39993
+ });
39994
+ if (!mcpServer) {
39995
+ return {
39996
+ kind: "unsupported",
39997
+ reason: "Could not resolve the ADHDev MCP server entrypoint without relying on a PATH bin shim"
39998
+ };
39999
+ }
39932
40000
  return {
39933
40001
  kind: "auto_import",
39934
40002
  serverName,
39935
- configPath: (0, import_path4.join)(workspace, path40),
39936
- configFormat: mcpConfig.format
40003
+ configPath: (0, import_node_path2.join)(workspace, path40),
40004
+ configFormat: mcpConfig.format,
40005
+ mcpServer
39937
40006
  };
39938
40007
  }
39939
40008
  if (mcpConfig.mode === "manual") {
@@ -39965,11 +40034,60 @@ function resolveMeshCoordinatorSetup(options) {
39965
40034
  function renderMeshCoordinatorTemplate(template, values) {
39966
40035
  return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_2, key) => values[key] || "");
39967
40036
  }
39968
- var import_path4, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND;
40037
+ function resolveAdhdevMcpServerLaunch(options) {
40038
+ const entryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath);
40039
+ if (!entryPath) return null;
40040
+ return {
40041
+ command: options.nodeExecutable?.trim() || process.execPath,
40042
+ args: [entryPath, "--repo-mesh", options.meshId]
40043
+ };
40044
+ }
40045
+ function resolveAdhdevMcpEntryPath(explicitPath) {
40046
+ const explicit = explicitPath?.trim();
40047
+ if (explicit) return normalizeExistingPath(explicit) || explicit;
40048
+ const envPath = process.env.ADHDEV_MCP_SERVER_PATH?.trim();
40049
+ if (envPath) return normalizeExistingPath(envPath) || envPath;
40050
+ const candidates = [];
40051
+ const addCandidate = (candidate) => {
40052
+ if (!candidates.includes(candidate)) candidates.push(candidate);
40053
+ };
40054
+ const addPackagedCandidates = (baseFile) => {
40055
+ if (!baseFile) return;
40056
+ const realBase = normalizeExistingPath(baseFile) || baseFile;
40057
+ const dir = (0, import_node_path2.dirname)(realBase);
40058
+ addCandidate((0, import_node_path2.resolve)(dir, "../vendor/mcp-server/index.js"));
40059
+ addCandidate((0, import_node_path2.resolve)(dir, "../../vendor/mcp-server/index.js"));
40060
+ addCandidate((0, import_node_path2.resolve)(dir, "../../../vendor/mcp-server/index.js"));
40061
+ };
40062
+ addPackagedCandidates(process.argv[1]);
40063
+ for (const candidate of candidates) {
40064
+ const normalized = normalizeExistingPath(candidate);
40065
+ if (normalized) return normalized;
40066
+ }
40067
+ try {
40068
+ const requireBase = process.argv[1] ? normalizeExistingPath(process.argv[1]) || process.argv[1] : (0, import_node_path2.join)(process.cwd(), "adhdev-daemon.js");
40069
+ const req = (0, import_node_module2.createRequire)(requireBase);
40070
+ const resolvedModule = req.resolve("@adhdev/mcp-server");
40071
+ return normalizeExistingPath(resolvedModule) || resolvedModule;
40072
+ } catch {
40073
+ return null;
40074
+ }
40075
+ }
40076
+ function normalizeExistingPath(filePath) {
40077
+ try {
40078
+ if (!(0, import_node_fs4.existsSync)(filePath)) return null;
40079
+ return import_node_fs4.realpathSync.native(filePath);
40080
+ } catch {
40081
+ return null;
40082
+ }
40083
+ }
40084
+ var import_node_fs4, import_node_module2, import_node_path2, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND;
39969
40085
  var init_mesh_coordinator = __esm({
39970
40086
  "../../oss/packages/daemon-core/src/commands/mesh-coordinator.ts"() {
39971
40087
  "use strict";
39972
- import_path4 = require("path");
40088
+ import_node_fs4 = require("fs");
40089
+ import_node_module2 = require("module");
40090
+ import_node_path2 = require("path");
39973
40091
  DEFAULT_SERVER_NAME = "adhdev-mesh";
39974
40092
  DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
39975
40093
  }
@@ -40488,7 +40606,7 @@ async function waitForPidExit(pid, timeoutMs) {
40488
40606
  while (Date.now() - start < timeoutMs) {
40489
40607
  try {
40490
40608
  process.kill(pid, 0);
40491
- await new Promise((resolve22) => setTimeout(resolve22, 250));
40609
+ await new Promise((resolve23) => setTimeout(resolve23, 250));
40492
40610
  } catch {
40493
40611
  return;
40494
40612
  }
@@ -40599,7 +40717,7 @@ async function runDaemonUpgradeHelper(payload) {
40599
40717
  appendUpgradeLog(installOutput.trim());
40600
40718
  }
40601
40719
  if (process.platform === "win32") {
40602
- await new Promise((resolve22) => setTimeout(resolve22, 500));
40720
+ await new Promise((resolve23) => setTimeout(resolve23, 500));
40603
40721
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
40604
40722
  appendUpgradeLog("Post-install staging cleanup complete");
40605
40723
  }
@@ -41475,11 +41593,16 @@ var init_router = __esm({
41475
41593
  const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
41476
41594
  if (!meshId) return { success: false, error: "meshId required" };
41477
41595
  try {
41478
- const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41479
41596
  const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
41480
- const mesh = getMesh3(meshId);
41597
+ let mesh;
41598
+ if (args?.inlineMesh && typeof args.inlineMesh === "object") {
41599
+ mesh = args.inlineMesh;
41600
+ } else {
41601
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
41602
+ mesh = getMesh3(meshId);
41603
+ }
41481
41604
  if (!mesh) return { success: false, error: "Mesh not found" };
41482
- if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
41605
+ if (!Array.isArray(mesh.nodes) || mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
41483
41606
  const workspace = mesh.nodes[0].workspace;
41484
41607
  const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
41485
41608
  const coordinatorSetup = resolveMeshCoordinatorSetup({
@@ -41518,9 +41641,9 @@ var init_router = __esm({
41518
41641
  workspace
41519
41642
  };
41520
41643
  }
41521
- const { existsSync: existsSync28, readFileSync: readFileSync21, writeFileSync: writeFileSync15, copyFileSync: copyFileSync4 } = await import("fs");
41644
+ const { existsSync: existsSync29, readFileSync: readFileSync21, writeFileSync: writeFileSync15, copyFileSync: copyFileSync4 } = await import("fs");
41522
41645
  const mcpConfigPath = coordinatorSetup.configPath;
41523
- const hadExistingMcpConfig = existsSync28(mcpConfigPath);
41646
+ const hadExistingMcpConfig = existsSync29(mcpConfigPath);
41524
41647
  let existingMcpConfig = {};
41525
41648
  if (hadExistingMcpConfig) {
41526
41649
  try {
@@ -41534,8 +41657,8 @@ var init_router = __esm({
41534
41657
  mcpServers: {
41535
41658
  ...existingMcpConfig.mcpServers || {},
41536
41659
  [coordinatorSetup.serverName]: {
41537
- command: "adhdev-mcp",
41538
- args: ["--repo-mesh", meshId]
41660
+ command: coordinatorSetup.mcpServer.command,
41661
+ args: coordinatorSetup.mcpServer.args
41539
41662
  }
41540
41663
  }
41541
41664
  };
@@ -41547,10 +41670,20 @@ var init_router = __esm({
41547
41670
  } catch {
41548
41671
  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).`;
41549
41672
  }
41673
+ const cliArgs = [];
41674
+ if (systemPrompt) {
41675
+ cliArgs.push("--append-system-prompt", systemPrompt);
41676
+ }
41677
+ if (cliType === "claude-cli") {
41678
+ cliArgs.push("--mcp-config", coordinatorSetup.configPath);
41679
+ }
41550
41680
  const launchResult = await this.deps.cliManager.handleCliCommand("launch_cli", {
41551
41681
  cliType,
41552
41682
  dir: workspace,
41553
- initialPrompt: systemPrompt
41683
+ cliArgs: cliArgs.length > 0 ? cliArgs : void 0,
41684
+ settings: {
41685
+ meshCoordinatorFor: meshId
41686
+ }
41554
41687
  });
41555
41688
  if (!launchResult?.success) {
41556
41689
  return { success: false, error: launchResult?.error || "Failed to launch CLI session" };
@@ -41861,7 +41994,8 @@ var init_reporter = __esm({
41861
41994
  workspace: session.workspace ?? null,
41862
41995
  title: session.title,
41863
41996
  cdpConnected: session.cdpConnected,
41864
- summaryMetadata: session.summaryMetadata
41997
+ summaryMetadata: session.summaryMetadata,
41998
+ settings: session.settings
41865
41999
  })),
41866
42000
  p2p: payload.p2p,
41867
42001
  timestamp: now
@@ -42210,7 +42344,7 @@ var init_provider_adapter = __esm({
42210
42344
  const beforeCount = this.messageCount(before);
42211
42345
  const beforeSignature = this.lastMessageSignature(before);
42212
42346
  for (let attempt = 0; attempt < 12; attempt += 1) {
42213
- await new Promise((resolve22) => setTimeout(resolve22, 250));
42347
+ await new Promise((resolve23) => setTimeout(resolve23, 250));
42214
42348
  let state;
42215
42349
  try {
42216
42350
  state = await this.readChat(evaluate);
@@ -42232,7 +42366,7 @@ var init_provider_adapter = __esm({
42232
42366
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
42233
42367
  return first;
42234
42368
  }
42235
- await new Promise((resolve22) => setTimeout(resolve22, 150));
42369
+ await new Promise((resolve23) => setTimeout(resolve23, 150));
42236
42370
  const second = await this.readChat(evaluate);
42237
42371
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
42238
42372
  }
@@ -42383,7 +42517,7 @@ var init_provider_adapter = __esm({
42383
42517
  if (typeof data.error === "string" && data.error.trim()) return false;
42384
42518
  }
42385
42519
  for (let attempt = 0; attempt < 6; attempt += 1) {
42386
- await new Promise((resolve22) => setTimeout(resolve22, 250));
42520
+ await new Promise((resolve23) => setTimeout(resolve23, 250));
42387
42521
  const state = await this.readChat(evaluate);
42388
42522
  const title = this.getStateTitle(state);
42389
42523
  if (this.titlesMatch(title, sessionId)) return true;
@@ -45030,7 +45164,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
45030
45164
  return { target, instance, adapter };
45031
45165
  }
45032
45166
  function sleep(ms) {
45033
- return new Promise((resolve22) => setTimeout(resolve22, ms));
45167
+ return new Promise((resolve23) => setTimeout(resolve23, ms));
45034
45168
  }
45035
45169
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
45036
45170
  const startedAt = Date.now();
@@ -47310,15 +47444,15 @@ var init_dev_server = __esm({
47310
47444
  this.json(res, 500, { error: e.message });
47311
47445
  }
47312
47446
  });
47313
- return new Promise((resolve22, reject) => {
47447
+ return new Promise((resolve23, reject) => {
47314
47448
  this.server.listen(port, "127.0.0.1", () => {
47315
47449
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
47316
- resolve22();
47450
+ resolve23();
47317
47451
  });
47318
47452
  this.server.on("error", (e) => {
47319
47453
  if (e.code === "EADDRINUSE") {
47320
47454
  this.log(`Port ${port} in use, skipping dev server`);
47321
- resolve22();
47455
+ resolve23();
47322
47456
  } else {
47323
47457
  reject(e);
47324
47458
  }
@@ -47400,20 +47534,20 @@ var init_dev_server = __esm({
47400
47534
  child.stderr?.on("data", (d) => {
47401
47535
  stderr += d.toString().slice(0, 2e3);
47402
47536
  });
47403
- await new Promise((resolve22) => {
47537
+ await new Promise((resolve23) => {
47404
47538
  const timer = setTimeout(() => {
47405
47539
  child.kill();
47406
- resolve22();
47540
+ resolve23();
47407
47541
  }, 3e3);
47408
47542
  child.on("exit", () => {
47409
47543
  clearTimeout(timer);
47410
- resolve22();
47544
+ resolve23();
47411
47545
  });
47412
47546
  child.stdout?.once("data", () => {
47413
47547
  setTimeout(() => {
47414
47548
  child.kill();
47415
47549
  clearTimeout(timer);
47416
- resolve22();
47550
+ resolve23();
47417
47551
  }, 500);
47418
47552
  });
47419
47553
  });
@@ -47916,14 +48050,14 @@ var init_dev_server = __esm({
47916
48050
  child.stderr?.on("data", (d) => {
47917
48051
  stderr += d.toString();
47918
48052
  });
47919
- await new Promise((resolve22) => {
48053
+ await new Promise((resolve23) => {
47920
48054
  const timer = setTimeout(() => {
47921
48055
  child.kill();
47922
- resolve22();
48056
+ resolve23();
47923
48057
  }, timeout);
47924
48058
  child.on("exit", () => {
47925
48059
  clearTimeout(timer);
47926
- resolve22();
48060
+ resolve23();
47927
48061
  });
47928
48062
  });
47929
48063
  const elapsed = Date.now() - start;
@@ -48593,14 +48727,14 @@ data: ${JSON.stringify(msg.data)}
48593
48727
  res.end(JSON.stringify(data, null, 2));
48594
48728
  }
48595
48729
  async readBody(req) {
48596
- return new Promise((resolve22) => {
48730
+ return new Promise((resolve23) => {
48597
48731
  let body = "";
48598
48732
  req.on("data", (chunk) => body += chunk);
48599
48733
  req.on("end", () => {
48600
48734
  try {
48601
- resolve22(JSON.parse(body));
48735
+ resolve23(JSON.parse(body));
48602
48736
  } catch {
48603
- resolve22({});
48737
+ resolve23({});
48604
48738
  }
48605
48739
  });
48606
48740
  });
@@ -49117,7 +49251,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
49117
49251
  const deadline = Date.now() + timeoutMs;
49118
49252
  while (Date.now() < deadline) {
49119
49253
  if (await canConnect(endpoint)) return;
49120
- await new Promise((resolve22) => setTimeout(resolve22, STARTUP_POLL_MS));
49254
+ await new Promise((resolve23) => setTimeout(resolve23, STARTUP_POLL_MS));
49121
49255
  }
49122
49256
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
49123
49257
  }
@@ -49223,10 +49357,10 @@ async function installExtension(ide, extension) {
49223
49357
  const buffer = Buffer.from(await res.arrayBuffer());
49224
49358
  const fs24 = await import("fs");
49225
49359
  fs24.writeFileSync(vsixPath, buffer);
49226
- return new Promise((resolve22) => {
49360
+ return new Promise((resolve23) => {
49227
49361
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
49228
49362
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
49229
- resolve22({
49363
+ resolve23({
49230
49364
  extensionId: extension.id,
49231
49365
  marketplaceId: extension.marketplaceId,
49232
49366
  success: !error48,
@@ -49239,11 +49373,11 @@ async function installExtension(ide, extension) {
49239
49373
  } catch (e) {
49240
49374
  }
49241
49375
  }
49242
- return new Promise((resolve22) => {
49376
+ return new Promise((resolve23) => {
49243
49377
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
49244
49378
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
49245
49379
  if (error48) {
49246
- resolve22({
49380
+ resolve23({
49247
49381
  extensionId: extension.id,
49248
49382
  marketplaceId: extension.marketplaceId,
49249
49383
  success: false,
@@ -49251,7 +49385,7 @@ async function installExtension(ide, extension) {
49251
49385
  error: stderr || error48.message
49252
49386
  });
49253
49387
  } else {
49254
- resolve22({
49388
+ resolve23({
49255
49389
  extensionId: extension.id,
49256
49390
  marketplaceId: extension.marketplaceId,
49257
49391
  success: true,
@@ -49441,6 +49575,51 @@ var init_registry = __esm({
49441
49575
  }
49442
49576
  });
49443
49577
 
49578
+ // ../../oss/packages/daemon-core/src/mesh/mesh-events.ts
49579
+ function setupMeshEventForwarding(components) {
49580
+ components.instanceManager.onEvent((event) => {
49581
+ if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
49582
+ const instanceId = event.instanceId;
49583
+ if (!instanceId) return;
49584
+ const sourceInstance = components.instanceManager.getInstance(instanceId);
49585
+ if (!sourceInstance || sourceInstance.category !== "cli") return;
49586
+ const state = sourceInstance.getState();
49587
+ const workspace = state.workspace;
49588
+ if (!workspace) return;
49589
+ const mesh = getMeshByRepo(workspace);
49590
+ if (!mesh) return;
49591
+ const allInstances = components.instanceManager.getByCategory("cli");
49592
+ const coordinatorInstances = allInstances.filter((inst) => {
49593
+ const instState = inst.getState();
49594
+ if (instState.settings?.meshCoordinatorFor !== mesh.id) return false;
49595
+ if (instState.instanceId === instanceId) return false;
49596
+ return true;
49597
+ });
49598
+ if (coordinatorInstances.length === 0) return;
49599
+ const targetNode = mesh.nodes.find((n) => n.workspace === workspace);
49600
+ const nodeLabel = targetNode ? `Node '${targetNode.id}'` : `Agent at ${workspace}`;
49601
+ let messageText = "";
49602
+ if (event.event === "agent:generating_completed") {
49603
+ messageText = `[System] ${nodeLabel} has completed its task and is now idle. You may use mesh_read_chat to review its progress.`;
49604
+ } else if (event.event === "agent:waiting_approval") {
49605
+ messageText = `[System] ${nodeLabel} is waiting for approval to proceed. You may use mesh_read_chat and mesh_approve to handle it.`;
49606
+ }
49607
+ if (!messageText) return;
49608
+ for (const coord of coordinatorInstances) {
49609
+ const coordState = coord.getState();
49610
+ LOG.info("MeshEvents", `Forwarding event from ${workspace} to coordinator ${coordState.instanceId}`);
49611
+ coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
49612
+ }
49613
+ });
49614
+ }
49615
+ var init_mesh_events = __esm({
49616
+ "../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
49617
+ "use strict";
49618
+ init_mesh_config();
49619
+ init_logger();
49620
+ }
49621
+ });
49622
+
49444
49623
  // ../../oss/packages/daemon-core/src/boot/daemon-lifecycle.ts
49445
49624
  async function initDaemonComponents(config2) {
49446
49625
  installGlobalInterceptor();
@@ -49599,7 +49778,7 @@ async function initDaemonComponents(config2) {
49599
49778
  });
49600
49779
  poller.start();
49601
49780
  instanceManager.startTicking(config2.tickIntervalMs ?? 5e3);
49602
- return {
49781
+ const components = {
49603
49782
  providerLoader,
49604
49783
  instanceManager,
49605
49784
  cliManager,
@@ -49613,6 +49792,8 @@ async function initDaemonComponents(config2) {
49613
49792
  detectedIdes: detectedIdesRef,
49614
49793
  refreshProviderAvailability
49615
49794
  };
49795
+ setupMeshEventForwarding(components);
49796
+ return components;
49616
49797
  }
49617
49798
  async function startDaemonDevSupport(options) {
49618
49799
  const devServer = new DevServer({
@@ -49688,6 +49869,7 @@ var init_daemon_lifecycle = __esm({
49688
49869
  init_runtime_defaults();
49689
49870
  init_config();
49690
49871
  init_git_commands();
49872
+ init_mesh_events();
49691
49873
  }
49692
49874
  });
49693
49875
 
@@ -49964,7 +50146,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
49964
50146
  const resolvedPort = resolveDaemonCommandPort(port);
49965
50147
  const WebSocket4 = (await import("ws")).default;
49966
50148
  const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
49967
- return new Promise((resolve22, reject) => {
50149
+ return new Promise((resolve23, reject) => {
49968
50150
  const wsUrl = `ws://127.0.0.1:${resolvedPort}${DAEMON_WS_PATH2 || "/daemon"}`;
49969
50151
  const ws = new WebSocket4(wsUrl);
49970
50152
  const requestId = `cli-${Date.now()}`;
@@ -50005,7 +50187,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
50005
50187
  if (msg.type === "ext:command_result" && msg.payload?.requestId === requestId || msg.type === "daemon:command_result" || msg.type === "command_result") {
50006
50188
  clearTimeout(timeout);
50007
50189
  ws.close();
50008
- resolve22(msg.payload?.result || msg.payload || msg);
50190
+ resolve23(msg.payload?.result || msg.payload || msg);
50009
50191
  }
50010
50192
  } catch {
50011
50193
  }
@@ -50024,13 +50206,13 @@ This command needs a running local daemon with IPC enabled. Start with: adhdev d
50024
50206
  }
50025
50207
  async function directCdpEval(expression, port = 9222) {
50026
50208
  const http3 = await import("http");
50027
- const targets = await new Promise((resolve22, reject) => {
50209
+ const targets = await new Promise((resolve23, reject) => {
50028
50210
  http3.get(`http://127.0.0.1:${port}/json`, (res) => {
50029
50211
  let data = "";
50030
50212
  res.on("data", (c) => data += c);
50031
50213
  res.on("end", () => {
50032
50214
  try {
50033
- resolve22(JSON.parse(data));
50215
+ resolve23(JSON.parse(data));
50034
50216
  } catch {
50035
50217
  reject(new Error("Invalid JSON"));
50036
50218
  }
@@ -50043,7 +50225,7 @@ async function directCdpEval(expression, port = 9222) {
50043
50225
  const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
50044
50226
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
50045
50227
  const WebSocket4 = (await import("ws")).default;
50046
- return new Promise((resolve22, reject) => {
50228
+ return new Promise((resolve23, reject) => {
50047
50229
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
50048
50230
  const timeout = setTimeout(() => {
50049
50231
  ws.close();
@@ -50065,11 +50247,11 @@ async function directCdpEval(expression, port = 9222) {
50065
50247
  clearTimeout(timeout);
50066
50248
  ws.close();
50067
50249
  if (msg.result?.result?.value !== void 0) {
50068
- resolve22(msg.result.result.value);
50250
+ resolve23(msg.result.result.value);
50069
50251
  } else if (msg.result?.exceptionDetails) {
50070
50252
  reject(new Error(msg.result.exceptionDetails.text));
50071
50253
  } else {
50072
- resolve22(msg.result);
50254
+ resolve23(msg.result);
50073
50255
  }
50074
50256
  }
50075
50257
  });
@@ -50605,14 +50787,14 @@ var require_run_async = __commonJS({
50605
50787
  return function() {
50606
50788
  var args = arguments;
50607
50789
  var originalThis = this;
50608
- var promise2 = new Promise(function(resolve22, reject) {
50790
+ var promise2 = new Promise(function(resolve23, reject) {
50609
50791
  var resolved = false;
50610
50792
  const wrappedResolve = function(value) {
50611
50793
  if (resolved) {
50612
50794
  console.warn("Run-async promise already resolved.");
50613
50795
  }
50614
50796
  resolved = true;
50615
- resolve22(value);
50797
+ resolve23(value);
50616
50798
  };
50617
50799
  var rejected = false;
50618
50800
  const wrappedReject = function(value) {
@@ -51403,7 +51585,7 @@ var require_Observable = __commonJS({
51403
51585
  Observable2.prototype.forEach = function(next, promiseCtor) {
51404
51586
  var _this = this;
51405
51587
  promiseCtor = getPromiseCtor(promiseCtor);
51406
- return new promiseCtor(function(resolve22, reject) {
51588
+ return new promiseCtor(function(resolve23, reject) {
51407
51589
  var subscriber = new Subscriber_1.SafeSubscriber({
51408
51590
  next: function(value) {
51409
51591
  try {
@@ -51414,7 +51596,7 @@ var require_Observable = __commonJS({
51414
51596
  }
51415
51597
  },
51416
51598
  error: reject,
51417
- complete: resolve22
51599
+ complete: resolve23
51418
51600
  });
51419
51601
  _this.subscribe(subscriber);
51420
51602
  });
@@ -51436,14 +51618,14 @@ var require_Observable = __commonJS({
51436
51618
  Observable2.prototype.toPromise = function(promiseCtor) {
51437
51619
  var _this = this;
51438
51620
  promiseCtor = getPromiseCtor(promiseCtor);
51439
- return new promiseCtor(function(resolve22, reject) {
51621
+ return new promiseCtor(function(resolve23, reject) {
51440
51622
  var value;
51441
51623
  _this.subscribe(function(x) {
51442
51624
  return value = x;
51443
51625
  }, function(err) {
51444
51626
  return reject(err);
51445
51627
  }, function() {
51446
- return resolve22(value);
51628
+ return resolve23(value);
51447
51629
  });
51448
51630
  });
51449
51631
  };
@@ -53539,11 +53721,11 @@ var require_innerFrom = __commonJS({
53539
53721
  "use strict";
53540
53722
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
53541
53723
  function adopt(value) {
53542
- return value instanceof P ? value : new P(function(resolve22) {
53543
- resolve22(value);
53724
+ return value instanceof P ? value : new P(function(resolve23) {
53725
+ resolve23(value);
53544
53726
  });
53545
53727
  }
53546
- return new (P || (P = Promise))(function(resolve22, reject) {
53728
+ return new (P || (P = Promise))(function(resolve23, reject) {
53547
53729
  function fulfilled(value) {
53548
53730
  try {
53549
53731
  step(generator.next(value));
@@ -53559,7 +53741,7 @@ var require_innerFrom = __commonJS({
53559
53741
  }
53560
53742
  }
53561
53743
  function step(result) {
53562
- result.done ? resolve22(result.value) : adopt(result.value).then(fulfilled, rejected);
53744
+ result.done ? resolve23(result.value) : adopt(result.value).then(fulfilled, rejected);
53563
53745
  }
53564
53746
  step((generator = generator.apply(thisArg, _arguments || [])).next());
53565
53747
  });
@@ -53641,14 +53823,14 @@ var require_innerFrom = __commonJS({
53641
53823
  }, i);
53642
53824
  function verb(n) {
53643
53825
  i[n] = o[n] && function(v) {
53644
- return new Promise(function(resolve22, reject) {
53645
- v = o[n](v), settle(resolve22, reject, v.done, v.value);
53826
+ return new Promise(function(resolve23, reject) {
53827
+ v = o[n](v), settle(resolve23, reject, v.done, v.value);
53646
53828
  });
53647
53829
  };
53648
53830
  }
53649
- function settle(resolve22, reject, d, v) {
53831
+ function settle(resolve23, reject, d, v) {
53650
53832
  Promise.resolve(v).then(function(v2) {
53651
- resolve22({ value: v2, done: d });
53833
+ resolve23({ value: v2, done: d });
53652
53834
  }, reject);
53653
53835
  }
53654
53836
  };
@@ -54267,7 +54449,7 @@ var require_lastValueFrom = __commonJS({
54267
54449
  var EmptyError_1 = require_EmptyError();
54268
54450
  function lastValueFrom(source, config2) {
54269
54451
  var hasConfig = typeof config2 === "object";
54270
- return new Promise(function(resolve22, reject) {
54452
+ return new Promise(function(resolve23, reject) {
54271
54453
  var _hasValue = false;
54272
54454
  var _value;
54273
54455
  source.subscribe({
@@ -54278,9 +54460,9 @@ var require_lastValueFrom = __commonJS({
54278
54460
  error: reject,
54279
54461
  complete: function() {
54280
54462
  if (_hasValue) {
54281
- resolve22(_value);
54463
+ resolve23(_value);
54282
54464
  } else if (hasConfig) {
54283
- resolve22(config2.defaultValue);
54465
+ resolve23(config2.defaultValue);
54284
54466
  } else {
54285
54467
  reject(new EmptyError_1.EmptyError());
54286
54468
  }
@@ -54302,16 +54484,16 @@ var require_firstValueFrom = __commonJS({
54302
54484
  var Subscriber_1 = require_Subscriber();
54303
54485
  function firstValueFrom(source, config2) {
54304
54486
  var hasConfig = typeof config2 === "object";
54305
- return new Promise(function(resolve22, reject) {
54487
+ return new Promise(function(resolve23, reject) {
54306
54488
  var subscriber = new Subscriber_1.SafeSubscriber({
54307
54489
  next: function(value) {
54308
- resolve22(value);
54490
+ resolve23(value);
54309
54491
  subscriber.unsubscribe();
54310
54492
  },
54311
54493
  error: reject,
54312
54494
  complete: function() {
54313
54495
  if (hasConfig) {
54314
- resolve22(config2.defaultValue);
54496
+ resolve23(config2.defaultValue);
54315
54497
  } else {
54316
54498
  reject(new EmptyError_1.EmptyError());
54317
54499
  }
@@ -66117,14 +66299,14 @@ var require_async_iterator = __commonJS({
66117
66299
  };
66118
66300
  }
66119
66301
  function readAndResolve(iter) {
66120
- var resolve22 = iter[kLastResolve];
66121
- if (resolve22 !== null) {
66302
+ var resolve23 = iter[kLastResolve];
66303
+ if (resolve23 !== null) {
66122
66304
  var data = iter[kStream].read();
66123
66305
  if (data !== null) {
66124
66306
  iter[kLastPromise] = null;
66125
66307
  iter[kLastResolve] = null;
66126
66308
  iter[kLastReject] = null;
66127
- resolve22(createIterResult(data, false));
66309
+ resolve23(createIterResult(data, false));
66128
66310
  }
66129
66311
  }
66130
66312
  }
@@ -66132,13 +66314,13 @@ var require_async_iterator = __commonJS({
66132
66314
  process.nextTick(readAndResolve, iter);
66133
66315
  }
66134
66316
  function wrapForNext(lastPromise, iter) {
66135
- return function(resolve22, reject) {
66317
+ return function(resolve23, reject) {
66136
66318
  lastPromise.then(function() {
66137
66319
  if (iter[kEnded]) {
66138
- resolve22(createIterResult(void 0, true));
66320
+ resolve23(createIterResult(void 0, true));
66139
66321
  return;
66140
66322
  }
66141
- iter[kHandlePromise](resolve22, reject);
66323
+ iter[kHandlePromise](resolve23, reject);
66142
66324
  }, reject);
66143
66325
  };
66144
66326
  }
@@ -66158,12 +66340,12 @@ var require_async_iterator = __commonJS({
66158
66340
  return Promise.resolve(createIterResult(void 0, true));
66159
66341
  }
66160
66342
  if (this[kStream].destroyed) {
66161
- return new Promise(function(resolve22, reject) {
66343
+ return new Promise(function(resolve23, reject) {
66162
66344
  process.nextTick(function() {
66163
66345
  if (_this[kError]) {
66164
66346
  reject(_this[kError]);
66165
66347
  } else {
66166
- resolve22(createIterResult(void 0, true));
66348
+ resolve23(createIterResult(void 0, true));
66167
66349
  }
66168
66350
  });
66169
66351
  });
@@ -66186,13 +66368,13 @@ var require_async_iterator = __commonJS({
66186
66368
  return this;
66187
66369
  }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
66188
66370
  var _this2 = this;
66189
- return new Promise(function(resolve22, reject) {
66371
+ return new Promise(function(resolve23, reject) {
66190
66372
  _this2[kStream].destroy(null, function(err) {
66191
66373
  if (err) {
66192
66374
  reject(err);
66193
66375
  return;
66194
66376
  }
66195
- resolve22(createIterResult(void 0, true));
66377
+ resolve23(createIterResult(void 0, true));
66196
66378
  });
66197
66379
  });
66198
66380
  }), _Object$setPrototypeO), AsyncIteratorPrototype);
@@ -66214,15 +66396,15 @@ var require_async_iterator = __commonJS({
66214
66396
  value: stream._readableState.endEmitted,
66215
66397
  writable: true
66216
66398
  }), _defineProperty(_Object$create, kHandlePromise, {
66217
- value: function value(resolve22, reject) {
66399
+ value: function value(resolve23, reject) {
66218
66400
  var data = iterator[kStream].read();
66219
66401
  if (data) {
66220
66402
  iterator[kLastPromise] = null;
66221
66403
  iterator[kLastResolve] = null;
66222
66404
  iterator[kLastReject] = null;
66223
- resolve22(createIterResult(data, false));
66405
+ resolve23(createIterResult(data, false));
66224
66406
  } else {
66225
- iterator[kLastResolve] = resolve22;
66407
+ iterator[kLastResolve] = resolve23;
66226
66408
  iterator[kLastReject] = reject;
66227
66409
  }
66228
66410
  },
@@ -66241,12 +66423,12 @@ var require_async_iterator = __commonJS({
66241
66423
  iterator[kError] = err;
66242
66424
  return;
66243
66425
  }
66244
- var resolve22 = iterator[kLastResolve];
66245
- if (resolve22 !== null) {
66426
+ var resolve23 = iterator[kLastResolve];
66427
+ if (resolve23 !== null) {
66246
66428
  iterator[kLastPromise] = null;
66247
66429
  iterator[kLastResolve] = null;
66248
66430
  iterator[kLastReject] = null;
66249
- resolve22(createIterResult(void 0, true));
66431
+ resolve23(createIterResult(void 0, true));
66250
66432
  }
66251
66433
  iterator[kEnded] = true;
66252
66434
  });
@@ -66261,7 +66443,7 @@ var require_async_iterator = __commonJS({
66261
66443
  var require_from2 = __commonJS({
66262
66444
  "../../node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
66263
66445
  "use strict";
66264
- function asyncGeneratorStep(gen, resolve22, reject, _next, _throw, key, arg) {
66446
+ function asyncGeneratorStep(gen, resolve23, reject, _next, _throw, key, arg) {
66265
66447
  try {
66266
66448
  var info = gen[key](arg);
66267
66449
  var value = info.value;
@@ -66270,7 +66452,7 @@ var require_from2 = __commonJS({
66270
66452
  return;
66271
66453
  }
66272
66454
  if (info.done) {
66273
- resolve22(value);
66455
+ resolve23(value);
66274
66456
  } else {
66275
66457
  Promise.resolve(value).then(_next, _throw);
66276
66458
  }
@@ -66278,13 +66460,13 @@ var require_from2 = __commonJS({
66278
66460
  function _asyncToGenerator(fn) {
66279
66461
  return function() {
66280
66462
  var self2 = this, args = arguments;
66281
- return new Promise(function(resolve22, reject) {
66463
+ return new Promise(function(resolve23, reject) {
66282
66464
  var gen = fn.apply(self2, args);
66283
66465
  function _next(value) {
66284
- asyncGeneratorStep(gen, resolve22, reject, _next, _throw, "next", value);
66466
+ asyncGeneratorStep(gen, resolve23, reject, _next, _throw, "next", value);
66285
66467
  }
66286
66468
  function _throw(err) {
66287
- asyncGeneratorStep(gen, resolve22, reject, _next, _throw, "throw", err);
66469
+ asyncGeneratorStep(gen, resolve23, reject, _next, _throw, "throw", err);
66288
66470
  }
66289
66471
  _next(void 0);
66290
66472
  });
@@ -68223,9 +68405,9 @@ var init_base = __esm({
68223
68405
  * @return {Promise}
68224
68406
  */
68225
68407
  run() {
68226
- return new Promise((resolve22, reject) => {
68408
+ return new Promise((resolve23, reject) => {
68227
68409
  this._run(
68228
- (value) => resolve22(value),
68410
+ (value) => resolve23(value),
68229
68411
  (error48) => reject(error48)
68230
68412
  );
68231
68413
  });
@@ -74857,7 +75039,7 @@ var require_lib = __commonJS({
74857
75039
  return matches;
74858
75040
  };
74859
75041
  exports2.analyse = analyse;
74860
- var detectFile = (filepath, opts = {}) => new Promise((resolve22, reject) => {
75042
+ var detectFile = (filepath, opts = {}) => new Promise((resolve23, reject) => {
74861
75043
  let fd;
74862
75044
  const fs24 = (0, node_1.default)();
74863
75045
  const handler = (err, buffer) => {
@@ -74867,7 +75049,7 @@ var require_lib = __commonJS({
74867
75049
  if (err) {
74868
75050
  reject(err);
74869
75051
  } else if (buffer) {
74870
- resolve22((0, exports2.detect)(buffer));
75052
+ resolve23((0, exports2.detect)(buffer));
74871
75053
  } else {
74872
75054
  reject(new Error("No error and no buffer received"));
74873
75055
  }
@@ -78795,14 +78977,14 @@ function splitStringBySpace(str) {
78795
78977
  }
78796
78978
  return pieces;
78797
78979
  }
78798
- var import_chardet, import_child_process12, import_fs7, import_node_path2, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
78980
+ var import_chardet, import_child_process12, import_fs7, import_node_path3, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
78799
78981
  var init_esm2 = __esm({
78800
78982
  "../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
78801
78983
  "use strict";
78802
78984
  import_chardet = __toESM(require_lib(), 1);
78803
78985
  import_child_process12 = require("child_process");
78804
78986
  import_fs7 = require("fs");
78805
- import_node_path2 = __toESM(require("path"), 1);
78987
+ import_node_path3 = __toESM(require("path"), 1);
78806
78988
  import_node_os4 = __toESM(require("os"), 1);
78807
78989
  import_node_crypto2 = require("crypto");
78808
78990
  import_iconv_lite = __toESM(require_lib2(), 1);
@@ -78867,8 +79049,8 @@ var init_esm2 = __esm({
78867
79049
  const prefix = sanitizeAffix(this.fileOptions.prefix);
78868
79050
  const postfix = sanitizeAffix(this.fileOptions.postfix);
78869
79051
  const filename = `${prefix}${id}${postfix}`;
78870
- const candidate = import_node_path2.default.resolve(baseDir, filename);
78871
- const baseResolved = import_node_path2.default.resolve(baseDir) + import_node_path2.default.sep;
79052
+ const candidate = import_node_path3.default.resolve(baseDir, filename);
79053
+ const baseResolved = import_node_path3.default.resolve(baseDir) + import_node_path3.default.sep;
78872
79054
  if (!candidate.startsWith(baseResolved)) {
78873
79055
  throw new Error("Resolved temporary file escaped the base directory");
78874
79056
  }
@@ -80602,9 +80784,9 @@ function resolvePackageVersion(options) {
80602
80784
  const injectedVersion = options?.injectedVersion || "unknown";
80603
80785
  const dir = options?.dirname || __dirname;
80604
80786
  const possiblePaths = [
80605
- (0, import_path5.join)(dir, "..", "..", "package.json"),
80606
- (0, import_path5.join)(dir, "..", "package.json"),
80607
- (0, import_path5.join)(dir, "package.json")
80787
+ (0, import_path4.join)(dir, "..", "..", "package.json"),
80788
+ (0, import_path4.join)(dir, "..", "package.json"),
80789
+ (0, import_path4.join)(dir, "package.json")
80608
80790
  ];
80609
80791
  for (const p of possiblePaths) {
80610
80792
  try {
@@ -80615,12 +80797,12 @@ function resolvePackageVersion(options) {
80615
80797
  }
80616
80798
  return injectedVersion;
80617
80799
  }
80618
- var import_fs8, import_path5;
80800
+ var import_fs8, import_path4;
80619
80801
  var init_version = __esm({
80620
80802
  "src/version.ts"() {
80621
80803
  "use strict";
80622
80804
  import_fs8 = require("fs");
80623
- import_path5 = require("path");
80805
+ import_path4 = require("path");
80624
80806
  }
80625
80807
  });
80626
80808
 
@@ -80737,7 +80919,7 @@ var init_server_connection = __esm({
80737
80919
  * Returns the command result or throws on timeout / auth failure.
80738
80920
  */
80739
80921
  sendMeshCommand(targetDaemonId, command, args = {}, timeoutMs = 3e4) {
80740
- return new Promise((resolve22, reject) => {
80922
+ return new Promise((resolve23, reject) => {
80741
80923
  const requestId = `mesh_${crypto.randomUUID()}`;
80742
80924
  const timer = setTimeout(() => {
80743
80925
  this.off("daemon_mesh_result", handler);
@@ -80750,7 +80932,7 @@ var init_server_connection = __esm({
80750
80932
  if (msg.payload?.success === false) {
80751
80933
  reject(new Error(msg.payload?.error ?? "Mesh command failed"));
80752
80934
  } else {
80753
- resolve22(msg.payload?.result);
80935
+ resolve23(msg.payload?.result);
80754
80936
  }
80755
80937
  };
80756
80938
  this.on("daemon_mesh_result", handler);
@@ -82057,19 +82239,19 @@ var init_peer_connection_manager = __esm({
82057
82239
  });
82058
82240
 
82059
82241
  // src/daemon-p2p/index.ts
82060
- var fs16, path29, import_node_module2, esmRequire, DaemonP2PSender;
82242
+ var fs16, path29, import_node_module3, esmRequire, DaemonP2PSender;
82061
82243
  var init_daemon_p2p = __esm({
82062
82244
  "src/daemon-p2p/index.ts"() {
82063
82245
  "use strict";
82064
82246
  fs16 = __toESM(require("fs"));
82065
82247
  path29 = __toESM(require("path"));
82066
- import_node_module2 = require("module");
82248
+ import_node_module3 = require("module");
82067
82249
  init_src();
82068
82250
  init_data_channel_router();
82069
82251
  init_screenshot_sender();
82070
82252
  init_peer_connection_manager();
82071
82253
  init_log();
82072
- esmRequire = (0, import_node_module2.createRequire)(__filename);
82254
+ esmRequire = (0, import_node_module3.createRequire)(__filename);
82073
82255
  DaemonP2PSender = class {
82074
82256
  serverConn;
82075
82257
  peers = /* @__PURE__ */ new Map();
@@ -82546,14 +82728,14 @@ var require_filesystem = __commonJS({
82546
82728
  });
82547
82729
  return buffer.subarray(0, bytesRead);
82548
82730
  };
82549
- var readFile2 = (path40) => new Promise((resolve22, reject) => {
82731
+ var readFile2 = (path40) => new Promise((resolve23, reject) => {
82550
82732
  fs24.open(path40, "r", (err, fd) => {
82551
82733
  if (err) {
82552
82734
  reject(err);
82553
82735
  } else {
82554
82736
  const buffer = Buffer.alloc(MAX_LENGTH);
82555
82737
  fs24.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
82556
- resolve22(buffer.subarray(0, bytesRead));
82738
+ resolve23(buffer.subarray(0, bytesRead));
82557
82739
  fs24.close(fd, () => {
82558
82740
  });
82559
82741
  });
@@ -82621,10 +82803,10 @@ var require_detect_libc = __commonJS({
82621
82803
  var commandOut = "";
82622
82804
  var safeCommand = () => {
82623
82805
  if (!commandOut) {
82624
- return new Promise((resolve22) => {
82806
+ return new Promise((resolve23) => {
82625
82807
  childProcess.exec(command, (err, out) => {
82626
82808
  commandOut = err ? " " : out;
82627
- resolve22(commandOut);
82809
+ resolve23(commandOut);
82628
82810
  });
82629
82811
  });
82630
82812
  }
@@ -85304,14 +85486,14 @@ var require_input = __commonJS({
85304
85486
  return this;
85305
85487
  } else {
85306
85488
  if (this._isStreamInput()) {
85307
- return new Promise((resolve22, reject) => {
85489
+ return new Promise((resolve23, reject) => {
85308
85490
  const finished = () => {
85309
85491
  this._flattenBufferIn();
85310
85492
  sharp.metadata(this.options, (err, metadata2) => {
85311
85493
  if (err) {
85312
85494
  reject(is.nativeError(err, stack));
85313
85495
  } else {
85314
- resolve22(metadata2);
85496
+ resolve23(metadata2);
85315
85497
  }
85316
85498
  });
85317
85499
  };
@@ -85322,12 +85504,12 @@ var require_input = __commonJS({
85322
85504
  }
85323
85505
  });
85324
85506
  } else {
85325
- return new Promise((resolve22, reject) => {
85507
+ return new Promise((resolve23, reject) => {
85326
85508
  sharp.metadata(this.options, (err, metadata2) => {
85327
85509
  if (err) {
85328
85510
  reject(is.nativeError(err, stack));
85329
85511
  } else {
85330
- resolve22(metadata2);
85512
+ resolve23(metadata2);
85331
85513
  }
85332
85514
  });
85333
85515
  });
@@ -85360,25 +85542,25 @@ var require_input = __commonJS({
85360
85542
  return this;
85361
85543
  } else {
85362
85544
  if (this._isStreamInput()) {
85363
- return new Promise((resolve22, reject) => {
85545
+ return new Promise((resolve23, reject) => {
85364
85546
  this.on("finish", function() {
85365
85547
  this._flattenBufferIn();
85366
85548
  sharp.stats(this.options, (err, stats2) => {
85367
85549
  if (err) {
85368
85550
  reject(is.nativeError(err, stack));
85369
85551
  } else {
85370
- resolve22(stats2);
85552
+ resolve23(stats2);
85371
85553
  }
85372
85554
  });
85373
85555
  });
85374
85556
  });
85375
85557
  } else {
85376
- return new Promise((resolve22, reject) => {
85558
+ return new Promise((resolve23, reject) => {
85377
85559
  sharp.stats(this.options, (err, stats2) => {
85378
85560
  if (err) {
85379
85561
  reject(is.nativeError(err, stack));
85380
85562
  } else {
85381
- resolve22(stats2);
85563
+ resolve23(stats2);
85382
85564
  }
85383
85565
  });
85384
85566
  });
@@ -88800,7 +88982,7 @@ var require_output = __commonJS({
88800
88982
  return this;
88801
88983
  } else {
88802
88984
  if (this._isStreamInput()) {
88803
- return new Promise((resolve22, reject) => {
88985
+ return new Promise((resolve23, reject) => {
88804
88986
  this.once("finish", () => {
88805
88987
  this._flattenBufferIn();
88806
88988
  sharp.pipeline(this.options, (err, data, info) => {
@@ -88808,24 +88990,24 @@ var require_output = __commonJS({
88808
88990
  reject(is.nativeError(err, stack));
88809
88991
  } else {
88810
88992
  if (this.options.resolveWithObject) {
88811
- resolve22({ data, info });
88993
+ resolve23({ data, info });
88812
88994
  } else {
88813
- resolve22(data);
88995
+ resolve23(data);
88814
88996
  }
88815
88997
  }
88816
88998
  });
88817
88999
  });
88818
89000
  });
88819
89001
  } else {
88820
- return new Promise((resolve22, reject) => {
89002
+ return new Promise((resolve23, reject) => {
88821
89003
  sharp.pipeline(this.options, (err, data, info) => {
88822
89004
  if (err) {
88823
89005
  reject(is.nativeError(err, stack));
88824
89006
  } else {
88825
89007
  if (this.options.resolveWithObject) {
88826
- resolve22({ data, info });
89008
+ resolve23({ data, info });
88827
89009
  } else {
88828
- resolve22(data);
89010
+ resolve23(data);
88829
89011
  }
88830
89012
  }
88831
89013
  });
@@ -90057,7 +90239,7 @@ var init_adhdev_daemon = __esm({
90057
90239
  init_version();
90058
90240
  init_src();
90059
90241
  init_runtime_defaults();
90060
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.70" });
90242
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.72" });
90061
90243
  AdhdevDaemon = class _AdhdevDaemon {
90062
90244
  localHttpServer = null;
90063
90245
  localWss = null;
@@ -90873,7 +91055,7 @@ ${err?.stack || ""}`);
90873
91055
  try {
90874
91056
  const statusResult = await Promise.race([
90875
91057
  this.components.router.execute("git_status", { workspace }, "mesh"),
90876
- new Promise((resolve22) => setTimeout(() => resolve22(null), 4e3))
91058
+ new Promise((resolve23) => setTimeout(() => resolve23(null), 4e3))
90877
91059
  ]);
90878
91060
  const s = statusResult?.status ?? statusResult;
90879
91061
  if (s?.isGitRepo) {
@@ -91056,7 +91238,7 @@ ${err?.stack || ""}`);
91056
91238
  this.localWss.emit("connection", ws, req);
91057
91239
  });
91058
91240
  });
91059
- await new Promise((resolve22, reject) => {
91241
+ await new Promise((resolve23, reject) => {
91060
91242
  const cleanup = () => {
91061
91243
  this.localHttpServer?.off("error", onError);
91062
91244
  this.localHttpServer?.off("listening", onListening);
@@ -91067,7 +91249,7 @@ ${err?.stack || ""}`);
91067
91249
  };
91068
91250
  const onListening = () => {
91069
91251
  cleanup();
91070
- resolve22();
91252
+ resolve23();
91071
91253
  };
91072
91254
  this.localHttpServer.once("error", onError);
91073
91255
  this.localHttpServer.once("listening", onListening);
@@ -91241,12 +91423,12 @@ ${err?.stack || ""}`);
91241
91423
  this.localClients.clear();
91242
91424
  this.localWss?.close();
91243
91425
  this.localWss = null;
91244
- await new Promise((resolve22) => {
91426
+ await new Promise((resolve23) => {
91245
91427
  if (!this.localHttpServer) {
91246
- resolve22();
91428
+ resolve23();
91247
91429
  return;
91248
91430
  }
91249
- this.localHttpServer.close(() => resolve22());
91431
+ this.localHttpServer.close(() => resolve23());
91250
91432
  this.localHttpServer = null;
91251
91433
  });
91252
91434
  } catch {
@@ -92701,7 +92883,7 @@ init_source();
92701
92883
  init_src();
92702
92884
 
92703
92885
  // src/cli/setup-commands.ts
92704
- var import_node_path3 = __toESM(require("path"));
92886
+ var import_node_path4 = __toESM(require("path"));
92705
92887
  init_source();
92706
92888
  init_src();
92707
92889
 
@@ -92854,7 +93036,7 @@ function parsePositiveInteger(value, fallback2) {
92854
93036
  return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback2;
92855
93037
  }
92856
93038
  function buildHistoryResumeLaunchPayload(cliType, session, overrideDir) {
92857
- const dir = typeof overrideDir === "string" && overrideDir.trim() ? import_node_path3.default.resolve(overrideDir.trim()) : typeof session.workspace === "string" && session.workspace.trim() ? import_node_path3.default.resolve(session.workspace.trim()) : "";
93039
+ const dir = typeof overrideDir === "string" && overrideDir.trim() ? import_node_path4.default.resolve(overrideDir.trim()) : typeof session.workspace === "string" && session.workspace.trim() ? import_node_path4.default.resolve(session.workspace.trim()) : "";
92858
93040
  if (!dir) {
92859
93041
  throw new Error(`Saved history ${session.providerSessionId} is missing workspace metadata. Pass --dir to resume it explicitly.`);
92860
93042
  }
@@ -92974,7 +93156,7 @@ function registerSetupCommands(program2, getProviderLoader2) {
92974
93156
  console.log(source_default.gray(" Then run: adhdev launch " + targetArg));
92975
93157
  process.exit(1);
92976
93158
  }
92977
- const resolvedDir = import_node_path3.default.resolve(workingDir);
93159
+ const resolvedDir = import_node_path4.default.resolve(workingDir);
92978
93160
  const result = await sendDaemonCommand("launch_cli", {
92979
93161
  cliType,
92980
93162
  dir: resolvedDir
@@ -93731,14 +93913,14 @@ async function requestSessionHostDirect(request) {
93731
93913
  }
93732
93914
  async function runRuntimeLaunchSpec(spec) {
93733
93915
  const { spawn: spawn7 } = await import("child_process");
93734
- return await new Promise((resolve22, reject) => {
93916
+ return await new Promise((resolve23, reject) => {
93735
93917
  const child = spawn7(spec.command, spec.args, {
93736
93918
  stdio: "inherit",
93737
93919
  env: spec.env,
93738
93920
  shell: process.platform === "win32" && spec.command !== process.execPath
93739
93921
  });
93740
93922
  child.on("error", reject);
93741
- child.on("exit", (code) => resolve22(code ?? 0));
93923
+ child.on("exit", (code) => resolve23(code ?? 0));
93742
93924
  });
93743
93925
  }
93744
93926
  async function resolveRuntimeSessionId(target, options) {
@@ -93972,7 +94154,7 @@ async function handleTraceCommand(options) {
93972
94154
  }
93973
94155
  }
93974
94156
  while (!stopped) {
93975
- await new Promise((resolve22) => setTimeout(resolve22, intervalMs));
94157
+ await new Promise((resolve23) => setTimeout(resolve23, intervalMs));
93976
94158
  if (stopped) break;
93977
94159
  const nextTrace = await fetchTrace(buildDebugTraceFollowPollArgs(baseArgs, cursor));
93978
94160
  const nextBatch = collectFreshDebugTraceEntries(nextTrace, cursor);
@@ -94794,33 +94976,33 @@ function buildDoctorAdvice(input) {
94794
94976
  }
94795
94977
 
94796
94978
  // src/cli/service-commands.ts
94797
- var import_node_fs4 = __toESM(require("fs"));
94798
- var import_node_path4 = __toESM(require("path"));
94979
+ var import_node_fs5 = __toESM(require("fs"));
94980
+ var import_node_path5 = __toESM(require("path"));
94799
94981
  var import_node_os5 = __toESM(require("os"));
94800
94982
  var import_node_child_process2 = require("child_process");
94801
94983
  init_source();
94802
94984
  init_src();
94803
94985
  var DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS3 = 1500;
94804
94986
  var LAUNCHD_LABEL = "dev.adhf.daemon";
94805
- var ADHDEV_DIR = import_node_path4.default.join(import_node_os5.default.homedir(), ".adhdev");
94806
- var LOG_OUT = import_node_path4.default.join(ADHDEV_DIR, "daemon-launchd.out");
94807
- var LOG_ERR = import_node_path4.default.join(ADHDEV_DIR, "daemon-launchd.err");
94987
+ var ADHDEV_DIR = import_node_path5.default.join(import_node_os5.default.homedir(), ".adhdev");
94988
+ var LOG_OUT = import_node_path5.default.join(ADHDEV_DIR, "daemon-launchd.out");
94989
+ var LOG_ERR = import_node_path5.default.join(ADHDEV_DIR, "daemon-launchd.err");
94808
94990
  var MAX_LOG_SIZE2 = 10 * 1024 * 1024;
94809
94991
  function getDarwinPlistPath() {
94810
- return import_node_path4.default.join(import_node_os5.default.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
94992
+ return import_node_path5.default.join(import_node_os5.default.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
94811
94993
  }
94812
94994
  function getWindowsStartupDir() {
94813
- const appData = process.env.APPDATA || import_node_path4.default.join(import_node_os5.default.homedir(), "AppData", "Roaming");
94814
- return import_node_path4.default.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup");
94995
+ const appData = process.env.APPDATA || import_node_path5.default.join(import_node_os5.default.homedir(), "AppData", "Roaming");
94996
+ return import_node_path5.default.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup");
94815
94997
  }
94816
94998
  function getWindowsVbsPath() {
94817
- return import_node_path4.default.join(getWindowsStartupDir(), "adhdev-daemon.vbs");
94999
+ return import_node_path5.default.join(getWindowsStartupDir(), "adhdev-daemon.vbs");
94818
95000
  }
94819
95001
  function resolveCliPath() {
94820
- return import_node_fs4.default.realpathSync(process.argv[1]);
95002
+ return import_node_fs5.default.realpathSync(process.argv[1]);
94821
95003
  }
94822
95004
  function ensureDir(dir) {
94823
- if (!import_node_fs4.default.existsSync(dir)) import_node_fs4.default.mkdirSync(dir, { recursive: true });
95005
+ if (!import_node_fs5.default.existsSync(dir)) import_node_fs5.default.mkdirSync(dir, { recursive: true });
94824
95006
  }
94825
95007
  async function fetchHealth() {
94826
95008
  const controller = new AbortController();
@@ -94862,13 +95044,13 @@ function formatElapsed(etime) {
94862
95044
  }
94863
95045
  function rotateLogIfNeeded(logPath) {
94864
95046
  try {
94865
- if (!import_node_fs4.default.existsSync(logPath)) return;
94866
- const stat5 = import_node_fs4.default.statSync(logPath);
95047
+ if (!import_node_fs5.default.existsSync(logPath)) return;
95048
+ const stat5 = import_node_fs5.default.statSync(logPath);
94867
95049
  if (stat5.size > MAX_LOG_SIZE2) {
94868
95050
  const rotated = logPath + ".old";
94869
- if (import_node_fs4.default.existsSync(rotated)) import_node_fs4.default.unlinkSync(rotated);
94870
- import_node_fs4.default.renameSync(logPath, rotated);
94871
- import_node_fs4.default.writeFileSync(logPath, `[log rotated at ${(/* @__PURE__ */ new Date()).toISOString()}]
95051
+ if (import_node_fs5.default.existsSync(rotated)) import_node_fs5.default.unlinkSync(rotated);
95052
+ import_node_fs5.default.renameSync(logPath, rotated);
95053
+ import_node_fs5.default.writeFileSync(logPath, `[log rotated at ${(/* @__PURE__ */ new Date()).toISOString()}]
94872
95054
  `, "utf-8");
94873
95055
  }
94874
95056
  } catch {
@@ -94879,8 +95061,8 @@ function rotateLogs() {
94879
95061
  rotateLogIfNeeded(LOG_ERR);
94880
95062
  }
94881
95063
  function buildPlist(nodeExe, cliExe) {
94882
- const brewPrefix = import_node_fs4.default.existsSync("/opt/homebrew/bin") ? "/opt/homebrew/bin" : "/usr/local/bin";
94883
- const nodeDir = import_node_path4.default.dirname(nodeExe);
95064
+ const brewPrefix = import_node_fs5.default.existsSync("/opt/homebrew/bin") ? "/opt/homebrew/bin" : "/usr/local/bin";
95065
+ const nodeDir = import_node_path5.default.dirname(nodeExe);
94884
95066
  const pathEntries = /* @__PURE__ */ new Set([nodeDir, brewPrefix, "/usr/local/bin", "/usr/bin", "/bin", "/usr/sbin", "/sbin"]);
94885
95067
  const pathValue = Array.from(pathEntries).join(":");
94886
95068
  return `<?xml version="1.0" encoding="UTF-8"?>
@@ -94919,8 +95101,8 @@ function buildPlist(nodeExe, cliExe) {
94919
95101
  function installDarwin(nodeExe, cliExe) {
94920
95102
  const plistPath = getDarwinPlistPath();
94921
95103
  ensureDir(ADHDEV_DIR);
94922
- ensureDir(import_node_path4.default.dirname(plistPath));
94923
- import_node_fs4.default.writeFileSync(plistPath, buildPlist(nodeExe, cliExe), "utf-8");
95104
+ ensureDir(import_node_path5.default.dirname(plistPath));
95105
+ import_node_fs5.default.writeFileSync(plistPath, buildPlist(nodeExe, cliExe), "utf-8");
94924
95106
  console.log(source_default.gray(` Plist: ${plistPath}`));
94925
95107
  try {
94926
95108
  (0, import_node_child_process2.execSync)(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
@@ -94937,7 +95119,7 @@ function installDarwin(nodeExe, cliExe) {
94937
95119
  }
94938
95120
  function uninstallDarwin() {
94939
95121
  const plistPath = getDarwinPlistPath();
94940
- if (!import_node_fs4.default.existsSync(plistPath)) {
95122
+ if (!import_node_fs5.default.existsSync(plistPath)) {
94941
95123
  console.log(source_default.yellow("\n \u26A0 Service is not installed."));
94942
95124
  return;
94943
95125
  }
@@ -94945,14 +95127,14 @@ function uninstallDarwin() {
94945
95127
  (0, import_node_child_process2.execSync)(`launchctl unload "${plistPath}" 2>/dev/null`, { stdio: "ignore" });
94946
95128
  } catch {
94947
95129
  }
94948
- import_node_fs4.default.unlinkSync(plistPath);
95130
+ import_node_fs5.default.unlinkSync(plistPath);
94949
95131
  console.log(source_default.green("\n \u2713 Removed LaunchAgent. Daemon will no longer auto-start."));
94950
95132
  }
94951
95133
  function isInstalledDarwin() {
94952
- return import_node_fs4.default.existsSync(getDarwinPlistPath());
95134
+ return import_node_fs5.default.existsSync(getDarwinPlistPath());
94953
95135
  }
94954
95136
  function buildVbs(nodeExe, cliExe) {
94955
- const logFile = import_node_path4.default.join(ADHDEV_DIR, "daemon-service.log").replace(/\\/g, "\\\\");
95137
+ const logFile = import_node_path5.default.join(ADHDEV_DIR, "daemon-service.log").replace(/\\/g, "\\\\");
94956
95138
  const escapedNodeExe = nodeExe.replace(/\\/g, "\\\\");
94957
95139
  const escapedCliExe = cliExe.replace(/\\/g, "\\\\");
94958
95140
  return `' ADHDev Daemon Auto-Start (generated by adhdev service install)
@@ -94963,25 +95145,25 @@ WshShell.Run "cmd.exe /c """"${escapedNodeExe}"""" """"${escapedCliExe}"""" daem
94963
95145
  function installWindows(nodeExe, cliExe) {
94964
95146
  const vbsPath = getWindowsVbsPath();
94965
95147
  ensureDir(ADHDEV_DIR);
94966
- ensureDir(import_node_path4.default.dirname(vbsPath));
94967
- import_node_fs4.default.writeFileSync(vbsPath, buildVbs(nodeExe, cliExe), "utf-8");
95148
+ ensureDir(import_node_path5.default.dirname(vbsPath));
95149
+ import_node_fs5.default.writeFileSync(vbsPath, buildVbs(nodeExe, cliExe), "utf-8");
94968
95150
  console.log(source_default.gray(` Startup script: ${vbsPath}`));
94969
95151
  console.log(source_default.green("\n \u2713 Registered in Startup folder \u2014 daemon will start on login (hidden)."));
94970
- console.log(source_default.gray(` Logs: ${import_node_path4.default.join(ADHDEV_DIR, "daemon-service.log")}`));
95152
+ console.log(source_default.gray(` Logs: ${import_node_path5.default.join(ADHDEV_DIR, "daemon-service.log")}`));
94971
95153
  console.log(source_default.gray(" To start now without rebooting, run: adhdev daemon"));
94972
95154
  }
94973
95155
  function uninstallWindows() {
94974
95156
  const vbsPath = getWindowsVbsPath();
94975
- if (!import_node_fs4.default.existsSync(vbsPath)) {
95157
+ if (!import_node_fs5.default.existsSync(vbsPath)) {
94976
95158
  console.log(source_default.yellow("\n \u26A0 Service is not installed."));
94977
95159
  return;
94978
95160
  }
94979
- import_node_fs4.default.unlinkSync(vbsPath);
95161
+ import_node_fs5.default.unlinkSync(vbsPath);
94980
95162
  console.log(source_default.green("\n \u2713 Removed Startup script. Daemon will no longer auto-start."));
94981
95163
  console.log(source_default.gray(" Note: a currently running daemon is not affected. Stop with: adhdev daemon:stop"));
94982
95164
  }
94983
95165
  function isInstalledWindows() {
94984
- return import_node_fs4.default.existsSync(getWindowsVbsPath());
95166
+ return import_node_fs5.default.existsSync(getWindowsVbsPath());
94985
95167
  }
94986
95168
  function registerServiceCommands(program2) {
94987
95169
  const svc = program2.command("service").description("\u{1F50C} Manage ADHDev as an OS background auto-start service");
@@ -95037,8 +95219,8 @@ function registerServiceCommands(program2) {
95037
95219
  } else {
95038
95220
  console.log(source_default.yellow(" \u2717 Daemon is not running."));
95039
95221
  }
95040
- const outSize = import_node_fs4.default.existsSync(LOG_OUT) ? import_node_fs4.default.statSync(LOG_OUT).size : 0;
95041
- const errSize = import_node_fs4.default.existsSync(LOG_ERR) ? import_node_fs4.default.statSync(LOG_ERR).size : 0;
95222
+ const outSize = import_node_fs5.default.existsSync(LOG_OUT) ? import_node_fs5.default.statSync(LOG_OUT).size : 0;
95223
+ const errSize = import_node_fs5.default.existsSync(LOG_ERR) ? import_node_fs5.default.statSync(LOG_ERR).size : 0;
95042
95224
  if (outSize > 0 || errSize > 0) {
95043
95225
  console.log(source_default.gray(` Logs: stdout ${formatBytes(outSize)}, stderr ${formatBytes(errSize)}`));
95044
95226
  }
@@ -95047,13 +95229,13 @@ function registerServiceCommands(program2) {
95047
95229
  svc.command("logs").description("View daemon service logs").option("--err", "Show stderr log instead of stdout").option("--clear", "Truncate all log files").option("-n, --lines <count>", "Number of lines to show", "30").action(async (options) => {
95048
95230
  if (options.clear) {
95049
95231
  for (const f of [LOG_OUT, LOG_ERR]) {
95050
- if (import_node_fs4.default.existsSync(f)) import_node_fs4.default.writeFileSync(f, "", "utf-8");
95232
+ if (import_node_fs5.default.existsSync(f)) import_node_fs5.default.writeFileSync(f, "", "utf-8");
95051
95233
  }
95052
95234
  console.log(source_default.green("\n \u2713 Logs cleared.\n"));
95053
95235
  return;
95054
95236
  }
95055
95237
  const logFile = options.err ? LOG_ERR : LOG_OUT;
95056
- if (!import_node_fs4.default.existsSync(logFile)) {
95238
+ if (!import_node_fs5.default.existsSync(logFile)) {
95057
95239
  console.log(source_default.gray(`
95058
95240
  No log file found: ${logFile}
95059
95241
  `));
@@ -95063,20 +95245,20 @@ function registerServiceCommands(program2) {
95063
95245
  console.log(source_default.gray(`
95064
95246
  \u2500\u2500 ${options.err ? "stderr" : "stdout"}: ${logFile} (last ${lines} lines) \u2500\u2500
95065
95247
  `));
95066
- const content = import_node_fs4.default.readFileSync(logFile, "utf-8");
95248
+ const content = import_node_fs5.default.readFileSync(logFile, "utf-8");
95067
95249
  const allLines = content.split("\n");
95068
95250
  const lastLines = allLines.slice(-lines).join("\n");
95069
95251
  if (lastLines.trim()) console.log(lastLines);
95070
95252
  console.log(source_default.gray("\n (watching for new output, Ctrl+C to stop)\n"));
95071
95253
  let offset = Buffer.byteLength(content, "utf-8");
95072
- const watcher = import_node_fs4.default.watchFile(logFile, { interval: 500 }, () => {
95254
+ const watcher = import_node_fs5.default.watchFile(logFile, { interval: 500 }, () => {
95073
95255
  try {
95074
- const stat5 = import_node_fs4.default.statSync(logFile);
95256
+ const stat5 = import_node_fs5.default.statSync(logFile);
95075
95257
  if (stat5.size > offset) {
95076
- const fd = import_node_fs4.default.openSync(logFile, "r");
95258
+ const fd = import_node_fs5.default.openSync(logFile, "r");
95077
95259
  const buf = Buffer.alloc(stat5.size - offset);
95078
- import_node_fs4.default.readSync(fd, buf, 0, buf.length, offset);
95079
- import_node_fs4.default.closeSync(fd);
95260
+ import_node_fs5.default.readSync(fd, buf, 0, buf.length, offset);
95261
+ import_node_fs5.default.closeSync(fd);
95080
95262
  process.stdout.write(buf.toString("utf-8"));
95081
95263
  offset = stat5.size;
95082
95264
  } else if (stat5.size < offset) {
@@ -95086,7 +95268,7 @@ function registerServiceCommands(program2) {
95086
95268
  }
95087
95269
  });
95088
95270
  const cleanup = () => {
95089
- import_node_fs4.default.unwatchFile(logFile);
95271
+ import_node_fs5.default.unwatchFile(logFile);
95090
95272
  process.exit(0);
95091
95273
  };
95092
95274
  process.on("SIGINT", cleanup);
@@ -95127,7 +95309,7 @@ function registerServiceCommands(program2) {
95127
95309
  await new Promise((r) => setTimeout(r, 2e3));
95128
95310
  if (platform12 === "win32") {
95129
95311
  const vbsPath = getWindowsVbsPath();
95130
- if (import_node_fs4.default.existsSync(vbsPath)) {
95312
+ if (import_node_fs5.default.existsSync(vbsPath)) {
95131
95313
  try {
95132
95314
  (0, import_node_child_process2.execSync)(`wscript.exe "${vbsPath}"`, { stdio: "ignore", windowsHide: true });
95133
95315
  } catch {
@@ -95738,7 +95920,7 @@ function registerProviderCommands(program2) {
95738
95920
  } catch {
95739
95921
  try {
95740
95922
  const http3 = await import("http");
95741
- const result = await new Promise((resolve22, reject) => {
95923
+ const result = await new Promise((resolve23, reject) => {
95742
95924
  const req = http3.request({
95743
95925
  hostname: "127.0.0.1",
95744
95926
  port: DEV_SERVER_PORT3,
@@ -95750,9 +95932,9 @@ function registerProviderCommands(program2) {
95750
95932
  res.on("data", (c) => data += c);
95751
95933
  res.on("end", () => {
95752
95934
  try {
95753
- resolve22(JSON.parse(data));
95935
+ resolve23(JSON.parse(data));
95754
95936
  } catch {
95755
- resolve22({ raw: data });
95937
+ resolve23({ raw: data });
95756
95938
  }
95757
95939
  });
95758
95940
  });
@@ -95854,12 +96036,12 @@ function registerProviderCommands(program2) {
95854
96036
  console.log(source_default.yellow("Invalid port number."));
95855
96037
  continue;
95856
96038
  }
95857
- const isFree = await new Promise((resolve22) => {
96039
+ const isFree = await new Promise((resolve23) => {
95858
96040
  const server = net3.createServer();
95859
96041
  server.unref();
95860
- server.on("error", () => resolve22(false));
96042
+ server.on("error", () => resolve23(false));
95861
96043
  server.listen(port, "127.0.0.1", () => {
95862
- server.close(() => resolve22(true));
96044
+ server.close(() => resolve23(true));
95863
96045
  });
95864
96046
  });
95865
96047
  if (!isFree) {
@@ -95874,7 +96056,7 @@ function registerProviderCommands(program2) {
95874
96056
  rl.close();
95875
96057
  const location = options.builtin ? "builtin" : "user";
95876
96058
  const http3 = await import("http");
95877
- const result = await new Promise((resolve22, reject) => {
96059
+ const result = await new Promise((resolve23, reject) => {
95878
96060
  const postData = JSON.stringify({ type, name, category, location, cdpPorts, osPaths, processNames });
95879
96061
  const req = http3.request({
95880
96062
  hostname: "127.0.0.1",
@@ -95887,9 +96069,9 @@ function registerProviderCommands(program2) {
95887
96069
  res.on("data", (c) => data += c);
95888
96070
  res.on("end", () => {
95889
96071
  try {
95890
- resolve22(JSON.parse(data));
96072
+ resolve23(JSON.parse(data));
95891
96073
  } catch {
95892
- resolve22({ raw: data });
96074
+ resolve23({ raw: data });
95893
96075
  }
95894
96076
  });
95895
96077
  });
@@ -96088,7 +96270,7 @@ function registerProviderCommands(program2) {
96088
96270
  reference,
96089
96271
  ...verification ? { verification } : {}
96090
96272
  });
96091
- const startResult = await new Promise((resolve22, reject) => {
96273
+ const startResult = await new Promise((resolve23, reject) => {
96092
96274
  const req = http3.request({
96093
96275
  hostname: "127.0.0.1",
96094
96276
  port: DEV_SERVER_PORT3,
@@ -96100,9 +96282,9 @@ function registerProviderCommands(program2) {
96100
96282
  res.on("data", (c) => data += c);
96101
96283
  res.on("end", () => {
96102
96284
  try {
96103
- resolve22(JSON.parse(data));
96285
+ resolve23(JSON.parse(data));
96104
96286
  } catch {
96105
- resolve22({ raw: data });
96287
+ resolve23({ raw: data });
96106
96288
  }
96107
96289
  });
96108
96290
  });
@@ -96136,7 +96318,7 @@ function registerProviderCommands(program2) {
96136
96318
  fsMock.writeFileSync(logFile, `=== Auto-Impl Started ===
96137
96319
  `);
96138
96320
  console.log(source_default.gray(` Agent logs: ${logFile}`));
96139
- await new Promise((resolve22, reject) => {
96321
+ await new Promise((resolve23, reject) => {
96140
96322
  http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}${startResult.sseUrl}`, (res) => {
96141
96323
  let buffer = "";
96142
96324
  res.on("data", (chunk) => {
@@ -96173,7 +96355,7 @@ function registerProviderCommands(program2) {
96173
96355
  if (currentData.success === false) {
96174
96356
  reject(new Error(`Agent failed to implement scripts properly (exit: ${currentData.exitCode})`));
96175
96357
  } else {
96176
- resolve22();
96358
+ resolve23();
96177
96359
  }
96178
96360
  } else if (currentEvent === "error") {
96179
96361
  fsMock.appendFileSync(logFile, `
@@ -96184,7 +96366,7 @@ function registerProviderCommands(program2) {
96184
96366
  }
96185
96367
  }
96186
96368
  });
96187
- res.on("end", resolve22);
96369
+ res.on("end", resolve23);
96188
96370
  }).on("error", reject);
96189
96371
  });
96190
96372
  console.log(source_default.green(`
@@ -96243,7 +96425,7 @@ function registerProviderCommands(program2) {
96243
96425
  ideType: type,
96244
96426
  params: options.param ? { text: options.param, sessionId: options.param, buttonText: options.param } : {}
96245
96427
  });
96246
- const result = await new Promise((resolve22, reject) => {
96428
+ const result = await new Promise((resolve23, reject) => {
96247
96429
  const req = http3.request({
96248
96430
  hostname: "127.0.0.1",
96249
96431
  port: DEV_SERVER_PORT3,
@@ -96255,9 +96437,9 @@ function registerProviderCommands(program2) {
96255
96437
  res.on("data", (c) => data += c);
96256
96438
  res.on("end", () => {
96257
96439
  try {
96258
- resolve22(JSON.parse(data));
96440
+ resolve23(JSON.parse(data));
96259
96441
  } catch {
96260
- resolve22({ raw: data });
96442
+ resolve23({ raw: data });
96261
96443
  }
96262
96444
  });
96263
96445
  });
@@ -96293,15 +96475,15 @@ function registerProviderCommands(program2) {
96293
96475
  provider.command("source <type>").description("View source code of a provider").action(async (type) => {
96294
96476
  try {
96295
96477
  const http3 = await import("http");
96296
- const result = await new Promise((resolve22, reject) => {
96478
+ const result = await new Promise((resolve23, reject) => {
96297
96479
  http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}/api/providers/${type}/source`, (res) => {
96298
96480
  let data = "";
96299
96481
  res.on("data", (c) => data += c);
96300
96482
  res.on("end", () => {
96301
96483
  try {
96302
- resolve22(JSON.parse(data));
96484
+ resolve23(JSON.parse(data));
96303
96485
  } catch {
96304
- resolve22({ raw: data });
96486
+ resolve23({ raw: data });
96305
96487
  }
96306
96488
  });
96307
96489
  }).on("error", () => {
@@ -96349,7 +96531,7 @@ function registerProviderCommands(program2) {
96349
96531
  try {
96350
96532
  const http3 = await import("http");
96351
96533
  const postData = JSON.stringify({ script: "readChat", params: {} });
96352
- const result = await new Promise((resolve22, reject) => {
96534
+ const result = await new Promise((resolve23, reject) => {
96353
96535
  const req = http3.request({
96354
96536
  hostname: "127.0.0.1",
96355
96537
  port: DEV_SERVER_PORT3,
@@ -96361,9 +96543,9 @@ function registerProviderCommands(program2) {
96361
96543
  res2.on("data", (c) => data += c);
96362
96544
  res2.on("end", () => {
96363
96545
  try {
96364
- resolve22(JSON.parse(data));
96546
+ resolve23(JSON.parse(data));
96365
96547
  } catch {
96366
- resolve22({ raw: data });
96548
+ resolve23({ raw: data });
96367
96549
  }
96368
96550
  });
96369
96551
  });
@@ -96604,13 +96786,13 @@ function registerCdpCommands(program2) {
96604
96786
  cdp.command("screenshot").description("Capture IDE screenshot").option("-p, --port <port>", "CDP port", "9222").option("-o, --output <file>", "Output file path", "/tmp/cdp_screenshot.jpg").action(async (options) => {
96605
96787
  try {
96606
96788
  const http3 = await import("http");
96607
- const targets = await new Promise((resolve22, reject) => {
96789
+ const targets = await new Promise((resolve23, reject) => {
96608
96790
  http3.get(`http://127.0.0.1:${options.port}/json`, (res) => {
96609
96791
  let data = "";
96610
96792
  res.on("data", (c) => data += c);
96611
96793
  res.on("end", () => {
96612
96794
  try {
96613
- resolve22(JSON.parse(data));
96795
+ resolve23(JSON.parse(data));
96614
96796
  } catch {
96615
96797
  reject(new Error("Invalid JSON"));
96616
96798
  }
@@ -96624,7 +96806,7 @@ function registerCdpCommands(program2) {
96624
96806
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target");
96625
96807
  const WebSocket4 = (await import("ws")).default;
96626
96808
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
96627
- await new Promise((resolve22, reject) => {
96809
+ await new Promise((resolve23, reject) => {
96628
96810
  ws.on("open", () => {
96629
96811
  ws.send(JSON.stringify({ id: 1, method: "Page.captureScreenshot", params: { format: "jpeg", quality: 50 } }));
96630
96812
  });
@@ -96637,7 +96819,7 @@ function registerCdpCommands(program2) {
96637
96819
  \u2713 Screenshot saved to ${options.output}
96638
96820
  `));
96639
96821
  ws.close();
96640
- resolve22();
96822
+ resolve23();
96641
96823
  }
96642
96824
  });
96643
96825
  ws.on("error", (e) => reject(e));
@@ -96654,7 +96836,7 @@ function registerCdpCommands(program2) {
96654
96836
  // src/cli/mcp-commands.ts
96655
96837
  var import_node_child_process3 = require("child_process");
96656
96838
  var fs23 = __toESM(require("fs"));
96657
- var import_node_module3 = require("module");
96839
+ var import_node_module4 = require("module");
96658
96840
  var path39 = __toESM(require("path"));
96659
96841
  init_source();
96660
96842
  function registerMcpCommands(program2) {
@@ -96714,7 +96896,7 @@ function resolveMcpBin() {
96714
96896
  }
96715
96897
  }
96716
96898
  try {
96717
- const req = (0, import_node_module3.createRequire)(__filename);
96899
+ const req = (0, import_node_module4.createRequire)(__filename);
96718
96900
  return req.resolve("@adhdev/mcp-server");
96719
96901
  } catch {
96720
96902
  return null;