@langchain/langgraph 0.4.8 → 1.0.0-alpha.0

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 (494) hide show
  1. package/CHANGELOG.md +7 -2
  2. package/README.md +1 -2
  3. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  4. package/dist/channels/any_value.d.cts +26 -0
  5. package/dist/channels/any_value.d.cts.map +1 -0
  6. package/dist/channels/any_value.d.ts +16 -9
  7. package/dist/channels/any_value.d.ts.map +1 -0
  8. package/dist/channels/base.cjs +97 -133
  9. package/dist/channels/base.cjs.map +1 -0
  10. package/dist/channels/base.d.cts +73 -0
  11. package/dist/channels/base.d.cts.map +1 -0
  12. package/dist/channels/base.d.ts +73 -74
  13. package/dist/channels/base.d.ts.map +1 -0
  14. package/dist/channels/base.js +94 -127
  15. package/dist/channels/base.js.map +1 -1
  16. package/dist/channels/binop.cjs +47 -77
  17. package/dist/channels/binop.cjs.map +1 -0
  18. package/dist/channels/binop.d.cts +22 -0
  19. package/dist/channels/binop.d.cts.map +1 -0
  20. package/dist/channels/binop.d.ts +17 -12
  21. package/dist/channels/binop.d.ts.map +1 -0
  22. package/dist/channels/binop.js +45 -71
  23. package/dist/channels/binop.js.map +1 -1
  24. package/dist/channels/dynamic_barrier_value.d.cts +43 -0
  25. package/dist/channels/dynamic_barrier_value.d.cts.map +1 -0
  26. package/dist/channels/dynamic_barrier_value.d.ts +20 -34
  27. package/dist/channels/dynamic_barrier_value.d.ts.map +1 -0
  28. package/dist/channels/ephemeral_value.cjs +46 -70
  29. package/dist/channels/ephemeral_value.cjs.map +1 -0
  30. package/dist/channels/ephemeral_value.d.cts +23 -0
  31. package/dist/channels/ephemeral_value.d.cts.map +1 -0
  32. package/dist/channels/ephemeral_value.d.ts +18 -11
  33. package/dist/channels/ephemeral_value.d.ts.map +1 -0
  34. package/dist/channels/ephemeral_value.js +45 -65
  35. package/dist/channels/ephemeral_value.js.map +1 -1
  36. package/dist/channels/index.cjs +2 -10
  37. package/dist/channels/index.js +4 -3
  38. package/dist/channels/last_value.cjs +91 -140
  39. package/dist/channels/last_value.cjs.map +1 -0
  40. package/dist/channels/last_value.d.cts +30 -0
  41. package/dist/channels/last_value.d.cts.map +1 -0
  42. package/dist/channels/last_value.d.ts +15 -23
  43. package/dist/channels/last_value.d.ts.map +1 -0
  44. package/dist/channels/last_value.js +88 -133
  45. package/dist/channels/last_value.js.map +1 -1
  46. package/dist/channels/named_barrier_value.cjs +114 -170
  47. package/dist/channels/named_barrier_value.cjs.map +1 -0
  48. package/dist/channels/named_barrier_value.d.cts +33 -0
  49. package/dist/channels/named_barrier_value.d.cts.map +1 -0
  50. package/dist/channels/named_barrier_value.d.ts +19 -29
  51. package/dist/channels/named_barrier_value.d.ts.map +1 -0
  52. package/dist/channels/named_barrier_value.js +112 -163
  53. package/dist/channels/named_barrier_value.js.map +1 -1
  54. package/dist/channels/topic.cjs +63 -96
  55. package/dist/channels/topic.cjs.map +1 -0
  56. package/dist/channels/topic.d.cts +26 -0
  57. package/dist/channels/topic.d.cts.map +1 -0
  58. package/dist/channels/topic.d.ts +21 -18
  59. package/dist/channels/topic.d.ts.map +1 -0
  60. package/dist/channels/topic.js +61 -90
  61. package/dist/channels/topic.js.map +1 -1
  62. package/dist/constants.cjs +373 -452
  63. package/dist/constants.cjs.map +1 -0
  64. package/dist/constants.d.cts +284 -0
  65. package/dist/constants.d.cts.map +1 -0
  66. package/dist/constants.d.ts +112 -148
  67. package/dist/constants.d.ts.map +1 -0
  68. package/dist/constants.js +333 -444
  69. package/dist/constants.js.map +1 -1
  70. package/dist/errors.cjs +150 -179
  71. package/dist/errors.cjs.map +1 -0
  72. package/dist/errors.d.cts +80 -0
  73. package/dist/errors.d.cts.map +1 -0
  74. package/dist/errors.d.ts +55 -46
  75. package/dist/errors.d.ts.map +1 -0
  76. package/dist/errors.js +139 -165
  77. package/dist/errors.js.map +1 -1
  78. package/dist/func/index.cjs +289 -290
  79. package/dist/func/index.cjs.map +1 -0
  80. package/dist/func/index.d.cts +289 -0
  81. package/dist/func/index.d.cts.map +1 -0
  82. package/dist/func/index.d.ts +81 -71
  83. package/dist/func/index.d.ts.map +1 -0
  84. package/dist/func/index.js +285 -284
  85. package/dist/func/index.js.map +1 -1
  86. package/dist/func/types.d.cts +64 -0
  87. package/dist/func/types.d.cts.map +1 -0
  88. package/dist/func/types.d.ts +24 -19
  89. package/dist/func/types.d.ts.map +1 -0
  90. package/dist/graph/annotation.cjs +96 -120
  91. package/dist/graph/annotation.cjs.map +1 -0
  92. package/dist/graph/annotation.d.cts +116 -0
  93. package/dist/graph/annotation.d.cts.map +1 -0
  94. package/dist/graph/annotation.d.ts +33 -34
  95. package/dist/graph/annotation.d.ts.map +1 -0
  96. package/dist/graph/annotation.js +91 -112
  97. package/dist/graph/annotation.js.map +1 -1
  98. package/dist/graph/graph.cjs +419 -723
  99. package/dist/graph/graph.cjs.map +1 -0
  100. package/dist/graph/graph.d.cts +131 -0
  101. package/dist/graph/graph.d.cts.map +1 -0
  102. package/dist/graph/graph.d.ts +122 -91
  103. package/dist/graph/graph.d.ts.map +1 -0
  104. package/dist/graph/graph.js +412 -713
  105. package/dist/graph/graph.js.map +1 -1
  106. package/dist/graph/index.cjs +4 -17
  107. package/dist/graph/index.js +6 -5
  108. package/dist/graph/message.cjs +59 -104
  109. package/dist/graph/message.cjs.map +1 -0
  110. package/dist/graph/message.d.cts +19 -0
  111. package/dist/graph/message.d.cts.map +1 -0
  112. package/dist/graph/message.d.ts +11 -10
  113. package/dist/graph/message.d.ts.map +1 -0
  114. package/dist/graph/message.js +56 -98
  115. package/dist/graph/message.js.map +1 -1
  116. package/dist/graph/messages_annotation.cjs +106 -106
  117. package/dist/graph/messages_annotation.cjs.map +1 -0
  118. package/dist/graph/messages_annotation.d.cts +111 -0
  119. package/dist/graph/messages_annotation.d.cts.map +1 -0
  120. package/dist/graph/messages_annotation.d.ts +18 -9
  121. package/dist/graph/messages_annotation.d.ts.map +1 -0
  122. package/dist/graph/messages_annotation.js +100 -100
  123. package/dist/graph/messages_annotation.js.map +1 -1
  124. package/dist/graph/state.cjs +476 -777
  125. package/dist/graph/state.cjs.map +1 -0
  126. package/dist/graph/state.d.cts +216 -0
  127. package/dist/graph/state.d.cts.map +1 -0
  128. package/dist/graph/state.d.ts +129 -134
  129. package/dist/graph/state.d.ts.map +1 -0
  130. package/dist/graph/state.js +470 -768
  131. package/dist/graph/state.js.map +1 -1
  132. package/dist/graph/zod/index.cjs +10 -21
  133. package/dist/graph/zod/index.d.cts +3 -0
  134. package/dist/graph/zod/index.d.ts +3 -3
  135. package/dist/graph/zod/index.js +4 -4
  136. package/dist/graph/zod/meta.cjs +142 -177
  137. package/dist/graph/zod/meta.cjs.map +1 -0
  138. package/dist/graph/zod/meta.d.cts +116 -0
  139. package/dist/graph/zod/meta.d.cts.map +1 -0
  140. package/dist/graph/zod/meta.d.ts +99 -97
  141. package/dist/graph/zod/meta.d.ts.map +1 -0
  142. package/dist/graph/zod/meta.js +136 -170
  143. package/dist/graph/zod/meta.js.map +1 -1
  144. package/dist/graph/zod/plugin.cjs +36 -39
  145. package/dist/graph/zod/plugin.cjs.map +1 -0
  146. package/dist/graph/zod/plugin.js +34 -35
  147. package/dist/graph/zod/plugin.js.map +1 -1
  148. package/dist/graph/zod/schema.cjs +82 -110
  149. package/dist/graph/zod/schema.cjs.map +1 -0
  150. package/dist/graph/zod/schema.d.cts +38 -0
  151. package/dist/graph/zod/schema.d.cts.map +1 -0
  152. package/dist/graph/zod/schema.d.ts +12 -6
  153. package/dist/graph/zod/schema.d.ts.map +1 -0
  154. package/dist/graph/zod/schema.js +77 -103
  155. package/dist/graph/zod/schema.js.map +1 -1
  156. package/dist/graph/zod/zod-registry.cjs +41 -47
  157. package/dist/graph/zod/zod-registry.cjs.map +1 -0
  158. package/dist/graph/zod/zod-registry.d.cts +51 -0
  159. package/dist/graph/zod/zod-registry.d.cts.map +1 -0
  160. package/dist/graph/zod/zod-registry.d.ts +34 -26
  161. package/dist/graph/zod/zod-registry.d.ts.map +1 -0
  162. package/dist/graph/zod/zod-registry.js +37 -41
  163. package/dist/graph/zod/zod-registry.js.map +1 -1
  164. package/dist/hash.cjs +205 -267
  165. package/dist/hash.cjs.map +1 -0
  166. package/dist/hash.js +205 -265
  167. package/dist/hash.js.map +1 -1
  168. package/dist/index.cjs +110 -33
  169. package/dist/index.cjs.map +1 -0
  170. package/dist/index.d.cts +25 -0
  171. package/dist/index.d.ts +25 -5
  172. package/dist/index.js +18 -7
  173. package/dist/index.js.map +1 -1
  174. package/dist/interrupt.cjs +79 -85
  175. package/dist/interrupt.cjs.map +1 -0
  176. package/dist/interrupt.d.cts +49 -0
  177. package/dist/interrupt.d.cts.map +1 -0
  178. package/dist/interrupt.d.ts +6 -1
  179. package/dist/interrupt.d.ts.map +1 -0
  180. package/dist/interrupt.js +76 -80
  181. package/dist/interrupt.js.map +1 -1
  182. package/dist/prebuilt/agentName.cjs +139 -172
  183. package/dist/prebuilt/agentName.cjs.map +1 -0
  184. package/dist/prebuilt/agentName.d.cts +42 -0
  185. package/dist/prebuilt/agentName.d.cts.map +1 -0
  186. package/dist/prebuilt/agentName.d.ts +13 -21
  187. package/dist/prebuilt/agentName.d.ts.map +1 -0
  188. package/dist/prebuilt/agentName.js +139 -168
  189. package/dist/prebuilt/agentName.js.map +1 -1
  190. package/dist/prebuilt/agent_executor.cjs +42 -80
  191. package/dist/prebuilt/agent_executor.cjs.map +1 -0
  192. package/dist/prebuilt/agent_executor.d.cts +57 -0
  193. package/dist/prebuilt/agent_executor.d.cts.map +1 -0
  194. package/dist/prebuilt/agent_executor.d.ts +46 -37
  195. package/dist/prebuilt/agent_executor.d.ts.map +1 -0
  196. package/dist/prebuilt/agent_executor.js +40 -75
  197. package/dist/prebuilt/agent_executor.js.map +1 -1
  198. package/dist/prebuilt/chat_agent_executor.cjs +66 -128
  199. package/dist/prebuilt/chat_agent_executor.cjs.map +1 -0
  200. package/dist/prebuilt/chat_agent_executor.d.cts +23 -0
  201. package/dist/prebuilt/chat_agent_executor.d.cts.map +1 -0
  202. package/dist/prebuilt/chat_agent_executor.d.ts +18 -10
  203. package/dist/prebuilt/chat_agent_executor.d.ts.map +1 -0
  204. package/dist/prebuilt/chat_agent_executor.js +63 -123
  205. package/dist/prebuilt/chat_agent_executor.js.map +1 -1
  206. package/dist/prebuilt/index.cjs +15 -18
  207. package/dist/prebuilt/index.d.cts +8 -0
  208. package/dist/prebuilt/index.d.ts +8 -8
  209. package/dist/prebuilt/index.js +8 -7
  210. package/dist/prebuilt/interrupt.d.cts +73 -0
  211. package/dist/prebuilt/interrupt.d.cts.map +1 -0
  212. package/dist/prebuilt/interrupt.d.ts +32 -15
  213. package/dist/prebuilt/interrupt.d.ts.map +1 -0
  214. package/dist/prebuilt/react_agent_executor.cjs +317 -473
  215. package/dist/prebuilt/react_agent_executor.cjs.map +1 -0
  216. package/dist/prebuilt/react_agent_executor.d.cts +229 -0
  217. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -0
  218. package/dist/prebuilt/react_agent_executor.d.ts +171 -143
  219. package/dist/prebuilt/react_agent_executor.d.ts.map +1 -0
  220. package/dist/prebuilt/react_agent_executor.js +315 -465
  221. package/dist/prebuilt/react_agent_executor.js.map +1 -1
  222. package/dist/prebuilt/tool_executor.cjs +45 -67
  223. package/dist/prebuilt/tool_executor.cjs.map +1 -0
  224. package/dist/prebuilt/tool_executor.d.cts +42 -0
  225. package/dist/prebuilt/tool_executor.d.cts.map +1 -0
  226. package/dist/prebuilt/tool_executor.d.ts +30 -24
  227. package/dist/prebuilt/tool_executor.d.ts.map +1 -0
  228. package/dist/prebuilt/tool_executor.js +44 -63
  229. package/dist/prebuilt/tool_executor.js.map +1 -1
  230. package/dist/prebuilt/tool_node.cjs +213 -275
  231. package/dist/prebuilt/tool_node.cjs.map +1 -0
  232. package/dist/prebuilt/tool_node.d.cts +151 -0
  233. package/dist/prebuilt/tool_node.d.cts.map +1 -0
  234. package/dist/prebuilt/tool_node.d.ts +30 -17
  235. package/dist/prebuilt/tool_node.d.ts.map +1 -0
  236. package/dist/prebuilt/tool_node.js +209 -268
  237. package/dist/prebuilt/tool_node.js.map +1 -1
  238. package/dist/pregel/algo.cjs +521 -692
  239. package/dist/pregel/algo.cjs.map +1 -0
  240. package/dist/pregel/algo.d.cts +13 -0
  241. package/dist/pregel/algo.d.cts.map +1 -0
  242. package/dist/pregel/algo.d.ts +8 -38
  243. package/dist/pregel/algo.d.ts.map +1 -0
  244. package/dist/pregel/algo.js +516 -683
  245. package/dist/pregel/algo.js.map +1 -1
  246. package/dist/pregel/call.cjs +46 -42
  247. package/dist/pregel/call.cjs.map +1 -0
  248. package/dist/pregel/call.js +43 -37
  249. package/dist/pregel/call.js.map +1 -1
  250. package/dist/pregel/debug.cjs +153 -223
  251. package/dist/pregel/debug.cjs.map +1 -0
  252. package/dist/pregel/debug.js +152 -215
  253. package/dist/pregel/debug.js.map +1 -1
  254. package/dist/pregel/index.cjs +1134 -1604
  255. package/dist/pregel/index.cjs.map +1 -0
  256. package/dist/pregel/index.d.cts +534 -0
  257. package/dist/pregel/index.d.cts.map +1 -0
  258. package/dist/pregel/index.d.ts +458 -422
  259. package/dist/pregel/index.d.ts.map +1 -0
  260. package/dist/pregel/index.js +1125 -1592
  261. package/dist/pregel/index.js.map +1 -1
  262. package/dist/pregel/io.cjs +127 -234
  263. package/dist/pregel/io.cjs.map +1 -0
  264. package/dist/pregel/io.js +122 -225
  265. package/dist/pregel/io.js.map +1 -1
  266. package/dist/pregel/loop.cjs +539 -954
  267. package/dist/pregel/loop.cjs.map +1 -0
  268. package/dist/pregel/loop.js +536 -948
  269. package/dist/pregel/loop.js.map +1 -1
  270. package/dist/pregel/messages.cjs +104 -196
  271. package/dist/pregel/messages.cjs.map +1 -0
  272. package/dist/pregel/messages.js +102 -191
  273. package/dist/pregel/messages.js.map +1 -1
  274. package/dist/pregel/read.cjs +150 -280
  275. package/dist/pregel/read.cjs.map +1 -0
  276. package/dist/pregel/read.d.cts +51 -0
  277. package/dist/pregel/read.d.cts.map +1 -0
  278. package/dist/pregel/read.d.ts +48 -46
  279. package/dist/pregel/read.d.ts.map +1 -0
  280. package/dist/pregel/read.js +147 -274
  281. package/dist/pregel/read.js.map +1 -1
  282. package/dist/pregel/remote.cjs +339 -458
  283. package/dist/pregel/remote.cjs.map +1 -0
  284. package/dist/pregel/remote.d.cts +121 -0
  285. package/dist/pregel/remote.d.cts.map +1 -0
  286. package/dist/pregel/remote.d.ts +79 -69
  287. package/dist/pregel/remote.d.ts.map +1 -0
  288. package/dist/pregel/remote.js +337 -453
  289. package/dist/pregel/remote.js.map +1 -1
  290. package/dist/pregel/retry.cjs +87 -138
  291. package/dist/pregel/retry.cjs.map +1 -0
  292. package/dist/pregel/retry.js +83 -130
  293. package/dist/pregel/retry.js.map +1 -1
  294. package/dist/pregel/runnable_types.d.cts +25 -0
  295. package/dist/pregel/runnable_types.d.cts.map +1 -0
  296. package/dist/pregel/runnable_types.d.ts +22 -16
  297. package/dist/pregel/runnable_types.d.ts.map +1 -0
  298. package/dist/pregel/runner.cjs +222 -315
  299. package/dist/pregel/runner.cjs.map +1 -0
  300. package/dist/pregel/runner.js +219 -308
  301. package/dist/pregel/runner.js.map +1 -1
  302. package/dist/pregel/stream.cjs +89 -130
  303. package/dist/pregel/stream.cjs.map +1 -0
  304. package/dist/pregel/stream.js +87 -125
  305. package/dist/pregel/stream.js.map +1 -1
  306. package/dist/pregel/types.cjs +25 -62
  307. package/dist/pregel/types.cjs.map +1 -0
  308. package/dist/pregel/types.d.cts +437 -0
  309. package/dist/pregel/types.d.cts.map +1 -0
  310. package/dist/pregel/types.d.ts +377 -431
  311. package/dist/pregel/types.d.ts.map +1 -0
  312. package/dist/pregel/types.js +23 -57
  313. package/dist/pregel/types.js.map +1 -1
  314. package/dist/pregel/utils/config.cjs +100 -147
  315. package/dist/pregel/utils/config.cjs.map +1 -0
  316. package/dist/pregel/utils/config.d.cts +36 -0
  317. package/dist/pregel/utils/config.d.cts.map +1 -0
  318. package/dist/pregel/utils/config.d.ts +12 -9
  319. package/dist/pregel/utils/config.d.ts.map +1 -0
  320. package/dist/pregel/utils/config.js +98 -143
  321. package/dist/pregel/utils/config.js.map +1 -1
  322. package/dist/pregel/utils/index.cjs +87 -125
  323. package/dist/pregel/utils/index.cjs.map +1 -0
  324. package/dist/pregel/utils/index.d.cts +51 -0
  325. package/dist/pregel/utils/index.d.cts.map +1 -0
  326. package/dist/pregel/utils/index.d.ts +45 -61
  327. package/dist/pregel/utils/index.d.ts.map +1 -0
  328. package/dist/pregel/utils/index.js +86 -120
  329. package/dist/pregel/utils/index.js.map +1 -1
  330. package/dist/pregel/utils/subgraph.cjs +15 -26
  331. package/dist/pregel/utils/subgraph.cjs.map +1 -0
  332. package/dist/pregel/utils/subgraph.js +12 -21
  333. package/dist/pregel/utils/subgraph.js.map +1 -1
  334. package/dist/pregel/validate.cjs +42 -92
  335. package/dist/pregel/validate.cjs.map +1 -0
  336. package/dist/pregel/validate.js +39 -84
  337. package/dist/pregel/validate.js.map +1 -1
  338. package/dist/pregel/write.cjs +87 -137
  339. package/dist/pregel/write.cjs.map +1 -0
  340. package/dist/pregel/write.d.cts +35 -0
  341. package/dist/pregel/write.d.cts.map +1 -0
  342. package/dist/pregel/write.d.ts +27 -23
  343. package/dist/pregel/write.d.ts.map +1 -0
  344. package/dist/pregel/write.js +83 -131
  345. package/dist/pregel/write.js.map +1 -1
  346. package/dist/remote.cjs +3 -6
  347. package/dist/remote.d.cts +2 -0
  348. package/dist/remote.d.ts +2 -1
  349. package/dist/remote.js +3 -2
  350. package/dist/setup/async_local_storage.cjs +10 -7
  351. package/dist/setup/async_local_storage.cjs.map +1 -0
  352. package/dist/setup/async_local_storage.js +7 -2
  353. package/dist/setup/async_local_storage.js.map +1 -1
  354. package/dist/ui/index.cjs +4 -0
  355. package/dist/ui/index.d.cts +5 -0
  356. package/dist/ui/index.d.ts +5 -0
  357. package/dist/ui/index.js +3 -0
  358. package/dist/ui/stream.cjs +145 -0
  359. package/dist/ui/stream.cjs.map +1 -0
  360. package/dist/ui/stream.d.cts +25 -0
  361. package/dist/ui/stream.d.cts.map +1 -0
  362. package/dist/ui/stream.d.ts +25 -0
  363. package/dist/ui/stream.d.ts.map +1 -0
  364. package/dist/ui/stream.js +143 -0
  365. package/dist/ui/stream.js.map +1 -0
  366. package/dist/ui/types.infer.d.cts +53 -0
  367. package/dist/ui/types.infer.d.cts.map +1 -0
  368. package/dist/ui/types.infer.d.ts +53 -0
  369. package/dist/ui/types.infer.d.ts.map +1 -0
  370. package/dist/ui/types.message.d.cts +95 -0
  371. package/dist/ui/types.message.d.cts.map +1 -0
  372. package/dist/ui/types.message.d.ts +95 -0
  373. package/dist/ui/types.message.d.ts.map +1 -0
  374. package/dist/ui/types.schema.d.cts +228 -0
  375. package/dist/ui/types.schema.d.cts.map +1 -0
  376. package/dist/ui/types.schema.d.ts +228 -0
  377. package/dist/ui/types.schema.d.ts.map +1 -0
  378. package/dist/utils.cjs +77 -147
  379. package/dist/utils.cjs.map +1 -0
  380. package/dist/utils.d.cts +32 -0
  381. package/dist/utils.d.cts.map +1 -0
  382. package/dist/utils.d.ts +29 -25
  383. package/dist/utils.d.ts.map +1 -0
  384. package/dist/utils.js +73 -140
  385. package/dist/utils.js.map +1 -1
  386. package/dist/web.cjs +97 -55
  387. package/dist/web.d.cts +23 -0
  388. package/dist/web.d.ts +23 -14
  389. package/dist/web.js +15 -8
  390. package/package.json +83 -86
  391. package/dist/channels/any_value.cjs +0 -65
  392. package/dist/channels/any_value.js +0 -61
  393. package/dist/channels/any_value.js.map +0 -1
  394. package/dist/channels/dynamic_barrier_value.cjs +0 -212
  395. package/dist/channels/dynamic_barrier_value.js +0 -207
  396. package/dist/channels/dynamic_barrier_value.js.map +0 -1
  397. package/dist/channels/index.d.ts +0 -7
  398. package/dist/channels/index.js.map +0 -1
  399. package/dist/func/types.cjs +0 -15
  400. package/dist/func/types.js +0 -12
  401. package/dist/func/types.js.map +0 -1
  402. package/dist/graph/index.d.ts +0 -4
  403. package/dist/graph/index.js.map +0 -1
  404. package/dist/graph/message.test.cjs +0 -196
  405. package/dist/graph/message.test.d.ts +0 -1
  406. package/dist/graph/message.test.js +0 -194
  407. package/dist/graph/message.test.js.map +0 -1
  408. package/dist/graph/zod/index.js.map +0 -1
  409. package/dist/graph/zod/plugin.d.ts +0 -28
  410. package/dist/hash.d.ts +0 -2
  411. package/dist/prebuilt/index.js.map +0 -1
  412. package/dist/prebuilt/interrupt.cjs +0 -3
  413. package/dist/prebuilt/interrupt.js +0 -2
  414. package/dist/prebuilt/interrupt.js.map +0 -1
  415. package/dist/pregel/call.d.ts +0 -16
  416. package/dist/pregel/debug.d.ts +0 -41
  417. package/dist/pregel/debug.test.cjs +0 -258
  418. package/dist/pregel/debug.test.d.ts +0 -1
  419. package/dist/pregel/debug.test.js +0 -256
  420. package/dist/pregel/debug.test.js.map +0 -1
  421. package/dist/pregel/io.d.ts +0 -30
  422. package/dist/pregel/io.mapCommand.test.cjs +0 -150
  423. package/dist/pregel/io.mapCommand.test.d.ts +0 -1
  424. package/dist/pregel/io.mapCommand.test.js +0 -148
  425. package/dist/pregel/io.mapCommand.test.js.map +0 -1
  426. package/dist/pregel/loop.d.ts +0 -147
  427. package/dist/pregel/messages.d.ts +0 -30
  428. package/dist/pregel/messages.test.cjs +0 -369
  429. package/dist/pregel/messages.test.d.ts +0 -1
  430. package/dist/pregel/messages.test.js +0 -367
  431. package/dist/pregel/messages.test.js.map +0 -1
  432. package/dist/pregel/read.test.cjs +0 -194
  433. package/dist/pregel/read.test.d.ts +0 -1
  434. package/dist/pregel/read.test.js +0 -192
  435. package/dist/pregel/read.test.js.map +0 -1
  436. package/dist/pregel/retry.d.ts +0 -17
  437. package/dist/pregel/runnable_types.cjs +0 -3
  438. package/dist/pregel/runnable_types.js +0 -2
  439. package/dist/pregel/runnable_types.js.map +0 -1
  440. package/dist/pregel/runner.d.ts +0 -79
  441. package/dist/pregel/runner.test.cjs +0 -66
  442. package/dist/pregel/runner.test.d.ts +0 -1
  443. package/dist/pregel/runner.test.js +0 -64
  444. package/dist/pregel/runner.test.js.map +0 -1
  445. package/dist/pregel/stream.d.ts +0 -40
  446. package/dist/pregel/utils/config.test.cjs +0 -214
  447. package/dist/pregel/utils/config.test.d.ts +0 -1
  448. package/dist/pregel/utils/config.test.js +0 -212
  449. package/dist/pregel/utils/config.test.js.map +0 -1
  450. package/dist/pregel/utils/subgraph.d.ts +0 -4
  451. package/dist/pregel/utils/subgraph.test.cjs +0 -83
  452. package/dist/pregel/utils/subgraph.test.d.ts +0 -1
  453. package/dist/pregel/utils/subgraph.test.js +0 -81
  454. package/dist/pregel/utils/subgraph.test.js.map +0 -1
  455. package/dist/pregel/validate.d.ts +0 -16
  456. package/dist/pregel/validate.test.cjs +0 -220
  457. package/dist/pregel/validate.test.d.ts +0 -1
  458. package/dist/pregel/validate.test.js +0 -218
  459. package/dist/pregel/validate.test.js.map +0 -1
  460. package/dist/pregel/write.test.cjs +0 -181
  461. package/dist/pregel/write.test.d.ts +0 -1
  462. package/dist/pregel/write.test.js +0 -179
  463. package/dist/pregel/write.test.js.map +0 -1
  464. package/dist/remote.js.map +0 -1
  465. package/dist/setup/async_local_storage.d.ts +0 -1
  466. package/dist/web.js.map +0 -1
  467. package/index.cjs +0 -1
  468. package/index.d.cts +0 -1
  469. package/index.d.ts +0 -1
  470. package/index.js +0 -1
  471. package/prebuilt.cjs +0 -1
  472. package/prebuilt.d.cts +0 -1
  473. package/prebuilt.d.ts +0 -1
  474. package/prebuilt.js +0 -1
  475. package/pregel.cjs +0 -1
  476. package/pregel.d.cts +0 -1
  477. package/pregel.d.ts +0 -1
  478. package/pregel.js +0 -1
  479. package/remote.cjs +0 -1
  480. package/remote.d.cts +0 -1
  481. package/remote.d.ts +0 -1
  482. package/remote.js +0 -1
  483. package/web.cjs +0 -1
  484. package/web.d.cts +0 -1
  485. package/web.d.ts +0 -1
  486. package/web.js +0 -1
  487. package/zod/schema.cjs +0 -1
  488. package/zod/schema.d.cts +0 -1
  489. package/zod/schema.d.ts +0 -1
  490. package/zod/schema.js +0 -1
  491. package/zod.cjs +0 -1
  492. package/zod.d.cts +0 -1
  493. package/zod.d.ts +0 -1
  494. package/zod.js +0 -1
@@ -1,714 +1,543 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.increment = void 0;
4
- exports.shouldInterrupt = shouldInterrupt;
5
- exports._localRead = _localRead;
6
- exports._localWrite = _localWrite;
7
- exports._applyWrites = _applyWrites;
8
- exports._prepareNextTasks = _prepareNextTasks;
9
- exports._prepareSingleTask = _prepareSingleTask;
10
- /* eslint-disable no-param-reassign */
11
- const runnables_1 = require("@langchain/core/runnables");
12
- const langgraph_checkpoint_1 = require("@langchain/langgraph-checkpoint");
13
- const base_js_1 = require("../channels/base.cjs");
14
- const io_js_1 = require("./io.cjs");
15
- const constants_js_1 = require("../constants.cjs");
16
- const types_js_1 = require("./types.cjs");
17
- const errors_js_1 = require("../errors.cjs");
18
- const index_js_1 = require("./utils/index.cjs");
19
- const call_js_1 = require("./call.cjs");
20
- const hash_js_1 = require("../hash.cjs");
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_errors = require('../errors.cjs');
3
+ const require_base = require('../channels/base.cjs');
4
+ const require_constants = require('../constants.cjs');
5
+ const require_hash = require('../hash.cjs');
6
+ const require_io = require('./io.cjs');
7
+ const require_types = require('./types.cjs');
8
+ const require_index = require('./utils/index.cjs');
9
+ const require_call = require('./call.cjs');
10
+ const __langchain_langgraph_checkpoint = require_rolldown_runtime.__toESM(require("@langchain/langgraph-checkpoint"));
11
+ const __langchain_core_runnables = require_rolldown_runtime.__toESM(require("@langchain/core/runnables"));
12
+
13
+ //#region src/pregel/algo.ts
21
14
  const increment = (current) => {
22
- return current !== undefined ? current + 1 : 1;
15
+ return current !== void 0 ? current + 1 : 1;
23
16
  };
24
- exports.increment = increment;
25
- // Avoids unnecessary double iteration
26
17
  function maxChannelMapVersion(channelVersions) {
27
- let maxVersion;
28
- for (const chan in channelVersions) {
29
- if (!Object.prototype.hasOwnProperty.call(channelVersions, chan))
30
- continue;
31
- if (maxVersion == null) {
32
- maxVersion = channelVersions[chan];
33
- }
34
- else {
35
- maxVersion = (0, langgraph_checkpoint_1.maxChannelVersion)(maxVersion, channelVersions[chan]);
36
- }
37
- }
38
- return maxVersion;
18
+ let maxVersion;
19
+ for (const chan in channelVersions) {
20
+ if (!Object.prototype.hasOwnProperty.call(channelVersions, chan)) continue;
21
+ if (maxVersion == null) maxVersion = channelVersions[chan];
22
+ else maxVersion = (0, __langchain_langgraph_checkpoint.maxChannelVersion)(maxVersion, channelVersions[chan]);
23
+ }
24
+ return maxVersion;
39
25
  }
40
26
  function shouldInterrupt(checkpoint, interruptNodes, tasks) {
41
- const nullVersion = (0, index_js_1.getNullChannelVersion)(checkpoint.channel_versions);
42
- const seen = checkpoint.versions_seen[constants_js_1.INTERRUPT] ?? {};
43
- let anyChannelUpdated = false;
44
- for (const chan in checkpoint.channel_versions) {
45
- if (!Object.prototype.hasOwnProperty.call(checkpoint.channel_versions, chan))
46
- continue;
47
- if (checkpoint.channel_versions[chan] > (seen[chan] ?? nullVersion)) {
48
- anyChannelUpdated = true;
49
- break;
50
- }
51
- }
52
- const anyTriggeredNodeInInterruptNodes = tasks.some((task) => interruptNodes === "*"
53
- ? !task.config?.tags?.includes(constants_js_1.TAG_HIDDEN)
54
- : interruptNodes.includes(task.name));
55
- return anyChannelUpdated && anyTriggeredNodeInInterruptNodes;
27
+ const nullVersion = require_index.getNullChannelVersion(checkpoint.channel_versions);
28
+ const seen = checkpoint.versions_seen[require_constants.INTERRUPT] ?? {};
29
+ let anyChannelUpdated = false;
30
+ for (const chan in checkpoint.channel_versions) {
31
+ if (!Object.prototype.hasOwnProperty.call(checkpoint.channel_versions, chan)) continue;
32
+ if (checkpoint.channel_versions[chan] > (seen[chan] ?? nullVersion)) {
33
+ anyChannelUpdated = true;
34
+ break;
35
+ }
36
+ }
37
+ const anyTriggeredNodeInInterruptNodes = tasks.some((task) => interruptNodes === "*" ? !task.config?.tags?.includes(require_constants.TAG_HIDDEN) : interruptNodes.includes(task.name));
38
+ return anyChannelUpdated && anyTriggeredNodeInInterruptNodes;
56
39
  }
57
40
  function _localRead(checkpoint, channels, task, select, fresh = false) {
58
- let updated = new Set();
59
- if (!Array.isArray(select)) {
60
- for (const [c] of task.writes) {
61
- if (c === select) {
62
- updated = new Set([c]);
63
- break;
64
- }
65
- }
66
- updated = updated || new Set();
67
- }
68
- else {
69
- updated = new Set(select.filter((c) => task.writes.some(([key, _]) => key === c)));
70
- }
71
- let values;
72
- if (fresh && updated.size > 0) {
73
- const localChannels = Object.fromEntries(Object.entries(channels).filter(([k, _]) => updated.has(k)));
74
- const newCheckpoint = (0, base_js_1.createCheckpoint)(checkpoint, localChannels, -1);
75
- const newChannels = (0, base_js_1.emptyChannels)(localChannels, newCheckpoint);
76
- _applyWrites((0, langgraph_checkpoint_1.copyCheckpoint)(newCheckpoint), newChannels, [task], undefined, undefined);
77
- values = (0, io_js_1.readChannels)({ ...channels, ...newChannels }, select);
78
- }
79
- else {
80
- values = (0, io_js_1.readChannels)(channels, select);
81
- }
82
- return values;
41
+ let updated = /* @__PURE__ */ new Set();
42
+ if (!Array.isArray(select)) {
43
+ for (const [c] of task.writes) if (c === select) {
44
+ updated = new Set([c]);
45
+ break;
46
+ }
47
+ updated = updated || /* @__PURE__ */ new Set();
48
+ } else updated = new Set(select.filter((c) => task.writes.some(([key, _]) => key === c)));
49
+ let values;
50
+ if (fresh && updated.size > 0) {
51
+ const localChannels = Object.fromEntries(Object.entries(channels).filter(([k, _]) => updated.has(k)));
52
+ const newCheckpoint = require_base.createCheckpoint(checkpoint, localChannels, -1);
53
+ const newChannels = require_base.emptyChannels(localChannels, newCheckpoint);
54
+ _applyWrites((0, __langchain_langgraph_checkpoint.copyCheckpoint)(newCheckpoint), newChannels, [task], void 0, void 0);
55
+ values = require_io.readChannels({
56
+ ...channels,
57
+ ...newChannels
58
+ }, select);
59
+ } else values = require_io.readChannels(channels, select);
60
+ return values;
83
61
  }
84
- function _localWrite(
85
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
- commit, processes,
87
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
- writes) {
89
- for (const [chan, value] of writes) {
90
- if ([constants_js_1.PUSH, constants_js_1.TASKS].includes(chan) && value != null) {
91
- if (!(0, constants_js_1._isSend)(value)) {
92
- throw new errors_js_1.InvalidUpdateError(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(value)}`);
93
- }
94
- if (!(value.node in processes)) {
95
- throw new errors_js_1.InvalidUpdateError(`Invalid node name "${value.node}" in Send packet`);
96
- }
97
- }
98
- }
99
- commit(writes);
62
+ function _localWrite(commit, processes, writes) {
63
+ for (const [chan, value] of writes) if ([require_constants.PUSH, require_constants.TASKS].includes(chan) && value != null) {
64
+ if (!require_constants._isSend(value)) throw new require_errors.InvalidUpdateError(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(value)}`);
65
+ if (!(value.node in processes)) throw new require_errors.InvalidUpdateError(`Invalid node name "${value.node}" in Send packet`);
66
+ }
67
+ commit(writes);
100
68
  }
101
69
  const IGNORE = new Set([
102
- constants_js_1.NO_WRITES,
103
- constants_js_1.PUSH,
104
- constants_js_1.RESUME,
105
- constants_js_1.INTERRUPT,
106
- constants_js_1.RETURN,
107
- constants_js_1.ERROR,
70
+ require_constants.NO_WRITES,
71
+ require_constants.PUSH,
72
+ require_constants.RESUME,
73
+ require_constants.INTERRUPT,
74
+ require_constants.RETURN,
75
+ require_constants.ERROR
108
76
  ]);
109
- function _applyWrites(checkpoint, channels, tasks,
110
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
- getNextVersion, triggerToNodes) {
112
- // Sort tasks by first 3 path elements for deterministic order
113
- // Later path parts (like task IDs) are ignored for sorting
114
- tasks.sort((a, b) => {
115
- const aPath = a.path?.slice(0, 3) || [];
116
- const bPath = b.path?.slice(0, 3) || [];
117
- // Compare each path element
118
- for (let i = 0; i < Math.min(aPath.length, bPath.length); i += 1) {
119
- if (aPath[i] < bPath[i])
120
- return -1;
121
- if (aPath[i] > bPath[i])
122
- return 1;
123
- }
124
- // If one path is shorter, it comes first
125
- return aPath.length - bPath.length;
126
- });
127
- // if no task has triggers this is applying writes from the null task only
128
- // so we don't do anything other than update the channels written to
129
- const bumpStep = tasks.some((task) => task.triggers.length > 0);
130
- // Filter out non instances of BaseChannel
131
- const onlyChannels = (0, base_js_1.getOnlyChannels)(channels);
132
- // Update seen versions
133
- for (const task of tasks) {
134
- checkpoint.versions_seen[task.name] ??= {};
135
- for (const chan of task.triggers) {
136
- if (chan in checkpoint.channel_versions) {
137
- checkpoint.versions_seen[task.name][chan] =
138
- checkpoint.channel_versions[chan];
139
- }
140
- }
141
- }
142
- // Find the highest version of all channels
143
- let maxVersion = maxChannelMapVersion(checkpoint.channel_versions);
144
- // Consume all channels that were read
145
- const channelsToConsume = new Set(tasks
146
- .flatMap((task) => task.triggers)
147
- .filter((chan) => !constants_js_1.RESERVED.includes(chan)));
148
- for (const chan of channelsToConsume) {
149
- if (chan in onlyChannels && onlyChannels[chan].consume()) {
150
- if (getNextVersion !== undefined) {
151
- checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
152
- }
153
- }
154
- }
155
- // Group writes by channel
156
- const pendingWritesByChannel = {};
157
- for (const task of tasks) {
158
- for (const [chan, val] of task.writes) {
159
- if (IGNORE.has(chan)) {
160
- // do nothing
161
- }
162
- else if (chan in onlyChannels) {
163
- pendingWritesByChannel[chan] ??= [];
164
- pendingWritesByChannel[chan].push(val);
165
- }
166
- }
167
- }
168
- // Find the highest version of all channels
169
- maxVersion = maxChannelMapVersion(checkpoint.channel_versions);
170
- const updatedChannels = new Set();
171
- // Apply writes to channels
172
- for (const [chan, vals] of Object.entries(pendingWritesByChannel)) {
173
- if (chan in onlyChannels) {
174
- const channel = onlyChannels[chan];
175
- let updated;
176
- try {
177
- updated = channel.update(vals);
178
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
179
- }
180
- catch (e) {
181
- if (e.name === errors_js_1.InvalidUpdateError.unminifiable_name) {
182
- const wrappedError = new errors_js_1.InvalidUpdateError(`Invalid update for channel "${chan}" with values ${JSON.stringify(vals)}: ${e.message}`);
183
- wrappedError.lc_error_code = e.lc_error_code;
184
- throw wrappedError;
185
- }
186
- else {
187
- throw e;
188
- }
189
- }
190
- if (updated && getNextVersion !== undefined) {
191
- checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
192
- // unavailable channels can't trigger tasks, so don't add them
193
- if (channel.isAvailable())
194
- updatedChannels.add(chan);
195
- }
196
- }
197
- }
198
- // Channels that weren't updated in this step are notified of a new step
199
- if (bumpStep) {
200
- for (const chan in onlyChannels) {
201
- if (!Object.prototype.hasOwnProperty.call(onlyChannels, chan))
202
- continue;
203
- const channel = onlyChannels[chan];
204
- if (channel.isAvailable() && !updatedChannels.has(chan)) {
205
- const updated = channel.update([]);
206
- if (updated && getNextVersion !== undefined) {
207
- checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
208
- // unavailable channels can't trigger tasks, so don't add them
209
- if (channel.isAvailable())
210
- updatedChannels.add(chan);
211
- }
212
- }
213
- }
214
- }
215
- // If this is (tentatively) the last superstep, notify all channels of finish
216
- if (bumpStep &&
217
- !Object.keys(triggerToNodes ?? {}).some((channel) => updatedChannels.has(channel))) {
218
- for (const chan in onlyChannels) {
219
- if (!Object.prototype.hasOwnProperty.call(onlyChannels, chan))
220
- continue;
221
- const channel = onlyChannels[chan];
222
- if (channel.finish() && getNextVersion !== undefined) {
223
- checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
224
- // unavailable channels can't trigger tasks, so don't add them
225
- if (channel.isAvailable())
226
- updatedChannels.add(chan);
227
- }
228
- }
229
- }
77
+ function _applyWrites(checkpoint, channels, tasks, getNextVersion, triggerToNodes) {
78
+ tasks.sort((a, b) => {
79
+ const aPath = a.path?.slice(0, 3) || [];
80
+ const bPath = b.path?.slice(0, 3) || [];
81
+ for (let i = 0; i < Math.min(aPath.length, bPath.length); i += 1) {
82
+ if (aPath[i] < bPath[i]) return -1;
83
+ if (aPath[i] > bPath[i]) return 1;
84
+ }
85
+ return aPath.length - bPath.length;
86
+ });
87
+ const bumpStep = tasks.some((task) => task.triggers.length > 0);
88
+ const onlyChannels = require_base.getOnlyChannels(channels);
89
+ for (const task of tasks) {
90
+ checkpoint.versions_seen[task.name] ??= {};
91
+ for (const chan of task.triggers) if (chan in checkpoint.channel_versions) checkpoint.versions_seen[task.name][chan] = checkpoint.channel_versions[chan];
92
+ }
93
+ let maxVersion = maxChannelMapVersion(checkpoint.channel_versions);
94
+ const channelsToConsume = new Set(tasks.flatMap((task) => task.triggers).filter((chan) => !require_constants.RESERVED.includes(chan)));
95
+ for (const chan of channelsToConsume) if (chan in onlyChannels && onlyChannels[chan].consume()) {
96
+ if (getNextVersion !== void 0) checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
97
+ }
98
+ const pendingWritesByChannel = {};
99
+ for (const task of tasks) for (const [chan, val] of task.writes) if (IGNORE.has(chan)) {} else if (chan in onlyChannels) {
100
+ pendingWritesByChannel[chan] ??= [];
101
+ pendingWritesByChannel[chan].push(val);
102
+ }
103
+ maxVersion = maxChannelMapVersion(checkpoint.channel_versions);
104
+ const updatedChannels = /* @__PURE__ */ new Set();
105
+ for (const [chan, vals] of Object.entries(pendingWritesByChannel)) if (chan in onlyChannels) {
106
+ const channel = onlyChannels[chan];
107
+ let updated;
108
+ try {
109
+ updated = channel.update(vals);
110
+ } catch (e) {
111
+ if (e.name === require_errors.InvalidUpdateError.unminifiable_name) {
112
+ const wrappedError = new require_errors.InvalidUpdateError(`Invalid update for channel "${chan}" with values ${JSON.stringify(vals)}: ${e.message}`);
113
+ wrappedError.lc_error_code = e.lc_error_code;
114
+ throw wrappedError;
115
+ } else throw e;
116
+ }
117
+ if (updated && getNextVersion !== void 0) {
118
+ checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
119
+ if (channel.isAvailable()) updatedChannels.add(chan);
120
+ }
121
+ }
122
+ if (bumpStep) for (const chan in onlyChannels) {
123
+ if (!Object.prototype.hasOwnProperty.call(onlyChannels, chan)) continue;
124
+ const channel = onlyChannels[chan];
125
+ if (channel.isAvailable() && !updatedChannels.has(chan)) {
126
+ const updated = channel.update([]);
127
+ if (updated && getNextVersion !== void 0) {
128
+ checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
129
+ if (channel.isAvailable()) updatedChannels.add(chan);
130
+ }
131
+ }
132
+ }
133
+ if (bumpStep && !Object.keys(triggerToNodes ?? {}).some((channel) => updatedChannels.has(channel))) for (const chan in onlyChannels) {
134
+ if (!Object.prototype.hasOwnProperty.call(onlyChannels, chan)) continue;
135
+ const channel = onlyChannels[chan];
136
+ if (channel.finish() && getNextVersion !== void 0) {
137
+ checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
138
+ if (channel.isAvailable()) updatedChannels.add(chan);
139
+ }
140
+ }
230
141
  }
231
142
  /**
232
- * Prepare the set of tasks that will make up the next Pregel step.
233
- * This is the union of all PUSH tasks (Sends) and PULL tasks (nodes triggered
234
- * by edges).
235
- */
143
+ * Prepare the set of tasks that will make up the next Pregel step.
144
+ * This is the union of all PUSH tasks (Sends) and PULL tasks (nodes triggered
145
+ * by edges).
146
+ */
236
147
  function _prepareNextTasks(checkpoint, pendingWrites, processes, channels, config, forExecution, extra) {
237
- const tasks = {};
238
- // Consume pending tasks
239
- const tasksChannel = channels[constants_js_1.TASKS];
240
- if (tasksChannel?.isAvailable()) {
241
- const len = tasksChannel.get().length;
242
- for (let i = 0; i < len; i += 1) {
243
- const task = _prepareSingleTask([constants_js_1.PUSH, i], checkpoint, pendingWrites, processes, channels, config, forExecution, extra);
244
- if (task !== undefined) {
245
- tasks[task.id] = task;
246
- }
247
- }
248
- }
249
- // Check if any processes should be run in next step
250
- // If so, prepare the values to be passed to them
251
- for (const name in processes) {
252
- if (!Object.prototype.hasOwnProperty.call(processes, name))
253
- continue;
254
- const task = _prepareSingleTask([constants_js_1.PULL, name], checkpoint, pendingWrites, processes, channels, config, forExecution, extra);
255
- if (task !== undefined) {
256
- tasks[task.id] = task;
257
- }
258
- }
259
- return tasks;
148
+ const tasks = {};
149
+ const tasksChannel = channels[require_constants.TASKS];
150
+ if (tasksChannel?.isAvailable()) {
151
+ const len = tasksChannel.get().length;
152
+ for (let i = 0; i < len; i += 1) {
153
+ const task = _prepareSingleTask([require_constants.PUSH, i], checkpoint, pendingWrites, processes, channels, config, forExecution, extra);
154
+ if (task !== void 0) tasks[task.id] = task;
155
+ }
156
+ }
157
+ for (const name in processes) {
158
+ if (!Object.prototype.hasOwnProperty.call(processes, name)) continue;
159
+ const task = _prepareSingleTask([require_constants.PULL, name], checkpoint, pendingWrites, processes, channels, config, forExecution, extra);
160
+ if (task !== void 0) tasks[task.id] = task;
161
+ }
162
+ return tasks;
260
163
  }
261
164
  /**
262
- * Prepares a single task for the next Pregel step, given a task path, which
263
- * uniquely identifies a PUSH or PULL task within the graph.
264
- */
165
+ * Prepares a single task for the next Pregel step, given a task path, which
166
+ * uniquely identifies a PUSH or PULL task within the graph.
167
+ */
265
168
  function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, channels, config, forExecution, extra) {
266
- const { step, checkpointer, manager } = extra;
267
- const configurable = config.configurable ?? {};
268
- const parentNamespace = configurable.checkpoint_ns ?? "";
269
- if (taskPath[0] === constants_js_1.PUSH && (0, types_js_1.isCall)(taskPath[taskPath.length - 1])) {
270
- const call = taskPath[taskPath.length - 1];
271
- const proc = (0, call_js_1.getRunnableForFunc)(call.name, call.func);
272
- const triggers = [constants_js_1.PUSH];
273
- const checkpointNamespace = parentNamespace === ""
274
- ? call.name
275
- : `${parentNamespace}${constants_js_1.CHECKPOINT_NAMESPACE_SEPARATOR}${call.name}`;
276
- const id = (0, langgraph_checkpoint_1.uuid5)(JSON.stringify([
277
- checkpointNamespace,
278
- step.toString(),
279
- call.name,
280
- constants_js_1.PUSH,
281
- taskPath[1],
282
- taskPath[2],
283
- ]), checkpoint.id);
284
- const taskCheckpointNamespace = `${checkpointNamespace}${constants_js_1.CHECKPOINT_NAMESPACE_END}${id}`;
285
- // we append `true` to the task path to indicate that a call is being made
286
- // so we should not return interrupts from this task (responsibility lies with the parent)
287
- const outputTaskPath = [...taskPath.slice(0, 3), true];
288
- const metadata = {
289
- langgraph_step: step,
290
- langgraph_node: call.name,
291
- langgraph_triggers: triggers,
292
- langgraph_path: outputTaskPath,
293
- langgraph_checkpoint_ns: taskCheckpointNamespace,
294
- };
295
- if (forExecution) {
296
- const writes = [];
297
- const task = {
298
- name: call.name,
299
- input: call.input,
300
- proc,
301
- writes,
302
- config: (0, runnables_1.patchConfig)((0, runnables_1.mergeConfigs)(config, {
303
- metadata,
304
- store: extra.store ?? config.store,
305
- }), {
306
- runName: call.name,
307
- callbacks: manager?.getChild(`graph:step:${step}`),
308
- configurable: {
309
- [constants_js_1.CONFIG_KEY_TASK_ID]: id,
310
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
311
- [constants_js_1.CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => writes.push(...items), processes, writes_),
312
- [constants_js_1.CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
313
- name: call.name,
314
- writes: writes,
315
- triggers,
316
- path: outputTaskPath,
317
- }, select_, fresh_),
318
- [constants_js_1.CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[constants_js_1.CONFIG_KEY_CHECKPOINTER],
319
- [constants_js_1.CONFIG_KEY_CHECKPOINT_MAP]: {
320
- ...configurable[constants_js_1.CONFIG_KEY_CHECKPOINT_MAP],
321
- [parentNamespace]: checkpoint.id,
322
- },
323
- [constants_js_1.CONFIG_KEY_SCRATCHPAD]: _scratchpad({
324
- pendingWrites: pendingWrites ?? [],
325
- taskId: id,
326
- currentTaskInput: call.input,
327
- resumeMap: config.configurable?.[constants_js_1.CONFIG_KEY_RESUME_MAP],
328
- namespaceHash: (0, hash_js_1.XXH3)(taskCheckpointNamespace),
329
- }),
330
- [constants_js_1.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[constants_js_1.PREVIOUS],
331
- checkpoint_id: undefined,
332
- checkpoint_ns: taskCheckpointNamespace,
333
- },
334
- }),
335
- triggers,
336
- retry_policy: call.retry,
337
- cache_key: call.cache
338
- ? {
339
- key: (0, hash_js_1.XXH3)((call.cache.keyFunc ?? JSON.stringify)([call.input])),
340
- ns: [constants_js_1.CACHE_NS_WRITES, call.name ?? "__dynamic__"],
341
- ttl: call.cache.ttl,
342
- }
343
- : undefined,
344
- id,
345
- path: outputTaskPath,
346
- writers: [],
347
- };
348
- return task;
349
- }
350
- else {
351
- return {
352
- id,
353
- name: call.name,
354
- interrupts: [],
355
- path: outputTaskPath,
356
- };
357
- }
358
- }
359
- else if (taskPath[0] === constants_js_1.PUSH) {
360
- const index = typeof taskPath[1] === "number"
361
- ? taskPath[1]
362
- : parseInt(taskPath[1], 10);
363
- if (!channels[constants_js_1.TASKS]?.isAvailable()) {
364
- return undefined;
365
- }
366
- const sends = channels[constants_js_1.TASKS].get();
367
- if (index < 0 || index >= sends.length) {
368
- return undefined;
369
- }
370
- const packet = (0, constants_js_1._isSendInterface)(sends[index]) && !(0, constants_js_1._isSend)(sends[index])
371
- ? new constants_js_1.Send(sends[index].node, sends[index].args)
372
- : sends[index];
373
- if (!(0, constants_js_1._isSendInterface)(packet)) {
374
- console.warn(`Ignoring invalid packet ${JSON.stringify(packet)} in pending sends.`);
375
- return undefined;
376
- }
377
- if (!(packet.node in processes)) {
378
- console.warn(`Ignoring unknown node name ${packet.node} in pending sends.`);
379
- return undefined;
380
- }
381
- const triggers = [constants_js_1.PUSH];
382
- const checkpointNamespace = parentNamespace === ""
383
- ? packet.node
384
- : `${parentNamespace}${constants_js_1.CHECKPOINT_NAMESPACE_SEPARATOR}${packet.node}`;
385
- const taskId = (0, langgraph_checkpoint_1.uuid5)(JSON.stringify([
386
- checkpointNamespace,
387
- step.toString(),
388
- packet.node,
389
- constants_js_1.PUSH,
390
- index.toString(),
391
- ]), checkpoint.id);
392
- const taskCheckpointNamespace = `${checkpointNamespace}${constants_js_1.CHECKPOINT_NAMESPACE_END}${taskId}`;
393
- let metadata = {
394
- langgraph_step: step,
395
- langgraph_node: packet.node,
396
- langgraph_triggers: triggers,
397
- langgraph_path: taskPath.slice(0, 3),
398
- langgraph_checkpoint_ns: taskCheckpointNamespace,
399
- };
400
- if (forExecution) {
401
- const proc = processes[packet.node];
402
- const node = proc.getNode();
403
- if (node !== undefined) {
404
- if (proc.metadata !== undefined) {
405
- metadata = { ...metadata, ...proc.metadata };
406
- }
407
- const writes = [];
408
- return {
409
- name: packet.node,
410
- input: packet.args,
411
- proc: node,
412
- subgraphs: proc.subgraphs,
413
- writes,
414
- config: (0, runnables_1.patchConfig)((0, runnables_1.mergeConfigs)(config, {
415
- metadata,
416
- tags: proc.tags,
417
- store: extra.store ?? config.store,
418
- }), {
419
- runName: packet.node,
420
- callbacks: manager?.getChild(`graph:step:${step}`),
421
- configurable: {
422
- [constants_js_1.CONFIG_KEY_TASK_ID]: taskId,
423
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
424
- [constants_js_1.CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => writes.push(...items), processes, writes_),
425
- [constants_js_1.CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
426
- name: packet.node,
427
- writes: writes,
428
- triggers,
429
- path: taskPath,
430
- }, select_, fresh_),
431
- [constants_js_1.CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[constants_js_1.CONFIG_KEY_CHECKPOINTER],
432
- [constants_js_1.CONFIG_KEY_CHECKPOINT_MAP]: {
433
- ...configurable[constants_js_1.CONFIG_KEY_CHECKPOINT_MAP],
434
- [parentNamespace]: checkpoint.id,
435
- },
436
- [constants_js_1.CONFIG_KEY_SCRATCHPAD]: _scratchpad({
437
- pendingWrites: pendingWrites ?? [],
438
- taskId,
439
- currentTaskInput: packet.args,
440
- resumeMap: config.configurable?.[constants_js_1.CONFIG_KEY_RESUME_MAP],
441
- namespaceHash: (0, hash_js_1.XXH3)(taskCheckpointNamespace),
442
- }),
443
- [constants_js_1.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[constants_js_1.PREVIOUS],
444
- checkpoint_id: undefined,
445
- checkpoint_ns: taskCheckpointNamespace,
446
- },
447
- }),
448
- triggers,
449
- retry_policy: proc.retryPolicy,
450
- cache_key: proc.cachePolicy
451
- ? {
452
- key: (0, hash_js_1.XXH3)((proc.cachePolicy.keyFunc ?? JSON.stringify)([packet.args])),
453
- ns: [constants_js_1.CACHE_NS_WRITES, proc.name ?? "__dynamic__", packet.node],
454
- ttl: proc.cachePolicy.ttl,
455
- }
456
- : undefined,
457
- id: taskId,
458
- path: taskPath,
459
- writers: proc.getWriters(),
460
- };
461
- }
462
- }
463
- else {
464
- return {
465
- id: taskId,
466
- name: packet.node,
467
- interrupts: [],
468
- path: taskPath,
469
- };
470
- }
471
- }
472
- else if (taskPath[0] === constants_js_1.PULL) {
473
- const name = taskPath[1].toString();
474
- const proc = processes[name];
475
- if (proc === undefined) {
476
- return undefined;
477
- }
478
- // Check if this task already has successful writes in the pending writes
479
- if (pendingWrites?.length) {
480
- // Find the task ID for this node/path
481
- const checkpointNamespace = parentNamespace === ""
482
- ? name
483
- : `${parentNamespace}${constants_js_1.CHECKPOINT_NAMESPACE_SEPARATOR}${name}`;
484
- const taskId = (0, langgraph_checkpoint_1.uuid5)(JSON.stringify([
485
- checkpointNamespace,
486
- step.toString(),
487
- name,
488
- constants_js_1.PULL,
489
- name,
490
- ]), checkpoint.id);
491
- // Check if there are successful writes (not ERROR) for this task ID
492
- const hasSuccessfulWrites = pendingWrites.some((w) => w[0] === taskId && w[1] !== constants_js_1.ERROR);
493
- // If task completed successfully, don't include it in next tasks
494
- if (hasSuccessfulWrites) {
495
- return undefined;
496
- }
497
- }
498
- const nullVersion = (0, index_js_1.getNullChannelVersion)(checkpoint.channel_versions);
499
- if (nullVersion === undefined) {
500
- return undefined;
501
- }
502
- const seen = checkpoint.versions_seen[name] ?? {};
503
- // Find the first trigger that is available and has a new version
504
- const trigger = proc.triggers.find((chan) => {
505
- if (!channels[chan].isAvailable())
506
- return false;
507
- return ((checkpoint.channel_versions[chan] ?? nullVersion) >
508
- (seen[chan] ?? nullVersion));
509
- });
510
- // If any of the channels read by this process were updated
511
- if (trigger !== undefined) {
512
- const val = _procInput(proc, channels, forExecution);
513
- if (val === undefined) {
514
- return undefined;
515
- }
516
- const checkpointNamespace = parentNamespace === ""
517
- ? name
518
- : `${parentNamespace}${constants_js_1.CHECKPOINT_NAMESPACE_SEPARATOR}${name}`;
519
- const taskId = (0, langgraph_checkpoint_1.uuid5)(JSON.stringify([
520
- checkpointNamespace,
521
- step.toString(),
522
- name,
523
- constants_js_1.PULL,
524
- [trigger],
525
- ]), checkpoint.id);
526
- const taskCheckpointNamespace = `${checkpointNamespace}${constants_js_1.CHECKPOINT_NAMESPACE_END}${taskId}`;
527
- let metadata = {
528
- langgraph_step: step,
529
- langgraph_node: name,
530
- langgraph_triggers: [trigger],
531
- langgraph_path: taskPath,
532
- langgraph_checkpoint_ns: taskCheckpointNamespace,
533
- };
534
- if (forExecution) {
535
- const node = proc.getNode();
536
- if (node !== undefined) {
537
- if (proc.metadata !== undefined) {
538
- metadata = { ...metadata, ...proc.metadata };
539
- }
540
- const writes = [];
541
- return {
542
- name,
543
- input: val,
544
- proc: node,
545
- subgraphs: proc.subgraphs,
546
- writes,
547
- config: (0, runnables_1.patchConfig)((0, runnables_1.mergeConfigs)(config, {
548
- metadata,
549
- tags: proc.tags,
550
- store: extra.store ?? config.store,
551
- }), {
552
- runName: name,
553
- callbacks: manager?.getChild(`graph:step:${step}`),
554
- configurable: {
555
- [constants_js_1.CONFIG_KEY_TASK_ID]: taskId,
556
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
557
- [constants_js_1.CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => {
558
- writes.push(...items);
559
- }, processes, writes_),
560
- [constants_js_1.CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
561
- name,
562
- writes: writes,
563
- triggers: [trigger],
564
- path: taskPath,
565
- }, select_, fresh_),
566
- [constants_js_1.CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[constants_js_1.CONFIG_KEY_CHECKPOINTER],
567
- [constants_js_1.CONFIG_KEY_CHECKPOINT_MAP]: {
568
- ...configurable[constants_js_1.CONFIG_KEY_CHECKPOINT_MAP],
569
- [parentNamespace]: checkpoint.id,
570
- },
571
- [constants_js_1.CONFIG_KEY_SCRATCHPAD]: _scratchpad({
572
- pendingWrites: pendingWrites ?? [],
573
- taskId,
574
- currentTaskInput: val,
575
- resumeMap: config.configurable?.[constants_js_1.CONFIG_KEY_RESUME_MAP],
576
- namespaceHash: (0, hash_js_1.XXH3)(taskCheckpointNamespace),
577
- }),
578
- [constants_js_1.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[constants_js_1.PREVIOUS],
579
- checkpoint_id: undefined,
580
- checkpoint_ns: taskCheckpointNamespace,
581
- },
582
- }),
583
- triggers: [trigger],
584
- retry_policy: proc.retryPolicy,
585
- cache_key: proc.cachePolicy
586
- ? {
587
- key: (0, hash_js_1.XXH3)((proc.cachePolicy.keyFunc ?? JSON.stringify)([val])),
588
- ns: [constants_js_1.CACHE_NS_WRITES, proc.name ?? "__dynamic__", name],
589
- ttl: proc.cachePolicy.ttl,
590
- }
591
- : undefined,
592
- id: taskId,
593
- path: taskPath,
594
- writers: proc.getWriters(),
595
- };
596
- }
597
- }
598
- else {
599
- return {
600
- id: taskId,
601
- name,
602
- interrupts: [],
603
- path: taskPath,
604
- };
605
- }
606
- }
607
- }
608
- return undefined;
169
+ const { step, checkpointer, manager } = extra;
170
+ const configurable = config.configurable ?? {};
171
+ const parentNamespace = configurable.checkpoint_ns ?? "";
172
+ if (taskPath[0] === require_constants.PUSH && require_types.isCall(taskPath[taskPath.length - 1])) {
173
+ const call = taskPath[taskPath.length - 1];
174
+ const proc = require_call.getRunnableForFunc(call.name, call.func);
175
+ const triggers = [require_constants.PUSH];
176
+ const checkpointNamespace = parentNamespace === "" ? call.name : `${parentNamespace}${require_constants.CHECKPOINT_NAMESPACE_SEPARATOR}${call.name}`;
177
+ const id = (0, __langchain_langgraph_checkpoint.uuid5)(JSON.stringify([
178
+ checkpointNamespace,
179
+ step.toString(),
180
+ call.name,
181
+ require_constants.PUSH,
182
+ taskPath[1],
183
+ taskPath[2]
184
+ ]), checkpoint.id);
185
+ const taskCheckpointNamespace = `${checkpointNamespace}${require_constants.CHECKPOINT_NAMESPACE_END}${id}`;
186
+ const outputTaskPath = [...taskPath.slice(0, 3), true];
187
+ const metadata = {
188
+ langgraph_step: step,
189
+ langgraph_node: call.name,
190
+ langgraph_triggers: triggers,
191
+ langgraph_path: outputTaskPath,
192
+ langgraph_checkpoint_ns: taskCheckpointNamespace
193
+ };
194
+ if (forExecution) {
195
+ const writes = [];
196
+ const task = {
197
+ name: call.name,
198
+ input: call.input,
199
+ proc,
200
+ writes,
201
+ config: (0, __langchain_core_runnables.patchConfig)((0, __langchain_core_runnables.mergeConfigs)(config, {
202
+ metadata,
203
+ store: extra.store ?? config.store
204
+ }), {
205
+ runName: call.name,
206
+ callbacks: manager?.getChild(`graph:step:${step}`),
207
+ configurable: {
208
+ [require_constants.CONFIG_KEY_TASK_ID]: id,
209
+ [require_constants.CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => writes.push(...items), processes, writes_),
210
+ [require_constants.CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
211
+ name: call.name,
212
+ writes,
213
+ triggers,
214
+ path: outputTaskPath
215
+ }, select_, fresh_),
216
+ [require_constants.CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[require_constants.CONFIG_KEY_CHECKPOINTER],
217
+ [require_constants.CONFIG_KEY_CHECKPOINT_MAP]: {
218
+ ...configurable[require_constants.CONFIG_KEY_CHECKPOINT_MAP],
219
+ [parentNamespace]: checkpoint.id
220
+ },
221
+ [require_constants.CONFIG_KEY_SCRATCHPAD]: _scratchpad({
222
+ pendingWrites: pendingWrites ?? [],
223
+ taskId: id,
224
+ currentTaskInput: call.input,
225
+ resumeMap: config.configurable?.[require_constants.CONFIG_KEY_RESUME_MAP],
226
+ namespaceHash: require_hash.XXH3(taskCheckpointNamespace)
227
+ }),
228
+ [require_constants.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[require_constants.PREVIOUS],
229
+ checkpoint_id: void 0,
230
+ checkpoint_ns: taskCheckpointNamespace
231
+ }
232
+ }),
233
+ triggers,
234
+ retry_policy: call.retry,
235
+ cache_key: call.cache ? {
236
+ key: require_hash.XXH3((call.cache.keyFunc ?? JSON.stringify)([call.input])),
237
+ ns: [require_constants.CACHE_NS_WRITES, call.name ?? "__dynamic__"],
238
+ ttl: call.cache.ttl
239
+ } : void 0,
240
+ id,
241
+ path: outputTaskPath,
242
+ writers: []
243
+ };
244
+ return task;
245
+ } else return {
246
+ id,
247
+ name: call.name,
248
+ interrupts: [],
249
+ path: outputTaskPath
250
+ };
251
+ } else if (taskPath[0] === require_constants.PUSH) {
252
+ const index = typeof taskPath[1] === "number" ? taskPath[1] : parseInt(taskPath[1], 10);
253
+ if (!channels[require_constants.TASKS]?.isAvailable()) return void 0;
254
+ const sends = channels[require_constants.TASKS].get();
255
+ if (index < 0 || index >= sends.length) return void 0;
256
+ const packet = require_constants._isSendInterface(sends[index]) && !require_constants._isSend(sends[index]) ? new require_constants.Send(sends[index].node, sends[index].args) : sends[index];
257
+ if (!require_constants._isSendInterface(packet)) {
258
+ console.warn(`Ignoring invalid packet ${JSON.stringify(packet)} in pending sends.`);
259
+ return void 0;
260
+ }
261
+ if (!(packet.node in processes)) {
262
+ console.warn(`Ignoring unknown node name ${packet.node} in pending sends.`);
263
+ return void 0;
264
+ }
265
+ const triggers = [require_constants.PUSH];
266
+ const checkpointNamespace = parentNamespace === "" ? packet.node : `${parentNamespace}${require_constants.CHECKPOINT_NAMESPACE_SEPARATOR}${packet.node}`;
267
+ const taskId = (0, __langchain_langgraph_checkpoint.uuid5)(JSON.stringify([
268
+ checkpointNamespace,
269
+ step.toString(),
270
+ packet.node,
271
+ require_constants.PUSH,
272
+ index.toString()
273
+ ]), checkpoint.id);
274
+ const taskCheckpointNamespace = `${checkpointNamespace}${require_constants.CHECKPOINT_NAMESPACE_END}${taskId}`;
275
+ let metadata = {
276
+ langgraph_step: step,
277
+ langgraph_node: packet.node,
278
+ langgraph_triggers: triggers,
279
+ langgraph_path: taskPath.slice(0, 3),
280
+ langgraph_checkpoint_ns: taskCheckpointNamespace
281
+ };
282
+ if (forExecution) {
283
+ const proc = processes[packet.node];
284
+ const node = proc.getNode();
285
+ if (node !== void 0) {
286
+ if (proc.metadata !== void 0) metadata = {
287
+ ...metadata,
288
+ ...proc.metadata
289
+ };
290
+ const writes = [];
291
+ return {
292
+ name: packet.node,
293
+ input: packet.args,
294
+ proc: node,
295
+ subgraphs: proc.subgraphs,
296
+ writes,
297
+ config: (0, __langchain_core_runnables.patchConfig)((0, __langchain_core_runnables.mergeConfigs)(config, {
298
+ metadata,
299
+ tags: proc.tags,
300
+ store: extra.store ?? config.store
301
+ }), {
302
+ runName: packet.node,
303
+ callbacks: manager?.getChild(`graph:step:${step}`),
304
+ configurable: {
305
+ [require_constants.CONFIG_KEY_TASK_ID]: taskId,
306
+ [require_constants.CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => writes.push(...items), processes, writes_),
307
+ [require_constants.CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
308
+ name: packet.node,
309
+ writes,
310
+ triggers,
311
+ path: taskPath
312
+ }, select_, fresh_),
313
+ [require_constants.CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[require_constants.CONFIG_KEY_CHECKPOINTER],
314
+ [require_constants.CONFIG_KEY_CHECKPOINT_MAP]: {
315
+ ...configurable[require_constants.CONFIG_KEY_CHECKPOINT_MAP],
316
+ [parentNamespace]: checkpoint.id
317
+ },
318
+ [require_constants.CONFIG_KEY_SCRATCHPAD]: _scratchpad({
319
+ pendingWrites: pendingWrites ?? [],
320
+ taskId,
321
+ currentTaskInput: packet.args,
322
+ resumeMap: config.configurable?.[require_constants.CONFIG_KEY_RESUME_MAP],
323
+ namespaceHash: require_hash.XXH3(taskCheckpointNamespace)
324
+ }),
325
+ [require_constants.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[require_constants.PREVIOUS],
326
+ checkpoint_id: void 0,
327
+ checkpoint_ns: taskCheckpointNamespace
328
+ }
329
+ }),
330
+ triggers,
331
+ retry_policy: proc.retryPolicy,
332
+ cache_key: proc.cachePolicy ? {
333
+ key: require_hash.XXH3((proc.cachePolicy.keyFunc ?? JSON.stringify)([packet.args])),
334
+ ns: [
335
+ require_constants.CACHE_NS_WRITES,
336
+ proc.name ?? "__dynamic__",
337
+ packet.node
338
+ ],
339
+ ttl: proc.cachePolicy.ttl
340
+ } : void 0,
341
+ id: taskId,
342
+ path: taskPath,
343
+ writers: proc.getWriters()
344
+ };
345
+ }
346
+ } else return {
347
+ id: taskId,
348
+ name: packet.node,
349
+ interrupts: [],
350
+ path: taskPath
351
+ };
352
+ } else if (taskPath[0] === require_constants.PULL) {
353
+ const name = taskPath[1].toString();
354
+ const proc = processes[name];
355
+ if (proc === void 0) return void 0;
356
+ if (pendingWrites?.length) {
357
+ const checkpointNamespace = parentNamespace === "" ? name : `${parentNamespace}${require_constants.CHECKPOINT_NAMESPACE_SEPARATOR}${name}`;
358
+ const taskId = (0, __langchain_langgraph_checkpoint.uuid5)(JSON.stringify([
359
+ checkpointNamespace,
360
+ step.toString(),
361
+ name,
362
+ require_constants.PULL,
363
+ name
364
+ ]), checkpoint.id);
365
+ const hasSuccessfulWrites = pendingWrites.some((w) => w[0] === taskId && w[1] !== require_constants.ERROR);
366
+ if (hasSuccessfulWrites) return void 0;
367
+ }
368
+ const nullVersion = require_index.getNullChannelVersion(checkpoint.channel_versions);
369
+ if (nullVersion === void 0) return void 0;
370
+ const seen = checkpoint.versions_seen[name] ?? {};
371
+ const trigger = proc.triggers.find((chan) => {
372
+ if (!channels[chan].isAvailable()) return false;
373
+ return (checkpoint.channel_versions[chan] ?? nullVersion) > (seen[chan] ?? nullVersion);
374
+ });
375
+ if (trigger !== void 0) {
376
+ const val = _procInput(proc, channels, forExecution);
377
+ if (val === void 0) return void 0;
378
+ const checkpointNamespace = parentNamespace === "" ? name : `${parentNamespace}${require_constants.CHECKPOINT_NAMESPACE_SEPARATOR}${name}`;
379
+ const taskId = (0, __langchain_langgraph_checkpoint.uuid5)(JSON.stringify([
380
+ checkpointNamespace,
381
+ step.toString(),
382
+ name,
383
+ require_constants.PULL,
384
+ [trigger]
385
+ ]), checkpoint.id);
386
+ const taskCheckpointNamespace = `${checkpointNamespace}${require_constants.CHECKPOINT_NAMESPACE_END}${taskId}`;
387
+ let metadata = {
388
+ langgraph_step: step,
389
+ langgraph_node: name,
390
+ langgraph_triggers: [trigger],
391
+ langgraph_path: taskPath,
392
+ langgraph_checkpoint_ns: taskCheckpointNamespace
393
+ };
394
+ if (forExecution) {
395
+ const node = proc.getNode();
396
+ if (node !== void 0) {
397
+ if (proc.metadata !== void 0) metadata = {
398
+ ...metadata,
399
+ ...proc.metadata
400
+ };
401
+ const writes = [];
402
+ return {
403
+ name,
404
+ input: val,
405
+ proc: node,
406
+ subgraphs: proc.subgraphs,
407
+ writes,
408
+ config: (0, __langchain_core_runnables.patchConfig)((0, __langchain_core_runnables.mergeConfigs)(config, {
409
+ metadata,
410
+ tags: proc.tags,
411
+ store: extra.store ?? config.store
412
+ }), {
413
+ runName: name,
414
+ callbacks: manager?.getChild(`graph:step:${step}`),
415
+ configurable: {
416
+ [require_constants.CONFIG_KEY_TASK_ID]: taskId,
417
+ [require_constants.CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => {
418
+ writes.push(...items);
419
+ }, processes, writes_),
420
+ [require_constants.CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
421
+ name,
422
+ writes,
423
+ triggers: [trigger],
424
+ path: taskPath
425
+ }, select_, fresh_),
426
+ [require_constants.CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[require_constants.CONFIG_KEY_CHECKPOINTER],
427
+ [require_constants.CONFIG_KEY_CHECKPOINT_MAP]: {
428
+ ...configurable[require_constants.CONFIG_KEY_CHECKPOINT_MAP],
429
+ [parentNamespace]: checkpoint.id
430
+ },
431
+ [require_constants.CONFIG_KEY_SCRATCHPAD]: _scratchpad({
432
+ pendingWrites: pendingWrites ?? [],
433
+ taskId,
434
+ currentTaskInput: val,
435
+ resumeMap: config.configurable?.[require_constants.CONFIG_KEY_RESUME_MAP],
436
+ namespaceHash: require_hash.XXH3(taskCheckpointNamespace)
437
+ }),
438
+ [require_constants.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[require_constants.PREVIOUS],
439
+ checkpoint_id: void 0,
440
+ checkpoint_ns: taskCheckpointNamespace
441
+ }
442
+ }),
443
+ triggers: [trigger],
444
+ retry_policy: proc.retryPolicy,
445
+ cache_key: proc.cachePolicy ? {
446
+ key: require_hash.XXH3((proc.cachePolicy.keyFunc ?? JSON.stringify)([val])),
447
+ ns: [
448
+ require_constants.CACHE_NS_WRITES,
449
+ proc.name ?? "__dynamic__",
450
+ name
451
+ ],
452
+ ttl: proc.cachePolicy.ttl
453
+ } : void 0,
454
+ id: taskId,
455
+ path: taskPath,
456
+ writers: proc.getWriters()
457
+ };
458
+ }
459
+ } else return {
460
+ id: taskId,
461
+ name,
462
+ interrupts: [],
463
+ path: taskPath
464
+ };
465
+ }
466
+ }
467
+ return void 0;
609
468
  }
610
469
  /**
611
- * Function injected under CONFIG_KEY_READ in task config, to read current state.
612
- * Used by conditional edges to read a copy of the state with reflecting the writes
613
- * from that node only.
614
- *
615
- * @internal
616
- */
470
+ * Function injected under CONFIG_KEY_READ in task config, to read current state.
471
+ * Used by conditional edges to read a copy of the state with reflecting the writes
472
+ * from that node only.
473
+ *
474
+ * @internal
475
+ */
617
476
  function _procInput(proc, channels, forExecution) {
618
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
619
- let val;
620
- if (typeof proc.channels === "object" && !Array.isArray(proc.channels)) {
621
- val = {};
622
- for (const [k, chan] of Object.entries(proc.channels)) {
623
- if (proc.triggers.includes(chan)) {
624
- try {
625
- val[k] = (0, io_js_1.readChannel)(channels, chan, false);
626
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
627
- }
628
- catch (e) {
629
- if (e.name === errors_js_1.EmptyChannelError.unminifiable_name) {
630
- return undefined;
631
- }
632
- else {
633
- throw e;
634
- }
635
- }
636
- }
637
- else if (chan in channels) {
638
- try {
639
- val[k] = (0, io_js_1.readChannel)(channels, chan, false);
640
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
641
- }
642
- catch (e) {
643
- if (e.name === errors_js_1.EmptyChannelError.unminifiable_name) {
644
- continue;
645
- }
646
- else {
647
- throw e;
648
- }
649
- }
650
- }
651
- }
652
- }
653
- else if (Array.isArray(proc.channels)) {
654
- let successfulRead = false;
655
- for (const chan of proc.channels) {
656
- try {
657
- val = (0, io_js_1.readChannel)(channels, chan, false);
658
- successfulRead = true;
659
- break;
660
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
661
- }
662
- catch (e) {
663
- if (e.name === errors_js_1.EmptyChannelError.unminifiable_name) {
664
- continue;
665
- }
666
- else {
667
- throw e;
668
- }
669
- }
670
- }
671
- if (!successfulRead) {
672
- return undefined;
673
- }
674
- }
675
- else {
676
- throw new Error(`Invalid channels type, expected list or dict, got ${proc.channels}`);
677
- }
678
- // If the process has a mapper, apply it to the value
679
- if (forExecution && proc.mapper !== undefined) {
680
- val = proc.mapper(val);
681
- }
682
- return val;
477
+ let val;
478
+ if (typeof proc.channels === "object" && !Array.isArray(proc.channels)) {
479
+ val = {};
480
+ for (const [k, chan] of Object.entries(proc.channels)) if (proc.triggers.includes(chan)) try {
481
+ val[k] = require_io.readChannel(channels, chan, false);
482
+ } catch (e) {
483
+ if (e.name === require_errors.EmptyChannelError.unminifiable_name) return void 0;
484
+ else throw e;
485
+ }
486
+ else if (chan in channels) try {
487
+ val[k] = require_io.readChannel(channels, chan, false);
488
+ } catch (e) {
489
+ if (e.name === require_errors.EmptyChannelError.unminifiable_name) continue;
490
+ else throw e;
491
+ }
492
+ } else if (Array.isArray(proc.channels)) {
493
+ let successfulRead = false;
494
+ for (const chan of proc.channels) try {
495
+ val = require_io.readChannel(channels, chan, false);
496
+ successfulRead = true;
497
+ break;
498
+ } catch (e) {
499
+ if (e.name === require_errors.EmptyChannelError.unminifiable_name) continue;
500
+ else throw e;
501
+ }
502
+ if (!successfulRead) return void 0;
503
+ } else throw new Error(`Invalid channels type, expected list or dict, got ${proc.channels}`);
504
+ if (forExecution && proc.mapper !== void 0) val = proc.mapper(val);
505
+ return val;
683
506
  }
684
- function _scratchpad({ pendingWrites, taskId, currentTaskInput, resumeMap, namespaceHash, }) {
685
- const nullResume = pendingWrites.find(([writeTaskId, chan]) => writeTaskId === constants_js_1.NULL_TASK_ID && chan === constants_js_1.RESUME)?.[2];
686
- const resume = (() => {
687
- const result = pendingWrites
688
- .filter(([writeTaskId, chan]) => writeTaskId === taskId && chan === constants_js_1.RESUME)
689
- .flatMap(([_writeTaskId, _chan, resume]) => resume);
690
- if (resumeMap != null && namespaceHash in resumeMap) {
691
- const mappedResume = resumeMap[namespaceHash];
692
- result.push(mappedResume);
693
- }
694
- return result;
695
- })();
696
- const scratchpad = {
697
- callCounter: 0,
698
- interruptCounter: -1,
699
- resume,
700
- nullResume,
701
- subgraphCounter: 0,
702
- currentTaskInput,
703
- consumeNullResume: () => {
704
- if (scratchpad.nullResume) {
705
- delete scratchpad.nullResume;
706
- pendingWrites.splice(pendingWrites.findIndex(([writeTaskId, chan]) => writeTaskId === constants_js_1.NULL_TASK_ID && chan === constants_js_1.RESUME), 1);
707
- return nullResume;
708
- }
709
- return undefined;
710
- },
711
- };
712
- return scratchpad;
507
+ function _scratchpad({ pendingWrites, taskId, currentTaskInput, resumeMap, namespaceHash }) {
508
+ const nullResume = pendingWrites.find(([writeTaskId, chan]) => writeTaskId === require_constants.NULL_TASK_ID && chan === require_constants.RESUME)?.[2];
509
+ const resume = (() => {
510
+ const result = pendingWrites.filter(([writeTaskId, chan]) => writeTaskId === taskId && chan === require_constants.RESUME).flatMap(([_writeTaskId, _chan, resume$1]) => resume$1);
511
+ if (resumeMap != null && namespaceHash in resumeMap) {
512
+ const mappedResume = resumeMap[namespaceHash];
513
+ result.push(mappedResume);
514
+ }
515
+ return result;
516
+ })();
517
+ const scratchpad = {
518
+ callCounter: 0,
519
+ interruptCounter: -1,
520
+ resume,
521
+ nullResume,
522
+ subgraphCounter: 0,
523
+ currentTaskInput,
524
+ consumeNullResume: () => {
525
+ if (scratchpad.nullResume) {
526
+ delete scratchpad.nullResume;
527
+ pendingWrites.splice(pendingWrites.findIndex(([writeTaskId, chan]) => writeTaskId === require_constants.NULL_TASK_ID && chan === require_constants.RESUME), 1);
528
+ return nullResume;
529
+ }
530
+ return void 0;
531
+ }
532
+ };
533
+ return scratchpad;
713
534
  }
714
- //# sourceMappingURL=algo.js.map
535
+
536
+ //#endregion
537
+ exports._applyWrites = _applyWrites;
538
+ exports._localRead = _localRead;
539
+ exports._prepareNextTasks = _prepareNextTasks;
540
+ exports._prepareSingleTask = _prepareSingleTask;
541
+ exports.increment = increment;
542
+ exports.shouldInterrupt = shouldInterrupt;
543
+ //# sourceMappingURL=algo.cjs.map