@langchain/langgraph 0.4.9 → 1.0.0-alpha.1

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 (505) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +1 -2
  3. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  4. package/dist/channels/any_value.cjs +44 -63
  5. package/dist/channels/any_value.cjs.map +1 -0
  6. package/dist/channels/any_value.d.cts +24 -0
  7. package/dist/channels/any_value.d.cts.map +1 -0
  8. package/dist/channels/any_value.d.ts +16 -11
  9. package/dist/channels/any_value.d.ts.map +1 -0
  10. package/dist/channels/any_value.js +42 -57
  11. package/dist/channels/any_value.js.map +1 -1
  12. package/dist/channels/base.cjs +93 -133
  13. package/dist/channels/base.cjs.map +1 -0
  14. package/dist/channels/base.d.cts +79 -0
  15. package/dist/channels/base.d.cts.map +1 -0
  16. package/dist/channels/base.d.ts +77 -73
  17. package/dist/channels/base.d.ts.map +1 -0
  18. package/dist/channels/base.js +90 -127
  19. package/dist/channels/base.js.map +1 -1
  20. package/dist/channels/binop.cjs +47 -77
  21. package/dist/channels/binop.cjs.map +1 -0
  22. package/dist/channels/binop.d.cts +22 -0
  23. package/dist/channels/binop.d.cts.map +1 -0
  24. package/dist/channels/binop.d.ts +17 -12
  25. package/dist/channels/binop.d.ts.map +1 -0
  26. package/dist/channels/binop.js +45 -71
  27. package/dist/channels/binop.js.map +1 -1
  28. package/dist/channels/dynamic_barrier_value.cjs +72 -208
  29. package/dist/channels/dynamic_barrier_value.cjs.map +1 -0
  30. package/dist/channels/dynamic_barrier_value.d.cts +42 -0
  31. package/dist/channels/dynamic_barrier_value.d.cts.map +1 -0
  32. package/dist/channels/dynamic_barrier_value.d.ts +20 -35
  33. package/dist/channels/dynamic_barrier_value.d.ts.map +1 -0
  34. package/dist/channels/dynamic_barrier_value.js +69 -200
  35. package/dist/channels/dynamic_barrier_value.js.map +1 -1
  36. package/dist/channels/ephemeral_value.cjs +44 -70
  37. package/dist/channels/ephemeral_value.cjs.map +1 -0
  38. package/dist/channels/ephemeral_value.d.cts +22 -0
  39. package/dist/channels/ephemeral_value.d.cts.map +1 -0
  40. package/dist/channels/ephemeral_value.d.ts +18 -12
  41. package/dist/channels/ephemeral_value.d.ts.map +1 -0
  42. package/dist/channels/ephemeral_value.js +43 -65
  43. package/dist/channels/ephemeral_value.js.map +1 -1
  44. package/dist/channels/index.cjs +21 -10
  45. package/dist/channels/index.d.cts +9 -0
  46. package/dist/channels/index.d.ts +9 -7
  47. package/dist/channels/index.js +10 -3
  48. package/dist/channels/last_value.cjs +90 -140
  49. package/dist/channels/last_value.cjs.map +1 -0
  50. package/dist/channels/last_value.d.cts +42 -0
  51. package/dist/channels/last_value.d.cts.map +1 -0
  52. package/dist/channels/last_value.d.ts +27 -23
  53. package/dist/channels/last_value.d.ts.map +1 -0
  54. package/dist/channels/last_value.js +87 -133
  55. package/dist/channels/last_value.js.map +1 -1
  56. package/dist/channels/named_barrier_value.cjs +114 -170
  57. package/dist/channels/named_barrier_value.cjs.map +1 -0
  58. package/dist/channels/named_barrier_value.d.cts +46 -0
  59. package/dist/channels/named_barrier_value.d.cts.map +1 -0
  60. package/dist/channels/named_barrier_value.d.ts +32 -29
  61. package/dist/channels/named_barrier_value.d.ts.map +1 -0
  62. package/dist/channels/named_barrier_value.js +111 -163
  63. package/dist/channels/named_barrier_value.js.map +1 -1
  64. package/dist/channels/topic.cjs +63 -96
  65. package/dist/channels/topic.cjs.map +1 -0
  66. package/dist/channels/topic.d.cts +32 -0
  67. package/dist/channels/topic.d.cts.map +1 -0
  68. package/dist/channels/topic.d.ts +28 -19
  69. package/dist/channels/topic.d.ts.map +1 -0
  70. package/dist/channels/topic.js +61 -90
  71. package/dist/channels/topic.js.map +1 -1
  72. package/dist/constants.cjs +376 -452
  73. package/dist/constants.cjs.map +1 -0
  74. package/dist/constants.d.cts +285 -0
  75. package/dist/constants.d.cts.map +1 -0
  76. package/dist/constants.d.ts +113 -148
  77. package/dist/constants.d.ts.map +1 -0
  78. package/dist/constants.js +336 -444
  79. package/dist/constants.js.map +1 -1
  80. package/dist/errors.cjs +151 -179
  81. package/dist/errors.cjs.map +1 -0
  82. package/dist/errors.d.cts +81 -0
  83. package/dist/errors.d.cts.map +1 -0
  84. package/dist/errors.d.ts +56 -46
  85. package/dist/errors.d.ts.map +1 -0
  86. package/dist/errors.js +140 -165
  87. package/dist/errors.js.map +1 -1
  88. package/dist/func/index.cjs +292 -290
  89. package/dist/func/index.cjs.map +1 -0
  90. package/dist/func/index.d.cts +293 -0
  91. package/dist/func/index.d.cts.map +1 -0
  92. package/dist/func/index.d.ts +86 -72
  93. package/dist/func/index.d.ts.map +1 -0
  94. package/dist/func/index.js +288 -284
  95. package/dist/func/index.js.map +1 -1
  96. package/dist/func/types.d.cts +64 -0
  97. package/dist/func/types.d.cts.map +1 -0
  98. package/dist/func/types.d.ts +24 -19
  99. package/dist/func/types.d.ts.map +1 -0
  100. package/dist/graph/annotation.cjs +96 -120
  101. package/dist/graph/annotation.cjs.map +1 -0
  102. package/dist/graph/annotation.d.cts +116 -0
  103. package/dist/graph/annotation.d.cts.map +1 -0
  104. package/dist/graph/annotation.d.ts +33 -34
  105. package/dist/graph/annotation.d.ts.map +1 -0
  106. package/dist/graph/annotation.js +91 -112
  107. package/dist/graph/annotation.js.map +1 -1
  108. package/dist/graph/graph.cjs +419 -723
  109. package/dist/graph/graph.cjs.map +1 -0
  110. package/dist/graph/graph.d.cts +133 -0
  111. package/dist/graph/graph.d.cts.map +1 -0
  112. package/dist/graph/graph.d.ts +124 -91
  113. package/dist/graph/graph.d.ts.map +1 -0
  114. package/dist/graph/graph.js +412 -713
  115. package/dist/graph/graph.js.map +1 -1
  116. package/dist/graph/index.cjs +4 -17
  117. package/dist/graph/index.js +6 -5
  118. package/dist/graph/message.cjs +59 -104
  119. package/dist/graph/message.cjs.map +1 -0
  120. package/dist/graph/message.d.cts +19 -0
  121. package/dist/graph/message.d.cts.map +1 -0
  122. package/dist/graph/message.d.ts +11 -10
  123. package/dist/graph/message.d.ts.map +1 -0
  124. package/dist/graph/message.js +56 -98
  125. package/dist/graph/message.js.map +1 -1
  126. package/dist/graph/messages_annotation.cjs +106 -106
  127. package/dist/graph/messages_annotation.cjs.map +1 -0
  128. package/dist/graph/messages_annotation.d.cts +111 -0
  129. package/dist/graph/messages_annotation.d.cts.map +1 -0
  130. package/dist/graph/messages_annotation.d.ts +18 -9
  131. package/dist/graph/messages_annotation.d.ts.map +1 -0
  132. package/dist/graph/messages_annotation.js +100 -100
  133. package/dist/graph/messages_annotation.js.map +1 -1
  134. package/dist/graph/state.cjs +475 -779
  135. package/dist/graph/state.cjs.map +1 -0
  136. package/dist/graph/state.d.cts +231 -0
  137. package/dist/graph/state.d.cts.map +1 -0
  138. package/dist/graph/state.d.ts +148 -138
  139. package/dist/graph/state.d.ts.map +1 -0
  140. package/dist/graph/state.js +469 -769
  141. package/dist/graph/state.js.map +1 -1
  142. package/dist/graph/zod/index.cjs +10 -21
  143. package/dist/graph/zod/index.d.cts +3 -0
  144. package/dist/graph/zod/index.d.ts +3 -3
  145. package/dist/graph/zod/index.js +4 -4
  146. package/dist/graph/zod/meta.cjs +142 -177
  147. package/dist/graph/zod/meta.cjs.map +1 -0
  148. package/dist/graph/zod/meta.d.cts +116 -0
  149. package/dist/graph/zod/meta.d.cts.map +1 -0
  150. package/dist/graph/zod/meta.d.ts +99 -97
  151. package/dist/graph/zod/meta.d.ts.map +1 -0
  152. package/dist/graph/zod/meta.js +136 -170
  153. package/dist/graph/zod/meta.js.map +1 -1
  154. package/dist/graph/zod/plugin.cjs +36 -39
  155. package/dist/graph/zod/plugin.cjs.map +1 -0
  156. package/dist/graph/zod/plugin.js +34 -35
  157. package/dist/graph/zod/plugin.js.map +1 -1
  158. package/dist/graph/zod/schema.cjs +82 -110
  159. package/dist/graph/zod/schema.cjs.map +1 -0
  160. package/dist/graph/zod/schema.d.cts +38 -0
  161. package/dist/graph/zod/schema.d.cts.map +1 -0
  162. package/dist/graph/zod/schema.d.ts +12 -6
  163. package/dist/graph/zod/schema.d.ts.map +1 -0
  164. package/dist/graph/zod/schema.js +77 -103
  165. package/dist/graph/zod/schema.js.map +1 -1
  166. package/dist/graph/zod/zod-registry.cjs +41 -47
  167. package/dist/graph/zod/zod-registry.cjs.map +1 -0
  168. package/dist/graph/zod/zod-registry.d.cts +51 -0
  169. package/dist/graph/zod/zod-registry.d.cts.map +1 -0
  170. package/dist/graph/zod/zod-registry.d.ts +34 -26
  171. package/dist/graph/zod/zod-registry.d.ts.map +1 -0
  172. package/dist/graph/zod/zod-registry.js +37 -41
  173. package/dist/graph/zod/zod-registry.js.map +1 -1
  174. package/dist/hash.cjs +205 -267
  175. package/dist/hash.cjs.map +1 -0
  176. package/dist/hash.js +205 -265
  177. package/dist/hash.js.map +1 -1
  178. package/dist/index.cjs +111 -33
  179. package/dist/index.cjs.map +1 -0
  180. package/dist/index.d.cts +26 -0
  181. package/dist/index.d.ts +26 -5
  182. package/dist/index.js +19 -7
  183. package/dist/index.js.map +1 -1
  184. package/dist/interrupt.cjs +79 -85
  185. package/dist/interrupt.cjs.map +1 -0
  186. package/dist/interrupt.d.cts +49 -0
  187. package/dist/interrupt.d.cts.map +1 -0
  188. package/dist/interrupt.d.ts +6 -1
  189. package/dist/interrupt.d.ts.map +1 -0
  190. package/dist/interrupt.js +76 -80
  191. package/dist/interrupt.js.map +1 -1
  192. package/dist/prebuilt/agentName.cjs +139 -172
  193. package/dist/prebuilt/agentName.cjs.map +1 -0
  194. package/dist/prebuilt/agentName.d.cts +42 -0
  195. package/dist/prebuilt/agentName.d.cts.map +1 -0
  196. package/dist/prebuilt/agentName.d.ts +13 -21
  197. package/dist/prebuilt/agentName.d.ts.map +1 -0
  198. package/dist/prebuilt/agentName.js +139 -168
  199. package/dist/prebuilt/agentName.js.map +1 -1
  200. package/dist/prebuilt/agent_executor.cjs +42 -80
  201. package/dist/prebuilt/agent_executor.cjs.map +1 -0
  202. package/dist/prebuilt/agent_executor.d.cts +57 -0
  203. package/dist/prebuilt/agent_executor.d.cts.map +1 -0
  204. package/dist/prebuilt/agent_executor.d.ts +47 -38
  205. package/dist/prebuilt/agent_executor.d.ts.map +1 -0
  206. package/dist/prebuilt/agent_executor.js +40 -75
  207. package/dist/prebuilt/agent_executor.js.map +1 -1
  208. package/dist/prebuilt/chat_agent_executor.cjs +66 -128
  209. package/dist/prebuilt/chat_agent_executor.cjs.map +1 -0
  210. package/dist/prebuilt/chat_agent_executor.d.cts +23 -0
  211. package/dist/prebuilt/chat_agent_executor.d.cts.map +1 -0
  212. package/dist/prebuilt/chat_agent_executor.d.ts +18 -10
  213. package/dist/prebuilt/chat_agent_executor.d.ts.map +1 -0
  214. package/dist/prebuilt/chat_agent_executor.js +63 -123
  215. package/dist/prebuilt/chat_agent_executor.js.map +1 -1
  216. package/dist/prebuilt/index.cjs +15 -18
  217. package/dist/prebuilt/index.d.cts +8 -0
  218. package/dist/prebuilt/index.d.ts +8 -8
  219. package/dist/prebuilt/index.js +8 -7
  220. package/dist/prebuilt/interrupt.d.cts +73 -0
  221. package/dist/prebuilt/interrupt.d.cts.map +1 -0
  222. package/dist/prebuilt/interrupt.d.ts +32 -15
  223. package/dist/prebuilt/interrupt.d.ts.map +1 -0
  224. package/dist/prebuilt/react_agent_executor.cjs +317 -473
  225. package/dist/prebuilt/react_agent_executor.cjs.map +1 -0
  226. package/dist/prebuilt/react_agent_executor.d.cts +229 -0
  227. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -0
  228. package/dist/prebuilt/react_agent_executor.d.ts +171 -143
  229. package/dist/prebuilt/react_agent_executor.d.ts.map +1 -0
  230. package/dist/prebuilt/react_agent_executor.js +315 -465
  231. package/dist/prebuilt/react_agent_executor.js.map +1 -1
  232. package/dist/prebuilt/tool_executor.cjs +45 -67
  233. package/dist/prebuilt/tool_executor.cjs.map +1 -0
  234. package/dist/prebuilt/tool_executor.d.cts +42 -0
  235. package/dist/prebuilt/tool_executor.d.cts.map +1 -0
  236. package/dist/prebuilt/tool_executor.d.ts +30 -24
  237. package/dist/prebuilt/tool_executor.d.ts.map +1 -0
  238. package/dist/prebuilt/tool_executor.js +44 -63
  239. package/dist/prebuilt/tool_executor.js.map +1 -1
  240. package/dist/prebuilt/tool_node.cjs +213 -275
  241. package/dist/prebuilt/tool_node.cjs.map +1 -0
  242. package/dist/prebuilt/tool_node.d.cts +151 -0
  243. package/dist/prebuilt/tool_node.d.cts.map +1 -0
  244. package/dist/prebuilt/tool_node.d.ts +30 -17
  245. package/dist/prebuilt/tool_node.d.ts.map +1 -0
  246. package/dist/prebuilt/tool_node.js +209 -268
  247. package/dist/prebuilt/tool_node.js.map +1 -1
  248. package/dist/pregel/algo.cjs +551 -692
  249. package/dist/pregel/algo.cjs.map +1 -0
  250. package/dist/pregel/algo.d.cts +13 -0
  251. package/dist/pregel/algo.d.cts.map +1 -0
  252. package/dist/pregel/algo.d.ts +8 -38
  253. package/dist/pregel/algo.d.ts.map +1 -0
  254. package/dist/pregel/algo.js +546 -683
  255. package/dist/pregel/algo.js.map +1 -1
  256. package/dist/pregel/call.cjs +46 -42
  257. package/dist/pregel/call.cjs.map +1 -0
  258. package/dist/pregel/call.js +43 -37
  259. package/dist/pregel/call.js.map +1 -1
  260. package/dist/pregel/debug.cjs +153 -223
  261. package/dist/pregel/debug.cjs.map +1 -0
  262. package/dist/pregel/debug.js +152 -215
  263. package/dist/pregel/debug.js.map +1 -1
  264. package/dist/pregel/index.cjs +1138 -1604
  265. package/dist/pregel/index.cjs.map +1 -0
  266. package/dist/pregel/index.d.cts +536 -0
  267. package/dist/pregel/index.d.cts.map +1 -0
  268. package/dist/pregel/index.d.ts +460 -422
  269. package/dist/pregel/index.d.ts.map +1 -0
  270. package/dist/pregel/index.js +1129 -1592
  271. package/dist/pregel/index.js.map +1 -1
  272. package/dist/pregel/io.cjs +127 -234
  273. package/dist/pregel/io.cjs.map +1 -0
  274. package/dist/pregel/io.js +122 -225
  275. package/dist/pregel/io.js.map +1 -1
  276. package/dist/pregel/loop.cjs +542 -954
  277. package/dist/pregel/loop.cjs.map +1 -0
  278. package/dist/pregel/loop.js +539 -948
  279. package/dist/pregel/loop.js.map +1 -1
  280. package/dist/pregel/messages.cjs +104 -196
  281. package/dist/pregel/messages.cjs.map +1 -0
  282. package/dist/pregel/messages.js +102 -191
  283. package/dist/pregel/messages.js.map +1 -1
  284. package/dist/pregel/read.cjs +150 -280
  285. package/dist/pregel/read.cjs.map +1 -0
  286. package/dist/pregel/read.d.cts +51 -0
  287. package/dist/pregel/read.d.cts.map +1 -0
  288. package/dist/pregel/read.d.ts +48 -46
  289. package/dist/pregel/read.d.ts.map +1 -0
  290. package/dist/pregel/read.js +147 -274
  291. package/dist/pregel/read.js.map +1 -1
  292. package/dist/pregel/remote.cjs +339 -458
  293. package/dist/pregel/remote.cjs.map +1 -0
  294. package/dist/pregel/remote.d.cts +121 -0
  295. package/dist/pregel/remote.d.cts.map +1 -0
  296. package/dist/pregel/remote.d.ts +79 -69
  297. package/dist/pregel/remote.d.ts.map +1 -0
  298. package/dist/pregel/remote.js +337 -453
  299. package/dist/pregel/remote.js.map +1 -1
  300. package/dist/pregel/retry.cjs +87 -138
  301. package/dist/pregel/retry.cjs.map +1 -0
  302. package/dist/pregel/retry.js +83 -130
  303. package/dist/pregel/retry.js.map +1 -1
  304. package/dist/pregel/runnable_types.d.cts +49 -0
  305. package/dist/pregel/runnable_types.d.cts.map +1 -0
  306. package/dist/pregel/runnable_types.d.ts +47 -17
  307. package/dist/pregel/runnable_types.d.ts.map +1 -0
  308. package/dist/pregel/runner.cjs +222 -315
  309. package/dist/pregel/runner.cjs.map +1 -0
  310. package/dist/pregel/runner.js +219 -308
  311. package/dist/pregel/runner.js.map +1 -1
  312. package/dist/pregel/stream.cjs +89 -130
  313. package/dist/pregel/stream.cjs.map +1 -0
  314. package/dist/pregel/stream.js +87 -125
  315. package/dist/pregel/stream.js.map +1 -1
  316. package/dist/pregel/types.cjs +25 -62
  317. package/dist/pregel/types.cjs.map +1 -0
  318. package/dist/pregel/types.d.cts +440 -0
  319. package/dist/pregel/types.d.cts.map +1 -0
  320. package/dist/pregel/types.d.ts +381 -432
  321. package/dist/pregel/types.d.ts.map +1 -0
  322. package/dist/pregel/types.js +23 -57
  323. package/dist/pregel/types.js.map +1 -1
  324. package/dist/pregel/utils/config.cjs +101 -147
  325. package/dist/pregel/utils/config.cjs.map +1 -0
  326. package/dist/pregel/utils/config.d.cts +36 -0
  327. package/dist/pregel/utils/config.d.cts.map +1 -0
  328. package/dist/pregel/utils/config.d.ts +12 -9
  329. package/dist/pregel/utils/config.d.ts.map +1 -0
  330. package/dist/pregel/utils/config.js +99 -143
  331. package/dist/pregel/utils/config.js.map +1 -1
  332. package/dist/pregel/utils/index.cjs +87 -125
  333. package/dist/pregel/utils/index.cjs.map +1 -0
  334. package/dist/pregel/utils/index.d.cts +51 -0
  335. package/dist/pregel/utils/index.d.cts.map +1 -0
  336. package/dist/pregel/utils/index.d.ts +45 -61
  337. package/dist/pregel/utils/index.d.ts.map +1 -0
  338. package/dist/pregel/utils/index.js +86 -120
  339. package/dist/pregel/utils/index.js.map +1 -1
  340. package/dist/pregel/utils/subgraph.cjs +15 -26
  341. package/dist/pregel/utils/subgraph.cjs.map +1 -0
  342. package/dist/pregel/utils/subgraph.js +12 -21
  343. package/dist/pregel/utils/subgraph.js.map +1 -1
  344. package/dist/pregel/validate.cjs +42 -92
  345. package/dist/pregel/validate.cjs.map +1 -0
  346. package/dist/pregel/validate.js +39 -84
  347. package/dist/pregel/validate.js.map +1 -1
  348. package/dist/pregel/write.cjs +87 -137
  349. package/dist/pregel/write.cjs.map +1 -0
  350. package/dist/pregel/write.d.cts +35 -0
  351. package/dist/pregel/write.d.cts.map +1 -0
  352. package/dist/pregel/write.d.ts +27 -23
  353. package/dist/pregel/write.d.ts.map +1 -0
  354. package/dist/pregel/write.js +83 -131
  355. package/dist/pregel/write.js.map +1 -1
  356. package/dist/remote.cjs +3 -6
  357. package/dist/remote.d.cts +2 -0
  358. package/dist/remote.d.ts +2 -1
  359. package/dist/remote.js +3 -2
  360. package/dist/setup/async_local_storage.cjs +10 -7
  361. package/dist/setup/async_local_storage.cjs.map +1 -0
  362. package/dist/setup/async_local_storage.js +7 -2
  363. package/dist/setup/async_local_storage.js.map +1 -1
  364. package/dist/ui/index.cjs +4 -0
  365. package/dist/ui/index.d.cts +5 -0
  366. package/dist/ui/index.d.ts +5 -0
  367. package/dist/ui/index.js +3 -0
  368. package/dist/ui/stream.cjs +145 -0
  369. package/dist/ui/stream.cjs.map +1 -0
  370. package/dist/ui/stream.d.cts +25 -0
  371. package/dist/ui/stream.d.cts.map +1 -0
  372. package/dist/ui/stream.d.ts +25 -0
  373. package/dist/ui/stream.d.ts.map +1 -0
  374. package/dist/ui/stream.js +143 -0
  375. package/dist/ui/stream.js.map +1 -0
  376. package/dist/ui/types.infer.d.cts +53 -0
  377. package/dist/ui/types.infer.d.cts.map +1 -0
  378. package/dist/ui/types.infer.d.ts +53 -0
  379. package/dist/ui/types.infer.d.ts.map +1 -0
  380. package/dist/ui/types.message.d.cts +95 -0
  381. package/dist/ui/types.message.d.cts.map +1 -0
  382. package/dist/ui/types.message.d.ts +95 -0
  383. package/dist/ui/types.message.d.ts.map +1 -0
  384. package/dist/ui/types.schema.d.cts +228 -0
  385. package/dist/ui/types.schema.d.cts.map +1 -0
  386. package/dist/ui/types.schema.d.ts +228 -0
  387. package/dist/ui/types.schema.d.ts.map +1 -0
  388. package/dist/utils.cjs +77 -147
  389. package/dist/utils.cjs.map +1 -0
  390. package/dist/utils.d.cts +32 -0
  391. package/dist/utils.d.cts.map +1 -0
  392. package/dist/utils.d.ts +29 -25
  393. package/dist/utils.d.ts.map +1 -0
  394. package/dist/utils.js +73 -140
  395. package/dist/utils.js.map +1 -1
  396. package/dist/web.cjs +96 -55
  397. package/dist/web.d.cts +23 -0
  398. package/dist/web.d.ts +23 -14
  399. package/dist/web.js +15 -8
  400. package/dist/writer.cjs +15 -0
  401. package/dist/writer.cjs.map +1 -0
  402. package/dist/writer.d.cts +5 -0
  403. package/dist/writer.d.cts.map +1 -0
  404. package/dist/writer.d.ts +5 -0
  405. package/dist/writer.d.ts.map +1 -0
  406. package/dist/writer.js +14 -0
  407. package/dist/writer.js.map +1 -0
  408. package/package.json +90 -83
  409. package/dist/channels/index.js.map +0 -1
  410. package/dist/func/types.cjs +0 -15
  411. package/dist/func/types.js +0 -12
  412. package/dist/func/types.js.map +0 -1
  413. package/dist/graph/index.d.ts +0 -4
  414. package/dist/graph/index.js.map +0 -1
  415. package/dist/graph/message.test.cjs +0 -196
  416. package/dist/graph/message.test.d.ts +0 -1
  417. package/dist/graph/message.test.js +0 -194
  418. package/dist/graph/message.test.js.map +0 -1
  419. package/dist/graph/zod/index.js.map +0 -1
  420. package/dist/graph/zod/plugin.d.ts +0 -28
  421. package/dist/hash.d.ts +0 -2
  422. package/dist/prebuilt/index.js.map +0 -1
  423. package/dist/prebuilt/interrupt.cjs +0 -3
  424. package/dist/prebuilt/interrupt.js +0 -2
  425. package/dist/prebuilt/interrupt.js.map +0 -1
  426. package/dist/pregel/call.d.ts +0 -16
  427. package/dist/pregel/debug.d.ts +0 -41
  428. package/dist/pregel/debug.test.cjs +0 -258
  429. package/dist/pregel/debug.test.d.ts +0 -1
  430. package/dist/pregel/debug.test.js +0 -256
  431. package/dist/pregel/debug.test.js.map +0 -1
  432. package/dist/pregel/io.d.ts +0 -30
  433. package/dist/pregel/io.mapCommand.test.cjs +0 -150
  434. package/dist/pregel/io.mapCommand.test.d.ts +0 -1
  435. package/dist/pregel/io.mapCommand.test.js +0 -148
  436. package/dist/pregel/io.mapCommand.test.js.map +0 -1
  437. package/dist/pregel/loop.d.ts +0 -147
  438. package/dist/pregel/messages.d.ts +0 -30
  439. package/dist/pregel/messages.test.cjs +0 -369
  440. package/dist/pregel/messages.test.d.ts +0 -1
  441. package/dist/pregel/messages.test.js +0 -367
  442. package/dist/pregel/messages.test.js.map +0 -1
  443. package/dist/pregel/read.test.cjs +0 -194
  444. package/dist/pregel/read.test.d.ts +0 -1
  445. package/dist/pregel/read.test.js +0 -192
  446. package/dist/pregel/read.test.js.map +0 -1
  447. package/dist/pregel/retry.d.ts +0 -17
  448. package/dist/pregel/runnable_types.cjs +0 -3
  449. package/dist/pregel/runnable_types.js +0 -2
  450. package/dist/pregel/runnable_types.js.map +0 -1
  451. package/dist/pregel/runner.d.ts +0 -79
  452. package/dist/pregel/runner.test.cjs +0 -66
  453. package/dist/pregel/runner.test.d.ts +0 -1
  454. package/dist/pregel/runner.test.js +0 -64
  455. package/dist/pregel/runner.test.js.map +0 -1
  456. package/dist/pregel/stream.d.ts +0 -40
  457. package/dist/pregel/utils/config.test.cjs +0 -214
  458. package/dist/pregel/utils/config.test.d.ts +0 -1
  459. package/dist/pregel/utils/config.test.js +0 -212
  460. package/dist/pregel/utils/config.test.js.map +0 -1
  461. package/dist/pregel/utils/subgraph.d.ts +0 -4
  462. package/dist/pregel/utils/subgraph.test.cjs +0 -83
  463. package/dist/pregel/utils/subgraph.test.d.ts +0 -1
  464. package/dist/pregel/utils/subgraph.test.js +0 -81
  465. package/dist/pregel/utils/subgraph.test.js.map +0 -1
  466. package/dist/pregel/validate.d.ts +0 -16
  467. package/dist/pregel/validate.test.cjs +0 -220
  468. package/dist/pregel/validate.test.d.ts +0 -1
  469. package/dist/pregel/validate.test.js +0 -218
  470. package/dist/pregel/validate.test.js.map +0 -1
  471. package/dist/pregel/write.test.cjs +0 -181
  472. package/dist/pregel/write.test.d.ts +0 -1
  473. package/dist/pregel/write.test.js +0 -179
  474. package/dist/pregel/write.test.js.map +0 -1
  475. package/dist/remote.js.map +0 -1
  476. package/dist/setup/async_local_storage.d.ts +0 -1
  477. package/dist/web.js.map +0 -1
  478. package/index.cjs +0 -1
  479. package/index.d.cts +0 -1
  480. package/index.d.ts +0 -1
  481. package/index.js +0 -1
  482. package/prebuilt.cjs +0 -1
  483. package/prebuilt.d.cts +0 -1
  484. package/prebuilt.d.ts +0 -1
  485. package/prebuilt.js +0 -1
  486. package/pregel.cjs +0 -1
  487. package/pregel.d.cts +0 -1
  488. package/pregel.d.ts +0 -1
  489. package/pregel.js +0 -1
  490. package/remote.cjs +0 -1
  491. package/remote.d.cts +0 -1
  492. package/remote.d.ts +0 -1
  493. package/remote.js +0 -1
  494. package/web.cjs +0 -1
  495. package/web.d.cts +0 -1
  496. package/web.d.ts +0 -1
  497. package/web.js +0 -1
  498. package/zod/schema.cjs +0 -1
  499. package/zod/schema.d.cts +0 -1
  500. package/zod/schema.d.ts +0 -1
  501. package/zod/schema.js +0 -1
  502. package/zod.cjs +0 -1
  503. package/zod.d.cts +0 -1
  504. package/zod.d.ts +0 -1
  505. package/zod.js +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent_executor.d.cts","names":["AgentAction","AgentFinish","BaseMessage","Runnable","Tool","ToolExecutor","BaseChannel","Step","AgentExecutorState","Array","createAgentExecutor","agentRunnable","tools","___web_js0","StateDefinition","Partial","CompiledStateGraph"],"sources":["../../src/prebuilt/agent_executor.d.ts"],"sourcesContent":["import { AgentAction, AgentFinish } from \"@langchain/core/agents\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { Tool } from \"@langchain/core/tools\";\nimport { ToolExecutor } from \"./tool_executor.js\";\nimport type { BaseChannel } from \"../channels/base.js\";\ninterface Step {\n action: AgentAction | AgentFinish;\n observation: unknown;\n}\n/** @ignore */\nexport interface AgentExecutorState {\n agentOutcome?: AgentAction | AgentFinish;\n steps: Array<Step>;\n input: string;\n chatHistory?: BaseMessage[];\n}\n/** @ignore */\nexport declare function createAgentExecutor({ agentRunnable, tools }: {\n agentRunnable: Runnable;\n tools: Array<Tool> | ToolExecutor;\n}): import(\"../web.js\").CompiledStateGraph<{\n agentOutcome?: AgentAction | AgentFinish | undefined;\n steps: Step[];\n input: string;\n chatHistory?: BaseMessage[] | undefined;\n}, {\n agentOutcome?: AgentAction | AgentFinish | undefined;\n steps?: Step[] | undefined;\n input?: string | undefined;\n chatHistory?: BaseMessage[] | undefined;\n}, \"__start__\" | \"action\" | \"agent\", {\n agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;\n steps: BaseChannel<Step[], Step[], unknown>;\n input: BaseChannel<string, string, unknown>;\n chatHistory?: BaseChannel<BaseMessage[] | undefined, BaseMessage[] | undefined, unknown> | undefined;\n}, {\n agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;\n steps: BaseChannel<Step[], Step[], unknown>;\n input: BaseChannel<string, string, unknown>;\n chatHistory?: BaseChannel<BaseMessage[] | undefined, BaseMessage[] | undefined, unknown> | undefined;\n}, import(\"../web.js\").StateDefinition, {\n action: Partial<AgentExecutorState>;\n agent: {\n agentOutcome: any;\n };\n}, unknown, unknown>;\nexport {};\n"],"mappings":";;;;;;;;;;UAMUO,IAAAA;UACEP,cAAcC;;;AAF6B;AACzC,UAKGO,kBAAAA,CALH;cACFR,CAAAA,EAKOA,WALPA,GAKqBC,WALrBD;OAAcC,EAMfQ,KANeR,CAMTM,IANSN,CAAAA;;EAITO,WAAAA,CAAAA,EAICN,WAJiB,EAAA;;;AACFD,iBAMTS,mBAAAA,CANST;EAAAA,aAAAA;EAAAA;CAAAA,EAAAA;eAChBM,EAMEJ,QANFI;OAANE,EAOAA,KAPAA,CAOML,IAPNK,CAAAA,GAOcJ,YAPdI;sBAEOP,CAAAA;iBAOCF,cAAcC;EAJTS,KAAAA,EAKbH,IALaG,EAAAA;EAAmB,KAAA,EAAA,MAAA;aAAGC,CAAAA,EAO5BT,WAP4BS,EAAAA,GAAAA,SAAAA;;cAC3BR,CAAAA,EAQAH,WARAG,GAQcF,WARdE,GAAAA,SAAAA;OACFC,CAAAA,EAQLG,IARKH,EAAAA,GAAAA,SAAAA;OAANK,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;aAAcJ,CAAAA,EAUPH,WAVOG,EAAAA,GAAAA,SAAAA;cAENL,GAAAA,QAAAA,GAAAA,OAAAA,EAAAA;cAAcC,CAAAA,EAUdK,WAVcL,CAUFD,WAVEC,GAUYA,WAVZA,GAAAA,SAAAA,EAUqCD,WAVrCC,GAUmDA,WAVnDA,GAAAA,SAAAA,EAAAA,OAAAA,CAAAA,GAAAA,SAAAA;OACtBM,EAUAD,WAVAC,CAUYA,IAVZA,EAAAA,EAUoBA,IAVpBA,EAAAA,EAAAA,OAAAA,CAAAA;OAEOL,EASPI,WATOJ,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,OAAAA,CAAAA;aAECF,CAAAA,EAQDM,WARCN,CAQWE,WARXF,EAAAA,GAAAA,SAAAA,EAQsCE,WARtCF,EAAAA,GAAAA,SAAAA,EAAAA,OAAAA,CAAAA,GAAAA,SAAAA;;cACPO,CAAAA,EASOD,WATPC,CASmBP,WATnBO,GASiCN,WATjCM,GAAAA,SAAAA,EAS0DP,WAT1DO,GASwEN,WATxEM,GAAAA,SAAAA,EAAAA,OAAAA,CAAAA,GAAAA,SAAAA;OAEML,EAQPI,WAROJ,CAQKK,IARLL,EAAAA,EAQaK,IARbL,EAAAA,EAAAA,OAAAA,CAAAA;OAEaF,EAOpBM,WAPoBN,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,OAAAA,CAAAA;aAAcC,CAAAA,EAQ3BK,WAR2BL,CAQfC,WAReD,EAAAA,GAAAA,SAAAA,EAQYC,WARZD,EAAAA,GAAAA,SAAAA,EAAAA,OAAAA,CAAAA,GAAAA,SAAAA;oBAAyBD;QAAcC,EAUxEc,OAVwEd,CAUhEO,kBAVgEP,CAAAA;OAAjEK,EAAAA;IACIC,YAAAA,EAAAA,GAAAA;;UAAZD,EAAAA,OAAAA,CAAAA"}
@@ -1,48 +1,57 @@
1
- import { AgentAction, AgentFinish } from "@langchain/core/agents";
2
- import { BaseMessage } from "@langchain/core/messages";
1
+ import { BaseChannel } from "../channels/base.js";
2
+ import { StateDefinition } from "../graph/annotation.js";
3
+ import { CompiledStateGraph } from "../graph/state.js";
4
+ import { ToolExecutor } from "./tool_executor.js";
3
5
  import { Runnable } from "@langchain/core/runnables";
6
+ import { BaseMessage } from "@langchain/core/messages";
7
+ import { AgentAction, AgentFinish } from "@langchain/core/agents";
4
8
  import { Tool } from "@langchain/core/tools";
5
- import { ToolExecutor } from "./tool_executor.js";
6
- import type { BaseChannel } from "../channels/base.js";
9
+
10
+ //#region src/prebuilt/agent_executor.d.ts
7
11
  interface Step {
8
- action: AgentAction | AgentFinish;
9
- observation: unknown;
12
+ action: AgentAction | AgentFinish;
13
+ observation: unknown;
10
14
  }
11
15
  /** @ignore */
12
- export interface AgentExecutorState {
13
- agentOutcome?: AgentAction | AgentFinish;
14
- steps: Array<Step>;
15
- input: string;
16
- chatHistory?: BaseMessage[];
16
+ interface AgentExecutorState {
17
+ agentOutcome?: AgentAction | AgentFinish;
18
+ steps: Array<Step>;
19
+ input: string;
20
+ chatHistory?: BaseMessage[];
17
21
  }
18
22
  /** @ignore */
19
- export declare function createAgentExecutor({ agentRunnable, tools, }: {
20
- agentRunnable: Runnable;
21
- tools: Array<Tool> | ToolExecutor;
22
- }): import("../web.js").CompiledStateGraph<{
23
- agentOutcome?: (AgentAction | AgentFinish) | undefined;
24
- steps: Array<Step>;
25
- input: string;
26
- chatHistory?: BaseMessage[] | undefined;
23
+ declare function createAgentExecutor({
24
+ agentRunnable,
25
+ tools
26
+ }: {
27
+ agentRunnable: Runnable;
28
+ tools: Array<Tool> | ToolExecutor;
29
+ }): CompiledStateGraph<{
30
+ agentOutcome?: AgentAction | AgentFinish | undefined;
31
+ steps: Step[];
32
+ input: string;
33
+ chatHistory?: BaseMessage[] | undefined;
27
34
  }, {
28
- agentOutcome?: (AgentAction | AgentFinish) | undefined;
29
- steps?: Step[] | undefined;
30
- input?: string | undefined;
31
- chatHistory?: BaseMessage[] | undefined;
35
+ agentOutcome?: AgentAction | AgentFinish | undefined;
36
+ steps?: Step[] | undefined;
37
+ input?: string | undefined;
38
+ chatHistory?: BaseMessage[] | undefined;
32
39
  }, "__start__" | "action" | "agent", {
33
- agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;
34
- steps: BaseChannel<Step[], Step[], unknown>;
35
- input: BaseChannel<string, string, unknown>;
36
- chatHistory?: BaseChannel<BaseMessage[] | undefined, BaseMessage[] | undefined, unknown> | undefined;
40
+ agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;
41
+ steps: BaseChannel<Step[], Step[], unknown>;
42
+ input: BaseChannel<string, string, unknown>;
43
+ chatHistory?: BaseChannel<BaseMessage[] | undefined, BaseMessage[] | undefined, unknown> | undefined;
37
44
  }, {
38
- agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;
39
- steps: BaseChannel<Step[], Step[], unknown>;
40
- input: BaseChannel<string, string, unknown>;
41
- chatHistory?: BaseChannel<BaseMessage[] | undefined, BaseMessage[] | undefined, unknown> | undefined;
42
- }, import("../web.js").StateDefinition, {
43
- agent: {
44
- agentOutcome: any;
45
- };
46
- action: Partial<AgentExecutorState>;
47
- }>;
48
- export {};
45
+ agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;
46
+ steps: BaseChannel<Step[], Step[], unknown>;
47
+ input: BaseChannel<string, string, unknown>;
48
+ chatHistory?: BaseChannel<BaseMessage[] | undefined, BaseMessage[] | undefined, unknown> | undefined;
49
+ }, StateDefinition, {
50
+ action: Partial<AgentExecutorState>;
51
+ agent: {
52
+ agentOutcome: any;
53
+ };
54
+ }, unknown, unknown>;
55
+ //#endregion
56
+ export { AgentExecutorState, createAgentExecutor };
57
+ //# sourceMappingURL=agent_executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent_executor.d.ts","names":["AgentAction","AgentFinish","BaseMessage","Runnable","Tool","ToolExecutor","BaseChannel","Step","AgentExecutorState","Array","createAgentExecutor","agentRunnable","tools","___web_js0","StateDefinition","Partial","CompiledStateGraph"],"sources":["../../src/prebuilt/agent_executor.d.ts"],"sourcesContent":["import { AgentAction, AgentFinish } from \"@langchain/core/agents\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { Tool } from \"@langchain/core/tools\";\nimport { ToolExecutor } from \"./tool_executor.js\";\nimport type { BaseChannel } from \"../channels/base.js\";\ninterface Step {\n action: AgentAction | AgentFinish;\n observation: unknown;\n}\n/** @ignore */\nexport interface AgentExecutorState {\n agentOutcome?: AgentAction | AgentFinish;\n steps: Array<Step>;\n input: string;\n chatHistory?: BaseMessage[];\n}\n/** @ignore */\nexport declare function createAgentExecutor({ agentRunnable, tools }: {\n agentRunnable: Runnable;\n tools: Array<Tool> | ToolExecutor;\n}): import(\"../web.js\").CompiledStateGraph<{\n agentOutcome?: AgentAction | AgentFinish | undefined;\n steps: Step[];\n input: string;\n chatHistory?: BaseMessage[] | undefined;\n}, {\n agentOutcome?: AgentAction | AgentFinish | undefined;\n steps?: Step[] | undefined;\n input?: string | undefined;\n chatHistory?: BaseMessage[] | undefined;\n}, \"__start__\" | \"action\" | \"agent\", {\n agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;\n steps: BaseChannel<Step[], Step[], unknown>;\n input: BaseChannel<string, string, unknown>;\n chatHistory?: BaseChannel<BaseMessage[] | undefined, BaseMessage[] | undefined, unknown> | undefined;\n}, {\n agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;\n steps: BaseChannel<Step[], Step[], unknown>;\n input: BaseChannel<string, string, unknown>;\n chatHistory?: BaseChannel<BaseMessage[] | undefined, BaseMessage[] | undefined, unknown> | undefined;\n}, import(\"../web.js\").StateDefinition, {\n action: Partial<AgentExecutorState>;\n agent: {\n agentOutcome: any;\n };\n}, unknown, unknown>;\nexport {};\n"],"mappings":";;;;;;;;;;UAMUO,IAAAA;UACEP,cAAcC;;;AAF6B;AACzC,UAKGO,kBAAAA,CALH;cACFR,CAAAA,EAKOA,WALPA,GAKqBC,WALrBD;OAAcC,EAMfQ,KANeR,CAMTM,IANSN,CAAAA;;EAITO,WAAAA,CAAAA,EAICN,WAJiB,EAAA;;;AACFD,iBAMTS,mBAAAA,CANST;EAAAA,aAAAA;EAAAA;CAAAA,EAAAA;eAChBM,EAMEJ,QANFI;OAANE,EAOAA,KAPAA,CAOML,IAPNK,CAAAA,GAOcJ,YAPdI;sBAEOP,CAAAA;iBAOCF,cAAcC;EAJTS,KAAAA,EAKbH,IALaG,EAAAA;EAAmB,KAAA,EAAA,MAAA;aAAGC,CAAAA,EAO5BT,WAP4BS,EAAAA,GAAAA,SAAAA;;cAC3BR,CAAAA,EAQAH,WARAG,GAQcF,WARdE,GAAAA,SAAAA;OACFC,CAAAA,EAQLG,IARKH,EAAAA,GAAAA,SAAAA;OAANK,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;aAAcJ,CAAAA,EAUPH,WAVOG,EAAAA,GAAAA,SAAAA;cAENL,GAAAA,QAAAA,GAAAA,OAAAA,EAAAA;cAAcC,CAAAA,EAUdK,WAVcL,CAUFD,WAVEC,GAUYA,WAVZA,GAAAA,SAAAA,EAUqCD,WAVrCC,GAUmDA,WAVnDA,GAAAA,SAAAA,EAAAA,OAAAA,CAAAA,GAAAA,SAAAA;OACtBM,EAUAD,WAVAC,CAUYA,IAVZA,EAAAA,EAUoBA,IAVpBA,EAAAA,EAAAA,OAAAA,CAAAA;OAEOL,EASPI,WATOJ,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,OAAAA,CAAAA;aAECF,CAAAA,EAQDM,WARCN,CAQWE,WARXF,EAAAA,GAAAA,SAAAA,EAQsCE,WARtCF,EAAAA,GAAAA,SAAAA,EAAAA,OAAAA,CAAAA,GAAAA,SAAAA;;cACPO,CAAAA,EASOD,WATPC,CASmBP,WATnBO,GASiCN,WATjCM,GAAAA,SAAAA,EAS0DP,WAT1DO,GASwEN,WATxEM,GAAAA,SAAAA,EAAAA,OAAAA,CAAAA,GAAAA,SAAAA;OAEML,EAQPI,WAROJ,CAQKK,IARLL,EAAAA,EAQaK,IARbL,EAAAA,EAAAA,OAAAA,CAAAA;OAEaF,EAOpBM,WAPoBN,CAAAA,MAAAA,EAAAA,MAAAA,EAAAA,OAAAA,CAAAA;aAAcC,CAAAA,EAQ3BK,WAR2BL,CAQfC,WAReD,EAAAA,GAAAA,SAAAA,EAQYC,WARZD,EAAAA,GAAAA,SAAAA,EAAAA,OAAAA,CAAAA,GAAAA,SAAAA;oBAAyBD;QAAcC,EAUxEc,OAVwEd,CAUhEO,kBAVgEP,CAAAA;OAAjEK,EAAAA;IACIC,YAAAA,EAAAA,GAAAA;;UAAZD,EAAAA,OAAAA,CAAAA"}
@@ -1,79 +1,44 @@
1
- import { ToolExecutor } from "./tool_executor.js";
2
- import { StateGraph } from "../graph/state.js";
3
1
  import { END, START } from "../constants.js";
2
+ import { StateGraph } from "../graph/state.js";
3
+ import { ToolExecutor } from "./tool_executor.js";
4
+
5
+ //#region src/prebuilt/agent_executor.ts
4
6
  /** @ignore */
5
- export function createAgentExecutor({ agentRunnable, tools, }) {
6
- let toolExecutor;
7
- if (!Array.isArray(tools)) {
8
- toolExecutor = tools;
9
- }
10
- else {
11
- toolExecutor = new ToolExecutor({
12
- tools,
13
- });
14
- }
15
- // Define logic that will be used to determine which conditional edge to go down
16
- const shouldContinue = (data) => {
17
- if (data.agentOutcome && "returnValues" in data.agentOutcome) {
18
- return "end";
19
- }
20
- return "continue";
21
- };
22
- const runAgent = async (data, config) => {
23
- const agentOutcome = await agentRunnable.invoke(data, config);
24
- return {
25
- agentOutcome,
26
- };
27
- };
28
- const executeTools = async (data, config) => {
29
- const agentAction = data.agentOutcome;
30
- if (!agentAction || "returnValues" in agentAction) {
31
- throw new Error("Agent has not been run yet");
32
- }
33
- const output = await toolExecutor.invoke(agentAction, config);
34
- return {
35
- steps: [{ action: agentAction, observation: output }],
36
- };
37
- };
38
- // Define a new graph
39
- const workflow = new StateGraph({
40
- channels: {
41
- input: null,
42
- agentOutcome: null,
43
- steps: {
44
- reducer: (x, y) => x.concat(y),
45
- default: () => [],
46
- },
47
- },
48
- })
49
- // Define the two nodes we will cycle between
50
- .addNode("agent", runAgent)
51
- .addNode("action", executeTools)
52
- // Set the entrypoint as `agent`
53
- // This means that this node is the first one called
54
- .addEdge(START, "agent")
55
- // We now add a conditional edge
56
- .addConditionalEdges(
57
- // First, we define the start node. We use `agent`.
58
- // This means these are the edges taken after the `agent` node is called.
59
- "agent",
60
- // Next, we pass in the function that will determine which node is called next.
61
- shouldContinue,
62
- // Finally we pass in a mapping.
63
- // The keys are strings, and the values are other nodes.
64
- // END is a special node marking that the graph should finish.
65
- // What will happen is we will call `should_continue`, and then the output of that
66
- // will be matched against the keys in this mapping.
67
- // Based on which one it matches, that node will then be called.
68
- {
69
- // If `tools`, then we call the tool node.
70
- continue: "action",
71
- // Otherwise we finish.
72
- end: END,
73
- })
74
- // We now add a normal edge from `tools` to `agent`.
75
- // This means that after `tools` is called, `agent` node is called next.
76
- .addEdge("action", "agent");
77
- return workflow.compile();
7
+ function createAgentExecutor({ agentRunnable, tools }) {
8
+ let toolExecutor;
9
+ if (!Array.isArray(tools)) toolExecutor = tools;
10
+ else toolExecutor = new ToolExecutor({ tools });
11
+ const shouldContinue = (data) => {
12
+ if (data.agentOutcome && "returnValues" in data.agentOutcome) return "end";
13
+ return "continue";
14
+ };
15
+ const runAgent = async (data, config) => {
16
+ const agentOutcome = await agentRunnable.invoke(data, config);
17
+ return { agentOutcome };
18
+ };
19
+ const executeTools = async (data, config) => {
20
+ const agentAction = data.agentOutcome;
21
+ if (!agentAction || "returnValues" in agentAction) throw new Error("Agent has not been run yet");
22
+ const output = await toolExecutor.invoke(agentAction, config);
23
+ return { steps: [{
24
+ action: agentAction,
25
+ observation: output
26
+ }] };
27
+ };
28
+ const workflow = new StateGraph({ channels: {
29
+ input: null,
30
+ agentOutcome: null,
31
+ steps: {
32
+ reducer: (x, y) => x.concat(y),
33
+ default: () => []
34
+ }
35
+ } }).addNode("agent", runAgent).addNode("action", executeTools).addEdge(START, "agent").addConditionalEdges("agent", shouldContinue, {
36
+ continue: "action",
37
+ end: END
38
+ }).addEdge("action", "agent");
39
+ return workflow.compile();
78
40
  }
41
+
42
+ //#endregion
43
+ export { createAgentExecutor };
79
44
  //# sourceMappingURL=agent_executor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent_executor.js","sourceRoot":"","sources":["../../src/prebuilt/agent_executor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAgB7C,cAAc;AACd,MAAM,UAAU,mBAAmB,CAAC,EAClC,aAAa,EACb,KAAK,GAIN;IACC,IAAI,YAA0B,CAAC;IAC/B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,YAAY,GAAG,KAAK,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,YAAY,GAAG,IAAI,YAAY,CAAC;YAC9B,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,gFAAgF;IAChF,MAAM,cAAc,GAAG,CAAC,IAAwB,EAAE,EAAE;QAClD,IAAI,IAAI,CAAC,YAAY,IAAI,cAAc,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC7D,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,KAAK,EACpB,IAAwB,EACxB,MAAuB,EACvB,EAAE;QACF,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9D,OAAO;YACL,YAAY;SACb,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,KAAK,EACxB,IAAwB,EACxB,MAAuB,EACe,EAAE;QACxC,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,WAAW,IAAI,cAAc,IAAI,WAAW,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC9D,OAAO;YACL,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;SACtD,CAAC;IACJ,CAAC,CAAC;IAEF,qBAAqB;IACrB,MAAM,QAAQ,GAAG,IAAI,UAAU,CAK5B;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,IAAI;YACX,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE;gBACL,OAAO,EAAE,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC9C,OAAO,EAAE,GAAG,EAAE,CAAC,EAAY;aAC5B;SACF;KACF,CAAC;QACA,6CAA6C;SAC5C,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC;SAC1B,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC;QAChC,gCAAgC;QAChC,oDAAoD;SACnD,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC;QACxB,gCAAgC;SAC/B,mBAAmB;IAClB,mDAAmD;IACnD,yEAAyE;IACzE,OAAO;IACP,+EAA+E;IAC/E,cAAc;IACd,gCAAgC;IAChC,wDAAwD;IACxD,8DAA8D;IAC9D,kFAAkF;IAClF,oDAAoD;IACpD,gEAAgE;IAChE;QACE,0CAA0C;QAC1C,QAAQ,EAAE,QAAQ;QAClB,uBAAuB;QACvB,GAAG,EAAE,GAAG;KACT,CACF;QACD,oDAAoD;QACpD,wEAAwE;SACvE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE9B,OAAO,QAAQ,CAAC,OAAO,EAAE,CAAC;AAC5B,CAAC"}
1
+ {"version":3,"file":"agent_executor.js","names":["toolExecutor: ToolExecutor"],"sources":["../../src/prebuilt/agent_executor.ts"],"sourcesContent":["import { AgentAction, AgentFinish } from \"@langchain/core/agents\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { Runnable, type RunnableConfig } from \"@langchain/core/runnables\";\nimport { Tool } from \"@langchain/core/tools\";\nimport { ToolExecutor } from \"./tool_executor.js\";\nimport { StateGraph } from \"../graph/state.js\";\nimport { END, START } from \"../constants.js\";\nimport type { BaseChannel } from \"../channels/base.js\";\n\ninterface Step {\n action: AgentAction | AgentFinish;\n observation: unknown;\n}\n\n/** @ignore */\nexport interface AgentExecutorState {\n agentOutcome?: AgentAction | AgentFinish;\n steps: Array<Step>;\n input: string;\n chatHistory?: BaseMessage[];\n}\n\n/** @ignore */\nexport function createAgentExecutor({\n agentRunnable,\n tools,\n}: {\n agentRunnable: Runnable;\n tools: Array<Tool> | ToolExecutor;\n}) {\n let toolExecutor: ToolExecutor;\n if (!Array.isArray(tools)) {\n toolExecutor = tools;\n } else {\n toolExecutor = new ToolExecutor({\n tools,\n });\n }\n\n // Define logic that will be used to determine which conditional edge to go down\n const shouldContinue = (data: AgentExecutorState) => {\n if (data.agentOutcome && \"returnValues\" in data.agentOutcome) {\n return \"end\";\n }\n return \"continue\";\n };\n\n const runAgent = async (\n data: AgentExecutorState,\n config?: RunnableConfig\n ) => {\n const agentOutcome = await agentRunnable.invoke(data, config);\n return {\n agentOutcome,\n };\n };\n\n const executeTools = async (\n data: AgentExecutorState,\n config?: RunnableConfig\n ): Promise<Partial<AgentExecutorState>> => {\n const agentAction = data.agentOutcome;\n if (!agentAction || \"returnValues\" in agentAction) {\n throw new Error(\"Agent has not been run yet\");\n }\n const output = await toolExecutor.invoke(agentAction, config);\n return {\n steps: [{ action: agentAction, observation: output }],\n };\n };\n\n // Define a new graph\n const workflow = new StateGraph<{\n [K in keyof AgentExecutorState]: BaseChannel<\n AgentExecutorState[K],\n AgentExecutorState[K]\n >;\n }>({\n channels: {\n input: null,\n agentOutcome: null,\n steps: {\n reducer: (x: Step[], y: Step[]) => x.concat(y),\n default: () => [] as Step[],\n },\n },\n })\n // Define the two nodes we will cycle between\n .addNode(\"agent\", runAgent)\n .addNode(\"action\", executeTools)\n // Set the entrypoint as `agent`\n // This means that this node is the first one called\n .addEdge(START, \"agent\")\n // We now add a conditional edge\n .addConditionalEdges(\n // First, we define the start node. We use `agent`.\n // This means these are the edges taken after the `agent` node is called.\n \"agent\",\n // Next, we pass in the function that will determine which node is called next.\n shouldContinue,\n // Finally we pass in a mapping.\n // The keys are strings, and the values are other nodes.\n // END is a special node marking that the graph should finish.\n // What will happen is we will call `should_continue`, and then the output of that\n // will be matched against the keys in this mapping.\n // Based on which one it matches, that node will then be called.\n {\n // If `tools`, then we call the tool node.\n continue: \"action\",\n // Otherwise we finish.\n end: END,\n }\n )\n // We now add a normal edge from `tools` to `agent`.\n // This means that after `tools` is called, `agent` node is called next.\n .addEdge(\"action\", \"agent\");\n\n return workflow.compile();\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,oBAAoB,EAClC,eACA,SAIC;CACD,IAAIA;AACJ,KAAI,CAAC,MAAM,QAAQ,OACjB,gBAAe;KAEf,gBAAe,IAAI,aAAa,EAC9B;CAKJ,MAAM,kBAAkB,SAA6B;AACnD,MAAI,KAAK,gBAAgB,kBAAkB,KAAK,aAC9C,QAAO;AAET,SAAO;;CAGT,MAAM,WAAW,OACf,MACA,WACG;EACH,MAAM,eAAe,MAAM,cAAc,OAAO,MAAM;AACtD,SAAO,EACL;;CAIJ,MAAM,eAAe,OACnB,MACA,WACyC;EACzC,MAAM,cAAc,KAAK;AACzB,MAAI,CAAC,eAAe,kBAAkB,YACpC,OAAM,IAAI,MAAM;EAElB,MAAM,SAAS,MAAM,aAAa,OAAO,aAAa;AACtD,SAAO,EACL,OAAO,CAAC;GAAE,QAAQ;GAAa,aAAa;;;CAKhD,MAAM,WAAW,IAAI,WAKlB,EACD,UAAU;EACR,OAAO;EACP,cAAc;EACd,OAAO;GACL,UAAU,GAAW,MAAc,EAAE,OAAO;GAC5C,eAAe;;MAKlB,QAAQ,SAAS,UACjB,QAAQ,UAAU,cAGlB,QAAQ,OAAO,SAEf,oBAGC,SAEA,gBAOA;EAEE,UAAU;EAEV,KAAK;IAKR,QAAQ,UAAU;AAErB,QAAO,SAAS"}
@@ -1,130 +1,68 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createFunctionCallingExecutor = createFunctionCallingExecutor;
4
- const function_calling_1 = require("@langchain/core/utils/function_calling");
5
- const messages_1 = require("@langchain/core/messages");
6
- const runnables_1 = require("@langchain/core/runnables");
7
- const tool_executor_js_1 = require("./tool_executor.cjs");
8
- const state_js_1 = require("../graph/state.cjs");
9
- const constants_js_1 = require("../constants.cjs");
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_constants = require('../constants.cjs');
3
+ const require_state = require('../graph/state.cjs');
4
+ const require_tool_executor = require('./tool_executor.cjs');
5
+ const __langchain_core_runnables = require_rolldown_runtime.__toESM(require("@langchain/core/runnables"));
6
+ const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages"));
7
+ const __langchain_core_utils_function_calling = require_rolldown_runtime.__toESM(require("@langchain/core/utils/function_calling"));
8
+
9
+ //#region src/prebuilt/chat_agent_executor.ts
10
10
  /** @deprecated Use {@link createReactAgent} instead with tool calling. */
11
- function createFunctionCallingExecutor({ model, tools, }) {
12
- let toolExecutor;
13
- let toolClasses;
14
- if (!Array.isArray(tools)) {
15
- toolExecutor = tools;
16
- toolClasses = tools.tools;
17
- }
18
- else {
19
- toolExecutor = new tool_executor_js_1.ToolExecutor({
20
- tools,
21
- });
22
- toolClasses = tools;
23
- }
24
- if (!("bind" in model) || typeof model.bind !== "function") {
25
- throw new Error("Model must be bindable");
26
- }
27
- const toolsAsOpenAIFunctions = toolClasses.map((tool) => (0, function_calling_1.convertToOpenAIFunction)(tool));
28
- const newModel = model.bind({
29
- functions: toolsAsOpenAIFunctions,
30
- });
31
- // Define the function that determines whether to continue or not
32
- const shouldContinue = (state) => {
33
- const { messages } = state;
34
- const lastMessage = messages[messages.length - 1];
35
- // If there is no function call, then we finish
36
- if (!("function_call" in lastMessage.additional_kwargs) ||
37
- !lastMessage.additional_kwargs.function_call) {
38
- return "end";
39
- }
40
- // Otherwise if there is, we continue
41
- return "continue";
42
- };
43
- // Define the function that calls the model
44
- const callModel = async (state, config) => {
45
- const { messages } = state;
46
- const response = await newModel.invoke(messages, config);
47
- // We return a list, because this will get added to the existing list
48
- return {
49
- messages: [response],
50
- };
51
- };
52
- // Define the function to execute tools
53
- const _getAction = (state) => {
54
- const { messages } = state;
55
- // Based on the continue condition
56
- // we know the last message involves a function call
57
- const lastMessage = messages[messages.length - 1];
58
- if (!lastMessage) {
59
- throw new Error("No messages found.");
60
- }
61
- if (!lastMessage.additional_kwargs.function_call) {
62
- throw new Error("No function call found in message.");
63
- }
64
- // We construct an AgentAction from the function_call
65
- return {
66
- tool: lastMessage.additional_kwargs.function_call.name,
67
- toolInput: JSON.stringify(lastMessage.additional_kwargs.function_call.arguments),
68
- log: "",
69
- };
70
- };
71
- const callTool = async (state, config) => {
72
- const action = _getAction(state);
73
- // We call the tool_executor and get back a response
74
- const response = await toolExecutor.invoke(action, config);
75
- // We use the response to create a FunctionMessage
76
- const functionMessage = new messages_1.FunctionMessage({
77
- content: response,
78
- name: action.tool,
79
- });
80
- // We return a list, because this will get added to the existing list
81
- return { messages: [functionMessage] };
82
- };
83
- // We create the AgentState that we will pass around
84
- // This simply involves a list of messages
85
- // We want steps to return messages to append to the list
86
- // So we annotate the messages attribute with operator.add
87
- const schema = {
88
- messages: {
89
- value: (x, y) => x.concat(y),
90
- default: () => [],
91
- },
92
- };
93
- // Define a new graph
94
- const workflow = new state_js_1.StateGraph({
95
- channels: schema,
96
- })
97
- // Define the two nodes we will cycle between
98
- .addNode("agent", new runnables_1.RunnableLambda({ func: callModel }))
99
- .addNode("action", new runnables_1.RunnableLambda({ func: callTool }))
100
- // Set the entrypoint as `agent`
101
- // This means that this node is the first one called
102
- .addEdge(constants_js_1.START, "agent")
103
- // We now add a conditional edge
104
- .addConditionalEdges(
105
- // First, we define the start node. We use `agent`.
106
- // This means these are the edges taken after the `agent` node is called.
107
- "agent",
108
- // Next, we pass in the function that will determine which node is called next.
109
- shouldContinue,
110
- // Finally we pass in a mapping.
111
- // The keys are strings, and the values are other nodes.
112
- // END is a special node marking that the graph should finish.
113
- // What will happen is we will call `should_continue`, and then the output of that
114
- // will be matched against the keys in this mapping.
115
- // Based on which one it matches, that node will then be called.
116
- {
117
- // If `tools`, then we call the tool node.
118
- continue: "action",
119
- // Otherwise we finish.
120
- end: constants_js_1.END,
121
- })
122
- // We now add a normal edge from `tools` to `agent`.
123
- // This means that after `tools` is called, `agent` node is called next.
124
- .addEdge("action", "agent");
125
- // Finally, we compile it!
126
- // This compiles it into a LangChain Runnable,
127
- // meaning you can use it as you would any other runnable
128
- return workflow.compile();
11
+ function createFunctionCallingExecutor({ model, tools }) {
12
+ let toolExecutor;
13
+ let toolClasses;
14
+ if (!Array.isArray(tools)) {
15
+ toolExecutor = tools;
16
+ toolClasses = tools.tools;
17
+ } else {
18
+ toolExecutor = new require_tool_executor.ToolExecutor({ tools });
19
+ toolClasses = tools;
20
+ }
21
+ if (!("bind" in model) || typeof model.bind !== "function") throw new Error("Model must be bindable");
22
+ const toolsAsOpenAIFunctions = toolClasses.map((tool) => (0, __langchain_core_utils_function_calling.convertToOpenAIFunction)(tool));
23
+ const newModel = model.bind({ functions: toolsAsOpenAIFunctions });
24
+ const shouldContinue = (state) => {
25
+ const { messages } = state;
26
+ const lastMessage = messages[messages.length - 1];
27
+ if (!("function_call" in lastMessage.additional_kwargs) || !lastMessage.additional_kwargs.function_call) return "end";
28
+ return "continue";
29
+ };
30
+ const callModel = async (state, config) => {
31
+ const { messages } = state;
32
+ const response = await newModel.invoke(messages, config);
33
+ return { messages: [response] };
34
+ };
35
+ const _getAction = (state) => {
36
+ const { messages } = state;
37
+ const lastMessage = messages[messages.length - 1];
38
+ if (!lastMessage) throw new Error("No messages found.");
39
+ if (!lastMessage.additional_kwargs.function_call) throw new Error("No function call found in message.");
40
+ return {
41
+ tool: lastMessage.additional_kwargs.function_call.name,
42
+ toolInput: JSON.stringify(lastMessage.additional_kwargs.function_call.arguments),
43
+ log: ""
44
+ };
45
+ };
46
+ const callTool = async (state, config) => {
47
+ const action = _getAction(state);
48
+ const response = await toolExecutor.invoke(action, config);
49
+ const functionMessage = new __langchain_core_messages.FunctionMessage({
50
+ content: response,
51
+ name: action.tool
52
+ });
53
+ return { messages: [functionMessage] };
54
+ };
55
+ const schema = { messages: {
56
+ value: (x, y) => x.concat(y),
57
+ default: () => []
58
+ } };
59
+ const workflow = new require_state.StateGraph({ channels: schema }).addNode("agent", new __langchain_core_runnables.RunnableLambda({ func: callModel })).addNode("action", new __langchain_core_runnables.RunnableLambda({ func: callTool })).addEdge(require_constants.START, "agent").addConditionalEdges("agent", shouldContinue, {
60
+ continue: "action",
61
+ end: require_constants.END
62
+ }).addEdge("action", "agent");
63
+ return workflow.compile();
129
64
  }
130
- //# sourceMappingURL=chat_agent_executor.js.map
65
+
66
+ //#endregion
67
+ exports.createFunctionCallingExecutor = createFunctionCallingExecutor;
68
+ //# sourceMappingURL=chat_agent_executor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_agent_executor.cjs","names":["toolExecutor: ToolExecutor","toolClasses: Array<StructuredToolInterface | RunnableToolLike>","ToolExecutor","FunctionMessage","schema: StateGraphArgs<FunctionCallingExecutorState>[\"channels\"]","StateGraph","RunnableLambda","START","END"],"sources":["../../src/prebuilt/chat_agent_executor.ts"],"sourcesContent":["import { StructuredToolInterface } from \"@langchain/core/tools\";\nimport { convertToOpenAIFunction } from \"@langchain/core/utils/function_calling\";\nimport { AgentAction } from \"@langchain/core/agents\";\nimport { FunctionMessage, BaseMessage } from \"@langchain/core/messages\";\nimport {\n type RunnableConfig,\n RunnableLambda,\n RunnableToolLike,\n} from \"@langchain/core/runnables\";\nimport { ToolExecutor } from \"./tool_executor.js\";\nimport {\n CompiledStateGraph,\n StateGraph,\n StateGraphArgs,\n} from \"../graph/state.js\";\nimport { END, START } from \"../constants.js\";\n\n/** @deprecated Use {@link createReactAgent} instead with tool calling. */\nexport type FunctionCallingExecutorState = { messages: Array<BaseMessage> };\n\n/** @deprecated Use {@link createReactAgent} instead with tool calling. */\nexport function createFunctionCallingExecutor<Model extends object>({\n model,\n tools,\n}: {\n model: Model;\n tools: Array<StructuredToolInterface | RunnableToolLike> | ToolExecutor;\n}): CompiledStateGraph<\n FunctionCallingExecutorState,\n Partial<FunctionCallingExecutorState>,\n typeof START | \"agent\" | \"action\"\n> {\n let toolExecutor: ToolExecutor;\n let toolClasses: Array<StructuredToolInterface | RunnableToolLike>;\n if (!Array.isArray(tools)) {\n toolExecutor = tools;\n toolClasses = tools.tools;\n } else {\n toolExecutor = new ToolExecutor({\n tools,\n });\n toolClasses = tools;\n }\n\n if (!(\"bind\" in model) || typeof model.bind !== \"function\") {\n throw new Error(\"Model must be bindable\");\n }\n const toolsAsOpenAIFunctions = toolClasses.map((tool) =>\n convertToOpenAIFunction(tool)\n );\n const newModel = model.bind({\n functions: toolsAsOpenAIFunctions,\n });\n\n // Define the function that determines whether to continue or not\n const shouldContinue = (state: FunctionCallingExecutorState) => {\n const { messages } = state;\n const lastMessage = messages[messages.length - 1];\n // If there is no function call, then we finish\n if (\n !(\"function_call\" in lastMessage.additional_kwargs) ||\n !lastMessage.additional_kwargs.function_call\n ) {\n return \"end\";\n }\n // Otherwise if there is, we continue\n return \"continue\";\n };\n\n // Define the function that calls the model\n const callModel = async (\n state: FunctionCallingExecutorState,\n config?: RunnableConfig\n ) => {\n const { messages } = state;\n const response = await newModel.invoke(messages, config);\n // We return a list, because this will get added to the existing list\n return {\n messages: [response],\n };\n };\n\n // Define the function to execute tools\n const _getAction = (state: FunctionCallingExecutorState): AgentAction => {\n const { messages } = state;\n // Based on the continue condition\n // we know the last message involves a function call\n const lastMessage = messages[messages.length - 1];\n if (!lastMessage) {\n throw new Error(\"No messages found.\");\n }\n if (!lastMessage.additional_kwargs.function_call) {\n throw new Error(\"No function call found in message.\");\n }\n // We construct an AgentAction from the function_call\n return {\n tool: lastMessage.additional_kwargs.function_call.name,\n toolInput: JSON.stringify(\n lastMessage.additional_kwargs.function_call.arguments\n ),\n log: \"\",\n };\n };\n\n const callTool = async (\n state: FunctionCallingExecutorState,\n config?: RunnableConfig\n ) => {\n const action = _getAction(state);\n // We call the tool_executor and get back a response\n const response = await toolExecutor.invoke(action, config);\n // We use the response to create a FunctionMessage\n const functionMessage = new FunctionMessage({\n content: response,\n name: action.tool,\n });\n // We return a list, because this will get added to the existing list\n return { messages: [functionMessage] };\n };\n\n // We create the AgentState that we will pass around\n // This simply involves a list of messages\n // We want steps to return messages to append to the list\n // So we annotate the messages attribute with operator.add\n const schema: StateGraphArgs<FunctionCallingExecutorState>[\"channels\"] = {\n messages: {\n value: (x: BaseMessage[], y: BaseMessage[]) => x.concat(y),\n default: () => [],\n },\n };\n\n // Define a new graph\n const workflow = new StateGraph<FunctionCallingExecutorState>({\n channels: schema,\n })\n // Define the two nodes we will cycle between\n .addNode(\"agent\", new RunnableLambda({ func: callModel }))\n .addNode(\"action\", new RunnableLambda({ func: callTool }))\n // Set the entrypoint as `agent`\n // This means that this node is the first one called\n .addEdge(START, \"agent\")\n // We now add a conditional edge\n .addConditionalEdges(\n // First, we define the start node. We use `agent`.\n // This means these are the edges taken after the `agent` node is called.\n \"agent\",\n // Next, we pass in the function that will determine which node is called next.\n shouldContinue,\n // Finally we pass in a mapping.\n // The keys are strings, and the values are other nodes.\n // END is a special node marking that the graph should finish.\n // What will happen is we will call `should_continue`, and then the output of that\n // will be matched against the keys in this mapping.\n // Based on which one it matches, that node will then be called.\n {\n // If `tools`, then we call the tool node.\n continue: \"action\",\n // Otherwise we finish.\n end: END,\n }\n )\n // We now add a normal edge from `tools` to `agent`.\n // This means that after `tools` is called, `agent` node is called next.\n .addEdge(\"action\", \"agent\");\n\n // Finally, we compile it!\n // This compiles it into a LangChain Runnable,\n // meaning you can use it as you would any other runnable\n return workflow.compile();\n}\n"],"mappings":";;;;;;;;;;AAqBA,SAAgB,8BAAoD,EAClE,OACA,SAQA;CACA,IAAIA;CACJ,IAAIC;AACJ,KAAI,CAAC,MAAM,QAAQ,QAAQ;AACzB,iBAAe;AACf,gBAAc,MAAM;QACf;AACL,iBAAe,IAAIC,mCAAa,EAC9B;AAEF,gBAAc;;AAGhB,KAAI,EAAE,UAAU,UAAU,OAAO,MAAM,SAAS,WAC9C,OAAM,IAAI,MAAM;CAElB,MAAM,yBAAyB,YAAY,KAAK,8EACtB;CAE1B,MAAM,WAAW,MAAM,KAAK,EAC1B,WAAW;CAIb,MAAM,kBAAkB,UAAwC;EAC9D,MAAM,EAAE,aAAa;EACrB,MAAM,cAAc,SAAS,SAAS,SAAS;AAE/C,MACE,EAAE,mBAAmB,YAAY,sBACjC,CAAC,YAAY,kBAAkB,cAE/B,QAAO;AAGT,SAAO;;CAIT,MAAM,YAAY,OAChB,OACA,WACG;EACH,MAAM,EAAE,aAAa;EACrB,MAAM,WAAW,MAAM,SAAS,OAAO,UAAU;AAEjD,SAAO,EACL,UAAU,CAAC;;CAKf,MAAM,cAAc,UAAqD;EACvE,MAAM,EAAE,aAAa;EAGrB,MAAM,cAAc,SAAS,SAAS,SAAS;AAC/C,MAAI,CAAC,YACH,OAAM,IAAI,MAAM;AAElB,MAAI,CAAC,YAAY,kBAAkB,cACjC,OAAM,IAAI,MAAM;AAGlB,SAAO;GACL,MAAM,YAAY,kBAAkB,cAAc;GAClD,WAAW,KAAK,UACd,YAAY,kBAAkB,cAAc;GAE9C,KAAK;;;CAIT,MAAM,WAAW,OACf,OACA,WACG;EACH,MAAM,SAAS,WAAW;EAE1B,MAAM,WAAW,MAAM,aAAa,OAAO,QAAQ;EAEnD,MAAM,kBAAkB,IAAIC,0CAAgB;GAC1C,SAAS;GACT,MAAM,OAAO;;AAGf,SAAO,EAAE,UAAU,CAAC;;CAOtB,MAAMC,SAAmE,EACvE,UAAU;EACR,QAAQ,GAAkB,MAAqB,EAAE,OAAO;EACxD,eAAe;;CAKnB,MAAM,WAAW,IAAIC,yBAAyC,EAC5D,UAAU,UAGT,QAAQ,SAAS,IAAIC,0CAAe,EAAE,MAAM,cAC5C,QAAQ,UAAU,IAAIA,0CAAe,EAAE,MAAM,aAG7C,QAAQC,yBAAO,SAEf,oBAGC,SAEA,gBAOA;EAEE,UAAU;EAEV,KAAKC;IAKR,QAAQ,UAAU;AAKrB,QAAO,SAAS"}
@@ -0,0 +1,23 @@
1
+ import { START } from "../constants.cjs";
2
+ import { CompiledStateGraph } from "../graph/state.cjs";
3
+ import { ToolExecutor } from "./tool_executor.cjs";
4
+ import { RunnableToolLike } from "@langchain/core/runnables";
5
+ import { BaseMessage } from "@langchain/core/messages";
6
+ import { StructuredToolInterface } from "@langchain/core/tools";
7
+
8
+ //#region src/prebuilt/chat_agent_executor.d.ts
9
+ /** @deprecated Use {@link createReactAgent} instead with tool calling. */
10
+ type FunctionCallingExecutorState = {
11
+ messages: Array<BaseMessage>;
12
+ };
13
+ /** @deprecated Use {@link createReactAgent} instead with tool calling. */
14
+ declare function createFunctionCallingExecutor<Model extends object>({
15
+ model,
16
+ tools
17
+ }: {
18
+ model: Model;
19
+ tools: Array<StructuredToolInterface | RunnableToolLike> | ToolExecutor;
20
+ }): CompiledStateGraph<FunctionCallingExecutorState, Partial<FunctionCallingExecutorState>, typeof START | "agent" | "action">;
21
+ //#endregion
22
+ export { FunctionCallingExecutorState, createFunctionCallingExecutor };
23
+ //# sourceMappingURL=chat_agent_executor.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_agent_executor.d.cts","names":["StructuredToolInterface","BaseMessage","RunnableToolLike","ToolExecutor","CompiledStateGraph","START","FunctionCallingExecutorState","Array","createFunctionCallingExecutor","model","tools","Model","Partial"],"sources":["../../src/prebuilt/chat_agent_executor.d.ts"],"sourcesContent":["import { StructuredToolInterface } from \"@langchain/core/tools\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { RunnableToolLike } from \"@langchain/core/runnables\";\nimport { ToolExecutor } from \"./tool_executor.js\";\nimport { CompiledStateGraph } from \"../graph/state.js\";\nimport { START } from \"../constants.js\";\n/** @deprecated Use {@link createReactAgent} instead with tool calling. */\nexport type FunctionCallingExecutorState = {\n messages: Array<BaseMessage>;\n};\n/** @deprecated Use {@link createReactAgent} instead with tool calling. */\nexport declare function createFunctionCallingExecutor<Model extends object>({ model, tools }: {\n model: Model;\n tools: Array<StructuredToolInterface | RunnableToolLike> | ToolExecutor;\n}): CompiledStateGraph<FunctionCallingExecutorState, Partial<FunctionCallingExecutorState>, typeof START | \"agent\" | \"action\">;\n"],"mappings":";;;;;;;;;KAOYM,4BAAAA;EAAAA,QAAAA,EACEC,KADFD,CACQL,WADRK,CAAAA;CAA4B;;AAC1BC,iBAGUC,6BAHVD,CAAAA,cAAAA,MAAAA,CAAAA,CAAAA;EAAAA,KAAAA;EAAAA;CAAAA,EAAAA;SAIHI;EADaH,KAAAA,EAEbD,KAFaC,CAEPR,uBAFoC,GAEVE,gBAFU,CAAA,GAEUC,YAFV;CAAA,CAAA,EAGjDC,kBAHiD,CAG9BE,4BAH8B,EAGAM,OAHA,CAGQN,4BAHR,CAAA,EAAA,OAG8CD,KAH9C,GAAA,OAAA,GAAA,QAAA,CAAA"}
@@ -1,15 +1,23 @@
1
- import { StructuredToolInterface } from "@langchain/core/tools";
2
- import { BaseMessage } from "@langchain/core/messages";
3
- import { RunnableToolLike } from "@langchain/core/runnables";
4
- import { ToolExecutor } from "./tool_executor.js";
5
- import { CompiledStateGraph } from "../graph/state.js";
6
1
  import { START } from "../constants.js";
2
+ import { CompiledStateGraph } from "../graph/state.js";
3
+ import { ToolExecutor } from "./tool_executor.js";
4
+ import { RunnableToolLike } from "@langchain/core/runnables";
5
+ import { BaseMessage } from "@langchain/core/messages";
6
+ import { StructuredToolInterface } from "@langchain/core/tools";
7
+
8
+ //#region src/prebuilt/chat_agent_executor.d.ts
7
9
  /** @deprecated Use {@link createReactAgent} instead with tool calling. */
8
- export type FunctionCallingExecutorState = {
9
- messages: Array<BaseMessage>;
10
+ type FunctionCallingExecutorState = {
11
+ messages: Array<BaseMessage>;
10
12
  };
11
13
  /** @deprecated Use {@link createReactAgent} instead with tool calling. */
12
- export declare function createFunctionCallingExecutor<Model extends object>({ model, tools, }: {
13
- model: Model;
14
- tools: Array<StructuredToolInterface | RunnableToolLike> | ToolExecutor;
14
+ declare function createFunctionCallingExecutor<Model extends object>({
15
+ model,
16
+ tools
17
+ }: {
18
+ model: Model;
19
+ tools: Array<StructuredToolInterface | RunnableToolLike> | ToolExecutor;
15
20
  }): CompiledStateGraph<FunctionCallingExecutorState, Partial<FunctionCallingExecutorState>, typeof START | "agent" | "action">;
21
+ //#endregion
22
+ export { FunctionCallingExecutorState, createFunctionCallingExecutor };
23
+ //# sourceMappingURL=chat_agent_executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_agent_executor.d.ts","names":["StructuredToolInterface","BaseMessage","RunnableToolLike","ToolExecutor","CompiledStateGraph","START","FunctionCallingExecutorState","Array","createFunctionCallingExecutor","model","tools","Model","Partial"],"sources":["../../src/prebuilt/chat_agent_executor.d.ts"],"sourcesContent":["import { StructuredToolInterface } from \"@langchain/core/tools\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { RunnableToolLike } from \"@langchain/core/runnables\";\nimport { ToolExecutor } from \"./tool_executor.js\";\nimport { CompiledStateGraph } from \"../graph/state.js\";\nimport { START } from \"../constants.js\";\n/** @deprecated Use {@link createReactAgent} instead with tool calling. */\nexport type FunctionCallingExecutorState = {\n messages: Array<BaseMessage>;\n};\n/** @deprecated Use {@link createReactAgent} instead with tool calling. */\nexport declare function createFunctionCallingExecutor<Model extends object>({ model, tools }: {\n model: Model;\n tools: Array<StructuredToolInterface | RunnableToolLike> | ToolExecutor;\n}): CompiledStateGraph<FunctionCallingExecutorState, Partial<FunctionCallingExecutorState>, typeof START | \"agent\" | \"action\">;\n"],"mappings":";;;;;;;;;KAOYM,4BAAAA;EAAAA,QAAAA,EACEC,KADFD,CACQL,WADRK,CAAAA;CAA4B;;AAC1BC,iBAGUC,6BAHVD,CAAAA,cAAAA,MAAAA,CAAAA,CAAAA;EAAAA,KAAAA;EAAAA;CAAAA,EAAAA;SAIHI;EADaH,KAAAA,EAEbD,KAFaC,CAEPR,uBAFoC,GAEVE,gBAFU,CAAA,GAEUC,YAFV;CAAA,CAAA,EAGjDC,kBAHiD,CAG9BE,4BAH8B,EAGAM,OAHA,CAGQN,4BAHR,CAAA,EAAA,OAG8CD,KAH9C,GAAA,OAAA,GAAA,QAAA,CAAA"}