@juspay/neurolink 6.1.0 → 6.2.1

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 (303) hide show
  1. package/CHANGELOG.md +16 -6
  2. package/dist/agent/direct-tools.js +6 -5
  3. package/dist/cli/commands/config.d.ts +13 -13
  4. package/dist/cli/index.js +3 -9
  5. package/dist/config/configManager.js +11 -10
  6. package/dist/core/analytics.d.ts +11 -1
  7. package/dist/core/analytics.js +2 -2
  8. package/dist/core/base-provider.js +4 -18
  9. package/dist/core/dynamic-models.d.ts +8 -8
  10. package/dist/core/factory.js +3 -11
  11. package/dist/index.d.ts +2 -4
  12. package/dist/index.js +2 -11
  13. package/dist/lib/agent/direct-tools.js +6 -5
  14. package/dist/lib/config/configManager.js +11 -10
  15. package/dist/lib/core/analytics.d.ts +11 -1
  16. package/dist/lib/core/analytics.js +2 -2
  17. package/dist/lib/core/base-provider.js +4 -18
  18. package/dist/lib/core/dynamic-models.d.ts +8 -8
  19. package/dist/lib/core/factory.js +3 -11
  20. package/dist/lib/index.d.ts +2 -4
  21. package/dist/lib/index.js +2 -11
  22. package/dist/lib/mcp/factory.d.ts +1 -1
  23. package/dist/lib/mcp/index.d.ts +9 -21
  24. package/dist/lib/mcp/index.js +16 -57
  25. package/dist/lib/mcp/registry.js +1 -1
  26. package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +2 -1
  27. package/dist/lib/mcp/tool-registry.js +1 -1
  28. package/dist/lib/neurolink.d.ts +1 -9
  29. package/dist/lib/neurolink.js +22 -71
  30. package/dist/lib/providers/amazon-bedrock.js +5 -16
  31. package/dist/lib/providers/anthropic-baseprovider.js +3 -21
  32. package/dist/lib/providers/anthropic.js +4 -7
  33. package/dist/lib/providers/azure-openai.js +6 -3
  34. package/dist/lib/providers/google-vertex.js +5 -9
  35. package/dist/lib/providers/huggingFace.js +5 -10
  36. package/dist/lib/providers/mistral.js +5 -8
  37. package/dist/lib/providers/openAI.js +4 -7
  38. package/dist/lib/telemetry/index.js +2 -1
  39. package/dist/lib/utils/logger.d.ts +62 -2
  40. package/dist/lib/utils/logger.js +174 -9
  41. package/dist/lib/utils/providerConfig.d.ts +117 -0
  42. package/dist/lib/utils/providerConfig.js +353 -0
  43. package/dist/lib/utils/providerUtils.d.ts +2 -1
  44. package/dist/lib/utils/providerUtils.js +53 -36
  45. package/dist/lib/utils/timeout.d.ts +72 -1
  46. package/dist/lib/utils/timeout.js +203 -2
  47. package/dist/mcp/factory.d.ts +1 -1
  48. package/dist/mcp/index.d.ts +9 -21
  49. package/dist/mcp/index.js +16 -57
  50. package/dist/mcp/registry.js +1 -1
  51. package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +2 -1
  52. package/dist/mcp/tool-registry.js +1 -1
  53. package/dist/neurolink.d.ts +1 -9
  54. package/dist/neurolink.js +22 -71
  55. package/dist/providers/amazon-bedrock.js +5 -16
  56. package/dist/providers/anthropic-baseprovider.js +3 -21
  57. package/dist/providers/anthropic.js +4 -7
  58. package/dist/providers/azure-openai.js +6 -3
  59. package/dist/providers/google-vertex.js +5 -9
  60. package/dist/providers/huggingFace.js +5 -10
  61. package/dist/providers/mistral.js +5 -8
  62. package/dist/providers/openAI.js +4 -7
  63. package/dist/telemetry/index.js +2 -1
  64. package/dist/utils/logger.d.ts +62 -2
  65. package/dist/utils/logger.js +174 -9
  66. package/dist/utils/providerConfig.d.ts +117 -0
  67. package/dist/utils/providerConfig.js +353 -0
  68. package/dist/utils/providerUtils.d.ts +2 -1
  69. package/dist/utils/providerUtils.js +53 -36
  70. package/dist/utils/timeout.d.ts +72 -1
  71. package/dist/utils/timeout.js +203 -2
  72. package/package.json +1 -1
  73. package/dist/chat/client-utils.d.ts +0 -95
  74. package/dist/chat/client-utils.js +0 -315
  75. package/dist/chat/index.d.ts +0 -24
  76. package/dist/chat/index.js +0 -33
  77. package/dist/chat/session-storage.d.ts +0 -77
  78. package/dist/chat/session-storage.js +0 -233
  79. package/dist/chat/session.d.ts +0 -96
  80. package/dist/chat/session.js +0 -257
  81. package/dist/chat/sse-handler.d.ts +0 -49
  82. package/dist/chat/sse-handler.js +0 -259
  83. package/dist/chat/types.d.ts +0 -74
  84. package/dist/chat/types.js +0 -5
  85. package/dist/chat/websocket-chat-handler.d.ts +0 -37
  86. package/dist/chat/websocket-chat-handler.js +0 -262
  87. package/dist/cli/commands/mcp.d.ts +0 -20
  88. package/dist/cli/commands/mcp.js +0 -1272
  89. package/dist/core/defaults.d.ts +0 -19
  90. package/dist/core/defaults.js +0 -29
  91. package/dist/core/evaluation-config.d.ts +0 -29
  92. package/dist/core/evaluation-config.js +0 -144
  93. package/dist/factories/compatibility-factory.d.ts +0 -35
  94. package/dist/factories/compatibility-factory.js +0 -71
  95. package/dist/factories/provider-generate-factory.d.ts +0 -20
  96. package/dist/factories/provider-generate-factory.js +0 -93
  97. package/dist/lib/chat/client-utils.d.ts +0 -95
  98. package/dist/lib/chat/client-utils.js +0 -315
  99. package/dist/lib/chat/index.d.ts +0 -24
  100. package/dist/lib/chat/index.js +0 -33
  101. package/dist/lib/chat/session-storage.d.ts +0 -77
  102. package/dist/lib/chat/session-storage.js +0 -233
  103. package/dist/lib/chat/session.d.ts +0 -96
  104. package/dist/lib/chat/session.js +0 -257
  105. package/dist/lib/chat/sse-handler.d.ts +0 -49
  106. package/dist/lib/chat/sse-handler.js +0 -259
  107. package/dist/lib/chat/types.d.ts +0 -74
  108. package/dist/lib/chat/types.js +0 -5
  109. package/dist/lib/chat/websocket-chat-handler.d.ts +0 -37
  110. package/dist/lib/chat/websocket-chat-handler.js +0 -262
  111. package/dist/lib/core/defaults.d.ts +0 -19
  112. package/dist/lib/core/defaults.js +0 -29
  113. package/dist/lib/core/evaluation-config.d.ts +0 -29
  114. package/dist/lib/core/evaluation-config.js +0 -144
  115. package/dist/lib/factories/compatibility-factory.d.ts +0 -35
  116. package/dist/lib/factories/compatibility-factory.js +0 -71
  117. package/dist/lib/factories/provider-generate-factory.d.ts +0 -20
  118. package/dist/lib/factories/provider-generate-factory.js +0 -93
  119. package/dist/lib/mcp/adapters/plugin-bridge.d.ts +0 -40
  120. package/dist/lib/mcp/adapters/plugin-bridge.js +0 -89
  121. package/dist/lib/mcp/auto-discovery.d.ts +0 -62
  122. package/dist/lib/mcp/auto-discovery.js +0 -149
  123. package/dist/lib/mcp/client.d.ts +0 -68
  124. package/dist/lib/mcp/client.js +0 -248
  125. package/dist/lib/mcp/config.d.ts +0 -31
  126. package/dist/lib/mcp/config.js +0 -99
  127. package/dist/lib/mcp/context-manager.d.ts +0 -171
  128. package/dist/lib/mcp/context-manager.js +0 -362
  129. package/dist/lib/mcp/contracts/mcp-contract.d.ts +0 -169
  130. package/dist/lib/mcp/contracts/mcp-contract.js +0 -58
  131. package/dist/lib/mcp/core/plugin-manager.d.ts +0 -46
  132. package/dist/lib/mcp/core/plugin-manager.js +0 -110
  133. package/dist/lib/mcp/demo/plugin-demo.d.ts +0 -20
  134. package/dist/lib/mcp/demo/plugin-demo.js +0 -118
  135. package/dist/lib/mcp/dynamic-chain-executor.d.ts +0 -225
  136. package/dist/lib/mcp/dynamic-chain-executor.js +0 -489
  137. package/dist/lib/mcp/dynamic-orchestrator.d.ts +0 -115
  138. package/dist/lib/mcp/dynamic-orchestrator.js +0 -351
  139. package/dist/lib/mcp/ecosystem.d.ts +0 -75
  140. package/dist/lib/mcp/ecosystem.js +0 -161
  141. package/dist/lib/mcp/error-manager.d.ts +0 -254
  142. package/dist/lib/mcp/error-manager.js +0 -501
  143. package/dist/lib/mcp/error-recovery.d.ts +0 -159
  144. package/dist/lib/mcp/error-recovery.js +0 -405
  145. package/dist/lib/mcp/external-client.d.ts +0 -88
  146. package/dist/lib/mcp/external-client.js +0 -331
  147. package/dist/lib/mcp/external-manager.d.ts +0 -112
  148. package/dist/lib/mcp/external-manager.js +0 -308
  149. package/dist/lib/mcp/function-calling.d.ts +0 -65
  150. package/dist/lib/mcp/function-calling.js +0 -642
  151. package/dist/lib/mcp/health-monitor.d.ts +0 -257
  152. package/dist/lib/mcp/health-monitor.js +0 -630
  153. package/dist/lib/mcp/initialize-tools.d.ts +0 -29
  154. package/dist/lib/mcp/initialize-tools.js +0 -261
  155. package/dist/lib/mcp/initialize.d.ts +0 -18
  156. package/dist/lib/mcp/initialize.js +0 -62
  157. package/dist/lib/mcp/logging.d.ts +0 -38
  158. package/dist/lib/mcp/logging.js +0 -100
  159. package/dist/lib/mcp/manager.d.ts +0 -68
  160. package/dist/lib/mcp/manager.js +0 -176
  161. package/dist/lib/mcp/neurolink-mcp-client.d.ts +0 -97
  162. package/dist/lib/mcp/neurolink-mcp-client.js +0 -462
  163. package/dist/lib/mcp/orchestrator.d.ts +0 -302
  164. package/dist/lib/mcp/orchestrator.js +0 -703
  165. package/dist/lib/mcp/plugin-manager.d.ts +0 -98
  166. package/dist/lib/mcp/plugin-manager.js +0 -296
  167. package/dist/lib/mcp/plugins/core/filesystem-mcp.d.ts +0 -36
  168. package/dist/lib/mcp/plugins/core/filesystem-mcp.js +0 -142
  169. package/dist/lib/mcp/plugins/filesystem-mcp.d.ts +0 -37
  170. package/dist/lib/mcp/plugins/filesystem-mcp.js +0 -54
  171. package/dist/lib/mcp/security-manager.d.ts +0 -87
  172. package/dist/lib/mcp/security-manager.js +0 -344
  173. package/dist/lib/mcp/semaphore-manager.d.ts +0 -137
  174. package/dist/lib/mcp/semaphore-manager.js +0 -329
  175. package/dist/lib/mcp/session-manager.d.ts +0 -187
  176. package/dist/lib/mcp/session-manager.js +0 -400
  177. package/dist/lib/mcp/session-persistence.d.ts +0 -93
  178. package/dist/lib/mcp/session-persistence.js +0 -301
  179. package/dist/lib/mcp/tool-integration.d.ts +0 -58
  180. package/dist/lib/mcp/tool-integration.js +0 -203
  181. package/dist/lib/mcp/transport-manager.d.ts +0 -154
  182. package/dist/lib/mcp/transport-manager.js +0 -334
  183. package/dist/lib/mcp/unified-mcp.d.ts +0 -133
  184. package/dist/lib/mcp/unified-mcp.js +0 -251
  185. package/dist/lib/mcp/unified-registry.d.ts +0 -165
  186. package/dist/lib/mcp/unified-registry.js +0 -538
  187. package/dist/lib/providers/analytics-helper.d.ts +0 -38
  188. package/dist/lib/providers/analytics-helper.js +0 -216
  189. package/dist/lib/providers/function-calling-provider.d.ts +0 -142
  190. package/dist/lib/providers/function-calling-provider.js +0 -630
  191. package/dist/lib/providers/mcp-provider.d.ts +0 -75
  192. package/dist/lib/providers/mcp-provider.js +0 -283
  193. package/dist/lib/providers/timeout-wrapper.d.ts +0 -40
  194. package/dist/lib/providers/timeout-wrapper.js +0 -100
  195. package/dist/lib/sdk/tool-extension.d.ts +0 -181
  196. package/dist/lib/sdk/tool-extension.js +0 -284
  197. package/dist/lib/services/streaming/streaming-manager.d.ts +0 -29
  198. package/dist/lib/services/streaming/streaming-manager.js +0 -245
  199. package/dist/lib/services/types.d.ts +0 -156
  200. package/dist/lib/services/types.js +0 -2
  201. package/dist/lib/services/websocket/websocket-server.d.ts +0 -34
  202. package/dist/lib/services/websocket/websocket-server.js +0 -305
  203. package/dist/lib/utils/provider-validation.d.ts +0 -36
  204. package/dist/lib/utils/provider-validation.js +0 -625
  205. package/dist/lib/utils/providerUtils-fixed.d.ts +0 -8
  206. package/dist/lib/utils/providerUtils-fixed.js +0 -94
  207. package/dist/lib/utils/streaming-utils.d.ts +0 -79
  208. package/dist/lib/utils/streaming-utils.js +0 -198
  209. package/dist/lib/utils/timeout-manager.d.ts +0 -75
  210. package/dist/lib/utils/timeout-manager.js +0 -244
  211. package/dist/mcp/adapters/plugin-bridge.d.ts +0 -40
  212. package/dist/mcp/adapters/plugin-bridge.js +0 -89
  213. package/dist/mcp/auto-discovery.d.ts +0 -62
  214. package/dist/mcp/auto-discovery.js +0 -149
  215. package/dist/mcp/client.d.ts +0 -68
  216. package/dist/mcp/client.js +0 -248
  217. package/dist/mcp/config.d.ts +0 -31
  218. package/dist/mcp/config.js +0 -99
  219. package/dist/mcp/context-manager.d.ts +0 -171
  220. package/dist/mcp/context-manager.js +0 -362
  221. package/dist/mcp/contracts/mcp-contract.d.ts +0 -169
  222. package/dist/mcp/contracts/mcp-contract.js +0 -58
  223. package/dist/mcp/core/plugin-manager.d.ts +0 -46
  224. package/dist/mcp/core/plugin-manager.js +0 -110
  225. package/dist/mcp/demo/plugin-demo.d.ts +0 -20
  226. package/dist/mcp/demo/plugin-demo.js +0 -118
  227. package/dist/mcp/dynamic-chain-executor.d.ts +0 -225
  228. package/dist/mcp/dynamic-chain-executor.js +0 -489
  229. package/dist/mcp/dynamic-orchestrator.d.ts +0 -115
  230. package/dist/mcp/dynamic-orchestrator.js +0 -351
  231. package/dist/mcp/ecosystem.d.ts +0 -75
  232. package/dist/mcp/ecosystem.js +0 -162
  233. package/dist/mcp/error-manager.d.ts +0 -254
  234. package/dist/mcp/error-manager.js +0 -501
  235. package/dist/mcp/error-recovery.d.ts +0 -159
  236. package/dist/mcp/error-recovery.js +0 -405
  237. package/dist/mcp/external-client.d.ts +0 -88
  238. package/dist/mcp/external-client.js +0 -331
  239. package/dist/mcp/external-manager.d.ts +0 -112
  240. package/dist/mcp/external-manager.js +0 -308
  241. package/dist/mcp/function-calling.d.ts +0 -65
  242. package/dist/mcp/function-calling.js +0 -642
  243. package/dist/mcp/health-monitor.d.ts +0 -257
  244. package/dist/mcp/health-monitor.js +0 -630
  245. package/dist/mcp/initialize-tools.d.ts +0 -29
  246. package/dist/mcp/initialize-tools.js +0 -262
  247. package/dist/mcp/initialize.d.ts +0 -18
  248. package/dist/mcp/initialize.js +0 -62
  249. package/dist/mcp/logging.d.ts +0 -38
  250. package/dist/mcp/logging.js +0 -100
  251. package/dist/mcp/manager.d.ts +0 -68
  252. package/dist/mcp/manager.js +0 -176
  253. package/dist/mcp/neurolink-mcp-client.d.ts +0 -97
  254. package/dist/mcp/neurolink-mcp-client.js +0 -462
  255. package/dist/mcp/orchestrator.d.ts +0 -302
  256. package/dist/mcp/orchestrator.js +0 -703
  257. package/dist/mcp/plugin-manager.d.ts +0 -98
  258. package/dist/mcp/plugin-manager.js +0 -297
  259. package/dist/mcp/plugins/core/filesystem-mcp.d.ts +0 -36
  260. package/dist/mcp/plugins/core/filesystem-mcp.js +0 -142
  261. package/dist/mcp/plugins/core/neurolink-mcp.json +0 -17
  262. package/dist/mcp/plugins/filesystem-mcp.d.ts +0 -37
  263. package/dist/mcp/plugins/filesystem-mcp.js +0 -54
  264. package/dist/mcp/security-manager.d.ts +0 -87
  265. package/dist/mcp/security-manager.js +0 -344
  266. package/dist/mcp/semaphore-manager.d.ts +0 -137
  267. package/dist/mcp/semaphore-manager.js +0 -329
  268. package/dist/mcp/session-manager.d.ts +0 -187
  269. package/dist/mcp/session-manager.js +0 -400
  270. package/dist/mcp/session-persistence.d.ts +0 -93
  271. package/dist/mcp/session-persistence.js +0 -302
  272. package/dist/mcp/tool-integration.d.ts +0 -58
  273. package/dist/mcp/tool-integration.js +0 -203
  274. package/dist/mcp/transport-manager.d.ts +0 -154
  275. package/dist/mcp/transport-manager.js +0 -335
  276. package/dist/mcp/unified-mcp.d.ts +0 -133
  277. package/dist/mcp/unified-mcp.js +0 -251
  278. package/dist/mcp/unified-registry.d.ts +0 -165
  279. package/dist/mcp/unified-registry.js +0 -539
  280. package/dist/providers/analytics-helper.d.ts +0 -38
  281. package/dist/providers/analytics-helper.js +0 -216
  282. package/dist/providers/function-calling-provider.d.ts +0 -142
  283. package/dist/providers/function-calling-provider.js +0 -630
  284. package/dist/providers/mcp-provider.d.ts +0 -75
  285. package/dist/providers/mcp-provider.js +0 -283
  286. package/dist/providers/timeout-wrapper.d.ts +0 -40
  287. package/dist/providers/timeout-wrapper.js +0 -100
  288. package/dist/sdk/tool-extension.d.ts +0 -181
  289. package/dist/sdk/tool-extension.js +0 -284
  290. package/dist/services/streaming/streaming-manager.d.ts +0 -29
  291. package/dist/services/streaming/streaming-manager.js +0 -245
  292. package/dist/services/types.d.ts +0 -156
  293. package/dist/services/types.js +0 -2
  294. package/dist/services/websocket/websocket-server.d.ts +0 -34
  295. package/dist/services/websocket/websocket-server.js +0 -306
  296. package/dist/utils/provider-validation.d.ts +0 -36
  297. package/dist/utils/provider-validation.js +0 -625
  298. package/dist/utils/providerUtils-fixed.d.ts +0 -8
  299. package/dist/utils/providerUtils-fixed.js +0 -94
  300. package/dist/utils/streaming-utils.d.ts +0 -79
  301. package/dist/utils/streaming-utils.js +0 -198
  302. package/dist/utils/timeout-manager.d.ts +0 -75
  303. package/dist/utils/timeout-manager.js +0 -244
@@ -1,169 +0,0 @@
1
- /**
2
- * MCP Abstract Contract - The Foundation of NeuroLink's Plugin Ecosystem
3
- * Based on research blueprint for extensible MCP architecture
4
- */
5
- import type { ZodSchema } from "zod";
6
- /**
7
- * Metadata structure for MCP plugins following manifest-based discovery
8
- */
9
- export interface MCPMetadata {
10
- /** Unique NPM-style package name */
11
- name: string;
12
- /** Semantic version */
13
- version: string;
14
- /** Entry point path */
15
- main: string;
16
- /** Compatible NeuroLink version range */
17
- engine: {
18
- neurolink: string;
19
- };
20
- /** Human-readable description */
21
- description: string;
22
- /** Declarative permissions array for security */
23
- permissions: string[];
24
- /** JSON Schema for configuration validation */
25
- configSchema?: ZodSchema | object;
26
- }
27
- /**
28
- * Execution Context - Security Sandbox for MCP Operations
29
- * Provides sandboxed access to system resources with permission checking
30
- */
31
- export interface ExecutionContext {
32
- /** Session identifier for tracking */
33
- sessionId: string;
34
- /** User identifier for permissions */
35
- userId: string;
36
- /** Sandboxed filesystem operations */
37
- secureFS: {
38
- readFile: (path: string, encoding?: string) => Promise<string | Buffer>;
39
- writeFile: (path: string, content: string | Buffer) => Promise<void>;
40
- readdir: (path: string) => Promise<string[]>;
41
- stat: (path: string) => Promise<{
42
- size: number;
43
- isFile: () => boolean;
44
- isDirectory: () => boolean;
45
- }>;
46
- mkdir: (path: string, options?: {
47
- recursive?: boolean;
48
- }) => Promise<void>;
49
- exists: (path: string) => Promise<boolean>;
50
- };
51
- /** Sandboxed path operations */
52
- path: {
53
- join: (...paths: string[]) => string;
54
- resolve: (...paths: string[]) => string;
55
- relative: (from: string, to: string) => string;
56
- dirname: (path: string) => string;
57
- basename: (path: string, ext?: string) => string;
58
- };
59
- /** Sandboxed network operations (future) */
60
- secureNet?: {
61
- fetch: (url: string, options?: RequestInit) => Promise<Response>;
62
- };
63
- /** Plugin-specific permissions granted */
64
- grantedPermissions: string[];
65
- /** Log function for debugging */
66
- log: (level: "debug" | "info" | "warn" | "error", message: string, data?: unknown) => void;
67
- /** Plugin instance reference (for plugin bridge compatibility) */
68
- plugin?: unknown;
69
- }
70
- /**
71
- * MCP Abstract Class - The Core Contract for All Plugins
72
- * Uses TypeScript generics for type-safe configuration
73
- */
74
- export declare abstract class MCP<TConfig = unknown, TArgs = unknown, TResult = unknown> {
75
- /** Static metadata loaded from manifest */
76
- abstract readonly metadata: MCPMetadata;
77
- /** Configuration state - accessible to child classes */
78
- config?: TConfig;
79
- /** Initialization flag */
80
- protected initialized: boolean;
81
- /**
82
- * Initialize the MCP with user-provided configuration
83
- * @param config - Plugin-specific configuration object
84
- */
85
- abstract initialize(config: TConfig): Promise<void>;
86
- /**
87
- * Execute the MCP's primary functionality
88
- * @param context - Sandboxed execution context
89
- * @param args - Operation-specific arguments
90
- * @returns Plugin-specific result
91
- */
92
- abstract execute(context: ExecutionContext, args: TArgs): Promise<TResult>;
93
- /**
94
- * Graceful shutdown and resource cleanup
95
- */
96
- abstract dispose(): Promise<void>;
97
- /**
98
- * Get the current configuration
99
- */
100
- getConfig(): TConfig | undefined;
101
- /**
102
- * Check if the MCP is initialized
103
- */
104
- isInitialized(): boolean;
105
- /**
106
- * Get plugin metadata
107
- */
108
- getMetadata(): MCPMetadata;
109
- /**
110
- * Validate that the MCP is ready for execution
111
- */
112
- protected ensureInitialized(): void;
113
- /**
114
- * Helper method for logging with context
115
- */
116
- protected log(context: ExecutionContext, level: "debug" | "info" | "warn" | "error", message: string, data?: unknown): void;
117
- }
118
- /**
119
- * Type definitions for plugin registry
120
- */
121
- export type MCPConstructor<T extends MCP = MCP> = new () => T;
122
- export type MCPInstance<T extends MCP = MCP> = T;
123
- /**
124
- * Plugin discovery result
125
- */
126
- export interface DiscoveredMCP {
127
- metadata: MCPMetadata;
128
- entryPath: string;
129
- source: "core" | "project" | "installed";
130
- constructor?: MCPConstructor;
131
- [key: string]: unknown;
132
- }
133
- /**
134
- * Plugin load result
135
- */
136
- export interface PluginLoadResult {
137
- success: boolean;
138
- plugin?: MCP;
139
- error?: string;
140
- }
141
- /**
142
- * Plugin discovery result
143
- */
144
- export interface PluginDiscoveryResult {
145
- total: number;
146
- loaded: number;
147
- failed: number;
148
- plugins: DiscoveredMCP[];
149
- }
150
- /**
151
- * Plugin execution result
152
- */
153
- export interface PluginExecutionResult<T = unknown> {
154
- success: boolean;
155
- result?: T;
156
- error?: string;
157
- executionTime?: number;
158
- }
159
- /**
160
- * MCP Category for organization
161
- */
162
- export declare enum MCPCategory {
163
- FILESYSTEM = "filesystem",
164
- NETWORK = "network",
165
- DATABASE = "database",
166
- AI = "ai",
167
- UTILITY = "utility",
168
- INTEGRATION = "integration"
169
- }
@@ -1,58 +0,0 @@
1
- /**
2
- * MCP Abstract Contract - The Foundation of NeuroLink's Plugin Ecosystem
3
- * Based on research blueprint for extensible MCP architecture
4
- */
5
- /**
6
- * MCP Abstract Class - The Core Contract for All Plugins
7
- * Uses TypeScript generics for type-safe configuration
8
- */
9
- export class MCP {
10
- /** Configuration state - accessible to child classes */
11
- config;
12
- /** Initialization flag */
13
- initialized = false;
14
- /**
15
- * Get the current configuration
16
- */
17
- getConfig() {
18
- return this.config;
19
- }
20
- /**
21
- * Check if the MCP is initialized
22
- */
23
- isInitialized() {
24
- return this.initialized;
25
- }
26
- /**
27
- * Get plugin metadata
28
- */
29
- getMetadata() {
30
- return this.metadata;
31
- }
32
- /**
33
- * Validate that the MCP is ready for execution
34
- */
35
- ensureInitialized() {
36
- if (!this.initialized) {
37
- throw new Error(`MCP ${this.metadata.name} is not initialized. Call initialize() first.`);
38
- }
39
- }
40
- /**
41
- * Helper method for logging with context
42
- */
43
- log(context, level, message, data) {
44
- context.log(level, `[${this.metadata.name}] ${message}`, data);
45
- }
46
- }
47
- /**
48
- * MCP Category for organization
49
- */
50
- export var MCPCategory;
51
- (function (MCPCategory) {
52
- MCPCategory["FILESYSTEM"] = "filesystem";
53
- MCPCategory["NETWORK"] = "network";
54
- MCPCategory["DATABASE"] = "database";
55
- MCPCategory["AI"] = "ai";
56
- MCPCategory["UTILITY"] = "utility";
57
- MCPCategory["INTEGRATION"] = "integration";
58
- })(MCPCategory || (MCPCategory = {}));
@@ -1,46 +0,0 @@
1
- /**
2
- * Core Plugin Manager
3
- * Enhanced plugin management with advanced lifecycle control
4
- */
5
- import type { MCP, MCPMetadata, MCPConstructor, PluginLoadResult, PluginExecutionResult, ExecutionContext } from "../contracts/mcp-contract.js";
6
- import type { UnknownRecord, Unknown } from "../../types/common.js";
7
- /**
8
- * Enhanced plugin manager with core functionality
9
- */
10
- export declare class CorePluginManager {
11
- private plugins;
12
- private constructors;
13
- private metadata;
14
- /**
15
- * Load a plugin from constructor
16
- */
17
- loadPlugin(name: string, Constructor: MCPConstructor, config: UnknownRecord): Promise<PluginLoadResult>;
18
- /**
19
- * Execute a plugin operation
20
- */
21
- executePlugin<T = Unknown>(name: string, context: ExecutionContext, args: Unknown): Promise<PluginExecutionResult<T>>;
22
- /**
23
- * Get plugin instance
24
- */
25
- getPlugin(name: string): MCP | undefined;
26
- /**
27
- * Get plugin metadata
28
- */
29
- getPluginMetadata(name: string): MCPMetadata | undefined;
30
- /**
31
- * List all loaded plugins
32
- */
33
- listPlugins(): string[];
34
- /**
35
- * Unload a plugin
36
- */
37
- unloadPlugin(name: string): Promise<void>;
38
- /**
39
- * Dispose all plugins
40
- */
41
- dispose(): Promise<void>;
42
- }
43
- /**
44
- * Default core plugin manager instance
45
- */
46
- export declare const corePluginManager: CorePluginManager;
@@ -1,110 +0,0 @@
1
- /**
2
- * Core Plugin Manager
3
- * Enhanced plugin management with advanced lifecycle control
4
- */
5
- import { mcpLogger } from "../logging.js";
6
- /**
7
- * Enhanced plugin manager with core functionality
8
- */
9
- export class CorePluginManager {
10
- plugins = new Map();
11
- constructors = new Map();
12
- metadata = new Map();
13
- /**
14
- * Load a plugin from constructor
15
- */
16
- async loadPlugin(name, Constructor, config) {
17
- try {
18
- const instance = new Constructor();
19
- await instance.initialize(config);
20
- this.plugins.set(name, instance);
21
- this.constructors.set(name, Constructor);
22
- this.metadata.set(name, instance.getMetadata());
23
- mcpLogger.info(`[CorePluginManager] Loaded plugin: ${name}`);
24
- return {
25
- success: true,
26
- plugin: instance,
27
- };
28
- }
29
- catch (error) {
30
- mcpLogger.error(`[CorePluginManager] Failed to load plugin ${name}:`, error);
31
- return {
32
- success: false,
33
- error: error instanceof Error ? error.message : String(error),
34
- };
35
- }
36
- }
37
- /**
38
- * Execute a plugin operation
39
- */
40
- async executePlugin(name, context, args) {
41
- const startTime = Date.now();
42
- try {
43
- const plugin = this.plugins.get(name);
44
- if (!plugin) {
45
- throw new Error(`Plugin ${name} not loaded`);
46
- }
47
- const result = await plugin.execute(context, args);
48
- const executionTime = Date.now() - startTime;
49
- return {
50
- success: true,
51
- result: result,
52
- executionTime,
53
- };
54
- }
55
- catch (error) {
56
- const executionTime = Date.now() - startTime;
57
- mcpLogger.error(`[CorePluginManager] Plugin execution failed for ${name}:`, error);
58
- return {
59
- success: false,
60
- error: error instanceof Error ? error.message : String(error),
61
- executionTime,
62
- };
63
- }
64
- }
65
- /**
66
- * Get plugin instance
67
- */
68
- getPlugin(name) {
69
- return this.plugins.get(name);
70
- }
71
- /**
72
- * Get plugin metadata
73
- */
74
- getPluginMetadata(name) {
75
- return this.metadata.get(name);
76
- }
77
- /**
78
- * List all loaded plugins
79
- */
80
- listPlugins() {
81
- return Array.from(this.plugins.keys());
82
- }
83
- /**
84
- * Unload a plugin
85
- */
86
- async unloadPlugin(name) {
87
- const plugin = this.plugins.get(name);
88
- if (plugin) {
89
- await plugin.dispose();
90
- this.plugins.delete(name);
91
- this.constructors.delete(name);
92
- this.metadata.delete(name);
93
- mcpLogger.info(`[CorePluginManager] Unloaded plugin: ${name}`);
94
- }
95
- }
96
- /**
97
- * Dispose all plugins
98
- */
99
- async dispose() {
100
- const pluginNames = Array.from(this.plugins.keys());
101
- for (const name of pluginNames) {
102
- await this.unloadPlugin(name);
103
- }
104
- mcpLogger.info("[CorePluginManager] All plugins disposed");
105
- }
106
- }
107
- /**
108
- * Default core plugin manager instance
109
- */
110
- export const corePluginManager = new CorePluginManager();
@@ -1,20 +0,0 @@
1
- /**
2
- * Plugin Demo - Example MCP Plugin Usage
3
- */
4
- /**
5
- * Demo plugin functionality
6
- */
7
- export declare class PluginDemo {
8
- /**
9
- * Demonstrate filesystem plugin
10
- */
11
- static demonstrateFileSystem(): Promise<void>;
12
- /**
13
- * Demonstrate plugin execution via ecosystem
14
- */
15
- static demonstrateEcosystem(): Promise<void>;
16
- /**
17
- * Demonstrate quick plugin factory
18
- */
19
- static demonstrateQuickFactory(): Promise<void>;
20
- }
@@ -1,118 +0,0 @@
1
- /**
2
- * Plugin Demo - Example MCP Plugin Usage
3
- */
4
- import { mcpEcosystem } from "../ecosystem.js";
5
- import { FileSystemMCP } from "../plugins/core/filesystem-mcp.js";
6
- import { QuickPluginFactory, executePlugin, } from "../adapters/plugin-bridge.js";
7
- import { mcpLogger } from "../logging.js";
8
- /**
9
- * Demo plugin functionality
10
- */
11
- export class PluginDemo {
12
- /**
13
- * Demonstrate filesystem plugin
14
- */
15
- static async demonstrateFileSystem() {
16
- try {
17
- // Create filesystem plugin instance
18
- const fsPlugin = new FileSystemMCP();
19
- await fsPlugin.initialize({ basePath: process.cwd() });
20
- mcpLogger.info("FileSystem plugin demonstration started");
21
- // This would normally be done through the ecosystem
22
- // but we're demonstrating direct usage
23
- const result = await mcpEcosystem.filesystem({
24
- action: "listFiles",
25
- path: ".",
26
- basePath: process.cwd(),
27
- });
28
- mcpLogger.info("File listing result:", result);
29
- }
30
- catch (error) {
31
- mcpLogger.error("Demo failed:", error);
32
- }
33
- }
34
- /**
35
- * Demonstrate plugin execution via ecosystem
36
- */
37
- static async demonstrateEcosystem() {
38
- try {
39
- await mcpEcosystem.initialize();
40
- const stats = await mcpEcosystem.getStats();
41
- mcpLogger.info("MCP Ecosystem stats:", stats);
42
- // Try to read a file
43
- const fsPlugin = new FileSystemMCP();
44
- await fsPlugin.initialize({ basePath: process.cwd() });
45
- // Cast FileSystemMCP to UnknownRecord for executePlugin compatibility
46
- const pluginAsRecord = fsPlugin;
47
- const result = await executePlugin(pluginAsRecord, createMockContext(), "listFiles", ".");
48
- mcpLogger.info("Plugin execution result:", result);
49
- }
50
- catch (error) {
51
- mcpLogger.error("Ecosystem demo failed:", error);
52
- }
53
- }
54
- /**
55
- * Demonstrate quick plugin factory
56
- */
57
- static async demonstrateQuickFactory() {
58
- try {
59
- const fsPlugin = new FileSystemMCP();
60
- await fsPlugin.initialize({ basePath: process.cwd() });
61
- const quickPlugin = await QuickPluginFactory.create("demo-plugin", {
62
- basePath: process.cwd(),
63
- });
64
- mcpLogger.info("Quick plugin created:", quickPlugin);
65
- }
66
- catch (error) {
67
- mcpLogger.error("Quick factory demo failed:", error);
68
- }
69
- }
70
- }
71
- /**
72
- * Create a mock execution context for testing
73
- */
74
- function createMockContext() {
75
- return {
76
- sessionId: "demo-session",
77
- userId: "demo-user",
78
- grantedPermissions: ["fs:read:./**/*", "fs:write:./temp/**/*"],
79
- secureFS: {
80
- async readFile(path, encoding) {
81
- return `Mock content from ${path}`;
82
- },
83
- async writeFile(path, content) {
84
- mcpLogger.info(`Mock write to ${path}`);
85
- },
86
- async readdir(path) {
87
- return ["file1.txt", "file2.json", "subdir"];
88
- },
89
- async stat(path) {
90
- return {
91
- size: 1024,
92
- mtime: new Date(),
93
- isDirectory: () => false,
94
- isFile: () => true,
95
- };
96
- },
97
- async mkdir(path, options) {
98
- mcpLogger.info(`Mock mkdir: ${path}`);
99
- },
100
- async exists(path) {
101
- return true;
102
- },
103
- },
104
- path: {
105
- join: (...paths) => paths.join("/"),
106
- resolve: (...paths) => "/" + paths.join("/"),
107
- relative: (from, to) => to,
108
- dirname: (path) => path.split("/").slice(0, -1).join("/"),
109
- basename: (path, ext) => {
110
- const name = path.split("/").pop() || "";
111
- return ext ? name.replace(ext, "") : name;
112
- },
113
- },
114
- log: (level, message, data) => {
115
- mcpLogger[level](`[MockContext] ${message}`, data);
116
- },
117
- };
118
- }