@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
@@ -1,6 +1,7 @@
1
1
  import { WebSocketServer, WebSocket } from "ws";
2
2
  import { EventEmitter } from "events";
3
3
  import { randomUUID } from "crypto";
4
+ import { IncomingMessage } from "http";
4
5
  import { logger } from "../../utils/logger.js";
5
6
  export class NeuroLinkWebSocketServer extends EventEmitter {
6
7
  wss;
@@ -44,7 +45,7 @@ export class NeuroLinkWebSocketServer extends EventEmitter {
44
45
  }
45
46
  const connectionId = randomUUID();
46
47
  const userAgent = request.headers["user-agent"];
47
- const ipAddress = request.socket.remoteAddress;
48
+ const ipAddress = request.socket?.remoteAddress;
48
49
  // Store connection
49
50
  this.connections.set(connectionId, ws);
50
51
  this.connectionInfo.set(connectionId, {
@@ -1,5 +1,5 @@
1
1
  import { NodeSDK } from "@opentelemetry/sdk-node";
2
- import { metrics, trace } from "@opentelemetry/api";
2
+ import { metrics, trace, } from "@opentelemetry/api";
3
3
  import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
4
4
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
5
5
  import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
@@ -0,0 +1,247 @@
1
+ /**
2
+ * CLI-specific type definitions for NeuroLink
3
+ * Replaces 'any' types in CLI commands and arguments
4
+ */
5
+ import type { UnknownRecord, JsonValue } from "./common.js";
6
+ import type { AnalyticsData, EvaluationData, TokenUsage } from "./providers.js";
7
+ import type { ToolCall, ToolResult } from "./tools.js";
8
+ /**
9
+ * Base command arguments interface
10
+ */
11
+ export interface BaseCommandArgs {
12
+ /** Enable debug output */
13
+ debug?: boolean;
14
+ /** Output format */
15
+ format?: "text" | "json" | "table";
16
+ /** Verbose output */
17
+ verbose?: boolean;
18
+ /** Quiet mode */
19
+ quiet?: boolean;
20
+ }
21
+ /**
22
+ * Generate command arguments
23
+ */
24
+ export interface GenerateCommandArgs extends BaseCommandArgs {
25
+ /** Input text or prompt */
26
+ input?: string;
27
+ /** AI provider to use */
28
+ provider?: string;
29
+ /** Model name */
30
+ model?: string;
31
+ /** System prompt */
32
+ system?: string;
33
+ /** Temperature setting */
34
+ temperature?: number;
35
+ /** Maximum tokens */
36
+ maxTokens?: number;
37
+ /** Enable analytics */
38
+ analytics?: boolean;
39
+ /** Enable evaluation */
40
+ evaluation?: boolean;
41
+ /** Context data */
42
+ context?: string;
43
+ /** Disable tools */
44
+ disableTools?: boolean;
45
+ /** Maximum steps for multi-turn */
46
+ maxSteps?: number;
47
+ /** Output file */
48
+ output?: string;
49
+ }
50
+ /**
51
+ * Stream command arguments
52
+ */
53
+ export interface StreamCommandArgs extends BaseCommandArgs {
54
+ /** Input text or prompt */
55
+ input?: string;
56
+ /** AI provider to use */
57
+ provider?: string;
58
+ /** Model name */
59
+ model?: string;
60
+ /** System prompt */
61
+ system?: string;
62
+ /** Temperature setting */
63
+ temperature?: number;
64
+ /** Maximum tokens */
65
+ maxTokens?: number;
66
+ /** Disable tools */
67
+ disableTools?: boolean;
68
+ }
69
+ /**
70
+ * MCP command arguments
71
+ */
72
+ export interface MCPCommandArgs extends BaseCommandArgs {
73
+ /** MCP server name */
74
+ server?: string;
75
+ /** Tool name to execute */
76
+ tool?: string;
77
+ /** Tool parameters as JSON string */
78
+ params?: string;
79
+ /** List available tools */
80
+ list?: boolean;
81
+ /** Discover MCP servers */
82
+ discover?: boolean;
83
+ /** Show server information */
84
+ info?: boolean;
85
+ }
86
+ /**
87
+ * Ollama command arguments
88
+ */
89
+ export interface OllamaCommandArgs extends BaseCommandArgs {
90
+ /** Ollama model name */
91
+ model?: string;
92
+ /** List available models */
93
+ list?: boolean;
94
+ /** Pull a model */
95
+ pull?: boolean;
96
+ /** Remove a model */
97
+ remove?: boolean;
98
+ /** Show model information */
99
+ show?: boolean;
100
+ }
101
+ /**
102
+ * Provider status command arguments
103
+ */
104
+ export interface ProviderStatusArgs extends BaseCommandArgs {
105
+ /** Specific provider to check */
106
+ provider?: string;
107
+ /** Check all providers */
108
+ all?: boolean;
109
+ }
110
+ /**
111
+ * CLI command result
112
+ */
113
+ export interface CommandResult {
114
+ /** Command success status */
115
+ success: boolean;
116
+ /** Result data */
117
+ data?: unknown;
118
+ /** Error message if failed */
119
+ error?: string;
120
+ /** Output content */
121
+ content?: string;
122
+ /** Execution metadata */
123
+ metadata?: {
124
+ executionTime?: number;
125
+ timestamp?: number;
126
+ command?: string;
127
+ };
128
+ }
129
+ /**
130
+ * Generate command result
131
+ */
132
+ export interface GenerateResult extends CommandResult {
133
+ content: string;
134
+ provider?: string;
135
+ model?: string;
136
+ usage?: TokenUsage;
137
+ responseTime?: number;
138
+ toolCalls?: ToolCall[];
139
+ toolResults?: ToolResult[];
140
+ analytics?: AnalyticsData;
141
+ evaluation?: EvaluationData;
142
+ toolsUsed?: string[];
143
+ toolExecutions?: Array<{
144
+ toolName: string;
145
+ args: UnknownRecord;
146
+ result: unknown;
147
+ executionTime: number;
148
+ }>;
149
+ enhancedWithTools?: boolean;
150
+ availableTools?: Array<{
151
+ name: string;
152
+ description: string;
153
+ }>;
154
+ }
155
+ /**
156
+ * Stream result chunk
157
+ */
158
+ export interface StreamChunk {
159
+ content?: string;
160
+ delta?: string;
161
+ done?: boolean;
162
+ metadata?: UnknownRecord;
163
+ }
164
+ /**
165
+ * CLI output formatting options
166
+ */
167
+ export interface OutputOptions {
168
+ format: "text" | "json" | "table";
169
+ pretty?: boolean;
170
+ color?: boolean;
171
+ compact?: boolean;
172
+ }
173
+ /**
174
+ * Command handler function type
175
+ */
176
+ export type CommandHandler<TArgs = BaseCommandArgs, TResult = CommandResult> = (args: TArgs) => Promise<TResult>;
177
+ /**
178
+ * Command definition
179
+ */
180
+ export interface CommandDefinition<TArgs = BaseCommandArgs> {
181
+ name: string;
182
+ description: string;
183
+ aliases?: string[];
184
+ args?: {
185
+ [K in keyof TArgs]: {
186
+ type: "string" | "number" | "boolean";
187
+ description: string;
188
+ required?: boolean;
189
+ default?: TArgs[K];
190
+ };
191
+ };
192
+ handler: CommandHandler<TArgs>;
193
+ }
194
+ /**
195
+ * CLI context
196
+ */
197
+ export interface CLIContext {
198
+ cwd: string;
199
+ args: string[];
200
+ env: NodeJS.ProcessEnv;
201
+ exitCode?: number;
202
+ }
203
+ /**
204
+ * Color mapping for CLI output
205
+ */
206
+ export interface ColorMap {
207
+ [severity: string]: {
208
+ color: string;
209
+ symbol?: string;
210
+ };
211
+ }
212
+ /**
213
+ * Display severity colors (for evaluation display)
214
+ */
215
+ export interface SeverityColors {
216
+ [key: string]: {
217
+ color: string;
218
+ symbol: string;
219
+ };
220
+ }
221
+ /**
222
+ * JSON output structure
223
+ */
224
+ export interface JSONOutput {
225
+ success: boolean;
226
+ data?: JsonValue;
227
+ error?: string;
228
+ metadata?: {
229
+ timestamp: number;
230
+ command: string;
231
+ version?: string;
232
+ };
233
+ }
234
+ /**
235
+ * Console override for quiet mode
236
+ */
237
+ export interface ConsoleOverride {
238
+ [method: string]: (() => void) | undefined;
239
+ }
240
+ /**
241
+ * Type guard for generate result
242
+ */
243
+ export declare function isGenerateResult(value: unknown): value is GenerateResult;
244
+ /**
245
+ * Type guard for command result
246
+ */
247
+ export declare function isCommandResult(value: unknown): value is CommandResult;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * CLI-specific type definitions for NeuroLink
3
+ * Replaces 'any' types in CLI commands and arguments
4
+ */
5
+ /**
6
+ * Type guard for generate result
7
+ */
8
+ export function isGenerateResult(value) {
9
+ return (typeof value === "object" &&
10
+ value !== null &&
11
+ "content" in value &&
12
+ typeof value.content === "string");
13
+ }
14
+ /**
15
+ * Type guard for command result
16
+ */
17
+ export function isCommandResult(value) {
18
+ return (typeof value === "object" &&
19
+ value !== null &&
20
+ "success" in value &&
21
+ typeof value.success === "boolean");
22
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Common utility types for NeuroLink
3
+ * These types provide type-safe alternatives to 'any' usage
4
+ */
5
+ /**
6
+ * Type-safe unknown value - use instead of 'any' when type is truly unknown
7
+ */
8
+ export type Unknown = unknown;
9
+ /**
10
+ * Type-safe record for metadata and configuration objects
11
+ */
12
+ export type UnknownRecord = Record<string, unknown>;
13
+ /**
14
+ * Type-safe array of unknown items
15
+ */
16
+ export type UnknownArray = unknown[];
17
+ /**
18
+ * JSON-serializable value type
19
+ */
20
+ export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
21
+ export interface JsonObject {
22
+ [key: string]: JsonValue;
23
+ }
24
+ export interface JsonArray extends Array<JsonValue> {
25
+ }
26
+ /**
27
+ * Type-safe error handling
28
+ */
29
+ export interface ErrorInfo {
30
+ message: string;
31
+ code?: string | number;
32
+ stack?: string;
33
+ cause?: unknown;
34
+ }
35
+ /**
36
+ * Generic success/error result type
37
+ */
38
+ export interface Result<T = unknown, E = ErrorInfo> {
39
+ success: boolean;
40
+ data?: T;
41
+ error?: E;
42
+ }
43
+ /**
44
+ * Function parameter type for dynamic functions
45
+ */
46
+ export interface FunctionParameters {
47
+ [key: string]: unknown;
48
+ }
49
+ /**
50
+ * Generic async function type
51
+ */
52
+ export type AsyncFunction<TParams = FunctionParameters, TResult = unknown> = (params: TParams) => Promise<TResult>;
53
+ /**
54
+ * Sync function type
55
+ */
56
+ export type SyncFunction<TParams = FunctionParameters, TResult = unknown> = (params: TParams) => TResult;
57
+ /**
58
+ * Union of async and sync functions
59
+ */
60
+ export type AnyFunction<TParams = FunctionParameters, TResult = unknown> = AsyncFunction<TParams, TResult> | SyncFunction<TParams, TResult>;
61
+ /**
62
+ * Type guard to check if value is Error
63
+ */
64
+ export declare function isError(value: unknown): value is Error;
65
+ /**
66
+ * Type guard to check if value is ErrorInfo
67
+ */
68
+ export declare function isErrorInfo(value: unknown): value is ErrorInfo;
69
+ /**
70
+ * Safe error message extraction
71
+ */
72
+ export declare function getErrorMessage(error: unknown): string;
73
+ /**
74
+ * Safe error conversion
75
+ */
76
+ export declare function toErrorInfo(error: unknown): ErrorInfo;
@@ -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;