@langchain/langgraph 0.2.61 → 0.2.63

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.
Files changed (78) hide show
  1. package/README.md +14 -0
  2. package/dist/constants.cjs +2 -1
  3. package/dist/constants.d.ts +1 -0
  4. package/dist/constants.js +1 -0
  5. package/dist/constants.js.map +1 -1
  6. package/dist/prebuilt/react_agent_executor.cjs +34 -13
  7. package/dist/prebuilt/react_agent_executor.d.ts +3 -0
  8. package/dist/prebuilt/react_agent_executor.js +34 -15
  9. package/dist/prebuilt/react_agent_executor.js.map +1 -1
  10. package/dist/prebuilt/tool_node.cjs +26 -4
  11. package/dist/prebuilt/tool_node.js +27 -5
  12. package/dist/prebuilt/tool_node.js.map +1 -1
  13. package/dist/pregel/debug.cjs +9 -7
  14. package/dist/pregel/debug.d.ts +10 -0
  15. package/dist/pregel/debug.js +2 -2
  16. package/dist/pregel/debug.js.map +1 -1
  17. package/dist/pregel/debug.test.cjs +189 -0
  18. package/dist/pregel/debug.test.d.ts +1 -0
  19. package/dist/pregel/debug.test.js +187 -0
  20. package/dist/pregel/debug.test.js.map +1 -0
  21. package/dist/pregel/index.cjs +12 -4
  22. package/dist/pregel/index.d.ts +3 -0
  23. package/dist/pregel/index.js +14 -6
  24. package/dist/pregel/index.js.map +1 -1
  25. package/dist/pregel/io.mapCommand.test.cjs +151 -0
  26. package/dist/pregel/io.mapCommand.test.d.ts +1 -0
  27. package/dist/pregel/io.mapCommand.test.js +149 -0
  28. package/dist/pregel/io.mapCommand.test.js.map +1 -0
  29. package/dist/pregel/messages.test.cjs +351 -0
  30. package/dist/pregel/messages.test.d.ts +1 -0
  31. package/dist/pregel/messages.test.js +349 -0
  32. package/dist/pregel/messages.test.js.map +1 -0
  33. package/dist/pregel/read.cjs +1 -1
  34. package/dist/pregel/read.js +1 -1
  35. package/dist/pregel/read.js.map +1 -1
  36. package/dist/pregel/read.test.cjs +194 -0
  37. package/dist/pregel/read.test.d.ts +1 -0
  38. package/dist/pregel/read.test.js +192 -0
  39. package/dist/pregel/read.test.js.map +1 -0
  40. package/dist/pregel/retry.cjs +5 -0
  41. package/dist/pregel/retry.d.ts +2 -0
  42. package/dist/pregel/retry.js +5 -0
  43. package/dist/pregel/retry.js.map +1 -1
  44. package/dist/pregel/runner.cjs +95 -27
  45. package/dist/pregel/runner.d.ts +14 -0
  46. package/dist/pregel/runner.js +97 -29
  47. package/dist/pregel/runner.js.map +1 -1
  48. package/dist/pregel/runner.test.cjs +66 -0
  49. package/dist/pregel/runner.test.d.ts +1 -0
  50. package/dist/pregel/runner.test.js +64 -0
  51. package/dist/pregel/runner.test.js.map +1 -0
  52. package/dist/pregel/stream.cjs +62 -1
  53. package/dist/pregel/stream.d.ts +23 -0
  54. package/dist/pregel/stream.js +60 -0
  55. package/dist/pregel/stream.js.map +1 -1
  56. package/dist/pregel/types.d.ts +19 -0
  57. package/dist/pregel/types.js.map +1 -1
  58. package/dist/pregel/utils/config.test.cjs +214 -0
  59. package/dist/pregel/utils/config.test.d.ts +1 -0
  60. package/dist/pregel/utils/config.test.js +212 -0
  61. package/dist/pregel/utils/config.test.js.map +1 -0
  62. package/dist/pregel/utils/index.cjs +26 -1
  63. package/dist/pregel/utils/index.d.ts +6 -0
  64. package/dist/pregel/utils/index.js +24 -0
  65. package/dist/pregel/utils/index.js.map +1 -1
  66. package/dist/pregel/utils/subgraph.test.cjs +83 -0
  67. package/dist/pregel/utils/subgraph.test.d.ts +1 -0
  68. package/dist/pregel/utils/subgraph.test.js +81 -0
  69. package/dist/pregel/utils/subgraph.test.js.map +1 -0
  70. package/dist/pregel/validate.test.cjs +220 -0
  71. package/dist/pregel/validate.test.d.ts +1 -0
  72. package/dist/pregel/validate.test.js +218 -0
  73. package/dist/pregel/validate.test.js.map +1 -0
  74. package/dist/pregel/write.test.cjs +181 -0
  75. package/dist/pregel/write.test.d.ts +1 -0
  76. package/dist/pregel/write.test.js +179 -0
  77. package/dist/pregel/write.test.js.map +1 -0
  78. package/package.json +1 -1
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const globals_1 = require("@jest/globals");
4
+ const debug_js_1 = require("./debug.cjs");
5
+ const last_value_js_1 = require("../channels/last_value.cjs");
6
+ const errors_js_1 = require("../errors.cjs");
7
+ (0, globals_1.describe)("wrap", () => {
8
+ (0, globals_1.it)("should wrap text with color codes", () => {
9
+ const color = {
10
+ start: "\x1b[34m",
11
+ end: "\x1b[0m",
12
+ };
13
+ const text = "test text";
14
+ const result = (0, debug_js_1.wrap)(color, text);
15
+ (0, globals_1.expect)(result).toBe(`${color.start}${text}${color.end}`);
16
+ });
17
+ });
18
+ (0, globals_1.describe)("_readChannels", () => {
19
+ (0, globals_1.it)("should read values from channels", () => {
20
+ const channels = {
21
+ channel1: new last_value_js_1.LastValue(),
22
+ channel2: new last_value_js_1.LastValue(),
23
+ };
24
+ // Update channels with values
25
+ channels.channel1.update(["value1"]);
26
+ channels.channel2.update(["42"]);
27
+ const results = Array.from((0, debug_js_1._readChannels)(channels));
28
+ (0, globals_1.expect)(results).toEqual([
29
+ ["channel1", "value1"],
30
+ ["channel2", "42"],
31
+ ]);
32
+ });
33
+ (0, globals_1.it)("should skip empty channels", () => {
34
+ const mockEmptyChannel = {
35
+ lc_graph_name: "MockChannel",
36
+ lg_is_channel: true,
37
+ ValueType: "",
38
+ UpdateType: [],
39
+ get: globals_1.jest.fn().mockImplementation(() => {
40
+ throw new errors_js_1.EmptyChannelError("Empty channel");
41
+ }),
42
+ update: globals_1.jest.fn().mockReturnValue(true),
43
+ checkpoint: globals_1.jest.fn(),
44
+ fromCheckpoint: globals_1.jest
45
+ .fn()
46
+ .mockReturnThis(),
47
+ consume: globals_1.jest.fn().mockReturnValue(false),
48
+ };
49
+ const channels = {
50
+ channel1: new last_value_js_1.LastValue(),
51
+ emptyChannel: mockEmptyChannel,
52
+ };
53
+ // Update channel with value
54
+ channels.channel1.update(["value1"]);
55
+ const results = Array.from((0, debug_js_1._readChannels)(channels));
56
+ (0, globals_1.expect)(results).toEqual([["channel1", "value1"]]);
57
+ });
58
+ (0, globals_1.it)("should propagate non-empty channel errors", () => {
59
+ const mockErrorChannel = {
60
+ lc_graph_name: "MockChannel",
61
+ lg_is_channel: true,
62
+ ValueType: "",
63
+ UpdateType: [],
64
+ get: globals_1.jest.fn().mockImplementation(() => {
65
+ throw new Error("Other error");
66
+ }),
67
+ update: globals_1.jest.fn().mockReturnValue(true),
68
+ checkpoint: globals_1.jest.fn(),
69
+ fromCheckpoint: globals_1.jest
70
+ .fn()
71
+ .mockReturnThis(),
72
+ consume: globals_1.jest.fn().mockReturnValue(false),
73
+ };
74
+ const channels = {
75
+ channel1: new last_value_js_1.LastValue(),
76
+ errorChannel: mockErrorChannel,
77
+ };
78
+ channels.channel1.update(["value1"]);
79
+ (0, globals_1.expect)(() => Array.from((0, debug_js_1._readChannels)(channels))).toThrow("Other error");
80
+ });
81
+ });
82
+ (0, globals_1.describe)("tasksWithWrites", () => {
83
+ (0, globals_1.it)("should return task descriptions with no writes", () => {
84
+ const tasks = [
85
+ {
86
+ id: "task1",
87
+ name: "Task 1",
88
+ path: ["PULL", "Task 1"],
89
+ interrupts: [],
90
+ },
91
+ {
92
+ id: "task2",
93
+ name: "Task 2",
94
+ path: ["PULL", "Task 2"],
95
+ interrupts: [],
96
+ },
97
+ ];
98
+ const pendingWrites = [];
99
+ const result = (0, debug_js_1.tasksWithWrites)(tasks, pendingWrites);
100
+ (0, globals_1.expect)(result).toEqual([
101
+ { id: "task1", name: "Task 1", path: ["PULL", "Task 1"], interrupts: [] },
102
+ { id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
103
+ ]);
104
+ });
105
+ (0, globals_1.it)("should include error information", () => {
106
+ const tasks = [
107
+ {
108
+ id: "task1",
109
+ name: "Task 1",
110
+ path: ["PULL", "Task 1"],
111
+ interrupts: [],
112
+ },
113
+ {
114
+ id: "task2",
115
+ name: "Task 2",
116
+ path: ["PULL", "Task 2"],
117
+ interrupts: [],
118
+ },
119
+ ];
120
+ const pendingWrites = [
121
+ ["task1", "__error__", { message: "Test error" }],
122
+ ];
123
+ const result = (0, debug_js_1.tasksWithWrites)(tasks, pendingWrites);
124
+ (0, globals_1.expect)(result).toEqual([
125
+ {
126
+ id: "task1",
127
+ name: "Task 1",
128
+ path: ["PULL", "Task 1"],
129
+ error: { message: "Test error" },
130
+ interrupts: [],
131
+ },
132
+ { id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
133
+ ]);
134
+ });
135
+ (0, globals_1.it)("should include state information", () => {
136
+ const tasks = [
137
+ {
138
+ id: "task1",
139
+ name: "Task 1",
140
+ path: ["PULL", "Task 1"],
141
+ interrupts: [],
142
+ },
143
+ {
144
+ id: "task2",
145
+ name: "Task 2",
146
+ path: ["PULL", "Task 2"],
147
+ interrupts: [],
148
+ },
149
+ ];
150
+ const pendingWrites = [];
151
+ const states = {
152
+ task1: { configurable: { key: "value" } },
153
+ };
154
+ const result = (0, debug_js_1.tasksWithWrites)(tasks, pendingWrites, states);
155
+ (0, globals_1.expect)(result).toEqual([
156
+ {
157
+ id: "task1",
158
+ name: "Task 1",
159
+ path: ["PULL", "Task 1"],
160
+ interrupts: [],
161
+ state: { configurable: { key: "value" } },
162
+ },
163
+ { id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
164
+ ]);
165
+ });
166
+ (0, globals_1.it)("should include interrupts", () => {
167
+ const tasks = [
168
+ {
169
+ id: "task1",
170
+ name: "Task 1",
171
+ path: ["PULL", "Task 1"],
172
+ interrupts: [],
173
+ },
174
+ ];
175
+ const pendingWrites = [
176
+ ["task1", "__interrupt__", { value: "Interrupted", when: "during" }],
177
+ ];
178
+ const result = (0, debug_js_1.tasksWithWrites)(tasks, pendingWrites);
179
+ (0, globals_1.expect)(result).toEqual([
180
+ {
181
+ id: "task1",
182
+ name: "Task 1",
183
+ path: ["PULL", "Task 1"],
184
+ interrupts: [{ value: "Interrupted", when: "during" }],
185
+ },
186
+ ]);
187
+ });
188
+ });
189
+ //# sourceMappingURL=debug.test.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,187 @@
1
+ import { describe, expect, it, jest } from "@jest/globals";
2
+ import { wrap, tasksWithWrites, _readChannels } from "./debug.js";
3
+ import { LastValue } from "../channels/last_value.js";
4
+ import { EmptyChannelError } from "../errors.js";
5
+ describe("wrap", () => {
6
+ it("should wrap text with color codes", () => {
7
+ const color = {
8
+ start: "\x1b[34m",
9
+ end: "\x1b[0m",
10
+ };
11
+ const text = "test text";
12
+ const result = wrap(color, text);
13
+ expect(result).toBe(`${color.start}${text}${color.end}`);
14
+ });
15
+ });
16
+ describe("_readChannels", () => {
17
+ it("should read values from channels", () => {
18
+ const channels = {
19
+ channel1: new LastValue(),
20
+ channel2: new LastValue(),
21
+ };
22
+ // Update channels with values
23
+ channels.channel1.update(["value1"]);
24
+ channels.channel2.update(["42"]);
25
+ const results = Array.from(_readChannels(channels));
26
+ expect(results).toEqual([
27
+ ["channel1", "value1"],
28
+ ["channel2", "42"],
29
+ ]);
30
+ });
31
+ it("should skip empty channels", () => {
32
+ const mockEmptyChannel = {
33
+ lc_graph_name: "MockChannel",
34
+ lg_is_channel: true,
35
+ ValueType: "",
36
+ UpdateType: [],
37
+ get: jest.fn().mockImplementation(() => {
38
+ throw new EmptyChannelError("Empty channel");
39
+ }),
40
+ update: jest.fn().mockReturnValue(true),
41
+ checkpoint: jest.fn(),
42
+ fromCheckpoint: jest
43
+ .fn()
44
+ .mockReturnThis(),
45
+ consume: jest.fn().mockReturnValue(false),
46
+ };
47
+ const channels = {
48
+ channel1: new LastValue(),
49
+ emptyChannel: mockEmptyChannel,
50
+ };
51
+ // Update channel with value
52
+ channels.channel1.update(["value1"]);
53
+ const results = Array.from(_readChannels(channels));
54
+ expect(results).toEqual([["channel1", "value1"]]);
55
+ });
56
+ it("should propagate non-empty channel errors", () => {
57
+ const mockErrorChannel = {
58
+ lc_graph_name: "MockChannel",
59
+ lg_is_channel: true,
60
+ ValueType: "",
61
+ UpdateType: [],
62
+ get: jest.fn().mockImplementation(() => {
63
+ throw new Error("Other error");
64
+ }),
65
+ update: jest.fn().mockReturnValue(true),
66
+ checkpoint: jest.fn(),
67
+ fromCheckpoint: jest
68
+ .fn()
69
+ .mockReturnThis(),
70
+ consume: jest.fn().mockReturnValue(false),
71
+ };
72
+ const channels = {
73
+ channel1: new LastValue(),
74
+ errorChannel: mockErrorChannel,
75
+ };
76
+ channels.channel1.update(["value1"]);
77
+ expect(() => Array.from(_readChannels(channels))).toThrow("Other error");
78
+ });
79
+ });
80
+ describe("tasksWithWrites", () => {
81
+ it("should return task descriptions with no writes", () => {
82
+ const tasks = [
83
+ {
84
+ id: "task1",
85
+ name: "Task 1",
86
+ path: ["PULL", "Task 1"],
87
+ interrupts: [],
88
+ },
89
+ {
90
+ id: "task2",
91
+ name: "Task 2",
92
+ path: ["PULL", "Task 2"],
93
+ interrupts: [],
94
+ },
95
+ ];
96
+ const pendingWrites = [];
97
+ const result = tasksWithWrites(tasks, pendingWrites);
98
+ expect(result).toEqual([
99
+ { id: "task1", name: "Task 1", path: ["PULL", "Task 1"], interrupts: [] },
100
+ { id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
101
+ ]);
102
+ });
103
+ it("should include error information", () => {
104
+ const tasks = [
105
+ {
106
+ id: "task1",
107
+ name: "Task 1",
108
+ path: ["PULL", "Task 1"],
109
+ interrupts: [],
110
+ },
111
+ {
112
+ id: "task2",
113
+ name: "Task 2",
114
+ path: ["PULL", "Task 2"],
115
+ interrupts: [],
116
+ },
117
+ ];
118
+ const pendingWrites = [
119
+ ["task1", "__error__", { message: "Test error" }],
120
+ ];
121
+ const result = tasksWithWrites(tasks, pendingWrites);
122
+ expect(result).toEqual([
123
+ {
124
+ id: "task1",
125
+ name: "Task 1",
126
+ path: ["PULL", "Task 1"],
127
+ error: { message: "Test error" },
128
+ interrupts: [],
129
+ },
130
+ { id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
131
+ ]);
132
+ });
133
+ it("should include state information", () => {
134
+ const tasks = [
135
+ {
136
+ id: "task1",
137
+ name: "Task 1",
138
+ path: ["PULL", "Task 1"],
139
+ interrupts: [],
140
+ },
141
+ {
142
+ id: "task2",
143
+ name: "Task 2",
144
+ path: ["PULL", "Task 2"],
145
+ interrupts: [],
146
+ },
147
+ ];
148
+ const pendingWrites = [];
149
+ const states = {
150
+ task1: { configurable: { key: "value" } },
151
+ };
152
+ const result = tasksWithWrites(tasks, pendingWrites, states);
153
+ expect(result).toEqual([
154
+ {
155
+ id: "task1",
156
+ name: "Task 1",
157
+ path: ["PULL", "Task 1"],
158
+ interrupts: [],
159
+ state: { configurable: { key: "value" } },
160
+ },
161
+ { id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
162
+ ]);
163
+ });
164
+ it("should include interrupts", () => {
165
+ const tasks = [
166
+ {
167
+ id: "task1",
168
+ name: "Task 1",
169
+ path: ["PULL", "Task 1"],
170
+ interrupts: [],
171
+ },
172
+ ];
173
+ const pendingWrites = [
174
+ ["task1", "__interrupt__", { value: "Interrupted", when: "during" }],
175
+ ];
176
+ const result = tasksWithWrites(tasks, pendingWrites);
177
+ expect(result).toEqual([
178
+ {
179
+ id: "task1",
180
+ name: "Task 1",
181
+ path: ["PULL", "Task 1"],
182
+ interrupts: [{ value: "Interrupted", when: "during" }],
183
+ },
184
+ ]);
185
+ });
186
+ });
187
+ //# sourceMappingURL=debug.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.test.js","sourceRoot":"","sources":["../../src/pregel/debug.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAElE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,OAAO,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;SACrE,CAAC;QAEF,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QAErD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB;gBACE,EAAE,EAAE,OAAO;gBACX,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;gBACxB,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;aACvD;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1176,21 +1176,29 @@ class Pregel extends runnables_1.Runnable {
1176
1176
  // There is currently no way in _streamIterator to determine whether this was
1177
1177
  // set by by ensureConfig or manually by the user, so we specify the bound value here
1178
1178
  // and override if it is passed as an explicit param in `options`.
1179
+ const abortController = new AbortController();
1179
1180
  const config = {
1180
1181
  recursionLimit: this.config?.recursionLimit,
1181
1182
  ...options,
1183
+ signal: options?.signal
1184
+ ? (0, index_js_1.combineAbortSignals)(options.signal, abortController.signal)
1185
+ : abortController.signal,
1182
1186
  };
1183
- return super.stream(input, config);
1187
+ return new stream_js_1.IterableReadableStreamWithAbortSignal(await super.stream(input, config), abortController);
1184
1188
  }
1185
1189
  streamEvents(input, options, streamOptions) {
1186
- // Similar to `stream`, we need to pass the `config.callbacks` here,
1187
- // otherwise the user-provided callback will get lost in `ensureLangGraphConfig`.
1190
+ const abortController = new AbortController();
1188
1191
  const config = {
1189
1192
  recursionLimit: this.config?.recursionLimit,
1193
+ // Similar to `stream`, we need to pass the `config.callbacks` here,
1194
+ // otherwise the user-provided callback will get lost in `ensureLangGraphConfig`.
1190
1195
  callbacks: this.config?.callbacks,
1191
1196
  ...options,
1197
+ signal: options?.signal
1198
+ ? (0, index_js_1.combineAbortSignals)(options.signal, abortController.signal)
1199
+ : abortController.signal,
1192
1200
  };
1193
- return super.streamEvents(input, config, streamOptions);
1201
+ return new stream_js_1.IterableReadableStreamWithAbortSignal(super.streamEvents(input, config, streamOptions), abortController);
1194
1202
  }
1195
1203
  /**
1196
1204
  * Prepares channel specifications and managed values for graph execution.
@@ -437,6 +437,9 @@ export declare class Pregel<Nodes extends StrRecord<string, PregelNode>, Channel
437
437
  * @returns An async iterable stream of graph state updates
438
438
  */
439
439
  stream(input: InputType | Command | null, options?: Partial<PregelOptions<Nodes, Channels, ConfigurableFieldType>>): Promise<IterableReadableStream<PregelOutputType>>;
440
+ /**
441
+ * @inheritdoc
442
+ */
440
443
  streamEvents(input: InputType | Command | null, options: Partial<PregelOptions<Nodes, Channels, ConfigurableFieldType>> & {
441
444
  version: "v1" | "v2";
442
445
  }, streamOptions?: StreamEventsOptions): IterableReadableStream<StreamEvent>;
@@ -10,7 +10,7 @@ import { ChannelWrite, PASSTHROUGH } from "./write.js";
10
10
  import { CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_READ, CONFIG_KEY_SEND, CONFIG_KEY_TASK_ID, ERROR, INPUT, INTERRUPT, PUSH, CHECKPOINT_NAMESPACE_SEPARATOR, CHECKPOINT_NAMESPACE_END, CONFIG_KEY_STREAM, NULL_TASK_ID, COPY, END, CONFIG_KEY_NODE_FINISHED, } from "../constants.js";
11
11
  import { GraphRecursionError, GraphValueError, InvalidUpdateError, } from "../errors.js";
12
12
  import { _prepareNextTasks, _localRead, _applyWrites, } from "./algo.js";
13
- import { _coerceToDict, getNewChannelVersions, patchCheckpointMap, } from "./utils/index.js";
13
+ import { _coerceToDict, combineAbortSignals, getNewChannelVersions, patchCheckpointMap, } from "./utils/index.js";
14
14
  import { findSubgraphPregel } from "./utils/subgraph.js";
15
15
  import { PregelLoop } from "./loop.js";
16
16
  import { ChannelKeyPlaceholder, isConfiguredManagedValue, ManagedValueMapping, NoopManagedValue, } from "../managed/base.js";
@@ -18,7 +18,7 @@ import { gatherIterator, patchConfigurable } from "../utils.js";
18
18
  import { ensureLangGraphConfig, recastCheckpointNamespace, } from "./utils/config.js";
19
19
  import { StreamMessagesHandler } from "./messages.js";
20
20
  import { PregelRunner } from "./runner.js";
21
- import { IterableReadableWritableStream } from "./stream.js";
21
+ import { IterableReadableStreamWithAbortSignal, IterableReadableWritableStream, } from "./stream.js";
22
22
  function isString(value) {
23
23
  return typeof value === "string";
24
24
  }
@@ -1172,21 +1172,29 @@ export class Pregel extends Runnable {
1172
1172
  // There is currently no way in _streamIterator to determine whether this was
1173
1173
  // set by by ensureConfig or manually by the user, so we specify the bound value here
1174
1174
  // and override if it is passed as an explicit param in `options`.
1175
+ const abortController = new AbortController();
1175
1176
  const config = {
1176
1177
  recursionLimit: this.config?.recursionLimit,
1177
1178
  ...options,
1179
+ signal: options?.signal
1180
+ ? combineAbortSignals(options.signal, abortController.signal)
1181
+ : abortController.signal,
1178
1182
  };
1179
- return super.stream(input, config);
1183
+ return new IterableReadableStreamWithAbortSignal(await super.stream(input, config), abortController);
1180
1184
  }
1181
1185
  streamEvents(input, options, streamOptions) {
1182
- // Similar to `stream`, we need to pass the `config.callbacks` here,
1183
- // otherwise the user-provided callback will get lost in `ensureLangGraphConfig`.
1186
+ const abortController = new AbortController();
1184
1187
  const config = {
1185
1188
  recursionLimit: this.config?.recursionLimit,
1189
+ // Similar to `stream`, we need to pass the `config.callbacks` here,
1190
+ // otherwise the user-provided callback will get lost in `ensureLangGraphConfig`.
1186
1191
  callbacks: this.config?.callbacks,
1187
1192
  ...options,
1193
+ signal: options?.signal
1194
+ ? combineAbortSignals(options.signal, abortController.signal)
1195
+ : abortController.signal,
1188
1196
  };
1189
- return super.streamEvents(input, config, streamOptions);
1197
+ return new IterableReadableStreamWithAbortSignal(super.streamEvents(input, config, streamOptions), abortController);
1190
1198
  }
1191
1199
  /**
1192
1200
  * Prepares channel specifications and managed values for graph execution.