@langchain/langgraph 1.0.12 → 1.0.14
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/dist/channels/any_value.cjs +46 -0
- package/dist/channels/any_value.cjs.map +1 -0
- package/dist/channels/any_value.d.cts +23 -0
- package/dist/channels/any_value.d.cts.map +1 -0
- package/dist/channels/any_value.d.ts +23 -0
- package/dist/channels/any_value.d.ts.map +1 -0
- package/dist/channels/any_value.js +46 -0
- package/dist/channels/any_value.js.map +1 -0
- package/dist/channels/base.cjs +101 -0
- package/dist/channels/base.cjs.map +1 -0
- package/dist/channels/base.d.cts +79 -0
- package/dist/channels/base.d.cts.map +1 -0
- package/dist/channels/base.d.ts +79 -0
- package/dist/channels/base.d.ts.map +1 -0
- package/dist/channels/base.js +97 -0
- package/dist/channels/base.js.map +1 -0
- package/dist/channels/binop.cjs +49 -0
- 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 +22 -0
- package/dist/channels/binop.d.ts.map +1 -0
- package/dist/channels/binop.js +49 -0
- package/dist/channels/binop.js.map +1 -0
- package/dist/channels/dynamic_barrier_value.cjs +75 -0
- package/dist/channels/dynamic_barrier_value.cjs.map +1 -0
- package/dist/channels/dynamic_barrier_value.d.cts +40 -0
- package/dist/channels/dynamic_barrier_value.d.cts.map +1 -0
- package/dist/channels/dynamic_barrier_value.d.ts +40 -0
- package/dist/channels/dynamic_barrier_value.d.ts.map +1 -0
- package/dist/channels/dynamic_barrier_value.js +75 -0
- package/dist/channels/dynamic_barrier_value.js.map +1 -0
- package/dist/channels/ephemeral_value.cjs +46 -0
- package/dist/channels/ephemeral_value.cjs.map +1 -0
- package/dist/channels/ephemeral_value.d.cts +21 -0
- package/dist/channels/ephemeral_value.d.cts.map +1 -0
- package/dist/channels/ephemeral_value.d.ts +21 -0
- package/dist/channels/ephemeral_value.d.ts.map +1 -0
- package/dist/channels/ephemeral_value.js +46 -0
- package/dist/channels/ephemeral_value.js.map +1 -0
- package/dist/channels/index.cjs +21 -0
- package/dist/channels/index.d.cts +9 -0
- package/dist/channels/index.d.ts +9 -0
- package/dist/channels/index.js +10 -0
- package/dist/channels/last_value.cjs +98 -0
- package/dist/channels/last_value.cjs.map +1 -0
- package/dist/channels/last_value.d.cts +42 -0
- package/dist/channels/last_value.d.cts.map +1 -0
- package/dist/channels/last_value.d.ts +42 -0
- package/dist/channels/last_value.d.ts.map +1 -0
- package/dist/channels/last_value.js +97 -0
- package/dist/channels/last_value.js.map +1 -0
- package/dist/channels/named_barrier_value.cjs +116 -0
- package/dist/channels/named_barrier_value.cjs.map +1 -0
- package/dist/channels/named_barrier_value.d.cts +44 -0
- package/dist/channels/named_barrier_value.d.cts.map +1 -0
- package/dist/channels/named_barrier_value.d.ts +44 -0
- package/dist/channels/named_barrier_value.d.ts.map +1 -0
- package/dist/channels/named_barrier_value.js +114 -0
- package/dist/channels/named_barrier_value.js.map +1 -0
- package/dist/channels/topic.cjs +65 -0
- package/dist/channels/topic.cjs.map +1 -0
- package/dist/channels/topic.d.cts +32 -0
- package/dist/channels/topic.d.cts.map +1 -0
- package/dist/channels/topic.d.ts +32 -0
- package/dist/channels/topic.d.ts.map +1 -0
- package/dist/channels/topic.js +65 -0
- package/dist/channels/topic.js.map +1 -0
- package/dist/constants.cjs +406 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +281 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.ts +281 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +362 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors.cjs +163 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +77 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.ts +77 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +146 -0
- package/dist/errors.js.map +1 -0
- package/dist/func/index.cjs +299 -0
- package/dist/func/index.cjs.map +1 -0
- package/dist/func/index.d.cts +288 -0
- package/dist/func/index.d.cts.map +1 -0
- package/dist/func/index.d.ts +288 -0
- package/dist/func/index.d.ts.map +1 -0
- package/dist/func/index.js +297 -0
- package/dist/func/index.js.map +1 -0
- package/dist/func/types.d.cts +62 -0
- package/dist/func/types.d.cts.map +1 -0
- package/dist/func/types.d.ts +62 -0
- package/dist/func/types.d.ts.map +1 -0
- package/dist/graph/annotation.cjs +101 -0
- 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 +116 -0
- package/dist/graph/annotation.d.ts.map +1 -0
- package/dist/graph/annotation.js +99 -0
- package/dist/graph/annotation.js.map +1 -0
- package/dist/graph/graph.cjs +420 -0
- package/dist/graph/graph.cjs.map +1 -0
- package/dist/graph/graph.d.cts +108 -0
- package/dist/graph/graph.d.cts.map +1 -0
- package/dist/graph/graph.d.ts +108 -0
- package/dist/graph/graph.d.ts.map +1 -0
- package/dist/graph/graph.js +418 -0
- package/dist/graph/graph.js.map +1 -0
- package/dist/graph/index.cjs +5 -0
- package/dist/graph/index.js +7 -0
- package/dist/graph/message.cjs +97 -0
- package/dist/graph/message.cjs.map +1 -0
- package/dist/graph/message.d.cts +40 -0
- package/dist/graph/message.d.cts.map +1 -0
- package/dist/graph/message.d.ts +40 -0
- package/dist/graph/message.d.ts.map +1 -0
- package/dist/graph/message.js +94 -0
- package/dist/graph/message.js.map +1 -0
- package/dist/graph/messages_annotation.cjs +109 -0
- package/dist/graph/messages_annotation.cjs.map +1 -0
- package/dist/graph/messages_annotation.d.cts +112 -0
- package/dist/graph/messages_annotation.d.cts.map +1 -0
- package/dist/graph/messages_annotation.d.ts +112 -0
- package/dist/graph/messages_annotation.d.ts.map +1 -0
- package/dist/graph/messages_annotation.js +107 -0
- package/dist/graph/messages_annotation.js.map +1 -0
- package/dist/graph/state.cjs +494 -0
- package/dist/graph/state.cjs.map +1 -0
- package/dist/graph/state.d.cts +229 -0
- package/dist/graph/state.d.cts.map +1 -0
- package/dist/graph/state.d.ts +229 -0
- package/dist/graph/state.d.ts.map +1 -0
- package/dist/graph/state.js +493 -0
- package/dist/graph/state.js.map +1 -0
- package/dist/graph/zod/index.cjs +10 -0
- package/dist/graph/zod/index.d.cts +3 -0
- package/dist/graph/zod/index.d.ts +3 -0
- package/dist/graph/zod/index.js +5 -0
- package/dist/graph/zod/meta.cjs +144 -0
- package/dist/graph/zod/meta.cjs.map +1 -0
- package/dist/graph/zod/meta.d.cts +115 -0
- package/dist/graph/zod/meta.d.cts.map +1 -0
- package/dist/graph/zod/meta.d.ts +115 -0
- package/dist/graph/zod/meta.d.ts.map +1 -0
- package/dist/graph/zod/meta.js +141 -0
- package/dist/graph/zod/meta.js.map +1 -0
- package/dist/graph/zod/plugin.cjs +39 -0
- package/dist/graph/zod/plugin.cjs.map +1 -0
- package/dist/graph/zod/plugin.js +40 -0
- package/dist/graph/zod/plugin.js.map +1 -0
- package/dist/graph/zod/schema.cjs +98 -0
- 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 +38 -0
- package/dist/graph/zod/schema.d.ts.map +1 -0
- package/dist/graph/zod/schema.js +94 -0
- package/dist/graph/zod/schema.js.map +1 -0
- package/dist/graph/zod/zod-registry.cjs +42 -0
- package/dist/graph/zod/zod-registry.cjs.map +1 -0
- package/dist/graph/zod/zod-registry.d.cts +49 -0
- package/dist/graph/zod/zod-registry.d.cts.map +1 -0
- package/dist/graph/zod/zod-registry.d.ts +49 -0
- package/dist/graph/zod/zod-registry.d.ts.map +1 -0
- package/dist/graph/zod/zod-registry.js +41 -0
- package/dist/graph/zod/zod-registry.js.map +1 -0
- package/dist/hash.cjs +265 -0
- package/dist/hash.cjs.map +1 -0
- package/dist/hash.js +263 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.cjs +111 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/interrupt.cjs +79 -0
- package/dist/interrupt.cjs.map +1 -0
- package/dist/interrupt.d.cts +55 -0
- package/dist/interrupt.d.cts.map +1 -0
- package/dist/interrupt.d.ts +55 -0
- package/dist/interrupt.d.ts.map +1 -0
- package/dist/interrupt.js +79 -0
- package/dist/interrupt.js.map +1 -0
- package/dist/prebuilt/agentName.cjs +148 -0
- 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 +42 -0
- package/dist/prebuilt/agentName.d.ts.map +1 -0
- package/dist/prebuilt/agentName.js +148 -0
- package/dist/prebuilt/agentName.js.map +1 -0
- package/dist/prebuilt/agent_executor.cjs +41 -0
- package/dist/prebuilt/agent_executor.cjs.map +1 -0
- package/dist/prebuilt/agent_executor.d.cts +58 -0
- package/dist/prebuilt/agent_executor.d.cts.map +1 -0
- package/dist/prebuilt/agent_executor.d.ts +58 -0
- package/dist/prebuilt/agent_executor.d.ts.map +1 -0
- package/dist/prebuilt/agent_executor.js +41 -0
- package/dist/prebuilt/agent_executor.js.map +1 -0
- package/dist/prebuilt/chat_agent_executor.cjs +62 -0
- 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 +23 -0
- package/dist/prebuilt/chat_agent_executor.d.ts.map +1 -0
- package/dist/prebuilt/chat_agent_executor.js +62 -0
- package/dist/prebuilt/chat_agent_executor.js.map +1 -0
- package/dist/prebuilt/index.cjs +15 -0
- package/dist/prebuilt/index.d.cts +8 -0
- package/dist/prebuilt/index.d.ts +8 -0
- package/dist/prebuilt/index.js +8 -0
- package/dist/prebuilt/interrupt.d.cts +60 -0
- package/dist/prebuilt/interrupt.d.cts.map +1 -0
- package/dist/prebuilt/interrupt.d.ts +60 -0
- package/dist/prebuilt/interrupt.d.ts.map +1 -0
- package/dist/prebuilt/react_agent_executor.cjs +339 -0
- package/dist/prebuilt/react_agent_executor.cjs.map +1 -0
- package/dist/prebuilt/react_agent_executor.d.cts +211 -0
- package/dist/prebuilt/react_agent_executor.d.cts.map +1 -0
- package/dist/prebuilt/react_agent_executor.d.ts +211 -0
- package/dist/prebuilt/react_agent_executor.d.ts.map +1 -0
- package/dist/prebuilt/react_agent_executor.js +338 -0
- package/dist/prebuilt/react_agent_executor.js.map +1 -0
- package/dist/prebuilt/tool_executor.cjs +43 -0
- package/dist/prebuilt/tool_executor.cjs.map +1 -0
- package/dist/prebuilt/tool_executor.d.cts +40 -0
- package/dist/prebuilt/tool_executor.d.cts.map +1 -0
- package/dist/prebuilt/tool_executor.d.ts +40 -0
- package/dist/prebuilt/tool_executor.d.ts.map +1 -0
- package/dist/prebuilt/tool_executor.js +43 -0
- package/dist/prebuilt/tool_executor.js.map +1 -0
- package/dist/prebuilt/tool_node.cjs +247 -0
- package/dist/prebuilt/tool_node.cjs.map +1 -0
- package/dist/prebuilt/tool_node.d.cts +180 -0
- package/dist/prebuilt/tool_node.d.cts.map +1 -0
- package/dist/prebuilt/tool_node.d.ts +180 -0
- package/dist/prebuilt/tool_node.d.ts.map +1 -0
- package/dist/prebuilt/tool_node.js +246 -0
- package/dist/prebuilt/tool_node.js.map +1 -0
- package/dist/pregel/algo.cjs +565 -0
- 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 +13 -0
- package/dist/pregel/algo.d.ts.map +1 -0
- package/dist/pregel/algo.js +560 -0
- package/dist/pregel/algo.js.map +1 -0
- package/dist/pregel/call.cjs +50 -0
- package/dist/pregel/call.cjs.map +1 -0
- package/dist/pregel/call.js +48 -0
- package/dist/pregel/call.js.map +1 -0
- package/dist/pregel/debug.cjs +172 -0
- package/dist/pregel/debug.cjs.map +1 -0
- package/dist/pregel/debug.js +166 -0
- package/dist/pregel/debug.js.map +1 -0
- package/dist/pregel/index.cjs +1163 -0
- package/dist/pregel/index.cjs.map +1 -0
- package/dist/pregel/index.d.cts +498 -0
- package/dist/pregel/index.d.cts.map +1 -0
- package/dist/pregel/index.d.ts +498 -0
- package/dist/pregel/index.d.ts.map +1 -0
- package/dist/pregel/index.js +1162 -0
- package/dist/pregel/index.js.map +1 -0
- package/dist/pregel/io.cjs +140 -0
- package/dist/pregel/io.cjs.map +1 -0
- package/dist/pregel/io.js +135 -0
- package/dist/pregel/io.js.map +1 -0
- package/dist/pregel/loop.cjs +545 -0
- package/dist/pregel/loop.cjs.map +1 -0
- package/dist/pregel/loop.js +545 -0
- package/dist/pregel/loop.js.map +1 -0
- package/dist/pregel/messages.cjs +107 -0
- package/dist/pregel/messages.cjs.map +1 -0
- package/dist/pregel/messages.js +107 -0
- package/dist/pregel/messages.js.map +1 -0
- package/dist/pregel/read.cjs +151 -0
- package/dist/pregel/read.cjs.map +1 -0
- package/dist/pregel/read.d.cts +45 -0
- package/dist/pregel/read.d.cts.map +1 -0
- package/dist/pregel/read.d.ts +45 -0
- package/dist/pregel/read.d.ts.map +1 -0
- package/dist/pregel/read.js +150 -0
- package/dist/pregel/read.js.map +1 -0
- package/dist/pregel/remote.cjs +341 -0
- package/dist/pregel/remote.cjs.map +1 -0
- package/dist/pregel/remote.d.cts +118 -0
- package/dist/pregel/remote.d.cts.map +1 -0
- package/dist/pregel/remote.d.ts +118 -0
- package/dist/pregel/remote.d.ts.map +1 -0
- package/dist/pregel/remote.js +341 -0
- package/dist/pregel/remote.js.map +1 -0
- package/dist/pregel/retry.cjs +91 -0
- package/dist/pregel/retry.cjs.map +1 -0
- package/dist/pregel/retry.js +91 -0
- package/dist/pregel/retry.js.map +1 -0
- package/dist/pregel/runnable_types.d.cts +43 -0
- package/dist/pregel/runnable_types.d.cts.map +1 -0
- package/dist/pregel/runnable_types.d.ts +43 -0
- package/dist/pregel/runnable_types.d.ts.map +1 -0
- package/dist/pregel/runner.cjs +228 -0
- package/dist/pregel/runner.cjs.map +1 -0
- package/dist/pregel/runner.js +228 -0
- package/dist/pregel/runner.js.map +1 -0
- package/dist/pregel/stream.cjs +197 -0
- package/dist/pregel/stream.cjs.map +1 -0
- package/dist/pregel/stream.js +195 -0
- package/dist/pregel/stream.js.map +1 -0
- package/dist/pregel/types.cjs +27 -0
- package/dist/pregel/types.cjs.map +1 -0
- package/dist/pregel/types.d.cts +440 -0
- package/dist/pregel/types.d.cts.map +1 -0
- package/dist/pregel/types.d.ts +440 -0
- package/dist/pregel/types.d.ts.map +1 -0
- package/dist/pregel/types.js +25 -0
- package/dist/pregel/types.js.map +1 -0
- package/dist/pregel/utils/config.cjs +121 -0
- 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 +36 -0
- package/dist/pregel/utils/config.d.ts.map +1 -0
- package/dist/pregel/utils/config.js +115 -0
- package/dist/pregel/utils/config.js.map +1 -0
- package/dist/pregel/utils/index.cjs +102 -0
- 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 +51 -0
- package/dist/pregel/utils/index.d.ts.map +1 -0
- package/dist/pregel/utils/index.js +96 -0
- package/dist/pregel/utils/index.js.map +1 -0
- package/dist/pregel/utils/subgraph.cjs +18 -0
- package/dist/pregel/utils/subgraph.cjs.map +1 -0
- package/dist/pregel/utils/subgraph.js +16 -0
- package/dist/pregel/utils/subgraph.js.map +1 -0
- package/dist/pregel/validate.cjs +45 -0
- package/dist/pregel/validate.cjs.map +1 -0
- package/dist/pregel/validate.js +44 -0
- package/dist/pregel/validate.js.map +1 -0
- package/dist/pregel/write.cjs +96 -0
- package/dist/pregel/write.cjs.map +1 -0
- package/dist/pregel/write.d.cts +31 -0
- package/dist/pregel/write.d.cts.map +1 -0
- package/dist/pregel/write.d.ts +31 -0
- package/dist/pregel/write.d.ts.map +1 -0
- package/dist/pregel/write.js +95 -0
- package/dist/pregel/write.js.map +1 -0
- package/dist/remote.cjs +3 -0
- package/dist/remote.d.cts +2 -0
- package/dist/remote.d.ts +2 -0
- package/dist/remote.js +3 -0
- package/dist/setup/async_local_storage.cjs +11 -0
- package/dist/setup/async_local_storage.cjs.map +1 -0
- package/dist/setup/async_local_storage.js +11 -0
- package/dist/setup/async_local_storage.js.map +1 -0
- package/dist/utils.cjs +86 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +25 -0
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.ts +25 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +80 -0
- package/dist/utils.js.map +1 -0
- package/dist/web.cjs +95 -0
- package/dist/web.d.cts +23 -0
- package/dist/web.d.ts +23 -0
- package/dist/web.js +15 -0
- package/dist/writer.cjs +14 -0
- package/dist/writer.cjs.map +1 -0
- package/dist/writer.d.cts +6 -0
- package/dist/writer.d.cts.map +1 -0
- package/dist/writer.d.ts +6 -0
- package/dist/writer.d.ts.map +1 -0
- package/dist/writer.js +14 -0
- package/dist/writer.js.map +1 -0
- package/package.json +25 -27
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.cts","names":["Runnable","RunnableConfig","Graph","DrawableGraph","All","BaseCheckpointSaver","RunnableLike","LangGraphRunnableConfig","PregelNode","Pregel","PregelParams","BaseChannel","END","Send","START","RunnableCallable","StateDefinition","StateType","BranchOptions","N","IO","BranchPathReturnValue","CallOptions","Record","Promise","NodeAction","S","U","C","Branch","Omit","NodeSpec","RunInput","RunOutput","AddNodeOptions","Nodes","NodeSpecType","Set","K","NodeInput","NodeOutput","checkpointer","interruptBefore","interruptAfter","name","CompiledGraph","State","Update","ContextType","InputType","OutputType","NodeReturnType","CommandType","StreamCustomType","builder"],"sources":["../../src/graph/graph.d.ts"],"sourcesContent":["import { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport { Graph as DrawableGraph } from \"@langchain/core/runnables/graph\";\nimport { All, BaseCheckpointSaver } from \"@langchain/langgraph-checkpoint\";\nimport type { RunnableLike, LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { Pregel } from \"../pregel/index.js\";\nimport type { PregelParams } from \"../pregel/types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { END, Send, START } from \"../constants.js\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { StateDefinition, StateType } from \"./annotation.js\";\nexport interface BranchOptions<IO, N extends string, CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig> {\n source: N;\n path: RunnableLike<IO, BranchPathReturnValue, CallOptions>;\n pathMap?: Record<string, N | typeof END> | (N | typeof END)[];\n}\nexport type BranchPathReturnValue = string | Send | (string | Send)[] | Promise<string | Send | (string | Send)[]>;\ntype NodeAction<S, U, C extends StateDefinition> = RunnableLike<S, U extends object ? U & Record<string, any> : U, LangGraphRunnableConfig<StateType<C>>>;\nexport declare class Branch<IO, N extends string, CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig> {\n path: Runnable<IO, BranchPathReturnValue, CallOptions>;\n ends?: Record<string, N | typeof END>;\n constructor(options: Omit<BranchOptions<IO, N, CallOptions>, \"source\">);\n run(writer: (dests: (string | Send)[], config: LangGraphRunnableConfig) => Runnable | void | Promise<void>, reader?: (config: CallOptions) => IO): RunnableCallable<unknown, unknown>;\n _route(input: IO, config: CallOptions, writer: (dests: (string | Send)[], config: LangGraphRunnableConfig) => Runnable | void | Promise<void>, reader?: (config: CallOptions) => IO): Promise<Runnable | any>;\n}\nexport type NodeSpec<RunInput, RunOutput> = {\n runnable: Runnable<RunInput, RunOutput>;\n metadata?: Record<string, unknown>;\n subgraphs?: Pregel<any, any>[];\n ends?: string[];\n defer?: boolean;\n};\nexport type AddNodeOptions<Nodes extends string = string> = {\n metadata?: Record<string, unknown>;\n subgraphs?: Pregel<any, any>[];\n ends?: Nodes[];\n defer?: boolean;\n};\nexport declare class Graph<N extends string = typeof START | typeof END, RunInput = any, RunOutput = any, NodeSpecType extends NodeSpec<RunInput, RunOutput> = NodeSpec<RunInput, RunOutput>, C extends StateDefinition = StateDefinition> {\n nodes: Record<N, NodeSpecType>;\n edges: Set<[N | typeof START, N | typeof END]>;\n branches: Record<string, Record<string, Branch<RunInput, N, any>>>;\n entryPoint?: string;\n compiled: boolean;\n constructor();\n protected warnIfCompiled(message: string): void;\n get allEdges(): Set<[string, string]>;\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(nodes: Record<K, NodeAction<NodeInput, NodeOutput, C>> | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ][]): Graph<N | K, RunInput, RunOutput>;\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(key: K, action: NodeAction<NodeInput, NodeOutput, C>, options?: AddNodeOptions): Graph<N | K, RunInput, RunOutput>;\n addEdge(startKey: N | typeof START, endKey: N | typeof END): this;\n addConditionalEdges(source: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>): this;\n addConditionalEdges(source: N, path: RunnableLike<RunInput, BranchPathReturnValue, LangGraphRunnableConfig<StateType<C>>>, pathMap?: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>[\"pathMap\"]): this;\n /**\n * @deprecated use `addEdge(START, key)` instead\n */\n setEntryPoint(key: N): this;\n /**\n * @deprecated use `addEdge(key, END)` instead\n */\n setFinishPoint(key: N): this;\n compile({ checkpointer, interruptBefore, interruptAfter, name }?: {\n checkpointer?: BaseCheckpointSaver | false;\n interruptBefore?: N[] | All;\n interruptAfter?: N[] | All;\n name?: string;\n }): CompiledGraph<N>;\n validate(interrupt?: string[]): void;\n}\nexport declare class CompiledGraph<N extends string, State = any, Update = any, ContextType extends Record<string, any> = Record<string, any>, InputType = any, OutputType = any, NodeReturnType = unknown, CommandType = unknown, StreamCustomType = any> extends Pregel<Record<N | typeof START, PregelNode<State, Update>>, Record<N | typeof START | typeof END | string, BaseChannel>, ContextType & Record<string, any>, InputType, OutputType, InputType, OutputType, NodeReturnType, CommandType, StreamCustomType> {\n \"~NodeType\": N;\n \"~NodeReturnType\": NodeReturnType;\n \"~RunInput\": Update;\n \"~RunOutput\": State;\n builder: Graph<N, State, Update>;\n constructor({ builder, ...rest }: {\n builder: Graph<N, State, Update>;\n } & PregelParams<Record<N | typeof START, PregelNode<State, Update>>, Record<N | typeof START | typeof END | string, BaseChannel>>);\n attachNode(key: N, node: NodeSpec<State, Update>): void;\n attachEdge(start: N | typeof START, end: N | typeof END): void;\n attachBranch(start: N | typeof START, name: string, branch: Branch<State, N>): void;\n /**\n * Returns a drawable representation of the computation graph.\n */\n getGraphAsync(config?: RunnableConfig & {\n xray?: boolean | number;\n }): Promise<DrawableGraph>;\n /**\n * Returns a drawable representation of the computation graph.\n *\n * @deprecated Use getGraphAsync instead. The async method will be the default in the next minor core release.\n */\n getGraph(config?: RunnableConfig & {\n xray?: boolean | number;\n }): DrawableGraph;\n}\nexport {};\n"],"mappings":";;;;;;;;;;;;;UAWiBkB,wDAAwDX,0BAA0BA;UACvFY;EADKD,IAAAA,EAEPZ,cAFoB,CAEPc,EAFO,EAEHC,qBAFG,EAEoBC,WAFpB,CAAA;EAAA,OAAA,CAAA,EAGhBC,MAHgB,CAAA,MAAA,EAGDJ,CAHC,GAAA,OAGUP,GAHV,CAAA,GAAA,CAGkBO,CAHlB,GAAA,OAG6BP,GAH7B,CAAA,EAAA;;AAAqEL,KAKvFc,qBAAAA,GALuFd,MAAAA,GAKtDM,IALsDN,GAAAA,CAAAA,MAAAA,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AA,MAAA,EA0D4Ce,MA1D5C,CA0DmDiB,KA1DnD,EA0D0D3B,CA1D1D,CAAA,CAAA,EAAA,IAAA;EAAA;;;eACNnB,CAAAA,OAAAA,EA6DaC,cA7DbD,GAAAA;IACCuB,IAAAA,CAAAA,EAAAA,OAAAA,GAAAA,MAAAA;MA8DPC,OA7DQf,CA6DAN,KA7DAM,CAAAA;EAAM;AAItB;;;;UAGW0B,CAAAA,MAGUjC,CAHViC,EA4DWlC,cA5DXkC,GAAAA;IAAK,IAAA,CAAA,EAAA,OAAA,GAAA,MAAA;EAGKjC,CAAAA,CAAAA,EA2DbC,KA3DkB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { BaseChannel } from "../channels/base.js";
|
|
2
|
+
import { LangGraphRunnableConfig, RunnableLike as RunnableLike$1 } from "../pregel/runnable_types.js";
|
|
3
|
+
import { StateDefinition, StateType } from "./annotation.js";
|
|
4
|
+
import { RunnableCallable } from "../utils.js";
|
|
5
|
+
import { PregelNode } from "../pregel/read.js";
|
|
6
|
+
import { END, START, Send } from "../constants.js";
|
|
7
|
+
import { PregelParams } from "../pregel/types.js";
|
|
8
|
+
import { Pregel } from "../pregel/index.js";
|
|
9
|
+
import { All, BaseCheckpointSaver } from "@langchain/langgraph-checkpoint";
|
|
10
|
+
import { Runnable, RunnableConfig } from "@langchain/core/runnables";
|
|
11
|
+
import { Graph } from "@langchain/core/runnables/graph";
|
|
12
|
+
|
|
13
|
+
//#region src/graph/graph.d.ts
|
|
14
|
+
interface BranchOptions<IO, N extends string, CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig> {
|
|
15
|
+
source: N;
|
|
16
|
+
path: RunnableLike$1<IO, BranchPathReturnValue, CallOptions>;
|
|
17
|
+
pathMap?: Record<string, N | typeof END> | (N | typeof END)[];
|
|
18
|
+
}
|
|
19
|
+
type BranchPathReturnValue = string | Send | (string | Send)[] | Promise<string | Send | (string | Send)[]>;
|
|
20
|
+
type NodeAction<S, U, C extends StateDefinition> = RunnableLike$1<S, U extends object ? U & Record<string, any> : U, LangGraphRunnableConfig<StateType<C>>>;
|
|
21
|
+
declare class Branch<IO, N extends string, CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig> {
|
|
22
|
+
path: Runnable<IO, BranchPathReturnValue, CallOptions>;
|
|
23
|
+
ends?: Record<string, N | typeof END>;
|
|
24
|
+
constructor(options: Omit<BranchOptions<IO, N, CallOptions>, "source">);
|
|
25
|
+
run(writer: (dests: (string | Send)[], config: LangGraphRunnableConfig) => Runnable | void | Promise<void>, reader?: (config: CallOptions) => IO): RunnableCallable<unknown, unknown>;
|
|
26
|
+
_route(input: IO, config: CallOptions, writer: (dests: (string | Send)[], config: LangGraphRunnableConfig) => Runnable | void | Promise<void>, reader?: (config: CallOptions) => IO): Promise<Runnable | any>;
|
|
27
|
+
}
|
|
28
|
+
type NodeSpec<RunInput, RunOutput> = {
|
|
29
|
+
runnable: Runnable<RunInput, RunOutput>;
|
|
30
|
+
metadata?: Record<string, unknown>;
|
|
31
|
+
subgraphs?: Pregel<any, any>[];
|
|
32
|
+
ends?: string[];
|
|
33
|
+
defer?: boolean;
|
|
34
|
+
};
|
|
35
|
+
type AddNodeOptions<Nodes extends string = string> = {
|
|
36
|
+
metadata?: Record<string, unknown>;
|
|
37
|
+
subgraphs?: Pregel<any, any>[];
|
|
38
|
+
ends?: Nodes[];
|
|
39
|
+
defer?: boolean;
|
|
40
|
+
};
|
|
41
|
+
declare class Graph$1<N extends string = typeof START | typeof END, RunInput = any, RunOutput = any, NodeSpecType extends NodeSpec<RunInput, RunOutput> = NodeSpec<RunInput, RunOutput>, C extends StateDefinition = StateDefinition> {
|
|
42
|
+
nodes: Record<N, NodeSpecType>;
|
|
43
|
+
edges: Set<[N | typeof START, N | typeof END]>;
|
|
44
|
+
branches: Record<string, Record<string, Branch<RunInput, N, any>>>;
|
|
45
|
+
entryPoint?: string;
|
|
46
|
+
compiled: boolean;
|
|
47
|
+
constructor();
|
|
48
|
+
protected warnIfCompiled(message: string): void;
|
|
49
|
+
get allEdges(): Set<[string, string]>;
|
|
50
|
+
addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(nodes: Record<K, NodeAction<NodeInput, NodeOutput, C>> | [key: K, action: NodeAction<NodeInput, NodeOutput, C>, options?: AddNodeOptions][]): Graph$1<N | K, RunInput, RunOutput>;
|
|
51
|
+
addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(key: K, action: NodeAction<NodeInput, NodeOutput, C>, options?: AddNodeOptions): Graph$1<N | K, RunInput, RunOutput>;
|
|
52
|
+
addEdge(startKey: N | typeof START, endKey: N | typeof END): this;
|
|
53
|
+
addConditionalEdges(source: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>): this;
|
|
54
|
+
addConditionalEdges(source: N, path: RunnableLike$1<RunInput, BranchPathReturnValue, LangGraphRunnableConfig<StateType<C>>>, pathMap?: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>["pathMap"]): this;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated use `addEdge(START, key)` instead
|
|
57
|
+
*/
|
|
58
|
+
setEntryPoint(key: N): this;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated use `addEdge(key, END)` instead
|
|
61
|
+
*/
|
|
62
|
+
setFinishPoint(key: N): this;
|
|
63
|
+
compile({
|
|
64
|
+
checkpointer,
|
|
65
|
+
interruptBefore,
|
|
66
|
+
interruptAfter,
|
|
67
|
+
name
|
|
68
|
+
}?: {
|
|
69
|
+
checkpointer?: BaseCheckpointSaver | false;
|
|
70
|
+
interruptBefore?: N[] | All;
|
|
71
|
+
interruptAfter?: N[] | All;
|
|
72
|
+
name?: string;
|
|
73
|
+
}): CompiledGraph<N>;
|
|
74
|
+
validate(interrupt?: string[]): void;
|
|
75
|
+
}
|
|
76
|
+
declare class CompiledGraph<N extends string, State = any, Update = any, ContextType extends Record<string, any> = Record<string, any>, InputType = any, OutputType = any, NodeReturnType = unknown, CommandType = unknown, StreamCustomType = any> extends Pregel<Record<N | typeof START, PregelNode<State, Update>>, Record<N | typeof START | typeof END | string, BaseChannel>, ContextType & Record<string, any>, InputType, OutputType, InputType, OutputType, NodeReturnType, CommandType, StreamCustomType> {
|
|
77
|
+
"~NodeType": N;
|
|
78
|
+
"~NodeReturnType": NodeReturnType;
|
|
79
|
+
"~RunInput": Update;
|
|
80
|
+
"~RunOutput": State;
|
|
81
|
+
builder: Graph$1<N, State, Update>;
|
|
82
|
+
constructor({
|
|
83
|
+
builder,
|
|
84
|
+
...rest
|
|
85
|
+
}: {
|
|
86
|
+
builder: Graph$1<N, State, Update>;
|
|
87
|
+
} & PregelParams<Record<N | typeof START, PregelNode<State, Update>>, Record<N | typeof START | typeof END | string, BaseChannel>>);
|
|
88
|
+
attachNode(key: N, node: NodeSpec<State, Update>): void;
|
|
89
|
+
attachEdge(start: N | typeof START, end: N | typeof END): void;
|
|
90
|
+
attachBranch(start: N | typeof START, name: string, branch: Branch<State, N>): void;
|
|
91
|
+
/**
|
|
92
|
+
* Returns a drawable representation of the computation graph.
|
|
93
|
+
*/
|
|
94
|
+
getGraphAsync(config?: RunnableConfig & {
|
|
95
|
+
xray?: boolean | number;
|
|
96
|
+
}): Promise<Graph>;
|
|
97
|
+
/**
|
|
98
|
+
* Returns a drawable representation of the computation graph.
|
|
99
|
+
*
|
|
100
|
+
* @deprecated Use getGraphAsync instead. The async method will be the default in the next minor core release.
|
|
101
|
+
*/
|
|
102
|
+
getGraph(config?: RunnableConfig & {
|
|
103
|
+
xray?: boolean | number;
|
|
104
|
+
}): Graph;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { AddNodeOptions, Branch, CompiledGraph, Graph$1 as Graph, NodeSpec };
|
|
108
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","names":["Runnable","RunnableConfig","Graph","DrawableGraph","All","BaseCheckpointSaver","RunnableLike","LangGraphRunnableConfig","PregelNode","Pregel","PregelParams","BaseChannel","END","Send","START","RunnableCallable","StateDefinition","StateType","BranchOptions","N","IO","BranchPathReturnValue","CallOptions","Record","Promise","NodeAction","S","U","C","Branch","Omit","NodeSpec","RunInput","RunOutput","AddNodeOptions","Nodes","NodeSpecType","Set","K","NodeInput","NodeOutput","checkpointer","interruptBefore","interruptAfter","name","CompiledGraph","State","Update","ContextType","InputType","OutputType","NodeReturnType","CommandType","StreamCustomType","builder"],"sources":["../../src/graph/graph.d.ts"],"sourcesContent":["import { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport { Graph as DrawableGraph } from \"@langchain/core/runnables/graph\";\nimport { All, BaseCheckpointSaver } from \"@langchain/langgraph-checkpoint\";\nimport type { RunnableLike, LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { Pregel } from \"../pregel/index.js\";\nimport type { PregelParams } from \"../pregel/types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { END, Send, START } from \"../constants.js\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { StateDefinition, StateType } from \"./annotation.js\";\nexport interface BranchOptions<IO, N extends string, CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig> {\n source: N;\n path: RunnableLike<IO, BranchPathReturnValue, CallOptions>;\n pathMap?: Record<string, N | typeof END> | (N | typeof END)[];\n}\nexport type BranchPathReturnValue = string | Send | (string | Send)[] | Promise<string | Send | (string | Send)[]>;\ntype NodeAction<S, U, C extends StateDefinition> = RunnableLike<S, U extends object ? U & Record<string, any> : U, LangGraphRunnableConfig<StateType<C>>>;\nexport declare class Branch<IO, N extends string, CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig> {\n path: Runnable<IO, BranchPathReturnValue, CallOptions>;\n ends?: Record<string, N | typeof END>;\n constructor(options: Omit<BranchOptions<IO, N, CallOptions>, \"source\">);\n run(writer: (dests: (string | Send)[], config: LangGraphRunnableConfig) => Runnable | void | Promise<void>, reader?: (config: CallOptions) => IO): RunnableCallable<unknown, unknown>;\n _route(input: IO, config: CallOptions, writer: (dests: (string | Send)[], config: LangGraphRunnableConfig) => Runnable | void | Promise<void>, reader?: (config: CallOptions) => IO): Promise<Runnable | any>;\n}\nexport type NodeSpec<RunInput, RunOutput> = {\n runnable: Runnable<RunInput, RunOutput>;\n metadata?: Record<string, unknown>;\n subgraphs?: Pregel<any, any>[];\n ends?: string[];\n defer?: boolean;\n};\nexport type AddNodeOptions<Nodes extends string = string> = {\n metadata?: Record<string, unknown>;\n subgraphs?: Pregel<any, any>[];\n ends?: Nodes[];\n defer?: boolean;\n};\nexport declare class Graph<N extends string = typeof START | typeof END, RunInput = any, RunOutput = any, NodeSpecType extends NodeSpec<RunInput, RunOutput> = NodeSpec<RunInput, RunOutput>, C extends StateDefinition = StateDefinition> {\n nodes: Record<N, NodeSpecType>;\n edges: Set<[N | typeof START, N | typeof END]>;\n branches: Record<string, Record<string, Branch<RunInput, N, any>>>;\n entryPoint?: string;\n compiled: boolean;\n constructor();\n protected warnIfCompiled(message: string): void;\n get allEdges(): Set<[string, string]>;\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(nodes: Record<K, NodeAction<NodeInput, NodeOutput, C>> | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ][]): Graph<N | K, RunInput, RunOutput>;\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(key: K, action: NodeAction<NodeInput, NodeOutput, C>, options?: AddNodeOptions): Graph<N | K, RunInput, RunOutput>;\n addEdge(startKey: N | typeof START, endKey: N | typeof END): this;\n addConditionalEdges(source: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>): this;\n addConditionalEdges(source: N, path: RunnableLike<RunInput, BranchPathReturnValue, LangGraphRunnableConfig<StateType<C>>>, pathMap?: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>[\"pathMap\"]): this;\n /**\n * @deprecated use `addEdge(START, key)` instead\n */\n setEntryPoint(key: N): this;\n /**\n * @deprecated use `addEdge(key, END)` instead\n */\n setFinishPoint(key: N): this;\n compile({ checkpointer, interruptBefore, interruptAfter, name }?: {\n checkpointer?: BaseCheckpointSaver | false;\n interruptBefore?: N[] | All;\n interruptAfter?: N[] | All;\n name?: string;\n }): CompiledGraph<N>;\n validate(interrupt?: string[]): void;\n}\nexport declare class CompiledGraph<N extends string, State = any, Update = any, ContextType extends Record<string, any> = Record<string, any>, InputType = any, OutputType = any, NodeReturnType = unknown, CommandType = unknown, StreamCustomType = any> extends Pregel<Record<N | typeof START, PregelNode<State, Update>>, Record<N | typeof START | typeof END | string, BaseChannel>, ContextType & Record<string, any>, InputType, OutputType, InputType, OutputType, NodeReturnType, CommandType, StreamCustomType> {\n \"~NodeType\": N;\n \"~NodeReturnType\": NodeReturnType;\n \"~RunInput\": Update;\n \"~RunOutput\": State;\n builder: Graph<N, State, Update>;\n constructor({ builder, ...rest }: {\n builder: Graph<N, State, Update>;\n } & PregelParams<Record<N | typeof START, PregelNode<State, Update>>, Record<N | typeof START | typeof END | string, BaseChannel>>);\n attachNode(key: N, node: NodeSpec<State, Update>): void;\n attachEdge(start: N | typeof START, end: N | typeof END): void;\n attachBranch(start: N | typeof START, name: string, branch: Branch<State, N>): void;\n /**\n * Returns a drawable representation of the computation graph.\n */\n getGraphAsync(config?: RunnableConfig & {\n xray?: boolean | number;\n }): Promise<DrawableGraph>;\n /**\n * Returns a drawable representation of the computation graph.\n *\n * @deprecated Use getGraphAsync instead. The async method will be the default in the next minor core release.\n */\n getGraph(config?: RunnableConfig & {\n xray?: boolean | number;\n }): DrawableGraph;\n}\nexport {};\n"],"mappings":";;;;;;;;;;;;;UAWiBkB,wDAAwDX,0BAA0BA;UACvFY;EADKD,IAAAA,EAEPZ,cAFoB,CAEPc,EAFO,EAEHC,qBAFG,EAEoBC,WAFpB,CAAA;EAAA,OAAA,CAAA,EAGhBC,MAHgB,CAAA,MAAA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A3DgK,EAAA,GAAA,EA2DpJK,CA3DoJ,GAAA,OA2DzIP,GA3DyI,CAAA,EAAA,IAAA;EAErLmB,YAAQ,CAAA,KAAA,EA0DIZ,CA1DJ,GAAA,OA0DeL,KA1Df,EAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EA0D4Ce,MA1D5C,CA0DmDiB,KA1DnD,EA0D0D3B,CA1D1D,CAAA,CAAA,EAAA,IAAA;EAAA;;;eACNnB,CAAAA,OAAAA,EA6DaC,cA7DbD,GAAAA;IACCuB,IAAAA,CAAAA,EAAAA,OAAAA,GAAAA,MAAAA;MA8DPC,OA7DQf,CA6DAN,KA7DAM,CAAAA;EAAM;AAItB;;;;UAGW0B,CAAAA,MAGUjC,CAHViC,EA4DWlC,cA5DXkC,GAAAA;IAAK,IAAA,CAAA,EAAA,OAAA,GAAA,MAAA;EAGKjC,CAAAA,CAAAA,EA2DbC,KA3DkB"}
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { InvalidUpdateError, NodeInterrupt, UnreachableNodeError } from "../errors.js";
|
|
2
|
+
import { CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, END, START, TAG_HIDDEN, _isSend } from "../constants.js";
|
|
3
|
+
import { RunnableCallable, gatherIterator, gatherIteratorSync } from "../utils.js";
|
|
4
|
+
import { ChannelWrite, PASSTHROUGH } from "../pregel/write.js";
|
|
5
|
+
import { PregelNode } from "../pregel/read.js";
|
|
6
|
+
import { isPregelLike } from "../pregel/utils/subgraph.js";
|
|
7
|
+
import { Channel, Pregel } from "../pregel/index.js";
|
|
8
|
+
import { EphemeralValue } from "../channels/ephemeral_value.js";
|
|
9
|
+
import { Runnable, _coerceToRunnable } from "@langchain/core/runnables";
|
|
10
|
+
import { Graph } from "@langchain/core/runnables/graph";
|
|
11
|
+
import { z } from "zod/v4";
|
|
12
|
+
import { validate } from "uuid";
|
|
13
|
+
|
|
14
|
+
//#region src/graph/graph.ts
|
|
15
|
+
var Branch = class {
|
|
16
|
+
path;
|
|
17
|
+
ends;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
if (Runnable.isRunnable(options.path)) this.path = options.path;
|
|
20
|
+
else this.path = _coerceToRunnable(options.path).withConfig({ runName: `Branch` });
|
|
21
|
+
this.ends = Array.isArray(options.pathMap) ? options.pathMap.reduce((acc, n) => {
|
|
22
|
+
acc[n] = n;
|
|
23
|
+
return acc;
|
|
24
|
+
}, {}) : options.pathMap;
|
|
25
|
+
}
|
|
26
|
+
run(writer, reader) {
|
|
27
|
+
return ChannelWrite.registerWriter(new RunnableCallable({
|
|
28
|
+
name: "<branch_run>",
|
|
29
|
+
trace: false,
|
|
30
|
+
func: async (input, config) => {
|
|
31
|
+
try {
|
|
32
|
+
return await this._route(input, config, writer, reader);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
if (e.name === NodeInterrupt.unminifiable_name) console.warn("[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.\nNodeInterrupt should only be thrown inside a node, not in edge conditions.");
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
async _route(input, config, writer, reader) {
|
|
41
|
+
let result = await this.path.invoke(reader ? reader(config) : input, config);
|
|
42
|
+
if (!Array.isArray(result)) result = [result];
|
|
43
|
+
let destinations;
|
|
44
|
+
if (this.ends) destinations = result.map((r) => _isSend(r) ? r : this.ends[r]);
|
|
45
|
+
else destinations = result;
|
|
46
|
+
if (destinations.some((dest) => !dest)) throw new Error("Branch condition returned unknown or null destination");
|
|
47
|
+
if (destinations.filter(_isSend).some((packet) => packet.node === END)) throw new InvalidUpdateError("Cannot send a packet to the END node");
|
|
48
|
+
return await writer(destinations, config) ?? input;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var Graph$1 = class {
|
|
52
|
+
nodes;
|
|
53
|
+
edges;
|
|
54
|
+
branches;
|
|
55
|
+
entryPoint;
|
|
56
|
+
compiled = false;
|
|
57
|
+
constructor() {
|
|
58
|
+
this.nodes = {};
|
|
59
|
+
this.edges = /* @__PURE__ */ new Set();
|
|
60
|
+
this.branches = {};
|
|
61
|
+
}
|
|
62
|
+
warnIfCompiled(message) {
|
|
63
|
+
if (this.compiled) console.warn(message);
|
|
64
|
+
}
|
|
65
|
+
get allEdges() {
|
|
66
|
+
return this.edges;
|
|
67
|
+
}
|
|
68
|
+
addNode(...args) {
|
|
69
|
+
function isMutlipleNodes(args$1) {
|
|
70
|
+
return args$1.length >= 1 && typeof args$1[0] !== "string";
|
|
71
|
+
}
|
|
72
|
+
const nodes = isMutlipleNodes(args) ? Array.isArray(args[0]) ? args[0] : Object.entries(args[0]) : [[
|
|
73
|
+
args[0],
|
|
74
|
+
args[1],
|
|
75
|
+
args[2]
|
|
76
|
+
]];
|
|
77
|
+
if (nodes.length === 0) throw new Error("No nodes provided in `addNode`");
|
|
78
|
+
for (const [key, action, options] of nodes) {
|
|
79
|
+
for (const reservedChar of [CHECKPOINT_NAMESPACE_SEPARATOR, CHECKPOINT_NAMESPACE_END]) if (key.includes(reservedChar)) throw new Error(`"${reservedChar}" is a reserved character and is not allowed in node names.`);
|
|
80
|
+
this.warnIfCompiled(`Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph.`);
|
|
81
|
+
if (key in this.nodes) throw new Error(`Node \`${key}\` already present.`);
|
|
82
|
+
if (key === END) throw new Error(`Node \`${key}\` is reserved.`);
|
|
83
|
+
const runnable = _coerceToRunnable(action);
|
|
84
|
+
this.nodes[key] = {
|
|
85
|
+
runnable,
|
|
86
|
+
metadata: options?.metadata,
|
|
87
|
+
subgraphs: isPregelLike(runnable) ? [runnable] : options?.subgraphs,
|
|
88
|
+
ends: options?.ends
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
addEdge(startKey, endKey) {
|
|
94
|
+
this.warnIfCompiled(`Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.`);
|
|
95
|
+
if (startKey === END) throw new Error("END cannot be a start node");
|
|
96
|
+
if (endKey === START) throw new Error("START cannot be an end node");
|
|
97
|
+
if (Array.from(this.edges).some(([start]) => start === startKey) && !("channels" in this)) throw new Error(`Already found path for ${startKey}. For multiple edges, use StateGraph.`);
|
|
98
|
+
this.edges.add([startKey, endKey]);
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
addConditionalEdges(source, path, pathMap) {
|
|
102
|
+
const options = typeof source === "object" ? source : {
|
|
103
|
+
source,
|
|
104
|
+
path,
|
|
105
|
+
pathMap
|
|
106
|
+
};
|
|
107
|
+
this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.");
|
|
108
|
+
if (!Runnable.isRunnable(options.path)) {
|
|
109
|
+
const pathDisplayValues = Array.isArray(options.pathMap) ? options.pathMap.join(",") : Object.keys(options.pathMap ?? {}).join(",");
|
|
110
|
+
options.path = _coerceToRunnable(options.path).withConfig({ runName: `Branch<${options.source}${pathDisplayValues !== "" ? `,${pathDisplayValues}` : ""}>`.slice(0, 63) });
|
|
111
|
+
}
|
|
112
|
+
const name = options.path.getName() === "RunnableLambda" ? "condition" : options.path.getName();
|
|
113
|
+
if (this.branches[options.source] && this.branches[options.source][name]) throw new Error(`Condition \`${name}\` already present for node \`${source}\``);
|
|
114
|
+
this.branches[options.source] ??= {};
|
|
115
|
+
this.branches[options.source][name] = new Branch(options);
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated use `addEdge(START, key)` instead
|
|
120
|
+
*/
|
|
121
|
+
setEntryPoint(key) {
|
|
122
|
+
this.warnIfCompiled("Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph.");
|
|
123
|
+
return this.addEdge(START, key);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* @deprecated use `addEdge(key, END)` instead
|
|
127
|
+
*/
|
|
128
|
+
setFinishPoint(key) {
|
|
129
|
+
this.warnIfCompiled("Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph.");
|
|
130
|
+
return this.addEdge(key, END);
|
|
131
|
+
}
|
|
132
|
+
compile({ checkpointer, interruptBefore, interruptAfter, name } = {}) {
|
|
133
|
+
this.validate([...Array.isArray(interruptBefore) ? interruptBefore : [], ...Array.isArray(interruptAfter) ? interruptAfter : []]);
|
|
134
|
+
const compiled = new CompiledGraph({
|
|
135
|
+
builder: this,
|
|
136
|
+
checkpointer,
|
|
137
|
+
interruptAfter,
|
|
138
|
+
interruptBefore,
|
|
139
|
+
autoValidate: false,
|
|
140
|
+
nodes: {},
|
|
141
|
+
channels: {
|
|
142
|
+
[START]: new EphemeralValue(),
|
|
143
|
+
[END]: new EphemeralValue()
|
|
144
|
+
},
|
|
145
|
+
inputChannels: START,
|
|
146
|
+
outputChannels: END,
|
|
147
|
+
streamChannels: [],
|
|
148
|
+
streamMode: "values",
|
|
149
|
+
name
|
|
150
|
+
});
|
|
151
|
+
for (const [key, node] of Object.entries(this.nodes)) compiled.attachNode(key, node);
|
|
152
|
+
for (const [start, end] of this.edges) compiled.attachEdge(start, end);
|
|
153
|
+
for (const [start, branches] of Object.entries(this.branches)) for (const [name$1, branch] of Object.entries(branches)) compiled.attachBranch(start, name$1, branch);
|
|
154
|
+
return compiled.validate();
|
|
155
|
+
}
|
|
156
|
+
validate(interrupt) {
|
|
157
|
+
const allSources = new Set([...this.allEdges].map(([src, _]) => src));
|
|
158
|
+
for (const [start] of Object.entries(this.branches)) allSources.add(start);
|
|
159
|
+
for (const source of allSources) if (source !== START && !(source in this.nodes)) throw new Error(`Found edge starting at unknown node \`${source}\``);
|
|
160
|
+
const allTargets = new Set([...this.allEdges].map(([_, target]) => target));
|
|
161
|
+
for (const [start, branches] of Object.entries(this.branches)) for (const branch of Object.values(branches)) if (branch.ends != null) for (const end of Object.values(branch.ends)) allTargets.add(end);
|
|
162
|
+
else {
|
|
163
|
+
allTargets.add(END);
|
|
164
|
+
for (const node of Object.keys(this.nodes)) if (node !== start) allTargets.add(node);
|
|
165
|
+
}
|
|
166
|
+
for (const node of Object.values(this.nodes)) for (const target of node.ends ?? []) allTargets.add(target);
|
|
167
|
+
for (const node of Object.keys(this.nodes)) if (!allTargets.has(node)) throw new UnreachableNodeError([
|
|
168
|
+
`Node \`${node}\` is not reachable.`,
|
|
169
|
+
"",
|
|
170
|
+
"If you are returning Command objects from your node,",
|
|
171
|
+
"make sure you are passing names of potential destination nodes as an \"ends\" array",
|
|
172
|
+
"into \".addNode(..., { ends: [\"node1\", \"node2\"] })\"."
|
|
173
|
+
].join("\n"), { lc_error_code: "UNREACHABLE_NODE" });
|
|
174
|
+
for (const target of allTargets) if (target !== END && !(target in this.nodes)) throw new Error(`Found edge ending at unknown node \`${target}\``);
|
|
175
|
+
if (interrupt) {
|
|
176
|
+
for (const node of interrupt) if (!(node in this.nodes)) throw new Error(`Interrupt node \`${node}\` is not present`);
|
|
177
|
+
}
|
|
178
|
+
this.compiled = true;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
var CompiledGraph = class extends Pregel {
|
|
182
|
+
builder;
|
|
183
|
+
constructor({ builder, ...rest }) {
|
|
184
|
+
super(rest);
|
|
185
|
+
this.builder = builder;
|
|
186
|
+
}
|
|
187
|
+
attachNode(key, node) {
|
|
188
|
+
this.channels[key] = new EphemeralValue();
|
|
189
|
+
this.nodes[key] = new PregelNode({
|
|
190
|
+
channels: [],
|
|
191
|
+
triggers: [],
|
|
192
|
+
metadata: node.metadata,
|
|
193
|
+
subgraphs: node.subgraphs,
|
|
194
|
+
ends: node.ends
|
|
195
|
+
}).pipe(node.runnable).pipe(new ChannelWrite([{
|
|
196
|
+
channel: key,
|
|
197
|
+
value: PASSTHROUGH
|
|
198
|
+
}], [TAG_HIDDEN]));
|
|
199
|
+
this.streamChannels.push(key);
|
|
200
|
+
}
|
|
201
|
+
attachEdge(start, end) {
|
|
202
|
+
if (end === END) {
|
|
203
|
+
if (start === START) throw new Error("Cannot have an edge from START to END");
|
|
204
|
+
this.nodes[start].writers.push(new ChannelWrite([{
|
|
205
|
+
channel: END,
|
|
206
|
+
value: PASSTHROUGH
|
|
207
|
+
}], [TAG_HIDDEN]));
|
|
208
|
+
} else {
|
|
209
|
+
this.nodes[end].triggers.push(start);
|
|
210
|
+
this.nodes[end].channels.push(start);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
attachBranch(start, name, branch) {
|
|
214
|
+
if (start === START && !this.nodes[START]) this.nodes[START] = Channel.subscribeTo(START, { tags: [TAG_HIDDEN] });
|
|
215
|
+
this.nodes[start].pipe(branch.run((dests) => {
|
|
216
|
+
return new ChannelWrite(dests.map((dest) => {
|
|
217
|
+
if (_isSend(dest)) return dest;
|
|
218
|
+
return {
|
|
219
|
+
channel: dest === END ? END : `branch:${start}:${name}:${dest}`,
|
|
220
|
+
value: PASSTHROUGH
|
|
221
|
+
};
|
|
222
|
+
}), [TAG_HIDDEN]);
|
|
223
|
+
}));
|
|
224
|
+
const ends = branch.ends ? Object.values(branch.ends) : Object.keys(this.nodes);
|
|
225
|
+
for (const end of ends) if (end !== END) {
|
|
226
|
+
const channelName = `branch:${start}:${name}:${end}`;
|
|
227
|
+
this.channels[channelName] = new EphemeralValue();
|
|
228
|
+
this.nodes[end].triggers.push(channelName);
|
|
229
|
+
this.nodes[end].channels.push(channelName);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Returns a drawable representation of the computation graph.
|
|
234
|
+
*/
|
|
235
|
+
async getGraphAsync(config) {
|
|
236
|
+
const xray = config?.xray;
|
|
237
|
+
const graph = new Graph();
|
|
238
|
+
const startNodes = { [START]: graph.addNode({ schema: z.any() }, START) };
|
|
239
|
+
const endNodes = {};
|
|
240
|
+
let subgraphs = {};
|
|
241
|
+
if (xray) subgraphs = Object.fromEntries((await gatherIterator(this.getSubgraphsAsync())).filter((x) => isCompiledGraph(x[1])));
|
|
242
|
+
function addEdge(start, end, label, conditional = false) {
|
|
243
|
+
if (end === END && endNodes[END] === void 0) endNodes[END] = graph.addNode({ schema: z.any() }, END);
|
|
244
|
+
if (startNodes[start] === void 0) return;
|
|
245
|
+
if (endNodes[end] === void 0) throw new Error(`End node ${end} not found!`);
|
|
246
|
+
return graph.addEdge(startNodes[start], endNodes[end], label !== end ? label : void 0, conditional);
|
|
247
|
+
}
|
|
248
|
+
for (const [key, nodeSpec] of Object.entries(this.builder.nodes)) {
|
|
249
|
+
const displayKey = _escapeMermaidKeywords(key);
|
|
250
|
+
const node = nodeSpec.runnable;
|
|
251
|
+
const metadata = nodeSpec.metadata ?? {};
|
|
252
|
+
if (this.interruptBefore?.includes(key) && this.interruptAfter?.includes(key)) metadata.__interrupt = "before,after";
|
|
253
|
+
else if (this.interruptBefore?.includes(key)) metadata.__interrupt = "before";
|
|
254
|
+
else if (this.interruptAfter?.includes(key)) metadata.__interrupt = "after";
|
|
255
|
+
if (xray) {
|
|
256
|
+
const newXrayValue = typeof xray === "number" ? xray - 1 : xray;
|
|
257
|
+
const drawableSubgraph = subgraphs[key] !== void 0 ? await subgraphs[key].getGraphAsync({
|
|
258
|
+
...config,
|
|
259
|
+
xray: newXrayValue
|
|
260
|
+
}) : node.getGraph(config);
|
|
261
|
+
drawableSubgraph.trimFirstNode();
|
|
262
|
+
drawableSubgraph.trimLastNode();
|
|
263
|
+
if (Object.keys(drawableSubgraph.nodes).length > 1) {
|
|
264
|
+
const [e, s] = graph.extend(drawableSubgraph, displayKey);
|
|
265
|
+
if (e === void 0) throw new Error(`Could not extend subgraph "${key}" due to missing entrypoint.`);
|
|
266
|
+
function _isRunnableInterface(thing) {
|
|
267
|
+
return thing ? thing.lc_runnable : false;
|
|
268
|
+
}
|
|
269
|
+
function _nodeDataStr(id, data) {
|
|
270
|
+
if (id !== void 0 && !validate(id)) return id;
|
|
271
|
+
else if (_isRunnableInterface(data)) try {
|
|
272
|
+
let dataStr = data.getName();
|
|
273
|
+
dataStr = dataStr.startsWith("Runnable") ? dataStr.slice(8) : dataStr;
|
|
274
|
+
return dataStr;
|
|
275
|
+
} catch (error) {
|
|
276
|
+
return data.getName();
|
|
277
|
+
}
|
|
278
|
+
else return data.name ?? "UnknownSchema";
|
|
279
|
+
}
|
|
280
|
+
if (s !== void 0) startNodes[displayKey] = {
|
|
281
|
+
name: _nodeDataStr(s.id, s.data),
|
|
282
|
+
...s
|
|
283
|
+
};
|
|
284
|
+
endNodes[displayKey] = {
|
|
285
|
+
name: _nodeDataStr(e.id, e.data),
|
|
286
|
+
...e
|
|
287
|
+
};
|
|
288
|
+
} else {
|
|
289
|
+
const newNode = graph.addNode(node, displayKey, metadata);
|
|
290
|
+
startNodes[displayKey] = newNode;
|
|
291
|
+
endNodes[displayKey] = newNode;
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
const newNode = graph.addNode(node, displayKey, metadata);
|
|
295
|
+
startNodes[displayKey] = newNode;
|
|
296
|
+
endNodes[displayKey] = newNode;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const sortedEdges = [...this.builder.allEdges].sort(([a], [b]) => {
|
|
300
|
+
if (a < b) return -1;
|
|
301
|
+
else if (b > a) return 1;
|
|
302
|
+
else return 0;
|
|
303
|
+
});
|
|
304
|
+
for (const [start, end] of sortedEdges) addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end));
|
|
305
|
+
for (const [start, branches] of Object.entries(this.builder.branches)) {
|
|
306
|
+
const defaultEnds = {
|
|
307
|
+
...Object.fromEntries(Object.keys(this.builder.nodes).filter((k) => k !== start).map((k) => [_escapeMermaidKeywords(k), _escapeMermaidKeywords(k)])),
|
|
308
|
+
[END]: END
|
|
309
|
+
};
|
|
310
|
+
for (const branch of Object.values(branches)) {
|
|
311
|
+
let ends;
|
|
312
|
+
if (branch.ends !== void 0) ends = branch.ends;
|
|
313
|
+
else ends = defaultEnds;
|
|
314
|
+
for (const [label, end] of Object.entries(ends)) addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end), label, true);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
for (const [key, node] of Object.entries(this.builder.nodes)) if (node.ends !== void 0) for (const end of node.ends) addEdge(_escapeMermaidKeywords(key), _escapeMermaidKeywords(end), void 0, true);
|
|
318
|
+
return graph;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Returns a drawable representation of the computation graph.
|
|
322
|
+
*
|
|
323
|
+
* @deprecated Use getGraphAsync instead. The async method will be the default in the next minor core release.
|
|
324
|
+
*/
|
|
325
|
+
getGraph(config) {
|
|
326
|
+
const xray = config?.xray;
|
|
327
|
+
const graph = new Graph();
|
|
328
|
+
const startNodes = { [START]: graph.addNode({ schema: z.any() }, START) };
|
|
329
|
+
const endNodes = {};
|
|
330
|
+
let subgraphs = {};
|
|
331
|
+
if (xray) subgraphs = Object.fromEntries(gatherIteratorSync(this.getSubgraphs()).filter((x) => isCompiledGraph(x[1])));
|
|
332
|
+
function addEdge(start, end, label, conditional = false) {
|
|
333
|
+
if (end === END && endNodes[END] === void 0) endNodes[END] = graph.addNode({ schema: z.any() }, END);
|
|
334
|
+
return graph.addEdge(startNodes[start], endNodes[end], label !== end ? label : void 0, conditional);
|
|
335
|
+
}
|
|
336
|
+
for (const [key, nodeSpec] of Object.entries(this.builder.nodes)) {
|
|
337
|
+
const displayKey = _escapeMermaidKeywords(key);
|
|
338
|
+
const node = nodeSpec.runnable;
|
|
339
|
+
const metadata = nodeSpec.metadata ?? {};
|
|
340
|
+
if (this.interruptBefore?.includes(key) && this.interruptAfter?.includes(key)) metadata.__interrupt = "before,after";
|
|
341
|
+
else if (this.interruptBefore?.includes(key)) metadata.__interrupt = "before";
|
|
342
|
+
else if (this.interruptAfter?.includes(key)) metadata.__interrupt = "after";
|
|
343
|
+
if (xray) {
|
|
344
|
+
const newXrayValue = typeof xray === "number" ? xray - 1 : xray;
|
|
345
|
+
const drawableSubgraph = subgraphs[key] !== void 0 ? subgraphs[key].getGraph({
|
|
346
|
+
...config,
|
|
347
|
+
xray: newXrayValue
|
|
348
|
+
}) : node.getGraph(config);
|
|
349
|
+
drawableSubgraph.trimFirstNode();
|
|
350
|
+
drawableSubgraph.trimLastNode();
|
|
351
|
+
if (Object.keys(drawableSubgraph.nodes).length > 1) {
|
|
352
|
+
const [e, s] = graph.extend(drawableSubgraph, displayKey);
|
|
353
|
+
if (e === void 0) throw new Error(`Could not extend subgraph "${key}" due to missing entrypoint.`);
|
|
354
|
+
function _isRunnableInterface(thing) {
|
|
355
|
+
return thing ? thing.lc_runnable : false;
|
|
356
|
+
}
|
|
357
|
+
function _nodeDataStr(id, data) {
|
|
358
|
+
if (id !== void 0 && !validate(id)) return id;
|
|
359
|
+
else if (_isRunnableInterface(data)) try {
|
|
360
|
+
let dataStr = data.getName();
|
|
361
|
+
dataStr = dataStr.startsWith("Runnable") ? dataStr.slice(8) : dataStr;
|
|
362
|
+
return dataStr;
|
|
363
|
+
} catch (error) {
|
|
364
|
+
return data.getName();
|
|
365
|
+
}
|
|
366
|
+
else return data.name ?? "UnknownSchema";
|
|
367
|
+
}
|
|
368
|
+
if (s !== void 0) startNodes[displayKey] = {
|
|
369
|
+
name: _nodeDataStr(s.id, s.data),
|
|
370
|
+
...s
|
|
371
|
+
};
|
|
372
|
+
endNodes[displayKey] = {
|
|
373
|
+
name: _nodeDataStr(e.id, e.data),
|
|
374
|
+
...e
|
|
375
|
+
};
|
|
376
|
+
} else {
|
|
377
|
+
const newNode = graph.addNode(node, displayKey, metadata);
|
|
378
|
+
startNodes[displayKey] = newNode;
|
|
379
|
+
endNodes[displayKey] = newNode;
|
|
380
|
+
}
|
|
381
|
+
} else {
|
|
382
|
+
const newNode = graph.addNode(node, displayKey, metadata);
|
|
383
|
+
startNodes[displayKey] = newNode;
|
|
384
|
+
endNodes[displayKey] = newNode;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
const sortedEdges = [...this.builder.allEdges].sort(([a], [b]) => {
|
|
388
|
+
if (a < b) return -1;
|
|
389
|
+
else if (b > a) return 1;
|
|
390
|
+
else return 0;
|
|
391
|
+
});
|
|
392
|
+
for (const [start, end] of sortedEdges) addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end));
|
|
393
|
+
for (const [start, branches] of Object.entries(this.builder.branches)) {
|
|
394
|
+
const defaultEnds = {
|
|
395
|
+
...Object.fromEntries(Object.keys(this.builder.nodes).filter((k) => k !== start).map((k) => [_escapeMermaidKeywords(k), _escapeMermaidKeywords(k)])),
|
|
396
|
+
[END]: END
|
|
397
|
+
};
|
|
398
|
+
for (const branch of Object.values(branches)) {
|
|
399
|
+
let ends;
|
|
400
|
+
if (branch.ends !== void 0) ends = branch.ends;
|
|
401
|
+
else ends = defaultEnds;
|
|
402
|
+
for (const [label, end] of Object.entries(ends)) addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end), label, true);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return graph;
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
function isCompiledGraph(x) {
|
|
409
|
+
return typeof x.attachNode === "function" && typeof x.attachEdge === "function";
|
|
410
|
+
}
|
|
411
|
+
function _escapeMermaidKeywords(key) {
|
|
412
|
+
if (key === "subgraph") return `"${key}"`;
|
|
413
|
+
return key;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
//#endregion
|
|
417
|
+
export { Branch, CompiledGraph, Graph$1 as Graph };
|
|
418
|
+
//# sourceMappingURL=graph.js.map
|