voyageai-cli 1.31.0 → 1.33.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 (96) hide show
  1. package/README.md +83 -0
  2. package/package.json +3 -1
  3. package/src/brand/ROBOT_EXAMPLES.md +142 -0
  4. package/src/brand/VaiRobotDesignSystem.jsx +1035 -0
  5. package/src/brand/robot.js +635 -0
  6. package/src/cli.js +24 -1
  7. package/src/commands/about.js +1 -1
  8. package/src/commands/bug.js +95 -12
  9. package/src/commands/chat.js +216 -134
  10. package/src/commands/completions.js +5 -2
  11. package/src/commands/config.js +2 -0
  12. package/src/commands/demo.js +843 -61
  13. package/src/commands/doctor.js +9 -8
  14. package/src/commands/embed.js +89 -43
  15. package/src/commands/explain.js +16 -7
  16. package/src/commands/ingest.js +49 -10
  17. package/src/commands/init.js +51 -1
  18. package/src/commands/models.js +6 -2
  19. package/src/commands/nano.js +52 -0
  20. package/src/commands/optimize.js +1 -1
  21. package/src/commands/pipeline.js +44 -8
  22. package/src/commands/playground.js +241 -5
  23. package/src/commands/purge.js +1 -1
  24. package/src/commands/quickstart.js +11 -12
  25. package/src/commands/refresh.js +1 -1
  26. package/src/commands/reset.js +225 -0
  27. package/src/commands/search.js +22 -5
  28. package/src/commands/telemetry.js +238 -0
  29. package/src/demo/sample-code/handlers/auth.js +100 -0
  30. package/src/demo/sample-code/handlers/health.js +71 -0
  31. package/src/demo/sample-code/handlers/tasks.js +129 -0
  32. package/src/demo/sample-code/middleware/auth.js +123 -0
  33. package/src/demo/sample-code/middleware/errors.js +107 -0
  34. package/src/demo/sample-code/middleware/logger.js +50 -0
  35. package/src/demo/sample-code/middleware/rate-limit.js +73 -0
  36. package/src/demo/sample-code/middleware/validate.js +180 -0
  37. package/src/demo/sample-code/models/database.js +72 -0
  38. package/src/demo/sample-code/models/task.js +182 -0
  39. package/src/demo/sample-code/models/user.js +118 -0
  40. package/src/demo/sample-code/server.js +75 -0
  41. package/src/demo/sample-code/utils/cache.js +130 -0
  42. package/src/demo/sample-code/utils/pagination.js +82 -0
  43. package/src/demo/sample-data/README.md +1 -1
  44. package/src/demo/sample-data/database/backup-recovery.md +217 -176
  45. package/src/demo/sample-data/database/constraints.md +242 -195
  46. package/src/demo/sample-data/database/data-types.md +221 -200
  47. package/src/demo/sample-data/database/indexes.md +232 -109
  48. package/src/demo/sample-data/database/migration-guide.md +245 -268
  49. package/src/demo/sample-data/database/relationships.md +259 -221
  50. package/src/demo/sample-data/database/replication.md +207 -198
  51. package/src/demo/sample-data/database/schema-overview.md +242 -164
  52. package/src/demo/sample-data/database/sharding.md +217 -182
  53. package/src/demo/sample-data/database/transactions.md +198 -185
  54. package/src/demo/sample-data/deployment/caching.md +2 -2
  55. package/src/demo/sample-data/deployment/ci-cd.md +1 -1
  56. package/src/demo/sample-data/deployment/performance-tuning.md +11 -12
  57. package/src/demo/sample-data/errors/alerts.md +2 -2
  58. package/src/demo/sample-data/errors/error-handling.md +2 -2
  59. package/src/demo/sample-data/errors/troubleshooting.md +2 -2
  60. package/src/demos/nano.js +461 -0
  61. package/src/lib/api.js +67 -2
  62. package/src/lib/banner.js +24 -17
  63. package/src/lib/chat-session-stats.js +89 -0
  64. package/src/lib/chat-ui.js +946 -0
  65. package/src/lib/chat.js +61 -4
  66. package/src/lib/demo-ingest.js +307 -73
  67. package/src/lib/explanations.js +98 -36
  68. package/src/lib/optimizer.js +10 -2
  69. package/src/lib/playground-nano-api.js +375 -0
  70. package/src/lib/playground-optimize-api.js +10 -0
  71. package/src/lib/playground-rag-api.js +342 -48
  72. package/src/lib/preflight.js +17 -1
  73. package/src/lib/robot-moments.js +277 -0
  74. package/src/lib/robot.js +597 -0
  75. package/src/lib/telemetry-catalog.js +293 -0
  76. package/src/lib/telemetry.js +263 -28
  77. package/src/lib/ui.js +25 -9
  78. package/src/lib/welcome.js +13 -13
  79. package/src/lib/wizard-cli.js +1 -1
  80. package/src/lib/wizard-steps-global.js +154 -0
  81. package/src/lib/wizard.js +23 -24
  82. package/src/mcp/tools/ingest.js +4 -1
  83. package/src/mcp/tools/utility.js +1 -1
  84. package/src/nano/nano-bridge.py +243 -0
  85. package/src/nano/nano-errors.js +108 -0
  86. package/src/nano/nano-health.js +263 -0
  87. package/src/nano/nano-local.js +42 -0
  88. package/src/nano/nano-manager.js +283 -0
  89. package/src/nano/nano-protocol.js +61 -0
  90. package/src/nano/nano-setup.js +366 -0
  91. package/src/nano/requirements.txt +2 -0
  92. package/src/playground/index.html +2492 -427
  93. package/src/playground/js/kb-manager.js +128 -0
  94. package/src/playground/js/kb-ui.js +183 -9
  95. package/src/playground/js/optimize-charts.js +18 -1
  96. package/src/playground/js/robot-game-assets.js +423 -0
package/README.md CHANGED
@@ -83,6 +83,7 @@ RAG workflows from npm<br/><br/>
83
83
  - [Core Workflow](#core-workflow)
84
84
  - [Individual Commands](#individual-commands)
85
85
  - [Models & Benchmarks](#models--benchmarks)
86
+ - [Local Inference](#local-inference)
86
87
  - [Benchmarking Your Data](#benchmarking-your-data)
87
88
  - [Learn](#learn)
88
89
  - [Environment & Auth](#environment--auth)
@@ -428,6 +429,59 @@ vai models --benchmarks
428
429
 
429
430
  Also available: `voyage-code-3` (code), `voyage-finance-2` (finance), `voyage-law-2` (legal), `rerank-2.5` / `rerank-2.5-lite`.
430
431
 
432
+ ### Local Inference
433
+
434
+ Run embeddings locally with `voyage-4-nano` -- no API key, no network, no cost.
435
+ Nano shares the same embedding space as the Voyage 4 API models, so you can
436
+ prototype locally and upgrade to the API when ready.
437
+
438
+ **Prerequisites:** Python 3.10+ and ~700MB disk space for the model.
439
+
440
+ #### Setup (one-time)
441
+
442
+ ```bash
443
+ vai nano setup # Creates venv, installs deps, downloads model
444
+ vai nano status # Verify everything is ready
445
+ ```
446
+
447
+ #### Usage
448
+
449
+ ```bash
450
+ # Embed text locally
451
+ vai embed "What is MongoDB?" --local
452
+
453
+ # Run the full pipeline locally
454
+ vai pipeline ./docs/ --local --db myapp --collection knowledge
455
+
456
+ # Bulk ingest with local embeddings
457
+ vai ingest --file corpus.jsonl --local --db myapp --collection docs
458
+ ```
459
+
460
+ #### Interactive Demo
461
+
462
+ ```bash
463
+ vai demo nano # Zero-dependency guided walkthrough
464
+ ```
465
+
466
+ Covers similarity matrices, MRL dimension comparison, and interactive REPL --
467
+ all without an API key or MongoDB connection.
468
+
469
+ #### Nano Commands
470
+
471
+ | Command | Description |
472
+ |---------|-------------|
473
+ | `vai nano setup` | Set up Python venv, install deps, download model |
474
+ | `vai nano status` | Check local inference readiness |
475
+ | `vai nano test` | Smoke-test local inference |
476
+ | `vai nano info` | Show model details and cache location |
477
+ | `vai nano clear-cache` | Remove cached model files |
478
+
479
+ #### Upgrade Path
480
+
481
+ Since nano shares the Voyage 4 embedding space, your local embeddings are
482
+ compatible with `voyage-4`, `voyage-4-lite`, and `voyage-4-large`. No
483
+ re-vectorization needed when you add an API key.
484
+
431
485
  ### Benchmarking Your Data
432
486
 
433
487
  Published benchmarks measure average quality across standardized datasets. `vai benchmark` measures what matters for **your** use case:
@@ -532,6 +586,35 @@ vai config set mongodb-uri "mongodb+srv://..."
532
586
 
533
587
  Config is stored in `~/.vai/config.json`. Use `vai config get` to see all values (secrets are masked) or `vai config get <key>` for a specific value. The desktop app's Settings → Database page also reads and writes this file.
534
588
 
589
+ #### Telemetry
590
+
591
+ vai collects anonymous usage telemetry for the CLI and desktop app. On first launch, vai shows a one-time notice before any telemetry is sent. The CLI and desktop app share the same telemetry preference and notice state via `~/.vai/config.json`.
592
+
593
+ Use the built-in telemetry controls:
594
+
595
+ ```bash
596
+ vai telemetry
597
+ vai telemetry off
598
+ vai telemetry on
599
+ vai telemetry status
600
+ vai telemetry reset
601
+ ```
602
+
603
+ You can also disable telemetry with environment variables:
604
+
605
+ ```bash
606
+ export VAI_TELEMETRY=0
607
+ export DO_NOT_TRACK=1
608
+ ```
609
+
610
+ For local auditing, set:
611
+
612
+ ```bash
613
+ export VAI_TELEMETRY_DEBUG=1
614
+ ```
615
+
616
+ This prints telemetry payloads to `stderr` instead of sending them.
617
+
535
618
  ### Shell Completions
536
619
 
537
620
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "voyageai-cli",
3
- "version": "1.31.0",
3
+ "version": "1.33.0",
4
4
  "description": "CLI for Voyage AI embeddings, reranking, and MongoDB Atlas Vector Search",
5
5
  "_comment": "This package contains the CLI + web playground. The electron/ directory is excluded via .npmignore and distributed via GitHub Releases.",
6
6
  "bin": {
@@ -36,6 +36,8 @@
36
36
  },
37
37
  "scripts": {
38
38
  "test": "node --test test/**/*.test.js",
39
+ "reset": "node scripts/reset.js",
40
+ "version": "node scripts/sync-nano-version.js && git add src/nano/nano-bridge.py",
39
41
  "release": "./scripts/release.sh",
40
42
  "app:install": "cd electron && npm install",
41
43
  "app:start": "cd electron && npm start",
@@ -0,0 +1,142 @@
1
+ /**
2
+ * @file ROBOT_INTEGRATION_EXAMPLES.md
3
+ *
4
+ * How to wire robot moments into existing vai commands.
5
+ * Copy the relevant snippets into each command file.
6
+ */
7
+
8
+ // ─────────────────────────────────────────────────────────────────────────────
9
+ // 1. vai --help (src/cli.js or wherever your root yargs setup lives)
10
+ // ─────────────────────────────────────────────────────────────────────────────
11
+
12
+ import { moments } from '../lib/robot-moments.js';
13
+ import { readFileSync } from 'fs';
14
+
15
+ const { version } = JSON.parse(readFileSync('package.json', 'utf8'));
16
+
17
+ // Add before yargs .usage() / .epilog():
18
+ moments.greet({ version, name: config.get('user-name') });
19
+
20
+
21
+ // ─────────────────────────────────────────────────────────────────────────────
22
+ // 2. vai ingest (src/commands/ingest.js)
23
+ // ─────────────────────────────────────────────────────────────────────────────
24
+
25
+ export async function handler(argv) {
26
+ // Show thinking animation while scanning files
27
+ const anim = moments.startThinking(`Scanning ${argv.path}…`);
28
+
29
+ try {
30
+ const files = await scanFiles(argv.path);
31
+ // Update label mid-animation isn't built-in, so just stop and restart:
32
+ anim.stop();
33
+
34
+ const anim2 = moments.startThinking(`Embedding ${files.length} files…`);
35
+ const { chunks } = await embedAndIngest(files, argv);
36
+ anim2.stop('success');
37
+
38
+ moments.success(
39
+ `Indexed ${chunks} chunks from ${files.length} files`,
40
+ [
41
+ `Collection: ${argv.collection}`,
42
+ `Model: ${argv.model ?? 'voyage-4-large'}`,
43
+ `Run 'vai search' to test retrieval`,
44
+ ]
45
+ );
46
+ } catch (err) {
47
+ anim.stop('error');
48
+ moments.error(err.message, 'Check your MongoDB URI and Voyage AI key');
49
+ process.exit(1);
50
+ }
51
+ }
52
+
53
+
54
+ // ─────────────────────────────────────────────────────────────────────────────
55
+ // 3. vai search (src/commands/search.js)
56
+ // ─────────────────────────────────────────────────────────────────────────────
57
+
58
+ export async function handler(argv) {
59
+ const anim = moments.startSearching(
60
+ `Searching ${argv.collection} · top-${argv.k ?? 5}…`
61
+ );
62
+
63
+ try {
64
+ const start = Date.now();
65
+ const hits = await vectorSearch(argv.query, argv);
66
+ anim.stop(hits.length > 0 ? 'success' : 'idle');
67
+
68
+ if (hits.length === 0) {
69
+ moments.noResults(
70
+ argv.collection,
71
+ 'Try a broader query or check that documents are ingested'
72
+ );
73
+ return;
74
+ }
75
+
76
+ moments.results(hits.length, argv.collection, Date.now() - start);
77
+ // ... render hits table as normal
78
+ } catch (err) {
79
+ anim.stop('error');
80
+ moments.error(err.message);
81
+ process.exit(1);
82
+ }
83
+ }
84
+
85
+
86
+ // ─────────────────────────────────────────────────────────────────────────────
87
+ // 4. vai explain (src/commands/explain.js)
88
+ // ─────────────────────────────────────────────────────────────────────────────
89
+
90
+ export async function handler(argv) {
91
+ moments.explain(argv.topic);
92
+ // ... existing explain output continues below
93
+ }
94
+
95
+
96
+ // ─────────────────────────────────────────────────────────────────────────────
97
+ // 5. vai init / vai config (first-run setup)
98
+ // ─────────────────────────────────────────────────────────────────────────────
99
+
100
+ export async function handler(argv) {
101
+ moments.setup('Let\'s configure vai for your project…');
102
+
103
+ // ... prompts, config writing, etc.
104
+
105
+ moments.success(
106
+ 'vai is configured and ready!',
107
+ ['Run \'vai ingest\' to embed your first documents']
108
+ );
109
+ }
110
+
111
+
112
+ // ─────────────────────────────────────────────────────────────────────────────
113
+ // 6. vai chat (src/commands/chat.js) — during RAG retrieval step
114
+ // ─────────────────────────────────────────────────────────────────────────────
115
+
116
+ async function handleTurn(userMessage, session) {
117
+ // Show searching animation during retrieval
118
+ const anim = moments.startSearching(`Searching ${session.collection}…`);
119
+ const docs = await retrieveAndRerank(userMessage, session);
120
+ anim.stop();
121
+
122
+ // Show thinking animation during LLM generation
123
+ const anim2 = moments.startThinking(`Generating with ${session.llmModel}…`);
124
+ const response = await streamGenerate(docs, userMessage, session);
125
+ anim2.stop();
126
+
127
+ // ... stream response to terminal
128
+ }
129
+
130
+
131
+ // ─────────────────────────────────────────────────────────────────────────────
132
+ // 7. Plain/pipe mode guard (add to any command)
133
+ // ─────────────────────────────────────────────────────────────────────────────
134
+
135
+ // Check if output is being piped — skip robot in that case
136
+ const isInteractive = process.stdout.isTTY && !argv.plain && !argv.json;
137
+
138
+ if (isInteractive) {
139
+ moments.greet({ version });
140
+ } else {
141
+ // plain text output only, no robot
142
+ }