@juspay/neurolink 9.28.0 → 9.29.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 (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +19 -16
  3. package/dist/adapters/providerImageAdapter.js +9 -1
  4. package/dist/constants/contextWindows.js +18 -7
  5. package/dist/constants/enums.d.ts +36 -6
  6. package/dist/constants/enums.js +38 -5
  7. package/dist/constants/tokens.d.ts +4 -0
  8. package/dist/constants/tokens.js +4 -0
  9. package/dist/context/contextCompactor.js +2 -2
  10. package/dist/core/baseProvider.d.ts +6 -2
  11. package/dist/core/baseProvider.js +61 -1
  12. package/dist/lib/adapters/providerImageAdapter.js +9 -1
  13. package/dist/lib/constants/contextWindows.js +18 -7
  14. package/dist/lib/constants/enums.d.ts +36 -6
  15. package/dist/lib/constants/enums.js +38 -5
  16. package/dist/lib/constants/tokens.d.ts +4 -0
  17. package/dist/lib/constants/tokens.js +4 -0
  18. package/dist/lib/context/contextCompactor.js +2 -2
  19. package/dist/lib/core/baseProvider.d.ts +6 -2
  20. package/dist/lib/core/baseProvider.js +61 -1
  21. package/dist/lib/memory/hippocampusInitializer.d.ts +2 -2
  22. package/dist/lib/neurolink.js +3 -3
  23. package/dist/lib/observability/exporters/langfuseExporter.d.ts +1 -0
  24. package/dist/lib/observability/exporters/langfuseExporter.js +8 -2
  25. package/dist/lib/observability/exporters/langsmithExporter.js +25 -5
  26. package/dist/lib/observability/otelBridge.js +1 -1
  27. package/dist/lib/observability/types/exporterTypes.d.ts +7 -0
  28. package/dist/lib/observability/utils/spanSerializer.js +3 -1
  29. package/dist/lib/providers/amazonBedrock.js +1 -1
  30. package/dist/lib/providers/anthropic.js +1 -1
  31. package/dist/lib/types/conversation.d.ts +2 -2
  32. package/dist/lib/types/index.d.ts +1 -1
  33. package/dist/lib/types/providers.d.ts +6 -3
  34. package/dist/memory/hippocampusInitializer.d.ts +2 -2
  35. package/dist/neurolink.js +3 -3
  36. package/dist/observability/exporters/langfuseExporter.d.ts +1 -0
  37. package/dist/observability/exporters/langfuseExporter.js +8 -2
  38. package/dist/observability/exporters/langsmithExporter.js +25 -5
  39. package/dist/observability/otelBridge.js +1 -1
  40. package/dist/observability/types/exporterTypes.d.ts +7 -0
  41. package/dist/observability/utils/spanSerializer.js +3 -1
  42. package/dist/providers/amazonBedrock.js +1 -1
  43. package/dist/providers/anthropic.js +1 -1
  44. package/dist/types/conversation.d.ts +2 -2
  45. package/dist/types/index.d.ts +1 -1
  46. package/dist/types/providers.d.ts +6 -3
  47. package/package.json +5 -3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [9.29.0](https://github.com/juspay/neurolink/compare/v9.28.1...v9.29.0) (2026-03-19)
2
+
3
+ ### Features
4
+
5
+ - **(observability):** add OTEL instrumentation, observability exporters, and comprehensive test suite fixes ([095a774](https://github.com/juspay/neurolink/commit/095a7748b08edac4c34467e2a72caff4426a65bd))
6
+
7
+ ## [9.28.1](https://github.com/juspay/neurolink/compare/v9.28.0...v9.28.1) (2026-03-18)
8
+
9
+ ### Bug Fixes
10
+
11
+ - **(docs):** comprehensive documentation audit, code example fixes, and model updates ([f294ff2](https://github.com/juspay/neurolink/commit/f294ff2eef71a09e271c5dc536a9d00d97cfd5e5))
12
+
1
13
  ## [9.28.0](https://github.com/juspay/neurolink/compare/v9.27.0...v9.28.0) (2026-03-18)
2
14
 
3
15
  ### Features
package/README.md CHANGED
@@ -9,11 +9,14 @@ generated (LLM providers: the neurons) to where they are needed (connectors: the
9
9
  ```typescript
10
10
  import { NeuroLink } from "@juspay/neurolink";
11
11
 
12
- const pipe = new NeuroLink({ defaultProvider: "anthropic" });
12
+ const pipe = new NeuroLink();
13
13
 
14
14
  // Everything is a stream
15
- for await (const token of pipe.stream({ prompt: "Hello" })) {
16
- process.stdout.write(token);
15
+ const result = await pipe.stream({ input: { text: "Hello" } });
16
+ for await (const chunk of result.stream) {
17
+ if ("content" in chunk) {
18
+ process.stdout.write(chunk.content);
19
+ }
17
20
  }
18
21
  ```
19
22
 
@@ -79,11 +82,12 @@ Extracted from production systems at Juspay and battle-tested at enterprise scal
79
82
 
80
83
  ```typescript
81
84
  // Image Generation with Gemini (v8.31.0)
82
- const image = await neurolink.generateImage({
83
- prompt: "A futuristic cityscape",
85
+ const image = await neurolink.generate({
86
+ input: { text: "A futuristic cityscape" },
84
87
  provider: "google-ai",
85
88
  model: "imagen-3.0-generate-002",
86
89
  });
90
+ console.log(image.imageOutput?.base64); // Base64-encoded image
87
91
 
88
92
  // HTTP Transport for Remote MCP (v8.29.0)
89
93
  await neurolink.addExternalMCPServer("remote-tools", {
@@ -398,27 +402,25 @@ import { NeuroLink } from "@juspay/neurolink";
398
402
  const neurolink = new NeuroLink({
399
403
  conversationMemory: {
400
404
  enabled: true,
401
- store: "redis", // Automatically uses REDIS_URL
402
- ttl: 86400, // 24-hour session expiration
405
+ enableSummarization: true,
403
406
  },
404
407
  });
405
408
 
406
- // Or explicit configuration
409
+ // Or explicit Redis configuration
407
410
  const neurolinkExplicit = new NeuroLink({
408
411
  conversationMemory: {
409
412
  enabled: true,
410
- store: "redis",
411
- redis: {
413
+ redisConfig: {
412
414
  host: "redis.example.com",
413
415
  port: 6379,
414
416
  password: process.env.REDIS_PASSWORD,
415
- tls: true, // Enable for production
417
+ ttl: 86400, // 24-hour session expiration (seconds)
416
418
  },
417
419
  },
418
420
  });
419
421
 
420
- // Export conversation for analytics
421
- const history = await neurolink.exportConversation({ format: "json" });
422
+ // Retrieve conversation history for analytics
423
+ const history = await neurolink.getConversationHistory("session-id");
422
424
  await saveToDataWarehouse(history);
423
425
  ```
424
426
 
@@ -605,7 +607,6 @@ import { NeuroLink } from "@juspay/neurolink";
605
607
  const neurolink = new NeuroLink({
606
608
  conversationMemory: {
607
609
  enabled: true,
608
- store: "redis",
609
610
  },
610
611
  enableOrchestration: true,
611
612
  });
@@ -633,7 +634,7 @@ console.log(result.evaluation?.overallScore);
633
634
 
634
635
  // RAG: Ask questions about your documents
635
636
  const answer = await neurolink.generate({
636
- prompt: "What are the main architectural decisions?",
637
+ input: { text: "What are the main architectural decisions?" },
637
638
  rag: {
638
639
  files: ["./docs/architecture.md", "./docs/decisions.md"],
639
640
  strategy: "markdown",
@@ -657,7 +658,9 @@ const result = await neurolink.generate({
657
658
  },
658
659
  provider: "vertex",
659
660
  model: "gemini-3-flash-preview",
660
- thinkingLevel: "medium", // Options: "minimal", "low", "medium", "high"
661
+ thinkingConfig: {
662
+ thinkingLevel: "medium", // Options: "minimal", "low", "medium", "high"
663
+ },
661
664
  });
662
665
 
663
666
  console.log(result.content);
@@ -62,7 +62,12 @@ function normalizeVisionProvider(provider) {
62
62
  */
63
63
  const VISION_CAPABILITIES = {
64
64
  openai: [
65
- // GPT-5.2 family (released Dec 11, 2025) - Latest flagship models
65
+ // GPT-5.4 family (released Mar 2026) - Latest flagship models
66
+ "gpt-5.4",
67
+ "gpt-5.4-mini",
68
+ "gpt-5.4-nano",
69
+ "gpt-5.4-pro",
70
+ // GPT-5.2 family (released Dec 11, 2025)
66
71
  "gpt-5.2",
67
72
  "gpt-5.2-chat-latest",
68
73
  "gpt-5.2-pro",
@@ -118,6 +123,9 @@ const VISION_CAPABILITIES = {
118
123
  "gemini-pro-vision",
119
124
  ],
120
125
  anthropic: [
126
+ // Claude 4.6 Series (February 2026)
127
+ "claude-opus-4-6",
128
+ "claude-sonnet-4-6",
121
129
  // Claude 4.5 Series (September-November 2025)
122
130
  "claude-sonnet-4-5",
123
131
  "claude-sonnet-4-5-20250929",
@@ -25,9 +25,9 @@ export const DEFAULT_OUTPUT_RESERVE_RATIO = 0.35;
25
25
  export const MODEL_CONTEXT_WINDOWS = {
26
26
  anthropic: {
27
27
  _default: 200_000,
28
- // Claude 4.6 (Feb 2026) — 200K standard, 1M with beta header
29
- "claude-opus-4-6": 200_000,
30
- "claude-sonnet-4-6": 200_000,
28
+ // Claude 4.6 (Feb 2026) — 1M context window
29
+ "claude-opus-4-6": 1_000_000,
30
+ "claude-sonnet-4-6": 1_000_000,
31
31
  // Claude 4.5
32
32
  "claude-opus-4-5-20251101": 200_000,
33
33
  "claude-sonnet-4-5-20250929": 200_000,
@@ -46,6 +46,11 @@ export const MODEL_CONTEXT_WINDOWS = {
46
46
  },
47
47
  openai: {
48
48
  _default: 128_000,
49
+ // GPT-5.4 family — 1.05M context
50
+ "gpt-5.4": 1_050_000,
51
+ "gpt-5.4-mini": 400_000,
52
+ "gpt-5.4-nano": 400_000,
53
+ "gpt-5.4-pro": 1_050_000,
49
54
  // GPT-5.x family — 400K context
50
55
  "gpt-5.3-codex": 400_000,
51
56
  "gpt-5.2": 400_000,
@@ -108,8 +113,8 @@ export const MODEL_CONTEXT_WINDOWS = {
108
113
  vertex: {
109
114
  _default: 1_048_576,
110
115
  // Claude on Vertex
111
- "claude-opus-4-6": 200_000,
112
- "claude-sonnet-4-6": 200_000,
116
+ "claude-opus-4-6": 1_000_000,
117
+ "claude-sonnet-4-6": 1_000_000,
113
118
  "claude-sonnet-4-5": 200_000,
114
119
  "claude-opus-4-5": 200_000,
115
120
  "claude-haiku-4-5": 200_000,
@@ -136,8 +141,8 @@ export const MODEL_CONTEXT_WINDOWS = {
136
141
  bedrock: {
137
142
  _default: 200_000,
138
143
  // Claude 4.6
139
- "anthropic.claude-opus-4-6-v1:0": 200_000,
140
- "anthropic.claude-sonnet-4-6": 200_000,
144
+ "anthropic.claude-opus-4-6-v1:0": 1_000_000,
145
+ "anthropic.claude-sonnet-4-6": 1_000_000,
141
146
  // Claude 4.5
142
147
  "anthropic.claude-opus-4-5-20251124-v1:0": 200_000,
143
148
  "anthropic.claude-sonnet-4-5-20250929-v1:0": 200_000,
@@ -160,6 +165,11 @@ export const MODEL_CONTEXT_WINDOWS = {
160
165
  },
161
166
  azure: {
162
167
  _default: 128_000,
168
+ // GPT-5.4
169
+ "gpt-5.4": 1_050_000,
170
+ "gpt-5.4-mini": 400_000,
171
+ "gpt-5.4-nano": 400_000,
172
+ "gpt-5.4-pro": 1_050_000,
163
173
  // GPT-5.x
164
174
  "gpt-5.2": 400_000,
165
175
  "gpt-5.2-pro": 400_000,
@@ -192,6 +202,7 @@ export const MODEL_CONTEXT_WINDOWS = {
192
202
  "devstral-2512": 256_000,
193
203
  "devstral-small-2512": 256_000,
194
204
  "magistral-medium-latest": 128_000,
205
+ "mistral-small-2603": 256_000,
195
206
  },
196
207
  ollama: {
197
208
  _default: 128_000,
@@ -58,10 +58,15 @@ export declare enum BedrockModels {
58
58
  CLAUDE_4_5_HAIKU = "anthropic.claude-haiku-4-5-20251001-v1:0",
59
59
  CLAUDE_4_1_OPUS = "anthropic.claude-opus-4-1-20250805-v1:0",
60
60
  CLAUDE_4_SONNET = "anthropic.claude-sonnet-4-20250514-v1:0",
61
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
61
62
  CLAUDE_3_7_SONNET = "anthropic.claude-3-7-sonnet-20250219-v1:0",
63
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
62
64
  CLAUDE_3_5_SONNET = "anthropic.claude-3-5-sonnet-20241022-v1:0",
65
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
63
66
  CLAUDE_3_5_HAIKU = "anthropic.claude-3-5-haiku-20241022-v1:0",
67
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
64
68
  CLAUDE_3_SONNET = "anthropic.claude-3-sonnet-20240229-v1:0",
69
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
65
70
  CLAUDE_3_HAIKU = "anthropic.claude-3-haiku-20240307-v1:0",
66
71
  NOVA_PREMIER = "amazon.nova-premier-v1:0",
67
72
  NOVA_PRO = "amazon.nova-pro-v1:0",
@@ -144,6 +149,10 @@ export declare enum BedrockModels {
144
149
  */
145
150
  export declare enum OpenAIModels {
146
151
  GPT_5_3_CODEX = "gpt-5.3-codex",
152
+ GPT_5_4 = "gpt-5.4",
153
+ GPT_5_4_MINI = "gpt-5.4-mini",
154
+ GPT_5_4_NANO = "gpt-5.4-nano",
155
+ GPT_5_4_PRO = "gpt-5.4-pro",
147
156
  GPT_5_2 = "gpt-5.2",
148
157
  GPT_5_2_CHAT_LATEST = "gpt-5.2-chat-latest",
149
158
  GPT_5_2_PRO = "gpt-5.2-pro",
@@ -171,7 +180,9 @@ export declare enum OpenAIModels {
171
180
  O3_PRO = "o3-pro",
172
181
  O4_MINI = "o4-mini",
173
182
  O1 = "o1",
183
+ /** @deprecated Turned off Jul 14, 2025. Use GPT_4_1 or O3. */
174
184
  O1_PREVIEW = "o1-preview",
185
+ /** @deprecated Replaced by o3-mini. */
175
186
  O1_MINI = "o1-mini",
176
187
  GPT_4 = "gpt-4",
177
188
  GPT_4_TURBO = "gpt-4-turbo",
@@ -186,6 +197,9 @@ export declare enum AzureOpenAIModels {
186
197
  GPT_5_2_CHAT = "gpt-5.2-chat",
187
198
  GPT_5_2_PRO = "gpt-5.2-pro",
188
199
  GPT_5_2_CODEX = "gpt-5.2-codex",
200
+ GPT_5_4 = "gpt-5.4",
201
+ GPT_5_4_MINI = "gpt-5.4-mini",
202
+ GPT_5_4_NANO = "gpt-5.4-nano",
189
203
  GPT_5_1 = "gpt-5.1",
190
204
  GPT_5_1_CHAT = "gpt-5.1-chat",
191
205
  GPT_5_1_CODEX = "gpt-5.1-codex",
@@ -228,11 +242,17 @@ export declare enum VertexModels {
228
242
  CLAUDE_4_5_HAIKU = "claude-haiku-4-5@20251001",
229
243
  CLAUDE_4_0_SONNET = "claude-sonnet-4@20250514",
230
244
  CLAUDE_4_0_OPUS = "claude-opus-4@20250514",
245
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
231
246
  CLAUDE_3_7_SONNET = "claude-3-7-sonnet@20250219",
247
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
232
248
  CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20241022",
249
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
233
250
  CLAUDE_3_5_HAIKU = "claude-3-5-haiku-20241022",
251
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
234
252
  CLAUDE_3_SONNET = "claude-3-sonnet-20240229",
253
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
235
254
  CLAUDE_3_OPUS = "claude-3-opus-20240229",
255
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
236
256
  CLAUDE_3_HAIKU = "claude-3-haiku-20240307",
237
257
  GEMINI_3_1_PRO = "gemini-3.1-pro",
238
258
  GEMINI_3_1_PRO_PREVIEW = "gemini-3.1-pro-preview",
@@ -253,9 +273,9 @@ export declare enum VertexModels {
253
273
  GEMINI_2_0_FLASH = "gemini-2.0-flash",
254
274
  GEMINI_2_0_FLASH_001 = "gemini-2.0-flash-001",
255
275
  GEMINI_2_0_FLASH_LITE = "gemini-2.0-flash-lite",
256
- /** @deprecated Retired Sep 2025. Use Gemini 2.5+ */
276
+ /** @deprecated SHUT DOWN. Returns 404. Use GEMINI_2_5_FLASH or newer. */
257
277
  GEMINI_1_5_PRO = "gemini-1.5-pro-002",
258
- /** @deprecated Retired Sep 2025. Use Gemini 2.5+ */
278
+ /** @deprecated SHUT DOWN. Returns 404. Use GEMINI_2_5_FLASH or newer. */
259
279
  GEMINI_1_5_FLASH = "gemini-1.5-flash-002"
260
280
  }
261
281
  /**
@@ -277,16 +297,18 @@ export declare enum GoogleAIModels {
277
297
  GEMINI_2_5_FLASH_IMAGE = "gemini-2.5-flash-image",
278
298
  GEMINI_2_5_FLASH_PREVIEW_TTS = "gemini-2.5-flash-preview-tts",
279
299
  GEMINI_2_5_PRO_PREVIEW_TTS = "gemini-2.5-pro-preview-tts",
300
+ /** @deprecated Retiring June 1, 2026. Use GEMINI_2_5_FLASH instead. */
280
301
  GEMINI_2_0_FLASH = "gemini-2.0-flash",
281
302
  GEMINI_2_0_FLASH_001 = "gemini-2.0-flash-001",
282
303
  GEMINI_2_0_FLASH_LITE = "gemini-2.0-flash-lite",
283
304
  GEMINI_2_0_FLASH_IMAGE = "gemini-2.0-flash-preview-image-generation",
284
- /** @deprecated Retired Sep 2025. Use Gemini 2.5+ */
305
+ /** @deprecated SHUT DOWN. Returns 404. Use GEMINI_2_5_FLASH or newer. */
285
306
  GEMINI_1_5_PRO = "gemini-1.5-pro",
286
- /** @deprecated Retired Sep 2025. Use Gemini 2.5+ */
307
+ /** @deprecated SHUT DOWN. Returns 404. Use GEMINI_2_5_FLASH or newer. */
287
308
  GEMINI_1_5_FLASH = "gemini-1.5-flash",
288
309
  GEMINI_EMBEDDING = "gemini-embedding-001",
289
- /** @deprecated Shutdown Jan 2026. Use gemini-embedding-001 */
310
+ GEMINI_EMBEDDING_2_PREVIEW = "gemini-embedding-2-preview",
311
+ /** @deprecated SHUT DOWN Jan 14, 2026. Use GEMINI_EMBEDDING instead. */
290
312
  TEXT_EMBEDDING_004 = "text-embedding-004"
291
313
  }
292
314
  /**
@@ -301,11 +323,17 @@ export declare enum AnthropicModels {
301
323
  CLAUDE_OPUS_4_1 = "claude-opus-4-1-20250805",
302
324
  CLAUDE_OPUS_4_0 = "claude-opus-4-20250514",
303
325
  CLAUDE_SONNET_4_0 = "claude-sonnet-4-20250514",
326
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
304
327
  CLAUDE_SONNET_3_7 = "claude-3-7-sonnet-20250219",
328
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
305
329
  CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20241022",
330
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
306
331
  CLAUDE_3_5_HAIKU = "claude-3-5-haiku-20241022",
332
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
307
333
  CLAUDE_3_SONNET = "claude-3-sonnet-20240229",
334
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
308
335
  CLAUDE_3_OPUS = "claude-3-opus-20240229",
336
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
309
337
  CLAUDE_3_HAIKU = "claude-3-haiku-20240307"
310
338
  }
311
339
  /**
@@ -341,7 +369,9 @@ export declare enum MistralModels {
341
369
  MISTRAL_OCR_LATEST = "mistral-ocr-latest",
342
370
  MISTRAL_NEMO = "mistral-nemo",
343
371
  MISTRAL_EMBED = "mistral-embed",
344
- MISTRAL_MODERATION_LATEST = "mistral-moderation-latest"
372
+ MISTRAL_MODERATION_LATEST = "mistral-moderation-latest",
373
+ MISTRAL_SMALL_4 = "mistral-small-2603",
374
+ MISTRAL_SMALL_CREATIVE = "mistral-small-creative"
345
375
  }
346
376
  /**
347
377
  * Supported Models for Ollama (Local)
@@ -78,12 +78,17 @@ export var BedrockModels;
78
78
  BedrockModels["CLAUDE_4_1_OPUS"] = "anthropic.claude-opus-4-1-20250805-v1:0";
79
79
  BedrockModels["CLAUDE_4_SONNET"] = "anthropic.claude-sonnet-4-20250514-v1:0";
80
80
  // Claude 3.7 Series
81
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
81
82
  BedrockModels["CLAUDE_3_7_SONNET"] = "anthropic.claude-3-7-sonnet-20250219-v1:0";
82
83
  // Claude 3.5 Series
84
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
83
85
  BedrockModels["CLAUDE_3_5_SONNET"] = "anthropic.claude-3-5-sonnet-20241022-v1:0";
86
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
84
87
  BedrockModels["CLAUDE_3_5_HAIKU"] = "anthropic.claude-3-5-haiku-20241022-v1:0";
85
88
  // Claude 3 Series (Legacy support)
89
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
86
90
  BedrockModels["CLAUDE_3_SONNET"] = "anthropic.claude-3-sonnet-20240229-v1:0";
91
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
87
92
  BedrockModels["CLAUDE_3_HAIKU"] = "anthropic.claude-3-haiku-20240307-v1:0";
88
93
  // ============================================================================
89
94
  // AMAZON NOVA MODELS
@@ -216,6 +221,11 @@ export var OpenAIModels;
216
221
  (function (OpenAIModels) {
217
222
  // GPT-5.3 Series (Released February 2026) - Latest coding models
218
223
  OpenAIModels["GPT_5_3_CODEX"] = "gpt-5.3-codex";
224
+ // GPT-5.4 Series (Released March 2026) - Latest flagship models
225
+ OpenAIModels["GPT_5_4"] = "gpt-5.4";
226
+ OpenAIModels["GPT_5_4_MINI"] = "gpt-5.4-mini";
227
+ OpenAIModels["GPT_5_4_NANO"] = "gpt-5.4-nano";
228
+ OpenAIModels["GPT_5_4_PRO"] = "gpt-5.4-pro";
219
229
  // GPT-5.2 Series (Released December 11, 2025) - Flagship models
220
230
  OpenAIModels["GPT_5_2"] = "gpt-5.2";
221
231
  OpenAIModels["GPT_5_2_CHAT_LATEST"] = "gpt-5.2-chat-latest";
@@ -250,7 +260,9 @@ export var OpenAIModels;
250
260
  OpenAIModels["O3_PRO"] = "o3-pro";
251
261
  OpenAIModels["O4_MINI"] = "o4-mini";
252
262
  OpenAIModels["O1"] = "o1";
263
+ /** @deprecated Turned off Jul 14, 2025. Use GPT_4_1 or O3. */
253
264
  OpenAIModels["O1_PREVIEW"] = "o1-preview";
265
+ /** @deprecated Replaced by o3-mini. */
254
266
  OpenAIModels["O1_MINI"] = "o1-mini";
255
267
  // GPT-4 Series (Legacy)
256
268
  OpenAIModels["GPT_4"] = "gpt-4";
@@ -269,6 +281,10 @@ export var AzureOpenAIModels;
269
281
  AzureOpenAIModels["GPT_5_2_CHAT"] = "gpt-5.2-chat";
270
282
  AzureOpenAIModels["GPT_5_2_PRO"] = "gpt-5.2-pro";
271
283
  AzureOpenAIModels["GPT_5_2_CODEX"] = "gpt-5.2-codex";
284
+ // GPT-5.4 Series (March 2026)
285
+ AzureOpenAIModels["GPT_5_4"] = "gpt-5.4";
286
+ AzureOpenAIModels["GPT_5_4_MINI"] = "gpt-5.4-mini";
287
+ AzureOpenAIModels["GPT_5_4_NANO"] = "gpt-5.4-nano";
272
288
  // GPT-5.1 Series (October 2025)
273
289
  AzureOpenAIModels["GPT_5_1"] = "gpt-5.1";
274
290
  AzureOpenAIModels["GPT_5_1_CHAT"] = "gpt-5.1-chat";
@@ -323,13 +339,19 @@ export var VertexModels;
323
339
  VertexModels["CLAUDE_4_0_SONNET"] = "claude-sonnet-4@20250514";
324
340
  VertexModels["CLAUDE_4_0_OPUS"] = "claude-opus-4@20250514";
325
341
  // Claude 3.7 Series (February 2025)
342
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
326
343
  VertexModels["CLAUDE_3_7_SONNET"] = "claude-3-7-sonnet@20250219";
327
344
  // Claude 3.5 Series (Still supported)
345
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
328
346
  VertexModels["CLAUDE_3_5_SONNET"] = "claude-3-5-sonnet-20241022";
347
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
329
348
  VertexModels["CLAUDE_3_5_HAIKU"] = "claude-3-5-haiku-20241022";
330
349
  // Claude 3 Series (Legacy support)
350
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
331
351
  VertexModels["CLAUDE_3_SONNET"] = "claude-3-sonnet-20240229";
352
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
332
353
  VertexModels["CLAUDE_3_OPUS"] = "claude-3-opus-20240229";
354
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_4_6_SONNET instead. */
333
355
  VertexModels["CLAUDE_3_HAIKU"] = "claude-3-haiku-20240307";
334
356
  // Gemini 3.1 Series (Released March 2026)
335
357
  VertexModels["GEMINI_3_1_PRO"] = "gemini-3.1-pro";
@@ -355,9 +377,9 @@ export var VertexModels;
355
377
  VertexModels["GEMINI_2_0_FLASH_001"] = "gemini-2.0-flash-001";
356
378
  VertexModels["GEMINI_2_0_FLASH_LITE"] = "gemini-2.0-flash-lite";
357
379
  // Gemini 1.5 Series (Retired - returns 404)
358
- /** @deprecated Retired Sep 2025. Use Gemini 2.5+ */
380
+ /** @deprecated SHUT DOWN. Returns 404. Use GEMINI_2_5_FLASH or newer. */
359
381
  VertexModels["GEMINI_1_5_PRO"] = "gemini-1.5-pro-002";
360
- /** @deprecated Retired Sep 2025. Use Gemini 2.5+ */
382
+ /** @deprecated SHUT DOWN. Returns 404. Use GEMINI_2_5_FLASH or newer. */
361
383
  VertexModels["GEMINI_1_5_FLASH"] = "gemini-1.5-flash-002";
362
384
  })(VertexModels || (VertexModels = {}));
363
385
  /**
@@ -384,18 +406,20 @@ export var GoogleAIModels;
384
406
  GoogleAIModels["GEMINI_2_5_FLASH_PREVIEW_TTS"] = "gemini-2.5-flash-preview-tts";
385
407
  GoogleAIModels["GEMINI_2_5_PRO_PREVIEW_TTS"] = "gemini-2.5-pro-preview-tts";
386
408
  // Gemini 2.0 Series (Deprecated - retiring Jun 2026)
409
+ /** @deprecated Retiring June 1, 2026. Use GEMINI_2_5_FLASH instead. */
387
410
  GoogleAIModels["GEMINI_2_0_FLASH"] = "gemini-2.0-flash";
388
411
  GoogleAIModels["GEMINI_2_0_FLASH_001"] = "gemini-2.0-flash-001";
389
412
  GoogleAIModels["GEMINI_2_0_FLASH_LITE"] = "gemini-2.0-flash-lite";
390
413
  GoogleAIModels["GEMINI_2_0_FLASH_IMAGE"] = "gemini-2.0-flash-preview-image-generation";
391
414
  // Gemini 1.5 Series (Retired - returns 404)
392
- /** @deprecated Retired Sep 2025. Use Gemini 2.5+ */
415
+ /** @deprecated SHUT DOWN. Returns 404. Use GEMINI_2_5_FLASH or newer. */
393
416
  GoogleAIModels["GEMINI_1_5_PRO"] = "gemini-1.5-pro";
394
- /** @deprecated Retired Sep 2025. Use Gemini 2.5+ */
417
+ /** @deprecated SHUT DOWN. Returns 404. Use GEMINI_2_5_FLASH or newer. */
395
418
  GoogleAIModels["GEMINI_1_5_FLASH"] = "gemini-1.5-flash";
396
419
  // Embedding Models
397
420
  GoogleAIModels["GEMINI_EMBEDDING"] = "gemini-embedding-001";
398
- /** @deprecated Shutdown Jan 2026. Use gemini-embedding-001 */
421
+ GoogleAIModels["GEMINI_EMBEDDING_2_PREVIEW"] = "gemini-embedding-2-preview";
422
+ /** @deprecated SHUT DOWN Jan 14, 2026. Use GEMINI_EMBEDDING instead. */
399
423
  GoogleAIModels["TEXT_EMBEDDING_004"] = "text-embedding-004";
400
424
  })(GoogleAIModels || (GoogleAIModels = {}));
401
425
  /**
@@ -416,13 +440,19 @@ export var AnthropicModels;
416
440
  AnthropicModels["CLAUDE_OPUS_4_0"] = "claude-opus-4-20250514";
417
441
  AnthropicModels["CLAUDE_SONNET_4_0"] = "claude-sonnet-4-20250514";
418
442
  // Claude 3.7 Series (Legacy)
443
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
419
444
  AnthropicModels["CLAUDE_SONNET_3_7"] = "claude-3-7-sonnet-20250219";
420
445
  // Claude 3.5 Series (Legacy)
446
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
421
447
  AnthropicModels["CLAUDE_3_5_SONNET"] = "claude-3-5-sonnet-20241022";
448
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
422
449
  AnthropicModels["CLAUDE_3_5_HAIKU"] = "claude-3-5-haiku-20241022";
423
450
  // Claude 3 Series (Legacy - Deprecated)
451
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
424
452
  AnthropicModels["CLAUDE_3_SONNET"] = "claude-3-sonnet-20240229";
453
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
425
454
  AnthropicModels["CLAUDE_3_OPUS"] = "claude-3-opus-20240229";
455
+ /** @deprecated Retired from Anthropic API. Use CLAUDE_SONNET_4_6 instead. */
426
456
  AnthropicModels["CLAUDE_3_HAIKU"] = "claude-3-haiku-20240307";
427
457
  })(AnthropicModels || (AnthropicModels = {}));
428
458
  /**
@@ -474,6 +504,9 @@ export var MistralModels;
474
504
  MistralModels["MISTRAL_NEMO"] = "mistral-nemo";
475
505
  MistralModels["MISTRAL_EMBED"] = "mistral-embed";
476
506
  MistralModels["MISTRAL_MODERATION_LATEST"] = "mistral-moderation-latest";
507
+ // Mistral Small 4 Series (June 2026)
508
+ MistralModels["MISTRAL_SMALL_4"] = "mistral-small-2603";
509
+ MistralModels["MISTRAL_SMALL_CREATIVE"] = "mistral-small-creative";
477
510
  })(MistralModels || (MistralModels = {}));
478
511
  /**
479
512
  * Supported Models for Ollama (Local)
@@ -71,6 +71,10 @@ export declare const PROVIDER_TOKEN_LIMITS: {
71
71
  };
72
72
  /** OpenAI model limits */
73
73
  readonly OPENAI: {
74
+ readonly "gpt-5.4": 128000;
75
+ readonly "gpt-5.4-mini": 128000;
76
+ readonly "gpt-5.4-nano": 128000;
77
+ readonly "gpt-5.4-pro": 128000;
74
78
  readonly "gpt-4o": 16384;
75
79
  readonly "gpt-4o-mini": 16384;
76
80
  readonly "gpt-3.5-turbo": 4096;
@@ -74,6 +74,10 @@ export const PROVIDER_TOKEN_LIMITS = {
74
74
  },
75
75
  /** OpenAI model limits */
76
76
  OPENAI: {
77
+ "gpt-5.4": 128_000,
78
+ "gpt-5.4-mini": 128_000,
79
+ "gpt-5.4-nano": 128_000,
80
+ "gpt-5.4-pro": 128_000,
77
81
  "gpt-4o": 16384,
78
82
  "gpt-4o-mini": 16384,
79
83
  "gpt-3.5-turbo": 4096,
@@ -40,7 +40,7 @@ export class ContextCompactor {
40
40
  * Run the multi-stage compaction pipeline until messages fit within budget.
41
41
  */
42
42
  async compact(messages, targetTokens, memoryConfig, requestId) {
43
- const span = SpanSerializer.createSpan(SpanType.CONTEXT_COMPACTION, "context.compact", {
43
+ let span = SpanSerializer.createSpan(SpanType.CONTEXT_COMPACTION, "context.compact", {
44
44
  "context.operation": "compact",
45
45
  "context.targetTokens": targetTokens,
46
46
  });
@@ -132,7 +132,7 @@ export class ContextCompactor {
132
132
  saved: 0,
133
133
  });
134
134
  // Record failure on the compaction span for trace visibility
135
- SpanSerializer.updateAttributes(span, {
135
+ span = SpanSerializer.updateAttributes(span, {
136
136
  "compaction.stage3.error": err.message,
137
137
  "compaction.stage3.errorName": err.name,
138
138
  "compaction.stage3.tokensBefore": stageTokensBefore,
@@ -24,11 +24,15 @@ export declare abstract class BaseProvider implements AIProvider {
24
24
  protected sessionId?: string;
25
25
  protected userId?: string;
26
26
  protected neurolink?: NeuroLink;
27
- /** Trace context propagated from NeuroLink SDK for span hierarchy */
28
- _traceContext: {
27
+ /** @internal Trace context propagated from NeuroLink SDK for span hierarchy */
28
+ protected _traceContext: {
29
29
  traceId: string;
30
30
  parentSpanId: string;
31
31
  } | null;
32
+ setTraceContext(ctx: {
33
+ traceId: string;
34
+ parentSpanId: string;
35
+ } | null): void;
32
36
  private readonly messageBuilder;
33
37
  private readonly streamHandler;
34
38
  private readonly generationHandler;
@@ -3,7 +3,10 @@ import { generateText } from "ai";
3
3
  import { directAgentTools } from "../agent/directTools.js";
4
4
  import { IMAGE_GENERATION_MODELS } from "../core/constants.js";
5
5
  import { MiddlewareFactory } from "../middleware/factory.js";
6
+ import { SpanStatus, SpanType } from "../observability/types/spanTypes.js";
7
+ import { SpanSerializer } from "../observability/utils/spanSerializer.js";
6
8
  import { ATTR, tracers } from "../telemetry/index.js";
9
+ import { calculateCost } from "../utils/pricing.js";
7
10
  import { isAbortError } from "../utils/errorHandling.js";
8
11
  import { logger } from "../utils/logger.js";
9
12
  import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
@@ -37,8 +40,11 @@ export class BaseProvider {
37
40
  sessionId;
38
41
  userId;
39
42
  neurolink; // Reference to actual NeuroLink instance for MCP tools
40
- /** Trace context propagated from NeuroLink SDK for span hierarchy */
43
+ /** @internal Trace context propagated from NeuroLink SDK for span hierarchy */
41
44
  _traceContext = null;
45
+ setTraceContext(ctx) {
46
+ this._traceContext = ctx;
47
+ }
42
48
  // Composition modules - Single Responsibility Principle
43
49
  messageBuilder;
44
50
  streamHandler;
@@ -81,6 +87,14 @@ export class BaseProvider {
81
87
  */
82
88
  async stream(optionsOrPrompt, analysisSchema) {
83
89
  let options = this.normalizeStreamOptions(optionsOrPrompt);
90
+ // Observability: create metrics span for provider.stream
91
+ const metricsSpan = SpanSerializer.createSpan(SpanType.MODEL_GENERATION, "provider.stream", {
92
+ "ai.provider": this.providerName || "unknown",
93
+ "ai.model": this.modelName || options.model || "unknown",
94
+ "ai.temperature": options.temperature,
95
+ "ai.max_tokens": options.maxTokens,
96
+ }, this._traceContext?.parentSpanId, this._traceContext?.traceId);
97
+ let metricsSpanRecorded = false;
84
98
  // OTEL span for provider-level stream tracing
85
99
  const otelStreamSpan = tracers.provider.startSpan("neurolink.provider.stream", {
86
100
  kind: SpanKind.CLIENT,
@@ -173,6 +187,11 @@ export class BaseProvider {
173
187
  }
174
188
  }
175
189
  catch (error) {
190
+ // Observability: record failed stream span
191
+ metricsSpanRecorded = true;
192
+ const _endedStreamSpan = SpanSerializer.endSpan(metricsSpan, SpanStatus.ERROR, error instanceof Error ? error.message : String(error));
193
+ // Note: Do NOT record to getMetricsAggregator() here — neurolink.ts
194
+ // stream:complete listener handles authoritative metrics to avoid double-counting.
176
195
  otelStreamSpan.setStatus({
177
196
  code: SpanStatusCode.ERROR,
178
197
  message: error instanceof Error ? error.message : String(error),
@@ -181,6 +200,12 @@ export class BaseProvider {
181
200
  throw error;
182
201
  }
183
202
  finally {
203
+ // Observability: record successful stream span (only if not already ended via error path)
204
+ if (!metricsSpanRecorded) {
205
+ const _endedStreamSpan = SpanSerializer.endSpan(metricsSpan, SpanStatus.OK);
206
+ // Note: Do NOT record to getMetricsAggregator() here — neurolink.ts
207
+ // stream:complete listener handles authoritative metrics to avoid double-counting.
208
+ }
184
209
  // End OTEL span on success (only if not already ended via error path)
185
210
  if (otelStreamSpan.isRecording()) {
186
211
  otelStreamSpan.setStatus({ code: SpanStatusCode.OK });
@@ -477,6 +502,13 @@ export class BaseProvider {
477
502
  const options = this.normalizeTextOptions(optionsOrPrompt);
478
503
  this.validateOptions(options);
479
504
  const startTime = Date.now();
505
+ // Observability: create metrics span for provider.generate
506
+ const metricsSpan = SpanSerializer.createSpan(SpanType.MODEL_GENERATION, "provider.generate", {
507
+ "ai.provider": this.providerName || "unknown",
508
+ "ai.model": this.modelName || options.model || "unknown",
509
+ "ai.temperature": options.temperature,
510
+ "ai.max_tokens": options.maxTokens,
511
+ }, this._traceContext?.parentSpanId, this._traceContext?.traceId);
480
512
  // OTEL span for provider-level generate tracing
481
513
  // Use startActiveSpan pattern via context.with() so child spans become descendants
482
514
  const otelSpan = tracers.provider.startSpan("neurolink.provider.generate", {
@@ -665,9 +697,37 @@ export class BaseProvider {
665
697
  });
666
698
  }
667
699
  }
700
+ // Observability: record successful generate span with token/cost data
701
+ let enrichedGenerateSpan = { ...metricsSpan };
702
+ if (enhancedResult?.usage) {
703
+ enrichedGenerateSpan = SpanSerializer.enrichWithTokenUsage(enrichedGenerateSpan, {
704
+ promptTokens: enhancedResult.usage.input || 0,
705
+ completionTokens: enhancedResult.usage.output || 0,
706
+ totalTokens: enhancedResult.usage.total || 0,
707
+ });
708
+ const cost = calculateCost(this.providerName, this.modelName, {
709
+ input: enhancedResult.usage.input || 0,
710
+ output: enhancedResult.usage.output || 0,
711
+ total: enhancedResult.usage.total || 0,
712
+ });
713
+ if (cost && cost > 0) {
714
+ enrichedGenerateSpan = SpanSerializer.enrichWithCost(enrichedGenerateSpan, {
715
+ totalCost: cost,
716
+ });
717
+ }
718
+ }
719
+ const _endedGenerateSpan = SpanSerializer.endSpan(enrichedGenerateSpan, SpanStatus.OK);
720
+ // Note: Do NOT record to getMetricsAggregator() here — the neurolink.ts
721
+ // generation:end listener creates an authoritative span with richer context
722
+ // (provider name, model, input/output) and records to both aggregators.
723
+ // Recording here would double-count cost and token metrics.
668
724
  return await this.enhanceResult(enhancedResult, options, startTime);
669
725
  }
670
726
  catch (error) {
727
+ // Observability: record failed generate span
728
+ const _endedGenerateSpan = SpanSerializer.endSpan(metricsSpan, SpanStatus.ERROR, error instanceof Error ? error.message : String(error));
729
+ // Note: Do NOT record to getMetricsAggregator() here — neurolink.ts
730
+ // handles authoritative metrics recording to avoid double-counting.
671
731
  otelSpan.setStatus({
672
732
  code: SpanStatusCode.ERROR,
673
733
  message: error instanceof Error ? error.message : String(error),