@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
package/dist/constants.js CHANGED
@@ -1,470 +1,362 @@
1
- var _a;
1
+ //#region src/constants.ts
2
2
  /** Special reserved node name denoting the start of a graph. */
3
- export const START = "__start__";
3
+ const START = "__start__";
4
4
  /** Special reserved node name denoting the end of a graph. */
5
- export const END = "__end__";
6
- export const INPUT = "__input__";
7
- export const COPY = "__copy__";
8
- export const ERROR = "__error__";
5
+ const END = "__end__";
6
+ const INPUT = "__input__";
7
+ const COPY = "__copy__";
8
+ const ERROR = "__error__";
9
9
  /** Special reserved cache namespaces */
10
- export const CACHE_NS_WRITES = "__pregel_ns_writes";
11
- export const CONFIG_KEY_SEND = "__pregel_send";
10
+ const CACHE_NS_WRITES = "__pregel_ns_writes";
11
+ const CONFIG_KEY_SEND = "__pregel_send";
12
12
  /** config key containing function used to call a node (push task) */
13
- export const CONFIG_KEY_CALL = "__pregel_call";
14
- export const CONFIG_KEY_READ = "__pregel_read";
15
- export const CONFIG_KEY_CHECKPOINTER = "__pregel_checkpointer";
16
- export const CONFIG_KEY_RESUMING = "__pregel_resuming";
17
- export const CONFIG_KEY_TASK_ID = "__pregel_task_id";
18
- export const CONFIG_KEY_STREAM = "__pregel_stream";
19
- export const CONFIG_KEY_RESUME_VALUE = "__pregel_resume_value";
20
- export const CONFIG_KEY_RESUME_MAP = "__pregel_resume_map";
21
- export const CONFIG_KEY_SCRATCHPAD = "__pregel_scratchpad";
13
+ const CONFIG_KEY_CALL = "__pregel_call";
14
+ const CONFIG_KEY_READ = "__pregel_read";
15
+ const CONFIG_KEY_CHECKPOINTER = "__pregel_checkpointer";
16
+ const CONFIG_KEY_RESUMING = "__pregel_resuming";
17
+ const CONFIG_KEY_TASK_ID = "__pregel_task_id";
18
+ const CONFIG_KEY_STREAM = "__pregel_stream";
19
+ const CONFIG_KEY_RESUME_VALUE = "__pregel_resume_value";
20
+ const CONFIG_KEY_RESUME_MAP = "__pregel_resume_map";
21
+ const CONFIG_KEY_SCRATCHPAD = "__pregel_scratchpad";
22
22
  /** config key containing state from previous invocation of graph for the given thread */
23
- export const CONFIG_KEY_PREVIOUS_STATE = "__pregel_previous";
24
- export const CONFIG_KEY_DURABILITY = "__pregel_durability";
25
- export const CONFIG_KEY_CHECKPOINT_ID = "checkpoint_id";
26
- export const CONFIG_KEY_CHECKPOINT_NS = "checkpoint_ns";
27
- export const CONFIG_KEY_NODE_FINISHED = "__pregel_node_finished";
28
- // this one is part of public API
29
- export const CONFIG_KEY_CHECKPOINT_MAP = "checkpoint_map";
30
- export const CONFIG_KEY_ABORT_SIGNALS = "__pregel_abort_signals";
23
+ const CONFIG_KEY_PREVIOUS_STATE = "__pregel_previous";
24
+ const CONFIG_KEY_DURABILITY = "__pregel_durability";
25
+ const CONFIG_KEY_CHECKPOINT_ID = "checkpoint_id";
26
+ const CONFIG_KEY_CHECKPOINT_NS = "checkpoint_ns";
27
+ const CONFIG_KEY_NODE_FINISHED = "__pregel_node_finished";
28
+ const CONFIG_KEY_CHECKPOINT_MAP = "checkpoint_map";
29
+ const CONFIG_KEY_ABORT_SIGNALS = "__pregel_abort_signals";
31
30
  /** Special channel reserved for graph interrupts */
32
- export const INTERRUPT = "__interrupt__";
31
+ const INTERRUPT = "__interrupt__";
33
32
  /** Special channel reserved for graph resume */
34
- export const RESUME = "__resume__";
33
+ const RESUME = "__resume__";
35
34
  /** Special channel reserved for cases when a task exits without any writes */
36
- export const NO_WRITES = "__no_writes__";
35
+ const NO_WRITES = "__no_writes__";
37
36
  /** Special channel reserved for graph return */
38
- export const RETURN = "__return__";
37
+ const RETURN = "__return__";
39
38
  /** Special channel reserved for graph previous state */
40
- export const PREVIOUS = "__previous__";
41
- export const RUNTIME_PLACEHOLDER = "__pregel_runtime_placeholder__";
42
- export const RECURSION_LIMIT_DEFAULT = 25;
43
- export const TAG_HIDDEN = "langsmith:hidden";
44
- export const TAG_NOSTREAM = "langsmith:nostream";
45
- export const SELF = "__self__";
46
- export const TASKS = "__pregel_tasks";
47
- export const PUSH = "__pregel_push";
48
- export const PULL = "__pregel_pull";
49
- export const TASK_NAMESPACE = "6ba7b831-9dad-11d1-80b4-00c04fd430c8";
50
- export const NULL_TASK_ID = "00000000-0000-0000-0000-000000000000";
51
- export const RESERVED = [
52
- TAG_HIDDEN,
53
- INPUT,
54
- INTERRUPT,
55
- RESUME,
56
- ERROR,
57
- NO_WRITES,
58
- // reserved config.configurable keys
59
- CONFIG_KEY_SEND,
60
- CONFIG_KEY_READ,
61
- CONFIG_KEY_CHECKPOINTER,
62
- CONFIG_KEY_DURABILITY,
63
- CONFIG_KEY_STREAM,
64
- CONFIG_KEY_RESUMING,
65
- CONFIG_KEY_TASK_ID,
66
- CONFIG_KEY_CALL,
67
- CONFIG_KEY_RESUME_VALUE,
68
- CONFIG_KEY_SCRATCHPAD,
69
- CONFIG_KEY_PREVIOUS_STATE,
70
- CONFIG_KEY_CHECKPOINT_MAP,
71
- CONFIG_KEY_CHECKPOINT_NS,
72
- CONFIG_KEY_CHECKPOINT_ID,
39
+ const PREVIOUS = "__previous__";
40
+ const TAG_HIDDEN = "langsmith:hidden";
41
+ const TAG_NOSTREAM = "langsmith:nostream";
42
+ const SELF = "__self__";
43
+ const TASKS = "__pregel_tasks";
44
+ const PUSH = "__pregel_push";
45
+ const PULL = "__pregel_pull";
46
+ const NULL_TASK_ID = "00000000-0000-0000-0000-000000000000";
47
+ const RESERVED = [
48
+ TAG_HIDDEN,
49
+ INPUT,
50
+ INTERRUPT,
51
+ RESUME,
52
+ ERROR,
53
+ NO_WRITES,
54
+ CONFIG_KEY_SEND,
55
+ CONFIG_KEY_READ,
56
+ CONFIG_KEY_CHECKPOINTER,
57
+ CONFIG_KEY_DURABILITY,
58
+ CONFIG_KEY_STREAM,
59
+ CONFIG_KEY_RESUMING,
60
+ CONFIG_KEY_TASK_ID,
61
+ CONFIG_KEY_CALL,
62
+ CONFIG_KEY_RESUME_VALUE,
63
+ CONFIG_KEY_SCRATCHPAD,
64
+ CONFIG_KEY_PREVIOUS_STATE,
65
+ CONFIG_KEY_CHECKPOINT_MAP,
66
+ CONFIG_KEY_CHECKPOINT_NS,
67
+ CONFIG_KEY_CHECKPOINT_ID
73
68
  ];
74
- export const CHECKPOINT_NAMESPACE_SEPARATOR = "|";
75
- export const CHECKPOINT_NAMESPACE_END = ":";
69
+ const CHECKPOINT_NAMESPACE_SEPARATOR = "|";
70
+ const CHECKPOINT_NAMESPACE_END = ":";
76
71
  /** @internal */
77
72
  const COMMAND_SYMBOL = Symbol.for("langgraph.command");
78
73
  /**
79
- * Instance of a {@link Command} class.
80
- *
81
- * This is used to avoid IntelliSense suggesting public fields
82
- * of {@link Command} class when a plain object is expected.
83
- *
84
- * @see {@link Command}
85
- * @internal
86
- */
87
- export class CommandInstance {
88
- constructor() {
89
- Object.defineProperty(this, _a, {
90
- enumerable: true,
91
- configurable: true,
92
- writable: true,
93
- value: void 0
94
- });
95
- }
96
- }
97
- _a = COMMAND_SYMBOL;
98
- export function _isSendInterface(x) {
99
- const operation = x;
100
- return (operation !== null &&
101
- operation !== undefined &&
102
- typeof operation.node === "string" &&
103
- operation.args !== undefined);
74
+ * Instance of a {@link Command} class.
75
+ *
76
+ * This is used to avoid IntelliSense suggesting public fields
77
+ * of {@link Command} class when a plain object is expected.
78
+ *
79
+ * @see {@link Command}
80
+ * @internal
81
+ */
82
+ var CommandInstance = class {
83
+ [COMMAND_SYMBOL];
84
+ constructor(args) {
85
+ this[COMMAND_SYMBOL] = args;
86
+ }
87
+ };
88
+ function _isSendInterface(x) {
89
+ const operation = x;
90
+ return operation !== null && operation !== void 0 && typeof operation.node === "string" && operation.args !== void 0;
104
91
  }
105
92
  /**
106
- *
107
- * A message or packet to send to a specific node in the graph.
108
- *
109
- * The `Send` class is used within a `StateGraph`'s conditional edges to
110
- * dynamically invoke a node with a custom state at the next step.
111
- *
112
- * Importantly, the sent state can differ from the core graph's state,
113
- * allowing for flexible and dynamic workflow management.
114
- *
115
- * One such example is a "map-reduce" workflow where your graph invokes
116
- * the same node multiple times in parallel with different states,
117
- * before aggregating the results back into the main graph's state.
118
- *
119
- * @example
120
- * ```typescript
121
- * import { Annotation, Send, StateGraph } from "@langchain/langgraph";
122
- *
123
- * const ChainState = Annotation.Root({
124
- * subjects: Annotation<string[]>,
125
- * jokes: Annotation<string[]>({
126
- * reducer: (a, b) => a.concat(b),
127
- * }),
128
- * });
129
- *
130
- * const continueToJokes = async (state: typeof ChainState.State) => {
131
- * return state.subjects.map((subject) => {
132
- * return new Send("generate_joke", { subjects: [subject] });
133
- * });
134
- * };
135
- *
136
- * const graph = new StateGraph(ChainState)
137
- * .addNode("generate_joke", (state) => ({
138
- * jokes: [`Joke about ${state.subjects}`],
139
- * }))
140
- * .addConditionalEdges("__start__", continueToJokes)
141
- * .addEdge("generate_joke", "__end__")
142
- * .compile();
143
- *
144
- * const res = await graph.invoke({ subjects: ["cats", "dogs"] });
145
- * console.log(res);
146
- *
147
- * // Invoking with two subjects results in a generated joke for each
148
- * // { subjects: ["cats", "dogs"], jokes: [`Joke about cats`, `Joke about dogs`] }
149
- * ```
150
- */
151
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
152
- export class Send {
153
- constructor(node, args) {
154
- Object.defineProperty(this, "lg_name", {
155
- enumerable: true,
156
- configurable: true,
157
- writable: true,
158
- value: "Send"
159
- });
160
- Object.defineProperty(this, "node", {
161
- enumerable: true,
162
- configurable: true,
163
- writable: true,
164
- value: void 0
165
- });
166
- Object.defineProperty(this, "args", {
167
- enumerable: true,
168
- configurable: true,
169
- writable: true,
170
- value: void 0
171
- });
172
- this.node = node;
173
- this.args = _deserializeCommandSendObjectGraph(args);
174
- }
175
- toJSON() {
176
- return { lg_name: this.lg_name, node: this.node, args: this.args };
177
- }
178
- }
179
- export function _isSend(x) {
180
- // eslint-disable-next-line no-instanceof/no-instanceof
181
- return x instanceof Send;
93
+ *
94
+ * A message or packet to send to a specific node in the graph.
95
+ *
96
+ * The `Send` class is used within a `StateGraph`'s conditional edges to
97
+ * dynamically invoke a node with a custom state at the next step.
98
+ *
99
+ * Importantly, the sent state can differ from the core graph's state,
100
+ * allowing for flexible and dynamic workflow management.
101
+ *
102
+ * One such example is a "map-reduce" workflow where your graph invokes
103
+ * the same node multiple times in parallel with different states,
104
+ * before aggregating the results back into the main graph's state.
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * import { Annotation, Send, StateGraph } from "@langchain/langgraph";
109
+ *
110
+ * const ChainState = Annotation.Root({
111
+ * subjects: Annotation<string[]>,
112
+ * jokes: Annotation<string[]>({
113
+ * reducer: (a, b) => a.concat(b),
114
+ * }),
115
+ * });
116
+ *
117
+ * const continueToJokes = async (state: typeof ChainState.State) => {
118
+ * return state.subjects.map((subject) => {
119
+ * return new Send("generate_joke", { subjects: [subject] });
120
+ * });
121
+ * };
122
+ *
123
+ * const graph = new StateGraph(ChainState)
124
+ * .addNode("generate_joke", (state) => ({
125
+ * jokes: [`Joke about ${state.subjects}`],
126
+ * }))
127
+ * .addConditionalEdges("__start__", continueToJokes)
128
+ * .addEdge("generate_joke", "__end__")
129
+ * .compile();
130
+ *
131
+ * const res = await graph.invoke({ subjects: ["cats", "dogs"] });
132
+ * console.log(res);
133
+ *
134
+ * // Invoking with two subjects results in a generated joke for each
135
+ * // { subjects: ["cats", "dogs"], jokes: [`Joke about cats`, `Joke about dogs`] }
136
+ * ```
137
+ */
138
+ var Send = class {
139
+ lg_name = "Send";
140
+ node;
141
+ args;
142
+ constructor(node, args) {
143
+ this.node = node;
144
+ this.args = _deserializeCommandSendObjectGraph(args);
145
+ }
146
+ toJSON() {
147
+ return {
148
+ lg_name: this.lg_name,
149
+ node: this.node,
150
+ args: this.args
151
+ };
152
+ }
153
+ };
154
+ function _isSend(x) {
155
+ return x instanceof Send;
182
156
  }
183
157
  /**
184
- * Checks if the given graph invoke / stream chunk contains interrupt.
185
- *
186
- * @example
187
- * ```ts
188
- * import { INTERRUPT, isInterrupted } from "@langchain/langgraph";
189
- *
190
- * const values = await graph.invoke({ foo: "bar" });
191
- * if (isInterrupted<string>(values)) {
192
- * const interrupt = values[INTERRUPT][0].value;
193
- * }
194
- * ```
195
- *
196
- * @param values - The values to check.
197
- * @returns `true` if the values contain an interrupt, `false` otherwise.
198
- */
199
- export function isInterrupted(values) {
200
- if (!values || typeof values !== "object")
201
- return false;
202
- if (!(INTERRUPT in values))
203
- return false;
204
- return Array.isArray(values[INTERRUPT]);
158
+ * Checks if the given graph invoke / stream chunk contains interrupt.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * import { INTERRUPT, isInterrupted } from "@langchain/langgraph";
163
+ *
164
+ * const values = await graph.invoke({ foo: "bar" });
165
+ * if (isInterrupted<string>(values)) {
166
+ * const interrupt = values[INTERRUPT][0].value;
167
+ * }
168
+ * ```
169
+ *
170
+ * @param values - The values to check.
171
+ * @returns `true` if the values contain an interrupt, `false` otherwise.
172
+ */
173
+ function isInterrupted(values) {
174
+ if (!values || typeof values !== "object") return false;
175
+ if (!(INTERRUPT in values)) return false;
176
+ return Array.isArray(values[INTERRUPT]);
205
177
  }
206
178
  /**
207
- * One or more commands to update the graph's state and send messages to nodes.
208
- * Can be used to combine routing logic with state updates in lieu of conditional edges
209
- *
210
- * @example
211
- * ```ts
212
- * import { Annotation, Command } from "@langchain/langgraph";
213
- *
214
- * // Define graph state
215
- * const StateAnnotation = Annotation.Root({
216
- * foo: Annotation<string>,
217
- * });
218
- *
219
- * // Define the nodes
220
- * const nodeA = async (_state: typeof StateAnnotation.State) => {
221
- * console.log("Called A");
222
- * // this is a replacement for a real conditional edge function
223
- * const goto = Math.random() > .5 ? "nodeB" : "nodeC";
224
- * // note how Command allows you to BOTH update the graph state AND route to the next node
225
- * return new Command({
226
- * // this is the state update
227
- * update: {
228
- * foo: "a",
229
- * },
230
- * // this is a replacement for an edge
231
- * goto,
232
- * });
233
- * };
234
- *
235
- * // Nodes B and C are unchanged
236
- * const nodeB = async (state: typeof StateAnnotation.State) => {
237
- * console.log("Called B");
238
- * return {
239
- * foo: state.foo + "|b",
240
- * };
241
- * }
242
- *
243
- * const nodeC = async (state: typeof StateAnnotation.State) => {
244
- * console.log("Called C");
245
- * return {
246
- * foo: state.foo + "|c",
247
- * };
248
- * }
249
- *
250
- * import { StateGraph } from "@langchain/langgraph";
179
+ * One or more commands to update the graph's state and send messages to nodes.
180
+ * Can be used to combine routing logic with state updates in lieu of conditional edges
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * import { Annotation, Command } from "@langchain/langgraph";
185
+ *
186
+ * // Define graph state
187
+ * const StateAnnotation = Annotation.Root({
188
+ * foo: Annotation<string>,
189
+ * });
190
+ *
191
+ * // Define the nodes
192
+ * const nodeA = async (_state: typeof StateAnnotation.State) => {
193
+ * console.log("Called A");
194
+ * // this is a replacement for a real conditional edge function
195
+ * const goto = Math.random() > .5 ? "nodeB" : "nodeC";
196
+ * // note how Command allows you to BOTH update the graph state AND route to the next node
197
+ * return new Command({
198
+ * // this is the state update
199
+ * update: {
200
+ * foo: "a",
201
+ * },
202
+ * // this is a replacement for an edge
203
+ * goto,
204
+ * });
205
+ * };
206
+ *
207
+ * // Nodes B and C are unchanged
208
+ * const nodeB = async (state: typeof StateAnnotation.State) => {
209
+ * console.log("Called B");
210
+ * return {
211
+ * foo: state.foo + "|b",
212
+ * };
213
+ * }
214
+ *
215
+ * const nodeC = async (state: typeof StateAnnotation.State) => {
216
+ * console.log("Called C");
217
+ * return {
218
+ * foo: state.foo + "|c",
219
+ * };
220
+ * }
221
+ *
222
+ * import { StateGraph } from "@langchain/langgraph";
251
223
 
252
- * // NOTE: there are no edges between nodes A, B and C!
253
- * const graph = new StateGraph(StateAnnotation)
254
- * .addNode("nodeA", nodeA, {
255
- * ends: ["nodeB", "nodeC"],
256
- * })
257
- * .addNode("nodeB", nodeB)
258
- * .addNode("nodeC", nodeC)
259
- * .addEdge("__start__", "nodeA")
260
- * .compile();
261
- *
262
- * await graph.invoke({ foo: "" });
263
- *
264
- * // Randomly oscillates between
265
- * // { foo: 'a|c' } and { foo: 'a|b' }
266
- * ```
267
- */
268
- export class Command extends CommandInstance {
269
- constructor(args) {
270
- super();
271
- Object.defineProperty(this, "lg_name", {
272
- enumerable: true,
273
- configurable: true,
274
- writable: true,
275
- value: "Command"
276
- });
277
- Object.defineProperty(this, "lc_direct_tool_output", {
278
- enumerable: true,
279
- configurable: true,
280
- writable: true,
281
- value: true
282
- });
283
- /**
284
- * Graph to send the command to. Supported values are:
285
- * - None: the current graph (default)
286
- * - The specific name of the graph to send the command to
287
- * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)
288
- */
289
- Object.defineProperty(this, "graph", {
290
- enumerable: true,
291
- configurable: true,
292
- writable: true,
293
- value: void 0
294
- });
295
- /**
296
- * Update to apply to the graph's state as a result of executing the node that is returning the command.
297
- * Written to the state as if the node had simply returned this value instead of the Command object.
298
- */
299
- Object.defineProperty(this, "update", {
300
- enumerable: true,
301
- configurable: true,
302
- writable: true,
303
- value: void 0
304
- });
305
- /**
306
- * Value to resume execution with. To be used together with {@link interrupt}.
307
- */
308
- Object.defineProperty(this, "resume", {
309
- enumerable: true,
310
- configurable: true,
311
- writable: true,
312
- value: void 0
313
- });
314
- /**
315
- * Can be one of the following:
316
- * - name of the node to navigate to next (any node that belongs to the specified `graph`)
317
- * - sequence of node names to navigate to next
318
- * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)
319
- * - sequence of {@link Send} objects
320
- */
321
- Object.defineProperty(this, "goto", {
322
- enumerable: true,
323
- configurable: true,
324
- writable: true,
325
- value: []
326
- });
327
- this.resume = args.resume;
328
- this.graph = args.graph;
329
- this.update = args.update;
330
- if (args.goto) {
331
- this.goto = Array.isArray(args.goto)
332
- ? _deserializeCommandSendObjectGraph(args.goto)
333
- : [_deserializeCommandSendObjectGraph(args.goto)];
334
- }
335
- }
336
- /**
337
- * Convert the update field to a list of {@link PendingWrite} tuples
338
- * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.
339
- * @internal
340
- */
341
- _updateAsTuples() {
342
- if (this.update &&
343
- typeof this.update === "object" &&
344
- !Array.isArray(this.update)) {
345
- return Object.entries(this.update);
346
- }
347
- else if (Array.isArray(this.update) &&
348
- this.update.every((t) => Array.isArray(t) && t.length === 2 && typeof t[0] === "string")) {
349
- return this.update;
350
- }
351
- else {
352
- return [["__root__", this.update]];
353
- }
354
- }
355
- toJSON() {
356
- let serializedGoto;
357
- if (typeof this.goto === "string") {
358
- serializedGoto = this.goto;
359
- }
360
- else if (_isSend(this.goto)) {
361
- serializedGoto = this.goto.toJSON();
362
- }
363
- else {
364
- serializedGoto = this.goto?.map((innerGoto) => {
365
- if (typeof innerGoto === "string") {
366
- return innerGoto;
367
- }
368
- else {
369
- return innerGoto.toJSON();
370
- }
371
- });
372
- }
373
- return {
374
- lg_name: this.lg_name,
375
- update: this.update,
376
- resume: this.resume,
377
- goto: serializedGoto,
378
- };
379
- }
380
- }
381
- Object.defineProperty(Command, "PARENT", {
382
- enumerable: true,
383
- configurable: true,
384
- writable: true,
385
- value: "__parent__"
386
- });
224
+ * // NOTE: there are no edges between nodes A, B and C!
225
+ * const graph = new StateGraph(StateAnnotation)
226
+ * .addNode("nodeA", nodeA, {
227
+ * ends: ["nodeB", "nodeC"],
228
+ * })
229
+ * .addNode("nodeB", nodeB)
230
+ * .addNode("nodeC", nodeC)
231
+ * .addEdge("__start__", "nodeA")
232
+ * .compile();
233
+ *
234
+ * await graph.invoke({ foo: "" });
235
+ *
236
+ * // Randomly oscillates between
237
+ * // { foo: 'a|c' } and { foo: 'a|b' }
238
+ * ```
239
+ */
240
+ var Command = class extends CommandInstance {
241
+ lg_name = "Command";
242
+ lc_direct_tool_output = true;
243
+ /**
244
+ * Graph to send the command to. Supported values are:
245
+ * - None: the current graph (default)
246
+ * - The specific name of the graph to send the command to
247
+ * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)
248
+ */
249
+ graph;
250
+ /**
251
+ * Update to apply to the graph's state as a result of executing the node that is returning the command.
252
+ * Written to the state as if the node had simply returned this value instead of the Command object.
253
+ */
254
+ update;
255
+ /**
256
+ * Value to resume execution with. To be used together with {@link interrupt}.
257
+ */
258
+ resume;
259
+ /**
260
+ * Can be one of the following:
261
+ * - name of the node to navigate to next (any node that belongs to the specified `graph`)
262
+ * - sequence of node names to navigate to next
263
+ * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)
264
+ * - sequence of {@link Send} objects
265
+ */
266
+ goto = [];
267
+ static PARENT = "__parent__";
268
+ constructor(args) {
269
+ super(args);
270
+ this.resume = args.resume;
271
+ this.graph = args.graph;
272
+ this.update = args.update;
273
+ if (args.goto) this.goto = Array.isArray(args.goto) ? _deserializeCommandSendObjectGraph(args.goto) : [_deserializeCommandSendObjectGraph(args.goto)];
274
+ }
275
+ /**
276
+ * Convert the update field to a list of {@link PendingWrite} tuples
277
+ * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.
278
+ * @internal
279
+ */
280
+ _updateAsTuples() {
281
+ if (this.update && typeof this.update === "object" && !Array.isArray(this.update)) return Object.entries(this.update);
282
+ else if (Array.isArray(this.update) && this.update.every((t) => Array.isArray(t) && t.length === 2 && typeof t[0] === "string")) return this.update;
283
+ else return [["__root__", this.update]];
284
+ }
285
+ toJSON() {
286
+ let serializedGoto;
287
+ if (typeof this.goto === "string") serializedGoto = this.goto;
288
+ else if (_isSend(this.goto)) serializedGoto = this.goto.toJSON();
289
+ else serializedGoto = this.goto?.map((innerGoto) => {
290
+ if (typeof innerGoto === "string") return innerGoto;
291
+ else return innerGoto.toJSON();
292
+ });
293
+ return {
294
+ lg_name: this.lg_name,
295
+ update: this.update,
296
+ resume: this.resume,
297
+ goto: serializedGoto
298
+ };
299
+ }
300
+ };
387
301
  /**
388
- * A type guard to check if the given value is a {@link Command}.
389
- *
390
- * Useful for type narrowing when working with the {@link Command} object.
391
- *
392
- * @param x - The value to check.
393
- * @returns `true` if the value is a {@link Command}, `false` otherwise.
394
- */
395
- export function isCommand(x) {
396
- if (typeof x !== "object") {
397
- return false;
398
- }
399
- if (x === null || x === undefined) {
400
- return false;
401
- }
402
- if ("lg_name" in x && x.lg_name === "Command") {
403
- return true;
404
- }
405
- return false;
302
+ * A type guard to check if the given value is a {@link Command}.
303
+ *
304
+ * Useful for type narrowing when working with the {@link Command} object.
305
+ *
306
+ * @param x - The value to check.
307
+ * @returns `true` if the value is a {@link Command}, `false` otherwise.
308
+ */
309
+ function isCommand(x) {
310
+ if (typeof x !== "object") return false;
311
+ if (x === null || x === void 0) return false;
312
+ if ("lg_name" in x && x.lg_name === "Command") return true;
313
+ return false;
406
314
  }
407
315
  /**
408
- * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects
409
- * matching their interfaces.
410
- *
411
- * This is only exported for testing purposes. It is NOT intended to be used outside of
412
- * the Command and Send classes.
413
- *
414
- * @internal
415
- *
416
- * @param x - The command send tree to convert.
417
- * @param seen - A map of seen objects to avoid infinite loops.
418
- * @returns The converted command send tree.
419
- */
420
- export function _deserializeCommandSendObjectGraph(x, seen = new Map()) {
421
- if (x !== undefined && x !== null && typeof x === "object") {
422
- // If we've already processed this object, return the transformed version
423
- if (seen.has(x)) {
424
- return seen.get(x);
425
- }
426
- let result;
427
- if (Array.isArray(x)) {
428
- // Create the array first, then populate it
429
- result = [];
430
- // Add to seen map before processing elements to handle self-references
431
- seen.set(x, result);
432
- // Now populate the array
433
- x.forEach((item, index) => {
434
- result[index] = _deserializeCommandSendObjectGraph(item, seen);
435
- });
436
- // eslint-disable-next-line no-instanceof/no-instanceof
437
- }
438
- else if (isCommand(x) && !(x instanceof Command)) {
439
- result = new Command(x);
440
- seen.set(x, result);
441
- // eslint-disable-next-line no-instanceof/no-instanceof
442
- }
443
- else if (_isSendInterface(x) && !(x instanceof Send)) {
444
- result = new Send(x.node, x.args);
445
- seen.set(x, result);
446
- }
447
- else if (isCommand(x) || _isSend(x)) {
448
- result = x;
449
- seen.set(x, result);
450
- }
451
- else if ("lc_serializable" in x && x.lc_serializable) {
452
- result = x;
453
- seen.set(x, result);
454
- }
455
- else {
456
- // Create empty object first
457
- result = {};
458
- // Add to seen map before processing properties to handle self-references
459
- seen.set(x, result);
460
- // Now populate the object
461
- for (const [key, value] of Object.entries(x)) {
462
- result[key] =
463
- _deserializeCommandSendObjectGraph(value, seen);
464
- }
465
- }
466
- return result;
467
- }
468
- return x;
316
+ * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects
317
+ * matching their interfaces.
318
+ *
319
+ * This is only exported for testing purposes. It is NOT intended to be used outside of
320
+ * the Command and Send classes.
321
+ *
322
+ * @internal
323
+ *
324
+ * @param x - The command send tree to convert.
325
+ * @param seen - A map of seen objects to avoid infinite loops.
326
+ * @returns The converted command send tree.
327
+ */
328
+ function _deserializeCommandSendObjectGraph(x, seen = /* @__PURE__ */ new Map()) {
329
+ if (x !== void 0 && x !== null && typeof x === "object") {
330
+ if (seen.has(x)) return seen.get(x);
331
+ let result;
332
+ if (Array.isArray(x)) {
333
+ result = [];
334
+ seen.set(x, result);
335
+ x.forEach((item, index) => {
336
+ result[index] = _deserializeCommandSendObjectGraph(item, seen);
337
+ });
338
+ } else if (isCommand(x) && !(x instanceof Command)) {
339
+ result = new Command(x);
340
+ seen.set(x, result);
341
+ } else if (_isSendInterface(x) && !(x instanceof Send)) {
342
+ result = new Send(x.node, x.args);
343
+ seen.set(x, result);
344
+ } else if (isCommand(x) || _isSend(x)) {
345
+ result = x;
346
+ seen.set(x, result);
347
+ } else if ("lc_serializable" in x && x.lc_serializable) {
348
+ result = x;
349
+ seen.set(x, result);
350
+ } else {
351
+ result = {};
352
+ seen.set(x, result);
353
+ for (const [key, value] of Object.entries(x)) result[key] = _deserializeCommandSendObjectGraph(value, seen);
354
+ }
355
+ return result;
356
+ }
357
+ return x;
469
358
  }
359
+
360
+ //#endregion
361
+ export { CACHE_NS_WRITES, CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_ABORT_SIGNALS, CONFIG_KEY_CALL, CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_CHECKPOINT_ID, CONFIG_KEY_CHECKPOINT_MAP, CONFIG_KEY_CHECKPOINT_NS, CONFIG_KEY_DURABILITY, CONFIG_KEY_NODE_FINISHED, CONFIG_KEY_PREVIOUS_STATE, CONFIG_KEY_READ, CONFIG_KEY_RESUME_MAP, CONFIG_KEY_RESUMING, CONFIG_KEY_SCRATCHPAD, CONFIG_KEY_SEND, CONFIG_KEY_STREAM, CONFIG_KEY_TASK_ID, COPY, Command, END, ERROR, INPUT, INTERRUPT, NO_WRITES, NULL_TASK_ID, PREVIOUS, PULL, PUSH, RESERVED, RESUME, RETURN, SELF, START, Send, TAG_HIDDEN, TAG_NOSTREAM, TASKS, _isSend, _isSendInterface, isCommand, isInterrupted };
470
362
  //# sourceMappingURL=constants.js.map