langchain 1.0.0-alpha.5 → 1.0.0-alpha.6

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 (351) 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 +1 -3
  4. package/dist/agents/ReactAgent.d.cts.map +1 -1
  5. package/dist/agents/ReactAgent.d.ts +1 -3
  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 +4 -6
  11. package/dist/agents/annotation.d.cts.map +1 -1
  12. package/dist/agents/annotation.d.ts +4 -6
  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 +47 -47
  20. package/dist/agents/index.d.cts.map +1 -1
  21. package/dist/agents/index.d.ts +47 -47
  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/middlewareAgent/ReactAgent.cjs +18 -18
  26. package/dist/agents/middlewareAgent/ReactAgent.cjs.map +1 -1
  27. package/dist/agents/middlewareAgent/ReactAgent.d.cts +8 -9
  28. package/dist/agents/middlewareAgent/ReactAgent.d.cts.map +1 -1
  29. package/dist/agents/middlewareAgent/ReactAgent.d.ts +8 -9
  30. package/dist/agents/middlewareAgent/ReactAgent.d.ts.map +1 -1
  31. package/dist/agents/middlewareAgent/ReactAgent.js +18 -18
  32. package/dist/agents/middlewareAgent/ReactAgent.js.map +1 -1
  33. package/dist/agents/middlewareAgent/annotation.cjs +2 -2
  34. package/dist/agents/middlewareAgent/annotation.cjs.map +1 -1
  35. package/dist/agents/middlewareAgent/annotation.js +2 -2
  36. package/dist/agents/middlewareAgent/annotation.js.map +1 -1
  37. package/dist/agents/middlewareAgent/index.cjs.map +1 -1
  38. package/dist/agents/middlewareAgent/index.js.map +1 -1
  39. package/dist/agents/middlewareAgent/{middlewares → middleware}/hitl.cjs +8 -8
  40. package/dist/agents/middlewareAgent/middleware/hitl.cjs.map +1 -0
  41. package/dist/agents/middlewareAgent/{middlewares → middleware}/hitl.d.cts +3 -3
  42. package/dist/agents/middlewareAgent/middleware/hitl.d.cts.map +1 -0
  43. package/dist/agents/middlewareAgent/{middlewares → middleware}/hitl.d.ts +3 -3
  44. package/dist/agents/middlewareAgent/middleware/hitl.d.ts.map +1 -0
  45. package/dist/agents/middlewareAgent/{middlewares → middleware}/hitl.js +3 -3
  46. package/dist/agents/middlewareAgent/middleware/hitl.js.map +1 -0
  47. package/dist/agents/middlewareAgent/middleware/index.cjs +26 -0
  48. package/dist/agents/middlewareAgent/middleware/index.cjs.map +1 -0
  49. package/dist/agents/middlewareAgent/middleware/index.js +17 -0
  50. package/dist/agents/middlewareAgent/middleware/index.js.map +1 -0
  51. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.cjs +51 -22
  52. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs.map +1 -0
  53. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.cts +9 -9
  54. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts.map +1 -0
  55. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.ts +9 -9
  56. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts.map +1 -0
  57. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.js +50 -21
  58. package/dist/agents/middlewareAgent/middleware/promptCaching.js.map +1 -0
  59. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.cjs +11 -11
  60. package/dist/agents/middlewareAgent/middleware/summarization.cjs.map +1 -0
  61. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.cts +3 -3
  62. package/dist/agents/middlewareAgent/middleware/summarization.d.cts.map +1 -0
  63. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.ts +10 -10
  64. package/dist/agents/middlewareAgent/{middlewares/summarization.d.cts.map → middleware/summarization.d.ts.map} +1 -1
  65. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.js +4 -4
  66. package/dist/agents/middlewareAgent/middleware/summarization.js.map +1 -0
  67. package/dist/agents/middlewareAgent/middleware.cjs.map +1 -1
  68. package/dist/agents/middlewareAgent/middleware.d.cts +1 -1
  69. package/dist/agents/middlewareAgent/middleware.d.cts.map +1 -1
  70. package/dist/agents/middlewareAgent/middleware.d.ts +1 -1
  71. package/dist/agents/middlewareAgent/middleware.d.ts.map +1 -1
  72. package/dist/agents/middlewareAgent/middleware.js.map +1 -1
  73. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs.map +1 -1
  74. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js.map +1 -1
  75. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs +12 -19
  76. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs.map +1 -1
  77. package/dist/agents/middlewareAgent/nodes/AgentNode.js +12 -19
  78. package/dist/agents/middlewareAgent/nodes/AgentNode.js.map +1 -1
  79. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs.map +1 -1
  80. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js.map +1 -1
  81. package/dist/agents/middlewareAgent/nodes/middleware.cjs.map +1 -1
  82. package/dist/agents/middlewareAgent/nodes/middleware.js.map +1 -1
  83. package/dist/agents/middlewareAgent/nodes/utils.cjs +7 -7
  84. package/dist/agents/middlewareAgent/nodes/utils.cjs.map +1 -1
  85. package/dist/agents/middlewareAgent/nodes/utils.js +3 -3
  86. package/dist/agents/middlewareAgent/nodes/utils.js.map +1 -1
  87. package/dist/agents/middlewareAgent/types.d.cts +10 -23
  88. package/dist/agents/middlewareAgent/types.d.cts.map +1 -1
  89. package/dist/agents/middlewareAgent/types.d.ts +10 -23
  90. package/dist/agents/middlewareAgent/types.d.ts.map +1 -1
  91. package/dist/agents/nodes/AgentNode.cjs +4 -4
  92. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  93. package/dist/agents/nodes/AgentNode.js +4 -4
  94. package/dist/agents/nodes/AgentNode.js.map +1 -1
  95. package/dist/agents/nodes/ToolNode.cjs +3 -3
  96. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  97. package/dist/agents/nodes/ToolNode.d.cts +1 -2
  98. package/dist/agents/nodes/ToolNode.d.cts.map +1 -1
  99. package/dist/agents/nodes/ToolNode.d.ts +1 -2
  100. package/dist/agents/nodes/ToolNode.d.ts.map +1 -1
  101. package/dist/agents/nodes/ToolNode.js +4 -4
  102. package/dist/agents/nodes/ToolNode.js.map +1 -1
  103. package/dist/agents/responses.cjs +1 -1
  104. package/dist/agents/responses.cjs.map +1 -1
  105. package/dist/agents/responses.d.cts.map +1 -1
  106. package/dist/agents/responses.d.ts.map +1 -1
  107. package/dist/agents/responses.js +1 -1
  108. package/dist/agents/responses.js.map +1 -1
  109. package/dist/agents/types.d.cts +1 -3
  110. package/dist/agents/types.d.cts.map +1 -1
  111. package/dist/agents/types.d.ts +1 -3
  112. package/dist/agents/types.d.ts.map +1 -1
  113. package/dist/agents/utils.cjs +6 -6
  114. package/dist/agents/utils.cjs.map +1 -1
  115. package/dist/agents/utils.js +7 -7
  116. package/dist/agents/utils.js.map +1 -1
  117. package/dist/agents/withAgentName.cjs.map +1 -1
  118. package/dist/agents/withAgentName.js.map +1 -1
  119. package/dist/chains/api/prompts.cjs.map +1 -1
  120. package/dist/chains/api/prompts.js.map +1 -1
  121. package/dist/chains/constitutional_ai/constitutional_chain.cjs.map +1 -1
  122. package/dist/chains/constitutional_ai/constitutional_chain.js.map +1 -1
  123. package/dist/chains/index.cjs +0 -3
  124. package/dist/chains/index.cjs.map +1 -1
  125. package/dist/chains/index.d.cts +1 -2
  126. package/dist/chains/index.d.ts +1 -2
  127. package/dist/chains/index.js +1 -3
  128. package/dist/chains/index.js.map +1 -1
  129. package/dist/chains/openai_functions/extraction.cjs.map +1 -1
  130. package/dist/chains/openai_functions/extraction.d.cts +1 -3
  131. package/dist/chains/openai_functions/extraction.d.cts.map +1 -1
  132. package/dist/chains/openai_functions/extraction.d.ts +1 -3
  133. package/dist/chains/openai_functions/extraction.d.ts.map +1 -1
  134. package/dist/chains/openai_functions/extraction.js.map +1 -1
  135. package/dist/chains/openai_functions/index.cjs +0 -5
  136. package/dist/chains/openai_functions/index.cjs.map +1 -1
  137. package/dist/chains/openai_functions/index.d.cts +1 -2
  138. package/dist/chains/openai_functions/index.d.ts +1 -2
  139. package/dist/chains/openai_functions/index.js +1 -4
  140. package/dist/chains/openai_functions/index.js.map +1 -1
  141. package/dist/chains/openai_functions/openapi.cjs +4 -4
  142. package/dist/chains/openai_functions/openapi.cjs.map +1 -1
  143. package/dist/chains/openai_functions/openapi.d.cts +1 -1
  144. package/dist/chains/openai_functions/openapi.js +4 -4
  145. package/dist/chains/openai_functions/openapi.js.map +1 -1
  146. package/dist/chains/openai_functions/tagging.cjs.map +1 -1
  147. package/dist/chains/openai_functions/tagging.d.cts +1 -3
  148. package/dist/chains/openai_functions/tagging.d.cts.map +1 -1
  149. package/dist/chains/openai_functions/tagging.d.ts +1 -3
  150. package/dist/chains/openai_functions/tagging.d.ts.map +1 -1
  151. package/dist/chains/openai_functions/tagging.js.map +1 -1
  152. package/dist/chains/query_constructor/index.cjs +4 -4
  153. package/dist/chains/query_constructor/index.cjs.map +1 -1
  154. package/dist/chains/query_constructor/index.d.cts +4 -2
  155. package/dist/chains/query_constructor/index.d.cts.map +1 -1
  156. package/dist/chains/query_constructor/index.d.ts +4 -2
  157. package/dist/chains/query_constructor/index.d.ts.map +1 -1
  158. package/dist/chains/query_constructor/index.js +1 -1
  159. package/dist/chains/query_constructor/index.js.map +1 -1
  160. package/dist/chains/question_answering/load.d.ts +2 -2
  161. package/dist/chains/question_answering/load.d.ts.map +1 -1
  162. package/dist/chains/question_answering/map_reduce_prompts.cjs.map +1 -1
  163. package/dist/chains/question_answering/map_reduce_prompts.js.map +1 -1
  164. package/dist/chains/question_answering/refine_prompts.cjs.map +1 -1
  165. package/dist/chains/question_answering/refine_prompts.js.map +1 -1
  166. package/dist/chains/question_answering/stuff_prompts.cjs.map +1 -1
  167. package/dist/chains/question_answering/stuff_prompts.js.map +1 -1
  168. package/dist/chains/router/multi_prompt.cjs +4 -4
  169. package/dist/chains/router/multi_prompt.cjs.map +1 -1
  170. package/dist/chains/router/multi_prompt.js +1 -1
  171. package/dist/chains/router/multi_prompt.js.map +1 -1
  172. package/dist/chains/router/multi_retrieval_qa.cjs +4 -4
  173. package/dist/chains/router/multi_retrieval_qa.cjs.map +1 -1
  174. package/dist/chains/router/multi_retrieval_qa.js +1 -1
  175. package/dist/chains/router/multi_retrieval_qa.js.map +1 -1
  176. package/dist/chains/sql_db/sql_db_prompt.cjs.map +1 -1
  177. package/dist/chains/sql_db/sql_db_prompt.d.cts.map +1 -1
  178. package/dist/chains/sql_db/sql_db_prompt.d.ts.map +1 -1
  179. package/dist/chains/sql_db/sql_db_prompt.js.map +1 -1
  180. package/dist/chains/summarization/load.d.ts +2 -2
  181. package/dist/chains/summarization/load.d.ts.map +1 -1
  182. package/dist/chains/summarization/stuff_prompts.cjs.map +1 -1
  183. package/dist/chains/summarization/stuff_prompts.js.map +1 -1
  184. package/dist/chat_models/universal.cjs +8 -5
  185. package/dist/chat_models/universal.cjs.map +1 -1
  186. package/dist/chat_models/universal.d.cts +2 -2
  187. package/dist/chat_models/universal.d.cts.map +1 -1
  188. package/dist/chat_models/universal.d.ts +2 -2
  189. package/dist/chat_models/universal.d.ts.map +1 -1
  190. package/dist/chat_models/universal.js +8 -5
  191. package/dist/chat_models/universal.js.map +1 -1
  192. package/dist/document_loaders/fs/directory.cjs.map +1 -1
  193. package/dist/document_loaders/fs/directory.d.cts +0 -1
  194. package/dist/document_loaders/fs/directory.d.cts.map +1 -1
  195. package/dist/document_loaders/fs/directory.d.ts +0 -1
  196. package/dist/document_loaders/fs/directory.d.ts.map +1 -1
  197. package/dist/document_loaders/fs/directory.js.map +1 -1
  198. package/dist/document_loaders/fs/json.cjs +7 -1
  199. package/dist/document_loaders/fs/json.cjs.map +1 -1
  200. package/dist/document_loaders/fs/json.js +7 -1
  201. package/dist/document_loaders/fs/json.js.map +1 -1
  202. package/dist/embeddings/cache_backed.cjs +1 -1
  203. package/dist/embeddings/cache_backed.cjs.map +1 -1
  204. package/dist/embeddings/cache_backed.d.cts +1 -1
  205. package/dist/embeddings/cache_backed.d.ts +1 -1
  206. package/dist/embeddings/cache_backed.js +2 -2
  207. package/dist/embeddings/cache_backed.js.map +1 -1
  208. package/dist/evaluation/agents/trajectory.d.cts.map +1 -1
  209. package/dist/evaluation/comparison/pairwise.d.ts.map +1 -1
  210. package/dist/evaluation/criteria/criteria.d.ts.map +1 -1
  211. package/dist/evaluation/embedding_distance/base.cjs +2 -4
  212. package/dist/evaluation/embedding_distance/base.cjs.map +1 -1
  213. package/dist/evaluation/embedding_distance/base.js +2 -3
  214. package/dist/evaluation/embedding_distance/base.js.map +1 -1
  215. package/dist/evaluation/loader.cjs +7 -12
  216. package/dist/evaluation/loader.cjs.map +1 -1
  217. package/dist/evaluation/loader.d.cts +8 -2
  218. package/dist/evaluation/loader.d.cts.map +1 -1
  219. package/dist/evaluation/loader.d.ts +8 -2
  220. package/dist/evaluation/loader.d.ts.map +1 -1
  221. package/dist/evaluation/loader.js +7 -12
  222. package/dist/evaluation/loader.js.map +1 -1
  223. package/dist/hub/base.cjs.map +1 -1
  224. package/dist/hub/base.js.map +1 -1
  225. package/dist/langchain-core/dist/load/serializable.d.cts.map +1 -1
  226. package/dist/langchain-core/dist/messages/base.d.cts +24 -33
  227. package/dist/langchain-core/dist/messages/base.d.cts.map +1 -1
  228. package/dist/langchain-core/dist/messages/content/index.d.cts +1 -1
  229. package/dist/langchain-core/dist/messages/content/index.d.cts.map +1 -1
  230. package/dist/langchain-core/dist/messages/message.d.cts +598 -0
  231. package/dist/langchain-core/dist/messages/message.d.cts.map +1 -0
  232. package/dist/langchain-core/dist/messages/metadata.d.cts +97 -0
  233. package/dist/langchain-core/dist/messages/metadata.d.cts.map +1 -0
  234. package/dist/langchain-core/dist/messages/utils.d.cts +75 -0
  235. package/dist/langchain-core/dist/messages/utils.d.cts.map +1 -0
  236. package/dist/langchain-core/dist/prompt_values.d.cts.map +1 -1
  237. package/dist/libs/langchain-core/dist/load/serializable.d.ts.map +1 -1
  238. package/dist/libs/langchain-core/dist/messages/base.d.ts +24 -33
  239. package/dist/libs/langchain-core/dist/messages/base.d.ts.map +1 -1
  240. package/dist/libs/langchain-core/dist/messages/content/index.d.ts +1 -1
  241. package/dist/libs/langchain-core/dist/messages/content/index.d.ts.map +1 -1
  242. package/dist/libs/langchain-core/dist/messages/message.d.ts +598 -0
  243. package/dist/libs/langchain-core/dist/messages/message.d.ts.map +1 -0
  244. package/dist/libs/langchain-core/dist/messages/metadata.d.ts +97 -0
  245. package/dist/libs/langchain-core/dist/messages/metadata.d.ts.map +1 -0
  246. package/dist/libs/langchain-core/dist/messages/utils.d.ts +75 -0
  247. package/dist/libs/langchain-core/dist/messages/utils.d.ts.map +1 -0
  248. package/dist/libs/langchain-core/dist/prompt_values.d.ts.map +1 -1
  249. package/dist/libs/langchain-core/dist/utils/types/index.d.ts +2 -0
  250. package/dist/libs/langchain-core/dist/utils/types/index.d.ts.map +1 -1
  251. package/dist/libs/langchain-core/dist/utils/types/zod.d.ts +1 -0
  252. package/dist/load/import_map.cjs +3 -14
  253. package/dist/load/import_map.cjs.map +1 -1
  254. package/dist/load/import_map.js +3 -14
  255. package/dist/load/import_map.js.map +1 -1
  256. package/dist/memory/prompt.cjs.map +1 -1
  257. package/dist/memory/prompt.d.cts.map +1 -1
  258. package/dist/memory/prompt.d.ts.map +1 -1
  259. package/dist/memory/prompt.js.map +1 -1
  260. package/dist/output_parsers/combining.cjs +1 -1
  261. package/dist/output_parsers/combining.cjs.map +1 -1
  262. package/dist/output_parsers/combining.js +1 -1
  263. package/dist/output_parsers/combining.js.map +1 -1
  264. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.cjs.map +1 -1
  265. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.js.map +1 -1
  266. package/dist/output_parsers/expression_type_handlers/base.cjs +1 -1
  267. package/dist/output_parsers/expression_type_handlers/base.cjs.map +1 -1
  268. package/dist/output_parsers/expression_type_handlers/base.js +1 -1
  269. package/dist/output_parsers/expression_type_handlers/base.js.map +1 -1
  270. package/dist/output_parsers/regex.cjs.map +1 -1
  271. package/dist/output_parsers/regex.js.map +1 -1
  272. package/dist/output_parsers/structured.cjs +4 -4
  273. package/dist/output_parsers/structured.cjs.map +1 -1
  274. package/dist/output_parsers/structured.d.cts +1 -1
  275. package/dist/output_parsers/structured.d.cts.map +1 -1
  276. package/dist/output_parsers/structured.d.ts +1 -1
  277. package/dist/output_parsers/structured.d.ts.map +1 -1
  278. package/dist/output_parsers/structured.js +2 -2
  279. package/dist/output_parsers/structured.js.map +1 -1
  280. package/dist/retrievers/ensemble.cjs.map +1 -1
  281. package/dist/retrievers/ensemble.js.map +1 -1
  282. package/dist/storage/file_system.cjs +1 -1
  283. package/dist/storage/file_system.cjs.map +1 -1
  284. package/dist/storage/file_system.js +1 -1
  285. package/dist/storage/file_system.js.map +1 -1
  286. package/dist/tools/fs.cjs +5 -5
  287. package/dist/tools/fs.cjs.map +1 -1
  288. package/dist/tools/fs.d.cts +1 -1
  289. package/dist/tools/fs.d.cts.map +1 -1
  290. package/dist/tools/fs.d.ts +1 -1
  291. package/dist/tools/fs.d.ts.map +1 -1
  292. package/dist/tools/fs.js +1 -1
  293. package/dist/tools/fs.js.map +1 -1
  294. package/dist/tools/retriever.cjs +2 -2
  295. package/dist/tools/retriever.cjs.map +1 -1
  296. package/dist/tools/retriever.d.cts +1 -1
  297. package/dist/tools/retriever.d.cts.map +1 -1
  298. package/dist/tools/retriever.d.ts +1 -1
  299. package/dist/tools/retriever.d.ts.map +1 -1
  300. package/dist/tools/retriever.js +1 -1
  301. package/dist/tools/retriever.js.map +1 -1
  302. package/dist/tools/sql.cjs +1 -2
  303. package/dist/tools/sql.cjs.map +1 -1
  304. package/dist/tools/sql.d.cts +1 -1
  305. package/dist/tools/sql.d.cts.map +1 -1
  306. package/dist/tools/sql.d.ts +1 -1
  307. package/dist/tools/sql.d.ts.map +1 -1
  308. package/dist/tools/sql.js +1 -2
  309. package/dist/tools/sql.js.map +1 -1
  310. package/dist/types/expression-parser.d.cts +2 -0
  311. package/dist/types/expression-parser.d.cts.map +1 -1
  312. package/dist/types/expression-parser.d.ts +2 -0
  313. package/dist/types/expression-parser.d.ts.map +1 -1
  314. package/dist/util/hub.cjs +1 -1
  315. package/dist/util/hub.js +1 -1
  316. package/dist/util/openapi.cjs +1 -1
  317. package/dist/util/openapi.cjs.map +1 -1
  318. package/dist/util/openapi.js +1 -1
  319. package/dist/util/openapi.js.map +1 -1
  320. package/package.json +15 -21
  321. package/dist/agents/middlewareAgent/middlewares/hitl.cjs.map +0 -1
  322. package/dist/agents/middlewareAgent/middlewares/hitl.d.cts.map +0 -1
  323. package/dist/agents/middlewareAgent/middlewares/hitl.d.ts.map +0 -1
  324. package/dist/agents/middlewareAgent/middlewares/hitl.js.map +0 -1
  325. package/dist/agents/middlewareAgent/middlewares/index.cjs +0 -8
  326. package/dist/agents/middlewareAgent/middlewares/index.js +0 -5
  327. package/dist/agents/middlewareAgent/middlewares/promptCaching.cjs.map +0 -1
  328. package/dist/agents/middlewareAgent/middlewares/promptCaching.d.cts.map +0 -1
  329. package/dist/agents/middlewareAgent/middlewares/promptCaching.d.ts.map +0 -1
  330. package/dist/agents/middlewareAgent/middlewares/promptCaching.js.map +0 -1
  331. package/dist/agents/middlewareAgent/middlewares/summarization.cjs.map +0 -1
  332. package/dist/agents/middlewareAgent/middlewares/summarization.d.ts.map +0 -1
  333. package/dist/agents/middlewareAgent/middlewares/summarization.js.map +0 -1
  334. package/dist/chains/openai_functions/structured_output.cjs +0 -107
  335. package/dist/chains/openai_functions/structured_output.cjs.map +0 -1
  336. package/dist/chains/openai_functions/structured_output.d.cts +0 -38
  337. package/dist/chains/openai_functions/structured_output.d.cts.map +0 -1
  338. package/dist/chains/openai_functions/structured_output.d.ts +0 -38
  339. package/dist/chains/openai_functions/structured_output.d.ts.map +0 -1
  340. package/dist/chains/openai_functions/structured_output.js +0 -105
  341. package/dist/chains/openai_functions/structured_output.js.map +0 -1
  342. package/dist/chains/openai_moderation.cjs +0 -107
  343. package/dist/chains/openai_moderation.cjs.map +0 -1
  344. package/dist/chains/openai_moderation.d.cts +0 -74
  345. package/dist/chains/openai_moderation.d.cts.map +0 -1
  346. package/dist/chains/openai_moderation.d.ts +0 -74
  347. package/dist/chains/openai_moderation.d.ts.map +0 -1
  348. package/dist/chains/openai_moderation.js +0 -106
  349. package/dist/chains/openai_moderation.js.map +0 -1
  350. /package/dist/agents/middlewareAgent/{middlewares → middleware}/index.d.cts +0 -0
  351. /package/dist/agents/middlewareAgent/{middlewares → middleware}/index.d.ts +0 -0
@@ -22,7 +22,7 @@ import { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
22
22
  * @example
23
23
  * ```ts
24
24
  * import { createAgent, tool } from "langchain";
25
- * import { z } from "zod";
25
+ * import { z } from "zod/v3";
26
26
  *
27
27
  * const getWeather = tool((input) => {
28
28
  * if (["sf", "san francisco"].includes(input.location.toLowerCase())) {
@@ -57,7 +57,7 @@ import { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
57
57
  * ```
58
58
  */
59
59
  // ===== V1 OVERLOADS (WITHOUT MIDDLEWARE) =====
60
- // These overloads come first to ensure proper type inference when middlewares is NOT provided
60
+ // These overloads come first to ensure proper type inference when middleware is NOT provided
61
61
  // Overload 1: V1 - With responseFormat as single InteropZodType
62
62
  declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, InteropZodType<T>> & {
63
63
  responseFormat: InteropZodType<T>;
@@ -101,61 +101,61 @@ declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodO
101
101
  responseFormat: any;
102
102
  }): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema>;
103
103
  // ===== V2 OVERLOADS (WITH MIDDLEWARE) =====
104
- // These overloads explicitly require the middlewares property
105
- // Overload 12: With responseFormat as single InteropZodType and middlewares
106
- declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, InteropZodType<T>> & {
104
+ // These overloads explicitly require the middleware property
105
+ // Overload 12: With responseFormat as single InteropZodType and middleware
106
+ declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, InteropZodType<T>> & {
107
107
  responseFormat: InteropZodType<T>;
108
- middlewares: TMiddlewares;
109
- }): ReactAgent$1<T, ContextSchema, TMiddlewares>;
110
- // Overload 13: With responseFormat as array of InteropZodTypes and middlewares
111
- declare function createAgent<T extends readonly InteropZodType<any>[], ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, T> & {
108
+ middleware: TMiddleware;
109
+ }): ReactAgent$1<T, ContextSchema, TMiddleware>;
110
+ // Overload 13: With responseFormat as array of InteropZodTypes and middleware
111
+ declare function createAgent<T extends readonly InteropZodType<any>[], ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, T> & {
112
112
  responseFormat: T;
113
- middlewares: TMiddlewares;
114
- }): ReactAgent$1<ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, TMiddlewares>;
115
- // Overload 14: With responseFormat as JsonSchemaFormat and middlewares
116
- declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<Record<string, unknown>, ContextSchema, JsonSchemaFormat> & {
113
+ middleware: TMiddleware;
114
+ }): ReactAgent$1<ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, TMiddleware>;
115
+ // Overload 14: With responseFormat as JsonSchemaFormat and middleware
116
+ declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<Record<string, unknown>, ContextSchema, JsonSchemaFormat> & {
117
117
  responseFormat: JsonSchemaFormat;
118
- middlewares: TMiddlewares;
119
- }): ReactAgent$1<Record<string, unknown>, ContextSchema, TMiddlewares>;
120
- // Overload 15: With responseFormat as array of JsonSchemaFormat and middlewares
121
- declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<Record<string, unknown>, ContextSchema, JsonSchemaFormat[]> & {
118
+ middleware: TMiddleware;
119
+ }): ReactAgent$1<Record<string, unknown>, ContextSchema, TMiddleware>;
120
+ // Overload 15: With responseFormat as array of JsonSchemaFormat and middleware
121
+ declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<Record<string, unknown>, ContextSchema, JsonSchemaFormat[]> & {
122
122
  responseFormat: JsonSchemaFormat[];
123
- middlewares: TMiddlewares;
124
- }): ReactAgent$1<Record<string, unknown>, ContextSchema, TMiddlewares>;
125
- // Overload 16: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[] and middlewares
126
- declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<Record<string, unknown>, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {
123
+ middleware: TMiddleware;
124
+ }): ReactAgent$1<Record<string, unknown>, ContextSchema, TMiddleware>;
125
+ // Overload 16: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[] and middleware
126
+ declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<Record<string, unknown>, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {
127
127
  responseFormat: JsonSchemaFormat | JsonSchemaFormat[];
128
- middlewares: TMiddlewares;
129
- }): ReactAgent$1<Record<string, unknown>, ContextSchema, TMiddlewares>;
130
- // Overload 17: With responseFormat as TypedToolStrategy and middlewares
131
- declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, TypedToolStrategy<T>> & {
128
+ middleware: TMiddleware;
129
+ }): ReactAgent$1<Record<string, unknown>, ContextSchema, TMiddleware>;
130
+ // Overload 17: With responseFormat as TypedToolStrategy and middleware
131
+ declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, TypedToolStrategy<T>> & {
132
132
  responseFormat: TypedToolStrategy<T>;
133
- middlewares: TMiddlewares;
134
- }): ReactAgent$1<T, ContextSchema, TMiddlewares>;
135
- // Overload 18: With responseFormat as single ToolStrategy and middlewares
136
- declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, ToolStrategy<T>> & {
133
+ middleware: TMiddleware;
134
+ }): ReactAgent$1<T, ContextSchema, TMiddleware>;
135
+ // Overload 18: With responseFormat as single ToolStrategy and middleware
136
+ declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, ToolStrategy<T>> & {
137
137
  responseFormat: ToolStrategy<T>;
138
- middlewares: TMiddlewares;
139
- }): ReactAgent$1<T, ContextSchema, TMiddlewares>;
140
- // Overload 19: With responseFormat as ProviderStrategy and middlewares
141
- declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, ProviderStrategy<T>> & {
138
+ middleware: TMiddleware;
139
+ }): ReactAgent$1<T, ContextSchema, TMiddleware>;
140
+ // Overload 19: With responseFormat as ProviderStrategy and middleware
141
+ declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, ProviderStrategy<T>> & {
142
142
  responseFormat: ProviderStrategy<T>;
143
- middlewares: TMiddlewares;
144
- }): ReactAgent$1<T, ContextSchema, TMiddlewares>;
145
- // Overload 20: Without responseFormat but with middlewares
146
- declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: Omit<CreateAgentParams$1<ResponseFormatUndefined, ContextSchema, never>, "responseFormat"> & {
147
- middlewares: TMiddlewares;
148
- }): ReactAgent$1<ResponseFormatUndefined, ContextSchema, TMiddlewares>;
149
- // Overload 21: With responseFormat explicitly undefined and middlewares
150
- declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: Omit<CreateAgentParams$1<ResponseFormatUndefined, ContextSchema, never>, "responseFormat"> & {
143
+ middleware: TMiddleware;
144
+ }): ReactAgent$1<T, ContextSchema, TMiddleware>;
145
+ // Overload 20: Without responseFormat but with middleware
146
+ declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: Omit<CreateAgentParams$1<ResponseFormatUndefined, ContextSchema, never>, "responseFormat"> & {
147
+ middleware: TMiddleware;
148
+ }): ReactAgent$1<ResponseFormatUndefined, ContextSchema, TMiddleware>;
149
+ // Overload 21: With responseFormat explicitly undefined and middleware
150
+ declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: Omit<CreateAgentParams$1<ResponseFormatUndefined, ContextSchema, never>, "responseFormat"> & {
151
151
  responseFormat?: undefined;
152
- middlewares: TMiddlewares;
153
- }): ReactAgent$1<ResponseFormatUndefined, ContextSchema, TMiddlewares>;
154
- // Overload 22: For other ResponseFormat values with middlewares (failsafe)
155
- declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<StructuredResponseFormat, ContextSchema, any> & {
152
+ middleware: TMiddleware;
153
+ }): ReactAgent$1<ResponseFormatUndefined, ContextSchema, TMiddleware>;
154
+ // Overload 22: For other ResponseFormat values with middleware (failsafe)
155
+ declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<StructuredResponseFormat, ContextSchema, any> & {
156
156
  responseFormat: any;
157
- middlewares: TMiddlewares;
158
- }): ReactAgent$1<StructuredResponseFormat, ContextSchema, TMiddlewares>;
157
+ middleware: TMiddleware;
158
+ }): ReactAgent$1<StructuredResponseFormat, ContextSchema, TMiddleware>;
159
159
  //#endregion
160
160
  export { createAgent };
161
161
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["InteropZodObject","InteropZodType","MessagesAnnotation","ReactAgent","ReactAgentV1","ReactAgentV2","AnyAnnotationRoot","CreateAgentParams","ExtractZodArrayTypes","CreateAgentParamsV2","AgentMiddleware","ToolStrategy","TypedToolStrategy","ProviderStrategy","ResponseFormatUndefined","JsonSchemaFormat","ToolNode","toolStrategy","providerStrategy","ResponseFormat","createMiddleware","createAgent","Record","StateSchema","T","ContextSchema","Omit","StructuredResponseFormat","TMiddlewares"],"sources":["../../src/agents/index.d.ts"],"sourcesContent":["import type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport { MessagesAnnotation } from \"@langchain/langgraph\";\nimport { ReactAgent as ReactAgentV1 } from \"./ReactAgent.js\";\nimport { ReactAgent as ReactAgentV2 } from \"./middlewareAgent/ReactAgent.js\";\nimport { type AnyAnnotationRoot } from \"./annotation.js\";\nimport type { CreateAgentParams, ExtractZodArrayTypes } from \"./types.js\";\nimport type { CreateAgentParams as CreateAgentParamsV2, AgentMiddleware } from \"./middlewareAgent/types.js\";\nimport type { ToolStrategy, TypedToolStrategy, ProviderStrategy, ResponseFormatUndefined, JsonSchemaFormat } from \"./responses.js\";\n// Re-export types and utilities\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport * from \"./interrupt.js\";\nexport { ToolNode } from \"./nodes/ToolNode.js\";\nexport { toolStrategy, providerStrategy, ToolStrategy, ProviderStrategy, type ResponseFormat, } from \"./responses.js\";\nexport { createMiddleware } from \"./middlewareAgent/index.js\";\nexport type { AgentMiddleware } from \"./middlewareAgent/types.js\";\n/**\n * Agents combine language models with tools to create systems that can reason\n * about tasks, decide which tools to use, and iteratively work towards solutions.\n * {@link createAgent} provides a production-ready ReAct (Reasoning + Acting)\n * agent implementation based on the paper {@link https://arxiv.org/abs/2210.03629|ReAct: Synergizing Reasoning and Acting in Language Models.}\n *\n * @example\n * ```ts\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createAgent({\n * // use chat model from \"@langchain/openai\"\n * model: \"openai:gpt-4o-mini\",\n * tools: [getWeather]\n * });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// ===== V1 OVERLOADS (WITHOUT MIDDLEWARE) =====\n// These overloads come first to ensure proper type inference when middlewares is NOT provided\n// Overload 1: V1 - With responseFormat as single InteropZodType\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, InteropZodType<T>> & {\n responseFormat: InteropZodType<T>;\n}): ReactAgentV1<StateSchema, T, ContextSchema>;\n// Overload 2: V1 - With responseFormat as array of InteropZodTypes\nexport declare function createAgent<T extends readonly InteropZodType<any>[], StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, T> & {\n responseFormat: T;\n}): ReactAgentV1<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema>;\n// Overload 3: V1 - With responseFormat as JsonSchemaFormat\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat> & {\n responseFormat: JsonSchemaFormat;\n}): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 4: V1 - With responseFormat as array of JsonSchemaFormat\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat[];\n}): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 5: V1 - With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n}): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 6: V1 - With responseFormat as TypedToolStrategy\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, TypedToolStrategy<T>> & {\n responseFormat: TypedToolStrategy<T>;\n}): ReactAgentV1<StateSchema, T, ContextSchema>;\n// Overload 7: V1 - With responseFormat as single ToolStrategy\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n}): ReactAgentV1<StateSchema, T, ContextSchema>;\n// Overload 8: V1 - With responseFormat as ProviderStrategy\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, ProviderStrategy<T>> & {\n responseFormat: ProviderStrategy<T>;\n}): ReactAgentV1<StateSchema, T, ContextSchema>;\n// Overload 9: V1 - Without responseFormat property at all\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\">): ReactAgentV1<StateSchema, ResponseFormatUndefined, ContextSchema>;\n// Overload 10: V1 - With responseFormat explicitly undefined\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\"> & {\n responseFormat?: undefined;\n}): ReactAgentV1<StateSchema, ResponseFormatUndefined, ContextSchema>;\n// Overload 11: V1 - For other ResponseFormat values (failsafe)\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema, any> & {\n responseFormat: any;\n}): ReactAgentV1<StateSchema, StructuredResponseFormat, ContextSchema>;\n// ===== V2 OVERLOADS (WITH MIDDLEWARE) =====\n// These overloads explicitly require the middlewares property\n// Overload 12: With responseFormat as single InteropZodType and middlewares\nexport declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<T, ContextSchema, InteropZodType<T>> & {\n responseFormat: InteropZodType<T>;\n middlewares: TMiddlewares;\n}): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n// Overload 13: With responseFormat as array of InteropZodTypes and middlewares\nexport declare function createAgent<T extends readonly InteropZodType<any>[], ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, T> & {\n responseFormat: T;\n middlewares: TMiddlewares;\n}): ReactAgentV2<ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, TMiddlewares>;\n// Overload 14: With responseFormat as JsonSchemaFormat and middlewares\nexport declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<Record<string, unknown>, ContextSchema, JsonSchemaFormat> & {\n responseFormat: JsonSchemaFormat;\n middlewares: TMiddlewares;\n}): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddlewares>;\n// Overload 15: With responseFormat as array of JsonSchemaFormat and middlewares\nexport declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<Record<string, unknown>, ContextSchema, JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat[];\n middlewares: TMiddlewares;\n}): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddlewares>;\n// Overload 16: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[] and middlewares\nexport declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<Record<string, unknown>, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n middlewares: TMiddlewares;\n}): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddlewares>;\n// Overload 17: With responseFormat as TypedToolStrategy and middlewares\nexport declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<T, ContextSchema, TypedToolStrategy<T>> & {\n responseFormat: TypedToolStrategy<T>;\n middlewares: TMiddlewares;\n}): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n// Overload 18: With responseFormat as single ToolStrategy and middlewares\nexport declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n middlewares: TMiddlewares;\n}): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n// Overload 19: With responseFormat as ProviderStrategy and middlewares\nexport declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<T, ContextSchema, ProviderStrategy<T>> & {\n responseFormat: ProviderStrategy<T>;\n middlewares: TMiddlewares;\n}): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n// Overload 20: Without responseFormat but with middlewares\nexport declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: Omit<CreateAgentParamsV2<ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\"> & {\n middlewares: TMiddlewares;\n}): ReactAgentV2<ResponseFormatUndefined, ContextSchema, TMiddlewares>;\n// Overload 21: With responseFormat explicitly undefined and middlewares\nexport declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: Omit<CreateAgentParamsV2<ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\"> & {\n responseFormat?: undefined;\n middlewares: TMiddlewares;\n}): ReactAgentV2<ResponseFormatUndefined, ContextSchema, TMiddlewares>;\n// Overload 22: For other ResponseFormat values with middlewares (failsafe)\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<StructuredResponseFormat, ContextSchema, any> & {\n responseFormat: any;\n middlewares: TMiddlewares;\n}): ReactAgentV2<StructuredResponseFormat, ContextSchema, TMiddlewares>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEgB;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;AAEoFQ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NrB,EAwEjMmB,aAxEiMnB,EAwElLsB,YAxEkLtB,CAAAA"}
1
+ {"version":3,"file":"index.d.ts","names":["InteropZodObject","InteropZodType","MessagesAnnotation","ReactAgent","ReactAgentV1","ReactAgentV2","AnyAnnotationRoot","CreateAgentParams","ExtractZodArrayTypes","CreateAgentParamsV2","AgentMiddleware","ToolStrategy","TypedToolStrategy","ProviderStrategy","ResponseFormatUndefined","JsonSchemaFormat","ToolNode","toolStrategy","providerStrategy","ResponseFormat","createMiddleware","createAgent","Record","StateSchema","T","ContextSchema","Omit","StructuredResponseFormat","TMiddleware"],"sources":["../../src/agents/index.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport { MessagesAnnotation } from \"@langchain/langgraph\";\nimport { ReactAgent as ReactAgentV1 } from \"./ReactAgent.js\";\nimport { ReactAgent as ReactAgentV2 } from \"./middlewareAgent/ReactAgent.js\";\nimport { type AnyAnnotationRoot } from \"./annotation.js\";\nimport type { CreateAgentParams, ExtractZodArrayTypes } from \"./types.js\";\nimport type { CreateAgentParams as CreateAgentParamsV2, AgentMiddleware } from \"./middlewareAgent/types.js\";\nimport type { ToolStrategy, TypedToolStrategy, ProviderStrategy, ResponseFormatUndefined, JsonSchemaFormat } from \"./responses.js\";\n// Re-export types and utilities\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport * from \"./interrupt.js\";\nexport { ToolNode } from \"./nodes/ToolNode.js\";\nexport { toolStrategy, providerStrategy, ToolStrategy, ProviderStrategy, type ResponseFormat, } from \"./responses.js\";\nexport { createMiddleware } from \"./middlewareAgent/index.js\";\nexport type { AgentMiddleware } from \"./middlewareAgent/types.js\";\n/**\n * Agents combine language models with tools to create systems that can reason\n * about tasks, decide which tools to use, and iteratively work towards solutions.\n * {@link createAgent} provides a production-ready ReAct (Reasoning + Acting)\n * agent implementation based on the paper {@link https://arxiv.org/abs/2210.03629|ReAct: Synergizing Reasoning and Acting in Language Models.}\n *\n * @example\n * ```ts\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod/v3\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createAgent({\n * // use chat model from \"@langchain/openai\"\n * model: \"openai:gpt-4o-mini\",\n * tools: [getWeather]\n * });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// ===== V1 OVERLOADS (WITHOUT MIDDLEWARE) =====\n// These overloads come first to ensure proper type inference when middleware is NOT provided\n// Overload 1: V1 - With responseFormat as single InteropZodType\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, InteropZodType<T>> & {\n responseFormat: InteropZodType<T>;\n}): ReactAgentV1<StateSchema, T, ContextSchema>;\n// Overload 2: V1 - With responseFormat as array of InteropZodTypes\nexport declare function createAgent<T extends readonly InteropZodType<any>[], StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, T> & {\n responseFormat: T;\n}): ReactAgentV1<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema>;\n// Overload 3: V1 - With responseFormat as JsonSchemaFormat\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat> & {\n responseFormat: JsonSchemaFormat;\n}): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 4: V1 - With responseFormat as array of JsonSchemaFormat\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat[];\n}): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 5: V1 - With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n}): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 6: V1 - With responseFormat as TypedToolStrategy\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, TypedToolStrategy<T>> & {\n responseFormat: TypedToolStrategy<T>;\n}): ReactAgentV1<StateSchema, T, ContextSchema>;\n// Overload 7: V1 - With responseFormat as single ToolStrategy\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n}): ReactAgentV1<StateSchema, T, ContextSchema>;\n// Overload 8: V1 - With responseFormat as ProviderStrategy\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, ProviderStrategy<T>> & {\n responseFormat: ProviderStrategy<T>;\n}): ReactAgentV1<StateSchema, T, ContextSchema>;\n// Overload 9: V1 - Without responseFormat property at all\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\">): ReactAgentV1<StateSchema, ResponseFormatUndefined, ContextSchema>;\n// Overload 10: V1 - With responseFormat explicitly undefined\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\"> & {\n responseFormat?: undefined;\n}): ReactAgentV1<StateSchema, ResponseFormatUndefined, ContextSchema>;\n// Overload 11: V1 - For other ResponseFormat values (failsafe)\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema, any> & {\n responseFormat: any;\n}): ReactAgentV1<StateSchema, StructuredResponseFormat, ContextSchema>;\n// ===== V2 OVERLOADS (WITH MIDDLEWARE) =====\n// These overloads explicitly require the middleware property\n// Overload 12: With responseFormat as single InteropZodType and middleware\nexport declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<T, ContextSchema, InteropZodType<T>> & {\n responseFormat: InteropZodType<T>;\n middleware: TMiddleware;\n}): ReactAgentV2<T, ContextSchema, TMiddleware>;\n// Overload 13: With responseFormat as array of InteropZodTypes and middleware\nexport declare function createAgent<T extends readonly InteropZodType<any>[], ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, T> & {\n responseFormat: T;\n middleware: TMiddleware;\n}): ReactAgentV2<ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, TMiddleware>;\n// Overload 14: With responseFormat as JsonSchemaFormat and middleware\nexport declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<Record<string, unknown>, ContextSchema, JsonSchemaFormat> & {\n responseFormat: JsonSchemaFormat;\n middleware: TMiddleware;\n}): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddleware>;\n// Overload 15: With responseFormat as array of JsonSchemaFormat and middleware\nexport declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<Record<string, unknown>, ContextSchema, JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat[];\n middleware: TMiddleware;\n}): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddleware>;\n// Overload 16: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[] and middleware\nexport declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<Record<string, unknown>, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n middleware: TMiddleware;\n}): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddleware>;\n// Overload 17: With responseFormat as TypedToolStrategy and middleware\nexport declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<T, ContextSchema, TypedToolStrategy<T>> & {\n responseFormat: TypedToolStrategy<T>;\n middleware: TMiddleware;\n}): ReactAgentV2<T, ContextSchema, TMiddleware>;\n// Overload 18: With responseFormat as single ToolStrategy and middleware\nexport declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n middleware: TMiddleware;\n}): ReactAgentV2<T, ContextSchema, TMiddleware>;\n// Overload 19: With responseFormat as ProviderStrategy and middleware\nexport declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<T, ContextSchema, ProviderStrategy<T>> & {\n responseFormat: ProviderStrategy<T>;\n middleware: TMiddleware;\n}): ReactAgentV2<T, ContextSchema, TMiddleware>;\n// Overload 20: Without responseFormat but with middleware\nexport declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: Omit<CreateAgentParamsV2<ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\"> & {\n middleware: TMiddleware;\n}): ReactAgentV2<ResponseFormatUndefined, ContextSchema, TMiddleware>;\n// Overload 21: With responseFormat explicitly undefined and middleware\nexport declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: Omit<CreateAgentParamsV2<ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\"> & {\n responseFormat?: undefined;\n middleware: TMiddleware;\n}): ReactAgentV2<ResponseFormatUndefined, ContextSchema, TMiddleware>;\n// Overload 22: For other ResponseFormat values with middleware (failsafe)\nexport declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddleware extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParamsV2<StructuredResponseFormat, ContextSchema, any> & {\n responseFormat: any;\n middleware: TMiddleware;\n}): ReactAgentV2<StructuredResponseFormat, ContextSchema, TMiddleware>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEgB;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;AAE8GsB,iBANtFD,WAMsFC,CAAAA,o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,EAAAA,GAAAA,CAAAA,GAAAA;EAAiB,cAAGN,EAAAA,GAAAA;EAAgB,UAAGM,EAuE5NsB,WAvE4NtB;CAAiB,CAAA,EAwEzPD,YAxEqRkB,CAwExQI,wBAxEwQJ,EAwE9OE,aAxE8OF,EAwE/NK,WAxE+NL,CAAAA"}
@@ -9,9 +9,9 @@ import "./interrupt.js";
9
9
  //#region src/agents/index.ts
10
10
  function createAgent$2(params) {
11
11
  /**
12
- * Check if middlewares property is present
12
+ * Check if middleware property is present
13
13
  */
14
- if ("middlewares" in params && params.middlewares !== void 0) {
14
+ if ("middleware" in params && params.middleware !== void 0) {
15
15
  /**
16
16
  * The user wants to use the middleware version of the agent.
17
17
  * Let's verify that `preModelHook` and `postModelHook` are not provided
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createAgent","params: any","createAgentV2","createAgentV1"],"sources":["../../src/agents/index.ts"],"sourcesContent":["import type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport { MessagesAnnotation } from \"@langchain/langgraph\";\n\n// Import v1 (without middleware)\nimport { createAgent as createAgentV1 } from \"./createAgent.js\";\nimport { ReactAgent as ReactAgentV1 } from \"./ReactAgent.js\";\n\n// Import v2 (with middleware)\nimport { createAgent as createAgentV2 } from \"./middlewareAgent/index.js\";\nimport { ReactAgent as ReactAgentV2 } from \"./middlewareAgent/ReactAgent.js\";\n\nimport { type AnyAnnotationRoot } from \"./annotation.js\";\nimport type { CreateAgentParams, ExtractZodArrayTypes } from \"./types.js\";\nimport type {\n CreateAgentParams as CreateAgentParamsV2,\n AgentMiddleware,\n} from \"./middlewareAgent/types.js\";\nimport type {\n ToolStrategy,\n TypedToolStrategy,\n ProviderStrategy,\n ResponseFormatUndefined,\n JsonSchemaFormat,\n} from \"./responses.js\";\n\n// Re-export types and utilities\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport * from \"./interrupt.js\";\nexport { ToolNode } from \"./nodes/ToolNode.js\";\nexport {\n toolStrategy,\n providerStrategy,\n ToolStrategy,\n ProviderStrategy,\n type ResponseFormat,\n} from \"./responses.js\";\nexport { createMiddleware } from \"./middlewareAgent/index.js\";\nexport type { AgentMiddleware } from \"./middlewareAgent/types.js\";\n\n/**\n * Agents combine language models with tools to create systems that can reason\n * about tasks, decide which tools to use, and iteratively work towards solutions.\n * {@link createAgent} provides a production-ready ReAct (Reasoning + Acting)\n * agent implementation based on the paper {@link https://arxiv.org/abs/2210.03629|ReAct: Synergizing Reasoning and Acting in Language Models.}\n *\n * @example\n * ```ts\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createAgent({\n * // use chat model from \"@langchain/openai\"\n * model: \"openai:gpt-4o-mini\",\n * tools: [getWeather]\n * });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n\n// ===== V1 OVERLOADS (WITHOUT MIDDLEWARE) =====\n// These overloads come first to ensure proper type inference when middlewares is NOT provided\n\n// Overload 1: V1 - With responseFormat as single InteropZodType\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n InteropZodType<T>\n > & {\n responseFormat: InteropZodType<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 2: V1 - With responseFormat as array of InteropZodTypes\nexport function createAgent<\n T extends readonly InteropZodType<any>[],\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n T\n > & {\n responseFormat: T;\n }\n): ReactAgentV1<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema\n>;\n\n// Overload 3: V1 - With responseFormat as JsonSchemaFormat\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n }\n): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 4: V1 - With responseFormat as array of JsonSchemaFormat\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n }\n): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 5: V1 - With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n }\n): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 6: V1 - With responseFormat as TypedToolStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n TypedToolStrategy<T>\n > & {\n responseFormat: TypedToolStrategy<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 7: V1 - With responseFormat as single ToolStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 8: V1 - With responseFormat as ProviderStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n ProviderStrategy<T>\n > & {\n responseFormat: ProviderStrategy<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 9: V1 - Without responseFormat property at all\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n >\n): ReactAgentV1<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 10: V1 - With responseFormat explicitly undefined\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n }\n): ReactAgentV1<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 11: V1 - For other ResponseFormat values (failsafe)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n any\n > & {\n responseFormat: any;\n }\n): ReactAgentV1<StateSchema, StructuredResponseFormat, ContextSchema>;\n\n// ===== V2 OVERLOADS (WITH MIDDLEWARE) =====\n// These overloads explicitly require the middlewares property\n\n// Overload 12: With responseFormat as single InteropZodType and middlewares\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, InteropZodType<T>> & {\n responseFormat: InteropZodType<T>;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n\n// Overload 13: With responseFormat as array of InteropZodTypes and middlewares\nexport function createAgent<\n T extends readonly InteropZodType<any>[],\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n T\n > & {\n responseFormat: T;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n TMiddlewares\n>;\n\n// Overload 14: With responseFormat as JsonSchemaFormat and middlewares\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddlewares>;\n\n// Overload 15: With responseFormat as array of JsonSchemaFormat and middlewares\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddlewares>;\n\n// Overload 16: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[] and middlewares\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddlewares>;\n\n// Overload 17: With responseFormat as TypedToolStrategy and middlewares\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, TypedToolStrategy<T>> & {\n responseFormat: TypedToolStrategy<T>;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n\n// Overload 18: With responseFormat as single ToolStrategy and middlewares\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n\n// Overload 19: With responseFormat as ProviderStrategy and middlewares\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, ProviderStrategy<T>> & {\n responseFormat: ProviderStrategy<T>;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n\n// Overload 20: Without responseFormat but with middlewares\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: Omit<\n CreateAgentParamsV2<ResponseFormatUndefined, ContextSchema, never>,\n \"responseFormat\"\n > & { middlewares: TMiddlewares }\n): ReactAgentV2<ResponseFormatUndefined, ContextSchema, TMiddlewares>;\n\n// Overload 21: With responseFormat explicitly undefined and middlewares\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: Omit<\n CreateAgentParamsV2<ResponseFormatUndefined, ContextSchema, never>,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<ResponseFormatUndefined, ContextSchema, TMiddlewares>;\n\n// Overload 22: For other ResponseFormat values with middlewares (failsafe)\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<StructuredResponseFormat, ContextSchema, any> & {\n responseFormat: any;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<StructuredResponseFormat, ContextSchema, TMiddlewares>;\n\nexport function createAgent(params: any): any {\n /**\n * Check if middlewares property is present\n */\n if (\"middlewares\" in params && params.middlewares !== undefined) {\n /**\n * The user wants to use the middleware version of the agent.\n * Let's verify that `preModelHook` and `postModelHook` are not provided\n */\n if (\"preModelHook\" in params || \"postModelHook\" in params) {\n throw new Error(\n \"The `preModelHook` and `postModelHook` parameters are not supported in the middleware version of the agent.\"\n );\n }\n\n /**\n * Use v2 (middleware version)\n */\n return createAgentV2(params);\n } else {\n /**\n * Use v1 (original version)\n */\n return createAgentV1(params);\n }\n}\n"],"mappings":";;;;;;;;;AAigBA,SAAgBA,cAAYC,QAAkB;;;;AAI5C,KAAI,iBAAiB,UAAU,OAAO,gBAAgB,QAAW;;;;;AAK/D,MAAI,kBAAkB,UAAU,mBAAmB,OACjD,OAAM,IAAI,MACR;;;;AAOJ,SAAOC,cAAc,OAAO;CAC7B;;;;AAIC,QAAOC,YAAc,OAAO;AAE/B"}
1
+ {"version":3,"file":"index.js","names":["createAgent","params: any","createAgentV2","createAgentV1"],"sources":["../../src/agents/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport { MessagesAnnotation } from \"@langchain/langgraph\";\n\n// Import v1 (without middleware)\nimport { createAgent as createAgentV1 } from \"./createAgent.js\";\nimport { ReactAgent as ReactAgentV1 } from \"./ReactAgent.js\";\n\n// Import v2 (with middleware)\nimport { createAgent as createAgentV2 } from \"./middlewareAgent/index.js\";\nimport { ReactAgent as ReactAgentV2 } from \"./middlewareAgent/ReactAgent.js\";\n\nimport { type AnyAnnotationRoot } from \"./annotation.js\";\nimport type { CreateAgentParams, ExtractZodArrayTypes } from \"./types.js\";\nimport type {\n CreateAgentParams as CreateAgentParamsV2,\n AgentMiddleware,\n} from \"./middlewareAgent/types.js\";\nimport type {\n ToolStrategy,\n TypedToolStrategy,\n ProviderStrategy,\n ResponseFormatUndefined,\n JsonSchemaFormat,\n} from \"./responses.js\";\n\n// Re-export types and utilities\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport * from \"./interrupt.js\";\nexport { ToolNode } from \"./nodes/ToolNode.js\";\nexport {\n toolStrategy,\n providerStrategy,\n ToolStrategy,\n ProviderStrategy,\n type ResponseFormat,\n} from \"./responses.js\";\nexport { createMiddleware } from \"./middlewareAgent/index.js\";\nexport type { AgentMiddleware } from \"./middlewareAgent/types.js\";\n\n/**\n * Agents combine language models with tools to create systems that can reason\n * about tasks, decide which tools to use, and iteratively work towards solutions.\n * {@link createAgent} provides a production-ready ReAct (Reasoning + Acting)\n * agent implementation based on the paper {@link https://arxiv.org/abs/2210.03629|ReAct: Synergizing Reasoning and Acting in Language Models.}\n *\n * @example\n * ```ts\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod/v3\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createAgent({\n * // use chat model from \"@langchain/openai\"\n * model: \"openai:gpt-4o-mini\",\n * tools: [getWeather]\n * });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n\n// ===== V1 OVERLOADS (WITHOUT MIDDLEWARE) =====\n// These overloads come first to ensure proper type inference when middleware is NOT provided\n\n// Overload 1: V1 - With responseFormat as single InteropZodType\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n InteropZodType<T>\n > & {\n responseFormat: InteropZodType<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 2: V1 - With responseFormat as array of InteropZodTypes\nexport function createAgent<\n T extends readonly InteropZodType<any>[],\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n T\n > & {\n responseFormat: T;\n }\n): ReactAgentV1<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema\n>;\n\n// Overload 3: V1 - With responseFormat as JsonSchemaFormat\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n }\n): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 4: V1 - With responseFormat as array of JsonSchemaFormat\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n }\n): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 5: V1 - With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n }\n): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 6: V1 - With responseFormat as TypedToolStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n TypedToolStrategy<T>\n > & {\n responseFormat: TypedToolStrategy<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 7: V1 - With responseFormat as single ToolStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 8: V1 - With responseFormat as ProviderStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n ProviderStrategy<T>\n > & {\n responseFormat: ProviderStrategy<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 9: V1 - Without responseFormat property at all\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n >\n): ReactAgentV1<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 10: V1 - With responseFormat explicitly undefined\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n }\n): ReactAgentV1<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 11: V1 - For other ResponseFormat values (failsafe)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n any\n > & {\n responseFormat: any;\n }\n): ReactAgentV1<StateSchema, StructuredResponseFormat, ContextSchema>;\n\n// ===== V2 OVERLOADS (WITH MIDDLEWARE) =====\n// These overloads explicitly require the middleware property\n\n// Overload 12: With responseFormat as single InteropZodType and middleware\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, InteropZodType<T>> & {\n responseFormat: InteropZodType<T>;\n middleware: TMiddleware;\n }\n): ReactAgentV2<T, ContextSchema, TMiddleware>;\n\n// Overload 13: With responseFormat as array of InteropZodTypes and middleware\nexport function createAgent<\n T extends readonly InteropZodType<any>[],\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n T\n > & {\n responseFormat: T;\n middleware: TMiddleware;\n }\n): ReactAgentV2<\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n TMiddleware\n>;\n\n// Overload 14: With responseFormat as JsonSchemaFormat and middleware\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n middleware: TMiddleware;\n }\n): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddleware>;\n\n// Overload 15: With responseFormat as array of JsonSchemaFormat and middleware\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n middleware: TMiddleware;\n }\n): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddleware>;\n\n// Overload 16: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[] and middleware\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n middleware: TMiddleware;\n }\n): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddleware>;\n\n// Overload 17: With responseFormat as TypedToolStrategy and middleware\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, TypedToolStrategy<T>> & {\n responseFormat: TypedToolStrategy<T>;\n middleware: TMiddleware;\n }\n): ReactAgentV2<T, ContextSchema, TMiddleware>;\n\n// Overload 18: With responseFormat as single ToolStrategy and middleware\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n middleware: TMiddleware;\n }\n): ReactAgentV2<T, ContextSchema, TMiddleware>;\n\n// Overload 19: With responseFormat as ProviderStrategy and middleware\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, ProviderStrategy<T>> & {\n responseFormat: ProviderStrategy<T>;\n middleware: TMiddleware;\n }\n): ReactAgentV2<T, ContextSchema, TMiddleware>;\n\n// Overload 20: Without responseFormat but with middleware\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: Omit<\n CreateAgentParamsV2<ResponseFormatUndefined, ContextSchema, never>,\n \"responseFormat\"\n > & { middleware: TMiddleware }\n): ReactAgentV2<ResponseFormatUndefined, ContextSchema, TMiddleware>;\n\n// Overload 21: With responseFormat explicitly undefined and middleware\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: Omit<\n CreateAgentParamsV2<ResponseFormatUndefined, ContextSchema, never>,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n middleware: TMiddleware;\n }\n): ReactAgentV2<ResponseFormatUndefined, ContextSchema, TMiddleware>;\n\n// Overload 22: For other ResponseFormat values with middleware (failsafe)\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<StructuredResponseFormat, ContextSchema, any> & {\n responseFormat: any;\n middleware: TMiddleware;\n }\n): ReactAgentV2<StructuredResponseFormat, ContextSchema, TMiddleware>;\n\nexport function createAgent(params: any): any {\n /**\n * Check if middleware property is present\n */\n if (\"middleware\" in params && params.middleware !== undefined) {\n /**\n * The user wants to use the middleware version of the agent.\n * Let's verify that `preModelHook` and `postModelHook` are not provided\n */\n if (\"preModelHook\" in params || \"postModelHook\" in params) {\n throw new Error(\n \"The `preModelHook` and `postModelHook` parameters are not supported in the middleware version of the agent.\"\n );\n }\n\n /**\n * Use v2 (middleware version)\n */\n return createAgentV2(params);\n } else {\n /**\n * Use v1 (original version)\n */\n return createAgentV1(params);\n }\n}\n"],"mappings":";;;;;;;;;AAkgBA,SAAgBA,cAAYC,QAAkB;;;;AAI5C,KAAI,gBAAgB,UAAU,OAAO,eAAe,QAAW;;;;;AAK7D,MAAI,kBAAkB,UAAU,mBAAmB,OACjD,OAAM,IAAI,MACR;;;;AAOJ,SAAOC,cAAc,OAAO;CAC7B;;;;AAIC,QAAOC,YAAc,OAAO;AAE/B"}
@@ -34,36 +34,36 @@ var ReactAgent = class {
34
34
  * our graph needs to check if these were called
35
35
  */
36
36
  const shouldReturnDirect = new Set(toolClasses.filter(require_utils.isClientTool).filter((tool) => "returnDirect" in tool && tool.returnDirect).map((tool) => tool.name));
37
- const schema = require_annotation.createAgentAnnotationConditional(this.options.responseFormat !== void 0, this.options.middlewares);
37
+ const schema = require_annotation.createAgentAnnotationConditional(this.options.responseFormat !== void 0, this.options.middleware);
38
38
  const workflow = new __langchain_langgraph.StateGraph(schema, this.options.contextSchema);
39
39
  const allNodeWorkflows = workflow;
40
40
  const beforeModelNodes = [];
41
41
  const afterModelNodes = [];
42
- const prepareModelRequestHookMiddlewares = [];
43
- const middlewares = this.options.middlewares ?? [];
44
- for (let i = 0; i < middlewares.length; i++) {
42
+ const prepareModelRequestHookMiddleware = [];
43
+ const middleware = this.options.middleware ?? [];
44
+ for (let i = 0; i < middleware.length; i++) {
45
45
  let beforeModelNode;
46
46
  let afterModelNode;
47
- const middleware = middlewares[i];
48
- if (middleware.beforeModel) {
49
- beforeModelNode = new require_BeforeModalNode.BeforeModelNode(middleware);
50
- const name = `before_model_${middleware.name}_${i}`;
47
+ const m = middleware[i];
48
+ if (m.beforeModel) {
49
+ beforeModelNode = new require_BeforeModalNode.BeforeModelNode(m);
50
+ const name = `before_model_${m.name}_${i}`;
51
51
  beforeModelNodes.push({
52
52
  index: i,
53
53
  name
54
54
  });
55
55
  allNodeWorkflows.addNode(name, beforeModelNode, beforeModelNode.nodeOptions);
56
56
  }
57
- if (middleware.afterModel) {
58
- afterModelNode = new require_AfterModalNode.AfterModelNode(middleware);
59
- const name = `after_model_${middleware.name}_${i}`;
57
+ if (m.afterModel) {
58
+ afterModelNode = new require_AfterModalNode.AfterModelNode(m);
59
+ const name = `after_model_${m.name}_${i}`;
60
60
  afterModelNodes.push({
61
61
  index: i,
62
62
  name
63
63
  });
64
64
  allNodeWorkflows.addNode(name, afterModelNode, afterModelNode.nodeOptions);
65
65
  }
66
- if (middleware.prepareModelRequest) prepareModelRequestHookMiddlewares.push([middleware, () => ({
66
+ if (m.prepareModelRequest) prepareModelRequestHookMiddleware.push([m, () => ({
67
67
  ...beforeModelNode?.getState(),
68
68
  ...afterModelNode?.getState()
69
69
  })]);
@@ -78,11 +78,11 @@ var ReactAgent = class {
78
78
  includeAgentName: this.options.includeAgentName,
79
79
  name: this.options.name,
80
80
  responseFormat: this.options.responseFormat,
81
- middlewares: this.options.middlewares,
81
+ middleware: this.options.middleware,
82
82
  toolClasses,
83
83
  shouldReturnDirect,
84
84
  signal: this.options.signal,
85
- prepareModelRequestHookMiddlewares
85
+ prepareModelRequestHookMiddleware
86
86
  }), require_AgentNode.AgentNode.nodeOptions);
87
87
  /**
88
88
  * add single tool node for all tools
@@ -165,7 +165,7 @@ var ReactAgent = class {
165
165
  return (state) => {
166
166
  const messages = state.messages;
167
167
  const lastMessage = messages.at(-1);
168
- if (!(lastMessage instanceof __langchain_core_messages.AIMessage) || !lastMessage.tool_calls || lastMessage.tool_calls.length === 0) return __langchain_langgraph.END;
168
+ if (!__langchain_core_messages.AIMessage.isInstance(lastMessage) || !lastMessage.tool_calls || lastMessage.tool_calls.length === 0) return __langchain_langgraph.END;
169
169
  /**
170
170
  * The tool node processes a single message.
171
171
  */
@@ -189,7 +189,7 @@ var ReactAgent = class {
189
189
  return (state) => {
190
190
  const messages = state.messages;
191
191
  const lastMessage = messages[messages.length - 1];
192
- if (lastMessage instanceof __langchain_core_messages.ToolMessage && lastMessage.name && shouldReturnDirect.has(lastMessage.name)) return this.options.responseFormat ? "model_request" : __langchain_langgraph.END;
192
+ if (__langchain_core_messages.ToolMessage.isInstance(lastMessage) && lastMessage.name && shouldReturnDirect.has(lastMessage.name)) return this.options.responseFormat ? "model_request" : __langchain_langgraph.END;
193
193
  return "model_request";
194
194
  };
195
195
  }
@@ -197,8 +197,8 @@ var ReactAgent = class {
197
197
  * Initialize middleware states if not already present in the input state.
198
198
  */
199
199
  #initializeMiddlewareStates(state) {
200
- if (!this.options.middlewares || this.options.middlewares.length === 0 || state instanceof __langchain_langgraph.Command || !state) return state;
201
- const defaultStates = require_utils$1.initializeMiddlewareStates(this.options.middlewares, state);
200
+ if (!this.options.middleware || this.options.middleware.length === 0 || state instanceof __langchain_langgraph.Command || !state) return state;
201
+ const defaultStates = require_utils$1.initializeMiddlewareStates(this.options.middleware, state);
202
202
  const updatedState = { ...state };
203
203
  if (!updatedState) return updatedState;
204
204
  for (const [key, value] of Object.entries(defaultStates)) if (!(key in updatedState)) updatedState[key] = value;
@@ -1 +1 @@
1
- {"version":3,"file":"ReactAgent.cjs","names":["options: CreateAgentParams<StructuredResponseFormat, ContextSchema>","#toolBehaviorVersion","validateLLMHasNoBoundTools","isClientTool","createAgentAnnotationConditional","StateGraph","beforeModelNodes: { index: number; name: string }[]","afterModelNodes: { index: number; name: string }[]","prepareModelRequestHookMiddlewares: [\n AgentMiddleware,\n /**\n * ToDo: better type to get the state of middleware\n */\n () => any\n ][]","beforeModelNode: BeforeModelNode | undefined","afterModelNode: AfterModelNode | undefined","BeforeModelNode","AfterModelNode","AgentNode","ToolNode","START","#getModelPaths","#createModelRouter","toolReturnTarget: string","#createToolsRouter","END","#graph","toolClasses: (ClientTool | ServerTool)[]","paths: (\"tools\" | typeof END)[]","state: any","AIMessage","Send","shouldReturnDirect: Set<string>","ToolMessage","state: InvokeStateParameter<TMiddlewares>","Command","initializeMiddlewareStates","invokeFunc: InvokeFunction","config?: LangGraphRunnableConfig<FullContext>","#initializeMiddlewareStates","params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }"],"sources":["../../../src/agents/middlewareAgent/ReactAgent.ts"],"sourcesContent":["/* eslint-disable prefer-destructuring, no-instanceof/no-instanceof, @typescript-eslint/ban-types */\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\n\nimport {\n AnnotationRoot,\n StateGraph,\n END,\n START,\n Send,\n Command,\n CompiledStateGraph,\n type LangGraphRunnableConfig,\n} from \"@langchain/langgraph\";\nimport { ToolMessage, AIMessage } from \"@langchain/core/messages\";\n\nimport { createAgentAnnotationConditional } from \"./annotation.js\";\nimport { isClientTool, validateLLMHasNoBoundTools } from \"../utils.js\";\n\nimport { AgentNode } from \"./nodes/AgentNode.js\";\nimport { ToolNode } from \"../nodes/ToolNode.js\";\nimport { BeforeModelNode } from \"./nodes/BeforeModalNode.js\";\nimport { AfterModelNode } from \"./nodes/AfterModalNode.js\";\nimport { initializeMiddlewareStates } from \"./nodes/utils.js\";\n\nimport type { ClientTool, ServerTool, WithStateGraphNodes } from \"../types.js\";\n\nimport {\n CreateAgentParams,\n AgentMiddleware,\n InferMiddlewareStates,\n InferMiddlewareInputStates,\n BuiltInState,\n InferMiddlewareContextInputs,\n IsAllOptional,\n InferContextInput,\n} from \"./types.js\";\n\nimport {\n type AnyAnnotationRoot,\n type ToAnnotationRoot,\n} from \"../annotation.js\";\nimport type { ResponseFormatUndefined } from \"../responses.js\";\n\n// Helper type to get the state definition with middleware states\ntype MergedAgentState<\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined,\n TMiddlewares extends readonly AgentMiddleware<any, any, any>[]\n> = (StructuredResponseFormat extends ResponseFormatUndefined\n ? BuiltInState\n : BuiltInState & { structuredResponse: StructuredResponseFormat }) &\n InferMiddlewareStates<TMiddlewares>;\n\ntype InvokeStateParameter<\n TMiddlewares extends readonly AgentMiddleware<any, any, any>[]\n> =\n | (BuiltInState & InferMiddlewareInputStates<TMiddlewares>)\n | Command<any, any, any>\n | null;\n\ntype AgentGraph<\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = []\n> = CompiledStateGraph<\n any,\n any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any,\n any,\n MergedAgentState<StructuredResponseFormat, TMiddlewares>,\n ToAnnotationRoot<ContextSchema>[\"spec\"],\n unknown\n>;\n\nexport class ReactAgent<\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = []\n> {\n #graph: AgentGraph<StructuredResponseFormat, ContextSchema, TMiddlewares>;\n\n #toolBehaviorVersion: \"v1\" | \"v2\" = \"v2\";\n\n constructor(\n public options: CreateAgentParams<StructuredResponseFormat, ContextSchema>\n ) {\n this.#toolBehaviorVersion = options.version ?? this.#toolBehaviorVersion;\n\n /**\n * Check if the LLM already has bound tools and throw if it does.\n */\n if (options.llm && typeof options.llm !== \"function\") {\n validateLLMHasNoBoundTools(options.llm);\n }\n\n /**\n * validate that model and llm options are not provided together\n */\n if (options.llm && options.model) {\n throw new Error(\"Cannot provide both `model` and `llm` options.\");\n }\n\n /**\n * validate that either model or llm option is provided\n */\n if (!options.llm && !options.model) {\n throw new Error(\n \"Either `model` or `llm` option must be provided to create an agent.\"\n );\n }\n\n const toolClasses =\n (Array.isArray(options.tools) ? options.tools : options.tools?.tools) ??\n [];\n\n /**\n * If any of the tools are configured to return_directly after running,\n * our graph needs to check if these were called\n */\n const shouldReturnDirect = new Set(\n toolClasses\n .filter(isClientTool)\n .filter((tool) => \"returnDirect\" in tool && tool.returnDirect)\n .map((tool) => tool.name)\n );\n\n // Create a schema that merges agent base schema with middleware state schemas\n const schema = createAgentAnnotationConditional<\n StructuredResponseFormat,\n TMiddlewares\n >(\n this.options.responseFormat !== undefined,\n this.options.middlewares as TMiddlewares\n );\n\n const workflow = new StateGraph(\n schema as AnnotationRoot<any>,\n this.options.contextSchema\n );\n\n const allNodeWorkflows = workflow as WithStateGraphNodes<\n \"tools\" | \"model_request\" | string,\n typeof workflow\n >;\n\n // Generate node names for middleware nodes that have hooks\n const beforeModelNodes: { index: number; name: string }[] = [];\n const afterModelNodes: { index: number; name: string }[] = [];\n const prepareModelRequestHookMiddlewares: [\n AgentMiddleware,\n /**\n * ToDo: better type to get the state of middleware\n */\n () => any\n ][] = [];\n\n const middlewares = this.options.middlewares ?? [];\n for (let i = 0; i < middlewares.length; i++) {\n let beforeModelNode: BeforeModelNode | undefined;\n let afterModelNode: AfterModelNode | undefined;\n const middleware = middlewares[i];\n if (middleware.beforeModel) {\n beforeModelNode = new BeforeModelNode(middleware);\n const name = `before_model_${middleware.name}_${i}`;\n beforeModelNodes.push({\n index: i,\n name,\n });\n allNodeWorkflows.addNode(\n name,\n beforeModelNode,\n beforeModelNode.nodeOptions\n );\n }\n if (middleware.afterModel) {\n afterModelNode = new AfterModelNode(middleware);\n const name = `after_model_${middleware.name}_${i}`;\n afterModelNodes.push({\n index: i,\n name,\n });\n allNodeWorkflows.addNode(\n name,\n afterModelNode,\n afterModelNode.nodeOptions\n );\n }\n\n if (middleware.prepareModelRequest) {\n prepareModelRequestHookMiddlewares.push([\n middleware,\n () => ({\n ...beforeModelNode?.getState(),\n ...afterModelNode?.getState(),\n }),\n ]);\n }\n }\n\n /**\n * Add Nodes\n */\n allNodeWorkflows.addNode(\n \"model_request\",\n new AgentNode({\n llm: this.options.llm,\n model: this.options.model,\n prompt: this.options.prompt,\n includeAgentName: this.options.includeAgentName,\n name: this.options.name,\n responseFormat: this.options.responseFormat,\n middlewares: this.options.middlewares,\n toolClasses,\n shouldReturnDirect,\n signal: this.options.signal,\n prepareModelRequestHookMiddlewares,\n }),\n AgentNode.nodeOptions\n );\n\n /**\n * add single tool node for all tools\n */\n if (toolClasses.length > 0) {\n const toolNode = new ToolNode(toolClasses.filter(isClientTool), {\n signal: this.options.signal,\n });\n allNodeWorkflows.addNode(\"tools\", toolNode);\n }\n\n /**\n * Add Edges\n */\n // Determine starting point based on what nodes exist\n if (beforeModelNodes.length > 0) {\n // If we have beforeModel nodes, start with the first one\n allNodeWorkflows.addEdge(START, beforeModelNodes[0].name);\n } else {\n // If no beforeModel nodes, go directly to agent\n allNodeWorkflows.addEdge(START, \"model_request\");\n }\n\n // Connect beforeModel nodes in sequence\n for (let i = 0; i < beforeModelNodes.length - 1; i++) {\n allNodeWorkflows.addEdge(\n beforeModelNodes[i].name,\n beforeModelNodes[i + 1].name\n );\n }\n\n // Connect last beforeModel node to agent\n const lastBeforeModelNode = beforeModelNodes.at(-1);\n if (beforeModelNodes.length > 0 && lastBeforeModelNode) {\n allNodeWorkflows.addEdge(lastBeforeModelNode.name, \"model_request\");\n }\n\n // Connect agent to last afterModel node (for reverse order execution)\n const lastAfterModelNode = afterModelNodes.at(-1);\n if (afterModelNodes.length > 0 && lastAfterModelNode) {\n allNodeWorkflows.addEdge(\"model_request\", lastAfterModelNode.name);\n } else {\n const modelPaths = this.#getModelPaths(toolClasses.filter(isClientTool));\n if (modelPaths.length === 1) {\n allNodeWorkflows.addEdge(\"model_request\", modelPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n \"model_request\",\n this.#createModelRouter(),\n modelPaths\n );\n }\n }\n\n // Connect afterModel nodes in reverse sequence\n for (let i = afterModelNodes.length - 1; i > 0; i--) {\n allNodeWorkflows.addEdge(\n afterModelNodes[i].name,\n afterModelNodes[i - 1].name\n );\n }\n\n // Connect first afterModel node (last to execute) to model paths\n if (afterModelNodes.length > 0) {\n const firstAfterModelNode = afterModelNodes[0].name;\n const modelPaths = this.#getModelPaths(toolClasses.filter(isClientTool));\n if (modelPaths.length === 1) {\n allNodeWorkflows.addEdge(firstAfterModelNode, modelPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n firstAfterModelNode,\n this.#createModelRouter(),\n modelPaths\n );\n }\n }\n\n /**\n * add edges for tools node\n */\n if (toolClasses.length > 0) {\n // Tools should return to first beforeModel node or agent\n let toolReturnTarget: string;\n if (beforeModelNodes.length > 0) {\n toolReturnTarget = beforeModelNodes[0].name;\n } else {\n toolReturnTarget = \"model_request\";\n }\n\n if (shouldReturnDirect.size > 0) {\n allNodeWorkflows.addConditionalEdges(\n \"tools\",\n this.#createToolsRouter(shouldReturnDirect),\n [toolReturnTarget, END]\n );\n } else {\n allNodeWorkflows.addEdge(\"tools\", toolReturnTarget);\n }\n }\n\n /**\n * compile the graph\n */\n this.#graph = allNodeWorkflows.compile({\n checkpointer: this.options.checkpointer ?? this.options.checkpointSaver,\n interruptBefore: this.options.interruptBefore,\n interruptAfter: this.options.interruptAfter,\n store: this.options.store,\n name: this.options.name,\n description: this.options.description,\n }) as AgentGraph<StructuredResponseFormat, ContextSchema, TMiddlewares>;\n }\n\n /**\n * Get the compiled graph.\n */\n get graph(): AgentGraph<\n StructuredResponseFormat,\n ContextSchema,\n TMiddlewares\n > {\n return this.#graph;\n }\n\n /**\n * Get possible edge destinations from model node.\n * @param toolClasses names of tools to call\n * @returns list of possible edge destinations\n */\n #getModelPaths(\n toolClasses: (ClientTool | ServerTool)[]\n ): (\"tools\" | typeof END)[] {\n const paths: (\"tools\" | typeof END)[] = [];\n if (toolClasses.length > 0) {\n paths.push(\"tools\");\n }\n\n paths.push(END);\n\n return paths;\n }\n\n /**\n * Create routing function for model node conditional edges.\n */\n #createModelRouter() {\n /**\n * determine if the agent should continue or not\n */\n /**\n * ToDo: fix type\n */\n return (state: any) => {\n const messages = state.messages;\n const lastMessage = messages.at(-1);\n\n if (\n !(lastMessage instanceof AIMessage) ||\n !lastMessage.tool_calls ||\n lastMessage.tool_calls.length === 0\n ) {\n return END;\n }\n\n /**\n * The tool node processes a single message.\n */\n if (this.#toolBehaviorVersion === \"v1\") {\n return \"tools\";\n }\n\n /**\n * Route to tools node\n */\n return lastMessage.tool_calls.map(\n (toolCall) => new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n };\n }\n\n /**\n * Create routing function for tools node conditional edges.\n */\n #createToolsRouter(shouldReturnDirect: Set<string>) {\n /**\n * ToDo: fix type\n */\n return (state: any) => {\n const messages = state.messages;\n const lastMessage = messages[messages.length - 1];\n\n // Check if we just executed a returnDirect tool\n if (\n lastMessage instanceof ToolMessage &&\n lastMessage.name &&\n shouldReturnDirect.has(lastMessage.name)\n ) {\n // If we have a response format, route to agent to generate structured response\n // Otherwise, return directly\n return this.options.responseFormat ? \"model_request\" : END;\n }\n\n // For non-returnDirect tools, always route back to agent\n return \"model_request\";\n };\n }\n\n /**\n * Initialize middleware states if not already present in the input state.\n */\n #initializeMiddlewareStates(\n state: InvokeStateParameter<TMiddlewares>\n ): InvokeStateParameter<TMiddlewares> {\n if (\n !this.options.middlewares ||\n this.options.middlewares.length === 0 ||\n state instanceof Command ||\n !state\n ) {\n return state;\n }\n\n const defaultStates = initializeMiddlewareStates(\n this.options.middlewares,\n state\n );\n const updatedState = { ...state } as InvokeStateParameter<TMiddlewares>;\n if (!updatedState) {\n return updatedState;\n }\n\n // Only add defaults for keys that don't exist in current state\n for (const [key, value] of Object.entries(defaultStates)) {\n if (!(key in updatedState)) {\n // @ts-expect-error - ToDo: fix type\n updatedState[key as keyof InvokeStateParameter<TMiddlewares>] = value;\n }\n }\n\n return updatedState;\n }\n\n /**\n * @inheritdoc\n */\n get invoke() {\n type FullState = MergedAgentState<StructuredResponseFormat, TMiddlewares>;\n type FullContext = InferContextInput<ContextSchema> &\n InferMiddlewareContextInputs<TMiddlewares>;\n\n // Create overloaded function type based on whether context has required fields\n type InvokeFunction = IsAllOptional<FullContext> extends true\n ? (\n state: InvokeStateParameter<TMiddlewares>,\n config?: LangGraphRunnableConfig<FullContext>\n ) => Promise<FullState>\n : (\n state: InvokeStateParameter<TMiddlewares>,\n config?: LangGraphRunnableConfig<FullContext>\n ) => Promise<FullState>;\n\n const invokeFunc: InvokeFunction = async (\n state: InvokeStateParameter<TMiddlewares>,\n config?: LangGraphRunnableConfig<FullContext>\n ): Promise<FullState> => {\n const initializedState = this.#initializeMiddlewareStates(state);\n return this.#graph.invoke(\n initializedState,\n config as any\n ) as Promise<FullState>;\n };\n\n return invokeFunc;\n }\n\n /**\n * ToDo(@christian-bromann): Add stream and streamEvents methods\n */\n\n /**\n * Visualize the graph as a PNG image.\n * @param params - Parameters for the drawMermaidPng method.\n * @param params.withStyles - Whether to include styles in the graph.\n * @param params.curveStyle - The style of the graph's curves.\n * @param params.nodeColors - The colors of the graph's nodes.\n * @param params.wrapLabelNWords - The maximum number of words to wrap in a node's label.\n * @param params.backgroundColor - The background color of the graph.\n * @returns PNG image as a buffer\n */\n async drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }) {\n const representation = await this.#graph.getGraphAsync();\n const image = await representation.drawMermaidPng(params);\n const arrayBuffer = await image.arrayBuffer();\n const buffer = new Uint8Array(arrayBuffer);\n return buffer;\n }\n\n /**\n * Draw the graph as a Mermaid string.\n * @param params - Parameters for the drawMermaid method.\n * @param params.withStyles - Whether to include styles in the graph.\n * @param params.curveStyle - The style of the graph's curves.\n * @param params.nodeColors - The colors of the graph's nodes.\n * @param params.wrapLabelNWords - The maximum number of words to wrap in a node's label.\n * @param params.backgroundColor - The background color of the graph.\n * @returns Mermaid string\n */\n async drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }) {\n const representation = await this.#graph.getGraphAsync();\n return representation.drawMermaid(params);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAgFA,IAAa,aAAb,MAQE;CACA;CAEA,uBAAoC;CAEpC,YACSA,SACP;EADO;EAEP,KAAKC,uBAAuB,QAAQ,WAAW,KAAKA;;;;AAKpD,MAAI,QAAQ,OAAO,OAAO,QAAQ,QAAQ,YACxCC,yCAA2B,QAAQ,IAAI;;;;AAMzC,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AM,KAAKd,OAAO,eAAe;AACxD,SAAO,eAAe,YAAY,OAAO;CAC1C;AACF"}
1
+ {"version":3,"file":"ReactAgent.cjs","names":["options: CreateAgentParams<StructuredResponseFormat, ContextSchema>","#toolBehaviorVersion","validateLLMHasNoBoundTools","isClientTool","createAgentAnnotationConditional","StateGraph","beforeModelNodes: { index: number; name: string }[]","afterModelNodes: { index: number; name: string }[]","prepareModelRequestHookMiddleware: [\n AgentMiddleware,\n /**\n * ToDo: better type to get the state of middleware\n */\n () => any\n ][]","beforeModelNode: BeforeModelNode | undefined","afterModelNode: AfterModelNode | undefined","BeforeModelNode","AfterModelNode","AgentNode","ToolNode","START","#getModelPaths","#createModelRouter","toolReturnTarget: string","#createToolsRouter","END","#graph","toolClasses: (ClientTool | ServerTool)[]","paths: (\"tools\" | typeof END)[]","state: any","AIMessage","Send","shouldReturnDirect: Set<string>","ToolMessage","state: InvokeStateParameter<TMiddleware>","Command","initializeMiddlewareStates","invokeFunc: InvokeFunction","config?: LangGraphRunnableConfig<FullContext>","#initializeMiddlewareStates","params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }"],"sources":["../../../src/agents/middlewareAgent/ReactAgent.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\n\nimport {\n AnnotationRoot,\n StateGraph,\n END,\n START,\n Send,\n Command,\n CompiledStateGraph,\n type LangGraphRunnableConfig,\n} from \"@langchain/langgraph\";\nimport { ToolMessage, AIMessage } from \"@langchain/core/messages\";\n\nimport { createAgentAnnotationConditional } from \"./annotation.js\";\nimport { isClientTool, validateLLMHasNoBoundTools } from \"../utils.js\";\n\nimport { AgentNode } from \"./nodes/AgentNode.js\";\nimport { ToolNode } from \"../nodes/ToolNode.js\";\nimport { BeforeModelNode } from \"./nodes/BeforeModalNode.js\";\nimport { AfterModelNode } from \"./nodes/AfterModalNode.js\";\nimport { initializeMiddlewareStates } from \"./nodes/utils.js\";\n\nimport type { ClientTool, ServerTool, WithStateGraphNodes } from \"../types.js\";\n\nimport {\n CreateAgentParams,\n AgentMiddleware,\n InferMiddlewareStates,\n InferMiddlewareInputStates,\n BuiltInState,\n InferMiddlewareContextInputs,\n IsAllOptional,\n InferContextInput,\n} from \"./types.js\";\n\nimport {\n type AnyAnnotationRoot,\n type ToAnnotationRoot,\n} from \"../annotation.js\";\nimport type { ResponseFormatUndefined } from \"../responses.js\";\n\n// Helper type to get the state definition with middleware states\ntype MergedAgentState<\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined,\n TMiddleware extends readonly AgentMiddleware<any, any, any>[]\n> = (StructuredResponseFormat extends ResponseFormatUndefined\n ? BuiltInState\n : BuiltInState & { structuredResponse: StructuredResponseFormat }) &\n InferMiddlewareStates<TMiddleware>;\n\ntype InvokeStateParameter<\n TMiddleware extends readonly AgentMiddleware<any, any, any>[]\n> =\n | (BuiltInState & InferMiddlewareInputStates<TMiddleware>)\n | Command<any, any, any>\n | null;\n\ntype AgentGraph<\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<any, any, any>[] = []\n> = CompiledStateGraph<\n any,\n any,\n any,\n any,\n MergedAgentState<StructuredResponseFormat, TMiddleware>,\n ToAnnotationRoot<ContextSchema>[\"spec\"],\n unknown\n>;\n\nexport class ReactAgent<\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddleware extends readonly AgentMiddleware<any, any, any>[] = []\n> {\n #graph: AgentGraph<StructuredResponseFormat, ContextSchema, TMiddleware>;\n\n #toolBehaviorVersion: \"v1\" | \"v2\" = \"v2\";\n\n constructor(\n public options: CreateAgentParams<StructuredResponseFormat, ContextSchema>\n ) {\n this.#toolBehaviorVersion = options.version ?? this.#toolBehaviorVersion;\n\n /**\n * Check if the LLM already has bound tools and throw if it does.\n */\n if (options.llm && typeof options.llm !== \"function\") {\n validateLLMHasNoBoundTools(options.llm);\n }\n\n /**\n * validate that model and llm options are not provided together\n */\n if (options.llm && options.model) {\n throw new Error(\"Cannot provide both `model` and `llm` options.\");\n }\n\n /**\n * validate that either model or llm option is provided\n */\n if (!options.llm && !options.model) {\n throw new Error(\n \"Either `model` or `llm` option must be provided to create an agent.\"\n );\n }\n\n const toolClasses =\n (Array.isArray(options.tools) ? options.tools : options.tools?.tools) ??\n [];\n\n /**\n * If any of the tools are configured to return_directly after running,\n * our graph needs to check if these were called\n */\n const shouldReturnDirect = new Set(\n toolClasses\n .filter(isClientTool)\n .filter((tool) => \"returnDirect\" in tool && tool.returnDirect)\n .map((tool) => tool.name)\n );\n\n // Create a schema that merges agent base schema with middleware state schemas\n const schema = createAgentAnnotationConditional<\n StructuredResponseFormat,\n TMiddleware\n >(\n this.options.responseFormat !== undefined,\n this.options.middleware as TMiddleware\n );\n\n const workflow = new StateGraph(\n schema as AnnotationRoot<any>,\n this.options.contextSchema\n );\n\n const allNodeWorkflows = workflow as WithStateGraphNodes<\n \"tools\" | \"model_request\" | string,\n typeof workflow\n >;\n\n // Generate node names for middleware nodes that have hooks\n const beforeModelNodes: { index: number; name: string }[] = [];\n const afterModelNodes: { index: number; name: string }[] = [];\n const prepareModelRequestHookMiddleware: [\n AgentMiddleware,\n /**\n * ToDo: better type to get the state of middleware\n */\n () => any\n ][] = [];\n\n const middleware = this.options.middleware ?? [];\n for (let i = 0; i < middleware.length; i++) {\n let beforeModelNode: BeforeModelNode | undefined;\n let afterModelNode: AfterModelNode | undefined;\n const m = middleware[i];\n if (m.beforeModel) {\n beforeModelNode = new BeforeModelNode(m);\n const name = `before_model_${m.name}_${i}`;\n beforeModelNodes.push({\n index: i,\n name,\n });\n allNodeWorkflows.addNode(\n name,\n beforeModelNode,\n beforeModelNode.nodeOptions\n );\n }\n if (m.afterModel) {\n afterModelNode = new AfterModelNode(m);\n const name = `after_model_${m.name}_${i}`;\n afterModelNodes.push({\n index: i,\n name,\n });\n allNodeWorkflows.addNode(\n name,\n afterModelNode,\n afterModelNode.nodeOptions\n );\n }\n\n if (m.prepareModelRequest) {\n prepareModelRequestHookMiddleware.push([\n m,\n () => ({\n ...beforeModelNode?.getState(),\n ...afterModelNode?.getState(),\n }),\n ]);\n }\n }\n\n /**\n * Add Nodes\n */\n allNodeWorkflows.addNode(\n \"model_request\",\n new AgentNode({\n llm: this.options.llm,\n model: this.options.model,\n prompt: this.options.prompt,\n includeAgentName: this.options.includeAgentName,\n name: this.options.name,\n responseFormat: this.options.responseFormat,\n middleware: this.options.middleware,\n toolClasses,\n shouldReturnDirect,\n signal: this.options.signal,\n prepareModelRequestHookMiddleware,\n }),\n AgentNode.nodeOptions\n );\n\n /**\n * add single tool node for all tools\n */\n if (toolClasses.length > 0) {\n const toolNode = new ToolNode(toolClasses.filter(isClientTool), {\n signal: this.options.signal,\n });\n allNodeWorkflows.addNode(\"tools\", toolNode);\n }\n\n /**\n * Add Edges\n */\n // Determine starting point based on what nodes exist\n if (beforeModelNodes.length > 0) {\n // If we have beforeModel nodes, start with the first one\n allNodeWorkflows.addEdge(START, beforeModelNodes[0].name);\n } else {\n // If no beforeModel nodes, go directly to agent\n allNodeWorkflows.addEdge(START, \"model_request\");\n }\n\n // Connect beforeModel nodes in sequence\n for (let i = 0; i < beforeModelNodes.length - 1; i++) {\n allNodeWorkflows.addEdge(\n beforeModelNodes[i].name,\n beforeModelNodes[i + 1].name\n );\n }\n\n // Connect last beforeModel node to agent\n const lastBeforeModelNode = beforeModelNodes.at(-1);\n if (beforeModelNodes.length > 0 && lastBeforeModelNode) {\n allNodeWorkflows.addEdge(lastBeforeModelNode.name, \"model_request\");\n }\n\n // Connect agent to last afterModel node (for reverse order execution)\n const lastAfterModelNode = afterModelNodes.at(-1);\n if (afterModelNodes.length > 0 && lastAfterModelNode) {\n allNodeWorkflows.addEdge(\"model_request\", lastAfterModelNode.name);\n } else {\n const modelPaths = this.#getModelPaths(toolClasses.filter(isClientTool));\n if (modelPaths.length === 1) {\n allNodeWorkflows.addEdge(\"model_request\", modelPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n \"model_request\",\n this.#createModelRouter(),\n modelPaths\n );\n }\n }\n\n // Connect afterModel nodes in reverse sequence\n for (let i = afterModelNodes.length - 1; i > 0; i--) {\n allNodeWorkflows.addEdge(\n afterModelNodes[i].name,\n afterModelNodes[i - 1].name\n );\n }\n\n // Connect first afterModel node (last to execute) to model paths\n if (afterModelNodes.length > 0) {\n const firstAfterModelNode = afterModelNodes[0].name;\n const modelPaths = this.#getModelPaths(toolClasses.filter(isClientTool));\n if (modelPaths.length === 1) {\n allNodeWorkflows.addEdge(firstAfterModelNode, modelPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n firstAfterModelNode,\n this.#createModelRouter(),\n modelPaths\n );\n }\n }\n\n /**\n * add edges for tools node\n */\n if (toolClasses.length > 0) {\n // Tools should return to first beforeModel node or agent\n let toolReturnTarget: string;\n if (beforeModelNodes.length > 0) {\n toolReturnTarget = beforeModelNodes[0].name;\n } else {\n toolReturnTarget = \"model_request\";\n }\n\n if (shouldReturnDirect.size > 0) {\n allNodeWorkflows.addConditionalEdges(\n \"tools\",\n this.#createToolsRouter(shouldReturnDirect),\n [toolReturnTarget, END]\n );\n } else {\n allNodeWorkflows.addEdge(\"tools\", toolReturnTarget);\n }\n }\n\n /**\n * compile the graph\n */\n this.#graph = allNodeWorkflows.compile({\n checkpointer: this.options.checkpointer ?? this.options.checkpointSaver,\n interruptBefore: this.options.interruptBefore,\n interruptAfter: this.options.interruptAfter,\n store: this.options.store,\n name: this.options.name,\n description: this.options.description,\n }) as AgentGraph<StructuredResponseFormat, ContextSchema, TMiddleware>;\n }\n\n /**\n * Get the compiled graph.\n */\n get graph(): AgentGraph<\n StructuredResponseFormat,\n ContextSchema,\n TMiddleware\n > {\n return this.#graph;\n }\n\n /**\n * Get possible edge destinations from model node.\n * @param toolClasses names of tools to call\n * @returns list of possible edge destinations\n */\n #getModelPaths(\n toolClasses: (ClientTool | ServerTool)[]\n ): (\"tools\" | typeof END)[] {\n const paths: (\"tools\" | typeof END)[] = [];\n if (toolClasses.length > 0) {\n paths.push(\"tools\");\n }\n\n paths.push(END);\n\n return paths;\n }\n\n /**\n * Create routing function for model node conditional edges.\n */\n #createModelRouter() {\n /**\n * determine if the agent should continue or not\n */\n /**\n * ToDo: fix type\n */\n return (state: any) => {\n const messages = state.messages;\n const lastMessage = messages.at(-1);\n\n if (\n !AIMessage.isInstance(lastMessage) ||\n !lastMessage.tool_calls ||\n lastMessage.tool_calls.length === 0\n ) {\n return END;\n }\n\n /**\n * The tool node processes a single message.\n */\n if (this.#toolBehaviorVersion === \"v1\") {\n return \"tools\";\n }\n\n /**\n * Route to tools node\n */\n return lastMessage.tool_calls.map(\n (toolCall) => new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n };\n }\n\n /**\n * Create routing function for tools node conditional edges.\n */\n #createToolsRouter(shouldReturnDirect: Set<string>) {\n /**\n * ToDo: fix type\n */\n return (state: any) => {\n const messages = state.messages;\n const lastMessage = messages[messages.length - 1];\n\n // Check if we just executed a returnDirect tool\n if (\n ToolMessage.isInstance(lastMessage) &&\n lastMessage.name &&\n shouldReturnDirect.has(lastMessage.name)\n ) {\n // If we have a response format, route to agent to generate structured response\n // Otherwise, return directly\n return this.options.responseFormat ? \"model_request\" : END;\n }\n\n // For non-returnDirect tools, always route back to agent\n return \"model_request\";\n };\n }\n\n /**\n * Initialize middleware states if not already present in the input state.\n */\n #initializeMiddlewareStates(\n state: InvokeStateParameter<TMiddleware>\n ): InvokeStateParameter<TMiddleware> {\n if (\n !this.options.middleware ||\n this.options.middleware.length === 0 ||\n state instanceof Command ||\n !state\n ) {\n return state;\n }\n\n const defaultStates = initializeMiddlewareStates(\n this.options.middleware,\n state\n );\n const updatedState = { ...state } as InvokeStateParameter<TMiddleware>;\n if (!updatedState) {\n return updatedState;\n }\n\n // Only add defaults for keys that don't exist in current state\n for (const [key, value] of Object.entries(defaultStates)) {\n if (!(key in updatedState)) {\n // @ts-expect-error - ToDo: fix type\n updatedState[key as keyof InvokeStateParameter<TMiddleware>] = value;\n }\n }\n\n return updatedState;\n }\n\n /**\n * @inheritdoc\n */\n get invoke() {\n type FullState = MergedAgentState<StructuredResponseFormat, TMiddleware>;\n type FullContext = InferContextInput<ContextSchema> &\n InferMiddlewareContextInputs<TMiddleware>;\n\n // Create overloaded function type based on whether context has required fields\n type InvokeFunction = IsAllOptional<FullContext> extends true\n ? (\n state: InvokeStateParameter<TMiddleware>,\n config?: LangGraphRunnableConfig<FullContext>\n ) => Promise<FullState>\n : (\n state: InvokeStateParameter<TMiddleware>,\n config?: LangGraphRunnableConfig<FullContext>\n ) => Promise<FullState>;\n\n const invokeFunc: InvokeFunction = async (\n state: InvokeStateParameter<TMiddleware>,\n config?: LangGraphRunnableConfig<FullContext>\n ): Promise<FullState> => {\n const initializedState = this.#initializeMiddlewareStates(state);\n return this.#graph.invoke(\n initializedState,\n config as any\n ) as Promise<FullState>;\n };\n\n return invokeFunc;\n }\n\n /**\n * ToDo(@christian-bromann): Add stream and streamEvents methods\n */\n\n /**\n * Visualize the graph as a PNG image.\n * @param params - Parameters for the drawMermaidPng method.\n * @param params.withStyles - Whether to include styles in the graph.\n * @param params.curveStyle - The style of the graph's curves.\n * @param params.nodeColors - The colors of the graph's nodes.\n * @param params.wrapLabelNWords - The maximum number of words to wrap in a node's label.\n * @param params.backgroundColor - The background color of the graph.\n * @returns PNG image as a buffer\n */\n async drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }) {\n const representation = await this.#graph.getGraphAsync();\n const image = await representation.drawMermaidPng(params);\n const arrayBuffer = await image.arrayBuffer();\n const buffer = new Uint8Array(arrayBuffer);\n return buffer;\n }\n\n /**\n * Draw the graph as a Mermaid string.\n * @param params - Parameters for the drawMermaid method.\n * @param params.withStyles - Whether to include styles in the graph.\n * @param params.curveStyle - The style of the graph's curves.\n * @param params.nodeColors - The colors of the graph's nodes.\n * @param params.wrapLabelNWords - The maximum number of words to wrap in a node's label.\n * @param params.backgroundColor - The background color of the graph.\n * @returns Mermaid string\n */\n async drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }) {\n const representation = await this.#graph.getGraphAsync();\n return representation.drawMermaid(params);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAgFA,IAAa,aAAb,MAQE;CACA;CAEA,uBAAoC;CAEpC,YACSA,SACP;EADO;EAEP,KAAKC,uBAAuB,QAAQ,WAAW,KAAKA;;;;AAKpD,MAAI,QAAQ,OAAO,OAAO,QAAQ,QAAQ,YACxCC,yCAA2B,QAAQ,IAAI;;;;AAMzC,MAAI,QAAQ,OAAO,QAAQ,MACzB,OAAM,IAAI,MAAM;;;;AAMlB,MAAI,CAAC,QAAQ,OAAO,CAAC,QAAQ,MAC3B,OAAM,IAAI,MACR;EAIJ,MAAM,eACH,MAAM,QAAQ,QAAQ,MAAM,GAAG,QAAQ,QAAQ,QAAQ,OAAO,UAC/D,CAAE;;;;;EAMJ,MAAM,qBAAqB,IAAI,IAC7B,YACG,OAAOC,2BAAa,CACpB,OAAO,CAAC,SAAS,kBAAkB,QAAQ,KAAK,aAAa,CAC7D,IAAI,CAAC,SAAS,KAAK,KAAK;EAI7B,MAAM,SAASC,oDAIb,KAAK,QAAQ,mBAAmB,QAChC,KAAK,QAAQ,WACd;EAED,MAAM,WAAW,IAAIC,iCACnB,QACA,KAAK,QAAQ;EAGf,MAAM,mBAAmB;EAMzB,MAAMC,mBAAsD,C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