@juspay/neurolink 9.65.1 → 9.65.2

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 (258) hide show
  1. package/CHANGELOG.md +2 -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 +369 -375
  8. package/dist/client/reactHooks.js +16 -8
  9. package/dist/client/reactHooks.tsx +24 -9
  10. package/dist/core/baseProvider.d.ts +1 -6
  11. package/dist/core/baseProvider.js +1 -1
  12. package/dist/core/modules/GenerationHandler.d.ts +2 -2
  13. package/dist/core/modules/GenerationHandler.js +3 -1
  14. package/dist/core/modules/MessageBuilder.d.ts +1 -15
  15. package/dist/core/modules/MessageBuilder.js +0 -14
  16. package/dist/core/modules/StreamHandler.js +1 -1
  17. package/dist/core/modules/ToolsManager.d.ts +1 -17
  18. package/dist/core/modules/ToolsManager.js +1 -17
  19. package/dist/core/streamAnalytics.js +1 -1
  20. package/dist/evaluation/contextBuilder.d.ts +1 -4
  21. package/dist/evaluation/contextBuilder.js +0 -3
  22. package/dist/evaluation/index.d.ts +1 -4
  23. package/dist/evaluation/index.js +0 -3
  24. package/dist/files/fileTools.d.ts +2 -18
  25. package/dist/files/fileTools.js +3 -19
  26. package/dist/lib/adapters/video/videoAnalyzer.d.ts +1 -1
  27. package/dist/lib/agent/directTools.d.ts +9 -17
  28. package/dist/lib/agent/directTools.js +1 -5
  29. package/dist/lib/autoresearch/tools.d.ts +2 -214
  30. package/dist/lib/autoresearch/tools.js +1 -1
  31. package/dist/lib/client/reactHooks.js +16 -8
  32. package/dist/lib/core/baseProvider.d.ts +1 -6
  33. package/dist/lib/core/baseProvider.js +1 -1
  34. package/dist/lib/core/modules/GenerationHandler.d.ts +2 -2
  35. package/dist/lib/core/modules/GenerationHandler.js +3 -1
  36. package/dist/lib/core/modules/MessageBuilder.d.ts +1 -15
  37. package/dist/lib/core/modules/MessageBuilder.js +0 -14
  38. package/dist/lib/core/modules/StreamHandler.js +1 -1
  39. package/dist/lib/core/modules/ToolsManager.d.ts +1 -17
  40. package/dist/lib/core/modules/ToolsManager.js +1 -17
  41. package/dist/lib/core/streamAnalytics.js +1 -1
  42. package/dist/lib/evaluation/contextBuilder.d.ts +1 -4
  43. package/dist/lib/evaluation/contextBuilder.js +0 -3
  44. package/dist/lib/evaluation/index.d.ts +1 -4
  45. package/dist/lib/evaluation/index.js +0 -3
  46. package/dist/lib/files/fileTools.d.ts +2 -18
  47. package/dist/lib/files/fileTools.js +3 -19
  48. package/dist/lib/memory/memoryRetrievalTools.d.ts +2 -126
  49. package/dist/lib/memory/memoryRetrievalTools.js +1 -9
  50. package/dist/lib/middleware/builtin/autoEvaluation.d.ts +0 -3
  51. package/dist/lib/middleware/builtin/autoEvaluation.js +0 -3
  52. package/dist/lib/middleware/builtin/guardrails.js +1 -1
  53. package/dist/lib/middleware/builtin/lifecycle.d.ts +0 -9
  54. package/dist/lib/middleware/builtin/lifecycle.js +0 -9
  55. package/dist/lib/middleware/factory.d.ts +1 -1
  56. package/dist/lib/middleware/factory.js +1 -1
  57. package/dist/lib/middleware/registry.d.ts +1 -1
  58. package/dist/lib/neurolink.d.ts +14 -2
  59. package/dist/lib/neurolink.js +46 -18
  60. package/dist/lib/processors/media/AudioProcessor.js +8 -3
  61. package/dist/lib/providers/amazonBedrock.js +1 -2
  62. package/dist/lib/providers/amazonSagemaker.d.ts +1 -7
  63. package/dist/lib/providers/amazonSagemaker.js +0 -6
  64. package/dist/lib/providers/anthropic.d.ts +1 -1
  65. package/dist/lib/providers/anthropic.js +2 -1
  66. package/dist/lib/providers/anthropicBaseProvider.d.ts +1 -1
  67. package/dist/lib/providers/anthropicBaseProvider.js +2 -1
  68. package/dist/lib/providers/azureOpenai.d.ts +1 -1
  69. package/dist/lib/providers/azureOpenai.js +2 -1
  70. package/dist/lib/providers/cloudflare.d.ts +1 -1
  71. package/dist/lib/providers/cloudflare.js +2 -1
  72. package/dist/lib/providers/cohere.d.ts +1 -1
  73. package/dist/lib/providers/cohere.js +2 -1
  74. package/dist/lib/providers/deepseek.d.ts +1 -1
  75. package/dist/lib/providers/deepseek.js +2 -1
  76. package/dist/lib/providers/fireworks.d.ts +1 -1
  77. package/dist/lib/providers/fireworks.js +2 -1
  78. package/dist/lib/providers/googleAiStudio.d.ts +1 -1
  79. package/dist/lib/providers/googleAiStudio.js +0 -1
  80. package/dist/lib/providers/googleNativeGemini3.d.ts +1 -1
  81. package/dist/lib/providers/googleNativeGemini3.js +1 -1
  82. package/dist/lib/providers/googleVertex.d.ts +1 -1
  83. package/dist/lib/providers/googleVertex.js +0 -1
  84. package/dist/lib/providers/groq.d.ts +1 -1
  85. package/dist/lib/providers/groq.js +2 -1
  86. package/dist/lib/providers/huggingFace.d.ts +1 -1
  87. package/dist/lib/providers/huggingFace.js +3 -1
  88. package/dist/lib/providers/ideogram.d.ts +1 -1
  89. package/dist/lib/providers/jina.d.ts +1 -1
  90. package/dist/lib/providers/litellm.d.ts +1 -1
  91. package/dist/lib/providers/litellm.js +12 -6
  92. package/dist/lib/providers/llamaCpp.d.ts +1 -1
  93. package/dist/lib/providers/llamaCpp.js +2 -1
  94. package/dist/lib/providers/lmStudio.d.ts +1 -1
  95. package/dist/lib/providers/lmStudio.js +2 -1
  96. package/dist/lib/providers/mistral.d.ts +1 -1
  97. package/dist/lib/providers/mistral.js +2 -1
  98. package/dist/lib/providers/nvidiaNim.d.ts +1 -1
  99. package/dist/lib/providers/nvidiaNim.js +2 -1
  100. package/dist/lib/providers/ollama.d.ts +1 -1
  101. package/dist/lib/providers/ollama.js +1 -2
  102. package/dist/lib/providers/openAI.d.ts +1 -1
  103. package/dist/lib/providers/openAI.js +3 -1
  104. package/dist/lib/providers/openRouter.d.ts +1 -1
  105. package/dist/lib/providers/openRouter.js +3 -1
  106. package/dist/lib/providers/openaiCompatible.d.ts +1 -1
  107. package/dist/lib/providers/openaiCompatible.js +3 -1
  108. package/dist/lib/providers/perplexity.d.ts +1 -1
  109. package/dist/lib/providers/perplexity.js +2 -1
  110. package/dist/lib/providers/providerTypeUtils.d.ts +2 -7
  111. package/dist/lib/providers/providerTypeUtils.js +0 -6
  112. package/dist/lib/providers/recraft.d.ts +1 -1
  113. package/dist/lib/providers/replicate.d.ts +1 -1
  114. package/dist/lib/providers/stability.d.ts +1 -1
  115. package/dist/lib/providers/togetherAi.d.ts +1 -1
  116. package/dist/lib/providers/togetherAi.js +2 -1
  117. package/dist/lib/providers/voyage.d.ts +1 -1
  118. package/dist/lib/providers/xai.d.ts +1 -1
  119. package/dist/lib/providers/xai.js +2 -1
  120. package/dist/lib/proxy/claudeFormat.d.ts +0 -15
  121. package/dist/lib/proxy/claudeFormat.js +1 -11
  122. package/dist/lib/rag/ragIntegration.d.ts +1 -12
  123. package/dist/lib/rag/ragIntegration.js +0 -8
  124. package/dist/lib/tasks/tools/taskTools.d.ts +2 -117
  125. package/dist/lib/tasks/tools/taskTools.js +1 -10
  126. package/dist/lib/types/aliases.d.ts +1 -1
  127. package/dist/lib/types/conversation.d.ts +1 -0
  128. package/dist/lib/types/evaluation.d.ts +1 -5
  129. package/dist/lib/types/evaluation.js +0 -4
  130. package/dist/lib/types/generate.d.ts +2 -22
  131. package/dist/lib/types/guardrails.d.ts +1 -1
  132. package/dist/lib/types/middleware.d.ts +8 -3
  133. package/dist/lib/types/providers.d.ts +2 -1
  134. package/dist/lib/types/rag.d.ts +1 -1
  135. package/dist/lib/types/rag.js +0 -6
  136. package/dist/lib/types/stream.d.ts +2 -11
  137. package/dist/lib/types/tools.d.ts +2 -1
  138. package/dist/lib/utils/generation.d.ts +8 -0
  139. package/dist/lib/utils/generation.js +9 -0
  140. package/dist/lib/utils/generationErrors.d.ts +10 -0
  141. package/dist/lib/utils/generationErrors.js +11 -0
  142. package/dist/lib/utils/messageBuilder.d.ts +1 -6
  143. package/dist/lib/utils/messageBuilder.js +0 -5
  144. package/dist/lib/utils/noOutputSentinel.d.ts +0 -13
  145. package/dist/lib/utils/noOutputSentinel.js +1 -14
  146. package/dist/lib/utils/providerRetry.js +1 -1
  147. package/dist/lib/utils/tool.d.ts +8 -0
  148. package/dist/lib/utils/tool.js +9 -0
  149. package/dist/lib/utils/toolCallRepair.d.ts +1 -16
  150. package/dist/lib/utils/toolCallRepair.js +1 -16
  151. package/dist/lib/utils/toolChoice.d.ts +1 -1
  152. package/dist/lib/utils/videoAnalysisProcessor.d.ts +1 -8
  153. package/dist/lib/utils/videoAnalysisProcessor.js +0 -7
  154. package/dist/memory/memoryRetrievalTools.d.ts +2 -126
  155. package/dist/memory/memoryRetrievalTools.js +1 -9
  156. package/dist/middleware/builtin/autoEvaluation.d.ts +0 -3
  157. package/dist/middleware/builtin/autoEvaluation.js +0 -3
  158. package/dist/middleware/builtin/guardrails.js +1 -1
  159. package/dist/middleware/builtin/lifecycle.d.ts +0 -9
  160. package/dist/middleware/builtin/lifecycle.js +0 -9
  161. package/dist/middleware/factory.d.ts +1 -1
  162. package/dist/middleware/factory.js +1 -1
  163. package/dist/middleware/registry.d.ts +1 -1
  164. package/dist/neurolink.d.ts +14 -2
  165. package/dist/neurolink.js +46 -18
  166. package/dist/processors/media/AudioProcessor.js +8 -3
  167. package/dist/providers/amazonBedrock.js +1 -2
  168. package/dist/providers/amazonSagemaker.d.ts +1 -7
  169. package/dist/providers/amazonSagemaker.js +0 -6
  170. package/dist/providers/anthropic.d.ts +1 -1
  171. package/dist/providers/anthropic.js +2 -1
  172. package/dist/providers/anthropicBaseProvider.d.ts +1 -1
  173. package/dist/providers/anthropicBaseProvider.js +2 -1
  174. package/dist/providers/azureOpenai.d.ts +1 -1
  175. package/dist/providers/azureOpenai.js +2 -1
  176. package/dist/providers/cloudflare.d.ts +1 -1
  177. package/dist/providers/cloudflare.js +2 -1
  178. package/dist/providers/cohere.d.ts +1 -1
  179. package/dist/providers/cohere.js +2 -1
  180. package/dist/providers/deepseek.d.ts +1 -1
  181. package/dist/providers/deepseek.js +2 -1
  182. package/dist/providers/fireworks.d.ts +1 -1
  183. package/dist/providers/fireworks.js +2 -1
  184. package/dist/providers/googleAiStudio.d.ts +1 -1
  185. package/dist/providers/googleNativeGemini3.d.ts +1 -1
  186. package/dist/providers/googleNativeGemini3.js +1 -1
  187. package/dist/providers/googleVertex.d.ts +1 -1
  188. package/dist/providers/groq.d.ts +1 -1
  189. package/dist/providers/groq.js +2 -1
  190. package/dist/providers/huggingFace.d.ts +1 -1
  191. package/dist/providers/huggingFace.js +3 -1
  192. package/dist/providers/ideogram.d.ts +1 -1
  193. package/dist/providers/jina.d.ts +1 -1
  194. package/dist/providers/litellm.d.ts +1 -1
  195. package/dist/providers/litellm.js +12 -6
  196. package/dist/providers/llamaCpp.d.ts +1 -1
  197. package/dist/providers/llamaCpp.js +2 -1
  198. package/dist/providers/lmStudio.d.ts +1 -1
  199. package/dist/providers/lmStudio.js +2 -1
  200. package/dist/providers/mistral.d.ts +1 -1
  201. package/dist/providers/mistral.js +2 -1
  202. package/dist/providers/nvidiaNim.d.ts +1 -1
  203. package/dist/providers/nvidiaNim.js +2 -1
  204. package/dist/providers/ollama.d.ts +1 -1
  205. package/dist/providers/ollama.js +1 -2
  206. package/dist/providers/openAI.d.ts +1 -1
  207. package/dist/providers/openAI.js +3 -1
  208. package/dist/providers/openRouter.d.ts +1 -1
  209. package/dist/providers/openRouter.js +3 -1
  210. package/dist/providers/openaiCompatible.d.ts +1 -1
  211. package/dist/providers/openaiCompatible.js +3 -1
  212. package/dist/providers/perplexity.d.ts +1 -1
  213. package/dist/providers/perplexity.js +2 -1
  214. package/dist/providers/providerTypeUtils.d.ts +2 -7
  215. package/dist/providers/providerTypeUtils.js +0 -6
  216. package/dist/providers/recraft.d.ts +1 -1
  217. package/dist/providers/replicate.d.ts +1 -1
  218. package/dist/providers/stability.d.ts +1 -1
  219. package/dist/providers/togetherAi.d.ts +1 -1
  220. package/dist/providers/togetherAi.js +2 -1
  221. package/dist/providers/voyage.d.ts +1 -1
  222. package/dist/providers/xai.d.ts +1 -1
  223. package/dist/providers/xai.js +2 -1
  224. package/dist/proxy/claudeFormat.d.ts +0 -15
  225. package/dist/proxy/claudeFormat.js +1 -11
  226. package/dist/rag/ragIntegration.d.ts +1 -12
  227. package/dist/rag/ragIntegration.js +0 -8
  228. package/dist/tasks/tools/taskTools.d.ts +2 -117
  229. package/dist/tasks/tools/taskTools.js +1 -10
  230. package/dist/types/aliases.d.ts +1 -1
  231. package/dist/types/conversation.d.ts +1 -0
  232. package/dist/types/evaluation.d.ts +1 -5
  233. package/dist/types/evaluation.js +0 -4
  234. package/dist/types/generate.d.ts +2 -22
  235. package/dist/types/guardrails.d.ts +1 -1
  236. package/dist/types/middleware.d.ts +8 -3
  237. package/dist/types/providers.d.ts +2 -1
  238. package/dist/types/rag.d.ts +1 -1
  239. package/dist/types/rag.js +0 -6
  240. package/dist/types/stream.d.ts +2 -11
  241. package/dist/types/tools.d.ts +2 -1
  242. package/dist/utils/generation.d.ts +8 -0
  243. package/dist/utils/generation.js +8 -0
  244. package/dist/utils/generationErrors.d.ts +10 -0
  245. package/dist/utils/generationErrors.js +10 -0
  246. package/dist/utils/messageBuilder.d.ts +1 -6
  247. package/dist/utils/messageBuilder.js +0 -5
  248. package/dist/utils/noOutputSentinel.d.ts +0 -13
  249. package/dist/utils/noOutputSentinel.js +1 -14
  250. package/dist/utils/providerRetry.js +1 -1
  251. package/dist/utils/tool.d.ts +8 -0
  252. package/dist/utils/tool.js +8 -0
  253. package/dist/utils/toolCallRepair.d.ts +1 -16
  254. package/dist/utils/toolCallRepair.js +1 -16
  255. package/dist/utils/toolChoice.d.ts +1 -1
  256. package/dist/utils/videoAnalysisProcessor.d.ts +1 -8
  257. package/dist/utils/videoAnalysisProcessor.js +0 -7
  258. package/package.json +2 -3
@@ -11,11 +11,11 @@
11
11
  import { randomUUID } from "node:crypto";
12
12
  import { existsSync, readFileSync } from "node:fs";
13
13
  import { extname } from "node:path";
14
- import { jsonSchema as aiJsonSchema, tool as createAISDKTool, } from "ai";
15
14
  import { DEFAULT_MAX_STEPS, DEFAULT_TOOL_MAX_RETRIES, } from "../core/constants.js";
16
15
  import { logger } from "../utils/logger.js";
17
16
  import { convertZodToJsonSchema, ensureNestedSchemaTypes, inlineJsonSchema, isZodSchema, normalizeJsonSchemaObject, } from "../utils/schemaConversion.js";
18
17
  import { createNativeThinkingConfig } from "../utils/thinkingConfig.js";
18
+ import { jsonSchema as aiJsonSchema, tool as createAISDKTool, } from "../utils/tool.js";
19
19
  // ── Functions ──
20
20
  /**
21
21
  * Google's `function_declarations[].name` validator regex.
@@ -1,8 +1,8 @@
1
1
  import type { ZodType } from "zod";
2
- import { type Schema, type LanguageModel } from "ai";
3
2
  import { AIProviderName } from "../constants/enums.js";
4
3
  import { BaseProvider } from "../core/baseProvider.js";
5
4
  import type { EnhancedGenerateResult, TextGenerationOptions, StreamOptions, StreamResult } from "../types/index.js";
5
+ import type { Schema, LanguageModel } from "../types/index.js";
6
6
  /**
7
7
  * Resolve the effective Vertex region for a given model.
8
8
  *
@@ -1,7 +1,7 @@
1
- import { type LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * Groq Provider
7
7
  *
@@ -1,5 +1,4 @@
1
1
  import { createOpenAI } from "@ai-sdk/openai";
2
- import { stepCountIs, streamText } from "ai";
3
2
  import { GroqModels } from "../constants/enums.js";
4
3
  import { BaseProvider } from "../core/baseProvider.js";
5
4
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
14
13
  import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
15
14
  import { resolveToolChoice } from "../utils/toolChoice.js";
16
15
  import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
16
+ import { stepCountIs } from "../utils/tool.js";
17
+ import { streamText } from "../utils/generation.js";
17
18
  const GROQ_DEFAULT_BASE_URL = "https://api.groq.com/openai/v1";
18
19
  const getGroqApiKey = () => validateApiKey(createGroqConfig());
19
20
  const getDefaultGroqModel = () => getProviderModel("GROQ_MODEL", GroqModels.LLAMA_3_3_70B_VERSATILE);
@@ -1,8 +1,8 @@
1
- import { type LanguageModel, type Schema } from "ai";
2
1
  import type { ZodType } from "zod";
3
2
  import type { AIProviderName } from "../constants/enums.js";
4
3
  import { BaseProvider } from "../core/baseProvider.js";
5
4
  import type { NeurolinkCredentials, StreamOptions, StreamResult } from "../types/index.js";
5
+ import type { LanguageModel, Schema } from "../types/index.js";
6
6
  /**
7
7
  * HuggingFace Provider - BaseProvider Implementation
8
8
  * Using AI SDK with HuggingFace's OpenAI-compatible endpoint
@@ -1,5 +1,4 @@
1
1
  import { createOpenAI } from "@ai-sdk/openai";
2
- import { NoOutputGeneratedError, stepCountIs, streamText, } from "ai";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
5
4
  import { createProxyFetch } from "../proxy/proxyFetch.js";
@@ -10,6 +9,9 @@ import { buildNoOutputSentinel, detectPostStreamNoOutput, stampNoOutputSpan, } f
10
9
  import { createHuggingFaceConfig, getProviderModel, validateApiKey, } from "../utils/providerConfig.js";
11
10
  import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
12
11
  import { resolveToolChoice } from "../utils/toolChoice.js";
12
+ import { NoOutputGeneratedError } from "../utils/generationErrors.js";
13
+ import { stepCountIs } from "../utils/tool.js";
14
+ import { streamText } from "../utils/generation.js";
13
15
  // Configuration helpers - now using consolidated utility
14
16
  const getHuggingFaceApiKey = () => {
15
17
  return validateApiKey(createHuggingFaceConfig());
@@ -1,7 +1,7 @@
1
- import type { LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { EnhancedGenerateResult, NeurolinkCredentials, StreamOptions, StreamResult, TextGenerationOptions, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * Ideogram Provider — direct image generation with strong typography.
7
7
  *
@@ -1,7 +1,7 @@
1
- import type { LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * Jina AI Provider — embeddings + reranking.
7
7
  *
@@ -1,8 +1,8 @@
1
- import { type LanguageModel, type Schema } from "ai";
2
1
  import type { ZodType } from "zod";
3
2
  import type { AIProviderName } from "../constants/enums.js";
4
3
  import { BaseProvider } from "../core/baseProvider.js";
5
4
  import type { StreamOptions, StreamResult } from "../types/index.js";
5
+ import type { LanguageModel, Schema } from "../types/index.js";
6
6
  /**
7
7
  * LiteLLM Provider - BaseProvider Implementation
8
8
  * Provides access to 100+ models via LiteLLM proxy server
@@ -1,6 +1,5 @@
1
1
  import { createOpenAI } from "@ai-sdk/openai";
2
2
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
3
- import { NoOutputGeneratedError, Output, stepCountIs, streamText, } from "ai";
4
3
  import { BaseProvider } from "../core/baseProvider.js";
5
4
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
6
5
  import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
@@ -12,9 +11,12 @@ import { logger } from "../utils/logger.js";
12
11
  import { buildNoOutputSentinel, detectPostStreamNoOutput, stampNoOutputSpan, } from "../utils/noOutputSentinel.js";
13
12
  import { calculateCost } from "../utils/pricing.js";
14
13
  import { getProviderModel } from "../utils/providerConfig.js";
15
- import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
14
+ import { composeAbortSignals, createTimeoutController, TimeoutError, withTimeout, } from "../utils/timeout.js";
16
15
  import { resolveToolChoice } from "../utils/toolChoice.js";
17
16
  import { getModelId } from "./providerTypeUtils.js";
17
+ import { NoOutputGeneratedError } from "../utils/generationErrors.js";
18
+ import { Output, stepCountIs } from "../utils/tool.js";
19
+ import { streamText } from "../utils/generation.js";
18
20
  const streamTracer = trace.getTracer("neurolink.provider.litellm");
19
21
  // Configuration helpers
20
22
  const getLiteLLMConfig = () => {
@@ -425,7 +427,7 @@ export class LiteLLMProvider extends BaseProvider {
425
427
  * Uses the LiteLLM proxy with OpenAI-compatible embedding API
426
428
  */
427
429
  async embed(text, modelName) {
428
- const { embed: aiEmbed } = await import("ai");
430
+ const { embed: aiEmbed } = await import("../utils/generation.js");
429
431
  const { createOpenAI } = await import("@ai-sdk/openai");
430
432
  const config = getLiteLLMConfig();
431
433
  const embeddingModelName = modelName ||
@@ -437,7 +439,10 @@ export class LiteLLMProvider extends BaseProvider {
437
439
  fetch: createProxyFetch(),
438
440
  });
439
441
  const embeddingModel = customOpenAI.textEmbeddingModel(embeddingModelName);
440
- const result = await aiEmbed({ model: embeddingModel, value: text });
442
+ // Wrap in withTimeout so stalled upstream embedding requests abort instead
443
+ // of hanging forever. 30s matches the default for embedding endpoints
444
+ // across the OpenAI-compatible cluster.
445
+ const result = await withTimeout(aiEmbed({ model: embeddingModel, value: text }), 30_000, "litellm", "generate");
441
446
  return result.embedding;
442
447
  }
443
448
  /**
@@ -445,7 +450,7 @@ export class LiteLLMProvider extends BaseProvider {
445
450
  * Uses the LiteLLM proxy with OpenAI-compatible embedding API
446
451
  */
447
452
  async embedMany(texts, modelName) {
448
- const { embedMany: aiEmbedMany } = await import("ai");
453
+ const { embedMany: aiEmbedMany } = await import("../utils/generation.js");
449
454
  const { createOpenAI } = await import("@ai-sdk/openai");
450
455
  const config = getLiteLLMConfig();
451
456
  const embeddingModelName = modelName ||
@@ -457,7 +462,8 @@ export class LiteLLMProvider extends BaseProvider {
457
462
  fetch: createProxyFetch(),
458
463
  });
459
464
  const embeddingModel = customOpenAI.textEmbeddingModel(embeddingModelName);
460
- const result = await aiEmbedMany({ model: embeddingModel, values: texts });
465
+ // Wrap in withTimeout so a single slow batch doesn't hang indefinitely.
466
+ const result = await withTimeout(aiEmbedMany({ model: embeddingModel, values: texts }), 30_000, "litellm", "generate");
461
467
  return result.embeddings;
462
468
  }
463
469
  /**
@@ -1,7 +1,7 @@
1
- import { type LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * llama.cpp Provider
7
7
  * Wraps a llama-server process (https://github.com/ggerganov/llama.cpp) that
@@ -1,5 +1,4 @@
1
1
  import { createOpenAI } from "@ai-sdk/openai";
2
- import { stepCountIs, streamText } from "ai";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
5
4
  import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
@@ -13,6 +12,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
13
12
  import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
14
13
  import { resolveToolChoice } from "../utils/toolChoice.js";
15
14
  import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
15
+ import { stepCountIs } from "../utils/tool.js";
16
+ import { streamText } from "../utils/generation.js";
16
17
  const LLAMACPP_DEFAULT_BASE_URL = "http://localhost:8080/v1";
17
18
  const LLAMACPP_PLACEHOLDER_KEY = "llamacpp";
18
19
  const FALLBACK_MODEL = "loaded-model";
@@ -1,7 +1,7 @@
1
- import { type LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * LM Studio Provider
7
7
  * Wraps the LM Studio local server (https://lmstudio.ai/) which exposes an
@@ -1,5 +1,4 @@
1
1
  import { createOpenAI } from "@ai-sdk/openai";
2
- import { stepCountIs, streamText } from "ai";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
5
4
  import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
@@ -13,6 +12,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
13
12
  import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
14
13
  import { resolveToolChoice } from "../utils/toolChoice.js";
15
14
  import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
15
+ import { stepCountIs } from "../utils/tool.js";
16
+ import { streamText } from "../utils/generation.js";
16
17
  const LM_STUDIO_DEFAULT_BASE_URL = "http://localhost:1234/v1";
17
18
  const LM_STUDIO_PLACEHOLDER_KEY = "lm-studio";
18
19
  const FALLBACK_MODEL = "local-model";
@@ -1,7 +1,7 @@
1
- import { type LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * Mistral AI Provider v2 - BaseProvider Implementation
7
7
  * Supports official AI-SDK integration with all Mistral models
@@ -1,5 +1,4 @@
1
1
  import { createMistral } from "@ai-sdk/mistral";
2
- import { stepCountIs, streamText } from "ai";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
5
4
  import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
@@ -12,6 +11,8 @@ import { createMistralConfig, getProviderModel, validateApiKey, } from "../utils
12
11
  import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
13
12
  import { resolveToolChoice } from "../utils/toolChoice.js";
14
13
  import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
14
+ import { stepCountIs } from "../utils/tool.js";
15
+ import { streamText } from "../utils/generation.js";
15
16
  // Configuration helpers - now using consolidated utility
16
17
  const getMistralApiKey = () => {
17
18
  return validateApiKey(createMistralConfig());
@@ -1,7 +1,7 @@
1
- import { type LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * NVIDIA NIM Provider
7
7
  * Wraps NVIDIA's hosted (or self-hosted) inference endpoints via OpenAI-compat.
@@ -1,5 +1,4 @@
1
1
  import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
2
- import { stepCountIs, streamText } from "ai";
3
2
  import { NvidiaNimModels } from "../constants/enums.js";
4
3
  import { BaseProvider } from "../core/baseProvider.js";
5
4
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
14
13
  import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
15
14
  import { resolveToolChoice } from "../utils/toolChoice.js";
16
15
  import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
16
+ import { stepCountIs } from "../utils/tool.js";
17
+ import { streamText } from "../utils/generation.js";
17
18
  /**
18
19
  * Decide whether a NIM 400 response body is a rejection of the named
19
20
  * field (as opposed to an unrelated 400 that happens to mention the
@@ -1,7 +1,7 @@
1
- import type { LanguageModel, Schema } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { StreamOptions, StreamResult, ZodUnknownSchema } from "../types/index.js";
4
+ import type { LanguageModel, Schema } from "../types/index.js";
5
5
  /**
6
6
  * Ollama Provider v2 - BaseProvider Implementation
7
7
  *
@@ -706,8 +706,7 @@ export class OllamaProvider extends BaseProvider {
706
706
  let iteration = 0;
707
707
  // Get all available tools (direct + MCP + external)
708
708
  // BaseProvider.stream() pre-merges base tools + external tools into options.tools
709
- const allTools = options.tools ||
710
- (await this.getAllTools());
709
+ const allTools = options.tools || (await this.getAllTools());
711
710
  // Convert tools to Ollama format
712
711
  const ollamaTools = this.convertToolsToOllamaFormat(allTools);
713
712
  span.setAttribute(ATTR.NL_TOOL_COUNT, ollamaTools.length);
@@ -1,8 +1,8 @@
1
- import { type LanguageModel } from "ai";
2
1
  import { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { NeuroLink } from "../neurolink.js";
5
4
  import type { EnhancedGenerateResult, TextGenerationOptions, ValidationSchema, StreamOptions, StreamResult } from "../types/index.js";
5
+ import type { LanguageModel } from "../types/index.js";
6
6
  /**
7
7
  * OpenAI Provider v2 - BaseProvider Implementation
8
8
  * Migrated to use factory pattern with exact Google AI provider pattern
@@ -1,6 +1,5 @@
1
1
  import { createOpenAI } from "@ai-sdk/openai";
2
2
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
3
- import { embed, embedMany, NoOutputGeneratedError, stepCountIs, streamText, } from "ai";
4
3
  import { AIProviderName } from "../constants/enums.js";
5
4
  import { BaseProvider } from "../core/baseProvider.js";
6
5
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
@@ -18,6 +17,9 @@ import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
18
17
  import { MAX_IMAGE_BYTES, readBoundedBuffer } from "../utils/sizeGuard.js";
19
18
  import { assertSafeUrl } from "../utils/ssrfGuard.js";
20
19
  import { getModelId } from "./providerTypeUtils.js";
20
+ import { NoOutputGeneratedError } from "../utils/generationErrors.js";
21
+ import { stepCountIs } from "../utils/tool.js";
22
+ import { embed, embedMany, streamText } from "../utils/generation.js";
21
23
  /**
22
24
  * Retrieve a tool's schema, handling both AI SDK v6 (`inputSchema`) and
23
25
  * legacy v4 (`parameters`) field names.
@@ -1,8 +1,8 @@
1
- import { type LanguageModel, type Schema } from "ai";
2
1
  import type { ZodType } from "zod";
3
2
  import { AIProviderName } from "../constants/enums.js";
4
3
  import { BaseProvider } from "../core/baseProvider.js";
5
4
  import type { StreamOptions, StreamResult } from "../types/index.js";
5
+ import type { LanguageModel, Schema } from "../types/index.js";
6
6
  /**
7
7
  * OpenRouter Provider - BaseProvider Implementation
8
8
  * Provides access to 300+ models from 60+ providers via OpenRouter unified gateway
@@ -1,5 +1,4 @@
1
1
  import { createOpenRouter } from "@openrouter/ai-sdk-provider";
2
- import { NoOutputGeneratedError, Output, stepCountIs, streamText, } from "ai";
3
2
  import { AIProviderName } from "../constants/enums.js";
4
3
  import { BaseProvider } from "../core/baseProvider.js";
5
4
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
@@ -13,6 +12,9 @@ import { buildNoOutputSentinel, detectPostStreamNoOutput, stampNoOutputSpan, } f
13
12
  import { getProviderModel } from "../utils/providerConfig.js";
14
13
  import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
15
14
  import { resolveToolChoice } from "../utils/toolChoice.js";
15
+ import { NoOutputGeneratedError } from "../utils/generationErrors.js";
16
+ import { Output, stepCountIs } from "../utils/tool.js";
17
+ import { streamText } from "../utils/generation.js";
16
18
  // Constants
17
19
  const MODELS_DISCOVERY_TIMEOUT_MS = 5000; // 5 seconds for model discovery
18
20
  // Configuration helpers
@@ -1,7 +1,7 @@
1
- import { type LanguageModel, type Schema } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { StreamOptions, StreamResult, ZodUnknownSchema } from "../types/index.js";
4
+ import type { LanguageModel, Schema } from "../types/index.js";
5
5
  /**
6
6
  * OpenAI Compatible Provider - BaseProvider Implementation
7
7
  * Provides access to one of the OpenAI-compatible endpoint (OpenRouter, vLLM, LiteLLM, etc.)
@@ -1,5 +1,4 @@
1
1
  import { createOpenAI } from "@ai-sdk/openai";
2
- import { NoOutputGeneratedError, stepCountIs, streamText, } from "ai";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
5
4
  import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
@@ -11,6 +10,9 @@ import { buildNoOutputSentinel, detectPostStreamNoOutput, stampNoOutputSpan, } f
11
10
  import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
12
11
  import { resolveToolChoice } from "../utils/toolChoice.js";
13
12
  import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
13
+ import { NoOutputGeneratedError } from "../utils/generationErrors.js";
14
+ import { stepCountIs } from "../utils/tool.js";
15
+ import { streamText } from "../utils/generation.js";
14
16
  // Constants
15
17
  const FALLBACK_OPENAI_COMPATIBLE_MODEL = "gpt-3.5-turbo";
16
18
  // Configuration helpers
@@ -1,7 +1,7 @@
1
- import { type LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * Perplexity Provider
7
7
  *
@@ -1,5 +1,4 @@
1
1
  import { createOpenAI } from "@ai-sdk/openai";
2
- import { stepCountIs, streamText } from "ai";
3
2
  import { PerplexityModels } from "../constants/enums.js";
4
3
  import { BaseProvider } from "../core/baseProvider.js";
5
4
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
14
13
  import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
15
14
  import { resolveToolChoice } from "../utils/toolChoice.js";
16
15
  import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
16
+ import { stepCountIs } from "../utils/tool.js";
17
+ import { streamText } from "../utils/generation.js";
17
18
  const PERPLEXITY_DEFAULT_BASE_URL = "https://api.perplexity.ai";
18
19
  const getPerplexityApiKey = () => validateApiKey(createPerplexityConfig());
19
20
  const getDefaultPerplexityModel = () => getProviderModel("PERPLEXITY_MODEL", PerplexityModels.SONAR);
@@ -1,11 +1,6 @@
1
- /**
2
- * Shared type utilities for AI SDK provider integration.
3
- *
4
- * Provides type-safe helpers to bridge between the AI SDK's generic types
5
- * and NeuroLink's internal type system without resorting to `as any` casts.
6
- */
7
- import type { LanguageModel, streamText } from "ai";
8
1
  import type { StreamTextResult } from "../types/index.js";
2
+ import type { LanguageModel } from "../types/index.js";
3
+ import type { streamText } from "../utils/generation.js";
9
4
  /**
10
5
  * Extract the model identifier from a LanguageModel value.
11
6
  *
@@ -1,9 +1,3 @@
1
- /**
2
- * Shared type utilities for AI SDK provider integration.
3
- *
4
- * Provides type-safe helpers to bridge between the AI SDK's generic types
5
- * and NeuroLink's internal type system without resorting to `as any` casts.
6
- */
7
1
  /**
8
2
  * Type guard: checks whether a LanguageModel value is an object with `modelId`
9
3
  * (i.e. LanguageModelV2 or LanguageModelV3) rather than a bare string ID.
@@ -1,7 +1,7 @@
1
- import type { LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { EnhancedGenerateResult, NeurolinkCredentials, StreamOptions, StreamResult, TextGenerationOptions, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * Recraft Provider — image generation with vector / illustration focus.
7
7
  *
@@ -1,7 +1,7 @@
1
- import type { LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { EnhancedGenerateResult, NeurolinkCredentials, StreamOptions, StreamResult, TextGenerationOptions, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * Replicate LLM Provider — predict-then-stream pattern.
7
7
  *
@@ -1,7 +1,7 @@
1
- import type { LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { EnhancedGenerateResult, NeurolinkCredentials, StreamOptions, StreamResult, TextGenerationOptions, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * Stability AI Provider — direct image generation.
7
7
  *
@@ -1,7 +1,7 @@
1
- import { type LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * Together AI Provider
7
7
  *
@@ -1,5 +1,4 @@
1
1
  import { createOpenAI } from "@ai-sdk/openai";
2
- import { stepCountIs, streamText } from "ai";
3
2
  import { TogetherAIModels } from "../constants/enums.js";
4
3
  import { BaseProvider } from "../core/baseProvider.js";
5
4
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
14
13
  import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
15
14
  import { resolveToolChoice } from "../utils/toolChoice.js";
16
15
  import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
16
+ import { stepCountIs } from "../utils/tool.js";
17
+ import { streamText } from "../utils/generation.js";
17
18
  const TOGETHER_DEFAULT_BASE_URL = "https://api.together.xyz/v1";
18
19
  const getTogetherApiKey = () => validateApiKey(createTogetherAIConfig());
19
20
  const getDefaultTogetherModel = () => getProviderModel("TOGETHER_MODEL", TogetherAIModels.LLAMA_3_3_70B_INSTRUCT_TURBO);
@@ -1,7 +1,7 @@
1
- import type { LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * Voyage AI Provider — embedding-only.
7
7
  *
@@ -1,7 +1,7 @@
1
- import { type LanguageModel } from "ai";
2
1
  import type { AIProviderName } from "../constants/enums.js";
3
2
  import { BaseProvider } from "../core/baseProvider.js";
4
3
  import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
4
+ import type { LanguageModel } from "../types/index.js";
5
5
  /**
6
6
  * xAI Grok Provider
7
7
  *
@@ -1,5 +1,4 @@
1
1
  import { createOpenAI } from "@ai-sdk/openai";
2
- import { stepCountIs, streamText } from "ai";
3
2
  import { XaiModels } from "../constants/enums.js";
4
3
  import { BaseProvider } from "../core/baseProvider.js";
5
4
  import { DEFAULT_MAX_STEPS } from "../core/constants.js";
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
14
13
  import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
15
14
  import { resolveToolChoice } from "../utils/toolChoice.js";
16
15
  import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
16
+ import { stepCountIs } from "../utils/tool.js";
17
+ import { streamText } from "../utils/generation.js";
17
18
  /**
18
19
  * Logging fetch wrapper — masks the proxy URL on non-2xx responses so
19
20
  * stack traces and log lines don't leak the upstream's internal token /
@@ -1,23 +1,8 @@
1
- /**
2
- * Claude Messages API format conversion layer.
3
- *
4
- * Provides a request parser (Claude -> NeuroLink), a response serializer
5
- * (NeuroLink -> Claude), a streaming SSE state machine, and an error
6
- * envelope helper. Together they allow NeuroLink to act as a
7
- * drop-in Claude API proxy.
8
- *
9
- * Reference: https://docs.anthropic.com/en/api/messages
10
- */
11
1
  import type { ClaudeErrorResponse, ClaudeRequest, ClaudeResponse, ContentBlockType, InternalResult, ParsedClaudeRequest, StreamLifecycleState } from "../types/index.js";
12
2
  /** Generate a unique message id in the Claude format. */
13
3
  export declare function generateMessageId(): string;
14
4
  /** Generate a Claude-format tool use ID (`toolu_` + 24 random chars). */
15
5
  export declare function generateToolUseId(): string;
16
- /**
17
- * Reset the internal id counter (useful in tests).
18
- * @internal
19
- */
20
- export declare function _resetIdCounter(): void;
21
6
  /**
22
7
  * Parse an incoming Claude Messages API request into an intermediate
23
8
  * representation consumable by NeuroLink's generate/stream pipeline.
@@ -1,16 +1,6 @@
1
- /**
2
- * Claude Messages API format conversion layer.
3
- *
4
- * Provides a request parser (Claude -> NeuroLink), a response serializer
5
- * (NeuroLink -> Claude), a streaming SSE state machine, and an error
6
- * envelope helper. Together they allow NeuroLink to act as a
7
- * drop-in Claude API proxy.
8
- *
9
- * Reference: https://docs.anthropic.com/en/api/messages
10
- */
11
- import { jsonSchema, tool } from "ai";
12
1
  import { randomBytes } from "crypto";
13
2
  import { normalizeJsonSchemaObject } from "../utils/schemaConversion.js";
3
+ import { jsonSchema, tool } from "../utils/tool.js";
14
4
  // ---------------------------------------------------------------------------
15
5
  // Helpers
16
6
  // ---------------------------------------------------------------------------
@@ -1,11 +1,3 @@
1
- /**
2
- * RAG Integration for generate() and stream()
3
- *
4
- * Provides automatic RAG pipeline setup when `rag` config is provided
5
- * in GenerateOptions or StreamOptions. Handles file loading, chunking,
6
- * embedding generation, vector storage, and tool creation internally
7
- * so developers only need to pass `rag: { files: [...] }`.
8
- */
9
1
  import type { RAGConfig, VectorQueryResult, RAGPreparedTool } from "../types/index.js";
10
2
  /**
11
3
  * Generate deterministic embeddings for chunks.
@@ -35,7 +27,4 @@ declare function diversifyResults(results: VectorQueryResult[], topK: number): V
35
27
  * @returns Prepared RAG tool to inject into the tools record
36
28
  */
37
29
  export declare function prepareRAGTool(ragConfig: RAGConfig, fallbackProvider?: string): Promise<RAGPreparedTool>;
38
- /** @internal Exported for testing only */
39
- export { generateSimpleEmbedding as _generateSimpleEmbedding };
40
- /** @internal Exported for testing only */
41
- export { diversifyResults as _diversifyResults };
30
+ export {};
@@ -1,11 +1,3 @@
1
- /**
2
- * RAG Integration for generate() and stream()
3
- *
4
- * Provides automatic RAG pipeline setup when `rag` config is provided
5
- * in GenerateOptions or StreamOptions. Handles file loading, chunking,
6
- * embedding generation, vector storage, and tool creation internally
7
- * so developers only need to pass `rag: { files: [...] }`.
8
- */
9
1
  import { existsSync, readFileSync } from "fs";
10
2
  import { extname, resolve } from "path";
11
3
  import { z } from "zod";