@langchain/langgraph 1.0.6 → 1.0.12
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/package.json +7 -7
- package/CHANGELOG.md +0 -280
- package/dist/_virtual/rolldown_runtime.cjs +0 -25
- package/dist/channels/any_value.cjs +0 -46
- package/dist/channels/any_value.cjs.map +0 -1
- package/dist/channels/any_value.d.cts +0 -24
- package/dist/channels/any_value.d.cts.map +0 -1
- package/dist/channels/any_value.d.ts +0 -24
- package/dist/channels/any_value.d.ts.map +0 -1
- package/dist/channels/any_value.js +0 -46
- package/dist/channels/any_value.js.map +0 -1
- package/dist/channels/base.cjs +0 -102
- package/dist/channels/base.cjs.map +0 -1
- package/dist/channels/base.d.cts +0 -79
- package/dist/channels/base.d.cts.map +0 -1
- package/dist/channels/base.d.ts +0 -79
- package/dist/channels/base.d.ts.map +0 -1
- package/dist/channels/base.js +0 -97
- package/dist/channels/base.js.map +0 -1
- package/dist/channels/binop.cjs +0 -49
- package/dist/channels/binop.cjs.map +0 -1
- package/dist/channels/binop.d.cts +0 -22
- package/dist/channels/binop.d.cts.map +0 -1
- package/dist/channels/binop.d.ts +0 -22
- package/dist/channels/binop.d.ts.map +0 -1
- package/dist/channels/binop.js +0 -49
- package/dist/channels/binop.js.map +0 -1
- package/dist/channels/dynamic_barrier_value.cjs +0 -76
- package/dist/channels/dynamic_barrier_value.cjs.map +0 -1
- package/dist/channels/dynamic_barrier_value.d.cts +0 -42
- package/dist/channels/dynamic_barrier_value.d.cts.map +0 -1
- package/dist/channels/dynamic_barrier_value.d.ts +0 -42
- package/dist/channels/dynamic_barrier_value.d.ts.map +0 -1
- package/dist/channels/dynamic_barrier_value.js +0 -76
- package/dist/channels/dynamic_barrier_value.js.map +0 -1
- package/dist/channels/ephemeral_value.cjs +0 -46
- package/dist/channels/ephemeral_value.cjs.map +0 -1
- package/dist/channels/ephemeral_value.d.cts +0 -22
- package/dist/channels/ephemeral_value.d.cts.map +0 -1
- package/dist/channels/ephemeral_value.d.ts +0 -22
- package/dist/channels/ephemeral_value.d.ts.map +0 -1
- package/dist/channels/ephemeral_value.js +0 -46
- package/dist/channels/ephemeral_value.js.map +0 -1
- package/dist/channels/index.cjs +0 -21
- package/dist/channels/index.d.cts +0 -9
- package/dist/channels/index.d.ts +0 -9
- package/dist/channels/index.js +0 -10
- package/dist/channels/last_value.cjs +0 -98
- package/dist/channels/last_value.cjs.map +0 -1
- package/dist/channels/last_value.d.cts +0 -44
- package/dist/channels/last_value.d.cts.map +0 -1
- package/dist/channels/last_value.d.ts +0 -44
- package/dist/channels/last_value.d.ts.map +0 -1
- package/dist/channels/last_value.js +0 -97
- package/dist/channels/last_value.js.map +0 -1
- package/dist/channels/named_barrier_value.cjs +0 -118
- package/dist/channels/named_barrier_value.cjs.map +0 -1
- package/dist/channels/named_barrier_value.d.cts +0 -46
- package/dist/channels/named_barrier_value.d.cts.map +0 -1
- package/dist/channels/named_barrier_value.d.ts +0 -46
- package/dist/channels/named_barrier_value.d.ts.map +0 -1
- package/dist/channels/named_barrier_value.js +0 -116
- package/dist/channels/named_barrier_value.js.map +0 -1
- package/dist/channels/topic.cjs +0 -65
- package/dist/channels/topic.cjs.map +0 -1
- package/dist/channels/topic.d.cts +0 -32
- package/dist/channels/topic.d.cts.map +0 -1
- package/dist/channels/topic.d.ts +0 -32
- package/dist/channels/topic.d.ts.map +0 -1
- package/dist/channels/topic.js +0 -65
- package/dist/channels/topic.js.map +0 -1
- package/dist/constants.cjs +0 -406
- package/dist/constants.cjs.map +0 -1
- package/dist/constants.d.cts +0 -285
- package/dist/constants.d.cts.map +0 -1
- package/dist/constants.d.ts +0 -285
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -362
- package/dist/constants.js.map +0 -1
- package/dist/errors.cjs +0 -163
- package/dist/errors.cjs.map +0 -1
- package/dist/errors.d.cts +0 -81
- package/dist/errors.d.cts.map +0 -1
- package/dist/errors.d.ts +0 -81
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -146
- package/dist/errors.js.map +0 -1
- package/dist/func/index.cjs +0 -301
- package/dist/func/index.cjs.map +0 -1
- package/dist/func/index.d.cts +0 -293
- package/dist/func/index.d.cts.map +0 -1
- package/dist/func/index.d.ts +0 -293
- package/dist/func/index.d.ts.map +0 -1
- package/dist/func/index.js +0 -298
- package/dist/func/index.js.map +0 -1
- package/dist/func/types.d.cts +0 -64
- package/dist/func/types.d.cts.map +0 -1
- package/dist/func/types.d.ts +0 -64
- package/dist/func/types.d.ts.map +0 -1
- package/dist/graph/annotation.cjs +0 -101
- package/dist/graph/annotation.cjs.map +0 -1
- package/dist/graph/annotation.d.cts +0 -116
- package/dist/graph/annotation.d.cts.map +0 -1
- package/dist/graph/annotation.d.ts +0 -116
- package/dist/graph/annotation.d.ts.map +0 -1
- package/dist/graph/annotation.js +0 -99
- package/dist/graph/annotation.js.map +0 -1
- package/dist/graph/graph.cjs +0 -423
- package/dist/graph/graph.cjs.map +0 -1
- package/dist/graph/graph.d.cts +0 -132
- package/dist/graph/graph.d.cts.map +0 -1
- package/dist/graph/graph.d.ts +0 -132
- package/dist/graph/graph.d.ts.map +0 -1
- package/dist/graph/graph.js +0 -420
- package/dist/graph/graph.js.map +0 -1
- package/dist/graph/index.cjs +0 -5
- package/dist/graph/index.js +0 -7
- package/dist/graph/message.cjs +0 -99
- package/dist/graph/message.cjs.map +0 -1
- package/dist/graph/message.d.cts +0 -40
- package/dist/graph/message.d.cts.map +0 -1
- package/dist/graph/message.d.ts +0 -40
- package/dist/graph/message.d.ts.map +0 -1
- package/dist/graph/message.js +0 -95
- package/dist/graph/message.js.map +0 -1
- package/dist/graph/messages_annotation.cjs +0 -110
- package/dist/graph/messages_annotation.cjs.map +0 -1
- package/dist/graph/messages_annotation.d.cts +0 -112
- package/dist/graph/messages_annotation.d.cts.map +0 -1
- package/dist/graph/messages_annotation.d.ts +0 -112
- package/dist/graph/messages_annotation.d.ts.map +0 -1
- package/dist/graph/messages_annotation.js +0 -107
- package/dist/graph/messages_annotation.js.map +0 -1
- package/dist/graph/state.cjs +0 -501
- package/dist/graph/state.cjs.map +0 -1
- package/dist/graph/state.d.cts +0 -236
- package/dist/graph/state.d.cts.map +0 -1
- package/dist/graph/state.d.ts +0 -236
- package/dist/graph/state.d.ts.map +0 -1
- package/dist/graph/state.js +0 -499
- package/dist/graph/state.js.map +0 -1
- package/dist/graph/zod/index.cjs +0 -10
- package/dist/graph/zod/index.d.cts +0 -3
- package/dist/graph/zod/index.d.ts +0 -3
- package/dist/graph/zod/index.js +0 -5
- package/dist/graph/zod/meta.cjs +0 -145
- package/dist/graph/zod/meta.cjs.map +0 -1
- package/dist/graph/zod/meta.d.cts +0 -116
- package/dist/graph/zod/meta.d.cts.map +0 -1
- package/dist/graph/zod/meta.d.ts +0 -116
- package/dist/graph/zod/meta.d.ts.map +0 -1
- package/dist/graph/zod/meta.js +0 -141
- package/dist/graph/zod/meta.js.map +0 -1
- package/dist/graph/zod/plugin.cjs +0 -41
- package/dist/graph/zod/plugin.cjs.map +0 -1
- package/dist/graph/zod/plugin.js +0 -41
- package/dist/graph/zod/plugin.js.map +0 -1
- package/dist/graph/zod/schema.cjs +0 -99
- package/dist/graph/zod/schema.cjs.map +0 -1
- package/dist/graph/zod/schema.d.cts +0 -38
- package/dist/graph/zod/schema.d.cts.map +0 -1
- package/dist/graph/zod/schema.d.ts +0 -38
- package/dist/graph/zod/schema.d.ts.map +0 -1
- package/dist/graph/zod/schema.js +0 -94
- package/dist/graph/zod/schema.js.map +0 -1
- package/dist/graph/zod/zod-registry.cjs +0 -43
- package/dist/graph/zod/zod-registry.cjs.map +0 -1
- package/dist/graph/zod/zod-registry.d.cts +0 -51
- package/dist/graph/zod/zod-registry.d.cts.map +0 -1
- package/dist/graph/zod/zod-registry.d.ts +0 -51
- package/dist/graph/zod/zod-registry.d.ts.map +0 -1
- package/dist/graph/zod/zod-registry.js +0 -41
- package/dist/graph/zod/zod-registry.js.map +0 -1
- package/dist/hash.cjs +0 -271
- package/dist/hash.cjs.map +0 -1
- package/dist/hash.js +0 -269
- package/dist/hash.js.map +0 -1
- package/dist/index.cjs +0 -112
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -26
- package/dist/index.d.ts +0 -26
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
- package/dist/interrupt.cjs +0 -82
- package/dist/interrupt.cjs.map +0 -1
- package/dist/interrupt.d.cts +0 -58
- package/dist/interrupt.d.cts.map +0 -1
- package/dist/interrupt.d.ts +0 -58
- package/dist/interrupt.d.ts.map +0 -1
- package/dist/interrupt.js +0 -81
- package/dist/interrupt.js.map +0 -1
- package/dist/prebuilt/agentName.cjs +0 -153
- package/dist/prebuilt/agentName.cjs.map +0 -1
- package/dist/prebuilt/agentName.d.cts +0 -42
- package/dist/prebuilt/agentName.d.cts.map +0 -1
- package/dist/prebuilt/agentName.d.ts +0 -42
- package/dist/prebuilt/agentName.d.ts.map +0 -1
- package/dist/prebuilt/agentName.js +0 -152
- package/dist/prebuilt/agentName.js.map +0 -1
- package/dist/prebuilt/agent_executor.cjs +0 -44
- package/dist/prebuilt/agent_executor.cjs.map +0 -1
- package/dist/prebuilt/agent_executor.d.cts +0 -58
- package/dist/prebuilt/agent_executor.d.cts.map +0 -1
- package/dist/prebuilt/agent_executor.d.ts +0 -58
- package/dist/prebuilt/agent_executor.d.ts.map +0 -1
- package/dist/prebuilt/agent_executor.js +0 -44
- package/dist/prebuilt/agent_executor.js.map +0 -1
- package/dist/prebuilt/chat_agent_executor.cjs +0 -68
- package/dist/prebuilt/chat_agent_executor.cjs.map +0 -1
- package/dist/prebuilt/chat_agent_executor.d.cts +0 -23
- package/dist/prebuilt/chat_agent_executor.d.cts.map +0 -1
- package/dist/prebuilt/chat_agent_executor.d.ts +0 -23
- package/dist/prebuilt/chat_agent_executor.d.ts.map +0 -1
- package/dist/prebuilt/chat_agent_executor.js +0 -67
- package/dist/prebuilt/chat_agent_executor.js.map +0 -1
- package/dist/prebuilt/index.cjs +0 -15
- package/dist/prebuilt/index.d.cts +0 -8
- package/dist/prebuilt/index.d.ts +0 -8
- package/dist/prebuilt/index.js +0 -8
- package/dist/prebuilt/interrupt.d.cts +0 -61
- package/dist/prebuilt/interrupt.d.cts.map +0 -1
- package/dist/prebuilt/interrupt.d.ts +0 -61
- package/dist/prebuilt/interrupt.d.ts.map +0 -1
- package/dist/prebuilt/react_agent_executor.cjs +0 -344
- package/dist/prebuilt/react_agent_executor.cjs.map +0 -1
- package/dist/prebuilt/react_agent_executor.d.cts +0 -230
- package/dist/prebuilt/react_agent_executor.d.cts.map +0 -1
- package/dist/prebuilt/react_agent_executor.d.ts +0 -230
- package/dist/prebuilt/react_agent_executor.d.ts.map +0 -1
- package/dist/prebuilt/react_agent_executor.js +0 -342
- package/dist/prebuilt/react_agent_executor.js.map +0 -1
- package/dist/prebuilt/tool_executor.cjs +0 -48
- package/dist/prebuilt/tool_executor.cjs.map +0 -1
- package/dist/prebuilt/tool_executor.d.cts +0 -42
- package/dist/prebuilt/tool_executor.d.cts.map +0 -1
- package/dist/prebuilt/tool_executor.d.ts +0 -42
- package/dist/prebuilt/tool_executor.d.ts.map +0 -1
- package/dist/prebuilt/tool_executor.js +0 -47
- package/dist/prebuilt/tool_executor.js.map +0 -1
- package/dist/prebuilt/tool_node.cjs +0 -248
- package/dist/prebuilt/tool_node.cjs.map +0 -1
- package/dist/prebuilt/tool_node.d.cts +0 -182
- package/dist/prebuilt/tool_node.d.cts.map +0 -1
- package/dist/prebuilt/tool_node.d.ts +0 -182
- package/dist/prebuilt/tool_node.d.ts.map +0 -1
- package/dist/prebuilt/tool_node.js +0 -246
- package/dist/prebuilt/tool_node.js.map +0 -1
- package/dist/pregel/algo.cjs +0 -573
- package/dist/pregel/algo.cjs.map +0 -1
- package/dist/pregel/algo.d.cts +0 -13
- package/dist/pregel/algo.d.cts.map +0 -1
- package/dist/pregel/algo.d.ts +0 -13
- package/dist/pregel/algo.d.ts.map +0 -1
- package/dist/pregel/algo.js +0 -567
- package/dist/pregel/algo.js.map +0 -1
- package/dist/pregel/call.cjs +0 -53
- package/dist/pregel/call.cjs.map +0 -1
- package/dist/pregel/call.js +0 -50
- package/dist/pregel/call.js.map +0 -1
- package/dist/pregel/debug.cjs +0 -175
- package/dist/pregel/debug.cjs.map +0 -1
- package/dist/pregel/debug.js +0 -169
- package/dist/pregel/debug.js.map +0 -1
- package/dist/pregel/index.cjs +0 -1170
- package/dist/pregel/index.cjs.map +0 -1
- package/dist/pregel/index.d.cts +0 -546
- package/dist/pregel/index.d.cts.map +0 -1
- package/dist/pregel/index.d.ts +0 -546
- package/dist/pregel/index.d.ts.map +0 -1
- package/dist/pregel/index.js +0 -1168
- package/dist/pregel/index.js.map +0 -1
- package/dist/pregel/io.cjs +0 -140
- package/dist/pregel/io.cjs.map +0 -1
- package/dist/pregel/io.js +0 -135
- package/dist/pregel/io.js.map +0 -1
- package/dist/pregel/loop.cjs +0 -548
- package/dist/pregel/loop.cjs.map +0 -1
- package/dist/pregel/loop.js +0 -547
- package/dist/pregel/loop.js.map +0 -1
- package/dist/pregel/messages.cjs +0 -108
- package/dist/pregel/messages.cjs.map +0 -1
- package/dist/pregel/messages.js +0 -107
- package/dist/pregel/messages.js.map +0 -1
- package/dist/pregel/read.cjs +0 -152
- package/dist/pregel/read.cjs.map +0 -1
- package/dist/pregel/read.d.cts +0 -51
- package/dist/pregel/read.d.cts.map +0 -1
- package/dist/pregel/read.d.ts +0 -51
- package/dist/pregel/read.d.ts.map +0 -1
- package/dist/pregel/read.js +0 -150
- package/dist/pregel/read.js.map +0 -1
- package/dist/pregel/remote.cjs +0 -346
- package/dist/pregel/remote.cjs.map +0 -1
- package/dist/pregel/remote.d.cts +0 -121
- package/dist/pregel/remote.d.cts.map +0 -1
- package/dist/pregel/remote.d.ts +0 -121
- package/dist/pregel/remote.d.ts.map +0 -1
- package/dist/pregel/remote.js +0 -345
- package/dist/pregel/remote.js.map +0 -1
- package/dist/pregel/retry.cjs +0 -92
- package/dist/pregel/retry.cjs.map +0 -1
- package/dist/pregel/retry.js +0 -92
- package/dist/pregel/retry.js.map +0 -1
- package/dist/pregel/runnable_types.d.cts +0 -49
- package/dist/pregel/runnable_types.d.cts.map +0 -1
- package/dist/pregel/runnable_types.d.ts +0 -49
- package/dist/pregel/runnable_types.d.ts.map +0 -1
- package/dist/pregel/runner.cjs +0 -228
- package/dist/pregel/runner.cjs.map +0 -1
- package/dist/pregel/runner.js +0 -228
- package/dist/pregel/runner.js.map +0 -1
- package/dist/pregel/stream.cjs +0 -199
- package/dist/pregel/stream.cjs.map +0 -1
- package/dist/pregel/stream.js +0 -196
- package/dist/pregel/stream.js.map +0 -1
- package/dist/pregel/types.cjs +0 -27
- package/dist/pregel/types.cjs.map +0 -1
- package/dist/pregel/types.d.cts +0 -453
- package/dist/pregel/types.d.cts.map +0 -1
- package/dist/pregel/types.d.ts +0 -453
- package/dist/pregel/types.d.ts.map +0 -1
- package/dist/pregel/types.js +0 -25
- package/dist/pregel/types.js.map +0 -1
- package/dist/pregel/utils/config.cjs +0 -122
- package/dist/pregel/utils/config.cjs.map +0 -1
- package/dist/pregel/utils/config.d.cts +0 -36
- package/dist/pregel/utils/config.d.cts.map +0 -1
- package/dist/pregel/utils/config.d.ts +0 -36
- package/dist/pregel/utils/config.d.ts.map +0 -1
- package/dist/pregel/utils/config.js +0 -115
- package/dist/pregel/utils/config.js.map +0 -1
- package/dist/pregel/utils/index.cjs +0 -103
- package/dist/pregel/utils/index.cjs.map +0 -1
- package/dist/pregel/utils/index.d.cts +0 -51
- package/dist/pregel/utils/index.d.cts.map +0 -1
- package/dist/pregel/utils/index.d.ts +0 -51
- package/dist/pregel/utils/index.d.ts.map +0 -1
- package/dist/pregel/utils/index.js +0 -97
- package/dist/pregel/utils/index.js.map +0 -1
- package/dist/pregel/utils/subgraph.cjs +0 -19
- package/dist/pregel/utils/subgraph.cjs.map +0 -1
- package/dist/pregel/utils/subgraph.js +0 -17
- package/dist/pregel/utils/subgraph.js.map +0 -1
- package/dist/pregel/validate.cjs +0 -45
- package/dist/pregel/validate.cjs.map +0 -1
- package/dist/pregel/validate.js +0 -44
- package/dist/pregel/validate.js.map +0 -1
- package/dist/pregel/write.cjs +0 -97
- package/dist/pregel/write.cjs.map +0 -1
- package/dist/pregel/write.d.cts +0 -35
- package/dist/pregel/write.d.cts.map +0 -1
- package/dist/pregel/write.d.ts +0 -35
- package/dist/pregel/write.d.ts.map +0 -1
- package/dist/pregel/write.js +0 -95
- package/dist/pregel/write.js.map +0 -1
- package/dist/remote.cjs +0 -3
- package/dist/remote.d.cts +0 -2
- package/dist/remote.d.ts +0 -2
- package/dist/remote.js +0 -3
- package/dist/setup/async_local_storage.cjs +0 -12
- package/dist/setup/async_local_storage.cjs.map +0 -1
- package/dist/setup/async_local_storage.js +0 -11
- package/dist/setup/async_local_storage.js.map +0 -1
- package/dist/utils.cjs +0 -88
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.d.cts +0 -32
- package/dist/utils.d.cts.map +0 -1
- package/dist/utils.d.ts +0 -32
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -81
- package/dist/utils.js.map +0 -1
- package/dist/web.cjs +0 -96
- package/dist/web.d.cts +0 -23
- package/dist/web.d.ts +0 -23
- package/dist/web.js +0 -15
- package/dist/writer.cjs +0 -15
- package/dist/writer.cjs.map +0 -1
- package/dist/writer.d.cts +0 -7
- package/dist/writer.d.cts.map +0 -1
- package/dist/writer.d.ts +0 -7
- package/dist/writer.d.ts.map +0 -1
- package/dist/writer.js +0 -14
- package/dist/writer.js.map +0 -1
package/dist/pregel/loop.cjs
DELETED
|
@@ -1,548 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_errors = require('../errors.cjs');
|
|
3
|
-
const require_base = require('../channels/base.cjs');
|
|
4
|
-
const require_constants = require('../constants.cjs');
|
|
5
|
-
const require_utils = require('../utils.cjs');
|
|
6
|
-
const require_hash = require('../hash.cjs');
|
|
7
|
-
const require_io = require('./io.cjs');
|
|
8
|
-
const require_index = require('./utils/index.cjs');
|
|
9
|
-
const require_algo = require('./algo.cjs');
|
|
10
|
-
const require_debug = require('./debug.cjs');
|
|
11
|
-
const require_stream = require('./stream.cjs');
|
|
12
|
-
const __langchain_langgraph_checkpoint = require_rolldown_runtime.__toESM(require("@langchain/langgraph-checkpoint"));
|
|
13
|
-
|
|
14
|
-
//#region src/pregel/loop.ts
|
|
15
|
-
const INPUT_DONE = Symbol.for("INPUT_DONE");
|
|
16
|
-
const INPUT_RESUMING = Symbol.for("INPUT_RESUMING");
|
|
17
|
-
const DEFAULT_LOOP_LIMIT = 25;
|
|
18
|
-
function createDuplexStream(...streams) {
|
|
19
|
-
return new require_stream.IterableReadableWritableStream({
|
|
20
|
-
passthroughFn: (value) => {
|
|
21
|
-
for (const stream of streams) if (stream.modes.has(value[1])) stream.push(value);
|
|
22
|
-
},
|
|
23
|
-
modes: new Set(streams.flatMap((s) => Array.from(s.modes)))
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
var AsyncBatchedCache = class extends __langchain_langgraph_checkpoint.BaseCache {
|
|
27
|
-
cache;
|
|
28
|
-
queue = Promise.resolve();
|
|
29
|
-
constructor(cache) {
|
|
30
|
-
super();
|
|
31
|
-
this.cache = cache;
|
|
32
|
-
}
|
|
33
|
-
async get(keys) {
|
|
34
|
-
return this.enqueueOperation("get", keys);
|
|
35
|
-
}
|
|
36
|
-
async set(pairs) {
|
|
37
|
-
return this.enqueueOperation("set", pairs);
|
|
38
|
-
}
|
|
39
|
-
async clear(namespaces) {
|
|
40
|
-
return this.enqueueOperation("clear", namespaces);
|
|
41
|
-
}
|
|
42
|
-
async stop() {
|
|
43
|
-
await this.queue;
|
|
44
|
-
}
|
|
45
|
-
enqueueOperation(type, ...args) {
|
|
46
|
-
const newPromise = this.queue.then(() => {
|
|
47
|
-
return this.cache[type](...args);
|
|
48
|
-
});
|
|
49
|
-
this.queue = newPromise.then(() => void 0, () => void 0);
|
|
50
|
-
return newPromise;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var PregelLoop = class PregelLoop {
|
|
54
|
-
input;
|
|
55
|
-
output;
|
|
56
|
-
config;
|
|
57
|
-
checkpointer;
|
|
58
|
-
checkpointerGetNextVersion;
|
|
59
|
-
channels;
|
|
60
|
-
checkpoint;
|
|
61
|
-
checkpointIdSaved;
|
|
62
|
-
checkpointConfig;
|
|
63
|
-
checkpointMetadata;
|
|
64
|
-
checkpointNamespace;
|
|
65
|
-
checkpointPendingWrites = [];
|
|
66
|
-
checkpointPreviousVersions;
|
|
67
|
-
step;
|
|
68
|
-
stop;
|
|
69
|
-
durability;
|
|
70
|
-
outputKeys;
|
|
71
|
-
streamKeys;
|
|
72
|
-
nodes;
|
|
73
|
-
skipDoneTasks;
|
|
74
|
-
prevCheckpointConfig;
|
|
75
|
-
updatedChannels;
|
|
76
|
-
status = "pending";
|
|
77
|
-
tasks = {};
|
|
78
|
-
stream;
|
|
79
|
-
checkpointerPromises = [];
|
|
80
|
-
isNested;
|
|
81
|
-
_checkpointerChainedPromise = Promise.resolve();
|
|
82
|
-
store;
|
|
83
|
-
cache;
|
|
84
|
-
manager;
|
|
85
|
-
interruptAfter;
|
|
86
|
-
interruptBefore;
|
|
87
|
-
toInterrupt = [];
|
|
88
|
-
debug = false;
|
|
89
|
-
triggerToNodes;
|
|
90
|
-
get isResuming() {
|
|
91
|
-
let hasChannelVersions = false;
|
|
92
|
-
if (require_constants.START in this.checkpoint.channel_versions) hasChannelVersions = true;
|
|
93
|
-
else for (const chan in this.checkpoint.channel_versions) if (Object.prototype.hasOwnProperty.call(this.checkpoint.channel_versions, chan)) {
|
|
94
|
-
hasChannelVersions = true;
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
const configHasResumingFlag = this.config.configurable?.[require_constants.CONFIG_KEY_RESUMING] !== void 0;
|
|
98
|
-
const configIsResuming = configHasResumingFlag && this.config.configurable?.[require_constants.CONFIG_KEY_RESUMING];
|
|
99
|
-
const inputIsNullOrUndefined = this.input === null || this.input === void 0;
|
|
100
|
-
const inputIsCommandResuming = require_constants.isCommand(this.input) && this.input.resume != null;
|
|
101
|
-
const inputIsResuming = this.input === INPUT_RESUMING;
|
|
102
|
-
const runIdMatchesPrevious = !this.isNested && this.config.metadata?.run_id !== void 0 && this.checkpointMetadata?.run_id !== void 0 && this.config.metadata.run_id === this.checkpointMetadata?.run_id;
|
|
103
|
-
return hasChannelVersions && (configIsResuming || inputIsNullOrUndefined || inputIsCommandResuming || inputIsResuming || runIdMatchesPrevious);
|
|
104
|
-
}
|
|
105
|
-
constructor(params) {
|
|
106
|
-
this.input = params.input;
|
|
107
|
-
this.checkpointer = params.checkpointer;
|
|
108
|
-
if (this.checkpointer !== void 0) this.checkpointerGetNextVersion = this.checkpointer.getNextVersion.bind(this.checkpointer);
|
|
109
|
-
else this.checkpointerGetNextVersion = require_algo.increment;
|
|
110
|
-
this.checkpoint = params.checkpoint;
|
|
111
|
-
this.checkpointMetadata = params.checkpointMetadata;
|
|
112
|
-
this.checkpointPreviousVersions = params.checkpointPreviousVersions;
|
|
113
|
-
this.channels = params.channels;
|
|
114
|
-
this.checkpointPendingWrites = params.checkpointPendingWrites;
|
|
115
|
-
this.step = params.step;
|
|
116
|
-
this.stop = params.stop;
|
|
117
|
-
this.config = params.config;
|
|
118
|
-
this.checkpointConfig = params.checkpointConfig;
|
|
119
|
-
this.isNested = params.isNested;
|
|
120
|
-
this.manager = params.manager;
|
|
121
|
-
this.outputKeys = params.outputKeys;
|
|
122
|
-
this.streamKeys = params.streamKeys;
|
|
123
|
-
this.nodes = params.nodes;
|
|
124
|
-
this.skipDoneTasks = params.skipDoneTasks;
|
|
125
|
-
this.store = params.store;
|
|
126
|
-
this.cache = params.cache ? new AsyncBatchedCache(params.cache) : void 0;
|
|
127
|
-
this.stream = params.stream;
|
|
128
|
-
this.checkpointNamespace = params.checkpointNamespace;
|
|
129
|
-
this.prevCheckpointConfig = params.prevCheckpointConfig;
|
|
130
|
-
this.interruptAfter = params.interruptAfter;
|
|
131
|
-
this.interruptBefore = params.interruptBefore;
|
|
132
|
-
this.durability = params.durability;
|
|
133
|
-
this.debug = params.debug;
|
|
134
|
-
this.triggerToNodes = params.triggerToNodes;
|
|
135
|
-
}
|
|
136
|
-
static async initialize(params) {
|
|
137
|
-
let { config, stream } = params;
|
|
138
|
-
if (stream !== void 0 && config.configurable?.[require_constants.CONFIG_KEY_STREAM] !== void 0) stream = createDuplexStream(stream, config.configurable[require_constants.CONFIG_KEY_STREAM]);
|
|
139
|
-
const skipDoneTasks = config.configurable ? !("checkpoint_id" in config.configurable) : true;
|
|
140
|
-
const scratchpad = config.configurable?.[require_constants.CONFIG_KEY_SCRATCHPAD];
|
|
141
|
-
if (config.configurable && scratchpad) {
|
|
142
|
-
if (scratchpad.subgraphCounter > 0) config = require_index.patchConfigurable(config, { [require_constants.CONFIG_KEY_CHECKPOINT_NS]: [config.configurable[require_constants.CONFIG_KEY_CHECKPOINT_NS], scratchpad.subgraphCounter.toString()].join(require_constants.CHECKPOINT_NAMESPACE_SEPARATOR) });
|
|
143
|
-
scratchpad.subgraphCounter += 1;
|
|
144
|
-
}
|
|
145
|
-
const isNested = require_constants.CONFIG_KEY_READ in (config.configurable ?? {});
|
|
146
|
-
if (!isNested && config.configurable?.checkpoint_ns !== void 0 && config.configurable?.checkpoint_ns !== "") config = require_index.patchConfigurable(config, {
|
|
147
|
-
checkpoint_ns: "",
|
|
148
|
-
checkpoint_id: void 0
|
|
149
|
-
});
|
|
150
|
-
let checkpointConfig = config;
|
|
151
|
-
if (config.configurable?.[require_constants.CONFIG_KEY_CHECKPOINT_MAP] !== void 0 && config.configurable?.[require_constants.CONFIG_KEY_CHECKPOINT_MAP]?.[config.configurable?.checkpoint_ns]) checkpointConfig = require_index.patchConfigurable(config, { checkpoint_id: config.configurable[require_constants.CONFIG_KEY_CHECKPOINT_MAP][config.configurable?.checkpoint_ns] });
|
|
152
|
-
const checkpointNamespace = config.configurable?.checkpoint_ns?.split(require_constants.CHECKPOINT_NAMESPACE_SEPARATOR) ?? [];
|
|
153
|
-
const saved = await params.checkpointer?.getTuple(checkpointConfig) ?? {
|
|
154
|
-
config,
|
|
155
|
-
checkpoint: (0, __langchain_langgraph_checkpoint.emptyCheckpoint)(),
|
|
156
|
-
metadata: {
|
|
157
|
-
source: "input",
|
|
158
|
-
step: -2,
|
|
159
|
-
parents: {}
|
|
160
|
-
},
|
|
161
|
-
pendingWrites: []
|
|
162
|
-
};
|
|
163
|
-
checkpointConfig = {
|
|
164
|
-
...config,
|
|
165
|
-
...saved.config,
|
|
166
|
-
configurable: {
|
|
167
|
-
checkpoint_ns: "",
|
|
168
|
-
...config.configurable,
|
|
169
|
-
...saved.config.configurable
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
const prevCheckpointConfig = saved.parentConfig;
|
|
173
|
-
const checkpoint = (0, __langchain_langgraph_checkpoint.copyCheckpoint)(saved.checkpoint);
|
|
174
|
-
const checkpointMetadata = { ...saved.metadata };
|
|
175
|
-
const checkpointPendingWrites = saved.pendingWrites ?? [];
|
|
176
|
-
const channels = require_base.emptyChannels(params.channelSpecs, checkpoint);
|
|
177
|
-
const step = (checkpointMetadata.step ?? 0) + 1;
|
|
178
|
-
const stop = step + (config.recursionLimit ?? DEFAULT_LOOP_LIMIT) + 1;
|
|
179
|
-
const checkpointPreviousVersions = { ...checkpoint.channel_versions };
|
|
180
|
-
const store = params.store ? new __langchain_langgraph_checkpoint.AsyncBatchedStore(params.store) : void 0;
|
|
181
|
-
if (store) await store.start();
|
|
182
|
-
return new PregelLoop({
|
|
183
|
-
input: params.input,
|
|
184
|
-
config,
|
|
185
|
-
checkpointer: params.checkpointer,
|
|
186
|
-
checkpoint,
|
|
187
|
-
checkpointMetadata,
|
|
188
|
-
checkpointConfig,
|
|
189
|
-
prevCheckpointConfig,
|
|
190
|
-
checkpointNamespace,
|
|
191
|
-
channels,
|
|
192
|
-
isNested,
|
|
193
|
-
manager: params.manager,
|
|
194
|
-
skipDoneTasks,
|
|
195
|
-
step,
|
|
196
|
-
stop,
|
|
197
|
-
checkpointPreviousVersions,
|
|
198
|
-
checkpointPendingWrites,
|
|
199
|
-
outputKeys: params.outputKeys ?? [],
|
|
200
|
-
streamKeys: params.streamKeys ?? [],
|
|
201
|
-
nodes: params.nodes,
|
|
202
|
-
stream,
|
|
203
|
-
store,
|
|
204
|
-
cache: params.cache,
|
|
205
|
-
interruptAfter: params.interruptAfter,
|
|
206
|
-
interruptBefore: params.interruptBefore,
|
|
207
|
-
durability: params.durability,
|
|
208
|
-
debug: params.debug,
|
|
209
|
-
triggerToNodes: params.triggerToNodes
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
_checkpointerPutAfterPrevious(input) {
|
|
213
|
-
this._checkpointerChainedPromise = this._checkpointerChainedPromise.then(() => {
|
|
214
|
-
return this.checkpointer?.put(input.config, input.checkpoint, input.metadata, input.newVersions);
|
|
215
|
-
});
|
|
216
|
-
this.checkpointerPromises.push(this._checkpointerChainedPromise);
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Put writes for a task, to be read by the next tick.
|
|
220
|
-
* @param taskId
|
|
221
|
-
* @param writes
|
|
222
|
-
*/
|
|
223
|
-
putWrites(taskId, writes) {
|
|
224
|
-
let writesCopy = writes;
|
|
225
|
-
if (writesCopy.length === 0) return;
|
|
226
|
-
if (writesCopy.every(([key]) => key in __langchain_langgraph_checkpoint.WRITES_IDX_MAP)) writesCopy = Array.from(new Map(writesCopy.map((w) => [w[0], w])).values());
|
|
227
|
-
this.checkpointPendingWrites = this.checkpointPendingWrites.filter((w) => w[0] !== taskId);
|
|
228
|
-
for (const [c, v] of writesCopy) this.checkpointPendingWrites.push([
|
|
229
|
-
taskId,
|
|
230
|
-
c,
|
|
231
|
-
v
|
|
232
|
-
]);
|
|
233
|
-
const config = require_index.patchConfigurable(this.checkpointConfig, {
|
|
234
|
-
[require_constants.CONFIG_KEY_CHECKPOINT_NS]: this.config.configurable?.checkpoint_ns ?? "",
|
|
235
|
-
[require_constants.CONFIG_KEY_CHECKPOINT_ID]: this.checkpoint.id
|
|
236
|
-
});
|
|
237
|
-
if (this.durability !== "exit" && this.checkpointer != null) this.checkpointerPromises.push(this.checkpointer.putWrites(config, writesCopy, taskId));
|
|
238
|
-
if (this.tasks) this._outputWrites(taskId, writesCopy);
|
|
239
|
-
if (!writes.length || !this.cache || !this.tasks) return;
|
|
240
|
-
const task = this.tasks[taskId];
|
|
241
|
-
if (task == null || task.cache_key == null) return;
|
|
242
|
-
if (writes[0][0] === require_constants.ERROR || writes[0][0] === require_constants.INTERRUPT) return;
|
|
243
|
-
this.cache.set([{
|
|
244
|
-
key: [task.cache_key.ns, task.cache_key.key],
|
|
245
|
-
value: task.writes,
|
|
246
|
-
ttl: task.cache_key.ttl
|
|
247
|
-
}]);
|
|
248
|
-
}
|
|
249
|
-
_outputWrites(taskId, writes, cached = false) {
|
|
250
|
-
const task = this.tasks[taskId];
|
|
251
|
-
if (task !== void 0) {
|
|
252
|
-
if (task.config !== void 0 && (task.config.tags ?? []).includes(require_constants.TAG_HIDDEN)) return;
|
|
253
|
-
if (writes.length > 0) {
|
|
254
|
-
if (writes[0][0] === require_constants.INTERRUPT) {
|
|
255
|
-
if (task.path?.[0] === require_constants.PUSH && task.path?.at(-1) === true) return;
|
|
256
|
-
const interruptWrites = writes.filter((w) => w[0] === require_constants.INTERRUPT).flatMap((w) => w[1]);
|
|
257
|
-
this._emit([["updates", { [require_constants.INTERRUPT]: interruptWrites }], ["values", { [require_constants.INTERRUPT]: interruptWrites }]]);
|
|
258
|
-
} else if (writes[0][0] !== require_constants.ERROR) this._emit(require_utils.gatherIteratorSync(require_utils.prefixGenerator(require_io.mapOutputUpdates(this.outputKeys, [[task, writes]], cached), "updates")));
|
|
259
|
-
}
|
|
260
|
-
if (!cached) this._emit(require_utils.gatherIteratorSync(require_utils.prefixGenerator(require_debug.mapDebugTaskResults([[task, writes]], this.streamKeys), "tasks")));
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
async _matchCachedWrites() {
|
|
264
|
-
if (!this.cache) return [];
|
|
265
|
-
const matched = [];
|
|
266
|
-
const serializeKey = ([ns, key]) => {
|
|
267
|
-
return `ns:${ns.join(",")}|key:${key}`;
|
|
268
|
-
};
|
|
269
|
-
const keys = [];
|
|
270
|
-
const keyMap = {};
|
|
271
|
-
for (const task of Object.values(this.tasks)) if (task.cache_key != null && !task.writes.length) {
|
|
272
|
-
keys.push([task.cache_key.ns, task.cache_key.key]);
|
|
273
|
-
keyMap[serializeKey([task.cache_key.ns, task.cache_key.key])] = task;
|
|
274
|
-
}
|
|
275
|
-
if (keys.length === 0) return [];
|
|
276
|
-
const cache = await this.cache.get(keys);
|
|
277
|
-
for (const { key, value } of cache) {
|
|
278
|
-
const task = keyMap[serializeKey(key)];
|
|
279
|
-
if (task != null) {
|
|
280
|
-
task.writes.push(...value);
|
|
281
|
-
matched.push({
|
|
282
|
-
task,
|
|
283
|
-
result: value
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
return matched;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Execute a single iteration of the Pregel loop.
|
|
291
|
-
* Returns true if more iterations are needed.
|
|
292
|
-
* @param params
|
|
293
|
-
*/
|
|
294
|
-
async tick(params) {
|
|
295
|
-
if (this.store && !this.store.isRunning) await this.store?.start();
|
|
296
|
-
const { inputKeys = [] } = params;
|
|
297
|
-
if (this.status !== "pending") throw new Error(`Cannot tick when status is no longer "pending". Current status: "${this.status}"`);
|
|
298
|
-
if (![INPUT_DONE, INPUT_RESUMING].includes(this.input)) await this._first(inputKeys);
|
|
299
|
-
else if (this.toInterrupt.length > 0) {
|
|
300
|
-
this.status = "interrupt_before";
|
|
301
|
-
throw new require_errors.GraphInterrupt();
|
|
302
|
-
} else if (Object.values(this.tasks).every((task) => task.writes.length > 0)) {
|
|
303
|
-
const writes = Object.values(this.tasks).flatMap((t) => t.writes);
|
|
304
|
-
this.updatedChannels = require_algo._applyWrites(this.checkpoint, this.channels, Object.values(this.tasks), this.checkpointerGetNextVersion, this.triggerToNodes);
|
|
305
|
-
const valuesOutput = await require_utils.gatherIterator(require_utils.prefixGenerator(require_io.mapOutputValues(this.outputKeys, writes, this.channels), "values"));
|
|
306
|
-
this._emit(valuesOutput);
|
|
307
|
-
this.checkpointPendingWrites = [];
|
|
308
|
-
await this._putCheckpoint({ source: "loop" });
|
|
309
|
-
if (require_algo.shouldInterrupt(this.checkpoint, this.interruptAfter, Object.values(this.tasks))) {
|
|
310
|
-
this.status = "interrupt_after";
|
|
311
|
-
throw new require_errors.GraphInterrupt();
|
|
312
|
-
}
|
|
313
|
-
if (this.config.configurable?.[require_constants.CONFIG_KEY_RESUMING] !== void 0) delete this.config.configurable?.[require_constants.CONFIG_KEY_RESUMING];
|
|
314
|
-
} else return false;
|
|
315
|
-
if (this.step > this.stop) {
|
|
316
|
-
this.status = "out_of_steps";
|
|
317
|
-
return false;
|
|
318
|
-
}
|
|
319
|
-
const nextTasks = require_algo._prepareNextTasks(this.checkpoint, this.checkpointPendingWrites, this.nodes, this.channels, this.config, true, {
|
|
320
|
-
step: this.step,
|
|
321
|
-
checkpointer: this.checkpointer,
|
|
322
|
-
isResuming: this.isResuming,
|
|
323
|
-
manager: this.manager,
|
|
324
|
-
store: this.store,
|
|
325
|
-
stream: this.stream,
|
|
326
|
-
triggerToNodes: this.triggerToNodes,
|
|
327
|
-
updatedChannels: this.updatedChannels
|
|
328
|
-
});
|
|
329
|
-
this.tasks = nextTasks;
|
|
330
|
-
if (this.checkpointer) this._emit(await require_utils.gatherIterator(require_utils.prefixGenerator(require_debug.mapDebugCheckpoint(this.checkpointConfig, this.channels, this.streamKeys, this.checkpointMetadata, Object.values(this.tasks), this.checkpointPendingWrites, this.prevCheckpointConfig, this.outputKeys), "checkpoints")));
|
|
331
|
-
if (Object.values(this.tasks).length === 0) {
|
|
332
|
-
this.status = "done";
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
if (this.skipDoneTasks && this.checkpointPendingWrites.length > 0) {
|
|
336
|
-
for (const [tid, k, v] of this.checkpointPendingWrites) {
|
|
337
|
-
if (k === require_constants.ERROR || k === require_constants.INTERRUPT || k === require_constants.RESUME) continue;
|
|
338
|
-
const task = Object.values(this.tasks).find((t) => t.id === tid);
|
|
339
|
-
if (task) task.writes.push([k, v]);
|
|
340
|
-
}
|
|
341
|
-
for (const task of Object.values(this.tasks)) if (task.writes.length > 0) this._outputWrites(task.id, task.writes, true);
|
|
342
|
-
}
|
|
343
|
-
if (Object.values(this.tasks).every((task) => task.writes.length > 0)) return this.tick({ inputKeys });
|
|
344
|
-
if (require_algo.shouldInterrupt(this.checkpoint, this.interruptBefore, Object.values(this.tasks))) {
|
|
345
|
-
this.status = "interrupt_before";
|
|
346
|
-
throw new require_errors.GraphInterrupt();
|
|
347
|
-
}
|
|
348
|
-
const debugOutput = await require_utils.gatherIterator(require_utils.prefixGenerator(require_debug.mapDebugTasks(Object.values(this.tasks)), "tasks"));
|
|
349
|
-
this._emit(debugOutput);
|
|
350
|
-
return true;
|
|
351
|
-
}
|
|
352
|
-
async finishAndHandleError(error) {
|
|
353
|
-
if (this.durability === "exit" && (!this.isNested || typeof error !== "undefined" || this.checkpointNamespace.every((part) => !part.includes(require_constants.CHECKPOINT_NAMESPACE_END)))) {
|
|
354
|
-
this._putCheckpoint(this.checkpointMetadata);
|
|
355
|
-
this._flushPendingWrites();
|
|
356
|
-
}
|
|
357
|
-
const suppress = this._suppressInterrupt(error);
|
|
358
|
-
if (suppress || error === void 0) this.output = require_io.readChannels(this.channels, this.outputKeys);
|
|
359
|
-
if (suppress) {
|
|
360
|
-
if (this.tasks !== void 0 && this.checkpointPendingWrites.length > 0 && Object.values(this.tasks).some((task) => task.writes.length > 0)) {
|
|
361
|
-
this.updatedChannels = require_algo._applyWrites(this.checkpoint, this.channels, Object.values(this.tasks), this.checkpointerGetNextVersion, this.triggerToNodes);
|
|
362
|
-
this._emit(require_utils.gatherIteratorSync(require_utils.prefixGenerator(require_io.mapOutputValues(this.outputKeys, Object.values(this.tasks).flatMap((t) => t.writes), this.channels), "values")));
|
|
363
|
-
}
|
|
364
|
-
if (require_errors.isGraphInterrupt(error) && !error.interrupts.length) this._emit([["updates", { [require_constants.INTERRUPT]: [] }], ["values", { [require_constants.INTERRUPT]: [] }]]);
|
|
365
|
-
}
|
|
366
|
-
return suppress;
|
|
367
|
-
}
|
|
368
|
-
async acceptPush(task, writeIdx, call) {
|
|
369
|
-
if (this.interruptAfter?.length > 0 && require_algo.shouldInterrupt(this.checkpoint, this.interruptAfter, [task])) {
|
|
370
|
-
this.toInterrupt.push(task);
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
const pushed = require_algo._prepareSingleTask([
|
|
374
|
-
require_constants.PUSH,
|
|
375
|
-
task.path ?? [],
|
|
376
|
-
writeIdx,
|
|
377
|
-
task.id,
|
|
378
|
-
call
|
|
379
|
-
], this.checkpoint, this.checkpointPendingWrites, this.nodes, this.channels, task.config ?? {}, true, {
|
|
380
|
-
step: this.step,
|
|
381
|
-
checkpointer: this.checkpointer,
|
|
382
|
-
manager: this.manager,
|
|
383
|
-
store: this.store,
|
|
384
|
-
stream: this.stream
|
|
385
|
-
});
|
|
386
|
-
if (!pushed) return;
|
|
387
|
-
if (this.interruptBefore?.length > 0 && require_algo.shouldInterrupt(this.checkpoint, this.interruptBefore, [pushed])) {
|
|
388
|
-
this.toInterrupt.push(pushed);
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
this._emit(require_utils.gatherIteratorSync(require_utils.prefixGenerator(require_debug.mapDebugTasks([pushed]), "tasks")));
|
|
392
|
-
if (this.debug) require_debug.printStepTasks(this.step, [pushed]);
|
|
393
|
-
this.tasks[pushed.id] = pushed;
|
|
394
|
-
if (this.skipDoneTasks) this._matchWrites({ [pushed.id]: pushed });
|
|
395
|
-
const tasks = await this._matchCachedWrites();
|
|
396
|
-
for (const { task: task$1 } of tasks) this._outputWrites(task$1.id, task$1.writes, true);
|
|
397
|
-
return pushed;
|
|
398
|
-
}
|
|
399
|
-
_suppressInterrupt(e) {
|
|
400
|
-
return require_errors.isGraphInterrupt(e) && !this.isNested;
|
|
401
|
-
}
|
|
402
|
-
async _first(inputKeys) {
|
|
403
|
-
const { configurable } = this.config;
|
|
404
|
-
const scratchpad = configurable?.[require_constants.CONFIG_KEY_SCRATCHPAD];
|
|
405
|
-
if (scratchpad && scratchpad.nullResume !== void 0) this.putWrites(require_constants.NULL_TASK_ID, [[require_constants.RESUME, scratchpad.nullResume]]);
|
|
406
|
-
if (require_constants.isCommand(this.input)) {
|
|
407
|
-
const hasResume = this.input.resume != null;
|
|
408
|
-
if (this.input.resume != null && typeof this.input.resume === "object" && Object.keys(this.input.resume).every(require_hash.isXXH3)) {
|
|
409
|
-
this.config.configurable ??= {};
|
|
410
|
-
this.config.configurable[require_constants.CONFIG_KEY_RESUME_MAP] = this.input.resume;
|
|
411
|
-
}
|
|
412
|
-
if (hasResume && this.checkpointer == null) throw new Error("Cannot use Command(resume=...) without checkpointer");
|
|
413
|
-
const writes = {};
|
|
414
|
-
for (const [tid, key, value] of require_io.mapCommand(this.input, this.checkpointPendingWrites)) {
|
|
415
|
-
writes[tid] ??= [];
|
|
416
|
-
writes[tid].push([key, value]);
|
|
417
|
-
}
|
|
418
|
-
if (Object.keys(writes).length === 0) throw new require_errors.EmptyInputError("Received empty Command input");
|
|
419
|
-
for (const [tid, ws] of Object.entries(writes)) this.putWrites(tid, ws);
|
|
420
|
-
}
|
|
421
|
-
const nullWrites = (this.checkpointPendingWrites ?? []).filter((w) => w[0] === require_constants.NULL_TASK_ID).map((w) => w.slice(1));
|
|
422
|
-
if (nullWrites.length > 0) require_algo._applyWrites(this.checkpoint, this.channels, [{
|
|
423
|
-
name: require_constants.INPUT,
|
|
424
|
-
writes: nullWrites,
|
|
425
|
-
triggers: []
|
|
426
|
-
}], this.checkpointerGetNextVersion, this.triggerToNodes);
|
|
427
|
-
const isCommandUpdateOrGoto = require_constants.isCommand(this.input) && nullWrites.length > 0;
|
|
428
|
-
if (this.isResuming || isCommandUpdateOrGoto) {
|
|
429
|
-
for (const channelName in this.channels) {
|
|
430
|
-
if (!Object.prototype.hasOwnProperty.call(this.channels, channelName)) continue;
|
|
431
|
-
if (this.checkpoint.channel_versions[channelName] !== void 0) {
|
|
432
|
-
const version = this.checkpoint.channel_versions[channelName];
|
|
433
|
-
this.checkpoint.versions_seen[require_constants.INTERRUPT] = {
|
|
434
|
-
...this.checkpoint.versions_seen[require_constants.INTERRUPT],
|
|
435
|
-
[channelName]: version
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
const valuesOutput = await require_utils.gatherIterator(require_utils.prefixGenerator(require_io.mapOutputValues(this.outputKeys, true, this.channels), "values"));
|
|
440
|
-
this._emit(valuesOutput);
|
|
441
|
-
}
|
|
442
|
-
if (this.isResuming) this.input = INPUT_RESUMING;
|
|
443
|
-
else if (isCommandUpdateOrGoto) {
|
|
444
|
-
await this._putCheckpoint({ source: "input" });
|
|
445
|
-
this.input = INPUT_DONE;
|
|
446
|
-
} else {
|
|
447
|
-
const inputWrites = await require_utils.gatherIterator(require_io.mapInput(inputKeys, this.input));
|
|
448
|
-
if (inputWrites.length > 0) {
|
|
449
|
-
const discardTasks = require_algo._prepareNextTasks(this.checkpoint, this.checkpointPendingWrites, this.nodes, this.channels, this.config, true, { step: this.step });
|
|
450
|
-
this.updatedChannels = require_algo._applyWrites(this.checkpoint, this.channels, Object.values(discardTasks).concat([{
|
|
451
|
-
name: require_constants.INPUT,
|
|
452
|
-
writes: inputWrites,
|
|
453
|
-
triggers: []
|
|
454
|
-
}]), this.checkpointerGetNextVersion, this.triggerToNodes);
|
|
455
|
-
await this._putCheckpoint({ source: "input" });
|
|
456
|
-
this.input = INPUT_DONE;
|
|
457
|
-
} else if (!(require_constants.CONFIG_KEY_RESUMING in (this.config.configurable ?? {}))) throw new require_errors.EmptyInputError(`Received no input writes for ${JSON.stringify(inputKeys, null, 2)}`);
|
|
458
|
-
else this.input = INPUT_DONE;
|
|
459
|
-
}
|
|
460
|
-
if (!this.isNested) this.config = require_index.patchConfigurable(this.config, { [require_constants.CONFIG_KEY_RESUMING]: this.isResuming });
|
|
461
|
-
}
|
|
462
|
-
_emit(values) {
|
|
463
|
-
for (const [mode, payload] of values) {
|
|
464
|
-
if (this.stream.modes.has(mode)) this.stream.push([
|
|
465
|
-
this.checkpointNamespace,
|
|
466
|
-
mode,
|
|
467
|
-
payload
|
|
468
|
-
]);
|
|
469
|
-
if ((mode === "checkpoints" || mode === "tasks") && this.stream.modes.has("debug")) {
|
|
470
|
-
const step = mode === "checkpoints" ? this.step - 1 : this.step;
|
|
471
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
472
|
-
const type = (() => {
|
|
473
|
-
if (mode === "checkpoints") return "checkpoint";
|
|
474
|
-
else if (typeof payload === "object" && payload != null && "result" in payload) return "task_result";
|
|
475
|
-
else return "task";
|
|
476
|
-
})();
|
|
477
|
-
this.stream.push([
|
|
478
|
-
this.checkpointNamespace,
|
|
479
|
-
"debug",
|
|
480
|
-
{
|
|
481
|
-
step,
|
|
482
|
-
type,
|
|
483
|
-
timestamp,
|
|
484
|
-
payload
|
|
485
|
-
}
|
|
486
|
-
]);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
_putCheckpoint(inputMetadata) {
|
|
491
|
-
const exiting = this.checkpointMetadata === inputMetadata;
|
|
492
|
-
const doCheckpoint = this.checkpointer != null && (this.durability !== "exit" || exiting);
|
|
493
|
-
const storeCheckpoint = (checkpoint) => {
|
|
494
|
-
this.prevCheckpointConfig = this.checkpointConfig?.configurable?.checkpoint_id ? this.checkpointConfig : void 0;
|
|
495
|
-
this.checkpointConfig = require_index.patchConfigurable(this.checkpointConfig, { [require_constants.CONFIG_KEY_CHECKPOINT_NS]: this.config.configurable?.checkpoint_ns ?? "" });
|
|
496
|
-
const channelVersions = { ...this.checkpoint.channel_versions };
|
|
497
|
-
const newVersions = require_index.getNewChannelVersions(this.checkpointPreviousVersions, channelVersions);
|
|
498
|
-
this.checkpointPreviousVersions = channelVersions;
|
|
499
|
-
this._checkpointerPutAfterPrevious({
|
|
500
|
-
config: { ...this.checkpointConfig },
|
|
501
|
-
checkpoint: (0, __langchain_langgraph_checkpoint.copyCheckpoint)(checkpoint),
|
|
502
|
-
metadata: { ...this.checkpointMetadata },
|
|
503
|
-
newVersions
|
|
504
|
-
});
|
|
505
|
-
this.checkpointConfig = {
|
|
506
|
-
...this.checkpointConfig,
|
|
507
|
-
configurable: {
|
|
508
|
-
...this.checkpointConfig.configurable,
|
|
509
|
-
checkpoint_id: this.checkpoint.id
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
};
|
|
513
|
-
if (!exiting) this.checkpointMetadata = {
|
|
514
|
-
...inputMetadata,
|
|
515
|
-
step: this.step,
|
|
516
|
-
parents: this.config.configurable?.[require_constants.CONFIG_KEY_CHECKPOINT_MAP] ?? {}
|
|
517
|
-
};
|
|
518
|
-
this.checkpoint = require_base.createCheckpoint(this.checkpoint, doCheckpoint ? this.channels : void 0, this.step, exiting ? { id: this.checkpoint.id } : void 0);
|
|
519
|
-
if (doCheckpoint) storeCheckpoint(this.checkpoint);
|
|
520
|
-
if (!exiting) this.step += 1;
|
|
521
|
-
}
|
|
522
|
-
_flushPendingWrites() {
|
|
523
|
-
if (this.checkpointer == null) return;
|
|
524
|
-
if (this.checkpointPendingWrites.length === 0) return;
|
|
525
|
-
const config = require_index.patchConfigurable(this.checkpointConfig, {
|
|
526
|
-
[require_constants.CONFIG_KEY_CHECKPOINT_NS]: this.config.configurable?.checkpoint_ns ?? "",
|
|
527
|
-
[require_constants.CONFIG_KEY_CHECKPOINT_ID]: this.checkpoint.id
|
|
528
|
-
});
|
|
529
|
-
const byTask = {};
|
|
530
|
-
for (const [tid, key, value] of this.checkpointPendingWrites) {
|
|
531
|
-
byTask[tid] ??= [];
|
|
532
|
-
byTask[tid].push([key, value]);
|
|
533
|
-
}
|
|
534
|
-
for (const [tid, ws] of Object.entries(byTask)) this.checkpointerPromises.push(this.checkpointer.putWrites(config, ws, tid));
|
|
535
|
-
}
|
|
536
|
-
_matchWrites(tasks) {
|
|
537
|
-
for (const [tid, k, v] of this.checkpointPendingWrites) {
|
|
538
|
-
if (k === require_constants.ERROR || k === require_constants.INTERRUPT || k === require_constants.RESUME) continue;
|
|
539
|
-
const task = Object.values(tasks).find((t) => t.id === tid);
|
|
540
|
-
if (task) task.writes.push([k, v]);
|
|
541
|
-
}
|
|
542
|
-
for (const task of Object.values(tasks)) if (task.writes.length > 0) this._outputWrites(task.id, task.writes, true);
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
//#endregion
|
|
547
|
-
exports.PregelLoop = PregelLoop;
|
|
548
|
-
//# sourceMappingURL=loop.cjs.map
|