@langchain/langgraph 1.3.6 → 1.4.0

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 (221) hide show
  1. package/dist/channels/base.cjs +78 -2
  2. package/dist/channels/base.cjs.map +1 -1
  3. package/dist/channels/base.d.cts +35 -2
  4. package/dist/channels/base.d.cts.map +1 -1
  5. package/dist/channels/base.d.ts +35 -2
  6. package/dist/channels/base.d.ts.map +1 -1
  7. package/dist/channels/base.js +77 -4
  8. package/dist/channels/base.js.map +1 -1
  9. package/dist/channels/delta.cjs +136 -0
  10. package/dist/channels/delta.cjs.map +1 -0
  11. package/dist/channels/delta.d.cts +99 -0
  12. package/dist/channels/delta.d.cts.map +1 -0
  13. package/dist/channels/delta.d.ts +99 -0
  14. package/dist/channels/delta.d.ts.map +1 -0
  15. package/dist/channels/delta.js +136 -0
  16. package/dist/channels/delta.js.map +1 -0
  17. package/dist/channels/index.cjs +5 -0
  18. package/dist/channels/index.d.cts +3 -2
  19. package/dist/channels/index.d.ts +3 -2
  20. package/dist/channels/index.js +3 -2
  21. package/dist/constants.cjs +62 -4
  22. package/dist/constants.cjs.map +1 -1
  23. package/dist/constants.d.cts +33 -2
  24. package/dist/constants.d.cts.map +1 -1
  25. package/dist/constants.d.ts +33 -2
  26. package/dist/constants.d.ts.map +1 -1
  27. package/dist/constants.js +59 -5
  28. package/dist/constants.js.map +1 -1
  29. package/dist/errors.cjs +128 -0
  30. package/dist/errors.cjs.map +1 -1
  31. package/dist/errors.d.cts +86 -1
  32. package/dist/errors.d.cts.map +1 -1
  33. package/dist/errors.d.ts +86 -1
  34. package/dist/errors.d.ts.map +1 -1
  35. package/dist/errors.js +123 -1
  36. package/dist/errors.js.map +1 -1
  37. package/dist/func/index.cjs +9 -2
  38. package/dist/func/index.cjs.map +1 -1
  39. package/dist/func/index.d.cts +14 -0
  40. package/dist/func/index.d.cts.map +1 -1
  41. package/dist/func/index.d.ts +14 -0
  42. package/dist/func/index.d.ts.map +1 -1
  43. package/dist/func/index.js +9 -2
  44. package/dist/func/index.js.map +1 -1
  45. package/dist/graph/graph.cjs +44 -7
  46. package/dist/graph/graph.cjs.map +1 -1
  47. package/dist/graph/graph.d.cts +24 -2
  48. package/dist/graph/graph.d.cts.map +1 -1
  49. package/dist/graph/graph.d.ts +24 -2
  50. package/dist/graph/graph.d.ts.map +1 -1
  51. package/dist/graph/graph.js +44 -7
  52. package/dist/graph/graph.js.map +1 -1
  53. package/dist/graph/index.d.ts +3 -3
  54. package/dist/graph/messages_reducer.cjs +55 -0
  55. package/dist/graph/messages_reducer.cjs.map +1 -1
  56. package/dist/graph/messages_reducer.d.cts +28 -1
  57. package/dist/graph/messages_reducer.d.cts.map +1 -1
  58. package/dist/graph/messages_reducer.d.ts +28 -1
  59. package/dist/graph/messages_reducer.d.ts.map +1 -1
  60. package/dist/graph/messages_reducer.js +56 -2
  61. package/dist/graph/messages_reducer.js.map +1 -1
  62. package/dist/graph/state.cjs +174 -7
  63. package/dist/graph/state.cjs.map +1 -1
  64. package/dist/graph/state.d.cts +193 -17
  65. package/dist/graph/state.d.cts.map +1 -1
  66. package/dist/graph/state.d.ts +193 -17
  67. package/dist/graph/state.d.ts.map +1 -1
  68. package/dist/graph/state.js +175 -8
  69. package/dist/graph/state.js.map +1 -1
  70. package/dist/graph/zod/schema.cjs +5 -0
  71. package/dist/graph/zod/schema.cjs.map +1 -1
  72. package/dist/graph/zod/schema.d.cts.map +1 -1
  73. package/dist/graph/zod/schema.d.ts.map +1 -1
  74. package/dist/graph/zod/schema.js +5 -0
  75. package/dist/graph/zod/schema.js.map +1 -1
  76. package/dist/index.cjs +11 -0
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.d.cts +11 -8
  79. package/dist/index.d.ts +11 -8
  80. package/dist/index.js +5 -3
  81. package/dist/index.js.map +1 -1
  82. package/dist/prebuilt/react_agent_executor.d.cts +1 -1
  83. package/dist/pregel/algo.cjs +182 -21
  84. package/dist/pregel/algo.cjs.map +1 -1
  85. package/dist/pregel/algo.d.cts +1 -1
  86. package/dist/pregel/algo.d.cts.map +1 -1
  87. package/dist/pregel/algo.d.ts +1 -1
  88. package/dist/pregel/algo.d.ts.map +1 -1
  89. package/dist/pregel/algo.js +185 -25
  90. package/dist/pregel/algo.js.map +1 -1
  91. package/dist/pregel/call.cjs +2 -1
  92. package/dist/pregel/call.cjs.map +1 -1
  93. package/dist/pregel/call.js +2 -1
  94. package/dist/pregel/call.js.map +1 -1
  95. package/dist/pregel/index.cjs +15 -3
  96. package/dist/pregel/index.cjs.map +1 -1
  97. package/dist/pregel/index.d.cts.map +1 -1
  98. package/dist/pregel/index.d.ts.map +1 -1
  99. package/dist/pregel/index.js +17 -5
  100. package/dist/pregel/index.js.map +1 -1
  101. package/dist/pregel/loop.cjs +362 -41
  102. package/dist/pregel/loop.cjs.map +1 -1
  103. package/dist/pregel/loop.js +365 -44
  104. package/dist/pregel/loop.js.map +1 -1
  105. package/dist/pregel/messages-v2.cjs +1 -1
  106. package/dist/pregel/messages-v2.js +1 -1
  107. package/dist/pregel/messages.cjs +1 -1
  108. package/dist/pregel/messages.js +1 -1
  109. package/dist/pregel/read.cjs +15 -5
  110. package/dist/pregel/read.cjs.map +1 -1
  111. package/dist/pregel/read.d.cts +9 -0
  112. package/dist/pregel/read.d.cts.map +1 -1
  113. package/dist/pregel/read.d.ts +9 -0
  114. package/dist/pregel/read.d.ts.map +1 -1
  115. package/dist/pregel/read.js +15 -5
  116. package/dist/pregel/read.js.map +1 -1
  117. package/dist/pregel/remote-run-stream.cjs +107 -0
  118. package/dist/pregel/remote-run-stream.cjs.map +1 -0
  119. package/dist/pregel/remote-run-stream.d.cts +33 -0
  120. package/dist/pregel/remote-run-stream.d.cts.map +1 -0
  121. package/dist/pregel/remote-run-stream.d.ts +33 -0
  122. package/dist/pregel/remote-run-stream.d.ts.map +1 -0
  123. package/dist/pregel/remote-run-stream.js +107 -0
  124. package/dist/pregel/remote-run-stream.js.map +1 -0
  125. package/dist/pregel/remote.cjs +61 -1
  126. package/dist/pregel/remote.cjs.map +1 -1
  127. package/dist/pregel/remote.d.cts +17 -0
  128. package/dist/pregel/remote.d.cts.map +1 -1
  129. package/dist/pregel/remote.d.ts +17 -0
  130. package/dist/pregel/remote.d.ts.map +1 -1
  131. package/dist/pregel/remote.js +61 -1
  132. package/dist/pregel/remote.js.map +1 -1
  133. package/dist/pregel/replay.cjs +62 -0
  134. package/dist/pregel/replay.cjs.map +1 -0
  135. package/dist/pregel/replay.js +62 -0
  136. package/dist/pregel/replay.js.map +1 -0
  137. package/dist/pregel/retry.cjs +8 -6
  138. package/dist/pregel/retry.cjs.map +1 -1
  139. package/dist/pregel/retry.js +8 -6
  140. package/dist/pregel/retry.js.map +1 -1
  141. package/dist/pregel/runnable_types.d.cts +20 -0
  142. package/dist/pregel/runnable_types.d.cts.map +1 -1
  143. package/dist/pregel/runnable_types.d.ts +20 -0
  144. package/dist/pregel/runnable_types.d.ts.map +1 -1
  145. package/dist/pregel/runner.cjs +48 -7
  146. package/dist/pregel/runner.cjs.map +1 -1
  147. package/dist/pregel/runner.js +50 -9
  148. package/dist/pregel/runner.js.map +1 -1
  149. package/dist/pregel/runtime.cjs +64 -0
  150. package/dist/pregel/runtime.cjs.map +1 -0
  151. package/dist/pregel/runtime.d.cts +57 -0
  152. package/dist/pregel/runtime.d.cts.map +1 -0
  153. package/dist/pregel/runtime.d.ts +57 -0
  154. package/dist/pregel/runtime.d.ts.map +1 -0
  155. package/dist/pregel/runtime.js +64 -0
  156. package/dist/pregel/runtime.js.map +1 -0
  157. package/dist/pregel/stream.cjs +2 -0
  158. package/dist/pregel/stream.cjs.map +1 -1
  159. package/dist/pregel/stream.js +2 -0
  160. package/dist/pregel/stream.js.map +1 -1
  161. package/dist/pregel/timeout.cjs +216 -0
  162. package/dist/pregel/timeout.cjs.map +1 -0
  163. package/dist/pregel/timeout.js +216 -0
  164. package/dist/pregel/timeout.js.map +1 -0
  165. package/dist/pregel/types.cjs +3 -1
  166. package/dist/pregel/types.cjs.map +1 -1
  167. package/dist/pregel/types.d.cts +13 -0
  168. package/dist/pregel/types.d.cts.map +1 -1
  169. package/dist/pregel/types.d.ts +14 -1
  170. package/dist/pregel/types.d.ts.map +1 -1
  171. package/dist/pregel/types.js +3 -1
  172. package/dist/pregel/types.js.map +1 -1
  173. package/dist/pregel/utils/config.cjs +3 -1
  174. package/dist/pregel/utils/config.cjs.map +1 -1
  175. package/dist/pregel/utils/config.d.cts.map +1 -1
  176. package/dist/pregel/utils/config.d.ts.map +1 -1
  177. package/dist/pregel/utils/config.js +3 -1
  178. package/dist/pregel/utils/config.js.map +1 -1
  179. package/dist/pregel/utils/index.cjs +1 -0
  180. package/dist/pregel/utils/index.cjs.map +1 -1
  181. package/dist/pregel/utils/index.d.cts +6 -1
  182. package/dist/pregel/utils/index.d.cts.map +1 -1
  183. package/dist/pregel/utils/index.d.ts +6 -1
  184. package/dist/pregel/utils/index.d.ts.map +1 -1
  185. package/dist/pregel/utils/index.js +1 -0
  186. package/dist/pregel/utils/index.js.map +1 -1
  187. package/dist/pregel/utils/timeout.cjs +34 -0
  188. package/dist/pregel/utils/timeout.cjs.map +1 -0
  189. package/dist/pregel/utils/timeout.d.cts +45 -0
  190. package/dist/pregel/utils/timeout.d.cts.map +1 -0
  191. package/dist/pregel/utils/timeout.d.ts +45 -0
  192. package/dist/pregel/utils/timeout.d.ts.map +1 -0
  193. package/dist/pregel/utils/timeout.js +34 -0
  194. package/dist/pregel/utils/timeout.js.map +1 -0
  195. package/dist/stream/index.cjs +1 -0
  196. package/dist/stream/index.d.cts +2 -1
  197. package/dist/stream/index.d.ts +2 -1
  198. package/dist/stream/index.js +1 -0
  199. package/dist/stream/stream-channel.d.cts +9 -1
  200. package/dist/stream/stream-channel.d.cts.map +1 -1
  201. package/dist/stream/stream-channel.d.ts +9 -1
  202. package/dist/stream/stream-channel.d.ts.map +1 -1
  203. package/dist/stream/subscription.cjs +136 -0
  204. package/dist/stream/subscription.cjs.map +1 -0
  205. package/dist/stream/subscription.d.cts +94 -0
  206. package/dist/stream/subscription.d.cts.map +1 -0
  207. package/dist/stream/subscription.d.ts +94 -0
  208. package/dist/stream/subscription.d.ts.map +1 -0
  209. package/dist/stream/subscription.js +131 -0
  210. package/dist/stream/subscription.js.map +1 -0
  211. package/dist/stream/types.d.cts +1 -1
  212. package/dist/stream/types.d.ts +1 -1
  213. package/dist/stream.cjs +16 -0
  214. package/dist/stream.d.cts +5 -0
  215. package/dist/stream.d.ts +5 -0
  216. package/dist/stream.js +4 -0
  217. package/dist/web.cjs +11 -0
  218. package/dist/web.d.cts +11 -8
  219. package/dist/web.d.ts +11 -8
  220. package/dist/web.js +5 -3
  221. package/package.json +18 -6
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\n\n/** Special reserved node name denoting the start of a graph. */\nexport const START = \"__start__\";\n/** Special reserved node name denoting the end of a graph. */\nexport const END = \"__end__\";\nexport const INPUT = \"__input__\";\nexport const COPY = \"__copy__\";\nexport const ERROR = \"__error__\";\n\n/** Special reserved cache namespaces */\nexport const CACHE_NS_WRITES = \"__pregel_ns_writes\";\n\nexport const CONFIG_KEY_SEND = \"__pregel_send\";\n/** config key containing function used to call a node (push task) */\nexport const CONFIG_KEY_CALL = \"__pregel_call\";\nexport const CONFIG_KEY_READ = \"__pregel_read\";\nexport const CONFIG_KEY_CHECKPOINTER = \"__pregel_checkpointer\";\nexport const CONFIG_KEY_RESUMING = \"__pregel_resuming\";\nexport const CONFIG_KEY_TASK_ID = \"__pregel_task_id\";\nexport const CONFIG_KEY_STREAM = \"__pregel_stream\";\nexport const CONFIG_KEY_RESUME_VALUE = \"__pregel_resume_value\";\nexport const CONFIG_KEY_RESUME_MAP = \"__pregel_resume_map\";\nexport const CONFIG_KEY_SCRATCHPAD = \"__pregel_scratchpad\";\n/** config key containing state from previous invocation of graph for the given thread */\nexport const CONFIG_KEY_PREVIOUS_STATE = \"__pregel_previous\";\nexport const CONFIG_KEY_DURABILITY = \"__pregel_durability\";\nexport const CONFIG_KEY_CHECKPOINT_ID = \"checkpoint_id\";\nexport const CONFIG_KEY_CHECKPOINT_NS = \"checkpoint_ns\";\n\nexport const CONFIG_KEY_NODE_FINISHED = \"__pregel_node_finished\";\n\n// this one is part of public API\nexport const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\n\nexport const CONFIG_KEY_ABORT_SIGNALS = \"__pregel_abort_signals\";\n\n/** Special channel reserved for graph interrupts */\nexport const INTERRUPT = \"__interrupt__\";\n/** Special channel reserved for graph resume */\nexport const RESUME = \"__resume__\";\n/** Special channel reserved for cases when a task exits without any writes */\nexport const NO_WRITES = \"__no_writes__\";\n/** Special channel reserved for graph return */\nexport const RETURN = \"__return__\";\n/** Special channel reserved for graph previous state */\nexport const PREVIOUS = \"__previous__\";\nexport const RUNTIME_PLACEHOLDER = \"__pregel_runtime_placeholder__\";\nexport const RECURSION_LIMIT_DEFAULT = 25;\n\nexport const TAG_HIDDEN = \"langsmith:hidden\";\nexport const TAG_NOSTREAM = \"langsmith:nostream\";\nexport const SELF = \"__self__\";\n\nexport const TASKS = \"__pregel_tasks\";\nexport const PUSH = \"__pregel_push\";\nexport const PULL = \"__pregel_pull\";\n\nexport const TASK_NAMESPACE = \"6ba7b831-9dad-11d1-80b4-00c04fd430c8\";\nexport const NULL_TASK_ID = \"00000000-0000-0000-0000-000000000000\";\n\nexport const RESERVED = [\n TAG_HIDDEN,\n INPUT,\n INTERRUPT,\n RESUME,\n ERROR,\n NO_WRITES,\n\n // reserved config.configurable keys\n CONFIG_KEY_SEND,\n CONFIG_KEY_READ,\n CONFIG_KEY_CHECKPOINTER,\n CONFIG_KEY_DURABILITY,\n CONFIG_KEY_STREAM,\n CONFIG_KEY_RESUMING,\n CONFIG_KEY_TASK_ID,\n CONFIG_KEY_CALL,\n CONFIG_KEY_RESUME_VALUE,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_PREVIOUS_STATE,\n CONFIG_KEY_CHECKPOINT_MAP,\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_CHECKPOINT_ID,\n];\n\nexport const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport const CHECKPOINT_NAMESPACE_END = \":\";\n\n/**\n * Symbol used internally to identify Command instances.\n * Exported to support cross-version type compatibility.\n * @internal\n */\nexport const COMMAND_SYMBOL = Symbol.for(\"langgraph.command\");\n\n/**\n * Instance of a {@link Command} class.\n *\n * This is used to avoid IntelliSense suggesting public fields\n * of {@link Command} class when a plain object is expected.\n *\n * @see {@link Command}\n * @internal\n */\nexport class CommandInstance<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string,\n> {\n [COMMAND_SYMBOL]: CommandParams<Resume, Update, Nodes>;\n\n constructor(args: CommandParams<Resume, Update, Nodes>) {\n this[COMMAND_SYMBOL] = args;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SendInterface<Node extends string = string, Args = any> {\n node: Node;\n args: Args;\n}\n\nexport function _isSendInterface(x: unknown): x is SendInterface {\n const operation = x as SendInterface;\n return (\n operation !== null &&\n operation !== undefined &&\n typeof operation.node === \"string\" &&\n operation.args !== undefined\n );\n}\n\n/**\n *\n * A message or packet to send to a specific node in the graph.\n *\n * The `Send` class is used within a `StateGraph`'s conditional edges to\n * dynamically invoke a node with a custom state at the next step.\n *\n * Importantly, the sent state can differ from the core graph's state,\n * allowing for flexible and dynamic workflow management.\n *\n * One such example is a \"map-reduce\" workflow where your graph invokes\n * the same node multiple times in parallel with different states,\n * before aggregating the results back into the main graph's state.\n *\n * @example\n * ```typescript\n * import { Annotation, Send, StateGraph } from \"@langchain/langgraph\";\n *\n * const ChainState = Annotation.Root({\n * subjects: Annotation<string[]>,\n * jokes: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * }),\n * });\n *\n * const continueToJokes = async (state: typeof ChainState.State) => {\n * return state.subjects.map((subject) => {\n * return new Send(\"generate_joke\", { subjects: [subject] });\n * });\n * };\n *\n * const graph = new StateGraph(ChainState)\n * .addNode(\"generate_joke\", (state) => ({\n * jokes: [`Joke about ${state.subjects}`],\n * }))\n * .addConditionalEdges(\"__start__\", continueToJokes)\n * .addEdge(\"generate_joke\", \"__end__\")\n * .compile();\n *\n * const res = await graph.invoke({ subjects: [\"cats\", \"dogs\"] });\n * console.log(res);\n *\n * // Invoking with two subjects results in a generated joke for each\n * // { subjects: [\"cats\", \"dogs\"], jokes: [`Joke about cats`, `Joke about dogs`] }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Send<\n Node extends string = string,\n Args = any,\n> implements SendInterface<Node, Args> {\n lg_name = \"Send\";\n\n public node: Node;\n\n public args: Args;\n\n constructor(node: Node, args: Args) {\n this.node = node;\n this.args = _deserializeCommandSendObjectGraph(args) as Args;\n }\n\n toJSON() {\n return { lg_name: this.lg_name, node: this.node, args: this.args };\n }\n}\n\nexport function _isSend(x: unknown): x is Send {\n // eslint-disable-next-line no-instanceof/no-instanceof\n return x instanceof Send;\n}\n\nexport const OVERWRITE = \"__overwrite__\";\n\n/**\n * An object representing a direct overwrite of a value for a channel.\n * Used to signal that the channel value should be replaced with the given value,\n * bypassing any reducer or binary operator logic.\n *\n * @template ValueType - The type of the value being overwritten.\n * @property {ValueType} [OVERWRITE] - The value to directly set.\n *\n * @example\n * const overwriteObj: OverwriteValue<number> = { __overwrite__: 123 };\n */\nexport interface OverwriteValue<ValueType> {\n [OVERWRITE]: ValueType;\n}\n\n/**\n * Bypass a reducer and write the wrapped value directly to a\n * {@link BinaryOperatorAggregate} channel.\n *\n * Receiving multiple `Overwrite` values for the same channel in a single\n * super-step will raise an {@link InvalidUpdateError}.\n *\n * @example\n * ```typescript\n * import { Annotation, StateGraph, Overwrite } from \"@langchain/langgraph\";\n *\n * const State = Annotation.Root({\n * messages: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * default: () => [],\n * }),\n * });\n *\n * const replaceMessages = (_state: typeof State.State) => {\n * return { messages: new Overwrite([\"replacement\"]) };\n * };\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Overwrite<ValueType = any> implements OverwriteValue<ValueType> {\n lg_name = \"Overwrite\";\n\n readonly [OVERWRITE]: ValueType;\n\n constructor(value: ValueType) {\n this[OVERWRITE] = value;\n }\n\n get value(): ValueType {\n return this[OVERWRITE];\n }\n\n toJSON() {\n return { [OVERWRITE]: this[OVERWRITE] };\n }\n\n static isInstance<ValueType>(value: unknown): value is Overwrite<ValueType> {\n if (!value || typeof value !== \"object\") return false;\n if (OVERWRITE in value) return true;\n if (\"lg_name\" in value && value.lg_name === \"Overwrite\") return true;\n return false;\n }\n}\n\n/**\n * Helper function to detect and extract the value from an Overwrite wrapper,\n * supporting both the Overwrite class instance and the serialized object format.\n *\n * Use to check if a provided value represents an Overwrite: returns the\n * unwrapped value if so, or undefined otherwise.\n *\n * - If the value is an Overwrite instance (preferred API), return its `.value`.\n * - If the value is a wire-format object ({ [OVERWRITE]: value }), extract it.\n * - Otherwise, returns undefined.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns The unwrapped value if value is an Overwrite, or undefined otherwise.\n * @internal\n */\nexport function _getOverwriteValue<ValueType>(\n value: unknown\n): [true, ValueType] | [false, undefined] {\n if (typeof value === \"object\" && value !== null && OVERWRITE in value) {\n return [true, (value as Record<string, ValueType>)[OVERWRITE]];\n }\n return [false, undefined];\n}\n\n/**\n * Type guard to check if a value is an Overwrite value -- either the class\n * instance or the wire format object.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns `true` if the value is an Overwrite value, `false` otherwise.\n * @internal\n */\nexport function _isOverwriteValue<ValueType>(\n value: unknown\n): value is OverwriteValue<ValueType> {\n return _getOverwriteValue<ValueType>(value)[0];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Interrupt<Value = any> = {\n id?: string;\n value?: Value;\n};\n\n/**\n * Checks if the given graph invoke / stream chunk contains interrupt.\n *\n * @example\n * ```ts\n * import { INTERRUPT, isInterrupted } from \"@langchain/langgraph\";\n *\n * const values = await graph.invoke({ foo: \"bar\" });\n * if (isInterrupted<string>(values)) {\n * const interrupt = values[INTERRUPT][0].value;\n * }\n * ```\n *\n * @param values - The values to check.\n * @returns `true` if the values contain an interrupt, `false` otherwise.\n */\nexport function isInterrupted<Value = unknown>(\n values: unknown\n): values is { [INTERRUPT]: Interrupt<Value>[] } {\n if (!values || typeof values !== \"object\") return false;\n if (!(INTERRUPT in values)) return false;\n return Array.isArray(values[INTERRUPT]);\n}\n\nexport type CommandParams<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string,\n> = {\n /**\n * A discriminator field used to identify the type of object. Must be populated when serializing.\n *\n * Optional because it's not required to specify this when directly constructing a {@link Command}\n * object.\n */\n lg_name?: \"Command\";\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - `Send` object (to execute a node with the input provided)\n * - sequence of `Send` objects\n */\n goto?:\n | Nodes\n | SendInterface<Nodes> // eslint-disable-line @typescript-eslint/no-explicit-any\n | (Nodes | SendInterface<Nodes>)[]; // eslint-disable-line @typescript-eslint/no-explicit-any\n};\n\n/**\n * One or more commands to update the graph's state and send messages to nodes.\n * Can be used to combine routing logic with state updates in lieu of conditional edges\n *\n * @example\n * ```ts\n * import { Annotation, Command } from \"@langchain/langgraph\";\n *\n * // Define graph state\n * const StateAnnotation = Annotation.Root({\n * foo: Annotation<string>,\n * });\n *\n * // Define the nodes\n * const nodeA = async (_state: typeof StateAnnotation.State) => {\n * console.log(\"Called A\");\n * // this is a replacement for a real conditional edge function\n * const goto = Math.random() > .5 ? \"nodeB\" : \"nodeC\";\n * // note how Command allows you to BOTH update the graph state AND route to the next node\n * return new Command({\n * // this is the state update\n * update: {\n * foo: \"a\",\n * },\n * // this is a replacement for an edge\n * goto,\n * });\n * };\n *\n * // Nodes B and C are unchanged\n * const nodeB = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called B\");\n * return {\n * foo: state.foo + \"|b\",\n * };\n * }\n *\n * const nodeC = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called C\");\n * return {\n * foo: state.foo + \"|c\",\n * };\n * }\n * \n * import { StateGraph } from \"@langchain/langgraph\";\n\n * // NOTE: there are no edges between nodes A, B and C!\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(\"nodeA\", nodeA, {\n * ends: [\"nodeB\", \"nodeC\"],\n * })\n * .addNode(\"nodeB\", nodeB)\n * .addNode(\"nodeC\", nodeC)\n * .addEdge(\"__start__\", \"nodeA\")\n * .compile();\n * \n * await graph.invoke({ foo: \"\" });\n *\n * // Randomly oscillates between\n * // { foo: 'a|c' } and { foo: 'a|b' }\n * ```\n */\nexport class Command<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string,\n> extends CommandInstance<Resume, Update, Nodes> {\n readonly lg_name = \"Command\";\n\n lc_direct_tool_output = true;\n\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state as a result of executing the node that is returning the command.\n * Written to the state as if the node had simply returned this value instead of the Command object.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)\n * - sequence of {@link Send} objects\n */\n goto?: Nodes | Send<Nodes> | (Nodes | Send<Nodes>)[] = [];\n\n static PARENT = \"__parent__\";\n\n constructor(args: Omit<CommandParams<Resume, Update, Nodes>, \"lg_name\">) {\n super(args);\n this.resume = args.resume;\n this.graph = args.graph;\n this.update = args.update;\n if (args.goto) {\n type ValidArg = Nodes | Send<Nodes, Update>;\n\n this.goto = Array.isArray(args.goto)\n ? (_deserializeCommandSendObjectGraph(args.goto) as ValidArg[])\n : [_deserializeCommandSendObjectGraph(args.goto) as ValidArg];\n }\n }\n\n /**\n * Convert the update field to a list of {@link PendingWrite} tuples\n * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.\n * @internal\n */\n _updateAsTuples(): PendingWrite[] {\n if (\n this.update &&\n typeof this.update === \"object\" &&\n !Array.isArray(this.update)\n ) {\n return Object.entries(this.update);\n } else if (\n Array.isArray(this.update) &&\n this.update.every(\n (t): t is [string, unknown] =>\n Array.isArray(t) && t.length === 2 && typeof t[0] === \"string\"\n )\n ) {\n return this.update;\n } else {\n return [[\"__root__\", this.update]];\n }\n }\n\n toJSON() {\n let serializedGoto;\n if (typeof this.goto === \"string\") {\n serializedGoto = this.goto;\n } else if (_isSend(this.goto)) {\n serializedGoto = this.goto.toJSON();\n } else {\n serializedGoto = this.goto?.map((innerGoto) => {\n if (typeof innerGoto === \"string\") {\n return innerGoto;\n } else {\n return innerGoto.toJSON();\n }\n });\n }\n return {\n lg_name: this.lg_name,\n update: this.update,\n resume: this.resume,\n goto: serializedGoto,\n };\n }\n}\n\n/**\n * A type guard to check if the given value is a {@link Command}.\n *\n * Useful for type narrowing when working with the {@link Command} object.\n *\n * @param x - The value to check.\n * @returns `true` if the value is a {@link Command}, `false` otherwise.\n */\nexport function isCommand(x: unknown): x is Command {\n if (typeof x !== \"object\") {\n return false;\n }\n\n if (x === null || x === undefined) {\n return false;\n }\n\n if (\"lg_name\" in x && x.lg_name === \"Command\") {\n return true;\n }\n\n return false;\n}\n\nfunction isPlainObject(value: object): value is Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\n/**\n * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects\n * matching their interfaces.\n *\n * This is only exported for testing purposes. It is NOT intended to be used outside of\n * the Command and Send classes.\n *\n * @internal\n *\n * @param x - The command send tree to convert.\n * @param seen - A map of seen objects to avoid infinite loops.\n * @returns The converted command send tree.\n */\nexport function _deserializeCommandSendObjectGraph(\n x: unknown,\n seen: Map<object, unknown> = new Map()\n): unknown {\n if (x !== undefined && x !== null && typeof x === \"object\") {\n // If we've already processed this object, return the transformed version\n if (seen.has(x)) {\n return seen.get(x);\n }\n\n let result: unknown;\n\n if (Array.isArray(x)) {\n // Create the array first, then populate it\n result = [];\n // Add to seen map before processing elements to handle self-references\n seen.set(x, result);\n\n // Now populate the array\n x.forEach((item, index) => {\n (result as unknown[])[index] = _deserializeCommandSendObjectGraph(\n item,\n seen\n );\n });\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (x instanceof Command || x instanceof Send || !isPlainObject(x)) {\n result = x;\n seen.set(x, result);\n } else if (isCommand(x)) {\n result = new Command(x);\n seen.set(x, result);\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (_isSendInterface(x)) {\n result = new Send(x.node, x.args);\n seen.set(x, result);\n } else if (\"lc_serializable\" in x && x.lc_serializable) {\n result = x;\n seen.set(x, result);\n } else {\n // Create empty object first\n result = {};\n // Add to seen map before processing properties to handle self-references\n seen.set(x, result);\n\n // Now populate the object\n for (const [key, value] of Object.entries(x)) {\n (result as Record<string, unknown>)[key] =\n _deserializeCommandSendObjectGraph(value, seen);\n }\n }\n\n return result;\n }\n return x;\n}\n"],"mappings":";;AAGA,MAAa,QAAQ;;AAErB,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KAAA,KAAa,MAAM,QAAQ,OAAO,MAAM,UAAU;AAE1D,MAAI,KAAK,IAAI,EAAE,CACb,QAAO,KAAK,IAAI,EAAE;EAGpB,IAAI;AAEJ,MAAI,MAAM,QAAQ,EAAE,EAAE;AAEpB,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,KAAE,SAAS,MAAM,UAAU;AACxB,WAAqB,SAAS,mCAC7B,MACA,KACD;KACD;aAEO,aAAa,WAAW,aAAa,QAAQ,CAAC,cAAc,EAAE,EAAE;AACzE,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;aACV,UAAU,EAAE,EAAE;AACvB,YAAS,IAAI,QAAQ,EAAE;AACvB,QAAK,IAAI,GAAG,OAAO;aAEV,iBAAiB,EAAE,EAAE;AAC9B,YAAS,IAAI,KAAK,EAAE,MAAM,EAAE,KAAK;AACjC,QAAK,IAAI,GAAG,OAAO;aACV,qBAAqB,KAAK,EAAE,iBAAiB;AACtD,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;SACd;AAEL,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,EAAE,CACzC,QAAmC,OAClC,mCAAmC,OAAO,KAAK;;AAIrD,SAAO;;AAET,QAAO"}
1
+ {"version":3,"file":"constants.cjs","names":["coerceTimeoutPolicy"],"sources":["../src/constants.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\nimport {\n coerceTimeoutPolicy,\n type TimeoutPolicy,\n} from \"./pregel/utils/timeout.js\";\n\n/** Special reserved node name denoting the start of a graph. */\nexport const START = \"__start__\";\n/** Special reserved node name denoting the end of a graph. */\nexport const END = \"__end__\";\nexport const INPUT = \"__input__\";\nexport const COPY = \"__copy__\";\nexport const ERROR = \"__error__\";\n/**\n * Special reserved write key recording the name of the node whose execution\n * failed, so node-level error handlers see the same failure provenance after a\n * checkpoint resume. Value format in pending writes:\n * `[taskId, ERROR_SOURCE_NODE, nodeName: string]`.\n */\nexport const ERROR_SOURCE_NODE = \"__error_source_node__\";\n\n/** Special reserved cache namespaces */\nexport const CACHE_NS_WRITES = \"__pregel_ns_writes\";\n\n/**\n * System-wide upper bound on how many supersteps a {@link DeltaChannel} may go\n * without writing a {@link DeltaSnapshot} blob. Once a channel's\n * supersteps-since-snapshot counter reaches this value, a snapshot is forced\n * even if the channel's own `snapshotFrequency` has not been reached — this\n * prevents unbounded ancestor walks on threads where a delta channel exists\n * but is no longer being updated.\n *\n * Overridable via the `LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT`\n * environment variable. Read lazily so test/runtime overrides take effect.\n *\n * @remarks Beta.\n */\nexport function getDeltaMaxSuperstepsSinceSnapshot(): number {\n const raw =\n typeof process !== \"undefined\"\n ? process.env?.LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT\n : undefined;\n if (raw !== undefined && raw !== \"\") {\n const parsed = Number.parseInt(raw, 10);\n if (Number.isFinite(parsed) && parsed > 0) return parsed;\n }\n return 5000;\n}\n\nexport const CONFIG_KEY_SEND = \"__pregel_send\";\n/** config key containing function used to call a node (push task) */\nexport const CONFIG_KEY_CALL = \"__pregel_call\";\nexport const CONFIG_KEY_READ = \"__pregel_read\";\nexport const CONFIG_KEY_CHECKPOINTER = \"__pregel_checkpointer\";\nexport const CONFIG_KEY_RESUMING = \"__pregel_resuming\";\nexport const CONFIG_KEY_TASK_ID = \"__pregel_task_id\";\nexport const CONFIG_KEY_STREAM = \"__pregel_stream\";\nexport const CONFIG_KEY_RESUME_VALUE = \"__pregel_resume_value\";\nexport const CONFIG_KEY_RESUME_MAP = \"__pregel_resume_map\";\nexport const CONFIG_KEY_SCRATCHPAD = \"__pregel_scratchpad\";\n/** config key containing state from previous invocation of graph for the given thread */\nexport const CONFIG_KEY_PREVIOUS_STATE = \"__pregel_previous\";\nexport const CONFIG_KEY_DURABILITY = \"__pregel_durability\";\nexport const CONFIG_KEY_CHECKPOINT_ID = \"checkpoint_id\";\nexport const CONFIG_KEY_CHECKPOINT_NS = \"checkpoint_ns\";\n\nexport const CONFIG_KEY_NODE_FINISHED = \"__pregel_node_finished\";\n\n/**\n * Config key holding a {@link NodeError} (failed source node + error) for the\n * current node-level error handler invocation. Injected when an error handler\n * task is prepared after the failing node's retry policy is exhausted.\n */\nexport const CONFIG_KEY_NODE_ERROR = \"__pregel_node_error\";\n\n// this one is part of public API\nexport const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\n\nexport const CONFIG_KEY_REPLAY_STATE = \"__pregel_replay_state\";\n\nexport const CONFIG_KEY_ABORT_SIGNALS = \"__pregel_abort_signals\";\n\n/** Special channel reserved for graph interrupts */\nexport const INTERRUPT = \"__interrupt__\";\n/** Special channel reserved for graph resume */\nexport const RESUME = \"__resume__\";\n/** Special channel reserved for cases when a task exits without any writes */\nexport const NO_WRITES = \"__no_writes__\";\n/** Special channel reserved for graph return */\nexport const RETURN = \"__return__\";\n/** Special channel reserved for graph previous state */\nexport const PREVIOUS = \"__previous__\";\nexport const RUNTIME_PLACEHOLDER = \"__pregel_runtime_placeholder__\";\nexport const RECURSION_LIMIT_DEFAULT = 25;\n\nexport const TAG_HIDDEN = \"langsmith:hidden\";\nexport const TAG_NOSTREAM = \"langsmith:nostream\";\nexport const SELF = \"__self__\";\n\nexport const TASKS = \"__pregel_tasks\";\nexport const PUSH = \"__pregel_push\";\nexport const PULL = \"__pregel_pull\";\n\nexport const TASK_NAMESPACE = \"6ba7b831-9dad-11d1-80b4-00c04fd430c8\";\nexport const NULL_TASK_ID = \"00000000-0000-0000-0000-000000000000\";\n\nexport const RESERVED = [\n TAG_HIDDEN,\n INPUT,\n INTERRUPT,\n RESUME,\n ERROR,\n ERROR_SOURCE_NODE,\n NO_WRITES,\n\n // reserved config.configurable keys\n CONFIG_KEY_SEND,\n CONFIG_KEY_READ,\n CONFIG_KEY_CHECKPOINTER,\n CONFIG_KEY_DURABILITY,\n CONFIG_KEY_STREAM,\n CONFIG_KEY_RESUMING,\n CONFIG_KEY_TASK_ID,\n CONFIG_KEY_CALL,\n CONFIG_KEY_RESUME_VALUE,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_PREVIOUS_STATE,\n CONFIG_KEY_CHECKPOINT_MAP,\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_CHECKPOINT_ID,\n CONFIG_KEY_REPLAY_STATE,\n];\n\nexport const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport const CHECKPOINT_NAMESPACE_END = \":\";\n\n/**\n * Symbol used internally to identify Command instances.\n * Exported to support cross-version type compatibility.\n * @internal\n */\nexport const COMMAND_SYMBOL = Symbol.for(\"langgraph.command\");\n\n/**\n * Instance of a {@link Command} class.\n *\n * This is used to avoid IntelliSense suggesting public fields\n * of {@link Command} class when a plain object is expected.\n *\n * @see {@link Command}\n * @internal\n */\nexport class CommandInstance<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string,\n> {\n [COMMAND_SYMBOL]: CommandParams<Resume, Update, Nodes>;\n\n constructor(args: CommandParams<Resume, Update, Nodes>) {\n this[COMMAND_SYMBOL] = args;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SendInterface<Node extends string = string, Args = any> {\n node: Node;\n args: Args;\n /**\n * Optional per-task timeout policy that overrides the target node's timeout\n * for this specific pushed task.\n */\n timeout?: TimeoutPolicy;\n}\n\n/** Keyword options for {@link Send}. */\nexport type SendOptions = {\n /**\n * Per-task timeout policy overriding the target node's timeout for this\n * pushed task. A bare number is treated as `runTimeout` (milliseconds).\n */\n timeout?: number | TimeoutPolicy;\n};\n\nexport function _isSendInterface(x: unknown): x is SendInterface {\n const operation = x as SendInterface;\n return (\n operation !== null &&\n operation !== undefined &&\n typeof operation.node === \"string\" &&\n operation.args !== undefined\n );\n}\n\n/**\n *\n * A message or packet to send to a specific node in the graph.\n *\n * The `Send` class is used within a `StateGraph`'s conditional edges to\n * dynamically invoke a node with a custom state at the next step.\n *\n * Importantly, the sent state can differ from the core graph's state,\n * allowing for flexible and dynamic workflow management.\n *\n * One such example is a \"map-reduce\" workflow where your graph invokes\n * the same node multiple times in parallel with different states,\n * before aggregating the results back into the main graph's state.\n *\n * @example\n * ```typescript\n * import { Annotation, Send, StateGraph } from \"@langchain/langgraph\";\n *\n * const ChainState = Annotation.Root({\n * subjects: Annotation<string[]>,\n * jokes: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * }),\n * });\n *\n * const continueToJokes = async (state: typeof ChainState.State) => {\n * return state.subjects.map((subject) => {\n * return new Send(\"generate_joke\", { subjects: [subject] });\n * });\n * };\n *\n * @remarks\n * A per-task timeout can be supplied via the third argument's `timeout` option\n * to override the target node's configured timeout for this specific pushed task:\n *\n * ```typescript\n * new Send(\"generate_joke\", { subjects: [subject] }, { timeout: { idleTimeout: 5000 } });\n * ```\n *\n * const graph = new StateGraph(ChainState)\n * .addNode(\"generate_joke\", (state) => ({\n * jokes: [`Joke about ${state.subjects}`],\n * }))\n * .addConditionalEdges(\"__start__\", continueToJokes)\n * .addEdge(\"generate_joke\", \"__end__\")\n * .compile();\n *\n * const res = await graph.invoke({ subjects: [\"cats\", \"dogs\"] });\n * console.log(res);\n *\n * // Invoking with two subjects results in a generated joke for each\n * // { subjects: [\"cats\", \"dogs\"], jokes: [`Joke about cats`, `Joke about dogs`] }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Send<\n Node extends string = string,\n Args = any,\n> implements SendInterface<Node, Args> {\n lg_name = \"Send\";\n\n public node: Node;\n\n public args: Args;\n\n /**\n * Optional per-task timeout policy that overrides the target node's timeout\n * for this specific pushed task. A bare number is treated as a hard\n * `runTimeout` (in milliseconds).\n */\n public timeout?: TimeoutPolicy;\n\n constructor(node: Node, args: Args, options?: SendOptions) {\n this.node = node;\n this.args = _deserializeCommandSendObjectGraph(args) as Args;\n this.timeout = coerceTimeoutPolicy(options?.timeout);\n }\n\n toJSON() {\n return {\n lg_name: this.lg_name,\n node: this.node,\n args: this.args,\n timeout: this.timeout,\n };\n }\n}\n\nexport function _isSend(x: unknown): x is Send {\n // eslint-disable-next-line no-instanceof/no-instanceof\n return x instanceof Send;\n}\n\nexport const OVERWRITE = \"__overwrite__\";\n\n/**\n * An object representing a direct overwrite of a value for a channel.\n * Used to signal that the channel value should be replaced with the given value,\n * bypassing any reducer or binary operator logic.\n *\n * @template ValueType - The type of the value being overwritten.\n * @property {ValueType} [OVERWRITE] - The value to directly set.\n *\n * @example\n * const overwriteObj: OverwriteValue<number> = { __overwrite__: 123 };\n */\nexport interface OverwriteValue<ValueType> {\n [OVERWRITE]: ValueType;\n}\n\n/**\n * Bypass a reducer and write the wrapped value directly to a\n * {@link BinaryOperatorAggregate} channel.\n *\n * Receiving multiple `Overwrite` values for the same channel in a single\n * super-step will raise an {@link InvalidUpdateError}.\n *\n * @example\n * ```typescript\n * import { Annotation, StateGraph, Overwrite } from \"@langchain/langgraph\";\n *\n * const State = Annotation.Root({\n * messages: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * default: () => [],\n * }),\n * });\n *\n * const replaceMessages = (_state: typeof State.State) => {\n * return { messages: new Overwrite([\"replacement\"]) };\n * };\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Overwrite<ValueType = any> implements OverwriteValue<ValueType> {\n lg_name = \"Overwrite\";\n\n readonly [OVERWRITE]: ValueType;\n\n constructor(value: ValueType) {\n this[OVERWRITE] = value;\n }\n\n get value(): ValueType {\n return this[OVERWRITE];\n }\n\n toJSON() {\n return { [OVERWRITE]: this[OVERWRITE] };\n }\n\n static isInstance<ValueType>(value: unknown): value is Overwrite<ValueType> {\n if (!value || typeof value !== \"object\") return false;\n if (OVERWRITE in value) return true;\n if (\"lg_name\" in value && value.lg_name === \"Overwrite\") return true;\n return false;\n }\n}\n\n/**\n * Helper function to detect and extract the value from an Overwrite wrapper,\n * supporting both the Overwrite class instance and the serialized object format.\n *\n * Use to check if a provided value represents an Overwrite: returns the\n * unwrapped value if so, or undefined otherwise.\n *\n * - If the value is an Overwrite instance (preferred API), return its `.value`.\n * - If the value is a wire-format object ({ [OVERWRITE]: value }), extract it.\n * - Otherwise, returns undefined.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns The unwrapped value if value is an Overwrite, or undefined otherwise.\n * @internal\n */\nexport function _getOverwriteValue<ValueType>(\n value: unknown\n): [true, ValueType] | [false, undefined] {\n if (typeof value === \"object\" && value !== null && OVERWRITE in value) {\n return [true, (value as Record<string, ValueType>)[OVERWRITE]];\n }\n return [false, undefined];\n}\n\n/**\n * Type guard to check if a value is an Overwrite value -- either the class\n * instance or the wire format object.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns `true` if the value is an Overwrite value, `false` otherwise.\n * @internal\n */\nexport function _isOverwriteValue<ValueType>(\n value: unknown\n): value is OverwriteValue<ValueType> {\n return _getOverwriteValue<ValueType>(value)[0];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Interrupt<Value = any> = {\n id?: string;\n value?: Value;\n};\n\n/**\n * Checks if the given graph invoke / stream chunk contains interrupt.\n *\n * @example\n * ```ts\n * import { INTERRUPT, isInterrupted } from \"@langchain/langgraph\";\n *\n * const values = await graph.invoke({ foo: \"bar\" });\n * if (isInterrupted<string>(values)) {\n * const interrupt = values[INTERRUPT][0].value;\n * }\n * ```\n *\n * @param values - The values to check.\n * @returns `true` if the values contain an interrupt, `false` otherwise.\n */\nexport function isInterrupted<Value = unknown>(\n values: unknown\n): values is { [INTERRUPT]: Interrupt<Value>[] } {\n if (!values || typeof values !== \"object\") return false;\n if (!(INTERRUPT in values)) return false;\n return Array.isArray(values[INTERRUPT]);\n}\n\nexport type CommandParams<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string,\n> = {\n /**\n * A discriminator field used to identify the type of object. Must be populated when serializing.\n *\n * Optional because it's not required to specify this when directly constructing a {@link Command}\n * object.\n */\n lg_name?: \"Command\";\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - `Send` object (to execute a node with the input provided)\n * - sequence of `Send` objects\n */\n goto?:\n | Nodes\n | SendInterface<Nodes> // eslint-disable-line @typescript-eslint/no-explicit-any\n | (Nodes | SendInterface<Nodes>)[]; // eslint-disable-line @typescript-eslint/no-explicit-any\n};\n\n/**\n * One or more commands to update the graph's state and send messages to nodes.\n * Can be used to combine routing logic with state updates in lieu of conditional edges\n *\n * @example\n * ```ts\n * import { Annotation, Command } from \"@langchain/langgraph\";\n *\n * // Define graph state\n * const StateAnnotation = Annotation.Root({\n * foo: Annotation<string>,\n * });\n *\n * // Define the nodes\n * const nodeA = async (_state: typeof StateAnnotation.State) => {\n * console.log(\"Called A\");\n * // this is a replacement for a real conditional edge function\n * const goto = Math.random() > .5 ? \"nodeB\" : \"nodeC\";\n * // note how Command allows you to BOTH update the graph state AND route to the next node\n * return new Command({\n * // this is the state update\n * update: {\n * foo: \"a\",\n * },\n * // this is a replacement for an edge\n * goto,\n * });\n * };\n *\n * // Nodes B and C are unchanged\n * const nodeB = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called B\");\n * return {\n * foo: state.foo + \"|b\",\n * };\n * }\n *\n * const nodeC = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called C\");\n * return {\n * foo: state.foo + \"|c\",\n * };\n * }\n * \n * import { StateGraph } from \"@langchain/langgraph\";\n\n * // NOTE: there are no edges between nodes A, B and C!\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(\"nodeA\", nodeA, {\n * ends: [\"nodeB\", \"nodeC\"],\n * })\n * .addNode(\"nodeB\", nodeB)\n * .addNode(\"nodeC\", nodeC)\n * .addEdge(\"__start__\", \"nodeA\")\n * .compile();\n * \n * await graph.invoke({ foo: \"\" });\n *\n * // Randomly oscillates between\n * // { foo: 'a|c' } and { foo: 'a|b' }\n * ```\n */\nexport class Command<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string,\n> extends CommandInstance<Resume, Update, Nodes> {\n readonly lg_name = \"Command\";\n\n lc_direct_tool_output = true;\n\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state as a result of executing the node that is returning the command.\n * Written to the state as if the node had simply returned this value instead of the Command object.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)\n * - sequence of {@link Send} objects\n */\n goto?: Nodes | Send<Nodes> | (Nodes | Send<Nodes>)[] = [];\n\n static PARENT = \"__parent__\";\n\n constructor(args: Omit<CommandParams<Resume, Update, Nodes>, \"lg_name\">) {\n super(args);\n this.resume = args.resume;\n this.graph = args.graph;\n this.update = args.update;\n if (args.goto) {\n type ValidArg = Nodes | Send<Nodes, Update>;\n\n this.goto = Array.isArray(args.goto)\n ? (_deserializeCommandSendObjectGraph(args.goto) as ValidArg[])\n : [_deserializeCommandSendObjectGraph(args.goto) as ValidArg];\n }\n }\n\n /**\n * Convert the update field to a list of {@link PendingWrite} tuples\n * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.\n * @internal\n */\n _updateAsTuples(): PendingWrite[] {\n if (\n this.update &&\n typeof this.update === \"object\" &&\n !Array.isArray(this.update)\n ) {\n return Object.entries(this.update);\n } else if (\n Array.isArray(this.update) &&\n this.update.every(\n (t): t is [string, unknown] =>\n Array.isArray(t) && t.length === 2 && typeof t[0] === \"string\"\n )\n ) {\n return this.update;\n } else {\n return [[\"__root__\", this.update]];\n }\n }\n\n toJSON() {\n let serializedGoto;\n if (typeof this.goto === \"string\") {\n serializedGoto = this.goto;\n } else if (_isSend(this.goto)) {\n serializedGoto = this.goto.toJSON();\n } else {\n serializedGoto = this.goto?.map((innerGoto) => {\n if (typeof innerGoto === \"string\") {\n return innerGoto;\n } else {\n return innerGoto.toJSON();\n }\n });\n }\n return {\n lg_name: this.lg_name,\n update: this.update,\n resume: this.resume,\n goto: serializedGoto,\n };\n }\n}\n\n/**\n * A type guard to check if the given value is a {@link Command}.\n *\n * Useful for type narrowing when working with the {@link Command} object.\n *\n * @param x - The value to check.\n * @returns `true` if the value is a {@link Command}, `false` otherwise.\n */\nexport function isCommand(x: unknown): x is Command {\n if (typeof x !== \"object\") {\n return false;\n }\n\n if (x === null || x === undefined) {\n return false;\n }\n\n if (\"lg_name\" in x && x.lg_name === \"Command\") {\n return true;\n }\n\n return false;\n}\n\nfunction isPlainObject(value: object): value is Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\n/**\n * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects\n * matching their interfaces.\n *\n * This is only exported for testing purposes. It is NOT intended to be used outside of\n * the Command and Send classes.\n *\n * @internal\n *\n * @param x - The command send tree to convert.\n * @param seen - A map of seen objects to avoid infinite loops.\n * @returns The converted command send tree.\n */\nexport function _deserializeCommandSendObjectGraph(\n x: unknown,\n seen: Map<object, unknown> = new Map()\n): unknown {\n if (x !== undefined && x !== null && typeof x === \"object\") {\n // If we've already processed this object, return the transformed version\n if (seen.has(x)) {\n return seen.get(x);\n }\n\n let result: unknown;\n\n if (Array.isArray(x)) {\n // Create the array first, then populate it\n result = [];\n // Add to seen map before processing elements to handle self-references\n seen.set(x, result);\n\n // Now populate the array\n x.forEach((item, index) => {\n (result as unknown[])[index] = _deserializeCommandSendObjectGraph(\n item,\n seen\n );\n });\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (x instanceof Command || x instanceof Send || !isPlainObject(x)) {\n result = x;\n seen.set(x, result);\n } else if (isCommand(x)) {\n result = new Command(x);\n seen.set(x, result);\n } else if (_isSendInterface(x)) {\n result = new Send(\n x.node,\n x.args,\n x.timeout !== undefined ? { timeout: x.timeout } : undefined\n );\n seen.set(x, result);\n } else if (\"lc_serializable\" in x && x.lc_serializable) {\n result = x;\n seen.set(x, result);\n } else {\n // Create empty object first\n result = {};\n // Add to seen map before processing properties to handle self-references\n seen.set(x, result);\n\n // Now populate the object\n for (const [key, value] of Object.entries(x)) {\n (result as Record<string, unknown>)[key] =\n _deserializeCommandSendObjectGraph(value, seen);\n }\n }\n\n return result;\n }\n return x;\n}\n"],"mappings":";;;AAOA,MAAa,QAAQ;;AAErB,MAAa,MAAM;AACnB,MAAa,QAAQ;AACrB,MAAa,OAAO;AACpB,MAAa,QAAQ;;;;;;;AAOrB,MAAa,oBAAoB;;AAGjC,MAAa,kBAAkB;;;;;;;;;;;;;;AAe/B,SAAgB,qCAA6C;CAC3D,MAAM,MACJ,OAAO,YAAY,cACf,QAAQ,KAAK,gDACb,KAAA;AACN,KAAI,QAAQ,KAAA,KAAa,QAAQ,IAAI;EACnC,MAAM,SAAS,OAAO,SAAS,KAAK,GAAG;AACvC,MAAI,OAAO,SAAS,OAAO,IAAI,SAAS,EAAG,QAAO;;AAEpD,QAAO;;AAGT,MAAa,kBAAkB;;AAE/B,MAAa,kBAAkB;AAC/B,MAAa,kBAAkB;AAC/B,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;AAClC,MAAa,oBAAoB;AACjC,MAAa,0B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AGpB,IAAI;AAEJ,MAAI,MAAM,QAAQ,EAAE,EAAE;AAEpB,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,KAAE,SAAS,MAAM,UAAU;AACxB,WAAqB,SAAS,mCAC7B,MACA,KACD;KACD;aAEO,aAAa,WAAW,aAAa,QAAQ,CAAC,cAAc,EAAE,EAAE;AACzE,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;aACV,UAAU,EAAE,EAAE;AACvB,YAAS,IAAI,QAAQ,EAAE;AACvB,QAAK,IAAI,GAAG,OAAO;aACV,iBAAiB,EAAE,EAAE;AAC9B,YAAS,IAAI,KACX,EAAE,MACF,EAAE,MACF,EAAE,YAAY,KAAA,IAAY,EAAE,SAAS,EAAE,SAAS,GAAG,KAAA,EACpD;AACD,QAAK,IAAI,GAAG,OAAO;aACV,qBAAqB,KAAK,EAAE,iBAAiB;AACtD,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;SACd;AAEL,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,EAAE,CACzC,QAAmC,OAClC,mCAAmC,OAAO,KAAK;;AAIrD,SAAO;;AAET,QAAO"}
@@ -1,3 +1,4 @@
1
+ import { TimeoutPolicy } from "./pregel/utils/timeout.cjs";
1
2
  import { PendingWrite } from "@langchain/langgraph-checkpoint";
2
3
 
3
4
  //#region src/constants.d.ts
@@ -31,7 +32,20 @@ declare class CommandInstance<Resume = unknown, Update = Record<string, unknown>
31
32
  interface SendInterface<Node extends string = string, Args = any> {
32
33
  node: Node;
33
34
  args: Args;
35
+ /**
36
+ * Optional per-task timeout policy that overrides the target node's timeout
37
+ * for this specific pushed task.
38
+ */
39
+ timeout?: TimeoutPolicy;
34
40
  }
41
+ /** Keyword options for {@link Send}. */
42
+ type SendOptions = {
43
+ /**
44
+ * Per-task timeout policy overriding the target node's timeout for this
45
+ * pushed task. A bare number is treated as `runTimeout` (milliseconds).
46
+ */
47
+ timeout?: number | TimeoutPolicy;
48
+ };
35
49
  /**
36
50
  *
37
51
  * A message or packet to send to a specific node in the graph.
@@ -63,6 +77,14 @@ interface SendInterface<Node extends string = string, Args = any> {
63
77
  * });
64
78
  * };
65
79
  *
80
+ * @remarks
81
+ * A per-task timeout can be supplied via the third argument's `timeout` option
82
+ * to override the target node's configured timeout for this specific pushed task:
83
+ *
84
+ * ```typescript
85
+ * new Send("generate_joke", { subjects: [subject] }, { timeout: { idleTimeout: 5000 } });
86
+ * ```
87
+ *
66
88
  * const graph = new StateGraph(ChainState)
67
89
  * .addNode("generate_joke", (state) => ({
68
90
  * jokes: [`Joke about ${state.subjects}`],
@@ -82,11 +104,18 @@ declare class Send<Node extends string = string, Args = any> implements SendInte
82
104
  lg_name: string;
83
105
  node: Node;
84
106
  args: Args;
85
- constructor(node: Node, args: Args);
107
+ /**
108
+ * Optional per-task timeout policy that overrides the target node's timeout
109
+ * for this specific pushed task. A bare number is treated as a hard
110
+ * `runTimeout` (in milliseconds).
111
+ */
112
+ timeout?: TimeoutPolicy;
113
+ constructor(node: Node, args: Args, options?: SendOptions);
86
114
  toJSON(): {
87
115
  lg_name: string;
88
116
  node: Node;
89
117
  args: Args;
118
+ timeout: TimeoutPolicy | undefined;
90
119
  };
91
120
  }
92
121
  declare const OVERWRITE = "__overwrite__";
@@ -297,10 +326,12 @@ declare class Command<Resume = unknown, Update extends Record<string, unknown> =
297
326
  lg_name: string;
298
327
  node: Nodes;
299
328
  args: any;
329
+ timeout: TimeoutPolicy | undefined;
300
330
  })[] | {
301
331
  lg_name: string;
302
332
  node: Nodes;
303
333
  args: any;
334
+ timeout: TimeoutPolicy | undefined;
304
335
  } | undefined;
305
336
  };
306
337
  }
@@ -314,5 +345,5 @@ declare class Command<Resume = unknown, Update extends Record<string, unknown> =
314
345
  */
315
346
  declare function isCommand(x: unknown): x is Command;
316
347
  //#endregion
317
- export { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, PREVIOUS, START, Send, isCommand, isInterrupted };
348
+ export { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, PREVIOUS, START, Send, SendOptions, isCommand, isInterrupted };
318
349
  //# sourceMappingURL=constants.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.cts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;cAGa,KAAA;AAAb;AAAA,cAEa,GAAA;;cAiCA,SAAA;;cAQA,QAAA;;;;;;cAgDA,cAAA;;;AAwBb;;;;;;;cAba,eAAA,4BAEF,MAAA;EAAA,CAGR,cAAA,GAAiB,aAAA,CAAc,MAAA,EAAQ,MAAA,EAAQ,KAAA;EAEhD,WAAA,CAAY,IAAA,EAAM,aAAA,CAAc,MAAA,EAAQ,MAAA,EAAQ,KAAA;AAAA;AAAA,UAMjC,aAAA;EACf,IAAA,EAAM,IAAA;EACN,IAAA,EAAM,IAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFR;;;;;AAaA;;;;;;;;cAtCa,IAAA,sDAGA,aAAA,CAAc,IAAA,EAAM,IAAA;EAC/B,OAAA;EAEO,IAAA,EAAM,IAAA;EAEN,IAAA,EAAM,IAAA;EAEb,WAAA,CAAY,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA;EAK9B,MAAA,CAAA;;;;;;cAUW,SAAA;;;;;;;;;;;;UAaI,cAAA;EAAA,CACd,SAAA,GAAY,SAAA;AAAA;;;;;;;;;;;AA6Ff;;;;;;;;;;AAqBA;;;cAvFa,SAAA,6BAAsC,cAAA,CAAe,SAAA;EAChE,OAAA;EAAA,UAEU,SAAA,GAAY,SAAA;EAEtB,WAAA,CAAY,KAAA,EAAO,SAAA;EAAA,IAIf,KAAA,CAAA,GAAS,SAAA;EAIb,MAAA,CAAA;;;SAIO,UAAA,WAAA,CAAsB,KAAA,YAAiB,KAAA,IA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;AAAA;AAAA,KAM1B,aAAA,4BAED,MAAA;EA0IM;;;;;;EAjIf,OAAA;EAqIkB;;;EAhIlB,MAAA,GAAS,MAAA;EAgI4C;;;;;;EAzHrD,KAAA;;;;EAKA,MAAA,GAAS,MAAA;;;;;;;;EAST,IAAA,GACI,KAAA,GACA,aAAA,CAAc,KAAA,KACb,KAAA,GAAQ,aAAA,CAAc,KAAA;AAAA;;;;;;;;AA+K7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA9Ga,OAAA,kCAEI,MAAA,oBAA0B,MAAA,0DAEjC,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,KAAA;EAAA,SAC/B,OAAA;EAET,qBAAA;;;;;;;EAQA,KAAA;;;;;EAMA,MAAA,GAAS,MAAA;;;;EAKT,MAAA,GAAS,MAAA;;;;;;;;EAST,IAAA,GAAO,KAAA,GAAQ,IAAA,CAAK,KAAA,KAAU,KAAA,GAAQ,IAAA,CAAK,KAAA;EAAA,OAEpC,MAAA;EAEP,WAAA,CAAY,IAAA,EAAM,IAAA,CAAK,aAAA,CAAc,MAAA,EAAQ,MAAA,EAAQ,KAAA;;;;;;EAmBrD,eAAA,CAAA,GAAmB,YAAA;EAoBnB,MAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;iBAgCc,SAAA,CAAU,CAAA,YAAa,CAAA,IAAK,OAAA"}
@@ -1,3 +1,4 @@
1
+ import { TimeoutPolicy } from "./pregel/utils/timeout.js";
1
2
  import { PendingWrite } from "@langchain/langgraph-checkpoint";
2
3
 
3
4
  //#region src/constants.d.ts
@@ -31,7 +32,20 @@ declare class CommandInstance<Resume = unknown, Update = Record<string, unknown>
31
32
  interface SendInterface<Node extends string = string, Args = any> {
32
33
  node: Node;
33
34
  args: Args;
35
+ /**
36
+ * Optional per-task timeout policy that overrides the target node's timeout
37
+ * for this specific pushed task.
38
+ */
39
+ timeout?: TimeoutPolicy;
34
40
  }
41
+ /** Keyword options for {@link Send}. */
42
+ type SendOptions = {
43
+ /**
44
+ * Per-task timeout policy overriding the target node's timeout for this
45
+ * pushed task. A bare number is treated as `runTimeout` (milliseconds).
46
+ */
47
+ timeout?: number | TimeoutPolicy;
48
+ };
35
49
  /**
36
50
  *
37
51
  * A message or packet to send to a specific node in the graph.
@@ -63,6 +77,14 @@ interface SendInterface<Node extends string = string, Args = any> {
63
77
  * });
64
78
  * };
65
79
  *
80
+ * @remarks
81
+ * A per-task timeout can be supplied via the third argument's `timeout` option
82
+ * to override the target node's configured timeout for this specific pushed task:
83
+ *
84
+ * ```typescript
85
+ * new Send("generate_joke", { subjects: [subject] }, { timeout: { idleTimeout: 5000 } });
86
+ * ```
87
+ *
66
88
  * const graph = new StateGraph(ChainState)
67
89
  * .addNode("generate_joke", (state) => ({
68
90
  * jokes: [`Joke about ${state.subjects}`],
@@ -82,11 +104,18 @@ declare class Send<Node extends string = string, Args = any> implements SendInte
82
104
  lg_name: string;
83
105
  node: Node;
84
106
  args: Args;
85
- constructor(node: Node, args: Args);
107
+ /**
108
+ * Optional per-task timeout policy that overrides the target node's timeout
109
+ * for this specific pushed task. A bare number is treated as a hard
110
+ * `runTimeout` (in milliseconds).
111
+ */
112
+ timeout?: TimeoutPolicy;
113
+ constructor(node: Node, args: Args, options?: SendOptions);
86
114
  toJSON(): {
87
115
  lg_name: string;
88
116
  node: Node;
89
117
  args: Args;
118
+ timeout: TimeoutPolicy | undefined;
90
119
  };
91
120
  }
92
121
  declare const OVERWRITE = "__overwrite__";
@@ -297,10 +326,12 @@ declare class Command<Resume = unknown, Update extends Record<string, unknown> =
297
326
  lg_name: string;
298
327
  node: Nodes;
299
328
  args: any;
329
+ timeout: TimeoutPolicy | undefined;
300
330
  })[] | {
301
331
  lg_name: string;
302
332
  node: Nodes;
303
333
  args: any;
334
+ timeout: TimeoutPolicy | undefined;
304
335
  } | undefined;
305
336
  };
306
337
  }
@@ -314,5 +345,5 @@ declare class Command<Resume = unknown, Update extends Record<string, unknown> =
314
345
  */
315
346
  declare function isCommand(x: unknown): x is Command;
316
347
  //#endregion
317
- export { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, PREVIOUS, START, Send, isCommand, isInterrupted };
348
+ export { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, PREVIOUS, START, Send, SendOptions, isCommand, isInterrupted };
318
349
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;cAGa,KAAA;AAAb;AAAA,cAEa,GAAA;;cAiCA,SAAA;;cAQA,QAAA;;;;;;cAgDA,cAAA;;;AAwBb;;;;;;;cAba,eAAA,4BAEF,MAAA;EAAA,CAGR,cAAA,GAAiB,aAAA,CAAc,MAAA,EAAQ,MAAA,EAAQ,KAAA;EAEhD,WAAA,CAAY,IAAA,EAAM,aAAA,CAAc,MAAA,EAAQ,MAAA,EAAQ,KAAA;AAAA;AAAA,UAMjC,aAAA;EACf,IAAA,EAAM,IAAA;EACN,IAAA,EAAM,IAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFR;;;;;AAaA;;;;;;;;cAtCa,IAAA,sDAGA,aAAA,CAAc,IAAA,EAAM,IAAA;EAC/B,OAAA;EAEO,IAAA,EAAM,IAAA;EAEN,IAAA,EAAM,IAAA;EAEb,WAAA,CAAY,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA;EAK9B,MAAA,CAAA;;;;;;cAUW,SAAA;;;;;;;;;;;;UAaI,cAAA;EAAA,CACd,SAAA,GAAY,SAAA;AAAA;;;;;;;;;;;AA6Ff;;;;;;;;;;AAqBA;;;cAvFa,SAAA,6BAAsC,cAAA,CAAe,SAAA;EAChE,OAAA;EAAA,UAEU,SAAA,GAAY,SAAA;EAEtB,WAAA,CAAY,KAAA,EAAO,SAA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A;;;;;;;;;;;;;;;;;iBAmBM,aAAA,iBAAA,CACd,MAAA,YACC,MAAA;EAAA,CAAa,SAAA,GAAY,SAAA,CAAU,KAAA;AAAA;AAAA,KAM1B,aAAA,4BAED,MAAA;EA0IM;;;;;;EAjIf,OAAA;EAqIkB;;;EAhIlB,MAAA,GAAS,MAAA;EAgI4C;;;;;;EAzHrD,KAAA;;;;EAKA,MAAA,GAAS,MAAA;;;;;;;;EAST,IAAA,GACI,KAAA,GACA,aAAA,CAAc,KAAA,KACb,KAAA,GAAQ,aAAA,CAAc,KAAA;AAAA;;;;;;;;AA+K7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA9Ga,OAAA,kCAEI,MAAA,oBAA0B,MAAA,0DAEjC,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,KAAA;EAAA,SAC/B,OAAA;EAET,qBAAA;;;;;;;EAQA,KAAA;;;;;EAMA,MAAA,GAAS,MAAA;;;;EAKT,MAAA,GAAS,MAAA;;;;;;;;EAST,IAAA,GAAO,KAAA,GAAQ,IAAA,CAAK,KAAA,KAAU,KAAA,GAAQ,IAAA,CAAK,KAAA;EAAA,OAEpC,MAAA;EAEP,WAAA,CAAY,IAAA,EAAM,IAAA,CAAK,aAAA,CAAc,MAAA,EAAQ,MAAA,EAAQ,KAAA;;;;;;EAmBrD,eAAA,CAAA,GAAmB,YAAA;EAoBnB,MAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;iBAgCc,SAAA,CAAU,CAAA,YAAa,CAAA,IAAK,OAAA"}
package/dist/constants.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { coerceTimeoutPolicy } from "./pregel/utils/timeout.js";
1
2
  //#region src/constants.ts
2
3
  /** Special reserved node name denoting the start of a graph. */
3
4
  const START = "__start__";
@@ -6,8 +7,36 @@ const END = "__end__";
6
7
  const INPUT = "__input__";
7
8
  const COPY = "__copy__";
8
9
  const ERROR = "__error__";
10
+ /**
11
+ * Special reserved write key recording the name of the node whose execution
12
+ * failed, so node-level error handlers see the same failure provenance after a
13
+ * checkpoint resume. Value format in pending writes:
14
+ * `[taskId, ERROR_SOURCE_NODE, nodeName: string]`.
15
+ */
16
+ const ERROR_SOURCE_NODE = "__error_source_node__";
9
17
  /** Special reserved cache namespaces */
10
18
  const CACHE_NS_WRITES = "__pregel_ns_writes";
19
+ /**
20
+ * System-wide upper bound on how many supersteps a {@link DeltaChannel} may go
21
+ * without writing a {@link DeltaSnapshot} blob. Once a channel's
22
+ * supersteps-since-snapshot counter reaches this value, a snapshot is forced
23
+ * even if the channel's own `snapshotFrequency` has not been reached — this
24
+ * prevents unbounded ancestor walks on threads where a delta channel exists
25
+ * but is no longer being updated.
26
+ *
27
+ * Overridable via the `LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT`
28
+ * environment variable. Read lazily so test/runtime overrides take effect.
29
+ *
30
+ * @remarks Beta.
31
+ */
32
+ function getDeltaMaxSuperstepsSinceSnapshot() {
33
+ const raw = typeof process !== "undefined" ? process.env?.LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT : void 0;
34
+ if (raw !== void 0 && raw !== "") {
35
+ const parsed = Number.parseInt(raw, 10);
36
+ if (Number.isFinite(parsed) && parsed > 0) return parsed;
37
+ }
38
+ return 5e3;
39
+ }
11
40
  const CONFIG_KEY_SEND = "__pregel_send";
12
41
  /** config key containing function used to call a node (push task) */
13
42
  const CONFIG_KEY_CALL = "__pregel_call";
@@ -25,7 +54,14 @@ const CONFIG_KEY_DURABILITY = "__pregel_durability";
25
54
  const CONFIG_KEY_CHECKPOINT_ID = "checkpoint_id";
26
55
  const CONFIG_KEY_CHECKPOINT_NS = "checkpoint_ns";
27
56
  const CONFIG_KEY_NODE_FINISHED = "__pregel_node_finished";
57
+ /**
58
+ * Config key holding a {@link NodeError} (failed source node + error) for the
59
+ * current node-level error handler invocation. Injected when an error handler
60
+ * task is prepared after the failing node's retry policy is exhausted.
61
+ */
62
+ const CONFIG_KEY_NODE_ERROR = "__pregel_node_error";
28
63
  const CONFIG_KEY_CHECKPOINT_MAP = "checkpoint_map";
64
+ const CONFIG_KEY_REPLAY_STATE = "__pregel_replay_state";
29
65
  const CONFIG_KEY_ABORT_SIGNALS = "__pregel_abort_signals";
30
66
  /** Special channel reserved for graph interrupts */
31
67
  const INTERRUPT = "__interrupt__";
@@ -50,6 +86,7 @@ const RESERVED = [
50
86
  INTERRUPT,
51
87
  RESUME,
52
88
  ERROR,
89
+ ERROR_SOURCE_NODE,
53
90
  NO_WRITES,
54
91
  CONFIG_KEY_SEND,
55
92
  CONFIG_KEY_READ,
@@ -64,7 +101,8 @@ const RESERVED = [
64
101
  CONFIG_KEY_PREVIOUS_STATE,
65
102
  CONFIG_KEY_CHECKPOINT_MAP,
66
103
  CONFIG_KEY_CHECKPOINT_NS,
67
- CONFIG_KEY_CHECKPOINT_ID
104
+ CONFIG_KEY_CHECKPOINT_ID,
105
+ CONFIG_KEY_REPLAY_STATE
68
106
  ];
69
107
  /**
70
108
  * Symbol used internally to identify Command instances.
@@ -122,6 +160,14 @@ function _isSendInterface(x) {
122
160
  * });
123
161
  * };
124
162
  *
163
+ * @remarks
164
+ * A per-task timeout can be supplied via the third argument's `timeout` option
165
+ * to override the target node's configured timeout for this specific pushed task:
166
+ *
167
+ * ```typescript
168
+ * new Send("generate_joke", { subjects: [subject] }, { timeout: { idleTimeout: 5000 } });
169
+ * ```
170
+ *
125
171
  * const graph = new StateGraph(ChainState)
126
172
  * .addNode("generate_joke", (state) => ({
127
173
  * jokes: [`Joke about ${state.subjects}`],
@@ -141,15 +187,23 @@ var Send = class {
141
187
  lg_name = "Send";
142
188
  node;
143
189
  args;
144
- constructor(node, args) {
190
+ /**
191
+ * Optional per-task timeout policy that overrides the target node's timeout
192
+ * for this specific pushed task. A bare number is treated as a hard
193
+ * `runTimeout` (in milliseconds).
194
+ */
195
+ timeout;
196
+ constructor(node, args, options) {
145
197
  this.node = node;
146
198
  this.args = _deserializeCommandSendObjectGraph(args);
199
+ this.timeout = coerceTimeoutPolicy(options?.timeout);
147
200
  }
148
201
  toJSON() {
149
202
  return {
150
203
  lg_name: this.lg_name,
151
204
  node: this.node,
152
- args: this.args
205
+ args: this.args,
206
+ timeout: this.timeout
153
207
  };
154
208
  }
155
209
  };
@@ -423,7 +477,7 @@ function _deserializeCommandSendObjectGraph(x, seen = /* @__PURE__ */ new Map())
423
477
  result = new Command(x);
424
478
  seen.set(x, result);
425
479
  } else if (_isSendInterface(x)) {
426
- result = new Send(x.node, x.args);
480
+ result = new Send(x.node, x.args, x.timeout !== void 0 ? { timeout: x.timeout } : void 0);
427
481
  seen.set(x, result);
428
482
  } else if ("lc_serializable" in x && x.lc_serializable) {
429
483
  result = x;
@@ -438,6 +492,6 @@ function _deserializeCommandSendObjectGraph(x, seen = /* @__PURE__ */ new Map())
438
492
  return x;
439
493
  }
440
494
  //#endregion
441
- export { CACHE_NS_WRITES, COMMAND_SYMBOL, CONFIG_KEY_ABORT_SIGNALS, CONFIG_KEY_CALL, CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_CHECKPOINT_ID, CONFIG_KEY_CHECKPOINT_MAP, CONFIG_KEY_CHECKPOINT_NS, CONFIG_KEY_DURABILITY, CONFIG_KEY_NODE_FINISHED, CONFIG_KEY_PREVIOUS_STATE, CONFIG_KEY_READ, CONFIG_KEY_RESUME_MAP, CONFIG_KEY_RESUMING, CONFIG_KEY_SCRATCHPAD, CONFIG_KEY_SEND, CONFIG_KEY_STREAM, CONFIG_KEY_TASK_ID, COPY, Command, CommandInstance, END, ERROR, INPUT, INTERRUPT, NO_WRITES, NULL_TASK_ID, Overwrite, PREVIOUS, PULL, PUSH, RESERVED, RESUME, RETURN, SELF, START, Send, TAG_HIDDEN, TAG_NOSTREAM, TASKS, _getOverwriteValue, _isOverwriteValue, _isSend, _isSendInterface, isCommand, isInterrupted };
495
+ export { CACHE_NS_WRITES, COMMAND_SYMBOL, CONFIG_KEY_ABORT_SIGNALS, CONFIG_KEY_CALL, CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_CHECKPOINT_ID, CONFIG_KEY_CHECKPOINT_MAP, CONFIG_KEY_CHECKPOINT_NS, CONFIG_KEY_DURABILITY, CONFIG_KEY_NODE_ERROR, CONFIG_KEY_NODE_FINISHED, CONFIG_KEY_PREVIOUS_STATE, CONFIG_KEY_READ, CONFIG_KEY_REPLAY_STATE, CONFIG_KEY_RESUME_MAP, CONFIG_KEY_RESUMING, CONFIG_KEY_SCRATCHPAD, CONFIG_KEY_SEND, CONFIG_KEY_STREAM, CONFIG_KEY_TASK_ID, COPY, Command, CommandInstance, END, ERROR, ERROR_SOURCE_NODE, INPUT, INTERRUPT, NO_WRITES, NULL_TASK_ID, Overwrite, PREVIOUS, PULL, PUSH, RESERVED, RESUME, RETURN, SELF, START, Send, TAG_HIDDEN, TAG_NOSTREAM, TASKS, _getOverwriteValue, _isOverwriteValue, _isSend, _isSendInterface, getDeltaMaxSuperstepsSinceSnapshot, isCommand, isInterrupted };
442
496
 
443
497
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\n\n/** Special reserved node name denoting the start of a graph. */\nexport const START = \"__start__\";\n/** Special reserved node name denoting the end of a graph. */\nexport const END = \"__end__\";\nexport const INPUT = \"__input__\";\nexport const COPY = \"__copy__\";\nexport const ERROR = \"__error__\";\n\n/** Special reserved cache namespaces */\nexport const CACHE_NS_WRITES = \"__pregel_ns_writes\";\n\nexport const CONFIG_KEY_SEND = \"__pregel_send\";\n/** config key containing function used to call a node (push task) */\nexport const CONFIG_KEY_CALL = \"__pregel_call\";\nexport const CONFIG_KEY_READ = \"__pregel_read\";\nexport const CONFIG_KEY_CHECKPOINTER = \"__pregel_checkpointer\";\nexport const CONFIG_KEY_RESUMING = \"__pregel_resuming\";\nexport const CONFIG_KEY_TASK_ID = \"__pregel_task_id\";\nexport const CONFIG_KEY_STREAM = \"__pregel_stream\";\nexport const CONFIG_KEY_RESUME_VALUE = \"__pregel_resume_value\";\nexport const CONFIG_KEY_RESUME_MAP = \"__pregel_resume_map\";\nexport const CONFIG_KEY_SCRATCHPAD = \"__pregel_scratchpad\";\n/** config key containing state from previous invocation of graph for the given thread */\nexport const CONFIG_KEY_PREVIOUS_STATE = \"__pregel_previous\";\nexport const CONFIG_KEY_DURABILITY = \"__pregel_durability\";\nexport const CONFIG_KEY_CHECKPOINT_ID = \"checkpoint_id\";\nexport const CONFIG_KEY_CHECKPOINT_NS = \"checkpoint_ns\";\n\nexport const CONFIG_KEY_NODE_FINISHED = \"__pregel_node_finished\";\n\n// this one is part of public API\nexport const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\n\nexport const CONFIG_KEY_ABORT_SIGNALS = \"__pregel_abort_signals\";\n\n/** Special channel reserved for graph interrupts */\nexport const INTERRUPT = \"__interrupt__\";\n/** Special channel reserved for graph resume */\nexport const RESUME = \"__resume__\";\n/** Special channel reserved for cases when a task exits without any writes */\nexport const NO_WRITES = \"__no_writes__\";\n/** Special channel reserved for graph return */\nexport const RETURN = \"__return__\";\n/** Special channel reserved for graph previous state */\nexport const PREVIOUS = \"__previous__\";\nexport const RUNTIME_PLACEHOLDER = \"__pregel_runtime_placeholder__\";\nexport const RECURSION_LIMIT_DEFAULT = 25;\n\nexport const TAG_HIDDEN = \"langsmith:hidden\";\nexport const TAG_NOSTREAM = \"langsmith:nostream\";\nexport const SELF = \"__self__\";\n\nexport const TASKS = \"__pregel_tasks\";\nexport const PUSH = \"__pregel_push\";\nexport const PULL = \"__pregel_pull\";\n\nexport const TASK_NAMESPACE = \"6ba7b831-9dad-11d1-80b4-00c04fd430c8\";\nexport const NULL_TASK_ID = \"00000000-0000-0000-0000-000000000000\";\n\nexport const RESERVED = [\n TAG_HIDDEN,\n INPUT,\n INTERRUPT,\n RESUME,\n ERROR,\n NO_WRITES,\n\n // reserved config.configurable keys\n CONFIG_KEY_SEND,\n CONFIG_KEY_READ,\n CONFIG_KEY_CHECKPOINTER,\n CONFIG_KEY_DURABILITY,\n CONFIG_KEY_STREAM,\n CONFIG_KEY_RESUMING,\n CONFIG_KEY_TASK_ID,\n CONFIG_KEY_CALL,\n CONFIG_KEY_RESUME_VALUE,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_PREVIOUS_STATE,\n CONFIG_KEY_CHECKPOINT_MAP,\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_CHECKPOINT_ID,\n];\n\nexport const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport const CHECKPOINT_NAMESPACE_END = \":\";\n\n/**\n * Symbol used internally to identify Command instances.\n * Exported to support cross-version type compatibility.\n * @internal\n */\nexport const COMMAND_SYMBOL = Symbol.for(\"langgraph.command\");\n\n/**\n * Instance of a {@link Command} class.\n *\n * This is used to avoid IntelliSense suggesting public fields\n * of {@link Command} class when a plain object is expected.\n *\n * @see {@link Command}\n * @internal\n */\nexport class CommandInstance<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string,\n> {\n [COMMAND_SYMBOL]: CommandParams<Resume, Update, Nodes>;\n\n constructor(args: CommandParams<Resume, Update, Nodes>) {\n this[COMMAND_SYMBOL] = args;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SendInterface<Node extends string = string, Args = any> {\n node: Node;\n args: Args;\n}\n\nexport function _isSendInterface(x: unknown): x is SendInterface {\n const operation = x as SendInterface;\n return (\n operation !== null &&\n operation !== undefined &&\n typeof operation.node === \"string\" &&\n operation.args !== undefined\n );\n}\n\n/**\n *\n * A message or packet to send to a specific node in the graph.\n *\n * The `Send` class is used within a `StateGraph`'s conditional edges to\n * dynamically invoke a node with a custom state at the next step.\n *\n * Importantly, the sent state can differ from the core graph's state,\n * allowing for flexible and dynamic workflow management.\n *\n * One such example is a \"map-reduce\" workflow where your graph invokes\n * the same node multiple times in parallel with different states,\n * before aggregating the results back into the main graph's state.\n *\n * @example\n * ```typescript\n * import { Annotation, Send, StateGraph } from \"@langchain/langgraph\";\n *\n * const ChainState = Annotation.Root({\n * subjects: Annotation<string[]>,\n * jokes: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * }),\n * });\n *\n * const continueToJokes = async (state: typeof ChainState.State) => {\n * return state.subjects.map((subject) => {\n * return new Send(\"generate_joke\", { subjects: [subject] });\n * });\n * };\n *\n * const graph = new StateGraph(ChainState)\n * .addNode(\"generate_joke\", (state) => ({\n * jokes: [`Joke about ${state.subjects}`],\n * }))\n * .addConditionalEdges(\"__start__\", continueToJokes)\n * .addEdge(\"generate_joke\", \"__end__\")\n * .compile();\n *\n * const res = await graph.invoke({ subjects: [\"cats\", \"dogs\"] });\n * console.log(res);\n *\n * // Invoking with two subjects results in a generated joke for each\n * // { subjects: [\"cats\", \"dogs\"], jokes: [`Joke about cats`, `Joke about dogs`] }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Send<\n Node extends string = string,\n Args = any,\n> implements SendInterface<Node, Args> {\n lg_name = \"Send\";\n\n public node: Node;\n\n public args: Args;\n\n constructor(node: Node, args: Args) {\n this.node = node;\n this.args = _deserializeCommandSendObjectGraph(args) as Args;\n }\n\n toJSON() {\n return { lg_name: this.lg_name, node: this.node, args: this.args };\n }\n}\n\nexport function _isSend(x: unknown): x is Send {\n // eslint-disable-next-line no-instanceof/no-instanceof\n return x instanceof Send;\n}\n\nexport const OVERWRITE = \"__overwrite__\";\n\n/**\n * An object representing a direct overwrite of a value for a channel.\n * Used to signal that the channel value should be replaced with the given value,\n * bypassing any reducer or binary operator logic.\n *\n * @template ValueType - The type of the value being overwritten.\n * @property {ValueType} [OVERWRITE] - The value to directly set.\n *\n * @example\n * const overwriteObj: OverwriteValue<number> = { __overwrite__: 123 };\n */\nexport interface OverwriteValue<ValueType> {\n [OVERWRITE]: ValueType;\n}\n\n/**\n * Bypass a reducer and write the wrapped value directly to a\n * {@link BinaryOperatorAggregate} channel.\n *\n * Receiving multiple `Overwrite` values for the same channel in a single\n * super-step will raise an {@link InvalidUpdateError}.\n *\n * @example\n * ```typescript\n * import { Annotation, StateGraph, Overwrite } from \"@langchain/langgraph\";\n *\n * const State = Annotation.Root({\n * messages: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * default: () => [],\n * }),\n * });\n *\n * const replaceMessages = (_state: typeof State.State) => {\n * return { messages: new Overwrite([\"replacement\"]) };\n * };\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Overwrite<ValueType = any> implements OverwriteValue<ValueType> {\n lg_name = \"Overwrite\";\n\n readonly [OVERWRITE]: ValueType;\n\n constructor(value: ValueType) {\n this[OVERWRITE] = value;\n }\n\n get value(): ValueType {\n return this[OVERWRITE];\n }\n\n toJSON() {\n return { [OVERWRITE]: this[OVERWRITE] };\n }\n\n static isInstance<ValueType>(value: unknown): value is Overwrite<ValueType> {\n if (!value || typeof value !== \"object\") return false;\n if (OVERWRITE in value) return true;\n if (\"lg_name\" in value && value.lg_name === \"Overwrite\") return true;\n return false;\n }\n}\n\n/**\n * Helper function to detect and extract the value from an Overwrite wrapper,\n * supporting both the Overwrite class instance and the serialized object format.\n *\n * Use to check if a provided value represents an Overwrite: returns the\n * unwrapped value if so, or undefined otherwise.\n *\n * - If the value is an Overwrite instance (preferred API), return its `.value`.\n * - If the value is a wire-format object ({ [OVERWRITE]: value }), extract it.\n * - Otherwise, returns undefined.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns The unwrapped value if value is an Overwrite, or undefined otherwise.\n * @internal\n */\nexport function _getOverwriteValue<ValueType>(\n value: unknown\n): [true, ValueType] | [false, undefined] {\n if (typeof value === \"object\" && value !== null && OVERWRITE in value) {\n return [true, (value as Record<string, ValueType>)[OVERWRITE]];\n }\n return [false, undefined];\n}\n\n/**\n * Type guard to check if a value is an Overwrite value -- either the class\n * instance or the wire format object.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns `true` if the value is an Overwrite value, `false` otherwise.\n * @internal\n */\nexport function _isOverwriteValue<ValueType>(\n value: unknown\n): value is OverwriteValue<ValueType> {\n return _getOverwriteValue<ValueType>(value)[0];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Interrupt<Value = any> = {\n id?: string;\n value?: Value;\n};\n\n/**\n * Checks if the given graph invoke / stream chunk contains interrupt.\n *\n * @example\n * ```ts\n * import { INTERRUPT, isInterrupted } from \"@langchain/langgraph\";\n *\n * const values = await graph.invoke({ foo: \"bar\" });\n * if (isInterrupted<string>(values)) {\n * const interrupt = values[INTERRUPT][0].value;\n * }\n * ```\n *\n * @param values - The values to check.\n * @returns `true` if the values contain an interrupt, `false` otherwise.\n */\nexport function isInterrupted<Value = unknown>(\n values: unknown\n): values is { [INTERRUPT]: Interrupt<Value>[] } {\n if (!values || typeof values !== \"object\") return false;\n if (!(INTERRUPT in values)) return false;\n return Array.isArray(values[INTERRUPT]);\n}\n\nexport type CommandParams<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string,\n> = {\n /**\n * A discriminator field used to identify the type of object. Must be populated when serializing.\n *\n * Optional because it's not required to specify this when directly constructing a {@link Command}\n * object.\n */\n lg_name?: \"Command\";\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - `Send` object (to execute a node with the input provided)\n * - sequence of `Send` objects\n */\n goto?:\n | Nodes\n | SendInterface<Nodes> // eslint-disable-line @typescript-eslint/no-explicit-any\n | (Nodes | SendInterface<Nodes>)[]; // eslint-disable-line @typescript-eslint/no-explicit-any\n};\n\n/**\n * One or more commands to update the graph's state and send messages to nodes.\n * Can be used to combine routing logic with state updates in lieu of conditional edges\n *\n * @example\n * ```ts\n * import { Annotation, Command } from \"@langchain/langgraph\";\n *\n * // Define graph state\n * const StateAnnotation = Annotation.Root({\n * foo: Annotation<string>,\n * });\n *\n * // Define the nodes\n * const nodeA = async (_state: typeof StateAnnotation.State) => {\n * console.log(\"Called A\");\n * // this is a replacement for a real conditional edge function\n * const goto = Math.random() > .5 ? \"nodeB\" : \"nodeC\";\n * // note how Command allows you to BOTH update the graph state AND route to the next node\n * return new Command({\n * // this is the state update\n * update: {\n * foo: \"a\",\n * },\n * // this is a replacement for an edge\n * goto,\n * });\n * };\n *\n * // Nodes B and C are unchanged\n * const nodeB = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called B\");\n * return {\n * foo: state.foo + \"|b\",\n * };\n * }\n *\n * const nodeC = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called C\");\n * return {\n * foo: state.foo + \"|c\",\n * };\n * }\n * \n * import { StateGraph } from \"@langchain/langgraph\";\n\n * // NOTE: there are no edges between nodes A, B and C!\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(\"nodeA\", nodeA, {\n * ends: [\"nodeB\", \"nodeC\"],\n * })\n * .addNode(\"nodeB\", nodeB)\n * .addNode(\"nodeC\", nodeC)\n * .addEdge(\"__start__\", \"nodeA\")\n * .compile();\n * \n * await graph.invoke({ foo: \"\" });\n *\n * // Randomly oscillates between\n * // { foo: 'a|c' } and { foo: 'a|b' }\n * ```\n */\nexport class Command<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string,\n> extends CommandInstance<Resume, Update, Nodes> {\n readonly lg_name = \"Command\";\n\n lc_direct_tool_output = true;\n\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state as a result of executing the node that is returning the command.\n * Written to the state as if the node had simply returned this value instead of the Command object.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)\n * - sequence of {@link Send} objects\n */\n goto?: Nodes | Send<Nodes> | (Nodes | Send<Nodes>)[] = [];\n\n static PARENT = \"__parent__\";\n\n constructor(args: Omit<CommandParams<Resume, Update, Nodes>, \"lg_name\">) {\n super(args);\n this.resume = args.resume;\n this.graph = args.graph;\n this.update = args.update;\n if (args.goto) {\n type ValidArg = Nodes | Send<Nodes, Update>;\n\n this.goto = Array.isArray(args.goto)\n ? (_deserializeCommandSendObjectGraph(args.goto) as ValidArg[])\n : [_deserializeCommandSendObjectGraph(args.goto) as ValidArg];\n }\n }\n\n /**\n * Convert the update field to a list of {@link PendingWrite} tuples\n * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.\n * @internal\n */\n _updateAsTuples(): PendingWrite[] {\n if (\n this.update &&\n typeof this.update === \"object\" &&\n !Array.isArray(this.update)\n ) {\n return Object.entries(this.update);\n } else if (\n Array.isArray(this.update) &&\n this.update.every(\n (t): t is [string, unknown] =>\n Array.isArray(t) && t.length === 2 && typeof t[0] === \"string\"\n )\n ) {\n return this.update;\n } else {\n return [[\"__root__\", this.update]];\n }\n }\n\n toJSON() {\n let serializedGoto;\n if (typeof this.goto === \"string\") {\n serializedGoto = this.goto;\n } else if (_isSend(this.goto)) {\n serializedGoto = this.goto.toJSON();\n } else {\n serializedGoto = this.goto?.map((innerGoto) => {\n if (typeof innerGoto === \"string\") {\n return innerGoto;\n } else {\n return innerGoto.toJSON();\n }\n });\n }\n return {\n lg_name: this.lg_name,\n update: this.update,\n resume: this.resume,\n goto: serializedGoto,\n };\n }\n}\n\n/**\n * A type guard to check if the given value is a {@link Command}.\n *\n * Useful for type narrowing when working with the {@link Command} object.\n *\n * @param x - The value to check.\n * @returns `true` if the value is a {@link Command}, `false` otherwise.\n */\nexport function isCommand(x: unknown): x is Command {\n if (typeof x !== \"object\") {\n return false;\n }\n\n if (x === null || x === undefined) {\n return false;\n }\n\n if (\"lg_name\" in x && x.lg_name === \"Command\") {\n return true;\n }\n\n return false;\n}\n\nfunction isPlainObject(value: object): value is Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\n/**\n * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects\n * matching their interfaces.\n *\n * This is only exported for testing purposes. It is NOT intended to be used outside of\n * the Command and Send classes.\n *\n * @internal\n *\n * @param x - The command send tree to convert.\n * @param seen - A map of seen objects to avoid infinite loops.\n * @returns The converted command send tree.\n */\nexport function _deserializeCommandSendObjectGraph(\n x: unknown,\n seen: Map<object, unknown> = new Map()\n): unknown {\n if (x !== undefined && x !== null && typeof x === \"object\") {\n // If we've already processed this object, return the transformed version\n if (seen.has(x)) {\n return seen.get(x);\n }\n\n let result: unknown;\n\n if (Array.isArray(x)) {\n // Create the array first, then populate it\n result = [];\n // Add to seen map before processing elements to handle self-references\n seen.set(x, result);\n\n // Now populate the array\n x.forEach((item, index) => {\n (result as unknown[])[index] = _deserializeCommandSendObjectGraph(\n item,\n seen\n );\n });\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (x instanceof Command || x instanceof Send || !isPlainObject(x)) {\n result = x;\n seen.set(x, result);\n } else if (isCommand(x)) {\n result = new Command(x);\n seen.set(x, result);\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (_isSendInterface(x)) {\n result = new Send(x.node, x.args);\n seen.set(x, result);\n } else if (\"lc_serializable\" in x && x.lc_serializable) {\n result = x;\n seen.set(x, result);\n } else {\n // Create empty object first\n result = {};\n // Add to seen map before processing properties to handle self-references\n seen.set(x, result);\n\n // Now populate the object\n for (const [key, value] of Object.entries(x)) {\n (result as Record<string, unknown>)[key] =\n _deserializeCommandSendObjectGraph(value, seen);\n }\n }\n\n return result;\n }\n return x;\n}\n"],"mappings":";;AAGA,MAAa,QAAQ;;AAErB,MAAa,MAAM;AACnB,MAAa,QAAQ;AACrB,MAAa,OAAO;AACpB,MAAa,QAAQ;;AAGrB,MAAa,kBAAkB;AAE/B,MAAa,kBAAkB;;AAE/B,MAAa,kBAAkB;AAC/B,MAAa,kBAAkB;AAC/B,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;AAClC,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;;AAErC,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;AACrC,MAAa,2BAA2B;AACxC,MAAa,2BAA2B;AAExC,MAAa,2BAA2B;AAGxC,MAAa,4BAA4B;AAEzC,MAAa,2BAA2B;;AAGxC,MAAa,YAAY;;AAEzB,MAAa,SAAS;;AAEtB,MAAa,YAAY;;AAEzB,MAAa,SAAS;;AAEtB,MAAa,WAAW;AAIxB,MAAa,aAAa;AAC1B,MAAa,eAAe;AAC5B,MAAa,OAAO;AAEpB,MAAa,QAAQ;AACrB,MAAa,OAAO;AACpB,MAAa,OAAO;AAGpB,MAAa,eAAe;AAE5B,MAAa,WAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;AAUD,MAAa,iBAAiB,OAAO,IAAI,oBAAoB;;;;;;;;;;AAW7D,IAAa,kBAAb,MAIE;CACA,CAAC;CAED,YAAY,MAA4C;AACtD,OAAK,kBAAkB;;;AAU3B,SAAgB,iBAAiB,GAAgC;CAC/D,MAAM,YAAY;AAClB,Q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a,KAAK,EAAE,YAAY,UAClC,QAAO;AAGT,QAAO;;AAGT,SAAS,cAAc,OAAiD;CACtE,MAAM,YAAY,OAAO,eAAe,MAAM;AAC9C,QAAO,cAAc,OAAO,aAAa,cAAc;;;;;;;;;;;;;;;AAgBzD,SAAgB,mCACd,GACA,uBAA6B,IAAI,KAAK,EAC7B;AACT,KAAI,MAAM,KAAA,KAAa,MAAM,QAAQ,OAAO,MAAM,UAAU;AAE1D,MAAI,KAAK,IAAI,EAAE,CACb,QAAO,KAAK,IAAI,EAAE;EAGpB,IAAI;AAEJ,MAAI,MAAM,QAAQ,EAAE,EAAE;AAEpB,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,KAAE,SAAS,MAAM,UAAU;AACxB,WAAqB,SAAS,mCAC7B,MACA,KACD;KACD;aAEO,aAAa,WAAW,aAAa,QAAQ,CAAC,cAAc,EAAE,EAAE;AACzE,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;aACV,UAAU,EAAE,EAAE;AACvB,YAAS,IAAI,QAAQ,EAAE;AACvB,QAAK,IAAI,GAAG,OAAO;aAEV,iBAAiB,EAAE,EAAE;AAC9B,YAAS,IAAI,KAAK,EAAE,MAAM,EAAE,KAAK;AACjC,QAAK,IAAI,GAAG,OAAO;aACV,qBAAqB,KAAK,EAAE,iBAAiB;AACtD,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;SACd;AAEL,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,EAAE,CACzC,QAAmC,OAClC,mCAAmC,OAAO,KAAK;;AAIrD,SAAO;;AAET,QAAO"}
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\nimport {\n coerceTimeoutPolicy,\n type TimeoutPolicy,\n} from \"./pregel/utils/timeout.js\";\n\n/** Special reserved node name denoting the start of a graph. */\nexport const START = \"__start__\";\n/** Special reserved node name denoting the end of a graph. */\nexport const END = \"__end__\";\nexport const INPUT = \"__input__\";\nexport const COPY = \"__copy__\";\nexport const ERROR = \"__error__\";\n/**\n * Special reserved write key recording the name of the node whose execution\n * failed, so node-level error handlers see the same failure provenance after a\n * checkpoint resume. Value format in pending writes:\n * `[taskId, ERROR_SOURCE_NODE, nodeName: string]`.\n */\nexport const ERROR_SOURCE_NODE = \"__error_source_node__\";\n\n/** Special reserved cache namespaces */\nexport const CACHE_NS_WRITES = \"__pregel_ns_writes\";\n\n/**\n * System-wide upper bound on how many supersteps a {@link DeltaChannel} may go\n * without writing a {@link DeltaSnapshot} blob. Once a channel's\n * supersteps-since-snapshot counter reaches this value, a snapshot is forced\n * even if the channel's own `snapshotFrequency` has not been reached — this\n * prevents unbounded ancestor walks on threads where a delta channel exists\n * but is no longer being updated.\n *\n * Overridable via the `LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT`\n * environment variable. Read lazily so test/runtime overrides take effect.\n *\n * @remarks Beta.\n */\nexport function getDeltaMaxSuperstepsSinceSnapshot(): number {\n const raw =\n typeof process !== \"undefined\"\n ? process.env?.LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT\n : undefined;\n if (raw !== undefined && raw !== \"\") {\n const parsed = Number.parseInt(raw, 10);\n if (Number.isFinite(parsed) && parsed > 0) return parsed;\n }\n return 5000;\n}\n\nexport const CONFIG_KEY_SEND = \"__pregel_send\";\n/** config key containing function used to call a node (push task) */\nexport const CONFIG_KEY_CALL = \"__pregel_call\";\nexport const CONFIG_KEY_READ = \"__pregel_read\";\nexport const CONFIG_KEY_CHECKPOINTER = \"__pregel_checkpointer\";\nexport const CONFIG_KEY_RESUMING = \"__pregel_resuming\";\nexport const CONFIG_KEY_TASK_ID = \"__pregel_task_id\";\nexport const CONFIG_KEY_STREAM = \"__pregel_stream\";\nexport const CONFIG_KEY_RESUME_VALUE = \"__pregel_resume_value\";\nexport const CONFIG_KEY_RESUME_MAP = \"__pregel_resume_map\";\nexport const CONFIG_KEY_SCRATCHPAD = \"__pregel_scratchpad\";\n/** config key containing state from previous invocation of graph for the given thread */\nexport const CONFIG_KEY_PREVIOUS_STATE = \"__pregel_previous\";\nexport const CONFIG_KEY_DURABILITY = \"__pregel_durability\";\nexport const CONFIG_KEY_CHECKPOINT_ID = \"checkpoint_id\";\nexport const CONFIG_KEY_CHECKPOINT_NS = \"checkpoint_ns\";\n\nexport const CONFIG_KEY_NODE_FINISHED = \"__pregel_node_finished\";\n\n/**\n * Config key holding a {@link NodeError} (failed source node + error) for the\n * current node-level error handler invocation. Injected when an error handler\n * task is prepared after the failing node's retry policy is exhausted.\n */\nexport const CONFIG_KEY_NODE_ERROR = \"__pregel_node_error\";\n\n// this one is part of public API\nexport const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\n\nexport const CONFIG_KEY_REPLAY_STATE = \"__pregel_replay_state\";\n\nexport const CONFIG_KEY_ABORT_SIGNALS = \"__pregel_abort_signals\";\n\n/** Special channel reserved for graph interrupts */\nexport const INTERRUPT = \"__interrupt__\";\n/** Special channel reserved for graph resume */\nexport const RESUME = \"__resume__\";\n/** Special channel reserved for cases when a task exits without any writes */\nexport const NO_WRITES = \"__no_writes__\";\n/** Special channel reserved for graph return */\nexport const RETURN = \"__return__\";\n/** Special channel reserved for graph previous state */\nexport const PREVIOUS = \"__previous__\";\nexport const RUNTIME_PLACEHOLDER = \"__pregel_runtime_placeholder__\";\nexport const RECURSION_LIMIT_DEFAULT = 25;\n\nexport const TAG_HIDDEN = \"langsmith:hidden\";\nexport const TAG_NOSTREAM = \"langsmith:nostream\";\nexport const SELF = \"__self__\";\n\nexport const TASKS = \"__pregel_tasks\";\nexport const PUSH = \"__pregel_push\";\nexport const PULL = \"__pregel_pull\";\n\nexport const TASK_NAMESPACE = \"6ba7b831-9dad-11d1-80b4-00c04fd430c8\";\nexport const NULL_TASK_ID = \"00000000-0000-0000-0000-000000000000\";\n\nexport const RESERVED = [\n TAG_HIDDEN,\n INPUT,\n INTERRUPT,\n RESUME,\n ERROR,\n ERROR_SOURCE_NODE,\n NO_WRITES,\n\n // reserved config.configurable keys\n CONFIG_KEY_SEND,\n CONFIG_KEY_READ,\n CONFIG_KEY_CHECKPOINTER,\n CONFIG_KEY_DURABILITY,\n CONFIG_KEY_STREAM,\n CONFIG_KEY_RESUMING,\n CONFIG_KEY_TASK_ID,\n CONFIG_KEY_CALL,\n CONFIG_KEY_RESUME_VALUE,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_PREVIOUS_STATE,\n CONFIG_KEY_CHECKPOINT_MAP,\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_CHECKPOINT_ID,\n CONFIG_KEY_REPLAY_STATE,\n];\n\nexport const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport const CHECKPOINT_NAMESPACE_END = \":\";\n\n/**\n * Symbol used internally to identify Command instances.\n * Exported to support cross-version type compatibility.\n * @internal\n */\nexport const COMMAND_SYMBOL = Symbol.for(\"langgraph.command\");\n\n/**\n * Instance of a {@link Command} class.\n *\n * This is used to avoid IntelliSense suggesting public fields\n * of {@link Command} class when a plain object is expected.\n *\n * @see {@link Command}\n * @internal\n */\nexport class CommandInstance<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string,\n> {\n [COMMAND_SYMBOL]: CommandParams<Resume, Update, Nodes>;\n\n constructor(args: CommandParams<Resume, Update, Nodes>) {\n this[COMMAND_SYMBOL] = args;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SendInterface<Node extends string = string, Args = any> {\n node: Node;\n args: Args;\n /**\n * Optional per-task timeout policy that overrides the target node's timeout\n * for this specific pushed task.\n */\n timeout?: TimeoutPolicy;\n}\n\n/** Keyword options for {@link Send}. */\nexport type SendOptions = {\n /**\n * Per-task timeout policy overriding the target node's timeout for this\n * pushed task. A bare number is treated as `runTimeout` (milliseconds).\n */\n timeout?: number | TimeoutPolicy;\n};\n\nexport function _isSendInterface(x: unknown): x is SendInterface {\n const operation = x as SendInterface;\n return (\n operation !== null &&\n operation !== undefined &&\n typeof operation.node === \"string\" &&\n operation.args !== undefined\n );\n}\n\n/**\n *\n * A message or packet to send to a specific node in the graph.\n *\n * The `Send` class is used within a `StateGraph`'s conditional edges to\n * dynamically invoke a node with a custom state at the next step.\n *\n * Importantly, the sent state can differ from the core graph's state,\n * allowing for flexible and dynamic workflow management.\n *\n * One such example is a \"map-reduce\" workflow where your graph invokes\n * the same node multiple times in parallel with different states,\n * before aggregating the results back into the main graph's state.\n *\n * @example\n * ```typescript\n * import { Annotation, Send, StateGraph } from \"@langchain/langgraph\";\n *\n * const ChainState = Annotation.Root({\n * subjects: Annotation<string[]>,\n * jokes: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * }),\n * });\n *\n * const continueToJokes = async (state: typeof ChainState.State) => {\n * return state.subjects.map((subject) => {\n * return new Send(\"generate_joke\", { subjects: [subject] });\n * });\n * };\n *\n * @remarks\n * A per-task timeout can be supplied via the third argument's `timeout` option\n * to override the target node's configured timeout for this specific pushed task:\n *\n * ```typescript\n * new Send(\"generate_joke\", { subjects: [subject] }, { timeout: { idleTimeout: 5000 } });\n * ```\n *\n * const graph = new StateGraph(ChainState)\n * .addNode(\"generate_joke\", (state) => ({\n * jokes: [`Joke about ${state.subjects}`],\n * }))\n * .addConditionalEdges(\"__start__\", continueToJokes)\n * .addEdge(\"generate_joke\", \"__end__\")\n * .compile();\n *\n * const res = await graph.invoke({ subjects: [\"cats\", \"dogs\"] });\n * console.log(res);\n *\n * // Invoking with two subjects results in a generated joke for each\n * // { subjects: [\"cats\", \"dogs\"], jokes: [`Joke about cats`, `Joke about dogs`] }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Send<\n Node extends string = string,\n Args = any,\n> implements SendInterface<Node, Args> {\n lg_name = \"Send\";\n\n public node: Node;\n\n public args: Args;\n\n /**\n * Optional per-task timeout policy that overrides the target node's timeout\n * for this specific pushed task. A bare number is treated as a hard\n * `runTimeout` (in milliseconds).\n */\n public timeout?: TimeoutPolicy;\n\n constructor(node: Node, args: Args, options?: SendOptions) {\n this.node = node;\n this.args = _deserializeCommandSendObjectGraph(args) as Args;\n this.timeout = coerceTimeoutPolicy(options?.timeout);\n }\n\n toJSON() {\n return {\n lg_name: this.lg_name,\n node: this.node,\n args: this.args,\n timeout: this.timeout,\n };\n }\n}\n\nexport function _isSend(x: unknown): x is Send {\n // eslint-disable-next-line no-instanceof/no-instanceof\n return x instanceof Send;\n}\n\nexport const OVERWRITE = \"__overwrite__\";\n\n/**\n * An object representing a direct overwrite of a value for a channel.\n * Used to signal that the channel value should be replaced with the given value,\n * bypassing any reducer or binary operator logic.\n *\n * @template ValueType - The type of the value being overwritten.\n * @property {ValueType} [OVERWRITE] - The value to directly set.\n *\n * @example\n * const overwriteObj: OverwriteValue<number> = { __overwrite__: 123 };\n */\nexport interface OverwriteValue<ValueType> {\n [OVERWRITE]: ValueType;\n}\n\n/**\n * Bypass a reducer and write the wrapped value directly to a\n * {@link BinaryOperatorAggregate} channel.\n *\n * Receiving multiple `Overwrite` values for the same channel in a single\n * super-step will raise an {@link InvalidUpdateError}.\n *\n * @example\n * ```typescript\n * import { Annotation, StateGraph, Overwrite } from \"@langchain/langgraph\";\n *\n * const State = Annotation.Root({\n * messages: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * default: () => [],\n * }),\n * });\n *\n * const replaceMessages = (_state: typeof State.State) => {\n * return { messages: new Overwrite([\"replacement\"]) };\n * };\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Overwrite<ValueType = any> implements OverwriteValue<ValueType> {\n lg_name = \"Overwrite\";\n\n readonly [OVERWRITE]: ValueType;\n\n constructor(value: ValueType) {\n this[OVERWRITE] = value;\n }\n\n get value(): ValueType {\n return this[OVERWRITE];\n }\n\n toJSON() {\n return { [OVERWRITE]: this[OVERWRITE] };\n }\n\n static isInstance<ValueType>(value: unknown): value is Overwrite<ValueType> {\n if (!value || typeof value !== \"object\") return false;\n if (OVERWRITE in value) return true;\n if (\"lg_name\" in value && value.lg_name === \"Overwrite\") return true;\n return false;\n }\n}\n\n/**\n * Helper function to detect and extract the value from an Overwrite wrapper,\n * supporting both the Overwrite class instance and the serialized object format.\n *\n * Use to check if a provided value represents an Overwrite: returns the\n * unwrapped value if so, or undefined otherwise.\n *\n * - If the value is an Overwrite instance (preferred API), return its `.value`.\n * - If the value is a wire-format object ({ [OVERWRITE]: value }), extract it.\n * - Otherwise, returns undefined.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns The unwrapped value if value is an Overwrite, or undefined otherwise.\n * @internal\n */\nexport function _getOverwriteValue<ValueType>(\n value: unknown\n): [true, ValueType] | [false, undefined] {\n if (typeof value === \"object\" && value !== null && OVERWRITE in value) {\n return [true, (value as Record<string, ValueType>)[OVERWRITE]];\n }\n return [false, undefined];\n}\n\n/**\n * Type guard to check if a value is an Overwrite value -- either the class\n * instance or the wire format object.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns `true` if the value is an Overwrite value, `false` otherwise.\n * @internal\n */\nexport function _isOverwriteValue<ValueType>(\n value: unknown\n): value is OverwriteValue<ValueType> {\n return _getOverwriteValue<ValueType>(value)[0];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Interrupt<Value = any> = {\n id?: string;\n value?: Value;\n};\n\n/**\n * Checks if the given graph invoke / stream chunk contains interrupt.\n *\n * @example\n * ```ts\n * import { INTERRUPT, isInterrupted } from \"@langchain/langgraph\";\n *\n * const values = await graph.invoke({ foo: \"bar\" });\n * if (isInterrupted<string>(values)) {\n * const interrupt = values[INTERRUPT][0].value;\n * }\n * ```\n *\n * @param values - The values to check.\n * @returns `true` if the values contain an interrupt, `false` otherwise.\n */\nexport function isInterrupted<Value = unknown>(\n values: unknown\n): values is { [INTERRUPT]: Interrupt<Value>[] } {\n if (!values || typeof values !== \"object\") return false;\n if (!(INTERRUPT in values)) return false;\n return Array.isArray(values[INTERRUPT]);\n}\n\nexport type CommandParams<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string,\n> = {\n /**\n * A discriminator field used to identify the type of object. Must be populated when serializing.\n *\n * Optional because it's not required to specify this when directly constructing a {@link Command}\n * object.\n */\n lg_name?: \"Command\";\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - `Send` object (to execute a node with the input provided)\n * - sequence of `Send` objects\n */\n goto?:\n | Nodes\n | SendInterface<Nodes> // eslint-disable-line @typescript-eslint/no-explicit-any\n | (Nodes | SendInterface<Nodes>)[]; // eslint-disable-line @typescript-eslint/no-explicit-any\n};\n\n/**\n * One or more commands to update the graph's state and send messages to nodes.\n * Can be used to combine routing logic with state updates in lieu of conditional edges\n *\n * @example\n * ```ts\n * import { Annotation, Command } from \"@langchain/langgraph\";\n *\n * // Define graph state\n * const StateAnnotation = Annotation.Root({\n * foo: Annotation<string>,\n * });\n *\n * // Define the nodes\n * const nodeA = async (_state: typeof StateAnnotation.State) => {\n * console.log(\"Called A\");\n * // this is a replacement for a real conditional edge function\n * const goto = Math.random() > .5 ? \"nodeB\" : \"nodeC\";\n * // note how Command allows you to BOTH update the graph state AND route to the next node\n * return new Command({\n * // this is the state update\n * update: {\n * foo: \"a\",\n * },\n * // this is a replacement for an edge\n * goto,\n * });\n * };\n *\n * // Nodes B and C are unchanged\n * const nodeB = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called B\");\n * return {\n * foo: state.foo + \"|b\",\n * };\n * }\n *\n * const nodeC = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called C\");\n * return {\n * foo: state.foo + \"|c\",\n * };\n * }\n * \n * import { StateGraph } from \"@langchain/langgraph\";\n\n * // NOTE: there are no edges between nodes A, B and C!\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(\"nodeA\", nodeA, {\n * ends: [\"nodeB\", \"nodeC\"],\n * })\n * .addNode(\"nodeB\", nodeB)\n * .addNode(\"nodeC\", nodeC)\n * .addEdge(\"__start__\", \"nodeA\")\n * .compile();\n * \n * await graph.invoke({ foo: \"\" });\n *\n * // Randomly oscillates between\n * // { foo: 'a|c' } and { foo: 'a|b' }\n * ```\n */\nexport class Command<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string,\n> extends CommandInstance<Resume, Update, Nodes> {\n readonly lg_name = \"Command\";\n\n lc_direct_tool_output = true;\n\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state as a result of executing the node that is returning the command.\n * Written to the state as if the node had simply returned this value instead of the Command object.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)\n * - sequence of {@link Send} objects\n */\n goto?: Nodes | Send<Nodes> | (Nodes | Send<Nodes>)[] = [];\n\n static PARENT = \"__parent__\";\n\n constructor(args: Omit<CommandParams<Resume, Update, Nodes>, \"lg_name\">) {\n super(args);\n this.resume = args.resume;\n this.graph = args.graph;\n this.update = args.update;\n if (args.goto) {\n type ValidArg = Nodes | Send<Nodes, Update>;\n\n this.goto = Array.isArray(args.goto)\n ? (_deserializeCommandSendObjectGraph(args.goto) as ValidArg[])\n : [_deserializeCommandSendObjectGraph(args.goto) as ValidArg];\n }\n }\n\n /**\n * Convert the update field to a list of {@link PendingWrite} tuples\n * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.\n * @internal\n */\n _updateAsTuples(): PendingWrite[] {\n if (\n this.update &&\n typeof this.update === \"object\" &&\n !Array.isArray(this.update)\n ) {\n return Object.entries(this.update);\n } else if (\n Array.isArray(this.update) &&\n this.update.every(\n (t): t is [string, unknown] =>\n Array.isArray(t) && t.length === 2 && typeof t[0] === \"string\"\n )\n ) {\n return this.update;\n } else {\n return [[\"__root__\", this.update]];\n }\n }\n\n toJSON() {\n let serializedGoto;\n if (typeof this.goto === \"string\") {\n serializedGoto = this.goto;\n } else if (_isSend(this.goto)) {\n serializedGoto = this.goto.toJSON();\n } else {\n serializedGoto = this.goto?.map((innerGoto) => {\n if (typeof innerGoto === \"string\") {\n return innerGoto;\n } else {\n return innerGoto.toJSON();\n }\n });\n }\n return {\n lg_name: this.lg_name,\n update: this.update,\n resume: this.resume,\n goto: serializedGoto,\n };\n }\n}\n\n/**\n * A type guard to check if the given value is a {@link Command}.\n *\n * Useful for type narrowing when working with the {@link Command} object.\n *\n * @param x - The value to check.\n * @returns `true` if the value is a {@link Command}, `false` otherwise.\n */\nexport function isCommand(x: unknown): x is Command {\n if (typeof x !== \"object\") {\n return false;\n }\n\n if (x === null || x === undefined) {\n return false;\n }\n\n if (\"lg_name\" in x && x.lg_name === \"Command\") {\n return true;\n }\n\n return false;\n}\n\nfunction isPlainObject(value: object): value is Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\n/**\n * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects\n * matching their interfaces.\n *\n * This is only exported for testing purposes. It is NOT intended to be used outside of\n * the Command and Send classes.\n *\n * @internal\n *\n * @param x - The command send tree to convert.\n * @param seen - A map of seen objects to avoid infinite loops.\n * @returns The converted command send tree.\n */\nexport function _deserializeCommandSendObjectGraph(\n x: unknown,\n seen: Map<object, unknown> = new Map()\n): unknown {\n if (x !== undefined && x !== null && typeof x === \"object\") {\n // If we've already processed this object, return the transformed version\n if (seen.has(x)) {\n return seen.get(x);\n }\n\n let result: unknown;\n\n if (Array.isArray(x)) {\n // Create the array first, then populate it\n result = [];\n // Add to seen map before processing elements to handle self-references\n seen.set(x, result);\n\n // Now populate the array\n x.forEach((item, index) => {\n (result as unknown[])[index] = _deserializeCommandSendObjectGraph(\n item,\n seen\n );\n });\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (x instanceof Command || x instanceof Send || !isPlainObject(x)) {\n result = x;\n seen.set(x, result);\n } else if (isCommand(x)) {\n result = new Command(x);\n seen.set(x, result);\n } else if (_isSendInterface(x)) {\n result = new Send(\n x.node,\n x.args,\n x.timeout !== undefined ? { timeout: x.timeout } : undefined\n );\n seen.set(x, result);\n } else if (\"lc_serializable\" in x && x.lc_serializable) {\n result = x;\n seen.set(x, result);\n } else {\n // Create empty object first\n result = {};\n // Add to seen map before processing properties to handle self-references\n seen.set(x, result);\n\n // Now populate the object\n for (const [key, value] of Object.entries(x)) {\n (result as Record<string, unknown>)[key] =\n _deserializeCommandSendObjectGraph(value, seen);\n }\n }\n\n return result;\n }\n return x;\n}\n"],"mappings":";;;AAOA,MAAa,QAAQ;;AAErB,MAAa,MAAM;AACnB,MAAa,QAAQ;AACrB,MAAa,OAAO;AACpB,MAAa,QAAQ;;;;;;;AAOrB,MAAa,oBAAoB;;AAGjC,MAAa,kBAAkB;;;;;;;;;;;;;;AAe/B,SAAgB,qCAA6C;CAC3D,MAAM,MACJ,OAAO,YAAY,cACf,QAAQ,KAAK,gDACb,KAAA;AACN,KAAI,QAAQ,KAAA,KAAa,QAAQ,IAAI;EACnC,MAAM,SAAS,OAAO,SAAS,KAAK,GAAG;AACvC,MAAI,OAAO,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