@trops/dash-core 0.1.62 → 0.1.64

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.
@@ -4844,18 +4844,43 @@ const fs$5 = require$$2;
4844
4844
  */
4845
4845
  let _shellPath$1 = null;
4846
4846
 
4847
+ /**
4848
+ * Check if a Node.js major version is compatible (v18, v20, or v22).
4849
+ * Node v24+ has stricter ESM resolution that breaks some MCP packages.
4850
+ */
4851
+ function isCompatibleNodeVersion(majorVersion) {
4852
+ return majorVersion >= 18 && majorVersion <= 22;
4853
+ }
4854
+
4855
+ /**
4856
+ * Detect if an error message indicates Node v24+ ESM incompatibility.
4857
+ */
4858
+ function isNodeEsmError(errorText) {
4859
+ if (!errorText) return false;
4860
+ return (
4861
+ errorText.includes("ERR_PACKAGE_PATH_NOT_EXPORTED") ||
4862
+ errorText.includes("ERR_MODULE_NOT_FOUND")
4863
+ );
4864
+ }
4865
+
4847
4866
  /**
4848
4867
  * Get the user's full shell PATH (including nvm, homebrew, volta, etc.).
4849
4868
  * Electron GUI apps on macOS don't inherit the shell PATH, so we
4850
4869
  * resolve it once by invoking a login shell.
4870
+ *
4871
+ * On systems where Node v24+ is the default, this will prefer a compatible
4872
+ * nvm-managed Node version (v18/v20/v22) to avoid ESM resolution errors
4873
+ * in MCP packages.
4851
4874
  */
4852
4875
  function getShellPath$1() {
4853
4876
  if (_shellPath$1 !== null) return _shellPath$1;
4854
4877
 
4878
+ const { execSync } = require$$5$2;
4855
4879
  const fallbackDirs = ["/usr/local/bin", "/opt/homebrew/bin"];
4856
4880
 
4857
- // Add nvm/volta/nodenv paths if available
4881
+ // Scan nvm versions, tracking both latest and best compatible version
4858
4882
  const home = process.env.HOME || "";
4883
+ let compatibleNvmBin = null;
4859
4884
  if (home) {
4860
4885
  fallbackDirs.push(`${home}/.volta/bin`);
4861
4886
  fallbackDirs.push(`${home}/.nodenv/shims`);
@@ -4863,18 +4888,37 @@ function getShellPath$1() {
4863
4888
  const nvmDir = `${home}/.nvm/versions/node`;
4864
4889
  const versions = fs$5.readdirSync(nvmDir).sort();
4865
4890
  if (versions.length > 0) {
4891
+ // Find the highest compatible version (v18/v20/v22)
4892
+ for (let i = versions.length - 1; i >= 0; i--) {
4893
+ const match = versions[i].match(/^v(\d+)/);
4894
+ if (match && isCompatibleNodeVersion(parseInt(match[1], 10))) {
4895
+ compatibleNvmBin = `${nvmDir}/${versions[i]}/bin`;
4896
+ break;
4897
+ }
4898
+ }
4899
+ // Always add the latest nvm version as fallback
4866
4900
  fallbackDirs.push(`${nvmDir}/${versions[versions.length - 1]}/bin`);
4867
4901
  }
4868
4902
  } catch {}
4869
4903
  }
4870
4904
 
4871
4905
  try {
4872
- const { execSync } = require("child_process");
4873
4906
  const shell = process.env.SHELL || "/bin/bash";
4874
- _shellPath$1 = execSync(`${shell} -ilc 'echo -n "$PATH"'`, {
4875
- encoding: "utf8",
4876
- timeout: 5000,
4877
- });
4907
+ const marker = "__DASH_PATH__";
4908
+ const raw = execSync(
4909
+ `${shell} -ilc 'echo "${marker}$PATH${marker}"'`,
4910
+ { encoding: "utf8", timeout: 5000 },
4911
+ );
4912
+ // Extract PATH between markers, stripping session restore noise
4913
+ const startIdx = raw.indexOf(marker);
4914
+ const endIdx = raw.lastIndexOf(marker);
4915
+ if (startIdx !== -1 && endIdx > startIdx) {
4916
+ _shellPath$1 = raw
4917
+ .substring(startIdx + marker.length, endIdx)
4918
+ .replace(/[\r\n]/g, "");
4919
+ } else {
4920
+ _shellPath$1 = process.env.PATH || "";
4921
+ }
4878
4922
  } catch (err) {
4879
4923
  console.warn("[mcpController] Failed to resolve shell PATH:", err.message);
4880
4924
  _shellPath$1 = process.env.PATH || "";
@@ -4888,6 +4932,24 @@ function getShellPath$1() {
4888
4932
  }
4889
4933
  }
4890
4934
 
4935
+ // If system Node is v24+, prepend compatible nvm version so it's found first
4936
+ if (compatibleNvmBin) {
4937
+ try {
4938
+ const nodeVersion = execSync(
4939
+ `PATH="${_shellPath$1}" node --version 2>/dev/null`,
4940
+ { encoding: "utf8", timeout: 5000 },
4941
+ ).trim();
4942
+ const majorMatch = nodeVersion.match(/^v(\d+)/);
4943
+ if (majorMatch && !isCompatibleNodeVersion(parseInt(majorMatch[1], 10))) {
4944
+ console.log(
4945
+ `[mcpController] System Node is ${nodeVersion} (incompatible), ` +
4946
+ `prepending compatible nvm path: ${compatibleNvmBin}`,
4947
+ );
4948
+ _shellPath$1 = `${compatibleNvmBin}:${_shellPath$1}`;
4949
+ }
4950
+ } catch {}
4951
+ }
4952
+
4891
4953
  console.log("[mcpController] Resolved PATH:", _shellPath$1);
4892
4954
  return _shellPath$1;
4893
4955
  }
@@ -5090,6 +5152,14 @@ const mcpController$2 = {
5090
5152
  error,
5091
5153
  );
5092
5154
 
5155
+ // Detect Node v24+ ESM compatibility errors and provide actionable message
5156
+ let errorMessage = error.message;
5157
+ if (isNodeEsmError(error.message)) {
5158
+ errorMessage =
5159
+ "This MCP server is incompatible with your system Node.js version. " +
5160
+ "Install Node.js v22 (LTS) using nvm and restart the app.";
5161
+ }
5162
+
5093
5163
  // Mark as error state
5094
5164
  activeServers.set(serverName, {
5095
5165
  client: null,
@@ -5097,12 +5167,12 @@ const mcpController$2 = {
5097
5167
  tools: [],
5098
5168
  resources: [],
5099
5169
  status: STATUS.ERROR,
5100
- error: error.message,
5170
+ error: errorMessage,
5101
5171
  });
5102
5172
 
5103
5173
  return {
5104
5174
  error: true,
5105
- message: error.message,
5175
+ message: errorMessage,
5106
5176
  serverName,
5107
5177
  status: STATUS.ERROR,
5108
5178
  };
@@ -5486,6 +5556,16 @@ const mcpController$2 = {
5486
5556
  resolve({ success: true });
5487
5557
  } else {
5488
5558
  const detail = stderr.trim() || stdout.trim() || "";
5559
+ // Detect Node v24+ ESM compatibility errors and provide actionable message
5560
+ if (isNodeEsmError(detail)) {
5561
+ resolve({
5562
+ error: true,
5563
+ message:
5564
+ "This MCP server is incompatible with your system Node.js version. " +
5565
+ "Install Node.js v22 (LTS) using nvm and restart the app.",
5566
+ });
5567
+ return;
5568
+ }
5489
5569
  resolve({
5490
5570
  error: true,
5491
5571
  message: `Auth exited with code ${code}${detail ? ": " + detail : ""}`,