@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.
@@ -25377,8 +25377,8 @@ async function detectIDEs(providerLoader) {
25377
25377
  if ((0, import_fs5.existsSync)(bundledCli)) resolvedCli = bundledCli;
25378
25378
  }
25379
25379
  if (!resolvedCli && appPath && os21 === "win32") {
25380
- const { dirname: dirname72 } = await import("path");
25381
- const appDir = dirname72(appPath);
25380
+ const { dirname: dirname82 } = await import("path");
25381
+ const appDir = dirname82(appPath);
25382
25382
  const candidates = [
25383
25383
  `${appDir}\\\\bin\\\\${def.cli}.cmd`,
25384
25384
  `${appDir}\\\\bin\\\\${def.cli}`,
@@ -25436,19 +25436,19 @@ function resolveCommandPath(command) {
25436
25436
  return null;
25437
25437
  }
25438
25438
  function execAsync(cmd, timeoutMs = 5e3) {
25439
- return new Promise((resolve152) => {
25439
+ return new Promise((resolve162) => {
25440
25440
  const child = (0, import_child_process4.exec)(cmd, {
25441
25441
  encoding: "utf-8",
25442
25442
  timeout: timeoutMs,
25443
25443
  ...process.platform === "win32" ? { windowsHide: true } : {}
25444
25444
  }, (err, stdout) => {
25445
25445
  if (err || !stdout?.trim()) {
25446
- resolve152(null);
25446
+ resolve162(null);
25447
25447
  } else {
25448
- resolve152(stdout.trim());
25448
+ resolve162(stdout.trim());
25449
25449
  }
25450
25450
  });
25451
- child.on("error", () => resolve152(null));
25451
+ child.on("error", () => resolve162(null));
25452
25452
  });
25453
25453
  }
25454
25454
  async function detectCLIs(providerLoader, options) {
@@ -27576,7 +27576,8 @@ function buildIdeWorkspaceSession(state, cdpManagers, options) {
27576
27576
  },
27577
27577
  errorMessage: state.errorMessage,
27578
27578
  errorReason: state.errorReason,
27579
- lastUpdated: state.lastUpdated
27579
+ lastUpdated: state.lastUpdated,
27580
+ settings: state.settings
27580
27581
  };
27581
27582
  }
27582
27583
  function buildExtensionAgentSession(parent, ext, options) {
@@ -27611,7 +27612,8 @@ function buildExtensionAgentSession(parent, ext, options) {
27611
27612
  },
27612
27613
  errorMessage: ext.errorMessage,
27613
27614
  errorReason: ext.errorReason,
27614
- lastUpdated: ext.lastUpdated
27615
+ lastUpdated: ext.lastUpdated,
27616
+ settings: ext.settings
27615
27617
  };
27616
27618
  }
27617
27619
  function shouldIncludeExtensionSession(ext) {
@@ -27677,7 +27679,8 @@ function buildCliSession(state, options) {
27677
27679
  },
27678
27680
  errorMessage: state.errorMessage,
27679
27681
  errorReason: state.errorReason,
27680
- lastUpdated: state.lastUpdated
27682
+ lastUpdated: state.lastUpdated,
27683
+ settings: state.settings
27681
27684
  };
27682
27685
  }
27683
27686
  function buildAcpSession(state, options) {
@@ -27711,7 +27714,8 @@ function buildAcpSession(state, options) {
27711
27714
  },
27712
27715
  errorMessage: state.errorMessage,
27713
27716
  errorReason: state.errorReason,
27714
- lastUpdated: state.lastUpdated
27717
+ lastUpdated: state.lastUpdated,
27718
+ settings: state.settings
27715
27719
  };
27716
27720
  }
27717
27721
  function buildSessionEntries(allStates, cdpManagers, options = {}) {
@@ -28048,6 +28052,8 @@ function getSendChatInputEnvelope(args) {
28048
28052
  function getHistorySessionId(h, args) {
28049
28053
  const explicit = typeof args?.historySessionId === "string" ? args.historySessionId.trim() : "";
28050
28054
  if (explicit) return explicit;
28055
+ const explicitProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : "";
28056
+ if (explicitProviderSessionId) return explicitProviderSessionId;
28051
28057
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
28052
28058
  if (!targetSessionId) return void 0;
28053
28059
  const instance = h.ctx.instanceManager?.getInstance(targetSessionId);
@@ -28506,7 +28512,7 @@ function getCliVisibleTranscriptCount(adapter) {
28506
28512
  async function getStableExtensionBaseline(h) {
28507
28513
  const first = await readExtensionChatState(h);
28508
28514
  if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
28509
- await new Promise((resolve152) => setTimeout(resolve152, 150));
28515
+ await new Promise((resolve162) => setTimeout(resolve162, 150));
28510
28516
  const second = await readExtensionChatState(h);
28511
28517
  return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
28512
28518
  }
@@ -28514,7 +28520,7 @@ async function verifyExtensionSendObserved(h, before) {
28514
28520
  const beforeCount = getStateMessageCount(before);
28515
28521
  const beforeSignature = getStateLastSignature(before);
28516
28522
  for (let attempt = 0; attempt < 12; attempt += 1) {
28517
- await new Promise((resolve152) => setTimeout(resolve152, 250));
28523
+ await new Promise((resolve162) => setTimeout(resolve162, 250));
28518
28524
  const state = await readExtensionChatState(h);
28519
28525
  if (state?.status === "waiting_approval") return true;
28520
28526
  const afterCount = getStateMessageCount(state);
@@ -28604,7 +28610,32 @@ async function handleReadChat(h, args) {
28604
28610
  ...coverage ? { coverage } : {}
28605
28611
  }, args);
28606
28612
  }
28607
- return { success: false, error: `${transport} adapter not found` };
28613
+ const historyLimit = normalizeReadChatTailLimit(args);
28614
+ try {
28615
+ const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
28616
+ const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
28617
+ const history = readProviderChatHistory(agentStr, {
28618
+ canonicalHistory: provider?.canonicalHistory,
28619
+ historySessionId,
28620
+ workspace,
28621
+ offset: 0,
28622
+ limit: historyLimit,
28623
+ excludeRecentCount: 0,
28624
+ historyBehavior: provider?.historyBehavior,
28625
+ scripts: provider?.scripts
28626
+ });
28627
+ const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : historySessionId;
28628
+ return buildReadChatCommandResult({
28629
+ messages: Array.isArray(history?.messages) ? history.messages : [],
28630
+ status: "idle",
28631
+ ...typeof history?.title === "string" ? { title: history.title } : {},
28632
+ ...historyProviderSessionId ? { providerSessionId: historyProviderSessionId } : {},
28633
+ ...provider?.historyBehavior?.transcriptAuthority === "provider" || provider?.historyBehavior?.transcriptAuthority === "daemon" ? { transcriptAuthority: (provider?.historyBehavior).transcriptAuthority } : {},
28634
+ coverage: "tail"
28635
+ }, args);
28636
+ } catch (error48) {
28637
+ return { success: false, error: error48?.message || `${transport} adapter not found` };
28638
+ }
28608
28639
  }
28609
28640
  if (isExtensionTransport(transport)) {
28610
28641
  let extensionReadChatError = "";
@@ -30072,7 +30103,7 @@ async function executeProviderScript(h, args, scriptName) {
30072
30103
  const enterCount = cliCommand.enterCount || 1;
30073
30104
  await adapter.writeRaw(cliCommand.text + "\r");
30074
30105
  for (let i = 1; i < enterCount; i += 1) {
30075
- await new Promise((resolve152) => setTimeout(resolve152, 50));
30106
+ await new Promise((resolve162) => setTimeout(resolve162, 50));
30076
30107
  await adapter.writeRaw("\r");
30077
30108
  }
30078
30109
  }
@@ -30452,7 +30483,7 @@ async function waitForCliAdapterReady(adapter, options) {
30452
30483
  if (status === "stopped") {
30453
30484
  throw new Error("CLI runtime stopped before it became ready");
30454
30485
  }
30455
- await new Promise((resolve152) => setTimeout(resolve152, pollMs));
30486
+ await new Promise((resolve162) => setTimeout(resolve162, pollMs));
30456
30487
  }
30457
30488
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
30458
30489
  }
@@ -31012,17 +31043,17 @@ async function findFreePort(ports) {
31012
31043
  throw new Error("No free port found");
31013
31044
  }
31014
31045
  function checkPortFree(port) {
31015
- return new Promise((resolve152) => {
31046
+ return new Promise((resolve162) => {
31016
31047
  const server = net2.createServer();
31017
31048
  server.unref();
31018
- server.on("error", () => resolve152(false));
31049
+ server.on("error", () => resolve162(false));
31019
31050
  server.listen(port, "127.0.0.1", () => {
31020
- server.close(() => resolve152(true));
31051
+ server.close(() => resolve162(true));
31021
31052
  });
31022
31053
  });
31023
31054
  }
31024
31055
  async function isCdpActive(port) {
31025
- return new Promise((resolve152) => {
31056
+ return new Promise((resolve162) => {
31026
31057
  const req = __require2("http").get(`http://127.0.0.1:${port}/json/version`, {
31027
31058
  timeout: 2e3
31028
31059
  }, (res) => {
@@ -31031,16 +31062,16 @@ async function isCdpActive(port) {
31031
31062
  res.on("end", () => {
31032
31063
  try {
31033
31064
  const info = JSON.parse(data);
31034
- resolve152(!!info["WebKit-Version"] || !!info["Browser"]);
31065
+ resolve162(!!info["WebKit-Version"] || !!info["Browser"]);
31035
31066
  } catch {
31036
- resolve152(false);
31067
+ resolve162(false);
31037
31068
  }
31038
31069
  });
31039
31070
  });
31040
- req.on("error", () => resolve152(false));
31071
+ req.on("error", () => resolve162(false));
31041
31072
  req.on("timeout", () => {
31042
31073
  req.destroy();
31043
- resolve152(false);
31074
+ resolve162(false);
31044
31075
  });
31045
31076
  });
31046
31077
  }
@@ -31494,11 +31525,23 @@ function resolveMeshCoordinatorSetup(options) {
31494
31525
  if (!path26) {
31495
31526
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
31496
31527
  }
31528
+ const mcpServer = resolveAdhdevMcpServerLaunch({
31529
+ meshId,
31530
+ nodeExecutable: options.nodeExecutable,
31531
+ adhdevMcpEntryPath: options.adhdevMcpEntryPath
31532
+ });
31533
+ if (!mcpServer) {
31534
+ return {
31535
+ kind: "unsupported",
31536
+ reason: "Could not resolve the ADHDev MCP server entrypoint without relying on a PATH bin shim"
31537
+ };
31538
+ }
31497
31539
  return {
31498
31540
  kind: "auto_import",
31499
31541
  serverName,
31500
31542
  configPath: (0, import_path4.join)(workspace, path26),
31501
- configFormat: mcpConfig.format
31543
+ configFormat: mcpConfig.format,
31544
+ mcpServer
31502
31545
  };
31503
31546
  }
31504
31547
  if (mcpConfig.mode === "manual") {
@@ -31530,6 +31573,53 @@ function resolveMeshCoordinatorSetup(options) {
31530
31573
  function renderMeshCoordinatorTemplate(template, values) {
31531
31574
  return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_, key) => values[key] || "");
31532
31575
  }
31576
+ function resolveAdhdevMcpServerLaunch(options) {
31577
+ const entryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath);
31578
+ if (!entryPath) return null;
31579
+ return {
31580
+ command: options.nodeExecutable?.trim() || process.execPath,
31581
+ args: [entryPath, "--repo-mesh", options.meshId]
31582
+ };
31583
+ }
31584
+ function resolveAdhdevMcpEntryPath(explicitPath) {
31585
+ const explicit = explicitPath?.trim();
31586
+ if (explicit) return normalizeExistingPath(explicit) || explicit;
31587
+ const envPath = process.env.ADHDEV_MCP_SERVER_PATH?.trim();
31588
+ if (envPath) return normalizeExistingPath(envPath) || envPath;
31589
+ const candidates = [];
31590
+ const addCandidate = (candidate) => {
31591
+ if (!candidates.includes(candidate)) candidates.push(candidate);
31592
+ };
31593
+ const addPackagedCandidates = (baseFile) => {
31594
+ if (!baseFile) return;
31595
+ const realBase = normalizeExistingPath(baseFile) || baseFile;
31596
+ const dir = (0, import_path4.dirname)(realBase);
31597
+ addCandidate((0, import_path4.resolve)(dir, "../vendor/mcp-server/index.js"));
31598
+ addCandidate((0, import_path4.resolve)(dir, "../../vendor/mcp-server/index.js"));
31599
+ addCandidate((0, import_path4.resolve)(dir, "../../../vendor/mcp-server/index.js"));
31600
+ };
31601
+ addPackagedCandidates(process.argv[1]);
31602
+ for (const candidate of candidates) {
31603
+ const normalized = normalizeExistingPath(candidate);
31604
+ if (normalized) return normalized;
31605
+ }
31606
+ try {
31607
+ const requireBase = process.argv[1] ? normalizeExistingPath(process.argv[1]) || process.argv[1] : (0, import_path4.join)(process.cwd(), "adhdev-daemon.js");
31608
+ const req = (0, import_module2.createRequire)(requireBase);
31609
+ const resolvedModule = req.resolve("@adhdev/mcp-server");
31610
+ return normalizeExistingPath(resolvedModule) || resolvedModule;
31611
+ } catch {
31612
+ return null;
31613
+ }
31614
+ }
31615
+ function normalizeExistingPath(filePath) {
31616
+ try {
31617
+ if (!(0, import_fs8.existsSync)(filePath)) return null;
31618
+ return import_fs8.realpathSync.native(filePath);
31619
+ } catch {
31620
+ return null;
31621
+ }
31622
+ }
31533
31623
  function buildRecentReadDebugSignature(snapshot) {
31534
31624
  return [
31535
31625
  snapshot.providerType,
@@ -32021,7 +32111,7 @@ async function waitForPidExit(pid, timeoutMs) {
32021
32111
  while (Date.now() - start < timeoutMs) {
32022
32112
  try {
32023
32113
  process.kill(pid, 0);
32024
- await new Promise((resolve152) => setTimeout(resolve152, 250));
32114
+ await new Promise((resolve162) => setTimeout(resolve162, 250));
32025
32115
  } catch {
32026
32116
  return;
32027
32117
  }
@@ -32132,7 +32222,7 @@ async function runDaemonUpgradeHelper(payload) {
32132
32222
  appendUpgradeLog(installOutput.trim());
32133
32223
  }
32134
32224
  if (process.platform === "win32") {
32135
- await new Promise((resolve152) => setTimeout(resolve152, 500));
32225
+ await new Promise((resolve162) => setTimeout(resolve162, 500));
32136
32226
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
32137
32227
  appendUpgradeLog("Post-install staging cleanup complete");
32138
32228
  }
@@ -34088,7 +34178,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
34088
34178
  return { target, instance, adapter };
34089
34179
  }
34090
34180
  function sleep(ms) {
34091
- return new Promise((resolve152) => setTimeout(resolve152, ms));
34181
+ return new Promise((resolve162) => setTimeout(resolve162, ms));
34092
34182
  }
34093
34183
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
34094
34184
  const startedAt = Date.now();
@@ -36242,7 +36332,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
36242
36332
  const deadline = Date.now() + timeoutMs;
36243
36333
  while (Date.now() < deadline) {
36244
36334
  if (await canConnect(endpoint)) return;
36245
- await new Promise((resolve152) => setTimeout(resolve152, STARTUP_POLL_MS));
36335
+ await new Promise((resolve162) => setTimeout(resolve162, STARTUP_POLL_MS));
36246
36336
  }
36247
36337
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
36248
36338
  }
@@ -36329,10 +36419,10 @@ async function installExtension(ide, extension) {
36329
36419
  const buffer = Buffer.from(await res.arrayBuffer());
36330
36420
  const fs16 = await import("fs");
36331
36421
  fs16.writeFileSync(vsixPath, buffer);
36332
- return new Promise((resolve152) => {
36422
+ return new Promise((resolve162) => {
36333
36423
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
36334
36424
  (0, import_child_process12.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
36335
- resolve152({
36425
+ resolve162({
36336
36426
  extensionId: extension.id,
36337
36427
  marketplaceId: extension.marketplaceId,
36338
36428
  success: !error48,
@@ -36345,11 +36435,11 @@ async function installExtension(ide, extension) {
36345
36435
  } catch (e) {
36346
36436
  }
36347
36437
  }
36348
- return new Promise((resolve152) => {
36438
+ return new Promise((resolve162) => {
36349
36439
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
36350
36440
  (0, import_child_process12.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
36351
36441
  if (error48) {
36352
- resolve152({
36442
+ resolve162({
36353
36443
  extensionId: extension.id,
36354
36444
  marketplaceId: extension.marketplaceId,
36355
36445
  success: false,
@@ -36357,7 +36447,7 @@ async function installExtension(ide, extension) {
36357
36447
  error: stderr || error48.message
36358
36448
  });
36359
36449
  } else {
36360
- resolve152({
36450
+ resolve162({
36361
36451
  extensionId: extension.id,
36362
36452
  marketplaceId: extension.marketplaceId,
36363
36453
  success: true,
@@ -36390,6 +36480,42 @@ function launchIDE(ide, workspacePath) {
36390
36480
  return false;
36391
36481
  }
36392
36482
  }
36483
+ function setupMeshEventForwarding(components) {
36484
+ components.instanceManager.onEvent((event) => {
36485
+ if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
36486
+ const instanceId = event.instanceId;
36487
+ if (!instanceId) return;
36488
+ const sourceInstance = components.instanceManager.getInstance(instanceId);
36489
+ if (!sourceInstance || sourceInstance.category !== "cli") return;
36490
+ const state = sourceInstance.getState();
36491
+ const workspace = state.workspace;
36492
+ if (!workspace) return;
36493
+ const mesh = getMeshByRepo(workspace);
36494
+ if (!mesh) return;
36495
+ const allInstances = components.instanceManager.getByCategory("cli");
36496
+ const coordinatorInstances = allInstances.filter((inst) => {
36497
+ const instState = inst.getState();
36498
+ if (instState.settings?.meshCoordinatorFor !== mesh.id) return false;
36499
+ if (instState.instanceId === instanceId) return false;
36500
+ return true;
36501
+ });
36502
+ if (coordinatorInstances.length === 0) return;
36503
+ const targetNode = mesh.nodes.find((n) => n.workspace === workspace);
36504
+ const nodeLabel = targetNode ? `Node '${targetNode.id}'` : `Agent at ${workspace}`;
36505
+ let messageText = "";
36506
+ if (event.event === "agent:generating_completed") {
36507
+ messageText = `[System] ${nodeLabel} has completed its task and is now idle. You may use mesh_read_chat to review its progress.`;
36508
+ } else if (event.event === "agent:waiting_approval") {
36509
+ messageText = `[System] ${nodeLabel} is waiting for approval to proceed. You may use mesh_read_chat and mesh_approve to handle it.`;
36510
+ }
36511
+ if (!messageText) return;
36512
+ for (const coord of coordinatorInstances) {
36513
+ const coordState = coord.getState();
36514
+ LOG.info("MeshEvents", `Forwarding event from ${workspace} to coordinator ${coordState.instanceId}`);
36515
+ coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
36516
+ }
36517
+ });
36518
+ }
36393
36519
  async function initDaemonComponents(config2) {
36394
36520
  installGlobalInterceptor();
36395
36521
  const appConfig = loadConfig();
@@ -36547,7 +36673,7 @@ async function initDaemonComponents(config2) {
36547
36673
  });
36548
36674
  poller.start();
36549
36675
  instanceManager.startTicking(config2.tickIntervalMs ?? 5e3);
36550
- return {
36676
+ const components = {
36551
36677
  providerLoader,
36552
36678
  instanceManager,
36553
36679
  cliManager,
@@ -36561,6 +36687,8 @@ async function initDaemonComponents(config2) {
36561
36687
  detectedIdes: detectedIdesRef,
36562
36688
  refreshProviderAvailability
36563
36689
  };
36690
+ setupMeshEventForwarding(components);
36691
+ return components;
36564
36692
  }
36565
36693
  async function startDaemonDevSupport(options) {
36566
36694
  const devServer = new DevServer({
@@ -36615,7 +36743,7 @@ async function shutdownDaemonComponents(components) {
36615
36743
  }
36616
36744
  cdpManagers.clear();
36617
36745
  }
36618
- var import_os, import_path, import_fs, import_crypto2, import_fs2, import_path2, import_crypto3, fs2, path9, os4, os8, os9, path13, import_child_process, os10, path14, os11, import_child_process2, import_fs3, import_promises4, path, import_util3, import_promises5, path22, path32, fs, os5, path4, import_crypto4, path5, path6, import_fs4, import_path3, import_child_process3, import_fs5, import_os2, path7, import_child_process4, os22, path8, import_fs6, os32, import_child_process5, http, crypto2, fs3, path10, os52, fs4, os6, path11, import_crypto5, fs5, path12, os7, os13, path16, crypto4, import_fs7, import_child_process6, os12, path15, crypto3, fs6, import_module, import_stream2, import_child_process7, import_child_process8, net2, os15, path18, fs7, path17, os14, fs8, path19, os16, import_path4, os17, import_child_process9, import_child_process10, fs9, os18, path20, fs10, fs11, path21, os19, import_child_process11, import_os3, http2, fs15, path25, fs12, path222, fs13, path23, fs14, path24, os20, import_child_process12, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __hasOwnProp2, __require2, __esm2, __export2, __copyProps2, __toCommonJS, DEFAULT_MESH_POLICY, init_repo_mesh_types, config_exports, DEFAULT_CONFIG, MACHINE_ID_PREFIX, init_config, mesh_config_exports, init_mesh_config, coordinator_prompt_exports, TOOLS_SECTION, WORKFLOW_SECTION, RULES_SECTION, init_coordinator_prompt, LEVEL_NUM, LEVEL_LABEL, currentLevel, LOG_DIR, MAX_LOG_SIZE, MAX_LOG_DAYS, currentDate, currentLogFile, writeCount, RING_BUFFER_SIZE, ringBuffer, origConsoleLog, origConsoleError, origConsoleWarn, LOG, interceptorInstalled, LOG_PATH, init_logger, NORMAL_TRACE_BUFFER_SIZE, DEV_TRACE_BUFFER_SIZE, DEFAULT_CONFIG2, currentConfig, init_debug_config, DEFAULT_BINDING_CANDIDATES, cachedBinding, cachedBindingError, GhosttyVtTerminalBackend, init_ghostty_vt_backend, TerminalCtor, XtermTerminalBackend, init_xterm_backend, DEFAULT_SCROLLBACK, loggedTerminalBackends, TerminalScreen, init_terminal_screen, init_spawn_env, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory, init_pty_transport, buildCliSpawnEnv, init_provider_cli_shared, init_provider_cli_parse, init_provider_cli_config, init_provider_cli_runtime, provider_cli_adapter_exports, ProviderCliAdapter, init_provider_cli_adapter, execFileAsync, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_BUFFER, GitCommandError, DEFAULT_MAX_FILES, DEFAULT_MAX_BYTES, summarizeGitStatus, InMemoryGitSnapshotStore, DEFAULT_GIT_WORKSPACE_POLL_INTERVAL_MS, MIN_GIT_WORKSPACE_POLL_INTERVAL_MS, GitWorkspaceMonitor, GIT_COMMAND_NAMES, SNAPSHOT_REASONS, FAILURE_REASONS, defaultSnapshotStore, defaultGitCommandServices, BUSY_STATUSES, TERMINAL_STATUSES, TurnSnapshotTracker, MAX_WORKSPACES, MAX_ACTIVITY, MAX_SAVED_SESSIONS, DEFAULT_STATE, BUILTIN_IDE_DEFINITIONS, registeredIDEs, LIVE_LIFECYCLES, DEFAULT_ACTIVE_CHAT_POLL_STATUSES, DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS, LIVE_RUNTIME_LIFECYCLES, DaemonCdpManager, CdpDomHandlers, DEFAULT_MONITOR_CONFIG, StatusMonitor, BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES, HISTORY_DIR, RETAIN_DAYS, SAVED_HISTORY_INDEX_VERSION, SAVED_HISTORY_INDEX_FILE, SAVED_HISTORY_INDEX_LOCK_SUFFIX, SAVED_HISTORY_INDEX_LOCK_WAIT_MS, SAVED_HISTORY_INDEX_LOCK_STALE_MS, SAVED_HISTORY_INDEX_LOCK_POLL_MS, SAVED_HISTORY_ROLLUP_THRESHOLD_BYTES, savedHistorySessionCache, savedHistoryFileSummaryCache, savedHistoryBackgroundRefresh, savedHistoryRollupInFlight, ChatHistoryWriter, IDE_PROVIDER_SESSION_CAPABILITIES_BASE, EXTENSION_PROVIDER_SESSION_CAPABILITIES_BASE, ExtensionProviderInstance, VALID_STATUSES, VALID_ROLES, VALID_BUBBLE_STATES, VALID_TURN_STATUSES, DEFAULT_APPROVAL_POSITIVE_HINTS, IdeProviderInstance, DEFAULT_CDP_SCAN_INTERVAL_MS, DEFAULT_CDP_DISCOVERY_INTERVAL_MS, DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS, DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS, DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS, MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_READY_TIMEOUT_MS, STANDALONE_CDP_SCAN_INTERVAL_MS, DaemonCdpScanner, DaemonCdpInitializer, WORKING_STATUSES, FULL_STATUS_ACTIVE_CHAT_OPTIONS, LIVE_STATUS_ACTIVE_CHAT_OPTIONS, STATUS_MODAL_MESSAGE_LIMIT, STATUS_MODAL_BUTTON_LIMIT, IDE_SESSION_CAPABILITIES, EXTENSION_SESSION_CAPABILITIES, PTY_SESSION_CAPABILITIES, CLI_CHAT_SESSION_CAPABILITIES, ACP_SESSION_CAPABILITIES, VALID_INPUT_MEDIA_TYPES, globalStore, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN, KEY_TO_VK, COMMAND_DEBUG_LEVELS, DaemonCommandHandler, CachedDatabaseSync, CliProviderInstance, AcpProviderInstance, chalkModule, chalkApi, DaemonCliManager, VALID_CAPABILITY_MEDIA_TYPES, KNOWN_PROVIDER_FIELDS, VALUE_CONTROL_TYPES, ProviderLoader, _providerLoader, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession, UPGRADE_HELPER_ENV, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter, DaemonStatusReporter, DEFAULT_DAEMON_PORT, DAEMON_WS_PATH, ProviderStreamAdapter, DaemonAgentStreamManager, AgentStreamPoller, ProviderInstanceManager, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive, DEV_SERVER_PORT, DevServer, SessionHostRuntimeTransport, SessionHostPtyTransportFactory, DEFAULT_SESSION_HOST_APP_NAME, DEFAULT_STANDALONE_SESSION_HOST_APP_NAME, STARTUP_TIMEOUT_MS, STARTUP_POLL_MS, EXTENSION_CATALOG, SessionRegistry;
36746
+ var import_os, import_path, import_fs, import_crypto2, import_fs2, import_path2, import_crypto3, fs2, path9, os4, os8, os9, path13, import_child_process, os10, path14, os11, import_child_process2, import_fs3, import_promises4, path, import_util3, import_promises5, path22, path32, fs, os5, path4, import_crypto4, path5, path6, import_fs4, import_path3, import_child_process3, import_fs5, import_os2, path7, import_child_process4, os22, path8, import_fs6, os32, import_child_process5, http, crypto2, fs3, path10, os52, fs4, os6, path11, import_crypto5, fs5, path12, os7, os13, path16, crypto4, import_fs7, import_child_process6, os12, path15, crypto3, fs6, import_module, import_stream2, import_child_process7, import_child_process8, net2, os15, path18, fs7, path17, os14, fs8, path19, os16, import_fs8, import_module2, import_path4, os17, import_child_process9, import_child_process10, fs9, os18, path20, fs10, fs11, path21, os19, import_child_process11, import_os3, http2, fs15, path25, fs12, path222, fs13, path23, fs14, path24, os20, import_child_process12, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __hasOwnProp2, __require2, __esm2, __export2, __copyProps2, __toCommonJS, DEFAULT_MESH_POLICY, init_repo_mesh_types, config_exports, DEFAULT_CONFIG, MACHINE_ID_PREFIX, init_config, mesh_config_exports, init_mesh_config, coordinator_prompt_exports, TOOLS_SECTION, WORKFLOW_SECTION, RULES_SECTION, init_coordinator_prompt, LEVEL_NUM, LEVEL_LABEL, currentLevel, LOG_DIR, MAX_LOG_SIZE, MAX_LOG_DAYS, currentDate, currentLogFile, writeCount, RING_BUFFER_SIZE, ringBuffer, origConsoleLog, origConsoleError, origConsoleWarn, LOG, interceptorInstalled, LOG_PATH, init_logger, NORMAL_TRACE_BUFFER_SIZE, DEV_TRACE_BUFFER_SIZE, DEFAULT_CONFIG2, currentConfig, init_debug_config, DEFAULT_BINDING_CANDIDATES, cachedBinding, cachedBindingError, GhosttyVtTerminalBackend, init_ghostty_vt_backend, TerminalCtor, XtermTerminalBackend, init_xterm_backend, DEFAULT_SCROLLBACK, loggedTerminalBackends, TerminalScreen, init_terminal_screen, init_spawn_env, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory, init_pty_transport, buildCliSpawnEnv, init_provider_cli_shared, init_provider_cli_parse, init_provider_cli_config, init_provider_cli_runtime, provider_cli_adapter_exports, ProviderCliAdapter, init_provider_cli_adapter, execFileAsync, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_BUFFER, GitCommandError, DEFAULT_MAX_FILES, DEFAULT_MAX_BYTES, summarizeGitStatus, InMemoryGitSnapshotStore, DEFAULT_GIT_WORKSPACE_POLL_INTERVAL_MS, MIN_GIT_WORKSPACE_POLL_INTERVAL_MS, GitWorkspaceMonitor, GIT_COMMAND_NAMES, SNAPSHOT_REASONS, FAILURE_REASONS, defaultSnapshotStore, defaultGitCommandServices, BUSY_STATUSES, TERMINAL_STATUSES, TurnSnapshotTracker, MAX_WORKSPACES, MAX_ACTIVITY, MAX_SAVED_SESSIONS, DEFAULT_STATE, BUILTIN_IDE_DEFINITIONS, registeredIDEs, LIVE_LIFECYCLES, DEFAULT_ACTIVE_CHAT_POLL_STATUSES, DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS, LIVE_RUNTIME_LIFECYCLES, DaemonCdpManager, CdpDomHandlers, DEFAULT_MONITOR_CONFIG, StatusMonitor, BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES, HISTORY_DIR, RETAIN_DAYS, SAVED_HISTORY_INDEX_VERSION, SAVED_HISTORY_INDEX_FILE, SAVED_HISTORY_INDEX_LOCK_SUFFIX, SAVED_HISTORY_INDEX_LOCK_WAIT_MS, SAVED_HISTORY_INDEX_LOCK_STALE_MS, SAVED_HISTORY_INDEX_LOCK_POLL_MS, SAVED_HISTORY_ROLLUP_THRESHOLD_BYTES, savedHistorySessionCache, savedHistoryFileSummaryCache, savedHistoryBackgroundRefresh, savedHistoryRollupInFlight, ChatHistoryWriter, IDE_PROVIDER_SESSION_CAPABILITIES_BASE, EXTENSION_PROVIDER_SESSION_CAPABILITIES_BASE, ExtensionProviderInstance, VALID_STATUSES, VALID_ROLES, VALID_BUBBLE_STATES, VALID_TURN_STATUSES, DEFAULT_APPROVAL_POSITIVE_HINTS, IdeProviderInstance, DEFAULT_CDP_SCAN_INTERVAL_MS, DEFAULT_CDP_DISCOVERY_INTERVAL_MS, DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS, DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS, DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS, MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_READY_TIMEOUT_MS, STANDALONE_CDP_SCAN_INTERVAL_MS, DaemonCdpScanner, DaemonCdpInitializer, WORKING_STATUSES, FULL_STATUS_ACTIVE_CHAT_OPTIONS, LIVE_STATUS_ACTIVE_CHAT_OPTIONS, STATUS_MODAL_MESSAGE_LIMIT, STATUS_MODAL_BUTTON_LIMIT, IDE_SESSION_CAPABILITIES, EXTENSION_SESSION_CAPABILITIES, PTY_SESSION_CAPABILITIES, CLI_CHAT_SESSION_CAPABILITIES, ACP_SESSION_CAPABILITIES, VALID_INPUT_MEDIA_TYPES, globalStore, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN, KEY_TO_VK, COMMAND_DEBUG_LEVELS, DaemonCommandHandler, CachedDatabaseSync, CliProviderInstance, AcpProviderInstance, chalkModule, chalkApi, DaemonCliManager, VALID_CAPABILITY_MEDIA_TYPES, KNOWN_PROVIDER_FIELDS, VALUE_CONTROL_TYPES, ProviderLoader, _providerLoader, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession, UPGRADE_HELPER_ENV, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter, DaemonStatusReporter, DEFAULT_DAEMON_PORT, DAEMON_WS_PATH, ProviderStreamAdapter, DaemonAgentStreamManager, AgentStreamPoller, ProviderInstanceManager, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive, DEV_SERVER_PORT, DevServer, SessionHostRuntimeTransport, SessionHostPtyTransportFactory, DEFAULT_SESSION_HOST_APP_NAME, DEFAULT_STANDALONE_SESSION_HOST_APP_NAME, STARTUP_TIMEOUT_MS, STARTUP_POLL_MS, EXTENSION_CATALOG, SessionRegistry;
36619
36747
  var init_dist2 = __esm({
36620
36748
  "../daemon-core/dist/index.mjs"() {
36621
36749
  "use strict";
@@ -36702,6 +36830,8 @@ var init_dist2 = __esm({
36702
36830
  fs8 = __toESM(require("fs"), 1);
36703
36831
  path19 = __toESM(require("path"), 1);
36704
36832
  os16 = __toESM(require("os"), 1);
36833
+ import_fs8 = require("fs");
36834
+ import_module2 = require("module");
36705
36835
  import_path4 = require("path");
36706
36836
  os17 = __toESM(require("os"), 1);
36707
36837
  import_child_process9 = require("child_process");
@@ -37819,7 +37949,7 @@ var init_dist2 = __esm({
37819
37949
  `[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
37820
37950
  );
37821
37951
  }
37822
- await new Promise((resolve152) => setTimeout(resolve152, 50));
37952
+ await new Promise((resolve162) => setTimeout(resolve162, 50));
37823
37953
  }
37824
37954
  const finalScreenText = this.terminalScreen.getText() || "";
37825
37955
  LOG.warn(
@@ -38729,7 +38859,7 @@ var init_dist2 = __esm({
38729
38859
  const deadline = Date.now() + 1e4;
38730
38860
  while (this.startupParseGate && Date.now() < deadline) {
38731
38861
  this.resolveStartupState("send_wait");
38732
- await new Promise((resolve152) => setTimeout(resolve152, 50));
38862
+ await new Promise((resolve162) => setTimeout(resolve162, 50));
38733
38863
  }
38734
38864
  }
38735
38865
  if (!allowInterventionPrompt) {
@@ -38805,13 +38935,13 @@ var init_dist2 = __esm({
38805
38935
  }
38806
38936
  this.responseEpoch += 1;
38807
38937
  this.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
38808
- await new Promise((resolve152, reject) => {
38938
+ await new Promise((resolve162, reject) => {
38809
38939
  let resolved = false;
38810
38940
  const completion = {
38811
38941
  resolveOnce: () => {
38812
38942
  if (resolved) return;
38813
38943
  resolved = true;
38814
- resolve152();
38944
+ resolve162();
38815
38945
  },
38816
38946
  rejectOnce: (error48) => {
38817
38947
  if (resolved) return;
@@ -38969,17 +39099,17 @@ var init_dist2 = __esm({
38969
39099
  }
38970
39100
  }
38971
39101
  waitForStopped(timeoutMs) {
38972
- return new Promise((resolve152) => {
39102
+ return new Promise((resolve162) => {
38973
39103
  const startedAt = Date.now();
38974
39104
  const timer = setInterval(() => {
38975
39105
  if (!this.ptyProcess || this.currentStatus === "stopped") {
38976
39106
  clearInterval(timer);
38977
- resolve152(true);
39107
+ resolve162(true);
38978
39108
  return;
38979
39109
  }
38980
39110
  if (Date.now() - startedAt >= timeoutMs) {
38981
39111
  clearInterval(timer);
38982
- resolve152(false);
39112
+ resolve162(false);
38983
39113
  }
38984
39114
  }, 100);
38985
39115
  });
@@ -39122,11 +39252,22 @@ var init_dist2 = __esm({
39122
39252
  }
39123
39253
  }
39124
39254
  }
39255
+ getParsedDebugState() {
39256
+ if (this.startupParseGate || typeof this.cliScripts?.parseSession !== "function") return null;
39257
+ try {
39258
+ const parsed = this.getScriptParsedStatus();
39259
+ return parsed && typeof parsed === "object" ? parsed : null;
39260
+ } catch {
39261
+ return null;
39262
+ }
39263
+ }
39125
39264
  getDebugState() {
39126
39265
  const screenText = sanitizeTerminalText(this.terminalScreen.getText());
39127
39266
  const startupModal = this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
39128
39267
  const effectiveStatus = this.projectEffectiveStatus(startupModal);
39129
39268
  const effectiveReady = this.ready || !!startupModal;
39269
+ const parsedDebugState = this.getParsedDebugState();
39270
+ const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
39130
39271
  return {
39131
39272
  type: this.cliType,
39132
39273
  name: this.cliName,
@@ -39139,8 +39280,18 @@ var init_dist2 = __esm({
39139
39280
  startupParseGate: this.startupParseGate,
39140
39281
  spawnAt: this.spawnAt,
39141
39282
  workingDir: this.workingDir,
39142
- messages: [],
39143
- messageCount: 0,
39283
+ messages: parsedMessages,
39284
+ messageCount: parsedMessages.length,
39285
+ parsedStatus: parsedDebugState ? {
39286
+ id: parsedDebugState.id,
39287
+ status: parsedDebugState.status,
39288
+ title: parsedDebugState.title,
39289
+ providerSessionId: parsedDebugState.providerSessionId,
39290
+ transcriptAuthority: parsedDebugState.transcriptAuthority,
39291
+ coverage: parsedDebugState.coverage,
39292
+ activeModal: parsedDebugState.activeModal,
39293
+ messageCount: parsedMessages.length
39294
+ } : null,
39144
39295
  screenText: screenText.slice(-4e3),
39145
39296
  currentTurnScope: this.currentTurnScope,
39146
39297
  startupBuffer: this.startupBuffer.slice(-4e3),
@@ -39557,7 +39708,7 @@ var init_dist2 = __esm({
39557
39708
  * Returns multiple entries if multiple IDE windows are open on same port
39558
39709
  */
39559
39710
  static listAllTargets(port) {
39560
- return new Promise((resolve152) => {
39711
+ return new Promise((resolve162) => {
39561
39712
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
39562
39713
  let data = "";
39563
39714
  res.on("data", (chunk) => data += chunk.toString());
@@ -39573,16 +39724,16 @@ var init_dist2 = __esm({
39573
39724
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
39574
39725
  );
39575
39726
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
39576
- resolve152(mainPages.length > 0 ? mainPages : fallbackPages);
39727
+ resolve162(mainPages.length > 0 ? mainPages : fallbackPages);
39577
39728
  } catch {
39578
- resolve152([]);
39729
+ resolve162([]);
39579
39730
  }
39580
39731
  });
39581
39732
  });
39582
- req.on("error", () => resolve152([]));
39733
+ req.on("error", () => resolve162([]));
39583
39734
  req.setTimeout(2e3, () => {
39584
39735
  req.destroy();
39585
- resolve152([]);
39736
+ resolve162([]);
39586
39737
  });
39587
39738
  });
39588
39739
  }
@@ -39622,7 +39773,7 @@ var init_dist2 = __esm({
39622
39773
  }
39623
39774
  }
39624
39775
  findTargetOnPort(port) {
39625
- return new Promise((resolve152) => {
39776
+ return new Promise((resolve162) => {
39626
39777
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
39627
39778
  let data = "";
39628
39779
  res.on("data", (chunk) => data += chunk.toString());
@@ -39633,7 +39784,7 @@ var init_dist2 = __esm({
39633
39784
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
39634
39785
  );
39635
39786
  if (pages.length === 0) {
39636
- resolve152(targets.find((t) => t.webSocketDebuggerUrl) || null);
39787
+ resolve162(targets.find((t) => t.webSocketDebuggerUrl) || null);
39637
39788
  return;
39638
39789
  }
39639
39790
  const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -39652,25 +39803,25 @@ var init_dist2 = __esm({
39652
39803
  this._targetId = selected.target.id;
39653
39804
  }
39654
39805
  this._pageTitle = selected.target.title || "";
39655
- resolve152(selected.target);
39806
+ resolve162(selected.target);
39656
39807
  return;
39657
39808
  }
39658
39809
  if (previousTargetId) {
39659
39810
  this.log(`[CDP] Target ${previousTargetId} not found in page list`);
39660
- resolve152(null);
39811
+ resolve162(null);
39661
39812
  return;
39662
39813
  }
39663
39814
  this._pageTitle = list[0]?.title || "";
39664
- resolve152(list[0]);
39815
+ resolve162(list[0]);
39665
39816
  } catch {
39666
- resolve152(null);
39817
+ resolve162(null);
39667
39818
  }
39668
39819
  });
39669
39820
  });
39670
- req.on("error", () => resolve152(null));
39821
+ req.on("error", () => resolve162(null));
39671
39822
  req.setTimeout(2e3, () => {
39672
39823
  req.destroy();
39673
- resolve152(null);
39824
+ resolve162(null);
39674
39825
  });
39675
39826
  });
39676
39827
  }
@@ -39681,7 +39832,7 @@ var init_dist2 = __esm({
39681
39832
  this.extensionProviders = providers;
39682
39833
  }
39683
39834
  connectToTarget(wsUrl) {
39684
- return new Promise((resolve152) => {
39835
+ return new Promise((resolve162) => {
39685
39836
  this.ws = new wrapper_default(wsUrl);
39686
39837
  this.ws.on("open", async () => {
39687
39838
  this._connected = true;
@@ -39691,17 +39842,17 @@ var init_dist2 = __esm({
39691
39842
  }
39692
39843
  this.connectBrowserWs().catch(() => {
39693
39844
  });
39694
- resolve152(true);
39845
+ resolve162(true);
39695
39846
  });
39696
39847
  this.ws.on("message", (data) => {
39697
39848
  try {
39698
39849
  const msg = JSON.parse(data.toString());
39699
39850
  if (msg.id && this.pending.has(msg.id)) {
39700
- const { resolve: resolve162, reject } = this.pending.get(msg.id);
39851
+ const { resolve: resolve172, reject } = this.pending.get(msg.id);
39701
39852
  this.pending.delete(msg.id);
39702
39853
  this.failureCount = 0;
39703
39854
  if (msg.error) reject(new Error(msg.error.message));
39704
- else resolve162(msg.result);
39855
+ else resolve172(msg.result);
39705
39856
  } else if (msg.method === "Runtime.executionContextCreated") {
39706
39857
  this.contexts.add(msg.params.context.id);
39707
39858
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -39724,7 +39875,7 @@ var init_dist2 = __esm({
39724
39875
  this.ws.on("error", (err) => {
39725
39876
  this.log(`[CDP] WebSocket error: ${err.message}`);
39726
39877
  this._connected = false;
39727
- resolve152(false);
39878
+ resolve162(false);
39728
39879
  });
39729
39880
  });
39730
39881
  }
@@ -39738,7 +39889,7 @@ var init_dist2 = __esm({
39738
39889
  return;
39739
39890
  }
39740
39891
  this.log(`[CDP] Connecting browser WS for target discovery...`);
39741
- await new Promise((resolve152, reject) => {
39892
+ await new Promise((resolve162, reject) => {
39742
39893
  this.browserWs = new wrapper_default(browserWsUrl);
39743
39894
  this.browserWs.on("open", async () => {
39744
39895
  this._browserConnected = true;
@@ -39748,16 +39899,16 @@ var init_dist2 = __esm({
39748
39899
  } catch (e) {
39749
39900
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
39750
39901
  }
39751
- resolve152();
39902
+ resolve162();
39752
39903
  });
39753
39904
  this.browserWs.on("message", (data) => {
39754
39905
  try {
39755
39906
  const msg = JSON.parse(data.toString());
39756
39907
  if (msg.id && this.browserPending.has(msg.id)) {
39757
- const { resolve: resolve162, reject: reject2 } = this.browserPending.get(msg.id);
39908
+ const { resolve: resolve172, reject: reject2 } = this.browserPending.get(msg.id);
39758
39909
  this.browserPending.delete(msg.id);
39759
39910
  if (msg.error) reject2(new Error(msg.error.message));
39760
- else resolve162(msg.result);
39911
+ else resolve172(msg.result);
39761
39912
  }
39762
39913
  } catch {
39763
39914
  }
@@ -39777,31 +39928,31 @@ var init_dist2 = __esm({
39777
39928
  }
39778
39929
  }
39779
39930
  getBrowserWsUrl() {
39780
- return new Promise((resolve152) => {
39931
+ return new Promise((resolve162) => {
39781
39932
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
39782
39933
  let data = "";
39783
39934
  res.on("data", (chunk) => data += chunk.toString());
39784
39935
  res.on("end", () => {
39785
39936
  try {
39786
39937
  const info = JSON.parse(data);
39787
- resolve152(info.webSocketDebuggerUrl || null);
39938
+ resolve162(info.webSocketDebuggerUrl || null);
39788
39939
  } catch {
39789
- resolve152(null);
39940
+ resolve162(null);
39790
39941
  }
39791
39942
  });
39792
39943
  });
39793
- req.on("error", () => resolve152(null));
39944
+ req.on("error", () => resolve162(null));
39794
39945
  req.setTimeout(3e3, () => {
39795
39946
  req.destroy();
39796
- resolve152(null);
39947
+ resolve162(null);
39797
39948
  });
39798
39949
  });
39799
39950
  }
39800
39951
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
39801
- return new Promise((resolve152, reject) => {
39952
+ return new Promise((resolve162, reject) => {
39802
39953
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
39803
39954
  const id = this.browserMsgId++;
39804
- this.browserPending.set(id, { resolve: resolve152, reject });
39955
+ this.browserPending.set(id, { resolve: resolve162, reject });
39805
39956
  this.browserWs.send(JSON.stringify({ id, method, params }));
39806
39957
  setTimeout(() => {
39807
39958
  if (this.browserPending.has(id)) {
@@ -39841,11 +39992,11 @@ var init_dist2 = __esm({
39841
39992
  }
39842
39993
  // ─── CDP Protocol ────────────────────────────────────────
39843
39994
  sendInternal(method, params = {}, timeoutMs = 15e3) {
39844
- return new Promise((resolve152, reject) => {
39995
+ return new Promise((resolve162, reject) => {
39845
39996
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
39846
39997
  if (this.ws.readyState !== wrapper_default.OPEN) return reject(new Error("WebSocket not open"));
39847
39998
  const id = this.msgId++;
39848
- this.pending.set(id, { resolve: resolve152, reject });
39999
+ this.pending.set(id, { resolve: resolve162, reject });
39849
40000
  this.ws.send(JSON.stringify({ id, method, params }));
39850
40001
  setTimeout(() => {
39851
40002
  if (this.pending.has(id)) {
@@ -40094,7 +40245,7 @@ var init_dist2 = __esm({
40094
40245
  const browserWs = this.browserWs;
40095
40246
  let msgId = this.browserMsgId;
40096
40247
  const sendWs = (method, params = {}, sessionId) => {
40097
- return new Promise((resolve152, reject) => {
40248
+ return new Promise((resolve162, reject) => {
40098
40249
  const mid = msgId++;
40099
40250
  this.browserMsgId = msgId;
40100
40251
  const handler = (raw) => {
@@ -40103,7 +40254,7 @@ var init_dist2 = __esm({
40103
40254
  if (msg.id === mid) {
40104
40255
  browserWs.removeListener("message", handler);
40105
40256
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
40106
- else resolve152(msg.result);
40257
+ else resolve162(msg.result);
40107
40258
  }
40108
40259
  } catch {
40109
40260
  }
@@ -40304,14 +40455,14 @@ var init_dist2 = __esm({
40304
40455
  if (!ws || ws.readyState !== wrapper_default.OPEN) {
40305
40456
  throw new Error("CDP not connected");
40306
40457
  }
40307
- return new Promise((resolve152, reject) => {
40458
+ return new Promise((resolve162, reject) => {
40308
40459
  const id = getNextId();
40309
40460
  pendingMap.set(id, {
40310
40461
  resolve: (result) => {
40311
40462
  if (result?.result?.subtype === "error") {
40312
40463
  reject(new Error(result.result.description));
40313
40464
  } else {
40314
- resolve152(result?.result?.value);
40465
+ resolve162(result?.result?.value);
40315
40466
  }
40316
40467
  },
40317
40468
  reject
@@ -40343,10 +40494,10 @@ var init_dist2 = __esm({
40343
40494
  throw new Error("CDP not connected");
40344
40495
  }
40345
40496
  const sendViaSession = (method, params = {}) => {
40346
- return new Promise((resolve152, reject) => {
40497
+ return new Promise((resolve162, reject) => {
40347
40498
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
40348
40499
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
40349
- pendingMap.set(id, { resolve: resolve152, reject });
40500
+ pendingMap.set(id, { resolve: resolve162, reject });
40350
40501
  ws.send(JSON.stringify({ id, sessionId, method, params }));
40351
40502
  setTimeout(() => {
40352
40503
  if (pendingMap.has(id)) {
@@ -43084,7 +43235,7 @@ ${effect.notification.body || ""}`.trim();
43084
43235
  try {
43085
43236
  const http3 = await import("http");
43086
43237
  const postData = JSON.stringify(body);
43087
- const result = await new Promise((resolve152, reject) => {
43238
+ const result = await new Promise((resolve162, reject) => {
43088
43239
  const req = http3.request({
43089
43240
  hostname: "127.0.0.1",
43090
43241
  port: 19280,
@@ -43096,9 +43247,9 @@ ${effect.notification.body || ""}`.trim();
43096
43247
  res.on("data", (chunk) => data += chunk);
43097
43248
  res.on("end", () => {
43098
43249
  try {
43099
- resolve152(JSON.parse(data));
43250
+ resolve162(JSON.parse(data));
43100
43251
  } catch {
43101
- resolve152({ raw: data });
43252
+ resolve162({ raw: data });
43102
43253
  }
43103
43254
  });
43104
43255
  });
@@ -43116,15 +43267,15 @@ ${effect.notification.body || ""}`.trim();
43116
43267
  if (!providerType) return { success: false, error: "providerType required" };
43117
43268
  try {
43118
43269
  const http3 = await import("http");
43119
- const result = await new Promise((resolve152, reject) => {
43270
+ const result = await new Promise((resolve162, reject) => {
43120
43271
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
43121
43272
  let data = "";
43122
43273
  res.on("data", (chunk) => data += chunk);
43123
43274
  res.on("end", () => {
43124
43275
  try {
43125
- resolve152(JSON.parse(data));
43276
+ resolve162(JSON.parse(data));
43126
43277
  } catch {
43127
- resolve152({ raw: data });
43278
+ resolve162({ raw: data });
43128
43279
  }
43129
43280
  });
43130
43281
  }).on("error", reject);
@@ -43138,7 +43289,7 @@ ${effect.notification.body || ""}`.trim();
43138
43289
  try {
43139
43290
  const http3 = await import("http");
43140
43291
  const postData = JSON.stringify(args || {});
43141
- const result = await new Promise((resolve152, reject) => {
43292
+ const result = await new Promise((resolve162, reject) => {
43142
43293
  const req = http3.request({
43143
43294
  hostname: "127.0.0.1",
43144
43295
  port: 19280,
@@ -43150,9 +43301,9 @@ ${effect.notification.body || ""}`.trim();
43150
43301
  res.on("data", (chunk) => data += chunk);
43151
43302
  res.on("end", () => {
43152
43303
  try {
43153
- resolve152(JSON.parse(data));
43304
+ resolve162(JSON.parse(data));
43154
43305
  } catch {
43155
- resolve152({ raw: data });
43306
+ resolve162({ raw: data });
43156
43307
  }
43157
43308
  });
43158
43309
  });
@@ -43323,7 +43474,7 @@ ${effect.notification.body || ""}`.trim();
43323
43474
  this.errorMessage = void 0;
43324
43475
  this.errorReason = void 0;
43325
43476
  }
43326
- const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
43477
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
43327
43478
  const visibleStatus = parseErrorMessage ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
43328
43479
  const parsedProviderSessionId = normalizeProviderSessionId(
43329
43480
  this.provider,
@@ -43510,18 +43661,14 @@ ${effect.notification.body || ""}`.trim();
43510
43661
  const enterCount = cliCommand.enterCount || 1;
43511
43662
  await this.adapter.writeRaw(cliCommand.text + "\r");
43512
43663
  for (let i = 1; i < enterCount; i += 1) {
43513
- await new Promise((resolve152) => setTimeout(resolve152, 50));
43664
+ await new Promise((resolve162) => setTimeout(resolve162, 50));
43514
43665
  await this.adapter.writeRaw("\r");
43515
43666
  }
43516
43667
  }
43517
43668
  this.applyProviderResponse(parsed.payload, { phase: "immediate" });
43518
43669
  }
43519
- detectStatusTransition() {
43520
- const now = Date.now();
43521
- const adapterStatus = this.adapter.getStatus({ allowParse: false });
43522
- const parsedStatus = null;
43523
- const rawStatus = adapterStatus.status;
43524
- const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
43670
+ maybeAutoApproveStatus(adapterStatus, now = Date.now()) {
43671
+ const autoApproveActive = adapterStatus?.status === "waiting_approval" && this.shouldAutoApprove();
43525
43672
  if (autoApproveActive && !this.autoApproveBusy) {
43526
43673
  this.autoApproveBusy = true;
43527
43674
  if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
@@ -43529,12 +43676,21 @@ ${effect.notification.body || ""}`.trim();
43529
43676
  this.autoApproveBusy = false;
43530
43677
  this.autoApproveBusyTimer = null;
43531
43678
  }, 2e3);
43532
- const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(adapterStatus.activeModal?.buttons, this.provider);
43533
- this.recordAutoApproval(adapterStatus.activeModal?.message, buttonLabel, now);
43679
+ const modal = adapterStatus.activeModal;
43680
+ const { index: buttonIndex, label: buttonLabel } = pickApprovalButton(modal?.buttons, this.provider);
43681
+ this.recordAutoApproval(modal?.message, buttonLabel, now);
43534
43682
  setTimeout(() => {
43535
43683
  this.adapter.resolveModal(buttonIndex);
43536
43684
  }, 0);
43537
43685
  }
43686
+ return autoApproveActive;
43687
+ }
43688
+ detectStatusTransition() {
43689
+ const now = Date.now();
43690
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
43691
+ const parsedStatus = null;
43692
+ const rawStatus = adapterStatus.status;
43693
+ const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, now);
43538
43694
  const newStatus = autoApproveActive ? "generating" : rawStatus;
43539
43695
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
43540
43696
  const chatTitle = `${this.provider.name} \xB7 ${dirName}`;
@@ -44524,13 +44680,13 @@ ${effect.notification.body || ""}`.trim();
44524
44680
  }
44525
44681
  this.currentStatus = "waiting_approval";
44526
44682
  this.detectStatusTransition();
44527
- const approved = await new Promise((resolve152) => {
44528
- this.permissionResolvers.push(resolve152);
44683
+ const approved = await new Promise((resolve162) => {
44684
+ this.permissionResolvers.push(resolve162);
44529
44685
  setTimeout(() => {
44530
- const idx = this.permissionResolvers.indexOf(resolve152);
44686
+ const idx = this.permissionResolvers.indexOf(resolve162);
44531
44687
  if (idx >= 0) {
44532
44688
  this.permissionResolvers.splice(idx, 1);
44533
- resolve152(false);
44689
+ resolve162(false);
44534
44690
  }
44535
44691
  }, 3e5);
44536
44692
  });
@@ -45359,7 +45515,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
45359
45515
  resolvedDir,
45360
45516
  resolvedCliArgs,
45361
45517
  resolvedProvider,
45362
- this.providerLoader.getSettings(normalizedType),
45518
+ { ...this.providerLoader.getSettings(normalizedType), ...options?.settingsOverride || {} },
45363
45519
  false,
45364
45520
  {
45365
45521
  providerSessionId: sessionBinding.providerSessionId,
@@ -45613,7 +45769,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
45613
45769
  dir,
45614
45770
  args?.cliArgs,
45615
45771
  args?.initialModel,
45616
- { resumeSessionId: args?.resumeSessionId }
45772
+ { resumeSessionId: args?.resumeSessionId, settingsOverride: args?.settings }
45617
45773
  );
45618
45774
  return {
45619
45775
  success: true,
@@ -46725,7 +46881,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46725
46881
  return { updated: false };
46726
46882
  }
46727
46883
  try {
46728
- const etag = await new Promise((resolve152, reject) => {
46884
+ const etag = await new Promise((resolve162, reject) => {
46729
46885
  const options = {
46730
46886
  method: "HEAD",
46731
46887
  hostname: "github.com",
@@ -46743,7 +46899,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46743
46899
  headers: { "User-Agent": "adhdev-launcher" },
46744
46900
  timeout: 1e4
46745
46901
  }, (res2) => {
46746
- resolve152(res2.headers.etag || res2.headers["last-modified"] || "");
46902
+ resolve162(res2.headers.etag || res2.headers["last-modified"] || "");
46747
46903
  });
46748
46904
  req2.on("error", reject);
46749
46905
  req2.on("timeout", () => {
@@ -46752,7 +46908,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46752
46908
  });
46753
46909
  req2.end();
46754
46910
  } else {
46755
- resolve152(res.headers.etag || res.headers["last-modified"] || "");
46911
+ resolve162(res.headers.etag || res.headers["last-modified"] || "");
46756
46912
  }
46757
46913
  });
46758
46914
  req.on("error", reject);
@@ -46816,7 +46972,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46816
46972
  downloadFile(url2, destPath) {
46817
46973
  const https = __require2("https");
46818
46974
  const http3 = __require2("http");
46819
- return new Promise((resolve152, reject) => {
46975
+ return new Promise((resolve162, reject) => {
46820
46976
  const doRequest = (reqUrl, redirectCount = 0) => {
46821
46977
  if (redirectCount > 5) {
46822
46978
  reject(new Error("Too many redirects"));
@@ -46836,7 +46992,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
46836
46992
  res.pipe(ws);
46837
46993
  ws.on("finish", () => {
46838
46994
  ws.close();
46839
- resolve152();
46995
+ resolve162();
46840
46996
  });
46841
46997
  ws.on("error", reject);
46842
46998
  });
@@ -48067,11 +48223,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
48067
48223
  const cliType = typeof args?.cliType === "string" ? args.cliType.trim() : "claude-cli";
48068
48224
  if (!meshId) return { success: false, error: "meshId required" };
48069
48225
  try {
48070
- const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
48071
48226
  const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_coordinator_prompt(), coordinator_prompt_exports));
48072
- const mesh = getMesh3(meshId);
48227
+ let mesh;
48228
+ if (args?.inlineMesh && typeof args.inlineMesh === "object") {
48229
+ mesh = args.inlineMesh;
48230
+ } else {
48231
+ const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
48232
+ mesh = getMesh3(meshId);
48233
+ }
48073
48234
  if (!mesh) return { success: false, error: "Mesh not found" };
48074
- if (mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
48235
+ if (!Array.isArray(mesh.nodes) || mesh.nodes.length === 0) return { success: false, error: "No nodes in mesh" };
48075
48236
  const workspace = mesh.nodes[0].workspace;
48076
48237
  const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
48077
48238
  const coordinatorSetup = resolveMeshCoordinatorSetup({
@@ -48110,9 +48271,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
48110
48271
  workspace
48111
48272
  };
48112
48273
  }
48113
- const { existsSync: existsSync21, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
48274
+ const { existsSync: existsSync22, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
48114
48275
  const mcpConfigPath = coordinatorSetup.configPath;
48115
- const hadExistingMcpConfig = existsSync21(mcpConfigPath);
48276
+ const hadExistingMcpConfig = existsSync22(mcpConfigPath);
48116
48277
  let existingMcpConfig = {};
48117
48278
  if (hadExistingMcpConfig) {
48118
48279
  try {
@@ -48126,8 +48287,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
48126
48287
  mcpServers: {
48127
48288
  ...existingMcpConfig.mcpServers || {},
48128
48289
  [coordinatorSetup.serverName]: {
48129
- command: "adhdev-mcp",
48130
- args: ["--repo-mesh", meshId]
48290
+ command: coordinatorSetup.mcpServer.command,
48291
+ args: coordinatorSetup.mcpServer.args
48131
48292
  }
48132
48293
  }
48133
48294
  };
@@ -48139,10 +48300,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
48139
48300
  } catch {
48140
48301
  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).`;
48141
48302
  }
48303
+ const cliArgs = [];
48304
+ if (systemPrompt) {
48305
+ cliArgs.push("--append-system-prompt", systemPrompt);
48306
+ }
48307
+ if (cliType === "claude-cli") {
48308
+ cliArgs.push("--mcp-config", coordinatorSetup.configPath);
48309
+ }
48142
48310
  const launchResult = await this.deps.cliManager.handleCliCommand("launch_cli", {
48143
48311
  cliType,
48144
48312
  dir: workspace,
48145
- initialPrompt: systemPrompt
48313
+ cliArgs: cliArgs.length > 0 ? cliArgs : void 0,
48314
+ settings: {
48315
+ meshCoordinatorFor: meshId
48316
+ }
48146
48317
  });
48147
48318
  if (!launchResult?.success) {
48148
48319
  return { success: false, error: launchResult?.error || "Failed to launch CLI session" };
@@ -48443,7 +48614,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
48443
48614
  workspace: session.workspace ?? null,
48444
48615
  title: session.title,
48445
48616
  cdpConnected: session.cdpConnected,
48446
- summaryMetadata: session.summaryMetadata
48617
+ summaryMetadata: session.summaryMetadata,
48618
+ settings: session.settings
48447
48619
  })),
48448
48620
  p2p: payload.p2p,
48449
48621
  timestamp: now
@@ -48630,7 +48802,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
48630
48802
  const beforeCount = this.messageCount(before);
48631
48803
  const beforeSignature = this.lastMessageSignature(before);
48632
48804
  for (let attempt = 0; attempt < 12; attempt += 1) {
48633
- await new Promise((resolve152) => setTimeout(resolve152, 250));
48805
+ await new Promise((resolve162) => setTimeout(resolve162, 250));
48634
48806
  let state;
48635
48807
  try {
48636
48808
  state = await this.readChat(evaluate);
@@ -48652,7 +48824,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
48652
48824
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
48653
48825
  return first;
48654
48826
  }
48655
- await new Promise((resolve152) => setTimeout(resolve152, 150));
48827
+ await new Promise((resolve162) => setTimeout(resolve162, 150));
48656
48828
  const second = await this.readChat(evaluate);
48657
48829
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
48658
48830
  }
@@ -48803,7 +48975,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
48803
48975
  if (typeof data.error === "string" && data.error.trim()) return false;
48804
48976
  }
48805
48977
  for (let attempt = 0; attempt < 6; attempt += 1) {
48806
- await new Promise((resolve152) => setTimeout(resolve152, 250));
48978
+ await new Promise((resolve162) => setTimeout(resolve162, 250));
48807
48979
  const state = await this.readChat(evaluate);
48808
48980
  const title = this.getStateTitle(state);
48809
48981
  if (this.titlesMatch(title, sessionId)) return true;
@@ -49783,15 +49955,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
49783
49955
  this.json(res, 500, { error: e.message });
49784
49956
  }
49785
49957
  });
49786
- return new Promise((resolve152, reject) => {
49958
+ return new Promise((resolve162, reject) => {
49787
49959
  this.server.listen(port, "127.0.0.1", () => {
49788
49960
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
49789
- resolve152();
49961
+ resolve162();
49790
49962
  });
49791
49963
  this.server.on("error", (e) => {
49792
49964
  if (e.code === "EADDRINUSE") {
49793
49965
  this.log(`Port ${port} in use, skipping dev server`);
49794
- resolve152();
49966
+ resolve162();
49795
49967
  } else {
49796
49968
  reject(e);
49797
49969
  }
@@ -49873,20 +50045,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
49873
50045
  child.stderr?.on("data", (d) => {
49874
50046
  stderr += d.toString().slice(0, 2e3);
49875
50047
  });
49876
- await new Promise((resolve152) => {
50048
+ await new Promise((resolve162) => {
49877
50049
  const timer = setTimeout(() => {
49878
50050
  child.kill();
49879
- resolve152();
50051
+ resolve162();
49880
50052
  }, 3e3);
49881
50053
  child.on("exit", () => {
49882
50054
  clearTimeout(timer);
49883
- resolve152();
50055
+ resolve162();
49884
50056
  });
49885
50057
  child.stdout?.once("data", () => {
49886
50058
  setTimeout(() => {
49887
50059
  child.kill();
49888
50060
  clearTimeout(timer);
49889
- resolve152();
50061
+ resolve162();
49890
50062
  }, 500);
49891
50063
  });
49892
50064
  });
@@ -50389,14 +50561,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
50389
50561
  child.stderr?.on("data", (d) => {
50390
50562
  stderr += d.toString();
50391
50563
  });
50392
- await new Promise((resolve152) => {
50564
+ await new Promise((resolve162) => {
50393
50565
  const timer = setTimeout(() => {
50394
50566
  child.kill();
50395
- resolve152();
50567
+ resolve162();
50396
50568
  }, timeout);
50397
50569
  child.on("exit", () => {
50398
50570
  clearTimeout(timer);
50399
- resolve152();
50571
+ resolve162();
50400
50572
  });
50401
50573
  });
50402
50574
  const elapsed = Date.now() - start;
@@ -51066,14 +51238,14 @@ data: ${JSON.stringify(msg.data)}
51066
51238
  res.end(JSON.stringify(data, null, 2));
51067
51239
  }
51068
51240
  async readBody(req) {
51069
- return new Promise((resolve152) => {
51241
+ return new Promise((resolve162) => {
51070
51242
  let body = "";
51071
51243
  req.on("data", (chunk) => body += chunk);
51072
51244
  req.on("end", () => {
51073
51245
  try {
51074
- resolve152(JSON.parse(body));
51246
+ resolve162(JSON.parse(body));
51075
51247
  } catch {
51076
- resolve152({});
51248
+ resolve162({});
51077
51249
  }
51078
51250
  });
51079
51251
  });
@@ -51668,6 +51840,8 @@ data: ${JSON.stringify(msg.data)}
51668
51840
  };
51669
51841
  init_logger();
51670
51842
  init_config();
51843
+ init_mesh_config();
51844
+ init_logger();
51671
51845
  }
51672
51846
  });
51673
51847
 
@@ -53100,7 +53274,11 @@ async function meshLaunchSession(ctx, args) {
53100
53274
  if (isLocalTransport(ctx.transport)) {
53101
53275
  const result = await ctx.transport.command("launch_cli", {
53102
53276
  cliType: args.type,
53103
- dir: node.workspace
53277
+ dir: node.workspace,
53278
+ settings: {
53279
+ meshNodeFor: ctx.mesh.id,
53280
+ launchedByCoordinator: true
53281
+ }
53104
53282
  });
53105
53283
  return JSON.stringify(result, null, 2);
53106
53284
  } else {
@@ -53246,7 +53424,7 @@ async function startMcpServer(opts) {
53246
53424
  coordinatorPrompt = `You are a Repo Mesh Coordinator for "${mesh.name}" (${mesh.repoIdentity}). Use mesh_* tools to orchestrate work.`;
53247
53425
  }
53248
53426
  const server2 = new import_server.Server(
53249
- { name: "adhdev-mcp-server", version: "0.9.70" },
53427
+ { name: "adhdev-mcp-server", version: "0.9.72" },
53250
53428
  { capabilities: { tools: {}, resources: {} } }
53251
53429
  );
53252
53430
  const { ListResourcesRequestSchema, ReadResourceRequestSchema } = await import("@modelcontextprotocol/sdk/types.js");