@trops/dash-core 0.1.62 → 0.1.63

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,13 +4888,21 @@ 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
4907
  _shellPath$1 = execSync(`${shell} -ilc 'echo -n "$PATH"'`, {
4875
4908
  encoding: "utf8",
@@ -4888,6 +4921,24 @@ function getShellPath$1() {
4888
4921
  }
4889
4922
  }
4890
4923
 
4924
+ // If system Node is v24+, prepend compatible nvm version so it's found first
4925
+ if (compatibleNvmBin) {
4926
+ try {
4927
+ const nodeVersion = execSync(
4928
+ `PATH="${_shellPath$1}" node --version 2>/dev/null`,
4929
+ { encoding: "utf8", timeout: 5000 },
4930
+ ).trim();
4931
+ const majorMatch = nodeVersion.match(/^v(\d+)/);
4932
+ if (majorMatch && !isCompatibleNodeVersion(parseInt(majorMatch[1], 10))) {
4933
+ console.log(
4934
+ `[mcpController] System Node is ${nodeVersion} (incompatible), ` +
4935
+ `prepending compatible nvm path: ${compatibleNvmBin}`,
4936
+ );
4937
+ _shellPath$1 = `${compatibleNvmBin}:${_shellPath$1}`;
4938
+ }
4939
+ } catch {}
4940
+ }
4941
+
4891
4942
  console.log("[mcpController] Resolved PATH:", _shellPath$1);
4892
4943
  return _shellPath$1;
4893
4944
  }
@@ -5090,6 +5141,14 @@ const mcpController$2 = {
5090
5141
  error,
5091
5142
  );
5092
5143
 
5144
+ // Detect Node v24+ ESM compatibility errors and provide actionable message
5145
+ let errorMessage = error.message;
5146
+ if (isNodeEsmError(error.message)) {
5147
+ errorMessage =
5148
+ "This MCP server is incompatible with your system Node.js version. " +
5149
+ "Install Node.js v22 (LTS) using nvm and restart the app.";
5150
+ }
5151
+
5093
5152
  // Mark as error state
5094
5153
  activeServers.set(serverName, {
5095
5154
  client: null,
@@ -5097,12 +5156,12 @@ const mcpController$2 = {
5097
5156
  tools: [],
5098
5157
  resources: [],
5099
5158
  status: STATUS.ERROR,
5100
- error: error.message,
5159
+ error: errorMessage,
5101
5160
  });
5102
5161
 
5103
5162
  return {
5104
5163
  error: true,
5105
- message: error.message,
5164
+ message: errorMessage,
5106
5165
  serverName,
5107
5166
  status: STATUS.ERROR,
5108
5167
  };
@@ -5486,6 +5545,16 @@ const mcpController$2 = {
5486
5545
  resolve({ success: true });
5487
5546
  } else {
5488
5547
  const detail = stderr.trim() || stdout.trim() || "";
5548
+ // Detect Node v24+ ESM compatibility errors and provide actionable message
5549
+ if (isNodeEsmError(detail)) {
5550
+ resolve({
5551
+ error: true,
5552
+ message:
5553
+ "This MCP server is incompatible with your system Node.js version. " +
5554
+ "Install Node.js v22 (LTS) using nvm and restart the app.",
5555
+ });
5556
+ return;
5557
+ }
5489
5558
  resolve({
5490
5559
  error: true,
5491
5560
  message: `Auth exited with code ${code}${detail ? ": " + detail : ""}`,