@librechat/agents 3.2.32 → 3.2.33

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 (573) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  2. package/dist/cjs/agents/AgentContext.cjs +844 -1046
  3. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  4. package/dist/cjs/common/constants.cjs +13 -13
  5. package/dist/cjs/common/constants.cjs.map +1 -1
  6. package/dist/cjs/common/enum.cjs +233 -240
  7. package/dist/cjs/common/enum.cjs.map +1 -1
  8. package/dist/cjs/common/index.cjs +2 -0
  9. package/dist/cjs/events.cjs +121 -169
  10. package/dist/cjs/events.cjs.map +1 -1
  11. package/dist/cjs/graphs/Graph.cjs +1389 -1807
  12. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  13. package/dist/cjs/graphs/MultiAgentGraph.cjs +713 -945
  14. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
  15. package/dist/cjs/graphs/index.cjs +2 -0
  16. package/dist/cjs/hitl/askUserQuestion.cjs +60 -62
  17. package/dist/cjs/hitl/askUserQuestion.cjs.map +1 -1
  18. package/dist/cjs/hitl/index.cjs +1 -0
  19. package/dist/cjs/hooks/HookRegistry.cjs +176 -202
  20. package/dist/cjs/hooks/HookRegistry.cjs.map +1 -1
  21. package/dist/cjs/hooks/createToolPolicyHook.cjs +71 -101
  22. package/dist/cjs/hooks/createToolPolicyHook.cjs.map +1 -1
  23. package/dist/cjs/hooks/createWorkspacePolicyHook.cjs +170 -273
  24. package/dist/cjs/hooks/createWorkspacePolicyHook.cjs.map +1 -1
  25. package/dist/cjs/hooks/executeHooks.cjs +227 -282
  26. package/dist/cjs/hooks/executeHooks.cjs.map +1 -1
  27. package/dist/cjs/hooks/index.cjs +6 -0
  28. package/dist/cjs/hooks/matchers.cjs +196 -230
  29. package/dist/cjs/hooks/matchers.cjs.map +1 -1
  30. package/dist/cjs/hooks/types.cjs +24 -24
  31. package/dist/cjs/hooks/types.cjs.map +1 -1
  32. package/dist/cjs/instrumentation.cjs +110 -137
  33. package/dist/cjs/instrumentation.cjs.map +1 -1
  34. package/dist/cjs/langchain/google-common.cjs +0 -3
  35. package/dist/cjs/langchain/index.cjs +80 -43
  36. package/dist/cjs/langchain/language_models/chat_models.cjs +0 -3
  37. package/dist/cjs/langchain/messages/tool.cjs +0 -3
  38. package/dist/cjs/langchain/messages.cjs +35 -18
  39. package/dist/cjs/langchain/openai.cjs +0 -3
  40. package/dist/cjs/langchain/prompts.cjs +5 -8
  41. package/dist/cjs/langchain/runnables.cjs +11 -10
  42. package/dist/cjs/langchain/tools.cjs +14 -11
  43. package/dist/cjs/langchain/utils/env.cjs +5 -8
  44. package/dist/cjs/langfuse.cjs +60 -79
  45. package/dist/cjs/langfuse.cjs.map +1 -1
  46. package/dist/cjs/langfuseToolOutputTracing.cjs +267 -399
  47. package/dist/cjs/langfuseToolOutputTracing.cjs.map +1 -1
  48. package/dist/cjs/llm/anthropic/index.cjs +432 -562
  49. package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
  50. package/dist/cjs/llm/anthropic/types.cjs +23 -47
  51. package/dist/cjs/llm/anthropic/types.cjs.map +1 -1
  52. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +441 -731
  53. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
  54. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +171 -256
  55. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
  56. package/dist/cjs/llm/anthropic/utils/output_parsers.cjs +2 -0
  57. package/dist/cjs/llm/anthropic/utils/tools.cjs +12 -26
  58. package/dist/cjs/llm/anthropic/utils/tools.cjs.map +1 -1
  59. package/dist/cjs/llm/bedrock/index.cjs +195 -240
  60. package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
  61. package/dist/cjs/llm/bedrock/toolCache.cjs +84 -106
  62. package/dist/cjs/llm/bedrock/toolCache.cjs.map +1 -1
  63. package/dist/cjs/llm/bedrock/utils/index.cjs +2 -0
  64. package/dist/cjs/llm/bedrock/utils/message_inputs.cjs +357 -620
  65. package/dist/cjs/llm/bedrock/utils/message_inputs.cjs.map +1 -1
  66. package/dist/cjs/llm/bedrock/utils/message_outputs.cjs +105 -149
  67. package/dist/cjs/llm/bedrock/utils/message_outputs.cjs.map +1 -1
  68. package/dist/cjs/llm/fake.cjs +86 -96
  69. package/dist/cjs/llm/fake.cjs.map +1 -1
  70. package/dist/cjs/llm/google/index.cjs +183 -237
  71. package/dist/cjs/llm/google/index.cjs.map +1 -1
  72. package/dist/cjs/llm/google/utils/common.cjs +398 -674
  73. package/dist/cjs/llm/google/utils/common.cjs.map +1 -1
  74. package/dist/cjs/llm/google/utils/zod_to_genai_parameters.cjs +2 -0
  75. package/dist/cjs/llm/init.cjs +44 -53
  76. package/dist/cjs/llm/init.cjs.map +1 -1
  77. package/dist/cjs/llm/invoke.cjs +142 -182
  78. package/dist/cjs/llm/invoke.cjs.map +1 -1
  79. package/dist/cjs/llm/openai/index.cjs +991 -1276
  80. package/dist/cjs/llm/openai/index.cjs.map +1 -1
  81. package/dist/cjs/llm/openai/utils/index.cjs +189 -316
  82. package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
  83. package/dist/cjs/llm/openrouter/index.cjs +102 -153
  84. package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
  85. package/dist/cjs/llm/openrouter/toolCache.cjs +35 -44
  86. package/dist/cjs/llm/openrouter/toolCache.cjs.map +1 -1
  87. package/dist/cjs/llm/providers.cjs +29 -37
  88. package/dist/cjs/llm/providers.cjs.map +1 -1
  89. package/dist/cjs/llm/request.cjs +20 -33
  90. package/dist/cjs/llm/request.cjs.map +1 -1
  91. package/dist/cjs/llm/vertexai/index.cjs +427 -453
  92. package/dist/cjs/llm/vertexai/index.cjs.map +1 -1
  93. package/dist/cjs/main.cjs +547 -528
  94. package/dist/cjs/messages/anthropicToolCache.cjs +68 -119
  95. package/dist/cjs/messages/anthropicToolCache.cjs.map +1 -1
  96. package/dist/cjs/messages/cache.cjs +305 -418
  97. package/dist/cjs/messages/cache.cjs.map +1 -1
  98. package/dist/cjs/messages/content.cjs +36 -49
  99. package/dist/cjs/messages/content.cjs.map +1 -1
  100. package/dist/cjs/messages/contextPruning.cjs +112 -145
  101. package/dist/cjs/messages/contextPruning.cjs.map +1 -1
  102. package/dist/cjs/messages/contextPruningSettings.cjs +36 -46
  103. package/dist/cjs/messages/contextPruningSettings.cjs.map +1 -1
  104. package/dist/cjs/messages/core.cjs +256 -397
  105. package/dist/cjs/messages/core.cjs.map +1 -1
  106. package/dist/cjs/messages/format.cjs +904 -1387
  107. package/dist/cjs/messages/format.cjs.map +1 -1
  108. package/dist/cjs/messages/ids.cjs +16 -20
  109. package/dist/cjs/messages/ids.cjs.map +1 -1
  110. package/dist/cjs/messages/index.cjs +12 -0
  111. package/dist/cjs/messages/langchain.cjs +18 -18
  112. package/dist/cjs/messages/langchain.cjs.map +1 -1
  113. package/dist/cjs/messages/prune.cjs +1054 -1517
  114. package/dist/cjs/messages/prune.cjs.map +1 -1
  115. package/dist/cjs/messages/recency.cjs +77 -95
  116. package/dist/cjs/messages/recency.cjs.map +1 -1
  117. package/dist/cjs/messages/reducer.cjs +63 -78
  118. package/dist/cjs/messages/reducer.cjs.map +1 -1
  119. package/dist/cjs/messages/tools.cjs +51 -79
  120. package/dist/cjs/messages/tools.cjs.map +1 -1
  121. package/dist/cjs/openai/index.cjs +171 -217
  122. package/dist/cjs/openai/index.cjs.map +1 -1
  123. package/dist/cjs/responses/index.cjs +302 -391
  124. package/dist/cjs/responses/index.cjs.map +1 -1
  125. package/dist/cjs/run.cjs +903 -1113
  126. package/dist/cjs/run.cjs.map +1 -1
  127. package/dist/cjs/session/AgentSession.cjs +805 -986
  128. package/dist/cjs/session/AgentSession.cjs.map +1 -1
  129. package/dist/cjs/session/JsonlSessionStore.cjs +327 -410
  130. package/dist/cjs/session/JsonlSessionStore.cjs.map +1 -1
  131. package/dist/cjs/session/handlers.cjs +192 -208
  132. package/dist/cjs/session/handlers.cjs.map +1 -1
  133. package/dist/cjs/session/ids.cjs +9 -10
  134. package/dist/cjs/session/ids.cjs.map +1 -1
  135. package/dist/cjs/session/index.cjs +4 -0
  136. package/dist/cjs/session/messageSerialization.cjs +94 -156
  137. package/dist/cjs/session/messageSerialization.cjs.map +1 -1
  138. package/dist/cjs/splitStream.cjs +147 -206
  139. package/dist/cjs/splitStream.cjs.map +1 -1
  140. package/dist/cjs/stream.cjs +856 -1344
  141. package/dist/cjs/stream.cjs.map +1 -1
  142. package/dist/cjs/summarization/index.cjs +57 -101
  143. package/dist/cjs/summarization/index.cjs.map +1 -1
  144. package/dist/cjs/summarization/node.cjs +643 -796
  145. package/dist/cjs/summarization/node.cjs.map +1 -1
  146. package/dist/cjs/tools/BashExecutor.cjs +110 -136
  147. package/dist/cjs/tools/BashExecutor.cjs.map +1 -1
  148. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +165 -245
  149. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
  150. package/dist/cjs/tools/Calculator.cjs +36 -57
  151. package/dist/cjs/tools/Calculator.cjs.map +1 -1
  152. package/dist/cjs/tools/CodeExecutor.cjs +126 -168
  153. package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
  154. package/dist/cjs/tools/CodeSessionFileSummary.cjs +36 -46
  155. package/dist/cjs/tools/CodeSessionFileSummary.cjs.map +1 -1
  156. package/dist/cjs/tools/ProgrammaticToolCalling.cjs +459 -649
  157. package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
  158. package/dist/cjs/tools/ReadFile.cjs +17 -20
  159. package/dist/cjs/tools/ReadFile.cjs.map +1 -1
  160. package/dist/cjs/tools/SkillTool.cjs +26 -27
  161. package/dist/cjs/tools/SkillTool.cjs.map +1 -1
  162. package/dist/cjs/tools/SubagentTool.cjs +59 -61
  163. package/dist/cjs/tools/SubagentTool.cjs.map +1 -1
  164. package/dist/cjs/tools/ToolNode.cjs +2109 -2686
  165. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  166. package/dist/cjs/tools/ToolSearch.cjs +663 -825
  167. package/dist/cjs/tools/ToolSearch.cjs.map +1 -1
  168. package/dist/cjs/tools/cloudflare/CloudflareBridgeRuntime.cjs +248 -340
  169. package/dist/cjs/tools/cloudflare/CloudflareBridgeRuntime.cjs.map +1 -1
  170. package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs +170 -197
  171. package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs.map +1 -1
  172. package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs +425 -520
  173. package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs.map +1 -1
  174. package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs +91 -124
  175. package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs.map +1 -1
  176. package/dist/cjs/tools/cloudflare/index.cjs +4 -0
  177. package/dist/cjs/tools/eagerEventExecution.cjs +75 -99
  178. package/dist/cjs/tools/eagerEventExecution.cjs.map +1 -1
  179. package/dist/cjs/tools/handlers.cjs +200 -262
  180. package/dist/cjs/tools/handlers.cjs.map +1 -1
  181. package/dist/cjs/tools/local/CompileCheckTool.cjs +150 -212
  182. package/dist/cjs/tools/local/CompileCheckTool.cjs.map +1 -1
  183. package/dist/cjs/tools/local/FileCheckpointer.cjs +77 -85
  184. package/dist/cjs/tools/local/FileCheckpointer.cjs.map +1 -1
  185. package/dist/cjs/tools/local/LocalCodingTools.cjs +763 -1022
  186. package/dist/cjs/tools/local/LocalCodingTools.cjs.map +1 -1
  187. package/dist/cjs/tools/local/LocalExecutionEngine.cjs +666 -941
  188. package/dist/cjs/tools/local/LocalExecutionEngine.cjs.map +1 -1
  189. package/dist/cjs/tools/local/LocalExecutionTools.cjs +49 -92
  190. package/dist/cjs/tools/local/LocalExecutionTools.cjs.map +1 -1
  191. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +286 -354
  192. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
  193. package/dist/cjs/tools/local/attachments.cjs +108 -165
  194. package/dist/cjs/tools/local/attachments.cjs.map +1 -1
  195. package/dist/cjs/tools/local/bashAst.cjs +99 -113
  196. package/dist/cjs/tools/local/bashAst.cjs.map +1 -1
  197. package/dist/cjs/tools/local/editStrategies.cjs +126 -169
  198. package/dist/cjs/tools/local/editStrategies.cjs.map +1 -1
  199. package/dist/cjs/tools/local/index.cjs +12 -0
  200. package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs +136 -218
  201. package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -1
  202. package/dist/cjs/tools/local/syntaxCheck.cjs +142 -161
  203. package/dist/cjs/tools/local/syntaxCheck.cjs.map +1 -1
  204. package/dist/cjs/tools/local/textEncoding.cjs +25 -23
  205. package/dist/cjs/tools/local/textEncoding.cjs.map +1 -1
  206. package/dist/cjs/tools/local/workspaceFS.cjs +38 -46
  207. package/dist/cjs/tools/local/workspaceFS.cjs.map +1 -1
  208. package/dist/cjs/tools/ptcTimeout.cjs +27 -47
  209. package/dist/cjs/tools/ptcTimeout.cjs.map +1 -1
  210. package/dist/cjs/tools/schema.cjs +24 -23
  211. package/dist/cjs/tools/schema.cjs.map +1 -1
  212. package/dist/cjs/tools/search/anthropic.cjs +24 -33
  213. package/dist/cjs/tools/search/anthropic.cjs.map +1 -1
  214. package/dist/cjs/tools/search/content.cjs +95 -137
  215. package/dist/cjs/tools/search/content.cjs.map +1 -1
  216. package/dist/cjs/tools/search/firecrawl.cjs +141 -172
  217. package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
  218. package/dist/cjs/tools/search/format.cjs +128 -196
  219. package/dist/cjs/tools/search/format.cjs.map +1 -1
  220. package/dist/cjs/tools/search/highlights.cjs +165 -232
  221. package/dist/cjs/tools/search/highlights.cjs.map +1 -1
  222. package/dist/cjs/tools/search/index.cjs +2 -0
  223. package/dist/cjs/tools/search/rerankers.cjs +151 -174
  224. package/dist/cjs/tools/search/rerankers.cjs.map +1 -1
  225. package/dist/cjs/tools/search/schema.cjs +40 -39
  226. package/dist/cjs/tools/search/schema.cjs.map +1 -1
  227. package/dist/cjs/tools/search/search.cjs +428 -530
  228. package/dist/cjs/tools/search/search.cjs.map +1 -1
  229. package/dist/cjs/tools/search/serper-scraper.cjs +106 -127
  230. package/dist/cjs/tools/search/serper-scraper.cjs.map +1 -1
  231. package/dist/cjs/tools/search/tavily-scraper.cjs +129 -181
  232. package/dist/cjs/tools/search/tavily-scraper.cjs.map +1 -1
  233. package/dist/cjs/tools/search/tavily-search.cjs +295 -359
  234. package/dist/cjs/tools/search/tavily-search.cjs.map +1 -1
  235. package/dist/cjs/tools/search/tool.cjs +260 -299
  236. package/dist/cjs/tools/search/tool.cjs.map +1 -1
  237. package/dist/cjs/tools/search/utils.cjs +74 -117
  238. package/dist/cjs/tools/search/utils.cjs.map +1 -1
  239. package/dist/cjs/tools/skillCatalog.cjs +54 -72
  240. package/dist/cjs/tools/skillCatalog.cjs.map +1 -1
  241. package/dist/cjs/tools/streamedToolCallSeals.cjs +19 -36
  242. package/dist/cjs/tools/streamedToolCallSeals.cjs.map +1 -1
  243. package/dist/cjs/tools/subagent/SubagentExecutor.cjs +612 -771
  244. package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
  245. package/dist/cjs/tools/subagent/index.cjs +1 -0
  246. package/dist/cjs/tools/toolOutputReferences.cjs +523 -630
  247. package/dist/cjs/tools/toolOutputReferences.cjs.map +1 -1
  248. package/dist/cjs/utils/callbacks.cjs +11 -21
  249. package/dist/cjs/utils/callbacks.cjs.map +1 -1
  250. package/dist/cjs/utils/errors.cjs +70 -95
  251. package/dist/cjs/utils/errors.cjs.map +1 -1
  252. package/dist/cjs/utils/events.cjs +32 -42
  253. package/dist/cjs/utils/events.cjs.map +1 -1
  254. package/dist/cjs/utils/graph.cjs +8 -12
  255. package/dist/cjs/utils/graph.cjs.map +1 -1
  256. package/dist/cjs/utils/handlers.cjs +60 -82
  257. package/dist/cjs/utils/handlers.cjs.map +1 -1
  258. package/dist/cjs/utils/index.cjs +9 -0
  259. package/dist/cjs/utils/llm.cjs +19 -27
  260. package/dist/cjs/utils/llm.cjs.map +1 -1
  261. package/dist/cjs/utils/misc.cjs +30 -46
  262. package/dist/cjs/utils/misc.cjs.map +1 -1
  263. package/dist/cjs/utils/run.cjs +50 -66
  264. package/dist/cjs/utils/run.cjs.map +1 -1
  265. package/dist/cjs/utils/schema.cjs +11 -19
  266. package/dist/cjs/utils/schema.cjs.map +1 -1
  267. package/dist/cjs/utils/title.cjs +71 -106
  268. package/dist/cjs/utils/title.cjs.map +1 -1
  269. package/dist/cjs/utils/tokens.cjs +186 -283
  270. package/dist/cjs/utils/tokens.cjs.map +1 -1
  271. package/dist/cjs/utils/truncation.cjs +95 -114
  272. package/dist/cjs/utils/truncation.cjs.map +1 -1
  273. package/dist/esm/agents/AgentContext.mjs +844 -1044
  274. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  275. package/dist/esm/common/constants.mjs +13 -11
  276. package/dist/esm/common/constants.mjs.map +1 -1
  277. package/dist/esm/common/enum.mjs +221 -238
  278. package/dist/esm/common/enum.mjs.map +1 -1
  279. package/dist/esm/common/index.mjs +3 -0
  280. package/dist/esm/events.mjs +121 -167
  281. package/dist/esm/events.mjs.map +1 -1
  282. package/dist/esm/graphs/Graph.mjs +1388 -1804
  283. package/dist/esm/graphs/Graph.mjs.map +1 -1
  284. package/dist/esm/graphs/MultiAgentGraph.mjs +713 -943
  285. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  286. package/dist/esm/graphs/index.mjs +3 -0
  287. package/dist/esm/hitl/askUserQuestion.mjs +60 -60
  288. package/dist/esm/hitl/askUserQuestion.mjs.map +1 -1
  289. package/dist/esm/hitl/index.mjs +2 -0
  290. package/dist/esm/hooks/HookRegistry.mjs +176 -200
  291. package/dist/esm/hooks/HookRegistry.mjs.map +1 -1
  292. package/dist/esm/hooks/createToolPolicyHook.mjs +71 -99
  293. package/dist/esm/hooks/createToolPolicyHook.mjs.map +1 -1
  294. package/dist/esm/hooks/createWorkspacePolicyHook.mjs +170 -271
  295. package/dist/esm/hooks/createWorkspacePolicyHook.mjs.map +1 -1
  296. package/dist/esm/hooks/executeHooks.mjs +227 -280
  297. package/dist/esm/hooks/executeHooks.mjs.map +1 -1
  298. package/dist/esm/hooks/index.mjs +7 -0
  299. package/dist/esm/hooks/matchers.mjs +196 -228
  300. package/dist/esm/hooks/matchers.mjs.map +1 -1
  301. package/dist/esm/hooks/types.mjs +24 -22
  302. package/dist/esm/hooks/types.mjs.map +1 -1
  303. package/dist/esm/instrumentation.mjs +109 -132
  304. package/dist/esm/instrumentation.mjs.map +1 -1
  305. package/dist/esm/langchain/google-common.mjs +1 -2
  306. package/dist/esm/langchain/index.mjs +5 -5
  307. package/dist/esm/langchain/language_models/chat_models.mjs +1 -2
  308. package/dist/esm/langchain/messages/tool.mjs +1 -2
  309. package/dist/esm/langchain/messages.mjs +2 -2
  310. package/dist/esm/langchain/openai.mjs +1 -2
  311. package/dist/esm/langchain/prompts.mjs +2 -2
  312. package/dist/esm/langchain/runnables.mjs +2 -2
  313. package/dist/esm/langchain/tools.mjs +2 -2
  314. package/dist/esm/langchain/utils/env.mjs +2 -2
  315. package/dist/esm/langfuse.mjs +60 -76
  316. package/dist/esm/langfuse.mjs.map +1 -1
  317. package/dist/esm/langfuseToolOutputTracing.mjs +267 -395
  318. package/dist/esm/langfuseToolOutputTracing.mjs.map +1 -1
  319. package/dist/esm/llm/anthropic/index.mjs +432 -559
  320. package/dist/esm/llm/anthropic/index.mjs.map +1 -1
  321. package/dist/esm/llm/anthropic/types.mjs +23 -45
  322. package/dist/esm/llm/anthropic/types.mjs.map +1 -1
  323. package/dist/esm/llm/anthropic/utils/message_inputs.mjs +439 -725
  324. package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
  325. package/dist/esm/llm/anthropic/utils/message_outputs.mjs +171 -253
  326. package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
  327. package/dist/esm/llm/anthropic/utils/output_parsers.mjs +3 -0
  328. package/dist/esm/llm/anthropic/utils/tools.mjs +12 -24
  329. package/dist/esm/llm/anthropic/utils/tools.mjs.map +1 -1
  330. package/dist/esm/llm/bedrock/index.mjs +195 -238
  331. package/dist/esm/llm/bedrock/index.mjs.map +1 -1
  332. package/dist/esm/llm/bedrock/toolCache.mjs +84 -104
  333. package/dist/esm/llm/bedrock/toolCache.mjs.map +1 -1
  334. package/dist/esm/llm/bedrock/utils/index.mjs +3 -0
  335. package/dist/esm/llm/bedrock/utils/message_inputs.mjs +357 -618
  336. package/dist/esm/llm/bedrock/utils/message_inputs.mjs.map +1 -1
  337. package/dist/esm/llm/bedrock/utils/message_outputs.mjs +105 -147
  338. package/dist/esm/llm/bedrock/utils/message_outputs.mjs.map +1 -1
  339. package/dist/esm/llm/fake.mjs +86 -94
  340. package/dist/esm/llm/fake.mjs.map +1 -1
  341. package/dist/esm/llm/google/index.mjs +183 -235
  342. package/dist/esm/llm/google/index.mjs.map +1 -1
  343. package/dist/esm/llm/google/utils/common.mjs +397 -666
  344. package/dist/esm/llm/google/utils/common.mjs.map +1 -1
  345. package/dist/esm/llm/google/utils/zod_to_genai_parameters.mjs +3 -0
  346. package/dist/esm/llm/init.mjs +44 -51
  347. package/dist/esm/llm/init.mjs.map +1 -1
  348. package/dist/esm/llm/invoke.mjs +142 -180
  349. package/dist/esm/llm/invoke.mjs.map +1 -1
  350. package/dist/esm/llm/openai/index.mjs +991 -1271
  351. package/dist/esm/llm/openai/index.mjs.map +1 -1
  352. package/dist/esm/llm/openai/utils/index.mjs +188 -312
  353. package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
  354. package/dist/esm/llm/openrouter/index.mjs +102 -151
  355. package/dist/esm/llm/openrouter/index.mjs.map +1 -1
  356. package/dist/esm/llm/openrouter/toolCache.mjs +35 -42
  357. package/dist/esm/llm/openrouter/toolCache.mjs.map +1 -1
  358. package/dist/esm/llm/providers.mjs +29 -34
  359. package/dist/esm/llm/providers.mjs.map +1 -1
  360. package/dist/esm/llm/request.mjs +20 -31
  361. package/dist/esm/llm/request.mjs.map +1 -1
  362. package/dist/esm/llm/vertexai/index.mjs +427 -449
  363. package/dist/esm/llm/vertexai/index.mjs.map +1 -1
  364. package/dist/esm/main.mjs +99 -87
  365. package/dist/esm/messages/anthropicToolCache.mjs +68 -117
  366. package/dist/esm/messages/anthropicToolCache.mjs.map +1 -1
  367. package/dist/esm/messages/cache.mjs +305 -416
  368. package/dist/esm/messages/cache.mjs.map +1 -1
  369. package/dist/esm/messages/content.mjs +36 -47
  370. package/dist/esm/messages/content.mjs.map +1 -1
  371. package/dist/esm/messages/contextPruning.mjs +112 -143
  372. package/dist/esm/messages/contextPruning.mjs.map +1 -1
  373. package/dist/esm/messages/contextPruningSettings.mjs +36 -44
  374. package/dist/esm/messages/contextPruningSettings.mjs.map +1 -1
  375. package/dist/esm/messages/core.mjs +254 -393
  376. package/dist/esm/messages/core.mjs.map +1 -1
  377. package/dist/esm/messages/format.mjs +902 -1383
  378. package/dist/esm/messages/format.mjs.map +1 -1
  379. package/dist/esm/messages/ids.mjs +16 -18
  380. package/dist/esm/messages/ids.mjs.map +1 -1
  381. package/dist/esm/messages/index.mjs +13 -0
  382. package/dist/esm/messages/langchain.mjs +18 -16
  383. package/dist/esm/messages/langchain.mjs.map +1 -1
  384. package/dist/esm/messages/prune.mjs +1053 -1514
  385. package/dist/esm/messages/prune.mjs.map +1 -1
  386. package/dist/esm/messages/recency.mjs +77 -93
  387. package/dist/esm/messages/recency.mjs.map +1 -1
  388. package/dist/esm/messages/reducer.mjs +63 -76
  389. package/dist/esm/messages/reducer.mjs.map +1 -1
  390. package/dist/esm/messages/tools.mjs +49 -75
  391. package/dist/esm/messages/tools.mjs.map +1 -1
  392. package/dist/esm/openai/index.mjs +170 -215
  393. package/dist/esm/openai/index.mjs.map +1 -1
  394. package/dist/esm/responses/index.mjs +301 -389
  395. package/dist/esm/responses/index.mjs.map +1 -1
  396. package/dist/esm/run.mjs +903 -1111
  397. package/dist/esm/run.mjs.map +1 -1
  398. package/dist/esm/session/AgentSession.mjs +806 -985
  399. package/dist/esm/session/AgentSession.mjs.map +1 -1
  400. package/dist/esm/session/JsonlSessionStore.mjs +326 -407
  401. package/dist/esm/session/JsonlSessionStore.mjs.map +1 -1
  402. package/dist/esm/session/handlers.mjs +192 -206
  403. package/dist/esm/session/handlers.mjs.map +1 -1
  404. package/dist/esm/session/ids.mjs +9 -8
  405. package/dist/esm/session/ids.mjs.map +1 -1
  406. package/dist/esm/session/index.mjs +5 -0
  407. package/dist/esm/session/messageSerialization.mjs +94 -154
  408. package/dist/esm/session/messageSerialization.mjs.map +1 -1
  409. package/dist/esm/splitStream.mjs +147 -204
  410. package/dist/esm/splitStream.mjs.map +1 -1
  411. package/dist/esm/stream.mjs +854 -1341
  412. package/dist/esm/stream.mjs.map +1 -1
  413. package/dist/esm/summarization/index.mjs +57 -99
  414. package/dist/esm/summarization/index.mjs.map +1 -1
  415. package/dist/esm/summarization/node.mjs +640 -790
  416. package/dist/esm/summarization/node.mjs.map +1 -1
  417. package/dist/esm/tools/BashExecutor.mjs +103 -129
  418. package/dist/esm/tools/BashExecutor.mjs.map +1 -1
  419. package/dist/esm/tools/BashProgrammaticToolCalling.mjs +162 -239
  420. package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
  421. package/dist/esm/tools/Calculator.mjs +34 -36
  422. package/dist/esm/tools/Calculator.mjs.map +1 -1
  423. package/dist/esm/tools/CodeExecutor.mjs +123 -164
  424. package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
  425. package/dist/esm/tools/CodeSessionFileSummary.mjs +36 -44
  426. package/dist/esm/tools/CodeSessionFileSummary.mjs.map +1 -1
  427. package/dist/esm/tools/ProgrammaticToolCalling.mjs +454 -644
  428. package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
  429. package/dist/esm/tools/ReadFile.mjs +17 -18
  430. package/dist/esm/tools/ReadFile.mjs.map +1 -1
  431. package/dist/esm/tools/SkillTool.mjs +26 -25
  432. package/dist/esm/tools/SkillTool.mjs.map +1 -1
  433. package/dist/esm/tools/SubagentTool.mjs +59 -59
  434. package/dist/esm/tools/SubagentTool.mjs.map +1 -1
  435. package/dist/esm/tools/ToolNode.mjs +2107 -2684
  436. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  437. package/dist/esm/tools/ToolSearch.mjs +659 -804
  438. package/dist/esm/tools/ToolSearch.mjs.map +1 -1
  439. package/dist/esm/tools/cloudflare/CloudflareBridgeRuntime.mjs +248 -338
  440. package/dist/esm/tools/cloudflare/CloudflareBridgeRuntime.mjs.map +1 -1
  441. package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs +170 -195
  442. package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs.map +1 -1
  443. package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs +424 -517
  444. package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs.map +1 -1
  445. package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs +91 -122
  446. package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs.map +1 -1
  447. package/dist/esm/tools/cloudflare/index.mjs +5 -0
  448. package/dist/esm/tools/eagerEventExecution.mjs +75 -96
  449. package/dist/esm/tools/eagerEventExecution.mjs.map +1 -1
  450. package/dist/esm/tools/handlers.mjs +200 -260
  451. package/dist/esm/tools/handlers.mjs.map +1 -1
  452. package/dist/esm/tools/local/CompileCheckTool.mjs +150 -210
  453. package/dist/esm/tools/local/CompileCheckTool.mjs.map +1 -1
  454. package/dist/esm/tools/local/FileCheckpointer.mjs +77 -83
  455. package/dist/esm/tools/local/FileCheckpointer.mjs.map +1 -1
  456. package/dist/esm/tools/local/LocalCodingTools.mjs +760 -1017
  457. package/dist/esm/tools/local/LocalCodingTools.mjs.map +1 -1
  458. package/dist/esm/tools/local/LocalExecutionEngine.mjs +663 -936
  459. package/dist/esm/tools/local/LocalExecutionEngine.mjs.map +1 -1
  460. package/dist/esm/tools/local/LocalExecutionTools.mjs +49 -90
  461. package/dist/esm/tools/local/LocalExecutionTools.mjs.map +1 -1
  462. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +283 -349
  463. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
  464. package/dist/esm/tools/local/attachments.mjs +108 -163
  465. package/dist/esm/tools/local/attachments.mjs.map +1 -1
  466. package/dist/esm/tools/local/bashAst.mjs +99 -111
  467. package/dist/esm/tools/local/bashAst.mjs.map +1 -1
  468. package/dist/esm/tools/local/editStrategies.mjs +126 -167
  469. package/dist/esm/tools/local/editStrategies.mjs.map +1 -1
  470. package/dist/esm/tools/local/index.mjs +13 -0
  471. package/dist/esm/tools/local/resolveLocalExecutionTools.mjs +136 -216
  472. package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -1
  473. package/dist/esm/tools/local/syntaxCheck.mjs +138 -155
  474. package/dist/esm/tools/local/syntaxCheck.mjs.map +1 -1
  475. package/dist/esm/tools/local/textEncoding.mjs +25 -21
  476. package/dist/esm/tools/local/textEncoding.mjs.map +1 -1
  477. package/dist/esm/tools/local/workspaceFS.mjs +38 -44
  478. package/dist/esm/tools/local/workspaceFS.mjs.map +1 -1
  479. package/dist/esm/tools/ptcTimeout.mjs +27 -42
  480. package/dist/esm/tools/ptcTimeout.mjs.map +1 -1
  481. package/dist/esm/tools/schema.mjs +24 -21
  482. package/dist/esm/tools/schema.mjs.map +1 -1
  483. package/dist/esm/tools/search/anthropic.mjs +24 -31
  484. package/dist/esm/tools/search/anthropic.mjs.map +1 -1
  485. package/dist/esm/tools/search/content.mjs +93 -116
  486. package/dist/esm/tools/search/content.mjs.map +1 -1
  487. package/dist/esm/tools/search/firecrawl.mjs +139 -169
  488. package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
  489. package/dist/esm/tools/search/format.mjs +128 -194
  490. package/dist/esm/tools/search/format.mjs.map +1 -1
  491. package/dist/esm/tools/search/highlights.mjs +165 -230
  492. package/dist/esm/tools/search/highlights.mjs.map +1 -1
  493. package/dist/esm/tools/search/index.mjs +3 -0
  494. package/dist/esm/tools/search/rerankers.mjs +149 -168
  495. package/dist/esm/tools/search/rerankers.mjs.map +1 -1
  496. package/dist/esm/tools/search/schema.mjs +39 -37
  497. package/dist/esm/tools/search/schema.mjs.map +1 -1
  498. package/dist/esm/tools/search/search.mjs +426 -528
  499. package/dist/esm/tools/search/search.mjs.map +1 -1
  500. package/dist/esm/tools/search/serper-scraper.mjs +104 -124
  501. package/dist/esm/tools/search/serper-scraper.mjs.map +1 -1
  502. package/dist/esm/tools/search/tavily-scraper.mjs +127 -178
  503. package/dist/esm/tools/search/tavily-scraper.mjs.map +1 -1
  504. package/dist/esm/tools/search/tavily-search.mjs +293 -357
  505. package/dist/esm/tools/search/tavily-search.mjs.map +1 -1
  506. package/dist/esm/tools/search/tool.mjs +259 -297
  507. package/dist/esm/tools/search/tool.mjs.map +1 -1
  508. package/dist/esm/tools/search/utils.mjs +74 -115
  509. package/dist/esm/tools/search/utils.mjs.map +1 -1
  510. package/dist/esm/tools/skillCatalog.mjs +54 -70
  511. package/dist/esm/tools/skillCatalog.mjs.map +1 -1
  512. package/dist/esm/tools/streamedToolCallSeals.mjs +19 -31
  513. package/dist/esm/tools/streamedToolCallSeals.mjs.map +1 -1
  514. package/dist/esm/tools/subagent/SubagentExecutor.mjs +612 -768
  515. package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
  516. package/dist/esm/tools/subagent/index.mjs +2 -0
  517. package/dist/esm/tools/toolOutputReferences.mjs +523 -624
  518. package/dist/esm/tools/toolOutputReferences.mjs.map +1 -1
  519. package/dist/esm/utils/callbacks.mjs +11 -19
  520. package/dist/esm/utils/callbacks.mjs.map +1 -1
  521. package/dist/esm/utils/errors.mjs +70 -93
  522. package/dist/esm/utils/errors.mjs.map +1 -1
  523. package/dist/esm/utils/events.mjs +32 -40
  524. package/dist/esm/utils/events.mjs.map +1 -1
  525. package/dist/esm/utils/graph.mjs +8 -10
  526. package/dist/esm/utils/graph.mjs.map +1 -1
  527. package/dist/esm/utils/handlers.mjs +60 -80
  528. package/dist/esm/utils/handlers.mjs.map +1 -1
  529. package/dist/esm/utils/index.mjs +10 -0
  530. package/dist/esm/utils/llm.mjs +19 -25
  531. package/dist/esm/utils/llm.mjs.map +1 -1
  532. package/dist/esm/utils/misc.mjs +30 -44
  533. package/dist/esm/utils/misc.mjs.map +1 -1
  534. package/dist/esm/utils/run.mjs +50 -64
  535. package/dist/esm/utils/run.mjs.map +1 -1
  536. package/dist/esm/utils/schema.mjs +11 -17
  537. package/dist/esm/utils/schema.mjs.map +1 -1
  538. package/dist/esm/utils/title.mjs +71 -104
  539. package/dist/esm/utils/title.mjs.map +1 -1
  540. package/dist/esm/utils/tokens.mjs +186 -281
  541. package/dist/esm/utils/tokens.mjs.map +1 -1
  542. package/dist/esm/utils/truncation.mjs +95 -112
  543. package/dist/esm/utils/truncation.mjs.map +1 -1
  544. package/dist/types/tools/search/tool.d.ts +17 -0
  545. package/dist/types/tools/search/types.d.ts +4 -0
  546. package/package.json +4 -10
  547. package/src/tools/search/highlights.ts +9 -1
  548. package/src/tools/search/search.ts +41 -3
  549. package/src/tools/search/source-processing.test.ts +373 -0
  550. package/src/tools/search/tool.ts +22 -2
  551. package/src/tools/search/types.ts +4 -0
  552. package/dist/cjs/langchain/google-common.cjs.map +0 -1
  553. package/dist/cjs/langchain/index.cjs.map +0 -1
  554. package/dist/cjs/langchain/language_models/chat_models.cjs.map +0 -1
  555. package/dist/cjs/langchain/messages/tool.cjs.map +0 -1
  556. package/dist/cjs/langchain/messages.cjs.map +0 -1
  557. package/dist/cjs/langchain/openai.cjs.map +0 -1
  558. package/dist/cjs/langchain/prompts.cjs.map +0 -1
  559. package/dist/cjs/langchain/runnables.cjs.map +0 -1
  560. package/dist/cjs/langchain/tools.cjs.map +0 -1
  561. package/dist/cjs/langchain/utils/env.cjs.map +0 -1
  562. package/dist/cjs/main.cjs.map +0 -1
  563. package/dist/esm/langchain/google-common.mjs.map +0 -1
  564. package/dist/esm/langchain/index.mjs.map +0 -1
  565. package/dist/esm/langchain/language_models/chat_models.mjs.map +0 -1
  566. package/dist/esm/langchain/messages/tool.mjs.map +0 -1
  567. package/dist/esm/langchain/messages.mjs.map +0 -1
  568. package/dist/esm/langchain/openai.mjs.map +0 -1
  569. package/dist/esm/langchain/prompts.mjs.map +0 -1
  570. package/dist/esm/langchain/runnables.mjs.map +0 -1
  571. package/dist/esm/langchain/tools.mjs.map +0 -1
  572. package/dist/esm/langchain/utils/env.mjs.map +0 -1
  573. package/dist/esm/main.mjs.map +0 -1
@@ -1,678 +1,571 @@
1
- 'use strict';
2
-
3
- var messages = require('@langchain/core/messages');
4
- var truncation = require('../utils/truncation.cjs');
5
-
1
+ const require_truncation = require("../utils/truncation.cjs");
2
+ let _langchain_core_messages = require("@langchain/core/messages");
3
+ //#region src/tools/toolOutputReferences.ts
6
4
  /**
7
- * Tool output reference registry.
8
- *
9
- * When enabled via `RunConfig.toolOutputReferences.enabled`, ToolNode
10
- * stores each successful tool output under a stable key
11
- * (`tool<idx>turn<turn>`) where `idx` is the tool's position within a
12
- * ToolNode batch and `turn` is the batch index within the run
13
- * (incremented once per ToolNode invocation).
14
- *
15
- * Subsequent tool calls can pipe a previous output into their args by
16
- * embedding `{{tool<idx>turn<turn>}}` inside any string argument;
17
- * {@link ToolOutputReferenceRegistry.resolve} walks the args and
18
- * substitutes the placeholders immediately before invocation.
19
- *
20
- * The registry stores the *raw, untruncated* tool output so a later
21
- * `{{…}}` substitution pipes the full payload into the next tool —
22
- * even when the LLM only saw a head+tail-truncated preview in
23
- * `ToolMessage.content`. Outputs are stored without any annotation
24
- * (the `_ref` key or the `[ref: ...]` prefix seen by the LLM is
25
- * strictly a UX signal attached to `ToolMessage.content`). Keeping the
26
- * registry pristine means downstream bash/jq piping receives the
27
- * complete, verbatim output with no injected fields.
28
- */
5
+ * Tool output reference registry.
6
+ *
7
+ * When enabled via `RunConfig.toolOutputReferences.enabled`, ToolNode
8
+ * stores each successful tool output under a stable key
9
+ * (`tool<idx>turn<turn>`) where `idx` is the tool's position within a
10
+ * ToolNode batch and `turn` is the batch index within the run
11
+ * (incremented once per ToolNode invocation).
12
+ *
13
+ * Subsequent tool calls can pipe a previous output into their args by
14
+ * embedding `{{tool<idx>turn<turn>}}` inside any string argument;
15
+ * {@link ToolOutputReferenceRegistry.resolve} walks the args and
16
+ * substitutes the placeholders immediately before invocation.
17
+ *
18
+ * The registry stores the *raw, untruncated* tool output so a later
19
+ * `{{…}}` substitution pipes the full payload into the next tool —
20
+ * even when the LLM only saw a head+tail-truncated preview in
21
+ * `ToolMessage.content`. Outputs are stored without any annotation
22
+ * (the `_ref` key or the `[ref: ...]` prefix seen by the LLM is
23
+ * strictly a UX signal attached to `ToolMessage.content`). Keeping the
24
+ * registry pristine means downstream bash/jq piping receives the
25
+ * complete, verbatim output with no injected fields.
26
+ */
29
27
  /**
30
- * Non-global matcher for a single `{{tool<i>turn<n>}}` placeholder.
31
- * Exported for consumers that want to detect references (e.g., syntax
32
- * highlighting, docs). The stateful `g` variant lives inside the
33
- * registry so nobody trips on `lastIndex`.
34
- */
28
+ * Non-global matcher for a single `{{tool<i>turn<n>}}` placeholder.
29
+ * Exported for consumers that want to detect references (e.g., syntax
30
+ * highlighting, docs). The stateful `g` variant lives inside the
31
+ * registry so nobody trips on `lastIndex`.
32
+ */
35
33
  const TOOL_OUTPUT_REF_PATTERN = /\{\{(tool\d+turn\d+)\}\}/;
36
34
  /** Object key used when a parsed-object output has `_ref` injected. */
37
- const TOOL_OUTPUT_REF_KEY = '_ref';
35
+ const TOOL_OUTPUT_REF_KEY = "_ref";
38
36
  /**
39
- * Object key used to carry unresolved reference warnings on a parsed-
40
- * object output. Using a dedicated field instead of a trailing text
41
- * line keeps the annotated `ToolMessage.content` parseable as JSON for
42
- * downstream consumers that rely on the object shape.
43
- */
44
- const TOOL_OUTPUT_UNRESOLVED_KEY = '_unresolved_refs';
37
+ * Object key used to carry unresolved reference warnings on a parsed-
38
+ * object output. Using a dedicated field instead of a trailing text
39
+ * line keeps the annotated `ToolMessage.content` parseable as JSON for
40
+ * downstream consumers that rely on the object shape.
41
+ */
42
+ const TOOL_OUTPUT_UNRESOLVED_KEY = "_unresolved_refs";
45
43
  /** Single-line prefix prepended to non-object tool outputs so the LLM sees the reference key. */
46
44
  function buildReferencePrefix(key) {
47
- return `[ref: ${key}]`;
45
+ return `[ref: ${key}]`;
48
46
  }
49
47
  /** Stable registry key for a tool output. */
50
48
  function buildReferenceKey(toolIndex, turn) {
51
- return `tool${toolIndex}turn${turn}`;
49
+ return `tool${toolIndex}turn${turn}`;
52
50
  }
53
- const EMPTY_ENTRIES = new Map();
51
+ const EMPTY_ENTRIES = /* @__PURE__ */ new Map();
54
52
  /**
55
- * Per-run state bucket held inside the registry. Each distinct
56
- * `run_id` gets its own bucket so overlapping concurrent runs on a
57
- * shared registry cannot leak outputs, turn counters, or warn-memos
58
- * into one another.
59
- */
60
- class RunStateBucket {
61
- entries = new Map();
62
- totalSize = 0;
63
- turnCounter = 0;
64
- warnedNonStringTools = new Set();
65
- }
53
+ * Per-run state bucket held inside the registry. Each distinct
54
+ * `run_id` gets its own bucket so overlapping concurrent runs on a
55
+ * shared registry cannot leak outputs, turn counters, or warn-memos
56
+ * into one another.
57
+ */
58
+ var RunStateBucket = class {
59
+ entries = /* @__PURE__ */ new Map();
60
+ totalSize = 0;
61
+ turnCounter = 0;
62
+ warnedNonStringTools = /* @__PURE__ */ new Set();
63
+ };
66
64
  /**
67
- * Anonymous (`run_id` absent) bucket key. Anonymous batches are
68
- * treated as fresh runs on every invocation — see `nextTurn`.
69
- */
70
- const ANON_RUN_KEY = '\0anon';
65
+ * Anonymous (`run_id` absent) bucket key. Anonymous batches are
66
+ * treated as fresh runs on every invocation — see `nextTurn`.
67
+ */
68
+ const ANON_RUN_KEY = "\0anon";
71
69
  /**
72
- * Default upper bound on the number of concurrently-tracked runs per
73
- * registry. When exceeded, the oldest run's bucket (by insertion
74
- * order) is evicted. Keeps memory bounded when a ToolNode is reused
75
- * across many runs without explicit `releaseRun` calls.
76
- */
70
+ * Default upper bound on the number of concurrently-tracked runs per
71
+ * registry. When exceeded, the oldest run's bucket (by insertion
72
+ * order) is evicted. Keeps memory bounded when a ToolNode is reused
73
+ * across many runs without explicit `releaseRun` calls.
74
+ */
77
75
  const DEFAULT_MAX_ACTIVE_RUNS = 32;
78
76
  /**
79
- * Ordered map of reference-key → stored output, partitioned by run so
80
- * concurrent / interleaved runs sharing one registry cannot leak
81
- * outputs between each other.
82
- *
83
- * Each public method takes a `runId` which selects the run's bucket.
84
- * Hosts typically get one registry per run via `Graph`, in which
85
- * case only a single bucket is ever populated; the partitioning
86
- * exists so the registry also behaves correctly when a single
87
- * instance is reused directly.
88
- */
89
- class ToolOutputReferenceRegistry {
90
- runStates = new Map();
91
- maxOutputSize;
92
- maxTotalSize;
93
- maxActiveRuns;
94
- /**
95
- * Local stateful matcher used only by `replaceInString`. Kept
96
- * off-module so callers of the exported `TOOL_OUTPUT_REF_PATTERN`
97
- * never see a stale `lastIndex`.
98
- */
99
- static PLACEHOLDER_MATCHER = /\{\{(tool\d+turn\d+)\}\}/g;
100
- constructor(options = {}) {
101
- /**
102
- * Per-output default is the same ~400 KB budget as the standard
103
- * tool-result truncation (`HARD_MAX_TOOL_RESULT_CHARS`). This
104
- * keeps a single `{{…}}` substitution at a size that is safe to
105
- * pass through typical shell `ARG_MAX` limits and matches what
106
- * the LLM would otherwise have seen. Hosts that want larger per-
107
- * output payloads (API consumers, long JSON streams) can raise
108
- * the cap explicitly up to the 5 MB total budget.
109
- */
110
- const perOutput = options.maxOutputSize != null && options.maxOutputSize > 0
111
- ? options.maxOutputSize
112
- : truncation.HARD_MAX_TOOL_RESULT_CHARS;
113
- /**
114
- * Clamp a caller-supplied `maxTotalSize` to
115
- * `HARD_MAX_TOTAL_TOOL_OUTPUT_SIZE` (5 MB) so the documented
116
- * absolute cap is enforced regardless of host config
117
- * `calculateMaxTotalToolOutputSize` already applies the same
118
- * upper bound on its computed default, but the user-provided
119
- * branch was bypassing it.
120
- */
121
- const totalRaw = options.maxTotalSize != null && options.maxTotalSize > 0
122
- ? Math.min(options.maxTotalSize, truncation.HARD_MAX_TOTAL_TOOL_OUTPUT_SIZE)
123
- : truncation.calculateMaxTotalToolOutputSize(perOutput);
124
- this.maxTotalSize = totalRaw;
125
- /**
126
- * The per-output cap can never exceed the per-run aggregate cap:
127
- * if a single entry were allowed to be larger than `maxTotalSize`,
128
- * the eviction loop would either blow the cap (to keep the entry)
129
- * or self-evict a just-stored value. Clamping here turns
130
- * `maxTotalSize` into a hard upper bound on *any* state the
131
- * registry retains per run.
132
- */
133
- this.maxOutputSize = Math.min(perOutput, totalRaw);
134
- this.maxActiveRuns =
135
- options.maxActiveRuns != null && options.maxActiveRuns > 0
136
- ? options.maxActiveRuns
137
- : DEFAULT_MAX_ACTIVE_RUNS;
138
- }
139
- keyFor(runId) {
140
- return runId ?? ANON_RUN_KEY;
141
- }
142
- getOrCreate(runId) {
143
- const key = this.keyFor(runId);
144
- let state = this.runStates.get(key);
145
- if (state == null) {
146
- state = new RunStateBucket();
147
- this.runStates.set(key, state);
148
- if (this.runStates.size > this.maxActiveRuns) {
149
- const oldest = this.runStates.keys().next().value;
150
- if (oldest != null && oldest !== key) {
151
- this.runStates.delete(oldest);
152
- }
153
- }
154
- }
155
- return state;
156
- }
157
- /** Registers (or replaces) the output stored under `key` for `runId`. */
158
- set(runId, key, value) {
159
- const bucket = this.getOrCreate(runId);
160
- const clipped = value.length > this.maxOutputSize
161
- ? value.slice(0, this.maxOutputSize)
162
- : value;
163
- const existing = bucket.entries.get(key);
164
- if (existing != null) {
165
- bucket.totalSize -= existing.length;
166
- bucket.entries.delete(key);
167
- }
168
- bucket.entries.set(key, clipped);
169
- bucket.totalSize += clipped.length;
170
- this.evictWithinBucket(bucket);
171
- }
172
- /** Returns the stored value for `key` in `runId`'s bucket, or `undefined`. */
173
- get(runId, key) {
174
- return this.runStates.get(this.keyFor(runId))?.entries.get(key);
175
- }
176
- /**
177
- * Returns `true` when `key` is currently stored in `runId`'s bucket.
178
- * Used by {@link annotateMessagesForLLM} to gate transient annotation
179
- * on whether the registry still owns the referenced output (a stale
180
- * `_refKey` from a prior run silently no-ops here).
181
- */
182
- has(runId, key) {
183
- return this.runStates.get(this.keyFor(runId))?.entries.has(key) ?? false;
184
- }
185
- /** Total number of registered outputs across every run bucket. */
186
- get size() {
187
- let n = 0;
188
- for (const bucket of this.runStates.values()) {
189
- n += bucket.entries.size;
190
- }
191
- return n;
192
- }
193
- /** Maximum characters retained per output (post-clip). */
194
- get perOutputLimit() {
195
- return this.maxOutputSize;
196
- }
197
- /** Maximum total characters retained *per run*. */
198
- get totalLimit() {
199
- return this.maxTotalSize;
200
- }
201
- /** Drops every run's state. */
202
- clear() {
203
- this.runStates.clear();
204
- }
205
- /**
206
- * Explicitly release `runId`'s state. Safe to call when a run has
207
- * finished. Hosts sharing one registry across runs should call this
208
- * to reclaim memory deterministically; otherwise LRU eviction kicks
209
- * in when `maxActiveRuns` runs accumulate.
210
- */
211
- releaseRun(runId) {
212
- this.runStates.delete(this.keyFor(runId));
213
- }
214
- /**
215
- * Claims the next batch turn synchronously from `runId`'s bucket.
216
- *
217
- * Must be called once at the start of each ToolNode batch before
218
- * any `await`, so concurrent invocations within the same run see
219
- * distinct turn values (reads are effectively atomic by JS's
220
- * single-threaded execution of the sync prefix).
221
- *
222
- * If `runId` is missing the anonymous bucket is dropped and a
223
- * fresh one created so each anonymous call behaves as its own run.
224
- */
225
- nextTurn(runId) {
226
- if (runId == null) {
227
- this.runStates.delete(ANON_RUN_KEY);
228
- }
229
- const bucket = this.getOrCreate(runId);
230
- return bucket.turnCounter++;
231
- }
232
- /**
233
- * Records that `toolName` has been warned about in `runId` (returns
234
- * `true` on the first call per run, `false` after). Used by
235
- * ToolNode to emit one log line per offending tool per run when a
236
- * `ToolMessage.content` isn't a string.
237
- */
238
- claimWarnOnce(runId, toolName) {
239
- const bucket = this.getOrCreate(runId);
240
- if (bucket.warnedNonStringTools.has(toolName)) {
241
- return false;
242
- }
243
- bucket.warnedNonStringTools.add(toolName);
244
- return true;
245
- }
246
- /**
247
- * Walks `args` and replaces every `{{tool<i>turn<n>}}` placeholder in
248
- * string values with the stored output *from `runId`'s bucket*. Non-
249
- * string values and object keys are left untouched. Unresolved
250
- * references are left in-place and reported so the caller can
251
- * surface them to the LLM. When no placeholder appears anywhere in
252
- * the serialized args, the original input is returned without
253
- * walking the tree.
254
- */
255
- resolve(runId, args) {
256
- if (!hasAnyPlaceholder(args)) {
257
- return { resolved: args, unresolved: [] };
258
- }
259
- const bucket = this.runStates.get(this.keyFor(runId));
260
- return this.resolveAgainst(bucket?.entries ?? EMPTY_ENTRIES, args);
261
- }
262
- /**
263
- * Captures a frozen snapshot of `runId`'s current entries and
264
- * returns a view that resolves placeholders against *only* that
265
- * snapshot. The snapshot is decoupled from the live registry, so
266
- * subsequent `set()` calls (for example, same-turn direct outputs
267
- * registering while an event branch is still in flight) are
268
- * invisible to the snapshot's `resolve`. Used by the mixed
269
- * direct+event dispatch path to preserve same-turn isolation when
270
- * a `PreToolUse` hook rewrites event args after directs have
271
- * completed.
272
- */
273
- snapshot(runId) {
274
- const bucket = this.runStates.get(this.keyFor(runId));
275
- const entries = bucket
276
- ? new Map(bucket.entries)
277
- : EMPTY_ENTRIES;
278
- return {
279
- resolve: (args) => this.resolveAgainst(entries, args),
280
- };
281
- }
282
- resolveAgainst(entries, args) {
283
- if (!hasAnyPlaceholder(args)) {
284
- return { resolved: args, unresolved: [] };
285
- }
286
- const unresolved = new Set();
287
- const resolved = this.transform(entries, args, unresolved);
288
- return { resolved, unresolved: Array.from(unresolved) };
289
- }
290
- transform(entries, value, unresolved) {
291
- if (typeof value === 'string') {
292
- return this.replaceInString(entries, value, unresolved);
293
- }
294
- if (Array.isArray(value)) {
295
- return value.map((item) => this.transform(entries, item, unresolved));
296
- }
297
- if (value !== null && typeof value === 'object') {
298
- const source = value;
299
- const next = {};
300
- for (const [key, item] of Object.entries(source)) {
301
- next[key] = this.transform(entries, item, unresolved);
302
- }
303
- return next;
304
- }
305
- return value;
306
- }
307
- replaceInString(entries, input, unresolved) {
308
- if (input.indexOf('{{tool') === -1) {
309
- return input;
310
- }
311
- return input.replace(ToolOutputReferenceRegistry.PLACEHOLDER_MATCHER, (match, key) => {
312
- const stored = entries.get(key);
313
- if (stored == null) {
314
- unresolved.add(key);
315
- return match;
316
- }
317
- return stored;
318
- });
319
- }
320
- evictWithinBucket(bucket) {
321
- if (bucket.totalSize <= this.maxTotalSize) {
322
- return;
323
- }
324
- for (const key of bucket.entries.keys()) {
325
- if (bucket.totalSize <= this.maxTotalSize) {
326
- return;
327
- }
328
- const entry = bucket.entries.get(key);
329
- if (entry == null) {
330
- continue;
331
- }
332
- bucket.totalSize -= entry.length;
333
- bucket.entries.delete(key);
334
- }
335
- }
336
- }
77
+ * Ordered map of reference-key → stored output, partitioned by run so
78
+ * concurrent / interleaved runs sharing one registry cannot leak
79
+ * outputs between each other.
80
+ *
81
+ * Each public method takes a `runId` which selects the run's bucket.
82
+ * Hosts typically get one registry per run via `Graph`, in which
83
+ * case only a single bucket is ever populated; the partitioning
84
+ * exists so the registry also behaves correctly when a single
85
+ * instance is reused directly.
86
+ */
87
+ var ToolOutputReferenceRegistry = class ToolOutputReferenceRegistry {
88
+ runStates = /* @__PURE__ */ new Map();
89
+ maxOutputSize;
90
+ maxTotalSize;
91
+ maxActiveRuns;
92
+ /**
93
+ * Local stateful matcher used only by `replaceInString`. Kept
94
+ * off-module so callers of the exported `TOOL_OUTPUT_REF_PATTERN`
95
+ * never see a stale `lastIndex`.
96
+ */
97
+ static PLACEHOLDER_MATCHER = /\{\{(tool\d+turn\d+)\}\}/g;
98
+ constructor(options = {}) {
99
+ /**
100
+ * Per-output default is the same ~400 KB budget as the standard
101
+ * tool-result truncation (`HARD_MAX_TOOL_RESULT_CHARS`). This
102
+ * keeps a single `{{…}}` substitution at a size that is safe to
103
+ * pass through typical shell `ARG_MAX` limits and matches what
104
+ * the LLM would otherwise have seen. Hosts that want larger per-
105
+ * output payloads (API consumers, long JSON streams) can raise
106
+ * the cap explicitly up to the 5 MB total budget.
107
+ */
108
+ const perOutput = options.maxOutputSize != null && options.maxOutputSize > 0 ? options.maxOutputSize : require_truncation.HARD_MAX_TOOL_RESULT_CHARS;
109
+ /**
110
+ * Clamp a caller-supplied `maxTotalSize` to
111
+ * `HARD_MAX_TOTAL_TOOL_OUTPUT_SIZE` (5 MB) so the documented
112
+ * absolute cap is enforced regardless of host config —
113
+ * `calculateMaxTotalToolOutputSize` already applies the same
114
+ * upper bound on its computed default, but the user-provided
115
+ * branch was bypassing it.
116
+ */
117
+ const totalRaw = options.maxTotalSize != null && options.maxTotalSize > 0 ? Math.min(options.maxTotalSize, require_truncation.HARD_MAX_TOTAL_TOOL_OUTPUT_SIZE) : require_truncation.calculateMaxTotalToolOutputSize(perOutput);
118
+ this.maxTotalSize = totalRaw;
119
+ /**
120
+ * The per-output cap can never exceed the per-run aggregate cap:
121
+ * if a single entry were allowed to be larger than `maxTotalSize`,
122
+ * the eviction loop would either blow the cap (to keep the entry)
123
+ * or self-evict a just-stored value. Clamping here turns
124
+ * `maxTotalSize` into a hard upper bound on *any* state the
125
+ * registry retains per run.
126
+ */
127
+ this.maxOutputSize = Math.min(perOutput, totalRaw);
128
+ this.maxActiveRuns = options.maxActiveRuns != null && options.maxActiveRuns > 0 ? options.maxActiveRuns : DEFAULT_MAX_ACTIVE_RUNS;
129
+ }
130
+ keyFor(runId) {
131
+ return runId ?? ANON_RUN_KEY;
132
+ }
133
+ getOrCreate(runId) {
134
+ const key = this.keyFor(runId);
135
+ let state = this.runStates.get(key);
136
+ if (state == null) {
137
+ state = new RunStateBucket();
138
+ this.runStates.set(key, state);
139
+ if (this.runStates.size > this.maxActiveRuns) {
140
+ const oldest = this.runStates.keys().next().value;
141
+ if (oldest != null && oldest !== key) this.runStates.delete(oldest);
142
+ }
143
+ }
144
+ return state;
145
+ }
146
+ /** Registers (or replaces) the output stored under `key` for `runId`. */
147
+ set(runId, key, value) {
148
+ const bucket = this.getOrCreate(runId);
149
+ const clipped = value.length > this.maxOutputSize ? value.slice(0, this.maxOutputSize) : value;
150
+ const existing = bucket.entries.get(key);
151
+ if (existing != null) {
152
+ bucket.totalSize -= existing.length;
153
+ bucket.entries.delete(key);
154
+ }
155
+ bucket.entries.set(key, clipped);
156
+ bucket.totalSize += clipped.length;
157
+ this.evictWithinBucket(bucket);
158
+ }
159
+ /** Returns the stored value for `key` in `runId`'s bucket, or `undefined`. */
160
+ get(runId, key) {
161
+ return this.runStates.get(this.keyFor(runId))?.entries.get(key);
162
+ }
163
+ /**
164
+ * Returns `true` when `key` is currently stored in `runId`'s bucket.
165
+ * Used by {@link annotateMessagesForLLM} to gate transient annotation
166
+ * on whether the registry still owns the referenced output (a stale
167
+ * `_refKey` from a prior run silently no-ops here).
168
+ */
169
+ has(runId, key) {
170
+ return this.runStates.get(this.keyFor(runId))?.entries.has(key) ?? false;
171
+ }
172
+ /** Total number of registered outputs across every run bucket. */
173
+ get size() {
174
+ let n = 0;
175
+ for (const bucket of this.runStates.values()) n += bucket.entries.size;
176
+ return n;
177
+ }
178
+ /** Maximum characters retained per output (post-clip). */
179
+ get perOutputLimit() {
180
+ return this.maxOutputSize;
181
+ }
182
+ /** Maximum total characters retained *per run*. */
183
+ get totalLimit() {
184
+ return this.maxTotalSize;
185
+ }
186
+ /** Drops every run's state. */
187
+ clear() {
188
+ this.runStates.clear();
189
+ }
190
+ /**
191
+ * Explicitly release `runId`'s state. Safe to call when a run has
192
+ * finished. Hosts sharing one registry across runs should call this
193
+ * to reclaim memory deterministically; otherwise LRU eviction kicks
194
+ * in when `maxActiveRuns` runs accumulate.
195
+ */
196
+ releaseRun(runId) {
197
+ this.runStates.delete(this.keyFor(runId));
198
+ }
199
+ /**
200
+ * Claims the next batch turn synchronously from `runId`'s bucket.
201
+ *
202
+ * Must be called once at the start of each ToolNode batch before
203
+ * any `await`, so concurrent invocations within the same run see
204
+ * distinct turn values (reads are effectively atomic by JS's
205
+ * single-threaded execution of the sync prefix).
206
+ *
207
+ * If `runId` is missing the anonymous bucket is dropped and a
208
+ * fresh one created so each anonymous call behaves as its own run.
209
+ */
210
+ nextTurn(runId) {
211
+ if (runId == null) this.runStates.delete(ANON_RUN_KEY);
212
+ const bucket = this.getOrCreate(runId);
213
+ return bucket.turnCounter++;
214
+ }
215
+ /**
216
+ * Records that `toolName` has been warned about in `runId` (returns
217
+ * `true` on the first call per run, `false` after). Used by
218
+ * ToolNode to emit one log line per offending tool per run when a
219
+ * `ToolMessage.content` isn't a string.
220
+ */
221
+ claimWarnOnce(runId, toolName) {
222
+ const bucket = this.getOrCreate(runId);
223
+ if (bucket.warnedNonStringTools.has(toolName)) return false;
224
+ bucket.warnedNonStringTools.add(toolName);
225
+ return true;
226
+ }
227
+ /**
228
+ * Walks `args` and replaces every `{{tool<i>turn<n>}}` placeholder in
229
+ * string values with the stored output *from `runId`'s bucket*. Non-
230
+ * string values and object keys are left untouched. Unresolved
231
+ * references are left in-place and reported so the caller can
232
+ * surface them to the LLM. When no placeholder appears anywhere in
233
+ * the serialized args, the original input is returned without
234
+ * walking the tree.
235
+ */
236
+ resolve(runId, args) {
237
+ if (!hasAnyPlaceholder(args)) return {
238
+ resolved: args,
239
+ unresolved: []
240
+ };
241
+ const bucket = this.runStates.get(this.keyFor(runId));
242
+ return this.resolveAgainst(bucket?.entries ?? EMPTY_ENTRIES, args);
243
+ }
244
+ /**
245
+ * Captures a frozen snapshot of `runId`'s current entries and
246
+ * returns a view that resolves placeholders against *only* that
247
+ * snapshot. The snapshot is decoupled from the live registry, so
248
+ * subsequent `set()` calls (for example, same-turn direct outputs
249
+ * registering while an event branch is still in flight) are
250
+ * invisible to the snapshot's `resolve`. Used by the mixed
251
+ * direct+event dispatch path to preserve same-turn isolation when
252
+ * a `PreToolUse` hook rewrites event args after directs have
253
+ * completed.
254
+ */
255
+ snapshot(runId) {
256
+ const bucket = this.runStates.get(this.keyFor(runId));
257
+ const entries = bucket ? new Map(bucket.entries) : EMPTY_ENTRIES;
258
+ return { resolve: (args) => this.resolveAgainst(entries, args) };
259
+ }
260
+ resolveAgainst(entries, args) {
261
+ if (!hasAnyPlaceholder(args)) return {
262
+ resolved: args,
263
+ unresolved: []
264
+ };
265
+ const unresolved = /* @__PURE__ */ new Set();
266
+ return {
267
+ resolved: this.transform(entries, args, unresolved),
268
+ unresolved: Array.from(unresolved)
269
+ };
270
+ }
271
+ transform(entries, value, unresolved) {
272
+ if (typeof value === "string") return this.replaceInString(entries, value, unresolved);
273
+ if (Array.isArray(value)) return value.map((item) => this.transform(entries, item, unresolved));
274
+ if (value !== null && typeof value === "object") {
275
+ const source = value;
276
+ const next = {};
277
+ for (const [key, item] of Object.entries(source)) next[key] = this.transform(entries, item, unresolved);
278
+ return next;
279
+ }
280
+ return value;
281
+ }
282
+ replaceInString(entries, input, unresolved) {
283
+ if (input.indexOf("{{tool") === -1) return input;
284
+ return input.replace(ToolOutputReferenceRegistry.PLACEHOLDER_MATCHER, (match, key) => {
285
+ const stored = entries.get(key);
286
+ if (stored == null) {
287
+ unresolved.add(key);
288
+ return match;
289
+ }
290
+ return stored;
291
+ });
292
+ }
293
+ evictWithinBucket(bucket) {
294
+ if (bucket.totalSize <= this.maxTotalSize) return;
295
+ for (const key of bucket.entries.keys()) {
296
+ if (bucket.totalSize <= this.maxTotalSize) return;
297
+ const entry = bucket.entries.get(key);
298
+ if (entry == null) continue;
299
+ bucket.totalSize -= entry.length;
300
+ bucket.entries.delete(key);
301
+ }
302
+ }
303
+ };
337
304
  /**
338
- * Cheap pre-check: returns true if any string value in `args` contains
339
- * the `{{tool` substring. Lets `resolve()` skip the deep tree walk (and
340
- * its object allocations) for the common case of plain args.
341
- */
305
+ * Cheap pre-check: returns true if any string value in `args` contains
306
+ * the `{{tool` substring. Lets `resolve()` skip the deep tree walk (and
307
+ * its object allocations) for the common case of plain args.
308
+ */
342
309
  function hasAnyPlaceholder(value) {
343
- if (typeof value === 'string') {
344
- return value.indexOf('{{tool') !== -1;
345
- }
346
- if (Array.isArray(value)) {
347
- for (const item of value) {
348
- if (hasAnyPlaceholder(item)) {
349
- return true;
350
- }
351
- }
352
- return false;
353
- }
354
- if (value !== null && typeof value === 'object') {
355
- for (const item of Object.values(value)) {
356
- if (hasAnyPlaceholder(item)) {
357
- return true;
358
- }
359
- }
360
- return false;
361
- }
362
- return false;
310
+ if (typeof value === "string") return value.indexOf("{{tool") !== -1;
311
+ if (Array.isArray(value)) {
312
+ for (const item of value) if (hasAnyPlaceholder(item)) return true;
313
+ return false;
314
+ }
315
+ if (value !== null && typeof value === "object") {
316
+ for (const item of Object.values(value)) if (hasAnyPlaceholder(item)) return true;
317
+ return false;
318
+ }
319
+ return false;
363
320
  }
364
321
  /**
365
- * Annotates `content` with a reference key and/or unresolved-ref
366
- * warnings so the LLM sees both alongside the tool output.
367
- *
368
- * Behavior:
369
- * - If `content` parses as a plain (non-array, non-null) JSON object
370
- * and the object does not already have a conflicting `_ref` key,
371
- * the reference key and (when present) `_unresolved_refs` array
372
- * are injected as object fields, preserving JSON validity for
373
- * downstream consumers that parse the output.
374
- * - Otherwise (string output, JSON array/primitive, parse failure,
375
- * or `_ref` collision), a `[ref: <key>]\n` prefix line is
376
- * prepended and unresolved refs are appended as a trailing
377
- * `[unresolved refs: …]` line.
378
- *
379
- * The annotated string is what the LLM sees as `ToolMessage.content`.
380
- * The *original* (un-annotated) value is what gets stored in the
381
- * registry, so downstream piping remains pristine.
382
- *
383
- * @param content Raw (post-truncation) tool output.
384
- * @param key Reference key for this output, or undefined when
385
- * there is nothing to register (errors etc.).
386
- * @param unresolved Reference keys that failed to resolve during
387
- * argument substitution. Surfaced so the LLM can
388
- * self-correct its next tool call.
389
- */
322
+ * Annotates `content` with a reference key and/or unresolved-ref
323
+ * warnings so the LLM sees both alongside the tool output.
324
+ *
325
+ * Behavior:
326
+ * - If `content` parses as a plain (non-array, non-null) JSON object
327
+ * and the object does not already have a conflicting `_ref` key,
328
+ * the reference key and (when present) `_unresolved_refs` array
329
+ * are injected as object fields, preserving JSON validity for
330
+ * downstream consumers that parse the output.
331
+ * - Otherwise (string output, JSON array/primitive, parse failure,
332
+ * or `_ref` collision), a `[ref: <key>]\n` prefix line is
333
+ * prepended and unresolved refs are appended as a trailing
334
+ * `[unresolved refs: …]` line.
335
+ *
336
+ * The annotated string is what the LLM sees as `ToolMessage.content`.
337
+ * The *original* (un-annotated) value is what gets stored in the
338
+ * registry, so downstream piping remains pristine.
339
+ *
340
+ * @param content Raw (post-truncation) tool output.
341
+ * @param key Reference key for this output, or undefined when
342
+ * there is nothing to register (errors etc.).
343
+ * @param unresolved Reference keys that failed to resolve during
344
+ * argument substitution. Surfaced so the LLM can
345
+ * self-correct its next tool call.
346
+ */
390
347
  function annotateToolOutputWithReference(content, key, unresolved = []) {
391
- const hasRefKey = key != null;
392
- const hasUnresolved = unresolved.length > 0;
393
- if (!hasRefKey && !hasUnresolved) {
394
- return content;
395
- }
396
- const trimmed = content.trimStart();
397
- if (trimmed.startsWith('{')) {
398
- const annotated = tryInjectRefIntoJsonObject(content, key, unresolved);
399
- if (annotated != null) {
400
- return annotated;
401
- }
402
- }
403
- const prefix = hasRefKey ? `${buildReferencePrefix(key)}\n` : '';
404
- const trailer = hasUnresolved
405
- ? `\n[unresolved refs: ${unresolved.join(', ')}]`
406
- : '';
407
- return `${prefix}${content}${trailer}`;
348
+ const hasRefKey = key != null;
349
+ const hasUnresolved = unresolved.length > 0;
350
+ if (!hasRefKey && !hasUnresolved) return content;
351
+ if (content.trimStart().startsWith("{")) {
352
+ const annotated = tryInjectRefIntoJsonObject(content, key, unresolved);
353
+ if (annotated != null) return annotated;
354
+ }
355
+ return `${hasRefKey ? `${buildReferencePrefix(key)}\n` : ""}${content}${hasUnresolved ? `\n[unresolved refs: ${unresolved.join(", ")}]` : ""}`;
408
356
  }
409
357
  function tryInjectRefIntoJsonObject(content, key, unresolved) {
410
- let parsed;
411
- try {
412
- parsed = JSON.parse(content);
413
- }
414
- catch {
415
- return null;
416
- }
417
- if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
418
- return null;
419
- }
420
- const obj = parsed;
421
- const injectingRef = key != null;
422
- const injectingUnresolved = unresolved.length > 0;
423
- /**
424
- * Reject the JSON-injection path (fall back to prefix form) when
425
- * either of our keys collides with real payload data:
426
- * - `_ref` collision: existing value is non-null and differs from
427
- * the key we're about to inject.
428
- * - `_unresolved_refs` collision: existing value is non-null and
429
- * is not a deep-equal match for the array we'd inject.
430
- * This keeps us from silently overwriting legitimate tool output.
431
- */
432
- if (injectingRef &&
433
- TOOL_OUTPUT_REF_KEY in obj &&
434
- obj[TOOL_OUTPUT_REF_KEY] !== key &&
435
- obj[TOOL_OUTPUT_REF_KEY] != null) {
436
- return null;
437
- }
438
- if (injectingUnresolved &&
439
- TOOL_OUTPUT_UNRESOLVED_KEY in obj &&
440
- obj[TOOL_OUTPUT_UNRESOLVED_KEY] != null &&
441
- !arraysShallowEqual(obj[TOOL_OUTPUT_UNRESOLVED_KEY], unresolved)) {
442
- return null;
443
- }
444
- /**
445
- * Only strip the framework-owned key we're actually injecting —
446
- * leave everything else (including a pre-existing `_ref` on the
447
- * unresolved-only path, or a pre-existing `_unresolved_refs` on a
448
- * plain-annotation path) untouched so we annotate rather than
449
- * mutate downstream payload data. Our injected keys land first in
450
- * the serialized JSON so the LLM sees them before the body.
451
- */
452
- const omitKeys = new Set();
453
- if (injectingRef)
454
- omitKeys.add(TOOL_OUTPUT_REF_KEY);
455
- if (injectingUnresolved)
456
- omitKeys.add(TOOL_OUTPUT_UNRESOLVED_KEY);
457
- const rest = {};
458
- for (const [k, v] of Object.entries(obj)) {
459
- if (!omitKeys.has(k)) {
460
- rest[k] = v;
461
- }
462
- }
463
- const injected = {};
464
- if (injectingRef) {
465
- injected[TOOL_OUTPUT_REF_KEY] = key;
466
- }
467
- if (injectingUnresolved) {
468
- injected[TOOL_OUTPUT_UNRESOLVED_KEY] = unresolved;
469
- }
470
- Object.assign(injected, rest);
471
- const pretty = /^\{\s*\n/.test(content);
472
- return pretty ? JSON.stringify(injected, null, 2) : JSON.stringify(injected);
358
+ let parsed;
359
+ try {
360
+ parsed = JSON.parse(content);
361
+ } catch {
362
+ return null;
363
+ }
364
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
365
+ const obj = parsed;
366
+ const injectingRef = key != null;
367
+ const injectingUnresolved = unresolved.length > 0;
368
+ /**
369
+ * Reject the JSON-injection path (fall back to prefix form) when
370
+ * either of our keys collides with real payload data:
371
+ * - `_ref` collision: existing value is non-null and differs from
372
+ * the key we're about to inject.
373
+ * - `_unresolved_refs` collision: existing value is non-null and
374
+ * is not a deep-equal match for the array we'd inject.
375
+ * This keeps us from silently overwriting legitimate tool output.
376
+ */
377
+ if (injectingRef && "_ref" in obj && obj["_ref"] !== key && obj["_ref"] != null) return null;
378
+ if (injectingUnresolved && "_unresolved_refs" in obj && obj["_unresolved_refs"] != null && !arraysShallowEqual(obj["_unresolved_refs"], unresolved)) return null;
379
+ /**
380
+ * Only strip the framework-owned key we're actually injecting —
381
+ * leave everything else (including a pre-existing `_ref` on the
382
+ * unresolved-only path, or a pre-existing `_unresolved_refs` on a
383
+ * plain-annotation path) untouched so we annotate rather than
384
+ * mutate downstream payload data. Our injected keys land first in
385
+ * the serialized JSON so the LLM sees them before the body.
386
+ */
387
+ const omitKeys = /* @__PURE__ */ new Set();
388
+ if (injectingRef) omitKeys.add(TOOL_OUTPUT_REF_KEY);
389
+ if (injectingUnresolved) omitKeys.add(TOOL_OUTPUT_UNRESOLVED_KEY);
390
+ const rest = {};
391
+ for (const [k, v] of Object.entries(obj)) if (!omitKeys.has(k)) rest[k] = v;
392
+ const injected = {};
393
+ if (injectingRef) injected[TOOL_OUTPUT_REF_KEY] = key;
394
+ if (injectingUnresolved) injected[TOOL_OUTPUT_UNRESOLVED_KEY] = unresolved;
395
+ Object.assign(injected, rest);
396
+ return /^\{\s*\n/.test(content) ? JSON.stringify(injected, null, 2) : JSON.stringify(injected);
473
397
  }
474
398
  function arraysShallowEqual(a, b) {
475
- if (!Array.isArray(a) || a.length !== b.length) {
476
- return false;
477
- }
478
- for (let i = 0; i < a.length; i++) {
479
- if (a[i] !== b[i]) {
480
- return false;
481
- }
482
- }
483
- return true;
399
+ if (!Array.isArray(a) || a.length !== b.length) return false;
400
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
401
+ return true;
484
402
  }
485
403
  /**
486
- * Lazy projection that, given a registry and a runId, returns a new
487
- * `messages` array where each `ToolMessage` carrying ref metadata is
488
- * projected into a transient copy with annotated content (when the ref
489
- * is live in the registry) and with the framework-owned `additional_
490
- * kwargs` keys (`_refKey`, `_refScope`, `_unresolvedRefs`) stripped
491
- * regardless of whether annotation applied. The original input array
492
- * and its messages are never mutated.
493
- *
494
- * Annotation is gated on registry presence: a stale `_refKey` from a
495
- * prior run (e.g. one that survived in persisted history) silently
496
- * no-ops on the *content* side. The strip-metadata side still runs so
497
- * stale framework keys never leak onto the wire under any custom or
498
- * future provider serializer that might transmit `additional_kwargs`.
499
- * `_unresolvedRefs` is always meaningful and is not gated.
500
- *
501
- * **Feature-disabled fast path:** when the host hasn't enabled the
502
- * tool-output-reference feature, the registry is `undefined` and this
503
- * function returns the input array reference-equal *without iterating
504
- * a single message*. The loop is exclusive to the feature-enabled
505
- * code path.
506
- */
404
+ * Lazy projection that, given a registry and a runId, returns a new
405
+ * `messages` array where each `ToolMessage` carrying ref metadata is
406
+ * projected into a transient copy with annotated content (when the ref
407
+ * is live in the registry) and with the framework-owned `additional_
408
+ * kwargs` keys (`_refKey`, `_refScope`, `_unresolvedRefs`) stripped
409
+ * regardless of whether annotation applied. The original input array
410
+ * and its messages are never mutated.
411
+ *
412
+ * Annotation is gated on registry presence: a stale `_refKey` from a
413
+ * prior run (e.g. one that survived in persisted history) silently
414
+ * no-ops on the *content* side. The strip-metadata side still runs so
415
+ * stale framework keys never leak onto the wire under any custom or
416
+ * future provider serializer that might transmit `additional_kwargs`.
417
+ * `_unresolvedRefs` is always meaningful and is not gated.
418
+ *
419
+ * **Feature-disabled fast path:** when the host hasn't enabled the
420
+ * tool-output-reference feature, the registry is `undefined` and this
421
+ * function returns the input array reference-equal *without iterating
422
+ * a single message*. The loop is exclusive to the feature-enabled
423
+ * code path.
424
+ */
507
425
  function annotateMessagesForLLM(messages, registry, runId) {
508
- if (registry == null)
509
- return messages;
510
- /**
511
- * Lazy-allocate the output array so the common case (no ToolMessage
512
- * carries framework metadata) returns the input reference-equal with
513
- * zero allocations beyond the per-message predicate checks.
514
- */
515
- let out;
516
- for (let i = 0; i < messages.length; i++) {
517
- const m = messages[i];
518
- if (m._getType() !== 'tool')
519
- continue;
520
- /**
521
- * `additional_kwargs` is untyped at the LangChain layer
522
- * (`Record<string, unknown>`), so persisted or client-supplied
523
- * ToolMessages can carry arbitrary shapes including primitives
524
- * (a malformed serializer might write a string, or `null`).
525
- * Guard with a runtime object check before the `in` probes
526
- * because the `in` operator throws `TypeError` on primitives.
527
- * A single malformed message must never crash the provider call
528
- * path; skip its annotation/strip and continue.
529
- */
530
- const rawMeta = m.additional_kwargs;
531
- if (rawMeta == null || typeof rawMeta !== 'object')
532
- continue;
533
- const meta = rawMeta;
534
- const hasRefKey = '_refKey' in meta;
535
- const hasRefScope = '_refScope' in meta;
536
- const hasUnresolvedField = '_unresolvedRefs' in meta;
537
- if (!hasRefKey && !hasRefScope && !hasUnresolvedField)
538
- continue;
539
- const refKey = readRefKey(meta);
540
- const unresolved = readUnresolvedRefs(meta);
541
- /**
542
- * Prefer the message-stamped `_refScope` for the registry lookup.
543
- * For named runs it equals the current `runId`; for anonymous
544
- * invocations it carries the per-batch synthetic scope minted by
545
- * ToolNode (`\0anon-<n>`), which `runId` from config cannot
546
- * recover. Falling back to `runId` keeps backward compatibility
547
- * with messages stamped before this field existed.
548
- */
549
- const lookupScope = readRefScope(meta) ?? runId;
550
- const liveRef = refKey != null && registry.has(lookupScope, refKey) ? refKey : undefined;
551
- const annotates = liveRef != null || unresolved.length > 0;
552
- const tm = m;
553
- let nextContent = tm.content;
554
- if (annotates && typeof tm.content === 'string') {
555
- nextContent = annotateToolOutputWithReference(tm.content, liveRef, unresolved);
556
- }
557
- else if (annotates &&
558
- Array.isArray(tm.content) &&
559
- unresolved.length > 0) {
560
- const warningBlock = {
561
- type: 'text',
562
- text: `[unresolved refs: ${unresolved.join(', ')}]`,
563
- };
564
- /**
565
- * `as unknown as ToolMessage['content']` is unavoidable here:
566
- * LangChain's content union (`MessageContentComplex[] |
567
- * DataContentBlock[] | string`) does not accept a freshly built
568
- * mixed array literal even though the structural shape is valid
569
- * at runtime. The double-cast is structurally safe we
570
- * preserve every block from `tm.content` and prepend a single
571
- * `{ type: 'text', text }` block that all providers accept.
572
- */
573
- nextContent = [
574
- warningBlock,
575
- ...tm.content,
576
- ];
577
- }
578
- /**
579
- * Project unconditionally: even when no annotation applies (stale
580
- * `_refKey` or non-annotatable content), `cloneToolMessageWithContent`
581
- * runs `stripFrameworkRefMetadata` on `additional_kwargs` so the
582
- * framework-owned keys never reach the wire.
583
- */
584
- out ??= messages.slice();
585
- out[i] = cloneToolMessageWithContent(tm, nextContent);
586
- }
587
- return out ?? messages;
426
+ if (registry == null) return messages;
427
+ /**
428
+ * Lazy-allocate the output array so the common case (no ToolMessage
429
+ * carries framework metadata) returns the input reference-equal with
430
+ * zero allocations beyond the per-message predicate checks.
431
+ */
432
+ let out;
433
+ for (let i = 0; i < messages.length; i++) {
434
+ const m = messages[i];
435
+ if (m._getType() !== "tool") continue;
436
+ /**
437
+ * `additional_kwargs` is untyped at the LangChain layer
438
+ * (`Record<string, unknown>`), so persisted or client-supplied
439
+ * ToolMessages can carry arbitrary shapes including primitives
440
+ * (a malformed serializer might write a string, or `null`).
441
+ * Guard with a runtime object check before the `in` probes
442
+ * because the `in` operator throws `TypeError` on primitives.
443
+ * A single malformed message must never crash the provider call
444
+ * path; skip its annotation/strip and continue.
445
+ */
446
+ const rawMeta = m.additional_kwargs;
447
+ if (rawMeta == null || typeof rawMeta !== "object") continue;
448
+ const meta = rawMeta;
449
+ const hasRefKey = "_refKey" in meta;
450
+ const hasRefScope = "_refScope" in meta;
451
+ const hasUnresolvedField = "_unresolvedRefs" in meta;
452
+ if (!hasRefKey && !hasRefScope && !hasUnresolvedField) continue;
453
+ const refKey = readRefKey(meta);
454
+ const unresolved = readUnresolvedRefs(meta);
455
+ /**
456
+ * Prefer the message-stamped `_refScope` for the registry lookup.
457
+ * For named runs it equals the current `runId`; for anonymous
458
+ * invocations it carries the per-batch synthetic scope minted by
459
+ * ToolNode (`\0anon-<n>`), which `runId` from config cannot
460
+ * recover. Falling back to `runId` keeps backward compatibility
461
+ * with messages stamped before this field existed.
462
+ */
463
+ const lookupScope = readRefScope(meta) ?? runId;
464
+ const liveRef = refKey != null && registry.has(lookupScope, refKey) ? refKey : void 0;
465
+ const annotates = liveRef != null || unresolved.length > 0;
466
+ const tm = m;
467
+ let nextContent = tm.content;
468
+ if (annotates && typeof tm.content === "string") nextContent = annotateToolOutputWithReference(tm.content, liveRef, unresolved);
469
+ else if (annotates && Array.isArray(tm.content) && unresolved.length > 0)
470
+ /**
471
+ * `as unknown as ToolMessage['content']` is unavoidable here:
472
+ * LangChain's content union (`MessageContentComplex[] |
473
+ * DataContentBlock[] | string`) does not accept a freshly built
474
+ * mixed array literal even though the structural shape is valid
475
+ * at runtime. The double-cast is structurally safe — we
476
+ * preserve every block from `tm.content` and prepend a single
477
+ * `{ type: 'text', text }` block that all providers accept.
478
+ */
479
+ nextContent = [{
480
+ type: "text",
481
+ text: `[unresolved refs: ${unresolved.join(", ")}]`
482
+ }, ...tm.content];
483
+ /**
484
+ * Project unconditionally: even when no annotation applies (stale
485
+ * `_refKey` or non-annotatable content), `cloneToolMessageWithContent`
486
+ * runs `stripFrameworkRefMetadata` on `additional_kwargs` so the
487
+ * framework-owned keys never reach the wire.
488
+ */
489
+ out ??= messages.slice();
490
+ out[i] = cloneToolMessageWithContent(tm, nextContent);
491
+ }
492
+ return out ?? messages;
588
493
  }
589
494
  /**
590
- * Reads `_refKey` defensively from untyped `additional_kwargs`. Returns
591
- * undefined for non-string values so a malformed field cannot poison
592
- * the registry lookup or downstream string operations.
593
- */
495
+ * Reads `_refKey` defensively from untyped `additional_kwargs`. Returns
496
+ * undefined for non-string values so a malformed field cannot poison
497
+ * the registry lookup or downstream string operations.
498
+ */
594
499
  function readRefKey(meta) {
595
- const v = meta?._refKey;
596
- return typeof v === 'string' ? v : undefined;
500
+ const v = meta?._refKey;
501
+ return typeof v === "string" ? v : void 0;
597
502
  }
598
503
  /**
599
- * Reads `_refScope` defensively from untyped `additional_kwargs`.
600
- * Mirrors {@link readRefKey} — non-string scopes are dropped (the
601
- * caller falls back to the run-derived scope) rather than passed into
602
- * the registry as a malformed key.
603
- */
504
+ * Reads `_refScope` defensively from untyped `additional_kwargs`.
505
+ * Mirrors {@link readRefKey} — non-string scopes are dropped (the
506
+ * caller falls back to the run-derived scope) rather than passed into
507
+ * the registry as a malformed key.
508
+ */
604
509
  function readRefScope(meta) {
605
- const v = meta?._refScope;
606
- return typeof v === 'string' ? v : undefined;
510
+ const v = meta?._refScope;
511
+ return typeof v === "string" ? v : void 0;
607
512
  }
608
513
  /**
609
- * Reads `_unresolvedRefs` defensively from untyped `additional_kwargs`.
610
- * Returns an empty array for any non-array value, and filters out
611
- * non-string entries from a real array. Without this guard, a hydrated
612
- * ToolMessage carrying e.g. `_unresolvedRefs: 'tool0turn0'` would crash
613
- * `attemptInvoke` on the eventual `.length` / `.join(...)` call.
614
- */
514
+ * Reads `_unresolvedRefs` defensively from untyped `additional_kwargs`.
515
+ * Returns an empty array for any non-array value, and filters out
516
+ * non-string entries from a real array. Without this guard, a hydrated
517
+ * ToolMessage carrying e.g. `_unresolvedRefs: 'tool0turn0'` would crash
518
+ * `attemptInvoke` on the eventual `.length` / `.join(...)` call.
519
+ */
615
520
  function readUnresolvedRefs(meta) {
616
- const v = meta?._unresolvedRefs;
617
- if (!Array.isArray(v))
618
- return [];
619
- const out = [];
620
- for (const item of v) {
621
- if (typeof item === 'string')
622
- out.push(item);
623
- }
624
- return out;
521
+ const v = meta?._unresolvedRefs;
522
+ if (!Array.isArray(v)) return [];
523
+ const out = [];
524
+ for (const item of v) if (typeof item === "string") out.push(item);
525
+ return out;
625
526
  }
626
527
  /**
627
- * Builds a fresh `ToolMessage` that mirrors `tm`'s identity fields with
628
- * the supplied `content`. Every `ToolMessage` field but `content` is
629
- * carried over so the projection is structurally identical to the
630
- * original from a LangChain serializer's perspective.
631
- *
632
- * `additional_kwargs` is rebuilt with the framework-owned ref keys
633
- * stripped. Defensive: LangChain's standard provider serializers do not
634
- * transmit `additional_kwargs` to provider HTTP APIs, but a custom
635
- * adapter or future LangChain change could. Stripping keeps the
636
- * implementation correct under any serializer behavior at the cost of a
637
- * shallow object spread per annotated message.
638
- */
528
+ * Builds a fresh `ToolMessage` that mirrors `tm`'s identity fields with
529
+ * the supplied `content`. Every `ToolMessage` field but `content` is
530
+ * carried over so the projection is structurally identical to the
531
+ * original from a LangChain serializer's perspective.
532
+ *
533
+ * `additional_kwargs` is rebuilt with the framework-owned ref keys
534
+ * stripped. Defensive: LangChain's standard provider serializers do not
535
+ * transmit `additional_kwargs` to provider HTTP APIs, but a custom
536
+ * adapter or future LangChain change could. Stripping keeps the
537
+ * implementation correct under any serializer behavior at the cost of a
538
+ * shallow object spread per annotated message.
539
+ */
639
540
  function cloneToolMessageWithContent(tm, content) {
640
- return new messages.ToolMessage({
641
- id: tm.id,
642
- name: tm.name,
643
- status: tm.status,
644
- artifact: tm.artifact,
645
- tool_call_id: tm.tool_call_id,
646
- response_metadata: tm.response_metadata,
647
- additional_kwargs: stripFrameworkRefMetadata(tm.additional_kwargs),
648
- content,
649
- });
541
+ return new _langchain_core_messages.ToolMessage({
542
+ id: tm.id,
543
+ name: tm.name,
544
+ status: tm.status,
545
+ artifact: tm.artifact,
546
+ tool_call_id: tm.tool_call_id,
547
+ response_metadata: tm.response_metadata,
548
+ additional_kwargs: stripFrameworkRefMetadata(tm.additional_kwargs),
549
+ content
550
+ });
650
551
  }
651
552
  /**
652
- * Returns a copy of `kwargs` with `_refKey`, `_refScope`, and
653
- * `_unresolvedRefs` removed. Returns the input reference-equal when
654
- * none of those keys are present so the no-strip path stays cheap;
655
- * returns `undefined` when stripping leaves the object empty so the
656
- * caller can drop the field entirely.
657
- */
553
+ * Returns a copy of `kwargs` with `_refKey`, `_refScope`, and
554
+ * `_unresolvedRefs` removed. Returns the input reference-equal when
555
+ * none of those keys are present so the no-strip path stays cheap;
556
+ * returns `undefined` when stripping leaves the object empty so the
557
+ * caller can drop the field entirely.
558
+ */
658
559
  function stripFrameworkRefMetadata(kwargs) {
659
- if (kwargs == null)
660
- return undefined;
661
- if (!('_refKey' in kwargs) &&
662
- !('_refScope' in kwargs) &&
663
- !('_unresolvedRefs' in kwargs)) {
664
- return kwargs;
665
- }
666
- const { _refKey, _refScope, _unresolvedRefs, ...rest } = kwargs;
667
- return Object.keys(rest).length === 0 ? undefined : rest;
560
+ if (kwargs == null) return void 0;
561
+ if (!("_refKey" in kwargs) && !("_refScope" in kwargs) && !("_unresolvedRefs" in kwargs)) return kwargs;
562
+ const { _refKey, _refScope, _unresolvedRefs, ...rest } = kwargs;
563
+ return Object.keys(rest).length === 0 ? void 0 : rest;
668
564
  }
669
-
670
- exports.TOOL_OUTPUT_REF_KEY = TOOL_OUTPUT_REF_KEY;
565
+ //#endregion
671
566
  exports.TOOL_OUTPUT_REF_PATTERN = TOOL_OUTPUT_REF_PATTERN;
672
- exports.TOOL_OUTPUT_UNRESOLVED_KEY = TOOL_OUTPUT_UNRESOLVED_KEY;
673
567
  exports.ToolOutputReferenceRegistry = ToolOutputReferenceRegistry;
674
568
  exports.annotateMessagesForLLM = annotateMessagesForLLM;
675
- exports.annotateToolOutputWithReference = annotateToolOutputWithReference;
676
569
  exports.buildReferenceKey = buildReferenceKey;
677
- exports.buildReferencePrefix = buildReferencePrefix;
678
- //# sourceMappingURL=toolOutputReferences.cjs.map
570
+
571
+ //# sourceMappingURL=toolOutputReferences.cjs.map