@uipath/cli 1.203.0-preview.242 → 1.203.0-preview.244

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.
package/README.md CHANGED
@@ -431,6 +431,52 @@ uip tools install @uipath/automation-tool
431
431
  ✅ Successfully installed @uipath/automation-tool
432
432
  ```
433
433
 
434
+ #### Declaring tool directories from a host (`UIPATH_CLI_TOOLS_DIRS`)
435
+
436
+ By default the CLI finds its tools by walking up from its own location and
437
+ from the current directory looking for `node_modules/@uipath`, falling back
438
+ to `npm root -g`. An application that embeds the CLI can declare those
439
+ directories instead, as a list of `node_modules/@uipath` paths separated by
440
+ the platform path delimiter (`:` on Linux/macOS, `;` on Windows):
441
+
442
+ ```bash
443
+ # Linux / macOS
444
+ export UIPATH_CLI_TOOLS_DIRS="$HOME/.myapp/npm/prefix/lib/node_modules/@uipath:/opt/myapp/resources/bin/node_modules/@uipath"
445
+ ```
446
+
447
+ ```powershell
448
+ # Windows (PowerShell)
449
+ $env:UIPATH_CLI_TOOLS_DIRS = "$env:LOCALAPPDATA\MyApp\npm\node_modules\@uipath;C:\Program Files\MyApp\resources\bin\node_modules\@uipath"
450
+ ```
451
+
452
+ - **Order matters.** The first entry is the **install target**: `uip tools
453
+ install` and auto-install write there, passing it to npm as
454
+ `npm_config_prefix` so the install lands where the next run will look. Later entries are
455
+ discovery-only.
456
+ - A declaration is **exclusive**: the declared directories are the only ones
457
+ searched. The walks, a `@uipath/cli` installed locally under the current
458
+ directory, and `npm root -g` are all skipped, so a tool installed outside
459
+ the host's directories can never shadow or stand in for the host's own set.
460
+ - Entries must be absolute paths and must not contain a double quote, a `%`,
461
+ or control characters; anything else is ignored with a warning. The first
462
+ valid entry is the install target even if it does not exist yet (the first
463
+ install creates it). Later entries that do not exist, or that are not
464
+ directories, are skipped. Spaces, parentheses and apostrophes are fine —
465
+ real install locations have them.
466
+ - The install target must use npm's global layout for the platform
467
+ (`<prefix>/lib/node_modules/@uipath` on Linux/macOS,
468
+ `<prefix>\node_modules\@uipath` on Windows). Otherwise installs are refused
469
+ rather than sent to npm's own global location, which discovery would never
470
+ search.
471
+ - `uip tools uninstall` only removes tools from the install target. A tool
472
+ found in a later, discovery-only entry belongs to the host and is refused
473
+ with an explanation.
474
+
475
+ This exists for hosts whose tool tree the CLI cannot infer — typically one
476
+ that redirects npm's global prefix (`npm_config_prefix`) for the shells it
477
+ spawns while running the CLI itself outside them, where `npm root -g` would
478
+ report a different tree than the one the install wrote to.
479
+
434
480
  ## Getting Help
435
481
 
436
482
  - View all available commands: `uip --help`
@@ -486,6 +532,12 @@ If you see `❌ Not logged in`, run `uip login` to authenticate.
486
532
 
487
533
  After installing a new tool with `uip tools install`, you may need to restart your terminal or CLI session for the tool to become available.
488
534
 
535
+ If a tool stays missing after a successful install, the install and the
536
+ lookup are probably pointing at different trees. Run the command again with
537
+ `--log-level debug` to see which tool directories were searched and where the
538
+ install went; when the CLI is embedded in another application, see
539
+ [`UIPATH_CLI_TOOLS_DIRS`](#declaring-tool-directories-from-a-host-uipath_cli_tools_dirs).
540
+
489
541
  ### Authentication issues
490
542
 
491
543
  If you're having trouble logging in, try:
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  runNode
3
- } from "./index-rjbjph6e.js";
3
+ } from "./index-6er44ym0.js";
4
4
  import"./index-982kyq65.js";
5
- import"./index-g6dsqejv.js";
5
+ import"./index-cyr9ff8r.js";
6
6
  import"./index-nab7xkhc.js";
7
7
  import"./index-g8ck9tv6.js";
8
8
  import"./index-hrt7fpkk.js";
@@ -34,12 +34,14 @@ import {
34
34
  DISABLE_AUTOINSTALL_ENV,
35
35
  DISABLE_TOOL_LINE_CHECK_ENV,
36
36
  HIDDEN_CHANNELS,
37
+ HostOwnedToolError,
37
38
  InstallRefusedError,
38
39
  PUBLIC_CHANNELS,
39
40
  SECRET_FIELD_PATHS,
40
41
  SkillSourceError,
41
42
  SkillsError,
42
43
  SkillsRegistryAuthError,
44
+ TOOLS_DIRS_ENV_VAR,
43
45
  TOOLS_UPDATE_PHASES,
44
46
  TOOLS_WHITELIST,
45
47
  VALID_CHANNELS,
@@ -56,6 +58,7 @@ import {
56
58
  getAvailableSkills,
57
59
  getContentStoreForRead,
58
60
  getEffectiveRegistry,
61
+ getEnvToolsDirsDeclaration,
59
62
  getGlobalNpmUipathDir,
60
63
  getInstalledTools,
61
64
  getSkillsDestinationHint,
@@ -81,10 +84,12 @@ import {
81
84
  readManifest,
82
85
  readState,
83
86
  recordToolUpdateDate,
87
+ refreshGlobalNpmUipathDir,
84
88
  rejectIfGlobalOnly,
85
89
  removeFromManifest,
86
90
  removeSkillCatalog,
87
91
  resolveConfigFilePathAsync,
92
+ resolveNpmPrefixForToolsDir,
88
93
  resolvePinnedVersion,
89
94
  resolveRootDir,
90
95
  resolveRuntimeChannel,
@@ -108,7 +113,7 @@ import {
108
113
  versionLinePrefix,
109
114
  versionMigrationNotice,
110
115
  withConfigLock
111
- } from "./index-g6dsqejv.js";
116
+ } from "./index-cyr9ff8r.js";
112
117
  import {
113
118
  CONFIG_FILENAME,
114
119
  Command,
@@ -1375,6 +1380,17 @@ function isInsideNodeModules(dir) {
1375
1380
  const segments = dir.replace(/\\/g, "/").split("/").filter(Boolean);
1376
1381
  return segments.includes("node_modules");
1377
1382
  }
1383
+ function installPrefixForToolsDir(toolsDir) {
1384
+ const { dirname } = getFileSystem().path;
1385
+ let prefix = dirname(dirname(toolsDir));
1386
+ while (isInsideNodeModules(prefix)) {
1387
+ const parent = dirname(prefix);
1388
+ if (parent === prefix)
1389
+ break;
1390
+ prefix = parent;
1391
+ }
1392
+ return prefix;
1393
+ }
1378
1394
  async function isLocalWorkspaceDir(dir) {
1379
1395
  const fs = getFileSystem();
1380
1396
  const pkgJsonPath = fs.path.join(dir, "package.json");
@@ -1649,11 +1665,21 @@ async function resolveToolsDirs(cliFilePath, cwd) {
1649
1665
  const seen = new Set;
1650
1666
  const dirs = [];
1651
1667
  const cliDir = dirname(cliFilePath);
1668
+ const declaration = await getEnvToolsDirsDeclaration();
1669
+ if (declaration) {
1670
+ logger.debug(`Using only the host-declared tool directories: [${declaration.dirs.join(", ")}]`);
1671
+ return [...declaration.dirs];
1672
+ }
1652
1673
  const localCliToolsDir = await findNearestLocalCliToolsDir(cwd);
1653
1674
  if (localCliToolsDir) {
1654
1675
  seen.add(localCliToolsDir);
1655
1676
  dirs.push(localCliToolsDir);
1656
- logger.debug("CWD has a local @uipath/cli install; skipping CLI-path and global tool discovery");
1677
+ if (!await isLocalWorkspaceDir(installPrefixForToolsDir(localCliToolsDir))) {
1678
+ const globalUipath = await getGlobalNpmUipathDir();
1679
+ if (globalUipath && !seen.has(globalUipath)) {
1680
+ dirs.push(globalUipath);
1681
+ }
1682
+ }
1657
1683
  return dirs;
1658
1684
  }
1659
1685
  dirs.push(...await findNearestToolsDir(cliDir, seen));
@@ -4390,7 +4416,7 @@ function registerLogoutCommand(program, context) {
4390
4416
  function registerMcpCommand(program) {
4391
4417
  const mcpCommand = program.command("mcp").description("Model Context Protocol (MCP) server");
4392
4418
  mcpCommand.command("serve").description("Start the MCP server (stdio transport)").trackedAction(processContext, async () => {
4393
- const { startMcpServer } = await import("./server-1fdys0d5.js");
4419
+ const { startMcpServer } = await import("./server-ven3m0jz.js");
4394
4420
  await startMcpServer(program);
4395
4421
  });
4396
4422
  }
@@ -5787,7 +5813,8 @@ function registerInstallCommand2(toolsCommand, _context, state) {
5787
5813
  packageSpec = `${packageName}@${candidate.version}`;
5788
5814
  }
5789
5815
  await toolService.install(packageSpec, location.path, {
5790
- global: location.global
5816
+ global: location.global,
5817
+ prefix: location.prefix
5791
5818
  });
5792
5819
  logger.info(`Installed to ${location.path}`);
5793
5820
  OutputFormatter.success({
@@ -5966,7 +5993,8 @@ function registerUninstallCommand2(toolsCommand, _context, state) {
5966
5993
  }
5967
5994
  async function runUninstall(packageName, location) {
5968
5995
  const [error] = await catchError(toolService.uninstall(packageName, location.path, {
5969
- global: location.global
5996
+ global: location.global,
5997
+ prefix: location.prefix
5970
5998
  }));
5971
5999
  return error;
5972
6000
  }
@@ -5976,7 +6004,7 @@ async function resolveLocation(state) {
5976
6004
  OutputFormatter.error({
5977
6005
  Result: RESULTS.ConfigError,
5978
6006
  Message: error.message,
5979
- Instructions: "Please ensure the CLI is installed correctly."
6007
+ Instructions: error instanceof InstallRefusedError ? error.instructions : "Please ensure the CLI is installed correctly."
5980
6008
  });
5981
6009
  processContext.exit(1);
5982
6010
  return;
@@ -6030,7 +6058,7 @@ async function uninstallAll(state) {
6030
6058
  const results = [];
6031
6059
  for (const tool of installed) {
6032
6060
  const error = await runUninstall(`@uipath/${tool.name}`, location);
6033
- results.push(error ? { name: tool.name, status: "failed", error: error.message } : { name: tool.name, status: "uninstalled" });
6061
+ results.push(!error ? { name: tool.name, status: "uninstalled" } : error instanceof HostOwnedToolError ? { name: tool.name, status: "skipped", error: error.message } : { name: tool.name, status: "failed", error: error.message });
6034
6062
  }
6035
6063
  OutputFormatter.success({
6036
6064
  Result: RESULTS.Success,
@@ -6459,7 +6487,11 @@ function registerUpdateCommand3(program, _context, state) {
6459
6487
  };
6460
6488
  const [err, report] = await catchError((async () => {
6461
6489
  const isDev = await isDevMode();
6462
- const location = await state.resolveInstallPath();
6490
+ const [locationError, location] = await catchError(state.resolveInstallPath());
6491
+ if (locationError && !(locationError instanceof InstallRefusedError)) {
6492
+ throw locationError;
6493
+ }
6494
+ const hostOwnsCli = await getEnvToolsDirsDeclaration() !== null;
6463
6495
  return runUpdate({
6464
6496
  dryRun: raw.dryRun ?? false,
6465
6497
  channel,
@@ -6472,14 +6504,14 @@ function registerUpdateCommand3(program, _context, state) {
6472
6504
  agent: raw.agent,
6473
6505
  local: raw.local
6474
6506
  },
6475
- cli: { self: raw.self !== false },
6507
+ cli: { self: raw.self !== false && !hostOwnsCli },
6476
6508
  versionPin: target.pin,
6477
6509
  versionPinOrigin: target.origin
6478
6510
  }, state, {
6479
6511
  cliPkgVersion: package_default.version,
6480
- isLocal: !location.global,
6512
+ isLocal: location ? !location.global : false,
6481
6513
  isDev,
6482
- installPath: location.path
6514
+ installPath: location?.path ?? ""
6483
6515
  });
6484
6516
  })());
6485
6517
  if (err) {
@@ -6611,14 +6643,22 @@ function createInstallPathResolver(toolsDir, isBrowser2) {
6611
6643
  const { getFileSystem: getFileSystem2 } = await import("./index-hhsf00x8.js");
6612
6644
  const fsLocal = getFileSystem2();
6613
6645
  const { dirname: dirnameFn, join: joinFn } = fsLocal.path;
6614
- if (toolsDir) {
6615
- let path = dirnameFn(dirnameFn(toolsDir));
6616
- while (isInsideNodeModules(path)) {
6617
- const parent = dirnameFn(path);
6618
- if (parent === path)
6619
- break;
6620
- path = parent;
6646
+ const declaration = await getEnvToolsDirsDeclaration();
6647
+ if (declaration) {
6648
+ const target = declaration.installTarget;
6649
+ const prefix = target ? resolveNpmPrefixForToolsDir(target) : null;
6650
+ if (prefix) {
6651
+ const [mkdirError] = await catchError(fsLocal.mkdir(prefix));
6652
+ if (mkdirError) {
6653
+ throw new InstallRefusedError(`Cannot create the ${TOOLS_DIRS_ENV_VAR} install prefix ${prefix}: ${String(mkdirError)}`, `Make the first ${TOOLS_DIRS_ENV_VAR} entry's npm prefix writable.`);
6654
+ }
6655
+ logger.debug(`Install path resolved from ${TOOLS_DIRS_ENV_VAR}: ${prefix} (global: true)`);
6656
+ return { path: prefix, global: true, prefix };
6621
6657
  }
6658
+ throw new InstallRefusedError(`${TOOLS_DIRS_ENV_VAR} names no usable install target${target ? ` (${target} is not an npm global layout for this platform)` : ""}; refusing to install outside the host's tool directories.`, `Declare a writable npm global '@uipath' directory as the first ${TOOLS_DIRS_ENV_VAR} entry.`);
6659
+ }
6660
+ if (toolsDir) {
6661
+ const path = installPrefixForToolsDir(toolsDir);
6622
6662
  const isGlobal = !await isLocalWorkspaceDir(path);
6623
6663
  logger.debug(`Install path resolved: ${path} (global: ${isGlobal})`);
6624
6664
  return { path, global: isGlobal };
@@ -6720,6 +6760,10 @@ async function runStartupSync(context, state) {
6720
6760
  logger.debug("Version sync skipped: dev mode (monorepo checkout)");
6721
6761
  return false;
6722
6762
  }
6763
+ if (await getEnvToolsDirsDeclaration()) {
6764
+ logger.debug("Version sync skipped: the host declared its tool directories and owns the CLI version");
6765
+ return false;
6766
+ }
6723
6767
  const [locationError, location] = await catchError(state.resolveInstallPath());
6724
6768
  if (!locationError && location && await isBundledDistribution(location.path)) {
6725
6769
  logger.debug("Version sync skipped: Studio-bundled CLI distribution");
@@ -6780,7 +6824,7 @@ async function resolveUpdateLocation(state, context) {
6780
6824
  return location;
6781
6825
  }
6782
6826
  async function runUpdateEngine(state, location, context, target) {
6783
- const { runUpdate: runUpdate2 } = await import("./updateService-8zj9j41v.js");
6827
+ const { runUpdate: runUpdate2 } = await import("./updateService-ka83bfcd.js");
6784
6828
  const spinner = await startSpinner(formatUpdateStartMessage(target));
6785
6829
  if (!spinner) {
6786
6830
  writeSyncStatus(context, formatUpdateStartMessage(target));
@@ -7062,7 +7106,14 @@ class ToolManager {
7062
7106
  this.freshVerbs.add(verb);
7063
7107
  return;
7064
7108
  }
7065
- const location = await this.resolveInstallPath();
7109
+ const [locationError, location] = await catchError(this.resolveInstallPath());
7110
+ if (locationError instanceof InstallRefusedError) {
7111
+ logger.debug(`Tool freshness check skipped: ${locationError.message}`);
7112
+ this.freshVerbs.add(verb);
7113
+ return;
7114
+ }
7115
+ if (locationError)
7116
+ throw locationError;
7066
7117
  if (await isBundledDistribution(location.path)) {
7067
7118
  logger.debug("Tool freshness check skipped: Studio-bundled CLI distribution");
7068
7119
  this.freshVerbs.add(verb);
@@ -7104,7 +7155,8 @@ class ToolManager {
7104
7155
  spinner.text = `Installing ${packageSpec}…`;
7105
7156
  }
7106
7157
  const [installErr] = await catchError(toolService.install(packageSpec, location.path, {
7107
- global: location.global
7158
+ global: location.global,
7159
+ prefix: location.prefix
7108
7160
  }));
7109
7161
  if (installErr) {
7110
7162
  throw toolInstallFailedError(installed.toolName, packageSpec, installErr);
@@ -7249,12 +7301,25 @@ class ToolManager {
7249
7301
  }
7250
7302
  logger.debug(`Installing ${packageSpec} from ${candidate.registry ?? "the configured registry"} to ${location.path} (global: ${location.global})`);
7251
7303
  await toolService.install(packageSpec, location.path, {
7252
- global: location.global
7304
+ global: location.global,
7305
+ prefix: location.prefix
7253
7306
  });
7254
7307
  logger.info(`Installed ${packageSpec} successfully.`);
7308
+ await this.includeGlobalInstallDirectory(location);
7255
7309
  await this.refreshDiscovery();
7256
7310
  await this.recordUpdateDate(packageName.replace(/^@uipath\//, ""));
7257
7311
  }
7312
+ async includeGlobalInstallDirectory(location) {
7313
+ if (!location.global || location.prefix)
7314
+ return;
7315
+ if (await getEnvToolsDirsDeclaration())
7316
+ return;
7317
+ const globalToolsDir = await refreshGlobalNpmUipathDir();
7318
+ if (globalToolsDir && !this.toolsDirs.includes(globalToolsDir)) {
7319
+ this.toolsDirs.push(globalToolsDir);
7320
+ logger.debug(`Added global tool directory after install: ${globalToolsDir}`);
7321
+ }
7322
+ }
7258
7323
  async refreshDiscovery() {
7259
7324
  logger.debug(`Re-discovering tools in [${this.toolsDirs.join(", ")}]...`);
7260
7325
  this.discoveredTools = await discoverToolPaths(this.toolsDirs);
@@ -7364,14 +7429,23 @@ import { fileURLToPath } from "node:url";
7364
7429
  async function resolveToolsDirectories(context) {
7365
7430
  if (context.capabilities.isBrowser) {
7366
7431
  logger.debug("Browser mode — tools directory: /tools");
7367
- return { toolsDirs: ["/tools"], toolsDir: "/tools" };
7432
+ return {
7433
+ toolsDirs: ["/tools"],
7434
+ toolsDir: "/tools",
7435
+ hasHostDeclaration: false
7436
+ };
7368
7437
  }
7369
7438
  const currentFilePath = fileURLToPath(import.meta.url);
7370
7439
  const fs = getFileSystem();
7371
7440
  const toolsDirs = await resolveToolsDirs(currentFilePath, fs.env.cwd());
7372
7441
  const toolsDir = toolsDirs[0];
7442
+ const hasHostDeclaration = Boolean(await getEnvToolsDirsDeclaration());
7373
7443
  if (toolsDirs.length > 0) {
7374
- return { toolsDirs, toolsDir };
7444
+ return { toolsDirs, toolsDir, hasHostDeclaration };
7445
+ }
7446
+ if (hasHostDeclaration) {
7447
+ logger.warn(`${TOOLS_DIRS_ENV_VAR} names no usable tool directory; no tools are available.`);
7448
+ return { toolsDirs: [], toolsDir: undefined, hasHostDeclaration: true };
7375
7449
  }
7376
7450
  logger.warn("Unable to determine tools directory. Please ensure the CLI is installed correctly.");
7377
7451
  const { dirname, join } = fs.path;
@@ -7381,11 +7455,19 @@ async function resolveToolsDirectories(context) {
7381
7455
  const packageDir = dirname(execDir);
7382
7456
  const fallbackDir2 = dirname(packageDir);
7383
7457
  logger.debug(`Fallback (installed package): ${fallbackDir2}`);
7384
- return { toolsDirs: [fallbackDir2], toolsDir: fallbackDir2 };
7458
+ return {
7459
+ toolsDirs: [fallbackDir2],
7460
+ toolsDir: fallbackDir2,
7461
+ hasHostDeclaration: false
7462
+ };
7385
7463
  }
7386
7464
  const fallbackDir = join(dirname(currentFilePath), "..");
7387
7465
  logger.debug(`Fallback (development mode): ${fallbackDir}`);
7388
- return { toolsDirs: [fallbackDir], toolsDir: fallbackDir };
7466
+ return {
7467
+ toolsDirs: [fallbackDir],
7468
+ toolsDir: fallbackDir,
7469
+ hasHostDeclaration: false
7470
+ };
7389
7471
  }
7390
7472
 
7391
7473
  // cli.node.ts
@@ -7430,7 +7512,7 @@ async function buildNodeProgram(context) {
7430
7512
  return null;
7431
7513
  }
7432
7514
  const { program, cleanedArgs } = init;
7433
- const { toolsDirs, toolsDir } = await toolsDirsPromise;
7515
+ const { toolsDirs, toolsDir, hasHostDeclaration } = await toolsDirsPromise;
7434
7516
  registerConfigCommand(program, context);
7435
7517
  registerLoginCommand(program, context);
7436
7518
  registerLogoutCommand(program, context);
@@ -7444,7 +7526,7 @@ async function buildNodeProgram(context) {
7444
7526
  const toolManager = new ToolManager([], toolsDirs, resolveInstallPath, getCliVersionPrefix(), discoveredTools, context.args);
7445
7527
  setPackagerFactoryProvider((verb) => toolManager.ensurePackagerFactory(verb));
7446
7528
  setExecutorFactoryProvider((verb) => toolManager.ensureExecutorFactory(verb));
7447
- if (toolsDir) {
7529
+ if (toolsDir || hasHostDeclaration) {
7448
7530
  const [autoInstallError] = await catchError(autoInstallToolIfNeeded(context.args, program, toolManager, context));
7449
7531
  if (autoInstallError) {
7450
7532
  OutputFormatter.error({
@@ -7502,4 +7584,4 @@ async function runNodeInvocation(context) {
7502
7584
 
7503
7585
  export { runNode };
7504
7586
 
7505
- //# debugId=A4A81EB58587B10164756E2164756E21
7587
+ //# debugId=D34805C9ECBCF9A164756E2164756E21
@@ -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.242",
554
+ version: "1.203.0-preview.244",
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";
@@ -1481,7 +1577,7 @@ async function spawnPackageManager(executable, args, cwd, label, extraEnv) {
1481
1577
  }
1482
1578
  const { spawn } = await loadChildProcess();
1483
1579
  const isWindows = process.platform === "win32";
1484
- const envOpt = extraEnv ? { env: { ...process.env, ...extraEnv } } : {};
1580
+ const envOpt = extraEnv ? { env: mergeEnvCaseInsensitive(process.env, extraEnv) } : {};
1485
1581
  return new Promise((resolve, reject) => {
1486
1582
  let proc;
1487
1583
  if (isWindows) {
@@ -1526,6 +1622,35 @@ async function spawnPackageManager(executable, args, cwd, label, extraEnv) {
1526
1622
  });
1527
1623
  });
1528
1624
  }
1625
+ function mergeEnvCaseInsensitive(base, overrides) {
1626
+ const overridden = new Set(Object.keys(overrides).map((k) => k.toLowerCase()));
1627
+ const merged = {};
1628
+ for (const [key, value] of Object.entries(base)) {
1629
+ if (!overridden.has(key.toLowerCase()))
1630
+ merged[key] = value;
1631
+ }
1632
+ return { ...merged, ...overrides };
1633
+ }
1634
+ function prefixEnv(prefix) {
1635
+ if (prefix === undefined || prefix.trim() === "")
1636
+ return {};
1637
+ if (!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(prefix)) {
1638
+ throw new Error(`npm prefix must be an absolute path: ${prefix}`);
1639
+ }
1640
+ if (hasUnsafePathChars(prefix)) {
1641
+ throw new Error(`npm prefix contains unsupported characters: ${JSON.stringify(prefix)}`);
1642
+ }
1643
+ return { npm_config_prefix: prefix };
1644
+ }
1645
+ async function bunCwdFor(args, cwd, extraEnv) {
1646
+ const prefix = extraEnv?.npm_config_prefix;
1647
+ if (!prefix || !args.includes("-g"))
1648
+ return cwd;
1649
+ const root = npmGlobalRootParent(prefix);
1650
+ if (root !== cwd)
1651
+ await getFileSystem().mkdir(root);
1652
+ return root;
1653
+ }
1529
1654
  async function runPackageManager(args, cwd, extraEnv) {
1530
1655
  for (const arg of args) {
1531
1656
  if (arg !== "-g" && !arg.startsWith("--")) {
@@ -1534,9 +1659,10 @@ async function runPackageManager(args, cwd, extraEnv) {
1534
1659
  }
1535
1660
  const useBun = await isDevMode();
1536
1661
  const pm = useBun ? "bun" : "npm";
1537
- logger.debug(`Running package manager: ${pm} ${args.join(" ")}${cwd ? ` (cwd: ${cwd})` : ""}`);
1662
+ const runCwd = useBun ? await bunCwdFor(args, cwd, extraEnv) : cwd;
1663
+ logger.debug(`Running package manager: ${pm} ${args.join(" ")}${runCwd ? ` (cwd: ${runCwd})` : ""}`);
1538
1664
  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);
1665
+ await spawnPackageManager(pm, pmArgs, runCwd, `${pm} ${pmArgs[0]}`, extraEnv);
1540
1666
  }
1541
1667
  async function runPackageManagerWithBun(args, cwd, extraEnv) {
1542
1668
  for (const arg of args) {
@@ -1545,8 +1671,16 @@ async function runPackageManagerWithBun(args, cwd, extraEnv) {
1545
1671
  }
1546
1672
  }
1547
1673
  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);
1674
+ const bunCwd = await bunCwdFor(args, cwd, extraEnv);
1675
+ logger.debug(`Running package manager: bun ${pmArgs.join(" ")}${bunCwd ? ` (cwd: ${bunCwd})` : ""}`);
1676
+ await spawnPackageManager("bun", pmArgs, bunCwd, `bun ${pmArgs[0]}`, extraEnv);
1677
+ }
1678
+
1679
+ class HostOwnedToolError extends InstallRefusedError {
1680
+ constructor(packageName, dir) {
1681
+ 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.");
1682
+ this.name = "HostOwnedToolError";
1683
+ }
1550
1684
  }
1551
1685
 
1552
1686
  class NodeToolService {
@@ -1714,7 +1848,10 @@ ${errors.map((e) => ` - ${e}`).join(`
1714
1848
  validatePackageSpec(packageName);
1715
1849
  await refuseIfBundledDistribution(destination, "install", packageName);
1716
1850
  const baseArgs = options?.global ? ["install", "-g", packageName] : ["install", packageName];
1717
- const extraEnv = { ...archPinEnv() };
1851
+ const extraEnv = {
1852
+ ...archPinEnv(),
1853
+ ...options?.global ? prefixEnv(options.prefix) : {}
1854
+ };
1718
1855
  await warnIfTranslatedNodeAsync();
1719
1856
  for (let attempt = 0;attempt <= NPM_MAX_RETRIES; attempt++) {
1720
1857
  const [err] = await catchError(runPackageManager(baseArgs, destination, extraEnv));
@@ -1748,7 +1885,8 @@ ${errors.map((e) => ` - ${e}`).join(`
1748
1885
  let containerDir;
1749
1886
  let relativeName;
1750
1887
  if (options?.global) {
1751
- const globalUipathDir = await getGlobalNpmUipathDir();
1888
+ const declaration = options.prefix ? await getEnvToolsDirsDeclaration() : null;
1889
+ const globalUipathDir = declaration ? declaration.installTarget : await getGlobalNpmUipathDir();
1752
1890
  if (!globalUipathDir) {
1753
1891
  throw new Error(`Cannot locate '${packageName}': npm root -g unavailable`);
1754
1892
  }
@@ -1763,6 +1901,12 @@ ${errors.map((e) => ` - ${e}`).join(`
1763
1901
  throw new Error(`Refusing to uninstall '${packageName}': resolved path escapes ${containerDir}`);
1764
1902
  }
1765
1903
  if (!await fs.exists(packageDir)) {
1904
+ const declaration = options?.prefix ? await getEnvToolsDirsDeclaration() : null;
1905
+ for (const dir of declaration?.dirs.slice(1) ?? []) {
1906
+ if (await fs.exists(fs.path.join(dir, relativeName))) {
1907
+ throw new HostOwnedToolError(packageName, dir);
1908
+ }
1909
+ }
1766
1910
  throw new Error(`Package '${packageName}' is not installed at ${packageDir}`);
1767
1911
  }
1768
1912
  const [statError, stat] = await catchError(fs.stat(packageDir));
@@ -1772,7 +1916,7 @@ ${errors.map((e) => ` - ${e}`).join(`
1772
1916
  return;
1773
1917
  }
1774
1918
  if (options?.global) {
1775
- await runPackageManager(["uninstall", "-g", packageName], destination);
1919
+ await runPackageManager(["uninstall", "-g", packageName], destination, options.prefix ? prefixEnv(options.prefix) : undefined);
1776
1920
  } else {
1777
1921
  await runPackageManager(["uninstall", packageName], destination);
1778
1922
  }
@@ -9391,7 +9535,7 @@ async function runToolsUpdate(opts, state) {
9391
9535
  code: "LOCATION_ERROR",
9392
9536
  result: "ConfigError",
9393
9537
  message: locationError.message,
9394
- instructions: "Please ensure the CLI is installed correctly."
9538
+ instructions: locationError instanceof InstallRefusedError ? locationError.instructions : "Please ensure the CLI is installed correctly."
9395
9539
  }
9396
9540
  };
9397
9541
  }
@@ -9474,7 +9618,8 @@ async function runToolsUpdate(opts, state) {
9474
9618
  });
9475
9619
  const packageName = `${fullName}@${targetVersion}`;
9476
9620
  await toolService.install(packageName, location.path, {
9477
- global: location.global
9621
+ global: location.global,
9622
+ prefix: location.prefix
9478
9623
  });
9479
9624
  })());
9480
9625
  if (updateError) {
@@ -9719,6 +9864,6 @@ function getManualCommandForInstallError(error, fallback) {
9719
9864
  return error instanceof CliSelfUpdateError ? error.manualCommand : fallback;
9720
9865
  }
9721
9866
 
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 };
9867
+ 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
9868
 
9724
- //# debugId=8B198ABFFD03C8E164756E2164756E21
9869
+ //# debugId=93E9D846280936BD64756E2164756E21
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runNode
4
- } from "./index-rjbjph6e.js";
4
+ } from "./index-6er44ym0.js";
5
5
  import {
6
6
  registerRobotClientLoader
7
7
  } from "./index-982kyq65.js";
8
- import"./index-g6dsqejv.js";
8
+ import"./index-cyr9ff8r.js";
9
9
  import {
10
10
  TELEMETRY_DRAIN_ARGV,
11
11
  configureLogger,
@@ -84,7 +84,7 @@ async function executeCommand(command) {
84
84
  const previousSink = getOutputSink();
85
85
  setGlobalSink(sink);
86
86
  const [error] = await catchError(async () => {
87
- const { run } = await import("./cli-bggvxatc.js");
87
+ const { run } = await import("./cli-3mpvrbpj.js");
88
88
  await runWithAuthProfile(undefined, () => runWithSink(sink, () => run(context)));
89
89
  });
90
90
  if (error) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runUpdate
3
- } from "./index-g6dsqejv.js";
3
+ } from "./index-cyr9ff8r.js";
4
4
  import"./index-nab7xkhc.js";
5
5
  import"./index-g8ck9tv6.js";
6
6
  import"./index-hrt7fpkk.js";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/cli",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.203.0-preview.242",
5
+ "version": "1.203.0-preview.244",
6
6
  "description": "Cross platform CLI for UiPath",
7
7
  "repository": {
8
8
  "type": "git",
@@ -36,5 +36,5 @@
36
36
  "kerberos": "7.0.0",
37
37
  "node-expose-sspi": "0.1.60"
38
38
  },
39
- "gitHead": "6798cf60dddf5227322f180628facfe367be894e"
39
+ "gitHead": "dd3817d6673bc6c4ec409e86bdbf3db8037dbd0b"
40
40
  }