@juspay/neurolink 1.2.4 → 1.5.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 (35) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/README.md +96 -232
  3. package/dist/cli/commands/config.d.ts +403 -0
  4. package/dist/cli/commands/config.js +567 -0
  5. package/dist/cli/commands/mcp.d.ts +7 -0
  6. package/dist/cli/commands/mcp.js +434 -0
  7. package/dist/cli/index.d.ts +9 -0
  8. package/dist/cli/index.js +16 -9
  9. package/dist/core/factory.js +6 -2
  10. package/dist/core/types.d.ts +12 -2
  11. package/dist/core/types.js +11 -0
  12. package/dist/mcp/context-manager.d.ts +164 -0
  13. package/dist/mcp/context-manager.js +273 -0
  14. package/dist/mcp/factory.d.ts +144 -0
  15. package/dist/mcp/factory.js +141 -0
  16. package/dist/mcp/orchestrator.d.ts +170 -0
  17. package/dist/mcp/orchestrator.js +372 -0
  18. package/dist/mcp/registry.d.ts +188 -0
  19. package/dist/mcp/registry.js +373 -0
  20. package/dist/mcp/servers/ai-providers/ai-analysis-tools.d.ts +21 -0
  21. package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +215 -0
  22. package/dist/mcp/servers/ai-providers/ai-core-server.d.ts +10 -0
  23. package/dist/mcp/servers/ai-providers/ai-core-server.js +302 -0
  24. package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +101 -0
  25. package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +430 -0
  26. package/dist/neurolink.d.ts +4 -4
  27. package/dist/neurolink.js +109 -56
  28. package/dist/providers/googleAIStudio.d.ts +30 -0
  29. package/dist/providers/googleAIStudio.js +215 -0
  30. package/dist/providers/googleVertexAI.js +2 -2
  31. package/dist/providers/index.d.ts +2 -0
  32. package/dist/providers/index.js +3 -1
  33. package/dist/providers/openAI.js +2 -2
  34. package/dist/utils/providerUtils.js +11 -2
  35. package/package.json +78 -6
@@ -0,0 +1,567 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * NeuroLink CLI Configuration Management
4
+ *
5
+ * Enhanced configuration system with interactive setup,
6
+ * multi-profile support, and smart validation.
7
+ */
8
+ import inquirer from 'inquirer';
9
+ import fs from 'fs';
10
+ import path from 'path';
11
+ import os from 'os';
12
+ import chalk from 'chalk';
13
+ import { z } from 'zod';
14
+ // Configuration schema for validation
15
+ const ConfigSchema = z.object({
16
+ defaultProvider: z.enum(['auto', 'openai', 'bedrock', 'vertex', 'anthropic', 'azure', 'google-ai', 'huggingface']).default('auto'),
17
+ providers: z.object({
18
+ openai: z.object({
19
+ apiKey: z.string().optional(),
20
+ model: z.string().default('gpt-4'),
21
+ baseURL: z.string().optional()
22
+ }).optional(),
23
+ bedrock: z.object({
24
+ region: z.string().optional(),
25
+ accessKeyId: z.string().optional(),
26
+ secretAccessKey: z.string().optional(),
27
+ sessionToken: z.string().optional(),
28
+ model: z.string().default('arn:aws:bedrock:us-east-2:225681119357:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0')
29
+ }).optional(),
30
+ vertex: z.object({
31
+ projectId: z.string().optional(),
32
+ location: z.string().default('us-east5'),
33
+ credentials: z.string().optional(),
34
+ serviceAccountKey: z.string().optional(),
35
+ clientEmail: z.string().optional(),
36
+ privateKey: z.string().optional(),
37
+ model: z.string().default('gemini-1.5-pro')
38
+ }).optional(),
39
+ anthropic: z.object({
40
+ apiKey: z.string().optional(),
41
+ model: z.string().default('claude-3-5-sonnet-20241022')
42
+ }).optional(),
43
+ azure: z.object({
44
+ apiKey: z.string().optional(),
45
+ endpoint: z.string().optional(),
46
+ deploymentId: z.string().optional(),
47
+ model: z.string().default('gpt-4')
48
+ }).optional(),
49
+ 'google-ai': z.object({
50
+ apiKey: z.string().optional(),
51
+ model: z.string().default('gemini-1.5-pro-latest')
52
+ }).optional(),
53
+ huggingface: z.object({
54
+ apiKey: z.string().optional(),
55
+ model: z.string().default('microsoft/DialoGPT-large')
56
+ }).optional()
57
+ }).default({}),
58
+ profiles: z.record(z.string(), z.any()).default({}),
59
+ preferences: z.object({
60
+ outputFormat: z.enum(['text', 'json', 'yaml']).default('text'),
61
+ temperature: z.number().min(0).max(2).default(0.7),
62
+ maxTokens: z.number().min(1).max(4000).default(500),
63
+ enableLogging: z.boolean().default(false),
64
+ enableCaching: z.boolean().default(true),
65
+ cacheStrategy: z.enum(['memory', 'file', 'redis']).default('memory')
66
+ }).default({})
67
+ });
68
+ export class ConfigManager {
69
+ configDir;
70
+ configFile;
71
+ config;
72
+ constructor() {
73
+ this.configDir = path.join(os.homedir(), '.neurolink');
74
+ this.configFile = path.join(this.configDir, 'config.json');
75
+ this.config = this.loadConfig();
76
+ }
77
+ /**
78
+ * Load configuration from file or create default
79
+ */
80
+ loadConfig() {
81
+ try {
82
+ if (fs.existsSync(this.configFile)) {
83
+ const configData = JSON.parse(fs.readFileSync(this.configFile, 'utf8'));
84
+ return ConfigSchema.parse(configData);
85
+ }
86
+ }
87
+ catch (error) {
88
+ console.warn(chalk.yellow(`⚠️ Invalid config file: ${error instanceof Error ? error.message : 'Unknown error'}`));
89
+ }
90
+ return ConfigSchema.parse({});
91
+ }
92
+ /**
93
+ * Save configuration to file
94
+ */
95
+ saveConfig() {
96
+ try {
97
+ // Ensure config directory exists
98
+ if (!fs.existsSync(this.configDir)) {
99
+ fs.mkdirSync(this.configDir, { recursive: true });
100
+ }
101
+ // Validate before saving
102
+ const validatedConfig = ConfigSchema.parse(this.config);
103
+ fs.writeFileSync(this.configFile, JSON.stringify(validatedConfig, null, 2));
104
+ console.log(chalk.green(`✅ Configuration saved to ${this.configFile}`));
105
+ }
106
+ catch (error) {
107
+ console.error(chalk.red(`❌ Failed to save config: ${error instanceof Error ? error.message : 'Unknown error'}`));
108
+ process.exit(1);
109
+ }
110
+ }
111
+ /**
112
+ * Interactive configuration setup
113
+ */
114
+ async initInteractive() {
115
+ console.log(chalk.blue('🧠 NeuroLink Configuration Setup\n'));
116
+ try {
117
+ // Basic preferences
118
+ const preferences = await inquirer.prompt([
119
+ {
120
+ type: 'list',
121
+ name: 'defaultProvider',
122
+ message: 'Select your default AI provider:',
123
+ choices: [
124
+ { name: 'Auto (recommended) - Automatically select best available', value: 'auto' },
125
+ { name: 'OpenAI - GPT models', value: 'openai' },
126
+ { name: 'Amazon Bedrock - Claude, Llama, Titan', value: 'bedrock' },
127
+ { name: 'Google Vertex AI - Gemini models', value: 'vertex' },
128
+ { name: 'Anthropic - Claude models (direct)', value: 'anthropic' },
129
+ { name: 'Azure OpenAI - Enterprise GPT', value: 'azure' },
130
+ { name: 'Google AI Studio - Gemini models (direct)', value: 'google-ai' },
131
+ { name: 'Hugging Face - Open source models', value: 'huggingface' }
132
+ ],
133
+ default: this.config.defaultProvider
134
+ },
135
+ {
136
+ type: 'list',
137
+ name: 'outputFormat',
138
+ message: 'Preferred output format:',
139
+ choices: ['text', 'json', 'yaml'],
140
+ default: this.config.preferences.outputFormat
141
+ },
142
+ {
143
+ type: 'number',
144
+ name: 'temperature',
145
+ message: 'Default creativity level (0.0 = focused, 1.0 = creative):',
146
+ default: this.config.preferences.temperature,
147
+ validate: (value) => value >= 0 && value <= 2
148
+ },
149
+ {
150
+ type: 'confirm',
151
+ name: 'setupProviders',
152
+ message: 'Would you like to configure provider credentials now?',
153
+ default: true
154
+ }
155
+ ]);
156
+ // Update config with preferences
157
+ this.config.defaultProvider = preferences.defaultProvider;
158
+ this.config.preferences.outputFormat = preferences.outputFormat;
159
+ this.config.preferences.temperature = preferences.temperature;
160
+ // Setup providers if requested
161
+ if (preferences.setupProviders) {
162
+ await this.setupProviders();
163
+ }
164
+ this.saveConfig();
165
+ console.log(chalk.green('\n✅ Configuration setup complete!'));
166
+ console.log(chalk.blue('💡 You can modify settings anytime with: neurolink config edit'));
167
+ console.log(chalk.blue('💡 Test your setup with: neurolink status'));
168
+ }
169
+ catch (error) {
170
+ if (error instanceof Error && error.message === 'User force closed the prompt with 0 null') {
171
+ console.log(chalk.yellow('\n⚠️ Setup cancelled by user'));
172
+ process.exit(0);
173
+ }
174
+ throw error;
175
+ }
176
+ }
177
+ /**
178
+ * Setup individual providers
179
+ */
180
+ async setupProviders() {
181
+ const { selectedProviders } = await inquirer.prompt([
182
+ {
183
+ type: 'checkbox',
184
+ name: 'selectedProviders',
185
+ message: 'Select providers to configure:',
186
+ choices: [
187
+ { name: 'OpenAI (GPT-4, GPT-3.5)', value: 'openai' },
188
+ { name: 'Amazon Bedrock (Claude, Llama)', value: 'bedrock' },
189
+ { name: 'Google Vertex AI (Gemini)', value: 'vertex' },
190
+ { name: 'Anthropic Direct (Claude)', value: 'anthropic' },
191
+ { name: 'Azure OpenAI (Enterprise)', value: 'azure' },
192
+ { name: 'Google AI Studio (Gemini Direct)', value: 'google-ai' },
193
+ { name: 'Hugging Face (Open Source)', value: 'huggingface' }
194
+ ]
195
+ }
196
+ ]);
197
+ for (const provider of selectedProviders) {
198
+ await this.setupProvider(provider);
199
+ }
200
+ }
201
+ /**
202
+ * Setup individual provider
203
+ */
204
+ async setupProvider(provider) {
205
+ console.log(chalk.blue(`\n🔧 Configuring ${provider.toUpperCase()}`));
206
+ switch (provider) {
207
+ case 'openai':
208
+ await this.setupOpenAI();
209
+ break;
210
+ case 'bedrock':
211
+ await this.setupBedrock();
212
+ break;
213
+ case 'vertex':
214
+ await this.setupVertex();
215
+ break;
216
+ case 'anthropic':
217
+ await this.setupAnthropic();
218
+ break;
219
+ case 'azure':
220
+ await this.setupAzure();
221
+ break;
222
+ case 'google-ai':
223
+ await this.setupGoogleAI();
224
+ break;
225
+ case 'huggingface':
226
+ await this.setupHuggingFace();
227
+ break;
228
+ }
229
+ }
230
+ /**
231
+ * OpenAI provider setup
232
+ */
233
+ async setupOpenAI() {
234
+ const answers = await inquirer.prompt([
235
+ {
236
+ type: 'password',
237
+ name: 'apiKey',
238
+ message: 'OpenAI API Key (sk-...):',
239
+ validate: (value) => value.startsWith('sk-') || 'API key should start with "sk-"'
240
+ },
241
+ {
242
+ type: 'list',
243
+ name: 'model',
244
+ message: 'Default model:',
245
+ choices: ['gpt-4', 'gpt-4-turbo', 'gpt-3.5-turbo'],
246
+ default: 'gpt-4'
247
+ },
248
+ {
249
+ type: 'input',
250
+ name: 'baseURL',
251
+ message: 'Custom base URL (optional):',
252
+ default: ''
253
+ }
254
+ ]);
255
+ this.config.providers.openai = {
256
+ apiKey: answers.apiKey,
257
+ model: answers.model,
258
+ ...(answers.baseURL && { baseURL: answers.baseURL })
259
+ };
260
+ }
261
+ /**
262
+ * Amazon Bedrock provider setup
263
+ */
264
+ async setupBedrock() {
265
+ const answers = await inquirer.prompt([
266
+ {
267
+ type: 'input',
268
+ name: 'region',
269
+ message: 'AWS Region:',
270
+ default: 'us-east-1'
271
+ },
272
+ {
273
+ type: 'input',
274
+ name: 'accessKeyId',
275
+ message: 'AWS Access Key ID (optional if using IAM roles):'
276
+ },
277
+ {
278
+ type: 'password',
279
+ name: 'secretAccessKey',
280
+ message: 'AWS Secret Access Key (optional if using IAM roles):'
281
+ },
282
+ {
283
+ type: 'password',
284
+ name: 'sessionToken',
285
+ message: 'AWS Session Token (optional):'
286
+ },
287
+ {
288
+ type: 'input',
289
+ name: 'model',
290
+ message: 'Model ARN:',
291
+ default: 'arn:aws:bedrock:us-east-2:225681119357:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0'
292
+ }
293
+ ]);
294
+ this.config.providers.bedrock = {
295
+ region: answers.region,
296
+ ...(answers.accessKeyId && { accessKeyId: answers.accessKeyId }),
297
+ ...(answers.secretAccessKey && { secretAccessKey: answers.secretAccessKey }),
298
+ ...(answers.sessionToken && { sessionToken: answers.sessionToken }),
299
+ model: answers.model
300
+ };
301
+ }
302
+ /**
303
+ * Google Vertex AI provider setup
304
+ */
305
+ async setupVertex() {
306
+ const { authMethod } = await inquirer.prompt([
307
+ {
308
+ type: 'list',
309
+ name: 'authMethod',
310
+ message: 'Authentication method:',
311
+ choices: [
312
+ { name: 'Service Account File', value: 'file' },
313
+ { name: 'Service Account JSON String', value: 'json' },
314
+ { name: 'Individual Environment Variables', value: 'env' }
315
+ ]
316
+ }
317
+ ]);
318
+ const commonAnswers = await inquirer.prompt([
319
+ {
320
+ type: 'input',
321
+ name: 'projectId',
322
+ message: 'Google Cloud Project ID:',
323
+ validate: (value) => value.length > 0 || 'Project ID is required'
324
+ },
325
+ {
326
+ type: 'input',
327
+ name: 'location',
328
+ message: 'Vertex AI Location:',
329
+ default: 'us-east5'
330
+ },
331
+ {
332
+ type: 'list',
333
+ name: 'model',
334
+ message: 'Default model:',
335
+ choices: ['gemini-1.5-pro', 'gemini-1.5-flash', 'gemini-pro'],
336
+ default: 'gemini-1.5-pro'
337
+ }
338
+ ]);
339
+ let authConfig = {};
340
+ switch (authMethod) {
341
+ case 'file':
342
+ const fileAnswers = await inquirer.prompt([
343
+ {
344
+ type: 'input',
345
+ name: 'credentials',
346
+ message: 'Path to service account JSON file:',
347
+ validate: (value) => fs.existsSync(value) || 'File does not exist'
348
+ }
349
+ ]);
350
+ authConfig = { credentials: fileAnswers.credentials };
351
+ break;
352
+ case 'json':
353
+ const jsonAnswers = await inquirer.prompt([
354
+ {
355
+ type: 'input',
356
+ name: 'serviceAccountKey',
357
+ message: 'Service account JSON string:',
358
+ validate: (value) => {
359
+ try {
360
+ JSON.parse(value);
361
+ return true;
362
+ }
363
+ catch {
364
+ return 'Invalid JSON';
365
+ }
366
+ }
367
+ }
368
+ ]);
369
+ authConfig = { serviceAccountKey: jsonAnswers.serviceAccountKey };
370
+ break;
371
+ case 'env':
372
+ const envAnswers = await inquirer.prompt([
373
+ {
374
+ type: 'input',
375
+ name: 'clientEmail',
376
+ message: 'Service account email:',
377
+ validate: (value) => value.includes('@') || 'Invalid email format'
378
+ },
379
+ {
380
+ type: 'password',
381
+ name: 'privateKey',
382
+ message: 'Private key:'
383
+ }
384
+ ]);
385
+ authConfig = {
386
+ clientEmail: envAnswers.clientEmail,
387
+ privateKey: envAnswers.privateKey
388
+ };
389
+ break;
390
+ }
391
+ this.config.providers.vertex = {
392
+ projectId: commonAnswers.projectId,
393
+ location: commonAnswers.location,
394
+ model: commonAnswers.model,
395
+ ...authConfig
396
+ };
397
+ }
398
+ /**
399
+ * Anthropic provider setup
400
+ */
401
+ async setupAnthropic() {
402
+ const answers = await inquirer.prompt([
403
+ {
404
+ type: 'password',
405
+ name: 'apiKey',
406
+ message: 'Anthropic API Key:',
407
+ validate: (value) => value.length > 0 || 'API key is required'
408
+ },
409
+ {
410
+ type: 'list',
411
+ name: 'model',
412
+ message: 'Default model:',
413
+ choices: [
414
+ 'claude-3-5-sonnet-20241022',
415
+ 'claude-3-5-haiku-20241022',
416
+ 'claude-3-opus-20240229'
417
+ ],
418
+ default: 'claude-3-5-sonnet-20241022'
419
+ }
420
+ ]);
421
+ this.config.providers.anthropic = answers;
422
+ }
423
+ /**
424
+ * Azure OpenAI provider setup
425
+ */
426
+ async setupAzure() {
427
+ const answers = await inquirer.prompt([
428
+ {
429
+ type: 'password',
430
+ name: 'apiKey',
431
+ message: 'Azure OpenAI API Key:'
432
+ },
433
+ {
434
+ type: 'input',
435
+ name: 'endpoint',
436
+ message: 'Azure OpenAI Endpoint:',
437
+ validate: (value) => value.startsWith('https://') || 'Endpoint should start with https://'
438
+ },
439
+ {
440
+ type: 'input',
441
+ name: 'deploymentId',
442
+ message: 'Deployment ID:'
443
+ },
444
+ {
445
+ type: 'list',
446
+ name: 'model',
447
+ message: 'Model:',
448
+ choices: ['gpt-4', 'gpt-4-turbo', 'gpt-35-turbo'],
449
+ default: 'gpt-4'
450
+ }
451
+ ]);
452
+ this.config.providers.azure = answers;
453
+ }
454
+ /**
455
+ * Google AI Studio provider setup
456
+ */
457
+ async setupGoogleAI() {
458
+ const answers = await inquirer.prompt([
459
+ {
460
+ type: 'password',
461
+ name: 'apiKey',
462
+ message: 'Google AI API Key:',
463
+ validate: (value) => value.length > 0 || 'API key is required'
464
+ },
465
+ {
466
+ type: 'list',
467
+ name: 'model',
468
+ message: 'Default model:',
469
+ choices: [
470
+ 'gemini-1.5-pro-latest',
471
+ 'gemini-2.0-flash-exp',
472
+ 'gemini-1.5-flash-latest',
473
+ 'gemini-1.0-pro'
474
+ ],
475
+ default: 'gemini-1.5-pro-latest'
476
+ }
477
+ ]);
478
+ this.config.providers['google-ai'] = answers;
479
+ }
480
+ /**
481
+ * Hugging Face provider setup
482
+ */
483
+ async setupHuggingFace() {
484
+ const answers = await inquirer.prompt([
485
+ {
486
+ type: 'password',
487
+ name: 'apiKey',
488
+ message: 'Hugging Face API Key:'
489
+ },
490
+ {
491
+ type: 'input',
492
+ name: 'model',
493
+ message: 'Model name:',
494
+ default: 'microsoft/DialoGPT-large'
495
+ }
496
+ ]);
497
+ this.config.providers.huggingface = answers;
498
+ }
499
+ /**
500
+ * Get current configuration
501
+ */
502
+ getConfig() {
503
+ return this.config;
504
+ }
505
+ /**
506
+ * Update configuration
507
+ */
508
+ updateConfig(updates) {
509
+ this.config = { ...this.config, ...updates };
510
+ this.saveConfig();
511
+ }
512
+ /**
513
+ * Show current configuration
514
+ */
515
+ showConfig() {
516
+ console.log(chalk.blue('📋 Current NeuroLink Configuration\n'));
517
+ console.log(chalk.cyan('General Settings:'));
518
+ console.log(` Default Provider: ${chalk.white(this.config.defaultProvider)}`);
519
+ console.log(` Output Format: ${chalk.white(this.config.preferences.outputFormat)}`);
520
+ console.log(` Temperature: ${chalk.white(this.config.preferences.temperature)}`);
521
+ console.log(` Max Tokens: ${chalk.white(this.config.preferences.maxTokens)}`);
522
+ console.log(chalk.cyan('\nConfigured Providers:'));
523
+ Object.entries(this.config.providers).forEach(([name, config]) => {
524
+ if (config && Object.keys(config).length > 0) {
525
+ console.log(` ${chalk.green('✅')} ${name.toUpperCase()}`);
526
+ if ('model' in config) {
527
+ console.log(` Model: ${chalk.white(config.model)}`);
528
+ }
529
+ }
530
+ });
531
+ console.log(chalk.cyan('\nConfiguration File:'));
532
+ console.log(` Location: ${chalk.white(this.configFile)}`);
533
+ }
534
+ /**
535
+ * Validate configuration
536
+ */
537
+ validateConfig() {
538
+ const errors = [];
539
+ try {
540
+ ConfigSchema.parse(this.config);
541
+ }
542
+ catch (error) {
543
+ if (error instanceof z.ZodError) {
544
+ errors.push(...error.errors.map(e => `${e.path.join('.')}: ${e.message}`));
545
+ }
546
+ }
547
+ // Check for at least one configured provider
548
+ const hasProvider = Object.values(this.config.providers).some(provider => provider && Object.keys(provider).length > 0);
549
+ if (!hasProvider) {
550
+ errors.push('No providers configured. Run "neurolink config init" to set up providers.');
551
+ }
552
+ return {
553
+ valid: errors.length === 0,
554
+ errors
555
+ };
556
+ }
557
+ /**
558
+ * Reset configuration to defaults
559
+ */
560
+ resetConfig() {
561
+ this.config = ConfigSchema.parse({});
562
+ this.saveConfig();
563
+ console.log(chalk.green('✅ Configuration reset to defaults'));
564
+ }
565
+ }
566
+ // Export for use in other CLI commands
567
+ export const configManager = new ConfigManager();
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP Server Management Commands
4
+ * Real MCP server connectivity and management
5
+ */
6
+ import type { Argv } from 'yargs';
7
+ export declare function addMCPCommands(yargs: Argv): Argv;