@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
@@ -2,6 +2,8 @@ import { AIProviderFactory } from "../core/factory.js";
2
2
  import { PromptBuilder } from "./prompts.js";
3
3
  import { logger } from "../utils/logger.js";
4
4
  import { SpanSerializer, SpanType, SpanStatus, getMetricsAggregator, } from "../observability/index.js";
5
+ import { withSpan } from "../telemetry/withSpan.js";
6
+ import { tracers } from "../telemetry/tracers.js";
5
7
  /**
6
8
  * Implements a RAGAS-style evaluator that uses a "judge" LLM to score the
7
9
  * quality of an AI response based on rich, contextual information.
@@ -33,45 +35,60 @@ export class RAGASEvaluator {
33
35
  * @returns A promise that resolves to a detailed `EvaluationResult`.
34
36
  */
35
37
  async evaluate(context) {
36
- const span = SpanSerializer.createSpan(SpanType.EVALUATION, "evaluation.ragas", {
37
- "evaluation.dimension": "relevance|accuracy|completeness",
38
- "ai.provider": this.providerName,
39
- "ai.model": this.evaluationModel,
40
- });
41
- const startTime = Date.now();
42
- try {
43
- const prompt = this.promptBuilder.buildEvaluationPrompt(context, this.promptGenerator);
44
- const provider = await AIProviderFactory.createProvider(this.providerName, this.evaluationModel);
45
- const result = await provider.generate({
46
- input: { text: prompt },
38
+ return withSpan({
39
+ name: "neurolink.evaluation.ragas",
40
+ tracer: tracers.sdk,
41
+ attributes: {
42
+ "evaluation.provider": this.providerName,
43
+ "evaluation.model": this.evaluationModel,
44
+ },
45
+ }, async (otelSpan) => {
46
+ const span = SpanSerializer.createSpan(SpanType.EVALUATION, "evaluation.ragas", {
47
+ "evaluation.dimension": "relevance|accuracy|completeness",
48
+ "ai.provider": this.providerName,
49
+ "ai.model": this.evaluationModel,
47
50
  });
48
- if (!result) {
49
- throw new Error("Evaluation generation failed to return a result.");
51
+ const startTime = Date.now();
52
+ try {
53
+ const prompt = this.promptBuilder.buildEvaluationPrompt(context, this.promptGenerator);
54
+ const provider = await AIProviderFactory.createProvider(this.providerName, this.evaluationModel);
55
+ const result = await provider.generate({
56
+ input: { text: prompt },
57
+ });
58
+ if (!result) {
59
+ throw new Error("Evaluation generation failed to return a result.");
60
+ }
61
+ const rawEvaluationResponse = result.content;
62
+ const parsedResult = this.parseEvaluationResponse(rawEvaluationResponse);
63
+ const evaluationTime = Date.now() - startTime;
64
+ const finalResult = {
65
+ ...parsedResult,
66
+ isPassing: parsedResult.finalScore >= this.threshold, // This will be recalculated, but is needed for the type
67
+ evaluationModel: this.evaluationModel,
68
+ evaluationTime,
69
+ attemptNumber: context.attemptNumber,
70
+ rawEvaluationResponse,
71
+ };
72
+ // Write evaluation scores to OTel span for Langfuse visibility
73
+ otelSpan.setAttribute("evaluation.relevance_score", finalResult.relevanceScore);
74
+ otelSpan.setAttribute("evaluation.accuracy_score", finalResult.accuracyScore);
75
+ otelSpan.setAttribute("evaluation.completeness_score", finalResult.completenessScore);
76
+ otelSpan.setAttribute("evaluation.final_score", finalResult.finalScore);
77
+ otelSpan.setAttribute("evaluation.is_passing", finalResult.isPassing);
78
+ span.durationMs = Date.now() - startTime;
79
+ const endedSpan = SpanSerializer.endSpan(span, SpanStatus.OK);
80
+ getMetricsAggregator().recordSpan(endedSpan);
81
+ return finalResult;
50
82
  }
51
- const rawEvaluationResponse = result.content;
52
- const parsedResult = this.parseEvaluationResponse(rawEvaluationResponse);
53
- const evaluationTime = Date.now() - startTime;
54
- const finalResult = {
55
- ...parsedResult,
56
- isPassing: parsedResult.finalScore >= this.threshold, // This will be recalculated, but is needed for the type
57
- evaluationModel: this.evaluationModel,
58
- evaluationTime,
59
- attemptNumber: context.attemptNumber,
60
- rawEvaluationResponse,
61
- };
62
- span.durationMs = Date.now() - startTime;
63
- const endedSpan = SpanSerializer.endSpan(span, SpanStatus.OK);
64
- getMetricsAggregator().recordSpan(endedSpan);
65
- return finalResult;
66
- }
67
- catch (error) {
68
- span.durationMs = Date.now() - startTime;
69
- const endedSpan = SpanSerializer.endSpan(span, SpanStatus.ERROR);
70
- endedSpan.statusMessage =
71
- error instanceof Error ? error.message : String(error);
72
- getMetricsAggregator().recordSpan(endedSpan);
73
- throw error;
74
- }
83
+ catch (error) {
84
+ span.durationMs = Date.now() - startTime;
85
+ const endedSpan = SpanSerializer.endSpan(span, SpanStatus.ERROR);
86
+ endedSpan.statusMessage =
87
+ error instanceof Error ? error.message : String(error);
88
+ getMetricsAggregator().recordSpan(endedSpan);
89
+ throw error;
90
+ }
91
+ }); // end withSpan
75
92
  }
76
93
  /**
77
94
  * Parses the raw JSON string from the judge LLM into a structured `EvaluationResult` object.
@@ -2,65 +2,7 @@
2
2
  * @file Metrics Collector
3
3
  * Collect and aggregate evaluation metrics
4
4
  */
5
- import type { ScoreResult, PipelineResult } from "../../types/index.js";
6
- /**
7
- * Scorer metrics
8
- */
9
- type ScorerMetrics = {
10
- scorerId: string;
11
- scorerName: string;
12
- totalExecutions: number;
13
- successfulExecutions: number;
14
- failedExecutions: number;
15
- passedCount: number;
16
- failedCount: number;
17
- totalScore: number;
18
- minScore: number;
19
- maxScore: number;
20
- totalDuration: number;
21
- averageDuration: number;
22
- averageScore: number;
23
- passRate: number;
24
- lastExecutionTime: number;
25
- };
26
- /**
27
- * Pipeline metrics
28
- */
29
- type PipelineMetrics = {
30
- pipelineName: string;
31
- totalExecutions: number;
32
- passedCount: number;
33
- failedCount: number;
34
- totalScore: number;
35
- minScore: number;
36
- maxScore: number;
37
- totalDuration: number;
38
- averageDuration: number;
39
- averageScore: number;
40
- passRate: number;
41
- lastExecutionTime: number;
42
- scorerMetrics: Map<string, ScorerMetrics>;
43
- };
44
- /**
45
- * Aggregated metrics
46
- */
47
- type AggregatedMetrics = {
48
- totalEvaluations: number;
49
- overallPassRate: number;
50
- averageScore: number;
51
- averageDuration: number;
52
- scoreDistribution: {
53
- excellent: number;
54
- good: number;
55
- fair: number;
56
- poor: number;
57
- failing: number;
58
- };
59
- pipelineMetrics: Map<string, PipelineMetrics>;
60
- scorerMetrics: Map<string, ScorerMetrics>;
61
- collectionStartTime: number;
62
- lastUpdateTime: number;
63
- };
5
+ import type { AggregatedMetrics, PipelineMetrics, PipelineResult, ScoreResult, ScorerMetrics } from "../../types/index.js";
64
6
  /**
65
7
  * Metrics collector for evaluation data
66
8
  */
@@ -144,4 +86,3 @@ export declare function createMetricsCollector(): MetricsCollector;
144
86
  * Global metrics collector instance
145
87
  */
146
88
  export declare const globalMetricsCollector: MetricsCollector;
147
- export {};
@@ -2,22 +2,7 @@
2
2
  * @file Report Generator
3
3
  * Generate evaluation reports in various formats
4
4
  */
5
- import type { ReportData, ReportConfig, ReportFormat } from "../../types/index.js";
6
- /**
7
- * Generated report
8
- */
9
- type GeneratedReport = {
10
- /** Report format */
11
- format: ReportFormat;
12
- /** Report content */
13
- content: string;
14
- /** Metadata */
15
- metadata: {
16
- generatedAt: number;
17
- format: ReportFormat;
18
- config: ReportConfig;
19
- };
20
- };
5
+ import type { GeneratedReport, ReportConfig, ReportData } from "../../types/index.js";
21
6
  /**
22
7
  * Report generator class
23
8
  */
@@ -70,4 +55,3 @@ export declare const Reports: {
70
55
  /** Generate HTML report */
71
56
  html: (data: ReportData) => GeneratedReport;
72
57
  };
73
- export {};
@@ -2,35 +2,8 @@
2
2
  * @file Content Similarity Scorer
3
3
  * Evaluates text similarity using various metrics (Jaccard, cosine, Levenshtein)
4
4
  */
5
- import type { RuleScorerConfig, ScoreResult, ScorerInput } from "../../../types/index.js";
5
+ import type { ContentSimilarityConfig, ScoreResult, ScorerInput } from "../../../types/index.js";
6
6
  import { BaseScorer } from "../baseScorer.js";
7
- /**
8
- * Similarity metric types
9
- */
10
- type SimilarityMetric = "jaccard" | "cosine" | "levenshtein" | "dice" | "overlap";
11
- /**
12
- * Configuration specific to content similarity scoring
13
- */
14
- type ContentSimilarityConfig = RuleScorerConfig & {
15
- /** Similarity metric to use */
16
- metric?: SimilarityMetric;
17
- /** Multiple metrics to combine */
18
- metrics?: SimilarityMetric[];
19
- /** How to combine multiple metrics */
20
- metricCombination?: "average" | "min" | "max" | "weighted";
21
- /** Weights for each metric (if weighted combination) */
22
- metricWeights?: Record<SimilarityMetric, number>;
23
- /** Whether to normalize text before comparison */
24
- normalizeText?: boolean;
25
- /** Whether to use word-level or character-level comparison */
26
- tokenLevel?: "word" | "character" | "ngram";
27
- /** N-gram size if using ngram tokenization */
28
- ngramSize?: number;
29
- /** Compare against ground truth, context, or custom reference */
30
- compareWith?: "groundTruth" | "context" | "custom";
31
- /** Custom reference text if compareWith is "custom" */
32
- referenceText?: string;
33
- };
34
7
  /**
35
8
  * ContentSimilarityScorer evaluates how similar the response is to a reference text
36
9
  */
@@ -106,4 +79,3 @@ export declare class ContentSimilarityScorer extends BaseScorer {
106
79
  * Factory function for creating ContentSimilarityScorer instances
107
80
  */
108
81
  export declare function createContentSimilarityScorer(config?: ContentSimilarityConfig): Promise<ContentSimilarityScorer>;
109
- export {};
@@ -2,48 +2,8 @@
2
2
  * @file Format Scorer
3
3
  * Evaluates response format compliance (JSON, markdown, code, etc.)
4
4
  */
5
- import type { RuleScorerConfig, ScoreResult, ScorerInput, ScorerRule } from "../../../types/index.js";
5
+ import type { FormatScorerConfig, ScoreResult, ScorerInput, ScorerRule } from "../../../types/index.js";
6
6
  import { BaseRuleScorer } from "./baseRuleScorer.js";
7
- /**
8
- * Expected format types
9
- */
10
- type FormatType = "json" | "markdown" | "code" | "list" | "numbered-list" | "bullet-list" | "table" | "yaml" | "xml" | "plain" | "html" | "custom";
11
- /**
12
- * Code language types for code format validation
13
- */
14
- type CodeLanguage = "javascript" | "typescript" | "python" | "java" | "c" | "cpp" | "csharp" | "go" | "rust" | "sql" | "bash" | "any";
15
- /**
16
- * Configuration specific to format scoring
17
- */
18
- type FormatScorerConfig = RuleScorerConfig & {
19
- /** Expected format type */
20
- expectedFormat?: FormatType;
21
- /** Multiple allowed formats */
22
- allowedFormats?: FormatType[];
23
- /** For code format: expected language */
24
- codeLanguage?: CodeLanguage;
25
- /** For JSON format: validate against schema */
26
- jsonSchema?: object;
27
- /** For markdown: required elements */
28
- markdownRequirements?: {
29
- hasHeadings?: boolean;
30
- hasCodeBlocks?: boolean;
31
- hasLinks?: boolean;
32
- hasLists?: boolean;
33
- minHeadingLevel?: number;
34
- maxHeadingLevel?: number;
35
- };
36
- /** For list format: requirements */
37
- listRequirements?: {
38
- minItems?: number;
39
- maxItems?: number;
40
- itemPattern?: string;
41
- };
42
- /** Custom format regex pattern */
43
- customPattern?: string;
44
- /** Whether format must be exclusive (no other content) */
45
- strictFormat?: boolean;
46
- };
47
7
  /**
48
8
  * FormatScorer evaluates response format against expected formats
49
9
  */
@@ -145,4 +105,3 @@ export declare const FormatScorerPresets: {
145
105
  /** Plain text only */
146
106
  readonly plainText: () => FormatScorer;
147
107
  };
148
- export {};
@@ -2,25 +2,8 @@
2
2
  * @file Keyword Coverage Scorer
3
3
  * Evaluates how well the response covers expected keywords or topics
4
4
  */
5
- import type { RuleScorerConfig, ScoreResult, ScorerInput, ScorerRule } from "../../../types/index.js";
5
+ import type { KeywordCoverageConfig, ScoreResult, ScorerInput, ScorerRule } from "../../../types/index.js";
6
6
  import { BaseRuleScorer } from "./baseRuleScorer.js";
7
- /**
8
- * Configuration specific to keyword coverage scoring
9
- */
10
- type KeywordCoverageConfig = RuleScorerConfig & {
11
- /** Keywords to check for */
12
- keywords?: string[];
13
- /** Minimum coverage ratio (0-1) to pass */
14
- minCoverage?: number;
15
- /** Whether to use case-insensitive matching */
16
- caseInsensitive?: boolean;
17
- /** Whether to use word boundary matching */
18
- wordBoundary?: boolean;
19
- /** Synonyms map for flexible matching */
20
- synonyms?: Record<string, string[]>;
21
- /** Weight different keywords differently */
22
- keywordWeights?: Record<string, number>;
23
- };
24
7
  /**
25
8
  * KeywordCoverageScorer evaluates how well a response covers expected keywords
26
9
  */
@@ -81,4 +64,3 @@ export declare class KeywordCoverageScorer extends BaseRuleScorer {
81
64
  * Factory function for creating KeywordCoverageScorer instances
82
65
  */
83
66
  export declare function createKeywordCoverageScorer(config?: KeywordCoverageConfig): Promise<KeywordCoverageScorer>;
84
- export {};
@@ -2,39 +2,8 @@
2
2
  * @file Length Scorer
3
3
  * Evaluates response length against configured constraints
4
4
  */
5
- import type { RuleScorerConfig, ScoreResult, ScorerInput, ScorerRule } from "../../../types/index.js";
5
+ import type { LengthScorerConfig, ScoreResult, ScorerInput, ScorerRule } from "../../../types/index.js";
6
6
  import { BaseRuleScorer } from "./baseRuleScorer.js";
7
- /**
8
- * Length measurement unit
9
- */
10
- type LengthUnit = "words" | "characters" | "sentences" | "paragraphs" | "tokens";
11
- /**
12
- * Length constraint type
13
- */
14
- type LengthConstraintType = "exact" | "range" | "minimum" | "maximum" | "ratio";
15
- /**
16
- * Configuration specific to length scoring
17
- */
18
- type LengthScorerConfig = RuleScorerConfig & {
19
- /** Unit of measurement */
20
- unit?: LengthUnit;
21
- /** Constraint type */
22
- constraintType?: LengthConstraintType;
23
- /** Minimum length (for range/minimum constraints) */
24
- minLength?: number;
25
- /** Maximum length (for range/maximum constraints) */
26
- maxLength?: number;
27
- /** Exact length (for exact constraint) */
28
- exactLength?: number;
29
- /** Tolerance for exact length (as percentage) */
30
- tolerance?: number;
31
- /** Compare ratio with query/context length */
32
- ratioTarget?: number;
33
- /** Ratio reference: compare against query or context */
34
- ratioReference?: "query" | "context";
35
- /** Scoring mode: binary (pass/fail) or proportional */
36
- scoringMode?: "binary" | "proportional";
37
- };
38
7
  /**
39
8
  * LengthScorer evaluates response length against configurable constraints
40
9
  */
@@ -103,4 +72,3 @@ export declare const LengthScorerPresets: {
103
72
  /** Tweet-length (max 280 characters) */
104
73
  readonly tweet: () => LengthScorer;
105
74
  };
106
- export {};
@@ -1,19 +1,5 @@
1
1
  import type { AIProviderName } from "../constants/enums.js";
2
- import type { UnknownRecord, AIProvider, NeurolinkCredentials } from "../types/index.js";
3
- /**
4
- * Provider constructor interface - supports both sync constructors and async factory functions
5
- */
6
- type ProviderConstructor = {
7
- new (modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string): AIProvider;
8
- } | ((modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string) => Promise<AIProvider>);
9
- /**
10
- * Provider registration entry
11
- */
12
- type ProviderRegistration = {
13
- constructor: ProviderConstructor;
14
- defaultModel?: string;
15
- aliases?: string[];
16
- };
2
+ import type { AIProvider, NeurolinkCredentials, ProviderConstructor, ProviderRegistration, UnknownRecord } from "../types/index.js";
17
3
  /**
18
4
  * True Factory Pattern implementation for AI Providers
19
5
  * Uses registration-based approach to eliminate switch statements
@@ -72,4 +58,3 @@ export declare class ProviderFactory {
72
58
  * Helper function to create providers with backward compatibility
73
59
  */
74
60
  export declare function createAIProvider(providerName: AIProviderName | string, modelName?: string, credentials?: NeurolinkCredentials): Promise<AIProvider>;
75
- export {};
@@ -1,4 +1,6 @@
1
1
  import { logger } from "../utils/logger.js";
2
+ // Pure factory pattern with no hardcoded imports
3
+ // All providers loaded dynamically via registry to avoid circular dependencies
2
4
  /**
3
5
  * True Factory Pattern implementation for AI Providers
4
6
  * Uses registration-based approach to eliminate switch statements
@@ -26,6 +26,9 @@
26
26
  * ```
27
27
  */
28
28
  import type { ImageGenConfig, ImageGenOptions, ImageGenResult } from "../types/index.js";
29
+ /**
30
+ * NeuroLink instance type (avoiding circular dependencies)
31
+ */
29
32
  /**
30
33
  * Image generation service for AI-powered image creation
31
34
  *
@@ -27,6 +27,9 @@
27
27
  */
28
28
  import { withTimeout } from "../utils/errorHandling.js";
29
29
  import { DEFAULT_IMAGE_GEN_CONFIG } from "../types/index.js";
30
+ /**
31
+ * NeuroLink instance type (avoiding circular dependencies)
32
+ */
30
33
  /**
31
34
  * Image generation service for AI-powered image creation
32
35
  *
@@ -2,7 +2,7 @@
2
2
  * GitHub Action input parsing and validation
3
3
  * @module action/actionInputs
4
4
  */
5
- import type { ActionInputs, ActionProviderKeys, ActionInputValidation, ActionAWSConfig, ActionGoogleCloudConfig } from "../types/index.js";
5
+ import type { ActionAWSConfig, ActionGoogleCloudConfig, ActionInputValidation, ActionInputs, ActionProviderKeys } from "../types/index.js";
6
6
  /**
7
7
  * Mask all secrets in logs
8
8
  */
@@ -168,6 +168,9 @@ async function readImageFromDisk(filePath, segmentIndex) {
168
168
  });
169
169
  }
170
170
  }
171
+ // ============================================================================
172
+ // PHASE 1: PARALLEL CLIP GENERATION (with circuit breaker)
173
+ // ============================================================================
171
174
  /**
172
175
  * Process clip completions in order to maintain an accurate consecutive failure count.
173
176
  * This prevents out-of-order completions from incorrectly resetting the failure streak.
@@ -307,6 +310,9 @@ async function generateClips(segments, videoOptions, region) {
307
310
  });
308
311
  return state.results;
309
312
  }
313
+ // ============================================================================
314
+ // PHASE 2: PARALLEL TRANSITION GENERATION
315
+ // ============================================================================
310
316
  /**
311
317
  * Extract boundary frames and generate transition clips in parallel.
312
318
  *
@@ -437,6 +437,12 @@ export async function generateVideoWithVertex(image, prompt, options = {}, regio
437
437
  });
438
438
  }
439
439
  }
440
+ // ============================================================================
441
+ // POLLING HELPERS
442
+ // ============================================================================
443
+ /**
444
+ * Vertex AI operation result type for type safety
445
+ */
440
446
  /**
441
447
  * Extract video buffer from completed operation result
442
448
  *
@@ -2,6 +2,7 @@
2
2
  * Direct Tool Definitions for NeuroLink CLI Agent
3
3
  * Simple, reliable tools that work immediately with Vercel AI SDK
4
4
  */
5
+ import type { AllToolsMap, BasicToolsMap, FilesystemToolsMap, UtilityToolsMap } from "../types/index.js";
5
6
  /**
6
7
  * Direct tool definitions that work immediately with Gemini/AI SDK
7
8
  * These bypass MCP complexity and provide reliable agent functionality
@@ -101,7 +102,7 @@ export declare const directAgentTools: {
101
102
  writeFile: import("ai").Tool<{
102
103
  path: string;
103
104
  content: string;
104
- mode: "create" | "overwrite" | "append";
105
+ mode: "append" | "create" | "overwrite";
105
106
  }, {
106
107
  success: boolean;
107
108
  error: string;
@@ -112,7 +113,7 @@ export declare const directAgentTools: {
112
113
  } | {
113
114
  success: boolean;
114
115
  path: string;
115
- mode: "create" | "overwrite" | "append";
116
+ mode: "append" | "create" | "overwrite";
116
117
  size: number;
117
118
  written: number;
118
119
  error?: undefined;
@@ -225,26 +226,6 @@ export declare const bashTool: import("ai").Tool<{
225
226
  timeout: number;
226
227
  cwd?: string | undefined;
227
228
  }, unknown>;
228
- /**
229
- * Type aliases for specific tool categories
230
- */
231
- type BasicToolsMap = {
232
- getCurrentTime: typeof directAgentTools.getCurrentTime;
233
- calculateMath: typeof directAgentTools.calculateMath;
234
- };
235
- type FilesystemToolsMap = {
236
- readFile: typeof directAgentTools.readFile;
237
- listDirectory: typeof directAgentTools.listDirectory;
238
- writeFile: typeof directAgentTools.writeFile;
239
- };
240
- type UtilityToolsMap = {
241
- getCurrentTime: typeof directAgentTools.getCurrentTime;
242
- calculateMath: typeof directAgentTools.calculateMath;
243
- listDirectory: typeof directAgentTools.listDirectory;
244
- };
245
- type AllToolsMap = typeof directAgentTools & {
246
- executeBashCommand?: typeof bashTool;
247
- };
248
229
  /**
249
230
  * Get a subset of tools for specific use cases with improved type safety
250
231
  */
@@ -260,4 +241,3 @@ export declare function getAvailableToolNames(): string[];
260
241
  * Validate that all tools have proper structure
261
242
  */
262
243
  export declare function validateToolStructure(): boolean;
263
- export {};
@@ -5,8 +5,7 @@
5
5
  * extension, no singleton instance. Providers are registered by
6
6
  * AuthProviderRegistry using dynamic imports to avoid circular dependencies.
7
7
  */
8
- import type { AuthProviderConfig, AuthProviderMetadata, MastraAuthProvider } from "../types/index.js";
9
- type AuthProviderConstructor = (config: AuthProviderConfig) => Promise<MastraAuthProvider>;
8
+ import type { AuthProviderConfig, AuthProviderConstructor, AuthProviderMetadata, MastraAuthProvider } from "../types/index.js";
10
9
  /**
11
10
  * AuthProviderFactory - Creates authentication provider instances
12
11
  *
@@ -68,4 +67,3 @@ export declare class AuthProviderFactory {
68
67
  * Create an auth provider using the factory
69
68
  */
70
69
  export declare function createAuthProvider(type: string, config: AuthProviderConfig): Promise<MastraAuthProvider>;
71
- export {};
@@ -15,6 +15,7 @@
15
15
  * @module auth/anthropicOAuth
16
16
  */
17
17
  import type { Server } from "http";
18
+ import type { ClaudeCodeIdentity } from "../types/index.js";
18
19
  /**
19
20
  * Claude Code's official OAuth client ID
20
21
  * Used to authenticate with Anthropic's OAuth system
@@ -46,12 +47,6 @@ export declare const DEFAULT_SCOPES: readonly string[];
46
47
  export declare const CLAUDE_CODE_VERSION = "2.1.87.6d6";
47
48
  export declare const CLAUDE_CODE_ENTRYPOINT = "sdk-cli";
48
49
  export declare const CLAUDE_CLI_USER_AGENT = "claude-cli/2.1.87 (external, sdk-cli)";
49
- type ClaudeCodeIdentity = {
50
- deviceId: string;
51
- accountUuid: string;
52
- sessionId: string;
53
- metadataUserId: string;
54
- };
55
50
  export declare function parseClaudeCodeUserId(userId: unknown): ClaudeCodeIdentity | null;
56
51
  export declare function getOrCreateClaudeCodeIdentity(seed: string, options?: {
57
52
  existingUserId?: unknown;
@@ -214,6 +209,7 @@ export declare class AnthropicOAuth {
214
209
  * ```
215
210
  */
216
211
  exchangeCodeForTokens(code: string, codeVerifier: string, config?: AnthropicOAuthConfig): Promise<OAuthFlowTokens>;
212
+ private _exchangeCodeForTokens;
217
213
  /**
218
214
  * Refreshes an expired access token using a refresh token
219
215
  *
@@ -231,6 +227,7 @@ export declare class AnthropicOAuth {
231
227
  * ```
232
228
  */
233
229
  refreshAccessToken(refreshToken: string, config?: AnthropicOAuthConfig): Promise<OAuthFlowTokens>;
230
+ private _refreshAccessToken;
234
231
  /**
235
232
  * Validates an access token and returns token information
236
233
  *
@@ -268,6 +265,7 @@ export declare class AnthropicOAuth {
268
265
  * @throws OAuthTokenRevocationError if revocation fails
269
266
  */
270
267
  revokeToken(token: string, tokenType?: "access_token" | "refresh_token"): Promise<void>;
268
+ private _revokeToken;
271
269
  /**
272
270
  * Build the list of token endpoint URLs to try, with optional fallback.
273
271
  *
@@ -400,4 +398,3 @@ export declare function performOAuthFlow(oauth: AnthropicOAuth, options?: {
400
398
  /** Whether to automatically open browser (default: true) */
401
399
  openBrowser?: boolean;
402
400
  }): Promise<OAuthFlowTokens>;
403
- export {};
@@ -18,6 +18,8 @@ import { createHash, createHmac, randomBytes, randomUUID } from "crypto";
18
18
  import { createServer, IncomingMessage, ServerResponse } from "http";
19
19
  import { OAuthError, OAuthConfigurationError, OAuthTokenExchangeError, OAuthTokenRefreshError, OAuthTokenRevocationError, OAuthCallbackServerError, } from "../types/index.js";
20
20
  import { logger } from "../utils/logger.js";
21
+ import { withSpan } from "../telemetry/withSpan.js";
22
+ import { tracers } from "../telemetry/tracers.js";
21
23
  /**
22
24
  * HTML-escape a string to prevent XSS when embedding in HTML responses.
23
25
  */
@@ -467,6 +469,13 @@ export class AnthropicOAuth {
467
469
  * ```
468
470
  */
469
471
  async exchangeCodeForTokens(code, codeVerifier, config = {}) {
472
+ return withSpan({
473
+ name: "neurolink.auth.oauth.exchange_code",
474
+ tracer: tracers.auth,
475
+ attributes: { "auth.oauth.grant_type": "authorization_code" },
476
+ }, async () => this._exchangeCodeForTokens(code, codeVerifier, config));
477
+ }
478
+ async _exchangeCodeForTokens(code, codeVerifier, config = {}) {
470
479
  if (!code) {
471
480
  throw new OAuthTokenExchangeError("Authorization code is required");
472
481
  }
@@ -555,6 +564,13 @@ export class AnthropicOAuth {
555
564
  * ```
556
565
  */
557
566
  async refreshAccessToken(refreshToken, config = {}) {
567
+ return withSpan({
568
+ name: "neurolink.auth.oauth.refresh",
569
+ tracer: tracers.auth,
570
+ attributes: { "auth.oauth.grant_type": "refresh_token" },
571
+ }, async () => this._refreshAccessToken(refreshToken, config));
572
+ }
573
+ async _refreshAccessToken(refreshToken, config = {}) {
558
574
  if (!refreshToken) {
559
575
  throw new OAuthTokenRefreshError("Refresh token is required");
560
576
  }
@@ -751,6 +767,13 @@ export class AnthropicOAuth {
751
767
  * @throws OAuthTokenRevocationError if revocation fails
752
768
  */
753
769
  async revokeToken(token, tokenType = "access_token") {
770
+ return withSpan({
771
+ name: "neurolink.auth.oauth.revoke",
772
+ tracer: tracers.auth,
773
+ attributes: { "auth.oauth.token_type": tokenType },
774
+ }, async () => this._revokeToken(token, tokenType));
775
+ }
776
+ async _revokeToken(token, tokenType = "access_token") {
754
777
  if (!token) {
755
778
  throw new OAuthTokenRevocationError("Token is required for revocation");
756
779
  }