langchain 1.0.0-alpha.8 → 1.0.0-alpha.9

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 (442) hide show
  1. package/LICENSE +6 -6
  2. package/dist/agents/ReactAgent.cjs +497 -104
  3. package/dist/agents/ReactAgent.cjs.map +1 -1
  4. package/dist/agents/ReactAgent.d.cts +140 -17
  5. package/dist/agents/ReactAgent.d.cts.map +1 -1
  6. package/dist/agents/ReactAgent.d.ts +140 -17
  7. package/dist/agents/ReactAgent.d.ts.map +1 -1
  8. package/dist/agents/ReactAgent.js +500 -107
  9. package/dist/agents/ReactAgent.js.map +1 -1
  10. package/dist/agents/annotation.cjs +32 -149
  11. package/dist/agents/annotation.cjs.map +1 -1
  12. package/dist/agents/annotation.js +34 -147
  13. package/dist/agents/annotation.js.map +1 -1
  14. package/dist/agents/constants.cjs.map +1 -1
  15. package/dist/agents/constants.d.cts +9 -0
  16. package/dist/agents/constants.d.cts.map +1 -0
  17. package/dist/agents/constants.d.ts +9 -0
  18. package/dist/agents/constants.d.ts.map +1 -0
  19. package/dist/agents/constants.js.map +1 -1
  20. package/dist/agents/errors.cjs +2 -1
  21. package/dist/agents/errors.cjs.map +1 -1
  22. package/dist/agents/errors.js +2 -1
  23. package/dist/agents/errors.js.map +1 -1
  24. package/dist/agents/index.cjs +5 -29
  25. package/dist/agents/index.cjs.map +1 -1
  26. package/dist/agents/index.d.cts +157 -128
  27. package/dist/agents/index.d.cts.map +1 -1
  28. package/dist/agents/index.d.ts +157 -128
  29. package/dist/agents/index.d.ts.map +1 -1
  30. package/dist/agents/index.js +5 -27
  31. package/dist/agents/index.js.map +1 -1
  32. package/dist/agents/{middlewareAgent/middleware → middleware}/callLimit.cjs +2 -2
  33. package/dist/agents/middleware/callLimit.cjs.map +1 -0
  34. package/dist/agents/{middlewareAgent/middleware → middleware}/callLimit.d.cts +3 -3
  35. package/dist/agents/middleware/callLimit.d.cts.map +1 -0
  36. package/dist/agents/{middlewareAgent/middleware → middleware}/callLimit.d.ts +3 -3
  37. package/dist/agents/middleware/callLimit.d.ts.map +1 -0
  38. package/dist/agents/{middlewareAgent/middleware → middleware}/callLimit.js +1 -1
  39. package/dist/agents/middleware/callLimit.js.map +1 -0
  40. package/dist/agents/{middlewareAgent/middleware → middleware}/contextEditing.cjs +5 -5
  41. package/dist/agents/middleware/contextEditing.cjs.map +1 -0
  42. package/dist/agents/{middlewareAgent/middleware → middleware}/contextEditing.d.cts +2 -2
  43. package/dist/agents/middleware/contextEditing.d.cts.map +1 -0
  44. package/dist/agents/{middlewareAgent/middleware → middleware}/contextEditing.d.ts +2 -2
  45. package/dist/agents/middleware/contextEditing.d.ts.map +1 -0
  46. package/dist/agents/{middlewareAgent/middleware → middleware}/contextEditing.js +4 -4
  47. package/dist/agents/middleware/contextEditing.js.map +1 -0
  48. package/dist/agents/{middlewareAgent/middleware → middleware}/dynamicSystemPrompt.cjs +6 -6
  49. package/dist/agents/middleware/dynamicSystemPrompt.cjs.map +1 -0
  50. package/dist/agents/{middlewareAgent/middleware → middleware}/dynamicSystemPrompt.d.cts +3 -2
  51. package/dist/agents/middleware/dynamicSystemPrompt.d.cts.map +1 -0
  52. package/dist/agents/{middlewareAgent/middleware → middleware}/dynamicSystemPrompt.d.ts +3 -2
  53. package/dist/agents/middleware/dynamicSystemPrompt.d.ts.map +1 -0
  54. package/dist/agents/{middlewareAgent/middleware → middleware}/dynamicSystemPrompt.js +6 -6
  55. package/dist/agents/middleware/dynamicSystemPrompt.js.map +1 -0
  56. package/dist/agents/middleware/hitl.cjs +404 -0
  57. package/dist/agents/middleware/hitl.cjs.map +1 -0
  58. package/dist/agents/middleware/hitl.d.cts +611 -0
  59. package/dist/agents/middleware/hitl.d.cts.map +1 -0
  60. package/dist/agents/middleware/hitl.d.ts +611 -0
  61. package/dist/agents/middleware/hitl.d.ts.map +1 -0
  62. package/dist/agents/middleware/hitl.js +403 -0
  63. package/dist/agents/middleware/hitl.js.map +1 -0
  64. package/dist/agents/middleware/index.cjs +12 -0
  65. package/dist/agents/middleware/index.js +12 -0
  66. package/dist/agents/{middlewareAgent/middleware → middleware}/llmToolSelector.cjs +7 -7
  67. package/dist/agents/middleware/llmToolSelector.cjs.map +1 -0
  68. package/dist/agents/{middlewareAgent/middleware → middleware}/llmToolSelector.d.cts +2 -2
  69. package/dist/agents/middleware/llmToolSelector.d.cts.map +1 -0
  70. package/dist/agents/{middlewareAgent/middleware → middleware}/llmToolSelector.d.ts +2 -2
  71. package/dist/agents/middleware/llmToolSelector.d.ts.map +1 -0
  72. package/dist/agents/{middlewareAgent/middleware → middleware}/llmToolSelector.js +6 -6
  73. package/dist/agents/middleware/llmToolSelector.js.map +1 -0
  74. package/dist/agents/{middlewareAgent/middleware → middleware}/modelFallback.cjs +28 -21
  75. package/dist/agents/middleware/modelFallback.cjs.map +1 -0
  76. package/dist/agents/{middlewareAgent/middleware → middleware}/modelFallback.d.cts +2 -2
  77. package/dist/agents/middleware/modelFallback.d.cts.map +1 -0
  78. package/dist/agents/{middlewareAgent/middleware → middleware}/modelFallback.d.ts +2 -2
  79. package/dist/agents/middleware/modelFallback.d.ts.map +1 -0
  80. package/dist/agents/{middlewareAgent/middleware → middleware}/modelFallback.js +28 -21
  81. package/dist/agents/middleware/modelFallback.js.map +1 -0
  82. package/dist/agents/{middlewareAgent/middleware → middleware}/piiRedaction.cjs +12 -12
  83. package/dist/agents/middleware/piiRedaction.cjs.map +1 -0
  84. package/dist/agents/{middlewareAgent/middleware → middleware}/piiRedaction.d.cts +4 -4
  85. package/dist/agents/middleware/piiRedaction.d.cts.map +1 -0
  86. package/dist/agents/{middlewareAgent/middleware → middleware}/piiRedaction.d.ts +4 -4
  87. package/dist/agents/middleware/piiRedaction.d.ts.map +1 -0
  88. package/dist/agents/{middlewareAgent/middleware → middleware}/piiRedaction.js +10 -10
  89. package/dist/agents/middleware/piiRedaction.js.map +1 -0
  90. package/dist/agents/{middlewareAgent/middleware → middleware}/promptCaching.cjs +27 -24
  91. package/dist/agents/middleware/promptCaching.cjs.map +1 -0
  92. package/dist/agents/{middlewareAgent/middleware → middleware}/promptCaching.d.cts +3 -3
  93. package/dist/agents/middleware/promptCaching.d.cts.map +1 -0
  94. package/dist/agents/{middlewareAgent/middleware → middleware}/promptCaching.d.ts +3 -3
  95. package/dist/agents/middleware/promptCaching.d.ts.map +1 -0
  96. package/dist/agents/{middlewareAgent/middleware → middleware}/promptCaching.js +26 -23
  97. package/dist/agents/middleware/promptCaching.js.map +1 -0
  98. package/dist/agents/{middlewareAgent/middleware → middleware}/summarization.cjs +7 -12
  99. package/dist/agents/middleware/summarization.cjs.map +1 -0
  100. package/dist/agents/{middlewareAgent/middleware → middleware}/summarization.d.cts +3 -3
  101. package/dist/agents/middleware/summarization.d.cts.map +1 -0
  102. package/dist/agents/{middlewareAgent/middleware → middleware}/summarization.d.ts +3 -3
  103. package/dist/agents/middleware/summarization.d.ts.map +1 -0
  104. package/dist/agents/{middlewareAgent/middleware → middleware}/summarization.js +4 -9
  105. package/dist/agents/middleware/summarization.js.map +1 -0
  106. package/dist/agents/middleware/todoListMiddleware.cjs +314 -0
  107. package/dist/agents/middleware/todoListMiddleware.cjs.map +1 -0
  108. package/dist/agents/middleware/todoListMiddleware.d.cts +75 -0
  109. package/dist/agents/middleware/todoListMiddleware.d.cts.map +1 -0
  110. package/dist/agents/middleware/todoListMiddleware.d.ts +75 -0
  111. package/dist/agents/middleware/todoListMiddleware.d.ts.map +1 -0
  112. package/dist/agents/middleware/todoListMiddleware.js +312 -0
  113. package/dist/agents/middleware/todoListMiddleware.js.map +1 -0
  114. package/dist/agents/{middlewareAgent/middleware → middleware}/toolCallLimit.cjs +2 -2
  115. package/dist/agents/middleware/toolCallLimit.cjs.map +1 -0
  116. package/dist/agents/{middlewareAgent/middleware → middleware}/toolCallLimit.d.cts +3 -3
  117. package/dist/agents/middleware/toolCallLimit.d.cts.map +1 -0
  118. package/dist/agents/{middlewareAgent/middleware → middleware}/toolCallLimit.d.ts +3 -3
  119. package/dist/agents/middleware/toolCallLimit.d.ts.map +1 -0
  120. package/dist/agents/{middlewareAgent/middleware → middleware}/toolCallLimit.js +1 -1
  121. package/dist/agents/middleware/toolCallLimit.js.map +1 -0
  122. package/dist/agents/middleware/types.d.cts +208 -0
  123. package/dist/agents/middleware/types.d.cts.map +1 -0
  124. package/dist/agents/middleware/types.d.ts +208 -0
  125. package/dist/agents/middleware/types.d.ts.map +1 -0
  126. package/dist/agents/{middlewareAgent/middleware → middleware}/utils.cjs +1 -1
  127. package/dist/agents/middleware/utils.cjs.map +1 -0
  128. package/dist/agents/{middlewareAgent/middleware → middleware}/utils.d.cts +1 -1
  129. package/dist/agents/middleware/utils.d.cts.map +1 -0
  130. package/dist/agents/{middlewareAgent/middleware → middleware}/utils.d.ts +1 -1
  131. package/dist/agents/middleware/utils.d.ts.map +1 -0
  132. package/dist/agents/{middlewareAgent/middleware → middleware}/utils.js +1 -1
  133. package/dist/agents/middleware/utils.js.map +1 -0
  134. package/dist/agents/{middlewareAgent/middleware.cjs → middleware.cjs} +11 -4
  135. package/dist/agents/middleware.cjs.map +1 -0
  136. package/dist/agents/middleware.d.cts +205 -0
  137. package/dist/agents/middleware.d.cts.map +1 -0
  138. package/dist/agents/middleware.d.ts +205 -0
  139. package/dist/agents/middleware.d.ts.map +1 -0
  140. package/dist/agents/{middlewareAgent/middleware.js → middleware.js} +11 -4
  141. package/dist/agents/middleware.js.map +1 -0
  142. package/dist/agents/nodes/AfterAgentNode.cjs +27 -0
  143. package/dist/agents/nodes/AfterAgentNode.cjs.map +1 -0
  144. package/dist/agents/nodes/AfterAgentNode.js +27 -0
  145. package/dist/agents/nodes/AfterAgentNode.js.map +1 -0
  146. package/dist/agents/{middlewareAgent/nodes/AfterModalNode.cjs → nodes/AfterModelNode.cjs} +3 -5
  147. package/dist/agents/nodes/AfterModelNode.cjs.map +1 -0
  148. package/dist/agents/{middlewareAgent/nodes/AfterModalNode.js → nodes/AfterModelNode.js} +3 -5
  149. package/dist/agents/nodes/AfterModelNode.js.map +1 -0
  150. package/dist/agents/nodes/AgentNode.cjs +202 -71
  151. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  152. package/dist/agents/nodes/AgentNode.js +204 -73
  153. package/dist/agents/nodes/AgentNode.js.map +1 -1
  154. package/dist/agents/nodes/BeforeAgentNode.cjs +27 -0
  155. package/dist/agents/nodes/BeforeAgentNode.cjs.map +1 -0
  156. package/dist/agents/nodes/BeforeAgentNode.js +27 -0
  157. package/dist/agents/nodes/BeforeAgentNode.js.map +1 -0
  158. package/dist/agents/{middlewareAgent/nodes/BeforeModalNode.cjs → nodes/BeforeModelNode.cjs} +3 -3
  159. package/dist/agents/nodes/BeforeModelNode.cjs.map +1 -0
  160. package/dist/agents/{middlewareAgent/nodes/BeforeModalNode.js → nodes/BeforeModelNode.js} +3 -3
  161. package/dist/agents/nodes/BeforeModelNode.js.map +1 -0
  162. package/dist/agents/nodes/ToolNode.cjs +157 -47
  163. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  164. package/dist/agents/nodes/ToolNode.js +158 -48
  165. package/dist/agents/nodes/ToolNode.js.map +1 -1
  166. package/dist/agents/{middlewareAgent/nodes → nodes}/middleware.cjs +35 -10
  167. package/dist/agents/nodes/middleware.cjs.map +1 -0
  168. package/dist/agents/{middlewareAgent/nodes → nodes}/middleware.js +34 -9
  169. package/dist/agents/nodes/middleware.js.map +1 -0
  170. package/dist/agents/nodes/types.d.cts +57 -0
  171. package/dist/agents/nodes/types.d.cts.map +1 -0
  172. package/dist/agents/nodes/types.d.ts +57 -0
  173. package/dist/agents/nodes/types.d.ts.map +1 -0
  174. package/dist/agents/nodes/utils.cjs +64 -0
  175. package/dist/agents/nodes/utils.cjs.map +1 -1
  176. package/dist/agents/nodes/utils.js +62 -1
  177. package/dist/agents/nodes/utils.js.map +1 -1
  178. package/dist/agents/responses.cjs +1 -1
  179. package/dist/agents/responses.cjs.map +1 -1
  180. package/dist/agents/responses.d.cts +9 -2
  181. package/dist/agents/responses.d.cts.map +1 -1
  182. package/dist/agents/responses.d.ts +8 -1
  183. package/dist/agents/responses.d.ts.map +1 -1
  184. package/dist/agents/responses.js +1 -1
  185. package/dist/agents/responses.js.map +1 -1
  186. package/dist/agents/runtime.d.cts +123 -0
  187. package/dist/agents/runtime.d.cts.map +1 -0
  188. package/dist/agents/runtime.d.ts +123 -0
  189. package/dist/agents/runtime.d.ts.map +1 -0
  190. package/dist/agents/tests/utils.cjs +13 -5
  191. package/dist/agents/tests/utils.cjs.map +1 -1
  192. package/dist/agents/tests/utils.d.cts +17 -8
  193. package/dist/agents/tests/utils.d.cts.map +1 -1
  194. package/dist/agents/tests/utils.d.ts +14 -5
  195. package/dist/agents/tests/utils.d.ts.map +1 -1
  196. package/dist/agents/tests/utils.js +13 -5
  197. package/dist/agents/tests/utils.js.map +1 -1
  198. package/dist/agents/tools.d.cts +9 -0
  199. package/dist/agents/tools.d.cts.map +1 -0
  200. package/dist/agents/tools.d.ts +9 -0
  201. package/dist/agents/tools.d.ts.map +1 -0
  202. package/dist/agents/types.d.cts +125 -126
  203. package/dist/agents/types.d.cts.map +1 -1
  204. package/dist/agents/types.d.ts +125 -126
  205. package/dist/agents/types.d.ts.map +1 -1
  206. package/dist/agents/utils.cjs +141 -38
  207. package/dist/agents/utils.cjs.map +1 -1
  208. package/dist/agents/utils.js +142 -40
  209. package/dist/agents/utils.js.map +1 -1
  210. package/dist/chat_models/universal.cjs +4 -0
  211. package/dist/chat_models/universal.cjs.map +1 -1
  212. package/dist/chat_models/universal.d.cts +6 -2
  213. package/dist/chat_models/universal.d.cts.map +1 -1
  214. package/dist/chat_models/universal.d.ts +4 -0
  215. package/dist/chat_models/universal.d.ts.map +1 -1
  216. package/dist/chat_models/universal.js +4 -0
  217. package/dist/chat_models/universal.js.map +1 -1
  218. package/dist/hub/base.cjs +4 -3
  219. package/dist/hub/base.cjs.map +1 -1
  220. package/dist/hub/base.d.cts +0 -4
  221. package/dist/hub/base.d.cts.map +1 -1
  222. package/dist/hub/base.d.ts +0 -4
  223. package/dist/hub/base.d.ts.map +1 -1
  224. package/dist/hub/base.js +4 -3
  225. package/dist/hub/base.js.map +1 -1
  226. package/dist/index.cjs +18 -38
  227. package/dist/index.cjs.map +1 -1
  228. package/dist/index.d.cts +21 -21
  229. package/dist/index.d.ts +21 -21
  230. package/dist/index.js +17 -26
  231. package/dist/index.js.map +1 -1
  232. package/dist/load/import_map.cjs +0 -2
  233. package/dist/load/import_map.cjs.map +1 -1
  234. package/dist/load/import_map.js +0 -2
  235. package/dist/load/import_map.js.map +1 -1
  236. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/client.cjs +74 -18
  237. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/client.cjs.map +1 -0
  238. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/client.js +75 -19
  239. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/client.js.map +1 -0
  240. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/env.cjs +1 -1
  241. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/env.cjs.map +1 -1
  242. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/env.js +1 -1
  243. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/env.js.map +1 -1
  244. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/constants.cjs +1 -1
  245. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/constants.cjs.map +1 -1
  246. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/constants.js +1 -1
  247. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/constants.js.map +1 -1
  248. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/translator.cjs +1 -1
  249. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/translator.cjs.map +1 -1
  250. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/translator.js +1 -1
  251. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/translator.js.map +1 -1
  252. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/index.cjs +2 -2
  253. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/index.cjs.map +1 -1
  254. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/index.js +2 -2
  255. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/index.js.map +1 -1
  256. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/run_trees.cjs +7 -5
  257. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/run_trees.cjs.map +1 -0
  258. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/run_trees.js +7 -5
  259. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/run_trees.js.map +1 -0
  260. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/constants.cjs +1 -1
  261. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/constants.cjs.map +1 -1
  262. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/constants.js +1 -1
  263. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/constants.js.map +1 -1
  264. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/fetch.cjs +1 -1
  265. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/fetch.cjs.map +1 -1
  266. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/fetch.js +1 -1
  267. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/fetch.js.map +1 -1
  268. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/otel.cjs +1 -1
  269. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/otel.cjs.map +1 -1
  270. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/otel.js +1 -1
  271. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/otel.js.map +1 -1
  272. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/_uuid.cjs +1 -1
  273. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/_uuid.cjs.map +1 -1
  274. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/_uuid.js +1 -1
  275. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/_uuid.js.map +1 -1
  276. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/async_caller.cjs +1 -1
  277. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/async_caller.cjs.map +1 -1
  278. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/async_caller.js +1 -1
  279. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/async_caller.js.map +1 -1
  280. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/env.cjs +19 -23
  281. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/env.cjs.map +1 -0
  282. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/env.js +19 -23
  283. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/env.js.map +1 -0
  284. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/error.cjs +16 -3
  285. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/error.cjs.map +1 -0
  286. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/error.js +16 -3
  287. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/error.js.map +1 -0
  288. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/fast-safe-stringify/index.cjs +1 -1
  289. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/fast-safe-stringify/index.cjs.map +1 -1
  290. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/fast-safe-stringify/index.js +1 -1
  291. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/fast-safe-stringify/index.js.map +1 -1
  292. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/messages.cjs +1 -1
  293. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/messages.cjs.map +1 -1
  294. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/messages.js +1 -1
  295. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/messages.js.map +1 -1
  296. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/project.cjs +1 -1
  297. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/project.cjs.map +1 -1
  298. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/project.js +1 -1
  299. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/project.js.map +1 -1
  300. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/prompts.cjs +1 -1
  301. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/prompts.cjs.map +1 -1
  302. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/prompts.js +1 -1
  303. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/prompts.js.map +1 -1
  304. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/warn.cjs +1 -1
  305. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/warn.cjs.map +1 -1
  306. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/warn.js +1 -1
  307. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/warn.js.map +1 -1
  308. package/package.json +4 -18
  309. package/dist/agents/RunnableCallable.d.cts +0 -41
  310. package/dist/agents/RunnableCallable.d.cts.map +0 -1
  311. package/dist/agents/RunnableCallable.d.ts +0 -41
  312. package/dist/agents/RunnableCallable.d.ts.map +0 -1
  313. package/dist/agents/annotation.d.cts +0 -52
  314. package/dist/agents/annotation.d.cts.map +0 -1
  315. package/dist/agents/annotation.d.ts +0 -52
  316. package/dist/agents/annotation.d.ts.map +0 -1
  317. package/dist/agents/createAgent.cjs +0 -10
  318. package/dist/agents/createAgent.cjs.map +0 -1
  319. package/dist/agents/createAgent.js +0 -10
  320. package/dist/agents/createAgent.js.map +0 -1
  321. package/dist/agents/interrupt.cjs +0 -2
  322. package/dist/agents/interrupt.d.cts +0 -81
  323. package/dist/agents/interrupt.d.cts.map +0 -1
  324. package/dist/agents/interrupt.d.ts +0 -81
  325. package/dist/agents/interrupt.d.ts.map +0 -1
  326. package/dist/agents/interrupt.js +0 -3
  327. package/dist/agents/middlewareAgent/ReactAgent.cjs +0 -579
  328. package/dist/agents/middlewareAgent/ReactAgent.cjs.map +0 -1
  329. package/dist/agents/middlewareAgent/ReactAgent.d.cts +0 -234
  330. package/dist/agents/middlewareAgent/ReactAgent.d.cts.map +0 -1
  331. package/dist/agents/middlewareAgent/ReactAgent.d.ts +0 -234
  332. package/dist/agents/middlewareAgent/ReactAgent.d.ts.map +0 -1
  333. package/dist/agents/middlewareAgent/ReactAgent.js +0 -578
  334. package/dist/agents/middlewareAgent/ReactAgent.js.map +0 -1
  335. package/dist/agents/middlewareAgent/annotation.cjs +0 -45
  336. package/dist/agents/middlewareAgent/annotation.cjs.map +0 -1
  337. package/dist/agents/middlewareAgent/annotation.js +0 -44
  338. package/dist/agents/middlewareAgent/annotation.js.map +0 -1
  339. package/dist/agents/middlewareAgent/constants.d.cts +0 -5
  340. package/dist/agents/middlewareAgent/constants.d.cts.map +0 -1
  341. package/dist/agents/middlewareAgent/constants.d.ts +0 -5
  342. package/dist/agents/middlewareAgent/constants.d.ts.map +0 -1
  343. package/dist/agents/middlewareAgent/index.cjs +0 -11
  344. package/dist/agents/middlewareAgent/index.cjs.map +0 -1
  345. package/dist/agents/middlewareAgent/index.js +0 -11
  346. package/dist/agents/middlewareAgent/index.js.map +0 -1
  347. package/dist/agents/middlewareAgent/middleware/callLimit.cjs.map +0 -1
  348. package/dist/agents/middlewareAgent/middleware/callLimit.d.cts.map +0 -1
  349. package/dist/agents/middlewareAgent/middleware/callLimit.d.ts.map +0 -1
  350. package/dist/agents/middlewareAgent/middleware/callLimit.js.map +0 -1
  351. package/dist/agents/middlewareAgent/middleware/contextEditing.cjs.map +0 -1
  352. package/dist/agents/middlewareAgent/middleware/contextEditing.d.cts.map +0 -1
  353. package/dist/agents/middlewareAgent/middleware/contextEditing.d.ts.map +0 -1
  354. package/dist/agents/middlewareAgent/middleware/contextEditing.js.map +0 -1
  355. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs.map +0 -1
  356. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts.map +0 -1
  357. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts.map +0 -1
  358. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js.map +0 -1
  359. package/dist/agents/middlewareAgent/middleware/hitl.cjs +0 -341
  360. package/dist/agents/middlewareAgent/middleware/hitl.cjs.map +0 -1
  361. package/dist/agents/middlewareAgent/middleware/hitl.d.cts +0 -524
  362. package/dist/agents/middlewareAgent/middleware/hitl.d.cts.map +0 -1
  363. package/dist/agents/middlewareAgent/middleware/hitl.d.ts +0 -524
  364. package/dist/agents/middlewareAgent/middleware/hitl.d.ts.map +0 -1
  365. package/dist/agents/middlewareAgent/middleware/hitl.js +0 -340
  366. package/dist/agents/middlewareAgent/middleware/hitl.js.map +0 -1
  367. package/dist/agents/middlewareAgent/middleware/index.cjs +0 -52
  368. package/dist/agents/middlewareAgent/middleware/index.cjs.map +0 -1
  369. package/dist/agents/middlewareAgent/middleware/index.d.cts +0 -13
  370. package/dist/agents/middlewareAgent/middleware/index.d.ts +0 -13
  371. package/dist/agents/middlewareAgent/middleware/index.js +0 -34
  372. package/dist/agents/middlewareAgent/middleware/index.js.map +0 -1
  373. package/dist/agents/middlewareAgent/middleware/llmToolSelector.cjs.map +0 -1
  374. package/dist/agents/middlewareAgent/middleware/llmToolSelector.d.cts.map +0 -1
  375. package/dist/agents/middlewareAgent/middleware/llmToolSelector.d.ts.map +0 -1
  376. package/dist/agents/middlewareAgent/middleware/llmToolSelector.js.map +0 -1
  377. package/dist/agents/middlewareAgent/middleware/modelFallback.cjs.map +0 -1
  378. package/dist/agents/middlewareAgent/middleware/modelFallback.d.cts.map +0 -1
  379. package/dist/agents/middlewareAgent/middleware/modelFallback.d.ts.map +0 -1
  380. package/dist/agents/middlewareAgent/middleware/modelFallback.js.map +0 -1
  381. package/dist/agents/middlewareAgent/middleware/piiRedaction.cjs.map +0 -1
  382. package/dist/agents/middlewareAgent/middleware/piiRedaction.d.cts.map +0 -1
  383. package/dist/agents/middlewareAgent/middleware/piiRedaction.d.ts.map +0 -1
  384. package/dist/agents/middlewareAgent/middleware/piiRedaction.js.map +0 -1
  385. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs.map +0 -1
  386. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts.map +0 -1
  387. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts.map +0 -1
  388. package/dist/agents/middlewareAgent/middleware/promptCaching.js.map +0 -1
  389. package/dist/agents/middlewareAgent/middleware/summarization.cjs.map +0 -1
  390. package/dist/agents/middlewareAgent/middleware/summarization.d.cts.map +0 -1
  391. package/dist/agents/middlewareAgent/middleware/summarization.d.ts.map +0 -1
  392. package/dist/agents/middlewareAgent/middleware/summarization.js.map +0 -1
  393. package/dist/agents/middlewareAgent/middleware/toolCallLimit.cjs.map +0 -1
  394. package/dist/agents/middlewareAgent/middleware/toolCallLimit.d.cts.map +0 -1
  395. package/dist/agents/middlewareAgent/middleware/toolCallLimit.d.ts.map +0 -1
  396. package/dist/agents/middlewareAgent/middleware/toolCallLimit.js.map +0 -1
  397. package/dist/agents/middlewareAgent/middleware/utils.cjs.map +0 -1
  398. package/dist/agents/middlewareAgent/middleware/utils.d.cts.map +0 -1
  399. package/dist/agents/middlewareAgent/middleware/utils.d.ts.map +0 -1
  400. package/dist/agents/middlewareAgent/middleware/utils.js.map +0 -1
  401. package/dist/agents/middlewareAgent/middleware.cjs.map +0 -1
  402. package/dist/agents/middlewareAgent/middleware.d.cts +0 -117
  403. package/dist/agents/middlewareAgent/middleware.d.cts.map +0 -1
  404. package/dist/agents/middlewareAgent/middleware.d.ts +0 -117
  405. package/dist/agents/middlewareAgent/middleware.d.ts.map +0 -1
  406. package/dist/agents/middlewareAgent/middleware.js.map +0 -1
  407. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs.map +0 -1
  408. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js.map +0 -1
  409. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs +0 -468
  410. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs.map +0 -1
  411. package/dist/agents/middlewareAgent/nodes/AgentNode.js +0 -467
  412. package/dist/agents/middlewareAgent/nodes/AgentNode.js.map +0 -1
  413. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs.map +0 -1
  414. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js.map +0 -1
  415. package/dist/agents/middlewareAgent/nodes/middleware.cjs.map +0 -1
  416. package/dist/agents/middlewareAgent/nodes/middleware.js.map +0 -1
  417. package/dist/agents/middlewareAgent/nodes/utils.cjs +0 -66
  418. package/dist/agents/middlewareAgent/nodes/utils.cjs.map +0 -1
  419. package/dist/agents/middlewareAgent/nodes/utils.js +0 -63
  420. package/dist/agents/middlewareAgent/nodes/utils.js.map +0 -1
  421. package/dist/agents/middlewareAgent/types.d.cts +0 -472
  422. package/dist/agents/middlewareAgent/types.d.cts.map +0 -1
  423. package/dist/agents/middlewareAgent/types.d.ts +0 -472
  424. package/dist/agents/middlewareAgent/types.d.ts.map +0 -1
  425. package/dist/agents/nodes/ToolNode.d.cts +0 -97
  426. package/dist/agents/nodes/ToolNode.d.cts.map +0 -1
  427. package/dist/agents/nodes/ToolNode.d.ts +0 -97
  428. package/dist/agents/nodes/ToolNode.d.ts.map +0 -1
  429. package/dist/agents/types.cjs +0 -7
  430. package/dist/agents/types.cjs.map +0 -1
  431. package/dist/agents/types.js +0 -6
  432. package/dist/agents/types.js.map +0 -1
  433. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/client.cjs.map +0 -1
  434. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/client.js.map +0 -1
  435. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/run_trees.cjs.map +0 -1
  436. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/run_trees.js.map +0 -1
  437. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/env.cjs.map +0 -1
  438. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/env.js.map +0 -1
  439. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/error.cjs.map +0 -1
  440. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/error.js.map +0 -1
  441. /package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/index.cjs +0 -0
  442. /package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.11.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/index.js +0 -0
@@ -1,340 +0,0 @@
1
- import { createMiddleware } from "../middleware.js";
2
- import { AIMessage, ToolMessage } from "@langchain/core/messages";
3
- import { interrupt } from "@langchain/langgraph";
4
- import { interopParse } from "@langchain/core/utils/types";
5
- import { z } from "zod/v3";
6
-
7
- //#region src/agents/middlewareAgent/middleware/hitl.ts
8
- const ToolConfigSchema = z.object({
9
- allowAccept: z.boolean().optional(),
10
- allowEdit: z.boolean().optional(),
11
- allowRespond: z.boolean().optional(),
12
- description: z.union([z.string(), z.function()]).optional()
13
- });
14
- const contextSchema = z.object({
15
- interruptOn: z.record(z.union([z.boolean(), ToolConfigSchema])).optional(),
16
- descriptionPrefix: z.string().default("Tool execution requires approval")
17
- });
18
- /**
19
- * Creates a Human-in-the-Loop (HITL) middleware for tool approval and oversight.
20
- *
21
- * This middleware intercepts tool calls made by an AI agent and provides human oversight
22
- * capabilities before execution. It enables selective approval workflows where certain tools
23
- * require human intervention while others can execute automatically.
24
- *
25
- * A invocation result that has been interrupted by the middleware will have a `__interrupt__`
26
- * property that contains the interrupt request. You can loop over the request to determine
27
- * which tools were interrupted, and how to handle them separately.
28
- *
29
- * ```ts
30
- * import { type ToolApprovalRequest, type HumanInTheLoopMiddlewareHumanResponse } from "langchain";
31
- * import { type Interrupt } from "langchain";
32
- *
33
- * const result = await agent.invoke(request);
34
- * const interruptRequest = initialResult.__interrupt__?.[0] as Interrupt<
35
- * ToolApprovalRequest[]
36
- * >;
37
- * const resume: HumanInTheLoopMiddlewareHumanResponse[] =
38
- * interruptRequest.value.map((request) => {
39
- * if (request.action === "calculator") {
40
- * return { id: request.toolCallId, type: "accept" };
41
- * } else if (request.action === "write_file") {
42
- * return {
43
- * id: request.toolCallId,
44
- * type: "edit",
45
- * args: { filename: "safe.txt", content: "Safe content" },
46
- * };
47
- * }
48
- *
49
- * throw new Error(`Unknown action: ${request.action}`);
50
- * });
51
- *
52
- * // Resume with approval
53
- * await agent.invoke(new Command({ resume }), config);
54
- * ```
55
- *
56
- * ## Features
57
- *
58
- * - **Selective Tool Approval**: Configure which tools require human approval
59
- * - **Multiple Response Types**: Accept, edit, ignore, or manually respond to tool calls
60
- * - **Asynchronous Workflow**: Uses LangGraph's interrupt mechanism for non-blocking approval
61
- * - **Custom Approval Messages**: Provide context-specific descriptions for approval requests
62
- *
63
- * ## Response Types
64
- *
65
- * When a tool requires approval, the human operator can respond with:
66
- * - `accept`: Execute the tool with original arguments
67
- * - `edit`: Modify the tool arguments before execution
68
- * - `ignore`: Skip the tool and terminate the agent
69
- * - `response`: Provide a manual response instead of executing the tool
70
- *
71
- * @param options - Configuration options for the middleware
72
- * @param options.interruptOn - Per-tool configuration mapping tool names to their settings
73
- * @param options.interruptOn[toolName].allowAccept - Whether the human can approve the current action without changes
74
- * @param options.interruptOn[toolName].allowEdit - Whether the human can reject the current action with feedback
75
- * @param options.interruptOn[toolName].allowRespond - Whether the human can approve the current action with edited content
76
- * @param options.interruptOn[toolName].description - Custom approval message for the tool. Can be either a static string or a callable that dynamically generates the description based on agent state, runtime, and tool call information
77
- * @param options.messagePrefix - Default prefix for approval messages (default: "Tool execution requires approval"). Only used for tools that do not define a custom `description` in their ToolConfig.
78
- *
79
- * @returns A middleware instance that can be passed to `createAgent`
80
- *
81
- * @example
82
- * Basic usage with selective tool approval
83
- * ```typescript
84
- * import { humanInTheLoopMiddleware } from "langchain";
85
- * import { createAgent } from "langchain";
86
- *
87
- * const hitlMiddleware = humanInTheLoopMiddleware({
88
- * interruptOn: {
89
- * // Interrupt write_file tool and allow edits or accepts
90
- * "write_file": {
91
- * allowEdit: true,
92
- * allowAccept: true,
93
- * description: "⚠️ File write operation requires approval"
94
- * },
95
- * // Auto-approve read_file tool
96
- * "read_file": false
97
- * }
98
- * });
99
- *
100
- * const agent = createAgent({
101
- * model: "openai:gpt-4",
102
- * tools: [writeFileTool, readFileTool],
103
- * middleware: [hitlMiddleware]
104
- * });
105
- * ```
106
- *
107
- * @example
108
- * Handling approval requests
109
- * ```typescript
110
- * import { type HumanInTheLoopRequest, type Interrupt } from "langchain";
111
- * import { Command } from "@langchain/langgraph";
112
- *
113
- * // Initial agent invocation
114
- * const result = await agent.invoke({
115
- * messages: [new HumanMessage("Write 'Hello' to output.txt")]
116
- * }, config);
117
- *
118
- * // Check if agent is paused for approval
119
- * if (result.__interrupt__) {
120
- * const interruptRequest = initialResult.__interrupt__?.[0] as Interrupt<
121
- * HumanInTheLoopRequest[]
122
- * >;
123
- *
124
- * // Show tool call details to user
125
- * console.log("Tool:", interruptRequest.value[0].actionRequest);
126
- * console.log("Allowed actions:", interruptRequest.value[0].config);
127
- *
128
- * // Resume with approval
129
- * await agent.invoke(
130
- * new Command({ resume: [{ type: "accept" }] }),
131
- * config
132
- * );
133
- * }
134
- * ```
135
- *
136
- * @example
137
- * Different response types
138
- * ```typescript
139
- * // Accept the tool call as-is
140
- * new Command({ resume: [{ type: "accept" }] })
141
- *
142
- * // Edit the tool arguments
143
- * new Command({
144
- * resume: [{
145
- * type: "edit",
146
- * args: { action: "write_file", args: { filename: "safe.txt", content: "Modified" } }
147
- * }]
148
- * })
149
- *
150
- * // Skip tool and terminate agent
151
- * new Command({ resume: [{ type: "response" }] })
152
- *
153
- * // Provide manual response
154
- * new Command({
155
- * resume: [{
156
- * type: "response",
157
- * // this must be a string
158
- * args: "File operation not allowed in demo mode"
159
- * }]
160
- * })
161
- * ```
162
- *
163
- * @example
164
- * Production use case with database operations
165
- * ```typescript
166
- * const hitlMiddleware = humanInTheLoopMiddleware({
167
- * interruptOn: {
168
- * "execute_sql": {
169
- * allowAccept: true,
170
- * allowEdit: true,
171
- * allowRespond: true,
172
- * description: "🚨 SQL query requires DBA approval\nPlease review for safety and performance"
173
- * },
174
- * "read_schema": false // Reading metadata is safe
175
- * "delete_records": {
176
- * allowAccept: true,
177
- * description: "⛔ DESTRUCTIVE OPERATION - Requires manager approval"
178
- * }
179
- * },
180
- * messagePrefix: "Database operation pending approval"
181
- * });
182
- * ```
183
- *
184
- * @example
185
- * Using dynamic callable descriptions
186
- * ```typescript
187
- * import { type DescriptionFactory } from "langchain";
188
- *
189
- * // Define a dynamic description factory
190
- * const formatToolDescription: DescriptionFactory = (toolCall, state, runtime) => {
191
- * return `Tool: ${toolCall.name}\nArguments:\n${JSON.stringify(toolCall.args, null, 2)}`;
192
- * };
193
- *
194
- * const hitlMiddleware = humanInTheLoopMiddleware({
195
- * interruptOn: {
196
- * "write_file": {
197
- * allowAccept: true,
198
- * allowEdit: true,
199
- * // Use dynamic description that can access tool call, state, and runtime
200
- * description: formatToolDescription
201
- * },
202
- * // Or use an inline function
203
- * "send_email": {
204
- * allowAccept: true,
205
- * description: (toolCall, state, runtime) => {
206
- * const { to, subject } = toolCall.args;
207
- * return `Email to ${to}\nSubject: ${subject}\n\nRequires approval before sending`;
208
- * }
209
- * }
210
- * }
211
- * });
212
- * ```
213
- *
214
- * @remarks
215
- * - Tool calls are processed in the order they appear in the AI message
216
- * - Auto-approved tools execute immediately without interruption
217
- * - Multiple tools requiring approval are bundled into a single interrupt
218
- * - The middleware operates in the `afterModel` phase, intercepting before tool execution
219
- * - Requires a checkpointer to maintain state across interruptions
220
- *
221
- * @see {@link createAgent} for agent creation
222
- * @see {@link Command} for resuming interrupted execution
223
- * @public
224
- */
225
- function humanInTheLoopMiddleware(options) {
226
- return createMiddleware({
227
- name: "HumanInTheLoopMiddleware",
228
- contextSchema,
229
- afterModelJumpTo: ["model"],
230
- afterModel: async (state, runtime) => {
231
- const config = interopParse(contextSchema, {
232
- ...options,
233
- ...runtime.context || {}
234
- });
235
- if (!config) return;
236
- const { messages } = state;
237
- if (!messages.length) return;
238
- /**
239
- * Don't do anything if the last message isn't an AI message with tool calls.
240
- */
241
- const lastMessage = [...messages].reverse().find((msg) => AIMessage.isInstance(msg));
242
- if (!lastMessage || !lastMessage.tool_calls?.length) return;
243
- /**
244
- * If the user omits the interruptOn config, we don't do anything.
245
- */
246
- if (!config.interruptOn) return;
247
- const resolvedToolConfigs = {};
248
- for (const [toolName, toolConfig] of Object.entries(config.interruptOn)) if (typeof toolConfig === "boolean") {
249
- if (toolConfig === true) resolvedToolConfigs[toolName] = {
250
- allowAccept: true,
251
- allowEdit: true,
252
- allowRespond: true
253
- };
254
- } else resolvedToolConfigs[toolName] = toolConfig;
255
- const interruptToolCalls = [];
256
- const autoApprovedToolCalls = [];
257
- for (const toolCall of lastMessage.tool_calls) if (toolCall.name in resolvedToolConfigs) interruptToolCalls.push(toolCall);
258
- else autoApprovedToolCalls.push(toolCall);
259
- /**
260
- * No interrupt tool calls, so we can just return.
261
- */
262
- if (!interruptToolCalls.length) return;
263
- const hitlRequests = await Promise.all(interruptToolCalls.map(async (toolCall) => {
264
- const toolConfig = resolvedToolConfigs[toolCall.name];
265
- const description = toolConfig.description ? typeof toolConfig.description === "function" ? await toolConfig.description(toolCall, state, runtime) : toolConfig.description : `${config.descriptionPrefix}\n\nTool: ${toolCall.name}\nArgs: ${JSON.stringify(toolCall.args, null, 2)}`;
266
- return {
267
- actionRequest: {
268
- action: toolCall.name,
269
- args: toolCall.args
270
- },
271
- config: toolConfig,
272
- description
273
- };
274
- }));
275
- const responses = await interrupt(hitlRequests);
276
- if (responses.length !== interruptToolCalls.length) throw new Error(`Number of human responses (${responses.length}) does not match number of hanging tool calls (${interruptToolCalls.length}).`);
277
- const approvedToolCalls = [...autoApprovedToolCalls];
278
- const artificialToolMessages = [];
279
- for (const [i, response] of responses.entries()) {
280
- const toolCall = interruptToolCalls[i];
281
- const toolConfig = resolvedToolConfigs[toolCall.name];
282
- if (response.type === "accept" && toolConfig?.allowAccept) {
283
- approvedToolCalls.push(toolCall);
284
- continue;
285
- }
286
- if (response.type === "edit" && toolConfig?.allowEdit) {
287
- const edited = response.args;
288
- approvedToolCalls.push({
289
- id: toolCall.id,
290
- name: edited.action,
291
- args: edited.args
292
- });
293
- continue;
294
- }
295
- if (response.type === "response" && toolConfig?.allowRespond) {
296
- const content = response.args ?? `User rejected the tool call for \`${toolCall.name}\` with id ${toolCall.id}`;
297
- /**
298
- * Providing a meaningful error message for this case that should never happen.
299
- */
300
- if (!toolCall.id) throw new Error(`Can't provide custom tool response for tool call without an ID: ${toolCall.name}!\nThis use case is not expected to happen, please report this as a bug.`);
301
- /**
302
- * ToolMessage expects a string, so we need to throw an error if it's not a string
303
- * as we currently have no way to proper type responses from users through the
304
- * Command object.
305
- */
306
- if (typeof content !== "string") throw new Error(`Tool call response for "${toolCall.name}" must be a string, got ${typeof content}`);
307
- artificialToolMessages.push(new ToolMessage({
308
- content,
309
- name: toolCall.name,
310
- tool_call_id: toolCall.id,
311
- status: "error"
312
- }));
313
- continue;
314
- }
315
- const allowedActions = [
316
- toolConfig?.allowAccept && "accept",
317
- toolConfig?.allowEdit && "edit",
318
- toolConfig?.allowRespond && "response"
319
- ].filter(Boolean).join("\", \"");
320
- throw new Error(`Unexpected human response: ${JSON.stringify(response)}. Response action '${response.type}' is not allowed for tool '${toolCall.name}'. Expected one of: "${allowedActions}", based on the tool's configuration.`);
321
- }
322
- /**
323
- * Replace the tool calls with the approved tool calls
324
- */
325
- if (AIMessage.isInstance(lastMessage)) lastMessage.tool_calls = lastMessage.tool_calls?.map((tc) => {
326
- const approvedToolCall = approvedToolCalls.find((atc) => atc.id === tc.id);
327
- return approvedToolCall ?? tc;
328
- });
329
- if (approvedToolCalls.length > 0) return { messages: [...state.messages, ...artificialToolMessages] };
330
- return {
331
- jumpTo: "model",
332
- messages: [...state.messages, ...artificialToolMessages]
333
- };
334
- }
335
- });
336
- }
337
-
338
- //#endregion
339
- export { humanInTheLoopMiddleware };
340
- //# sourceMappingURL=hitl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hitl.js","names":["options: NonNullable<HumanInTheLoopMiddlewareConfig>","resolvedToolConfigs: Record<string, ToolConfig>","interruptToolCalls: ToolCall[]","autoApprovedToolCalls: ToolCall[]","hitlRequests: HumanInTheLoopRequest[]","approvedToolCalls: ToolCall[]","artificialToolMessages: ToolMessage[]"],"sources":["../../../../src/agents/middlewareAgent/middleware/hitl.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { AIMessage, ToolMessage } from \"@langchain/core/messages\";\nimport {\n InferInteropZodInput,\n interopParse,\n} from \"@langchain/core/utils/types\";\nimport { interrupt } from \"@langchain/langgraph\";\n\nimport { createMiddleware } from \"../middleware.js\";\nimport type { AgentBuiltInState, Runtime } from \"../types.js\";\n\nconst ToolConfigSchema = z.object({\n /**\n * Whether the human can approve the current action without changes\n */\n allowAccept: z.boolean().optional(),\n /**\n * Whether the human can reject the current action with feedback\n */\n allowEdit: z.boolean().optional(),\n /**\n * Whether the human can approve the current action with edited content\n */\n allowRespond: z.boolean().optional(),\n /**\n * The description attached to the request for human input.\n * Can be either:\n * - A static string describing the approval request\n * - A callable that dynamically generates the description based on agent state,\n * runtime, and tool call information\n *\n * @example\n * Static string description\n * ```typescript\n * const config: ToolConfig = {\n * allowAccept: true,\n * description: \"Please review this tool execution\"\n * };\n * ```\n *\n * @example\n * Dynamic callable description\n * ```typescript\n * const formatToolDescription: DescriptionFactory = (toolCall, state, runtime) => {\n * return `Tool: ${toolCall.name}\\nArguments:\\n${JSON.stringify(toolCall.args, null, 2)}`;\n * };\n *\n * const config: ToolConfig = {\n * allowAccept: true,\n * description: formatToolDescription\n * };\n * ```\n */\n description: z.union([z.string(), z.function()]).optional(),\n});\n\ntype ToolConfigSchema = z.input<typeof ToolConfigSchema>;\ntype ToolCall = NonNullable<AIMessage[\"tool_calls\"]>[number];\n\n/**\n * Function type that dynamically generates a description based on agent state,\n * runtime, and tool call information.\n */\nexport type DescriptionFactory<\n State extends AgentBuiltInState = AgentBuiltInState\n> = (\n toolCall: ToolCall,\n state: State,\n runtime: Runtime<unknown>\n) => string | Promise<string>;\n\n/**\n * Configuration that defines which reviewer response types are permitted during a human interrupt.\n * These flags control what the human reviewer may do (e.g., accept/edit/respond),\n * not the tool action the agent has requested.\n */\nexport interface HumanInTheLoopConfig\n extends Omit<ToolConfigSchema, \"description\"> {}\n\n/**\n * Describes the agent-requested tool action (name and arguments).\n * This is what the AI intends to execute, subject to human review.\n */\nexport interface ActionRequest {\n /**\n * The tool/action name requested by the agent (e.g., \"send_email\").\n */\n action: string;\n /**\n * Arguments for the requested tool call (e.g., {\"a\": 1, \"b\": 2}).\n */\n args: Record<string, any>;\n}\n\n/**\n * Represents an interrupt triggered by the graph that requires human intervention\n * to approve, edit, or respond to an agent-requested tool action.\n *\n * @example\n * ```ts\n * const hitlRequest: HumanInTheLoopRequest = {\n * actionRequest: { action: \"Approve XYZ action\", args: { ... } },\n * config: { allowAccept: true, allowEdit: true, allowRespond: true },\n * description: \"Please review the command before execution\"\n * };\n * response = interrupt([request])[0]\n * ```\n */\nexport interface HumanInTheLoopRequest {\n /**\n * The agent-requested tool action to be reviewed.\n */\n actionRequest: ActionRequest;\n /**\n * Which reviewer responses are allowed (accept/edit/respond).\n */\n config: HumanInTheLoopConfig;\n /**\n * Optional human-facing description shown in the approval prompt.\n */\n description?: string;\n}\n\n/**\n * Response when a human approves the agent-requested action.\n */\nexport interface AcceptPayload {\n type: \"accept\";\n}\n\n/**\n * Response when a human provides a manual response instead of executing\n * the agent-requested action.\n */\nexport interface ResponsePayload {\n type: \"response\";\n args?: string;\n}\n\n/**\n * Response when a human edits the agent-requested action (tool name and/or args).\n */\nexport interface EditPayload {\n type: \"edit\";\n args: ActionRequest;\n}\n\nexport type HumanInTheLoopMiddlewareHumanResponse =\n | AcceptPayload\n | ResponsePayload\n | EditPayload;\n\n/**\n * Configuration for a tool requiring human in the loop.\n */\nexport interface ToolConfig extends HumanInTheLoopConfig {\n /**\n * Human-facing description shown in the approval request.\n * Can be either:\n * - A static string describing the approval request\n * - A callable that dynamically generates the description based on agent state,\n * runtime, and tool call information\n */\n description?: string | DescriptionFactory;\n}\n\nconst contextSchema = z.object({\n /**\n * Mapping of tool name to allowed reviewer responses.\n * If a tool doesn't have an entry, it's auto-approved by default.\n *\n * - `true` -> pause for approval and allow accept/edit/respond\n * - `false` -> auto-approve (no human review)\n * - `ToolConfig` -> explicitly specify which reviewer responses are allowed for this tool\n */\n interruptOn: z.record(z.union([z.boolean(), ToolConfigSchema])).optional(),\n /**\n * Prefix used when constructing human-facing approval messages.\n * Provides context about the tool call being reviewed; does not change the underlying action.\n *\n * Note: This prefix is only applied for tools that do not provide a custom\n * `description` via their {@link ToolConfig}. If a tool specifies a custom\n * `description`, that per-tool text is used and this prefix is ignored.\n */\n descriptionPrefix: z.string().default(\"Tool execution requires approval\"),\n});\nexport type HumanInTheLoopMiddlewareConfig = InferInteropZodInput<\n typeof contextSchema\n>;\n\n/**\n * Creates a Human-in-the-Loop (HITL) middleware for tool approval and oversight.\n *\n * This middleware intercepts tool calls made by an AI agent and provides human oversight\n * capabilities before execution. It enables selective approval workflows where certain tools\n * require human intervention while others can execute automatically.\n *\n * A invocation result that has been interrupted by the middleware will have a `__interrupt__`\n * property that contains the interrupt request. You can loop over the request to determine\n * which tools were interrupted, and how to handle them separately.\n *\n * ```ts\n * import { type ToolApprovalRequest, type HumanInTheLoopMiddlewareHumanResponse } from \"langchain\";\n * import { type Interrupt } from \"langchain\";\n *\n * const result = await agent.invoke(request);\n * const interruptRequest = initialResult.__interrupt__?.[0] as Interrupt<\n * ToolApprovalRequest[]\n * >;\n * const resume: HumanInTheLoopMiddlewareHumanResponse[] =\n * interruptRequest.value.map((request) => {\n * if (request.action === \"calculator\") {\n * return { id: request.toolCallId, type: \"accept\" };\n * } else if (request.action === \"write_file\") {\n * return {\n * id: request.toolCallId,\n * type: \"edit\",\n * args: { filename: \"safe.txt\", content: \"Safe content\" },\n * };\n * }\n *\n * throw new Error(`Unknown action: ${request.action}`);\n * });\n *\n * // Resume with approval\n * await agent.invoke(new Command({ resume }), config);\n * ```\n *\n * ## Features\n *\n * - **Selective Tool Approval**: Configure which tools require human approval\n * - **Multiple Response Types**: Accept, edit, ignore, or manually respond to tool calls\n * - **Asynchronous Workflow**: Uses LangGraph's interrupt mechanism for non-blocking approval\n * - **Custom Approval Messages**: Provide context-specific descriptions for approval requests\n *\n * ## Response Types\n *\n * When a tool requires approval, the human operator can respond with:\n * - `accept`: Execute the tool with original arguments\n * - `edit`: Modify the tool arguments before execution\n * - `ignore`: Skip the tool and terminate the agent\n * - `response`: Provide a manual response instead of executing the tool\n *\n * @param options - Configuration options for the middleware\n * @param options.interruptOn - Per-tool configuration mapping tool names to their settings\n * @param options.interruptOn[toolName].allowAccept - Whether the human can approve the current action without changes\n * @param options.interruptOn[toolName].allowEdit - Whether the human can reject the current action with feedback\n * @param options.interruptOn[toolName].allowRespond - Whether the human can approve the current action with edited content\n * @param options.interruptOn[toolName].description - Custom approval message for the tool. Can be either a static string or a callable that dynamically generates the description based on agent state, runtime, and tool call information\n * @param options.messagePrefix - Default prefix for approval messages (default: \"Tool execution requires approval\"). Only used for tools that do not define a custom `description` in their ToolConfig.\n *\n * @returns A middleware instance that can be passed to `createAgent`\n *\n * @example\n * Basic usage with selective tool approval\n * ```typescript\n * import { humanInTheLoopMiddleware } from \"langchain\";\n * import { createAgent } from \"langchain\";\n *\n * const hitlMiddleware = humanInTheLoopMiddleware({\n * interruptOn: {\n * // Interrupt write_file tool and allow edits or accepts\n * \"write_file\": {\n * allowEdit: true,\n * allowAccept: true,\n * description: \"⚠️ File write operation requires approval\"\n * },\n * // Auto-approve read_file tool\n * \"read_file\": false\n * }\n * });\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4\",\n * tools: [writeFileTool, readFileTool],\n * middleware: [hitlMiddleware]\n * });\n * ```\n *\n * @example\n * Handling approval requests\n * ```typescript\n * import { type HumanInTheLoopRequest, type Interrupt } from \"langchain\";\n * import { Command } from \"@langchain/langgraph\";\n *\n * // Initial agent invocation\n * const result = await agent.invoke({\n * messages: [new HumanMessage(\"Write 'Hello' to output.txt\")]\n * }, config);\n *\n * // Check if agent is paused for approval\n * if (result.__interrupt__) {\n * const interruptRequest = initialResult.__interrupt__?.[0] as Interrupt<\n * HumanInTheLoopRequest[]\n * >;\n *\n * // Show tool call details to user\n * console.log(\"Tool:\", interruptRequest.value[0].actionRequest);\n * console.log(\"Allowed actions:\", interruptRequest.value[0].config);\n *\n * // Resume with approval\n * await agent.invoke(\n * new Command({ resume: [{ type: \"accept\" }] }),\n * config\n * );\n * }\n * ```\n *\n * @example\n * Different response types\n * ```typescript\n * // Accept the tool call as-is\n * new Command({ resume: [{ type: \"accept\" }] })\n *\n * // Edit the tool arguments\n * new Command({\n * resume: [{\n * type: \"edit\",\n * args: { action: \"write_file\", args: { filename: \"safe.txt\", content: \"Modified\" } }\n * }]\n * })\n *\n * // Skip tool and terminate agent\n * new Command({ resume: [{ type: \"response\" }] })\n *\n * // Provide manual response\n * new Command({\n * resume: [{\n * type: \"response\",\n * // this must be a string\n * args: \"File operation not allowed in demo mode\"\n * }]\n * })\n * ```\n *\n * @example\n * Production use case with database operations\n * ```typescript\n * const hitlMiddleware = humanInTheLoopMiddleware({\n * interruptOn: {\n * \"execute_sql\": {\n * allowAccept: true,\n * allowEdit: true,\n * allowRespond: true,\n * description: \"🚨 SQL query requires DBA approval\\nPlease review for safety and performance\"\n * },\n * \"read_schema\": false // Reading metadata is safe\n * \"delete_records\": {\n * allowAccept: true,\n * description: \"⛔ DESTRUCTIVE OPERATION - Requires manager approval\"\n * }\n * },\n * messagePrefix: \"Database operation pending approval\"\n * });\n * ```\n *\n * @example\n * Using dynamic callable descriptions\n * ```typescript\n * import { type DescriptionFactory } from \"langchain\";\n *\n * // Define a dynamic description factory\n * const formatToolDescription: DescriptionFactory = (toolCall, state, runtime) => {\n * return `Tool: ${toolCall.name}\\nArguments:\\n${JSON.stringify(toolCall.args, null, 2)}`;\n * };\n *\n * const hitlMiddleware = humanInTheLoopMiddleware({\n * interruptOn: {\n * \"write_file\": {\n * allowAccept: true,\n * allowEdit: true,\n * // Use dynamic description that can access tool call, state, and runtime\n * description: formatToolDescription\n * },\n * // Or use an inline function\n * \"send_email\": {\n * allowAccept: true,\n * description: (toolCall, state, runtime) => {\n * const { to, subject } = toolCall.args;\n * return `Email to ${to}\\nSubject: ${subject}\\n\\nRequires approval before sending`;\n * }\n * }\n * }\n * });\n * ```\n *\n * @remarks\n * - Tool calls are processed in the order they appear in the AI message\n * - Auto-approved tools execute immediately without interruption\n * - Multiple tools requiring approval are bundled into a single interrupt\n * - The middleware operates in the `afterModel` phase, intercepting before tool execution\n * - Requires a checkpointer to maintain state across interruptions\n *\n * @see {@link createAgent} for agent creation\n * @see {@link Command} for resuming interrupted execution\n * @public\n */\nexport function humanInTheLoopMiddleware(\n options: NonNullable<HumanInTheLoopMiddlewareConfig>\n) {\n return createMiddleware({\n name: \"HumanInTheLoopMiddleware\",\n contextSchema,\n afterModelJumpTo: [\"model\"],\n afterModel: async (state, runtime) => {\n const config = interopParse(contextSchema, {\n ...options,\n ...(runtime.context || {}),\n });\n if (!config) {\n return;\n }\n\n const { messages } = state;\n if (!messages.length) {\n return;\n }\n\n /**\n * Don't do anything if the last message isn't an AI message with tool calls.\n */\n const lastMessage = [...messages]\n .reverse()\n .find((msg) => AIMessage.isInstance(msg)) as AIMessage;\n if (!lastMessage || !lastMessage.tool_calls?.length) {\n return;\n }\n\n /**\n * If the user omits the interruptOn config, we don't do anything.\n */\n if (!config.interruptOn) {\n return;\n }\n\n // Resolve per-tool configs (boolean true -> all actions allowed; false -> auto-approve)\n const resolvedToolConfigs: Record<string, ToolConfig> = {};\n for (const [toolName, toolConfig] of Object.entries(config.interruptOn)) {\n if (typeof toolConfig === \"boolean\") {\n if (toolConfig === true) {\n resolvedToolConfigs[toolName] = {\n allowAccept: true,\n allowEdit: true,\n allowRespond: true,\n };\n }\n } else {\n resolvedToolConfigs[toolName] = toolConfig as ToolConfig;\n }\n }\n\n const interruptToolCalls: ToolCall[] = [];\n const autoApprovedToolCalls: ToolCall[] = [];\n\n for (const toolCall of lastMessage.tool_calls) {\n if (toolCall.name in resolvedToolConfigs) {\n interruptToolCalls.push(toolCall);\n } else {\n autoApprovedToolCalls.push(toolCall);\n }\n }\n\n /**\n * No interrupt tool calls, so we can just return.\n */\n if (!interruptToolCalls.length) {\n return;\n }\n\n const hitlRequests: HumanInTheLoopRequest[] = await Promise.all(\n interruptToolCalls.map(async (toolCall) => {\n const toolConfig = resolvedToolConfigs[toolCall.name]!;\n const description = toolConfig.description\n ? typeof toolConfig.description === \"function\"\n ? /**\n * If description is a function, call it with the required parameters\n */\n await toolConfig.description(toolCall, state, runtime)\n : /**\n * Otherwise, use the static string\n */\n toolConfig.description\n : /**\n * Fall back to the default description\n */\n `${config.descriptionPrefix}\\n\\nTool: ${\n toolCall.name\n }\\nArgs: ${JSON.stringify(toolCall.args, null, 2)}`;\n\n return {\n actionRequest: { action: toolCall.name, args: toolCall.args },\n config: toolConfig,\n description,\n };\n })\n );\n\n const responses = (await interrupt(\n hitlRequests\n )) as HumanInTheLoopMiddlewareHumanResponse[];\n\n if (responses.length !== interruptToolCalls.length) {\n throw new Error(\n `Number of human responses (${responses.length}) does not match number of hanging tool calls (${interruptToolCalls.length}).`\n );\n }\n\n const approvedToolCalls: ToolCall[] = [...autoApprovedToolCalls];\n const artificialToolMessages: ToolMessage[] = [];\n\n for (const [i, response] of responses.entries()) {\n const toolCall = interruptToolCalls[i]!;\n const toolConfig = resolvedToolConfigs[toolCall.name]!;\n\n if (response.type === \"accept\" && toolConfig?.allowAccept) {\n approvedToolCalls.push(toolCall);\n continue;\n }\n\n if (response.type === \"edit\" && toolConfig?.allowEdit) {\n const edited = response.args;\n approvedToolCalls.push({\n id: toolCall.id,\n name: edited.action,\n args: edited.args,\n });\n continue;\n }\n\n if (response.type === \"response\" && toolConfig?.allowRespond) {\n const content =\n response.args ??\n `User rejected the tool call for \\`${toolCall.name}\\` with id ${toolCall.id}`;\n\n /**\n * Providing a meaningful error message for this case that should never happen.\n */\n if (!toolCall.id) {\n throw new Error(\n `Can't provide custom tool response for tool call without an ID: ${toolCall.name}!\\n` +\n \"This use case is not expected to happen, please report this as a bug.\"\n );\n }\n\n /**\n * ToolMessage expects a string, so we need to throw an error if it's not a string\n * as we currently have no way to proper type responses from users through the\n * Command object.\n */\n if (typeof content !== \"string\") {\n throw new Error(\n `Tool call response for \"${\n toolCall.name\n }\" must be a string, got ${typeof content}`\n );\n }\n\n artificialToolMessages.push(\n new ToolMessage({\n content,\n name: toolCall.name,\n tool_call_id: toolCall.id,\n status: \"error\",\n })\n );\n continue;\n }\n\n const allowedActions = [\n toolConfig?.allowAccept && \"accept\",\n toolConfig?.allowEdit && \"edit\",\n toolConfig?.allowRespond && \"response\",\n ]\n .filter(Boolean)\n .join('\", \"');\n throw new Error(\n `Unexpected human response: ${JSON.stringify(\n response\n )}. Response action '${response.type}' is not allowed for tool '${\n toolCall.name\n }'. Expected one of: \"${allowedActions}\", based on the tool's configuration.`\n );\n }\n\n /**\n * Replace the tool calls with the approved tool calls\n */\n if (AIMessage.isInstance(lastMessage)) {\n lastMessage.tool_calls = lastMessage.tool_calls?.map((tc) => {\n const approvedToolCall = approvedToolCalls.find(\n (atc) => atc.id === tc.id\n );\n return approvedToolCall ?? tc;\n });\n }\n\n if (approvedToolCalls.length > 0) {\n return { messages: [...state.messages, ...artificialToolMessages] };\n }\n\n return {\n jumpTo: \"model\",\n messages: [...state.messages, ...artificialToolMessages],\n };\n },\n });\n}\n"],"mappings":"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"}
@@ -1,52 +0,0 @@
1
- const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
- const require_utils = require('./utils.cjs');
3
- const require_summarization = require('./summarization.cjs');
4
- const require_hitl = require('./hitl.cjs');
5
- const require_promptCaching = require('./promptCaching.cjs');
6
- const require_dynamicSystemPrompt = require('./dynamicSystemPrompt.cjs');
7
- const require_llmToolSelector = require('./llmToolSelector.cjs');
8
- const require_piiRedaction = require('./piiRedaction.cjs');
9
- const require_contextEditing = require('./contextEditing.cjs');
10
- const require_toolCallLimit = require('./toolCallLimit.cjs');
11
- const require_callLimit = require('./callLimit.cjs');
12
- const require_modelFallback = require('./modelFallback.cjs');
13
-
14
- //#region src/agents/middlewareAgent/middleware/index.ts
15
- var middleware_exports = {};
16
- require_rolldown_runtime.__export(middleware_exports, {
17
- ClearToolUsesEdit: () => require_contextEditing.ClearToolUsesEdit,
18
- ToolCallLimitExceededError: () => require_toolCallLimit.ToolCallLimitExceededError,
19
- anthropicPromptCachingMiddleware: () => require_promptCaching.anthropicPromptCachingMiddleware,
20
- contextEditingMiddleware: () => require_contextEditing.contextEditingMiddleware,
21
- countTokensApproximately: () => require_utils.countTokensApproximately,
22
- dynamicSystemPromptMiddleware: () => require_dynamicSystemPrompt.dynamicSystemPromptMiddleware,
23
- humanInTheLoopMiddleware: () => require_hitl.humanInTheLoopMiddleware,
24
- llmToolSelectorMiddleware: () => require_llmToolSelector.llmToolSelectorMiddleware,
25
- modelCallLimitMiddleware: () => require_callLimit.modelCallLimitMiddleware,
26
- modelFallbackMiddleware: () => require_modelFallback.modelFallbackMiddleware,
27
- piiRedactionMiddleware: () => require_piiRedaction.piiRedactionMiddleware,
28
- summarizationMiddleware: () => require_summarization.summarizationMiddleware,
29
- toolCallLimitMiddleware: () => require_toolCallLimit.toolCallLimitMiddleware
30
- });
31
-
32
- //#endregion
33
- exports.ClearToolUsesEdit = require_contextEditing.ClearToolUsesEdit;
34
- exports.ToolCallLimitExceededError = require_toolCallLimit.ToolCallLimitExceededError;
35
- exports.anthropicPromptCachingMiddleware = require_promptCaching.anthropicPromptCachingMiddleware;
36
- exports.contextEditingMiddleware = require_contextEditing.contextEditingMiddleware;
37
- exports.countTokensApproximately = require_utils.countTokensApproximately;
38
- exports.dynamicSystemPromptMiddleware = require_dynamicSystemPrompt.dynamicSystemPromptMiddleware;
39
- exports.humanInTheLoopMiddleware = require_hitl.humanInTheLoopMiddleware;
40
- exports.llmToolSelectorMiddleware = require_llmToolSelector.llmToolSelectorMiddleware;
41
- Object.defineProperty(exports, 'middleware_exports', {
42
- enumerable: true,
43
- get: function () {
44
- return middleware_exports;
45
- }
46
- });
47
- exports.modelCallLimitMiddleware = require_callLimit.modelCallLimitMiddleware;
48
- exports.modelFallbackMiddleware = require_modelFallback.modelFallbackMiddleware;
49
- exports.piiRedactionMiddleware = require_piiRedaction.piiRedactionMiddleware;
50
- exports.summarizationMiddleware = require_summarization.summarizationMiddleware;
51
- exports.toolCallLimitMiddleware = require_toolCallLimit.toolCallLimitMiddleware;
52
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../../../src/agents/middlewareAgent/middleware/index.ts"],"sourcesContent":["export {\n summarizationMiddleware,\n type SummarizationMiddlewareConfig,\n} from \"./summarization.js\";\nexport {\n humanInTheLoopMiddleware,\n type HumanInTheLoopRequest,\n type HumanInTheLoopMiddlewareHumanResponse,\n type HumanInTheLoopMiddlewareConfig,\n type ActionRequest,\n} from \"./hitl.js\";\nexport {\n anthropicPromptCachingMiddleware,\n type PromptCachingMiddlewareConfig,\n} from \"./promptCaching.js\";\nexport {\n dynamicSystemPromptMiddleware,\n type DynamicSystemPromptMiddlewareConfig,\n} from \"./dynamicSystemPrompt.js\";\nexport {\n llmToolSelectorMiddleware,\n type LLMToolSelectorConfig,\n} from \"./llmToolSelector.js\";\nexport {\n piiRedactionMiddleware,\n type PIIRedactionMiddlewareConfig,\n} from \"./piiRedaction.js\";\nexport {\n contextEditingMiddleware,\n ClearToolUsesEdit,\n type ContextEditingMiddlewareConfig,\n type ContextEdit,\n type ClearToolUsesEditConfig,\n type TokenCounter,\n} from \"./contextEditing.js\";\nexport {\n toolCallLimitMiddleware,\n ToolCallLimitExceededError,\n type ToolCallLimitConfig,\n} from \"./toolCallLimit.js\";\nexport {\n modelCallLimitMiddleware,\n type ModelCallLimitMiddlewareConfig,\n} from \"./callLimit.js\";\nexport { modelFallbackMiddleware } from \"./modelFallback.js\";\nexport { type AgentMiddleware } from \"../types.js\";\nexport { countTokensApproximately } from \"./utils.js\";\n"],"mappings":""}
@@ -1,13 +0,0 @@
1
- import { SummarizationMiddlewareConfig, summarizationMiddleware } from "./summarization.cjs";
2
- import { AgentMiddleware } from "../types.cjs";
3
- import { ActionRequest, HumanInTheLoopMiddlewareConfig, HumanInTheLoopMiddlewareHumanResponse, HumanInTheLoopRequest, humanInTheLoopMiddleware } from "./hitl.cjs";
4
- import { PromptCachingMiddlewareConfig, anthropicPromptCachingMiddleware } from "./promptCaching.cjs";
5
- import { DynamicSystemPromptMiddlewareConfig, dynamicSystemPromptMiddleware } from "./dynamicSystemPrompt.cjs";
6
- import { LLMToolSelectorConfig, llmToolSelectorMiddleware } from "./llmToolSelector.cjs";
7
- import { PIIRedactionMiddlewareConfig, piiRedactionMiddleware } from "./piiRedaction.cjs";
8
- import { ClearToolUsesEdit, ClearToolUsesEditConfig, ContextEdit, ContextEditingMiddlewareConfig, TokenCounter, contextEditingMiddleware } from "./contextEditing.cjs";
9
- import { ToolCallLimitConfig, ToolCallLimitExceededError, toolCallLimitMiddleware } from "./toolCallLimit.cjs";
10
- import { ModelCallLimitMiddlewareConfig, modelCallLimitMiddleware } from "./callLimit.cjs";
11
- import { modelFallbackMiddleware } from "./modelFallback.cjs";
12
- import { countTokensApproximately } from "./utils.cjs";
13
- export { type ActionRequest, type AgentMiddleware, ClearToolUsesEdit, type ClearToolUsesEditConfig, type ContextEdit, type ContextEditingMiddlewareConfig, type DynamicSystemPromptMiddlewareConfig, type HumanInTheLoopMiddlewareConfig, type HumanInTheLoopMiddlewareHumanResponse, type HumanInTheLoopRequest, type LLMToolSelectorConfig, type ModelCallLimitMiddlewareConfig, type PIIRedactionMiddlewareConfig, type PromptCachingMiddlewareConfig, type SummarizationMiddlewareConfig, type TokenCounter, type ToolCallLimitConfig, ToolCallLimitExceededError, anthropicPromptCachingMiddleware, contextEditingMiddleware, countTokensApproximately, dynamicSystemPromptMiddleware, humanInTheLoopMiddleware, llmToolSelectorMiddleware, modelCallLimitMiddleware, modelFallbackMiddleware, piiRedactionMiddleware, summarizationMiddleware, toolCallLimitMiddleware };
@@ -1,13 +0,0 @@
1
- import { SummarizationMiddlewareConfig, summarizationMiddleware } from "./summarization.js";
2
- import { AgentMiddleware } from "../types.js";
3
- import { ActionRequest, HumanInTheLoopMiddlewareConfig, HumanInTheLoopMiddlewareHumanResponse, HumanInTheLoopRequest, humanInTheLoopMiddleware } from "./hitl.js";
4
- import { PromptCachingMiddlewareConfig, anthropicPromptCachingMiddleware } from "./promptCaching.js";
5
- import { DynamicSystemPromptMiddlewareConfig, dynamicSystemPromptMiddleware } from "./dynamicSystemPrompt.js";
6
- import { LLMToolSelectorConfig, llmToolSelectorMiddleware } from "./llmToolSelector.js";
7
- import { PIIRedactionMiddlewareConfig, piiRedactionMiddleware } from "./piiRedaction.js";
8
- import { ClearToolUsesEdit, ClearToolUsesEditConfig, ContextEdit, ContextEditingMiddlewareConfig, TokenCounter, contextEditingMiddleware } from "./contextEditing.js";
9
- import { ToolCallLimitConfig, ToolCallLimitExceededError, toolCallLimitMiddleware } from "./toolCallLimit.js";
10
- import { ModelCallLimitMiddlewareConfig, modelCallLimitMiddleware } from "./callLimit.js";
11
- import { modelFallbackMiddleware } from "./modelFallback.js";
12
- import { countTokensApproximately } from "./utils.js";
13
- export { type ActionRequest, type AgentMiddleware, ClearToolUsesEdit, type ClearToolUsesEditConfig, type ContextEdit, type ContextEditingMiddlewareConfig, type DynamicSystemPromptMiddlewareConfig, type HumanInTheLoopMiddlewareConfig, type HumanInTheLoopMiddlewareHumanResponse, type HumanInTheLoopRequest, type LLMToolSelectorConfig, type ModelCallLimitMiddlewareConfig, type PIIRedactionMiddlewareConfig, type PromptCachingMiddlewareConfig, type SummarizationMiddlewareConfig, type TokenCounter, type ToolCallLimitConfig, ToolCallLimitExceededError, anthropicPromptCachingMiddleware, contextEditingMiddleware, countTokensApproximately, dynamicSystemPromptMiddleware, humanInTheLoopMiddleware, llmToolSelectorMiddleware, modelCallLimitMiddleware, modelFallbackMiddleware, piiRedactionMiddleware, summarizationMiddleware, toolCallLimitMiddleware };
@@ -1,34 +0,0 @@
1
- import { __export } from "../../../_virtual/rolldown_runtime.js";
2
- import { countTokensApproximately } from "./utils.js";
3
- import { summarizationMiddleware } from "./summarization.js";
4
- import { humanInTheLoopMiddleware } from "./hitl.js";
5
- import { anthropicPromptCachingMiddleware } from "./promptCaching.js";
6
- import { dynamicSystemPromptMiddleware } from "./dynamicSystemPrompt.js";
7
- import { llmToolSelectorMiddleware } from "./llmToolSelector.js";
8
- import { piiRedactionMiddleware } from "./piiRedaction.js";
9
- import { ClearToolUsesEdit, contextEditingMiddleware } from "./contextEditing.js";
10
- import { ToolCallLimitExceededError, toolCallLimitMiddleware } from "./toolCallLimit.js";
11
- import { modelCallLimitMiddleware } from "./callLimit.js";
12
- import { modelFallbackMiddleware } from "./modelFallback.js";
13
-
14
- //#region src/agents/middlewareAgent/middleware/index.ts
15
- var middleware_exports = {};
16
- __export(middleware_exports, {
17
- ClearToolUsesEdit: () => ClearToolUsesEdit,
18
- ToolCallLimitExceededError: () => ToolCallLimitExceededError,
19
- anthropicPromptCachingMiddleware: () => anthropicPromptCachingMiddleware,
20
- contextEditingMiddleware: () => contextEditingMiddleware,
21
- countTokensApproximately: () => countTokensApproximately,
22
- dynamicSystemPromptMiddleware: () => dynamicSystemPromptMiddleware,
23
- humanInTheLoopMiddleware: () => humanInTheLoopMiddleware,
24
- llmToolSelectorMiddleware: () => llmToolSelectorMiddleware,
25
- modelCallLimitMiddleware: () => modelCallLimitMiddleware,
26
- modelFallbackMiddleware: () => modelFallbackMiddleware,
27
- piiRedactionMiddleware: () => piiRedactionMiddleware,
28
- summarizationMiddleware: () => summarizationMiddleware,
29
- toolCallLimitMiddleware: () => toolCallLimitMiddleware
30
- });
31
-
32
- //#endregion
33
- export { ClearToolUsesEdit, ToolCallLimitExceededError, anthropicPromptCachingMiddleware, contextEditingMiddleware, countTokensApproximately, dynamicSystemPromptMiddleware, humanInTheLoopMiddleware, llmToolSelectorMiddleware, middleware_exports, modelCallLimitMiddleware, modelFallbackMiddleware, piiRedactionMiddleware, summarizationMiddleware, toolCallLimitMiddleware };
34
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/agents/middlewareAgent/middleware/index.ts"],"sourcesContent":["export {\n summarizationMiddleware,\n type SummarizationMiddlewareConfig,\n} from \"./summarization.js\";\nexport {\n humanInTheLoopMiddleware,\n type HumanInTheLoopRequest,\n type HumanInTheLoopMiddlewareHumanResponse,\n type HumanInTheLoopMiddlewareConfig,\n type ActionRequest,\n} from \"./hitl.js\";\nexport {\n anthropicPromptCachingMiddleware,\n type PromptCachingMiddlewareConfig,\n} from \"./promptCaching.js\";\nexport {\n dynamicSystemPromptMiddleware,\n type DynamicSystemPromptMiddlewareConfig,\n} from \"./dynamicSystemPrompt.js\";\nexport {\n llmToolSelectorMiddleware,\n type LLMToolSelectorConfig,\n} from \"./llmToolSelector.js\";\nexport {\n piiRedactionMiddleware,\n type PIIRedactionMiddlewareConfig,\n} from \"./piiRedaction.js\";\nexport {\n contextEditingMiddleware,\n ClearToolUsesEdit,\n type ContextEditingMiddlewareConfig,\n type ContextEdit,\n type ClearToolUsesEditConfig,\n type TokenCounter,\n} from \"./contextEditing.js\";\nexport {\n toolCallLimitMiddleware,\n ToolCallLimitExceededError,\n type ToolCallLimitConfig,\n} from \"./toolCallLimit.js\";\nexport {\n modelCallLimitMiddleware,\n type ModelCallLimitMiddlewareConfig,\n} from \"./callLimit.js\";\nexport { modelFallbackMiddleware } from \"./modelFallback.js\";\nexport { type AgentMiddleware } from \"../types.js\";\nexport { countTokensApproximately } from \"./utils.js\";\n"],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"llmToolSelector.cjs","names":["tools: StructuredToolInterface[]","z","BaseLanguageModel","options: LLMToolSelectorConfig","createMiddleware","request: ModelRequest","runtime: Runtime<LLMToolSelectorConfig>","lastUserMessage: HumanMessage | undefined","HumanMessage","initChatModel","response: { tools: string[] }","availableTools: StructuredToolInterface[]","validToolNames: string[]","selectedToolNames: string[]","invalidToolSelections: string[]"],"sources":["../../../../src/agents/middlewareAgent/middleware/llmToolSelector.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport type { InferInteropZodInput } from \"@langchain/core/utils/types\";\nimport { HumanMessage } from \"@langchain/core/messages\";\nimport type { StructuredToolInterface } from \"@langchain/core/tools\";\n\nimport { createMiddleware } from \"../middleware.js\";\nimport { initChatModel } from \"../../../chat_models/universal.js\";\nimport type { ModelRequest, Runtime } from \"../types.js\";\n\nconst DEFAULT_SYSTEM_PROMPT =\n \"Your goal is to select the most relevant tools for answering the user's query.\";\n\n/**\n * Prepared inputs for tool selection.\n */\ninterface SelectionRequest {\n availableTools: StructuredToolInterface[];\n systemMessage: string;\n lastUserMessage: HumanMessage;\n model: BaseLanguageModel;\n validToolNames: string[];\n}\n\n/**\n * Create a structured output schema for tool selection.\n *\n * @param tools - Available tools to include in the schema.\n * @returns Zod schema where each tool name is a literal with its description.\n */\nfunction createToolSelectionResponse(tools: StructuredToolInterface[]) {\n if (!tools || tools.length === 0) {\n throw new Error(\"Invalid usage: tools must be non-empty\");\n }\n\n // Create a union of literals for each tool name\n const toolLiterals = tools.map((tool) => z.literal(tool.name));\n const toolEnum = z.union(\n toolLiterals as [\n z.ZodLiteral<string>,\n z.ZodLiteral<string>,\n ...z.ZodLiteral<string>[]\n ]\n );\n\n return z.object({\n tools: z\n .array(toolEnum)\n .describe(\"Tools to use. Place the most relevant tools first.\"),\n });\n}\n\n/**\n * Options for configuring the LLM Tool Selector middleware.\n */\nexport const LLMToolSelectorOptionsSchema = z.object({\n /**\n * The language model to use for tool selection (default: the provided model from the agent options).\n */\n model: z.string().or(z.instanceof(BaseLanguageModel)).optional(),\n /**\n * System prompt for the tool selection model.\n */\n systemPrompt: z.string().optional(),\n /**\n * Maximum number of tools to select. If the model selects more,\n * only the first maxTools will be used. No limit if not specified.\n */\n maxTools: z.number().optional(),\n /**\n * Tool names to always include regardless of selection.\n * These do not count against the maxTools limit.\n */\n alwaysInclude: z.array(z.string()).optional(),\n});\nexport type LLMToolSelectorConfig = InferInteropZodInput<\n typeof LLMToolSelectorOptionsSchema\n>;\n\n/**\n * Middleware for selecting tools using an LLM-based strategy.\n *\n * When an agent has many tools available, this middleware filters them down\n * to only the most relevant ones for the user's query. This reduces token usage\n * and helps the main model focus on the right tools.\n *\n * @param options - Configuration options for the middleware\n * @param options.model - The language model to use for tool selection (default: the provided model from the agent options).\n * @param options.systemPrompt - Instructions for the selection model.\n * @param options.maxTools - Maximum number of tools to select. If the model selects more,\n * only the first maxTools will be used. No limit if not specified.\n * @param options.alwaysInclude - Tool names to always include regardless of selection.\n * These do not count against the maxTools limit.\n *\n * @example\n * Limit to 3 tools:\n * ```ts\n * import { llmToolSelectorMiddleware } from \"langchain/agents/middleware\";\n *\n * const middleware = llmToolSelectorMiddleware({ maxTools: 3 });\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [tool1, tool2, tool3, tool4, tool5],\n * middleware: [middleware],\n * });\n * ```\n *\n * @example\n * Use a smaller model for selection:\n * ```ts\n * const middleware = llmToolSelectorMiddleware({\n * model: \"openai:gpt-4o-mini\",\n * maxTools: 2\n * });\n * ```\n */\nexport function llmToolSelectorMiddleware(\n options: LLMToolSelectorConfig\n): ReturnType<typeof createMiddleware> {\n return createMiddleware({\n name: \"LLMToolSelector\",\n contextSchema: LLMToolSelectorOptionsSchema,\n async modifyModelRequest(request, _, runtime): Promise<ModelRequest> {\n const selectionRequest = await prepareSelectionRequest(\n request,\n options,\n runtime\n );\n if (!selectionRequest) {\n return request;\n }\n\n // Create dynamic response model with union of literal tool names\n const toolSelectionSchema = createToolSelectionResponse(\n selectionRequest.availableTools\n );\n const structuredModel =\n await selectionRequest.model.withStructuredOutput?.(\n toolSelectionSchema\n );\n\n const response = await structuredModel?.invoke([\n { role: \"system\", content: selectionRequest.systemMessage },\n selectionRequest.lastUserMessage,\n ]);\n\n // Response should be an object with a tools array\n if (!response || typeof response !== \"object\" || !(\"tools\" in response)) {\n throw new Error(\n `Expected object response with tools array, got ${typeof response}`\n );\n }\n\n return processSelectionResponse(\n response as { tools: string[] },\n selectionRequest.availableTools,\n selectionRequest.validToolNames,\n request,\n options\n );\n },\n });\n}\n\n/**\n * Prepare inputs for tool selection.\n *\n * @param request - The model request to process.\n * @param options - Configuration options.\n * @param runtime - Runtime context.\n * @returns SelectionRequest with prepared inputs, or null if no selection is needed.\n */\nasync function prepareSelectionRequest(\n request: ModelRequest,\n options: LLMToolSelectorConfig,\n runtime: Runtime<LLMToolSelectorConfig>\n): Promise<SelectionRequest | undefined> {\n const model = runtime.context.model ?? options.model;\n const maxTools = runtime.context.maxTools ?? options.maxTools;\n const alwaysInclude =\n runtime.context.alwaysInclude ?? options.alwaysInclude ?? [];\n const systemPrompt =\n runtime.context.systemPrompt ??\n options.systemPrompt ??\n DEFAULT_SYSTEM_PROMPT;\n\n /**\n * If no tools available, return null\n */\n if (!request.tools || request.tools.length === 0) {\n return undefined;\n }\n\n /**\n * Filter to only StructuredToolInterface instances (exclude provider-specific tool dicts)\n */\n const baseTools = request.tools.filter(\n (tool): tool is StructuredToolInterface =>\n typeof tool === \"object\" &&\n \"name\" in tool &&\n \"description\" in tool &&\n typeof tool.name === \"string\"\n );\n\n /**\n * Validate that alwaysInclude tools exist\n */\n if (alwaysInclude.length > 0) {\n const availableToolNames = new Set(baseTools.map((tool) => tool.name));\n const missingTools = alwaysInclude.filter(\n (name) => !availableToolNames.has(name)\n );\n if (missingTools.length > 0) {\n throw new Error(\n `Tools in alwaysInclude not found in request: ${missingTools.join(\n \", \"\n )}. ` +\n `Available tools: ${Array.from(availableToolNames).sort().join(\", \")}`\n );\n }\n }\n\n /**\n * Separate tools that are always included from those available for selection\n */\n const availableTools = baseTools.filter(\n (tool) => !alwaysInclude.includes(tool.name)\n );\n\n /**\n * If no tools available for selection, return null\n */\n if (availableTools.length === 0) {\n return undefined;\n }\n\n let systemMessage = systemPrompt;\n /**\n * If there's a maxTools limit, append instructions to the system prompt\n */\n if (maxTools !== undefined) {\n systemMessage +=\n `\\nIMPORTANT: List the tool names in order of relevance, ` +\n `with the most relevant first. ` +\n `If you exceed the maximum number of tools, ` +\n `only the first ${maxTools} will be used.`;\n }\n\n /**\n * Get the last user message from the conversation history\n */\n let lastUserMessage: HumanMessage | undefined;\n for (const message of request.messages) {\n if (HumanMessage.isInstance(message)) {\n lastUserMessage = message;\n }\n }\n\n if (!lastUserMessage) {\n throw new Error(\"No user message found in request messages\");\n }\n\n const modelInstance = !model\n ? (request.model as BaseLanguageModel)\n : typeof model === \"string\"\n ? await initChatModel(model)\n : model;\n\n const validToolNames = availableTools.map((tool) => tool.name);\n\n return {\n availableTools,\n systemMessage,\n lastUserMessage,\n model: modelInstance,\n validToolNames,\n };\n}\n\n/**\n * Process the selection response and return filtered ModelRequest.\n *\n * @param response - The structured output response from the model.\n * @param availableTools - Tools available for selection.\n * @param validToolNames - Valid tool names that can be selected.\n * @param request - Original model request.\n * @param options - Configuration options.\n * @returns Modified ModelRequest with filtered tools.\n */\nfunction processSelectionResponse(\n response: { tools: string[] },\n availableTools: StructuredToolInterface[],\n validToolNames: string[],\n request: ModelRequest,\n options: LLMToolSelectorConfig\n): ModelRequest {\n const maxTools = options.maxTools;\n const alwaysInclude = options.alwaysInclude ?? [];\n\n const selectedToolNames: string[] = [];\n const invalidToolSelections: string[] = [];\n\n for (const toolName of response.tools) {\n if (!validToolNames.includes(toolName)) {\n invalidToolSelections.push(toolName);\n continue;\n }\n\n /**\n * Only add if not already selected and within maxTools limit\n */\n if (\n !selectedToolNames.includes(toolName) &&\n (maxTools === undefined || selectedToolNames.length < maxTools)\n ) {\n selectedToolNames.push(toolName);\n }\n }\n\n if (invalidToolSelections.length > 0) {\n throw new Error(\n `Model selected invalid tools: ${invalidToolSelections.join(\", \")}`\n );\n }\n\n /**\n * Filter tools based on selection\n */\n const selectedTools = availableTools.filter((tool) =>\n selectedToolNames.includes(tool.name)\n );\n\n /**\n * Append always-included tools\n */\n const alwaysIncludedTools = (request.tools ?? []).filter(\n (tool): tool is StructuredToolInterface =>\n typeof tool === \"object\" &&\n \"name\" in tool &&\n typeof tool.name === \"string\" &&\n alwaysInclude.includes(tool.name)\n );\n selectedTools.push(...alwaysIncludedTools);\n\n /**\n * Also preserve any provider-specific tool dicts from the original request\n */\n const providerTools = (request.tools ?? []).filter(\n (tool) =>\n !(\n typeof tool === \"object\" &&\n \"name\" in tool &&\n \"description\" in tool &&\n typeof tool.name === \"string\"\n )\n );\n\n return {\n ...request,\n tools: [...selectedTools, ...providerTools],\n };\n}\n"],"mappings":"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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"llmToolSelector.d.cts","names":["z","BaseLanguageModel","InferInteropZodInput","createMiddleware","LLMToolSelectorOptionsSchema","ZodString","_langchain_core_language_models_base7","BaseLanguageModelCallOptions","ZodTypeDef","ZodType","ZodUnion","ZodOptional","ZodNumber","ZodArray","ZodTypeAny","ZodObject","LLMToolSelectorConfig","llmToolSelectorMiddleware","ReturnType"],"sources":["../../../../src/agents/middlewareAgent/middleware/llmToolSelector.d.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport type { InferInteropZodInput } from \"@langchain/core/utils/types\";\nimport { createMiddleware } from \"../middleware.js\";\n/**\n * Options for configuring the LLM Tool Selector middleware.\n */\nexport declare const LLMToolSelectorOptionsSchema: z.ZodObject<{\n /**\n * The language model to use for tool selection (default: the provided model from the agent options).\n */\n model: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<BaseLanguageModel<unknown, import(\"@langchain/core/language_models/base\").BaseLanguageModelCallOptions>, z.ZodTypeDef, BaseLanguageModel<unknown, import(\"@langchain/core/language_models/base\").BaseLanguageModelCallOptions>>]>>;\n /**\n * System prompt for the tool selection model.\n */\n systemPrompt: z.ZodOptional<z.ZodString>;\n /**\n * Maximum number of tools to select. If the model selects more,\n * only the first maxTools will be used. No limit if not specified.\n */\n maxTools: z.ZodOptional<z.ZodNumber>;\n /**\n * Tool names to always include regardless of selection.\n * These do not count against the maxTools limit.\n */\n alwaysInclude: z.ZodOptional<z.ZodArray<z.ZodString, \"many\">>;\n}, \"strip\", z.ZodTypeAny, {\n model?: string | BaseLanguageModel<unknown, import(\"@langchain/core/language_models/base\").BaseLanguageModelCallOptions> | undefined;\n systemPrompt?: string | undefined;\n maxTools?: number | undefined;\n alwaysInclude?: string[] | undefined;\n}, {\n model?: string | BaseLanguageModel<unknown, import(\"@langchain/core/language_models/base\").BaseLanguageModelCallOptions> | undefined;\n systemPrompt?: string | undefined;\n maxTools?: number | undefined;\n alwaysInclude?: string[] | undefined;\n}>;\nexport type LLMToolSelectorConfig = InferInteropZodInput<typeof LLMToolSelectorOptionsSchema>;\n/**\n * Middleware for selecting tools using an LLM-based strategy.\n *\n * When an agent has many tools available, this middleware filters them down\n * to only the most relevant ones for the user's query. This reduces token usage\n * and helps the main model focus on the right tools.\n *\n * @param options - Configuration options for the middleware\n * @param options.model - The language model to use for tool selection (default: the provided model from the agent options).\n * @param options.systemPrompt - Instructions for the selection model.\n * @param options.maxTools - Maximum number of tools to select. If the model selects more,\n * only the first maxTools will be used. No limit if not specified.\n * @param options.alwaysInclude - Tool names to always include regardless of selection.\n * These do not count against the maxTools limit.\n *\n * @example\n * Limit to 3 tools:\n * ```ts\n * import { llmToolSelectorMiddleware } from \"langchain/agents/middleware\";\n *\n * const middleware = llmToolSelectorMiddleware({ maxTools: 3 });\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [tool1, tool2, tool3, tool4, tool5],\n * middleware: [middleware],\n * });\n * ```\n *\n * @example\n * Use a smaller model for selection:\n * ```ts\n * const middleware = llmToolSelectorMiddleware({\n * model: \"openai:gpt-4o-mini\",\n * maxTools: 2\n * });\n * ```\n */\nexport declare function llmToolSelectorMiddleware(options: LLMToolSelectorConfig): ReturnType<typeof createMiddleware>;\n"],"mappings":";;;;;;;;;;AAOqBI,cAAAA,4BA6BnB,EA7BiDJ,CAAAA,CAAEe,SA6BnD,CAAA;EAAA;;;EAzBgK,KAAtGd,EAAjDD,CAAAA,CAAEW,WAA+CV,CAAnCD,CAAAA,CAAEU,QAAiCT,CAAAA,CAAvBD,CAAAA,CAAEK,SAAqBJ,EAAVD,CAAAA,CAAES,OAAQR,CAAAA,iBAAAA,CAAAA,OAAAA,EAAZK,qCAAAA,CAAsFC,4BAAAA,CAA1EN,EAAyGD,CAAAA,CAAEQ,UAA3GP,EAAuHA,iBAAvHA,CAAAA,OAAAA,EAAqHK,qCAAAA,CAA4EC,4BAAAA,CAAjMN,CAAAA,CAAAA,CAAAA,CAAAA;EAAiB;;;EAAuH,YAAhJQ,EAIlCT,CAAAA,CAAEW,WAJgCF,CAIpBT,CAAAA,CAAEK,SAJkBI,CAAAA;EAAO;;;;EAI5B,QAKDG,EAAhBZ,CAAAA,CAAEW,WAAcC,CAAFZ,CAAAA,CAAEY,SAAAA,CAAAA;EAAS;;;;EAKP,aAClBE,EADKd,CAAAA,CAAEW,WACPG,CADmBd,CAAAA,CAAEa,QACrBC,CAD8Bd,CAAAA,CAAEK,SAChCS,EAAAA,MAAAA,CAAAA,CAAAA;CAAU,EAAA,OAAAR,EAAZN,CAAAA,CAAEc,UAAUR,EAAAA;EACmG,KAAtGL,CAAAA,EAAAA,MAAAA,GAAAA,iBAAAA,CAAAA,OAAAA,EADGK,qCAAAA,CACuEC,4BAAAA,CAA1EN,GAAAA,SAAAA;EAAiB,YAAAK,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAKqF,QAAtGL,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAAiB,aAzBec,CAAAA,EAAAA,MAAAA,EAAAA,GAAAA,SAAAA;AAAS,CAAA,EAAA;EA8BlDC,KAAAA,CAAAA,EAAAA,MAAAA,GALSf,iBAKY,CAAA,OAAA,EAVKK,qCAAAA,CAKyDC,4BAAAA,CAK9D,GAAA,SAAA;EAAA,YAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAAA,QAA+BH,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAA4B,aAAxDF,CAAAA,EAAAA,MAAAA,EAAAA,GAAAA,SAAAA;AAAoB,CAAA,CAAA;AAuChCe,KAvCZD,qBAAAA,GAAwBd,oBAuCa,CAAA,OAvCeE,4BAuCf,CAAA;;;;;AAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAArEa,yBAAAA,UAAmCD,wBAAwBE,kBAAkBf"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"llmToolSelector.d.ts","names":["z","BaseLanguageModel","InferInteropZodInput","createMiddleware","LLMToolSelectorOptionsSchema","ZodString","_langchain_core_language_models_base7","BaseLanguageModelCallOptions","ZodTypeDef","ZodType","ZodUnion","ZodOptional","ZodNumber","ZodArray","ZodTypeAny","ZodObject","LLMToolSelectorConfig","llmToolSelectorMiddleware","ReturnType"],"sources":["../../../../src/agents/middlewareAgent/middleware/llmToolSelector.d.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport type { InferInteropZodInput } from \"@langchain/core/utils/types\";\nimport { createMiddleware } from \"../middleware.js\";\n/**\n * Options for configuring the LLM Tool Selector middleware.\n */\nexport declare const LLMToolSelectorOptionsSchema: z.ZodObject<{\n /**\n * The language model to use for tool selection (default: the provided model from the agent options).\n */\n model: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<BaseLanguageModel<unknown, import(\"@langchain/core/language_models/base\").BaseLanguageModelCallOptions>, z.ZodTypeDef, BaseLanguageModel<unknown, import(\"@langchain/core/language_models/base\").BaseLanguageModelCallOptions>>]>>;\n /**\n * System prompt for the tool selection model.\n */\n systemPrompt: z.ZodOptional<z.ZodString>;\n /**\n * Maximum number of tools to select. If the model selects more,\n * only the first maxTools will be used. No limit if not specified.\n */\n maxTools: z.ZodOptional<z.ZodNumber>;\n /**\n * Tool names to always include regardless of selection.\n * These do not count against the maxTools limit.\n */\n alwaysInclude: z.ZodOptional<z.ZodArray<z.ZodString, \"many\">>;\n}, \"strip\", z.ZodTypeAny, {\n model?: string | BaseLanguageModel<unknown, import(\"@langchain/core/language_models/base\").BaseLanguageModelCallOptions> | undefined;\n systemPrompt?: string | undefined;\n maxTools?: number | undefined;\n alwaysInclude?: string[] | undefined;\n}, {\n model?: string | BaseLanguageModel<unknown, import(\"@langchain/core/language_models/base\").BaseLanguageModelCallOptions> | undefined;\n systemPrompt?: string | undefined;\n maxTools?: number | undefined;\n alwaysInclude?: string[] | undefined;\n}>;\nexport type LLMToolSelectorConfig = InferInteropZodInput<typeof LLMToolSelectorOptionsSchema>;\n/**\n * Middleware for selecting tools using an LLM-based strategy.\n *\n * When an agent has many tools available, this middleware filters them down\n * to only the most relevant ones for the user's query. This reduces token usage\n * and helps the main model focus on the right tools.\n *\n * @param options - Configuration options for the middleware\n * @param options.model - The language model to use for tool selection (default: the provided model from the agent options).\n * @param options.systemPrompt - Instructions for the selection model.\n * @param options.maxTools - Maximum number of tools to select. If the model selects more,\n * only the first maxTools will be used. No limit if not specified.\n * @param options.alwaysInclude - Tool names to always include regardless of selection.\n * These do not count against the maxTools limit.\n *\n * @example\n * Limit to 3 tools:\n * ```ts\n * import { llmToolSelectorMiddleware } from \"langchain/agents/middleware\";\n *\n * const middleware = llmToolSelectorMiddleware({ maxTools: 3 });\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [tool1, tool2, tool3, tool4, tool5],\n * middleware: [middleware],\n * });\n * ```\n *\n * @example\n * Use a smaller model for selection:\n * ```ts\n * const middleware = llmToolSelectorMiddleware({\n * model: \"openai:gpt-4o-mini\",\n * maxTools: 2\n * });\n * ```\n */\nexport declare function llmToolSelectorMiddleware(options: LLMToolSelectorConfig): ReturnType<typeof createMiddleware>;\n"],"mappings":";;;;;;;;;;AAOqBI,cAAAA,4BA6BnB,EA7BiDJ,CAAAA,CAAEe,SA6BnD,CAAA;EAAA;;;EAzBgK,KAAtGd,EAAjDD,CAAAA,CAAEW,WAA+CV,CAAnCD,CAAAA,CAAEU,QAAiCT,CAAAA,CAAvBD,CAAAA,CAAEK,SAAqBJ,EAAVD,CAAAA,CAAES,OAAQR,CAAAA,iBAAAA,CAAAA,OAAAA,EAAZK,qCAAAA,CAAsFC,4BAAAA,CAA1EN,EAAyGD,CAAAA,CAAEQ,UAA3GP,EAAuHA,iBAAvHA,CAAAA,OAAAA,EAAqHK,qCAAAA,CAA4EC,4BAAAA,CAAjMN,CAAAA,CAAAA,CAAAA,CAAAA;EAAiB;;;EAAuH,YAAhJQ,EAIlCT,CAAAA,CAAEW,WAJgCF,CAIpBT,CAAAA,CAAEK,SAJkBI,CAAAA;EAAO;;;;EAI5B,QAKDG,EAAhBZ,CAAAA,CAAEW,WAAcC,CAAFZ,CAAAA,CAAEY,SAAAA,CAAAA;EAAS;;;;EAKP,aAClBE,EADKd,CAAAA,CAAEW,WACPG,CADmBd,CAAAA,CAAEa,QACrBC,CAD8Bd,CAAAA,CAAEK,SAChCS,EAAAA,MAAAA,CAAAA,CAAAA;CAAU,EAAA,OAAAR,EAAZN,CAAAA,CAAEc,UAAUR,EAAAA;EACmG,KAAtGL,CAAAA,EAAAA,MAAAA,GAAAA,iBAAAA,CAAAA,OAAAA,EADGK,qCAAAA,CACuEC,4BAAAA,CAA1EN,GAAAA,SAAAA;EAAiB,YAAAK,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAKqF,QAAtGL,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAAiB,aAzBec,CAAAA,EAAAA,MAAAA,EAAAA,GAAAA,SAAAA;AAAS,CAAA,EAAA;EA8BlDC,KAAAA,CAAAA,EAAAA,MAAAA,GALSf,iBAKY,CAAA,OAAA,EAVKK,qCAAAA,CAKyDC,4BAAAA,CAK9D,GAAA,SAAA;EAAA,YAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAAA,QAA+BH,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAA4B,aAAxDF,CAAAA,EAAAA,MAAAA,EAAAA,GAAAA,SAAAA;AAAoB,CAAA,CAAA;AAuChCe,KAvCZD,qBAAAA,GAAwBd,oBAuCa,CAAA,OAvCeE,4BAuCf,CAAA;;;;;AAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAArEa,yBAAAA,UAAmCD,wBAAwBE,kBAAkBf"}