@librechat/agents 4.2.12 → 4.2.14

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 (357) hide show
  1. package/dist/cjs/graphs/Graph.cjs +56 -6
  2. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  3. package/dist/cjs/harness/providerText.cjs +1 -0
  4. package/dist/cjs/harness/providerText.cjs.map +1 -1
  5. package/dist/cjs/llm/anthropic/index.cjs +4 -3
  6. package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
  7. package/dist/cjs/llm/anthropic/utils/container.cjs +37 -0
  8. package/dist/cjs/llm/anthropic/utils/container.cjs.map +1 -0
  9. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +25 -23
  10. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
  11. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +15 -21
  12. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
  13. package/dist/cjs/llm/anthropic/utils/stream_events.cjs +16 -14
  14. package/dist/cjs/llm/anthropic/utils/stream_events.cjs.map +1 -1
  15. package/dist/cjs/llm/bedrock/index.cjs +1 -1
  16. package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
  17. package/dist/cjs/llm/bedrock/toolCache.cjs +1 -1
  18. package/dist/cjs/llm/bedrock/utils/message_inputs.cjs +19 -13
  19. package/dist/cjs/llm/bedrock/utils/message_inputs.cjs.map +1 -1
  20. package/dist/cjs/llm/google/utils/common.cjs +59 -13
  21. package/dist/cjs/llm/google/utils/common.cjs.map +1 -1
  22. package/dist/cjs/llm/google/utils/signatures.cjs +22 -14
  23. package/dist/cjs/llm/google/utils/signatures.cjs.map +1 -1
  24. package/dist/cjs/llm/init.cjs +12 -2
  25. package/dist/cjs/llm/init.cjs.map +1 -1
  26. package/dist/cjs/llm/invoke.cjs +122 -13
  27. package/dist/cjs/llm/invoke.cjs.map +1 -1
  28. package/dist/cjs/llm/openai/index.cjs +9 -3
  29. package/dist/cjs/llm/openai/index.cjs.map +1 -1
  30. package/dist/cjs/llm/openai/typedContent.cjs +94 -0
  31. package/dist/cjs/llm/openai/typedContent.cjs.map +1 -0
  32. package/dist/cjs/llm/openrouter/toolCache.cjs +1 -1
  33. package/dist/cjs/llm/prepareProviderRequest.cjs +81 -4
  34. package/dist/cjs/llm/prepareProviderRequest.cjs.map +1 -1
  35. package/dist/cjs/llm/providerTextBatch.cjs +128 -0
  36. package/dist/cjs/llm/providerTextBatch.cjs.map +1 -0
  37. package/dist/cjs/llm/providerTextBoundary.cjs +81 -12
  38. package/dist/cjs/llm/providerTextBoundary.cjs.map +1 -1
  39. package/dist/cjs/main.cjs +8 -3
  40. package/dist/cjs/messages/alternation.cjs +1 -1
  41. package/dist/cjs/messages/anthropicServerTools.cjs +20 -0
  42. package/dist/cjs/messages/anthropicServerTools.cjs.map +1 -0
  43. package/dist/cjs/messages/budget.cjs +1 -1
  44. package/dist/cjs/messages/core.cjs +3 -2
  45. package/dist/cjs/messages/core.cjs.map +1 -1
  46. package/dist/cjs/messages/format.cjs +2 -2
  47. package/dist/cjs/messages/index.cjs +1 -1
  48. package/dist/cjs/messages/prune.cjs +1 -1
  49. package/dist/cjs/messages/recency.cjs +1 -1
  50. package/dist/cjs/messages/toolResultTypes.cjs +21 -45
  51. package/dist/cjs/messages/toolResultTypes.cjs.map +1 -1
  52. package/dist/cjs/protection/providerText.cjs +60 -6
  53. package/dist/cjs/protection/providerText.cjs.map +1 -1
  54. package/dist/cjs/protection/providerTextAdmission.cjs +5 -0
  55. package/dist/cjs/protection/providerTextAdmission.cjs.map +1 -1
  56. package/dist/cjs/protection/toolResult.cjs +119 -0
  57. package/dist/cjs/protection/toolResult.cjs.map +1 -0
  58. package/dist/cjs/run.cjs +14 -3
  59. package/dist/cjs/run.cjs.map +1 -1
  60. package/dist/cjs/runtime/client.cjs +4 -0
  61. package/dist/cjs/runtime/client.cjs.map +1 -1
  62. package/dist/cjs/stream.cjs +10 -2
  63. package/dist/cjs/stream.cjs.map +1 -1
  64. package/dist/cjs/summarization/node.cjs +1 -1
  65. package/dist/cjs/tools/ToolNode.cjs +46 -13
  66. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  67. package/dist/cjs/tools/handlers.cjs +47 -1
  68. package/dist/cjs/tools/handlers.cjs.map +1 -1
  69. package/dist/cjs/tools/search/citations.cjs +194 -0
  70. package/dist/cjs/tools/search/citations.cjs.map +1 -0
  71. package/dist/cjs/tools/search/content.cjs +163 -42
  72. package/dist/cjs/tools/search/content.cjs.map +1 -1
  73. package/dist/cjs/tools/search/firecrawl.cjs +4 -9
  74. package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
  75. package/dist/cjs/tools/search/google.cjs +68 -0
  76. package/dist/cjs/tools/search/google.cjs.map +1 -0
  77. package/dist/cjs/tools/search/openai.cjs +80 -0
  78. package/dist/cjs/tools/search/openai.cjs.map +1 -0
  79. package/dist/cjs/tools/subagent/SubagentExecutor.cjs +4 -0
  80. package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
  81. package/dist/cjs/utils/tokens.cjs +12 -2
  82. package/dist/cjs/utils/tokens.cjs.map +1 -1
  83. package/dist/esm/graphs/Graph.mjs +57 -7
  84. package/dist/esm/graphs/Graph.mjs.map +1 -1
  85. package/dist/esm/harness/providerText.mjs +1 -0
  86. package/dist/esm/harness/providerText.mjs.map +1 -1
  87. package/dist/esm/llm/anthropic/index.mjs +4 -3
  88. package/dist/esm/llm/anthropic/index.mjs.map +1 -1
  89. package/dist/esm/llm/anthropic/utils/container.mjs +37 -0
  90. package/dist/esm/llm/anthropic/utils/container.mjs.map +1 -0
  91. package/dist/esm/llm/anthropic/utils/message_inputs.mjs +25 -23
  92. package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
  93. package/dist/esm/llm/anthropic/utils/message_outputs.mjs +15 -21
  94. package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
  95. package/dist/esm/llm/anthropic/utils/stream_events.mjs +16 -14
  96. package/dist/esm/llm/anthropic/utils/stream_events.mjs.map +1 -1
  97. package/dist/esm/llm/bedrock/index.mjs +2 -2
  98. package/dist/esm/llm/bedrock/index.mjs.map +1 -1
  99. package/dist/esm/llm/bedrock/toolCache.mjs +1 -1
  100. package/dist/esm/llm/bedrock/utils/message_inputs.mjs +19 -14
  101. package/dist/esm/llm/bedrock/utils/message_inputs.mjs.map +1 -1
  102. package/dist/esm/llm/google/utils/common.mjs +59 -13
  103. package/dist/esm/llm/google/utils/common.mjs.map +1 -1
  104. package/dist/esm/llm/google/utils/signatures.mjs +22 -14
  105. package/dist/esm/llm/google/utils/signatures.mjs.map +1 -1
  106. package/dist/esm/llm/init.mjs +12 -2
  107. package/dist/esm/llm/init.mjs.map +1 -1
  108. package/dist/esm/llm/invoke.mjs +124 -15
  109. package/dist/esm/llm/invoke.mjs.map +1 -1
  110. package/dist/esm/llm/openai/index.mjs +9 -3
  111. package/dist/esm/llm/openai/index.mjs.map +1 -1
  112. package/dist/esm/llm/openai/typedContent.mjs +93 -0
  113. package/dist/esm/llm/openai/typedContent.mjs.map +1 -0
  114. package/dist/esm/llm/openrouter/toolCache.mjs +1 -1
  115. package/dist/esm/llm/prepareProviderRequest.mjs +81 -4
  116. package/dist/esm/llm/prepareProviderRequest.mjs.map +1 -1
  117. package/dist/esm/llm/providerTextBatch.mjs +128 -0
  118. package/dist/esm/llm/providerTextBatch.mjs.map +1 -0
  119. package/dist/esm/llm/providerTextBoundary.mjs +81 -12
  120. package/dist/esm/llm/providerTextBoundary.mjs.map +1 -1
  121. package/dist/esm/main.mjs +7 -6
  122. package/dist/esm/messages/alternation.mjs +1 -1
  123. package/dist/esm/messages/anthropicServerTools.mjs +18 -0
  124. package/dist/esm/messages/anthropicServerTools.mjs.map +1 -0
  125. package/dist/esm/messages/budget.mjs +1 -1
  126. package/dist/esm/messages/core.mjs +3 -2
  127. package/dist/esm/messages/core.mjs.map +1 -1
  128. package/dist/esm/messages/format.mjs +2 -2
  129. package/dist/esm/messages/index.mjs +1 -1
  130. package/dist/esm/messages/prune.mjs +1 -1
  131. package/dist/esm/messages/recency.mjs +1 -1
  132. package/dist/esm/messages/toolResultTypes.mjs +21 -45
  133. package/dist/esm/messages/toolResultTypes.mjs.map +1 -1
  134. package/dist/esm/protection/providerText.mjs +58 -7
  135. package/dist/esm/protection/providerText.mjs.map +1 -1
  136. package/dist/esm/protection/providerTextAdmission.mjs +5 -0
  137. package/dist/esm/protection/providerTextAdmission.mjs.map +1 -1
  138. package/dist/esm/protection/toolResult.mjs +114 -0
  139. package/dist/esm/protection/toolResult.mjs.map +1 -0
  140. package/dist/esm/run.mjs +14 -3
  141. package/dist/esm/run.mjs.map +1 -1
  142. package/dist/esm/runtime/client.mjs +4 -0
  143. package/dist/esm/runtime/client.mjs.map +1 -1
  144. package/dist/esm/stream.mjs +10 -2
  145. package/dist/esm/stream.mjs.map +1 -1
  146. package/dist/esm/summarization/node.mjs +1 -1
  147. package/dist/esm/tools/ToolNode.mjs +46 -13
  148. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  149. package/dist/esm/tools/handlers.mjs +47 -2
  150. package/dist/esm/tools/handlers.mjs.map +1 -1
  151. package/dist/esm/tools/search/citations.mjs +190 -0
  152. package/dist/esm/tools/search/citations.mjs.map +1 -0
  153. package/dist/esm/tools/search/content.mjs +163 -42
  154. package/dist/esm/tools/search/content.mjs.map +1 -1
  155. package/dist/esm/tools/search/firecrawl.mjs +4 -9
  156. package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
  157. package/dist/esm/tools/search/google.mjs +67 -0
  158. package/dist/esm/tools/search/google.mjs.map +1 -0
  159. package/dist/esm/tools/search/openai.mjs +80 -0
  160. package/dist/esm/tools/search/openai.mjs.map +1 -0
  161. package/dist/esm/tools/subagent/SubagentExecutor.mjs +4 -0
  162. package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
  163. package/dist/esm/utils/tokens.mjs +12 -2
  164. package/dist/esm/utils/tokens.mjs.map +1 -1
  165. package/dist/types/common/index.d.ts +2 -2
  166. package/dist/types/decisions/breaker.d.ts +2 -2
  167. package/dist/types/decisions/core.d.ts +13 -13
  168. package/dist/types/decisions/dialect.d.ts +1 -1
  169. package/dist/types/decisions/http.d.ts +2 -2
  170. package/dist/types/decisions/index.d.ts +5 -5
  171. package/dist/types/decisions/node.d.ts +2 -2
  172. package/dist/types/decisions/presets.d.ts +2 -2
  173. package/dist/types/decisions/probe.d.ts +1 -1
  174. package/dist/types/decisions/questions.d.ts +1 -1
  175. package/dist/types/decisions/structuredChat.d.ts +2 -2
  176. package/dist/types/decisions/transport.d.ts +1 -1
  177. package/dist/types/eventActor/EventActorExecutor.d.ts +1 -1
  178. package/dist/types/eventActor/index.d.ts +2 -2
  179. package/dist/types/graphs/Graph.d.ts +18 -2
  180. package/dist/types/graphs/MultiAgentGraph.d.ts +1 -1
  181. package/dist/types/graphs/applyGraphRuntimeConfig.d.ts +1 -1
  182. package/dist/types/graphs/graphFactory.d.ts +1 -1
  183. package/dist/types/graphs/index.d.ts +5 -5
  184. package/dist/types/harness/fileBindings.d.ts +2 -2
  185. package/dist/types/harness/fileService.d.ts +2 -2
  186. package/dist/types/harness/fileStream.d.ts +1 -1
  187. package/dist/types/harness/index.d.ts +15 -15
  188. package/dist/types/harness/model.d.ts +1 -1
  189. package/dist/types/harness/modelService.d.ts +2 -2
  190. package/dist/types/harness/modelStreamCallbacks.d.ts +1 -1
  191. package/dist/types/harness/providerText.d.ts +1 -1
  192. package/dist/types/hitl/index.d.ts +3 -3
  193. package/dist/types/hooks/HookRegistry.d.ts +1 -1
  194. package/dist/types/hooks/createToolPolicyHook.d.ts +1 -1
  195. package/dist/types/hooks/createWorkspacePolicyHook.d.ts +1 -1
  196. package/dist/types/hooks/executeHooks.d.ts +2 -2
  197. package/dist/types/hooks/index.d.ts +11 -11
  198. package/dist/types/index.d.ts +62 -60
  199. package/dist/types/langchain/index.d.ts +8 -8
  200. package/dist/types/llm/anthropic/utils/container.d.ts +4 -0
  201. package/dist/types/llm/anthropic/utils/message_inputs.d.ts +1 -1
  202. package/dist/types/llm/anthropic/utils/message_outputs.d.ts +1 -1
  203. package/dist/types/llm/anthropic/utils/stream_events.d.ts +1 -1
  204. package/dist/types/llm/bedrock/index.d.ts +2 -3
  205. package/dist/types/llm/bedrock/utils/harmony.d.ts +1 -1
  206. package/dist/types/llm/bedrock/utils/index.d.ts +2 -2
  207. package/dist/types/llm/bedrock/utils/message_inputs.d.ts +3 -12
  208. package/dist/types/llm/bedrock/utils/message_outputs.d.ts +1 -1
  209. package/dist/types/llm/google/index.d.ts +2 -2
  210. package/dist/types/llm/google/utils/common.d.ts +1 -1
  211. package/dist/types/llm/google/utils/tools.d.ts +1 -1
  212. package/dist/types/llm/openai/index.d.ts +1 -1
  213. package/dist/types/llm/openai/typedContent.d.ts +14 -0
  214. package/dist/types/llm/providerRegistry.d.ts +1 -1
  215. package/dist/types/llm/providerTextBatch.d.ts +26 -0
  216. package/dist/types/llm/providerTextBoundary.d.ts +7 -1
  217. package/dist/types/llm/providers.d.ts +1 -1
  218. package/dist/types/messages/anthropicServerTools.d.ts +13 -0
  219. package/dist/types/messages/contextPruning.d.ts +1 -1
  220. package/dist/types/messages/core.d.ts +4 -4
  221. package/dist/types/messages/format.d.ts +1 -1
  222. package/dist/types/messages/index.d.ts +21 -21
  223. package/dist/types/messages/prune.d.ts +1 -1
  224. package/dist/types/openai/index.d.ts +2 -2
  225. package/dist/types/openai/toolProjection.d.ts +1 -1
  226. package/dist/types/prompts/index.d.ts +2 -2
  227. package/dist/types/protection/providerText.d.ts +32 -2
  228. package/dist/types/protection/providerTextAdmission.d.ts +1 -0
  229. package/dist/types/protection/toolResult.d.ts +69 -0
  230. package/dist/types/provider-registration.d.ts +1 -1
  231. package/dist/types/rerank/bm25.d.ts +1 -1
  232. package/dist/types/rerank/core.d.ts +17 -17
  233. package/dist/types/rerank/crossEncoder.d.ts +3 -3
  234. package/dist/types/rerank/fallback.d.ts +1 -1
  235. package/dist/types/rerank/index.d.ts +2 -2
  236. package/dist/types/rerank/outcome.d.ts +2 -2
  237. package/dist/types/rerank/pin.d.ts +2 -2
  238. package/dist/types/rerank/search.d.ts +1 -1
  239. package/dist/types/rerank/systemone.d.ts +4 -4
  240. package/dist/types/rerank/types.d.ts +1 -1
  241. package/dist/types/run.d.ts +1 -0
  242. package/dist/types/runtime/admission.d.ts +1 -1
  243. package/dist/types/runtime/checkpoint.d.ts +1 -1
  244. package/dist/types/runtime/client.d.ts +2 -2
  245. package/dist/types/runtime/files.d.ts +3 -3
  246. package/dist/types/runtime/hostTools.d.ts +2 -2
  247. package/dist/types/runtime/index.d.ts +12 -12
  248. package/dist/types/runtime/model.d.ts +5 -5
  249. package/dist/types/runtime/policy.d.ts +3 -3
  250. package/dist/types/runtime/recovery/client.d.ts +3 -3
  251. package/dist/types/runtime/recovery/log.d.ts +2 -2
  252. package/dist/types/runtime/recovery/redis.d.ts +1 -1
  253. package/dist/types/runtime/recovery/server.d.ts +3 -3
  254. package/dist/types/runtime/resume.d.ts +1 -1
  255. package/dist/types/runtime/server.d.ts +3 -3
  256. package/dist/types/runtime/snapshot.d.ts +1 -1
  257. package/dist/types/runtime/types.d.ts +2 -2
  258. package/dist/types/session/AgentSession.d.ts +2 -2
  259. package/dist/types/session/JsonlSessionStore.d.ts +1 -1
  260. package/dist/types/session/deriveMessages.d.ts +1 -1
  261. package/dist/types/session/handlers.d.ts +1 -1
  262. package/dist/types/session/index.d.ts +7 -7
  263. package/dist/types/session/messageSerialization.d.ts +1 -1
  264. package/dist/types/session/sessionProjection.d.ts +3 -3
  265. package/dist/types/summarization/index.d.ts +2 -2
  266. package/dist/types/tools/BashProgrammaticToolCalling.d.ts +1 -1
  267. package/dist/types/tools/GitHubCompare.d.ts +6 -6
  268. package/dist/types/tools/ProgrammaticToolCalling.d.ts +1 -1
  269. package/dist/types/tools/ReadFile.d.ts +6 -6
  270. package/dist/types/tools/SkillTool.d.ts +6 -6
  271. package/dist/types/tools/ToolNode.d.ts +5 -1
  272. package/dist/types/tools/cloudflare/index.d.ts +4 -4
  273. package/dist/types/tools/handlers.d.ts +13 -0
  274. package/dist/types/tools/local/FileCheckpointer.d.ts +1 -1
  275. package/dist/types/tools/local/LocalExecutionEngine.d.ts +1 -1
  276. package/dist/types/tools/local/attachments.d.ts +1 -1
  277. package/dist/types/tools/local/index.d.ts +12 -12
  278. package/dist/types/tools/search/anthropic.d.ts +1 -1
  279. package/dist/types/tools/search/citations.d.ts +88 -0
  280. package/dist/types/tools/search/content.d.ts +38 -1
  281. package/dist/types/tools/search/crw-scraper.d.ts +1 -1
  282. package/dist/types/tools/search/crw-search.d.ts +1 -1
  283. package/dist/types/tools/search/firecrawl.d.ts +4 -2
  284. package/dist/types/tools/search/format.d.ts +1 -1
  285. package/dist/types/tools/search/google.d.ts +11 -0
  286. package/dist/types/tools/search/highlights.d.ts +1 -1
  287. package/dist/types/tools/search/index.d.ts +3 -3
  288. package/dist/types/tools/search/keenable-scraper.d.ts +1 -1
  289. package/dist/types/tools/search/keenable-search.d.ts +1 -1
  290. package/dist/types/tools/search/metrics.d.ts +1 -1
  291. package/dist/types/tools/search/openai.d.ts +3 -0
  292. package/dist/types/tools/search/rerankers.d.ts +1 -1
  293. package/dist/types/tools/search/schema.d.ts +6 -6
  294. package/dist/types/tools/search/search.d.ts +1 -1
  295. package/dist/types/tools/search/serper-scraper.d.ts +1 -1
  296. package/dist/types/tools/search/tavily-scraper.d.ts +1 -1
  297. package/dist/types/tools/search/tavily-search.d.ts +1 -1
  298. package/dist/types/tools/search/tool.d.ts +3 -3
  299. package/dist/types/tools/search/types.d.ts +26 -2
  300. package/dist/types/tools/search/utils.d.ts +3 -3
  301. package/dist/types/tools/subagent/SubagentExecutionRegistry.d.ts +1 -1
  302. package/dist/types/tools/subagent/SubagentExecutor.d.ts +6 -3
  303. package/dist/types/tools/subagent/diagnostics.d.ts +1 -1
  304. package/dist/types/tools/subagent/index.d.ts +7 -7
  305. package/dist/types/types/attachments.d.ts +1 -1
  306. package/dist/types/types/graph.d.ts +4 -1
  307. package/dist/types/types/index.d.ts +14 -14
  308. package/dist/types/types/llm.d.ts +2 -2
  309. package/dist/types/types/run.d.ts +3 -1
  310. package/dist/types/types/stream.d.ts +12 -0
  311. package/dist/types/types/subagentTasks.d.ts +2 -2
  312. package/dist/types/types/tools.d.ts +6 -3
  313. package/dist/types/utils/index.d.ts +10 -10
  314. package/dist/types/utils/tokens.d.ts +2 -0
  315. package/package.json +3 -2
  316. package/src/graphs/Graph.ts +125 -3
  317. package/src/harness/providerText.ts +1 -0
  318. package/src/index.ts +10 -0
  319. package/src/llm/anthropic/index.ts +11 -3
  320. package/src/llm/anthropic/utils/container.ts +63 -0
  321. package/src/llm/anthropic/utils/message_inputs.ts +57 -51
  322. package/src/llm/anthropic/utils/message_outputs.ts +12 -39
  323. package/src/llm/anthropic/utils/stream_events.ts +17 -12
  324. package/src/llm/bedrock/index.ts +7 -5
  325. package/src/llm/bedrock/utils/message_inputs.ts +28 -35
  326. package/src/llm/google/utils/common.ts +88 -36
  327. package/src/llm/google/utils/signatures.ts +52 -36
  328. package/src/llm/init.ts +35 -3
  329. package/src/llm/invoke.ts +160 -16
  330. package/src/llm/openai/index.ts +18 -5
  331. package/src/llm/openai/typedContent.ts +110 -0
  332. package/src/llm/prepareProviderRequest.ts +154 -4
  333. package/src/llm/providerTextBatch.ts +158 -0
  334. package/src/llm/providerTextBoundary.ts +119 -13
  335. package/src/messages/anthropicServerTools.ts +24 -0
  336. package/src/messages/core.ts +12 -11
  337. package/src/messages/toolResultTypes.ts +80 -88
  338. package/src/protection/providerText.ts +222 -46
  339. package/src/protection/providerTextAdmission.ts +6 -0
  340. package/src/protection/toolResult.ts +272 -0
  341. package/src/run.ts +37 -5
  342. package/src/runtime/client.ts +6 -0
  343. package/src/stream.ts +23 -2
  344. package/src/tools/ToolNode.ts +112 -17
  345. package/src/tools/handlers.ts +110 -5
  346. package/src/tools/search/citations.ts +375 -0
  347. package/src/tools/search/content.ts +282 -62
  348. package/src/tools/search/firecrawl.ts +13 -16
  349. package/src/tools/search/google.ts +122 -0
  350. package/src/tools/search/openai.ts +118 -0
  351. package/src/tools/search/types.ts +21 -0
  352. package/src/tools/subagent/SubagentExecutor.ts +6 -0
  353. package/src/types/graph.ts +3 -0
  354. package/src/types/run.ts +3 -0
  355. package/src/types/stream.ts +9 -0
  356. package/src/types/tools.ts +3 -0
  357. package/src/utils/tokens.ts +37 -2
@@ -39,13 +39,13 @@ export declare const WebSearchToolSchema: {
39
39
  readonly intent: {
40
40
  readonly type: "string" | "number" | "integer" | "float" | "boolean" | "array" | "object";
41
41
  readonly enum?: string[];
42
- readonly items?: import("../..").JsonSchemaType;
43
- readonly properties?: Record<string, import("../..").JsonSchemaType>;
42
+ readonly items?: import("../../index.js").JsonSchemaType;
43
+ readonly properties?: Record<string, import("../../index.js").JsonSchemaType>;
44
44
  readonly required?: string[];
45
45
  readonly description?: string;
46
46
  readonly pattern?: string;
47
47
  readonly maxLength?: number;
48
- readonly additionalProperties?: boolean | import("../..").JsonSchemaType;
48
+ readonly additionalProperties?: boolean | import("../../index.js").JsonSchemaType;
49
49
  };
50
50
  readonly query: {
51
51
  readonly type: "string";
@@ -86,13 +86,13 @@ export declare const WebSearchToolDefinition: {
86
86
  readonly intent: {
87
87
  readonly type: "string" | "number" | "integer" | "float" | "boolean" | "array" | "object";
88
88
  readonly enum?: string[];
89
- readonly items?: import("../..").JsonSchemaType;
90
- readonly properties?: Record<string, import("../..").JsonSchemaType>;
89
+ readonly items?: import("../../index.js").JsonSchemaType;
90
+ readonly properties?: Record<string, import("../../index.js").JsonSchemaType>;
91
91
  readonly required?: string[];
92
92
  readonly description?: string;
93
93
  readonly pattern?: string;
94
94
  readonly maxLength?: number;
95
- readonly additionalProperties?: boolean | import("../..").JsonSchemaType;
95
+ readonly additionalProperties?: boolean | import("../../index.js").JsonSchemaType;
96
96
  };
97
97
  readonly query: {
98
98
  readonly type: "string";
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  export declare const createSearchAPI: (config: t.SearchConfig) => {
3
3
  getSources: (params: t.GetSourcesParams) => Promise<t.SearchResult>;
4
4
  };
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  /**
3
3
  * Serper scraper implementation
4
4
  * Uses the Serper Scrape API (https://scrape.serper.dev) to scrape web pages
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  export declare class TavilyScraper implements t.BaseScraper {
3
3
  private apiKey;
4
4
  private apiUrl;
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  export declare const createTavilyAPI: (apiKey?: string, apiUrl?: string, options?: t.TavilySearchOptions) => {
3
3
  getSources: (params: t.GetSourcesParams) => Promise<t.SearchResult>;
4
4
  };
@@ -1,7 +1,7 @@
1
1
  import { DynamicStructuredTool } from '@langchain/core/tools';
2
- import type * as t from './types';
3
- import { DATE_RANGE } from './schema';
4
- import { createSearchAPI } from './search';
2
+ import type * as t from './types.js';
3
+ import { DATE_RANGE } from './schema.js';
4
+ import { createSearchAPI } from './search.js';
5
5
  /**
6
6
  * Settled label for a `web_search` call's intent (see `intentArg.ts`).
7
7
  *
@@ -2,8 +2,8 @@ import type { RunnableConfig } from '@langchain/core/runnables';
2
2
  import type { Logger as WinstonLogger } from 'winston';
3
3
  import type { Agent as HttpsAgent } from 'https';
4
4
  import type { Agent as HttpAgent } from 'http';
5
- import type { BaseReranker } from './rerankers';
6
- import { DATE_RANGE } from './schema';
5
+ import type { BaseReranker } from './rerankers.js';
6
+ import { DATE_RANGE } from './schema.js';
7
7
  export type { HttpAgent, HttpsAgent };
8
8
  export interface HttpAgentConfig {
9
9
  httpAgent?: HttpAgent;
@@ -58,6 +58,30 @@ export interface SearchResultData {
58
58
  references?: ResultReference[];
59
59
  error?: string;
60
60
  }
61
+ /**
62
+ * Gemini's `groundingMetadata` as the API returns it. The
63
+ * `@google/generative-ai` declarations type `segment` as a string and
64
+ * misspell `groundingChunkIndices`, so they cannot describe it.
65
+ */
66
+ export type GoogleGroundingMetadata = {
67
+ webSearchQueries?: string[];
68
+ groundingChunks?: {
69
+ web?: {
70
+ uri?: string;
71
+ title?: string;
72
+ domain?: string;
73
+ };
74
+ }[];
75
+ groundingSupports?: {
76
+ segment?: {
77
+ partIndex?: number;
78
+ startIndex?: number;
79
+ endIndex?: number;
80
+ text?: string;
81
+ };
82
+ groundingChunkIndices?: number[];
83
+ }[];
84
+ };
61
85
  export interface SearchResult {
62
86
  data?: SearchResultData;
63
87
  error?: string;
@@ -1,6 +1,6 @@
1
- import type { SafeErrorLog } from './types';
2
- import type * as t from './types';
3
- export type { SafeErrorLog } from './types';
1
+ import type { SafeErrorLog } from './types.js';
2
+ import type * as t from './types.js';
3
+ export type { SafeErrorLog } from './types.js';
4
4
  /**
5
5
  * Creates a default logger that maps to console methods
6
6
  * Uses a singleton pattern to avoid creating multiple instances
@@ -1,5 +1,5 @@
1
1
  import type { RunnableConfig } from '@langchain/core/runnables';
2
- import type { SubagentResumeExecution } from './SubagentReplay';
2
+ import type { SubagentResumeExecution } from './SubagentReplay.js';
3
3
  export type SubagentExecutionAddressInput = {
4
4
  threadId?: string;
5
5
  parentToolCallId: string;
@@ -2,13 +2,13 @@ import { BaseMessage } from '@langchain/core/messages';
2
2
  import type { RunnableConfig } from '@langchain/core/runnables';
3
3
  import type { ToolCall } from '@langchain/core/messages/tool';
4
4
  import type { MultiAgentGraphState, HumanInTheLoopConfig, StandardGraphInput, ExecutableSubagentConfigEntry, SubagentExecutionContext, SubagentContextAdapter, SubagentContextResult, SubagentTaskConfig, SubagentTaskRuntime, SubagentHostArgs, SubagentUsageSink, TokenCounter } from '../../types/index.js';
5
- import type { SubagentResolutionPhase, SubagentResolutionCause, SubagentHostArgumentFailure, SubagentResolutionFailureHandler } from './diagnostics';
6
- import type { SubagentResumeManifest, SettledSubagentToolOutput } from './SubagentReplay';
5
+ import type { SubagentResolutionPhase, SubagentResolutionCause, SubagentHostArgumentFailure, SubagentResolutionFailureHandler } from './diagnostics.js';
6
+ import type { SubagentResumeManifest, SettledSubagentToolOutput } from './SubagentReplay.js';
7
7
  import type { GraphFactory } from '../../graphs/graphFactory.js';
8
8
  import type { StandardGraph } from '../../graphs/Graph.js';
9
9
  import { HookRegistry } from '../../hooks/index.js';
10
10
  import { HandlerRegistry } from '../../events.js';
11
- export { buildChildInputs, isGraphSubagentConfig, normalizeSubagentConfigs, normalizeSubagentConfigEntries, resolveSubagentConfigs, resolveSubagentConfigEntries, } from './childGraphConfig';
11
+ export { buildChildInputs, isGraphSubagentConfig, normalizeSubagentConfigs, normalizeSubagentConfigEntries, resolveSubagentConfigs, resolveSubagentConfigEntries, } from './childGraphConfig.js';
12
12
  export declare const DEFAULT_SUBAGENT_DESCRIPTION = "No task description provided";
13
13
  export type SubagentExecuteParams = {
14
14
  description: string;
@@ -127,6 +127,8 @@ export type SubagentExecutorOptions = {
127
127
  * revert to the defaults.
128
128
  */
129
129
  providerTextProtection?: StandardGraphInput['providerTextProtection'];
130
+ /** The parent's tool result protection, so a child inspects the same tools. */
131
+ toolResultProtection?: StandardGraphInput['toolResultProtection'];
130
132
  /** The parent's attachment resolver, so a child resolves the references it inherits. */
131
133
  resolveAttachment?: StandardGraphInput['resolveAttachment'];
132
134
  streamLimits?: StandardGraphInput['streamLimits'];
@@ -197,6 +199,7 @@ export declare class SubagentExecutor {
197
199
  private readonly langfuse?;
198
200
  private readonly tokenCounter?;
199
201
  private readonly providerTextProtection?;
202
+ private readonly toolResultProtection?;
200
203
  private readonly resolveAttachment?;
201
204
  private readonly streamLimits?;
202
205
  private readonly humanInTheLoop?;
@@ -1,5 +1,5 @@
1
1
  import type { SubagentHostArgs } from '../../types/graph.js';
2
- import { SubagentSettlementBindingError, SubagentDefinitionBindingError, SubagentInvocationBindingError, SubagentExecutionInvalidatedError } from './SubagentExecutionRegistry';
2
+ import { SubagentSettlementBindingError, SubagentDefinitionBindingError, SubagentInvocationBindingError, SubagentExecutionInvalidatedError } from './SubagentExecutionRegistry.js';
3
3
  import { describeCodeApiError } from '../diagnostics.js';
4
4
  /** Which step of child start-up failed: execution identity, then host config resolution. */
5
5
  export type SubagentResolutionPhase = 'identity' | 'config';
@@ -1,7 +1,7 @@
1
- export { DEFAULT_SUBAGENT_DESCRIPTION, SubagentExecutor, filterSubagentResult, filterGraphSubagentResult, isGraphSubagentConfig, normalizeSubagentConfigs, normalizeSubagentConfigEntries, resolveSubagentConfigs, resolveSubagentConfigEntries, buildChildInputs, summarizeEvent, } from './SubagentExecutor';
2
- export type { SubagentExecuteParams, SubagentExecuteResult, SubagentExecutorOptions, ChildGraphFactory, } from './SubagentExecutor';
3
- export { InMemorySubagentTaskStore } from './InMemorySubagentTaskStore';
4
- export type { InMemorySubagentTaskStoreOptions } from './InMemorySubagentTaskStore';
5
- export { SubagentResolutionError, SubagentHostArgumentError, getSubagentResolutionFailureMessage, getSubagentHostArgumentFailureMessage, } from './diagnostics';
6
- export { SUBAGENT_HOST_ARG_LIMITS, SELF_SUBAGENT_HOST_ARGS_SUPPORTED, buildSubagentHostArgProperties, resolveSubagentHostArgs, } from './hostArgs';
7
- export type { SubagentHostArgumentFailure, SubagentHostArgumentRejection, SubagentResolutionPhase, SubagentResolutionCause, SubagentResolutionContext, SubagentResolutionDiagnostic, SubagentResolutionFailureHandler, } from './diagnostics';
1
+ export { DEFAULT_SUBAGENT_DESCRIPTION, SubagentExecutor, filterSubagentResult, filterGraphSubagentResult, isGraphSubagentConfig, normalizeSubagentConfigs, normalizeSubagentConfigEntries, resolveSubagentConfigs, resolveSubagentConfigEntries, buildChildInputs, summarizeEvent, } from './SubagentExecutor.js';
2
+ export type { SubagentExecuteParams, SubagentExecuteResult, SubagentExecutorOptions, ChildGraphFactory, } from './SubagentExecutor.js';
3
+ export { InMemorySubagentTaskStore } from './InMemorySubagentTaskStore.js';
4
+ export type { InMemorySubagentTaskStoreOptions } from './InMemorySubagentTaskStore.js';
5
+ export { SubagentResolutionError, SubagentHostArgumentError, getSubagentResolutionFailureMessage, getSubagentHostArgumentFailureMessage, } from './diagnostics.js';
6
+ export { SUBAGENT_HOST_ARG_LIMITS, SELF_SUBAGENT_HOST_ARGS_SUPPORTED, buildSubagentHostArgProperties, resolveSubagentHostArgs, } from './hostArgs.js';
7
+ export type { SubagentHostArgumentFailure, SubagentHostArgumentRejection, SubagentResolutionPhase, SubagentResolutionCause, SubagentResolutionContext, SubagentResolutionDiagnostic, SubagentResolutionFailureHandler, } from './diagnostics.js';
@@ -1,6 +1,6 @@
1
1
  import type { Data, MessageContentComplex } from '@langchain/core/messages';
2
2
  import type { ProviderMessageProjectionMode } from '../llm/prepareProviderRequest.js';
3
- import type { ProviderName } from './llm';
3
+ import type { ProviderName } from './llm.js';
4
4
  /** An attachment a message carries by reference: LangChain's `source_type: 'id'` data block. */
5
5
  export type AttachmentReference = Data.IDContentBlock;
6
6
  /** The provider request a reference is being resolved for. */
@@ -1,5 +1,6 @@
1
1
  import type { ProviderTextProtection } from '../protection/providerText.js';
2
- import type { AttachmentResolver } from './attachments';
2
+ import type { ToolResultProtection } from '../protection/toolResult.js';
3
+ import type { AttachmentResolver } from './attachments.js';
3
4
  import type { BaseMessage, AIMessageChunk, SystemMessage, UsageMetadata } from '@langchain/core/messages';
4
5
  import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
5
6
  import type { START, StateGraph, StateGraphArgs } from '@langchain/langgraph';
@@ -290,6 +291,8 @@ export type ModelEndData = (StreamEventData & {
290
291
  export type GraphTools = GenericTool[] | BindToolsInput[] | GoogleAIToolType[];
291
292
  export type StandardGraphInput = {
292
293
  providerTextProtection?: ProviderTextProtection;
294
+ /** Host inspection of selected tools' result text, for every graph of the run. */
295
+ toolResultProtection?: ToolResultProtection;
293
296
  /** Resolves attachments that messages carry by reference; see {@link AttachmentResolver}. */
294
297
  resolveAttachment?: AttachmentResolver;
295
298
  runId?: string;
@@ -1,14 +1,14 @@
1
- export * from './attachments';
2
- export * from './graph';
3
- export * from './hitl';
4
- export * from './llm';
5
- export * from './messages';
6
- export * from './run';
7
- export * from './skill';
8
- export * from './stream';
9
- export * from './subagentTasks';
10
- export * from './tools';
11
- export * from './summarize';
12
- export * from './activityLabel';
13
- export * from './assistantPhase';
14
- export * from './reasoningLabel';
1
+ export * from './attachments.js';
2
+ export * from './graph.js';
3
+ export * from './hitl.js';
4
+ export * from './llm.js';
5
+ export * from './messages.js';
6
+ export * from './run.js';
7
+ export * from './skill.js';
8
+ export * from './stream.js';
9
+ export * from './subagentTasks.js';
10
+ export * from './tools.js';
11
+ export * from './summarize.js';
12
+ export * from './activityLabel.js';
13
+ export * from './assistantPhase.js';
14
+ export * from './reasoningLabel.js';
@@ -12,7 +12,7 @@ import type { AnthropicInput } from '@langchain/anthropic';
12
12
  import type { Runnable } from '@langchain/core/runnables';
13
13
  import type { OpenAI as OpenAIClient } from 'openai';
14
14
  import type { ChatXAIInput } from '@langchain/xai';
15
- import type { CustomProviderOptionsMap } from '../provider-registration';
15
+ import type { CustomProviderOptionsMap } from '../provider-registration.js';
16
16
  import type { ChatOpenRouterCallOptions } from '../llm/openrouter/index.js';
17
17
  import type { PromptCacheTtl } from '../messages/cache.js';
18
18
  import { AzureChatOpenAI, ChatDeepSeek, ChatMoonshot, ChatOpenAI, ChatXAI } from '../llm/openai/index.js';
@@ -221,4 +221,4 @@ export type ChatModelInstance = BaseChatModel;
221
221
  export type ModelWithTools = BaseChatModel & {
222
222
  bindTools(tools: CommonToolType[]): Runnable;
223
223
  };
224
- export type { CustomProviderOptionsMap } from '../provider-registration';
224
+ export type { CustomProviderOptionsMap } from '../provider-registration.js';
@@ -27,7 +27,7 @@ export type LegacyGraphConfig = BaseGraphConfig & {
27
27
  * would type-check but be silently ignored by `createLegacyGraph`.
28
28
  * Required provider-text protection also belongs only to RunConfig, as
29
29
  * does the attachment resolver. */
30
- 'provider' | 'clientOptions' | 'agents' | 'streamLimits' | 'providerTextProtection' | 'resolveAttachment'> & Omit<g.AgentInputs, 'provider' | 'clientOptions' | 'agentId'>;
30
+ 'provider' | 'clientOptions' | 'agents' | 'streamLimits' | 'providerTextProtection' | 'toolResultProtection' | 'resolveAttachment'> & Omit<g.AgentInputs, 'provider' | 'clientOptions' | 'agentId'>;
31
31
  export type SupervisedGraphConfig = BaseGraphConfig & {
32
32
  type: 'supervised';
33
33
  /** Enable supervised router; when false, fall back to standard loop */
@@ -320,6 +320,8 @@ export type RunConfig = {
320
320
  * opt-in. See {@link StreamLimits}.
321
321
  */
322
322
  providerTextProtection?: g.StandardGraphInput['providerTextProtection'];
323
+ /** Host inspection of selected tools' result text. Default off. */
324
+ toolResultProtection?: g.StandardGraphInput['toolResultProtection'];
323
325
  /** Resolves attachments that messages carry by reference, for every graph of the run. */
324
326
  resolveAttachment?: g.StandardGraphInput['resolveAttachment'];
325
327
  streamLimits?: StreamLimits;
@@ -338,12 +338,24 @@ export interface ReasoningDelta {
338
338
  */
339
339
  content?: MessageContentComplex[];
340
340
  }
341
+ /** Replaces `[start, end)` of a text part's accumulated text; an insertion when both match. */
342
+ export type TextEdit = {
343
+ start: number;
344
+ end: number;
345
+ text: string;
346
+ };
341
347
  export type MessageDeltaUpdate = {
342
348
  type: ContentTypes.TEXT;
343
349
  text: string;
344
350
  tool_call_ids?: string[];
345
351
  /** Provider-supplied source citations, accumulated across deltas. */
346
352
  citations?: Anthropic.TextCitation[];
353
+ /**
354
+ * Rewrites of text this part already holds, for citations a provider sends
355
+ * after the text they cite (Google grounding, OpenAI `url_citation`). Never
356
+ * stored on the part; a delta carrying them has no `text`.
357
+ */
358
+ edits?: TextEdit[];
347
359
  };
348
360
  export type ReasoningDeltaUpdate = {
349
361
  type: ContentTypes.THINK;
@@ -1,6 +1,6 @@
1
1
  import type { BaseMessage } from '@langchain/core/messages';
2
- import type { SubagentUpdateEvent } from './graph';
3
- import type { InjectedMessage } from './tools';
2
+ import type { SubagentUpdateEvent } from './graph.js';
3
+ import type { InjectedMessage } from './tools.js';
4
4
  /** Terminal and in-flight states for a detached subagent task. */
5
5
  export type SubagentTaskStatus = 'running' | 'completed' | 'error' | 'cancelled';
6
6
  /** Where a pending parent message may enter the child run. */
@@ -1,13 +1,14 @@
1
1
  import type { RunnableConfig, RunnableToolLike } from '@langchain/core/runnables';
2
2
  import type { StructuredToolInterface } from '@langchain/core/tools';
3
3
  import type { ToolCall } from '@langchain/core/messages/tool';
4
- import type { MessageContentComplex, RunStepResumeState, ToolErrorData } from './stream';
4
+ import type { MessageContentComplex, RunStepResumeState, ToolErrorData } from './stream.js';
5
5
  import type { ToolOutputReferenceRegistry } from '../tools/toolOutputReferences.js';
6
- import type { LangfuseConfig, SubagentExecutionContext } from './graph';
6
+ import type { LangfuseConfig, SubagentExecutionContext } from './graph.js';
7
+ import type { ToolResultProtection } from '../protection/toolResult.js';
7
8
  import type { PreparedSubagents } from '../tools/preparedSubagents.js';
8
9
  import type { RunBreakerScope } from '../llm/streamLimits.js';
9
10
  import type { HandoffRouting } from '../graphs/handoff.js';
10
- import type { HumanInTheLoopConfig } from './hitl';
11
+ import type { HumanInTheLoopConfig } from './hitl.js';
11
12
  import type { HookRegistry } from '../hooks/index.js';
12
13
  /** Replacement type for `import type { ToolCall } from '@langchain/core/messages/tool'` in order to have stringified args typed */
13
14
  export type CustomToolCall = {
@@ -254,6 +255,8 @@ export type ToolNodeOptions = {
254
255
  * precedence over `toolOutputReferences` when both are set.
255
256
  */
256
257
  toolOutputRegistry?: ToolOutputReferenceRegistry;
258
+ /** Host inspection of selected tools' result text; see {@link ToolResultProtection}. */
259
+ toolResultProtection?: ToolResultProtection;
257
260
  /**
258
261
  * Selects where built-in code execution tools run. Defaults to the
259
262
  * remote LibreChat Code API sandbox; `local` swaps those same tool names
@@ -1,10 +1,10 @@
1
- export * from './graph';
2
- export * from './llm';
3
- export * from './misc';
4
- export * from './proxy';
5
- export * from './handlers';
6
- export * from './run';
7
- export * from './tokens';
8
- export * from './schema';
9
- export * from './truncation';
10
- export * from './errors';
1
+ export * from './graph.js';
2
+ export * from './llm.js';
3
+ export * from './misc.js';
4
+ export * from './proxy.js';
5
+ export * from './handlers.js';
6
+ export * from './run.js';
7
+ export * from './tokens.js';
8
+ export * from './schema.js';
9
+ export * from './truncation.js';
10
+ export * from './errors.js';
@@ -37,7 +37,9 @@ export declare function estimateImageBlockTokens(block: Record<string, unknown>,
37
37
  * and Anthropic format (`type: 'document'` with `source`).
38
38
  *
39
39
  * - Plain text: tokenized directly via `getTokenCount`.
40
+ * - Audio and video: priced by duration, as {@link estimateTimedMediaBlockTokens}.
40
41
  * - Base64 PDF: page count estimated from base64 length × per-page cost.
42
+ * - Other base64 documents: decoded text, or decoded size when binary.
41
43
  * - URL reference: conservative flat estimate.
42
44
  */
43
45
  export declare function estimateDocumentBlockTokens(block: Record<string, unknown>, encoding: EncodingName, getTokenCount: (text: string) => number): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@librechat/agents",
3
- "version": "4.2.12",
3
+ "version": "4.2.14",
4
4
  "reova": {
5
5
  "enabled": true,
6
6
  "endpoint": "https://telemetry.reo.dev/data"
@@ -313,7 +313,8 @@
313
313
  "label:eval": "tsx -r dotenv/config ./src/scripts/activity-labels/run.ts",
314
314
  "label:rescore": "node ./src/scripts/activity-labels/rescore.cjs",
315
315
  "test:runtime-package": "node --test config/runtime-package.test.mjs",
316
- "build:types": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json"
316
+ "test:declaration-extensions": "node --test scripts/fix-dts-extensions.test.mjs",
317
+ "build:types": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node scripts/fix-dts-extensions.mjs dist/types"
317
318
  },
318
319
  "overrides": {
319
320
  "@langchain/openai": "$@langchain/openai",