@algosuite/vo-mcp 0.2.0-beta.17 → 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.
@@ -947,6 +947,7 @@ import {
947
947
  rmSync,
948
948
  writeFileSync
949
949
  } from "node:fs";
950
+ import { homedir } from "node:os";
950
951
  import { dirname as dirname2, isAbsolute as isAbsolute2, join as join2, relative as relative2, resolve as resolve3 } from "node:path";
951
952
  var SLOT_ID_RE = /^vo-mcp-[0-9A-Za-z._-]{1,96}$/u;
952
953
  var ACTION_ID_RE = /^[0-9A-Za-z._-]{1,128}$/u;
@@ -962,9 +963,26 @@ function within(parent, candidate) {
962
963
  const rel = relative2(resolve3(parent), resolve3(candidate));
963
964
  return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
964
965
  }
965
- function runtimeRootFromEnv(env = process.env) {
966
+ var APP_IDENTIFIER = "ai.algosuite.vo-runner";
967
+ var RUNNER_RUNTIME_DIR = "runner-runtime";
968
+ function defaultRuntimeRoot({ platform = process.platform, env = process.env, home = homedir() } = {}) {
969
+ if (platform === "win32") {
970
+ const appData = String(env.APPDATA || "").trim();
971
+ return appData && isAbsolute2(appData) ? join2(appData, APP_IDENTIFIER, RUNNER_RUNTIME_DIR) : null;
972
+ }
973
+ if (!home) return null;
974
+ if (platform === "darwin") {
975
+ return join2(home, "Library", "Application Support", APP_IDENTIFIER, RUNNER_RUNTIME_DIR);
976
+ }
977
+ const xdg = String(env.XDG_CONFIG_HOME || "").trim();
978
+ const base = xdg && isAbsolute2(xdg) ? xdg : join2(home, ".config");
979
+ return join2(base, APP_IDENTIFIER, RUNNER_RUNTIME_DIR);
980
+ }
981
+ function runtimeRootFromEnv(env = process.env, { platform, home } = {}) {
966
982
  const value = String(env.VO_RUNNER_RUNTIME_ROOT || "").trim();
967
- return value && isAbsolute2(value) ? resolve3(value) : null;
983
+ if (value) return isAbsolute2(value) ? resolve3(value) : null;
984
+ const derived = defaultRuntimeRoot({ platform, env, home });
985
+ return derived ? resolve3(derived) : null;
968
986
  }
969
987
  function hashFileSha512(file) {
970
988
  return `sha512-${createHash3("sha512").update(readFileSync3(file)).digest("base64")}`;
@@ -1566,10 +1584,17 @@ import { spawnSync as spawnSync3 } from "node:child_process";
1566
1584
  import { existsSync as existsSync5, mkdirSync as mkdirSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
1567
1585
  import os from "node:os";
1568
1586
  import path from "node:path";
1569
- 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 } = {}) {
1570
1594
  if (!Number.isInteger(pid) || pid <= 0) return false;
1571
1595
  if (platform === "win32") {
1572
- 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 });
1573
1598
  return !r.error && r.status === 0;
1574
1599
  }
1575
1600
  try {
@@ -1638,17 +1663,21 @@ function parsePosixSweepLine(line, nowMs) {
1638
1663
  commandLine: match[4]
1639
1664
  };
1640
1665
  }
1641
- 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 } = {}) {
1642
1667
  const rows = [];
1643
1668
  if (platform === "win32") {
1644
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 }";
1645
- const result2 = spawn2("powershell", ["-NoProfile", "-NonInteractive", "-Command", ps], {
1670
+ const result2 = spawn2(windowsPowershellExe(env), ["-NoProfile", "-NonInteractive", "-Command", ps], {
1646
1671
  windowsHide: true,
1647
1672
  encoding: "utf8",
1648
1673
  timeout: 3e4,
1649
1674
  maxBuffer: 64 * 1024 * 1024
1650
1675
  });
1651
- 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
+ }
1652
1681
  for (const line of String(result2.stdout ?? "").split(/\r?\n/u)) {
1653
1682
  if (!line.trim()) continue;
1654
1683
  try {
@@ -1667,7 +1696,11 @@ function listProcessesForSweep({ platform = process.platform, spawn: spawn2 = sp
1667
1696
  return rows;
1668
1697
  }
1669
1698
  const result = spawn2("ps", ["-eo", "pid=,ppid=,etimes=,args="], { encoding: "utf8", timeout: 3e4, maxBuffer: 64 * 1024 * 1024 });
1670
- 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
+ }
1671
1704
  for (const line of String(result.stdout ?? "").split("\n")) {
1672
1705
  const row = parsePosixSweepLine(line, nowMs);
1673
1706
  if (row) rows.push(row);