@juspay/neurolink 1.2.4 → 1.3.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.
@@ -0,0 +1,280 @@
1
+ /**
2
+ * NeuroLink AI Core Server
3
+ * Wraps existing AI provider functionality as MCP tools for orchestration
4
+ * Integrates AIProviderFactory with Factory-First MCP architecture
5
+ */
6
+ import { z } from 'zod';
7
+ import { createMCPServer } from '../../factory.js';
8
+ import { AIProviderFactory } from '../../../core/factory.js';
9
+ import { getBestProvider, getAvailableProviders } from '../../../utils/providerUtils.js';
10
+ /**
11
+ * AI Core Server - Central hub for AI provider tools
12
+ * Provides text generation, provider selection, and AI capabilities
13
+ */
14
+ export const aiCoreServer = createMCPServer({
15
+ id: 'neurolink-ai-core',
16
+ title: 'NeuroLink AI Core',
17
+ description: 'Core AI provider tools with automatic fallback and orchestration',
18
+ category: 'ai-providers',
19
+ version: '1.0.0',
20
+ capabilities: [
21
+ 'text-generation',
22
+ 'provider-selection',
23
+ 'automatic-fallback',
24
+ 'usage-tracking',
25
+ 'multi-provider-support'
26
+ ]
27
+ });
28
+ /**
29
+ * Text Generation Input Schema
30
+ */
31
+ const TextGenerationSchema = z.object({
32
+ prompt: z.string().min(1, 'Prompt is required'),
33
+ provider: z.enum(['openai', 'bedrock', 'vertex', 'anthropic']).optional(),
34
+ model: z.string().optional(),
35
+ temperature: z.number().min(0).max(2).optional(),
36
+ maxTokens: z.number().positive().optional(),
37
+ systemPrompt: z.string().optional()
38
+ });
39
+ /**
40
+ * Provider Selection Input Schema
41
+ */
42
+ const ProviderSelectionSchema = z.object({
43
+ preferred: z.string().optional(),
44
+ requirements: z.object({
45
+ multimodal: z.boolean().optional(),
46
+ streaming: z.boolean().optional(),
47
+ maxTokens: z.number().optional(),
48
+ costEfficient: z.boolean().optional()
49
+ }).optional()
50
+ });
51
+ /**
52
+ * Register Text Generation Tool
53
+ * Core tool that leverages existing AIProviderFactory for text generation
54
+ */
55
+ aiCoreServer.registerTool({
56
+ name: 'generate-text',
57
+ description: 'Generate text using AI providers with automatic fallback and provider selection',
58
+ category: 'text-generation',
59
+ inputSchema: TextGenerationSchema,
60
+ isImplemented: true,
61
+ execute: async (params, context) => {
62
+ const startTime = Date.now();
63
+ try {
64
+ console.log(`[AI-Core] Starting text generation: "${params.prompt.substring(0, 50)}..."`);
65
+ // Use existing AIProviderFactory with best provider selection
66
+ const selectedProvider = params.provider || getBestProvider(params.provider);
67
+ const provider = AIProviderFactory.createBestProvider(selectedProvider);
68
+ // Generate text using existing NeuroLink patterns
69
+ const result = await provider.generateText({
70
+ prompt: params.prompt,
71
+ model: params.model,
72
+ temperature: params.temperature,
73
+ maxTokens: params.maxTokens,
74
+ systemPrompt: params.systemPrompt
75
+ });
76
+ if (!result) {
77
+ throw new Error('AI provider returned null result');
78
+ }
79
+ const executionTime = Date.now() - startTime;
80
+ console.log(`[AI-Core] Text generation successful in ${executionTime}ms using ${selectedProvider}`);
81
+ return {
82
+ success: true,
83
+ data: {
84
+ text: result.text,
85
+ model: params.model || 'default',
86
+ provider: selectedProvider,
87
+ generatedAt: new Date().toISOString()
88
+ },
89
+ usage: {
90
+ tokens: result.usage?.totalTokens,
91
+ provider: selectedProvider,
92
+ model: params.model || 'default',
93
+ executionTime
94
+ },
95
+ metadata: {
96
+ toolName: 'generate-text',
97
+ serverId: 'neurolink-ai-core',
98
+ sessionId: context.sessionId,
99
+ timestamp: Date.now(),
100
+ executionTime
101
+ }
102
+ };
103
+ }
104
+ catch (error) {
105
+ const executionTime = Date.now() - startTime;
106
+ const errorMessage = error instanceof Error ? error.message : String(error);
107
+ console.error(`[AI-Core] Text generation failed: ${errorMessage}`);
108
+ return {
109
+ success: false,
110
+ error: errorMessage,
111
+ metadata: {
112
+ toolName: 'generate-text',
113
+ serverId: 'neurolink-ai-core',
114
+ sessionId: context.sessionId,
115
+ timestamp: Date.now(),
116
+ executionTime
117
+ }
118
+ };
119
+ }
120
+ }
121
+ });
122
+ /**
123
+ * Register Provider Selection Tool
124
+ * Intelligent provider selection based on requirements and availability
125
+ */
126
+ aiCoreServer.registerTool({
127
+ name: 'select-provider',
128
+ description: 'Select the best available AI provider based on requirements and availability',
129
+ category: 'provider-management',
130
+ inputSchema: ProviderSelectionSchema,
131
+ isImplemented: true,
132
+ execute: async (params, context) => {
133
+ const startTime = Date.now();
134
+ try {
135
+ console.log(`[AI-Core] Selecting provider with requirements:`, params.requirements);
136
+ // Use existing provider selection logic
137
+ const availableProviders = getAvailableProviders();
138
+ const selectedProvider = getBestProvider(params.preferred);
139
+ // Get provider capabilities (mock for now, can be enhanced)
140
+ const getProviderCapabilities = (provider) => ({
141
+ multimodal: provider === 'openai' || provider === 'vertex',
142
+ streaming: provider === 'openai' || provider === 'anthropic',
143
+ maxTokens: provider === 'anthropic' ? 100000 : 4000,
144
+ costEfficient: provider === 'openai' || provider === 'vertex'
145
+ });
146
+ const capabilities = getProviderCapabilities(selectedProvider);
147
+ const executionTime = Date.now() - startTime;
148
+ console.log(`[AI-Core] Selected provider: ${selectedProvider} in ${executionTime}ms`);
149
+ return {
150
+ success: true,
151
+ data: {
152
+ provider: selectedProvider,
153
+ available: availableProviders,
154
+ capabilities,
155
+ reason: params.preferred
156
+ ? `Preferred provider ${params.preferred} selected`
157
+ : 'Best available provider selected',
158
+ selectedAt: new Date().toISOString()
159
+ },
160
+ usage: {
161
+ executionTime
162
+ },
163
+ metadata: {
164
+ toolName: 'select-provider',
165
+ serverId: 'neurolink-ai-core',
166
+ sessionId: context.sessionId,
167
+ timestamp: Date.now(),
168
+ executionTime
169
+ }
170
+ };
171
+ }
172
+ catch (error) {
173
+ const executionTime = Date.now() - startTime;
174
+ const errorMessage = error instanceof Error ? error.message : String(error);
175
+ console.error(`[AI-Core] Provider selection failed: ${errorMessage}`);
176
+ return {
177
+ success: false,
178
+ error: errorMessage,
179
+ metadata: {
180
+ toolName: 'select-provider',
181
+ serverId: 'neurolink-ai-core',
182
+ sessionId: context.sessionId,
183
+ timestamp: Date.now(),
184
+ executionTime
185
+ }
186
+ };
187
+ }
188
+ }
189
+ });
190
+ /**
191
+ * Register Provider Status Tool
192
+ * Check health and availability of AI providers
193
+ */
194
+ aiCoreServer.registerTool({
195
+ name: 'check-provider-status',
196
+ description: 'Check the health and availability status of AI providers',
197
+ category: 'provider-management',
198
+ inputSchema: z.object({
199
+ provider: z.string().optional(),
200
+ includeCapabilities: z.boolean().default(true)
201
+ }),
202
+ isImplemented: true,
203
+ execute: async (params, context) => {
204
+ const startTime = Date.now();
205
+ try {
206
+ console.log(`[AI-Core] Checking provider status for: ${params.provider || 'all providers'}`);
207
+ const availableProviders = getAvailableProviders();
208
+ const providerStatuses = [];
209
+ const providersToCheck = params.provider ? [params.provider] : availableProviders;
210
+ for (const provider of providersToCheck) {
211
+ try {
212
+ // Quick health check (can be enhanced with actual API calls)
213
+ const isAvailable = availableProviders.includes(provider);
214
+ providerStatuses.push({
215
+ provider,
216
+ status: isAvailable ? 'available' : 'unavailable',
217
+ capabilities: params.includeCapabilities ? {
218
+ textGeneration: true,
219
+ multimodal: provider === 'openai' || provider === 'vertex',
220
+ streaming: provider === 'openai' || provider === 'anthropic',
221
+ maxTokens: provider === 'anthropic' ? 100000 : 4000
222
+ } : undefined,
223
+ lastChecked: new Date().toISOString()
224
+ });
225
+ }
226
+ catch (error) {
227
+ providerStatuses.push({
228
+ provider,
229
+ status: 'error',
230
+ error: error instanceof Error ? error.message : String(error),
231
+ lastChecked: new Date().toISOString()
232
+ });
233
+ }
234
+ }
235
+ const executionTime = Date.now() - startTime;
236
+ console.log(`[AI-Core] Provider status check completed in ${executionTime}ms`);
237
+ return {
238
+ success: true,
239
+ data: {
240
+ providers: providerStatuses,
241
+ summary: {
242
+ total: providerStatuses.length,
243
+ available: providerStatuses.filter(p => p.status === 'available').length,
244
+ unavailable: providerStatuses.filter(p => p.status === 'unavailable').length,
245
+ errors: providerStatuses.filter(p => p.status === 'error').length
246
+ },
247
+ checkedAt: new Date().toISOString()
248
+ },
249
+ usage: {
250
+ executionTime
251
+ },
252
+ metadata: {
253
+ toolName: 'check-provider-status',
254
+ serverId: 'neurolink-ai-core',
255
+ sessionId: context.sessionId,
256
+ timestamp: Date.now(),
257
+ executionTime
258
+ }
259
+ };
260
+ }
261
+ catch (error) {
262
+ const executionTime = Date.now() - startTime;
263
+ const errorMessage = error instanceof Error ? error.message : String(error);
264
+ console.error(`[AI-Core] Provider status check failed: ${errorMessage}`);
265
+ return {
266
+ success: false,
267
+ error: errorMessage,
268
+ metadata: {
269
+ toolName: 'check-provider-status',
270
+ serverId: 'neurolink-ai-core',
271
+ sessionId: context.sessionId,
272
+ timestamp: Date.now(),
273
+ executionTime
274
+ }
275
+ };
276
+ }
277
+ }
278
+ });
279
+ // Log successful server creation
280
+ console.log('[AI-Core] NeuroLink AI Core Server created with tools:', Object.keys(aiCoreServer.tools));
@@ -12,7 +12,7 @@ export function getBestProvider(requestedProvider) {
12
12
  return requestedProvider;
13
13
  }
14
14
  // Default fallback order based on environment variables - OpenAI first since it's most reliable
15
- const providers = ['openai', 'vertex', 'bedrock'];
15
+ const providers = ['openai', 'vertex', 'bedrock', 'anthropic', 'azure'];
16
16
  // Check which providers have their required environment variables
17
17
  for (const provider of providers) {
18
18
  if (isProviderConfigured(provider)) {
@@ -42,6 +42,12 @@ function isProviderConfigured(provider) {
42
42
  case 'openai':
43
43
  case 'gpt':
44
44
  return !!process.env.OPENAI_API_KEY;
45
+ case 'anthropic':
46
+ case 'claude':
47
+ return !!process.env.ANTHROPIC_API_KEY;
48
+ case 'azure':
49
+ case 'azure-openai':
50
+ return !!process.env.AZURE_OPENAI_API_KEY;
45
51
  default:
46
52
  return false;
47
53
  }
@@ -51,7 +57,7 @@ function isProviderConfigured(provider) {
51
57
  * @returns Array of available provider names
52
58
  */
53
59
  export function getAvailableProviders() {
54
- return ['bedrock', 'vertex', 'openai'];
60
+ return ['bedrock', 'vertex', 'openai', 'anthropic', 'azure'];
55
61
  }
56
62
  /**
57
63
  * Validate provider name
package/package.json CHANGED
@@ -1,13 +1,38 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "1.2.4",
4
- "description": "AI toolkit with multi-provider support for OpenAI, Amazon Bedrock, and Google Vertex AI",
5
- "author": "Juspay Technologies",
3
+ "version": "1.3.0",
4
+ "description": "Universal AI Development Platform with external MCP server integration, multi-provider support, and professional CLI. Connect to 65+ MCP servers for filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with OpenAI, Anthropic, Google Vertex AI, and AWS Bedrock.",
5
+ "author": {
6
+ "name": "Juspay Technologies",
7
+ "email": "support@juspay.in",
8
+ "url": "https://juspay.io"
9
+ },
6
10
  "license": "MIT",
11
+ "homepage": "https://github.com/juspay/neurolink#readme",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/juspay/neurolink.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/juspay/neurolink/issues"
18
+ },
19
+ "funding": {
20
+ "type": "individual",
21
+ "url": "https://github.com/sponsors/juspay"
22
+ },
23
+ "engines": {
24
+ "node": ">=18.0.0",
25
+ "npm": ">=8.0.0",
26
+ "pnpm": ">=8.0.0"
27
+ },
7
28
  "files": [
8
29
  "dist",
9
30
  "!dist/**/*.test.*",
10
- "!dist/**/*.spec.*"
31
+ "!dist/**/*.spec.*",
32
+ "!dist/**/*.map",
33
+ "README.md",
34
+ "CHANGELOG.md",
35
+ "LICENSE"
11
36
  ],
12
37
  "sideEffects": [
13
38
  "**/*.css"
@@ -25,6 +50,12 @@
25
50
  "svelte": "./dist/index.js",
26
51
  "import": "./dist/index.js",
27
52
  "default": "./dist/index.js"
53
+ },
54
+ "./package.json": "./package.json",
55
+ "./cli": {
56
+ "types": "./dist/cli/index.d.ts",
57
+ "import": "./dist/cli/index.js",
58
+ "default": "./dist/cli/index.js"
28
59
  }
29
60
  },
30
61
  "peerDependencies": {
@@ -34,6 +65,17 @@
34
65
  "ai": "^4.0.0",
35
66
  "zod": "^3.22.0"
36
67
  },
68
+ "peerDependenciesMeta": {
69
+ "@ai-sdk/amazon-bedrock": {
70
+ "optional": true
71
+ },
72
+ "@ai-sdk/google-vertex": {
73
+ "optional": true
74
+ },
75
+ "@ai-sdk/openai": {
76
+ "optional": true
77
+ }
78
+ },
37
79
  "dependencies": {
38
80
  "chalk": "^5.3.0",
39
81
  "dotenv": "^16.5.0",
@@ -65,6 +107,11 @@
65
107
  "keywords": [
66
108
  "ai",
67
109
  "llm",
110
+ "mcp",
111
+ "model-context-protocol",
112
+ "lighthouse",
113
+ "tool-orchestration",
114
+ "ai-platform",
68
115
  "openai",
69
116
  "anthropic",
70
117
  "google",
@@ -74,12 +121,35 @@
74
121
  "tools",
75
122
  "neurolink",
76
123
  "juspay",
77
- "svelte"
124
+ "svelte",
125
+ "chatgpt",
126
+ "gpt-4",
127
+ "claude",
128
+ "gemini",
129
+ "ai-sdk",
130
+ "typescript",
131
+ "cli-tool",
132
+ "developer-tools",
133
+ "automation",
134
+ "machine-learning",
135
+ "artificial-intelligence",
136
+ "multi-provider",
137
+ "ai-agents",
138
+ "prompt-engineering",
139
+ "ai-workflow",
140
+ "universal-ai",
141
+ "ai-development",
142
+ "llm-integration"
143
+ ],
144
+ "os": [
145
+ "darwin",
146
+ "linux",
147
+ "win32"
78
148
  ],
79
149
  "scripts": {
80
150
  "dev": "vite dev",
81
151
  "build": "vite build && pnpm run prepack",
82
- "build:cli": "echo 'Building CLI...' && tsc src/cli/index.ts --outDir dist/cli --target es2022 --module esnext --moduleResolution bundler --allowImportingTsExtensions false --resolveJsonModule --esModuleInterop --allowSyntheticDefaultImports --strict --rootDir src/cli",
152
+ "build:cli": "echo 'Building CLI...' && tsc --project tsconfig.cli.json",
83
153
  "cli": "node dist/cli/index.js",
84
154
  "preview": "vite preview",
85
155
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",