@langchain/langgraph 0.4.9 → 1.0.0-alpha.1
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.
- package/CHANGELOG.md +26 -0
- package/README.md +1 -2
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/channels/any_value.cjs +44 -63
- package/dist/channels/any_value.cjs.map +1 -0
- package/dist/channels/any_value.d.cts +24 -0
- package/dist/channels/any_value.d.cts.map +1 -0
- package/dist/channels/any_value.d.ts +16 -11
- package/dist/channels/any_value.d.ts.map +1 -0
- package/dist/channels/any_value.js +42 -57
- package/dist/channels/any_value.js.map +1 -1
- package/dist/channels/base.cjs +93 -133
- package/dist/channels/base.cjs.map +1 -0
- package/dist/channels/base.d.cts +79 -0
- package/dist/channels/base.d.cts.map +1 -0
- package/dist/channels/base.d.ts +77 -73
- package/dist/channels/base.d.ts.map +1 -0
- package/dist/channels/base.js +90 -127
- package/dist/channels/base.js.map +1 -1
- package/dist/channels/binop.cjs +47 -77
- package/dist/channels/binop.cjs.map +1 -0
- package/dist/channels/binop.d.cts +22 -0
- package/dist/channels/binop.d.cts.map +1 -0
- package/dist/channels/binop.d.ts +17 -12
- package/dist/channels/binop.d.ts.map +1 -0
- package/dist/channels/binop.js +45 -71
- package/dist/channels/binop.js.map +1 -1
- package/dist/channels/dynamic_barrier_value.cjs +72 -208
- package/dist/channels/dynamic_barrier_value.cjs.map +1 -0
- package/dist/channels/dynamic_barrier_value.d.cts +42 -0
- package/dist/channels/dynamic_barrier_value.d.cts.map +1 -0
- package/dist/channels/dynamic_barrier_value.d.ts +20 -35
- package/dist/channels/dynamic_barrier_value.d.ts.map +1 -0
- package/dist/channels/dynamic_barrier_value.js +69 -200
- package/dist/channels/dynamic_barrier_value.js.map +1 -1
- package/dist/channels/ephemeral_value.cjs +44 -70
- package/dist/channels/ephemeral_value.cjs.map +1 -0
- package/dist/channels/ephemeral_value.d.cts +22 -0
- package/dist/channels/ephemeral_value.d.cts.map +1 -0
- package/dist/channels/ephemeral_value.d.ts +18 -12
- package/dist/channels/ephemeral_value.d.ts.map +1 -0
- package/dist/channels/ephemeral_value.js +43 -65
- package/dist/channels/ephemeral_value.js.map +1 -1
- package/dist/channels/index.cjs +21 -10
- package/dist/channels/index.d.cts +9 -0
- package/dist/channels/index.d.ts +9 -7
- package/dist/channels/index.js +10 -3
- package/dist/channels/last_value.cjs +90 -140
- package/dist/channels/last_value.cjs.map +1 -0
- package/dist/channels/last_value.d.cts +42 -0
- package/dist/channels/last_value.d.cts.map +1 -0
- package/dist/channels/last_value.d.ts +27 -23
- package/dist/channels/last_value.d.ts.map +1 -0
- package/dist/channels/last_value.js +87 -133
- package/dist/channels/last_value.js.map +1 -1
- package/dist/channels/named_barrier_value.cjs +114 -170
- package/dist/channels/named_barrier_value.cjs.map +1 -0
- package/dist/channels/named_barrier_value.d.cts +46 -0
- package/dist/channels/named_barrier_value.d.cts.map +1 -0
- package/dist/channels/named_barrier_value.d.ts +32 -29
- package/dist/channels/named_barrier_value.d.ts.map +1 -0
- package/dist/channels/named_barrier_value.js +111 -163
- package/dist/channels/named_barrier_value.js.map +1 -1
- package/dist/channels/topic.cjs +63 -96
- package/dist/channels/topic.cjs.map +1 -0
- package/dist/channels/topic.d.cts +32 -0
- package/dist/channels/topic.d.cts.map +1 -0
- package/dist/channels/topic.d.ts +28 -19
- package/dist/channels/topic.d.ts.map +1 -0
- package/dist/channels/topic.js +61 -90
- package/dist/channels/topic.js.map +1 -1
- package/dist/constants.cjs +376 -452
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +285 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.ts +113 -148
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +336 -444
- package/dist/constants.js.map +1 -1
- package/dist/errors.cjs +151 -179
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +81 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.ts +56 -46
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +140 -165
- package/dist/errors.js.map +1 -1
- package/dist/func/index.cjs +292 -290
- package/dist/func/index.cjs.map +1 -0
- package/dist/func/index.d.cts +293 -0
- package/dist/func/index.d.cts.map +1 -0
- package/dist/func/index.d.ts +86 -72
- package/dist/func/index.d.ts.map +1 -0
- package/dist/func/index.js +288 -284
- package/dist/func/index.js.map +1 -1
- package/dist/func/types.d.cts +64 -0
- package/dist/func/types.d.cts.map +1 -0
- package/dist/func/types.d.ts +24 -19
- package/dist/func/types.d.ts.map +1 -0
- package/dist/graph/annotation.cjs +96 -120
- package/dist/graph/annotation.cjs.map +1 -0
- package/dist/graph/annotation.d.cts +116 -0
- package/dist/graph/annotation.d.cts.map +1 -0
- package/dist/graph/annotation.d.ts +33 -34
- package/dist/graph/annotation.d.ts.map +1 -0
- package/dist/graph/annotation.js +91 -112
- package/dist/graph/annotation.js.map +1 -1
- package/dist/graph/graph.cjs +419 -723
- package/dist/graph/graph.cjs.map +1 -0
- package/dist/graph/graph.d.cts +133 -0
- package/dist/graph/graph.d.cts.map +1 -0
- package/dist/graph/graph.d.ts +124 -91
- package/dist/graph/graph.d.ts.map +1 -0
- package/dist/graph/graph.js +412 -713
- package/dist/graph/graph.js.map +1 -1
- package/dist/graph/index.cjs +4 -17
- package/dist/graph/index.js +6 -5
- package/dist/graph/message.cjs +59 -104
- package/dist/graph/message.cjs.map +1 -0
- package/dist/graph/message.d.cts +19 -0
- package/dist/graph/message.d.cts.map +1 -0
- package/dist/graph/message.d.ts +11 -10
- package/dist/graph/message.d.ts.map +1 -0
- package/dist/graph/message.js +56 -98
- package/dist/graph/message.js.map +1 -1
- package/dist/graph/messages_annotation.cjs +106 -106
- package/dist/graph/messages_annotation.cjs.map +1 -0
- package/dist/graph/messages_annotation.d.cts +111 -0
- package/dist/graph/messages_annotation.d.cts.map +1 -0
- package/dist/graph/messages_annotation.d.ts +18 -9
- package/dist/graph/messages_annotation.d.ts.map +1 -0
- package/dist/graph/messages_annotation.js +100 -100
- package/dist/graph/messages_annotation.js.map +1 -1
- package/dist/graph/state.cjs +475 -779
- package/dist/graph/state.cjs.map +1 -0
- package/dist/graph/state.d.cts +231 -0
- package/dist/graph/state.d.cts.map +1 -0
- package/dist/graph/state.d.ts +148 -138
- package/dist/graph/state.d.ts.map +1 -0
- package/dist/graph/state.js +469 -769
- package/dist/graph/state.js.map +1 -1
- package/dist/graph/zod/index.cjs +10 -21
- package/dist/graph/zod/index.d.cts +3 -0
- package/dist/graph/zod/index.d.ts +3 -3
- package/dist/graph/zod/index.js +4 -4
- package/dist/graph/zod/meta.cjs +142 -177
- package/dist/graph/zod/meta.cjs.map +1 -0
- package/dist/graph/zod/meta.d.cts +116 -0
- package/dist/graph/zod/meta.d.cts.map +1 -0
- package/dist/graph/zod/meta.d.ts +99 -97
- package/dist/graph/zod/meta.d.ts.map +1 -0
- package/dist/graph/zod/meta.js +136 -170
- package/dist/graph/zod/meta.js.map +1 -1
- package/dist/graph/zod/plugin.cjs +36 -39
- package/dist/graph/zod/plugin.cjs.map +1 -0
- package/dist/graph/zod/plugin.js +34 -35
- package/dist/graph/zod/plugin.js.map +1 -1
- package/dist/graph/zod/schema.cjs +82 -110
- package/dist/graph/zod/schema.cjs.map +1 -0
- package/dist/graph/zod/schema.d.cts +38 -0
- package/dist/graph/zod/schema.d.cts.map +1 -0
- package/dist/graph/zod/schema.d.ts +12 -6
- package/dist/graph/zod/schema.d.ts.map +1 -0
- package/dist/graph/zod/schema.js +77 -103
- package/dist/graph/zod/schema.js.map +1 -1
- package/dist/graph/zod/zod-registry.cjs +41 -47
- package/dist/graph/zod/zod-registry.cjs.map +1 -0
- package/dist/graph/zod/zod-registry.d.cts +51 -0
- package/dist/graph/zod/zod-registry.d.cts.map +1 -0
- package/dist/graph/zod/zod-registry.d.ts +34 -26
- package/dist/graph/zod/zod-registry.d.ts.map +1 -0
- package/dist/graph/zod/zod-registry.js +37 -41
- package/dist/graph/zod/zod-registry.js.map +1 -1
- package/dist/hash.cjs +205 -267
- package/dist/hash.cjs.map +1 -0
- package/dist/hash.js +205 -265
- package/dist/hash.js.map +1 -1
- package/dist/index.cjs +111 -33
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -5
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/interrupt.cjs +79 -85
- package/dist/interrupt.cjs.map +1 -0
- package/dist/interrupt.d.cts +49 -0
- package/dist/interrupt.d.cts.map +1 -0
- package/dist/interrupt.d.ts +6 -1
- package/dist/interrupt.d.ts.map +1 -0
- package/dist/interrupt.js +76 -80
- package/dist/interrupt.js.map +1 -1
- package/dist/prebuilt/agentName.cjs +139 -172
- package/dist/prebuilt/agentName.cjs.map +1 -0
- package/dist/prebuilt/agentName.d.cts +42 -0
- package/dist/prebuilt/agentName.d.cts.map +1 -0
- package/dist/prebuilt/agentName.d.ts +13 -21
- package/dist/prebuilt/agentName.d.ts.map +1 -0
- package/dist/prebuilt/agentName.js +139 -168
- package/dist/prebuilt/agentName.js.map +1 -1
- package/dist/prebuilt/agent_executor.cjs +42 -80
- package/dist/prebuilt/agent_executor.cjs.map +1 -0
- package/dist/prebuilt/agent_executor.d.cts +57 -0
- package/dist/prebuilt/agent_executor.d.cts.map +1 -0
- package/dist/prebuilt/agent_executor.d.ts +47 -38
- package/dist/prebuilt/agent_executor.d.ts.map +1 -0
- package/dist/prebuilt/agent_executor.js +40 -75
- package/dist/prebuilt/agent_executor.js.map +1 -1
- package/dist/prebuilt/chat_agent_executor.cjs +66 -128
- package/dist/prebuilt/chat_agent_executor.cjs.map +1 -0
- package/dist/prebuilt/chat_agent_executor.d.cts +23 -0
- package/dist/prebuilt/chat_agent_executor.d.cts.map +1 -0
- package/dist/prebuilt/chat_agent_executor.d.ts +18 -10
- package/dist/prebuilt/chat_agent_executor.d.ts.map +1 -0
- package/dist/prebuilt/chat_agent_executor.js +63 -123
- package/dist/prebuilt/chat_agent_executor.js.map +1 -1
- package/dist/prebuilt/index.cjs +15 -18
- package/dist/prebuilt/index.d.cts +8 -0
- package/dist/prebuilt/index.d.ts +8 -8
- package/dist/prebuilt/index.js +8 -7
- package/dist/prebuilt/interrupt.d.cts +73 -0
- package/dist/prebuilt/interrupt.d.cts.map +1 -0
- package/dist/prebuilt/interrupt.d.ts +32 -15
- package/dist/prebuilt/interrupt.d.ts.map +1 -0
- package/dist/prebuilt/react_agent_executor.cjs +317 -473
- package/dist/prebuilt/react_agent_executor.cjs.map +1 -0
- package/dist/prebuilt/react_agent_executor.d.cts +229 -0
- package/dist/prebuilt/react_agent_executor.d.cts.map +1 -0
- package/dist/prebuilt/react_agent_executor.d.ts +171 -143
- package/dist/prebuilt/react_agent_executor.d.ts.map +1 -0
- package/dist/prebuilt/react_agent_executor.js +315 -465
- package/dist/prebuilt/react_agent_executor.js.map +1 -1
- package/dist/prebuilt/tool_executor.cjs +45 -67
- package/dist/prebuilt/tool_executor.cjs.map +1 -0
- package/dist/prebuilt/tool_executor.d.cts +42 -0
- package/dist/prebuilt/tool_executor.d.cts.map +1 -0
- package/dist/prebuilt/tool_executor.d.ts +30 -24
- package/dist/prebuilt/tool_executor.d.ts.map +1 -0
- package/dist/prebuilt/tool_executor.js +44 -63
- package/dist/prebuilt/tool_executor.js.map +1 -1
- package/dist/prebuilt/tool_node.cjs +213 -275
- package/dist/prebuilt/tool_node.cjs.map +1 -0
- package/dist/prebuilt/tool_node.d.cts +151 -0
- package/dist/prebuilt/tool_node.d.cts.map +1 -0
- package/dist/prebuilt/tool_node.d.ts +30 -17
- package/dist/prebuilt/tool_node.d.ts.map +1 -0
- package/dist/prebuilt/tool_node.js +209 -268
- package/dist/prebuilt/tool_node.js.map +1 -1
- package/dist/pregel/algo.cjs +551 -692
- package/dist/pregel/algo.cjs.map +1 -0
- package/dist/pregel/algo.d.cts +13 -0
- package/dist/pregel/algo.d.cts.map +1 -0
- package/dist/pregel/algo.d.ts +8 -38
- package/dist/pregel/algo.d.ts.map +1 -0
- package/dist/pregel/algo.js +546 -683
- package/dist/pregel/algo.js.map +1 -1
- package/dist/pregel/call.cjs +46 -42
- package/dist/pregel/call.cjs.map +1 -0
- package/dist/pregel/call.js +43 -37
- package/dist/pregel/call.js.map +1 -1
- package/dist/pregel/debug.cjs +153 -223
- package/dist/pregel/debug.cjs.map +1 -0
- package/dist/pregel/debug.js +152 -215
- package/dist/pregel/debug.js.map +1 -1
- package/dist/pregel/index.cjs +1138 -1604
- package/dist/pregel/index.cjs.map +1 -0
- package/dist/pregel/index.d.cts +536 -0
- package/dist/pregel/index.d.cts.map +1 -0
- package/dist/pregel/index.d.ts +460 -422
- package/dist/pregel/index.d.ts.map +1 -0
- package/dist/pregel/index.js +1129 -1592
- package/dist/pregel/index.js.map +1 -1
- package/dist/pregel/io.cjs +127 -234
- package/dist/pregel/io.cjs.map +1 -0
- package/dist/pregel/io.js +122 -225
- package/dist/pregel/io.js.map +1 -1
- package/dist/pregel/loop.cjs +542 -954
- package/dist/pregel/loop.cjs.map +1 -0
- package/dist/pregel/loop.js +539 -948
- package/dist/pregel/loop.js.map +1 -1
- package/dist/pregel/messages.cjs +104 -196
- package/dist/pregel/messages.cjs.map +1 -0
- package/dist/pregel/messages.js +102 -191
- package/dist/pregel/messages.js.map +1 -1
- package/dist/pregel/read.cjs +150 -280
- package/dist/pregel/read.cjs.map +1 -0
- package/dist/pregel/read.d.cts +51 -0
- package/dist/pregel/read.d.cts.map +1 -0
- package/dist/pregel/read.d.ts +48 -46
- package/dist/pregel/read.d.ts.map +1 -0
- package/dist/pregel/read.js +147 -274
- package/dist/pregel/read.js.map +1 -1
- package/dist/pregel/remote.cjs +339 -458
- package/dist/pregel/remote.cjs.map +1 -0
- package/dist/pregel/remote.d.cts +121 -0
- package/dist/pregel/remote.d.cts.map +1 -0
- package/dist/pregel/remote.d.ts +79 -69
- package/dist/pregel/remote.d.ts.map +1 -0
- package/dist/pregel/remote.js +337 -453
- package/dist/pregel/remote.js.map +1 -1
- package/dist/pregel/retry.cjs +87 -138
- package/dist/pregel/retry.cjs.map +1 -0
- package/dist/pregel/retry.js +83 -130
- package/dist/pregel/retry.js.map +1 -1
- package/dist/pregel/runnable_types.d.cts +49 -0
- package/dist/pregel/runnable_types.d.cts.map +1 -0
- package/dist/pregel/runnable_types.d.ts +47 -17
- package/dist/pregel/runnable_types.d.ts.map +1 -0
- package/dist/pregel/runner.cjs +222 -315
- package/dist/pregel/runner.cjs.map +1 -0
- package/dist/pregel/runner.js +219 -308
- package/dist/pregel/runner.js.map +1 -1
- package/dist/pregel/stream.cjs +89 -130
- package/dist/pregel/stream.cjs.map +1 -0
- package/dist/pregel/stream.js +87 -125
- package/dist/pregel/stream.js.map +1 -1
- package/dist/pregel/types.cjs +25 -62
- package/dist/pregel/types.cjs.map +1 -0
- package/dist/pregel/types.d.cts +440 -0
- package/dist/pregel/types.d.cts.map +1 -0
- package/dist/pregel/types.d.ts +381 -432
- package/dist/pregel/types.d.ts.map +1 -0
- package/dist/pregel/types.js +23 -57
- package/dist/pregel/types.js.map +1 -1
- package/dist/pregel/utils/config.cjs +101 -147
- package/dist/pregel/utils/config.cjs.map +1 -0
- package/dist/pregel/utils/config.d.cts +36 -0
- package/dist/pregel/utils/config.d.cts.map +1 -0
- package/dist/pregel/utils/config.d.ts +12 -9
- package/dist/pregel/utils/config.d.ts.map +1 -0
- package/dist/pregel/utils/config.js +99 -143
- package/dist/pregel/utils/config.js.map +1 -1
- package/dist/pregel/utils/index.cjs +87 -125
- package/dist/pregel/utils/index.cjs.map +1 -0
- package/dist/pregel/utils/index.d.cts +51 -0
- package/dist/pregel/utils/index.d.cts.map +1 -0
- package/dist/pregel/utils/index.d.ts +45 -61
- package/dist/pregel/utils/index.d.ts.map +1 -0
- package/dist/pregel/utils/index.js +86 -120
- package/dist/pregel/utils/index.js.map +1 -1
- package/dist/pregel/utils/subgraph.cjs +15 -26
- package/dist/pregel/utils/subgraph.cjs.map +1 -0
- package/dist/pregel/utils/subgraph.js +12 -21
- package/dist/pregel/utils/subgraph.js.map +1 -1
- package/dist/pregel/validate.cjs +42 -92
- package/dist/pregel/validate.cjs.map +1 -0
- package/dist/pregel/validate.js +39 -84
- package/dist/pregel/validate.js.map +1 -1
- package/dist/pregel/write.cjs +87 -137
- package/dist/pregel/write.cjs.map +1 -0
- package/dist/pregel/write.d.cts +35 -0
- package/dist/pregel/write.d.cts.map +1 -0
- package/dist/pregel/write.d.ts +27 -23
- package/dist/pregel/write.d.ts.map +1 -0
- package/dist/pregel/write.js +83 -131
- package/dist/pregel/write.js.map +1 -1
- package/dist/remote.cjs +3 -6
- package/dist/remote.d.cts +2 -0
- package/dist/remote.d.ts +2 -1
- package/dist/remote.js +3 -2
- package/dist/setup/async_local_storage.cjs +10 -7
- package/dist/setup/async_local_storage.cjs.map +1 -0
- package/dist/setup/async_local_storage.js +7 -2
- package/dist/setup/async_local_storage.js.map +1 -1
- package/dist/ui/index.cjs +4 -0
- package/dist/ui/index.d.cts +5 -0
- package/dist/ui/index.d.ts +5 -0
- package/dist/ui/index.js +3 -0
- package/dist/ui/stream.cjs +145 -0
- package/dist/ui/stream.cjs.map +1 -0
- package/dist/ui/stream.d.cts +25 -0
- package/dist/ui/stream.d.cts.map +1 -0
- package/dist/ui/stream.d.ts +25 -0
- package/dist/ui/stream.d.ts.map +1 -0
- package/dist/ui/stream.js +143 -0
- package/dist/ui/stream.js.map +1 -0
- package/dist/ui/types.infer.d.cts +53 -0
- package/dist/ui/types.infer.d.cts.map +1 -0
- package/dist/ui/types.infer.d.ts +53 -0
- package/dist/ui/types.infer.d.ts.map +1 -0
- package/dist/ui/types.message.d.cts +95 -0
- package/dist/ui/types.message.d.cts.map +1 -0
- package/dist/ui/types.message.d.ts +95 -0
- package/dist/ui/types.message.d.ts.map +1 -0
- package/dist/ui/types.schema.d.cts +228 -0
- package/dist/ui/types.schema.d.cts.map +1 -0
- package/dist/ui/types.schema.d.ts +228 -0
- package/dist/ui/types.schema.d.ts.map +1 -0
- package/dist/utils.cjs +77 -147
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +32 -0
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.ts +29 -25
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +73 -140
- package/dist/utils.js.map +1 -1
- package/dist/web.cjs +96 -55
- package/dist/web.d.cts +23 -0
- package/dist/web.d.ts +23 -14
- package/dist/web.js +15 -8
- package/dist/writer.cjs +15 -0
- package/dist/writer.cjs.map +1 -0
- package/dist/writer.d.cts +5 -0
- package/dist/writer.d.cts.map +1 -0
- package/dist/writer.d.ts +5 -0
- package/dist/writer.d.ts.map +1 -0
- package/dist/writer.js +14 -0
- package/dist/writer.js.map +1 -0
- package/package.json +90 -83
- package/dist/channels/index.js.map +0 -1
- package/dist/func/types.cjs +0 -15
- package/dist/func/types.js +0 -12
- package/dist/func/types.js.map +0 -1
- package/dist/graph/index.d.ts +0 -4
- package/dist/graph/index.js.map +0 -1
- package/dist/graph/message.test.cjs +0 -196
- package/dist/graph/message.test.d.ts +0 -1
- package/dist/graph/message.test.js +0 -194
- package/dist/graph/message.test.js.map +0 -1
- package/dist/graph/zod/index.js.map +0 -1
- package/dist/graph/zod/plugin.d.ts +0 -28
- package/dist/hash.d.ts +0 -2
- package/dist/prebuilt/index.js.map +0 -1
- package/dist/prebuilt/interrupt.cjs +0 -3
- package/dist/prebuilt/interrupt.js +0 -2
- package/dist/prebuilt/interrupt.js.map +0 -1
- package/dist/pregel/call.d.ts +0 -16
- package/dist/pregel/debug.d.ts +0 -41
- package/dist/pregel/debug.test.cjs +0 -258
- package/dist/pregel/debug.test.d.ts +0 -1
- package/dist/pregel/debug.test.js +0 -256
- package/dist/pregel/debug.test.js.map +0 -1
- package/dist/pregel/io.d.ts +0 -30
- package/dist/pregel/io.mapCommand.test.cjs +0 -150
- package/dist/pregel/io.mapCommand.test.d.ts +0 -1
- package/dist/pregel/io.mapCommand.test.js +0 -148
- package/dist/pregel/io.mapCommand.test.js.map +0 -1
- package/dist/pregel/loop.d.ts +0 -147
- package/dist/pregel/messages.d.ts +0 -30
- package/dist/pregel/messages.test.cjs +0 -369
- package/dist/pregel/messages.test.d.ts +0 -1
- package/dist/pregel/messages.test.js +0 -367
- package/dist/pregel/messages.test.js.map +0 -1
- package/dist/pregel/read.test.cjs +0 -194
- package/dist/pregel/read.test.d.ts +0 -1
- package/dist/pregel/read.test.js +0 -192
- package/dist/pregel/read.test.js.map +0 -1
- package/dist/pregel/retry.d.ts +0 -17
- package/dist/pregel/runnable_types.cjs +0 -3
- package/dist/pregel/runnable_types.js +0 -2
- package/dist/pregel/runnable_types.js.map +0 -1
- package/dist/pregel/runner.d.ts +0 -79
- package/dist/pregel/runner.test.cjs +0 -66
- package/dist/pregel/runner.test.d.ts +0 -1
- package/dist/pregel/runner.test.js +0 -64
- package/dist/pregel/runner.test.js.map +0 -1
- package/dist/pregel/stream.d.ts +0 -40
- package/dist/pregel/utils/config.test.cjs +0 -214
- package/dist/pregel/utils/config.test.d.ts +0 -1
- package/dist/pregel/utils/config.test.js +0 -212
- package/dist/pregel/utils/config.test.js.map +0 -1
- package/dist/pregel/utils/subgraph.d.ts +0 -4
- package/dist/pregel/utils/subgraph.test.cjs +0 -83
- package/dist/pregel/utils/subgraph.test.d.ts +0 -1
- package/dist/pregel/utils/subgraph.test.js +0 -81
- package/dist/pregel/utils/subgraph.test.js.map +0 -1
- package/dist/pregel/validate.d.ts +0 -16
- package/dist/pregel/validate.test.cjs +0 -220
- package/dist/pregel/validate.test.d.ts +0 -1
- package/dist/pregel/validate.test.js +0 -218
- package/dist/pregel/validate.test.js.map +0 -1
- package/dist/pregel/write.test.cjs +0 -181
- package/dist/pregel/write.test.d.ts +0 -1
- package/dist/pregel/write.test.js +0 -179
- package/dist/pregel/write.test.js.map +0 -1
- package/dist/remote.js.map +0 -1
- package/dist/setup/async_local_storage.d.ts +0 -1
- package/dist/web.js.map +0 -1
- package/index.cjs +0 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/prebuilt.cjs +0 -1
- package/prebuilt.d.cts +0 -1
- package/prebuilt.d.ts +0 -1
- package/prebuilt.js +0 -1
- package/pregel.cjs +0 -1
- package/pregel.d.cts +0 -1
- package/pregel.d.ts +0 -1
- package/pregel.js +0 -1
- package/remote.cjs +0 -1
- package/remote.d.cts +0 -1
- package/remote.d.ts +0 -1
- package/remote.js +0 -1
- package/web.cjs +0 -1
- package/web.d.cts +0 -1
- package/web.d.ts +0 -1
- package/web.js +0 -1
- package/zod/schema.cjs +0 -1
- package/zod/schema.d.cts +0 -1
- package/zod/schema.d.ts +0 -1
- package/zod/schema.js +0 -1
- package/zod.cjs +0 -1
- package/zod.d.cts +0 -1
- package/zod.d.ts +0 -1
- package/zod.js +0 -1
package/dist/pregel/algo.js
CHANGED
|
@@ -1,704 +1,567 @@
|
|
|
1
|
-
/* eslint-disable no-param-reassign */
|
|
2
|
-
import { mergeConfigs, patchConfig, } from "@langchain/core/runnables";
|
|
3
|
-
import { copyCheckpoint, uuid5, maxChannelVersion, } from "@langchain/langgraph-checkpoint";
|
|
4
|
-
import { createCheckpoint, emptyChannels, getOnlyChannels, } from "../channels/base.js";
|
|
5
|
-
import { readChannel, readChannels } from "./io.js";
|
|
6
|
-
import { _isSend, _isSendInterface, CONFIG_KEY_CHECKPOINT_MAP, CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_READ, CONFIG_KEY_TASK_ID, CONFIG_KEY_SEND, INTERRUPT, RESERVED, Send, TAG_HIDDEN, TASKS, CHECKPOINT_NAMESPACE_END, PUSH, PULL, RESUME, NULL_TASK_ID, CONFIG_KEY_SCRATCHPAD, RETURN, ERROR, NO_WRITES, CONFIG_KEY_PREVIOUS_STATE, PREVIOUS, CACHE_NS_WRITES, CONFIG_KEY_RESUME_MAP, } from "../constants.js";
|
|
7
|
-
import { isCall, } from "./types.js";
|
|
8
1
|
import { EmptyChannelError, InvalidUpdateError } from "../errors.js";
|
|
2
|
+
import { createCheckpoint, emptyChannels, getOnlyChannels } from "../channels/base.js";
|
|
3
|
+
import { CACHE_NS_WRITES, CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_CHECKPOINT_MAP, CONFIG_KEY_PREVIOUS_STATE, CONFIG_KEY_READ, CONFIG_KEY_RESUME_MAP, CONFIG_KEY_SCRATCHPAD, CONFIG_KEY_SEND, CONFIG_KEY_TASK_ID, ERROR, INTERRUPT, NO_WRITES, NULL_TASK_ID, PREVIOUS, PULL, PUSH, RESERVED, RESUME, RETURN, START, Send, TAG_HIDDEN, TASKS, _isSend, _isSendInterface } from "../constants.js";
|
|
4
|
+
import { XXH3 } from "../hash.js";
|
|
5
|
+
import { readChannel, readChannels } from "./io.js";
|
|
6
|
+
import { isCall } from "./types.js";
|
|
9
7
|
import { getNullChannelVersion } from "./utils/index.js";
|
|
10
8
|
import { getRunnableForFunc } from "./call.js";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
import { copyCheckpoint, maxChannelVersion, uuid5 } from "@langchain/langgraph-checkpoint";
|
|
10
|
+
import { mergeConfigs, patchConfig } from "@langchain/core/runnables";
|
|
11
|
+
|
|
12
|
+
//#region src/pregel/algo.ts
|
|
13
|
+
const increment = (current) => {
|
|
14
|
+
return current !== void 0 ? current + 1 : 1;
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
+
function triggersNextStep(updatedChannels, triggerToNodes) {
|
|
17
|
+
if (triggerToNodes == null) return false;
|
|
18
|
+
for (const chan of updatedChannels) if (triggerToNodes[chan]) return true;
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
16
21
|
function maxChannelMapVersion(channelVersions) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
else {
|
|
25
|
-
maxVersion = maxChannelVersion(maxVersion, channelVersions[chan]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return maxVersion;
|
|
22
|
+
let maxVersion;
|
|
23
|
+
for (const chan in channelVersions) {
|
|
24
|
+
if (!Object.prototype.hasOwnProperty.call(channelVersions, chan)) continue;
|
|
25
|
+
if (maxVersion == null) maxVersion = channelVersions[chan];
|
|
26
|
+
else maxVersion = maxChannelVersion(maxVersion, channelVersions[chan]);
|
|
27
|
+
}
|
|
28
|
+
return maxVersion;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
: interruptNodes.includes(task.name));
|
|
45
|
-
return anyChannelUpdated && anyTriggeredNodeInInterruptNodes;
|
|
30
|
+
function shouldInterrupt(checkpoint, interruptNodes, tasks) {
|
|
31
|
+
const nullVersion = getNullChannelVersion(checkpoint.channel_versions);
|
|
32
|
+
const seen = checkpoint.versions_seen[INTERRUPT] ?? {};
|
|
33
|
+
let anyChannelUpdated = false;
|
|
34
|
+
if ((checkpoint.channel_versions[START] ?? nullVersion) > (seen[START] ?? nullVersion)) anyChannelUpdated = true;
|
|
35
|
+
else for (const chan in checkpoint.channel_versions) {
|
|
36
|
+
if (!Object.prototype.hasOwnProperty.call(checkpoint.channel_versions, chan)) continue;
|
|
37
|
+
if (checkpoint.channel_versions[chan] > (seen[chan] ?? nullVersion)) {
|
|
38
|
+
anyChannelUpdated = true;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const anyTriggeredNodeInInterruptNodes = tasks.some((task) => interruptNodes === "*" ? !task.config?.tags?.includes(TAG_HIDDEN) : interruptNodes.includes(task.name));
|
|
43
|
+
return anyChannelUpdated && anyTriggeredNodeInInterruptNodes;
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
values = readChannels(channels, select);
|
|
71
|
-
}
|
|
72
|
-
return values;
|
|
45
|
+
function _localRead(checkpoint, channels, task, select, fresh = false) {
|
|
46
|
+
let updated = /* @__PURE__ */ new Set();
|
|
47
|
+
if (!Array.isArray(select)) {
|
|
48
|
+
for (const [c] of task.writes) if (c === select) {
|
|
49
|
+
updated = new Set([c]);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
updated = updated || /* @__PURE__ */ new Set();
|
|
53
|
+
} else updated = new Set(select.filter((c) => task.writes.some(([key, _]) => key === c)));
|
|
54
|
+
let values;
|
|
55
|
+
if (fresh && updated.size > 0) {
|
|
56
|
+
const localChannels = Object.fromEntries(Object.entries(channels).filter(([k, _]) => updated.has(k)));
|
|
57
|
+
const newCheckpoint = createCheckpoint(checkpoint, localChannels, -1);
|
|
58
|
+
const newChannels = emptyChannels(localChannels, newCheckpoint);
|
|
59
|
+
_applyWrites(copyCheckpoint(newCheckpoint), newChannels, [task], void 0, void 0);
|
|
60
|
+
values = readChannels({
|
|
61
|
+
...channels,
|
|
62
|
+
...newChannels
|
|
63
|
+
}, select);
|
|
64
|
+
} else values = readChannels(channels, select);
|
|
65
|
+
return values;
|
|
73
66
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if ([PUSH, TASKS].includes(chan) && value != null) {
|
|
81
|
-
if (!_isSend(value)) {
|
|
82
|
-
throw new InvalidUpdateError(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(value)}`);
|
|
83
|
-
}
|
|
84
|
-
if (!(value.node in processes)) {
|
|
85
|
-
throw new InvalidUpdateError(`Invalid node name "${value.node}" in Send packet`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
commit(writes);
|
|
67
|
+
function _localWrite(commit, processes, writes) {
|
|
68
|
+
for (const [chan, value] of writes) if ([PUSH, TASKS].includes(chan) && value != null) {
|
|
69
|
+
if (!_isSend(value)) throw new InvalidUpdateError(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(value)}`);
|
|
70
|
+
if (!(value.node in processes)) throw new InvalidUpdateError(`Invalid node name "${value.node}" in Send packet`);
|
|
71
|
+
}
|
|
72
|
+
commit(writes);
|
|
90
73
|
}
|
|
91
74
|
const IGNORE = new Set([
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
75
|
+
NO_WRITES,
|
|
76
|
+
PUSH,
|
|
77
|
+
RESUME,
|
|
78
|
+
INTERRUPT,
|
|
79
|
+
RETURN,
|
|
80
|
+
ERROR
|
|
98
81
|
]);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
// Channels that weren't updated in this step are notified of a new step
|
|
189
|
-
if (bumpStep) {
|
|
190
|
-
for (const chan in onlyChannels) {
|
|
191
|
-
if (!Object.prototype.hasOwnProperty.call(onlyChannels, chan))
|
|
192
|
-
continue;
|
|
193
|
-
const channel = onlyChannels[chan];
|
|
194
|
-
if (channel.isAvailable() && !updatedChannels.has(chan)) {
|
|
195
|
-
const updated = channel.update([]);
|
|
196
|
-
if (updated && getNextVersion !== undefined) {
|
|
197
|
-
checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
|
|
198
|
-
// unavailable channels can't trigger tasks, so don't add them
|
|
199
|
-
if (channel.isAvailable())
|
|
200
|
-
updatedChannels.add(chan);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
// If this is (tentatively) the last superstep, notify all channels of finish
|
|
206
|
-
if (bumpStep &&
|
|
207
|
-
!Object.keys(triggerToNodes ?? {}).some((channel) => updatedChannels.has(channel))) {
|
|
208
|
-
for (const chan in onlyChannels) {
|
|
209
|
-
if (!Object.prototype.hasOwnProperty.call(onlyChannels, chan))
|
|
210
|
-
continue;
|
|
211
|
-
const channel = onlyChannels[chan];
|
|
212
|
-
if (channel.finish() && getNextVersion !== undefined) {
|
|
213
|
-
checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
|
|
214
|
-
// unavailable channels can't trigger tasks, so don't add them
|
|
215
|
-
if (channel.isAvailable())
|
|
216
|
-
updatedChannels.add(chan);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
82
|
+
function _applyWrites(checkpoint, channels, tasks, getNextVersion, triggerToNodes) {
|
|
83
|
+
tasks.sort((a, b) => {
|
|
84
|
+
const aPath = a.path?.slice(0, 3) || [];
|
|
85
|
+
const bPath = b.path?.slice(0, 3) || [];
|
|
86
|
+
for (let i = 0; i < Math.min(aPath.length, bPath.length); i += 1) {
|
|
87
|
+
if (aPath[i] < bPath[i]) return -1;
|
|
88
|
+
if (aPath[i] > bPath[i]) return 1;
|
|
89
|
+
}
|
|
90
|
+
return aPath.length - bPath.length;
|
|
91
|
+
});
|
|
92
|
+
const bumpStep = tasks.some((task) => task.triggers.length > 0);
|
|
93
|
+
const onlyChannels = getOnlyChannels(channels);
|
|
94
|
+
for (const task of tasks) {
|
|
95
|
+
checkpoint.versions_seen[task.name] ??= {};
|
|
96
|
+
for (const chan of task.triggers) if (chan in checkpoint.channel_versions) checkpoint.versions_seen[task.name][chan] = checkpoint.channel_versions[chan];
|
|
97
|
+
}
|
|
98
|
+
let maxVersion = maxChannelMapVersion(checkpoint.channel_versions);
|
|
99
|
+
const channelsToConsume = new Set(tasks.flatMap((task) => task.triggers).filter((chan) => !RESERVED.includes(chan)));
|
|
100
|
+
let usedNewVersion = false;
|
|
101
|
+
for (const chan of channelsToConsume) if (chan in onlyChannels && onlyChannels[chan].consume()) {
|
|
102
|
+
if (getNextVersion !== void 0) {
|
|
103
|
+
checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
|
|
104
|
+
usedNewVersion = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const pendingWritesByChannel = {};
|
|
108
|
+
for (const task of tasks) for (const [chan, val] of task.writes) if (IGNORE.has(chan)) {} else if (chan in onlyChannels) {
|
|
109
|
+
pendingWritesByChannel[chan] ??= [];
|
|
110
|
+
pendingWritesByChannel[chan].push(val);
|
|
111
|
+
}
|
|
112
|
+
if (maxVersion != null && getNextVersion != null) maxVersion = usedNewVersion ? getNextVersion(maxVersion) : maxVersion;
|
|
113
|
+
const updatedChannels = /* @__PURE__ */ new Set();
|
|
114
|
+
for (const [chan, vals] of Object.entries(pendingWritesByChannel)) if (chan in onlyChannels) {
|
|
115
|
+
const channel = onlyChannels[chan];
|
|
116
|
+
let updated;
|
|
117
|
+
try {
|
|
118
|
+
updated = channel.update(vals);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
if (e.name === InvalidUpdateError.unminifiable_name) {
|
|
121
|
+
const wrappedError = new InvalidUpdateError(`Invalid update for channel "${chan}" with values ${JSON.stringify(vals)}: ${e.message}`);
|
|
122
|
+
wrappedError.lc_error_code = e.lc_error_code;
|
|
123
|
+
throw wrappedError;
|
|
124
|
+
} else throw e;
|
|
125
|
+
}
|
|
126
|
+
if (updated && getNextVersion !== void 0) {
|
|
127
|
+
checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
|
|
128
|
+
if (channel.isAvailable()) updatedChannels.add(chan);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (bumpStep) for (const chan in onlyChannels) {
|
|
132
|
+
if (!Object.prototype.hasOwnProperty.call(onlyChannels, chan)) continue;
|
|
133
|
+
const channel = onlyChannels[chan];
|
|
134
|
+
if (channel.isAvailable() && !updatedChannels.has(chan)) {
|
|
135
|
+
const updated = channel.update([]);
|
|
136
|
+
if (updated && getNextVersion !== void 0) {
|
|
137
|
+
checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
|
|
138
|
+
if (channel.isAvailable()) updatedChannels.add(chan);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (bumpStep && !triggersNextStep(updatedChannels, triggerToNodes)) for (const chan in onlyChannels) {
|
|
143
|
+
if (!Object.prototype.hasOwnProperty.call(onlyChannels, chan)) continue;
|
|
144
|
+
const channel = onlyChannels[chan];
|
|
145
|
+
if (channel.finish() && getNextVersion !== void 0) {
|
|
146
|
+
checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
|
|
147
|
+
if (channel.isAvailable()) updatedChannels.add(chan);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return updatedChannels;
|
|
151
|
+
}
|
|
152
|
+
function* candidateNodes(checkpoint, processes, extra) {
|
|
153
|
+
if (extra.updatedChannels != null && extra.triggerToNodes != null) {
|
|
154
|
+
const triggeredNodes = /* @__PURE__ */ new Set();
|
|
155
|
+
for (const channel of extra.updatedChannels) {
|
|
156
|
+
const nodeIds = extra.triggerToNodes[channel];
|
|
157
|
+
for (const id of nodeIds ?? []) triggeredNodes.add(id);
|
|
158
|
+
}
|
|
159
|
+
yield* [...triggeredNodes].sort();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const isEmptyChannelVersions = (() => {
|
|
163
|
+
for (const chan in checkpoint.channel_versions) if (checkpoint.channel_versions[chan] !== null) return false;
|
|
164
|
+
return true;
|
|
165
|
+
})();
|
|
166
|
+
if (isEmptyChannelVersions) return;
|
|
167
|
+
for (const name in processes) {
|
|
168
|
+
if (!Object.prototype.hasOwnProperty.call(processes, name)) continue;
|
|
169
|
+
yield name;
|
|
170
|
+
}
|
|
220
171
|
}
|
|
221
172
|
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
for (const name in processes) {
|
|
242
|
-
if (!Object.prototype.hasOwnProperty.call(processes, name))
|
|
243
|
-
continue;
|
|
244
|
-
const task = _prepareSingleTask([PULL, name], checkpoint, pendingWrites, processes, channels, config, forExecution, extra);
|
|
245
|
-
if (task !== undefined) {
|
|
246
|
-
tasks[task.id] = task;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return tasks;
|
|
173
|
+
* Prepare the set of tasks that will make up the next Pregel step.
|
|
174
|
+
* This is the union of all PUSH tasks (Sends) and PULL tasks (nodes triggered
|
|
175
|
+
* by edges).
|
|
176
|
+
*/
|
|
177
|
+
function _prepareNextTasks(checkpoint, pendingWrites, processes, channels, config, forExecution, extra) {
|
|
178
|
+
const tasks = {};
|
|
179
|
+
const tasksChannel = channels[TASKS];
|
|
180
|
+
if (tasksChannel?.isAvailable()) {
|
|
181
|
+
const len = tasksChannel.get().length;
|
|
182
|
+
for (let i = 0; i < len; i += 1) {
|
|
183
|
+
const task = _prepareSingleTask([PUSH, i], checkpoint, pendingWrites, processes, channels, config, forExecution, extra);
|
|
184
|
+
if (task !== void 0) tasks[task.id] = task;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
for (const name of candidateNodes(checkpoint, processes, extra)) {
|
|
188
|
+
const task = _prepareSingleTask([PULL, name], checkpoint, pendingWrites, processes, channels, config, forExecution, extra);
|
|
189
|
+
if (task !== void 0) tasks[task.id] = task;
|
|
190
|
+
}
|
|
191
|
+
return tasks;
|
|
250
192
|
}
|
|
251
193
|
/**
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
}, select_, fresh_),
|
|
556
|
-
[CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[CONFIG_KEY_CHECKPOINTER],
|
|
557
|
-
[CONFIG_KEY_CHECKPOINT_MAP]: {
|
|
558
|
-
...configurable[CONFIG_KEY_CHECKPOINT_MAP],
|
|
559
|
-
[parentNamespace]: checkpoint.id,
|
|
560
|
-
},
|
|
561
|
-
[CONFIG_KEY_SCRATCHPAD]: _scratchpad({
|
|
562
|
-
pendingWrites: pendingWrites ?? [],
|
|
563
|
-
taskId,
|
|
564
|
-
currentTaskInput: val,
|
|
565
|
-
resumeMap: config.configurable?.[CONFIG_KEY_RESUME_MAP],
|
|
566
|
-
namespaceHash: XXH3(taskCheckpointNamespace),
|
|
567
|
-
}),
|
|
568
|
-
[CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[PREVIOUS],
|
|
569
|
-
checkpoint_id: undefined,
|
|
570
|
-
checkpoint_ns: taskCheckpointNamespace,
|
|
571
|
-
},
|
|
572
|
-
}),
|
|
573
|
-
triggers: [trigger],
|
|
574
|
-
retry_policy: proc.retryPolicy,
|
|
575
|
-
cache_key: proc.cachePolicy
|
|
576
|
-
? {
|
|
577
|
-
key: XXH3((proc.cachePolicy.keyFunc ?? JSON.stringify)([val])),
|
|
578
|
-
ns: [CACHE_NS_WRITES, proc.name ?? "__dynamic__", name],
|
|
579
|
-
ttl: proc.cachePolicy.ttl,
|
|
580
|
-
}
|
|
581
|
-
: undefined,
|
|
582
|
-
id: taskId,
|
|
583
|
-
path: taskPath,
|
|
584
|
-
writers: proc.getWriters(),
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
else {
|
|
589
|
-
return {
|
|
590
|
-
id: taskId,
|
|
591
|
-
name,
|
|
592
|
-
interrupts: [],
|
|
593
|
-
path: taskPath,
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
return undefined;
|
|
194
|
+
* Prepares a single task for the next Pregel step, given a task path, which
|
|
195
|
+
* uniquely identifies a PUSH or PULL task within the graph.
|
|
196
|
+
*/
|
|
197
|
+
function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, channels, config, forExecution, extra) {
|
|
198
|
+
const { step, checkpointer, manager } = extra;
|
|
199
|
+
const configurable = config.configurable ?? {};
|
|
200
|
+
const parentNamespace = configurable.checkpoint_ns ?? "";
|
|
201
|
+
if (taskPath[0] === PUSH && isCall(taskPath[taskPath.length - 1])) {
|
|
202
|
+
const call = taskPath[taskPath.length - 1];
|
|
203
|
+
const proc = getRunnableForFunc(call.name, call.func);
|
|
204
|
+
const triggers = [PUSH];
|
|
205
|
+
const checkpointNamespace = parentNamespace === "" ? call.name : `${parentNamespace}${CHECKPOINT_NAMESPACE_SEPARATOR}${call.name}`;
|
|
206
|
+
const id = uuid5(JSON.stringify([
|
|
207
|
+
checkpointNamespace,
|
|
208
|
+
step.toString(),
|
|
209
|
+
call.name,
|
|
210
|
+
PUSH,
|
|
211
|
+
taskPath[1],
|
|
212
|
+
taskPath[2]
|
|
213
|
+
]), checkpoint.id);
|
|
214
|
+
const taskCheckpointNamespace = `${checkpointNamespace}${CHECKPOINT_NAMESPACE_END}${id}`;
|
|
215
|
+
const outputTaskPath = [...taskPath.slice(0, 3), true];
|
|
216
|
+
const metadata = {
|
|
217
|
+
langgraph_step: step,
|
|
218
|
+
langgraph_node: call.name,
|
|
219
|
+
langgraph_triggers: triggers,
|
|
220
|
+
langgraph_path: outputTaskPath,
|
|
221
|
+
langgraph_checkpoint_ns: taskCheckpointNamespace
|
|
222
|
+
};
|
|
223
|
+
if (forExecution) {
|
|
224
|
+
const writes = [];
|
|
225
|
+
const task = {
|
|
226
|
+
name: call.name,
|
|
227
|
+
input: call.input,
|
|
228
|
+
proc,
|
|
229
|
+
writes,
|
|
230
|
+
config: patchConfig(mergeConfigs(config, {
|
|
231
|
+
metadata,
|
|
232
|
+
store: extra.store ?? config.store
|
|
233
|
+
}), {
|
|
234
|
+
runName: call.name,
|
|
235
|
+
callbacks: manager?.getChild(`graph:step:${step}`),
|
|
236
|
+
configurable: {
|
|
237
|
+
[CONFIG_KEY_TASK_ID]: id,
|
|
238
|
+
[CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => writes.push(...items), processes, writes_),
|
|
239
|
+
[CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
|
|
240
|
+
name: call.name,
|
|
241
|
+
writes,
|
|
242
|
+
triggers,
|
|
243
|
+
path: outputTaskPath
|
|
244
|
+
}, select_, fresh_),
|
|
245
|
+
[CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[CONFIG_KEY_CHECKPOINTER],
|
|
246
|
+
[CONFIG_KEY_CHECKPOINT_MAP]: {
|
|
247
|
+
...configurable[CONFIG_KEY_CHECKPOINT_MAP],
|
|
248
|
+
[parentNamespace]: checkpoint.id
|
|
249
|
+
},
|
|
250
|
+
[CONFIG_KEY_SCRATCHPAD]: _scratchpad({
|
|
251
|
+
pendingWrites: pendingWrites ?? [],
|
|
252
|
+
taskId: id,
|
|
253
|
+
currentTaskInput: call.input,
|
|
254
|
+
resumeMap: config.configurable?.[CONFIG_KEY_RESUME_MAP],
|
|
255
|
+
namespaceHash: XXH3(taskCheckpointNamespace)
|
|
256
|
+
}),
|
|
257
|
+
[CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[PREVIOUS],
|
|
258
|
+
checkpoint_id: void 0,
|
|
259
|
+
checkpoint_ns: taskCheckpointNamespace
|
|
260
|
+
}
|
|
261
|
+
}),
|
|
262
|
+
triggers,
|
|
263
|
+
retry_policy: call.retry,
|
|
264
|
+
cache_key: call.cache ? {
|
|
265
|
+
key: XXH3((call.cache.keyFunc ?? JSON.stringify)([call.input])),
|
|
266
|
+
ns: [CACHE_NS_WRITES, call.name ?? "__dynamic__"],
|
|
267
|
+
ttl: call.cache.ttl
|
|
268
|
+
} : void 0,
|
|
269
|
+
id,
|
|
270
|
+
path: outputTaskPath,
|
|
271
|
+
writers: []
|
|
272
|
+
};
|
|
273
|
+
return task;
|
|
274
|
+
} else return {
|
|
275
|
+
id,
|
|
276
|
+
name: call.name,
|
|
277
|
+
interrupts: [],
|
|
278
|
+
path: outputTaskPath
|
|
279
|
+
};
|
|
280
|
+
} else if (taskPath[0] === PUSH) {
|
|
281
|
+
const index = typeof taskPath[1] === "number" ? taskPath[1] : parseInt(taskPath[1], 10);
|
|
282
|
+
if (!channels[TASKS]?.isAvailable()) return void 0;
|
|
283
|
+
const sends = channels[TASKS].get();
|
|
284
|
+
if (index < 0 || index >= sends.length) return void 0;
|
|
285
|
+
const packet = _isSendInterface(sends[index]) && !_isSend(sends[index]) ? new Send(sends[index].node, sends[index].args) : sends[index];
|
|
286
|
+
if (!_isSendInterface(packet)) {
|
|
287
|
+
console.warn(`Ignoring invalid packet ${JSON.stringify(packet)} in pending sends.`);
|
|
288
|
+
return void 0;
|
|
289
|
+
}
|
|
290
|
+
if (!(packet.node in processes)) {
|
|
291
|
+
console.warn(`Ignoring unknown node name ${packet.node} in pending sends.`);
|
|
292
|
+
return void 0;
|
|
293
|
+
}
|
|
294
|
+
const triggers = [PUSH];
|
|
295
|
+
const checkpointNamespace = parentNamespace === "" ? packet.node : `${parentNamespace}${CHECKPOINT_NAMESPACE_SEPARATOR}${packet.node}`;
|
|
296
|
+
const taskId = uuid5(JSON.stringify([
|
|
297
|
+
checkpointNamespace,
|
|
298
|
+
step.toString(),
|
|
299
|
+
packet.node,
|
|
300
|
+
PUSH,
|
|
301
|
+
index.toString()
|
|
302
|
+
]), checkpoint.id);
|
|
303
|
+
const taskCheckpointNamespace = `${checkpointNamespace}${CHECKPOINT_NAMESPACE_END}${taskId}`;
|
|
304
|
+
let metadata = {
|
|
305
|
+
langgraph_step: step,
|
|
306
|
+
langgraph_node: packet.node,
|
|
307
|
+
langgraph_triggers: triggers,
|
|
308
|
+
langgraph_path: taskPath.slice(0, 3),
|
|
309
|
+
langgraph_checkpoint_ns: taskCheckpointNamespace
|
|
310
|
+
};
|
|
311
|
+
if (forExecution) {
|
|
312
|
+
const proc = processes[packet.node];
|
|
313
|
+
const node = proc.getNode();
|
|
314
|
+
if (node !== void 0) {
|
|
315
|
+
if (proc.metadata !== void 0) metadata = {
|
|
316
|
+
...metadata,
|
|
317
|
+
...proc.metadata
|
|
318
|
+
};
|
|
319
|
+
const writes = [];
|
|
320
|
+
return {
|
|
321
|
+
name: packet.node,
|
|
322
|
+
input: packet.args,
|
|
323
|
+
proc: node,
|
|
324
|
+
subgraphs: proc.subgraphs,
|
|
325
|
+
writes,
|
|
326
|
+
config: patchConfig(mergeConfigs(config, {
|
|
327
|
+
metadata,
|
|
328
|
+
tags: proc.tags,
|
|
329
|
+
store: extra.store ?? config.store
|
|
330
|
+
}), {
|
|
331
|
+
runName: packet.node,
|
|
332
|
+
callbacks: manager?.getChild(`graph:step:${step}`),
|
|
333
|
+
configurable: {
|
|
334
|
+
[CONFIG_KEY_TASK_ID]: taskId,
|
|
335
|
+
[CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => writes.push(...items), processes, writes_),
|
|
336
|
+
[CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
|
|
337
|
+
name: packet.node,
|
|
338
|
+
writes,
|
|
339
|
+
triggers,
|
|
340
|
+
path: taskPath
|
|
341
|
+
}, select_, fresh_),
|
|
342
|
+
[CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[CONFIG_KEY_CHECKPOINTER],
|
|
343
|
+
[CONFIG_KEY_CHECKPOINT_MAP]: {
|
|
344
|
+
...configurable[CONFIG_KEY_CHECKPOINT_MAP],
|
|
345
|
+
[parentNamespace]: checkpoint.id
|
|
346
|
+
},
|
|
347
|
+
[CONFIG_KEY_SCRATCHPAD]: _scratchpad({
|
|
348
|
+
pendingWrites: pendingWrites ?? [],
|
|
349
|
+
taskId,
|
|
350
|
+
currentTaskInput: packet.args,
|
|
351
|
+
resumeMap: config.configurable?.[CONFIG_KEY_RESUME_MAP],
|
|
352
|
+
namespaceHash: XXH3(taskCheckpointNamespace)
|
|
353
|
+
}),
|
|
354
|
+
[CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[PREVIOUS],
|
|
355
|
+
checkpoint_id: void 0,
|
|
356
|
+
checkpoint_ns: taskCheckpointNamespace
|
|
357
|
+
}
|
|
358
|
+
}),
|
|
359
|
+
triggers,
|
|
360
|
+
retry_policy: proc.retryPolicy,
|
|
361
|
+
cache_key: proc.cachePolicy ? {
|
|
362
|
+
key: XXH3((proc.cachePolicy.keyFunc ?? JSON.stringify)([packet.args])),
|
|
363
|
+
ns: [
|
|
364
|
+
CACHE_NS_WRITES,
|
|
365
|
+
proc.name ?? "__dynamic__",
|
|
366
|
+
packet.node
|
|
367
|
+
],
|
|
368
|
+
ttl: proc.cachePolicy.ttl
|
|
369
|
+
} : void 0,
|
|
370
|
+
id: taskId,
|
|
371
|
+
path: taskPath,
|
|
372
|
+
writers: proc.getWriters()
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
} else return {
|
|
376
|
+
id: taskId,
|
|
377
|
+
name: packet.node,
|
|
378
|
+
interrupts: [],
|
|
379
|
+
path: taskPath
|
|
380
|
+
};
|
|
381
|
+
} else if (taskPath[0] === PULL) {
|
|
382
|
+
const name = taskPath[1].toString();
|
|
383
|
+
const proc = processes[name];
|
|
384
|
+
if (proc === void 0) return void 0;
|
|
385
|
+
if (pendingWrites?.length) {
|
|
386
|
+
const checkpointNamespace = parentNamespace === "" ? name : `${parentNamespace}${CHECKPOINT_NAMESPACE_SEPARATOR}${name}`;
|
|
387
|
+
const taskId = uuid5(JSON.stringify([
|
|
388
|
+
checkpointNamespace,
|
|
389
|
+
step.toString(),
|
|
390
|
+
name,
|
|
391
|
+
PULL,
|
|
392
|
+
name
|
|
393
|
+
]), checkpoint.id);
|
|
394
|
+
const hasSuccessfulWrites = pendingWrites.some((w) => w[0] === taskId && w[1] !== ERROR);
|
|
395
|
+
if (hasSuccessfulWrites) return void 0;
|
|
396
|
+
}
|
|
397
|
+
const nullVersion = getNullChannelVersion(checkpoint.channel_versions);
|
|
398
|
+
if (nullVersion === void 0) return void 0;
|
|
399
|
+
const seen = checkpoint.versions_seen[name] ?? {};
|
|
400
|
+
const trigger = proc.triggers.find((chan) => {
|
|
401
|
+
if (!channels[chan].isAvailable()) return false;
|
|
402
|
+
return (checkpoint.channel_versions[chan] ?? nullVersion) > (seen[chan] ?? nullVersion);
|
|
403
|
+
});
|
|
404
|
+
if (trigger !== void 0) {
|
|
405
|
+
const val = _procInput(proc, channels, forExecution);
|
|
406
|
+
if (val === void 0) return void 0;
|
|
407
|
+
const checkpointNamespace = parentNamespace === "" ? name : `${parentNamespace}${CHECKPOINT_NAMESPACE_SEPARATOR}${name}`;
|
|
408
|
+
const taskId = uuid5(JSON.stringify([
|
|
409
|
+
checkpointNamespace,
|
|
410
|
+
step.toString(),
|
|
411
|
+
name,
|
|
412
|
+
PULL,
|
|
413
|
+
[trigger]
|
|
414
|
+
]), checkpoint.id);
|
|
415
|
+
const taskCheckpointNamespace = `${checkpointNamespace}${CHECKPOINT_NAMESPACE_END}${taskId}`;
|
|
416
|
+
let metadata = {
|
|
417
|
+
langgraph_step: step,
|
|
418
|
+
langgraph_node: name,
|
|
419
|
+
langgraph_triggers: [trigger],
|
|
420
|
+
langgraph_path: taskPath,
|
|
421
|
+
langgraph_checkpoint_ns: taskCheckpointNamespace
|
|
422
|
+
};
|
|
423
|
+
if (forExecution) {
|
|
424
|
+
const node = proc.getNode();
|
|
425
|
+
if (node !== void 0) {
|
|
426
|
+
if (proc.metadata !== void 0) metadata = {
|
|
427
|
+
...metadata,
|
|
428
|
+
...proc.metadata
|
|
429
|
+
};
|
|
430
|
+
const writes = [];
|
|
431
|
+
return {
|
|
432
|
+
name,
|
|
433
|
+
input: val,
|
|
434
|
+
proc: node,
|
|
435
|
+
subgraphs: proc.subgraphs,
|
|
436
|
+
writes,
|
|
437
|
+
config: patchConfig(mergeConfigs(config, {
|
|
438
|
+
metadata,
|
|
439
|
+
tags: proc.tags,
|
|
440
|
+
store: extra.store ?? config.store
|
|
441
|
+
}), {
|
|
442
|
+
runName: name,
|
|
443
|
+
callbacks: manager?.getChild(`graph:step:${step}`),
|
|
444
|
+
configurable: {
|
|
445
|
+
[CONFIG_KEY_TASK_ID]: taskId,
|
|
446
|
+
[CONFIG_KEY_SEND]: (writes_) => _localWrite((items) => {
|
|
447
|
+
writes.push(...items);
|
|
448
|
+
}, processes, writes_),
|
|
449
|
+
[CONFIG_KEY_READ]: (select_, fresh_ = false) => _localRead(checkpoint, channels, {
|
|
450
|
+
name,
|
|
451
|
+
writes,
|
|
452
|
+
triggers: [trigger],
|
|
453
|
+
path: taskPath
|
|
454
|
+
}, select_, fresh_),
|
|
455
|
+
[CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable[CONFIG_KEY_CHECKPOINTER],
|
|
456
|
+
[CONFIG_KEY_CHECKPOINT_MAP]: {
|
|
457
|
+
...configurable[CONFIG_KEY_CHECKPOINT_MAP],
|
|
458
|
+
[parentNamespace]: checkpoint.id
|
|
459
|
+
},
|
|
460
|
+
[CONFIG_KEY_SCRATCHPAD]: _scratchpad({
|
|
461
|
+
pendingWrites: pendingWrites ?? [],
|
|
462
|
+
taskId,
|
|
463
|
+
currentTaskInput: val,
|
|
464
|
+
resumeMap: config.configurable?.[CONFIG_KEY_RESUME_MAP],
|
|
465
|
+
namespaceHash: XXH3(taskCheckpointNamespace)
|
|
466
|
+
}),
|
|
467
|
+
[CONFIG_KEY_PREVIOUS_STATE]: checkpoint.channel_values[PREVIOUS],
|
|
468
|
+
checkpoint_id: void 0,
|
|
469
|
+
checkpoint_ns: taskCheckpointNamespace
|
|
470
|
+
}
|
|
471
|
+
}),
|
|
472
|
+
triggers: [trigger],
|
|
473
|
+
retry_policy: proc.retryPolicy,
|
|
474
|
+
cache_key: proc.cachePolicy ? {
|
|
475
|
+
key: XXH3((proc.cachePolicy.keyFunc ?? JSON.stringify)([val])),
|
|
476
|
+
ns: [
|
|
477
|
+
CACHE_NS_WRITES,
|
|
478
|
+
proc.name ?? "__dynamic__",
|
|
479
|
+
name
|
|
480
|
+
],
|
|
481
|
+
ttl: proc.cachePolicy.ttl
|
|
482
|
+
} : void 0,
|
|
483
|
+
id: taskId,
|
|
484
|
+
path: taskPath,
|
|
485
|
+
writers: proc.getWriters()
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
} else return {
|
|
489
|
+
id: taskId,
|
|
490
|
+
name,
|
|
491
|
+
interrupts: [],
|
|
492
|
+
path: taskPath
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return void 0;
|
|
599
497
|
}
|
|
600
498
|
/**
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
499
|
+
* Function injected under CONFIG_KEY_READ in task config, to read current state.
|
|
500
|
+
* Used by conditional edges to read a copy of the state with reflecting the writes
|
|
501
|
+
* from that node only.
|
|
502
|
+
*
|
|
503
|
+
* @internal
|
|
504
|
+
*/
|
|
607
505
|
function _procInput(proc, channels, forExecution) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
throw e;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
else if (Array.isArray(proc.channels)) {
|
|
644
|
-
let successfulRead = false;
|
|
645
|
-
for (const chan of proc.channels) {
|
|
646
|
-
try {
|
|
647
|
-
val = readChannel(channels, chan, false);
|
|
648
|
-
successfulRead = true;
|
|
649
|
-
break;
|
|
650
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
651
|
-
}
|
|
652
|
-
catch (e) {
|
|
653
|
-
if (e.name === EmptyChannelError.unminifiable_name) {
|
|
654
|
-
continue;
|
|
655
|
-
}
|
|
656
|
-
else {
|
|
657
|
-
throw e;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
if (!successfulRead) {
|
|
662
|
-
return undefined;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
else {
|
|
666
|
-
throw new Error(`Invalid channels type, expected list or dict, got ${proc.channels}`);
|
|
667
|
-
}
|
|
668
|
-
// If the process has a mapper, apply it to the value
|
|
669
|
-
if (forExecution && proc.mapper !== undefined) {
|
|
670
|
-
val = proc.mapper(val);
|
|
671
|
-
}
|
|
672
|
-
return val;
|
|
506
|
+
let val;
|
|
507
|
+
if (typeof proc.channels === "object" && !Array.isArray(proc.channels)) {
|
|
508
|
+
val = {};
|
|
509
|
+
for (const [k, chan] of Object.entries(proc.channels)) if (proc.triggers.includes(chan)) try {
|
|
510
|
+
val[k] = readChannel(channels, chan, false);
|
|
511
|
+
} catch (e) {
|
|
512
|
+
if (e.name === EmptyChannelError.unminifiable_name) return void 0;
|
|
513
|
+
else throw e;
|
|
514
|
+
}
|
|
515
|
+
else if (chan in channels) try {
|
|
516
|
+
val[k] = readChannel(channels, chan, false);
|
|
517
|
+
} catch (e) {
|
|
518
|
+
if (e.name === EmptyChannelError.unminifiable_name) continue;
|
|
519
|
+
else throw e;
|
|
520
|
+
}
|
|
521
|
+
} else if (Array.isArray(proc.channels)) {
|
|
522
|
+
let successfulRead = false;
|
|
523
|
+
for (const chan of proc.channels) try {
|
|
524
|
+
val = readChannel(channels, chan, false);
|
|
525
|
+
successfulRead = true;
|
|
526
|
+
break;
|
|
527
|
+
} catch (e) {
|
|
528
|
+
if (e.name === EmptyChannelError.unminifiable_name) continue;
|
|
529
|
+
else throw e;
|
|
530
|
+
}
|
|
531
|
+
if (!successfulRead) return void 0;
|
|
532
|
+
} else throw new Error(`Invalid channels type, expected list or dict, got ${proc.channels}`);
|
|
533
|
+
if (forExecution && proc.mapper !== void 0) val = proc.mapper(val);
|
|
534
|
+
return val;
|
|
673
535
|
}
|
|
674
|
-
function _scratchpad({ pendingWrites, taskId, currentTaskInput, resumeMap, namespaceHash
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
};
|
|
702
|
-
return scratchpad;
|
|
536
|
+
function _scratchpad({ pendingWrites, taskId, currentTaskInput, resumeMap, namespaceHash }) {
|
|
537
|
+
const nullResume = pendingWrites.find(([writeTaskId, chan]) => writeTaskId === NULL_TASK_ID && chan === RESUME)?.[2];
|
|
538
|
+
const resume = (() => {
|
|
539
|
+
const result = pendingWrites.filter(([writeTaskId, chan]) => writeTaskId === taskId && chan === RESUME).flatMap(([_writeTaskId, _chan, resume$1]) => resume$1);
|
|
540
|
+
if (resumeMap != null && namespaceHash in resumeMap) {
|
|
541
|
+
const mappedResume = resumeMap[namespaceHash];
|
|
542
|
+
result.push(mappedResume);
|
|
543
|
+
}
|
|
544
|
+
return result;
|
|
545
|
+
})();
|
|
546
|
+
const scratchpad = {
|
|
547
|
+
callCounter: 0,
|
|
548
|
+
interruptCounter: -1,
|
|
549
|
+
resume,
|
|
550
|
+
nullResume,
|
|
551
|
+
subgraphCounter: 0,
|
|
552
|
+
currentTaskInput,
|
|
553
|
+
consumeNullResume: () => {
|
|
554
|
+
if (scratchpad.nullResume) {
|
|
555
|
+
delete scratchpad.nullResume;
|
|
556
|
+
pendingWrites.splice(pendingWrites.findIndex(([writeTaskId, chan]) => writeTaskId === NULL_TASK_ID && chan === RESUME), 1);
|
|
557
|
+
return nullResume;
|
|
558
|
+
}
|
|
559
|
+
return void 0;
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
return scratchpad;
|
|
703
563
|
}
|
|
564
|
+
|
|
565
|
+
//#endregion
|
|
566
|
+
export { _applyWrites, _localRead, _prepareNextTasks, _prepareSingleTask, increment, shouldInterrupt };
|
|
704
567
|
//# sourceMappingURL=algo.js.map
|