@uipath/cartographer-cli 0.0.0-stage → 1.207.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 (4) hide show
  1. package/LICENSE +204 -0
  2. package/README.md +648 -2
  3. package/dist/cli.mjs +2 -0
  4. package/package.json +31 -4
package/README.md CHANGED
@@ -1,3 +1,649 @@
1
- # Temporary Holding Version
1
+ # @uipath/cartographer-cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Document how work happens with the UiPath Cartographer agent from the terminal — interview, map a process, write its PDD and SDD, share its Map of Work, all without the desktop app. A thin wrapper over `@uipath/delegate-sdk` (installed automatically as a dependency): the SDK owns the agent, interop, login, and host machinery; this package owns the terminal surface.
4
+
5
+ `cartographer-cli` is `@uipath/delegate-cli` as a Cartographer engagement, what `delegate-cli --cartographer` was. Every session runs as the Cartographer vertical (its prompt, and the Map of Work of the `--project` folder) without computer use, with the desktop app's business-analysis skills preloaded: `business-analysis`, `project-task-list`, `knowledge-base`, `source-coverage` and `note-taker`. It adds the `export` and `maps` commands. Pair a run with `--project` / `--working-dir` to say where the engagement's files live; extra `--preload-skill` flags add skills, and one already preloaded is not preloaded twice. It uses the same saved login as delegate-cli (`~/.aria/sdk-auth.json`).
6
+
7
+ Two other CLIs have the same commands and flags (without `export` and `maps`), on another agent, and use that same saved login:
8
+
9
+ - [`@uipath/delegate-cli`](https://www.npmjs.com/package/@uipath/delegate-cli) (`delegate-cli`) drives the UiPath Delegate agent, with computer use and UI automation.
10
+ - [`@uipath/autopilot-cli`](https://www.npmjs.com/package/@uipath/autopilot-cli) (`autopilot-cli`) answers as the UiPath Autopilot agent, without Delegate's desktop UI-automation guidance.
11
+
12
+ - **Platforms**: macOS arm64, Windows x64, Linux x64. Linux is text-only — run with `--headless`.
13
+
14
+ ---
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install @uipath/cartographer-cli
20
+ ```
21
+
22
+ npm pulls the CLI, the SDK, and your platform's runtime package (Mac arm64, Win x64, or Linux x64).
23
+
24
+ ## Quick start
25
+
26
+ ```bash
27
+ npx cartographer-cli login --env production # once — browser OAuth → ~/.aria/sdk-auth.json
28
+ npx cartographer-cli # start a conversation
29
+ npx cartographer-cli --project invoice-approval "Help me capture our invoice approval process." # optional first message
30
+ npx cartographer-cli --print "summarize this process" # one turn, then exit
31
+ ```
32
+
33
+ Commands default to the cloud you logged into; `--env` / `--backend` override per command. There is no hardcoded environment — with no saved login and no `--env`/`--backend`, commands error rather than guess.
34
+
35
+ If the access token expires mid-session in a TTY, the CLI opens the browser, re-logs in, and retries the prompt automatically in the same session.
36
+
37
+ ---
38
+
39
+ ## CLI
40
+
41
+ ```
42
+ cartographer-cli [flags] ["<prompt>"] Start a conversation in a terminal
43
+ cartographer-cli --print "<prompt>" Run one turn and exit (-p is shorthand)
44
+ cartographer-cli [flags] - Read one prompt from stdin through EOF, then exit
45
+ Piped stdin also implies one-turn mode
46
+ Explicit `-` waits for EOF; the implicit form gives up after 2 s
47
+ of silence so a missing prompt errors instead of hanging
48
+ cartographer-cli -p "<prompt>" --output-format json|stream-json
49
+ One turn, JSON-only stdout (result object, or NDJSON
50
+ events then the result); exit 1 when the turn fails
51
+ cartographer-cli login [--env NAME | --url BASE] [--tenant NAME]
52
+ OAuth browser login (--env or --url required on FIRST
53
+ login; afterwards defaults to the saved login's
54
+ deployment; --tenant picks a tenant by name, otherwise
55
+ a re-login keeps the saved tenant)
56
+ cartographer-cli tenant [NAME] List the organization's tenants, or switch the saved
57
+ login to NAME — no browser round-trip
58
+ cartographer-cli logout Remove the saved CLI login
59
+ cartographer-cli whoami Show the current login (org, tenant, token expiry)
60
+ cartographer-cli models [--env NAME] List LLM models available on the tenant, with
61
+ any BYO configuration warning per model
62
+ cartographer-cli sessions [list] [--page N] [--limit N] [--include-subagents]
63
+ List your backend chat sessions, most recently
64
+ active first
65
+ cartographer-cli sessions show|delete ID Show one session's title and owner, or delete it
66
+ with its messages and sub-agents (no prompt)
67
+ cartographer-cli sessions rename ID TITLE
68
+ Rename a session (1-500 characters)
69
+ cartographer-cli sessions cancel ID --turn TURN
70
+ Cancel turn TURN running on session ID in another
71
+ process; exits 1 when no such turn is in progress
72
+ cartographer-cli sessions fork ID [MESSAGE]
73
+ Copy session ID into a new session, up to and
74
+ including message MESSAGE (default: all of it)
75
+ cartographer-cli check [--env NAME] [--headless]
76
+ Verify auth, backend readiness, backend and
77
+ interop without sending a prompt; exits 1 when
78
+ any check fails
79
+ cartographer-cli usage [--session ID] Quota and spend: licensing quota, monthly spend and
80
+ cap
81
+ cartographer-cli usage activity|daily [--days N]
82
+ Activity totals, or per-day usage, over the last N
83
+ days (1-365, default 30)
84
+ cartographer-cli evaluate|rerank|verify FILE|- [--model ID]
85
+ Stateless typed judgments: POST the JSON request in
86
+ FILE (or stdin) to /v1/completions/<command> and print
87
+ the answers; exits 1 when the backend rejects it
88
+ cartographer-cli complete --json-schema FILE [--model ID] [--session ID] "<prompt>"|-
89
+ One structured completion, no agent turn: print the
90
+ JSON object matching the schema in FILE; exits 1
91
+ when the output fails the schema (422)
92
+ cartographer-cli --json-schema FILE "<prompt>"
93
+ One turn, then its result extracted as JSON matching
94
+ the schema in FILE; exits 1 when extraction fails
95
+ cartographer-cli transcribe FILE|- Speech-to-text (transcription model): print the text of the audio
96
+ in FILE (or stdin with -)
97
+ cartographer-cli export TYPE [DOCUMENT_ID] --project ID [--working-dir PATH]
98
+ A project's living document (pdd, sdd, ...) to .docx
99
+ from the local disk: no login or interop
100
+ cartographer-cli maps share --project ID --remote URL|PATH --map-name NAME [--working-dir PATH]
101
+ Share a project's Map of Work to a bare git repository
102
+ (file:// URL or absolute path), as the desktop app's
103
+ Share does; no login or interop. See Sharing a Map of Work
104
+ cartographer-cli maps save-version MESSAGE --project ID [--working-dir PATH]
105
+ Save version: the map's next 0.x (0.1.0 first)
106
+ cartographer-cli org-users QUERY Search your organization's users by name or email
107
+ prefix, for delegations create --to
108
+ cartographer-cli delegations create --session ID [--to WHO] [--summary TEXT] "<task>"|-
109
+ Hand a task to a colleague (or print a claimable link)
110
+ cartographer-cli delegations pending|list|show|claim|complete|accept|dismiss|cancel|delete ...
111
+ Follow a delegation through; see Delegating to people
112
+ cartographer-cli host [flags] Run this PC as a remote worker until Ctrl+C
113
+ cartographer-cli host install [flags] Auto-start the host at login (macOS/Windows)
114
+ cartographer-cli host uninstall Remove auto-start
115
+ cartographer-cli host status Show auto-start state
116
+ cartographer-cli --cleanup Stop the running interop service
117
+ cartographer-cli --version
118
+ cartographer-cli --help
119
+ ```
120
+
121
+ ### Conversations and one-turn mode
122
+
123
+ When both stdin and stdout are terminals, the CLI starts an interactive conversation. An optional prompt is sent first; otherwise it waits at `You> `. Enter sends a message, blank lines are ignored, and replies run sequentially in the same session. Each entered line is a separate message; use piped input or `-` for a multiline prompt.
124
+
125
+ In a conversation the agent can also ask structured questions (its AskUser tool), as it does in the Delegate app. The CLI prints each question with numbered choices and waits for your answer before the turn goes on: type a number (several, separated by commas, where more than one choice is allowed), your own answer where the question offers one, or a value for each slider. Press Enter to skip a question; on a slider, Enter takes the value shown in the prompt instead, so a slider question is always answered. The CLI cannot attach a file or recording to an answer. A one-turn run (`--print`, a JSON format, piped input) has nobody to answer, so the agent gets no AskUser there and asks in its reply instead.
126
+
127
+ Use `/exit` or EOF (Ctrl+D on an empty input line) to finish. EOF lets an active turn finish before exiting, except at an AskUser question, where it stops the turn as Ctrl+C does. Ctrl+C stops the CLI and exits with code 130; during a turn it first cancels the turn on the backend too (see [Cancelling a turn](#cancelling-a-turn)), so the turn does not keep running server-side; during initialization it waits for setup to settle before cleaning up. A second Ctrl+C forces immediate exit. The SDK and interop are cleaned up on exit, subject to `--keep-alive`.
128
+
129
+ `--print` / `-p` sends one prompt and exits after the response and any tool execution. This mode is also automatic when stdin **or** stdout is not a terminal, or when the prompt is `-`. Piped lines form one prompt, not separate turns. Missing input in one-turn mode exits with code 2.
130
+
131
+ One-turn runs use the SDK's tool approval policy. Permissions set to **Ask** are approved automatically. The agent can perform Integration Service writes during the turn, including creating a draft. The agent can still write when asked for a preview. Automation Ops blocks prevent the corresponding tool calls.
132
+
133
+ The CLI prints the session ID to stderr when a session starts. Resume later with `cartographer-cli --session <id>`, or send one follow-up with `cartographer-cli --print --session <id> "..."`. Repeat the desired project, working-directory, model and tool options when starting a new invocation. The SDK reuses the session; the backend stores conversation history. A project ID shares local files but does not preserve the conversation by itself. Fatal errors exit after cleanup; the session ID can be used to resume.
134
+
135
+ Assistant responses go to stdout; terminal prompts, session IDs and progress go to stderr. `--verbose` additionally puts SDK diagnostics on stdout (on stderr under `--output-format json | stream-json`).
136
+
137
+ ### Machine-readable output (`--output-format`)
138
+
139
+ ```bash
140
+ cartographer-cli -p "Summarise my inbox" --output-format text # default: the answer as text
141
+ cartographer-cli -p "Summarise my inbox" --output-format json # one JSON object on exit
142
+ cartographer-cli -p "Summarise my inbox" --output-format stream-json # NDJSON: one event per line, then the result
143
+ ```
144
+
145
+ Under `json` and `stream-json`, **stdout carries only JSON**, one value per line. Everything else the process would print there — SDK and framework logs, `--verbose` diagnostics, `--help` text — is redirected to stderr, together with the backend line, progress and errors. Both formats imply `--print`: they run exactly one turn and never open the interactive conversation, even in a terminal. A missing prompt is still a usage error (exit 2, nothing on stdout).
146
+
147
+ `json` prints one result object when the turn ends:
148
+
149
+ ```json
150
+ {"type":"result","sessionId":"4f0c…","text":"You have 3 unread emails…","isError":false,"usage":{"promptTokens":18342,"completionTokens":611,"promptTokensCached":15020,"cacheCreationTokens":0,"turnTokenUnits":0,"rounds":3},"toolCalls":2,"durationMs":14873}
151
+ ```
152
+
153
+ | Field | Meaning |
154
+ |---|---|
155
+ | `sessionId` | Session the turn ran in — pass it to `--session` to continue. `null` if the run failed before a session existed. |
156
+ | `turnId` | Backend id of the turn's last round (see `turn_start` below). Absent when none was announced, e.g. the run failed before the stream opened. |
157
+ | `text` | The turn's final answer (for a failed turn, the error text). |
158
+ | `isError` | `true` when the turn failed: it threw, it ended on an agent error, or the CLI failed before the turn (auth, backend URL, initialize). |
159
+ | `error` | Why it failed. Present only when `isError` is `true`. |
160
+ | `usage` | Token usage **summed over every backend round of the turn** (a turn that runs tools calls the backend once per step); `rounds` is how many were summed. `null` when the backend reported none. |
161
+ | `toolCalls` | Distinct tool calls the turn made. |
162
+ | `durationMs` | Wall-clock duration of the turn, not counting startup and sign-in. |
163
+ | `structured` | With `--json-schema`: the object extracted from the turn. See [Structured output from a prompt](#structured-output-from-a-prompt---json-schema). |
164
+ | `structuredError` | With `--json-schema`: `{"message","reason","status"}` when the extraction failed (exit 1). |
165
+
166
+ `stream-json` writes every agent event as it happens — `session_start`, `turn_start`, `thinking`, `message`, `tool_call`, `tool_result`, `error`, `done` — with the same fields the SDK's `AgentEvent` carries, then the same result object as its last line. `message` and `thinking` events are streamed deltas: concatenate their `content`. `turn_start` carries the backend `turnId` another process passes to `cartographer-cli sessions cancel <sessionId> --turn <turnId>` (see [Cancelling a turn](#cancelling-a-turn)); each backend round of the turn (one per tool-result round trip) has its own id, so cancel with the latest.
167
+
168
+ ### Steering a running turn (`--input-format stream-json`)
169
+
170
+ Like `claude -p --input-format stream-json`, the CLI can keep reading standard input while it works. Run it with `--input-format stream-json --output-format stream-json` and no prompt argument; each stdin line is one user message:
171
+
172
+ ```json
173
+ {"type":"user","message":{"role":"user","content":"also add tests"},"uuid":"steer-1"}
174
+ ```
175
+
176
+ The first line is the prompt. Every later line steers the turn in flight the way the app's Steer button does: the message is queued, moved to the front, and the running turn is stopped, so the agent continues in the same session with it (a tool call in flight is interrupted). With `--replay-user-messages` each steering message is echoed on stdout (`"isReplay":true`, same `uuid`) when the agent takes it, which is how a caller knows it was read. The result line is the last turn's answer. A malformed line is reported on stderr and skipped; a message that arrives after the turn ended is reported as not read; end of input does not end the turn.
177
+
178
+ ```json
179
+ {"type":"session_start","sessionId":"4f0c…"}
180
+ {"type":"turn_start","sessionId":"4f0c…","turnId":"9b2e…"}
181
+ {"type":"tool_call","toolName":"ReadFile","toolId":"call_1","toolArgs":{"path":"inbox.md"}}
182
+ {"type":"tool_result","toolName":"ReadFile","toolId":"call_1","toolResult":"…","toolStatus":"completed"}
183
+ {"type":"message","content":"You have 3 "}
184
+ {"type":"message","content":"unread emails…"}
185
+ {"type":"done","sessionId":"4f0c…"}
186
+ {"type":"result","sessionId":"4f0c…","text":"You have 3 unread emails…","isError":false,"usage":{…},"toolCalls":1,"durationMs":9120}
187
+ ```
188
+
189
+ The same shapes are exported by the SDK (`agentEventToJsonLine`, `runTurnForResult`, `TurnResult`), so a program driving `DelegateAgent` directly can produce identical output.
190
+
191
+ Every subcommand that prints a result honours the flag too, printing one JSON value; `login`, `logout`, `tenant` and `host` refuse it with exit 2:
192
+
193
+ - `models`: the model array (`[{"id":"claude_sonnet_5_5","name":"Claude Sonnet 5.5"}, …]`, `[]` when none). Entries carry the SDK `ModelInfo` fields the backend sent (`description`, `locked`, `lockReason`, …), and a model with a BYO configuration gap also carries `byoWarning`.
194
+ - `whoami`: the identity (`source`, `baseUrl`, `deployment`, `organization`, `tenant`, `tokenExpiresAt` — never a token).
195
+ - `check`: the health result (`{"ok":…,"checks":[{"name","status","detail"}]}`), one entry each for `auth`, `readiness`, `backend` and `interop`.
196
+ - `sessions`: the page (`{"sessions":[{"id","title","createdAt","updatedAt","parentSessionId","storageMode","productId","projectId","metadata"}],"page":1,"pageSize":30,"isLastPage":true}`).
197
+ - `sessions show|rename|delete <id>`: `{"id","title","userId","organizationId","delegationId"}`, `{"id","title"}` and `{"id","deleted":true}`. See [Managing one session](#managing-one-session).
198
+ - `sessions cancel`: the outcome (`{"sessionId","turnId","cancelled":true}`; `cancelled: false` also exits 1).
199
+ - `sessions fork`: the new session, in the same shape as a `sessions` row. See [Forking a session](#forking-a-session).
200
+ - `usage`: the quota summary or the activity/daily report (see [Quota and spend](#quota-and-spend)).
201
+ - `evaluate` / `rerank` / `verify`: the backend response unchanged (see [Typed judgments](#typed-judgments-evaluate-rerank-verify)).
202
+ - `complete`: `{"structured":{…},"usage":{…}|null}` (see [Structured completion](#structured-completion-complete)).
203
+ - `transcribe`: the backend response, `{"text":"…"}` (see [Speech-to-text](#speech-to-text-transcribe)).
204
+ - `org-users`: `[{"userId","displayName","email"}]`.
205
+ - `delegations`: the SDK result of the action — `list` a `Delegation` array, `pending` `{"delegation","pendingResults"}`, `show` the briefing, `create` `{"delegationId","deliveryMode","deepLink","assignedUser","sourceMessageId"}`, `claim` the briefing plus `sessionId`, `complete` `{"delegationId","alreadyCompleted"}`, `accept` `{"delegationId","messageId","alreadyAccepted"}`, and `{"delegationId","dismissed"|"cancelled"|"deleted":true}` (see [Delegating to people](#delegating-to-people-delegations-org-users)).
206
+
207
+ Exit codes:
208
+
209
+ | Code | When |
210
+ |---|---|
211
+ | 0 | Success. |
212
+ | 1 | The turn ended in error (`isError: true`); a `--json-schema` extraction failed (`structuredError`); `check` found a failing check; the backend rejected an `evaluate` / `rerank` / `verify` / `complete` / `transcribe` request; any other runtime failure. |
213
+ | 2 | Usage error — unknown flag, bad `--output-format` or `--days` value, unknown `usage` view, missing prompt, audio `transcribe` refuses before uploading. Nothing is written to stdout. |
214
+ | 130 | Interrupted with Ctrl+C. |
215
+
216
+ ### Managing one session
217
+
218
+ `sessions show|rename|delete <id>` act on one backend session by id, through the SDK's `getSession`, `renameSession` and `deleteSession`:
219
+
220
+ - `show <id>` prints the title, the owner's user id and organization, and the delegation id of a session claimed from a delegation link. A session another user shared in your organization is shown too. Use `sessions` for timestamps and sub-agent links.
221
+ - `rename <id> <title>` sets the title. Everything after the id is the title, so quotes are optional.
222
+ - `delete <id>` deletes the session permanently, with its messages and sub-agent sessions, and the session's local task log under the state root (pass the run's `--working-dir`). It does not ask for confirmation, because the CLI never prompts outside a conversation, so check the id first.
223
+
224
+ An id the backend does not know prints `Session <id> not found.` on stderr and exits 1. A missing id or title, an extra operand, or `--page` / `--limit` / `--include-subagents` exits 2 before any request. Rename and delete work only on your own sessions.
225
+
226
+ ### Forking a session
227
+
228
+ `sessions fork <id> [<message-id>]` copies one of your sessions into a new session through the SDK's `forkSession`. The source is not changed. With a message id, the copy ends at that message, inclusive. Without one, it copies the whole conversation. The new id goes to stdout and a `Continue it with: cartographer-cli --session <new-id> "<prompt>"` hint goes to stderr. The fork keeps the source's title; change it with `sessions rename`.
229
+
230
+ ```bash
231
+ fork=$(npx cartographer-cli sessions fork <id> --output-format json | jq -r .id)
232
+ npx cartographer-cli --headless --session "$fork" "Try the other approach"
233
+ ```
234
+
235
+ The message id is a backend message id, the `id` of a message in the SDK's `getSessionMessages()` (see [Forking a session at a message](../../sdk/README.md#forking-a-session-at-a-message)). A 404 means no such session, a session with no messages, or a message id that is not in it. It prints that on stderr and exits 1. A missing id, an extra operand, or a list flag exits 2 before any request. Only remote sessions can be forked, not a Delegate desktop conversation kept in the app's local store.
236
+
237
+ ### Typed judgments (`evaluate`, `rerank`, `verify`)
238
+
239
+ Stateless, one-shot judgments from the backend — no agent, no session, no interop. Each command reads one JSON request from a file (or stdin with `-`, or a pipe) and posts it unchanged to `/v1/completions/evaluate`, `/rerank` or `/verify`:
240
+
241
+ ```bash
242
+ cat > claims.json <<'EOF'
243
+ {"claims": [{"id": "c1", "claim": "The invoice is paid.", "evidence": {"status": "paid"}}]}
244
+ EOF
245
+ cartographer-cli verify claims.json
246
+ # Model gpt_5_6_luna (…), 412 tokens
247
+ # Rubric …
248
+ # c1: supported (confidence 0.97)
249
+
250
+ echo '{"query": "late payment", "candidates": [{"id": "a", "content": "…"}, {"id": "b", "content": "…"}], "top_k": 1}' \
251
+ | cartographer-cli rerank - --output-format json # the raw response on stdout
252
+ cartographer-cli evaluate request.json --model claude_sonnet_5_5
253
+ ```
254
+
255
+ - The request is the backend's snake_case JSON (`questions` with a `type` of `probability`, `choice` or `score`; `candidates` and `top_k`; `claims`). The "Evaluate, rerank, verify" section of the `@uipath/delegate-sdk` README lists the fields.
256
+ - `--model <id>` replaces the request's `model`. Without it the request's own `model`, or the server default, applies (the `MODEL` env var does not).
257
+ - Text mode prints the model, then one line per answer, ranked candidate or verdict. `--output-format json` prints the backend response as it came.
258
+ - A rejected request prints one line on stderr, such as `verify failed (422 invalid_request): body.claims: List should have at least 1 item`, and exits 1. A missing, unreadable or non-object request exits 2 before any call.
259
+
260
+ ### Structured completion (`complete`)
261
+
262
+ One LLM call that answers a prompt with a JSON object matching a JSON schema — no agent turn, no tools, no interop (`/v1/completions/structured`, SDK `complete`):
263
+
264
+ ```bash
265
+ cat > invoice.schema.json <<'EOF'
266
+ {"type": "object", "properties": {"total": {"type": "number"}, "currency": {"type": "string"}}, "required": ["total", "currency"]}
267
+ EOF
268
+ cartographer-cli complete --json-schema invoice.schema.json "Extract the total: Invoice 42, total due 1,200.00 EUR"
269
+ # {
270
+ # "total": 1200,
271
+ # "currency": "EUR"
272
+ # }
273
+
274
+ pdftotext invoice.pdf - | cartographer-cli complete --json-schema invoice.schema.json - --output-format json
275
+ # {"structured":{"total":1200,"currency":"EUR"},"usage":{"model":"gpt-5.6-luna",…}}
276
+ cartographer-cli complete --json-schema verdict.schema.json --session <id> "Did the run succeed?"
277
+ ```
278
+
279
+ - The prompt is the positional, or stdin with `-` or a pipe. `--json-schema FILE` is required and must hold a JSON object. The backend names the model's tool after the schema's top-level `title`; a schema without a usable one (letters, digits, `_` and `-`, at most 64 characters) is sent titled `structured_output`. The same applies to `--json-schema` on a prompt.
280
+ - `--session ID` loads that backend session's history as context before the prompt, so you can extract an answer from a finished run. `--model ID` picks the model (it needs structured-output support); without it the `MODEL` env var, then `gpt_5_6_luna`, apply, as for a prompt.
281
+ - Text mode prints the structured object as indented JSON on stdout — pipe it to `jq`. `--output-format json` prints `{structured, usage}` on one line.
282
+ - When the model output fails the schema the command prints one line on stderr, such as `complete failed (422 schema_validation): LLM failed to generate valid structured output: …`, and exits 1; so does any other rejection (`413 context_too_large` when the session history is too long, `404 session_not_found`, …). A missing or invalid schema file, or no prompt, exits 2 before any call.
283
+
284
+ ### Structured output from a prompt (`--json-schema`)
285
+
286
+ `--json-schema FILE` on a prompt runs the agent turn as usual, then extracts its result as a JSON object matching the schema — a second LLM call to `/v1/completions/structured` over the turn's session (SDK `sendMessage(prompt, { outputSchema })`):
287
+
288
+ ```bash
289
+ cartographer-cli --json-schema invoice.schema.json "Open invoice.pdf in Downloads and read the total"
290
+ # …the agent's answer, streamed as usual…
291
+ # {
292
+ # "total": 1200,
293
+ # "currency": "EUR"
294
+ # }
295
+
296
+ cartographer-cli --json-schema invoice.schema.json --output-format json "Read the total of invoice.pdf"
297
+ # {"type":"result",…,"text":"The total is 1,200.00 EUR.","isError":false,…,"structured":{"total":1200,"currency":"EUR"}}
298
+ ```
299
+
300
+ - The flag implies `--print`: one turn, no conversation.
301
+ - Text mode prints the answer as usual, then the object as indented JSON on stdout. `--output-format json` and `stream-json` put it in the result object as `structured`.
302
+ - When extraction fails — `422 schema_validation` when no output matches the schema, `413 context_too_large` when the session is too long even after summarization, … — text mode prints `Structured output failed: …` on stderr, the JSON formats carry `structuredError`, and the command exits 1. A failed turn skips the extraction and also exits 1.
303
+ - The extraction runs on the agent's model (`--model`, `MODEL`, or `gpt_5_6_luna`), so that model needs structured-output support. It costs a second LLM call per run.
304
+ - A missing or invalid schema file exits 2 before the agent starts.
305
+
306
+ ### Attachments (`--attach`)
307
+
308
+ `--attach PATH` sends a file or folder with the first message, as the Delegate app sends attached files (SDK `sendMessage(prompt, { attachments })`). Repeat it for more:
309
+
310
+ ```bash
311
+ cartographer-cli --print --attach invoice.pdf --attach po.xlsx "Do the invoice and the purchase order match?"
312
+ cartographer-cli --attach screenshot.png # conversation: the first line you type carries it
313
+ ```
314
+
315
+ - Images go inline; printable text goes inline up to 16,000 characters; PDFs, Office documents, archives and other binaries go as a reference to the file, which the agent opens with its own tools; a folder goes as its path.
316
+ - One 30 MiB cap covers all files of a message. A larger file goes as a reference to the file, unread, and when the inline files add up to more than 24 MiB the oldest turn into references until the message fits.
317
+ - In a conversation only the first message carries attachments — the prompt given on the command line, or the first line typed. Later messages carry none of their own, but the first message's files stay in context for the rest of the session.
318
+ - Relative paths resolve against the current directory. A path that does not exist, or the flag on a subcommand, exits 2 before any auth or interop work; a file that cannot be read fails the turn before it starts (exit 1).
319
+
320
+ ### Skills
321
+
322
+ The CLI uses the skills the `@uipath/delegate-sdk` package ships, with no Delegate desktop app needed: the Integration Service API skills (`jira`, `confluence`, `github`, `google-workspace`, `uipath-integrations`, `uipath-orchestrator`), the Office and document skills (`excel-architect`, `word-architect`, `powerpoint-architect`, `pdf-architect`, `office-convert`, `office-download`, `doc-coauthoring`, `internal-comms`, `knowledge-base`), `outlook-365`, `slack-operation`, `teams-operation`, `uipath-taskautomation`, `uipath-workflow-documenter`, `business-analysis`, `project-task-list`, `source-coverage`, `map-of-work`, `uipath-planner`, `transcribe-media`, `media-tools` and `system-diagnostics`. The agent picks one when the task calls for it; `--preload-skill <name>` attaches one up front.
323
+
324
+ For anything else, put your skills in a folder (one sub-folder per skill, each with a `SKILL.md`) and pass `--skills-path <folder>`, or set `DELEGATE_BUNDLED_SKILLS_PATH`. They load on top of the packaged skills, and one with the same name as a packaged skill replaces it.
325
+
326
+ ### Speech-to-text (`transcribe`)
327
+
328
+ Transcribe an audio file with the backend's transcription model route (`/v1/transcription`, the one the desktop app's voice input uses) and print the text:
329
+
330
+ ```bash
331
+ cartographer-cli transcribe standup.m4a
332
+ # Ship it on Friday.
333
+
334
+ cat memo.wav | cartographer-cli transcribe - --output-format json # {"text":"…"}
335
+ ```
336
+
337
+ - Formats: mp3, mp4, mpeg, mpga, m4a, wav, webm — named by the file's extension; for stdin (`-`) the format is detected from the bytes. At most 14 MB. There is no language option; the model detects it (Gemini 3.1 Flash-Lite through LLM Gateway).
338
+ - Audio the CLI refuses before uploading (unreadable file, unsupported format, empty, over 14 MB) prints the reason and exits 2. A backend rejection prints one line on stderr, such as `Transcription failed (400 empty): Audio file is empty.`, and exits 1.
339
+
340
+ ### Sharing a Map of Work (`maps`)
341
+
342
+ A run with `--project ID` keeps the project's history in a local Map of Work under the state root (`<working-dir>/mow/<ID>/`). Two of the desktop app's person actions on it run from the CLI, from the local disk with no agent, login or interop (SDK `shareMap` and `saveMapVersion`):
343
+
344
+ ```bash
345
+ # Save version: the map's next 0.x version (0.1.0 first), named by the message
346
+ cartographer-cli maps save-version "Seeded from the automations" --project invoice-approval --working-dir ~/engagements
347
+ # Saved version 0.1.0 of the Map of Work of invoice-approval: Seeded from the automations
348
+
349
+ # Share: the Map's history, change requests and versions to a bare repository, under a Map name
350
+ git init --bare /mnt/shared/maps.git
351
+ cartographer-cli maps share --project invoice-approval --working-dir ~/engagements \
352
+ --remote file:///mnt/shared/maps.git --map-name invoicing
353
+ # Shared the Map of Work of invoice-approval to file:///mnt/shared/maps.git as "invoicing".
354
+ ```
355
+
356
+ - `maps share` is the app's Share with *New map of work*: the remote is a bare git repository given as a `file://` URL or an absolute path, on this computer or a shared drive, and several projects' Maps can share one repository, each under its own `--map-name`. The repository's default branch also gets a copy of the Map's latest content in a folder of that name. A name that holds only this Map's history (a share cut short, or one shared again after more work) is resumed; a name that holds another Map, a Map that is already shared, or a GitHub repository is refused. From then on the Map publishes to the remote at every checkpoint and version, a later Cartographer run's included.
357
+ - Join the shared Map in the desktop app: in a fresh project, *Sharing* → *Use another git remote*, the same remote, then *Existing map of work* → *Use shared project*. Settling the current process and applying change requests stay the process owner's steps in the app.
358
+ - `maps save-version` is the app's *Save version*, which the app offers while the map is unsettled: it is refused once the map is settled (`1.0.0`), when versions come only from applied change requests, and when nothing changed since the latest version.
359
+ - A refusal prints its reason on stderr (`maps share: …`) and exits 1; a missing `--project`, `--remote`, `--map-name` or message prints the usage and exits 2. `--output-format json` prints the SDK's result: `{remote, mapName}`, or `{version, message, revision, date, changedFiles}`.
360
+ - Run these between agent runs on the project, not during one: each process keeps its own Map of Work.
361
+
362
+ ### Delegating to people (`delegations`, `org-users`)
363
+
364
+ Hand a task to a colleague from a script or robot, and take the answer back — the Delegate app's "delegate to a person" flow. See the SDK README's "Delegating a task to a person" for the lifecycle and every error code.
365
+
366
+ ```bash
367
+ cartographer-cli org-users ana # ana@acme.com Ana Pop
368
+ cartographer-cli delegations create --session "$SID" --to ana@acme.com \
369
+ --summary "Ledger reconciled; one 1,200 EUR variance left." "Approve the write-off?"
370
+ # Delegated 3333…-… to Ana Pop <ana@acme.com>.
371
+ cartographer-cli delegations pending "$SID" --output-format json # poll: answers awaiting acceptance
372
+ cartographer-cli delegations accept 3333…-… # the answer joins session $SID
373
+
374
+ # Ana's side (her own login):
375
+ cartographer-cli delegations show 3333…-… # the briefing, without claiming
376
+ cartographer-cli delegations claim 3333…-… # prints the session to work it in
377
+ cartographer-cli delegations complete 3333…-… "Approved, see the memo."
378
+ ```
379
+
380
+ - `create` needs `--session` (a remote session you own). `--to` takes an email, or a name that matches exactly one colleague; without it the CLI prints a `delegate://delegation/…` link anyone in the organization can `show` or `claim`. The task is the rest of the line (`-` reads it from stdin), and so is the answer for `complete`.
381
+ - Also `delegations list PROJECT` (every delegation targeting a backend project), `dismiss ID` (drop an answer), `cancel ID` (withdraw a live one) and `delete ID`.
382
+ - There is no push notification: poll `delegations pending` on the source session (or the backend's `/v1/notifications` feed).
383
+ - Missing operands exit 2 before any request. A refusal — no such person, `already_claimed`, `expired`, direct assignment not enabled for the organization (`not_found`), … — prints one line on stderr, such as `Could not claim delegation (409): Someone else already claimed this delegation.`, and exits 1.
384
+
385
+
386
+ ### Machine access
387
+
388
+ Three levels of machine access, independent of conversation mode:
389
+
390
+ | | interop | screen + UI automation | file / Office / PDF / shell |
391
+ |---|---|---|---|
392
+ | default | yes | yes | yes |
393
+ | `--no-computer-use` | yes | **no** | yes |
394
+ | `--headless` | **no** | no | **no** |
395
+
396
+ cartographer-cli runs every session at the `--no-computer-use` level; `--headless` moves it down a row.
397
+
398
+ ### Flags
399
+
400
+ | Flag | Default | What it does |
401
+ |---|---|---|
402
+ | `-p`, `--print` | automatic outside a terminal | Send one prompt, execute any tools, print the response and exit. Otherwise, when stdin and stdout are terminals, accept follow-up messages interactively. Explicit `-` input also selects one-turn mode. |
403
+ | `--env <name>` | saved login's deployment | `alpha` / `staging` / `production` / `localhost`. Composes the backend URL from saved org/tenant slugs; localhost → `http://localhost:5002`. Omitted → the deployment you logged into (`cartographer-cli login`). With no saved login and no `--backend` / `BACKEND_URL` either, commands error — the CLI never guesses an environment. For anything that is not a named cloud, use `--url`. |
404
+ | `--url <base>` | — | (`login` only; alias `--authority`) Base URL of a deployment that is not a named cloud — Automation Suite, Dedicated, Public Sector. A tenant path or a trailing `/identity_` is accepted and reduced to the origin. Mutually exclusive with `--env`; also settable via `UIPATH_BASE_URL`. Non-`https` URLs and URLs with embedded credentials are refused. See [Automation Suite](#automation-suite-and-other-self-hosted-deployments). |
405
+ | `--skip-env-check` | off | (`login` only) Skip the deployment checks that run before sign-in and after the token exchange. Escape hatch — it also gives up the diagnosis when something is genuinely wrong. |
406
+ | `--backend <url>` | — | Full backend URL — overrides `--env` and `BACKEND_URL`. |
407
+ | `--tenant <name>` | saved login's tenant, else the org's first | (`login` only) Tenant to sign into, matched by name case-insensitively. Without it a re-login keeps the tenant of the saved login on that cloud. An unknown name fails and lists the tenants that exist; on any other command the flag is refused — switch an existing login with `cartographer-cli tenant <name>`. |
408
+ | `--model <id>` | `gpt_5_6_luna` | LLM id (use `cartographer-cli models` to discover). Also via `MODEL` env. For a prompt, the id is checked against the tenant's catalog before interop starts: an unknown or plan-locked id fails and lists the valid ids. If the catalog cannot be read, the run continues with a warning. For `evaluate` / `rerank` / `verify` it replaces the request's `model` (no `MODEL` fallback). `complete` and a `--json-schema` extraction use the same model as a prompt. |
409
+ | `--headless` | off | Skip interop entirely. Text-only prompts: no screen **and** no file, Office, PDF or shell tools. Skills still load — they are read through Node, not interop. |
410
+ | `--no-computer-use` | off | Keep interop, drop the screen. File, Office, PDF and shell tools keep working; screenshots, the window list, the focused element and the UI-automation tools (`AppFind`, `AppAct`, `AppGetDescriptor`) all go. Cuts the image tokens and the per-turn screen capture, keeps desktop window titles off the wire, and removes the agent's ability to act on the desktop UI. The right default for document and file work on a real machine. `--headless` implies it. |
411
+ | `--keep-alive` | off | Keep a spawned interop running for reuse by later invocations with the same issuer. A session reuses a healthy persistent interop when one is available and otherwise starts its own. |
412
+ | `--cleanup` | — | Force-stop interops recorded in `~/.delegate-sdk/interop*.pid`, including private interops used by other active sessions, and exit. A PID is signalled only while its port reports that PID on `/health`. A record is removed once its PID has stopped. Otherwise the record is kept, and its PID and port are printed to stderr so you can stop that process yourself. |
413
+ | `--no-connections` | off | Disable orchestrator ConnectionService (silences 404 noise on tenants without orchestrator). |
414
+ | `--no-security` | off | Disable tool security wrapper. Debug only. |
415
+ | `--no-memory` | off | Do not send the Delegate app's local long-term memories with each turn (SDK `enableMemory: false`). By default the CLI reads the same `Memories` folder the desktop app uses, and the model may save new preferences and learnings there with its file tools. |
416
+ | `--preload-skill <name>` | — | Preload a skill into the session before the first model turn (repeatable; SDK `preloadSkills`). A name given twice is preloaded once. |
417
+ | `--vertical <id>` | `cartographer` | Every session runs as the Cartographer vertical, inside the CLI's process with no desktop app installed (SDK `vertical`): the backend's Cartographer prompt profile, the `shell_app` stamp on the sessions the run creates (a session resumed with `--session` keeps its own), the Map of Work bound to `--project`, Cartographer cost attribution and its allowance check, machine-driving calls refused, and `gpt_5_6_luna` starting at `xhigh` when no `--effort` is given. `--vertical cartographer` changes nothing; another id exits with code 2. |
418
+ | `--project <id>` | — | Bind the session to a project: wiki, plans and `task-list.md` live under `<state root>/projects/<id>/` (the state root is `--working-dir`, else `~/.aria-sdk`), the preloaded skills' declared project files are copied there on the first message, and the project context (`ProjectId`, `TaskListPath`) is injected into every turn (SDK `projectId`). Rules in `<state root>/projects/<id>/agents.md` go to the model on the first turn of each new session. Client-side routing key only — the CLI never links a backend project row. |
419
+ | `--working-dir <path>` | `~/.aria-sdk` for state; process cwd for shells | Shell cwd for the agent and root for SDK-local state (SDK `workingDirectory`). Relative paths resolve against the current directory; **the directory is created if missing**. |
420
+ | `--skills-path <path>` | — | Folder of your own skills, loaded on top of the [packaged skills](#skills) (SDK `bundledSkillsPath`); also `DELEGATE_BUNDLED_SKILLS_PATH`. On a name clash your copy wins. Relative paths resolve against the current directory. |
421
+ | `--effort <tier>` | model's recommended tier | Reasoning effort: `low` / `medium` / `high` / `xhigh` / `max` (SDK `effort`). Any other value exits with code 2. |
422
+ | `--session <id>` | server-assigned | Pin the session id (SDK `sessionId`). Must be an existing backend session: the backend assigns session ids, so an id it does not know fails the turn (exit 1) before anything is sent. Reuse it across invocations to continue one conversation — the agent then remembers earlier turns. Note that `--preload-skill` is stamped when the SDK *creates* a session, so passing it alongside `--session` does not reconfigure an existing one. For `complete`, the session whose history is sent as context. |
423
+ | `--json-schema <file>` | — | JSON schema file the structured answer must match: for `complete`, and for a prompt (the turn's result is extracted after it runs; implies `--print`). On another command the flag exits with code 2. |
424
+ | `--attach <path>` | — | (prompts only) File or folder sent with the first message (repeatable; SDK `sendMessage(prompt, { attachments })`). See [Attachments](#attachments---attach). |
425
+ | `--input-format <fmt>` | `text` | `text` / `stream-json`. `stream-json` reads the prompt and later steering messages from stdin; needs `--output-format stream-json`. See [Steering a running turn](#steering-a-running-turn---input-format-stream-json). |
426
+ | `--replay-user-messages` | off | With `--input-format stream-json`: echo each steering message once the agent takes it. |
427
+ | `--output-format <fmt>` | `text` | `text` / `json` / `stream-json`. The JSON formats keep stdout JSON-only, imply `--print`, and exit 1 when the turn ends in error. Also honoured by every subcommand that prints a result. See [Machine-readable output](#machine-readable-output---output-format). |
428
+ | `--days <n>` | 30 | (`usage activity` / `usage daily` only) Look-back window in days, a whole number from 1 to 365; anything else, or the flag on another command, exits with code 2. |
429
+ | `-q`, `--quiet` | off | Suppress 🤔 thinking on stderr. |
430
+ | `--verbose` | off | Print SDK and framework diagnostics (SDK `verbose`). Independent of `-q`. In `text` output they share stdout with the answer, so do not pipe the answer with this on; under the JSON formats they go to stderr. |
431
+ | `-v`, `--version` | — | Print the installed CLI version. |
432
+ | `--runner-url <url>` | — | (host) Runner worker WS URL. Required; or `CONTROL_PLANE_WS_URL` env. |
433
+ | `--interop <path>` | — | (host) Interop binary path; or `INTEROP_EXECUTABLE_PATH` env. Absent → registration/discovery only, tool execution disabled. |
434
+ | `--worker-id <id>` | hostname | (host) Stable worker identity; or `WORKER_ID` env. |
435
+ | `--page <n>` | `1` | (`sessions` only) Page of the session list to show. |
436
+ | `--limit <n>` | `30` | (`sessions` only) Sessions per page, 1–100. |
437
+ | `--include-subagents` | off | (`sessions` only) Also list sub-agent sessions. They are hidden by default, as in the desktop app's history, and are marked `(sub-agent of <id>)` in the table. |
438
+ | `--turn <id>` | — | (`sessions cancel` only, required) Backend turn id to cancel. |
439
+ | `--to <who>` | — | (`delegations create` only) Assign the task to this person: an email, or a name matching exactly one colleague. Without it the delegation is a shareable link. |
440
+ | `--summary <text>` | empty | (`delegations create` only) The briefing the person starts from. |
441
+ | `--remote <url-or-path>` | — | (`maps share` only, required) The bare git repository to share the Map to: a `file://` URL or an absolute path, on this computer or a shared drive. Passed as given; a GitHub repository is refused (exit 1). |
442
+ | `--map-name <name>` | — | (`maps share` only, required) The Map's name in that repository, beside other projects' Maps: up to 64 letters, digits, `.`, `_` or `-`, starting with a letter or digit. |
443
+
444
+ `--preload-skill`, `--project`, `--session`, `--working-dir`, `--skills-path`, `--effort`, `--days`, `--attach` and `--output-format` require a value — a following flag, long (`--headless`) or short (`-p`), counts as missing and exits with code 2, as does any unknown flag. `--project` must be a single folder-safe segment (letters, digits, spaces, `_`, `-`, `.`, parentheses; at most 64 characters; not starting with `.` or ending with `.` or a space) — anything else exits with code 2 rather than silently routing the engagement's files to the session folder.
445
+
446
+ ### Examples
447
+
448
+ ```bash
449
+ # An engagement: state under ~/engagements/projects/invoice-approval, the Cartographer
450
+ # skills preloaded before the first model turn. Run the same command again later to reuse
451
+ # the project's files; add --session <id> to resume chat history.
452
+ npx cartographer-cli --project invoice-approval --working-dir ~/engagements \
453
+ "Read the AS-IS notes and draft the process overview."
454
+
455
+ # One more skill the package does not ship, loaded from a folder of your own;
456
+ # business-analysis is already preloaded, so naming it again changes nothing
457
+ npx cartographer-cli --skills-path ~/my-skills --preload-skill company-process-guide \
458
+ --project invoice-approval "Start the engagement."
459
+
460
+ # Headless: no interop, so no project files are read or written; fastest for questions
461
+ npx cartographer-cli --headless --project invoice-approval "Which steps are still unclear?"
462
+
463
+ # Word deliverable of a living document the engagement wrote: the agent calls
464
+ # /livingdoc/export, which writes ~/engagements/projects/invoice-approval/<slug>-PDD.docx.
465
+ # It reads and writes through interop, so it needs --project and fails under --headless.
466
+ npx cartographer-cli --project invoice-approval --working-dir ~/engagements \
467
+ "Export the PDD to Word."
468
+
469
+ # The same export without an agent, login or interop: reads the project's drafts and its
470
+ # open change requests' documents from the local disk and prints the .docx path
471
+ # (--output-format json: {docxPath, message}). Pass the draft path as a second argument
472
+ # when the project holds two PDDs. BPMN diagrams are drawn, as in the agent's export
473
+ # (it needs the optional @napi-rs/canvas); a Mermaid diagram (a Case, a flowchart)
474
+ # becomes a placeholder line, and the message counts those.
475
+ npx cartographer-cli export pdd --project invoice-approval --working-dir ~/engagements
476
+
477
+ # Hand the engagement's map to the desktop app: name a version, then share the project's
478
+ # Map of Work to a bare repository on a shared drive under the Map name "invoicing".
479
+ # No agent, login or interop. In the app, a fresh project joins it with Existing map of
480
+ # work → Use shared project. See Sharing a Map of Work.
481
+ npx cartographer-cli maps save-version "Seeded from the automations" --project invoice-approval --working-dir ~/engagements
482
+ npx cartographer-cli maps share --project invoice-approval --working-dir ~/engagements \
483
+ --remote file:///mnt/shared/maps.git --map-name invoicing
484
+
485
+ # Script it: the answer and its token usage as JSON (logs stay on stderr)
486
+ npx cartographer-cli --project invoice-approval --output-format json "List the open questions." | jq '.text, .usage'
487
+
488
+ # Find a session to resume: the newest 30, then the next page
489
+ npx cartographer-cli sessions
490
+ npx cartographer-cli --project invoice-approval --working-dir ~/engagements --session <id>
491
+
492
+ # Target another environment for one command, or override the backend URL fully
493
+ npx cartographer-cli --print --env staging --project invoice-approval "Summarize the process."
494
+ npx cartographer-cli --backend "https://custom.example.com/autopilot-everywhere" "..."
495
+ ```
496
+
497
+ ---
498
+
499
+ ## Cancelling a turn
500
+
501
+ Ctrl+C during a turn cancels it the way the desktop app's Stop button does — the backend is asked to stop the turn, then the CLI cleans up and exits with code 130. A second Ctrl+C exits at once. With `--output-format json`, the result line still prints, with `isError: true` and `error: "Turn cancelled"`.
502
+
503
+ To cancel a turn another process is running (a scheduled job, a program using the SDK):
504
+
505
+ ```bash
506
+ npx cartographer-cli sessions cancel <session-id> --turn <turn-id>
507
+ ```
508
+
509
+ The backend cancels only that exact turn, so a late cancel never stops a newer turn in the same session. The turn id comes from the running process: a `turn_start` line of its `--output-format stream-json` output, the `Turn: …` line the CLI prints on stderr in every output format (with this exact command), or `agent.getActiveTurnId()` / the `turn_start` event in an SDK program. Each backend round of a turn has its own id; cancel with the latest. The command prints `Cancel requested…` when the turn was flagged; the backend stops it within a few seconds. When the session has no such turn in progress (already finished, another turn, or not your session), the command says so on stderr and exits 1.
510
+
511
+ ---
512
+
513
+ ## Quota and spend
514
+
515
+ `cartographer-cli usage` prints the signed-in user's standing, from two read-only Agents Backend calls:
516
+
517
+ ```
518
+ Licensing: 42.3% of 200 PU used (resets 2026-10-01T00:00:00+00:00)
519
+ Spending: $12.30 this month of a $50.00 cap
520
+ ```
521
+
522
+ - **Licensing** (`GET /v1/usage/licensing-summary`): the monthly licensing quota in Platform Units. `limit_enabled: false` means no licensing quota applies to this login. `pct_used` can exceed 100 — usage past the quota spills into an extra pool (`extra_pool_consumed_pu`) rather than being refused. `--session <id>` adds that session's lifetime usage (`session_consumed_pu`).
523
+ - **Spending** (`GET /v1/usage/monthly-spending`): the spend this calendar month (UTC) against the per-user cap. The backend refuses new turns (HTTP 429 `monthly_spending_limit_exceeded`) once `monthly_spend_usd` is above `monthly_limit_usd`, but only while `limit_enabled` is true; a null limit means unlimited.
524
+
525
+ `cartographer-cli usage activity` and `cartographer-cli usage daily` report the last `--days` days (default 30): session, cost and token totals per model, or one row per day with usage.
526
+
527
+ With `--output-format json` the summary is one object, `{"licensing":{…},"monthlySpending":{…}}`, holding the backend's answers unchanged (snake_case fields); `activity` and `daily` print the backend's answer as is. `usage` sets no exit code for being over a limit: no single field means "every run will be refused" — the cap has exemptions and licensing overage is allowed. A scheduler decides with `jq -e`, which exits 1 when the expression is false or null:
528
+
529
+ ```bash
530
+ # Skip the run once the spending cap is exceeded (the backend then refuses turns).
531
+ npx cartographer-cli usage --output-format json | jq -e '
532
+ .monthlySpending | (.limit_enabled | not) or .monthly_limit_usd == null
533
+ or .monthly_spend_usd <= .monthly_limit_usd' >/dev/null || exit 0
534
+
535
+ # Or gate on the licensing quota.
536
+ npx cartographer-cli usage --output-format json | jq -e '
537
+ .licensing | (.limit_enabled | not) or .pct_used < 100' >/dev/null || exit 0
538
+ ```
539
+
540
+ A failed backend call exits 1 with the status on stderr and nothing on stdout, and `jq -e` then fails too (exit 4, no input), so both examples also skip the run when the limits cannot be read. To tell the two apart, `set -o pipefail` and check the CLI's own exit code.
541
+
542
+ ---
543
+
544
+ ## Run as a remote machine (host mode)
545
+
546
+ `cartographer-cli host` registers this PC as a remote worker on a runner control plane and serves tool executions until Ctrl+C — no Electron app needed.
547
+
548
+ ```bash
549
+ npx cartographer-cli login --env production # once
550
+ npx cartographer-cli host --runner-url wss://runner.example/worker \
551
+ --interop /path/to/UiPath.Delegate.Host.Api # omit --interop → discovery only
552
+ ```
553
+
554
+ Backend URL defaults to the saved login's org/tenant (override with `--backend` or `AUTOPILOT_BACKEND_URL`). Tokens refresh automatically from `~/.aria/sdk-auth.json`; when refresh permanently fails the host prints a re-login instruction and exits non-zero.
555
+
556
+ When the runner URL points at the cloud front door (`wss://<cloud>/delegate_/websocket_/…`), the host fills the account/tenant query parameters from the saved login's org/tenant slugs so the request can be routed. Explicit non-empty params on the URL win; each missing or empty one is filled independently. Other runner URLs are left unchanged for compatibility with older runners that reject query strings.
557
+
558
+ ### Auto-start at login
559
+
560
+ ```bash
561
+ npx cartographer-cli host install --runner-url wss://runner.example/worker # needs a saved login
562
+ npx cartographer-cli host status # one-line state
563
+ npx cartographer-cli host uninstall # idempotent
564
+ ```
565
+
566
+ Flags/env present at `install` time are persisted into the OS entry.
567
+
568
+ The host is the same remote worker in `delegate-cli`, `autopilot-cli` and `cartographer-cli`, with one auto-start entry: `host install` from one replaces another's, and the entry runs the CLI that installed it, so run `cartographer-cli host uninstall` before you remove the CLI that installed it.
569
+
570
+ | OS | Mechanism | Notes |
571
+ |---|---|---|
572
+ | macOS | LaunchAgent `com.uipath.delegate.host` in `~/Library/LaunchAgents/` | Restarts on crash, not on clean exit. Logs: `~/Library/Logs/UiPathDelegateHost/`. |
573
+ | Windows | Scheduled Task "UiPath Delegate Host" (at logon) | Env vars are baked into the task as flags. Output not captured — run `cartographer-cli host` manually to debug. |
574
+ | Linux | Not supported yet | |
575
+
576
+ ---
577
+
578
+ ## Authentication
579
+
580
+ `cartographer-cli login --env <env>` runs OAuth PKCE in your browser and saves to `~/.aria/sdk-auth.json`. The first login must name the deployment (`--env` for a UiPath cloud, `--url` for anything else); from then on that deployment is the default — `cartographer-cli login` re-logs into it, and prompts/`models` target it unless `--env`/`--backend` say otherwise.
581
+
582
+ The browser step only picks the organization (Identity asks when your account belongs to several). The tenant comes from the CLI: the organization's first tenant unless `--tenant <name>` names another, and a re-login on the same deployment keeps the saved tenant. The login output lists the organization's other tenants, and `cartographer-cli whoami` shows the active one.
583
+
584
+ To change tenant afterwards, run `cartographer-cli tenant <name>` — no browser: tokens are issued per organization, so the command only lists the organization's tenants, matches the name case-insensitively, and rewrites the tenant id and slug in `~/.aria/sdk-auth.json`. `cartographer-cli tenant` alone lists the tenants and marks the current one. It works on the CLI's own login only: with `AUTH_TOKEN` env-var auth the tenant is `TENANT_ID`/`TENANT_SLUG`, and the Delegate desktop app's fallback file keeps the tenant chosen in the app.
585
+
586
+ `cartographer-cli whoami` shows the active identity (auth source, deployment kind, org/tenant, token expiry). It is strictly read-only: no backend call, and no token refresh either — so an expired token is reported as expired instead of being silently rotated behind an inspection command. The `Source:` line names the file the credential actually came from, which may be the Delegate desktop app's `~/.aria/auth.json` (the SDK's read-only fallback).
587
+
588
+ `cartographer-cli check` is the pre-flight a prompt would otherwise run implicitly, without sending one: it loads (and refreshes) auth and resolves the backend URL exactly like a prompt does, then prints four lines — `auth` (token not expired, and its organization and tenant match the backend URL), `readiness` (one unauthenticated `GET /readiness` under the backend URL: the service is up and its database reachable; when it fails the `backend` line is skipped, and a 401/403/404 — a gateway that does not expose it — skips the `readiness` line instead), `backend` (one read-only `GET /v1/config` with the token; on Automation Suite the answer must also advertise `delegate` in `SUPPORTED_SHELL_APPS`, which pre-26.10 images omit), and `interop` (spawns the bundled interop with the saved login's deployment as its trusted OIDC issuer, waits for `/health`, stops it again; `--headless` skips it). Any failed line makes the command exit 1, so a scheduler or a Robot job can gate on it. A saved login whose org/tenant slugs disagree with the backend URL — after a `--backend` override or a `tenant` switch — fails the `auth` line, and a prompt with the same combination is refused by the SDK before any request is sent.
589
+
590
+ `cartographer-cli logout` deletes the saved CLI login and never the desktop app's file. When that fallback is what you are authenticating with, it says so rather than reporting nothing to remove — sign out in the Delegate app to clear it.
591
+
592
+ Tokens with < 30 % lifetime left are refreshed proactively on startup. 401s in a TTY trigger the login flow inline and retry once, preserving the active session and the selected tenant on the same cloud.
593
+
594
+ To authenticate as your own identity app (custom `UIPATH_CLIENT_ID` / `UIPATH_CLIENT_SECRET`), see the "Using your own identity app" section in the `@uipath/delegate-sdk` README — the same environment variables apply to the CLI.
595
+
596
+ **No-browser alternative**:
597
+ ```bash
598
+ AUTH_TOKEN=... TENANT_ID=... ORG_ID=... npx cartographer-cli --env production "..."
599
+ ```
600
+
601
+ `AUTH_TOKEN` is never refreshed, so a run that outlives it fails. A host that can renew the token sets `AUTH_TOKEN_FILE` to a file it keeps rewritten with the current token instead; the CLI re-reads it on every request.
602
+
603
+ These variables are removed from the environment of the interop process, so the shell commands the agent runs cannot read them.
604
+
605
+ ### Automation Suite and other self-hosted deployments
606
+
607
+ Sign in by URL rather than by environment name:
608
+
609
+ ```bash
610
+ export NODE_EXTRA_CA_CERTS=/path/to/cluster-ca.pem # only for a private certificate authority
611
+
612
+ npx cartographer-cli login --url https://automationsuite.contoso.com --tenant DefaultTenant
613
+ npx cartographer-cli whoami # confirms the deployment, org and tenant
614
+ npx cartographer-cli check # auth, backend readiness and capability, interop, end to end
615
+ ```
616
+
617
+ Three things differ from a cloud login:
618
+
619
+ - **Automation Suite 26.10 or later with the Delegate service** is required. Older deployments, and clusters without the service, are refused at login, with `--skip-env-check` as the override.
620
+ - **The deployment may reject the built-in client.** It is a registration on the UiPath clouds; when the token exchange fails with `invalid_client`, register an external application on the cluster with the redirect URIs `http://localhost:8055/oidc/login`, `http://localhost:42042/oidc/login` and `http://localhost:8104/oidc/login` and the `openid profile offline_access` scopes, then set `UIPATH_CLIENT_ID` (and `UIPATH_CLIENT_SECRET` for a confidential app).
621
+ - **A private certificate authority needs `NODE_EXTRA_CA_CERTS`.** Do not disable certificate verification — sign-in and token requests carry credentials. A TLS or DNS failure is reported with the remedy rather than as a bare socket error.
622
+
623
+ Before the browser opens, `login` checks that the URL really serves a UiPath Identity, and refuses it otherwise; after the token exchange it asks the deployment's Delegate service (`GET /v1/config`) whether it supports this SDK. `--skip-env-check` skips both. The `@uipath/delegate-sdk` README documents exactly what each check asks and why they run at different moments.
624
+
625
+ Computer use works on a self-hosted deployment too. The interop sidecar starts with the deployment as its trusted OIDC issuer. Persistent sidecars for different deployments run independently.
626
+
627
+ ---
628
+
629
+ ## Telemetry
630
+
631
+ The CLI reports usage analytics linked to the signed-in UiPath account (user, organization, and tenant, plus task and tool events — never prompts, file contents, or tool outputs) to help improve the product. To disable it entirely:
632
+
633
+ ```bash
634
+ DELEGATE_TELEMETRY_DISABLED=1 npx cartographer-cli --env production "..."
635
+ ```
636
+
637
+ `1` or `true` (case-insensitive) turns all reporting off. The same variable disables telemetry in the UiPath Delegate desktop app.
638
+
639
+ ---
640
+
641
+ ## Documentation & support
642
+
643
+ See [docs.uipath.com](https://docs.uipath.com) for product documentation. For issues with the package, contact UiPath support.
644
+
645
+ ---
646
+
647
+ ## License
648
+
649
+ Apache-2.0. See [LICENSE](./LICENSE).