Skip to content

Fix uipath-project-discovery-agent: avoid cmd.exe/PowerShell dependency when invoking uip CLI - #2425

Open
nsandrosBDO wants to merge 1 commit into
UiPath:mainfrom
nsandrosBDO:fix/discovery-agent-avoid-shell-cli-invocation
Open

Fix uipath-project-discovery-agent: avoid cmd.exe/PowerShell dependency when invoking uip CLI#2425
nsandrosBDO wants to merge 1 commit into
UiPath:mainfrom
nsandrosBDO:fix/discovery-agent-avoid-shell-cli-invocation

Conversation

@nsandrosBDO

Copy link
Copy Markdown

Problem

uipath-project-discovery-agent (skills/uipath-rpa/agents/uipath-project-discovery-agent.md) declares tools: Bash, Read, Glob, Grep and, in its workflow, shells out directly to the uip CLI:

  • Step 1 ("Locate the Project"): uip rpa list-instances --format json
  • "UILibrary NuGet Packages" discovery step: uip rpa inspect-package --package-name <PackageName>

On Windows, the globally-installed uip command resolves to a uip.cmd/uip.ps1 shell wrapper that npm generates around the CLI's real Node.js entry point (@uipath/cli on npm declares "bin": { "uip": "dist/index.js" }). Invoking uip ... through the Bash tool therefore requires spawning cmd.exe or powershell.exe to interpret that wrapper script.

In hosts/environments where direct shell-interpreter execution (cmd.exe/PowerShell) is restricted or blocked by policy, these steps fail outright — even though the underlying uip CLI is itself a plain Node.js program with no OS-shell dependency at all.

Fix

  • Added an "Invoking the uip CLI" section documenting that any uip functionality this agent needs should be run by resolving the CLI's Node.js entry point (@uipath/cli's dist/index.js, via an env var override, local node_modules, or the global npm root) and invoking it directly with node <entry.js> <args> — never through the uip/uip.cmd/uip.ps1 shell wrapper.
  • Made Step 1's Studio Desktop instance lookup (rpa list-instances) explicitly best-effort: if the CLI entry can't be resolved/invoked (no Node reachable, no Bash tool, blocked shell, etc.), the agent skips it and falls back to the explicit path / current working directory instead of failing.
  • Applied the same graceful-skip treatment to the UILibrary NuGet package inspection step (rpa inspect-package) — it's an optional enhancement, not a hard requirement, and now degrades to just recording the package name/version from project.json.
  • Added a short caveat to the generated "Quick Reference" section clarifying that its example uip commands are for humans/other tooling, not something the discovery agent itself depends on for shell access.

Why this matters

Some hosts/orgs restrict direct cmd.exe/powershell.exe execution by AI agents for security reasons. Since uip is fundamentally a Node.js CLI, the agent doesn't need a shell interpreter at all to use it — it only needed one because of how npm's global bin shims work on Windows. This change removes that unnecessary hard dependency while keeping full functionality when a shell/Node path is available, and degrading gracefully (rather than failing) when it isn't.

This mirrors an existing working pattern from a downstream UiPath coded-app project, which already resolves @uipath/uipath-ts-cli's dist/cli.js and invokes it via node/process.execPath directly (shell: false) instead of through the uip/.cmd/.ps1 wrapper.

Scope

Documentation-only change (the "agent" is an LLM subagent prompt, not executable code) — no build/tests apply.

The uip CLI's global `uip` command resolves to a `uip.cmd`/`uip.ps1`
shell wrapper on Windows that npm generates around the real Node.js
entry point (@uipath/cli, bin -> dist/index.js). Invoking `uip ...`
from the Bash tool therefore requires spawning cmd.exe or PowerShell
to interpret that wrapper, which fails in environments where direct
shell-interpreter execution is restricted or blocked, even though the
underlying CLI is itself Node.js.

Add guidance to resolve and invoke the CLI's Node entry point directly
via `node <entry.js> ...` instead of the `uip`/`uip.cmd`/`uip.ps1`
wrapper, and make the two shell-dependent discovery steps (locating an
open Studio Desktop instance, inspecting UILibrary packages) best-
effort so discovery degrades gracefully instead of failing when no
shell/Node invocation path is available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant