@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,71 +0,0 @@
1
- /**
2
- * Compatibility conversion factory for seamless migration
3
- * between generateText and generate functions
4
- */
5
- export class CompatibilityConversionFactory {
6
- /**
7
- * Convert TextGenerationOptions to GenerateOptions
8
- */
9
- static convertTextToGenerate(options) {
10
- const { prompt, ...rest } = options;
11
- return {
12
- input: { text: prompt || "" },
13
- output: { format: "text" },
14
- provider: rest.provider,
15
- model: rest.model,
16
- temperature: rest.temperature,
17
- maxTokens: rest.maxTokens,
18
- systemPrompt: rest.systemPrompt,
19
- schema: rest.schema,
20
- tools: rest.tools,
21
- timeout: rest.timeout,
22
- enableEvaluation: rest.enableEvaluation,
23
- enableAnalytics: rest.enableAnalytics,
24
- context: rest.context,
25
- evaluationDomain: rest.evaluationDomain,
26
- toolUsageContext: rest.toolUsageContext,
27
- conversationHistory: rest.conversationHistory,
28
- };
29
- }
30
- /**
31
- * Convert GenerateResult to legacy TextGenerationResult format
32
- */
33
- static convertGenerateToText(result) {
34
- return {
35
- content: result.content,
36
- provider: result.provider,
37
- model: result.model,
38
- usage: result.usage,
39
- responseTime: result.responseTime,
40
- toolsUsed: Array.isArray(result.toolsUsed)
41
- ? result.toolsUsed.length
42
- : result.toolsUsed,
43
- toolExecutions: result.toolExecutions,
44
- enhancedWithTools: result.enhancedWithTools,
45
- availableTools: result.availableTools,
46
- analytics: result.analytics,
47
- evaluation: result.evaluation,
48
- };
49
- }
50
- /**
51
- * Convert GenerateOptions to TextGenerationOptions
52
- */
53
- static convertGenerateToText_Options(options) {
54
- return {
55
- prompt: options.input.text,
56
- model: options.model,
57
- temperature: options.temperature,
58
- maxTokens: options.maxTokens,
59
- systemPrompt: options.systemPrompt,
60
- schema: options.schema,
61
- tools: options.tools,
62
- timeout: options.timeout,
63
- enableEvaluation: options.enableEvaluation,
64
- enableAnalytics: options.enableAnalytics,
65
- context: options.context,
66
- evaluationDomain: options.evaluationDomain,
67
- toolUsageContext: options.toolUsageContext,
68
- conversationHistory: options.conversationHistory,
69
- };
70
- }
71
- }
@@ -1,20 +0,0 @@
1
- import type { EnhancedProvider } from "../types/generate-types.js";
2
- import type { AIProvider } from "../core/types.js";
3
- /**
4
- * Factory for enhancing providers with generate() capability using Proxy pattern
5
- * Maintains 100% backward compatibility while adding new generate method
6
- */
7
- export declare class ProviderGenerateFactory {
8
- /**
9
- * Enhance any provider with generate() method using TypeScript Proxy
10
- */
11
- static enhanceProvider<T extends AIProvider>(provider: T): T & EnhancedProvider;
12
- /**
13
- * Create the generate() method that internally uses generateText for performance parity
14
- */
15
- private static createGenerateMethod;
16
- /**
17
- * Enhance all providers from a registry
18
- */
19
- static enhanceAllProviders(providers: Map<string, AIProvider>): Map<string, AIProvider & EnhancedProvider>;
20
- }
@@ -1,93 +0,0 @@
1
- import { CompatibilityConversionFactory } from "./compatibility-factory.js";
2
- /**
3
- * Factory for enhancing providers with generate() capability using Proxy pattern
4
- * Maintains 100% backward compatibility while adding new generate method
5
- */
6
- export class ProviderGenerateFactory {
7
- /**
8
- * Enhance any provider with generate() method using TypeScript Proxy
9
- */
10
- static enhanceProvider(provider) {
11
- return new Proxy(provider, {
12
- get(target, prop, receiver) {
13
- if (prop === "generate") {
14
- return ProviderGenerateFactory.createGenerateMethod(target);
15
- }
16
- return Reflect.get(target, prop, receiver);
17
- },
18
- has(target, prop) {
19
- if (prop === "generate") {
20
- return true;
21
- }
22
- return Reflect.has(target, prop);
23
- },
24
- });
25
- }
26
- /**
27
- * Create the generate() method that internally uses generateText for performance parity
28
- */
29
- static createGenerateMethod(provider) {
30
- return async (options) => {
31
- // Validate input
32
- if (!options.input?.text) {
33
- throw new Error("Generate options must include input.text");
34
- }
35
- // Convert GenerateOptions to TextGenerationOptions
36
- const textOptions = CompatibilityConversionFactory.convertGenerateToText_Options(options);
37
- try {
38
- // Use existing generate method for identical performance
39
- const textResult = await provider.generate(textOptions);
40
- if (!textResult) {
41
- throw new Error("Generate method returned null result");
42
- }
43
- // Convert back to GenerateResult format with type safety
44
- const generateResult = {
45
- content: textResult.content || "",
46
- outputs: { text: textResult.content || "" },
47
- provider: textResult.provider,
48
- model: textResult.model,
49
- usage: textResult.usage
50
- ? {
51
- inputTokens: textResult.usage.inputTokens || 0,
52
- outputTokens: textResult.usage.outputTokens || 0,
53
- totalTokens: textResult.usage.totalTokens || 0,
54
- }
55
- : undefined,
56
- responseTime: textResult.responseTime,
57
- toolsUsed: textResult.toolsUsed,
58
- toolExecutions: textResult.toolExecutions?.map((te) => {
59
- const toolExecution = te;
60
- return {
61
- name: toolExecution.toolName || toolExecution.name || "",
62
- input: toolExecution.input || {},
63
- output: toolExecution.output || toolExecution.result,
64
- duration: toolExecution.executionTime || toolExecution.duration || 0,
65
- };
66
- }),
67
- enhancedWithTools: textResult.enhancedWithTools,
68
- availableTools: textResult.availableTools?.map((at) => ({
69
- name: at.name || "",
70
- description: at.description || "",
71
- parameters: at.parameters || {},
72
- })),
73
- analytics: textResult.analytics,
74
- evaluation: textResult.evaluation,
75
- };
76
- return generateResult;
77
- }
78
- catch (error) {
79
- throw new Error(`Generate method failed: ${error}`);
80
- }
81
- };
82
- }
83
- /**
84
- * Enhance all providers from a registry
85
- */
86
- static enhanceAllProviders(providers) {
87
- const enhancedProviders = new Map();
88
- for (const [name, provider] of providers) {
89
- enhancedProviders.set(name, this.enhanceProvider(provider));
90
- }
91
- return enhancedProviders;
92
- }
93
- }
@@ -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;