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