@juspay/neurolink 3.0.1 → 4.1.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 (232) hide show
  1. package/CHANGELOG.md +66 -6
  2. package/README.md +318 -27
  3. package/dist/agent/direct-tools.d.ts +6 -6
  4. package/dist/chat/client-utils.d.ts +92 -0
  5. package/dist/chat/client-utils.js +298 -0
  6. package/dist/chat/index.d.ts +27 -0
  7. package/dist/chat/index.js +41 -0
  8. package/dist/chat/session-storage.d.ts +77 -0
  9. package/dist/chat/session-storage.js +233 -0
  10. package/dist/chat/session.d.ts +95 -0
  11. package/dist/chat/session.js +257 -0
  12. package/dist/chat/sse-handler.d.ts +49 -0
  13. package/dist/chat/sse-handler.js +266 -0
  14. package/dist/chat/types.d.ts +73 -0
  15. package/dist/chat/types.js +5 -0
  16. package/dist/chat/websocket-chat-handler.d.ts +36 -0
  17. package/dist/chat/websocket-chat-handler.js +262 -0
  18. package/dist/cli/commands/config.js +12 -12
  19. package/dist/cli/commands/mcp.js +3 -4
  20. package/dist/cli/index.d.ts +0 -7
  21. package/dist/cli/index.js +247 -28
  22. package/dist/config/configManager.d.ts +60 -0
  23. package/dist/config/configManager.js +300 -0
  24. package/dist/config/types.d.ts +136 -0
  25. package/dist/config/types.js +43 -0
  26. package/dist/core/analytics.d.ts +23 -0
  27. package/dist/core/analytics.js +131 -0
  28. package/dist/core/constants.d.ts +41 -0
  29. package/dist/core/constants.js +50 -0
  30. package/dist/core/defaults.d.ts +18 -0
  31. package/dist/core/defaults.js +29 -0
  32. package/dist/core/evaluation-config.d.ts +29 -0
  33. package/dist/core/evaluation-config.js +144 -0
  34. package/dist/core/evaluation-providers.d.ts +30 -0
  35. package/dist/core/evaluation-providers.js +187 -0
  36. package/dist/core/evaluation.d.ts +117 -0
  37. package/dist/core/evaluation.js +528 -0
  38. package/dist/core/factory.js +33 -25
  39. package/dist/core/types.d.ts +165 -6
  40. package/dist/core/types.js +3 -4
  41. package/dist/index.d.ts +9 -4
  42. package/dist/index.js +25 -4
  43. package/dist/lib/agent/direct-tools.d.ts +6 -6
  44. package/dist/lib/chat/client-utils.d.ts +92 -0
  45. package/dist/lib/chat/client-utils.js +298 -0
  46. package/dist/lib/chat/index.d.ts +27 -0
  47. package/dist/lib/chat/index.js +41 -0
  48. package/dist/lib/chat/session-storage.d.ts +77 -0
  49. package/dist/lib/chat/session-storage.js +233 -0
  50. package/dist/lib/chat/session.d.ts +95 -0
  51. package/dist/lib/chat/session.js +257 -0
  52. package/dist/lib/chat/sse-handler.d.ts +49 -0
  53. package/dist/lib/chat/sse-handler.js +266 -0
  54. package/dist/lib/chat/types.d.ts +73 -0
  55. package/dist/lib/chat/types.js +5 -0
  56. package/dist/lib/chat/websocket-chat-handler.d.ts +36 -0
  57. package/dist/lib/chat/websocket-chat-handler.js +262 -0
  58. package/dist/lib/config/configManager.d.ts +60 -0
  59. package/dist/lib/config/configManager.js +300 -0
  60. package/dist/lib/config/types.d.ts +136 -0
  61. package/dist/lib/config/types.js +43 -0
  62. package/dist/lib/core/analytics.d.ts +23 -0
  63. package/dist/lib/core/analytics.js +131 -0
  64. package/dist/lib/core/constants.d.ts +41 -0
  65. package/dist/lib/core/constants.js +50 -0
  66. package/dist/lib/core/defaults.d.ts +18 -0
  67. package/dist/lib/core/defaults.js +29 -0
  68. package/dist/lib/core/evaluation-config.d.ts +29 -0
  69. package/dist/lib/core/evaluation-config.js +144 -0
  70. package/dist/lib/core/evaluation-providers.d.ts +30 -0
  71. package/dist/lib/core/evaluation-providers.js +187 -0
  72. package/dist/lib/core/evaluation.d.ts +117 -0
  73. package/dist/lib/core/evaluation.js +528 -0
  74. package/dist/lib/core/factory.js +33 -26
  75. package/dist/lib/core/types.d.ts +165 -6
  76. package/dist/lib/core/types.js +3 -4
  77. package/dist/lib/index.d.ts +9 -4
  78. package/dist/lib/index.js +25 -4
  79. package/dist/lib/mcp/contracts/mcpContract.d.ts +118 -0
  80. package/dist/lib/mcp/contracts/mcpContract.js +5 -0
  81. package/dist/lib/mcp/dynamic-chain-executor.d.ts +201 -0
  82. package/dist/lib/mcp/dynamic-chain-executor.js +489 -0
  83. package/dist/lib/mcp/dynamic-orchestrator.d.ts +109 -0
  84. package/dist/lib/mcp/dynamic-orchestrator.js +351 -0
  85. package/dist/lib/mcp/error-manager.d.ts +254 -0
  86. package/dist/lib/mcp/error-manager.js +501 -0
  87. package/dist/lib/mcp/error-recovery.d.ts +158 -0
  88. package/dist/lib/mcp/error-recovery.js +405 -0
  89. package/dist/lib/mcp/function-calling.js +11 -3
  90. package/dist/lib/mcp/health-monitor.d.ts +256 -0
  91. package/dist/lib/mcp/health-monitor.js +621 -0
  92. package/dist/lib/mcp/logging.js +5 -0
  93. package/dist/lib/mcp/neurolink-mcp-client.js +2 -1
  94. package/dist/lib/mcp/orchestrator.d.ts +136 -5
  95. package/dist/lib/mcp/orchestrator.js +332 -16
  96. package/dist/lib/mcp/registry.d.ts +71 -16
  97. package/dist/lib/mcp/registry.js +104 -6
  98. package/dist/lib/mcp/semaphore-manager.d.ts +137 -0
  99. package/dist/lib/mcp/semaphore-manager.js +329 -0
  100. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
  101. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +5 -4
  102. package/dist/lib/mcp/session-manager.d.ts +186 -0
  103. package/dist/lib/mcp/session-manager.js +400 -0
  104. package/dist/lib/mcp/session-persistence.d.ts +93 -0
  105. package/dist/lib/mcp/session-persistence.js +298 -0
  106. package/dist/lib/mcp/tool-integration.js +1 -1
  107. package/dist/lib/mcp/tool-registry.d.ts +55 -34
  108. package/dist/lib/mcp/tool-registry.js +111 -97
  109. package/dist/lib/mcp/transport-manager.d.ts +153 -0
  110. package/dist/lib/mcp/transport-manager.js +330 -0
  111. package/dist/lib/mcp/unified-mcp.js +6 -1
  112. package/dist/lib/mcp/unified-registry.d.ts +54 -5
  113. package/dist/lib/mcp/unified-registry.js +139 -6
  114. package/dist/lib/neurolink.d.ts +101 -0
  115. package/dist/lib/neurolink.js +147 -1
  116. package/dist/lib/providers/agent-enhanced-provider.d.ts +11 -2
  117. package/dist/lib/providers/agent-enhanced-provider.js +86 -15
  118. package/dist/lib/providers/amazonBedrock.d.ts +9 -1
  119. package/dist/lib/providers/amazonBedrock.js +26 -2
  120. package/dist/lib/providers/analytics-helper.d.ts +53 -0
  121. package/dist/lib/providers/analytics-helper.js +151 -0
  122. package/dist/lib/providers/anthropic.d.ts +11 -1
  123. package/dist/lib/providers/anthropic.js +29 -4
  124. package/dist/lib/providers/azureOpenAI.d.ts +3 -1
  125. package/dist/lib/providers/azureOpenAI.js +28 -4
  126. package/dist/lib/providers/function-calling-provider.d.ts +9 -1
  127. package/dist/lib/providers/function-calling-provider.js +14 -1
  128. package/dist/lib/providers/googleAIStudio.d.ts +15 -1
  129. package/dist/lib/providers/googleAIStudio.js +32 -2
  130. package/dist/lib/providers/googleVertexAI.d.ts +9 -1
  131. package/dist/lib/providers/googleVertexAI.js +31 -2
  132. package/dist/lib/providers/huggingFace.d.ts +3 -1
  133. package/dist/lib/providers/huggingFace.js +26 -3
  134. package/dist/lib/providers/mcp-provider.d.ts +9 -1
  135. package/dist/lib/providers/mcp-provider.js +12 -0
  136. package/dist/lib/providers/mistralAI.d.ts +3 -1
  137. package/dist/lib/providers/mistralAI.js +25 -2
  138. package/dist/lib/providers/ollama.d.ts +3 -1
  139. package/dist/lib/providers/ollama.js +27 -4
  140. package/dist/lib/providers/openAI.d.ts +15 -1
  141. package/dist/lib/providers/openAI.js +32 -2
  142. package/dist/lib/proxy/proxy-fetch.js +8 -7
  143. package/dist/lib/services/streaming/streaming-manager.d.ts +29 -0
  144. package/dist/lib/services/streaming/streaming-manager.js +244 -0
  145. package/dist/lib/services/types.d.ts +155 -0
  146. package/dist/lib/services/types.js +2 -0
  147. package/dist/lib/services/websocket/websocket-server.d.ts +34 -0
  148. package/dist/lib/services/websocket/websocket-server.js +304 -0
  149. package/dist/lib/telemetry/index.d.ts +15 -0
  150. package/dist/lib/telemetry/index.js +22 -0
  151. package/dist/lib/telemetry/telemetry-service.d.ts +47 -0
  152. package/dist/lib/telemetry/telemetry-service.js +259 -0
  153. package/dist/lib/utils/streaming-utils.d.ts +67 -0
  154. package/dist/lib/utils/streaming-utils.js +201 -0
  155. package/dist/mcp/contracts/mcpContract.d.ts +118 -0
  156. package/dist/mcp/contracts/mcpContract.js +5 -0
  157. package/dist/mcp/dynamic-chain-executor.d.ts +201 -0
  158. package/dist/mcp/dynamic-chain-executor.js +489 -0
  159. package/dist/mcp/dynamic-orchestrator.d.ts +109 -0
  160. package/dist/mcp/dynamic-orchestrator.js +351 -0
  161. package/dist/mcp/error-manager.d.ts +254 -0
  162. package/dist/mcp/error-manager.js +501 -0
  163. package/dist/mcp/error-recovery.d.ts +158 -0
  164. package/dist/mcp/error-recovery.js +405 -0
  165. package/dist/mcp/function-calling.js +11 -3
  166. package/dist/mcp/health-monitor.d.ts +256 -0
  167. package/dist/mcp/health-monitor.js +621 -0
  168. package/dist/mcp/logging.js +5 -0
  169. package/dist/mcp/neurolink-mcp-client.js +2 -1
  170. package/dist/mcp/orchestrator.d.ts +136 -5
  171. package/dist/mcp/orchestrator.js +332 -16
  172. package/dist/mcp/plugins/core/neurolink-mcp.json +15 -15
  173. package/dist/mcp/registry.d.ts +71 -16
  174. package/dist/mcp/registry.js +104 -6
  175. package/dist/mcp/semaphore-manager.d.ts +137 -0
  176. package/dist/mcp/semaphore-manager.js +329 -0
  177. package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
  178. package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +5 -4
  179. package/dist/mcp/session-manager.d.ts +186 -0
  180. package/dist/mcp/session-manager.js +400 -0
  181. package/dist/mcp/session-persistence.d.ts +93 -0
  182. package/dist/mcp/session-persistence.js +299 -0
  183. package/dist/mcp/tool-integration.js +1 -1
  184. package/dist/mcp/tool-registry.d.ts +55 -34
  185. package/dist/mcp/tool-registry.js +111 -97
  186. package/dist/mcp/transport-manager.d.ts +153 -0
  187. package/dist/mcp/transport-manager.js +331 -0
  188. package/dist/mcp/unified-mcp.js +6 -1
  189. package/dist/mcp/unified-registry.d.ts +54 -5
  190. package/dist/mcp/unified-registry.js +139 -6
  191. package/dist/neurolink.d.ts +101 -0
  192. package/dist/neurolink.js +147 -1
  193. package/dist/providers/agent-enhanced-provider.d.ts +11 -2
  194. package/dist/providers/agent-enhanced-provider.js +86 -15
  195. package/dist/providers/amazonBedrock.d.ts +9 -1
  196. package/dist/providers/amazonBedrock.js +26 -2
  197. package/dist/providers/analytics-helper.d.ts +53 -0
  198. package/dist/providers/analytics-helper.js +151 -0
  199. package/dist/providers/anthropic.d.ts +11 -1
  200. package/dist/providers/anthropic.js +29 -4
  201. package/dist/providers/azureOpenAI.d.ts +3 -1
  202. package/dist/providers/azureOpenAI.js +29 -4
  203. package/dist/providers/function-calling-provider.d.ts +9 -1
  204. package/dist/providers/function-calling-provider.js +14 -1
  205. package/dist/providers/googleAIStudio.d.ts +15 -1
  206. package/dist/providers/googleAIStudio.js +32 -2
  207. package/dist/providers/googleVertexAI.d.ts +9 -1
  208. package/dist/providers/googleVertexAI.js +31 -2
  209. package/dist/providers/huggingFace.d.ts +3 -1
  210. package/dist/providers/huggingFace.js +26 -3
  211. package/dist/providers/mcp-provider.d.ts +9 -1
  212. package/dist/providers/mcp-provider.js +12 -0
  213. package/dist/providers/mistralAI.d.ts +3 -1
  214. package/dist/providers/mistralAI.js +25 -2
  215. package/dist/providers/ollama.d.ts +3 -1
  216. package/dist/providers/ollama.js +27 -4
  217. package/dist/providers/openAI.d.ts +15 -1
  218. package/dist/providers/openAI.js +33 -2
  219. package/dist/proxy/proxy-fetch.js +8 -7
  220. package/dist/services/streaming/streaming-manager.d.ts +29 -0
  221. package/dist/services/streaming/streaming-manager.js +244 -0
  222. package/dist/services/types.d.ts +155 -0
  223. package/dist/services/types.js +2 -0
  224. package/dist/services/websocket/websocket-server.d.ts +34 -0
  225. package/dist/services/websocket/websocket-server.js +304 -0
  226. package/dist/telemetry/index.d.ts +15 -0
  227. package/dist/telemetry/index.js +22 -0
  228. package/dist/telemetry/telemetry-service.d.ts +47 -0
  229. package/dist/telemetry/telemetry-service.js +261 -0
  230. package/dist/utils/streaming-utils.d.ts +67 -0
  231. package/dist/utils/streaming-utils.js +201 -0
  232. package/package.json +245 -228
package/CHANGELOG.md CHANGED
@@ -1,23 +1,83 @@
1
- ## [3.0.1](https://github.com/juspay/neurolink/compare/v3.0.0...v3.0.1) (2025-07-01)
1
+ # [4.1.0](https://github.com/juspay/neurolink/compare/v4.0.0...v4.1.0) (2025-07-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * **mcp:** comprehensive MCP system overhaul with GitHub PR fixes ([c0d8114](https://github.com/juspay/neurolink/commit/c0d8114ef1ab2d5dd3162c369f234d0de17397f7))
7
+
8
+ # [4.0.0](https://github.com/juspay/neurolink/compare/v3.0.1...v4.0.0) (2025-07-06)
9
+
10
+ - feat(core)!: transform NeuroLink into enterprise AI analytics platform ([74c88d6](https://github.com/juspay/neurolink/commit/74c88d6484bbd983aba9119929481e655d62eab3))
2
11
 
12
+ ### BREAKING CHANGES
13
+
14
+ - Major architectural enhancement from basic AI SDK
15
+ to comprehensive enterprise platform with analytics, evaluation,
16
+ real-time services, and business intelligence capabilities.
17
+
18
+ Core Features Added:
19
+
20
+ - Analytics System: Usage tracking, cost estimation, performance monitoring
21
+ - Evaluation Framework: AI-powered quality assessment and scoring
22
+ - Enterprise Config: Backup/restore, validation, provider management
23
+ - Real-time Services: Chat, streaming, websocket capabilities
24
+ - Telemetry: OpenTelemetry integration for production monitoring
25
+ - Documentation: Complete business and technical documentation overhaul
26
+ - Examples: Comprehensive demo library with 30+ working examples
27
+ - Provider Integration: Analytics helper integrated across all 9 providers
28
+
29
+ Technical Implementation:
30
+
31
+ - NEW: src/lib/core/analytics.ts - Real usage tracking engine
32
+ - NEW: src/lib/core/evaluation.ts - AI quality assessment framework
33
+ - NEW: src/lib/config/configManager.ts - Enterprise configuration management
34
+ - NEW: src/lib/chat/ - Complete chat service infrastructure (7 files)
35
+ - NEW: src/lib/services/ - Streaming and WebSocket architecture
36
+ - NEW: src/lib/telemetry/ - OpenTelemetry integration
37
+ - NEW: examples/ - Comprehensive demo ecosystem (30+ examples)
38
+ - NEW: docs/ - Complete documentation overhaul (15+ guides)
39
+ - ENHANCED: All 9 providers with analytics integration
40
+ - ENHANCED: CLI with professional analytics display
41
+ - ENHANCED: Testing infrastructure with new test suites
42
+
43
+ Files Changed: 127 files (+20,542 additions, -6,142 deletions)
44
+ Backward Compatibility: 100% maintained - existing functionality preserved
45
+ New Features: Opt-in via --enable-analytics --enable-evaluation flags
46
+
47
+ Business Impact:
48
+
49
+ - Production Monitoring: Real-time performance and cost tracking
50
+ - Quality Assurance: AI-powered response evaluation and scoring
51
+ - Cost Optimization: Usage analytics and provider comparison
52
+ - Risk Management: Backup systems and error recovery
53
+ - Developer Experience: Professional CLI and comprehensive examples
54
+ - Enterprise Readiness: OpenTelemetry observability and operational excellence
55
+
56
+ Performance Metrics:
57
+
58
+ - Analytics: Real token counts (299-768), response times (2-10s)
59
+ - Evaluation: Quality scores (8-10/10), sub-6s processing
60
+ - Providers: All 9 providers enhanced with zero breaking changes
61
+ - CLI: Professional output with debug diagnostics
62
+
63
+ ## [3.0.1](https://github.com/juspay/neurolink/compare/v3.0.0...v3.0.1) (2025-07-01)
3
64
 
4
65
  ### Bug Fixes
5
66
 
6
- * **cli:** honor --model parameter in CLI commands ([467ea85](https://github.com/juspay/neurolink/commit/467ea8548688a9db6046c98dbfd268ecd297605c))
67
+ - **cli:** honor --model parameter in CLI commands ([467ea85](https://github.com/juspay/neurolink/commit/467ea8548688a9db6046c98dbfd268ecd297605c))
7
68
 
8
69
  # [3.0.0](https://github.com/juspay/neurolink/compare/v2.1.0...v3.0.0) (2025-07-01)
9
70
 
10
-
11
71
  ### Features
12
72
 
13
- * **proxy:** add comprehensive enterprise proxy support across all providers ([9668e67](https://github.com/juspay/neurolink/commit/9668e67dfaa27831ba85d45fdf5b7739de902b28))
14
-
73
+ - **proxy:** add comprehensive enterprise proxy support across all providers ([9668e67](https://github.com/juspay/neurolink/commit/9668e67dfaa27831ba85d45fdf5b7739de902b28))
15
74
 
16
75
  ### BREAKING CHANGES
17
76
 
18
- * **proxy:** None - fully backward compatible
77
+ - **proxy:** None - fully backward compatible
19
78
 
20
79
  Files modified:
80
+
21
81
  - docs/ENTERPRISE-PROXY-SETUP.md (NEW) - Comprehensive enterprise proxy guide
22
82
  - docs/PROVIDER-CONFIGURATION.md - Added proxy configuration section
23
83
  - docs/CLI-GUIDE.md - Added proxy environment variables documentation
package/README.md CHANGED
@@ -1,4 +1,15 @@
1
- # 🧠 NeuroLink
1
+ # @juspay/neurolink
2
+
3
+ <!-- TOC -->
4
+
5
+ - [📄 License](#[object Object])
6
+ - [🔗 Related Projects](#-related-projects)
7
+ <!-- /TOC -->
8
+
9
+ Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 9 major providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.
10
+
11
+ **Version:** 4.0.0
12
+ **License:** MIT
2
13
 
3
14
  [![NPM Version](https://img.shields.io/npm/v/@juspay/neurolink)](https://www.npmjs.com/package/@juspay/neurolink)
4
15
  [![Downloads](https://img.shields.io/npm/dm/@juspay/neurolink)](https://www.npmjs.com/package/@juspay/neurolink)
@@ -7,9 +18,69 @@
7
18
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)](https://www.typescriptlang.org/)
8
19
  [![CI](https://github.com/juspay/neurolink/workflows/CI/badge.svg)](https://github.com/juspay/neurolink/actions)
9
20
 
10
- > Universal AI toolkit with multiple provider support, automatic fallback, and both CLI + SDK interfaces. Production-ready with TypeScript support.
21
+ > Enterprise AI Development Platform with real-time capabilities, advanced telemetry, and universal provider support. Production-ready with TypeScript support.
22
+
23
+ **NeuroLink** is an Enterprise AI Development Platform that unifies 9 major AI providers with intelligent fallback, real-time WebSocket infrastructure, and optional enterprise telemetry. Available as both a **programmatic SDK** and **professional CLI tool**. Extracted from production use at Juspay.
24
+
25
+ ## 🚀 Enterprise Platform Features
26
+
27
+ - **🌐 Real-time WebSocket Infrastructure** - Professional-grade streaming with session management
28
+ - **📊 Advanced Telemetry** - Optional OpenTelemetry monitoring with zero overhead when disabled
29
+ - **💬 Enhanced Chat Services** - Dual-mode SSE + WebSocket support for enterprise applications
30
+ - **🏗️ Enterprise Architecture** - Production-ready scaling with connection pooling and optimization
31
+
32
+ ## 🏗️ Enterprise Configuration Management
33
+
34
+ ### **✨ NEW: Automatic Backup System**
35
+
36
+ ```bash
37
+ # All config changes create automatic backups
38
+ npm run config:update
39
+ # ✅ Backup created: .neurolink.backups/neurolink-config-2025-01-07T10-30-00.js
40
+
41
+ # Auto-restore on failures
42
+ npm run config:validate
43
+ # ✅ Config validated with suggestions and warnings
44
+ ```
45
+
46
+ ### **✨ NEW: Industry-Standard Interfaces**
47
+
48
+ ```typescript
49
+ // Modern camelCase interfaces with rich context
50
+ interface ExecutionContext {
51
+ sessionId?: string;
52
+ userId?: string;
53
+ aiProvider?: string;
54
+ permissions?: string[];
55
+ cacheOptions?: CacheOptions;
56
+ fallbackOptions?: FallbackOptions;
57
+ metadata?: Record<string, unknown>;
58
+ }
59
+
60
+ // Optional methods for maximum flexibility
61
+ interface McpRegistry {
62
+ registerServer?(
63
+ serverId: string,
64
+ config?: unknown,
65
+ context?: ExecutionContext,
66
+ ): Promise<void>;
67
+ executeTool?<T>(
68
+ toolName: string,
69
+ args?: unknown,
70
+ context?: ExecutionContext,
71
+ ): Promise<T>;
72
+ listTools?(context?: ExecutionContext): Promise<ToolInfo[]>;
73
+ }
74
+ ```
75
+
76
+ ### **Enterprise Features**
11
77
 
12
- **NeuroLink** unifies OpenAI, Bedrock, Vertex AI, Google AI Studio, Anthropic, Azure OpenAI, Hugging Face, Ollama, and Mistral AI with intelligent fallback and streaming support. Available as both a **programmatic SDK** and **professional CLI tool**. Extracted from production use at Juspay.
78
+ - **🔄 Automatic Backup/Restore** - Timestamped backups with hash verification
79
+ - **✅ Config Validation** - Comprehensive validation with suggestions
80
+ - **🏗️ Factory-First MCP** - Lighthouse-compatible architecture (99% compatible)
81
+ - **🔧 Type Safety** - Industry-standard TypeScript interfaces
82
+ - **⚡ Performance** - Tool execution <1ms, pipeline execution ~22ms
83
+ - **🛡️ Error Recovery** - Graceful failures with auto-restore
13
84
 
14
85
  ## 🚀 Quick Start
15
86
 
@@ -22,6 +93,12 @@ export GOOGLE_AI_API_KEY="AIza-your-google-ai-api-key"
22
93
  # CLI - No installation required
23
94
  npx @juspay/neurolink generate "Hello, AI"
24
95
  npx @juspay/neurolink gen "Hello, AI" # Shortest form
96
+
97
+ # 🆕 NEW: AI Enhancement Features
98
+ npx @juspay/neurolink generate "Explain AI" --enable-analytics --debug
99
+ npx @juspay/neurolink generate "Write code" --enable-evaluation --debug
100
+ npx @juspay/neurolink generate "Help me" --context '{"userId":"123"}' --debug
101
+
25
102
  npx @juspay/neurolink status
26
103
  ```
27
104
 
@@ -38,14 +115,181 @@ import { createBestAIProvider } from "@juspay/neurolink";
38
115
  // Auto-selects best available provider
39
116
  const provider = createBestAIProvider();
40
117
  const result = await provider.generateText({
41
- prompt: "Write a haiku about programming",
42
- timeout: "30s", // Optional: Set custom timeout (default: 30s)
118
+ prompt: "Write a haiku about programming",
119
+ timeout: "30s", // Optional: Set custom timeout (default: 30s)
43
120
  });
44
121
 
45
122
  console.log(result.text);
46
123
  console.log(`Used: ${result.provider}`);
47
124
  ```
48
125
 
126
+ #### 🔗 CLI-SDK Consistency (NEW! ✨)
127
+
128
+ Method aliases that match CLI command names:
129
+
130
+ ```typescript
131
+ // All three methods are equivalent:
132
+ const result1 = await provider.generateText({ prompt: "Hello" }); // Original
133
+ const result2 = await provider.generate({ prompt: "Hello" }); // Matches CLI 'generate'
134
+ const result3 = await provider.gen({ prompt: "Hello" }); // Matches CLI 'gen'
135
+
136
+ // Use whichever style you prefer:
137
+ const provider = createBestAIProvider();
138
+
139
+ // Detailed method name
140
+ const story = await provider.generateText({
141
+ prompt: "Write a short story about AI",
142
+ maxTokens: 200,
143
+ });
144
+
145
+ // CLI-style method names
146
+ const poem = await provider.generate({ prompt: "Write a poem" });
147
+ const joke = await provider.gen({ prompt: "Tell me a joke" });
148
+ ```
149
+
150
+ ### 🆕 Enhanced Usage (NEW! ✨)
151
+
152
+ #### Enhanced CLI with Analytics & Evaluation
153
+
154
+ ```bash
155
+ # Basic AI generation
156
+ npx @juspay/neurolink generate "Write a business email"
157
+
158
+ # With analytics and evaluation (NEW!)
159
+ npx @juspay/neurolink generate "Write a business email" --enable-analytics --enable-evaluation --debug
160
+
161
+ # See detailed usage data:
162
+ # 📊 Analytics: Provider usage, token costs, response times
163
+ # ⭐ Response Evaluation: AI-powered quality scores
164
+
165
+ # With custom context
166
+ npx @juspay/neurolink generate "Create a proposal" --context '{"company":"TechCorp"}' --debug
167
+ ```
168
+
169
+ #### Enhanced SDK with Analytics & Evaluation
170
+
171
+ ```typescript
172
+ import { NeuroLink } from "@juspay/neurolink";
173
+ const neurolink = new NeuroLink();
174
+
175
+ // Basic usage
176
+ const result = await neurolink.generateText("Write a story");
177
+
178
+ // With enhancements (NEW!)
179
+ const enhancedResult = await neurolink.generateText({
180
+ prompt: "Write a business proposal",
181
+ enableAnalytics: true, // Get usage & cost data
182
+ enableEvaluation: true, // Get AI quality scores
183
+ context: { project: "Q1-sales" }, // Custom context
184
+ });
185
+
186
+ // Access enhancement data
187
+ console.log("📊 Usage:", enhancedResult.analytics);
188
+ console.log("⭐ Quality:", enhancedResult.evaluation);
189
+ console.log("Response:", enhancedResult.content);
190
+
191
+ // 🆕 NEW: Enhanced Evaluation with Domain Awareness
192
+ import {
193
+ performEnhancedEvaluation,
194
+ createEnhancedContext,
195
+ } from "@juspay/neurolink";
196
+
197
+ const enhancedContext = createEnhancedContext(
198
+ "Write a business proposal for Q1 expansion",
199
+ enhancedResult.text,
200
+ {
201
+ domain: "Business development",
202
+ role: "Business proposal assistant",
203
+ toolsUsed: ["generate-text", "analytics-helper"],
204
+ conversationHistory: [
205
+ { role: "user", content: "I need help with our Q1 business plan" },
206
+ {
207
+ role: "assistant",
208
+ content: "I can help you create a comprehensive plan",
209
+ },
210
+ ],
211
+ },
212
+ );
213
+
214
+ const domainEvaluation = await performEnhancedEvaluation(enhancedContext);
215
+ console.log("🎯 Enhanced Evaluation:", domainEvaluation);
216
+ // {
217
+ // relevanceScore: 9, accuracyScore: 8, completenessScore: 9,
218
+ // domainAlignment: 9, terminologyAccuracy: 8, toolEffectiveness: 9,
219
+ // overall: 8.7, alertSeverity: 'none'
220
+ // }
221
+ ```
222
+
223
+ ### 🌐 Enterprise Real-time Features (NEW! 🚀)
224
+
225
+ #### Real-time WebSocket Chat
226
+
227
+ ```typescript
228
+ import {
229
+ createEnhancedChatService,
230
+ NeuroLinkWebSocketServer,
231
+ } from "@juspay/neurolink";
232
+
233
+ // Enhanced chat with WebSocket support
234
+ const chatService = createEnhancedChatService({
235
+ provider: await createBestAIProvider(),
236
+ enableWebSocket: true,
237
+ enableSSE: true,
238
+ streamingConfig: {
239
+ bufferSize: 8192,
240
+ compressionEnabled: true,
241
+ },
242
+ });
243
+
244
+ // WebSocket server for real-time applications
245
+ const wsServer = new NeuroLinkWebSocketServer({
246
+ port: 8080,
247
+ maxConnections: 1000,
248
+ enableCompression: true,
249
+ });
250
+
251
+ // Handle real-time chat
252
+ wsServer.on("chat-message", async ({ connectionId, message }) => {
253
+ await chatService.streamChat({
254
+ prompt: message.data.prompt,
255
+ onChunk: (chunk) => {
256
+ wsServer.sendMessage(connectionId, {
257
+ type: "ai-chunk",
258
+ data: { chunk },
259
+ });
260
+ },
261
+ });
262
+ });
263
+ ```
264
+
265
+ #### Enterprise Telemetry Integration
266
+
267
+ ```typescript
268
+ import { initializeTelemetry, getTelemetryStatus } from "@juspay/neurolink";
269
+
270
+ // Optional enterprise monitoring (zero overhead when disabled)
271
+ const telemetry = initializeTelemetry({
272
+ serviceName: "my-ai-app",
273
+ endpoint: "http://localhost:4318",
274
+ enableTracing: true,
275
+ enableMetrics: true,
276
+ enableLogs: true,
277
+ });
278
+
279
+ // Check telemetry status
280
+ const status = await getTelemetryStatus();
281
+ console.log("Telemetry enabled:", status.enabled);
282
+ console.log("Service:", status.service);
283
+ console.log("Version:", status.version);
284
+
285
+ // All AI operations are now automatically monitored
286
+ const provider = await createBestAIProvider();
287
+ const result = await provider.generateText({
288
+ prompt: "Generate business report",
289
+ });
290
+ // Telemetry automatically tracks: response time, token usage, cost, errors
291
+ ```
292
+
49
293
  ### Environment Setup
50
294
 
51
295
  ```bash
@@ -189,34 +433,34 @@ npx @juspay/neurolink batch prompts.txt --timeout 45s --output results.json
189
433
  ```typescript
190
434
  // SvelteKit API route with timeout handling
191
435
  export const POST: RequestHandler = async ({ request }) => {
192
- const { message } = await request.json();
193
- const provider = createBestAIProvider();
194
-
195
- try {
196
- const result = await provider.streamText({
197
- prompt: message,
198
- timeout: "2m", // 2 minutes for streaming
199
- });
200
- return new Response(result.toReadableStream());
201
- } catch (error) {
202
- if (error.name === "TimeoutError") {
203
- return new Response("Request timed out", { status: 408 });
204
- }
205
- throw error;
206
- }
436
+ const { message } = await request.json();
437
+ const provider = createBestAIProvider();
438
+
439
+ try {
440
+ const result = await provider.streamText({
441
+ prompt: message,
442
+ timeout: "2m", // 2 minutes for streaming
443
+ });
444
+ return new Response(result.toReadableStream());
445
+ } catch (error) {
446
+ if (error.name === "TimeoutError") {
447
+ return new Response("Request timed out", { status: 408 });
448
+ }
449
+ throw error;
450
+ }
207
451
  };
208
452
 
209
453
  // Next.js API route with timeout
210
454
  export async function POST(request: NextRequest) {
211
- const { prompt } = await request.json();
212
- const provider = createBestAIProvider();
455
+ const { prompt } = await request.json();
456
+ const provider = createBestAIProvider();
213
457
 
214
- const result = await provider.generateText({
215
- prompt,
216
- timeout: process.env.AI_TIMEOUT || "30s", // Configurable timeout
217
- });
458
+ const result = await provider.generateText({
459
+ prompt,
460
+ timeout: process.env.AI_TIMEOUT || "30s", // Configurable timeout
461
+ });
218
462
 
219
- return NextResponse.json({ text: result.text });
463
+ return NextResponse.json({ text: result.text });
220
464
  }
221
465
  ```
222
466
 
@@ -303,6 +547,53 @@ cd neurolink-demo && node server.js
303
547
  - **Analysis Tools**: Usage optimization, performance benchmarking, parameter tuning
304
548
  - **Workflow Tools**: Test generation, code refactoring, documentation, debugging
305
549
  - **Extensibility**: Connect external tools and services via MCP protocol
550
+ - **🆕 Dynamic Server Management**: Programmatically add MCP servers at runtime
551
+
552
+ ### 🔧 NEW: Programmatic MCP Server Management
553
+
554
+ **Add external MCP servers dynamically** for enhanced tool ecosystem:
555
+
556
+ ```typescript
557
+ import { NeuroLink } from "@juspay/neurolink";
558
+ const neurolink = new NeuroLink();
559
+
560
+ // Add Bitbucket integration
561
+ await neurolink.addMCPServer("bitbucket", {
562
+ command: "npx",
563
+ args: ["-y", "@nexus2520/bitbucket-mcp-server"],
564
+ env: {
565
+ BITBUCKET_USERNAME: "your-username",
566
+ BITBUCKET_APP_PASSWORD: "your-app-password",
567
+ },
568
+ });
569
+
570
+ // Add custom database connector
571
+ await neurolink.addMCPServer("database", {
572
+ command: "node",
573
+ args: ["./custom-db-mcp-server.js"],
574
+ env: { DB_CONNECTION_STRING: "postgresql://..." },
575
+ });
576
+
577
+ // Add any MCP-compatible server
578
+ await neurolink.addMCPServer("slack-integration", {
579
+ command: "npx",
580
+ args: ["-y", "@slack/mcp-server"],
581
+ env: { SLACK_BOT_TOKEN: "xoxb-..." },
582
+ cwd: "/tmp",
583
+ });
584
+
585
+ // Verify servers are registered
586
+ const status = await neurolink.getMCPStatus();
587
+ console.log("Active servers:", status.totalServers);
588
+ console.log("Available tools:", status.totalTools);
589
+ ```
590
+
591
+ **Perfect for:**
592
+
593
+ - **External Service Integration**: Bitbucket, Slack, Jira, databases
594
+ - **Custom Tool Development**: Your own MCP servers
595
+ - **Dynamic Workflows**: Add servers based on project needs
596
+ - **Enterprise Applications**: Runtime tool ecosystem management
306
597
 
307
598
  ## 🤝 Contributing
308
599
 
@@ -220,8 +220,8 @@ export declare const directAgentTools: {
220
220
  mode: z.ZodDefault<z.ZodEnum<["create", "overwrite", "append"]>>;
221
221
  }, "strip", z.ZodTypeAny, {
222
222
  path: string;
223
- content: string;
224
223
  mode: "create" | "overwrite" | "append";
224
+ content: string;
225
225
  }, {
226
226
  path: string;
227
227
  content: string;
@@ -250,8 +250,8 @@ export declare const directAgentTools: {
250
250
  }> & {
251
251
  execute: (args: {
252
252
  path: string;
253
- content: string;
254
253
  mode: "create" | "overwrite" | "append";
254
+ content: string;
255
255
  }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
256
256
  success: boolean;
257
257
  error: string;
@@ -563,8 +563,8 @@ export declare function getToolsForCategory(category?: "basic" | "filesystem" |
563
563
  mode: z.ZodDefault<z.ZodEnum<["create", "overwrite", "append"]>>;
564
564
  }, "strip", z.ZodTypeAny, {
565
565
  path: string;
566
- content: string;
567
566
  mode: "create" | "overwrite" | "append";
567
+ content: string;
568
568
  }, {
569
569
  path: string;
570
570
  content: string;
@@ -593,8 +593,8 @@ export declare function getToolsForCategory(category?: "basic" | "filesystem" |
593
593
  }> & {
594
594
  execute: (args: {
595
595
  path: string;
596
- content: string;
597
596
  mode: "create" | "overwrite" | "append";
597
+ content: string;
598
598
  }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
599
599
  success: boolean;
600
600
  error: string;
@@ -907,8 +907,8 @@ export declare function getToolsForCategory(category?: "basic" | "filesystem" |
907
907
  mode: z.ZodDefault<z.ZodEnum<["create", "overwrite", "append"]>>;
908
908
  }, "strip", z.ZodTypeAny, {
909
909
  path: string;
910
- content: string;
911
910
  mode: "create" | "overwrite" | "append";
911
+ content: string;
912
912
  }, {
913
913
  path: string;
914
914
  content: string;
@@ -937,8 +937,8 @@ export declare function getToolsForCategory(category?: "basic" | "filesystem" |
937
937
  }> & {
938
938
  execute: (args: {
939
939
  path: string;
940
- content: string;
941
940
  mode: "create" | "overwrite" | "append";
941
+ content: string;
942
942
  }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
943
943
  success: boolean;
944
944
  error: string;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Phase 3: SSE Chat Utilities
3
+ * Client-side utilities for SSE chat integration
4
+ */
5
+ import type { ChatMessage } from "./types.js";
6
+ export interface ChatClientOptions {
7
+ endpoint: string;
8
+ sessionId: string;
9
+ onMessage?: (message: ChatMessage) => void;
10
+ onError?: (error: Error) => void;
11
+ onConnect?: () => void;
12
+ onDisconnect?: () => void;
13
+ reconnectAttempts?: number;
14
+ reconnectDelay?: number;
15
+ }
16
+ export interface ChatStreamHook {
17
+ messages: ChatMessage[];
18
+ isConnected: boolean;
19
+ isReconnecting: boolean;
20
+ sendMessage: (content: string) => Promise<void>;
21
+ disconnect: () => void;
22
+ reconnect: () => void;
23
+ clearHistory: () => void;
24
+ }
25
+ /**
26
+ * Client for SSE chat communication
27
+ */
28
+ export declare class ChatClient {
29
+ private eventSource?;
30
+ private options;
31
+ private messages;
32
+ private reconnectCount;
33
+ private isConnected;
34
+ private isReconnecting;
35
+ private reconnectTimeout?;
36
+ constructor(options: ChatClientOptions);
37
+ /**
38
+ * Connect to SSE endpoint
39
+ */
40
+ connect(): void;
41
+ /**
42
+ * Send message to chat
43
+ */
44
+ sendMessage(content: string): Promise<void>;
45
+ /**
46
+ * Disconnect from SSE endpoint
47
+ */
48
+ disconnect(): void;
49
+ /**
50
+ * Get message history
51
+ */
52
+ getMessages(): ChatMessage[];
53
+ /**
54
+ * Clear message history
55
+ */
56
+ clearMessages(): void;
57
+ /**
58
+ * Check connection status
59
+ */
60
+ getConnectionStatus(): {
61
+ connected: boolean;
62
+ reconnecting: boolean;
63
+ reconnectCount: number;
64
+ };
65
+ private handleSSEEvent;
66
+ private handleDataEvent;
67
+ private handleErrorEvent;
68
+ private handleCompleteEvent;
69
+ private scheduleReconnect;
70
+ }
71
+ /**
72
+ * Create chat client instance
73
+ */
74
+ export declare function createChatClient(options: ChatClientOptions): ChatClient;
75
+ /**
76
+ * React-style hook for chat streaming (can be adapted for other frameworks)
77
+ */
78
+ export declare function useChatStream(options: ChatClientOptions): ChatStreamHook;
79
+ /**
80
+ * Utility for creating SSE EventSource with automatic reconnection
81
+ */
82
+ export declare function createSSEConnection(url: string, options?: {
83
+ onMessage?: (event: MessageEvent) => void;
84
+ onError?: (error: Error) => void;
85
+ onOpen?: () => void;
86
+ reconnect?: boolean;
87
+ maxReconnectAttempts?: number;
88
+ }): {
89
+ connect: () => void;
90
+ disconnect: () => void;
91
+ isConnected: () => boolean;
92
+ };