@juspay/neurolink 7.29.2 → 7.29.3
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 +6 -0
- package/dist/cli/commands/config.d.ts +83 -83
- package/dist/cli/commands/mcp.js +39 -9
- package/dist/cli/commands/models.js +25 -21
- package/dist/cli/commands/ollama.js +2 -2
- package/dist/cli/factories/commandFactory.d.ts +8 -0
- package/dist/cli/factories/commandFactory.js +65 -65
- package/dist/cli/factories/ollamaCommandFactory.js +3 -1
- package/dist/cli/factories/sagemakerCommandFactory.js +3 -2
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +11 -11
- package/dist/cli/utils/envManager.js +5 -5
- package/dist/cli/utils/ollamaUtils.d.ts +12 -0
- package/dist/cli/utils/ollamaUtils.js +58 -42
- package/dist/config/configManager.js +5 -2
- package/dist/core/analytics.d.ts +2 -24
- package/dist/core/analytics.js +12 -17
- package/dist/core/baseProvider.d.ts +30 -1
- package/dist/core/baseProvider.js +180 -198
- package/dist/core/dynamicModels.d.ts +4 -4
- package/dist/core/dynamicModels.js +7 -7
- package/dist/core/evaluation.d.ts +9 -9
- package/dist/core/evaluation.js +117 -65
- package/dist/core/evaluationProviders.d.ts +18 -2
- package/dist/core/evaluationProviders.js +15 -13
- package/dist/core/modelConfiguration.d.ts +63 -0
- package/dist/core/modelConfiguration.js +354 -290
- package/dist/core/streamAnalytics.d.ts +10 -5
- package/dist/core/streamAnalytics.js +10 -10
- package/dist/core/types.d.ts +19 -109
- package/dist/core/types.js +13 -0
- package/dist/factories/providerFactory.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/lib/config/configManager.js +5 -2
- package/dist/lib/core/analytics.d.ts +2 -24
- package/dist/lib/core/analytics.js +12 -17
- package/dist/lib/core/baseProvider.d.ts +30 -1
- package/dist/lib/core/baseProvider.js +180 -198
- package/dist/lib/core/dynamicModels.js +7 -7
- package/dist/lib/core/evaluation.d.ts +9 -9
- package/dist/lib/core/evaluation.js +117 -65
- package/dist/lib/core/evaluationProviders.d.ts +18 -2
- package/dist/lib/core/evaluationProviders.js +15 -13
- package/dist/lib/core/modelConfiguration.d.ts +63 -0
- package/dist/lib/core/modelConfiguration.js +354 -290
- package/dist/lib/core/streamAnalytics.d.ts +10 -5
- package/dist/lib/core/streamAnalytics.js +10 -10
- package/dist/lib/core/types.d.ts +19 -109
- package/dist/lib/core/types.js +13 -0
- package/dist/lib/factories/providerFactory.js +1 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/mcp/externalServerManager.js +15 -6
- package/dist/lib/mcp/factory.js +1 -1
- package/dist/lib/mcp/index.d.ts +1 -1
- package/dist/lib/mcp/index.js +1 -1
- package/dist/lib/mcp/mcpCircuitBreaker.js +5 -1
- package/dist/lib/mcp/mcpClientFactory.js +3 -0
- package/dist/lib/mcp/registry.d.ts +3 -3
- package/dist/lib/mcp/registry.js +3 -3
- package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +5 -5
- package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +6 -6
- package/dist/lib/mcp/servers/utilities/utilityServer.js +1 -1
- package/dist/lib/mcp/toolDiscoveryService.js +8 -2
- package/dist/lib/mcp/toolRegistry.js +4 -4
- package/dist/lib/middleware/builtin/analytics.js +4 -4
- package/dist/lib/middleware/builtin/guardrails.js +2 -2
- package/dist/lib/middleware/registry.js +11 -2
- package/dist/lib/models/modelRegistry.d.ts +1 -1
- package/dist/lib/models/modelRegistry.js +3 -3
- package/dist/lib/models/modelResolver.d.ts +1 -1
- package/dist/lib/models/modelResolver.js +2 -2
- package/dist/lib/neurolink.d.ts +116 -0
- package/dist/lib/neurolink.js +716 -922
- package/dist/lib/providers/amazonSagemaker.d.ts +1 -1
- package/dist/lib/providers/amazonSagemaker.js +12 -3
- package/dist/lib/providers/anthropic.d.ts +1 -1
- package/dist/lib/providers/anthropic.js +7 -6
- package/dist/lib/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/lib/providers/anthropicBaseProvider.js +4 -3
- package/dist/lib/providers/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/azureOpenai.js +1 -1
- package/dist/lib/providers/googleAiStudio.d.ts +1 -1
- package/dist/lib/providers/googleAiStudio.js +2 -2
- package/dist/lib/providers/googleVertex.d.ts +40 -0
- package/dist/lib/providers/googleVertex.js +330 -274
- package/dist/lib/providers/huggingFace.js +1 -1
- package/dist/lib/providers/mistral.d.ts +1 -1
- package/dist/lib/providers/mistral.js +2 -2
- package/dist/lib/providers/ollama.d.ts +4 -0
- package/dist/lib/providers/ollama.js +38 -18
- package/dist/lib/providers/openAI.d.ts +1 -1
- package/dist/lib/providers/openAI.js +2 -2
- package/dist/lib/providers/sagemaker/adaptive-semaphore.js +7 -4
- package/dist/lib/providers/sagemaker/client.js +13 -3
- package/dist/lib/providers/sagemaker/config.js +5 -1
- package/dist/lib/providers/sagemaker/detection.js +19 -9
- package/dist/lib/providers/sagemaker/errors.d.ts +8 -1
- package/dist/lib/providers/sagemaker/errors.js +103 -20
- package/dist/lib/providers/sagemaker/language-model.d.ts +3 -3
- package/dist/lib/providers/sagemaker/language-model.js +4 -4
- package/dist/lib/providers/sagemaker/parsers.js +14 -6
- package/dist/lib/providers/sagemaker/streaming.js +14 -3
- package/dist/lib/providers/sagemaker/types.d.ts +1 -1
- package/dist/lib/proxy/awsProxyIntegration.js +1 -1
- package/dist/lib/sdk/toolRegistration.d.ts +1 -1
- package/dist/lib/types/cli.d.ts +80 -8
- package/dist/lib/types/contextTypes.js +2 -2
- package/dist/lib/types/generateTypes.d.ts +4 -6
- package/dist/lib/types/providers.d.ts +81 -19
- package/dist/lib/types/providers.js +6 -6
- package/dist/lib/types/streamTypes.d.ts +4 -6
- package/dist/lib/types/typeAliases.d.ts +1 -1
- package/dist/lib/utils/analyticsUtils.d.ts +33 -0
- package/dist/lib/utils/analyticsUtils.js +76 -0
- package/dist/lib/utils/errorHandling.js +4 -1
- package/dist/lib/utils/evaluationUtils.d.ts +27 -0
- package/dist/lib/utils/evaluationUtils.js +131 -0
- package/dist/lib/utils/optionsUtils.js +10 -1
- package/dist/lib/utils/performance.d.ts +1 -1
- package/dist/lib/utils/performance.js +15 -3
- package/dist/lib/utils/providerHealth.d.ts +48 -0
- package/dist/lib/utils/providerHealth.js +199 -254
- package/dist/lib/utils/providerUtils.js +2 -2
- package/dist/lib/utils/timeout.js +8 -3
- package/dist/mcp/externalServerManager.js +15 -6
- package/dist/mcp/factory.js +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/mcpCircuitBreaker.js +5 -1
- package/dist/mcp/mcpClientFactory.js +3 -0
- package/dist/mcp/registry.d.ts +3 -3
- package/dist/mcp/registry.js +3 -3
- package/dist/mcp/servers/aiProviders/aiAnalysisTools.js +5 -5
- package/dist/mcp/servers/aiProviders/aiWorkflowTools.js +6 -6
- package/dist/mcp/servers/utilities/utilityServer.js +1 -1
- package/dist/mcp/toolDiscoveryService.js +8 -2
- package/dist/mcp/toolRegistry.js +4 -4
- package/dist/middleware/builtin/analytics.js +4 -4
- package/dist/middleware/builtin/guardrails.js +2 -2
- package/dist/middleware/registry.js +11 -2
- package/dist/models/modelRegistry.d.ts +1 -1
- package/dist/models/modelRegistry.js +3 -3
- package/dist/models/modelResolver.d.ts +1 -1
- package/dist/models/modelResolver.js +2 -2
- package/dist/neurolink.d.ts +116 -0
- package/dist/neurolink.js +716 -922
- package/dist/providers/amazonSagemaker.d.ts +1 -1
- package/dist/providers/amazonSagemaker.js +12 -3
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +7 -6
- package/dist/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/providers/anthropicBaseProvider.js +4 -3
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/azureOpenai.js +1 -1
- package/dist/providers/googleAiStudio.d.ts +1 -1
- package/dist/providers/googleAiStudio.js +2 -2
- package/dist/providers/googleVertex.d.ts +40 -0
- package/dist/providers/googleVertex.js +330 -274
- package/dist/providers/huggingFace.js +1 -1
- package/dist/providers/mistral.d.ts +1 -1
- package/dist/providers/mistral.js +2 -2
- package/dist/providers/ollama.d.ts +4 -0
- package/dist/providers/ollama.js +38 -18
- package/dist/providers/openAI.d.ts +1 -1
- package/dist/providers/openAI.js +2 -2
- package/dist/providers/sagemaker/adaptive-semaphore.js +7 -4
- package/dist/providers/sagemaker/client.js +13 -3
- package/dist/providers/sagemaker/config.js +5 -1
- package/dist/providers/sagemaker/detection.js +19 -9
- package/dist/providers/sagemaker/errors.d.ts +8 -1
- package/dist/providers/sagemaker/errors.js +103 -20
- package/dist/providers/sagemaker/language-model.d.ts +3 -3
- package/dist/providers/sagemaker/language-model.js +4 -4
- package/dist/providers/sagemaker/parsers.js +14 -6
- package/dist/providers/sagemaker/streaming.js +14 -3
- package/dist/providers/sagemaker/types.d.ts +1 -1
- package/dist/proxy/awsProxyIntegration.js +1 -1
- package/dist/sdk/toolRegistration.d.ts +1 -1
- package/dist/types/cli.d.ts +80 -8
- package/dist/types/contextTypes.js +2 -2
- package/dist/types/generateTypes.d.ts +4 -6
- package/dist/types/providers.d.ts +81 -19
- package/dist/types/providers.js +6 -6
- package/dist/types/streamTypes.d.ts +4 -6
- package/dist/types/typeAliases.d.ts +1 -1
- package/dist/utils/analyticsUtils.d.ts +33 -0
- package/dist/utils/analyticsUtils.js +76 -0
- package/dist/utils/errorHandling.js +4 -1
- package/dist/utils/evaluationUtils.d.ts +27 -0
- package/dist/utils/evaluationUtils.js +131 -0
- package/dist/utils/optionsUtils.js +10 -1
- package/dist/utils/performance.d.ts +1 -1
- package/dist/utils/performance.js +15 -3
- package/dist/utils/providerHealth.d.ts +48 -0
- package/dist/utils/providerHealth.js +199 -254
- package/dist/utils/providerUtils.js +2 -2
- package/dist/utils/timeout.js +8 -3
- package/package.json +1 -1
|
@@ -135,9 +135,9 @@ export class MiddlewareRegistry {
|
|
|
135
135
|
/**
|
|
136
136
|
* Configure middleware with runtime configuration
|
|
137
137
|
*/
|
|
138
|
-
configureMiddleware(middleware, config, globalConfig,
|
|
138
|
+
configureMiddleware(middleware, config, globalConfig, _context) {
|
|
139
139
|
// Merge configurations: global < middleware config < runtime config
|
|
140
|
-
const
|
|
140
|
+
const _mergedConfig = {
|
|
141
141
|
...globalConfig,
|
|
142
142
|
...config?.config,
|
|
143
143
|
};
|
|
@@ -149,6 +149,9 @@ export class MiddlewareRegistry {
|
|
|
149
149
|
wrappedMiddleware.transformParams = async (args) => {
|
|
150
150
|
const startTime = Date.now();
|
|
151
151
|
try {
|
|
152
|
+
if (!middleware.transformParams) {
|
|
153
|
+
throw new Error("transformParams method is required");
|
|
154
|
+
}
|
|
152
155
|
const result = await middleware.transformParams(args);
|
|
153
156
|
this.recordExecution(middleware.metadata.id, startTime, true);
|
|
154
157
|
return result;
|
|
@@ -163,6 +166,9 @@ export class MiddlewareRegistry {
|
|
|
163
166
|
wrappedMiddleware.wrapGenerate = async (args) => {
|
|
164
167
|
const startTime = Date.now();
|
|
165
168
|
try {
|
|
169
|
+
if (!middleware.wrapGenerate) {
|
|
170
|
+
throw new Error("wrapGenerate method is required");
|
|
171
|
+
}
|
|
166
172
|
const result = await middleware.wrapGenerate(args);
|
|
167
173
|
this.recordExecution(middleware.metadata.id, startTime, true);
|
|
168
174
|
return result;
|
|
@@ -177,6 +183,9 @@ export class MiddlewareRegistry {
|
|
|
177
183
|
wrappedMiddleware.wrapStream = async (args) => {
|
|
178
184
|
const startTime = Date.now();
|
|
179
185
|
try {
|
|
186
|
+
if (!middleware.wrapStream) {
|
|
187
|
+
throw new Error("wrapStream method is required");
|
|
188
|
+
}
|
|
180
189
|
const result = await middleware.wrapStream(args);
|
|
181
190
|
this.recordExecution(middleware.metadata.id, startTime, true);
|
|
182
191
|
return result;
|
|
@@ -125,7 +125,7 @@ export declare function getAvailableProviders(): AIProviderName[];
|
|
|
125
125
|
/**
|
|
126
126
|
* Calculate estimated cost for a request
|
|
127
127
|
*/
|
|
128
|
-
export declare function calculateCost(model: ModelInfo,
|
|
128
|
+
export declare function calculateCost(model: ModelInfo, input: number, output: number): number;
|
|
129
129
|
/**
|
|
130
130
|
* Format model for display
|
|
131
131
|
*/
|
|
@@ -445,9 +445,9 @@ export function getAvailableProviders() {
|
|
|
445
445
|
/**
|
|
446
446
|
* Calculate estimated cost for a request
|
|
447
447
|
*/
|
|
448
|
-
export function calculateCost(model,
|
|
449
|
-
const inputCost = (
|
|
450
|
-
const outputCost = (
|
|
448
|
+
export function calculateCost(model, input, output) {
|
|
449
|
+
const inputCost = (input / 1000) * model.pricing.inputCostPer1K;
|
|
450
|
+
const outputCost = (output / 1000) * model.pricing.outputCostPer1K;
|
|
451
451
|
return inputCost + outputCost;
|
|
452
452
|
}
|
|
453
453
|
/**
|
|
@@ -76,7 +76,7 @@ export declare class ModelResolver {
|
|
|
76
76
|
/**
|
|
77
77
|
* Calculate cost comparison for models
|
|
78
78
|
*/
|
|
79
|
-
static calculateCostComparison(models: ModelInfo[],
|
|
79
|
+
static calculateCostComparison(models: ModelInfo[], input?: number, output?: number): Array<{
|
|
80
80
|
model: ModelInfo;
|
|
81
81
|
cost: number;
|
|
82
82
|
costPer1K: number;
|
|
@@ -160,11 +160,11 @@ export class ModelResolver {
|
|
|
160
160
|
/**
|
|
161
161
|
* Calculate cost comparison for models
|
|
162
162
|
*/
|
|
163
|
-
static calculateCostComparison(models,
|
|
163
|
+
static calculateCostComparison(models, input = 1000, output = 500) {
|
|
164
164
|
return models
|
|
165
165
|
.map((model) => ({
|
|
166
166
|
model,
|
|
167
|
-
cost: calculateCost(model,
|
|
167
|
+
cost: calculateCost(model, input, output),
|
|
168
168
|
costPer1K: model.pricing.inputCostPer1K + model.pricing.outputCostPer1K,
|
|
169
169
|
}))
|
|
170
170
|
.sort((a, b) => a.cost - b.cost);
|
package/dist/lib/neurolink.d.ts
CHANGED
|
@@ -90,11 +90,71 @@ export declare class NeuroLink {
|
|
|
90
90
|
constructor(config?: {
|
|
91
91
|
conversationMemory?: Partial<ConversationMemoryConfig>;
|
|
92
92
|
});
|
|
93
|
+
/**
|
|
94
|
+
* Log constructor start with comprehensive environment analysis
|
|
95
|
+
*/
|
|
96
|
+
private logConstructorStart;
|
|
97
|
+
/**
|
|
98
|
+
* Initialize provider registry with security settings
|
|
99
|
+
*/
|
|
100
|
+
private initializeProviderRegistry;
|
|
101
|
+
/**
|
|
102
|
+
* Initialize conversation memory if enabled
|
|
103
|
+
*/
|
|
104
|
+
private initializeConversationMemory;
|
|
105
|
+
/**
|
|
106
|
+
* Initialize external server manager with event handlers
|
|
107
|
+
*/
|
|
108
|
+
private initializeExternalServerManager;
|
|
109
|
+
/**
|
|
110
|
+
* Setup event handlers for external server manager
|
|
111
|
+
*/
|
|
112
|
+
private setupExternalServerEventHandlers;
|
|
113
|
+
/**
|
|
114
|
+
* Log constructor completion with final state summary
|
|
115
|
+
*/
|
|
116
|
+
private logConstructorComplete;
|
|
93
117
|
/**
|
|
94
118
|
* Initialize MCP registry with enhanced error handling and resource cleanup
|
|
95
119
|
* Uses isolated async context to prevent hanging
|
|
96
120
|
*/
|
|
97
121
|
private initializeMCP;
|
|
122
|
+
/**
|
|
123
|
+
* Log MCP initialization start
|
|
124
|
+
*/
|
|
125
|
+
private logMCPInitStart;
|
|
126
|
+
/**
|
|
127
|
+
* Log MCP already initialized
|
|
128
|
+
*/
|
|
129
|
+
private logMCPAlreadyInitialized;
|
|
130
|
+
/**
|
|
131
|
+
* Import performance manager with error handling
|
|
132
|
+
*/
|
|
133
|
+
private importPerformanceManager;
|
|
134
|
+
/**
|
|
135
|
+
* Perform main MCP initialization logic
|
|
136
|
+
*/
|
|
137
|
+
private performMCPInitialization;
|
|
138
|
+
/**
|
|
139
|
+
* Initialize tool registry with timeout protection
|
|
140
|
+
*/
|
|
141
|
+
private initializeToolRegistryInternal;
|
|
142
|
+
/**
|
|
143
|
+
* Initialize provider registry
|
|
144
|
+
*/
|
|
145
|
+
private initializeProviderRegistryInternal;
|
|
146
|
+
/**
|
|
147
|
+
* Register direct tools server
|
|
148
|
+
*/
|
|
149
|
+
private registerDirectToolsServerInternal;
|
|
150
|
+
/**
|
|
151
|
+
* Load MCP configuration from .mcp-config.json
|
|
152
|
+
*/
|
|
153
|
+
private loadMCPConfigurationInternal;
|
|
154
|
+
/**
|
|
155
|
+
* Log MCP initialization completion
|
|
156
|
+
*/
|
|
157
|
+
private logMCPInitComplete;
|
|
98
158
|
/**
|
|
99
159
|
* MAIN ENTRY POINT: Enhanced generate method with new function signature
|
|
100
160
|
* Replaces both generateText and legacy methods
|
|
@@ -179,6 +239,26 @@ export declare class NeuroLink {
|
|
|
179
239
|
* 5. Store conversation turn for future context
|
|
180
240
|
*/
|
|
181
241
|
private generateTextInternal;
|
|
242
|
+
/**
|
|
243
|
+
* Log generateTextInternal start with comprehensive analysis
|
|
244
|
+
*/
|
|
245
|
+
private logGenerateTextInternalStart;
|
|
246
|
+
/**
|
|
247
|
+
* Emit generation start events
|
|
248
|
+
*/
|
|
249
|
+
private emitGenerationStartEvents;
|
|
250
|
+
/**
|
|
251
|
+
* Initialize conversation memory for generation
|
|
252
|
+
*/
|
|
253
|
+
private initializeConversationMemoryForGeneration;
|
|
254
|
+
/**
|
|
255
|
+
* Attempt MCP generation with retry logic
|
|
256
|
+
*/
|
|
257
|
+
private attemptMCPGeneration;
|
|
258
|
+
/**
|
|
259
|
+
* Perform MCP generation with retry logic
|
|
260
|
+
*/
|
|
261
|
+
private performMCPGenerationRetries;
|
|
182
262
|
/**
|
|
183
263
|
* Try MCP-enhanced generation (no fallback recursion)
|
|
184
264
|
*/
|
|
@@ -257,6 +337,42 @@ export declare class NeuroLink {
|
|
|
257
337
|
* @throws {Error} When conversation memory operations fail (if enabled)
|
|
258
338
|
*/
|
|
259
339
|
stream(options: StreamOptions): Promise<StreamResult>;
|
|
340
|
+
/**
|
|
341
|
+
* Log stream entry point with comprehensive analysis
|
|
342
|
+
*/
|
|
343
|
+
private logStreamEntryPoint;
|
|
344
|
+
/**
|
|
345
|
+
* Log performance baseline
|
|
346
|
+
*/
|
|
347
|
+
private logPerformanceBaseline;
|
|
348
|
+
/**
|
|
349
|
+
* Validate stream input with comprehensive error reporting
|
|
350
|
+
*/
|
|
351
|
+
private validateStreamInput;
|
|
352
|
+
/**
|
|
353
|
+
* Emit stream start events
|
|
354
|
+
*/
|
|
355
|
+
private emitStreamStartEvents;
|
|
356
|
+
/**
|
|
357
|
+
* Create MCP stream
|
|
358
|
+
*/
|
|
359
|
+
private createMCPStream;
|
|
360
|
+
/**
|
|
361
|
+
* Process stream result
|
|
362
|
+
*/
|
|
363
|
+
private processStreamResult;
|
|
364
|
+
/**
|
|
365
|
+
* Emit stream end events
|
|
366
|
+
*/
|
|
367
|
+
private emitStreamEndEvents;
|
|
368
|
+
/**
|
|
369
|
+
* Create stream response
|
|
370
|
+
*/
|
|
371
|
+
private createStreamResponse;
|
|
372
|
+
/**
|
|
373
|
+
* Handle stream error with fallback
|
|
374
|
+
*/
|
|
375
|
+
private handleStreamError;
|
|
260
376
|
/**
|
|
261
377
|
* Get the EventEmitter instance to listen to NeuroLink events for real-time monitoring and debugging.
|
|
262
378
|
* This method provides access to the internal event system that emits events during AI generation,
|