uqadm 2026.22.0.dev0__tar.gz

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 (32) hide show
  1. uqadm-2026.22.0.dev0/PKG-INFO +481 -0
  2. uqadm-2026.22.0.dev0/README.md +468 -0
  3. uqadm-2026.22.0.dev0/pyproject.toml +74 -0
  4. uqadm-2026.22.0.dev0/uqadm/__init__.py +3 -0
  5. uqadm-2026.22.0.dev0/uqadm/__main__.py +4 -0
  6. uqadm-2026.22.0.dev0/uqadm/chat/__init__.py +200 -0
  7. uqadm-2026.22.0.dev0/uqadm/chat/history.py +77 -0
  8. uqadm-2026.22.0.dev0/uqadm/chat/render.py +115 -0
  9. uqadm-2026.22.0.dev0/uqadm/chat/send.py +103 -0
  10. uqadm-2026.22.0.dev0/uqadm/cli.py +69 -0
  11. uqadm-2026.22.0.dev0/uqadm/core/__init__.py +1 -0
  12. uqadm-2026.22.0.dev0/uqadm/core/auth_debug.py +85 -0
  13. uqadm-2026.22.0.dev0/uqadm/core/config_file.py +38 -0
  14. uqadm-2026.22.0.dev0/uqadm/core/endpoint.py +109 -0
  15. uqadm-2026.22.0.dev0/uqadm/core/env.py +205 -0
  16. uqadm-2026.22.0.dev0/uqadm/core/paths.py +28 -0
  17. uqadm-2026.22.0.dev0/uqadm/core/slot.py +32 -0
  18. uqadm-2026.22.0.dev0/uqadm/env/__init__.py +121 -0
  19. uqadm-2026.22.0.dev0/uqadm/env/create.py +88 -0
  20. uqadm-2026.22.0.dev0/uqadm/env/delete.py +35 -0
  21. uqadm-2026.22.0.dev0/uqadm/env/list.py +39 -0
  22. uqadm-2026.22.0.dev0/uqadm/env/set_default.py +20 -0
  23. uqadm-2026.22.0.dev0/uqadm/env/show.py +34 -0
  24. uqadm-2026.22.0.dev0/uqadm/install.py +192 -0
  25. uqadm-2026.22.0.dev0/uqadm/space/__init__.py +274 -0
  26. uqadm-2026.22.0.dev0/uqadm/space/delete.py +86 -0
  27. uqadm-2026.22.0.dev0/uqadm/space/diff.py +259 -0
  28. uqadm-2026.22.0.dev0/uqadm/space/export.py +76 -0
  29. uqadm-2026.22.0.dev0/uqadm/space/export_yaml.py +38 -0
  30. uqadm-2026.22.0.dev0/uqadm/space/list.py +87 -0
  31. uqadm-2026.22.0.dev0/uqadm/space/migrate.py +345 -0
  32. uqadm-2026.22.0.dev0/uqadm/space/upsert.py +219 -0
@@ -0,0 +1,481 @@
1
+ Metadata-Version: 2.3
2
+ Name: uqadm
3
+ Version: 2026.22.0.dev0
4
+ Summary: Unique admin CLI (space list, export, upsert, migrate, delete): separate from unique-cli
5
+ Requires-Dist: unique-sdk>=2026.22.0.dev3,<2026.22.0rc0
6
+ Requires-Dist: typer>=0.12,<1
7
+ Requires-Dist: python-dotenv>=1.0.0,<2
8
+ Requires-Dist: pyyaml>=6.0.1,<7
9
+ Requires-Dist: rich>=13.3.5
10
+ Requires-Dist: tomli-w>=1.0,<2
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+
14
+ # uqadm
15
+
16
+ Admin CLI for the Unique platform. It groups four command families:
17
+
18
+ - **`space`** — list, export, diff, migrate, upsert, and delete assistant spaces.
19
+ - **`chat`** — send messages to an assistant and inspect chat history.
20
+ - **`env`** — manage named credential slots stored in `~/.uqadm/envs/`.
21
+ - **`install`** — one-time bootstrap: create directories, install shell completion, set up your first slot.
22
+
23
+ It is separate from `unique-cli` (the agent-oriented file explorer) and shares the same `UNIQUE_*` environment variable conventions as `unique_sdk`.
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ From the AI monorepo root:
30
+
31
+ ```bash
32
+ cd /path/to/ai
33
+ uv sync --package uqadm
34
+ uv run uqadm --help
35
+ ```
36
+
37
+ Or install the `uqadm` package into any environment that already has `unique-sdk`:
38
+
39
+ ```bash
40
+ pip install -e uqadm/
41
+ uqadm --help
42
+ ```
43
+
44
+ ---
45
+
46
+ ## `uqadm install`
47
+
48
+ One-time bootstrap for a new machine or user. Safe to re-run (idempotent).
49
+
50
+ ```bash
51
+ uqadm install # interactive
52
+ uqadm install --dry-run # preview without changes
53
+ uqadm install --no-rc # skip rc file patching
54
+ uqadm install --shell bash # force bash (auto-detected by default)
55
+ uqadm install --rc-file ~/.zshrc # explicit rc file path
56
+ ```
57
+
58
+ What it does:
59
+
60
+ 1. Creates `~/.uqadm/` (mode `0700`) and `~/.uqadm/envs/`.
61
+ 2. Installs shell completion for `uqadm`.
62
+ 3. Offers to create your first credential slot interactively (skipped if slots already exist).
63
+ 4. Appends an idempotent `export UQADM_HOME=...` block to your shell rc file.
64
+
65
+ | Option | Description |
66
+ |--------|-------------|
67
+ | `--dry-run` | Print what would be done without making any changes. |
68
+ | `--no-rc` | Skip patching the shell rc file. |
69
+ | `--shell SHELL` | Shell to configure: `zsh` or `bash` (auto-detected from `$SHELL`). |
70
+ | `--rc-file PATH` | Explicit path to the rc file to patch. |
71
+
72
+ ---
73
+
74
+ ## Quick start
75
+
76
+ ```bash
77
+ # 1. Bootstrap directories, shell completion, and first credential slot
78
+ uqadm install
79
+
80
+ # 2. (Optional) add more slots or set a different default
81
+ uqadm env create prod --set-default
82
+
83
+ # 3. List spaces — uses the configured default slot
84
+ uqadm space list
85
+
86
+ # 4. Send a message to an assistant
87
+ uqadm chat send asst_abc123 --text "Hello!"
88
+
89
+ # 5. Continue the same thread using the chat_id printed after step 4
90
+ uqadm chat send asst_abc123 --text "Tell me more" --chat-id chat_xyz789
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Credential slots
96
+
97
+ A **slot** is a short name (e.g. `qa`, `prod`, `1`) that maps to a `.env` file holding `UNIQUE_*` credentials.
98
+
99
+ ### File locations (resolution order)
100
+
101
+ 1. `~/.uqadm/envs/.{slot}.env` — managed by `uqadm env create`; this is the primary location.
102
+ 2. If not found there, falls back to the **current working directory** (or `--cwd` if set):
103
+ - `.{slot}.env` (hidden file wins)
104
+ - `{slot}.env`
105
+
106
+ If no file is found, `uqadm` prints a short guide to stderr and exits with code **2** — no Python traceback.
107
+
108
+ ### Default slot
109
+
110
+ Running `uqadm env set-default qa` writes the default slot to `~/.uqadm/config.toml`. All commands that accept `--slot` will use this default when the option is omitted.
111
+
112
+ ### Env file format
113
+
114
+ ```bash
115
+ # ~/.uqadm/envs/.qa.env
116
+ UNIQUE_USER_ID=user_...
117
+ UNIQUE_COMPANY_ID=company_...
118
+ UNIQUE_API_KEY=ukey_...
119
+ UNIQUE_APP_ID=app_...
120
+ UNIQUE_API_BASE=https://unique_api_base_url
121
+ ```
122
+
123
+ Toolkit-style names are also accepted (lowercase `unique_auth_user_id`, `unique_app_key`, etc.). If both `UNIQUE_*` and its alias are present, `UNIQUE_*` wins.
124
+
125
+ ### Supported variables
126
+
127
+ | Variable | Required | Notes |
128
+ |----------|----------|-------|
129
+ | `UNIQUE_USER_ID` | Yes | Also: `unique_auth_user_id` / `UNIQUE_AUTH_USER_ID` |
130
+ | `UNIQUE_COMPANY_ID` | Yes | Also: `unique_auth_company_id` / `UNIQUE_AUTH_COMPANY_ID` |
131
+ | `UNIQUE_API_KEY` | No | Also: `unique_app_key` / `UNIQUE_APP_KEY` |
132
+ | `UNIQUE_APP_ID` | No | Also: `unique_app_id` |
133
+ | `UNIQUE_API_BASE` | No | Also: `unique_api_base_url` / `UNIQUE_API_BASE_URL`. Host-only URLs get `/public/chat` appended automatically. |
134
+
135
+ ### Authentication debug output
136
+
137
+ If an API call fails with HTTP 401 or an authentication error, `uqadm` prints a redacted credential snapshot to stderr (user id, company id, app id, base URL, and a masked description of the API key — never the full key).
138
+
139
+ ---
140
+
141
+ ## Global options
142
+
143
+ These must appear **before** the subcommand:
144
+
145
+ | Option | Description |
146
+ |--------|-------------|
147
+ | `--help` / `-h` | Show help and exit. |
148
+ | `--version` | Print `uqadm` version and exit. |
149
+ | `--cwd DIRECTORY` | Override the directory used for local env file lookup. |
150
+
151
+ ```bash
152
+ uqadm --version
153
+ uqadm --cwd /path/to/secrets space list --slot qa
154
+ ```
155
+
156
+ ---
157
+
158
+ ## `uqadm env`
159
+
160
+ Manage credential slots in `~/.uqadm/envs/`.
161
+
162
+ ```bash
163
+ uqadm env --help
164
+ ```
165
+
166
+ ### `env create SLOT`
167
+
168
+ Interactively (or non-interactively) create a credential slot file at `~/.uqadm/envs/.{SLOT}.env`.
169
+
170
+ ```bash
171
+ uqadm env create qa
172
+ uqadm env create prod --set-default
173
+ uqadm env create staging --force # overwrite if already exists
174
+ uqadm env create ci --non-interactive \
175
+ --user-id user_abc \
176
+ --company-id company_xyz \
177
+ --api-key ukey_... \
178
+ --api-base https://gateway.unique.app/public/chat-gen2
179
+ ```
180
+
181
+ | Option | Description |
182
+ |--------|-------------|
183
+ | `--set-default` | Mark this slot as the default after creation. |
184
+ | `--force` | Overwrite an existing slot file without prompting. |
185
+ | `--non-interactive` | Skip prompts; supply values via flags below. |
186
+ | `--user-id TEXT` | `UNIQUE_USER_ID` value. |
187
+ | `--company-id TEXT` | `UNIQUE_COMPANY_ID` value. |
188
+ | `--api-key TEXT` | `UNIQUE_API_KEY` value (optional). |
189
+ | `--app-id TEXT` | `UNIQUE_APP_ID` value (optional). |
190
+ | `--api-base TEXT` | `UNIQUE_API_BASE` value (optional). |
191
+
192
+ ### `env list`
193
+
194
+ List all available slots; the default slot is marked with `*`.
195
+
196
+ ```bash
197
+ uqadm env list
198
+ # * qa
199
+ # prod
200
+ # staging
201
+ ```
202
+
203
+ ### `env show [SLOT]`
204
+
205
+ Print the resolved credential values for a slot (API key is redacted). Omit `SLOT` to use the default.
206
+
207
+ ```bash
208
+ uqadm env show
209
+ uqadm env show prod
210
+ ```
211
+
212
+ ### `env set-default SLOT`
213
+
214
+ Set the default slot written to `~/.uqadm/config.toml`.
215
+
216
+ ```bash
217
+ uqadm env set-default prod
218
+ ```
219
+
220
+ ### `env delete SLOT`
221
+
222
+ Remove the env file for a slot (prompts for confirmation unless `-y`).
223
+
224
+ ```bash
225
+ uqadm env delete staging
226
+ uqadm env delete staging -y
227
+ ```
228
+
229
+ ---
230
+
231
+ ## `uqadm space`
232
+
233
+ Space administration commands.
234
+
235
+ ```bash
236
+ uqadm space --help
237
+ ```
238
+
239
+ ### `space list`
240
+
241
+ List all spaces visible to the resolved slot credentials.
242
+
243
+ ```bash
244
+ uqadm space list # uses default slot
245
+ uqadm space list --slot qa
246
+ uqadm space list --slot prod --name Report
247
+ uqadm space list --slot prod --json
248
+ ```
249
+
250
+ | Option | Description |
251
+ |--------|-------------|
252
+ | `--slot SLOT` | Credential slot (default: configured default slot). |
253
+ | `--name TEXT` | Case-insensitive partial filter on space name. |
254
+ | `--json` | Print full result as JSON instead of a table. |
255
+
256
+ ### `space export SPACE_ID`
257
+
258
+ Export a space snapshot to stdout (JSON) or a file.
259
+
260
+ ```bash
261
+ uqadm space export space_abc123 # JSON to stdout
262
+ uqadm space export space_abc123 --slot prod
263
+ uqadm space export space_abc123 -o backup.yaml # YAML file
264
+ uqadm space export space_abc123 -o backup.json
265
+ ```
266
+
267
+ | Option | Description |
268
+ |--------|-------------|
269
+ | `SPACE_ID` | Space id or `https://` URL containing `/space/<id>`. |
270
+ | `--slot SLOT` | Credential slot (default: configured default slot). |
271
+ | `-o`, `--output PATH` | Write to file; suffix must be `.json`, `.yaml`, or `.yml`. Default: stdout. |
272
+
273
+ ### `space upsert`
274
+
275
+ Create or update a space from a local snapshot file. Omit `--target` to create a new space; provide `--target` to update an existing one.
276
+
277
+ ```bash
278
+ uqadm space upsert -f backup.yaml # create on default slot
279
+ uqadm space upsert -f backup.yaml --slot qa # create on specific slot
280
+ uqadm space upsert -f edited.json --target space_dst456 # update existing space
281
+ uqadm space upsert -f backup.yaml --slot prod --target space_dst456
282
+ uqadm space upsert -f backup.yaml --dry-run
283
+ ```
284
+
285
+ | Option | Description |
286
+ |--------|-------------|
287
+ | `-f`, `--file FILE` | Local snapshot (`.json`, `.yaml`, or `.yml`). Required. |
288
+ | `--slot SLOT` | Credential slot (default: configured default slot). |
289
+ | `--target SPACE_ID` | Space id or URL to update. Omit to create a new space. |
290
+ | `--dry-run` | Print actions without calling create/update APIs. |
291
+
292
+ ### `space diff`
293
+
294
+ Compare two spaces. Exits **0** if identical, **1** if differences exist.
295
+
296
+ ```bash
297
+ uqadm space diff --source "qa:space_a" --destination "qa:space_b"
298
+ uqadm space diff --source "qa:space_x" --destination "prod:space_y" --format side-by-side
299
+ uqadm space diff --source "qa:x" --destination "prod:y" --strict
300
+ ```
301
+
302
+ | Option | Description |
303
+ |--------|-------------|
304
+ | `--source SPEC` | First space (`slot:space_id` or `slot:URL`). |
305
+ | `--destination SPEC` | Second space (same format). |
306
+ | `--strict` | Compare raw payloads (skip normalization). |
307
+ | `--format` | `unified` (default) or `side-by-side`. |
308
+
309
+ By default, ephemeral keys (`id`, `createdAt`, `updatedAt`, etc.) are stripped before comparison so you see meaningful config drift.
310
+
311
+ ### `space migrate`
312
+
313
+ Copy assistant configuration from a source space to a destination (new or existing).
314
+
315
+ ```bash
316
+ uqadm space migrate --source "qa:space_src123" --destination "prod:" # create new
317
+ uqadm space migrate --source "qa:space_src123" --destination "prod:space_dst" # update existing
318
+ uqadm space migrate --source "qa:space_src123" --destination "prod:" --dry-run
319
+ ```
320
+
321
+ | Option | Description |
322
+ |--------|-------------|
323
+ | `--source SPEC` | Source space (`slot:space_id` or `slot:URL`). Space id required. |
324
+ | `--destination SPEC` | `slot` / `slot:` to create; `slot:space_id` or `slot:URL` to update. |
325
+ | `--dry-run` | Print actions without making API write calls. |
326
+ | `--with-knowledge` | Reserved; currently informational only. |
327
+
328
+ **Endpoint spec format** (`slot:space_id` or `slot:URL`):
329
+
330
+ | Spec | Slot | Space id |
331
+ |------|------|----------|
332
+ | `qa` | `qa` | *(none — create)* |
333
+ | `qa:` | `qa` | *(none — create)* |
334
+ | `qa:space_abc123` | `qa` | `space_abc123` |
335
+ | `prod:https://host/app/space/space_xyz` | `prod` | `space_xyz` |
336
+
337
+ Supported URL path markers: `/space/<id>`, `/custom-space/<id>`, `/swappable-intelligence-space/<id>`.
338
+
339
+ ### `space delete SPACE_ID`
340
+
341
+ Delete a space (prompts for confirmation unless `-y`).
342
+
343
+ ```bash
344
+ uqadm space delete space_old123
345
+ uqadm space delete space_old123 --slot prod -y
346
+ uqadm space delete space_old123 --dry-run
347
+ ```
348
+
349
+ | Option | Description |
350
+ |--------|-------------|
351
+ | `SPACE_ID` | Space id or `https://` URL containing `/space/<id>`. |
352
+ | `--slot SLOT` | Credential slot (default: configured default slot). |
353
+ | `-y`, `--yes` | Skip the confirmation prompt. |
354
+ | `--dry-run` | Fetch and describe what would be deleted, without deleting. |
355
+
356
+ ---
357
+
358
+ ## `uqadm chat`
359
+
360
+ Send messages to an assistant and inspect conversation history.
361
+
362
+ ```bash
363
+ uqadm chat --help
364
+ ```
365
+
366
+ ### `chat send ASSISTANT_ID`
367
+
368
+ Send a message and print the reply. The `chat_id` of the thread is always shown in the framed header so you can copy it for follow-up messages.
369
+
370
+ **Message input** (pick one):
371
+
372
+ | Method | Flag / Usage |
373
+ |--------|-------------|
374
+ | Inline text | `--text "your message"` |
375
+ | File | `--file ./prompt.txt` |
376
+ | stdin | `echo "message" \| uqadm chat send ASSISTANT_ID` |
377
+
378
+ **Output format:**
379
+
380
+ ```
381
+ ────────────────────────────────────────────────────────────
382
+ chat_id: chat_xyz789
383
+ ────────────────────────────────────────────────────────────
384
+ Here are the latest F1 headlines...
385
+ ────────────────────────────────────────────────────────────
386
+ References
387
+ [1] Formula 1 Official https://www.formula1.com/...
388
+ ────────────────────────────────────────────────────────────
389
+ Evaluation
390
+ APPROVED · accurate
391
+ The answer correctly summarizes recent race results.
392
+ ────────────────────────────────────────────────────────────
393
+ ```
394
+
395
+ References and Evaluation sections only appear when the response includes them. Use `--json` to get the full raw `Space.Message` object instead.
396
+
397
+ **Examples:**
398
+
399
+ ```bash
400
+ # First message — starts a new thread
401
+ uqadm chat send asst_abc123 --text "What are the latest F1 news?"
402
+
403
+ # Follow-up in the same thread
404
+ uqadm chat send asst_abc123 --text "Tell me more about the race" --chat-id chat_xyz789
405
+
406
+ # Specific slot
407
+ uqadm chat send asst_abc123 --text "Hello" --slot prod
408
+
409
+ # Force a tool
410
+ uqadm chat send asst_abc123 --text "Search the web" --tool web_search
411
+
412
+ # Force multiple tools
413
+ uqadm chat send asst_abc123 --text "Run and explain" --tool code_interpreter --tool web_search
414
+
415
+ # Message from a file
416
+ uqadm chat send asst_abc123 --file ./prompt.txt
417
+
418
+ # Piped from stdin
419
+ echo "Summarize this" | uqadm chat send asst_abc123
420
+
421
+ # Increase timeout (default: 300 s)
422
+ uqadm chat send asst_abc123 --text "Complex question" --max-wait 600
423
+
424
+ # Raw JSON output
425
+ uqadm chat send asst_abc123 --text "Hello" --json
426
+ ```
427
+
428
+ **All options:**
429
+
430
+ | Option | Default | Description |
431
+ |--------|---------|-------------|
432
+ | `ASSISTANT_ID` | — | The assistant to message. |
433
+ | `--slot SLOT` | default slot | Credential slot. |
434
+ | `--text TEXT` | — | Inline message text. |
435
+ | `--file PATH` | — | Read message from file. |
436
+ | `--chat-id ID` | — | Continue an existing chat thread. |
437
+ | `--tool NAME` | — | Force a tool (repeatable). |
438
+ | `--max-wait SECS` | `300` | Timeout waiting for a response. |
439
+ | `--poll-interval SECS` | `1.0` | Polling interval between status checks. |
440
+ | `--stop-on` | `stoppedStreamingAt` | Stop condition: `stoppedStreamingAt` or `completedAt`. |
441
+ | `--json` | off | Print raw `Space.Message` JSON. |
442
+
443
+ ### `chat history CHAT_ID`
444
+
445
+ Fetch and display conversation history.
446
+
447
+ By default, shows the **selected token window** (last N messages within a token budget) — useful for reviewing context. Use `--full` to see every message in the thread exactly as stored.
448
+
449
+ ```bash
450
+ uqadm chat history chat_xyz789
451
+ uqadm chat history chat_xyz789 --full
452
+ uqadm chat history chat_xyz789 --full --json
453
+ uqadm chat history chat_xyz789 --slot prod
454
+ ```
455
+
456
+ Output uses the same framed style as `chat send`, with each message in its own block labeled `You` or `Assistant`.
457
+
458
+ | Option | Default | Description |
459
+ |--------|---------|-------------|
460
+ | `CHAT_ID` | — | Chat thread to fetch. |
461
+ | `--slot SLOT` | default slot | Credential slot. |
462
+ | `--full` | off | Show all messages (bypasses token-window selection). |
463
+ | `--json` | off | Print raw message list as JSON. |
464
+ | `--max-tokens INT` | `8000` | Token budget for the windowed view. |
465
+ | `--percent FLOAT` | `0.15` | Fraction of `max-tokens` allocated to history. |
466
+ | `--max-messages INT` | `4` | Maximum number of messages in the windowed view. |
467
+
468
+ ---
469
+
470
+ ## Python module entry
471
+
472
+ ```bash
473
+ python -m uqadm --help
474
+ ```
475
+
476
+ ---
477
+
478
+ ## Related
479
+
480
+ - **`unique-cli`** — SDK file-explorer CLI (`unique_sdk`); unchanged by `uqadm`.
481
+ - **`unique_sdk.cli.config`** — `load_config()` and env semantics shared with `unique-cli`.