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