@langchain/langgraph 0.4.8 → 1.0.0-alpha.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.
- package/CHANGELOG.md +7 -2
- package/README.md +1 -2
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/channels/any_value.d.cts +26 -0
- package/dist/channels/any_value.d.cts.map +1 -0
- package/dist/channels/any_value.d.ts +16 -9
- package/dist/channels/any_value.d.ts.map +1 -0
- package/dist/channels/base.cjs +97 -133
- package/dist/channels/base.cjs.map +1 -0
- package/dist/channels/base.d.cts +73 -0
- package/dist/channels/base.d.cts.map +1 -0
- package/dist/channels/base.d.ts +73 -74
- package/dist/channels/base.d.ts.map +1 -0
- package/dist/channels/base.js +94 -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.d.cts +43 -0
- package/dist/channels/dynamic_barrier_value.d.cts.map +1 -0
- package/dist/channels/dynamic_barrier_value.d.ts +20 -34
- package/dist/channels/dynamic_barrier_value.d.ts.map +1 -0
- package/dist/channels/ephemeral_value.cjs +46 -70
- package/dist/channels/ephemeral_value.cjs.map +1 -0
- package/dist/channels/ephemeral_value.d.cts +23 -0
- package/dist/channels/ephemeral_value.d.cts.map +1 -0
- package/dist/channels/ephemeral_value.d.ts +18 -11
- package/dist/channels/ephemeral_value.d.ts.map +1 -0
- package/dist/channels/ephemeral_value.js +45 -65
- package/dist/channels/ephemeral_value.js.map +1 -1
- package/dist/channels/index.cjs +2 -10
- package/dist/channels/index.js +4 -3
- package/dist/channels/last_value.cjs +91 -140
- package/dist/channels/last_value.cjs.map +1 -0
- package/dist/channels/last_value.d.cts +30 -0
- package/dist/channels/last_value.d.cts.map +1 -0
- package/dist/channels/last_value.d.ts +15 -23
- package/dist/channels/last_value.d.ts.map +1 -0
- package/dist/channels/last_value.js +88 -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 +33 -0
- package/dist/channels/named_barrier_value.d.cts.map +1 -0
- package/dist/channels/named_barrier_value.d.ts +19 -29
- package/dist/channels/named_barrier_value.d.ts.map +1 -0
- package/dist/channels/named_barrier_value.js +112 -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 +26 -0
- package/dist/channels/topic.d.cts.map +1 -0
- package/dist/channels/topic.d.ts +21 -18
- 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 +373 -452
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +284 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.ts +112 -148
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +333 -444
- package/dist/constants.js.map +1 -1
- package/dist/errors.cjs +150 -179
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +80 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.ts +55 -46
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +139 -165
- package/dist/errors.js.map +1 -1
- package/dist/func/index.cjs +289 -290
- package/dist/func/index.cjs.map +1 -0
- package/dist/func/index.d.cts +289 -0
- package/dist/func/index.d.cts.map +1 -0
- package/dist/func/index.d.ts +81 -71
- package/dist/func/index.d.ts.map +1 -0
- package/dist/func/index.js +285 -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 +131 -0
- package/dist/graph/graph.d.cts.map +1 -0
- package/dist/graph/graph.d.ts +122 -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 +476 -777
- package/dist/graph/state.cjs.map +1 -0
- package/dist/graph/state.d.cts +216 -0
- package/dist/graph/state.d.cts.map +1 -0
- package/dist/graph/state.d.ts +129 -134
- package/dist/graph/state.d.ts.map +1 -0
- package/dist/graph/state.js +470 -768
- 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 +110 -33
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +25 -0
- package/dist/index.d.ts +25 -5
- package/dist/index.js +18 -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 +46 -37
- 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 +521 -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 +516 -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 +1134 -1604
- package/dist/pregel/index.cjs.map +1 -0
- package/dist/pregel/index.d.cts +534 -0
- package/dist/pregel/index.d.cts.map +1 -0
- package/dist/pregel/index.d.ts +458 -422
- package/dist/pregel/index.d.ts.map +1 -0
- package/dist/pregel/index.js +1125 -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 +539 -954
- package/dist/pregel/loop.cjs.map +1 -0
- package/dist/pregel/loop.js +536 -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 +25 -0
- package/dist/pregel/runnable_types.d.cts.map +1 -0
- package/dist/pregel/runnable_types.d.ts +22 -16
- 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 +437 -0
- package/dist/pregel/types.d.cts.map +1 -0
- package/dist/pregel/types.d.ts +377 -431
- 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 +100 -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 +98 -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 +97 -55
- package/dist/web.d.cts +23 -0
- package/dist/web.d.ts +23 -14
- package/dist/web.js +15 -8
- package/package.json +83 -86
- package/dist/channels/any_value.cjs +0 -65
- package/dist/channels/any_value.js +0 -61
- package/dist/channels/any_value.js.map +0 -1
- package/dist/channels/dynamic_barrier_value.cjs +0 -212
- package/dist/channels/dynamic_barrier_value.js +0 -207
- package/dist/channels/dynamic_barrier_value.js.map +0 -1
- package/dist/channels/index.d.ts +0 -7
- 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/debug.cjs
CHANGED
|
@@ -1,245 +1,175 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.mapDebugTasks = mapDebugTasks;
|
|
7
|
-
exports.mapDebugTaskResults = mapDebugTaskResults;
|
|
8
|
-
exports.mapDebugCheckpoint = mapDebugCheckpoint;
|
|
9
|
-
exports.tasksWithWrites = tasksWithWrites;
|
|
10
|
-
exports.printStepCheckpoint = printStepCheckpoint;
|
|
11
|
-
exports.printStepTasks = printStepTasks;
|
|
12
|
-
exports.printStepWrites = printStepWrites;
|
|
13
|
-
const constants_js_1 = require("../constants.cjs");
|
|
14
|
-
const errors_js_1 = require("../errors.cjs");
|
|
15
|
-
const io_js_1 = require("./io.cjs");
|
|
16
|
-
const subgraph_js_1 = require("./utils/subgraph.cjs");
|
|
1
|
+
const require_constants = require('../constants.cjs');
|
|
2
|
+
const require_io = require('./io.cjs');
|
|
3
|
+
const require_subgraph = require('./utils/subgraph.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/pregel/debug.ts
|
|
17
6
|
const COLORS_MAP = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
7
|
+
blue: {
|
|
8
|
+
start: "\x1B[34m",
|
|
9
|
+
end: "\x1B[0m"
|
|
10
|
+
},
|
|
11
|
+
green: {
|
|
12
|
+
start: "\x1B[32m",
|
|
13
|
+
end: "\x1B[0m"
|
|
14
|
+
},
|
|
15
|
+
yellow: {
|
|
16
|
+
start: "\x1B[33;1m",
|
|
17
|
+
end: "\x1B[0m"
|
|
18
|
+
}
|
|
30
19
|
};
|
|
31
20
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
* Wrap some text in a color for printing to the console.
|
|
22
|
+
*/
|
|
34
23
|
const wrap = (color, text) => `${color.start}${text}${color.end}`;
|
|
35
|
-
exports.wrap = wrap;
|
|
36
|
-
function printCheckpoint(step, channels) {
|
|
37
|
-
console.log([
|
|
38
|
-
`${(0, exports.wrap)(COLORS_MAP.blue, "[langgraph/checkpoint]")}`,
|
|
39
|
-
`Finishing step ${step}. Channel values:\n`,
|
|
40
|
-
`\n${JSON.stringify(Object.fromEntries(_readChannels(channels)), null, 2)}`,
|
|
41
|
-
].join(""));
|
|
42
|
-
}
|
|
43
|
-
function* _readChannels(channels
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
-
) {
|
|
46
|
-
for (const [name, channel] of Object.entries(channels)) {
|
|
47
|
-
try {
|
|
48
|
-
yield [name, channel.get()];
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
if (error.name === errors_js_1.EmptyChannelError.unminifiable_name) {
|
|
53
|
-
// Skip the channel if it's empty
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
throw error; // Re-throw the error if it's not an EmptyChannelError
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
24
|
function* mapDebugTasks(tasks) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
25
|
+
for (const { id, name, input, config, triggers, writes } of tasks) {
|
|
26
|
+
if (config?.tags?.includes(require_constants.TAG_HIDDEN)) continue;
|
|
27
|
+
const interrupts = writes.filter(([writeId, n]) => {
|
|
28
|
+
return writeId === id && n === require_constants.INTERRUPT;
|
|
29
|
+
}).map(([, v]) => {
|
|
30
|
+
return v;
|
|
31
|
+
});
|
|
32
|
+
yield {
|
|
33
|
+
id,
|
|
34
|
+
name,
|
|
35
|
+
input,
|
|
36
|
+
triggers,
|
|
37
|
+
interrupts
|
|
38
|
+
};
|
|
39
|
+
}
|
|
75
40
|
}
|
|
76
41
|
function isMultipleChannelWrite(value) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return "$writes" in value && Array.isArray(value.$writes);
|
|
42
|
+
if (typeof value !== "object" || value === null) return false;
|
|
43
|
+
return "$writes" in value && Array.isArray(value.$writes);
|
|
80
44
|
}
|
|
81
45
|
function mapTaskResultWrites(writes) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
else {
|
|
93
|
-
result[strChannel] = value;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return result;
|
|
46
|
+
const result = {};
|
|
47
|
+
for (const [channel, value] of writes) {
|
|
48
|
+
const strChannel = String(channel);
|
|
49
|
+
if (strChannel in result) {
|
|
50
|
+
const channelWrites = isMultipleChannelWrite(result[strChannel]) ? result[strChannel].$writes : [result[strChannel]];
|
|
51
|
+
channelWrites.push(value);
|
|
52
|
+
result[strChannel] = { $writes: channelWrites };
|
|
53
|
+
} else result[strChannel] = value;
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
97
56
|
}
|
|
98
57
|
function* mapDebugTaskResults(tasks, streamChannels) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
interrupts: writes.filter((w) => w[0] === constants_js_1.INTERRUPT).map((w) => w[1]),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
58
|
+
for (const [{ id, name, config }, writes] of tasks) {
|
|
59
|
+
if (config?.tags?.includes(require_constants.TAG_HIDDEN)) continue;
|
|
60
|
+
yield {
|
|
61
|
+
id,
|
|
62
|
+
name,
|
|
63
|
+
result: mapTaskResultWrites(writes.filter(([channel]) => {
|
|
64
|
+
return Array.isArray(streamChannels) ? streamChannels.includes(channel) : channel === streamChannels;
|
|
65
|
+
})),
|
|
66
|
+
interrupts: writes.filter((w) => w[0] === require_constants.INTERRUPT).map((w) => w[1])
|
|
67
|
+
};
|
|
68
|
+
}
|
|
113
69
|
}
|
|
114
70
|
function* mapDebugCheckpoint(config, channels, streamChannels, metadata, tasks, pendingWrites, parentConfig, outputKeys) {
|
|
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
|
-
thread_id: config.configurable?.thread_id,
|
|
148
|
-
checkpoint_ns: taskNs,
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
yield {
|
|
153
|
-
config: formatConfig(config),
|
|
154
|
-
values: (0, io_js_1.readChannels)(channels, streamChannels),
|
|
155
|
-
metadata,
|
|
156
|
-
next: tasks.map((task) => task.name),
|
|
157
|
-
tasks: tasksWithWrites(tasks, pendingWrites, taskStates, outputKeys),
|
|
158
|
-
parentConfig: parentConfig ? formatConfig(parentConfig) : undefined,
|
|
159
|
-
};
|
|
71
|
+
function formatConfig(config$1) {
|
|
72
|
+
const pyConfig = {};
|
|
73
|
+
if (config$1.callbacks != null) pyConfig.callbacks = config$1.callbacks;
|
|
74
|
+
if (config$1.configurable != null) pyConfig.configurable = config$1.configurable;
|
|
75
|
+
if (config$1.maxConcurrency != null) pyConfig.max_concurrency = config$1.maxConcurrency;
|
|
76
|
+
if (config$1.metadata != null) pyConfig.metadata = config$1.metadata;
|
|
77
|
+
if (config$1.recursionLimit != null) pyConfig.recursion_limit = config$1.recursionLimit;
|
|
78
|
+
if (config$1.runId != null) pyConfig.run_id = config$1.runId;
|
|
79
|
+
if (config$1.runName != null) pyConfig.run_name = config$1.runName;
|
|
80
|
+
if (config$1.tags != null) pyConfig.tags = config$1.tags;
|
|
81
|
+
return pyConfig;
|
|
82
|
+
}
|
|
83
|
+
const parentNs = config.configurable?.checkpoint_ns;
|
|
84
|
+
const taskStates = {};
|
|
85
|
+
for (const task of tasks) {
|
|
86
|
+
const candidates = task.subgraphs?.length ? task.subgraphs : [task.proc];
|
|
87
|
+
if (!candidates.find(require_subgraph.findSubgraphPregel)) continue;
|
|
88
|
+
let taskNs = `${task.name}:${task.id}`;
|
|
89
|
+
if (parentNs) taskNs = `${parentNs}|${taskNs}`;
|
|
90
|
+
taskStates[task.id] = { configurable: {
|
|
91
|
+
thread_id: config.configurable?.thread_id,
|
|
92
|
+
checkpoint_ns: taskNs
|
|
93
|
+
} };
|
|
94
|
+
}
|
|
95
|
+
yield {
|
|
96
|
+
config: formatConfig(config),
|
|
97
|
+
values: require_io.readChannels(channels, streamChannels),
|
|
98
|
+
metadata,
|
|
99
|
+
next: tasks.map((task) => task.name),
|
|
100
|
+
tasks: tasksWithWrites(tasks, pendingWrites, taskStates, outputKeys),
|
|
101
|
+
parentConfig: parentConfig ? formatConfig(parentConfig) : void 0
|
|
102
|
+
};
|
|
160
103
|
}
|
|
161
104
|
function tasksWithWrites(tasks, pendingWrites, states, outputKeys) {
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
const taskState = states?.[task.id];
|
|
197
|
-
return {
|
|
198
|
-
id: task.id,
|
|
199
|
-
name: task.name,
|
|
200
|
-
path: task.path,
|
|
201
|
-
interrupts,
|
|
202
|
-
...(taskState !== undefined ? { state: taskState } : {}),
|
|
203
|
-
result,
|
|
204
|
-
};
|
|
205
|
-
});
|
|
105
|
+
return tasks.map((task) => {
|
|
106
|
+
const error = pendingWrites.find(([id, n]) => id === task.id && n === require_constants.ERROR)?.[2];
|
|
107
|
+
const interrupts = pendingWrites.filter(([id, n]) => id === task.id && n === require_constants.INTERRUPT).map(([, , v]) => v);
|
|
108
|
+
const result = (() => {
|
|
109
|
+
if (error || interrupts.length || !pendingWrites.length) return void 0;
|
|
110
|
+
const idx = pendingWrites.findIndex(([tid, n]) => tid === task.id && n === require_constants.RETURN);
|
|
111
|
+
if (idx >= 0) return pendingWrites[idx][2];
|
|
112
|
+
if (typeof outputKeys === "string") return pendingWrites.find(([tid, n]) => tid === task.id && n === outputKeys)?.[2];
|
|
113
|
+
if (Array.isArray(outputKeys)) {
|
|
114
|
+
const results = pendingWrites.filter(([tid, n]) => tid === task.id && outputKeys.includes(n)).map(([, n, v]) => [n, v]);
|
|
115
|
+
if (!results.length) return void 0;
|
|
116
|
+
return mapTaskResultWrites(results);
|
|
117
|
+
}
|
|
118
|
+
return void 0;
|
|
119
|
+
})();
|
|
120
|
+
if (error) return {
|
|
121
|
+
id: task.id,
|
|
122
|
+
name: task.name,
|
|
123
|
+
path: task.path,
|
|
124
|
+
error,
|
|
125
|
+
interrupts,
|
|
126
|
+
result
|
|
127
|
+
};
|
|
128
|
+
const taskState = states?.[task.id];
|
|
129
|
+
return {
|
|
130
|
+
id: task.id,
|
|
131
|
+
name: task.name,
|
|
132
|
+
path: task.path,
|
|
133
|
+
interrupts,
|
|
134
|
+
...taskState !== void 0 ? { state: taskState } : {},
|
|
135
|
+
result
|
|
136
|
+
};
|
|
137
|
+
});
|
|
206
138
|
}
|
|
207
139
|
function printStepCheckpoint(step, channels, whitelist) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
140
|
+
console.log([
|
|
141
|
+
`${wrap(COLORS_MAP.blue, `[${step}:checkpoint]`)}`,
|
|
142
|
+
`\x1b[1m State at the end of step ${step}:\x1b[0m\n`,
|
|
143
|
+
JSON.stringify(require_io.readChannels(channels, whitelist), null, 2)
|
|
144
|
+
].join(""));
|
|
213
145
|
}
|
|
214
146
|
function printStepTasks(step, nextTasks) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
.join("\n"),
|
|
222
|
-
].join(""));
|
|
147
|
+
const nTasks = nextTasks.length;
|
|
148
|
+
console.log([
|
|
149
|
+
`${wrap(COLORS_MAP.blue, `[${step}:tasks]`)}`,
|
|
150
|
+
`\x1b[1m Starting step ${step} with ${nTasks} task${nTasks === 1 ? "" : "s"}:\x1b[0m\n`,
|
|
151
|
+
nextTasks.map((task) => `- ${wrap(COLORS_MAP.green, String(task.name))} -> ${JSON.stringify(task.input, null, 2)}`).join("\n")
|
|
152
|
+
].join(""));
|
|
223
153
|
}
|
|
224
154
|
function printStepWrites(step, writes, whitelist) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
console.log([
|
|
236
|
-
`${(0, exports.wrap)(COLORS_MAP.blue, `[${step}:writes]`)}`,
|
|
237
|
-
`\x1b[1m Finished step ${step} with writes to ${Object.keys(byChannel).length} channel${Object.keys(byChannel).length !== 1 ? "s" : ""}:\x1b[0m\n`,
|
|
238
|
-
Object.entries(byChannel)
|
|
239
|
-
.map(([name, vals]) => `- ${(0, exports.wrap)(COLORS_MAP.yellow, name)} -> ${vals
|
|
240
|
-
.map((v) => JSON.stringify(v))
|
|
241
|
-
.join(", ")}`)
|
|
242
|
-
.join("\n"),
|
|
243
|
-
].join(""));
|
|
155
|
+
const byChannel = {};
|
|
156
|
+
for (const [channel, value] of writes) if (whitelist.includes(channel)) {
|
|
157
|
+
if (!byChannel[channel]) byChannel[channel] = [];
|
|
158
|
+
byChannel[channel].push(value);
|
|
159
|
+
}
|
|
160
|
+
console.log([
|
|
161
|
+
`${wrap(COLORS_MAP.blue, `[${step}:writes]`)}`,
|
|
162
|
+
`\x1b[1m Finished step ${step} with writes to ${Object.keys(byChannel).length} channel${Object.keys(byChannel).length !== 1 ? "s" : ""}:\x1b[0m\n`,
|
|
163
|
+
Object.entries(byChannel).map(([name, vals]) => `- ${wrap(COLORS_MAP.yellow, name)} -> ${vals.map((v) => JSON.stringify(v)).join(", ")}`).join("\n")
|
|
164
|
+
].join(""));
|
|
244
165
|
}
|
|
245
|
-
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
exports.mapDebugCheckpoint = mapDebugCheckpoint;
|
|
169
|
+
exports.mapDebugTaskResults = mapDebugTaskResults;
|
|
170
|
+
exports.mapDebugTasks = mapDebugTasks;
|
|
171
|
+
exports.printStepCheckpoint = printStepCheckpoint;
|
|
172
|
+
exports.printStepTasks = printStepTasks;
|
|
173
|
+
exports.printStepWrites = printStepWrites;
|
|
174
|
+
exports.tasksWithWrites = tasksWithWrites;
|
|
175
|
+
//# sourceMappingURL=debug.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.cjs","names":["COLORS_MAP: ConsoleColorMap","TAG_HIDDEN","INTERRUPT","result: Record<string, unknown>","pyConfig: Partial<\n Record<CamelToSnake<keyof RunnableConfig>, unknown>\n >","config","taskStates: Record<string, RunnableConfig | StateSnapshot>","findSubgraphPregel","readChannels","ERROR","RETURN","byChannel: Record<string, any[]>"],"sources":["../../src/pregel/debug.ts"],"sourcesContent":["import { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n CheckpointMetadata,\n CheckpointPendingWrite,\n PendingWrite,\n} from \"@langchain/langgraph-checkpoint\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport {\n ERROR,\n Interrupt,\n INTERRUPT,\n RETURN,\n TAG_HIDDEN,\n} from \"../constants.js\";\nimport { EmptyChannelError } from \"../errors.js\";\nimport {\n PregelExecutableTask,\n PregelTaskDescription,\n StateSnapshot,\n} from \"./types.js\";\nimport { readChannels } from \"./io.js\";\nimport { findSubgraphPregel } from \"./utils/subgraph.js\";\n\ntype ConsoleColors = {\n start: string;\n end: string;\n};\n\ntype ConsoleColorMap = {\n [key: string]: ConsoleColors;\n};\n\nconst COLORS_MAP: ConsoleColorMap = {\n blue: {\n start: \"\\x1b[34m\",\n end: \"\\x1b[0m\",\n },\n green: {\n start: \"\\x1b[32m\",\n end: \"\\x1b[0m\",\n },\n yellow: {\n start: \"\\x1b[33;1m\",\n end: \"\\x1b[0m\",\n },\n};\n\n/**\n * Wrap some text in a color for printing to the console.\n */\nexport const wrap = (color: ConsoleColors, text: string): string =>\n `${color.start}${text}${color.end}`;\n\nexport function printCheckpoint<Value>(\n step: number,\n channels: Record<string, BaseChannel<Value>>\n) {\n console.log(\n [\n `${wrap(COLORS_MAP.blue, \"[langgraph/checkpoint]\")}`,\n `Finishing step ${step}. Channel values:\\n`,\n `\\n${JSON.stringify(\n Object.fromEntries(_readChannels<Value>(channels)),\n null,\n 2\n )}`,\n ].join(\"\")\n );\n}\n\nexport function* _readChannels<Value>(\n channels: Record<string, BaseChannel<Value>>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): IterableIterator<[string, any]> {\n for (const [name, channel] of Object.entries(channels)) {\n try {\n yield [name, channel.get()];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n // Skip the channel if it's empty\n continue;\n } else {\n throw error; // Re-throw the error if it's not an EmptyChannelError\n }\n }\n }\n}\n\nexport function* mapDebugTasks<N extends PropertyKey, C extends PropertyKey>(\n tasks: readonly PregelExecutableTask<N, C>[]\n) {\n for (const { id, name, input, config, triggers, writes } of tasks) {\n if (config?.tags?.includes(TAG_HIDDEN)) continue;\n\n const interrupts = writes\n .filter(([writeId, n]) => {\n return writeId === id && n === INTERRUPT;\n })\n .map(([, v]) => {\n return v;\n });\n yield { id, name, input, triggers, interrupts };\n }\n}\n\nfunction isMultipleChannelWrite(\n value: unknown\n): value is { $writes: unknown[] } {\n if (typeof value !== \"object\" || value === null) return false;\n return \"$writes\" in value && Array.isArray(value.$writes);\n}\n\nfunction mapTaskResultWrites(writes: PendingWrite<unknown>[]) {\n const result: Record<string, unknown> = {};\n\n for (const [channel, value] of writes) {\n const strChannel = String(channel);\n\n if (strChannel in result) {\n const channelWrites = isMultipleChannelWrite(result[strChannel])\n ? result[strChannel].$writes\n : [result[strChannel]];\n\n channelWrites.push(value);\n result[strChannel] = { $writes: channelWrites };\n } else {\n result[strChannel] = value;\n }\n }\n return result;\n}\n\nexport function* mapDebugTaskResults<\n N extends PropertyKey,\n C extends PropertyKey\n>(\n tasks: readonly [PregelExecutableTask<N, C>, PendingWrite<C>[]][],\n streamChannels: PropertyKey | Array<PropertyKey>\n) {\n for (const [{ id, name, config }, writes] of tasks) {\n if (config?.tags?.includes(TAG_HIDDEN)) continue;\n yield {\n id,\n name,\n result: mapTaskResultWrites(\n writes.filter(([channel]) => {\n return Array.isArray(streamChannels)\n ? streamChannels.includes(channel)\n : channel === streamChannels;\n })\n ),\n interrupts: writes.filter((w) => w[0] === INTERRUPT).map((w) => w[1]),\n };\n }\n}\n\ntype ChannelKey = string | number | symbol;\n\nexport function* mapDebugCheckpoint<\n N extends PropertyKey,\n C extends PropertyKey\n>(\n config: RunnableConfig,\n channels: Record<string, BaseChannel>,\n streamChannels: string | string[],\n metadata: CheckpointMetadata,\n tasks: readonly PregelExecutableTask<N, C>[],\n pendingWrites: CheckpointPendingWrite[],\n parentConfig: RunnableConfig | undefined,\n outputKeys: ChannelKey | ChannelKey[]\n) {\n function formatConfig(config: RunnableConfig) {\n // https://stackoverflow.com/a/78298178\n type CamelToSnake<\n T extends string,\n A extends string = \"\"\n > = T extends `${infer F}${infer R}`\n ? CamelToSnake<\n R,\n `${A}${F extends Lowercase<F> ? F : `_${Lowercase<F>}`}`\n >\n : A;\n\n // make sure the config is consistent with Python\n const pyConfig: Partial<\n Record<CamelToSnake<keyof RunnableConfig>, unknown>\n > = {};\n\n if (config.callbacks != null) pyConfig.callbacks = config.callbacks;\n if (config.configurable != null)\n pyConfig.configurable = config.configurable;\n if (config.maxConcurrency != null)\n pyConfig.max_concurrency = config.maxConcurrency;\n\n if (config.metadata != null) pyConfig.metadata = config.metadata;\n if (config.recursionLimit != null)\n pyConfig.recursion_limit = config.recursionLimit;\n if (config.runId != null) pyConfig.run_id = config.runId;\n if (config.runName != null) pyConfig.run_name = config.runName;\n if (config.tags != null) pyConfig.tags = config.tags;\n\n return pyConfig;\n }\n\n const parentNs = config.configurable?.checkpoint_ns;\n const taskStates: Record<string, RunnableConfig | StateSnapshot> = {};\n\n for (const task of tasks) {\n const candidates = task.subgraphs?.length ? task.subgraphs : [task.proc];\n if (!candidates.find(findSubgraphPregel)) continue;\n\n let taskNs = `${task.name as string}:${task.id}`;\n if (parentNs) taskNs = `${parentNs}|${taskNs}`;\n\n taskStates[task.id] = {\n configurable: {\n thread_id: config.configurable?.thread_id,\n checkpoint_ns: taskNs,\n },\n };\n }\n\n yield {\n config: formatConfig(config),\n values: readChannels(channels, streamChannels),\n metadata,\n next: tasks.map((task) => task.name),\n tasks: tasksWithWrites(tasks, pendingWrites, taskStates, outputKeys),\n parentConfig: parentConfig ? formatConfig(parentConfig) : undefined,\n };\n}\n\nexport function tasksWithWrites<N extends PropertyKey, C extends PropertyKey>(\n tasks: PregelTaskDescription[] | readonly PregelExecutableTask<N, C>[],\n pendingWrites: CheckpointPendingWrite[],\n states: Record<string, RunnableConfig | StateSnapshot> | undefined,\n outputKeys: ChannelKey[] | ChannelKey\n): PregelTaskDescription[] {\n return tasks.map((task): PregelTaskDescription => {\n const error = pendingWrites.find(\n ([id, n]) => id === task.id && n === ERROR\n )?.[2];\n\n const interrupts = pendingWrites\n .filter(([id, n]) => id === task.id && n === INTERRUPT)\n .map(([, , v]) => v) as Interrupt[];\n\n const result = (() => {\n if (error || interrupts.length || !pendingWrites.length) return undefined;\n\n const idx = pendingWrites.findIndex(\n ([tid, n]) => tid === task.id && n === RETURN\n );\n\n if (idx >= 0) return pendingWrites[idx][2];\n\n if (typeof outputKeys === \"string\") {\n return pendingWrites.find(\n ([tid, n]) => tid === task.id && n === outputKeys\n )?.[2];\n }\n\n if (Array.isArray(outputKeys)) {\n const results = pendingWrites\n .filter(([tid, n]) => tid === task.id && outputKeys.includes(n))\n .map(([, n, v]) => [n, v] as PendingWrite<C>);\n\n if (!results.length) return undefined;\n return mapTaskResultWrites(results);\n }\n\n return undefined;\n })();\n\n if (error) {\n return {\n id: task.id,\n name: task.name as string,\n path: task.path,\n error,\n interrupts,\n result,\n };\n }\n\n const taskState = states?.[task.id];\n return {\n id: task.id,\n name: task.name as string,\n path: task.path,\n interrupts,\n ...(taskState !== undefined ? { state: taskState } : {}),\n result,\n };\n });\n}\n\nexport function printStepCheckpoint(\n step: number,\n channels: Record<string, BaseChannel<unknown>>,\n whitelist: string[]\n): void {\n console.log(\n [\n `${wrap(COLORS_MAP.blue, `[${step}:checkpoint]`)}`,\n `\\x1b[1m State at the end of step ${step}:\\x1b[0m\\n`,\n JSON.stringify(readChannels(channels, whitelist), null, 2),\n ].join(\"\")\n );\n}\n\nexport function printStepTasks<N extends PropertyKey, C extends PropertyKey>(\n step: number,\n nextTasks: readonly PregelExecutableTask<N, C>[]\n): void {\n const nTasks = nextTasks.length;\n console.log(\n [\n `${wrap(COLORS_MAP.blue, `[${step}:tasks]`)}`,\n `\\x1b[1m Starting step ${step} with ${nTasks} task${\n nTasks === 1 ? \"\" : \"s\"\n }:\\x1b[0m\\n`,\n nextTasks\n .map(\n (task) =>\n `- ${wrap(COLORS_MAP.green, String(task.name))} -> ${JSON.stringify(\n task.input,\n null,\n 2\n )}`\n )\n .join(\"\\n\"),\n ].join(\"\")\n );\n}\n\nexport function printStepWrites(\n step: number,\n writes: PendingWrite[],\n whitelist: string[]\n): void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const byChannel: Record<string, any[]> = {};\n\n for (const [channel, value] of writes) {\n if (whitelist.includes(channel)) {\n if (!byChannel[channel]) {\n byChannel[channel] = [];\n }\n byChannel[channel].push(value);\n }\n }\n\n console.log(\n [\n `${wrap(COLORS_MAP.blue, `[${step}:writes]`)}`,\n `\\x1b[1m Finished step ${step} with writes to ${\n Object.keys(byChannel).length\n } channel${Object.keys(byChannel).length !== 1 ? \"s\" : \"\"}:\\x1b[0m\\n`,\n Object.entries(byChannel)\n .map(\n ([name, vals]) =>\n `- ${wrap(COLORS_MAP.yellow, name)} -> ${vals\n .map((v) => JSON.stringify(v))\n .join(\", \")}`\n )\n .join(\"\\n\"),\n ].join(\"\")\n );\n}\n"],"mappings":";;;;;AAgCA,MAAMA,aAA8B;CAClC,MAAM;EACJ,OAAO;EACP,KAAK;;CAEP,OAAO;EACL,OAAO;EACP,KAAK;;CAEP,QAAQ;EACN,OAAO;EACP,KAAK;;;;;;AAOT,MAAa,QAAQ,OAAsB,SACzC,GAAG,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