langchain 1.0.0-alpha.5 → 1.0.0-alpha.7

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 (405) hide show
  1. package/dist/agents/ReactAgent.cjs +5 -5
  2. package/dist/agents/ReactAgent.cjs.map +1 -1
  3. package/dist/agents/ReactAgent.d.cts +2 -5
  4. package/dist/agents/ReactAgent.d.cts.map +1 -1
  5. package/dist/agents/ReactAgent.d.ts +2 -5
  6. package/dist/agents/ReactAgent.d.ts.map +1 -1
  7. package/dist/agents/ReactAgent.js +6 -6
  8. package/dist/agents/ReactAgent.js.map +1 -1
  9. package/dist/agents/annotation.cjs.map +1 -1
  10. package/dist/agents/annotation.d.cts +13 -8
  11. package/dist/agents/annotation.d.cts.map +1 -1
  12. package/dist/agents/annotation.d.ts +13 -8
  13. package/dist/agents/annotation.d.ts.map +1 -1
  14. package/dist/agents/annotation.js.map +1 -1
  15. package/dist/agents/createAgent.cjs.map +1 -1
  16. package/dist/agents/createAgent.js.map +1 -1
  17. package/dist/agents/index.cjs +2 -2
  18. package/dist/agents/index.cjs.map +1 -1
  19. package/dist/agents/index.d.cts +50 -50
  20. package/dist/agents/index.d.cts.map +1 -1
  21. package/dist/agents/index.d.ts +50 -50
  22. package/dist/agents/index.d.ts.map +1 -1
  23. package/dist/agents/index.js +2 -2
  24. package/dist/agents/index.js.map +1 -1
  25. package/dist/agents/interrupt.d.cts +14 -1
  26. package/dist/agents/interrupt.d.cts.map +1 -1
  27. package/dist/agents/interrupt.d.ts +14 -1
  28. package/dist/agents/interrupt.d.ts.map +1 -1
  29. package/dist/agents/middlewareAgent/ReactAgent.cjs +273 -66
  30. package/dist/agents/middlewareAgent/ReactAgent.cjs.map +1 -1
  31. package/dist/agents/middlewareAgent/ReactAgent.d.cts +102 -16
  32. package/dist/agents/middlewareAgent/ReactAgent.d.cts.map +1 -1
  33. package/dist/agents/middlewareAgent/ReactAgent.d.ts +102 -16
  34. package/dist/agents/middlewareAgent/ReactAgent.d.ts.map +1 -1
  35. package/dist/agents/middlewareAgent/ReactAgent.js +275 -68
  36. package/dist/agents/middlewareAgent/ReactAgent.js.map +1 -1
  37. package/dist/agents/middlewareAgent/annotation.cjs +12 -6
  38. package/dist/agents/middlewareAgent/annotation.cjs.map +1 -1
  39. package/dist/agents/middlewareAgent/annotation.js +12 -6
  40. package/dist/agents/middlewareAgent/annotation.js.map +1 -1
  41. package/dist/agents/middlewareAgent/constants.d.cts +5 -0
  42. package/dist/agents/middlewareAgent/constants.d.cts.map +1 -0
  43. package/dist/agents/middlewareAgent/constants.d.ts +5 -0
  44. package/dist/agents/middlewareAgent/constants.d.ts.map +1 -0
  45. package/dist/agents/middlewareAgent/index.cjs.map +1 -1
  46. package/dist/agents/middlewareAgent/index.js.map +1 -1
  47. package/dist/agents/middlewareAgent/middleware/bigTool.cjs +162 -0
  48. package/dist/agents/middlewareAgent/middleware/bigTool.cjs.map +1 -0
  49. package/dist/agents/middlewareAgent/middleware/bigTool.d.cts +113 -0
  50. package/dist/agents/middlewareAgent/middleware/bigTool.d.cts.map +1 -0
  51. package/dist/agents/middlewareAgent/middleware/bigTool.d.ts +113 -0
  52. package/dist/agents/middlewareAgent/middleware/bigTool.d.ts.map +1 -0
  53. package/dist/agents/middlewareAgent/middleware/bigTool.js +161 -0
  54. package/dist/agents/middlewareAgent/middleware/bigTool.js.map +1 -0
  55. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs +58 -0
  56. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs.map +1 -0
  57. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts +46 -0
  58. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts.map +1 -0
  59. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts +46 -0
  60. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts.map +1 -0
  61. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js +58 -0
  62. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js.map +1 -0
  63. package/dist/agents/middlewareAgent/middleware/hitl.cjs +311 -0
  64. package/dist/agents/middlewareAgent/middleware/hitl.cjs.map +1 -0
  65. package/dist/agents/middlewareAgent/middleware/hitl.d.cts +419 -0
  66. package/dist/agents/middlewareAgent/middleware/hitl.d.cts.map +1 -0
  67. package/dist/agents/middlewareAgent/middleware/hitl.d.ts +419 -0
  68. package/dist/agents/middlewareAgent/middleware/hitl.d.ts.map +1 -0
  69. package/dist/agents/middlewareAgent/middleware/hitl.js +310 -0
  70. package/dist/agents/middlewareAgent/middleware/hitl.js.map +1 -0
  71. package/dist/agents/middlewareAgent/middleware/index.cjs +32 -0
  72. package/dist/agents/middlewareAgent/middleware/index.cjs.map +1 -0
  73. package/dist/agents/middlewareAgent/middleware/index.d.cts +6 -0
  74. package/dist/agents/middlewareAgent/middleware/index.d.ts +6 -0
  75. package/dist/agents/middlewareAgent/middleware/index.js +21 -0
  76. package/dist/agents/middlewareAgent/middleware/index.js.map +1 -0
  77. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.cjs +72 -27
  78. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs.map +1 -0
  79. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.cts +60 -15
  80. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts.map +1 -0
  81. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.ts +60 -15
  82. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts.map +1 -0
  83. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.js +71 -26
  84. package/dist/agents/middlewareAgent/middleware/promptCaching.js.map +1 -0
  85. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.cjs +35 -23
  86. package/dist/agents/middlewareAgent/middleware/summarization.cjs.map +1 -0
  87. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.cts +7 -5
  88. package/dist/agents/middlewareAgent/middleware/summarization.d.cts.map +1 -0
  89. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.ts +7 -5
  90. package/dist/agents/middlewareAgent/middleware/summarization.d.ts.map +1 -0
  91. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.js +29 -17
  92. package/dist/agents/middlewareAgent/middleware/summarization.js.map +1 -0
  93. package/dist/agents/middlewareAgent/middleware.cjs +8 -5
  94. package/dist/agents/middlewareAgent/middleware.cjs.map +1 -1
  95. package/dist/agents/middlewareAgent/middleware.d.cts +67 -7
  96. package/dist/agents/middlewareAgent/middleware.d.cts.map +1 -1
  97. package/dist/agents/middlewareAgent/middleware.d.ts +67 -7
  98. package/dist/agents/middlewareAgent/middleware.d.ts.map +1 -1
  99. package/dist/agents/middlewareAgent/middleware.js +8 -5
  100. package/dist/agents/middlewareAgent/middleware.js.map +1 -1
  101. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs +2 -2
  102. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs.map +1 -1
  103. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js +2 -2
  104. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js.map +1 -1
  105. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs +125 -83
  106. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs.map +1 -1
  107. package/dist/agents/middlewareAgent/nodes/AgentNode.js +128 -86
  108. package/dist/agents/middlewareAgent/nodes/AgentNode.js.map +1 -1
  109. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs +2 -2
  110. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs.map +1 -1
  111. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js +2 -2
  112. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js.map +1 -1
  113. package/dist/agents/middlewareAgent/nodes/middleware.cjs +42 -17
  114. package/dist/agents/middlewareAgent/nodes/middleware.cjs.map +1 -1
  115. package/dist/agents/middlewareAgent/nodes/middleware.js +42 -18
  116. package/dist/agents/middlewareAgent/nodes/middleware.js.map +1 -1
  117. package/dist/agents/middlewareAgent/nodes/utils.cjs +30 -16
  118. package/dist/agents/middlewareAgent/nodes/utils.cjs.map +1 -1
  119. package/dist/agents/middlewareAgent/nodes/utils.js +28 -14
  120. package/dist/agents/middlewareAgent/nodes/utils.js.map +1 -1
  121. package/dist/agents/middlewareAgent/types.d.cts +162 -88
  122. package/dist/agents/middlewareAgent/types.d.cts.map +1 -1
  123. package/dist/agents/middlewareAgent/types.d.ts +162 -88
  124. package/dist/agents/middlewareAgent/types.d.ts.map +1 -1
  125. package/dist/agents/model.cjs +13 -0
  126. package/dist/agents/model.cjs.map +1 -0
  127. package/dist/agents/model.js +11 -0
  128. package/dist/agents/model.js.map +1 -0
  129. package/dist/agents/nodes/AgentNode.cjs +60 -32
  130. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  131. package/dist/agents/nodes/AgentNode.js +61 -33
  132. package/dist/agents/nodes/AgentNode.js.map +1 -1
  133. package/dist/agents/nodes/ToolNode.cjs +4 -4
  134. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  135. package/dist/agents/nodes/ToolNode.d.cts +2 -3
  136. package/dist/agents/nodes/ToolNode.d.cts.map +1 -1
  137. package/dist/agents/nodes/ToolNode.d.ts +1 -2
  138. package/dist/agents/nodes/ToolNode.d.ts.map +1 -1
  139. package/dist/agents/nodes/ToolNode.js +5 -5
  140. package/dist/agents/nodes/ToolNode.js.map +1 -1
  141. package/dist/agents/responses.cjs +53 -11
  142. package/dist/agents/responses.cjs.map +1 -1
  143. package/dist/agents/responses.d.cts +12 -20
  144. package/dist/agents/responses.d.cts.map +1 -1
  145. package/dist/agents/responses.d.ts +12 -20
  146. package/dist/agents/responses.d.ts.map +1 -1
  147. package/dist/agents/responses.js +53 -12
  148. package/dist/agents/responses.js.map +1 -1
  149. package/dist/agents/types.d.cts +3 -6
  150. package/dist/agents/types.d.cts.map +1 -1
  151. package/dist/agents/types.d.ts +3 -6
  152. package/dist/agents/types.d.ts.map +1 -1
  153. package/dist/agents/utils.cjs +11 -29
  154. package/dist/agents/utils.cjs.map +1 -1
  155. package/dist/agents/utils.js +9 -26
  156. package/dist/agents/utils.js.map +1 -1
  157. package/dist/agents/withAgentName.cjs.map +1 -1
  158. package/dist/agents/withAgentName.js.map +1 -1
  159. package/dist/chains/api/prompts.cjs.map +1 -1
  160. package/dist/chains/api/prompts.js.map +1 -1
  161. package/dist/chains/constitutional_ai/constitutional_chain.cjs.map +1 -1
  162. package/dist/chains/constitutional_ai/constitutional_chain.js.map +1 -1
  163. package/dist/chains/index.cjs +0 -3
  164. package/dist/chains/index.cjs.map +1 -1
  165. package/dist/chains/index.d.cts +1 -2
  166. package/dist/chains/index.d.ts +1 -2
  167. package/dist/chains/index.js +1 -3
  168. package/dist/chains/index.js.map +1 -1
  169. package/dist/chains/openai_functions/extraction.cjs.map +1 -1
  170. package/dist/chains/openai_functions/extraction.d.cts +1 -3
  171. package/dist/chains/openai_functions/extraction.d.cts.map +1 -1
  172. package/dist/chains/openai_functions/extraction.d.ts +1 -3
  173. package/dist/chains/openai_functions/extraction.d.ts.map +1 -1
  174. package/dist/chains/openai_functions/extraction.js.map +1 -1
  175. package/dist/chains/openai_functions/index.cjs +0 -5
  176. package/dist/chains/openai_functions/index.cjs.map +1 -1
  177. package/dist/chains/openai_functions/index.d.cts +1 -2
  178. package/dist/chains/openai_functions/index.d.ts +1 -2
  179. package/dist/chains/openai_functions/index.js +1 -4
  180. package/dist/chains/openai_functions/index.js.map +1 -1
  181. package/dist/chains/openai_functions/openapi.cjs +4 -4
  182. package/dist/chains/openai_functions/openapi.cjs.map +1 -1
  183. package/dist/chains/openai_functions/openapi.d.cts +1 -1
  184. package/dist/chains/openai_functions/openapi.js +4 -4
  185. package/dist/chains/openai_functions/openapi.js.map +1 -1
  186. package/dist/chains/openai_functions/tagging.cjs.map +1 -1
  187. package/dist/chains/openai_functions/tagging.d.cts +1 -3
  188. package/dist/chains/openai_functions/tagging.d.cts.map +1 -1
  189. package/dist/chains/openai_functions/tagging.d.ts +1 -3
  190. package/dist/chains/openai_functions/tagging.d.ts.map +1 -1
  191. package/dist/chains/openai_functions/tagging.js.map +1 -1
  192. package/dist/chains/query_constructor/index.cjs +4 -4
  193. package/dist/chains/query_constructor/index.cjs.map +1 -1
  194. package/dist/chains/query_constructor/index.d.cts +4 -2
  195. package/dist/chains/query_constructor/index.d.cts.map +1 -1
  196. package/dist/chains/query_constructor/index.d.ts +4 -2
  197. package/dist/chains/query_constructor/index.d.ts.map +1 -1
  198. package/dist/chains/query_constructor/index.js +1 -1
  199. package/dist/chains/query_constructor/index.js.map +1 -1
  200. package/dist/chains/question_answering/load.d.ts +2 -2
  201. package/dist/chains/question_answering/load.d.ts.map +1 -1
  202. package/dist/chains/question_answering/map_reduce_prompts.cjs.map +1 -1
  203. package/dist/chains/question_answering/map_reduce_prompts.js.map +1 -1
  204. package/dist/chains/question_answering/refine_prompts.cjs.map +1 -1
  205. package/dist/chains/question_answering/refine_prompts.js.map +1 -1
  206. package/dist/chains/question_answering/stuff_prompts.cjs.map +1 -1
  207. package/dist/chains/question_answering/stuff_prompts.js.map +1 -1
  208. package/dist/chains/router/multi_prompt.cjs +4 -4
  209. package/dist/chains/router/multi_prompt.cjs.map +1 -1
  210. package/dist/chains/router/multi_prompt.js +1 -1
  211. package/dist/chains/router/multi_prompt.js.map +1 -1
  212. package/dist/chains/router/multi_retrieval_qa.cjs +4 -4
  213. package/dist/chains/router/multi_retrieval_qa.cjs.map +1 -1
  214. package/dist/chains/router/multi_retrieval_qa.js +1 -1
  215. package/dist/chains/router/multi_retrieval_qa.js.map +1 -1
  216. package/dist/chains/sql_db/sql_db_prompt.cjs.map +1 -1
  217. package/dist/chains/sql_db/sql_db_prompt.d.cts.map +1 -1
  218. package/dist/chains/sql_db/sql_db_prompt.d.ts.map +1 -1
  219. package/dist/chains/sql_db/sql_db_prompt.js.map +1 -1
  220. package/dist/chains/summarization/stuff_prompts.cjs.map +1 -1
  221. package/dist/chains/summarization/stuff_prompts.js.map +1 -1
  222. package/dist/chat_models/universal.cjs +8 -5
  223. package/dist/chat_models/universal.cjs.map +1 -1
  224. package/dist/chat_models/universal.d.cts +2 -2
  225. package/dist/chat_models/universal.d.cts.map +1 -1
  226. package/dist/chat_models/universal.d.ts +2 -2
  227. package/dist/chat_models/universal.d.ts.map +1 -1
  228. package/dist/chat_models/universal.js +8 -5
  229. package/dist/chat_models/universal.js.map +1 -1
  230. package/dist/document_loaders/fs/directory.cjs.map +1 -1
  231. package/dist/document_loaders/fs/directory.d.cts +0 -1
  232. package/dist/document_loaders/fs/directory.d.cts.map +1 -1
  233. package/dist/document_loaders/fs/directory.d.ts +0 -1
  234. package/dist/document_loaders/fs/directory.d.ts.map +1 -1
  235. package/dist/document_loaders/fs/directory.js.map +1 -1
  236. package/dist/document_loaders/fs/json.cjs +7 -1
  237. package/dist/document_loaders/fs/json.cjs.map +1 -1
  238. package/dist/document_loaders/fs/json.js +7 -1
  239. package/dist/document_loaders/fs/json.js.map +1 -1
  240. package/dist/embeddings/cache_backed.cjs +1 -1
  241. package/dist/embeddings/cache_backed.cjs.map +1 -1
  242. package/dist/embeddings/cache_backed.d.cts +1 -1
  243. package/dist/embeddings/cache_backed.d.ts +2 -2
  244. package/dist/embeddings/cache_backed.js +2 -2
  245. package/dist/embeddings/cache_backed.js.map +1 -1
  246. package/dist/evaluation/agents/trajectory.d.cts.map +1 -1
  247. package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
  248. package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
  249. package/dist/evaluation/embedding_distance/base.cjs +2 -4
  250. package/dist/evaluation/embedding_distance/base.cjs.map +1 -1
  251. package/dist/evaluation/embedding_distance/base.js +2 -3
  252. package/dist/evaluation/embedding_distance/base.js.map +1 -1
  253. package/dist/evaluation/loader.cjs +7 -12
  254. package/dist/evaluation/loader.cjs.map +1 -1
  255. package/dist/evaluation/loader.d.cts +8 -2
  256. package/dist/evaluation/loader.d.cts.map +1 -1
  257. package/dist/evaluation/loader.d.ts +8 -2
  258. package/dist/evaluation/loader.d.ts.map +1 -1
  259. package/dist/evaluation/loader.js +7 -12
  260. package/dist/evaluation/loader.js.map +1 -1
  261. package/dist/hub/base.cjs.map +1 -1
  262. package/dist/hub/base.js.map +1 -1
  263. package/dist/index.cjs +38 -6
  264. package/dist/index.cjs.map +1 -1
  265. package/dist/index.d.cts +11 -4
  266. package/dist/index.d.ts +11 -4
  267. package/dist/index.js +18 -4
  268. package/dist/index.js.map +1 -1
  269. package/dist/langchain-core/dist/load/serializable.d.cts.map +1 -1
  270. package/dist/langchain-core/dist/messages/base.d.cts +24 -33
  271. package/dist/langchain-core/dist/messages/base.d.cts.map +1 -1
  272. package/dist/langchain-core/dist/messages/content/index.d.cts +21 -2
  273. package/dist/langchain-core/dist/messages/content/index.d.cts.map +1 -1
  274. package/dist/langchain-core/dist/messages/content/tools.d.cts +67 -6
  275. package/dist/langchain-core/dist/messages/content/tools.d.cts.map +1 -1
  276. package/dist/langchain-core/dist/messages/message.d.cts +598 -0
  277. package/dist/langchain-core/dist/messages/message.d.cts.map +1 -0
  278. package/dist/langchain-core/dist/messages/metadata.d.cts +97 -0
  279. package/dist/langchain-core/dist/messages/metadata.d.cts.map +1 -0
  280. package/dist/langchain-core/dist/messages/utils.d.cts +75 -0
  281. package/dist/langchain-core/dist/messages/utils.d.cts.map +1 -0
  282. package/dist/langchain-core/dist/prompt_values.d.cts.map +1 -1
  283. package/dist/langchain-core/dist/utils/types/index.d.cts.map +1 -1
  284. package/dist/libs/langchain-core/dist/load/serializable.d.ts.map +1 -1
  285. package/dist/libs/langchain-core/dist/messages/base.d.ts +24 -33
  286. package/dist/libs/langchain-core/dist/messages/base.d.ts.map +1 -1
  287. package/dist/libs/langchain-core/dist/messages/content/index.d.ts +21 -2
  288. package/dist/libs/langchain-core/dist/messages/content/index.d.ts.map +1 -1
  289. package/dist/libs/langchain-core/dist/messages/content/tools.d.ts +67 -6
  290. package/dist/libs/langchain-core/dist/messages/content/tools.d.ts.map +1 -1
  291. package/dist/libs/langchain-core/dist/messages/message.d.ts +598 -0
  292. package/dist/libs/langchain-core/dist/messages/message.d.ts.map +1 -0
  293. package/dist/libs/langchain-core/dist/messages/metadata.d.ts +97 -0
  294. package/dist/libs/langchain-core/dist/messages/metadata.d.ts.map +1 -0
  295. package/dist/libs/langchain-core/dist/messages/utils.d.ts +75 -0
  296. package/dist/libs/langchain-core/dist/messages/utils.d.ts.map +1 -0
  297. package/dist/libs/langchain-core/dist/prompt_values.d.ts.map +1 -1
  298. package/dist/libs/langchain-core/dist/utils/types/index.d.ts +2 -0
  299. package/dist/libs/langchain-core/dist/utils/types/index.d.ts.map +1 -1
  300. package/dist/libs/langchain-core/dist/utils/types/zod.d.ts +1 -0
  301. package/dist/load/import_map.cjs +3 -14
  302. package/dist/load/import_map.cjs.map +1 -1
  303. package/dist/load/import_map.js +3 -14
  304. package/dist/load/import_map.js.map +1 -1
  305. package/dist/memory/prompt.cjs.map +1 -1
  306. package/dist/memory/prompt.d.cts.map +1 -1
  307. package/dist/memory/prompt.d.ts.map +1 -1
  308. package/dist/memory/prompt.js.map +1 -1
  309. package/dist/output_parsers/combining.cjs +1 -1
  310. package/dist/output_parsers/combining.cjs.map +1 -1
  311. package/dist/output_parsers/combining.js +1 -1
  312. package/dist/output_parsers/combining.js.map +1 -1
  313. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.cjs.map +1 -1
  314. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.js.map +1 -1
  315. package/dist/output_parsers/expression_type_handlers/base.cjs +1 -1
  316. package/dist/output_parsers/expression_type_handlers/base.cjs.map +1 -1
  317. package/dist/output_parsers/expression_type_handlers/base.js +1 -1
  318. package/dist/output_parsers/expression_type_handlers/base.js.map +1 -1
  319. package/dist/output_parsers/regex.cjs.map +1 -1
  320. package/dist/output_parsers/regex.js.map +1 -1
  321. package/dist/output_parsers/structured.cjs +4 -4
  322. package/dist/output_parsers/structured.cjs.map +1 -1
  323. package/dist/output_parsers/structured.d.cts +1 -1
  324. package/dist/output_parsers/structured.d.cts.map +1 -1
  325. package/dist/output_parsers/structured.d.ts +1 -1
  326. package/dist/output_parsers/structured.d.ts.map +1 -1
  327. package/dist/output_parsers/structured.js +2 -2
  328. package/dist/output_parsers/structured.js.map +1 -1
  329. package/dist/retrievers/ensemble.cjs.map +1 -1
  330. package/dist/retrievers/ensemble.js.map +1 -1
  331. package/dist/storage/file_system.cjs +1 -1
  332. package/dist/storage/file_system.cjs.map +1 -1
  333. package/dist/storage/file_system.js +1 -1
  334. package/dist/storage/file_system.js.map +1 -1
  335. package/dist/tools/fs.cjs +5 -5
  336. package/dist/tools/fs.cjs.map +1 -1
  337. package/dist/tools/fs.d.cts +1 -1
  338. package/dist/tools/fs.d.cts.map +1 -1
  339. package/dist/tools/fs.d.ts +1 -1
  340. package/dist/tools/fs.d.ts.map +1 -1
  341. package/dist/tools/fs.js +1 -1
  342. package/dist/tools/fs.js.map +1 -1
  343. package/dist/tools/retriever.cjs +2 -2
  344. package/dist/tools/retriever.cjs.map +1 -1
  345. package/dist/tools/retriever.d.cts +1 -1
  346. package/dist/tools/retriever.d.cts.map +1 -1
  347. package/dist/tools/retriever.d.ts +1 -1
  348. package/dist/tools/retriever.d.ts.map +1 -1
  349. package/dist/tools/retriever.js +1 -1
  350. package/dist/tools/retriever.js.map +1 -1
  351. package/dist/tools/sql.cjs +1 -2
  352. package/dist/tools/sql.cjs.map +1 -1
  353. package/dist/tools/sql.d.cts +1 -1
  354. package/dist/tools/sql.d.cts.map +1 -1
  355. package/dist/tools/sql.d.ts +1 -1
  356. package/dist/tools/sql.d.ts.map +1 -1
  357. package/dist/tools/sql.js +1 -2
  358. package/dist/tools/sql.js.map +1 -1
  359. package/dist/types/expression-parser.d.cts +2 -0
  360. package/dist/types/expression-parser.d.cts.map +1 -1
  361. package/dist/types/expression-parser.d.ts +2 -0
  362. package/dist/types/expression-parser.d.ts.map +1 -1
  363. package/dist/util/hub.cjs +1 -1
  364. package/dist/util/hub.js +1 -1
  365. package/dist/util/openapi.cjs +1 -1
  366. package/dist/util/openapi.cjs.map +1 -1
  367. package/dist/util/openapi.js +1 -1
  368. package/dist/util/openapi.js.map +1 -1
  369. package/package.json +15 -21
  370. package/dist/agents/middlewareAgent/middlewares/hitl.cjs +0 -235
  371. package/dist/agents/middlewareAgent/middlewares/hitl.cjs.map +0 -1
  372. package/dist/agents/middlewareAgent/middlewares/hitl.d.cts +0 -199
  373. package/dist/agents/middlewareAgent/middlewares/hitl.d.cts.map +0 -1
  374. package/dist/agents/middlewareAgent/middlewares/hitl.d.ts +0 -199
  375. package/dist/agents/middlewareAgent/middlewares/hitl.d.ts.map +0 -1
  376. package/dist/agents/middlewareAgent/middlewares/hitl.js +0 -234
  377. package/dist/agents/middlewareAgent/middlewares/hitl.js.map +0 -1
  378. package/dist/agents/middlewareAgent/middlewares/index.cjs +0 -8
  379. package/dist/agents/middlewareAgent/middlewares/index.d.cts +0 -4
  380. package/dist/agents/middlewareAgent/middlewares/index.d.ts +0 -4
  381. package/dist/agents/middlewareAgent/middlewares/index.js +0 -5
  382. package/dist/agents/middlewareAgent/middlewares/promptCaching.cjs.map +0 -1
  383. package/dist/agents/middlewareAgent/middlewares/promptCaching.d.cts.map +0 -1
  384. package/dist/agents/middlewareAgent/middlewares/promptCaching.d.ts.map +0 -1
  385. package/dist/agents/middlewareAgent/middlewares/promptCaching.js.map +0 -1
  386. package/dist/agents/middlewareAgent/middlewares/summarization.cjs.map +0 -1
  387. package/dist/agents/middlewareAgent/middlewares/summarization.d.cts.map +0 -1
  388. package/dist/agents/middlewareAgent/middlewares/summarization.d.ts.map +0 -1
  389. package/dist/agents/middlewareAgent/middlewares/summarization.js.map +0 -1
  390. package/dist/chains/openai_functions/structured_output.cjs +0 -107
  391. package/dist/chains/openai_functions/structured_output.cjs.map +0 -1
  392. package/dist/chains/openai_functions/structured_output.d.cts +0 -38
  393. package/dist/chains/openai_functions/structured_output.d.cts.map +0 -1
  394. package/dist/chains/openai_functions/structured_output.d.ts +0 -38
  395. package/dist/chains/openai_functions/structured_output.d.ts.map +0 -1
  396. package/dist/chains/openai_functions/structured_output.js +0 -105
  397. package/dist/chains/openai_functions/structured_output.js.map +0 -1
  398. package/dist/chains/openai_moderation.cjs +0 -107
  399. package/dist/chains/openai_moderation.cjs.map +0 -1
  400. package/dist/chains/openai_moderation.d.cts +0 -74
  401. package/dist/chains/openai_moderation.d.cts.map +0 -1
  402. package/dist/chains/openai_moderation.d.ts +0 -74
  403. package/dist/chains/openai_moderation.d.ts.map +0 -1
  404. package/dist/chains/openai_moderation.js +0 -106
  405. package/dist/chains/openai_moderation.js.map +0 -1
@@ -0,0 +1,419 @@
1
+ import { AgentMiddleware } from "../types.cjs";
2
+ import { InferInteropZodInput } from "@langchain/core/utils/types";
3
+ import { z } from "zod/v3";
4
+
5
+ //#region src/agents/middlewareAgent/middleware/hitl.d.ts
6
+ declare const ToolConfigSchema: z.ZodObject<{
7
+ /**
8
+ * Whether the human can approve the current action without changes
9
+ */
10
+ allowAccept: z.ZodOptional<z.ZodBoolean>;
11
+ /**
12
+ * Whether the human can reject the current action with feedback
13
+ */
14
+ allowEdit: z.ZodOptional<z.ZodBoolean>;
15
+ /**
16
+ * Whether the human can approve the current action with edited content
17
+ */
18
+ allowRespond: z.ZodOptional<z.ZodBoolean>;
19
+ /**
20
+ * The description attached to the request for human input
21
+ */
22
+ description: z.ZodOptional<z.ZodString>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ allowAccept?: boolean | undefined;
25
+ allowEdit?: boolean | undefined;
26
+ allowRespond?: boolean | undefined;
27
+ description?: string | undefined;
28
+ }, {
29
+ allowAccept?: boolean | undefined;
30
+ allowEdit?: boolean | undefined;
31
+ allowRespond?: boolean | undefined;
32
+ description?: string | undefined;
33
+ }>;
34
+ type ToolConfigSchema = z.input<typeof ToolConfigSchema>;
35
+ /**
36
+ * Represents information about an interrupt.
37
+ */
38
+
39
+ /**
40
+ * Configuration that defines which reviewer response types are permitted during a human interrupt.
41
+ * These flags control what the human reviewer may do (e.g., accept/edit/respond),
42
+ * not the tool action the agent has requested.
43
+ */
44
+ interface HumanInTheLoopConfig extends Omit<ToolConfigSchema, "description"> {}
45
+ /**
46
+ * Describes the agent-requested tool action (name and arguments).
47
+ * This is what the AI intends to execute, subject to human review.
48
+ */
49
+ interface ActionRequest {
50
+ /**
51
+ * The tool/action name requested by the agent (e.g., "send_email").
52
+ */
53
+ action: string;
54
+ /**
55
+ * Arguments for the requested tool call (e.g., {"a": 1, "b": 2}).
56
+ */
57
+ args: Record<string, any>;
58
+ }
59
+ /**
60
+ * Represents an interrupt triggered by the graph that requires human intervention
61
+ * to approve, edit, or respond to an agent-requested tool action.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const hitlRequest: HumanInTheLoopRequest = {
66
+ * actionRequest: { action: "Approve XYZ action", args: { ... } },
67
+ * config: { allowAccept: true, allowEdit: true, allowRespond: true },
68
+ * description: "Please review the command before execution"
69
+ * };
70
+ * response = interrupt([request])[0]
71
+ * ```
72
+ */
73
+ interface HumanInTheLoopRequest {
74
+ /**
75
+ * The agent-requested tool action to be reviewed.
76
+ */
77
+ actionRequest: ActionRequest;
78
+ /**
79
+ * Which reviewer responses are allowed (accept/edit/respond).
80
+ */
81
+ config: HumanInTheLoopConfig;
82
+ /**
83
+ * Optional human-facing description shown in the approval prompt.
84
+ */
85
+ description?: string;
86
+ }
87
+ /**
88
+ * Response when a human approves the agent-requested action.
89
+ */
90
+ interface AcceptPayload {
91
+ type: "accept";
92
+ }
93
+ /**
94
+ * Response when a human provides a manual response instead of executing
95
+ * the agent-requested action.
96
+ */
97
+ interface ResponsePayload {
98
+ type: "response";
99
+ args?: string;
100
+ }
101
+ /**
102
+ * Response when a human edits the agent-requested action (tool name and/or args).
103
+ */
104
+ interface EditPayload {
105
+ type: "edit";
106
+ args: ActionRequest;
107
+ }
108
+ type HumanInTheLoopMiddlewareHumanResponse = AcceptPayload | ResponsePayload | EditPayload;
109
+ /**
110
+ * Configuration for a tool requiring human in the loop.
111
+ */
112
+
113
+ declare const contextSchema: z.ZodObject<{
114
+ /**
115
+ * Mapping of tool name to allowed reviewer responses.
116
+ * If a tool doesn't have an entry, it's auto-approved by default.
117
+ *
118
+ * - `true` -> pause for approval and allow accept/edit/respond
119
+ * - `false` -> auto-approve (no human review)
120
+ * - `ToolConfig` -> explicitly specify which reviewer responses are allowed for this tool
121
+ */
122
+ interruptOn: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
123
+ /**
124
+ * Whether the human can approve the current action without changes
125
+ */
126
+ allowAccept: z.ZodOptional<z.ZodBoolean>;
127
+ /**
128
+ * Whether the human can reject the current action with feedback
129
+ */
130
+ allowEdit: z.ZodOptional<z.ZodBoolean>;
131
+ /**
132
+ * Whether the human can approve the current action with edited content
133
+ */
134
+ allowRespond: z.ZodOptional<z.ZodBoolean>;
135
+ /**
136
+ * The description attached to the request for human input
137
+ */
138
+ description: z.ZodOptional<z.ZodString>;
139
+ }, "strip", z.ZodTypeAny, {
140
+ allowAccept?: boolean | undefined;
141
+ allowEdit?: boolean | undefined;
142
+ allowRespond?: boolean | undefined;
143
+ description?: string | undefined;
144
+ }, {
145
+ allowAccept?: boolean | undefined;
146
+ allowEdit?: boolean | undefined;
147
+ allowRespond?: boolean | undefined;
148
+ description?: string | undefined;
149
+ }>]>>>;
150
+ /**
151
+ * Prefix used when constructing human-facing approval messages.
152
+ * Provides context about the tool call being reviewed; does not change the underlying action.
153
+ *
154
+ * Note: This prefix is only applied for tools that do not provide a custom
155
+ * `description` via their {@link ToolConfig}. If a tool specifies a custom
156
+ * `description`, that per-tool text is used and this prefix is ignored.
157
+ */
158
+ descriptionPrefix: z.ZodDefault<z.ZodString>;
159
+ }, "strip", z.ZodTypeAny, {
160
+ interruptOn?: Record<string, boolean | {
161
+ allowAccept?: boolean | undefined;
162
+ allowEdit?: boolean | undefined;
163
+ allowRespond?: boolean | undefined;
164
+ description?: string | undefined;
165
+ }> | undefined;
166
+ descriptionPrefix: string;
167
+ }, {
168
+ interruptOn?: Record<string, boolean | {
169
+ allowAccept?: boolean | undefined;
170
+ allowEdit?: boolean | undefined;
171
+ allowRespond?: boolean | undefined;
172
+ description?: string | undefined;
173
+ }> | undefined;
174
+ descriptionPrefix?: string | undefined;
175
+ }>;
176
+ type HumanInTheLoopMiddlewareConfig = InferInteropZodInput<typeof contextSchema>;
177
+ /**
178
+ * Creates a Human-in-the-Loop (HITL) middleware for tool approval and oversight.
179
+ *
180
+ * This middleware intercepts tool calls made by an AI agent and provides human oversight
181
+ * capabilities before execution. It enables selective approval workflows where certain tools
182
+ * require human intervention while others can execute automatically.
183
+ *
184
+ * A invocation result that has been interrupted by the middleware will have a `__interrupt__`
185
+ * property that contains the interrupt request. You can loop over the request to determine
186
+ * which tools were interrupted, and how to handle them separately.
187
+ *
188
+ * ```ts
189
+ * import { type ToolApprovalRequest, type HumanInTheLoopMiddlewareHumanResponse } from "langchain/middleware";
190
+ * import { type Interrupt } from "langchain";
191
+ *
192
+ * const result = await agent.invoke(request);
193
+ * const interruptRequest = initialResult.__interrupt__?.[0] as Interrupt<
194
+ * ToolApprovalRequest[]
195
+ * >;
196
+ * const resume: HumanInTheLoopMiddlewareHumanResponse[] =
197
+ * interruptRequest.value.map((request) => {
198
+ * if (request.action === "calculator") {
199
+ * return { id: request.toolCallId, type: "accept" };
200
+ * } else if (request.action === "write_file") {
201
+ * return {
202
+ * id: request.toolCallId,
203
+ * type: "edit",
204
+ * args: { filename: "safe.txt", content: "Safe content" },
205
+ * };
206
+ * }
207
+ *
208
+ * throw new Error(`Unknown action: ${request.action}`);
209
+ * });
210
+ *
211
+ * // Resume with approval
212
+ * await agent.invoke(new Command({ resume }), config);
213
+ * ```
214
+ *
215
+ * ## Features
216
+ *
217
+ * - **Selective Tool Approval**: Configure which tools require human approval
218
+ * - **Multiple Response Types**: Accept, edit, ignore, or manually respond to tool calls
219
+ * - **Asynchronous Workflow**: Uses LangGraph's interrupt mechanism for non-blocking approval
220
+ * - **Custom Approval Messages**: Provide context-specific descriptions for approval requests
221
+ *
222
+ * ## Response Types
223
+ *
224
+ * When a tool requires approval, the human operator can respond with:
225
+ * - `accept`: Execute the tool with original arguments
226
+ * - `edit`: Modify the tool arguments before execution
227
+ * - `ignore`: Skip the tool and terminate the agent
228
+ * - `response`: Provide a manual response instead of executing the tool
229
+ *
230
+ * @param options - Configuration options for the middleware
231
+ * @param options.interruptOn - Per-tool configuration mapping tool names to their settings
232
+ * @param options.interruptOn[toolName].allowAccept - Whether the human can approve the current action without changes
233
+ * @param options.interruptOn[toolName].allowEdit - Whether the human can reject the current action with feedback
234
+ * @param options.interruptOn[toolName].allowRespond - Whether the human can approve the current action with edited content
235
+ * @param options.interruptOn[toolName].description - Custom approval message for the tool
236
+ * @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.
237
+ *
238
+ * @returns A middleware instance that can be passed to `createAgent`
239
+ *
240
+ * @example
241
+ * Basic usage with selective tool approval
242
+ * ```typescript
243
+ * import { humanInTheLoopMiddleware } from "langchain/middleware";
244
+ * import { createAgent } from "langchain";
245
+ *
246
+ * const hitlMiddleware = humanInTheLoopMiddleware({
247
+ * interruptOn: {
248
+ * // Interrupt write_file tool and allow edits or accepts
249
+ * "write_file": {
250
+ * allowEdit: true,
251
+ * allowAccept: true,
252
+ * description: "⚠️ File write operation requires approval"
253
+ * },
254
+ * // Auto-approve read_file tool
255
+ * "read_file": false
256
+ * }
257
+ * });
258
+ *
259
+ * const agent = createAgent({
260
+ * model: "openai:gpt-4",
261
+ * tools: [writeFileTool, readFileTool],
262
+ * middleware: [hitlMiddleware]
263
+ * });
264
+ * ```
265
+ *
266
+ * @example
267
+ * Handling approval requests
268
+ * ```typescript
269
+ * import { type HumanInTheLoopRequest, type Interrupt } from "langchain/middleware";
270
+ * import { Command } from "@langchain/langgraph";
271
+ *
272
+ * // Initial agent invocation
273
+ * const result = await agent.invoke({
274
+ * messages: [new HumanMessage("Write 'Hello' to output.txt")]
275
+ * }, config);
276
+ *
277
+ * // Check if agent is paused for approval
278
+ * if (result.__interrupt__) {
279
+ * const interruptRequest = initialResult.__interrupt__?.[0] as Interrupt<
280
+ * HumanInTheLoopRequest[]
281
+ * >;
282
+ *
283
+ * // Show tool call details to user
284
+ * console.log("Tool:", interruptRequest.value[0].actionRequest);
285
+ * console.log("Allowed actions:", interruptRequest.value[0].config);
286
+ *
287
+ * // Resume with approval
288
+ * await agent.invoke(
289
+ * new Command({ resume: [{ type: "accept" }] }),
290
+ * config
291
+ * );
292
+ * }
293
+ * ```
294
+ *
295
+ * @example
296
+ * Different response types
297
+ * ```typescript
298
+ * // Accept the tool call as-is
299
+ * new Command({ resume: [{ type: "accept" }] })
300
+ *
301
+ * // Edit the tool arguments
302
+ * new Command({
303
+ * resume: [{
304
+ * type: "edit",
305
+ * args: { action: "write_file", args: { filename: "safe.txt", content: "Modified" } }
306
+ * }]
307
+ * })
308
+ *
309
+ * // Skip tool and terminate agent
310
+ * new Command({ resume: [{ type: "response" }] })
311
+ *
312
+ * // Provide manual response
313
+ * new Command({
314
+ * resume: [{
315
+ * type: "response",
316
+ * // this must be a string
317
+ * args: "File operation not allowed in demo mode"
318
+ * }]
319
+ * })
320
+ * ```
321
+ *
322
+ * @example
323
+ * Production use case with database operations
324
+ * ```typescript
325
+ * const hitlMiddleware = humanInTheLoopMiddleware({
326
+ * interruptOn: {
327
+ * "execute_sql": {
328
+ * allowAccept: true,
329
+ * allowEdit: true,
330
+ * allowRespond: true,
331
+ * description: "🚨 SQL query requires DBA approval\nPlease review for safety and performance"
332
+ * },
333
+ * "read_schema": false // Reading metadata is safe
334
+ * "delete_records": {
335
+ * allowAccept: true,
336
+ * description: "⛔ DESTRUCTIVE OPERATION - Requires manager approval"
337
+ * }
338
+ * },
339
+ * messagePrefix: "Database operation pending approval"
340
+ * });
341
+ * ```
342
+ *
343
+ * @remarks
344
+ * - Tool calls are processed in the order they appear in the AI message
345
+ * - Auto-approved tools execute immediately without interruption
346
+ * - Multiple tools requiring approval are bundled into a single interrupt
347
+ * - The middleware operates in the `afterModel` phase, intercepting before tool execution
348
+ * - Requires a checkpointer to maintain state across interruptions
349
+ *
350
+ * @see {@link createAgent} for agent creation
351
+ * @see {@link Command} for resuming interrupted execution
352
+ * @public
353
+ */
354
+ declare function humanInTheLoopMiddleware(options: NonNullable<HumanInTheLoopMiddlewareConfig>): AgentMiddleware<undefined, z.ZodObject<{
355
+ /**
356
+ * Mapping of tool name to allowed reviewer responses.
357
+ * If a tool doesn't have an entry, it's auto-approved by default.
358
+ *
359
+ * - `true` -> pause for approval and allow accept/edit/respond
360
+ * - `false` -> auto-approve (no human review)
361
+ * - `ToolConfig` -> explicitly specify which reviewer responses are allowed for this tool
362
+ */
363
+ interruptOn: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
364
+ /**
365
+ * Whether the human can approve the current action without changes
366
+ */
367
+ allowAccept: z.ZodOptional<z.ZodBoolean>;
368
+ /**
369
+ * Whether the human can reject the current action with feedback
370
+ */
371
+ allowEdit: z.ZodOptional<z.ZodBoolean>;
372
+ /**
373
+ * Whether the human can approve the current action with edited content
374
+ */
375
+ allowRespond: z.ZodOptional<z.ZodBoolean>;
376
+ /**
377
+ * The description attached to the request for human input
378
+ */
379
+ description: z.ZodOptional<z.ZodString>;
380
+ }, "strip", z.ZodTypeAny, {
381
+ allowAccept?: boolean | undefined;
382
+ allowEdit?: boolean | undefined;
383
+ allowRespond?: boolean | undefined;
384
+ description?: string | undefined;
385
+ }, {
386
+ allowAccept?: boolean | undefined;
387
+ allowEdit?: boolean | undefined;
388
+ allowRespond?: boolean | undefined;
389
+ description?: string | undefined;
390
+ }>]>>>;
391
+ /**
392
+ * Prefix used when constructing human-facing approval messages.
393
+ * Provides context about the tool call being reviewed; does not change the underlying action.
394
+ *
395
+ * Note: This prefix is only applied for tools that do not provide a custom
396
+ * `description` via their {@link ToolConfig}. If a tool specifies a custom
397
+ * `description`, that per-tool text is used and this prefix is ignored.
398
+ */
399
+ descriptionPrefix: z.ZodDefault<z.ZodString>;
400
+ }, "strip", z.ZodTypeAny, {
401
+ interruptOn?: Record<string, boolean | {
402
+ allowAccept?: boolean | undefined;
403
+ allowEdit?: boolean | undefined;
404
+ allowRespond?: boolean | undefined;
405
+ description?: string | undefined;
406
+ }> | undefined;
407
+ descriptionPrefix: string;
408
+ }, {
409
+ interruptOn?: Record<string, boolean | {
410
+ allowAccept?: boolean | undefined;
411
+ allowEdit?: boolean | undefined;
412
+ allowRespond?: boolean | undefined;
413
+ description?: string | undefined;
414
+ }> | undefined;
415
+ descriptionPrefix?: string | undefined;
416
+ }>, any>;
417
+ //#endregion
418
+ export { ActionRequest, HumanInTheLoopMiddlewareConfig, HumanInTheLoopMiddlewareHumanResponse, HumanInTheLoopRequest, humanInTheLoopMiddleware };
419
+ //# sourceMappingURL=hitl.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hitl.d.cts","names":["z","InferInteropZodInput","ToolConfigSchema","ZodBoolean","ZodOptional","ZodString","ZodTypeAny","ZodObject","input","Interrupt","TValue","HumanInTheLoopConfig","Omit","ActionRequest","Record","HumanInTheLoopRequest","AcceptPayload","ResponsePayload","EditPayload","HumanInTheLoopMiddlewareHumanResponse","ToolConfig","contextSchema","ZodUnion","ZodRecord","ZodDefault","HumanInTheLoopMiddlewareConfig","humanInTheLoopMiddleware","NonNullable","___types_js0","AgentMiddleware"],"sources":["../../../../src/agents/middlewareAgent/middleware/hitl.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { InferInteropZodInput } from \"@langchain/core/utils/types\";\ndeclare const ToolConfigSchema: z.ZodObject<{\n /**\n * Whether the human can approve the current action without changes\n */\n allowAccept: z.ZodOptional<z.ZodBoolean>;\n /**\n * Whether the human can reject the current action with feedback\n */\n allowEdit: z.ZodOptional<z.ZodBoolean>;\n /**\n * Whether the human can approve the current action with edited content\n */\n allowRespond: z.ZodOptional<z.ZodBoolean>;\n /**\n * The description attached to the request for human input\n */\n description: z.ZodOptional<z.ZodString>;\n}, \"strip\", z.ZodTypeAny, {\n allowAccept?: boolean | undefined;\n allowEdit?: boolean | undefined;\n allowRespond?: boolean | undefined;\n description?: string | undefined;\n}, {\n allowAccept?: boolean | undefined;\n allowEdit?: boolean | undefined;\n allowRespond?: boolean | undefined;\n description?: string | undefined;\n}>;\ntype ToolConfigSchema = z.input<typeof ToolConfigSchema>;\n/**\n * Represents information about an interrupt.\n */\nexport interface Interrupt<TValue = unknown> {\n /**\n * The ID of the interrupt.\n */\n id: string;\n /**\n * The requests for human input.\n */\n value: TValue;\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 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 * 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 * Response when a human approves the agent-requested action.\n */\nexport interface AcceptPayload {\n type: \"accept\";\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 * 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}\nexport type HumanInTheLoopMiddlewareHumanResponse = AcceptPayload | ResponsePayload | EditPayload;\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 */\n description?: string;\n}\ndeclare const contextSchema: z.ZodObject<{\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.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodBoolean, z.ZodObject<{\n /**\n * Whether the human can approve the current action without changes\n */\n allowAccept: z.ZodOptional<z.ZodBoolean>;\n /**\n * Whether the human can reject the current action with feedback\n */\n allowEdit: z.ZodOptional<z.ZodBoolean>;\n /**\n * Whether the human can approve the current action with edited content\n */\n allowRespond: z.ZodOptional<z.ZodBoolean>;\n /**\n * The description attached to the request for human input\n */\n description: z.ZodOptional<z.ZodString>;\n }, \"strip\", z.ZodTypeAny, {\n allowAccept?: boolean | undefined;\n allowEdit?: boolean | undefined;\n allowRespond?: boolean | undefined;\n description?: string | undefined;\n }, {\n allowAccept?: boolean | undefined;\n allowEdit?: boolean | undefined;\n allowRespond?: boolean | undefined;\n description?: string | undefined;\n }>]>>>;\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.ZodDefault<z.ZodString>;\n}, \"strip\", z.ZodTypeAny, {\n interruptOn?: Record<string, boolean | {\n allowAccept?: boolean | undefined;\n allowEdit?: boolean | undefined;\n allowRespond?: boolean | undefined;\n description?: string | undefined;\n }> | undefined;\n descriptionPrefix: string;\n}, {\n interruptOn?: Record<string, boolean | {\n allowAccept?: boolean | undefined;\n allowEdit?: boolean | undefined;\n allowRespond?: boolean | undefined;\n description?: string | undefined;\n }> | undefined;\n descriptionPrefix?: string | undefined;\n}>;\nexport type HumanInTheLoopMiddlewareConfig = InferInteropZodInput<typeof contextSchema>;\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/middleware\";\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\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/middleware\";\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/middleware\";\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 * @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 declare function humanInTheLoopMiddleware(options: NonNullable<HumanInTheLoopMiddlewareConfig>): import(\"../types.js\").AgentMiddleware<undefined, z.ZodObject<{\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.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodBoolean, z.ZodObject<{\n /**\n * Whether the human can approve the current action without changes\n */\n allowAccept: z.ZodOptional<z.ZodBoolean>;\n /**\n * Whether the human can reject the current action with feedback\n */\n allowEdit: z.ZodOptional<z.ZodBoolean>;\n /**\n * Whether the human can approve the current action with edited content\n */\n allowRespond: z.ZodOptional<z.ZodBoolean>;\n /**\n * The description attached to the request for human input\n */\n description: z.ZodOptional<z.ZodString>;\n }, \"strip\", z.ZodTypeAny, {\n allowAccept?: boolean | undefined;\n allowEdit?: boolean | undefined;\n allowRespond?: boolean | undefined;\n description?: string | undefined;\n }, {\n allowAccept?: boolean | undefined;\n allowEdit?: boolean | undefined;\n allowRespond?: boolean | undefined;\n description?: string | undefined;\n }>]>>>;\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.ZodDefault<z.ZodString>;\n}, \"strip\", z.ZodTypeAny, {\n interruptOn?: Record<string, boolean | {\n allowAccept?: boolean | undefined;\n allowEdit?: boolean | undefined;\n allowRespond?: boolean | undefined;\n description?: string | undefined;\n }> | undefined;\n descriptionPrefix: string;\n}, {\n interruptOn?: Record<string, boolean | {\n allowAccept?: boolean | undefined;\n allowEdit?: boolean | undefined;\n allowRespond?: boolean | undefined;\n description?: string | undefined;\n }> | undefined;\n descriptionPrefix?: string | undefined;\n}>, any>;\nexport {};\n"],"mappings":"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"}