@langchain/langgraph 1.0.7 → 1.0.12

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 (383) hide show
  1. package/package.json +7 -7
  2. package/CHANGELOG.md +0 -286
  3. package/dist/_virtual/rolldown_runtime.cjs +0 -25
  4. package/dist/channels/any_value.cjs +0 -46
  5. package/dist/channels/any_value.cjs.map +0 -1
  6. package/dist/channels/any_value.d.cts +0 -24
  7. package/dist/channels/any_value.d.cts.map +0 -1
  8. package/dist/channels/any_value.d.ts +0 -24
  9. package/dist/channels/any_value.d.ts.map +0 -1
  10. package/dist/channels/any_value.js +0 -46
  11. package/dist/channels/any_value.js.map +0 -1
  12. package/dist/channels/base.cjs +0 -102
  13. package/dist/channels/base.cjs.map +0 -1
  14. package/dist/channels/base.d.cts +0 -79
  15. package/dist/channels/base.d.cts.map +0 -1
  16. package/dist/channels/base.d.ts +0 -79
  17. package/dist/channels/base.d.ts.map +0 -1
  18. package/dist/channels/base.js +0 -97
  19. package/dist/channels/base.js.map +0 -1
  20. package/dist/channels/binop.cjs +0 -49
  21. package/dist/channels/binop.cjs.map +0 -1
  22. package/dist/channels/binop.d.cts +0 -22
  23. package/dist/channels/binop.d.cts.map +0 -1
  24. package/dist/channels/binop.d.ts +0 -22
  25. package/dist/channels/binop.d.ts.map +0 -1
  26. package/dist/channels/binop.js +0 -49
  27. package/dist/channels/binop.js.map +0 -1
  28. package/dist/channels/dynamic_barrier_value.cjs +0 -76
  29. package/dist/channels/dynamic_barrier_value.cjs.map +0 -1
  30. package/dist/channels/dynamic_barrier_value.d.cts +0 -42
  31. package/dist/channels/dynamic_barrier_value.d.cts.map +0 -1
  32. package/dist/channels/dynamic_barrier_value.d.ts +0 -42
  33. package/dist/channels/dynamic_barrier_value.d.ts.map +0 -1
  34. package/dist/channels/dynamic_barrier_value.js +0 -76
  35. package/dist/channels/dynamic_barrier_value.js.map +0 -1
  36. package/dist/channels/ephemeral_value.cjs +0 -46
  37. package/dist/channels/ephemeral_value.cjs.map +0 -1
  38. package/dist/channels/ephemeral_value.d.cts +0 -22
  39. package/dist/channels/ephemeral_value.d.cts.map +0 -1
  40. package/dist/channels/ephemeral_value.d.ts +0 -22
  41. package/dist/channels/ephemeral_value.d.ts.map +0 -1
  42. package/dist/channels/ephemeral_value.js +0 -46
  43. package/dist/channels/ephemeral_value.js.map +0 -1
  44. package/dist/channels/index.cjs +0 -21
  45. package/dist/channels/index.d.cts +0 -9
  46. package/dist/channels/index.d.ts +0 -9
  47. package/dist/channels/index.js +0 -10
  48. package/dist/channels/last_value.cjs +0 -98
  49. package/dist/channels/last_value.cjs.map +0 -1
  50. package/dist/channels/last_value.d.cts +0 -44
  51. package/dist/channels/last_value.d.cts.map +0 -1
  52. package/dist/channels/last_value.d.ts +0 -44
  53. package/dist/channels/last_value.d.ts.map +0 -1
  54. package/dist/channels/last_value.js +0 -97
  55. package/dist/channels/last_value.js.map +0 -1
  56. package/dist/channels/named_barrier_value.cjs +0 -118
  57. package/dist/channels/named_barrier_value.cjs.map +0 -1
  58. package/dist/channels/named_barrier_value.d.cts +0 -46
  59. package/dist/channels/named_barrier_value.d.cts.map +0 -1
  60. package/dist/channels/named_barrier_value.d.ts +0 -46
  61. package/dist/channels/named_barrier_value.d.ts.map +0 -1
  62. package/dist/channels/named_barrier_value.js +0 -116
  63. package/dist/channels/named_barrier_value.js.map +0 -1
  64. package/dist/channels/topic.cjs +0 -65
  65. package/dist/channels/topic.cjs.map +0 -1
  66. package/dist/channels/topic.d.cts +0 -32
  67. package/dist/channels/topic.d.cts.map +0 -1
  68. package/dist/channels/topic.d.ts +0 -32
  69. package/dist/channels/topic.d.ts.map +0 -1
  70. package/dist/channels/topic.js +0 -65
  71. package/dist/channels/topic.js.map +0 -1
  72. package/dist/constants.cjs +0 -406
  73. package/dist/constants.cjs.map +0 -1
  74. package/dist/constants.d.cts +0 -285
  75. package/dist/constants.d.cts.map +0 -1
  76. package/dist/constants.d.ts +0 -285
  77. package/dist/constants.d.ts.map +0 -1
  78. package/dist/constants.js +0 -362
  79. package/dist/constants.js.map +0 -1
  80. package/dist/errors.cjs +0 -163
  81. package/dist/errors.cjs.map +0 -1
  82. package/dist/errors.d.cts +0 -81
  83. package/dist/errors.d.cts.map +0 -1
  84. package/dist/errors.d.ts +0 -81
  85. package/dist/errors.d.ts.map +0 -1
  86. package/dist/errors.js +0 -146
  87. package/dist/errors.js.map +0 -1
  88. package/dist/func/index.cjs +0 -301
  89. package/dist/func/index.cjs.map +0 -1
  90. package/dist/func/index.d.cts +0 -293
  91. package/dist/func/index.d.cts.map +0 -1
  92. package/dist/func/index.d.ts +0 -293
  93. package/dist/func/index.d.ts.map +0 -1
  94. package/dist/func/index.js +0 -298
  95. package/dist/func/index.js.map +0 -1
  96. package/dist/func/types.d.cts +0 -64
  97. package/dist/func/types.d.cts.map +0 -1
  98. package/dist/func/types.d.ts +0 -64
  99. package/dist/func/types.d.ts.map +0 -1
  100. package/dist/graph/annotation.cjs +0 -101
  101. package/dist/graph/annotation.cjs.map +0 -1
  102. package/dist/graph/annotation.d.cts +0 -116
  103. package/dist/graph/annotation.d.cts.map +0 -1
  104. package/dist/graph/annotation.d.ts +0 -116
  105. package/dist/graph/annotation.d.ts.map +0 -1
  106. package/dist/graph/annotation.js +0 -99
  107. package/dist/graph/annotation.js.map +0 -1
  108. package/dist/graph/graph.cjs +0 -423
  109. package/dist/graph/graph.cjs.map +0 -1
  110. package/dist/graph/graph.d.cts +0 -132
  111. package/dist/graph/graph.d.cts.map +0 -1
  112. package/dist/graph/graph.d.ts +0 -132
  113. package/dist/graph/graph.d.ts.map +0 -1
  114. package/dist/graph/graph.js +0 -420
  115. package/dist/graph/graph.js.map +0 -1
  116. package/dist/graph/index.cjs +0 -5
  117. package/dist/graph/index.js +0 -7
  118. package/dist/graph/message.cjs +0 -99
  119. package/dist/graph/message.cjs.map +0 -1
  120. package/dist/graph/message.d.cts +0 -40
  121. package/dist/graph/message.d.cts.map +0 -1
  122. package/dist/graph/message.d.ts +0 -40
  123. package/dist/graph/message.d.ts.map +0 -1
  124. package/dist/graph/message.js +0 -95
  125. package/dist/graph/message.js.map +0 -1
  126. package/dist/graph/messages_annotation.cjs +0 -110
  127. package/dist/graph/messages_annotation.cjs.map +0 -1
  128. package/dist/graph/messages_annotation.d.cts +0 -112
  129. package/dist/graph/messages_annotation.d.cts.map +0 -1
  130. package/dist/graph/messages_annotation.d.ts +0 -112
  131. package/dist/graph/messages_annotation.d.ts.map +0 -1
  132. package/dist/graph/messages_annotation.js +0 -107
  133. package/dist/graph/messages_annotation.js.map +0 -1
  134. package/dist/graph/state.cjs +0 -501
  135. package/dist/graph/state.cjs.map +0 -1
  136. package/dist/graph/state.d.cts +0 -236
  137. package/dist/graph/state.d.cts.map +0 -1
  138. package/dist/graph/state.d.ts +0 -236
  139. package/dist/graph/state.d.ts.map +0 -1
  140. package/dist/graph/state.js +0 -499
  141. package/dist/graph/state.js.map +0 -1
  142. package/dist/graph/zod/index.cjs +0 -10
  143. package/dist/graph/zod/index.d.cts +0 -3
  144. package/dist/graph/zod/index.d.ts +0 -3
  145. package/dist/graph/zod/index.js +0 -5
  146. package/dist/graph/zod/meta.cjs +0 -145
  147. package/dist/graph/zod/meta.cjs.map +0 -1
  148. package/dist/graph/zod/meta.d.cts +0 -116
  149. package/dist/graph/zod/meta.d.cts.map +0 -1
  150. package/dist/graph/zod/meta.d.ts +0 -116
  151. package/dist/graph/zod/meta.d.ts.map +0 -1
  152. package/dist/graph/zod/meta.js +0 -141
  153. package/dist/graph/zod/meta.js.map +0 -1
  154. package/dist/graph/zod/plugin.cjs +0 -41
  155. package/dist/graph/zod/plugin.cjs.map +0 -1
  156. package/dist/graph/zod/plugin.js +0 -41
  157. package/dist/graph/zod/plugin.js.map +0 -1
  158. package/dist/graph/zod/schema.cjs +0 -99
  159. package/dist/graph/zod/schema.cjs.map +0 -1
  160. package/dist/graph/zod/schema.d.cts +0 -38
  161. package/dist/graph/zod/schema.d.cts.map +0 -1
  162. package/dist/graph/zod/schema.d.ts +0 -38
  163. package/dist/graph/zod/schema.d.ts.map +0 -1
  164. package/dist/graph/zod/schema.js +0 -94
  165. package/dist/graph/zod/schema.js.map +0 -1
  166. package/dist/graph/zod/zod-registry.cjs +0 -43
  167. package/dist/graph/zod/zod-registry.cjs.map +0 -1
  168. package/dist/graph/zod/zod-registry.d.cts +0 -51
  169. package/dist/graph/zod/zod-registry.d.cts.map +0 -1
  170. package/dist/graph/zod/zod-registry.d.ts +0 -51
  171. package/dist/graph/zod/zod-registry.d.ts.map +0 -1
  172. package/dist/graph/zod/zod-registry.js +0 -41
  173. package/dist/graph/zod/zod-registry.js.map +0 -1
  174. package/dist/hash.cjs +0 -271
  175. package/dist/hash.cjs.map +0 -1
  176. package/dist/hash.js +0 -269
  177. package/dist/hash.js.map +0 -1
  178. package/dist/index.cjs +0 -112
  179. package/dist/index.cjs.map +0 -1
  180. package/dist/index.d.cts +0 -26
  181. package/dist/index.d.ts +0 -26
  182. package/dist/index.js +0 -22
  183. package/dist/index.js.map +0 -1
  184. package/dist/interrupt.cjs +0 -82
  185. package/dist/interrupt.cjs.map +0 -1
  186. package/dist/interrupt.d.cts +0 -58
  187. package/dist/interrupt.d.cts.map +0 -1
  188. package/dist/interrupt.d.ts +0 -58
  189. package/dist/interrupt.d.ts.map +0 -1
  190. package/dist/interrupt.js +0 -81
  191. package/dist/interrupt.js.map +0 -1
  192. package/dist/prebuilt/agentName.cjs +0 -153
  193. package/dist/prebuilt/agentName.cjs.map +0 -1
  194. package/dist/prebuilt/agentName.d.cts +0 -42
  195. package/dist/prebuilt/agentName.d.cts.map +0 -1
  196. package/dist/prebuilt/agentName.d.ts +0 -42
  197. package/dist/prebuilt/agentName.d.ts.map +0 -1
  198. package/dist/prebuilt/agentName.js +0 -152
  199. package/dist/prebuilt/agentName.js.map +0 -1
  200. package/dist/prebuilt/agent_executor.cjs +0 -44
  201. package/dist/prebuilt/agent_executor.cjs.map +0 -1
  202. package/dist/prebuilt/agent_executor.d.cts +0 -58
  203. package/dist/prebuilt/agent_executor.d.cts.map +0 -1
  204. package/dist/prebuilt/agent_executor.d.ts +0 -58
  205. package/dist/prebuilt/agent_executor.d.ts.map +0 -1
  206. package/dist/prebuilt/agent_executor.js +0 -44
  207. package/dist/prebuilt/agent_executor.js.map +0 -1
  208. package/dist/prebuilt/chat_agent_executor.cjs +0 -68
  209. package/dist/prebuilt/chat_agent_executor.cjs.map +0 -1
  210. package/dist/prebuilt/chat_agent_executor.d.cts +0 -23
  211. package/dist/prebuilt/chat_agent_executor.d.cts.map +0 -1
  212. package/dist/prebuilt/chat_agent_executor.d.ts +0 -23
  213. package/dist/prebuilt/chat_agent_executor.d.ts.map +0 -1
  214. package/dist/prebuilt/chat_agent_executor.js +0 -67
  215. package/dist/prebuilt/chat_agent_executor.js.map +0 -1
  216. package/dist/prebuilt/index.cjs +0 -15
  217. package/dist/prebuilt/index.d.cts +0 -8
  218. package/dist/prebuilt/index.d.ts +0 -8
  219. package/dist/prebuilt/index.js +0 -8
  220. package/dist/prebuilt/interrupt.d.cts +0 -61
  221. package/dist/prebuilt/interrupt.d.cts.map +0 -1
  222. package/dist/prebuilt/interrupt.d.ts +0 -61
  223. package/dist/prebuilt/interrupt.d.ts.map +0 -1
  224. package/dist/prebuilt/react_agent_executor.cjs +0 -344
  225. package/dist/prebuilt/react_agent_executor.cjs.map +0 -1
  226. package/dist/prebuilt/react_agent_executor.d.cts +0 -230
  227. package/dist/prebuilt/react_agent_executor.d.cts.map +0 -1
  228. package/dist/prebuilt/react_agent_executor.d.ts +0 -230
  229. package/dist/prebuilt/react_agent_executor.d.ts.map +0 -1
  230. package/dist/prebuilt/react_agent_executor.js +0 -342
  231. package/dist/prebuilt/react_agent_executor.js.map +0 -1
  232. package/dist/prebuilt/tool_executor.cjs +0 -48
  233. package/dist/prebuilt/tool_executor.cjs.map +0 -1
  234. package/dist/prebuilt/tool_executor.d.cts +0 -42
  235. package/dist/prebuilt/tool_executor.d.cts.map +0 -1
  236. package/dist/prebuilt/tool_executor.d.ts +0 -42
  237. package/dist/prebuilt/tool_executor.d.ts.map +0 -1
  238. package/dist/prebuilt/tool_executor.js +0 -47
  239. package/dist/prebuilt/tool_executor.js.map +0 -1
  240. package/dist/prebuilt/tool_node.cjs +0 -248
  241. package/dist/prebuilt/tool_node.cjs.map +0 -1
  242. package/dist/prebuilt/tool_node.d.cts +0 -182
  243. package/dist/prebuilt/tool_node.d.cts.map +0 -1
  244. package/dist/prebuilt/tool_node.d.ts +0 -182
  245. package/dist/prebuilt/tool_node.d.ts.map +0 -1
  246. package/dist/prebuilt/tool_node.js +0 -246
  247. package/dist/prebuilt/tool_node.js.map +0 -1
  248. package/dist/pregel/algo.cjs +0 -573
  249. package/dist/pregel/algo.cjs.map +0 -1
  250. package/dist/pregel/algo.d.cts +0 -13
  251. package/dist/pregel/algo.d.cts.map +0 -1
  252. package/dist/pregel/algo.d.ts +0 -13
  253. package/dist/pregel/algo.d.ts.map +0 -1
  254. package/dist/pregel/algo.js +0 -567
  255. package/dist/pregel/algo.js.map +0 -1
  256. package/dist/pregel/call.cjs +0 -53
  257. package/dist/pregel/call.cjs.map +0 -1
  258. package/dist/pregel/call.js +0 -50
  259. package/dist/pregel/call.js.map +0 -1
  260. package/dist/pregel/debug.cjs +0 -175
  261. package/dist/pregel/debug.cjs.map +0 -1
  262. package/dist/pregel/debug.js +0 -169
  263. package/dist/pregel/debug.js.map +0 -1
  264. package/dist/pregel/index.cjs +0 -1170
  265. package/dist/pregel/index.cjs.map +0 -1
  266. package/dist/pregel/index.d.cts +0 -546
  267. package/dist/pregel/index.d.cts.map +0 -1
  268. package/dist/pregel/index.d.ts +0 -546
  269. package/dist/pregel/index.d.ts.map +0 -1
  270. package/dist/pregel/index.js +0 -1168
  271. package/dist/pregel/index.js.map +0 -1
  272. package/dist/pregel/io.cjs +0 -140
  273. package/dist/pregel/io.cjs.map +0 -1
  274. package/dist/pregel/io.js +0 -135
  275. package/dist/pregel/io.js.map +0 -1
  276. package/dist/pregel/loop.cjs +0 -548
  277. package/dist/pregel/loop.cjs.map +0 -1
  278. package/dist/pregel/loop.js +0 -547
  279. package/dist/pregel/loop.js.map +0 -1
  280. package/dist/pregel/messages.cjs +0 -108
  281. package/dist/pregel/messages.cjs.map +0 -1
  282. package/dist/pregel/messages.js +0 -107
  283. package/dist/pregel/messages.js.map +0 -1
  284. package/dist/pregel/read.cjs +0 -152
  285. package/dist/pregel/read.cjs.map +0 -1
  286. package/dist/pregel/read.d.cts +0 -51
  287. package/dist/pregel/read.d.cts.map +0 -1
  288. package/dist/pregel/read.d.ts +0 -51
  289. package/dist/pregel/read.d.ts.map +0 -1
  290. package/dist/pregel/read.js +0 -150
  291. package/dist/pregel/read.js.map +0 -1
  292. package/dist/pregel/remote.cjs +0 -349
  293. package/dist/pregel/remote.cjs.map +0 -1
  294. package/dist/pregel/remote.d.cts +0 -123
  295. package/dist/pregel/remote.d.cts.map +0 -1
  296. package/dist/pregel/remote.d.ts +0 -123
  297. package/dist/pregel/remote.d.ts.map +0 -1
  298. package/dist/pregel/remote.js +0 -348
  299. package/dist/pregel/remote.js.map +0 -1
  300. package/dist/pregel/retry.cjs +0 -92
  301. package/dist/pregel/retry.cjs.map +0 -1
  302. package/dist/pregel/retry.js +0 -92
  303. package/dist/pregel/retry.js.map +0 -1
  304. package/dist/pregel/runnable_types.d.cts +0 -49
  305. package/dist/pregel/runnable_types.d.cts.map +0 -1
  306. package/dist/pregel/runnable_types.d.ts +0 -49
  307. package/dist/pregel/runnable_types.d.ts.map +0 -1
  308. package/dist/pregel/runner.cjs +0 -228
  309. package/dist/pregel/runner.cjs.map +0 -1
  310. package/dist/pregel/runner.js +0 -228
  311. package/dist/pregel/runner.js.map +0 -1
  312. package/dist/pregel/stream.cjs +0 -199
  313. package/dist/pregel/stream.cjs.map +0 -1
  314. package/dist/pregel/stream.js +0 -196
  315. package/dist/pregel/stream.js.map +0 -1
  316. package/dist/pregel/types.cjs +0 -27
  317. package/dist/pregel/types.cjs.map +0 -1
  318. package/dist/pregel/types.d.cts +0 -453
  319. package/dist/pregel/types.d.cts.map +0 -1
  320. package/dist/pregel/types.d.ts +0 -453
  321. package/dist/pregel/types.d.ts.map +0 -1
  322. package/dist/pregel/types.js +0 -25
  323. package/dist/pregel/types.js.map +0 -1
  324. package/dist/pregel/utils/config.cjs +0 -122
  325. package/dist/pregel/utils/config.cjs.map +0 -1
  326. package/dist/pregel/utils/config.d.cts +0 -36
  327. package/dist/pregel/utils/config.d.cts.map +0 -1
  328. package/dist/pregel/utils/config.d.ts +0 -36
  329. package/dist/pregel/utils/config.d.ts.map +0 -1
  330. package/dist/pregel/utils/config.js +0 -115
  331. package/dist/pregel/utils/config.js.map +0 -1
  332. package/dist/pregel/utils/index.cjs +0 -103
  333. package/dist/pregel/utils/index.cjs.map +0 -1
  334. package/dist/pregel/utils/index.d.cts +0 -51
  335. package/dist/pregel/utils/index.d.cts.map +0 -1
  336. package/dist/pregel/utils/index.d.ts +0 -51
  337. package/dist/pregel/utils/index.d.ts.map +0 -1
  338. package/dist/pregel/utils/index.js +0 -97
  339. package/dist/pregel/utils/index.js.map +0 -1
  340. package/dist/pregel/utils/subgraph.cjs +0 -19
  341. package/dist/pregel/utils/subgraph.cjs.map +0 -1
  342. package/dist/pregel/utils/subgraph.js +0 -17
  343. package/dist/pregel/utils/subgraph.js.map +0 -1
  344. package/dist/pregel/validate.cjs +0 -45
  345. package/dist/pregel/validate.cjs.map +0 -1
  346. package/dist/pregel/validate.js +0 -44
  347. package/dist/pregel/validate.js.map +0 -1
  348. package/dist/pregel/write.cjs +0 -97
  349. package/dist/pregel/write.cjs.map +0 -1
  350. package/dist/pregel/write.d.cts +0 -35
  351. package/dist/pregel/write.d.cts.map +0 -1
  352. package/dist/pregel/write.d.ts +0 -35
  353. package/dist/pregel/write.d.ts.map +0 -1
  354. package/dist/pregel/write.js +0 -95
  355. package/dist/pregel/write.js.map +0 -1
  356. package/dist/remote.cjs +0 -3
  357. package/dist/remote.d.cts +0 -2
  358. package/dist/remote.d.ts +0 -2
  359. package/dist/remote.js +0 -3
  360. package/dist/setup/async_local_storage.cjs +0 -12
  361. package/dist/setup/async_local_storage.cjs.map +0 -1
  362. package/dist/setup/async_local_storage.js +0 -11
  363. package/dist/setup/async_local_storage.js.map +0 -1
  364. package/dist/utils.cjs +0 -88
  365. package/dist/utils.cjs.map +0 -1
  366. package/dist/utils.d.cts +0 -32
  367. package/dist/utils.d.cts.map +0 -1
  368. package/dist/utils.d.ts +0 -32
  369. package/dist/utils.d.ts.map +0 -1
  370. package/dist/utils.js +0 -81
  371. package/dist/utils.js.map +0 -1
  372. package/dist/web.cjs +0 -96
  373. package/dist/web.d.cts +0 -23
  374. package/dist/web.d.ts +0 -23
  375. package/dist/web.js +0 -15
  376. package/dist/writer.cjs +0 -15
  377. package/dist/writer.cjs.map +0 -1
  378. package/dist/writer.d.cts +0 -7
  379. package/dist/writer.d.cts.map +0 -1
  380. package/dist/writer.d.ts +0 -7
  381. package/dist/writer.d.ts.map +0 -1
  382. package/dist/writer.js +0 -14
  383. package/dist/writer.js.map +0 -1
@@ -1,97 +0,0 @@
1
- import { CONFIG_KEY_CHECKPOINT_MAP, START } from "../../constants.js";
2
-
3
- //#region src/pregel/utils/index.ts
4
- function getNullChannelVersion(currentVersions) {
5
- const startVersion = typeof currentVersions[START];
6
- if (startVersion === "number") return 0;
7
- if (startVersion === "string") return "";
8
- for (const key in currentVersions) {
9
- if (!Object.prototype.hasOwnProperty.call(currentVersions, key)) continue;
10
- const versionType = typeof currentVersions[key];
11
- if (versionType === "number") return 0;
12
- if (versionType === "string") return "";
13
- break;
14
- }
15
- return void 0;
16
- }
17
- function getNewChannelVersions(previousVersions, currentVersions) {
18
- if (Object.keys(previousVersions).length > 0) {
19
- const nullVersion = getNullChannelVersion(currentVersions);
20
- return Object.fromEntries(Object.entries(currentVersions).filter(([k, v]) => v > (previousVersions[k] ?? nullVersion)));
21
- } else return currentVersions;
22
- }
23
- function _coerceToDict(value, defaultKey) {
24
- return value && !Array.isArray(value) && !(value instanceof Date) && typeof value === "object" ? value : { [defaultKey]: value };
25
- }
26
- function patchConfigurable(config, patch) {
27
- if (config === null) return { configurable: patch };
28
- else if (config?.configurable === void 0) return {
29
- ...config,
30
- configurable: patch
31
- };
32
- else return {
33
- ...config,
34
- configurable: {
35
- ...config.configurable,
36
- ...patch
37
- }
38
- };
39
- }
40
- function patchCheckpointMap(config, metadata) {
41
- const parents = metadata?.parents ?? {};
42
- if (Object.keys(parents).length > 0) return patchConfigurable(config, { [CONFIG_KEY_CHECKPOINT_MAP]: {
43
- ...parents,
44
- [config.configurable?.checkpoint_ns ?? ""]: config.configurable?.checkpoint_id
45
- } });
46
- else return config;
47
- }
48
- /**
49
- * Combine multiple abort signals into a single abort signal.
50
- * @param signals - The abort signals to combine.
51
- * @returns A combined abort signal and a dispose function to remove the abort listener if unused.
52
- */
53
- function combineAbortSignals(...x) {
54
- const signals = [...new Set(x.filter(Boolean))];
55
- if (signals.length === 0) return {
56
- signal: void 0,
57
- dispose: void 0
58
- };
59
- if (signals.length === 1) return {
60
- signal: signals[0],
61
- dispose: void 0
62
- };
63
- const combinedController = new AbortController();
64
- const listener = () => {
65
- const reason = signals.find((s) => s.aborted)?.reason;
66
- combinedController.abort(reason);
67
- signals.forEach((s) => s.removeEventListener("abort", listener));
68
- };
69
- signals.forEach((s) => s.addEventListener("abort", listener, { once: true }));
70
- const hasAlreadyAbortedSignal = signals.find((s) => s.aborted);
71
- if (hasAlreadyAbortedSignal) combinedController.abort(hasAlreadyAbortedSignal.reason);
72
- return {
73
- signal: combinedController.signal,
74
- dispose: () => {
75
- signals.forEach((s) => s.removeEventListener("abort", listener));
76
- }
77
- };
78
- }
79
- /**
80
- * Combine multiple callbacks into a single callback.
81
- * @param callback1 - The first callback to combine.
82
- * @param callback2 - The second callback to combine.
83
- * @returns A single callback that is a combination of the input callbacks.
84
- */
85
- const combineCallbacks = (callback1, callback2) => {
86
- if (!callback1 && !callback2) return void 0;
87
- if (!callback1) return callback2;
88
- if (!callback2) return callback1;
89
- if (Array.isArray(callback1) && Array.isArray(callback2)) return [...callback1, ...callback2];
90
- if (Array.isArray(callback1)) return [...callback1, callback2];
91
- if (Array.isArray(callback2)) return [callback1, ...callback2];
92
- return [callback1, callback2];
93
- };
94
-
95
- //#endregion
96
- export { _coerceToDict, combineAbortSignals, combineCallbacks, getNewChannelVersions, getNullChannelVersion, patchCheckpointMap, patchConfigurable };
97
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/pregel/utils/index.ts"],"sourcesContent":["import { Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport type {\n ChannelVersions,\n CheckpointMetadata,\n} from \"@langchain/langgraph-checkpoint\";\nimport { CONFIG_KEY_CHECKPOINT_MAP, START } from \"../../constants.js\";\n\nexport function getNullChannelVersion(currentVersions: ChannelVersions) {\n // Short circuit for commonly used channels such as __start__\n // (used by StateGraph)\n const startVersion = typeof currentVersions[START];\n if (startVersion === \"number\") return 0;\n if (startVersion === \"string\") return \"\";\n\n // Defer back to obtaining a first key from channel versions\n for (const key in currentVersions) {\n if (!Object.prototype.hasOwnProperty.call(currentVersions, key)) continue;\n const versionType = typeof currentVersions[key];\n if (versionType === \"number\") return 0;\n if (versionType === \"string\") return \"\";\n break;\n }\n\n return undefined;\n}\n\nexport function getNewChannelVersions(\n previousVersions: ChannelVersions,\n currentVersions: ChannelVersions\n): ChannelVersions {\n // Get new channel versions\n if (Object.keys(previousVersions).length > 0) {\n const nullVersion = getNullChannelVersion(currentVersions);\n return Object.fromEntries(\n Object.entries(currentVersions).filter(\n ([k, v]) => v > (previousVersions[k] ?? nullVersion)\n )\n );\n } else {\n return currentVersions;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function _coerceToDict(value: any, defaultKey: string) {\n return value &&\n !Array.isArray(value) &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n !(value instanceof Date) &&\n typeof value === \"object\"\n ? value\n : { [defaultKey]: value };\n}\n\nexport type RetryPolicy = {\n /**\n * Amount of time that must elapse before the first retry occurs in milliseconds.\n * @default 500\n */\n initialInterval?: number;\n\n /**\n * Multiplier by which the interval increases after each retry.\n * @default 2\n */\n backoffFactor?: number;\n\n /**\n * Maximum amount of time that may elapse between retries in milliseconds.\n * @default 128000\n */\n maxInterval?: number;\n\n /**\n * Maximum amount of time that may elapse between retries.\n * @default 3\n */\n maxAttempts?: number;\n\n /** Whether to add random jitter to the interval between retries. */\n jitter?: boolean;\n\n /** A function that returns True for exceptions that should trigger a retry. */\n retryOn?: (e: any) => boolean; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n /** Whether to log a warning when a retry is attempted. Defaults to true. */\n logWarning?: boolean;\n};\n\n/**\n * Configuration for caching nodes.\n */\nexport type CachePolicy = {\n /**\n * A function used to generate a cache key from node's input.\n * @returns A key for the cache.\n */\n keyFunc?: (args: unknown[]) => string;\n\n /**\n * The time to live for the cache in seconds.\n * If not defined, the entry will never expire.\n */\n ttl?: number;\n};\n\nexport function patchConfigurable(\n config: RunnableConfig | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n patch: Record<string, any>\n): RunnableConfig {\n if (config === null) {\n return { configurable: patch };\n } else if (config?.configurable === undefined) {\n return { ...config, configurable: patch };\n } else {\n return {\n ...config,\n configurable: { ...config.configurable, ...patch },\n };\n }\n}\n\nexport function patchCheckpointMap(\n config: RunnableConfig,\n metadata?: CheckpointMetadata\n): RunnableConfig {\n const parents = metadata?.parents ?? {};\n\n if (Object.keys(parents).length > 0) {\n return patchConfigurable(config, {\n [CONFIG_KEY_CHECKPOINT_MAP]: {\n ...parents,\n [config.configurable?.checkpoint_ns ?? \"\"]:\n config.configurable?.checkpoint_id,\n },\n });\n } else {\n return config;\n }\n}\n\n/**\n * Combine multiple abort signals into a single abort signal.\n * @param signals - The abort signals to combine.\n * @returns A combined abort signal and a dispose function to remove the abort listener if unused.\n */\nexport function combineAbortSignals(...x: (AbortSignal | undefined)[]): {\n signal: AbortSignal | undefined;\n dispose?: () => void;\n} {\n const signals = [...new Set(x.filter(Boolean))] as AbortSignal[];\n\n if (signals.length === 0) {\n return { signal: undefined, dispose: undefined };\n }\n\n if (signals.length === 1) {\n return { signal: signals[0], dispose: undefined };\n }\n\n const combinedController = new AbortController();\n const listener = () => {\n const reason = signals.find((s) => s.aborted)?.reason;\n combinedController.abort(reason);\n signals.forEach((s) => s.removeEventListener(\"abort\", listener));\n };\n\n signals.forEach((s) => s.addEventListener(\"abort\", listener, { once: true }));\n\n const hasAlreadyAbortedSignal = signals.find((s) => s.aborted);\n if (hasAlreadyAbortedSignal) {\n combinedController.abort(hasAlreadyAbortedSignal.reason);\n }\n\n return {\n signal: combinedController.signal,\n dispose: () => {\n signals.forEach((s) => s.removeEventListener(\"abort\", listener));\n },\n };\n}\n\n/**\n * Combine multiple callbacks into a single callback.\n * @param callback1 - The first callback to combine.\n * @param callback2 - The second callback to combine.\n * @returns A single callback that is a combination of the input callbacks.\n */\nexport const combineCallbacks = (\n callback1?: Callbacks,\n callback2?: Callbacks\n): Callbacks | undefined => {\n if (!callback1 && !callback2) {\n return undefined;\n }\n\n if (!callback1) {\n return callback2;\n }\n\n if (!callback2) {\n return callback1;\n }\n if (Array.isArray(callback1) && Array.isArray(callback2)) {\n return [...callback1, ...callback2];\n }\n if (Array.isArray(callback1)) {\n return [...callback1, callback2] as Callbacks;\n }\n if (Array.isArray(callback2)) {\n return [callback1, ...callback2];\n }\n return [callback1, callback2] as Callbacks;\n};\n"],"mappings":";;;AAQA,SAAgB,sBAAsB,iBAAkC;CAGtE,MAAM,eAAe,OAAO,gBAAgB;AAC5C,KAAI,iBAAiB,SAAU,QAAO;AACtC,KAAI,iBAAiB,SAAU,QAAO;AAGtC,MAAK,MAAM,OAAO,iBAAiB;AACjC,MAAI,CAAC,OAAO,UAAU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AAC/C,qBAAmB,MAAM;AACzB,UAAQ,SAAS,MAAM,EAAE,oBAAoB,SAAS;;AAGxD,SAAQ,SAAS,MAAM,EAAE,iBAAiB,SAAS,UAAU,EAAE,MAAM;CAErE,MAAM,0BAA0B,QAAQ,MAAM,MAAM,EAAE;AACtD,KAAI,wBACF,oBAAmB,MAAM,wBAAwB;AAGnD,QAAO;EACL,QAAQ,mBAAmB;EAC3B,eAAe;AACb,WAAQ,SAAS,MAAM,EAAE,oBAAoB,SAAS;;;;;;;;;;AAW5D,MAAa,oBACX,WACA,cAC0B;AAC1B,KAAI,CAAC,aAAa,CAAC,UACjB,QAAO;AAGT,KAAI,CAAC,UACH,QAAO;AAGT,KAAI,CAAC,UACH,QAAO;AAET,KAAI,MAAM,QAAQ,cAAc,MAAM,QAAQ,WAC5C,QAAO,CAAC,GAAG,WAAW,GAAG;AAE3B,KAAI,MAAM,QAAQ,WAChB,QAAO,CAAC,GAAG,WAAW;AAExB,KAAI,MAAM,QAAQ,WAChB,QAAO,CAAC,WAAW,GAAG;AAExB,QAAO,CAAC,WAAW"}
@@ -1,19 +0,0 @@
1
-
2
- //#region src/pregel/utils/subgraph.ts
3
- function isRunnableSequence(x) {
4
- return "steps" in x && Array.isArray(x.steps);
5
- }
6
- function isPregelLike(x) {
7
- return "lg_is_pregel" in x && x.lg_is_pregel === true;
8
- }
9
- function findSubgraphPregel(candidate) {
10
- const candidates = [candidate];
11
- for (const candidate$1 of candidates) if (isPregelLike(candidate$1)) return candidate$1;
12
- else if (isRunnableSequence(candidate$1)) candidates.push(...candidate$1.steps);
13
- return void 0;
14
- }
15
-
16
- //#endregion
17
- exports.findSubgraphPregel = findSubgraphPregel;
18
- exports.isPregelLike = isPregelLike;
19
- //# sourceMappingURL=subgraph.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subgraph.cjs","names":["candidate"],"sources":["../../../src/pregel/utils/subgraph.ts"],"sourcesContent":["import {\n RunnableSequence,\n Runnable,\n RunnableLike,\n} from \"@langchain/core/runnables\";\nimport type { PregelInterface } from \"../types.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isRunnableSequence(\n x: RunnableSequence | Runnable\n): x is RunnableSequence {\n return \"steps\" in x && Array.isArray(x.steps);\n}\n\nexport function isPregelLike(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n x: PregelInterface<any, any> | RunnableLike<any, any, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): x is PregelInterface<any, any> {\n return \"lg_is_pregel\" in x && x.lg_is_pregel === true;\n}\n\nexport function findSubgraphPregel(\n candidate: Runnable\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): PregelInterface<any, any> | undefined {\n const candidates = [candidate];\n for (const candidate of candidates) {\n if (isPregelLike(candidate)) {\n return candidate;\n } else if (isRunnableSequence(candidate)) {\n candidates.push(...candidate.steps);\n }\n }\n return undefined;\n}\n"],"mappings":";;AAQA,SAAS,mBACP,GACuB;AACvB,QAAO,WAAW,KAAK,MAAM,QAAQ,EAAE;;AAGzC,SAAgB,aAEd,GAEgC;AAChC,QAAO,kBAAkB,KAAK,EAAE,iBAAiB;;AAGnD,SAAgB,mBACd,WAEuC;CACvC,MAAM,aAAa,CAAC;AACpB,MAAK,MAAMA,eAAa,WACtB,KAAI,aAAaA,aACf,QAAOA;UACE,mBAAmBA,aAC5B,YAAW,KAAK,GAAGA,YAAU;AAGjC,QAAO"}
@@ -1,17 +0,0 @@
1
- //#region src/pregel/utils/subgraph.ts
2
- function isRunnableSequence(x) {
3
- return "steps" in x && Array.isArray(x.steps);
4
- }
5
- function isPregelLike(x) {
6
- return "lg_is_pregel" in x && x.lg_is_pregel === true;
7
- }
8
- function findSubgraphPregel(candidate) {
9
- const candidates = [candidate];
10
- for (const candidate$1 of candidates) if (isPregelLike(candidate$1)) return candidate$1;
11
- else if (isRunnableSequence(candidate$1)) candidates.push(...candidate$1.steps);
12
- return void 0;
13
- }
14
-
15
- //#endregion
16
- export { findSubgraphPregel, isPregelLike };
17
- //# sourceMappingURL=subgraph.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subgraph.js","names":["candidate"],"sources":["../../../src/pregel/utils/subgraph.ts"],"sourcesContent":["import {\n RunnableSequence,\n Runnable,\n RunnableLike,\n} from \"@langchain/core/runnables\";\nimport type { PregelInterface } from \"../types.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isRunnableSequence(\n x: RunnableSequence | Runnable\n): x is RunnableSequence {\n return \"steps\" in x && Array.isArray(x.steps);\n}\n\nexport function isPregelLike(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n x: PregelInterface<any, any> | RunnableLike<any, any, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): x is PregelInterface<any, any> {\n return \"lg_is_pregel\" in x && x.lg_is_pregel === true;\n}\n\nexport function findSubgraphPregel(\n candidate: Runnable\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): PregelInterface<any, any> | undefined {\n const candidates = [candidate];\n for (const candidate of candidates) {\n if (isPregelLike(candidate)) {\n return candidate;\n } else if (isRunnableSequence(candidate)) {\n candidates.push(...candidate.steps);\n }\n }\n return undefined;\n}\n"],"mappings":";AAQA,SAAS,mBACP,GACuB;AACvB,QAAO,WAAW,KAAK,MAAM,QAAQ,EAAE;;AAGzC,SAAgB,aAEd,GAEgC;AAChC,QAAO,kBAAkB,KAAK,EAAE,iBAAiB;;AAGnD,SAAgB,mBACd,WAEuC;CACvC,MAAM,aAAa,CAAC;AACpB,MAAK,MAAMA,eAAa,WACtB,KAAI,aAAaA,aACf,QAAOA;UACE,mBAAmBA,aAC5B,YAAW,KAAK,GAAGA,YAAU;AAGjC,QAAO"}
@@ -1,45 +0,0 @@
1
- const require_constants = require('../constants.cjs');
2
- const require_read = require('./read.cjs');
3
-
4
- //#region src/pregel/validate.ts
5
- var GraphValidationError = class extends Error {
6
- constructor(message) {
7
- super(message);
8
- this.name = "GraphValidationError";
9
- }
10
- };
11
- function validateGraph({ nodes, channels, inputChannels, outputChannels, streamChannels, interruptAfterNodes, interruptBeforeNodes }) {
12
- if (!channels) throw new GraphValidationError("Channels not provided");
13
- const subscribedChannels = /* @__PURE__ */ new Set();
14
- const allOutputChannels = /* @__PURE__ */ new Set();
15
- for (const [name, node] of Object.entries(nodes)) {
16
- if (name === require_constants.INTERRUPT) throw new GraphValidationError(`"Node name ${require_constants.INTERRUPT} is reserved"`);
17
- if (node.constructor === require_read.PregelNode) node.triggers.forEach((trigger) => subscribedChannels.add(trigger));
18
- else throw new GraphValidationError(`Invalid node type ${typeof node}, expected PregelNode`);
19
- }
20
- for (const chan of subscribedChannels) if (!(chan in channels)) throw new GraphValidationError(`Subscribed channel '${String(chan)}' not in channels`);
21
- if (!Array.isArray(inputChannels)) {
22
- if (!subscribedChannels.has(inputChannels)) throw new GraphValidationError(`Input channel ${String(inputChannels)} is not subscribed to by any node`);
23
- } else if (inputChannels.every((channel) => !subscribedChannels.has(channel))) throw new GraphValidationError(`None of the input channels ${inputChannels} are subscribed to by any node`);
24
- if (!Array.isArray(outputChannels)) allOutputChannels.add(outputChannels);
25
- else outputChannels.forEach((chan) => allOutputChannels.add(chan));
26
- if (streamChannels && !Array.isArray(streamChannels)) allOutputChannels.add(streamChannels);
27
- else if (Array.isArray(streamChannels)) streamChannels.forEach((chan) => allOutputChannels.add(chan));
28
- for (const chan of allOutputChannels) if (!(chan in channels)) throw new GraphValidationError(`Output channel '${String(chan)}' not in channels`);
29
- if (interruptAfterNodes && interruptAfterNodes !== "*") {
30
- for (const node of interruptAfterNodes) if (!(node in nodes)) throw new GraphValidationError(`Node ${String(node)} not in nodes`);
31
- }
32
- if (interruptBeforeNodes && interruptBeforeNodes !== "*") {
33
- for (const node of interruptBeforeNodes) if (!(node in nodes)) throw new GraphValidationError(`Node ${String(node)} not in nodes`);
34
- }
35
- }
36
- function validateKeys(keys, channels) {
37
- if (Array.isArray(keys)) {
38
- for (const key of keys) if (!(key in channels)) throw new Error(`Key ${String(key)} not found in channels`);
39
- } else if (!(keys in channels)) throw new Error(`Key ${String(keys)} not found in channels`);
40
- }
41
-
42
- //#endregion
43
- exports.validateGraph = validateGraph;
44
- exports.validateKeys = validateKeys;
45
- //# sourceMappingURL=validate.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate.cjs","names":["INTERRUPT","PregelNode"],"sources":["../../src/pregel/validate.ts"],"sourcesContent":["import { All } from \"@langchain/langgraph-checkpoint\";\nimport { BaseChannel } from \"../channels/index.js\";\nimport { INTERRUPT } from \"../constants.js\";\nimport { PregelNode } from \"./read.js\";\n\nexport class GraphValidationError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraphValidationError\";\n }\n}\n\nexport function validateGraph<\n Nn extends Record<string, PregelNode>,\n Cc extends Record<string, BaseChannel>\n>({\n nodes,\n channels,\n inputChannels,\n outputChannels,\n streamChannels,\n interruptAfterNodes,\n interruptBeforeNodes,\n}: {\n nodes: Nn;\n channels: Cc;\n inputChannels: keyof Cc | Array<keyof Cc>;\n outputChannels: keyof Cc | Array<keyof Cc>;\n streamChannels?: keyof Cc | Array<keyof Cc>;\n interruptAfterNodes?: Array<keyof Nn> | All;\n interruptBeforeNodes?: Array<keyof Nn> | All;\n}): void {\n if (!channels) {\n throw new GraphValidationError(\"Channels not provided\");\n }\n\n const subscribedChannels = new Set<keyof Cc>();\n const allOutputChannels = new Set<keyof Cc>();\n\n for (const [name, node] of Object.entries(nodes)) {\n if (name === INTERRUPT) {\n throw new GraphValidationError(`\"Node name ${INTERRUPT} is reserved\"`);\n }\n if (node.constructor === PregelNode) {\n node.triggers.forEach((trigger) => subscribedChannels.add(trigger));\n } else {\n throw new GraphValidationError(\n `Invalid node type ${typeof node}, expected PregelNode`\n );\n }\n }\n\n // side effect: update channels\n for (const chan of subscribedChannels) {\n if (!(chan in channels)) {\n throw new GraphValidationError(\n `Subscribed channel '${String(chan)}' not in channels`\n );\n }\n }\n\n if (!Array.isArray(inputChannels)) {\n if (!subscribedChannels.has(inputChannels)) {\n throw new GraphValidationError(\n `Input channel ${String(\n inputChannels\n )} is not subscribed to by any node`\n );\n }\n } else {\n if (inputChannels.every((channel) => !subscribedChannels.has(channel))) {\n throw new GraphValidationError(\n `None of the input channels ${inputChannels} are subscribed to by any node`\n );\n }\n }\n\n if (!Array.isArray(outputChannels)) {\n allOutputChannels.add(outputChannels);\n } else {\n outputChannels.forEach((chan) => allOutputChannels.add(chan));\n }\n\n if (streamChannels && !Array.isArray(streamChannels)) {\n allOutputChannels.add(streamChannels);\n } else if (Array.isArray(streamChannels)) {\n streamChannels.forEach((chan) => allOutputChannels.add(chan));\n }\n\n for (const chan of allOutputChannels) {\n if (!(chan in channels)) {\n throw new GraphValidationError(\n `Output channel '${String(chan)}' not in channels`\n );\n }\n }\n\n // validate interrupt before/after\n if (interruptAfterNodes && interruptAfterNodes !== \"*\") {\n for (const node of interruptAfterNodes) {\n if (!(node in nodes)) {\n throw new GraphValidationError(`Node ${String(node)} not in nodes`);\n }\n }\n }\n\n if (interruptBeforeNodes && interruptBeforeNodes !== \"*\") {\n for (const node of interruptBeforeNodes) {\n if (!(node in nodes)) {\n throw new GraphValidationError(`Node ${String(node)} not in nodes`);\n }\n }\n }\n}\n\nexport function validateKeys<Cc extends Record<string, BaseChannel>>(\n keys: keyof Cc | Array<keyof Cc>,\n channels: Cc\n): void {\n if (Array.isArray(keys)) {\n for (const key of keys) {\n if (!(key in channels)) {\n throw new Error(`Key ${String(key)} not found in channels`);\n }\n }\n } else {\n if (!(keys in channels)) {\n throw new Error(`Key ${String(keys)} not found in channels`);\n }\n }\n}\n"],"mappings":";;;;AAKA,IAAa,uBAAb,cAA0C,MAAM;CAC9C,YAAY,SAAkB;AAC5B,QAAM;AACN,OAAK,OAAO;;;AAIhB,SAAgB,cAGd,EACA,OACA,UACA,eACA,gBACA,gBACA,qBACA,wBASO;AACP,KAAI,CAAC,SACH,OAAM,IAAI,qBAAqB;CAGjC,MAAM,qCAAqB,IAAI;CAC/B,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M,IAAI,MAAM,OAAO,OAAO,KAAK;YAInC,EAAE,QAAQ,UACZ,OAAM,IAAI,MAAM,OAAO,OAAO,MAAM"}
@@ -1,44 +0,0 @@
1
- import { INTERRUPT } from "../constants.js";
2
- import { PregelNode } from "./read.js";
3
-
4
- //#region src/pregel/validate.ts
5
- var GraphValidationError = class extends Error {
6
- constructor(message) {
7
- super(message);
8
- this.name = "GraphValidationError";
9
- }
10
- };
11
- function validateGraph({ nodes, channels, inputChannels, outputChannels, streamChannels, interruptAfterNodes, interruptBeforeNodes }) {
12
- if (!channels) throw new GraphValidationError("Channels not provided");
13
- const subscribedChannels = /* @__PURE__ */ new Set();
14
- const allOutputChannels = /* @__PURE__ */ new Set();
15
- for (const [name, node] of Object.entries(nodes)) {
16
- if (name === INTERRUPT) throw new GraphValidationError(`"Node name ${INTERRUPT} is reserved"`);
17
- if (node.constructor === PregelNode) node.triggers.forEach((trigger) => subscribedChannels.add(trigger));
18
- else throw new GraphValidationError(`Invalid node type ${typeof node}, expected PregelNode`);
19
- }
20
- for (const chan of subscribedChannels) if (!(chan in channels)) throw new GraphValidationError(`Subscribed channel '${String(chan)}' not in channels`);
21
- if (!Array.isArray(inputChannels)) {
22
- if (!subscribedChannels.has(inputChannels)) throw new GraphValidationError(`Input channel ${String(inputChannels)} is not subscribed to by any node`);
23
- } else if (inputChannels.every((channel) => !subscribedChannels.has(channel))) throw new GraphValidationError(`None of the input channels ${inputChannels} are subscribed to by any node`);
24
- if (!Array.isArray(outputChannels)) allOutputChannels.add(outputChannels);
25
- else outputChannels.forEach((chan) => allOutputChannels.add(chan));
26
- if (streamChannels && !Array.isArray(streamChannels)) allOutputChannels.add(streamChannels);
27
- else if (Array.isArray(streamChannels)) streamChannels.forEach((chan) => allOutputChannels.add(chan));
28
- for (const chan of allOutputChannels) if (!(chan in channels)) throw new GraphValidationError(`Output channel '${String(chan)}' not in channels`);
29
- if (interruptAfterNodes && interruptAfterNodes !== "*") {
30
- for (const node of interruptAfterNodes) if (!(node in nodes)) throw new GraphValidationError(`Node ${String(node)} not in nodes`);
31
- }
32
- if (interruptBeforeNodes && interruptBeforeNodes !== "*") {
33
- for (const node of interruptBeforeNodes) if (!(node in nodes)) throw new GraphValidationError(`Node ${String(node)} not in nodes`);
34
- }
35
- }
36
- function validateKeys(keys, channels) {
37
- if (Array.isArray(keys)) {
38
- for (const key of keys) if (!(key in channels)) throw new Error(`Key ${String(key)} not found in channels`);
39
- } else if (!(keys in channels)) throw new Error(`Key ${String(keys)} not found in channels`);
40
- }
41
-
42
- //#endregion
43
- export { validateGraph, validateKeys };
44
- //# sourceMappingURL=validate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate.js","names":[],"sources":["../../src/pregel/validate.ts"],"sourcesContent":["import { All } from \"@langchain/langgraph-checkpoint\";\nimport { BaseChannel } from \"../channels/index.js\";\nimport { INTERRUPT } from \"../constants.js\";\nimport { PregelNode } from \"./read.js\";\n\nexport class GraphValidationError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraphValidationError\";\n }\n}\n\nexport function validateGraph<\n Nn extends Record<string, PregelNode>,\n Cc extends Record<string, BaseChannel>\n>({\n nodes,\n channels,\n inputChannels,\n outputChannels,\n streamChannels,\n interruptAfterNodes,\n interruptBeforeNodes,\n}: {\n nodes: Nn;\n channels: Cc;\n inputChannels: keyof Cc | Array<keyof Cc>;\n outputChannels: keyof Cc | Array<keyof Cc>;\n streamChannels?: keyof Cc | Array<keyof Cc>;\n interruptAfterNodes?: Array<keyof Nn> | All;\n interruptBeforeNodes?: Array<keyof Nn> | All;\n}): void {\n if (!channels) {\n throw new GraphValidationError(\"Channels not provided\");\n }\n\n const subscribedChannels = new Set<keyof Cc>();\n const allOutputChannels = new Set<keyof Cc>();\n\n for (const [name, node] of Object.entries(nodes)) {\n if (name === INTERRUPT) {\n throw new GraphValidationError(`\"Node name ${INTERRUPT} is reserved\"`);\n }\n if (node.constructor === PregelNode) {\n node.triggers.forEach((trigger) => subscribedChannels.add(trigger));\n } else {\n throw new GraphValidationError(\n `Invalid node type ${typeof node}, expected PregelNode`\n );\n }\n }\n\n // side effect: update channels\n for (const chan of subscribedChannels) {\n if (!(chan in channels)) {\n throw new GraphValidationError(\n `Subscribed channel '${String(chan)}' not in channels`\n );\n }\n }\n\n if (!Array.isArray(inputChannels)) {\n if (!subscribedChannels.has(inputChannels)) {\n throw new GraphValidationError(\n `Input channel ${String(\n inputChannels\n )} is not subscribed to by any node`\n );\n }\n } else {\n if (inputChannels.every((channel) => !subscribedChannels.has(channel))) {\n throw new GraphValidationError(\n `None of the input channels ${inputChannels} are subscribed to by any node`\n );\n }\n }\n\n if (!Array.isArray(outputChannels)) {\n allOutputChannels.add(outputChannels);\n } else {\n outputChannels.forEach((chan) => allOutputChannels.add(chan));\n }\n\n if (streamChannels && !Array.isArray(streamChannels)) {\n allOutputChannels.add(streamChannels);\n } else if (Array.isArray(streamChannels)) {\n streamChannels.forEach((chan) => allOutputChannels.add(chan));\n }\n\n for (const chan of allOutputChannels) {\n if (!(chan in channels)) {\n throw new GraphValidationError(\n `Output channel '${String(chan)}' not in channels`\n );\n }\n }\n\n // validate interrupt before/after\n if (interruptAfterNodes && interruptAfterNodes !== \"*\") {\n for (const node of interruptAfterNodes) {\n if (!(node in nodes)) {\n throw new GraphValidationError(`Node ${String(node)} not in nodes`);\n }\n }\n }\n\n if (interruptBeforeNodes && interruptBeforeNodes !== \"*\") {\n for (const node of interruptBeforeNodes) {\n if (!(node in nodes)) {\n throw new GraphValidationError(`Node ${String(node)} not in nodes`);\n }\n }\n }\n}\n\nexport function validateKeys<Cc extends Record<string, BaseChannel>>(\n keys: keyof Cc | Array<keyof Cc>,\n channels: Cc\n): void {\n if (Array.isArray(keys)) {\n for (const key of keys) {\n if (!(key in channels)) {\n throw new Error(`Key ${String(key)} not found in channels`);\n }\n }\n } else {\n if (!(keys in channels)) {\n throw new Error(`Key ${String(keys)} not found in channels`);\n }\n }\n}\n"],"mappings":";;;;AAKA,IAAa,u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nD;OAAK,MAAM,QAAQ,qBACjB,KAAI,EAAE,QAAQ,OACZ,OAAM,IAAI,qBAAqB,QAAQ,OAAO,MAAM;;;AAM5D,SAAgB,aACd,MACA,UACM;AACN,KAAI,MAAM,QAAQ,OAChB;OAAK,MAAM,OAAO,KAChB,KAAI,EAAE,OAAO,UACX,OAAM,IAAI,MAAM,OAAO,OAAO,KAAK;YAInC,EAAE,QAAQ,UACZ,OAAM,IAAI,MAAM,OAAO,OAAO,MAAM"}
@@ -1,97 +0,0 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_errors = require('../errors.cjs');
3
- const require_constants = require('../constants.cjs');
4
- const require_utils = require('../utils.cjs');
5
- const __langchain_core_runnables = require_rolldown_runtime.__toESM(require("@langchain/core/runnables"));
6
-
7
- //#region src/pregel/write.ts
8
- const SKIP_WRITE = { [Symbol.for("LG_SKIP_WRITE")]: true };
9
- function _isSkipWrite(x) {
10
- return typeof x === "object" && x?.[Symbol.for("LG_SKIP_WRITE")] !== void 0;
11
- }
12
- const PASSTHROUGH = { [Symbol.for("LG_PASSTHROUGH")]: true };
13
- function _isPassthrough(x) {
14
- return typeof x === "object" && x?.[Symbol.for("LG_PASSTHROUGH")] !== void 0;
15
- }
16
- const IS_WRITER = Symbol("IS_WRITER");
17
- /**
18
- * Mapping of write channels to Runnables that return the value to be written,
19
- * or None to skip writing.
20
- */
21
- var ChannelWrite = class ChannelWrite extends require_utils.RunnableCallable {
22
- writes;
23
- constructor(writes, tags) {
24
- const name = `ChannelWrite<${writes.map((packet) => {
25
- if (require_constants._isSend(packet)) return packet.node;
26
- else if ("channel" in packet) return packet.channel;
27
- return "...";
28
- }).join(",")}>`;
29
- super({
30
- writes,
31
- name,
32
- tags,
33
- func: async (input, config) => {
34
- return this._write(input, config ?? {});
35
- }
36
- });
37
- this.writes = writes;
38
- }
39
- async _write(input, config) {
40
- const writes = this.writes.map((write) => {
41
- if (_isChannelWriteTupleEntry(write) && _isPassthrough(write.value)) return {
42
- mapper: write.mapper,
43
- value: input
44
- };
45
- else if (_isChannelWriteEntry(write) && _isPassthrough(write.value)) return {
46
- channel: write.channel,
47
- value: input,
48
- skipNone: write.skipNone,
49
- mapper: write.mapper
50
- };
51
- else return write;
52
- });
53
- await ChannelWrite.doWrite(config, writes);
54
- return input;
55
- }
56
- static async doWrite(config, writes) {
57
- for (const w of writes) {
58
- if (_isChannelWriteEntry(w)) {
59
- if (w.channel === require_constants.TASKS) throw new require_errors.InvalidUpdateError("Cannot write to the reserved channel TASKS");
60
- if (_isPassthrough(w.value)) throw new require_errors.InvalidUpdateError("PASSTHROUGH value must be replaced");
61
- }
62
- if (_isChannelWriteTupleEntry(w)) {
63
- if (_isPassthrough(w.value)) throw new require_errors.InvalidUpdateError("PASSTHROUGH value must be replaced");
64
- }
65
- }
66
- const writeEntries = [];
67
- for (const w of writes) if (require_constants._isSend(w)) writeEntries.push([require_constants.TASKS, w]);
68
- else if (_isChannelWriteTupleEntry(w)) {
69
- const mappedResult = await w.mapper.invoke(w.value, config);
70
- if (mappedResult != null && mappedResult.length > 0) writeEntries.push(...mappedResult);
71
- } else if (_isChannelWriteEntry(w)) {
72
- const mappedValue = w.mapper !== void 0 ? await w.mapper.invoke(w.value, config) : w.value;
73
- if (_isSkipWrite(mappedValue)) continue;
74
- if (w.skipNone && mappedValue === void 0) continue;
75
- writeEntries.push([w.channel, mappedValue]);
76
- } else throw new Error(`Invalid write entry: ${JSON.stringify(w)}`);
77
- const write = config.configurable?.[require_constants.CONFIG_KEY_SEND];
78
- write(writeEntries);
79
- }
80
- static isWriter(runnable) {
81
- return runnable instanceof ChannelWrite || IS_WRITER in runnable && !!runnable[IS_WRITER];
82
- }
83
- static registerWriter(runnable) {
84
- return Object.defineProperty(runnable, IS_WRITER, { value: true });
85
- }
86
- };
87
- function _isChannelWriteEntry(x) {
88
- return x !== void 0 && typeof x.channel === "string";
89
- }
90
- function _isChannelWriteTupleEntry(x) {
91
- return x !== void 0 && !_isChannelWriteEntry(x) && __langchain_core_runnables.Runnable.isRunnable(x.mapper);
92
- }
93
-
94
- //#endregion
95
- exports.ChannelWrite = ChannelWrite;
96
- exports.PASSTHROUGH = PASSTHROUGH;
97
- //# sourceMappingURL=write.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.cjs","names":["RunnableCallable","_isSend","TASKS","InvalidUpdateError","writeEntries: [string, any][]","write: TYPE_SEND","CONFIG_KEY_SEND","Runnable"],"sources":["../../src/pregel/write.ts"],"sourcesContent":["import {\n Runnable,\n RunnableConfig,\n RunnableLike,\n} from \"@langchain/core/runnables\";\nimport { _isSend, CONFIG_KEY_SEND, Send, TASKS } from \"../constants.js\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { InvalidUpdateError } from \"../errors.js\";\n\ntype TYPE_SEND = (values: Array<[string, unknown]>) => void;\n\nexport const SKIP_WRITE = {\n [Symbol.for(\"LG_SKIP_WRITE\")]: true,\n};\n\nfunction _isSkipWrite(x: unknown) {\n return (\n typeof x === \"object\" &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x as any)?.[Symbol.for(\"LG_SKIP_WRITE\")] !== undefined\n );\n}\n\nexport const PASSTHROUGH = {\n [Symbol.for(\"LG_PASSTHROUGH\")]: true,\n};\n\nfunction _isPassthrough(x: unknown) {\n return (\n typeof x === \"object\" &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x as any)?.[Symbol.for(\"LG_PASSTHROUGH\")] !== undefined\n );\n}\n\nconst IS_WRITER = Symbol(\"IS_WRITER\");\n\n/**\n * Mapping of write channels to Runnables that return the value to be written,\n * or None to skip writing.\n */\nexport class ChannelWrite<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput = any\n> extends RunnableCallable<RunInput, RunInput> {\n writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>;\n\n constructor(\n writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>,\n tags?: string[]\n ) {\n const name = `ChannelWrite<${writes\n .map((packet) => {\n if (_isSend(packet)) {\n return packet.node;\n } else if (\"channel\" in packet) {\n return packet.channel;\n }\n return \"...\";\n })\n .join(\",\")}>`;\n super({\n ...{ writes, name, tags },\n func: async (input: RunInput, config?: RunnableConfig) => {\n return this._write(input, config ?? {});\n },\n });\n\n this.writes = writes;\n }\n\n async _write(input: unknown, config: RunnableConfig): Promise<unknown> {\n const writes = this.writes.map((write) => {\n if (_isChannelWriteTupleEntry(write) && _isPassthrough(write.value)) {\n return {\n mapper: write.mapper,\n value: input,\n };\n } else if (_isChannelWriteEntry(write) && _isPassthrough(write.value)) {\n return {\n channel: write.channel,\n value: input,\n skipNone: write.skipNone,\n mapper: write.mapper,\n };\n } else {\n return write;\n }\n });\n await ChannelWrite.doWrite(config, writes);\n return input;\n }\n\n // TODO: Support requireAtLeastOneOf\n static async doWrite(\n config: RunnableConfig,\n writes: (ChannelWriteEntry | ChannelWriteTupleEntry | Send)[]\n ): Promise<void> {\n // validate\n for (const w of writes) {\n if (_isChannelWriteEntry(w)) {\n if (w.channel === TASKS) {\n throw new InvalidUpdateError(\n \"Cannot write to the reserved channel TASKS\"\n );\n }\n if (_isPassthrough(w.value)) {\n throw new InvalidUpdateError(\"PASSTHROUGH value must be replaced\");\n }\n }\n if (_isChannelWriteTupleEntry(w)) {\n if (_isPassthrough(w.value)) {\n throw new InvalidUpdateError(\"PASSTHROUGH value must be replaced\");\n }\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const writeEntries: [string, any][] = [];\n for (const w of writes) {\n if (_isSend(w)) {\n writeEntries.push([TASKS, w]);\n } else if (_isChannelWriteTupleEntry(w)) {\n const mappedResult = await w.mapper.invoke(w.value, config);\n if (mappedResult != null && mappedResult.length > 0) {\n writeEntries.push(...mappedResult);\n }\n } else if (_isChannelWriteEntry(w)) {\n const mappedValue =\n w.mapper !== undefined\n ? await w.mapper.invoke(w.value, config)\n : w.value;\n if (_isSkipWrite(mappedValue)) {\n continue;\n }\n if (w.skipNone && mappedValue === undefined) {\n continue;\n }\n writeEntries.push([w.channel, mappedValue]);\n } else {\n throw new Error(`Invalid write entry: ${JSON.stringify(w)}`);\n }\n }\n const write: TYPE_SEND = config.configurable?.[CONFIG_KEY_SEND];\n write(writeEntries);\n }\n\n static isWriter(runnable: RunnableLike): runnable is ChannelWrite {\n return (\n // eslint-disable-next-line no-instanceof/no-instanceof\n runnable instanceof ChannelWrite ||\n (IS_WRITER in runnable && !!runnable[IS_WRITER])\n );\n }\n\n static registerWriter<T extends Runnable>(runnable: T): T {\n return Object.defineProperty(runnable, IS_WRITER, { value: true });\n }\n}\n\nexport interface ChannelWriteEntry {\n channel: string;\n value: unknown;\n skipNone?: boolean;\n mapper?: Runnable;\n}\n\nfunction _isChannelWriteEntry(x: unknown): x is ChannelWriteEntry {\n return (\n x !== undefined && typeof (x as ChannelWriteEntry).channel === \"string\"\n );\n}\n\nexport interface ChannelWriteTupleEntry {\n value: unknown;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mapper: Runnable<any, [string, any][]>;\n}\n\nfunction _isChannelWriteTupleEntry(x: unknown): x is ChannelWriteTupleEntry {\n return (\n x !== undefined &&\n !_isChannelWriteEntry(x) &&\n Runnable.isRunnable((x as ChannelWriteTupleEntry).mapper)\n );\n}\n"],"mappings":";;;;;;;AAWA,MAAa,aAAa,GACvB,OAAO,IAAI,mBAAmB;AAGjC,SAAS,aAAa,GAAY;AAChC,QACE,OAAO,MAAM,YAEZ,IAAY,OAAO,IAAI,sBAAsB;;AAIlD,MAAa,cAAc,GACxB,OAAO,IAAI,oBAAoB;AAGlC,SAAS,eAAe,GAAY;AAClC,QACE,OAAO,MAAM,YAEZ,IAAY,OAAO,IAAI,uBAAuB;;AAInD,MAAM,YAAY,OAAO;;;;;AAMzB,IAAa,eAAb,MAAa,qBAGHA,+BAAqC;CAC7C;CAEA,YACE,QACA,MACA;EACA,MAAM,OAAO,gBAAgB,OAC1B,KAAK,WAAW;AACf,OAAIC,0BAAQ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AE9B,OAAM,IAAI,MAAM,wBAAwB,KAAK,UAAU;EAG3D,MAAMG,QAAmB,OAAO,eAAeC;AAC/C,QAAM;;CAGR,OAAO,SAAS,UAAkD;AAChE,SAEE,oBAAoB,gBACnB,aAAa,YAAY,CAAC,CAAC,SAAS;;CAIzC,OAAO,eAAmC,UAAgB;AACxD,SAAO,OAAO,eAAe,UAAU,WAAW,EAAE,OAAO;;;AAW/D,SAAS,qBAAqB,GAAoC;AAChE,QACE,MAAM,UAAa,OAAQ,EAAwB,YAAY;;AAUnE,SAAS,0BAA0B,GAAyC;AAC1E,QACE,MAAM,UACN,CAAC,qBAAqB,MACtBC,oCAAS,WAAY,EAA6B"}
@@ -1,35 +0,0 @@
1
- import { RunnableCallable } from "../utils.cjs";
2
- import { Send } from "../constants.cjs";
3
- import { Runnable, RunnableConfig, RunnableLike } from "@langchain/core/runnables";
4
-
5
- //#region src/pregel/write.d.ts
6
-
7
- /**
8
- * Mapping of write channels to Runnables that return the value to be written,
9
- * or None to skip writing.
10
- */
11
- declare class ChannelWrite<
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- RunInput = any> extends RunnableCallable<RunInput, RunInput> {
14
- writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>;
15
- constructor(writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>, tags?: string[]);
16
- _write(input: unknown, config: RunnableConfig): Promise<unknown>;
17
- // TODO: Support requireAtLeastOneOf
18
- static doWrite(config: RunnableConfig, writes: (ChannelWriteEntry | ChannelWriteTupleEntry | Send)[]): Promise<void>;
19
- static isWriter(runnable: RunnableLike): runnable is ChannelWrite;
20
- static registerWriter<T extends Runnable>(runnable: T): T;
21
- }
22
- interface ChannelWriteEntry {
23
- channel: string;
24
- value: unknown;
25
- skipNone?: boolean;
26
- mapper?: Runnable;
27
- }
28
- interface ChannelWriteTupleEntry {
29
- value: unknown;
30
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
- mapper: Runnable<any, [string, any][]>;
32
- }
33
- //#endregion
34
- export { ChannelWrite };
35
- //# sourceMappingURL=write.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.d.cts","names":["Runnable","RunnableConfig","RunnableLike","Send","RunnableCallable","SKIP_WRITE","PASSTHROUGH","ChannelWrite","RunInput","ChannelWriteEntry","ChannelWriteTupleEntry","Array","Promise","T"],"sources":["../../src/pregel/write.d.ts"],"sourcesContent":["import { Runnable, RunnableConfig, RunnableLike } from \"@langchain/core/runnables\";\nimport { Send } from \"../constants.js\";\nimport { RunnableCallable } from \"../utils.js\";\nexport declare const SKIP_WRITE: {\n [x: symbol]: boolean;\n};\nexport declare const PASSTHROUGH: {\n [x: symbol]: boolean;\n};\n/**\n * Mapping of write channels to Runnables that return the value to be written,\n * or None to skip writing.\n */\nexport declare class ChannelWrite<\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nRunInput = any> extends RunnableCallable<RunInput, RunInput> {\n writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>;\n constructor(writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>, tags?: string[]);\n _write(input: unknown, config: RunnableConfig): Promise<unknown>;\n // TODO: Support requireAtLeastOneOf\n static doWrite(config: RunnableConfig, writes: (ChannelWriteEntry | ChannelWriteTupleEntry | Send)[]): Promise<void>;\n static isWriter(runnable: RunnableLike): runnable is ChannelWrite;\n static registerWriter<T extends Runnable>(runnable: T): T;\n}\nexport interface ChannelWriteEntry {\n channel: string;\n value: unknown;\n skipNone?: boolean;\n mapper?: Runnable;\n}\nexport interface ChannelWriteTupleEntry {\n value: unknown;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mapper: Runnable<any, [string, any][]>;\n}\n"],"mappings":";;;;;;;;;;AAiB8BS,cAJTF,YAISE;;WAA6CN,GAAAA,CAAAA,SAFnDC,gBAEmDD,CAFlCK,QAEkCL,EAFxBK,QAEwBL,CAAAA,CAAAA;QAAnDQ,EADZA,KACYA,CADNF,iBACME,GADcD,sBACdC,GADuCR,IACvCQ,CAAAA;aACWV,CAAAA,MAAAA,EADXU,KACWV,CADLQ,iBACKR,GADeS,sBACfT,GADwCE,IACxCF,CAAAA,EAAAA,IAAAA,CAAAA,EAAAA,MAAAA,EAAAA;QAAiBW,CAAAA,KAAAA,EAAAA,OAAAA,EAAAA,MAAAA,EAAjBX,cAAiBW,CAAAA,EAAAA,OAAAA,CAAAA,OAAAA,CAAAA;;SAEAH,OAAAA,CAAAA,MAAAA,EAAzBR,cAAyBQ,EAAAA,MAAAA,EAAAA,CAAAA,iBAAAA,GAAoBC,sBAApBD,GAA6CN,IAA7CM,CAAAA,EAAAA,CAAAA,EAAuDG,OAAvDH,CAAAA,IAAAA,CAAAA;SAAoBC,QAAAA,CAAAA,QAAAA,EAC1CR,YAD0CQ,CAAAA,EAAAA,QAAAA,IACfH,YADeG;SAAyBP,cAAAA,CAAAA,UAE7DH,QAF6DG,CAAAA,CAAAA,QAAAA,EAEzCU,CAFyCV,CAAAA,EAErCU,CAFqCV;;AACnED,UAGbO,iBAAAA,CAHaP;SAA2BK,EAAAA,MAAAA;OACrBP,EAAAA,OAAAA;UAAoBa,CAAAA,EAAAA,OAAAA;QAAIA,CAAAA,EAM/Cb,QAN+Ca;;UAQ3CH,sBAAAA;EANAD,KAAAA,EAAAA,OAAAA;EAMAC;UAGLV"}
@@ -1,35 +0,0 @@
1
- import { RunnableCallable } from "../utils.js";
2
- import { Send } from "../constants.js";
3
- import { Runnable, RunnableConfig, RunnableLike } from "@langchain/core/runnables";
4
-
5
- //#region src/pregel/write.d.ts
6
-
7
- /**
8
- * Mapping of write channels to Runnables that return the value to be written,
9
- * or None to skip writing.
10
- */
11
- declare class ChannelWrite<
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- RunInput = any> extends RunnableCallable<RunInput, RunInput> {
14
- writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>;
15
- constructor(writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>, tags?: string[]);
16
- _write(input: unknown, config: RunnableConfig): Promise<unknown>;
17
- // TODO: Support requireAtLeastOneOf
18
- static doWrite(config: RunnableConfig, writes: (ChannelWriteEntry | ChannelWriteTupleEntry | Send)[]): Promise<void>;
19
- static isWriter(runnable: RunnableLike): runnable is ChannelWrite;
20
- static registerWriter<T extends Runnable>(runnable: T): T;
21
- }
22
- interface ChannelWriteEntry {
23
- channel: string;
24
- value: unknown;
25
- skipNone?: boolean;
26
- mapper?: Runnable;
27
- }
28
- interface ChannelWriteTupleEntry {
29
- value: unknown;
30
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
- mapper: Runnable<any, [string, any][]>;
32
- }
33
- //#endregion
34
- export { ChannelWrite };
35
- //# sourceMappingURL=write.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.d.ts","names":["Runnable","RunnableConfig","RunnableLike","Send","RunnableCallable","SKIP_WRITE","PASSTHROUGH","ChannelWrite","RunInput","ChannelWriteEntry","ChannelWriteTupleEntry","Array","Promise","T"],"sources":["../../src/pregel/write.d.ts"],"sourcesContent":["import { Runnable, RunnableConfig, RunnableLike } from \"@langchain/core/runnables\";\nimport { Send } from \"../constants.js\";\nimport { RunnableCallable } from \"../utils.js\";\nexport declare const SKIP_WRITE: {\n [x: symbol]: boolean;\n};\nexport declare const PASSTHROUGH: {\n [x: symbol]: boolean;\n};\n/**\n * Mapping of write channels to Runnables that return the value to be written,\n * or None to skip writing.\n */\nexport declare class ChannelWrite<\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nRunInput = any> extends RunnableCallable<RunInput, RunInput> {\n writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>;\n constructor(writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>, tags?: string[]);\n _write(input: unknown, config: RunnableConfig): Promise<unknown>;\n // TODO: Support requireAtLeastOneOf\n static doWrite(config: RunnableConfig, writes: (ChannelWriteEntry | ChannelWriteTupleEntry | Send)[]): Promise<void>;\n static isWriter(runnable: RunnableLike): runnable is ChannelWrite;\n static registerWriter<T extends Runnable>(runnable: T): T;\n}\nexport interface ChannelWriteEntry {\n channel: string;\n value: unknown;\n skipNone?: boolean;\n mapper?: Runnable;\n}\nexport interface ChannelWriteTupleEntry {\n value: unknown;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mapper: Runnable<any, [string, any][]>;\n}\n"],"mappings":";;;;;;;;;;AAiB8BS,cAJTF,YAISE;;WAA6CN,GAAAA,CAAAA,SAFnDC,gBAEmDD,CAFlCK,QAEkCL,EAFxBK,QAEwBL,CAAAA,CAAAA;QAAnDQ,EADZA,KACYA,CADNF,iBACME,GADcD,sBACdC,GADuCR,IACvCQ,CAAAA;aACWV,CAAAA,MAAAA,EADXU,KACWV,CADLQ,iBACKR,GADeS,sBACfT,GADwCE,IACxCF,CAAAA,EAAAA,IAAAA,CAAAA,EAAAA,MAAAA,EAAAA;QAAiBW,CAAAA,KAAAA,EAAAA,OAAAA,EAAAA,MAAAA,EAAjBX,cAAiBW,CAAAA,EAAAA,OAAAA,CAAAA,OAAAA,CAAAA;;SAEAH,OAAAA,CAAAA,MAAAA,EAAzBR,cAAyBQ,EAAAA,MAAAA,EAAAA,CAAAA,iBAAAA,GAAoBC,sBAApBD,GAA6CN,IAA7CM,CAAAA,EAAAA,CAAAA,EAAuDG,OAAvDH,CAAAA,IAAAA,CAAAA;SAAoBC,QAAAA,CAAAA,QAAAA,EAC1CR,YAD0CQ,CAAAA,EAAAA,QAAAA,IACfH,YADeG;SAAyBP,cAAAA,CAAAA,UAE7DH,QAF6DG,CAAAA,CAAAA,QAAAA,EAEzCU,CAFyCV,CAAAA,EAErCU,CAFqCV;;AACnED,UAGbO,iBAAAA,CAHaP;SAA2BK,EAAAA,MAAAA;OACrBP,EAAAA,OAAAA;UAAoBa,CAAAA,EAAAA,OAAAA;QAAIA,CAAAA,EAM/Cb,QAN+Ca;;UAQ3CH,sBAAAA;EANAD,KAAAA,EAAAA,OAAAA;EAMAC;UAGLV"}
@@ -1,95 +0,0 @@
1
- import { InvalidUpdateError } from "../errors.js";
2
- import { CONFIG_KEY_SEND, TASKS, _isSend } from "../constants.js";
3
- import { RunnableCallable } from "../utils.js";
4
- import { Runnable } from "@langchain/core/runnables";
5
-
6
- //#region src/pregel/write.ts
7
- const SKIP_WRITE = { [Symbol.for("LG_SKIP_WRITE")]: true };
8
- function _isSkipWrite(x) {
9
- return typeof x === "object" && x?.[Symbol.for("LG_SKIP_WRITE")] !== void 0;
10
- }
11
- const PASSTHROUGH = { [Symbol.for("LG_PASSTHROUGH")]: true };
12
- function _isPassthrough(x) {
13
- return typeof x === "object" && x?.[Symbol.for("LG_PASSTHROUGH")] !== void 0;
14
- }
15
- const IS_WRITER = Symbol("IS_WRITER");
16
- /**
17
- * Mapping of write channels to Runnables that return the value to be written,
18
- * or None to skip writing.
19
- */
20
- var ChannelWrite = class ChannelWrite extends RunnableCallable {
21
- writes;
22
- constructor(writes, tags) {
23
- const name = `ChannelWrite<${writes.map((packet) => {
24
- if (_isSend(packet)) return packet.node;
25
- else if ("channel" in packet) return packet.channel;
26
- return "...";
27
- }).join(",")}>`;
28
- super({
29
- writes,
30
- name,
31
- tags,
32
- func: async (input, config) => {
33
- return this._write(input, config ?? {});
34
- }
35
- });
36
- this.writes = writes;
37
- }
38
- async _write(input, config) {
39
- const writes = this.writes.map((write) => {
40
- if (_isChannelWriteTupleEntry(write) && _isPassthrough(write.value)) return {
41
- mapper: write.mapper,
42
- value: input
43
- };
44
- else if (_isChannelWriteEntry(write) && _isPassthrough(write.value)) return {
45
- channel: write.channel,
46
- value: input,
47
- skipNone: write.skipNone,
48
- mapper: write.mapper
49
- };
50
- else return write;
51
- });
52
- await ChannelWrite.doWrite(config, writes);
53
- return input;
54
- }
55
- static async doWrite(config, writes) {
56
- for (const w of writes) {
57
- if (_isChannelWriteEntry(w)) {
58
- if (w.channel === TASKS) throw new InvalidUpdateError("Cannot write to the reserved channel TASKS");
59
- if (_isPassthrough(w.value)) throw new InvalidUpdateError("PASSTHROUGH value must be replaced");
60
- }
61
- if (_isChannelWriteTupleEntry(w)) {
62
- if (_isPassthrough(w.value)) throw new InvalidUpdateError("PASSTHROUGH value must be replaced");
63
- }
64
- }
65
- const writeEntries = [];
66
- for (const w of writes) if (_isSend(w)) writeEntries.push([TASKS, w]);
67
- else if (_isChannelWriteTupleEntry(w)) {
68
- const mappedResult = await w.mapper.invoke(w.value, config);
69
- if (mappedResult != null && mappedResult.length > 0) writeEntries.push(...mappedResult);
70
- } else if (_isChannelWriteEntry(w)) {
71
- const mappedValue = w.mapper !== void 0 ? await w.mapper.invoke(w.value, config) : w.value;
72
- if (_isSkipWrite(mappedValue)) continue;
73
- if (w.skipNone && mappedValue === void 0) continue;
74
- writeEntries.push([w.channel, mappedValue]);
75
- } else throw new Error(`Invalid write entry: ${JSON.stringify(w)}`);
76
- const write = config.configurable?.[CONFIG_KEY_SEND];
77
- write(writeEntries);
78
- }
79
- static isWriter(runnable) {
80
- return runnable instanceof ChannelWrite || IS_WRITER in runnable && !!runnable[IS_WRITER];
81
- }
82
- static registerWriter(runnable) {
83
- return Object.defineProperty(runnable, IS_WRITER, { value: true });
84
- }
85
- };
86
- function _isChannelWriteEntry(x) {
87
- return x !== void 0 && typeof x.channel === "string";
88
- }
89
- function _isChannelWriteTupleEntry(x) {
90
- return x !== void 0 && !_isChannelWriteEntry(x) && Runnable.isRunnable(x.mapper);
91
- }
92
-
93
- //#endregion
94
- export { ChannelWrite, PASSTHROUGH };
95
- //# sourceMappingURL=write.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.js","names":["writeEntries: [string, any][]","write: TYPE_SEND"],"sources":["../../src/pregel/write.ts"],"sourcesContent":["import {\n Runnable,\n RunnableConfig,\n RunnableLike,\n} from \"@langchain/core/runnables\";\nimport { _isSend, CONFIG_KEY_SEND, Send, TASKS } from \"../constants.js\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { InvalidUpdateError } from \"../errors.js\";\n\ntype TYPE_SEND = (values: Array<[string, unknown]>) => void;\n\nexport const SKIP_WRITE = {\n [Symbol.for(\"LG_SKIP_WRITE\")]: true,\n};\n\nfunction _isSkipWrite(x: unknown) {\n return (\n typeof x === \"object\" &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x as any)?.[Symbol.for(\"LG_SKIP_WRITE\")] !== undefined\n );\n}\n\nexport const PASSTHROUGH = {\n [Symbol.for(\"LG_PASSTHROUGH\")]: true,\n};\n\nfunction _isPassthrough(x: unknown) {\n return (\n typeof x === \"object\" &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x as any)?.[Symbol.for(\"LG_PASSTHROUGH\")] !== undefined\n );\n}\n\nconst IS_WRITER = Symbol(\"IS_WRITER\");\n\n/**\n * Mapping of write channels to Runnables that return the value to be written,\n * or None to skip writing.\n */\nexport class ChannelWrite<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput = any\n> extends RunnableCallable<RunInput, RunInput> {\n writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>;\n\n constructor(\n writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>,\n tags?: string[]\n ) {\n const name = `ChannelWrite<${writes\n .map((packet) => {\n if (_isSend(packet)) {\n return packet.node;\n } else if (\"channel\" in packet) {\n return packet.channel;\n }\n return \"...\";\n })\n .join(\",\")}>`;\n super({\n ...{ writes, name, tags },\n func: async (input: RunInput, config?: RunnableConfig) => {\n return this._write(input, config ?? {});\n },\n });\n\n this.writes = writes;\n }\n\n async _write(input: unknown, config: RunnableConfig): Promise<unknown> {\n const writes = this.writes.map((write) => {\n if (_isChannelWriteTupleEntry(write) && _isPassthrough(write.value)) {\n return {\n mapper: write.mapper,\n value: input,\n };\n } else if (_isChannelWriteEntry(write) && _isPassthrough(write.value)) {\n return {\n channel: write.channel,\n value: input,\n skipNone: write.skipNone,\n mapper: write.mapper,\n };\n } else {\n return write;\n }\n });\n await ChannelWrite.doWrite(config, writes);\n return input;\n }\n\n // TODO: Support requireAtLeastOneOf\n static async doWrite(\n config: RunnableConfig,\n writes: (ChannelWriteEntry | ChannelWriteTupleEntry | Send)[]\n ): Promise<void> {\n // validate\n for (const w of writes) {\n if (_isChannelWriteEntry(w)) {\n if (w.channel === TASKS) {\n throw new InvalidUpdateError(\n \"Cannot write to the reserved channel TASKS\"\n );\n }\n if (_isPassthrough(w.value)) {\n throw new InvalidUpdateError(\"PASSTHROUGH value must be replaced\");\n }\n }\n if (_isChannelWriteTupleEntry(w)) {\n if (_isPassthrough(w.value)) {\n throw new InvalidUpdateError(\"PASSTHROUGH value must be replaced\");\n }\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const writeEntries: [string, any][] = [];\n for (const w of writes) {\n if (_isSend(w)) {\n writeEntries.push([TASKS, w]);\n } else if (_isChannelWriteTupleEntry(w)) {\n const mappedResult = await w.mapper.invoke(w.value, config);\n if (mappedResult != null && mappedResult.length > 0) {\n writeEntries.push(...mappedResult);\n }\n } else if (_isChannelWriteEntry(w)) {\n const mappedValue =\n w.mapper !== undefined\n ? await w.mapper.invoke(w.value, config)\n : w.value;\n if (_isSkipWrite(mappedValue)) {\n continue;\n }\n if (w.skipNone && mappedValue === undefined) {\n continue;\n }\n writeEntries.push([w.channel, mappedValue]);\n } else {\n throw new Error(`Invalid write entry: ${JSON.stringify(w)}`);\n }\n }\n const write: TYPE_SEND = config.configurable?.[CONFIG_KEY_SEND];\n write(writeEntries);\n }\n\n static isWriter(runnable: RunnableLike): runnable is ChannelWrite {\n return (\n // eslint-disable-next-line no-instanceof/no-instanceof\n runnable instanceof ChannelWrite ||\n (IS_WRITER in runnable && !!runnable[IS_WRITER])\n );\n }\n\n static registerWriter<T extends Runnable>(runnable: T): T {\n return Object.defineProperty(runnable, IS_WRITER, { value: true });\n }\n}\n\nexport interface ChannelWriteEntry {\n channel: string;\n value: unknown;\n skipNone?: boolean;\n mapper?: Runnable;\n}\n\nfunction _isChannelWriteEntry(x: unknown): x is ChannelWriteEntry {\n return (\n x !== undefined && typeof (x as ChannelWriteEntry).channel === \"string\"\n );\n}\n\nexport interface ChannelWriteTupleEntry {\n value: unknown;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mapper: Runnable<any, [string, any][]>;\n}\n\nfunction _isChannelWriteTupleEntry(x: unknown): x is ChannelWriteTupleEntry {\n return (\n x !== undefined &&\n !_isChannelWriteEntry(x) &&\n Runnable.isRunnable((x as ChannelWriteTupleEntry).mapper)\n );\n}\n"],"mappings":";;;;;;AAWA,MAAa,aAAa,GACvB,OAAO,IAAI,mBAAmB;AAGjC,SAAS,aAAa,GAAY;AAChC,QACE,OAAO,MAAM,YAEZ,IAAY,OAAO,IAAI,sBAAsB;;AAIlD,MAAa,cAAc,GACxB,OAAO,IAAI,oBAAoB;AAGlC,SAAS,eAAe,GAAY;AAClC,QACE,OAAO,MAAM,YAEZ,IAAY,OAAO,IAAI,uBAAuB;;AAInD,MAAM,YAAY,OAAO;;;;;AAMzB,IAAa,eAAb,MAAa,qBAGH,iBAAqC;CAC7C;CAEA,YACE,QACA,MACA;EACA,MAAM,OAAO,gBAAgB,OAC1B,KAAK,WAAW;AACf,OAAI,QAAQ,QACV,QAAO,OAAO;YACL,aAAa,OACtB,QAAO,OAAO;AAEhB,UAAO;KAER,KAAK,KAAK;AACb,QAAM;GACC;GAAQ;GAAM;GACnB,MAAM,OAAO,OAAiB,WAA4B;AACxD,WAAO,KAAK,OAAO,OAAO,UAAU;;;AAIxC,OAAK,SAAS;;CAGhB,MAAM,OAAO,OAAgB,QAA0C;EACrE,MAAM,SAAS,KAAK,OAAO,KAAK,UAAU;AACxC,OAAI,0BAA0B,UAAU,eAAe,MAAM,OAC3D,QAAO;IACL,QAAQ,MAAM;IACd,OAAO;;YAEA,qBAAqB,UAAU,eAAe,MAAM,OAC7D,QAAO;IACL,SAAS,MAAM;IACf,OAAO;IACP,UAAU,MAAM;IAChB,QAAQ,MAAM;;OAGhB,QAAO;;AAGX,QAAM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.RemoteGraph = require_remote.RemoteGraph;
package/dist/remote.d.cts DELETED
@@ -1,2 +0,0 @@
1
- import { RemoteGraph, RemoteGraphParams } from "./pregel/remote.cjs";
2
- export { RemoteGraph, type RemoteGraphParams };
package/dist/remote.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { RemoteGraph, RemoteGraphParams } from "./pregel/remote.js";
2
- export { RemoteGraph, type RemoteGraphParams };
package/dist/remote.js DELETED
@@ -1,3 +0,0 @@
1
- import { RemoteGraph } from "./pregel/remote.js";
2
-
3
- export { RemoteGraph };