@uipath/function-tool 1.200.0-preview.118
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 +192 -0
- package/dist/packager-tool-37x76zdn.js +6 -0
- package/dist/packager-tool.js +2291 -0
- package/dist/tool.js +200145 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @uipath/function-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
|
+
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:
|
|
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
|
+
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.
|
|
17
|
+
|
|
18
|
+
### Architecture
|
|
19
|
+
|
|
20
|
+
```
|
|
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
|
|
38
|
+
```
|
|
39
|
+
|
|
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.
|
|
43
|
+
|
|
44
|
+
### Call chain
|
|
45
|
+
|
|
46
|
+
```
|
|
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)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Language detection
|
|
65
|
+
|
|
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 |
|
|
73
|
+
|
|
74
|
+
## Commands
|
|
75
|
+
|
|
76
|
+
| Command | JS/TS → `uipath-functions` (in-process) | Python → `uipath` (spawn) |
|
|
77
|
+
|---|---|---|
|
|
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 |
|
|
85
|
+
|
|
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
|
+
|
|
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>`).
|
|
93
|
+
|
|
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]`
|
|
96
|
+
|
|
97
|
+
## Typical workflow
|
|
98
|
+
|
|
99
|
+
```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
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Options
|
|
127
|
+
|
|
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 |
|
|
134
|
+
|
|
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).
|
|
138
|
+
|
|
139
|
+
### `uip function init` _(Python only)_
|
|
140
|
+
|
|
141
|
+
No flags — forwards directly to `uipath init`. For JS/TS projects this command exits with an error and suggests `uip function new --empty`.
|
|
142
|
+
|
|
143
|
+
### `uip function serve` _(JS/TS only)_
|
|
144
|
+
| Flag | Description |
|
|
145
|
+
|---|---|
|
|
146
|
+
| `--runtime <runtime>` | `node` (default) or `deno` |
|
|
147
|
+
| `--port <port>` | Port to listen on (default: `7070`) |
|
|
148
|
+
|
|
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>'`) |
|
|
155
|
+
|
|
156
|
+
### `uip function pack`
|
|
157
|
+
| Flag | Description | Applies to |
|
|
158
|
+
|---|---|---|
|
|
159
|
+
| `--nolock` | Exclude lock file from the package | JS/TS |
|
|
160
|
+
|
|
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 |
|
|
169
|
+
|
|
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.
|
|
171
|
+
|
|
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 |
|
|
180
|
+
|
|
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.
|
|
182
|
+
|
|
183
|
+
## Known issues
|
|
184
|
+
|
|
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).
|
|
186
|
+
|
|
187
|
+
## Cache files
|
|
188
|
+
|
|
189
|
+
| File | Contents |
|
|
190
|
+
|---|---|
|
|
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 |
|