@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
@@ -1 +1 @@
1
- {"version":3,"file":"react_agent_executor.js","sourceRoot":"","sources":["../../src/prebuilt/react_agent_executor.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,WAAW,EACX,aAAa,EACb,aAAa,EACb,aAAa,GAEd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,QAAQ,EAER,cAAc,EAEd,gBAAgB,EAChB,eAAe,GAEhB,MAAM,2BAA2B,CAAC;AAYnC,OAAO,EACL,UAAU,GAGX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAY,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AA2B/C,SAAS,+BAA+B,CACtC,eAAgC;IAEhC,iCAAiC;IACjC,IACE,OAAO,eAAe,KAAK,QAAQ;QACnC,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,eAAe,CAAC,QAAQ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kB,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EACpC,CAAC;oBACD,OAAO,GAAG,CAAC;gBACb,CAAC;YACH,CAAC;YAED,OAAO,UAAU,CAAC;QACpB,CAAC,EACD,cAAc,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CACzD,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,gBAAgB,CAAC,OAAO,CAAC;QAC9B,YAAY,EAAE,YAAY,IAAI,eAAe;QAC7C,eAAe;QACf,cAAc;QACd,KAAK;QACL,IAAI;QACJ,WAAW;KACZ,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"react_agent_executor.js","names":["promptRunnable: Runnable","boundToolName: string | undefined","model","nextSteps: unknown[]","toolClasses: (ClientTool | ServerTool)[]","toolNode: ToolNode","cachedStaticModel: Runnable | null","modelWithTools: LanguageModelLike","llm","model: LanguageModelLike","schema","prompt","modelRunnable: Runnable","entrypoint: \"agent\" | \"pre_model_hook\"","inputSchema: AnnotationRoot<ToAnnotationRoot<A>[\"spec\"]> | undefined","toolMessageIds: Set<string>","lastAiMessage: AIMessage | undefined"],"sources":["../../src/prebuilt/react_agent_executor.ts"],"sourcesContent":["import {\n BaseChatModel,\n BindToolsInput,\n} from \"@langchain/core/language_models/chat_models\";\nimport { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport {\n BaseMessage,\n BaseMessageLike,\n isAIMessage,\n isBaseMessage,\n isToolMessage,\n SystemMessage,\n type AIMessage,\n} from \"@langchain/core/messages\";\nimport {\n Runnable,\n RunnableLambda,\n RunnableToolLike,\n RunnableSequence,\n RunnableBinding,\n type RunnableLike,\n} from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport {\n All,\n BaseCheckpointSaver,\n BaseStore,\n} from \"@langchain/langgraph-checkpoint\";\n\nimport {\n StateGraph,\n type CompiledStateGraph,\n AnnotationRoot,\n} from \"../graph/index.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { ToolNode } from \"./tool_node.js\";\nimport { LangGraphRunnableConfig, Runtime } from \"../pregel/runnable_types.js\";\nimport { Annotation } from \"../graph/annotation.js\";\nimport { Messages, messagesStateReducer } from \"../graph/message.js\";\nimport { END, Send, START } from \"../constants.js\";\nimport { withAgentName } from \"./agentName.js\";\nimport type { InteropZodToStateDefinition } from \"../graph/zod/meta.js\";\n\n/**\n * @deprecated `AgentState` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { AgentState } from \"langchain\";`\n */\nexport interface AgentState<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n StructuredResponseType extends Record<string, any> = Record<string, any>\n> {\n messages: BaseMessage[];\n // TODO: This won't be set until we\n // implement managed values in LangGraphJS\n // Will be useful for inserting a message on\n // graph recursion end\n // is_last_step: boolean;\n structuredResponse: StructuredResponseType;\n}\n\nexport type N = typeof START | \"agent\" | \"tools\";\n\ntype StructuredResponseSchemaOptions<StructuredResponseType> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: InteropZodType<StructuredResponseType> | Record<string, any>;\n prompt?: string;\n\n strict?: boolean;\n [key: string]: unknown;\n};\n\nfunction _convertMessageModifierToPrompt(\n messageModifier: MessageModifier\n): Prompt {\n // Handle string or SystemMessage\n if (\n typeof messageModifier === \"string\" ||\n (isBaseMessage(messageModifier) && messageModifier._getType() === \"system\")\n ) {\n return messageModifier;\n }\n\n // Handle callable function\n if (typeof messageModifier === \"function\") {\n return async (state: typeof MessagesAnnotation.State) =>\n messageModifier(state.messages);\n }\n\n // Handle Runnable\n if (Runnable.isRunnable(messageModifier)) {\n return RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => state.messages\n ).pipe(messageModifier);\n }\n\n throw new Error(\n `Unexpected type for messageModifier: ${typeof messageModifier}`\n );\n}\n\nconst PROMPT_RUNNABLE_NAME = \"prompt\";\n\nfunction _getPromptRunnable(prompt?: Prompt): Runnable {\n let promptRunnable: Runnable;\n\n if (prompt == null) {\n promptRunnable = RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => state.messages\n ).withConfig({ runName: PROMPT_RUNNABLE_NAME });\n } else if (typeof prompt === \"string\") {\n const systemMessage = new SystemMessage(prompt);\n promptRunnable = RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => {\n return [systemMessage, ...(state.messages ?? [])];\n }\n ).withConfig({ runName: PROMPT_RUNNABLE_NAME });\n } else if (isBaseMessage(prompt) && prompt._getType() === \"system\") {\n promptRunnable = RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => [prompt, ...state.messages]\n ).withConfig({ runName: PROMPT_RUNNABLE_NAME });\n } else if (typeof prompt === \"function\") {\n promptRunnable = RunnableLambda.from(prompt).withConfig({\n runName: PROMPT_RUNNABLE_NAME,\n });\n } else if (Runnable.isRunnable(prompt)) {\n promptRunnable = prompt;\n } else {\n throw new Error(`Got unexpected type for 'prompt': ${typeof prompt}`);\n }\n\n return promptRunnable;\n}\n\ntype ServerTool = Record<string, unknown>;\ntype ClientTool = StructuredToolInterface | DynamicTool | RunnableToolLike;\n\nfunction isClientTool(tool: ClientTool | ServerTool): tool is ClientTool {\n return Runnable.isRunnable(tool);\n}\n\nfunction _getPrompt(\n prompt?: Prompt,\n stateModifier?: CreateReactAgentParams[\"stateModifier\"],\n messageModifier?: CreateReactAgentParams[\"messageModifier\"]\n): Runnable {\n // Check if multiple modifiers exist\n const definedCount = [prompt, stateModifier, messageModifier].filter(\n (x) => x != null\n ).length;\n if (definedCount > 1) {\n throw new Error(\n \"Expected only one of prompt, stateModifier, or messageModifier, got multiple values\"\n );\n }\n\n let finalPrompt = prompt;\n if (stateModifier != null) {\n finalPrompt = stateModifier;\n } else if (messageModifier != null) {\n finalPrompt = _convertMessageModifierToPrompt(messageModifier);\n }\n\n return _getPromptRunnable(finalPrompt);\n}\n\nfunction _isBaseChatModel(model: LanguageModelLike): model is BaseChatModel {\n return (\n \"invoke\" in model &&\n typeof model.invoke === \"function\" &&\n \"_modelType\" in model\n );\n}\n\ninterface ConfigurableModelInterface {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _queuedMethodOperations: Record<string, any>;\n _model: () => Promise<BaseChatModel>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _isConfigurableModel(model: any): model is ConfigurableModelInterface {\n return (\n \"_queuedMethodOperations\" in model &&\n \"_model\" in model &&\n typeof model._model === \"function\"\n );\n}\n\nfunction _isChatModelWithBindTools(\n llm: LanguageModelLike\n): llm is BaseChatModel & Required<Pick<BaseChatModel, \"bindTools\">> {\n if (!_isBaseChatModel(llm)) return false;\n return \"bindTools\" in llm && typeof llm.bindTools === \"function\";\n}\n\nexport async function _shouldBindTools(\n llm: LanguageModelLike,\n tools: (ClientTool | ServerTool)[]\n): Promise<boolean> {\n // If model is a RunnableSequence, find a RunnableBinding or BaseChatModel in its steps\n let model = llm;\n if (RunnableSequence.isRunnableSequence(model)) {\n model =\n model.steps.find(\n (step) =>\n RunnableBinding.isRunnableBinding(step) ||\n _isBaseChatModel(step) ||\n _isConfigurableModel(step)\n ) || model;\n }\n\n if (_isConfigurableModel(model)) {\n model = await model._model();\n }\n\n // If not a RunnableBinding, we should bind tools\n if (!RunnableBinding.isRunnableBinding(model)) {\n return true;\n }\n\n let boundTools = (() => {\n // check if model.kwargs contain the tools key\n if (\n model.kwargs != null &&\n typeof model.kwargs === \"object\" &&\n \"tools\" in model.kwargs &&\n Array.isArray(model.kwargs.tools)\n ) {\n return (model.kwargs.tools ?? null) as BindToolsInput[] | null;\n }\n\n // Some models can bind the tools via `withConfig()` instead of `bind()`\n if (\n model.config != null &&\n typeof model.config === \"object\" &&\n \"tools\" in model.config &&\n Array.isArray(model.config.tools)\n ) {\n return (model.config.tools ?? null) as BindToolsInput[] | null;\n }\n\n return null;\n })();\n\n // google-style\n if (\n boundTools != null &&\n boundTools.length === 1 &&\n \"functionDeclarations\" in boundTools[0]\n ) {\n boundTools = boundTools[0].functionDeclarations;\n }\n\n // If no tools in kwargs, we should bind tools\n if (boundTools == null) return true;\n\n // Check if tools count matches\n if (tools.length !== boundTools.length) {\n throw new Error(\n \"Number of tools in the model.bindTools() and tools passed to createReactAgent must match\"\n );\n }\n\n const toolNames = new Set<string>(\n tools.flatMap((tool) => (isClientTool(tool) ? tool.name : []))\n );\n\n const boundToolNames = new Set<string>();\n\n for (const boundTool of boundTools) {\n let boundToolName: string | undefined;\n\n // OpenAI-style tool\n if (\"type\" in boundTool && boundTool.type === \"function\") {\n boundToolName = boundTool.function.name;\n }\n // Anthropic or Google-style tool\n else if (\"name\" in boundTool) {\n boundToolName = boundTool.name;\n }\n // Bedrock-style tool\n else if (\"toolSpec\" in boundTool && \"name\" in boundTool.toolSpec) {\n boundToolName = boundTool.toolSpec.name;\n }\n // unknown tool type so we'll ignore it\n else {\n continue;\n }\n\n if (boundToolName) {\n boundToolNames.add(boundToolName);\n }\n }\n\n const missingTools = [...toolNames].filter((x) => !boundToolNames.has(x));\n if (missingTools.length > 0) {\n throw new Error(\n `Missing tools '${missingTools}' in the model.bindTools().` +\n `Tools in the model.bindTools() must match the tools passed to createReactAgent.`\n );\n }\n\n return false;\n}\n\nconst _simpleBindTools = (\n llm: LanguageModelLike,\n toolClasses: (ClientTool | ServerTool)[]\n) => {\n if (_isChatModelWithBindTools(llm)) {\n return llm.bindTools(toolClasses);\n }\n\n if (\n RunnableBinding.isRunnableBinding(llm) &&\n _isChatModelWithBindTools(llm.bound)\n ) {\n const newBound = llm.bound.bindTools(toolClasses);\n\n if (RunnableBinding.isRunnableBinding(newBound)) {\n return new RunnableBinding({\n bound: newBound.bound,\n config: { ...llm.config, ...newBound.config },\n kwargs: { ...llm.kwargs, ...newBound.kwargs },\n configFactories: newBound.configFactories ?? llm.configFactories,\n });\n }\n\n return new RunnableBinding({\n bound: newBound,\n config: llm.config,\n kwargs: llm.kwargs,\n configFactories: llm.configFactories,\n });\n }\n\n return null;\n};\n\nexport async function _bindTools(\n llm: LanguageModelLike,\n toolClasses: (ClientTool | ServerTool)[]\n) {\n const model = _simpleBindTools(llm, toolClasses);\n if (model) return model;\n\n if (_isConfigurableModel(llm)) {\n const model = _simpleBindTools(await llm._model(), toolClasses);\n if (model) return model;\n }\n\n if (RunnableSequence.isRunnableSequence(llm)) {\n const modelStep = llm.steps.findIndex(\n (step) =>\n RunnableBinding.isRunnableBinding(step) ||\n _isBaseChatModel(step) ||\n _isConfigurableModel(step)\n );\n\n if (modelStep >= 0) {\n const model = _simpleBindTools(llm.steps[modelStep], toolClasses);\n if (model) {\n const nextSteps: unknown[] = llm.steps.slice();\n nextSteps.splice(modelStep, 1, model);\n\n return RunnableSequence.from(\n nextSteps as [RunnableLike, ...RunnableLike[], RunnableLike]\n );\n }\n }\n }\n\n throw new Error(`llm ${llm} must define bindTools method.`);\n}\n\nexport async function _getModel(\n llm: LanguageModelLike | ConfigurableModelInterface\n): Promise<LanguageModelLike> {\n // If model is a RunnableSequence, find a RunnableBinding or BaseChatModel in its steps\n let model = llm;\n if (RunnableSequence.isRunnableSequence(model)) {\n model =\n model.steps.find(\n (step) =>\n RunnableBinding.isRunnableBinding(step) ||\n _isBaseChatModel(step) ||\n _isConfigurableModel(step)\n ) || model;\n }\n\n if (_isConfigurableModel(model)) {\n model = await model._model();\n }\n\n // Get the underlying model from a RunnableBinding\n if (RunnableBinding.isRunnableBinding(model)) {\n model = model.bound;\n }\n\n if (!_isBaseChatModel(model)) {\n throw new Error(\n `Expected \\`llm\\` to be a ChatModel or RunnableBinding (e.g. llm.bind_tools(...)) with invoke() and generate() methods, got ${model.constructor.name}`\n );\n }\n\n return model;\n}\n\nexport type Prompt =\n | SystemMessage\n | string\n | ((\n state: typeof MessagesAnnotation.State,\n config: LangGraphRunnableConfig\n ) => BaseMessageLike[])\n | ((\n state: typeof MessagesAnnotation.State,\n config: LangGraphRunnableConfig\n ) => Promise<BaseMessageLike[]>)\n | Runnable;\n\n/** @deprecated Use Prompt instead. */\nexport type StateModifier = Prompt;\n\n/** @deprecated Use Prompt instead. */\nexport type MessageModifier =\n | SystemMessage\n | string\n | ((messages: BaseMessage[]) => BaseMessage[])\n | ((messages: BaseMessage[]) => Promise<BaseMessage[]>)\n | Runnable;\n\nexport const createReactAgentAnnotation = <\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, any> = Record<string, any>\n>() =>\n Annotation.Root({\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n structuredResponse: Annotation<T>,\n });\n\ntype WithStateGraphNodes<K extends string, Graph> = Graph extends StateGraph<\n infer SD,\n infer S,\n infer U,\n infer N,\n infer I,\n infer O,\n infer C\n>\n ? StateGraph<SD, S, U, N | K, I, O, C>\n : never;\n\nconst PreHookAnnotation = Annotation.Root({\n llmInputMessages: Annotation<BaseMessage[], Messages>({\n reducer: (_, update) => messagesStateReducer([], update),\n default: () => [],\n }),\n});\n\ntype PreHookAnnotation = typeof PreHookAnnotation;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyAnnotationRoot = AnnotationRoot<any>;\n\ntype ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> =\n A extends AnyAnnotationRoot\n ? A\n : A extends InteropZodObject\n ? AnnotationRoot<InteropZodToStateDefinition<A>>\n : never;\n\n/**\n * @deprecated `CreateReactAgentParams` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { CreateAgentParams } from \"langchain\";`\n */\nexport type CreateReactAgentParams<\n A extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n StructuredResponseType extends Record<string, any> = Record<string, any>,\n C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n> = {\n /** The chat model that can utilize OpenAI-style tool calling. */\n llm:\n | LanguageModelLike\n | ((\n state: ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"],\n runtime: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => Promise<LanguageModelLike> | LanguageModelLike);\n\n /** A list of tools or a ToolNode. */\n tools: ToolNode | (ServerTool | ClientTool)[];\n\n /**\n * @deprecated Use prompt instead.\n */\n messageModifier?: MessageModifier;\n\n /**\n * @deprecated Use prompt instead.\n */\n stateModifier?: StateModifier;\n\n /**\n * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.\n *\n * Can take a few different forms:\n *\n * - str: This is converted to a SystemMessage and added to the beginning of the list of messages in state[\"messages\"].\n * - SystemMessage: this is added to the beginning of the list of messages in state[\"messages\"].\n * - Function: This function should take in full graph state and the output is then passed to the language model.\n * - Runnable: This runnable should take in full graph state and the output is then passed to the language model.\n *\n * Note:\n * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.\n * This is now deprecated and will be removed in a future release.\n */\n prompt?: Prompt;\n\n /**\n * Additional state schema for the agent.\n */\n stateSchema?: A;\n\n /**\n * An optional schema for the context.\n */\n contextSchema?: C;\n /** An optional checkpoint saver to persist the agent's state. */\n checkpointSaver?: BaseCheckpointSaver | boolean;\n /** An optional checkpoint saver to persist the agent's state. Alias of \"checkpointSaver\". */\n checkpointer?: BaseCheckpointSaver | boolean;\n /** An optional list of node names to interrupt before running. */\n interruptBefore?: N[] | All;\n /** An optional list of node names to interrupt after running. */\n interruptAfter?: N[] | All;\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * - JSON schema\n * - { prompt, schema }, where schema is one of the above.\n * The prompt will be used together with the model that is being used to generate the structured response.\n *\n * @remarks\n * **Important**: `responseFormat` requires the model to support `.withStructuredOutput()`.\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?:\n | InteropZodType<StructuredResponseType>\n | StructuredResponseSchemaOptions<StructuredResponseType>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>;\n\n /**\n * An optional name for the agent.\n */\n name?: string;\n\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string | undefined;\n\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n\n - undefined: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n\n /**\n * An optional node to add before the `agent` node (i.e., the node that calls the LLM).\n * Useful for managing long message histories (e.g., message trimming, summarization, etc.).\n */\n preModelHook?: RunnableLike<\n ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"],\n ToAnnotationRoot<A>[\"Update\"] & PreHookAnnotation[\"Update\"],\n LangGraphRunnableConfig\n >;\n\n /**\n * An optional node to add after the `agent` node (i.e., the node that calls the LLM).\n * Useful for implementing human-in-the-loop, guardrails, validation, or other post-processing.\n */\n postModelHook?: RunnableLike<\n ToAnnotationRoot<A>[\"State\"],\n ToAnnotationRoot<A>[\"Update\"],\n LangGraphRunnableConfig\n >;\n\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: 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 * @default `\"v1\"`\n */\n version?: \"v1\" | \"v2\";\n};\n\n/**\n * @deprecated `createReactAgent` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { createAgent } from \"langchain\";`\n *\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { createReactAgent } from \"@langchain/langgraph/prebuilt\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createReactAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\nexport function createReactAgent<\n A extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateReactAgentParams<A, StructuredResponseFormat, C>\n): CompiledStateGraph<\n ToAnnotationRoot<A>[\"State\"],\n ToAnnotationRoot<A>[\"Update\"],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any,\n typeof MessagesAnnotation.spec & ToAnnotationRoot<A>[\"spec\"],\n ReturnType<\n typeof createReactAgentAnnotation<StructuredResponseFormat>\n >[\"spec\"] &\n ToAnnotationRoot<A>[\"spec\"]\n> {\n const {\n llm,\n tools,\n messageModifier,\n stateModifier,\n prompt,\n stateSchema,\n contextSchema,\n checkpointSaver,\n checkpointer,\n interruptBefore,\n interruptAfter,\n store,\n responseFormat,\n preModelHook,\n postModelHook,\n name,\n description,\n version = \"v1\",\n includeAgentName,\n } = params;\n\n let toolClasses: (ClientTool | ServerTool)[];\n\n let toolNode: ToolNode;\n if (!Array.isArray(tools)) {\n toolClasses = tools.tools;\n toolNode = tools;\n } else {\n toolClasses = tools;\n toolNode = new ToolNode(toolClasses.filter(isClientTool));\n }\n\n let cachedStaticModel: Runnable | null = null;\n\n const _getStaticModel = async (llm: LanguageModelLike): Promise<Runnable> => {\n if (cachedStaticModel) return cachedStaticModel;\n\n let modelWithTools: LanguageModelLike;\n if (await _shouldBindTools(llm, toolClasses)) {\n modelWithTools = await _bindTools(llm, toolClasses);\n } else {\n modelWithTools = llm;\n }\n\n const promptRunnable = _getPrompt(prompt, stateModifier, messageModifier);\n const modelRunnable =\n includeAgentName === \"inline\"\n ? withAgentName(modelWithTools, includeAgentName)\n : modelWithTools;\n\n cachedStaticModel = promptRunnable.pipe(modelRunnable);\n return cachedStaticModel;\n };\n\n const _getDynamicModel = async (\n llm: (\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n runtime: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => Promise<LanguageModelLike> | LanguageModelLike,\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n config: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => {\n const model = await llm(state, config);\n\n return _getPrompt(prompt, stateModifier, messageModifier).pipe(\n includeAgentName === \"inline\"\n ? withAgentName(model, includeAgentName)\n : model\n );\n };\n\n // If any of the tools are configured to return_directly after running,\n // our graph needs to check if these were called\n 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 function getModelInputState(\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"]\n ): Omit<AgentState<StructuredResponseFormat>, \"llmInputMessages\"> {\n const { messages, llmInputMessages, ...rest } = state;\n if (llmInputMessages != null && llmInputMessages.length > 0) {\n return { messages: llmInputMessages, ...rest };\n }\n return { messages, ...rest };\n }\n\n const generateStructuredResponse = async (\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n config: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => {\n if (responseFormat == null) {\n throw new Error(\n \"Attempted to generate structured output with no passed response schema. Please contact us for help.\"\n );\n }\n const messages = [...state.messages];\n let modelWithStructuredOutput;\n\n const model: LanguageModelLike =\n typeof llm === \"function\"\n ? await llm(state, config)\n : await _getModel(llm);\n\n if (!_isBaseChatModel(model)) {\n throw new Error(\n `Expected \\`llm\\` to be a ChatModel with .withStructuredOutput() method, got ${model.constructor.name}`\n );\n }\n\n if (typeof responseFormat === \"object\" && \"schema\" in responseFormat) {\n const { prompt, schema, ...options } =\n responseFormat as StructuredResponseSchemaOptions<StructuredResponseFormat>;\n\n modelWithStructuredOutput = model.withStructuredOutput(schema, options);\n if (prompt != null) {\n messages.unshift(new SystemMessage({ content: prompt }));\n }\n } else {\n modelWithStructuredOutput = model.withStructuredOutput(responseFormat);\n }\n\n const response = await modelWithStructuredOutput.invoke(messages, config);\n return { structuredResponse: response };\n };\n\n const callModel = async (\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n config: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => {\n // NOTE: we're dynamically creating the model runnable here\n // to ensure that we can validate ConfigurableModel properly\n const modelRunnable: Runnable =\n typeof llm === \"function\"\n ? await _getDynamicModel(llm, state, config)\n : await _getStaticModel(llm);\n\n // TODO: Auto-promote streaming.\n const response = (await modelRunnable.invoke(\n getModelInputState(state),\n config\n )) as BaseMessage;\n // add agent name to the AIMessage\n // TODO: figure out if we can avoid mutating the message directly\n response.name = name;\n response.lc_kwargs.name = name;\n return { messages: [response] };\n };\n\n const schema =\n stateSchema ?? createReactAgentAnnotation<StructuredResponseFormat>();\n\n const workflow = new StateGraph(\n schema as AnyAnnotationRoot,\n contextSchema\n ).addNode(\"tools\", toolNode);\n\n if (!(\"messages\" in workflow._schemaDefinition)) {\n throw new Error(\"Missing required `messages` key in state schema.\");\n }\n\n const allNodeWorkflows = workflow as WithStateGraphNodes<\n | \"pre_model_hook\"\n | \"post_model_hook\"\n | \"generate_structured_response\"\n | \"agent\",\n typeof workflow\n >;\n\n const conditionalMap = <T extends string>(map: Record<string, T | null>) => {\n return Object.fromEntries(\n Object.entries(map).filter(([_, v]) => v != null) as [string, T][]\n );\n };\n\n let entrypoint: \"agent\" | \"pre_model_hook\" = \"agent\";\n let inputSchema: AnnotationRoot<ToAnnotationRoot<A>[\"spec\"]> | undefined;\n if (preModelHook != null) {\n allNodeWorkflows\n .addNode(\"pre_model_hook\", preModelHook)\n .addEdge(\"pre_model_hook\", \"agent\");\n entrypoint = \"pre_model_hook\";\n\n inputSchema = Annotation.Root({\n ...workflow._schemaDefinition,\n ...PreHookAnnotation.spec,\n });\n } else {\n entrypoint = \"agent\";\n }\n\n allNodeWorkflows\n .addNode(\"agent\", callModel, { input: inputSchema })\n .addEdge(START, entrypoint);\n\n if (postModelHook != null) {\n allNodeWorkflows\n .addNode(\"post_model_hook\", postModelHook)\n .addEdge(\"agent\", \"post_model_hook\")\n .addConditionalEdges(\n \"post_model_hook\",\n (state: AgentState<StructuredResponseFormat>) => {\n const { messages } = state;\n\n const toolMessageIds: Set<string> = new Set(\n messages.filter(isToolMessage).map((msg) => msg.tool_call_id)\n );\n\n let lastAiMessage: AIMessage | undefined;\n for (let i = messages.length - 1; i >= 0; i -= 1) {\n const message = messages[i];\n if (isAIMessage(message)) {\n lastAiMessage = message;\n break;\n }\n }\n\n const pendingToolCalls =\n lastAiMessage?.tool_calls?.filter(\n (i) => i.id == null || !toolMessageIds.has(i.id)\n ) ?? [];\n\n const lastMessage = messages.at(-1);\n if (pendingToolCalls.length > 0) {\n if (version === \"v2\") {\n return pendingToolCalls.map(\n (toolCall) =>\n new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n }\n return \"tools\";\n }\n\n if (lastMessage && isToolMessage(lastMessage)) return entrypoint;\n if (responseFormat != null) return \"generate_structured_response\";\n return END;\n },\n conditionalMap({\n tools: \"tools\",\n [entrypoint]: entrypoint,\n generate_structured_response:\n responseFormat != null ? \"generate_structured_response\" : null,\n [END]: responseFormat != null ? null : END,\n })\n );\n }\n\n if (responseFormat !== undefined) {\n workflow\n .addNode(\"generate_structured_response\", generateStructuredResponse)\n .addEdge(\"generate_structured_response\", END);\n }\n\n if (postModelHook == null) {\n allNodeWorkflows.addConditionalEdges(\n \"agent\",\n (state: AgentState<StructuredResponseFormat>) => {\n const { messages } = state;\n const lastMessage = messages[messages.length - 1];\n\n // if there's no function call, we finish\n if (!isAIMessage(lastMessage) || !lastMessage.tool_calls?.length) {\n if (responseFormat != null) return \"generate_structured_response\";\n return END;\n }\n\n // there are function calls, we continue\n if (version === \"v2\") {\n return lastMessage.tool_calls.map(\n (toolCall) =>\n new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n }\n\n return \"tools\";\n },\n conditionalMap({\n tools: \"tools\",\n generate_structured_response:\n responseFormat != null ? \"generate_structured_response\" : null,\n [END]: responseFormat != null ? null : END,\n })\n );\n }\n\n if (shouldReturnDirect.size > 0) {\n allNodeWorkflows.addConditionalEdges(\n \"tools\",\n (state: AgentState<StructuredResponseFormat>) => {\n // Check the last consecutive tool calls\n for (let i = state.messages.length - 1; i >= 0; i -= 1) {\n const message = state.messages[i];\n if (!isToolMessage(message)) break;\n\n // Check if this tool is configured to return directly\n if (\n message.name !== undefined &&\n shouldReturnDirect.has(message.name)\n ) {\n return END;\n }\n }\n\n return entrypoint;\n },\n conditionalMap({ [entrypoint]: entrypoint, [END]: END })\n );\n } else {\n allNodeWorkflows.addEdge(\"tools\", entrypoint);\n }\n\n return allNodeWorkflows.compile({\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,UAAO;;AAGT,MAAI,eAAe,cAAc,aAAc,QAAO;AACtD,MAAI,kBAAkB,KAAM,QAAO;AACnC,SAAO;IAET,eAAe;EACb,OAAO;GACN,aAAa;EACd,8BACE,kBAAkB,OAAO,iCAAiC;GAC3D,MAAM,kBAAkB,OAAO,OAAO;;AAK/C,KAAI,mBAAmB,OACrB,UACG,QAAQ,gCAAgC,4BACxC,QAAQ,gCAAgC;AAG7C,KAAI,iBAAiB,KACnB,kBAAiB,oBACf,UACC,UAAgD;EAC/C,MAAM,EAAE,aAAa;EACrB,MAAM,cAAc,SAAS,SAAS,SAAS;AAG/C,MAAI,CAAC,YAAY,gBAAgB,CAAC,YAAY,YAAY,QAAQ;AAChE,OAAI,kBAAkB,KAAM,QAAO;AACnC,UAAO;;AAIT,MAAI,YAAY,KACd,QAAO,YAAY,WAAW,KAC3B,aACC,IAAI,KAAK,SAAS;GAAE,GAAG;GAAO,cAAc;;AAIlD,SAAO;IAET,eAAe;EACb,OAAO;EACP,8BACE,kBAAkB,OAAO,iCAAiC;GAC3D,MAAM,kBAAkB,OAAO,OAAO;;AAK7C,KAAI,mBAAmB,OAAO,EAC5B,kBAAiB,oBACf,UACC,UAAgD;AAE/C,OAAK,IAAI,IAAI,MAAM,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG;GACtD,MAAM,UAAU,MAAM,SAAS;AAC/B,OAAI,CAAC,cAAc,SAAU;AAG7B,OACE,QAAQ,SAAS,UACjB,mBAAmB,IAAI,QAAQ,MAE/B,QAAO;;AAIX,SAAO;IAET,eAAe;GAAG,aAAa;GAAa,MAAM;;KAGpD,kBAAiB,QAAQ,SAAS;AAGpC,QAAO,iBAAiB,QAAQ;EAC9B,cAAc,gBAAgB;EAC9B;EACA;EACA;EACA;EACA"}
@@ -1,70 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToolExecutor = void 0;
4
- const runnables_1 = require("@langchain/core/runnables");
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const __langchain_core_runnables = require_rolldown_runtime.__toESM(require("@langchain/core/runnables"));
3
+
4
+ //#region src/prebuilt/tool_executor.ts
5
5
  const INVALID_TOOL_MSG_TEMPLATE = `{requestedToolName} is not a valid tool, try one of {availableToolNamesString}.`;
6
6
  /** @deprecated Use {@link ToolNode} instead. */
7
- class ToolExecutor extends runnables_1.RunnableBinding {
8
- constructor(fields) {
9
- const fieldsWithDefaults = {
10
- invalidToolMsgTemplate: INVALID_TOOL_MSG_TEMPLATE,
11
- ...fields,
12
- };
13
- const bound = runnables_1.RunnableLambda.from(async (input, config) => this._execute(input, config));
14
- super({
15
- bound,
16
- config: {},
17
- });
18
- Object.defineProperty(this, "lc_graph_name", {
19
- enumerable: true,
20
- configurable: true,
21
- writable: true,
22
- value: "ToolExecutor"
23
- });
24
- Object.defineProperty(this, "tools", {
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- value: void 0
29
- });
30
- Object.defineProperty(this, "toolMap", {
31
- enumerable: true,
32
- configurable: true,
33
- writable: true,
34
- value: void 0
35
- });
36
- Object.defineProperty(this, "invalidToolMsgTemplate", {
37
- enumerable: true,
38
- configurable: true,
39
- writable: true,
40
- value: void 0
41
- });
42
- this.tools = fieldsWithDefaults.tools;
43
- this.invalidToolMsgTemplate = fieldsWithDefaults.invalidToolMsgTemplate;
44
- this.toolMap = this.tools.reduce((acc, tool) => {
45
- acc[tool.name] = tool;
46
- return acc;
47
- }, {});
48
- }
49
- /**
50
- * Execute a tool invocation
51
- *
52
- * @param {ToolInvocationInterface} toolInvocation The tool to invoke and the input to pass to it.
53
- * @param {RunnableConfig | undefined} config Optional configuration to pass to the tool when invoked.
54
- * @returns Either the result of the tool invocation (`string` or `ToolMessage`, set by the `ToolOutput` generic) or a string error message.
55
- */
56
- async _execute(toolInvocation, config) {
57
- if (!(toolInvocation.tool in this.toolMap)) {
58
- return this.invalidToolMsgTemplate
59
- .replace("{requestedToolName}", toolInvocation.tool)
60
- .replace("{availableToolNamesString}", Object.keys(this.toolMap).join(", "));
61
- }
62
- else {
63
- const tool = this.toolMap[toolInvocation.tool];
64
- const output = await tool.invoke(toolInvocation.toolInput, config);
65
- return output;
66
- }
67
- }
68
- }
7
+ var ToolExecutor = class extends __langchain_core_runnables.RunnableBinding {
8
+ lc_graph_name = "ToolExecutor";
9
+ tools;
10
+ toolMap;
11
+ invalidToolMsgTemplate;
12
+ constructor(fields) {
13
+ const fieldsWithDefaults = {
14
+ invalidToolMsgTemplate: INVALID_TOOL_MSG_TEMPLATE,
15
+ ...fields
16
+ };
17
+ const bound = __langchain_core_runnables.RunnableLambda.from(async (input, config) => this._execute(input, config));
18
+ super({
19
+ bound,
20
+ config: {}
21
+ });
22
+ this.tools = fieldsWithDefaults.tools;
23
+ this.invalidToolMsgTemplate = fieldsWithDefaults.invalidToolMsgTemplate;
24
+ this.toolMap = this.tools.reduce((acc, tool) => {
25
+ acc[tool.name] = tool;
26
+ return acc;
27
+ }, {});
28
+ }
29
+ /**
30
+ * Execute a tool invocation
31
+ *
32
+ * @param {ToolInvocationInterface} toolInvocation The tool to invoke and the input to pass to it.
33
+ * @param {RunnableConfig | undefined} config Optional configuration to pass to the tool when invoked.
34
+ * @returns Either the result of the tool invocation (`string` or `ToolMessage`, set by the `ToolOutput` generic) or a string error message.
35
+ */
36
+ async _execute(toolInvocation, config) {
37
+ if (!(toolInvocation.tool in this.toolMap)) return this.invalidToolMsgTemplate.replace("{requestedToolName}", toolInvocation.tool).replace("{availableToolNamesString}", Object.keys(this.toolMap).join(", "));
38
+ else {
39
+ const tool = this.toolMap[toolInvocation.tool];
40
+ const output = await tool.invoke(toolInvocation.toolInput, config);
41
+ return output;
42
+ }
43
+ }
44
+ };
45
+
46
+ //#endregion
69
47
  exports.ToolExecutor = ToolExecutor;
70
- //# sourceMappingURL=tool_executor.js.map
48
+ //# sourceMappingURL=tool_executor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool_executor.cjs","names":["RunnableBinding","RunnableLambda"],"sources":["../../src/prebuilt/tool_executor.ts"],"sourcesContent":["import {\n RunnableBinding,\n RunnableConfig,\n RunnableLambda,\n RunnableToolLike,\n} from \"@langchain/core/runnables\";\nimport { StructuredToolInterface } from \"@langchain/core/tools\";\n\nconst INVALID_TOOL_MSG_TEMPLATE = `{requestedToolName} is not a valid tool, try one of {availableToolNamesString}.`;\n\n/** @deprecated Use {@link ToolNode} instead. */\nexport interface ToolExecutorArgs {\n tools: Array<StructuredToolInterface | RunnableToolLike>;\n /**\n * @default {INVALID_TOOL_MSG_TEMPLATE}\n */\n invalidToolMsgTemplate?: string;\n}\n\n/**\n * Interface for invoking a tool\n */\nexport interface ToolInvocationInterface {\n tool: string;\n toolInput: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ToolExecutorInputType = any;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ToolExecutorOutputType = any;\n\n/** @deprecated Use {@link ToolNode} instead. */\nexport class ToolExecutor extends RunnableBinding<\n ToolExecutorInputType,\n ToolExecutorOutputType\n> {\n lc_graph_name = \"ToolExecutor\";\n\n tools: Array<StructuredToolInterface | RunnableToolLike>;\n\n toolMap: Record<string, StructuredToolInterface | RunnableToolLike>;\n\n invalidToolMsgTemplate: string;\n\n constructor(fields: ToolExecutorArgs) {\n const fieldsWithDefaults = {\n invalidToolMsgTemplate: INVALID_TOOL_MSG_TEMPLATE,\n ...fields,\n };\n const bound = RunnableLambda.from(\n async (input: ToolInvocationInterface, config?: RunnableConfig) =>\n this._execute(input, config)\n );\n super({\n bound,\n config: {},\n });\n this.tools = fieldsWithDefaults.tools;\n this.invalidToolMsgTemplate = fieldsWithDefaults.invalidToolMsgTemplate;\n this.toolMap = this.tools.reduce((acc, tool) => {\n acc[tool.name] = tool;\n return acc;\n }, {} as Record<string, StructuredToolInterface | RunnableToolLike>);\n }\n\n /**\n * Execute a tool invocation\n *\n * @param {ToolInvocationInterface} toolInvocation The tool to invoke and the input to pass to it.\n * @param {RunnableConfig | undefined} config Optional configuration to pass to the tool when invoked.\n * @returns Either the result of the tool invocation (`string` or `ToolMessage`, set by the `ToolOutput` generic) or a string error message.\n */\n async _execute(\n toolInvocation: ToolInvocationInterface,\n config?: RunnableConfig\n ): Promise<ToolExecutorOutputType> {\n if (!(toolInvocation.tool in this.toolMap)) {\n return this.invalidToolMsgTemplate\n .replace(\"{requestedToolName}\", toolInvocation.tool)\n .replace(\n \"{availableToolNamesString}\",\n Object.keys(this.toolMap).join(\", \")\n );\n } else {\n const tool = this.toolMap[toolInvocation.tool];\n const output = await tool.invoke(toolInvocation.toolInput, config);\n return output;\n }\n }\n}\n"],"mappings":";;;;AAQA,MAAM,4BAA4B;;AA0BlC,IAAa,eAAb,cAAkCA,2CAGhC;CACA,gBAAgB;CAEhB;CAEA;CAEA;CAEA,YAAY,QAA0B;EACpC,MAAM,qBAAqB;GACzB,wBAAwB;GACxB,GAAG;;EAEL,MAAM,QAAQC,0CAAe,KAC3B,OAAO,OAAgC,WACrC,KAAK,SAAS,OAAO;AAEzB,QAAM;GACJ;GACA,QAAQ;;AAEV,OAAK,QAAQ,mBAAmB;AAChC,OAAK,yBAAyB,mBAAmB;AACjD,OAAK,UAAU,KAAK,MAAM,QAAQ,KAAK,SAAS;AAC9C,OAAI,KAAK,QAAQ;AACjB,UAAO;KACN;;;;;;;;;CAUL,MAAM,SACJ,gBACA,QACiC;AACjC,MAAI,EAAE,eAAe,QAAQ,KAAK,SAChC,QAAO,KAAK,uBACT,QAAQ,uBAAuB,eAAe,MAC9C,QACC,8BACA,OAAO,KAAK,KAAK,SAAS,KAAK;OAE9B;GACL,MAAM,OAAO,KAAK,QAAQ,eAAe;GACzC,MAAM,SAAS,MAAM,KAAK,OAAO,eAAe,WAAW;AAC3D,UAAO"}
@@ -0,0 +1,42 @@
1
+ import { RunnableBinding, RunnableConfig, RunnableToolLike } from "@langchain/core/runnables";
2
+ import { StructuredToolInterface } from "@langchain/core/tools";
3
+
4
+ //#region src/prebuilt/tool_executor.d.ts
5
+ /** @deprecated Use {@link ToolNode} instead. */
6
+ interface ToolExecutorArgs {
7
+ tools: Array<StructuredToolInterface | RunnableToolLike>;
8
+ /**
9
+ * @default {INVALID_TOOL_MSG_TEMPLATE}
10
+ */
11
+ invalidToolMsgTemplate?: string;
12
+ }
13
+ /**
14
+ * Interface for invoking a tool
15
+ */
16
+ interface ToolInvocationInterface {
17
+ tool: string;
18
+ toolInput: string;
19
+ }
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ type ToolExecutorInputType = any;
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ type ToolExecutorOutputType = any;
24
+ /** @deprecated Use {@link ToolNode} instead. */
25
+ declare class ToolExecutor extends RunnableBinding<ToolExecutorInputType, ToolExecutorOutputType> {
26
+ lc_graph_name: string;
27
+ tools: Array<StructuredToolInterface | RunnableToolLike>;
28
+ toolMap: Record<string, StructuredToolInterface | RunnableToolLike>;
29
+ invalidToolMsgTemplate: string;
30
+ constructor(fields: ToolExecutorArgs);
31
+ /**
32
+ * Execute a tool invocation
33
+ *
34
+ * @param {ToolInvocationInterface} toolInvocation The tool to invoke and the input to pass to it.
35
+ * @param {RunnableConfig | undefined} config Optional configuration to pass to the tool when invoked.
36
+ * @returns Either the result of the tool invocation (`string` or `ToolMessage`, set by the `ToolOutput` generic) or a string error message.
37
+ */
38
+ _execute(toolInvocation: ToolInvocationInterface, config?: RunnableConfig): Promise<ToolExecutorOutputType>;
39
+ }
40
+ //#endregion
41
+ export { ToolExecutor, ToolExecutorArgs, ToolInvocationInterface };
42
+ //# sourceMappingURL=tool_executor.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool_executor.d.cts","names":["RunnableBinding","RunnableConfig","RunnableToolLike","StructuredToolInterface","ToolExecutorArgs","Array","ToolInvocationInterface","ToolExecutorInputType","ToolExecutorOutputType","ToolExecutor","Record","Promise"],"sources":["../../src/prebuilt/tool_executor.d.ts"],"sourcesContent":["import { RunnableBinding, RunnableConfig, RunnableToolLike } from \"@langchain/core/runnables\";\nimport { StructuredToolInterface } from \"@langchain/core/tools\";\n/** @deprecated Use {@link ToolNode} instead. */\nexport interface ToolExecutorArgs {\n tools: Array<StructuredToolInterface | RunnableToolLike>;\n /**\n * @default {INVALID_TOOL_MSG_TEMPLATE}\n */\n invalidToolMsgTemplate?: string;\n}\n/**\n * Interface for invoking a tool\n */\nexport interface ToolInvocationInterface {\n tool: string;\n toolInput: string;\n}\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ToolExecutorInputType = any;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ToolExecutorOutputType = any;\n/** @deprecated Use {@link ToolNode} instead. */\nexport declare class ToolExecutor extends RunnableBinding<ToolExecutorInputType, ToolExecutorOutputType> {\n lc_graph_name: string;\n tools: Array<StructuredToolInterface | RunnableToolLike>;\n toolMap: Record<string, StructuredToolInterface | RunnableToolLike>;\n invalidToolMsgTemplate: string;\n constructor(fields: ToolExecutorArgs);\n /**\n * Execute a tool invocation\n *\n * @param {ToolInvocationInterface} toolInvocation The tool to invoke and the input to pass to it.\n * @param {RunnableConfig | undefined} config Optional configuration to pass to the tool when invoked.\n * @returns Either the result of the tool invocation (`string` or `ToolMessage`, set by the `ToolOutput` generic) or a string error message.\n */\n _execute(toolInvocation: ToolInvocationInterface, config?: RunnableConfig): Promise<ToolExecutorOutputType>;\n}\nexport {};\n"],"mappings":";;;;;UAGiBI,gBAAAA;EAAAA,KAAAA,EACNC,KADMD,CACAD,uBADgB,GACUD,gBADV,CAAA;EAAA;;;wBACtBG,CAAAA,EAAAA,MAAAA;;AASX;AAGC;AAEyB;AAILI,UATJH,uBAAAA,CASgB;EAAA,IAAA,EAAA,MAAA;WAAyBC,EAAAA,MAAAA;;;KAJrDA,qBAAAA,GAMsCL,GAAAA;;KAJtCM,sBAAAA,GAKuBL,GAAAA;;AAAfO,cAHQD,YAAAA,SAAqBT,eAG7BU,CAH6CH,qBAG7CG,EAHoEF,sBAGpEE,CAAAA,CAAAA;eAEWN,EAAAA,MAAAA;OAQKE,EAXlBD,KAWkBC,CAXZH,uBAWYG,GAXcJ,gBAWdI,CAAAA;SAAkCL,EAVlDS,MAUkDT,CAAAA,MAAAA,EAVnCE,uBAUmCF,GAVTC,gBAUSD,CAAAA;wBAAyBO,EAAAA,MAAAA;aAARG,CAAAA,MAAAA,EARxDP,gBAQwDO;;;;;;;;2BAAnDL,kCAAkCL,iBAAiBU,QAAQH"}
@@ -1,36 +1,42 @@
1
1
  import { RunnableBinding, RunnableConfig, RunnableToolLike } from "@langchain/core/runnables";
2
2
  import { StructuredToolInterface } from "@langchain/core/tools";
3
+
4
+ //#region src/prebuilt/tool_executor.d.ts
3
5
  /** @deprecated Use {@link ToolNode} instead. */
4
- export interface ToolExecutorArgs {
5
- tools: Array<StructuredToolInterface | RunnableToolLike>;
6
- /**
7
- * @default {INVALID_TOOL_MSG_TEMPLATE}
8
- */
9
- invalidToolMsgTemplate?: string;
6
+ interface ToolExecutorArgs {
7
+ tools: Array<StructuredToolInterface | RunnableToolLike>;
8
+ /**
9
+ * @default {INVALID_TOOL_MSG_TEMPLATE}
10
+ */
11
+ invalidToolMsgTemplate?: string;
10
12
  }
11
13
  /**
12
14
  * Interface for invoking a tool
13
15
  */
14
- export interface ToolInvocationInterface {
15
- tool: string;
16
- toolInput: string;
16
+ interface ToolInvocationInterface {
17
+ tool: string;
18
+ toolInput: string;
17
19
  }
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
21
  type ToolExecutorInputType = any;
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
23
  type ToolExecutorOutputType = any;
20
24
  /** @deprecated Use {@link ToolNode} instead. */
21
- export declare class ToolExecutor extends RunnableBinding<ToolExecutorInputType, ToolExecutorOutputType> {
22
- lc_graph_name: string;
23
- tools: Array<StructuredToolInterface | RunnableToolLike>;
24
- toolMap: Record<string, StructuredToolInterface | RunnableToolLike>;
25
- invalidToolMsgTemplate: string;
26
- constructor(fields: ToolExecutorArgs);
27
- /**
28
- * Execute a tool invocation
29
- *
30
- * @param {ToolInvocationInterface} toolInvocation The tool to invoke and the input to pass to it.
31
- * @param {RunnableConfig | undefined} config Optional configuration to pass to the tool when invoked.
32
- * @returns Either the result of the tool invocation (`string` or `ToolMessage`, set by the `ToolOutput` generic) or a string error message.
33
- */
34
- _execute(toolInvocation: ToolInvocationInterface, config?: RunnableConfig): Promise<ToolExecutorOutputType>;
25
+ declare class ToolExecutor extends RunnableBinding<ToolExecutorInputType, ToolExecutorOutputType> {
26
+ lc_graph_name: string;
27
+ tools: Array<StructuredToolInterface | RunnableToolLike>;
28
+ toolMap: Record<string, StructuredToolInterface | RunnableToolLike>;
29
+ invalidToolMsgTemplate: string;
30
+ constructor(fields: ToolExecutorArgs);
31
+ /**
32
+ * Execute a tool invocation
33
+ *
34
+ * @param {ToolInvocationInterface} toolInvocation The tool to invoke and the input to pass to it.
35
+ * @param {RunnableConfig | undefined} config Optional configuration to pass to the tool when invoked.
36
+ * @returns Either the result of the tool invocation (`string` or `ToolMessage`, set by the `ToolOutput` generic) or a string error message.
37
+ */
38
+ _execute(toolInvocation: ToolInvocationInterface, config?: RunnableConfig): Promise<ToolExecutorOutputType>;
35
39
  }
36
- export {};
40
+ //#endregion
41
+ export { ToolExecutor, ToolExecutorArgs, ToolInvocationInterface };
42
+ //# sourceMappingURL=tool_executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool_executor.d.ts","names":["RunnableBinding","RunnableConfig","RunnableToolLike","StructuredToolInterface","ToolExecutorArgs","Array","ToolInvocationInterface","ToolExecutorInputType","ToolExecutorOutputType","ToolExecutor","Record","Promise"],"sources":["../../src/prebuilt/tool_executor.d.ts"],"sourcesContent":["import { RunnableBinding, RunnableConfig, RunnableToolLike } from \"@langchain/core/runnables\";\nimport { StructuredToolInterface } from \"@langchain/core/tools\";\n/** @deprecated Use {@link ToolNode} instead. */\nexport interface ToolExecutorArgs {\n tools: Array<StructuredToolInterface | RunnableToolLike>;\n /**\n * @default {INVALID_TOOL_MSG_TEMPLATE}\n */\n invalidToolMsgTemplate?: string;\n}\n/**\n * Interface for invoking a tool\n */\nexport interface ToolInvocationInterface {\n tool: string;\n toolInput: string;\n}\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ToolExecutorInputType = any;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ToolExecutorOutputType = any;\n/** @deprecated Use {@link ToolNode} instead. */\nexport declare class ToolExecutor extends RunnableBinding<ToolExecutorInputType, ToolExecutorOutputType> {\n lc_graph_name: string;\n tools: Array<StructuredToolInterface | RunnableToolLike>;\n toolMap: Record<string, StructuredToolInterface | RunnableToolLike>;\n invalidToolMsgTemplate: string;\n constructor(fields: ToolExecutorArgs);\n /**\n * Execute a tool invocation\n *\n * @param {ToolInvocationInterface} toolInvocation The tool to invoke and the input to pass to it.\n * @param {RunnableConfig | undefined} config Optional configuration to pass to the tool when invoked.\n * @returns Either the result of the tool invocation (`string` or `ToolMessage`, set by the `ToolOutput` generic) or a string error message.\n */\n _execute(toolInvocation: ToolInvocationInterface, config?: RunnableConfig): Promise<ToolExecutorOutputType>;\n}\nexport {};\n"],"mappings":";;;;;UAGiBI,gBAAAA;EAAAA,KAAAA,EACNC,KADMD,CACAD,uBADgB,GACUD,gBADV,CAAA;EAAA;;;wBACtBG,CAAAA,EAAAA,MAAAA;;AASX;AAGC;AAEyB;AAILI,UATJH,uBAAAA,CASgB;EAAA,IAAA,EAAA,MAAA;WAAyBC,EAAAA,MAAAA;;;KAJrDA,qBAAAA,GAMsCL,GAAAA;;KAJtCM,sBAAAA,GAKuBL,GAAAA;;AAAfO,cAHQD,YAAAA,SAAqBT,eAG7BU,CAH6CH,qBAG7CG,EAHoEF,sBAGpEE,CAAAA,CAAAA;eAEWN,EAAAA,MAAAA;OAQKE,EAXlBD,KAWkBC,CAXZH,uBAWYG,GAXcJ,gBAWdI,CAAAA;SAAkCL,EAVlDS,MAUkDT,CAAAA,MAAAA,EAVnCE,uBAUmCF,GAVTC,gBAUSD,CAAAA;wBAAyBO,EAAAA,MAAAA;aAARG,CAAAA,MAAAA,EARxDP,gBAQwDO;;;;;;;;2BAAnDL,kCAAkCL,iBAAiBU,QAAQH"}
@@ -1,66 +1,47 @@
1
- import { RunnableBinding, RunnableLambda, } from "@langchain/core/runnables";
1
+ import { RunnableBinding, RunnableLambda } from "@langchain/core/runnables";
2
+
3
+ //#region src/prebuilt/tool_executor.ts
2
4
  const INVALID_TOOL_MSG_TEMPLATE = `{requestedToolName} is not a valid tool, try one of {availableToolNamesString}.`;
3
5
  /** @deprecated Use {@link ToolNode} instead. */
4
- export class ToolExecutor extends RunnableBinding {
5
- constructor(fields) {
6
- const fieldsWithDefaults = {
7
- invalidToolMsgTemplate: INVALID_TOOL_MSG_TEMPLATE,
8
- ...fields,
9
- };
10
- const bound = RunnableLambda.from(async (input, config) => this._execute(input, config));
11
- super({
12
- bound,
13
- config: {},
14
- });
15
- Object.defineProperty(this, "lc_graph_name", {
16
- enumerable: true,
17
- configurable: true,
18
- writable: true,
19
- value: "ToolExecutor"
20
- });
21
- Object.defineProperty(this, "tools", {
22
- enumerable: true,
23
- configurable: true,
24
- writable: true,
25
- value: void 0
26
- });
27
- Object.defineProperty(this, "toolMap", {
28
- enumerable: true,
29
- configurable: true,
30
- writable: true,
31
- value: void 0
32
- });
33
- Object.defineProperty(this, "invalidToolMsgTemplate", {
34
- enumerable: true,
35
- configurable: true,
36
- writable: true,
37
- value: void 0
38
- });
39
- this.tools = fieldsWithDefaults.tools;
40
- this.invalidToolMsgTemplate = fieldsWithDefaults.invalidToolMsgTemplate;
41
- this.toolMap = this.tools.reduce((acc, tool) => {
42
- acc[tool.name] = tool;
43
- return acc;
44
- }, {});
45
- }
46
- /**
47
- * Execute a tool invocation
48
- *
49
- * @param {ToolInvocationInterface} toolInvocation The tool to invoke and the input to pass to it.
50
- * @param {RunnableConfig | undefined} config Optional configuration to pass to the tool when invoked.
51
- * @returns Either the result of the tool invocation (`string` or `ToolMessage`, set by the `ToolOutput` generic) or a string error message.
52
- */
53
- async _execute(toolInvocation, config) {
54
- if (!(toolInvocation.tool in this.toolMap)) {
55
- return this.invalidToolMsgTemplate
56
- .replace("{requestedToolName}", toolInvocation.tool)
57
- .replace("{availableToolNamesString}", Object.keys(this.toolMap).join(", "));
58
- }
59
- else {
60
- const tool = this.toolMap[toolInvocation.tool];
61
- const output = await tool.invoke(toolInvocation.toolInput, config);
62
- return output;
63
- }
64
- }
65
- }
6
+ var ToolExecutor = class extends RunnableBinding {
7
+ lc_graph_name = "ToolExecutor";
8
+ tools;
9
+ toolMap;
10
+ invalidToolMsgTemplate;
11
+ constructor(fields) {
12
+ const fieldsWithDefaults = {
13
+ invalidToolMsgTemplate: INVALID_TOOL_MSG_TEMPLATE,
14
+ ...fields
15
+ };
16
+ const bound = RunnableLambda.from(async (input, config) => this._execute(input, config));
17
+ super({
18
+ bound,
19
+ config: {}
20
+ });
21
+ this.tools = fieldsWithDefaults.tools;
22
+ this.invalidToolMsgTemplate = fieldsWithDefaults.invalidToolMsgTemplate;
23
+ this.toolMap = this.tools.reduce((acc, tool) => {
24
+ acc[tool.name] = tool;
25
+ return acc;
26
+ }, {});
27
+ }
28
+ /**
29
+ * Execute a tool invocation
30
+ *
31
+ * @param {ToolInvocationInterface} toolInvocation The tool to invoke and the input to pass to it.
32
+ * @param {RunnableConfig | undefined} config Optional configuration to pass to the tool when invoked.
33
+ * @returns Either the result of the tool invocation (`string` or `ToolMessage`, set by the `ToolOutput` generic) or a string error message.
34
+ */
35
+ async _execute(toolInvocation, config) {
36
+ if (!(toolInvocation.tool in this.toolMap)) return this.invalidToolMsgTemplate.replace("{requestedToolName}", toolInvocation.tool).replace("{availableToolNamesString}", Object.keys(this.toolMap).join(", "));
37
+ else {
38
+ const tool = this.toolMap[toolInvocation.tool];
39
+ const output = await tool.invoke(toolInvocation.toolInput, config);
40
+ return output;
41
+ }
42
+ }
43
+ };
44
+
45
+ //#endregion
46
+ export { ToolExecutor };
66
47
  //# sourceMappingURL=tool_executor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool_executor.js","sourceRoot":"","sources":["../../src/prebuilt/tool_executor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,cAAc,GAEf,MAAM,2BAA2B,CAAC;AAGnC,MAAM,yBAAyB,GAAG,iFAAiF,CAAC;AAyBpH,gDAAgD;AAChD,MAAM,OAAO,YAAa,SAAQ,eAGjC;IASC,YAAY,MAAwB;QAClC,MAAM,kBAAkB,GAAG;YACzB,sBAAsB,EAAE,yBAAyB;YACjD,GAAG,MAAM;SACV,CAAC;QACF,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAC/B,KAAK,EAAE,KAA8B,EAAE,MAAuB,EAAE,EAAE,CAChE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAC/B,CAAC;QACF,KAAK,CAAC;YACJ,KAAK;YACL,MAAM,EAAE,EAAE;SACX,CAAC,CAAC;QApBL;;;;mBAAgB,cAAc;WAAC;QAE/B;;;;;WAAyD;QAEzD;;;;;WAAoE;QAEpE;;;;;WAA+B;QAe7B,IAAI,CAAC,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC;QACtC,IAAI,CAAC,sBAAsB,GAAG,kBAAkB,CAAC,sBAAsB,CAAC;QACxE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YAC7C,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;YACtB,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAgE,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,CACZ,cAAuC,EACvC,MAAuB;QAEvB,IAAI,CAAC,CAAC,cAAc,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3C,OAAO,IAAI,CAAC,sBAAsB;iBAC/B,OAAO,CAAC,qBAAqB,EAAE,cAAc,CAAC,IAAI,CAAC;iBACnD,OAAO,CACN,4BAA4B,EAC5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CACrC,CAAC;QACN,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC/C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YACnE,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"tool_executor.js","names":[],"sources":["../../src/prebuilt/tool_executor.ts"],"sourcesContent":["import {\n RunnableBinding,\n RunnableConfig,\n RunnableLambda,\n RunnableToolLike,\n} from \"@langchain/core/runnables\";\nimport { StructuredToolInterface } from \"@langchain/core/tools\";\n\nconst INVALID_TOOL_MSG_TEMPLATE = `{requestedToolName} is not a valid tool, try one of {availableToolNamesString}.`;\n\n/** @deprecated Use {@link ToolNode} instead. */\nexport interface ToolExecutorArgs {\n tools: Array<StructuredToolInterface | RunnableToolLike>;\n /**\n * @default {INVALID_TOOL_MSG_TEMPLATE}\n */\n invalidToolMsgTemplate?: string;\n}\n\n/**\n * Interface for invoking a tool\n */\nexport interface ToolInvocationInterface {\n tool: string;\n toolInput: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ToolExecutorInputType = any;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ToolExecutorOutputType = any;\n\n/** @deprecated Use {@link ToolNode} instead. */\nexport class ToolExecutor extends RunnableBinding<\n ToolExecutorInputType,\n ToolExecutorOutputType\n> {\n lc_graph_name = \"ToolExecutor\";\n\n tools: Array<StructuredToolInterface | RunnableToolLike>;\n\n toolMap: Record<string, StructuredToolInterface | RunnableToolLike>;\n\n invalidToolMsgTemplate: string;\n\n constructor(fields: ToolExecutorArgs) {\n const fieldsWithDefaults = {\n invalidToolMsgTemplate: INVALID_TOOL_MSG_TEMPLATE,\n ...fields,\n };\n const bound = RunnableLambda.from(\n async (input: ToolInvocationInterface, config?: RunnableConfig) =>\n this._execute(input, config)\n );\n super({\n bound,\n config: {},\n });\n this.tools = fieldsWithDefaults.tools;\n this.invalidToolMsgTemplate = fieldsWithDefaults.invalidToolMsgTemplate;\n this.toolMap = this.tools.reduce((acc, tool) => {\n acc[tool.name] = tool;\n return acc;\n }, {} as Record<string, StructuredToolInterface | RunnableToolLike>);\n }\n\n /**\n * Execute a tool invocation\n *\n * @param {ToolInvocationInterface} toolInvocation The tool to invoke and the input to pass to it.\n * @param {RunnableConfig | undefined} config Optional configuration to pass to the tool when invoked.\n * @returns Either the result of the tool invocation (`string` or `ToolMessage`, set by the `ToolOutput` generic) or a string error message.\n */\n async _execute(\n toolInvocation: ToolInvocationInterface,\n config?: RunnableConfig\n ): Promise<ToolExecutorOutputType> {\n if (!(toolInvocation.tool in this.toolMap)) {\n return this.invalidToolMsgTemplate\n .replace(\"{requestedToolName}\", toolInvocation.tool)\n .replace(\n \"{availableToolNamesString}\",\n Object.keys(this.toolMap).join(\", \")\n );\n } else {\n const tool = this.toolMap[toolInvocation.tool];\n const output = await tool.invoke(toolInvocation.toolInput, config);\n return output;\n }\n }\n}\n"],"mappings":";;;AAQA,MAAM,4BAA4B;;AA0BlC,IAAa,eAAb,cAAkC,gBAGhC;CACA,gBAAgB;CAEhB;CAEA;CAEA;CAEA,YAAY,QAA0B;EACpC,MAAM,qBAAqB;GACzB,wBAAwB;GACxB,GAAG;;EAEL,MAAM,QAAQ,eAAe,KAC3B,OAAO,OAAgC,WACrC,KAAK,SAAS,OAAO;AAEzB,QAAM;GACJ;GACA,QAAQ;;AAEV,OAAK,QAAQ,mBAAmB;AAChC,OAAK,yBAAyB,mBAAmB;AACjD,OAAK,UAAU,KAAK,MAAM,QAAQ,KAAK,SAAS;AAC9C,OAAI,KAAK,QAAQ;AACjB,UAAO;KACN;;;;;;;;;CAUL,MAAM,SACJ,gBACA,QACiC;AACjC,MAAI,EAAE,eAAe,QAAQ,KAAK,SAChC,QAAO,KAAK,uBACT,QAAQ,uBAAuB,eAAe,MAC9C,QACC,8BACA,OAAO,KAAK,KAAK,SAAS,KAAK;OAE9B;GACL,MAAM,OAAO,KAAK,QAAQ,eAAe;GACzC,MAAM,SAAS,MAAM,KAAK,OAAO,eAAe,WAAW;AAC3D,UAAO"}