@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,293 +0,0 @@
1
- import { LastValue } from "../channels/last_value.cjs";
2
- import { EphemeralValue } from "../channels/ephemeral_value.cjs";
3
- import { CachePolicy, RetryPolicy } from "../pregel/utils/index.cjs";
4
- import { PregelNode } from "../pregel/read.cjs";
5
- import { END, PREVIOUS, START } from "../constants.cjs";
6
- import { Pregel } from "../pregel/index.cjs";
7
- import { EntrypointFinal, EntrypointFinalSaveT, EntrypointFunc, EntrypointReturnT, TaskFunc } from "./types.cjs";
8
- import { BaseCache, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
9
-
10
- //#region src/func/index.d.ts
11
-
12
- /**
13
- * Options for the {@link task} function
14
- */
15
- interface TaskOptions {
16
- /**
17
- * The name of the task, analogous to the node name in {@link StateGraph}.
18
- */
19
- name: string;
20
- /**
21
- * The retry policy for the task. Configures how many times and under what conditions
22
- * the task should be retried if it fails.
23
- */
24
- retry?: RetryPolicy;
25
- /**
26
- * The cache policy for the task. Configures how the task should be cached.
27
- */
28
- cachePolicy?: CachePolicy;
29
- }
30
- /**
31
- * Define a LangGraph task using the `task` function.
32
- *
33
- * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.
34
- * A task can be called like a regular function with the following differences:
35
- *
36
- * - When a checkpointer is enabled, the function inputs and outputs must be serializable.
37
- * - The wrapped function can only be called from within an entrypoint or StateGraph.
38
- * - Calling the function produces a promise. This makes it easy to parallelize tasks.
39
- *
40
- * @typeParam ArgsT - The type of arguments the task function accepts
41
- * @typeParam OutputT - The type of value the task function returns
42
- * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task
43
- * @param func - The function that executes this task
44
- * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise
45
- *
46
- * @example basic example
47
- * ```typescript
48
- * const addOne = task("add", async (a: number) => a + 1);
49
- *
50
- * const workflow = entrypoint("example", async (numbers: number[]) => {
51
- * const promises = numbers.map(n => addOne(n));
52
- * const results = await Promise.all(promises);
53
- * return results;
54
- * });
55
- *
56
- * // Call the entrypoint
57
- * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]
58
- * ```
59
- *
60
- * @example using a retry policy
61
- * ```typescript
62
- * const addOne = task({
63
- * name: "add",
64
- * retry: { maxAttempts: 3 }
65
- * },
66
- * async (a: number) => a + 1
67
- * );
68
- *
69
- * const workflow = entrypoint("example", async (numbers: number[]) => {
70
- * const promises = numbers.map(n => addOne(n));
71
- * const results = await Promise.all(promises);
72
- * return results;
73
- * });
74
- * ```
75
- * @category Functional API
76
- */
77
- declare function task<ArgsT extends unknown[], OutputT>(optionsOrName: TaskOptions | string, func: TaskFunc<ArgsT, OutputT>): (...args: ArgsT) => Promise<OutputT>;
78
- /**
79
- * Options for the {@link entrypoint} function
80
- */
81
- type EntrypointOptions = {
82
- /**
83
- * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.
84
- * This name is used for logging, debugging, and checkpoint identification.
85
- */
86
- name: string;
87
- /**
88
- * The checkpointer for the {@link entrypoint}. Used to save and restore state between
89
- * invocations of the workflow.
90
- */
91
- checkpointer?: BaseCheckpointSaver;
92
- /**
93
- * The store for the {@link entrypoint}. Used to persist data across workflow runs.
94
- */
95
- store?: BaseStore;
96
- /**
97
- * The cache for the {@link entrypoint}. Used to cache values between workflow runs.
98
- */
99
- cache?: BaseCache;
100
- };
101
- /**
102
- * Type declaration for the entrypoint function with its properties
103
- * @category Functional API
104
- */
105
- interface EntrypointFunction {
106
- <InputT, OutputT>(optionsOrName: EntrypointOptions | string, func: EntrypointFunc<InputT, OutputT>): Pregel<Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, {
107
- [START]: EphemeralValue<InputT>;
108
- [END]: LastValue<EntrypointReturnT<OutputT>>;
109
- [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;
110
- }, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>,
111
- // Because the update type is an return type union of tasks + entrypoint,
112
- // thus we can't type it properly.
113
- any,
114
- // eslint-disable-line @typescript-eslint/no-explicit-any
115
- Awaited<EntrypointReturnT<OutputT>>>;
116
- /**
117
- * A helper utility for use with the functional API that returns a value to the caller,
118
- * as well as a separate state value to persist to the checkpoint. This allows workflows
119
- * to maintain state between runs while returning different values to the caller.
120
- *
121
- * @typeParam ValueT - The type of the value to return to the caller
122
- * @typeParam SaveT - The type of the state to save to the checkpoint
123
- * @param options.value - The value to return to the caller
124
- * @param options.save - The value to save to the checkpoint
125
- * @returns An object with the value and save properties
126
- *
127
- * @example
128
- * ```typescript
129
- * return entrypoint.final({
130
- * value: "result for caller",
131
- * save: { counter: currentCount + 1 }
132
- * });
133
- * ```
134
- */
135
- final<ValueT, SaveT>(options: {
136
- value?: ValueT;
137
- save?: SaveT;
138
- }): EntrypointFinal<ValueT, SaveT>;
139
- }
140
- /**
141
- * Define a LangGraph workflow using the `entrypoint` function.
142
- *
143
- * ### Function signature
144
- *
145
- * The wrapped function must accept at most **two parameters**. The first parameter
146
- * is the input to the function. The second (optional) parameter is a
147
- * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to
148
- * the function, you can pass them as an object.
149
- *
150
- * ### Helper functions
151
- *
152
- * #### Streaming
153
- * To write data to the "custom" stream, use the {@link getWriter} function, or the
154
- * {@link LangGraphRunnableConfig.writer} property.
155
- *
156
- * #### State management
157
- * The {@link getPreviousState} function can be used to access the previous state
158
- * that was returned from the last invocation of the entrypoint on the same thread id.
159
- *
160
- * If you wish to save state other than the return value, you can use the
161
- * {@link entrypoint.final} function.
162
- *
163
- * @typeParam InputT - The type of input the entrypoint accepts
164
- * @typeParam OutputT - The type of output the entrypoint produces
165
- * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint
166
- * @param func - The function that executes this entrypoint
167
- * @returns A {@link Pregel} instance that can be run to execute the workflow
168
- *
169
- * @example Using entrypoint and tasks
170
- * ```typescript
171
- * import { task, entrypoint } from "@langchain/langgraph";
172
- * import { MemorySaver } from "@langchain/langgraph-checkpoint";
173
- * import { interrupt, Command } from "@langchain/langgraph";
174
- *
175
- * const composeEssay = task("compose", async (topic: string) => {
176
- * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation
177
- * return `An essay about ${topic}`;
178
- * });
179
- *
180
- * const reviewWorkflow = entrypoint({
181
- * name: "review",
182
- * checkpointer: new MemorySaver()
183
- * }, async (topic: string) => {
184
- * const essay = await composeEssay(topic);
185
- * const humanReview = await interrupt({
186
- * question: "Please provide a review",
187
- * essay
188
- * });
189
- * return {
190
- * essay,
191
- * review: humanReview
192
- * };
193
- * });
194
- *
195
- * // Example configuration for the workflow
196
- * const config = {
197
- * configurable: {
198
- * thread_id: "some_thread"
199
- * }
200
- * };
201
- *
202
- * // Topic for the essay
203
- * const topic = "cats";
204
- *
205
- * // Stream the workflow to generate the essay and await human review
206
- * for await (const result of reviewWorkflow.stream(topic, config)) {
207
- * console.log(result);
208
- * }
209
- *
210
- * // Example human review provided after the interrupt
211
- * const humanReview = "This essay is great.";
212
- *
213
- * // Resume the workflow with the provided human review
214
- * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {
215
- * console.log(result);
216
- * }
217
- * ```
218
- *
219
- * @example Accessing the previous return value
220
- * ```typescript
221
- * import { entrypoint, getPreviousState } from "@langchain/langgraph";
222
- * import { MemorySaver } from "@langchain/langgraph-checkpoint";
223
- *
224
- * const accumulator = entrypoint({
225
- * name: "accumulator",
226
- * checkpointer: new MemorySaver()
227
- * }, async (input: string) => {
228
- * const previous = getPreviousState<number>();
229
- * return previous !== undefined ? `${previous } ${input}` : input;
230
- * });
231
- *
232
- * const config = {
233
- * configurable: {
234
- * thread_id: "some_thread"
235
- * }
236
- * };
237
- * await accumulator.invoke("hello", config); // returns "hello"
238
- * await accumulator.invoke("world", config); // returns "hello world"
239
- * ```
240
- *
241
- * @example Using entrypoint.final to save a value
242
- * ```typescript
243
- * import { entrypoint, getPreviousState } from "@langchain/langgraph";
244
- * import { MemorySaver } from "@langchain/langgraph-checkpoint";
245
- *
246
- * const myWorkflow = entrypoint({
247
- * name: "accumulator",
248
- * checkpointer: new MemorySaver()
249
- * }, async (num: number) => {
250
- * const previous = getPreviousState<number>();
251
- *
252
- * // This will return the previous value to the caller, saving
253
- * // 2 * num to the checkpoint, which will be used in the next invocation
254
- * // for the `previous` parameter.
255
- * return entrypoint.final({
256
- * value: previous ?? 0,
257
- * save: 2 * num
258
- * });
259
- * });
260
- *
261
- * const config = {
262
- * configurable: {
263
- * thread_id: "some_thread"
264
- * }
265
- * };
266
- *
267
- * await myWorkflow.invoke(3, config); // 0 (previous was undefined)
268
- * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)
269
- * ```
270
- * @category Functional API
271
- */
272
- declare const entrypoint: EntrypointFunction;
273
- /**
274
- * A helper utility function for use with the functional API that returns the previous
275
- * state from the checkpoint from the last invocation of the current thread.
276
- *
277
- * This function allows workflows to access state that was saved in previous runs
278
- * using {@link entrypoint.final}.
279
- *
280
- * @typeParam StateT - The type of the state that was previously saved
281
- * @returns The previous saved state from the last invocation of the current thread
282
- *
283
- * @example
284
- * ```typescript
285
- * const previousState = getPreviousState<{ counter: number }>();
286
- * const newCount = (previousState?.counter ?? 0) + 1;
287
- * ```
288
- * @category Functional API
289
- */
290
- declare function getPreviousState<StateT>(): StateT;
291
- //#endregion
292
- export { EntrypointOptions, TaskOptions, entrypoint, getPreviousState, task };
293
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":["BaseCache","BaseCheckpointSaver","BaseStore","Pregel","PregelNode","END","PREVIOUS","START","EphemeralValue","CachePolicy","RetryPolicy","LastValue","EntrypointFinal","EntrypointReturnT","EntrypointFinalSaveT","EntrypointFunc","TaskFunc","TaskOptions","task","ArgsT","OutputT","Promise","EntrypointOptions","EntrypointFunction","InputT","Record","Awaited","ValueT","SaveT","entrypoint","getPreviousState","StateT"],"sources":["../../src/func/index.d.ts"],"sourcesContent":["import { BaseCache, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { Pregel } from \"../pregel/index.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { END, PREVIOUS, START } from \"../constants.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport type { CachePolicy, RetryPolicy } from \"../pregel/utils/index.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nimport { EntrypointFinal, EntrypointReturnT, EntrypointFinalSaveT, EntrypointFunc, TaskFunc } from \"./types.js\";\n/**\n * Options for the {@link task} function\n */\nexport interface TaskOptions {\n /**\n * The name of the task, analogous to the node name in {@link StateGraph}.\n */\n name: string;\n /**\n * The retry policy for the task. Configures how many times and under what conditions\n * the task should be retried if it fails.\n */\n retry?: RetryPolicy;\n /**\n * The cache policy for the task. Configures how the task should be cached.\n */\n cachePolicy?: CachePolicy;\n}\n/**\n * Define a LangGraph task using the `task` function.\n *\n * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.\n * A task can be called like a regular function with the following differences:\n *\n * - When a checkpointer is enabled, the function inputs and outputs must be serializable.\n * - The wrapped function can only be called from within an entrypoint or StateGraph.\n * - Calling the function produces a promise. This makes it easy to parallelize tasks.\n *\n * @typeParam ArgsT - The type of arguments the task function accepts\n * @typeParam OutputT - The type of value the task function returns\n * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task\n * @param func - The function that executes this task\n * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise\n *\n * @example basic example\n * ```typescript\n * const addOne = task(\"add\", async (a: number) => a + 1);\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n *\n * // Call the entrypoint\n * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]\n * ```\n *\n * @example using a retry policy\n * ```typescript\n * const addOne = task({\n * name: \"add\",\n * retry: { maxAttempts: 3 }\n * },\n * async (a: number) => a + 1\n * );\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n * ```\n * @category Functional API\n */\nexport declare function task<ArgsT extends unknown[], OutputT>(optionsOrName: TaskOptions | string, func: TaskFunc<ArgsT, OutputT>): (...args: ArgsT) => Promise<OutputT>;\n/**\n * Options for the {@link entrypoint} function\n */\nexport type EntrypointOptions = {\n /**\n * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.\n * This name is used for logging, debugging, and checkpoint identification.\n */\n name: string;\n /**\n * The checkpointer for the {@link entrypoint}. Used to save and restore state between\n * invocations of the workflow.\n */\n checkpointer?: BaseCheckpointSaver;\n /**\n * The store for the {@link entrypoint}. Used to persist data across workflow runs.\n */\n store?: BaseStore;\n /**\n * The cache for the {@link entrypoint}. Used to cache values between workflow runs.\n */\n cache?: BaseCache;\n};\n/**\n * Type declaration for the entrypoint function with its properties\n * @category Functional API\n */\nexport interface EntrypointFunction {\n <InputT, OutputT>(optionsOrName: EntrypointOptions | string, func: EntrypointFunc<InputT, OutputT>): Pregel<Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n }, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>, \n // Because the update type is an return type union of tasks + entrypoint,\n // thus we can't type it properly.\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Awaited<EntrypointReturnT<OutputT>>>;\n /**\n * A helper utility for use with the functional API that returns a value to the caller,\n * as well as a separate state value to persist to the checkpoint. This allows workflows\n * to maintain state between runs while returning different values to the caller.\n *\n * @typeParam ValueT - The type of the value to return to the caller\n * @typeParam SaveT - The type of the state to save to the checkpoint\n * @param options.value - The value to return to the caller\n * @param options.save - The value to save to the checkpoint\n * @returns An object with the value and save properties\n *\n * @example\n * ```typescript\n * return entrypoint.final({\n * value: \"result for caller\",\n * save: { counter: currentCount + 1 }\n * });\n * ```\n */\n final<ValueT, SaveT>(options: {\n value?: ValueT;\n save?: SaveT;\n }): EntrypointFinal<ValueT, SaveT>;\n}\n/**\n * Define a LangGraph workflow using the `entrypoint` function.\n *\n * ### Function signature\n *\n * The wrapped function must accept at most **two parameters**. The first parameter\n * is the input to the function. The second (optional) parameter is a\n * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to\n * the function, you can pass them as an object.\n *\n * ### Helper functions\n *\n * #### Streaming\n * To write data to the \"custom\" stream, use the {@link getWriter} function, or the\n * {@link LangGraphRunnableConfig.writer} property.\n *\n * #### State management\n * The {@link getPreviousState} function can be used to access the previous state\n * that was returned from the last invocation of the entrypoint on the same thread id.\n *\n * If you wish to save state other than the return value, you can use the\n * {@link entrypoint.final} function.\n *\n * @typeParam InputT - The type of input the entrypoint accepts\n * @typeParam OutputT - The type of output the entrypoint produces\n * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint\n * @param func - The function that executes this entrypoint\n * @returns A {@link Pregel} instance that can be run to execute the workflow\n *\n * @example Using entrypoint and tasks\n * ```typescript\n * import { task, entrypoint } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n * import { interrupt, Command } from \"@langchain/langgraph\";\n *\n * const composeEssay = task(\"compose\", async (topic: string) => {\n * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation\n * return `An essay about ${topic}`;\n * });\n *\n * const reviewWorkflow = entrypoint({\n * name: \"review\",\n * checkpointer: new MemorySaver()\n * }, async (topic: string) => {\n * const essay = await composeEssay(topic);\n * const humanReview = await interrupt({\n * question: \"Please provide a review\",\n * essay\n * });\n * return {\n * essay,\n * review: humanReview\n * };\n * });\n *\n * // Example configuration for the workflow\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * // Topic for the essay\n * const topic = \"cats\";\n *\n * // Stream the workflow to generate the essay and await human review\n * for await (const result of reviewWorkflow.stream(topic, config)) {\n * console.log(result);\n * }\n *\n * // Example human review provided after the interrupt\n * const humanReview = \"This essay is great.\";\n *\n * // Resume the workflow with the provided human review\n * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {\n * console.log(result);\n * }\n * ```\n *\n * @example Accessing the previous return value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const accumulator = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (input: string) => {\n * const previous = getPreviousState<number>();\n * return previous !== undefined ? `${previous } ${input}` : input;\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n * await accumulator.invoke(\"hello\", config); // returns \"hello\"\n * await accumulator.invoke(\"world\", config); // returns \"hello world\"\n * ```\n *\n * @example Using entrypoint.final to save a value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const myWorkflow = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (num: number) => {\n * const previous = getPreviousState<number>();\n *\n * // This will return the previous value to the caller, saving\n * // 2 * num to the checkpoint, which will be used in the next invocation\n * // for the `previous` parameter.\n * return entrypoint.final({\n * value: previous ?? 0,\n * save: 2 * num\n * });\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * await myWorkflow.invoke(3, config); // 0 (previous was undefined)\n * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)\n * ```\n * @category Functional API\n */\nexport declare const entrypoint: EntrypointFunction;\n/**\n * A helper utility function for use with the functional API that returns the previous\n * state from the checkpoint from the last invocation of the current thread.\n *\n * This function allows workflows to access state that was saved in previous runs\n * using {@link entrypoint.final}.\n *\n * @typeParam StateT - The type of the state that was previously saved\n * @returns The previous saved state from the last invocation of the current thread\n *\n * @example\n * ```typescript\n * const previousState = getPreviousState<{ counter: number }>();\n * const newCount = (previousState?.counter ?? 0) + 1;\n * ```\n * @category Functional API\n */\nexport declare function getPreviousState<StateT>(): StateT;\n"],"mappings":";;;;;;;;;;;;;AAWA;AAA4B,UAAXiB,WAAAA,CAAW;;;;EA8DJC,IAAAA,EAAAA,MAAI;EAAA;;;;OAA8EF,CAAAA,EArD9FN,WAqD8FM;;;;gBAjDxFP;AAqDlB;;;;;;AAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsKA;AAkBA;;;;;iBApNwBS,sDAAsDD,4BAA4BD,SAASG,OAAOC,qBAAqBD,UAAUE,QAAQD;;;;KAIrJE,iBAAAA;;;;;;;;;;iBAUOrB;;;;UAIPC;;;;UAIAF;;;;;;UAMKuB,kBAAAA;mCACoBD,kCAAkCP,eAAeS,QAAQJ,WAAWjB,OAAOsB,eAAerB,WAAWoB,QAAQX,kBAAkBO;KAC3Jb,KAAAA,GAAQC,eAAegB;KACvBnB,GAAAA,GAAMM,UAAUE,kBAAkBO;KAClCd,QAAAA,GAAWK,UAAUG,qBAAqBM;KAC5CK,yBAAyBD,QAAQX,kBAAkBO;;;;;EAItDM,QAAQb,kBAAkBO;;;;;;;;;;;;;;;;;;;;;YAqBdO;WACDC;MACPhB,gBAAgBe,QAAQC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsIXC,YAAYN;;;;;;;;;;;;;;;;;;iBAkBTO,4BAA4BC"}
@@ -1,293 +0,0 @@
1
- import { LastValue } from "../channels/last_value.js";
2
- import { EphemeralValue } from "../channels/ephemeral_value.js";
3
- import { CachePolicy, RetryPolicy } from "../pregel/utils/index.js";
4
- import { PregelNode } from "../pregel/read.js";
5
- import { END, PREVIOUS, START } from "../constants.js";
6
- import { Pregel } from "../pregel/index.js";
7
- import { EntrypointFinal, EntrypointFinalSaveT, EntrypointFunc, EntrypointReturnT, TaskFunc } from "./types.js";
8
- import { BaseCache, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
9
-
10
- //#region src/func/index.d.ts
11
-
12
- /**
13
- * Options for the {@link task} function
14
- */
15
- interface TaskOptions {
16
- /**
17
- * The name of the task, analogous to the node name in {@link StateGraph}.
18
- */
19
- name: string;
20
- /**
21
- * The retry policy for the task. Configures how many times and under what conditions
22
- * the task should be retried if it fails.
23
- */
24
- retry?: RetryPolicy;
25
- /**
26
- * The cache policy for the task. Configures how the task should be cached.
27
- */
28
- cachePolicy?: CachePolicy;
29
- }
30
- /**
31
- * Define a LangGraph task using the `task` function.
32
- *
33
- * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.
34
- * A task can be called like a regular function with the following differences:
35
- *
36
- * - When a checkpointer is enabled, the function inputs and outputs must be serializable.
37
- * - The wrapped function can only be called from within an entrypoint or StateGraph.
38
- * - Calling the function produces a promise. This makes it easy to parallelize tasks.
39
- *
40
- * @typeParam ArgsT - The type of arguments the task function accepts
41
- * @typeParam OutputT - The type of value the task function returns
42
- * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task
43
- * @param func - The function that executes this task
44
- * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise
45
- *
46
- * @example basic example
47
- * ```typescript
48
- * const addOne = task("add", async (a: number) => a + 1);
49
- *
50
- * const workflow = entrypoint("example", async (numbers: number[]) => {
51
- * const promises = numbers.map(n => addOne(n));
52
- * const results = await Promise.all(promises);
53
- * return results;
54
- * });
55
- *
56
- * // Call the entrypoint
57
- * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]
58
- * ```
59
- *
60
- * @example using a retry policy
61
- * ```typescript
62
- * const addOne = task({
63
- * name: "add",
64
- * retry: { maxAttempts: 3 }
65
- * },
66
- * async (a: number) => a + 1
67
- * );
68
- *
69
- * const workflow = entrypoint("example", async (numbers: number[]) => {
70
- * const promises = numbers.map(n => addOne(n));
71
- * const results = await Promise.all(promises);
72
- * return results;
73
- * });
74
- * ```
75
- * @category Functional API
76
- */
77
- declare function task<ArgsT extends unknown[], OutputT>(optionsOrName: TaskOptions | string, func: TaskFunc<ArgsT, OutputT>): (...args: ArgsT) => Promise<OutputT>;
78
- /**
79
- * Options for the {@link entrypoint} function
80
- */
81
- type EntrypointOptions = {
82
- /**
83
- * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.
84
- * This name is used for logging, debugging, and checkpoint identification.
85
- */
86
- name: string;
87
- /**
88
- * The checkpointer for the {@link entrypoint}. Used to save and restore state between
89
- * invocations of the workflow.
90
- */
91
- checkpointer?: BaseCheckpointSaver;
92
- /**
93
- * The store for the {@link entrypoint}. Used to persist data across workflow runs.
94
- */
95
- store?: BaseStore;
96
- /**
97
- * The cache for the {@link entrypoint}. Used to cache values between workflow runs.
98
- */
99
- cache?: BaseCache;
100
- };
101
- /**
102
- * Type declaration for the entrypoint function with its properties
103
- * @category Functional API
104
- */
105
- interface EntrypointFunction {
106
- <InputT, OutputT>(optionsOrName: EntrypointOptions | string, func: EntrypointFunc<InputT, OutputT>): Pregel<Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, {
107
- [START]: EphemeralValue<InputT>;
108
- [END]: LastValue<EntrypointReturnT<OutputT>>;
109
- [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;
110
- }, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>,
111
- // Because the update type is an return type union of tasks + entrypoint,
112
- // thus we can't type it properly.
113
- any,
114
- // eslint-disable-line @typescript-eslint/no-explicit-any
115
- Awaited<EntrypointReturnT<OutputT>>>;
116
- /**
117
- * A helper utility for use with the functional API that returns a value to the caller,
118
- * as well as a separate state value to persist to the checkpoint. This allows workflows
119
- * to maintain state between runs while returning different values to the caller.
120
- *
121
- * @typeParam ValueT - The type of the value to return to the caller
122
- * @typeParam SaveT - The type of the state to save to the checkpoint
123
- * @param options.value - The value to return to the caller
124
- * @param options.save - The value to save to the checkpoint
125
- * @returns An object with the value and save properties
126
- *
127
- * @example
128
- * ```typescript
129
- * return entrypoint.final({
130
- * value: "result for caller",
131
- * save: { counter: currentCount + 1 }
132
- * });
133
- * ```
134
- */
135
- final<ValueT, SaveT>(options: {
136
- value?: ValueT;
137
- save?: SaveT;
138
- }): EntrypointFinal<ValueT, SaveT>;
139
- }
140
- /**
141
- * Define a LangGraph workflow using the `entrypoint` function.
142
- *
143
- * ### Function signature
144
- *
145
- * The wrapped function must accept at most **two parameters**. The first parameter
146
- * is the input to the function. The second (optional) parameter is a
147
- * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to
148
- * the function, you can pass them as an object.
149
- *
150
- * ### Helper functions
151
- *
152
- * #### Streaming
153
- * To write data to the "custom" stream, use the {@link getWriter} function, or the
154
- * {@link LangGraphRunnableConfig.writer} property.
155
- *
156
- * #### State management
157
- * The {@link getPreviousState} function can be used to access the previous state
158
- * that was returned from the last invocation of the entrypoint on the same thread id.
159
- *
160
- * If you wish to save state other than the return value, you can use the
161
- * {@link entrypoint.final} function.
162
- *
163
- * @typeParam InputT - The type of input the entrypoint accepts
164
- * @typeParam OutputT - The type of output the entrypoint produces
165
- * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint
166
- * @param func - The function that executes this entrypoint
167
- * @returns A {@link Pregel} instance that can be run to execute the workflow
168
- *
169
- * @example Using entrypoint and tasks
170
- * ```typescript
171
- * import { task, entrypoint } from "@langchain/langgraph";
172
- * import { MemorySaver } from "@langchain/langgraph-checkpoint";
173
- * import { interrupt, Command } from "@langchain/langgraph";
174
- *
175
- * const composeEssay = task("compose", async (topic: string) => {
176
- * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation
177
- * return `An essay about ${topic}`;
178
- * });
179
- *
180
- * const reviewWorkflow = entrypoint({
181
- * name: "review",
182
- * checkpointer: new MemorySaver()
183
- * }, async (topic: string) => {
184
- * const essay = await composeEssay(topic);
185
- * const humanReview = await interrupt({
186
- * question: "Please provide a review",
187
- * essay
188
- * });
189
- * return {
190
- * essay,
191
- * review: humanReview
192
- * };
193
- * });
194
- *
195
- * // Example configuration for the workflow
196
- * const config = {
197
- * configurable: {
198
- * thread_id: "some_thread"
199
- * }
200
- * };
201
- *
202
- * // Topic for the essay
203
- * const topic = "cats";
204
- *
205
- * // Stream the workflow to generate the essay and await human review
206
- * for await (const result of reviewWorkflow.stream(topic, config)) {
207
- * console.log(result);
208
- * }
209
- *
210
- * // Example human review provided after the interrupt
211
- * const humanReview = "This essay is great.";
212
- *
213
- * // Resume the workflow with the provided human review
214
- * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {
215
- * console.log(result);
216
- * }
217
- * ```
218
- *
219
- * @example Accessing the previous return value
220
- * ```typescript
221
- * import { entrypoint, getPreviousState } from "@langchain/langgraph";
222
- * import { MemorySaver } from "@langchain/langgraph-checkpoint";
223
- *
224
- * const accumulator = entrypoint({
225
- * name: "accumulator",
226
- * checkpointer: new MemorySaver()
227
- * }, async (input: string) => {
228
- * const previous = getPreviousState<number>();
229
- * return previous !== undefined ? `${previous } ${input}` : input;
230
- * });
231
- *
232
- * const config = {
233
- * configurable: {
234
- * thread_id: "some_thread"
235
- * }
236
- * };
237
- * await accumulator.invoke("hello", config); // returns "hello"
238
- * await accumulator.invoke("world", config); // returns "hello world"
239
- * ```
240
- *
241
- * @example Using entrypoint.final to save a value
242
- * ```typescript
243
- * import { entrypoint, getPreviousState } from "@langchain/langgraph";
244
- * import { MemorySaver } from "@langchain/langgraph-checkpoint";
245
- *
246
- * const myWorkflow = entrypoint({
247
- * name: "accumulator",
248
- * checkpointer: new MemorySaver()
249
- * }, async (num: number) => {
250
- * const previous = getPreviousState<number>();
251
- *
252
- * // This will return the previous value to the caller, saving
253
- * // 2 * num to the checkpoint, which will be used in the next invocation
254
- * // for the `previous` parameter.
255
- * return entrypoint.final({
256
- * value: previous ?? 0,
257
- * save: 2 * num
258
- * });
259
- * });
260
- *
261
- * const config = {
262
- * configurable: {
263
- * thread_id: "some_thread"
264
- * }
265
- * };
266
- *
267
- * await myWorkflow.invoke(3, config); // 0 (previous was undefined)
268
- * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)
269
- * ```
270
- * @category Functional API
271
- */
272
- declare const entrypoint: EntrypointFunction;
273
- /**
274
- * A helper utility function for use with the functional API that returns the previous
275
- * state from the checkpoint from the last invocation of the current thread.
276
- *
277
- * This function allows workflows to access state that was saved in previous runs
278
- * using {@link entrypoint.final}.
279
- *
280
- * @typeParam StateT - The type of the state that was previously saved
281
- * @returns The previous saved state from the last invocation of the current thread
282
- *
283
- * @example
284
- * ```typescript
285
- * const previousState = getPreviousState<{ counter: number }>();
286
- * const newCount = (previousState?.counter ?? 0) + 1;
287
- * ```
288
- * @category Functional API
289
- */
290
- declare function getPreviousState<StateT>(): StateT;
291
- //#endregion
292
- export { EntrypointOptions, TaskOptions, entrypoint, getPreviousState, task };
293
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":["BaseCache","BaseCheckpointSaver","BaseStore","Pregel","PregelNode","END","PREVIOUS","START","EphemeralValue","CachePolicy","RetryPolicy","LastValue","EntrypointFinal","EntrypointReturnT","EntrypointFinalSaveT","EntrypointFunc","TaskFunc","TaskOptions","task","ArgsT","OutputT","Promise","EntrypointOptions","EntrypointFunction","InputT","Record","Awaited","ValueT","SaveT","entrypoint","getPreviousState","StateT"],"sources":["../../src/func/index.d.ts"],"sourcesContent":["import { BaseCache, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { Pregel } from \"../pregel/index.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { END, PREVIOUS, START } from \"../constants.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport type { CachePolicy, RetryPolicy } from \"../pregel/utils/index.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nimport { EntrypointFinal, EntrypointReturnT, EntrypointFinalSaveT, EntrypointFunc, TaskFunc } from \"./types.js\";\n/**\n * Options for the {@link task} function\n */\nexport interface TaskOptions {\n /**\n * The name of the task, analogous to the node name in {@link StateGraph}.\n */\n name: string;\n /**\n * The retry policy for the task. Configures how many times and under what conditions\n * the task should be retried if it fails.\n */\n retry?: RetryPolicy;\n /**\n * The cache policy for the task. Configures how the task should be cached.\n */\n cachePolicy?: CachePolicy;\n}\n/**\n * Define a LangGraph task using the `task` function.\n *\n * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.\n * A task can be called like a regular function with the following differences:\n *\n * - When a checkpointer is enabled, the function inputs and outputs must be serializable.\n * - The wrapped function can only be called from within an entrypoint or StateGraph.\n * - Calling the function produces a promise. This makes it easy to parallelize tasks.\n *\n * @typeParam ArgsT - The type of arguments the task function accepts\n * @typeParam OutputT - The type of value the task function returns\n * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task\n * @param func - The function that executes this task\n * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise\n *\n * @example basic example\n * ```typescript\n * const addOne = task(\"add\", async (a: number) => a + 1);\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n *\n * // Call the entrypoint\n * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]\n * ```\n *\n * @example using a retry policy\n * ```typescript\n * const addOne = task({\n * name: \"add\",\n * retry: { maxAttempts: 3 }\n * },\n * async (a: number) => a + 1\n * );\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n * ```\n * @category Functional API\n */\nexport declare function task<ArgsT extends unknown[], OutputT>(optionsOrName: TaskOptions | string, func: TaskFunc<ArgsT, OutputT>): (...args: ArgsT) => Promise<OutputT>;\n/**\n * Options for the {@link entrypoint} function\n */\nexport type EntrypointOptions = {\n /**\n * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.\n * This name is used for logging, debugging, and checkpoint identification.\n */\n name: string;\n /**\n * The checkpointer for the {@link entrypoint}. Used to save and restore state between\n * invocations of the workflow.\n */\n checkpointer?: BaseCheckpointSaver;\n /**\n * The store for the {@link entrypoint}. Used to persist data across workflow runs.\n */\n store?: BaseStore;\n /**\n * The cache for the {@link entrypoint}. Used to cache values between workflow runs.\n */\n cache?: BaseCache;\n};\n/**\n * Type declaration for the entrypoint function with its properties\n * @category Functional API\n */\nexport interface EntrypointFunction {\n <InputT, OutputT>(optionsOrName: EntrypointOptions | string, func: EntrypointFunc<InputT, OutputT>): Pregel<Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n }, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>, \n // Because the update type is an return type union of tasks + entrypoint,\n // thus we can't type it properly.\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Awaited<EntrypointReturnT<OutputT>>>;\n /**\n * A helper utility for use with the functional API that returns a value to the caller,\n * as well as a separate state value to persist to the checkpoint. This allows workflows\n * to maintain state between runs while returning different values to the caller.\n *\n * @typeParam ValueT - The type of the value to return to the caller\n * @typeParam SaveT - The type of the state to save to the checkpoint\n * @param options.value - The value to return to the caller\n * @param options.save - The value to save to the checkpoint\n * @returns An object with the value and save properties\n *\n * @example\n * ```typescript\n * return entrypoint.final({\n * value: \"result for caller\",\n * save: { counter: currentCount + 1 }\n * });\n * ```\n */\n final<ValueT, SaveT>(options: {\n value?: ValueT;\n save?: SaveT;\n }): EntrypointFinal<ValueT, SaveT>;\n}\n/**\n * Define a LangGraph workflow using the `entrypoint` function.\n *\n * ### Function signature\n *\n * The wrapped function must accept at most **two parameters**. The first parameter\n * is the input to the function. The second (optional) parameter is a\n * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to\n * the function, you can pass them as an object.\n *\n * ### Helper functions\n *\n * #### Streaming\n * To write data to the \"custom\" stream, use the {@link getWriter} function, or the\n * {@link LangGraphRunnableConfig.writer} property.\n *\n * #### State management\n * The {@link getPreviousState} function can be used to access the previous state\n * that was returned from the last invocation of the entrypoint on the same thread id.\n *\n * If you wish to save state other than the return value, you can use the\n * {@link entrypoint.final} function.\n *\n * @typeParam InputT - The type of input the entrypoint accepts\n * @typeParam OutputT - The type of output the entrypoint produces\n * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint\n * @param func - The function that executes this entrypoint\n * @returns A {@link Pregel} instance that can be run to execute the workflow\n *\n * @example Using entrypoint and tasks\n * ```typescript\n * import { task, entrypoint } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n * import { interrupt, Command } from \"@langchain/langgraph\";\n *\n * const composeEssay = task(\"compose\", async (topic: string) => {\n * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation\n * return `An essay about ${topic}`;\n * });\n *\n * const reviewWorkflow = entrypoint({\n * name: \"review\",\n * checkpointer: new MemorySaver()\n * }, async (topic: string) => {\n * const essay = await composeEssay(topic);\n * const humanReview = await interrupt({\n * question: \"Please provide a review\",\n * essay\n * });\n * return {\n * essay,\n * review: humanReview\n * };\n * });\n *\n * // Example configuration for the workflow\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * // Topic for the essay\n * const topic = \"cats\";\n *\n * // Stream the workflow to generate the essay and await human review\n * for await (const result of reviewWorkflow.stream(topic, config)) {\n * console.log(result);\n * }\n *\n * // Example human review provided after the interrupt\n * const humanReview = \"This essay is great.\";\n *\n * // Resume the workflow with the provided human review\n * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {\n * console.log(result);\n * }\n * ```\n *\n * @example Accessing the previous return value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const accumulator = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (input: string) => {\n * const previous = getPreviousState<number>();\n * return previous !== undefined ? `${previous } ${input}` : input;\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n * await accumulator.invoke(\"hello\", config); // returns \"hello\"\n * await accumulator.invoke(\"world\", config); // returns \"hello world\"\n * ```\n *\n * @example Using entrypoint.final to save a value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const myWorkflow = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (num: number) => {\n * const previous = getPreviousState<number>();\n *\n * // This will return the previous value to the caller, saving\n * // 2 * num to the checkpoint, which will be used in the next invocation\n * // for the `previous` parameter.\n * return entrypoint.final({\n * value: previous ?? 0,\n * save: 2 * num\n * });\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * await myWorkflow.invoke(3, config); // 0 (previous was undefined)\n * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)\n * ```\n * @category Functional API\n */\nexport declare const entrypoint: EntrypointFunction;\n/**\n * A helper utility function for use with the functional API that returns the previous\n * state from the checkpoint from the last invocation of the current thread.\n *\n * This function allows workflows to access state that was saved in previous runs\n * using {@link entrypoint.final}.\n *\n * @typeParam StateT - The type of the state that was previously saved\n * @returns The previous saved state from the last invocation of the current thread\n *\n * @example\n * ```typescript\n * const previousState = getPreviousState<{ counter: number }>();\n * const newCount = (previousState?.counter ?? 0) + 1;\n * ```\n * @category Functional API\n */\nexport declare function getPreviousState<StateT>(): StateT;\n"],"mappings":";;;;;;;;;;;;;AAWA;AAA4B,UAAXiB,WAAAA,CAAW;;;;EA8DJC,IAAAA,EAAAA,MAAI;EAAA;;;;OAA8EF,CAAAA,EArD9FN,WAqD8FM;;;;gBAjDxFP;AAqDlB;;;;;;AAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsKA;AAkBA;;;;;iBApNwBS,sDAAsDD,4BAA4BD,SAASG,OAAOC,qBAAqBD,UAAUE,QAAQD;;;;KAIrJE,iBAAAA;;;;;;;;;;iBAUOrB;;;;UAIPC;;;;UAIAF;;;;;;UAMKuB,kBAAAA;mCACoBD,kCAAkCP,eAAeS,QAAQJ,WAAWjB,OAAOsB,eAAerB,WAAWoB,QAAQX,kBAAkBO;KAC3Jb,KAAAA,GAAQC,eAAegB;KACvBnB,GAAAA,GAAMM,UAAUE,kBAAkBO;KAClCd,QAAAA,GAAWK,UAAUG,qBAAqBM;KAC5CK,yBAAyBD,QAAQX,kBAAkBO;;;;;EAItDM,QAAQb,kBAAkBO;;;;;;;;;;;;;;;;;;;;;YAqBdO;WACDC;MACPhB,gBAAgBe,QAAQC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsIXC,YAAYN;;;;;;;;;;;;;;;;;;iBAkBTO,4BAA4BC"}