@juspay/neurolink 9.54.5 → 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 (432) hide show
  1. package/CHANGELOG.md +4 -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 -1
  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 +2 -2
  54. package/dist/client/httpClient.js +13 -0
  55. package/dist/client/sseClient.d.ts +2 -2
  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 +7 -2
  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/core/toolEvents.d.ts +0 -1
  72. package/dist/evaluation/BatchEvaluator.d.ts +1 -97
  73. package/dist/evaluation/EvaluationAggregator.d.ts +1 -118
  74. package/dist/evaluation/EvaluatorFactory.d.ts +1 -13
  75. package/dist/evaluation/EvaluatorRegistry.d.ts +1 -50
  76. package/dist/evaluation/errors/EvaluationError.d.ts +2 -27
  77. package/dist/evaluation/hooks/langfuseAdapter.d.ts +1 -39
  78. package/dist/evaluation/hooks/observabilityHooks.d.ts +3 -55
  79. package/dist/evaluation/hooks/observabilityHooks.js +3 -0
  80. package/dist/evaluation/pipeline/strategies/batchStrategy.d.ts +7 -61
  81. package/dist/evaluation/pipeline/strategies/batchStrategy.js +7 -7
  82. package/dist/evaluation/ragasEvaluator.js +54 -37
  83. package/dist/evaluation/reporting/metricsCollector.d.ts +1 -60
  84. package/dist/evaluation/reporting/reportGenerator.d.ts +1 -17
  85. package/dist/evaluation/scorers/rule/contentSimilarityScorer.d.ts +1 -29
  86. package/dist/evaluation/scorers/rule/formatScorer.d.ts +1 -42
  87. package/dist/evaluation/scorers/rule/keywordCoverageScorer.d.ts +1 -19
  88. package/dist/evaluation/scorers/rule/lengthScorer.d.ts +1 -33
  89. package/dist/factories/providerFactory.d.ts +1 -16
  90. package/dist/factories/providerFactory.js +2 -0
  91. package/dist/image-gen/ImageGenService.d.ts +3 -0
  92. package/dist/image-gen/ImageGenService.js +3 -0
  93. package/dist/lib/action/actionInputs.d.ts +1 -1
  94. package/dist/lib/adapters/video/directorPipeline.js +6 -0
  95. package/dist/lib/adapters/video/vertexVideoHandler.js +6 -0
  96. package/dist/lib/agent/directTools.d.ts +3 -23
  97. package/dist/lib/auth/AuthProviderFactory.d.ts +1 -3
  98. package/dist/lib/auth/anthropicOAuth.d.ts +4 -7
  99. package/dist/lib/auth/anthropicOAuth.js +23 -0
  100. package/dist/lib/auth/errors.d.ts +1 -1
  101. package/dist/lib/auth/index.d.ts +11 -0
  102. package/dist/lib/auth/index.js +14 -0
  103. package/dist/lib/auth/middleware/AuthMiddleware.d.ts +5 -60
  104. package/dist/lib/auth/middleware/AuthMiddleware.js +3 -0
  105. package/dist/lib/auth/middleware/rateLimitByUser.d.ts +4 -93
  106. package/dist/lib/auth/middleware/rateLimitByUser.js +4 -0
  107. package/dist/lib/auth/providers/BaseAuthProvider.d.ts +1 -1
  108. package/dist/lib/auth/providers/CognitoProvider.js +3 -0
  109. package/dist/lib/auth/providers/KeycloakProvider.js +3 -0
  110. package/dist/lib/auth/providers/auth0.d.ts +1 -1
  111. package/dist/lib/auth/sessionManager.d.ts +2 -0
  112. package/dist/lib/auth/sessionManager.js +53 -11
  113. package/dist/lib/auth/tokenStore.d.ts +2 -1
  114. package/dist/lib/auth/tokenStore.js +45 -4
  115. package/dist/lib/autoresearch/tools.d.ts +1 -16
  116. package/dist/lib/client/aiSdkAdapter.d.ts +1 -1
  117. package/dist/lib/client/aiSdkAdapter.js +1 -0
  118. package/dist/lib/client/httpClient.d.ts +2 -2
  119. package/dist/lib/client/httpClient.js +13 -0
  120. package/dist/lib/client/sseClient.d.ts +2 -2
  121. package/dist/lib/client/sseClient.js +29 -0
  122. package/dist/lib/client/streamingClient.d.ts +2 -0
  123. package/dist/lib/client/streamingClient.js +19 -0
  124. package/dist/lib/client/wsClient.d.ts +7 -2
  125. package/dist/lib/client/wsClient.js +90 -10
  126. package/dist/lib/context/budgetChecker.js +3 -1
  127. package/dist/lib/context/contextCompactor.js +163 -143
  128. package/dist/lib/context/fileSummarizationService.d.ts +1 -9
  129. package/dist/lib/context/summarizationEngine.js +29 -16
  130. package/dist/lib/core/baseProvider.js +124 -153
  131. package/dist/lib/core/infrastructure/baseRegistry.d.ts +1 -7
  132. package/dist/lib/core/modules/GenerationHandler.d.ts +3 -2
  133. package/dist/lib/core/modules/GenerationHandler.js +9 -1
  134. package/dist/lib/core/modules/StreamHandler.js +9 -0
  135. package/dist/lib/core/modules/ToolsManager.js +18 -2
  136. package/dist/lib/core/toolEvents.d.ts +0 -1
  137. package/dist/lib/evaluation/BatchEvaluator.d.ts +1 -97
  138. package/dist/lib/evaluation/EvaluationAggregator.d.ts +1 -118
  139. package/dist/lib/evaluation/EvaluatorFactory.d.ts +1 -13
  140. package/dist/lib/evaluation/EvaluatorRegistry.d.ts +1 -50
  141. package/dist/lib/evaluation/errors/EvaluationError.d.ts +2 -27
  142. package/dist/lib/evaluation/hooks/langfuseAdapter.d.ts +1 -39
  143. package/dist/lib/evaluation/hooks/observabilityHooks.d.ts +3 -55
  144. package/dist/lib/evaluation/hooks/observabilityHooks.js +3 -0
  145. package/dist/lib/evaluation/pipeline/strategies/batchStrategy.d.ts +7 -61
  146. package/dist/lib/evaluation/pipeline/strategies/batchStrategy.js +7 -7
  147. package/dist/lib/evaluation/ragasEvaluator.js +54 -37
  148. package/dist/lib/evaluation/reporting/metricsCollector.d.ts +1 -60
  149. package/dist/lib/evaluation/reporting/reportGenerator.d.ts +1 -17
  150. package/dist/lib/evaluation/scorers/rule/contentSimilarityScorer.d.ts +1 -29
  151. package/dist/lib/evaluation/scorers/rule/formatScorer.d.ts +1 -42
  152. package/dist/lib/evaluation/scorers/rule/keywordCoverageScorer.d.ts +1 -19
  153. package/dist/lib/evaluation/scorers/rule/lengthScorer.d.ts +1 -33
  154. package/dist/lib/factories/providerFactory.d.ts +1 -16
  155. package/dist/lib/factories/providerFactory.js +2 -0
  156. package/dist/lib/image-gen/ImageGenService.d.ts +3 -0
  157. package/dist/lib/image-gen/ImageGenService.js +3 -0
  158. package/dist/lib/mcp/batching/requestBatcher.js +99 -73
  159. package/dist/lib/mcp/httpRateLimiter.js +3 -1
  160. package/dist/lib/mcp/httpRetryHandler.js +3 -1
  161. package/dist/lib/mcp/mcpClientFactory.js +3 -1
  162. package/dist/lib/mcp/multiServerManager.d.ts +1 -14
  163. package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +5 -1
  164. package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +1 -0
  165. package/dist/lib/mcp/toolDiscoveryService.js +70 -57
  166. package/dist/lib/mcp/toolRegistry.js +11 -1
  167. package/dist/lib/memory/hippocampusInitializer.d.ts +1 -2
  168. package/dist/lib/memory/hippocampusInitializer.js +1 -1
  169. package/dist/lib/memory/memoryRetrievalTools.js +182 -141
  170. package/dist/lib/models/anthropicModels.d.ts +0 -1
  171. package/dist/lib/models/anthropicModels.js +1 -0
  172. package/dist/lib/neurolink.js +237 -41
  173. package/dist/lib/observability/exporterRegistry.d.ts +3 -22
  174. package/dist/lib/observability/exporters/sentryExporter.js +1 -0
  175. package/dist/lib/observability/metricsAggregator.d.ts +1 -31
  176. package/dist/lib/observability/retryPolicy.d.ts +0 -1
  177. package/dist/lib/observability/sampling/samplers.d.ts +0 -1
  178. package/dist/lib/observability/spanProcessor.d.ts +0 -1
  179. package/dist/lib/observability/tokenTracker.d.ts +7 -16
  180. package/dist/lib/observability/tokenTracker.js +6 -4
  181. package/dist/lib/observability/utils/spanSerializer.d.ts +5 -1
  182. package/dist/lib/observability/utils/spanSerializer.js +24 -4
  183. package/dist/lib/processors/base/BaseFileProcessor.js +66 -53
  184. package/dist/lib/processors/document/ExcelProcessor.d.ts +1 -1
  185. package/dist/lib/processors/errors/errorHelpers.d.ts +1 -31
  186. package/dist/lib/processors/errors/errorSerializer.d.ts +1 -45
  187. package/dist/lib/processors/registry/ProcessorRegistry.js +17 -6
  188. package/dist/lib/providers/amazonBedrock.js +189 -15
  189. package/dist/lib/providers/amazonSagemaker.js +25 -11
  190. package/dist/lib/providers/anthropic.js +13 -0
  191. package/dist/lib/providers/azureOpenai.js +2 -0
  192. package/dist/lib/providers/googleAiStudio.js +82 -0
  193. package/dist/lib/providers/googleNativeGemini3.d.ts +1 -2
  194. package/dist/lib/providers/googleVertex.js +52 -0
  195. package/dist/lib/providers/huggingFace.js +2 -0
  196. package/dist/lib/providers/litellm.js +2 -0
  197. package/dist/lib/providers/mistral.js +2 -0
  198. package/dist/lib/providers/ollama.js +84 -5
  199. package/dist/lib/providers/openAI.d.ts +2 -0
  200. package/dist/lib/providers/openAI.js +17 -6
  201. package/dist/lib/providers/openRouter.js +2 -0
  202. package/dist/lib/providers/openaiCompatible.js +2 -0
  203. package/dist/lib/providers/sagemaker/detection.d.ts +1 -33
  204. package/dist/lib/providers/sagemaker/diagnostics.d.ts +1 -25
  205. package/dist/lib/providers/sagemaker/language-model.d.ts +1 -1
  206. package/dist/lib/proxy/proxyConfig.js +4 -0
  207. package/dist/lib/proxy/proxyEnv.d.ts +1 -17
  208. package/dist/lib/proxy/proxyHealth.d.ts +0 -1
  209. package/dist/lib/proxy/proxyTracer.d.ts +1 -36
  210. package/dist/lib/proxy/proxyTracer.js +9 -0
  211. package/dist/lib/proxy/quietDetector.d.ts +1 -7
  212. package/dist/lib/proxy/rawStreamCapture.d.ts +1 -10
  213. package/dist/lib/proxy/requestLogger.d.ts +1 -21
  214. package/dist/lib/proxy/routingPolicy.d.ts +1 -2
  215. package/dist/lib/proxy/sseInterceptor.d.ts +1 -66
  216. package/dist/lib/proxy/sseInterceptor.js +6 -0
  217. package/dist/lib/proxy/updateChecker.d.ts +1 -6
  218. package/dist/lib/proxy/updateState.d.ts +1 -12
  219. package/dist/lib/rag/chunkers/BaseChunker.js +36 -22
  220. package/dist/lib/rag/chunking/jsonChunker.d.ts +1 -1
  221. package/dist/lib/rag/errors/RAGError.d.ts +1 -2
  222. package/dist/lib/rag/ragIntegration.js +45 -32
  223. package/dist/lib/rag/reranker/reranker.js +151 -122
  224. package/dist/lib/rag/retrieval/vectorQueryTool.js +79 -65
  225. package/dist/lib/sdk/toolRegistration.d.ts +10 -44
  226. package/dist/lib/sdk/toolRegistration.js +1 -1
  227. package/dist/lib/server/middleware/abortSignal.d.ts +1 -11
  228. package/dist/lib/server/middleware/auth.d.ts +1 -21
  229. package/dist/lib/server/middleware/auth.js +12 -0
  230. package/dist/lib/server/middleware/common.js +48 -32
  231. package/dist/lib/server/middleware/deprecation.d.ts +1 -20
  232. package/dist/lib/server/middleware/rateLimit.d.ts +1 -75
  233. package/dist/lib/server/middleware/validation.d.ts +3 -81
  234. package/dist/lib/server/middleware/validation.js +3 -0
  235. package/dist/lib/server/openapi/generator.d.ts +1 -47
  236. package/dist/lib/server/routes/agentRoutes.js +112 -57
  237. package/dist/lib/server/routes/claudeProxyRoutes.d.ts +1 -6
  238. package/dist/lib/server/routes/claudeProxyRoutes.js +127 -13
  239. package/dist/lib/server/routes/healthRoutes.js +58 -12
  240. package/dist/lib/server/routes/index.d.ts +1 -26
  241. package/dist/lib/server/routes/mcpRoutes.js +40 -7
  242. package/dist/lib/server/routes/memoryRoutes.js +22 -7
  243. package/dist/lib/server/routes/openApiRoutes.js +30 -6
  244. package/dist/lib/server/routes/toolRoutes.js +140 -68
  245. package/dist/lib/server/streaming/dataStream.d.ts +1 -35
  246. package/dist/lib/server/streaming/dataStream.js +15 -0
  247. package/dist/lib/services/server/ai/observability/instrumentation.js +114 -14
  248. package/dist/lib/session/globalSessionState.d.ts +1 -10
  249. package/dist/lib/tasks/tools/taskTools.d.ts +2 -2
  250. package/dist/lib/telemetry/traceContext.d.ts +9 -0
  251. package/dist/lib/telemetry/traceContext.js +19 -0
  252. package/dist/lib/telemetry/tracers.d.ts +2 -0
  253. package/dist/lib/telemetry/tracers.js +2 -0
  254. package/dist/lib/types/action.d.ts +2 -0
  255. package/dist/lib/types/artifact.d.ts +7 -0
  256. package/dist/lib/types/auth.d.ts +125 -18
  257. package/dist/lib/types/autoresearch.d.ts +12 -0
  258. package/dist/lib/types/cli.d.ts +415 -0
  259. package/dist/lib/types/client.d.ts +34 -0
  260. package/dist/lib/types/common.d.ts +12 -41
  261. package/dist/lib/types/context.d.ts +5 -0
  262. package/dist/lib/types/evaluation.d.ts +332 -1
  263. package/dist/lib/types/file.d.ts +4 -0
  264. package/dist/lib/types/mcp.d.ts +102 -2
  265. package/dist/lib/types/middleware.d.ts +116 -0
  266. package/dist/lib/types/multimodal.d.ts +65 -0
  267. package/dist/lib/types/observability.d.ts +81 -0
  268. package/dist/lib/types/processor.d.ts +47 -0
  269. package/dist/lib/types/providers.d.ts +120 -16
  270. package/dist/lib/types/proxy.d.ts +321 -1
  271. package/dist/lib/types/rag.d.ts +22 -0
  272. package/dist/lib/types/scorer.d.ts +141 -0
  273. package/dist/lib/types/server.d.ts +99 -0
  274. package/dist/lib/types/span.d.ts +2 -1
  275. package/dist/lib/types/span.js +1 -0
  276. package/dist/lib/types/tools.d.ts +44 -0
  277. package/dist/lib/types/tts.d.ts +6 -0
  278. package/dist/lib/types/utilities.d.ts +22 -0
  279. package/dist/lib/types/workflow.d.ts +18 -0
  280. package/dist/lib/utils/async/retry.d.ts +2 -8
  281. package/dist/lib/utils/async/retry.js +9 -9
  282. package/dist/lib/utils/imageCompressor.d.ts +1 -21
  283. package/dist/lib/utils/imageCompressor.js +5 -1
  284. package/dist/lib/utils/messageBuilder.d.ts +1 -1
  285. package/dist/lib/utils/redis.d.ts +1 -4
  286. package/dist/lib/utils/sanitizers/filename.d.ts +0 -1
  287. package/dist/lib/utils/toolEndEmitter.d.ts +25 -0
  288. package/dist/lib/utils/toolEndEmitter.js +65 -0
  289. package/dist/lib/workflow/config.d.ts +7 -32
  290. package/dist/lib/workflow/core/ensembleExecutor.js +28 -0
  291. package/dist/lib/workflow/core/judgeScorer.js +23 -0
  292. package/dist/lib/workflow/core/responseConditioner.js +17 -0
  293. package/dist/lib/workflow/core/workflowRunner.d.ts +1 -19
  294. package/dist/lib/workflow/core/workflowRunner.js +202 -147
  295. package/dist/mcp/batching/requestBatcher.js +99 -73
  296. package/dist/mcp/httpRateLimiter.js +3 -1
  297. package/dist/mcp/httpRetryHandler.js +3 -1
  298. package/dist/mcp/mcpClientFactory.js +3 -1
  299. package/dist/mcp/multiServerManager.d.ts +1 -14
  300. package/dist/mcp/servers/aiProviders/aiAnalysisTools.js +5 -1
  301. package/dist/mcp/servers/aiProviders/aiWorkflowTools.js +1 -0
  302. package/dist/mcp/toolDiscoveryService.js +70 -57
  303. package/dist/mcp/toolRegistry.js +11 -1
  304. package/dist/memory/hippocampusInitializer.d.ts +1 -2
  305. package/dist/memory/hippocampusInitializer.js +1 -1
  306. package/dist/memory/memoryRetrievalTools.js +182 -141
  307. package/dist/models/anthropicModels.d.ts +0 -1
  308. package/dist/models/anthropicModels.js +1 -0
  309. package/dist/neurolink.js +237 -41
  310. package/dist/observability/exporterRegistry.d.ts +3 -22
  311. package/dist/observability/exporters/sentryExporter.js +1 -0
  312. package/dist/observability/metricsAggregator.d.ts +1 -31
  313. package/dist/observability/retryPolicy.d.ts +0 -1
  314. package/dist/observability/sampling/samplers.d.ts +0 -1
  315. package/dist/observability/spanProcessor.d.ts +0 -1
  316. package/dist/observability/tokenTracker.d.ts +7 -16
  317. package/dist/observability/tokenTracker.js +6 -4
  318. package/dist/observability/utils/spanSerializer.d.ts +5 -1
  319. package/dist/observability/utils/spanSerializer.js +24 -4
  320. package/dist/processors/base/BaseFileProcessor.js +66 -53
  321. package/dist/processors/document/ExcelProcessor.d.ts +1 -1
  322. package/dist/processors/errors/errorHelpers.d.ts +1 -31
  323. package/dist/processors/errors/errorSerializer.d.ts +1 -45
  324. package/dist/processors/registry/ProcessorRegistry.js +17 -6
  325. package/dist/providers/amazonBedrock.js +189 -15
  326. package/dist/providers/amazonSagemaker.js +25 -11
  327. package/dist/providers/anthropic.js +13 -0
  328. package/dist/providers/azureOpenai.js +2 -0
  329. package/dist/providers/googleAiStudio.js +82 -0
  330. package/dist/providers/googleNativeGemini3.d.ts +1 -2
  331. package/dist/providers/googleVertex.js +52 -0
  332. package/dist/providers/huggingFace.js +2 -0
  333. package/dist/providers/litellm.js +2 -0
  334. package/dist/providers/mistral.js +2 -0
  335. package/dist/providers/ollama.js +84 -5
  336. package/dist/providers/openAI.d.ts +2 -0
  337. package/dist/providers/openAI.js +17 -6
  338. package/dist/providers/openRouter.js +2 -0
  339. package/dist/providers/openaiCompatible.js +2 -0
  340. package/dist/providers/sagemaker/detection.d.ts +1 -33
  341. package/dist/providers/sagemaker/diagnostics.d.ts +1 -25
  342. package/dist/providers/sagemaker/language-model.d.ts +1 -1
  343. package/dist/proxy/proxyConfig.js +4 -0
  344. package/dist/proxy/proxyEnv.d.ts +1 -17
  345. package/dist/proxy/proxyHealth.d.ts +0 -1
  346. package/dist/proxy/proxyTracer.d.ts +1 -36
  347. package/dist/proxy/proxyTracer.js +9 -0
  348. package/dist/proxy/quietDetector.d.ts +1 -7
  349. package/dist/proxy/rawStreamCapture.d.ts +1 -10
  350. package/dist/proxy/requestLogger.d.ts +1 -21
  351. package/dist/proxy/routingPolicy.d.ts +1 -2
  352. package/dist/proxy/sseInterceptor.d.ts +1 -66
  353. package/dist/proxy/sseInterceptor.js +6 -0
  354. package/dist/proxy/updateChecker.d.ts +1 -6
  355. package/dist/proxy/updateState.d.ts +1 -12
  356. package/dist/rag/chunkers/BaseChunker.js +36 -22
  357. package/dist/rag/chunking/jsonChunker.d.ts +1 -1
  358. package/dist/rag/errors/RAGError.d.ts +1 -2
  359. package/dist/rag/ragIntegration.js +45 -32
  360. package/dist/rag/reranker/reranker.js +151 -122
  361. package/dist/rag/retrieval/vectorQueryTool.js +79 -65
  362. package/dist/sdk/toolRegistration.d.ts +10 -44
  363. package/dist/sdk/toolRegistration.js +1 -1
  364. package/dist/server/middleware/abortSignal.d.ts +1 -11
  365. package/dist/server/middleware/auth.d.ts +1 -21
  366. package/dist/server/middleware/auth.js +12 -0
  367. package/dist/server/middleware/common.js +48 -32
  368. package/dist/server/middleware/deprecation.d.ts +1 -20
  369. package/dist/server/middleware/rateLimit.d.ts +1 -75
  370. package/dist/server/middleware/validation.d.ts +3 -81
  371. package/dist/server/middleware/validation.js +3 -0
  372. package/dist/server/openapi/generator.d.ts +1 -47
  373. package/dist/server/routes/agentRoutes.js +112 -57
  374. package/dist/server/routes/claudeProxyRoutes.d.ts +1 -6
  375. package/dist/server/routes/claudeProxyRoutes.js +127 -13
  376. package/dist/server/routes/healthRoutes.js +58 -12
  377. package/dist/server/routes/index.d.ts +1 -26
  378. package/dist/server/routes/mcpRoutes.js +40 -7
  379. package/dist/server/routes/memoryRoutes.js +22 -7
  380. package/dist/server/routes/openApiRoutes.js +30 -6
  381. package/dist/server/routes/toolRoutes.js +140 -68
  382. package/dist/server/streaming/dataStream.d.ts +1 -35
  383. package/dist/server/streaming/dataStream.js +15 -0
  384. package/dist/services/server/ai/observability/instrumentation.js +114 -14
  385. package/dist/session/globalSessionState.d.ts +1 -10
  386. package/dist/tasks/tools/taskTools.d.ts +2 -2
  387. package/dist/telemetry/traceContext.d.ts +9 -0
  388. package/dist/telemetry/traceContext.js +18 -0
  389. package/dist/telemetry/tracers.d.ts +2 -0
  390. package/dist/telemetry/tracers.js +2 -0
  391. package/dist/types/action.d.ts +2 -0
  392. package/dist/types/artifact.d.ts +7 -0
  393. package/dist/types/auth.d.ts +125 -18
  394. package/dist/types/autoresearch.d.ts +12 -0
  395. package/dist/types/cli.d.ts +415 -0
  396. package/dist/types/client.d.ts +34 -0
  397. package/dist/types/common.d.ts +12 -41
  398. package/dist/types/context.d.ts +5 -0
  399. package/dist/types/evaluation.d.ts +332 -1
  400. package/dist/types/file.d.ts +4 -0
  401. package/dist/types/mcp.d.ts +102 -2
  402. package/dist/types/middleware.d.ts +116 -0
  403. package/dist/types/multimodal.d.ts +65 -0
  404. package/dist/types/observability.d.ts +81 -0
  405. package/dist/types/processor.d.ts +47 -0
  406. package/dist/types/providers.d.ts +120 -16
  407. package/dist/types/proxy.d.ts +321 -1
  408. package/dist/types/rag.d.ts +22 -0
  409. package/dist/types/scorer.d.ts +141 -0
  410. package/dist/types/server.d.ts +99 -0
  411. package/dist/types/span.d.ts +2 -1
  412. package/dist/types/span.js +1 -0
  413. package/dist/types/tools.d.ts +44 -0
  414. package/dist/types/tts.d.ts +6 -0
  415. package/dist/types/utilities.d.ts +22 -0
  416. package/dist/types/workflow.d.ts +18 -0
  417. package/dist/utils/async/retry.d.ts +2 -8
  418. package/dist/utils/async/retry.js +9 -9
  419. package/dist/utils/imageCompressor.d.ts +1 -21
  420. package/dist/utils/imageCompressor.js +5 -1
  421. package/dist/utils/messageBuilder.d.ts +1 -1
  422. package/dist/utils/redis.d.ts +1 -4
  423. package/dist/utils/sanitizers/filename.d.ts +0 -1
  424. package/dist/utils/toolEndEmitter.d.ts +25 -0
  425. package/dist/utils/toolEndEmitter.js +64 -0
  426. package/dist/workflow/config.d.ts +4 -29
  427. package/dist/workflow/core/ensembleExecutor.js +28 -0
  428. package/dist/workflow/core/judgeScorer.js +23 -0
  429. package/dist/workflow/core/responseConditioner.js +17 -0
  430. package/dist/workflow/core/workflowRunner.d.ts +1 -19
  431. package/dist/workflow/core/workflowRunner.js +202 -147
  432. package/package.json +2 -1
@@ -2,102 +2,7 @@
2
2
  * @file BatchEvaluator - Supports batch evaluation of multiple responses.
3
3
  * Enables parallel evaluation with configurable concurrency and error handling.
4
4
  */
5
- import type { LanguageModelV3CallOptions } from "@ai-sdk/provider";
6
- import type { GenerateResult, EvaluationConfig, EvaluationData, AutoEvaluationConfig } from "../types/index.js";
7
- /**
8
- * Configuration for batch evaluation.
9
- */
10
- type BatchEvaluationConfig = EvaluationConfig & {
11
- /** Maximum number of concurrent evaluations (default: 5) */
12
- concurrency?: number;
13
- /** Whether to continue on individual failures (default: true) */
14
- continueOnError?: boolean;
15
- /** Maximum retries for retryable errors (default: 2) */
16
- maxRetries?: number;
17
- /** Delay between retries in milliseconds (default: 1000) */
18
- retryDelay?: number;
19
- /** Callback for progress updates */
20
- onProgress?: (progress: BatchProgress) => void;
21
- /** Callback for individual evaluation completion */
22
- onItemComplete?: (result: BatchEvaluationItemResult) => void;
23
- };
24
- /**
25
- * Progress information for batch evaluation.
26
- */
27
- type BatchProgress = {
28
- /** Total items to evaluate */
29
- total: number;
30
- /** Items completed (success + failed) */
31
- completed: number;
32
- /** Items that succeeded */
33
- succeeded: number;
34
- /** Items that failed */
35
- failed: number;
36
- /** Items still pending */
37
- pending: number;
38
- /** Percentage complete */
39
- percentComplete: number;
40
- };
41
- /**
42
- * Input item for batch evaluation.
43
- */
44
- type BatchEvaluationItem = {
45
- /** Unique identifier for this item */
46
- id: string;
47
- /** The generation options */
48
- options: LanguageModelV3CallOptions;
49
- /** The generation result to evaluate */
50
- result: GenerateResult;
51
- /** Optional item-specific threshold override */
52
- threshold?: number;
53
- };
54
- /**
55
- * Result for a single item in batch evaluation.
56
- */
57
- type BatchEvaluationItemResult = {
58
- /** The item ID */
59
- id: string;
60
- /** Whether the evaluation succeeded */
61
- success: boolean;
62
- /** The evaluation data (if successful) */
63
- data?: EvaluationData;
64
- /** Error information (if failed) */
65
- error?: {
66
- message: string;
67
- code?: string;
68
- retryable?: boolean;
69
- };
70
- /** Time taken for this evaluation in milliseconds */
71
- duration: number;
72
- /** Number of retry attempts (if any) */
73
- retryCount: number;
74
- };
75
- /**
76
- * Result of a batch evaluation operation.
77
- */
78
- type BatchEvaluationResult = {
79
- /** All item results */
80
- results: BatchEvaluationItemResult[];
81
- /** Summary statistics */
82
- summary: {
83
- /** Total items evaluated */
84
- total: number;
85
- /** Number of successful evaluations */
86
- succeeded: number;
87
- /** Number of failed evaluations */
88
- failed: number;
89
- /** Average evaluation score (for successful items) */
90
- averageScore: number;
91
- /** Average evaluation time in milliseconds */
92
- averageDuration: number;
93
- /** Total time for batch evaluation */
94
- totalDuration: number;
95
- /** Passing rate (percentage of items meeting threshold) */
96
- passingRate: number;
97
- };
98
- /** Whether all evaluations succeeded */
99
- allSucceeded: boolean;
100
- };
5
+ import type { AutoEvaluationConfig, BatchEvaluationConfig, BatchEvaluationItem, BatchEvaluationResult } from "../types/index.js";
101
6
  /**
102
7
  * BatchEvaluator - Performs evaluation on multiple items in parallel.
103
8
  * Supports configurable concurrency, retry logic, and progress tracking.
@@ -158,4 +63,3 @@ export declare class BatchEvaluator {
158
63
  */
159
64
  private delay;
160
65
  }
161
- export {};
@@ -2,123 +2,7 @@
2
2
  * @file EvaluationAggregator - Aggregates and analyzes evaluation results.
3
3
  * Provides statistical analysis, trend detection, and summary generation.
4
4
  */
5
- import type { EvaluationData } from "../types/index.js";
6
- /**
7
- * Statistical summary of evaluation scores.
8
- */
9
- type ScoreStatistics = {
10
- /** Minimum score */
11
- min: number;
12
- /** Maximum score */
13
- max: number;
14
- /** Mean (average) score */
15
- mean: number;
16
- /** Median score */
17
- median: number;
18
- /** Standard deviation */
19
- stdDev: number;
20
- /** Variance */
21
- variance: number;
22
- /** 25th percentile */
23
- p25: number;
24
- /** 75th percentile */
25
- p75: number;
26
- /** 90th percentile */
27
- p90: number;
28
- /** 95th percentile */
29
- p95: number;
30
- };
31
- /**
32
- * Score distribution across ranges.
33
- */
34
- type ScoreDistribution = {
35
- /** Items scoring 1-3 (poor) */
36
- poor: number;
37
- /** Items scoring 4-5 (below average) */
38
- belowAverage: number;
39
- /** Items scoring 6-7 (average) */
40
- average: number;
41
- /** Items scoring 8-9 (good) */
42
- good: number;
43
- /** Items scoring 10 (excellent) */
44
- excellent: number;
45
- };
46
- /**
47
- * Trend analysis results.
48
- */
49
- type TrendAnalysis = {
50
- /** Direction of the trend */
51
- direction: "improving" | "declining" | "stable";
52
- /** Slope of the linear regression */
53
- slope: number;
54
- /** R-squared value (fit quality) */
55
- rSquared: number;
56
- /** Percentage change from first to last */
57
- percentChange: number;
58
- /** Moving average of last N evaluations */
59
- movingAverage: number;
60
- };
61
- /**
62
- * Dimension-specific analysis for RAGAS metrics.
63
- */
64
- type DimensionAnalysis = {
65
- /** Relevance score statistics */
66
- relevance: ScoreStatistics;
67
- /** Accuracy score statistics */
68
- accuracy: ScoreStatistics;
69
- /** Completeness score statistics */
70
- completeness: ScoreStatistics;
71
- /** Overall score statistics */
72
- overall: ScoreStatistics;
73
- /** Correlation matrix between dimensions */
74
- correlations: {
75
- relevanceAccuracy: number;
76
- relevanceCompleteness: number;
77
- accuracyCompleteness: number;
78
- };
79
- };
80
- /**
81
- * Quality alerts summary.
82
- */
83
- type AlertSummary = {
84
- /** Total number of alerts */
85
- total: number;
86
- /** Number of high severity alerts */
87
- high: number;
88
- /** Number of medium severity alerts */
89
- medium: number;
90
- /** Number of items marked as off-topic */
91
- offTopic: number;
92
- /** Alert rate as percentage */
93
- alertRate: number;
94
- };
95
- /**
96
- * Comprehensive aggregation result.
97
- */
98
- type AggregationResult = {
99
- /** Number of evaluations aggregated */
100
- count: number;
101
- /** Statistics for overall scores */
102
- statistics: ScoreStatistics;
103
- /** Score distribution */
104
- distribution: ScoreDistribution;
105
- /** Dimension-specific analysis */
106
- dimensions: DimensionAnalysis;
107
- /** Sequence trend analysis based on insertion order (not time-based) */
108
- sequenceTrend?: TrendAnalysis;
109
- /** Alert summary */
110
- alerts: AlertSummary;
111
- /** Passing rate based on threshold */
112
- passingRate: number;
113
- /** Average evaluation time */
114
- avgEvaluationTime: number;
115
- /** Aggregation metadata */
116
- metadata: {
117
- aggregatedAt: string;
118
- threshold: number;
119
- evaluationModels: string[];
120
- };
121
- };
5
+ import type { AggregationResult, EvaluationData, ScoreDistribution, ScoreStatistics, TrendAnalysis } from "../types/index.js";
122
6
  /**
123
7
  * EvaluationAggregator - Aggregates evaluation results and provides analytics.
124
8
  * Supports statistical analysis, trend detection, and quality monitoring.
@@ -270,4 +154,3 @@ export declare class EvaluationAggregator {
270
154
  */
271
155
  generateSummary(threshold?: number): string;
272
156
  }
273
- export {};
@@ -3,19 +3,8 @@
3
3
  * Extends BaseFactory to provide dynamic evaluator creation with configuration support.
4
4
  */
5
5
  import { BaseFactory } from "../core/infrastructure/index.js";
6
- import type { EvaluationConfig } from "../types/index.js";
6
+ import type { EvaluationConfig, EvaluatorPreset } from "../types/index.js";
7
7
  import { Evaluator } from "./index.js";
8
- /**
9
- * Configuration presets for common evaluation scenarios.
10
- */
11
- type EvaluatorPreset = {
12
- /** Preset name for identification */
13
- name: string;
14
- /** Description of the preset use case */
15
- description: string;
16
- /** The underlying evaluation configuration (optional for built-in presets) */
17
- config?: EvaluationConfig;
18
- };
19
8
  /**
20
9
  * Factory for creating Evaluator instances with various configurations.
21
10
  * Supports presets for common use cases and custom configurations.
@@ -111,4 +100,3 @@ export declare class EvaluatorFactory extends BaseFactory<Evaluator, EvaluationC
111
100
  unregisterPreset(name: string): boolean;
112
101
  }
113
102
  export declare const getEvaluatorFactory: () => EvaluatorFactory;
114
- export {};
@@ -3,55 +3,7 @@
3
3
  * Extends BaseRegistry to provide dynamic strategy registration and lookup.
4
4
  */
5
5
  import { BaseRegistry } from "../core/infrastructure/index.js";
6
- import type { LanguageModelV3CallOptions } from "@ai-sdk/provider";
7
- import type { GenerateResult, EvaluationResult, EnhancedEvaluationContext } from "../types/index.js";
8
- /**
9
- * A function that performs evaluation and returns results.
10
- */
11
- type EvaluationStrategyFunction = (options: LanguageModelV3CallOptions, result: GenerateResult, config?: EvaluationStrategyConfig) => Promise<{
12
- evaluationResult: EvaluationResult;
13
- evalContext: EnhancedEvaluationContext;
14
- }>;
15
- /**
16
- * Configuration for evaluation strategies.
17
- */
18
- type EvaluationStrategyConfig = {
19
- /** The model to use for evaluation */
20
- evaluationModel?: string;
21
- /** The provider to use for evaluation */
22
- provider?: string;
23
- /** The passing threshold (1-10) */
24
- threshold?: number;
25
- /** Custom prompt generator */
26
- promptGenerator?: (context: {
27
- userQuery: string;
28
- history: string;
29
- tools: string;
30
- retryInfo: string;
31
- aiResponse: string;
32
- }) => string;
33
- /** Additional strategy-specific options */
34
- options?: Record<string, unknown>;
35
- };
36
- /**
37
- * Metadata for registered evaluation strategies.
38
- */
39
- type EvaluationStrategyMetadata = {
40
- /** Human-readable name for the strategy */
41
- name: string;
42
- /** Description of what the strategy does */
43
- description: string;
44
- /** Whether the strategy requires an external LLM */
45
- requiresLLM: boolean;
46
- /** Default model for the strategy (if requiresLLM is true) */
47
- defaultModel?: string;
48
- /** Default provider for the strategy (if requiresLLM is true) */
49
- defaultProvider?: string;
50
- /** Version of the strategy */
51
- version: string;
52
- /** Supported features */
53
- features: string[];
54
- };
6
+ import type { EvaluationStrategyFunction, EvaluationStrategyMetadata } from "../types/index.js";
55
7
  /**
56
8
  * Registry for evaluation strategies.
57
9
  * Allows dynamic registration and retrieval of evaluation strategies.
@@ -157,4 +109,3 @@ export declare class EvaluatorRegistry extends BaseRegistry<EvaluationStrategyFu
157
109
  getStrategiesByProvider(provider: string): Promise<string[]>;
158
110
  }
159
111
  export declare const getEvaluatorRegistry: () => EvaluatorRegistry;
160
- export {};
@@ -3,7 +3,7 @@
3
3
  * Uses NeuroLinkFeatureError and createErrorFactory from core infrastructure.
4
4
  */
5
5
  import { NeuroLinkFeatureError } from "../../core/infrastructure/index.js";
6
- import type { EnhancedEvaluationContext } from "../../types/index.js";
6
+ import type { EnhancedEvaluationContext, EvaluationErrorContext } from "../../types/index.js";
7
7
  /**
8
8
  * Error codes for the Evaluation feature.
9
9
  * These codes help identify specific error scenarios for proper handling.
@@ -65,36 +65,12 @@ export declare const evaluationErrors: {
65
65
  /** Rate limit hit during evaluation */
66
66
  readonly RATE_LIMIT_ERROR: "RATE_LIMIT_ERROR";
67
67
  };
68
- create: (code: "PROVIDER_ERROR" | "CONFIGURATION_ERROR" | "EVALUATION_FAILED" | "PARSE_ERROR" | "STRATEGY_NOT_FOUND" | "CUSTOM_EVALUATOR_ERROR" | "BATCH_EVALUATION_ERROR" | "AGGREGATION_ERROR" | "REGISTRY_ERROR" | "MAX_RETRIES_EXCEEDED" | "TIMEOUT_ERROR" | "RATE_LIMIT_ERROR", message: string, options?: {
68
+ create: (code: "EVALUATION_FAILED" | "PARSE_ERROR" | "STRATEGY_NOT_FOUND" | "PROVIDER_ERROR" | "CONFIGURATION_ERROR" | "CUSTOM_EVALUATOR_ERROR" | "BATCH_EVALUATION_ERROR" | "AGGREGATION_ERROR" | "REGISTRY_ERROR" | "MAX_RETRIES_EXCEEDED" | "TIMEOUT_ERROR" | "RATE_LIMIT_ERROR", message: string, options?: {
69
69
  retryable?: boolean;
70
70
  details?: Record<string, unknown>;
71
71
  cause?: Error;
72
72
  } | undefined) => NeuroLinkFeatureError;
73
73
  };
74
- /**
75
- * Extended evaluation context for error details.
76
- * Provides rich debugging information when errors occur.
77
- */
78
- type EvaluationErrorContext = {
79
- /** Length of the user query (redacted for safety) */
80
- userQueryLength?: number;
81
- /** Length of the AI response (redacted for safety) */
82
- aiResponseLength?: number;
83
- /** The current attempt number */
84
- attemptNumber?: number;
85
- /** Previous evaluation scores if any */
86
- previousScores?: number[];
87
- /** The evaluation strategy in use */
88
- strategy?: string;
89
- /** The evaluation model being used */
90
- evaluationModel?: string;
91
- /** The provider being used */
92
- provider?: string;
93
- /** Length of the raw response (redacted for safety) */
94
- rawResponseLength?: number;
95
- /** Any additional context */
96
- additionalContext?: Record<string, unknown>;
97
- };
98
74
  /**
99
75
  * Checks if an error is retryable based on its code.
100
76
  * Transient errors (timeout, rate limit, some provider errors) are retryable.
@@ -183,4 +159,3 @@ export declare function createConfigurationError(message: string, configIssue: s
183
159
  * @returns An EvaluationErrorContext
184
160
  */
185
161
  export declare function contextToErrorContext(context: EnhancedEvaluationContext): EvaluationErrorContext;
186
- export {};
@@ -2,44 +2,7 @@
2
2
  * @file Langfuse Adapter
3
3
  * Integration with Langfuse for LLM observability
4
4
  */
5
- /**
6
- * Langfuse client interface (minimal for type safety)
7
- */
8
- type LangfuseClient = {
9
- score: (params: {
10
- name: string;
11
- value: number;
12
- traceId?: string;
13
- observationId?: string;
14
- comment?: string;
15
- metadata?: Record<string, unknown>;
16
- }) => Promise<unknown>;
17
- trace?: (params: {
18
- name: string;
19
- metadata?: Record<string, unknown>;
20
- tags?: string[];
21
- }) => {
22
- id: string;
23
- };
24
- shutdown?: () => Promise<void>;
25
- };
26
- /**
27
- * Langfuse adapter configuration
28
- */
29
- type LangfuseAdapterConfig = {
30
- /** Langfuse client instance */
31
- client: LangfuseClient;
32
- /** Prefix for score names */
33
- scorePrefix?: string;
34
- /** Include detailed metadata */
35
- includeMetadata?: boolean;
36
- /** Tags to add to all scores */
37
- tags?: string[];
38
- /** Whether to send pipeline-level scores */
39
- sendPipelineScores?: boolean;
40
- /** Whether to send individual scorer scores */
41
- sendScorerScores?: boolean;
42
- };
5
+ import type { LangfuseAdapterConfig, LangfuseClient } from "../../types/index.js";
43
6
  /**
44
7
  * Langfuse adapter for evaluation observability
45
8
  */
@@ -97,4 +60,3 @@ export declare function createMockLangfuseClient(): LangfuseClient & {
97
60
  metadata?: Record<string, unknown>;
98
61
  }>;
99
62
  };
100
- export {};
@@ -2,57 +2,7 @@
2
2
  * @file Observability Hooks
3
3
  * OpenTelemetry integration for evaluation tracing
4
4
  */
5
- import type { EvaluationTraceContext, ScoreResult, PipelineResult } from "../../types/index.js";
6
- /**
7
- * Event handler type
8
- */
9
- type EventHandler<T> = (event: T) => void | Promise<void>;
10
- /**
11
- * Evaluation events
12
- */
13
- type EvaluationEvents = {
14
- "scorer:start": {
15
- scorerId: string;
16
- scorerName: string;
17
- timestamp: number;
18
- traceContext?: EvaluationTraceContext;
19
- };
20
- "scorer:end": {
21
- scorerId: string;
22
- scorerName: string;
23
- result: ScoreResult;
24
- timestamp: number;
25
- duration: number;
26
- traceContext?: EvaluationTraceContext;
27
- };
28
- "scorer:error": {
29
- scorerId: string;
30
- scorerName: string;
31
- error: string;
32
- timestamp: number;
33
- traceContext?: EvaluationTraceContext;
34
- };
35
- "pipeline:start": {
36
- pipelineName: string;
37
- scorerCount: number;
38
- timestamp: number;
39
- correlationId: string;
40
- traceContext?: EvaluationTraceContext;
41
- };
42
- "pipeline:end": {
43
- pipelineName: string;
44
- result: PipelineResult;
45
- timestamp: number;
46
- duration: number;
47
- traceContext?: EvaluationTraceContext;
48
- };
49
- "pipeline:error": {
50
- pipelineName: string;
51
- error: string;
52
- timestamp: number;
53
- traceContext?: EvaluationTraceContext;
54
- };
55
- };
5
+ import type { EvaluationEvents, EvaluationSpanAttributes, EvaluationTraceContext, EventHandler, PipelineResult, ScoreResult } from "../../types/index.js";
56
6
  /**
57
7
  * Observability hooks manager
58
8
  */
@@ -117,13 +67,11 @@ export declare function createMetricsCollectorHook(collector: {
117
67
  /**
118
68
  * OpenTelemetry span attributes
119
69
  */
120
- type SpanAttributes = Record<string, string | number | boolean>;
121
70
  /**
122
71
  * Create span attributes from scorer result
123
72
  */
124
- export declare function scorerToSpanAttributes(result: ScoreResult): SpanAttributes;
73
+ export declare function scorerToSpanAttributes(result: ScoreResult): EvaluationSpanAttributes;
125
74
  /**
126
75
  * Create span attributes from pipeline result
127
76
  */
128
- export declare function pipelineToSpanAttributes(result: PipelineResult): SpanAttributes;
129
- export {};
77
+ export declare function pipelineToSpanAttributes(result: PipelineResult): EvaluationSpanAttributes;
@@ -145,6 +145,9 @@ export function createMetricsCollectorHook(collector) {
145
145
  collector.recordPipeline(event.result);
146
146
  });
147
147
  }
148
+ /**
149
+ * OpenTelemetry span attributes
150
+ */
148
151
  /**
149
152
  * Create span attributes from scorer result
150
153
  */
@@ -2,72 +2,19 @@
2
2
  * @file Batch Strategy
3
3
  * Batch processing for evaluation pipelines
4
4
  */
5
- import type { ScorerInput, PipelineExecutionOptions, PipelineResult } from "../../../types/index.js";
5
+ import type { ScorerInput, PipelineExecutionOptions, BatchEvaluationConfig, BatchEvaluationResult, BatchItemResult } from "../../../types/index.js";
6
6
  import type { EvaluationPipeline } from "../evaluationPipeline.js";
7
- /**
8
- * Batch processing configuration
9
- */
10
- type BatchConfig = {
11
- /** Maximum concurrent evaluations */
12
- concurrency?: number;
13
- /** Delay between batches (ms) */
14
- batchDelay?: number;
15
- /** Continue on individual failures */
16
- continueOnError?: boolean;
17
- /** Progress callback */
18
- onProgress?: (progress: BatchProgress) => void;
19
- /** Individual result callback */
20
- onResult?: (result: BatchItemResult) => void;
21
- };
22
- /**
23
- * Batch progress information
24
- */
25
- type BatchProgress = {
26
- total: number;
27
- completed: number;
28
- failed: number;
29
- remaining: number;
30
- percentComplete: number;
31
- estimatedTimeRemaining?: number;
32
- };
33
- /**
34
- * Individual batch item result
35
- */
36
- type BatchItemResult = {
37
- index: number;
38
- input: ScorerInput;
39
- result?: PipelineResult;
40
- error?: string;
41
- duration: number;
42
- };
43
- /**
44
- * Batch evaluation result
45
- */
46
- type BatchResult = {
47
- /** All individual results */
48
- results: BatchItemResult[];
49
- /** Summary statistics */
50
- summary: {
51
- total: number;
52
- successful: number;
53
- failed: number;
54
- averageScore: number;
55
- passRate: number;
56
- totalDuration: number;
57
- averageDuration: number;
58
- };
59
- };
60
7
  /**
61
8
  * Batch evaluation strategy
62
9
  */
63
10
  export declare class BatchStrategy {
64
11
  private _pipeline;
65
12
  private _config;
66
- constructor(pipeline: EvaluationPipeline, config?: BatchConfig);
13
+ constructor(pipeline: EvaluationPipeline, config?: BatchEvaluationConfig);
67
14
  /**
68
15
  * Evaluate a batch of inputs
69
16
  */
70
- evaluate(inputs: ScorerInput[], options?: PipelineExecutionOptions): Promise<BatchResult>;
17
+ evaluate(inputs: ScorerInput[], options?: PipelineExecutionOptions): Promise<BatchEvaluationResult>;
71
18
  /**
72
19
  * Evaluate a single item
73
20
  */
@@ -83,18 +30,17 @@ export declare class BatchStrategy {
83
30
  /**
84
31
  * Update configuration
85
32
  */
86
- configure(config: Partial<BatchConfig>): void;
33
+ configure(config: Partial<BatchEvaluationConfig>): void;
87
34
  }
88
35
  /**
89
36
  * Create a batch strategy for a pipeline
90
37
  */
91
- export declare function createBatchStrategy(pipeline: EvaluationPipeline, config?: BatchConfig): BatchStrategy;
38
+ export declare function createBatchStrategy(pipeline: EvaluationPipeline, config?: BatchEvaluationConfig): BatchStrategy;
92
39
  /**
93
40
  * Evaluate a batch of inputs using a pipeline
94
41
  */
95
- export declare function evaluateBatch(pipeline: EvaluationPipeline, inputs: ScorerInput[], config?: BatchConfig): Promise<BatchResult>;
42
+ export declare function evaluateBatch(pipeline: EvaluationPipeline, inputs: ScorerInput[], config?: BatchEvaluationConfig): Promise<BatchEvaluationResult>;
96
43
  /**
97
44
  * Stream batch evaluation results
98
45
  */
99
- export declare function streamBatchEvaluation(pipeline: EvaluationPipeline, inputs: ScorerInput[], config?: Omit<BatchConfig, "onResult" | "onProgress">): AsyncGenerator<BatchItemResult, BatchResult["summary"], void>;
100
- export {};
46
+ export declare function streamBatchEvaluation(pipeline: EvaluationPipeline, inputs: ScorerInput[], config?: Omit<BatchEvaluationConfig, "onResult" | "onProgress">): AsyncGenerator<BatchItemResult, BatchEvaluationResult["summary"], void>;
@@ -57,7 +57,7 @@ export class BatchStrategy {
57
57
  total: inputs.length,
58
58
  completed: results.length,
59
59
  failed: results.filter((r) => r.error).length,
60
- remaining: inputs.length - results.length,
60
+ pending: inputs.length - results.length,
61
61
  percentComplete: (results.length / inputs.length) * 100,
62
62
  estimatedTimeRemaining: this._estimateRemainingTime(durations, inputs.length - results.length),
63
63
  });
@@ -76,12 +76,12 @@ export class BatchStrategy {
76
76
  results,
77
77
  summary: {
78
78
  total: inputs.length,
79
- successful: successfulResults.length,
79
+ succeeded: successfulResults.length,
80
80
  failed: results.length - successfulResults.length,
81
81
  averageScore: scores.length > 0
82
82
  ? scores.reduce((a, b) => a + b, 0) / scores.length
83
83
  : 0,
84
- passRate: successfulResults.length > 0
84
+ passingRate: successfulResults.length > 0
85
85
  ? passed.length / successfulResults.length
86
86
  : 0,
87
87
  totalDuration,
@@ -200,12 +200,12 @@ export async function* streamBatchEvaluation(pipeline, inputs, config) {
200
200
  const earlyPassed = successfulResults.filter((r) => r.result.passed);
201
201
  return {
202
202
  total: inputs.length,
203
- successful: successfulResults.length,
203
+ succeeded: successfulResults.length,
204
204
  failed: results.length - successfulResults.length,
205
205
  averageScore: earlyScores.length > 0
206
206
  ? earlyScores.reduce((a, b) => a + b, 0) / earlyScores.length
207
207
  : 0,
208
- passRate: successfulResults.length > 0
208
+ passingRate: successfulResults.length > 0
209
209
  ? earlyPassed.length / successfulResults.length
210
210
  : 0,
211
211
  totalDuration: Date.now() - startTime,
@@ -227,10 +227,10 @@ export async function* streamBatchEvaluation(pipeline, inputs, config) {
227
227
  const passed = successfulResults.filter((r) => r.result.passed);
228
228
  return {
229
229
  total: inputs.length,
230
- successful: successfulResults.length,
230
+ succeeded: successfulResults.length,
231
231
  failed: results.length - successfulResults.length,
232
232
  averageScore: scores.length > 0 ? scores.reduce((a, b) => a + b, 0) / scores.length : 0,
233
- passRate: successfulResults.length > 0
233
+ passingRate: successfulResults.length > 0
234
234
  ? passed.length / successfulResults.length
235
235
  : 0,
236
236
  totalDuration: Date.now() - startTime,