@juspay/neurolink 5.3.0 → 6.1.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 (273) hide show
  1. package/CHANGELOG.md +83 -2
  2. package/dist/chat/client-utils.d.ts +3 -0
  3. package/dist/chat/client-utils.js +22 -5
  4. package/dist/chat/index.d.ts +4 -7
  5. package/dist/chat/index.js +0 -8
  6. package/dist/chat/session-storage.d.ts +2 -2
  7. package/dist/chat/session.d.ts +4 -3
  8. package/dist/chat/session.js +1 -1
  9. package/dist/chat/sse-handler.js +13 -21
  10. package/dist/chat/types.d.ts +3 -2
  11. package/dist/chat/websocket-chat-handler.d.ts +4 -3
  12. package/dist/chat/websocket-chat-handler.js +12 -12
  13. package/dist/cli/commands/config.d.ts +2 -2
  14. package/dist/cli/commands/mcp.d.ts +3 -2
  15. package/dist/cli/commands/mcp.js +39 -29
  16. package/dist/cli/commands/ollama.js +8 -4
  17. package/dist/cli/factories/command-factory.d.ts +2 -1
  18. package/dist/cli/index.js +22 -19
  19. package/dist/core/analytics.d.ts +3 -2
  20. package/dist/core/analytics.js +16 -7
  21. package/dist/core/base-provider.d.ts +35 -7
  22. package/dist/core/base-provider.js +36 -13
  23. package/dist/core/defaults.d.ts +2 -1
  24. package/dist/core/evaluation.d.ts +4 -4
  25. package/dist/core/evaluation.js +17 -7
  26. package/dist/core/factory.d.ts +3 -2
  27. package/dist/core/service-registry.d.ts +4 -4
  28. package/dist/core/types.d.ts +11 -4
  29. package/dist/factories/compatibility-factory.d.ts +16 -1
  30. package/dist/factories/compatibility-factory.js +3 -1
  31. package/dist/factories/provider-factory.d.ts +5 -4
  32. package/dist/factories/provider-factory.js +15 -24
  33. package/dist/factories/provider-generate-factory.js +26 -20
  34. package/dist/lib/chat/client-utils.d.ts +3 -0
  35. package/dist/lib/chat/client-utils.js +22 -5
  36. package/dist/lib/chat/index.d.ts +4 -7
  37. package/dist/lib/chat/index.js +0 -8
  38. package/dist/lib/chat/session-storage.d.ts +2 -2
  39. package/dist/lib/chat/session.d.ts +4 -3
  40. package/dist/lib/chat/session.js +1 -1
  41. package/dist/lib/chat/sse-handler.js +13 -21
  42. package/dist/lib/chat/types.d.ts +3 -2
  43. package/dist/lib/chat/websocket-chat-handler.d.ts +4 -3
  44. package/dist/lib/chat/websocket-chat-handler.js +12 -12
  45. package/dist/lib/core/analytics.d.ts +3 -2
  46. package/dist/lib/core/analytics.js +16 -7
  47. package/dist/lib/core/base-provider.d.ts +35 -7
  48. package/dist/lib/core/base-provider.js +36 -13
  49. package/dist/lib/core/defaults.d.ts +2 -1
  50. package/dist/lib/core/evaluation.d.ts +4 -4
  51. package/dist/lib/core/evaluation.js +17 -7
  52. package/dist/lib/core/factory.d.ts +3 -2
  53. package/dist/lib/core/service-registry.d.ts +4 -4
  54. package/dist/lib/core/types.d.ts +11 -4
  55. package/dist/lib/factories/compatibility-factory.d.ts +16 -1
  56. package/dist/lib/factories/compatibility-factory.js +3 -1
  57. package/dist/lib/factories/provider-factory.d.ts +5 -4
  58. package/dist/lib/factories/provider-factory.js +15 -24
  59. package/dist/lib/factories/provider-generate-factory.js +26 -20
  60. package/dist/lib/mcp/adapters/plugin-bridge.d.ts +5 -4
  61. package/dist/lib/mcp/adapters/plugin-bridge.js +13 -6
  62. package/dist/lib/mcp/client.d.ts +2 -1
  63. package/dist/lib/mcp/client.js +12 -10
  64. package/dist/lib/mcp/context-manager.d.ts +1 -1
  65. package/dist/lib/mcp/contracts/mcp-contract.d.ts +15 -8
  66. package/dist/lib/mcp/core/plugin-manager.d.ts +3 -2
  67. package/dist/lib/mcp/core/plugin-manager.js +1 -1
  68. package/dist/lib/mcp/demo/plugin-demo.js +3 -1
  69. package/dist/lib/mcp/dynamic-chain-executor.d.ts +64 -40
  70. package/dist/lib/mcp/dynamic-chain-executor.js +3 -3
  71. package/dist/lib/mcp/dynamic-orchestrator.d.ts +14 -8
  72. package/dist/lib/mcp/ecosystem.d.ts +4 -4
  73. package/dist/lib/mcp/error-manager.d.ts +2 -2
  74. package/dist/lib/mcp/error-recovery.d.ts +4 -3
  75. package/dist/lib/mcp/external-client.d.ts +1 -1
  76. package/dist/lib/mcp/external-client.js +14 -10
  77. package/dist/lib/mcp/external-manager.d.ts +3 -3
  78. package/dist/lib/mcp/external-manager.js +9 -3
  79. package/dist/lib/mcp/factory.d.ts +7 -7
  80. package/dist/lib/mcp/function-calling.d.ts +3 -2
  81. package/dist/lib/mcp/health-monitor.d.ts +2 -1
  82. package/dist/lib/mcp/health-monitor.js +16 -7
  83. package/dist/lib/mcp/index.d.ts +5 -5
  84. package/dist/lib/mcp/initialize-tools.d.ts +2 -1
  85. package/dist/lib/mcp/initialize-tools.js +10 -2
  86. package/dist/lib/mcp/manager.d.ts +2 -1
  87. package/dist/lib/mcp/neurolink-mcp-client.js +1 -1
  88. package/dist/lib/mcp/orchestrator.d.ts +13 -12
  89. package/dist/lib/mcp/orchestrator.js +10 -8
  90. package/dist/lib/mcp/plugin-manager.js +4 -2
  91. package/dist/lib/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
  92. package/dist/lib/mcp/plugins/core/filesystem-mcp.js +5 -2
  93. package/dist/lib/mcp/plugins/filesystem-mcp.d.ts +2 -1
  94. package/dist/lib/mcp/registry.d.ts +2 -1
  95. package/dist/lib/mcp/registry.js +2 -1
  96. package/dist/lib/mcp/security-manager.d.ts +4 -2
  97. package/dist/lib/mcp/servers/agent/direct-tools-server.js +18 -6
  98. package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
  99. package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
  100. package/dist/lib/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
  101. package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +15 -133
  102. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
  103. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
  104. package/dist/lib/mcp/session-manager.d.ts +4 -3
  105. package/dist/lib/mcp/session-persistence.js +5 -2
  106. package/dist/lib/mcp/tool-integration.d.ts +3 -2
  107. package/dist/lib/mcp/tool-integration.js +3 -1
  108. package/dist/lib/mcp/tool-registry.d.ts +18 -1
  109. package/dist/lib/mcp/tool-registry.js +11 -8
  110. package/dist/lib/mcp/transport-manager.d.ts +2 -1
  111. package/dist/lib/mcp/transport-manager.js +5 -1
  112. package/dist/lib/mcp/unified-mcp.d.ts +5 -5
  113. package/dist/lib/mcp/unified-registry.d.ts +18 -2
  114. package/dist/lib/mcp/unified-registry.js +52 -3
  115. package/dist/lib/neurolink.d.ts +2 -2
  116. package/dist/lib/neurolink.js +40 -15
  117. package/dist/lib/providers/amazon-bedrock.d.ts +1 -1
  118. package/dist/lib/providers/amazon-bedrock.js +8 -7
  119. package/dist/lib/providers/analytics-helper.d.ts +8 -23
  120. package/dist/lib/providers/analytics-helper.js +95 -33
  121. package/dist/lib/providers/anthropic-baseprovider.d.ts +3 -3
  122. package/dist/lib/providers/anthropic-baseprovider.js +6 -5
  123. package/dist/lib/providers/anthropic.d.ts +2 -2
  124. package/dist/lib/providers/anthropic.js +11 -4
  125. package/dist/lib/providers/azure-openai.d.ts +5 -4
  126. package/dist/lib/providers/azure-openai.js +10 -4
  127. package/dist/lib/providers/function-calling-provider.d.ts +2 -2
  128. package/dist/lib/providers/function-calling-provider.js +1 -1
  129. package/dist/lib/providers/google-ai-studio.d.ts +2 -2
  130. package/dist/lib/providers/google-ai-studio.js +9 -3
  131. package/dist/lib/providers/google-vertex.d.ts +2 -2
  132. package/dist/lib/providers/google-vertex.js +18 -12
  133. package/dist/lib/providers/huggingFace.d.ts +1 -1
  134. package/dist/lib/providers/huggingFace.js +8 -4
  135. package/dist/lib/providers/mcp-provider.d.ts +3 -3
  136. package/dist/lib/providers/mistral.d.ts +34 -27
  137. package/dist/lib/providers/mistral.js +115 -107
  138. package/dist/lib/providers/ollama.d.ts +2 -1
  139. package/dist/lib/providers/ollama.js +43 -3
  140. package/dist/lib/providers/openAI.d.ts +1 -1
  141. package/dist/lib/providers/openAI.js +8 -4
  142. package/dist/lib/proxy/proxy-fetch.js +3 -2
  143. package/dist/lib/sdk/tool-extension.d.ts +12 -12
  144. package/dist/lib/sdk/tool-extension.js +2 -1
  145. package/dist/lib/sdk/tool-registration.d.ts +16 -12
  146. package/dist/lib/sdk/tool-registration.js +3 -2
  147. package/dist/lib/services/types.d.ts +5 -4
  148. package/dist/lib/services/websocket/websocket-server.d.ts +1 -1
  149. package/dist/lib/services/websocket/websocket-server.js +1 -1
  150. package/dist/lib/telemetry/telemetry-service.js +1 -1
  151. package/dist/lib/types/cli.d.ts +247 -0
  152. package/dist/lib/types/cli.js +22 -0
  153. package/dist/lib/types/common.d.ts +76 -0
  154. package/dist/lib/types/common.js +52 -0
  155. package/dist/lib/types/generate-types.d.ts +6 -6
  156. package/dist/lib/types/index.d.ts +12 -0
  157. package/dist/lib/types/index.js +12 -0
  158. package/dist/lib/types/mcp-types.d.ts +7 -7
  159. package/dist/lib/types/providers.d.ts +158 -0
  160. package/dist/lib/types/providers.js +23 -0
  161. package/dist/lib/types/stream-types.d.ts +4 -3
  162. package/dist/lib/types/tools.d.ts +154 -0
  163. package/dist/lib/types/tools.js +24 -0
  164. package/dist/lib/utils/logger.d.ts +5 -5
  165. package/dist/lib/utils/provider-validation.d.ts +2 -1
  166. package/dist/mcp/adapters/plugin-bridge.d.ts +5 -4
  167. package/dist/mcp/adapters/plugin-bridge.js +13 -6
  168. package/dist/mcp/client.d.ts +2 -1
  169. package/dist/mcp/client.js +12 -10
  170. package/dist/mcp/context-manager.d.ts +1 -1
  171. package/dist/mcp/contracts/mcp-contract.d.ts +15 -8
  172. package/dist/mcp/core/plugin-manager.d.ts +3 -2
  173. package/dist/mcp/core/plugin-manager.js +1 -1
  174. package/dist/mcp/demo/plugin-demo.js +3 -1
  175. package/dist/mcp/dynamic-chain-executor.d.ts +64 -40
  176. package/dist/mcp/dynamic-chain-executor.js +3 -3
  177. package/dist/mcp/dynamic-orchestrator.d.ts +14 -8
  178. package/dist/mcp/dynamic-orchestrator.js +1 -1
  179. package/dist/mcp/ecosystem.d.ts +4 -4
  180. package/dist/mcp/error-manager.d.ts +2 -2
  181. package/dist/mcp/error-recovery.d.ts +4 -3
  182. package/dist/mcp/external-client.d.ts +1 -1
  183. package/dist/mcp/external-client.js +14 -10
  184. package/dist/mcp/external-manager.d.ts +3 -3
  185. package/dist/mcp/external-manager.js +9 -3
  186. package/dist/mcp/factory.d.ts +7 -7
  187. package/dist/mcp/function-calling.d.ts +3 -2
  188. package/dist/mcp/health-monitor.d.ts +2 -1
  189. package/dist/mcp/health-monitor.js +16 -7
  190. package/dist/mcp/index.d.ts +5 -5
  191. package/dist/mcp/initialize-tools.d.ts +2 -1
  192. package/dist/mcp/initialize-tools.js +10 -2
  193. package/dist/mcp/manager.d.ts +2 -1
  194. package/dist/mcp/neurolink-mcp-client.js +1 -1
  195. package/dist/mcp/orchestrator.d.ts +13 -12
  196. package/dist/mcp/orchestrator.js +10 -8
  197. package/dist/mcp/plugin-manager.js +4 -2
  198. package/dist/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
  199. package/dist/mcp/plugins/core/filesystem-mcp.js +5 -2
  200. package/dist/mcp/plugins/filesystem-mcp.d.ts +2 -1
  201. package/dist/mcp/registry.d.ts +2 -1
  202. package/dist/mcp/registry.js +2 -1
  203. package/dist/mcp/security-manager.d.ts +4 -2
  204. package/dist/mcp/servers/agent/direct-tools-server.js +19 -6
  205. package/dist/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
  206. package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
  207. package/dist/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
  208. package/dist/mcp/servers/ai-providers/ai-core-server.js +15 -132
  209. package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
  210. package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
  211. package/dist/mcp/session-manager.d.ts +4 -3
  212. package/dist/mcp/session-persistence.js +5 -2
  213. package/dist/mcp/tool-integration.d.ts +3 -2
  214. package/dist/mcp/tool-integration.js +3 -1
  215. package/dist/mcp/tool-registry.d.ts +18 -1
  216. package/dist/mcp/tool-registry.js +11 -8
  217. package/dist/mcp/transport-manager.d.ts +2 -1
  218. package/dist/mcp/transport-manager.js +5 -1
  219. package/dist/mcp/unified-mcp.d.ts +5 -5
  220. package/dist/mcp/unified-registry.d.ts +18 -2
  221. package/dist/mcp/unified-registry.js +52 -3
  222. package/dist/neurolink.d.ts +2 -2
  223. package/dist/neurolink.js +40 -15
  224. package/dist/providers/amazon-bedrock.d.ts +1 -1
  225. package/dist/providers/amazon-bedrock.js +8 -7
  226. package/dist/providers/analytics-helper.d.ts +8 -23
  227. package/dist/providers/analytics-helper.js +95 -33
  228. package/dist/providers/anthropic-baseprovider.d.ts +3 -3
  229. package/dist/providers/anthropic-baseprovider.js +6 -5
  230. package/dist/providers/anthropic.d.ts +2 -2
  231. package/dist/providers/anthropic.js +11 -4
  232. package/dist/providers/azure-openai.d.ts +5 -4
  233. package/dist/providers/azure-openai.js +10 -4
  234. package/dist/providers/function-calling-provider.d.ts +2 -2
  235. package/dist/providers/function-calling-provider.js +1 -1
  236. package/dist/providers/google-ai-studio.d.ts +2 -2
  237. package/dist/providers/google-ai-studio.js +9 -3
  238. package/dist/providers/google-vertex.d.ts +2 -2
  239. package/dist/providers/google-vertex.js +18 -12
  240. package/dist/providers/huggingFace.d.ts +1 -1
  241. package/dist/providers/huggingFace.js +8 -4
  242. package/dist/providers/mcp-provider.d.ts +3 -3
  243. package/dist/providers/mistral.d.ts +34 -27
  244. package/dist/providers/mistral.js +116 -108
  245. package/dist/providers/ollama.d.ts +2 -1
  246. package/dist/providers/ollama.js +43 -3
  247. package/dist/providers/openAI.d.ts +1 -1
  248. package/dist/providers/openAI.js +8 -4
  249. package/dist/proxy/proxy-fetch.js +3 -2
  250. package/dist/sdk/tool-extension.d.ts +12 -12
  251. package/dist/sdk/tool-extension.js +2 -1
  252. package/dist/sdk/tool-registration.d.ts +16 -12
  253. package/dist/sdk/tool-registration.js +3 -2
  254. package/dist/services/types.d.ts +5 -4
  255. package/dist/services/websocket/websocket-server.d.ts +1 -1
  256. package/dist/services/websocket/websocket-server.js +2 -1
  257. package/dist/telemetry/telemetry-service.js +1 -1
  258. package/dist/types/cli.d.ts +247 -0
  259. package/dist/types/cli.js +22 -0
  260. package/dist/types/common.d.ts +76 -0
  261. package/dist/types/common.js +52 -0
  262. package/dist/types/generate-types.d.ts +6 -6
  263. package/dist/types/index.d.ts +12 -0
  264. package/dist/types/index.js +12 -0
  265. package/dist/types/mcp-types.d.ts +7 -7
  266. package/dist/types/providers.d.ts +158 -0
  267. package/dist/types/providers.js +23 -0
  268. package/dist/types/stream-types.d.ts +4 -3
  269. package/dist/types/tools.d.ts +154 -0
  270. package/dist/types/tools.js +25 -0
  271. package/dist/utils/logger.d.ts +5 -5
  272. package/dist/utils/provider-validation.d.ts +2 -1
  273. package/package.json +2 -1
@@ -578,26 +578,35 @@ export class HealthMonitor {
578
578
  */
579
579
  generateRecommendations(summary, servers) {
580
580
  const recommendations = [];
581
+ // Type-safe access to summary properties
582
+ const overallHealth = typeof summary.overallHealth === "number" ? summary.overallHealth : 0;
583
+ const unhealthyServers = typeof summary.unhealthyServers === "number"
584
+ ? summary.unhealthyServers
585
+ : 0;
586
+ const totalServers = typeof summary.totalServers === "number" ? summary.totalServers : 1;
581
587
  // Check overall health
582
- if (summary.overallHealth < 50) {
588
+ if (overallHealth < 50) {
583
589
  recommendations.push("Critical: System health is below 50%. Immediate attention required.");
584
590
  }
585
591
  // Check unhealthy servers
586
- if (summary.unhealthyServers > summary.totalServers * 0.3) {
592
+ if (unhealthyServers > totalServers * 0.3) {
587
593
  recommendations.push("Multiple servers are failing. Check network connectivity and server availability.");
588
594
  }
589
595
  // Check recovery attempts
590
- const highRecoveryServers = servers.filter((s) => s.metrics.recoveryAttempts > 2);
596
+ const highRecoveryServers = servers.filter((s) => typeof s.metrics === "object" &&
597
+ s.metrics &&
598
+ typeof s.metrics.recoveryAttempts === "number" &&
599
+ s.metrics.recoveryAttempts > 2);
591
600
  if (highRecoveryServers.length > 0) {
592
- recommendations.push(`Servers with repeated recovery attempts: ${highRecoveryServers.map((s) => s.serverId).join(", ")}. Consider manual intervention.`);
601
+ recommendations.push(`Servers with repeated recovery attempts: ${highRecoveryServers.map((s) => (typeof s.serverId === "string" ? s.serverId : "unknown")).join(", ")}. Consider manual intervention.`);
593
602
  }
594
603
  // Check latency
595
- const highLatencyServers = servers.filter((s) => s.avgLatency > 1000);
604
+ const highLatencyServers = servers.filter((s) => typeof s.avgLatency === "number" && s.avgLatency > 1000);
596
605
  if (highLatencyServers.length > 0) {
597
- recommendations.push(`High latency detected on servers: ${highLatencyServers.map((s) => s.serverId).join(", ")}. Check server load and network conditions.`);
606
+ recommendations.push(`High latency detected on servers: ${highLatencyServers.map((s) => (typeof s.serverId === "string" ? s.serverId : "unknown")).join(", ")}. Check server load and network conditions.`);
598
607
  }
599
608
  // Positive feedback
600
- if (summary.overallHealth >= 90) {
609
+ if (overallHealth >= 90) {
601
610
  recommendations.push("System health is excellent. All servers are operating normally.");
602
611
  }
603
612
  return recommendations;
@@ -23,17 +23,17 @@ export declare function listMCPs(): Promise<MCPMetadata[]>;
23
23
  /**
24
24
  * Execute an MCP operation
25
25
  */
26
- export declare function executeMCP<T = any>(name: string, config: any, args: any, context?: {
26
+ export declare function executeMCP<T = unknown>(name: string, config: unknown, args: unknown, context?: {
27
27
  sessionId?: string;
28
28
  userId?: string;
29
29
  }): Promise<T>;
30
30
  /**
31
31
  * Quick filesystem operations
32
32
  */
33
- export declare function readFile(path: string, basePath?: string): Promise<any>;
34
- export declare function writeFile(path: string, content: string, basePath?: string): Promise<any>;
35
- export declare function listFiles(path: string, basePath?: string): Promise<any>;
36
- export declare function createDirectory(path: string, basePath?: string): Promise<any>;
33
+ export declare function readFile(path: string, basePath?: string): Promise<string | Buffer>;
34
+ export declare function writeFile(path: string, content: string, basePath?: string): Promise<void>;
35
+ export declare function listFiles(path: string, basePath?: string): Promise<string[]>;
36
+ export declare function createDirectory(path: string, basePath?: string): Promise<void>;
37
37
  /**
38
38
  * Get MCP ecosystem statistics
39
39
  */
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type { NeuroLinkMCPClient } from "./client.js";
6
6
  import type { NeuroLinkExecutionContext } from "./factory.js";
7
+ import type { UnknownRecord } from "../types/common.js";
7
8
  /**
8
9
  * Initialize and register tools from MCP Servers with the MCP client
9
10
  * Following Lighthouse's pattern for tool registration
@@ -13,7 +14,7 @@ export declare const initializeMCPTools: (sessionId: string, client: NeuroLinkMC
13
14
  * Get all available tools across all servers
14
15
  * Useful for documentation and discovery
15
16
  */
16
- export declare function getAllAvailableTools(inMemoryServers?: Map<string, any>): Promise<Array<{
17
+ export declare function getAllAvailableTools(inMemoryServers?: Map<string, UnknownRecord>): Promise<Array<{
17
18
  serverId: string;
18
19
  serverTitle: string;
19
20
  toolName: string;
@@ -145,7 +145,10 @@ export async function getAllAvailableTools(inMemoryServers) {
145
145
  if (inMemoryServers) {
146
146
  for (const [serverId, serverConfig] of inMemoryServers) {
147
147
  const server = serverConfig.server;
148
- if (server && server.tools) {
148
+ if (server &&
149
+ typeof server === "object" &&
150
+ "tools" in server &&
151
+ server.tools) {
149
152
  // Handle both Map and object formats
150
153
  const toolEntries = server.tools instanceof Map
151
154
  ? Array.from(server.tools.entries())
@@ -175,7 +178,12 @@ export async function getAllAvailableTools(inMemoryServers) {
175
178
  }
176
179
  tools.push({
177
180
  serverId,
178
- serverTitle: server.title || serverId,
181
+ serverTitle: typeof server === "object" &&
182
+ server &&
183
+ "title" in server &&
184
+ typeof server.title === "string"
185
+ ? server.title
186
+ : serverId,
179
187
  toolName,
180
188
  namespacedName,
181
189
  description,
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { NeuroLinkMCPClient } from "./client.js";
6
6
  import type { MCPClientConfig } from "./client.js";
7
+ import type { UnknownRecord } from "../types/common.js";
7
8
  /**
8
9
  * MCP Manager - Factory pattern for managing multiple client instances
9
10
  * Following Lighthouse's session-based architecture
@@ -46,7 +47,7 @@ export declare class NeuroLinkMCPManager {
46
47
  static getAllStats(): {
47
48
  instanceCount: number;
48
49
  maxInstances: number;
49
- instances: Record<string, any>;
50
+ instances: Record<string, UnknownRecord>;
50
51
  };
51
52
  /**
52
53
  * Clear all instances (for testing or shutdown)
@@ -382,7 +382,7 @@ Response (JSON array only):`;
382
382
  const toolResult = toolResults[0];
383
383
  if (toolResult.result.success && toolResult.result.data) {
384
384
  const data = toolResult.result.data;
385
- if (data.displayString) {
385
+ if (typeof data.displayString === "string") {
386
386
  return data.displayString;
387
387
  }
388
388
  }
@@ -5,6 +5,7 @@
5
5
  * Now with semaphore-based race condition prevention
6
6
  */
7
7
  import type { ToolResult } from "./factory.js";
8
+ import type { JsonValue, UnknownRecord } from "../types/common.js";
8
9
  import { MCPToolRegistry, type ToolExecutionOptions } from "./tool-registry.js";
9
10
  import { ContextManager, type ContextRequest } from "./context-manager.js";
10
11
  import { SemaphoreManager } from "./semaphore-manager.js";
@@ -27,7 +28,7 @@ export interface PipelineOptions {
27
28
  */
28
29
  export interface PipelineStep {
29
30
  toolName: string;
30
- params: any;
31
+ params: JsonValue;
31
32
  options?: ToolExecutionOptions;
32
33
  dependsOn?: string[];
33
34
  stepId?: string;
@@ -95,7 +96,7 @@ export declare class MCPOrchestrator {
95
96
  * @param options Execution options
96
97
  * @returns Tool execution result
97
98
  */
98
- executeTool(toolName: string, params: any, contextRequest?: ContextRequest, options?: ToolExecutionOptions & {
99
+ executeTool(toolName: string, params: JsonValue, contextRequest?: ContextRequest, options?: ToolExecutionOptions & {
99
100
  sessionOptions?: SessionOptions;
100
101
  }): Promise<ToolResult>;
101
102
  /**
@@ -129,11 +130,11 @@ export declare class MCPOrchestrator {
129
130
  * @returns Comprehensive orchestrator statistics
130
131
  */
131
132
  getStats(): {
132
- registry: any;
133
- context: any;
134
- session: any;
135
- error: any;
136
- health?: any;
133
+ registry: UnknownRecord;
134
+ context: UnknownRecord;
135
+ session: UnknownRecord;
136
+ error: UnknownRecord;
137
+ health?: UnknownRecord;
137
138
  orchestrator: {
138
139
  pipelinesExecuted: number;
139
140
  };
@@ -162,7 +163,7 @@ export declare class MCPOrchestrator {
162
163
  * @param value State value
163
164
  * @returns Success status
164
165
  */
165
- setSessionState(sessionId: string, key: string, value: any): Promise<boolean>;
166
+ setSessionState(sessionId: string, key: string, value: JsonValue): Promise<boolean>;
166
167
  /**
167
168
  * Get session state value
168
169
  *
@@ -170,7 +171,7 @@ export declare class MCPOrchestrator {
170
171
  * @param key State key
171
172
  * @returns State value or undefined
172
173
  */
173
- getSessionState(sessionId: string, key: string): Promise<any>;
174
+ getSessionState(sessionId: string, key: string): Promise<JsonValue | undefined>;
174
175
  /**
175
176
  * Get all active sessions
176
177
  *
@@ -240,7 +241,7 @@ export declare class MCPOrchestrator {
240
241
  * @param config Transport configuration
241
242
  * @returns Connected MCP client
242
243
  */
243
- connectTransport(config: TransportConfig): Promise<any>;
244
+ connectTransport(config: TransportConfig): Promise<unknown>;
244
245
  /**
245
246
  * Disconnect from MCP server
246
247
  */
@@ -280,7 +281,7 @@ export declare const defaultOrchestrator: MCPOrchestrator;
280
281
  * @param options Execution options
281
282
  * @returns Tool execution result
282
283
  */
283
- export declare function executeTool(toolName: string, params: any, contextRequest?: ContextRequest, options?: ToolExecutionOptions): Promise<ToolResult>;
284
+ export declare function executeTool(toolName: string, params: JsonValue, contextRequest?: ContextRequest, options?: ToolExecutionOptions): Promise<ToolResult>;
284
285
  /**
285
286
  * Utility function to execute text generation pipeline
286
287
  *
@@ -289,7 +290,7 @@ export declare function executeTool(toolName: string, params: any, contextReques
289
290
  * @param options Generation options
290
291
  * @returns Text generation result
291
292
  */
292
- export declare function executeTextPipeline(prompt: string, contextRequest?: ContextRequest, options?: any): Promise<TextPipelineResult>;
293
+ export declare function executeTextPipeline(prompt: string, contextRequest?: ContextRequest, options?: UnknownRecord): Promise<TextPipelineResult>;
293
294
  /**
294
295
  * Utility function to execute pipeline with default orchestrator
295
296
  *
@@ -295,7 +295,7 @@ export class MCPOrchestrator {
295
295
  toolName: "select-provider",
296
296
  params: {
297
297
  requirements: {
298
- maxTokens: options.maxTokens,
298
+ maxTokens: options.maxTokens || 1000,
299
299
  costEfficient: true,
300
300
  },
301
301
  },
@@ -307,11 +307,11 @@ export class MCPOrchestrator {
307
307
  toolName: "generate",
308
308
  params: {
309
309
  prompt,
310
- provider: options.provider,
311
- model: options.model,
312
- temperature: options.temperature,
313
- maxTokens: options.maxTokens,
314
- systemPrompt: options.systemPrompt,
310
+ provider: options.provider || "auto",
311
+ model: options.model || "default",
312
+ temperature: options.temperature || 0.7,
313
+ maxTokens: options.maxTokens || 1000,
314
+ systemPrompt: options.systemPrompt || "",
315
315
  },
316
316
  dependsOn: options.provider ? [] : ["select-provider"],
317
317
  });
@@ -346,7 +346,8 @@ export class MCPOrchestrator {
346
346
  return {
347
347
  success: true,
348
348
  text: textResult.data?.text,
349
- provider: textResult.data?.provider || providerResult?.data?.provider,
349
+ provider: textResult.data?.provider ||
350
+ providerResult?.data?.provider,
350
351
  model: textResult.data?.model,
351
352
  executionTime,
352
353
  usage: textResult.usage,
@@ -441,7 +442,8 @@ export class MCPOrchestrator {
441
442
  * @returns State value or undefined
442
443
  */
443
444
  async getSessionState(sessionId, key) {
444
- return this.sessionManager.getSessionState(sessionId, key);
445
+ const result = this.sessionManager.getSessionState(sessionId, key);
446
+ return result;
445
447
  }
446
448
  /**
447
449
  * Get all active sessions
@@ -168,10 +168,12 @@ export class PluginManager {
168
168
  return false;
169
169
  }
170
170
  const obj = manifest;
171
- return (typeof obj.name === "string" &&
171
+ return Boolean(typeof obj.name === "string" &&
172
172
  typeof obj.version === "string" &&
173
173
  typeof obj.main === "string" &&
174
- obj.engine?.neurolink &&
174
+ typeof obj.engine === "object" &&
175
+ obj.engine &&
176
+ "neurolink" in obj.engine &&
175
177
  typeof obj.description === "string" &&
176
178
  Array.isArray(obj.permissions));
177
179
  }
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { MCP } from "../../contracts/mcp-contract.js";
6
6
  import type { MCPMetadata, ExecutionContext } from "../../contracts/mcp-contract.js";
7
+ import type { UnknownRecord } from "../../../types/common.js";
7
8
  interface FileSystemConfig {
8
9
  basePath: string;
9
10
  allowedExtensions?: string[];
@@ -12,11 +13,11 @@ interface FileSystemArgs {
12
13
  operation: "readFile" | "writeFile" | "listFiles" | "createDir";
13
14
  path: string;
14
15
  content?: string;
15
- options?: any;
16
+ options?: UnknownRecord;
16
17
  }
17
18
  interface FileSystemResult {
18
19
  success: boolean;
19
- data?: any;
20
+ data?: UnknownRecord;
20
21
  error?: string;
21
22
  }
22
23
  /**
@@ -77,7 +77,8 @@ export class FileSystemMCP extends MCP {
77
77
  data: {
78
78
  content,
79
79
  size: stats.size,
80
- lastModified: stats.mtime,
80
+ lastModified: stats.mtime ||
81
+ new Date(stats.mtimeMs || Date.now()),
81
82
  path: filePath,
82
83
  },
83
84
  };
@@ -104,7 +105,9 @@ export class FileSystemMCP extends MCP {
104
105
  name: item,
105
106
  type: stats.isDirectory() ? "directory" : "file",
106
107
  size: stats.isFile() ? stats.size : undefined,
107
- lastModified: stats.mtime,
108
+ lastModified: stats.mtime ||
109
+ new Date(stats.mtimeMs ||
110
+ Date.now()),
108
111
  });
109
112
  }
110
113
  catch {
@@ -4,6 +4,7 @@
4
4
  * Based on research document recommendations
5
5
  */
6
6
  import { MCP, type MCPMetadata, type ExecutionContext } from "../contracts/mcp-contract.js";
7
+ import type { Unknown } from "../../types/common.js";
7
8
  /**
8
9
  * FileSystem MCP Configuration
9
10
  */
@@ -29,7 +30,7 @@ export declare class FileSystemMCP extends MCP<FileSystemConfig> {
29
30
  config: FileSystemConfig;
30
31
  readonly metadata: MCPMetadata;
31
32
  initialize(config: FileSystemConfig): Promise<void>;
32
- execute(context: ExecutionContext, args: FileSystemArgs): Promise<any>;
33
+ execute(context: ExecutionContext, args: FileSystemArgs): Promise<Unknown>;
33
34
  private resolvePath;
34
35
  dispose(): Promise<void>;
35
36
  }
@@ -2,6 +2,7 @@
2
2
  * MCP Registry - Industry Standard Interface with camelCase
3
3
  */
4
4
  import type { DiscoveredMcp, ExecutionContext, ToolInfo } from "./contracts/mcpContract.js";
5
+ import type { UnknownRecord } from "../types/common.js";
5
6
  /**
6
7
  * MCP Registry interface with optional methods for maximum flexibility
7
8
  */
@@ -59,7 +60,7 @@ export declare class MCPRegistry implements McpRegistry {
59
60
  /**
60
61
  * Execute a tool (legacy sync version)
61
62
  */
62
- executeToolSync(toolName: string, args?: unknown): any;
63
+ executeToolSync(toolName: string, args?: unknown): UnknownRecord;
63
64
  /**
64
65
  * List all tools (legacy sync version)
65
66
  */
@@ -58,7 +58,8 @@ export class MCPRegistry {
58
58
  metadata: {
59
59
  name: serverId,
60
60
  description: typeof serverConfig === "object" && serverConfig
61
- ? serverConfig.description || "No description"
61
+ ? serverConfig.description ||
62
+ "No description"
62
63
  : "No description",
63
64
  },
64
65
  tools: typeof serverConfig === "object" && serverConfig
@@ -2,6 +2,8 @@
2
2
  * Security Manager - Permission-Based Sandbox for MCP Operations
3
3
  * Implements the research blueprint's security-by-design principles
4
4
  */
5
+ import type { Stats } from "fs";
6
+ import type { UnknownRecord } from "../types/common.js";
5
7
  import type { ExecutionContext } from "./contracts/mcp-contract.js";
6
8
  /**
7
9
  * Security levels for plugin execution
@@ -66,8 +68,8 @@ export declare class SecurityManager {
66
68
  readFile(filePath: string, encoding?: string): Promise<string | Buffer>;
67
69
  writeFile(filePath: string, content: string | Buffer): Promise<void>;
68
70
  readdir(dirPath: string): Promise<string[]>;
69
- stat(filePath: string): Promise<any>;
70
- mkdir(dirPath: string, options?: any): Promise<void>;
71
+ stat(filePath: string): Promise<Stats>;
72
+ mkdir(dirPath: string, options?: UnknownRecord): Promise<void>;
71
73
  exists(filePath: string): Promise<boolean>;
72
74
  };
73
75
  /**
@@ -22,9 +22,18 @@ Object.entries(directAgentTools).forEach(([toolName, toolDef]) => {
22
22
  // The toolDef is a Vercel AI SDK Tool object
23
23
  // Extract properties from the Tool object
24
24
  const toolSpec = toolDef._spec || toolDef;
25
- const description = toolSpec.description || `Direct tool: ${toolName}`;
26
- const inputSchema = toolSpec.parameters;
27
- const execute = toolSpec.execute;
25
+ const description = typeof toolSpec === "object" &&
26
+ toolSpec &&
27
+ "description" in toolSpec &&
28
+ typeof toolSpec.description === "string"
29
+ ? toolSpec.description
30
+ : `Direct tool: ${toolName}`;
31
+ const inputSchema = typeof toolSpec === "object" && toolSpec && "parameters" in toolSpec
32
+ ? toolSpec.parameters
33
+ : undefined;
34
+ const execute = typeof toolSpec === "object" && toolSpec && "execute" in toolSpec
35
+ ? toolSpec.execute
36
+ : undefined;
28
37
  directToolsServer.registerTool({
29
38
  name: toolName,
30
39
  description: description,
@@ -36,12 +45,15 @@ Object.entries(directAgentTools).forEach(([toolName, toolDef]) => {
36
45
  try {
37
46
  logger.debug(`[Direct Tools] Executing ${toolName} with params:`, params);
38
47
  // Execute the direct tool
48
+ if (!execute || typeof execute !== "function") {
49
+ throw new Error(`Tool ${toolName} has no execute function`);
50
+ }
39
51
  const result = await execute(params);
40
52
  // Convert direct tool result to ToolResult format
41
- if (result.success) {
53
+ if (result?.success) {
42
54
  return {
43
55
  success: true,
44
- data: result,
56
+ data: result.data || result,
45
57
  usage: {
46
58
  executionTime: Date.now() - startTime,
47
59
  },
@@ -56,7 +68,7 @@ Object.entries(directAgentTools).forEach(([toolName, toolDef]) => {
56
68
  return {
57
69
  success: false,
58
70
  data: null,
59
- error: result.error || "Unknown error",
71
+ error: String(result?.error) || "Unknown error",
60
72
  usage: {
61
73
  executionTime: Date.now() - startTime,
62
74
  },
@@ -3,19 +3,4 @@
3
3
  * AI-focused MCP tools for usage analysis, performance benchmarking, and parameter optimization
4
4
  * Tools: analyze-ai-usage, benchmark-provider-performance, optimize-prompt-parameters
5
5
  */
6
- import type { NeuroLinkMCPTool } from "../../factory.js";
7
- /**
8
- * AI Usage Analysis Tool
9
- * Analyzes AI usage patterns, token consumption, and cost optimization opportunities
10
- */
11
- export declare const analyzeAIUsageTool: NeuroLinkMCPTool;
12
- /**
13
- * Provider Performance Benchmarking Tool
14
- * Benchmarks AI provider performance across latency, quality, and cost metrics
15
- */
16
- export declare const benchmarkProviderPerformanceTool: NeuroLinkMCPTool;
17
- /**
18
- * Prompt Parameter Optimization Tool
19
- * Optimizes prompt parameters (temperature, max tokens) for better AI output quality and efficiency
20
- */
21
- export declare const optimizePromptParametersTool: NeuroLinkMCPTool;
6
+ export {};
@@ -77,7 +77,7 @@ const OptimizeParametersSchema = z.object({
77
77
  * AI Usage Analysis Tool
78
78
  * Analyzes AI usage patterns, token consumption, and cost optimization opportunities
79
79
  */
80
- export const analyzeAIUsageTool = {
80
+ const analyzeAIUsageTool = {
81
81
  name: "analyze-ai-usage",
82
82
  description: "Analyze AI usage patterns, token consumption, and cost optimization opportunities",
83
83
  category: "ai-analysis",
@@ -86,9 +86,10 @@ export const analyzeAIUsageTool = {
86
86
  permissions: ["read", "analytics"],
87
87
  version: "1.2.0", // Updated version with real AI
88
88
  execute: async (params, context) => {
89
+ const typedParams = params;
89
90
  const startTime = Date.now();
90
91
  try {
91
- console.log(`[AI-Analysis] Starting real AI-powered usage analysis for timeRange: ${params.timeRange}`);
92
+ console.log(`[AI-Analysis] Starting real AI-powered usage analysis for timeRange: ${typedParams.timeRange}`);
92
93
  const providerName = await getBestProvider();
93
94
  const provider = await AIProviderFactory.createProvider(providerName);
94
95
  if (!provider) {
@@ -96,8 +97,8 @@ export const analyzeAIUsageTool = {
96
97
  }
97
98
  const analysisPrompt = `
98
99
  Analyze hypothetical AI usage data for a project based on the following parameters.
99
- Time Range: ${params.timeRange}
100
- Provider Focus: ${params.provider || "all"}
100
+ Time Range: ${typedParams.timeRange}
101
+ Provider Focus: ${typedParams.provider || "all"}
101
102
 
102
103
  Generate a realistic analysis including:
103
104
  1. A summary of usage statistics (totalRequests, totalTokens).
@@ -161,7 +162,7 @@ export const analyzeAIUsageTool = {
161
162
  * Provider Performance Benchmarking Tool
162
163
  * Benchmarks AI provider performance across latency, quality, and cost metrics
163
164
  */
164
- export const benchmarkProviderPerformanceTool = {
165
+ const benchmarkProviderPerformanceTool = {
165
166
  name: "benchmark-provider-performance",
166
167
  description: "Benchmark AI provider performance across latency, quality, and cost metrics",
167
168
  category: "ai-analysis",
@@ -170,10 +171,11 @@ export const benchmarkProviderPerformanceTool = {
170
171
  permissions: ["read", "benchmark"],
171
172
  version: "1.1.0", // Updated version with real AI
172
173
  execute: async (params, context) => {
174
+ const typedParams = params;
173
175
  const startTime = Date.now();
174
176
  try {
175
- const providersToTest = params.providers || getAvailableProviders();
176
- const testPrompts = params.testPrompts || [
177
+ const providersToTest = typedParams.providers || getAvailableProviders();
178
+ const testPrompts = typedParams.testPrompts || [
177
179
  "Explain quantum computing in simple terms",
178
180
  ];
179
181
  const benchmarkResults = [];
@@ -188,11 +190,11 @@ export const benchmarkProviderPerformanceTool = {
188
190
  }
189
191
  let totalLatency = 0, totalTokens = 0, successfulTests = 0;
190
192
  for (const prompt of testPrompts) {
191
- for (let i = 0; i < params.iterations; i++) {
193
+ for (let i = 0; i < typedParams.iterations; i++) {
192
194
  const testStartTime = Date.now();
193
195
  const result = await provider.generate({
194
196
  prompt: prompt,
195
- maxTokens: params.maxTokens,
197
+ maxTokens: typedParams.maxTokens,
196
198
  });
197
199
  if (result && result.usage) {
198
200
  totalLatency += Date.now() - testStartTime;
@@ -208,7 +210,8 @@ export const benchmarkProviderPerformanceTool = {
208
210
  ? Math.round(totalLatency / successfulTests)
209
211
  : 0,
210
212
  totalTokens: totalTokens,
211
- successRate: (successfulTests / (testPrompts.length * params.iterations)) *
213
+ successRate: (successfulTests /
214
+ (testPrompts.length * typedParams.iterations)) *
212
215
  100,
213
216
  },
214
217
  });
@@ -255,7 +258,7 @@ export const benchmarkProviderPerformanceTool = {
255
258
  * Prompt Parameter Optimization Tool
256
259
  * Optimizes prompt parameters (temperature, max tokens) for better AI output quality and efficiency
257
260
  */
258
- export const optimizePromptParametersTool = {
261
+ const optimizePromptParametersTool = {
259
262
  name: "optimize-prompt-parameters",
260
263
  description: "Optimize prompt parameters (temperature, max tokens) for better AI output quality and efficiency",
261
264
  category: "ai-optimization",
@@ -264,9 +267,10 @@ export const optimizePromptParametersTool = {
264
267
  permissions: ["read", "optimize"],
265
268
  version: "1.1.0", // Updated version with real AI
266
269
  execute: async (params, context) => {
270
+ const typedParams = params;
267
271
  const startTime = Date.now();
268
272
  try {
269
- const providerName = params.provider || (await getBestProvider());
273
+ const providerName = typedParams.provider || (await getBestProvider());
270
274
  const provider = await AIProviderFactory.createProvider(providerName);
271
275
  if (!provider) {
272
276
  throw new Error(`Failed to create provider: ${providerName}`);
@@ -275,9 +279,9 @@ export const optimizePromptParametersTool = {
275
279
  const temperatures = [0.2, 0.7, 1.0]; // Test a range of temperatures
276
280
  for (const temp of temperatures) {
277
281
  const result = await provider.generate({
278
- prompt: params.prompt,
282
+ prompt: typedParams.prompt,
279
283
  temperature: temp,
280
- maxTokens: params.targetLength || 250,
284
+ maxTokens: typedParams.targetLength || 250,
281
285
  });
282
286
  if (result) {
283
287
  optimizationResults.push({
@@ -292,7 +296,7 @@ export const optimizePromptParametersTool = {
292
296
  throw new Error("Failed to create analysis provider.");
293
297
  }
294
298
  const analysisPrompt = `
295
- Analyze the following AI-generated responses for the prompt "${params.prompt}" based on the optimization goal of "${params.optimizeFor}".
299
+ Analyze the following AI-generated responses for the prompt "${typedParams.prompt}" based on the optimization goal of "${typedParams.optimizeFor}".
296
300
 
297
301
  Responses:
298
302
  ${optimizationResults.map((r, i) => `Response ${i + 1} (Temp: ${r.parameters.temperature}):\n${r.output}`).join("\n\n")}
@@ -313,8 +317,8 @@ export const optimizePromptParametersTool = {
313
317
  success: true,
314
318
  data: {
315
319
  optimization: {
316
- originalPrompt: params.prompt,
317
- optimizeFor: params.optimizeFor,
320
+ originalPrompt: typedParams.prompt,
321
+ optimizeFor: typedParams.optimizeFor,
318
322
  provider: providerName,
319
323
  },
320
324
  results: optimizationResults,
@@ -4,7 +4,7 @@
4
4
  * Integrates AIProviderFactory with Factory-First MCP architecture
5
5
  */
6
6
  /**
7
- * AI Core Server - Central hub for AI provider tools
8
- * Provides text generation, provider selection, AI analysis, and development workflow tools
7
+ * AI Core Server - Central hub for AI provider management
8
+ * Provides provider selection and status checking functionality
9
9
  */
10
10
  export declare const aiCoreServer: import("../../factory.js").NeuroLinkMCPServer;