@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
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { BaseChannel } from "./channels/base.cjs";
2
- import { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, START, Send, isCommand, isInterrupted } from "./constants.cjs";
2
+ import { TimeoutPolicy } from "./pregel/utils/timeout.cjs";
3
+ import { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, START, Send, SendOptions, isCommand, isInterrupted } from "./constants.cjs";
4
+ import { DeltaChannel, DeltaReducer } from "./channels/delta.cjs";
3
5
  import { BinaryOperator, BinaryOperatorAggregate } from "./channels/binop.cjs";
4
6
  import { AnyValue } from "./channels/any_value.cjs";
5
7
  import { LastValue } from "./channels/last_value.cjs";
@@ -8,6 +10,7 @@ import { EphemeralValue } from "./channels/ephemeral_value.cjs";
8
10
  import { NamedBarrierValue } from "./channels/named_barrier_value.cjs";
9
11
  import { Topic } from "./channels/topic.cjs";
10
12
  import { UntrackedValueChannel } from "./channels/untracked_value.cjs";
13
+ import { RunControl } from "./pregel/runtime.cjs";
11
14
  import { ExecutionInfo, LangGraphRunnableConfig, Runtime, ServerInfo } from "./pregel/runnable_types.cjs";
12
15
  import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.cjs";
13
16
  import { CachePolicy, RetryPolicy } from "./pregel/utils/index.cjs";
@@ -24,22 +27,22 @@ import { createValuesTransformer } from "./stream/transformers/values.cjs";
24
27
  import { CreateGraphRunStreamOptions, GraphRunStream, SubgraphRunStream, createGraphRunStream } from "./stream/run-stream.cjs";
25
28
  import { ChatModelStreamImpl } from "./stream/index.cjs";
26
29
  import { Pregel } from "./pregel/index.cjs";
27
- import { AddNodeOptions, CompiledGraph, CompiledGraphType, Graph, NodeSpec } from "./graph/graph.cjs";
28
- import { InferInterruptInputType, InferInterruptResumeType, interrupt } from "./interrupt.cjs";
29
- import { InferWriterType, writer } from "./writer.cjs";
30
+ import { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isNodeError, isNodeTimeoutError, isParentCommand } from "./errors.cjs";
30
31
  import { isSerializableSchema, isStandardSchema } from "./state/types.cjs";
31
32
  import { ReducedValue, ReducedValueInit } from "./state/values/reduced.cjs";
32
33
  import { UntrackedValue, UntrackedValueInit } from "./state/values/untracked.cjs";
33
34
  import { AnyStateSchema, InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition } from "./state/schema.cjs";
34
35
  import { ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ExtractStateType, ExtractUpdateType, GraphNode, GraphNodeReturnValue, GraphNodeTypes, StateDefinitionInit, StateGraphInit, StateGraphOptions, ToStateDefinition } from "./graph/types.cjs";
35
- import { CompiledStateGraph, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec } from "./graph/state.cjs";
36
- import { Messages, REMOVE_ALL_MESSAGES, messagesStateReducer } from "./graph/messages_reducer.cjs";
36
+ import { AddNodeOptions, CompiledGraph, CompiledGraphType, Graph, NodeSpec } from "./graph/graph.cjs";
37
+ import { InferInterruptInputType, InferInterruptResumeType, interrupt } from "./interrupt.cjs";
38
+ import { InferWriterType, writer } from "./writer.cjs";
39
+ import { CompiledStateGraph, NodePolicyOptions, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec } from "./graph/state.cjs";
40
+ import { Messages, REMOVE_ALL_MESSAGES, messagesDeltaReducer, messagesStateReducer } from "./graph/messages_reducer.cjs";
37
41
  import { MessageGraph, pushMessage } from "./graph/message.cjs";
38
- import { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand } from "./errors.cjs";
39
42
  import { EntrypointOptions, TaskOptions, entrypoint, getPreviousState, task } from "./func/index.cjs";
40
43
  import { MessagesAnnotation, MessagesZodMeta, MessagesZodState } from "./graph/messages_annotation.cjs";
41
44
  import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter.cjs";
42
45
  import { MessagesValue } from "./state/prebuilt/messages.cjs";
43
46
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.cjs";
44
47
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "./web.cjs";
45
- export { AddNodeOptions, AgentStatus, Annotation, AnnotationRoot, AnyStateSchema, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, CachePolicy, ChatModelStream, ChatModelStreamImpl, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandInstance, CommandParams, CompiledGraph, CompiledGraphType, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ConvertToProtocolEventOptions, CreateGraphRunStreamOptions, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, StreamChannel as EventLog, ExecutionInfo, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InferExtensions, InferInterruptInputType, InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, InferWriterType, Interrupt, InterruptPayload, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, LifecycleCause, LifecycleData, LifecycleEntry, LifecycleProjection, LifecycleTransformerOptions, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, Namespace, NamespaceMatchType, NativeStreamTransformer, NodeInterrupt, NodeSpec, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, ProtocolEvent, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, STREAM_EVENTS_V3_MODES, SearchOperation, Send, ServerInfo, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphInit, StateGraphInputError, StateGraphNodeSpec, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, StateSnapshot, StateType, StreamChannel, StreamEmitter, StreamMode, StreamOutputMap, StreamTransformer, SubgraphDiscoveryProjection, SubgraphDiscoveryTransformerOptions, SubgraphRunStream, TaskOptions, ToStateDefinition, ToolCallStatus, ToolCallStream, ToolsEventData, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, UpdatesEventData, UsageInfo, WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
48
+ export { AddNodeOptions, AgentStatus, Annotation, AnnotationRoot, AnyStateSchema, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, CachePolicy, ChatModelStream, ChatModelStreamImpl, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandInstance, CommandParams, CompiledGraph, CompiledGraphType, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ConvertToProtocolEventOptions, CreateGraphRunStreamOptions, DeltaChannel, DeltaReducer, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, StreamChannel as EventLog, ExecutionInfo, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InferExtensions, InferInterruptInputType, InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, InferWriterType, Interrupt, InterruptPayload, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, LifecycleCause, LifecycleData, LifecycleEntry, LifecycleProjection, LifecycleTransformerOptions, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, Namespace, NamespaceMatchType, NativeStreamTransformer, NodeError, NodeInterrupt, NodePolicyOptions, NodeSpec, NodeTimeoutError, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, ProtocolEvent, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, RunControl, Runtime, START, STREAM_EVENTS_V3_MODES, SearchOperation, Send, SendOptions, ServerInfo, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphInit, StateGraphInputError, StateGraphNodeSpec, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, StateSnapshot, StateType, StreamChannel, StreamEmitter, StreamMode, StreamOutputMap, StreamTransformer, SubgraphDiscoveryProjection, SubgraphDiscoveryTransformerOptions, SubgraphRunStream, TaskOptions, TimeoutPolicy, ToStateDefinition, ToolCallStatus, ToolCallStream, ToolsEventData, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, UpdatesEventData, UsageInfo, WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, pushMessage, task, writer };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { BaseChannel } from "./channels/base.js";
2
- import { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, START, Send, isCommand, isInterrupted } from "./constants.js";
2
+ import { TimeoutPolicy } from "./pregel/utils/timeout.js";
3
+ import { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, START, Send, SendOptions, isCommand, isInterrupted } from "./constants.js";
4
+ import { DeltaChannel, DeltaReducer } from "./channels/delta.js";
3
5
  import { BinaryOperator, BinaryOperatorAggregate } from "./channels/binop.js";
4
6
  import { AnyValue } from "./channels/any_value.js";
5
7
  import { LastValue } from "./channels/last_value.js";
@@ -8,6 +10,7 @@ import { EphemeralValue } from "./channels/ephemeral_value.js";
8
10
  import { NamedBarrierValue } from "./channels/named_barrier_value.js";
9
11
  import { Topic } from "./channels/topic.js";
10
12
  import { UntrackedValueChannel } from "./channels/untracked_value.js";
13
+ import { RunControl } from "./pregel/runtime.js";
11
14
  import { ExecutionInfo, LangGraphRunnableConfig, Runtime, ServerInfo } from "./pregel/runnable_types.js";
12
15
  import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.js";
13
16
  import { CachePolicy, RetryPolicy } from "./pregel/utils/index.js";
@@ -24,22 +27,22 @@ import { createValuesTransformer } from "./stream/transformers/values.js";
24
27
  import { CreateGraphRunStreamOptions, GraphRunStream, SubgraphRunStream, createGraphRunStream } from "./stream/run-stream.js";
25
28
  import { ChatModelStreamImpl } from "./stream/index.js";
26
29
  import { Pregel } from "./pregel/index.js";
27
- import { AddNodeOptions, CompiledGraph, CompiledGraphType, Graph, NodeSpec } from "./graph/graph.js";
28
- import { InferInterruptInputType, InferInterruptResumeType, interrupt } from "./interrupt.js";
29
- import { InferWriterType, writer } from "./writer.js";
30
+ import { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isNodeError, isNodeTimeoutError, isParentCommand } from "./errors.js";
30
31
  import { isSerializableSchema, isStandardSchema } from "./state/types.js";
31
32
  import { ReducedValue, ReducedValueInit } from "./state/values/reduced.js";
32
33
  import { UntrackedValue, UntrackedValueInit } from "./state/values/untracked.js";
33
34
  import { AnyStateSchema, InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition } from "./state/schema.js";
34
35
  import { ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ExtractStateType, ExtractUpdateType, GraphNode, GraphNodeReturnValue, GraphNodeTypes, StateDefinitionInit, StateGraphInit, StateGraphOptions, ToStateDefinition } from "./graph/types.js";
35
- import { CompiledStateGraph, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec } from "./graph/state.js";
36
- import { Messages, REMOVE_ALL_MESSAGES, messagesStateReducer } from "./graph/messages_reducer.js";
36
+ import { AddNodeOptions, CompiledGraph, CompiledGraphType, Graph, NodeSpec } from "./graph/graph.js";
37
+ import { InferInterruptInputType, InferInterruptResumeType, interrupt } from "./interrupt.js";
38
+ import { InferWriterType, writer } from "./writer.js";
39
+ import { CompiledStateGraph, NodePolicyOptions, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec } from "./graph/state.js";
40
+ import { Messages, REMOVE_ALL_MESSAGES, messagesDeltaReducer, messagesStateReducer } from "./graph/messages_reducer.js";
37
41
  import { MessageGraph, pushMessage } from "./graph/message.js";
38
- import { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand } from "./errors.js";
39
42
  import { EntrypointOptions, TaskOptions, entrypoint, getPreviousState, task } from "./func/index.js";
40
43
  import { MessagesAnnotation, MessagesZodMeta, MessagesZodState } from "./graph/messages_annotation.js";
41
44
  import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter.js";
42
45
  import { MessagesValue } from "./state/prebuilt/messages.js";
43
46
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
44
47
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "./web.js";
45
- export { AddNodeOptions, AgentStatus, Annotation, AnnotationRoot, AnyStateSchema, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, CachePolicy, ChatModelStream, ChatModelStreamImpl, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandInstance, CommandParams, CompiledGraph, CompiledGraphType, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ConvertToProtocolEventOptions, CreateGraphRunStreamOptions, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, StreamChannel as EventLog, ExecutionInfo, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InferExtensions, InferInterruptInputType, InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, InferWriterType, Interrupt, InterruptPayload, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, LifecycleCause, LifecycleData, LifecycleEntry, LifecycleProjection, LifecycleTransformerOptions, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, Namespace, NamespaceMatchType, NativeStreamTransformer, NodeInterrupt, NodeSpec, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, ProtocolEvent, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, STREAM_EVENTS_V3_MODES, SearchOperation, Send, ServerInfo, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphInit, StateGraphInputError, StateGraphNodeSpec, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, StateSnapshot, StateType, StreamChannel, StreamEmitter, StreamMode, StreamOutputMap, StreamTransformer, SubgraphDiscoveryProjection, SubgraphDiscoveryTransformerOptions, SubgraphRunStream, TaskOptions, ToStateDefinition, ToolCallStatus, ToolCallStream, ToolsEventData, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, UpdatesEventData, UsageInfo, WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
48
+ export { AddNodeOptions, AgentStatus, Annotation, AnnotationRoot, AnyStateSchema, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, CachePolicy, ChatModelStream, ChatModelStreamImpl, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandInstance, CommandParams, CompiledGraph, CompiledGraphType, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ConvertToProtocolEventOptions, CreateGraphRunStreamOptions, DeltaChannel, DeltaReducer, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, StreamChannel as EventLog, ExecutionInfo, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InferExtensions, InferInterruptInputType, InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, InferWriterType, Interrupt, InterruptPayload, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, LifecycleCause, LifecycleData, LifecycleEntry, LifecycleProjection, LifecycleTransformerOptions, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, Namespace, NamespaceMatchType, NativeStreamTransformer, NodeError, NodeInterrupt, NodePolicyOptions, NodeSpec, NodeTimeoutError, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, ProtocolEvent, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, RunControl, Runtime, START, STREAM_EVENTS_V3_MODES, SearchOperation, Send, SendOptions, ServerInfo, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphInit, StateGraphInputError, StateGraphNodeSpec, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, StateSnapshot, StateType, StreamChannel, StreamEmitter, StreamMode, StreamOutputMap, StreamTransformer, SubgraphDiscoveryProjection, SubgraphDiscoveryTransformerOptions, SubgraphRunStream, TaskOptions, TimeoutPolicy, ToStateDefinition, ToolCallStatus, ToolCallStream, ToolsEventData, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, UpdatesEventData, UsageInfo, WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, pushMessage, task, writer };
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { initializeAsyncLocalStorageSingleton } from "./node.js";
2
2
  import { COMMAND_SYMBOL, Command, CommandInstance, END, INTERRUPT, Overwrite, START, Send, isCommand, isInterrupted } from "./constants.js";
3
- import { BaseLangGraphError, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand } from "./errors.js";
3
+ import { BaseLangGraphError, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isNodeError, isNodeTimeoutError, isParentCommand } from "./errors.js";
4
4
  import { BaseChannel } from "./channels/base.js";
5
5
  import { BinaryOperatorAggregate } from "./channels/binop.js";
6
6
  import { Annotation } from "./graph/annotation.js";
7
7
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
8
+ import { RunControl } from "./pregel/runtime.js";
8
9
  import { STREAM_EVENTS_V3_MODES, convertToProtocolEvent, isCheckpointEnvelope } from "./stream/convert.js";
9
10
  import { StreamChannel } from "./stream/stream-channel.js";
10
11
  import { createLifecycleTransformer, filterLifecycleEntries } from "./stream/transformers/lifecycle.js";
@@ -18,11 +19,12 @@ import { interrupt } from "./interrupt.js";
18
19
  import { Graph } from "./graph/graph.js";
19
20
  import { isSerializableSchema, isStandardSchema } from "./state/types.js";
20
21
  import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter.js";
22
+ import { DeltaChannel } from "./channels/delta.js";
21
23
  import { UntrackedValueChannel } from "./channels/untracked_value.js";
22
24
  import { ReducedValue } from "./state/values/reduced.js";
23
25
  import { UntrackedValue } from "./state/values/untracked.js";
24
26
  import { StateSchema } from "./state/schema.js";
25
- import { REMOVE_ALL_MESSAGES, messagesStateReducer } from "./graph/messages_reducer.js";
27
+ import { REMOVE_ALL_MESSAGES, messagesDeltaReducer, messagesStateReducer } from "./graph/messages_reducer.js";
26
28
  import { MessagesValue } from "./state/prebuilt/messages.js";
27
29
  import { CompiledStateGraph, StateGraph } from "./graph/state.js";
28
30
  import { MessageGraph, pushMessage } from "./graph/message.js";
@@ -33,6 +35,6 @@ import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, InMemoryStore, Memor
33
35
  //#region src/index.ts
34
36
  initializeAsyncLocalStorageSingleton();
35
37
  //#endregion
36
- export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, COMMAND_SYMBOL, ChatModelStreamImpl, Command, CommandInstance, CompiledStateGraph, END, EmptyChannelError, EmptyInputError, StreamChannel as EventLog, Graph, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeInterrupt, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, START, STREAM_EVENTS_V3_MODES, Send, StateGraph, StateGraphInputError, StateSchema, StreamChannel, SubgraphRunStream, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
38
+ export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, COMMAND_SYMBOL, ChatModelStreamImpl, Command, CommandInstance, CompiledStateGraph, DeltaChannel, END, EmptyChannelError, EmptyInputError, StreamChannel as EventLog, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, RunControl, START, STREAM_EVENTS_V3_MODES, Send, StateGraph, StateGraphInputError, StateSchema, StreamChannel, SubgraphRunStream, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, pushMessage, task, writer };
37
39
 
38
40
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\nimport { initializeAsyncLocalStorageSingleton } from \"./node.js\";\n\n// Initialize global async local storage instance for tracing\ninitializeAsyncLocalStorageSingleton();\n\nexport * from \"./web.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,sCAAsC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\nimport { initializeAsyncLocalStorageSingleton } from \"./node.js\";\n\n// Initialize global async local storage instance for tracing\ninitializeAsyncLocalStorageSingleton();\n\nexport * from \"./web.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,sCAAsC"}
@@ -9,8 +9,8 @@ import { Messages } from "../graph/messages_reducer.cjs";
9
9
  import { MessagesAnnotation } from "../graph/messages_annotation.cjs";
10
10
  import { ToolNode } from "./tool_node.cjs";
11
11
  import { All, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
12
- import { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
13
12
  import { Runnable, RunnableBinding, RunnableLike, RunnableToolLike } from "@langchain/core/runnables";
13
+ import { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
14
14
  import * as _langchain_core_messages0 from "@langchain/core/messages";
15
15
  import { BaseMessage, BaseMessageLike, SystemMessage } from "@langchain/core/messages";
16
16
  import { DynamicTool, StructuredToolInterface } from "@langchain/core/tools";
@@ -53,7 +53,13 @@ function _localRead(checkpoint, channels, task, select, fresh = false) {
53
53
  let values;
54
54
  if (fresh && updated.size > 0) {
55
55
  const localChannels = Object.fromEntries(Object.entries(channels).filter(([k, _]) => updated.has(k)));
56
- const newCheckpoint = require_base.createCheckpoint(checkpoint, localChannels, -1);
56
+ const channelsToSnapshot = /* @__PURE__ */ new Set();
57
+ for (const k in localChannels) {
58
+ if (!Object.prototype.hasOwnProperty.call(localChannels, k)) continue;
59
+ const ch = localChannels[k];
60
+ if (require_base.isDeltaChannel(ch) && ch.isAvailable()) channelsToSnapshot.add(k);
61
+ }
62
+ const newCheckpoint = require_base.createCheckpoint(checkpoint, localChannels, -1, { channelsToSnapshot });
57
63
  const newChannels = require_base.emptyChannels(localChannels, newCheckpoint);
58
64
  _applyWrites((0, _langchain_langgraph_checkpoint.copyCheckpoint)(newCheckpoint), newChannels, [task], void 0, void 0);
59
65
  values = require_io.readChannels({
@@ -76,26 +82,34 @@ const IGNORE = new Set([
76
82
  require_constants.RESUME,
77
83
  require_constants.INTERRUPT,
78
84
  require_constants.RETURN,
79
- require_constants.ERROR
85
+ require_constants.ERROR,
86
+ require_constants.ERROR_SOURCE_NODE
80
87
  ]);
88
+ const RESERVED_SET = new Set(require_constants.RESERVED);
81
89
  function _applyWrites(checkpoint, channels, tasks, getNextVersion, triggerToNodes) {
90
+ const pathCache = /* @__PURE__ */ new Map();
91
+ for (const task of tasks) pathCache.set(task, task.path?.slice(0, 3) || []);
82
92
  tasks.sort((a, b) => {
83
- const aPath = a.path?.slice(0, 3) || [];
84
- const bPath = b.path?.slice(0, 3) || [];
93
+ const aPath = pathCache.get(a);
94
+ const bPath = pathCache.get(b);
85
95
  for (let i = 0; i < Math.min(aPath.length, bPath.length); i += 1) {
86
96
  if (aPath[i] < bPath[i]) return -1;
87
97
  if (aPath[i] > bPath[i]) return 1;
88
98
  }
89
99
  return aPath.length - bPath.length;
90
100
  });
91
- const bumpStep = tasks.some((task) => task.triggers.length > 0);
92
101
  const onlyChannels = require_base.getOnlyChannels(channels);
102
+ let bumpStep = false;
103
+ const channelsToConsume = /* @__PURE__ */ new Set();
93
104
  for (const task of tasks) {
105
+ if (task.triggers.length > 0) bumpStep = true;
94
106
  checkpoint.versions_seen[task.name] ??= {};
95
- for (const chan of task.triggers) if (chan in checkpoint.channel_versions) checkpoint.versions_seen[task.name][chan] = checkpoint.channel_versions[chan];
107
+ for (const chan of task.triggers) {
108
+ if (chan in checkpoint.channel_versions) checkpoint.versions_seen[task.name][chan] = checkpoint.channel_versions[chan];
109
+ if (!RESERVED_SET.has(chan)) channelsToConsume.add(chan);
110
+ }
96
111
  }
97
112
  let maxVersion = maxChannelMapVersion(checkpoint.channel_versions);
98
- const channelsToConsume = new Set(tasks.flatMap((task) => task.triggers).filter((chan) => !require_constants.RESERVED.includes(chan)));
99
113
  let usedNewVersion = false;
100
114
  for (const chan of channelsToConsume) if (chan in onlyChannels && onlyChannels[chan].consume()) {
101
115
  if (getNextVersion !== void 0) {
@@ -167,22 +181,53 @@ function* candidateNodes(checkpoint, processes, extra) {
167
181
  }
168
182
  }
169
183
  /**
184
+ * Build an index over pendingWrites for O(1) lookups.
185
+ *
186
+ * @internal Exported for benchmarks and regression tests only.
187
+ */
188
+ function _indexPendingWrites(pendingWrites) {
189
+ let nullResume;
190
+ const resumeByTaskId = /* @__PURE__ */ new Map();
191
+ const successfulWriteTaskIds = /* @__PURE__ */ new Set();
192
+ if (pendingWrites) for (const [tid, chan, val] of pendingWrites) {
193
+ if (tid === "00000000-0000-0000-0000-000000000000" && chan === "__resume__" && nullResume === void 0) nullResume = val;
194
+ if (chan === "__resume__" && tid !== "00000000-0000-0000-0000-000000000000") {
195
+ let arr = resumeByTaskId.get(tid);
196
+ if (!arr) {
197
+ arr = [];
198
+ resumeByTaskId.set(tid, arr);
199
+ }
200
+ arr.push(val);
201
+ }
202
+ if (chan !== "__error__") successfulWriteTaskIds.add(tid);
203
+ }
204
+ return {
205
+ nullResume,
206
+ resumeByTaskId,
207
+ successfulWriteTaskIds
208
+ };
209
+ }
210
+ /**
170
211
  * Prepare the set of tasks that will make up the next Pregel step.
171
212
  * This is the union of all PUSH tasks (Sends) and PULL tasks (nodes triggered
172
213
  * by edges).
173
214
  */
174
215
  function _prepareNextTasks(checkpoint, pendingWrites, processes, channels, config, forExecution, extra) {
175
216
  const tasks = {};
217
+ const indexedExtra = extra.pendingWritesIndex ? extra : {
218
+ ...extra,
219
+ pendingWritesIndex: _indexPendingWrites(pendingWrites)
220
+ };
176
221
  const tasksChannel = channels[require_constants.TASKS];
177
222
  if (tasksChannel?.isAvailable()) {
178
223
  const len = tasksChannel.get().length;
179
224
  for (let i = 0; i < len; i += 1) {
180
- const task = _prepareSingleTask([require_constants.PUSH, i], checkpoint, pendingWrites, processes, channels, config, forExecution, extra);
225
+ const task = _prepareSingleTask([require_constants.PUSH, i], checkpoint, pendingWrites, processes, channels, config, forExecution, indexedExtra);
181
226
  if (task !== void 0) tasks[task.id] = task;
182
227
  }
183
228
  }
184
- for (const name of candidateNodes(checkpoint, processes, extra)) {
185
- const task = _prepareSingleTask([require_constants.PULL, name], checkpoint, pendingWrites, processes, channels, config, forExecution, extra);
229
+ for (const name of candidateNodes(checkpoint, processes, indexedExtra)) {
230
+ const task = _prepareSingleTask([require_constants.PULL, name], checkpoint, pendingWrites, processes, channels, config, forExecution, indexedExtra);
186
231
  if (task !== void 0) tasks[task.id] = task;
187
232
  }
188
233
  return tasks;
@@ -259,7 +304,8 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
259
304
  taskId: id,
260
305
  currentTaskInput: call.input,
261
306
  resumeMap: config.configurable?.[require_constants.CONFIG_KEY_RESUME_MAP],
262
- namespaceHash: require_hash.XXH3(taskCheckpointNamespace)
307
+ namespaceHash: require_hash.XXH3(taskCheckpointNamespace),
308
+ pendingWritesIndex: extra.pendingWritesIndex
263
309
  }),
264
310
  [require_constants.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[require_constants.PREVIOUS],
265
311
  checkpoint_id: void 0,
@@ -277,7 +323,8 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
277
323
  } : void 0,
278
324
  id,
279
325
  path: outputTaskPath,
280
- writers: []
326
+ writers: [],
327
+ timeout: call.timeout
281
328
  };
282
329
  } else return {
283
330
  id,
@@ -290,7 +337,7 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
290
337
  if (!channels["__pregel_tasks"]?.isAvailable()) return;
291
338
  const sends = channels[require_constants.TASKS].get();
292
339
  if (index < 0 || index >= sends.length) return;
293
- const packet = require_constants._isSendInterface(sends[index]) && !require_constants._isSend(sends[index]) ? new require_constants.Send(sends[index].node, sends[index].args) : sends[index];
340
+ const packet = require_constants._isSendInterface(sends[index]) && !require_constants._isSend(sends[index]) ? new require_constants.Send(sends[index].node, sends[index].args, sends[index].timeout !== void 0 ? { timeout: sends[index].timeout } : void 0) : sends[index];
294
341
  if (!require_constants._isSendInterface(packet)) {
295
342
  console.warn(`Ignoring invalid packet ${JSON.stringify(packet)} in pending sends.`);
296
343
  return;
@@ -367,7 +414,8 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
367
414
  taskId,
368
415
  currentTaskInput: packet.args,
369
416
  resumeMap: config.configurable?.[require_constants.CONFIG_KEY_RESUME_MAP],
370
- namespaceHash: require_hash.XXH3(taskCheckpointNamespace)
417
+ namespaceHash: require_hash.XXH3(taskCheckpointNamespace),
418
+ pendingWritesIndex: extra.pendingWritesIndex
371
419
  }),
372
420
  [require_constants.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[require_constants.PREVIOUS],
373
421
  checkpoint_id: void 0,
@@ -389,7 +437,8 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
389
437
  } : void 0,
390
438
  id: taskId,
391
439
  path: taskPath,
392
- writers: proc.getWriters()
440
+ writers: proc.getWriters(),
441
+ timeout: packet.timeout ?? proc.timeout
393
442
  };
394
443
  }
395
444
  } else return {
@@ -411,7 +460,7 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
411
460
  require_constants.PULL,
412
461
  name
413
462
  ]), checkpoint.id);
414
- if (pendingWrites.some((w) => w[0] === taskId && w[1] !== "__error__")) return;
463
+ if (extra.pendingWritesIndex ? extra.pendingWritesIndex.successfulWriteTaskIds.has(taskId) : pendingWrites.some((w) => w[0] === taskId && w[1] !== "__error__")) return;
415
464
  }
416
465
  const nullVersion = require_index.getNullChannelVersion(checkpoint.channel_versions);
417
466
  if (nullVersion === void 0) return;
@@ -491,7 +540,8 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
491
540
  taskId,
492
541
  currentTaskInput: val,
493
542
  resumeMap: config.configurable?.[require_constants.CONFIG_KEY_RESUME_MAP],
494
- namespaceHash: require_hash.XXH3(taskCheckpointNamespace)
543
+ namespaceHash: require_hash.XXH3(taskCheckpointNamespace),
544
+ pendingWritesIndex: extra.pendingWritesIndex
495
545
  }),
496
546
  [require_constants.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[require_constants.PREVIOUS],
497
547
  checkpoint_id: void 0,
@@ -513,7 +563,8 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
513
563
  } : void 0,
514
564
  id: taskId,
515
565
  path: taskPath,
516
- writers: proc.getWriters()
566
+ writers: proc.getWriters(),
567
+ timeout: proc.timeout
517
568
  };
518
569
  }
519
570
  } else return {
@@ -526,6 +577,115 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
526
577
  }
527
578
  }
528
579
  /**
580
+ * Prepare an immediate node-level error handler task for a failed task.
581
+ *
582
+ * The handler runs only after the failed node's retry policy is exhausted (the
583
+ * runner schedules it once a non-bubble-up error settles). It is prepared like
584
+ * a PUSH task targeting the auto-generated handler node, receives the failed
585
+ * node's input, and is injected with a {@link NodeError} under
586
+ * {@link CONFIG_KEY_NODE_ERROR} so the handler can inspect the failure
587
+ * provenance (and route via `Command({ goto })`).
588
+ *
589
+ * @internal
590
+ */
591
+ function _prepareNodeErrorHandlerTask(failedTask, handlerNodeName, error, checkpoint, pendingWrites, processes, channels, config, extra) {
592
+ const { step, checkpointer, manager } = extra;
593
+ const proc = processes[handlerNodeName];
594
+ if (proc === void 0) return;
595
+ const node = proc.getNode();
596
+ if (node === void 0) return;
597
+ const configurable = config.configurable ?? {};
598
+ const parentNamespace = configurable.checkpoint_ns ?? "";
599
+ const triggers = [require_constants.PUSH];
600
+ const checkpointNamespace = parentNamespace === "" ? handlerNodeName : `${parentNamespace}|${handlerNodeName}`;
601
+ const taskId = (0, _langchain_langgraph_checkpoint.uuid5)(JSON.stringify([
602
+ checkpointNamespace,
603
+ step.toString(),
604
+ handlerNodeName,
605
+ require_constants.PUSH,
606
+ "node_error_handler",
607
+ failedTask.id
608
+ ]), checkpoint.id);
609
+ const taskCheckpointNamespace = `${checkpointNamespace}:${taskId}`;
610
+ const taskPath = [
611
+ require_constants.PUSH,
612
+ String(failedTask.name),
613
+ handlerNodeName,
614
+ false
615
+ ];
616
+ let metadata = {
617
+ langgraph_step: step,
618
+ langgraph_node: handlerNodeName,
619
+ langgraph_triggers: triggers,
620
+ langgraph_path: taskPath,
621
+ langgraph_checkpoint_ns: taskCheckpointNamespace,
622
+ checkpoint_ns: taskCheckpointNamespace
623
+ };
624
+ if (proc.metadata !== void 0) metadata = {
625
+ ...metadata,
626
+ ...proc.metadata
627
+ };
628
+ const writes = [];
629
+ const executionInfo = {
630
+ checkpointId: checkpoint.id,
631
+ checkpointNs: taskCheckpointNamespace,
632
+ taskId,
633
+ threadId: configurable.thread_id,
634
+ runId: config.runId != null ? String(config.runId) : void 0,
635
+ nodeAttempt: 1
636
+ };
637
+ return {
638
+ name: handlerNodeName,
639
+ input: failedTask.input,
640
+ proc: node,
641
+ subgraphs: proc.subgraphs,
642
+ writes,
643
+ config: {
644
+ ...(0, _langchain_core_runnables.patchConfig)((0, _langchain_core_runnables.mergeConfigs)(config, {
645
+ metadata,
646
+ tags: proc.tags,
647
+ store: extra.store ?? config.store
648
+ }), {
649
+ runName: handlerNodeName,
650
+ callbacks: manager?.getChild(`graph:step:${step}`),
651
+ configurable: {
652
+ [require_constants.CONFIG_KEY_TASK_ID]: taskId,
653
+ [require_constants.CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => writes.push(...items), processes, writes_),
654
+ [require_constants.CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
655
+ name: handlerNodeName,
656
+ writes,
657
+ triggers,
658
+ path: taskPath
659
+ }, select_, fresh_),
660
+ [require_constants.CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable["__pregel_checkpointer"],
661
+ [require_constants.CONFIG_KEY_CHECKPOINT_MAP]: {
662
+ ...configurable[require_constants.CONFIG_KEY_CHECKPOINT_MAP],
663
+ [parentNamespace]: checkpoint.id
664
+ },
665
+ [require_constants.CONFIG_KEY_SCRATCHPAD]: _scratchpad({
666
+ pendingWrites: pendingWrites ?? [],
667
+ taskId,
668
+ currentTaskInput: failedTask.input,
669
+ resumeMap: config.configurable?.[require_constants.CONFIG_KEY_RESUME_MAP],
670
+ namespaceHash: require_hash.XXH3(taskCheckpointNamespace)
671
+ }),
672
+ [require_constants.CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[require_constants.PREVIOUS],
673
+ [require_constants.CONFIG_KEY_NODE_ERROR]: new require_errors.NodeError(String(failedTask.name), error),
674
+ checkpoint_id: void 0,
675
+ checkpoint_ns: taskCheckpointNamespace
676
+ }
677
+ }),
678
+ executionInfo
679
+ },
680
+ triggers,
681
+ retry_policy: proc.retryPolicy,
682
+ cache_key: void 0,
683
+ id: taskId,
684
+ path: taskPath,
685
+ writers: proc.getWriters()
686
+ };
687
+ }
688
+ /**
529
689
  * Function injected under CONFIG_KEY_READ in task config, to read current state.
530
690
  * Used by conditional edges to read a copy of the state with reflecting the writes
531
691
  * from that node only.
@@ -581,13 +741,13 @@ function sanitizeUntrackedValuesInSend(packet, channels) {
581
741
  }
582
742
  return new require_constants.Send(packet.node, sanitizedArg);
583
743
  }
584
- function _scratchpad({ pendingWrites, taskId, currentTaskInput, resumeMap, namespaceHash }) {
585
- const nullResume = pendingWrites.find(([writeTaskId, chan]) => writeTaskId === "00000000-0000-0000-0000-000000000000" && chan === "__resume__")?.[2];
744
+ function _scratchpad({ pendingWrites, taskId, currentTaskInput, resumeMap, namespaceHash, pendingWritesIndex }) {
745
+ const nullResume = pendingWritesIndex ? pendingWritesIndex.nullResume : pendingWrites.find(([writeTaskId, chan]) => writeTaskId === "00000000-0000-0000-0000-000000000000" && chan === "__resume__")?.[2];
586
746
  const scratchpad = {
587
747
  callCounter: 0,
588
748
  interruptCounter: -1,
589
749
  resume: (() => {
590
- const result = pendingWrites.filter(([writeTaskId, chan]) => writeTaskId === taskId && chan === "__resume__").flatMap(([_writeTaskId, _chan, resume]) => resume);
750
+ const result = pendingWritesIndex ? (pendingWritesIndex.resumeByTaskId.get(taskId) ?? []).flat() : pendingWrites.filter(([writeTaskId, chan]) => writeTaskId === taskId && chan === "__resume__").flatMap(([_writeTaskId, _chan, resume]) => resume);
591
751
  if (resumeMap != null && namespaceHash in resumeMap) {
592
752
  const mappedResume = resumeMap[namespaceHash];
593
753
  result.push(mappedResume);
@@ -611,6 +771,7 @@ function _scratchpad({ pendingWrites, taskId, currentTaskInput, resumeMap, names
611
771
  exports._applyWrites = _applyWrites;
612
772
  exports._localRead = _localRead;
613
773
  exports._prepareNextTasks = _prepareNextTasks;
774
+ exports._prepareNodeErrorHandlerTask = _prepareNodeErrorHandlerTask;
614
775
  exports._prepareSingleTask = _prepareSingleTask;
615
776
  exports.increment = increment;
616
777
  exports.sanitizeUntrackedValuesInSend = sanitizeUntrackedValuesInSend;