@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.
- package/CHANGELOG.md +62 -4
- package/README.md +235 -2
- package/dist/agent/direct-tools.d.ts +6 -6
- package/dist/chat/client-utils.d.ts +92 -0
- package/dist/chat/client-utils.js +298 -0
- package/dist/chat/index.d.ts +27 -0
- package/dist/chat/index.js +41 -0
- package/dist/chat/session-storage.d.ts +77 -0
- package/dist/chat/session-storage.js +233 -0
- package/dist/chat/session.d.ts +95 -0
- package/dist/chat/session.js +257 -0
- package/dist/chat/sse-handler.d.ts +49 -0
- package/dist/chat/sse-handler.js +266 -0
- package/dist/chat/types.d.ts +73 -0
- package/dist/chat/types.js +5 -0
- package/dist/chat/websocket-chat-handler.d.ts +36 -0
- package/dist/chat/websocket-chat-handler.js +262 -0
- package/dist/cli/commands/config.js +12 -12
- package/dist/cli/commands/mcp.js +3 -4
- package/dist/cli/index.d.ts +0 -7
- package/dist/cli/index.js +256 -27
- package/dist/config/configManager.d.ts +60 -0
- package/dist/config/configManager.js +300 -0
- package/dist/config/types.d.ts +136 -0
- package/dist/config/types.js +43 -0
- package/dist/core/analytics.d.ts +23 -0
- package/dist/core/analytics.js +131 -0
- package/dist/core/constants.d.ts +41 -0
- package/dist/core/constants.js +50 -0
- package/dist/core/defaults.d.ts +18 -0
- package/dist/core/defaults.js +29 -0
- package/dist/core/evaluation-config.d.ts +29 -0
- package/dist/core/evaluation-config.js +144 -0
- package/dist/core/evaluation-providers.d.ts +30 -0
- package/dist/core/evaluation-providers.js +187 -0
- package/dist/core/evaluation.d.ts +117 -0
- package/dist/core/evaluation.js +528 -0
- package/dist/core/factory.js +33 -25
- package/dist/core/types.d.ts +165 -6
- package/dist/core/types.js +3 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +25 -4
- package/dist/lib/agent/direct-tools.d.ts +6 -6
- package/dist/lib/chat/client-utils.d.ts +92 -0
- package/dist/lib/chat/client-utils.js +298 -0
- package/dist/lib/chat/index.d.ts +27 -0
- package/dist/lib/chat/index.js +41 -0
- package/dist/lib/chat/session-storage.d.ts +77 -0
- package/dist/lib/chat/session-storage.js +233 -0
- package/dist/lib/chat/session.d.ts +95 -0
- package/dist/lib/chat/session.js +257 -0
- package/dist/lib/chat/sse-handler.d.ts +49 -0
- package/dist/lib/chat/sse-handler.js +266 -0
- package/dist/lib/chat/types.d.ts +73 -0
- package/dist/lib/chat/types.js +5 -0
- package/dist/lib/chat/websocket-chat-handler.d.ts +36 -0
- package/dist/lib/chat/websocket-chat-handler.js +262 -0
- package/dist/lib/config/configManager.d.ts +60 -0
- package/dist/lib/config/configManager.js +300 -0
- package/dist/lib/config/types.d.ts +136 -0
- package/dist/lib/config/types.js +43 -0
- package/dist/lib/core/analytics.d.ts +23 -0
- package/dist/lib/core/analytics.js +131 -0
- package/dist/lib/core/constants.d.ts +41 -0
- package/dist/lib/core/constants.js +50 -0
- package/dist/lib/core/defaults.d.ts +18 -0
- package/dist/lib/core/defaults.js +29 -0
- package/dist/lib/core/evaluation-config.d.ts +29 -0
- package/dist/lib/core/evaluation-config.js +144 -0
- package/dist/lib/core/evaluation-providers.d.ts +30 -0
- package/dist/lib/core/evaluation-providers.js +187 -0
- package/dist/lib/core/evaluation.d.ts +117 -0
- package/dist/lib/core/evaluation.js +528 -0
- package/dist/lib/core/factory.js +33 -26
- package/dist/lib/core/types.d.ts +165 -6
- package/dist/lib/core/types.js +3 -4
- package/dist/lib/index.d.ts +9 -4
- package/dist/lib/index.js +25 -4
- package/dist/lib/mcp/contracts/mcpContract.d.ts +118 -0
- package/dist/lib/mcp/contracts/mcpContract.js +5 -0
- package/dist/lib/mcp/function-calling.js +11 -3
- package/dist/lib/mcp/logging.js +5 -0
- package/dist/lib/mcp/neurolink-mcp-client.js +2 -1
- package/dist/lib/mcp/orchestrator.js +18 -9
- package/dist/lib/mcp/registry.d.ts +49 -16
- package/dist/lib/mcp/registry.js +80 -6
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +5 -4
- package/dist/lib/mcp/tool-integration.js +1 -1
- package/dist/lib/mcp/tool-registry.d.ts +55 -34
- package/dist/lib/mcp/tool-registry.js +111 -97
- package/dist/lib/mcp/unified-mcp.js +6 -1
- package/dist/lib/mcp/unified-registry.d.ts +12 -4
- package/dist/lib/mcp/unified-registry.js +17 -4
- package/dist/lib/neurolink.d.ts +28 -0
- package/dist/lib/neurolink.js +48 -4
- package/dist/lib/providers/agent-enhanced-provider.d.ts +11 -2
- package/dist/lib/providers/agent-enhanced-provider.js +86 -15
- package/dist/lib/providers/amazonBedrock.d.ts +9 -1
- package/dist/lib/providers/amazonBedrock.js +26 -2
- package/dist/lib/providers/analytics-helper.d.ts +53 -0
- package/dist/lib/providers/analytics-helper.js +151 -0
- package/dist/lib/providers/anthropic.d.ts +11 -1
- package/dist/lib/providers/anthropic.js +29 -4
- package/dist/lib/providers/azureOpenAI.d.ts +3 -1
- package/dist/lib/providers/azureOpenAI.js +28 -4
- package/dist/lib/providers/function-calling-provider.d.ts +9 -1
- package/dist/lib/providers/function-calling-provider.js +14 -1
- package/dist/lib/providers/googleAIStudio.d.ts +15 -1
- package/dist/lib/providers/googleAIStudio.js +32 -2
- package/dist/lib/providers/googleVertexAI.d.ts +9 -1
- package/dist/lib/providers/googleVertexAI.js +31 -2
- package/dist/lib/providers/huggingFace.d.ts +3 -1
- package/dist/lib/providers/huggingFace.js +26 -3
- package/dist/lib/providers/mcp-provider.d.ts +9 -1
- package/dist/lib/providers/mcp-provider.js +12 -0
- package/dist/lib/providers/mistralAI.d.ts +3 -1
- package/dist/lib/providers/mistralAI.js +25 -2
- package/dist/lib/providers/ollama.d.ts +3 -1
- package/dist/lib/providers/ollama.js +27 -4
- package/dist/lib/providers/openAI.d.ts +15 -1
- package/dist/lib/providers/openAI.js +32 -2
- package/dist/lib/proxy/proxy-fetch.js +8 -7
- package/dist/lib/services/streaming/streaming-manager.d.ts +29 -0
- package/dist/lib/services/streaming/streaming-manager.js +244 -0
- package/dist/lib/services/types.d.ts +155 -0
- package/dist/lib/services/types.js +2 -0
- package/dist/lib/services/websocket/websocket-server.d.ts +34 -0
- package/dist/lib/services/websocket/websocket-server.js +304 -0
- package/dist/lib/telemetry/index.d.ts +15 -0
- package/dist/lib/telemetry/index.js +22 -0
- package/dist/lib/telemetry/telemetry-service.d.ts +47 -0
- package/dist/lib/telemetry/telemetry-service.js +259 -0
- package/dist/lib/utils/streaming-utils.d.ts +67 -0
- package/dist/lib/utils/streaming-utils.js +201 -0
- package/dist/mcp/contracts/mcpContract.d.ts +118 -0
- package/dist/mcp/contracts/mcpContract.js +5 -0
- package/dist/mcp/function-calling.js +11 -3
- package/dist/mcp/logging.js +5 -0
- package/dist/mcp/neurolink-mcp-client.js +2 -1
- package/dist/mcp/orchestrator.js +18 -9
- package/dist/mcp/registry.d.ts +49 -16
- package/dist/mcp/registry.js +80 -6
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +5 -4
- package/dist/mcp/tool-integration.js +1 -1
- package/dist/mcp/tool-registry.d.ts +55 -34
- package/dist/mcp/tool-registry.js +111 -97
- package/dist/mcp/unified-mcp.js +6 -1
- package/dist/mcp/unified-registry.d.ts +12 -4
- package/dist/mcp/unified-registry.js +17 -4
- package/dist/neurolink.d.ts +28 -0
- package/dist/neurolink.js +48 -4
- package/dist/providers/agent-enhanced-provider.d.ts +11 -2
- package/dist/providers/agent-enhanced-provider.js +86 -15
- package/dist/providers/amazonBedrock.d.ts +9 -1
- package/dist/providers/amazonBedrock.js +26 -2
- package/dist/providers/analytics-helper.d.ts +53 -0
- package/dist/providers/analytics-helper.js +151 -0
- package/dist/providers/anthropic.d.ts +11 -1
- package/dist/providers/anthropic.js +29 -4
- package/dist/providers/azureOpenAI.d.ts +3 -1
- package/dist/providers/azureOpenAI.js +29 -4
- package/dist/providers/function-calling-provider.d.ts +9 -1
- package/dist/providers/function-calling-provider.js +14 -1
- package/dist/providers/googleAIStudio.d.ts +15 -1
- package/dist/providers/googleAIStudio.js +32 -2
- package/dist/providers/googleVertexAI.d.ts +9 -1
- package/dist/providers/googleVertexAI.js +31 -2
- package/dist/providers/huggingFace.d.ts +3 -1
- package/dist/providers/huggingFace.js +26 -3
- package/dist/providers/mcp-provider.d.ts +9 -1
- package/dist/providers/mcp-provider.js +12 -0
- package/dist/providers/mistralAI.d.ts +3 -1
- package/dist/providers/mistralAI.js +25 -2
- package/dist/providers/ollama.d.ts +3 -1
- package/dist/providers/ollama.js +27 -4
- package/dist/providers/openAI.d.ts +15 -1
- package/dist/providers/openAI.js +33 -2
- package/dist/proxy/proxy-fetch.js +8 -7
- package/dist/services/streaming/streaming-manager.d.ts +29 -0
- package/dist/services/streaming/streaming-manager.js +244 -0
- package/dist/services/types.d.ts +155 -0
- package/dist/services/types.js +2 -0
- package/dist/services/websocket/websocket-server.d.ts +34 -0
- package/dist/services/websocket/websocket-server.js +304 -0
- package/dist/telemetry/index.d.ts +15 -0
- package/dist/telemetry/index.js +22 -0
- package/dist/telemetry/telemetry-service.d.ts +47 -0
- package/dist/telemetry/telemetry-service.js +261 -0
- package/dist/utils/streaming-utils.d.ts +67 -0
- package/dist/utils/streaming-utils.js +201 -0
- package/package.json +18 -2
package/dist/core/types.d.ts
CHANGED
|
@@ -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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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<
|
|
103
|
-
generateText(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<
|
|
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
|
package/dist/core/types.js
CHANGED
|
@@ -47,10 +47,9 @@ export var VertexModels;
|
|
|
47
47
|
*/
|
|
48
48
|
export var GoogleAIModels;
|
|
49
49
|
(function (GoogleAIModels) {
|
|
50
|
-
GoogleAIModels["
|
|
51
|
-
GoogleAIModels["
|
|
52
|
-
GoogleAIModels["
|
|
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
|
package/dist/index.d.ts
CHANGED
|
@@ -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/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
|
+
}
|
|
@@ -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
|
+
};
|