@agent-nexus/cli 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +765 -0
  2. package/dist/index.js +6409 -265
  3. package/package.json +4 -3
package/README.md ADDED
@@ -0,0 +1,765 @@
1
+ # @agent-nexus/cli
2
+
3
+ Official CLI for the [Nexus](https://nexusgpt.io) AI agent platform. Manage agents, workflows, deployments, knowledge bases, and more from your terminal.
4
+
5
+ - Wraps the full [Nexus Public API v1](../sdk)
6
+ - 24 command groups, 120+ subcommands
7
+ - Table, record, and JSON output modes
8
+ - Pipe-friendly: stdin input, `--json` output, composable with `jq`
9
+ - Zero config after `nexus auth login`
10
+ - Node.js 18+
11
+
12
+ > **Status: BETA** -- The CLI surface is stable but may evolve before 1.0.
13
+
14
+ ---
15
+
16
+ ## Table of Contents
17
+
18
+ - [Installation](#installation)
19
+ - [Authentication](#authentication)
20
+ - [Quick Start](#quick-start)
21
+ - [Global Options](#global-options)
22
+ - [Input Patterns](#input-patterns)
23
+ - [Output Modes](#output-modes)
24
+ - [Commands](#commands)
25
+ - [Common Patterns](#common-patterns)
26
+ - [SDK Cross-Reference](#sdk-cross-reference)
27
+ - [Error Handling](#error-handling)
28
+ - [Troubleshooting](#troubleshooting)
29
+ - [Configuration Files](#configuration-files)
30
+ - [Related Resources](#related-resources)
31
+ - [License](#license)
32
+
33
+ ---
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ # Install globally
39
+ npm install -g @agent-nexus/cli
40
+
41
+ # Or with pnpm
42
+ pnpm add -g @agent-nexus/cli
43
+
44
+ # Or with yarn
45
+ yarn global add @agent-nexus/cli
46
+ ```
47
+
48
+ Run a one-off command without installing:
49
+
50
+ ```bash
51
+ npx @agent-nexus/cli agent list
52
+ ```
53
+
54
+ Verify the installation:
55
+
56
+ ```bash
57
+ nexus --version
58
+ ```
59
+
60
+ Upgrade to the latest version:
61
+
62
+ ```bash
63
+ nexus upgrade
64
+ ```
65
+
66
+ > The CLI checks for updates once per day and prints a notice to stderr when a newer version is available. This check never delays command execution.
67
+
68
+ ---
69
+
70
+ ## Authentication
71
+
72
+ ### Interactive Login
73
+
74
+ ```bash
75
+ nexus auth login
76
+ ```
77
+
78
+ This opens the Nexus settings page in your browser. Copy your API key and paste it at the prompt. The key is validated against the API before being saved.
79
+
80
+ ### Non-Interactive Login
81
+
82
+ For CI/CD or scripting:
83
+
84
+ ```bash
85
+ # Via flag
86
+ nexus auth login --api-key nxs_abc123
87
+
88
+ # Via environment variable (no login needed)
89
+ export NEXUS_API_KEY=nxs_abc123
90
+ ```
91
+
92
+ ### Verify Authentication
93
+
94
+ ```bash
95
+ nexus auth whoami
96
+ ```
97
+
98
+ Prints the API base URL and a masked version of your key (e.g., `nxs_abc1...3def`).
99
+
100
+ ### Logout
101
+
102
+ ```bash
103
+ nexus auth logout
104
+ ```
105
+
106
+ Removes stored credentials from `~/.nexus-mcp/config.json`.
107
+
108
+ ### API Key Resolution
109
+
110
+ The CLI resolves the API key in this order (first match wins):
111
+
112
+ | Priority | Source | Example |
113
+ | -------- | ----------------------- | ------------------------------------ |
114
+ | 1 | `--api-key` flag | `nexus agent list --api-key nxs_...` |
115
+ | 2 | `NEXUS_API_KEY` env var | `export NEXUS_API_KEY=nxs_...` |
116
+ | 3 | Config file | Written by `nexus auth login` |
117
+
118
+ ### Base URL Resolution
119
+
120
+ | Priority | Source | Default |
121
+ | -------- | ------------------------ | ------------------------------------------------------------------------- |
122
+ | 1 | `--base-url` flag | |
123
+ | 2 | `NEXUS_BASE_URL` env var | |
124
+ | 3 | Config file | |
125
+ | 4 | `NEXUS_ENV` env var | `production` = `https://api.nexusgpt.io`, `dev` = `http://localhost:3001` |
126
+ | 5 | Default | `https://api.nexusgpt.io` |
127
+
128
+ ### Multi-Profile Support
129
+
130
+ The CLI supports multiple named profiles for managing different organizations or environments.
131
+
132
+ #### Create profiles
133
+
134
+ ```bash
135
+ # Interactive (opens browser, prompts for key and profile name)
136
+ nexus auth login
137
+
138
+ # Non-interactive with explicit profile name
139
+ nexus auth login --profile work --api-key nxs_abc123
140
+ nexus auth login --profile personal --api-key nxs_xyz789
141
+ ```
142
+
143
+ #### Switch between profiles
144
+
145
+ ```bash
146
+ nexus auth switch work
147
+ nexus auth switch personal
148
+ ```
149
+
150
+ #### List all profiles
151
+
152
+ ```bash
153
+ nexus auth list
154
+ # PROFILE ORGANIZATION BASE URL
155
+ # ▸ work Acme Corp https://api.nexusgpt.io
156
+ # personal My Startup https://api.nexusgpt.io
157
+ ```
158
+
159
+ #### Pin a directory to a profile
160
+
161
+ Create a `.nexusrc` file in your project directory so the CLI automatically uses the right profile:
162
+
163
+ ```bash
164
+ cd ~/projects/acme
165
+ nexus auth pin work
166
+ # Creates .nexusrc with { "profile": "work" }
167
+
168
+ cd ~/projects/startup
169
+ nexus auth pin personal
170
+ ```
171
+
172
+ #### Check which profile is active
173
+
174
+ ```bash
175
+ nexus auth status
176
+ # Using profile "work" (Acme Corp) — .nexusrc at /Users/you/projects/acme/.nexusrc
177
+ ```
178
+
179
+ #### Profile Resolution Order
180
+
181
+ When determining which profile to use, the CLI checks (first match wins):
182
+
183
+ | Priority | Source | Example |
184
+ |----------|--------|---------|
185
+ | 1 | `--api-key` flag or `NEXUS_API_KEY` env | Bypasses profiles entirely |
186
+ | 2 | `--profile` flag | `nexus agent list --profile work` |
187
+ | 3 | `NEXUS_PROFILE` env var | `export NEXUS_PROFILE=work` |
188
+ | 4 | `.nexusrc` file | Walks up directory tree to find `.nexusrc` |
189
+ | 5 | Active profile | Set by `nexus auth switch` |
190
+ | 6 | `"default"` profile | Fallback |
191
+
192
+ #### Remove profiles
193
+
194
+ ```bash
195
+ nexus auth logout # removes active profile
196
+ nexus auth logout work # removes specific profile
197
+ nexus auth logout --all # removes everything
198
+
199
+ nexus auth unpin # removes .nexusrc from current directory
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Quick Start
205
+
206
+ A complete walkthrough: create an agent, give it a knowledge base, deploy it, and test it.
207
+
208
+ ```bash
209
+ # 1. Authenticate
210
+ nexus auth login
211
+
212
+ # 2. Create an agent
213
+ nexus agent create \
214
+ --first-name "Support" \
215
+ --last-name "Bot" \
216
+ --role "Customer Support" \
217
+ --prompt "You are a helpful customer support agent. Answer questions using the knowledge base."
218
+
219
+ # 3. Upload a document to the knowledge base
220
+ nexus document upload ./product-faq.pdf
221
+
222
+ # 4. Create a collection (retrieval-augmented generation index)
223
+ nexus collection create --name "Product FAQ"
224
+
225
+ # 5. Attach the document to the collection
226
+ nexus collection attach-documents <collection-id> --document-ids <document-id>
227
+
228
+ # 6. Attach the collection as a tool on the agent
229
+ nexus agent-tool create <agent-id> \
230
+ --type COLLECTION \
231
+ --collection-id <collection-id> \
232
+ --label "FAQ Search"
233
+
234
+ # 7. Deploy the agent as a web widget
235
+ nexus deployment create \
236
+ --name "Support Widget" \
237
+ --type web \
238
+ --agent-id <agent-id>
239
+
240
+ # 8. Test via the emulator
241
+ nexus emulator session create <deployment-id>
242
+ nexus emulator send <deployment-id> <session-id> \
243
+ --text "How do I reset my password?"
244
+ ```
245
+
246
+ > **Tip:** Add `--json` to any command and pipe to `jq` to extract IDs:
247
+ >
248
+ > ```bash
249
+ > AGENT_ID=$(nexus agent create --first-name Bot --last-name Helper --role QA --json | jq -r '.id')
250
+ > ```
251
+
252
+ ---
253
+
254
+ ## Global Options
255
+
256
+ These flags are available on every command:
257
+
258
+ | Flag | Description |
259
+ | ------------------ | ------------------------------------------------- |
260
+ | `--json` | Output results as JSON (for scripting and piping) |
261
+ | `--api-key <key>` | Override the API key for this invocation |
262
+ | `--base-url <url>` | Override the API base URL |
263
+ | `--profile <name>` | Use a specific named profile |
264
+ | `--no-auto-update` | Disable automatic CLI updates for this invocation |
265
+ | `-v, --version` | Print the CLI version and exit |
266
+ | `--help` | Show help for any command or subcommand |
267
+
268
+ ### Environment Variables
269
+
270
+ | Variable | Description |
271
+ | ---------------- | --------------------------------------------------------------- |
272
+ | `NEXUS_API_KEY` | API key (used when `--api-key` flag and config file are absent) |
273
+ | `NEXUS_BASE_URL` | API base URL override |
274
+ | `NEXUS_ENV` | Environment name: `production` (default) or `dev` |
275
+ | `NEXUS_PROFILE` | Profile name override (same as `--profile` flag) |
276
+ | `NO_COLOR` | Disable all color output ([no-color.org](https://no-color.org)) |
277
+
278
+ ---
279
+
280
+ ## Input Patterns
281
+
282
+ The CLI offers flexible input for create and update commands.
283
+
284
+ ### The `--body` Flag
285
+
286
+ Most create/update commands accept `--body` for raw JSON input:
287
+
288
+ ```bash
289
+ # Inline JSON
290
+ nexus agent create --body '{"firstName":"Ada","lastName":"Bot","role":"Assistant"}'
291
+
292
+ # From a JSON file
293
+ nexus agent create --body payload.json
294
+
295
+ # From stdin
296
+ cat payload.json | nexus agent create --body -
297
+ echo '{"firstName":"Ada","lastName":"Bot","role":"Assistant"}' | nexus agent create --body -
298
+ ```
299
+
300
+ ### Flag-Over-Body Merge
301
+
302
+ When you use both `--body` and individual flags, **flags take precedence**. The body provides defaults; flags override specific fields:
303
+
304
+ ```bash
305
+ # Body sets firstName and role; --role flag overrides the role field
306
+ nexus agent create \
307
+ --body '{"firstName":"Ada","lastName":"Bot","role":"Assistant"}' \
308
+ --role "Senior Assistant"
309
+ # Result: { firstName: "Ada", lastName: "Bot", role: "Senior Assistant" }
310
+ ```
311
+
312
+ ### File and Stdin Input
313
+
314
+ Flags like `--prompt`, `--content`, and `--description` accept:
315
+
316
+ | Input | Example |
317
+ | ------------ | ---------------------------------------------------------------- |
318
+ | Literal text | `--prompt "You are a helpful agent"` |
319
+ | File path | `--prompt ./system-prompt.md` (auto-detected if the file exists) |
320
+ | Stdin | `--prompt -` (reads from stdin) |
321
+
322
+ ```bash
323
+ # Load a prompt from a markdown file
324
+ nexus agent create --first-name Bot --last-name Helper --role QA --prompt ./prompt.md
325
+
326
+ # Pipe a prompt from another command
327
+ generate-prompt | nexus agent update abc-123 --prompt -
328
+ ```
329
+
330
+ ### Pagination
331
+
332
+ List commands support pagination:
333
+
334
+ ```bash
335
+ nexus agent list --page 2 --limit 50
336
+ ```
337
+
338
+ The pagination footer shows `total`, `page`, and whether `more available`.
339
+
340
+ ---
341
+
342
+ ## Output Modes
343
+
344
+ ### Table (Default for Lists)
345
+
346
+ ```
347
+ ID FIRST NAME STATUS
348
+ ──────────────────────────────────── ─────────────── ──────
349
+ abc-123-def-456 Support Bot ACTIVE
350
+ ghi-789-jkl-012 Sales Agent DRAFT
351
+
352
+ 3 total · page 1 · more available
353
+ ```
354
+
355
+ ### Record (Default for Single Resources)
356
+
357
+ ```
358
+ ID abc-123-def-456
359
+ Name Support Bot
360
+ Role Customer Support
361
+ Status ACTIVE
362
+ Created 2026-03-15T10:30:00.000Z
363
+ ```
364
+
365
+ ### JSON (`--json`)
366
+
367
+ ```bash
368
+ nexus agent list --json
369
+ ```
370
+
371
+ ```json
372
+ {
373
+ "data": [{ "id": "abc-123", "firstName": "Support", "lastName": "Bot", "status": "ACTIVE" }],
374
+ "meta": { "total": 3, "page": 1, "hasMore": true }
375
+ }
376
+ ```
377
+
378
+ ```bash
379
+ nexus agent get abc-123 --json
380
+ ```
381
+
382
+ ```json
383
+ {
384
+ "id": "abc-123",
385
+ "firstName": "Support",
386
+ "lastName": "Bot",
387
+ "role": "Customer Support",
388
+ "status": "ACTIVE"
389
+ }
390
+ ```
391
+
392
+ > **Important:** Always use `--json` when piping output to `jq` or other tools. The default table output is for humans and will break parsers.
393
+
394
+ ### Error Output in JSON Mode
395
+
396
+ When `--json` is active, errors are also returned as JSON:
397
+
398
+ ```json
399
+ {
400
+ "error": {
401
+ "message": "Authentication failed — invalid or missing API key.",
402
+ "hint": "Run \"nexus auth login\" to re-authenticate, or set NEXUS_API_KEY."
403
+ }
404
+ }
405
+ ```
406
+
407
+ ---
408
+
409
+ ## Commands
410
+
411
+ All commands follow the pattern: `nexus <group> <action> [arguments] [options]`
412
+
413
+ ### Core Platform
414
+
415
+ | Command | Subcommands | Description |
416
+ | ---------------------------------------------------------- | ----------------------------------------------------------- | ------------------------- |
417
+ | [`auth`](docs/command-reference.md#nexus-auth) | `login` `logout` `switch` `list` `pin` `unpin` `status` `whoami` | Authentication |
418
+ | [`agent`](docs/command-reference.md#nexus-agent) | `list` `get` `create` `update` `delete` `duplicate` | AI agent management |
419
+ | [`agent-tool`](docs/command-reference.md#nexus-agent-tool) | `list` `get` `create` `update` `delete` | Agent tool configurations |
420
+ | [`version`](docs/command-reference.md#nexus-version) | `list` `get` `create` `update` `delete` `restore` `publish` | Prompt version management |
421
+ | [`folder`](docs/command-reference.md#nexus-folder) | `list` `create` `update` `delete` `assign` | Agent folder organization |
422
+ | [`model`](docs/command-reference.md#nexus-model) | `list` | Available AI models |
423
+
424
+ ### Workflows & Execution
425
+
426
+ | Command | Subcommands | Description |
427
+ | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | --------------------------- |
428
+ | [`workflow`](docs/command-reference.md#nexus-workflow) | `list` `get` `create` `update` `delete` `duplicate` `publish` `unpublish` `validate` `test` | Workflow CRUD and lifecycle |
429
+ | [`workflow node`](docs/command-reference.md#nexus-workflow-node) | `create` `get` `update` `delete` `test` `variables` `output-format` `reload-props` | Workflow node operations |
430
+ | [`workflow edge`](docs/command-reference.md#nexus-workflow-edge) | `create` `delete` | Node connections |
431
+ | [`workflow branch`](docs/command-reference.md#nexus-workflow-branch) | `list` `create` `update` `delete` | Branching logic |
432
+ | [`execution`](docs/command-reference.md#nexus-execution) | `list` `get` `graph` `output` `retry` `export` `node-result` | Workflow execution history |
433
+
434
+ ### Knowledge & Documents
435
+
436
+ | Command | Subcommands | Description |
437
+ | ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------- |
438
+ | [`document`](docs/command-reference.md#nexus-document) | `list` `get` `upload` `create-text` `add-website` `import-google-sheets` `delete` | Knowledge documents |
439
+ | [`collection`](docs/command-reference.md#nexus-collection) | `list` `get` `create` `update` `delete` `search` `documents` `attach-documents` `remove-document` `stats` | Knowledge collections |
440
+
441
+ ### Skills & Tasks
442
+
443
+ | Command | Subcommands | Description |
444
+ | ---------------------------------------------------------------- | ------------------------------------------------- | ---------------------- |
445
+ | [`task`](docs/command-reference.md#nexus-task) | `list` `get` `create` `update` `delete` `execute` | AI task management |
446
+ | [`template`](docs/command-reference.md#nexus-template) | `list` `get` `create` `upload` `generate` | Document templates |
447
+ | [`external-tool`](docs/command-reference.md#nexus-external-tool) | `list` `get` `create` `update` `delete` `test` | OpenAPI external tools |
448
+
449
+ ### Deployment & Testing
450
+
451
+ | Command | Subcommands | Description |
452
+ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | --------------------------------- |
453
+ | [`deployment`](docs/command-reference.md#nexus-deployment) | `list` `get` `create` `update` `delete` `duplicate` `stats` `embed-config` `embed-config-update` | Agent deployments |
454
+ | [`deployment folder`](docs/command-reference.md#nexus-deployment-folder) | `list` `create` `update` `delete` `assign` | Deployment folder organization |
455
+ | [`emulator`](docs/command-reference.md#nexus-emulator) | `send` | Send messages to test deployments |
456
+ | [`emulator session`](docs/command-reference.md#nexus-emulator-session) | `create` `list` `get` `delete` | Emulator session management |
457
+ | [`emulator scenario`](docs/command-reference.md#nexus-emulator-scenario) | `save` `list` `get` `replay` `delete` | Save and replay test scenarios |
458
+
459
+ ### Marketplace & Discovery
460
+
461
+ | Command | Subcommands | Description |
462
+ | ---------------------------------------------- | ------------------------------------------------------------------------ | -------------------------- |
463
+ | [`tool`](docs/command-reference.md#nexus-tool) | `search` `get` `credentials` `connect` `resolve-options` `skills` `test` | Marketplace tool discovery |
464
+
465
+ ### Analytics & Operations
466
+
467
+ | Command | Subcommands | Description |
468
+ | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | -------------------------- |
469
+ | [`analytics`](docs/command-reference.md#nexus-analytics) | `overview` `feedback` `export` | Organization analytics |
470
+ | [`eval`](docs/command-reference.md#nexus-eval) | (subgroups: `session`, `dataset`, `execute`, `judge`, `results`, `formats`, `judges`) | AI task evaluation |
471
+ | [`ticket`](docs/command-reference.md#nexus-ticket) | `list` `get` `create` `update` `comment` `comments` | Bug and feature tracking |
472
+ | [`phone-number`](docs/command-reference.md#nexus-phone-number) | `search` `buy` `list` `get` `release` | Phone number management |
473
+ | [`prompt-assistant`](docs/command-reference.md#nexus-prompt-assistant) | `chat` `get-thread` `delete-thread` | AI-assisted prompt writing |
474
+
475
+ ### Utility
476
+
477
+ | Command | Subcommands | Description |
478
+ | ---------------------------------------------------- | ------------- | ------------------------------ |
479
+ | [`api`](docs/command-reference.md#nexus-api) | (passthrough) | Call any API endpoint directly |
480
+ | [`docs`](docs/command-reference.md#nexus-docs) | (topic browser) | View built-in documentation |
481
+ | [`upgrade`](docs/command-reference.md#nexus-upgrade) | (self-update) | Upgrade the CLI to latest |
482
+
483
+ > **Full reference:** See [docs/command-reference.md](docs/command-reference.md) for complete documentation of every command, option, and example.
484
+
485
+ ---
486
+
487
+ ## Common Patterns
488
+
489
+ ### Extract IDs with `jq`
490
+
491
+ ```bash
492
+ # Get the ID of a newly created agent
493
+ AGENT_ID=$(nexus agent create \
494
+ --first-name Bot --last-name Helper --role QA --json | jq -r '.id')
495
+ echo "Created agent: $AGENT_ID"
496
+ ```
497
+
498
+ ### Pipe JSON Output
499
+
500
+ ```bash
501
+ # List all active agent IDs
502
+ nexus agent list --json | jq -r '.data[] | select(.status == "ACTIVE") | .id'
503
+
504
+ # Count deployments by type
505
+ nexus deployment list --json | jq '.data | group_by(.type) | map({type: .[0].type, count: length})'
506
+ ```
507
+
508
+ ### Bulk Operations
509
+
510
+ ```bash
511
+ # Update all agents to use a specific model
512
+ nexus agent list --json | jq -r '.data[].id' | while read id; do
513
+ nexus agent update "$id" --model gpt-4o
514
+ echo "Updated $id"
515
+ done
516
+ ```
517
+
518
+ ### Raw API Passthrough
519
+
520
+ For endpoints without a dedicated CLI command:
521
+
522
+ ```bash
523
+ # GET request
524
+ nexus api GET /models
525
+
526
+ # POST with inline body
527
+ nexus api POST /agents --body '{"firstName":"Test","lastName":"Bot","role":"QA"}'
528
+
529
+ # GET with query parameters
530
+ nexus api GET /agents --query page=1 --query limit=5
531
+
532
+ # POST with body from file
533
+ nexus api PATCH /agents/abc-123 --body payload.json
534
+
535
+ # POST with body from stdin
536
+ echo '{"text":"hello"}' | nexus api POST /emulator/dep-1/sessions/s-1/messages --body -
537
+ ```
538
+
539
+ ### Suppress Confirmation Prompts (CI/CD)
540
+
541
+ ```bash
542
+ # Skip delete confirmation
543
+ nexus agent delete abc-123 --yes
544
+
545
+ # Preview what would be deleted without executing
546
+ nexus agent delete abc-123 --dry-run
547
+ ```
548
+
549
+ ### Load Prompts from Files
550
+
551
+ ```bash
552
+ # Create an agent with a prompt from a markdown file
553
+ nexus agent create \
554
+ --first-name Support --last-name Bot --role "Customer Support" \
555
+ --prompt ./prompts/support-agent.md
556
+
557
+ # Update an agent's prompt from stdin
558
+ cat new-prompt.md | nexus agent update abc-123 --prompt -
559
+ ```
560
+
561
+ ### Workflow Build Pipeline
562
+
563
+ ```bash
564
+ # Create, build, validate, test, and publish in one pipeline
565
+ WF_ID=$(nexus workflow create --name "Lead Qualifier" --json | jq -r '.id')
566
+
567
+ nexus workflow node create $WF_ID --type agentInputTrigger --name "Start"
568
+ nexus workflow node create $WF_ID --type aiTask --name "Qualify" \
569
+ --body '{"data":{"taskId":"task-123"}}'
570
+
571
+ nexus workflow validate $WF_ID
572
+ nexus workflow test $WF_ID --input '{"message":"I want to buy 100 units"}'
573
+ nexus workflow publish $WF_ID
574
+ ```
575
+
576
+ ---
577
+
578
+ ## SDK Cross-Reference
579
+
580
+ Every CLI command maps to an SDK method. Use the SDK (`@agent-nexus/sdk`) when building applications; use the CLI for scripting and exploration.
581
+
582
+ | CLI Command | SDK Equivalent |
583
+ | --------------------------------------- | ----------------------------------------------------- |
584
+ | `nexus agent list` | `client.agents.list()` |
585
+ | `nexus agent get <id>` | `client.agents.get(id)` |
586
+ | `nexus agent create --first-name X ...` | `client.agents.create({ firstName: "X", ... })` |
587
+ | `nexus agent update <id> --role Y` | `client.agents.update(id, { role: "Y" })` |
588
+ | `nexus agent delete <id>` | `client.agents.delete(id)` |
589
+ | `nexus agent-tool list <agentId>` | `client.agents.tools.list(agentId)` |
590
+ | `nexus version list <agentId>` | `client.agents.versions.list(agentId)` |
591
+ | `nexus workflow list` | `client.workflows.list()` |
592
+ | `nexus workflow publish <id>` | `client.workflows.publish(id)` |
593
+ | `nexus document upload <file>` | `client.documents.uploadFile(file)` |
594
+ | `nexus collection create --name X` | `client.documents.createCollection({ name: "X" })` |
595
+ | `nexus deployment create --name X ...` | `client.deployments.create({ name: "X", ... })` |
596
+ | `nexus emulator session create <depId>` | `client.emulator.createSession(depId)` |
597
+ | `nexus emulator send <depId> <sessId>` | `client.emulator.sendMessage(depId, sessId, { ... })` |
598
+ | `nexus tool search --query X` | `client.tools.search({ query: "X" })` |
599
+ | `nexus analytics overview` | `client.analytics.getOverview()` |
600
+ | `nexus model list` | `client.models.list()` |
601
+ | `nexus ticket create --title X ...` | `client.tickets.create({ title: "X", ... })` |
602
+ | `nexus phone-number list` | `client.phoneNumbers.list()` |
603
+
604
+ > **Full SDK documentation:** See [@agent-nexus/sdk README](../sdk/README.md)
605
+
606
+ ---
607
+
608
+ ## Error Handling
609
+
610
+ The CLI catches all errors and prints actionable messages with hints.
611
+
612
+ ### Error Types
613
+
614
+ | Error | Cause | Hint |
615
+ | -------------------------- | ------------------------------------ | ------------------------------------------------------ |
616
+ | **Authentication failed** | Invalid, missing, or expired API key | Run `nexus auth login` or set `NEXUS_API_KEY` |
617
+ | **Not found (404)** | Resource ID doesn't exist | Run `nexus <resource> list` to find valid IDs |
618
+ | **Validation error (422)** | Invalid request body or parameters | Add `--json` to see the `details` field |
619
+ | **Connection error** | Network issue or wrong base URL | Check `--base-url` and network connectivity |
620
+ | **API error (5xx)** | Server-side error | Retry after a moment; report via `nexus ticket create` |
621
+
622
+ ### Exit Codes
623
+
624
+ | Code | Meaning |
625
+ | ---- | ------------------------------------------------------------- |
626
+ | `0` | Success |
627
+ | `1` | Any error (authentication, API, validation, connection, etc.) |
628
+
629
+ ### Error Format
630
+
631
+ **Human-readable (default):**
632
+
633
+ ```
634
+ Error: Authentication failed — invalid or missing API key.
635
+ Run "nexus auth login" to re-authenticate, or set NEXUS_API_KEY.
636
+ ```
637
+
638
+ **JSON (`--json`):**
639
+
640
+ ```json
641
+ {
642
+ "error": {
643
+ "message": "Authentication failed — invalid or missing API key.",
644
+ "hint": "Run \"nexus auth login\" to re-authenticate, or set NEXUS_API_KEY."
645
+ }
646
+ }
647
+ ```
648
+
649
+ ---
650
+
651
+ ## Troubleshooting
652
+
653
+ ### "No API key found"
654
+
655
+ ```
656
+ Error: No API key found. Set NEXUS_API_KEY or run:
657
+ nexus auth login
658
+ ```
659
+
660
+ **Fix:** Run `nexus auth login` or set the `NEXUS_API_KEY` environment variable.
661
+
662
+ ### "Invalid key format -- keys start with nxs\_"
663
+
664
+ **Fix:** Copy the full API key from Settings > API Keys, including the `nxs_` prefix.
665
+
666
+ ### "Could not reach the Nexus API"
667
+
668
+ **Fix:** Check your network connection. If using a custom base URL, verify it:
669
+
670
+ ```bash
671
+ nexus auth whoami # shows the current base URL
672
+ ```
673
+
674
+ ### "Validation failed (HTTP 401)"
675
+
676
+ **Fix:** Your API key may be expired or revoked. Regenerate it at [Settings > API Keys](https://app.nexusgpt.io/app/settings/api-keys) and run `nexus auth login` again.
677
+
678
+ ### Colors Not Showing
679
+
680
+ The CLI disables colors when:
681
+
682
+ - `NO_COLOR` environment variable is set
683
+ - `--no-color` flag is passed
684
+ - stdout is not a TTY (e.g., piped to a file or another command)
685
+
686
+ ### Update Check Not Working
687
+
688
+ The version check cache is stored at `~/.nexus-mcp/version-check.json`. Delete it to force a fresh check:
689
+
690
+ ```bash
691
+ rm ~/.nexus-mcp/version-check.json
692
+ nexus agent list # triggers a new check
693
+ ```
694
+
695
+ ### Upgrade Failed
696
+
697
+ If `nexus upgrade` fails (e.g., permission denied), run the install manually:
698
+
699
+ ```bash
700
+ sudo npm install -g @agent-nexus/cli@latest
701
+ ```
702
+
703
+ ---
704
+
705
+ ## Configuration Files
706
+
707
+ | File | Purpose | Permissions |
708
+ |------|---------|-------------|
709
+ | `~/.nexus-mcp/config.json` | Profiles with API keys and base URLs | `0600` |
710
+ | `~/.nexus-mcp/version-check.json` | Update check cache (auto-managed, checked once/day) | `0600` |
711
+ | `.nexusrc` | Directory-level profile pinning (created by `nexus auth pin`) | — |
712
+
713
+ The `~/.nexus-mcp/` directory is created with `0700` permissions. This path is shared with the [`@nexus/mcp-server`](../mcp-server/) package.
714
+
715
+ ### Config File Format (V2)
716
+
717
+ ```json
718
+ {
719
+ "activeProfile": "work",
720
+ "profiles": {
721
+ "work": {
722
+ "apiKey": "nxs_...",
723
+ "baseUrl": "https://api.nexusgpt.io",
724
+ "orgName": "Acme Corp",
725
+ "orgId": "org_..."
726
+ },
727
+ "personal": {
728
+ "apiKey": "nxs_...",
729
+ "orgName": "My Startup"
730
+ }
731
+ }
732
+ }
733
+ ```
734
+
735
+ ### .nexusrc Format
736
+
737
+ ```json
738
+ { "profile": "work" }
739
+ ```
740
+
741
+ Place in your project root. The CLI walks up the directory tree to find it. Consider adding `.nexusrc` to `.gitignore`.
742
+
743
+ ---
744
+
745
+ ## Related Resources
746
+
747
+ | Resource | Link |
748
+ | --------------------- | ------------------------------------------------------------------------------ |
749
+ | SDK | [`@agent-nexus/sdk`](../sdk/README.md) |
750
+ | Product Documentation | [`packages/docs`](../docs/) |
751
+ | Claude Code Skills | [`packages/claude-code-skills`](../claude-code-skills/) |
752
+ | API Reference | `https://api.nexusgpt.io/api/public/v1` |
753
+ | Dashboard | [app.nexusgpt.io](https://app.nexusgpt.io) |
754
+ | CLI Command Reference | [docs/command-reference.md](docs/command-reference.md) |
755
+ | Input/Output Guide | [docs/input-output-patterns.md](docs/input-output-patterns.md) |
756
+ | Common Gotchas | [docs/gotchas.md](docs/gotchas.md) |
757
+ | Recipes | [docs/recipes.md](docs/recipes.md) |
758
+ | Report Issues | `nexus ticket create --type BUG --title "..." --description "..."` |
759
+ | Request Features | `nexus ticket create --type FEATURE_REQUEST --title "..." --description "..."` |
760
+
761
+ ---
762
+
763
+ ## License
764
+
765
+ [MIT](LICENSE)