@langchain/langgraph 1.0.12 → 1.0.14

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 +25 -27
@@ -0,0 +1,116 @@
1
+ import { BaseChannel } from "../channels/base.cjs";
2
+ import { BinaryOperator, BinaryOperatorAggregate } from "../channels/binop.cjs";
3
+ import { LastValue } from "../channels/last_value.cjs";
4
+ import { RunnableLike } from "../pregel/runnable_types.cjs";
5
+
6
+ //#region src/graph/annotation.d.ts
7
+ type SingleReducer<ValueType, UpdateType = ValueType> = {
8
+ reducer: BinaryOperator<ValueType, UpdateType>;
9
+ default?: () => ValueType;
10
+ } | {
11
+ /**
12
+ * @deprecated Use `reducer` instead
13
+ */
14
+ value: BinaryOperator<ValueType, UpdateType>;
15
+ default?: () => ValueType;
16
+ } | null;
17
+ interface StateDefinition {
18
+ [key: string]: BaseChannel | (() => BaseChannel);
19
+ }
20
+ type ExtractValueType<C> = C extends BaseChannel ? C["ValueType"] : C extends (() => BaseChannel) ? ReturnType<C>["ValueType"] : never;
21
+ type ExtractUpdateType<C> = C extends BaseChannel ? C["UpdateType"] : C extends (() => BaseChannel) ? ReturnType<C>["UpdateType"] : never;
22
+ type StateType<SD extends StateDefinition> = { [key in keyof SD]: ExtractValueType<SD[key]> };
23
+ type UpdateType<SD extends StateDefinition> = { [key in keyof SD]?: ExtractUpdateType<SD[key]> };
24
+ type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;
25
+ /** @ignore */
26
+ interface AnnotationFunction {
27
+ <ValueType>(): LastValue<ValueType>;
28
+ <ValueType, UpdateType = ValueType>(annotation: SingleReducer<ValueType, UpdateType>): BinaryOperatorAggregate<ValueType, UpdateType>;
29
+ Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;
30
+ }
31
+ /**
32
+ * Should not be instantiated directly. See {@link Annotation}.
33
+ */
34
+ declare class AnnotationRoot<SD extends StateDefinition> {
35
+ lc_graph_name: string;
36
+ State: StateType<SD>;
37
+ Update: UpdateType<SD>;
38
+ Node: NodeType<SD>;
39
+ spec: SD;
40
+ constructor(s: SD);
41
+ }
42
+ /**
43
+ * Helper that instantiates channels within a StateGraph state.
44
+ *
45
+ * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:
46
+ * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.
47
+ * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * import { StateGraph, Annotation } from "@langchain/langgraph";
52
+ *
53
+ * // Define a state with a single string key named "currentOutput"
54
+ * const SimpleAnnotation = Annotation.Root({
55
+ * currentOutput: Annotation<string>,
56
+ * });
57
+ *
58
+ * const graphBuilder = new StateGraph(SimpleAnnotation);
59
+ *
60
+ * // A node in the graph that returns an object with a "currentOutput" key
61
+ * // replaces the value in the state. You can get the state type as shown below:
62
+ * const myNode = (state: typeof SimpleAnnotation.State) => {
63
+ * return {
64
+ * currentOutput: "some_new_value",
65
+ * };
66
+ * }
67
+ *
68
+ * const graph = graphBuilder
69
+ * .addNode("myNode", myNode)
70
+ * ...
71
+ * .compile();
72
+ * ```
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * import { type BaseMessage, AIMessage } from "@langchain/core/messages";
77
+ * import { StateGraph, Annotation } from "@langchain/langgraph";
78
+ *
79
+ * // Define a state with a single key named "messages" that will
80
+ * // combine a returned BaseMessage or arrays of BaseMessages
81
+ * const AnnotationWithReducer = Annotation.Root({
82
+ * messages: Annotation<BaseMessage[]>({
83
+ * // Different types are allowed for updates
84
+ * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {
85
+ * if (Array.isArray(right)) {
86
+ * return left.concat(right);
87
+ * }
88
+ * return left.concat([right]);
89
+ * },
90
+ * default: () => [],
91
+ * }),
92
+ * });
93
+ *
94
+ * const graphBuilder = new StateGraph(AnnotationWithReducer);
95
+ *
96
+ * // A node in the graph that returns an object with a "messages" key
97
+ * // will update the state by combining the existing value with the returned one.
98
+ * const myNode = (state: typeof AnnotationWithReducer.State) => {
99
+ * return {
100
+ * messages: [new AIMessage("Some new response")],
101
+ * };
102
+ * };
103
+ *
104
+ * const graph = graphBuilder
105
+ * .addNode("myNode", myNode)
106
+ * ...
107
+ * .compile();
108
+ * ```
109
+ * @namespace
110
+ * @property Root
111
+ * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.
112
+ */
113
+ declare const Annotation: AnnotationFunction;
114
+ //#endregion
115
+ export { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType };
116
+ //# sourceMappingURL=annotation.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.d.cts","names":["RunnableLike","BaseChannel","BinaryOperator","BinaryOperatorAggregate","LastValue","SingleReducer","ValueType","UpdateType","StateDefinition","ExtractValueType","C","ReturnType","ExtractUpdateType","StateType","SD","key","NodeType","Partial","AnnotationFunction","S","AnnotationRoot","Annotation","getChannel","V","U"],"sources":["../../src/graph/annotation.d.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nexport type SingleReducer<ValueType, UpdateType = ValueType> = {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | null;\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\ntype ExtractValueType<C> = C extends BaseChannel ? C[\"ValueType\"] : C extends () => BaseChannel ? ReturnType<C>[\"ValueType\"] : never;\ntype ExtractUpdateType<C> = C extends BaseChannel ? C[\"UpdateType\"] : C extends () => BaseChannel ? ReturnType<C>[\"UpdateType\"] : never;\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\nexport type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(annotation: SingleReducer<ValueType, UpdateType>): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport declare class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name: string;\n State: StateType<SD>;\n Update: UpdateType<SD>;\n Node: NodeType<SD>;\n spec: SD;\n constructor(s: SD);\n}\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport declare const Annotation: AnnotationFunction;\nexport declare function getChannel<V, U = V>(reducer: SingleReducer<V, U>): BaseChannel<V, U>;\nexport {};\n"],"mappings":";;;;;;KAIYK,sCAAsCC;WACrCJ,eAAeI,WAAWC;EAD3BF,OAAAA,CAAAA,EAAAA,GAAAA,GAEQC,SAFK;CAAA,GAAA;;;;OACZJ,EAMFA,cANEA,CAMaI,SANbJ,EAMwBK,UANxBL,CAAAA;SACOI,CAAAA,EAAAA,GAAAA,GAMAA,SANAA;QAKMA;AAAWC,UAGpBC,eAAAA,CAHoBD;MAA1BL,EAAAA,MAAAA,CAAAA,EAIQD,WAJRC,GAAAA,CAAAA,GAAAA,GAI6BD,WAJ7BC,CAAAA;;KAMNO,gBALwB,CAAA,CAAA,CAAA,GAKFC,CALE,SAKQT,WALR,GAKsBS,CALtB,CAAA,WAAA,CAAA,GAKuCA,CALvC,UAAA,GAAA,GAKuDT,WALvD,IAKqEU,UALrE,CAKgFD,CALhF,CAAA,CAAA,WAAA,CAAA,GAAA,KAAA;AAE7B,KAIKE,iBAJ2B,CAAA,CAAA,CAAA,GAIJF,CAJI,SAIMT,WAJN,GAIoBS,CAJpB,CAAA,YAAA,CAAA,GAIsCA,CAJtC,UAAA,GAAA,GAIsDT,WAJtD,IAIoEU,UAJpE,CAI+ED,CAJ/E,CAAA,CAAA,YAAA,CAAA,GAAA,KAAA;AAAA,KAKpBG,SALoB,CAAA,WAKCL,eALD,CAAA,GAAA,UACbP,MAKDa,EALCb,GAKIQ,gBALJR,CAKqBa,EALrBb,CAKwBc,GALxBd,CAAAA,CAAAA;AAAgC,KAOvCM,UAPuC,CAAA,WAOjBC,eAPiB,CAAA,GAAA,UAE9CC,MAMaK,EANbL,IAMmBG,iBANH,CAMqBE,EANrB,CAMwBC,GANxB,CAAA,CAAA,EAAA;AAAML,KAQfM,QAReN,CAAAA,WAQKF,eARLE,CAAAA,GAQwBV,YARxBU,CAQqCG,SARrCH,CAQ+CI,EAR/CJ,CAAAA,EAQoDH,UARpDG,CAQ+DI,EAR/DJ,CAAAA,GAQqEO,OARrEP,CAQ6EG,SAR7EH,CAQuFI,EARvFJ,CAAAA,CAAAA,CAAAA;;AAAwBA,UAUlCQ,kBAAAA,CAVkCR;YAAiBA,CAAAA,EAAAA,EAWjDN,SAXiDM,CAWvCJ,SAXuCI,CAAAA;YAAgBT,EAAAA,aAYvDK,SAZuDL,CAAAA,CAAAA,UAAAA,EAYhCI,aAZgCJ,CAYlBK,SAZkBL,EAYPM,UAZON,CAAAA,CAAAA,EAYOE,uBAZPF,CAY+BK,SAZ/BL,EAY0CM,UAZ1CN,CAAAA;MAAyBS,EAAAA,CAAAA,UAaxFF,eAbwFE,CAAAA,CAAAA,EAAAA,EAanES,CAbmET,EAAAA,GAa7DU,cAb6DV,CAa9CS,CAb8CT,CAAAA;;;AAAD;;AAChFA,cAiBPU,cAjBOV,CAAAA,WAiBmBF,eAjBnBE,CAAAA,CAAAA;eAAUT,EAAAA,MAAAA;OAAcS,EAmBzCG,SAnByCH,CAmB/BI,EAnB+BJ,CAAAA;QAAkBA,EAoB1DH,UApB0DG,CAoB/CI,EApB+CJ,CAAAA;MAAgBT,EAqB5Ee,QArB4Ef,CAqBnEa,EArBmEb,CAAAA;MAAyBS,EAsBrGI,EAtBqGJ;aAAXC,CAAAA,CAAAA,EAuBjFG,EAvBiFH;;AACpG;;;;;;;;AAGA;;;;;;;;AAGA;;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;AA+EA;;;;;;;;;;;;;;;cAAqBU,YAAYH"}
@@ -0,0 +1,116 @@
1
+ import { BaseChannel } from "../channels/base.js";
2
+ import { BinaryOperator, BinaryOperatorAggregate } from "../channels/binop.js";
3
+ import { LastValue } from "../channels/last_value.js";
4
+ import { RunnableLike } from "../pregel/runnable_types.js";
5
+
6
+ //#region src/graph/annotation.d.ts
7
+ type SingleReducer<ValueType, UpdateType = ValueType> = {
8
+ reducer: BinaryOperator<ValueType, UpdateType>;
9
+ default?: () => ValueType;
10
+ } | {
11
+ /**
12
+ * @deprecated Use `reducer` instead
13
+ */
14
+ value: BinaryOperator<ValueType, UpdateType>;
15
+ default?: () => ValueType;
16
+ } | null;
17
+ interface StateDefinition {
18
+ [key: string]: BaseChannel | (() => BaseChannel);
19
+ }
20
+ type ExtractValueType<C> = C extends BaseChannel ? C["ValueType"] : C extends (() => BaseChannel) ? ReturnType<C>["ValueType"] : never;
21
+ type ExtractUpdateType<C> = C extends BaseChannel ? C["UpdateType"] : C extends (() => BaseChannel) ? ReturnType<C>["UpdateType"] : never;
22
+ type StateType<SD extends StateDefinition> = { [key in keyof SD]: ExtractValueType<SD[key]> };
23
+ type UpdateType<SD extends StateDefinition> = { [key in keyof SD]?: ExtractUpdateType<SD[key]> };
24
+ type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;
25
+ /** @ignore */
26
+ interface AnnotationFunction {
27
+ <ValueType>(): LastValue<ValueType>;
28
+ <ValueType, UpdateType = ValueType>(annotation: SingleReducer<ValueType, UpdateType>): BinaryOperatorAggregate<ValueType, UpdateType>;
29
+ Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;
30
+ }
31
+ /**
32
+ * Should not be instantiated directly. See {@link Annotation}.
33
+ */
34
+ declare class AnnotationRoot<SD extends StateDefinition> {
35
+ lc_graph_name: string;
36
+ State: StateType<SD>;
37
+ Update: UpdateType<SD>;
38
+ Node: NodeType<SD>;
39
+ spec: SD;
40
+ constructor(s: SD);
41
+ }
42
+ /**
43
+ * Helper that instantiates channels within a StateGraph state.
44
+ *
45
+ * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:
46
+ * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.
47
+ * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * import { StateGraph, Annotation } from "@langchain/langgraph";
52
+ *
53
+ * // Define a state with a single string key named "currentOutput"
54
+ * const SimpleAnnotation = Annotation.Root({
55
+ * currentOutput: Annotation<string>,
56
+ * });
57
+ *
58
+ * const graphBuilder = new StateGraph(SimpleAnnotation);
59
+ *
60
+ * // A node in the graph that returns an object with a "currentOutput" key
61
+ * // replaces the value in the state. You can get the state type as shown below:
62
+ * const myNode = (state: typeof SimpleAnnotation.State) => {
63
+ * return {
64
+ * currentOutput: "some_new_value",
65
+ * };
66
+ * }
67
+ *
68
+ * const graph = graphBuilder
69
+ * .addNode("myNode", myNode)
70
+ * ...
71
+ * .compile();
72
+ * ```
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * import { type BaseMessage, AIMessage } from "@langchain/core/messages";
77
+ * import { StateGraph, Annotation } from "@langchain/langgraph";
78
+ *
79
+ * // Define a state with a single key named "messages" that will
80
+ * // combine a returned BaseMessage or arrays of BaseMessages
81
+ * const AnnotationWithReducer = Annotation.Root({
82
+ * messages: Annotation<BaseMessage[]>({
83
+ * // Different types are allowed for updates
84
+ * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {
85
+ * if (Array.isArray(right)) {
86
+ * return left.concat(right);
87
+ * }
88
+ * return left.concat([right]);
89
+ * },
90
+ * default: () => [],
91
+ * }),
92
+ * });
93
+ *
94
+ * const graphBuilder = new StateGraph(AnnotationWithReducer);
95
+ *
96
+ * // A node in the graph that returns an object with a "messages" key
97
+ * // will update the state by combining the existing value with the returned one.
98
+ * const myNode = (state: typeof AnnotationWithReducer.State) => {
99
+ * return {
100
+ * messages: [new AIMessage("Some new response")],
101
+ * };
102
+ * };
103
+ *
104
+ * const graph = graphBuilder
105
+ * .addNode("myNode", myNode)
106
+ * ...
107
+ * .compile();
108
+ * ```
109
+ * @namespace
110
+ * @property Root
111
+ * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.
112
+ */
113
+ declare const Annotation: AnnotationFunction;
114
+ //#endregion
115
+ export { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType };
116
+ //# sourceMappingURL=annotation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.d.ts","names":["RunnableLike","BaseChannel","BinaryOperator","BinaryOperatorAggregate","LastValue","SingleReducer","ValueType","UpdateType","StateDefinition","ExtractValueType","C","ReturnType","ExtractUpdateType","StateType","SD","key","NodeType","Partial","AnnotationFunction","S","AnnotationRoot","Annotation","getChannel","V","U"],"sources":["../../src/graph/annotation.d.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nexport type SingleReducer<ValueType, UpdateType = ValueType> = {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | null;\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\ntype ExtractValueType<C> = C extends BaseChannel ? C[\"ValueType\"] : C extends () => BaseChannel ? ReturnType<C>[\"ValueType\"] : never;\ntype ExtractUpdateType<C> = C extends BaseChannel ? C[\"UpdateType\"] : C extends () => BaseChannel ? ReturnType<C>[\"UpdateType\"] : never;\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\nexport type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(annotation: SingleReducer<ValueType, UpdateType>): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport declare class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name: string;\n State: StateType<SD>;\n Update: UpdateType<SD>;\n Node: NodeType<SD>;\n spec: SD;\n constructor(s: SD);\n}\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport declare const Annotation: AnnotationFunction;\nexport declare function getChannel<V, U = V>(reducer: SingleReducer<V, U>): BaseChannel<V, U>;\nexport {};\n"],"mappings":";;;;;;KAIYK,sCAAsCC;WACrCJ,eAAeI,WAAWC;EAD3BF,OAAAA,CAAAA,EAAAA,GAAAA,GAEQC,SAFK;CAAA,GAAA;;;;OACZJ,EAMFA,cANEA,CAMaI,SANbJ,EAMwBK,UANxBL,CAAAA;SACOI,CAAAA,EAAAA,GAAAA,GAMAA,SANAA;QAKMA;AAAWC,UAGpBC,eAAAA,CAHoBD;MAA1BL,EAAAA,MAAAA,CAAAA,EAIQD,WAJRC,GAAAA,CAAAA,GAAAA,GAI6BD,WAJ7BC,CAAAA;;KAMNO,gBALwB,CAAA,CAAA,CAAA,GAKFC,CALE,SAKQT,WALR,GAKsBS,CALtB,CAAA,WAAA,CAAA,GAKuCA,CALvC,UAAA,GAAA,GAKuDT,WALvD,IAKqEU,UALrE,CAKgFD,CALhF,CAAA,CAAA,WAAA,CAAA,GAAA,KAAA;AAE7B,KAIKE,iBAJ2B,CAAA,CAAA,CAAA,GAIJF,CAJI,SAIMT,WAJN,GAIoBS,CAJpB,CAAA,YAAA,CAAA,GAIsCA,CAJtC,UAAA,GAAA,GAIsDT,WAJtD,IAIoEU,UAJpE,CAI+ED,CAJ/E,CAAA,CAAA,YAAA,CAAA,GAAA,KAAA;AAAA,KAKpBG,SALoB,CAAA,WAKCL,eALD,CAAA,GAAA,UACbP,MAKDa,EALCb,GAKIQ,gBALJR,CAKqBa,EALrBb,CAKwBc,GALxBd,CAAAA,CAAAA;AAAgC,KAOvCM,UAPuC,CAAA,WAOjBC,eAPiB,CAAA,GAAA,UAE9CC,MAMaK,EANbL,IAMmBG,iBANH,CAMqBE,EANrB,CAMwBC,GANxB,CAAA,CAAA,EAAA;AAAML,KAQfM,QAReN,CAAAA,WAQKF,eARLE,CAAAA,GAQwBV,YARxBU,CAQqCG,SARrCH,CAQ+CI,EAR/CJ,CAAAA,EAQoDH,UARpDG,CAQ+DI,EAR/DJ,CAAAA,GAQqEO,OARrEP,CAQ6EG,SAR7EH,CAQuFI,EARvFJ,CAAAA,CAAAA,CAAAA;;AAAwBA,UAUlCQ,kBAAAA,CAVkCR;YAAiBA,CAAAA,EAAAA,EAWjDN,SAXiDM,CAWvCJ,SAXuCI,CAAAA;YAAgBT,EAAAA,aAYvDK,SAZuDL,CAAAA,CAAAA,UAAAA,EAYhCI,aAZgCJ,CAYlBK,SAZkBL,EAYPM,UAZON,CAAAA,CAAAA,EAYOE,uBAZPF,CAY+BK,SAZ/BL,EAY0CM,UAZ1CN,CAAAA;MAAyBS,EAAAA,CAAAA,UAaxFF,eAbwFE,CAAAA,CAAAA,EAAAA,EAanES,CAbmET,EAAAA,GAa7DU,cAb6DV,CAa9CS,CAb8CT,CAAAA;;;AAAD;;AAChFA,cAiBPU,cAjBOV,CAAAA,WAiBmBF,eAjBnBE,CAAAA,CAAAA;eAAUT,EAAAA,MAAAA;OAAcS,EAmBzCG,SAnByCH,CAmB/BI,EAnB+BJ,CAAAA;QAAkBA,EAoB1DH,UApB0DG,CAoB/CI,EApB+CJ,CAAAA;MAAgBT,EAqB5Ee,QArB4Ef,CAqBnEa,EArBmEb,CAAAA;MAAyBS,EAsBrGI,EAtBqGJ;aAAXC,CAAAA,CAAAA,EAuBjFG,EAvBiFH;;AACpG;;;;;;;;AAGA;;;;;;;;AAGA;;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;AA+EA;;;;;;;;;;;;;;;cAAqBU,YAAYH"}
@@ -0,0 +1,99 @@
1
+ import { BinaryOperatorAggregate } from "../channels/binop.js";
2
+ import { LastValue } from "../channels/last_value.js";
3
+
4
+ //#region src/graph/annotation.ts
5
+ /**
6
+ * Should not be instantiated directly. See {@link Annotation}.
7
+ */
8
+ var AnnotationRoot = class {
9
+ lc_graph_name = "AnnotationRoot";
10
+ spec;
11
+ constructor(s) {
12
+ this.spec = s;
13
+ }
14
+ };
15
+ /**
16
+ * Helper that instantiates channels within a StateGraph state.
17
+ *
18
+ * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:
19
+ * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.
20
+ * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { StateGraph, Annotation } from "@langchain/langgraph";
25
+ *
26
+ * // Define a state with a single string key named "currentOutput"
27
+ * const SimpleAnnotation = Annotation.Root({
28
+ * currentOutput: Annotation<string>,
29
+ * });
30
+ *
31
+ * const graphBuilder = new StateGraph(SimpleAnnotation);
32
+ *
33
+ * // A node in the graph that returns an object with a "currentOutput" key
34
+ * // replaces the value in the state. You can get the state type as shown below:
35
+ * const myNode = (state: typeof SimpleAnnotation.State) => {
36
+ * return {
37
+ * currentOutput: "some_new_value",
38
+ * };
39
+ * }
40
+ *
41
+ * const graph = graphBuilder
42
+ * .addNode("myNode", myNode)
43
+ * ...
44
+ * .compile();
45
+ * ```
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { type BaseMessage, AIMessage } from "@langchain/core/messages";
50
+ * import { StateGraph, Annotation } from "@langchain/langgraph";
51
+ *
52
+ * // Define a state with a single key named "messages" that will
53
+ * // combine a returned BaseMessage or arrays of BaseMessages
54
+ * const AnnotationWithReducer = Annotation.Root({
55
+ * messages: Annotation<BaseMessage[]>({
56
+ * // Different types are allowed for updates
57
+ * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {
58
+ * if (Array.isArray(right)) {
59
+ * return left.concat(right);
60
+ * }
61
+ * return left.concat([right]);
62
+ * },
63
+ * default: () => [],
64
+ * }),
65
+ * });
66
+ *
67
+ * const graphBuilder = new StateGraph(AnnotationWithReducer);
68
+ *
69
+ * // A node in the graph that returns an object with a "messages" key
70
+ * // will update the state by combining the existing value with the returned one.
71
+ * const myNode = (state: typeof AnnotationWithReducer.State) => {
72
+ * return {
73
+ * messages: [new AIMessage("Some new response")],
74
+ * };
75
+ * };
76
+ *
77
+ * const graph = graphBuilder
78
+ * .addNode("myNode", myNode)
79
+ * ...
80
+ * .compile();
81
+ * ```
82
+ * @namespace
83
+ * @property Root
84
+ * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.
85
+ */
86
+ const Annotation = function(annotation) {
87
+ if (annotation) return getChannel(annotation);
88
+ else return new LastValue();
89
+ };
90
+ Annotation.Root = (sd) => new AnnotationRoot(sd);
91
+ function getChannel(reducer) {
92
+ if (typeof reducer === "object" && reducer && "reducer" in reducer && reducer.reducer) return new BinaryOperatorAggregate(reducer.reducer, reducer.default);
93
+ if (typeof reducer === "object" && reducer && "value" in reducer && reducer.value) return new BinaryOperatorAggregate(reducer.value, reducer.default);
94
+ return new LastValue();
95
+ }
96
+
97
+ //#endregion
98
+ export { Annotation, AnnotationRoot, getChannel };
99
+ //# sourceMappingURL=annotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.js","names":[],"sources":["../../src/graph/annotation.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\n\nexport type SingleReducer<ValueType, UpdateType = ValueType> =\n | {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | null;\n\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\n\ntype ExtractValueType<C> = C extends BaseChannel\n ? C[\"ValueType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"ValueType\"]\n : never;\n\ntype ExtractUpdateType<C> = C extends BaseChannel\n ? C[\"UpdateType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"UpdateType\"]\n : never;\n\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\n\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\n\nexport type NodeType<SD extends StateDefinition> = RunnableLike<\n StateType<SD>,\n UpdateType<SD> | Partial<StateType<SD>>\n>;\n\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(\n annotation: SingleReducer<ValueType, UpdateType>\n ): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name = \"AnnotationRoot\";\n\n declare State: StateType<SD>;\n\n declare Update: UpdateType<SD>;\n\n declare Node: NodeType<SD>;\n\n spec: SD;\n\n constructor(s: SD) {\n this.spec = s;\n }\n}\n\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport const Annotation: AnnotationFunction = function <\n ValueType,\n UpdateType = ValueType\n>(\n annotation?: SingleReducer<ValueType, UpdateType>\n): BaseChannel<ValueType, UpdateType> {\n if (annotation) {\n return getChannel<ValueType, UpdateType>(annotation);\n } else {\n // @ts-expect-error - Annotation without reducer\n return new LastValue<ValueType>();\n }\n} as AnnotationFunction;\n\nAnnotation.Root = <S extends StateDefinition>(sd: S) => new AnnotationRoot(sd);\n\nexport function getChannel<V, U = V>(\n reducer: SingleReducer<V, U>\n): BaseChannel<V, U> {\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"reducer\" in reducer &&\n reducer.reducer\n ) {\n return new BinaryOperatorAggregate(reducer.reducer, reducer.default);\n }\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"value\" in reducer &&\n reducer.value\n ) {\n return new BinaryOperatorAggregate(reducer.value, reducer.default);\n }\n // @ts-expect-error - Annotation without reducer\n return new LastValue<V>();\n}\n"],"mappings":";;;;;;;AA4DA,IAAa,iBAAb,MAAwD;CACtD,gBAAgB;CAQhB;CAEA,YAAY,GAAO;AACjB,OAAK,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EhB,MAAa,aAAiC,SAI5C,YACoC;AACpC,KAAI,WACF,QAAO,WAAkC,WAAW;KAGpD,QAAO,IAAI,WAAsB;;AAIrC,WAAW,QAAmC,OAAU,IAAI,eAAe,GAAG;AAE9E,SAAgB,WACd,SACmB;AACnB,KACE,OAAO,YAAY,YACnB,WACA,aAAa,WACb,QAAQ,QAER,QAAO,IAAI,wBAAwB,QAAQ,SAAS,QAAQ,QAAQ;AAEtE,KACE,OAAO,YAAY,YACnB,WACA,WAAW,WACX,QAAQ,MAER,QAAO,IAAI,wBAAwB,QAAQ,OAAO,QAAQ,QAAQ;AAGpE,QAAO,IAAI,WAAc"}