@juspay/neurolink 9.65.1 → 9.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/adapters/video/videoAnalyzer.d.ts +1 -1
  3. package/dist/agent/directTools.d.ts +9 -17
  4. package/dist/agent/directTools.js +1 -5
  5. package/dist/autoresearch/tools.d.ts +2 -214
  6. package/dist/autoresearch/tools.js +1 -1
  7. package/dist/browser/neurolink.min.js +388 -386
  8. package/dist/cli/commands/proxy.js +154 -5
  9. package/dist/client/reactHooks.js +16 -8
  10. package/dist/client/reactHooks.tsx +24 -9
  11. package/dist/core/baseProvider.d.ts +1 -6
  12. package/dist/core/baseProvider.js +1 -1
  13. package/dist/core/modules/GenerationHandler.d.ts +2 -2
  14. package/dist/core/modules/GenerationHandler.js +3 -1
  15. package/dist/core/modules/MessageBuilder.d.ts +1 -15
  16. package/dist/core/modules/MessageBuilder.js +0 -14
  17. package/dist/core/modules/StreamHandler.js +1 -1
  18. package/dist/core/modules/ToolsManager.d.ts +1 -17
  19. package/dist/core/modules/ToolsManager.js +1 -17
  20. package/dist/core/streamAnalytics.js +1 -1
  21. package/dist/evaluation/contextBuilder.d.ts +1 -4
  22. package/dist/evaluation/contextBuilder.js +0 -3
  23. package/dist/evaluation/index.d.ts +1 -4
  24. package/dist/evaluation/index.js +0 -3
  25. package/dist/files/fileTools.d.ts +2 -18
  26. package/dist/files/fileTools.js +3 -19
  27. package/dist/lib/adapters/video/videoAnalyzer.d.ts +1 -1
  28. package/dist/lib/agent/directTools.d.ts +9 -17
  29. package/dist/lib/agent/directTools.js +1 -5
  30. package/dist/lib/autoresearch/tools.d.ts +2 -214
  31. package/dist/lib/autoresearch/tools.js +1 -1
  32. package/dist/lib/client/reactHooks.js +16 -8
  33. package/dist/lib/core/baseProvider.d.ts +1 -6
  34. package/dist/lib/core/baseProvider.js +1 -1
  35. package/dist/lib/core/modules/GenerationHandler.d.ts +2 -2
  36. package/dist/lib/core/modules/GenerationHandler.js +3 -1
  37. package/dist/lib/core/modules/MessageBuilder.d.ts +1 -15
  38. package/dist/lib/core/modules/MessageBuilder.js +0 -14
  39. package/dist/lib/core/modules/StreamHandler.js +1 -1
  40. package/dist/lib/core/modules/ToolsManager.d.ts +1 -17
  41. package/dist/lib/core/modules/ToolsManager.js +1 -17
  42. package/dist/lib/core/streamAnalytics.js +1 -1
  43. package/dist/lib/evaluation/contextBuilder.d.ts +1 -4
  44. package/dist/lib/evaluation/contextBuilder.js +0 -3
  45. package/dist/lib/evaluation/index.d.ts +1 -4
  46. package/dist/lib/evaluation/index.js +0 -3
  47. package/dist/lib/files/fileTools.d.ts +2 -18
  48. package/dist/lib/files/fileTools.js +3 -19
  49. package/dist/lib/memory/memoryRetrievalTools.d.ts +2 -126
  50. package/dist/lib/memory/memoryRetrievalTools.js +1 -9
  51. package/dist/lib/middleware/builtin/autoEvaluation.d.ts +0 -3
  52. package/dist/lib/middleware/builtin/autoEvaluation.js +0 -3
  53. package/dist/lib/middleware/builtin/guardrails.js +1 -1
  54. package/dist/lib/middleware/builtin/lifecycle.d.ts +0 -9
  55. package/dist/lib/middleware/builtin/lifecycle.js +0 -9
  56. package/dist/lib/middleware/factory.d.ts +1 -1
  57. package/dist/lib/middleware/factory.js +1 -1
  58. package/dist/lib/middleware/registry.d.ts +1 -1
  59. package/dist/lib/neurolink.d.ts +14 -2
  60. package/dist/lib/neurolink.js +46 -18
  61. package/dist/lib/processors/media/AudioProcessor.js +8 -3
  62. package/dist/lib/providers/amazonBedrock.js +1 -2
  63. package/dist/lib/providers/amazonSagemaker.d.ts +1 -7
  64. package/dist/lib/providers/amazonSagemaker.js +0 -6
  65. package/dist/lib/providers/anthropic.d.ts +1 -1
  66. package/dist/lib/providers/anthropic.js +2 -1
  67. package/dist/lib/providers/anthropicBaseProvider.d.ts +1 -1
  68. package/dist/lib/providers/anthropicBaseProvider.js +2 -1
  69. package/dist/lib/providers/azureOpenai.d.ts +1 -1
  70. package/dist/lib/providers/azureOpenai.js +2 -1
  71. package/dist/lib/providers/cloudflare.d.ts +1 -1
  72. package/dist/lib/providers/cloudflare.js +2 -1
  73. package/dist/lib/providers/cohere.d.ts +1 -1
  74. package/dist/lib/providers/cohere.js +2 -1
  75. package/dist/lib/providers/deepseek.d.ts +1 -1
  76. package/dist/lib/providers/deepseek.js +2 -1
  77. package/dist/lib/providers/fireworks.d.ts +1 -1
  78. package/dist/lib/providers/fireworks.js +2 -1
  79. package/dist/lib/providers/googleAiStudio.d.ts +1 -1
  80. package/dist/lib/providers/googleAiStudio.js +0 -1
  81. package/dist/lib/providers/googleNativeGemini3.d.ts +1 -1
  82. package/dist/lib/providers/googleNativeGemini3.js +1 -1
  83. package/dist/lib/providers/googleVertex.d.ts +1 -1
  84. package/dist/lib/providers/googleVertex.js +0 -1
  85. package/dist/lib/providers/groq.d.ts +1 -1
  86. package/dist/lib/providers/groq.js +2 -1
  87. package/dist/lib/providers/huggingFace.d.ts +1 -1
  88. package/dist/lib/providers/huggingFace.js +3 -1
  89. package/dist/lib/providers/ideogram.d.ts +1 -1
  90. package/dist/lib/providers/jina.d.ts +1 -1
  91. package/dist/lib/providers/litellm.d.ts +1 -1
  92. package/dist/lib/providers/litellm.js +12 -6
  93. package/dist/lib/providers/llamaCpp.d.ts +1 -1
  94. package/dist/lib/providers/llamaCpp.js +2 -1
  95. package/dist/lib/providers/lmStudio.d.ts +1 -1
  96. package/dist/lib/providers/lmStudio.js +2 -1
  97. package/dist/lib/providers/mistral.d.ts +1 -1
  98. package/dist/lib/providers/mistral.js +2 -1
  99. package/dist/lib/providers/nvidiaNim.d.ts +1 -1
  100. package/dist/lib/providers/nvidiaNim.js +2 -1
  101. package/dist/lib/providers/ollama.d.ts +1 -1
  102. package/dist/lib/providers/ollama.js +1 -2
  103. package/dist/lib/providers/openAI.d.ts +1 -1
  104. package/dist/lib/providers/openAI.js +3 -1
  105. package/dist/lib/providers/openRouter.d.ts +1 -1
  106. package/dist/lib/providers/openRouter.js +3 -1
  107. package/dist/lib/providers/openaiCompatible.d.ts +1 -1
  108. package/dist/lib/providers/openaiCompatible.js +3 -1
  109. package/dist/lib/providers/perplexity.d.ts +1 -1
  110. package/dist/lib/providers/perplexity.js +2 -1
  111. package/dist/lib/providers/providerTypeUtils.d.ts +2 -7
  112. package/dist/lib/providers/providerTypeUtils.js +0 -6
  113. package/dist/lib/providers/recraft.d.ts +1 -1
  114. package/dist/lib/providers/replicate.d.ts +1 -1
  115. package/dist/lib/providers/stability.d.ts +1 -1
  116. package/dist/lib/providers/togetherAi.d.ts +1 -1
  117. package/dist/lib/providers/togetherAi.js +2 -1
  118. package/dist/lib/providers/voyage.d.ts +1 -1
  119. package/dist/lib/providers/xai.d.ts +1 -1
  120. package/dist/lib/providers/xai.js +2 -1
  121. package/dist/lib/proxy/claudeFormat.d.ts +0 -15
  122. package/dist/lib/proxy/claudeFormat.js +1 -11
  123. package/dist/lib/proxy/modelRouter.d.ts +5 -1
  124. package/dist/lib/proxy/modelRouter.js +8 -0
  125. package/dist/lib/proxy/openaiFormat.d.ts +137 -0
  126. package/dist/lib/proxy/openaiFormat.js +801 -0
  127. package/dist/lib/proxy/proxyTranslationEngine.d.ts +124 -0
  128. package/dist/lib/proxy/proxyTranslationEngine.js +679 -0
  129. package/dist/lib/rag/ragIntegration.d.ts +1 -12
  130. package/dist/lib/rag/ragIntegration.js +0 -8
  131. package/dist/lib/server/routes/claudeProxyRoutes.d.ts +6 -5
  132. package/dist/lib/server/routes/claudeProxyRoutes.js +22 -355
  133. package/dist/lib/server/routes/index.d.ts +1 -0
  134. package/dist/lib/server/routes/index.js +10 -2
  135. package/dist/lib/server/routes/openaiProxyRoutes.d.ts +30 -0
  136. package/dist/lib/server/routes/openaiProxyRoutes.js +337 -0
  137. package/dist/lib/tasks/tools/taskTools.d.ts +2 -117
  138. package/dist/lib/tasks/tools/taskTools.js +1 -10
  139. package/dist/lib/types/aliases.d.ts +1 -1
  140. package/dist/lib/types/conversation.d.ts +1 -0
  141. package/dist/lib/types/evaluation.d.ts +1 -5
  142. package/dist/lib/types/evaluation.js +0 -4
  143. package/dist/lib/types/generate.d.ts +2 -22
  144. package/dist/lib/types/guardrails.d.ts +1 -1
  145. package/dist/lib/types/middleware.d.ts +8 -3
  146. package/dist/lib/types/providers.d.ts +2 -1
  147. package/dist/lib/types/proxy.d.ts +179 -0
  148. package/dist/lib/types/rag.d.ts +1 -1
  149. package/dist/lib/types/rag.js +0 -6
  150. package/dist/lib/types/server.d.ts +3 -0
  151. package/dist/lib/types/stream.d.ts +2 -11
  152. package/dist/lib/types/tools.d.ts +2 -1
  153. package/dist/lib/utils/generation.d.ts +8 -0
  154. package/dist/lib/utils/generation.js +9 -0
  155. package/dist/lib/utils/generationErrors.d.ts +10 -0
  156. package/dist/lib/utils/generationErrors.js +11 -0
  157. package/dist/lib/utils/messageBuilder.d.ts +1 -6
  158. package/dist/lib/utils/messageBuilder.js +0 -5
  159. package/dist/lib/utils/noOutputSentinel.d.ts +0 -13
  160. package/dist/lib/utils/noOutputSentinel.js +1 -14
  161. package/dist/lib/utils/providerRetry.js +1 -1
  162. package/dist/lib/utils/tool.d.ts +8 -0
  163. package/dist/lib/utils/tool.js +9 -0
  164. package/dist/lib/utils/toolCallRepair.d.ts +1 -16
  165. package/dist/lib/utils/toolCallRepair.js +1 -16
  166. package/dist/lib/utils/toolChoice.d.ts +1 -1
  167. package/dist/lib/utils/videoAnalysisProcessor.d.ts +1 -8
  168. package/dist/lib/utils/videoAnalysisProcessor.js +0 -7
  169. package/dist/memory/memoryRetrievalTools.d.ts +2 -126
  170. package/dist/memory/memoryRetrievalTools.js +1 -9
  171. package/dist/middleware/builtin/autoEvaluation.d.ts +0 -3
  172. package/dist/middleware/builtin/autoEvaluation.js +0 -3
  173. package/dist/middleware/builtin/guardrails.js +1 -1
  174. package/dist/middleware/builtin/lifecycle.d.ts +0 -9
  175. package/dist/middleware/builtin/lifecycle.js +0 -9
  176. package/dist/middleware/factory.d.ts +1 -1
  177. package/dist/middleware/factory.js +1 -1
  178. package/dist/middleware/registry.d.ts +1 -1
  179. package/dist/neurolink.d.ts +14 -2
  180. package/dist/neurolink.js +46 -18
  181. package/dist/processors/media/AudioProcessor.js +8 -3
  182. package/dist/providers/amazonBedrock.js +1 -2
  183. package/dist/providers/amazonSagemaker.d.ts +1 -7
  184. package/dist/providers/amazonSagemaker.js +0 -6
  185. package/dist/providers/anthropic.d.ts +1 -1
  186. package/dist/providers/anthropic.js +2 -1
  187. package/dist/providers/anthropicBaseProvider.d.ts +1 -1
  188. package/dist/providers/anthropicBaseProvider.js +2 -1
  189. package/dist/providers/azureOpenai.d.ts +1 -1
  190. package/dist/providers/azureOpenai.js +2 -1
  191. package/dist/providers/cloudflare.d.ts +1 -1
  192. package/dist/providers/cloudflare.js +2 -1
  193. package/dist/providers/cohere.d.ts +1 -1
  194. package/dist/providers/cohere.js +2 -1
  195. package/dist/providers/deepseek.d.ts +1 -1
  196. package/dist/providers/deepseek.js +2 -1
  197. package/dist/providers/fireworks.d.ts +1 -1
  198. package/dist/providers/fireworks.js +2 -1
  199. package/dist/providers/googleAiStudio.d.ts +1 -1
  200. package/dist/providers/googleNativeGemini3.d.ts +1 -1
  201. package/dist/providers/googleNativeGemini3.js +1 -1
  202. package/dist/providers/googleVertex.d.ts +1 -1
  203. package/dist/providers/groq.d.ts +1 -1
  204. package/dist/providers/groq.js +2 -1
  205. package/dist/providers/huggingFace.d.ts +1 -1
  206. package/dist/providers/huggingFace.js +3 -1
  207. package/dist/providers/ideogram.d.ts +1 -1
  208. package/dist/providers/jina.d.ts +1 -1
  209. package/dist/providers/litellm.d.ts +1 -1
  210. package/dist/providers/litellm.js +12 -6
  211. package/dist/providers/llamaCpp.d.ts +1 -1
  212. package/dist/providers/llamaCpp.js +2 -1
  213. package/dist/providers/lmStudio.d.ts +1 -1
  214. package/dist/providers/lmStudio.js +2 -1
  215. package/dist/providers/mistral.d.ts +1 -1
  216. package/dist/providers/mistral.js +2 -1
  217. package/dist/providers/nvidiaNim.d.ts +1 -1
  218. package/dist/providers/nvidiaNim.js +2 -1
  219. package/dist/providers/ollama.d.ts +1 -1
  220. package/dist/providers/ollama.js +1 -2
  221. package/dist/providers/openAI.d.ts +1 -1
  222. package/dist/providers/openAI.js +3 -1
  223. package/dist/providers/openRouter.d.ts +1 -1
  224. package/dist/providers/openRouter.js +3 -1
  225. package/dist/providers/openaiCompatible.d.ts +1 -1
  226. package/dist/providers/openaiCompatible.js +3 -1
  227. package/dist/providers/perplexity.d.ts +1 -1
  228. package/dist/providers/perplexity.js +2 -1
  229. package/dist/providers/providerTypeUtils.d.ts +2 -7
  230. package/dist/providers/providerTypeUtils.js +0 -6
  231. package/dist/providers/recraft.d.ts +1 -1
  232. package/dist/providers/replicate.d.ts +1 -1
  233. package/dist/providers/stability.d.ts +1 -1
  234. package/dist/providers/togetherAi.d.ts +1 -1
  235. package/dist/providers/togetherAi.js +2 -1
  236. package/dist/providers/voyage.d.ts +1 -1
  237. package/dist/providers/xai.d.ts +1 -1
  238. package/dist/providers/xai.js +2 -1
  239. package/dist/proxy/claudeFormat.d.ts +0 -15
  240. package/dist/proxy/claudeFormat.js +1 -11
  241. package/dist/proxy/modelRouter.d.ts +5 -1
  242. package/dist/proxy/modelRouter.js +8 -0
  243. package/dist/proxy/openaiFormat.d.ts +137 -0
  244. package/dist/proxy/openaiFormat.js +800 -0
  245. package/dist/proxy/proxyTranslationEngine.d.ts +124 -0
  246. package/dist/proxy/proxyTranslationEngine.js +678 -0
  247. package/dist/rag/ragIntegration.d.ts +1 -12
  248. package/dist/rag/ragIntegration.js +0 -8
  249. package/dist/server/routes/claudeProxyRoutes.d.ts +6 -5
  250. package/dist/server/routes/claudeProxyRoutes.js +22 -355
  251. package/dist/server/routes/index.d.ts +1 -0
  252. package/dist/server/routes/index.js +10 -2
  253. package/dist/server/routes/openaiProxyRoutes.d.ts +30 -0
  254. package/dist/server/routes/openaiProxyRoutes.js +336 -0
  255. package/dist/tasks/tools/taskTools.d.ts +2 -117
  256. package/dist/tasks/tools/taskTools.js +1 -10
  257. package/dist/types/aliases.d.ts +1 -1
  258. package/dist/types/conversation.d.ts +1 -0
  259. package/dist/types/evaluation.d.ts +1 -5
  260. package/dist/types/evaluation.js +0 -4
  261. package/dist/types/generate.d.ts +2 -22
  262. package/dist/types/guardrails.d.ts +1 -1
  263. package/dist/types/middleware.d.ts +8 -3
  264. package/dist/types/providers.d.ts +2 -1
  265. package/dist/types/proxy.d.ts +179 -0
  266. package/dist/types/rag.d.ts +1 -1
  267. package/dist/types/rag.js +0 -6
  268. package/dist/types/server.d.ts +3 -0
  269. package/dist/types/stream.d.ts +2 -11
  270. package/dist/types/tools.d.ts +2 -1
  271. package/dist/utils/generation.d.ts +8 -0
  272. package/dist/utils/generation.js +8 -0
  273. package/dist/utils/generationErrors.d.ts +10 -0
  274. package/dist/utils/generationErrors.js +10 -0
  275. package/dist/utils/messageBuilder.d.ts +1 -6
  276. package/dist/utils/messageBuilder.js +0 -5
  277. package/dist/utils/noOutputSentinel.d.ts +0 -13
  278. package/dist/utils/noOutputSentinel.js +1 -14
  279. package/dist/utils/providerRetry.js +1 -1
  280. package/dist/utils/tool.d.ts +8 -0
  281. package/dist/utils/tool.js +8 -0
  282. package/dist/utils/toolCallRepair.d.ts +1 -16
  283. package/dist/utils/toolCallRepair.js +1 -16
  284. package/dist/utils/toolChoice.d.ts +1 -1
  285. package/dist/utils/videoAnalysisProcessor.d.ts +1 -8
  286. package/dist/utils/videoAnalysisProcessor.js +0 -7
  287. package/package.json +2 -3
@@ -1,28 +1,12 @@
1
- /**
2
- * On-Demand File Access Tools
3
- *
4
- * Exposes file operations as LLM tools via the Vercel AI SDK `tool()` pattern.
5
- * These tools allow the LLM to access file content lazily — only reading
6
- * the specific sections, lines, or search results it needs.
7
- *
8
- * Tools:
9
- * - list_attached_files: List all registered files with metadata
10
- * - read_file_section: Read specific line range with token budget
11
- * - search_in_file: Search for patterns within a file
12
- * - get_file_preview: Get the preview/summary of a file
13
- * - extract_file_content: Targeted extraction for any file type (video frames,
14
- * PDF pages, spreadsheet ranges, archive entries, PPTX slides)
15
- *
16
- * @module files/fileTools
17
- */
18
- import { tool } from "ai";
19
1
  import { z } from "zod";
2
+ import { tool } from "../utils/tool.js";
20
3
  /**
21
4
  * Create file access tools bound to a FileReferenceRegistry instance.
22
5
  *
23
6
  * These tools follow the same pattern as the existing directAgentTools
24
7
  * (getCurrentTime, readFile, etc.) in src/lib/agent/directTools.ts.
25
- * They use `tool()` from the Vercel AI SDK with zod parameter schemas.
8
+ * They use NeuroLink's `tool()` helper from `../utils/tool.js` with Zod
9
+ * parameter schemas.
26
10
  *
27
11
  * @param registry - The FileReferenceRegistry instance to bind to
28
12
  * @returns Record of tool name to tool definition
@@ -7,7 +7,7 @@
7
7
  * @module adapters/video/geminiVideoAnalyzer
8
8
  */
9
9
  import { AIProviderName } from "../../constants/enums.js";
10
- import type { ModelMessage } from "ai";
10
+ import type { ModelMessage } from "../../types/index.js";
11
11
  export declare function analyzeVideoWithVertexAI(messages: ModelMessage[], options?: {
12
12
  project?: string;
13
13
  location?: string;
@@ -1,14 +1,10 @@
1
- /**
2
- * Direct Tool Definitions for NeuroLink CLI Agent
3
- * Simple, reliable tools that work immediately with Vercel AI SDK
4
- */
5
- import type { AllToolsMap, BasicToolsMap, FilesystemToolsMap, UtilityToolsMap } from "../types/index.js";
1
+ import type { AllToolsMap, BasicToolsMap, FilesystemToolsMap, Tool, UtilityToolsMap } from "../types/index.js";
6
2
  /**
7
3
  * Direct tool definitions that work immediately with Gemini/AI SDK
8
4
  * These bypass MCP complexity and provide reliable agent functionality
9
5
  */
10
6
  export declare const directAgentTools: {
11
- getCurrentTime: import("ai").Tool<{
7
+ getCurrentTime: Tool<{
12
8
  timezone?: string | undefined;
13
9
  }, {
14
10
  success: boolean;
@@ -32,7 +28,7 @@ export declare const directAgentTools: {
32
28
  iso?: undefined;
33
29
  timestamp?: undefined;
34
30
  }>;
35
- readFile: import("ai").Tool<{
31
+ readFile: Tool<{
36
32
  path: string;
37
33
  }, {
38
34
  success: boolean;
@@ -56,7 +52,7 @@ export declare const directAgentTools: {
56
52
  size?: undefined;
57
53
  lastModified?: undefined;
58
54
  }>;
59
- listDirectory: import("ai").Tool<{
55
+ listDirectory: Tool<{
60
56
  path: string;
61
57
  includeHidden: boolean;
62
58
  }, {
@@ -77,7 +73,7 @@ export declare const directAgentTools: {
77
73
  items?: undefined;
78
74
  count?: undefined;
79
75
  }>;
80
- calculateMath: import("ai").Tool<{
76
+ calculateMath: Tool<{
81
77
  expression: string;
82
78
  precision: number;
83
79
  }, {
@@ -99,7 +95,7 @@ export declare const directAgentTools: {
99
95
  result?: undefined;
100
96
  type?: undefined;
101
97
  }>;
102
- writeFile: import("ai").Tool<{
98
+ writeFile: Tool<{
103
99
  path: string;
104
100
  content: string;
105
101
  mode: "append" | "create" | "overwrite";
@@ -125,7 +121,7 @@ export declare const directAgentTools: {
125
121
  size?: undefined;
126
122
  written?: undefined;
127
123
  }>;
128
- analyzeCSV: import("ai").Tool<{
124
+ analyzeCSV: Tool<{
129
125
  filePath: string;
130
126
  operation: "count_by_column" | "sum_by_column" | "average_by_column" | "min_max_by_column" | "describe";
131
127
  column: string;
@@ -147,7 +143,7 @@ export declare const directAgentTools: {
147
143
  operation: "count_by_column" | "sum_by_column" | "average_by_column" | "min_max_by_column" | "describe";
148
144
  column: string;
149
145
  }>;
150
- websearchGrounding: import("ai").Tool<{
146
+ websearchGrounding: Tool<{
151
147
  query: string;
152
148
  maxResults: number;
153
149
  maxWords: number;
@@ -221,11 +217,7 @@ export declare const directAgentTools: {
221
217
  * Import this directly when you need bash execution capabilities:
222
218
  * import { bashTool } from '../agent/directTools.js';
223
219
  */
224
- export declare const bashTool: import("ai").Tool<{
225
- command: string;
226
- timeout: number;
227
- cwd?: string | undefined;
228
- }, unknown>;
220
+ export declare const bashTool: Tool;
229
221
  /**
230
222
  * Get a subset of tools for specific use cases with improved type safety
231
223
  */
@@ -1,8 +1,3 @@
1
- /**
2
- * Direct Tool Definitions for NeuroLink CLI Agent
3
- * Simple, reliable tools that work immediately with Vercel AI SDK
4
- */
5
- import { tool } from "ai";
6
1
  import { z } from "zod";
7
2
  import * as fs from "fs";
8
3
  import * as path from "path";
@@ -11,6 +6,7 @@ import { logger } from "../utils/logger.js";
11
6
  import { VertexAI } from "@google-cloud/vertexai";
12
7
  import { CSVProcessor } from "../utils/csvProcessor.js";
13
8
  import { shouldEnableBashTool } from "../utils/toolUtils.js";
9
+ import { tool } from "../utils/tool.js";
14
10
  const MAX_OUTPUT_BYTES = 102400; // 100KB
15
11
  function truncateOutput(output) {
16
12
  if (output.length > MAX_OUTPUT_BYTES) {
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @module autoresearch/tools
9
9
  */
10
- import type { ExperimentRecord, ResearchToolsDeps } from "../types/index.js";
10
+ import type { ResearchToolsDeps, Tool } from "../types/index.js";
11
11
  /**
12
12
  * Create research management tools bound to a research session.
13
13
  *
@@ -24,216 +24,4 @@ import type { ExperimentRecord, ResearchToolsDeps } from "../types/index.js";
24
24
  * // tools.research_get_context, tools.research_read_file, etc.
25
25
  * ```
26
26
  */
27
- export declare function createResearchTools(deps: ResearchToolsDeps): {
28
- /**
29
- * Get current research context including state, config, and recent results.
30
- */
31
- research_get_context: import("ai").Tool<Record<string, never>, {
32
- success: boolean;
33
- error: string;
34
- branch?: undefined;
35
- acceptedCommit?: undefined;
36
- bestMetric?: undefined;
37
- recentResults?: undefined;
38
- mutablePaths?: undefined;
39
- immutablePaths?: undefined;
40
- currentPhase?: undefined;
41
- runCount?: undefined;
42
- tag?: undefined;
43
- keepCount?: undefined;
44
- } | {
45
- success: boolean;
46
- branch: string;
47
- acceptedCommit: string | null;
48
- bestMetric: number | null;
49
- recentResults: ExperimentRecord[];
50
- mutablePaths: string[];
51
- immutablePaths: string[];
52
- currentPhase: import("../types/autoresearch.js").ExperimentPhase;
53
- runCount: number;
54
- tag: string;
55
- keepCount: number;
56
- error?: undefined;
57
- }>;
58
- /**
59
- * Read a file from the repository if allowed by policy.
60
- */
61
- research_read_file: import("ai").Tool<{
62
- path: string;
63
- }, {
64
- success: boolean;
65
- error: string;
66
- path?: undefined;
67
- content?: undefined;
68
- } | {
69
- success: boolean;
70
- path: string;
71
- content: string;
72
- error?: undefined;
73
- } | {
74
- success: boolean;
75
- error: string;
76
- path: string;
77
- content?: undefined;
78
- }>;
79
- /**
80
- * Write a candidate file to the repository if allowed by policy.
81
- */
82
- research_write_candidate: import("ai").Tool<{
83
- path: string;
84
- content: string;
85
- }, {
86
- success: boolean;
87
- error: string;
88
- path?: undefined;
89
- bytesWritten?: undefined;
90
- } | {
91
- success: boolean;
92
- path: string;
93
- bytesWritten: number;
94
- error?: undefined;
95
- } | {
96
- success: boolean;
97
- error: string;
98
- path: string;
99
- bytesWritten?: undefined;
100
- }>;
101
- /**
102
- * Get git diff of mutable paths only.
103
- */
104
- research_diff: import("ai").Tool<Record<string, never>, {
105
- success: boolean;
106
- diff: string;
107
- hasChanges: boolean;
108
- error?: undefined;
109
- } | {
110
- success: boolean;
111
- error: string;
112
- diff?: undefined;
113
- hasChanges?: undefined;
114
- }>;
115
- /**
116
- * Commit staged changes as a candidate.
117
- */
118
- research_commit_candidate: import("ai").Tool<{
119
- message: string;
120
- }, {
121
- success: boolean;
122
- error: string;
123
- violations?: undefined;
124
- candidateCommit?: undefined;
125
- message?: undefined;
126
- } | {
127
- success: boolean;
128
- error: string;
129
- violations: string[];
130
- candidateCommit?: undefined;
131
- message?: undefined;
132
- } | {
133
- success: boolean;
134
- candidateCommit: string;
135
- message: string;
136
- error?: undefined;
137
- violations?: undefined;
138
- }>;
139
- /**
140
- * Run the experiment.
141
- */
142
- research_run_experiment: import("ai").Tool<{
143
- description: string;
144
- }, {
145
- success: boolean;
146
- description: string;
147
- summary: import("../types/autoresearch.js").ExperimentSummary;
148
- error?: undefined;
149
- } | {
150
- success: boolean;
151
- error: string;
152
- description?: undefined;
153
- summary?: undefined;
154
- }>;
155
- /**
156
- * Parse the experiment log file.
157
- */
158
- research_parse_log: import("ai").Tool<Record<string, never>, {
159
- success: boolean;
160
- summary: import("../types/autoresearch.js").ExperimentSummary;
161
- error?: undefined;
162
- } | {
163
- success: boolean;
164
- error: string;
165
- summary?: undefined;
166
- }>;
167
- /**
168
- * Record an experiment result.
169
- */
170
- research_record: import("ai").Tool<{
171
- description: string;
172
- }, {
173
- success: boolean;
174
- error: string;
175
- record?: undefined;
176
- } | {
177
- success: boolean;
178
- record: ExperimentRecord;
179
- error?: undefined;
180
- }>;
181
- /**
182
- * Accept the candidate commit as the new baseline.
183
- */
184
- research_accept: import("ai").Tool<Record<string, never>, {
185
- success: boolean;
186
- error: string;
187
- acceptedCommit?: undefined;
188
- bestMetric?: undefined;
189
- keepCount?: undefined;
190
- } | {
191
- success: boolean;
192
- acceptedCommit: string;
193
- bestMetric: number;
194
- keepCount: number;
195
- error?: undefined;
196
- }>;
197
- /**
198
- * Revert to the accepted commit.
199
- */
200
- research_revert: import("ai").Tool<Record<string, never>, {
201
- success: boolean;
202
- error: string;
203
- revertedTo?: undefined;
204
- } | {
205
- success: boolean;
206
- revertedTo: string;
207
- error?: undefined;
208
- }>;
209
- /**
210
- * Inspect the last 50 lines of the run log for debugging.
211
- */
212
- research_inspect_failure: import("ai").Tool<Record<string, never>, {
213
- success: boolean;
214
- tail: string;
215
- totalLines: number;
216
- error?: undefined;
217
- } | {
218
- success: boolean;
219
- error: string;
220
- tail?: undefined;
221
- totalLines?: undefined;
222
- }>;
223
- /**
224
- * Save the current state to disk.
225
- */
226
- research_checkpoint: import("ai").Tool<Record<string, never>, {
227
- success: boolean;
228
- error: string;
229
- checkpointedAt?: undefined;
230
- phase?: undefined;
231
- runCount?: undefined;
232
- } | {
233
- success: boolean;
234
- checkpointedAt: string;
235
- phase: import("../types/autoresearch.js").ExperimentPhase;
236
- runCount: number;
237
- error?: undefined;
238
- }>;
239
- };
27
+ export declare function createResearchTools(deps: ResearchToolsDeps): Record<string, Tool>;
@@ -10,11 +10,11 @@
10
10
  import { execFileSync } from "node:child_process";
11
11
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
12
12
  import path from "node:path";
13
- import { tool } from "ai";
14
13
  import { z } from "zod";
15
14
  import { withTimeout } from "../utils/errorHandling.js";
16
15
  import { logger } from "../utils/logger.js";
17
16
  import { parseExperimentSummary } from "./summaryParser.js";
17
+ import { tool } from "../utils/tool.js";
18
18
  /**
19
19
  * Create research management tools bound to a research session.
20
20
  *
@@ -254,8 +254,9 @@ export function useChat(options = {}) {
254
254
  */
255
255
  const handleSubmit = useCallback((e, submitOptions) => {
256
256
  e?.preventDefault?.();
257
- if (!input.trim())
257
+ if (!input.trim()) {
258
258
  return;
259
+ }
259
260
  const message = {
260
261
  role: "user",
261
262
  content: input,
@@ -271,8 +272,9 @@ export function useChat(options = {}) {
271
272
  // Read from the ref so we always have the latest messages
272
273
  const currentMessages = messagesRef.current;
273
274
  const lastUserMessageIndex = currentMessages.findLastIndex((m) => m.role === "user");
274
- if (lastUserMessageIndex === -1)
275
+ if (lastUserMessageIndex === -1) {
275
276
  return null;
277
+ }
276
278
  const lastUserMessage = currentMessages[lastUserMessageIndex];
277
279
  // Remove messages after the last user message
278
280
  setMessages((prev) => prev.slice(0, lastUserMessageIndex));
@@ -742,8 +744,9 @@ export function useVoice(options = {}) {
742
744
  const synthesisRef = useRef(null);
743
745
  // Check browser support
744
746
  const isSupported = useMemo(() => {
745
- if (typeof window === "undefined")
747
+ if (typeof window === "undefined") {
746
748
  return false;
749
+ }
747
750
  const hasSpeechRecognition = "SpeechRecognition" in window || "webkitSpeechRecognition" in window;
748
751
  const hasSpeechSynthesis = "speechSynthesis" in window;
749
752
  return hasSpeechRecognition || hasSpeechSynthesis;
@@ -752,12 +755,14 @@ export function useVoice(options = {}) {
752
755
  * Initialize speech recognition
753
756
  */
754
757
  const initRecognition = useCallback(() => {
755
- if (typeof window === "undefined")
758
+ if (typeof window === "undefined") {
756
759
  return null;
760
+ }
757
761
  const SpeechRecognitionCtor = window.SpeechRecognition ||
758
762
  window.webkitSpeechRecognition;
759
- if (!SpeechRecognitionCtor)
763
+ if (!SpeechRecognitionCtor) {
760
764
  return null;
765
+ }
761
766
  const recognition = new SpeechRecognitionCtor();
762
767
  recognition.continuous = true;
763
768
  recognition.interimResults = true;
@@ -795,8 +800,9 @@ export function useVoice(options = {}) {
795
800
  * Start listening for voice input
796
801
  */
797
802
  const startListening = useCallback(() => {
798
- if (!enableSpeechRecognition)
803
+ if (!enableSpeechRecognition) {
799
804
  return;
805
+ }
800
806
  if (!recognitionRef.current) {
801
807
  recognitionRef.current = initRecognition();
802
808
  }
@@ -820,8 +826,9 @@ export function useVoice(options = {}) {
820
826
  * Speak text using TTS
821
827
  */
822
828
  const speak = useCallback(async (text) => {
823
- if (typeof window === "undefined")
829
+ if (typeof window === "undefined") {
824
830
  return;
831
+ }
825
832
  setIsSpeaking(true);
826
833
  onSpeechStart?.();
827
834
  try {
@@ -1002,8 +1009,9 @@ export function useStream(options = {}) {
1002
1009
  let fullText = "";
1003
1010
  while (true) {
1004
1011
  const { done, value } = await reader.read();
1005
- if (done)
1012
+ if (done) {
1006
1013
  break;
1014
+ }
1007
1015
  buffer += decoder.decode(value, { stream: true });
1008
1016
  const lines = buffer.split("\n");
1009
1017
  buffer = lines.pop() ?? "";
@@ -1,9 +1,9 @@
1
- import type { LanguageModel, ModelMessage, Tool, ToolCallRepairFunction, ToolSet } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import type { EvaluationData } from "../index.js";
4
3
  import type { NeuroLink } from "../neurolink.js";
5
4
  import type { UnknownRecord, MiddlewareFactoryOptions, StreamOptions, StreamResult, AIProvider, AnalyticsData, EnhancedGenerateResult, TextGenerationOptions, TextGenerationResult, ValidationSchema } from "../types/index.js";
6
5
  import { TelemetryHandler } from "./modules/TelemetryHandler.js";
6
+ import type { LanguageModel, ModelMessage, Tool, ToolCallRepairFunction, ToolSet } from "../types/index.js";
7
7
  /**
8
8
  * Abstract base class for all AI providers
9
9
  * Tools are integrated as first-class citizens - always available by default
@@ -20,11 +20,6 @@ export declare abstract class BaseProvider implements AIProvider {
20
20
  protected sessionId?: string;
21
21
  protected userId?: string;
22
22
  protected neurolink?: NeuroLink;
23
- /** @internal Trace context propagated from NeuroLink SDK for span hierarchy */
24
- protected _traceContext: {
25
- traceId: string;
26
- parentSpanId: string;
27
- } | null;
28
23
  setTraceContext(ctx: {
29
24
  traceId: string;
30
25
  parentSpanId: string;
@@ -1,5 +1,4 @@
1
1
  import { context, SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
2
- import { generateText } from "ai";
3
2
  import { directAgentTools } from "../agent/directTools.js";
4
3
  import { IMAGE_GENERATION_MODELS } from "../core/constants.js";
5
4
  import { MiddlewareFactory } from "../middleware/factory.js";
@@ -21,6 +20,7 @@ import { StreamHandler } from "./modules/StreamHandler.js";
21
20
  import { TelemetryHandler } from "./modules/TelemetryHandler.js";
22
21
  import { ToolsManager } from "./modules/ToolsManager.js";
23
22
  import { Utilities } from "./modules/Utilities.js";
23
+ import { generateText } from "../utils/generation.js";
24
24
  /**
25
25
  * Abstract base class for all AI providers
26
26
  * Tools are integrated as first-class citizens - always available by default
@@ -12,9 +12,9 @@
12
12
  *
13
13
  * @module core/modules/GenerationHandler
14
14
  */
15
- import type { LanguageModel, ModelMessage, Tool } from "ai";
16
- import { generateText } from "ai";
17
15
  import type { AIProviderName, EnhancedGenerateResult, NeuroLinkEvents, StandardRecord, TextGenerationOptions, TypedEventEmitter } from "../../types/index.js";
16
+ import type { LanguageModel, ModelMessage, Tool } from "../../types/index.js";
17
+ import { generateText } from "../../utils/generation.js";
18
18
  /**
19
19
  * GenerationHandler class - Handles text generation operations for AI providers
20
20
  */
@@ -13,7 +13,6 @@
13
13
  * @module core/modules/GenerationHandler
14
14
  */
15
15
  import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
16
- import { generateText, NoObjectGeneratedError, Output, stepCountIs } from "ai";
17
16
  import { getModelId } from "../../providers/providerTypeUtils.js";
18
17
  import { tracers } from "../../telemetry/tracers.js";
19
18
  import { logger } from "../../utils/logger.js";
@@ -22,6 +21,9 @@ import { calculateCost } from "../../utils/pricing.js";
22
21
  import { withProviderRetry } from "../../utils/providerRetry.js";
23
22
  import { calculateCacheSavingsPercent, extractCacheCreationTokens, extractCacheReadTokens, extractTokenUsage, } from "../../utils/tokenUtils.js";
24
23
  import { DEFAULT_MAX_STEPS } from "../constants.js";
24
+ import { NoObjectGeneratedError } from "../../utils/generationErrors.js";
25
+ import { Output, stepCountIs } from "../../utils/tool.js";
26
+ import { generateText } from "../../utils/generation.js";
25
27
  const genTracer = tracers.generation;
26
28
  /**
27
29
  * Safely preview-serialize a value for debug logging.
@@ -1,19 +1,5 @@
1
- /**
2
- * Message Builder Module
3
- *
4
- * Handles all message construction logic for AI providers.
5
- * Extracted from BaseProvider to follow Single Responsibility Principle.
6
- *
7
- * Responsibilities:
8
- * - Building messages from text generation options
9
- * - Building messages from stream options
10
- * - Multimodal input detection
11
- * - Message format conversion (to ModelMessage[])
12
- *
13
- * @module core/modules/MessageBuilder
14
- */
15
- import type { ModelMessage } from "ai";
16
1
  import type { AIProviderName, TextGenerationOptions, StreamOptions } from "../../types/index.js";
2
+ import type { ModelMessage } from "../../types/index.js";
17
3
  /**
18
4
  * MessageBuilder class - Handles message construction for AI providers
19
5
  */
@@ -1,17 +1,3 @@
1
- /**
2
- * Message Builder Module
3
- *
4
- * Handles all message construction logic for AI providers.
5
- * Extracted from BaseProvider to follow Single Responsibility Principle.
6
- *
7
- * Responsibilities:
8
- * - Building messages from text generation options
9
- * - Building messages from stream options
10
- * - Multimodal input detection
11
- * - Message format conversion (to ModelMessage[])
12
- *
13
- * @module core/modules/MessageBuilder
14
- */
15
1
  import { tracers, ATTR, withSpan } from "../../telemetry/index.js";
16
2
  import { logger } from "../../utils/logger.js";
17
3
  import { buildMessagesArray, buildMultimodalMessagesArray, } from "../../utils/messageBuilder.js";
@@ -20,7 +20,7 @@ import { buildNoOutputSentinel, detectPostStreamNoOutput, stampNoOutputSpan, } f
20
20
  import { STEP_LIMITS } from "../constants.js";
21
21
  import { createAnalytics } from "../analytics.js";
22
22
  import { nanoid } from "nanoid";
23
- import { NoOutputGeneratedError } from "ai";
23
+ import { NoOutputGeneratedError } from "../../utils/generationErrors.js";
24
24
  /**
25
25
  * StreamHandler class - Handles streaming operations for AI providers
26
26
  */
@@ -1,22 +1,6 @@
1
- /**
2
- * Tools Manager Module
3
- *
4
- * Handles all tool registration, discovery, and execution for AI providers.
5
- * Extracted from BaseProvider to follow Single Responsibility Principle.
6
- *
7
- * Responsibilities:
8
- * - Tool registration (direct, custom, MCP, external MCP)
9
- * - Tool discovery and aggregation
10
- * - Tool creation from definitions and schemas
11
- * - Tool executor setup
12
- * - Session context management for MCP tools
13
- * - Event emission wrapping for tool execution
14
- *
15
- * @module core/modules/ToolsManager
16
- */
17
- import type { Tool } from "ai";
18
1
  import type { AIProviderName, ToolUtilities } from "../../types/index.js";
19
2
  import type { NeuroLink } from "../../neurolink.js";
3
+ import type { Tool } from "../../types/index.js";
20
4
  /**
21
5
  * ToolsManager class - Handles all tool management operations
22
6
  */
@@ -1,20 +1,3 @@
1
- /**
2
- * Tools Manager Module
3
- *
4
- * Handles all tool registration, discovery, and execution for AI providers.
5
- * Extracted from BaseProvider to follow Single Responsibility Principle.
6
- *
7
- * Responsibilities:
8
- * - Tool registration (direct, custom, MCP, external MCP)
9
- * - Tool discovery and aggregation
10
- * - Tool creation from definitions and schemas
11
- * - Tool executor setup
12
- * - Session context management for MCP tools
13
- * - Event emission wrapping for tool execution
14
- *
15
- * @module core/modules/ToolsManager
16
- */
17
- import { tool as createAISDKTool, jsonSchema } from "ai";
18
1
  import { z } from "zod";
19
2
  import { createToolEventPayload } from "../toolEvents.js";
20
3
  import { tracers, ATTR, withSpan } from "../../telemetry/index.js";
@@ -23,6 +6,7 @@ import { logger } from "../../utils/logger.js";
23
6
  import { getKeyCount } from "../../utils/transformationUtils.js";
24
7
  import { convertJsonSchemaToZod } from "../../utils/schemaConversion.js";
25
8
  import { generateToolOutputPreview } from "../../context/toolOutputLimits.js";
9
+ import { tool as createAISDKTool, jsonSchema } from "../../utils/tool.js";
26
10
  /**
27
11
  * ToolsManager class - Handles all tool management operations
28
12
  */
@@ -1,7 +1,7 @@
1
1
  import { createAnalytics } from "./analytics.js";
2
2
  import { logger } from "../utils/logger.js";
3
3
  import { extractTokenUsage, createEmptyTokenUsage, } from "../utils/tokenUtils.js";
4
- import { NoOutputGeneratedError } from "ai";
4
+ import { NoOutputGeneratedError } from "../utils/generationErrors.js";
5
5
  /**
6
6
  * Base implementation for collecting analytics from Vercel AI SDK stream results
7
7
  */
@@ -1,8 +1,5 @@
1
- /**
2
- * @file Implements the ContextBuilder class for creating rich evaluation context.
3
- */
4
- import type { LanguageModelV3CallOptions } from "@ai-sdk/provider";
5
1
  import type { EnhancedEvaluationContext, EvaluationResult, GenerateResult } from "../types/index.js";
2
+ import type { LanguageModelV3CallOptions } from "../types/index.js";
6
3
  /**
7
4
  * Builds the enhanced context required for a RAGAS-style evaluation.
8
5
  * This class gathers data from the generation options and results to create a
@@ -1,6 +1,3 @@
1
- /**
2
- * @file Implements the ContextBuilder class for creating rich evaluation context.
3
- */
4
1
  import { logger } from "../utils/logger.js";
5
2
  /**
6
3
  * Builds the enhanced context required for a RAGAS-style evaluation.
@@ -1,8 +1,5 @@
1
- /**
2
- * @file This file exports the main Evaluator class, which serves as the central entry point for the evaluation system.
3
- */
4
- import type { LanguageModelV3CallOptions } from "@ai-sdk/provider";
5
1
  import type { EvaluationData, GenerateResult, AutoEvaluationConfig, EvaluationConfig } from "../types/index.js";
2
+ import type { LanguageModelV3CallOptions } from "../types/index.js";
6
3
  export * from "./errors/index.js";
7
4
  export * from "./hooks/index.js";
8
5
  export * from "./pipeline/index.js";