@langchain/langgraph 1.0.12 → 1.0.13

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 (381) hide show
  1. package/dist/channels/any_value.cjs +46 -0
  2. package/dist/channels/any_value.cjs.map +1 -0
  3. package/dist/channels/any_value.d.cts +23 -0
  4. package/dist/channels/any_value.d.cts.map +1 -0
  5. package/dist/channels/any_value.d.ts +23 -0
  6. package/dist/channels/any_value.d.ts.map +1 -0
  7. package/dist/channels/any_value.js +46 -0
  8. package/dist/channels/any_value.js.map +1 -0
  9. package/dist/channels/base.cjs +101 -0
  10. package/dist/channels/base.cjs.map +1 -0
  11. package/dist/channels/base.d.cts +79 -0
  12. package/dist/channels/base.d.cts.map +1 -0
  13. package/dist/channels/base.d.ts +79 -0
  14. package/dist/channels/base.d.ts.map +1 -0
  15. package/dist/channels/base.js +97 -0
  16. package/dist/channels/base.js.map +1 -0
  17. package/dist/channels/binop.cjs +49 -0
  18. package/dist/channels/binop.cjs.map +1 -0
  19. package/dist/channels/binop.d.cts +22 -0
  20. package/dist/channels/binop.d.cts.map +1 -0
  21. package/dist/channels/binop.d.ts +22 -0
  22. package/dist/channels/binop.d.ts.map +1 -0
  23. package/dist/channels/binop.js +49 -0
  24. package/dist/channels/binop.js.map +1 -0
  25. package/dist/channels/dynamic_barrier_value.cjs +75 -0
  26. package/dist/channels/dynamic_barrier_value.cjs.map +1 -0
  27. package/dist/channels/dynamic_barrier_value.d.cts +40 -0
  28. package/dist/channels/dynamic_barrier_value.d.cts.map +1 -0
  29. package/dist/channels/dynamic_barrier_value.d.ts +40 -0
  30. package/dist/channels/dynamic_barrier_value.d.ts.map +1 -0
  31. package/dist/channels/dynamic_barrier_value.js +75 -0
  32. package/dist/channels/dynamic_barrier_value.js.map +1 -0
  33. package/dist/channels/ephemeral_value.cjs +46 -0
  34. package/dist/channels/ephemeral_value.cjs.map +1 -0
  35. package/dist/channels/ephemeral_value.d.cts +21 -0
  36. package/dist/channels/ephemeral_value.d.cts.map +1 -0
  37. package/dist/channels/ephemeral_value.d.ts +21 -0
  38. package/dist/channels/ephemeral_value.d.ts.map +1 -0
  39. package/dist/channels/ephemeral_value.js +46 -0
  40. package/dist/channels/ephemeral_value.js.map +1 -0
  41. package/dist/channels/index.cjs +21 -0
  42. package/dist/channels/index.d.cts +9 -0
  43. package/dist/channels/index.d.ts +9 -0
  44. package/dist/channels/index.js +10 -0
  45. package/dist/channels/last_value.cjs +98 -0
  46. package/dist/channels/last_value.cjs.map +1 -0
  47. package/dist/channels/last_value.d.cts +42 -0
  48. package/dist/channels/last_value.d.cts.map +1 -0
  49. package/dist/channels/last_value.d.ts +42 -0
  50. package/dist/channels/last_value.d.ts.map +1 -0
  51. package/dist/channels/last_value.js +97 -0
  52. package/dist/channels/last_value.js.map +1 -0
  53. package/dist/channels/named_barrier_value.cjs +116 -0
  54. package/dist/channels/named_barrier_value.cjs.map +1 -0
  55. package/dist/channels/named_barrier_value.d.cts +44 -0
  56. package/dist/channels/named_barrier_value.d.cts.map +1 -0
  57. package/dist/channels/named_barrier_value.d.ts +44 -0
  58. package/dist/channels/named_barrier_value.d.ts.map +1 -0
  59. package/dist/channels/named_barrier_value.js +114 -0
  60. package/dist/channels/named_barrier_value.js.map +1 -0
  61. package/dist/channels/topic.cjs +65 -0
  62. package/dist/channels/topic.cjs.map +1 -0
  63. package/dist/channels/topic.d.cts +32 -0
  64. package/dist/channels/topic.d.cts.map +1 -0
  65. package/dist/channels/topic.d.ts +32 -0
  66. package/dist/channels/topic.d.ts.map +1 -0
  67. package/dist/channels/topic.js +65 -0
  68. package/dist/channels/topic.js.map +1 -0
  69. package/dist/constants.cjs +406 -0
  70. package/dist/constants.cjs.map +1 -0
  71. package/dist/constants.d.cts +281 -0
  72. package/dist/constants.d.cts.map +1 -0
  73. package/dist/constants.d.ts +281 -0
  74. package/dist/constants.d.ts.map +1 -0
  75. package/dist/constants.js +362 -0
  76. package/dist/constants.js.map +1 -0
  77. package/dist/errors.cjs +163 -0
  78. package/dist/errors.cjs.map +1 -0
  79. package/dist/errors.d.cts +77 -0
  80. package/dist/errors.d.cts.map +1 -0
  81. package/dist/errors.d.ts +77 -0
  82. package/dist/errors.d.ts.map +1 -0
  83. package/dist/errors.js +146 -0
  84. package/dist/errors.js.map +1 -0
  85. package/dist/func/index.cjs +299 -0
  86. package/dist/func/index.cjs.map +1 -0
  87. package/dist/func/index.d.cts +288 -0
  88. package/dist/func/index.d.cts.map +1 -0
  89. package/dist/func/index.d.ts +288 -0
  90. package/dist/func/index.d.ts.map +1 -0
  91. package/dist/func/index.js +297 -0
  92. package/dist/func/index.js.map +1 -0
  93. package/dist/func/types.d.cts +62 -0
  94. package/dist/func/types.d.cts.map +1 -0
  95. package/dist/func/types.d.ts +62 -0
  96. package/dist/func/types.d.ts.map +1 -0
  97. package/dist/graph/annotation.cjs +101 -0
  98. package/dist/graph/annotation.cjs.map +1 -0
  99. package/dist/graph/annotation.d.cts +116 -0
  100. package/dist/graph/annotation.d.cts.map +1 -0
  101. package/dist/graph/annotation.d.ts +116 -0
  102. package/dist/graph/annotation.d.ts.map +1 -0
  103. package/dist/graph/annotation.js +99 -0
  104. package/dist/graph/annotation.js.map +1 -0
  105. package/dist/graph/graph.cjs +420 -0
  106. package/dist/graph/graph.cjs.map +1 -0
  107. package/dist/graph/graph.d.cts +108 -0
  108. package/dist/graph/graph.d.cts.map +1 -0
  109. package/dist/graph/graph.d.ts +108 -0
  110. package/dist/graph/graph.d.ts.map +1 -0
  111. package/dist/graph/graph.js +418 -0
  112. package/dist/graph/graph.js.map +1 -0
  113. package/dist/graph/index.cjs +5 -0
  114. package/dist/graph/index.js +7 -0
  115. package/dist/graph/message.cjs +97 -0
  116. package/dist/graph/message.cjs.map +1 -0
  117. package/dist/graph/message.d.cts +40 -0
  118. package/dist/graph/message.d.cts.map +1 -0
  119. package/dist/graph/message.d.ts +40 -0
  120. package/dist/graph/message.d.ts.map +1 -0
  121. package/dist/graph/message.js +94 -0
  122. package/dist/graph/message.js.map +1 -0
  123. package/dist/graph/messages_annotation.cjs +109 -0
  124. package/dist/graph/messages_annotation.cjs.map +1 -0
  125. package/dist/graph/messages_annotation.d.cts +112 -0
  126. package/dist/graph/messages_annotation.d.cts.map +1 -0
  127. package/dist/graph/messages_annotation.d.ts +112 -0
  128. package/dist/graph/messages_annotation.d.ts.map +1 -0
  129. package/dist/graph/messages_annotation.js +107 -0
  130. package/dist/graph/messages_annotation.js.map +1 -0
  131. package/dist/graph/state.cjs +494 -0
  132. package/dist/graph/state.cjs.map +1 -0
  133. package/dist/graph/state.d.cts +229 -0
  134. package/dist/graph/state.d.cts.map +1 -0
  135. package/dist/graph/state.d.ts +229 -0
  136. package/dist/graph/state.d.ts.map +1 -0
  137. package/dist/graph/state.js +493 -0
  138. package/dist/graph/state.js.map +1 -0
  139. package/dist/graph/zod/index.cjs +10 -0
  140. package/dist/graph/zod/index.d.cts +3 -0
  141. package/dist/graph/zod/index.d.ts +3 -0
  142. package/dist/graph/zod/index.js +5 -0
  143. package/dist/graph/zod/meta.cjs +144 -0
  144. package/dist/graph/zod/meta.cjs.map +1 -0
  145. package/dist/graph/zod/meta.d.cts +115 -0
  146. package/dist/graph/zod/meta.d.cts.map +1 -0
  147. package/dist/graph/zod/meta.d.ts +115 -0
  148. package/dist/graph/zod/meta.d.ts.map +1 -0
  149. package/dist/graph/zod/meta.js +141 -0
  150. package/dist/graph/zod/meta.js.map +1 -0
  151. package/dist/graph/zod/plugin.cjs +39 -0
  152. package/dist/graph/zod/plugin.cjs.map +1 -0
  153. package/dist/graph/zod/plugin.js +40 -0
  154. package/dist/graph/zod/plugin.js.map +1 -0
  155. package/dist/graph/zod/schema.cjs +98 -0
  156. package/dist/graph/zod/schema.cjs.map +1 -0
  157. package/dist/graph/zod/schema.d.cts +38 -0
  158. package/dist/graph/zod/schema.d.cts.map +1 -0
  159. package/dist/graph/zod/schema.d.ts +38 -0
  160. package/dist/graph/zod/schema.d.ts.map +1 -0
  161. package/dist/graph/zod/schema.js +94 -0
  162. package/dist/graph/zod/schema.js.map +1 -0
  163. package/dist/graph/zod/zod-registry.cjs +42 -0
  164. package/dist/graph/zod/zod-registry.cjs.map +1 -0
  165. package/dist/graph/zod/zod-registry.d.cts +49 -0
  166. package/dist/graph/zod/zod-registry.d.cts.map +1 -0
  167. package/dist/graph/zod/zod-registry.d.ts +49 -0
  168. package/dist/graph/zod/zod-registry.d.ts.map +1 -0
  169. package/dist/graph/zod/zod-registry.js +41 -0
  170. package/dist/graph/zod/zod-registry.js.map +1 -0
  171. package/dist/hash.cjs +265 -0
  172. package/dist/hash.cjs.map +1 -0
  173. package/dist/hash.js +263 -0
  174. package/dist/hash.js.map +1 -0
  175. package/dist/index.cjs +111 -0
  176. package/dist/index.cjs.map +1 -0
  177. package/dist/index.d.cts +26 -0
  178. package/dist/index.d.ts +26 -0
  179. package/dist/index.js +22 -0
  180. package/dist/index.js.map +1 -0
  181. package/dist/interrupt.cjs +79 -0
  182. package/dist/interrupt.cjs.map +1 -0
  183. package/dist/interrupt.d.cts +55 -0
  184. package/dist/interrupt.d.cts.map +1 -0
  185. package/dist/interrupt.d.ts +55 -0
  186. package/dist/interrupt.d.ts.map +1 -0
  187. package/dist/interrupt.js +79 -0
  188. package/dist/interrupt.js.map +1 -0
  189. package/dist/prebuilt/agentName.cjs +148 -0
  190. package/dist/prebuilt/agentName.cjs.map +1 -0
  191. package/dist/prebuilt/agentName.d.cts +42 -0
  192. package/dist/prebuilt/agentName.d.cts.map +1 -0
  193. package/dist/prebuilt/agentName.d.ts +42 -0
  194. package/dist/prebuilt/agentName.d.ts.map +1 -0
  195. package/dist/prebuilt/agentName.js +148 -0
  196. package/dist/prebuilt/agentName.js.map +1 -0
  197. package/dist/prebuilt/agent_executor.cjs +41 -0
  198. package/dist/prebuilt/agent_executor.cjs.map +1 -0
  199. package/dist/prebuilt/agent_executor.d.cts +58 -0
  200. package/dist/prebuilt/agent_executor.d.cts.map +1 -0
  201. package/dist/prebuilt/agent_executor.d.ts +58 -0
  202. package/dist/prebuilt/agent_executor.d.ts.map +1 -0
  203. package/dist/prebuilt/agent_executor.js +41 -0
  204. package/dist/prebuilt/agent_executor.js.map +1 -0
  205. package/dist/prebuilt/chat_agent_executor.cjs +62 -0
  206. package/dist/prebuilt/chat_agent_executor.cjs.map +1 -0
  207. package/dist/prebuilt/chat_agent_executor.d.cts +23 -0
  208. package/dist/prebuilt/chat_agent_executor.d.cts.map +1 -0
  209. package/dist/prebuilt/chat_agent_executor.d.ts +23 -0
  210. package/dist/prebuilt/chat_agent_executor.d.ts.map +1 -0
  211. package/dist/prebuilt/chat_agent_executor.js +62 -0
  212. package/dist/prebuilt/chat_agent_executor.js.map +1 -0
  213. package/dist/prebuilt/index.cjs +15 -0
  214. package/dist/prebuilt/index.d.cts +8 -0
  215. package/dist/prebuilt/index.d.ts +8 -0
  216. package/dist/prebuilt/index.js +8 -0
  217. package/dist/prebuilt/interrupt.d.cts +60 -0
  218. package/dist/prebuilt/interrupt.d.cts.map +1 -0
  219. package/dist/prebuilt/interrupt.d.ts +60 -0
  220. package/dist/prebuilt/interrupt.d.ts.map +1 -0
  221. package/dist/prebuilt/react_agent_executor.cjs +339 -0
  222. package/dist/prebuilt/react_agent_executor.cjs.map +1 -0
  223. package/dist/prebuilt/react_agent_executor.d.cts +211 -0
  224. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -0
  225. package/dist/prebuilt/react_agent_executor.d.ts +211 -0
  226. package/dist/prebuilt/react_agent_executor.d.ts.map +1 -0
  227. package/dist/prebuilt/react_agent_executor.js +338 -0
  228. package/dist/prebuilt/react_agent_executor.js.map +1 -0
  229. package/dist/prebuilt/tool_executor.cjs +43 -0
  230. package/dist/prebuilt/tool_executor.cjs.map +1 -0
  231. package/dist/prebuilt/tool_executor.d.cts +40 -0
  232. package/dist/prebuilt/tool_executor.d.cts.map +1 -0
  233. package/dist/prebuilt/tool_executor.d.ts +40 -0
  234. package/dist/prebuilt/tool_executor.d.ts.map +1 -0
  235. package/dist/prebuilt/tool_executor.js +43 -0
  236. package/dist/prebuilt/tool_executor.js.map +1 -0
  237. package/dist/prebuilt/tool_node.cjs +247 -0
  238. package/dist/prebuilt/tool_node.cjs.map +1 -0
  239. package/dist/prebuilt/tool_node.d.cts +180 -0
  240. package/dist/prebuilt/tool_node.d.cts.map +1 -0
  241. package/dist/prebuilt/tool_node.d.ts +180 -0
  242. package/dist/prebuilt/tool_node.d.ts.map +1 -0
  243. package/dist/prebuilt/tool_node.js +246 -0
  244. package/dist/prebuilt/tool_node.js.map +1 -0
  245. package/dist/pregel/algo.cjs +565 -0
  246. package/dist/pregel/algo.cjs.map +1 -0
  247. package/dist/pregel/algo.d.cts +13 -0
  248. package/dist/pregel/algo.d.cts.map +1 -0
  249. package/dist/pregel/algo.d.ts +13 -0
  250. package/dist/pregel/algo.d.ts.map +1 -0
  251. package/dist/pregel/algo.js +560 -0
  252. package/dist/pregel/algo.js.map +1 -0
  253. package/dist/pregel/call.cjs +50 -0
  254. package/dist/pregel/call.cjs.map +1 -0
  255. package/dist/pregel/call.js +48 -0
  256. package/dist/pregel/call.js.map +1 -0
  257. package/dist/pregel/debug.cjs +172 -0
  258. package/dist/pregel/debug.cjs.map +1 -0
  259. package/dist/pregel/debug.js +166 -0
  260. package/dist/pregel/debug.js.map +1 -0
  261. package/dist/pregel/index.cjs +1163 -0
  262. package/dist/pregel/index.cjs.map +1 -0
  263. package/dist/pregel/index.d.cts +498 -0
  264. package/dist/pregel/index.d.cts.map +1 -0
  265. package/dist/pregel/index.d.ts +498 -0
  266. package/dist/pregel/index.d.ts.map +1 -0
  267. package/dist/pregel/index.js +1162 -0
  268. package/dist/pregel/index.js.map +1 -0
  269. package/dist/pregel/io.cjs +140 -0
  270. package/dist/pregel/io.cjs.map +1 -0
  271. package/dist/pregel/io.js +135 -0
  272. package/dist/pregel/io.js.map +1 -0
  273. package/dist/pregel/loop.cjs +545 -0
  274. package/dist/pregel/loop.cjs.map +1 -0
  275. package/dist/pregel/loop.js +545 -0
  276. package/dist/pregel/loop.js.map +1 -0
  277. package/dist/pregel/messages.cjs +107 -0
  278. package/dist/pregel/messages.cjs.map +1 -0
  279. package/dist/pregel/messages.js +107 -0
  280. package/dist/pregel/messages.js.map +1 -0
  281. package/dist/pregel/read.cjs +151 -0
  282. package/dist/pregel/read.cjs.map +1 -0
  283. package/dist/pregel/read.d.cts +45 -0
  284. package/dist/pregel/read.d.cts.map +1 -0
  285. package/dist/pregel/read.d.ts +45 -0
  286. package/dist/pregel/read.d.ts.map +1 -0
  287. package/dist/pregel/read.js +150 -0
  288. package/dist/pregel/read.js.map +1 -0
  289. package/dist/pregel/remote.cjs +341 -0
  290. package/dist/pregel/remote.cjs.map +1 -0
  291. package/dist/pregel/remote.d.cts +118 -0
  292. package/dist/pregel/remote.d.cts.map +1 -0
  293. package/dist/pregel/remote.d.ts +118 -0
  294. package/dist/pregel/remote.d.ts.map +1 -0
  295. package/dist/pregel/remote.js +341 -0
  296. package/dist/pregel/remote.js.map +1 -0
  297. package/dist/pregel/retry.cjs +91 -0
  298. package/dist/pregel/retry.cjs.map +1 -0
  299. package/dist/pregel/retry.js +91 -0
  300. package/dist/pregel/retry.js.map +1 -0
  301. package/dist/pregel/runnable_types.d.cts +43 -0
  302. package/dist/pregel/runnable_types.d.cts.map +1 -0
  303. package/dist/pregel/runnable_types.d.ts +43 -0
  304. package/dist/pregel/runnable_types.d.ts.map +1 -0
  305. package/dist/pregel/runner.cjs +228 -0
  306. package/dist/pregel/runner.cjs.map +1 -0
  307. package/dist/pregel/runner.js +228 -0
  308. package/dist/pregel/runner.js.map +1 -0
  309. package/dist/pregel/stream.cjs +197 -0
  310. package/dist/pregel/stream.cjs.map +1 -0
  311. package/dist/pregel/stream.js +195 -0
  312. package/dist/pregel/stream.js.map +1 -0
  313. package/dist/pregel/types.cjs +27 -0
  314. package/dist/pregel/types.cjs.map +1 -0
  315. package/dist/pregel/types.d.cts +440 -0
  316. package/dist/pregel/types.d.cts.map +1 -0
  317. package/dist/pregel/types.d.ts +440 -0
  318. package/dist/pregel/types.d.ts.map +1 -0
  319. package/dist/pregel/types.js +25 -0
  320. package/dist/pregel/types.js.map +1 -0
  321. package/dist/pregel/utils/config.cjs +121 -0
  322. package/dist/pregel/utils/config.cjs.map +1 -0
  323. package/dist/pregel/utils/config.d.cts +36 -0
  324. package/dist/pregel/utils/config.d.cts.map +1 -0
  325. package/dist/pregel/utils/config.d.ts +36 -0
  326. package/dist/pregel/utils/config.d.ts.map +1 -0
  327. package/dist/pregel/utils/config.js +115 -0
  328. package/dist/pregel/utils/config.js.map +1 -0
  329. package/dist/pregel/utils/index.cjs +102 -0
  330. package/dist/pregel/utils/index.cjs.map +1 -0
  331. package/dist/pregel/utils/index.d.cts +51 -0
  332. package/dist/pregel/utils/index.d.cts.map +1 -0
  333. package/dist/pregel/utils/index.d.ts +51 -0
  334. package/dist/pregel/utils/index.d.ts.map +1 -0
  335. package/dist/pregel/utils/index.js +96 -0
  336. package/dist/pregel/utils/index.js.map +1 -0
  337. package/dist/pregel/utils/subgraph.cjs +18 -0
  338. package/dist/pregel/utils/subgraph.cjs.map +1 -0
  339. package/dist/pregel/utils/subgraph.js +16 -0
  340. package/dist/pregel/utils/subgraph.js.map +1 -0
  341. package/dist/pregel/validate.cjs +45 -0
  342. package/dist/pregel/validate.cjs.map +1 -0
  343. package/dist/pregel/validate.js +44 -0
  344. package/dist/pregel/validate.js.map +1 -0
  345. package/dist/pregel/write.cjs +96 -0
  346. package/dist/pregel/write.cjs.map +1 -0
  347. package/dist/pregel/write.d.cts +31 -0
  348. package/dist/pregel/write.d.cts.map +1 -0
  349. package/dist/pregel/write.d.ts +31 -0
  350. package/dist/pregel/write.d.ts.map +1 -0
  351. package/dist/pregel/write.js +95 -0
  352. package/dist/pregel/write.js.map +1 -0
  353. package/dist/remote.cjs +3 -0
  354. package/dist/remote.d.cts +2 -0
  355. package/dist/remote.d.ts +2 -0
  356. package/dist/remote.js +3 -0
  357. package/dist/setup/async_local_storage.cjs +11 -0
  358. package/dist/setup/async_local_storage.cjs.map +1 -0
  359. package/dist/setup/async_local_storage.js +11 -0
  360. package/dist/setup/async_local_storage.js.map +1 -0
  361. package/dist/utils.cjs +86 -0
  362. package/dist/utils.cjs.map +1 -0
  363. package/dist/utils.d.cts +25 -0
  364. package/dist/utils.d.cts.map +1 -0
  365. package/dist/utils.d.ts +25 -0
  366. package/dist/utils.d.ts.map +1 -0
  367. package/dist/utils.js +80 -0
  368. package/dist/utils.js.map +1 -0
  369. package/dist/web.cjs +95 -0
  370. package/dist/web.d.cts +23 -0
  371. package/dist/web.d.ts +23 -0
  372. package/dist/web.js +15 -0
  373. package/dist/writer.cjs +14 -0
  374. package/dist/writer.cjs.map +1 -0
  375. package/dist/writer.d.cts +6 -0
  376. package/dist/writer.d.cts.map +1 -0
  377. package/dist/writer.d.ts +6 -0
  378. package/dist/writer.d.ts.map +1 -0
  379. package/dist/writer.js +14 -0
  380. package/dist/writer.js.map +1 -0
  381. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.cts","names":["Command","Interrupt","BaseLangGraphErrorFields","BaseLangGraphError","Error","GraphBubbleUp","GraphRecursionError","GraphValueError","GraphInterrupt","NodeInterrupt","ParentCommand","isParentCommand","isGraphBubbleUp","isGraphInterrupt","EmptyInputError","EmptyChannelError","InvalidUpdateError","MultipleSubgraphsError","UnreachableNodeError","RemoteException","getSubgraphsSeenSet"],"sources":["../src/errors.d.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\nexport type BaseLangGraphErrorFields = {\n lc_error_code?: \"GRAPH_RECURSION_LIMIT\" | \"INVALID_CONCURRENT_GRAPH_UPDATE\" | \"INVALID_GRAPH_NODE_RETURN_VALUE\" | \"MISSING_CHECKPOINTER\" | \"MULTIPLE_SUBGRAPHS\" | \"UNREACHABLE_NODE\";\n};\n/** @category Errors */\nexport declare class BaseLangGraphError extends Error {\n lc_error_code?: string;\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n}\nexport declare class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up(): boolean;\n}\nexport declare class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/** Raised by a node to interrupt execution. */\nexport declare class NodeInterrupt extends GraphInterrupt {\n constructor(message: any, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class ParentCommand extends GraphBubbleUp {\n command: Command;\n constructor(command: Command);\n static get unminifiable_name(): string;\n}\nexport declare function isParentCommand(e?: unknown): e is ParentCommand;\nexport declare function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp;\nexport declare function isGraphInterrupt(e?: unknown): e is GraphInterrupt;\nexport declare class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport declare class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport declare class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Used for subgraph detection.\n */\nexport declare const getSubgraphsSeenSet: () => any;\n"],"mappings":";;;KACYE,wBAAAA;;AAAZ,CAAA;AAIA;AAAuC,cAAlBC,kBAAAA,SAA2BC,KAAAA,CAAT;eAEIF,CAAAA,EAAAA,MAAAA;aAFKE,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAELF,wBAFKE;;AAI3BC,cAAAA,aAAAA,SAAsBF,kBAAAA,CAAkB;EAGxCG,IAAAA,YAAAA,CAAAA,CAAAA,EAAAA,OAAmB;;AACGJ,cADtBI,mBAAAA,SAA4BH,kBAAAA,CACND;aADMC,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EACND,wBADMC;EAAkB,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;AAInE;AAAoC,cAAfI,eAAAA,SAAwBJ,kBAAAA,CAAT;aACOD,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAAAA,wBAAAA;aADEC,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;AAIxBK,cAAAA,cAAAA,SAAuBH,aAAAA,CAAT;EAAA,UAAA,EACnBJ,SADmB,EAAA;aACnBA,CAAAA,UAAAA,CAAAA,EACaA,SADbA,EAAAA,EAAAA,MAAAA,CAAAA,EACmCC,wBADnCD;aACaA,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;;AAF4B,cAMpCQ,aAAAA,SAAsBD,cAAAA,CANc;EAMpCC,WAAAA,CAAAA,OAAa,EAAA,GAAA,EAAA,MAAA,CAAA,EACKP,wBADL;EAAA,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;;AAASM,cAItBE,aAAAA,SAAsBL,aAAAA,CAJAG;EAAc,OAAA,EAK5CR,OAL4C;EAIpCU,WAAAA,CAAAA,OAAa,EAETV,OAFS;E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AO7BgB,eAAAA,SAAwBhB,kBAAAA,CAPKA;EAAkB,WAAA,CAAA,OAAA,CAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAQzBD,wBARyB;EAO/CiB,WAAAA,iBAAe,CAAA,CAAA,EAAA,MAAA;;;;;AAOfC,cAAAA,mBAA8B,EAAA,GAAA,GAAA,GAAA"}
@@ -0,0 +1,77 @@
1
+ import { Command, Interrupt } from "./constants.js";
2
+
3
+ //#region src/errors.d.ts
4
+ type BaseLangGraphErrorFields = {
5
+ lc_error_code?: "GRAPH_RECURSION_LIMIT" | "INVALID_CONCURRENT_GRAPH_UPDATE" | "INVALID_GRAPH_NODE_RETURN_VALUE" | "MISSING_CHECKPOINTER" | "MULTIPLE_SUBGRAPHS" | "UNREACHABLE_NODE";
6
+ };
7
+ /** @category Errors */
8
+ declare class BaseLangGraphError extends Error {
9
+ lc_error_code?: string;
10
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
11
+ }
12
+ declare class GraphBubbleUp extends BaseLangGraphError {
13
+ get is_bubble_up(): boolean;
14
+ }
15
+ declare class GraphRecursionError extends BaseLangGraphError {
16
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
17
+ static get unminifiable_name(): string;
18
+ }
19
+ declare class GraphValueError extends BaseLangGraphError {
20
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
21
+ static get unminifiable_name(): string;
22
+ }
23
+ declare class GraphInterrupt extends GraphBubbleUp {
24
+ interrupts: Interrupt[];
25
+ constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields);
26
+ static get unminifiable_name(): string;
27
+ }
28
+ /** Raised by a node to interrupt execution. */
29
+ declare class NodeInterrupt extends GraphInterrupt {
30
+ constructor(message: any, fields?: BaseLangGraphErrorFields);
31
+ static get unminifiable_name(): string;
32
+ }
33
+ declare class ParentCommand extends GraphBubbleUp {
34
+ command: Command;
35
+ constructor(command: Command);
36
+ static get unminifiable_name(): string;
37
+ }
38
+ declare function isParentCommand(e?: unknown): e is ParentCommand;
39
+ declare function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp;
40
+ declare function isGraphInterrupt(e?: unknown): e is GraphInterrupt;
41
+ declare class EmptyInputError extends BaseLangGraphError {
42
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
43
+ static get unminifiable_name(): string;
44
+ }
45
+ declare class EmptyChannelError extends BaseLangGraphError {
46
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
47
+ static get unminifiable_name(): string;
48
+ }
49
+ declare class InvalidUpdateError extends BaseLangGraphError {
50
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
51
+ static get unminifiable_name(): string;
52
+ }
53
+ /**
54
+ * @deprecated This exception type is no longer thrown.
55
+ */
56
+ declare class MultipleSubgraphsError extends BaseLangGraphError {
57
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
58
+ static get unminifiable_name(): string;
59
+ }
60
+ declare class UnreachableNodeError extends BaseLangGraphError {
61
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
62
+ static get unminifiable_name(): string;
63
+ }
64
+ /**
65
+ * Exception raised when an error occurs in the remote graph.
66
+ */
67
+ declare class RemoteException extends BaseLangGraphError {
68
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
69
+ static get unminifiable_name(): string;
70
+ }
71
+ /**
72
+ * Used for subgraph detection.
73
+ */
74
+ declare const getSubgraphsSeenSet: () => any;
75
+ //#endregion
76
+ export { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand };
77
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","names":["Command","Interrupt","BaseLangGraphErrorFields","BaseLangGraphError","Error","GraphBubbleUp","GraphRecursionError","GraphValueError","GraphInterrupt","NodeInterrupt","ParentCommand","isParentCommand","isGraphBubbleUp","isGraphInterrupt","EmptyInputError","EmptyChannelError","InvalidUpdateError","MultipleSubgraphsError","UnreachableNodeError","RemoteException","getSubgraphsSeenSet"],"sources":["../src/errors.d.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\nexport type BaseLangGraphErrorFields = {\n lc_error_code?: \"GRAPH_RECURSION_LIMIT\" | \"INVALID_CONCURRENT_GRAPH_UPDATE\" | \"INVALID_GRAPH_NODE_RETURN_VALUE\" | \"MISSING_CHECKPOINTER\" | \"MULTIPLE_SUBGRAPHS\" | \"UNREACHABLE_NODE\";\n};\n/** @category Errors */\nexport declare class BaseLangGraphError extends Error {\n lc_error_code?: string;\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n}\nexport declare class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up(): boolean;\n}\nexport declare class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/** Raised by a node to interrupt execution. */\nexport declare class NodeInterrupt extends GraphInterrupt {\n constructor(message: any, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class ParentCommand extends GraphBubbleUp {\n command: Command;\n constructor(command: Command);\n static get unminifiable_name(): string;\n}\nexport declare function isParentCommand(e?: unknown): e is ParentCommand;\nexport declare function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp;\nexport declare function isGraphInterrupt(e?: unknown): e is GraphInterrupt;\nexport declare class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport declare class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport declare class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Used for subgraph detection.\n */\nexport declare const getSubgraphsSeenSet: () => any;\n"],"mappings":";;;KACYE,wBAAAA;;AAAZ,CAAA;AAIA;AAAuC,cAAlBC,kBAAAA,SAA2BC,KAAAA,CAAT;eAEIF,CAAAA,EAAAA,MAAAA;aAFKE,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAELF,wBAFKE;;AAI3BC,cAAAA,aAAAA,SAAsBF,kBAAAA,CAAkB;EAGxCG,IAAAA,YAAAA,CAAAA,CAAAA,EAAAA,OAAmB;;AACGJ,cADtBI,mBAAAA,SAA4BH,kBAAAA,CACND;aADMC,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EACND,wBADMC;EAAkB,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;AAInE;AAAoC,cAAfI,eAAAA,SAAwBJ,kBAAAA,CAAT;aACOD,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAAAA,wBAAAA;aADEC,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;AAIx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AA,CAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAKKD,wBALL;aACKA,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;;AAG3C;;AAC2CA,cAMtBe,sBAAAA,SAA+Bd,kBAAAA,CANTD;aADKC,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAQLD,wBARKC;EAAkB,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;AAOlE;AAA2C,cAItBe,oBAAAA,SAA6Bf,kBAAAA,CAJP;aACAD,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAIAA,wBAJAA;aADSC,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;AAIpD;;;AAAkDA,cAO7BgB,eAAAA,SAAwBhB,kBAAAA,CAPKA;EAAkB,WAAA,CAAA,OAAA,CAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAQzBD,wBARyB;EAO/CiB,WAAAA,iBAAe,CAAA,CAAA,EAAA,MAAA;;;;;AAOfC,cAAAA,mBAA8B,EAAA,GAAA,GAAA,GAAA"}
package/dist/errors.js ADDED
@@ -0,0 +1,146 @@
1
+ //#region src/errors.ts
2
+ /** @category Errors */
3
+ var BaseLangGraphError = class extends Error {
4
+ lc_error_code;
5
+ constructor(message, fields) {
6
+ let finalMessage = message ?? "";
7
+ if (fields?.lc_error_code) finalMessage = `${finalMessage}\n\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${fields.lc_error_code}/\n`;
8
+ super(finalMessage);
9
+ this.lc_error_code = fields?.lc_error_code;
10
+ }
11
+ };
12
+ var GraphBubbleUp = class extends BaseLangGraphError {
13
+ get is_bubble_up() {
14
+ return true;
15
+ }
16
+ };
17
+ var GraphRecursionError = class extends BaseLangGraphError {
18
+ constructor(message, fields) {
19
+ super(message, fields);
20
+ this.name = "GraphRecursionError";
21
+ }
22
+ static get unminifiable_name() {
23
+ return "GraphRecursionError";
24
+ }
25
+ };
26
+ var GraphValueError = class extends BaseLangGraphError {
27
+ constructor(message, fields) {
28
+ super(message, fields);
29
+ this.name = "GraphValueError";
30
+ }
31
+ static get unminifiable_name() {
32
+ return "GraphValueError";
33
+ }
34
+ };
35
+ var GraphInterrupt = class extends GraphBubbleUp {
36
+ interrupts;
37
+ constructor(interrupts, fields) {
38
+ super(JSON.stringify(interrupts, null, 2), fields);
39
+ this.name = "GraphInterrupt";
40
+ this.interrupts = interrupts ?? [];
41
+ }
42
+ static get unminifiable_name() {
43
+ return "GraphInterrupt";
44
+ }
45
+ };
46
+ /** Raised by a node to interrupt execution. */
47
+ var NodeInterrupt = class extends GraphInterrupt {
48
+ constructor(message, fields) {
49
+ super([{ value: message }], fields);
50
+ this.name = "NodeInterrupt";
51
+ }
52
+ static get unminifiable_name() {
53
+ return "NodeInterrupt";
54
+ }
55
+ };
56
+ var ParentCommand = class extends GraphBubbleUp {
57
+ command;
58
+ constructor(command) {
59
+ super();
60
+ this.name = "ParentCommand";
61
+ this.command = command;
62
+ }
63
+ static get unminifiable_name() {
64
+ return "ParentCommand";
65
+ }
66
+ };
67
+ function isParentCommand(e) {
68
+ return e !== void 0 && e.name === ParentCommand.unminifiable_name;
69
+ }
70
+ function isGraphBubbleUp(e) {
71
+ return e !== void 0 && e.is_bubble_up === true;
72
+ }
73
+ function isGraphInterrupt(e) {
74
+ return e !== void 0 && [GraphInterrupt.unminifiable_name, NodeInterrupt.unminifiable_name].includes(e.name);
75
+ }
76
+ var EmptyInputError = class extends BaseLangGraphError {
77
+ constructor(message, fields) {
78
+ super(message, fields);
79
+ this.name = "EmptyInputError";
80
+ }
81
+ static get unminifiable_name() {
82
+ return "EmptyInputError";
83
+ }
84
+ };
85
+ var EmptyChannelError = class extends BaseLangGraphError {
86
+ constructor(message, fields) {
87
+ super(message, fields);
88
+ this.name = "EmptyChannelError";
89
+ }
90
+ static get unminifiable_name() {
91
+ return "EmptyChannelError";
92
+ }
93
+ };
94
+ var InvalidUpdateError = class extends BaseLangGraphError {
95
+ constructor(message, fields) {
96
+ super(message, fields);
97
+ this.name = "InvalidUpdateError";
98
+ }
99
+ static get unminifiable_name() {
100
+ return "InvalidUpdateError";
101
+ }
102
+ };
103
+ /**
104
+ * @deprecated This exception type is no longer thrown.
105
+ */
106
+ var MultipleSubgraphsError = class extends BaseLangGraphError {
107
+ constructor(message, fields) {
108
+ super(message, fields);
109
+ this.name = "MultipleSubgraphError";
110
+ }
111
+ static get unminifiable_name() {
112
+ return "MultipleSubgraphError";
113
+ }
114
+ };
115
+ var UnreachableNodeError = class extends BaseLangGraphError {
116
+ constructor(message, fields) {
117
+ super(message, fields);
118
+ this.name = "UnreachableNodeError";
119
+ }
120
+ static get unminifiable_name() {
121
+ return "UnreachableNodeError";
122
+ }
123
+ };
124
+ /**
125
+ * Exception raised when an error occurs in the remote graph.
126
+ */
127
+ var RemoteException = class extends BaseLangGraphError {
128
+ constructor(message, fields) {
129
+ super(message, fields);
130
+ this.name = "RemoteException";
131
+ }
132
+ static get unminifiable_name() {
133
+ return "RemoteException";
134
+ }
135
+ };
136
+ /**
137
+ * Used for subgraph detection.
138
+ */
139
+ const getSubgraphsSeenSet = () => {
140
+ if (globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")] === void 0) globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")] = /* @__PURE__ */ new Set();
141
+ return globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")];
142
+ };
143
+
144
+ //#endregion
145
+ export { BaseLangGraphError, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand };
146
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\n\n// When editing, make sure to update the index found here:\n// https://langchain-ai.github.io/langgraphjs/troubleshooting/errors/\nexport type BaseLangGraphErrorFields = {\n lc_error_code?:\n | \"GRAPH_RECURSION_LIMIT\"\n | \"INVALID_CONCURRENT_GRAPH_UPDATE\"\n | \"INVALID_GRAPH_NODE_RETURN_VALUE\"\n | \"MISSING_CHECKPOINTER\"\n | \"MULTIPLE_SUBGRAPHS\"\n | \"UNREACHABLE_NODE\";\n};\n\n// TODO: Merge with base LangChain error class when we drop support for core@0.2.0\n/** @category Errors */\nexport class BaseLangGraphError extends Error {\n lc_error_code?: string;\n\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n let finalMessage = message ?? \"\";\n if (fields?.lc_error_code) {\n finalMessage = `${finalMessage}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${fields.lc_error_code}/\\n`;\n }\n super(finalMessage);\n this.lc_error_code = fields?.lc_error_code;\n }\n}\n\nexport class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up() {\n return true;\n }\n}\n\nexport class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphRecursionError\";\n }\n\n static get unminifiable_name() {\n return \"GraphRecursionError\";\n }\n}\n\nexport class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphValueError\";\n }\n\n static get unminifiable_name() {\n return \"GraphValueError\";\n }\n}\n\nexport class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields) {\n super(JSON.stringify(interrupts, null, 2), fields);\n this.name = \"GraphInterrupt\";\n this.interrupts = interrupts ?? [];\n }\n\n static get unminifiable_name() {\n return \"GraphInterrupt\";\n }\n}\n\n/** Raised by a node to interrupt execution. */\nexport class NodeInterrupt extends GraphInterrupt {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(message: any, fields?: BaseLangGraphErrorFields) {\n super([{ value: message }], fields);\n this.name = \"NodeInterrupt\";\n }\n\n static get unminifiable_name() {\n return \"NodeInterrupt\";\n }\n}\n\nexport class ParentCommand extends GraphBubbleUp {\n command: Command;\n\n constructor(command: Command) {\n super();\n this.name = \"ParentCommand\";\n this.command = command;\n }\n\n static get unminifiable_name() {\n return \"ParentCommand\";\n }\n}\n\nexport function isParentCommand(e?: unknown): e is ParentCommand {\n return (\n e !== undefined &&\n (e as ParentCommand).name === ParentCommand.unminifiable_name\n );\n}\n\nexport function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp {\n return e !== undefined && (e as GraphBubbleUp).is_bubble_up === true;\n}\n\nexport function isGraphInterrupt(e?: unknown): e is GraphInterrupt {\n return (\n e !== undefined &&\n [\n GraphInterrupt.unminifiable_name,\n NodeInterrupt.unminifiable_name,\n ].includes((e as Error).name)\n );\n}\n\nexport class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyInputError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyInputError\";\n }\n}\n\nexport class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyChannelError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyChannelError\";\n }\n}\n\nexport class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"InvalidUpdateError\";\n }\n\n static get unminifiable_name() {\n return \"InvalidUpdateError\";\n }\n}\n\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"MultipleSubgraphError\";\n }\n\n static get unminifiable_name() {\n return \"MultipleSubgraphError\";\n }\n}\n\nexport class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"UnreachableNodeError\";\n }\n\n static get unminifiable_name() {\n return \"UnreachableNodeError\";\n }\n}\n\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"RemoteException\";\n }\n\n static get unminifiable_name() {\n return \"RemoteException\";\n }\n}\n\n/**\n * Used for subgraph detection.\n */\nexport const getSubgraphsSeenSet = () => {\n if (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] === undefined\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] = new Set();\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")];\n};\n"],"mappings":";;AAgBA,IAAa,qBAAb,cAAwC,MAAM;CAC5C;CAEA,YAAY,SAAkB,QAAmC;EAC/D,IAAI,eAAe,WAAW;AAC9B,MAAI,QAAQ,cACV,gBAAe,GAAG,aAAa,+EAA+E,OAAO,cAAc;AAErI,QAAM,aAAa;AACnB,OAAK,gBAAgB,QAAQ;;;AAIjC,IAAa,gBAAb,cAAmC,mBAAmB;CACpD,IAAI,eAAe;AACjB,SAAO;;;AAIX,IAAa,sBAAb,cAAyC,mBAAmB;CAC1D,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;AAIX,IAAa,kBAAb,cAAqC,mBAAmB;CACtD,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SA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4C,mBAAmB;CAC7D,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;AAIX,IAAa,uBAAb,cAA0C,mBAAmB;CAC3D,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;;;;AAOX,IAAa,kBAAb,cAAqC,mBAAmB;CACtD,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;;;;AAOX,MAAa,4BAA4B;AACvC,KAEG,WAAmB,OAAO,IAAI,4BAA4B,MAAM,OAGjE,CAAC,WAAmB,OAAO,IAAI,4BAA4B,oBAAI,IAAI,KAAK;AAG1E,QAAQ,WAAmB,OAAO,IAAI,4BAA4B"}
@@ -0,0 +1,299 @@
1
+ const require_last_value = require('../channels/last_value.cjs');
2
+ const require_constants = require('../constants.cjs');
3
+ const require_utils = require('../utils.cjs');
4
+ const require_write = require('../pregel/write.cjs');
5
+ const require_read = require('../pregel/read.cjs');
6
+ const require_call = require('../pregel/call.cjs');
7
+ const require_pregel_index = require('../pregel/index.cjs');
8
+ const require_ephemeral_value = require('../channels/ephemeral_value.cjs');
9
+ let _langchain_core_singletons = require("@langchain/core/singletons");
10
+
11
+ //#region src/func/index.ts
12
+ /**
13
+ * Define a LangGraph task using the `task` function.
14
+ *
15
+ * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.
16
+ * A task can be called like a regular function with the following differences:
17
+ *
18
+ * - When a checkpointer is enabled, the function inputs and outputs must be serializable.
19
+ * - The wrapped function can only be called from within an entrypoint or StateGraph.
20
+ * - Calling the function produces a promise. This makes it easy to parallelize tasks.
21
+ *
22
+ * @typeParam ArgsT - The type of arguments the task function accepts
23
+ * @typeParam OutputT - The type of value the task function returns
24
+ * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task
25
+ * @param func - The function that executes this task
26
+ * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise
27
+ *
28
+ * @example basic example
29
+ * ```typescript
30
+ * const addOne = task("add", async (a: number) => a + 1);
31
+ *
32
+ * const workflow = entrypoint("example", async (numbers: number[]) => {
33
+ * const promises = numbers.map(n => addOne(n));
34
+ * const results = await Promise.all(promises);
35
+ * return results;
36
+ * });
37
+ *
38
+ * // Call the entrypoint
39
+ * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]
40
+ * ```
41
+ *
42
+ * @example using a retry policy
43
+ * ```typescript
44
+ * const addOne = task({
45
+ * name: "add",
46
+ * retry: { maxAttempts: 3 }
47
+ * },
48
+ * async (a: number) => a + 1
49
+ * );
50
+ *
51
+ * const workflow = entrypoint("example", async (numbers: number[]) => {
52
+ * const promises = numbers.map(n => addOne(n));
53
+ * const results = await Promise.all(promises);
54
+ * return results;
55
+ * });
56
+ * ```
57
+ * @category Functional API
58
+ */
59
+ function task(optionsOrName, func) {
60
+ const options = typeof optionsOrName === "string" ? {
61
+ name: optionsOrName,
62
+ retry: void 0,
63
+ cachePolicy: void 0
64
+ } : optionsOrName;
65
+ const { name, retry } = options;
66
+ if (require_utils.isAsyncGeneratorFunction(func) || require_utils.isGeneratorFunction(func)) throw new Error("Generators are disallowed as tasks. For streaming responses, use config.write.");
67
+ const cachePolicy = options.cachePolicy ?? ("cache" in options ? options.cache : void 0);
68
+ let cache;
69
+ if (typeof cachePolicy === "boolean") cache = cachePolicy ? {} : void 0;
70
+ else cache = cachePolicy;
71
+ return (...args) => {
72
+ return require_call.call({
73
+ func,
74
+ name,
75
+ retry,
76
+ cache
77
+ }, ...args);
78
+ };
79
+ }
80
+ /**
81
+ * Define a LangGraph workflow using the `entrypoint` function.
82
+ *
83
+ * ### Function signature
84
+ *
85
+ * The wrapped function must accept at most **two parameters**. The first parameter
86
+ * is the input to the function. The second (optional) parameter is a
87
+ * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to
88
+ * the function, you can pass them as an object.
89
+ *
90
+ * ### Helper functions
91
+ *
92
+ * #### Streaming
93
+ * To write data to the "custom" stream, use the {@link getWriter} function, or the
94
+ * {@link LangGraphRunnableConfig.writer} property.
95
+ *
96
+ * #### State management
97
+ * The {@link getPreviousState} function can be used to access the previous state
98
+ * that was returned from the last invocation of the entrypoint on the same thread id.
99
+ *
100
+ * If you wish to save state other than the return value, you can use the
101
+ * {@link entrypoint.final} function.
102
+ *
103
+ * @typeParam InputT - The type of input the entrypoint accepts
104
+ * @typeParam OutputT - The type of output the entrypoint produces
105
+ * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint
106
+ * @param func - The function that executes this entrypoint
107
+ * @returns A {@link Pregel} instance that can be run to execute the workflow
108
+ *
109
+ * @example Using entrypoint and tasks
110
+ * ```typescript
111
+ * import { task, entrypoint } from "@langchain/langgraph";
112
+ * import { MemorySaver } from "@langchain/langgraph-checkpoint";
113
+ * import { interrupt, Command } from "@langchain/langgraph";
114
+ *
115
+ * const composeEssay = task("compose", async (topic: string) => {
116
+ * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation
117
+ * return `An essay about ${topic}`;
118
+ * });
119
+ *
120
+ * const reviewWorkflow = entrypoint({
121
+ * name: "review",
122
+ * checkpointer: new MemorySaver()
123
+ * }, async (topic: string) => {
124
+ * const essay = await composeEssay(topic);
125
+ * const humanReview = await interrupt({
126
+ * question: "Please provide a review",
127
+ * essay
128
+ * });
129
+ * return {
130
+ * essay,
131
+ * review: humanReview
132
+ * };
133
+ * });
134
+ *
135
+ * // Example configuration for the workflow
136
+ * const config = {
137
+ * configurable: {
138
+ * thread_id: "some_thread"
139
+ * }
140
+ * };
141
+ *
142
+ * // Topic for the essay
143
+ * const topic = "cats";
144
+ *
145
+ * // Stream the workflow to generate the essay and await human review
146
+ * for await (const result of reviewWorkflow.stream(topic, config)) {
147
+ * console.log(result);
148
+ * }
149
+ *
150
+ * // Example human review provided after the interrupt
151
+ * const humanReview = "This essay is great.";
152
+ *
153
+ * // Resume the workflow with the provided human review
154
+ * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {
155
+ * console.log(result);
156
+ * }
157
+ * ```
158
+ *
159
+ * @example Accessing the previous return value
160
+ * ```typescript
161
+ * import { entrypoint, getPreviousState } from "@langchain/langgraph";
162
+ * import { MemorySaver } from "@langchain/langgraph-checkpoint";
163
+ *
164
+ * const accumulator = entrypoint({
165
+ * name: "accumulator",
166
+ * checkpointer: new MemorySaver()
167
+ * }, async (input: string) => {
168
+ * const previous = getPreviousState<number>();
169
+ * return previous !== undefined ? `${previous } ${input}` : input;
170
+ * });
171
+ *
172
+ * const config = {
173
+ * configurable: {
174
+ * thread_id: "some_thread"
175
+ * }
176
+ * };
177
+ * await accumulator.invoke("hello", config); // returns "hello"
178
+ * await accumulator.invoke("world", config); // returns "hello world"
179
+ * ```
180
+ *
181
+ * @example Using entrypoint.final to save a value
182
+ * ```typescript
183
+ * import { entrypoint, getPreviousState } from "@langchain/langgraph";
184
+ * import { MemorySaver } from "@langchain/langgraph-checkpoint";
185
+ *
186
+ * const myWorkflow = entrypoint({
187
+ * name: "accumulator",
188
+ * checkpointer: new MemorySaver()
189
+ * }, async (num: number) => {
190
+ * const previous = getPreviousState<number>();
191
+ *
192
+ * // This will return the previous value to the caller, saving
193
+ * // 2 * num to the checkpoint, which will be used in the next invocation
194
+ * // for the `previous` parameter.
195
+ * return entrypoint.final({
196
+ * value: previous ?? 0,
197
+ * save: 2 * num
198
+ * });
199
+ * });
200
+ *
201
+ * const config = {
202
+ * configurable: {
203
+ * thread_id: "some_thread"
204
+ * }
205
+ * };
206
+ *
207
+ * await myWorkflow.invoke(3, config); // 0 (previous was undefined)
208
+ * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)
209
+ * ```
210
+ * @category Functional API
211
+ */
212
+ const entrypoint = function entrypoint$1(optionsOrName, func) {
213
+ const { name, checkpointer, store, cache } = typeof optionsOrName === "string" ? {
214
+ name: optionsOrName,
215
+ checkpointer: void 0,
216
+ store: void 0
217
+ } : optionsOrName;
218
+ if (require_utils.isAsyncGeneratorFunction(func) || require_utils.isGeneratorFunction(func)) throw new Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");
219
+ const streamMode = "updates";
220
+ const bound = require_call.getRunnableForEntrypoint(name, func);
221
+ function isEntrypointFinal(value) {
222
+ return typeof value === "object" && value !== null && "__lg_type" in value && value.__lg_type === "__pregel_final";
223
+ }
224
+ const pluckReturnValue = new require_utils.RunnableCallable({
225
+ name: "pluckReturnValue",
226
+ func: (value) => {
227
+ return isEntrypointFinal(value) ? value.value : value;
228
+ }
229
+ });
230
+ const pluckSaveValue = new require_utils.RunnableCallable({
231
+ name: "pluckSaveValue",
232
+ func: (value) => {
233
+ return isEntrypointFinal(value) ? value.save : value;
234
+ }
235
+ });
236
+ const entrypointNode = new require_read.PregelNode({
237
+ bound,
238
+ triggers: [require_constants.START],
239
+ channels: [require_constants.START],
240
+ writers: [new require_write.ChannelWrite([{
241
+ channel: require_constants.END,
242
+ value: require_write.PASSTHROUGH,
243
+ mapper: pluckReturnValue
244
+ }, {
245
+ channel: require_constants.PREVIOUS,
246
+ value: require_write.PASSTHROUGH,
247
+ mapper: pluckSaveValue
248
+ }], [require_constants.TAG_HIDDEN])]
249
+ });
250
+ return new require_pregel_index.Pregel({
251
+ name,
252
+ checkpointer,
253
+ nodes: { [name]: entrypointNode },
254
+ channels: {
255
+ [require_constants.START]: new require_ephemeral_value.EphemeralValue(),
256
+ [require_constants.END]: new require_last_value.LastValue(),
257
+ [require_constants.PREVIOUS]: new require_last_value.LastValue()
258
+ },
259
+ inputChannels: require_constants.START,
260
+ outputChannels: require_constants.END,
261
+ streamChannels: require_constants.END,
262
+ streamMode,
263
+ store,
264
+ cache
265
+ });
266
+ };
267
+ entrypoint.final = function final({ value, save }) {
268
+ return {
269
+ value,
270
+ save,
271
+ __lg_type: "__pregel_final"
272
+ };
273
+ };
274
+ /**
275
+ * A helper utility function for use with the functional API that returns the previous
276
+ * state from the checkpoint from the last invocation of the current thread.
277
+ *
278
+ * This function allows workflows to access state that was saved in previous runs
279
+ * using {@link entrypoint.final}.
280
+ *
281
+ * @typeParam StateT - The type of the state that was previously saved
282
+ * @returns The previous saved state from the last invocation of the current thread
283
+ *
284
+ * @example
285
+ * ```typescript
286
+ * const previousState = getPreviousState<{ counter: number }>();
287
+ * const newCount = (previousState?.counter ?? 0) + 1;
288
+ * ```
289
+ * @category Functional API
290
+ */
291
+ function getPreviousState() {
292
+ return _langchain_core_singletons.AsyncLocalStorageProviderSingleton.getRunnableConfig().configurable?.[require_constants.CONFIG_KEY_PREVIOUS_STATE];
293
+ }
294
+
295
+ //#endregion
296
+ exports.entrypoint = entrypoint;
297
+ exports.getPreviousState = getPreviousState;
298
+ exports.task = task;
299
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["isAsyncGeneratorFunction","isGeneratorFunction","call","entrypoint","getRunnableForEntrypoint","RunnableCallable","PregelNode","START","ChannelWrite","END","PASSTHROUGH","PREVIOUS","TAG_HIDDEN","Pregel","EphemeralValue","LastValue","AsyncLocalStorageProviderSingleton","CONFIG_KEY_PREVIOUS_STATE"],"sources":["../../src/func/index.ts"],"sourcesContent":["import {\n BaseCache,\n BaseCheckpointSaver,\n BaseStore,\n} from \"@langchain/langgraph-checkpoint\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { Pregel } from \"../pregel/index.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport {\n CONFIG_KEY_PREVIOUS_STATE,\n END,\n PREVIOUS,\n START,\n TAG_HIDDEN,\n} from \"../constants.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport { call, getRunnableForEntrypoint } from \"../pregel/call.js\";\nimport type { CachePolicy, RetryPolicy } from \"../pregel/utils/index.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nimport {\n EntrypointFinal,\n EntrypointReturnT,\n EntrypointFinalSaveT,\n EntrypointFunc,\n TaskFunc,\n} from \"./types.js\";\nimport { LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\nimport {\n RunnableCallable,\n isAsyncGeneratorFunction,\n isGeneratorFunction,\n} from \"../utils.js\";\nimport { ChannelWrite, PASSTHROUGH } from \"../pregel/write.js\";\n\n/**\n * Options for the {@link task} function\n */\nexport interface TaskOptions {\n /**\n * The name of the task, analogous to the node name in {@link StateGraph}.\n */\n name: string;\n /**\n * The retry policy for the task. Configures how many times and under what conditions\n * the task should be retried if it fails.\n */\n retry?: RetryPolicy;\n\n /**\n * The cache policy for the task. Configures how the task should be cached.\n */\n cachePolicy?: CachePolicy;\n}\n\n/**\n * Define a LangGraph task using the `task` function.\n *\n * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.\n * A task can be called like a regular function with the following differences:\n *\n * - When a checkpointer is enabled, the function inputs and outputs must be serializable.\n * - The wrapped function can only be called from within an entrypoint or StateGraph.\n * - Calling the function produces a promise. This makes it easy to parallelize tasks.\n *\n * @typeParam ArgsT - The type of arguments the task function accepts\n * @typeParam OutputT - The type of value the task function returns\n * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task\n * @param func - The function that executes this task\n * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise\n *\n * @example basic example\n * ```typescript\n * const addOne = task(\"add\", async (a: number) => a + 1);\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n *\n * // Call the entrypoint\n * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]\n * ```\n *\n * @example using a retry policy\n * ```typescript\n * const addOne = task({\n * name: \"add\",\n * retry: { maxAttempts: 3 }\n * },\n * async (a: number) => a + 1\n * );\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n * ```\n * @category Functional API\n */\nexport function task<ArgsT extends unknown[], OutputT>(\n optionsOrName: TaskOptions | string,\n func: TaskFunc<ArgsT, OutputT>\n): (...args: ArgsT) => Promise<OutputT> {\n const options =\n typeof optionsOrName === \"string\"\n ? { name: optionsOrName, retry: undefined, cachePolicy: undefined }\n : optionsOrName;\n\n const { name, retry } = options;\n if (isAsyncGeneratorFunction(func) || isGeneratorFunction(func)) {\n throw new Error(\n \"Generators are disallowed as tasks. For streaming responses, use config.write.\"\n );\n }\n\n const cachePolicy =\n options.cachePolicy ??\n // `cache` was mistakingly used as an alias for `cachePolicy` in v0.3.x,\n // TODO: remove in 1.x\n (\"cache\" in options ? (options.cache as CachePolicy) : undefined);\n\n let cache: CachePolicy | undefined;\n if (typeof cachePolicy === \"boolean\") {\n cache = cachePolicy ? {} : undefined;\n } else {\n cache = cachePolicy;\n }\n\n return (...args: ArgsT) => {\n return call({ func, name, retry, cache }, ...args);\n };\n}\n\n/**\n * Options for the {@link entrypoint} function\n */\nexport type EntrypointOptions = {\n /**\n * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.\n * This name is used for logging, debugging, and checkpoint identification.\n */\n name: string;\n /**\n * The checkpointer for the {@link entrypoint}. Used to save and restore state between\n * invocations of the workflow.\n */\n checkpointer?: BaseCheckpointSaver;\n /**\n * The store for the {@link entrypoint}. Used to persist data across workflow runs.\n */\n store?: BaseStore;\n\n /**\n * The cache for the {@link entrypoint}. Used to cache values between workflow runs.\n */\n cache?: BaseCache;\n};\n\n/**\n * Type declaration for the entrypoint function with its properties\n * @category Functional API\n */\nexport interface EntrypointFunction {\n <InputT, OutputT>(\n optionsOrName: EntrypointOptions | string,\n func: EntrypointFunc<InputT, OutputT>\n ): Pregel<\n Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>,\n {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n },\n Record<string, unknown>,\n InputT,\n EntrypointReturnT<OutputT>,\n // Because the update type is an return type union of tasks + entrypoint,\n // thus we can't type it properly.\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Awaited<EntrypointReturnT<OutputT>>\n >;\n\n /**\n * A helper utility for use with the functional API that returns a value to the caller,\n * as well as a separate state value to persist to the checkpoint. This allows workflows\n * to maintain state between runs while returning different values to the caller.\n *\n * @typeParam ValueT - The type of the value to return to the caller\n * @typeParam SaveT - The type of the state to save to the checkpoint\n * @param options.value - The value to return to the caller\n * @param options.save - The value to save to the checkpoint\n * @returns An object with the value and save properties\n *\n * @example\n * ```typescript\n * return entrypoint.final({\n * value: \"result for caller\",\n * save: { counter: currentCount + 1 }\n * });\n * ```\n */\n final<ValueT, SaveT>(options: {\n value?: ValueT;\n save?: SaveT;\n }): EntrypointFinal<ValueT, SaveT>;\n}\n\n/**\n * Define a LangGraph workflow using the `entrypoint` function.\n *\n * ### Function signature\n *\n * The wrapped function must accept at most **two parameters**. The first parameter\n * is the input to the function. The second (optional) parameter is a\n * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to\n * the function, you can pass them as an object.\n *\n * ### Helper functions\n *\n * #### Streaming\n * To write data to the \"custom\" stream, use the {@link getWriter} function, or the\n * {@link LangGraphRunnableConfig.writer} property.\n *\n * #### State management\n * The {@link getPreviousState} function can be used to access the previous state\n * that was returned from the last invocation of the entrypoint on the same thread id.\n *\n * If you wish to save state other than the return value, you can use the\n * {@link entrypoint.final} function.\n *\n * @typeParam InputT - The type of input the entrypoint accepts\n * @typeParam OutputT - The type of output the entrypoint produces\n * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint\n * @param func - The function that executes this entrypoint\n * @returns A {@link Pregel} instance that can be run to execute the workflow\n *\n * @example Using entrypoint and tasks\n * ```typescript\n * import { task, entrypoint } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n * import { interrupt, Command } from \"@langchain/langgraph\";\n *\n * const composeEssay = task(\"compose\", async (topic: string) => {\n * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation\n * return `An essay about ${topic}`;\n * });\n *\n * const reviewWorkflow = entrypoint({\n * name: \"review\",\n * checkpointer: new MemorySaver()\n * }, async (topic: string) => {\n * const essay = await composeEssay(topic);\n * const humanReview = await interrupt({\n * question: \"Please provide a review\",\n * essay\n * });\n * return {\n * essay,\n * review: humanReview\n * };\n * });\n *\n * // Example configuration for the workflow\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * // Topic for the essay\n * const topic = \"cats\";\n *\n * // Stream the workflow to generate the essay and await human review\n * for await (const result of reviewWorkflow.stream(topic, config)) {\n * console.log(result);\n * }\n *\n * // Example human review provided after the interrupt\n * const humanReview = \"This essay is great.\";\n *\n * // Resume the workflow with the provided human review\n * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {\n * console.log(result);\n * }\n * ```\n *\n * @example Accessing the previous return value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const accumulator = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (input: string) => {\n * const previous = getPreviousState<number>();\n * return previous !== undefined ? `${previous } ${input}` : input;\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n * await accumulator.invoke(\"hello\", config); // returns \"hello\"\n * await accumulator.invoke(\"world\", config); // returns \"hello world\"\n * ```\n *\n * @example Using entrypoint.final to save a value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const myWorkflow = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (num: number) => {\n * const previous = getPreviousState<number>();\n *\n * // This will return the previous value to the caller, saving\n * // 2 * num to the checkpoint, which will be used in the next invocation\n * // for the `previous` parameter.\n * return entrypoint.final({\n * value: previous ?? 0,\n * save: 2 * num\n * });\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * await myWorkflow.invoke(3, config); // 0 (previous was undefined)\n * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)\n * ```\n * @category Functional API\n */\nexport const entrypoint = function entrypoint<InputT, OutputT>(\n optionsOrName: EntrypointOptions | string,\n func: EntrypointFunc<InputT, OutputT>\n) {\n const { name, checkpointer, store, cache } =\n typeof optionsOrName === \"string\"\n ? { name: optionsOrName, checkpointer: undefined, store: undefined }\n : optionsOrName;\n if (isAsyncGeneratorFunction(func) || isGeneratorFunction(func)) {\n throw new Error(\n \"Generators are disallowed as entrypoints. For streaming responses, use config.write.\"\n );\n }\n const streamMode = \"updates\";\n const bound = getRunnableForEntrypoint(name, func);\n\n // Helper to check if a value is an EntrypointFinal\n function isEntrypointFinal(\n value: unknown\n ): value is EntrypointFinal<unknown, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"__lg_type\" in value &&\n value.__lg_type === \"__pregel_final\"\n );\n }\n\n // Helper function to pluck the return value from EntrypointFinal or passthrough\n const pluckReturnValue = new RunnableCallable({\n name: \"pluckReturnValue\",\n func: (value: unknown) => {\n return isEntrypointFinal(value) ? value.value : value;\n },\n });\n\n // Helper function to pluck the save value from EntrypointFinal or passthrough\n const pluckSaveValue = new RunnableCallable({\n name: \"pluckSaveValue\",\n func: (value: unknown) => {\n return isEntrypointFinal(value) ? value.save : value;\n },\n });\n\n const entrypointNode = new PregelNode<InputT, EntrypointReturnT<OutputT>>({\n bound,\n triggers: [START],\n channels: [START],\n writers: [\n new ChannelWrite(\n [\n { channel: END, value: PASSTHROUGH, mapper: pluckReturnValue },\n { channel: PREVIOUS, value: PASSTHROUGH, mapper: pluckSaveValue },\n ],\n [TAG_HIDDEN]\n ),\n ],\n });\n\n return new Pregel<\n Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, // node types\n {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n }, // channel types\n Record<string, unknown>, // configurable types\n InputT, // input type\n EntrypointReturnT<OutputT> // output type\n >({\n name,\n checkpointer,\n nodes: {\n [name]: entrypointNode,\n },\n channels: {\n [START]: new EphemeralValue<InputT>(),\n [END]: new LastValue<EntrypointReturnT<OutputT>>(),\n [PREVIOUS]: new LastValue<EntrypointFinalSaveT<OutputT>>(),\n },\n inputChannels: START,\n outputChannels: END,\n streamChannels: END,\n streamMode,\n store,\n cache,\n });\n} as EntrypointFunction;\n\n// documented by the EntrypointFunction interface\nentrypoint.final = function final<ValueT, SaveT>({\n value,\n save,\n}: {\n value?: ValueT;\n save?: SaveT;\n}): EntrypointFinal<ValueT, SaveT> {\n return { value, save, __lg_type: \"__pregel_final\" };\n};\n\n/**\n * A helper utility function for use with the functional API that returns the previous\n * state from the checkpoint from the last invocation of the current thread.\n *\n * This function allows workflows to access state that was saved in previous runs\n * using {@link entrypoint.final}.\n *\n * @typeParam StateT - The type of the state that was previously saved\n * @returns The previous saved state from the last invocation of the current thread\n *\n * @example\n * ```typescript\n * const previousState = getPreviousState<{ counter: number }>();\n * const newCount = (previousState?.counter ?? 0) + 1;\n * ```\n * @category Functional API\n */\nexport function getPreviousState<StateT>(): StateT {\n const config: LangGraphRunnableConfig =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n return config.configurable?.[CONFIG_KEY_PREVIOUS_STATE] as StateT;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,SAAgB,KACd,eACA,MACsC;CACtC,MAAM,UACJ,OAAO,kBAAkB,WACrB;EAAE,MAAM;EAAe,OAAO;EAAW,aAAa;EAAW,GACjE;CAEN,MAAM,EAAE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