@langchain/langgraph 1.0.7 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/dist/channels/any_value.cjs.map +1 -1
  2. package/dist/channels/any_value.d.cts +0 -1
  3. package/dist/channels/any_value.d.cts.map +1 -1
  4. package/dist/channels/any_value.d.ts +0 -1
  5. package/dist/channels/any_value.d.ts.map +1 -1
  6. package/dist/channels/any_value.js.map +1 -1
  7. package/dist/channels/base.cjs +2 -3
  8. package/dist/channels/base.cjs.map +1 -1
  9. package/dist/channels/base.d.cts.map +1 -1
  10. package/dist/channels/base.d.ts.map +1 -1
  11. package/dist/channels/base.js.map +1 -1
  12. package/dist/channels/binop.cjs.map +1 -1
  13. package/dist/channels/binop.d.cts.map +1 -1
  14. package/dist/channels/binop.d.ts.map +1 -1
  15. package/dist/channels/binop.js.map +1 -1
  16. package/dist/channels/dynamic_barrier_value.cjs +0 -1
  17. package/dist/channels/dynamic_barrier_value.cjs.map +1 -1
  18. package/dist/channels/dynamic_barrier_value.d.cts +1 -3
  19. package/dist/channels/dynamic_barrier_value.d.cts.map +1 -1
  20. package/dist/channels/dynamic_barrier_value.d.ts +1 -3
  21. package/dist/channels/dynamic_barrier_value.d.ts.map +1 -1
  22. package/dist/channels/dynamic_barrier_value.js +0 -1
  23. package/dist/channels/dynamic_barrier_value.js.map +1 -1
  24. package/dist/channels/ephemeral_value.cjs.map +1 -1
  25. package/dist/channels/ephemeral_value.d.cts +0 -1
  26. package/dist/channels/ephemeral_value.d.cts.map +1 -1
  27. package/dist/channels/ephemeral_value.d.ts +0 -1
  28. package/dist/channels/ephemeral_value.d.ts.map +1 -1
  29. package/dist/channels/ephemeral_value.js.map +1 -1
  30. package/dist/channels/last_value.cjs.map +1 -1
  31. package/dist/channels/last_value.d.cts +0 -2
  32. package/dist/channels/last_value.d.cts.map +1 -1
  33. package/dist/channels/last_value.d.ts +0 -2
  34. package/dist/channels/last_value.d.ts.map +1 -1
  35. package/dist/channels/last_value.js.map +1 -1
  36. package/dist/channels/named_barrier_value.cjs +0 -2
  37. package/dist/channels/named_barrier_value.cjs.map +1 -1
  38. package/dist/channels/named_barrier_value.d.cts +2 -4
  39. package/dist/channels/named_barrier_value.d.cts.map +1 -1
  40. package/dist/channels/named_barrier_value.d.ts +2 -4
  41. package/dist/channels/named_barrier_value.d.ts.map +1 -1
  42. package/dist/channels/named_barrier_value.js +0 -2
  43. package/dist/channels/named_barrier_value.js.map +1 -1
  44. package/dist/channels/topic.cjs.map +1 -1
  45. package/dist/channels/topic.d.cts.map +1 -1
  46. package/dist/channels/topic.d.ts.map +1 -1
  47. package/dist/channels/topic.js.map +1 -1
  48. package/dist/constants.cjs.map +1 -1
  49. package/dist/constants.d.cts +2 -6
  50. package/dist/constants.d.cts.map +1 -1
  51. package/dist/constants.d.ts +2 -6
  52. package/dist/constants.d.ts.map +1 -1
  53. package/dist/constants.js.map +1 -1
  54. package/dist/errors.cjs.map +1 -1
  55. package/dist/errors.d.cts +0 -4
  56. package/dist/errors.d.cts.map +1 -1
  57. package/dist/errors.d.ts +0 -4
  58. package/dist/errors.d.ts.map +1 -1
  59. package/dist/errors.js.map +1 -1
  60. package/dist/func/index.cjs +2 -4
  61. package/dist/func/index.cjs.map +1 -1
  62. package/dist/func/index.d.cts +1 -6
  63. package/dist/func/index.d.cts.map +1 -1
  64. package/dist/func/index.d.ts +1 -6
  65. package/dist/func/index.d.ts.map +1 -1
  66. package/dist/func/index.js +1 -2
  67. package/dist/func/index.js.map +1 -1
  68. package/dist/func/types.d.cts +2 -4
  69. package/dist/func/types.d.cts.map +1 -1
  70. package/dist/func/types.d.ts +2 -4
  71. package/dist/func/types.d.ts.map +1 -1
  72. package/dist/graph/annotation.cjs.map +1 -1
  73. package/dist/graph/annotation.d.cts.map +1 -1
  74. package/dist/graph/annotation.d.ts.map +1 -1
  75. package/dist/graph/annotation.js.map +1 -1
  76. package/dist/graph/graph.cjs +15 -18
  77. package/dist/graph/graph.cjs.map +1 -1
  78. package/dist/graph/graph.d.cts +4 -28
  79. package/dist/graph/graph.d.cts.map +1 -1
  80. package/dist/graph/graph.d.ts +4 -28
  81. package/dist/graph/graph.d.ts.map +1 -1
  82. package/dist/graph/graph.js +4 -6
  83. package/dist/graph/graph.js.map +1 -1
  84. package/dist/graph/message.cjs +8 -10
  85. package/dist/graph/message.cjs.map +1 -1
  86. package/dist/graph/message.d.cts +2 -2
  87. package/dist/graph/message.d.cts.map +1 -1
  88. package/dist/graph/message.d.ts +2 -2
  89. package/dist/graph/message.d.ts.map +1 -1
  90. package/dist/graph/message.js +3 -4
  91. package/dist/graph/message.js.map +1 -1
  92. package/dist/graph/messages_annotation.cjs +1 -2
  93. package/dist/graph/messages_annotation.cjs.map +1 -1
  94. package/dist/graph/messages_annotation.d.cts +5 -5
  95. package/dist/graph/messages_annotation.d.cts.map +1 -1
  96. package/dist/graph/messages_annotation.d.ts +5 -5
  97. package/dist/graph/messages_annotation.d.ts.map +1 -1
  98. package/dist/graph/messages_annotation.js.map +1 -1
  99. package/dist/graph/state.cjs +23 -30
  100. package/dist/graph/state.cjs.map +1 -1
  101. package/dist/graph/state.d.cts +2 -9
  102. package/dist/graph/state.d.cts.map +1 -1
  103. package/dist/graph/state.d.ts +2 -9
  104. package/dist/graph/state.d.ts.map +1 -1
  105. package/dist/graph/state.js +6 -12
  106. package/dist/graph/state.js.map +1 -1
  107. package/dist/graph/zod/meta.cjs +8 -9
  108. package/dist/graph/zod/meta.cjs.map +1 -1
  109. package/dist/graph/zod/meta.d.cts +0 -1
  110. package/dist/graph/zod/meta.d.cts.map +1 -1
  111. package/dist/graph/zod/meta.d.ts +0 -1
  112. package/dist/graph/zod/meta.d.ts.map +1 -1
  113. package/dist/graph/zod/meta.js.map +1 -1
  114. package/dist/graph/zod/plugin.cjs +4 -6
  115. package/dist/graph/zod/plugin.cjs.map +1 -1
  116. package/dist/graph/zod/plugin.js +1 -2
  117. package/dist/graph/zod/plugin.js.map +1 -1
  118. package/dist/graph/zod/schema.cjs +2 -3
  119. package/dist/graph/zod/schema.cjs.map +1 -1
  120. package/dist/graph/zod/schema.d.cts.map +1 -1
  121. package/dist/graph/zod/schema.d.ts.map +1 -1
  122. package/dist/graph/zod/schema.js.map +1 -1
  123. package/dist/graph/zod/zod-registry.cjs +3 -4
  124. package/dist/graph/zod/zod-registry.cjs.map +1 -1
  125. package/dist/graph/zod/zod-registry.d.cts +0 -2
  126. package/dist/graph/zod/zod-registry.d.cts.map +1 -1
  127. package/dist/graph/zod/zod-registry.d.ts +0 -2
  128. package/dist/graph/zod/zod-registry.d.ts.map +1 -1
  129. package/dist/graph/zod/zod-registry.js.map +1 -1
  130. package/dist/hash.cjs +4 -10
  131. package/dist/hash.cjs.map +1 -1
  132. package/dist/hash.js +4 -10
  133. package/dist/hash.js.map +1 -1
  134. package/dist/index.cjs +8 -9
  135. package/dist/index.cjs.map +1 -1
  136. package/dist/index.js.map +1 -1
  137. package/dist/interrupt.cjs +4 -7
  138. package/dist/interrupt.cjs.map +1 -1
  139. package/dist/interrupt.d.cts +1 -4
  140. package/dist/interrupt.d.cts.map +1 -1
  141. package/dist/interrupt.d.ts +1 -4
  142. package/dist/interrupt.d.ts.map +1 -1
  143. package/dist/interrupt.js +2 -4
  144. package/dist/interrupt.js.map +1 -1
  145. package/dist/prebuilt/agentName.cjs +14 -19
  146. package/dist/prebuilt/agentName.cjs.map +1 -1
  147. package/dist/prebuilt/agentName.js +6 -10
  148. package/dist/prebuilt/agentName.js.map +1 -1
  149. package/dist/prebuilt/agent_executor.cjs +4 -7
  150. package/dist/prebuilt/agent_executor.cjs.map +1 -1
  151. package/dist/prebuilt/agent_executor.d.cts +5 -5
  152. package/dist/prebuilt/agent_executor.d.cts.map +1 -1
  153. package/dist/prebuilt/agent_executor.d.ts +5 -5
  154. package/dist/prebuilt/agent_executor.d.ts.map +1 -1
  155. package/dist/prebuilt/agent_executor.js +4 -7
  156. package/dist/prebuilt/agent_executor.js.map +1 -1
  157. package/dist/prebuilt/chat_agent_executor.cjs +11 -17
  158. package/dist/prebuilt/chat_agent_executor.cjs.map +1 -1
  159. package/dist/prebuilt/chat_agent_executor.d.cts.map +1 -1
  160. package/dist/prebuilt/chat_agent_executor.d.ts.map +1 -1
  161. package/dist/prebuilt/chat_agent_executor.js +7 -12
  162. package/dist/prebuilt/chat_agent_executor.js.map +1 -1
  163. package/dist/prebuilt/interrupt.d.cts +0 -1
  164. package/dist/prebuilt/interrupt.d.cts.map +1 -1
  165. package/dist/prebuilt/interrupt.d.ts +0 -1
  166. package/dist/prebuilt/interrupt.d.ts.map +1 -1
  167. package/dist/prebuilt/react_agent_executor.cjs +35 -40
  168. package/dist/prebuilt/react_agent_executor.cjs.map +1 -1
  169. package/dist/prebuilt/react_agent_executor.d.cts +8 -27
  170. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
  171. package/dist/prebuilt/react_agent_executor.d.ts +8 -27
  172. package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
  173. package/dist/prebuilt/react_agent_executor.js +8 -12
  174. package/dist/prebuilt/react_agent_executor.js.map +1 -1
  175. package/dist/prebuilt/tool_executor.cjs +4 -9
  176. package/dist/prebuilt/tool_executor.cjs.map +1 -1
  177. package/dist/prebuilt/tool_executor.d.cts +0 -2
  178. package/dist/prebuilt/tool_executor.d.cts.map +1 -1
  179. package/dist/prebuilt/tool_executor.d.ts +0 -2
  180. package/dist/prebuilt/tool_executor.d.ts.map +1 -1
  181. package/dist/prebuilt/tool_executor.js +1 -5
  182. package/dist/prebuilt/tool_executor.js.map +1 -1
  183. package/dist/prebuilt/tool_node.cjs +7 -8
  184. package/dist/prebuilt/tool_node.cjs.map +1 -1
  185. package/dist/prebuilt/tool_node.d.cts +0 -2
  186. package/dist/prebuilt/tool_node.d.cts.map +1 -1
  187. package/dist/prebuilt/tool_node.d.ts +0 -2
  188. package/dist/prebuilt/tool_node.d.ts.map +1 -1
  189. package/dist/prebuilt/tool_node.js.map +1 -1
  190. package/dist/pregel/algo.cjs +33 -41
  191. package/dist/pregel/algo.cjs.map +1 -1
  192. package/dist/pregel/algo.d.cts.map +1 -1
  193. package/dist/pregel/algo.d.ts.map +1 -1
  194. package/dist/pregel/algo.js +22 -29
  195. package/dist/pregel/algo.js.map +1 -1
  196. package/dist/pregel/call.cjs +11 -14
  197. package/dist/pregel/call.cjs.map +1 -1
  198. package/dist/pregel/call.js +7 -9
  199. package/dist/pregel/call.js.map +1 -1
  200. package/dist/pregel/debug.cjs +6 -9
  201. package/dist/pregel/debug.cjs.map +1 -1
  202. package/dist/pregel/debug.js +6 -9
  203. package/dist/pregel/debug.js.map +1 -1
  204. package/dist/pregel/index.cjs +28 -35
  205. package/dist/pregel/index.cjs.map +1 -1
  206. package/dist/pregel/index.d.cts +6 -54
  207. package/dist/pregel/index.d.cts.map +1 -1
  208. package/dist/pregel/index.d.ts +6 -54
  209. package/dist/pregel/index.d.ts.map +1 -1
  210. package/dist/pregel/index.js +10 -16
  211. package/dist/pregel/index.js.map +1 -1
  212. package/dist/pregel/io.cjs.map +1 -1
  213. package/dist/pregel/io.js.map +1 -1
  214. package/dist/pregel/loop.cjs +9 -12
  215. package/dist/pregel/loop.cjs.map +1 -1
  216. package/dist/pregel/loop.js +2 -4
  217. package/dist/pregel/loop.js.map +1 -1
  218. package/dist/pregel/messages.cjs +13 -14
  219. package/dist/pregel/messages.cjs.map +1 -1
  220. package/dist/pregel/messages.js.map +1 -1
  221. package/dist/pregel/read.cjs +7 -8
  222. package/dist/pregel/read.cjs.map +1 -1
  223. package/dist/pregel/read.d.cts +0 -6
  224. package/dist/pregel/read.d.cts.map +1 -1
  225. package/dist/pregel/read.d.ts +0 -6
  226. package/dist/pregel/read.d.ts.map +1 -1
  227. package/dist/pregel/read.js +1 -1
  228. package/dist/pregel/read.js.map +1 -1
  229. package/dist/pregel/remote.cjs +24 -32
  230. package/dist/pregel/remote.cjs.map +1 -1
  231. package/dist/pregel/remote.d.cts +1 -6
  232. package/dist/pregel/remote.d.cts.map +1 -1
  233. package/dist/pregel/remote.d.ts +1 -6
  234. package/dist/pregel/remote.d.ts.map +1 -1
  235. package/dist/pregel/remote.js +12 -19
  236. package/dist/pregel/remote.js.map +1 -1
  237. package/dist/pregel/retry.cjs +1 -2
  238. package/dist/pregel/retry.cjs.map +1 -1
  239. package/dist/pregel/retry.js +1 -2
  240. package/dist/pregel/retry.js.map +1 -1
  241. package/dist/pregel/runnable_types.d.cts +2 -8
  242. package/dist/pregel/runnable_types.d.cts.map +1 -1
  243. package/dist/pregel/runnable_types.d.ts +2 -8
  244. package/dist/pregel/runnable_types.d.ts.map +1 -1
  245. package/dist/pregel/runner.cjs +1 -1
  246. package/dist/pregel/runner.cjs.map +1 -1
  247. package/dist/pregel/runner.js +1 -1
  248. package/dist/pregel/runner.js.map +1 -1
  249. package/dist/pregel/stream.cjs +4 -6
  250. package/dist/pregel/stream.cjs.map +1 -1
  251. package/dist/pregel/stream.js +1 -2
  252. package/dist/pregel/stream.js.map +1 -1
  253. package/dist/pregel/types.d.cts +5 -18
  254. package/dist/pregel/types.d.cts.map +1 -1
  255. package/dist/pregel/types.d.ts +5 -18
  256. package/dist/pregel/types.d.ts.map +1 -1
  257. package/dist/pregel/utils/config.cjs +6 -7
  258. package/dist/pregel/utils/config.cjs.map +1 -1
  259. package/dist/pregel/utils/config.d.cts.map +1 -1
  260. package/dist/pregel/utils/config.d.ts.map +1 -1
  261. package/dist/pregel/utils/config.js.map +1 -1
  262. package/dist/pregel/utils/index.cjs +1 -2
  263. package/dist/pregel/utils/index.cjs.map +1 -1
  264. package/dist/pregel/utils/index.d.cts +1 -1
  265. package/dist/pregel/utils/index.d.cts.map +1 -1
  266. package/dist/pregel/utils/index.d.ts +1 -1
  267. package/dist/pregel/utils/index.d.ts.map +1 -1
  268. package/dist/pregel/utils/index.js +1 -2
  269. package/dist/pregel/utils/index.js.map +1 -1
  270. package/dist/pregel/utils/subgraph.cjs +0 -1
  271. package/dist/pregel/utils/subgraph.cjs.map +1 -1
  272. package/dist/pregel/utils/subgraph.js +0 -1
  273. package/dist/pregel/utils/subgraph.js.map +1 -1
  274. package/dist/pregel/validate.cjs.map +1 -1
  275. package/dist/pregel/validate.js.map +1 -1
  276. package/dist/pregel/write.cjs +2 -3
  277. package/dist/pregel/write.cjs.map +1 -1
  278. package/dist/pregel/write.d.cts +1 -5
  279. package/dist/pregel/write.d.cts.map +1 -1
  280. package/dist/pregel/write.d.ts +1 -5
  281. package/dist/pregel/write.d.ts.map +1 -1
  282. package/dist/pregel/write.js.map +1 -1
  283. package/dist/setup/async_local_storage.cjs +3 -4
  284. package/dist/setup/async_local_storage.cjs.map +1 -1
  285. package/dist/setup/async_local_storage.js.map +1 -1
  286. package/dist/utils.cjs +9 -11
  287. package/dist/utils.cjs.map +1 -1
  288. package/dist/utils.d.cts +1 -8
  289. package/dist/utils.d.cts.map +1 -1
  290. package/dist/utils.d.ts +1 -8
  291. package/dist/utils.d.ts.map +1 -1
  292. package/dist/utils.js +1 -2
  293. package/dist/utils.js.map +1 -1
  294. package/dist/web.cjs +8 -9
  295. package/dist/writer.cjs +2 -3
  296. package/dist/writer.cjs.map +1 -1
  297. package/dist/writer.d.cts +1 -2
  298. package/dist/writer.d.cts.map +1 -1
  299. package/dist/writer.d.ts +1 -2
  300. package/dist/writer.d.ts.map +1 -1
  301. package/dist/writer.js.map +1 -1
  302. package/package.json +7 -7
  303. package/CHANGELOG.md +0 -286
  304. package/dist/_virtual/rolldown_runtime.cjs +0 -25
@@ -107,12 +107,7 @@ interface EntrypointFunction {
107
107
  [START]: EphemeralValue<InputT>;
108
108
  [END]: LastValue<EntrypointReturnT<OutputT>>;
109
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>>>;
110
+ }, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>, any, Awaited<EntrypointReturnT<OutputT>>>;
116
111
  /**
117
112
  * A helper utility for use with the functional API that returns a value to the caller,
118
113
  * as well as a separate state value to persist to the checkpoint. This allows workflows
@@ -1 +1 @@
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"}
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>, any, 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;;;;EAAsD,WAAA,CAAA,EAjD9IP,WAiD8I;AAIhK;;;;;;AAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkKA;AAkBA;;;;;iBAhNwBS,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,eAAeM,QAAQb,kBAAkBO;;;;;;;;;;;;;;;;;;;;;YAqBnFO;WACDC;MACPhB,gBAAgBe,QAAQC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsIXC,YAAYN;;;;;;;;;;;;;;;;;;iBAkBTO,4BAA4BC"}
@@ -289,8 +289,7 @@ entrypoint.final = function final({ value, save }) {
289
289
  * @category Functional API
290
290
  */
291
291
  function getPreviousState() {
292
- const config = AsyncLocalStorageProviderSingleton.getRunnableConfig();
293
- return config.configurable?.[CONFIG_KEY_PREVIOUS_STATE];
292
+ return AsyncLocalStorageProviderSingleton.getRunnableConfig().configurable?.[CONFIG_KEY_PREVIOUS_STATE];
294
293
  }
295
294
 
296
295
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["cache: CachePolicy | undefined","entrypoint","config: LangGraphRunnableConfig"],"sources":["../../src/func/index.ts"],"sourcesContent":["import {\n BaseCache,\n BaseCheckpointSaver,\n BaseStore,\n} from \"@langchain/langgraph-checkpoint\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { Pregel } from \"../pregel/index.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport {\n CONFIG_KEY_PREVIOUS_STATE,\n END,\n PREVIOUS,\n START,\n TAG_HIDDEN,\n} from \"../constants.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport { call, getRunnableForEntrypoint } from \"../pregel/call.js\";\nimport type { CachePolicy, RetryPolicy } from \"../pregel/utils/index.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nimport {\n EntrypointFinal,\n EntrypointReturnT,\n EntrypointFinalSaveT,\n EntrypointFunc,\n TaskFunc,\n} from \"./types.js\";\nimport { LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\nimport {\n RunnableCallable,\n isAsyncGeneratorFunction,\n isGeneratorFunction,\n} from \"../utils.js\";\nimport { ChannelWrite, PASSTHROUGH } from \"../pregel/write.js\";\n\n/**\n * Options for the {@link task} function\n */\nexport interface TaskOptions {\n /**\n * The name of the task, analogous to the node name in {@link StateGraph}.\n */\n name: string;\n /**\n * The retry policy for the task. Configures how many times and under what conditions\n * the task should be retried if it fails.\n */\n retry?: RetryPolicy;\n\n /**\n * The cache policy for the task. Configures how the task should be cached.\n */\n cachePolicy?: CachePolicy;\n}\n\n/**\n * Define a LangGraph task using the `task` function.\n *\n * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.\n * A task can be called like a regular function with the following differences:\n *\n * - When a checkpointer is enabled, the function inputs and outputs must be serializable.\n * - The wrapped function can only be called from within an entrypoint or StateGraph.\n * - Calling the function produces a promise. This makes it easy to parallelize tasks.\n *\n * @typeParam ArgsT - The type of arguments the task function accepts\n * @typeParam OutputT - The type of value the task function returns\n * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task\n * @param func - The function that executes this task\n * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise\n *\n * @example basic example\n * ```typescript\n * const addOne = task(\"add\", async (a: number) => a + 1);\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n *\n * // Call the entrypoint\n * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]\n * ```\n *\n * @example using a retry policy\n * ```typescript\n * const addOne = task({\n * name: \"add\",\n * retry: { maxAttempts: 3 }\n * },\n * async (a: number) => a + 1\n * );\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n * ```\n * @category Functional API\n */\nexport function task<ArgsT extends unknown[], OutputT>(\n optionsOrName: TaskOptions | string,\n func: TaskFunc<ArgsT, OutputT>\n): (...args: ArgsT) => Promise<OutputT> {\n const options =\n typeof optionsOrName === \"string\"\n ? { name: optionsOrName, retry: undefined, cachePolicy: undefined }\n : optionsOrName;\n\n const { name, retry } = options;\n if (isAsyncGeneratorFunction(func) || isGeneratorFunction(func)) {\n throw new Error(\n \"Generators are disallowed as tasks. For streaming responses, use config.write.\"\n );\n }\n\n const cachePolicy =\n options.cachePolicy ??\n // `cache` was mistakingly used as an alias for `cachePolicy` in v0.3.x,\n // TODO: remove in 1.x\n (\"cache\" in options ? (options.cache as CachePolicy) : undefined);\n\n let cache: CachePolicy | undefined;\n if (typeof cachePolicy === \"boolean\") {\n cache = cachePolicy ? {} : undefined;\n } else {\n cache = cachePolicy;\n }\n\n return (...args: ArgsT) => {\n return call({ func, name, retry, cache }, ...args);\n };\n}\n\n/**\n * Options for the {@link entrypoint} function\n */\nexport type EntrypointOptions = {\n /**\n * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.\n * This name is used for logging, debugging, and checkpoint identification.\n */\n name: string;\n /**\n * The checkpointer for the {@link entrypoint}. Used to save and restore state between\n * invocations of the workflow.\n */\n checkpointer?: BaseCheckpointSaver;\n /**\n * The store for the {@link entrypoint}. Used to persist data across workflow runs.\n */\n store?: BaseStore;\n\n /**\n * The cache for the {@link entrypoint}. Used to cache values between workflow runs.\n */\n cache?: BaseCache;\n};\n\n/**\n * Type declaration for the entrypoint function with its properties\n * @category Functional API\n */\nexport interface EntrypointFunction {\n <InputT, OutputT>(\n optionsOrName: EntrypointOptions | string,\n func: EntrypointFunc<InputT, OutputT>\n ): Pregel<\n Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>,\n {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n },\n Record<string, unknown>,\n InputT,\n EntrypointReturnT<OutputT>,\n // Because the update type is an return type union of tasks + entrypoint,\n // thus we can't type it properly.\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Awaited<EntrypointReturnT<OutputT>>\n >;\n\n /**\n * A helper utility for use with the functional API that returns a value to the caller,\n * as well as a separate state value to persist to the checkpoint. This allows workflows\n * to maintain state between runs while returning different values to the caller.\n *\n * @typeParam ValueT - The type of the value to return to the caller\n * @typeParam SaveT - The type of the state to save to the checkpoint\n * @param options.value - The value to return to the caller\n * @param options.save - The value to save to the checkpoint\n * @returns An object with the value and save properties\n *\n * @example\n * ```typescript\n * return entrypoint.final({\n * value: \"result for caller\",\n * save: { counter: currentCount + 1 }\n * });\n * ```\n */\n final<ValueT, SaveT>(options: {\n value?: ValueT;\n save?: SaveT;\n }): EntrypointFinal<ValueT, SaveT>;\n}\n\n/**\n * Define a LangGraph workflow using the `entrypoint` function.\n *\n * ### Function signature\n *\n * The wrapped function must accept at most **two parameters**. The first parameter\n * is the input to the function. The second (optional) parameter is a\n * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to\n * the function, you can pass them as an object.\n *\n * ### Helper functions\n *\n * #### Streaming\n * To write data to the \"custom\" stream, use the {@link getWriter} function, or the\n * {@link LangGraphRunnableConfig.writer} property.\n *\n * #### State management\n * The {@link getPreviousState} function can be used to access the previous state\n * that was returned from the last invocation of the entrypoint on the same thread id.\n *\n * If you wish to save state other than the return value, you can use the\n * {@link entrypoint.final} function.\n *\n * @typeParam InputT - The type of input the entrypoint accepts\n * @typeParam OutputT - The type of output the entrypoint produces\n * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint\n * @param func - The function that executes this entrypoint\n * @returns A {@link Pregel} instance that can be run to execute the workflow\n *\n * @example Using entrypoint and tasks\n * ```typescript\n * import { task, entrypoint } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n * import { interrupt, Command } from \"@langchain/langgraph\";\n *\n * const composeEssay = task(\"compose\", async (topic: string) => {\n * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation\n * return `An essay about ${topic}`;\n * });\n *\n * const reviewWorkflow = entrypoint({\n * name: \"review\",\n * checkpointer: new MemorySaver()\n * }, async (topic: string) => {\n * const essay = await composeEssay(topic);\n * const humanReview = await interrupt({\n * question: \"Please provide a review\",\n * essay\n * });\n * return {\n * essay,\n * review: humanReview\n * };\n * });\n *\n * // Example configuration for the workflow\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * // Topic for the essay\n * const topic = \"cats\";\n *\n * // Stream the workflow to generate the essay and await human review\n * for await (const result of reviewWorkflow.stream(topic, config)) {\n * console.log(result);\n * }\n *\n * // Example human review provided after the interrupt\n * const humanReview = \"This essay is great.\";\n *\n * // Resume the workflow with the provided human review\n * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {\n * console.log(result);\n * }\n * ```\n *\n * @example Accessing the previous return value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const accumulator = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (input: string) => {\n * const previous = getPreviousState<number>();\n * return previous !== undefined ? `${previous } ${input}` : input;\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n * await accumulator.invoke(\"hello\", config); // returns \"hello\"\n * await accumulator.invoke(\"world\", config); // returns \"hello world\"\n * ```\n *\n * @example Using entrypoint.final to save a value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const myWorkflow = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (num: number) => {\n * const previous = getPreviousState<number>();\n *\n * // This will return the previous value to the caller, saving\n * // 2 * num to the checkpoint, which will be used in the next invocation\n * // for the `previous` parameter.\n * return entrypoint.final({\n * value: previous ?? 0,\n * save: 2 * num\n * });\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * await myWorkflow.invoke(3, config); // 0 (previous was undefined)\n * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)\n * ```\n * @category Functional API\n */\nexport const entrypoint = function entrypoint<InputT, OutputT>(\n optionsOrName: EntrypointOptions | string,\n func: EntrypointFunc<InputT, OutputT>\n) {\n const { name, checkpointer, store, cache } =\n typeof optionsOrName === \"string\"\n ? { name: optionsOrName, checkpointer: undefined, store: undefined }\n : optionsOrName;\n if (isAsyncGeneratorFunction(func) || isGeneratorFunction(func)) {\n throw new Error(\n \"Generators are disallowed as entrypoints. For streaming responses, use config.write.\"\n );\n }\n const streamMode = \"updates\";\n const bound = getRunnableForEntrypoint(name, func);\n\n // Helper to check if a value is an EntrypointFinal\n function isEntrypointFinal(\n value: unknown\n ): value is EntrypointFinal<unknown, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"__lg_type\" in value &&\n value.__lg_type === \"__pregel_final\"\n );\n }\n\n // Helper function to pluck the return value from EntrypointFinal or passthrough\n const pluckReturnValue = new RunnableCallable({\n name: \"pluckReturnValue\",\n func: (value: unknown) => {\n return isEntrypointFinal(value) ? value.value : value;\n },\n });\n\n // Helper function to pluck the save value from EntrypointFinal or passthrough\n const pluckSaveValue = new RunnableCallable({\n name: \"pluckSaveValue\",\n func: (value: unknown) => {\n return isEntrypointFinal(value) ? value.save : value;\n },\n });\n\n const entrypointNode = new PregelNode<InputT, EntrypointReturnT<OutputT>>({\n bound,\n triggers: [START],\n channels: [START],\n writers: [\n new ChannelWrite(\n [\n { channel: END, value: PASSTHROUGH, mapper: pluckReturnValue },\n { channel: PREVIOUS, value: PASSTHROUGH, mapper: pluckSaveValue },\n ],\n [TAG_HIDDEN]\n ),\n ],\n });\n\n return new Pregel<\n Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, // node types\n {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n }, // channel types\n Record<string, unknown>, // configurable types\n InputT, // input type\n EntrypointReturnT<OutputT> // output type\n >({\n name,\n checkpointer,\n nodes: {\n [name]: entrypointNode,\n },\n channels: {\n [START]: new EphemeralValue<InputT>(),\n [END]: new LastValue<EntrypointReturnT<OutputT>>(),\n [PREVIOUS]: new LastValue<EntrypointFinalSaveT<OutputT>>(),\n },\n inputChannels: START,\n outputChannels: END,\n streamChannels: END,\n streamMode,\n store,\n cache,\n });\n} as EntrypointFunction;\n\n// documented by the EntrypointFunction interface\nentrypoint.final = function final<ValueT, SaveT>({\n value,\n save,\n}: {\n value?: ValueT;\n save?: SaveT;\n}): EntrypointFinal<ValueT, SaveT> {\n return { value, save, __lg_type: \"__pregel_final\" };\n};\n\n/**\n * A helper utility function for use with the functional API that returns the previous\n * state from the checkpoint from the last invocation of the current thread.\n *\n * This function allows workflows to access state that was saved in previous runs\n * using {@link entrypoint.final}.\n *\n * @typeParam StateT - The type of the state that was previously saved\n * @returns The previous saved state from the last invocation of the current thread\n *\n * @example\n * ```typescript\n * const previousState = getPreviousState<{ counter: number }>();\n * const newCount = (previousState?.counter ?? 0) + 1;\n * ```\n * @category Functional API\n */\nexport function getPreviousState<StateT>(): StateT {\n const config: LangGraphRunnableConfig =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n return config.configurable?.[CONFIG_KEY_PREVIOUS_STATE] as StateT;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,SAAgB,KACd,eACA,MACsC;CACtC,MAAM,UACJ,OAAO,kBAAkB,WACrB;EAAE,MAAM;EAAe,OAAO;EAAW,aAAa;KACtD;CAEN,MAAM,EAAE,MAAM,UAAU;AACxB,KAAI,yBAAyB,SAAS,o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O;EAEV,UAAU;IACP,QAAQ,IAAI;IACZ,MAAM,IAAI;IACV,WAAW,IAAI;;EAElB,eAAe;EACf,gBAAgB;EAChB,gBAAgB;EAChB;EACA;EACA;;;AAKJ,WAAW,QAAQ,SAAS,MAAqB,EAC/C,OACA,QAIiC;AACjC,QAAO;EAAE;EAAO;EAAM,WAAW;;;;;;;;;;;;;;;;;;;;AAoBnC,SAAgB,mBAAmC;CACjD,MAAMC,SACJ,mCAAmC;AACrC,QAAO,OAAO,eAAe"}
1
+ {"version":3,"file":"index.js","names":["entrypoint"],"sources":["../../src/func/index.ts"],"sourcesContent":["import {\n BaseCache,\n BaseCheckpointSaver,\n BaseStore,\n} from \"@langchain/langgraph-checkpoint\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { Pregel } from \"../pregel/index.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport {\n CONFIG_KEY_PREVIOUS_STATE,\n END,\n PREVIOUS,\n START,\n TAG_HIDDEN,\n} from \"../constants.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport { call, getRunnableForEntrypoint } from \"../pregel/call.js\";\nimport type { CachePolicy, RetryPolicy } from \"../pregel/utils/index.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nimport {\n EntrypointFinal,\n EntrypointReturnT,\n EntrypointFinalSaveT,\n EntrypointFunc,\n TaskFunc,\n} from \"./types.js\";\nimport { LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\nimport {\n RunnableCallable,\n isAsyncGeneratorFunction,\n isGeneratorFunction,\n} from \"../utils.js\";\nimport { ChannelWrite, PASSTHROUGH } from \"../pregel/write.js\";\n\n/**\n * Options for the {@link task} function\n */\nexport interface TaskOptions {\n /**\n * The name of the task, analogous to the node name in {@link StateGraph}.\n */\n name: string;\n /**\n * The retry policy for the task. Configures how many times and under what conditions\n * the task should be retried if it fails.\n */\n retry?: RetryPolicy;\n\n /**\n * The cache policy for the task. Configures how the task should be cached.\n */\n cachePolicy?: CachePolicy;\n}\n\n/**\n * Define a LangGraph task using the `task` function.\n *\n * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.\n * A task can be called like a regular function with the following differences:\n *\n * - When a checkpointer is enabled, the function inputs and outputs must be serializable.\n * - The wrapped function can only be called from within an entrypoint or StateGraph.\n * - Calling the function produces a promise. This makes it easy to parallelize tasks.\n *\n * @typeParam ArgsT - The type of arguments the task function accepts\n * @typeParam OutputT - The type of value the task function returns\n * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task\n * @param func - The function that executes this task\n * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise\n *\n * @example basic example\n * ```typescript\n * const addOne = task(\"add\", async (a: number) => a + 1);\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n *\n * // Call the entrypoint\n * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]\n * ```\n *\n * @example using a retry policy\n * ```typescript\n * const addOne = task({\n * name: \"add\",\n * retry: { maxAttempts: 3 }\n * },\n * async (a: number) => a + 1\n * );\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n * ```\n * @category Functional API\n */\nexport function task<ArgsT extends unknown[], OutputT>(\n optionsOrName: TaskOptions | string,\n func: TaskFunc<ArgsT, OutputT>\n): (...args: ArgsT) => Promise<OutputT> {\n const options =\n typeof optionsOrName === \"string\"\n ? { name: optionsOrName, retry: undefined, cachePolicy: undefined }\n : optionsOrName;\n\n const { name, retry } = options;\n if (isAsyncGeneratorFunction(func) || isGeneratorFunction(func)) {\n throw new Error(\n \"Generators are disallowed as tasks. For streaming responses, use config.write.\"\n );\n }\n\n const cachePolicy =\n options.cachePolicy ??\n // `cache` was mistakingly used as an alias for `cachePolicy` in v0.3.x,\n // TODO: remove in 1.x\n (\"cache\" in options ? (options.cache as CachePolicy) : undefined);\n\n let cache: CachePolicy | undefined;\n if (typeof cachePolicy === \"boolean\") {\n cache = cachePolicy ? {} : undefined;\n } else {\n cache = cachePolicy;\n }\n\n return (...args: ArgsT) => {\n return call({ func, name, retry, cache }, ...args);\n };\n}\n\n/**\n * Options for the {@link entrypoint} function\n */\nexport type EntrypointOptions = {\n /**\n * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.\n * This name is used for logging, debugging, and checkpoint identification.\n */\n name: string;\n /**\n * The checkpointer for the {@link entrypoint}. Used to save and restore state between\n * invocations of the workflow.\n */\n checkpointer?: BaseCheckpointSaver;\n /**\n * The store for the {@link entrypoint}. Used to persist data across workflow runs.\n */\n store?: BaseStore;\n\n /**\n * The cache for the {@link entrypoint}. Used to cache values between workflow runs.\n */\n cache?: BaseCache;\n};\n\n/**\n * Type declaration for the entrypoint function with its properties\n * @category Functional API\n */\nexport interface EntrypointFunction {\n <InputT, OutputT>(\n optionsOrName: EntrypointOptions | string,\n func: EntrypointFunc<InputT, OutputT>\n ): Pregel<\n Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>,\n {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n },\n Record<string, unknown>,\n InputT,\n EntrypointReturnT<OutputT>,\n // Because the update type is an return type union of tasks + entrypoint,\n // thus we can't type it properly.\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Awaited<EntrypointReturnT<OutputT>>\n >;\n\n /**\n * A helper utility for use with the functional API that returns a value to the caller,\n * as well as a separate state value to persist to the checkpoint. This allows workflows\n * to maintain state between runs while returning different values to the caller.\n *\n * @typeParam ValueT - The type of the value to return to the caller\n * @typeParam SaveT - The type of the state to save to the checkpoint\n * @param options.value - The value to return to the caller\n * @param options.save - The value to save to the checkpoint\n * @returns An object with the value and save properties\n *\n * @example\n * ```typescript\n * return entrypoint.final({\n * value: \"result for caller\",\n * save: { counter: currentCount + 1 }\n * });\n * ```\n */\n final<ValueT, SaveT>(options: {\n value?: ValueT;\n save?: SaveT;\n }): EntrypointFinal<ValueT, SaveT>;\n}\n\n/**\n * Define a LangGraph workflow using the `entrypoint` function.\n *\n * ### Function signature\n *\n * The wrapped function must accept at most **two parameters**. The first parameter\n * is the input to the function. The second (optional) parameter is a\n * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to\n * the function, you can pass them as an object.\n *\n * ### Helper functions\n *\n * #### Streaming\n * To write data to the \"custom\" stream, use the {@link getWriter} function, or the\n * {@link LangGraphRunnableConfig.writer} property.\n *\n * #### State management\n * The {@link getPreviousState} function can be used to access the previous state\n * that was returned from the last invocation of the entrypoint on the same thread id.\n *\n * If you wish to save state other than the return value, you can use the\n * {@link entrypoint.final} function.\n *\n * @typeParam InputT - The type of input the entrypoint accepts\n * @typeParam OutputT - The type of output the entrypoint produces\n * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint\n * @param func - The function that executes this entrypoint\n * @returns A {@link Pregel} instance that can be run to execute the workflow\n *\n * @example Using entrypoint and tasks\n * ```typescript\n * import { task, entrypoint } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n * import { interrupt, Command } from \"@langchain/langgraph\";\n *\n * const composeEssay = task(\"compose\", async (topic: string) => {\n * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation\n * return `An essay about ${topic}`;\n * });\n *\n * const reviewWorkflow = entrypoint({\n * name: \"review\",\n * checkpointer: new MemorySaver()\n * }, async (topic: string) => {\n * const essay = await composeEssay(topic);\n * const humanReview = await interrupt({\n * question: \"Please provide a review\",\n * essay\n * });\n * return {\n * essay,\n * review: humanReview\n * };\n * });\n *\n * // Example configuration for the workflow\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * // Topic for the essay\n * const topic = \"cats\";\n *\n * // Stream the workflow to generate the essay and await human review\n * for await (const result of reviewWorkflow.stream(topic, config)) {\n * console.log(result);\n * }\n *\n * // Example human review provided after the interrupt\n * const humanReview = \"This essay is great.\";\n *\n * // Resume the workflow with the provided human review\n * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {\n * console.log(result);\n * }\n * ```\n *\n * @example Accessing the previous return value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const accumulator = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (input: string) => {\n * const previous = getPreviousState<number>();\n * return previous !== undefined ? `${previous } ${input}` : input;\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n * await accumulator.invoke(\"hello\", config); // returns \"hello\"\n * await accumulator.invoke(\"world\", config); // returns \"hello world\"\n * ```\n *\n * @example Using entrypoint.final to save a value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const myWorkflow = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (num: number) => {\n * const previous = getPreviousState<number>();\n *\n * // This will return the previous value to the caller, saving\n * // 2 * num to the checkpoint, which will be used in the next invocation\n * // for the `previous` parameter.\n * return entrypoint.final({\n * value: previous ?? 0,\n * save: 2 * num\n * });\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * await myWorkflow.invoke(3, config); // 0 (previous was undefined)\n * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)\n * ```\n * @category Functional API\n */\nexport const entrypoint = function entrypoint<InputT, OutputT>(\n optionsOrName: EntrypointOptions | string,\n func: EntrypointFunc<InputT, OutputT>\n) {\n const { name, checkpointer, store, cache } =\n typeof optionsOrName === \"string\"\n ? { name: optionsOrName, checkpointer: undefined, store: undefined }\n : optionsOrName;\n if (isAsyncGeneratorFunction(func) || isGeneratorFunction(func)) {\n throw new Error(\n \"Generators are disallowed as entrypoints. For streaming responses, use config.write.\"\n );\n }\n const streamMode = \"updates\";\n const bound = getRunnableForEntrypoint(name, func);\n\n // Helper to check if a value is an EntrypointFinal\n function isEntrypointFinal(\n value: unknown\n ): value is EntrypointFinal<unknown, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"__lg_type\" in value &&\n value.__lg_type === \"__pregel_final\"\n );\n }\n\n // Helper function to pluck the return value from EntrypointFinal or passthrough\n const pluckReturnValue = new RunnableCallable({\n name: \"pluckReturnValue\",\n func: (value: unknown) => {\n return isEntrypointFinal(value) ? value.value : value;\n },\n });\n\n // Helper function to pluck the save value from EntrypointFinal or passthrough\n const pluckSaveValue = new RunnableCallable({\n name: \"pluckSaveValue\",\n func: (value: unknown) => {\n return isEntrypointFinal(value) ? value.save : value;\n },\n });\n\n const entrypointNode = new PregelNode<InputT, EntrypointReturnT<OutputT>>({\n bound,\n triggers: [START],\n channels: [START],\n writers: [\n new ChannelWrite(\n [\n { channel: END, value: PASSTHROUGH, mapper: pluckReturnValue },\n { channel: PREVIOUS, value: PASSTHROUGH, mapper: pluckSaveValue },\n ],\n [TAG_HIDDEN]\n ),\n ],\n });\n\n return new Pregel<\n Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, // node types\n {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n }, // channel types\n Record<string, unknown>, // configurable types\n InputT, // input type\n EntrypointReturnT<OutputT> // output type\n >({\n name,\n checkpointer,\n nodes: {\n [name]: entrypointNode,\n },\n channels: {\n [START]: new EphemeralValue<InputT>(),\n [END]: new LastValue<EntrypointReturnT<OutputT>>(),\n [PREVIOUS]: new LastValue<EntrypointFinalSaveT<OutputT>>(),\n },\n inputChannels: START,\n outputChannels: END,\n streamChannels: END,\n streamMode,\n store,\n cache,\n });\n} as EntrypointFunction;\n\n// documented by the EntrypointFunction interface\nentrypoint.final = function final<ValueT, SaveT>({\n value,\n save,\n}: {\n value?: ValueT;\n save?: SaveT;\n}): EntrypointFinal<ValueT, SaveT> {\n return { value, save, __lg_type: \"__pregel_final\" };\n};\n\n/**\n * A helper utility function for use with the functional API that returns the previous\n * state from the checkpoint from the last invocation of the current thread.\n *\n * This function allows workflows to access state that was saved in previous runs\n * using {@link entrypoint.final}.\n *\n * @typeParam StateT - The type of the state that was previously saved\n * @returns The previous saved state from the last invocation of the current thread\n *\n * @example\n * ```typescript\n * const previousState = getPreviousState<{ counter: number }>();\n * const newCount = (previousState?.counter ?? 0) + 1;\n * ```\n * @category Functional API\n */\nexport function getPreviousState<StateT>(): StateT {\n const config: LangGraphRunnableConfig =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n return config.configurable?.[CONFIG_KEY_PREVIOUS_STATE] as StateT;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,SAAgB,KACd,eACA,MACsC;CACtC,MAAM,UACJ,OAAO,kBAAkB,WACrB;EAAE,MAAM;EAAe,OAAO;EAAW,aAAa;EAAW,GACjE;CAEN,MAAM,EAAE,MAAM,UAAU;AACxB,KAAI,yBAAyB,KAAK,IAAI,oBAAoB,KAAK,CAC7D,OAAM,IAAI,MACR,iFACD;CAGH,MAAM,cACJ,QAAQ,gBAGP,WAAW,UAAW,QAAQ,QAAwB;CAEzD,IAAI;AACJ,KAAI,OAAO,gBAAgB,UACzB,SAAQ,cAAc,EAAE,GAAG;KAE3B,SAAQ;AAGV,SAAQ,GAAG,SAAgB;AACzB,SAAO,KAAK;GAAE;GAAM;GAAM;GAAO;GAAO,EAAE,GAAG,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AkB;;;;;;;;;;;;;;;;;;;AAoBrD,SAAgB,mBAAmC;AAGjD,QADE,mCAAmC,mBAAmB,CAC1C,eAAe"}
@@ -52,13 +52,11 @@ type AsyncGeneratorExists = AsyncGenerator<unknown, unknown, unknown> extends ob
52
52
  /**
53
53
  * Matches valid function signatures for entrypoints. Disallows generator functions.
54
54
  */
55
- type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist
56
- ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;
55
+ type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;
57
56
  /**
58
57
  * Matches valid function signatures for tasks. Disallows generator functions.
59
58
  */
60
- type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [never] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist
61
- ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT;
59
+ type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [never] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT;
62
60
  //#endregion
63
61
  export { EntrypointFinal, EntrypointFinalSaveT, EntrypointFunc, EntrypointReturnT, TaskFunc };
64
62
  //# sourceMappingURL=types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":["LangGraphRunnableConfig","EntrypointFinal","ValueT","SaveT","isEntrypointFinal","EntrypointReturnT","OutputT","Promise","EntrypointFinalSaveT","EntrypointFinalValueT","AsyncGeneratorExists","AsyncGenerator","EntrypointFunc","InputT","Generator","TaskFunc","ArgsT"],"sources":["../../src/func/types.d.ts"],"sourcesContent":["import { LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\n/**\n * Allows the entrypoint function to return a value to the caller, as well as a separate state value to persist to the checkpoint\n */\nexport type EntrypointFinal<ValueT, SaveT> = {\n /**\n * The value to return to the caller\n */\n value?: ValueT;\n /**\n * The value to save to the checkpoint\n */\n save?: SaveT;\n __lg_type: \"__pregel_final\";\n};\n/**\n * Checks if a value is an EntrypointFinal - use this instead of `instanceof`, as value may have been deserialized\n * @param value The value to check\n * @returns Whether the value is an EntrypointFinal\n */\nexport declare function isEntrypointFinal<ValueT, SaveT>(value: unknown): value is EntrypointFinal<ValueT, SaveT>;\n/**\n * The return type of an entrypoint function.\n */\nexport type EntrypointReturnT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, unknown> | Promise<EntrypointFinal<infer ValueT, unknown>> ? ValueT : OutputT;\n/**\n * The value to be saved when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalSaveT<OutputT> = OutputT extends EntrypointFinal<unknown, infer SaveT> | Promise<EntrypointFinal<unknown, infer SaveT>> ? SaveT : OutputT;\n/**\n * The value to be returned when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalValueT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, infer SaveT> | Promise<EntrypointFinal<infer ValueT, infer SaveT>> ? EntrypointFinal<ValueT, SaveT> : OutputT;\n/**\n * Checks if an AsyncGenerator exists in the ES target/lib that we're compiling to.\n *\n * This is necessary because `tsc --init` targets ES2016 by default, which doesn't include AsyncGenerators.\n *\n * This works because when `skipLibCheck` is true (and it is in the default `tsconfig.json` created by `tsc --init`),\n * TypeScript will replace any unresolved library types with `any`. So, when `AsyncGenerator` doesn't exist, this checks\n * if `any` extends `object`, which it doesn't. When that happens, this type resolves to the `false` literal, and we can\n * use it in the type predicates below to skip over the AsyncGenerator-specific logic.\n *\n * If we didn't have this, then the types below would be checking if the user's function extends `any` in place of the\n * `AsyncGenerator` type, and the type predicate would branch to `never`, disallowing any valid function from being passed\n * to `task` or `entrypoint`.\n */\ntype AsyncGeneratorExists = AsyncGenerator<unknown, unknown, unknown> extends object ? true : false;\n/**\n * Matches valid function signatures for entrypoints. Disallows generator functions.\n */\nexport type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist\n ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;\n/**\n * Matches valid function signatures for tasks. Disallows generator functions.\n */\nexport type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [\n never\n] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist\n ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT;\nexport {};\n"],"mappings":";;;;;;AAIA;AAA2B,KAAfC,eAAe,CAAA,MAAA,EAAA,KAAA,CAAA,GAAA;;;;EAoBfI,KAAAA,CAAAA,EAhB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A,GAPuKL,OAOvKK,GAPiLL,OAOjLK,SAPiMG,SAOjMH,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,KAAAA,EAPwPE,MAOxPF,EAAAA,MAAAA,EAPwQX,uBAOxQW,EAAAA,GAPoSL,OAOpSK;;;;AAAuIL,KAH9IS,QAG8IT,CAAAA,cAAAA,OAAAA,EAAAA,EAAAA,OAAAA,CAAAA,GAAAA,CAHhGA,OAGgGA,CAAAA,SAAAA,MAAUA,QAAgBQ,IAAAA,EADtKE,KACsKF,EAAAA,GAAAA,KAAAA,GADpJJ,oBACoJI,SAAAA,IAAAA,CAAAA;AAAAA,EAAjLR,OAA0OU,SAA1NL,cAA0NK,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAtKV,OAAsKU,SAAtJF,SAAsJE,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,GAAAA,IAAAA,EAA7FA,KAA6FA,EAAAA,GAAnFV,OAAmFU,GAAzEV,OAAyEU,SAAzDF,SAAyDE,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,GAAAA,IAAAA,EAAAA,KAAAA,EAAAA,GAAUV,OAAVU"}
1
+ {"version":3,"file":"types.d.cts","names":["LangGraphRunnableConfig","EntrypointFinal","ValueT","SaveT","isEntrypointFinal","EntrypointReturnT","OutputT","Promise","EntrypointFinalSaveT","EntrypointFinalValueT","AsyncGeneratorExists","AsyncGenerator","EntrypointFunc","InputT","Generator","TaskFunc","ArgsT"],"sources":["../../src/func/types.d.ts"],"sourcesContent":["import { LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\n/**\n * Allows the entrypoint function to return a value to the caller, as well as a separate state value to persist to the checkpoint\n */\nexport type EntrypointFinal<ValueT, SaveT> = {\n /**\n * The value to return to the caller\n */\n value?: ValueT;\n /**\n * The value to save to the checkpoint\n */\n save?: SaveT;\n __lg_type: \"__pregel_final\";\n};\n/**\n * Checks if a value is an EntrypointFinal - use this instead of `instanceof`, as value may have been deserialized\n * @param value The value to check\n * @returns Whether the value is an EntrypointFinal\n */\nexport declare function isEntrypointFinal<ValueT, SaveT>(value: unknown): value is EntrypointFinal<ValueT, SaveT>;\n/**\n * The return type of an entrypoint function.\n */\nexport type EntrypointReturnT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, unknown> | Promise<EntrypointFinal<infer ValueT, unknown>> ? ValueT : OutputT;\n/**\n * The value to be saved when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalSaveT<OutputT> = OutputT extends EntrypointFinal<unknown, infer SaveT> | Promise<EntrypointFinal<unknown, infer SaveT>> ? SaveT : OutputT;\n/**\n * The value to be returned when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalValueT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, infer SaveT> | Promise<EntrypointFinal<infer ValueT, infer SaveT>> ? EntrypointFinal<ValueT, SaveT> : OutputT;\n/**\n * Checks if an AsyncGenerator exists in the ES target/lib that we're compiling to.\n *\n * This is necessary because `tsc --init` targets ES2016 by default, which doesn't include AsyncGenerators.\n *\n * This works because when `skipLibCheck` is true (and it is in the default `tsconfig.json` created by `tsc --init`),\n * TypeScript will replace any unresolved library types with `any`. So, when `AsyncGenerator` doesn't exist, this checks\n * if `any` extends `object`, which it doesn't. When that happens, this type resolves to the `false` literal, and we can\n * use it in the type predicates below to skip over the AsyncGenerator-specific logic.\n *\n * If we didn't have this, then the types below would be checking if the user's function extends `any` in place of the\n * `AsyncGenerator` type, and the type predicate would branch to `never`, disallowing any valid function from being passed\n * to `task` or `entrypoint`.\n */\ntype AsyncGeneratorExists = AsyncGenerator<unknown, unknown, unknown> extends object ? true : false;\n/**\n * Matches valid function signatures for entrypoints. Disallows generator functions.\n */\nexport type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;\n/**\n * Matches valid function signatures for tasks. Disallows generator functions.\n */\nexport type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [\n never\n] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT;\nexport {};\n"],"mappings":";;;;;;AAIA;AAA2B,KAAfC,eAAe,CAAA,MAAA,EAAA,KAAA,CAAA,GAAA;;;;EAoBfI,KAAAA,CAAAA,EAhBAH,MAgBAG;EAAiB;;;MAA6EJ,CAAAA,EAZ/FE,KAY+FF;WAARM,EAAAA,gBAAAA;;;;AAIlG;;;;;;;AAA6JD,KAJjJD,iBAIiJC,CAAAA,OAAAA,CAAAA,GAJpHA,OAIoHA,SAJpGL,eAIoGK,CAAAA,KAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAJ3DC,OAI2DD,CAJnDL,eAImDK,CAAAA,KAAAA,OAAAA,EAAAA,OAAAA,CAAAA,CAAAA,GAJTJ,MAISI,GAJAA,OAIAA;;AAI4C;AAmBzM;AAA0B,KAvBdE,oBAuBc,CAAA,OAAA,CAAA,GAvBkBF,OAuBlB,SAvBkCL,eAuBlC,CAAA,OAAA,EAAA,KAAA,MAAA,CAAA,GAvB0EM,OAuB1E,CAvBkFN,eAuBlF,CAAA,OAAA,EAAA,KAAA,MAAA,CAAA,CAAA,GAvB2HE,KAuB3H,GAvBmIG,OAuBnI;;;;;;;;;;;;;;;;;;AAI1B;KARKI,oB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GAAAA,IAAAA,EAApBU,KAAoBV,EAAAA,GAAVA,OAAUA,GAAAA,OAAAA,SAAgBQ,SAAhBR,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,GAAAA,IAAAA,EAAyEU,KAAzEV,EAAAA,GAAmFA,OAAnFA"}
@@ -52,13 +52,11 @@ type AsyncGeneratorExists = AsyncGenerator<unknown, unknown, unknown> extends ob
52
52
  /**
53
53
  * Matches valid function signatures for entrypoints. Disallows generator functions.
54
54
  */
55
- type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist
56
- ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;
55
+ type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;
57
56
  /**
58
57
  * Matches valid function signatures for tasks. Disallows generator functions.
59
58
  */
60
- type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [never] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist
61
- ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT;
59
+ type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [never] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT;
62
60
  //#endregion
63
61
  export { EntrypointFinal, EntrypointFinalSaveT, EntrypointFunc, EntrypointReturnT, TaskFunc };
64
62
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":["LangGraphRunnableConfig","EntrypointFinal","ValueT","SaveT","isEntrypointFinal","EntrypointReturnT","OutputT","Promise","EntrypointFinalSaveT","EntrypointFinalValueT","AsyncGeneratorExists","AsyncGenerator","EntrypointFunc","InputT","Generator","TaskFunc","ArgsT"],"sources":["../../src/func/types.d.ts"],"sourcesContent":["import { LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\n/**\n * Allows the entrypoint function to return a value to the caller, as well as a separate state value to persist to the checkpoint\n */\nexport type EntrypointFinal<ValueT, SaveT> = {\n /**\n * The value to return to the caller\n */\n value?: ValueT;\n /**\n * The value to save to the checkpoint\n */\n save?: SaveT;\n __lg_type: \"__pregel_final\";\n};\n/**\n * Checks if a value is an EntrypointFinal - use this instead of `instanceof`, as value may have been deserialized\n * @param value The value to check\n * @returns Whether the value is an EntrypointFinal\n */\nexport declare function isEntrypointFinal<ValueT, SaveT>(value: unknown): value is EntrypointFinal<ValueT, SaveT>;\n/**\n * The return type of an entrypoint function.\n */\nexport type EntrypointReturnT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, unknown> | Promise<EntrypointFinal<infer ValueT, unknown>> ? ValueT : OutputT;\n/**\n * The value to be saved when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalSaveT<OutputT> = OutputT extends EntrypointFinal<unknown, infer SaveT> | Promise<EntrypointFinal<unknown, infer SaveT>> ? SaveT : OutputT;\n/**\n * The value to be returned when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalValueT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, infer SaveT> | Promise<EntrypointFinal<infer ValueT, infer SaveT>> ? EntrypointFinal<ValueT, SaveT> : OutputT;\n/**\n * Checks if an AsyncGenerator exists in the ES target/lib that we're compiling to.\n *\n * This is necessary because `tsc --init` targets ES2016 by default, which doesn't include AsyncGenerators.\n *\n * This works because when `skipLibCheck` is true (and it is in the default `tsconfig.json` created by `tsc --init`),\n * TypeScript will replace any unresolved library types with `any`. So, when `AsyncGenerator` doesn't exist, this checks\n * if `any` extends `object`, which it doesn't. When that happens, this type resolves to the `false` literal, and we can\n * use it in the type predicates below to skip over the AsyncGenerator-specific logic.\n *\n * If we didn't have this, then the types below would be checking if the user's function extends `any` in place of the\n * `AsyncGenerator` type, and the type predicate would branch to `never`, disallowing any valid function from being passed\n * to `task` or `entrypoint`.\n */\ntype AsyncGeneratorExists = AsyncGenerator<unknown, unknown, unknown> extends object ? true : false;\n/**\n * Matches valid function signatures for entrypoints. Disallows generator functions.\n */\nexport type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist\n ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;\n/**\n * Matches valid function signatures for tasks. Disallows generator functions.\n */\nexport type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [\n never\n] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist\n ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT)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EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,KAAAA,EAP2HE,MAO3HF,EAAAA,MAAAA,EAP2IX,uBAO3IW,EAAAA,GAPuKL,OAOvKK,GAPiLL,OAOjLK,SAPiMG,SAOjMH,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,KAAAA,EAPwPE,MAOxPF,EAAAA,MAAAA,EAPwQX,uBAOxQW,EAAAA,GAPoSL,OAOpSK;;;;AAAuIL,KAH9IS,QAG8IT,CAAAA,cAAAA,OAAAA,EAAAA,EAAAA,OAAAA,CAAAA,GAAAA,CAHhGA,OAGgGA,CAAAA,SAAAA,MAAUA,QAAgBQ,IAAAA,EADtKE,KACsKF,EAAAA,GAAAA,KAAAA,GADpJJ,oBACoJI,SAAAA,IAAAA,CAAAA;AAAAA,EAAjLR,OAA0OU,SAA1NL,cAA0NK,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAtKV,OAAsKU,SAAtJF,SAAsJE,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,GAAAA,IAAAA,EAA7FA,KAA6FA,EAAAA,GAAnFV,OAAmFU,GAAzEV,OAAyEU,SAAzDF,SAAyDE,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,GAAAA,IAAAA,EAAAA,KAAAA,EAAAA,GAAUV,OAAVU"}
1
+ {"version":3,"file":"types.d.ts","names":["LangGraphRunnableConfig","EntrypointFinal","ValueT","SaveT","isEntrypointFinal","EntrypointReturnT","OutputT","Promise","EntrypointFinalSaveT","EntrypointFinalValueT","AsyncGeneratorExists","AsyncGenerator","EntrypointFunc","InputT","Generator","TaskFunc","ArgsT"],"sources":["../../src/func/types.d.ts"],"sourcesContent":["import { LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\n/**\n * Allows the entrypoint function to return a value to the caller, as well as a separate state value to persist to the checkpoint\n */\nexport type EntrypointFinal<ValueT, SaveT> = {\n /**\n * The value to return to the caller\n */\n value?: ValueT;\n /**\n * The value to save to the checkpoint\n */\n save?: SaveT;\n __lg_type: \"__pregel_final\";\n};\n/**\n * Checks if a value is an EntrypointFinal - use this instead of `instanceof`, as value may have been deserialized\n * @param value The value to check\n * @returns Whether the value is an EntrypointFinal\n */\nexport declare function isEntrypointFinal<ValueT, SaveT>(value: unknown): value is EntrypointFinal<ValueT, SaveT>;\n/**\n * The return type of an entrypoint function.\n */\nexport type EntrypointReturnT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, unknown> | Promise<EntrypointFinal<infer ValueT, unknown>> ? ValueT : OutputT;\n/**\n * The value to be saved when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalSaveT<OutputT> = OutputT extends EntrypointFinal<unknown, infer SaveT> | Promise<EntrypointFinal<unknown, infer SaveT>> ? SaveT : OutputT;\n/**\n * The value to be returned when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalValueT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, infer SaveT> | Promise<EntrypointFinal<infer ValueT, infer SaveT>> ? EntrypointFinal<ValueT, SaveT> : OutputT;\n/**\n * Checks if an AsyncGenerator exists in the ES target/lib that we're compiling to.\n *\n * This is necessary because `tsc --init` targets ES2016 by default, which doesn't include AsyncGenerators.\n *\n * This works because when `skipLibCheck` is true (and it is in the default `tsconfig.json` created by `tsc --init`),\n * TypeScript will replace any unresolved library types with `any`. So, when `AsyncGenerator` doesn't exist, this checks\n * if `any` extends `object`, which it doesn't. When that happens, this type resolves to the `false` literal, and we can\n * use it in the type predicates below to skip over the AsyncGenerator-specific logic.\n *\n * If we didn't have this, then the types below would be checking if the user's function extends `any` in place of the\n * `AsyncGenerator` type, and the type predicate would branch to `never`, disallowing any valid function from being passed\n * to `task` or `entrypoint`.\n */\ntype AsyncGeneratorExists = AsyncGenerator<unknown, unknown, unknown> extends object ? true : false;\n/**\n * Matches valid function signatures for entrypoints. Disallows generator functions.\n */\nexport type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;\n/**\n * Matches valid function signatures for tasks. Disallows generator functions.\n */\nexport type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [\n never\n] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT;\nexport {};\n"],"mappings":";;;;;;AAIA;AAA2B,KAAfC,eAAe,CAAA,MAAA,EAAA,KAAA,CAAA,GAAA;;;;EAoBfI,KAAAA,CAAAA,EAhBAH,MAgBAG;EAAiB;;;MAA6EJ,CAAAA,EAZ/FE,KAY+FF;WAARM,EAAAA,gBAAAA;;;;AAIlG;;;;;;;AAA6JD,KAJjJD,iBAIiJC,CAAAA,OAAAA,CAAAA,GAJpHA,OAIoHA,SAJpGL,eAIoGK,CAAAA,KAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAJ3DC,OAI2DD,CAJnDL,eAImDK,CAAAA,KAAAA,OAAAA,EAAAA,OAAAA,CAAAA,CAAAA,GAJTJ,MAISI,GAJAA,OAIAA;;AAI4C;AAmBzM;AAA0B,KAvBdE,oBAuBc,CAAA,OAAA,CAAA,GAvBkBF,OAuBlB,SAvBkCL,eAuBlC,CAAA,OAAA,EAAA,KAAA,MAAA,CAAA,GAvB0EM,OAuB1E,CAvBk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AAA,KAAAA,GAA7FA,OAA6FA,SAA7EQ,SAA6ER,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,GAAAA,IAAAA,EAApBU,KAAoBV,EAAAA,GAAVA,OAAUA,GAAAA,OAAAA,SAAgBQ,SAAhBR,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,GAAAA,IAAAA,EAAyEU,KAAzEV,EAAAA,GAAmFA,OAAnFA"}
@@ -1 +1 @@
1
- {"version":3,"file":"annotation.cjs","names":["Annotation: AnnotationFunction","LastValue","BinaryOperatorAggregate"],"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,MAAaA,aAAiC,SAI5C,YACoC;AACpC,KAAI,WACF,QAAO,WAAkC;KAGzC,QAAO,IAAIC;;AAIf,WAAW,QAAmC,OAAU,IAAI,eAAe;AAE3E,SAAgB,WACd,SACmB;AACnB,KACE,OAAO,YAAY,YACnB,WACA,aAAa,WACb,QAAQ,QAER,QAAO,IAAIC,sCAAwB,QAAQ,SAAS,QAAQ;AAE9D,KACE,OAAO,YAAY,YACnB,WACA,WAAW,WACX,QAAQ,MAER,QAAO,IAAIA,sCAAwB,QAAQ,OAAO,QAAQ;AAG5D,QAAO,IAAID"}
1
+ {"version":3,"file":"annotation.cjs","names":["LastValue","BinaryOperatorAggregate"],"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,IAAIA,8BAAsB;;AAIrC,WAAW,QAAmC,OAAU,IAAI,eAAe,GAAG;AAE9E,SAAgB,WACd,SACmB;AACnB,KACE,OAAO,YAAY,YACnB,WACA,aAAa,WACb,QAAQ,QAER,QAAO,IAAIC,sCAAwB,QAAQ,SAAS,QAAQ,QAAQ;AAEtE,KACE,OAAO,YAAY,YACnB,WACA,WAAW,WACX,QAAQ,MAER,QAAO,IAAIA,sCAAwB,QAAQ,OAAO,QAAQ,QAAQ;AAGpE,QAAO,IAAID,8BAAc"}
@@ -1 +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,sBAAsBC,UAAUT,cAAcS,iBAAiBA,iBAAgBT,eAAcU,WAAWD;AAH7G,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;KAOPM,sBAAsBC,6BAL7BC,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"}
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,WAAW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;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"}
@@ -1 +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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,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"}
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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AAyBS,EAsBrGI,EAtBqGJ;aAAXC,CAAAA,CAAAA,EAuBjFG,EAvBiFH;;AACpG;;;;;;;;AAGA;;;;;;;;AAGA;;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;AA+EA;;;;;;;;;;;;;;;cAAqBU,YAAYH"}
@@ -1 +1 @@
1
- {"version":3,"file":"annotation.js","names":["Annotation: AnnotationFunction"],"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,MAAaA,aAAiC,SAI5C,YACoC;AACpC,KAAI,WACF,QAAO,WAAkC;KAGzC,QAAO,IAAI;;AAIf,WAAW,QAAmC,OAAU,IAAI,eAAe;AAE3E,SAAgB,WACd,SACmB;AACnB,KACE,OAAO,YAAY,YACnB,WACA,aAAa,WACb,QAAQ,QAER,QAAO,IAAI,wBAAwB,QAAQ,SAAS,QAAQ;AAE9D,KACE,OAAO,YAAY,YACnB,WACA,WAAW,WACX,QAAQ,MAER,QAAO,IAAI,wBAAwB,QAAQ,OAAO,QAAQ;AAG5D,QAAO,IAAI"}
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"}
@@ -1,4 +1,3 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
1
  const require_errors = require('../errors.cjs');
3
2
  const require_constants = require('../constants.cjs');
4
3
  const require_utils = require('../utils.cjs');
@@ -7,18 +6,18 @@ const require_read = require('../pregel/read.cjs');
7
6
  const require_subgraph = require('../pregel/utils/subgraph.cjs');
8
7
  const require_pregel_index = require('../pregel/index.cjs');
9
8
  const require_ephemeral_value = require('../channels/ephemeral_value.cjs');
10
- const __langchain_core_runnables = require_rolldown_runtime.__toESM(require("@langchain/core/runnables"));
11
- const __langchain_core_runnables_graph = require_rolldown_runtime.__toESM(require("@langchain/core/runnables/graph"));
12
- const zod_v4 = require_rolldown_runtime.__toESM(require("zod/v4"));
13
- const uuid = require_rolldown_runtime.__toESM(require("uuid"));
9
+ let _langchain_core_runnables = require("@langchain/core/runnables");
10
+ let _langchain_core_runnables_graph = require("@langchain/core/runnables/graph");
11
+ let zod_v4 = require("zod/v4");
12
+ let uuid = require("uuid");
14
13
 
15
14
  //#region src/graph/graph.ts
16
15
  var Branch = class {
17
16
  path;
18
17
  ends;
19
18
  constructor(options) {
20
- if (__langchain_core_runnables.Runnable.isRunnable(options.path)) this.path = options.path;
21
- else this.path = (0, __langchain_core_runnables._coerceToRunnable)(options.path).withConfig({ runName: `Branch` });
19
+ if (_langchain_core_runnables.Runnable.isRunnable(options.path)) this.path = options.path;
20
+ else this.path = (0, _langchain_core_runnables._coerceToRunnable)(options.path).withConfig({ runName: `Branch` });
22
21
  this.ends = Array.isArray(options.pathMap) ? options.pathMap.reduce((acc, n) => {
23
22
  acc[n] = n;
24
23
  return acc;
@@ -46,8 +45,7 @@ var Branch = class {
46
45
  else destinations = result;
47
46
  if (destinations.some((dest) => !dest)) throw new Error("Branch condition returned unknown or null destination");
48
47
  if (destinations.filter(require_constants._isSend).some((packet) => packet.node === require_constants.END)) throw new require_errors.InvalidUpdateError("Cannot send a packet to the END node");
49
- const writeResult = await writer(destinations, config);
50
- return writeResult ?? input;
48
+ return await writer(destinations, config) ?? input;
51
49
  }
52
50
  };
53
51
  var Graph = class {
@@ -82,7 +80,7 @@ var Graph = class {
82
80
  this.warnIfCompiled(`Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph.`);
83
81
  if (key in this.nodes) throw new Error(`Node \`${key}\` already present.`);
84
82
  if (key === require_constants.END) throw new Error(`Node \`${key}\` is reserved.`);
85
- const runnable = (0, __langchain_core_runnables._coerceToRunnable)(action);
83
+ const runnable = (0, _langchain_core_runnables._coerceToRunnable)(action);
86
84
  this.nodes[key] = {
87
85
  runnable,
88
86
  metadata: options?.metadata,
@@ -107,9 +105,9 @@ var Graph = class {
107
105
  pathMap
108
106
  };
109
107
  this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.");
110
- if (!__langchain_core_runnables.Runnable.isRunnable(options.path)) {
108
+ if (!_langchain_core_runnables.Runnable.isRunnable(options.path)) {
111
109
  const pathDisplayValues = Array.isArray(options.pathMap) ? options.pathMap.join(",") : Object.keys(options.pathMap ?? {}).join(",");
112
- options.path = (0, __langchain_core_runnables._coerceToRunnable)(options.path).withConfig({ runName: `Branch<${options.source}${pathDisplayValues !== "" ? `,${pathDisplayValues}` : ""}>`.slice(0, 63) });
110
+ options.path = (0, _langchain_core_runnables._coerceToRunnable)(options.path).withConfig({ runName: `Branch<${options.source}${pathDisplayValues !== "" ? `,${pathDisplayValues}` : ""}>`.slice(0, 63) });
113
111
  }
114
112
  const name = options.path.getName() === "RunnableLambda" ? "condition" : options.path.getName();
115
113
  if (this.branches[options.source] && this.branches[options.source][name]) throw new Error(`Condition \`${name}\` already present for node \`${source}\``);
@@ -182,7 +180,7 @@ var Graph = class {
182
180
  };
183
181
  var CompiledGraph = class extends require_pregel_index.Pregel {
184
182
  builder;
185
- constructor({ builder,...rest }) {
183
+ constructor({ builder, ...rest }) {
186
184
  super(rest);
187
185
  this.builder = builder;
188
186
  }
@@ -215,14 +213,13 @@ var CompiledGraph = class extends require_pregel_index.Pregel {
215
213
  attachBranch(start, name, branch) {
216
214
  if (start === require_constants.START && !this.nodes[require_constants.START]) this.nodes[require_constants.START] = require_pregel_index.Channel.subscribeTo(require_constants.START, { tags: [require_constants.TAG_HIDDEN] });
217
215
  this.nodes[start].pipe(branch.run((dests) => {
218
- const writes = dests.map((dest) => {
216
+ return new require_write.ChannelWrite(dests.map((dest) => {
219
217
  if (require_constants._isSend(dest)) return dest;
220
218
  return {
221
219
  channel: dest === require_constants.END ? require_constants.END : `branch:${start}:${name}:${dest}`,
222
220
  value: require_write.PASSTHROUGH
223
221
  };
224
- });
225
- return new require_write.ChannelWrite(writes, [require_constants.TAG_HIDDEN]);
222
+ }), [require_constants.TAG_HIDDEN]);
226
223
  }));
227
224
  const ends = branch.ends ? Object.values(branch.ends) : Object.keys(this.nodes);
228
225
  for (const end of ends) if (end !== require_constants.END) {
@@ -237,7 +234,7 @@ var CompiledGraph = class extends require_pregel_index.Pregel {
237
234
  */
238
235
  async getGraphAsync(config) {
239
236
  const xray = config?.xray;
240
- const graph = new __langchain_core_runnables_graph.Graph();
237
+ const graph = new _langchain_core_runnables_graph.Graph();
241
238
  const startNodes = { [require_constants.START]: graph.addNode({ schema: zod_v4.z.any() }, require_constants.START) };
242
239
  const endNodes = {};
243
240
  let subgraphs = {};
@@ -327,7 +324,7 @@ var CompiledGraph = class extends require_pregel_index.Pregel {
327
324
  */
328
325
  getGraph(config) {
329
326
  const xray = config?.xray;
330
- const graph = new __langchain_core_runnables_graph.Graph();
327
+ const graph = new _langchain_core_runnables_graph.Graph();
331
328
  const startNodes = { [require_constants.START]: graph.addNode({ schema: zod_v4.z.any() }, require_constants.START) };
332
329
  const endNodes = {};
333
330
  let subgraphs = {};