@juspay/neurolink 9.54.6 → 9.54.7

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 +2 -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 +353 -353
  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 +82 -0
  184. package/dist/lib/providers/googleVertex.js +52 -0
  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 +82 -0
  310. package/dist/providers/googleVertex.js +52 -0
  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 -1
@@ -5,126 +5,7 @@
5
5
  * Enhanced configuration system with interactive setup,
6
6
  * multi-profile support, and smart validation.
7
7
  */
8
- import { z } from "zod";
9
- declare const ConfigSchema: z.ZodObject<{
10
- defaultProvider: z.ZodDefault<z.ZodEnum<{
11
- bedrock: "bedrock";
12
- openai: "openai";
13
- vertex: "vertex";
14
- anthropic: "anthropic";
15
- azure: "azure";
16
- "google-ai": "google-ai";
17
- huggingface: "huggingface";
18
- ollama: "ollama";
19
- mistral: "mistral";
20
- auto: "auto";
21
- }>>;
22
- providers: z.ZodDefault<z.ZodObject<{
23
- openai: z.ZodOptional<z.ZodObject<{
24
- apiKey: z.ZodOptional<z.ZodString>;
25
- model: z.ZodDefault<z.ZodString>;
26
- baseURL: z.ZodOptional<z.ZodString>;
27
- }, z.core.$strip>>;
28
- bedrock: z.ZodOptional<z.ZodObject<{
29
- region: z.ZodOptional<z.ZodString>;
30
- accessKeyId: z.ZodOptional<z.ZodString>;
31
- secretAccessKey: z.ZodOptional<z.ZodString>;
32
- sessionToken: z.ZodOptional<z.ZodString>;
33
- model: z.ZodDefault<z.ZodString>;
34
- }, z.core.$strip>>;
35
- vertex: z.ZodOptional<z.ZodObject<{
36
- projectId: z.ZodOptional<z.ZodString>;
37
- location: z.ZodDefault<z.ZodString>;
38
- credentials: z.ZodOptional<z.ZodString>;
39
- serviceAccountKey: z.ZodOptional<z.ZodString>;
40
- clientEmail: z.ZodOptional<z.ZodString>;
41
- privateKey: z.ZodOptional<z.ZodString>;
42
- model: z.ZodDefault<z.ZodString>;
43
- }, z.core.$strip>>;
44
- anthropic: z.ZodOptional<z.ZodObject<{
45
- apiKey: z.ZodOptional<z.ZodString>;
46
- model: z.ZodDefault<z.ZodString>;
47
- }, z.core.$strip>>;
48
- azure: z.ZodOptional<z.ZodObject<{
49
- apiKey: z.ZodOptional<z.ZodString>;
50
- endpoint: z.ZodOptional<z.ZodString>;
51
- deploymentId: z.ZodOptional<z.ZodString>;
52
- model: z.ZodDefault<z.ZodString>;
53
- }, z.core.$strip>>;
54
- "google-ai": z.ZodOptional<z.ZodObject<{
55
- apiKey: z.ZodOptional<z.ZodString>;
56
- model: z.ZodDefault<z.ZodString>;
57
- }, z.core.$strip>>;
58
- huggingface: z.ZodOptional<z.ZodObject<{
59
- apiKey: z.ZodOptional<z.ZodString>;
60
- model: z.ZodDefault<z.ZodString>;
61
- }, z.core.$strip>>;
62
- ollama: z.ZodOptional<z.ZodObject<{
63
- baseUrl: z.ZodDefault<z.ZodString>;
64
- model: z.ZodDefault<z.ZodString>;
65
- timeout: z.ZodDefault<z.ZodNumber>;
66
- }, z.core.$strip>>;
67
- mistral: z.ZodOptional<z.ZodObject<{
68
- apiKey: z.ZodOptional<z.ZodString>;
69
- model: z.ZodDefault<z.ZodString>;
70
- }, z.core.$strip>>;
71
- }, z.core.$strip>>;
72
- profiles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
73
- preferences: z.ZodDefault<z.ZodObject<{
74
- outputFormat: z.ZodDefault<z.ZodEnum<{
75
- text: "text";
76
- json: "json";
77
- yaml: "yaml";
78
- }>>;
79
- temperature: z.ZodDefault<z.ZodNumber>;
80
- maxTokens: z.ZodOptional<z.ZodNumber>;
81
- enableLogging: z.ZodDefault<z.ZodBoolean>;
82
- enableCaching: z.ZodDefault<z.ZodBoolean>;
83
- cacheStrategy: z.ZodDefault<z.ZodEnum<{
84
- file: "file";
85
- redis: "redis";
86
- memory: "memory";
87
- }>>;
88
- defaultEvaluationDomain: z.ZodOptional<z.ZodString>;
89
- enableAnalyticsByDefault: z.ZodDefault<z.ZodBoolean>;
90
- enableEvaluationByDefault: z.ZodDefault<z.ZodBoolean>;
91
- }, z.core.$strip>>;
92
- domains: z.ZodDefault<z.ZodObject<{
93
- healthcare: z.ZodDefault<z.ZodObject<{
94
- evaluationCriteria: z.ZodDefault<z.ZodArray<z.ZodString>>;
95
- analyticsConfig: z.ZodDefault<z.ZodObject<{
96
- trackPatientData: z.ZodDefault<z.ZodBoolean>;
97
- trackDiagnosticAccuracy: z.ZodDefault<z.ZodBoolean>;
98
- trackTreatmentOutcomes: z.ZodDefault<z.ZodBoolean>;
99
- }, z.core.$strip>>;
100
- }, z.core.$strip>>;
101
- analytics: z.ZodDefault<z.ZodObject<{
102
- evaluationCriteria: z.ZodDefault<z.ZodArray<z.ZodString>>;
103
- analyticsConfig: z.ZodDefault<z.ZodObject<{
104
- trackDataQuality: z.ZodDefault<z.ZodBoolean>;
105
- trackModelPerformance: z.ZodDefault<z.ZodBoolean>;
106
- trackBusinessImpact: z.ZodDefault<z.ZodBoolean>;
107
- }, z.core.$strip>>;
108
- }, z.core.$strip>>;
109
- finance: z.ZodDefault<z.ZodObject<{
110
- evaluationCriteria: z.ZodDefault<z.ZodArray<z.ZodString>>;
111
- analyticsConfig: z.ZodDefault<z.ZodObject<{
112
- trackRiskMetrics: z.ZodDefault<z.ZodBoolean>;
113
- trackRegulatory: z.ZodDefault<z.ZodBoolean>;
114
- trackPortfolioImpact: z.ZodDefault<z.ZodBoolean>;
115
- }, z.core.$strip>>;
116
- }, z.core.$strip>>;
117
- ecommerce: z.ZodDefault<z.ZodObject<{
118
- evaluationCriteria: z.ZodDefault<z.ZodArray<z.ZodString>>;
119
- analyticsConfig: z.ZodDefault<z.ZodObject<{
120
- trackConversions: z.ZodDefault<z.ZodBoolean>;
121
- trackUserBehavior: z.ZodDefault<z.ZodBoolean>;
122
- trackRevenueImpact: z.ZodDefault<z.ZodBoolean>;
123
- }, z.core.$strip>>;
124
- }, z.core.$strip>>;
125
- }, z.core.$strip>>;
126
- }, z.core.$strip>;
127
- type NeuroLinkConfig = z.infer<typeof ConfigSchema>;
8
+ import { type CliNeuroLinkConfig } from "../../lib/types/index.js";
128
9
  export declare class ConfigManager {
129
10
  private configDir;
130
11
  private configFile;
@@ -189,11 +70,11 @@ export declare class ConfigManager {
189
70
  /**
190
71
  * Get current configuration
191
72
  */
192
- getConfig(): NeuroLinkConfig;
73
+ getConfig(): CliNeuroLinkConfig;
193
74
  /**
194
75
  * Update configuration
195
76
  */
196
- updateConfig(updates: Partial<NeuroLinkConfig>): void;
77
+ updateConfig(updates: Partial<CliNeuroLinkConfig>): void;
197
78
  /**
198
79
  * Show current configuration
199
80
  */
@@ -211,4 +92,3 @@ export declare class ConfigManager {
211
92
  resetConfig(): void;
212
93
  }
213
94
  export declare const configManager: ConfigManager;
214
- export {};
@@ -14,8 +14,10 @@ import { z } from "zod";
14
14
  import { CLI_LIMITS } from "../../lib/core/constants.js";
15
15
  import { logger } from "../../lib/utils/logger.js";
16
16
  import { getTopModelChoices } from "../../lib/utils/modelChoices.js";
17
- import { AIProviderName } from "../../lib/types/index.js";
18
- // Configuration schema for validation
17
+ import { AIProviderName, } from "../../lib/types/index.js";
18
+ // Configuration schema for validation. Annotated with
19
+ // z.ZodType<CliNeuroLinkConfig> so drift between the canonical structural
20
+ // type in src/lib/types/cli.ts and this runtime schema fails at compile time.
19
21
  const ConfigSchema = z.object({
20
22
  defaultProvider: z
21
23
  .enum([
@@ -6,24 +6,7 @@
6
6
  * Supports subcommands: run, score, report, presets, scorers (list-scorers)
7
7
  */
8
8
  import type { CommandModule } from "yargs";
9
- /**
10
- * Base evaluate command arguments
11
- */
12
- type BaseEvaluateArgs = {
13
- json?: boolean;
14
- verbose?: boolean;
15
- format?: "text" | "json" | "table";
16
- };
17
- /**
18
- * Direct evaluate command arguments (main command)
19
- */
20
- type DirectEvaluateArgs = BaseEvaluateArgs & {
21
- input?: string;
22
- query?: string;
23
- scorers?: string[];
24
- context?: string;
25
- threshold?: number;
26
- };
9
+ import type { DirectEvaluateArgs } from "../../lib/types/index.js";
27
10
  /**
28
11
  * Main evaluate command with subcommands
29
12
  */
@@ -45,4 +28,3 @@ export declare class EvaluateCommandFactory {
45
28
  */
46
29
  static listPipelines(): void;
47
30
  }
48
- export {};
@@ -10,7 +10,7 @@
10
10
  * (generate/stream), with an optional ModelRouter for model remapping.
11
11
  */
12
12
  import type { CommandModule } from "yargs";
13
- import type { ProxyStartArgs, ProxyStatusArgs, ProxyGuardArgs, ProxyTelemetryArgs } from "../../lib/types/index.js";
13
+ import type { ProxyGuardArgs, ProxyStartArgs, ProxyStatusArgs, ProxyTelemetryArgs } from "../../lib/types/index.js";
14
14
  export declare function mapClaudeErrorTypeToStatus(errorType?: string): number;
15
15
  export declare const proxyStartCommand: CommandModule<object, ProxyStartArgs>;
16
16
  export declare const proxyStatusCommand: CommandModule<object, ProxyStatusArgs>;
@@ -1131,6 +1131,9 @@ export const proxyStartCommand = {
1131
1131
  await startProxyCommandHandler(argv);
1132
1132
  },
1133
1133
  };
1134
+ // =============================================================================
1135
+ // STATUS DISPLAY HELPERS
1136
+ // =============================================================================
1134
1137
  function printStatusStats(stats) {
1135
1138
  console.info(`\n Stats:`);
1136
1139
  if (stats.totalAttempts !== undefined) {
@@ -167,6 +167,9 @@ async function getEmbeddingModel(provider, model) {
167
167
  logger.warn(`No default embedding model for provider ${resolvedProvider}, falling back to OpenAI text-embedding-3-small`);
168
168
  return { provider: "openai", model: "text-embedding-3-small" };
169
169
  }
170
+ /**
171
+ * Chunk subcommand arguments
172
+ */
170
173
  /**
171
174
  * In-memory storage for indexed documents
172
175
  * In production, this would be persisted to a vector database
@@ -8,9 +8,5 @@
8
8
  *
9
9
  * Follows the same UX patterns as setup-openai and setup-google-ai
10
10
  */
11
- type AnthropicSetupArgv = {
12
- check?: boolean;
13
- nonInteractive?: boolean;
14
- };
15
- export declare function handleAnthropicSetup(argv: AnthropicSetupArgv): Promise<void>;
16
- export {};
11
+ import { type ProviderSetupArgv } from "../../lib/types/index.js";
12
+ export declare function handleAnthropicSetup(argv: ProviderSetupArgv): Promise<void>;
@@ -15,7 +15,7 @@ import chalk from "chalk";
15
15
  import ora from "ora";
16
16
  import { logger } from "../../lib/utils/logger.js";
17
17
  import { getTopModelChoices } from "../../lib/utils/modelChoices.js";
18
- import { AIProviderName } from "../../lib/types/index.js";
18
+ import { AIProviderName, } from "../../lib/types/index.js";
19
19
  import { maskCredential } from "../utils/maskCredential.js";
20
20
  export async function handleAnthropicSetup(argv) {
21
21
  try {
@@ -9,9 +9,5 @@
9
9
  *
10
10
  * Follows the same UX patterns as other setup commands
11
11
  */
12
- type AzureSetupArgv = {
13
- check?: boolean;
14
- nonInteractive?: boolean;
15
- };
16
- export declare function handleAzureSetup(argv: AzureSetupArgv): Promise<void>;
17
- export {};
12
+ import { type ProviderSetupArgv } from "../../lib/types/index.js";
13
+ export declare function handleAzureSetup(argv: ProviderSetupArgv): Promise<void>;
@@ -15,7 +15,7 @@ import ora from "ora";
15
15
  import { logger } from "../../lib/utils/logger.js";
16
16
  import { updateEnvFile as updateEnvFileShared, displayEnvUpdateSummary, } from "../utils/envManager.js";
17
17
  import { getTopModelChoices } from "../../lib/utils/modelChoices.js";
18
- import { AIProviderName } from "../../lib/types/index.js";
18
+ import { AIProviderName, } from "../../lib/types/index.js";
19
19
  import { maskCredential } from "../utils/maskCredential.js";
20
20
  export async function handleAzureSetup(argv) {
21
21
  try {
@@ -5,9 +5,5 @@
5
5
  * Checks for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
6
6
  * Auto-detects AWS CLI configuration, prompts for missing config, updates .env safely
7
7
  */
8
- type BedrockSetupArgv = {
9
- check?: boolean;
10
- nonInteractive?: boolean;
11
- };
12
- export declare function handleBedrockSetup(argv: BedrockSetupArgv): Promise<void>;
13
- export {};
8
+ import { type ProviderSetupArgv } from "../../lib/types/index.js";
9
+ export declare function handleBedrockSetup(argv: ProviderSetupArgv): Promise<void>;
@@ -14,7 +14,7 @@ import ora from "ora";
14
14
  import { logger } from "../../lib/utils/logger.js";
15
15
  import { updateEnvFile as envUpdate } from "../utils/envManager.js";
16
16
  import { getTopModelChoices } from "../../lib/utils/modelChoices.js";
17
- import { AIProviderName } from "../../lib/types/index.js";
17
+ import { AIProviderName, } from "../../lib/types/index.js";
18
18
  import { maskCredential } from "../utils/maskCredential.js";
19
19
  export async function handleBedrockSetup(argv) {
20
20
  try {
@@ -10,9 +10,5 @@
10
10
  * All methods require GOOGLE_VERTEX_PROJECT
11
11
  * Optional: GOOGLE_VERTEX_LOCATION (defaults to 'us-central1')
12
12
  */
13
- type GCPSetupArgv = {
14
- check?: boolean;
15
- nonInteractive?: boolean;
16
- };
17
- export declare function handleGCPSetup(argv: GCPSetupArgv): Promise<void>;
18
- export {};
13
+ import type { ProviderSetupArgv } from "../../lib/types/index.js";
14
+ export declare function handleGCPSetup(argv: ProviderSetupArgv): Promise<void>;
@@ -8,9 +8,5 @@
8
8
  *
9
9
  * Follows the same UX patterns as setup-openai and setup-gcp
10
10
  */
11
- type GoogleAISetupArgv = {
12
- check?: boolean;
13
- nonInteractive?: boolean;
14
- };
15
- export declare function handleGoogleAISetup(argv: GoogleAISetupArgv): Promise<void>;
16
- export {};
11
+ import { type ProviderSetupArgv } from "../../lib/types/index.js";
12
+ export declare function handleGoogleAISetup(argv: ProviderSetupArgv): Promise<void>;
@@ -16,7 +16,7 @@ import { logger } from "../../lib/utils/logger.js";
16
16
  import { GoogleAIModels } from "../../lib/constants/enums.js";
17
17
  import { updateEnvFile as updateEnvFileManager, displayEnvUpdateSummary, } from "../utils/envManager.js";
18
18
  import { getTopModelChoices } from "../../lib/utils/modelChoices.js";
19
- import { AIProviderName } from "../../lib/types/index.js";
19
+ import { AIProviderName, } from "../../lib/types/index.js";
20
20
  import { maskCredential } from "../utils/maskCredential.js";
21
21
  /**
22
22
  * Get the runtime default model that matches the provider implementation
@@ -1,8 +1,4 @@
1
1
  import type { Arguments, CommandBuilder } from "yargs";
2
- type SetupHuggingFaceArgs = {
3
- check?: boolean;
4
- "non-interactive"?: boolean;
5
- };
2
+ import type { SetupHuggingFaceArgs } from "../../lib/types/index.js";
6
3
  export declare const handleHuggingFaceSetup: (argv: Arguments<SetupHuggingFaceArgs>) => Promise<void>;
7
4
  export declare const setupHuggingFaceBuilder: CommandBuilder;
8
- export {};
@@ -1,8 +1,4 @@
1
1
  import type { Arguments, CommandBuilder } from "yargs";
2
- type SetupMistralArgs = {
3
- check?: boolean;
4
- "non-interactive"?: boolean;
5
- };
2
+ import type { SetupMistralArgs } from "../../lib/types/index.js";
6
3
  export declare const handleMistralSetup: (argv: Arguments<SetupMistralArgs>) => Promise<void>;
7
4
  export declare const setupMistralBuilder: CommandBuilder;
8
- export {};
@@ -8,9 +8,5 @@
8
8
  *
9
9
  * Follows the same UX patterns as setup-gcp and setup-bedrock
10
10
  */
11
- type OpenAISetupArgv = {
12
- check?: boolean;
13
- nonInteractive?: boolean;
14
- };
15
- export declare function handleOpenAISetup(argv: OpenAISetupArgv): Promise<void>;
16
- export {};
11
+ import { type ProviderSetupArgv } from "../../lib/types/index.js";
12
+ export declare function handleOpenAISetup(argv: ProviderSetupArgv): Promise<void>;
@@ -15,7 +15,7 @@ import chalk from "chalk";
15
15
  import ora from "ora";
16
16
  import { logger } from "../../lib/utils/logger.js";
17
17
  import { getTopModelChoices } from "../../lib/utils/modelChoices.js";
18
- import { AIProviderName } from "../../lib/types/index.js";
18
+ import { AIProviderName, } from "../../lib/types/index.js";
19
19
  import { maskCredential } from "../utils/maskCredential.js";
20
20
  export async function handleOpenAISetup(argv) {
21
21
  try {
@@ -5,15 +5,8 @@
5
5
  * Provides a beautiful welcome experience for new users and guided
6
6
  * provider selection, while delegating to existing setup commands.
7
7
  */
8
- type SetupArgs = {
9
- provider?: string;
10
- list?: boolean;
11
- status?: boolean;
12
- interactive?: boolean;
13
- help?: boolean;
14
- };
8
+ import type { SetupArgs } from "../../lib/types/index.js";
15
9
  /**
16
10
  * Main setup command handler
17
11
  */
18
12
  export declare function handleSetup(argv: SetupArgs): Promise<void>;
19
- export {};
@@ -864,4 +864,5 @@ function formatDuration(ms) {
864
864
  }
865
865
  return `${ms / 86_400_000}d`;
866
866
  }
867
+ // ── Arg Types ───────────────────────────────────────────
867
868
  //# sourceMappingURL=task.js.map
@@ -1,6 +1,3 @@
1
1
  import type { CommandModule } from "yargs";
2
- type VoiceServerArgs = {
3
- port: number;
4
- };
2
+ import type { VoiceServerArgs } from "../../lib/types/index.js";
5
3
  export declare const voiceServerCommand: CommandModule<object, VoiceServerArgs>;
6
- export {};
@@ -5,6 +5,8 @@ import { NeuroLink } from "../../lib/neurolink.js";
5
5
  import { globalSession } from "../../lib/session/globalSessionState.js";
6
6
  import { logger } from "../../lib/utils/logger.js";
7
7
  import { displayConversationPreview, displaySessionMessage, getConversationPreview, loadCommandHistory, parseValue, restoreSessionVariables, saveCommandToHistory, verifyConversationContext, } from "../../lib/utils/loopUtils.js";
8
+ import { SpanStatusCode } from "@opentelemetry/api";
9
+ import { tracers } from "../../lib/telemetry/tracers.js";
8
10
  import { handleError } from "../errorHandler.js";
9
11
  import { ConversationSelector } from "./conversationSelector.js";
10
12
  import { textGenerationOptionsSchema } from "./optionsSchema.js";
@@ -108,19 +110,38 @@ export class LoopSession {
108
110
  // Default: treat as stream command with array format
109
111
  processedCommand = ["stream", command];
110
112
  }
111
- // Execute the command
113
+ // Execute the command within an OTel span for per-turn visibility.
112
114
  // The .fail() handler in cli.ts is now session-aware and will
113
115
  // handle all parsing and validation errors without exiting the loop.
114
116
  // We create a fresh instance for each command to prevent state pollution.
115
- const yargsInstance = this.initializeCliParser();
116
- await yargsInstance
117
- .scriptName("")
118
- .fail((msg, err) => {
119
- // Re-throw the error to be caught by the outer catch block
120
- throw err || new Error(msg);
121
- })
122
- .exitProcess(false)
123
- .parse(processedCommand);
117
+ await tracers.sdk.startActiveSpan("neurolink.cli.turn", async (turnSpan) => {
118
+ try {
119
+ turnSpan.setAttribute("cli.command", typeof processedCommand === "string"
120
+ ? processedCommand.slice(0, 100)
121
+ : (processedCommand[0] ?? "unknown"));
122
+ turnSpan.setAttribute("cli.session_id", this.sessionId ?? "none");
123
+ const yargsInstance = this.initializeCliParser();
124
+ await yargsInstance
125
+ .scriptName("")
126
+ .fail((msg, err) => {
127
+ throw err || new Error(msg);
128
+ })
129
+ .exitProcess(false)
130
+ .parse(processedCommand);
131
+ }
132
+ catch (e) {
133
+ const err = e instanceof Error ? e : new Error(String(e));
134
+ turnSpan.recordException(err);
135
+ turnSpan.setStatus({
136
+ code: SpanStatusCode.ERROR,
137
+ message: err.message,
138
+ });
139
+ throw e;
140
+ }
141
+ finally {
142
+ turnSpan.end();
143
+ }
144
+ });
124
145
  // Check context budget after each generation command
125
146
  await this.checkContextBudgetWarning();
126
147
  }
@@ -5,20 +5,8 @@
5
5
  * credential collection, testing, and environment file management.
6
6
  */
7
7
  import { AIProviderName } from "../../lib/constants/enums.js";
8
- import type { SetupResult } from "../../lib/types/index.js";
9
- type ProviderConfig = {
10
- id: AIProviderName;
11
- name: string;
12
- description: string;
13
- envVars: Array<{
14
- key: string;
15
- prompt: string;
16
- secure?: boolean;
17
- default?: string;
18
- optional?: boolean;
19
- }>;
20
- };
21
- export declare const PROVIDER_CONFIGS: ProviderConfig[];
8
+ import type { InteractiveProviderConfig, SetupResult } from "../../lib/types/index.js";
9
+ export declare const PROVIDER_CONFIGS: InteractiveProviderConfig[];
22
10
  /**
23
11
  * Run the interactive setup wizard
24
12
  */
@@ -36,4 +24,3 @@ export declare function testProviderConnectivity(providers: AIProviderName[], qu
36
24
  * Display setup summary
37
25
  */
38
26
  export declare function displaySetupSummary(result: SetupResult, quiet?: boolean): void;
39
- export {};
@@ -7,20 +7,7 @@
7
7
  *
8
8
  * @module cli/utils/videoFileUtils
9
9
  */
10
- import type { VideoGenerationResult } from "../../lib/types/index.js";
11
- /**
12
- * Result of saving video to file
13
- */
14
- type VideoSaveResult = {
15
- /** Whether the save was successful */
16
- success: boolean;
17
- /** Full path to the saved file */
18
- path: string;
19
- /** File size in bytes */
20
- size: number;
21
- /** Error message if failed */
22
- error?: string;
23
- };
10
+ import type { VideoGenerationResult, VideoSaveResult } from "../../lib/types/index.js";
24
11
  /**
25
12
  * Format file size in human-readable format
26
13
  *
@@ -109,4 +96,3 @@ export declare function isVideoGenerationResult(obj: unknown): obj is VideoGener
109
96
  * @returns Formatted metadata summary string
110
97
  */
111
98
  export declare function getVideoMetadataSummary(video: VideoGenerationResult): string;
112
- export {};
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @module @neurolink/ai-sdk
9
9
  */
10
- import type { ClientLanguageModel, ClientLanguageModelCallOptions, ClientLanguageModelResponse, ClientLanguageModelStreamResponse, NeuroLinkProviderOptions, ClientModelOptions } from "../types/index.js";
10
+ import type { ClientLanguageModel, ClientLanguageModelCallOptions, ClientLanguageModelResponse, ClientLanguageModelStreamResponse, ClientModelOptions, NeuroLinkProviderOptions } from "../types/index.js";
11
11
  import { NeuroLinkClient } from "./httpClient.js";
12
12
  /**
13
13
  * NeuroLink Language Model implementation compatible with Vercel AI SDK
@@ -107,6 +107,7 @@ export class NeuroLinkLanguageModel {
107
107
  }
108
108
  // Extract system message if present
109
109
  const systemPrompt = system ?? messages?.find((m) => m.role === "system")?.content;
110
+ // ---- Async queue (push/pull pattern) ----
110
111
  const buffer = [];
111
112
  let finished = false;
112
113
  let notifyConsumer = null;
@@ -99,6 +99,7 @@ export declare class NeuroLinkClient {
99
99
  * Execute HTTP request with middleware and retry logic
100
100
  */
101
101
  private request;
102
+ private _doRequest;
102
103
  /**
103
104
  * Generate text using AI models
104
105
  *
@@ -8,6 +8,8 @@
8
8
  */
9
9
  import { HttpError, ClientNetworkError, ClientTimeoutError } from "./errors.js";
10
10
  import { logger } from "../utils/logger.js";
11
+ import { tracers } from "../telemetry/tracers.js";
12
+ import { withClientSpan } from "../telemetry/withSpan.js";
11
13
  // =============================================================================
12
14
  // Shared Utilities
13
15
  // =============================================================================
@@ -184,6 +186,17 @@ export class NeuroLinkClient {
184
186
  * Execute HTTP request with middleware and retry logic
185
187
  */
186
188
  async request(method, path, body, options) {
189
+ return withClientSpan({
190
+ name: "neurolink.client.http.request",
191
+ tracer: tracers.http,
192
+ attributes: {
193
+ "http.method": method,
194
+ "http.route": path,
195
+ "http.url": `${this.config.baseUrl}${path}`,
196
+ },
197
+ }, async () => this._doRequest(method, path, body, options));
198
+ }
199
+ async _doRequest(method, path, body, options) {
187
200
  const url = `${this.config.baseUrl}${path}`;
188
201
  const requestId = this.generateRequestId();
189
202
  const { retry } = this.config;
@@ -49,6 +49,7 @@ export declare class NeuroLinkSSE {
49
49
  * Stream from an endpoint using SSE
50
50
  */
51
51
  stream(path: string, options?: SSERequestOptions, callbacks?: ClientStreamCallbacks): Promise<void>;
52
+ private _streamInternal;
52
53
  /**
53
54
  * Abort the current stream
54
55
  */
@@ -7,7 +7,10 @@
7
7
  *
8
8
  * @module @neurolink/client/sseClient
9
9
  */
10
+ import { SpanStatusCode } from "@opentelemetry/api";
10
11
  import { logger } from "../utils/logger.js";
12
+ import { withClientSpan } from "../telemetry/withSpan.js";
13
+ import { tracers } from "../telemetry/tracers.js";
11
14
  // =============================================================================
12
15
  // SSE Client Implementation
13
16
  // =============================================================================
@@ -69,6 +72,32 @@ export class NeuroLinkSSE {
69
72
  * Stream from an endpoint using SSE
70
73
  */
71
74
  async stream(path, options = {}, callbacks = {}) {
75
+ return withClientSpan({
76
+ name: "neurolink.client.sse.stream",
77
+ tracer: tracers.http,
78
+ attributes: {
79
+ "http.method": options.body ? "POST" : "GET",
80
+ "http.route": path,
81
+ "http.url": this.buildUrl(path),
82
+ "sse.auto_reconnect": this.config.autoReconnect,
83
+ "sse.native_event_source": this.config.useNativeEventSource,
84
+ },
85
+ }, async (span) => {
86
+ // Wrap onError callback so the span is marked failed on stream errors
87
+ const wrappedCallbacks = {
88
+ ...callbacks,
89
+ onError: (error) => {
90
+ span.setStatus({
91
+ code: SpanStatusCode.ERROR,
92
+ message: error?.message ?? "SSE stream error",
93
+ });
94
+ callbacks.onError?.(error);
95
+ },
96
+ };
97
+ return this._streamInternal(path, options, wrappedCallbacks);
98
+ });
99
+ }
100
+ async _streamInternal(path, options = {}, callbacks = {}) {
72
101
  const url = this.buildUrl(path);
73
102
  const isGetRequest = !options.body;
74
103
  // Use native EventSource for GET requests when configured and available