@uipath/functions-tool 1.0.0

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.
Files changed (3) hide show
  1. package/README.md +179 -0
  2. package/dist/tool.js +35457 -0
  3. package/package.json +49 -0
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # @uipath/functions-tool
2
+
3
+ UiPath CLI plugin for JS/TS and Python Functions. Installed as a tool in the `uip` CLI.
4
+
5
+ ## How it works
6
+
7
+ This package is a thin passthrough plugin. It does not contain build logic — it detects the project language and delegates every command to the appropriate language-specific CLI:
8
+
9
+ - **JS/TS projects** → `cliRunner(args)` from `@uipath/coded-functions-js-cli` — bundled into `dist/tool.js`, called in-process
10
+ - **Python projects** → `uipath <args>` (resolved from the codedagents-tool cache or PATH)
11
+
12
+ ### Architecture
13
+
14
+ ```
15
+ Studio Web publish (JS/TS)
16
+ → FunctionsTool.buildAsync() ← packager-tool-functions (browser packager)
17
+ → buildFunctionsPackage() ← shared library in @uipath/coded-functions-js-packager
18
+
19
+ Studio Web publish (Python) ← TODO: not yet implemented
20
+ → FunctionsTool.buildAsync() ← returns error; Python Functions team to implement
21
+ (see feat/functions-packager-wrapper)
22
+
23
+ CLI: uip functions pack (JS/TS)
24
+ → cliRunner(["pack"]) ← @uipath/coded-functions-js-cli (bundled into dist/tool.js)
25
+ → buildFunctionsPackage() ← same shared library, called in-process
26
+
27
+ CLI: uip functions pack (Python)
28
+ → uipath pack ← Python CLI subprocess, entirely separate
29
+ ```
30
+
31
+ ### Call chain
32
+
33
+ ```
34
+ uip functions <verb>
35
+ cli.ts:buildProgram()
36
+ discoverTools() → loads dist/tool.js via dynamic import
37
+ program.command("functions") → registerCommands(sub-program)
38
+ "setup" (hidden) → registerSetupCommand (runs natively, JS/TS only)
39
+ verifies Node ≥20 + tsx; does NOT install uipath-functions
40
+ anything else → command:* handler → runPassthrough(args)
41
+ init/new: ensureSetup() first (Node ≥20 + tsx, idempotent)
42
+ detectLanguage(cwd)
43
+ uipath.json functions map → JS or Python
44
+ fallback: package.json → JS, pyproject.toml → Python
45
+ unknown (fresh dir) → peek --language flag, default JS
46
+ JS/TS → cliRunner(args) from bundled @uipath/coded-functions-js-cli ← in-process
47
+ Python → spawn(uipath, args, { stdio: "inherit" })
48
+ process.exit(child exit code)
49
+ ```
50
+
51
+ ### Language detection
52
+
53
+ | Signal | Result |
54
+ |---|---|
55
+ | `uipath.json` functions map extension `.ts`/`.js` | javascript |
56
+ | `uipath.json` functions map extension `.py` | python |
57
+ | `package.json` present | javascript (fallback) |
58
+ | `pyproject.toml` present | python (fallback) |
59
+ | Neither (fresh directory) | peek `--language` arg; default javascript |
60
+
61
+ ## Commands
62
+
63
+ | Command | JS/TS → `uipath-functions` (in-process) | Python → `uipath` (spawn) |
64
+ |---|---|---|
65
+ | `uip functions new` | `new --name <n> [--empty]` — scaffold project | `uipath new <n> --type function` — scaffold in-place |
66
+ | `uip functions init` | ❌ not supported — use `new --empty` | `uipath init` — discover entrypoints, write entry-points.json etc. |
67
+ | `uip functions serve` | `serve` — hot-reload server | _(no equivalent — use `run`)_ |
68
+ | `uip functions run <name>` | `run <name>` — call local HTTP server | `uipath run <entrypoint>` — execute directly |
69
+ | `uip functions pack` | `pack` | `uipath pack` |
70
+ | `uip functions publish` | `publish` | `uipath publish` |
71
+ | `uip functions push` | `push` — sync to Studio Web | `uipath push` — sync to Studio Web |
72
+
73
+ > **Why `init` is Python-only:** Python's `pack` and `push` are dumb readers — they require
74
+ > `entry-points.json` / `bindings.json` / `project.uiproj` to already exist and will hard-fail
75
+ > otherwise. `uipath init` does the code introspection step that generates these files.
76
+ > JS/TS `pack` and `push` introspect inline via `tsx`, so no separate init step is needed.
77
+
78
+ > **Arg translation for Python:** `--language`/`-l` is dropped before forwarding (Python CLI has no such flag).
79
+ > `--name <n>` is converted to a positional argument (`uipath new <n>`).
80
+
81
+ > **`uip functions setup`** is hidden from help. JS/TS-only — verifies Node.js ≥20 and tsx.
82
+ > Called automatically before `new` is forwarded. Callable manually for repair: `uip functions setup [--force]`
83
+
84
+ ## Typical workflow
85
+
86
+ ```sh
87
+ # ── JS/TS project ────────────────────────────────────────────────────────────
88
+ uip functions new --name my-fn --language ts # scaffold + hello world; npm install runs automatically
89
+ uip functions new --name my-fn --empty # scaffold empty project (no sample function)
90
+ cd my-fn
91
+ uip functions serve # hot-reload server on :7070
92
+ uip functions run hello --input '{"x":1}' # invoke against local server
93
+ uip functions push # sync to Studio Web
94
+ uip functions pack && uip functions publish # deploy to Orchestrator
95
+
96
+ # ── Python project ───────────────────────────────────────────────────────────
97
+ # Prereq: uipath CLI installed (pip install uipath)
98
+
99
+ uip functions new --name my-fn --language py # scaffold in current directory + sample function
100
+ uip functions init # introspect code → entry-points.json, bindings.json, project.uiproj
101
+ # (required before pack/push; re-run whenever function signatures change)
102
+ uip functions run main '{"message":"hi"}' # run function directly (no server needed)
103
+ uip functions push # sync to Studio Web
104
+ uip functions pack && uip functions publish # deploy to Orchestrator
105
+
106
+ # ── After first command, --language is never needed again ────────────────────
107
+ # uipath.json is created with .ts/.py entries; detectLanguage reads it automatically
108
+ uip functions pack
109
+ uip functions publish
110
+ uip functions push
111
+ ```
112
+
113
+ ## Options
114
+
115
+ ### `uip functions new`
116
+ | Flag | Description | Applies to |
117
+ |---|---|---|
118
+ | `--name <name>` | Project name / directory (default: `my-functions`) | JS/TS |
119
+ | `--language <lang>` | `ts` (default), `js`, `py`, or `python` | both |
120
+ | `--empty` | Skip hello world — create an empty project | JS/TS |
121
+
122
+ > `--language` is a router flag consumed by `functions-tool`. It is never forwarded to either CLI.
123
+ > `--name` is forwarded to `uipath-functions` as `--name <n>` (JS/TS) or as a positional arg to `uipath new <n>` (Python).
124
+ > `--empty` is forwarded to `uipath-functions new --empty`. Has no effect for Python (Python `new` does not support it).
125
+
126
+ ### `uip functions init` _(Python only)_
127
+
128
+ No flags — forwards directly to `uipath init`. For JS/TS projects this command exits with an error and suggests `uip functions new --empty`.
129
+
130
+ ### `uip functions serve` _(JS/TS only)_
131
+ | Flag | Description |
132
+ |---|---|
133
+ | `--runtime <runtime>` | `node` (default) or `deno` |
134
+ | `--port <port>` | Port to listen on (default: `7070`) |
135
+
136
+ ### `uip functions run <name>`
137
+ | Flag | Description | Applies to |
138
+ |---|---|---|
139
+ | `--port <port>` | Port the local server is on (default: `7070`) | JS/TS |
140
+ | `--input <json>` | JSON input payload (default: `{}`) | JS/TS |
141
+ | positional `<input>` | JSON input string | Python (`uipath run <entrypoint> '<json>'`) |
142
+
143
+ ### `uip functions pack`
144
+ | Flag | Description | Applies to |
145
+ |---|---|---|
146
+ | `--nolock` | Exclude lock file from the package | JS/TS |
147
+
148
+ ### `uip functions publish`
149
+ | Flag | Description | Applies to |
150
+ |---|---|---|
151
+ | `--url <url>` | UiPath platform URL (or `UIPATH_URL` env) | JS/TS |
152
+ | `--org <org>` | Organization name (or `UIPATH_ORGANIZATION_NAME` env) | JS/TS |
153
+ | `--tenant <tenant>` | Tenant name (or `UIPATH_TENANT_NAME` env) | JS/TS |
154
+ | `--token <token>` | Access token (or `UIPATH_ACCESS_TOKEN` env) | JS/TS |
155
+ | `--feed-id <id>` | Feed ID — skips the interactive picker (CI use) | JS/TS |
156
+
157
+ > For Python, credentials are managed by the `uipath` Python CLI independently (via its own auth flow). The `--url/--org/--tenant/--token` flags are not forwarded to Python; run `uipath auth login` before using push/publish with Python projects.
158
+
159
+ ### `uip functions push`
160
+ | Flag | Description | Applies to |
161
+ |---|---|---|
162
+ | `--url <url>` | UiPath platform URL (or `UIPATH_URL` env) | JS/TS |
163
+ | `--project-id <id>` | Studio Web project ID — mandatory (or `UIPATH_PROJECT_ID` env) | JS/TS |
164
+ | `--org <org>` | Organization name (or `UIPATH_ORGANIZATION_NAME` env) | JS/TS |
165
+ | `--tenant <tenant>` | Tenant name (or `UIPATH_TENANT_NAME` env) | JS/TS |
166
+ | `--token <token>` | Access token (or `UIPATH_ACCESS_TOKEN` env) | JS/TS |
167
+
168
+ > For Python, credentials are managed by the `uipath` Python CLI independently — the `--url/--org/--tenant/--token/--project-id` flags are not forwarded. Run `uipath auth login` before using push with Python projects.
169
+
170
+ ## Known issues
171
+
172
+ - **`uip functions new --language py` scaffolds an agent instead of a function** when `uipath-langchain` is installed. Tracked in [uipath-python#1543](https://github.com/UiPath/uipath-python/issues/1543).
173
+
174
+ ## Cache files
175
+
176
+ | File | Contents |
177
+ |---|---|
178
+ | `~/.uipcli/.functions-tool-cache.json` | Cached Node.js path + version (written by `ensureSetup`) |
179
+ | `~/.uipcli/.codedagents-tool-cache.json` | Read to resolve Python `uipath` binary path |