@algosuite/vo-mcp 0.2.0-beta.18 → 0.2.0-beta.19

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.
@@ -1584,10 +1584,17 @@ import { spawnSync as spawnSync3 } from "node:child_process";
1584
1584
  import { existsSync as existsSync5, mkdirSync as mkdirSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
1585
1585
  import os from "node:os";
1586
1586
  import path from "node:path";
1587
- function killProcessTree(pid, { platform = process.platform, spawn: spawn2 = spawnSync3 } = {}) {
1587
+ function windowsSystemRoot(env = process.env) {
1588
+ return env.SystemRoot || env.WINDIR || "C:\\Windows";
1589
+ }
1590
+ function windowsPowershellExe(env = process.env) {
1591
+ return path.join(windowsSystemRoot(env), "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
1592
+ }
1593
+ function killProcessTree(pid, { platform = process.platform, spawn: spawn2 = spawnSync3, env = process.env } = {}) {
1588
1594
  if (!Number.isInteger(pid) || pid <= 0) return false;
1589
1595
  if (platform === "win32") {
1590
- const r = spawn2("taskkill", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, stdio: "ignore", timeout: 15e3 });
1596
+ const taskkill = path.join(windowsSystemRoot(env), "System32", "taskkill.exe");
1597
+ const r = spawn2(taskkill, ["/PID", String(pid), "/T", "/F"], { windowsHide: true, stdio: "ignore", timeout: 15e3 });
1591
1598
  return !r.error && r.status === 0;
1592
1599
  }
1593
1600
  try {
@@ -1656,17 +1663,21 @@ function parsePosixSweepLine(line, nowMs) {
1656
1663
  commandLine: match[4]
1657
1664
  };
1658
1665
  }
1659
- function listProcessesForSweep({ platform = process.platform, spawn: spawn2 = spawnSync4, nowMs = Date.now() } = {}) {
1666
+ function listProcessesForSweep({ platform = process.platform, spawn: spawn2 = spawnSync4, nowMs = Date.now(), env = process.env, warn = console.warn } = {}) {
1660
1667
  const rows = [];
1661
1668
  if (platform === "win32") {
1662
1669
  const ps = "Get-CimInstance Win32_Process | Where-Object { $_.CreationDate } | ForEach-Object { @{ p = $_.ProcessId; pp = $_.ParentProcessId; c = (([DateTimeOffset]$_.CreationDate.ToUniversalTime()).ToUnixTimeMilliseconds()); cl = [string]$_.CommandLine } | ConvertTo-Json -Compress }";
1663
- const result2 = spawn2("powershell", ["-NoProfile", "-NonInteractive", "-Command", ps], {
1670
+ const result2 = spawn2(windowsPowershellExe(env), ["-NoProfile", "-NonInteractive", "-Command", ps], {
1664
1671
  windowsHide: true,
1665
1672
  encoding: "utf8",
1666
1673
  timeout: 3e4,
1667
1674
  maxBuffer: 64 * 1024 * 1024
1668
1675
  });
1669
- if (result2.error || result2.status !== 0) return rows;
1676
+ if (result2.error || result2.status !== 0) {
1677
+ const cause = result2.error ? result2.error.message : `powershell exit ${result2.status}`;
1678
+ warn(`[orphan-sweep] process enumeration failed (${cause}); sweeping nothing this cycle`);
1679
+ throw new Error(`process enumeration failed (${cause}); swept nothing`);
1680
+ }
1670
1681
  for (const line of String(result2.stdout ?? "").split(/\r?\n/u)) {
1671
1682
  if (!line.trim()) continue;
1672
1683
  try {
@@ -1685,7 +1696,11 @@ function listProcessesForSweep({ platform = process.platform, spawn: spawn2 = sp
1685
1696
  return rows;
1686
1697
  }
1687
1698
  const result = spawn2("ps", ["-eo", "pid=,ppid=,etimes=,args="], { encoding: "utf8", timeout: 3e4, maxBuffer: 64 * 1024 * 1024 });
1688
- if (result.error || result.status !== 0) return rows;
1699
+ if (result.error || result.status !== 0) {
1700
+ const cause = result.error ? result.error.message : `ps exit ${result.status}`;
1701
+ warn(`[orphan-sweep] process enumeration failed (${cause}); sweeping nothing this cycle`);
1702
+ throw new Error(`process enumeration failed (${cause}); swept nothing`);
1703
+ }
1689
1704
  for (const line of String(result.stdout ?? "").split("\n")) {
1690
1705
  const row = parsePosixSweepLine(line, nowMs);
1691
1706
  if (row) rows.push(row);