@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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { LangGraphRunnableConfig } from "../pregel/runnable_types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/func/types.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Allows the entrypoint function to return a value to the caller, as well as a separate state value to persist to the checkpoint
|
|
7
|
+
*/
|
|
8
|
+
type EntrypointFinal<ValueT, SaveT> = {
|
|
9
|
+
/**
|
|
10
|
+
* The value to return to the caller
|
|
11
|
+
*/
|
|
12
|
+
value?: ValueT;
|
|
13
|
+
/**
|
|
14
|
+
* The value to save to the checkpoint
|
|
15
|
+
*/
|
|
16
|
+
save?: SaveT;
|
|
17
|
+
__lg_type: "__pregel_final";
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Checks if a value is an EntrypointFinal - use this instead of `instanceof`, as value may have been deserialized
|
|
21
|
+
* @param value The value to check
|
|
22
|
+
* @returns Whether the value is an EntrypointFinal
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The return type of an entrypoint function.
|
|
27
|
+
*/
|
|
28
|
+
type EntrypointReturnT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, unknown> | Promise<EntrypointFinal<infer ValueT, unknown>> ? ValueT : OutputT;
|
|
29
|
+
/**
|
|
30
|
+
* The value to be saved when a function returns an EntrypointFinal.
|
|
31
|
+
*/
|
|
32
|
+
type EntrypointFinalSaveT<OutputT> = OutputT extends EntrypointFinal<unknown, infer SaveT> | Promise<EntrypointFinal<unknown, infer SaveT>> ? SaveT : OutputT;
|
|
33
|
+
/**
|
|
34
|
+
* The value to be returned when a function returns an EntrypointFinal.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Checks if an AsyncGenerator exists in the ES target/lib that we're compiling to.
|
|
39
|
+
*
|
|
40
|
+
* This is necessary because `tsc --init` targets ES2016 by default, which doesn't include AsyncGenerators.
|
|
41
|
+
*
|
|
42
|
+
* This works because when `skipLibCheck` is true (and it is in the default `tsconfig.json` created by `tsc --init`),
|
|
43
|
+
* TypeScript will replace any unresolved library types with `any`. So, when `AsyncGenerator` doesn't exist, this checks
|
|
44
|
+
* if `any` extends `object`, which it doesn't. When that happens, this type resolves to the `false` literal, and we can
|
|
45
|
+
* use it in the type predicates below to skip over the AsyncGenerator-specific logic.
|
|
46
|
+
*
|
|
47
|
+
* If we didn't have this, then the types below would be checking if the user's function extends `any` in place of the
|
|
48
|
+
* `AsyncGenerator` type, and the type predicate would branch to `never`, disallowing any valid function from being passed
|
|
49
|
+
* to `task` or `entrypoint`.
|
|
50
|
+
*/
|
|
51
|
+
type AsyncGeneratorExists = AsyncGenerator<unknown, unknown, unknown> extends object ? true : false;
|
|
52
|
+
/**
|
|
53
|
+
* Matches valid function signatures for entrypoints. Disallows generator functions.
|
|
54
|
+
*/
|
|
55
|
+
type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist
|
|
56
|
+
? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;
|
|
57
|
+
/**
|
|
58
|
+
* Matches valid function signatures for tasks. Disallows generator functions.
|
|
59
|
+
*/
|
|
60
|
+
type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [never] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist
|
|
61
|
+
? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { EntrypointFinal, EntrypointFinalSaveT, EntrypointFunc, EntrypointReturnT, TaskFunc };
|
|
64
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":["LangGraphRunnableConfig","EntrypointFinal","ValueT","SaveT","isEntrypointFinal","EntrypointReturnT","OutputT","Promise","EntrypointFinalSaveT","EntrypointFinalValueT","AsyncGeneratorExists","AsyncGenerator","EntrypointFunc","InputT","Generator","TaskFunc","ArgsT"],"sources":["../../src/func/types.d.ts"],"sourcesContent":["import { LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\n/**\n * Allows the entrypoint function to return a value to the caller, as well as a separate state value to persist to the checkpoint\n */\nexport type EntrypointFinal<ValueT, SaveT> = {\n /**\n * The value to return to the caller\n */\n value?: ValueT;\n /**\n * The value to save to the checkpoint\n */\n save?: SaveT;\n __lg_type: \"__pregel_final\";\n};\n/**\n * Checks if a value is an EntrypointFinal - use this instead of `instanceof`, as value may have been deserialized\n * @param value The value to check\n * @returns Whether the value is an EntrypointFinal\n */\nexport declare function isEntrypointFinal<ValueT, SaveT>(value: unknown): value is EntrypointFinal<ValueT, SaveT>;\n/**\n * The return type of an entrypoint function.\n */\nexport type EntrypointReturnT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, unknown> | Promise<EntrypointFinal<infer ValueT, unknown>> ? ValueT : OutputT;\n/**\n * The value to be saved when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalSaveT<OutputT> = OutputT extends EntrypointFinal<unknown, infer SaveT> | Promise<EntrypointFinal<unknown, infer SaveT>> ? SaveT : OutputT;\n/**\n * The value to be returned when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalValueT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, infer SaveT> | Promise<EntrypointFinal<infer ValueT, infer SaveT>> ? EntrypointFinal<ValueT, SaveT> : OutputT;\n/**\n * Checks if an AsyncGenerator exists in the ES target/lib that we're compiling to.\n *\n * This is necessary because `tsc --init` targets ES2016 by default, which doesn't include AsyncGenerators.\n *\n * This works because when `skipLibCheck` is true (and it is in the default `tsconfig.json` created by `tsc --init`),\n * TypeScript will replace any unresolved library types with `any`. So, when `AsyncGenerator` doesn't exist, this checks\n * if `any` extends `object`, which it doesn't. When that happens, this type resolves to the `false` literal, and we can\n * use it in the type predicates below to skip over the AsyncGenerator-specific logic.\n *\n * If we didn't have this, then the types below would be checking if the user's function extends `any` in place of the\n * `AsyncGenerator` type, and the type predicate would branch to `never`, disallowing any valid function from being passed\n * to `task` or `entrypoint`.\n */\ntype AsyncGeneratorExists = AsyncGenerator<unknown, unknown, unknown> extends object ? true : false;\n/**\n * Matches valid function signatures for entrypoints. Disallows generator functions.\n */\nexport type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist\n ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;\n/**\n * Matches valid function signatures for tasks. Disallows generator functions.\n */\nexport type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [\n never\n] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist\n ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT;\nexport {};\n"],"mappings":";;;;;;AAIA;AAA2B,KAAfC,eAAe,CAAA,MAAA,EAAA,KAAA,CAAA,GAAA;;;;EAoBfI,KAAAA,CAAAA,EAhBAH,MAgBAG;EAAiB;;;MAA6EJ,CAAAA,EAZ/FE,KAY+FF;WAARM,EAAAA,gBAAAA;;;;AAIlG;;;;;;;AAA6JD,KAJjJD,iBAIiJC,CAAAA,OAAAA,CAAAA,GAJpHA,OAIoHA,SAJpGL,eAIoGK,CAAAA,KAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAJ3DC,OAI2DD,CAJnDL,eAImDK,CAAAA,KAAAA,OAAAA,EAAAA,OAAAA,CAAAA,CAAAA,GAJTJ,MAISI,GAJAA,OAIAA;;AAI4C;AAmBzM;AAA0B,KAvBdE,oBAuBc,CAAA,OAAA,CAAA,GAvBkBF,OAuBlB,SAvBkCL,eAuBlC,CAAA,OAAA,EAAA,KAAA,MAAA,CAAA,GAvB0EM,OAuB1E,CAvBkFN,eAuBlF,CAAA,OAAA,EAAA,KAAA,MAAA,CAAA,CAAA,GAvB2HE,KAuB3H,GAvBmIG,OAuBnI;;;;;;;;;;;;;;;;;;AAK1B;KATKI,oBAAAA,GAAuBC,cASR,CAAA,OAAA,EAAA,OAAA,EAAA,OAAA,CAAA,SAAA,MAAA,GAAA,IAAA,GAAA,KAAA;;;;AAGjBL,KARSM,cAQTN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,GAAAA,CAR4CA,OAQ5CA,CAAAA,SAAAA,KAAAA,GAAAA,CAAAA,KAAAA,EAR6EO,MAQ7EP,EAAAA,MAAAA,EAR6FN,uBAQ7FM,EAAAA,GAAAA,KAAAA,GARiII,oBAQjIJ,SAAAA,IAAAA,CAAAA;AAAAA,EAPAA,OAOgBK,SAPAA,cAOAA,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAPoDL,OAOpDK,SAPoEG,SAOpEH,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,KAAAA,EAP2HE,MAO3HF,EAAAA,MAAAA,EAP2IX,uBAO3IW,EAAAA,GAPuKL,OAOvKK,GAPiLL,OAOjLK,SAPiMG,SAOjMH,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,KAAAA,EAPwPE,MAOxPF,EAAAA,MAAAA,EAPwQX,uBAOxQW,EAAAA,GAPoSL,OAOpSK;;;;AAAuIL,KAH9IS,QAG8IT,CAAAA,cAAAA,OAAAA,EAAAA,EAAAA,OAAAA,CAAAA,GAAAA,CAHhGA,OAGgGA,CAAAA,SAAAA,MAAUA,QAAgBQ,IAAAA,EADtKE,KACsKF,EAAAA,GAAAA,KAAAA,GADpJJ,oBACoJI,SAAAA,IAAAA,CAAAA;AAAAA,EAAjLR,OAA0OU,SAA1NL,cAA0NK,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAtKV,OAAsKU,SAAtJF,SAAsJE,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,GAAAA,IAAAA,EAA7FA,KAA6FA,EAAAA,GAAnFV,OAAmFU,GAAzEV,OAAyEU,SAAzDF,SAAyDE,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,GAAAA,IAAAA,EAAAA,KAAAA,EAAAA,GAAUV,OAAVU"}
|
package/dist/func/types.d.ts
CHANGED
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
import { LangGraphRunnableConfig } from "../pregel/runnable_types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/func/types.d.ts
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
6
|
* Allows the entrypoint function to return a value to the caller, as well as a separate state value to persist to the checkpoint
|
|
4
7
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
type EntrypointFinal<ValueT, SaveT> = {
|
|
9
|
+
/**
|
|
10
|
+
* The value to return to the caller
|
|
11
|
+
*/
|
|
12
|
+
value?: ValueT;
|
|
13
|
+
/**
|
|
14
|
+
* The value to save to the checkpoint
|
|
15
|
+
*/
|
|
16
|
+
save?: SaveT;
|
|
17
|
+
__lg_type: "__pregel_final";
|
|
15
18
|
};
|
|
16
19
|
/**
|
|
17
20
|
* Checks if a value is an EntrypointFinal - use this instead of `instanceof`, as value may have been deserialized
|
|
18
21
|
* @param value The value to check
|
|
19
22
|
* @returns Whether the value is an EntrypointFinal
|
|
20
23
|
*/
|
|
21
|
-
|
|
24
|
+
|
|
22
25
|
/**
|
|
23
26
|
* The return type of an entrypoint function.
|
|
24
27
|
*/
|
|
25
|
-
|
|
28
|
+
type EntrypointReturnT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, unknown> | Promise<EntrypointFinal<infer ValueT, unknown>> ? ValueT : OutputT;
|
|
26
29
|
/**
|
|
27
30
|
* The value to be saved when a function returns an EntrypointFinal.
|
|
28
31
|
*/
|
|
29
|
-
|
|
32
|
+
type EntrypointFinalSaveT<OutputT> = OutputT extends EntrypointFinal<unknown, infer SaveT> | Promise<EntrypointFinal<unknown, infer SaveT>> ? SaveT : OutputT;
|
|
30
33
|
/**
|
|
31
34
|
* The value to be returned when a function returns an EntrypointFinal.
|
|
32
35
|
*/
|
|
33
|
-
|
|
36
|
+
|
|
34
37
|
/**
|
|
35
38
|
* Checks if an AsyncGenerator exists in the ES target/lib that we're compiling to.
|
|
36
39
|
*
|
|
@@ -49,11 +52,13 @@ type AsyncGeneratorExists = AsyncGenerator<unknown, unknown, unknown> extends ob
|
|
|
49
52
|
/**
|
|
50
53
|
* Matches valid function signatures for entrypoints. Disallows generator functions.
|
|
51
54
|
*/
|
|
52
|
-
|
|
55
|
+
type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist
|
|
56
|
+
? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;
|
|
53
57
|
/**
|
|
54
58
|
* Matches valid function signatures for tasks. Disallows generator functions.
|
|
55
59
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
export {};
|
|
60
|
+
type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [never] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist
|
|
61
|
+
? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { EntrypointFinal, EntrypointFinalSaveT, EntrypointFunc, EntrypointReturnT, TaskFunc };
|
|
64
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":["LangGraphRunnableConfig","EntrypointFinal","ValueT","SaveT","isEntrypointFinal","EntrypointReturnT","OutputT","Promise","EntrypointFinalSaveT","EntrypointFinalValueT","AsyncGeneratorExists","AsyncGenerator","EntrypointFunc","InputT","Generator","TaskFunc","ArgsT"],"sources":["../../src/func/types.d.ts"],"sourcesContent":["import { LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\n/**\n * Allows the entrypoint function to return a value to the caller, as well as a separate state value to persist to the checkpoint\n */\nexport type EntrypointFinal<ValueT, SaveT> = {\n /**\n * The value to return to the caller\n */\n value?: ValueT;\n /**\n * The value to save to the checkpoint\n */\n save?: SaveT;\n __lg_type: \"__pregel_final\";\n};\n/**\n * Checks if a value is an EntrypointFinal - use this instead of `instanceof`, as value may have been deserialized\n * @param value The value to check\n * @returns Whether the value is an EntrypointFinal\n */\nexport declare function isEntrypointFinal<ValueT, SaveT>(value: unknown): value is EntrypointFinal<ValueT, SaveT>;\n/**\n * The return type of an entrypoint function.\n */\nexport type EntrypointReturnT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, unknown> | Promise<EntrypointFinal<infer ValueT, unknown>> ? ValueT : OutputT;\n/**\n * The value to be saved when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalSaveT<OutputT> = OutputT extends EntrypointFinal<unknown, infer SaveT> | Promise<EntrypointFinal<unknown, infer SaveT>> ? SaveT : OutputT;\n/**\n * The value to be returned when a function returns an EntrypointFinal.\n */\nexport type EntrypointFinalValueT<OutputT> = OutputT extends EntrypointFinal<infer ValueT, infer SaveT> | Promise<EntrypointFinal<infer ValueT, infer SaveT>> ? EntrypointFinal<ValueT, SaveT> : OutputT;\n/**\n * Checks if an AsyncGenerator exists in the ES target/lib that we're compiling to.\n *\n * This is necessary because `tsc --init` targets ES2016 by default, which doesn't include AsyncGenerators.\n *\n * This works because when `skipLibCheck` is true (and it is in the default `tsconfig.json` created by `tsc --init`),\n * TypeScript will replace any unresolved library types with `any`. So, when `AsyncGenerator` doesn't exist, this checks\n * if `any` extends `object`, which it doesn't. When that happens, this type resolves to the `false` literal, and we can\n * use it in the type predicates below to skip over the AsyncGenerator-specific logic.\n *\n * If we didn't have this, then the types below would be checking if the user's function extends `any` in place of the\n * `AsyncGenerator` type, and the type predicate would branch to `never`, disallowing any valid function from being passed\n * to `task` or `entrypoint`.\n */\ntype AsyncGeneratorExists = AsyncGenerator<unknown, unknown, unknown> extends object ? true : false;\n/**\n * Matches valid function signatures for entrypoints. Disallows generator functions.\n */\nexport type EntrypointFunc<InputT, OutputT> = [OutputT] extends never ? (input: InputT, config: LangGraphRunnableConfig) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist\n ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (input: InputT, config: LangGraphRunnableConfig) => OutputT;\n/**\n * Matches valid function signatures for tasks. Disallows generator functions.\n */\nexport type TaskFunc<ArgsT extends unknown[], OutputT> = [OutputT] extends [\n never\n] ? (...args: ArgsT) => never : AsyncGeneratorExists extends true // only check if it may be an AsyncGenerator when those actually exist\n ? OutputT extends AsyncGenerator<unknown, unknown, unknown> ? never : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT : OutputT extends Generator<unknown, unknown, unknown> ? never : (...args: ArgsT) => OutputT;\nexport {};\n"],"mappings":";;;;;;AAIA;AAA2B,KAAfC,eAAe,CAAA,MAAA,EAAA,KAAA,CAAA,GAAA;;;;EAoBfI,KAAAA,CAAAA,EAhBAH,MAgBAG;EAAiB;;;MAA6EJ,CAAAA,EAZ/FE,KAY+FF;WAARM,EAAAA,gBAAAA;;;;AAIlG;;;;;;;AAA6JD,KAJjJD,iBAIiJC,CAAAA,OAAAA,CAAAA,GAJpHA,OAIoHA,SAJpGL,eAIoGK,CAAAA,KAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAJ3DC,OAI2DD,CAJnDL,eAImDK,CAAAA,KAAAA,OAAAA,EAAAA,OAAAA,CAAAA,CAAAA,GAJTJ,MAISI,GAJAA,OAIAA;;AAI4C;AAmBzM;AAA0B,KAvBdE,oBAuBc,CAAA,OAAA,CAAA,GAvBkBF,OAuBlB,SAvBkCL,eAuBlC,CAAA,OAAA,EAAA,KAAA,MAAA,CAAA,GAvB0EM,OAuB1E,CAvBkFN,eAuBlF,CAAA,OAAA,EAAA,KAAA,MAAA,CAAA,CAAA,GAvB2HE,KAuB3H,GAvBmIG,OAuBnI;;;;;;;;;;;;;;;;;;AAK1B;KATKI,oBAAAA,GAAuBC,cASR,CAAA,OAAA,EAAA,OAAA,EAAA,OAAA,CAAA,SAAA,MAAA,GAAA,IAAA,GAAA,KAAA;;;;AAGjBL,KARSM,cAQTN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,GAAAA,CAR4CA,OAQ5CA,CAAAA,SAAAA,KAAAA,GAAAA,CAAAA,KAAAA,EAR6EO,MAQ7EP,EAAAA,MAAAA,EAR6FN,uBAQ7FM,EAAAA,GAAAA,KAAAA,GARiII,oBAQjIJ,SAAAA,IAAAA,CAAAA;AAAAA,EAPAA,OAOgBK,SAPAA,cAOAA,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAPoDL,OAOpDK,SAPoEG,SAOpEH,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,KAAAA,EAP2HE,MAO3HF,EAAAA,MAAAA,EAP2IX,uBAO3IW,EAAAA,GAPuKL,OAOvKK,GAPiLL,OAOjLK,SAPiMG,SAOjMH,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,KAAAA,EAPwPE,MAOxPF,EAAAA,MAAAA,EAPwQX,uBAOxQW,EAAAA,GAPoSL,OAOpSK;;;;AAAuIL,KAH9IS,QAG8IT,CAAAA,cAAAA,OAAAA,EAAAA,EAAAA,OAAAA,CAAAA,GAAAA,CAHhGA,OAGgGA,CAAAA,SAAAA,MAAUA,QAAgBQ,IAAAA,EADtKE,KACsKF,EAAAA,GAAAA,KAAAA,GADpJJ,oBACoJI,SAAAA,IAAAA,CAAAA;AAAAA,EAAjLR,OAA0OU,SAA1NL,cAA0NK,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAtKV,OAAsKU,SAAtJF,SAAsJE,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,GAAAA,IAAAA,EAA7FA,KAA6FA,EAAAA,GAAnFV,OAAmFU,GAAzEV,OAAyEU,SAAzDF,SAAyDE,CAAAA,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAAAA,KAAAA,GAAAA,CAAAA,GAAAA,IAAAA,EAAAA,KAAAA,EAAAA,GAAUV,OAAVU"}
|
|
@@ -1,125 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const binop_js_1 = require("../channels/binop.cjs");
|
|
6
|
-
const last_value_js_1 = require("../channels/last_value.cjs");
|
|
1
|
+
const require_binop = require('../channels/binop.cjs');
|
|
2
|
+
const require_last_value = require('../channels/last_value.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/graph/annotation.ts
|
|
7
5
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(this, "spec", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
configurable: true,
|
|
21
|
-
writable: true,
|
|
22
|
-
value: void 0
|
|
23
|
-
});
|
|
24
|
-
this.spec = s;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.AnnotationRoot = AnnotationRoot;
|
|
6
|
+
* Should not be instantiated directly. See {@link Annotation}.
|
|
7
|
+
*/
|
|
8
|
+
var AnnotationRoot = class {
|
|
9
|
+
lc_graph_name = "AnnotationRoot";
|
|
10
|
+
spec;
|
|
11
|
+
constructor(s) {
|
|
12
|
+
this.spec = s;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
28
15
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
else {
|
|
104
|
-
// @ts-expect-error - Annotation without reducer
|
|
105
|
-
return new last_value_js_1.LastValue();
|
|
106
|
-
}
|
|
16
|
+
* Helper that instantiates channels within a StateGraph state.
|
|
17
|
+
*
|
|
18
|
+
* Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:
|
|
19
|
+
* 1. **Directly**: Creates a channel that stores the most recent value returned from a node.
|
|
20
|
+
* 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { StateGraph, Annotation } from "@langchain/langgraph";
|
|
25
|
+
*
|
|
26
|
+
* // Define a state with a single string key named "currentOutput"
|
|
27
|
+
* const SimpleAnnotation = Annotation.Root({
|
|
28
|
+
* currentOutput: Annotation<string>,
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* const graphBuilder = new StateGraph(SimpleAnnotation);
|
|
32
|
+
*
|
|
33
|
+
* // A node in the graph that returns an object with a "currentOutput" key
|
|
34
|
+
* // replaces the value in the state. You can get the state type as shown below:
|
|
35
|
+
* const myNode = (state: typeof SimpleAnnotation.State) => {
|
|
36
|
+
* return {
|
|
37
|
+
* currentOutput: "some_new_value",
|
|
38
|
+
* };
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* const graph = graphBuilder
|
|
42
|
+
* .addNode("myNode", myNode)
|
|
43
|
+
* ...
|
|
44
|
+
* .compile();
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { type BaseMessage, AIMessage } from "@langchain/core/messages";
|
|
50
|
+
* import { StateGraph, Annotation } from "@langchain/langgraph";
|
|
51
|
+
*
|
|
52
|
+
* // Define a state with a single key named "messages" that will
|
|
53
|
+
* // combine a returned BaseMessage or arrays of BaseMessages
|
|
54
|
+
* const AnnotationWithReducer = Annotation.Root({
|
|
55
|
+
* messages: Annotation<BaseMessage[]>({
|
|
56
|
+
* // Different types are allowed for updates
|
|
57
|
+
* reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {
|
|
58
|
+
* if (Array.isArray(right)) {
|
|
59
|
+
* return left.concat(right);
|
|
60
|
+
* }
|
|
61
|
+
* return left.concat([right]);
|
|
62
|
+
* },
|
|
63
|
+
* default: () => [],
|
|
64
|
+
* }),
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* const graphBuilder = new StateGraph(AnnotationWithReducer);
|
|
68
|
+
*
|
|
69
|
+
* // A node in the graph that returns an object with a "messages" key
|
|
70
|
+
* // will update the state by combining the existing value with the returned one.
|
|
71
|
+
* const myNode = (state: typeof AnnotationWithReducer.State) => {
|
|
72
|
+
* return {
|
|
73
|
+
* messages: [new AIMessage("Some new response")],
|
|
74
|
+
* };
|
|
75
|
+
* };
|
|
76
|
+
*
|
|
77
|
+
* const graph = graphBuilder
|
|
78
|
+
* .addNode("myNode", myNode)
|
|
79
|
+
* ...
|
|
80
|
+
* .compile();
|
|
81
|
+
* ```
|
|
82
|
+
* @namespace
|
|
83
|
+
* @property Root
|
|
84
|
+
* Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.
|
|
85
|
+
*/
|
|
86
|
+
const Annotation = function(annotation) {
|
|
87
|
+
if (annotation) return getChannel(annotation);
|
|
88
|
+
else return new require_last_value.LastValue();
|
|
107
89
|
};
|
|
108
|
-
|
|
90
|
+
Annotation.Root = (sd) => new AnnotationRoot(sd);
|
|
109
91
|
function getChannel(reducer) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
reducer.reducer) {
|
|
114
|
-
return new binop_js_1.BinaryOperatorAggregate(reducer.reducer, reducer.default);
|
|
115
|
-
}
|
|
116
|
-
if (typeof reducer === "object" &&
|
|
117
|
-
reducer &&
|
|
118
|
-
"value" in reducer &&
|
|
119
|
-
reducer.value) {
|
|
120
|
-
return new binop_js_1.BinaryOperatorAggregate(reducer.value, reducer.default);
|
|
121
|
-
}
|
|
122
|
-
// @ts-expect-error - Annotation without reducer
|
|
123
|
-
return new last_value_js_1.LastValue();
|
|
92
|
+
if (typeof reducer === "object" && reducer && "reducer" in reducer && reducer.reducer) return new require_binop.BinaryOperatorAggregate(reducer.reducer, reducer.default);
|
|
93
|
+
if (typeof reducer === "object" && reducer && "value" in reducer && reducer.value) return new require_binop.BinaryOperatorAggregate(reducer.value, reducer.default);
|
|
94
|
+
return new require_last_value.LastValue();
|
|
124
95
|
}
|
|
125
|
-
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
exports.Annotation = Annotation;
|
|
99
|
+
exports.AnnotationRoot = AnnotationRoot;
|
|
100
|
+
exports.getChannel = getChannel;
|
|
101
|
+
//# sourceMappingURL=annotation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation.cjs","names":["Annotation: AnnotationFunction","LastValue","BinaryOperatorAggregate"],"sources":["../../src/graph/annotation.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\n\nexport type SingleReducer<ValueType, UpdateType = ValueType> =\n | {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | null;\n\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\n\ntype ExtractValueType<C> = C extends BaseChannel\n ? C[\"ValueType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"ValueType\"]\n : never;\n\ntype ExtractUpdateType<C> = C extends BaseChannel\n ? C[\"UpdateType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"UpdateType\"]\n : never;\n\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\n\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\n\nexport type NodeType<SD extends StateDefinition> = RunnableLike<\n StateType<SD>,\n UpdateType<SD> | Partial<StateType<SD>>\n>;\n\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(\n annotation: SingleReducer<ValueType, UpdateType>\n ): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name = \"AnnotationRoot\";\n\n declare State: StateType<SD>;\n\n declare Update: UpdateType<SD>;\n\n declare Node: NodeType<SD>;\n\n spec: SD;\n\n constructor(s: SD) {\n this.spec = s;\n }\n}\n\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport const Annotation: AnnotationFunction = function <\n ValueType,\n UpdateType = ValueType\n>(\n annotation?: SingleReducer<ValueType, UpdateType>\n): BaseChannel<ValueType, UpdateType> {\n if (annotation) {\n return getChannel<ValueType, UpdateType>(annotation);\n } else {\n // @ts-expect-error - Annotation without reducer\n return new LastValue<ValueType>();\n }\n} as AnnotationFunction;\n\nAnnotation.Root = <S extends StateDefinition>(sd: S) => new AnnotationRoot(sd);\n\nexport function getChannel<V, U = V>(\n reducer: SingleReducer<V, U>\n): BaseChannel<V, U> {\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"reducer\" in reducer &&\n reducer.reducer\n ) {\n return new BinaryOperatorAggregate(reducer.reducer, reducer.default);\n }\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"value\" in reducer &&\n reducer.value\n ) {\n return new BinaryOperatorAggregate(reducer.value, reducer.default);\n }\n // @ts-expect-error - Annotation without reducer\n return new LastValue<V>();\n}\n"],"mappings":";;;;;;;AA4DA,IAAa,iBAAb,MAAwD;CACtD,gBAAgB;CAQhB;CAEA,YAAY,GAAO;AACjB,OAAK,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EhB,MAAaA,aAAiC,SAI5C,YACoC;AACpC,KAAI,WACF,QAAO,WAAkC;KAGzC,QAAO,IAAIC;;AAIf,WAAW,QAAmC,OAAU,IAAI,eAAe;AAE3E,SAAgB,WACd,SACmB;AACnB,KACE,OAAO,YAAY,YACnB,WACA,aAAa,WACb,QAAQ,QAER,QAAO,IAAIC,sCAAwB,QAAQ,SAAS,QAAQ;AAE9D,KACE,OAAO,YAAY,YACnB,WACA,WAAW,WACX,QAAQ,MAER,QAAO,IAAIA,sCAAwB,QAAQ,OAAO,QAAQ;AAG5D,QAAO,IAAID"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { BaseChannel } from "../channels/base.cjs";
|
|
2
|
+
import { RunnableLike } from "../pregel/runnable_types.cjs";
|
|
3
|
+
import { BinaryOperator, BinaryOperatorAggregate } from "../channels/binop.cjs";
|
|
4
|
+
import { LastValue } from "../channels/last_value.cjs";
|
|
5
|
+
|
|
6
|
+
//#region src/graph/annotation.d.ts
|
|
7
|
+
type SingleReducer<ValueType, UpdateType = ValueType> = {
|
|
8
|
+
reducer: BinaryOperator<ValueType, UpdateType>;
|
|
9
|
+
default?: () => ValueType;
|
|
10
|
+
} | {
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `reducer` instead
|
|
13
|
+
*/
|
|
14
|
+
value: BinaryOperator<ValueType, UpdateType>;
|
|
15
|
+
default?: () => ValueType;
|
|
16
|
+
} | null;
|
|
17
|
+
interface StateDefinition {
|
|
18
|
+
[key: string]: BaseChannel | (() => BaseChannel);
|
|
19
|
+
}
|
|
20
|
+
type ExtractValueType<C> = C extends BaseChannel ? C["ValueType"] : C extends (() => BaseChannel) ? ReturnType<C>["ValueType"] : never;
|
|
21
|
+
type ExtractUpdateType<C> = C extends BaseChannel ? C["UpdateType"] : C extends (() => BaseChannel) ? ReturnType<C>["UpdateType"] : never;
|
|
22
|
+
type StateType<SD extends StateDefinition> = { [key in keyof SD]: ExtractValueType<SD[key]> };
|
|
23
|
+
type UpdateType<SD extends StateDefinition> = { [key in keyof SD]?: ExtractUpdateType<SD[key]> };
|
|
24
|
+
type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;
|
|
25
|
+
/** @ignore */
|
|
26
|
+
interface AnnotationFunction {
|
|
27
|
+
<ValueType>(): LastValue<ValueType>;
|
|
28
|
+
<ValueType, UpdateType = ValueType>(annotation: SingleReducer<ValueType, UpdateType>): BinaryOperatorAggregate<ValueType, UpdateType>;
|
|
29
|
+
Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Should not be instantiated directly. See {@link Annotation}.
|
|
33
|
+
*/
|
|
34
|
+
declare class AnnotationRoot<SD extends StateDefinition> {
|
|
35
|
+
lc_graph_name: string;
|
|
36
|
+
State: StateType<SD>;
|
|
37
|
+
Update: UpdateType<SD>;
|
|
38
|
+
Node: NodeType<SD>;
|
|
39
|
+
spec: SD;
|
|
40
|
+
constructor(s: SD);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Helper that instantiates channels within a StateGraph state.
|
|
44
|
+
*
|
|
45
|
+
* Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:
|
|
46
|
+
* 1. **Directly**: Creates a channel that stores the most recent value returned from a node.
|
|
47
|
+
* 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { StateGraph, Annotation } from "@langchain/langgraph";
|
|
52
|
+
*
|
|
53
|
+
* // Define a state with a single string key named "currentOutput"
|
|
54
|
+
* const SimpleAnnotation = Annotation.Root({
|
|
55
|
+
* currentOutput: Annotation<string>,
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* const graphBuilder = new StateGraph(SimpleAnnotation);
|
|
59
|
+
*
|
|
60
|
+
* // A node in the graph that returns an object with a "currentOutput" key
|
|
61
|
+
* // replaces the value in the state. You can get the state type as shown below:
|
|
62
|
+
* const myNode = (state: typeof SimpleAnnotation.State) => {
|
|
63
|
+
* return {
|
|
64
|
+
* currentOutput: "some_new_value",
|
|
65
|
+
* };
|
|
66
|
+
* }
|
|
67
|
+
*
|
|
68
|
+
* const graph = graphBuilder
|
|
69
|
+
* .addNode("myNode", myNode)
|
|
70
|
+
* ...
|
|
71
|
+
* .compile();
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { type BaseMessage, AIMessage } from "@langchain/core/messages";
|
|
77
|
+
* import { StateGraph, Annotation } from "@langchain/langgraph";
|
|
78
|
+
*
|
|
79
|
+
* // Define a state with a single key named "messages" that will
|
|
80
|
+
* // combine a returned BaseMessage or arrays of BaseMessages
|
|
81
|
+
* const AnnotationWithReducer = Annotation.Root({
|
|
82
|
+
* messages: Annotation<BaseMessage[]>({
|
|
83
|
+
* // Different types are allowed for updates
|
|
84
|
+
* reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {
|
|
85
|
+
* if (Array.isArray(right)) {
|
|
86
|
+
* return left.concat(right);
|
|
87
|
+
* }
|
|
88
|
+
* return left.concat([right]);
|
|
89
|
+
* },
|
|
90
|
+
* default: () => [],
|
|
91
|
+
* }),
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* const graphBuilder = new StateGraph(AnnotationWithReducer);
|
|
95
|
+
*
|
|
96
|
+
* // A node in the graph that returns an object with a "messages" key
|
|
97
|
+
* // will update the state by combining the existing value with the returned one.
|
|
98
|
+
* const myNode = (state: typeof AnnotationWithReducer.State) => {
|
|
99
|
+
* return {
|
|
100
|
+
* messages: [new AIMessage("Some new response")],
|
|
101
|
+
* };
|
|
102
|
+
* };
|
|
103
|
+
*
|
|
104
|
+
* const graph = graphBuilder
|
|
105
|
+
* .addNode("myNode", myNode)
|
|
106
|
+
* ...
|
|
107
|
+
* .compile();
|
|
108
|
+
* ```
|
|
109
|
+
* @namespace
|
|
110
|
+
* @property Root
|
|
111
|
+
* Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.
|
|
112
|
+
*/
|
|
113
|
+
declare const Annotation: AnnotationFunction;
|
|
114
|
+
//#endregion
|
|
115
|
+
export { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType };
|
|
116
|
+
//# sourceMappingURL=annotation.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation.d.cts","names":["RunnableLike","BaseChannel","BinaryOperator","BinaryOperatorAggregate","LastValue","SingleReducer","ValueType","UpdateType","StateDefinition","ExtractValueType","C","ReturnType","ExtractUpdateType","StateType","SD","key","NodeType","Partial","AnnotationFunction","S","AnnotationRoot","Annotation","getChannel","V","U"],"sources":["../../src/graph/annotation.d.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nexport type SingleReducer<ValueType, UpdateType = ValueType> = {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | null;\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\ntype ExtractValueType<C> = C extends BaseChannel ? C[\"ValueType\"] : C extends () => BaseChannel ? ReturnType<C>[\"ValueType\"] : never;\ntype ExtractUpdateType<C> = C extends BaseChannel ? C[\"UpdateType\"] : C extends () => BaseChannel ? ReturnType<C>[\"UpdateType\"] : never;\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\nexport type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(annotation: SingleReducer<ValueType, UpdateType>): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport declare class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name: string;\n State: StateType<SD>;\n Update: UpdateType<SD>;\n Node: NodeType<SD>;\n spec: SD;\n constructor(s: SD);\n}\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport declare const Annotation: AnnotationFunction;\nexport declare function getChannel<V, U = V>(reducer: SingleReducer<V, U>): BaseChannel<V, U>;\nexport {};\n"],"mappings":";;;;;;KAIYK,sCAAsCC;WACrCJ,eAAeI,WAAWC;EAD3BF,OAAAA,CAAAA,EAAAA,GAAAA,GAEQC,SAFK;CAAA,GAAA;;;;OACZJ,EAMFA,cANEA,CAMaI,SANbJ,EAMwBK,UANxBL,CAAAA;SACOI,CAAAA,EAAAA,GAAAA,GAMAA,SANAA;QAKMA;AAAWC,UAGpBC,eAAAA,CAHoBD;MAA1BL,EAAAA,MAAAA,CAAAA,EAIQD,WAJRC,GAAAA,CAAAA,GAAAA,GAI6BD,WAJ7BC,CAAAA;;KAMNO,sBAAsBC,UAAUT,cAAcS,iBAAiBA,iBAAgBT,eAAcU,WAAWD;AAH7G,KAIKE,iBAJ2B,CAAA,CAAA,CAAA,GAIJF,CAJI,SAIMT,WAJN,GAIoBS,CAJpB,CAAA,YAAA,CAAA,GAIsCA,CAJtC,UAAA,GAAA,GAIsDT,WAJtD,IAIoEU,UAJpE,CAI+ED,CAJ/E,CAAA,CAAA,YAAA,CAAA,GAAA,KAAA;AAAA,KAKpBG,SALoB,CAAA,WAKCL,eALD,CAAA,GAAA,UACbP,MAKDa,EALCb,GAKIQ,gBALJR,CAKqBa,EALrBb,CAKwBc,GALxBd,CAAAA,CAAAA;KAOPM,sBAAsBC,6BAL7BC,MAMaK,EANbL,IAMmBG,iBANH,CAMqBE,EANrB,CAMwBC,GANxB,CAAA,CAAA,EAAA;AAAML,KAQfM,QAReN,CAAAA,WAQKF,eARLE,CAAAA,GAQwBV,YARxBU,CAQqCG,SARrCH,CAQ+CI,EAR/CJ,CAAAA,EAQoDH,UARpDG,CAQ+DI,EAR/DJ,CAAAA,GAQqEO,OARrEP,CAQ6EG,SAR7EH,CAQuFI,EARvFJ,CAAAA,CAAAA,CAAAA;;AAAwBA,UAUlCQ,kBAAAA,CAVkCR;YAAiBA,CAAAA,EAAAA,EAWjDN,SAXiDM,CAWvCJ,SAXuCI,CAAAA;YAAgBT,EAAAA,aAYvDK,SAZuDL,CAAAA,CAAAA,UAAAA,EAYhCI,aAZgCJ,CAYlBK,SAZkBL,EAYPM,UAZON,CAAAA,CAAAA,EAYOE,uBAZPF,CAY+BK,SAZ/BL,EAY0CM,UAZ1CN,CAAAA;MAAyBS,EAAAA,CAAAA,UAaxFF,eAbwFE,CAAAA,CAAAA,EAAAA,EAanES,CAbmET,EAAAA,GAa7DU,cAb6DV,CAa9CS,CAb8CT,CAAAA;;;AAAD;;AAChFA,cAiBPU,cAjBOV,CAAAA,WAiBmBF,eAjBnBE,CAAAA,CAAAA;eAAUT,EAAAA,MAAAA;OAAcS,EAmBzCG,SAnByCH,CAmB/BI,EAnB+BJ,CAAAA;QAAkBA,EAoB1DH,UApB0DG,CAoB/CI,EApB+CJ,CAAAA;MAAgBT,EAqB5Ee,QArB4Ef,CAqBnEa,EArBmEb,CAAAA;MAAyBS,EAsBrGI,EAtBqGJ;aAAXC,CAAAA,CAAAA,EAuBjFG,EAvBiFH;;AACpG;;;;;;;;AAGA;;;;;;;;AAGA;;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;AA+EA;;;;;;;;;;;;;;;cAAqBU,YAAYH"}
|
|
@@ -1,45 +1,43 @@
|
|
|
1
|
-
import { RunnableLike } from "../pregel/runnable_types.js";
|
|
2
1
|
import { BaseChannel } from "../channels/base.js";
|
|
2
|
+
import { RunnableLike } from "../pregel/runnable_types.js";
|
|
3
3
|
import { BinaryOperator, BinaryOperatorAggregate } from "../channels/binop.js";
|
|
4
4
|
import { LastValue } from "../channels/last_value.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
|
|
6
|
+
//#region src/graph/annotation.d.ts
|
|
7
|
+
type SingleReducer<ValueType, UpdateType = ValueType> = {
|
|
8
|
+
reducer: BinaryOperator<ValueType, UpdateType>;
|
|
9
|
+
default?: () => ValueType;
|
|
8
10
|
} | {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `reducer` instead
|
|
13
|
+
*/
|
|
14
|
+
value: BinaryOperator<ValueType, UpdateType>;
|
|
15
|
+
default?: () => ValueType;
|
|
14
16
|
} | null;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
interface StateDefinition {
|
|
18
|
+
[key: string]: BaseChannel | (() => BaseChannel);
|
|
17
19
|
}
|
|
18
|
-
type ExtractValueType<C> = C extends BaseChannel ? C["ValueType"] : C extends () => BaseChannel ? ReturnType<C>["ValueType"] : never;
|
|
19
|
-
type ExtractUpdateType<C> = C extends BaseChannel ? C["UpdateType"] : C extends () => BaseChannel ? ReturnType<C>["UpdateType"] : never;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export type UpdateType<SD extends StateDefinition> = {
|
|
24
|
-
[key in keyof SD]?: ExtractUpdateType<SD[key]>;
|
|
25
|
-
};
|
|
26
|
-
export type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;
|
|
20
|
+
type ExtractValueType<C> = C extends BaseChannel ? C["ValueType"] : C extends (() => BaseChannel) ? ReturnType<C>["ValueType"] : never;
|
|
21
|
+
type ExtractUpdateType<C> = C extends BaseChannel ? C["UpdateType"] : C extends (() => BaseChannel) ? ReturnType<C>["UpdateType"] : never;
|
|
22
|
+
type StateType<SD extends StateDefinition> = { [key in keyof SD]: ExtractValueType<SD[key]> };
|
|
23
|
+
type UpdateType<SD extends StateDefinition> = { [key in keyof SD]?: ExtractUpdateType<SD[key]> };
|
|
24
|
+
type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;
|
|
27
25
|
/** @ignore */
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
interface AnnotationFunction {
|
|
27
|
+
<ValueType>(): LastValue<ValueType>;
|
|
28
|
+
<ValueType, UpdateType = ValueType>(annotation: SingleReducer<ValueType, UpdateType>): BinaryOperatorAggregate<ValueType, UpdateType>;
|
|
29
|
+
Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;
|
|
32
30
|
}
|
|
33
31
|
/**
|
|
34
32
|
* Should not be instantiated directly. See {@link Annotation}.
|
|
35
33
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
declare class AnnotationRoot<SD extends StateDefinition> {
|
|
35
|
+
lc_graph_name: string;
|
|
36
|
+
State: StateType<SD>;
|
|
37
|
+
Update: UpdateType<SD>;
|
|
38
|
+
Node: NodeType<SD>;
|
|
39
|
+
spec: SD;
|
|
40
|
+
constructor(s: SD);
|
|
43
41
|
}
|
|
44
42
|
/**
|
|
45
43
|
* Helper that instantiates channels within a StateGraph state.
|
|
@@ -112,6 +110,7 @@ export declare class AnnotationRoot<SD extends StateDefinition> {
|
|
|
112
110
|
* @property Root
|
|
113
111
|
* Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.
|
|
114
112
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
export {};
|
|
113
|
+
declare const Annotation: AnnotationFunction;
|
|
114
|
+
//#endregion
|
|
115
|
+
export { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType };
|
|
116
|
+
//# sourceMappingURL=annotation.d.ts.map
|