@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,714 +1,573 @@
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
17
+ function triggersNextStep(updatedChannels, triggerToNodes) {
18
+ if (triggerToNodes == null) return false;
19
+ for (const chan of updatedChannels) if (triggerToNodes[chan]) return true;
20
+ return false;
21
+ }
26
22
  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;
23
+ let maxVersion;
24
+ for (const chan in channelVersions) {
25
+ if (!Object.prototype.hasOwnProperty.call(channelVersions, chan)) continue;
26
+ if (maxVersion == null) maxVersion = channelVersions[chan];
27
+ else maxVersion = (0, __langchain_langgraph_checkpoint.maxChannelVersion)(maxVersion, channelVersions[chan]);
28
+ }
29
+ return maxVersion;
39
30
  }
40
31
  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;
32
+ const nullVersion = require_index.getNullChannelVersion(checkpoint.channel_versions);
33
+ const seen = checkpoint.versions_seen[require_constants.INTERRUPT] ?? {};
34
+ let anyChannelUpdated = false;
35
+ if ((checkpoint.channel_versions[require_constants.START] ?? nullVersion) > (seen[require_constants.START] ?? nullVersion)) anyChannelUpdated = true;
36
+ else for (const chan in checkpoint.channel_versions) {
37
+ if (!Object.prototype.hasOwnProperty.call(checkpoint.channel_versions, chan)) continue;
38
+ if (checkpoint.channel_versions[chan] > (seen[chan] ?? nullVersion)) {
39
+ anyChannelUpdated = true;
40
+ break;
41
+ }
42
+ }
43
+ const anyTriggeredNodeInInterruptNodes = tasks.some((task) => interruptNodes === "*" ? !task.config?.tags?.includes(require_constants.TAG_HIDDEN) : interruptNodes.includes(task.name));
44
+ return anyChannelUpdated && anyTriggeredNodeInInterruptNodes;
56
45
  }
57
46
  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;
47
+ let updated = /* @__PURE__ */ new Set();
48
+ if (!Array.isArray(select)) {
49
+ for (const [c] of task.writes) if (c === select) {
50
+ updated = new Set([c]);
51
+ break;
52
+ }
53
+ updated = updated || /* @__PURE__ */ new Set();
54
+ } else updated = new Set(select.filter((c) => task.writes.some(([key, _]) => key === c)));
55
+ let values;
56
+ if (fresh && updated.size > 0) {
57
+ const localChannels = Object.fromEntries(Object.entries(channels).filter(([k, _]) => updated.has(k)));
58
+ const newCheckpoint = require_base.createCheckpoint(checkpoint, localChannels, -1);
59
+ const newChannels = require_base.emptyChannels(localChannels, newCheckpoint);
60
+ _applyWrites((0, __langchain_langgraph_checkpoint.copyCheckpoint)(newCheckpoint), newChannels, [task], void 0, void 0);
61
+ values = require_io.readChannels({
62
+ ...channels,
63
+ ...newChannels
64
+ }, select);
65
+ } else values = require_io.readChannels(channels, select);
66
+ return values;
83
67
  }
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);
68
+ function _localWrite(commit, processes, writes) {
69
+ for (const [chan, value] of writes) if ([require_constants.PUSH, require_constants.TASKS].includes(chan) && value != null) {
70
+ if (!require_constants._isSend(value)) throw new require_errors.InvalidUpdateError(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(value)}`);
71
+ if (!(value.node in processes)) throw new require_errors.InvalidUpdateError(`Invalid node name "${value.node}" in Send packet`);
72
+ }
73
+ commit(writes);
100
74
  }
101
75
  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,
76
+ require_constants.NO_WRITES,
77
+ require_constants.PUSH,
78
+ require_constants.RESUME,
79
+ require_constants.INTERRUPT,
80
+ require_constants.RETURN,
81
+ require_constants.ERROR
108
82
  ]);
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
- }
83
+ function _applyWrites(checkpoint, channels, tasks, getNextVersion, triggerToNodes) {
84
+ tasks.sort((a, b) => {
85
+ const aPath = a.path?.slice(0, 3) || [];
86
+ const bPath = b.path?.slice(0, 3) || [];
87
+ for (let i = 0; i < Math.min(aPath.length, bPath.length); i += 1) {
88
+ if (aPath[i] < bPath[i]) return -1;
89
+ if (aPath[i] > bPath[i]) return 1;
90
+ }
91
+ return aPath.length - bPath.length;
92
+ });
93
+ const bumpStep = tasks.some((task) => task.triggers.length > 0);
94
+ const onlyChannels = require_base.getOnlyChannels(channels);
95
+ for (const task of tasks) {
96
+ checkpoint.versions_seen[task.name] ??= {};
97
+ for (const chan of task.triggers) if (chan in checkpoint.channel_versions) checkpoint.versions_seen[task.name][chan] = checkpoint.channel_versions[chan];
98
+ }
99
+ let maxVersion = maxChannelMapVersion(checkpoint.channel_versions);
100
+ const channelsToConsume = new Set(tasks.flatMap((task) => task.triggers).filter((chan) => !require_constants.RESERVED.includes(chan)));
101
+ let usedNewVersion = false;
102
+ for (const chan of channelsToConsume) if (chan in onlyChannels && onlyChannels[chan].consume()) {
103
+ if (getNextVersion !== void 0) {
104
+ checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
105
+ usedNewVersion = true;
106
+ }
107
+ }
108
+ const pendingWritesByChannel = {};
109
+ for (const task of tasks) for (const [chan, val] of task.writes) if (IGNORE.has(chan)) {} else if (chan in onlyChannels) {
110
+ pendingWritesByChannel[chan] ??= [];
111
+ pendingWritesByChannel[chan].push(val);
112
+ }
113
+ if (maxVersion != null && getNextVersion != null) maxVersion = usedNewVersion ? getNextVersion(maxVersion) : maxVersion;
114
+ const updatedChannels = /* @__PURE__ */ new Set();
115
+ for (const [chan, vals] of Object.entries(pendingWritesByChannel)) if (chan in onlyChannels) {
116
+ const channel = onlyChannels[chan];
117
+ let updated;
118
+ try {
119
+ updated = channel.update(vals);
120
+ } catch (e) {
121
+ if (e.name === require_errors.InvalidUpdateError.unminifiable_name) {
122
+ const wrappedError = new require_errors.InvalidUpdateError(`Invalid update for channel "${chan}" with values ${JSON.stringify(vals)}: ${e.message}`);
123
+ wrappedError.lc_error_code = e.lc_error_code;
124
+ throw wrappedError;
125
+ } else throw e;
126
+ }
127
+ if (updated && getNextVersion !== void 0) {
128
+ checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
129
+ if (channel.isAvailable()) updatedChannels.add(chan);
130
+ }
131
+ }
132
+ if (bumpStep) for (const chan in onlyChannels) {
133
+ if (!Object.prototype.hasOwnProperty.call(onlyChannels, chan)) continue;
134
+ const channel = onlyChannels[chan];
135
+ if (channel.isAvailable() && !updatedChannels.has(chan)) {
136
+ const updated = channel.update([]);
137
+ if (updated && getNextVersion !== void 0) {
138
+ checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
139
+ if (channel.isAvailable()) updatedChannels.add(chan);
140
+ }
141
+ }
142
+ }
143
+ if (bumpStep && !triggersNextStep(updatedChannels, triggerToNodes)) for (const chan in onlyChannels) {
144
+ if (!Object.prototype.hasOwnProperty.call(onlyChannels, chan)) continue;
145
+ const channel = onlyChannels[chan];
146
+ if (channel.finish() && getNextVersion !== void 0) {
147
+ checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
148
+ if (channel.isAvailable()) updatedChannels.add(chan);
149
+ }
150
+ }
151
+ return updatedChannels;
152
+ }
153
+ function* candidateNodes(checkpoint, processes, extra) {
154
+ if (extra.updatedChannels != null && extra.triggerToNodes != null) {
155
+ const triggeredNodes = /* @__PURE__ */ new Set();
156
+ for (const channel of extra.updatedChannels) {
157
+ const nodeIds = extra.triggerToNodes[channel];
158
+ for (const id of nodeIds ?? []) triggeredNodes.add(id);
159
+ }
160
+ yield* [...triggeredNodes].sort();
161
+ return;
162
+ }
163
+ const isEmptyChannelVersions = (() => {
164
+ for (const chan in checkpoint.channel_versions) if (checkpoint.channel_versions[chan] !== null) return false;
165
+ return true;
166
+ })();
167
+ if (isEmptyChannelVersions) return;
168
+ for (const name in processes) {
169
+ if (!Object.prototype.hasOwnProperty.call(processes, name)) continue;
170
+ yield name;
171
+ }
230
172
  }
231
173
  /**
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
- */
174
+ * Prepare the set of tasks that will make up the next Pregel step.
175
+ * This is the union of all PUSH tasks (Sends) and PULL tasks (nodes triggered
176
+ * by edges).
177
+ */
236
178
  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;
179
+ const tasks = {};
180
+ const tasksChannel = channels[require_constants.TASKS];
181
+ if (tasksChannel?.isAvailable()) {
182
+ const len = tasksChannel.get().length;
183
+ for (let i = 0; i < len; i += 1) {
184
+ const task = _prepareSingleTask([require_constants.PUSH, i], checkpoint, pendingWrites, processes, channels, config, forExecution, extra);
185
+ if (task !== void 0) tasks[task.id] = task;
186
+ }
187
+ }
188
+ for (const name of candidateNodes(checkpoint, processes, extra)) {
189
+ const task = _prepareSingleTask([require_constants.PULL, name], checkpoint, pendingWrites, processes, channels, config, forExecution, extra);
190
+ if (task !== void 0) tasks[task.id] = task;
191
+ }
192
+ return tasks;
260
193
  }
261
194
  /**
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
- */
195
+ * Prepares a single task for the next Pregel step, given a task path, which
196
+ * uniquely identifies a PUSH or PULL task within the graph.
197
+ */
265
198
  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;
199
+ const { step, checkpointer, manager } = extra;
200
+ const configurable = config.configurable ?? {};
201
+ const parentNamespace = configurable.checkpoint_ns ?? "";
202
+ if (taskPath[0] === require_constants.PUSH && require_types.isCall(taskPath[taskPath.length - 1])) {
203
+ const call = taskPath[taskPath.length - 1];
204
+ const proc = require_call.getRunnableForFunc(call.name, call.func);
205
+ const triggers = [require_constants.PUSH];
206
+ const checkpointNamespace = parentNamespace === "" ? call.name : `${parentNamespace}${require_constants.CHECKPOINT_NAMESPACE_SEPARATOR}${call.name}`;
207
+ const id = (0, __langchain_langgraph_checkpoint.uuid5)(JSON.stringify([
208
+ checkpointNamespace,
209
+ step.toString(),
210
+ call.name,
211
+ require_constants.PUSH,
212
+ taskPath[1],
213
+ taskPath[2]
214
+ ]), checkpoint.id);
215
+ const taskCheckpointNamespace = `${checkpointNamespace}${require_constants.CHECKPOINT_NAMESPACE_END}${id}`;
216
+ const outputTaskPath = [...taskPath.slice(0, 3), true];
217
+ const metadata = {
218
+ langgraph_step: step,
219
+ langgraph_node: call.name,
220
+ langgraph_triggers: triggers,
221
+ langgraph_path: outputTaskPath,
222
+ langgraph_checkpoint_ns: taskCheckpointNamespace
223
+ };
224
+ if (forExecution) {
225
+ const writes = [];
226
+ const task = {
227
+ name: call.name,
228
+ input: call.input,
229
+ proc,
230
+ writes,
231
+ config: (0, __langchain_core_runnables.patchConfig)((0, __langchain_core_runnables.mergeConfigs)(config, {
232
+ metadata,
233
+ store: extra.store ?? config.store
234
+ }), {
235
+ runName: call.name,
236
+ callbacks: manager?.getChild(`graph:step:${step}`),
237
+ configurable: {
238
+ [require_constants.CONFIG_KEY_TASK_ID]: id,
239
+ [require_constants.CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => writes.push(...items), processes, writes_),
240
+ [require_constants.CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
241
+ name: call.name,
242
+ writes,
243
+ triggers,
244
+ path: outputTaskPath
245
+ }, select_, fresh_),
246
+ [require_constants.CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[require_constants.CONFIG_KEY_CHECKPOINTER],
247
+ [require_constants.CONFIG_KEY_CHECKPOINT_MAP]: {
248
+ ...configurable[require_constants.CONFIG_KEY_CHECKPOINT_MAP],
249
+ [parentNamespace]: checkpoint.id
250
+ },
251
+ [require_constants.CONFIG_KEY_SCRATCHPAD]: _scratchpad({
252
+ pendingWrites: pendingWrites ?? [],
253
+ taskId: id,
254
+ currentTaskInput: call.input,
255
+ resumeMap: config.configurable?.[require_constants.CONFIG_KEY_RESUME_MAP],
256
+ namespaceHash: require_hash.XXH3(taskCheckpointNamespace)
257
+ }),
258
+ [require_constants.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[require_constants.PREVIOUS],
259
+ checkpoint_id: void 0,
260
+ checkpoint_ns: taskCheckpointNamespace
261
+ }
262
+ }),
263
+ triggers,
264
+ retry_policy: call.retry,
265
+ cache_key: call.cache ? {
266
+ key: require_hash.XXH3((call.cache.keyFunc ?? JSON.stringify)([call.input])),
267
+ ns: [require_constants.CACHE_NS_WRITES, call.name ?? "__dynamic__"],
268
+ ttl: call.cache.ttl
269
+ } : void 0,
270
+ id,
271
+ path: outputTaskPath,
272
+ writers: []
273
+ };
274
+ return task;
275
+ } else return {
276
+ id,
277
+ name: call.name,
278
+ interrupts: [],
279
+ path: outputTaskPath
280
+ };
281
+ } else if (taskPath[0] === require_constants.PUSH) {
282
+ const index = typeof taskPath[1] === "number" ? taskPath[1] : parseInt(taskPath[1], 10);
283
+ if (!channels[require_constants.TASKS]?.isAvailable()) return void 0;
284
+ const sends = channels[require_constants.TASKS].get();
285
+ if (index < 0 || index >= sends.length) return void 0;
286
+ const packet = require_constants._isSendInterface(sends[index]) && !require_constants._isSend(sends[index]) ? new require_constants.Send(sends[index].node, sends[index].args) : sends[index];
287
+ if (!require_constants._isSendInterface(packet)) {
288
+ console.warn(`Ignoring invalid packet ${JSON.stringify(packet)} in pending sends.`);
289
+ return void 0;
290
+ }
291
+ if (!(packet.node in processes)) {
292
+ console.warn(`Ignoring unknown node name ${packet.node} in pending sends.`);
293
+ return void 0;
294
+ }
295
+ const triggers = [require_constants.PUSH];
296
+ const checkpointNamespace = parentNamespace === "" ? packet.node : `${parentNamespace}${require_constants.CHECKPOINT_NAMESPACE_SEPARATOR}${packet.node}`;
297
+ const taskId = (0, __langchain_langgraph_checkpoint.uuid5)(JSON.stringify([
298
+ checkpointNamespace,
299
+ step.toString(),
300
+ packet.node,
301
+ require_constants.PUSH,
302
+ index.toString()
303
+ ]), checkpoint.id);
304
+ const taskCheckpointNamespace = `${checkpointNamespace}${require_constants.CHECKPOINT_NAMESPACE_END}${taskId}`;
305
+ let metadata = {
306
+ langgraph_step: step,
307
+ langgraph_node: packet.node,
308
+ langgraph_triggers: triggers,
309
+ langgraph_path: taskPath.slice(0, 3),
310
+ langgraph_checkpoint_ns: taskCheckpointNamespace
311
+ };
312
+ if (forExecution) {
313
+ const proc = processes[packet.node];
314
+ const node = proc.getNode();
315
+ if (node !== void 0) {
316
+ if (proc.metadata !== void 0) metadata = {
317
+ ...metadata,
318
+ ...proc.metadata
319
+ };
320
+ const writes = [];
321
+ return {
322
+ name: packet.node,
323
+ input: packet.args,
324
+ proc: node,
325
+ subgraphs: proc.subgraphs,
326
+ writes,
327
+ config: (0, __langchain_core_runnables.patchConfig)((0, __langchain_core_runnables.mergeConfigs)(config, {
328
+ metadata,
329
+ tags: proc.tags,
330
+ store: extra.store ?? config.store
331
+ }), {
332
+ runName: packet.node,
333
+ callbacks: manager?.getChild(`graph:step:${step}`),
334
+ configurable: {
335
+ [require_constants.CONFIG_KEY_TASK_ID]: taskId,
336
+ [require_constants.CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => writes.push(...items), processes, writes_),
337
+ [require_constants.CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
338
+ name: packet.node,
339
+ writes,
340
+ triggers,
341
+ path: taskPath
342
+ }, select_, fresh_),
343
+ [require_constants.CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[require_constants.CONFIG_KEY_CHECKPOINTER],
344
+ [require_constants.CONFIG_KEY_CHECKPOINT_MAP]: {
345
+ ...configurable[require_constants.CONFIG_KEY_CHECKPOINT_MAP],
346
+ [parentNamespace]: checkpoint.id
347
+ },
348
+ [require_constants.CONFIG_KEY_SCRATCHPAD]: _scratchpad({
349
+ pendingWrites: pendingWrites ?? [],
350
+ taskId,
351
+ currentTaskInput: packet.args,
352
+ resumeMap: config.configurable?.[require_constants.CONFIG_KEY_RESUME_MAP],
353
+ namespaceHash: require_hash.XXH3(taskCheckpointNamespace)
354
+ }),
355
+ [require_constants.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[require_constants.PREVIOUS],
356
+ checkpoint_id: void 0,
357
+ checkpoint_ns: taskCheckpointNamespace
358
+ }
359
+ }),
360
+ triggers,
361
+ retry_policy: proc.retryPolicy,
362
+ cache_key: proc.cachePolicy ? {
363
+ key: require_hash.XXH3((proc.cachePolicy.keyFunc ?? JSON.stringify)([packet.args])),
364
+ ns: [
365
+ require_constants.CACHE_NS_WRITES,
366
+ proc.name ?? "__dynamic__",
367
+ packet.node
368
+ ],
369
+ ttl: proc.cachePolicy.ttl
370
+ } : void 0,
371
+ id: taskId,
372
+ path: taskPath,
373
+ writers: proc.getWriters()
374
+ };
375
+ }
376
+ } else return {
377
+ id: taskId,
378
+ name: packet.node,
379
+ interrupts: [],
380
+ path: taskPath
381
+ };
382
+ } else if (taskPath[0] === require_constants.PULL) {
383
+ const name = taskPath[1].toString();
384
+ const proc = processes[name];
385
+ if (proc === void 0) return void 0;
386
+ if (pendingWrites?.length) {
387
+ const checkpointNamespace = parentNamespace === "" ? name : `${parentNamespace}${require_constants.CHECKPOINT_NAMESPACE_SEPARATOR}${name}`;
388
+ const taskId = (0, __langchain_langgraph_checkpoint.uuid5)(JSON.stringify([
389
+ checkpointNamespace,
390
+ step.toString(),
391
+ name,
392
+ require_constants.PULL,
393
+ name
394
+ ]), checkpoint.id);
395
+ const hasSuccessfulWrites = pendingWrites.some((w) => w[0] === taskId && w[1] !== require_constants.ERROR);
396
+ if (hasSuccessfulWrites) return void 0;
397
+ }
398
+ const nullVersion = require_index.getNullChannelVersion(checkpoint.channel_versions);
399
+ if (nullVersion === void 0) return void 0;
400
+ const seen = checkpoint.versions_seen[name] ?? {};
401
+ const trigger = proc.triggers.find((chan) => {
402
+ if (!channels[chan].isAvailable()) return false;
403
+ return (checkpoint.channel_versions[chan] ?? nullVersion) > (seen[chan] ?? nullVersion);
404
+ });
405
+ if (trigger !== void 0) {
406
+ const val = _procInput(proc, channels, forExecution);
407
+ if (val === void 0) return void 0;
408
+ const checkpointNamespace = parentNamespace === "" ? name : `${parentNamespace}${require_constants.CHECKPOINT_NAMESPACE_SEPARATOR}${name}`;
409
+ const taskId = (0, __langchain_langgraph_checkpoint.uuid5)(JSON.stringify([
410
+ checkpointNamespace,
411
+ step.toString(),
412
+ name,
413
+ require_constants.PULL,
414
+ [trigger]
415
+ ]), checkpoint.id);
416
+ const taskCheckpointNamespace = `${checkpointNamespace}${require_constants.CHECKPOINT_NAMESPACE_END}${taskId}`;
417
+ let metadata = {
418
+ langgraph_step: step,
419
+ langgraph_node: name,
420
+ langgraph_triggers: [trigger],
421
+ langgraph_path: taskPath,
422
+ langgraph_checkpoint_ns: taskCheckpointNamespace
423
+ };
424
+ if (forExecution) {
425
+ const node = proc.getNode();
426
+ if (node !== void 0) {
427
+ if (proc.metadata !== void 0) metadata = {
428
+ ...metadata,
429
+ ...proc.metadata
430
+ };
431
+ const writes = [];
432
+ return {
433
+ name,
434
+ input: val,
435
+ proc: node,
436
+ subgraphs: proc.subgraphs,
437
+ writes,
438
+ config: (0, __langchain_core_runnables.patchConfig)((0, __langchain_core_runnables.mergeConfigs)(config, {
439
+ metadata,
440
+ tags: proc.tags,
441
+ store: extra.store ?? config.store
442
+ }), {
443
+ runName: name,
444
+ callbacks: manager?.getChild(`graph:step:${step}`),
445
+ configurable: {
446
+ [require_constants.CONFIG_KEY_TASK_ID]: taskId,
447
+ [require_constants.CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => {
448
+ writes.push(...items);
449
+ }, processes, writes_),
450
+ [require_constants.CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
451
+ name,
452
+ writes,
453
+ triggers: [trigger],
454
+ path: taskPath
455
+ }, select_, fresh_),
456
+ [require_constants.CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[require_constants.CONFIG_KEY_CHECKPOINTER],
457
+ [require_constants.CONFIG_KEY_CHECKPOINT_MAP]: {
458
+ ...configurable[require_constants.CONFIG_KEY_CHECKPOINT_MAP],
459
+ [parentNamespace]: checkpoint.id
460
+ },
461
+ [require_constants.CONFIG_KEY_SCRATCHPAD]: _scratchpad({
462
+ pendingWrites: pendingWrites ?? [],
463
+ taskId,
464
+ currentTaskInput: val,
465
+ resumeMap: config.configurable?.[require_constants.CONFIG_KEY_RESUME_MAP],
466
+ namespaceHash: require_hash.XXH3(taskCheckpointNamespace)
467
+ }),
468
+ [require_constants.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[require_constants.PREVIOUS],
469
+ checkpoint_id: void 0,
470
+ checkpoint_ns: taskCheckpointNamespace
471
+ }
472
+ }),
473
+ triggers: [trigger],
474
+ retry_policy: proc.retryPolicy,
475
+ cache_key: proc.cachePolicy ? {
476
+ key: require_hash.XXH3((proc.cachePolicy.keyFunc ?? JSON.stringify)([val])),
477
+ ns: [
478
+ require_constants.CACHE_NS_WRITES,
479
+ proc.name ?? "__dynamic__",
480
+ name
481
+ ],
482
+ ttl: proc.cachePolicy.ttl
483
+ } : void 0,
484
+ id: taskId,
485
+ path: taskPath,
486
+ writers: proc.getWriters()
487
+ };
488
+ }
489
+ } else return {
490
+ id: taskId,
491
+ name,
492
+ interrupts: [],
493
+ path: taskPath
494
+ };
495
+ }
496
+ }
497
+ return void 0;
609
498
  }
610
499
  /**
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
- */
500
+ * Function injected under CONFIG_KEY_READ in task config, to read current state.
501
+ * Used by conditional edges to read a copy of the state with reflecting the writes
502
+ * from that node only.
503
+ *
504
+ * @internal
505
+ */
617
506
  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;
507
+ let val;
508
+ if (typeof proc.channels === "object" && !Array.isArray(proc.channels)) {
509
+ val = {};
510
+ for (const [k, chan] of Object.entries(proc.channels)) if (proc.triggers.includes(chan)) try {
511
+ val[k] = require_io.readChannel(channels, chan, false);
512
+ } catch (e) {
513
+ if (e.name === require_errors.EmptyChannelError.unminifiable_name) return void 0;
514
+ else throw e;
515
+ }
516
+ else if (chan in channels) try {
517
+ val[k] = require_io.readChannel(channels, chan, false);
518
+ } catch (e) {
519
+ if (e.name === require_errors.EmptyChannelError.unminifiable_name) continue;
520
+ else throw e;
521
+ }
522
+ } else if (Array.isArray(proc.channels)) {
523
+ let successfulRead = false;
524
+ for (const chan of proc.channels) try {
525
+ val = require_io.readChannel(channels, chan, false);
526
+ successfulRead = true;
527
+ break;
528
+ } catch (e) {
529
+ if (e.name === require_errors.EmptyChannelError.unminifiable_name) continue;
530
+ else throw e;
531
+ }
532
+ if (!successfulRead) return void 0;
533
+ } else throw new Error(`Invalid channels type, expected list or dict, got ${proc.channels}`);
534
+ if (forExecution && proc.mapper !== void 0) val = proc.mapper(val);
535
+ return val;
683
536
  }
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;
537
+ function _scratchpad({ pendingWrites, taskId, currentTaskInput, resumeMap, namespaceHash }) {
538
+ const nullResume = pendingWrites.find(([writeTaskId, chan]) => writeTaskId === require_constants.NULL_TASK_ID && chan === require_constants.RESUME)?.[2];
539
+ const resume = (() => {
540
+ const result = pendingWrites.filter(([writeTaskId, chan]) => writeTaskId === taskId && chan === require_constants.RESUME).flatMap(([_writeTaskId, _chan, resume$1]) => resume$1);
541
+ if (resumeMap != null && namespaceHash in resumeMap) {
542
+ const mappedResume = resumeMap[namespaceHash];
543
+ result.push(mappedResume);
544
+ }
545
+ return result;
546
+ })();
547
+ const scratchpad = {
548
+ callCounter: 0,
549
+ interruptCounter: -1,
550
+ resume,
551
+ nullResume,
552
+ subgraphCounter: 0,
553
+ currentTaskInput,
554
+ consumeNullResume: () => {
555
+ if (scratchpad.nullResume) {
556
+ delete scratchpad.nullResume;
557
+ pendingWrites.splice(pendingWrites.findIndex(([writeTaskId, chan]) => writeTaskId === require_constants.NULL_TASK_ID && chan === require_constants.RESUME), 1);
558
+ return nullResume;
559
+ }
560
+ return void 0;
561
+ }
562
+ };
563
+ return scratchpad;
713
564
  }
714
- //# sourceMappingURL=algo.js.map
565
+
566
+ //#endregion
567
+ exports._applyWrites = _applyWrites;
568
+ exports._localRead = _localRead;
569
+ exports._prepareNextTasks = _prepareNextTasks;
570
+ exports._prepareSingleTask = _prepareSingleTask;
571
+ exports.increment = increment;
572
+ exports.shouldInterrupt = shouldInterrupt;
573
+ //# sourceMappingURL=algo.cjs.map