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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (405) hide show
  1. package/dist/agents/ReactAgent.cjs +5 -5
  2. package/dist/agents/ReactAgent.cjs.map +1 -1
  3. package/dist/agents/ReactAgent.d.cts +2 -5
  4. package/dist/agents/ReactAgent.d.cts.map +1 -1
  5. package/dist/agents/ReactAgent.d.ts +2 -5
  6. package/dist/agents/ReactAgent.d.ts.map +1 -1
  7. package/dist/agents/ReactAgent.js +6 -6
  8. package/dist/agents/ReactAgent.js.map +1 -1
  9. package/dist/agents/annotation.cjs.map +1 -1
  10. package/dist/agents/annotation.d.cts +13 -8
  11. package/dist/agents/annotation.d.cts.map +1 -1
  12. package/dist/agents/annotation.d.ts +13 -8
  13. package/dist/agents/annotation.d.ts.map +1 -1
  14. package/dist/agents/annotation.js.map +1 -1
  15. package/dist/agents/createAgent.cjs.map +1 -1
  16. package/dist/agents/createAgent.js.map +1 -1
  17. package/dist/agents/index.cjs +2 -2
  18. package/dist/agents/index.cjs.map +1 -1
  19. package/dist/agents/index.d.cts +50 -50
  20. package/dist/agents/index.d.cts.map +1 -1
  21. package/dist/agents/index.d.ts +50 -50
  22. package/dist/agents/index.d.ts.map +1 -1
  23. package/dist/agents/index.js +2 -2
  24. package/dist/agents/index.js.map +1 -1
  25. package/dist/agents/interrupt.d.cts +14 -1
  26. package/dist/agents/interrupt.d.cts.map +1 -1
  27. package/dist/agents/interrupt.d.ts +14 -1
  28. package/dist/agents/interrupt.d.ts.map +1 -1
  29. package/dist/agents/middlewareAgent/ReactAgent.cjs +273 -66
  30. package/dist/agents/middlewareAgent/ReactAgent.cjs.map +1 -1
  31. package/dist/agents/middlewareAgent/ReactAgent.d.cts +102 -16
  32. package/dist/agents/middlewareAgent/ReactAgent.d.cts.map +1 -1
  33. package/dist/agents/middlewareAgent/ReactAgent.d.ts +102 -16
  34. package/dist/agents/middlewareAgent/ReactAgent.d.ts.map +1 -1
  35. package/dist/agents/middlewareAgent/ReactAgent.js +275 -68
  36. package/dist/agents/middlewareAgent/ReactAgent.js.map +1 -1
  37. package/dist/agents/middlewareAgent/annotation.cjs +12 -6
  38. package/dist/agents/middlewareAgent/annotation.cjs.map +1 -1
  39. package/dist/agents/middlewareAgent/annotation.js +12 -6
  40. package/dist/agents/middlewareAgent/annotation.js.map +1 -1
  41. package/dist/agents/middlewareAgent/constants.d.cts +5 -0
  42. package/dist/agents/middlewareAgent/constants.d.cts.map +1 -0
  43. package/dist/agents/middlewareAgent/constants.d.ts +5 -0
  44. package/dist/agents/middlewareAgent/constants.d.ts.map +1 -0
  45. package/dist/agents/middlewareAgent/index.cjs.map +1 -1
  46. package/dist/agents/middlewareAgent/index.js.map +1 -1
  47. package/dist/agents/middlewareAgent/middleware/bigTool.cjs +162 -0
  48. package/dist/agents/middlewareAgent/middleware/bigTool.cjs.map +1 -0
  49. package/dist/agents/middlewareAgent/middleware/bigTool.d.cts +113 -0
  50. package/dist/agents/middlewareAgent/middleware/bigTool.d.cts.map +1 -0
  51. package/dist/agents/middlewareAgent/middleware/bigTool.d.ts +113 -0
  52. package/dist/agents/middlewareAgent/middleware/bigTool.d.ts.map +1 -0
  53. package/dist/agents/middlewareAgent/middleware/bigTool.js +161 -0
  54. package/dist/agents/middlewareAgent/middleware/bigTool.js.map +1 -0
  55. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs +58 -0
  56. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs.map +1 -0
  57. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts +46 -0
  58. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts.map +1 -0
  59. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts +46 -0
  60. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts.map +1 -0
  61. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js +58 -0
  62. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js.map +1 -0
  63. package/dist/agents/middlewareAgent/middleware/hitl.cjs +311 -0
  64. package/dist/agents/middlewareAgent/middleware/hitl.cjs.map +1 -0
  65. package/dist/agents/middlewareAgent/middleware/hitl.d.cts +419 -0
  66. package/dist/agents/middlewareAgent/middleware/hitl.d.cts.map +1 -0
  67. package/dist/agents/middlewareAgent/middleware/hitl.d.ts +419 -0
  68. package/dist/agents/middlewareAgent/middleware/hitl.d.ts.map +1 -0
  69. package/dist/agents/middlewareAgent/middleware/hitl.js +310 -0
  70. package/dist/agents/middlewareAgent/middleware/hitl.js.map +1 -0
  71. package/dist/agents/middlewareAgent/middleware/index.cjs +32 -0
  72. package/dist/agents/middlewareAgent/middleware/index.cjs.map +1 -0
  73. package/dist/agents/middlewareAgent/middleware/index.d.cts +6 -0
  74. package/dist/agents/middlewareAgent/middleware/index.d.ts +6 -0
  75. package/dist/agents/middlewareAgent/middleware/index.js +21 -0
  76. package/dist/agents/middlewareAgent/middleware/index.js.map +1 -0
  77. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.cjs +72 -27
  78. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs.map +1 -0
  79. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.cts +60 -15
  80. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts.map +1 -0
  81. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.ts +60 -15
  82. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts.map +1 -0
  83. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.js +71 -26
  84. package/dist/agents/middlewareAgent/middleware/promptCaching.js.map +1 -0
  85. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.cjs +35 -23
  86. package/dist/agents/middlewareAgent/middleware/summarization.cjs.map +1 -0
  87. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.cts +7 -5
  88. package/dist/agents/middlewareAgent/middleware/summarization.d.cts.map +1 -0
  89. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.ts +7 -5
  90. package/dist/agents/middlewareAgent/middleware/summarization.d.ts.map +1 -0
  91. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.js +29 -17
  92. package/dist/agents/middlewareAgent/middleware/summarization.js.map +1 -0
  93. package/dist/agents/middlewareAgent/middleware.cjs +8 -5
  94. package/dist/agents/middlewareAgent/middleware.cjs.map +1 -1
  95. package/dist/agents/middlewareAgent/middleware.d.cts +67 -7
  96. package/dist/agents/middlewareAgent/middleware.d.cts.map +1 -1
  97. package/dist/agents/middlewareAgent/middleware.d.ts +67 -7
  98. package/dist/agents/middlewareAgent/middleware.d.ts.map +1 -1
  99. package/dist/agents/middlewareAgent/middleware.js +8 -5
  100. package/dist/agents/middlewareAgent/middleware.js.map +1 -1
  101. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs +2 -2
  102. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs.map +1 -1
  103. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js +2 -2
  104. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js.map +1 -1
  105. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs +125 -83
  106. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs.map +1 -1
  107. package/dist/agents/middlewareAgent/nodes/AgentNode.js +128 -86
  108. package/dist/agents/middlewareAgent/nodes/AgentNode.js.map +1 -1
  109. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs +2 -2
  110. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs.map +1 -1
  111. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js +2 -2
  112. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js.map +1 -1
  113. package/dist/agents/middlewareAgent/nodes/middleware.cjs +42 -17
  114. package/dist/agents/middlewareAgent/nodes/middleware.cjs.map +1 -1
  115. package/dist/agents/middlewareAgent/nodes/middleware.js +42 -18
  116. package/dist/agents/middlewareAgent/nodes/middleware.js.map +1 -1
  117. package/dist/agents/middlewareAgent/nodes/utils.cjs +30 -16
  118. package/dist/agents/middlewareAgent/nodes/utils.cjs.map +1 -1
  119. package/dist/agents/middlewareAgent/nodes/utils.js +28 -14
  120. package/dist/agents/middlewareAgent/nodes/utils.js.map +1 -1
  121. package/dist/agents/middlewareAgent/types.d.cts +162 -88
  122. package/dist/agents/middlewareAgent/types.d.cts.map +1 -1
  123. package/dist/agents/middlewareAgent/types.d.ts +162 -88
  124. package/dist/agents/middlewareAgent/types.d.ts.map +1 -1
  125. package/dist/agents/model.cjs +13 -0
  126. package/dist/agents/model.cjs.map +1 -0
  127. package/dist/agents/model.js +11 -0
  128. package/dist/agents/model.js.map +1 -0
  129. package/dist/agents/nodes/AgentNode.cjs +60 -32
  130. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  131. package/dist/agents/nodes/AgentNode.js +61 -33
  132. package/dist/agents/nodes/AgentNode.js.map +1 -1
  133. package/dist/agents/nodes/ToolNode.cjs +4 -4
  134. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  135. package/dist/agents/nodes/ToolNode.d.cts +2 -3
  136. package/dist/agents/nodes/ToolNode.d.cts.map +1 -1
  137. package/dist/agents/nodes/ToolNode.d.ts +1 -2
  138. package/dist/agents/nodes/ToolNode.d.ts.map +1 -1
  139. package/dist/agents/nodes/ToolNode.js +5 -5
  140. package/dist/agents/nodes/ToolNode.js.map +1 -1
  141. package/dist/agents/responses.cjs +53 -11
  142. package/dist/agents/responses.cjs.map +1 -1
  143. package/dist/agents/responses.d.cts +12 -20
  144. package/dist/agents/responses.d.cts.map +1 -1
  145. package/dist/agents/responses.d.ts +12 -20
  146. package/dist/agents/responses.d.ts.map +1 -1
  147. package/dist/agents/responses.js +53 -12
  148. package/dist/agents/responses.js.map +1 -1
  149. package/dist/agents/types.d.cts +3 -6
  150. package/dist/agents/types.d.cts.map +1 -1
  151. package/dist/agents/types.d.ts +3 -6
  152. package/dist/agents/types.d.ts.map +1 -1
  153. package/dist/agents/utils.cjs +11 -29
  154. package/dist/agents/utils.cjs.map +1 -1
  155. package/dist/agents/utils.js +9 -26
  156. package/dist/agents/utils.js.map +1 -1
  157. package/dist/agents/withAgentName.cjs.map +1 -1
  158. package/dist/agents/withAgentName.js.map +1 -1
  159. package/dist/chains/api/prompts.cjs.map +1 -1
  160. package/dist/chains/api/prompts.js.map +1 -1
  161. package/dist/chains/constitutional_ai/constitutional_chain.cjs.map +1 -1
  162. package/dist/chains/constitutional_ai/constitutional_chain.js.map +1 -1
  163. package/dist/chains/index.cjs +0 -3
  164. package/dist/chains/index.cjs.map +1 -1
  165. package/dist/chains/index.d.cts +1 -2
  166. package/dist/chains/index.d.ts +1 -2
  167. package/dist/chains/index.js +1 -3
  168. package/dist/chains/index.js.map +1 -1
  169. package/dist/chains/openai_functions/extraction.cjs.map +1 -1
  170. package/dist/chains/openai_functions/extraction.d.cts +1 -3
  171. package/dist/chains/openai_functions/extraction.d.cts.map +1 -1
  172. package/dist/chains/openai_functions/extraction.d.ts +1 -3
  173. package/dist/chains/openai_functions/extraction.d.ts.map +1 -1
  174. package/dist/chains/openai_functions/extraction.js.map +1 -1
  175. package/dist/chains/openai_functions/index.cjs +0 -5
  176. package/dist/chains/openai_functions/index.cjs.map +1 -1
  177. package/dist/chains/openai_functions/index.d.cts +1 -2
  178. package/dist/chains/openai_functions/index.d.ts +1 -2
  179. package/dist/chains/openai_functions/index.js +1 -4
  180. package/dist/chains/openai_functions/index.js.map +1 -1
  181. package/dist/chains/openai_functions/openapi.cjs +4 -4
  182. package/dist/chains/openai_functions/openapi.cjs.map +1 -1
  183. package/dist/chains/openai_functions/openapi.d.cts +1 -1
  184. package/dist/chains/openai_functions/openapi.js +4 -4
  185. package/dist/chains/openai_functions/openapi.js.map +1 -1
  186. package/dist/chains/openai_functions/tagging.cjs.map +1 -1
  187. package/dist/chains/openai_functions/tagging.d.cts +1 -3
  188. package/dist/chains/openai_functions/tagging.d.cts.map +1 -1
  189. package/dist/chains/openai_functions/tagging.d.ts +1 -3
  190. package/dist/chains/openai_functions/tagging.d.ts.map +1 -1
  191. package/dist/chains/openai_functions/tagging.js.map +1 -1
  192. package/dist/chains/query_constructor/index.cjs +4 -4
  193. package/dist/chains/query_constructor/index.cjs.map +1 -1
  194. package/dist/chains/query_constructor/index.d.cts +4 -2
  195. package/dist/chains/query_constructor/index.d.cts.map +1 -1
  196. package/dist/chains/query_constructor/index.d.ts +4 -2
  197. package/dist/chains/query_constructor/index.d.ts.map +1 -1
  198. package/dist/chains/query_constructor/index.js +1 -1
  199. package/dist/chains/query_constructor/index.js.map +1 -1
  200. package/dist/chains/question_answering/load.d.ts +2 -2
  201. package/dist/chains/question_answering/load.d.ts.map +1 -1
  202. package/dist/chains/question_answering/map_reduce_prompts.cjs.map +1 -1
  203. package/dist/chains/question_answering/map_reduce_prompts.js.map +1 -1
  204. package/dist/chains/question_answering/refine_prompts.cjs.map +1 -1
  205. package/dist/chains/question_answering/refine_prompts.js.map +1 -1
  206. package/dist/chains/question_answering/stuff_prompts.cjs.map +1 -1
  207. package/dist/chains/question_answering/stuff_prompts.js.map +1 -1
  208. package/dist/chains/router/multi_prompt.cjs +4 -4
  209. package/dist/chains/router/multi_prompt.cjs.map +1 -1
  210. package/dist/chains/router/multi_prompt.js +1 -1
  211. package/dist/chains/router/multi_prompt.js.map +1 -1
  212. package/dist/chains/router/multi_retrieval_qa.cjs +4 -4
  213. package/dist/chains/router/multi_retrieval_qa.cjs.map +1 -1
  214. package/dist/chains/router/multi_retrieval_qa.js +1 -1
  215. package/dist/chains/router/multi_retrieval_qa.js.map +1 -1
  216. package/dist/chains/sql_db/sql_db_prompt.cjs.map +1 -1
  217. package/dist/chains/sql_db/sql_db_prompt.d.cts.map +1 -1
  218. package/dist/chains/sql_db/sql_db_prompt.d.ts.map +1 -1
  219. package/dist/chains/sql_db/sql_db_prompt.js.map +1 -1
  220. package/dist/chains/summarization/stuff_prompts.cjs.map +1 -1
  221. package/dist/chains/summarization/stuff_prompts.js.map +1 -1
  222. package/dist/chat_models/universal.cjs +8 -5
  223. package/dist/chat_models/universal.cjs.map +1 -1
  224. package/dist/chat_models/universal.d.cts +2 -2
  225. package/dist/chat_models/universal.d.cts.map +1 -1
  226. package/dist/chat_models/universal.d.ts +2 -2
  227. package/dist/chat_models/universal.d.ts.map +1 -1
  228. package/dist/chat_models/universal.js +8 -5
  229. package/dist/chat_models/universal.js.map +1 -1
  230. package/dist/document_loaders/fs/directory.cjs.map +1 -1
  231. package/dist/document_loaders/fs/directory.d.cts +0 -1
  232. package/dist/document_loaders/fs/directory.d.cts.map +1 -1
  233. package/dist/document_loaders/fs/directory.d.ts +0 -1
  234. package/dist/document_loaders/fs/directory.d.ts.map +1 -1
  235. package/dist/document_loaders/fs/directory.js.map +1 -1
  236. package/dist/document_loaders/fs/json.cjs +7 -1
  237. package/dist/document_loaders/fs/json.cjs.map +1 -1
  238. package/dist/document_loaders/fs/json.js +7 -1
  239. package/dist/document_loaders/fs/json.js.map +1 -1
  240. package/dist/embeddings/cache_backed.cjs +1 -1
  241. package/dist/embeddings/cache_backed.cjs.map +1 -1
  242. package/dist/embeddings/cache_backed.d.cts +1 -1
  243. package/dist/embeddings/cache_backed.d.ts +2 -2
  244. package/dist/embeddings/cache_backed.js +2 -2
  245. package/dist/embeddings/cache_backed.js.map +1 -1
  246. package/dist/evaluation/agents/trajectory.d.cts.map +1 -1
  247. package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
  248. package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
  249. package/dist/evaluation/embedding_distance/base.cjs +2 -4
  250. package/dist/evaluation/embedding_distance/base.cjs.map +1 -1
  251. package/dist/evaluation/embedding_distance/base.js +2 -3
  252. package/dist/evaluation/embedding_distance/base.js.map +1 -1
  253. package/dist/evaluation/loader.cjs +7 -12
  254. package/dist/evaluation/loader.cjs.map +1 -1
  255. package/dist/evaluation/loader.d.cts +8 -2
  256. package/dist/evaluation/loader.d.cts.map +1 -1
  257. package/dist/evaluation/loader.d.ts +8 -2
  258. package/dist/evaluation/loader.d.ts.map +1 -1
  259. package/dist/evaluation/loader.js +7 -12
  260. package/dist/evaluation/loader.js.map +1 -1
  261. package/dist/hub/base.cjs.map +1 -1
  262. package/dist/hub/base.js.map +1 -1
  263. package/dist/index.cjs +38 -6
  264. package/dist/index.cjs.map +1 -1
  265. package/dist/index.d.cts +11 -4
  266. package/dist/index.d.ts +11 -4
  267. package/dist/index.js +18 -4
  268. package/dist/index.js.map +1 -1
  269. package/dist/langchain-core/dist/load/serializable.d.cts.map +1 -1
  270. package/dist/langchain-core/dist/messages/base.d.cts +24 -33
  271. package/dist/langchain-core/dist/messages/base.d.cts.map +1 -1
  272. package/dist/langchain-core/dist/messages/content/index.d.cts +21 -2
  273. package/dist/langchain-core/dist/messages/content/index.d.cts.map +1 -1
  274. package/dist/langchain-core/dist/messages/content/tools.d.cts +67 -6
  275. package/dist/langchain-core/dist/messages/content/tools.d.cts.map +1 -1
  276. package/dist/langchain-core/dist/messages/message.d.cts +598 -0
  277. package/dist/langchain-core/dist/messages/message.d.cts.map +1 -0
  278. package/dist/langchain-core/dist/messages/metadata.d.cts +97 -0
  279. package/dist/langchain-core/dist/messages/metadata.d.cts.map +1 -0
  280. package/dist/langchain-core/dist/messages/utils.d.cts +75 -0
  281. package/dist/langchain-core/dist/messages/utils.d.cts.map +1 -0
  282. package/dist/langchain-core/dist/prompt_values.d.cts.map +1 -1
  283. package/dist/langchain-core/dist/utils/types/index.d.cts.map +1 -1
  284. package/dist/libs/langchain-core/dist/load/serializable.d.ts.map +1 -1
  285. package/dist/libs/langchain-core/dist/messages/base.d.ts +24 -33
  286. package/dist/libs/langchain-core/dist/messages/base.d.ts.map +1 -1
  287. package/dist/libs/langchain-core/dist/messages/content/index.d.ts +21 -2
  288. package/dist/libs/langchain-core/dist/messages/content/index.d.ts.map +1 -1
  289. package/dist/libs/langchain-core/dist/messages/content/tools.d.ts +67 -6
  290. package/dist/libs/langchain-core/dist/messages/content/tools.d.ts.map +1 -1
  291. package/dist/libs/langchain-core/dist/messages/message.d.ts +598 -0
  292. package/dist/libs/langchain-core/dist/messages/message.d.ts.map +1 -0
  293. package/dist/libs/langchain-core/dist/messages/metadata.d.ts +97 -0
  294. package/dist/libs/langchain-core/dist/messages/metadata.d.ts.map +1 -0
  295. package/dist/libs/langchain-core/dist/messages/utils.d.ts +75 -0
  296. package/dist/libs/langchain-core/dist/messages/utils.d.ts.map +1 -0
  297. package/dist/libs/langchain-core/dist/prompt_values.d.ts.map +1 -1
  298. package/dist/libs/langchain-core/dist/utils/types/index.d.ts +2 -0
  299. package/dist/libs/langchain-core/dist/utils/types/index.d.ts.map +1 -1
  300. package/dist/libs/langchain-core/dist/utils/types/zod.d.ts +1 -0
  301. package/dist/load/import_map.cjs +3 -14
  302. package/dist/load/import_map.cjs.map +1 -1
  303. package/dist/load/import_map.js +3 -14
  304. package/dist/load/import_map.js.map +1 -1
  305. package/dist/memory/prompt.cjs.map +1 -1
  306. package/dist/memory/prompt.d.cts.map +1 -1
  307. package/dist/memory/prompt.d.ts.map +1 -1
  308. package/dist/memory/prompt.js.map +1 -1
  309. package/dist/output_parsers/combining.cjs +1 -1
  310. package/dist/output_parsers/combining.cjs.map +1 -1
  311. package/dist/output_parsers/combining.js +1 -1
  312. package/dist/output_parsers/combining.js.map +1 -1
  313. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.cjs.map +1 -1
  314. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.js.map +1 -1
  315. package/dist/output_parsers/expression_type_handlers/base.cjs +1 -1
  316. package/dist/output_parsers/expression_type_handlers/base.cjs.map +1 -1
  317. package/dist/output_parsers/expression_type_handlers/base.js +1 -1
  318. package/dist/output_parsers/expression_type_handlers/base.js.map +1 -1
  319. package/dist/output_parsers/regex.cjs.map +1 -1
  320. package/dist/output_parsers/regex.js.map +1 -1
  321. package/dist/output_parsers/structured.cjs +4 -4
  322. package/dist/output_parsers/structured.cjs.map +1 -1
  323. package/dist/output_parsers/structured.d.cts +1 -1
  324. package/dist/output_parsers/structured.d.cts.map +1 -1
  325. package/dist/output_parsers/structured.d.ts +1 -1
  326. package/dist/output_parsers/structured.d.ts.map +1 -1
  327. package/dist/output_parsers/structured.js +2 -2
  328. package/dist/output_parsers/structured.js.map +1 -1
  329. package/dist/retrievers/ensemble.cjs.map +1 -1
  330. package/dist/retrievers/ensemble.js.map +1 -1
  331. package/dist/storage/file_system.cjs +1 -1
  332. package/dist/storage/file_system.cjs.map +1 -1
  333. package/dist/storage/file_system.js +1 -1
  334. package/dist/storage/file_system.js.map +1 -1
  335. package/dist/tools/fs.cjs +5 -5
  336. package/dist/tools/fs.cjs.map +1 -1
  337. package/dist/tools/fs.d.cts +1 -1
  338. package/dist/tools/fs.d.cts.map +1 -1
  339. package/dist/tools/fs.d.ts +1 -1
  340. package/dist/tools/fs.d.ts.map +1 -1
  341. package/dist/tools/fs.js +1 -1
  342. package/dist/tools/fs.js.map +1 -1
  343. package/dist/tools/retriever.cjs +2 -2
  344. package/dist/tools/retriever.cjs.map +1 -1
  345. package/dist/tools/retriever.d.cts +1 -1
  346. package/dist/tools/retriever.d.cts.map +1 -1
  347. package/dist/tools/retriever.d.ts +1 -1
  348. package/dist/tools/retriever.d.ts.map +1 -1
  349. package/dist/tools/retriever.js +1 -1
  350. package/dist/tools/retriever.js.map +1 -1
  351. package/dist/tools/sql.cjs +1 -2
  352. package/dist/tools/sql.cjs.map +1 -1
  353. package/dist/tools/sql.d.cts +1 -1
  354. package/dist/tools/sql.d.cts.map +1 -1
  355. package/dist/tools/sql.d.ts +1 -1
  356. package/dist/tools/sql.d.ts.map +1 -1
  357. package/dist/tools/sql.js +1 -2
  358. package/dist/tools/sql.js.map +1 -1
  359. package/dist/types/expression-parser.d.cts +2 -0
  360. package/dist/types/expression-parser.d.cts.map +1 -1
  361. package/dist/types/expression-parser.d.ts +2 -0
  362. package/dist/types/expression-parser.d.ts.map +1 -1
  363. package/dist/util/hub.cjs +1 -1
  364. package/dist/util/hub.js +1 -1
  365. package/dist/util/openapi.cjs +1 -1
  366. package/dist/util/openapi.cjs.map +1 -1
  367. package/dist/util/openapi.js +1 -1
  368. package/dist/util/openapi.js.map +1 -1
  369. package/package.json +15 -21
  370. package/dist/agents/middlewareAgent/middlewares/hitl.cjs +0 -235
  371. package/dist/agents/middlewareAgent/middlewares/hitl.cjs.map +0 -1
  372. package/dist/agents/middlewareAgent/middlewares/hitl.d.cts +0 -199
  373. package/dist/agents/middlewareAgent/middlewares/hitl.d.cts.map +0 -1
  374. package/dist/agents/middlewareAgent/middlewares/hitl.d.ts +0 -199
  375. package/dist/agents/middlewareAgent/middlewares/hitl.d.ts.map +0 -1
  376. package/dist/agents/middlewareAgent/middlewares/hitl.js +0 -234
  377. package/dist/agents/middlewareAgent/middlewares/hitl.js.map +0 -1
  378. package/dist/agents/middlewareAgent/middlewares/index.cjs +0 -8
  379. package/dist/agents/middlewareAgent/middlewares/index.d.cts +0 -4
  380. package/dist/agents/middlewareAgent/middlewares/index.d.ts +0 -4
  381. package/dist/agents/middlewareAgent/middlewares/index.js +0 -5
  382. package/dist/agents/middlewareAgent/middlewares/promptCaching.cjs.map +0 -1
  383. package/dist/agents/middlewareAgent/middlewares/promptCaching.d.cts.map +0 -1
  384. package/dist/agents/middlewareAgent/middlewares/promptCaching.d.ts.map +0 -1
  385. package/dist/agents/middlewareAgent/middlewares/promptCaching.js.map +0 -1
  386. package/dist/agents/middlewareAgent/middlewares/summarization.cjs.map +0 -1
  387. package/dist/agents/middlewareAgent/middlewares/summarization.d.cts.map +0 -1
  388. package/dist/agents/middlewareAgent/middlewares/summarization.d.ts.map +0 -1
  389. package/dist/agents/middlewareAgent/middlewares/summarization.js.map +0 -1
  390. package/dist/chains/openai_functions/structured_output.cjs +0 -107
  391. package/dist/chains/openai_functions/structured_output.cjs.map +0 -1
  392. package/dist/chains/openai_functions/structured_output.d.cts +0 -38
  393. package/dist/chains/openai_functions/structured_output.d.cts.map +0 -1
  394. package/dist/chains/openai_functions/structured_output.d.ts +0 -38
  395. package/dist/chains/openai_functions/structured_output.d.ts.map +0 -1
  396. package/dist/chains/openai_functions/structured_output.js +0 -105
  397. package/dist/chains/openai_functions/structured_output.js.map +0 -1
  398. package/dist/chains/openai_moderation.cjs +0 -107
  399. package/dist/chains/openai_moderation.cjs.map +0 -1
  400. package/dist/chains/openai_moderation.d.cts +0 -74
  401. package/dist/chains/openai_moderation.d.cts.map +0 -1
  402. package/dist/chains/openai_moderation.d.ts +0 -74
  403. package/dist/chains/openai_moderation.d.ts.map +0 -1
  404. package/dist/chains/openai_moderation.js +0 -106
  405. package/dist/chains/openai_moderation.js.map +0 -1
@@ -118,8 +118,8 @@ var ReactAgent = class {
118
118
  #createPostModelHookRouter() {
119
119
  return (state) => {
120
120
  const messages = state.messages;
121
- const toolMessages = messages.filter(__langchain_core_messages.isToolMessage);
122
- const lastAiMessage = messages.filter(__langchain_core_messages.isAIMessage).at(-1);
121
+ const toolMessages = messages.filter(__langchain_core_messages.ToolMessage.isInstance);
122
+ const lastAiMessage = messages.filter(__langchain_core_messages.AIMessage.isInstance).at(-1);
123
123
  const pendingToolCalls = lastAiMessage?.tool_calls?.filter((call) => !toolMessages.some((m) => m.tool_call_id === call.id));
124
124
  if (pendingToolCalls && pendingToolCalls.length > 0) {
125
125
  /**
@@ -137,7 +137,7 @@ var ReactAgent = class {
137
137
  lg_tool_call: toolCall
138
138
  }));
139
139
  }
140
- if (messages.at(-1) instanceof __langchain_core_messages.ToolMessage) return this.#getEntryPoint();
140
+ if (__langchain_core_messages.ToolMessage.isInstance(messages.at(-1))) return this.#getEntryPoint();
141
141
  return __langchain_langgraph.END;
142
142
  };
143
143
  }
@@ -162,7 +162,7 @@ var ReactAgent = class {
162
162
  return (state) => {
163
163
  const messages = state.messages;
164
164
  const lastMessage = messages.at(-1);
165
- if (!(lastMessage instanceof __langchain_core_messages.AIMessage) || !lastMessage.tool_calls || lastMessage.tool_calls.length === 0) {
165
+ if (!__langchain_core_messages.AIMessage.isInstance(lastMessage) || !lastMessage.tool_calls || lastMessage.tool_calls.length === 0) {
166
166
  if (this.options.postModelHook) return "post_model_hook";
167
167
  return __langchain_langgraph.END;
168
168
  }
@@ -187,7 +187,7 @@ var ReactAgent = class {
187
187
  return (state) => {
188
188
  const messages = state.messages;
189
189
  const lastMessage = messages[messages.length - 1];
190
- if (lastMessage instanceof __langchain_core_messages.ToolMessage && lastMessage.name && shouldReturnDirect.has(lastMessage.name)) return this.options.responseFormat ? this.#getEntryPoint() : __langchain_langgraph.END;
190
+ if (__langchain_core_messages.ToolMessage.isInstance(lastMessage) && lastMessage.name && shouldReturnDirect.has(lastMessage.name)) return this.options.responseFormat ? this.#getEntryPoint() : __langchain_langgraph.END;
191
191
  return this.#getEntryPoint();
192
192
  };
193
193
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ReactAgent.cjs","names":["options: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n >","#toolBehaviorVersion","validateLLMHasNoBoundTools","isClientTool","enhanceStateSchemaWithMessageReducer","createAgentAnnotationConditional","StateGraph","AgentNode","#inputSchema","ToolNode","START","#getEntryPoint","#getPostModelHookPaths","#createPostModelHookRouter","#getModelPaths","#createModelRouter","#createToolsRouter","END","#graph","toolClasses: (ClientTool | ServerTool)[]","paths: (typeof END | \"agent\" | \"pre_model_hook\" | \"tools\")[]","state: InternalAgentState<StructuredResponseFormat>","isToolMessage","isAIMessage","Send","ToolMessage","paths: (\"tools\" | typeof END)[]","AIMessage","shouldReturnDirect: Set<string>","params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }"],"sources":["../../src/agents/ReactAgent.ts"],"sourcesContent":["/* eslint-disable prefer-destructuring, no-instanceof/no-instanceof */\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport {\n AnnotationRoot,\n StateGraph,\n END,\n START,\n Send,\n CompiledStateGraph,\n MessagesAnnotation,\n} from \"@langchain/langgraph\";\nimport {\n isToolMessage,\n isAIMessage,\n ToolMessage,\n AIMessage,\n} from \"@langchain/core/messages\";\n\nimport {\n createAgentAnnotationConditional,\n ReactAgentAnnotation,\n} from \"./annotation.js\";\nimport { isClientTool, validateLLMHasNoBoundTools } from \"./utils.js\";\nimport { AgentNode } from \"./nodes/AgentNode.js\";\nimport { ToolNode } from \"./nodes/ToolNode.js\";\nimport type {\n CreateAgentParams,\n ClientTool,\n ServerTool,\n InternalAgentState,\n WithStateGraphNodes,\n} from \"./types.js\";\nimport {\n enhanceStateSchemaWithMessageReducer,\n type AnyAnnotationRoot,\n type ToAnnotationRoot,\n} from \"./annotation.js\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\n\ntype AgentGraph<\n StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n> = CompiledStateGraph<\n ToAnnotationRoot<StateSchema>[\"State\"],\n ToAnnotationRoot<StateSchema>[\"Update\"],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any,\n typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>[\"spec\"],\n ReactAgentAnnotation<StructuredResponseFormat>[\"spec\"] &\n ToAnnotationRoot<StateSchema>[\"spec\"],\n ToAnnotationRoot<ContextSchema>[\"spec\"],\n unknown\n>;\n\nexport class ReactAgent<\n StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n> {\n #graph: AgentGraph<StateSchema, StructuredResponseFormat, ContextSchema>;\n\n #inputSchema?: AnnotationRoot<ToAnnotationRoot<StateSchema>[\"spec\"]>;\n\n #toolBehaviorVersion: \"v1\" | \"v2\" = \"v2\";\n\n constructor(\n public options: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n >\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 = Array.isArray(options.tools)\n ? options.tools\n : options.tools.tools;\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 const schema = this.options.stateSchema\n ? enhanceStateSchemaWithMessageReducer(this.options.stateSchema)\n : createAgentAnnotationConditional<StructuredResponseFormat>(\n this.options.responseFormat !== undefined\n );\n\n const workflow = new StateGraph(schema, this.options.contextSchema);\n\n const allNodeWorkflows = workflow as WithStateGraphNodes<\n \"pre_model_hook\" | \"post_model_hook\" | \"tools\" | \"agent\",\n typeof workflow\n >;\n\n /**\n * Add Nodes\n */\n allNodeWorkflows.addNode(\n \"agent\",\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 toolClasses,\n shouldReturnDirect,\n signal: this.options.signal,\n }),\n {\n input: this.#inputSchema,\n }\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 * setup preModelHook\n */\n if (options.preModelHook) {\n allNodeWorkflows.addNode(\"pre_model_hook\", options.preModelHook);\n }\n\n /**\n * setup postModelHook\n */\n if (options.postModelHook) {\n allNodeWorkflows.addNode(\"post_model_hook\", options.postModelHook);\n }\n\n /**\n * Add Edges\n */\n allNodeWorkflows.addEdge(START, this.#getEntryPoint());\n\n if (this.options.preModelHook) {\n allNodeWorkflows.addEdge(\"pre_model_hook\", \"agent\");\n }\n\n if (this.options.postModelHook) {\n allNodeWorkflows.addEdge(\"agent\", \"post_model_hook\");\n const postHookPaths = this.#getPostModelHookPaths(\n toolClasses.filter(isClientTool)\n );\n if (postHookPaths.length === 1) {\n allNodeWorkflows.addEdge(\"post_model_hook\", postHookPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n \"post_model_hook\",\n this.#createPostModelHookRouter(),\n postHookPaths\n );\n }\n } else {\n const modelPaths = this.#getModelPaths(toolClasses.filter(isClientTool));\n if (modelPaths.length === 1) {\n allNodeWorkflows.addEdge(\"agent\", modelPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n \"agent\",\n this.#createModelRouter(),\n modelPaths\n );\n }\n }\n\n /**\n * add edges for tools node\n */\n if (toolClasses.length > 0) {\n if (shouldReturnDirect.size > 0) {\n allNodeWorkflows.addConditionalEdges(\n \"tools\",\n this.#createToolsRouter(shouldReturnDirect),\n [this.#getEntryPoint(), END]\n );\n } else {\n allNodeWorkflows.addEdge(\"tools\", this.#getEntryPoint());\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 });\n }\n\n /**\n * Get the compiled graph.\n */\n get graph(): AgentGraph<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n > {\n return this.#graph;\n }\n\n #getEntryPoint() {\n const entryPoint = this.options.preModelHook ? \"pre_model_hook\" : \"agent\";\n return entryPoint;\n }\n\n /**\n * Get possible edge destinations from post_model_hook node.\n */\n #getPostModelHookPaths(toolClasses: (ClientTool | ServerTool)[]) {\n const paths: (typeof END | \"agent\" | \"pre_model_hook\" | \"tools\")[] = [];\n if (toolClasses.length > 0) {\n paths.push(this.#getEntryPoint(), \"tools\");\n }\n paths.push(END);\n return paths;\n }\n\n #createPostModelHookRouter() {\n return (state: InternalAgentState<StructuredResponseFormat>) => {\n const messages = state.messages;\n const toolMessages = messages.filter(isToolMessage);\n const lastAiMessage = messages.filter(isAIMessage).at(-1);\n const pendingToolCalls = lastAiMessage?.tool_calls?.filter(\n (call) => !toolMessages.some((m) => m.tool_call_id === call.id)\n );\n\n if (pendingToolCalls && pendingToolCalls.length > 0) {\n /**\n * The tool node processes a single message.\n * All tool calls in the message are executed in parallel within the tool node.\n * @deprecated likely to be removed in the next version of the agent\n */\n if (this.#toolBehaviorVersion === \"v1\") {\n return \"tools\";\n }\n\n /**\n * The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n */\n return pendingToolCalls.map(\n (toolCall) => new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n }\n\n if (messages.at(-1) instanceof ToolMessage) {\n return this.#getEntryPoint();\n }\n\n return END;\n };\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 return (state: InternalAgentState<StructuredResponseFormat>) => {\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 if (this.options.postModelHook) {\n return \"post_model_hook\";\n }\n\n return END;\n }\n\n if (this.options.postModelHook) {\n return \"post_model_hook\";\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 return (state: InternalAgentState<StructuredResponseFormat>) => {\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 ? this.#getEntryPoint() : END;\n }\n\n // For non-returnDirect tools, always route back to agent\n return this.#getEntryPoint();\n };\n }\n\n /**\n * @inheritdoc\n */\n get invoke(): AgentGraph<StateSchema, StructuredResponseFormat>[\"invoke\"] {\n return this.#graph.invoke.bind(this.#graph);\n }\n\n /**\n * @inheritdoc\n */\n get stream(): AgentGraph<StateSchema, StructuredResponseFormat>[\"stream\"] {\n return this.#graph.stream.bind(this.#graph);\n }\n\n /**\n * @inheritdoc\n */\n get streamEvents(): AgentGraph<\n StateSchema,\n StructuredResponseFormat\n >[\"streamEvents\"] {\n return this.#graph.streamEvents.bind(this.#graph);\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":";;;;;;;;;AAyDA,IAAa,aAAb,MAME;CACA;CAEA;CAEA,uBAAoC;CAEpC,YACSA,SAKP;EALO;EAMP,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,cAAc,MAAM,QAAQ,QAAQ,MAAM,GAC5C,QAAQ,QACR,QAAQ,MAAM;;;;;EAMlB,MAAM,qBAAqB,IAAI,IAC7B,YACG,OAAOC,2BAAa,CACpB,OAAO,CAAC,SAAS,kBAAkB,QAAQ,KAAK,aAAa,CAC7D,IAAI,CAAC,SAAS,KAAK,KAAK;EAG7B,MAAM,S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;;;;;;;;CAYD,MAAM,eAAeW,QAMlB;EACD,MAAM,iBAAiB,MAAM,KAAKX,OAAO,eAAe;EACxD,MAAM,QAAQ,MAAM,eAAe,eAAe,OAAO;EACzD,MAAM,cAAc,MAAM,MAAM,aAAa;EAC7C,MAAM,SAAS,IAAI,WAAW;AAC9B,SAAO;CACR;;;;;;;;;;;CAYD,MAAM,YAAYW,QAMf;EACD,MAAM,iBAAiB,MAAM,KAAKX,OAAO,eAAe;AACxD,SAAO,eAAe,YAAY,OAAO;CAC1C;AACF"}
1
+ {"version":3,"file":"ReactAgent.cjs","names":["options: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n >","#toolBehaviorVersion","validateLLMHasNoBoundTools","isClientTool","enhanceStateSchemaWithMessageReducer","createAgentAnnotationConditional","StateGraph","AgentNode","#inputSchema","ToolNode","START","#getEntryPoint","#getPostModelHookPaths","#createPostModelHookRouter","#getModelPaths","#createModelRouter","#createToolsRouter","END","#graph","toolClasses: (ClientTool | ServerTool)[]","paths: (typeof END | \"agent\" | \"pre_model_hook\" | \"tools\")[]","state: InternalAgentState<StructuredResponseFormat>","ToolMessage","AIMessage","Send","paths: (\"tools\" | typeof END)[]","shouldReturnDirect: Set<string>","params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }"],"sources":["../../src/agents/ReactAgent.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport {\n AnnotationRoot,\n StateGraph,\n END,\n START,\n Send,\n CompiledStateGraph,\n MessagesAnnotation,\n} from \"@langchain/langgraph\";\nimport { ToolMessage, AIMessage } from \"@langchain/core/messages\";\n\nimport {\n createAgentAnnotationConditional,\n ReactAgentAnnotation,\n} from \"./annotation.js\";\nimport { isClientTool, validateLLMHasNoBoundTools } from \"./utils.js\";\nimport { AgentNode } from \"./nodes/AgentNode.js\";\nimport { ToolNode } from \"./nodes/ToolNode.js\";\nimport type {\n CreateAgentParams,\n ClientTool,\n ServerTool,\n InternalAgentState,\n WithStateGraphNodes,\n} from \"./types.js\";\nimport {\n enhanceStateSchemaWithMessageReducer,\n type AnyAnnotationRoot,\n type ToAnnotationRoot,\n type ResponseFormatUndefined,\n} from \"./annotation.js\";\n\ntype AgentGraph<\n StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n> = CompiledStateGraph<\n ToAnnotationRoot<StateSchema>[\"State\"],\n ToAnnotationRoot<StateSchema>[\"Update\"],\n any,\n typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>[\"spec\"],\n ReactAgentAnnotation<StructuredResponseFormat>[\"spec\"] &\n ToAnnotationRoot<StateSchema>[\"spec\"],\n ToAnnotationRoot<ContextSchema>[\"spec\"],\n unknown\n>;\n\nexport class ReactAgent<\n StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n> {\n #graph: AgentGraph<StateSchema, StructuredResponseFormat, ContextSchema>;\n\n #inputSchema?: AnnotationRoot<ToAnnotationRoot<StateSchema>[\"spec\"]>;\n\n #toolBehaviorVersion: \"v1\" | \"v2\" = \"v2\";\n\n constructor(\n public options: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n >\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 = Array.isArray(options.tools)\n ? options.tools\n : options.tools.tools;\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 const schema = this.options.stateSchema\n ? enhanceStateSchemaWithMessageReducer(this.options.stateSchema)\n : createAgentAnnotationConditional<StructuredResponseFormat>(\n this.options.responseFormat !== undefined\n );\n\n const workflow = new StateGraph(schema, this.options.contextSchema);\n\n const allNodeWorkflows = workflow as WithStateGraphNodes<\n \"pre_model_hook\" | \"post_model_hook\" | \"tools\" | \"agent\",\n typeof workflow\n >;\n\n /**\n * Add Nodes\n */\n allNodeWorkflows.addNode(\n \"agent\",\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 toolClasses,\n shouldReturnDirect,\n signal: this.options.signal,\n }),\n {\n input: this.#inputSchema,\n }\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 * setup preModelHook\n */\n if (options.preModelHook) {\n allNodeWorkflows.addNode(\"pre_model_hook\", options.preModelHook);\n }\n\n /**\n * setup postModelHook\n */\n if (options.postModelHook) {\n allNodeWorkflows.addNode(\"post_model_hook\", options.postModelHook);\n }\n\n /**\n * Add Edges\n */\n allNodeWorkflows.addEdge(START, this.#getEntryPoint());\n\n if (this.options.preModelHook) {\n allNodeWorkflows.addEdge(\"pre_model_hook\", \"agent\");\n }\n\n if (this.options.postModelHook) {\n allNodeWorkflows.addEdge(\"agent\", \"post_model_hook\");\n const postHookPaths = this.#getPostModelHookPaths(\n toolClasses.filter(isClientTool)\n );\n if (postHookPaths.length === 1) {\n allNodeWorkflows.addEdge(\"post_model_hook\", postHookPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n \"post_model_hook\",\n this.#createPostModelHookRouter(),\n postHookPaths\n );\n }\n } else {\n const modelPaths = this.#getModelPaths(toolClasses.filter(isClientTool));\n if (modelPaths.length === 1) {\n allNodeWorkflows.addEdge(\"agent\", modelPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n \"agent\",\n this.#createModelRouter(),\n modelPaths\n );\n }\n }\n\n /**\n * add edges for tools node\n */\n if (toolClasses.length > 0) {\n if (shouldReturnDirect.size > 0) {\n allNodeWorkflows.addConditionalEdges(\n \"tools\",\n this.#createToolsRouter(shouldReturnDirect),\n [this.#getEntryPoint(), END]\n );\n } else {\n allNodeWorkflows.addEdge(\"tools\", this.#getEntryPoint());\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 });\n }\n\n /**\n * Get the compiled graph.\n */\n get graph(): AgentGraph<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n > {\n return this.#graph;\n }\n\n #getEntryPoint() {\n const entryPoint = this.options.preModelHook ? \"pre_model_hook\" : \"agent\";\n return entryPoint;\n }\n\n /**\n * Get possible edge destinations from post_model_hook node.\n */\n #getPostModelHookPaths(toolClasses: (ClientTool | ServerTool)[]) {\n const paths: (typeof END | \"agent\" | \"pre_model_hook\" | \"tools\")[] = [];\n if (toolClasses.length > 0) {\n paths.push(this.#getEntryPoint(), \"tools\");\n }\n paths.push(END);\n return paths;\n }\n\n #createPostModelHookRouter() {\n return (state: InternalAgentState<StructuredResponseFormat>) => {\n const messages = state.messages;\n const toolMessages = messages.filter(ToolMessage.isInstance);\n const lastAiMessage = messages.filter(AIMessage.isInstance).at(-1);\n const pendingToolCalls = lastAiMessage?.tool_calls?.filter(\n (call) => !toolMessages.some((m) => m.tool_call_id === call.id)\n );\n\n if (pendingToolCalls && pendingToolCalls.length > 0) {\n /**\n * The tool node processes a single message.\n * All tool calls in the message are executed in parallel within the tool node.\n * @deprecated likely to be removed in the next version of the agent\n */\n if (this.#toolBehaviorVersion === \"v1\") {\n return \"tools\";\n }\n\n /**\n * The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n */\n return pendingToolCalls.map(\n (toolCall) => new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n }\n\n if (ToolMessage.isInstance(messages.at(-1))) {\n return this.#getEntryPoint();\n }\n\n return END;\n };\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 return (state: InternalAgentState<StructuredResponseFormat>) => {\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 if (this.options.postModelHook) {\n return \"post_model_hook\";\n }\n\n return END;\n }\n\n if (this.options.postModelHook) {\n return \"post_model_hook\";\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 return (state: InternalAgentState<StructuredResponseFormat>) => {\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 ? this.#getEntryPoint() : END;\n }\n\n // For non-returnDirect tools, always route back to agent\n return this.#getEntryPoint();\n };\n }\n\n /**\n * @inheritdoc\n */\n get invoke(): AgentGraph<StateSchema, StructuredResponseFormat>[\"invoke\"] {\n return this.#graph.invoke.bind(this.#graph);\n }\n\n /**\n * @inheritdoc\n */\n get stream(): AgentGraph<StateSchema, StructuredResponseFormat>[\"stream\"] {\n return this.#graph.stream.bind(this.#graph);\n }\n\n /**\n * @inheritdoc\n */\n get streamEvents(): AgentGraph<\n StateSchema,\n StructuredResponseFormat\n >[\"streamEvents\"] {\n return this.#graph.streamEvents.bind(this.#graph);\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":";;;;;;;;;AAmDA,IAAa,aAAb,MAME;CACA;CAEA;CAEA,uBAAoC;CAEpC,YACSA,SAKP;EALO;EAMP,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,cAAc,MAAM,QAAQ,QAAQ,MAAM,GAC5C,QAAQ,QACR,QAAQ,MAAM;;;;;EAMlB,MAAM,qBAAqB,IAAI,IAC7B,YACG,OAAOC,2BAAa,CACpB,OAAO,CAAC,SAAS,kBAAkB,QAAQ,KAAK,aAAa,CAC7D,IAAI,CAAC,SAAS,KAAK,KAAK;EAG7B,MAAM,SAAS,KAAK,QAAQ,cACxBC,wDAAqC,KAAK,QAAQ,YAAY,GAC9DC,oDACE,KAAK,QAAQ,mBAAmB,OACjC;EAEL,MAAM,WAAW,IAAIC,iCAAW,QAAQ,KAAK,QAAQ;EAErD,MAAM,mBAAmB;;;;EAQzB,iBAAiB,QACf,SACA,IAAIC,4BAAU;GACZ,KAAK,KAAK,QAAQ;GAClB,OAAO,KAAK,QAAQ;GACpB,QAAQ,KAAK,QAAQ;GACrB,kBAAkB,KAAK,QAAQ;GAC/B,MAA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AAe;AACxD,SAAO,eAAe,YAAY,OAAO;CAC1C;AACF"}
@@ -1,13 +1,10 @@
1
- import { ResponseFormatUndefined } from "./responses.cjs";
2
- import { AnyAnnotationRoot, ReactAgentAnnotation, ToAnnotationRoot } from "./annotation.cjs";
1
+ import { AnyAnnotationRoot, ReactAgentAnnotation, ResponseFormatUndefined, ToAnnotationRoot } from "./annotation.cjs";
3
2
  import { CreateAgentParams } from "./types.cjs";
4
3
  import { InteropZodObject } from "@langchain/core/utils/types";
5
4
  import { CompiledStateGraph, MessagesAnnotation } from "@langchain/langgraph";
6
5
 
7
6
  //#region src/agents/ReactAgent.d.ts
8
- type AgentGraph<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = CompiledStateGraph<ToAnnotationRoot<StateSchema>["State"], ToAnnotationRoot<StateSchema>["Update"],
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- any, typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>["spec"], ReactAgentAnnotation<StructuredResponseFormat>["spec"] & ToAnnotationRoot<StateSchema>["spec"], ToAnnotationRoot<ContextSchema>["spec"], unknown>;
7
+ type AgentGraph<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = CompiledStateGraph<ToAnnotationRoot<StateSchema>["State"], ToAnnotationRoot<StateSchema>["Update"], any, typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>["spec"], ReactAgentAnnotation<StructuredResponseFormat>["spec"] & ToAnnotationRoot<StateSchema>["spec"], ToAnnotationRoot<ContextSchema>["spec"], unknown>;
11
8
  declare class ReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> {
12
9
  #private;
13
10
  options: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"ReactAgent.d.cts","names":["InteropZodObject","CompiledStateGraph","MessagesAnnotation","ReactAgentAnnotation","CreateAgentParams","AnyAnnotationRoot","ToAnnotationRoot","ResponseFormatUndefined","AgentGraph","Record","StateSchema","spec","StructuredResponseFormat","ContextSchema","ReactAgent","ArrayBuffer","Uint8Array","Promise"],"sources":["../../src/agents/ReactAgent.d.ts"],"sourcesContent":["/* eslint-disable prefer-destructuring, no-instanceof/no-instanceof */\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport { CompiledStateGraph, MessagesAnnotation } from \"@langchain/langgraph\";\nimport { ReactAgentAnnotation } from \"./annotation.js\";\nimport type { CreateAgentParams } from \"./types.js\";\nimport { type AnyAnnotationRoot, type ToAnnotationRoot } from \"./annotation.js\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\ntype AgentGraph<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = CompiledStateGraph<ToAnnotationRoot<StateSchema>[\"State\"], ToAnnotationRoot<StateSchema>[\"Update\"], \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nany, typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>[\"spec\"], ReactAgentAnnotation<StructuredResponseFormat>[\"spec\"] & ToAnnotationRoot<StateSchema>[\"spec\"], ToAnnotationRoot<ContextSchema>[\"spec\"], unknown>;\nexport declare class ReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> {\n #private;\n options: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema>;\n constructor(options: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema>);\n /**\n * Get the compiled graph.\n */\n get graph(): AgentGraph<StateSchema, StructuredResponseFormat, ContextSchema>;\n /**\n * @inheritdoc\n */\n get invoke(): AgentGraph<StateSchema, StructuredResponseFormat>[\"invoke\"];\n /**\n * @inheritdoc\n */\n get stream(): AgentGraph<StateSchema, StructuredResponseFormat>[\"stream\"];\n /**\n * @inheritdoc\n */\n get streamEvents(): AgentGraph<StateSchema, StructuredResponseFormat>[\"streamEvents\"];\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 drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<Uint8Array<ArrayBuffer>>;\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 drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<string>;\n}\nexport {};\n"],"mappings":";;;;;;;AAM8D,KACzDQ,UAAAA,CAAAA,oBAA+BH,iBAArB,GAAyCL,gBAAzC,GAA4DK,iBAA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esAnnotation","ReactAgentAnnotation","CreateAgentParams","AnyAnnotationRoot","ToAnnotationRoot","ResponseFormatUndefined","AgentGraph","Record","StateSchema","spec","StructuredResponseFormat","ContextSchema","ReactAgent","ArrayBuffer","Uint8Array","Promise"],"sources":["../../src/agents/ReactAgent.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport { CompiledStateGraph, MessagesAnnotation } from \"@langchain/langgraph\";\nimport { ReactAgentAnnotation } from \"./annotation.js\";\nimport type { CreateAgentParams } from \"./types.js\";\nimport { type AnyAnnotationRoot, type ToAnnotationRoot, type ResponseFormatUndefined } from \"./annotation.js\";\ntype AgentGraph<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = CompiledStateGraph<ToAnnotationRoot<StateSchema>[\"State\"], ToAnnotationRoot<StateSchema>[\"Update\"], any, typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>[\"spec\"], ReactAgentAnnotation<StructuredResponseFormat>[\"spec\"] & ToAnnotationRoot<StateSchema>[\"spec\"], ToAnnotationRoot<ContextSchema>[\"spec\"], unknown>;\nexport declare class ReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> {\n #private;\n options: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema>;\n constructor(options: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema>);\n /**\n * Get the compiled graph.\n */\n get graph(): AgentGraph<StateSchema, StructuredResponseFormat, ContextSchema>;\n /**\n * @inheritdoc\n */\n get invoke(): AgentGraph<StateSchema, StructuredResponseFormat>[\"invoke\"];\n /**\n * @inheritdoc\n */\n get stream(): AgentGraph<StateSchema, StructuredResponseFormat>[\"stream\"];\n /**\n * @inheritdoc\n */\n get streamEvents(): AgentGraph<StateSchema, StructuredResponseFormat>[\"streamEvents\"];\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 drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<Uint8Array<ArrayBuffer>>;\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 drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<string>;\n}\nexport {};\n"],"mappings":";;;;;;AAK8G,KACzGQ,UAAAA,CAAAA,oBAA+BH,iBAArB,GAAyCL,gBAAzC,GAA4DK,iBAA5D,EAAA,iCAAgHI,MAAhH,CAAA,MAAA,EAAA,GAAA,CAAA,GAAsIF,uBAAtI,GAAgKE,MAAhK,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,sBAA2MJ,iBAA3M,GAA+NL,gBAA/N,GAAkPK,iBAAlP,CAAA,GAAuQJ,kBAAvQ,CAA0RK,gBAA1R,CAA2SI,WAA3S,CAAA,CAAA,OAAA,CAAA,EAAkUJ,gBAAlU,CAAmVI,WAAnV,CAAA,C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CAoB9eA,WApB8eA,EAoBjeE,wBApBieF,CAAAA,CAAAA,cAAAA,CAAAA;EAAW;;;;AAApP;AACxS;;;;;EAA4G,cAAmCD,CAAAA,MAAmJ,CAAnJA,EAAAA;IAAsBF,UAAAA,CAAAA,EAAAA,OAAAA;IAA0BE,UAAAA,CAAAA,EAAAA,MAAAA;IAA2CJ,UAAAA,CAAAA,EAiCrNI,MAjCqNJ,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;IAAoBL,eAAAA,CAAAA,EAAAA,MAAAA;IAAmBK,eAAAA,CAAAA,EAAAA,MAAAA;EAAiB,CAAA,CAAA,EAoC1RY,OAlCuBP,CAkCfM,UAlCeN,CAkCJK,WAlCIL,CAAAA,CAAAA;EAAW;;;;;;;;;;EAKsC,WAA/DF,CAAAA,MAQiD,CARjDA,EAAAA;IAIYE,UAAAA,CAAAA,EAAAA,OAAAA;IAAaE,UAAAA,CAAAA,EAAAA,MAAAA;IAAxBJ,UAAAA,CAAAA,EAuCGC,MAvCHD,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;IAIWE,eAAAA,CAAAA,EAAAA,MAAAA;IAAaE,eAAAA,CAAAA,EAAAA,MAAAA;EAAwB,CAAA,CAAA,EAsC1DK,OAtCUT,CAAAA,MAAAA,CAAAA"}
@@ -1,13 +1,10 @@
1
- import { ResponseFormatUndefined } from "./responses.js";
2
- import { AnyAnnotationRoot, ReactAgentAnnotation, ToAnnotationRoot } from "./annotation.js";
1
+ import { AnyAnnotationRoot, ReactAgentAnnotation, ResponseFormatUndefined, ToAnnotationRoot } from "./annotation.js";
3
2
  import { CreateAgentParams } from "./types.js";
4
3
  import { CompiledStateGraph, MessagesAnnotation } from "@langchain/langgraph";
5
4
  import { InteropZodObject } from "@langchain/core/utils/types";
6
5
 
7
6
  //#region src/agents/ReactAgent.d.ts
8
- type AgentGraph<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = CompiledStateGraph<ToAnnotationRoot<StateSchema>["State"], ToAnnotationRoot<StateSchema>["Update"],
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- any, typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>["spec"], ReactAgentAnnotation<StructuredResponseFormat>["spec"] & ToAnnotationRoot<StateSchema>["spec"], ToAnnotationRoot<ContextSchema>["spec"], unknown>;
7
+ type AgentGraph<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = CompiledStateGraph<ToAnnotationRoot<StateSchema>["State"], ToAnnotationRoot<StateSchema>["Update"], any, typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>["spec"], ReactAgentAnnotation<StructuredResponseFormat>["spec"] & ToAnnotationRoot<StateSchema>["spec"], ToAnnotationRoot<ContextSchema>["spec"], unknown>;
11
8
  declare class ReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> {
12
9
  #private;
13
10
  options: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"ReactAgent.d.ts","names":["InteropZodObject","CompiledStateGraph","MessagesAnnotation","ReactAgentAnnotation","CreateAgentParams","AnyAnnotationRoot","ToAnnotationRoot","ResponseFormatUndefined","AgentGraph","Record","StateSchema","spec","StructuredResponseFormat","ContextSchema","ReactAgent","ArrayBuffer","Uint8Array","Promise"],"sources":["../../src/agents/ReactAgent.d.ts"],"sourcesContent":["/* eslint-disable prefer-destructuring, no-instanceof/no-instanceof */\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport { CompiledStateGraph, MessagesAnnotation } from \"@langchain/langgraph\";\nimport { ReactAgentAnnotation } from \"./annotation.js\";\nimport type { CreateAgentParams } from \"./types.js\";\nimport { type AnyAnnotationRoot, type ToAnnotationRoot } from \"./annotation.js\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\ntype AgentGraph<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = CompiledStateGraph<ToAnnotationRoot<StateSchema>[\"State\"], ToAnnotationRoot<StateSchema>[\"Update\"], \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nany, typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>[\"spec\"], ReactAgentAnnotation<StructuredResponseFormat>[\"spec\"] & ToAnnotationRoot<StateSchema>[\"spec\"], ToAnnotationRoot<ContextSchema>[\"spec\"], unknown>;\nexport declare class ReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> {\n #private;\n options: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema>;\n constructor(options: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema>);\n /**\n * Get the compiled graph.\n */\n get graph(): AgentGraph<StateSchema, StructuredResponseFormat, ContextSchema>;\n /**\n * @inheritdoc\n */\n get invoke(): AgentGraph<StateSchema, StructuredResponseFormat>[\"invoke\"];\n /**\n * @inheritdoc\n */\n get stream(): AgentGraph<StateSchema, StructuredResponseFormat>[\"stream\"];\n /**\n * @inheritdoc\n */\n get streamEvents(): AgentGraph<StateSchema, StructuredResponseFormat>[\"streamEvents\"];\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 drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<Uint8Array<ArrayBuffer>>;\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 drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<string>;\n}\nexport {};\n"],"mappings":";;;;;;;AAM8D,KACzDQ,UAAAA,CAAAA,oBAA+BH,iBAArB,GAAyCL,gBAAzC,GAA4DK,iBAA5D,EAAA,iCAAgHI,MAAhH,CAAA,MAAA,EAAA,GAAA,CAAA,GAAsIF,uBAAtI,GAAgKE,MAAhK,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,sBAA2MJ,iBAA3M,GAA+NL,gBAA/N,GAAkPK,iBAAlP,CAAA,GAAuQJ,kBAAvQ,CAA0RK,gBAA1R,CAA2SI,WAA3S,CAAA,CAAA,OAAA,CAAA,EAAkUJ,gBAAlU,CAAmVI,WAAnV,CAAA,CAAA,QAAA,CAAA;;GAAA,EAAA,OAEHR,kBAAAA,CAAmBS,IAFKN,GAEEC,gBAFFD,CAEmBK,WAFnBL,CAAAA,CAAAA,MAAAA,CAAAA,EAEyCF,oBAFzCE,CAE8DO,wBAF9DP,CAAAA,CAAAA,MAAAA,CAAAA,GAE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AF2HA,EAAAA;IAA2CJ,UAAAA,CAAAA,EAAAA,OAAAA;IAAoBL,UAAAA,CAAAA,EAAAA,MAAAA;IAAmBK,UAAAA,CAAAA,EAiC5PI,MAjC4PJ,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;IAElPK,eAAAA,CAAAA,EAAAA,MAAAA;IAAaE,eAAAA,CAAAA,EAAAA,MAAAA;EAAwB,CAAA,CAAA,EAkC5DK,OAlC8DJ,CAkCtDG,UAlCsDH,CAkC3CE,WAlC2CF,CAAAA,CAAAA;EAAa;;;;;;;;;;EAS3C,WAAED,CAAAA,MAQI,CARJA,EAAAA;IAAxBJ,UAAAA,CAAAA,EAAAA,OAAAA;IAIWE,UAAAA,CAAAA,EAAAA,MAAAA;IAAaE,UAAAA,CAAAA,EAmCrBH,MAnCqBG,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;IAAxBJ,eAAAA,CAAAA,EAAAA,MAAAA;IAIiBE,eAAAA,CAAAA,EAAAA,MAAAA;EAAW,CAAA,CAAA,EAkCtCO,OAlCwCL,CAAAA,MAAAA,CAAAA"}
1
+ {"version":3,"file":"ReactAgent.d.ts","names":["InteropZodObject","CompiledStateGraph","MessagesAnnotation","ReactAgentAnnotation","CreateAgentParams","AnyAnnotationRoot","ToAnnotationRoot","ResponseFormatUndefined","AgentGraph","Record","StateSchema","spec","StructuredResponseFormat","ContextSchema","ReactAgent","ArrayBuffer","Uint8Array","Promise"],"sources":["../../src/agents/ReactAgent.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport { CompiledStateGraph, MessagesAnnotation } from \"@langchain/langgraph\";\nimport { ReactAgentAnnotation } from \"./annotation.js\";\nimport type { CreateAgentParams } from \"./types.js\";\nimport { type AnyAnnotationRoot, type ToAnnotationRoot, type ResponseFormatUndefined } from \"./annotation.js\";\ntype AgentGraph<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = CompiledStateGraph<ToAnnotationRoot<StateSchema>[\"State\"], ToAnnotationRoot<StateSchema>[\"Update\"], any, typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>[\"spec\"], ReactAgentAnnotation<StructuredResponseFormat>[\"spec\"] & ToAnnotationRoot<StateSchema>[\"spec\"], ToAnnotationRoot<ContextSchema>[\"spec\"], unknown>;\nexport declare class ReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, StructuredResponseFormat extends Record<string, any> | ResponseFormatUndefined = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> {\n #private;\n options: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema>;\n constructor(options: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema>);\n /**\n * Get the compiled graph.\n */\n get graph(): AgentGraph<StateSchema, StructuredResponseFormat, ContextSchema>;\n /**\n * @inheritdoc\n */\n get invoke(): AgentGraph<StateSchema, StructuredResponseFormat>[\"invoke\"];\n /**\n * @inheritdoc\n */\n get stream(): AgentGraph<StateSchema, StructuredResponseFormat>[\"stream\"];\n /**\n * @inheritdoc\n */\n get streamEvents(): AgentGraph<StateSchema, StructuredResponseFormat>[\"streamEvents\"];\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 drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<Uint8Array<ArrayBuffer>>;\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 drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<string>;\n}\nexport {};\n"],"mappings":";;;;;;AAK8G,KACzGQ,UAAAA,CAAAA,oBAA+BH,iBAArB,GAAyCL,gBAAzC,GAA4DK,iBAA5D,EAAA,iCAAgHI,MAAhH,CAAA,MAAA,EAAA,GAAA,CAAA,GAAsIF,uBAAtI,GAAgKE,MAAhK,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,sBAA2MJ,iBAA3M,GAA+NL,gBAA/N,GAAkPK,iBAAlP,CAAA,GAAuQJ,kBAAvQ,CAA0RK,gBAA1R,CAA2SI,WAA3S,CAAA,CAAA,OAAA,CAAA,EAAkUJ,gBAAlU,CAAmVI,WAAnV,CAAA,CAAA,QAAA,CAAA,EAAA,GAAA,EAAA,OAAuXR,kBAAAA,CAAmBS,IAA1Y,GAAiZL,gBAAjZ,CAAkaI,WAAla,CAAA,CAAA,MAAA,CAAA,EAAwbP,oBAAxb,CAA6cS,wBAA7c,CAAA,CAAA,MAAA,CAAA,GAAifN,gBAAjf,CAAkgBI,WAAlgB,CAAA,CAAA,MAAA,CAAA,EAAwhBJ,gBAAxhB,CAAyiBO,aAAziB,CAAA,CAAA,MAAA,CAAA,EAAA,OAAA,CAAA;AAAA,cACMC,UADN,CAAA,oBACqCT,iBADrC,GACyDL,gBADzD,GAC4EK,iBAD5E,EAAA,iCACgII,MADhI,CAAA,MAAA,EAAA,GAAA,CAAA,GACsJF,uBADtJ,GACgLE,MADhL,CAAA,MAAA,EAAA,GAAA,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A,MAQiD,CARjDA,EAAAA;IAIYE,UAAAA,CAAAA,EAAAA,OAAAA;IAAaE,UAAAA,CAAAA,EAAAA,MAAAA;IAAxBJ,UAAAA,CAAAA,EAuCGC,MAvCHD,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;IAIWE,eAAAA,CAAAA,EAAAA,MAAAA;IAAaE,eAAAA,CAAAA,EAAAA,MAAAA;EAAwB,CAAA,CAAA,EAsC1DK,OAtCUT,CAAAA,MAAAA,CAAAA"}
@@ -2,7 +2,7 @@ import { createAgentAnnotationConditional, enhanceStateSchemaWithMessageReducer
2
2
  import { isClientTool, validateLLMHasNoBoundTools } from "./utils.js";
3
3
  import { AgentNode } from "./nodes/AgentNode.js";
4
4
  import { ToolNode } from "./nodes/ToolNode.js";
5
- import { AIMessage, ToolMessage, isAIMessage, isToolMessage } from "@langchain/core/messages";
5
+ import { AIMessage, ToolMessage } from "@langchain/core/messages";
6
6
  import { END, START, Send, StateGraph } from "@langchain/langgraph";
7
7
 
8
8
  //#region src/agents/ReactAgent.ts
@@ -117,8 +117,8 @@ var ReactAgent = class {
117
117
  #createPostModelHookRouter() {
118
118
  return (state) => {
119
119
  const messages = state.messages;
120
- const toolMessages = messages.filter(isToolMessage);
121
- const lastAiMessage = messages.filter(isAIMessage).at(-1);
120
+ const toolMessages = messages.filter(ToolMessage.isInstance);
121
+ const lastAiMessage = messages.filter(AIMessage.isInstance).at(-1);
122
122
  const pendingToolCalls = lastAiMessage?.tool_calls?.filter((call) => !toolMessages.some((m) => m.tool_call_id === call.id));
123
123
  if (pendingToolCalls && pendingToolCalls.length > 0) {
124
124
  /**
@@ -136,7 +136,7 @@ var ReactAgent = class {
136
136
  lg_tool_call: toolCall
137
137
  }));
138
138
  }
139
- if (messages.at(-1) instanceof ToolMessage) return this.#getEntryPoint();
139
+ if (ToolMessage.isInstance(messages.at(-1))) return this.#getEntryPoint();
140
140
  return END;
141
141
  };
142
142
  }
@@ -161,7 +161,7 @@ var ReactAgent = class {
161
161
  return (state) => {
162
162
  const messages = state.messages;
163
163
  const lastMessage = messages.at(-1);
164
- if (!(lastMessage instanceof AIMessage) || !lastMessage.tool_calls || lastMessage.tool_calls.length === 0) {
164
+ if (!AIMessage.isInstance(lastMessage) || !lastMessage.tool_calls || lastMessage.tool_calls.length === 0) {
165
165
  if (this.options.postModelHook) return "post_model_hook";
166
166
  return END;
167
167
  }
@@ -186,7 +186,7 @@ var ReactAgent = class {
186
186
  return (state) => {
187
187
  const messages = state.messages;
188
188
  const lastMessage = messages[messages.length - 1];
189
- if (lastMessage instanceof ToolMessage && lastMessage.name && shouldReturnDirect.has(lastMessage.name)) return this.options.responseFormat ? this.#getEntryPoint() : END;
189
+ if (ToolMessage.isInstance(lastMessage) && lastMessage.name && shouldReturnDirect.has(lastMessage.name)) return this.options.responseFormat ? this.#getEntryPoint() : END;
190
190
  return this.#getEntryPoint();
191
191
  };
192
192
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ReactAgent.js","names":["options: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n >","#toolBehaviorVersion","#inputSchema","#getEntryPoint","#getPostModelHookPaths","#createPostModelHookRouter","#getModelPaths","#createModelRouter","#createToolsRouter","#graph","toolClasses: (ClientTool | ServerTool)[]","paths: (typeof END | \"agent\" | \"pre_model_hook\" | \"tools\")[]","state: InternalAgentState<StructuredResponseFormat>","paths: (\"tools\" | typeof END)[]","shouldReturnDirect: Set<string>","params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }"],"sources":["../../src/agents/ReactAgent.ts"],"sourcesContent":["/* eslint-disable prefer-destructuring, no-instanceof/no-instanceof */\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport {\n AnnotationRoot,\n StateGraph,\n END,\n START,\n Send,\n CompiledStateGraph,\n MessagesAnnotation,\n} from \"@langchain/langgraph\";\nimport {\n isToolMessage,\n isAIMessage,\n ToolMessage,\n AIMessage,\n} from \"@langchain/core/messages\";\n\nimport {\n createAgentAnnotationConditional,\n ReactAgentAnnotation,\n} from \"./annotation.js\";\nimport { isClientTool, validateLLMHasNoBoundTools } from \"./utils.js\";\nimport { AgentNode } from \"./nodes/AgentNode.js\";\nimport { ToolNode } from \"./nodes/ToolNode.js\";\nimport type {\n CreateAgentParams,\n ClientTool,\n ServerTool,\n InternalAgentState,\n WithStateGraphNodes,\n} from \"./types.js\";\nimport {\n enhanceStateSchemaWithMessageReducer,\n type AnyAnnotationRoot,\n type ToAnnotationRoot,\n} from \"./annotation.js\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\n\ntype AgentGraph<\n StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n> = CompiledStateGraph<\n ToAnnotationRoot<StateSchema>[\"State\"],\n ToAnnotationRoot<StateSchema>[\"Update\"],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any,\n typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>[\"spec\"],\n ReactAgentAnnotation<StructuredResponseFormat>[\"spec\"] &\n ToAnnotationRoot<StateSchema>[\"spec\"],\n ToAnnotationRoot<ContextSchema>[\"spec\"],\n unknown\n>;\n\nexport class ReactAgent<\n StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n> {\n #graph: AgentGraph<StateSchema, StructuredResponseFormat, ContextSchema>;\n\n #inputSchema?: AnnotationRoot<ToAnnotationRoot<StateSchema>[\"spec\"]>;\n\n #toolBehaviorVersion: \"v1\" | \"v2\" = \"v2\";\n\n constructor(\n public options: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n >\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 = Array.isArray(options.tools)\n ? options.tools\n : options.tools.tools;\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 const schema = this.options.stateSchema\n ? enhanceStateSchemaWithMessageReducer(this.options.stateSchema)\n : createAgentAnnotationConditional<StructuredResponseFormat>(\n this.options.responseFormat !== undefined\n );\n\n const workflow = new StateGraph(schema, this.options.contextSchema);\n\n const allNodeWorkflows = workflow as WithStateGraphNodes<\n \"pre_model_hook\" | \"post_model_hook\" | \"tools\" | \"agent\",\n typeof workflow\n >;\n\n /**\n * Add Nodes\n */\n allNodeWorkflows.addNode(\n \"agent\",\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 toolClasses,\n shouldReturnDirect,\n signal: this.options.signal,\n }),\n {\n input: this.#inputSchema,\n }\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 * setup preModelHook\n */\n if (options.preModelHook) {\n allNodeWorkflows.addNode(\"pre_model_hook\", options.preModelHook);\n }\n\n /**\n * setup postModelHook\n */\n if (options.postModelHook) {\n allNodeWorkflows.addNode(\"post_model_hook\", options.postModelHook);\n }\n\n /**\n * Add Edges\n */\n allNodeWorkflows.addEdge(START, this.#getEntryPoint());\n\n if (this.options.preModelHook) {\n allNodeWorkflows.addEdge(\"pre_model_hook\", \"agent\");\n }\n\n if (this.options.postModelHook) {\n allNodeWorkflows.addEdge(\"agent\", \"post_model_hook\");\n const postHookPaths = this.#getPostModelHookPaths(\n toolClasses.filter(isClientTool)\n );\n if (postHookPaths.length === 1) {\n allNodeWorkflows.addEdge(\"post_model_hook\", postHookPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n \"post_model_hook\",\n this.#createPostModelHookRouter(),\n postHookPaths\n );\n }\n } else {\n const modelPaths = this.#getModelPaths(toolClasses.filter(isClientTool));\n if (modelPaths.length === 1) {\n allNodeWorkflows.addEdge(\"agent\", modelPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n \"agent\",\n this.#createModelRouter(),\n modelPaths\n );\n }\n }\n\n /**\n * add edges for tools node\n */\n if (toolClasses.length > 0) {\n if (shouldReturnDirect.size > 0) {\n allNodeWorkflows.addConditionalEdges(\n \"tools\",\n this.#createToolsRouter(shouldReturnDirect),\n [this.#getEntryPoint(), END]\n );\n } else {\n allNodeWorkflows.addEdge(\"tools\", this.#getEntryPoint());\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 });\n }\n\n /**\n * Get the compiled graph.\n */\n get graph(): AgentGraph<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n > {\n return this.#graph;\n }\n\n #getEntryPoint() {\n const entryPoint = this.options.preModelHook ? \"pre_model_hook\" : \"agent\";\n return entryPoint;\n }\n\n /**\n * Get possible edge destinations from post_model_hook node.\n */\n #getPostModelHookPaths(toolClasses: (ClientTool | ServerTool)[]) {\n const paths: (typeof END | \"agent\" | \"pre_model_hook\" | \"tools\")[] = [];\n if (toolClasses.length > 0) {\n paths.push(this.#getEntryPoint(), \"tools\");\n }\n paths.push(END);\n return paths;\n }\n\n #createPostModelHookRouter() {\n return (state: InternalAgentState<StructuredResponseFormat>) => {\n const messages = state.messages;\n const toolMessages = messages.filter(isToolMessage);\n const lastAiMessage = messages.filter(isAIMessage).at(-1);\n const pendingToolCalls = lastAiMessage?.tool_calls?.filter(\n (call) => !toolMessages.some((m) => m.tool_call_id === call.id)\n );\n\n if (pendingToolCalls && pendingToolCalls.length > 0) {\n /**\n * The tool node processes a single message.\n * All tool calls in the message are executed in parallel within the tool node.\n * @deprecated likely to be removed in the next version of the agent\n */\n if (this.#toolBehaviorVersion === \"v1\") {\n return \"tools\";\n }\n\n /**\n * The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n */\n return pendingToolCalls.map(\n (toolCall) => new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n }\n\n if (messages.at(-1) instanceof ToolMessage) {\n return this.#getEntryPoint();\n }\n\n return END;\n };\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 return (state: InternalAgentState<StructuredResponseFormat>) => {\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 if (this.options.postModelHook) {\n return \"post_model_hook\";\n }\n\n return END;\n }\n\n if (this.options.postModelHook) {\n return \"post_model_hook\";\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 return (state: InternalAgentState<StructuredResponseFormat>) => {\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 ? this.#getEntryPoint() : END;\n }\n\n // For non-returnDirect tools, always route back to agent\n return this.#getEntryPoint();\n };\n }\n\n /**\n * @inheritdoc\n */\n get invoke(): AgentGraph<StateSchema, StructuredResponseFormat>[\"invoke\"] {\n return this.#graph.invoke.bind(this.#graph);\n }\n\n /**\n * @inheritdoc\n */\n get stream(): AgentGraph<StateSchema, StructuredResponseFormat>[\"stream\"] {\n return this.#graph.stream.bind(this.#graph);\n }\n\n /**\n * @inheritdoc\n */\n get streamEvents(): AgentGraph<\n StateSchema,\n StructuredResponseFormat\n >[\"streamEvents\"] {\n return this.#graph.streamEvents.bind(this.#graph);\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":";;;;;;;;AAyDA,IAAa,aAAb,MAME;CACA;CAEA;CAEA,uBAAoC;CAEpC,YACSA,SAKP;EALO;EAMP,KAAKC,uBAAuB,QAAQ,WAAW,KAAKA;;;;AAKpD,MAAI,QAAQ,OAAO,OAAO,QAAQ,QAAQ,YACxC,2BAA2B,QAAQ,IAAI;;;;AAMzC,MAAI,QAAQ,OAAO,QAAQ,MACzB,OAAM,IAAI,MAAM;;;;AAMlB,MAAI,CAAC,QAAQ,OAAO,CAAC,QAAQ,MAC3B,OAAM,IAAI,MACR;EAIJ,MAAM,cAAc,MAAM,QAAQ,QAAQ,MAAM,GAC5C,QAAQ,QACR,QAAQ,MAAM;;;;;EAMlB,MAAM,qBAAqB,IAAI,IAC7B,YACG,OAAO,aAAa,CACpB,OAAO,CAAC,SAAS,kBAAkB,QAAQ,KAAK,aAAa,CAC7D,IAAI,CAAC,SAAS,KAAK,KAAK;EAG7B,MAAM,SAAS,KAAK,QAAQ,cACxB,qCAAqC,KAAK,QAAQ,YAAY,GAC9D,iCACE,KAAK,QAAQ,mBAAmB,OACjC;EAEL,MAAM,WAAW,IAAI,WAAW,QAAQ,K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AAI,WAAW;AAC9B,SAAO;CACR;;;;;;;;;;;CAYD,MAAM,YAAYM,QAMf;EACD,MAAM,iBAAiB,MAAM,KAAKN,OAAO,eAAe;AACxD,SAAO,eAAe,YAAY,OAAO;CAC1C;AACF"}
1
+ {"version":3,"file":"ReactAgent.js","names":["options: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n >","#toolBehaviorVersion","#inputSchema","#getEntryPoint","#getPostModelHookPaths","#createPostModelHookRouter","#getModelPaths","#createModelRouter","#createToolsRouter","#graph","toolClasses: (ClientTool | ServerTool)[]","paths: (typeof END | \"agent\" | \"pre_model_hook\" | \"tools\")[]","state: InternalAgentState<StructuredResponseFormat>","paths: (\"tools\" | typeof END)[]","shouldReturnDirect: Set<string>","params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }"],"sources":["../../src/agents/ReactAgent.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport {\n AnnotationRoot,\n StateGraph,\n END,\n START,\n Send,\n CompiledStateGraph,\n MessagesAnnotation,\n} from \"@langchain/langgraph\";\nimport { ToolMessage, AIMessage } from \"@langchain/core/messages\";\n\nimport {\n createAgentAnnotationConditional,\n ReactAgentAnnotation,\n} from \"./annotation.js\";\nimport { isClientTool, validateLLMHasNoBoundTools } from \"./utils.js\";\nimport { AgentNode } from \"./nodes/AgentNode.js\";\nimport { ToolNode } from \"./nodes/ToolNode.js\";\nimport type {\n CreateAgentParams,\n ClientTool,\n ServerTool,\n InternalAgentState,\n WithStateGraphNodes,\n} from \"./types.js\";\nimport {\n enhanceStateSchemaWithMessageReducer,\n type AnyAnnotationRoot,\n type ToAnnotationRoot,\n type ResponseFormatUndefined,\n} from \"./annotation.js\";\n\ntype AgentGraph<\n StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n> = CompiledStateGraph<\n ToAnnotationRoot<StateSchema>[\"State\"],\n ToAnnotationRoot<StateSchema>[\"Update\"],\n any,\n typeof MessagesAnnotation.spec & ToAnnotationRoot<StateSchema>[\"spec\"],\n ReactAgentAnnotation<StructuredResponseFormat>[\"spec\"] &\n ToAnnotationRoot<StateSchema>[\"spec\"],\n ToAnnotationRoot<ContextSchema>[\"spec\"],\n unknown\n>;\n\nexport class ReactAgent<\n StateSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n StructuredResponseFormat extends\n | Record<string, any>\n | ResponseFormatUndefined = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n> {\n #graph: AgentGraph<StateSchema, StructuredResponseFormat, ContextSchema>;\n\n #inputSchema?: AnnotationRoot<ToAnnotationRoot<StateSchema>[\"spec\"]>;\n\n #toolBehaviorVersion: \"v1\" | \"v2\" = \"v2\";\n\n constructor(\n public options: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n >\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 = Array.isArray(options.tools)\n ? options.tools\n : options.tools.tools;\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 const schema = this.options.stateSchema\n ? enhanceStateSchemaWithMessageReducer(this.options.stateSchema)\n : createAgentAnnotationConditional<StructuredResponseFormat>(\n this.options.responseFormat !== undefined\n );\n\n const workflow = new StateGraph(schema, this.options.contextSchema);\n\n const allNodeWorkflows = workflow as WithStateGraphNodes<\n \"pre_model_hook\" | \"post_model_hook\" | \"tools\" | \"agent\",\n typeof workflow\n >;\n\n /**\n * Add Nodes\n */\n allNodeWorkflows.addNode(\n \"agent\",\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 toolClasses,\n shouldReturnDirect,\n signal: this.options.signal,\n }),\n {\n input: this.#inputSchema,\n }\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 * setup preModelHook\n */\n if (options.preModelHook) {\n allNodeWorkflows.addNode(\"pre_model_hook\", options.preModelHook);\n }\n\n /**\n * setup postModelHook\n */\n if (options.postModelHook) {\n allNodeWorkflows.addNode(\"post_model_hook\", options.postModelHook);\n }\n\n /**\n * Add Edges\n */\n allNodeWorkflows.addEdge(START, this.#getEntryPoint());\n\n if (this.options.preModelHook) {\n allNodeWorkflows.addEdge(\"pre_model_hook\", \"agent\");\n }\n\n if (this.options.postModelHook) {\n allNodeWorkflows.addEdge(\"agent\", \"post_model_hook\");\n const postHookPaths = this.#getPostModelHookPaths(\n toolClasses.filter(isClientTool)\n );\n if (postHookPaths.length === 1) {\n allNodeWorkflows.addEdge(\"post_model_hook\", postHookPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n \"post_model_hook\",\n this.#createPostModelHookRouter(),\n postHookPaths\n );\n }\n } else {\n const modelPaths = this.#getModelPaths(toolClasses.filter(isClientTool));\n if (modelPaths.length === 1) {\n allNodeWorkflows.addEdge(\"agent\", modelPaths[0]);\n } else {\n allNodeWorkflows.addConditionalEdges(\n \"agent\",\n this.#createModelRouter(),\n modelPaths\n );\n }\n }\n\n /**\n * add edges for tools node\n */\n if (toolClasses.length > 0) {\n if (shouldReturnDirect.size > 0) {\n allNodeWorkflows.addConditionalEdges(\n \"tools\",\n this.#createToolsRouter(shouldReturnDirect),\n [this.#getEntryPoint(), END]\n );\n } else {\n allNodeWorkflows.addEdge(\"tools\", this.#getEntryPoint());\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 });\n }\n\n /**\n * Get the compiled graph.\n */\n get graph(): AgentGraph<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema\n > {\n return this.#graph;\n }\n\n #getEntryPoint() {\n const entryPoint = this.options.preModelHook ? \"pre_model_hook\" : \"agent\";\n return entryPoint;\n }\n\n /**\n * Get possible edge destinations from post_model_hook node.\n */\n #getPostModelHookPaths(toolClasses: (ClientTool | ServerTool)[]) {\n const paths: (typeof END | \"agent\" | \"pre_model_hook\" | \"tools\")[] = [];\n if (toolClasses.length > 0) {\n paths.push(this.#getEntryPoint(), \"tools\");\n }\n paths.push(END);\n return paths;\n }\n\n #createPostModelHookRouter() {\n return (state: InternalAgentState<StructuredResponseFormat>) => {\n const messages = state.messages;\n const toolMessages = messages.filter(ToolMessage.isInstance);\n const lastAiMessage = messages.filter(AIMessage.isInstance).at(-1);\n const pendingToolCalls = lastAiMessage?.tool_calls?.filter(\n (call) => !toolMessages.some((m) => m.tool_call_id === call.id)\n );\n\n if (pendingToolCalls && pendingToolCalls.length > 0) {\n /**\n * The tool node processes a single message.\n * All tool calls in the message are executed in parallel within the tool node.\n * @deprecated likely to be removed in the next version of the agent\n */\n if (this.#toolBehaviorVersion === \"v1\") {\n return \"tools\";\n }\n\n /**\n * The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n */\n return pendingToolCalls.map(\n (toolCall) => new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n }\n\n if (ToolMessage.isInstance(messages.at(-1))) {\n return this.#getEntryPoint();\n }\n\n return END;\n };\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 return (state: InternalAgentState<StructuredResponseFormat>) => {\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 if (this.options.postModelHook) {\n return \"post_model_hook\";\n }\n\n return END;\n }\n\n if (this.options.postModelHook) {\n return \"post_model_hook\";\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 return (state: InternalAgentState<StructuredResponseFormat>) => {\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 ? this.#getEntryPoint() : END;\n }\n\n // For non-returnDirect tools, always route back to agent\n return this.#getEntryPoint();\n };\n }\n\n /**\n * @inheritdoc\n */\n get invoke(): AgentGraph<StateSchema, StructuredResponseFormat>[\"invoke\"] {\n return this.#graph.invoke.bind(this.#graph);\n }\n\n /**\n * @inheritdoc\n */\n get stream(): AgentGraph<StateSchema, StructuredResponseFormat>[\"stream\"] {\n return this.#graph.stream.bind(this.#graph);\n }\n\n /**\n * @inheritdoc\n */\n get streamEvents(): AgentGraph<\n StateSchema,\n StructuredResponseFormat\n >[\"streamEvents\"] {\n return this.#graph.streamEvents.bind(this.#graph);\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 represent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AC,aAAa,IAAI,KAAK,SAAS;IAAE,GAAG;IAAO,cAAc;GAAU,GACrE;EACF;CACF;;;;CAKD,mBAAmBa,oBAAiC;AAClD,SAAO,CAACF,UAAwD;GAC9D,MAAM,WAAW,MAAM;GACvB,MAAM,cAAc,SAAS,SAAS,SAAS;AAG/C,OACE,YAAY,WAAW,YAAY,IACnC,YAAY,QACZ,mBAAmB,IAAI,YAAY,KAAK,CAIxC,QAAO,KAAK,QAAQ,iBAAiB,KAAKT,gBAAgB,GAAG;AAI/D,UAAO,KAAKA,gBAAgB;EAC7B;CACF;;;;CAKD,IAAI,SAAsE;AACxE,SAAO,KAAKM,OAAO,OAAO,KAAK,KAAKA,OAAO;CAC5C;;;;CAKD,IAAI,SAAsE;AACxE,SAAO,KAAKA,OAAO,OAAO,KAAK,KAAKA,OAAO;CAC5C;;;;CAKD,IAAI,eAGc;AAChB,SAAO,KAAKA,OAAO,aAAa,KAAK,KAAKA,OAAO;CAClD;;;;;;;;;;;CAYD,MAAM,eAAeM,QAMlB;EACD,MAAM,iBAAiB,MAAM,KAAKN,OAAO,eAAe;EACxD,MAAM,QAAQ,MAAM,eAAe,eAAe,OAAO;EACzD,MAAM,cAAc,MAAM,MAAM,aAAa;EAC7C,MAAM,SAAS,IAAI,WAAW;AAC9B,SAAO;CACR;;;;;;;;;;;CAYD,MAAM,YAAYM,QAMf;EACD,MAAM,iBAAiB,MAAM,KAAKN,OAAO,eAAe;AACxD,SAAO,eAAe,YAAY,OAAO;CAC1C;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"annotation.cjs","names":["PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>","Annotation","messagesStateReducer","stateSchema: AnyAnnotationRoot | InteropZodObject","annotationFields: Record<string, any>","_: unknown","update: unknown","current: unknown[]","update: unknown[]","config: (typeof ZOD_TYPE_CONFIGS)[keyof typeof ZOD_TYPE_CONFIGS]","defaultValueFn: () => unknown","zodType: any","config"],"sources":["../../src/agents/annotation.ts"],"sourcesContent":["import { BaseMessage } from \"@langchain/core/messages\";\nimport {\n Annotation,\n Messages,\n AnnotationRoot,\n messagesStateReducer,\n type BinaryOperatorAggregate,\n type LastValue,\n} from \"@langchain/langgraph\";\nimport type { InteropZodToStateDefinition } from \"@langchain/langgraph/zod\";\nimport {\n isInteropZodSchema,\n getInteropZodObjectShape,\n getInteropZodDefaultGetter,\n type InteropZodObject,\n} from \"@langchain/core/utils/types\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\n\nexport const PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}> = Annotation.Root({\n llmInputMessages: Annotation<BaseMessage[], Messages>({\n reducer: (_, update) => messagesStateReducer([], update),\n default: () => [],\n }),\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n});\nexport type PreHookAnnotation = typeof PreHookAnnotation;\n\n// Base annotation without structuredResponse (for ResponseFormatUndefined)\nexport const createAgentBaseAnnotation = () =>\n Annotation.Root({\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n });\n\n// Full annotation with structuredResponse (for regular cases)\nconst createAgentAnnotation = <\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, any> = Record<string, any>\n>(): AnnotationRoot<{\n structuredResponse: LastValue<T>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}> =>\n Annotation.Root({\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n structuredResponse: Annotation<T>(),\n });\n\n// Create annotation conditionally - for ResponseFormatUndefined, don't include structuredResponse\nexport function createAgentAnnotationConditional<\n T extends Record<string, any> | ResponseFormatUndefined\n>(\n hasStructuredResponse = true\n): AnnotationRoot<{\n structuredResponse: LastValue<T extends ResponseFormatUndefined ? never : T>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}> {\n const baseAnnotation = {\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n };\n\n if (!hasStructuredResponse) {\n return Annotation.Root(baseAnnotation) as AnnotationRoot<{\n structuredResponse: LastValue<\n T extends ResponseFormatUndefined ? never : T\n >;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n }>;\n }\n\n return Annotation.Root({\n ...baseAnnotation,\n structuredResponse:\n Annotation<T extends ResponseFormatUndefined ? never : T>(),\n });\n}\n\n// Helper type to select the right annotation based on the response format type\nexport type ReactAgentAnnotation<\n T extends Record<string, any> | ResponseFormatUndefined\n> = T extends ResponseFormatUndefined\n ? ReturnType<typeof createAgentBaseAnnotation>\n : T extends Record<string, any>\n ? ReturnType<typeof createAgentAnnotation<T>>\n : never;\n\nexport type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> =\n A extends AnyAnnotationRoot\n ? A\n : A extends InteropZodObject\n ? AnnotationRoot<InteropZodToStateDefinition<A>>\n : never;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyAnnotationRoot = AnnotationRoot<any>;\n\n/**\n * Enhances a state schema to ensure proper message handling.\n * If a Zod schema is provided, it creates an annotation that includes the messagesStateReducer\n * and infers appropriate reducers for all other fields.\n *\n * @param stateSchema - The state schema to enhance.\n * @returns The enhanced state schema.\n */\nexport function enhanceStateSchemaWithMessageReducer(\n stateSchema: AnyAnnotationRoot | InteropZodObject\n) {\n /**\n * If it's already an annotation, return as-is\n */\n if (typeof stateSchema === \"object\" && \"State\" in stateSchema) {\n return stateSchema;\n }\n\n /**\n * If it's a Zod schema, create annotations for all fields\n */\n if (isInteropZodSchema(stateSchema)) {\n const shape = getInteropZodObjectShape(stateSchema);\n const annotationFields: Record<string, any> = {};\n\n /**\n * Process each field in the Zod schema\n */\n for (const [key, zodType] of Object.entries(shape)) {\n annotationFields[key] =\n key === \"messages\"\n ? /**\n * Special handling for messages field - always use messagesStateReducer\n */\n Annotation<BaseMessage[]>({\n reducer: messagesStateReducer,\n default: () => [],\n })\n : /**\n * For other fields, create appropriate annotations based on type\n */\n createAnnotationForZodType(zodType);\n }\n\n /**\n * Ensure messages field exists even if not in the Zod schema\n */\n if (!annotationFields.messages) {\n annotationFields.messages = Annotation<BaseMessage[]>({\n reducer: messagesStateReducer,\n default: () => [],\n });\n }\n\n return Annotation.Root(annotationFields);\n }\n\n /**\n * Fallback: create a base annotation with message reducer only\n */\n return Annotation.Root({\n messages: Annotation<BaseMessage[]>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n });\n}\n\n/**\n * Type configuration for different Zod types\n */\nconst ZOD_TYPE_CONFIGS = {\n ZodString: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: \"\",\n },\n ZodNumber: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: 0,\n },\n ZodBoolean: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: false,\n },\n ZodArray: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: [] as unknown[],\n },\n ZodRecord: {\n reducer: (current: unknown[], update: unknown[]) => ({\n ...current,\n ...update,\n }),\n fallbackDefault: {} as Record<string, unknown>,\n },\n ZodObject: {\n reducer: (current: unknown[], update: unknown[]) => ({\n ...current,\n ...update,\n }),\n fallbackDefault: {} as Record<string, unknown>,\n },\n} as const;\n\n/**\n * Creates an annotation based on type configuration and default value\n */\nfunction createAnnotationFromConfig(\n config: (typeof ZOD_TYPE_CONFIGS)[keyof typeof ZOD_TYPE_CONFIGS],\n defaultValueFn: () => unknown\n) {\n return Annotation<any>({\n reducer: config.reducer,\n default: defaultValueFn,\n });\n}\n\n/**\n * Creates an appropriate annotation for a given Zod type.\n */\nfunction createAnnotationForZodType(zodType: any): any {\n const typeName = zodType._def?.typeName;\n const defaultGetter = getInteropZodDefaultGetter(zodType);\n const isOptional = typeName === \"ZodOptional\";\n\n /**\n * Handle Zod wrapper first\n */\n if (\n typeName === \"ZodDefault\" ||\n typeName === \"ZodOptional\" ||\n typeName === \"ZodNullable\"\n ) {\n const innerTypeName = zodType._def.innerType._def?.typeName;\n const config =\n ZOD_TYPE_CONFIGS[innerTypeName as keyof typeof ZOD_TYPE_CONFIGS];\n return config\n ? createAnnotationFromConfig(\n config,\n () =>\n defaultGetter?.() ||\n (isOptional ? undefined : config?.fallbackDefault)\n )\n : Annotation<unknown>({\n reducer: (_: unknown, update: unknown) => update,\n default: () => defaultGetter?.(),\n });\n }\n\n /**\n * Handle regular types\n */\n const config = ZOD_TYPE_CONFIGS[typeName as keyof typeof ZOD_TYPE_CONFIGS];\n if (config) {\n return createAnnotationFromConfig(\n config,\n () => defaultGetter?.() || config?.fallbackDefault\n );\n }\n\n /**\n * Fallback for unknown types\n */\n return Annotation<unknown>({\n reducer: (_: unknown, update: unknown) => update,\n default: () => defaultGetter?.(),\n });\n}\n"],"mappings":";;;;;AAkBA,MAAaA,oBAGRC,iCAAW,KAAK;CACnB,wDAAsD;EACpD,SAAS,CAAC,GAAG,2DAAgC,CAAE,GAAE,OAAO;EACxD,SAAS,MAAM,CAAE;CAClB,EAAC;CACF,gDAA8C;EAC5C,SAASC;EACT,SAAS,MAAM,CAAE;CAClB,EAAC;AACH,EAAC;AA6BF,SAAgB,iCAGd,wBAAwB,MAIvB;CACD,MAAM,iBAAiB,EACrB,gDAA8C;EAC5C,SAASA;EACT,SAAS,MAAM,CAAE;CAClB,EAAC,CACH;AAED,KAAI,CAAC,sBACH,QAAOD,iCAAW,KAAK,eAAe;AAQxC,QAAOA,iCAAW,KAAK;EACrB,GAAG;EACH,2DAC6D;CAC9D,EAAC;AACH;;;;;;;;;AA6BD,SAAgB,qCACdE,aACA;;;;AAIA,KAAI,OAAO,gBAAgB,YAAY,WAAW,YAChD,QAAO;;;;AAMT,0DAAuB,YAAY,EAAE;EACnC,MAAM,mEAAiC,YA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UAAU,MAAM;EACnD,MAAMC,WACJ,iBAAiB;AACnB,SAAOA,WACH,2BACEA,UACA,MACE,iBAAiB,KAChB,aAAa,SAAYA,UAAQ,iBACrC,yCACmB;GAClB,SAAS,CAACP,GAAYC,WAAoB;GAC1C,SAAS,MAAM,iBAAiB;EACjC,EAAC;CACP;;;;CAKD,MAAM,SAAS,iBAAiB;AAChC,KAAI,OACF,QAAO,2BACL,QACA,MAAM,iBAAiB,IAAI,QAAQ,gBACpC;;;;AAMH,8CAA2B;EACzB,SAAS,CAACD,GAAYC,WAAoB;EAC1C,SAAS,MAAM,iBAAiB;CACjC,EAAC;AACH"}
1
+ {"version":3,"file":"annotation.cjs","names":["PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>","Annotation","messagesStateReducer","stateSchema: AnyAnnotationRoot | InteropZodObject","annotationFields: Record<string, any>","_: unknown","update: unknown","current: unknown[]","update: unknown[]","config: (typeof ZOD_TYPE_CONFIGS)[keyof typeof ZOD_TYPE_CONFIGS]","defaultValueFn: () => unknown","zodType: any","config"],"sources":["../../src/agents/annotation.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport {\n Annotation,\n Messages,\n AnnotationRoot,\n messagesStateReducer,\n type BinaryOperatorAggregate,\n type LastValue,\n} from \"@langchain/langgraph\";\nimport type { InteropZodToStateDefinition } from \"@langchain/langgraph/zod\";\nimport {\n isInteropZodSchema,\n getInteropZodObjectShape,\n getInteropZodDefaultGetter,\n type InteropZodObject,\n} from \"@langchain/core/utils/types\";\n\n/**\n * Special type to indicate that no response format is provided.\n * When this type is used, the structuredResponse property should not be present in the result.\n */\nexport type ResponseFormatUndefined = {\n __responseFormatUndefined: true;\n};\n\nexport const PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}> = Annotation.Root({\n llmInputMessages: Annotation<BaseMessage[], Messages>({\n reducer: (_, update) => messagesStateReducer([], update),\n default: () => [],\n }),\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n});\nexport type PreHookAnnotation = typeof PreHookAnnotation;\n\n// Base annotation without structuredResponse (for ResponseFormatUndefined)\nexport const createAgentBaseAnnotation = () =>\n Annotation.Root({\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n });\n\n// Full annotation with structuredResponse (for regular cases)\nexport const createAgentAnnotation = <\n T extends Record<string, any> = Record<string, any>\n>(): AnnotationRoot<{\n structuredResponse: LastValue<T>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}> =>\n Annotation.Root({\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n structuredResponse: Annotation<T>(),\n });\n\n// Create annotation conditionally - for ResponseFormatUndefined, don't include structuredResponse\nexport function createAgentAnnotationConditional<\n T extends Record<string, any> | ResponseFormatUndefined\n>(\n hasStructuredResponse = true\n): AnnotationRoot<{\n structuredResponse: LastValue<T extends ResponseFormatUndefined ? never : T>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}> {\n const baseAnnotation = {\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n };\n\n if (!hasStructuredResponse) {\n return Annotation.Root(baseAnnotation) as AnnotationRoot<{\n structuredResponse: LastValue<\n T extends ResponseFormatUndefined ? never : T\n >;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n }>;\n }\n\n return Annotation.Root({\n ...baseAnnotation,\n structuredResponse:\n Annotation<T extends ResponseFormatUndefined ? never : T>(),\n });\n}\n\n// Helper type to select the right annotation based on the response format type\nexport type ReactAgentAnnotation<\n T extends Record<string, any> | ResponseFormatUndefined\n> = T extends ResponseFormatUndefined\n ? ReturnType<typeof createAgentBaseAnnotation>\n : T extends Record<string, any>\n ? ReturnType<typeof createAgentAnnotation<T>>\n : never;\n\nexport type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> =\n A extends AnyAnnotationRoot\n ? A\n : A extends InteropZodObject\n ? AnnotationRoot<InteropZodToStateDefinition<A>>\n : never;\n\nexport type AnyAnnotationRoot = AnnotationRoot<any>;\n\n/**\n * Enhances a state schema to ensure proper message handling.\n * If a Zod schema is provided, it creates an annotation that includes the messagesStateReducer\n * and infers appropriate reducers for all other fields.\n *\n * @param stateSchema - The state schema to enhance.\n * @returns The enhanced state schema.\n */\nexport function enhanceStateSchemaWithMessageReducer(\n stateSchema: AnyAnnotationRoot | InteropZodObject\n) {\n /**\n * If it's already an annotation, return as-is\n */\n if (typeof stateSchema === \"object\" && \"State\" in stateSchema) {\n return stateSchema;\n }\n\n /**\n * If it's a Zod schema, create annotations for all fields\n */\n if (isInteropZodSchema(stateSchema)) {\n const shape = getInteropZodObjectShape(stateSchema);\n const annotationFields: Record<string, any> = {};\n\n /**\n * Process each field in the Zod schema\n */\n for (const [key, zodType] of Object.entries(shape)) {\n annotationFields[key] =\n key === \"messages\"\n ? /**\n * Special handling for messages field - always use messagesStateReducer\n */\n Annotation<BaseMessage[]>({\n reducer: messagesStateReducer,\n default: () => [],\n })\n : /**\n * For other fields, create appropriate annotations based on type\n */\n createAnnotationForZodType(zodType);\n }\n\n /**\n * Ensure messages field exists even if not in the Zod schema\n */\n if (!annotationFields.messages) {\n annotationFields.messages = Annotation<BaseMessage[]>({\n reducer: messagesStateReducer,\n default: () => [],\n });\n }\n\n return Annotation.Root(annotationFields);\n }\n\n /**\n * Fallback: create a base annotation with message reducer only\n */\n return Annotation.Root({\n messages: Annotation<BaseMessage[]>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n });\n}\n\n/**\n * Type configuration for different Zod types\n */\nconst ZOD_TYPE_CONFIGS = {\n ZodString: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: \"\",\n },\n ZodNumber: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: 0,\n },\n ZodBoolean: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: false,\n },\n ZodArray: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: [] as unknown[],\n },\n ZodRecord: {\n reducer: (current: unknown[], update: unknown[]) => ({\n ...current,\n ...update,\n }),\n fallbackDefault: {} as Record<string, unknown>,\n },\n ZodObject: {\n reducer: (current: unknown[], update: unknown[]) => ({\n ...current,\n ...update,\n }),\n fallbackDefault: {} as Record<string, unknown>,\n },\n} as const;\n\n/**\n * Creates an annotation based on type configuration and default value\n */\nfunction createAnnotationFromConfig(\n config: (typeof ZOD_TYPE_CONFIGS)[keyof typeof ZOD_TYPE_CONFIGS],\n defaultValueFn: () => unknown\n) {\n return Annotation<any>({\n reducer: config.reducer,\n default: defaultValueFn,\n });\n}\n\n/**\n * Creates an appropriate annotation for a given Zod type.\n */\nfunction createAnnotationForZodType(zodType: any): any {\n const typeName = zodType._def?.typeName;\n const defaultGetter = getInteropZodDefaultGetter(zodType);\n const isOptional = typeName === \"ZodOptional\";\n\n /**\n * Handle Zod wrapper first\n */\n if (\n typeName === \"ZodDefault\" ||\n typeName === \"ZodOptional\" ||\n typeName === \"ZodNullable\"\n ) {\n const innerTypeName = zodType._def.innerType._def?.typeName;\n const config =\n ZOD_TYPE_CONFIGS[innerTypeName as keyof typeof ZOD_TYPE_CONFIGS];\n return config\n ? createAnnotationFromConfig(\n config,\n () =>\n defaultGetter?.() ||\n (isOptional ? undefined : config?.fallbackDefault)\n )\n : Annotation<unknown>({\n reducer: (_: unknown, update: unknown) => update,\n default: () => defaultGetter?.(),\n });\n }\n\n /**\n * Handle regular types\n */\n const config = ZOD_TYPE_CONFIGS[typeName as keyof typeof ZOD_TYPE_CONFIGS];\n if (config) {\n return createAnnotationFromConfig(\n config,\n () => defaultGetter?.() || config?.fallbackDefault\n );\n }\n\n /**\n * Fallback for unknown types\n */\n return Annotation<unknown>({\n reducer: (_: unknown, update: unknown) => update,\n default: () => defaultGetter?.(),\n });\n}\n"],"mappings":";;;;;AA0BA,MAAaA,oBAGRC,iCAAW,KAAK;CACnB,wDAAsD;EACpD,SAAS,CAAC,GAAG,2DAAgC,CAAE,GAAE,OAAO;EACxD,SAAS,MAAM,CAAE;CAClB,EAAC;CACF,gDAA8C;EAC5C,SAASC;EACT,SAAS,MAAM,CAAE;CAClB,EAAC;AACH,EAAC;AA4BF,SAAgB,iCAGd,wBAAwB,MAIvB;CACD,MAAM,iBAAiB,EACrB,gDAA8C;EAC5C,SAASA;EACT,SAAS,MAAM,CAAE;CAClB,EAAC,CACH;AAED,KAAI,CAAC,sBACH,QAAOD,iCAAW,KAAK,eAAe;AAQxC,QAAOA,iCAAW,KAAK;EACrB,GAAG;EACH,2DAC6D;CAC9D,EAAC;AACH;;;;;;;;;AA4BD,SAAgB,qCACdE,aACA;;;;AAIA,KAAI,OAAO,gBAAgB,YAAY,WAAW,YAChD,QAAO;;;;AAMT,0DAAuB,YAAY,EAAE;EACnC,MAAM,mEAAiC,YAAY;EACnD,MAAMC,mBAAwC,CAAE;;;;AAKhD,OAAK,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,MAAM,EAChD,iBAAiB,OACf,QAAQ,mDAIsB;GACxB,SAASF;GACT,SAAS,MAAM,CAAE;EAClB,EAAC,GAIF,2BAA2B,QAAQ;;;;AAM3C,MAAI,CAAC,iBAAiB,UACpB,iBAAiB,iDAAqC;GACpD,SAASA;GACT,SAAS,MAAM,CAAE;EAClB,EAAC;AAGJ,SAAOD,iCAAW,KAAK,iBAAiB;CACzC;;;;AAKD,QAAOA,iCAAW,KAAK,EACrB,gDAAoC;EAClC,SAASC;EACT,SAAS,MAAM,CAAE;CAClB,EAAC,CACH,EAAC;AACH;;;;AAKD,MAAM,mBAAmB;CACvB,WAAW;EACT,SAAS,CAACG,GAAYC,WAAoB;EAC1C,iBAAiB;CAClB;CACD,WAAW;EACT,SAAS,CAACD,GAAYC,WAAoB;EAC1C,iBAAiB;CAClB;CACD,YAAY;EACV,SAAS,CAACD,GAAYC,WAAoB;EAC1C,iBAAiB;CAClB;CACD,UAAU;EACR,SAAS,CAACD,GAAYC,WAAoB;EAC1C,iBAAiB,CAAE;CACpB;CACD,WAAW;EACT,SAAS,CAACC,SAAoBC,YAAuB;GACnD,GAAG;GACH,GAAG;EACJ;EACD,iBAAiB,CAAE;CACpB;CACD,WAAW;EACT,SAAS,CAACD,SAAoBC,YAAuB;GACnD,GAAG;GACH,GAAG;EACJ;EACD,iBAAiB,CAAE;CACpB;AACF;;;;AAKD,SAAS,2BACPC,QACAC,gBACA;AACA,8CAAuB;EACrB,SAAS,OAAO;EAChB,SAAS;CACV,EAAC;AACH;;;;AAKD,SAAS,2BAA2BC,SAAmB;CACrD,MAAM,WAAW,QAAQ,MAAM;CAC/B,MAAM,6EAA2C,QAAQ;CACzD,MAAM,aAAa,aAAa;;;;AAKhC,KACE,aAAa,gBACb,aAAa,iBACb,aAAa,eACb;EACA,MAAM,gBAAgB,QAAQ,KAAK,UAAU,MAAM;EACnD,MAAMC,WACJ,iBAAiB;AACnB,SAAOA,WACH,2BACEA,UACA,MACE,iBAAiB,KAChB,aAAa,SAAYA,UAAQ,iBACrC,yCACmB;GAClB,SAAS,CAACP,GAAYC,WAAoB;GAC1C,SAAS,MAAM,iBAAiB;EACjC,EAAC;CACP;;;;CAKD,MAAM,SAAS,iBAAiB;AAChC,KAAI,OACF,QAAO,2BACL,QACA,MAAM,iBAAiB,IAAI,QAAQ,gBACpC;;;;AAMH,8CAA2B;EACzB,SAAS,CAACD,GAAYC,WAAoB;EAC1C,SAAS,MAAM,iBAAiB;CACjC,EAAC;AACH"}
@@ -1,10 +1,18 @@
1
- import { ResponseFormatUndefined } from "./responses.cjs";
2
1
  import { InteropZodObject } from "@langchain/core/utils/types";
3
2
  import { AnnotationRoot, BinaryOperatorAggregate, LastValue, Messages } from "@langchain/langgraph";
3
+ import * as _langchain_core_messages23 from "@langchain/core/messages";
4
4
  import { BaseMessage } from "@langchain/core/messages";
5
5
  import { InteropZodToStateDefinition } from "@langchain/langgraph/zod";
6
6
 
7
7
  //#region src/agents/annotation.d.ts
8
+
9
+ /**
10
+ * Special type to indicate that no response format is provided.
11
+ * When this type is used, the structuredResponse property should not be present in the result.
12
+ */
13
+ type ResponseFormatUndefined = {
14
+ __responseFormatUndefined: true;
15
+ };
8
16
  declare const PreHookAnnotation: AnnotationRoot<{
9
17
  llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;
10
18
  messages: BinaryOperatorAggregate<BaseMessage[], Messages>;
@@ -12,21 +20,18 @@ declare const PreHookAnnotation: AnnotationRoot<{
12
20
  type PreHookAnnotation = typeof PreHookAnnotation;
13
21
  // Base annotation without structuredResponse (for ResponseFormatUndefined)
14
22
  declare const createAgentBaseAnnotation: () => AnnotationRoot<{
15
- messages: BinaryOperatorAggregate<BaseMessage[], Messages>;
23
+ messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages23.MessageStructure, _langchain_core_messages23.MessageType>[], Messages>;
16
24
  }>;
17
25
  // Full annotation with structuredResponse (for regular cases)
18
- declare const createAgentAnnotation: <
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
26
+ declare const createAgentAnnotation: <T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
21
27
  structuredResponse: LastValue<T>;
22
- messages: BinaryOperatorAggregate<BaseMessage[], Messages>;
28
+ messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages23.MessageStructure, _langchain_core_messages23.MessageType>[], Messages>;
23
29
  }>;
24
30
  // Create annotation conditionally - for ResponseFormatUndefined, don't include structuredResponse
25
31
 
26
32
  // Helper type to select the right annotation based on the response format type
27
33
  type ReactAgentAnnotation<T extends Record<string, any> | ResponseFormatUndefined> = T extends ResponseFormatUndefined ? ReturnType<typeof createAgentBaseAnnotation> : T extends Record<string, any> ? ReturnType<typeof createAgentAnnotation<T>> : never;
28
34
  type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;
29
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
35
  type AnyAnnotationRoot = AnnotationRoot<any>;
31
36
  /**
32
37
  * Enhances a state schema to ensure proper message handling.
@@ -38,5 +43,5 @@ type AnyAnnotationRoot = AnnotationRoot<any>;
38
43
  */
39
44
 
40
45
  //#endregion
41
- export { AnyAnnotationRoot, PreHookAnnotation, ReactAgentAnnotation, ToAnnotationRoot };
46
+ export { AnyAnnotationRoot, PreHookAnnotation, ReactAgentAnnotation, ResponseFormatUndefined, ToAnnotationRoot };
42
47
  //# sourceMappingURL=annotation.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"annotation.d.cts","names":["BaseMessage","Messages","AnnotationRoot","BinaryOperatorAggregate","LastValue","InteropZodToStateDefinition","InteropZodObject","ResponseFormatUndefined","PreHookAnnotation","createAgentBaseAnnotation","createAgentAnnotation","Record","T","createAgentAnnotationConditional","ReactAgentAnnotation","ReturnType","ToAnnotationRoot","AnyAnnotationRoot","A","enhanceStateSchemaWithMessageReducer"],"sources":["../../src/agents/annotation.d.ts"],"sourcesContent":["import { BaseMessage } from \"@langchain/core/messages\";\nimport { Messages, AnnotationRoot, type BinaryOperatorAggregate, type LastValue } from \"@langchain/langgraph\";\nimport type { InteropZodToStateDefinition } from \"@langchain/langgraph/zod\";\nimport { type InteropZodObject } from \"@langchain/core/utils/types\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\nexport declare const PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>;\nexport type PreHookAnnotation = typeof PreHookAnnotation;\n// Base annotation without structuredResponse (for ResponseFormatUndefined)\nexport declare const createAgentBaseAnnotation: () => AnnotationRoot<{\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>;\n// Full annotation with structuredResponse (for regular cases)\ndeclare const createAgentAnnotation: <\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nT extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{\n structuredResponse: LastValue<T>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>;\n// Create annotation conditionally - for ResponseFormatUndefined, don't include structuredResponse\nexport declare function createAgentAnnotationConditional<T extends Record<string, any> | ResponseFormatUndefined>(hasStructuredResponse?: boolean): AnnotationRoot<{\n structuredResponse: LastValue<T extends ResponseFormatUndefined ? never : T>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>;\n// Helper type to select the right annotation based on the response format type\nexport type ReactAgentAnnotation<T extends Record<string, any> | ResponseFormatUndefined> = T extends ResponseFormatUndefined ? ReturnType<typeof createAgentBaseAnnotation> : T extends Record<string, any> ? ReturnType<typeof createAgentAnnotation<T>> : never;\nexport type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyAnnotationRoot = AnnotationRoot<any>;\n/**\n * Enhances a state schema to ensure proper message handling.\n * If a Zod schema is provided, it creates an annotation that includes the messagesStateReducer\n * and infers appropriate reducers for all other fields.\n *\n * @param stateSchema - The state schema to enhance.\n * @returns The enhanced state schema.\n */\nexport declare function enhanceStateSchemaWithMessageReducer(stateSchema: AnyAnnotationRoot | InteropZodObject): AnnotationRoot<{\n messages: BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;\n}> | AnyAnnotationRoot;\nexport {};\n"],"mappings":";;;;;;;cAKqBQ,mBAAmBN;oBAClBC,wBAAwBH,eAAeC;EADxCO,QAAAA,EAEPL,u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
+ {"version":3,"file":"annotation.d.cts","names":["BaseMessage","Messages","AnnotationRoot","BinaryOperatorAggregate","LastValue","InteropZodToStateDefinition","InteropZodObject","ResponseFormatUndefined","PreHookAnnotation","createAgentBaseAnnotation","_langchain_core_messages23","MessageStructure","MessageType","createAgentAnnotation","Record","T","createAgentAnnotationConditional","ReactAgentAnnotation","ReturnType","ToAnnotationRoot","AnyAnnotationRoot","A","enhanceStateSchemaWithMessageReducer"],"sources":["../../src/agents/annotation.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { Messages, AnnotationRoot, type BinaryOperatorAggregate, type LastValue } from \"@langchain/langgraph\";\nimport type { InteropZodToStateDefinition } from \"@langchain/langgraph/zod\";\nimport { type InteropZodObject } from \"@langchain/core/utils/types\";\n/**\n * Special type to indicate that no response format is provided.\n * When this type is used, the structuredResponse property should not be present in the result.\n */\nexport type ResponseFormatUndefined = {\n __responseFormatUndefined: true;\n};\nexport declare const PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>;\nexport type PreHookAnnotation = typeof PreHookAnnotation;\n// Base annotation without structuredResponse (for ResponseFormatUndefined)\nexport declare const createAgentBaseAnnotation: () => AnnotationRoot<{\n messages: BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n}>;\n// Full annotation with structuredResponse (for regular cases)\nexport declare const createAgentAnnotation: <T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{\n structuredResponse: LastValue<T>;\n messages: BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n}>;\n// Create annotation conditionally - for ResponseFormatUndefined, don't include structuredResponse\nexport declare function createAgentAnnotationConditional<T extends Record<string, any> | ResponseFormatUndefined>(hasStructuredResponse?: boolean): AnnotationRoot<{\n structuredResponse: LastValue<T extends ResponseFormatUndefined ? never : T>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>;\n// Helper type to select the right annotation based on the response format type\nexport type ReactAgentAnnotation<T extends Record<string, any> | ResponseFormatUndefined> = T extends ResponseFormatUndefined ? ReturnType<typeof createAgentBaseAnnotation> : T extends Record<string, any> ? ReturnType<typeof createAgentAnnotation<T>> : never;\nexport type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;\nexport type AnyAnnotationRoot = AnnotationRoot<any>;\n/**\n * Enhances a state schema to ensure proper message handling.\n * If a Zod schema is provided, it creates an annotation that includes the messagesStateReducer\n * and infers appropriate reducers for all other fields.\n *\n * @param stateSchema - The state schema to enhance.\n * @returns The enhanced state schema.\n */\nexport declare function enhanceStateSchemaWithMessageReducer(stateSchema: AnyAnnotationRoot | InteropZodObject): AnnotationRoot<{\n messages: BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[]>;\n}> | AnyAnnotationRoot;\n"],"mappings":";;;;;;;;;;AASA;AAGA;AAGE,KANUO,uBAAAA,GAMV;EAAA,yBAF4CP,EAAAA,IAAAA;CAAW;AAAnCG,cADDK,iBACCL,EADkBD,cAClBC,CAAAA;EAAuB,gBACPH,EADhBG,uBACgBH,CADQA,WACRA,EAAAA,EADuBC,QACvBD,CAAAA;EAAW,QAAIC,EAAvCE,uBAAuCF,CAAfD,WAAeC,EAAAA,EAAAA,QAAAA,CAAAA;CAAQ,CAAA;AAFrBC,KAI5BM,iBAAAA,GAJ4BN,OAIDM,iBAJCN;AAAc;AAI1CM,cAESC,yBAFkBD,EAAAA,GAAAA,GAEeN,cAFE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"}
@@ -1,10 +1,18 @@
1
- import { ResponseFormatUndefined } from "./responses.js";
1
+ import * as _langchain_core_messages23 from "@langchain/core/messages";
2
2
  import { BaseMessage } from "@langchain/core/messages";
3
3
  import { AnnotationRoot, BinaryOperatorAggregate, LastValue, Messages } from "@langchain/langgraph";
4
4
  import { InteropZodObject } from "@langchain/core/utils/types";
5
5
  import { InteropZodToStateDefinition } from "@langchain/langgraph/zod";
6
6
 
7
7
  //#region src/agents/annotation.d.ts
8
+
9
+ /**
10
+ * Special type to indicate that no response format is provided.
11
+ * When this type is used, the structuredResponse property should not be present in the result.
12
+ */
13
+ type ResponseFormatUndefined = {
14
+ __responseFormatUndefined: true;
15
+ };
8
16
  declare const PreHookAnnotation: AnnotationRoot<{
9
17
  llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;
10
18
  messages: BinaryOperatorAggregate<BaseMessage[], Messages>;
@@ -12,21 +20,18 @@ declare const PreHookAnnotation: AnnotationRoot<{
12
20
  type PreHookAnnotation = typeof PreHookAnnotation;
13
21
  // Base annotation without structuredResponse (for ResponseFormatUndefined)
14
22
  declare const createAgentBaseAnnotation: () => AnnotationRoot<{
15
- messages: BinaryOperatorAggregate<BaseMessage[], Messages>;
23
+ messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages23.MessageStructure, _langchain_core_messages23.MessageType>[], Messages>;
16
24
  }>;
17
25
  // Full annotation with structuredResponse (for regular cases)
18
- declare const createAgentAnnotation: <
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
26
+ declare const createAgentAnnotation: <T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
21
27
  structuredResponse: LastValue<T>;
22
- messages: BinaryOperatorAggregate<BaseMessage[], Messages>;
28
+ messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages23.MessageStructure, _langchain_core_messages23.MessageType>[], Messages>;
23
29
  }>;
24
30
  // Create annotation conditionally - for ResponseFormatUndefined, don't include structuredResponse
25
31
 
26
32
  // Helper type to select the right annotation based on the response format type
27
33
  type ReactAgentAnnotation<T extends Record<string, any> | ResponseFormatUndefined> = T extends ResponseFormatUndefined ? ReturnType<typeof createAgentBaseAnnotation> : T extends Record<string, any> ? ReturnType<typeof createAgentAnnotation<T>> : never;
28
34
  type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;
29
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
35
  type AnyAnnotationRoot = AnnotationRoot<any>;
31
36
  /**
32
37
  * Enhances a state schema to ensure proper message handling.
@@ -38,5 +43,5 @@ type AnyAnnotationRoot = AnnotationRoot<any>;
38
43
  */
39
44
 
40
45
  //#endregion
41
- export { AnyAnnotationRoot, PreHookAnnotation, ReactAgentAnnotation, ToAnnotationRoot };
46
+ export { AnyAnnotationRoot, PreHookAnnotation, ReactAgentAnnotation, ResponseFormatUndefined, ToAnnotationRoot };
42
47
  //# sourceMappingURL=annotation.d.ts.map