@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,15 +1,18 @@
1
- import { Runnable, RunnableConfig, RunnableFunc } from "@langchain/core/runnables";
2
- import type { StreamEvent } from "@langchain/core/tracers/log_stream";
3
- import { IterableReadableStream } from "@langchain/core/utils/stream";
4
- import { All, BaseCache, BaseCheckpointSaver, BaseStore, CheckpointListOptions, CheckpointTuple } from "@langchain/langgraph-checkpoint";
5
1
  import { BaseChannel } from "../channels/base.js";
6
- import { Command, type CommandInstance } from "../constants.js";
7
- import { StrRecord } from "./algo.js";
8
- import { PregelNode } from "./read.js";
9
2
  import { LangGraphRunnableConfig } from "./runnable_types.js";
10
- import type { Durability, GetStateOptions, MultipleChannelSubscriptionOptions, PregelInputType, PregelInterface, PregelOptions, PregelOutputType, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./types.js";
11
3
  import { RetryPolicy } from "./utils/index.js";
4
+ import { PregelNode } from "./read.js";
5
+ import { Command, CommandInstance } from "../constants.js";
6
+ import { Durability, GetStateOptions, MultipleChannelSubscriptionOptions, PregelInputType, PregelInterface, PregelOptions, PregelOutputType, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./types.js";
7
+ import { StrRecord } from "./algo.js";
12
8
  import { ChannelWrite } from "./write.js";
9
+ import { All, BaseCache, BaseCheckpointSaver, BaseStore, CheckpointListOptions, CheckpointTuple } from "@langchain/langgraph-checkpoint";
10
+ import { Runnable, RunnableConfig, RunnableFunc } from "@langchain/core/runnables";
11
+ import * as _langchain_core_runnables_graph0 from "@langchain/core/runnables/graph";
12
+ import { IterableReadableStream } from "@langchain/core/utils/stream";
13
+ import { StreamEvent } from "@langchain/core/tracers/log_stream";
14
+
15
+ //#region src/pregel/index.d.ts
13
16
  type WriteValue = Runnable | RunnableFunc<unknown, unknown> | unknown;
14
17
  type StreamEventsOptions = Parameters<Runnable["streamEvents"]>[2];
15
18
  /**
@@ -19,84 +22,93 @@ type StreamEventsOptions = Parameters<Runnable["streamEvents"]>[2];
19
22
  * Channels are the communication pathways between nodes in a Pregel graph.
20
23
  * They enable message passing and state updates between different parts of the graph.
21
24
  */
22
- export declare class Channel {
23
- /**
24
- * Creates a PregelNode that subscribes to a single channel.
25
- * This is used to define how nodes receive input from channels.
26
- *
27
- * @example
28
- * ```typescript
29
- * // Subscribe to a single channel
30
- * const node = Channel.subscribeTo("messages");
31
- *
32
- * // Subscribe to multiple channels
33
- * const node = Channel.subscribeTo(["messages", "state"]);
34
- *
35
- * // Subscribe with a custom key
36
- * const node = Channel.subscribeTo("messages", { key: "chat" });
37
- * ```
38
- *
39
- * @param channel - Single channel name to subscribe to
40
- * @param options - Subscription options
41
- * @returns A PregelNode configured to receive from the specified channels
42
- * @throws {Error} If a key is specified when subscribing to multiple channels
43
- */
44
- static subscribeTo(channel: string, options?: SingleChannelSubscriptionOptions): PregelNode;
45
- /**
46
- * Creates a PregelNode that subscribes to multiple channels.
47
- * This is used to define how nodes receive input from channels.
48
- *
49
- * @example
50
- * ```typescript
51
- * // Subscribe to a single channel
52
- * const node = Channel.subscribeTo("messages");
53
- *
54
- * // Subscribe to multiple channels
55
- * const node = Channel.subscribeTo(["messages", "state"]);
56
- *
57
- * // Subscribe with a custom key
58
- * const node = Channel.subscribeTo("messages", { key: "chat" });
59
- * ```
60
- *
61
- * @param channel - Single channel name to subscribe to
62
- * @param options - Subscription options
63
- * @returns A PregelNode configured to receive from the specified channels
64
- * @throws {Error} If a key is specified when subscribing to multiple channels
65
- */
66
- static subscribeTo(channels: string[], options?: MultipleChannelSubscriptionOptions): PregelNode;
67
- /**
68
- * Creates a ChannelWrite that specifies how to write values to channels.
69
- * This is used to define how nodes send output to channels.
70
- *
71
- * @example
72
- * ```typescript
73
- * // Write to multiple channels
74
- * const write = Channel.writeTo(["output", "state"]);
75
- *
76
- * // Write with specific values
77
- * const write = Channel.writeTo(["output"], {
78
- * state: "completed",
79
- * result: calculateResult()
80
- * });
81
- *
82
- * // Write with a transformation function
83
- * const write = Channel.writeTo(["output"], {
84
- * result: (x) => processResult(x)
85
- * });
86
- * ```
87
- *
88
- * @param channels - Array of channel names to write to
89
- * @param writes - Optional map of channel names to values or transformations
90
- * @returns A ChannelWrite object that can be used to write to the specified channels
91
- */
92
- static writeTo(channels: string[], writes?: Record<string, WriteValue>): ChannelWrite;
25
+ declare class Channel {
26
+ /**
27
+ * Creates a PregelNode that subscribes to a single channel.
28
+ * This is used to define how nodes receive input from channels.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * // Subscribe to a single channel
33
+ * const node = Channel.subscribeTo("messages");
34
+ *
35
+ * // Subscribe to multiple channels
36
+ * const node = Channel.subscribeTo(["messages", "state"]);
37
+ *
38
+ * // Subscribe with a custom key
39
+ * const node = Channel.subscribeTo("messages", { key: "chat" });
40
+ * ```
41
+ *
42
+ * @param channel - Single channel name to subscribe to
43
+ * @param options - Subscription options
44
+ * @returns A PregelNode configured to receive from the specified channels
45
+ * @throws {Error} If a key is specified when subscribing to multiple channels
46
+ */
47
+ static subscribeTo(channel: string, options?: SingleChannelSubscriptionOptions): PregelNode;
48
+ /**
49
+ * Creates a PregelNode that subscribes to multiple channels.
50
+ * This is used to define how nodes receive input from channels.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // Subscribe to a single channel
55
+ * const node = Channel.subscribeTo("messages");
56
+ *
57
+ * // Subscribe to multiple channels
58
+ * const node = Channel.subscribeTo(["messages", "state"]);
59
+ *
60
+ * // Subscribe with a custom key
61
+ * const node = Channel.subscribeTo("messages", { key: "chat" });
62
+ * ```
63
+ *
64
+ * @param channel - Single channel name to subscribe to
65
+ * @param options - Subscription options
66
+ * @returns A PregelNode configured to receive from the specified channels
67
+ * @throws {Error} If a key is specified when subscribing to multiple channels
68
+ */
69
+ static subscribeTo(channels: string[], options?: MultipleChannelSubscriptionOptions): PregelNode;
70
+ /**
71
+ * Creates a ChannelWrite that specifies how to write values to channels.
72
+ * This is used to define how nodes send output to channels.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * // Write to multiple channels
77
+ * const write = Channel.writeTo(["output", "state"]);
78
+ *
79
+ * // Write with specific values
80
+ * const write = Channel.writeTo(["output"], {
81
+ * state: "completed",
82
+ * result: calculateResult()
83
+ * });
84
+ *
85
+ * // Write with a transformation function
86
+ * const write = Channel.writeTo(["output"], {
87
+ * result: (x) => processResult(x)
88
+ * });
89
+ * ```
90
+ *
91
+ * @param channels - Array of channel names to write to
92
+ * @param writes - Optional map of channel names to values or transformations
93
+ * @returns A ChannelWrite object that can be used to write to the specified channels
94
+ */
95
+ static writeTo(channels: string[], writes?: Record<string, WriteValue>): ChannelWrite;
93
96
  }
94
- export type { PregelInputType, PregelOptions, PregelOutputType };
97
+ // This is a workaround to allow Pregel to override `invoke` / `stream` and `withConfig`
98
+ // without having to adhere to the types in the `Runnable` class (thanks to `any`).
99
+ // Alternatively we could mark those methods with @ts-ignore / @ts-expect-error,
100
+ // but these do not get carried over when building via `tsc`.
95
101
  declare class PartialRunnable<RunInput, RunOutput, CallOptions extends RunnableConfig> extends Runnable<RunInput, RunOutput, CallOptions> {
96
- lc_namespace: string[];
97
- invoke(_input: RunInput, _options?: Partial<CallOptions>): Promise<any>;
98
- withConfig(_config: CallOptions): typeof this;
99
- stream(input: RunInput, options?: Partial<CallOptions>): Promise<IterableReadableStream<any>>;
102
+ lc_namespace: string[];
103
+ invoke(_input: RunInput, _options?: Partial<CallOptions>
104
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
+ ): Promise<any>;
106
+ // Overriden by `Pregel`
107
+ withConfig(_config: CallOptions): typeof this;
108
+ // Overriden by `Pregel`
109
+ stream(input: RunInput, options?: Partial<CallOptions>
110
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
+ ): Promise<IterableReadableStream<any>>;
100
112
  }
101
113
  /**
102
114
  * The Pregel class is the core runtime engine of LangGraph, implementing a message-passing graph computation model
@@ -157,342 +169,368 @@ declare class PartialRunnable<RunInput, RunOutput, CallOptions extends RunnableC
157
169
  * @typeParam InputType - Type of input values accepted by the graph
158
170
  * @typeParam OutputType - Type of output values produced by the graph
159
171
  */
160
- export declare class Pregel<Nodes extends StrRecord<string, PregelNode>, Channels extends StrRecord<string, BaseChannel>, ContextType extends Record<string, any> = StrRecord<string, any>, InputType = PregelInputType, OutputType = PregelOutputType, StreamUpdatesType = InputType, StreamValuesType = OutputType, NodeReturnType = unknown> extends PartialRunnable<InputType | CommandInstance | null, OutputType, PregelOptions<Nodes, Channels, ContextType>> implements PregelInterface<Nodes, Channels, ContextType>, PregelParams<Nodes, Channels> {
161
- /**
162
- * Name of the class when serialized
163
- * @internal
164
- */
165
- static lc_name(): string;
166
- /** @internal Used for type inference */
167
- "~InputType": InputType;
168
- /** @internal Used for type inference */
169
- "~OutputType": OutputType;
170
- /** @internal LangChain namespace for serialization necessary because Pregel extends Runnable */
171
- lc_namespace: string[];
172
- /** @internal Flag indicating this is a Pregel instance - necessary for serialization */
173
- lg_is_pregel: boolean;
174
- /** The nodes in the graph, mapping node names to their PregelNode instances */
175
- nodes: Nodes;
176
- /** The channels in the graph, mapping channel names to their BaseChannel or ManagedValueSpec instances */
177
- channels: Channels;
178
- /**
179
- * The input channels for the graph. These channels receive the initial input when the graph is invoked.
180
- * Can be a single channel key or an array of channel keys.
181
- */
182
- inputChannels: keyof Channels | Array<keyof Channels>;
183
- /**
184
- * The output channels for the graph. These channels contain the final output when the graph completes.
185
- * Can be a single channel key or an array of channel keys.
186
- */
187
- outputChannels: keyof Channels | Array<keyof Channels>;
188
- /** Whether to automatically validate the graph structure when it is compiled. Defaults to true. */
189
- autoValidate: boolean;
190
- /**
191
- * The streaming modes enabled for this graph. Defaults to ["values"].
192
- * Supported modes:
193
- * - "values": Streams the full state after each step
194
- * - "updates": Streams state updates after each step
195
- * - "messages": Streams messages from within nodes
196
- * - "custom": Streams custom events from within nodes
197
- * - "debug": Streams events related to the execution of the graph - useful for tracing & debugging graph execution
198
- */
199
- streamMode: StreamMode[];
200
- /**
201
- * Optional channels to stream. If not specified, all channels will be streamed.
202
- * Can be a single channel key or an array of channel keys.
203
- */
204
- streamChannels?: keyof Channels | Array<keyof Channels>;
205
- /**
206
- * Optional array of node names or "all" to interrupt after executing these nodes.
207
- * Used for implementing human-in-the-loop workflows.
208
- */
209
- interruptAfter?: Array<keyof Nodes> | All;
210
- /**
211
- * Optional array of node names or "all" to interrupt before executing these nodes.
212
- * Used for implementing human-in-the-loop workflows.
213
- */
214
- interruptBefore?: Array<keyof Nodes> | All;
215
- /** Optional timeout in milliseconds for the execution of each superstep */
216
- stepTimeout?: number;
217
- /** Whether to enable debug logging. Defaults to false. */
218
- debug: boolean;
219
- /**
220
- * Optional checkpointer for persisting graph state.
221
- * When provided, saves a checkpoint of the graph state at every superstep.
222
- * When false or undefined, checkpointing is disabled, and the graph will not be able to save or restore state.
223
- */
224
- checkpointer?: BaseCheckpointSaver | boolean;
225
- /** Optional retry policy for handling failures in node execution */
226
- retryPolicy?: RetryPolicy;
227
- /** The default configuration for graph execution, can be overridden on a per-invocation basis */
228
- config?: LangGraphRunnableConfig;
229
- /**
230
- * Optional long-term memory store for the graph, allows for persistence & retrieval of data across threads
231
- */
232
- store?: BaseStore;
233
- triggerToNodes: Record<string, string[]>;
234
- /**
235
- * Optional cache for the graph, useful for caching tasks.
236
- */
237
- cache?: BaseCache;
238
- /**
239
- * Constructor for Pregel - meant for internal use only.
240
- *
241
- * @internal
242
- */
243
- constructor(fields: PregelParams<Nodes, Channels>);
244
- /**
245
- * Creates a new instance of the Pregel graph with updated configuration.
246
- * This method follows the immutable pattern - instead of modifying the current instance,
247
- * it returns a new instance with the merged configuration.
248
- *
249
- * @example
250
- * ```typescript
251
- * // Create a new instance with debug enabled
252
- * const debugGraph = graph.withConfig({ debug: true });
253
- *
254
- * // Create a new instance with a specific thread ID
255
- * const threadGraph = graph.withConfig({
256
- * configurable: { thread_id: "123" }
257
- * });
258
- * ```
259
- *
260
- * @param config - The configuration to merge with the current configuration
261
- * @returns A new Pregel instance with the merged configuration
262
- */
263
- withConfig(config: Omit<LangGraphRunnableConfig, "store" | "writer">): typeof this;
264
- /**
265
- * Validates the graph structure to ensure it is well-formed.
266
- * Checks for:
267
- * - No orphaned nodes
268
- * - Valid input/output channel configurations
269
- * - Valid interrupt configurations
270
- *
271
- * @returns this - The Pregel instance for method chaining
272
- * @throws {GraphValidationError} If the graph structure is invalid
273
- */
274
- validate(): this;
275
- /**
276
- * Gets a list of all channels that should be streamed.
277
- * If streamChannels is specified, returns those channels.
278
- * Otherwise, returns all channels in the graph.
279
- *
280
- * @returns Array of channel keys to stream
281
- */
282
- get streamChannelsList(): Array<keyof Channels>;
283
- /**
284
- * Gets the channels to stream in their original format.
285
- * If streamChannels is specified, returns it as-is (either single key or array).
286
- * Otherwise, returns all channels in the graph as an array.
287
- *
288
- * @returns Channel keys to stream, either as a single key or array
289
- */
290
- get streamChannelsAsIs(): keyof Channels | Array<keyof Channels>;
291
- /**
292
- * Gets a drawable representation of the graph structure.
293
- * This is an async version of getGraph() and is the preferred method to use.
294
- *
295
- * @param config - Configuration for generating the graph visualization
296
- * @returns A representation of the graph that can be visualized
297
- */
298
- getGraphAsync(config: RunnableConfig): Promise<import("@langchain/core/runnables/graph").Graph>;
299
- /**
300
- * Gets all subgraphs within this graph.
301
- * A subgraph is a Pregel instance that is nested within a node of this graph.
302
- *
303
- * @deprecated Use getSubgraphsAsync instead. The async method will become the default in the next minor release.
304
- * @param namespace - Optional namespace to filter subgraphs
305
- * @param recurse - Whether to recursively get subgraphs of subgraphs
306
- * @returns Generator yielding tuples of [name, subgraph]
307
- */
308
- getSubgraphs(namespace?: string, recurse?: boolean): Generator<[string, Pregel<any, any>]>;
309
- /**
310
- * Gets all subgraphs within this graph asynchronously.
311
- * A subgraph is a Pregel instance that is nested within a node of this graph.
312
- *
313
- * @param namespace - Optional namespace to filter subgraphs
314
- * @param recurse - Whether to recursively get subgraphs of subgraphs
315
- * @returns AsyncGenerator yielding tuples of [name, subgraph]
316
- */
317
- getSubgraphsAsync(namespace?: string, recurse?: boolean): AsyncGenerator<[string, Pregel<any, any>]>;
318
- /**
319
- * Prepares a state snapshot from saved checkpoint data.
320
- * This is an internal method used by getState and getStateHistory.
321
- *
322
- * @param config - Configuration for preparing the snapshot
323
- * @param saved - Optional saved checkpoint data
324
- * @param subgraphCheckpointer - Optional checkpointer for subgraphs
325
- * @param applyPendingWrites - Whether to apply pending writes to tasks and then to channels
326
- * @returns A snapshot of the graph state
327
- * @internal
328
- */
329
- protected _prepareStateSnapshot({ config, saved, subgraphCheckpointer, applyPendingWrites, }: {
330
- config: RunnableConfig;
331
- saved?: CheckpointTuple;
332
- subgraphCheckpointer?: BaseCheckpointSaver;
333
- applyPendingWrites?: boolean;
334
- }): Promise<StateSnapshot>;
335
- /**
336
- * Gets the current state of the graph.
337
- * Requires a checkpointer to be configured.
338
- *
339
- * @param config - Configuration for retrieving the state
340
- * @param options - Additional options
341
- * @returns A snapshot of the current graph state
342
- * @throws {GraphValueError} If no checkpointer is configured
343
- */
344
- getState(config: RunnableConfig, options?: GetStateOptions): Promise<StateSnapshot>;
345
- /**
346
- * Gets the history of graph states.
347
- * Requires a checkpointer to be configured.
348
- * Useful for:
349
- * - Debugging execution history
350
- * - Implementing time travel
351
- * - Analyzing graph behavior
352
- *
353
- * @param config - Configuration for retrieving the history
354
- * @param options - Options for filtering the history
355
- * @returns An async iterator of state snapshots
356
- * @throws {Error} If no checkpointer is configured
357
- */
358
- getStateHistory(config: RunnableConfig, options?: CheckpointListOptions): AsyncIterableIterator<StateSnapshot>;
359
- /**
360
- * Apply updates to the graph state in bulk.
361
- * Requires a checkpointer to be configured.
362
- *
363
- * This method is useful for recreating a thread
364
- * from a list of updates, especially if a checkpoint
365
- * is created as a result of multiple tasks.
366
- *
367
- * @internal The API might change in the future.
368
- *
369
- * @param startConfig - Configuration for the update
370
- * @param updates - The list of updates to apply to graph state
371
- * @returns Updated configuration
372
- * @throws {GraphValueError} If no checkpointer is configured
373
- * @throws {InvalidUpdateError} If the update cannot be attributed to a node or an update can be only applied in sequence.
374
- */
375
- bulkUpdateState(startConfig: LangGraphRunnableConfig, supersteps: Array<{
376
- updates: Array<{
377
- values?: Record<string, unknown> | unknown;
378
- asNode?: keyof Nodes | string;
379
- }>;
380
- }>): Promise<RunnableConfig>;
381
- /**
382
- * Updates the state of the graph with new values.
383
- * Requires a checkpointer to be configured.
384
- *
385
- * This method can be used for:
386
- * - Implementing human-in-the-loop workflows
387
- * - Modifying graph state during breakpoints
388
- * - Integrating external inputs into the graph
389
- *
390
- * @param inputConfig - Configuration for the update
391
- * @param values - The values to update the state with
392
- * @param asNode - Optional node name to attribute the update to
393
- * @returns Updated configuration
394
- * @throws {GraphValueError} If no checkpointer is configured
395
- * @throws {InvalidUpdateError} If the update cannot be attributed to a node
396
- */
397
- updateState(inputConfig: LangGraphRunnableConfig, values: Record<string, unknown> | unknown, asNode?: keyof Nodes | string): Promise<RunnableConfig>;
398
- /**
399
- * Gets the default values for various graph configuration options.
400
- * This is an internal method used to process and normalize configuration options.
401
- *
402
- * @param config - The input configuration options
403
- * @returns A tuple containing normalized values for:
404
- * - debug mode
405
- * - stream modes
406
- * - input keys
407
- * - output keys
408
- * - remaining config
409
- * - interrupt before nodes
410
- * - interrupt after nodes
411
- * - checkpointer
412
- * - store
413
- * - whether stream mode is single
414
- * - node cache
415
- * - whether checkpoint during is enabled
416
- * @internal
417
- */
418
- _defaults(config: PregelOptions<Nodes, Channels>): [
419
- boolean,
420
- StreamMode[],
421
- // stream mode
422
- string | string[],
423
- // input keys
424
- string | string[],
425
- LangGraphRunnableConfig,
426
- // config without pregel keys
427
- All | string[],
428
- // interrupt before
429
- All | string[],
430
- // interrupt after
431
- BaseCheckpointSaver | undefined,
432
- // checkpointer
433
- BaseStore | undefined,
434
- boolean,
435
- // stream mode single
436
- BaseCache | undefined,
437
- Durability
438
- ];
439
- /**
440
- * Streams the execution of the graph, emitting state updates as they occur.
441
- * This is the primary method for observing graph execution in real-time.
442
- *
443
- * Stream modes:
444
- * - "values": Emits complete state after each step
445
- * - "updates": Emits only state changes after each step
446
- * - "debug": Emits detailed debug information
447
- * - "messages": Emits messages from within nodes
448
- *
449
- * For more details, see the [Streaming how-to guides](../../how-tos/#streaming_1).
450
- *
451
- * @param input - The input to start graph execution with
452
- * @param options - Configuration options for streaming
453
- * @returns An async iterable stream of graph state updates
454
- */
455
- stream<TStreamMode extends StreamMode | StreamMode[] | undefined, TSubgraphs extends boolean>(input: InputType | CommandInstance | null, options?: Partial<PregelOptions<Nodes, Channels, ContextType, TStreamMode, TSubgraphs>>): Promise<IterableReadableStream<StreamOutputMap<TStreamMode, TSubgraphs, StreamUpdatesType, StreamValuesType, keyof Nodes, NodeReturnType>>>;
456
- /**
457
- * @inheritdoc
458
- */
459
- streamEvents(input: InputType | CommandInstance | null, options: Partial<PregelOptions<Nodes, Channels, ContextType>> & {
460
- version: "v1" | "v2";
461
- }, streamOptions?: StreamEventsOptions): IterableReadableStream<StreamEvent>;
462
- streamEvents(input: InputType | CommandInstance | null, options: Partial<PregelOptions<Nodes, Channels, ContextType>> & {
463
- version: "v1" | "v2";
464
- encoding: "text/event-stream";
465
- }, streamOptions?: StreamEventsOptions): IterableReadableStream<Uint8Array>;
466
- /**
467
- * Validates the input for the graph.
468
- * @param input - The input to validate
469
- * @returns The validated input
470
- * @internal
471
- */
472
- protected _validateInput(input: PregelInputType): Promise<any>;
473
- /**
474
- * Validates the context options for the graph.
475
- * @param context - The context options to validate
476
- * @returns The validated context options
477
- * @internal
478
- */
479
- protected _validateContext(context: Partial<LangGraphRunnableConfig["context"]>): Promise<LangGraphRunnableConfig["context"]>;
480
- /**
481
- * Internal iterator used by stream() to generate state updates.
482
- * This method handles the core logic of graph execution and streaming.
483
- *
484
- * @param input - The input to start graph execution with
485
- * @param options - Configuration options for streaming
486
- * @returns AsyncGenerator yielding state updates
487
- * @internal
488
- */
489
- _streamIterator(input: PregelInputType | Command, options?: Partial<PregelOptions<Nodes, Channels>>): AsyncGenerator<PregelOutputType>;
490
- /**
491
- * Run the graph with a single input and config.
492
- * @param input The input to the graph.
493
- * @param options The configuration to use for the run.
494
- */
495
- invoke(input: InputType | CommandInstance | null, options?: Partial<PregelOptions<Nodes, Channels, ContextType>>): Promise<OutputType>;
496
- private _runLoop;
497
- clearCache(): Promise<void>;
172
+ declare class Pregel<Nodes extends StrRecord<string, PregelNode>, Channels extends StrRecord<string, BaseChannel>,
173
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
174
+ ContextType extends Record<string, any> = StrRecord<string, any>, InputType = PregelInputType, OutputType = PregelOutputType, StreamUpdatesType = InputType, StreamValuesType = OutputType, NodeReturnType = unknown, CommandType = CommandInstance,
175
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
176
+ StreamCustom = any> extends PartialRunnable<InputType | CommandType | null, OutputType, PregelOptions<Nodes, Channels, ContextType>> implements PregelInterface<Nodes, Channels, ContextType>, PregelParams<Nodes, Channels> {
177
+ /**
178
+ * Name of the class when serialized
179
+ * @internal
180
+ */
181
+ static lc_name(): string;
182
+ /** @internal Used for type inference */
183
+ "~InputType": InputType;
184
+ /** @internal Used for type inference */
185
+ "~OutputType": OutputType;
186
+ /** @internal LangChain namespace for serialization necessary because Pregel extends Runnable */
187
+ lc_namespace: string[];
188
+ /** @internal Flag indicating this is a Pregel instance - necessary for serialization */
189
+ lg_is_pregel: boolean;
190
+ /** The nodes in the graph, mapping node names to their PregelNode instances */
191
+ nodes: Nodes;
192
+ /** The channels in the graph, mapping channel names to their BaseChannel or ManagedValueSpec instances */
193
+ channels: Channels;
194
+ /**
195
+ * The input channels for the graph. These channels receive the initial input when the graph is invoked.
196
+ * Can be a single channel key or an array of channel keys.
197
+ */
198
+ inputChannels: keyof Channels | Array<keyof Channels>;
199
+ /**
200
+ * The output channels for the graph. These channels contain the final output when the graph completes.
201
+ * Can be a single channel key or an array of channel keys.
202
+ */
203
+ outputChannels: keyof Channels | Array<keyof Channels>;
204
+ /** Whether to automatically validate the graph structure when it is compiled. Defaults to true. */
205
+ autoValidate: boolean;
206
+ /**
207
+ * The streaming modes enabled for this graph. Defaults to ["values"].
208
+ * Supported modes:
209
+ * - "values": Streams the full state after each step
210
+ * - "updates": Streams state updates after each step
211
+ * - "messages": Streams messages from within nodes
212
+ * - "custom": Streams custom events from within nodes
213
+ * - "debug": Streams events related to the execution of the graph - useful for tracing & debugging graph execution
214
+ */
215
+ streamMode: StreamMode[];
216
+ /**
217
+ * Optional channels to stream. If not specified, all channels will be streamed.
218
+ * Can be a single channel key or an array of channel keys.
219
+ */
220
+ streamChannels?: keyof Channels | Array<keyof Channels>;
221
+ /**
222
+ * Optional array of node names or "all" to interrupt after executing these nodes.
223
+ * Used for implementing human-in-the-loop workflows.
224
+ */
225
+ interruptAfter?: Array<keyof Nodes> | All;
226
+ /**
227
+ * Optional array of node names or "all" to interrupt before executing these nodes.
228
+ * Used for implementing human-in-the-loop workflows.
229
+ */
230
+ interruptBefore?: Array<keyof Nodes> | All;
231
+ /** Optional timeout in milliseconds for the execution of each superstep */
232
+ stepTimeout?: number;
233
+ /** Whether to enable debug logging. Defaults to false. */
234
+ debug: boolean;
235
+ /**
236
+ * Optional checkpointer for persisting graph state.
237
+ * When provided, saves a checkpoint of the graph state at every superstep.
238
+ * When false or undefined, checkpointing is disabled, and the graph will not be able to save or restore state.
239
+ */
240
+ checkpointer?: BaseCheckpointSaver | boolean;
241
+ /** Optional retry policy for handling failures in node execution */
242
+ retryPolicy?: RetryPolicy;
243
+ /** The default configuration for graph execution, can be overridden on a per-invocation basis */
244
+ config?: LangGraphRunnableConfig;
245
+ /**
246
+ * Optional long-term memory store for the graph, allows for persistence & retrieval of data across threads
247
+ */
248
+ store?: BaseStore;
249
+ triggerToNodes: Record<string, string[]>;
250
+ /**
251
+ * Optional cache for the graph, useful for caching tasks.
252
+ */
253
+ cache?: BaseCache;
254
+ /**
255
+ * Constructor for Pregel - meant for internal use only.
256
+ *
257
+ * @internal
258
+ */
259
+ constructor(fields: PregelParams<Nodes, Channels>);
260
+ /**
261
+ * Creates a new instance of the Pregel graph with updated configuration.
262
+ * This method follows the immutable pattern - instead of modifying the current instance,
263
+ * it returns a new instance with the merged configuration.
264
+ *
265
+ * @example
266
+ * ```typescript
267
+ * // Create a new instance with debug enabled
268
+ * const debugGraph = graph.withConfig({ debug: true });
269
+ *
270
+ * // Create a new instance with a specific thread ID
271
+ * const threadGraph = graph.withConfig({
272
+ * configurable: { thread_id: "123" }
273
+ * });
274
+ * ```
275
+ *
276
+ * @param config - The configuration to merge with the current configuration
277
+ * @returns A new Pregel instance with the merged configuration
278
+ */
279
+ withConfig(config: Omit<LangGraphRunnableConfig, "store" | "writer" | "interrupt">): typeof this;
280
+ /**
281
+ * Validates the graph structure to ensure it is well-formed.
282
+ * Checks for:
283
+ * - No orphaned nodes
284
+ * - Valid input/output channel configurations
285
+ * - Valid interrupt configurations
286
+ *
287
+ * @returns this - The Pregel instance for method chaining
288
+ * @throws {GraphValidationError} If the graph structure is invalid
289
+ */
290
+ validate(): this;
291
+ /**
292
+ * Gets a list of all channels that should be streamed.
293
+ * If streamChannels is specified, returns those channels.
294
+ * Otherwise, returns all channels in the graph.
295
+ *
296
+ * @returns Array of channel keys to stream
297
+ */
298
+ get streamChannelsList(): Array<keyof Channels>;
299
+ /**
300
+ * Gets the channels to stream in their original format.
301
+ * If streamChannels is specified, returns it as-is (either single key or array).
302
+ * Otherwise, returns all channels in the graph as an array.
303
+ *
304
+ * @returns Channel keys to stream, either as a single key or array
305
+ */
306
+ get streamChannelsAsIs(): keyof Channels | Array<keyof Channels>;
307
+ /**
308
+ * Gets a drawable representation of the graph structure.
309
+ * This is an async version of getGraph() and is the preferred method to use.
310
+ *
311
+ * @param config - Configuration for generating the graph visualization
312
+ * @returns A representation of the graph that can be visualized
313
+ */
314
+ getGraphAsync(config: RunnableConfig): Promise<_langchain_core_runnables_graph0.Graph>;
315
+ /**
316
+ * Gets all subgraphs within this graph.
317
+ * A subgraph is a Pregel instance that is nested within a node of this graph.
318
+ *
319
+ * @deprecated Use getSubgraphsAsync instead. The async method will become the default in the next minor release.
320
+ * @param namespace - Optional namespace to filter subgraphs
321
+ * @param recurse - Whether to recursively get subgraphs of subgraphs
322
+ * @returns Generator yielding tuples of [name, subgraph]
323
+ */
324
+ getSubgraphs(namespace?: string, recurse?: boolean
325
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
326
+ ): Generator<[string, Pregel<any, any>]>;
327
+ /**
328
+ * Gets all subgraphs within this graph asynchronously.
329
+ * A subgraph is a Pregel instance that is nested within a node of this graph.
330
+ *
331
+ * @param namespace - Optional namespace to filter subgraphs
332
+ * @param recurse - Whether to recursively get subgraphs of subgraphs
333
+ * @returns AsyncGenerator yielding tuples of [name, subgraph]
334
+ */
335
+ getSubgraphsAsync(namespace?: string, recurse?: boolean
336
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
337
+ ): AsyncGenerator<[string, Pregel<any, any>]>;
338
+ /**
339
+ * Prepares a state snapshot from saved checkpoint data.
340
+ * This is an internal method used by getState and getStateHistory.
341
+ *
342
+ * @param config - Configuration for preparing the snapshot
343
+ * @param saved - Optional saved checkpoint data
344
+ * @param subgraphCheckpointer - Optional checkpointer for subgraphs
345
+ * @param applyPendingWrites - Whether to apply pending writes to tasks and then to channels
346
+ * @returns A snapshot of the graph state
347
+ * @internal
348
+ */
349
+ protected _prepareStateSnapshot({
350
+ config,
351
+ saved,
352
+ subgraphCheckpointer,
353
+ applyPendingWrites
354
+ }: {
355
+ config: RunnableConfig;
356
+ saved?: CheckpointTuple;
357
+ subgraphCheckpointer?: BaseCheckpointSaver;
358
+ applyPendingWrites?: boolean;
359
+ }): Promise<StateSnapshot>;
360
+ /**
361
+ * Gets the current state of the graph.
362
+ * Requires a checkpointer to be configured.
363
+ *
364
+ * @param config - Configuration for retrieving the state
365
+ * @param options - Additional options
366
+ * @returns A snapshot of the current graph state
367
+ * @throws {GraphValueError} If no checkpointer is configured
368
+ */
369
+ getState(config: RunnableConfig, options?: GetStateOptions): Promise<StateSnapshot>;
370
+ /**
371
+ * Gets the history of graph states.
372
+ * Requires a checkpointer to be configured.
373
+ * Useful for:
374
+ * - Debugging execution history
375
+ * - Implementing time travel
376
+ * - Analyzing graph behavior
377
+ *
378
+ * @param config - Configuration for retrieving the history
379
+ * @param options - Options for filtering the history
380
+ * @returns An async iterator of state snapshots
381
+ * @throws {Error} If no checkpointer is configured
382
+ */
383
+ getStateHistory(config: RunnableConfig, options?: CheckpointListOptions): AsyncIterableIterator<StateSnapshot>;
384
+ /**
385
+ * Apply updates to the graph state in bulk.
386
+ * Requires a checkpointer to be configured.
387
+ *
388
+ * This method is useful for recreating a thread
389
+ * from a list of updates, especially if a checkpoint
390
+ * is created as a result of multiple tasks.
391
+ *
392
+ * @internal The API might change in the future.
393
+ *
394
+ * @param startConfig - Configuration for the update
395
+ * @param updates - The list of updates to apply to graph state
396
+ * @returns Updated configuration
397
+ * @throws {GraphValueError} If no checkpointer is configured
398
+ * @throws {InvalidUpdateError} If the update cannot be attributed to a node or an update can be only applied in sequence.
399
+ */
400
+ bulkUpdateState(startConfig: LangGraphRunnableConfig, supersteps: Array<{
401
+ updates: Array<{
402
+ values?: Record<string, unknown> | unknown;
403
+ asNode?: keyof Nodes | string;
404
+ }>;
405
+ }>): Promise<RunnableConfig>;
406
+ /**
407
+ * Updates the state of the graph with new values.
408
+ * Requires a checkpointer to be configured.
409
+ *
410
+ * This method can be used for:
411
+ * - Implementing human-in-the-loop workflows
412
+ * - Modifying graph state during breakpoints
413
+ * - Integrating external inputs into the graph
414
+ *
415
+ * @param inputConfig - Configuration for the update
416
+ * @param values - The values to update the state with
417
+ * @param asNode - Optional node name to attribute the update to
418
+ * @returns Updated configuration
419
+ * @throws {GraphValueError} If no checkpointer is configured
420
+ * @throws {InvalidUpdateError} If the update cannot be attributed to a node
421
+ */
422
+ updateState(inputConfig: LangGraphRunnableConfig, values: Record<string, unknown> | unknown, asNode?: keyof Nodes | string): Promise<RunnableConfig>;
423
+ /**
424
+ * Gets the default values for various graph configuration options.
425
+ * This is an internal method used to process and normalize configuration options.
426
+ *
427
+ * @param config - The input configuration options
428
+ * @returns A tuple containing normalized values for:
429
+ * - debug mode
430
+ * - stream modes
431
+ * - input keys
432
+ * - output keys
433
+ * - remaining config
434
+ * - interrupt before nodes
435
+ * - interrupt after nodes
436
+ * - checkpointer
437
+ * - store
438
+ * - whether stream mode is single
439
+ * - node cache
440
+ * - whether checkpoint during is enabled
441
+ * @internal
442
+ */
443
+ _defaults(config: PregelOptions<Nodes, Channels>): [boolean,
444
+ // debug
445
+ StreamMode[],
446
+ // stream mode
447
+ // stream mode
448
+ string | string[],
449
+ // input keys
450
+ // input keys
451
+ string | string[],
452
+ // output keys
453
+ LangGraphRunnableConfig,
454
+ // config without pregel keys
455
+ // config without pregel keys
456
+ All | string[],
457
+ // interrupt before
458
+ // interrupt before
459
+ All | string[],
460
+ // interrupt after
461
+ // interrupt after
462
+ BaseCheckpointSaver | undefined,
463
+ // checkpointer
464
+ // checkpointer
465
+ BaseStore | undefined,
466
+ // store
467
+ boolean,
468
+ // stream mode single
469
+ // stream mode single
470
+ BaseCache | undefined,
471
+ // node cache
472
+ Durability // durability
473
+ ];
474
+ /**
475
+ * Streams the execution of the graph, emitting state updates as they occur.
476
+ * This is the primary method for observing graph execution in real-time.
477
+ *
478
+ * Stream modes:
479
+ * - "values": Emits complete state after each step
480
+ * - "updates": Emits only state changes after each step
481
+ * - "debug": Emits detailed debug information
482
+ * - "messages": Emits messages from within nodes
483
+ *
484
+ * For more details, see the [Streaming how-to guides](../../how-tos/#streaming_1).
485
+ *
486
+ * @param input - The input to start graph execution with
487
+ * @param options - Configuration options for streaming
488
+ * @returns An async iterable stream of graph state updates
489
+ */
490
+ stream<TStreamMode extends StreamMode | StreamMode[] | undefined, TSubgraphs extends boolean>(input: InputType | CommandType | null, options?: Partial<PregelOptions<Nodes, Channels, ContextType, TStreamMode, TSubgraphs>>): Promise<IterableReadableStream<StreamOutputMap<TStreamMode, TSubgraphs, StreamUpdatesType, StreamValuesType, keyof Nodes, NodeReturnType, StreamCustom>>>;
491
+ /**
492
+ * @inheritdoc
493
+ */
494
+ streamEvents(input: InputType | CommandType | null, options: Partial<PregelOptions<Nodes, Channels, ContextType>> & {
495
+ version: "v1" | "v2";
496
+ }, streamOptions?: StreamEventsOptions): IterableReadableStream<StreamEvent>;
497
+ streamEvents(input: InputType | CommandType | null, options: Partial<PregelOptions<Nodes, Channels, ContextType>> & {
498
+ version: "v1" | "v2";
499
+ encoding: "text/event-stream";
500
+ }, streamOptions?: StreamEventsOptions): IterableReadableStream<Uint8Array>;
501
+ /**
502
+ * Validates the input for the graph.
503
+ * @param input - The input to validate
504
+ * @returns The validated input
505
+ * @internal
506
+ */
507
+ protected _validateInput(input: PregelInputType): Promise<any>;
508
+ /**
509
+ * Validates the context options for the graph.
510
+ * @param context - The context options to validate
511
+ * @returns The validated context options
512
+ * @internal
513
+ */
514
+ protected _validateContext(context: Partial<LangGraphRunnableConfig["context"]>): Promise<LangGraphRunnableConfig["context"]>;
515
+ /**
516
+ * Internal iterator used by stream() to generate state updates.
517
+ * This method handles the core logic of graph execution and streaming.
518
+ *
519
+ * @param input - The input to start graph execution with
520
+ * @param options - Configuration options for streaming
521
+ * @returns AsyncGenerator yielding state updates
522
+ * @internal
523
+ */
524
+ _streamIterator(input: PregelInputType | Command, options?: Partial<PregelOptions<Nodes, Channels>>): AsyncGenerator<PregelOutputType>;
525
+ /**
526
+ * Run the graph with a single input and config.
527
+ * @param input The input to the graph.
528
+ * @param options The configuration to use for the run.
529
+ */
530
+ invoke(input: InputType | CommandType | null, options?: Partial<PregelOptions<Nodes, Channels, ContextType>>): Promise<OutputType>;
531
+ private _runLoop;
532
+ clearCache(): Promise<void>;
498
533
  }
534
+ //#endregion
535
+ export { Channel, Pregel, type PregelInputType, type PregelOptions, type PregelOutputType };
536
+ //# sourceMappingURL=index.d.ts.map