@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,46 @@
1
+ const require_errors = require('../errors.cjs');
2
+ const require_base = require('./base.cjs');
3
+
4
+ //#region src/channels/any_value.ts
5
+ /**
6
+ * Stores the last value received, assumes that if multiple values are received, they are all equal.
7
+ *
8
+ * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values
9
+ * will be continuously overwritten.
10
+ */
11
+ var AnyValue = class AnyValue extends require_base.BaseChannel {
12
+ lc_graph_name = "AnyValue";
13
+ value = [];
14
+ constructor() {
15
+ super();
16
+ }
17
+ fromCheckpoint(checkpoint) {
18
+ const empty = new AnyValue();
19
+ if (typeof checkpoint !== "undefined") empty.value = [checkpoint];
20
+ return empty;
21
+ }
22
+ update(values) {
23
+ if (values.length === 0) {
24
+ const updated = this.value.length > 0;
25
+ this.value = [];
26
+ return updated;
27
+ }
28
+ this.value = [values[values.length - 1]];
29
+ return false;
30
+ }
31
+ get() {
32
+ if (this.value.length === 0) throw new require_errors.EmptyChannelError();
33
+ return this.value[0];
34
+ }
35
+ checkpoint() {
36
+ if (this.value.length === 0) throw new require_errors.EmptyChannelError();
37
+ return this.value[0];
38
+ }
39
+ isAvailable() {
40
+ return this.value.length !== 0;
41
+ }
42
+ };
43
+
44
+ //#endregion
45
+ exports.AnyValue = AnyValue;
46
+ //# sourceMappingURL=any_value.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any_value.cjs","names":["BaseChannel","EmptyChannelError"],"sources":["../../src/channels/any_value.ts"],"sourcesContent":["import { EmptyChannelError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, assumes that if multiple values are received, they are all equal.\n *\n * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values\n * will be continuously overwritten.\n */\nexport class AnyValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"AnyValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor() {\n super();\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new AnyValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n const updated = this.value.length > 0;\n this.value = [];\n return updated;\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return false;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,WAAb,MAAa,iBAAwBA,yBAAiC;CACpE,gBAAgB;CAGhB,QAAsB,EAAE;CAExB,cAAc;AACZ,SAAO;;CAGT,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI,UAAiB;AACnC,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ,CAAC,WAAW;AAE5B,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,GAAG;GACvB,MAAM,UAAU,KAAK,MAAM,SAAS;AACpC,QAAK,QAAQ,EAAE;AACf,UAAO;;AAIT,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS,GAAG;AACxC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAIC,kCAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,aAAoB;AAClB,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAIA,kCAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW"}
@@ -0,0 +1,23 @@
1
+ import { BaseChannel } from "./base.cjs";
2
+
3
+ //#region src/channels/any_value.d.ts
4
+
5
+ /**
6
+ * Stores the last value received, assumes that if multiple values are received, they are all equal.
7
+ *
8
+ * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values
9
+ * will be continuously overwritten.
10
+ */
11
+ declare class AnyValue<Value> extends BaseChannel<Value, Value, Value> {
12
+ lc_graph_name: string;
13
+ value: [Value] | [];
14
+ constructor();
15
+ fromCheckpoint(checkpoint?: Value): this;
16
+ update(values: Value[]): boolean;
17
+ get(): Value;
18
+ checkpoint(): Value;
19
+ isAvailable(): boolean;
20
+ }
21
+ //#endregion
22
+ export { AnyValue };
23
+ //# sourceMappingURL=any_value.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any_value.d.cts","names":["BaseChannel","AnyValue","Value"],"sources":["../../src/channels/any_value.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\n/**\n * Stores the last value received, assumes that if multiple values are received, they are all equal.\n *\n * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values\n * will be continuously overwritten.\n */\nexport declare class AnyValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name: string;\n value: [Value] | [];\n constructor();\n fromCheckpoint(checkpoint?: Value): this;\n update(values: Value[]): boolean;\n get(): Value;\n checkpoint(): Value;\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;;AAOA;;;;AAAuEE,cAAlDD,QAAkDC,CAAAA,KAAAA,CAAAA,SAA1BF,WAA0BE,CAAdA,KAAcA,EAAPA,KAAOA,EAAAA,KAAAA,CAAAA,CAAAA;eAE3DA,EAAAA,MAAAA;OAEoBA,EAAAA,CAFpBA,KAEoBA,CAAAA,GAAAA,EAAAA;aACbA,CAAAA;gBACRA,CAAAA,UAAAA,CAAAA,EAFqBA,KAErBA,CAAAA,EAAAA,IAAAA;QACOA,CAAAA,MAAAA,EAFCA,KAEDA,EAAAA,CAAAA,EAAAA,OAAAA;KAP2BF,CAAAA,CAAAA,EAMlCE,KANkCF;EAAW,UAAA,CAAA,CAAA,EAOtCE,KAPsC"}
@@ -0,0 +1,23 @@
1
+ import { BaseChannel } from "./base.js";
2
+
3
+ //#region src/channels/any_value.d.ts
4
+
5
+ /**
6
+ * Stores the last value received, assumes that if multiple values are received, they are all equal.
7
+ *
8
+ * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values
9
+ * will be continuously overwritten.
10
+ */
11
+ declare class AnyValue<Value> extends BaseChannel<Value, Value, Value> {
12
+ lc_graph_name: string;
13
+ value: [Value] | [];
14
+ constructor();
15
+ fromCheckpoint(checkpoint?: Value): this;
16
+ update(values: Value[]): boolean;
17
+ get(): Value;
18
+ checkpoint(): Value;
19
+ isAvailable(): boolean;
20
+ }
21
+ //#endregion
22
+ export { AnyValue };
23
+ //# sourceMappingURL=any_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any_value.d.ts","names":["BaseChannel","AnyValue","Value"],"sources":["../../src/channels/any_value.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\n/**\n * Stores the last value received, assumes that if multiple values are received, they are all equal.\n *\n * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values\n * will be continuously overwritten.\n */\nexport declare class AnyValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name: string;\n value: [Value] | [];\n constructor();\n fromCheckpoint(checkpoint?: Value): this;\n update(values: Value[]): boolean;\n get(): Value;\n checkpoint(): Value;\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;;AAOA;;;;AAAuEE,cAAlDD,QAAkDC,CAAAA,KAAAA,CAAAA,SAA1BF,WAA0BE,CAAdA,KAAcA,EAAPA,KAAOA,EAAAA,KAAAA,CAAAA,CAAAA;eAE3DA,EAAAA,MAAAA;OAEoBA,EAAAA,CAFpBA,KAEoBA,CAAAA,GAAAA,EAAAA;aACbA,CAAAA;gBACRA,CAAAA,UAAAA,CAAAA,EAFqBA,KAErBA,CAAAA,EAAAA,IAAAA;QACOA,CAAAA,MAAAA,EAFCA,KAEDA,EAAAA,CAAAA,EAAAA,OAAAA;KAP2BF,CAAAA,CAAAA,EAMlCE,KANkCF;EAAW,UAAA,CAAA,CAAA,EAOtCE,KAPsC"}
@@ -0,0 +1,46 @@
1
+ import { EmptyChannelError } from "../errors.js";
2
+ import { BaseChannel } from "./base.js";
3
+
4
+ //#region src/channels/any_value.ts
5
+ /**
6
+ * Stores the last value received, assumes that if multiple values are received, they are all equal.
7
+ *
8
+ * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values
9
+ * will be continuously overwritten.
10
+ */
11
+ var AnyValue = class AnyValue extends BaseChannel {
12
+ lc_graph_name = "AnyValue";
13
+ value = [];
14
+ constructor() {
15
+ super();
16
+ }
17
+ fromCheckpoint(checkpoint) {
18
+ const empty = new AnyValue();
19
+ if (typeof checkpoint !== "undefined") empty.value = [checkpoint];
20
+ return empty;
21
+ }
22
+ update(values) {
23
+ if (values.length === 0) {
24
+ const updated = this.value.length > 0;
25
+ this.value = [];
26
+ return updated;
27
+ }
28
+ this.value = [values[values.length - 1]];
29
+ return false;
30
+ }
31
+ get() {
32
+ if (this.value.length === 0) throw new EmptyChannelError();
33
+ return this.value[0];
34
+ }
35
+ checkpoint() {
36
+ if (this.value.length === 0) throw new EmptyChannelError();
37
+ return this.value[0];
38
+ }
39
+ isAvailable() {
40
+ return this.value.length !== 0;
41
+ }
42
+ };
43
+
44
+ //#endregion
45
+ export { AnyValue };
46
+ //# sourceMappingURL=any_value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any_value.js","names":[],"sources":["../../src/channels/any_value.ts"],"sourcesContent":["import { EmptyChannelError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, assumes that if multiple values are received, they are all equal.\n *\n * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values\n * will be continuously overwritten.\n */\nexport class AnyValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"AnyValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor() {\n super();\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new AnyValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n const updated = this.value.length > 0;\n this.value = [];\n return updated;\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return false;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,WAAb,MAAa,iBAAwB,YAAiC;CACpE,gBAAgB;CAGhB,QAAsB,EAAE;CAExB,cAAc;AACZ,SAAO;;CAGT,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI,UAAiB;AACnC,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ,CAAC,WAAW;AAE5B,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,GAAG;GACvB,MAAM,UAAU,KAAK,MAAM,SAAS;AACpC,QAAK,QAAQ,EAAE;AACf,UAAO;;AAIT,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS,GAAG;AACxC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,aAAoB;AAClB,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW"}
@@ -0,0 +1,101 @@
1
+ const require_errors = require('../errors.cjs');
2
+ let _langchain_langgraph_checkpoint = require("@langchain/langgraph-checkpoint");
3
+
4
+ //#region src/channels/base.ts
5
+ function isBaseChannel(obj) {
6
+ return obj != null && obj.lg_is_channel === true;
7
+ }
8
+ /** @internal */
9
+ var BaseChannel = class {
10
+ ValueType;
11
+ UpdateType;
12
+ /** @ignore */
13
+ lg_is_channel = true;
14
+ /**
15
+ * Mark the current value of the channel as consumed. By default, no-op.
16
+ * A channel can use this method to modify its state, preventing the value
17
+ * from being consumed again.
18
+ *
19
+ * Returns True if the channel was updated, False otherwise.
20
+ */
21
+ consume() {
22
+ return false;
23
+ }
24
+ /**
25
+ * Notify the channel that the Pregel run is finishing. By default, no-op.
26
+ * A channel can use this method to modify its state, preventing finish.
27
+ *
28
+ * Returns True if the channel was updated, False otherwise.
29
+ */
30
+ finish() {
31
+ return false;
32
+ }
33
+ /**
34
+ * Return True if the channel is available (not empty), False otherwise.
35
+ * Subclasses should override this method to provide a more efficient
36
+ * implementation than calling get() and catching EmptyChannelError.
37
+ */
38
+ isAvailable() {
39
+ try {
40
+ this.get();
41
+ return true;
42
+ } catch (error) {
43
+ if (error.name === require_errors.EmptyChannelError.unminifiable_name) return false;
44
+ throw error;
45
+ }
46
+ }
47
+ };
48
+ const IS_ONLY_BASE_CHANNEL = Symbol.for("LG_IS_ONLY_BASE_CHANNEL");
49
+ function getOnlyChannels(channels) {
50
+ if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;
51
+ const newChannels = {};
52
+ for (const k in channels) {
53
+ if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;
54
+ const value = channels[k];
55
+ if (isBaseChannel(value)) newChannels[k] = value;
56
+ }
57
+ Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });
58
+ return newChannels;
59
+ }
60
+ function emptyChannels(channels, checkpoint) {
61
+ const filteredChannels = getOnlyChannels(channels);
62
+ const newChannels = {};
63
+ for (const k in filteredChannels) {
64
+ if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;
65
+ const channelValue = checkpoint.channel_values[k];
66
+ newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);
67
+ }
68
+ Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });
69
+ return newChannels;
70
+ }
71
+ function createCheckpoint(checkpoint, channels, step, options) {
72
+ let values;
73
+ if (channels === void 0) values = checkpoint.channel_values;
74
+ else {
75
+ values = {};
76
+ for (const k in channels) {
77
+ if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;
78
+ try {
79
+ values[k] = channels[k].checkpoint();
80
+ } catch (error) {
81
+ if (error.name === require_errors.EmptyChannelError.unminifiable_name) {} else throw error;
82
+ }
83
+ }
84
+ }
85
+ return {
86
+ v: 4,
87
+ id: options?.id ?? (0, _langchain_langgraph_checkpoint.uuid6)(step),
88
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
89
+ channel_values: values,
90
+ channel_versions: checkpoint.channel_versions,
91
+ versions_seen: checkpoint.versions_seen
92
+ };
93
+ }
94
+
95
+ //#endregion
96
+ exports.BaseChannel = BaseChannel;
97
+ exports.createCheckpoint = createCheckpoint;
98
+ exports.emptyChannels = emptyChannels;
99
+ exports.getOnlyChannels = getOnlyChannels;
100
+ exports.isBaseChannel = isBaseChannel;
101
+ //# sourceMappingURL=base.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.cjs","names":["EmptyChannelError"],"sources":["../../src/channels/base.ts"],"sourcesContent":["import {\n ReadonlyCheckpoint,\n uuid6,\n Checkpoint,\n} from \"@langchain/langgraph-checkpoint\";\nimport { EmptyChannelError } from \"../errors.js\";\n\nexport function isBaseChannel(obj: unknown): obj is BaseChannel {\n return obj != null && (obj as BaseChannel).lg_is_channel === true;\n}\n\n/** @internal */\nexport abstract class BaseChannel<\n ValueType = unknown,\n UpdateType = unknown,\n CheckpointType = unknown\n> {\n ValueType: ValueType;\n\n UpdateType: UpdateType;\n\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n\n /** @ignore */\n lg_is_channel = true;\n\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean {\n return false;\n }\n\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean {\n return false;\n }\n\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean {\n try {\n this.get();\n return true;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n return false;\n }\n throw error;\n }\n }\n}\n\nconst IS_ONLY_BASE_CHANNEL = Symbol.for(\"LG_IS_ONLY_BASE_CHANNEL\");\nexport function getOnlyChannels(\n channels: Record<string, BaseChannel>\n): Record<string, BaseChannel> {\n // @ts-expect-error - we know it's a record of base channels\n if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;\n\n const newChannels = {} as Record<string, BaseChannel>;\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n const value = channels[k];\n if (isBaseChannel(value)) newChannels[k] = value;\n }\n\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function emptyChannels<Cc extends Record<string, BaseChannel>>(\n channels: Cc,\n checkpoint: ReadonlyCheckpoint\n): Cc {\n const filteredChannels = getOnlyChannels(channels) as Cc;\n\n const newChannels = {} as Cc;\n for (const k in filteredChannels) {\n if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;\n const channelValue = checkpoint.channel_values[k];\n newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);\n }\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function createCheckpoint<ValueType>(\n checkpoint: ReadonlyCheckpoint,\n channels: Record<string, BaseChannel<ValueType>> | undefined,\n step: number,\n options?: { id?: string }\n): Checkpoint {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let values: Record<string, any>;\n if (channels === undefined) {\n values = checkpoint.channel_values;\n } else {\n values = {};\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n try {\n values[k] = channels[k].checkpoint();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n // no-op\n } else {\n throw error; // Rethrow unexpected errors\n }\n }\n }\n }\n\n return {\n v: 4,\n id: options?.id ?? uuid6(step),\n ts: new Date().toISOString(),\n channel_values: values,\n channel_versions: checkpoint.channel_versions,\n versions_seen: checkpoint.versions_seen,\n };\n}\n"],"mappings":";;;;AAOA,SAAgB,cAAc,KAAkC;AAC9D,QAAO,OAAO,QAAS,IAAoB,kBAAkB;;;AAI/D,IAAsB,cAAtB,MAIE;CACA;CAEA;;CAQA,gBAAgB;;;;;;;;CAkDhB,UAAmB;AACjB,SAAO;;;;;;;;CAST,SAAkB;AAChB,SAAO;;;;;;;CAQT,cAAuB;AACrB,MAAI;AACF,QAAK,KAAK;AACV,UAAO;WAEA,OAAY;AACnB,OAAI,MAAM,SAASA,iCAAkB,kBACnC,QAAO;AAET,SAAM;;;;AAKZ,MAAM,uBAAuB,OAAO,IAAI,0BAA0B;AAClE,SAAgB,gBACd,UAC6B;AAE7B,KAAI,SAAS,0BAA0B,KAAM,QAAO;CAEpD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,UAAU;AACxB,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;EACxD,MAAM,QAAQ,SAAS;AACvB,MAAI,cAAc,MAAM,CAAE,aAAY,KAAK;;AAG7C,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,cACd,UACA,YACI;CACJ,MAAM,mBAAmB,gBAAgB,SAAS;CAElD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,kBAAkB;AAChC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,kBAAkB,EAAE,CAAE;EAChE,MAAM,eAAe,WAAW,eAAe;AAC/C,cAAY,KAAK,iBAAiB,GAAG,eAAe,aAAa;;AAEnE,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,iBACd,YACA,UACA,MACA,SACY;CAEZ,IAAI;AACJ,KAAI,aAAa,OACf,UAAS,WAAW;MACf;AACL,WAAS,EAAE;AACX,OAAK,MAAM,KAAK,UAAU;AACxB,OAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;AACxD,OAAI;AACF,WAAO,KAAK,SAAS,GAAG,YAAY;YAE7B,OAAY;AACnB,QAAI,MAAM,SAASA,iCAAkB,mBAAmB,OAGtD,OAAM;;;;AAMd,QAAO;EACL,GAAG;EACH,IAAI,SAAS,iDAAY,KAAK;EAC9B,qBAAI,IAAI,MAAM,EAAC,aAAa;EAC5B,gBAAgB;EAChB,kBAAkB,WAAW;EAC7B,eAAe,WAAW;EAC3B"}
@@ -0,0 +1,79 @@
1
+ import { Checkpoint, ReadonlyCheckpoint } from "@langchain/langgraph-checkpoint";
2
+
3
+ //#region src/channels/base.d.ts
4
+ /** @internal */
5
+ declare abstract class BaseChannel<ValueType = unknown, UpdateType = unknown, CheckpointType = unknown> {
6
+ ValueType: ValueType;
7
+ UpdateType: UpdateType;
8
+ /**
9
+ * The name of the channel.
10
+ */
11
+ abstract lc_graph_name: string;
12
+ /** @ignore */
13
+ lg_is_channel: boolean;
14
+ /**
15
+ * Return a new identical channel, optionally initialized from a checkpoint.
16
+ * Can be thought of as a "restoration" from a checkpoint which is a "snapshot" of the channel's state.
17
+ *
18
+ * @param {CheckpointType | undefined} checkpoint
19
+ * @param {CheckpointType | undefined} initialValue
20
+ * @returns {this}
21
+ */
22
+ abstract fromCheckpoint(checkpoint?: CheckpointType): this;
23
+ /**
24
+ * Update the channel's value with the given sequence of updates.
25
+ * The order of the updates in the sequence is arbitrary.
26
+ * This method is called by Pregel for all channels at the end of each step.
27
+ * If there are no updates, it is called with an empty sequence.
28
+ *
29
+ * Raises InvalidUpdateError if the sequence of updates is invalid.
30
+ * Returns True if the channel was updated, False otherwise.
31
+ *
32
+ * @throws {InvalidUpdateError} if the sequence of updates is invalid.
33
+ * @param {Array<UpdateType>} values
34
+ * @returns {void}
35
+ */
36
+ abstract update(values: UpdateType[]): boolean;
37
+ /**
38
+ * Return the current value of the channel.
39
+ *
40
+ * @throws {EmptyChannelError} if the channel is empty (never updated yet).
41
+ * @returns {ValueType}
42
+ */
43
+ abstract get(): ValueType;
44
+ /**
45
+ * Return a string representation of the channel's current state.
46
+ *
47
+ * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.
48
+ * @returns {CheckpointType | undefined}
49
+ */
50
+ abstract checkpoint(): CheckpointType | undefined;
51
+ /**
52
+ * Mark the current value of the channel as consumed. By default, no-op.
53
+ * A channel can use this method to modify its state, preventing the value
54
+ * from being consumed again.
55
+ *
56
+ * Returns True if the channel was updated, False otherwise.
57
+ */
58
+ consume(): boolean;
59
+ /**
60
+ * Notify the channel that the Pregel run is finishing. By default, no-op.
61
+ * A channel can use this method to modify its state, preventing finish.
62
+ *
63
+ * Returns True if the channel was updated, False otherwise.
64
+ */
65
+ finish(): boolean;
66
+ /**
67
+ * Return True if the channel is available (not empty), False otherwise.
68
+ * Subclasses should override this method to provide a more efficient
69
+ * implementation than calling get() and catching EmptyChannelError.
70
+ */
71
+ isAvailable(): boolean;
72
+ }
73
+ declare function emptyChannels<Cc extends Record<string, BaseChannel>>(channels: Cc, checkpoint: ReadonlyCheckpoint): Cc;
74
+ declare function createCheckpoint<ValueType>(checkpoint: ReadonlyCheckpoint, channels: Record<string, BaseChannel<ValueType>> | undefined, step: number, options?: {
75
+ id?: string;
76
+ }): Checkpoint;
77
+ //#endregion
78
+ export { BaseChannel, createCheckpoint, emptyChannels };
79
+ //# sourceMappingURL=base.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.cts","names":["ReadonlyCheckpoint","Checkpoint","isBaseChannel","BaseChannel","ValueType","UpdateType","CheckpointType","getOnlyChannels","Record","emptyChannels","Cc","createCheckpoint"],"sources":["../../src/channels/base.d.ts"],"sourcesContent":["import { ReadonlyCheckpoint, Checkpoint } from \"@langchain/langgraph-checkpoint\";\nexport declare function isBaseChannel(obj: unknown): obj is BaseChannel;\n/** @internal */\nexport declare abstract class BaseChannel<ValueType = unknown, UpdateType = unknown, CheckpointType = unknown> {\n ValueType: ValueType;\n UpdateType: UpdateType;\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n /** @ignore */\n lg_is_channel: boolean;\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean;\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean;\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean;\n}\nexport declare function getOnlyChannels(channels: Record<string, BaseChannel>): Record<string, BaseChannel>;\nexport declare function emptyChannels<Cc extends Record<string, BaseChannel>>(channels: Cc, checkpoint: ReadonlyCheckpoint): Cc;\nexport declare function createCheckpoint<ValueType>(checkpoint: ReadonlyCheckpoint, channels: Record<string, BaseChannel<ValueType>> | undefined, step: number, options?: {\n id?: string;\n}): Checkpoint;\n"],"mappings":";;;;AAG8BG,uBAAAA,WAAW,CAAA,YAAA,OAAA,EAAA,aAAA,OAAA,EAAA,iBAAA,OAAA,CAAA,CAAA;EAAA,SAAA,EAC1BC,SAD0B;YAC1BA,EACCC,UADDD;;;;WAqCKA,aAAAA,EAAAA,MAAAA;;EAOqB,aAAA,EAAA,OAAA;EAwBjBK;;;;;;;;EACAE,SAAAA,cAAgB,CAAA,UAAA,CAAA,EArDCL,cAqDD,CAAA,EAAA,IAAA;EAAA;;;;;;;;;;;;;0BAvCZD;;;;;;;kBAORD;;;;;;;yBAOOE;;;;;;;;;;;;;;;;;;;;;;;iBAwBHG,yBAAyBD,eAAeL,wBAAwBO,gBAAgBV,qBAAqBU;iBACrGC,wCAAwCX,8BAA8BQ,eAAeL,YAAYC;;IAErHH"}
@@ -0,0 +1,79 @@
1
+ import { Checkpoint, ReadonlyCheckpoint } from "@langchain/langgraph-checkpoint";
2
+
3
+ //#region src/channels/base.d.ts
4
+ /** @internal */
5
+ declare abstract class BaseChannel<ValueType = unknown, UpdateType = unknown, CheckpointType = unknown> {
6
+ ValueType: ValueType;
7
+ UpdateType: UpdateType;
8
+ /**
9
+ * The name of the channel.
10
+ */
11
+ abstract lc_graph_name: string;
12
+ /** @ignore */
13
+ lg_is_channel: boolean;
14
+ /**
15
+ * Return a new identical channel, optionally initialized from a checkpoint.
16
+ * Can be thought of as a "restoration" from a checkpoint which is a "snapshot" of the channel's state.
17
+ *
18
+ * @param {CheckpointType | undefined} checkpoint
19
+ * @param {CheckpointType | undefined} initialValue
20
+ * @returns {this}
21
+ */
22
+ abstract fromCheckpoint(checkpoint?: CheckpointType): this;
23
+ /**
24
+ * Update the channel's value with the given sequence of updates.
25
+ * The order of the updates in the sequence is arbitrary.
26
+ * This method is called by Pregel for all channels at the end of each step.
27
+ * If there are no updates, it is called with an empty sequence.
28
+ *
29
+ * Raises InvalidUpdateError if the sequence of updates is invalid.
30
+ * Returns True if the channel was updated, False otherwise.
31
+ *
32
+ * @throws {InvalidUpdateError} if the sequence of updates is invalid.
33
+ * @param {Array<UpdateType>} values
34
+ * @returns {void}
35
+ */
36
+ abstract update(values: UpdateType[]): boolean;
37
+ /**
38
+ * Return the current value of the channel.
39
+ *
40
+ * @throws {EmptyChannelError} if the channel is empty (never updated yet).
41
+ * @returns {ValueType}
42
+ */
43
+ abstract get(): ValueType;
44
+ /**
45
+ * Return a string representation of the channel's current state.
46
+ *
47
+ * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.
48
+ * @returns {CheckpointType | undefined}
49
+ */
50
+ abstract checkpoint(): CheckpointType | undefined;
51
+ /**
52
+ * Mark the current value of the channel as consumed. By default, no-op.
53
+ * A channel can use this method to modify its state, preventing the value
54
+ * from being consumed again.
55
+ *
56
+ * Returns True if the channel was updated, False otherwise.
57
+ */
58
+ consume(): boolean;
59
+ /**
60
+ * Notify the channel that the Pregel run is finishing. By default, no-op.
61
+ * A channel can use this method to modify its state, preventing finish.
62
+ *
63
+ * Returns True if the channel was updated, False otherwise.
64
+ */
65
+ finish(): boolean;
66
+ /**
67
+ * Return True if the channel is available (not empty), False otherwise.
68
+ * Subclasses should override this method to provide a more efficient
69
+ * implementation than calling get() and catching EmptyChannelError.
70
+ */
71
+ isAvailable(): boolean;
72
+ }
73
+ declare function emptyChannels<Cc extends Record<string, BaseChannel>>(channels: Cc, checkpoint: ReadonlyCheckpoint): Cc;
74
+ declare function createCheckpoint<ValueType>(checkpoint: ReadonlyCheckpoint, channels: Record<string, BaseChannel<ValueType>> | undefined, step: number, options?: {
75
+ id?: string;
76
+ }): Checkpoint;
77
+ //#endregion
78
+ export { BaseChannel, createCheckpoint, emptyChannels };
79
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","names":["ReadonlyCheckpoint","Checkpoint","isBaseChannel","BaseChannel","ValueType","UpdateType","CheckpointType","getOnlyChannels","Record","emptyChannels","Cc","createCheckpoint"],"sources":["../../src/channels/base.d.ts"],"sourcesContent":["import { ReadonlyCheckpoint, Checkpoint } from \"@langchain/langgraph-checkpoint\";\nexport declare function isBaseChannel(obj: unknown): obj is BaseChannel;\n/** @internal */\nexport declare abstract class BaseChannel<ValueType = unknown, UpdateType = unknown, CheckpointType = unknown> {\n ValueType: ValueType;\n UpdateType: UpdateType;\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n /** @ignore */\n lg_is_channel: boolean;\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean;\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean;\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean;\n}\nexport declare function getOnlyChannels(channels: Record<string, BaseChannel>): Record<string, BaseChannel>;\nexport declare function emptyChannels<Cc extends Record<string, BaseChannel>>(channels: Cc, checkpoint: ReadonlyCheckpoint): Cc;\nexport declare function createCheckpoint<ValueType>(checkpoint: ReadonlyCheckpoint, channels: Record<string, BaseChannel<ValueType>> | undefined, step: number, options?: {\n id?: string;\n}): Checkpoint;\n"],"mappings":";;;;AAG8BG,uBAAAA,WAAW,CAAA,YAAA,OAAA,EAAA,aAAA,OAAA,EAAA,iBAAA,OAAA,CAAA,CAAA;EAAA,SAAA,EAC1BC,SAD0B;YAC1BA,EACCC,UADDD;;;;WAqCKA,aAAAA,EAAAA,MAAAA;;EAOqB,aAAA,EAAA,OAAA;EAwBjBK;;;;;;;;EACAE,SAAAA,cAAgB,CAAA,UAAA,CAAA,EArDCL,cAqDD,CAAA,EAAA,IAAA;EAAA;;;;;;;;;;;;;0BAvCZD;;;;;;;kBAORD;;;;;;;yBAOOE;;;;;;;;;;;;;;;;;;;;;;;iBAwBHG,yBAAyBD,eAAeL,wBAAwBO,gBAAgBV,qBAAqBU;iBACrGC,wCAAwCX,8BAA8BQ,eAAeL,YAAYC;;IAErHH"}
@@ -0,0 +1,97 @@
1
+ import { EmptyChannelError } from "../errors.js";
2
+ import { uuid6 } from "@langchain/langgraph-checkpoint";
3
+
4
+ //#region src/channels/base.ts
5
+ function isBaseChannel(obj) {
6
+ return obj != null && obj.lg_is_channel === true;
7
+ }
8
+ /** @internal */
9
+ var BaseChannel = class {
10
+ ValueType;
11
+ UpdateType;
12
+ /** @ignore */
13
+ lg_is_channel = true;
14
+ /**
15
+ * Mark the current value of the channel as consumed. By default, no-op.
16
+ * A channel can use this method to modify its state, preventing the value
17
+ * from being consumed again.
18
+ *
19
+ * Returns True if the channel was updated, False otherwise.
20
+ */
21
+ consume() {
22
+ return false;
23
+ }
24
+ /**
25
+ * Notify the channel that the Pregel run is finishing. By default, no-op.
26
+ * A channel can use this method to modify its state, preventing finish.
27
+ *
28
+ * Returns True if the channel was updated, False otherwise.
29
+ */
30
+ finish() {
31
+ return false;
32
+ }
33
+ /**
34
+ * Return True if the channel is available (not empty), False otherwise.
35
+ * Subclasses should override this method to provide a more efficient
36
+ * implementation than calling get() and catching EmptyChannelError.
37
+ */
38
+ isAvailable() {
39
+ try {
40
+ this.get();
41
+ return true;
42
+ } catch (error) {
43
+ if (error.name === EmptyChannelError.unminifiable_name) return false;
44
+ throw error;
45
+ }
46
+ }
47
+ };
48
+ const IS_ONLY_BASE_CHANNEL = Symbol.for("LG_IS_ONLY_BASE_CHANNEL");
49
+ function getOnlyChannels(channels) {
50
+ if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;
51
+ const newChannels = {};
52
+ for (const k in channels) {
53
+ if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;
54
+ const value = channels[k];
55
+ if (isBaseChannel(value)) newChannels[k] = value;
56
+ }
57
+ Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });
58
+ return newChannels;
59
+ }
60
+ function emptyChannels(channels, checkpoint) {
61
+ const filteredChannels = getOnlyChannels(channels);
62
+ const newChannels = {};
63
+ for (const k in filteredChannels) {
64
+ if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;
65
+ const channelValue = checkpoint.channel_values[k];
66
+ newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);
67
+ }
68
+ Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });
69
+ return newChannels;
70
+ }
71
+ function createCheckpoint(checkpoint, channels, step, options) {
72
+ let values;
73
+ if (channels === void 0) values = checkpoint.channel_values;
74
+ else {
75
+ values = {};
76
+ for (const k in channels) {
77
+ if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;
78
+ try {
79
+ values[k] = channels[k].checkpoint();
80
+ } catch (error) {
81
+ if (error.name === EmptyChannelError.unminifiable_name) {} else throw error;
82
+ }
83
+ }
84
+ }
85
+ return {
86
+ v: 4,
87
+ id: options?.id ?? uuid6(step),
88
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
89
+ channel_values: values,
90
+ channel_versions: checkpoint.channel_versions,
91
+ versions_seen: checkpoint.versions_seen
92
+ };
93
+ }
94
+
95
+ //#endregion
96
+ export { BaseChannel, createCheckpoint, emptyChannels, getOnlyChannels, isBaseChannel };
97
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","names":[],"sources":["../../src/channels/base.ts"],"sourcesContent":["import {\n ReadonlyCheckpoint,\n uuid6,\n Checkpoint,\n} from \"@langchain/langgraph-checkpoint\";\nimport { EmptyChannelError } from \"../errors.js\";\n\nexport function isBaseChannel(obj: unknown): obj is BaseChannel {\n return obj != null && (obj as BaseChannel).lg_is_channel === true;\n}\n\n/** @internal */\nexport abstract class BaseChannel<\n ValueType = unknown,\n UpdateType = unknown,\n CheckpointType = unknown\n> {\n ValueType: ValueType;\n\n UpdateType: UpdateType;\n\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n\n /** @ignore */\n lg_is_channel = true;\n\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean {\n return false;\n }\n\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean {\n return false;\n }\n\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean {\n try {\n this.get();\n return true;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n return false;\n }\n throw error;\n }\n }\n}\n\nconst IS_ONLY_BASE_CHANNEL = Symbol.for(\"LG_IS_ONLY_BASE_CHANNEL\");\nexport function getOnlyChannels(\n channels: Record<string, BaseChannel>\n): Record<string, BaseChannel> {\n // @ts-expect-error - we know it's a record of base channels\n if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;\n\n const newChannels = {} as Record<string, BaseChannel>;\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n const value = channels[k];\n if (isBaseChannel(value)) newChannels[k] = value;\n }\n\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function emptyChannels<Cc extends Record<string, BaseChannel>>(\n channels: Cc,\n checkpoint: ReadonlyCheckpoint\n): Cc {\n const filteredChannels = getOnlyChannels(channels) as Cc;\n\n const newChannels = {} as Cc;\n for (const k in filteredChannels) {\n if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;\n const channelValue = checkpoint.channel_values[k];\n newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);\n }\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function createCheckpoint<ValueType>(\n checkpoint: ReadonlyCheckpoint,\n channels: Record<string, BaseChannel<ValueType>> | undefined,\n step: number,\n options?: { id?: string }\n): Checkpoint {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let values: Record<string, any>;\n if (channels === undefined) {\n values = checkpoint.channel_values;\n } else {\n values = {};\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n try {\n values[k] = channels[k].checkpoint();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n // no-op\n } else {\n throw error; // Rethrow unexpected errors\n }\n }\n }\n }\n\n return {\n v: 4,\n id: options?.id ?? uuid6(step),\n ts: new Date().toISOString(),\n channel_values: values,\n channel_versions: checkpoint.channel_versions,\n versions_seen: checkpoint.versions_seen,\n };\n}\n"],"mappings":";;;;AAOA,SAAgB,cAAc,KAAkC;AAC9D,QAAO,OAAO,QAAS,IAAoB,kBAAkB;;;AAI/D,IAAsB,cAAtB,MAIE;CACA;CAEA;;CAQA,gBAAgB;;;;;;;;CAkDhB,UAAmB;AACjB,SAAO;;;;;;;;CAST,SAAkB;AAChB,SAAO;;;;;;;CAQT,cAAuB;AACrB,MAAI;AACF,QAAK,KAAK;AACV,UAAO;WAEA,OAAY;AACnB,OAAI,MAAM,SAAS,kBAAkB,kBACnC,QAAO;AAET,SAAM;;;;AAKZ,MAAM,uBAAuB,OAAO,IAAI,0BAA0B;AAClE,SAAgB,gBACd,UAC6B;AAE7B,KAAI,SAAS,0BAA0B,KAAM,QAAO;CAEpD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,UAAU;AACxB,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;EACxD,MAAM,QAAQ,SAAS;AACvB,MAAI,cAAc,MAAM,CAAE,aAAY,KAAK;;AAG7C,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,cACd,UACA,YACI;CACJ,MAAM,mBAAmB,gBAAgB,SAAS;CAElD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,kBAAkB;AAChC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,kBAAkB,EAAE,CAAE;EAChE,MAAM,eAAe,WAAW,eAAe;AAC/C,cAAY,KAAK,iBAAiB,GAAG,eAAe,aAAa;;AAEnE,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,iBACd,YACA,UACA,MACA,SACY;CAEZ,IAAI;AACJ,KAAI,aAAa,OACf,UAAS,WAAW;MACf;AACL,WAAS,EAAE;AACX,OAAK,MAAM,KAAK,UAAU;AACxB,OAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;AACxD,OAAI;AACF,WAAO,KAAK,SAAS,GAAG,YAAY;YAE7B,OAAY;AACnB,QAAI,MAAM,SAAS,kBAAkB,mBAAmB,OAGtD,OAAM;;;;AAMd,QAAO;EACL,GAAG;EACH,IAAI,SAAS,MAAM,MAAM,KAAK;EAC9B,qBAAI,IAAI,MAAM,EAAC,aAAa;EAC5B,gBAAgB;EAChB,kBAAkB,WAAW;EAC7B,eAAe,WAAW;EAC3B"}
@@ -0,0 +1,49 @@
1
+ const require_errors = require('../errors.cjs');
2
+ const require_base = require('./base.cjs');
3
+
4
+ //#region src/channels/binop.ts
5
+ /**
6
+ * Stores the result of applying a binary operator to the current value and each new value.
7
+ */
8
+ var BinaryOperatorAggregate = class BinaryOperatorAggregate extends require_base.BaseChannel {
9
+ lc_graph_name = "BinaryOperatorAggregate";
10
+ value;
11
+ operator;
12
+ initialValueFactory;
13
+ constructor(operator, initialValueFactory) {
14
+ super();
15
+ this.operator = operator;
16
+ this.initialValueFactory = initialValueFactory;
17
+ this.value = initialValueFactory?.();
18
+ }
19
+ fromCheckpoint(checkpoint) {
20
+ const empty = new BinaryOperatorAggregate(this.operator, this.initialValueFactory);
21
+ if (typeof checkpoint !== "undefined") empty.value = checkpoint;
22
+ return empty;
23
+ }
24
+ update(values) {
25
+ let newValues = values;
26
+ if (!newValues.length) return false;
27
+ if (this.value === void 0) {
28
+ [this.value] = newValues;
29
+ newValues = newValues.slice(1);
30
+ }
31
+ for (const value of newValues) if (this.value !== void 0) this.value = this.operator(this.value, value);
32
+ return true;
33
+ }
34
+ get() {
35
+ if (this.value === void 0) throw new require_errors.EmptyChannelError();
36
+ return this.value;
37
+ }
38
+ checkpoint() {
39
+ if (this.value === void 0) throw new require_errors.EmptyChannelError();
40
+ return this.value;
41
+ }
42
+ isAvailable() {
43
+ return this.value !== void 0;
44
+ }
45
+ };
46
+
47
+ //#endregion
48
+ exports.BinaryOperatorAggregate = BinaryOperatorAggregate;
49
+ //# sourceMappingURL=binop.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binop.cjs","names":["BaseChannel","EmptyChannelError"],"sources":["../../src/channels/binop.ts"],"sourcesContent":["import { EmptyChannelError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\nexport type BinaryOperator<ValueType, UpdateType> = (\n a: ValueType,\n b: UpdateType\n) => ValueType;\n\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport class BinaryOperatorAggregate<\n ValueType,\n UpdateType = ValueType\n> extends BaseChannel<ValueType, UpdateType, ValueType> {\n lc_graph_name = \"BinaryOperatorAggregate\";\n\n value: ValueType | undefined;\n\n operator: BinaryOperator<ValueType, UpdateType>;\n\n initialValueFactory?: () => ValueType;\n\n constructor(\n operator: BinaryOperator<ValueType, UpdateType>,\n initialValueFactory?: () => ValueType\n ) {\n super();\n\n this.operator = operator;\n this.initialValueFactory = initialValueFactory;\n this.value = initialValueFactory?.();\n }\n\n public fromCheckpoint(checkpoint?: ValueType) {\n const empty = new BinaryOperatorAggregate(\n this.operator,\n this.initialValueFactory\n );\n if (typeof checkpoint !== \"undefined\") {\n empty.value = checkpoint;\n }\n return empty as this;\n }\n\n public update(values: UpdateType[]): boolean {\n let newValues = values;\n if (!newValues.length) return false;\n\n if (this.value === undefined) {\n [this.value as UpdateType] = newValues;\n newValues = newValues.slice(1);\n }\n\n for (const value of newValues) {\n if (this.value !== undefined) {\n this.value = this.operator(this.value, value);\n }\n }\n return true;\n }\n\n public get(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n public checkpoint(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n isAvailable(): boolean {\n return this.value !== undefined;\n }\n}\n"],"mappings":";;;;;;;AAWA,IAAa,0BAAb,MAAa,gCAGHA,yBAA8C;CACtD,gBAAgB;CAEhB;CAEA;CAEA;CAEA,YACE,UACA,qBACA;AACA,SAAO;AAEP,OAAK,WAAW;AAChB,OAAK,sBAAsB;AAC3B,OAAK,QAAQ,uBAAuB;;CAGtC,AAAO,eAAe,YAAwB;EAC5C,MAAM,QAAQ,IAAI,wBAChB,KAAK,UACL,KAAK,oBACN;AACD,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ;AAEhB,SAAO;;CAGT,AAAO,OAAO,QAA+B;EAC3C,IAAI,YAAY;AAChB,MAAI,CAAC,UAAU,OAAQ,QAAO;AAE9B,MAAI,KAAK,UAAU,QAAW;AAC5B,IAAC,KAAK,SAAuB;AAC7B,eAAY,UAAU,MAAM,EAAE;;AAGhC,OAAK,MAAM,SAAS,UAClB,KAAI,KAAK,UAAU,OACjB,MAAK,QAAQ,KAAK,SAAS,KAAK,OAAO,MAAM;AAGjD,SAAO;;CAGT,AAAO,MAAiB;AACtB,MAAI,KAAK,UAAU,OACjB,OAAM,IAAIC,kCAAmB;AAE/B,SAAO,KAAK;;CAGd,AAAO,aAAwB;AAC7B,MAAI,KAAK,UAAU,OACjB,OAAM,IAAIA,kCAAmB;AAE/B,SAAO,KAAK;;CAGd,cAAuB;AACrB,SAAO,KAAK,UAAU"}