@trops/dash-core 0.1.381 → 0.1.383

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.
@@ -18,7 +18,8 @@ var require$$8$1 = require('https');
18
18
  var require$$0$6 = require('@modelcontextprotocol/sdk/client/index.js');
19
19
  var require$$1$4 = require('@modelcontextprotocol/sdk/client/stdio.js');
20
20
  var require$$0$5 = require('pkce-challenge');
21
- var require$$6$1 = require('child_process');
21
+ var require$$5$1 = require('os');
22
+ var require$$7 = require('child_process');
22
23
  var require$$2$2 = require('algoliasearch');
23
24
  var require$$3$3 = require('node:path');
24
25
  var require$$0$7 = require('openai');
@@ -28,7 +29,6 @@ var require$$1$5 = require('crypto');
28
29
  var require$$0$8 = require('http');
29
30
  var require$$1$6 = require('http2');
30
31
  var require$$2$3 = require('node-forge');
31
- var require$$2$5 = require('os');
32
32
  var require$$3$4 = require('adm-zip');
33
33
  var require$$4$1 = require('url');
34
34
  var require$$2$4 = require('vm');
@@ -25629,6 +25629,7 @@ const {
25629
25629
  } = streamableHttp$1;
25630
25630
  const path$c = require$$1$2;
25631
25631
  const fs$8 = require$$0$2;
25632
+ const os = require$$5$1;
25632
25633
  const responseCache$2 = responseCache_1;
25633
25634
 
25634
25635
  /**
@@ -25676,6 +25677,8 @@ function isReadOnlyTool(toolName) {
25676
25677
  */
25677
25678
  const DEFAULT_TOOL_CACHE_TTL = 5000;
25678
25679
 
25680
+ const IS_WINDOWS$1 = process.platform === "win32";
25681
+
25679
25682
  /**
25680
25683
  * Cached shell PATH result (resolved once, reused for all spawns).
25681
25684
  */
@@ -25712,11 +25715,21 @@ function isNodeEsmError(errorText) {
25712
25715
  function getShellPath$1() {
25713
25716
  if (_shellPath$1 !== null) return _shellPath$1;
25714
25717
 
25715
- const { execSync } = require$$6$1;
25718
+ // Windows: skip the POSIX shell-path discovery entirely. The nvm /
25719
+ // homebrew / volta fallback dirs below are *nix-specific, and
25720
+ // Windows Electron apps typically inherit a working PATH from the
25721
+ // launcher. Users managing Node via nvm-windows or fnm should
25722
+ // already have their shims on PATH.
25723
+ if (IS_WINDOWS$1) {
25724
+ _shellPath$1 = process.env.PATH || "";
25725
+ return _shellPath$1;
25726
+ }
25727
+
25728
+ const { execSync } = require$$7;
25716
25729
  const fallbackDirs = ["/usr/local/bin", "/opt/homebrew/bin"];
25717
25730
 
25718
25731
  // Scan nvm versions, tracking both latest and best compatible version
25719
- const home = process.env.HOME || "";
25732
+ const home = os.homedir();
25720
25733
  let compatibleNvmBin = null;
25721
25734
  if (home) {
25722
25735
  fallbackDirs.push(`${home}/.volta/bin`);
@@ -25855,7 +25868,7 @@ function interpolate$1(template, credentials) {
25855
25868
  * @param {object} tokenRefresh { credentialsPath, oauthKeysPath }
25856
25869
  */
25857
25870
  async function refreshGoogleOAuthToken(tokenRefresh) {
25858
- const home = process.env.HOME || "";
25871
+ const home = os.homedir();
25859
25872
  const credPath = tokenRefresh.credentialsPath.replace(/^~/, home);
25860
25873
  const keysPath = tokenRefresh.oauthKeysPath.replace(/^~/, home);
25861
25874
 
@@ -26051,7 +26064,7 @@ const mcpController$2 = {
26051
26064
  // Merge static env vars from mcpConfig (with ~ expansion)
26052
26065
  if (mcpConfig.staticEnv) {
26053
26066
  Object.entries(mcpConfig.staticEnv).forEach(([envVar, value]) => {
26054
- env[envVar] = value.replace(/^~/, process.env.HOME || "");
26067
+ env[envVar] = value.replace(/^~/, os.homedir());
26055
26068
  });
26056
26069
  }
26057
26070
 
@@ -26542,7 +26555,7 @@ const mcpController$2 = {
26542
26555
  * @returns {{ success } | { error, message }}
26543
26556
  */
26544
26557
  runAuth: async (win, mcpConfig, credentials, authCommand) => {
26545
- const { spawn } = require$$6$1;
26558
+ const { spawn } = require$$7;
26546
26559
 
26547
26560
  const env = cleanEnvForChildProcess();
26548
26561
 
@@ -26551,7 +26564,7 @@ const mcpController$2 = {
26551
26564
  const { from, to } = authCommand.setup.copyCredential;
26552
26565
  const sourcePath = credentials?.[from];
26553
26566
  if (sourcePath) {
26554
- const destPath = to.replace(/^~/, process.env.HOME || "");
26567
+ const destPath = to.replace(/^~/, os.homedir());
26555
26568
  const destDir = require$$1$2.dirname(destPath);
26556
26569
  try {
26557
26570
  fs$8.mkdirSync(destDir, { recursive: true });
@@ -26586,7 +26599,7 @@ const mcpController$2 = {
26586
26599
  // Merge static env vars from authCommand with ~ expansion
26587
26600
  if (authCommand.staticEnv) {
26588
26601
  Object.entries(authCommand.staticEnv).forEach(([key, value]) => {
26589
- env[key] = value.replace(/^~/, process.env.HOME || "");
26602
+ env[key] = value.replace(/^~/, os.homedir());
26590
26603
  });
26591
26604
  }
26592
26605
 
@@ -26602,6 +26615,8 @@ const mcpController$2 = {
26602
26615
  const proc = spawn(authCommand.command, resolvedArgs, {
26603
26616
  env,
26604
26617
  stdio: ["ignore", "pipe", "pipe"],
26618
+ // Needed so Windows can launch .cmd/.bat wrappers (npx.cmd, etc).
26619
+ shell: IS_WINDOWS$1,
26605
26620
  });
26606
26621
 
26607
26622
  let stdout = "";
@@ -28149,7 +28164,7 @@ var pluginController_1 = pluginController$1;
28149
28164
  * can use the Chat widget without a separate API key.
28150
28165
  */
28151
28166
 
28152
- const { spawn, execSync } = require$$6$1;
28167
+ const { spawn, execSync } = require$$7;
28153
28168
  const {
28154
28169
  LLM_STREAM_DELTA: LLM_STREAM_DELTA$2,
28155
28170
  LLM_STREAM_TOOL_CALL: LLM_STREAM_TOOL_CALL$2,
@@ -28158,6 +28173,8 @@ const {
28158
28173
  LLM_STREAM_ERROR: LLM_STREAM_ERROR$2,
28159
28174
  } = llmEvents$1;
28160
28175
 
28176
+ const IS_WINDOWS = process.platform === "win32";
28177
+
28161
28178
  /**
28162
28179
  * Cached shell PATH result (resolved once, reused for all spawns).
28163
28180
  * Same pattern as mcpController.js.
@@ -28167,6 +28184,13 @@ let _shellPath = null;
28167
28184
  function getShellPath() {
28168
28185
  if (_shellPath !== null) return _shellPath;
28169
28186
 
28187
+ // Windows: no POSIX login-shell trick — just use the inherited PATH,
28188
+ // which is typically correct for GUI-launched Electron apps.
28189
+ if (IS_WINDOWS) {
28190
+ _shellPath = process.env.PATH || "";
28191
+ return _shellPath;
28192
+ }
28193
+
28170
28194
  try {
28171
28195
  const shell = process.env.SHELL || "/bin/bash";
28172
28196
  _shellPath = execSync(`${shell} -ilc 'echo -n "$PATH"'`, {
@@ -28181,7 +28205,7 @@ function getShellPath() {
28181
28205
  }
28182
28206
 
28183
28207
  /**
28184
- * Cached CLI binary path (resolved once via `which claude`).
28208
+ * Cached CLI binary path (resolved once via `which` / `where`).
28185
28209
  */
28186
28210
  let _cliBinaryPath = undefined; // undefined = not yet checked
28187
28211
 
@@ -28190,11 +28214,21 @@ function resolveCliBinary() {
28190
28214
 
28191
28215
  try {
28192
28216
  const fullPath = getShellPath();
28193
- _cliBinaryPath = execSync("which claude", {
28217
+ // `where` on Windows, `which` everywhere else. `where` may list
28218
+ // multiple matches on separate lines (e.g. claude.cmd + claude.ps1)
28219
+ // — take the first hit.
28220
+ const lookup = IS_WINDOWS ? "where claude" : "which claude";
28221
+ const result = execSync(lookup, {
28194
28222
  encoding: "utf8",
28195
28223
  timeout: 5000,
28196
28224
  env: { ...process.env, PATH: fullPath },
28197
- }).trim();
28225
+ });
28226
+ _cliBinaryPath = IS_WINDOWS
28227
+ ? result
28228
+ .split(/\r?\n/)
28229
+ .find((l) => l.trim())
28230
+ ?.trim() || null
28231
+ : result.trim();
28198
28232
  } catch {
28199
28233
  _cliBinaryPath = null;
28200
28234
  }
@@ -28208,6 +28242,33 @@ function resolveCliBinary() {
28208
28242
  */
28209
28243
  const activeProcesses = new Map();
28210
28244
 
28245
+ /**
28246
+ * Kill a child process and its descendants. On Windows, spawning with
28247
+ * shell:true (needed for .cmd targets) means child.kill() only
28248
+ * terminates the cmd.exe — the real CLI keeps running. Use taskkill
28249
+ * with /T (tree) /F (force) to clean up.
28250
+ */
28251
+ function killChildTree(child) {
28252
+ if (!child || child.killed || typeof child.pid !== "number") return;
28253
+ if (IS_WINDOWS) {
28254
+ try {
28255
+ execSync(`taskkill /pid ${child.pid} /T /F`, {
28256
+ stdio: "ignore",
28257
+ timeout: 5000,
28258
+ });
28259
+ } catch {
28260
+ // Fall back to plain kill — best-effort
28261
+ try {
28262
+ child.kill();
28263
+ } catch {
28264
+ /* ignore */
28265
+ }
28266
+ }
28267
+ } else {
28268
+ child.kill("SIGTERM");
28269
+ }
28270
+ }
28271
+
28211
28272
  /**
28212
28273
  * Session IDs for conversation continuity.
28213
28274
  * Map<widgetUuid, sessionId>
@@ -28319,6 +28380,10 @@ const cliController$2 = {
28319
28380
  const spawnOpts = {
28320
28381
  env: { ...process.env, PATH: fullPath },
28321
28382
  stdio: ["pipe", "pipe", "pipe"],
28383
+ // On Windows, the Claude CLI is typically installed as claude.cmd
28384
+ // (a batch wrapper). Node's child_process.spawn can't launch .cmd
28385
+ // files directly without a shell — ENOENT otherwise.
28386
+ shell: IS_WINDOWS,
28322
28387
  };
28323
28388
  if (cwd) {
28324
28389
  const fs = require("fs");
@@ -28523,7 +28588,7 @@ const cliController$2 = {
28523
28588
  abortRequest: (requestId) => {
28524
28589
  const child = activeProcesses.get(requestId);
28525
28590
  if (child) {
28526
- child.kill("SIGTERM");
28591
+ killChildTree(child);
28527
28592
  activeProcesses.delete(requestId);
28528
28593
  return { success: true };
28529
28594
  }
@@ -28580,7 +28645,7 @@ const cliController$2 = {
28580
28645
  // Kill any active processes for this widget
28581
28646
  for (const [reqId, child] of activeProcesses) {
28582
28647
  if (reqId.startsWith(widgetUuid)) {
28583
- child.kill("SIGTERM");
28648
+ killChildTree(child);
28584
28649
  activeProcesses.delete(reqId);
28585
28650
  }
28586
28651
  }
@@ -50645,7 +50710,7 @@ var schedulerController_1 = schedulerController$2;
50645
50710
  (function (module) {
50646
50711
  const fs = require$$0$2;
50647
50712
  const path = require$$1$2;
50648
- const os = require$$2$5;
50713
+ const os = require$$5$1;
50649
50714
  const AdmZip = require$$3$4;
50650
50715
  const { fileURLToPath } = require$$4$1;
50651
50716
  const { app, ipcMain, BrowserWindow } = require$$0$1;