@langchain/langgraph 0.4.7 → 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 +11 -0
- 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 +77 -80
- package/dist/channels/any_value.cjs +0 -65
- package/dist/channels/any_value.js +0 -61
- package/dist/channels/any_value.js.map +0 -1
- package/dist/channels/dynamic_barrier_value.cjs +0 -212
- package/dist/channels/dynamic_barrier_value.js +0 -207
- package/dist/channels/dynamic_barrier_value.js.map +0 -1
- package/dist/channels/index.d.ts +0 -7
- package/dist/channels/index.js.map +0 -1
- package/dist/func/types.cjs +0 -15
- package/dist/func/types.js +0 -12
- package/dist/func/types.js.map +0 -1
- package/dist/graph/index.d.ts +0 -4
- package/dist/graph/index.js.map +0 -1
- package/dist/graph/message.test.cjs +0 -196
- package/dist/graph/message.test.d.ts +0 -1
- package/dist/graph/message.test.js +0 -194
- package/dist/graph/message.test.js.map +0 -1
- package/dist/graph/zod/index.js.map +0 -1
- package/dist/graph/zod/plugin.d.ts +0 -28
- package/dist/hash.d.ts +0 -2
- package/dist/prebuilt/index.js.map +0 -1
- package/dist/prebuilt/interrupt.cjs +0 -3
- package/dist/prebuilt/interrupt.js +0 -2
- package/dist/prebuilt/interrupt.js.map +0 -1
- package/dist/pregel/call.d.ts +0 -16
- package/dist/pregel/debug.d.ts +0 -41
- package/dist/pregel/debug.test.cjs +0 -258
- package/dist/pregel/debug.test.d.ts +0 -1
- package/dist/pregel/debug.test.js +0 -256
- package/dist/pregel/debug.test.js.map +0 -1
- package/dist/pregel/io.d.ts +0 -30
- package/dist/pregel/io.mapCommand.test.cjs +0 -150
- package/dist/pregel/io.mapCommand.test.d.ts +0 -1
- package/dist/pregel/io.mapCommand.test.js +0 -148
- package/dist/pregel/io.mapCommand.test.js.map +0 -1
- package/dist/pregel/loop.d.ts +0 -147
- package/dist/pregel/messages.d.ts +0 -30
- package/dist/pregel/messages.test.cjs +0 -369
- package/dist/pregel/messages.test.d.ts +0 -1
- package/dist/pregel/messages.test.js +0 -367
- package/dist/pregel/messages.test.js.map +0 -1
- package/dist/pregel/read.test.cjs +0 -194
- package/dist/pregel/read.test.d.ts +0 -1
- package/dist/pregel/read.test.js +0 -192
- package/dist/pregel/read.test.js.map +0 -1
- package/dist/pregel/retry.d.ts +0 -17
- package/dist/pregel/runnable_types.cjs +0 -3
- package/dist/pregel/runnable_types.js +0 -2
- package/dist/pregel/runnable_types.js.map +0 -1
- package/dist/pregel/runner.d.ts +0 -79
- package/dist/pregel/runner.test.cjs +0 -66
- package/dist/pregel/runner.test.d.ts +0 -1
- package/dist/pregel/runner.test.js +0 -64
- package/dist/pregel/runner.test.js.map +0 -1
- package/dist/pregel/stream.d.ts +0 -40
- package/dist/pregel/utils/config.test.cjs +0 -214
- package/dist/pregel/utils/config.test.d.ts +0 -1
- package/dist/pregel/utils/config.test.js +0 -212
- package/dist/pregel/utils/config.test.js.map +0 -1
- package/dist/pregel/utils/subgraph.d.ts +0 -4
- package/dist/pregel/utils/subgraph.test.cjs +0 -83
- package/dist/pregel/utils/subgraph.test.d.ts +0 -1
- package/dist/pregel/utils/subgraph.test.js +0 -81
- package/dist/pregel/utils/subgraph.test.js.map +0 -1
- package/dist/pregel/validate.d.ts +0 -16
- package/dist/pregel/validate.test.cjs +0 -220
- package/dist/pregel/validate.test.d.ts +0 -1
- package/dist/pregel/validate.test.js +0 -218
- package/dist/pregel/validate.test.js.map +0 -1
- package/dist/pregel/write.test.cjs +0 -181
- package/dist/pregel/write.test.d.ts +0 -1
- package/dist/pregel/write.test.js +0 -179
- package/dist/pregel/write.test.js.map +0 -1
- package/dist/remote.js.map +0 -1
- package/dist/setup/async_local_storage.d.ts +0 -1
- package/dist/web.js.map +0 -1
- package/index.cjs +0 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/prebuilt.cjs +0 -1
- package/prebuilt.d.cts +0 -1
- package/prebuilt.d.ts +0 -1
- package/prebuilt.js +0 -1
- package/pregel.cjs +0 -1
- package/pregel.d.cts +0 -1
- package/pregel.d.ts +0 -1
- package/pregel.js +0 -1
- package/remote.cjs +0 -1
- package/remote.d.cts +0 -1
- package/remote.d.ts +0 -1
- package/remote.js +0 -1
- package/web.cjs +0 -1
- package/web.d.cts +0 -1
- package/web.d.ts +0 -1
- package/web.js +0 -1
- package/zod/schema.cjs +0 -1
- package/zod/schema.d.cts +0 -1
- package/zod/schema.d.ts +0 -1
- package/zod/schema.js +0 -1
- package/zod.cjs +0 -1
- package/zod.d.cts +0 -1
- package/zod.d.ts +0 -1
- package/zod.js +0 -1
package/dist/graph/zod/meta.js
CHANGED
|
@@ -1,175 +1,141 @@
|
|
|
1
|
-
import { getInteropZodObjectShape, extendInteropZodObject, getInteropZodDefaultGetter, interopZodObjectPartial, isZodSchemaV3, getSchemaDescription, } from "@langchain/core/utils/types";
|
|
2
1
|
import { BinaryOperatorAggregate } from "../../channels/binop.js";
|
|
3
2
|
import { LastValue } from "../../channels/last_value.js";
|
|
4
|
-
|
|
3
|
+
import { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopZodObjectPartial, isZodSchemaV3 } from "@langchain/core/utils/types";
|
|
4
|
+
|
|
5
|
+
//#region src/graph/zod/meta.ts
|
|
6
|
+
const META_EXTRAS_DESCRIPTION_PREFIX = "lg:";
|
|
5
7
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
description,
|
|
136
|
-
});
|
|
137
|
-
outputSchema = outputSchema.describe(`${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`);
|
|
138
|
-
}
|
|
139
|
-
return [key, outputSchema];
|
|
140
|
-
});
|
|
141
|
-
modifiedSchema = extendInteropZodObject(schema, Object.fromEntries(newShapeEntries));
|
|
142
|
-
if (isZodSchemaV3(modifiedSchema)) {
|
|
143
|
-
modifiedSchema._def.unknownKeys = "strip";
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (effects.asPartial) {
|
|
147
|
-
modifiedSchema = interopZodObjectPartial(modifiedSchema);
|
|
148
|
-
}
|
|
149
|
-
cache.set(schema, modifiedSchema);
|
|
150
|
-
this._extensionCache.set(cacheKey, cache);
|
|
151
|
-
return modifiedSchema;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
export const schemaMetaRegistry = new SchemaMetaRegistry();
|
|
155
|
-
export function withLangGraph(schema, meta) {
|
|
156
|
-
if (meta.reducer && !meta.default) {
|
|
157
|
-
const defaultValueGetter = getInteropZodDefaultGetter(schema);
|
|
158
|
-
if (defaultValueGetter != null) {
|
|
159
|
-
// eslint-disable-next-line no-param-reassign
|
|
160
|
-
meta.default = defaultValueGetter;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (meta.reducer) {
|
|
164
|
-
const schemaWithReducer = Object.assign(schema, {
|
|
165
|
-
lg_reducer_schema: meta.reducer?.schema ?? schema,
|
|
166
|
-
});
|
|
167
|
-
schemaMetaRegistry.extend(schemaWithReducer, () => meta);
|
|
168
|
-
return schemaWithReducer;
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
schemaMetaRegistry.extend(schema, () => meta);
|
|
172
|
-
return schema;
|
|
173
|
-
}
|
|
8
|
+
* A registry for storing and managing metadata associated with schemas.
|
|
9
|
+
* This class provides methods to get, extend, remove, and check metadata for a given schema.
|
|
10
|
+
*/
|
|
11
|
+
var SchemaMetaRegistry = class {
|
|
12
|
+
/**
|
|
13
|
+
* Internal map storing schema metadata.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
_map = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
/**
|
|
18
|
+
* Cache for extended schfemas.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
_extensionCache = /* @__PURE__ */ new Map();
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves the metadata associated with a given schema.
|
|
24
|
+
* @template TValue The value type of the schema.
|
|
25
|
+
* @template TUpdate The update type of the schema (defaults to TValue).
|
|
26
|
+
* @param schema The schema to retrieve metadata for.
|
|
27
|
+
* @returns The associated SchemaMeta, or undefined if not present.
|
|
28
|
+
*/
|
|
29
|
+
get(schema) {
|
|
30
|
+
return this._map.get(schema);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Extends or sets the metadata for a given schema.
|
|
34
|
+
* @template TValue The value type of the schema.
|
|
35
|
+
* @template TUpdate The update type of the schema (defaults to TValue).
|
|
36
|
+
* @param schema The schema to extend metadata for.
|
|
37
|
+
* @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.
|
|
38
|
+
*/
|
|
39
|
+
extend(schema, predicate) {
|
|
40
|
+
const existingMeta = this.get(schema);
|
|
41
|
+
this._map.set(schema, predicate(existingMeta));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Removes the metadata associated with a given schema.
|
|
45
|
+
* @param schema The schema to remove metadata for.
|
|
46
|
+
* @returns The SchemaMetaRegistry instance (for chaining).
|
|
47
|
+
*/
|
|
48
|
+
remove(schema) {
|
|
49
|
+
this._map.delete(schema);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Checks if metadata exists for a given schema.
|
|
54
|
+
* @param schema The schema to check.
|
|
55
|
+
* @returns True if metadata exists, false otherwise.
|
|
56
|
+
*/
|
|
57
|
+
has(schema) {
|
|
58
|
+
return this._map.has(schema);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns a mapping of channel instances for each property in the schema
|
|
62
|
+
* using the associated metadata in the registry.
|
|
63
|
+
*
|
|
64
|
+
* This is used to create the `channels` object that's passed to the `Graph` constructor.
|
|
65
|
+
*
|
|
66
|
+
* @template T The shape of the schema.
|
|
67
|
+
* @param schema The schema to extract channels from.
|
|
68
|
+
* @returns A mapping from property names to channel instances.
|
|
69
|
+
*/
|
|
70
|
+
getChannelsForSchema(schema) {
|
|
71
|
+
const channels = {};
|
|
72
|
+
const shape = getInteropZodObjectShape(schema);
|
|
73
|
+
for (const [key, channelSchema] of Object.entries(shape)) {
|
|
74
|
+
const meta = this.get(channelSchema);
|
|
75
|
+
if (meta?.reducer) channels[key] = new BinaryOperatorAggregate(meta.reducer.fn, meta.default);
|
|
76
|
+
else channels[key] = new LastValue();
|
|
77
|
+
}
|
|
78
|
+
return channels;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns a modified schema that introspectively looks at all keys of the provided
|
|
82
|
+
* object schema, and applies the augmentations based on meta provided with those keys
|
|
83
|
+
* in the registry and the selectors provided in the `effects` parameter.
|
|
84
|
+
*
|
|
85
|
+
* This assumes that the passed in schema is the "root" schema object for a graph where
|
|
86
|
+
* the keys of the schema are the channels of the graph. Because we need to represent
|
|
87
|
+
* the input of a graph in a couple of different ways, the `effects` parameter allows
|
|
88
|
+
* us to apply those augmentations based on pre determined conditions.
|
|
89
|
+
*
|
|
90
|
+
* @param schema The root schema object to extend.
|
|
91
|
+
* @param effects The effects that are being applied.
|
|
92
|
+
* @returns The extended schema.
|
|
93
|
+
*/
|
|
94
|
+
getExtendedChannelSchemas(schema, effects) {
|
|
95
|
+
if (Object.keys(effects).length === 0) return schema;
|
|
96
|
+
const cacheKey = Object.entries(effects).filter(([, v]) => v === true).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}:${v}`).join("|");
|
|
97
|
+
const cache = this._extensionCache.get(cacheKey) ?? /* @__PURE__ */ new WeakMap();
|
|
98
|
+
if (cache.has(schema)) return cache.get(schema);
|
|
99
|
+
let modifiedSchema = schema;
|
|
100
|
+
if (effects.withReducerSchema || effects.withJsonSchemaExtrasAsDescription) {
|
|
101
|
+
const newShapeEntries = Object.entries(getInteropZodObjectShape(schema)).map(([key, schema$1]) => {
|
|
102
|
+
const meta = this.get(schema$1);
|
|
103
|
+
let outputSchema = effects.withReducerSchema ? meta?.reducer?.schema ?? schema$1 : schema$1;
|
|
104
|
+
if (effects.withJsonSchemaExtrasAsDescription && meta?.jsonSchemaExtra) {
|
|
105
|
+
const description = getSchemaDescription(outputSchema) ?? getSchemaDescription(schema$1);
|
|
106
|
+
const strExtras = JSON.stringify({
|
|
107
|
+
...meta.jsonSchemaExtra,
|
|
108
|
+
description
|
|
109
|
+
});
|
|
110
|
+
outputSchema = outputSchema.describe(`${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`);
|
|
111
|
+
}
|
|
112
|
+
return [key, outputSchema];
|
|
113
|
+
});
|
|
114
|
+
modifiedSchema = extendInteropZodObject(schema, Object.fromEntries(newShapeEntries));
|
|
115
|
+
if (isZodSchemaV3(modifiedSchema)) modifiedSchema._def.unknownKeys = "strip";
|
|
116
|
+
}
|
|
117
|
+
if (effects.asPartial) modifiedSchema = interopZodObjectPartial(modifiedSchema);
|
|
118
|
+
cache.set(schema, modifiedSchema);
|
|
119
|
+
this._extensionCache.set(cacheKey, cache);
|
|
120
|
+
return modifiedSchema;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const schemaMetaRegistry = new SchemaMetaRegistry();
|
|
124
|
+
function withLangGraph(schema, meta) {
|
|
125
|
+
if (meta.reducer && !meta.default) {
|
|
126
|
+
const defaultValueGetter = getInteropZodDefaultGetter(schema);
|
|
127
|
+
if (defaultValueGetter != null) meta.default = defaultValueGetter;
|
|
128
|
+
}
|
|
129
|
+
if (meta.reducer) {
|
|
130
|
+
const schemaWithReducer = Object.assign(schema, { lg_reducer_schema: meta.reducer?.schema ?? schema });
|
|
131
|
+
schemaMetaRegistry.extend(schemaWithReducer, () => meta);
|
|
132
|
+
return schemaWithReducer;
|
|
133
|
+
} else {
|
|
134
|
+
schemaMetaRegistry.extend(schema, () => meta);
|
|
135
|
+
return schema;
|
|
136
|
+
}
|
|
174
137
|
}
|
|
138
|
+
|
|
139
|
+
//#endregion
|
|
140
|
+
export { META_EXTRAS_DESCRIPTION_PREFIX, SchemaMetaRegistry, schemaMetaRegistry, withLangGraph };
|
|
175
141
|
//# sourceMappingURL=meta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/graph/zod/meta.ts"],"names":[],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"meta.js","names":["modifiedSchema: InteropZodObject","schema"],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<unknown>\n ? ReducerSchema extends InteropZodType<infer U>\n ? U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new WeakMap<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schfemas.\n * @internal\n */\n _extensionCache = new Map<string, WeakMap<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue();\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new WeakMap();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAgBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI;;;;;CAMX,kCAAkB,IAAI;;;;;;;;CAStB,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI;;;;;;;;;CAUvB,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB;AAC/C,OAAK,KAAK,IAAI,QAAQ,UAAU;;;;;;;CAQlC,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO;AACjB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI;;;;;;;;;;;;CAavB,qBACE,QACgC;EAChC,MAAM,WAAW;EACjB,MAAM,QAAQ,yBAAyB;AACvC,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,QAAQ;GACxD,MAAM,OAAO,KAAK,IAAI;AACtB,OAAI,MAAM,QACR,UAAS,OAAO,IAAI,wBAElB,KAAK,QAAQ,IAAI,KAAK;OAExB,UAAS,OAAO,IAAI;;AAGxB,SAAO;;;;;;;;;;;;;;;;CAiBT,0BACE,QACA,SAckB;AAElB,MAAI,OAAO,KAAK,SAAS,WAAW,EAClC,QAAO;EAIT,MAAM,WAAW,OAAO,QAAQ,SAC7B,QAAQ,GAAG,OAAO,MAAM,MACxB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,IACnC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,KACxB,KAAK;EAER,MAAM,QAAQ,KAAK,gBAAgB,IAAI,6BAAa,IAAI;AACxD,MAAI,MAAM,IAAI,QAAS,QAAO,MAAM,IAAI;EAExC,IAAIA,iBAAmC;AAEvC,MACE,QAAQ,qBACR,QAAQ,mCACR;GACA,MAAM,kBAAkB,OAAO,QAC7B,yBAAyB,SACzB,KAAK,CAAC,KAAKC,cAAY;IACvB,MAAM,OAAO,KAAK,IAAIA;IACtB,IAAI,eAAe,QAAQ,oBACvB,MAAM,SAAS,UAAUA,WACzBA;AACJ,QACE,QAAQ,qCACR,MAAM,iBACN;KACA,MAAM,cACJ,qBAAqB,iBAAiB,qBAAqBA;KAC7D,MAAM,YAAY,KAAK,UAAU;MAC/B,GAAG,KAAK;MACR;;AAEF,oBAAe,aAAa,SAC1B,GAAG,iCAAiC;;AAGxC,WAAO,CAAC,KAAK;;AAEf,oBAAiB,uBACf,QACA,OAAO,YAAY;AAErB,OAAI,cAAc,gBAChB,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,kBAAiB,wBAAwB;AAG3C,QAAM,IAAI,QAAQ;AAClB,OAAK,gBAAgB,IAAI,UAAU;AACnC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI;AAkBtC,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,qBAAqB,2BAA2B;AACtD,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU;AAE7C,qBAAmB,OAAO,yBAAyB;AACnD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc;AACxC,SAAO"}
|
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_meta = require('./meta.cjs');
|
|
3
|
+
const zod = require_rolldown_runtime.__toESM(require("zod"));
|
|
4
|
+
const __langchain_core_utils_types = require_rolldown_runtime.__toESM(require("@langchain/core/utils/types"));
|
|
5
|
+
const zod_v3 = require_rolldown_runtime.__toESM(require("zod/v3"));
|
|
6
|
+
|
|
7
|
+
//#region src/graph/zod/plugin.ts
|
|
7
8
|
const metaSymbol = Symbol.for("langgraph-zod");
|
|
8
|
-
if (!(metaSymbol in globalThis))
|
|
9
|
-
globalThis[metaSymbol] = new WeakSet();
|
|
10
|
-
}
|
|
9
|
+
if (!(metaSymbol in globalThis)) globalThis[metaSymbol] = /* @__PURE__ */ new WeakSet();
|
|
11
10
|
function applyPluginPrototype(prototype) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
cache.add(prototype);
|
|
11
|
+
const cache = globalThis[metaSymbol];
|
|
12
|
+
if (cache.has(prototype)) return;
|
|
13
|
+
Object.defineProperty(prototype, "langgraph", { get() {
|
|
14
|
+
const zodThis = this;
|
|
15
|
+
return {
|
|
16
|
+
metadata(jsonSchemaExtra) {
|
|
17
|
+
return require_meta.withLangGraph(zodThis, { jsonSchemaExtra });
|
|
18
|
+
},
|
|
19
|
+
reducer(fn, schema) {
|
|
20
|
+
const defaultFn = (0, __langchain_core_utils_types.getInteropZodDefaultGetter)(zodThis);
|
|
21
|
+
return require_meta.withLangGraph(zodThis, {
|
|
22
|
+
default: defaultFn,
|
|
23
|
+
reducer: {
|
|
24
|
+
schema,
|
|
25
|
+
fn
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
} });
|
|
31
|
+
cache.add(prototype);
|
|
36
32
|
}
|
|
37
33
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
throw new Error("Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.", { cause: error });
|
|
34
|
+
applyPluginPrototype(zod_v3.z.ZodType.prototype);
|
|
35
|
+
applyPluginPrototype(zod.z.ZodType.prototype);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
throw new Error("Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.", { cause: error });
|
|
43
38
|
}
|
|
44
|
-
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//# sourceMappingURL=plugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":["withLangGraph","z3","zd"],"sources":["../../../src/graph/zod/plugin.ts"],"sourcesContent":["import { z as zd } from \"zod\";\nimport { z as z3 } from \"zod/v3\";\nimport { getInteropZodDefaultGetter } from \"@langchain/core/utils/types\";\nimport { SchemaMeta, withLangGraph } from \"./meta.js\";\n\nconst metaSymbol = Symbol.for(\"langgraph-zod\");\n\ninterface ZodLangGraphTypes<T extends zd.ZodTypeAny, Output> {\n reducer<Input = zd.output<T>>(\n transform: (a: Output, arg: Input) => Output,\n options?: zd.ZodType<Input>\n ): zd.ZodType<Output, zd.ZodEffectsDef<T>, Input>;\n\n metadata(payload: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\";\n\n [key: string]: unknown;\n }): T;\n}\n\ndeclare module \"zod\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n langgraph: ZodLangGraphTypes<this, Output>;\n }\n}\n\ndeclare module \"zod/v3\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n langgraph: ZodLangGraphTypes<this, Output>;\n }\n}\n\ninterface PluginGlobalType {\n [metaSymbol]?: WeakSet<object>;\n}\n\nif (!(metaSymbol in globalThis)) {\n (globalThis as PluginGlobalType)[metaSymbol] = new WeakSet();\n}\n\nfunction applyPluginPrototype<\n PrototypeToExtend extends\n | typeof zd.ZodType.prototype\n | typeof z3.ZodType.prototype\n>(prototype: PrototypeToExtend) {\n const cache = (globalThis as PluginGlobalType)[metaSymbol]!;\n if (cache.has(prototype)) {\n return; // Already applied\n }\n\n Object.defineProperty(\n prototype,\n \"langgraph\" satisfies keyof PrototypeToExtend,\n {\n get(): zd.ZodType[\"langgraph\"] {\n // Return type is any, actual type provided by module augmentation\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const zodThis = this as zd.ZodTypeAny;\n type Output = zd.infer<typeof zodThis>;\n\n return {\n metadata(\n jsonSchemaExtra: SchemaMeta<Output, Output>[\"jsonSchemaExtra\"]\n ) {\n return withLangGraph(zodThis, { jsonSchemaExtra });\n },\n reducer<Input>(\n fn: (a: Output, arg: Input) => Output,\n schema?: zd.ZodType<Input>\n ) {\n const defaultFn = getInteropZodDefaultGetter(zodThis);\n return withLangGraph(zodThis, {\n default: defaultFn,\n reducer: { schema, fn },\n });\n },\n };\n },\n }\n );\n cache.add(prototype);\n}\n\ntry {\n applyPluginPrototype(z3.ZodType.prototype);\n applyPluginPrototype(zd.ZodType.prototype);\n} catch (error) {\n throw new Error(\n \"Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.\",\n { cause: error }\n );\n}\n"],"mappings":";;;;;;;AAKA,MAAM,aAAa,OAAO,IAAI;AAwC9B,IAAI,EAAE,cAAc,YAClB,CAAC,WAAgC,8BAAc,IAAI;AAGrD,SAAS,qBAIP,WAA8B;CAC9B,MAAM,QAAS,WAAgC;AAC/C,KAAI,MAAM,IAAI,WACZ;AAGF,QAAO,eACL,WACA,aACA,EACE,MAA+B;EAG7B,MAAM,UAAU;AAGhB,SAAO;GACL,SACE,iBACA;AACA,WAAOA,2BAAc,SAAS,EAAE;;GAElC,QACE,IACA,QACA;IACA,MAAM,yEAAuC;AAC7C,WAAOA,2BAAc,SAAS;KAC5B,SAAS;KACT,SAAS;MAAE;MAAQ;;;;;;AAO/B,OAAM,IAAI;;AAGZ,IAAI;AACF,sBAAqBC,SAAG,QAAQ;AAChC,sBAAqBC,MAAG,QAAQ;SACzB,OAAO;AACd,OAAM,IAAI,MACR,sKACA,EAAE,OAAO"}
|
package/dist/graph/zod/plugin.js
CHANGED
|
@@ -1,42 +1,41 @@
|
|
|
1
|
-
import { z as zd } from "zod";
|
|
2
|
-
import { z as z3 } from "zod/v3";
|
|
3
|
-
import { getInteropZodDefaultGetter } from "@langchain/core/utils/types";
|
|
4
1
|
import { withLangGraph } from "./meta.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { getInteropZodDefaultGetter } from "@langchain/core/utils/types";
|
|
4
|
+
import { z as z$1 } from "zod/v3";
|
|
5
|
+
|
|
6
|
+
//#region src/graph/zod/plugin.ts
|
|
5
7
|
const metaSymbol = Symbol.for("langgraph-zod");
|
|
6
|
-
if (!(metaSymbol in globalThis))
|
|
7
|
-
globalThis[metaSymbol] = new WeakSet();
|
|
8
|
-
}
|
|
8
|
+
if (!(metaSymbol in globalThis)) globalThis[metaSymbol] = /* @__PURE__ */ new WeakSet();
|
|
9
9
|
function applyPluginPrototype(prototype) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
cache.add(prototype);
|
|
10
|
+
const cache = globalThis[metaSymbol];
|
|
11
|
+
if (cache.has(prototype)) return;
|
|
12
|
+
Object.defineProperty(prototype, "langgraph", { get() {
|
|
13
|
+
const zodThis = this;
|
|
14
|
+
return {
|
|
15
|
+
metadata(jsonSchemaExtra) {
|
|
16
|
+
return withLangGraph(zodThis, { jsonSchemaExtra });
|
|
17
|
+
},
|
|
18
|
+
reducer(fn, schema) {
|
|
19
|
+
const defaultFn = getInteropZodDefaultGetter(zodThis);
|
|
20
|
+
return withLangGraph(zodThis, {
|
|
21
|
+
default: defaultFn,
|
|
22
|
+
reducer: {
|
|
23
|
+
schema,
|
|
24
|
+
fn
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
} });
|
|
30
|
+
cache.add(prototype);
|
|
34
31
|
}
|
|
35
32
|
try {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
throw new Error("Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.", { cause: error });
|
|
33
|
+
applyPluginPrototype(z$1.ZodType.prototype);
|
|
34
|
+
applyPluginPrototype(z.ZodType.prototype);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throw new Error("Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.", { cause: error });
|
|
41
37
|
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { };
|
|
42
41
|
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","
|
|
1
|
+
{"version":3,"file":"plugin.js","names":["z3","zd"],"sources":["../../../src/graph/zod/plugin.ts"],"sourcesContent":["import { z as zd } from \"zod\";\nimport { z as z3 } from \"zod/v3\";\nimport { getInteropZodDefaultGetter } from \"@langchain/core/utils/types\";\nimport { SchemaMeta, withLangGraph } from \"./meta.js\";\n\nconst metaSymbol = Symbol.for(\"langgraph-zod\");\n\ninterface ZodLangGraphTypes<T extends zd.ZodTypeAny, Output> {\n reducer<Input = zd.output<T>>(\n transform: (a: Output, arg: Input) => Output,\n options?: zd.ZodType<Input>\n ): zd.ZodType<Output, zd.ZodEffectsDef<T>, Input>;\n\n metadata(payload: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\";\n\n [key: string]: unknown;\n }): T;\n}\n\ndeclare module \"zod\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n langgraph: ZodLangGraphTypes<this, Output>;\n }\n}\n\ndeclare module \"zod/v3\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n langgraph: ZodLangGraphTypes<this, Output>;\n }\n}\n\ninterface PluginGlobalType {\n [metaSymbol]?: WeakSet<object>;\n}\n\nif (!(metaSymbol in globalThis)) {\n (globalThis as PluginGlobalType)[metaSymbol] = new WeakSet();\n}\n\nfunction applyPluginPrototype<\n PrototypeToExtend extends\n | typeof zd.ZodType.prototype\n | typeof z3.ZodType.prototype\n>(prototype: PrototypeToExtend) {\n const cache = (globalThis as PluginGlobalType)[metaSymbol]!;\n if (cache.has(prototype)) {\n return; // Already applied\n }\n\n Object.defineProperty(\n prototype,\n \"langgraph\" satisfies keyof PrototypeToExtend,\n {\n get(): zd.ZodType[\"langgraph\"] {\n // Return type is any, actual type provided by module augmentation\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const zodThis = this as zd.ZodTypeAny;\n type Output = zd.infer<typeof zodThis>;\n\n return {\n metadata(\n jsonSchemaExtra: SchemaMeta<Output, Output>[\"jsonSchemaExtra\"]\n ) {\n return withLangGraph(zodThis, { jsonSchemaExtra });\n },\n reducer<Input>(\n fn: (a: Output, arg: Input) => Output,\n schema?: zd.ZodType<Input>\n ) {\n const defaultFn = getInteropZodDefaultGetter(zodThis);\n return withLangGraph(zodThis, {\n default: defaultFn,\n reducer: { schema, fn },\n });\n },\n };\n },\n }\n );\n cache.add(prototype);\n}\n\ntry {\n applyPluginPrototype(z3.ZodType.prototype);\n applyPluginPrototype(zd.ZodType.prototype);\n} catch (error) {\n throw new Error(\n \"Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.\",\n { cause: error }\n );\n}\n"],"mappings":";;;;;;AAKA,MAAM,aAAa,OAAO,IAAI;AAwC9B,IAAI,EAAE,cAAc,YAClB,CAAC,WAAgC,8BAAc,IAAI;AAGrD,SAAS,qBAIP,WAA8B;CAC9B,MAAM,QAAS,WAAgC;AAC/C,KAAI,MAAM,IAAI,WACZ;AAGF,QAAO,eACL,WACA,aACA,EACE,MAA+B;EAG7B,MAAM,UAAU;AAGhB,SAAO;GACL,SACE,iBACA;AACA,WAAO,cAAc,SAAS,EAAE;;GAElC,QACE,IACA,QACA;IACA,MAAM,YAAY,2BAA2B;AAC7C,WAAO,cAAc,SAAS;KAC5B,SAAS;KACT,SAAS;MAAE;MAAQ;;;;;;AAO/B,OAAM,IAAI;;AAGZ,IAAI;AACF,sBAAqBA,IAAG,QAAQ;AAChC,sBAAqBC,EAAG,QAAQ;SACzB,OAAO;AACd,OAAM,IAAI,MACR,sKACA,EAAE,OAAO"}
|