@juspay/neurolink 6.0.0 → 6.2.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 (283) hide show
  1. package/CHANGELOG.md +14 -3
  2. package/dist/cli/commands/config.d.ts +13 -13
  3. package/dist/cli/index.js +3 -9
  4. package/dist/core/analytics.d.ts +11 -1
  5. package/dist/core/analytics.js +2 -2
  6. package/dist/core/base-provider.js +4 -18
  7. package/dist/core/dynamic-models.d.ts +8 -8
  8. package/dist/core/factory.js +3 -11
  9. package/dist/index.d.ts +2 -4
  10. package/dist/index.js +2 -11
  11. package/dist/lib/core/analytics.d.ts +11 -1
  12. package/dist/lib/core/analytics.js +2 -2
  13. package/dist/lib/core/base-provider.js +4 -18
  14. package/dist/lib/core/dynamic-models.d.ts +8 -8
  15. package/dist/lib/core/factory.js +3 -11
  16. package/dist/lib/index.d.ts +2 -4
  17. package/dist/lib/index.js +2 -11
  18. package/dist/lib/mcp/factory.d.ts +1 -1
  19. package/dist/lib/mcp/index.d.ts +7 -19
  20. package/dist/lib/mcp/index.js +15 -56
  21. package/dist/lib/neurolink.d.ts +1 -9
  22. package/dist/lib/neurolink.js +21 -70
  23. package/dist/lib/providers/amazon-bedrock.js +5 -16
  24. package/dist/lib/providers/anthropic-baseprovider.js +3 -21
  25. package/dist/lib/providers/anthropic.js +4 -7
  26. package/dist/lib/providers/azure-openai.js +4 -2
  27. package/dist/lib/providers/google-vertex.js +5 -9
  28. package/dist/lib/providers/huggingFace.js +5 -10
  29. package/dist/lib/providers/mistral.js +5 -8
  30. package/dist/lib/providers/openAI.js +4 -7
  31. package/dist/lib/utils/providerConfig.d.ts +117 -0
  32. package/dist/lib/utils/providerConfig.js +353 -0
  33. package/dist/lib/utils/providerUtils.d.ts +2 -1
  34. package/dist/lib/utils/providerUtils.js +53 -36
  35. package/dist/lib/utils/timeout.d.ts +72 -1
  36. package/dist/lib/utils/timeout.js +203 -2
  37. package/dist/mcp/factory.d.ts +1 -1
  38. package/dist/mcp/index.d.ts +7 -19
  39. package/dist/mcp/index.js +15 -56
  40. package/dist/neurolink.d.ts +1 -9
  41. package/dist/neurolink.js +21 -70
  42. package/dist/providers/amazon-bedrock.js +5 -16
  43. package/dist/providers/anthropic-baseprovider.js +3 -21
  44. package/dist/providers/anthropic.js +4 -7
  45. package/dist/providers/azure-openai.js +4 -2
  46. package/dist/providers/google-vertex.js +5 -9
  47. package/dist/providers/huggingFace.js +5 -10
  48. package/dist/providers/mistral.js +5 -8
  49. package/dist/providers/openAI.js +4 -7
  50. package/dist/utils/providerConfig.d.ts +117 -0
  51. package/dist/utils/providerConfig.js +353 -0
  52. package/dist/utils/providerUtils.d.ts +2 -1
  53. package/dist/utils/providerUtils.js +53 -36
  54. package/dist/utils/timeout.d.ts +72 -1
  55. package/dist/utils/timeout.js +203 -2
  56. package/package.json +2 -1
  57. package/dist/chat/client-utils.d.ts +0 -95
  58. package/dist/chat/client-utils.js +0 -315
  59. package/dist/chat/index.d.ts +0 -24
  60. package/dist/chat/index.js +0 -33
  61. package/dist/chat/session-storage.d.ts +0 -77
  62. package/dist/chat/session-storage.js +0 -233
  63. package/dist/chat/session.d.ts +0 -96
  64. package/dist/chat/session.js +0 -257
  65. package/dist/chat/sse-handler.d.ts +0 -49
  66. package/dist/chat/sse-handler.js +0 -259
  67. package/dist/chat/types.d.ts +0 -74
  68. package/dist/chat/types.js +0 -5
  69. package/dist/chat/websocket-chat-handler.d.ts +0 -37
  70. package/dist/chat/websocket-chat-handler.js +0 -262
  71. package/dist/cli/commands/mcp.d.ts +0 -20
  72. package/dist/cli/commands/mcp.js +0 -1272
  73. package/dist/core/defaults.d.ts +0 -19
  74. package/dist/core/defaults.js +0 -29
  75. package/dist/core/evaluation-config.d.ts +0 -29
  76. package/dist/core/evaluation-config.js +0 -144
  77. package/dist/factories/compatibility-factory.d.ts +0 -35
  78. package/dist/factories/compatibility-factory.js +0 -71
  79. package/dist/factories/provider-generate-factory.d.ts +0 -20
  80. package/dist/factories/provider-generate-factory.js +0 -93
  81. package/dist/lib/chat/client-utils.d.ts +0 -95
  82. package/dist/lib/chat/client-utils.js +0 -315
  83. package/dist/lib/chat/index.d.ts +0 -24
  84. package/dist/lib/chat/index.js +0 -33
  85. package/dist/lib/chat/session-storage.d.ts +0 -77
  86. package/dist/lib/chat/session-storage.js +0 -233
  87. package/dist/lib/chat/session.d.ts +0 -96
  88. package/dist/lib/chat/session.js +0 -257
  89. package/dist/lib/chat/sse-handler.d.ts +0 -49
  90. package/dist/lib/chat/sse-handler.js +0 -259
  91. package/dist/lib/chat/types.d.ts +0 -74
  92. package/dist/lib/chat/types.js +0 -5
  93. package/dist/lib/chat/websocket-chat-handler.d.ts +0 -37
  94. package/dist/lib/chat/websocket-chat-handler.js +0 -262
  95. package/dist/lib/core/defaults.d.ts +0 -19
  96. package/dist/lib/core/defaults.js +0 -29
  97. package/dist/lib/core/evaluation-config.d.ts +0 -29
  98. package/dist/lib/core/evaluation-config.js +0 -144
  99. package/dist/lib/factories/compatibility-factory.d.ts +0 -35
  100. package/dist/lib/factories/compatibility-factory.js +0 -71
  101. package/dist/lib/factories/provider-generate-factory.d.ts +0 -20
  102. package/dist/lib/factories/provider-generate-factory.js +0 -93
  103. package/dist/lib/mcp/adapters/plugin-bridge.d.ts +0 -40
  104. package/dist/lib/mcp/adapters/plugin-bridge.js +0 -89
  105. package/dist/lib/mcp/auto-discovery.d.ts +0 -62
  106. package/dist/lib/mcp/auto-discovery.js +0 -149
  107. package/dist/lib/mcp/client.d.ts +0 -68
  108. package/dist/lib/mcp/client.js +0 -248
  109. package/dist/lib/mcp/config.d.ts +0 -31
  110. package/dist/lib/mcp/config.js +0 -99
  111. package/dist/lib/mcp/context-manager.d.ts +0 -171
  112. package/dist/lib/mcp/context-manager.js +0 -362
  113. package/dist/lib/mcp/contracts/mcp-contract.d.ts +0 -169
  114. package/dist/lib/mcp/contracts/mcp-contract.js +0 -58
  115. package/dist/lib/mcp/core/plugin-manager.d.ts +0 -46
  116. package/dist/lib/mcp/core/plugin-manager.js +0 -110
  117. package/dist/lib/mcp/demo/plugin-demo.d.ts +0 -20
  118. package/dist/lib/mcp/demo/plugin-demo.js +0 -118
  119. package/dist/lib/mcp/dynamic-chain-executor.d.ts +0 -225
  120. package/dist/lib/mcp/dynamic-chain-executor.js +0 -489
  121. package/dist/lib/mcp/dynamic-orchestrator.d.ts +0 -115
  122. package/dist/lib/mcp/dynamic-orchestrator.js +0 -351
  123. package/dist/lib/mcp/ecosystem.d.ts +0 -75
  124. package/dist/lib/mcp/ecosystem.js +0 -161
  125. package/dist/lib/mcp/error-manager.d.ts +0 -254
  126. package/dist/lib/mcp/error-manager.js +0 -501
  127. package/dist/lib/mcp/error-recovery.d.ts +0 -159
  128. package/dist/lib/mcp/error-recovery.js +0 -405
  129. package/dist/lib/mcp/external-client.d.ts +0 -88
  130. package/dist/lib/mcp/external-client.js +0 -331
  131. package/dist/lib/mcp/external-manager.d.ts +0 -112
  132. package/dist/lib/mcp/external-manager.js +0 -308
  133. package/dist/lib/mcp/function-calling.d.ts +0 -65
  134. package/dist/lib/mcp/function-calling.js +0 -642
  135. package/dist/lib/mcp/health-monitor.d.ts +0 -257
  136. package/dist/lib/mcp/health-monitor.js +0 -630
  137. package/dist/lib/mcp/initialize-tools.d.ts +0 -29
  138. package/dist/lib/mcp/initialize-tools.js +0 -261
  139. package/dist/lib/mcp/initialize.d.ts +0 -18
  140. package/dist/lib/mcp/initialize.js +0 -62
  141. package/dist/lib/mcp/manager.d.ts +0 -68
  142. package/dist/lib/mcp/manager.js +0 -176
  143. package/dist/lib/mcp/neurolink-mcp-client.d.ts +0 -97
  144. package/dist/lib/mcp/neurolink-mcp-client.js +0 -462
  145. package/dist/lib/mcp/orchestrator.d.ts +0 -302
  146. package/dist/lib/mcp/orchestrator.js +0 -703
  147. package/dist/lib/mcp/plugin-manager.d.ts +0 -98
  148. package/dist/lib/mcp/plugin-manager.js +0 -296
  149. package/dist/lib/mcp/plugins/core/filesystem-mcp.d.ts +0 -36
  150. package/dist/lib/mcp/plugins/core/filesystem-mcp.js +0 -142
  151. package/dist/lib/mcp/plugins/filesystem-mcp.d.ts +0 -37
  152. package/dist/lib/mcp/plugins/filesystem-mcp.js +0 -54
  153. package/dist/lib/mcp/security-manager.d.ts +0 -87
  154. package/dist/lib/mcp/security-manager.js +0 -344
  155. package/dist/lib/mcp/semaphore-manager.d.ts +0 -137
  156. package/dist/lib/mcp/semaphore-manager.js +0 -329
  157. package/dist/lib/mcp/session-manager.d.ts +0 -187
  158. package/dist/lib/mcp/session-manager.js +0 -400
  159. package/dist/lib/mcp/session-persistence.d.ts +0 -93
  160. package/dist/lib/mcp/session-persistence.js +0 -301
  161. package/dist/lib/mcp/tool-integration.d.ts +0 -58
  162. package/dist/lib/mcp/tool-integration.js +0 -203
  163. package/dist/lib/mcp/transport-manager.d.ts +0 -154
  164. package/dist/lib/mcp/transport-manager.js +0 -334
  165. package/dist/lib/mcp/unified-mcp.d.ts +0 -133
  166. package/dist/lib/mcp/unified-mcp.js +0 -251
  167. package/dist/lib/mcp/unified-registry.d.ts +0 -165
  168. package/dist/lib/mcp/unified-registry.js +0 -538
  169. package/dist/lib/providers/analytics-helper.d.ts +0 -38
  170. package/dist/lib/providers/analytics-helper.js +0 -216
  171. package/dist/lib/providers/function-calling-provider.d.ts +0 -142
  172. package/dist/lib/providers/function-calling-provider.js +0 -630
  173. package/dist/lib/providers/mcp-provider.d.ts +0 -75
  174. package/dist/lib/providers/mcp-provider.js +0 -283
  175. package/dist/lib/providers/timeout-wrapper.d.ts +0 -40
  176. package/dist/lib/providers/timeout-wrapper.js +0 -100
  177. package/dist/lib/sdk/tool-extension.d.ts +0 -181
  178. package/dist/lib/sdk/tool-extension.js +0 -284
  179. package/dist/lib/services/streaming/streaming-manager.d.ts +0 -29
  180. package/dist/lib/services/streaming/streaming-manager.js +0 -245
  181. package/dist/lib/services/types.d.ts +0 -156
  182. package/dist/lib/services/types.js +0 -2
  183. package/dist/lib/services/websocket/websocket-server.d.ts +0 -34
  184. package/dist/lib/services/websocket/websocket-server.js +0 -305
  185. package/dist/lib/utils/provider-validation.d.ts +0 -36
  186. package/dist/lib/utils/provider-validation.js +0 -625
  187. package/dist/lib/utils/providerUtils-fixed.d.ts +0 -8
  188. package/dist/lib/utils/providerUtils-fixed.js +0 -94
  189. package/dist/lib/utils/streaming-utils.d.ts +0 -79
  190. package/dist/lib/utils/streaming-utils.js +0 -198
  191. package/dist/lib/utils/timeout-manager.d.ts +0 -75
  192. package/dist/lib/utils/timeout-manager.js +0 -244
  193. package/dist/mcp/adapters/plugin-bridge.d.ts +0 -40
  194. package/dist/mcp/adapters/plugin-bridge.js +0 -89
  195. package/dist/mcp/auto-discovery.d.ts +0 -62
  196. package/dist/mcp/auto-discovery.js +0 -149
  197. package/dist/mcp/client.d.ts +0 -68
  198. package/dist/mcp/client.js +0 -248
  199. package/dist/mcp/config.d.ts +0 -31
  200. package/dist/mcp/config.js +0 -99
  201. package/dist/mcp/context-manager.d.ts +0 -171
  202. package/dist/mcp/context-manager.js +0 -362
  203. package/dist/mcp/contracts/mcp-contract.d.ts +0 -169
  204. package/dist/mcp/contracts/mcp-contract.js +0 -58
  205. package/dist/mcp/core/plugin-manager.d.ts +0 -46
  206. package/dist/mcp/core/plugin-manager.js +0 -110
  207. package/dist/mcp/demo/plugin-demo.d.ts +0 -20
  208. package/dist/mcp/demo/plugin-demo.js +0 -118
  209. package/dist/mcp/dynamic-chain-executor.d.ts +0 -225
  210. package/dist/mcp/dynamic-chain-executor.js +0 -489
  211. package/dist/mcp/dynamic-orchestrator.d.ts +0 -115
  212. package/dist/mcp/dynamic-orchestrator.js +0 -351
  213. package/dist/mcp/ecosystem.d.ts +0 -75
  214. package/dist/mcp/ecosystem.js +0 -162
  215. package/dist/mcp/error-manager.d.ts +0 -254
  216. package/dist/mcp/error-manager.js +0 -501
  217. package/dist/mcp/error-recovery.d.ts +0 -159
  218. package/dist/mcp/error-recovery.js +0 -405
  219. package/dist/mcp/external-client.d.ts +0 -88
  220. package/dist/mcp/external-client.js +0 -331
  221. package/dist/mcp/external-manager.d.ts +0 -112
  222. package/dist/mcp/external-manager.js +0 -308
  223. package/dist/mcp/function-calling.d.ts +0 -65
  224. package/dist/mcp/function-calling.js +0 -642
  225. package/dist/mcp/health-monitor.d.ts +0 -257
  226. package/dist/mcp/health-monitor.js +0 -630
  227. package/dist/mcp/initialize-tools.d.ts +0 -29
  228. package/dist/mcp/initialize-tools.js +0 -262
  229. package/dist/mcp/initialize.d.ts +0 -18
  230. package/dist/mcp/initialize.js +0 -62
  231. package/dist/mcp/manager.d.ts +0 -68
  232. package/dist/mcp/manager.js +0 -176
  233. package/dist/mcp/neurolink-mcp-client.d.ts +0 -97
  234. package/dist/mcp/neurolink-mcp-client.js +0 -462
  235. package/dist/mcp/orchestrator.d.ts +0 -302
  236. package/dist/mcp/orchestrator.js +0 -703
  237. package/dist/mcp/plugin-manager.d.ts +0 -98
  238. package/dist/mcp/plugin-manager.js +0 -297
  239. package/dist/mcp/plugins/core/filesystem-mcp.d.ts +0 -36
  240. package/dist/mcp/plugins/core/filesystem-mcp.js +0 -142
  241. package/dist/mcp/plugins/core/neurolink-mcp.json +0 -17
  242. package/dist/mcp/plugins/filesystem-mcp.d.ts +0 -37
  243. package/dist/mcp/plugins/filesystem-mcp.js +0 -54
  244. package/dist/mcp/security-manager.d.ts +0 -87
  245. package/dist/mcp/security-manager.js +0 -344
  246. package/dist/mcp/semaphore-manager.d.ts +0 -137
  247. package/dist/mcp/semaphore-manager.js +0 -329
  248. package/dist/mcp/session-manager.d.ts +0 -187
  249. package/dist/mcp/session-manager.js +0 -400
  250. package/dist/mcp/session-persistence.d.ts +0 -93
  251. package/dist/mcp/session-persistence.js +0 -302
  252. package/dist/mcp/tool-integration.d.ts +0 -58
  253. package/dist/mcp/tool-integration.js +0 -203
  254. package/dist/mcp/transport-manager.d.ts +0 -154
  255. package/dist/mcp/transport-manager.js +0 -335
  256. package/dist/mcp/unified-mcp.d.ts +0 -133
  257. package/dist/mcp/unified-mcp.js +0 -251
  258. package/dist/mcp/unified-registry.d.ts +0 -165
  259. package/dist/mcp/unified-registry.js +0 -539
  260. package/dist/providers/analytics-helper.d.ts +0 -38
  261. package/dist/providers/analytics-helper.js +0 -216
  262. package/dist/providers/function-calling-provider.d.ts +0 -142
  263. package/dist/providers/function-calling-provider.js +0 -630
  264. package/dist/providers/mcp-provider.d.ts +0 -75
  265. package/dist/providers/mcp-provider.js +0 -283
  266. package/dist/providers/timeout-wrapper.d.ts +0 -40
  267. package/dist/providers/timeout-wrapper.js +0 -100
  268. package/dist/sdk/tool-extension.d.ts +0 -181
  269. package/dist/sdk/tool-extension.js +0 -284
  270. package/dist/services/streaming/streaming-manager.d.ts +0 -29
  271. package/dist/services/streaming/streaming-manager.js +0 -245
  272. package/dist/services/types.d.ts +0 -156
  273. package/dist/services/types.js +0 -2
  274. package/dist/services/websocket/websocket-server.d.ts +0 -34
  275. package/dist/services/websocket/websocket-server.js +0 -306
  276. package/dist/utils/provider-validation.d.ts +0 -36
  277. package/dist/utils/provider-validation.js +0 -625
  278. package/dist/utils/providerUtils-fixed.d.ts +0 -8
  279. package/dist/utils/providerUtils-fixed.js +0 -94
  280. package/dist/utils/streaming-utils.d.ts +0 -79
  281. package/dist/utils/streaming-utils.js +0 -198
  282. package/dist/utils/timeout-manager.d.ts +0 -75
  283. package/dist/utils/timeout-manager.js +0 -244
@@ -1,40 +0,0 @@
1
- /**
2
- * Plugin Bridge Adapter
3
- * Provides compatibility layer for existing MCP integrations
4
- */
5
- import type { ExecutionContext } from "../contracts/mcp-contract.js";
6
- import type { JsonValue, UnknownRecord, Unknown } from "../../types/common.js";
7
- /**
8
- * Bridge interface for legacy MCP compatibility
9
- */
10
- export interface LegacyMCPBridge {
11
- writeFile: (filePath: string, content: string) => Promise<void>;
12
- readFile: (filePath: string) => Promise<string>;
13
- listFiles: (dirPath: string) => Promise<string[]>;
14
- }
15
- /**
16
- * Create a bridge for legacy MCP integrations
17
- */
18
- export declare function createLegacyBridge(context: ExecutionContext): LegacyMCPBridge;
19
- /**
20
- * Enhanced execution context with bridge compatibility
21
- */
22
- export declare function enhanceExecutionContext(context: ExecutionContext): ExecutionContext;
23
- /**
24
- * Utility function to adapt legacy MCP calls
25
- */
26
- export declare function adaptLegacyMCPCall(context: ExecutionContext, operation: string, ...args: JsonValue[]): Promise<Unknown>;
27
- /**
28
- * Quick plugin factory for simple plugin creation
29
- */
30
- export declare class QuickPluginFactory {
31
- static create(name: string, config: UnknownRecord): Promise<{
32
- name: string;
33
- config: UnknownRecord;
34
- initialized: boolean;
35
- }>;
36
- }
37
- /**
38
- * Execute plugin with enhanced context
39
- */
40
- export declare function executePlugin(plugin: UnknownRecord, context: ExecutionContext, operation: string, ...args: JsonValue[]): Promise<Unknown>;
@@ -1,89 +0,0 @@
1
- /**
2
- * Plugin Bridge Adapter
3
- * Provides compatibility layer for existing MCP integrations
4
- */
5
- import * as path from "path";
6
- /**
7
- * Create a bridge for legacy MCP integrations
8
- */
9
- export function createLegacyBridge(context) {
10
- const basePath = process.cwd();
11
- return {
12
- async writeFile(filePath, content) {
13
- const fullPath = path.resolve(basePath, filePath);
14
- await context.secureFS.writeFile(fullPath, content);
15
- },
16
- async readFile(filePath) {
17
- const fullPath = path.resolve(basePath, filePath);
18
- const result = await context.secureFS.readFile(fullPath, "utf-8");
19
- return typeof result === "string" ? result : result.toString();
20
- },
21
- async listFiles(dirPath) {
22
- const fullPath = path.resolve(basePath, dirPath);
23
- return await context.secureFS.readdir(fullPath);
24
- },
25
- };
26
- }
27
- /**
28
- * Enhanced execution context with bridge compatibility
29
- */
30
- export function enhanceExecutionContext(context) {
31
- return {
32
- ...context,
33
- path: {
34
- join: path.join,
35
- resolve: path.resolve,
36
- relative: path.relative,
37
- dirname: path.dirname,
38
- basename: path.basename,
39
- },
40
- plugin: createLegacyBridge(context),
41
- };
42
- }
43
- /**
44
- * Utility function to adapt legacy MCP calls
45
- */
46
- export async function adaptLegacyMCPCall(context, operation, ...args) {
47
- const bridge = createLegacyBridge(context);
48
- switch (operation) {
49
- case "writeFile": {
50
- const filePath = typeof args[0] === "string" ? args[0] : String(args[0]);
51
- const content = typeof args[1] === "string" ? args[1] : String(args[1]);
52
- return bridge.writeFile(filePath, content);
53
- }
54
- case "readFile": {
55
- const readPath = typeof args[0] === "string" ? args[0] : String(args[0]);
56
- return bridge.readFile(readPath);
57
- }
58
- case "listFiles": {
59
- const listPath = typeof args[0] === "string" ? args[0] : String(args[0]);
60
- return bridge.listFiles(listPath);
61
- }
62
- default:
63
- throw new Error(`Unsupported legacy operation: ${operation}`);
64
- }
65
- }
66
- /**
67
- * Quick plugin factory for simple plugin creation
68
- */
69
- export class QuickPluginFactory {
70
- static async create(name, config) {
71
- // Simple factory implementation
72
- return {
73
- name,
74
- config,
75
- initialized: true,
76
- };
77
- }
78
- }
79
- /**
80
- * Execute plugin with enhanced context
81
- */
82
- export async function executePlugin(plugin, context, operation, ...args) {
83
- const enhancedContext = enhanceExecutionContext(context);
84
- if (typeof plugin.execute === "function") {
85
- return plugin.execute(enhancedContext, { operation, args });
86
- }
87
- // Fallback to legacy adaptation
88
- return adaptLegacyMCPCall(enhancedContext, operation, ...args);
89
- }
@@ -1,62 +0,0 @@
1
- /**
2
- * Auto-Discovery Module for MCP Plugins
3
- * Handles automatic plugin discovery and registration
4
- */
5
- import type { DiscoveredMCP } from "./contracts/mcp-contract.js";
6
- /**
7
- * Auto-discovery configuration
8
- */
9
- interface AutoDiscoveryConfig {
10
- searchPaths: string[];
11
- manifestName: string;
12
- maxDepth: number;
13
- }
14
- /**
15
- * Auto-discovery service for MCP plugins
16
- */
17
- export declare class AutoDiscovery {
18
- private config;
19
- constructor(config?: Partial<AutoDiscoveryConfig>);
20
- /**
21
- * Discover all available MCP plugins
22
- */
23
- discover(): Promise<DiscoveredMCP[]>;
24
- /**
25
- * Discover plugins in a specific path
26
- */
27
- private discoverInPath;
28
- /**
29
- * Load plugin from manifest
30
- */
31
- private loadPlugin;
32
- /**
33
- * Determine plugin source based on path
34
- */
35
- private determineSource;
36
- }
37
- /**
38
- * Default auto-discovery instance
39
- */
40
- export declare const autoDiscovery: AutoDiscovery;
41
- /**
42
- * Discovery options interface
43
- */
44
- export interface DiscoveryOptions {
45
- searchPaths?: string[];
46
- manifestName?: string;
47
- maxDepth?: number;
48
- includeDevPlugins?: boolean;
49
- }
50
- /**
51
- * Discover MCP servers using auto-discovery
52
- */
53
- export declare function discoverMCPServers(options?: DiscoveryOptions): Promise<DiscoveredMCP[]>;
54
- /**
55
- * Auto-register discovered MCP servers
56
- */
57
- export declare function autoRegisterMCPServers(options?: DiscoveryOptions): Promise<{
58
- registered: number;
59
- failed: number;
60
- plugins: DiscoveredMCP[];
61
- }>;
62
- export {};
@@ -1,149 +0,0 @@
1
- /**
2
- * Auto-Discovery Module for MCP Plugins
3
- * Handles automatic plugin discovery and registration
4
- */
5
- import * as fs from "fs/promises";
6
- import * as path from "path";
7
- import { autoDiscoveryLogger } from "./logging.js";
8
- /**
9
- * Default auto-discovery configuration
10
- */
11
- const DEFAULT_CONFIG = {
12
- searchPaths: ["./src/lib/mcp/plugins", "./neurolink-mcp", "./node_modules"],
13
- manifestName: "neurolink-mcp.json",
14
- maxDepth: 3,
15
- };
16
- /**
17
- * Auto-discovery service for MCP plugins
18
- */
19
- export class AutoDiscovery {
20
- config;
21
- constructor(config = {}) {
22
- this.config = { ...DEFAULT_CONFIG, ...config };
23
- }
24
- /**
25
- * Discover all available MCP plugins
26
- */
27
- async discover() {
28
- const discovered = [];
29
- for (const searchPath of this.config.searchPaths) {
30
- try {
31
- const plugins = await this.discoverInPath(searchPath);
32
- discovered.push(...plugins);
33
- }
34
- catch (error) {
35
- autoDiscoveryLogger.debug(`Failed to discover in ${searchPath}:`, error);
36
- }
37
- }
38
- autoDiscoveryLogger.info(`Auto-discovery completed: ${discovered.length} plugins found`);
39
- return discovered;
40
- }
41
- /**
42
- * Discover plugins in a specific path
43
- */
44
- async discoverInPath(basePath, depth = 0) {
45
- if (depth > this.config.maxDepth) {
46
- return [];
47
- }
48
- const discovered = [];
49
- try {
50
- const items = await fs.readdir(basePath);
51
- for (const item of items) {
52
- const itemPath = path.join(basePath, item);
53
- const stats = await fs.stat(itemPath);
54
- if (stats.isDirectory()) {
55
- // Check for manifest in this directory
56
- const manifestPath = path.join(itemPath, this.config.manifestName);
57
- try {
58
- await fs.access(manifestPath);
59
- const plugin = await this.loadPlugin(manifestPath, itemPath);
60
- if (plugin) {
61
- discovered.push(plugin);
62
- }
63
- }
64
- catch {
65
- // No manifest, continue searching subdirectories
66
- const subPlugins = await this.discoverInPath(itemPath, depth + 1);
67
- discovered.push(...subPlugins);
68
- }
69
- }
70
- }
71
- }
72
- catch (error) {
73
- autoDiscoveryLogger.debug(`Failed to scan ${basePath}:`, error);
74
- }
75
- return discovered;
76
- }
77
- /**
78
- * Load plugin from manifest
79
- */
80
- async loadPlugin(manifestPath, pluginPath) {
81
- try {
82
- const manifestContent = await fs.readFile(manifestPath, "utf-8");
83
- const metadata = JSON.parse(manifestContent);
84
- // Validate basic metadata
85
- if (!metadata.name || !metadata.version || !metadata.main) {
86
- autoDiscoveryLogger.warn(`Invalid manifest at ${manifestPath}`);
87
- return null;
88
- }
89
- const entryPath = path.resolve(pluginPath, metadata.main);
90
- return {
91
- metadata,
92
- entryPath,
93
- source: this.determineSource(pluginPath),
94
- constructor: undefined,
95
- };
96
- }
97
- catch (error) {
98
- autoDiscoveryLogger.error(`Failed to load plugin manifest at ${manifestPath}:`, error);
99
- return null;
100
- }
101
- }
102
- /**
103
- * Determine plugin source based on path
104
- */
105
- determineSource(pluginPath) {
106
- if (pluginPath.includes("node_modules")) {
107
- return "installed";
108
- }
109
- if (pluginPath.includes("src/lib/mcp/plugins")) {
110
- return "core";
111
- }
112
- return "project";
113
- }
114
- }
115
- /**
116
- * Default auto-discovery instance
117
- */
118
- export const autoDiscovery = new AutoDiscovery();
119
- /**
120
- * Discover MCP servers using auto-discovery
121
- */
122
- export async function discoverMCPServers(options = {}) {
123
- const discovery = new AutoDiscovery(options);
124
- return discovery.discover();
125
- }
126
- /**
127
- * Auto-register discovered MCP servers
128
- */
129
- export async function autoRegisterMCPServers(options = {}) {
130
- const discovered = await discoverMCPServers(options);
131
- let registered = 0;
132
- let failed = 0;
133
- for (const plugin of discovered) {
134
- try {
135
- // Registration logic would go here
136
- autoDiscoveryLogger.info(`Registered plugin: ${plugin.metadata.name}`);
137
- registered++;
138
- }
139
- catch (error) {
140
- autoDiscoveryLogger.error(`Failed to register ${plugin.metadata.name}:`, error);
141
- failed++;
142
- }
143
- }
144
- return {
145
- registered,
146
- failed,
147
- plugins: discovered,
148
- };
149
- }
@@ -1,68 +0,0 @@
1
- /**
2
- * NeuroLink MCP Client
3
- * Following Lighthouse's pattern for MCP tool registration and execution
4
- */
5
- import { EventEmitter } from "events";
6
- import type { ToolResult, NeuroLinkExecutionContext } from "./factory.js";
7
- import type { Unknown } from "../types/common.js";
8
- /**
9
- * MCP Client Configuration
10
- */
11
- export interface MCPClientConfig {
12
- sessionId: string;
13
- userId?: string;
14
- aiProvider?: string;
15
- modelId?: string;
16
- logLevel?: "debug" | "info" | "warn" | "error";
17
- }
18
- /**
19
- * NeuroLink MCP Client
20
- * Manages tool registration and execution following Lighthouse patterns
21
- */
22
- export declare class NeuroLinkMCPClient extends EventEmitter {
23
- private tools;
24
- private config;
25
- private executionCount;
26
- private isConnected;
27
- constructor(config: MCPClientConfig);
28
- /**
29
- * Register a tool with the MCP client
30
- * Following Lighthouse's pattern of namespacing tools with server ID
31
- */
32
- registerTool(toolName: string, execute: (name: string, params: Record<string, unknown>) => Promise<Unknown>, description?: string, inputSchema?: unknown): void;
33
- /**
34
- * Get all registered tools
35
- */
36
- getTools(): Record<string, {
37
- name: string;
38
- description?: string;
39
- inputSchema?: unknown;
40
- }>;
41
- /**
42
- * Execute a tool by name
43
- */
44
- executeTool(toolName: string, params: unknown, context?: Partial<NeuroLinkExecutionContext>): Promise<ToolResult>;
45
- /**
46
- * Check if connected to MCP
47
- */
48
- isConnectedToMCP(): boolean;
49
- /**
50
- * Disconnect from MCP
51
- */
52
- disconnect(): Promise<void>;
53
- /**
54
- * Get client statistics
55
- */
56
- getStats(): {
57
- sessionId: string;
58
- toolCount: number;
59
- executionCount: number;
60
- isConnected: boolean;
61
- uptime: number;
62
- };
63
- private startTime;
64
- }
65
- /**
66
- * Create a new MCP client instance
67
- */
68
- export declare function createMCPClient(config: MCPClientConfig): NeuroLinkMCPClient;
@@ -1,248 +0,0 @@
1
- /**
2
- * NeuroLink MCP Client
3
- * Following Lighthouse's pattern for MCP tool registration and execution
4
- */
5
- import { EventEmitter } from "events";
6
- import { logger } from "../utils/logger.js";
7
- /**
8
- * NeuroLink MCP Client
9
- * Manages tool registration and execution following Lighthouse patterns
10
- */
11
- export class NeuroLinkMCPClient extends EventEmitter {
12
- tools = new Map();
13
- config;
14
- executionCount = 0;
15
- isConnected = false;
16
- constructor(config) {
17
- super();
18
- this.config = config;
19
- this.isConnected = true;
20
- logger.info(`[MCP Client] Initialized for session ${config.sessionId}`, {
21
- userId: config.userId,
22
- aiProvider: config.aiProvider,
23
- modelId: config.modelId,
24
- });
25
- }
26
- /**
27
- * Register a tool with the MCP client
28
- * Following Lighthouse's pattern of namespacing tools with server ID
29
- */
30
- registerTool(toolName, execute, description, inputSchema) {
31
- // Parse server ID from tool name (format: serverId_toolName)
32
- const parts = toolName.split("_");
33
- const serverId = parts[0];
34
- const originalName = parts.slice(1).join("_");
35
- // Create registered tool
36
- const registeredTool = {
37
- name: toolName,
38
- originalName,
39
- serverId,
40
- execute: async (params, context) => {
41
- try {
42
- // Call the execute function with Lighthouse-style parameters
43
- const result = await execute(toolName, params);
44
- // Handle different response formats
45
- if (result && typeof result === "object") {
46
- // If it's already in NeuroLink format
47
- if ("success" in result &&
48
- ("data" in result || "error" in result)) {
49
- return result;
50
- }
51
- // If it's in Lighthouse format with content array
52
- const lightouseResult = result;
53
- if (lightouseResult.text &&
54
- Array.isArray(lightouseResult.text) &&
55
- lightouseResult.text[0]?.text) {
56
- try {
57
- const data = JSON.parse(lightouseResult.text[0].text);
58
- return {
59
- success: !lightouseResult.isError,
60
- data,
61
- metadata: {
62
- toolName,
63
- serverId,
64
- sessionId: context.sessionId,
65
- timestamp: Date.now(),
66
- },
67
- };
68
- }
69
- catch (parseError) {
70
- // If JSON parsing fails, return the text as-is
71
- return {
72
- success: !lightouseResult.isError,
73
- data: { text: lightouseResult.text[0].text },
74
- metadata: {
75
- toolName,
76
- serverId,
77
- sessionId: context.sessionId,
78
- timestamp: Date.now(),
79
- },
80
- };
81
- }
82
- }
83
- // If it has a direct text property
84
- const textResult = result;
85
- if (textResult.text) {
86
- return {
87
- success: true,
88
- data: { text: textResult.text },
89
- metadata: {
90
- toolName,
91
- serverId,
92
- sessionId: context.sessionId,
93
- timestamp: Date.now(),
94
- },
95
- };
96
- }
97
- }
98
- return {
99
- success: false,
100
- error: "Invalid tool response format",
101
- };
102
- }
103
- catch (error) {
104
- logger.error(`[MCP Client] Tool execution failed: ${toolName}`, error);
105
- return {
106
- success: false,
107
- error: error instanceof Error ? error.message : String(error),
108
- };
109
- }
110
- },
111
- description,
112
- inputSchema,
113
- };
114
- // Register the tool
115
- this.tools.set(toolName, registeredTool);
116
- logger.debug(`[MCP Client] Registered tool: ${toolName}`, {
117
- serverId,
118
- originalName,
119
- description,
120
- });
121
- // Emit tool registration event
122
- this.emit("tool:registered", {
123
- toolName,
124
- serverId,
125
- originalName,
126
- });
127
- }
128
- /**
129
- * Get all registered tools
130
- */
131
- getTools() {
132
- const tools = {};
133
- for (const [name, tool] of Array.from(this.tools.entries())) {
134
- tools[name] = {
135
- name: name, // Include the tool name as a property
136
- description: tool.description,
137
- inputSchema: tool.inputSchema,
138
- };
139
- }
140
- return tools;
141
- }
142
- /**
143
- * Execute a tool by name
144
- */
145
- async executeTool(toolName, params, context) {
146
- const tool = this.tools.get(toolName);
147
- if (!tool) {
148
- return {
149
- success: false,
150
- error: `Tool not found: ${toolName}`,
151
- };
152
- }
153
- // Create full context using createExecutionContext for proper structure
154
- const { createExecutionContext } = await import("./context-manager.js");
155
- const fullContext = createExecutionContext({
156
- sessionId: this.config.sessionId,
157
- userId: this.config.userId,
158
- aiProvider: this.config.aiProvider,
159
- modelId: this.config.modelId,
160
- ...context,
161
- });
162
- // Track execution
163
- this.executionCount++;
164
- const executionId = `exec-${this.executionCount}`;
165
- // Emit execution start event
166
- this.emit("tool:execute:start", {
167
- executionId,
168
- toolName,
169
- serverId: tool.serverId,
170
- params,
171
- });
172
- const startTime = Date.now();
173
- try {
174
- // Execute the tool
175
- const result = await tool.execute(params, fullContext);
176
- // Add execution metadata
177
- result.metadata = {
178
- ...result.metadata,
179
- executionId,
180
- executionTime: Date.now() - startTime,
181
- };
182
- // Emit execution complete event
183
- this.emit("tool:execute:complete", {
184
- executionId,
185
- toolName,
186
- serverId: tool.serverId,
187
- success: result.success,
188
- executionTime: result.metadata.executionTime,
189
- });
190
- return result;
191
- }
192
- catch (error) {
193
- const executionTime = Date.now() - startTime;
194
- // Emit execution error event
195
- this.emit("tool:execute:error", {
196
- executionId,
197
- toolName,
198
- serverId: tool.serverId,
199
- error: error instanceof Error ? error.message : String(error),
200
- executionTime,
201
- });
202
- return {
203
- success: false,
204
- error: error instanceof Error ? error.message : String(error),
205
- metadata: {
206
- executionId,
207
- toolName,
208
- serverId: tool.serverId,
209
- executionTime,
210
- },
211
- };
212
- }
213
- }
214
- /**
215
- * Check if connected to MCP
216
- */
217
- isConnectedToMCP() {
218
- return this.isConnected;
219
- }
220
- /**
221
- * Disconnect from MCP
222
- */
223
- async disconnect() {
224
- this.isConnected = false;
225
- this.tools.clear();
226
- this.removeAllListeners();
227
- logger.info(`[MCP Client] Disconnected for session ${this.config.sessionId}`);
228
- }
229
- /**
230
- * Get client statistics
231
- */
232
- getStats() {
233
- return {
234
- sessionId: this.config.sessionId,
235
- toolCount: this.tools.size,
236
- executionCount: this.executionCount,
237
- isConnected: this.isConnected,
238
- uptime: Date.now() - (this.startTime || Date.now()),
239
- };
240
- }
241
- startTime = Date.now();
242
- }
243
- /**
244
- * Create a new MCP client instance
245
- */
246
- export function createMCPClient(config) {
247
- return new NeuroLinkMCPClient(config);
248
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * NeuroLink MCP Configuration
3
- * Central registry for all MCP servers following Lighthouse patterns
4
- * Handles built-in servers only - auto-discovery handled by unified registry
5
- */
6
- import type { NeuroLinkMCPServer } from "./factory.js";
7
- /**
8
- * Built-in MCP servers (kept for backward compatibility)
9
- * Add new servers here as they are created
10
- */
11
- export declare const allServers: NeuroLinkMCPServer[];
12
- /**
13
- * MCP Configuration following Lighthouse patterns
14
- * Handles built-in servers - auto-discovery is handled by unified registry
15
- */
16
- export declare const mcpConfig: {
17
- /**
18
- * Get list of active built-in MCP servers with implemented tools
19
- */
20
- getServers: () => Promise<NeuroLinkMCPServer[]>;
21
- /**
22
- * Get all available tools across all servers
23
- */
24
- getAllTools: () => Promise<{
25
- name: string;
26
- description: string;
27
- serverId: string;
28
- serverTitle: string;
29
- category?: string;
30
- }[]>;
31
- };