@juspay/neurolink 1.6.0 → 1.9.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 (176) hide show
  1. package/CHANGELOG.md +193 -7
  2. package/README.md +100 -17
  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 +589 -323
  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 +176 -61
  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 +176 -61
  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 +2 -2
  65. package/dist/lib/mcp/registry.js +42 -33
  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 +113 -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.js +53 -31
  107. package/dist/mcp/auto-discovery.d.ts +120 -0
  108. package/dist/mcp/auto-discovery.js +794 -0
  109. package/dist/mcp/client.d.ts +66 -0
  110. package/dist/mcp/client.js +245 -0
  111. package/dist/mcp/config.d.ts +31 -0
  112. package/dist/mcp/config.js +74 -0
  113. package/dist/mcp/context-manager.d.ts +4 -4
  114. package/dist/mcp/context-manager.js +24 -18
  115. package/dist/mcp/factory.d.ts +28 -11
  116. package/dist/mcp/factory.js +36 -29
  117. package/dist/mcp/function-calling.d.ts +51 -0
  118. package/dist/mcp/function-calling.js +510 -0
  119. package/dist/mcp/index.d.ts +190 -0
  120. package/dist/mcp/index.js +156 -0
  121. package/dist/mcp/initialize-tools.d.ts +28 -0
  122. package/dist/mcp/initialize-tools.js +210 -0
  123. package/dist/mcp/initialize.d.ts +17 -0
  124. package/dist/mcp/initialize.js +51 -0
  125. package/dist/mcp/logging.d.ts +71 -0
  126. package/dist/mcp/logging.js +183 -0
  127. package/dist/mcp/manager.d.ts +67 -0
  128. package/dist/mcp/manager.js +176 -0
  129. package/dist/mcp/neurolink-mcp-client.d.ts +96 -0
  130. package/dist/mcp/neurolink-mcp-client.js +417 -0
  131. package/dist/mcp/orchestrator.d.ts +3 -3
  132. package/dist/mcp/orchestrator.js +46 -43
  133. package/dist/mcp/registry.d.ts +2 -2
  134. package/dist/mcp/registry.js +42 -33
  135. package/dist/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -1
  136. package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +204 -65
  137. package/dist/mcp/servers/ai-providers/ai-core-server.js +142 -102
  138. package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +6 -6
  139. package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +197 -142
  140. package/dist/mcp/servers/utilities/utility-server.d.ts +8 -0
  141. package/dist/mcp/servers/utilities/utility-server.js +326 -0
  142. package/dist/mcp/tool-integration.d.ts +67 -0
  143. package/dist/mcp/tool-integration.js +179 -0
  144. package/dist/mcp/unified-registry.d.ts +269 -0
  145. package/dist/mcp/unified-registry.js +1411 -0
  146. package/dist/neurolink.d.ts +68 -6
  147. package/dist/neurolink.js +304 -42
  148. package/dist/providers/agent-enhanced-provider.d.ts +59 -0
  149. package/dist/providers/agent-enhanced-provider.js +242 -0
  150. package/dist/providers/amazonBedrock.d.ts +3 -3
  151. package/dist/providers/amazonBedrock.js +54 -50
  152. package/dist/providers/anthropic.d.ts +2 -2
  153. package/dist/providers/anthropic.js +92 -84
  154. package/dist/providers/azureOpenAI.d.ts +2 -2
  155. package/dist/providers/azureOpenAI.js +97 -86
  156. package/dist/providers/function-calling-provider.d.ts +70 -0
  157. package/dist/providers/function-calling-provider.js +359 -0
  158. package/dist/providers/googleAIStudio.d.ts +10 -5
  159. package/dist/providers/googleAIStudio.js +60 -38
  160. package/dist/providers/googleVertexAI.d.ts +3 -3
  161. package/dist/providers/googleVertexAI.js +96 -86
  162. package/dist/providers/huggingFace.d.ts +3 -3
  163. package/dist/providers/huggingFace.js +70 -63
  164. package/dist/providers/index.d.ts +11 -11
  165. package/dist/providers/index.js +18 -18
  166. package/dist/providers/mcp-provider.d.ts +62 -0
  167. package/dist/providers/mcp-provider.js +183 -0
  168. package/dist/providers/mistralAI.d.ts +3 -3
  169. package/dist/providers/mistralAI.js +42 -36
  170. package/dist/providers/ollama.d.ts +4 -4
  171. package/dist/providers/ollama.js +113 -98
  172. package/dist/providers/openAI.d.ts +7 -3
  173. package/dist/providers/openAI.js +45 -33
  174. package/dist/utils/logger.js +2 -2
  175. package/dist/utils/providerUtils.js +53 -31
  176. package/package.json +175 -161
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Complete Setup Integration for NeuroLink CLI
3
+ *
4
+ * Orchestrates the entire setup process: interactive wizard, environment management,
5
+ * provider testing, and summary display.
6
+ */
7
+ import { type SetupResult } from "./interactive-setup.js";
8
+ /**
9
+ * Run the complete interactive setup process
10
+ */
11
+ export declare function runCompleteSetup(quiet?: boolean): Promise<SetupResult>;
12
+ /**
13
+ * Wrapper for config setup command
14
+ */
15
+ export declare function configSetup(quiet?: boolean): Promise<void>;
16
+ /**
17
+ * Wrapper for config init command (alias for setup)
18
+ */
19
+ export declare function configInit(quiet?: boolean): Promise<void>;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Complete Setup Integration for NeuroLink CLI
3
+ *
4
+ * Orchestrates the entire setup process: interactive wizard, environment management,
5
+ * provider testing, and summary display.
6
+ */
7
+ import { runInteractiveSetup, testProviderConnectivity, displaySetupSummary, } from "./interactive-setup.js";
8
+ import { updateEnvFile, displayEnvUpdateSummary } from "./env-manager.js";
9
+ import chalk from "chalk";
10
+ /**
11
+ * Run the complete interactive setup process
12
+ */
13
+ export async function runCompleteSetup(quiet = false) {
14
+ try {
15
+ // Step 1: Run interactive setup wizard
16
+ if (!quiet) {
17
+ console.log(chalk.blue("🚀 Starting NeuroLink Configuration Setup...\n"));
18
+ }
19
+ const setupResult = await runInteractiveSetup(quiet);
20
+ // If no providers selected, exit early
21
+ if (setupResult.selectedProviders.length === 0) {
22
+ if (!quiet) {
23
+ console.log(chalk.yellow("⚠️ No providers selected. Setup cancelled."));
24
+ }
25
+ return setupResult;
26
+ }
27
+ // Step 2: Update environment file with credentials
28
+ if (Object.keys(setupResult.credentials).length > 0) {
29
+ if (!quiet) {
30
+ console.log(chalk.blue("\n💾 Updating environment configuration...\n"));
31
+ }
32
+ try {
33
+ const envResult = updateEnvFile(setupResult.credentials, ".env", true);
34
+ setupResult.envFileBackup = envResult.backup.backupPath;
35
+ if (!quiet) {
36
+ displayEnvUpdateSummary(envResult, false);
37
+ }
38
+ // Update process.env for immediate testing
39
+ for (const [key, value] of Object.entries(setupResult.credentials)) {
40
+ process.env[key] = value;
41
+ }
42
+ }
43
+ catch (error) {
44
+ if (!quiet) {
45
+ console.error(chalk.red(`❌ Failed to update environment file: ${error instanceof Error ? error.message : String(error)}`));
46
+ }
47
+ throw error;
48
+ }
49
+ }
50
+ // Step 3: Test provider connectivity
51
+ if (!quiet) {
52
+ console.log(chalk.blue("\n🧪 Testing configured providers...\n"));
53
+ }
54
+ setupResult.testResults = await testProviderConnectivity(setupResult.selectedProviders, quiet);
55
+ // Step 4: Display summary
56
+ displaySetupSummary(setupResult, quiet);
57
+ return setupResult;
58
+ }
59
+ catch (error) {
60
+ if (!quiet) {
61
+ console.error(chalk.red(`❌ Setup failed: ${error instanceof Error ? error.message : String(error)}`));
62
+ console.log(chalk.yellow("💡 You can retry setup with: neurolink config setup"));
63
+ }
64
+ throw error;
65
+ }
66
+ }
67
+ /**
68
+ * Wrapper for config setup command
69
+ */
70
+ export async function configSetup(quiet = false) {
71
+ await runCompleteSetup(quiet);
72
+ }
73
+ /**
74
+ * Wrapper for config init command (alias for setup)
75
+ */
76
+ export async function configInit(quiet = false) {
77
+ if (!quiet) {
78
+ console.log(chalk.gray("📝 config init is an alias for config setup\n"));
79
+ }
80
+ await runCompleteSetup(quiet);
81
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Environment File Management Utilities for NeuroLink CLI
3
+ *
4
+ * Handles .env file operations including backup, update, and validation.
5
+ */
6
+ export interface EnvBackupResult {
7
+ backupPath?: string;
8
+ existed: boolean;
9
+ }
10
+ export interface EnvUpdateResult {
11
+ backup: EnvBackupResult;
12
+ updated: string[];
13
+ added: string[];
14
+ unchanged: string[];
15
+ }
16
+ /**
17
+ * Create a timestamped backup of the existing .env file
18
+ */
19
+ export declare function backupEnvFile(envPath?: string): EnvBackupResult;
20
+ /**
21
+ * Parse .env file content into key-value pairs
22
+ */
23
+ export declare function parseEnvFile(content: string): Record<string, string>;
24
+ /**
25
+ * Generate .env file content from key-value pairs
26
+ */
27
+ export declare function generateEnvContent(envVars: Record<string, string>, existingContent?: string): string;
28
+ /**
29
+ * Update .env file with new environment variables
30
+ */
31
+ export declare function updateEnvFile(newVars: Record<string, string>, envPath?: string, createBackup?: boolean): EnvUpdateResult;
32
+ /**
33
+ * Display environment file update summary
34
+ */
35
+ export declare function displayEnvUpdateSummary(result: EnvUpdateResult, quiet?: boolean): void;
36
+ /**
37
+ * Validate .env file format and required variables
38
+ */
39
+ export declare function validateEnvFile(envPath?: string, requiredVars?: string[]): {
40
+ valid: boolean;
41
+ errors: string[];
42
+ warnings: string[];
43
+ variables: Record<string, string>;
44
+ };
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Environment File Management Utilities for NeuroLink CLI
3
+ *
4
+ * Handles .env file operations including backup, update, and validation.
5
+ */
6
+ import fs from "fs";
7
+ import chalk from "chalk";
8
+ /**
9
+ * Create a timestamped backup of the existing .env file
10
+ */
11
+ export function backupEnvFile(envPath = ".env") {
12
+ const result = {
13
+ existed: false,
14
+ };
15
+ if (fs.existsSync(envPath)) {
16
+ result.existed = true;
17
+ const timestamp = new Date()
18
+ .toISOString()
19
+ .replace(/[:.]/g, "-")
20
+ .replace("T", "_")
21
+ .split(".")[0]; // Remove milliseconds
22
+ const backupPath = `${envPath}.backup.${timestamp}`;
23
+ try {
24
+ fs.copyFileSync(envPath, backupPath);
25
+ result.backupPath = backupPath;
26
+ }
27
+ catch (error) {
28
+ throw new Error(`Failed to create backup: ${error instanceof Error ? error.message : String(error)}`);
29
+ }
30
+ }
31
+ return result;
32
+ }
33
+ /**
34
+ * Parse .env file content into key-value pairs
35
+ */
36
+ export function parseEnvFile(content) {
37
+ const result = {};
38
+ const lines = content.split("\n");
39
+ for (const line of lines) {
40
+ const trimmedLine = line.trim();
41
+ // Skip empty lines and comments
42
+ if (!trimmedLine || trimmedLine.startsWith("#")) {
43
+ continue;
44
+ }
45
+ // Find the first = character
46
+ const equalIndex = trimmedLine.indexOf("=");
47
+ if (equalIndex === -1) {
48
+ continue; // Invalid line format
49
+ }
50
+ const key = trimmedLine.substring(0, equalIndex).trim();
51
+ const value = trimmedLine.substring(equalIndex + 1).trim();
52
+ // Remove surrounding quotes if present
53
+ const cleanValue = value.replace(/^["']|["']$/g, "");
54
+ result[key] = cleanValue;
55
+ }
56
+ return result;
57
+ }
58
+ /**
59
+ * Generate .env file content from key-value pairs
60
+ */
61
+ export function generateEnvContent(envVars, existingContent) {
62
+ const lines = [];
63
+ const existingVars = existingContent ? parseEnvFile(existingContent) : {};
64
+ const processedKeys = new Set();
65
+ // If we have existing content, preserve its structure and comments
66
+ if (existingContent) {
67
+ const existingLines = existingContent.split("\n");
68
+ for (const line of existingLines) {
69
+ const trimmedLine = line.trim();
70
+ // Preserve comments and empty lines
71
+ if (!trimmedLine || trimmedLine.startsWith("#")) {
72
+ lines.push(line);
73
+ continue;
74
+ }
75
+ const equalIndex = trimmedLine.indexOf("=");
76
+ if (equalIndex === -1) {
77
+ lines.push(line); // Preserve invalid lines as-is
78
+ continue;
79
+ }
80
+ const key = trimmedLine.substring(0, equalIndex).trim();
81
+ if (Object.prototype.hasOwnProperty.call(envVars, key)) {
82
+ // Update existing variable
83
+ lines.push(`${key}=${envVars[key]}`);
84
+ processedKeys.add(key);
85
+ }
86
+ else {
87
+ // Preserve existing variable
88
+ lines.push(line);
89
+ }
90
+ }
91
+ }
92
+ // Add new variables that weren't in the existing file
93
+ const newVars = Object.keys(envVars).filter((key) => !processedKeys.has(key));
94
+ if (newVars.length > 0) {
95
+ if (lines.length > 0 && lines[lines.length - 1].trim() !== "") {
96
+ lines.push(""); // Add blank line before new variables
97
+ }
98
+ if (!existingContent) {
99
+ lines.push("# NeuroLink AI Provider Configuration");
100
+ }
101
+ for (const key of newVars) {
102
+ lines.push(`${key}=${envVars[key]}`);
103
+ }
104
+ }
105
+ return lines.join("\n") + (lines.length > 0 ? "\n" : "");
106
+ }
107
+ /**
108
+ * Update .env file with new environment variables
109
+ */
110
+ export function updateEnvFile(newVars, envPath = ".env", createBackup = true) {
111
+ const result = {
112
+ backup: { existed: false },
113
+ updated: [],
114
+ added: [],
115
+ unchanged: [],
116
+ };
117
+ // Create backup if requested and file exists
118
+ if (createBackup) {
119
+ result.backup = backupEnvFile(envPath);
120
+ }
121
+ // Read existing content
122
+ let existingContent = "";
123
+ let existingVars = {};
124
+ if (fs.existsSync(envPath)) {
125
+ existingContent = fs.readFileSync(envPath, "utf8");
126
+ existingVars = parseEnvFile(existingContent);
127
+ }
128
+ // Categorize changes
129
+ for (const [key, value] of Object.entries(newVars)) {
130
+ if (Object.prototype.hasOwnProperty.call(existingVars, key)) {
131
+ if (existingVars[key] !== value) {
132
+ result.updated.push(key);
133
+ }
134
+ else {
135
+ result.unchanged.push(key);
136
+ }
137
+ }
138
+ else {
139
+ result.added.push(key);
140
+ }
141
+ }
142
+ // Generate new content
143
+ const newContent = generateEnvContent(newVars, existingContent);
144
+ // Write updated file
145
+ try {
146
+ fs.writeFileSync(envPath, newContent, "utf8");
147
+ }
148
+ catch (error) {
149
+ throw new Error(`Failed to write .env file: ${error instanceof Error ? error.message : String(error)}`);
150
+ }
151
+ return result;
152
+ }
153
+ /**
154
+ * Display environment file update summary
155
+ */
156
+ export function displayEnvUpdateSummary(result, quiet = false) {
157
+ if (quiet) {
158
+ return;
159
+ }
160
+ if (result.backup.existed && result.backup.backupPath) {
161
+ console.log(chalk.gray(`💾 Created backup: ${result.backup.backupPath}`));
162
+ }
163
+ if (result.added.length > 0) {
164
+ console.log(chalk.green(`➕ Added ${result.added.length} new variables: ${result.added.join(", ")}`));
165
+ }
166
+ if (result.updated.length > 0) {
167
+ console.log(chalk.yellow(`🔄 Updated ${result.updated.length} existing variables: ${result.updated.join(", ")}`));
168
+ }
169
+ if (result.unchanged.length > 0) {
170
+ console.log(chalk.gray(`✓ ${result.unchanged.length} variables unchanged: ${result.unchanged.join(", ")}`));
171
+ }
172
+ const totalChanges = result.added.length + result.updated.length;
173
+ if (totalChanges > 0) {
174
+ console.log(chalk.blue(`📝 Environment file updated with ${totalChanges} changes`));
175
+ }
176
+ else {
177
+ console.log(chalk.gray("📝 No changes needed to environment file"));
178
+ }
179
+ }
180
+ /**
181
+ * Validate .env file format and required variables
182
+ */
183
+ export function validateEnvFile(envPath = ".env", requiredVars = []) {
184
+ const result = {
185
+ valid: true,
186
+ errors: [],
187
+ warnings: [],
188
+ variables: {},
189
+ };
190
+ if (!fs.existsSync(envPath)) {
191
+ result.valid = false;
192
+ result.errors.push(`Environment file not found: ${envPath}`);
193
+ return result;
194
+ }
195
+ try {
196
+ const content = fs.readFileSync(envPath, "utf8");
197
+ result.variables = parseEnvFile(content);
198
+ // Check for required variables
199
+ for (const requiredVar of requiredVars) {
200
+ if (!Object.prototype.hasOwnProperty.call(result.variables, requiredVar) ||
201
+ !result.variables[requiredVar]) {
202
+ result.valid = false;
203
+ result.errors.push(`Missing required variable: ${requiredVar}`);
204
+ }
205
+ }
206
+ // Check for common formatting issues
207
+ const lines = content.split("\n");
208
+ for (let i = 0; i < lines.length; i++) {
209
+ const line = lines[i].trim();
210
+ if (!line || line.startsWith("#")) {
211
+ continue;
212
+ }
213
+ if (!line.includes("=")) {
214
+ result.warnings.push(`Line ${i + 1}: Invalid format (missing =)`);
215
+ }
216
+ else if (line.startsWith("=")) {
217
+ result.warnings.push(`Line ${i + 1}: Empty variable name`);
218
+ }
219
+ }
220
+ }
221
+ catch (error) {
222
+ result.valid = false;
223
+ result.errors.push(`Failed to read environment file: ${error instanceof Error ? error.message : String(error)}`);
224
+ }
225
+ return result;
226
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Interactive Setup Utilities for NeuroLink CLI
3
+ *
4
+ * Provides interactive configuration wizard with provider selection,
5
+ * credential collection, testing, and environment file management.
6
+ */
7
+ import { AIProviderName } from "../../lib/core/types.js";
8
+ export interface ProviderConfig {
9
+ id: AIProviderName;
10
+ name: string;
11
+ description: string;
12
+ envVars: Array<{
13
+ key: string;
14
+ prompt: string;
15
+ secure?: boolean;
16
+ default?: string;
17
+ optional?: boolean;
18
+ }>;
19
+ }
20
+ export declare const PROVIDER_CONFIGS: ProviderConfig[];
21
+ export interface SetupResult {
22
+ selectedProviders: AIProviderName[];
23
+ credentials: Record<string, string>;
24
+ envFileBackup?: string;
25
+ testResults: Array<{
26
+ provider: AIProviderName;
27
+ status: "working" | "failed";
28
+ error?: string;
29
+ responseTime?: number;
30
+ }>;
31
+ }
32
+ /**
33
+ * Run the interactive setup wizard
34
+ */
35
+ export declare function runInteractiveSetup(quiet?: boolean): Promise<SetupResult>;
36
+ /**
37
+ * Test provider connectivity using existing logic
38
+ */
39
+ export declare function testProviderConnectivity(providers: AIProviderName[], quiet?: boolean): Promise<Array<{
40
+ provider: AIProviderName;
41
+ status: "working" | "failed";
42
+ error?: string;
43
+ responseTime?: number;
44
+ }>>;
45
+ /**
46
+ * Display setup summary
47
+ */
48
+ export declare function displaySetupSummary(result: SetupResult, quiet?: boolean): void;