@juspay/neurolink 3.0.0 → 4.0.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 (192) hide show
  1. package/CHANGELOG.md +62 -4
  2. package/README.md +235 -2
  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 +256 -27
  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/function-calling.js +11 -3
  82. package/dist/lib/mcp/logging.js +5 -0
  83. package/dist/lib/mcp/neurolink-mcp-client.js +2 -1
  84. package/dist/lib/mcp/orchestrator.js +18 -9
  85. package/dist/lib/mcp/registry.d.ts +49 -16
  86. package/dist/lib/mcp/registry.js +80 -6
  87. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +5 -4
  88. package/dist/lib/mcp/tool-integration.js +1 -1
  89. package/dist/lib/mcp/tool-registry.d.ts +55 -34
  90. package/dist/lib/mcp/tool-registry.js +111 -97
  91. package/dist/lib/mcp/unified-mcp.js +6 -1
  92. package/dist/lib/mcp/unified-registry.d.ts +12 -4
  93. package/dist/lib/mcp/unified-registry.js +17 -4
  94. package/dist/lib/neurolink.d.ts +28 -0
  95. package/dist/lib/neurolink.js +48 -4
  96. package/dist/lib/providers/agent-enhanced-provider.d.ts +11 -2
  97. package/dist/lib/providers/agent-enhanced-provider.js +86 -15
  98. package/dist/lib/providers/amazonBedrock.d.ts +9 -1
  99. package/dist/lib/providers/amazonBedrock.js +26 -2
  100. package/dist/lib/providers/analytics-helper.d.ts +53 -0
  101. package/dist/lib/providers/analytics-helper.js +151 -0
  102. package/dist/lib/providers/anthropic.d.ts +11 -1
  103. package/dist/lib/providers/anthropic.js +29 -4
  104. package/dist/lib/providers/azureOpenAI.d.ts +3 -1
  105. package/dist/lib/providers/azureOpenAI.js +28 -4
  106. package/dist/lib/providers/function-calling-provider.d.ts +9 -1
  107. package/dist/lib/providers/function-calling-provider.js +14 -1
  108. package/dist/lib/providers/googleAIStudio.d.ts +15 -1
  109. package/dist/lib/providers/googleAIStudio.js +32 -2
  110. package/dist/lib/providers/googleVertexAI.d.ts +9 -1
  111. package/dist/lib/providers/googleVertexAI.js +31 -2
  112. package/dist/lib/providers/huggingFace.d.ts +3 -1
  113. package/dist/lib/providers/huggingFace.js +26 -3
  114. package/dist/lib/providers/mcp-provider.d.ts +9 -1
  115. package/dist/lib/providers/mcp-provider.js +12 -0
  116. package/dist/lib/providers/mistralAI.d.ts +3 -1
  117. package/dist/lib/providers/mistralAI.js +25 -2
  118. package/dist/lib/providers/ollama.d.ts +3 -1
  119. package/dist/lib/providers/ollama.js +27 -4
  120. package/dist/lib/providers/openAI.d.ts +15 -1
  121. package/dist/lib/providers/openAI.js +32 -2
  122. package/dist/lib/proxy/proxy-fetch.js +8 -7
  123. package/dist/lib/services/streaming/streaming-manager.d.ts +29 -0
  124. package/dist/lib/services/streaming/streaming-manager.js +244 -0
  125. package/dist/lib/services/types.d.ts +155 -0
  126. package/dist/lib/services/types.js +2 -0
  127. package/dist/lib/services/websocket/websocket-server.d.ts +34 -0
  128. package/dist/lib/services/websocket/websocket-server.js +304 -0
  129. package/dist/lib/telemetry/index.d.ts +15 -0
  130. package/dist/lib/telemetry/index.js +22 -0
  131. package/dist/lib/telemetry/telemetry-service.d.ts +47 -0
  132. package/dist/lib/telemetry/telemetry-service.js +259 -0
  133. package/dist/lib/utils/streaming-utils.d.ts +67 -0
  134. package/dist/lib/utils/streaming-utils.js +201 -0
  135. package/dist/mcp/contracts/mcpContract.d.ts +118 -0
  136. package/dist/mcp/contracts/mcpContract.js +5 -0
  137. package/dist/mcp/function-calling.js +11 -3
  138. package/dist/mcp/logging.js +5 -0
  139. package/dist/mcp/neurolink-mcp-client.js +2 -1
  140. package/dist/mcp/orchestrator.js +18 -9
  141. package/dist/mcp/registry.d.ts +49 -16
  142. package/dist/mcp/registry.js +80 -6
  143. package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
  144. package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +5 -4
  145. package/dist/mcp/tool-integration.js +1 -1
  146. package/dist/mcp/tool-registry.d.ts +55 -34
  147. package/dist/mcp/tool-registry.js +111 -97
  148. package/dist/mcp/unified-mcp.js +6 -1
  149. package/dist/mcp/unified-registry.d.ts +12 -4
  150. package/dist/mcp/unified-registry.js +17 -4
  151. package/dist/neurolink.d.ts +28 -0
  152. package/dist/neurolink.js +48 -4
  153. package/dist/providers/agent-enhanced-provider.d.ts +11 -2
  154. package/dist/providers/agent-enhanced-provider.js +86 -15
  155. package/dist/providers/amazonBedrock.d.ts +9 -1
  156. package/dist/providers/amazonBedrock.js +26 -2
  157. package/dist/providers/analytics-helper.d.ts +53 -0
  158. package/dist/providers/analytics-helper.js +151 -0
  159. package/dist/providers/anthropic.d.ts +11 -1
  160. package/dist/providers/anthropic.js +29 -4
  161. package/dist/providers/azureOpenAI.d.ts +3 -1
  162. package/dist/providers/azureOpenAI.js +29 -4
  163. package/dist/providers/function-calling-provider.d.ts +9 -1
  164. package/dist/providers/function-calling-provider.js +14 -1
  165. package/dist/providers/googleAIStudio.d.ts +15 -1
  166. package/dist/providers/googleAIStudio.js +32 -2
  167. package/dist/providers/googleVertexAI.d.ts +9 -1
  168. package/dist/providers/googleVertexAI.js +31 -2
  169. package/dist/providers/huggingFace.d.ts +3 -1
  170. package/dist/providers/huggingFace.js +26 -3
  171. package/dist/providers/mcp-provider.d.ts +9 -1
  172. package/dist/providers/mcp-provider.js +12 -0
  173. package/dist/providers/mistralAI.d.ts +3 -1
  174. package/dist/providers/mistralAI.js +25 -2
  175. package/dist/providers/ollama.d.ts +3 -1
  176. package/dist/providers/ollama.js +27 -4
  177. package/dist/providers/openAI.d.ts +15 -1
  178. package/dist/providers/openAI.js +33 -2
  179. package/dist/proxy/proxy-fetch.js +8 -7
  180. package/dist/services/streaming/streaming-manager.d.ts +29 -0
  181. package/dist/services/streaming/streaming-manager.js +244 -0
  182. package/dist/services/types.d.ts +155 -0
  183. package/dist/services/types.js +2 -0
  184. package/dist/services/websocket/websocket-server.d.ts +34 -0
  185. package/dist/services/websocket/websocket-server.js +304 -0
  186. package/dist/telemetry/index.d.ts +15 -0
  187. package/dist/telemetry/index.js +22 -0
  188. package/dist/telemetry/telemetry-service.d.ts +47 -0
  189. package/dist/telemetry/telemetry-service.js +261 -0
  190. package/dist/utils/streaming-utils.d.ts +67 -0
  191. package/dist/utils/streaming-utils.js +201 -0
  192. package/package.json +18 -2
@@ -44,10 +44,9 @@ export declare enum VertexModels {
44
44
  * Supported Models for Google AI Studio
45
45
  */
46
46
  export declare enum GoogleAIModels {
47
- GEMINI_1_5_PRO_LATEST = "gemini-1.5-pro-latest",
48
- GEMINI_1_5_FLASH_LATEST = "gemini-1.5-flash-latest",
49
- GEMINI_2_0_FLASH_EXP = "gemini-2.0-flash-exp",
50
- GEMINI_1_0_PRO = "gemini-1.0-pro"
47
+ GEMINI_2_5_PRO = "gemini-2.5-pro",
48
+ GEMINI_2_5_FLASH = "gemini-2.5-flash",
49
+ GEMINI_1_5_FLASH_LITE = "gemini-2.5-flash-lite"
51
50
  }
52
51
  /**
53
52
  * Union type of all supported model names
@@ -81,6 +80,15 @@ export interface TextGenerationOptions {
81
80
  schema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>;
82
81
  tools?: Record<string, Tool>;
83
82
  timeout?: number | string;
83
+ enableEvaluation?: boolean;
84
+ enableAnalytics?: boolean;
85
+ context?: Record<string, any>;
86
+ evaluationDomain?: string;
87
+ toolUsageContext?: string;
88
+ conversationHistory?: Array<{
89
+ role: string;
90
+ content: string;
91
+ }>;
84
92
  }
85
93
  /**
86
94
  * Stream text options interface
@@ -94,13 +102,164 @@ export interface StreamTextOptions {
94
102
  schema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>;
95
103
  tools?: Record<string, Tool>;
96
104
  timeout?: number | string;
105
+ enableEvaluation?: boolean;
106
+ enableAnalytics?: boolean;
107
+ context?: Record<string, any>;
108
+ evaluationDomain?: string;
109
+ toolUsageContext?: string;
110
+ conversationHistory?: Array<{
111
+ role: string;
112
+ content: string;
113
+ }>;
114
+ }
115
+ /**
116
+ * Analytics data for usage tracking
117
+ */
118
+ export interface AnalyticsData {
119
+ provider: string;
120
+ model: string;
121
+ tokens: {
122
+ input: number;
123
+ output: number;
124
+ total: number;
125
+ };
126
+ cost?: number;
127
+ responseTime: number;
128
+ timestamp: string;
129
+ context?: Record<string, any>;
130
+ }
131
+ /**
132
+ * Response quality evaluation scores (Lighthouse-Compatible Schema)
133
+ * Updated to match Lighthouse's exact evaluation interface for consistency
134
+ */
135
+ export interface EvaluationData {
136
+ relevanceScore: number;
137
+ accuracyScore: number;
138
+ completenessScore: number;
139
+ overall: number;
140
+ isOffTopic: boolean;
141
+ alertSeverity: "low" | "medium" | "high" | "none";
142
+ reasoning: string;
143
+ suggestedImprovements?: string;
144
+ evaluationModel: string;
145
+ evaluationTime: number;
146
+ evaluationProvider?: string;
147
+ evaluationAttempt?: number;
148
+ evaluationConfig?: {
149
+ mode: string;
150
+ fallbackUsed: boolean;
151
+ costEstimate: number;
152
+ };
153
+ }
154
+ /**
155
+ * BACKWARD COMPATIBILITY: Legacy evaluation interface
156
+ * Maintains existing field names for backward compatibility
157
+ */
158
+ export interface LegacyEvaluationData {
159
+ relevance: number;
160
+ accuracy: number;
161
+ completeness: number;
162
+ overall: number;
163
+ isOffTopic: boolean;
164
+ alertSeverity: "low" | "medium" | "high" | "none";
165
+ reasoning: string;
166
+ suggestedImprovements?: string;
167
+ evaluationModel: string;
168
+ evaluationTime: number;
169
+ }
170
+ /**
171
+ * Evaluation system configuration for multi-provider support
172
+ */
173
+ export interface EvaluationConfig {
174
+ provider: string;
175
+ model: string;
176
+ mode: "fast" | "balanced" | "quality";
177
+ fallbackEnabled: boolean;
178
+ fallbackProviders: string[];
179
+ timeout: number;
180
+ maxTokens: number;
181
+ temperature: number;
182
+ preferCheap: boolean;
183
+ maxCostPerEval: number;
184
+ retryAttempts: number;
185
+ }
186
+ /**
187
+ * Provider model configuration for evaluation
188
+ */
189
+ export interface ProviderModelConfig {
190
+ provider: string;
191
+ models: {
192
+ fast: string;
193
+ balanced: string;
194
+ quality: string;
195
+ };
196
+ costPerToken: {
197
+ input: number;
198
+ output: number;
199
+ };
200
+ requiresApiKey: string[];
201
+ performance: {
202
+ speed: number;
203
+ quality: number;
204
+ cost: number;
205
+ };
206
+ }
207
+ /**
208
+ * Enhanced result interfaces with optional analytics/evaluation
209
+ */
210
+ export interface EnhancedGenerateTextResult extends GenerateTextResult<ToolSet, unknown> {
211
+ analytics?: AnalyticsData;
212
+ evaluation?: EvaluationData;
213
+ }
214
+ export interface EnhancedStreamTextResult extends StreamTextResult<ToolSet, unknown> {
215
+ analytics?: AnalyticsData;
216
+ evaluation?: EvaluationData;
217
+ }
218
+ /**
219
+ * Phase 2: Enhanced Streaming Infrastructure
220
+ * Progress tracking and metadata for streaming operations
221
+ */
222
+ export interface StreamingProgressData {
223
+ chunkCount: number;
224
+ totalBytes: number;
225
+ chunkSize: number;
226
+ elapsedTime: number;
227
+ estimatedRemaining?: number;
228
+ streamId?: string;
229
+ phase: "initializing" | "streaming" | "processing" | "complete" | "error";
230
+ }
231
+ export interface StreamingMetadata {
232
+ startTime: number;
233
+ endTime?: number;
234
+ totalDuration?: number;
235
+ averageChunkSize: number;
236
+ maxChunkSize: number;
237
+ minChunkSize: number;
238
+ throughputBytesPerSecond?: number;
239
+ streamingProvider: string;
240
+ modelUsed: string;
241
+ }
242
+ export type ProgressCallback = (progress: StreamingProgressData) => void;
243
+ export interface EnhancedStreamTextOptions extends StreamTextOptions {
244
+ enableProgressTracking?: boolean;
245
+ progressCallback?: ProgressCallback;
246
+ includeStreamingMetadata?: boolean;
247
+ streamingBufferSize?: number;
248
+ enableStreamingHeaders?: boolean;
249
+ customStreamingConfig?: {
250
+ chunkDelayMs?: number;
251
+ maxConcurrentChunks?: number;
252
+ compressionEnabled?: boolean;
253
+ };
97
254
  }
98
255
  /**
99
256
  * AI Provider interface with flexible parameter support
100
257
  */
101
258
  export interface AIProvider {
102
- streamText(optionsOrPrompt: StreamTextOptions | string, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamTextResult<ToolSet, unknown> | null>;
103
- generateText(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<GenerateTextResult<ToolSet, unknown> | null>;
259
+ streamText(optionsOrPrompt: StreamTextOptions | string, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<EnhancedStreamTextResult | null>;
260
+ generateText(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<EnhancedGenerateTextResult | null>;
261
+ generate(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<EnhancedGenerateTextResult | null>;
262
+ gen(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<EnhancedGenerateTextResult | null>;
104
263
  }
105
264
  /**
106
265
  * Provider attempt result for iteration tracking
@@ -47,10 +47,9 @@ export var VertexModels;
47
47
  */
48
48
  export var GoogleAIModels;
49
49
  (function (GoogleAIModels) {
50
- GoogleAIModels["GEMINI_1_5_PRO_LATEST"] = "gemini-1.5-pro-latest";
51
- GoogleAIModels["GEMINI_1_5_FLASH_LATEST"] = "gemini-1.5-flash-latest";
52
- GoogleAIModels["GEMINI_2_0_FLASH_EXP"] = "gemini-2.0-flash-exp";
53
- GoogleAIModels["GEMINI_1_0_PRO"] = "gemini-1.0-pro";
50
+ GoogleAIModels["GEMINI_2_5_PRO"] = "gemini-2.5-pro";
51
+ GoogleAIModels["GEMINI_2_5_FLASH"] = "gemini-2.5-flash";
52
+ GoogleAIModels["GEMINI_1_5_FLASH_LITE"] = "gemini-2.5-flash-lite";
54
53
  })(GoogleAIModels || (GoogleAIModels = {}));
55
54
  /**
56
55
  * Default provider configurations
@@ -22,7 +22,7 @@ export declare const VERSION = "1.0.0";
22
22
  *
23
23
  * @example
24
24
  * ```typescript
25
- * import { createAIProvider } from 'neurolink';
25
+ * import { createAIProvider } from '@juspay/neurolink';
26
26
  *
27
27
  * const provider = await createAIProvider('bedrock');
28
28
  * const result = await provider.streamText('Hello, AI!');
@@ -34,7 +34,7 @@ export declare function createAIProvider(providerName?: string, modelName?: stri
34
34
  *
35
35
  * @example
36
36
  * ```typescript
37
- * import { createAIProviderWithFallback } from 'neurolink';
37
+ * import { createAIProviderWithFallback } from '@juspay/neurolink';
38
38
  *
39
39
  * const { primary, fallback } = await createAIProviderWithFallback('bedrock', 'vertex');
40
40
  * ```
@@ -48,7 +48,7 @@ export declare function createAIProviderWithFallback(primaryProvider?: string, f
48
48
  *
49
49
  * @example
50
50
  * ```typescript
51
- * import { createBestAIProvider } from 'neurolink';
51
+ * import { createBestAIProvider } from '@juspay/neurolink';
52
52
  *
53
53
  * const provider = await createBestAIProvider();
54
54
  * ```
@@ -62,7 +62,7 @@ export declare function createBestAIProvider(requestedProvider?: string, modelNa
62
62
  *
63
63
  * @example
64
64
  * ```typescript
65
- * import { mcpEcosystem, readFile, writeFile } from 'neurolink';
65
+ * import { mcpEcosystem, readFile, writeFile } from '@juspay/neurolink';
66
66
  *
67
67
  * // Initialize the ecosystem
68
68
  * await mcpEcosystem.initialize();
@@ -77,3 +77,8 @@ export declare function createBestAIProvider(requestedProvider?: string, modelNa
77
77
  */
78
78
  export { MCPEcosystem, mcpEcosystem, initializeMCPEcosystem, PluginManager, pluginManager, listMCPs, executeMCP, getMCPStats, readFile, writeFile, listFiles, createDirectory, MCP, SecurityManager, mcpLogger, FileSystemMCP, } from "./mcp/index.js";
79
79
  export type { MCPMetadata, ExecutionContext, MCPConstructor, MCPInstance, DiscoveredMCP, LogLevel, } from "./mcp/index.js";
80
+ export declare function initializeTelemetry(): Promise<boolean>;
81
+ export declare function getTelemetryStatus(): {
82
+ enabled: boolean;
83
+ initialized: boolean;
84
+ };
package/dist/lib/index.js CHANGED
@@ -25,7 +25,7 @@ export const VERSION = "1.0.0";
25
25
  *
26
26
  * @example
27
27
  * ```typescript
28
- * import { createAIProvider } from 'neurolink';
28
+ * import { createAIProvider } from '@juspay/neurolink';
29
29
  *
30
30
  * const provider = await createAIProvider('bedrock');
31
31
  * const result = await provider.streamText('Hello, AI!');
@@ -39,7 +39,7 @@ export async function createAIProvider(providerName, modelName) {
39
39
  *
40
40
  * @example
41
41
  * ```typescript
42
- * import { createAIProviderWithFallback } from 'neurolink';
42
+ * import { createAIProviderWithFallback } from '@juspay/neurolink';
43
43
  *
44
44
  * const { primary, fallback } = await createAIProviderWithFallback('bedrock', 'vertex');
45
45
  * ```
@@ -52,7 +52,7 @@ export async function createAIProviderWithFallback(primaryProvider, fallbackProv
52
52
  *
53
53
  * @example
54
54
  * ```typescript
55
- * import { createBestAIProvider } from 'neurolink';
55
+ * import { createBestAIProvider } from '@juspay/neurolink';
56
56
  *
57
57
  * const provider = await createBestAIProvider();
58
58
  * ```
@@ -71,7 +71,7 @@ export async function createBestAIProvider(requestedProvider, modelName) {
71
71
  *
72
72
  * @example
73
73
  * ```typescript
74
- * import { mcpEcosystem, readFile, writeFile } from 'neurolink';
74
+ * import { mcpEcosystem, readFile, writeFile } from '@juspay/neurolink';
75
75
  *
76
76
  * // Initialize the ecosystem
77
77
  * await mcpEcosystem.initialize();
@@ -95,3 +95,24 @@ readFile, writeFile, listFiles, createDirectory,
95
95
  MCP, SecurityManager, mcpLogger,
96
96
  // Core plugins
97
97
  FileSystemMCP, } from "./mcp/index.js";
98
+ // ============================================================================
99
+ // REAL-TIME SERVICES & TELEMETRY - Enterprise Platform Features
100
+ // ============================================================================
101
+ // Real-time Services (Phase 1) - Basic SSE functionality only
102
+ // export { createEnhancedChatService } from './chat/index.js';
103
+ // export type * from './services/types.js';
104
+ // Optional Telemetry (Phase 2) - Conditional export based on feature flag
105
+ export async function initializeTelemetry() {
106
+ if (process.env.NEUROLINK_TELEMETRY_ENABLED === "true") {
107
+ const { initializeTelemetry: init } = await import("./telemetry/index.js");
108
+ const result = await init();
109
+ return !!result; // Convert TelemetryService to boolean
110
+ }
111
+ return Promise.resolve(false);
112
+ }
113
+ export function getTelemetryStatus() {
114
+ if (process.env.NEUROLINK_TELEMETRY_ENABLED === "true") {
115
+ return { enabled: true, initialized: false };
116
+ }
117
+ return { enabled: false, initialized: false };
118
+ }
@@ -0,0 +1,118 @@
1
+ /**
2
+ * MCP Contract - Core Type Definitions
3
+ * Industry standard camelCase interfaces for maximum flexibility
4
+ */
5
+ /**
6
+ * Generic execution context for MCP operations
7
+ * All properties optional for maximum flexibility
8
+ */
9
+ export interface ExecutionContext<T = Record<string, unknown>> {
10
+ sessionId?: string;
11
+ userId?: string;
12
+ config?: T;
13
+ metadata?: Record<string, unknown>;
14
+ cacheOptions?: CacheOptions;
15
+ fallbackOptions?: FallbackOptions;
16
+ timeoutMs?: number;
17
+ startTime?: number;
18
+ }
19
+ /**
20
+ * Cache configuration options
21
+ */
22
+ export interface CacheOptions {
23
+ enabled?: boolean;
24
+ ttlMs?: number;
25
+ strategy?: "memory" | "writeThrough" | "cacheAside";
26
+ }
27
+ /**
28
+ * Fallback configuration options
29
+ */
30
+ export interface FallbackOptions {
31
+ enabled?: boolean;
32
+ maxAttempts?: number;
33
+ delayMs?: number;
34
+ circuitBreaker?: boolean;
35
+ }
36
+ /**
37
+ * Tool information with extensibility
38
+ */
39
+ export interface ToolInfo {
40
+ name: string;
41
+ description?: string;
42
+ category?: string;
43
+ serverId?: string;
44
+ inputSchema?: Record<string, unknown>;
45
+ outputSchema?: Record<string, unknown>;
46
+ [key: string]: unknown;
47
+ }
48
+ /**
49
+ * Discovered MCP server/plugin definition
50
+ */
51
+ export interface DiscoveredMcp<TTools = Record<string, unknown>> {
52
+ metadata: McpMetadata;
53
+ tools?: TTools;
54
+ capabilities?: string[];
55
+ version?: string;
56
+ configuration?: Record<string, string | number | boolean>;
57
+ [key: string]: unknown;
58
+ }
59
+ /**
60
+ * MCP server metadata
61
+ */
62
+ export interface McpMetadata {
63
+ name: string;
64
+ description?: string;
65
+ version?: string;
66
+ author?: string;
67
+ homepage?: string;
68
+ repository?: string;
69
+ }
70
+ /**
71
+ * Tool definition schema
72
+ */
73
+ export interface ToolDefinition {
74
+ description?: string;
75
+ inputSchema?: Record<string, unknown>;
76
+ outputSchema?: Record<string, unknown>;
77
+ category?: string;
78
+ examples?: Array<{
79
+ input: Record<string, unknown>;
80
+ output: Record<string, unknown>;
81
+ description?: string;
82
+ }>;
83
+ }
84
+ /**
85
+ * Tool execution result
86
+ */
87
+ export interface ToolExecutionResult<T = unknown> {
88
+ result: T;
89
+ context?: ExecutionContext;
90
+ performance?: {
91
+ duration: number;
92
+ tokensUsed?: number;
93
+ cost?: number;
94
+ };
95
+ validation?: ValidationResult;
96
+ cached?: boolean;
97
+ fallback?: boolean;
98
+ }
99
+ /**
100
+ * Validation result for runtime checks
101
+ */
102
+ export interface ValidationResult {
103
+ valid: boolean;
104
+ missing: string[];
105
+ warnings: string[];
106
+ recommendations: string[];
107
+ }
108
+ /**
109
+ * Provider status information
110
+ */
111
+ export interface ProviderStatus {
112
+ available: boolean;
113
+ lastCheck: number;
114
+ reason?: string;
115
+ model?: string;
116
+ cost?: number;
117
+ latencyMs?: number;
118
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * MCP Contract - Core Type Definitions
3
+ * Industry standard camelCase interfaces for maximum flexibility
4
+ */
5
+ export {};
@@ -156,7 +156,10 @@ export async function getAvailableFunctionTools() {
156
156
  let functionName;
157
157
  let originalFunctionName;
158
158
  // Convert server name to underscore format to check if it's embedded in tool name
159
- const sanitizedServerCheck = (toolInfo.server || "unknown").replace(/[^a-zA-Z0-9_]/g, "_");
159
+ const serverName = typeof toolInfo.serverId === "string"
160
+ ? toolInfo.serverId
161
+ : "unknown";
162
+ const sanitizedServerCheck = serverName.replace(/[^a-zA-Z0-9_]/g, "_");
160
163
  if (toolInfo.name.includes(sanitizedServerCheck) ||
161
164
  toolInfo.name.endsWith("-tools") ||
162
165
  toolInfo.name.startsWith("github_com_") ||
@@ -206,7 +209,10 @@ export async function getAvailableFunctionTools() {
206
209
  }
207
210
  else {
208
211
  // Tool name doesn't include server info, create compound name
209
- const sanitizedServerName = (toolInfo.server || "unknown").replace(/[^a-zA-Z0-9_]/g, "_");
212
+ const serverName = typeof toolInfo.serverId === "string"
213
+ ? toolInfo.serverId
214
+ : "unknown";
215
+ const sanitizedServerName = serverName.replace(/[^a-zA-Z0-9_]/g, "_");
210
216
  const sanitizedToolName = toolInfo.name.replace(/[^a-zA-Z0-9_]/g, "_");
211
217
  // Check if it's a filesystem tool from MCP
212
218
  if (sanitizedServerName.includes("modelcontextprotocol") &&
@@ -277,7 +283,9 @@ export async function getAvailableFunctionTools() {
277
283
  tools.push(aiTool);
278
284
  // Store mapping for execution - CRITICAL: Use sanitized functionName as key
279
285
  toolMap.set(functionName, {
280
- serverId: toolInfo.server || "unknown",
286
+ serverId: typeof toolInfo.serverId === "string"
287
+ ? toolInfo.serverId
288
+ : "unknown",
281
289
  toolName: toolInfo.name,
282
290
  });
283
291
  mcpLogger.debug(`[${functionTag}] Converted tool: ${functionName} (original: ${originalFunctionName})`);
@@ -17,6 +17,11 @@ class MCPLogger {
17
17
  this.logLevel = level;
18
18
  }
19
19
  shouldLog(level) {
20
+ // CRITICAL: Respect CLI debug flag - hide all logs except errors unless debugging
21
+ const isDebugMode = process.argv.includes("--debug");
22
+ if (!isDebugMode && level !== "error") {
23
+ return false;
24
+ }
20
25
  const levels = ["debug", "info", "warn", "error"];
21
26
  return levels.indexOf(level) >= levels.indexOf(this.logLevel);
22
27
  }
@@ -6,6 +6,7 @@
6
6
  import { EventEmitter } from "events";
7
7
  import { logger } from "../utils/logger.js";
8
8
  import { v4 as uuidv4 } from "uuid";
9
+ import { DEFAULT_MAX_TOKENS } from "../core/constants.js";
9
10
  /**
10
11
  * NeuroLink MCP Client with Automatic Tool Detection
11
12
  */
@@ -381,7 +382,7 @@ Please provide a natural response based on the tool results.`;
381
382
  const response = await this.provider.generateText({
382
383
  prompt: enhancedPrompt,
383
384
  temperature: 0.7,
384
- maxTokens: 1000,
385
+ maxTokens: DEFAULT_MAX_TOKENS,
385
386
  });
386
387
  return response?.text || toolResultsText;
387
388
  }
@@ -26,7 +26,10 @@ export class MCPOrchestrator {
26
26
  async initializeDefaultServers() {
27
27
  try {
28
28
  await this.registry.registerServer(aiCoreServer.id, aiCoreServer);
29
- console.log("[Orchestrator] Initialized with AI Core Server");
29
+ // Only log in debug mode
30
+ if (process.env.NEUROLINK_DEBUG === "true") {
31
+ console.log("[Orchestrator] Initialized with AI Core Server");
32
+ }
30
33
  }
31
34
  catch (error) {
32
35
  console.warn("[Orchestrator] Failed to register AI Core Server:", error);
@@ -44,10 +47,14 @@ export class MCPOrchestrator {
44
47
  async executeTool(toolName, params, contextRequest = {}, options = {}) {
45
48
  // Create execution context
46
49
  const context = this.contextManager.createContext(contextRequest);
47
- console.log(`[Orchestrator] Executing tool '${toolName}' in session ${context.sessionId}`);
50
+ if (process.env.NEUROLINK_DEBUG === "true") {
51
+ console.log(`[Orchestrator] Executing tool '${toolName}' in session ${context.sessionId}`);
52
+ }
48
53
  // Execute tool through registry
49
54
  const result = await this.registry.executeTool(toolName, params, context);
50
- console.log(`[Orchestrator] Tool '${toolName}' execution ${result.success ? "completed" : "failed"}`);
55
+ if (process.env.NEUROLINK_DEBUG === "true") {
56
+ console.log(`[Orchestrator] Tool '${toolName}' execution ${result.success ? "completed" : "failed"}`);
57
+ }
51
58
  return result;
52
59
  }
53
60
  /**
@@ -92,9 +99,10 @@ export class MCPOrchestrator {
92
99
  results.set(stepId, stepResult);
93
100
  stepsExecuted++;
94
101
  if (!stepResult.success) {
95
- const errorMessage = stepResult.error instanceof Error
96
- ? stepResult.error.message
97
- : stepResult.error || "Unknown error";
102
+ const error = stepResult.error;
103
+ const errorMessage = error instanceof Error
104
+ ? error.message
105
+ : String(error) || "Unknown error";
98
106
  errors.set(stepId, errorMessage);
99
107
  if (stopOnError) {
100
108
  console.error(`[Orchestrator] Pipeline ${pipelineId} stopped due to error in step ${stepId}`);
@@ -301,9 +309,10 @@ export class MCPOrchestrator {
301
309
  const result = await this.registry.executeTool(step.toolName, step.params, context);
302
310
  results.set(stepId, result);
303
311
  if (!result.success) {
304
- const errorMessage = result.error instanceof Error
305
- ? result.error.message
306
- : result.error || "Unknown error";
312
+ const error = result.error;
313
+ const errorMessage = error instanceof Error
314
+ ? error.message
315
+ : String(error) || "Unknown error";
307
316
  errors.set(stepId, errorMessage);
308
317
  }
309
318
  }
@@ -1,16 +1,25 @@
1
1
  /**
2
- * MCP Registry - Plugin Registration and Management
2
+ * MCP Registry - Industry Standard Interface with camelCase
3
3
  */
4
- import type { DiscoveredMCP } from "./contracts/mcp-contract.js";
4
+ import type { DiscoveredMcp, ExecutionContext, ToolInfo } from "./contracts/mcpContract.js";
5
+ /**
6
+ * MCP Registry interface with optional methods for maximum flexibility
7
+ */
8
+ export interface McpRegistry {
9
+ registerServer?(serverId: string, serverConfig?: unknown, context?: ExecutionContext): Promise<void>;
10
+ executeTool?<T = unknown>(toolName: string, args?: unknown, context?: ExecutionContext): Promise<T>;
11
+ listTools?(context?: ExecutionContext): Promise<ToolInfo[]>;
12
+ }
5
13
  /**
6
14
  * Simple MCP registry for plugin management
15
+ * Maintains backward compatibility with existing code
7
16
  */
8
- export declare class MCPRegistry {
17
+ export declare class MCPRegistry implements McpRegistry {
9
18
  private plugins;
10
19
  /**
11
20
  * Register a plugin
12
21
  */
13
- register(plugin: DiscoveredMCP): void;
22
+ register(plugin: DiscoveredMcp): void;
14
23
  /**
15
24
  * Unregister a plugin
16
25
  */
@@ -18,11 +27,11 @@ export declare class MCPRegistry {
18
27
  /**
19
28
  * Get a plugin
20
29
  */
21
- get(name: string): DiscoveredMCP | undefined;
30
+ get(name: string): DiscoveredMcp | undefined;
22
31
  /**
23
32
  * List all plugins
24
33
  */
25
- list(): DiscoveredMCP[];
34
+ list(): DiscoveredMcp[];
26
35
  /**
27
36
  * Check if plugin exists
28
37
  */
@@ -31,17 +40,41 @@ export declare class MCPRegistry {
31
40
  * Clear all plugins
32
41
  */
33
42
  clear(): void;
43
+ /**
44
+ * Register a server (compatible with new interface)
45
+ */
46
+ registerServer(serverId: string, serverConfig?: unknown, context?: ExecutionContext): Promise<void>;
47
+ /**
48
+ * Execute a tool (mock implementation for tests)
49
+ */
50
+ executeTool<T = unknown>(toolName: string, args?: unknown, context?: ExecutionContext): Promise<T>;
51
+ /**
52
+ * List all tools (compatible with new interface)
53
+ */
54
+ listTools(context?: ExecutionContext): Promise<ToolInfo[]>;
55
+ /**
56
+ * Register a server (legacy sync version)
57
+ */
58
+ registerServerSync(plugin: DiscoveredMcp): void;
59
+ /**
60
+ * Execute a tool (legacy sync version)
61
+ */
62
+ executeToolSync(toolName: string, args?: unknown): any;
63
+ /**
64
+ * List all tools (legacy sync version)
65
+ */
66
+ listToolsSync(): Array<{
67
+ name: string;
68
+ description?: string;
69
+ }>;
34
70
  }
35
71
  /**
36
- * Default registry instance
72
+ * Enhanced MCP Registry implementation with config integration
73
+ * Will be implemented in Phase 3.2
37
74
  */
38
- export declare const mcpRegistry: MCPRegistry;
39
- export type MCPToolRegistry = MCPRegistry;
40
- export declare const defaultToolRegistry: MCPRegistry;
41
- export { mcpRegistry as defaultMCPRegistry };
42
- export interface ToolExecutionOptions {
43
- preferredSource?: string;
44
- fallbackEnabled?: boolean;
45
- validateBeforeExecution?: boolean;
46
- timeoutMs?: number;
75
+ export declare class McpRegistryImpl implements McpRegistry {
76
+ private baseRegistry;
77
+ registerServer(serverId: string, serverConfig?: unknown, context?: ExecutionContext): Promise<void>;
78
+ executeTool<T = unknown>(toolName: string, args?: unknown, context?: ExecutionContext): Promise<T>;
79
+ listTools(context?: ExecutionContext): Promise<ToolInfo[]>;
47
80
  }