nexus-ai-pro 0.7.0 → 0.8.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 (41) hide show
  1. package/EXPLANATION.md +39 -6
  2. package/NEXUS.md +23 -1
  3. package/README.md +83 -27
  4. package/dist/cli.d.ts +2 -0
  5. package/dist/cli.js +418 -0
  6. package/dist/core/config-builder.d.ts +94 -0
  7. package/dist/core/config-builder.js +192 -0
  8. package/dist/core/create-nexus.d.ts +33 -0
  9. package/dist/core/create-nexus.js +180 -0
  10. package/dist/core/nexus.d.ts +91 -0
  11. package/dist/core/nexus.js +129 -1
  12. package/dist/index.d.ts +7 -1
  13. package/dist/index.js +6 -0
  14. package/dist/providers/anthropic.d.ts +2 -0
  15. package/dist/providers/anthropic.js +33 -12
  16. package/dist/providers/azure-openai.d.ts +8 -0
  17. package/dist/providers/azure-openai.js +26 -0
  18. package/dist/providers/deepseek.d.ts +8 -0
  19. package/dist/providers/deepseek.js +14 -0
  20. package/dist/providers/llamacpp.d.ts +8 -0
  21. package/dist/providers/llamacpp.js +15 -0
  22. package/dist/providers/lmstudio.d.ts +8 -0
  23. package/dist/providers/lmstudio.js +15 -0
  24. package/dist/providers/openai.d.ts +2 -0
  25. package/dist/providers/openai.js +37 -14
  26. package/dist/router/auto-router.js +24 -6
  27. package/dist/security/schema-validator.d.ts +4 -4
  28. package/dist/types/config.d.ts +63 -0
  29. package/dist/types/providers.js +17 -1
  30. package/dist/utils/logger.d.ts +5 -1
  31. package/dist/utils/logger.js +54 -4
  32. package/examples/cli-eval.json +16 -0
  33. package/examples/config-builder.ts +18 -0
  34. package/examples/create-nexus.ts +15 -0
  35. package/examples/custom-provider.ts +16 -0
  36. package/examples/exports/README.md +10 -0
  37. package/examples/exports/config.ts +18 -0
  38. package/examples/exports/providers.ts +33 -0
  39. package/examples/exports/root.ts +54 -0
  40. package/examples/exports/runtime-modules.ts +40 -0
  41. package/package.json +12 -2
package/EXPLANATION.md CHANGED
@@ -17,15 +17,15 @@ Most AI apps begin with one provider call. Then the app grows:
17
17
  - documents need RAG
18
18
  - production needs metrics, retries, health checks, and test fixtures
19
19
 
20
- `nexus-ai-pro` puts those pieces behind one main class: `NexusAI`.
20
+ `nexus-ai-pro` puts those pieces behind one main class: `NexusAI`, plus a small `createNexus()` helper for beginner setups.
21
21
 
22
22
  You can use it lightly:
23
23
 
24
24
  ```ts
25
- const ai = new NexusAI({
26
- providers: { openai: { apiKey: process.env.OPENAI_API_KEY! } },
27
- routing: { mode: 'direct' },
28
- defaultModel: 'openai/fast',
25
+ const ai = createNexus({
26
+ provider: 'openai',
27
+ apiKey: process.env.OPENAI_API_KEY!,
28
+ model: 'openai/fast',
29
29
  security: 'off',
30
30
  tokenOptimizer: { enabled: false },
31
31
  });
@@ -91,9 +91,38 @@ Supported adapters:
91
91
  - Groq
92
92
  - Mistral
93
93
  - Cohere
94
+ - DeepSeek
95
+ - Azure OpenAI
96
+ - LM Studio
97
+ - llama.cpp
98
+ - custom OpenAI- or Anthropic-compatible endpoints
94
99
 
95
100
  Provider SDKs are optional peer dependencies. Install only the SDKs your app uses.
96
101
 
102
+ For typed setup without a large config object, use the builder:
103
+
104
+ ```ts
105
+ const ai = createNexusConfig()
106
+ .openai(process.env.OPENAI_API_KEY!)
107
+ .deepseek(process.env.DEEPSEEK_API_KEY!)
108
+ .auto('quality')
109
+ .security('standard')
110
+ .create();
111
+ ```
112
+
113
+ ## CLI
114
+
115
+ The package also installs `nexus`:
116
+
117
+ ```bash
118
+ nexus scan src --json
119
+ nexus models --provider openai
120
+ nexus optimize prompt.txt --max-input-tokens 4000
121
+ nexus eval examples/cli-eval.json
122
+ ```
123
+
124
+ The CLI is intentionally small. It calls the same scanner, model registry, eval runner, and token optimizer that library users can import directly.
125
+
97
126
  ### Routing
98
127
 
99
128
  Routing chooses a model and provider.
@@ -363,12 +392,16 @@ const ai = new NexusAI({
363
392
  retry: { enabled: true, maxRetries: 2 },
364
393
  health: { enabled: true },
365
394
  metrics: { enabled: true },
395
+ logger: { console: false, sink: (event) => console.log(JSON.stringify(event)) },
366
396
  });
367
397
  ```
368
398
 
369
399
  ## Important Files
370
400
 
371
401
  - `src/core/nexus.ts` - main runtime
402
+ - `src/core/create-nexus.ts` - beginner factory
403
+ - `src/core/config-builder.ts` - fluent typed config builder
404
+ - `src/cli.ts` - `nexus` command implementation
372
405
  - `src/providers/*` - provider adapters
373
406
  - `src/router/*` - routing and failover
374
407
  - `src/security/*` - guardrails
@@ -385,7 +418,7 @@ const ai = new NexusAI({
385
418
 
386
419
  ## Known Limitations
387
420
 
388
- - Voice is documented as a roadmap, not a finished runtime.
421
+ - Voice, telephony, local models, and custom providers are optional layers; apps should enable only the pieces they use.
389
422
  - Audio/video preprocessing is limited.
390
423
  - Provider modality support differs and may require preprocessing.
391
424
  - Built-in model metadata is a routing convenience, not a pricing contract.
package/NEXUS.md CHANGED
@@ -49,6 +49,8 @@ Core runtime:
49
49
  - `ai.plan(...)`
50
50
  - `ai.batchComplete(...)`
51
51
  - `ai.createQueue(...)`
52
+ - `createNexus(...)`
53
+ - `createNexusConfig(...)`
52
54
 
53
55
  Provider adapters:
54
56
 
@@ -60,7 +62,18 @@ Provider adapters:
60
62
  - Groq
61
63
  - Mistral
62
64
  - Cohere
63
- - custom providers through `registerProvider(...)`
65
+ - DeepSeek
66
+ - Azure OpenAI
67
+ - LM Studio
68
+ - llama.cpp
69
+ - custom providers through `providers.custom` or `registerProvider(...)`
70
+
71
+ CLI:
72
+
73
+ - `nexus scan`
74
+ - `nexus models`
75
+ - `nexus eval`
76
+ - `nexus optimize`
64
77
 
65
78
  Pipeline layers:
66
79
 
@@ -74,6 +87,7 @@ Pipeline layers:
74
87
  - metrics and provider health
75
88
  - audit logs and rate limits
76
89
  - pipeline hooks and custom steps
90
+ - structured logger hooks
77
91
 
78
92
  Supporting modules:
79
93
 
@@ -219,6 +233,14 @@ npm install
219
233
  npm run build
220
234
  ```
221
235
 
236
+ Quick CLI checks after build:
237
+
238
+ ```bash
239
+ node dist/cli.js models --provider deepseek
240
+ node dist/cli.js scan src --no-fail
241
+ node dist/cli.js optimize README.md --model gpt-5.4-mini
242
+ ```
243
+
222
244
  Main test suite:
223
245
 
224
246
  ```bash
package/README.md CHANGED
@@ -14,7 +14,7 @@ Use the whole pipeline for production AI features, or turn pieces off when you o
14
14
  npm install nexus-ai-pro
15
15
  ```
16
16
 
17
- Install only the provider SDKs your app uses:
17
+ Install only the provider SDKs your app uses. The OpenAI SDK also powers OpenAI-compatible adapters such as OpenRouter, Groq, Mistral, DeepSeek, Azure OpenAI, LM Studio, and llama.cpp.
18
18
 
19
19
  ```bash
20
20
  npm install openai @anthropic-ai/sdk ollama
@@ -25,33 +25,13 @@ The Google Gemini provider uses Node.js `fetch`, so it does not need an extra SD
25
25
  ## Quick Start
26
26
 
27
27
  ```ts
28
- import { NexusAI } from 'nexus-ai-pro';
28
+ import { createNexus } from 'nexus-ai-pro';
29
29
 
30
- const ai = new NexusAI({
31
- providers: {
32
- openai: { apiKey: process.env.OPENAI_API_KEY! },
33
- anthropic: { apiKey: process.env.ANTHROPIC_API_KEY! },
34
- google: { apiKey: process.env.GOOGLE_API_KEY! },
35
- ollama: { baseUrl: 'http://localhost:11434' },
36
- },
37
- routing: {
38
- mode: 'auto',
39
- strategy: 'quality',
40
- },
30
+ const ai = createNexus({
31
+ provider: 'openai',
32
+ apiKey: process.env.OPENAI_API_KEY!,
33
+ model: 'gpt-5.4-mini',
41
34
  security: 'standard',
42
- contextWindow: {
43
- strategy: 'last-messages-with-summary',
44
- lastMessages: 10,
45
- summary: { model: 'openai/fast', maxTokens: 600 },
46
- },
47
- tokenOptimizer: {
48
- densification: { enabled: true },
49
- budget: {
50
- enabled: true,
51
- maxInputTokens: 8000,
52
- onExceeded: 'densify',
53
- },
54
- },
55
35
  });
56
36
 
57
37
  const response = await ai.complete({
@@ -64,6 +44,24 @@ console.log(response.meta.providerUsed);
64
44
  console.log(response.meta.modelUsed);
65
45
  ```
66
46
 
47
+ For a fuller typed config, use the builder:
48
+
49
+ ```ts
50
+ import { createNexusConfig } from 'nexus-ai-pro';
51
+
52
+ const ai = createNexusConfig()
53
+ .openai(process.env.OPENAI_API_KEY!)
54
+ .anthropic(process.env.ANTHROPIC_API_KEY!)
55
+ .deepseek(process.env.DEEPSEEK_API_KEY!)
56
+ .lmstudio({ baseUrl: 'http://localhost:1234/v1' })
57
+ .auto('quality')
58
+ .security('standard')
59
+ .retry({ enabled: true, maxRetries: 2 })
60
+ .create();
61
+ ```
62
+
63
+ You can still pass a plain `NexusAIConfig` to `new NexusAI(...)` when you want full object-literal control.
64
+
67
65
  ## Why Use It
68
66
 
69
67
  `nexus-ai-pro` is useful when an app needs more than a direct SDK call:
@@ -78,6 +76,24 @@ console.log(response.meta.modelUsed);
78
76
  - add tools, agents, RAG context, evals, batch jobs, and queues
79
77
  - keep TypeScript types around every request and response
80
78
 
79
+ ## CLI
80
+
81
+ The package installs a `nexus` command:
82
+
83
+ ```bash
84
+ nexus scan src --json
85
+ nexus models --provider deepseek
86
+ nexus optimize prompt.txt --model gpt-5.4-mini --max-input-tokens 4000
87
+ nexus eval examples/cli-eval.json
88
+ ```
89
+
90
+ CLI commands are intentionally thin wrappers around library modules:
91
+
92
+ - `nexus scan` checks files for secrets, PII, and prompt-injection patterns.
93
+ - `nexus models` lists the bundled model registry.
94
+ - `nexus eval` runs JSON or JS eval cases.
95
+ - `nexus optimize` previews token optimization for a request or prompt file.
96
+
81
97
  ## Core Concepts
82
98
 
83
99
  ### Providers and Routing
@@ -88,7 +104,10 @@ const ai = new NexusAI({
88
104
  openai: { apiKey: process.env.OPENAI_API_KEY! },
89
105
  anthropic: { apiKey: process.env.ANTHROPIC_API_KEY! },
90
106
  groq: { apiKey: process.env.GROQ_API_KEY! },
107
+ deepseek: { apiKey: process.env.DEEPSEEK_API_KEY! },
108
+ openrouter: { apiKey: process.env.OPENROUTER_API_KEY! },
91
109
  ollama: { baseUrl: 'http://localhost:11434' },
110
+ lmstudio: { baseUrl: 'http://localhost:1234/v1' },
92
111
  },
93
112
  routing: {
94
113
  mode: 'auto',
@@ -101,6 +120,22 @@ const ai = new NexusAI({
101
120
  });
102
121
  ```
103
122
 
123
+ First-class provider adapters:
124
+
125
+ - OpenAI
126
+ - Anthropic
127
+ - Google Gemini
128
+ - Ollama
129
+ - OpenRouter
130
+ - Groq
131
+ - Mistral
132
+ - Cohere
133
+ - DeepSeek
134
+ - Azure OpenAI
135
+ - LM Studio
136
+ - llama.cpp
137
+ - custom OpenAI- or Anthropic-compatible endpoints through `providers.custom` or `registerProvider(...)`
138
+
104
139
  Routing modes:
105
140
 
106
141
  - `direct` - always use the requested model or `defaultModel`
@@ -589,6 +624,19 @@ console.log(ai.getPrometheusMetrics());
589
624
  console.log(await ai.checkProviders());
590
625
  ```
591
626
 
627
+ Structured logging can be injected without replacing audit logs or metrics:
628
+
629
+ ```ts
630
+ const ai = createNexusConfig()
631
+ .openai(process.env.OPENAI_API_KEY!)
632
+ .direct('gpt-5.4-mini')
633
+ .logger({
634
+ console: false,
635
+ sink: (event) => myLogger.info(event),
636
+ })
637
+ .create();
638
+ ```
639
+
592
640
  Production controls include:
593
641
 
594
642
  - request timeouts
@@ -599,6 +647,7 @@ Production controls include:
599
647
  - Prometheus metrics
600
648
  - OpenTelemetry metrics and trace export helpers
601
649
  - audit log sink
650
+ - structured logger sink
602
651
  - rate limiting
603
652
 
604
653
  ## Import Surface
@@ -606,17 +655,19 @@ Production controls include:
606
655
  The root import is convenient:
607
656
 
608
657
  ```ts
609
- import { NexusAI } from 'nexus-ai-pro';
658
+ import { NexusAI, createNexus, createNexusConfig } from 'nexus-ai-pro';
610
659
  ```
611
660
 
612
661
  Focused subpaths are available for smaller imports:
613
662
 
614
663
  ```ts
615
664
  import { NexusAI } from 'nexus-ai-pro/core';
665
+ import { createNexusConfig } from 'nexus-ai-pro/config';
616
666
  import { TokenOptimizer } from 'nexus-ai-pro/optimizer';
617
667
  import { ContextWindowManager } from 'nexus-ai-pro/context';
618
668
  import { guardrailPolicy } from 'nexus-ai-pro/security';
619
669
  import { RedisCacheAdapter } from 'nexus-ai-pro/cache';
670
+ import { DeepSeekProvider } from 'nexus-ai-pro/providers/deepseek';
620
671
  ```
621
672
 
622
673
  Provider SDKs are optional peer dependencies. The package is ESM-first and marked with `sideEffects: false`.
@@ -625,6 +676,9 @@ Provider SDKs are optional peer dependencies. The package is ESM-first and marke
625
676
 
626
677
  ```bash
627
678
  npm run example:minimal
679
+ npm run example:create-nexus
680
+ npm run example:config-builder
681
+ npm run example:custom-provider
628
682
  npm run example:feature-flags
629
683
  npm run example:basic
630
684
  npm run example:security
@@ -640,6 +694,8 @@ Included example files cover:
640
694
  - persisted vector stores
641
695
  - classifier calibration
642
696
  - domain workflows
697
+ - custom providers
698
+ - import examples under `examples/exports`
643
699
 
644
700
  ## Test Commands
645
701
 
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};