@uipath/function-tool 1.202.0-preview.155 → 1.202.0-preview.157

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
@@ -1,192 +1,216 @@
1
1
  # @uipath/function-tool
2
2
 
3
- UiPath CLI plugin for JS/TS and Python Functions. Installed as a tool in the `uip` CLI.
3
+ Build, run, and ship UiPath Coded Functions from the command line. Adds the
4
+ `uip function` command group to the [uip CLI](https://www.npmjs.com/package/@uipath/cli),
5
+ for both JS/TS and Python projects.
4
6
 
5
- ## How it works
7
+ A Coded Function is a single typed function the UiPath platform can call — from
8
+ a Coded App, an agent, Maestro, or as a job. You write the handler, run it
9
+ locally until it does what you want, then publish it to Orchestrator or push it
10
+ into Studio Web.
6
11
 
7
- The CLI verbs are a thin passthrough. They contain no build logic — they detect the project language and delegate every command to the appropriate language-specific CLI:
12
+ ## Before you start
8
13
 
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)
14
+ | Project | Needs |
15
+ |---|---|
16
+ | JS/TS | Node.js 20 or later. The CLI checks this for you on `new`. |
17
+ | Python | The `uipath` Python CLI: `pip install uipath`, then `uipath auth login`. |
11
18
 
12
- Separately, this package owns the **solution packager factory** for the `Function`
13
- project type. `src/packager-tool.ts` registers `FunctionsToolFactory` from
14
- `@uipath/packager-tool-functions`, so `uip solution pack` on a solution containing
15
- a Functions project loads the packaging code from here rather than from
16
- `solution-tool`. That path does not shell out to either CLI — see below.
19
+ Everything else is installed for you.
17
20
 
18
- ### Architecture
21
+ ## Quick start — JS/TS
19
22
 
23
+ ```sh
24
+ uip function new my-fn # scaffold a TypeScript project + a hello function
25
+ cd my-fn
26
+ # edit functions/hello.ts
27
+ uip function run hello --input '{"name":"Ada"}'
20
28
  ```
21
- Solution pack (JS/TS + Python)
22
- → uip solution pack
23
- → ensurePackagerTools() → ensurePackagerFactory("function")
24
- → @uipath/function-tool/packager-tool ← registers FunctionsToolFactory
25
- → FunctionsTool.buildAsync() ← packager-tool-functions, in-process
26
- JS/TS → buildFunctionsPackage() ← @uipath/coded-functions-js-packager
27
- Python → buildPyFunctionsPackage() ← reads entry-points.json / uipath.json
28
-
29
- Studio Web publish
30
- → FunctionsTool.buildAsync() ← same packager-tool-functions (browser build)
31
-
32
- CLI: uip function pack (JS/TS)
33
- → cliRunner(["pack"]) ← @uipath/coded-functions-js-cli (bundled into dist/tool.js)
34
- → buildFunctionsPackage() ← same shared library, called in-process
35
-
36
- CLI: uip function pack (Python)
37
- → uipath pack ← Python CLI subprocess, entirely separate
29
+
30
+ `run` executes the function once and prints what it returned — no server, no
31
+ tenant. That is the fastest loop while you are writing the handler.
32
+
33
+ When you want a server that stays up and reloads on every save:
34
+
35
+ ```sh
36
+ uip function serve # http://localhost:7070, hot reload
38
37
  ```
39
38
 
40
- > `uip function pack` and the solution-pack path are two different code paths to a
41
- > package. The standalone verb forwards to the language CLI; solution pack runs
42
- > `packager-tool-functions` in-process, exactly as Studio Web does.
39
+ Then call it from a second terminal with whatever HTTP client you already use:
40
+
41
+ ```sh
42
+ curl -X POST http://localhost:7070/hello \
43
+ -H 'content-type: application/json' -d '{"name":"Ada"}'
44
+ ```
43
45
 
44
- ### Call chain
46
+ Then ship it:
45
47
 
48
+ ```sh
49
+ uip function pack # build the .nupkg
50
+ uip function publish # upload it to an Orchestrator feed
46
51
  ```
47
- uip function <verb> (also accepts the `functions` alias)
48
- cli.ts:buildProgram()
49
- discoverTools() → loads dist/tool.js via dynamic import
50
- program.command("function") → registerCommands(sub-program)
51
- "setup" (hidden) → registerSetupCommand (runs natively, JS/TS only)
52
- verifies Node ≥20 + tsx; does NOT install uipath-functions
53
- anything else → command:* handler → runPassthrough(args)
54
- init/new: ensureSetup() first (Node ≥20 + tsx, idempotent)
55
- detectLanguage(cwd)
56
- uipath.json functions map → JS or Python
57
- fallback: package.json → JS, pyproject.toml → Python
58
- unknown (fresh dir) → peek --language flag, default JS
59
- JS/TS → cliRunner(args) from bundled @uipath/coded-functions-js-cli ← in-process
60
- Python → spawn(uipath, args, { stdio: "inherit" })
61
- process.exit(child exit code)
52
+
53
+ or, to keep working on it in Studio Web:
54
+
55
+ ```sh
56
+ uip function push --project-id <studio-web-project-id>
62
57
  ```
63
58
 
64
- ### Language detection
59
+ ## Quick start — Python
65
60
 
66
- | Signal | Result |
67
- |---|---|
68
- | `uipath.json` functions map extension `.ts`/`.js` | javascript |
69
- | `uipath.json` functions map extension `.py` | python |
70
- | `package.json` present | javascript (fallback) |
71
- | `pyproject.toml` present | python (fallback) |
72
- | Neither (fresh directory) | peek `--language` arg; default javascript |
61
+ ```sh
62
+ uip function new my-fn --language py # scaffold into the current directory
63
+ uip function init # read your code, write the project files
64
+ uip function run main '{"message":"hi"}'
65
+ uip function pack && uip function publish
66
+ ```
67
+
68
+ `init` is the step to remember: Python's `pack` and `push` read
69
+ `entry-points.json`, `bindings.json`, and `project.uiproj` and fail if they are
70
+ missing. `init` generates them from your code, so re-run it whenever a function
71
+ signature changes. JS/TS needs no equivalent — it reads your types directly.
73
72
 
74
73
  ## Commands
75
74
 
76
- | Command | JS/TS → `uipath-functions` (in-process) | Python → `uipath` (spawn) |
75
+ | Command | What it does | Languages |
77
76
  |---|---|---|
78
- | `uip function new` | `new --name <n> [--empty]` — scaffold project | `uipath new <n> --type function` — scaffold in-place |
79
- | `uip function init` | ❌ not supported — use `new --empty` | `uipath init` — discover entrypoints, write entry-points.json etc. |
80
- | `uip function serve` | `serve` — hot-reload server | _(no equivalent — use `run`)_ |
81
- | `uip function run <name>` | `run <name>` — call local HTTP server | `uipath run <entrypoint>` — execute directly |
82
- | `uip function pack` | `pack` | `uipath pack` |
83
- | `uip function publish` | `publish` | `uipath publish` |
84
- | `uip function push` | `push` — sync to Studio Web | `uipath push` — sync to Studio Web |
77
+ | `new [name]` | Scaffold a project with a hello function | both |
78
+ | `init` | Read your code and write the project files | Python |
79
+ | `run [name]` | Execute one function once and print the result | both |
80
+ | `serve` | Start the local server with hot reload | JS/TS |
81
+ | `pack` | Build a `.nupkg` for deployment | both |
82
+ | `publish` | Upload the `.nupkg` to an Orchestrator feed | both |
83
+ | `push` | Sync the project into a Studio Web project | both |
84
+ | `runtime-install` | Prepare a runner folder — used by the platform, rarely by hand | JS/TS |
85
+
86
+ `uip functions` still works as an alias for `uip function`.
87
+
88
+ ### `new [name]`
85
89
 
86
- > **Why `init` is Python-only:** Python's `pack` and `push` are dumb readers — they require
87
- > `entry-points.json` / `bindings.json` / `project.uiproj` to already exist and will hard-fail
88
- > otherwise. `uipath init` does the code introspection step that generates these files.
89
- > JS/TS `pack` and `push` introspect inline via `tsx`, so no separate init step is needed.
90
+ ```sh
91
+ uip function new my-fn # TypeScript, with a hello function
92
+ uip function new my-fn --language js
93
+ uip function new my-fn --language py
94
+ uip function new my-fn --empty # no sample function (JS/TS)
95
+ ```
90
96
 
91
- > **Arg translation for Python:** `--language`/`-l` is dropped before forwarding (Python CLI has no such flag).
92
- > `--name <n>` is converted to a positional argument (`uipath new <n>`).
97
+ | Flag | Description |
98
+ |---|---|
99
+ | `--name <name>` | Same as the positional name. Defaults to `my-functions`. |
100
+ | `--language <lang>` | `ts` (default), `js`, `py`, or `python`. |
101
+ | `--empty` | Skip the hello function and scaffold an empty project (JS/TS). |
93
102
 
94
- > **`uip function setup`** is hidden from help. JS/TS-only — verifies Node.js ≥20 and tsx.
95
- > Called automatically before `new` is forwarded. Callable manually for repair: `uip function setup [--force]`
103
+ JS/TS scaffolds into a new `./<name>` directory and installs dependencies.
104
+ Python scaffolds into the current directory.
96
105
 
97
- ## Typical workflow
106
+ You only need `--language` for the first command in an empty directory. After
107
+ that the project files say which language it is.
108
+
109
+ ### `run [name]`
98
110
 
99
111
  ```sh
100
- # ── JS/TS project ────────────────────────────────────────────────────────────
101
- uip function new --name my-fn --language ts # scaffold + hello world; npm install runs automatically
102
- uip function new --name my-fn --empty # scaffold empty project (no sample function)
103
- cd my-fn
104
- uip function serve # hot-reload server on :7070
105
- uip function run hello --input '{"x":1}' # invoke against local server
106
- uip function push # sync to Studio Web
107
- uip function pack && uip function publish # deploy to Orchestrator
108
-
109
- # ── Python project ───────────────────────────────────────────────────────────
110
- # Prereq: uipath CLI installed (pip install uipath)
111
-
112
- uip function new --name my-fn --language py # scaffold in current directory + sample function
113
- uip function init # introspect code → entry-points.json, bindings.json, project.uiproj
114
- # (required before pack/push; re-run whenever function signatures change)
115
- uip function run main '{"message":"hi"}' # run function directly (no server needed)
116
- uip function push # sync to Studio Web
117
- uip function pack && uip function publish # deploy to Orchestrator
118
-
119
- # ── After first command, --language is never needed again ────────────────────
120
- # uipath.json is created with .ts/.py entries; detectLanguage reads it automatically
121
- uip function pack
122
- uip function publish
123
- uip function push
112
+ uip function run hello --input '{"name":"Ada"}'
113
+ uip function run hello --input-file ./payload.json
124
114
  ```
125
115
 
126
- ## Options
116
+ | Flag | Description |
117
+ |---|---|
118
+ | `--input <json>` | JSON payload. Defaults to `{}`. |
119
+ | `--input-file <path>` | Read the payload from a file. Wins over `--input`. JS/TS only. |
127
120
 
128
- ### `uip function new`
129
- | Flag | Description | Applies to |
130
- |---|---|---|
131
- | `--name <name>` | Project name / directory (default: `my-functions`) | JS/TS |
132
- | `--language <lang>` | `ts` (default), `js`, `py`, or `python` | both |
133
- | `--empty` | Skip hello world — create an empty project | JS/TS |
121
+ The name comes from your project's function list, which `pack`, `serve` and
122
+ `push` regenerate — so a function you have just written is not in it yet, and
123
+ one of those has to run before `run` can find it.
134
124
 
135
- > `--language` is a router flag consumed by `function-tool`. It is never forwarded to either CLI.
136
- > `--name` is forwarded to `uipath-functions` as `--name <n>` (JS/TS) or as a positional arg to `uipath new <n>` (Python).
137
- > `--empty` is forwarded to `uipath-functions new --empty`. Has no effect for Python (Python `new` does not support it).
125
+ Python takes the payload as a positional instead: `uip function run main '{"message":"hi"}'`.
138
126
 
139
- ### `uip function init` _(Python only)_
127
+ ### `serve`
140
128
 
141
- No flags — forwards directly to `uipath init`. For JS/TS projects this command exits with an error and suggests `uip function new --empty`.
129
+ ```sh
130
+ uip function serve
131
+ uip function serve --port 9000
132
+ ```
142
133
 
143
- ### `uip function serve` _(JS/TS only)_
144
134
  | Flag | Description |
145
135
  |---|---|
146
- | `--runtime <runtime>` | `node` (default) or `deno` |
147
- | `--port <port>` | Port to listen on (default: `7070`) |
136
+ | `--port <port>` | Port to listen on. Defaults to `7070`. |
137
+ | `--runtime <runtime>` | `node` (default) or `deno`. |
148
138
 
149
- ### `uip function run <name>`
150
- | Flag | Description | Applies to |
151
- |---|---|---|
152
- | `--port <port>` | Port the local server is on (default: `7070`) | JS/TS |
153
- | `--input <json>` | JSON input payload (default: `{}`) | JS/TS |
154
- | positional `<input>` | JSON input string | Python (`uipath run <entrypoint> '<json>'`) |
139
+ Saving a file reloads it. Each function is served at the HTTP method and path
140
+ it declares, so call it with any HTTP client:
155
141
 
156
- ### `uip function pack`
157
- | Flag | Description | Applies to |
158
- |---|---|---|
159
- | `--nolock` | Exclude lock file from the package | JS/TS |
142
+ ```sh
143
+ curl -X POST http://localhost:7070/hello \
144
+ -H 'content-type: application/json' -d '{"name":"Ada"}'
145
+ ```
160
146
 
161
- ### `uip function publish`
162
- | Flag | Description | Applies to |
163
- |---|---|---|
164
- | `--url <url>` | UiPath platform URL (or `UIPATH_URL` env) | JS/TS |
165
- | `--org <org>` | Organization name (or `UIPATH_ORGANIZATION_NAME` env) | JS/TS |
166
- | `--tenant <tenant>` | Tenant name (or `UIPATH_TENANT_NAME` env) | JS/TS |
167
- | `--token <token>` | Access token (or `UIPATH_ACCESS_TOKEN` env) | JS/TS |
168
- | `--feed-id <id>` | Feed ID — skips the interactive picker (CI use) | JS/TS |
147
+ Use `run` instead if you would rather not keep a server up.
169
148
 
170
- > 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.
149
+ ### `pack`
171
150
 
172
- ### `uip function push`
173
- | Flag | Description | Applies to |
174
- |---|---|---|
175
- | `--url <url>` | UiPath platform URL (or `UIPATH_URL` env) | JS/TS |
176
- | `--project-id <id>` | Studio Web project ID — mandatory (or `UIPATH_PROJECT_ID` env) | JS/TS |
177
- | `--org <org>` | Organization name (or `UIPATH_ORGANIZATION_NAME` env) | JS/TS |
178
- | `--tenant <tenant>` | Tenant name (or `UIPATH_TENANT_NAME` env) | JS/TS |
179
- | `--token <token>` | Access token (or `UIPATH_ACCESS_TOKEN` env) | JS/TS |
151
+ ```sh
152
+ uip function pack
153
+ ```
180
154
 
181
- > 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.
155
+ Writes the `.nupkg` that `publish` uploads. No flags, no auth.
182
156
 
183
- ## Known issues
157
+ ### `publish`
158
+
159
+ ```sh
160
+ uip function publish # pick the feed from a list
161
+ uip function publish --feed-id <id> # skip the picker, for CI
162
+ ```
184
163
 
185
- - **`uip function 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).
164
+ | Flag | Description |
165
+ |---|---|
166
+ | `--feed-id <id>` | Publish straight to this feed instead of prompting. |
167
+ | `--url <url>` | Platform URL, or `UIPATH_URL`. |
168
+ | `--org <org>` | Organization name, or `UIPATH_ORGANIZATION_NAME`. |
169
+ | `--token <token>` | Access token, or `UIPATH_ACCESS_TOKEN`. |
186
170
 
187
- ## Cache files
171
+ Uploads the most recently packed `.nupkg`, so run `pack` first. Without
172
+ `--feed-id` it lists the feeds you can publish to and prompts; ESC cancels.
188
173
 
189
- | File | Contents |
174
+ ### `push`
175
+
176
+ ```sh
177
+ uip function push --project-id <studio-web-project-id>
178
+ ```
179
+
180
+ | Flag | Description |
190
181
  |---|---|
191
- | `~/.uipcli/.function-tool-cache.json` | Cached Node.js path + version (written by `ensureSetup`) |
192
- | `~/.uipcli/.codedagents-tool-cache.json` | Read to resolve Python `uipath` binary path |
182
+ | `--project-id <id>` | Studio Web project to sync into, or `UIPATH_PROJECT_ID`. Required. |
183
+ | `--url <url>` | Platform URL, or `UIPATH_URL`. |
184
+ | `--org <org>` | Organization name, or `UIPATH_ORGANIZATION_NAME`. |
185
+ | `--token <token>` | Access token, or `UIPATH_ACCESS_TOKEN`. |
186
+
187
+ Uploads the files that changed, so it is safe to run repeatedly.
188
+
189
+ > **Python auth is separate.** The `uipath` Python CLI keeps its own login, so
190
+ > run `uipath auth login` before `publish` or `push`. For `push` specifically,
191
+ > `--url`, `--org`, `--tenant` and `--token` are not forwarded; `--project-id`
192
+ > is never forwarded for either verb, and Python resolves the project from its
193
+ > own config.
194
+
195
+ ## Troubleshooting
196
+
197
+ **"No Functions project detected in this directory."** You are not in a project
198
+ root. Change into the directory holding `uipath.json`, `package.json`, or
199
+ `pyproject.toml`, or pass `--language ts|js|py` to say which one you mean.
200
+
201
+ **"'init' is not applicable to JS/TS projects."** JS/TS has no init step. If you
202
+ wanted an empty project, that is `uip function new <name> --empty`.
203
+
204
+ **Node.js errors on `new` for a JS/TS project.** The CLI needs Node 20 or later
205
+ on your `PATH`. After installing it, `uip function setup --force` re-runs the
206
+ check.
207
+
208
+ **`run` cannot find a function you just added.** Names resolve through the
209
+ project's function list, which `run` never regenerates. Run
210
+ `uip function pack` once, or start `uip function serve`, to refresh it.
211
+
212
+ ## Known issues
213
+
214
+ - **`uip function new --language py` scaffolds an agent instead of a function**
215
+ when `uipath-langchain` is installed. Tracked in
216
+ [uipath-python#1543](https://github.com/UiPath/uipath-python/issues/1543).
@@ -5,12 +5,44 @@ compiled into its `dist/` output rather than installed alongside it.
5
5
  Their licences and copyright notices are reproduced here in full, as
6
6
  those licences require.
7
7
 
8
- 1 bundled dependency:
8
+ 2 bundled dependencies:
9
9
 
10
+ - commander@14.0.3 — MIT
10
11
  - fflate@0.8.3 — MIT
11
12
 
12
13
  ---
13
14
 
15
+ ## commander@14.0.3
16
+
17
+ SPDX: MIT
18
+
19
+ ```
20
+ (The MIT License)
21
+
22
+ Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
23
+
24
+ Permission is hereby granted, free of charge, to any person obtaining
25
+ a copy of this software and associated documentation files (the
26
+ 'Software'), to deal in the Software without restriction, including
27
+ without limitation the rights to use, copy, modify, merge, publish,
28
+ distribute, sublicense, and/or sell copies of the Software, and to
29
+ permit persons to whom the Software is furnished to do so, subject to
30
+ the following conditions:
31
+
32
+ The above copyright notice and this permission notice shall be
33
+ included in all copies or substantial portions of the Software.
34
+
35
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
36
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
38
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
39
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
40
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
41
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42
+ ```
43
+
44
+ ---
45
+
14
46
  ## fflate@0.8.3
15
47
 
16
48
  SPDX: MIT
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  cliRunner,
3
3
  generateManifests
4
- } from "./packager-tool-3hvc4zcd.js";
5
- import"./packager-tool-1bx83sw4.js";
4
+ } from "./packager-tool-sdc3wrcd.js";
5
+ import"./packager-tool-1de529jm.js";
6
6
  export {
7
7
  cliRunner,
8
8
  generateManifests
@@ -0,0 +1,39 @@
1
+ import { createRequire } from "node:module";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ if (mod && typeof mod === "object" || typeof mod === "function") {
23
+ for (let key of __getOwnPropNames(mod))
24
+ if (!__hasOwnProp.call(to, key))
25
+ __defProp(to, key, {
26
+ get: __accessProp.bind(mod, key),
27
+ enumerable: true
28
+ });
29
+ }
30
+ if (canCache)
31
+ cache.set(mod, to);
32
+ return to;
33
+ };
34
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
35
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
36
+
37
+ export { __toESM, __commonJS, __require };
38
+
39
+ //# debugId=4A15A0D6FCDB684764756E2164756E21