@uipath/cli 1.203.0-preview.205 → 1.204.0-preview.206

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.
@@ -11,7 +11,7 @@ import {
11
11
  logger,
12
12
  processContext,
13
13
  wasInteractiveFlagPassed
14
- } from "./index-7pvwjzsq.js";
14
+ } from "./index-kyn5nn3d.js";
15
15
  import {
16
16
  exports_external
17
17
  } from "./index-hrt7fpkk.js";
@@ -551,7 +551,7 @@ var package_default = {
551
551
  name: "@uipath/cli",
552
552
  author: "UiPath",
553
553
  license: "SEE LICENSE IN LICENSE.txt",
554
- version: "1.203.0-preview.205",
554
+ version: "1.204.0-preview.206",
555
555
  description: "Cross platform CLI for UiPath",
556
556
  repository: {
557
557
  type: "git",
@@ -932,6 +932,10 @@ async function getGlobalNpmUipathDir() {
932
932
  cachedLookup = resolveGlobalNpmUipathDir();
933
933
  return cachedLookup;
934
934
  }
935
+ async function refreshGlobalNpmUipathDir() {
936
+ cachedLookup = resolveGlobalNpmUipathDir();
937
+ return cachedLookup;
938
+ }
935
939
  async function resolveGlobalNpmUipathDir() {
936
940
  const root = await runNpmRootGlobal();
937
941
  if (!root) {
@@ -984,6 +988,98 @@ async function runNpmRootGlobal() {
984
988
  });
985
989
  }
986
990
 
991
+ // src/utils/toolsDirsEnv.ts
992
+ var TOOLS_DIRS_ENV_VAR = "UIPATH_CLI_TOOLS_DIRS";
993
+ var UNSAFE_PATH_CHARS = /["%\p{Cc}]/u;
994
+ function hasUnsafePathChars(value) {
995
+ return UNSAFE_PATH_CHARS.test(value);
996
+ }
997
+ var cachedDeclaration = null;
998
+ async function getEnvToolsDirsDeclaration() {
999
+ if (cachedDeclaration)
1000
+ return cachedDeclaration;
1001
+ cachedDeclaration = resolveDeclaration();
1002
+ return cachedDeclaration;
1003
+ }
1004
+ async function resolveDeclaration() {
1005
+ const fs = getFileSystem();
1006
+ const raw = fs.env.getenv(TOOLS_DIRS_ENV_VAR);
1007
+ if (raw === undefined || raw.trim() === "")
1008
+ return null;
1009
+ const delimiter = process.platform === "win32" ? ";" : ":";
1010
+ const dirs = [];
1011
+ const seen = new Set;
1012
+ let installTarget = null;
1013
+ let declared = false;
1014
+ for (const entry of raw.split(delimiter)) {
1015
+ const candidate = entry.trim();
1016
+ if (candidate === "")
1017
+ continue;
1018
+ if (hasUnsafePathChars(candidate)) {
1019
+ logger.warn(`${TOOLS_DIRS_ENV_VAR} entry rejected — unsupported characters in path: ${JSON.stringify(candidate)}`);
1020
+ continue;
1021
+ }
1022
+ if (!fs.path.isAbsolute(candidate)) {
1023
+ logger.warn(`${TOOLS_DIRS_ENV_VAR} entry rejected — path is not absolute: ${JSON.stringify(candidate)}`);
1024
+ continue;
1025
+ }
1026
+ const resolved = fs.path.resolve(candidate);
1027
+ const key = process.platform === "win32" ? resolved.toLowerCase() : resolved;
1028
+ if (seen.has(key))
1029
+ continue;
1030
+ seen.add(key);
1031
+ const isFirst = !declared;
1032
+ declared = true;
1033
+ const [error, stats] = await catchError(fs.stat(resolved));
1034
+ if (error) {
1035
+ logger.debug(`${TOOLS_DIRS_ENV_VAR} entry skipped — cannot stat ${resolved}: ${String(error)}`);
1036
+ continue;
1037
+ }
1038
+ if (stats && !stats.isDirectory()) {
1039
+ logger.warn(`${TOOLS_DIRS_ENV_VAR} entry skipped — not a directory: ${resolved}`);
1040
+ continue;
1041
+ }
1042
+ if (stats) {
1043
+ const [readError] = await catchError(fs.readdir(resolved));
1044
+ if (readError) {
1045
+ logger.warn(`${TOOLS_DIRS_ENV_VAR} entry skipped — directory is not readable: ${resolved}`);
1046
+ continue;
1047
+ }
1048
+ }
1049
+ if (isFirst) {
1050
+ installTarget = resolved;
1051
+ dirs.push(resolved);
1052
+ continue;
1053
+ }
1054
+ if (!stats) {
1055
+ logger.debug(`${TOOLS_DIRS_ENV_VAR} entry skipped — directory does not exist: ${resolved}`);
1056
+ continue;
1057
+ }
1058
+ dirs.push(resolved);
1059
+ }
1060
+ if (!declared)
1061
+ return null;
1062
+ logger.debug(`${TOOLS_DIRS_ENV_VAR} declared tool directories: [${dirs.join(", ")}] (install target: ${installTarget ?? "none"})`);
1063
+ return { installTarget, dirs };
1064
+ }
1065
+ function resolveNpmPrefixForToolsDir(toolsDir, platform = process.platform) {
1066
+ const fs = getFileSystem();
1067
+ const { basename, dirname } = fs.path;
1068
+ const is = (path, name) => platform === "win32" ? basename(path).toLowerCase() === name : basename(path) === name;
1069
+ if (!is(toolsDir, "@uipath"))
1070
+ return null;
1071
+ const nodeModules = dirname(toolsDir);
1072
+ if (!is(nodeModules, "node_modules"))
1073
+ return null;
1074
+ const parent = dirname(nodeModules);
1075
+ if (platform === "win32")
1076
+ return parent;
1077
+ return is(parent, "lib") ? dirname(parent) : null;
1078
+ }
1079
+ function npmGlobalRootParent(prefix, platform = process.platform) {
1080
+ return platform === "win32" ? prefix : getFileSystem().path.join(prefix, "lib");
1081
+ }
1082
+
987
1083
  // src/services/bundleDistribution.ts
988
1084
  var BUNDLE_PACKAGE_NAME = "uipath-cli-bundle";
989
1085
  var DISABLE_AUTOINSTALL_ENV = "UIPATH_CLI_DISABLE_AUTOINSTALL";
@@ -1097,6 +1193,7 @@ var TOOLS_WHITELIST = new Map([
1097
1193
  ["@uipath/test-manager-tool", "tm"],
1098
1194
  ["@uipath/api-workflow-tool", "api-workflow"],
1099
1195
  ["@uipath/maestro-tool", "maestro"],
1196
+ ["@uipath/rules-tool", "rules"],
1100
1197
  ["@uipath/docsai-tool", "docsai"],
1101
1198
  ["@uipath/vertical-solutions-tool", "vss"],
1102
1199
  ["@uipath/rpa-legacy-tool", "rpa-legacy"],
@@ -1481,7 +1578,7 @@ async function spawnPackageManager(executable, args, cwd, label, extraEnv) {
1481
1578
  }
1482
1579
  const { spawn } = await loadChildProcess();
1483
1580
  const isWindows = process.platform === "win32";
1484
- const envOpt = extraEnv ? { env: { ...process.env, ...extraEnv } } : {};
1581
+ const envOpt = extraEnv ? { env: mergeEnvCaseInsensitive(process.env, extraEnv) } : {};
1485
1582
  return new Promise((resolve, reject) => {
1486
1583
  let proc;
1487
1584
  if (isWindows) {
@@ -1526,6 +1623,35 @@ async function spawnPackageManager(executable, args, cwd, label, extraEnv) {
1526
1623
  });
1527
1624
  });
1528
1625
  }
1626
+ function mergeEnvCaseInsensitive(base, overrides) {
1627
+ const overridden = new Set(Object.keys(overrides).map((k) => k.toLowerCase()));
1628
+ const merged = {};
1629
+ for (const [key, value] of Object.entries(base)) {
1630
+ if (!overridden.has(key.toLowerCase()))
1631
+ merged[key] = value;
1632
+ }
1633
+ return { ...merged, ...overrides };
1634
+ }
1635
+ function prefixEnv(prefix) {
1636
+ if (prefix === undefined || prefix.trim() === "")
1637
+ return {};
1638
+ if (!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(prefix)) {
1639
+ throw new Error(`npm prefix must be an absolute path: ${prefix}`);
1640
+ }
1641
+ if (hasUnsafePathChars(prefix)) {
1642
+ throw new Error(`npm prefix contains unsupported characters: ${JSON.stringify(prefix)}`);
1643
+ }
1644
+ return { npm_config_prefix: prefix };
1645
+ }
1646
+ async function bunCwdFor(args, cwd, extraEnv) {
1647
+ const prefix = extraEnv?.npm_config_prefix;
1648
+ if (!prefix || !args.includes("-g"))
1649
+ return cwd;
1650
+ const root = npmGlobalRootParent(prefix);
1651
+ if (root !== cwd)
1652
+ await getFileSystem().mkdir(root);
1653
+ return root;
1654
+ }
1529
1655
  async function runPackageManager(args, cwd, extraEnv) {
1530
1656
  for (const arg of args) {
1531
1657
  if (arg !== "-g" && !arg.startsWith("--")) {
@@ -1534,9 +1660,10 @@ async function runPackageManager(args, cwd, extraEnv) {
1534
1660
  }
1535
1661
  const useBun = await isDevMode();
1536
1662
  const pm = useBun ? "bun" : "npm";
1537
- logger.debug(`Running package manager: ${pm} ${args.join(" ")}${cwd ? ` (cwd: ${cwd})` : ""}`);
1663
+ const runCwd = useBun ? await bunCwdFor(args, cwd, extraEnv) : cwd;
1664
+ logger.debug(`Running package manager: ${pm} ${args.join(" ")}${runCwd ? ` (cwd: ${runCwd})` : ""}`);
1538
1665
  const pmArgs = useBun ? args.filter((a) => a !== "-g").map((a) => a === "uninstall" ? "remove" : a) : args;
1539
- await spawnPackageManager(pm, pmArgs, cwd, `${pm} ${pmArgs[0]}`, extraEnv);
1666
+ await spawnPackageManager(pm, pmArgs, runCwd, `${pm} ${pmArgs[0]}`, extraEnv);
1540
1667
  }
1541
1668
  async function runPackageManagerWithBun(args, cwd, extraEnv) {
1542
1669
  for (const arg of args) {
@@ -1545,8 +1672,16 @@ async function runPackageManagerWithBun(args, cwd, extraEnv) {
1545
1672
  }
1546
1673
  }
1547
1674
  const pmArgs = args.filter((a) => a !== "-g").map((a) => a === "uninstall" ? "remove" : a);
1548
- logger.debug(`Running package manager: bun ${pmArgs.join(" ")}${cwd ? ` (cwd: ${cwd})` : ""}`);
1549
- await spawnPackageManager("bun", pmArgs, cwd, `bun ${pmArgs[0]}`, extraEnv);
1675
+ const bunCwd = await bunCwdFor(args, cwd, extraEnv);
1676
+ logger.debug(`Running package manager: bun ${pmArgs.join(" ")}${bunCwd ? ` (cwd: ${bunCwd})` : ""}`);
1677
+ await spawnPackageManager("bun", pmArgs, bunCwd, `bun ${pmArgs[0]}`, extraEnv);
1678
+ }
1679
+
1680
+ class HostOwnedToolError extends InstallRefusedError {
1681
+ constructor(packageName, dir) {
1682
+ super(`Refusing to uninstall '${packageName}': it ships with the host application at ${dir}, which the CLI does not manage.`, "Only tools installed with 'uip tools install' can be uninstalled here.");
1683
+ this.name = "HostOwnedToolError";
1684
+ }
1550
1685
  }
1551
1686
 
1552
1687
  class NodeToolService {
@@ -1714,7 +1849,10 @@ ${errors.map((e) => ` - ${e}`).join(`
1714
1849
  validatePackageSpec(packageName);
1715
1850
  await refuseIfBundledDistribution(destination, "install", packageName);
1716
1851
  const baseArgs = options?.global ? ["install", "-g", packageName] : ["install", packageName];
1717
- const extraEnv = { ...archPinEnv() };
1852
+ const extraEnv = {
1853
+ ...archPinEnv(),
1854
+ ...options?.global ? prefixEnv(options.prefix) : {}
1855
+ };
1718
1856
  await warnIfTranslatedNodeAsync();
1719
1857
  for (let attempt = 0;attempt <= NPM_MAX_RETRIES; attempt++) {
1720
1858
  const [err] = await catchError(runPackageManager(baseArgs, destination, extraEnv));
@@ -1748,7 +1886,8 @@ ${errors.map((e) => ` - ${e}`).join(`
1748
1886
  let containerDir;
1749
1887
  let relativeName;
1750
1888
  if (options?.global) {
1751
- const globalUipathDir = await getGlobalNpmUipathDir();
1889
+ const declaration = options.prefix ? await getEnvToolsDirsDeclaration() : null;
1890
+ const globalUipathDir = declaration ? declaration.installTarget : await getGlobalNpmUipathDir();
1752
1891
  if (!globalUipathDir) {
1753
1892
  throw new Error(`Cannot locate '${packageName}': npm root -g unavailable`);
1754
1893
  }
@@ -1763,6 +1902,12 @@ ${errors.map((e) => ` - ${e}`).join(`
1763
1902
  throw new Error(`Refusing to uninstall '${packageName}': resolved path escapes ${containerDir}`);
1764
1903
  }
1765
1904
  if (!await fs.exists(packageDir)) {
1905
+ const declaration = options?.prefix ? await getEnvToolsDirsDeclaration() : null;
1906
+ for (const dir of declaration?.dirs.slice(1) ?? []) {
1907
+ if (await fs.exists(fs.path.join(dir, relativeName))) {
1908
+ throw new HostOwnedToolError(packageName, dir);
1909
+ }
1910
+ }
1766
1911
  throw new Error(`Package '${packageName}' is not installed at ${packageDir}`);
1767
1912
  }
1768
1913
  const [statError, stat] = await catchError(fs.stat(packageDir));
@@ -1772,7 +1917,7 @@ ${errors.map((e) => ` - ${e}`).join(`
1772
1917
  return;
1773
1918
  }
1774
1919
  if (options?.global) {
1775
- await runPackageManager(["uninstall", "-g", packageName], destination);
1920
+ await runPackageManager(["uninstall", "-g", packageName], destination, options.prefix ? prefixEnv(options.prefix) : undefined);
1776
1921
  } else {
1777
1922
  await runPackageManager(["uninstall", packageName], destination);
1778
1923
  }
@@ -9474,7 +9619,8 @@ async function runToolsUpdate(opts, state) {
9474
9619
  });
9475
9620
  const packageName = `${fullName}@${targetVersion}`;
9476
9621
  await toolService.install(packageName, location.path, {
9477
- global: location.global
9622
+ global: location.global,
9623
+ prefix: location.prefix
9478
9624
  });
9479
9625
  })());
9480
9626
  if (updateError) {
@@ -9719,6 +9865,6 @@ function getManualCommandForInstallError(error, fallback) {
9719
9865
  return error instanceof CliSelfUpdateError ? error.manualCommand : fallback;
9720
9866
  }
9721
9867
 
9722
- export { package_default, VALID_CHANNELS, HIDDEN_CHANNELS, PUBLIC_CHANNELS, withConfigLock, SECRET_FIELD_PATHS, migrateVersionConfig, versionMigrationNotice, resolveConfigFilePathAsync, loadConfigAsync, resolveUpdateChannel, resolveRuntimeChannel, isPreviewVersion, isValidVersionPin, majorOf, resolvePinnedVersion, isExactPin, versionLinePrefix, formatVersionPin, dist_default5 as dist_default, dist_default6 as dist_default1, dist_default7 as dist_default2, getGlobalNpmUipathDir, DISABLE_AUTOINSTALL_ENV, DISABLE_TOOL_LINE_CHECK_ENV, InstallRefusedError, isBundledDistribution, isAutoInstallDisabled, isToolLineCheckDisabled, TOOLS_WHITELIST, COMMAND_ALIASES, ALIASES_BY_COMMAND, WHITELIST_BY_COMMAND, WHITELIST_BY_SHORT_NAME, isValidSemver, compareSemver, resolveToolPackageName, parsePackageSpec, describeCandidateFailure, getEffectiveRegistry, isDevMode, truncateVersionsForDisplay, toolService, SkillSourceError, SkillsRegistryAuthError, resolveSkillSource, getContentStoreForRead, getAvailableSkills, readManifest, removeFromManifest, readExtraFiles, AGENT_DEFS, getSkillsDir, getSkillsDestinationHint, hasDistinctGlobalPath, skillOwnerOf, uninstallExtraFolders, uninstallSkill, rejectIfGlobalOnly, getSkillsSourceFailureDetails, buildSkillCatalog, removeSkillCatalog, searchSkillCatalog, ALL_AGENTS, AGENT_DISPLAY_NAMES, promptAgentSelection, SkillsError, resolveSkillsTargetVersion, resolveRootDir, resolveSkillsContext, runAgentInstalls, runSkillsUpdate, getInstalledTools, toolFailureRemediation, collapsePinnedLineErrors, todayLocal, readState, recordToolUpdateDate, mergeState, TOOLS_UPDATE_PHASES, runToolsUpdate, runUpdate };
9868
+ export { package_default, VALID_CHANNELS, HIDDEN_CHANNELS, PUBLIC_CHANNELS, withConfigLock, SECRET_FIELD_PATHS, migrateVersionConfig, versionMigrationNotice, resolveConfigFilePathAsync, loadConfigAsync, resolveUpdateChannel, resolveRuntimeChannel, isPreviewVersion, isValidVersionPin, majorOf, resolvePinnedVersion, isExactPin, versionLinePrefix, formatVersionPin, dist_default5 as dist_default, dist_default6 as dist_default1, dist_default7 as dist_default2, getGlobalNpmUipathDir, refreshGlobalNpmUipathDir, TOOLS_DIRS_ENV_VAR, getEnvToolsDirsDeclaration, resolveNpmPrefixForToolsDir, DISABLE_AUTOINSTALL_ENV, DISABLE_TOOL_LINE_CHECK_ENV, InstallRefusedError, isBundledDistribution, isAutoInstallDisabled, isToolLineCheckDisabled, TOOLS_WHITELIST, COMMAND_ALIASES, ALIASES_BY_COMMAND, WHITELIST_BY_COMMAND, WHITELIST_BY_SHORT_NAME, isValidSemver, compareSemver, resolveToolPackageName, parsePackageSpec, describeCandidateFailure, getEffectiveRegistry, isDevMode, HostOwnedToolError, truncateVersionsForDisplay, toolService, SkillSourceError, SkillsRegistryAuthError, resolveSkillSource, getContentStoreForRead, getAvailableSkills, readManifest, removeFromManifest, readExtraFiles, AGENT_DEFS, getSkillsDir, getSkillsDestinationHint, hasDistinctGlobalPath, skillOwnerOf, uninstallExtraFolders, uninstallSkill, rejectIfGlobalOnly, getSkillsSourceFailureDetails, buildSkillCatalog, removeSkillCatalog, searchSkillCatalog, ALL_AGENTS, AGENT_DISPLAY_NAMES, promptAgentSelection, SkillsError, resolveSkillsTargetVersion, resolveRootDir, resolveSkillsContext, runAgentInstalls, runSkillsUpdate, getInstalledTools, toolFailureRemediation, collapsePinnedLineErrors, todayLocal, readState, recordToolUpdateDate, mergeState, TOOLS_UPDATE_PHASES, runToolsUpdate, runUpdate };
9723
9869
 
9724
- //# debugId=452E6333FCBBBE5F64756E2164756E21
9870
+ //# debugId=28073FAA99B3D1C564756E2164756E21