@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,289 @@
|
|
|
1
|
+
import { LastValue } from "../channels/last_value.cjs";
|
|
2
|
+
import { CachePolicy, RetryPolicy } from "../pregel/utils/index.cjs";
|
|
3
|
+
import { PregelNode } from "../pregel/read.cjs";
|
|
4
|
+
import { END, PREVIOUS, START } from "../constants.cjs";
|
|
5
|
+
import { Pregel } from "../pregel/index.cjs";
|
|
6
|
+
import { EphemeralValue } from "../channels/ephemeral_value.cjs";
|
|
7
|
+
import { EntrypointFinal, EntrypointFinalSaveT, EntrypointFunc, EntrypointReturnT, TaskFunc } from "./types.cjs";
|
|
8
|
+
import { BaseCache, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
9
|
+
|
|
10
|
+
//#region src/func/index.d.ts
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Options for the {@link task} function
|
|
14
|
+
*/
|
|
15
|
+
interface TaskOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The name of the task, analogous to the node name in {@link StateGraph}.
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
/**
|
|
21
|
+
* The retry policy for the task. Configures how many times and under what conditions
|
|
22
|
+
* the task should be retried if it fails.
|
|
23
|
+
*/
|
|
24
|
+
retry?: RetryPolicy;
|
|
25
|
+
/**
|
|
26
|
+
* The cache policy for the task. Configures how the task should be cached.
|
|
27
|
+
*/
|
|
28
|
+
cachePolicy?: CachePolicy;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Define a LangGraph task using the `task` function.
|
|
32
|
+
*
|
|
33
|
+
* Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.
|
|
34
|
+
* A task can be called like a regular function with the following differences:
|
|
35
|
+
*
|
|
36
|
+
* - When a checkpointer is enabled, the function inputs and outputs must be serializable.
|
|
37
|
+
* - The wrapped function can only be called from within an entrypoint or StateGraph.
|
|
38
|
+
* - Calling the function produces a promise. This makes it easy to parallelize tasks.
|
|
39
|
+
*
|
|
40
|
+
* @typeParam ArgsT - The type of arguments the task function accepts
|
|
41
|
+
* @typeParam OutputT - The type of value the task function returns
|
|
42
|
+
* @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task
|
|
43
|
+
* @param func - The function that executes this task
|
|
44
|
+
* @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise
|
|
45
|
+
*
|
|
46
|
+
* @example basic example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const addOne = task("add", async (a: number) => a + 1);
|
|
49
|
+
*
|
|
50
|
+
* const workflow = entrypoint("example", async (numbers: number[]) => {
|
|
51
|
+
* const promises = numbers.map(n => addOne(n));
|
|
52
|
+
* const results = await Promise.all(promises);
|
|
53
|
+
* return results;
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // Call the entrypoint
|
|
57
|
+
* await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example using a retry policy
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const addOne = task({
|
|
63
|
+
* name: "add",
|
|
64
|
+
* retry: { maxAttempts: 3 }
|
|
65
|
+
* },
|
|
66
|
+
* async (a: number) => a + 1
|
|
67
|
+
* );
|
|
68
|
+
*
|
|
69
|
+
* const workflow = entrypoint("example", async (numbers: number[]) => {
|
|
70
|
+
* const promises = numbers.map(n => addOne(n));
|
|
71
|
+
* const results = await Promise.all(promises);
|
|
72
|
+
* return results;
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function task<ArgsT extends unknown[], OutputT>(optionsOrName: TaskOptions | string, func: TaskFunc<ArgsT, OutputT>): (...args: ArgsT) => Promise<OutputT>;
|
|
77
|
+
/**
|
|
78
|
+
* Options for the {@link entrypoint} function
|
|
79
|
+
*/
|
|
80
|
+
type EntrypointOptions = {
|
|
81
|
+
/**
|
|
82
|
+
* The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.
|
|
83
|
+
* This name is used for logging, debugging, and checkpoint identification.
|
|
84
|
+
*/
|
|
85
|
+
name: string;
|
|
86
|
+
/**
|
|
87
|
+
* The checkpointer for the {@link entrypoint}. Used to save and restore state between
|
|
88
|
+
* invocations of the workflow.
|
|
89
|
+
*/
|
|
90
|
+
checkpointer?: BaseCheckpointSaver;
|
|
91
|
+
/**
|
|
92
|
+
* The store for the {@link entrypoint}. Used to persist data across workflow runs.
|
|
93
|
+
*/
|
|
94
|
+
store?: BaseStore;
|
|
95
|
+
/**
|
|
96
|
+
* The cache for the {@link entrypoint}. Used to cache values between workflow runs.
|
|
97
|
+
*/
|
|
98
|
+
cache?: BaseCache;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Type declaration for the entrypoint function with its properties
|
|
102
|
+
*/
|
|
103
|
+
interface EntrypointFunction {
|
|
104
|
+
<InputT, OutputT>(optionsOrName: EntrypointOptions | string, func: EntrypointFunc<InputT, OutputT>): Pregel<Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, {
|
|
105
|
+
[START]: EphemeralValue<InputT>;
|
|
106
|
+
[END]: LastValue<EntrypointReturnT<OutputT>>;
|
|
107
|
+
[PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;
|
|
108
|
+
}, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>,
|
|
109
|
+
// Because the update type is an return type union of tasks + entrypoint,
|
|
110
|
+
// thus we can't type it properly.
|
|
111
|
+
any,
|
|
112
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
113
|
+
Awaited<EntrypointReturnT<OutputT>>>;
|
|
114
|
+
/**
|
|
115
|
+
* A helper utility for use with the functional API that returns a value to the caller,
|
|
116
|
+
* as well as a separate state value to persist to the checkpoint. This allows workflows
|
|
117
|
+
* to maintain state between runs while returning different values to the caller.
|
|
118
|
+
*
|
|
119
|
+
* @typeParam ValueT - The type of the value to return to the caller
|
|
120
|
+
* @typeParam SaveT - The type of the state to save to the checkpoint
|
|
121
|
+
* @param value - The value to return to the caller
|
|
122
|
+
* @param save - The value to save to the checkpoint
|
|
123
|
+
* @returns An object with the value and save properties
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* return entrypoint.final({
|
|
128
|
+
* value: "result for caller",
|
|
129
|
+
* save: { counter: currentCount + 1 }
|
|
130
|
+
* });
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
final<ValueT, SaveT>(options: {
|
|
134
|
+
value?: ValueT;
|
|
135
|
+
save?: SaveT;
|
|
136
|
+
}): EntrypointFinal<ValueT, SaveT>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Define a LangGraph workflow using the `entrypoint` function.
|
|
140
|
+
*
|
|
141
|
+
* ### Function signature
|
|
142
|
+
*
|
|
143
|
+
* The wrapped function must accept at most **two parameters**. The first parameter
|
|
144
|
+
* is the input to the function. The second (optional) parameter is a
|
|
145
|
+
* {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to
|
|
146
|
+
* the function, you can pass them as an object.
|
|
147
|
+
*
|
|
148
|
+
* ### Helper functions
|
|
149
|
+
*
|
|
150
|
+
* #### Streaming
|
|
151
|
+
* To write data to the "custom" stream, use the {@link getWriter} function, or the
|
|
152
|
+
* {@link LangGraphRunnableConfig.writer} property.
|
|
153
|
+
*
|
|
154
|
+
* #### State management
|
|
155
|
+
* The {@link getPreviousState} function can be used to access the previous state
|
|
156
|
+
* that was returned from the last invocation of the entrypoint on the same thread id.
|
|
157
|
+
*
|
|
158
|
+
* If you wish to save state other than the return value, you can use the
|
|
159
|
+
* {@link entrypoint.final} function.
|
|
160
|
+
*
|
|
161
|
+
* @typeParam InputT - The type of input the entrypoint accepts
|
|
162
|
+
* @typeParam OutputT - The type of output the entrypoint produces
|
|
163
|
+
* @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint
|
|
164
|
+
* @param func - The function that executes this entrypoint
|
|
165
|
+
* @returns A {@link Pregel} instance that can be run to execute the workflow
|
|
166
|
+
*
|
|
167
|
+
* @example Using entrypoint and tasks
|
|
168
|
+
* ```typescript
|
|
169
|
+
* import { task, entrypoint } from "@langchain/langgraph";
|
|
170
|
+
* import { MemorySaver } from "@langchain/langgraph-checkpoint";
|
|
171
|
+
* import { interrupt, Command } from "@langchain/langgraph";
|
|
172
|
+
*
|
|
173
|
+
* const composeEssay = task("compose", async (topic: string) => {
|
|
174
|
+
* await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation
|
|
175
|
+
* return `An essay about ${topic}`;
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* const reviewWorkflow = entrypoint({
|
|
179
|
+
* name: "review",
|
|
180
|
+
* checkpointer: new MemorySaver()
|
|
181
|
+
* }, async (topic: string) => {
|
|
182
|
+
* const essay = await composeEssay(topic);
|
|
183
|
+
* const humanReview = await interrupt({
|
|
184
|
+
* question: "Please provide a review",
|
|
185
|
+
* essay
|
|
186
|
+
* });
|
|
187
|
+
* return {
|
|
188
|
+
* essay,
|
|
189
|
+
* review: humanReview
|
|
190
|
+
* };
|
|
191
|
+
* });
|
|
192
|
+
*
|
|
193
|
+
* // Example configuration for the workflow
|
|
194
|
+
* const config = {
|
|
195
|
+
* configurable: {
|
|
196
|
+
* thread_id: "some_thread"
|
|
197
|
+
* }
|
|
198
|
+
* };
|
|
199
|
+
*
|
|
200
|
+
* // Topic for the essay
|
|
201
|
+
* const topic = "cats";
|
|
202
|
+
*
|
|
203
|
+
* // Stream the workflow to generate the essay and await human review
|
|
204
|
+
* for await (const result of reviewWorkflow.stream(topic, config)) {
|
|
205
|
+
* console.log(result);
|
|
206
|
+
* }
|
|
207
|
+
*
|
|
208
|
+
* // Example human review provided after the interrupt
|
|
209
|
+
* const humanReview = "This essay is great.";
|
|
210
|
+
*
|
|
211
|
+
* // Resume the workflow with the provided human review
|
|
212
|
+
* for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {
|
|
213
|
+
* console.log(result);
|
|
214
|
+
* }
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @example Accessing the previous return value
|
|
218
|
+
* ```typescript
|
|
219
|
+
* import { entrypoint, getPreviousState } from "@langchain/langgraph";
|
|
220
|
+
* import { MemorySaver } from "@langchain/langgraph-checkpoint";
|
|
221
|
+
*
|
|
222
|
+
* const accumulator = entrypoint({
|
|
223
|
+
* name: "accumulator",
|
|
224
|
+
* checkpointer: new MemorySaver()
|
|
225
|
+
* }, async (input: string) => {
|
|
226
|
+
* const previous = getPreviousState<number>();
|
|
227
|
+
* return previous !== undefined ? `${previous } ${input}` : input;
|
|
228
|
+
* });
|
|
229
|
+
*
|
|
230
|
+
* const config = {
|
|
231
|
+
* configurable: {
|
|
232
|
+
* thread_id: "some_thread"
|
|
233
|
+
* }
|
|
234
|
+
* };
|
|
235
|
+
* await accumulator.invoke("hello", config); // returns "hello"
|
|
236
|
+
* await accumulator.invoke("world", config); // returns "hello world"
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @example Using entrypoint.final to save a value
|
|
240
|
+
* ```typescript
|
|
241
|
+
* import { entrypoint, getPreviousState } from "@langchain/langgraph";
|
|
242
|
+
* import { MemorySaver } from "@langchain/langgraph-checkpoint";
|
|
243
|
+
*
|
|
244
|
+
* const myWorkflow = entrypoint({
|
|
245
|
+
* name: "accumulator",
|
|
246
|
+
* checkpointer: new MemorySaver()
|
|
247
|
+
* }, async (num: number) => {
|
|
248
|
+
* const previous = getPreviousState<number>();
|
|
249
|
+
*
|
|
250
|
+
* // This will return the previous value to the caller, saving
|
|
251
|
+
* // 2 * num to the checkpoint, which will be used in the next invocation
|
|
252
|
+
* // for the `previous` parameter.
|
|
253
|
+
* return entrypoint.final({
|
|
254
|
+
* value: previous ?? 0,
|
|
255
|
+
* save: 2 * num
|
|
256
|
+
* });
|
|
257
|
+
* });
|
|
258
|
+
*
|
|
259
|
+
* const config = {
|
|
260
|
+
* configurable: {
|
|
261
|
+
* thread_id: "some_thread"
|
|
262
|
+
* }
|
|
263
|
+
* };
|
|
264
|
+
*
|
|
265
|
+
* await myWorkflow.invoke(3, config); // 0 (previous was undefined)
|
|
266
|
+
* await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
declare const entrypoint: EntrypointFunction;
|
|
270
|
+
/**
|
|
271
|
+
* A helper utility function for use with the functional API that returns the previous
|
|
272
|
+
* state from the checkpoint from the last invocation of the current thread.
|
|
273
|
+
*
|
|
274
|
+
* This function allows workflows to access state that was saved in previous runs
|
|
275
|
+
* using {@link entrypoint.final}.
|
|
276
|
+
*
|
|
277
|
+
* @typeParam StateT - The type of the state that was previously saved
|
|
278
|
+
* @returns The previous saved state from the last invocation of the current thread
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* const previousState = getPreviousState<{ counter: number }>();
|
|
283
|
+
* const newCount = (previousState?.counter ?? 0) + 1;
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
declare function getPreviousState<StateT>(): StateT;
|
|
287
|
+
//#endregion
|
|
288
|
+
export { EntrypointOptions, TaskOptions, entrypoint, getPreviousState, task };
|
|
289
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["BaseCache","BaseCheckpointSaver","BaseStore","Pregel","PregelNode","END","PREVIOUS","START","EphemeralValue","CachePolicy","RetryPolicy","LastValue","EntrypointFinal","EntrypointReturnT","EntrypointFinalSaveT","EntrypointFunc","TaskFunc","TaskOptions","task","ArgsT","OutputT","Promise","EntrypointOptions","EntrypointFunction","InputT","Record","Awaited","ValueT","SaveT","entrypoint","getPreviousState","StateT"],"sources":["../../src/func/index.d.ts"],"sourcesContent":["import { BaseCache, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { Pregel } from \"../pregel/index.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { END, PREVIOUS, START } from \"../constants.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport type { CachePolicy, RetryPolicy } from \"../pregel/utils/index.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nimport { EntrypointFinal, EntrypointReturnT, EntrypointFinalSaveT, EntrypointFunc, TaskFunc } from \"./types.js\";\n/**\n * Options for the {@link task} function\n */\nexport interface TaskOptions {\n /**\n * The name of the task, analogous to the node name in {@link StateGraph}.\n */\n name: string;\n /**\n * The retry policy for the task. Configures how many times and under what conditions\n * the task should be retried if it fails.\n */\n retry?: RetryPolicy;\n /**\n * The cache policy for the task. Configures how the task should be cached.\n */\n cachePolicy?: CachePolicy;\n}\n/**\n * Define a LangGraph task using the `task` function.\n *\n * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.\n * A task can be called like a regular function with the following differences:\n *\n * - When a checkpointer is enabled, the function inputs and outputs must be serializable.\n * - The wrapped function can only be called from within an entrypoint or StateGraph.\n * - Calling the function produces a promise. This makes it easy to parallelize tasks.\n *\n * @typeParam ArgsT - The type of arguments the task function accepts\n * @typeParam OutputT - The type of value the task function returns\n * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task\n * @param func - The function that executes this task\n * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise\n *\n * @example basic example\n * ```typescript\n * const addOne = task(\"add\", async (a: number) => a + 1);\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n *\n * // Call the entrypoint\n * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]\n * ```\n *\n * @example using a retry policy\n * ```typescript\n * const addOne = task({\n * name: \"add\",\n * retry: { maxAttempts: 3 }\n * },\n * async (a: number) => a + 1\n * );\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n * ```\n */\nexport declare function task<ArgsT extends unknown[], OutputT>(optionsOrName: TaskOptions | string, func: TaskFunc<ArgsT, OutputT>): (...args: ArgsT) => Promise<OutputT>;\n/**\n * Options for the {@link entrypoint} function\n */\nexport type EntrypointOptions = {\n /**\n * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.\n * This name is used for logging, debugging, and checkpoint identification.\n */\n name: string;\n /**\n * The checkpointer for the {@link entrypoint}. Used to save and restore state between\n * invocations of the workflow.\n */\n checkpointer?: BaseCheckpointSaver;\n /**\n * The store for the {@link entrypoint}. Used to persist data across workflow runs.\n */\n store?: BaseStore;\n /**\n * The cache for the {@link entrypoint}. Used to cache values between workflow runs.\n */\n cache?: BaseCache;\n};\n/**\n * Type declaration for the entrypoint function with its properties\n */\nexport interface EntrypointFunction {\n <InputT, OutputT>(optionsOrName: EntrypointOptions | string, func: EntrypointFunc<InputT, OutputT>): Pregel<Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n }, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>, \n // Because the update type is an return type union of tasks + entrypoint,\n // thus we can't type it properly.\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Awaited<EntrypointReturnT<OutputT>>>;\n /**\n * A helper utility for use with the functional API that returns a value to the caller,\n * as well as a separate state value to persist to the checkpoint. This allows workflows\n * to maintain state between runs while returning different values to the caller.\n *\n * @typeParam ValueT - The type of the value to return to the caller\n * @typeParam SaveT - The type of the state to save to the checkpoint\n * @param value - The value to return to the caller\n * @param save - The value to save to the checkpoint\n * @returns An object with the value and save properties\n *\n * @example\n * ```typescript\n * return entrypoint.final({\n * value: \"result for caller\",\n * save: { counter: currentCount + 1 }\n * });\n * ```\n */\n final<ValueT, SaveT>(options: {\n value?: ValueT;\n save?: SaveT;\n }): EntrypointFinal<ValueT, SaveT>;\n}\n/**\n * Define a LangGraph workflow using the `entrypoint` function.\n *\n * ### Function signature\n *\n * The wrapped function must accept at most **two parameters**. The first parameter\n * is the input to the function. The second (optional) parameter is a\n * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to\n * the function, you can pass them as an object.\n *\n * ### Helper functions\n *\n * #### Streaming\n * To write data to the \"custom\" stream, use the {@link getWriter} function, or the\n * {@link LangGraphRunnableConfig.writer} property.\n *\n * #### State management\n * The {@link getPreviousState} function can be used to access the previous state\n * that was returned from the last invocation of the entrypoint on the same thread id.\n *\n * If you wish to save state other than the return value, you can use the\n * {@link entrypoint.final} function.\n *\n * @typeParam InputT - The type of input the entrypoint accepts\n * @typeParam OutputT - The type of output the entrypoint produces\n * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint\n * @param func - The function that executes this entrypoint\n * @returns A {@link Pregel} instance that can be run to execute the workflow\n *\n * @example Using entrypoint and tasks\n * ```typescript\n * import { task, entrypoint } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n * import { interrupt, Command } from \"@langchain/langgraph\";\n *\n * const composeEssay = task(\"compose\", async (topic: string) => {\n * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation\n * return `An essay about ${topic}`;\n * });\n *\n * const reviewWorkflow = entrypoint({\n * name: \"review\",\n * checkpointer: new MemorySaver()\n * }, async (topic: string) => {\n * const essay = await composeEssay(topic);\n * const humanReview = await interrupt({\n * question: \"Please provide a review\",\n * essay\n * });\n * return {\n * essay,\n * review: humanReview\n * };\n * });\n *\n * // Example configuration for the workflow\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * // Topic for the essay\n * const topic = \"cats\";\n *\n * // Stream the workflow to generate the essay and await human review\n * for await (const result of reviewWorkflow.stream(topic, config)) {\n * console.log(result);\n * }\n *\n * // Example human review provided after the interrupt\n * const humanReview = \"This essay is great.\";\n *\n * // Resume the workflow with the provided human review\n * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {\n * console.log(result);\n * }\n * ```\n *\n * @example Accessing the previous return value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const accumulator = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (input: string) => {\n * const previous = getPreviousState<number>();\n * return previous !== undefined ? `${previous } ${input}` : input;\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n * await accumulator.invoke(\"hello\", config); // returns \"hello\"\n * await accumulator.invoke(\"world\", config); // returns \"hello world\"\n * ```\n *\n * @example Using entrypoint.final to save a value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const myWorkflow = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (num: number) => {\n * const previous = getPreviousState<number>();\n *\n * // This will return the previous value to the caller, saving\n * // 2 * num to the checkpoint, which will be used in the next invocation\n * // for the `previous` parameter.\n * return entrypoint.final({\n * value: previous ?? 0,\n * save: 2 * num\n * });\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * await myWorkflow.invoke(3, config); // 0 (previous was undefined)\n * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)\n * ```\n */\nexport declare const entrypoint: EntrypointFunction;\n/**\n * A helper utility function for use with the functional API that returns the previous\n * state from the checkpoint from the last invocation of the current thread.\n *\n * This function allows workflows to access state that was saved in previous runs\n * using {@link entrypoint.final}.\n *\n * @typeParam StateT - The type of the state that was previously saved\n * @returns The previous saved state from the last invocation of the current thread\n *\n * @example\n * ```typescript\n * const previousState = getPreviousState<{ counter: number }>();\n * const newCount = (previousState?.counter ?? 0) + 1;\n * ```\n */\nexport declare function getPreviousState<StateT>(): StateT;\n"],"mappings":";;;;;;;;;;;;;AAWA;AAA4B,UAAXiB,WAAAA,CAAW;;;;EA6DJC,IAAAA,EAAAA,MAAI;EAAA;;;;OAA8EF,CAAAA,EApD9FN,WAoD8FM;;;;gBAhDxFP;AAoDlB;;;;;;AAuBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqKA;AAiBA;;;;iBAjNwBS,sDAAsDD,4BAA4BD,SAASG,OAAOC,qBAAqBD,UAAUE,QAAQD;;;;KAIrJE,iBAAAA;;;;;;;;;;iBAUOrB;;;;UAIPC;;;;UAIAF;;;;;UAKKuB,kBAAAA;mCACoBD,kCAAkCP,eAAeS,QAAQJ,WAAWjB,OAAOsB,eAAerB,WAAWoB,QAAQX,kBAAkBO;KAC3Jb,KAAAA,GAAQC,eAAegB;KACvBnB,GAAAA,GAAMM,UAAUE,kBAAkBO;KAClCd,QAAAA,GAAWK,UAAUG,qBAAqBM;KAC5CK,yBAAyBD,QAAQX,kBAAkBO;;;;;EAItDM,QAAQb,kBAAkBO;;;;;;;;;;;;;;;;;;;;;YAqBdO;WACDC;MACPhB,gBAAgBe,QAAQC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqIXC,YAAYN;;;;;;;;;;;;;;;;;iBAiBTO,4BAA4BC"}
|
package/dist/func/index.d.ts
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { LastValue } from "../channels/last_value.js";
|
|
2
|
+
import { CachePolicy, RetryPolicy } from "../pregel/utils/index.js";
|
|
3
3
|
import { PregelNode } from "../pregel/read.js";
|
|
4
4
|
import { END, PREVIOUS, START } from "../constants.js";
|
|
5
|
+
import { Pregel } from "../pregel/index.js";
|
|
5
6
|
import { EphemeralValue } from "../channels/ephemeral_value.js";
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import { EntrypointFinal, EntrypointFinalSaveT, EntrypointFunc, EntrypointReturnT, TaskFunc } from "./types.js";
|
|
8
|
+
import { BaseCache, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
9
|
+
|
|
10
|
+
//#region src/func/index.d.ts
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
13
|
* Options for the {@link task} function
|
|
11
14
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
interface TaskOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The name of the task, analogous to the node name in {@link StateGraph}.
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
/**
|
|
21
|
+
* The retry policy for the task. Configures how many times and under what conditions
|
|
22
|
+
* the task should be retried if it fails.
|
|
23
|
+
*/
|
|
24
|
+
retry?: RetryPolicy;
|
|
25
|
+
/**
|
|
26
|
+
* The cache policy for the task. Configures how the task should be cached.
|
|
27
|
+
*/
|
|
28
|
+
cachePolicy?: CachePolicy;
|
|
26
29
|
}
|
|
27
30
|
/**
|
|
28
31
|
* Define a LangGraph task using the `task` function.
|
|
@@ -70,63 +73,67 @@ export interface TaskOptions {
|
|
|
70
73
|
* });
|
|
71
74
|
* ```
|
|
72
75
|
*/
|
|
73
|
-
|
|
76
|
+
declare function task<ArgsT extends unknown[], OutputT>(optionsOrName: TaskOptions | string, func: TaskFunc<ArgsT, OutputT>): (...args: ArgsT) => Promise<OutputT>;
|
|
74
77
|
/**
|
|
75
78
|
* Options for the {@link entrypoint} function
|
|
76
79
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
type EntrypointOptions = {
|
|
81
|
+
/**
|
|
82
|
+
* The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.
|
|
83
|
+
* This name is used for logging, debugging, and checkpoint identification.
|
|
84
|
+
*/
|
|
85
|
+
name: string;
|
|
86
|
+
/**
|
|
87
|
+
* The checkpointer for the {@link entrypoint}. Used to save and restore state between
|
|
88
|
+
* invocations of the workflow.
|
|
89
|
+
*/
|
|
90
|
+
checkpointer?: BaseCheckpointSaver;
|
|
91
|
+
/**
|
|
92
|
+
* The store for the {@link entrypoint}. Used to persist data across workflow runs.
|
|
93
|
+
*/
|
|
94
|
+
store?: BaseStore;
|
|
95
|
+
/**
|
|
96
|
+
* The cache for the {@link entrypoint}. Used to cache values between workflow runs.
|
|
97
|
+
*/
|
|
98
|
+
cache?: BaseCache;
|
|
96
99
|
};
|
|
97
100
|
/**
|
|
98
101
|
* Type declaration for the entrypoint function with its properties
|
|
99
102
|
*/
|
|
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
|
-
|
|
103
|
+
interface EntrypointFunction {
|
|
104
|
+
<InputT, OutputT>(optionsOrName: EntrypointOptions | string, func: EntrypointFunc<InputT, OutputT>): Pregel<Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, {
|
|
105
|
+
[START]: EphemeralValue<InputT>;
|
|
106
|
+
[END]: LastValue<EntrypointReturnT<OutputT>>;
|
|
107
|
+
[PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;
|
|
108
|
+
}, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>,
|
|
109
|
+
// Because the update type is an return type union of tasks + entrypoint,
|
|
110
|
+
// thus we can't type it properly.
|
|
111
|
+
any,
|
|
112
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
113
|
+
Awaited<EntrypointReturnT<OutputT>>>;
|
|
114
|
+
/**
|
|
115
|
+
* A helper utility for use with the functional API that returns a value to the caller,
|
|
116
|
+
* as well as a separate state value to persist to the checkpoint. This allows workflows
|
|
117
|
+
* to maintain state between runs while returning different values to the caller.
|
|
118
|
+
*
|
|
119
|
+
* @typeParam ValueT - The type of the value to return to the caller
|
|
120
|
+
* @typeParam SaveT - The type of the state to save to the checkpoint
|
|
121
|
+
* @param value - The value to return to the caller
|
|
122
|
+
* @param save - The value to save to the checkpoint
|
|
123
|
+
* @returns An object with the value and save properties
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* return entrypoint.final({
|
|
128
|
+
* value: "result for caller",
|
|
129
|
+
* save: { counter: currentCount + 1 }
|
|
130
|
+
* });
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
final<ValueT, SaveT>(options: {
|
|
134
|
+
value?: ValueT;
|
|
135
|
+
save?: SaveT;
|
|
136
|
+
}): EntrypointFinal<ValueT, SaveT>;
|
|
130
137
|
}
|
|
131
138
|
/**
|
|
132
139
|
* Define a LangGraph workflow using the `entrypoint` function.
|
|
@@ -259,7 +266,7 @@ export interface EntrypointFunction {
|
|
|
259
266
|
* await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)
|
|
260
267
|
* ```
|
|
261
268
|
*/
|
|
262
|
-
|
|
269
|
+
declare const entrypoint: EntrypointFunction;
|
|
263
270
|
/**
|
|
264
271
|
* A helper utility function for use with the functional API that returns the previous
|
|
265
272
|
* state from the checkpoint from the last invocation of the current thread.
|
|
@@ -276,4 +283,7 @@ export declare const entrypoint: EntrypointFunction;
|
|
|
276
283
|
* const newCount = (previousState?.counter ?? 0) + 1;
|
|
277
284
|
* ```
|
|
278
285
|
*/
|
|
279
|
-
|
|
286
|
+
declare function getPreviousState<StateT>(): StateT;
|
|
287
|
+
//#endregion
|
|
288
|
+
export { EntrypointOptions, TaskOptions, entrypoint, getPreviousState, task };
|
|
289
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["BaseCache","BaseCheckpointSaver","BaseStore","Pregel","PregelNode","END","PREVIOUS","START","EphemeralValue","CachePolicy","RetryPolicy","LastValue","EntrypointFinal","EntrypointReturnT","EntrypointFinalSaveT","EntrypointFunc","TaskFunc","TaskOptions","task","ArgsT","OutputT","Promise","EntrypointOptions","EntrypointFunction","InputT","Record","Awaited","ValueT","SaveT","entrypoint","getPreviousState","StateT"],"sources":["../../src/func/index.d.ts"],"sourcesContent":["import { BaseCache, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { Pregel } from \"../pregel/index.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { END, PREVIOUS, START } from \"../constants.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport type { CachePolicy, RetryPolicy } from \"../pregel/utils/index.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nimport { EntrypointFinal, EntrypointReturnT, EntrypointFinalSaveT, EntrypointFunc, TaskFunc } from \"./types.js\";\n/**\n * Options for the {@link task} function\n */\nexport interface TaskOptions {\n /**\n * The name of the task, analogous to the node name in {@link StateGraph}.\n */\n name: string;\n /**\n * The retry policy for the task. Configures how many times and under what conditions\n * the task should be retried if it fails.\n */\n retry?: RetryPolicy;\n /**\n * The cache policy for the task. Configures how the task should be cached.\n */\n cachePolicy?: CachePolicy;\n}\n/**\n * Define a LangGraph task using the `task` function.\n *\n * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.\n * A task can be called like a regular function with the following differences:\n *\n * - When a checkpointer is enabled, the function inputs and outputs must be serializable.\n * - The wrapped function can only be called from within an entrypoint or StateGraph.\n * - Calling the function produces a promise. This makes it easy to parallelize tasks.\n *\n * @typeParam ArgsT - The type of arguments the task function accepts\n * @typeParam OutputT - The type of value the task function returns\n * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task\n * @param func - The function that executes this task\n * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise\n *\n * @example basic example\n * ```typescript\n * const addOne = task(\"add\", async (a: number) => a + 1);\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n *\n * // Call the entrypoint\n * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]\n * ```\n *\n * @example using a retry policy\n * ```typescript\n * const addOne = task({\n * name: \"add\",\n * retry: { maxAttempts: 3 }\n * },\n * async (a: number) => a + 1\n * );\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n * ```\n */\nexport declare function task<ArgsT extends unknown[], OutputT>(optionsOrName: TaskOptions | string, func: TaskFunc<ArgsT, OutputT>): (...args: ArgsT) => Promise<OutputT>;\n/**\n * Options for the {@link entrypoint} function\n */\nexport type EntrypointOptions = {\n /**\n * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.\n * This name is used for logging, debugging, and checkpoint identification.\n */\n name: string;\n /**\n * The checkpointer for the {@link entrypoint}. Used to save and restore state between\n * invocations of the workflow.\n */\n checkpointer?: BaseCheckpointSaver;\n /**\n * The store for the {@link entrypoint}. Used to persist data across workflow runs.\n */\n store?: BaseStore;\n /**\n * The cache for the {@link entrypoint}. Used to cache values between workflow runs.\n */\n cache?: BaseCache;\n};\n/**\n * Type declaration for the entrypoint function with its properties\n */\nexport interface EntrypointFunction {\n <InputT, OutputT>(optionsOrName: EntrypointOptions | string, func: EntrypointFunc<InputT, OutputT>): Pregel<Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n }, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>, \n // Because the update type is an return type union of tasks + entrypoint,\n // thus we can't type it properly.\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Awaited<EntrypointReturnT<OutputT>>>;\n /**\n * A helper utility for use with the functional API that returns a value to the caller,\n * as well as a separate state value to persist to the checkpoint. This allows workflows\n * to maintain state between runs while returning different values to the caller.\n *\n * @typeParam ValueT - The type of the value to return to the caller\n * @typeParam SaveT - The type of the state to save to the checkpoint\n * @param value - The value to return to the caller\n * @param save - The value to save to the checkpoint\n * @returns An object with the value and save properties\n *\n * @example\n * ```typescript\n * return entrypoint.final({\n * value: \"result for caller\",\n * save: { counter: currentCount + 1 }\n * });\n * ```\n */\n final<ValueT, SaveT>(options: {\n value?: ValueT;\n save?: SaveT;\n }): EntrypointFinal<ValueT, SaveT>;\n}\n/**\n * Define a LangGraph workflow using the `entrypoint` function.\n *\n * ### Function signature\n *\n * The wrapped function must accept at most **two parameters**. The first parameter\n * is the input to the function. The second (optional) parameter is a\n * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to\n * the function, you can pass them as an object.\n *\n * ### Helper functions\n *\n * #### Streaming\n * To write data to the \"custom\" stream, use the {@link getWriter} function, or the\n * {@link LangGraphRunnableConfig.writer} property.\n *\n * #### State management\n * The {@link getPreviousState} function can be used to access the previous state\n * that was returned from the last invocation of the entrypoint on the same thread id.\n *\n * If you wish to save state other than the return value, you can use the\n * {@link entrypoint.final} function.\n *\n * @typeParam InputT - The type of input the entrypoint accepts\n * @typeParam OutputT - The type of output the entrypoint produces\n * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint\n * @param func - The function that executes this entrypoint\n * @returns A {@link Pregel} instance that can be run to execute the workflow\n *\n * @example Using entrypoint and tasks\n * ```typescript\n * import { task, entrypoint } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n * import { interrupt, Command } from \"@langchain/langgraph\";\n *\n * const composeEssay = task(\"compose\", async (topic: string) => {\n * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation\n * return `An essay about ${topic}`;\n * });\n *\n * const reviewWorkflow = entrypoint({\n * name: \"review\",\n * checkpointer: new MemorySaver()\n * }, async (topic: string) => {\n * const essay = await composeEssay(topic);\n * const humanReview = await interrupt({\n * question: \"Please provide a review\",\n * essay\n * });\n * return {\n * essay,\n * review: humanReview\n * };\n * });\n *\n * // Example configuration for the workflow\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * // Topic for the essay\n * const topic = \"cats\";\n *\n * // Stream the workflow to generate the essay and await human review\n * for await (const result of reviewWorkflow.stream(topic, config)) {\n * console.log(result);\n * }\n *\n * // Example human review provided after the interrupt\n * const humanReview = \"This essay is great.\";\n *\n * // Resume the workflow with the provided human review\n * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {\n * console.log(result);\n * }\n * ```\n *\n * @example Accessing the previous return value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const accumulator = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (input: string) => {\n * const previous = getPreviousState<number>();\n * return previous !== undefined ? `${previous } ${input}` : input;\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n * await accumulator.invoke(\"hello\", config); // returns \"hello\"\n * await accumulator.invoke(\"world\", config); // returns \"hello world\"\n * ```\n *\n * @example Using entrypoint.final to save a value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const myWorkflow = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (num: number) => {\n * const previous = getPreviousState<number>();\n *\n * // This will return the previous value to the caller, saving\n * // 2 * num to the checkpoint, which will be used in the next invocation\n * // for the `previous` parameter.\n * return entrypoint.final({\n * value: previous ?? 0,\n * save: 2 * num\n * });\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * await myWorkflow.invoke(3, config); // 0 (previous was undefined)\n * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)\n * ```\n */\nexport declare const entrypoint: EntrypointFunction;\n/**\n * A helper utility function for use with the functional API that returns the previous\n * state from the checkpoint from the last invocation of the current thread.\n *\n * This function allows workflows to access state that was saved in previous runs\n * using {@link entrypoint.final}.\n *\n * @typeParam StateT - The type of the state that was previously saved\n * @returns The previous saved state from the last invocation of the current thread\n *\n * @example\n * ```typescript\n * const previousState = getPreviousState<{ counter: number }>();\n * const newCount = (previousState?.counter ?? 0) + 1;\n * ```\n */\nexport declare function getPreviousState<StateT>(): StateT;\n"],"mappings":";;;;;;;;;;;;;AAWA;AAA4B,UAAXiB,WAAAA,CAAW;;;;EA6DJC,IAAAA,EAAAA,MAAI;EAAA;;;;OAA8EF,CAAAA,EApD9FN,WAoD8FM;;;;gBAhDxFP;AAoDlB;;;;;;AAuBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqKA;AAiBA;;;;iBAjNwBS,sDAAsDD,4BAA4BD,SAASG,OAAOC,qBAAqBD,UAAUE,QAAQD;;;;KAIrJE,iBAAAA;;;;;;;;;;iBAUOrB;;;;UAIPC;;;;UAIAF;;;;;UAKKuB,kBAAAA;mCACoBD,kCAAkCP,eAAeS,QAAQJ,WAAWjB,OAAOsB,eAAerB,WAAWoB,QAAQX,kBAAkBO;KAC3Jb,KAAAA,GAAQC,eAAegB;KACvBnB,GAAAA,GAAMM,UAAUE,kBAAkBO;KAClCd,QAAAA,GAAWK,UAAUG,qBAAqBM;KAC5CK,yBAAyBD,QAAQX,kBAAkBO;;;;;EAItDM,QAAQb,kBAAkBO;;;;;;;;;;;;;;;;;;;;;YAqBdO;WACDC;MACPhB,gBAAgBe,QAAQC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqIXC,YAAYN;;;;;;;;;;;;;;;;;iBAiBTO,4BAA4BC"}
|