@librechat/agents 3.2.2 → 3.2.31

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 (401) hide show
  1. package/dist/cjs/agents/AgentContext.cjs +3 -2
  2. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  3. package/dist/cjs/events.cjs.map +1 -1
  4. package/dist/cjs/graphs/Graph.cjs +200 -54
  5. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  6. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
  7. package/dist/cjs/hooks/createWorkspacePolicyHook.cjs +13 -7
  8. package/dist/cjs/hooks/createWorkspacePolicyHook.cjs.map +1 -1
  9. package/dist/cjs/hooks/executeHooks.cjs.map +1 -1
  10. package/dist/cjs/hooks/types.cjs.map +1 -1
  11. package/dist/cjs/instrumentation.cjs +33 -0
  12. package/dist/cjs/instrumentation.cjs.map +1 -1
  13. package/dist/cjs/langfuse.cjs +17 -1
  14. package/dist/cjs/langfuse.cjs.map +1 -1
  15. package/dist/cjs/langfuseToolOutputTracing.cjs +2 -2
  16. package/dist/cjs/langfuseToolOutputTracing.cjs.map +1 -1
  17. package/dist/cjs/llm/anthropic/index.cjs +1 -1
  18. package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
  19. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
  20. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +1 -1
  21. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
  22. package/dist/cjs/llm/bedrock/index.cjs +2 -2
  23. package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
  24. package/dist/cjs/llm/bedrock/toolCache.cjs +8 -5
  25. package/dist/cjs/llm/bedrock/toolCache.cjs.map +1 -1
  26. package/dist/cjs/llm/fake.cjs +16 -14
  27. package/dist/cjs/llm/fake.cjs.map +1 -1
  28. package/dist/cjs/llm/google/index.cjs +22 -0
  29. package/dist/cjs/llm/google/index.cjs.map +1 -1
  30. package/dist/cjs/llm/google/utils/common.cjs +88 -27
  31. package/dist/cjs/llm/google/utils/common.cjs.map +1 -1
  32. package/dist/cjs/llm/init.cjs +2 -2
  33. package/dist/cjs/llm/invoke.cjs +108 -11
  34. package/dist/cjs/llm/invoke.cjs.map +1 -1
  35. package/dist/cjs/llm/openai/index.cjs +1 -1
  36. package/dist/cjs/llm/openai/index.cjs.map +1 -1
  37. package/dist/cjs/llm/openai/utils/index.cjs +1 -1
  38. package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
  39. package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
  40. package/dist/cjs/llm/vertexai/index.cjs.map +1 -1
  41. package/dist/cjs/main.cjs +1 -0
  42. package/dist/cjs/main.cjs.map +1 -1
  43. package/dist/cjs/messages/cache.cjs +8 -7
  44. package/dist/cjs/messages/cache.cjs.map +1 -1
  45. package/dist/cjs/messages/content.cjs.map +1 -1
  46. package/dist/cjs/messages/contextPruning.cjs.map +1 -1
  47. package/dist/cjs/messages/format.cjs +124 -17
  48. package/dist/cjs/messages/format.cjs.map +1 -1
  49. package/dist/cjs/messages/prune.cjs.map +1 -1
  50. package/dist/cjs/messages/reducer.cjs +1 -1
  51. package/dist/cjs/messages/reducer.cjs.map +1 -1
  52. package/dist/cjs/messages/tools.cjs +1 -1
  53. package/dist/cjs/messages/tools.cjs.map +1 -1
  54. package/dist/cjs/openai/index.cjs.map +1 -1
  55. package/dist/cjs/responses/index.cjs.map +1 -1
  56. package/dist/cjs/run.cjs +47 -21
  57. package/dist/cjs/run.cjs.map +1 -1
  58. package/dist/cjs/session/AgentSession.cjs +4 -4
  59. package/dist/cjs/session/AgentSession.cjs.map +1 -1
  60. package/dist/cjs/session/JsonlSessionStore.cjs +2 -2
  61. package/dist/cjs/session/JsonlSessionStore.cjs.map +1 -1
  62. package/dist/cjs/session/handlers.cjs +2 -2
  63. package/dist/cjs/session/handlers.cjs.map +1 -1
  64. package/dist/cjs/stream.cjs +248 -25
  65. package/dist/cjs/stream.cjs.map +1 -1
  66. package/dist/cjs/summarization/node.cjs.map +1 -1
  67. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +1 -1
  68. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
  69. package/dist/cjs/tools/Calculator.cjs +1 -1
  70. package/dist/cjs/tools/Calculator.cjs.map +1 -1
  71. package/dist/cjs/tools/CodeExecutor.cjs +1 -1
  72. package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
  73. package/dist/cjs/tools/SubagentTool.cjs.map +1 -1
  74. package/dist/cjs/tools/ToolNode.cjs +37 -18
  75. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  76. package/dist/cjs/tools/ToolSearch.cjs +1 -1
  77. package/dist/cjs/tools/ToolSearch.cjs.map +1 -1
  78. package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs +7 -4
  79. package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs.map +1 -1
  80. package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs +4 -4
  81. package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs.map +1 -1
  82. package/dist/cjs/tools/handlers.cjs +2 -1
  83. package/dist/cjs/tools/handlers.cjs.map +1 -1
  84. package/dist/cjs/tools/local/CompileCheckTool.cjs.map +1 -1
  85. package/dist/cjs/tools/local/FileCheckpointer.cjs +2 -1
  86. package/dist/cjs/tools/local/FileCheckpointer.cjs.map +1 -1
  87. package/dist/cjs/tools/local/LocalCodingTools.cjs +45 -19
  88. package/dist/cjs/tools/local/LocalCodingTools.cjs.map +1 -1
  89. package/dist/cjs/tools/local/LocalExecutionEngine.cjs +3 -3
  90. package/dist/cjs/tools/local/LocalExecutionEngine.cjs.map +1 -1
  91. package/dist/cjs/tools/local/LocalExecutionTools.cjs +2 -2
  92. package/dist/cjs/tools/local/LocalExecutionTools.cjs.map +1 -1
  93. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +4 -3
  94. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
  95. package/dist/cjs/tools/local/attachments.cjs +0 -5
  96. package/dist/cjs/tools/local/attachments.cjs.map +1 -1
  97. package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs +4 -4
  98. package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -1
  99. package/dist/cjs/tools/search/firecrawl.cjs +1 -1
  100. package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
  101. package/dist/cjs/tools/search/rerankers.cjs +7 -3
  102. package/dist/cjs/tools/search/rerankers.cjs.map +1 -1
  103. package/dist/cjs/tools/search/tavily-search.cjs +1 -1
  104. package/dist/cjs/tools/search/tavily-search.cjs.map +1 -1
  105. package/dist/cjs/tools/search/utils.cjs +76 -8
  106. package/dist/cjs/tools/search/utils.cjs.map +1 -1
  107. package/dist/cjs/tools/subagent/SubagentExecutor.cjs +1 -1
  108. package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
  109. package/dist/cjs/utils/handlers.cjs +1 -1
  110. package/dist/cjs/utils/handlers.cjs.map +1 -1
  111. package/dist/cjs/utils/run.cjs +1 -1
  112. package/dist/cjs/utils/run.cjs.map +1 -1
  113. package/dist/esm/agents/AgentContext.mjs +3 -2
  114. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  115. package/dist/esm/events.mjs.map +1 -1
  116. package/dist/esm/graphs/Graph.mjs +200 -54
  117. package/dist/esm/graphs/Graph.mjs.map +1 -1
  118. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  119. package/dist/esm/hooks/createWorkspacePolicyHook.mjs +13 -7
  120. package/dist/esm/hooks/createWorkspacePolicyHook.mjs.map +1 -1
  121. package/dist/esm/hooks/executeHooks.mjs.map +1 -1
  122. package/dist/esm/hooks/types.mjs.map +1 -1
  123. package/dist/esm/instrumentation.mjs +33 -1
  124. package/dist/esm/instrumentation.mjs.map +1 -1
  125. package/dist/esm/langfuse.mjs +17 -2
  126. package/dist/esm/langfuse.mjs.map +1 -1
  127. package/dist/esm/langfuseToolOutputTracing.mjs +2 -2
  128. package/dist/esm/langfuseToolOutputTracing.mjs.map +1 -1
  129. package/dist/esm/llm/anthropic/index.mjs +1 -1
  130. package/dist/esm/llm/anthropic/index.mjs.map +1 -1
  131. package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
  132. package/dist/esm/llm/anthropic/utils/message_outputs.mjs +1 -1
  133. package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
  134. package/dist/esm/llm/bedrock/index.mjs +2 -2
  135. package/dist/esm/llm/bedrock/index.mjs.map +1 -1
  136. package/dist/esm/llm/bedrock/toolCache.mjs +8 -5
  137. package/dist/esm/llm/bedrock/toolCache.mjs.map +1 -1
  138. package/dist/esm/llm/fake.mjs +16 -14
  139. package/dist/esm/llm/fake.mjs.map +1 -1
  140. package/dist/esm/llm/google/index.mjs +23 -1
  141. package/dist/esm/llm/google/index.mjs.map +1 -1
  142. package/dist/esm/llm/google/utils/common.mjs +88 -27
  143. package/dist/esm/llm/google/utils/common.mjs.map +1 -1
  144. package/dist/esm/llm/init.mjs +2 -2
  145. package/dist/esm/llm/invoke.mjs +104 -7
  146. package/dist/esm/llm/invoke.mjs.map +1 -1
  147. package/dist/esm/llm/openai/index.mjs +1 -1
  148. package/dist/esm/llm/openai/index.mjs.map +1 -1
  149. package/dist/esm/llm/openai/utils/index.mjs +1 -1
  150. package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
  151. package/dist/esm/llm/openrouter/index.mjs.map +1 -1
  152. package/dist/esm/llm/vertexai/index.mjs.map +1 -1
  153. package/dist/esm/main.mjs +1 -1
  154. package/dist/esm/messages/cache.mjs +8 -7
  155. package/dist/esm/messages/cache.mjs.map +1 -1
  156. package/dist/esm/messages/content.mjs.map +1 -1
  157. package/dist/esm/messages/contextPruning.mjs.map +1 -1
  158. package/dist/esm/messages/format.mjs +124 -18
  159. package/dist/esm/messages/format.mjs.map +1 -1
  160. package/dist/esm/messages/prune.mjs.map +1 -1
  161. package/dist/esm/messages/reducer.mjs +1 -1
  162. package/dist/esm/messages/reducer.mjs.map +1 -1
  163. package/dist/esm/messages/tools.mjs +1 -1
  164. package/dist/esm/messages/tools.mjs.map +1 -1
  165. package/dist/esm/openai/index.mjs.map +1 -1
  166. package/dist/esm/responses/index.mjs.map +1 -1
  167. package/dist/esm/run.mjs +47 -21
  168. package/dist/esm/run.mjs.map +1 -1
  169. package/dist/esm/session/AgentSession.mjs +4 -4
  170. package/dist/esm/session/AgentSession.mjs.map +1 -1
  171. package/dist/esm/session/JsonlSessionStore.mjs +2 -2
  172. package/dist/esm/session/JsonlSessionStore.mjs.map +1 -1
  173. package/dist/esm/session/handlers.mjs +2 -2
  174. package/dist/esm/session/handlers.mjs.map +1 -1
  175. package/dist/esm/stream.mjs +248 -25
  176. package/dist/esm/stream.mjs.map +1 -1
  177. package/dist/esm/summarization/node.mjs.map +1 -1
  178. package/dist/esm/tools/BashProgrammaticToolCalling.mjs +1 -1
  179. package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
  180. package/dist/esm/tools/Calculator.mjs +1 -1
  181. package/dist/esm/tools/Calculator.mjs.map +1 -1
  182. package/dist/esm/tools/CodeExecutor.mjs +1 -1
  183. package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
  184. package/dist/esm/tools/SubagentTool.mjs.map +1 -1
  185. package/dist/esm/tools/ToolNode.mjs +37 -18
  186. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  187. package/dist/esm/tools/ToolSearch.mjs +1 -1
  188. package/dist/esm/tools/ToolSearch.mjs.map +1 -1
  189. package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs +7 -4
  190. package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs.map +1 -1
  191. package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs +4 -4
  192. package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs.map +1 -1
  193. package/dist/esm/tools/handlers.mjs +2 -1
  194. package/dist/esm/tools/handlers.mjs.map +1 -1
  195. package/dist/esm/tools/local/CompileCheckTool.mjs.map +1 -1
  196. package/dist/esm/tools/local/FileCheckpointer.mjs +2 -1
  197. package/dist/esm/tools/local/FileCheckpointer.mjs.map +1 -1
  198. package/dist/esm/tools/local/LocalCodingTools.mjs +45 -19
  199. package/dist/esm/tools/local/LocalCodingTools.mjs.map +1 -1
  200. package/dist/esm/tools/local/LocalExecutionEngine.mjs +3 -3
  201. package/dist/esm/tools/local/LocalExecutionEngine.mjs.map +1 -1
  202. package/dist/esm/tools/local/LocalExecutionTools.mjs +2 -2
  203. package/dist/esm/tools/local/LocalExecutionTools.mjs.map +1 -1
  204. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +4 -3
  205. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
  206. package/dist/esm/tools/local/attachments.mjs +0 -5
  207. package/dist/esm/tools/local/attachments.mjs.map +1 -1
  208. package/dist/esm/tools/local/resolveLocalExecutionTools.mjs +4 -4
  209. package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -1
  210. package/dist/esm/tools/search/firecrawl.mjs +1 -1
  211. package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
  212. package/dist/esm/tools/search/rerankers.mjs +8 -4
  213. package/dist/esm/tools/search/rerankers.mjs.map +1 -1
  214. package/dist/esm/tools/search/tavily-search.mjs +1 -1
  215. package/dist/esm/tools/search/tavily-search.mjs.map +1 -1
  216. package/dist/esm/tools/search/utils.mjs +76 -9
  217. package/dist/esm/tools/search/utils.mjs.map +1 -1
  218. package/dist/esm/tools/subagent/SubagentExecutor.mjs +1 -1
  219. package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
  220. package/dist/esm/utils/handlers.mjs +1 -1
  221. package/dist/esm/utils/handlers.mjs.map +1 -1
  222. package/dist/esm/utils/run.mjs +1 -1
  223. package/dist/esm/utils/run.mjs.map +1 -1
  224. package/dist/types/agents/__tests__/promptCacheLiveHelpers.d.ts +1 -1
  225. package/dist/types/events.d.ts +1 -1
  226. package/dist/types/graphs/Graph.d.ts +7 -1
  227. package/dist/types/hooks/executeHooks.d.ts +1 -1
  228. package/dist/types/hooks/types.d.ts +5 -0
  229. package/dist/types/instrumentation.d.ts +1 -0
  230. package/dist/types/langfuse.d.ts +4 -0
  231. package/dist/types/llm/anthropic/utils/message_inputs.d.ts +1 -1
  232. package/dist/types/llm/anthropic/utils/message_outputs.d.ts +1 -1
  233. package/dist/types/llm/anthropic/utils/output_parsers.d.ts +2 -2
  234. package/dist/types/llm/bedrock/index.d.ts +2 -2
  235. package/dist/types/llm/fake.d.ts +3 -3
  236. package/dist/types/llm/google/index.d.ts +1 -0
  237. package/dist/types/llm/google/types.d.ts +1 -1
  238. package/dist/types/llm/google/utils/common.d.ts +2 -2
  239. package/dist/types/llm/google/utils/tools.d.ts +1 -1
  240. package/dist/types/llm/google/utils/zod_to_genai_parameters.d.ts +1 -1
  241. package/dist/types/llm/openai/index.d.ts +2 -2
  242. package/dist/types/llm/openai/utils/index.d.ts +1 -1
  243. package/dist/types/llm/openrouter/index.d.ts +4 -4
  244. package/dist/types/messages/contextPruning.d.ts +1 -1
  245. package/dist/types/messages/format.d.ts +9 -4
  246. package/dist/types/messages/prune.d.ts +1 -1
  247. package/dist/types/session/JsonlSessionStore.d.ts +1 -1
  248. package/dist/types/session/handlers.d.ts +1 -1
  249. package/dist/types/session/types.d.ts +1 -1
  250. package/dist/types/summarization/node.d.ts +1 -1
  251. package/dist/types/tools/SubagentTool.d.ts +2 -2
  252. package/dist/types/tools/ToolNode.d.ts +9 -2
  253. package/dist/types/tools/cloudflare/CloudflareSandboxExecutionEngine.d.ts +1 -1
  254. package/dist/types/tools/search/types.d.ts +1 -1
  255. package/dist/types/tools/search/utils.d.ts +11 -0
  256. package/dist/types/types/graph.d.ts +12 -4
  257. package/dist/types/types/llm.d.ts +4 -3
  258. package/dist/types/types/messages.d.ts +1 -1
  259. package/dist/types/types/run.d.ts +6 -6
  260. package/dist/types/types/stream.d.ts +2 -2
  261. package/dist/types/types/tools.d.ts +5 -1
  262. package/dist/types/utils/handlers.d.ts +2 -2
  263. package/dist/types/utils/run.d.ts +1 -1
  264. package/package.json +6 -3
  265. package/src/__tests__/stream.eagerEventExecution.test.ts +543 -6
  266. package/src/agents/AgentContext.ts +2 -2
  267. package/src/agents/__tests__/AgentContext.test.ts +3 -3
  268. package/src/agents/__tests__/promptCacheLiveHelpers.ts +1 -1
  269. package/src/events.ts +1 -1
  270. package/src/graphs/Graph.ts +329 -72
  271. package/src/graphs/MultiAgentGraph.ts +1 -1
  272. package/src/graphs/__tests__/Graph.reasoning.test.ts +919 -6
  273. package/src/graphs/__tests__/MultiAgentGraph.test.ts +1 -1
  274. package/src/graphs/__tests__/composition.smoke.test.ts +1 -1
  275. package/src/hooks/__tests__/HookRegistry.test.ts +1 -1
  276. package/src/hooks/__tests__/compactHooks.test.ts +8 -8
  277. package/src/hooks/__tests__/createWorkspacePolicyHook.test.ts +34 -22
  278. package/src/hooks/__tests__/executeHooks.test.ts +3 -3
  279. package/src/hooks/__tests__/integration.test.ts +3 -3
  280. package/src/hooks/__tests__/toolHooks.test.ts +10 -10
  281. package/src/hooks/createWorkspacePolicyHook.ts +17 -14
  282. package/src/hooks/executeHooks.ts +1 -1
  283. package/src/hooks/types.ts +5 -0
  284. package/src/instrumentation.ts +49 -8
  285. package/src/langfuse.ts +35 -1
  286. package/src/langfuseToolOutputTracing.ts +2 -2
  287. package/src/llm/anthropic/index.ts +1 -1
  288. package/src/llm/anthropic/utils/message_inputs.ts +1 -1
  289. package/src/llm/anthropic/utils/message_outputs.ts +3 -5
  290. package/src/llm/anthropic/utils/output_parsers.ts +5 -5
  291. package/src/llm/bedrock/index.ts +4 -4
  292. package/src/llm/bedrock/toolCache.test.ts +48 -9
  293. package/src/llm/bedrock/toolCache.ts +11 -6
  294. package/src/llm/custom-chat-models.smoke.test.ts +114 -0
  295. package/src/llm/fake.ts +30 -25
  296. package/src/llm/google/index.ts +43 -1
  297. package/src/llm/google/llm.spec.ts +173 -1
  298. package/src/llm/google/types.ts +1 -1
  299. package/src/llm/google/utils/common.ts +154 -45
  300. package/src/llm/google/utils/tools.ts +8 -8
  301. package/src/llm/google/utils/zod_to_genai_parameters.ts +4 -4
  302. package/src/llm/invoke.test.ts +3 -3
  303. package/src/llm/invoke.ts +170 -10
  304. package/src/llm/openai/index.ts +4 -4
  305. package/src/llm/openai/utils/index.ts +14 -14
  306. package/src/llm/openrouter/index.ts +4 -4
  307. package/src/llm/openrouter/reasoning.test.ts +2 -2
  308. package/src/llm/vertexai/fixThoughtSignatures.test.ts +1 -1
  309. package/src/llm/vertexai/index.ts +1 -1
  310. package/src/messages/cache.test.ts +22 -0
  311. package/src/messages/cache.ts +25 -12
  312. package/src/messages/content.ts +1 -1
  313. package/src/messages/contextPruning.ts +1 -1
  314. package/src/messages/format.ts +227 -43
  315. package/src/messages/formatAgentMessages.skills.test.ts +105 -26
  316. package/src/messages/formatAgentMessages.test.ts +841 -10
  317. package/src/messages/labelContentByAgent.test.ts +2 -2
  318. package/src/messages/prune.ts +1 -1
  319. package/src/messages/reducer.ts +1 -1
  320. package/src/messages/tools.ts +1 -1
  321. package/src/openai/__tests__/openai.test.ts +2 -2
  322. package/src/openai/index.ts +1 -1
  323. package/src/responses/__tests__/responses.test.ts +2 -2
  324. package/src/responses/index.ts +1 -1
  325. package/src/run.ts +82 -47
  326. package/src/session/AgentSession.ts +6 -6
  327. package/src/session/JsonlSessionStore.ts +3 -3
  328. package/src/session/__tests__/JsonlSessionStore.test.ts +5 -5
  329. package/src/session/__tests__/handlers.test.ts +2 -2
  330. package/src/session/handlers.ts +5 -5
  331. package/src/session/types.ts +1 -1
  332. package/src/specs/agent-handoffs.test.ts +1 -1
  333. package/src/specs/deterministic-trace-id.test.ts +50 -0
  334. package/src/specs/langfuse-callbacks.test.ts +2 -2
  335. package/src/specs/langfuse-metadata.test.ts +39 -0
  336. package/src/specs/langfuse-tool-output-tracing.test.ts +1 -1
  337. package/src/specs/multi-agent-summarization.test.ts +4 -4
  338. package/src/specs/subagent.test.ts +3 -3
  339. package/src/specs/summarization-unit.test.ts +1 -1
  340. package/src/specs/thinking-handoff.test.ts +1 -1
  341. package/src/splitStream.test.ts +48 -0
  342. package/src/stream.test.ts +53 -3
  343. package/src/stream.ts +450 -39
  344. package/src/summarization/__tests__/aggregator.test.ts +2 -2
  345. package/src/summarization/__tests__/node.test.ts +2 -2
  346. package/src/summarization/node.ts +1 -1
  347. package/src/tools/BashProgrammaticToolCalling.ts +5 -5
  348. package/src/tools/Calculator.ts +1 -1
  349. package/src/tools/CodeExecutor.ts +2 -4
  350. package/src/tools/SubagentTool.ts +2 -2
  351. package/src/tools/ToolNode.ts +37 -16
  352. package/src/tools/ToolSearch.ts +1 -1
  353. package/src/tools/__tests__/CloudflareSandboxExecution.test.ts +4 -4
  354. package/src/tools/__tests__/CodeApiAuthHeaders.test.ts +12 -12
  355. package/src/tools/__tests__/LocalExecutionTools.test.ts +125 -93
  356. package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +29 -5
  357. package/src/tools/__tests__/ReadFile.test.ts +1 -1
  358. package/src/tools/__tests__/SkillTool.test.ts +4 -4
  359. package/src/tools/__tests__/SubagentExecutor.test.ts +17 -13
  360. package/src/tools/__tests__/SubagentTool.test.ts +2 -2
  361. package/src/tools/__tests__/ToolNode.eagerEventExecution.test.ts +1 -1
  362. package/src/tools/__tests__/ToolNode.outputReferences.test.ts +2 -5
  363. package/src/tools/__tests__/ToolNode.session.test.ts +1 -1
  364. package/src/tools/__tests__/ToolSearch.test.ts +1 -1
  365. package/src/tools/__tests__/annotateMessagesForLLM.test.ts +1 -1
  366. package/src/tools/__tests__/directToolHITLResumeScope.test.ts +35 -32
  367. package/src/tools/__tests__/directToolHooks.test.ts +41 -0
  368. package/src/tools/__tests__/handlers.test.ts +2 -2
  369. package/src/tools/__tests__/hitl.test.ts +11 -11
  370. package/src/tools/__tests__/localToolNames.test.ts +8 -6
  371. package/src/tools/__tests__/skillCatalog.test.ts +1 -1
  372. package/src/tools/__tests__/subagentHooks.test.ts +20 -10
  373. package/src/tools/__tests__/workspaceSeam.test.ts +20 -7
  374. package/src/tools/cloudflare/CloudflareSandboxExecutionEngine.ts +9 -6
  375. package/src/tools/cloudflare/CloudflareSandboxTools.ts +19 -19
  376. package/src/tools/handlers.ts +5 -5
  377. package/src/tools/local/CompileCheckTool.ts +4 -7
  378. package/src/tools/local/FileCheckpointer.ts +6 -5
  379. package/src/tools/local/LocalCodingTools.ts +100 -45
  380. package/src/tools/local/LocalExecutionEngine.ts +5 -5
  381. package/src/tools/local/LocalExecutionTools.ts +9 -9
  382. package/src/tools/local/LocalProgrammaticToolCalling.ts +5 -4
  383. package/src/tools/local/attachments.ts +0 -6
  384. package/src/tools/local/resolveLocalExecutionTools.ts +15 -15
  385. package/src/tools/search/firecrawl.ts +1 -1
  386. package/src/tools/search/jina-reranker.test.ts +148 -37
  387. package/src/tools/search/rerankers.ts +14 -4
  388. package/src/tools/search/tavily-search.ts +2 -2
  389. package/src/tools/search/types.ts +1 -1
  390. package/src/tools/search/utils.ts +99 -9
  391. package/src/tools/subagent/SubagentExecutor.ts +12 -6
  392. package/src/types/graph.ts +20 -12
  393. package/src/types/llm.ts +7 -6
  394. package/src/types/messages.ts +1 -1
  395. package/src/types/run.ts +7 -7
  396. package/src/types/stream.ts +2 -2
  397. package/src/types/tools.ts +5 -1
  398. package/src/utils/handlers.ts +2 -2
  399. package/src/utils/llmConfig.ts +1 -1
  400. package/src/utils/logging.ts +20 -10
  401. package/src/utils/run.ts +2 -2
@@ -1,18 +1,72 @@
1
- import { JinaReranker } from './rerankers';
1
+ import axios from 'axios';
2
+
3
+ import { createReranker, JinaReranker } from './rerankers';
2
4
  import { createDefaultLogger } from './utils';
3
5
 
6
+ type AxiosErrorFixture = Error & {
7
+ isAxiosError: true;
8
+ code: string;
9
+ config: {
10
+ data: string;
11
+ headers: {
12
+ Authorization: string;
13
+ };
14
+ method: string;
15
+ url: string;
16
+ };
17
+ response: {
18
+ data: {
19
+ details?: string;
20
+ message: string;
21
+ };
22
+ status: number;
23
+ };
24
+ };
25
+
26
+ const getApiUrl = (reranker: JinaReranker): string => {
27
+ const descriptor = Object.getOwnPropertyDescriptor(reranker, 'apiUrl');
28
+ if (typeof descriptor?.value === 'string') {
29
+ return descriptor.value;
30
+ }
31
+ throw new Error('Expected JinaReranker apiUrl to be initialized.');
32
+ };
33
+
34
+ const createAxiosErrorFixture = (
35
+ url: string,
36
+ responseData: AxiosErrorFixture['response']['data']
37
+ ): AxiosErrorFixture =>
38
+ Object.assign(new Error('Request failed with status code 500'), {
39
+ isAxiosError: true as const,
40
+ code: 'ERR_BAD_RESPONSE',
41
+ config: {
42
+ data: JSON.stringify({ documents: ['document1', 'document2'] }),
43
+ headers: {
44
+ Authorization: 'Bearer test-key',
45
+ },
46
+ method: 'post',
47
+ url,
48
+ },
49
+ response: {
50
+ data: responseData,
51
+ status: 500,
52
+ },
53
+ });
54
+
4
55
  describe('JinaReranker', () => {
5
56
  const mockLogger = createDefaultLogger();
6
-
57
+
58
+ afterEach(() => {
59
+ jest.restoreAllMocks();
60
+ });
61
+
7
62
  describe('constructor', () => {
8
63
  it('should use default API URL when no apiUrl is provided', () => {
9
64
  const reranker = new JinaReranker({
10
65
  apiKey: 'test-key',
11
66
  logger: mockLogger,
12
67
  });
13
-
14
- // Access private property for testing
15
- const apiUrl = (reranker as any).apiUrl;
68
+
69
+ const apiUrl = getApiUrl(reranker);
16
70
  expect(apiUrl).toBe('https://api.jina.ai/v1/rerank');
17
71
  });
18
72
 
@@ -23,25 +77,24 @@ describe('JinaReranker', () => {
23
77
  apiUrl: customUrl,
24
78
  logger: mockLogger,
25
79
  });
26
-
27
- const apiUrl = (reranker as any).apiUrl;
80
+
81
+ const apiUrl = getApiUrl(reranker);
28
82
  expect(apiUrl).toBe(customUrl);
29
83
  });
30
84
 
31
85
  it('should use environment variable JINA_API_URL when available', () => {
32
86
  const originalEnv = process.env.JINA_API_URL;
33
87
  process.env.JINA_API_URL = 'https://env-jina-endpoint.com/v1/rerank';
34
-
88
+
35
89
  const reranker = new JinaReranker({
36
90
  apiKey: 'test-key',
37
91
  logger: mockLogger,
38
92
  });
39
-
40
- const apiUrl = (reranker as any).apiUrl;
93
+
94
+ const apiUrl = getApiUrl(reranker);
41
95
  expect(apiUrl).toBe('https://env-jina-endpoint.com/v1/rerank');
42
-
43
- // Restore original environment
44
- if (originalEnv) {
96
+
97
+ if (typeof originalEnv === 'string') {
45
98
  process.env.JINA_API_URL = originalEnv;
46
99
  } else {
47
100
  delete process.env.JINA_API_URL;
@@ -51,19 +104,18 @@ describe('JinaReranker', () => {
51
104
  it('should prioritize explicit apiUrl over environment variable', () => {
52
105
  const originalEnv = process.env.JINA_API_URL;
53
106
  process.env.JINA_API_URL = 'https://env-jina-endpoint.com/v1/rerank';
54
-
107
+
55
108
  const customUrl = 'https://explicit-jina-endpoint.com/v1/rerank';
56
109
  const reranker = new JinaReranker({
57
110
  apiKey: 'test-key',
58
111
  apiUrl: customUrl,
59
112
  logger: mockLogger,
60
113
  });
61
-
62
- const apiUrl = (reranker as any).apiUrl;
114
+
115
+ const apiUrl = getApiUrl(reranker);
63
116
  expect(apiUrl).toBe(customUrl);
64
-
65
- // Restore original environment
66
- if (originalEnv) {
117
+
118
+ if (typeof originalEnv === 'string') {
67
119
  process.env.JINA_API_URL = originalEnv;
68
120
  } else {
69
121
  delete process.env.JINA_API_URL;
@@ -79,27 +131,80 @@ describe('JinaReranker', () => {
79
131
  apiUrl: customUrl,
80
132
  logger: mockLogger,
81
133
  });
82
-
83
- const logSpy = jest.spyOn(mockLogger, 'debug');
84
-
85
- try {
86
- await reranker.rerank('test query', ['document1', 'document2'], 2);
87
- } catch (error) {
88
- // Expected to fail due to missing API key, but we can check the log
89
- }
90
-
134
+
135
+ const logSpy = jest
136
+ .spyOn(mockLogger, 'debug')
137
+ .mockImplementation(() => mockLogger);
138
+ jest.spyOn(mockLogger, 'error').mockImplementation(() => mockLogger);
139
+ jest
140
+ .spyOn(axios, 'post')
141
+ .mockRejectedValueOnce(new Error('Network error'));
142
+
143
+ await reranker.rerank('test query', ['document1', 'document2'], 2);
144
+
91
145
  expect(logSpy).toHaveBeenCalledWith(
92
- expect.stringContaining(`Reranking 2 chunks with Jina using API URL: ${customUrl}`)
146
+ expect.stringContaining(
147
+ `Reranking 2 chunks with Jina using API URL: ${customUrl}`
148
+ )
149
+ );
150
+ });
151
+
152
+ it('should log compact Axios errors without request internals', async () => {
153
+ const customUrl = 'https://test-jina-endpoint.com/v1/rerank?api_key=hidden';
154
+ const reranker = new JinaReranker({
155
+ apiKey: 'test-key',
156
+ apiUrl: customUrl,
157
+ logger: mockLogger,
158
+ });
159
+ const errorSpy = jest
160
+ .spyOn(mockLogger, 'error')
161
+ .mockImplementation(() => mockLogger);
162
+ jest.spyOn(mockLogger, 'debug').mockImplementation(() => mockLogger);
163
+ jest.spyOn(axios, 'isAxiosError').mockReturnValue(true);
164
+ jest.spyOn(axios, 'post').mockRejectedValueOnce(
165
+ createAxiosErrorFixture(customUrl, {
166
+ message: 'upstream failed',
167
+ details: 'x'.repeat(5000),
168
+ })
169
+ );
170
+
171
+ const result = await reranker.rerank(
172
+ 'test query',
173
+ ['document1', 'document2'],
174
+ 2
175
+ );
176
+
177
+ expect(result).toEqual([
178
+ { text: 'document1', score: 0 },
179
+ { text: 'document2', score: 0 },
180
+ ]);
181
+ expect(errorSpy).toHaveBeenCalledWith(
182
+ 'Error using Jina reranker',
183
+ expect.objectContaining({
184
+ code: 'ERR_BAD_RESPONSE',
185
+ message: 'Request failed with status code 500',
186
+ method: 'POST',
187
+ name: 'Error',
188
+ responseDataSummary: 'object(2)',
189
+ status: 500,
190
+ url: 'https://test-jina-endpoint.com/v1/rerank',
191
+ })
93
192
  );
94
-
95
- logSpy.mockRestore();
193
+
194
+ const metadata = errorSpy.mock.calls.flat()[1];
195
+ const serializedMetadata = JSON.stringify(metadata);
196
+
197
+ expect(serializedMetadata).not.toContain('upstream failed');
198
+ expect(serializedMetadata).not.toContain('Authorization');
199
+ expect(serializedMetadata).not.toContain('api_key');
200
+ expect(serializedMetadata).not.toContain('document1');
201
+ expect(serializedMetadata).not.toContain('test-key');
202
+ expect(serializedMetadata.length).toBeLessThan(500);
96
203
  });
97
204
  });
98
205
  });
99
206
 
100
207
  describe('createReranker', () => {
101
- const { createReranker } = require('./rerankers');
102
-
103
208
  it('should create JinaReranker with jinaApiUrl when provided', () => {
104
209
  const customUrl = 'https://custom-jina-endpoint.com/v1/rerank';
105
210
  const reranker = createReranker({
@@ -107,9 +212,12 @@ describe('createReranker', () => {
107
212
  jinaApiKey: 'test-key',
108
213
  jinaApiUrl: customUrl,
109
214
  });
110
-
215
+
111
216
  expect(reranker).toBeInstanceOf(JinaReranker);
112
- const apiUrl = (reranker as any).apiUrl;
217
+ if (!(reranker instanceof JinaReranker)) {
218
+ throw new Error('Expected createReranker to return a JinaReranker.');
219
+ }
220
+ const apiUrl = getApiUrl(reranker);
113
221
  expect(apiUrl).toBe(customUrl);
114
222
  });
115
223
 
@@ -118,9 +226,12 @@ describe('createReranker', () => {
118
226
  rerankerType: 'jina',
119
227
  jinaApiKey: 'test-key',
120
228
  });
121
-
229
+
122
230
  expect(reranker).toBeInstanceOf(JinaReranker);
123
- const apiUrl = (reranker as any).apiUrl;
231
+ if (!(reranker instanceof JinaReranker)) {
232
+ throw new Error('Expected createReranker to return a JinaReranker.');
233
+ }
234
+ const apiUrl = getApiUrl(reranker);
124
235
  expect(apiUrl).toBe('https://api.jina.ai/v1/rerank');
125
236
  });
126
237
  });
@@ -1,6 +1,13 @@
1
1
  import axios from 'axios';
2
2
  import type * as t from './types';
3
- import { createDefaultLogger } from './utils';
3
+ import { createDefaultLogger, formatErrorForLog } from './utils';
4
+
5
+ const DEFAULT_JINA_API_URL = 'https://api.jina.ai/v1/rerank';
6
+
7
+ const getDefaultJinaApiUrl = (): string =>
8
+ process.env.JINA_API_URL != null && process.env.JINA_API_URL !== ''
9
+ ? process.env.JINA_API_URL
10
+ : DEFAULT_JINA_API_URL;
4
11
 
5
12
  export abstract class BaseReranker {
6
13
  protected apiKey: string | undefined;
@@ -32,7 +39,7 @@ export class JinaReranker extends BaseReranker {
32
39
 
33
40
  constructor({
34
41
  apiKey = process.env.JINA_API_KEY,
35
- apiUrl = process.env.JINA_API_URL || 'https://api.jina.ai/v1/rerank',
42
+ apiUrl = getDefaultJinaApiUrl(),
36
43
  logger,
37
44
  }: {
38
45
  apiKey?: string;
@@ -107,7 +114,7 @@ export class JinaReranker extends BaseReranker {
107
114
  return this.getDefaultRanking(documents, topK);
108
115
  }
109
116
  } catch (error) {
110
- this.logger.error('Error using Jina reranker:', error);
117
+ this.logger.error('Error using Jina reranker', formatErrorForLog(error));
111
118
  // Fallback to default ranking on error
112
119
  return this.getDefaultRanking(documents, topK);
113
120
  }
@@ -174,7 +181,10 @@ export class CohereReranker extends BaseReranker {
174
181
  return this.getDefaultRanking(documents, topK);
175
182
  }
176
183
  } catch (error) {
177
- this.logger.error('Error using Cohere reranker:', error);
184
+ this.logger.error(
185
+ 'Error using Cohere reranker',
186
+ formatErrorForLog(error)
187
+ );
178
188
  // Fallback to default ranking on error
179
189
  return this.getDefaultRanking(documents, topK);
180
190
  }
@@ -3,7 +3,7 @@ import type * as t from './types';
3
3
 
4
4
  const DEFAULT_TAVILY_TIMEOUT = 15000;
5
5
 
6
- const TAVILY_COUNTRY_ALIASES: Record<string, string> = {
6
+ const TAVILY_COUNTRY_ALIASES: Partial<Record<string, string>> = {
7
7
  ba: 'bosnia and herzegovina',
8
8
  cg: 'congo',
9
9
  cz: 'czech republic',
@@ -319,7 +319,7 @@ export const createTavilyAPI = (
319
319
  if (tavilyCountry != null) {
320
320
  payload.country = tavilyCountry;
321
321
  }
322
- if (type === 'images' || options?.includeImages) {
322
+ if (type === 'images' || options?.includeImages === true) {
323
323
  payload.include_images = true;
324
324
  }
325
325
  if (options?.includeAnswer != null) {
@@ -1,5 +1,5 @@
1
- import type { Logger as WinstonLogger } from 'winston';
2
1
  import type { RunnableConfig } from '@langchain/core/runnables';
2
+ import type { Logger as WinstonLogger } from 'winston';
3
3
  import type { BaseReranker } from './rerankers';
4
4
  import { DATE_RANGE } from './schema';
5
5
 
@@ -1,7 +1,23 @@
1
1
  /* eslint-disable no-console */
2
2
 
3
+ import { isAxiosError } from 'axios';
4
+
5
+ import type { AxiosError } from 'axios';
3
6
  import type * as t from './types';
4
7
 
8
+ const LOG_VALUE_MAX_LENGTH = 2048;
9
+
10
+ export interface SafeErrorLog {
11
+ message: string;
12
+ name?: string;
13
+ code?: string;
14
+ status?: number;
15
+ method?: string;
16
+ url?: string;
17
+ responseDataSummary?: string;
18
+ value?: string;
19
+ }
20
+
5
21
  /**
6
22
  * Singleton instance of the default logger
7
23
  */
@@ -24,6 +40,83 @@ export const createDefaultLogger = (): t.Logger => {
24
40
  return defaultLoggerInstance;
25
41
  };
26
42
 
43
+ const truncateLogValue = (value: string): string =>
44
+ value.length <= LOG_VALUE_MAX_LENGTH
45
+ ? value
46
+ : `${value.slice(0, LOG_VALUE_MAX_LENGTH)}... [truncated]`;
47
+
48
+ const summarizeLogValue = (value: unknown): string => {
49
+ if (value === null) {
50
+ return 'null';
51
+ }
52
+ if (Array.isArray(value)) {
53
+ return `array(${value.length})`;
54
+ }
55
+ if (typeof value === 'string') {
56
+ return `string(${value.length})`;
57
+ }
58
+ if (typeof value === 'object') {
59
+ return `object(${Object.keys(value).length})`;
60
+ }
61
+ return typeof value;
62
+ };
63
+
64
+ const sanitizeUrlForLog = (url: string): string => {
65
+ try {
66
+ const parsed = new URL(url);
67
+ return truncateLogValue(`${parsed.origin}${parsed.pathname}`);
68
+ } catch {
69
+ return truncateLogValue(url.split('?')[0].split('#')[0]);
70
+ }
71
+ };
72
+
73
+ const formatAxiosErrorForLog = (
74
+ error: AxiosError<unknown, unknown>
75
+ ): SafeErrorLog => {
76
+ const log: SafeErrorLog = {
77
+ message: error.message,
78
+ name: error.name,
79
+ };
80
+ const { code, config, response, status } = error;
81
+ const responseStatus = response?.status ?? status;
82
+ const method = config?.method;
83
+ const url = config?.url;
84
+
85
+ if (typeof code === 'string' && code !== '') {
86
+ log.code = code;
87
+ }
88
+ if (responseStatus != null) {
89
+ log.status = responseStatus;
90
+ }
91
+ if (typeof method === 'string' && method !== '') {
92
+ log.method = method.toUpperCase();
93
+ }
94
+ if (typeof url === 'string' && url !== '') {
95
+ log.url = sanitizeUrlForLog(url);
96
+ }
97
+ if (typeof response?.data !== 'undefined') {
98
+ log.responseDataSummary = summarizeLogValue(response.data);
99
+ }
100
+
101
+ return log;
102
+ };
103
+
104
+ export const formatErrorForLog = (error: unknown): SafeErrorLog => {
105
+ if (isAxiosError<unknown, unknown>(error)) {
106
+ return formatAxiosErrorForLog(error);
107
+ }
108
+ if (error instanceof Error) {
109
+ return {
110
+ message: error.message,
111
+ name: error.name,
112
+ };
113
+ }
114
+ return {
115
+ message: String(error),
116
+ value: summarizeLogValue(error),
117
+ };
118
+ };
119
+
27
120
  export const fileExtRegex =
28
121
  /\.(pdf|jpe?g|png|gif|svg|webp|bmp|ico|tiff?|avif|heic|doc[xm]?|xls[xm]?|ppt[xm]?|zip|rar|mp[34]|mov|avi|wav)(?:\?.*)?$/i;
29
122
 
@@ -33,16 +126,13 @@ export const getDomainName = (
33
126
  logger?: t.Logger
34
127
  ): string | undefined => {
35
128
  try {
36
- const sourceUrl = metadata?.sourceURL;
37
- const metadataUrl = metadata?.url;
38
- const url =
39
- typeof sourceUrl === 'string'
40
- ? sourceUrl
41
- : typeof metadataUrl === 'string'
42
- ? metadataUrl
43
- : link || '';
129
+ const sourceUrl =
130
+ typeof metadata?.sourceURL === 'string' ? metadata.sourceURL : undefined;
131
+ const metadataUrl =
132
+ typeof metadata?.url === 'string' ? metadata.url : undefined;
133
+ const url = sourceUrl ?? metadataUrl ?? link;
44
134
  const domain = new URL(url).hostname.replace(/^www\./, '');
45
- if (domain) {
135
+ if (domain !== '') {
46
136
  return domain;
47
137
  }
48
138
  } catch (e) {
@@ -1,8 +1,8 @@
1
1
  import { nanoid } from 'nanoid';
2
- import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
3
2
  import { HumanMessage } from '@langchain/core/messages';
4
- import type { BaseMessage } from '@langchain/core/messages';
3
+ import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
5
4
  import type { Callbacks } from '@langchain/core/callbacks/manager';
5
+ import type { BaseMessage } from '@langchain/core/messages';
6
6
  import type {
7
7
  AgentInputs,
8
8
  MessageDeltaEvent,
@@ -23,8 +23,8 @@ import type {
23
23
  import type { AggregatedHookResult, HookRegistry } from '@/hooks';
24
24
  import type { AgentContext } from '@/agents/AgentContext';
25
25
  import type { StandardGraph } from '@/graphs/Graph';
26
- import { GraphEvents, Callback, StepTypes } from '@/common';
27
26
  import type { HandlerRegistry } from '@/events';
27
+ import { GraphEvents, Callback, StepTypes } from '@/common';
28
28
  import { executeHooks } from '@/hooks';
29
29
 
30
30
  const DEFAULT_MAX_TURNS = 25;
@@ -797,7 +797,9 @@ function sanitizeToolCallForUpdate(
797
797
  return sanitized;
798
798
  }
799
799
 
800
- function sanitizeRunStepUpdateData(data: unknown): SanitizedRunStep | undefined {
800
+ function sanitizeRunStepUpdateData(
801
+ data: unknown
802
+ ): SanitizedRunStep | undefined {
801
803
  if (!isObjectLike(data)) {
802
804
  return undefined;
803
805
  }
@@ -879,7 +881,9 @@ function sanitizeReasoningDeltaUpdateData(
879
881
  return sanitized;
880
882
  }
881
883
 
882
- function sanitizeStepDetails(stepDetails: unknown): SanitizedStepDetails | undefined {
884
+ function sanitizeStepDetails(
885
+ stepDetails: unknown
886
+ ): SanitizedStepDetails | undefined {
883
887
  if (!isObjectLike(stepDetails)) {
884
888
  return undefined;
885
889
  }
@@ -929,7 +933,9 @@ function sanitizeToolCallDelta(
929
933
  return sanitized;
930
934
  }
931
935
 
932
- function sanitizeStepCompleted(data: unknown): SanitizedStepCompleted | undefined {
936
+ function sanitizeStepCompleted(
937
+ data: unknown
938
+ ): SanitizedStepCompleted | undefined {
933
939
  if (!isObjectLike(data)) {
934
940
  return undefined;
935
941
  }
@@ -1,24 +1,14 @@
1
1
  // src/types/graph.ts
2
- import type { START, StateGraph, StateGraphArgs } from '@langchain/langgraph';
3
- import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
4
2
  import type {
5
3
  BaseMessage,
6
4
  AIMessageChunk,
7
5
  SystemMessage,
8
6
  } from '@langchain/core/messages';
7
+ import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
8
+ import type { START, StateGraph, StateGraphArgs } from '@langchain/langgraph';
9
9
  import type { RunnableConfig, Runnable } from '@langchain/core/runnables';
10
10
  import type { ChatGenerationChunk } from '@langchain/core/outputs';
11
11
  import type { GoogleAIToolType } from '@langchain/google-common';
12
- import type {
13
- ToolMap,
14
- ToolEndEvent,
15
- GenericTool,
16
- LCTool,
17
- ToolExecuteBatchRequest,
18
- } from '@/types/tools';
19
- import type { Providers, Callback, GraphNodeKeys } from '@/common';
20
- import type { StandardGraph, MultiAgentGraph } from '@/graphs';
21
- import type { ClientOptions } from '@/types/llm';
22
12
  import type {
23
13
  SummarizationNodeInput,
24
14
  SummarizeCompleteEvent,
@@ -26,12 +16,22 @@ import type {
26
16
  SummarizeStartEvent,
27
17
  SummarizeDeltaEvent,
28
18
  } from '@/types/summarize';
19
+ import type {
20
+ ToolMap,
21
+ ToolEndEvent,
22
+ GenericTool,
23
+ LCTool,
24
+ ToolExecuteBatchRequest,
25
+ } from '@/types/tools';
29
26
  import type {
30
27
  RunStep,
31
28
  RunStepDeltaEvent,
32
29
  MessageDeltaEvent,
33
30
  ReasoningDeltaEvent,
34
31
  } from '@/types/stream';
32
+ import type { Providers, Callback, GraphNodeKeys } from '@/common';
33
+ import type { StandardGraph, MultiAgentGraph } from '@/graphs';
34
+ import type { ClientOptions } from '@/types/llm';
35
35
  import type { TokenCounter } from '@/types/run';
36
36
 
37
37
  /** Interface for bound model with stream and invoke methods */
@@ -445,6 +445,14 @@ export interface LangfuseConfig {
445
445
  baseUrl?: string;
446
446
  toolNodeTracing?: LangfuseToolNodeTracingConfig;
447
447
  toolOutputTracing?: LangfuseToolOutputTracingConfig;
448
+ /**
449
+ * When true, derive the run's root Langfuse trace id deterministically from
450
+ * its `runId` (`sha256(runId)` → 32 hex chars, matching `@langfuse/tracing`
451
+ * `createTraceId`) instead of a random id. This lets external systems attach
452
+ * scores or observations to the trace afterwards by regenerating the same id
453
+ * from the run/message id, without a trace lookup. Default: random ids.
454
+ */
455
+ deterministicTraceId?: boolean;
448
456
  }
449
457
 
450
458
  export interface AgentInputs {
package/src/types/llm.ts CHANGED
@@ -1,27 +1,27 @@
1
1
  // src/types/llm.ts
2
2
  import { ChatMistralAI } from '@langchain/mistralai';
3
- import type {
4
- BindToolsInput,
5
- BaseChatModelParams,
6
- } from '@langchain/core/language_models/chat_models';
7
3
  import type {
8
4
  OpenAIChatInput,
9
5
  ChatOpenAIFields,
10
6
  AzureOpenAIInput,
11
7
  ClientOptions as OAIClientOptions,
12
8
  } from '@langchain/openai';
9
+ import type {
10
+ BindToolsInput,
11
+ BaseChatModelParams,
12
+ } from '@langchain/core/language_models/chat_models';
13
13
  import type { GoogleGenerativeAIChatInput } from '@langchain/google-genai';
14
14
  import type { ChatVertexAIInput } from '@langchain/google-vertexai';
15
- import type { ChatDeepSeekInput } from '@langchain/deepseek';
16
- import type { ChatOpenRouterCallOptions } from '@/llm/openrouter';
17
15
  import type { ChatBedrockConverseInput } from '@langchain/aws';
18
16
  import type { ChatMistralAIInput } from '@langchain/mistralai';
17
+ import type { ChatDeepSeekInput } from '@langchain/deepseek';
19
18
  import type { RequestOptions } from '@google/generative-ai';
20
19
  import type { StructuredTool } from '@langchain/core/tools';
21
20
  import type { AnthropicInput } from '@langchain/anthropic';
22
21
  import type { Runnable } from '@langchain/core/runnables';
23
22
  import type { OpenAI as OpenAIClient } from 'openai';
24
23
  import type { ChatXAIInput } from '@langchain/xai';
24
+ import type { ChatOpenRouterCallOptions } from '@/llm/openrouter';
25
25
  import {
26
26
  AzureChatOpenAI,
27
27
  ChatDeepSeek,
@@ -92,6 +92,7 @@ export type BedrockAnthropicClientOptions = BedrockAnthropicInput;
92
92
  export type GoogleClientOptions = GoogleGenerativeAIChatInput & {
93
93
  customHeaders?: RequestOptions['customHeaders'];
94
94
  thinkingConfig?: GoogleThinkingConfig;
95
+ includeServerSideToolInvocations?: boolean;
95
96
  };
96
97
  export type DeepSeekClientOptions = Partial<ChatDeepSeekInput>;
97
98
  export type XAIClientOptions = ChatXAIInput;
@@ -1,5 +1,5 @@
1
- import type Anthropic from '@anthropic-ai/sdk';
2
1
  import type { BaseMessage } from '@langchain/core/messages';
2
+ import type Anthropic from '@anthropic-ai/sdk';
3
3
  export type AnthropicMessages = Array<AnthropicMessage | BaseMessage>;
4
4
  export type AnthropicMessage = Anthropic.MessageParam;
5
5
 
package/src/types/run.ts CHANGED
@@ -1,13 +1,9 @@
1
1
  // src/types/run.ts
2
- import type * as z from 'zod';
2
+ import type { Callbacks } from '@langchain/core/callbacks/manager';
3
+ import type { RunnableConfig } from '@langchain/core/runnables';
3
4
  import type { BaseMessage } from '@langchain/core/messages';
4
5
  import type { StructuredTool } from '@langchain/core/tools';
5
- import type { RunnableConfig } from '@langchain/core/runnables';
6
- import type { Callbacks } from '@langchain/core/callbacks/manager';
7
- import type * as s from '@/types/stream';
8
- import type * as e from '@/common/enum';
9
- import type * as g from '@/types/graph';
10
- import type * as l from '@/types/llm';
6
+ import type * as z from 'zod';
11
7
  import type {
12
8
  ToolSessionMap,
13
9
  ToolExecutionConfig,
@@ -16,6 +12,10 @@ import type {
16
12
  } from '@/types/tools';
17
13
  import type { HumanInTheLoopConfig } from '@/types/hitl';
18
14
  import type { HookRegistry } from '@/hooks';
15
+ import type * as s from '@/types/stream';
16
+ import type * as e from '@/common/enum';
17
+ import type * as g from '@/types/graph';
18
+ import type * as l from '@/types/llm';
19
19
 
20
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
21
  export type ZodObjectAny = z.ZodObject<any, any, any, any>;
@@ -1,5 +1,4 @@
1
1
  // src/types/stream.ts
2
- import type OpenAITypes from 'openai';
3
2
  import type {
4
3
  MessageContentImageUrl,
5
4
  MessageContentText,
@@ -8,8 +7,9 @@ import type {
8
7
  } from '@langchain/core/messages';
9
8
  import type { ToolCall, ToolCallChunk } from '@langchain/core/messages/tool';
10
9
  import type { LLMResult, Generation } from '@langchain/core/outputs';
11
- import type { AnthropicContentBlock } from '@/llm/anthropic/types';
12
10
  import type { Command } from '@langchain/langgraph';
11
+ import type OpenAITypes from 'openai';
12
+ import type { AnthropicContentBlock } from '@/llm/anthropic/types';
13
13
  import type { SummarizeCompleteEvent } from '@/types/summarize';
14
14
  import type { ToolEndEvent } from '@/types/tools';
15
15
  import { StepTypes, ContentTypes, GraphEvents } from '@/common/enum';