@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
@@ -38,8 +38,14 @@ export interface ExecutionContext {
38
38
  readFile: (path: string, encoding?: string) => Promise<string | Buffer>;
39
39
  writeFile: (path: string, content: string | Buffer) => Promise<void>;
40
40
  readdir: (path: string) => Promise<string[]>;
41
- stat: (path: string) => Promise<any>;
42
- mkdir: (path: string, options?: any) => Promise<void>;
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>;
43
49
  exists: (path: string) => Promise<boolean>;
44
50
  };
45
51
  /** Sandboxed path operations */
@@ -52,20 +58,20 @@ export interface ExecutionContext {
52
58
  };
53
59
  /** Sandboxed network operations (future) */
54
60
  secureNet?: {
55
- fetch: (url: string, options?: any) => Promise<Response>;
61
+ fetch: (url: string, options?: RequestInit) => Promise<Response>;
56
62
  };
57
63
  /** Plugin-specific permissions granted */
58
64
  grantedPermissions: string[];
59
65
  /** Log function for debugging */
60
- log: (level: "debug" | "info" | "warn" | "error", message: string, data?: any) => void;
66
+ log: (level: "debug" | "info" | "warn" | "error", message: string, data?: unknown) => void;
61
67
  /** Plugin instance reference (for plugin bridge compatibility) */
62
- plugin?: any;
68
+ plugin?: unknown;
63
69
  }
64
70
  /**
65
71
  * MCP Abstract Class - The Core Contract for All Plugins
66
72
  * Uses TypeScript generics for type-safe configuration
67
73
  */
68
- export declare abstract class MCP<TConfig = any, TArgs = any, TResult = any> {
74
+ export declare abstract class MCP<TConfig = unknown, TArgs = unknown, TResult = unknown> {
69
75
  /** Static metadata loaded from manifest */
70
76
  abstract readonly metadata: MCPMetadata;
71
77
  /** Configuration state - accessible to child classes */
@@ -107,7 +113,7 @@ export declare abstract class MCP<TConfig = any, TArgs = any, TResult = any> {
107
113
  /**
108
114
  * Helper method for logging with context
109
115
  */
110
- protected log(context: ExecutionContext, level: "debug" | "info" | "warn" | "error", message: string, data?: any): void;
116
+ protected log(context: ExecutionContext, level: "debug" | "info" | "warn" | "error", message: string, data?: unknown): void;
111
117
  }
112
118
  /**
113
119
  * Type definitions for plugin registry
@@ -122,6 +128,7 @@ export interface DiscoveredMCP {
122
128
  entryPath: string;
123
129
  source: "core" | "project" | "installed";
124
130
  constructor?: MCPConstructor;
131
+ [key: string]: unknown;
125
132
  }
126
133
  /**
127
134
  * Plugin load result
@@ -143,7 +150,7 @@ export interface PluginDiscoveryResult {
143
150
  /**
144
151
  * Plugin execution result
145
152
  */
146
- export interface PluginExecutionResult<T = any> {
153
+ export interface PluginExecutionResult<T = unknown> {
147
154
  success: boolean;
148
155
  result?: T;
149
156
  error?: string;
@@ -3,6 +3,7 @@
3
3
  * Enhanced plugin management with advanced lifecycle control
4
4
  */
5
5
  import type { MCP, MCPMetadata, MCPConstructor, PluginLoadResult, PluginExecutionResult, ExecutionContext } from "../contracts/mcp-contract.js";
6
+ import type { UnknownRecord, Unknown } from "../../types/common.js";
6
7
  /**
7
8
  * Enhanced plugin manager with core functionality
8
9
  */
@@ -13,11 +14,11 @@ export declare class CorePluginManager {
13
14
  /**
14
15
  * Load a plugin from constructor
15
16
  */
16
- loadPlugin(name: string, Constructor: MCPConstructor, config: any): Promise<PluginLoadResult>;
17
+ loadPlugin(name: string, Constructor: MCPConstructor, config: UnknownRecord): Promise<PluginLoadResult>;
17
18
  /**
18
19
  * Execute a plugin operation
19
20
  */
20
- executePlugin<T = any>(name: string, context: ExecutionContext, args: any): Promise<PluginExecutionResult<T>>;
21
+ executePlugin<T = Unknown>(name: string, context: ExecutionContext, args: Unknown): Promise<PluginExecutionResult<T>>;
21
22
  /**
22
23
  * Get plugin instance
23
24
  */
@@ -48,7 +48,7 @@ export class CorePluginManager {
48
48
  const executionTime = Date.now() - startTime;
49
49
  return {
50
50
  success: true,
51
- result,
51
+ result: result,
52
52
  executionTime,
53
53
  };
54
54
  }
@@ -42,7 +42,9 @@ export class PluginDemo {
42
42
  // Try to read a file
43
43
  const fsPlugin = new FileSystemMCP();
44
44
  await fsPlugin.initialize({ basePath: process.cwd() });
45
- const result = await executePlugin(fsPlugin, createMockContext(), "listFiles", ".");
45
+ // Cast FileSystemMCP to UnknownRecord for executePlugin compatibility
46
+ const pluginAsRecord = fsPlugin;
47
+ const result = await executePlugin(pluginAsRecord, createMockContext(), "listFiles", ".");
46
48
  mcpLogger.info("Plugin execution result:", result);
47
49
  }
48
50
  catch (error) {
@@ -5,18 +5,69 @@
5
5
  import type { MCPOrchestrator } from "./orchestrator.js";
6
6
  import type { MCPRegistry } from "./registry.js";
7
7
  import type { NeuroLinkExecutionContext } from "./factory.js";
8
+ import type { JsonValue, UnknownRecord } from "../types/common.js";
8
9
  import { ErrorManager } from "./error-manager.js";
10
+ /**
11
+ * Tool input schema structure
12
+ */
13
+ export interface ToolInputSchema {
14
+ type?: string;
15
+ properties?: Record<string, unknown>;
16
+ required?: string[];
17
+ [key: string]: unknown;
18
+ }
19
+ /**
20
+ * Tool execution parameters
21
+ */
22
+ export interface ToolExecutionParameters extends Record<string, JsonValue> {
23
+ }
24
+ /**
25
+ * Context evolution entry tracking data changes
26
+ */
27
+ export interface ContextEvolutionEntry {
28
+ step: string;
29
+ timestamp: number;
30
+ dataKeys: string[];
31
+ [key: string]: JsonValue;
32
+ }
33
+ /**
34
+ * AI model planning response structure
35
+ */
36
+ export interface AIPlanningResponse {
37
+ toolName: string | null;
38
+ parameters?: ToolExecutionParameters;
39
+ reasoning?: string;
40
+ confidence?: number;
41
+ expectedOutcome?: string;
42
+ }
43
+ /**
44
+ * AI model evaluation response structure
45
+ */
46
+ export interface AIEvaluationResponse {
47
+ goalAchieved: boolean;
48
+ confidence: number;
49
+ nextAction: "continue" | "retry" | "abort" | "complete";
50
+ reasoning: string;
51
+ }
52
+ /**
53
+ * Available tool descriptor
54
+ */
55
+ export interface AvailableToolDescriptor {
56
+ name: string;
57
+ description: string;
58
+ inputSchema: ToolInputSchema;
59
+ }
9
60
  /**
10
61
  * Tool execution result with metadata
11
62
  */
12
63
  export interface ToolExecutionResult {
13
64
  toolName: string;
14
65
  success: boolean;
15
- result?: any;
66
+ result?: JsonValue;
16
67
  error?: Error;
17
68
  timestamp: number;
18
69
  executionTime: number;
19
- context?: Record<string, any>;
70
+ context?: UnknownRecord;
20
71
  }
21
72
  /**
22
73
  * Chain execution step
@@ -24,7 +75,7 @@ export interface ToolExecutionResult {
24
75
  export interface ChainStep {
25
76
  stepId: string;
26
77
  toolName: string;
27
- parameters: any;
78
+ parameters: ToolExecutionParameters;
28
79
  reasoning: string;
29
80
  confidence: number;
30
81
  expectedOutcome: string;
@@ -37,7 +88,7 @@ export interface ChainExecutionContext {
37
88
  currentStep: number;
38
89
  totalSteps?: number;
39
90
  executionHistory: ToolExecutionResult[];
40
- accumulatedContext: Record<string, any>;
91
+ accumulatedContext: UnknownRecord;
41
92
  userContext?: NeuroLinkExecutionContext;
42
93
  maxSteps: number;
43
94
  aiModel?: string;
@@ -51,13 +102,13 @@ export interface ChainExecutionResult {
51
102
  totalSteps: number;
52
103
  executionTime: number;
53
104
  results: ToolExecutionResult[];
54
- finalResult?: any;
105
+ finalResult?: JsonValue;
55
106
  reasoning: string;
56
107
  error?: Error;
57
108
  metadata: {
58
109
  toolsUsed: string[];
59
110
  averageConfidence: number;
60
- contextEvolution: Record<string, any>[];
111
+ contextEvolution: ContextEvolutionEntry[];
61
112
  };
62
113
  }
63
114
  /**
@@ -65,34 +116,16 @@ export interface ChainExecutionResult {
65
116
  */
66
117
  export interface AIChainPlanner {
67
118
  name: string;
68
- planNextStep(goal: string, availableTools: Array<{
69
- name: string;
70
- description: string;
71
- inputSchema: any;
72
- }>, executionHistory: ToolExecutionResult[], accumulatedContext: Record<string, any>): Promise<ChainStep | null>;
73
- evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<{
74
- goalAchieved: boolean;
75
- confidence: number;
76
- nextAction: "continue" | "retry" | "abort" | "complete";
77
- reasoning: string;
78
- }>;
119
+ planNextStep(goal: string, availableTools: AvailableToolDescriptor[], executionHistory: ToolExecutionResult[], accumulatedContext: UnknownRecord): Promise<ChainStep | null>;
120
+ evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<AIEvaluationResponse>;
79
121
  }
80
122
  /**
81
123
  * Simple AI Chain Planner using heuristics
82
124
  */
83
125
  export declare class HeuristicChainPlanner implements AIChainPlanner {
84
126
  name: string;
85
- planNextStep(goal: string, availableTools: Array<{
86
- name: string;
87
- description: string;
88
- inputSchema: any;
89
- }>, executionHistory: ToolExecutionResult[], accumulatedContext: Record<string, any>): Promise<ChainStep | null>;
90
- evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<{
91
- goalAchieved: boolean;
92
- confidence: number;
93
- nextAction: "continue" | "retry" | "abort" | "complete";
94
- reasoning: string;
95
- }>;
127
+ planNextStep(goal: string, availableTools: AvailableToolDescriptor[], executionHistory: ToolExecutionResult[], accumulatedContext: UnknownRecord): Promise<ChainStep | null>;
128
+ evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<AIEvaluationResponse>;
96
129
  private generateParameters;
97
130
  }
98
131
  /**
@@ -102,17 +135,8 @@ export declare class AIModelChainPlanner implements AIChainPlanner {
102
135
  name: string;
103
136
  private aiModel;
104
137
  constructor(aiModel?: string);
105
- planNextStep(goal: string, availableTools: Array<{
106
- name: string;
107
- description: string;
108
- inputSchema: any;
109
- }>, executionHistory: ToolExecutionResult[], accumulatedContext: Record<string, any>): Promise<ChainStep | null>;
110
- evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<{
111
- goalAchieved: boolean;
112
- confidence: number;
113
- nextAction: "continue" | "retry" | "abort" | "complete";
114
- reasoning: string;
115
- }>;
138
+ planNextStep(goal: string, availableTools: AvailableToolDescriptor[], executionHistory: ToolExecutionResult[], accumulatedContext: UnknownRecord): Promise<ChainStep | null>;
139
+ evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<AIEvaluationResponse>;
116
140
  private buildPlanningPrompt;
117
141
  private buildEvaluationPrompt;
118
142
  private callAIModel;
@@ -137,7 +161,7 @@ export declare class DynamicChainExecutor {
137
161
  * @param options Execution options
138
162
  * @returns Chain execution result
139
163
  */
140
- executeChain(goal: string, initialContext?: Record<string, any>, userContext?: NeuroLinkExecutionContext, options?: {
164
+ executeChain(goal: string, initialContext?: UnknownRecord, userContext?: NeuroLinkExecutionContext, options?: {
141
165
  maxSteps?: number;
142
166
  aiModel?: string;
143
167
  timeout?: number;
@@ -82,7 +82,7 @@ export class HeuristicChainPlanner {
82
82
  const lastResult = history[history.length - 1];
83
83
  if (lastResult?.result) {
84
84
  // Pass relevant data from previous step
85
- if (typeof lastResult.result === "object") {
85
+ if (typeof lastResult.result === "object" && lastResult.result !== null) {
86
86
  Object.assign(params, lastResult.result);
87
87
  }
88
88
  else if (typeof lastResult.result === "string") {
@@ -378,7 +378,7 @@ export class DynamicChainExecutor {
378
378
  return {
379
379
  toolName: step.toolName,
380
380
  success: true,
381
- result,
381
+ result: result,
382
382
  timestamp: Date.now(),
383
383
  executionTime: Date.now() - startTime,
384
384
  context: {
@@ -445,7 +445,7 @@ export class DynamicChainExecutor {
445
445
  evolution.push({
446
446
  step: result.toolName,
447
447
  timestamp: result.timestamp,
448
- dataKeys: typeof result.result === "object"
448
+ dataKeys: typeof result.result === "object" && result.result !== null
449
449
  ? Object.keys(result.result)
450
450
  : ["primitive"],
451
451
  });
@@ -6,12 +6,18 @@
6
6
  import { MCPOrchestrator } from "./orchestrator.js";
7
7
  import type { ToolResult } from "./factory.js";
8
8
  import type { ContextRequest } from "./context-manager.js";
9
+ import type { UnknownRecord } from "../types/common.js";
10
+ import { ErrorManager } from "./error-manager.js";
11
+ import type { MCPToolRegistry } from "./tool-registry.js";
12
+ import type { ContextManager } from "./context-manager.js";
13
+ import type { SemaphoreManager } from "./semaphore-manager.js";
14
+ import type { SessionManager } from "./session-manager.js";
9
15
  /**
10
16
  * Tool decision made by AI
11
17
  */
12
18
  export interface ToolDecision {
13
19
  toolName: string;
14
- args: Record<string, any>;
20
+ args: UnknownRecord;
15
21
  reasoning: string;
16
22
  confidence: number;
17
23
  shouldContinue: boolean;
@@ -42,7 +48,7 @@ export interface DynamicToolChainResult {
42
48
  * Dynamic orchestrator with AI-driven tool selection
43
49
  */
44
50
  export declare class DynamicOrchestrator extends MCPOrchestrator {
45
- constructor(registry?: any, contextManager?: any, semaphoreManager?: any, sessionManager?: any, errorManager?: any);
51
+ constructor(registry?: MCPToolRegistry, contextManager?: ContextManager, semaphoreManager?: SemaphoreManager, sessionManager?: SessionManager, errorManager?: ErrorManager);
46
52
  private defaultOptions;
47
53
  /**
48
54
  * Execute a dynamic tool chain where AI decides which tools to use
@@ -86,11 +92,11 @@ export declare class DynamicOrchestrator extends MCPOrchestrator {
86
92
  reasoningCapture: boolean;
87
93
  };
88
94
  };
89
- registry: any;
90
- context: any;
91
- session: any;
92
- error: any;
93
- health?: any;
95
+ registry: UnknownRecord;
96
+ context: UnknownRecord;
97
+ session: UnknownRecord;
98
+ error: UnknownRecord;
99
+ health?: UnknownRecord;
94
100
  orchestrator: {
95
101
  pipelinesExecuted: number;
96
102
  };
@@ -106,4 +112,4 @@ export declare class DynamicOrchestrator extends MCPOrchestrator {
106
112
  * @param errorManager Error manager (optional)
107
113
  * @returns Dynamic orchestrator instance
108
114
  */
109
- export declare function createDynamicOrchestrator(registry: any, contextManager: any, semaphoreManager?: any, sessionManager?: any, errorManager?: any): DynamicOrchestrator;
115
+ export declare function createDynamicOrchestrator(registry: MCPToolRegistry, contextManager: ContextManager, semaphoreManager?: SemaphoreManager, sessionManager?: SessionManager, errorManager?: ErrorManager): DynamicOrchestrator;
@@ -28,7 +28,7 @@ export declare class MCPEcosystem {
28
28
  /**
29
29
  * Create and execute an MCP instance
30
30
  */
31
- execute<T = any>(name: string, config: any, args: any, context?: {
31
+ execute<T = unknown>(name: string, config: unknown, args: unknown, context?: {
32
32
  sessionId?: string;
33
33
  userId?: string;
34
34
  }): Promise<T>;
@@ -40,7 +40,7 @@ export declare class MCPEcosystem {
40
40
  path: string;
41
41
  content?: string;
42
42
  basePath?: string;
43
- }): Promise<any>;
43
+ }): Promise<unknown>;
44
44
  /**
45
45
  * Get ecosystem statistics
46
46
  */
@@ -53,7 +53,7 @@ export declare class MCPEcosystem {
53
53
  /**
54
54
  * Create an MCP instance for direct use
55
55
  */
56
- createInstance<T extends MCP>(name: string, config: any): Promise<T>;
56
+ createInstance<T extends MCP>(name: string, config: unknown): Promise<T>;
57
57
  /**
58
58
  * Create execution context for manual MCP usage
59
59
  */
@@ -65,7 +65,7 @@ export declare class MCPEcosystem {
65
65
  /**
66
66
  * Get all tools formatted for AI providers
67
67
  */
68
- getToolsForAI(): Promise<any>;
68
+ getToolsForAI(): Promise<Record<string, unknown>>;
69
69
  /**
70
70
  * Dispose of all resources
71
71
  */
@@ -38,7 +38,7 @@ export interface ErrorEntry {
38
38
  context: {
39
39
  sessionId?: string;
40
40
  toolName?: string;
41
- parameters?: any;
41
+ parameters?: unknown;
42
42
  executionContext?: NeuroLinkExecutionContext;
43
43
  };
44
44
  stackTrace?: string;
@@ -103,7 +103,7 @@ export declare class ErrorManager {
103
103
  severity?: ErrorSeverity;
104
104
  sessionId?: string;
105
105
  toolName?: string;
106
- parameters?: any;
106
+ parameters?: unknown;
107
107
  executionContext?: NeuroLinkExecutionContext;
108
108
  }): Promise<ErrorEntry>;
109
109
  /**
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { ErrorEntry, ErrorSeverity } from "./error-manager.js";
7
7
  import type { NeuroLinkExecutionContext } from "./factory.js";
8
+ import type { UnknownRecord } from "../types/common.js";
8
9
  /**
9
10
  * Circuit breaker states
10
11
  */
@@ -16,7 +17,7 @@ export declare enum CircuitState {
16
17
  /**
17
18
  * Retry strategy configuration
18
19
  */
19
- export interface RetryConfig {
20
+ export interface RetryConfig extends UnknownRecord {
20
21
  maxAttempts: number;
21
22
  initialDelay: number;
22
23
  maxDelay: number;
@@ -26,7 +27,7 @@ export interface RetryConfig {
26
27
  /**
27
28
  * Circuit breaker configuration
28
29
  */
29
- export interface CircuitBreakerConfig {
30
+ export interface CircuitBreakerConfig extends UnknownRecord {
30
31
  failureThreshold: number;
31
32
  resetTimeout: number;
32
33
  successThreshold: number;
@@ -48,7 +49,7 @@ export interface ErrorPattern {
48
49
  */
49
50
  export interface RecoveryStrategy {
50
51
  type: "retry" | "circuit-breaker" | "fallback" | "manual";
51
- config?: any;
52
+ config?: UnknownRecord;
52
53
  action?: (context: RecoveryContext) => Promise<RecoveryResult>;
53
54
  }
54
55
  /**
@@ -44,7 +44,7 @@ export declare class ExternalMCPClient extends EventEmitter {
44
44
  /**
45
45
  * Execute a tool on the external server
46
46
  */
47
- executeTool(toolName: string, params: any, context: NeuroLinkExecutionContext): Promise<ToolResult>;
47
+ executeTool(toolName: string, params: unknown, context: NeuroLinkExecutionContext): Promise<ToolResult>;
48
48
  /**
49
49
  * Get available tools as NeuroLink MCP tools
50
50
  */
@@ -105,13 +105,15 @@ export class ExternalMCPClient extends EventEmitter {
105
105
  async discoverTools() {
106
106
  try {
107
107
  const response = await this.sendRequest("tools/list", {});
108
- if (response.tools && Array.isArray(response.tools)) {
108
+ const responseObj = response;
109
+ if (responseObj.tools && Array.isArray(responseObj.tools)) {
109
110
  this.tools.clear();
110
- for (const tool of response.tools) {
111
- this.tools.set(tool.name, {
112
- name: tool.name,
113
- description: tool.description,
114
- inputSchema: tool.inputSchema,
111
+ for (const tool of responseObj.tools) {
112
+ const toolObj = tool;
113
+ this.tools.set(toolObj.name || "unknown", {
114
+ name: toolObj.name || "unknown",
115
+ description: toolObj.description || "",
116
+ inputSchema: toolObj.inputSchema,
115
117
  });
116
118
  }
117
119
  logger.debug(`[External MCP] Discovered ${this.tools.size} tools from ${this.config.name}`);
@@ -137,9 +139,10 @@ export class ExternalMCPClient extends EventEmitter {
137
139
  });
138
140
  const executionTime = Date.now() - startTime;
139
141
  // Transform MCP response to NeuroLink format
142
+ const responseObj = response;
140
143
  const result = {
141
- success: !response.isError,
142
- data: response.text || response.result || response,
144
+ success: !responseObj.isError,
145
+ data: responseObj.text || responseObj.result || response,
143
146
  metadata: {
144
147
  toolName,
145
148
  serverId: this.config.name,
@@ -149,8 +152,9 @@ export class ExternalMCPClient extends EventEmitter {
149
152
  executionTime,
150
153
  },
151
154
  };
152
- if (response.isError) {
153
- result.error = response.text?.[0]?.text || "Tool execution failed";
155
+ if (responseObj.isError) {
156
+ const textArray = responseObj.text;
157
+ result.error = textArray?.[0]?.text || "Tool execution failed";
154
158
  }
155
159
  logger.debug(`[External MCP] Tool ${toolName} executed in ${executionTime}ms`);
156
160
  return result;
@@ -11,8 +11,8 @@ import { MCPToolRegistry } from "./tool-registry.js";
11
11
  */
12
12
  interface ExternalServerInfo {
13
13
  name: string;
14
- client: ExternalMCPClient;
15
- server: NeuroLinkMCPServer;
14
+ client: ExternalMCPClient | null;
15
+ server: NeuroLinkMCPServer | null;
16
16
  status: "connecting" | "connected" | "disconnected" | "error";
17
17
  lastError?: string;
18
18
  toolCount: number;
@@ -61,7 +61,7 @@ export declare class ExternalMCPManager {
61
61
  /**
62
62
  * Execute a tool on any connected server
63
63
  */
64
- executeTool(toolName: string, params: any, context: NeuroLinkExecutionContext): Promise<ToolResult>;
64
+ executeTool(toolName: string, params: unknown, context: NeuroLinkExecutionContext): Promise<ToolResult>;
65
65
  /**
66
66
  * List all available tools from external servers
67
67
  */
@@ -72,7 +72,7 @@ export class ExternalMCPManager {
72
72
  });
73
73
  }
74
74
  catch (error) {
75
- if (error.code === "ENOENT") {
75
+ if (error?.code === "ENOENT") {
76
76
  logger.warn(`[External MCP Manager] Config file not found: ${this.configPath}`);
77
77
  this.config = { mcpServers: {} };
78
78
  }
@@ -163,6 +163,12 @@ export class ExternalMCPManager {
163
163
  */
164
164
  async registerServerTools(serverInfo) {
165
165
  try {
166
+ if (!serverInfo.client) {
167
+ throw new Error("Client is not available");
168
+ }
169
+ if (!serverInfo.server) {
170
+ throw new Error("Server is not available");
171
+ }
166
172
  const tools = serverInfo.client.getNeuroLinkTools();
167
173
  // Register each tool with the server
168
174
  for (const [toolName, tool] of Object.entries(tools)) {
@@ -198,8 +204,8 @@ export class ExternalMCPManager {
198
204
  statuses[name] = {
199
205
  ...info,
200
206
  // Don't include the actual client/server objects in status
201
- client: undefined,
202
- server: undefined,
207
+ client: null,
208
+ server: null,
203
209
  };
204
210
  }
205
211
  return statuses;
@@ -42,15 +42,15 @@ export interface NeuroLinkExecutionContext extends ExecutionContext {
42
42
  features?: string[];
43
43
  enableDemoMode?: boolean;
44
44
  securityLevel?: "public" | "private" | "organization";
45
- metadata?: Record<string, any>;
46
- [key: string]: any;
45
+ metadata?: Record<string, unknown>;
46
+ [key: string]: unknown;
47
47
  }
48
48
  /**
49
49
  * Tool execution result - Standardized result format
50
50
  */
51
51
  export interface ToolResult {
52
52
  success: boolean;
53
- data?: any;
53
+ data?: unknown;
54
54
  error?: string | Error;
55
55
  usage?: {
56
56
  tokens?: number;
@@ -67,7 +67,7 @@ export interface ToolResult {
67
67
  timestamp?: number;
68
68
  executionTime?: number;
69
69
  executionId?: string;
70
- [key: string]: any;
70
+ [key: string]: unknown;
71
71
  };
72
72
  }
73
73
  /**
@@ -83,7 +83,7 @@ export interface NeuroLinkMCPTool {
83
83
  category?: string;
84
84
  permissions?: string[];
85
85
  version?: string;
86
- metadata?: Record<string, any>;
86
+ metadata?: Record<string, unknown>;
87
87
  }
88
88
  /**
89
89
  * MCP Server Interface - Lighthouse compatible
@@ -97,7 +97,7 @@ export interface NeuroLinkMCPServer {
97
97
  visibility?: "public" | "private" | "organization";
98
98
  tools: Record<string, NeuroLinkMCPTool>;
99
99
  registerTool(tool: NeuroLinkMCPTool): NeuroLinkMCPServer;
100
- metadata?: Record<string, any>;
100
+ metadata?: Record<string, unknown>;
101
101
  dependencies?: string[];
102
102
  capabilities?: string[];
103
103
  }
@@ -111,7 +111,7 @@ export interface MCPServerConfig {
111
111
  version?: string;
112
112
  category?: MCPServerCategory;
113
113
  visibility?: "public" | "private" | "organization";
114
- metadata?: Record<string, any>;
114
+ metadata?: Record<string, unknown>;
115
115
  dependencies?: string[];
116
116
  capabilities?: string[];
117
117
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { Tool } from "ai";
7
7
  import type { NeuroLinkMCPTool, ToolResult, NeuroLinkExecutionContext } from "./factory.js";
8
+ import type { UnknownRecord } from "../types/common.js";
8
9
  /**
9
10
  * Convert MCP tool to AI SDK function definition
10
11
  */
@@ -53,12 +54,12 @@ export declare function isFunctionCallingAvailable(): Promise<boolean>;
53
54
  /**
54
55
  * Utility function to create a named tool object for debugging
55
56
  */
56
- export declare function createNamedTool(name: string, toolDef: any): any & {
57
+ export declare function createNamedTool(name: string, toolDef: Tool): Tool & {
57
58
  name: string;
58
59
  };
59
60
  /**
60
61
  * Get tools with proper name properties for debugging
61
62
  */
62
- export declare function getToolsWithNames(): Promise<Record<string, any & {
63
+ export declare function getToolsWithNames(): Promise<Record<string, UnknownRecord & {
63
64
  name: string;
64
65
  }>>;
@@ -4,6 +4,7 @@
4
4
  * Based on health monitoring patterns from Cline
5
5
  */
6
6
  import type { MCPRegistry } from "./registry.js";
7
+ import type { Unknown } from "../types/common.js";
7
8
  import { ErrorManager } from "./error-manager.js";
8
9
  /**
9
10
  * Connection status states
@@ -215,7 +216,7 @@ export declare class HealthMonitor {
215
216
  * @param event Event type to subscribe to
216
217
  * @param callback Callback function
217
218
  */
218
- on(event: "health-change" | "recovery-started" | "recovery-failed" | "critical-error", callback: (data: any) => void): void;
219
+ on(event: "health-change" | "recovery-started" | "recovery-failed" | "critical-error", callback: (data: Unknown) => void): void;
219
220
  /**
220
221
  * Get health history for trend analysis
221
222
  *