nexus-ai-pro 0.2.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 (171) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1249 -0
  3. package/assets/nexus-ai-pro-presentation.jpg +0 -0
  4. package/dist/agent/loop.d.ts +12 -0
  5. package/dist/agent/loop.js +89 -0
  6. package/dist/agent/tool.d.ts +16 -0
  7. package/dist/agent/tool.js +43 -0
  8. package/dist/cache/adapters.d.ts +42 -0
  9. package/dist/cache/adapters.js +76 -0
  10. package/dist/cache/memory-cache.d.ts +20 -0
  11. package/dist/cache/memory-cache.js +63 -0
  12. package/dist/cache/semantic-cache.d.ts +19 -0
  13. package/dist/cache/semantic-cache.js +71 -0
  14. package/dist/connectors/web.d.ts +8 -0
  15. package/dist/connectors/web.js +60 -0
  16. package/dist/core/nexus.d.ts +71 -0
  17. package/dist/core/nexus.js +477 -0
  18. package/dist/core/response-format.d.ts +8 -0
  19. package/dist/core/response-format.js +121 -0
  20. package/dist/core/secure-stream.d.ts +3 -0
  21. package/dist/core/secure-stream.js +41 -0
  22. package/dist/core/streaming.d.ts +4 -0
  23. package/dist/core/streaming.js +30 -0
  24. package/dist/embeddings/providers.d.ts +20 -0
  25. package/dist/embeddings/providers.js +60 -0
  26. package/dist/evals/metrics.d.ts +75 -0
  27. package/dist/evals/metrics.js +157 -0
  28. package/dist/evals/runner.d.ts +35 -0
  29. package/dist/evals/runner.js +47 -0
  30. package/dist/hallucination/consistency.d.ts +14 -0
  31. package/dist/hallucination/consistency.js +58 -0
  32. package/dist/hallucination/factual.d.ts +14 -0
  33. package/dist/hallucination/factual.js +35 -0
  34. package/dist/hallucination/knowledge-graph.d.ts +27 -0
  35. package/dist/hallucination/knowledge-graph.js +70 -0
  36. package/dist/hallucination/rag.d.ts +21 -0
  37. package/dist/hallucination/rag.js +46 -0
  38. package/dist/hallucination/retrieval.d.ts +24 -0
  39. package/dist/hallucination/retrieval.js +71 -0
  40. package/dist/hallucination/verification.d.ts +36 -0
  41. package/dist/hallucination/verification.js +110 -0
  42. package/dist/index.d.ts +62 -0
  43. package/dist/index.js +53 -0
  44. package/dist/jobs/batch.d.ts +11 -0
  45. package/dist/jobs/batch.js +32 -0
  46. package/dist/jobs/durable-adapters.d.ts +48 -0
  47. package/dist/jobs/durable-adapters.js +50 -0
  48. package/dist/jobs/queue.d.ts +24 -0
  49. package/dist/jobs/queue.js +57 -0
  50. package/dist/models/registry.d.ts +15 -0
  51. package/dist/models/registry.js +43 -0
  52. package/dist/next/route-handler.d.ts +6 -0
  53. package/dist/next/route-handler.js +35 -0
  54. package/dist/ops/audit-logger.d.ts +6 -0
  55. package/dist/ops/audit-logger.js +19 -0
  56. package/dist/ops/health.d.ts +29 -0
  57. package/dist/ops/health.js +69 -0
  58. package/dist/ops/metrics.d.ts +53 -0
  59. package/dist/ops/metrics.js +122 -0
  60. package/dist/ops/otel-tracing.d.ts +20 -0
  61. package/dist/ops/otel-tracing.js +50 -0
  62. package/dist/ops/rate-limiter.d.ts +11 -0
  63. package/dist/ops/rate-limiter.js +33 -0
  64. package/dist/optimizer/budget.d.ts +19 -0
  65. package/dist/optimizer/budget.js +88 -0
  66. package/dist/optimizer/cost.d.ts +13 -0
  67. package/dist/optimizer/cost.js +31 -0
  68. package/dist/optimizer/densifier.d.ts +10 -0
  69. package/dist/optimizer/densifier.js +77 -0
  70. package/dist/optimizer/index.d.ts +12 -0
  71. package/dist/optimizer/index.js +59 -0
  72. package/dist/pipeline/pipeline.d.ts +14 -0
  73. package/dist/pipeline/pipeline.js +106 -0
  74. package/dist/pipeline/types.d.ts +46 -0
  75. package/dist/pipeline/types.js +1 -0
  76. package/dist/providers/anthropic.d.ts +15 -0
  77. package/dist/providers/anthropic.js +183 -0
  78. package/dist/providers/base.d.ts +19 -0
  79. package/dist/providers/base.js +75 -0
  80. package/dist/providers/cohere.d.ts +16 -0
  81. package/dist/providers/cohere.js +104 -0
  82. package/dist/providers/google.d.ts +22 -0
  83. package/dist/providers/google.js +226 -0
  84. package/dist/providers/groq.d.ts +15 -0
  85. package/dist/providers/groq.js +50 -0
  86. package/dist/providers/mistral.d.ts +15 -0
  87. package/dist/providers/mistral.js +50 -0
  88. package/dist/providers/ollama.d.ts +15 -0
  89. package/dist/providers/ollama.js +108 -0
  90. package/dist/providers/openai.d.ts +21 -0
  91. package/dist/providers/openai.js +304 -0
  92. package/dist/providers/openrouter.d.ts +14 -0
  93. package/dist/providers/openrouter.js +19 -0
  94. package/dist/rag/file-ingestion.d.ts +20 -0
  95. package/dist/rag/file-ingestion.js +55 -0
  96. package/dist/rag/ingestion.d.ts +21 -0
  97. package/dist/rag/ingestion.js +47 -0
  98. package/dist/router/auto-router.d.ts +17 -0
  99. package/dist/router/auto-router.js +228 -0
  100. package/dist/router/failover.d.ts +21 -0
  101. package/dist/router/failover.js +126 -0
  102. package/dist/router/index.d.ts +12 -0
  103. package/dist/router/index.js +31 -0
  104. package/dist/router/rules-router.d.ts +7 -0
  105. package/dist/router/rules-router.js +68 -0
  106. package/dist/router/types.d.ts +19 -0
  107. package/dist/router/types.js +1 -0
  108. package/dist/security/index.d.ts +31 -0
  109. package/dist/security/index.js +173 -0
  110. package/dist/security/injection-calibration.d.ts +17 -0
  111. package/dist/security/injection-calibration.js +48 -0
  112. package/dist/security/injection-detector.d.ts +8 -0
  113. package/dist/security/injection-detector.js +66 -0
  114. package/dist/security/input-guard.d.ts +7 -0
  115. package/dist/security/input-guard.js +109 -0
  116. package/dist/security/output-guard.d.ts +6 -0
  117. package/dist/security/output-guard.js +144 -0
  118. package/dist/security/pii-detector.d.ts +8 -0
  119. package/dist/security/pii-detector.js +66 -0
  120. package/dist/security/policies.d.ts +4 -0
  121. package/dist/security/policies.js +61 -0
  122. package/dist/security/prompt-hardening.d.ts +6 -0
  123. package/dist/security/prompt-hardening.js +18 -0
  124. package/dist/security/schema-validator.d.ts +234 -0
  125. package/dist/security/schema-validator.js +68 -0
  126. package/dist/security/semantic-injection-classifier.d.ts +19 -0
  127. package/dist/security/semantic-injection-classifier.js +75 -0
  128. package/dist/security/upload-scanner.d.ts +29 -0
  129. package/dist/security/upload-scanner.js +72 -0
  130. package/dist/testing/provider-conformance.d.ts +24 -0
  131. package/dist/testing/provider-conformance.js +97 -0
  132. package/dist/types/agent.d.ts +34 -0
  133. package/dist/types/agent.js +1 -0
  134. package/dist/types/config.d.ts +171 -0
  135. package/dist/types/config.js +1 -0
  136. package/dist/types/messages.d.ts +96 -0
  137. package/dist/types/messages.js +1 -0
  138. package/dist/types/optimizer.d.ts +30 -0
  139. package/dist/types/optimizer.js +1 -0
  140. package/dist/types/planning.d.ts +27 -0
  141. package/dist/types/planning.js +1 -0
  142. package/dist/types/providers.d.ts +39 -0
  143. package/dist/types/providers.js +479 -0
  144. package/dist/types/response.d.ts +55 -0
  145. package/dist/types/response.js +1 -0
  146. package/dist/types/security.d.ts +87 -0
  147. package/dist/types/security.js +1 -0
  148. package/dist/utils/ids.d.ts +1 -0
  149. package/dist/utils/ids.js +4 -0
  150. package/dist/utils/logger.d.ts +7 -0
  151. package/dist/utils/logger.js +17 -0
  152. package/dist/utils/tokenizer.d.ts +6 -0
  153. package/dist/utils/tokenizer.js +38 -0
  154. package/dist/workflow/chains.d.ts +53 -0
  155. package/dist/workflow/chains.js +117 -0
  156. package/dist/workflow/domain.d.ts +22 -0
  157. package/dist/workflow/domain.js +96 -0
  158. package/examples/agent.ts +69 -0
  159. package/examples/basic.ts +37 -0
  160. package/examples/bullmq-worker.ts +36 -0
  161. package/examples/classifier-calibration.ts +7 -0
  162. package/examples/domain-workflows.ts +38 -0
  163. package/examples/feature-flags.ts +65 -0
  164. package/examples/minimal.ts +45 -0
  165. package/examples/ocr-pdf-ingestion.ts +42 -0
  166. package/examples/optimizer.ts +43 -0
  167. package/examples/otel-express.ts +47 -0
  168. package/examples/otel-node-http.ts +46 -0
  169. package/examples/persisted-vector-store.ts +42 -0
  170. package/examples/security.ts +69 -0
  171. package/package.json +165 -0
@@ -0,0 +1,479 @@
1
+ function model(capabilities) {
2
+ return capabilities;
3
+ }
4
+ const openaiReasoning = {
5
+ efforts: ['none', 'low', 'medium', 'high', 'xhigh'],
6
+ };
7
+ const gpt5 = (family, maxContextTokens, inputPerMillion, outputPerMillion, qualityScore, speedScore, release, knowledgeCutoff) => model({
8
+ provider: 'openai',
9
+ family,
10
+ modalities: ['text', 'vision'],
11
+ streaming: true,
12
+ toolCalling: true,
13
+ structuredOutputs: true,
14
+ jsonMode: true,
15
+ reasoning: openaiReasoning,
16
+ maxContextTokens,
17
+ maxOutputTokens: 128000,
18
+ costPer1kInput: inputPerMillion / 1000,
19
+ costPer1kOutput: outputPerMillion / 1000,
20
+ qualityScore,
21
+ speedScore,
22
+ release,
23
+ knowledgeCutoff,
24
+ status: 'stable',
25
+ endpoints: ['chat', 'responses'],
26
+ });
27
+ const claude = (family, inputPerMillion, outputPerMillion, qualityScore, speedScore, maxOutputTokens, release, knowledgeCutoff, maxContextTokens = 200000) => model({
28
+ provider: 'anthropic',
29
+ family,
30
+ modalities: ['text', 'vision'],
31
+ streaming: true,
32
+ toolCalling: true,
33
+ structuredOutputs: false,
34
+ jsonMode: false,
35
+ reasoning: family.includes('4') || family.includes('3.7'),
36
+ maxContextTokens,
37
+ maxOutputTokens,
38
+ costPer1kInput: inputPerMillion / 1000,
39
+ costPer1kOutput: outputPerMillion / 1000,
40
+ qualityScore,
41
+ speedScore,
42
+ release,
43
+ knowledgeCutoff,
44
+ status: 'stable',
45
+ endpoints: ['messages'],
46
+ });
47
+ const gemini = (family, maxContextTokens, inputPerMillion, outputPerMillion, qualityScore, speedScore, release, knowledgeCutoff, status = 'stable') => model({
48
+ provider: 'google',
49
+ family,
50
+ modalities: ['text', 'vision', 'audio', 'video', 'pdf'],
51
+ streaming: true,
52
+ toolCalling: true,
53
+ structuredOutputs: true,
54
+ jsonMode: true,
55
+ reasoning: true,
56
+ maxContextTokens,
57
+ maxOutputTokens: 65536,
58
+ costPer1kInput: inputPerMillion / 1000,
59
+ costPer1kOutput: outputPerMillion / 1000,
60
+ qualityScore,
61
+ speedScore,
62
+ release,
63
+ knowledgeCutoff,
64
+ status,
65
+ endpoints: ['generateContent'],
66
+ });
67
+ const openAiCompatible = (provider, family, modalities, maxContextTokens, maxOutputTokens, inputPerMillion, outputPerMillion, qualityScore, speedScore, release, status = 'stable', notes) => model({
68
+ provider,
69
+ family,
70
+ modalities,
71
+ streaming: true,
72
+ toolCalling: true,
73
+ structuredOutputs: true,
74
+ jsonMode: true,
75
+ reasoning: family.includes('reasoning') || family.includes('gpt-oss') || family.includes('magistral') || family.includes('gemini-3'),
76
+ maxContextTokens,
77
+ maxOutputTokens,
78
+ costPer1kInput: inputPerMillion / 1000,
79
+ costPer1kOutput: outputPerMillion / 1000,
80
+ qualityScore,
81
+ speedScore,
82
+ release,
83
+ status,
84
+ endpoints: ['chat'],
85
+ notes,
86
+ });
87
+ const cohere = (family, modalities, maxContextTokens, maxOutputTokens, qualityScore, speedScore, release, notes) => model({
88
+ provider: 'cohere',
89
+ family,
90
+ modalities,
91
+ streaming: false,
92
+ toolCalling: true,
93
+ structuredOutputs: false,
94
+ jsonMode: false,
95
+ reasoning: family.includes('reasoning'),
96
+ maxContextTokens,
97
+ maxOutputTokens,
98
+ costPer1kInput: 0,
99
+ costPer1kOutput: 0,
100
+ qualityScore,
101
+ speedScore,
102
+ release,
103
+ status: 'stable',
104
+ endpoints: ['chat'],
105
+ notes: notes || 'Cohere pricing is deployment/plan dependent; override costs in models.registry for exact estimates.',
106
+ });
107
+ export const KNOWN_MODELS = {
108
+ // OpenAI - current GPT-5 family
109
+ 'gpt-5.5': gpt5('gpt-5.5', 1000000, 5, 30, 99, 82, '2026', '2025-12-01'),
110
+ 'gpt-5.5-pro': {
111
+ ...gpt5('gpt-5.5', 1050000, 30, 180, 100, 55, '2026', '2025-12-01'),
112
+ structuredOutputs: false,
113
+ endpoints: ['responses'],
114
+ },
115
+ 'gpt-5.4': gpt5('gpt-5.4', 1050000, 2.5, 15, 97, 85, '2026-03', '2025-08-31'),
116
+ 'gpt-5.4-pro': {
117
+ ...gpt5('gpt-5.4', 1050000, 30, 180, 99, 55, '2026-03', '2025-08-31'),
118
+ structuredOutputs: false,
119
+ endpoints: ['responses'],
120
+ },
121
+ 'gpt-5.4-mini': gpt5('gpt-5.4', 400000, 0.75, 4.5, 92, 94, '2026-03', '2025-08-31'),
122
+ 'gpt-5.4-nano': gpt5('gpt-5.4', 400000, 0.2, 1.25, 84, 98, '2026-03', '2025-08-31'),
123
+ 'gpt-5.2': gpt5('gpt-5.2', 400000, 1.75, 14, 96, 82, '2025', '2025-08-31'),
124
+ 'gpt-5.2-pro': {
125
+ ...gpt5('gpt-5.2', 400000, 30, 180, 98, 55, '2025', '2025-08-31'),
126
+ endpoints: ['responses'],
127
+ },
128
+ 'gpt-5.2-codex': {
129
+ ...gpt5('gpt-5.2', 400000, 1.75, 14, 96, 78, '2025', '2025-08-31'),
130
+ family: 'codex',
131
+ endpoints: ['responses'],
132
+ },
133
+ 'gpt-5.1': gpt5('gpt-5.1', 400000, 1.25, 10, 94, 82, '2025', '2024-09-30'),
134
+ 'gpt-5': gpt5('gpt-5', 400000, 1.25, 10, 92, 80, '2025', '2024-09-30'),
135
+ 'gpt-5-mini': gpt5('gpt-5', 400000, 0.25, 2, 88, 94, '2025', '2024-05-31'),
136
+ 'gpt-5-nano': gpt5('gpt-5', 400000, 0.05, 0.4, 78, 99, '2025', '2024-05-31'),
137
+ 'gpt-5-codex': {
138
+ ...gpt5('gpt-5', 400000, 1.25, 10, 93, 78, '2025', '2024-09-30'),
139
+ family: 'codex',
140
+ endpoints: ['responses'],
141
+ },
142
+ 'gpt-5-chat-latest': {
143
+ ...gpt5('gpt-5', 128000, 1.25, 10, 90, 82, 'latest', '2024-09-30'),
144
+ maxOutputTokens: 16384,
145
+ status: 'latest',
146
+ },
147
+ // OpenAI - GPT-4 / reasoning legacy still commonly deployed
148
+ 'gpt-4.1': model({
149
+ provider: 'openai',
150
+ family: 'gpt-4.1',
151
+ modalities: ['text', 'vision'],
152
+ streaming: true,
153
+ toolCalling: true,
154
+ structuredOutputs: true,
155
+ jsonMode: true,
156
+ maxContextTokens: 1047576,
157
+ maxOutputTokens: 32768,
158
+ costPer1kInput: 0.002,
159
+ costPer1kOutput: 0.008,
160
+ qualityScore: 88,
161
+ speedScore: 80,
162
+ release: '2025',
163
+ status: 'stable',
164
+ endpoints: ['chat', 'responses'],
165
+ }),
166
+ 'gpt-4.1-mini': model({
167
+ provider: 'openai',
168
+ family: 'gpt-4.1',
169
+ modalities: ['text', 'vision'],
170
+ streaming: true,
171
+ toolCalling: true,
172
+ structuredOutputs: true,
173
+ jsonMode: true,
174
+ maxContextTokens: 1047576,
175
+ maxOutputTokens: 32768,
176
+ costPer1kInput: 0.0004,
177
+ costPer1kOutput: 0.0016,
178
+ qualityScore: 82,
179
+ speedScore: 94,
180
+ release: '2025',
181
+ status: 'stable',
182
+ endpoints: ['chat', 'responses'],
183
+ }),
184
+ 'gpt-4.1-nano': model({
185
+ provider: 'openai',
186
+ family: 'gpt-4.1',
187
+ modalities: ['text', 'vision'],
188
+ streaming: true,
189
+ toolCalling: true,
190
+ structuredOutputs: true,
191
+ jsonMode: true,
192
+ maxContextTokens: 1047576,
193
+ maxOutputTokens: 32768,
194
+ costPer1kInput: 0.0001,
195
+ costPer1kOutput: 0.0004,
196
+ qualityScore: 74,
197
+ speedScore: 98,
198
+ release: '2025',
199
+ status: 'stable',
200
+ endpoints: ['chat', 'responses'],
201
+ }),
202
+ 'gpt-4o': model({
203
+ provider: 'openai',
204
+ family: 'gpt-4o',
205
+ modalities: ['text', 'vision', 'audio'],
206
+ streaming: true,
207
+ toolCalling: true,
208
+ structuredOutputs: true,
209
+ jsonMode: true,
210
+ maxContextTokens: 128000,
211
+ maxOutputTokens: 16384,
212
+ costPer1kInput: 0.0025,
213
+ costPer1kOutput: 0.01,
214
+ qualityScore: 84,
215
+ speedScore: 84,
216
+ release: '2024',
217
+ status: 'stable',
218
+ endpoints: ['chat', 'responses', 'realtime'],
219
+ }),
220
+ 'gpt-4o-mini': model({
221
+ provider: 'openai',
222
+ family: 'gpt-4o',
223
+ modalities: ['text', 'vision'],
224
+ streaming: true,
225
+ toolCalling: true,
226
+ structuredOutputs: true,
227
+ jsonMode: true,
228
+ maxContextTokens: 128000,
229
+ maxOutputTokens: 16384,
230
+ costPer1kInput: 0.00015,
231
+ costPer1kOutput: 0.0006,
232
+ qualityScore: 76,
233
+ speedScore: 96,
234
+ release: '2024',
235
+ status: 'stable',
236
+ endpoints: ['chat', 'responses'],
237
+ }),
238
+ 'o3': model({
239
+ provider: 'openai',
240
+ family: 'o-series',
241
+ modalities: ['text', 'vision'],
242
+ streaming: true,
243
+ toolCalling: true,
244
+ structuredOutputs: true,
245
+ jsonMode: true,
246
+ reasoning: { efforts: ['low', 'medium', 'high'] },
247
+ maxContextTokens: 200000,
248
+ maxOutputTokens: 100000,
249
+ costPer1kInput: 0.002,
250
+ costPer1kOutput: 0.008,
251
+ qualityScore: 90,
252
+ speedScore: 66,
253
+ release: '2025',
254
+ status: 'stable',
255
+ endpoints: ['chat', 'responses'],
256
+ }),
257
+ 'o3-mini': model({
258
+ provider: 'openai',
259
+ family: 'o-series',
260
+ modalities: ['text'],
261
+ streaming: true,
262
+ toolCalling: true,
263
+ structuredOutputs: true,
264
+ jsonMode: true,
265
+ reasoning: { efforts: ['low', 'medium', 'high'] },
266
+ maxContextTokens: 200000,
267
+ maxOutputTokens: 100000,
268
+ costPer1kInput: 0.0011,
269
+ costPer1kOutput: 0.0044,
270
+ qualityScore: 84,
271
+ speedScore: 82,
272
+ release: '2025',
273
+ status: 'stable',
274
+ endpoints: ['chat', 'responses'],
275
+ }),
276
+ 'o4-mini': model({
277
+ provider: 'openai',
278
+ family: 'o-series',
279
+ modalities: ['text', 'vision'],
280
+ streaming: true,
281
+ toolCalling: true,
282
+ structuredOutputs: true,
283
+ jsonMode: true,
284
+ reasoning: { efforts: ['low', 'medium', 'high'] },
285
+ maxContextTokens: 200000,
286
+ maxOutputTokens: 100000,
287
+ costPer1kInput: 0.0011,
288
+ costPer1kOutput: 0.0044,
289
+ qualityScore: 86,
290
+ speedScore: 88,
291
+ release: '2025',
292
+ status: 'stable',
293
+ endpoints: ['chat', 'responses'],
294
+ }),
295
+ 'gpt-oss-120b': model({
296
+ provider: 'openai',
297
+ family: 'gpt-oss',
298
+ modalities: ['text'],
299
+ streaming: true,
300
+ toolCalling: true,
301
+ maxContextTokens: 131000,
302
+ maxOutputTokens: 32768,
303
+ costPer1kInput: 0,
304
+ costPer1kOutput: 0,
305
+ qualityScore: 78,
306
+ speedScore: 70,
307
+ release: '2025',
308
+ status: 'stable',
309
+ endpoints: [],
310
+ }),
311
+ 'gpt-oss-20b': model({
312
+ provider: 'openai',
313
+ family: 'gpt-oss',
314
+ modalities: ['text'],
315
+ streaming: true,
316
+ toolCalling: true,
317
+ maxContextTokens: 131000,
318
+ maxOutputTokens: 32768,
319
+ costPer1kInput: 0,
320
+ costPer1kOutput: 0,
321
+ qualityScore: 68,
322
+ speedScore: 88,
323
+ release: '2025',
324
+ status: 'stable',
325
+ endpoints: [],
326
+ }),
327
+ // Anthropic
328
+ 'claude-opus-4-7': claude('claude-opus-4.7', 5, 25, 99, 72, 128000, '2026', '2026-01', 1000000),
329
+ 'claude-opus-4-6': {
330
+ ...claude('claude-opus-4.6', 5, 25, 98, 72, 128000, '2026', '2026-01', 1000000),
331
+ notes: 'Anthropic docs reference claude-opus-4-6 for Claude Code and batch beta usage; verify account and platform availability.',
332
+ },
333
+ 'claude-opus-4-5-20251101': {
334
+ ...claude('claude-opus-4.5', 5, 25, 97, 72, 128000, '2025-11-01', '2025-08', 1000000),
335
+ notes: 'Anthropic Claude Code Bedrock docs reference this Opus 4.5 snapshot; verify direct Claude API availability before production use.',
336
+ },
337
+ 'claude-sonnet-4-6': claude('claude-sonnet-4.6', 3, 15, 96, 88, 64000, '2026', '2025-08', 1000000),
338
+ 'claude-haiku-4-5-20251001': claude('claude-haiku-4.5', 1, 5, 86, 98, 64000, '2025-10-01', '2025-02'),
339
+ 'claude-opus-4-1-20250805': claude('claude-opus-4.1', 15, 75, 97, 70, 32000, '2025-08-05', '2025-03'),
340
+ 'claude-opus-4-20250514': claude('claude-opus-4', 15, 75, 95, 70, 32000, '2025-05-14', '2025-03'),
341
+ 'claude-sonnet-4-20250514': claude('claude-sonnet-4', 3, 15, 92, 86, 64000, '2025-05-14', '2025-03'),
342
+ 'claude-3-7-sonnet-20250219': claude('claude-3.7', 3, 15, 89, 84, 64000, '2025-02-19', '2024-10'),
343
+ 'claude-3-5-sonnet-20241022': claude('claude-3.5', 3, 15, 86, 84, 8192, '2024-10-22', '2024-04'),
344
+ 'claude-3-5-sonnet-20240620': claude('claude-3.5', 3, 15, 84, 82, 8192, '2024-06-20', '2024-04'),
345
+ 'claude-3-5-haiku-20241022': claude('claude-haiku-3.5', 0.8, 4, 78, 96, 8192, '2024-10-22', '2024-07'),
346
+ 'claude-3-haiku-20240307': claude('claude-haiku-3', 0.25, 1.25, 68, 94, 4096, '2024-03-07', '2023-08'),
347
+ // Google Gemini
348
+ 'gemini-3.1-pro-preview': gemini('gemini-3.1', 1048576, 2, 12, 97, 76, '2026-02', '2025-01', 'preview'),
349
+ 'gemini-3.1-pro-preview-customtools': gemini('gemini-3.1', 1048576, 2, 12, 97, 74, '2026-02', '2025-01', 'preview'),
350
+ 'gemini-3.1-flash-lite-preview': gemini('gemini-3.1', 1048576, 0.1, 0.4, 86, 98, '2026', '2025-01', 'preview'),
351
+ 'gemini-3-pro-preview': {
352
+ ...gemini('gemini-3', 1048576, 2, 12, 96, 76, '2025-11', '2025-01', 'preview'),
353
+ status: 'deprecated',
354
+ notes: 'Deprecated and shut down by Google on 2026-03-09; migrate to gemini-3.1-pro-preview.',
355
+ },
356
+ 'gemini-3-flash-preview': gemini('gemini-3', 1048576, 0.5, 3, 90, 94, '2025-12', '2025-01', 'preview'),
357
+ 'gemini-3-pro-image-preview': {
358
+ ...gemini('gemini-3-image', 65536, 2, 12, 88, 70, '2025-11', '2025-01', 'preview'),
359
+ modalities: ['text', 'vision', 'image'],
360
+ toolCalling: false,
361
+ },
362
+ 'gemini-2.5-pro': gemini('gemini-2.5', 1048576, 1.25, 10, 92, 76, '2025-06', '2025-01'),
363
+ 'gemini-2.5-flash': gemini('gemini-2.5', 1048576, 0.3, 2.5, 86, 94, '2025', '2025-01'),
364
+ 'gemini-2.5-flash-lite': gemini('gemini-2.5', 1048576, 0.1, 0.4, 76, 98, '2025', '2025-01'),
365
+ 'gemini-2.5-flash-lite-preview-09-2025': gemini('gemini-2.5', 1048576, 0.1, 0.4, 76, 98, '2025-09', '2025-01', 'preview'),
366
+ 'gemini-2.0-flash': gemini('gemini-2.0', 1048576, 0.1, 0.4, 78, 94, '2025-02', '2024-08'),
367
+ 'gemini-1.5-pro': {
368
+ ...gemini('gemini-1.5', 2000000, 1.25, 5, 80, 70, '2024', '2024'),
369
+ status: 'deprecated',
370
+ },
371
+ 'gemini-1.5-flash': {
372
+ ...gemini('gemini-1.5', 1000000, 0.075, 0.3, 72, 90, '2024', '2024'),
373
+ status: 'deprecated',
374
+ },
375
+ // Groq hosted models and systems
376
+ 'groq/openai/gpt-oss-120b': openAiCompatible('groq', 'gpt-oss', ['text'], 131072, 65536, 0.15, 0.6, 86, 96, '2025'),
377
+ 'groq/openai/gpt-oss-20b': openAiCompatible('groq', 'gpt-oss', ['text'], 131072, 65536, 0.075, 0.3, 78, 100, '2025'),
378
+ 'groq/llama-3.3-70b-versatile': openAiCompatible('groq', 'llama-3.3', ['text'], 131072, 32768, 0.59, 0.79, 80, 92, '2024'),
379
+ 'groq/llama-3.1-8b-instant': openAiCompatible('groq', 'llama-3.1', ['text'], 131072, 131072, 0.05, 0.08, 68, 98, '2024'),
380
+ 'groq/groq/compound': openAiCompatible('groq', 'compound', ['text'], 131072, 8192, 0, 0, 82, 94, '2026', 'stable', 'Groq Compound is a hosted agentic system with built-in tools; pricing is not token-metered in the model table.'),
381
+ 'groq/groq/compound-mini': openAiCompatible('groq', 'compound', ['text'], 131072, 8192, 0, 0, 76, 96, '2026', 'stable', 'Groq Compound Mini is a hosted agentic system with built-in tools; pricing is not token-metered in the model table.'),
382
+ 'groq/meta-llama/llama-4-scout-17b-16e-instruct': openAiCompatible('groq', 'llama-4', ['text', 'vision'], 131072, 8192, 0.11, 0.34, 78, 97, '2026', 'preview'),
383
+ 'groq/qwen/qwen3-32b': openAiCompatible('groq', 'qwen3', ['text'], 131072, 40960, 0.29, 0.59, 76, 90, '2026', 'preview'),
384
+ 'groq/openai/gpt-oss-safeguard-20b': openAiCompatible('groq', 'safety', ['text'], 131072, 65536, 0.075, 0.3, 70, 100, '2025', 'preview'),
385
+ 'groq/meta-llama/llama-prompt-guard-2-22m': openAiCompatible('groq', 'prompt-guard', ['text'], 512, 512, 0.03, 0.03, 55, 100, '2026', 'preview'),
386
+ 'groq/meta-llama/llama-prompt-guard-2-86m': openAiCompatible('groq', 'prompt-guard', ['text'], 512, 512, 0.04, 0.04, 58, 100, '2026', 'preview'),
387
+ // Mistral AI
388
+ 'mistral/mistral-medium-3-5': openAiCompatible('mistral', 'mistral-medium-3.5', ['text', 'vision', 'pdf'], 256000, 8192, 1.5, 7.5, 90, 78, '2026-04'),
389
+ 'mistral/mistral-small-2603': openAiCompatible('mistral', 'mistral-small-4', ['text', 'vision'], 256000, 8192, 0.2, 0.6, 82, 92, '2026-03', 'stable', 'Pricing varies by deployment; override costs in models.registry if needed.'),
390
+ 'mistral/mistral-large-2512': openAiCompatible('mistral', 'mistral-large-3', ['text', 'vision'], 256000, 8192, 2, 6, 88, 76, '2025-12', 'stable', 'Pricing varies by deployment; override costs in models.registry if needed.'),
391
+ 'mistral/devstral-2512': openAiCompatible('mistral', 'devstral-2', ['text'], 256000, 8192, 0.4, 2, 86, 84, '2025-12', 'stable', 'Code-agent model.'),
392
+ 'mistral/codestral-2508': openAiCompatible('mistral', 'codestral', ['text'], 256000, 8192, 0.3, 0.9, 84, 86, '2025-08', 'stable', 'Code model. Pricing varies by deployment; override costs in models.registry if needed.'),
393
+ 'mistral/magistral-medium-2509': openAiCompatible('mistral', 'magistral-medium-1.2', ['text', 'vision'], 128000, 8192, 2, 5, 88, 70, '2025-09', 'stable', 'Reasoning model. Pricing varies by deployment; override costs in models.registry if needed.'),
394
+ 'mistral/mistral-moderation-2603': openAiCompatible('mistral', 'moderation', ['text'], 128000, 4096, 0, 0, 70, 92, '2026-03', 'stable', 'Moderation model, not intended for normal chat completions.'),
395
+ // Cohere
396
+ 'cohere/command-a-03-2025': cohere('command-a', ['text'], 256000, 8000, 86, 80, '2025-03'),
397
+ 'cohere/command-a-reasoning-08-2025': cohere('command-a-reasoning', ['text'], 256000, 32000, 88, 68, '2025-08'),
398
+ 'cohere/command-a-vision-07-2025': cohere('command-a-vision', ['text', 'vision'], 128000, 8000, 84, 78, '2025-07'),
399
+ 'cohere/command-a-translate-08-2025': cohere('command-a-translate', ['text'], 8000, 8000, 84, 82, '2025-08'),
400
+ 'cohere/command-r7b-12-2024': cohere('command-r7b', ['text'], 128000, 4000, 74, 94, '2024-12'),
401
+ 'cohere/c4ai-aya-expanse-32b': cohere('aya-expanse', ['text'], 128000, 4000, 76, 84, '2024'),
402
+ 'cohere/c4ai-aya-vision-32b': cohere('aya-vision', ['text', 'vision'], 16000, 4000, 78, 78, '2024'),
403
+ 'cohere/tiny-aya-global': cohere('tiny-aya', ['text'], 8000, 8000, 62, 98, '2026'),
404
+ };
405
+ export const MODEL_ALIASES = {
406
+ 'openai/best': 'gpt-5.5',
407
+ 'openai/pro': 'gpt-5.5-pro',
408
+ 'openai/balanced': 'gpt-5.4',
409
+ 'openai/fast': 'gpt-5.4-mini',
410
+ 'openai/cheap': 'gpt-5.4-nano',
411
+ 'openai/coding': 'gpt-5.5',
412
+ 'openai/codex': 'gpt-5-codex',
413
+ 'anthropic/best': 'claude-opus-4-7',
414
+ 'anthropic/balanced': 'claude-sonnet-4-6',
415
+ 'anthropic/fast': 'claude-haiku-4-5-20251001',
416
+ 'google/best': 'gemini-3.1-pro-preview',
417
+ 'google/balanced': 'gemini-2.5-pro',
418
+ 'google/fast': 'gemini-3-flash-preview',
419
+ 'google/cheap': 'gemini-2.5-flash-lite',
420
+ 'groq/best': 'groq/openai/gpt-oss-120b',
421
+ 'groq/fast': 'groq/openai/gpt-oss-20b',
422
+ 'groq/cheap': 'groq/llama-3.1-8b-instant',
423
+ 'groq/compound': 'groq/groq/compound',
424
+ 'mistral/best': 'mistral/mistral-medium-3-5',
425
+ 'mistral/balanced': 'mistral/mistral-large-2512',
426
+ 'mistral/fast': 'mistral/mistral-small-2603',
427
+ 'mistral/coding': 'mistral/devstral-2512',
428
+ 'mistral/mistral-small-4': 'mistral/mistral-small-2603',
429
+ 'mistral/mistral-large-3': 'mistral/mistral-large-2512',
430
+ 'mistral/devstral-2': 'mistral/devstral-2512',
431
+ 'cohere/best': 'cohere/command-a-03-2025',
432
+ 'cohere/reasoning': 'cohere/command-a-reasoning-08-2025',
433
+ 'cohere/vision': 'cohere/command-a-vision-07-2025',
434
+ 'cohere/fast': 'cohere/command-r7b-12-2024',
435
+ 'claude-opus-4.7': 'claude-opus-4-7',
436
+ 'claude-opus-4-7-latest': 'claude-opus-4-7',
437
+ 'claude-opus-4.6': 'claude-opus-4-6',
438
+ 'claude-opus-4-6-latest': 'claude-opus-4-6',
439
+ 'claude-opus-4.5': 'claude-opus-4-5-20251101',
440
+ 'claude-opus-4-5': 'claude-opus-4-5-20251101',
441
+ 'claude-opus-4-5-latest': 'claude-opus-4-5-20251101',
442
+ 'claude-sonnet-4.6': 'claude-sonnet-4-6',
443
+ 'claude-sonnet-4-6-latest': 'claude-sonnet-4-6',
444
+ 'claude-haiku-4.5': 'claude-haiku-4-5-20251001',
445
+ 'claude-haiku-4-5': 'claude-haiku-4-5-20251001',
446
+ 'claude-haiku-4-5-latest': 'claude-haiku-4-5-20251001',
447
+ 'claude-opus-4.1': 'claude-opus-4-1-20250805',
448
+ 'claude-opus-4-1': 'claude-opus-4-1-20250805',
449
+ 'claude-opus-4': 'claude-opus-4-20250514',
450
+ 'claude-opus-4-0': 'claude-opus-4-20250514',
451
+ 'claude-sonnet-4': 'claude-sonnet-4-20250514',
452
+ 'claude-sonnet-4-0': 'claude-sonnet-4-20250514',
453
+ 'claude-sonnet-3.7': 'claude-3-7-sonnet-20250219',
454
+ 'claude-3-7-sonnet-latest': 'claude-3-7-sonnet-20250219',
455
+ 'claude-sonnet-3.5': 'claude-3-5-sonnet-20241022',
456
+ 'claude-3-5-sonnet-latest': 'claude-3-5-sonnet-20241022',
457
+ 'claude-haiku-3.5': 'claude-3-5-haiku-20241022',
458
+ 'claude-3-5-haiku-latest': 'claude-3-5-haiku-20241022',
459
+ 'gemini-pro-latest': 'gemini-3.1-pro-preview',
460
+ 'gemini-flash-latest': 'gemini-3-flash-preview',
461
+ 'gemini-flash-lite-latest': 'gemini-3.1-flash-lite-preview',
462
+ };
463
+ export function resolveProvider(model) {
464
+ if (model.startsWith('gpt-')
465
+ || model.startsWith('o1')
466
+ || model.startsWith('o3')
467
+ || model.startsWith('o4'))
468
+ return 'openai';
469
+ if (model.startsWith('claude-'))
470
+ return 'anthropic';
471
+ if (model.startsWith('gemini-'))
472
+ return 'google';
473
+ if (model.includes('/')) {
474
+ const prefix = model.split('/')[0];
475
+ if (['ollama', 'google', 'groq', 'lmstudio', 'openrouter', 'together', 'deepseek', 'mistral', 'cohere'].includes(prefix))
476
+ return prefix;
477
+ }
478
+ return null;
479
+ }
@@ -0,0 +1,55 @@
1
+ import type { PipelineTrace } from '../pipeline/types.js';
2
+ export interface ResponseMeta {
3
+ requestId: string;
4
+ providerUsed: string;
5
+ modelUsed: string;
6
+ latencyMs: number;
7
+ tokensInput: number;
8
+ tokensOutput: number;
9
+ tokensSaved: number;
10
+ estimatedCost: string;
11
+ cacheHit: boolean;
12
+ guardrailsApplied: string[];
13
+ routingDecision?: {
14
+ reason: string;
15
+ fallbacksConsidered: number;
16
+ };
17
+ verification?: {
18
+ ok: boolean;
19
+ supportRatio: number;
20
+ factsChecked: number;
21
+ unsupportedFacts: string[];
22
+ };
23
+ pipeline?: PipelineTrace;
24
+ semanticCache?: {
25
+ hit: boolean;
26
+ score: number;
27
+ key: string;
28
+ };
29
+ }
30
+ export interface ToolCall {
31
+ id: string;
32
+ type: 'function';
33
+ function: {
34
+ name: string;
35
+ arguments: string;
36
+ };
37
+ }
38
+ export interface NexusResponse {
39
+ content: string;
40
+ role: 'assistant';
41
+ toolCalls?: ToolCall[];
42
+ finishReason: 'stop' | 'tool_calls' | 'length' | 'content_filter' | 'error';
43
+ meta: ResponseMeta;
44
+ }
45
+ export interface StreamChunk {
46
+ type: 'text' | 'tool_call' | 'done' | 'error';
47
+ content?: string;
48
+ toolCall?: ToolCall;
49
+ meta?: Partial<ResponseMeta>;
50
+ error?: string;
51
+ }
52
+ export interface NexusStream extends AsyncIterable<StreamChunk> {
53
+ [Symbol.asyncIterator](): AsyncIterator<StreamChunk>;
54
+ abort(): void;
55
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,87 @@
1
+ export type SecurityLevel = 'off' | 'basic' | 'standard' | 'strict' | 'paranoid';
2
+ export type SecurityPreset = 'developer' | 'startup' | 'enterprise' | 'healthcare' | 'finance';
3
+ export type SecurityAction = 'allow' | 'block' | 'mask' | 'flag';
4
+ export type PIIType = 'email' | 'phone' | 'credit-card' | 'ip-address' | 'aws-key' | 'private-key';
5
+ export interface InjectionDetectionConfig {
6
+ enabled?: boolean;
7
+ sensitivity?: number;
8
+ onDetection?: 'block' | 'flag' | 'transform';
9
+ customPatterns?: RegExp[];
10
+ semantic?: {
11
+ enabled?: boolean;
12
+ threshold?: number;
13
+ examples?: string[];
14
+ };
15
+ }
16
+ export interface PIIConfig {
17
+ enabled?: boolean;
18
+ detect?: PIIType[];
19
+ action?: 'mask' | 'remove' | 'block' | 'flag';
20
+ maskChar?: string;
21
+ preserveFormat?: boolean;
22
+ }
23
+ export interface SecretDetectionConfig {
24
+ enabled?: boolean;
25
+ action?: 'block' | 'mask' | 'flag';
26
+ }
27
+ export interface UrlRiskConfig {
28
+ enabled?: boolean;
29
+ action?: 'block' | 'flag';
30
+ }
31
+ export interface ToolPolicyConfig {
32
+ allowedNames?: string[];
33
+ requiresApproval?: string[];
34
+ }
35
+ export interface ModerationConfig {
36
+ enabled?: boolean;
37
+ forbiddenTerms?: string[];
38
+ onViolation?: 'block' | 'flag' | 'redact';
39
+ }
40
+ export interface DLPConfig {
41
+ enabled?: boolean;
42
+ proprietaryTerms?: string[];
43
+ connectionStrings?: boolean;
44
+ }
45
+ export interface TopicGuardrailConfig {
46
+ forbiddenTopics?: string[];
47
+ onViolation?: 'block' | 'flag';
48
+ }
49
+ export interface GroundingConfig {
50
+ enabled?: boolean;
51
+ context?: string[];
52
+ minOverlapRatio?: number;
53
+ }
54
+ export interface SecurityConfig {
55
+ preset?: SecurityPreset;
56
+ level?: SecurityLevel;
57
+ input?: {
58
+ maxContentLength?: number;
59
+ injectionDetection?: InjectionDetectionConfig;
60
+ pii?: PIIConfig;
61
+ secrets?: SecretDetectionConfig;
62
+ urls?: UrlRiskConfig;
63
+ tools?: ToolPolicyConfig;
64
+ };
65
+ output?: {
66
+ maxContentLength?: number;
67
+ piiRedaction?: boolean;
68
+ moderation?: ModerationConfig;
69
+ dlp?: DLPConfig;
70
+ topics?: TopicGuardrailConfig;
71
+ grounding?: GroundingConfig;
72
+ };
73
+ }
74
+ export interface SecurityFinding {
75
+ type: 'schema' | 'prompt-injection' | 'pii' | 'content-length' | 'secret' | 'url-risk' | 'tool-policy' | 'moderation' | 'dlp' | 'topic' | 'grounding';
76
+ severity: 'low' | 'medium' | 'high' | 'critical';
77
+ message: string;
78
+ path?: string;
79
+ value?: string;
80
+ metadata?: Record<string, unknown>;
81
+ }
82
+ export interface SecurityResult<T> {
83
+ ok: boolean;
84
+ value: T;
85
+ findings: SecurityFinding[];
86
+ guardrailsApplied: string[];
87
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function generateRequestId(): string;
@@ -0,0 +1,4 @@
1
+ import { randomBytes } from 'crypto';
2
+ export function generateRequestId() {
3
+ return `req_${randomBytes(12).toString('hex')}`;
4
+ }
@@ -0,0 +1,7 @@
1
+ export declare class Logger {
2
+ private debug;
3
+ constructor(debug?: boolean);
4
+ info(msg: string, data?: Record<string, unknown>): void;
5
+ warn(msg: string, data?: Record<string, unknown>): void;
6
+ error(msg: string, err?: unknown): void;
7
+ }
@@ -0,0 +1,17 @@
1
+ export class Logger {
2
+ debug;
3
+ constructor(debug = false) {
4
+ this.debug = debug;
5
+ }
6
+ info(msg, data) {
7
+ if (this.debug) {
8
+ console.log(`[nexus-ai-pro] ${msg}`, data ? JSON.stringify(data) : '');
9
+ }
10
+ }
11
+ warn(msg, data) {
12
+ console.warn(`[nexus-ai-pro] WARN: ${msg}`, data ? JSON.stringify(data) : '');
13
+ }
14
+ error(msg, err) {
15
+ console.error(`[nexus-ai-pro] ERROR: ${msg}`, err instanceof Error ? err.message : err);
16
+ }
17
+ }
@@ -0,0 +1,6 @@
1
+ import type { CompletionRequest, Message } from '../types/messages.js';
2
+ export declare class Tokenizer {
3
+ estimateTextTokens(text: string): number;
4
+ estimateMessageTokens(message: Message): number;
5
+ estimateRequestTokens(request: CompletionRequest): number;
6
+ }