@langchain/langgraph 1.2.9 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/graph/graph.cjs +6 -2
- package/dist/graph/graph.cjs.map +1 -1
- package/dist/graph/graph.d.cts +58 -7
- package/dist/graph/graph.d.cts.map +1 -1
- package/dist/graph/graph.d.ts +58 -7
- package/dist/graph/graph.d.ts.map +1 -1
- package/dist/graph/graph.js +6 -2
- package/dist/graph/graph.js.map +1 -1
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/state.cjs +3 -2
- package/dist/graph/state.cjs.map +1 -1
- package/dist/graph/state.d.cts +13 -5
- package/dist/graph/state.d.cts.map +1 -1
- package/dist/graph/state.d.ts +13 -5
- package/dist/graph/state.d.ts.map +1 -1
- package/dist/graph/state.js +3 -2
- package/dist/graph/state.js.map +1 -1
- package/dist/index.cjs +34 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/prebuilt/agent_executor.d.cts +1 -1
- package/dist/prebuilt/agent_executor.d.ts +1 -1
- package/dist/pregel/index.cjs +69 -25
- package/dist/pregel/index.cjs.map +1 -1
- package/dist/pregel/index.d.cts +25 -3
- package/dist/pregel/index.d.cts.map +1 -1
- package/dist/pregel/index.d.ts +25 -3
- package/dist/pregel/index.d.ts.map +1 -1
- package/dist/pregel/index.js +69 -25
- package/dist/pregel/index.js.map +1 -1
- package/dist/pregel/loop.cjs +51 -10
- package/dist/pregel/loop.cjs.map +1 -1
- package/dist/pregel/loop.js +51 -10
- package/dist/pregel/loop.js.map +1 -1
- package/dist/pregel/messages-v2.cjs +231 -0
- package/dist/pregel/messages-v2.cjs.map +1 -0
- package/dist/pregel/messages-v2.js +231 -0
- package/dist/pregel/messages-v2.js.map +1 -0
- package/dist/pregel/stream.cjs.map +1 -1
- package/dist/pregel/stream.d.cts +30 -0
- package/dist/pregel/stream.d.cts.map +1 -0
- package/dist/pregel/stream.d.ts +30 -1
- package/dist/pregel/stream.d.ts.map +1 -0
- package/dist/pregel/stream.js.map +1 -1
- package/dist/pregel/types.cjs.map +1 -1
- package/dist/pregel/types.d.cts +8 -1
- package/dist/pregel/types.d.cts.map +1 -1
- package/dist/pregel/types.d.ts +8 -1
- package/dist/pregel/types.d.ts.map +1 -1
- package/dist/pregel/types.js.map +1 -1
- package/dist/stream/convert.cjs +207 -0
- package/dist/stream/convert.cjs.map +1 -0
- package/dist/stream/convert.d.cts +69 -0
- package/dist/stream/convert.d.cts.map +1 -0
- package/dist/stream/convert.d.ts +69 -0
- package/dist/stream/convert.d.ts.map +1 -0
- package/dist/stream/convert.js +206 -0
- package/dist/stream/convert.js.map +1 -0
- package/dist/stream/index.cjs +11 -0
- package/dist/stream/index.d.cts +12 -0
- package/dist/stream/index.d.ts +12 -0
- package/dist/stream/index.js +12 -0
- package/dist/stream/mux.cjs +350 -0
- package/dist/stream/mux.cjs.map +1 -0
- package/dist/stream/mux.d.cts +160 -0
- package/dist/stream/mux.d.cts.map +1 -0
- package/dist/stream/mux.d.ts +160 -0
- package/dist/stream/mux.d.ts.map +1 -0
- package/dist/stream/mux.js +345 -0
- package/dist/stream/mux.js.map +1 -0
- package/dist/stream/run-stream.cjs +439 -0
- package/dist/stream/run-stream.cjs.map +1 -0
- package/dist/stream/run-stream.d.cts +286 -0
- package/dist/stream/run-stream.d.cts.map +1 -0
- package/dist/stream/run-stream.d.ts +285 -0
- package/dist/stream/run-stream.d.ts.map +1 -0
- package/dist/stream/run-stream.js +434 -0
- package/dist/stream/run-stream.js.map +1 -0
- package/dist/stream/stream-channel.cjs +208 -0
- package/dist/stream/stream-channel.cjs.map +1 -0
- package/dist/stream/stream-channel.d.cts +129 -0
- package/dist/stream/stream-channel.d.cts.map +1 -0
- package/dist/stream/stream-channel.d.ts +129 -0
- package/dist/stream/stream-channel.d.ts.map +1 -0
- package/dist/stream/stream-channel.js +207 -0
- package/dist/stream/stream-channel.js.map +1 -0
- package/dist/stream/transformers/index.cjs +4 -0
- package/dist/stream/transformers/index.d.ts +5 -0
- package/dist/stream/transformers/index.js +5 -0
- package/dist/stream/transformers/lifecycle.cjs +326 -0
- package/dist/stream/transformers/lifecycle.cjs.map +1 -0
- package/dist/stream/transformers/lifecycle.d.cts +53 -0
- package/dist/stream/transformers/lifecycle.d.cts.map +1 -0
- package/dist/stream/transformers/lifecycle.d.ts +53 -0
- package/dist/stream/transformers/lifecycle.d.ts.map +1 -0
- package/dist/stream/transformers/lifecycle.js +325 -0
- package/dist/stream/transformers/lifecycle.js.map +1 -0
- package/dist/stream/transformers/messages.cjs +94 -0
- package/dist/stream/transformers/messages.cjs.map +1 -0
- package/dist/stream/transformers/messages.d.cts +23 -0
- package/dist/stream/transformers/messages.d.cts.map +1 -0
- package/dist/stream/transformers/messages.d.ts +23 -0
- package/dist/stream/transformers/messages.d.ts.map +1 -0
- package/dist/stream/transformers/messages.js +94 -0
- package/dist/stream/transformers/messages.js.map +1 -0
- package/dist/stream/transformers/subgraphs.cjs +125 -0
- package/dist/stream/transformers/subgraphs.cjs.map +1 -0
- package/dist/stream/transformers/subgraphs.d.cts +95 -0
- package/dist/stream/transformers/subgraphs.d.cts.map +1 -0
- package/dist/stream/transformers/subgraphs.d.ts +95 -0
- package/dist/stream/transformers/subgraphs.d.ts.map +1 -0
- package/dist/stream/transformers/subgraphs.js +124 -0
- package/dist/stream/transformers/subgraphs.js.map +1 -0
- package/dist/stream/transformers/types.d.cts +89 -0
- package/dist/stream/transformers/types.d.cts.map +1 -0
- package/dist/stream/transformers/types.d.ts +89 -0
- package/dist/stream/transformers/types.d.ts.map +1 -0
- package/dist/stream/transformers/values.cjs +39 -0
- package/dist/stream/transformers/values.cjs.map +1 -0
- package/dist/stream/transformers/values.d.cts +21 -0
- package/dist/stream/transformers/values.d.cts.map +1 -0
- package/dist/stream/transformers/values.d.ts +21 -0
- package/dist/stream/transformers/values.d.ts.map +1 -0
- package/dist/stream/transformers/values.js +39 -0
- package/dist/stream/transformers/values.js.map +1 -0
- package/dist/stream/types.cjs +11 -0
- package/dist/stream/types.cjs.map +1 -0
- package/dist/stream/types.d.cts +255 -0
- package/dist/stream/types.d.cts.map +1 -0
- package/dist/stream/types.d.ts +255 -0
- package/dist/stream/types.d.ts.map +1 -0
- package/dist/stream/types.js +11 -0
- package/dist/stream/types.js.map +1 -0
- package/dist/web.cjs +39 -9
- package/dist/web.d.cts +12 -2
- package/dist/web.d.ts +12 -2
- package/dist/web.js +10 -1
- package/package.json +9 -8
package/dist/index.cjs
CHANGED
|
@@ -6,16 +6,24 @@ const require_base = require("./channels/base.cjs");
|
|
|
6
6
|
const require_binop = require("./channels/binop.cjs");
|
|
7
7
|
const require_annotation = require("./graph/annotation.cjs");
|
|
8
8
|
const require_config = require("./pregel/utils/config.cjs");
|
|
9
|
+
const require_stream_channel = require("./stream/stream-channel.cjs");
|
|
10
|
+
const require_convert = require("./stream/convert.cjs");
|
|
11
|
+
const require_lifecycle = require("./stream/transformers/lifecycle.cjs");
|
|
12
|
+
const require_messages = require("./stream/transformers/messages.cjs");
|
|
13
|
+
const require_subgraphs = require("./stream/transformers/subgraphs.cjs");
|
|
14
|
+
const require_values = require("./stream/transformers/values.cjs");
|
|
15
|
+
const require_types = require("./stream/types.cjs");
|
|
16
|
+
const require_run_stream = require("./stream/run-stream.cjs");
|
|
9
17
|
const require_interrupt = require("./interrupt.cjs");
|
|
10
18
|
const require_graph = require("./graph/graph.cjs");
|
|
11
|
-
const require_types = require("./state/types.cjs");
|
|
19
|
+
const require_types$1 = require("./state/types.cjs");
|
|
12
20
|
const require_adapter = require("./state/adapter.cjs");
|
|
13
21
|
const require_untracked_value = require("./channels/untracked_value.cjs");
|
|
14
22
|
const require_reduced = require("./state/values/reduced.cjs");
|
|
15
23
|
const require_untracked = require("./state/values/untracked.cjs");
|
|
16
24
|
const require_schema = require("./state/schema.cjs");
|
|
17
25
|
const require_messages_reducer = require("./graph/messages_reducer.cjs");
|
|
18
|
-
const require_messages = require("./state/prebuilt/messages.cjs");
|
|
26
|
+
const require_messages$1 = require("./state/prebuilt/messages.cjs");
|
|
19
27
|
const require_state = require("./graph/state.cjs");
|
|
20
28
|
const require_message = require("./graph/message.cjs");
|
|
21
29
|
const require_index = require("./func/index.cjs");
|
|
@@ -23,6 +31,7 @@ const require_messages_annotation = require("./graph/messages_annotation.cjs");
|
|
|
23
31
|
const require_writer = require("./writer.cjs");
|
|
24
32
|
require("./web.cjs");
|
|
25
33
|
let _langchain_langgraph_checkpoint = require("@langchain/langgraph-checkpoint");
|
|
34
|
+
let _langchain_core_language_models_stream = require("@langchain/core/language_models/stream");
|
|
26
35
|
//#region src/index.ts
|
|
27
36
|
require_async_local_storage.initializeAsyncLocalStorageSingleton();
|
|
28
37
|
//#endregion
|
|
@@ -49,16 +58,24 @@ Object.defineProperty(exports, "BaseStore", {
|
|
|
49
58
|
});
|
|
50
59
|
exports.BinaryOperatorAggregate = require_binop.BinaryOperatorAggregate;
|
|
51
60
|
exports.COMMAND_SYMBOL = require_constants.COMMAND_SYMBOL;
|
|
61
|
+
Object.defineProperty(exports, "ChatModelStreamImpl", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function() {
|
|
64
|
+
return _langchain_core_language_models_stream.ChatModelStream;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
52
67
|
exports.Command = require_constants.Command;
|
|
53
68
|
exports.CommandInstance = require_constants.CommandInstance;
|
|
54
69
|
exports.CompiledStateGraph = require_state.CompiledStateGraph;
|
|
55
70
|
exports.END = require_constants.END;
|
|
56
71
|
exports.EmptyChannelError = require_errors.EmptyChannelError;
|
|
57
72
|
exports.EmptyInputError = require_errors.EmptyInputError;
|
|
73
|
+
exports.EventLog = require_stream_channel.StreamChannel;
|
|
58
74
|
exports.Graph = require_graph.Graph;
|
|
59
75
|
exports.GraphBubbleUp = require_errors.GraphBubbleUp;
|
|
60
76
|
exports.GraphInterrupt = require_errors.GraphInterrupt;
|
|
61
77
|
exports.GraphRecursionError = require_errors.GraphRecursionError;
|
|
78
|
+
exports.GraphRunStream = require_run_stream.GraphRunStream;
|
|
62
79
|
exports.GraphValueError = require_errors.GraphValueError;
|
|
63
80
|
exports.INTERRUPT = require_constants.INTERRUPT;
|
|
64
81
|
Object.defineProperty(exports, "InMemoryStore", {
|
|
@@ -76,7 +93,7 @@ Object.defineProperty(exports, "MemorySaver", {
|
|
|
76
93
|
});
|
|
77
94
|
exports.MessageGraph = require_message.MessageGraph;
|
|
78
95
|
exports.MessagesAnnotation = require_messages_annotation.MessagesAnnotation;
|
|
79
|
-
exports.MessagesValue = require_messages.MessagesValue;
|
|
96
|
+
exports.MessagesValue = require_messages$1.MessagesValue;
|
|
80
97
|
exports.MessagesZodMeta = require_messages_annotation.MessagesZodMeta;
|
|
81
98
|
exports.MessagesZodState = require_messages_annotation.MessagesZodState;
|
|
82
99
|
exports.MultipleSubgraphsError = require_errors.MultipleSubgraphsError;
|
|
@@ -87,20 +104,29 @@ exports.REMOVE_ALL_MESSAGES = require_messages_reducer.REMOVE_ALL_MESSAGES;
|
|
|
87
104
|
exports.ReducedValue = require_reduced.ReducedValue;
|
|
88
105
|
exports.RemoteException = require_errors.RemoteException;
|
|
89
106
|
exports.START = require_constants.START;
|
|
107
|
+
exports.STREAM_EVENTS_V3_MODES = require_convert.STREAM_EVENTS_V3_MODES;
|
|
90
108
|
exports.Send = require_constants.Send;
|
|
91
109
|
exports.StateGraph = require_state.StateGraph;
|
|
92
110
|
exports.StateGraphInputError = require_errors.StateGraphInputError;
|
|
93
111
|
exports.StateSchema = require_schema.StateSchema;
|
|
112
|
+
exports.StreamChannel = require_stream_channel.StreamChannel;
|
|
113
|
+
exports.SubgraphRunStream = require_run_stream.SubgraphRunStream;
|
|
94
114
|
exports.UnreachableNodeError = require_errors.UnreachableNodeError;
|
|
95
115
|
exports.UntrackedValue = require_untracked.UntrackedValue;
|
|
96
116
|
exports.UntrackedValueChannel = require_untracked_value.UntrackedValueChannel;
|
|
97
117
|
exports.addMessages = require_messages_reducer.messagesStateReducer;
|
|
118
|
+
exports.convertToProtocolEvent = require_convert.convertToProtocolEvent;
|
|
98
119
|
Object.defineProperty(exports, "copyCheckpoint", {
|
|
99
120
|
enumerable: true,
|
|
100
121
|
get: function() {
|
|
101
122
|
return _langchain_langgraph_checkpoint.copyCheckpoint;
|
|
102
123
|
}
|
|
103
124
|
});
|
|
125
|
+
exports.createGraphRunStream = require_run_stream.createGraphRunStream;
|
|
126
|
+
exports.createLifecycleTransformer = require_lifecycle.createLifecycleTransformer;
|
|
127
|
+
exports.createMessagesTransformer = require_messages.createMessagesTransformer;
|
|
128
|
+
exports.createSubgraphDiscoveryTransformer = require_subgraphs.createSubgraphDiscoveryTransformer;
|
|
129
|
+
exports.createValuesTransformer = require_values.createValuesTransformer;
|
|
104
130
|
Object.defineProperty(exports, "emptyCheckpoint", {
|
|
105
131
|
enumerable: true,
|
|
106
132
|
get: function() {
|
|
@@ -108,6 +134,8 @@ Object.defineProperty(exports, "emptyCheckpoint", {
|
|
|
108
134
|
}
|
|
109
135
|
});
|
|
110
136
|
exports.entrypoint = require_index.entrypoint;
|
|
137
|
+
exports.filterLifecycleEntries = require_lifecycle.filterLifecycleEntries;
|
|
138
|
+
exports.filterSubgraphHandles = require_subgraphs.filterSubgraphHandles;
|
|
111
139
|
exports.getConfig = require_config.getConfig;
|
|
112
140
|
exports.getCurrentTaskInput = require_config.getCurrentTaskInput;
|
|
113
141
|
exports.getJsonSchemaFromSchema = require_adapter.getJsonSchemaFromSchema;
|
|
@@ -121,9 +149,10 @@ exports.isCommand = require_constants.isCommand;
|
|
|
121
149
|
exports.isGraphBubbleUp = require_errors.isGraphBubbleUp;
|
|
122
150
|
exports.isGraphInterrupt = require_errors.isGraphInterrupt;
|
|
123
151
|
exports.isInterrupted = require_constants.isInterrupted;
|
|
152
|
+
exports.isNativeTransformer = require_types.isNativeTransformer;
|
|
124
153
|
exports.isParentCommand = require_errors.isParentCommand;
|
|
125
|
-
exports.isSerializableSchema = require_types.isSerializableSchema;
|
|
126
|
-
exports.isStandardSchema = require_types.isStandardSchema;
|
|
154
|
+
exports.isSerializableSchema = require_types$1.isSerializableSchema;
|
|
155
|
+
exports.isStandardSchema = require_types$1.isStandardSchema;
|
|
127
156
|
exports.messagesStateReducer = require_messages_reducer.messagesStateReducer;
|
|
128
157
|
exports.pushMessage = require_message.pushMessage;
|
|
129
158
|
exports.task = require_index.task;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["initializeAsyncLocalStorageSingleton"],"sources":["../src/index.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\nimport { initializeAsyncLocalStorageSingleton } from \"./setup/async_local_storage.js\";\n\n// Initialize global async local storage instance for tracing\ninitializeAsyncLocalStorageSingleton();\n\nexport * from \"./web.js\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["initializeAsyncLocalStorageSingleton"],"sources":["../src/index.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\nimport { initializeAsyncLocalStorageSingleton } from \"./setup/async_local_storage.js\";\n\n// Initialize global async local storage instance for tracing\ninitializeAsyncLocalStorageSingleton();\n\nexport * from \"./web.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKAA,4BAAAA,sCAAsC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -12,9 +12,19 @@ import { ExecutionInfo, LangGraphRunnableConfig, Runtime, ServerInfo } from "./p
|
|
|
12
12
|
import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.cjs";
|
|
13
13
|
import { CachePolicy, RetryPolicy } from "./pregel/utils/index.cjs";
|
|
14
14
|
import { PregelNode } from "./pregel/read.cjs";
|
|
15
|
+
import { AgentStatus, ChatModelStream, InferExtensions, InterruptPayload, LifecycleCause, LifecycleData, MessagesEventData, Namespace, NativeStreamTransformer, ProtocolEvent, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, ToolsEventData, UpdatesEventData, UsageInfo, isNativeTransformer } from "./stream/types.cjs";
|
|
15
16
|
import { GetStateOptions, MultipleChannelSubscriptionOptions, PregelOptions, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./pregel/types.cjs";
|
|
17
|
+
import { StreamChannel } from "./stream/stream-channel.cjs";
|
|
18
|
+
import { ConvertToProtocolEventOptions, STREAM_EVENTS_V3_MODES, convertToProtocolEvent } from "./stream/convert.cjs";
|
|
19
|
+
import { LifecycleEntry, LifecycleTransformerOptions } from "./stream/transformers/types.cjs";
|
|
20
|
+
import { LifecycleProjection, createLifecycleTransformer, filterLifecycleEntries } from "./stream/transformers/lifecycle.cjs";
|
|
21
|
+
import { createMessagesTransformer } from "./stream/transformers/messages.cjs";
|
|
22
|
+
import { SubgraphDiscoveryProjection, SubgraphDiscoveryTransformerOptions, createSubgraphDiscoveryTransformer, filterSubgraphHandles } from "./stream/transformers/subgraphs.cjs";
|
|
23
|
+
import { createValuesTransformer } from "./stream/transformers/values.cjs";
|
|
24
|
+
import { CreateGraphRunStreamOptions, GraphRunStream, SubgraphRunStream, createGraphRunStream } from "./stream/run-stream.cjs";
|
|
25
|
+
import { ChatModelStreamImpl } from "./stream/index.cjs";
|
|
16
26
|
import { Pregel } from "./pregel/index.cjs";
|
|
17
|
-
import { AddNodeOptions, CompiledGraph, Graph, NodeSpec } from "./graph/graph.cjs";
|
|
27
|
+
import { AddNodeOptions, CompiledGraph, CompiledGraphType, Graph, NodeSpec } from "./graph/graph.cjs";
|
|
18
28
|
import { InferInterruptInputType, InferInterruptResumeType, interrupt } from "./interrupt.cjs";
|
|
19
29
|
import { InferWriterType, writer } from "./writer.cjs";
|
|
20
30
|
import { isSerializableSchema, isStandardSchema } from "./state/types.cjs";
|
|
@@ -32,4 +42,4 @@ import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter
|
|
|
32
42
|
import { MessagesValue } from "./state/prebuilt/messages.cjs";
|
|
33
43
|
import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.cjs";
|
|
34
44
|
import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "./web.cjs";
|
|
35
|
-
export { AddNodeOptions, Annotation, AnnotationRoot, AnyStateSchema, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, CachePolicy, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandInstance, CommandParams, CompiledGraph, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, ExecutionInfo, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferInterruptInputType, InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, InferWriterType, Interrupt, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, NamespaceMatchType, NodeInterrupt, NodeSpec, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, SearchOperation, Send, ServerInfo, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphInit, StateGraphInputError, StateGraphNodeSpec, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, StateSnapshot, StateType, StreamMode, StreamOutputMap, TaskOptions, ToStateDefinition, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
|
45
|
+
export { AddNodeOptions, AgentStatus, Annotation, AnnotationRoot, AnyStateSchema, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, CachePolicy, ChatModelStream, ChatModelStreamImpl, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandInstance, CommandParams, CompiledGraph, CompiledGraphType, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ConvertToProtocolEventOptions, CreateGraphRunStreamOptions, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, StreamChannel as EventLog, ExecutionInfo, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InferExtensions, InferInterruptInputType, InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, InferWriterType, Interrupt, InterruptPayload, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, LifecycleCause, LifecycleData, LifecycleEntry, LifecycleProjection, LifecycleTransformerOptions, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, Namespace, NamespaceMatchType, NativeStreamTransformer, NodeInterrupt, NodeSpec, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, ProtocolEvent, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, STREAM_EVENTS_V3_MODES, SearchOperation, Send, ServerInfo, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphInit, StateGraphInputError, StateGraphNodeSpec, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, StateSnapshot, StateType, StreamChannel, StreamEmitter, StreamMode, StreamOutputMap, StreamTransformer, SubgraphDiscoveryProjection, SubgraphDiscoveryTransformerOptions, SubgraphRunStream, TaskOptions, ToStateDefinition, ToolCallStatus, ToolCallStream, ToolsEventData, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, UpdatesEventData, UsageInfo, WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,9 +12,19 @@ import { ExecutionInfo, LangGraphRunnableConfig, Runtime, ServerInfo } from "./p
|
|
|
12
12
|
import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.js";
|
|
13
13
|
import { CachePolicy, RetryPolicy } from "./pregel/utils/index.js";
|
|
14
14
|
import { PregelNode } from "./pregel/read.js";
|
|
15
|
+
import { AgentStatus, ChatModelStream, InferExtensions, InterruptPayload, LifecycleCause, LifecycleData, MessagesEventData, Namespace, NativeStreamTransformer, ProtocolEvent, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, ToolsEventData, UpdatesEventData, UsageInfo, isNativeTransformer } from "./stream/types.js";
|
|
15
16
|
import { GetStateOptions, MultipleChannelSubscriptionOptions, PregelOptions, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./pregel/types.js";
|
|
17
|
+
import { StreamChannel } from "./stream/stream-channel.js";
|
|
18
|
+
import { ConvertToProtocolEventOptions, STREAM_EVENTS_V3_MODES, convertToProtocolEvent } from "./stream/convert.js";
|
|
19
|
+
import { LifecycleEntry, LifecycleTransformerOptions } from "./stream/transformers/types.js";
|
|
20
|
+
import { LifecycleProjection, createLifecycleTransformer, filterLifecycleEntries } from "./stream/transformers/lifecycle.js";
|
|
21
|
+
import { createMessagesTransformer } from "./stream/transformers/messages.js";
|
|
22
|
+
import { SubgraphDiscoveryProjection, SubgraphDiscoveryTransformerOptions, createSubgraphDiscoveryTransformer, filterSubgraphHandles } from "./stream/transformers/subgraphs.js";
|
|
23
|
+
import { createValuesTransformer } from "./stream/transformers/values.js";
|
|
24
|
+
import { CreateGraphRunStreamOptions, GraphRunStream, SubgraphRunStream, createGraphRunStream } from "./stream/run-stream.js";
|
|
25
|
+
import { ChatModelStreamImpl } from "./stream/index.js";
|
|
16
26
|
import { Pregel } from "./pregel/index.js";
|
|
17
|
-
import { AddNodeOptions, CompiledGraph, Graph, NodeSpec } from "./graph/graph.js";
|
|
27
|
+
import { AddNodeOptions, CompiledGraph, CompiledGraphType, Graph, NodeSpec } from "./graph/graph.js";
|
|
18
28
|
import { InferInterruptInputType, InferInterruptResumeType, interrupt } from "./interrupt.js";
|
|
19
29
|
import { InferWriterType, writer } from "./writer.js";
|
|
20
30
|
import { isSerializableSchema, isStandardSchema } from "./state/types.js";
|
|
@@ -32,4 +42,4 @@ import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter
|
|
|
32
42
|
import { MessagesValue } from "./state/prebuilt/messages.js";
|
|
33
43
|
import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
|
|
34
44
|
import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "./web.js";
|
|
35
|
-
export { AddNodeOptions, Annotation, AnnotationRoot, AnyStateSchema, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, CachePolicy, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandInstance, CommandParams, CompiledGraph, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, ExecutionInfo, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferInterruptInputType, InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, InferWriterType, Interrupt, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, NamespaceMatchType, NodeInterrupt, NodeSpec, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, SearchOperation, Send, ServerInfo, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphInit, StateGraphInputError, StateGraphNodeSpec, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, StateSnapshot, StateType, StreamMode, StreamOutputMap, TaskOptions, ToStateDefinition, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
|
45
|
+
export { AddNodeOptions, AgentStatus, Annotation, AnnotationRoot, AnyStateSchema, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, CachePolicy, ChatModelStream, ChatModelStreamImpl, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandInstance, CommandParams, CompiledGraph, CompiledGraphType, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ConvertToProtocolEventOptions, CreateGraphRunStreamOptions, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, StreamChannel as EventLog, ExecutionInfo, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InferExtensions, InferInterruptInputType, InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, InferWriterType, Interrupt, InterruptPayload, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, LifecycleCause, LifecycleData, LifecycleEntry, LifecycleProjection, LifecycleTransformerOptions, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, Namespace, NamespaceMatchType, NativeStreamTransformer, NodeInterrupt, NodeSpec, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, ProtocolEvent, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, STREAM_EVENTS_V3_MODES, SearchOperation, Send, ServerInfo, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphInit, StateGraphInputError, StateGraphNodeSpec, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, StateSnapshot, StateType, StreamChannel, StreamEmitter, StreamMode, StreamOutputMap, StreamTransformer, SubgraphDiscoveryProjection, SubgraphDiscoveryTransformerOptions, SubgraphRunStream, TaskOptions, ToStateDefinition, ToolCallStatus, ToolCallStream, ToolsEventData, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, UpdatesEventData, UsageInfo, WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,15 @@ import { BaseChannel } from "./channels/base.js";
|
|
|
5
5
|
import { BinaryOperatorAggregate } from "./channels/binop.js";
|
|
6
6
|
import { Annotation } from "./graph/annotation.js";
|
|
7
7
|
import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
|
|
8
|
+
import { StreamChannel } from "./stream/stream-channel.js";
|
|
9
|
+
import { STREAM_EVENTS_V3_MODES, convertToProtocolEvent } from "./stream/convert.js";
|
|
10
|
+
import { createLifecycleTransformer, filterLifecycleEntries } from "./stream/transformers/lifecycle.js";
|
|
11
|
+
import { createMessagesTransformer } from "./stream/transformers/messages.js";
|
|
12
|
+
import { createSubgraphDiscoveryTransformer, filterSubgraphHandles } from "./stream/transformers/subgraphs.js";
|
|
13
|
+
import { createValuesTransformer } from "./stream/transformers/values.js";
|
|
14
|
+
import { isNativeTransformer } from "./stream/types.js";
|
|
15
|
+
import { GraphRunStream, SubgraphRunStream, createGraphRunStream } from "./stream/run-stream.js";
|
|
16
|
+
import { ChatModelStreamImpl } from "./stream/index.js";
|
|
8
17
|
import { interrupt } from "./interrupt.js";
|
|
9
18
|
import { Graph } from "./graph/graph.js";
|
|
10
19
|
import { isSerializableSchema, isStandardSchema } from "./state/types.js";
|
|
@@ -24,6 +33,6 @@ import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, InMemoryStore, Memor
|
|
|
24
33
|
//#region src/index.ts
|
|
25
34
|
initializeAsyncLocalStorageSingleton();
|
|
26
35
|
//#endregion
|
|
27
|
-
export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, COMMAND_SYMBOL, Command, CommandInstance, CompiledStateGraph, END, EmptyChannelError, EmptyInputError, Graph, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeInterrupt, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, START, Send, StateGraph, StateGraphInputError, StateSchema, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
|
36
|
+
export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, COMMAND_SYMBOL, ChatModelStreamImpl, Command, CommandInstance, CompiledStateGraph, END, EmptyChannelError, EmptyInputError, StreamChannel as EventLog, Graph, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeInterrupt, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, START, STREAM_EVENTS_V3_MODES, Send, StateGraph, StateGraphInputError, StateSchema, StreamChannel, SubgraphRunStream, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
|
28
37
|
|
|
29
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\nimport { initializeAsyncLocalStorageSingleton } from \"./setup/async_local_storage.js\";\n\n// Initialize global async local storage instance for tracing\ninitializeAsyncLocalStorageSingleton();\n\nexport * from \"./web.js\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\nimport { initializeAsyncLocalStorageSingleton } from \"./setup/async_local_storage.js\";\n\n// Initialize global async local storage instance for tracing\ninitializeAsyncLocalStorageSingleton();\n\nexport * from \"./web.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,sCAAsC"}
|
package/dist/pregel/index.cjs
CHANGED
|
@@ -14,7 +14,11 @@ const require_debug = require("./debug.cjs");
|
|
|
14
14
|
const require_stream = require("./stream.cjs");
|
|
15
15
|
const require_loop = require("./loop.cjs");
|
|
16
16
|
const require_messages = require("./messages.cjs");
|
|
17
|
+
const require_messages_v2 = require("./messages-v2.cjs");
|
|
17
18
|
const require_runner = require("./runner.cjs");
|
|
19
|
+
const require_convert = require("../stream/convert.cjs");
|
|
20
|
+
const require_run_stream = require("../stream/run-stream.cjs");
|
|
21
|
+
require("../stream/index.cjs");
|
|
18
22
|
const require_validate = require("./validate.cjs");
|
|
19
23
|
const require_topic = require("../channels/topic.cjs");
|
|
20
24
|
const require_interrupt = require("../interrupt.cjs");
|
|
@@ -22,6 +26,22 @@ let _langchain_langgraph_checkpoint = require("@langchain/langgraph-checkpoint")
|
|
|
22
26
|
let _langchain_core_runnables = require("@langchain/core/runnables");
|
|
23
27
|
let _langchain_core_callbacks_manager = require("@langchain/core/callbacks/manager");
|
|
24
28
|
//#region src/pregel/index.ts
|
|
29
|
+
function protocolEventsToEventStream(run) {
|
|
30
|
+
const encoder = new TextEncoder();
|
|
31
|
+
return new ReadableStream({ async start(controller) {
|
|
32
|
+
try {
|
|
33
|
+
for await (const event of run) {
|
|
34
|
+
const namespace = event.params.namespace;
|
|
35
|
+
const eventName = namespace.length ? `${event.method}|${namespace.join("|")}` : event.method;
|
|
36
|
+
controller.enqueue(encoder.encode(`event: ${eventName}\ndata: ${JSON.stringify(event.params.data ?? {})}\n\n`));
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
controller.enqueue(encoder.encode(`event: error\ndata: ${JSON.stringify({ message: String(error) })}\n\n`));
|
|
40
|
+
} finally {
|
|
41
|
+
controller.close();
|
|
42
|
+
}
|
|
43
|
+
} });
|
|
44
|
+
}
|
|
25
45
|
/**
|
|
26
46
|
* Utility class for working with channels in the Pregel system.
|
|
27
47
|
* Provides static methods for subscribing to channels and writing to them.
|
|
@@ -246,6 +266,12 @@ var Pregel = class extends PartialRunnable {
|
|
|
246
266
|
*/
|
|
247
267
|
userInterrupt;
|
|
248
268
|
/**
|
|
269
|
+
* Stream reducer factories registered at compile time. These run
|
|
270
|
+
* automatically for every `streamEvents(..., { version: "v3" })` call,
|
|
271
|
+
* before any call-site transformers.
|
|
272
|
+
*/
|
|
273
|
+
streamTransformers;
|
|
274
|
+
/**
|
|
249
275
|
* The trigger to node mapping for the graph run.
|
|
250
276
|
* @internal
|
|
251
277
|
*/
|
|
@@ -280,32 +306,17 @@ var Pregel = class extends PartialRunnable {
|
|
|
280
306
|
this.name = fields.name;
|
|
281
307
|
this.triggerToNodes = fields.triggerToNodes ?? this.triggerToNodes;
|
|
282
308
|
this.userInterrupt = fields.userInterrupt;
|
|
309
|
+
this.streamTransformers = fields.streamTransformers ?? [];
|
|
283
310
|
if (this.autoValidate) this.validate();
|
|
284
311
|
}
|
|
285
|
-
/**
|
|
286
|
-
* Creates a new instance of the Pregel graph with updated configuration.
|
|
287
|
-
* This method follows the immutable pattern - instead of modifying the current instance,
|
|
288
|
-
* it returns a new instance with the merged configuration.
|
|
289
|
-
*
|
|
290
|
-
* @example
|
|
291
|
-
* ```typescript
|
|
292
|
-
* // Create a new instance with debug enabled
|
|
293
|
-
* const debugGraph = graph.withConfig({ debug: true });
|
|
294
|
-
*
|
|
295
|
-
* // Create a new instance with a specific thread ID
|
|
296
|
-
* const threadGraph = graph.withConfig({
|
|
297
|
-
* configurable: { thread_id: "123" }
|
|
298
|
-
* });
|
|
299
|
-
* ```
|
|
300
|
-
*
|
|
301
|
-
* @param config - The configuration to merge with the current configuration
|
|
302
|
-
* @returns A new Pregel instance with the merged configuration
|
|
303
|
-
*/
|
|
304
312
|
withConfig(config) {
|
|
305
|
-
const
|
|
313
|
+
const { streamTransformers, ...restConfig } = config;
|
|
314
|
+
const mergedConfig = (0, _langchain_core_runnables.mergeConfigs)(this.config, restConfig);
|
|
315
|
+
const mergedStreamTransformers = [...this.streamTransformers, ...streamTransformers ?? []];
|
|
306
316
|
return new this.constructor({
|
|
307
317
|
...this,
|
|
308
|
-
config: mergedConfig
|
|
318
|
+
config: mergedConfig,
|
|
319
|
+
streamTransformers: mergedStreamTransformers
|
|
309
320
|
});
|
|
310
321
|
}
|
|
311
322
|
/**
|
|
@@ -914,7 +925,34 @@ var Pregel = class extends PartialRunnable {
|
|
|
914
925
|
const stream = await super.stream(input, config);
|
|
915
926
|
return new require_stream.IterableReadableStreamWithAbortSignal(options?.encoding === "text/event-stream" ? require_stream.toEventStream(stream) : stream, abortController);
|
|
916
927
|
}
|
|
928
|
+
async #streamEventsV3(input, options) {
|
|
929
|
+
const { version, encoding, transformers: userTransformers, ...restOptions } = options;
|
|
930
|
+
const streamOptions = {
|
|
931
|
+
recursionLimit: this.config?.recursionLimit,
|
|
932
|
+
...restOptions,
|
|
933
|
+
configurable: {
|
|
934
|
+
...this.config?.configurable,
|
|
935
|
+
...restOptions?.configurable
|
|
936
|
+
},
|
|
937
|
+
version,
|
|
938
|
+
streamMode: require_convert.STREAM_EVENTS_V3_MODES,
|
|
939
|
+
subgraphs: true,
|
|
940
|
+
encoding: void 0
|
|
941
|
+
};
|
|
942
|
+
const sourcePromise = this.stream(input, streamOptions);
|
|
943
|
+
const graphRun = require_run_stream.createGraphRunStream({ [Symbol.asyncIterator]: async function* () {
|
|
944
|
+
const src = await sourcePromise;
|
|
945
|
+
for await (const chunk of src) yield chunk;
|
|
946
|
+
} }, [...this.streamTransformers ?? [], ...userTransformers ?? []]);
|
|
947
|
+
if (encoding === "text/event-stream") {
|
|
948
|
+
const abortController = new AbortController();
|
|
949
|
+
abortController.signal.addEventListener("abort", () => graphRun.abort(abortController.signal.reason), { once: true });
|
|
950
|
+
return new require_stream.IterableReadableStreamWithAbortSignal(protocolEventsToEventStream(graphRun), abortController);
|
|
951
|
+
}
|
|
952
|
+
return graphRun;
|
|
953
|
+
}
|
|
917
954
|
streamEvents(input, options, streamOptions) {
|
|
955
|
+
if (options.version === "v3") return this.#streamEventsV3(input, options);
|
|
918
956
|
const abortController = new AbortController();
|
|
919
957
|
const config = {
|
|
920
958
|
recursionLimit: this.config?.recursionLimit,
|
|
@@ -973,7 +1011,7 @@ var Pregel = class extends PartialRunnable {
|
|
|
973
1011
|
config.configurable[require_constants.CONFIG_KEY_CHECKPOINT_NS] = ns.split("|").map((part) => part.split(":")[0]).join("|");
|
|
974
1012
|
}
|
|
975
1013
|
if (streamMode.includes("messages")) {
|
|
976
|
-
const messageStreamer = new require_messages.StreamMessagesHandler((chunk) => stream.push(chunk));
|
|
1014
|
+
const messageStreamer = options?.version === "v3" ? new require_messages_v2.StreamProtocolMessagesHandler((chunk) => stream.push(chunk)) : new require_messages.StreamMessagesHandler((chunk) => stream.push(chunk));
|
|
977
1015
|
const { callbacks } = config;
|
|
978
1016
|
if (callbacks === void 0) config.callbacks = [messageStreamer];
|
|
979
1017
|
else if (Array.isArray(callbacks)) config.callbacks = callbacks.concat(messageStreamer);
|
|
@@ -1005,7 +1043,8 @@ var Pregel = class extends PartialRunnable {
|
|
|
1005
1043
|
};
|
|
1006
1044
|
config.interrupt ??= this.userInterrupt ?? require_interrupt.interrupt;
|
|
1007
1045
|
if (config.serverInfo == null) config.serverInfo = _buildServerInfo(config);
|
|
1008
|
-
const
|
|
1046
|
+
const callbackManagerOptions = { tracerInheritableMetadata: _getTracingMetadataDefaults(config) };
|
|
1047
|
+
const runManager = await (await _langchain_core_callbacks_manager.CallbackManager._configureSync(config?.callbacks, void 0, config?.tags, void 0, config?.metadata, void 0, callbackManagerOptions))?.handleChainStart(this.toJSON(), require_index._coerceToDict(input, "input"), runId, void 0, void 0, void 0, config?.runName ?? this.getName());
|
|
1009
1048
|
const channelSpecs = require_base.getOnlyChannels(this.channels);
|
|
1010
1049
|
let loop;
|
|
1011
1050
|
let loopError;
|
|
@@ -1072,7 +1111,7 @@ var Pregel = class extends PartialRunnable {
|
|
|
1072
1111
|
try {
|
|
1073
1112
|
for await (const chunk of stream) {
|
|
1074
1113
|
if (chunk === void 0) throw new Error("Data structure error.");
|
|
1075
|
-
const [namespace, mode, payload] = chunk;
|
|
1114
|
+
const [namespace, mode, payload, meta] = chunk;
|
|
1076
1115
|
if (streamMode.includes(mode)) {
|
|
1077
1116
|
if (streamEncoding === "text/event-stream") {
|
|
1078
1117
|
if (streamSubgraphs) yield [
|
|
@@ -1087,7 +1126,12 @@ var Pregel = class extends PartialRunnable {
|
|
|
1087
1126
|
];
|
|
1088
1127
|
continue;
|
|
1089
1128
|
}
|
|
1090
|
-
if (streamSubgraphs && !streamModeSingle) yield [
|
|
1129
|
+
if (streamSubgraphs && !streamModeSingle) yield meta !== void 0 ? [
|
|
1130
|
+
namespace,
|
|
1131
|
+
mode,
|
|
1132
|
+
payload,
|
|
1133
|
+
meta
|
|
1134
|
+
] : [
|
|
1091
1135
|
namespace,
|
|
1092
1136
|
mode,
|
|
1093
1137
|
payload
|