@juspay/neurolink 9.54.6 → 9.54.8

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 (408) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/action/actionInputs.d.ts +1 -1
  3. package/dist/adapters/video/directorPipeline.js +6 -0
  4. package/dist/adapters/video/vertexVideoHandler.js +6 -0
  5. package/dist/agent/directTools.d.ts +3 -23
  6. package/dist/auth/AuthProviderFactory.d.ts +1 -3
  7. package/dist/auth/anthropicOAuth.d.ts +4 -7
  8. package/dist/auth/anthropicOAuth.js +23 -0
  9. package/dist/auth/errors.d.ts +1 -1
  10. package/dist/auth/index.d.ts +11 -0
  11. package/dist/auth/index.js +14 -0
  12. package/dist/auth/middleware/AuthMiddleware.d.ts +5 -60
  13. package/dist/auth/middleware/AuthMiddleware.js +3 -0
  14. package/dist/auth/middleware/rateLimitByUser.d.ts +4 -93
  15. package/dist/auth/middleware/rateLimitByUser.js +4 -0
  16. package/dist/auth/providers/BaseAuthProvider.d.ts +1 -1
  17. package/dist/auth/providers/CognitoProvider.js +3 -0
  18. package/dist/auth/providers/KeycloakProvider.js +3 -0
  19. package/dist/auth/providers/auth0.d.ts +1 -1
  20. package/dist/auth/sessionManager.d.ts +2 -0
  21. package/dist/auth/sessionManager.js +53 -11
  22. package/dist/auth/tokenStore.d.ts +2 -0
  23. package/dist/auth/tokenStore.js +45 -4
  24. package/dist/autoresearch/tools.d.ts +1 -16
  25. package/dist/browser/neurolink.min.js +358 -358
  26. package/dist/cli/commands/config.d.ts +3 -123
  27. package/dist/cli/commands/config.js +4 -2
  28. package/dist/cli/commands/evaluate.d.ts +1 -19
  29. package/dist/cli/commands/proxy.d.ts +1 -1
  30. package/dist/cli/commands/proxy.js +3 -0
  31. package/dist/cli/commands/rag.js +3 -0
  32. package/dist/cli/commands/setup-anthropic.d.ts +2 -6
  33. package/dist/cli/commands/setup-anthropic.js +1 -1
  34. package/dist/cli/commands/setup-azure.d.ts +2 -6
  35. package/dist/cli/commands/setup-azure.js +1 -1
  36. package/dist/cli/commands/setup-bedrock.d.ts +2 -6
  37. package/dist/cli/commands/setup-bedrock.js +1 -1
  38. package/dist/cli/commands/setup-gcp.d.ts +2 -6
  39. package/dist/cli/commands/setup-google-ai.d.ts +2 -6
  40. package/dist/cli/commands/setup-google-ai.js +1 -1
  41. package/dist/cli/commands/setup-huggingface.d.ts +1 -5
  42. package/dist/cli/commands/setup-mistral.d.ts +1 -5
  43. package/dist/cli/commands/setup-openai.d.ts +2 -6
  44. package/dist/cli/commands/setup-openai.js +1 -1
  45. package/dist/cli/commands/setup.d.ts +1 -8
  46. package/dist/cli/commands/task.js +1 -0
  47. package/dist/cli/commands/voiceServer.d.ts +1 -4
  48. package/dist/cli/loop/session.js +31 -10
  49. package/dist/cli/utils/interactiveSetup.d.ts +2 -15
  50. package/dist/cli/utils/videoFileUtils.d.ts +1 -15
  51. package/dist/client/aiSdkAdapter.d.ts +1 -1
  52. package/dist/client/aiSdkAdapter.js +1 -0
  53. package/dist/client/httpClient.d.ts +1 -0
  54. package/dist/client/httpClient.js +13 -0
  55. package/dist/client/sseClient.d.ts +1 -0
  56. package/dist/client/sseClient.js +29 -0
  57. package/dist/client/streamingClient.d.ts +2 -0
  58. package/dist/client/streamingClient.js +19 -0
  59. package/dist/client/wsClient.d.ts +6 -0
  60. package/dist/client/wsClient.js +90 -10
  61. package/dist/context/budgetChecker.js +3 -1
  62. package/dist/context/contextCompactor.js +163 -143
  63. package/dist/context/fileSummarizationService.d.ts +1 -9
  64. package/dist/context/summarizationEngine.js +29 -16
  65. package/dist/core/baseProvider.js +124 -153
  66. package/dist/core/infrastructure/baseRegistry.d.ts +1 -7
  67. package/dist/core/modules/GenerationHandler.d.ts +3 -2
  68. package/dist/core/modules/GenerationHandler.js +9 -1
  69. package/dist/core/modules/StreamHandler.js +9 -0
  70. package/dist/core/modules/ToolsManager.js +18 -2
  71. package/dist/evaluation/BatchEvaluator.d.ts +1 -97
  72. package/dist/evaluation/EvaluationAggregator.d.ts +1 -118
  73. package/dist/evaluation/EvaluatorFactory.d.ts +1 -13
  74. package/dist/evaluation/EvaluatorRegistry.d.ts +1 -50
  75. package/dist/evaluation/errors/EvaluationError.d.ts +2 -27
  76. package/dist/evaluation/hooks/langfuseAdapter.d.ts +1 -39
  77. package/dist/evaluation/hooks/observabilityHooks.d.ts +3 -55
  78. package/dist/evaluation/hooks/observabilityHooks.js +3 -0
  79. package/dist/evaluation/pipeline/strategies/batchStrategy.d.ts +7 -61
  80. package/dist/evaluation/pipeline/strategies/batchStrategy.js +7 -7
  81. package/dist/evaluation/ragasEvaluator.js +54 -37
  82. package/dist/evaluation/reporting/metricsCollector.d.ts +1 -60
  83. package/dist/evaluation/reporting/reportGenerator.d.ts +1 -17
  84. package/dist/evaluation/scorers/rule/contentSimilarityScorer.d.ts +1 -29
  85. package/dist/evaluation/scorers/rule/formatScorer.d.ts +1 -42
  86. package/dist/evaluation/scorers/rule/keywordCoverageScorer.d.ts +1 -19
  87. package/dist/evaluation/scorers/rule/lengthScorer.d.ts +1 -33
  88. package/dist/factories/providerFactory.d.ts +1 -16
  89. package/dist/factories/providerFactory.js +2 -0
  90. package/dist/image-gen/ImageGenService.d.ts +3 -0
  91. package/dist/image-gen/ImageGenService.js +3 -0
  92. package/dist/lib/action/actionInputs.d.ts +1 -1
  93. package/dist/lib/adapters/video/directorPipeline.js +6 -0
  94. package/dist/lib/adapters/video/vertexVideoHandler.js +6 -0
  95. package/dist/lib/agent/directTools.d.ts +3 -23
  96. package/dist/lib/auth/AuthProviderFactory.d.ts +1 -3
  97. package/dist/lib/auth/anthropicOAuth.d.ts +4 -7
  98. package/dist/lib/auth/anthropicOAuth.js +23 -0
  99. package/dist/lib/auth/errors.d.ts +1 -1
  100. package/dist/lib/auth/index.d.ts +11 -0
  101. package/dist/lib/auth/index.js +14 -0
  102. package/dist/lib/auth/middleware/AuthMiddleware.d.ts +5 -60
  103. package/dist/lib/auth/middleware/AuthMiddleware.js +3 -0
  104. package/dist/lib/auth/middleware/rateLimitByUser.d.ts +4 -93
  105. package/dist/lib/auth/middleware/rateLimitByUser.js +4 -0
  106. package/dist/lib/auth/providers/BaseAuthProvider.d.ts +1 -1
  107. package/dist/lib/auth/providers/CognitoProvider.js +3 -0
  108. package/dist/lib/auth/providers/KeycloakProvider.js +3 -0
  109. package/dist/lib/auth/providers/auth0.d.ts +1 -1
  110. package/dist/lib/auth/sessionManager.d.ts +2 -0
  111. package/dist/lib/auth/sessionManager.js +53 -11
  112. package/dist/lib/auth/tokenStore.d.ts +2 -0
  113. package/dist/lib/auth/tokenStore.js +45 -4
  114. package/dist/lib/autoresearch/tools.d.ts +1 -16
  115. package/dist/lib/client/aiSdkAdapter.d.ts +1 -1
  116. package/dist/lib/client/aiSdkAdapter.js +1 -0
  117. package/dist/lib/client/httpClient.d.ts +1 -0
  118. package/dist/lib/client/httpClient.js +13 -0
  119. package/dist/lib/client/sseClient.d.ts +1 -0
  120. package/dist/lib/client/sseClient.js +29 -0
  121. package/dist/lib/client/streamingClient.d.ts +2 -0
  122. package/dist/lib/client/streamingClient.js +19 -0
  123. package/dist/lib/client/wsClient.d.ts +6 -0
  124. package/dist/lib/client/wsClient.js +90 -10
  125. package/dist/lib/context/budgetChecker.js +3 -1
  126. package/dist/lib/context/contextCompactor.js +163 -143
  127. package/dist/lib/context/fileSummarizationService.d.ts +1 -9
  128. package/dist/lib/context/summarizationEngine.js +29 -16
  129. package/dist/lib/core/baseProvider.js +124 -153
  130. package/dist/lib/core/infrastructure/baseRegistry.d.ts +1 -7
  131. package/dist/lib/core/modules/GenerationHandler.d.ts +3 -2
  132. package/dist/lib/core/modules/GenerationHandler.js +9 -1
  133. package/dist/lib/core/modules/StreamHandler.js +9 -0
  134. package/dist/lib/core/modules/ToolsManager.js +18 -2
  135. package/dist/lib/evaluation/BatchEvaluator.d.ts +1 -97
  136. package/dist/lib/evaluation/EvaluationAggregator.d.ts +1 -118
  137. package/dist/lib/evaluation/EvaluatorFactory.d.ts +1 -13
  138. package/dist/lib/evaluation/EvaluatorRegistry.d.ts +1 -50
  139. package/dist/lib/evaluation/errors/EvaluationError.d.ts +2 -27
  140. package/dist/lib/evaluation/hooks/langfuseAdapter.d.ts +1 -39
  141. package/dist/lib/evaluation/hooks/observabilityHooks.d.ts +3 -55
  142. package/dist/lib/evaluation/hooks/observabilityHooks.js +3 -0
  143. package/dist/lib/evaluation/pipeline/strategies/batchStrategy.d.ts +7 -61
  144. package/dist/lib/evaluation/pipeline/strategies/batchStrategy.js +7 -7
  145. package/dist/lib/evaluation/ragasEvaluator.js +54 -37
  146. package/dist/lib/evaluation/reporting/metricsCollector.d.ts +1 -60
  147. package/dist/lib/evaluation/reporting/reportGenerator.d.ts +1 -17
  148. package/dist/lib/evaluation/scorers/rule/contentSimilarityScorer.d.ts +1 -29
  149. package/dist/lib/evaluation/scorers/rule/formatScorer.d.ts +1 -42
  150. package/dist/lib/evaluation/scorers/rule/keywordCoverageScorer.d.ts +1 -19
  151. package/dist/lib/evaluation/scorers/rule/lengthScorer.d.ts +1 -33
  152. package/dist/lib/factories/providerFactory.d.ts +1 -16
  153. package/dist/lib/factories/providerFactory.js +2 -0
  154. package/dist/lib/image-gen/ImageGenService.d.ts +3 -0
  155. package/dist/lib/image-gen/ImageGenService.js +3 -0
  156. package/dist/lib/mcp/batching/requestBatcher.js +99 -73
  157. package/dist/lib/mcp/httpRateLimiter.js +3 -1
  158. package/dist/lib/mcp/httpRetryHandler.js +3 -1
  159. package/dist/lib/mcp/mcpClientFactory.js +3 -1
  160. package/dist/lib/mcp/multiServerManager.d.ts +1 -14
  161. package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +5 -1
  162. package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +1 -0
  163. package/dist/lib/mcp/toolDiscoveryService.js +70 -57
  164. package/dist/lib/mcp/toolRegistry.js +11 -1
  165. package/dist/lib/memory/memoryRetrievalTools.js +182 -141
  166. package/dist/lib/neurolink.js +236 -40
  167. package/dist/lib/observability/exporterRegistry.d.ts +3 -21
  168. package/dist/lib/observability/exporters/sentryExporter.js +1 -0
  169. package/dist/lib/observability/metricsAggregator.d.ts +1 -31
  170. package/dist/lib/observability/tokenTracker.d.ts +7 -16
  171. package/dist/lib/observability/tokenTracker.js +6 -4
  172. package/dist/lib/observability/utils/spanSerializer.d.ts +5 -1
  173. package/dist/lib/observability/utils/spanSerializer.js +24 -4
  174. package/dist/lib/processors/base/BaseFileProcessor.js +66 -53
  175. package/dist/lib/processors/document/ExcelProcessor.d.ts +1 -1
  176. package/dist/lib/processors/errors/errorHelpers.d.ts +1 -31
  177. package/dist/lib/processors/errors/errorSerializer.d.ts +1 -45
  178. package/dist/lib/processors/registry/ProcessorRegistry.js +17 -6
  179. package/dist/lib/providers/amazonBedrock.js +189 -15
  180. package/dist/lib/providers/amazonSagemaker.js +25 -11
  181. package/dist/lib/providers/anthropic.js +13 -0
  182. package/dist/lib/providers/azureOpenai.js +2 -0
  183. package/dist/lib/providers/googleAiStudio.js +96 -26
  184. package/dist/lib/providers/googleVertex.js +66 -27
  185. package/dist/lib/providers/huggingFace.js +2 -0
  186. package/dist/lib/providers/litellm.js +2 -0
  187. package/dist/lib/providers/mistral.js +2 -0
  188. package/dist/lib/providers/ollama.js +84 -5
  189. package/dist/lib/providers/openAI.d.ts +2 -0
  190. package/dist/lib/providers/openAI.js +17 -6
  191. package/dist/lib/providers/openRouter.js +2 -0
  192. package/dist/lib/providers/openaiCompatible.js +2 -0
  193. package/dist/lib/providers/sagemaker/detection.d.ts +1 -33
  194. package/dist/lib/providers/sagemaker/diagnostics.d.ts +1 -25
  195. package/dist/lib/providers/sagemaker/language-model.d.ts +1 -1
  196. package/dist/lib/proxy/proxyConfig.js +4 -0
  197. package/dist/lib/proxy/proxyEnv.d.ts +1 -17
  198. package/dist/lib/proxy/proxyTracer.d.ts +1 -36
  199. package/dist/lib/proxy/proxyTracer.js +9 -0
  200. package/dist/lib/proxy/quietDetector.d.ts +1 -7
  201. package/dist/lib/proxy/rawStreamCapture.d.ts +1 -10
  202. package/dist/lib/proxy/requestLogger.d.ts +1 -21
  203. package/dist/lib/proxy/sseInterceptor.d.ts +1 -66
  204. package/dist/lib/proxy/sseInterceptor.js +6 -0
  205. package/dist/lib/proxy/updateChecker.d.ts +1 -6
  206. package/dist/lib/proxy/updateState.d.ts +1 -12
  207. package/dist/lib/rag/chunkers/BaseChunker.js +36 -22
  208. package/dist/lib/rag/chunking/jsonChunker.d.ts +1 -1
  209. package/dist/lib/rag/errors/RAGError.d.ts +1 -2
  210. package/dist/lib/rag/ragIntegration.js +45 -32
  211. package/dist/lib/rag/reranker/reranker.js +151 -122
  212. package/dist/lib/rag/retrieval/vectorQueryTool.js +79 -65
  213. package/dist/lib/sdk/toolRegistration.d.ts +10 -44
  214. package/dist/lib/sdk/toolRegistration.js +1 -1
  215. package/dist/lib/server/middleware/abortSignal.d.ts +1 -11
  216. package/dist/lib/server/middleware/auth.d.ts +1 -21
  217. package/dist/lib/server/middleware/auth.js +12 -0
  218. package/dist/lib/server/middleware/common.js +48 -32
  219. package/dist/lib/server/middleware/deprecation.d.ts +1 -20
  220. package/dist/lib/server/middleware/rateLimit.d.ts +1 -75
  221. package/dist/lib/server/middleware/validation.d.ts +3 -81
  222. package/dist/lib/server/middleware/validation.js +3 -0
  223. package/dist/lib/server/openapi/generator.d.ts +1 -47
  224. package/dist/lib/server/routes/agentRoutes.js +112 -57
  225. package/dist/lib/server/routes/claudeProxyRoutes.d.ts +1 -6
  226. package/dist/lib/server/routes/claudeProxyRoutes.js +127 -13
  227. package/dist/lib/server/routes/healthRoutes.js +58 -12
  228. package/dist/lib/server/routes/index.d.ts +1 -26
  229. package/dist/lib/server/routes/mcpRoutes.js +40 -7
  230. package/dist/lib/server/routes/memoryRoutes.js +22 -7
  231. package/dist/lib/server/routes/openApiRoutes.js +30 -6
  232. package/dist/lib/server/routes/toolRoutes.js +140 -68
  233. package/dist/lib/server/streaming/dataStream.d.ts +1 -35
  234. package/dist/lib/server/streaming/dataStream.js +15 -0
  235. package/dist/lib/services/server/ai/observability/instrumentation.js +114 -14
  236. package/dist/lib/session/globalSessionState.d.ts +1 -10
  237. package/dist/lib/tasks/tools/taskTools.d.ts +2 -2
  238. package/dist/lib/telemetry/traceContext.d.ts +9 -0
  239. package/dist/lib/telemetry/traceContext.js +19 -0
  240. package/dist/lib/telemetry/tracers.d.ts +2 -0
  241. package/dist/lib/telemetry/tracers.js +2 -0
  242. package/dist/lib/types/action.d.ts +2 -0
  243. package/dist/lib/types/artifact.d.ts +7 -0
  244. package/dist/lib/types/auth.d.ts +125 -18
  245. package/dist/lib/types/autoresearch.d.ts +12 -0
  246. package/dist/lib/types/cli.d.ts +415 -0
  247. package/dist/lib/types/client.d.ts +34 -0
  248. package/dist/lib/types/common.d.ts +12 -41
  249. package/dist/lib/types/context.d.ts +5 -0
  250. package/dist/lib/types/evaluation.d.ts +332 -1
  251. package/dist/lib/types/file.d.ts +4 -0
  252. package/dist/lib/types/mcp.d.ts +102 -2
  253. package/dist/lib/types/middleware.d.ts +116 -0
  254. package/dist/lib/types/multimodal.d.ts +65 -0
  255. package/dist/lib/types/observability.d.ts +81 -0
  256. package/dist/lib/types/processor.d.ts +47 -0
  257. package/dist/lib/types/providers.d.ts +120 -16
  258. package/dist/lib/types/proxy.d.ts +321 -1
  259. package/dist/lib/types/rag.d.ts +22 -0
  260. package/dist/lib/types/scorer.d.ts +141 -0
  261. package/dist/lib/types/server.d.ts +99 -0
  262. package/dist/lib/types/span.d.ts +2 -1
  263. package/dist/lib/types/span.js +1 -0
  264. package/dist/lib/types/tools.d.ts +44 -0
  265. package/dist/lib/types/tts.d.ts +6 -0
  266. package/dist/lib/types/utilities.d.ts +22 -0
  267. package/dist/lib/types/workflow.d.ts +18 -0
  268. package/dist/lib/utils/async/retry.d.ts +2 -8
  269. package/dist/lib/utils/async/retry.js +9 -9
  270. package/dist/lib/utils/imageCompressor.d.ts +1 -21
  271. package/dist/lib/utils/imageCompressor.js +5 -1
  272. package/dist/lib/utils/messageBuilder.d.ts +1 -1
  273. package/dist/lib/utils/redis.d.ts +1 -4
  274. package/dist/lib/utils/toolEndEmitter.d.ts +25 -0
  275. package/dist/lib/utils/toolEndEmitter.js +65 -0
  276. package/dist/lib/workflow/config.d.ts +7 -32
  277. package/dist/lib/workflow/core/ensembleExecutor.js +28 -0
  278. package/dist/lib/workflow/core/judgeScorer.js +23 -0
  279. package/dist/lib/workflow/core/responseConditioner.js +17 -0
  280. package/dist/lib/workflow/core/workflowRunner.d.ts +1 -19
  281. package/dist/lib/workflow/core/workflowRunner.js +202 -147
  282. package/dist/mcp/batching/requestBatcher.js +99 -73
  283. package/dist/mcp/httpRateLimiter.js +3 -1
  284. package/dist/mcp/httpRetryHandler.js +3 -1
  285. package/dist/mcp/mcpClientFactory.js +3 -1
  286. package/dist/mcp/multiServerManager.d.ts +1 -14
  287. package/dist/mcp/servers/aiProviders/aiAnalysisTools.js +5 -1
  288. package/dist/mcp/servers/aiProviders/aiWorkflowTools.js +1 -0
  289. package/dist/mcp/toolDiscoveryService.js +70 -57
  290. package/dist/mcp/toolRegistry.js +11 -1
  291. package/dist/memory/memoryRetrievalTools.js +182 -141
  292. package/dist/neurolink.js +236 -40
  293. package/dist/observability/exporterRegistry.d.ts +3 -21
  294. package/dist/observability/exporters/sentryExporter.js +1 -0
  295. package/dist/observability/metricsAggregator.d.ts +1 -31
  296. package/dist/observability/tokenTracker.d.ts +7 -16
  297. package/dist/observability/tokenTracker.js +6 -4
  298. package/dist/observability/utils/spanSerializer.d.ts +5 -1
  299. package/dist/observability/utils/spanSerializer.js +24 -4
  300. package/dist/processors/base/BaseFileProcessor.js +66 -53
  301. package/dist/processors/document/ExcelProcessor.d.ts +1 -1
  302. package/dist/processors/errors/errorHelpers.d.ts +1 -31
  303. package/dist/processors/errors/errorSerializer.d.ts +1 -45
  304. package/dist/processors/registry/ProcessorRegistry.js +17 -6
  305. package/dist/providers/amazonBedrock.js +189 -15
  306. package/dist/providers/amazonSagemaker.js +25 -11
  307. package/dist/providers/anthropic.js +13 -0
  308. package/dist/providers/azureOpenai.js +2 -0
  309. package/dist/providers/googleAiStudio.js +96 -26
  310. package/dist/providers/googleVertex.js +66 -27
  311. package/dist/providers/huggingFace.js +2 -0
  312. package/dist/providers/litellm.js +2 -0
  313. package/dist/providers/mistral.js +2 -0
  314. package/dist/providers/ollama.js +84 -5
  315. package/dist/providers/openAI.d.ts +2 -0
  316. package/dist/providers/openAI.js +17 -6
  317. package/dist/providers/openRouter.js +2 -0
  318. package/dist/providers/openaiCompatible.js +2 -0
  319. package/dist/providers/sagemaker/detection.d.ts +1 -33
  320. package/dist/providers/sagemaker/diagnostics.d.ts +1 -25
  321. package/dist/providers/sagemaker/language-model.d.ts +1 -1
  322. package/dist/proxy/proxyConfig.js +4 -0
  323. package/dist/proxy/proxyEnv.d.ts +1 -17
  324. package/dist/proxy/proxyTracer.d.ts +1 -36
  325. package/dist/proxy/proxyTracer.js +9 -0
  326. package/dist/proxy/quietDetector.d.ts +1 -7
  327. package/dist/proxy/rawStreamCapture.d.ts +1 -10
  328. package/dist/proxy/requestLogger.d.ts +1 -21
  329. package/dist/proxy/sseInterceptor.d.ts +1 -66
  330. package/dist/proxy/sseInterceptor.js +6 -0
  331. package/dist/proxy/updateChecker.d.ts +1 -6
  332. package/dist/proxy/updateState.d.ts +1 -12
  333. package/dist/rag/chunkers/BaseChunker.js +36 -22
  334. package/dist/rag/chunking/jsonChunker.d.ts +1 -1
  335. package/dist/rag/errors/RAGError.d.ts +1 -2
  336. package/dist/rag/ragIntegration.js +45 -32
  337. package/dist/rag/reranker/reranker.js +151 -122
  338. package/dist/rag/retrieval/vectorQueryTool.js +79 -65
  339. package/dist/sdk/toolRegistration.d.ts +10 -44
  340. package/dist/sdk/toolRegistration.js +1 -1
  341. package/dist/server/middleware/abortSignal.d.ts +1 -11
  342. package/dist/server/middleware/auth.d.ts +1 -21
  343. package/dist/server/middleware/auth.js +12 -0
  344. package/dist/server/middleware/common.js +48 -32
  345. package/dist/server/middleware/deprecation.d.ts +1 -20
  346. package/dist/server/middleware/rateLimit.d.ts +1 -75
  347. package/dist/server/middleware/validation.d.ts +3 -81
  348. package/dist/server/middleware/validation.js +3 -0
  349. package/dist/server/openapi/generator.d.ts +1 -47
  350. package/dist/server/routes/agentRoutes.js +112 -57
  351. package/dist/server/routes/claudeProxyRoutes.d.ts +1 -6
  352. package/dist/server/routes/claudeProxyRoutes.js +127 -13
  353. package/dist/server/routes/healthRoutes.js +58 -12
  354. package/dist/server/routes/index.d.ts +1 -26
  355. package/dist/server/routes/mcpRoutes.js +40 -7
  356. package/dist/server/routes/memoryRoutes.js +22 -7
  357. package/dist/server/routes/openApiRoutes.js +30 -6
  358. package/dist/server/routes/toolRoutes.js +140 -68
  359. package/dist/server/streaming/dataStream.d.ts +1 -35
  360. package/dist/server/streaming/dataStream.js +15 -0
  361. package/dist/services/server/ai/observability/instrumentation.js +114 -14
  362. package/dist/session/globalSessionState.d.ts +1 -10
  363. package/dist/tasks/tools/taskTools.d.ts +2 -2
  364. package/dist/telemetry/traceContext.d.ts +9 -0
  365. package/dist/telemetry/traceContext.js +18 -0
  366. package/dist/telemetry/tracers.d.ts +2 -0
  367. package/dist/telemetry/tracers.js +2 -0
  368. package/dist/types/action.d.ts +2 -0
  369. package/dist/types/artifact.d.ts +7 -0
  370. package/dist/types/auth.d.ts +125 -18
  371. package/dist/types/autoresearch.d.ts +12 -0
  372. package/dist/types/cli.d.ts +415 -0
  373. package/dist/types/client.d.ts +34 -0
  374. package/dist/types/common.d.ts +12 -41
  375. package/dist/types/context.d.ts +5 -0
  376. package/dist/types/evaluation.d.ts +332 -1
  377. package/dist/types/file.d.ts +4 -0
  378. package/dist/types/mcp.d.ts +102 -2
  379. package/dist/types/middleware.d.ts +116 -0
  380. package/dist/types/multimodal.d.ts +65 -0
  381. package/dist/types/observability.d.ts +81 -0
  382. package/dist/types/processor.d.ts +47 -0
  383. package/dist/types/providers.d.ts +120 -16
  384. package/dist/types/proxy.d.ts +321 -1
  385. package/dist/types/rag.d.ts +22 -0
  386. package/dist/types/scorer.d.ts +141 -0
  387. package/dist/types/server.d.ts +99 -0
  388. package/dist/types/span.d.ts +2 -1
  389. package/dist/types/span.js +1 -0
  390. package/dist/types/tools.d.ts +44 -0
  391. package/dist/types/tts.d.ts +6 -0
  392. package/dist/types/utilities.d.ts +22 -0
  393. package/dist/types/workflow.d.ts +18 -0
  394. package/dist/utils/async/retry.d.ts +2 -8
  395. package/dist/utils/async/retry.js +9 -9
  396. package/dist/utils/imageCompressor.d.ts +1 -21
  397. package/dist/utils/imageCompressor.js +5 -1
  398. package/dist/utils/messageBuilder.d.ts +1 -1
  399. package/dist/utils/redis.d.ts +1 -4
  400. package/dist/utils/toolEndEmitter.d.ts +25 -0
  401. package/dist/utils/toolEndEmitter.js +64 -0
  402. package/dist/workflow/config.d.ts +4 -29
  403. package/dist/workflow/core/ensembleExecutor.js +28 -0
  404. package/dist/workflow/core/judgeScorer.js +23 -0
  405. package/dist/workflow/core/responseConditioner.js +17 -0
  406. package/dist/workflow/core/workflowRunner.d.ts +1 -19
  407. package/dist/workflow/core/workflowRunner.js +202 -147
  408. package/package.json +2 -8
@@ -0,0 +1,18 @@
1
+ import { trace, context } from "@opentelemetry/api";
2
+ /**
3
+ * Extract the current OTel trace context for use by Pipeline B spans.
4
+ * Returns undefined values when no OTel context is active, allowing
5
+ * Pipeline B spans to share the same trace as Pipeline A spans.
6
+ */
7
+ export function getActiveTraceContext() {
8
+ const activeSpan = trace.getSpan(context.active());
9
+ if (!activeSpan) {
10
+ return {};
11
+ }
12
+ const ctx = activeSpan.spanContext();
13
+ // Invalid trace IDs are all zeros — don't use those
14
+ if (!ctx.traceId || ctx.traceId === "00000000000000000000000000000000") {
15
+ return {};
16
+ }
17
+ return { traceId: ctx.traceId, parentSpanId: ctx.spanId };
18
+ }
@@ -14,4 +14,6 @@ export declare const tracers: {
14
14
  readonly processor: import("@opentelemetry/api").Tracer;
15
15
  readonly file: import("@opentelemetry/api").Tracer;
16
16
  readonly autoresearch: import("@opentelemetry/api").Tracer;
17
+ readonly auth: import("@opentelemetry/api").Tracer;
18
+ readonly workflow: import("@opentelemetry/api").Tracer;
17
19
  };
@@ -15,4 +15,6 @@ export const tracers = {
15
15
  processor: trace.getTracer("neurolink.processor"),
16
16
  file: trace.getTracer("neurolink.file"),
17
17
  autoresearch: trace.getTracer("neurolink.autoresearch"),
18
+ auth: trace.getTracer("neurolink.auth"),
19
+ workflow: trace.getTracer("neurolink.workflow"),
18
20
  };
@@ -203,3 +203,5 @@ export type ActionInputValidation = {
203
203
  export type ProviderKeyMapping = {
204
204
  [K in AIProviderName]?: (keyof ActionProviderKeys)[];
205
205
  };
206
+ /** Provider-to-required-keys map used by actionInputs.ts. */
207
+ export type ProviderKeyMap = Record<string, string[]>;
@@ -61,3 +61,10 @@ export type ArtifactStore = {
61
61
  /** Generate a short preview string from a serialized payload. */
62
62
  generatePreview(payload: string): string;
63
63
  };
64
+ /**
65
+ * In-memory index row tracked by LocalTempArtifactStore.
66
+ * Combines metadata with the on-disk path.
67
+ */
68
+ export type IndexEntry = ArtifactMeta & {
69
+ path: string;
70
+ };
@@ -820,24 +820,6 @@ export type AuthEventHandler = (event: AuthEventData) => void | Promise<void>;
820
820
  * Auth provider factory function type
821
821
  */
822
822
  export type AuthProviderFactoryFn = (config: AuthProviderConfig) => Promise<MastraAuthProvider>;
823
- /**
824
- * Auth provider registration entry
825
- */
826
- export type AuthProviderRegistration = {
827
- /** Provider type */
828
- type: AuthProviderType;
829
- /** Factory function */
830
- factory: AuthProviderFactoryFn;
831
- /** Provider aliases */
832
- aliases: string[];
833
- /** Provider metadata */
834
- metadata?: {
835
- name: string;
836
- description: string;
837
- version?: string;
838
- documentation?: string;
839
- };
840
- };
841
823
  /**
842
824
  * Auth health check result
843
825
  */
@@ -1031,3 +1013,128 @@ export type SessionManagerStorage = {
1031
1013
  /** Health check */
1032
1014
  isHealthy(): Promise<boolean>;
1033
1015
  };
1016
+ /** Cached JWKS entry with TTL. Used by Cognito and Keycloak providers. */
1017
+ export type AuthJWKSCacheEntry = {
1018
+ jwks: JWKS;
1019
+ expiresAt: number;
1020
+ };
1021
+ /** Async constructor for an auth provider given its config. */
1022
+ export type AuthProviderConstructor = (config: AuthProviderConfig) => Promise<MastraAuthProvider>;
1023
+ /** Registration row for an auth provider in AuthProviderFactory. */
1024
+ export type AuthProviderRegistration = {
1025
+ factory: AuthProviderConstructor;
1026
+ aliases: string[];
1027
+ metadata?: AuthProviderMetadata;
1028
+ };
1029
+ /** Synthetic Claude Code client identity used for quota + identification. */
1030
+ export type ClaudeCodeIdentity = {
1031
+ deviceId: string;
1032
+ accountUuid: string;
1033
+ sessionId: string;
1034
+ metadataUserId: string;
1035
+ };
1036
+ /** Minimal request object accepted by the auth middleware. */
1037
+ export type IncomingRequest = {
1038
+ method?: string;
1039
+ url?: string;
1040
+ path?: string;
1041
+ headers?: Record<string, string | string[] | undefined>;
1042
+ cookies?: Record<string, string>;
1043
+ query?: Record<string, string | string[] | undefined>;
1044
+ body?: unknown;
1045
+ ip?: string;
1046
+ user?: AuthUser;
1047
+ authContext?: AuthenticatedContext;
1048
+ };
1049
+ /** Minimal Express-style response object used by the auth middleware. */
1050
+ export type OutgoingResponse = {
1051
+ status(code: number): OutgoingResponse;
1052
+ json(body: unknown): void;
1053
+ };
1054
+ /** Middleware handler function type for the auth layer. */
1055
+ export type AuthMiddlewareHandler<TContext = AuthRequestContext> = (context: TContext) => Promise<AuthMiddlewareResult>;
1056
+ /** Result produced by an auth middleware handler. */
1057
+ export type AuthMiddlewareResult = {
1058
+ proceed: boolean;
1059
+ context?: AuthenticatedContext;
1060
+ error?: {
1061
+ statusCode: number;
1062
+ message: string;
1063
+ code?: string;
1064
+ };
1065
+ };
1066
+ /** Next-function for Express-style middleware chaining. */
1067
+ export type NextFunction = () => Promise<void>;
1068
+ /** Express-style auth middleware signature. */
1069
+ export type ExpressMiddleware = (req: IncomingRequest, res: OutgoingResponse, next: NextFunction) => Promise<void>;
1070
+ /** Token bucket state for a single user. */
1071
+ export type TokenBucket = {
1072
+ tokens: number;
1073
+ lastRefill: number;
1074
+ userId: string;
1075
+ };
1076
+ /** Rate limit configuration per user or role. */
1077
+ export type AuthRateLimitConfig = {
1078
+ maxRequests: number;
1079
+ windowMs: number;
1080
+ roleLimits?: Record<string, number>;
1081
+ userLimits?: Record<string, number>;
1082
+ skipRoles?: string[];
1083
+ message?: string;
1084
+ };
1085
+ /** Rate limit result. */
1086
+ export type RateLimitResult = {
1087
+ allowed: boolean;
1088
+ remaining: number;
1089
+ resetIn: number;
1090
+ limit: number;
1091
+ error?: string;
1092
+ };
1093
+ /** Result of an atomic consume operation against a token bucket. */
1094
+ export type AtomicConsumeResult = {
1095
+ bucket: TokenBucket;
1096
+ consumed: boolean;
1097
+ };
1098
+ /** Storage contract for rate-limit buckets (memory or Redis). */
1099
+ export type RateLimitStorage = {
1100
+ getBucket(userId: string): Promise<TokenBucket | null>;
1101
+ setBucket(userId: string, bucket: TokenBucket): Promise<void>;
1102
+ deleteBucket(userId: string): Promise<void>;
1103
+ healthCheck(): Promise<boolean>;
1104
+ cleanup(): Promise<void>;
1105
+ atomicConsume?(userId: string, limit: number, windowMs: number, nowMs: number): Promise<AtomicConsumeResult | null>;
1106
+ };
1107
+ /**
1108
+ * Minimal Redis client shape used by the rate-limiter to avoid a hard
1109
+ * dependency on the full `RedisClientType`. Named with an Auth prefix to
1110
+ * avoid collision with `RedisClientType` from the redis package.
1111
+ */
1112
+ export type AuthRateLimitRedisClient = {
1113
+ connect(): Promise<void>;
1114
+ quit(): Promise<void>;
1115
+ ping(): Promise<string>;
1116
+ get(key: string): Promise<string | null>;
1117
+ setEx(key: string, seconds: number, value: string): Promise<void>;
1118
+ del(key: string): Promise<number>;
1119
+ eval(script: string, numkeys: number, ...args: string[]): Promise<unknown>;
1120
+ };
1121
+ /** Middleware-level outcome returned by the rate limiter. */
1122
+ export type RateLimitMiddlewareResult = {
1123
+ proceed: boolean;
1124
+ rateLimitResult: RateLimitResult;
1125
+ response?: Response;
1126
+ };
1127
+ /** Auth0 JWT payload structure. */
1128
+ export type Auth0TokenPayload = {
1129
+ sub: string;
1130
+ email?: string;
1131
+ name?: string;
1132
+ picture?: string;
1133
+ email_verified?: boolean;
1134
+ roles?: string[];
1135
+ permissions?: string[];
1136
+ iat: number;
1137
+ exp: number;
1138
+ aud: string | string[];
1139
+ iss: string;
1140
+ };
@@ -5,6 +5,10 @@
5
5
  * experiments, evaluates results against a deterministic metric, and
6
6
  * keeps or discards each change — running unattended for hours.
7
7
  */
8
+ import type { RepoPolicy } from "../autoresearch/repoPolicy.js";
9
+ import type { ResearchStateStore } from "../autoresearch/stateStore.js";
10
+ import type { ResultRecorder } from "../autoresearch/resultRecorder.js";
11
+ import type { ExperimentRunner } from "../autoresearch/runner.js";
8
12
  import type { ThinkingLevel } from "./config.js";
9
13
  export type MetricDirection = "lower" | "higher";
10
14
  export type MetricConfig = {
@@ -192,3 +196,11 @@ export declare const AUTORESEARCH_DEFAULTS: {
192
196
  readonly branchPrefix: "autoresearch/";
193
197
  readonly thinkingLevel: ThinkingLevel;
194
198
  };
199
+ /** Dependencies required to create research tools. */
200
+ export type ResearchToolsDeps = {
201
+ config: ResearchConfig;
202
+ stateStore: ResearchStateStore;
203
+ repoPolicy: RepoPolicy;
204
+ runner: ExperimentRunner;
205
+ recorder: ResultRecorder;
206
+ };
@@ -577,6 +577,11 @@ export type SetupArgs = {
577
577
  interactive?: boolean;
578
578
  help?: boolean;
579
579
  };
580
+ /**
581
+ * Narrowed ProviderInfo used by the main `neurolink setup` command,
582
+ * where the descriptive fields are always populated.
583
+ */
584
+ export type SetupProviderInfo = ProviderInfo & Required<Pick<ProviderInfo, "bestFor" | "models" | "strengths" | "pricing" | "setupCommand">>;
580
585
  /**
581
586
  * Provider information for setup display
582
587
  */
@@ -1075,3 +1080,413 @@ export type SetupResult = {
1075
1080
  responseTime?: number;
1076
1081
  }>;
1077
1082
  };
1083
+ /**
1084
+ * Shared options for every provider-specific CLI setup command
1085
+ * (anthropic, azure, bedrock, gcp, google-ai, openai).
1086
+ */
1087
+ export type ProviderSetupOptions = {
1088
+ checkOnly?: boolean;
1089
+ interactive?: boolean;
1090
+ };
1091
+ /** Shared yargs-argv shape for every provider-specific CLI setup command. */
1092
+ export type ProviderSetupArgv = {
1093
+ check?: boolean;
1094
+ nonInteractive?: boolean;
1095
+ };
1096
+ /**
1097
+ * Superset provider-setup config. `endpoint` is Azure-only; other providers
1098
+ * leave it undefined. Pre-consolidation there were 4 near-duplicate types
1099
+ * (Anthropic/Azure/GoogleAI/OpenAI); they are now one.
1100
+ */
1101
+ export type ProviderSetupConfig = {
1102
+ apiKey?: string;
1103
+ model?: string;
1104
+ endpoint?: string;
1105
+ isReconfiguring?: boolean;
1106
+ };
1107
+ /** Providers supported by the `neurolink auth` command. */
1108
+ export type SupportedProvider = "anthropic";
1109
+ /** Arguments for `neurolink autoresearch init`. */
1110
+ export type AutoresearchInitArgs = {
1111
+ repoPath: string;
1112
+ tag: string;
1113
+ target: string;
1114
+ immutable: string;
1115
+ runCommand: string;
1116
+ metricName: string;
1117
+ metricPattern: string;
1118
+ metricDirection: string;
1119
+ timeout: number;
1120
+ provider?: string;
1121
+ model?: string;
1122
+ };
1123
+ /** Base options shared across all `neurolink evaluate` subcommands. */
1124
+ export type BaseEvaluateArgs = {
1125
+ json?: boolean;
1126
+ verbose?: boolean;
1127
+ format?: "text" | "json" | "table";
1128
+ };
1129
+ /** Arguments for the bare `neurolink evaluate` invocation. */
1130
+ export type DirectEvaluateArgs = BaseEvaluateArgs & {
1131
+ input?: string;
1132
+ query?: string;
1133
+ scorers?: string[];
1134
+ context?: string;
1135
+ threshold?: number;
1136
+ };
1137
+ /** Arguments for `neurolink evaluate run`. */
1138
+ export type EvaluateRunArgs = BaseEvaluateArgs & {
1139
+ input?: string;
1140
+ output?: string;
1141
+ context?: string[];
1142
+ groundTruth?: string;
1143
+ pipeline?: string;
1144
+ scorer?: string[];
1145
+ };
1146
+ /** Arguments for `neurolink evaluate score`. */
1147
+ export type EvaluateScoreArgs = BaseEvaluateArgs & {
1148
+ scorer: string;
1149
+ input?: string;
1150
+ output?: string;
1151
+ context?: string[];
1152
+ groundTruth?: string;
1153
+ };
1154
+ /** Arguments for `neurolink evaluate report`. */
1155
+ export type EvaluateReportArgs = BaseEvaluateArgs & {
1156
+ input?: string;
1157
+ output?: string;
1158
+ context?: string[];
1159
+ groundTruth?: string;
1160
+ "ground-truth"?: string;
1161
+ pipeline?: string;
1162
+ scorer?: string[];
1163
+ outputFile?: string;
1164
+ "output-file"?: string;
1165
+ };
1166
+ /** Arguments for `neurolink evaluate presets`. */
1167
+ export type EvaluatePresetsArgs = {
1168
+ preset?: string;
1169
+ json?: boolean;
1170
+ };
1171
+ /** Arguments for `neurolink evaluate scorers` (list-scorers). */
1172
+ export type EvaluateScorersArgs = {
1173
+ category?: string;
1174
+ type?: string;
1175
+ json?: boolean;
1176
+ detailed?: boolean;
1177
+ };
1178
+ /** Arguments for `neurolink evaluate run-pipeline`. */
1179
+ export type RunPipelineArgs = BaseEvaluateArgs & {
1180
+ preset: string;
1181
+ input: string;
1182
+ query?: string;
1183
+ context?: string;
1184
+ threshold?: number;
1185
+ };
1186
+ /** Info row for an MCP tool annotation. */
1187
+ export type ToolAnnotationInfo = {
1188
+ serverName: string;
1189
+ serverId: string;
1190
+ toolName: string;
1191
+ description: string;
1192
+ annotations: import("./mcp.js").MCPToolAnnotations;
1193
+ };
1194
+ /** Tool target used by the annotation printer. */
1195
+ export type AnnotatedToolTarget = {
1196
+ name: string;
1197
+ description: string;
1198
+ serverId: string;
1199
+ serverName: string;
1200
+ };
1201
+ /** Arguments for `neurolink rag chunk`. */
1202
+ export type RagChunkArgs = import("./rag.js").RAGCommandArgs & {
1203
+ file: string;
1204
+ output?: string;
1205
+ extract?: boolean;
1206
+ };
1207
+ /** Arguments for `neurolink rag index`. */
1208
+ export type RagIndexArgs = import("./rag.js").RAGCommandArgs & {
1209
+ file: string;
1210
+ indexName?: string;
1211
+ };
1212
+ /** Arguments for `neurolink rag query`. */
1213
+ export type RagQueryArgs = import("./rag.js").RAGCommandArgs & {
1214
+ query: string;
1215
+ indexName?: string;
1216
+ };
1217
+ /** Minimal server instance contract used by `neurolink serve`. */
1218
+ export type ServerInstance = {
1219
+ initialize: () => Promise<void>;
1220
+ start: () => Promise<void>;
1221
+ stop: () => Promise<void>;
1222
+ registerRouteGroup: (group: import("./server.js").RouteGroup) => void;
1223
+ listRoutes?: () => import("./server.js").RouteDefinition[];
1224
+ };
1225
+ /** Persisted state for a running `neurolink serve` process. */
1226
+ export type ServeState = {
1227
+ pid: number;
1228
+ port: number;
1229
+ host: string;
1230
+ framework: string;
1231
+ startTime: string;
1232
+ basePath: string;
1233
+ configFile?: string;
1234
+ };
1235
+ /** Captured Bedrock setup configuration data. */
1236
+ export type BedrockConfigData = {
1237
+ accessKeyId?: string;
1238
+ secretAccessKey?: string;
1239
+ region?: string;
1240
+ model?: string;
1241
+ };
1242
+ /** Status of Bedrock setup configuration flags. */
1243
+ export type BedrockConfigStatus = {
1244
+ hasAccessKey: boolean;
1245
+ hasSecretKey: boolean;
1246
+ hasRegion: boolean;
1247
+ };
1248
+ /** Status of each GCP auth method tried by setup-gcp. */
1249
+ export type GcpAuthMethodStatus = {
1250
+ method1: {
1251
+ complete: boolean;
1252
+ hasCredentials: boolean;
1253
+ missingVars: string[];
1254
+ };
1255
+ method2: {
1256
+ complete: boolean;
1257
+ hasServiceAccountKey: boolean;
1258
+ missingVars: string[];
1259
+ };
1260
+ method3: {
1261
+ complete: boolean;
1262
+ hasClientEmail: boolean;
1263
+ hasPrivateKey: boolean;
1264
+ missingVars: string[];
1265
+ };
1266
+ common: {
1267
+ hasProject: boolean;
1268
+ hasLocation: boolean;
1269
+ missingVars: string[];
1270
+ };
1271
+ };
1272
+ /** Arguments for `neurolink setup huggingface`. */
1273
+ export type SetupHuggingFaceArgs = {
1274
+ check?: boolean;
1275
+ "non-interactive"?: boolean;
1276
+ };
1277
+ /** Arguments for `neurolink setup mistral`. */
1278
+ export type SetupMistralArgs = {
1279
+ check?: boolean;
1280
+ "non-interactive"?: boolean;
1281
+ };
1282
+ /** Arguments for `neurolink task create`. */
1283
+ export type TaskCreateArgs = {
1284
+ name: string;
1285
+ prompt: string;
1286
+ cron?: string;
1287
+ timezone?: string;
1288
+ every?: string;
1289
+ at?: string;
1290
+ mode: string;
1291
+ provider?: string;
1292
+ model?: string;
1293
+ maxRuns?: number;
1294
+ maxTokens?: number;
1295
+ temperature?: number;
1296
+ systemPrompt?: string;
1297
+ };
1298
+ /** Arguments for `neurolink task update`. */
1299
+ export type TaskUpdateArgs = {
1300
+ taskId: string;
1301
+ prompt?: string;
1302
+ cron?: string;
1303
+ every?: string;
1304
+ at?: string;
1305
+ mode?: string;
1306
+ };
1307
+ /** Arguments for `neurolink task logs`. */
1308
+ export type TaskLogsArgs = {
1309
+ taskId: string;
1310
+ limit: number;
1311
+ status?: string;
1312
+ full?: boolean;
1313
+ };
1314
+ /** Arguments for `neurolink voice-server`. */
1315
+ export type VoiceServerArgs = {
1316
+ port: number;
1317
+ };
1318
+ /** Provider config row used by the interactive setup wizard. */
1319
+ export type InteractiveProviderConfig = {
1320
+ id: AIProviderName;
1321
+ name: string;
1322
+ description: string;
1323
+ envVars: Array<{
1324
+ key: string;
1325
+ prompt: string;
1326
+ secure?: boolean;
1327
+ default?: string;
1328
+ optional?: boolean;
1329
+ }>;
1330
+ };
1331
+ /** Result of saving video to file. */
1332
+ export type VideoSaveResult = {
1333
+ success: boolean;
1334
+ path: string;
1335
+ size: number;
1336
+ error?: string;
1337
+ };
1338
+ /** Provider identifier recognized by the `neurolink config` command. */
1339
+ export type CliConfigProvider = "auto" | "openai" | "bedrock" | "vertex" | "anthropic" | "azure" | "google-ai" | "huggingface" | "ollama" | "mistral";
1340
+ /** Analytics config for the healthcare evaluation domain. */
1341
+ export type CliHealthcareAnalyticsConfig = {
1342
+ trackPatientData: boolean;
1343
+ trackDiagnosticAccuracy: boolean;
1344
+ trackTreatmentOutcomes: boolean;
1345
+ };
1346
+ /** Analytics config for the analytics evaluation domain. */
1347
+ export type CliAnalyticsDomainAnalyticsConfig = {
1348
+ trackDataQuality: boolean;
1349
+ trackModelPerformance: boolean;
1350
+ trackBusinessImpact: boolean;
1351
+ };
1352
+ /** Analytics config for the finance evaluation domain. */
1353
+ export type CliFinanceAnalyticsConfig = {
1354
+ trackRiskMetrics: boolean;
1355
+ trackRegulatory: boolean;
1356
+ trackPortfolioImpact: boolean;
1357
+ };
1358
+ /** Analytics config for the ecommerce evaluation domain. */
1359
+ export type CliEcommerceAnalyticsConfig = {
1360
+ trackConversions: boolean;
1361
+ trackUserBehavior: boolean;
1362
+ trackRevenueImpact: boolean;
1363
+ };
1364
+ /** Generic shape of a single domain entry in the CLI config. */
1365
+ export type CliDomainConfig<TAnalytics extends Record<string, boolean> = Record<string, boolean>> = {
1366
+ evaluationCriteria: string[];
1367
+ analyticsConfig: TAnalytics;
1368
+ };
1369
+ /**
1370
+ * Materialized shape of the CLI config parsed from `~/.neurolink/config.json`.
1371
+ * Matches the output of `ConfigSchema.parse()` defined in
1372
+ * `src/cli/commands/config.ts`. The schema is annotated with
1373
+ * `z.ZodType<CliNeuroLinkConfig>` so drift fails at compile time.
1374
+ */
1375
+ export type CliNeuroLinkConfig = {
1376
+ defaultProvider: CliConfigProvider;
1377
+ providers: {
1378
+ openai?: {
1379
+ apiKey?: string;
1380
+ model: string;
1381
+ baseURL?: string;
1382
+ };
1383
+ bedrock?: {
1384
+ region?: string;
1385
+ accessKeyId?: string;
1386
+ secretAccessKey?: string;
1387
+ sessionToken?: string;
1388
+ model: string;
1389
+ };
1390
+ vertex?: {
1391
+ projectId?: string;
1392
+ location: string;
1393
+ credentials?: string;
1394
+ serviceAccountKey?: string;
1395
+ clientEmail?: string;
1396
+ privateKey?: string;
1397
+ model: string;
1398
+ };
1399
+ anthropic?: {
1400
+ apiKey?: string;
1401
+ model: string;
1402
+ };
1403
+ azure?: {
1404
+ apiKey?: string;
1405
+ endpoint?: string;
1406
+ deploymentId?: string;
1407
+ model: string;
1408
+ };
1409
+ "google-ai"?: {
1410
+ apiKey?: string;
1411
+ model: string;
1412
+ };
1413
+ huggingface?: {
1414
+ apiKey?: string;
1415
+ model: string;
1416
+ };
1417
+ ollama?: {
1418
+ baseUrl: string;
1419
+ model: string;
1420
+ timeout: number;
1421
+ };
1422
+ mistral?: {
1423
+ apiKey?: string;
1424
+ model: string;
1425
+ };
1426
+ };
1427
+ profiles: Record<string, unknown>;
1428
+ preferences: {
1429
+ outputFormat: "text" | "json" | "yaml";
1430
+ temperature: number;
1431
+ maxTokens?: number;
1432
+ enableLogging: boolean;
1433
+ enableCaching: boolean;
1434
+ cacheStrategy: "memory" | "file" | "redis";
1435
+ defaultEvaluationDomain?: string;
1436
+ enableAnalyticsByDefault: boolean;
1437
+ enableEvaluationByDefault: boolean;
1438
+ };
1439
+ domains: {
1440
+ healthcare: CliDomainConfig<CliHealthcareAnalyticsConfig>;
1441
+ analytics: CliDomainConfig<CliAnalyticsDomainAnalyticsConfig>;
1442
+ finance: CliDomainConfig<CliFinanceAnalyticsConfig>;
1443
+ ecommerce: CliDomainConfig<CliEcommerceAnalyticsConfig>;
1444
+ };
1445
+ };
1446
+ /** Row in the MCP tools listing produced by `neurolink mcp tools`. */
1447
+ export type MCPToolWithServer = {
1448
+ name: string;
1449
+ description: string;
1450
+ serverId: string;
1451
+ serverName: string;
1452
+ inputSchema?: object;
1453
+ category?: string;
1454
+ annotations?: {
1455
+ readOnlyHint?: boolean;
1456
+ destructiveHint?: boolean;
1457
+ idempotentHint?: boolean;
1458
+ requiresConfirmation?: boolean;
1459
+ tags?: string[];
1460
+ };
1461
+ };
1462
+ /** Per-server discovery result produced by `neurolink mcp discover`. */
1463
+ export type MCPDiscoveryResult = {
1464
+ serverId: string;
1465
+ serverName: string;
1466
+ toolCount: number;
1467
+ tools: Array<{
1468
+ name: string;
1469
+ description: string;
1470
+ annotations: Record<string, unknown>;
1471
+ }>;
1472
+ };
1473
+ /**
1474
+ * Minimal route-group shape reflected at runtime by `neurolink serve routes`.
1475
+ * Named with a `CliServe` prefix to disambiguate from the richer RouteGroup
1476
+ * in server.ts (§Rule 9).
1477
+ */
1478
+ export type CliServeRouteGroup = {
1479
+ prefix: string;
1480
+ routes: Array<{
1481
+ method: string;
1482
+ path: string;
1483
+ description?: string;
1484
+ }>;
1485
+ };
1486
+ /** Flat per-route row used by the `neurolink serve routes` listing. */
1487
+ export type CliServeFlatRoute = {
1488
+ method: string;
1489
+ path: string;
1490
+ description?: string;
1491
+ group: string;
1492
+ };
@@ -1251,3 +1251,37 @@ export type ClientWebSocketConfig = WSClientConfig;
1251
1251
  export type ClientWebSocketMessage = WSClientMessage;
1252
1252
  /** @see WSClientEventHandlers */
1253
1253
  export type WebSocketEventHandlers = WSClientEventHandlers;
1254
+ /**
1255
+ * Superset internal config for SSE and WebSocket client wrappers.
1256
+ * The 9 shared fields are required. Protocol-specific fields
1257
+ * (useNativeEventSource for SSE; heartbeatInterval/queueSize for WS)
1258
+ * are optional — each client populates only its own fields.
1259
+ */
1260
+ export type ClientInternalConfig = {
1261
+ baseUrl: string;
1262
+ apiKey: string;
1263
+ token: string;
1264
+ timeout: number;
1265
+ headers: Record<string, string>;
1266
+ autoReconnect: boolean;
1267
+ maxReconnectAttempts: number;
1268
+ reconnectDelay: number;
1269
+ maxReconnectDelay: number;
1270
+ useNativeEventSource?: boolean;
1271
+ heartbeatInterval?: number;
1272
+ queueSize?: number;
1273
+ };
1274
+ /**
1275
+ * Internal stream chunk format used by the AI-SDK adapter's push/pull queue.
1276
+ * Distinct from the public NeuroLink `StreamChunk` (stream.ts) — this one
1277
+ * mirrors the underlying `ai` package event shape (text-delta / finish).
1278
+ */
1279
+ export type AiSdkStreamChunk = {
1280
+ type: "text-delta" | "finish";
1281
+ textDelta?: string;
1282
+ finishReason?: string;
1283
+ usage?: {
1284
+ promptTokens: number;
1285
+ completionTokens: number;
1286
+ };
1287
+ };