@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/remote.cjs
CHANGED
|
@@ -1,465 +1,346 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_errors = require('../errors.cjs');
|
|
3
|
+
const require_constants = require('../constants.cjs');
|
|
4
|
+
require('../web.cjs');
|
|
5
|
+
const __langchain_core_runnables = require_rolldown_runtime.__toESM(require("@langchain/core/runnables"));
|
|
6
|
+
const __langchain_core_runnables_graph = require_rolldown_runtime.__toESM(require("@langchain/core/runnables/graph"));
|
|
7
|
+
const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages"));
|
|
8
|
+
const __langchain_langgraph_sdk = require_rolldown_runtime.__toESM(require("@langchain/langgraph-sdk"));
|
|
9
|
+
|
|
10
|
+
//#region src/pregel/remote.ts
|
|
11
11
|
const _serializeInputs = (obj) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
...dict.data,
|
|
23
|
-
role: obj.getType(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, _serializeInputs(value)]));
|
|
12
|
+
if (obj === null || typeof obj !== "object") return obj;
|
|
13
|
+
if (Array.isArray(obj)) return obj.map(_serializeInputs);
|
|
14
|
+
if ((0, __langchain_core_messages.isBaseMessage)(obj)) {
|
|
15
|
+
const dict = obj.toDict();
|
|
16
|
+
return {
|
|
17
|
+
...dict.data,
|
|
18
|
+
role: obj.getType()
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, _serializeInputs(value)]));
|
|
27
22
|
};
|
|
28
23
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
* Return a tuple of the final list of stream modes sent to the
|
|
25
|
+
* remote graph and a boolean flag indicating if only one stream mode was
|
|
26
|
+
* originally requested and whether stream mode 'updates'
|
|
27
|
+
* was present in the original list of stream modes.
|
|
28
|
+
*
|
|
29
|
+
* 'updates' mode is always added to the list of stream modes so that interrupts
|
|
30
|
+
* can be detected in the remote graph.
|
|
31
|
+
*/
|
|
37
32
|
const getStreamModes = (streamMode, defaultStreamMode = "updates") => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
updatedStreamModes.push("updates");
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
updatedStreamModes,
|
|
59
|
-
reqUpdates,
|
|
60
|
-
reqSingle,
|
|
61
|
-
};
|
|
33
|
+
const updatedStreamModes = [];
|
|
34
|
+
let reqUpdates = false;
|
|
35
|
+
let reqSingle = true;
|
|
36
|
+
if (streamMode !== void 0 && (typeof streamMode === "string" || Array.isArray(streamMode) && streamMode.length > 0)) {
|
|
37
|
+
reqSingle = typeof streamMode === "string";
|
|
38
|
+
const mapped = Array.isArray(streamMode) ? streamMode : [streamMode];
|
|
39
|
+
updatedStreamModes.push(...mapped);
|
|
40
|
+
} else updatedStreamModes.push(defaultStreamMode);
|
|
41
|
+
if (updatedStreamModes.includes("updates")) reqUpdates = true;
|
|
42
|
+
else updatedStreamModes.push("updates");
|
|
43
|
+
return {
|
|
44
|
+
updatedStreamModes,
|
|
45
|
+
reqUpdates,
|
|
46
|
+
reqSingle
|
|
47
|
+
};
|
|
62
48
|
};
|
|
63
49
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
throw new web_js_1.GraphInterrupt(chunk.data[constants_js_1.INTERRUPT]);
|
|
360
|
-
}
|
|
361
|
-
if (!reqUpdates) {
|
|
362
|
-
continue;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
else if (chunk.event?.startsWith("error")) {
|
|
366
|
-
throw new web_js_1.RemoteException(typeof chunk.data === "string"
|
|
367
|
-
? chunk.data
|
|
368
|
-
: JSON.stringify(chunk.data));
|
|
369
|
-
}
|
|
370
|
-
if (!updatedStreamModes.includes(chunk.event.split(constants_js_1.CHECKPOINT_NAMESPACE_SEPARATOR)[0])) {
|
|
371
|
-
continue;
|
|
372
|
-
}
|
|
373
|
-
if (options?.subgraphs) {
|
|
374
|
-
if (reqSingle) {
|
|
375
|
-
yield [namespace, chunk.data];
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
yield [namespace, mode, chunk.data];
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
else if (reqSingle) {
|
|
382
|
-
yield chunk.data;
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
yield [mode, chunk.data];
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
async updateState(inputConfig, values, asNode) {
|
|
390
|
-
const mergedConfig = (0, runnables_1.mergeConfigs)(this.config, inputConfig);
|
|
391
|
-
const response = await this.client.threads.updateState(mergedConfig.configurable?.thread_id, { values, asNode, checkpoint: this._getCheckpoint(mergedConfig) });
|
|
392
|
-
// TODO: Fix SDK typing
|
|
393
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
394
|
-
return this._getConfig(response.checkpoint);
|
|
395
|
-
}
|
|
396
|
-
async *getStateHistory(config, options) {
|
|
397
|
-
const mergedConfig = (0, runnables_1.mergeConfigs)(this.config, config);
|
|
398
|
-
const states = await this.client.threads.getHistory(mergedConfig.configurable?.thread_id, {
|
|
399
|
-
limit: options?.limit ?? 10,
|
|
400
|
-
// TODO: Fix type
|
|
401
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
402
|
-
before: this._getCheckpoint(options?.before),
|
|
403
|
-
metadata: options?.filter,
|
|
404
|
-
checkpoint: this._getCheckpoint(mergedConfig),
|
|
405
|
-
});
|
|
406
|
-
for (const state of states) {
|
|
407
|
-
yield this._createStateSnapshot(state);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
_getDrawableNodes(nodes) {
|
|
411
|
-
const nodesMap = {};
|
|
412
|
-
for (const node of nodes) {
|
|
413
|
-
const nodeId = node.id;
|
|
414
|
-
nodesMap[nodeId] = {
|
|
415
|
-
id: nodeId.toString(),
|
|
416
|
-
name: typeof node.data === "string" ? node.data : node.data?.name ?? "",
|
|
417
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
418
|
-
data: node.data ?? {},
|
|
419
|
-
metadata: typeof node.data !== "string" ? node.data?.metadata ?? {} : {},
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
return nodesMap;
|
|
423
|
-
}
|
|
424
|
-
async getState(config, options) {
|
|
425
|
-
const mergedConfig = (0, runnables_1.mergeConfigs)(this.config, config);
|
|
426
|
-
const state = await this.client.threads.getState(mergedConfig.configurable?.thread_id, this._getCheckpoint(mergedConfig), options);
|
|
427
|
-
return this._createStateSnapshot(state);
|
|
428
|
-
}
|
|
429
|
-
/** @deprecated Use getGraphAsync instead. The async method will become the default in the next minor release. */
|
|
430
|
-
getGraph(_) {
|
|
431
|
-
throw new Error(`The synchronous "getGraph" is not supported for this graph. Call "getGraphAsync" instead.`);
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Returns a drawable representation of the computation graph.
|
|
435
|
-
*/
|
|
436
|
-
async getGraphAsync(config) {
|
|
437
|
-
const graph = await this.client.assistants.getGraph(this.graphId, {
|
|
438
|
-
xray: config?.xray,
|
|
439
|
-
});
|
|
440
|
-
return new graph_1.Graph({
|
|
441
|
-
nodes: this._getDrawableNodes(graph.nodes),
|
|
442
|
-
edges: graph.edges,
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
/** @deprecated Use getSubgraphsAsync instead. The async method will become the default in the next minor release. */
|
|
446
|
-
getSubgraphs() {
|
|
447
|
-
throw new Error(`The synchronous "getSubgraphs" method is not supported for this graph. Call "getSubgraphsAsync" instead.`);
|
|
448
|
-
}
|
|
449
|
-
async *getSubgraphsAsync(namespace, recurse = false) {
|
|
450
|
-
const subgraphs = await this.client.assistants.getSubgraphs(this.graphId, {
|
|
451
|
-
namespace,
|
|
452
|
-
recurse,
|
|
453
|
-
});
|
|
454
|
-
for (const [ns, graphSchema] of Object.entries(subgraphs)) {
|
|
455
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
456
|
-
const remoteSubgraph = new this.constructor({
|
|
457
|
-
...this,
|
|
458
|
-
graphId: graphSchema.graph_id,
|
|
459
|
-
});
|
|
460
|
-
yield [ns, remoteSubgraph];
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
50
|
+
* The `RemoteGraph` class is a client implementation for calling remote
|
|
51
|
+
* APIs that implement the LangGraph Server API specification.
|
|
52
|
+
*
|
|
53
|
+
* For example, the `RemoteGraph` class can be used to call APIs from deployments
|
|
54
|
+
* on LangGraph Cloud.
|
|
55
|
+
*
|
|
56
|
+
* `RemoteGraph` behaves the same way as a `StateGraph` and can be used directly as
|
|
57
|
+
* a node in another `StateGraph`.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { RemoteGraph } from "@langchain/langgraph/remote";
|
|
62
|
+
*
|
|
63
|
+
* // Can also pass a LangGraph SDK client instance directly
|
|
64
|
+
* const remoteGraph = new RemoteGraph({
|
|
65
|
+
* graphId: process.env.LANGGRAPH_REMOTE_GRAPH_ID!,
|
|
66
|
+
* apiKey: process.env.LANGGRAPH_REMOTE_GRAPH_API_KEY,
|
|
67
|
+
* url: process.env.LANGGRAPH_REMOTE_GRAPH_API_URL,
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* const input = {
|
|
71
|
+
* messages: [
|
|
72
|
+
* {
|
|
73
|
+
* role: "human",
|
|
74
|
+
* content: "Hello world!",
|
|
75
|
+
* },
|
|
76
|
+
* ],
|
|
77
|
+
* };
|
|
78
|
+
*
|
|
79
|
+
* const config = {
|
|
80
|
+
* configurable: { thread_id: "threadId1" },
|
|
81
|
+
* };
|
|
82
|
+
*
|
|
83
|
+
* await remoteGraph.invoke(input, config);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
var RemoteGraph = class extends __langchain_core_runnables.Runnable {
|
|
87
|
+
static lc_name() {
|
|
88
|
+
return "RemoteGraph";
|
|
89
|
+
}
|
|
90
|
+
lc_namespace = ["langgraph", "pregel"];
|
|
91
|
+
lg_is_pregel = true;
|
|
92
|
+
config;
|
|
93
|
+
graphId;
|
|
94
|
+
client;
|
|
95
|
+
interruptBefore;
|
|
96
|
+
interruptAfter;
|
|
97
|
+
constructor(params) {
|
|
98
|
+
super(params);
|
|
99
|
+
this.graphId = params.graphId;
|
|
100
|
+
this.client = params.client ?? new __langchain_langgraph_sdk.Client({
|
|
101
|
+
apiUrl: params.url,
|
|
102
|
+
apiKey: params.apiKey,
|
|
103
|
+
defaultHeaders: params.headers
|
|
104
|
+
});
|
|
105
|
+
this.config = params.config;
|
|
106
|
+
this.interruptBefore = params.interruptBefore;
|
|
107
|
+
this.interruptAfter = params.interruptAfter;
|
|
108
|
+
}
|
|
109
|
+
withConfig(config) {
|
|
110
|
+
const mergedConfig = (0, __langchain_core_runnables.mergeConfigs)(this.config, config);
|
|
111
|
+
return new this.constructor({
|
|
112
|
+
...this,
|
|
113
|
+
config: mergedConfig
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
_sanitizeConfig(config) {
|
|
117
|
+
const reservedConfigurableKeys = new Set([
|
|
118
|
+
"callbacks",
|
|
119
|
+
"checkpoint_map",
|
|
120
|
+
"checkpoint_id",
|
|
121
|
+
"checkpoint_ns"
|
|
122
|
+
]);
|
|
123
|
+
const sanitizeObj = (obj) => {
|
|
124
|
+
try {
|
|
125
|
+
JSON.stringify(obj);
|
|
126
|
+
return obj;
|
|
127
|
+
} catch {
|
|
128
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
129
|
+
return JSON.parse(JSON.stringify(obj, (_, value) => {
|
|
130
|
+
if (typeof value === "object" && value != null) {
|
|
131
|
+
if (seen.has(value)) return "[Circular]";
|
|
132
|
+
seen.add(value);
|
|
133
|
+
}
|
|
134
|
+
if (typeof value === "bigint") return value.toString();
|
|
135
|
+
return value;
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const sanitizedConfig = sanitizeObj(config);
|
|
140
|
+
const newConfigurable = Object.fromEntries(Object.entries(sanitizedConfig.configurable ?? {}).filter(([k]) => !reservedConfigurableKeys.has(k) && !k.startsWith("__pregel_")));
|
|
141
|
+
return {
|
|
142
|
+
tags: sanitizedConfig.tags ?? [],
|
|
143
|
+
metadata: sanitizedConfig.metadata ?? {},
|
|
144
|
+
configurable: newConfigurable,
|
|
145
|
+
recursion_limit: sanitizedConfig.recursionLimit
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
_getConfig(checkpoint) {
|
|
149
|
+
return { configurable: {
|
|
150
|
+
thread_id: checkpoint.thread_id,
|
|
151
|
+
checkpoint_ns: checkpoint.checkpoint_ns,
|
|
152
|
+
checkpoint_id: checkpoint.checkpoint_id,
|
|
153
|
+
checkpoint_map: checkpoint.checkpoint_map ?? {}
|
|
154
|
+
} };
|
|
155
|
+
}
|
|
156
|
+
_getCheckpoint(config) {
|
|
157
|
+
if (config?.configurable === void 0) return void 0;
|
|
158
|
+
const checkpointKeys = [
|
|
159
|
+
"thread_id",
|
|
160
|
+
"checkpoint_ns",
|
|
161
|
+
"checkpoint_id",
|
|
162
|
+
"checkpoint_map"
|
|
163
|
+
];
|
|
164
|
+
const checkpoint = Object.fromEntries(checkpointKeys.map((key) => [key, config.configurable[key]]).filter(([_, value]) => value !== void 0));
|
|
165
|
+
return Object.keys(checkpoint).length > 0 ? checkpoint : void 0;
|
|
166
|
+
}
|
|
167
|
+
_createStateSnapshot(state) {
|
|
168
|
+
const tasks = state.tasks.map((task) => {
|
|
169
|
+
return {
|
|
170
|
+
id: task.id,
|
|
171
|
+
name: task.name,
|
|
172
|
+
error: task.error ? { message: task.error } : void 0,
|
|
173
|
+
interrupts: task.interrupts.map(({ id,...rest }) => ({
|
|
174
|
+
interrupt_id: id,
|
|
175
|
+
...rest
|
|
176
|
+
})),
|
|
177
|
+
state: task.state ? this._createStateSnapshot(task.state) : task.checkpoint ? { configurable: task.checkpoint } : void 0,
|
|
178
|
+
result: task.result
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
return {
|
|
182
|
+
values: state.values,
|
|
183
|
+
next: state.next ? [...state.next] : [],
|
|
184
|
+
config: { configurable: {
|
|
185
|
+
thread_id: state.checkpoint.thread_id,
|
|
186
|
+
checkpoint_ns: state.checkpoint.checkpoint_ns,
|
|
187
|
+
checkpoint_id: state.checkpoint.checkpoint_id,
|
|
188
|
+
checkpoint_map: state.checkpoint.checkpoint_map ?? {}
|
|
189
|
+
} },
|
|
190
|
+
metadata: state.metadata ? state.metadata : void 0,
|
|
191
|
+
createdAt: state.created_at ?? void 0,
|
|
192
|
+
parentConfig: state.parent_checkpoint ? { configurable: {
|
|
193
|
+
thread_id: state.parent_checkpoint.thread_id,
|
|
194
|
+
checkpoint_ns: state.parent_checkpoint.checkpoint_ns,
|
|
195
|
+
checkpoint_id: state.parent_checkpoint.checkpoint_id,
|
|
196
|
+
checkpoint_map: state.parent_checkpoint.checkpoint_map ?? {}
|
|
197
|
+
} } : void 0,
|
|
198
|
+
tasks
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
async invoke(input, options) {
|
|
202
|
+
let lastValue;
|
|
203
|
+
const stream = await this.stream(input, {
|
|
204
|
+
...options,
|
|
205
|
+
streamMode: "values"
|
|
206
|
+
});
|
|
207
|
+
for await (const chunk of stream) lastValue = chunk;
|
|
208
|
+
return lastValue;
|
|
209
|
+
}
|
|
210
|
+
streamEvents(_input, _options) {
|
|
211
|
+
throw new Error("Not implemented.");
|
|
212
|
+
}
|
|
213
|
+
async *_streamIterator(input, options) {
|
|
214
|
+
const mergedConfig = (0, __langchain_core_runnables.mergeConfigs)(this.config, options);
|
|
215
|
+
const sanitizedConfig = this._sanitizeConfig(mergedConfig);
|
|
216
|
+
const streamProtocolInstance = options?.configurable?.[require_constants.CONFIG_KEY_STREAM];
|
|
217
|
+
const streamSubgraphs = options?.subgraphs ?? streamProtocolInstance !== void 0;
|
|
218
|
+
const interruptBefore = options?.interruptBefore ?? this.interruptBefore;
|
|
219
|
+
const interruptAfter = options?.interruptAfter ?? this.interruptAfter;
|
|
220
|
+
const { updatedStreamModes, reqSingle, reqUpdates } = getStreamModes(options?.streamMode);
|
|
221
|
+
const extendedStreamModes = [...new Set([...updatedStreamModes, ...streamProtocolInstance?.modes ?? /* @__PURE__ */ new Set()])].map((mode) => {
|
|
222
|
+
if (mode === "messages") return "messages-tuple";
|
|
223
|
+
return mode;
|
|
224
|
+
});
|
|
225
|
+
let command;
|
|
226
|
+
let serializedInput;
|
|
227
|
+
if (require_constants.isCommand(input)) {
|
|
228
|
+
command = input.toJSON();
|
|
229
|
+
serializedInput = void 0;
|
|
230
|
+
} else serializedInput = _serializeInputs(input);
|
|
231
|
+
for await (const chunk of this.client.runs.stream(sanitizedConfig.configurable.thread_id, this.graphId, {
|
|
232
|
+
command,
|
|
233
|
+
input: serializedInput,
|
|
234
|
+
config: sanitizedConfig,
|
|
235
|
+
streamMode: extendedStreamModes,
|
|
236
|
+
interruptBefore,
|
|
237
|
+
interruptAfter,
|
|
238
|
+
streamSubgraphs,
|
|
239
|
+
ifNotExists: "create",
|
|
240
|
+
signal: mergedConfig.signal
|
|
241
|
+
})) {
|
|
242
|
+
let mode;
|
|
243
|
+
let namespace;
|
|
244
|
+
if (chunk.event.includes(require_constants.CHECKPOINT_NAMESPACE_SEPARATOR)) {
|
|
245
|
+
const eventComponents = chunk.event.split(require_constants.CHECKPOINT_NAMESPACE_SEPARATOR);
|
|
246
|
+
mode = eventComponents[0];
|
|
247
|
+
namespace = eventComponents.slice(1);
|
|
248
|
+
} else {
|
|
249
|
+
mode = chunk.event;
|
|
250
|
+
namespace = [];
|
|
251
|
+
}
|
|
252
|
+
const callerNamespace = options?.configurable?.checkpoint_ns;
|
|
253
|
+
if (typeof callerNamespace === "string") namespace = callerNamespace.split(require_constants.CHECKPOINT_NAMESPACE_SEPARATOR).concat(namespace);
|
|
254
|
+
if (streamProtocolInstance !== void 0 && streamProtocolInstance.modes?.has(chunk.event)) streamProtocolInstance.push([
|
|
255
|
+
namespace,
|
|
256
|
+
mode,
|
|
257
|
+
chunk.data
|
|
258
|
+
]);
|
|
259
|
+
if (chunk.event.startsWith("updates")) {
|
|
260
|
+
if (typeof chunk.data === "object" && chunk.data?.[require_constants.INTERRUPT] !== void 0) throw new require_errors.GraphInterrupt(chunk.data[require_constants.INTERRUPT]);
|
|
261
|
+
if (!reqUpdates) continue;
|
|
262
|
+
} else if (chunk.event?.startsWith("error")) throw new require_errors.RemoteException(typeof chunk.data === "string" ? chunk.data : JSON.stringify(chunk.data));
|
|
263
|
+
if (!updatedStreamModes.includes(chunk.event.split(require_constants.CHECKPOINT_NAMESPACE_SEPARATOR)[0])) continue;
|
|
264
|
+
if (options?.subgraphs) if (reqSingle) yield [namespace, chunk.data];
|
|
265
|
+
else yield [
|
|
266
|
+
namespace,
|
|
267
|
+
mode,
|
|
268
|
+
chunk.data
|
|
269
|
+
];
|
|
270
|
+
else if (reqSingle) yield chunk.data;
|
|
271
|
+
else yield [mode, chunk.data];
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async updateState(inputConfig, values, asNode) {
|
|
275
|
+
const mergedConfig = (0, __langchain_core_runnables.mergeConfigs)(this.config, inputConfig);
|
|
276
|
+
const response = await this.client.threads.updateState(mergedConfig.configurable?.thread_id, {
|
|
277
|
+
values,
|
|
278
|
+
asNode,
|
|
279
|
+
checkpoint: this._getCheckpoint(mergedConfig)
|
|
280
|
+
});
|
|
281
|
+
return this._getConfig(response.checkpoint);
|
|
282
|
+
}
|
|
283
|
+
async *getStateHistory(config, options) {
|
|
284
|
+
const mergedConfig = (0, __langchain_core_runnables.mergeConfigs)(this.config, config);
|
|
285
|
+
const states = await this.client.threads.getHistory(mergedConfig.configurable?.thread_id, {
|
|
286
|
+
limit: options?.limit ?? 10,
|
|
287
|
+
before: this._getCheckpoint(options?.before),
|
|
288
|
+
metadata: options?.filter,
|
|
289
|
+
checkpoint: this._getCheckpoint(mergedConfig)
|
|
290
|
+
});
|
|
291
|
+
for (const state of states) yield this._createStateSnapshot(state);
|
|
292
|
+
}
|
|
293
|
+
_getDrawableNodes(nodes) {
|
|
294
|
+
const nodesMap = {};
|
|
295
|
+
for (const node of nodes) {
|
|
296
|
+
const nodeId = node.id;
|
|
297
|
+
nodesMap[nodeId] = {
|
|
298
|
+
id: nodeId.toString(),
|
|
299
|
+
name: typeof node.data === "string" ? node.data : node.data?.name ?? "",
|
|
300
|
+
data: node.data ?? {},
|
|
301
|
+
metadata: typeof node.data !== "string" ? node.data?.metadata ?? {} : {}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
return nodesMap;
|
|
305
|
+
}
|
|
306
|
+
async getState(config, options) {
|
|
307
|
+
const mergedConfig = (0, __langchain_core_runnables.mergeConfigs)(this.config, config);
|
|
308
|
+
const state = await this.client.threads.getState(mergedConfig.configurable?.thread_id, this._getCheckpoint(mergedConfig), options);
|
|
309
|
+
return this._createStateSnapshot(state);
|
|
310
|
+
}
|
|
311
|
+
/** @deprecated Use getGraphAsync instead. The async method will become the default in the next minor release. */
|
|
312
|
+
getGraph(_) {
|
|
313
|
+
throw new Error(`The synchronous "getGraph" is not supported for this graph. Call "getGraphAsync" instead.`);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Returns a drawable representation of the computation graph.
|
|
317
|
+
*/
|
|
318
|
+
async getGraphAsync(config) {
|
|
319
|
+
const graph = await this.client.assistants.getGraph(this.graphId, { xray: config?.xray });
|
|
320
|
+
return new __langchain_core_runnables_graph.Graph({
|
|
321
|
+
nodes: this._getDrawableNodes(graph.nodes),
|
|
322
|
+
edges: graph.edges
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
/** @deprecated Use getSubgraphsAsync instead. The async method will become the default in the next minor release. */
|
|
326
|
+
getSubgraphs() {
|
|
327
|
+
throw new Error(`The synchronous "getSubgraphs" method is not supported for this graph. Call "getSubgraphsAsync" instead.`);
|
|
328
|
+
}
|
|
329
|
+
async *getSubgraphsAsync(namespace, recurse = false) {
|
|
330
|
+
const subgraphs = await this.client.assistants.getSubgraphs(this.graphId, {
|
|
331
|
+
namespace,
|
|
332
|
+
recurse
|
|
333
|
+
});
|
|
334
|
+
for (const [ns, graphSchema] of Object.entries(subgraphs)) {
|
|
335
|
+
const remoteSubgraph = new this.constructor({
|
|
336
|
+
...this,
|
|
337
|
+
graphId: graphSchema.graph_id
|
|
338
|
+
});
|
|
339
|
+
yield [ns, remoteSubgraph];
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
//#endregion
|
|
464
345
|
exports.RemoteGraph = RemoteGraph;
|
|
465
|
-
//# sourceMappingURL=remote.
|
|
346
|
+
//# sourceMappingURL=remote.cjs.map
|