@adhdev/daemon-standalone 0.9.70 → 0.9.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -30095,7 +30095,7 @@ ${rules.join("\n")}`;
30095
30095
  `[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
30096
30096
  );
30097
30097
  }
30098
- await new Promise((resolve15) => setTimeout(resolve15, 50));
30098
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
30099
30099
  }
30100
30100
  const finalScreenText = this.terminalScreen.getText() || "";
30101
30101
  LOG2.warn(
@@ -31005,7 +31005,7 @@ ${rules.join("\n")}`;
31005
31005
  const deadline = Date.now() + 1e4;
31006
31006
  while (this.startupParseGate && Date.now() < deadline) {
31007
31007
  this.resolveStartupState("send_wait");
31008
- await new Promise((resolve15) => setTimeout(resolve15, 50));
31008
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
31009
31009
  }
31010
31010
  }
31011
31011
  if (!allowInterventionPrompt) {
@@ -31081,13 +31081,13 @@ ${rules.join("\n")}`;
31081
31081
  }
31082
31082
  this.responseEpoch += 1;
31083
31083
  this.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
31084
- await new Promise((resolve15, reject) => {
31084
+ await new Promise((resolve16, reject) => {
31085
31085
  let resolved = false;
31086
31086
  const completion = {
31087
31087
  resolveOnce: () => {
31088
31088
  if (resolved) return;
31089
31089
  resolved = true;
31090
- resolve15();
31090
+ resolve16();
31091
31091
  },
31092
31092
  rejectOnce: (error48) => {
31093
31093
  if (resolved) return;
@@ -31245,17 +31245,17 @@ ${rules.join("\n")}`;
31245
31245
  }
31246
31246
  }
31247
31247
  waitForStopped(timeoutMs) {
31248
- return new Promise((resolve15) => {
31248
+ return new Promise((resolve16) => {
31249
31249
  const startedAt = Date.now();
31250
31250
  const timer = setInterval(() => {
31251
31251
  if (!this.ptyProcess || this.currentStatus === "stopped") {
31252
31252
  clearInterval(timer);
31253
- resolve15(true);
31253
+ resolve16(true);
31254
31254
  return;
31255
31255
  }
31256
31256
  if (Date.now() - startedAt >= timeoutMs) {
31257
31257
  clearInterval(timer);
31258
- resolve15(false);
31258
+ resolve16(false);
31259
31259
  }
31260
31260
  }, 100);
31261
31261
  });
@@ -31398,11 +31398,22 @@ ${rules.join("\n")}`;
31398
31398
  }
31399
31399
  }
31400
31400
  }
31401
+ getParsedDebugState() {
31402
+ if (this.startupParseGate || typeof this.cliScripts?.parseSession !== "function") return null;
31403
+ try {
31404
+ const parsed = this.getScriptParsedStatus();
31405
+ return parsed && typeof parsed === "object" ? parsed : null;
31406
+ } catch {
31407
+ return null;
31408
+ }
31409
+ }
31401
31410
  getDebugState() {
31402
31411
  const screenText = sanitizeTerminalText(this.terminalScreen.getText());
31403
31412
  const startupModal = this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
31404
31413
  const effectiveStatus = this.projectEffectiveStatus(startupModal);
31405
31414
  const effectiveReady = this.ready || !!startupModal;
31415
+ const parsedDebugState = this.getParsedDebugState();
31416
+ const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
31406
31417
  return {
31407
31418
  type: this.cliType,
31408
31419
  name: this.cliName,
@@ -31415,8 +31426,18 @@ ${rules.join("\n")}`;
31415
31426
  startupParseGate: this.startupParseGate,
31416
31427
  spawnAt: this.spawnAt,
31417
31428
  workingDir: this.workingDir,
31418
- messages: [],
31419
- messageCount: 0,
31429
+ messages: parsedMessages,
31430
+ messageCount: parsedMessages.length,
31431
+ parsedStatus: parsedDebugState ? {
31432
+ id: parsedDebugState.id,
31433
+ status: parsedDebugState.status,
31434
+ title: parsedDebugState.title,
31435
+ providerSessionId: parsedDebugState.providerSessionId,
31436
+ transcriptAuthority: parsedDebugState.transcriptAuthority,
31437
+ coverage: parsedDebugState.coverage,
31438
+ activeModal: parsedDebugState.activeModal,
31439
+ messageCount: parsedMessages.length
31440
+ } : null,
31420
31441
  screenText: screenText.slice(-4e3),
31421
31442
  currentTurnScope: this.currentTurnScope,
31422
31443
  startupBuffer: this.startupBuffer.slice(-4e3),
@@ -33635,8 +33656,8 @@ ${rules.join("\n")}`;
33635
33656
  if ((0, import_fs4.existsSync)(bundledCli)) resolvedCli = bundledCli;
33636
33657
  }
33637
33658
  if (!resolvedCli && appPath && os21 === "win32") {
33638
- const { dirname: dirname7 } = await import("path");
33639
- const appDir = dirname7(appPath);
33659
+ const { dirname: dirname8 } = await import("path");
33660
+ const appDir = dirname8(appPath);
33640
33661
  const candidates = [
33641
33662
  `${appDir}\\\\bin\\\\${def.cli}.cmd`,
33642
33663
  `${appDir}\\\\bin\\\\${def.cli}`,
@@ -33698,19 +33719,19 @@ ${rules.join("\n")}`;
33698
33719
  return null;
33699
33720
  }
33700
33721
  function execAsync(cmd, timeoutMs = 5e3) {
33701
- return new Promise((resolve15) => {
33722
+ return new Promise((resolve16) => {
33702
33723
  const child = (0, import_child_process2.exec)(cmd, {
33703
33724
  encoding: "utf-8",
33704
33725
  timeout: timeoutMs,
33705
33726
  ...process.platform === "win32" ? { windowsHide: true } : {}
33706
33727
  }, (err, stdout) => {
33707
33728
  if (err || !stdout?.trim()) {
33708
- resolve15(null);
33729
+ resolve16(null);
33709
33730
  } else {
33710
- resolve15(stdout.trim());
33731
+ resolve16(stdout.trim());
33711
33732
  }
33712
33733
  });
33713
- child.on("error", () => resolve15(null));
33734
+ child.on("error", () => resolve16(null));
33714
33735
  });
33715
33736
  }
33716
33737
  async function detectCLIs(providerLoader, options) {
@@ -34067,7 +34088,7 @@ ${rules.join("\n")}`;
34067
34088
  * Returns multiple entries if multiple IDE windows are open on same port
34068
34089
  */
34069
34090
  static listAllTargets(port) {
34070
- return new Promise((resolve15) => {
34091
+ return new Promise((resolve16) => {
34071
34092
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
34072
34093
  let data = "";
34073
34094
  res.on("data", (chunk) => data += chunk.toString());
@@ -34083,16 +34104,16 @@ ${rules.join("\n")}`;
34083
34104
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
34084
34105
  );
34085
34106
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
34086
- resolve15(mainPages.length > 0 ? mainPages : fallbackPages);
34107
+ resolve16(mainPages.length > 0 ? mainPages : fallbackPages);
34087
34108
  } catch {
34088
- resolve15([]);
34109
+ resolve16([]);
34089
34110
  }
34090
34111
  });
34091
34112
  });
34092
- req.on("error", () => resolve15([]));
34113
+ req.on("error", () => resolve16([]));
34093
34114
  req.setTimeout(2e3, () => {
34094
34115
  req.destroy();
34095
- resolve15([]);
34116
+ resolve16([]);
34096
34117
  });
34097
34118
  });
34098
34119
  }
@@ -34132,7 +34153,7 @@ ${rules.join("\n")}`;
34132
34153
  }
34133
34154
  }
34134
34155
  findTargetOnPort(port) {
34135
- return new Promise((resolve15) => {
34156
+ return new Promise((resolve16) => {
34136
34157
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
34137
34158
  let data = "";
34138
34159
  res.on("data", (chunk) => data += chunk.toString());
@@ -34143,7 +34164,7 @@ ${rules.join("\n")}`;
34143
34164
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
34144
34165
  );
34145
34166
  if (pages.length === 0) {
34146
- resolve15(targets.find((t) => t.webSocketDebuggerUrl) || null);
34167
+ resolve16(targets.find((t) => t.webSocketDebuggerUrl) || null);
34147
34168
  return;
34148
34169
  }
34149
34170
  const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -34162,25 +34183,25 @@ ${rules.join("\n")}`;
34162
34183
  this._targetId = selected.target.id;
34163
34184
  }
34164
34185
  this._pageTitle = selected.target.title || "";
34165
- resolve15(selected.target);
34186
+ resolve16(selected.target);
34166
34187
  return;
34167
34188
  }
34168
34189
  if (previousTargetId) {
34169
34190
  this.log(`[CDP] Target ${previousTargetId} not found in page list`);
34170
- resolve15(null);
34191
+ resolve16(null);
34171
34192
  return;
34172
34193
  }
34173
34194
  this._pageTitle = list[0]?.title || "";
34174
- resolve15(list[0]);
34195
+ resolve16(list[0]);
34175
34196
  } catch {
34176
- resolve15(null);
34197
+ resolve16(null);
34177
34198
  }
34178
34199
  });
34179
34200
  });
34180
- req.on("error", () => resolve15(null));
34201
+ req.on("error", () => resolve16(null));
34181
34202
  req.setTimeout(2e3, () => {
34182
34203
  req.destroy();
34183
- resolve15(null);
34204
+ resolve16(null);
34184
34205
  });
34185
34206
  });
34186
34207
  }
@@ -34191,7 +34212,7 @@ ${rules.join("\n")}`;
34191
34212
  this.extensionProviders = providers;
34192
34213
  }
34193
34214
  connectToTarget(wsUrl) {
34194
- return new Promise((resolve15) => {
34215
+ return new Promise((resolve16) => {
34195
34216
  this.ws = new import_ws2.default(wsUrl);
34196
34217
  this.ws.on("open", async () => {
34197
34218
  this._connected = true;
@@ -34201,17 +34222,17 @@ ${rules.join("\n")}`;
34201
34222
  }
34202
34223
  this.connectBrowserWs().catch(() => {
34203
34224
  });
34204
- resolve15(true);
34225
+ resolve16(true);
34205
34226
  });
34206
34227
  this.ws.on("message", (data) => {
34207
34228
  try {
34208
34229
  const msg = JSON.parse(data.toString());
34209
34230
  if (msg.id && this.pending.has(msg.id)) {
34210
- const { resolve: resolve16, reject } = this.pending.get(msg.id);
34231
+ const { resolve: resolve17, reject } = this.pending.get(msg.id);
34211
34232
  this.pending.delete(msg.id);
34212
34233
  this.failureCount = 0;
34213
34234
  if (msg.error) reject(new Error(msg.error.message));
34214
- else resolve16(msg.result);
34235
+ else resolve17(msg.result);
34215
34236
  } else if (msg.method === "Runtime.executionContextCreated") {
34216
34237
  this.contexts.add(msg.params.context.id);
34217
34238
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -34234,7 +34255,7 @@ ${rules.join("\n")}`;
34234
34255
  this.ws.on("error", (err) => {
34235
34256
  this.log(`[CDP] WebSocket error: ${err.message}`);
34236
34257
  this._connected = false;
34237
- resolve15(false);
34258
+ resolve16(false);
34238
34259
  });
34239
34260
  });
34240
34261
  }
@@ -34248,7 +34269,7 @@ ${rules.join("\n")}`;
34248
34269
  return;
34249
34270
  }
34250
34271
  this.log(`[CDP] Connecting browser WS for target discovery...`);
34251
- await new Promise((resolve15, reject) => {
34272
+ await new Promise((resolve16, reject) => {
34252
34273
  this.browserWs = new import_ws2.default(browserWsUrl);
34253
34274
  this.browserWs.on("open", async () => {
34254
34275
  this._browserConnected = true;
@@ -34258,16 +34279,16 @@ ${rules.join("\n")}`;
34258
34279
  } catch (e) {
34259
34280
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
34260
34281
  }
34261
- resolve15();
34282
+ resolve16();
34262
34283
  });
34263
34284
  this.browserWs.on("message", (data) => {
34264
34285
  try {
34265
34286
  const msg = JSON.parse(data.toString());
34266
34287
  if (msg.id && this.browserPending.has(msg.id)) {
34267
- const { resolve: resolve16, reject: reject2 } = this.browserPending.get(msg.id);
34288
+ const { resolve: resolve17, reject: reject2 } = this.browserPending.get(msg.id);
34268
34289
  this.browserPending.delete(msg.id);
34269
34290
  if (msg.error) reject2(new Error(msg.error.message));
34270
- else resolve16(msg.result);
34291
+ else resolve17(msg.result);
34271
34292
  }
34272
34293
  } catch {
34273
34294
  }
@@ -34287,31 +34308,31 @@ ${rules.join("\n")}`;
34287
34308
  }
34288
34309
  }
34289
34310
  getBrowserWsUrl() {
34290
- return new Promise((resolve15) => {
34311
+ return new Promise((resolve16) => {
34291
34312
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
34292
34313
  let data = "";
34293
34314
  res.on("data", (chunk) => data += chunk.toString());
34294
34315
  res.on("end", () => {
34295
34316
  try {
34296
34317
  const info = JSON.parse(data);
34297
- resolve15(info.webSocketDebuggerUrl || null);
34318
+ resolve16(info.webSocketDebuggerUrl || null);
34298
34319
  } catch {
34299
- resolve15(null);
34320
+ resolve16(null);
34300
34321
  }
34301
34322
  });
34302
34323
  });
34303
- req.on("error", () => resolve15(null));
34324
+ req.on("error", () => resolve16(null));
34304
34325
  req.setTimeout(3e3, () => {
34305
34326
  req.destroy();
34306
- resolve15(null);
34327
+ resolve16(null);
34307
34328
  });
34308
34329
  });
34309
34330
  }
34310
34331
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
34311
- return new Promise((resolve15, reject) => {
34332
+ return new Promise((resolve16, reject) => {
34312
34333
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
34313
34334
  const id = this.browserMsgId++;
34314
- this.browserPending.set(id, { resolve: resolve15, reject });
34335
+ this.browserPending.set(id, { resolve: resolve16, reject });
34315
34336
  this.browserWs.send(JSON.stringify({ id, method, params }));
34316
34337
  setTimeout(() => {
34317
34338
  if (this.browserPending.has(id)) {
@@ -34351,11 +34372,11 @@ ${rules.join("\n")}`;
34351
34372
  }
34352
34373
  // ─── CDP Protocol ────────────────────────────────────────
34353
34374
  sendInternal(method, params = {}, timeoutMs = 15e3) {
34354
- return new Promise((resolve15, reject) => {
34375
+ return new Promise((resolve16, reject) => {
34355
34376
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
34356
34377
  if (this.ws.readyState !== import_ws2.default.OPEN) return reject(new Error("WebSocket not open"));
34357
34378
  const id = this.msgId++;
34358
- this.pending.set(id, { resolve: resolve15, reject });
34379
+ this.pending.set(id, { resolve: resolve16, reject });
34359
34380
  this.ws.send(JSON.stringify({ id, method, params }));
34360
34381
  setTimeout(() => {
34361
34382
  if (this.pending.has(id)) {
@@ -34604,7 +34625,7 @@ ${rules.join("\n")}`;
34604
34625
  const browserWs = this.browserWs;
34605
34626
  let msgId = this.browserMsgId;
34606
34627
  const sendWs = (method, params = {}, sessionId) => {
34607
- return new Promise((resolve15, reject) => {
34628
+ return new Promise((resolve16, reject) => {
34608
34629
  const mid = msgId++;
34609
34630
  this.browserMsgId = msgId;
34610
34631
  const handler = (raw) => {
@@ -34613,7 +34634,7 @@ ${rules.join("\n")}`;
34613
34634
  if (msg.id === mid) {
34614
34635
  browserWs.removeListener("message", handler);
34615
34636
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
34616
- else resolve15(msg.result);
34637
+ else resolve16(msg.result);
34617
34638
  }
34618
34639
  } catch {
34619
34640
  }
@@ -34814,14 +34835,14 @@ ${rules.join("\n")}`;
34814
34835
  if (!ws2 || ws2.readyState !== import_ws2.default.OPEN) {
34815
34836
  throw new Error("CDP not connected");
34816
34837
  }
34817
- return new Promise((resolve15, reject) => {
34838
+ return new Promise((resolve16, reject) => {
34818
34839
  const id = getNextId();
34819
34840
  pendingMap.set(id, {
34820
34841
  resolve: (result) => {
34821
34842
  if (result?.result?.subtype === "error") {
34822
34843
  reject(new Error(result.result.description));
34823
34844
  } else {
34824
- resolve15(result?.result?.value);
34845
+ resolve16(result?.result?.value);
34825
34846
  }
34826
34847
  },
34827
34848
  reject
@@ -34853,10 +34874,10 @@ ${rules.join("\n")}`;
34853
34874
  throw new Error("CDP not connected");
34854
34875
  }
34855
34876
  const sendViaSession = (method, params = {}) => {
34856
- return new Promise((resolve15, reject) => {
34877
+ return new Promise((resolve16, reject) => {
34857
34878
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
34858
34879
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
34859
- pendingMap.set(id, { resolve: resolve15, reject });
34880
+ pendingMap.set(id, { resolve: resolve16, reject });
34860
34881
  ws2.send(JSON.stringify({ id, sessionId, method, params }));
34861
34882
  setTimeout(() => {
34862
34883
  if (pendingMap.has(id)) {
@@ -39024,7 +39045,8 @@ ${effect.notification.body || ""}`.trim();
39024
39045
  },
39025
39046
  errorMessage: state.errorMessage,
39026
39047
  errorReason: state.errorReason,
39027
- lastUpdated: state.lastUpdated
39048
+ lastUpdated: state.lastUpdated,
39049
+ settings: state.settings
39028
39050
  };
39029
39051
  }
39030
39052
  function buildExtensionAgentSession(parent, ext, options) {
@@ -39059,7 +39081,8 @@ ${effect.notification.body || ""}`.trim();
39059
39081
  },
39060
39082
  errorMessage: ext.errorMessage,
39061
39083
  errorReason: ext.errorReason,
39062
- lastUpdated: ext.lastUpdated
39084
+ lastUpdated: ext.lastUpdated,
39085
+ settings: ext.settings
39063
39086
  };
39064
39087
  }
39065
39088
  function shouldIncludeExtensionSession(ext) {
@@ -39125,7 +39148,8 @@ ${effect.notification.body || ""}`.trim();
39125
39148
  },
39126
39149
  errorMessage: state.errorMessage,
39127
39150
  errorReason: state.errorReason,
39128
- lastUpdated: state.lastUpdated
39151
+ lastUpdated: state.lastUpdated,
39152
+ settings: state.settings
39129
39153
  };
39130
39154
  }
39131
39155
  function buildAcpSession(state, options) {
@@ -39159,7 +39183,8 @@ ${effect.notification.body || ""}`.trim();
39159
39183
  },
39160
39184
  errorMessage: state.errorMessage,
39161
39185
  errorReason: state.errorReason,
39162
- lastUpdated: state.lastUpdated
39186
+ lastUpdated: state.lastUpdated,
39187
+ settings: state.settings
39163
39188
  };
39164
39189
  }
39165
39190
  function buildSessionEntries(allStates, cdpManagers, options = {}) {
@@ -39508,6 +39533,8 @@ ${effect.notification.body || ""}`.trim();
39508
39533
  function getHistorySessionId(h, args) {
39509
39534
  const explicit = typeof args?.historySessionId === "string" ? args.historySessionId.trim() : "";
39510
39535
  if (explicit) return explicit;
39536
+ const explicitProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : "";
39537
+ if (explicitProviderSessionId) return explicitProviderSessionId;
39511
39538
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
39512
39539
  if (!targetSessionId) return void 0;
39513
39540
  const instance = h.ctx.instanceManager?.getInstance(targetSessionId);
@@ -39973,7 +40000,7 @@ ${effect.notification.body || ""}`.trim();
39973
40000
  async function getStableExtensionBaseline(h) {
39974
40001
  const first = await readExtensionChatState(h);
39975
40002
  if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
39976
- await new Promise((resolve15) => setTimeout(resolve15, 150));
40003
+ await new Promise((resolve16) => setTimeout(resolve16, 150));
39977
40004
  const second = await readExtensionChatState(h);
39978
40005
  return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
39979
40006
  }
@@ -39981,7 +40008,7 @@ ${effect.notification.body || ""}`.trim();
39981
40008
  const beforeCount = getStateMessageCount(before);
39982
40009
  const beforeSignature = getStateLastSignature(before);
39983
40010
  for (let attempt = 0; attempt < 12; attempt += 1) {
39984
- await new Promise((resolve15) => setTimeout(resolve15, 250));
40011
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
39985
40012
  const state = await readExtensionChatState(h);
39986
40013
  if (state?.status === "waiting_approval") return true;
39987
40014
  const afterCount = getStateMessageCount(state);
@@ -40071,7 +40098,32 @@ ${effect.notification.body || ""}`.trim();
40071
40098
  ...coverage ? { coverage } : {}
40072
40099
  }, args);
40073
40100
  }
40074
- return { success: false, error: `${transport} adapter not found` };
40101
+ const historyLimit = normalizeReadChatTailLimit(args);
40102
+ try {
40103
+ const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
40104
+ const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
40105
+ const history = readProviderChatHistory(agentStr, {
40106
+ canonicalHistory: provider?.canonicalHistory,
40107
+ historySessionId,
40108
+ workspace,
40109
+ offset: 0,
40110
+ limit: historyLimit,
40111
+ excludeRecentCount: 0,
40112
+ historyBehavior: provider?.historyBehavior,
40113
+ scripts: provider?.scripts
40114
+ });
40115
+ const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : historySessionId;
40116
+ return buildReadChatCommandResult({
40117
+ messages: Array.isArray(history?.messages) ? history.messages : [],
40118
+ status: "idle",
40119
+ ...typeof history?.title === "string" ? { title: history.title } : {},
40120
+ ...historyProviderSessionId ? { providerSessionId: historyProviderSessionId } : {},
40121
+ ...provider?.historyBehavior?.transcriptAuthority === "provider" || provider?.historyBehavior?.transcriptAuthority === "daemon" ? { transcriptAuthority: (provider?.historyBehavior).transcriptAuthority } : {},
40122
+ coverage: "tail"
40123
+ }, args);
40124
+ } catch (error48) {
40125
+ return { success: false, error: error48?.message || `${transport} adapter not found` };
40126
+ }
40075
40127
  }
40076
40128
  if (isExtensionTransport(transport)) {
40077
40129
  let extensionReadChatError = "";
@@ -41579,7 +41631,7 @@ ${effect.notification.body || ""}`.trim();
41579
41631
  const enterCount = cliCommand.enterCount || 1;
41580
41632
  await adapter.writeRaw(cliCommand.text + "\r");
41581
41633
  for (let i = 1; i < enterCount; i += 1) {
41582
- await new Promise((resolve15) => setTimeout(resolve15, 50));
41634
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
41583
41635
  await adapter.writeRaw("\r");
41584
41636
  }
41585
41637
  }
@@ -42260,7 +42312,7 @@ ${effect.notification.body || ""}`.trim();
42260
42312
  try {
42261
42313
  const http3 = await import("http");
42262
42314
  const postData = JSON.stringify(body);
42263
- const result = await new Promise((resolve15, reject) => {
42315
+ const result = await new Promise((resolve16, reject) => {
42264
42316
  const req = http3.request({
42265
42317
  hostname: "127.0.0.1",
42266
42318
  port: 19280,
@@ -42272,9 +42324,9 @@ ${effect.notification.body || ""}`.trim();
42272
42324
  res.on("data", (chunk) => data += chunk);
42273
42325
  res.on("end", () => {
42274
42326
  try {
42275
- resolve15(JSON.parse(data));
42327
+ resolve16(JSON.parse(data));
42276
42328
  } catch {
42277
- resolve15({ raw: data });
42329
+ resolve16({ raw: data });
42278
42330
  }
42279
42331
  });
42280
42332
  });
@@ -42292,15 +42344,15 @@ ${effect.notification.body || ""}`.trim();
42292
42344
  if (!providerType) return { success: false, error: "providerType required" };
42293
42345
  try {
42294
42346
  const http3 = await import("http");
42295
- const result = await new Promise((resolve15, reject) => {
42347
+ const result = await new Promise((resolve16, reject) => {
42296
42348
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
42297
42349
  let data = "";
42298
42350
  res.on("data", (chunk) => data += chunk);
42299
42351
  res.on("end", () => {
42300
42352
  try {
42301
- resolve15(JSON.parse(data));
42353
+ resolve16(JSON.parse(data));
42302
42354
  } catch {
42303
- resolve15({ raw: data });
42355
+ resolve16({ raw: data });
42304
42356
  }
42305
42357
  });
42306
42358
  }).on("error", reject);
@@ -42314,7 +42366,7 @@ ${effect.notification.body || ""}`.trim();
42314
42366
  try {
42315
42367
  const http3 = await import("http");
42316
42368
  const postData = JSON.stringify(args || {});
42317
- const result = await new Promise((resolve15, reject) => {
42369
+ const result = await new Promise((resolve16, reject) => {
42318
42370
  const req = http3.request({
42319
42371
  hostname: "127.0.0.1",
42320
42372
  port: 19280,
@@ -42326,9 +42378,9 @@ ${effect.notification.body || ""}`.trim();
42326
42378
  res.on("data", (chunk) => data += chunk);
42327
42379
  res.on("end", () => {
42328
42380
  try {
42329
- resolve15(JSON.parse(data));
42381
+ resolve16(JSON.parse(data));
42330
42382
  } catch {
42331
- resolve15({ raw: data });
42383
+ resolve16({ raw: data });
42332
42384
  }
42333
42385
  });
42334
42386
  });
@@ -42444,7 +42496,7 @@ ${effect.notification.body || ""}`.trim();
42444
42496
  if (status === "stopped") {
42445
42497
  throw new Error("CLI runtime stopped before it became ready");
42446
42498
  }
42447
- await new Promise((resolve15) => setTimeout(resolve15, pollMs));
42499
+ await new Promise((resolve16) => setTimeout(resolve16, pollMs));
42448
42500
  }
42449
42501
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
42450
42502
  }
@@ -42600,7 +42652,7 @@ ${effect.notification.body || ""}`.trim();
42600
42652
  this.errorMessage = void 0;
42601
42653
  this.errorReason = void 0;
42602
42654
  }
42603
- const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
42655
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
42604
42656
  const visibleStatus = parseErrorMessage ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
42605
42657
  const parsedProviderSessionId = normalizeProviderSessionId(
42606
42658
  this.provider,
@@ -42787,18 +42839,14 @@ ${effect.notification.body || ""}`.trim();
42787
42839
  const enterCount = cliCommand.enterCount || 1;
42788
42840
  await this.adapter.writeRaw(cliCommand.text + "\r");
42789
42841
  for (let i = 1; i < enterCount; i += 1) {
42790
- await new Promise((resolve15) => setTimeout(resolve15, 50));
42842
+ await new Promise((resolve16) => setTimeout(resolve16, 50));
42791
42843
  await this.adapter.writeRaw("\r");
42792
42844
  }
42793
42845
  }
42794
42846
  this.applyProviderResponse(parsed.payload, { phase: "immediate" });
42795
42847
  }
42796
- detectStatusTransition() {
42797
- const now = Date.now();
42798
- const adapterStatus = this.adapter.getStatus({ allowParse: false });
42799
- const parsedStatus = null;
42800
- const rawStatus = adapterStatus.status;
42801
- const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
42848
+ maybeAutoApproveStatus(adapterStatus, now = Date.now()) {
42849
+ const autoApproveActive = adapterStatus?.status === "waiting_approval" && this.shouldAutoApprove();
42802
42850
  if (autoApproveActive && !this.autoApproveBusy) {
42803
42851
  this.autoApproveBusy = true;
42804
42852
  if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
@@ -42806,12 +42854,21 @@ ${effect.notification.body || ""}`.trim();
42806
42854
  this.autoApproveBusy = false;
42807
42855
  this.autoApproveBusyTimer = null;
42808
42856
  }, 2e3);
42809
- const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(adapterStatus.activeModal?.buttons, this.provider);
42810
- this.recordAutoApproval(adapterStatus.activeModal?.message, buttonLabel, now);
42857
+ const modal = adapterStatus.activeModal;
42858
+ const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(modal?.buttons, this.provider);
42859
+ this.recordAutoApproval(modal?.message, buttonLabel, now);
42811
42860
  setTimeout(() => {
42812
42861
  this.adapter.resolveModal(buttonIndex);
42813
42862
  }, 0);
42814
42863
  }
42864
+ return autoApproveActive;
42865
+ }
42866
+ detectStatusTransition() {
42867
+ const now = Date.now();
42868
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
42869
+ const parsedStatus = null;
42870
+ const rawStatus = adapterStatus.status;
42871
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, now);
42815
42872
  const newStatus = autoApproveActive ? "generating" : rawStatus;
42816
42873
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
42817
42874
  const chatTitle = `${this.provider.name} \xB7 ${dirName}`;
@@ -43885,13 +43942,13 @@ ${effect.notification.body || ""}`.trim();
43885
43942
  }
43886
43943
  this.currentStatus = "waiting_approval";
43887
43944
  this.detectStatusTransition();
43888
- const approved = await new Promise((resolve15) => {
43889
- this.permissionResolvers.push(resolve15);
43945
+ const approved = await new Promise((resolve16) => {
43946
+ this.permissionResolvers.push(resolve16);
43890
43947
  setTimeout(() => {
43891
- const idx = this.permissionResolvers.indexOf(resolve15);
43948
+ const idx = this.permissionResolvers.indexOf(resolve16);
43892
43949
  if (idx >= 0) {
43893
43950
  this.permissionResolvers.splice(idx, 1);
43894
- resolve15(false);
43951
+ resolve16(false);
43895
43952
  }
43896
43953
  }, 3e5);
43897
43954
  });
@@ -44869,7 +44926,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
44869
44926
  resolvedDir,
44870
44927
  resolvedCliArgs,
44871
44928
  resolvedProvider,
44872
- this.providerLoader.getSettings(normalizedType),
44929
+ { ...this.providerLoader.getSettings(normalizedType), ...options?.settingsOverride || {} },
44873
44930
  false,
44874
44931
  {
44875
44932
  providerSessionId: sessionBinding.providerSessionId,
@@ -45123,7 +45180,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
45123
45180
  dir,
45124
45181
  args?.cliArgs,
45125
45182
  args?.initialModel,
45126
- { resumeSessionId: args?.resumeSessionId }
45183
+ { resumeSessionId: args?.resumeSessionId, settingsOverride: args?.settings }
45127
45184
  );
45128
45185
  return {
45129
45186
  success: true,
@@ -46463,7 +46520,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46463
46520
  return { updated: false };
46464
46521
  }
46465
46522
  try {
46466
- const etag = await new Promise((resolve15, reject) => {
46523
+ const etag = await new Promise((resolve16, reject) => {
46467
46524
  const options = {
46468
46525
  method: "HEAD",
46469
46526
  hostname: "github.com",
@@ -46481,7 +46538,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46481
46538
  headers: { "User-Agent": "adhdev-launcher" },
46482
46539
  timeout: 1e4
46483
46540
  }, (res2) => {
46484
- resolve15(res2.headers.etag || res2.headers["last-modified"] || "");
46541
+ resolve16(res2.headers.etag || res2.headers["last-modified"] || "");
46485
46542
  });
46486
46543
  req2.on("error", reject);
46487
46544
  req2.on("timeout", () => {
@@ -46490,7 +46547,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46490
46547
  });
46491
46548
  req2.end();
46492
46549
  } else {
46493
- resolve15(res.headers.etag || res.headers["last-modified"] || "");
46550
+ resolve16(res.headers.etag || res.headers["last-modified"] || "");
46494
46551
  }
46495
46552
  });
46496
46553
  req.on("error", reject);
@@ -46554,7 +46611,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46554
46611
  downloadFile(url2, destPath) {
46555
46612
  const https = require("https");
46556
46613
  const http3 = require("http");
46557
- return new Promise((resolve15, reject) => {
46614
+ return new Promise((resolve16, reject) => {
46558
46615
  const doRequest = (reqUrl, redirectCount = 0) => {
46559
46616
  if (redirectCount > 5) {
46560
46617
  reject(new Error("Too many redirects"));
@@ -46574,7 +46631,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46574
46631
  res.pipe(ws2);
46575
46632
  ws2.on("finish", () => {
46576
46633
  ws2.close();
46577
- resolve15();
46634
+ resolve16();
46578
46635
  });
46579
46636
  ws2.on("error", reject);
46580
46637
  });
@@ -47149,17 +47206,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
47149
47206
  throw new Error("No free port found");
47150
47207
  }
47151
47208
  function checkPortFree(port) {
47152
- return new Promise((resolve15) => {
47209
+ return new Promise((resolve16) => {
47153
47210
  const server = net3.createServer();
47154
47211
  server.unref();
47155
- server.on("error", () => resolve15(false));
47212
+ server.on("error", () => resolve16(false));
47156
47213
  server.listen(port, "127.0.0.1", () => {
47157
- server.close(() => resolve15(true));
47214
+ server.close(() => resolve16(true));
47158
47215
  });
47159
47216
  });
47160
47217
  }
47161
47218
  async function isCdpActive(port) {
47162
- return new Promise((resolve15) => {
47219
+ return new Promise((resolve16) => {
47163
47220
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
47164
47221
  timeout: 2e3
47165
47222
  }, (res) => {
@@ -47168,16 +47225,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
47168
47225
  res.on("end", () => {
47169
47226
  try {
47170
47227
  const info = JSON.parse(data);
47171
- resolve15(!!info["WebKit-Version"] || !!info["Browser"]);
47228
+ resolve16(!!info["WebKit-Version"] || !!info["Browser"]);
47172
47229
  } catch {
47173
- resolve15(false);
47230
+ resolve16(false);
47174
47231
  }
47175
47232
  });
47176
47233
  });
47177
- req.on("error", () => resolve15(false));
47234
+ req.on("error", () => resolve16(false));
47178
47235
  req.on("timeout", () => {
47179
47236
  req.destroy();
47180
- resolve15(false);
47237
+ resolve16(false);
47181
47238
  });
47182
47239
  });
47183
47240
  }
@@ -47645,7 +47702,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
47645
47702
  }
47646
47703
  cleanOldFiles();
47647
47704
  init_logger();
47648
- var import_path4 = require("path");
47705
+ var import_node_fs22 = require("fs");
47706
+ var import_node_module2 = require("module");
47707
+ var import_node_path2 = require("path");
47649
47708
  var DEFAULT_SERVER_NAME = "adhdev-mesh";
47650
47709
  var DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
47651
47710
  function resolveMeshCoordinatorSetup(options) {
@@ -47670,11 +47729,23 @@ Run 'adhdev doctor' for detailed diagnostics.`
47670
47729
  if (!path26) {
47671
47730
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
47672
47731
  }
47732
+ const mcpServer = resolveAdhdevMcpServerLaunch({
47733
+ meshId,
47734
+ nodeExecutable: options.nodeExecutable,
47735
+ adhdevMcpEntryPath: options.adhdevMcpEntryPath
47736
+ });
47737
+ if (!mcpServer) {
47738
+ return {
47739
+ kind: "unsupported",
47740
+ reason: "Could not resolve the ADHDev MCP server entrypoint without relying on a PATH bin shim"
47741
+ };
47742
+ }
47673
47743
  return {
47674
47744
  kind: "auto_import",
47675
47745
  serverName,
47676
- configPath: (0, import_path4.join)(workspace, path26),
47677
- configFormat: mcpConfig.format
47746
+ configPath: (0, import_node_path2.join)(workspace, path26),
47747
+ configFormat: mcpConfig.format,
47748
+ mcpServer
47678
47749
  };
47679
47750
  }
47680
47751
  if (mcpConfig.mode === "manual") {
@@ -47706,6 +47777,53 @@ Run 'adhdev doctor' for detailed diagnostics.`
47706
47777
  function renderMeshCoordinatorTemplate(template, values) {
47707
47778
  return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_, key) => values[key] || "");
47708
47779
  }
47780
+ function resolveAdhdevMcpServerLaunch(options) {
47781
+ const entryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath);
47782
+ if (!entryPath) return null;
47783
+ return {
47784
+ command: options.nodeExecutable?.trim() || process.execPath,
47785
+ args: [entryPath, "--repo-mesh", options.meshId]
47786
+ };
47787
+ }
47788
+ function resolveAdhdevMcpEntryPath(explicitPath) {
47789
+ const explicit = explicitPath?.trim();
47790
+ if (explicit) return normalizeExistingPath(explicit) || explicit;
47791
+ const envPath = process.env.ADHDEV_MCP_SERVER_PATH?.trim();
47792
+ if (envPath) return normalizeExistingPath(envPath) || envPath;
47793
+ const candidates = [];
47794
+ const addCandidate = (candidate) => {
47795
+ if (!candidates.includes(candidate)) candidates.push(candidate);
47796
+ };
47797
+ const addPackagedCandidates = (baseFile) => {
47798
+ if (!baseFile) return;
47799
+ const realBase = normalizeExistingPath(baseFile) || baseFile;
47800
+ const dir = (0, import_node_path2.dirname)(realBase);
47801
+ addCandidate((0, import_node_path2.resolve)(dir, "../vendor/mcp-server/index.js"));
47802
+ addCandidate((0, import_node_path2.resolve)(dir, "../../vendor/mcp-server/index.js"));
47803
+ addCandidate((0, import_node_path2.resolve)(dir, "../../../vendor/mcp-server/index.js"));
47804
+ };
47805
+ addPackagedCandidates(process.argv[1]);
47806
+ for (const candidate of candidates) {
47807
+ const normalized = normalizeExistingPath(candidate);
47808
+ if (normalized) return normalized;
47809
+ }
47810
+ try {
47811
+ const requireBase = process.argv[1] ? normalizeExistingPath(process.argv[1]) || process.argv[1] : (0, import_node_path2.join)(process.cwd(), "adhdev-daemon.js");
47812
+ const req = (0, import_node_module2.createRequire)(requireBase);
47813
+ const resolvedModule = req.resolve("@adhdev/mcp-server");
47814
+ return normalizeExistingPath(resolvedModule) || resolvedModule;
47815
+ } catch {
47816
+ return null;
47817
+ }
47818
+ }
47819
+ function normalizeExistingPath(filePath) {
47820
+ try {
47821
+ if (!(0, import_node_fs22.existsSync)(filePath)) return null;
47822
+ return import_node_fs22.realpathSync.native(filePath);
47823
+ } catch {
47824
+ return null;
47825
+ }
47826
+ }
47709
47827
  var os17 = __toESM2(require("os"));
47710
47828
  init_config();
47711
47829
  init_terminal_screen();
@@ -48209,7 +48327,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
48209
48327
  while (Date.now() - start < timeoutMs) {
48210
48328
  try {
48211
48329
  process.kill(pid, 0);
48212
- await new Promise((resolve15) => setTimeout(resolve15, 250));
48330
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
48213
48331
  } catch {
48214
48332
  return;
48215
48333
  }
@@ -48320,7 +48438,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
48320
48438
  appendUpgradeLog(installOutput.trim());
48321
48439
  }
48322
48440
  if (process.platform === "win32") {
48323
- await new Promise((resolve15) => setTimeout(resolve15, 500));
48441
+ await new Promise((resolve16) => setTimeout(resolve16, 500));
48324
48442
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
48325
48443
  appendUpgradeLog("Post-install staging cleanup complete");
48326
48444
  }
@@ -49156,11 +49274,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
49156
49274
  const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
49157
49275
  if (!meshId) return { success: false, error: "meshId required" };
49158
49276
  try {
49159
- const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
49160
49277
  const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
49161
- const mesh = getMesh3(meshId);
49278
+ let mesh;
49279
+ if (args?.inlineMesh && typeof args.inlineMesh === "object") {
49280
+ mesh = args.inlineMesh;
49281
+ } else {
49282
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
49283
+ mesh = getMesh3(meshId);
49284
+ }
49162
49285
  if (!mesh) return { success: false, error: "Mesh not found" };
49163
- if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
49286
+ if (!Array.isArray(mesh.nodes) || mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
49164
49287
  const workspace = mesh.nodes[0].workspace;
49165
49288
  const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
49166
49289
  const coordinatorSetup = resolveMeshCoordinatorSetup({
@@ -49199,9 +49322,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
49199
49322
  workspace
49200
49323
  };
49201
49324
  }
49202
- const { existsSync: existsSync21, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
49325
+ const { existsSync: existsSync22, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
49203
49326
  const mcpConfigPath = coordinatorSetup.configPath;
49204
- const hadExistingMcpConfig = existsSync21(mcpConfigPath);
49327
+ const hadExistingMcpConfig = existsSync22(mcpConfigPath);
49205
49328
  let existingMcpConfig = {};
49206
49329
  if (hadExistingMcpConfig) {
49207
49330
  try {
@@ -49215,8 +49338,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
49215
49338
  mcpServers: {
49216
49339
  ...existingMcpConfig.mcpServers || {},
49217
49340
  [coordinatorSetup.serverName]: {
49218
- command: "adhdev-mcp",
49219
- args: ["--repo-mesh", meshId]
49341
+ command: coordinatorSetup.mcpServer.command,
49342
+ args: coordinatorSetup.mcpServer.args
49220
49343
  }
49221
49344
  }
49222
49345
  };
@@ -49228,10 +49351,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
49228
49351
  } catch {
49229
49352
  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).`;
49230
49353
  }
49354
+ const cliArgs = [];
49355
+ if (systemPrompt) {
49356
+ cliArgs.push("--append-system-prompt", systemPrompt);
49357
+ }
49358
+ if (cliType === "claude-cli") {
49359
+ cliArgs.push("--mcp-config", coordinatorSetup.configPath);
49360
+ }
49231
49361
  const launchResult = await this.deps.cliManager.handleCliCommand("launch_cli", {
49232
49362
  cliType,
49233
49363
  dir: workspace,
49234
- initialPrompt: systemPrompt
49364
+ cliArgs: cliArgs.length > 0 ? cliArgs : void 0,
49365
+ settings: {
49366
+ meshCoordinatorFor: meshId
49367
+ }
49235
49368
  });
49236
49369
  if (!launchResult?.success) {
49237
49370
  return { success: false, error: launchResult?.error || "Failed to launch CLI session" };
@@ -49532,7 +49665,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
49532
49665
  workspace: session.workspace ?? null,
49533
49666
  title: session.title,
49534
49667
  cdpConnected: session.cdpConnected,
49535
- summaryMetadata: session.summaryMetadata
49668
+ summaryMetadata: session.summaryMetadata,
49669
+ settings: session.settings
49536
49670
  })),
49537
49671
  p2p: payload.p2p,
49538
49672
  timestamp: now
@@ -49847,7 +49981,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
49847
49981
  const beforeCount = this.messageCount(before);
49848
49982
  const beforeSignature = this.lastMessageSignature(before);
49849
49983
  for (let attempt = 0; attempt < 12; attempt += 1) {
49850
- await new Promise((resolve15) => setTimeout(resolve15, 250));
49984
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
49851
49985
  let state;
49852
49986
  try {
49853
49987
  state = await this.readChat(evaluate);
@@ -49869,7 +50003,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
49869
50003
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
49870
50004
  return first;
49871
50005
  }
49872
- await new Promise((resolve15) => setTimeout(resolve15, 150));
50006
+ await new Promise((resolve16) => setTimeout(resolve16, 150));
49873
50007
  const second = await this.readChat(evaluate);
49874
50008
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
49875
50009
  }
@@ -50020,7 +50154,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
50020
50154
  if (typeof data.error === "string" && data.error.trim()) return false;
50021
50155
  }
50022
50156
  for (let attempt = 0; attempt < 6; attempt += 1) {
50023
- await new Promise((resolve15) => setTimeout(resolve15, 250));
50157
+ await new Promise((resolve16) => setTimeout(resolve16, 250));
50024
50158
  const state = await this.readChat(evaluate);
50025
50159
  const title = this.getStateTitle(state);
50026
50160
  if (this.titlesMatch(title, sessionId)) return true;
@@ -52593,7 +52727,7 @@ async (params) => {
52593
52727
  return { target, instance, adapter };
52594
52728
  }
52595
52729
  function sleep(ms2) {
52596
- return new Promise((resolve15) => setTimeout(resolve15, ms2));
52730
+ return new Promise((resolve16) => setTimeout(resolve16, ms2));
52597
52731
  }
52598
52732
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
52599
52733
  const startedAt = Date.now();
@@ -54835,15 +54969,15 @@ data: ${JSON.stringify(msg.data)}
54835
54969
  this.json(res, 500, { error: e.message });
54836
54970
  }
54837
54971
  });
54838
- return new Promise((resolve15, reject) => {
54972
+ return new Promise((resolve16, reject) => {
54839
54973
  this.server.listen(port, "127.0.0.1", () => {
54840
54974
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
54841
- resolve15();
54975
+ resolve16();
54842
54976
  });
54843
54977
  this.server.on("error", (e) => {
54844
54978
  if (e.code === "EADDRINUSE") {
54845
54979
  this.log(`Port ${port} in use, skipping dev server`);
54846
- resolve15();
54980
+ resolve16();
54847
54981
  } else {
54848
54982
  reject(e);
54849
54983
  }
@@ -54925,20 +55059,20 @@ data: ${JSON.stringify(msg.data)}
54925
55059
  child.stderr?.on("data", (d) => {
54926
55060
  stderr += d.toString().slice(0, 2e3);
54927
55061
  });
54928
- await new Promise((resolve15) => {
55062
+ await new Promise((resolve16) => {
54929
55063
  const timer = setTimeout(() => {
54930
55064
  child.kill();
54931
- resolve15();
55065
+ resolve16();
54932
55066
  }, 3e3);
54933
55067
  child.on("exit", () => {
54934
55068
  clearTimeout(timer);
54935
- resolve15();
55069
+ resolve16();
54936
55070
  });
54937
55071
  child.stdout?.once("data", () => {
54938
55072
  setTimeout(() => {
54939
55073
  child.kill();
54940
55074
  clearTimeout(timer);
54941
- resolve15();
55075
+ resolve16();
54942
55076
  }, 500);
54943
55077
  });
54944
55078
  });
@@ -55441,14 +55575,14 @@ data: ${JSON.stringify(msg.data)}
55441
55575
  child.stderr?.on("data", (d) => {
55442
55576
  stderr += d.toString();
55443
55577
  });
55444
- await new Promise((resolve15) => {
55578
+ await new Promise((resolve16) => {
55445
55579
  const timer = setTimeout(() => {
55446
55580
  child.kill();
55447
- resolve15();
55581
+ resolve16();
55448
55582
  }, timeout);
55449
55583
  child.on("exit", () => {
55450
55584
  clearTimeout(timer);
55451
- resolve15();
55585
+ resolve16();
55452
55586
  });
55453
55587
  });
55454
55588
  const elapsed = Date.now() - start;
@@ -56118,14 +56252,14 @@ data: ${JSON.stringify(msg.data)}
56118
56252
  res.end(JSON.stringify(data, null, 2));
56119
56253
  }
56120
56254
  async readBody(req) {
56121
- return new Promise((resolve15) => {
56255
+ return new Promise((resolve16) => {
56122
56256
  let body = "";
56123
56257
  req.on("data", (chunk) => body += chunk);
56124
56258
  req.on("end", () => {
56125
56259
  try {
56126
- resolve15(JSON.parse(body));
56260
+ resolve16(JSON.parse(body));
56127
56261
  } catch {
56128
- resolve15({});
56262
+ resolve16({});
56129
56263
  }
56130
56264
  });
56131
56265
  });
@@ -56627,7 +56761,7 @@ data: ${JSON.stringify(msg.data)}
56627
56761
  const deadline = Date.now() + timeoutMs;
56628
56762
  while (Date.now() < deadline) {
56629
56763
  if (await canConnect(endpoint)) return;
56630
- await new Promise((resolve15) => setTimeout(resolve15, STARTUP_POLL_MS));
56764
+ await new Promise((resolve16) => setTimeout(resolve16, STARTUP_POLL_MS));
56631
56765
  }
56632
56766
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
56633
56767
  }
@@ -56801,10 +56935,10 @@ data: ${JSON.stringify(msg.data)}
56801
56935
  const buffer = Buffer.from(await res.arrayBuffer());
56802
56936
  const fs16 = await import("fs");
56803
56937
  fs16.writeFileSync(vsixPath, buffer);
56804
- return new Promise((resolve15) => {
56938
+ return new Promise((resolve16) => {
56805
56939
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
56806
56940
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
56807
- resolve15({
56941
+ resolve16({
56808
56942
  extensionId: extension.id,
56809
56943
  marketplaceId: extension.marketplaceId,
56810
56944
  success: !error48,
@@ -56817,11 +56951,11 @@ data: ${JSON.stringify(msg.data)}
56817
56951
  } catch (e) {
56818
56952
  }
56819
56953
  }
56820
- return new Promise((resolve15) => {
56954
+ return new Promise((resolve16) => {
56821
56955
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
56822
56956
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
56823
56957
  if (error48) {
56824
- resolve15({
56958
+ resolve16({
56825
56959
  extensionId: extension.id,
56826
56960
  marketplaceId: extension.marketplaceId,
56827
56961
  success: false,
@@ -56829,7 +56963,7 @@ data: ${JSON.stringify(msg.data)}
56829
56963
  error: stderr || error48.message
56830
56964
  });
56831
56965
  } else {
56832
- resolve15({
56966
+ resolve16({
56833
56967
  extensionId: extension.id,
56834
56968
  marketplaceId: extension.marketplaceId,
56835
56969
  success: true,
@@ -56919,6 +57053,44 @@ data: ${JSON.stringify(msg.data)}
56919
57053
  };
56920
57054
  init_logger();
56921
57055
  init_config();
57056
+ init_mesh_config();
57057
+ init_logger();
57058
+ function setupMeshEventForwarding(components) {
57059
+ components.instanceManager.onEvent((event) => {
57060
+ if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
57061
+ const instanceId = event.instanceId;
57062
+ if (!instanceId) return;
57063
+ const sourceInstance = components.instanceManager.getInstance(instanceId);
57064
+ if (!sourceInstance || sourceInstance.category !== "cli") return;
57065
+ const state = sourceInstance.getState();
57066
+ const workspace = state.workspace;
57067
+ if (!workspace) return;
57068
+ const mesh = getMeshByRepo(workspace);
57069
+ if (!mesh) return;
57070
+ const allInstances = components.instanceManager.getByCategory("cli");
57071
+ const coordinatorInstances = allInstances.filter((inst) => {
57072
+ const instState = inst.getState();
57073
+ if (instState.settings?.meshCoordinatorFor !== mesh.id) return false;
57074
+ if (instState.instanceId === instanceId) return false;
57075
+ return true;
57076
+ });
57077
+ if (coordinatorInstances.length === 0) return;
57078
+ const targetNode = mesh.nodes.find((n) => n.workspace === workspace);
57079
+ const nodeLabel = targetNode ? `Node '${targetNode.id}'` : `Agent at ${workspace}`;
57080
+ let messageText = "";
57081
+ if (event.event === "agent:generating_completed") {
57082
+ messageText = `[System] ${nodeLabel} has completed its task and is now idle. You may use mesh_read_chat to review its progress.`;
57083
+ } else if (event.event === "agent:waiting_approval") {
57084
+ messageText = `[System] ${nodeLabel} is waiting for approval to proceed. You may use mesh_read_chat and mesh_approve to handle it.`;
57085
+ }
57086
+ if (!messageText) return;
57087
+ for (const coord of coordinatorInstances) {
57088
+ const coordState = coord.getState();
57089
+ LOG2.info("MeshEvents", `Forwarding event from ${workspace} to coordinator ${coordState.instanceId}`);
57090
+ coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
57091
+ }
57092
+ });
57093
+ }
56922
57094
  async function initDaemonComponents2(config2) {
56923
57095
  installGlobalInterceptor();
56924
57096
  const appConfig = loadConfig2();
@@ -57076,7 +57248,7 @@ data: ${JSON.stringify(msg.data)}
57076
57248
  });
57077
57249
  poller.start();
57078
57250
  instanceManager.startTicking(config2.tickIntervalMs ?? 5e3);
57079
- return {
57251
+ const components = {
57080
57252
  providerLoader,
57081
57253
  instanceManager,
57082
57254
  cliManager,
@@ -57090,6 +57262,8 @@ data: ${JSON.stringify(msg.data)}
57090
57262
  detectedIdes: detectedIdesRef,
57091
57263
  refreshProviderAvailability
57092
57264
  };
57265
+ setupMeshEventForwarding(components);
57266
+ return components;
57093
57267
  }
57094
57268
  async function startDaemonDevSupport2(options) {
57095
57269
  const devServer = new DevServer({