@langchain/langgraph 0.2.14 → 0.2.16

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.
@@ -39,7 +39,9 @@ class LastValue extends base_js_1.BaseChannel {
39
39
  return false;
40
40
  }
41
41
  if (values.length !== 1) {
42
- throw new errors_js_1.InvalidUpdateError("LastValue can only receive one value per step.");
42
+ throw new errors_js_1.InvalidUpdateError("LastValue can only receive one value per step.", {
43
+ lc_error_code: "INVALID_CONCURRENT_GRAPH_UPDATE",
44
+ });
43
45
  }
44
46
  // eslint-disable-next-line prefer-destructuring
45
47
  this.value = values[values.length - 1];
@@ -36,7 +36,9 @@ export class LastValue extends BaseChannel {
36
36
  return false;
37
37
  }
38
38
  if (values.length !== 1) {
39
- throw new InvalidUpdateError("LastValue can only receive one value per step.");
39
+ throw new InvalidUpdateError("LastValue can only receive one value per step.", {
40
+ lc_error_code: "INVALID_CONCURRENT_GRAPH_UPDATE",
41
+ });
40
42
  }
41
43
  // eslint-disable-next-line prefer-destructuring
42
44
  this.value = values[values.length - 1];
package/dist/errors.cjs CHANGED
@@ -1,9 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSubgraphsSeenSet = exports.MultipleSubgraphsError = exports.InvalidUpdateError = exports.EmptyChannelError = exports.EmptyInputError = exports.isGraphInterrupt = exports.NodeInterrupt = exports.GraphInterrupt = exports.GraphValueError = exports.GraphRecursionError = void 0;
4
- class GraphRecursionError extends Error {
5
- constructor(message) {
6
- super(message);
3
+ exports.getSubgraphsSeenSet = exports.MultipleSubgraphsError = exports.InvalidUpdateError = exports.EmptyChannelError = exports.EmptyInputError = exports.isGraphInterrupt = exports.NodeInterrupt = exports.GraphInterrupt = exports.GraphValueError = exports.GraphRecursionError = exports.BaseLangGraphError = void 0;
4
+ // TODO: Merge with base LangChain error class when we drop support for core@0.2.0
5
+ class BaseLangGraphError extends Error {
6
+ constructor(message, fields) {
7
+ let finalMessage = message ?? "";
8
+ if (fields?.lc_error_code) {
9
+ finalMessage = `${finalMessage}\n\nTroubleshooting URL: https://js.langchain.com/docs/troubleshooting/errors/${fields.lc_error_code}/\n`;
10
+ }
11
+ super(finalMessage);
12
+ Object.defineProperty(this, "lc_error_code", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ this.lc_error_code = fields?.lc_error_code;
19
+ }
20
+ }
21
+ exports.BaseLangGraphError = BaseLangGraphError;
22
+ class GraphRecursionError extends BaseLangGraphError {
23
+ constructor(message, fields) {
24
+ super(message, fields);
7
25
  this.name = "GraphRecursionError";
8
26
  }
9
27
  static get unminifiable_name() {
@@ -11,9 +29,9 @@ class GraphRecursionError extends Error {
11
29
  }
12
30
  }
13
31
  exports.GraphRecursionError = GraphRecursionError;
14
- class GraphValueError extends Error {
15
- constructor(message) {
16
- super(message);
32
+ class GraphValueError extends BaseLangGraphError {
33
+ constructor(message, fields) {
34
+ super(message, fields);
17
35
  this.name = "GraphValueError";
18
36
  }
19
37
  static get unminifiable_name() {
@@ -21,9 +39,9 @@ class GraphValueError extends Error {
21
39
  }
22
40
  }
23
41
  exports.GraphValueError = GraphValueError;
24
- class GraphInterrupt extends Error {
25
- constructor(interrupts = []) {
26
- super(JSON.stringify(interrupts, null, 2));
42
+ class GraphInterrupt extends BaseLangGraphError {
43
+ constructor(interrupts, fields) {
44
+ super(JSON.stringify(interrupts, null, 2), fields);
27
45
  Object.defineProperty(this, "interrupts", {
28
46
  enumerable: true,
29
47
  configurable: true,
@@ -31,7 +49,7 @@ class GraphInterrupt extends Error {
31
49
  value: void 0
32
50
  });
33
51
  this.name = "GraphInterrupt";
34
- this.interrupts = interrupts;
52
+ this.interrupts = interrupts ?? [];
35
53
  }
36
54
  static get unminifiable_name() {
37
55
  return "GraphInterrupt";
@@ -40,13 +58,13 @@ class GraphInterrupt extends Error {
40
58
  exports.GraphInterrupt = GraphInterrupt;
41
59
  /** Raised by a node to interrupt execution. */
42
60
  class NodeInterrupt extends GraphInterrupt {
43
- constructor(message) {
61
+ constructor(message, fields) {
44
62
  super([
45
63
  {
46
64
  value: message,
47
65
  when: "during",
48
66
  },
49
- ]);
67
+ ], fields);
50
68
  this.name = "NodeInterrupt";
51
69
  }
52
70
  static get unminifiable_name() {
@@ -62,9 +80,9 @@ function isGraphInterrupt(e) {
62
80
  ].includes(e.name));
63
81
  }
64
82
  exports.isGraphInterrupt = isGraphInterrupt;
65
- class EmptyInputError extends Error {
66
- constructor(message) {
67
- super(message);
83
+ class EmptyInputError extends BaseLangGraphError {
84
+ constructor(message, fields) {
85
+ super(message, fields);
68
86
  this.name = "EmptyInputError";
69
87
  }
70
88
  static get unminifiable_name() {
@@ -72,9 +90,9 @@ class EmptyInputError extends Error {
72
90
  }
73
91
  }
74
92
  exports.EmptyInputError = EmptyInputError;
75
- class EmptyChannelError extends Error {
76
- constructor(message) {
77
- super(message);
93
+ class EmptyChannelError extends BaseLangGraphError {
94
+ constructor(message, fields) {
95
+ super(message, fields);
78
96
  this.name = "EmptyChannelError";
79
97
  }
80
98
  static get unminifiable_name() {
@@ -82,9 +100,9 @@ class EmptyChannelError extends Error {
82
100
  }
83
101
  }
84
102
  exports.EmptyChannelError = EmptyChannelError;
85
- class InvalidUpdateError extends Error {
86
- constructor(message) {
87
- super(message);
103
+ class InvalidUpdateError extends BaseLangGraphError {
104
+ constructor(message, fields) {
105
+ super(message, fields);
88
106
  this.name = "InvalidUpdateError";
89
107
  }
90
108
  static get unminifiable_name() {
@@ -92,9 +110,9 @@ class InvalidUpdateError extends Error {
92
110
  }
93
111
  }
94
112
  exports.InvalidUpdateError = InvalidUpdateError;
95
- class MultipleSubgraphsError extends Error {
96
- constructor(message) {
97
- super(message);
113
+ class MultipleSubgraphsError extends BaseLangGraphError {
114
+ constructor(message, fields) {
115
+ super(message, fields);
98
116
  this.name = "MultipleSubgraphError";
99
117
  }
100
118
  static get unminifiable_name() {
package/dist/errors.d.ts CHANGED
@@ -1,37 +1,44 @@
1
1
  import { Interrupt } from "./constants.js";
2
- export declare class GraphRecursionError extends Error {
3
- constructor(message?: string);
2
+ export type BaseLangGraphErrorFields = {
3
+ lc_error_code?: string;
4
+ };
5
+ export declare class BaseLangGraphError extends Error {
6
+ lc_error_code?: string;
7
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
8
+ }
9
+ export declare class GraphRecursionError extends BaseLangGraphError {
10
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
4
11
  static get unminifiable_name(): string;
5
12
  }
6
- export declare class GraphValueError extends Error {
7
- constructor(message?: string);
13
+ export declare class GraphValueError extends BaseLangGraphError {
14
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
8
15
  static get unminifiable_name(): string;
9
16
  }
10
- export declare class GraphInterrupt extends Error {
17
+ export declare class GraphInterrupt extends BaseLangGraphError {
11
18
  interrupts: Interrupt[];
12
- constructor(interrupts?: Interrupt[]);
19
+ constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields);
13
20
  static get unminifiable_name(): string;
14
21
  }
15
22
  /** Raised by a node to interrupt execution. */
16
23
  export declare class NodeInterrupt extends GraphInterrupt {
17
- constructor(message: string);
24
+ constructor(message: string, fields?: BaseLangGraphErrorFields);
18
25
  static get unminifiable_name(): string;
19
26
  }
20
27
  export declare function isGraphInterrupt(e?: GraphInterrupt | Error): e is GraphInterrupt;
21
- export declare class EmptyInputError extends Error {
22
- constructor(message?: string);
28
+ export declare class EmptyInputError extends BaseLangGraphError {
29
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
23
30
  static get unminifiable_name(): string;
24
31
  }
25
- export declare class EmptyChannelError extends Error {
26
- constructor(message?: string);
32
+ export declare class EmptyChannelError extends BaseLangGraphError {
33
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
27
34
  static get unminifiable_name(): string;
28
35
  }
29
- export declare class InvalidUpdateError extends Error {
30
- constructor(message?: string);
36
+ export declare class InvalidUpdateError extends BaseLangGraphError {
37
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
31
38
  static get unminifiable_name(): string;
32
39
  }
33
- export declare class MultipleSubgraphsError extends Error {
34
- constructor(message?: string);
40
+ export declare class MultipleSubgraphsError extends BaseLangGraphError {
41
+ constructor(message?: string, fields?: BaseLangGraphErrorFields);
35
42
  static get unminifiable_name(): string;
36
43
  }
37
44
  /**
package/dist/errors.js CHANGED
@@ -1,24 +1,41 @@
1
- export class GraphRecursionError extends Error {
2
- constructor(message) {
3
- super(message);
1
+ // TODO: Merge with base LangChain error class when we drop support for core@0.2.0
2
+ export class BaseLangGraphError extends Error {
3
+ constructor(message, fields) {
4
+ let finalMessage = message ?? "";
5
+ if (fields?.lc_error_code) {
6
+ finalMessage = `${finalMessage}\n\nTroubleshooting URL: https://js.langchain.com/docs/troubleshooting/errors/${fields.lc_error_code}/\n`;
7
+ }
8
+ super(finalMessage);
9
+ Object.defineProperty(this, "lc_error_code", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: void 0
14
+ });
15
+ this.lc_error_code = fields?.lc_error_code;
16
+ }
17
+ }
18
+ export class GraphRecursionError extends BaseLangGraphError {
19
+ constructor(message, fields) {
20
+ super(message, fields);
4
21
  this.name = "GraphRecursionError";
5
22
  }
6
23
  static get unminifiable_name() {
7
24
  return "GraphRecursionError";
8
25
  }
9
26
  }
10
- export class GraphValueError extends Error {
11
- constructor(message) {
12
- super(message);
27
+ export class GraphValueError extends BaseLangGraphError {
28
+ constructor(message, fields) {
29
+ super(message, fields);
13
30
  this.name = "GraphValueError";
14
31
  }
15
32
  static get unminifiable_name() {
16
33
  return "GraphValueError";
17
34
  }
18
35
  }
19
- export class GraphInterrupt extends Error {
20
- constructor(interrupts = []) {
21
- super(JSON.stringify(interrupts, null, 2));
36
+ export class GraphInterrupt extends BaseLangGraphError {
37
+ constructor(interrupts, fields) {
38
+ super(JSON.stringify(interrupts, null, 2), fields);
22
39
  Object.defineProperty(this, "interrupts", {
23
40
  enumerable: true,
24
41
  configurable: true,
@@ -26,7 +43,7 @@ export class GraphInterrupt extends Error {
26
43
  value: void 0
27
44
  });
28
45
  this.name = "GraphInterrupt";
29
- this.interrupts = interrupts;
46
+ this.interrupts = interrupts ?? [];
30
47
  }
31
48
  static get unminifiable_name() {
32
49
  return "GraphInterrupt";
@@ -34,13 +51,13 @@ export class GraphInterrupt extends Error {
34
51
  }
35
52
  /** Raised by a node to interrupt execution. */
36
53
  export class NodeInterrupt extends GraphInterrupt {
37
- constructor(message) {
54
+ constructor(message, fields) {
38
55
  super([
39
56
  {
40
57
  value: message,
41
58
  when: "during",
42
59
  },
43
- ]);
60
+ ], fields);
44
61
  this.name = "NodeInterrupt";
45
62
  }
46
63
  static get unminifiable_name() {
@@ -54,36 +71,36 @@ export function isGraphInterrupt(e) {
54
71
  NodeInterrupt.unminifiable_name,
55
72
  ].includes(e.name));
56
73
  }
57
- export class EmptyInputError extends Error {
58
- constructor(message) {
59
- super(message);
74
+ export class EmptyInputError extends BaseLangGraphError {
75
+ constructor(message, fields) {
76
+ super(message, fields);
60
77
  this.name = "EmptyInputError";
61
78
  }
62
79
  static get unminifiable_name() {
63
80
  return "EmptyInputError";
64
81
  }
65
82
  }
66
- export class EmptyChannelError extends Error {
67
- constructor(message) {
68
- super(message);
83
+ export class EmptyChannelError extends BaseLangGraphError {
84
+ constructor(message, fields) {
85
+ super(message, fields);
69
86
  this.name = "EmptyChannelError";
70
87
  }
71
88
  static get unminifiable_name() {
72
89
  return "EmptyChannelError";
73
90
  }
74
91
  }
75
- export class InvalidUpdateError extends Error {
76
- constructor(message) {
77
- super(message);
92
+ export class InvalidUpdateError extends BaseLangGraphError {
93
+ constructor(message, fields) {
94
+ super(message, fields);
78
95
  this.name = "InvalidUpdateError";
79
96
  }
80
97
  static get unminifiable_name() {
81
98
  return "InvalidUpdateError";
82
99
  }
83
100
  }
84
- export class MultipleSubgraphsError extends Error {
85
- constructor(message) {
86
- super(message);
101
+ export class MultipleSubgraphsError extends BaseLangGraphError {
102
+ constructor(message, fields) {
103
+ super(message, fields);
87
104
  this.name = "MultipleSubgraphError";
88
105
  }
89
106
  static get unminifiable_name() {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.messagesStateReducer = exports.MessageGraph = exports.StateGraph = exports.Graph = exports.START = exports.END = exports.AnnotationRoot = exports.Annotation = void 0;
3
+ exports.messagesStateReducer = exports.MessageGraph = exports.CompiledStateGraph = exports.StateGraph = exports.Graph = exports.START = exports.END = exports.AnnotationRoot = exports.Annotation = void 0;
4
4
  var annotation_js_1 = require("./annotation.cjs");
5
5
  Object.defineProperty(exports, "Annotation", { enumerable: true, get: function () { return annotation_js_1.Annotation; } });
6
6
  Object.defineProperty(exports, "AnnotationRoot", { enumerable: true, get: function () { return annotation_js_1.AnnotationRoot; } });
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "START", { enumerable: true, get: function () { r
10
10
  Object.defineProperty(exports, "Graph", { enumerable: true, get: function () { return graph_js_1.Graph; } });
11
11
  var state_js_1 = require("./state.cjs");
12
12
  Object.defineProperty(exports, "StateGraph", { enumerable: true, get: function () { return state_js_1.StateGraph; } });
13
+ Object.defineProperty(exports, "CompiledStateGraph", { enumerable: true, get: function () { return state_js_1.CompiledStateGraph; } });
13
14
  var message_js_1 = require("./message.cjs");
14
15
  Object.defineProperty(exports, "MessageGraph", { enumerable: true, get: function () { return message_js_1.MessageGraph; } });
15
16
  Object.defineProperty(exports, "messagesStateReducer", { enumerable: true, get: function () { return message_js_1.messagesStateReducer; } });
@@ -1,4 +1,4 @@
1
1
  export { Annotation, type StateType, type UpdateType, type NodeType, AnnotationRoot, type StateDefinition, type SingleReducer, } from "./annotation.js";
2
2
  export { END, START, Graph, type CompiledGraph } from "./graph.js";
3
- export { type StateGraphArgs, StateGraph, type CompiledStateGraph, } from "./state.js";
3
+ export { type StateGraphArgs, StateGraph, CompiledStateGraph, } from "./state.js";
4
4
  export { MessageGraph, messagesStateReducer, type Messages, } from "./message.js";
@@ -1,4 +1,4 @@
1
1
  export { Annotation, AnnotationRoot, } from "./annotation.js";
2
2
  export { END, START, Graph } from "./graph.js";
3
- export { StateGraph, } from "./state.js";
3
+ export { StateGraph, CompiledStateGraph, } from "./state.js";
4
4
  export { MessageGraph, messagesStateReducer, } from "./message.js";
@@ -238,14 +238,14 @@ class StateGraph extends graph_js_1.Graph {
238
238
  throw new Error("END cannot be a start node");
239
239
  }
240
240
  if (!Object.keys(this.nodes).some((node) => node === start)) {
241
- throw new Error(`Need to addNode ${start} first`);
241
+ throw new Error(`Need to add a node named "${start}" first`);
242
242
  }
243
243
  }
244
244
  if (endKey === graph_js_1.END) {
245
245
  throw new Error("END cannot be an end node");
246
246
  }
247
247
  if (!Object.keys(this.nodes).some((node) => node === endKey)) {
248
- throw new Error(`Need to addNode ${endKey} first`);
248
+ throw new Error(`Need to add a node named "${endKey}" first`);
249
249
  }
250
250
  this.waitingEdges.add([startKey, endKey]);
251
251
  return this;
@@ -312,6 +312,11 @@ function _getChannels(schema) {
312
312
  }
313
313
  return channels;
314
314
  }
315
+ /**
316
+ * Final result from building and compiling a {@link StateGraph}.
317
+ * Should not be instantiated directly, only using the StateGraph `.compile()`
318
+ * instance method.
319
+ */
315
320
  class CompiledStateGraph extends graph_js_1.CompiledGraph {
316
321
  attachNode(key, node) {
317
322
  const stateKeys = Object.keys(this.builder.channels);
@@ -321,7 +326,9 @@ class CompiledStateGraph extends graph_js_1.CompiledGraph {
321
326
  }
322
327
  else if (typeof input !== "object" || Array.isArray(input)) {
323
328
  const typeofInput = Array.isArray(input) ? "array" : typeof input;
324
- throw new errors_js_1.InvalidUpdateError(`Expected object, got ${typeofInput}`);
329
+ throw new errors_js_1.InvalidUpdateError(`Expected node "${key.toString()}" to return an object, received ${typeofInput}`, {
330
+ lc_error_code: "INVALID_GRAPH_NODE_RETURN_VALUE",
331
+ });
325
332
  }
326
333
  else {
327
334
  return key in input ? input[key] : write_js_1.SKIP_WRITE;
@@ -123,6 +123,11 @@ export declare class StateGraph<SD extends StateDefinition | unknown, S = SD ext
123
123
  interruptAfter?: N[] | All;
124
124
  }): CompiledStateGraph<S, U, N, I, O, C>;
125
125
  }
126
+ /**
127
+ * Final result from building and compiling a {@link StateGraph}.
128
+ * Should not be instantiated directly, only using the StateGraph `.compile()`
129
+ * instance method.
130
+ */
126
131
  export declare class CompiledStateGraph<S, U, N extends string = typeof START, I extends StateDefinition = StateDefinition, O extends StateDefinition = StateDefinition, C extends StateDefinition = StateDefinition> extends CompiledGraph<N, S, U, StateType<C>> {
127
132
  builder: StateGraph<unknown, S, U, N, I, O, C>;
128
133
  attachNode(key: typeof START, node?: never): void;
@@ -235,14 +235,14 @@ export class StateGraph extends Graph {
235
235
  throw new Error("END cannot be a start node");
236
236
  }
237
237
  if (!Object.keys(this.nodes).some((node) => node === start)) {
238
- throw new Error(`Need to addNode ${start} first`);
238
+ throw new Error(`Need to add a node named "${start}" first`);
239
239
  }
240
240
  }
241
241
  if (endKey === END) {
242
242
  throw new Error("END cannot be an end node");
243
243
  }
244
244
  if (!Object.keys(this.nodes).some((node) => node === endKey)) {
245
- throw new Error(`Need to addNode ${endKey} first`);
245
+ throw new Error(`Need to add a node named "${endKey}" first`);
246
246
  }
247
247
  this.waitingEdges.add([startKey, endKey]);
248
248
  return this;
@@ -308,6 +308,11 @@ function _getChannels(schema) {
308
308
  }
309
309
  return channels;
310
310
  }
311
+ /**
312
+ * Final result from building and compiling a {@link StateGraph}.
313
+ * Should not be instantiated directly, only using the StateGraph `.compile()`
314
+ * instance method.
315
+ */
311
316
  export class CompiledStateGraph extends CompiledGraph {
312
317
  attachNode(key, node) {
313
318
  const stateKeys = Object.keys(this.builder.channels);
@@ -317,7 +322,9 @@ export class CompiledStateGraph extends CompiledGraph {
317
322
  }
318
323
  else if (typeof input !== "object" || Array.isArray(input)) {
319
324
  const typeofInput = Array.isArray(input) ? "array" : typeof input;
320
- throw new InvalidUpdateError(`Expected object, got ${typeofInput}`);
325
+ throw new InvalidUpdateError(`Expected node "${key.toString()}" to return an object, received ${typeofInput}`, {
326
+ lc_error_code: "INVALID_GRAPH_NODE_RETURN_VALUE",
327
+ });
321
328
  }
322
329
  else {
323
330
  return key in input ? input[key] : SKIP_WRITE;
@@ -84,7 +84,7 @@ writes) {
84
84
  throw new errors_js_1.InvalidUpdateError(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(value)}`);
85
85
  }
86
86
  if (!(value.node in processes)) {
87
- throw new errors_js_1.InvalidUpdateError(`Invalid node name ${value.node} in packet`);
87
+ throw new errors_js_1.InvalidUpdateError(`Invalid node name "${value.node}" in Send packet`);
88
88
  }
89
89
  // replace any runtime values with placeholders
90
90
  managed.replaceRuntimeValues(step, value.args);
@@ -178,7 +178,9 @@ getNextVersion) {
178
178
  }
179
179
  catch (e) {
180
180
  if (e.name === errors_js_1.InvalidUpdateError.unminifiable_name) {
181
- throw new errors_js_1.InvalidUpdateError(`Invalid update for channel ${chan} with values ${JSON.stringify(vals)}: ${e.message}`);
181
+ const wrappedError = new errors_js_1.InvalidUpdateError(`Invalid update for channel "${chan}" with values ${JSON.stringify(vals)}: ${e.message}`);
182
+ wrappedError.lc_error_code = e.lc_error_code;
183
+ throw wrappedError;
182
184
  }
183
185
  else {
184
186
  throw e;
@@ -78,7 +78,7 @@ writes) {
78
78
  throw new InvalidUpdateError(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(value)}`);
79
79
  }
80
80
  if (!(value.node in processes)) {
81
- throw new InvalidUpdateError(`Invalid node name ${value.node} in packet`);
81
+ throw new InvalidUpdateError(`Invalid node name "${value.node}" in Send packet`);
82
82
  }
83
83
  // replace any runtime values with placeholders
84
84
  managed.replaceRuntimeValues(step, value.args);
@@ -171,7 +171,9 @@ getNextVersion) {
171
171
  }
172
172
  catch (e) {
173
173
  if (e.name === InvalidUpdateError.unminifiable_name) {
174
- throw new InvalidUpdateError(`Invalid update for channel ${chan} with values ${JSON.stringify(vals)}: ${e.message}`);
174
+ const wrappedError = new InvalidUpdateError(`Invalid update for channel "${chan}" with values ${JSON.stringify(vals)}: ${e.message}`);
175
+ wrappedError.lc_error_code = e.lc_error_code;
176
+ throw wrappedError;
175
177
  }
176
178
  else {
177
179
  throw e;
@@ -4,6 +4,7 @@ exports.printStepWrites = exports.printStepTasks = exports.printStepCheckpoint =
4
4
  const constants_js_1 = require("../constants.cjs");
5
5
  const errors_js_1 = require("../errors.cjs");
6
6
  const io_js_1 = require("./io.cjs");
7
+ const subgraph_js_1 = require("./utils/subgraph.cjs");
7
8
  const COLORS_MAP = {
8
9
  blue: {
9
10
  start: "\x1b[34m",
@@ -101,7 +102,7 @@ function* mapDebugTaskResults(step, tasks, streamChannels) {
101
102
  }
102
103
  }
103
104
  exports.mapDebugTaskResults = mapDebugTaskResults;
104
- function* mapDebugCheckpoint(step, config, channels, streamChannels, metadata, tasks, pendingWrites) {
105
+ function* mapDebugCheckpoint(step, config, channels, streamChannels, metadata, tasks, pendingWrites, parentConfig) {
105
106
  function formatConfig(config) {
106
107
  // make sure the config is consistent with Python
107
108
  const pyConfig = {};
@@ -123,11 +124,22 @@ function* mapDebugCheckpoint(step, config, channels, streamChannels, metadata, t
123
124
  pyConfig.tags = config.tags;
124
125
  return pyConfig;
125
126
  }
126
- function getCurrentUTC() {
127
- const now = new Date();
128
- return new Date(now.getTime() - now.getTimezoneOffset() * 60 * 1000);
127
+ const parentNs = config.configurable?.checkpoint_ns;
128
+ const taskStates = {};
129
+ for (const task of tasks) {
130
+ if (!(0, subgraph_js_1.findSubgraphPregel)(task.proc))
131
+ continue;
132
+ let taskNs = `${task.name}:${task.id}`;
133
+ if (parentNs)
134
+ taskNs = `${parentNs}|${taskNs}`;
135
+ taskStates[task.id] = {
136
+ configurable: {
137
+ thread_id: config.configurable?.thread_id,
138
+ checkpoint_ns: taskNs,
139
+ },
140
+ };
129
141
  }
130
- const ts = getCurrentUTC().toISOString();
142
+ const ts = new Date().toISOString();
131
143
  yield {
132
144
  type: "checkpoint",
133
145
  timestamp: ts,
@@ -137,7 +149,8 @@ function* mapDebugCheckpoint(step, config, channels, streamChannels, metadata, t
137
149
  values: (0, io_js_1.readChannels)(channels, streamChannels),
138
150
  metadata,
139
151
  next: tasks.map((task) => task.name),
140
- tasks: tasksWithWrites(tasks, pendingWrites),
152
+ tasks: tasksWithWrites(tasks, pendingWrites, taskStates),
153
+ parentConfig: parentConfig ? formatConfig(parentConfig) : undefined,
141
154
  },
142
155
  };
143
156
  }
@@ -26,7 +26,7 @@ export declare function mapDebugTaskResults<N extends PropertyKey, C extends Pro
26
26
  interrupts: PendingWrite<C>[];
27
27
  };
28
28
  }, void, unknown>;
29
- export declare function mapDebugCheckpoint<N extends PropertyKey, C extends PropertyKey>(step: number, config: RunnableConfig, channels: Record<string, BaseChannel>, streamChannels: string | string[], metadata: CheckpointMetadata, tasks: readonly PregelExecutableTask<N, C>[], pendingWrites: CheckpointPendingWrite[]): Generator<{
29
+ export declare function mapDebugCheckpoint<N extends PropertyKey, C extends PropertyKey>(step: number, config: RunnableConfig, channels: Record<string, BaseChannel>, streamChannels: string | string[], metadata: CheckpointMetadata, tasks: readonly PregelExecutableTask<N, C>[], pendingWrites: CheckpointPendingWrite[], parentConfig: RunnableConfig | undefined): Generator<{
30
30
  type: string;
31
31
  timestamp: string;
32
32
  step: number;
@@ -36,6 +36,7 @@ export declare function mapDebugCheckpoint<N extends PropertyKey, C extends Prop
36
36
  metadata: CheckpointMetadata;
37
37
  next: N[];
38
38
  tasks: PregelTaskDescription[];
39
+ parentConfig: Partial<Record<"configurable" | "timeout" | "signal" | "tags" | "metadata" | "callbacks" | "recursion_limit" | "max_concurrency" | "run_name" | "run_id", unknown>> | undefined;
39
40
  };
40
41
  }, void, unknown>;
41
42
  export declare function tasksWithWrites<N extends PropertyKey, C extends PropertyKey>(tasks: PregelTaskDescription[] | readonly PregelExecutableTask<N, C>[], pendingWrites: CheckpointPendingWrite[], states?: Record<string, RunnableConfig | StateSnapshot>): PregelTaskDescription[];
@@ -1,6 +1,7 @@
1
1
  import { ERROR, INTERRUPT, TAG_HIDDEN } from "../constants.js";
2
2
  import { EmptyChannelError } from "../errors.js";
3
3
  import { readChannels } from "./io.js";
4
+ import { findSubgraphPregel } from "./utils/subgraph.js";
4
5
  const COLORS_MAP = {
5
6
  blue: {
6
7
  start: "\x1b[34m",
@@ -95,7 +96,7 @@ export function* mapDebugTaskResults(step, tasks, streamChannels) {
95
96
  };
96
97
  }
97
98
  }
98
- export function* mapDebugCheckpoint(step, config, channels, streamChannels, metadata, tasks, pendingWrites) {
99
+ export function* mapDebugCheckpoint(step, config, channels, streamChannels, metadata, tasks, pendingWrites, parentConfig) {
99
100
  function formatConfig(config) {
100
101
  // make sure the config is consistent with Python
101
102
  const pyConfig = {};
@@ -117,11 +118,22 @@ export function* mapDebugCheckpoint(step, config, channels, streamChannels, meta
117
118
  pyConfig.tags = config.tags;
118
119
  return pyConfig;
119
120
  }
120
- function getCurrentUTC() {
121
- const now = new Date();
122
- return new Date(now.getTime() - now.getTimezoneOffset() * 60 * 1000);
121
+ const parentNs = config.configurable?.checkpoint_ns;
122
+ const taskStates = {};
123
+ for (const task of tasks) {
124
+ if (!findSubgraphPregel(task.proc))
125
+ continue;
126
+ let taskNs = `${task.name}:${task.id}`;
127
+ if (parentNs)
128
+ taskNs = `${parentNs}|${taskNs}`;
129
+ taskStates[task.id] = {
130
+ configurable: {
131
+ thread_id: config.configurable?.thread_id,
132
+ checkpoint_ns: taskNs,
133
+ },
134
+ };
123
135
  }
124
- const ts = getCurrentUTC().toISOString();
136
+ const ts = new Date().toISOString();
125
137
  yield {
126
138
  type: "checkpoint",
127
139
  timestamp: ts,
@@ -131,7 +143,8 @@ export function* mapDebugCheckpoint(step, config, channels, streamChannels, meta
131
143
  values: readChannels(channels, streamChannels),
132
144
  metadata,
133
145
  next: tasks.map((task) => task.name),
134
- tasks: tasksWithWrites(tasks, pendingWrites),
146
+ tasks: tasksWithWrites(tasks, pendingWrites, taskStates),
147
+ parentConfig: parentConfig ? formatConfig(parentConfig) : undefined,
135
148
  },
136
149
  };
137
150
  }
@@ -18,6 +18,7 @@ const constants_js_1 = require("../constants.cjs");
18
18
  const errors_js_1 = require("../errors.cjs");
19
19
  const algo_js_1 = require("./algo.cjs");
20
20
  const index_js_1 = require("./utils/index.cjs");
21
+ const subgraph_js_1 = require("./utils/subgraph.cjs");
21
22
  const loop_js_1 = require("./loop.cjs");
22
23
  const retry_js_1 = require("./retry.cjs");
23
24
  const base_js_2 = require("../managed/base.cjs");
@@ -81,16 +82,6 @@ class Channel {
81
82
  }
82
83
  }
83
84
  exports.Channel = Channel;
84
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
- function isPregel(x) {
86
- return ("inputChannels" in x &&
87
- x.inputChannels !== undefined &&
88
- "outputChannels" &&
89
- x.outputChannels !== undefined);
90
- }
91
- function isRunnableSequence(x) {
92
- return "steps" in x && Array.isArray(x.steps);
93
- }
94
85
  class Pregel extends runnables_1.Runnable {
95
86
  static lc_name() {
96
87
  return "LangGraph";
@@ -264,18 +255,7 @@ class Pregel extends runnables_1.Runnable {
264
255
  continue;
265
256
  }
266
257
  }
267
- // find the subgraph if any
268
- let graph;
269
- const candidates = [node.bound];
270
- for (const candidate of candidates) {
271
- if (isPregel(candidate)) {
272
- graph = candidate;
273
- break;
274
- }
275
- else if (isRunnableSequence(candidate)) {
276
- candidates.push(...candidate.steps);
277
- }
278
- }
258
+ const graph = (0, subgraph_js_1.findSubgraphPregel)(node.bound);
279
259
  // if found, yield recursively
280
260
  if (graph !== undefined) {
281
261
  if (name === namespace) {
@@ -814,7 +794,9 @@ class Pregel extends runnables_1.Runnable {
814
794
  `Recursion limit of ${config.recursionLimit} reached`,
815
795
  "without hitting a stop condition. You can increase the",
816
796
  `limit by setting the "recursionLimit" config key.`,
817
- ].join(" "));
797
+ ].join(" "), {
798
+ lc_error_code: "GRAPH_RECURSION_LIMIT",
799
+ });
818
800
  }
819
801
  await Promise.all(loop?.checkpointerPromises ?? []);
820
802
  await runManager?.handleChainEnd(loop.output);
@@ -12,6 +12,7 @@ import { CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_READ, CONFIG_KEY_SEND, ERROR, INTER
12
12
  import { GraphRecursionError, GraphValueError, InvalidUpdateError, isGraphInterrupt, } from "../errors.js";
13
13
  import { _prepareNextTasks, _localRead, _applyWrites, } from "./algo.js";
14
14
  import { _coerceToDict, getNewChannelVersions, patchCheckpointMap, } from "./utils/index.js";
15
+ import { findSubgraphPregel } from "./utils/subgraph.js";
15
16
  import { PregelLoop, StreamProtocol } from "./loop.js";
16
17
  import { executeTasksWithRetry } from "./retry.js";
17
18
  import { ChannelKeyPlaceholder, isConfiguredManagedValue, ManagedValueMapping, NoopManagedValue, } from "../managed/base.js";
@@ -74,16 +75,6 @@ export class Channel {
74
75
  return new ChannelWrite(channelWriteEntries);
75
76
  }
76
77
  }
77
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
- function isPregel(x) {
79
- return ("inputChannels" in x &&
80
- x.inputChannels !== undefined &&
81
- "outputChannels" &&
82
- x.outputChannels !== undefined);
83
- }
84
- function isRunnableSequence(x) {
85
- return "steps" in x && Array.isArray(x.steps);
86
- }
87
78
  export class Pregel extends Runnable {
88
79
  static lc_name() {
89
80
  return "LangGraph";
@@ -257,18 +248,7 @@ export class Pregel extends Runnable {
257
248
  continue;
258
249
  }
259
250
  }
260
- // find the subgraph if any
261
- let graph;
262
- const candidates = [node.bound];
263
- for (const candidate of candidates) {
264
- if (isPregel(candidate)) {
265
- graph = candidate;
266
- break;
267
- }
268
- else if (isRunnableSequence(candidate)) {
269
- candidates.push(...candidate.steps);
270
- }
271
- }
251
+ const graph = findSubgraphPregel(node.bound);
272
252
  // if found, yield recursively
273
253
  if (graph !== undefined) {
274
254
  if (name === namespace) {
@@ -807,7 +787,9 @@ export class Pregel extends Runnable {
807
787
  `Recursion limit of ${config.recursionLimit} reached`,
808
788
  "without hitting a stop condition. You can increase the",
809
789
  `limit by setting the "recursionLimit" config key.`,
810
- ].join(" "));
790
+ ].join(" "), {
791
+ lc_error_code: "GRAPH_RECURSION_LIMIT",
792
+ });
811
793
  }
812
794
  await Promise.all(loop?.checkpointerPromises ?? []);
813
795
  await runManager?.handleChainEnd(loop.output);
@@ -166,6 +166,12 @@ class PregelLoop {
166
166
  writable: true,
167
167
  value: 0
168
168
  });
169
+ Object.defineProperty(this, "prevCheckpointConfig", {
170
+ enumerable: true,
171
+ configurable: true,
172
+ writable: true,
173
+ value: void 0
174
+ });
169
175
  Object.defineProperty(this, "status", {
170
176
  enumerable: true,
171
177
  configurable: true,
@@ -238,6 +244,7 @@ class PregelLoop {
238
244
  this.store = params.store;
239
245
  this.stream = params.stream;
240
246
  this.checkpointNamespace = params.checkpointNamespace;
247
+ this.prevCheckpointConfig = params.prevCheckpointConfig;
241
248
  }
242
249
  static async initialize(params) {
243
250
  let { config, stream } = params;
@@ -284,6 +291,7 @@ class PregelLoop {
284
291
  ...saved.config.configurable,
285
292
  },
286
293
  };
294
+ const prevCheckpointConfig = saved.parentConfig;
287
295
  const checkpoint = (0, langgraph_checkpoint_1.copyCheckpoint)(saved.checkpoint);
288
296
  const checkpointMetadata = { ...saved.metadata };
289
297
  const checkpointPendingWrites = saved.pendingWrites ?? [];
@@ -305,7 +313,9 @@ class PregelLoop {
305
313
  "This is not allowed if checkpointing is enabled.",
306
314
  "",
307
315
  `You can disable checkpointing for a subgraph by compiling it with ".compile({ checkpointer: false });"`,
308
- ].join("\n"));
316
+ ].join("\n"), {
317
+ lc_error_code: "MULTIPLE_SUBGRAPHS",
318
+ });
309
319
  }
310
320
  else {
311
321
  (0, errors_js_1.getSubgraphsSeenSet)().add(config.configurable?.checkpoint_ns);
@@ -318,6 +328,7 @@ class PregelLoop {
318
328
  checkpoint,
319
329
  checkpointMetadata,
320
330
  checkpointConfig,
331
+ prevCheckpointConfig,
321
332
  checkpointNamespace,
322
333
  channels,
323
334
  managed: params.managed,
@@ -467,7 +478,7 @@ class PregelLoop {
467
478
  // Produce debug output
468
479
  if (this.checkpointer) {
469
480
  this._emit(await (0, utils_js_1.gatherIterator)((0, utils_js_1.prefixGenerator)((0, debug_js_1.mapDebugCheckpoint)(this.step - 1, // printing checkpoint for previous step
470
- this.checkpointConfig, this.channels, this.streamKeys, this.checkpointMetadata, Object.values(this.tasks), this.checkpointPendingWrites), "debug")));
481
+ this.checkpointConfig, this.channels, this.streamKeys, this.checkpointMetadata, Object.values(this.tasks), this.checkpointPendingWrites, this.prevCheckpointConfig), "debug")));
471
482
  }
472
483
  if (Object.values(this.tasks).length === 0) {
473
484
  this.status = "done";
@@ -600,6 +611,11 @@ class PregelLoop {
600
611
  };
601
612
  // Bail if no checkpointer
602
613
  if (this.checkpointer !== undefined) {
614
+ // store the previous checkpoint config for debug events
615
+ this.prevCheckpointConfig = this.checkpointConfig?.configurable
616
+ ?.checkpoint_id
617
+ ? this.checkpointConfig
618
+ : undefined;
603
619
  // create new checkpoint
604
620
  this.checkpointMetadata = metadata;
605
621
  // child graphs keep at most one checkpoint per parent checkpoint
@@ -41,6 +41,7 @@ type PregelLoopParams = {
41
41
  isNested: boolean;
42
42
  stream: StreamProtocol;
43
43
  store?: AsyncBatchedStore;
44
+ prevCheckpointConfig: RunnableConfig | undefined;
44
45
  };
45
46
  export declare class StreamProtocol {
46
47
  push: (chunk: StreamChunk) => void;
@@ -68,6 +69,7 @@ export declare class PregelLoop {
68
69
  protected nodes: Record<string, PregelNode>;
69
70
  protected skipDoneTasks: boolean;
70
71
  protected taskWritesLeft: number;
72
+ protected prevCheckpointConfig: RunnableConfig | undefined;
71
73
  status: "pending" | "done" | "interrupt_before" | "interrupt_after" | "out_of_steps";
72
74
  tasks: Record<string, PregelExecutableTask<any, any>>;
73
75
  stream: StreamProtocol;
@@ -162,6 +162,12 @@ export class PregelLoop {
162
162
  writable: true,
163
163
  value: 0
164
164
  });
165
+ Object.defineProperty(this, "prevCheckpointConfig", {
166
+ enumerable: true,
167
+ configurable: true,
168
+ writable: true,
169
+ value: void 0
170
+ });
165
171
  Object.defineProperty(this, "status", {
166
172
  enumerable: true,
167
173
  configurable: true,
@@ -234,6 +240,7 @@ export class PregelLoop {
234
240
  this.store = params.store;
235
241
  this.stream = params.stream;
236
242
  this.checkpointNamespace = params.checkpointNamespace;
243
+ this.prevCheckpointConfig = params.prevCheckpointConfig;
237
244
  }
238
245
  static async initialize(params) {
239
246
  let { config, stream } = params;
@@ -280,6 +287,7 @@ export class PregelLoop {
280
287
  ...saved.config.configurable,
281
288
  },
282
289
  };
290
+ const prevCheckpointConfig = saved.parentConfig;
283
291
  const checkpoint = copyCheckpoint(saved.checkpoint);
284
292
  const checkpointMetadata = { ...saved.metadata };
285
293
  const checkpointPendingWrites = saved.pendingWrites ?? [];
@@ -301,7 +309,9 @@ export class PregelLoop {
301
309
  "This is not allowed if checkpointing is enabled.",
302
310
  "",
303
311
  `You can disable checkpointing for a subgraph by compiling it with ".compile({ checkpointer: false });"`,
304
- ].join("\n"));
312
+ ].join("\n"), {
313
+ lc_error_code: "MULTIPLE_SUBGRAPHS",
314
+ });
305
315
  }
306
316
  else {
307
317
  getSubgraphsSeenSet().add(config.configurable?.checkpoint_ns);
@@ -314,6 +324,7 @@ export class PregelLoop {
314
324
  checkpoint,
315
325
  checkpointMetadata,
316
326
  checkpointConfig,
327
+ prevCheckpointConfig,
317
328
  checkpointNamespace,
318
329
  channels,
319
330
  managed: params.managed,
@@ -463,7 +474,7 @@ export class PregelLoop {
463
474
  // Produce debug output
464
475
  if (this.checkpointer) {
465
476
  this._emit(await gatherIterator(prefixGenerator(mapDebugCheckpoint(this.step - 1, // printing checkpoint for previous step
466
- this.checkpointConfig, this.channels, this.streamKeys, this.checkpointMetadata, Object.values(this.tasks), this.checkpointPendingWrites), "debug")));
477
+ this.checkpointConfig, this.channels, this.streamKeys, this.checkpointMetadata, Object.values(this.tasks), this.checkpointPendingWrites, this.prevCheckpointConfig), "debug")));
467
478
  }
468
479
  if (Object.values(this.tasks).length === 0) {
469
480
  this.status = "done";
@@ -596,6 +607,11 @@ export class PregelLoop {
596
607
  };
597
608
  // Bail if no checkpointer
598
609
  if (this.checkpointer !== undefined) {
610
+ // store the previous checkpoint config for debug events
611
+ this.prevCheckpointConfig = this.checkpointConfig?.configurable
612
+ ?.checkpoint_id
613
+ ? this.checkpointConfig
614
+ : undefined;
599
615
  // create new checkpoint
600
616
  this.checkpointMetadata = metadata;
601
617
  // child graphs keep at most one checkpoint per parent checkpoint
@@ -131,13 +131,9 @@ pregelTask, retryPolicy) {
131
131
  error.constructor.unminifiable_name ??
132
132
  error.constructor.name;
133
133
  console.log(`Retrying task "${pregelTask.name}" after ${interval.toFixed(2)} seconds (attempt ${attempts}) after ${errorName}: ${error}`);
134
- // Clear checkpoint_ns seen (for subgraph detection)
135
- const checkpointNs = pregelTask.config?.configurable?.checkpoint_ns;
136
- if (checkpointNs) {
137
- (0, errors_js_1.getSubgraphsSeenSet)().delete(checkpointNs);
138
- }
139
134
  }
140
135
  finally {
136
+ // Clear checkpoint_ns seen (for subgraph detection)
141
137
  const checkpointNs = pregelTask.config?.configurable?.checkpoint_ns;
142
138
  if (checkpointNs) {
143
139
  (0, errors_js_1.getSubgraphsSeenSet)().delete(checkpointNs);
@@ -127,13 +127,9 @@ pregelTask, retryPolicy) {
127
127
  error.constructor.unminifiable_name ??
128
128
  error.constructor.name;
129
129
  console.log(`Retrying task "${pregelTask.name}" after ${interval.toFixed(2)} seconds (attempt ${attempts}) after ${errorName}: ${error}`);
130
- // Clear checkpoint_ns seen (for subgraph detection)
131
- const checkpointNs = pregelTask.config?.configurable?.checkpoint_ns;
132
- if (checkpointNs) {
133
- getSubgraphsSeenSet().delete(checkpointNs);
134
- }
135
130
  }
136
131
  finally {
132
+ // Clear checkpoint_ns seen (for subgraph detection)
137
133
  const checkpointNs = pregelTask.config?.configurable?.checkpoint_ns;
138
134
  if (checkpointNs) {
139
135
  getSubgraphsSeenSet().delete(checkpointNs);
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findSubgraphPregel = void 0;
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ function isRunnableSequence(x) {
6
+ return "steps" in x && Array.isArray(x.steps);
7
+ }
8
+ function isPregelLike(
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ x
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ ) {
13
+ return ("inputChannels" in x &&
14
+ x.inputChannels !== undefined &&
15
+ "outputChannels" &&
16
+ x.outputChannels !== undefined);
17
+ }
18
+ function findSubgraphPregel(candidate
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ ) {
21
+ const candidates = [candidate];
22
+ for (const candidate of candidates) {
23
+ if (isPregelLike(candidate)) {
24
+ return candidate;
25
+ }
26
+ else if (isRunnableSequence(candidate)) {
27
+ candidates.push(...candidate.steps);
28
+ }
29
+ }
30
+ return undefined;
31
+ }
32
+ exports.findSubgraphPregel = findSubgraphPregel;
@@ -0,0 +1,3 @@
1
+ import { Runnable } from "@langchain/core/runnables";
2
+ import type { PregelInterface } from "../types.js";
3
+ export declare function findSubgraphPregel(candidate: Runnable): PregelInterface<any, any> | undefined;
@@ -0,0 +1,28 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ function isRunnableSequence(x) {
3
+ return "steps" in x && Array.isArray(x.steps);
4
+ }
5
+ function isPregelLike(
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ x
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ ) {
10
+ return ("inputChannels" in x &&
11
+ x.inputChannels !== undefined &&
12
+ "outputChannels" &&
13
+ x.outputChannels !== undefined);
14
+ }
15
+ export function findSubgraphPregel(candidate
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ ) {
18
+ const candidates = [candidate];
19
+ for (const candidate of candidates) {
20
+ if (isPregelLike(candidate)) {
21
+ return candidate;
22
+ }
23
+ else if (isRunnableSequence(candidate)) {
24
+ candidates.push(...candidate.steps);
25
+ }
26
+ }
27
+ return undefined;
28
+ }
package/dist/web.cjs CHANGED
@@ -14,12 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.MessagesAnnotation = exports.InMemoryStore = exports.AsyncBatchedStore = exports.BaseStore = exports.BaseCheckpointSaver = exports.emptyCheckpoint = exports.copyCheckpoint = exports.MemorySaver = exports.Send = exports.BinaryOperatorAggregate = exports.BaseChannel = exports.Annotation = exports.messagesStateReducer = exports.MessageGraph = exports.StateGraph = exports.START = exports.Graph = exports.END = void 0;
17
+ exports.MessagesAnnotation = exports.InMemoryStore = exports.AsyncBatchedStore = exports.BaseStore = exports.BaseCheckpointSaver = exports.emptyCheckpoint = exports.copyCheckpoint = exports.MemorySaver = exports.Send = exports.BinaryOperatorAggregate = exports.BaseChannel = exports.Annotation = exports.messagesStateReducer = exports.MessageGraph = exports.CompiledStateGraph = exports.StateGraph = exports.START = exports.Graph = exports.END = void 0;
18
18
  var index_js_1 = require("./graph/index.cjs");
19
19
  Object.defineProperty(exports, "END", { enumerable: true, get: function () { return index_js_1.END; } });
20
20
  Object.defineProperty(exports, "Graph", { enumerable: true, get: function () { return index_js_1.Graph; } });
21
21
  Object.defineProperty(exports, "START", { enumerable: true, get: function () { return index_js_1.START; } });
22
22
  Object.defineProperty(exports, "StateGraph", { enumerable: true, get: function () { return index_js_1.StateGraph; } });
23
+ Object.defineProperty(exports, "CompiledStateGraph", { enumerable: true, get: function () { return index_js_1.CompiledStateGraph; } });
23
24
  Object.defineProperty(exports, "MessageGraph", { enumerable: true, get: function () { return index_js_1.MessageGraph; } });
24
25
  Object.defineProperty(exports, "messagesStateReducer", { enumerable: true, get: function () { return index_js_1.messagesStateReducer; } });
25
26
  Object.defineProperty(exports, "Annotation", { enumerable: true, get: function () { return index_js_1.Annotation; } });
package/dist/web.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { END, Graph, type StateGraphArgs, START, StateGraph, type CompiledStateGraph, MessageGraph, messagesStateReducer, type Messages, Annotation, type StateType, type UpdateType, type NodeType, type StateDefinition, type SingleReducer, type CompiledGraph, } from "./graph/index.js";
1
+ export { END, Graph, type StateGraphArgs, START, StateGraph, CompiledStateGraph, MessageGraph, messagesStateReducer, type Messages, Annotation, type StateType, type UpdateType, type NodeType, type StateDefinition, type SingleReducer, type CompiledGraph, } from "./graph/index.js";
2
2
  export type { StateSnapshot } from "./pregel/types.js";
3
3
  export * from "./errors.js";
4
4
  export { BaseChannel, type BinaryOperator, BinaryOperatorAggregate, type AnyValue, type WaitForNames, type DynamicBarrierValue, type LastValue, type NamedBarrierValue, type Topic, } from "./channels/index.js";
package/dist/web.js CHANGED
@@ -1,4 +1,4 @@
1
- export { END, Graph, START, StateGraph, MessageGraph, messagesStateReducer, Annotation, } from "./graph/index.js";
1
+ export { END, Graph, START, StateGraph, CompiledStateGraph, MessageGraph, messagesStateReducer, Annotation, } from "./graph/index.js";
2
2
  export * from "./errors.js";
3
3
  export { BaseChannel, BinaryOperatorAggregate, } from "./channels/index.js";
4
4
  export { Send } from "./constants.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {
@@ -43,7 +43,7 @@
43
43
  "@jest/globals": "^29.5.0",
44
44
  "@langchain/anthropic": "^0.3.0",
45
45
  "@langchain/community": "^0.3.0",
46
- "@langchain/core": "^0.3.6",
46
+ "@langchain/core": "^0.3.10",
47
47
  "@langchain/langgraph-checkpoint-postgres": "workspace:*",
48
48
  "@langchain/langgraph-checkpoint-sqlite": "workspace:*",
49
49
  "@langchain/openai": "^0.3.0",