@juspay/neurolink 5.2.0 → 6.0.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 (288) hide show
  1. package/CHANGELOG.md +82 -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/factories/command-factory.js +6 -5
  19. package/dist/cli/index.js +22 -19
  20. package/dist/core/analytics.d.ts +3 -2
  21. package/dist/core/analytics.js +16 -7
  22. package/dist/core/base-provider.d.ts +35 -7
  23. package/dist/core/base-provider.js +57 -23
  24. package/dist/core/constants.d.ts +1 -0
  25. package/dist/core/constants.js +1 -0
  26. package/dist/core/defaults.d.ts +2 -1
  27. package/dist/core/evaluation.d.ts +4 -4
  28. package/dist/core/evaluation.js +17 -7
  29. package/dist/core/factory.d.ts +3 -2
  30. package/dist/core/service-registry.d.ts +4 -4
  31. package/dist/core/types.d.ts +11 -4
  32. package/dist/factories/compatibility-factory.d.ts +16 -1
  33. package/dist/factories/compatibility-factory.js +3 -1
  34. package/dist/factories/provider-factory.d.ts +5 -4
  35. package/dist/factories/provider-factory.js +15 -24
  36. package/dist/factories/provider-generate-factory.js +26 -20
  37. package/dist/lib/chat/client-utils.d.ts +3 -0
  38. package/dist/lib/chat/client-utils.js +22 -5
  39. package/dist/lib/chat/index.d.ts +4 -7
  40. package/dist/lib/chat/index.js +0 -8
  41. package/dist/lib/chat/session-storage.d.ts +2 -2
  42. package/dist/lib/chat/session.d.ts +4 -3
  43. package/dist/lib/chat/session.js +1 -1
  44. package/dist/lib/chat/sse-handler.js +13 -21
  45. package/dist/lib/chat/types.d.ts +3 -2
  46. package/dist/lib/chat/websocket-chat-handler.d.ts +4 -3
  47. package/dist/lib/chat/websocket-chat-handler.js +12 -12
  48. package/dist/lib/core/analytics.d.ts +3 -2
  49. package/dist/lib/core/analytics.js +16 -7
  50. package/dist/lib/core/base-provider.d.ts +35 -7
  51. package/dist/lib/core/base-provider.js +57 -23
  52. package/dist/lib/core/constants.d.ts +1 -0
  53. package/dist/lib/core/constants.js +1 -0
  54. package/dist/lib/core/defaults.d.ts +2 -1
  55. package/dist/lib/core/evaluation.d.ts +4 -4
  56. package/dist/lib/core/evaluation.js +17 -7
  57. package/dist/lib/core/factory.d.ts +3 -2
  58. package/dist/lib/core/service-registry.d.ts +4 -4
  59. package/dist/lib/core/types.d.ts +11 -4
  60. package/dist/lib/factories/compatibility-factory.d.ts +16 -1
  61. package/dist/lib/factories/compatibility-factory.js +3 -1
  62. package/dist/lib/factories/provider-factory.d.ts +5 -4
  63. package/dist/lib/factories/provider-factory.js +15 -24
  64. package/dist/lib/factories/provider-generate-factory.js +26 -20
  65. package/dist/lib/mcp/adapters/plugin-bridge.d.ts +5 -4
  66. package/dist/lib/mcp/adapters/plugin-bridge.js +13 -6
  67. package/dist/lib/mcp/client.d.ts +3 -1
  68. package/dist/lib/mcp/client.js +13 -10
  69. package/dist/lib/mcp/context-manager.d.ts +2 -1
  70. package/dist/lib/mcp/context-manager.js +8 -4
  71. package/dist/lib/mcp/contracts/mcp-contract.d.ts +15 -8
  72. package/dist/lib/mcp/core/plugin-manager.d.ts +3 -2
  73. package/dist/lib/mcp/core/plugin-manager.js +1 -1
  74. package/dist/lib/mcp/demo/plugin-demo.js +3 -1
  75. package/dist/lib/mcp/dynamic-chain-executor.d.ts +64 -40
  76. package/dist/lib/mcp/dynamic-chain-executor.js +3 -3
  77. package/dist/lib/mcp/dynamic-orchestrator.d.ts +14 -8
  78. package/dist/lib/mcp/ecosystem.d.ts +4 -4
  79. package/dist/lib/mcp/error-manager.d.ts +2 -2
  80. package/dist/lib/mcp/error-recovery.d.ts +4 -3
  81. package/dist/lib/mcp/external-client.d.ts +1 -1
  82. package/dist/lib/mcp/external-client.js +14 -10
  83. package/dist/lib/mcp/external-manager.d.ts +3 -3
  84. package/dist/lib/mcp/external-manager.js +9 -3
  85. package/dist/lib/mcp/factory.d.ts +7 -7
  86. package/dist/lib/mcp/function-calling.d.ts +14 -0
  87. package/dist/lib/mcp/function-calling.js +133 -34
  88. package/dist/lib/mcp/health-monitor.d.ts +2 -1
  89. package/dist/lib/mcp/health-monitor.js +16 -7
  90. package/dist/lib/mcp/index.d.ts +5 -5
  91. package/dist/lib/mcp/initialize-tools.d.ts +2 -1
  92. package/dist/lib/mcp/initialize-tools.js +10 -2
  93. package/dist/lib/mcp/manager.d.ts +2 -1
  94. package/dist/lib/mcp/neurolink-mcp-client.d.ts +1 -0
  95. package/dist/lib/mcp/neurolink-mcp-client.js +22 -6
  96. package/dist/lib/mcp/orchestrator.d.ts +13 -12
  97. package/dist/lib/mcp/orchestrator.js +10 -8
  98. package/dist/lib/mcp/plugin-manager.js +4 -2
  99. package/dist/lib/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
  100. package/dist/lib/mcp/plugins/core/filesystem-mcp.js +5 -2
  101. package/dist/lib/mcp/plugins/filesystem-mcp.d.ts +2 -1
  102. package/dist/lib/mcp/registry.d.ts +2 -1
  103. package/dist/lib/mcp/registry.js +2 -1
  104. package/dist/lib/mcp/security-manager.d.ts +4 -2
  105. package/dist/lib/mcp/servers/agent/direct-tools-server.js +18 -6
  106. package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
  107. package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
  108. package/dist/lib/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
  109. package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +15 -133
  110. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
  111. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
  112. package/dist/lib/mcp/session-manager.d.ts +4 -3
  113. package/dist/lib/mcp/session-persistence.js +5 -2
  114. package/dist/lib/mcp/tool-integration.d.ts +3 -2
  115. package/dist/lib/mcp/tool-integration.js +3 -1
  116. package/dist/lib/mcp/tool-registry.d.ts +18 -1
  117. package/dist/lib/mcp/tool-registry.js +11 -8
  118. package/dist/lib/mcp/transport-manager.d.ts +2 -1
  119. package/dist/lib/mcp/transport-manager.js +5 -1
  120. package/dist/lib/mcp/unified-mcp.d.ts +5 -5
  121. package/dist/lib/mcp/unified-registry.d.ts +18 -2
  122. package/dist/lib/mcp/unified-registry.js +52 -3
  123. package/dist/lib/neurolink.d.ts +2 -2
  124. package/dist/lib/neurolink.js +40 -15
  125. package/dist/lib/providers/amazon-bedrock.d.ts +1 -1
  126. package/dist/lib/providers/amazon-bedrock.js +8 -7
  127. package/dist/lib/providers/analytics-helper.d.ts +8 -23
  128. package/dist/lib/providers/analytics-helper.js +95 -33
  129. package/dist/lib/providers/anthropic-baseprovider.d.ts +3 -3
  130. package/dist/lib/providers/anthropic-baseprovider.js +6 -5
  131. package/dist/lib/providers/anthropic.d.ts +2 -2
  132. package/dist/lib/providers/anthropic.js +11 -4
  133. package/dist/lib/providers/azure-openai.d.ts +5 -4
  134. package/dist/lib/providers/azure-openai.js +10 -4
  135. package/dist/lib/providers/function-calling-provider.d.ts +66 -4
  136. package/dist/lib/providers/function-calling-provider.js +209 -10
  137. package/dist/lib/providers/google-ai-studio.d.ts +2 -2
  138. package/dist/lib/providers/google-ai-studio.js +9 -3
  139. package/dist/lib/providers/google-vertex.d.ts +2 -2
  140. package/dist/lib/providers/google-vertex.js +18 -12
  141. package/dist/lib/providers/huggingFace.d.ts +1 -1
  142. package/dist/lib/providers/huggingFace.js +8 -4
  143. package/dist/lib/providers/mcp-provider.d.ts +3 -3
  144. package/dist/lib/providers/mcp-provider.js +20 -5
  145. package/dist/lib/providers/mistral.d.ts +34 -27
  146. package/dist/lib/providers/mistral.js +115 -107
  147. package/dist/lib/providers/ollama.d.ts +2 -1
  148. package/dist/lib/providers/ollama.js +43 -3
  149. package/dist/lib/providers/openAI.d.ts +1 -1
  150. package/dist/lib/providers/openAI.js +8 -4
  151. package/dist/lib/proxy/proxy-fetch.js +3 -2
  152. package/dist/lib/sdk/tool-extension.d.ts +12 -12
  153. package/dist/lib/sdk/tool-extension.js +2 -1
  154. package/dist/lib/sdk/tool-registration.d.ts +16 -12
  155. package/dist/lib/sdk/tool-registration.js +3 -2
  156. package/dist/lib/services/streaming/streaming-manager.js +11 -10
  157. package/dist/lib/services/types.d.ts +5 -4
  158. package/dist/lib/services/websocket/websocket-server.d.ts +1 -1
  159. package/dist/lib/services/websocket/websocket-server.js +13 -12
  160. package/dist/lib/telemetry/telemetry-service.js +9 -8
  161. package/dist/lib/types/cli.d.ts +247 -0
  162. package/dist/lib/types/cli.js +22 -0
  163. package/dist/lib/types/common.d.ts +76 -0
  164. package/dist/lib/types/common.js +52 -0
  165. package/dist/lib/types/generate-types.d.ts +6 -6
  166. package/dist/lib/types/index.d.ts +12 -0
  167. package/dist/lib/types/index.js +12 -0
  168. package/dist/lib/types/mcp-types.d.ts +7 -7
  169. package/dist/lib/types/providers.d.ts +158 -0
  170. package/dist/lib/types/providers.js +23 -0
  171. package/dist/lib/types/stream-types.d.ts +4 -3
  172. package/dist/lib/types/tools.d.ts +154 -0
  173. package/dist/lib/types/tools.js +24 -0
  174. package/dist/lib/utils/logger.d.ts +5 -5
  175. package/dist/lib/utils/provider-validation.d.ts +2 -1
  176. package/dist/mcp/adapters/plugin-bridge.d.ts +5 -4
  177. package/dist/mcp/adapters/plugin-bridge.js +13 -6
  178. package/dist/mcp/client.d.ts +3 -1
  179. package/dist/mcp/client.js +13 -10
  180. package/dist/mcp/context-manager.d.ts +2 -1
  181. package/dist/mcp/context-manager.js +8 -4
  182. package/dist/mcp/contracts/mcp-contract.d.ts +15 -8
  183. package/dist/mcp/core/plugin-manager.d.ts +3 -2
  184. package/dist/mcp/core/plugin-manager.js +1 -1
  185. package/dist/mcp/demo/plugin-demo.js +3 -1
  186. package/dist/mcp/dynamic-chain-executor.d.ts +64 -40
  187. package/dist/mcp/dynamic-chain-executor.js +3 -3
  188. package/dist/mcp/dynamic-orchestrator.d.ts +14 -8
  189. package/dist/mcp/dynamic-orchestrator.js +1 -1
  190. package/dist/mcp/ecosystem.d.ts +4 -4
  191. package/dist/mcp/error-manager.d.ts +2 -2
  192. package/dist/mcp/error-recovery.d.ts +4 -3
  193. package/dist/mcp/external-client.d.ts +1 -1
  194. package/dist/mcp/external-client.js +14 -10
  195. package/dist/mcp/external-manager.d.ts +3 -3
  196. package/dist/mcp/external-manager.js +9 -3
  197. package/dist/mcp/factory.d.ts +7 -7
  198. package/dist/mcp/function-calling.d.ts +14 -0
  199. package/dist/mcp/function-calling.js +133 -34
  200. package/dist/mcp/health-monitor.d.ts +2 -1
  201. package/dist/mcp/health-monitor.js +16 -7
  202. package/dist/mcp/index.d.ts +5 -5
  203. package/dist/mcp/initialize-tools.d.ts +2 -1
  204. package/dist/mcp/initialize-tools.js +10 -2
  205. package/dist/mcp/manager.d.ts +2 -1
  206. package/dist/mcp/neurolink-mcp-client.d.ts +1 -0
  207. package/dist/mcp/neurolink-mcp-client.js +22 -6
  208. package/dist/mcp/orchestrator.d.ts +13 -12
  209. package/dist/mcp/orchestrator.js +10 -8
  210. package/dist/mcp/plugin-manager.js +4 -2
  211. package/dist/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
  212. package/dist/mcp/plugins/core/filesystem-mcp.js +5 -2
  213. package/dist/mcp/plugins/filesystem-mcp.d.ts +2 -1
  214. package/dist/mcp/registry.d.ts +2 -1
  215. package/dist/mcp/registry.js +2 -1
  216. package/dist/mcp/security-manager.d.ts +4 -2
  217. package/dist/mcp/servers/agent/direct-tools-server.js +19 -6
  218. package/dist/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
  219. package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
  220. package/dist/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
  221. package/dist/mcp/servers/ai-providers/ai-core-server.js +15 -132
  222. package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
  223. package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
  224. package/dist/mcp/session-manager.d.ts +4 -3
  225. package/dist/mcp/session-persistence.js +5 -2
  226. package/dist/mcp/tool-integration.d.ts +3 -2
  227. package/dist/mcp/tool-integration.js +3 -1
  228. package/dist/mcp/tool-registry.d.ts +18 -1
  229. package/dist/mcp/tool-registry.js +11 -8
  230. package/dist/mcp/transport-manager.d.ts +2 -1
  231. package/dist/mcp/transport-manager.js +5 -1
  232. package/dist/mcp/unified-mcp.d.ts +5 -5
  233. package/dist/mcp/unified-registry.d.ts +18 -2
  234. package/dist/mcp/unified-registry.js +52 -3
  235. package/dist/neurolink.d.ts +2 -2
  236. package/dist/neurolink.js +40 -15
  237. package/dist/providers/amazon-bedrock.d.ts +1 -1
  238. package/dist/providers/amazon-bedrock.js +8 -7
  239. package/dist/providers/analytics-helper.d.ts +8 -23
  240. package/dist/providers/analytics-helper.js +95 -33
  241. package/dist/providers/anthropic-baseprovider.d.ts +3 -3
  242. package/dist/providers/anthropic-baseprovider.js +6 -5
  243. package/dist/providers/anthropic.d.ts +2 -2
  244. package/dist/providers/anthropic.js +11 -4
  245. package/dist/providers/azure-openai.d.ts +5 -4
  246. package/dist/providers/azure-openai.js +10 -4
  247. package/dist/providers/function-calling-provider.d.ts +66 -4
  248. package/dist/providers/function-calling-provider.js +209 -10
  249. package/dist/providers/google-ai-studio.d.ts +2 -2
  250. package/dist/providers/google-ai-studio.js +9 -3
  251. package/dist/providers/google-vertex.d.ts +2 -2
  252. package/dist/providers/google-vertex.js +18 -12
  253. package/dist/providers/huggingFace.d.ts +1 -1
  254. package/dist/providers/huggingFace.js +8 -4
  255. package/dist/providers/mcp-provider.d.ts +3 -3
  256. package/dist/providers/mcp-provider.js +20 -5
  257. package/dist/providers/mistral.d.ts +34 -27
  258. package/dist/providers/mistral.js +116 -108
  259. package/dist/providers/ollama.d.ts +2 -1
  260. package/dist/providers/ollama.js +43 -3
  261. package/dist/providers/openAI.d.ts +1 -1
  262. package/dist/providers/openAI.js +8 -4
  263. package/dist/proxy/proxy-fetch.js +3 -2
  264. package/dist/sdk/tool-extension.d.ts +12 -12
  265. package/dist/sdk/tool-extension.js +2 -1
  266. package/dist/sdk/tool-registration.d.ts +16 -12
  267. package/dist/sdk/tool-registration.js +3 -2
  268. package/dist/services/streaming/streaming-manager.js +11 -10
  269. package/dist/services/types.d.ts +5 -4
  270. package/dist/services/websocket/websocket-server.d.ts +1 -1
  271. package/dist/services/websocket/websocket-server.js +14 -12
  272. package/dist/telemetry/telemetry-service.js +9 -8
  273. package/dist/types/cli.d.ts +247 -0
  274. package/dist/types/cli.js +22 -0
  275. package/dist/types/common.d.ts +76 -0
  276. package/dist/types/common.js +52 -0
  277. package/dist/types/generate-types.d.ts +6 -6
  278. package/dist/types/index.d.ts +12 -0
  279. package/dist/types/index.js +12 -0
  280. package/dist/types/mcp-types.d.ts +7 -7
  281. package/dist/types/providers.d.ts +158 -0
  282. package/dist/types/providers.js +23 -0
  283. package/dist/types/stream-types.d.ts +4 -3
  284. package/dist/types/tools.d.ts +154 -0
  285. package/dist/types/tools.js +25 -0
  286. package/dist/utils/logger.d.ts +5 -5
  287. package/dist/utils/provider-validation.d.ts +2 -1
  288. package/package.json +12 -10
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Common utility types for NeuroLink
3
+ * These types provide type-safe alternatives to 'any' usage
4
+ */
5
+ /**
6
+ * Type guard to check if value is Error
7
+ */
8
+ export function isError(value) {
9
+ return value instanceof Error;
10
+ }
11
+ /**
12
+ * Type guard to check if value is ErrorInfo
13
+ */
14
+ export function isErrorInfo(value) {
15
+ return (typeof value === "object" &&
16
+ value !== null &&
17
+ "message" in value &&
18
+ typeof value.message === "string");
19
+ }
20
+ /**
21
+ * Safe error message extraction
22
+ */
23
+ export function getErrorMessage(error) {
24
+ if (isError(error)) {
25
+ return error.message;
26
+ }
27
+ if (isErrorInfo(error)) {
28
+ return error.message;
29
+ }
30
+ if (typeof error === "string") {
31
+ return error;
32
+ }
33
+ return String(error);
34
+ }
35
+ /**
36
+ * Safe error conversion
37
+ */
38
+ export function toErrorInfo(error) {
39
+ if (isError(error)) {
40
+ return {
41
+ message: error.message,
42
+ stack: error.stack,
43
+ code: error.code,
44
+ };
45
+ }
46
+ if (isErrorInfo(error)) {
47
+ return error;
48
+ }
49
+ return {
50
+ message: getErrorMessage(error),
51
+ };
52
+ }
@@ -23,7 +23,7 @@ export interface GenerateOptions {
23
23
  disableTools?: boolean;
24
24
  enableEvaluation?: boolean;
25
25
  enableAnalytics?: boolean;
26
- context?: Record<string, any>;
26
+ context?: Record<string, unknown>;
27
27
  evaluationDomain?: string;
28
28
  toolUsageContext?: string;
29
29
  conversationHistory?: Array<{
@@ -51,21 +51,21 @@ export interface GenerateResult {
51
51
  toolCalls?: Array<{
52
52
  toolCallId: string;
53
53
  toolName: string;
54
- args: Record<string, any>;
54
+ args: Record<string, unknown>;
55
55
  }>;
56
- toolResults?: any[];
56
+ toolResults?: unknown[];
57
57
  toolsUsed?: string[];
58
58
  toolExecutions?: Array<{
59
59
  name: string;
60
- input: Record<string, any>;
61
- output: any;
60
+ input: Record<string, unknown>;
61
+ output: unknown;
62
62
  duration: number;
63
63
  }>;
64
64
  enhancedWithTools?: boolean;
65
65
  availableTools?: Array<{
66
66
  name: string;
67
67
  description: string;
68
- parameters: Record<string, any>;
68
+ parameters: Record<string, unknown>;
69
69
  }>;
70
70
  analytics?: AnalyticsData;
71
71
  evaluation?: EvaluationData;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Centralized type exports for NeuroLink
3
+ * Provides type-safe alternatives to 'any' usage throughout the codebase
4
+ */
5
+ export * from "./common.js";
6
+ export * from "./tools.js";
7
+ export * from "./providers.js";
8
+ export * from "./cli.js";
9
+ export type { Unknown, UnknownRecord, UnknownArray, JsonValue, JsonObject, JsonArray, ErrorInfo, Result, FunctionParameters, } from "./common.js";
10
+ export type { ToolArgs, ToolContext, ToolResult, ToolDefinition, SimpleTool, AvailableTool, ToolExecution, } from "./tools.js";
11
+ export type { AISDKModel, ProviderError, TokenUsage, AnalyticsData, EvaluationData, ProviderConfig, } from "./providers.js";
12
+ export type { BaseCommandArgs, GenerateCommandArgs, CommandResult, GenerateResult, StreamChunk, } from "./cli.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Centralized type exports for NeuroLink
3
+ * Provides type-safe alternatives to 'any' usage throughout the codebase
4
+ */
5
+ // Common utility types
6
+ export * from "./common.js";
7
+ // Tool system types
8
+ export * from "./tools.js";
9
+ // Provider types
10
+ export * from "./providers.js";
11
+ // CLI types
12
+ export * from "./cli.js";
@@ -34,7 +34,7 @@ export interface InMemoryMCPServerConfig {
34
34
  provider?: string;
35
35
  version?: string;
36
36
  author?: string;
37
- [key: string]: any;
37
+ [key: string]: unknown;
38
38
  };
39
39
  }
40
40
  /**
@@ -48,11 +48,11 @@ export interface InMemoryToolInfo {
48
48
  /**
49
49
  * Tool execution function
50
50
  */
51
- execute: (params: any) => Promise<InMemoryToolResult> | InMemoryToolResult;
51
+ execute: (params: unknown) => Promise<InMemoryToolResult> | InMemoryToolResult;
52
52
  /**
53
53
  * Input parameter schema (Zod or JSON Schema)
54
54
  */
55
- inputSchema?: any;
55
+ inputSchema?: unknown;
56
56
  /**
57
57
  * Whether the tool is implemented (default: true)
58
58
  */
@@ -60,7 +60,7 @@ export interface InMemoryToolInfo {
60
60
  /**
61
61
  * Optional metadata
62
62
  */
63
- metadata?: Record<string, any>;
63
+ metadata?: Record<string, unknown>;
64
64
  }
65
65
  /**
66
66
  * Result from in-memory tool execution
@@ -73,7 +73,7 @@ export interface InMemoryToolResult {
73
73
  /**
74
74
  * Result data if successful
75
75
  */
76
- data?: any;
76
+ data?: unknown;
77
77
  /**
78
78
  * Error message if failed
79
79
  */
@@ -85,7 +85,7 @@ export interface InMemoryToolResult {
85
85
  executionTime?: number;
86
86
  toolName?: string;
87
87
  serverId?: string;
88
- [key: string]: any;
88
+ [key: string]: unknown;
89
89
  };
90
90
  }
91
91
  /**
@@ -108,7 +108,7 @@ export interface UnifiedMCPRegistry {
108
108
  /**
109
109
  * Execute a tool
110
110
  */
111
- executeTool(toolName: string, params: any, context: any): Promise<any>;
111
+ executeTool(toolName: string, params: unknown, context: unknown): Promise<unknown>;
112
112
  /**
113
113
  * Check if connected to a server
114
114
  */
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Provider-specific type definitions for NeuroLink
3
+ * Replaces 'any' types in provider implementations
4
+ */
5
+ import type { UnknownRecord, JsonValue } from "./common.js";
6
+ /**
7
+ * Generic AI SDK model interface
8
+ */
9
+ export interface AISDKModel {
10
+ [key: string]: unknown;
11
+ }
12
+ /**
13
+ * Provider error information
14
+ */
15
+ export interface ProviderError extends Error {
16
+ code?: string | number;
17
+ statusCode?: number;
18
+ provider?: string;
19
+ originalError?: unknown;
20
+ }
21
+ /**
22
+ * Token usage information
23
+ */
24
+ export interface TokenUsage {
25
+ inputTokens: number;
26
+ outputTokens: number;
27
+ totalTokens: number;
28
+ }
29
+ /**
30
+ * Analytics data structure
31
+ */
32
+ export interface AnalyticsData {
33
+ provider: string;
34
+ model: string;
35
+ requestDuration: number;
36
+ tokenUsage: {
37
+ inputTokens: number;
38
+ outputTokens: number;
39
+ totalTokens: number;
40
+ };
41
+ timestamp: number;
42
+ context?: JsonValue;
43
+ [key: string]: JsonValue | undefined;
44
+ }
45
+ /**
46
+ * Evaluation data structure
47
+ */
48
+ export interface EvaluationData {
49
+ relevance?: number;
50
+ accuracy?: number;
51
+ completeness?: number;
52
+ coherence?: number;
53
+ overall?: number;
54
+ feedback?: string;
55
+ [key: string]: JsonValue | undefined;
56
+ }
57
+ /**
58
+ * Provider capabilities
59
+ */
60
+ export interface ProviderCapabilities {
61
+ supportsStreaming: boolean;
62
+ supportsTools: boolean;
63
+ supportsImages: boolean;
64
+ supportsAudio: boolean;
65
+ maxTokens?: number;
66
+ supportedModels: string[];
67
+ }
68
+ /**
69
+ * Provider configuration
70
+ */
71
+ export interface ProviderConfig {
72
+ apiKey?: string;
73
+ baseURL?: string;
74
+ timeout?: number;
75
+ retries?: number;
76
+ model?: string;
77
+ [key: string]: unknown;
78
+ }
79
+ /**
80
+ * Amazon Bedrock specific types
81
+ */
82
+ export declare namespace BedrockTypes {
83
+ interface Client {
84
+ send(command: unknown): Promise<unknown>;
85
+ config: {
86
+ region?: string;
87
+ credentials?: unknown;
88
+ };
89
+ }
90
+ interface InvokeModelCommand {
91
+ input: {
92
+ modelId: string;
93
+ body: string;
94
+ contentType?: string;
95
+ };
96
+ }
97
+ }
98
+ /**
99
+ * Mistral specific types
100
+ */
101
+ export declare namespace MistralTypes {
102
+ interface Client {
103
+ chat?: {
104
+ complete?: (options: unknown) => Promise<unknown>;
105
+ stream?: (options: unknown) => AsyncIterable<unknown>;
106
+ };
107
+ }
108
+ }
109
+ /**
110
+ * OpenTelemetry specific types (for telemetry service)
111
+ */
112
+ export declare namespace TelemetryTypes {
113
+ interface Meter {
114
+ createCounter(name: string, options?: unknown): Counter;
115
+ createHistogram(name: string, options?: unknown): Histogram;
116
+ }
117
+ interface Tracer {
118
+ startSpan(name: string, options?: unknown): Span;
119
+ }
120
+ interface Counter {
121
+ add(value: number, attributes?: UnknownRecord): void;
122
+ }
123
+ interface Histogram {
124
+ record(value: number, attributes?: UnknownRecord): void;
125
+ }
126
+ interface Span {
127
+ end(): void;
128
+ setStatus(status: unknown): void;
129
+ recordException(exception: unknown): void;
130
+ }
131
+ }
132
+ /**
133
+ * Provider factory function type
134
+ */
135
+ export type ProviderFactory = (modelName?: string, providerName?: string, sdk?: unknown) => Promise<unknown>;
136
+ /**
137
+ * Provider constructor type
138
+ */
139
+ export interface ProviderConstructor {
140
+ new (modelName?: string, providerName?: string, sdk?: unknown): unknown;
141
+ }
142
+ /**
143
+ * Provider registration entry
144
+ */
145
+ export interface ProviderRegistration {
146
+ name: string;
147
+ constructor: ProviderConstructor | ProviderFactory;
148
+ capabilities?: ProviderCapabilities;
149
+ defaultConfig?: ProviderConfig;
150
+ }
151
+ /**
152
+ * Type guard for provider error
153
+ */
154
+ export declare function isProviderError(error: unknown): error is ProviderError;
155
+ /**
156
+ * Type guard for token usage
157
+ */
158
+ export declare function isTokenUsage(value: unknown): value is TokenUsage;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Provider-specific type definitions for NeuroLink
3
+ * Replaces 'any' types in provider implementations
4
+ */
5
+ /**
6
+ * Type guard for provider error
7
+ */
8
+ export function isProviderError(error) {
9
+ return error instanceof Error && "provider" in error;
10
+ }
11
+ /**
12
+ * Type guard for token usage
13
+ */
14
+ export function isTokenUsage(value) {
15
+ return (typeof value === "object" &&
16
+ value !== null &&
17
+ "inputTokens" in value &&
18
+ "outputTokens" in value &&
19
+ "totalTokens" in value &&
20
+ typeof value.inputTokens === "number" &&
21
+ typeof value.outputTokens === "number" &&
22
+ typeof value.totalTokens === "number");
23
+ }
@@ -1,12 +1,13 @@
1
1
  import type { ZodType, ZodTypeDef } from "zod";
2
2
  import type { Tool, Schema } from "ai";
3
3
  import type { AIProviderName, AnalyticsData, EvaluationData } from "../core/types.js";
4
+ import type { UnknownRecord, Unknown } from "./common.js";
4
5
  /**
5
6
  * Interface for tool execution calls
6
7
  */
7
8
  export interface ToolCall {
8
9
  toolName: string;
9
- parameters: Record<string, any>;
10
+ parameters: UnknownRecord;
10
11
  id?: string;
11
12
  }
12
13
  /**
@@ -15,7 +16,7 @@ export interface ToolCall {
15
16
  export interface ToolResult {
16
17
  toolName: string;
17
18
  status: "success" | "failure";
18
- output?: any;
19
+ output?: Unknown;
19
20
  error?: string;
20
21
  id?: string;
21
22
  executionTime?: number;
@@ -48,7 +49,7 @@ export interface StreamOptions {
48
49
  maxSteps?: number;
49
50
  enableEvaluation?: boolean;
50
51
  enableAnalytics?: boolean;
51
- context?: Record<string, any>;
52
+ context?: UnknownRecord;
52
53
  evaluationDomain?: string;
53
54
  toolUsageContext?: string;
54
55
  conversationHistory?: Array<{
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Tool system type definitions for NeuroLink
3
+ * Replaces 'any' types in tool registration and execution
4
+ */
5
+ import { z } from "zod";
6
+ import type { Result, JsonValue, ErrorInfo } from "./common.js";
7
+ /**
8
+ * Tool parameter schema types
9
+ */
10
+ export type ToolParameterSchema = z.ZodSchema | Record<string, JsonValue>;
11
+ /**
12
+ * Standard tool input parameters
13
+ */
14
+ export interface BaseToolArgs {
15
+ [key: string]: JsonValue | undefined;
16
+ }
17
+ /**
18
+ * Tool execution arguments with specific common patterns
19
+ */
20
+ export interface ToolArgs extends BaseToolArgs {
21
+ input?: JsonValue;
22
+ data?: JsonValue;
23
+ options?: JsonValue;
24
+ }
25
+ /**
26
+ * Tool execution metadata
27
+ */
28
+ export interface ToolExecutionMetadata {
29
+ requestId?: string;
30
+ startTime?: number;
31
+ version?: string;
32
+ [key: string]: JsonValue | undefined;
33
+ }
34
+ /**
35
+ * Tool execution context
36
+ */
37
+ export interface ToolContext {
38
+ sessionId?: string;
39
+ userId?: string;
40
+ aiProvider?: string;
41
+ metadata?: ToolExecutionMetadata;
42
+ }
43
+ /**
44
+ * Tool execution result metadata
45
+ */
46
+ export interface ToolResultMetadata {
47
+ toolName?: string;
48
+ executionTime?: number;
49
+ timestamp?: number;
50
+ source?: string;
51
+ version?: string;
52
+ serverId?: string;
53
+ }
54
+ /**
55
+ * Tool execution result
56
+ */
57
+ export interface ToolResult<T = JsonValue> extends Result<T, ErrorInfo> {
58
+ success: boolean;
59
+ data?: T;
60
+ error?: ErrorInfo;
61
+ metadata?: ToolResultMetadata;
62
+ }
63
+ /**
64
+ * Tool metadata for registration
65
+ */
66
+ export interface ToolMetadata {
67
+ category?: string;
68
+ version?: string;
69
+ author?: string;
70
+ tags?: string[];
71
+ documentation?: string;
72
+ [key: string]: JsonValue | undefined;
73
+ }
74
+ /**
75
+ * Tool definition interface
76
+ */
77
+ export interface ToolDefinition<TArgs = ToolArgs, TResult = JsonValue> {
78
+ description: string;
79
+ parameters?: ToolParameterSchema;
80
+ metadata?: ToolMetadata;
81
+ execute: (args: TArgs, context?: ToolContext) => Promise<ToolResult<TResult>> | ToolResult<TResult>;
82
+ }
83
+ /**
84
+ * Simple tool interface (for SDK)
85
+ */
86
+ export interface SimpleTool<TArgs = ToolArgs, TResult = JsonValue> {
87
+ description: string;
88
+ parameters?: z.ZodSchema;
89
+ metadata?: ToolMetadata;
90
+ execute: (args: TArgs, context?: ToolContext) => Promise<TResult> | TResult;
91
+ }
92
+ /**
93
+ * Tool registry entry
94
+ */
95
+ export interface ToolRegistryEntry {
96
+ name: string;
97
+ description: string;
98
+ serverId?: string;
99
+ isImplemented?: boolean;
100
+ parameters?: ToolParameterSchema;
101
+ execute?: ToolDefinition["execute"];
102
+ }
103
+ /**
104
+ * Tool execution information
105
+ */
106
+ export interface ToolExecution {
107
+ toolName: string;
108
+ args: ToolArgs;
109
+ result: ToolResult;
110
+ executionTime: number;
111
+ timestamp: number;
112
+ }
113
+ /**
114
+ * Available tool information
115
+ */
116
+ export interface AvailableTool {
117
+ name: string;
118
+ description: string;
119
+ serverId?: string;
120
+ toolName?: string;
121
+ parameters?: ToolParameterSchema;
122
+ }
123
+ /**
124
+ * Tool validation options
125
+ */
126
+ export interface ToolValidationOptions {
127
+ customValidator?: (toolName: string, args: ToolArgs) => boolean | Promise<boolean>;
128
+ validateSchema?: boolean;
129
+ allowUnknownProperties?: boolean;
130
+ }
131
+ /**
132
+ * Tool call information (for AI SDK integration)
133
+ */
134
+ export interface ToolCall {
135
+ toolName: string;
136
+ parameters: ToolArgs;
137
+ id?: string;
138
+ }
139
+ /**
140
+ * Tool call result (for AI SDK integration)
141
+ */
142
+ export interface ToolCallResult {
143
+ id?: string;
144
+ result: ToolResult;
145
+ formattedForAI: string;
146
+ }
147
+ /**
148
+ * Type guard for tool result
149
+ */
150
+ export declare function isToolResult(value: unknown): value is ToolResult;
151
+ /**
152
+ * Type guard for tool definition
153
+ */
154
+ export declare function isToolDefinition(value: unknown): value is ToolDefinition;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Tool system type definitions for NeuroLink
3
+ * Replaces 'any' types in tool registration and execution
4
+ */
5
+ import { z } from "zod";
6
+ /**
7
+ * Type guard for tool result
8
+ */
9
+ export function isToolResult(value) {
10
+ return (typeof value === "object" &&
11
+ value !== null &&
12
+ "success" in value &&
13
+ typeof value.success === "boolean");
14
+ }
15
+ /**
16
+ * Type guard for tool definition
17
+ */
18
+ export function isToolDefinition(value) {
19
+ return (typeof value === "object" &&
20
+ value !== null &&
21
+ "description" in value &&
22
+ "execute" in value &&
23
+ typeof value.description === "string" &&
24
+ typeof value.execute === "function");
25
+ }
@@ -4,9 +4,9 @@
4
4
  * Provides conditional logging based on NEUROLINK_DEBUG environment variable
5
5
  */
6
6
  export declare const logger: {
7
- debug: (...args: any[]) => void;
8
- info: (...args: any[]) => void;
9
- warn: (...args: any[]) => void;
10
- error: (...args: any[]) => void;
11
- always: (...args: any[]) => void;
7
+ debug: (...args: unknown[]) => void;
8
+ info: (...args: unknown[]) => void;
9
+ warn: (...args: unknown[]) => void;
10
+ error: (...args: unknown[]) => void;
11
+ always: (...args: unknown[]) => void;
12
12
  };
@@ -7,6 +7,7 @@
7
7
  * - Proper error classification
8
8
  * - Rate-limit friendly validation
9
9
  */
10
+ import type { UnknownRecord } from "../types/common.js";
10
11
  export interface ProviderValidationResult {
11
12
  configured: boolean;
12
13
  formatValid: boolean;
@@ -15,7 +16,7 @@ export interface ProviderValidationResult {
15
16
  error?: string;
16
17
  errorType?: "config" | "format" | "auth" | "network" | "quota" | "unknown";
17
18
  responseTime?: number;
18
- details?: Record<string, any>;
19
+ details?: UnknownRecord;
19
20
  }
20
21
  /**
21
22
  * Validate API key format for a specific provider
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
4
4
  "description": "Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 9 major providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
5
5
  "author": {
6
6
  "name": "Juspay Technologies",
@@ -149,25 +149,22 @@
149
149
  "@opentelemetry/sdk-node": "^0.54.2",
150
150
  "@opentelemetry/semantic-conventions": "^1.34.0",
151
151
  "ai": "^4.0.0",
152
+ "chalk": "^5.3.0",
152
153
  "dotenv": "^16.5.0",
154
+ "inquirer": "^9.2.15",
155
+ "mathjs": "^14.5.3",
153
156
  "ollama-ai-provider": "^1.2.0",
157
+ "ora": "^7.0.1",
154
158
  "reconnecting-eventsource": "^1.6.4",
155
159
  "undici": "^6.6.2",
156
160
  "uuid": "^11.1.0",
157
161
  "ws": "^8.18.3",
162
+ "yargs": "^17.7.2",
158
163
  "zod": "^3.22.0",
159
- "zod-to-json-schema": "^3.24.5",
160
- "chalk": "^5.3.0",
161
- "inquirer": "^9.2.15",
162
- "ora": "^7.0.1",
163
- "yargs": "^17.7.2"
164
+ "zod-to-json-schema": "^3.24.5"
164
165
  },
165
166
  "devDependencies": {
166
167
  "@changesets/cli": "^2.26.2",
167
- "@types/ws": "^8.18.1",
168
- "@vitest/coverage-v8": "^2.1.9",
169
- "cors": "^2.8.5",
170
- "express": "^5.1.0",
171
168
  "@eslint/js": "^9.0.0",
172
169
  "@semantic-release/changelog": "^6.0.3",
173
170
  "@semantic-release/commit-analyzer": "^13.0.0",
@@ -183,15 +180,20 @@
183
180
  "@types/express": "^5.0.3",
184
181
  "@types/inquirer": "^9.0.7",
185
182
  "@types/node": "^20.0.0",
183
+ "@types/ws": "^8.18.1",
186
184
  "@types/yargs": "^17.0.33",
187
185
  "@typescript-eslint/eslint-plugin": "^8.0.0",
188
186
  "@typescript-eslint/parser": "^8.0.0",
187
+ "@vitest/coverage-v8": "^2.1.9",
188
+ "cors": "^2.8.5",
189
189
  "eslint": "^9.0.0",
190
+ "express": "^5.1.0",
190
191
  "playwright": "^1.52.0",
191
192
  "prettier": "^3.0.0",
192
193
  "publint": "^0.3.2",
193
194
  "puppeteer": "^24.10.0",
194
195
  "semantic-release": "^24.0.0",
196
+ "shell-quote": "^1.8.3",
195
197
  "svelte": "^5.0.0",
196
198
  "svelte-check": "^4.0.0",
197
199
  "tslib": "^2.4.1",