@langchain/langgraph 0.2.34 → 0.2.36

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.
@@ -425,7 +425,7 @@ class CompiledStateGraph extends graph_js_1.CompiledGraph {
425
425
  }
426
426
  else {
427
427
  const typeofInput = Array.isArray(input) ? "array" : typeof input;
428
- throw new errors_js_1.InvalidUpdateError(`Expected node "${nodeKey.toString()}" to return an object, received ${typeofInput}`, {
428
+ throw new errors_js_1.InvalidUpdateError(`Expected node "${nodeKey.toString()}" to return an object or an array containing at least one Command object, received ${typeofInput}`, {
429
429
  lc_error_code: "INVALID_GRAPH_NODE_RETURN_VALUE",
430
430
  });
431
431
  }
@@ -583,13 +583,29 @@ function _controlBranch(value) {
583
583
  if ((0, constants_js_1._isSend)(value)) {
584
584
  return [value];
585
585
  }
586
- if (!(0, constants_js_1.isCommand)(value)) {
586
+ const commands = [];
587
+ if ((0, constants_js_1.isCommand)(value)) {
588
+ commands.push(value);
589
+ }
590
+ else if (Array.isArray(value) && value.every(constants_js_1.isCommand)) {
591
+ commands.push(...value);
592
+ }
593
+ else {
587
594
  return [];
588
595
  }
589
- if (value.graph === constants_js_1.Command.PARENT) {
590
- throw new errors_js_1.ParentCommand(value);
596
+ const destinations = [];
597
+ for (const command of commands) {
598
+ if (command.graph === constants_js_1.Command.PARENT) {
599
+ throw new errors_js_1.ParentCommand(command);
600
+ }
601
+ if ((0, constants_js_1._isSend)(command.goto) || typeof command.goto === "string") {
602
+ destinations.push(command.goto);
603
+ }
604
+ else {
605
+ destinations.push(...command.goto);
606
+ }
591
607
  }
592
- return Array.isArray(value.goto) ? value.goto : [value.goto];
608
+ return destinations;
593
609
  }
594
610
  function _getControlBranch() {
595
611
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -421,7 +421,7 @@ export class CompiledStateGraph extends CompiledGraph {
421
421
  }
422
422
  else {
423
423
  const typeofInput = Array.isArray(input) ? "array" : typeof input;
424
- throw new InvalidUpdateError(`Expected node "${nodeKey.toString()}" to return an object, received ${typeofInput}`, {
424
+ throw new InvalidUpdateError(`Expected node "${nodeKey.toString()}" to return an object or an array containing at least one Command object, received ${typeofInput}`, {
425
425
  lc_error_code: "INVALID_GRAPH_NODE_RETURN_VALUE",
426
426
  });
427
427
  }
@@ -578,13 +578,29 @@ function _controlBranch(value) {
578
578
  if (_isSend(value)) {
579
579
  return [value];
580
580
  }
581
- if (!isCommand(value)) {
581
+ const commands = [];
582
+ if (isCommand(value)) {
583
+ commands.push(value);
584
+ }
585
+ else if (Array.isArray(value) && value.every(isCommand)) {
586
+ commands.push(...value);
587
+ }
588
+ else {
582
589
  return [];
583
590
  }
584
- if (value.graph === Command.PARENT) {
585
- throw new ParentCommand(value);
591
+ const destinations = [];
592
+ for (const command of commands) {
593
+ if (command.graph === Command.PARENT) {
594
+ throw new ParentCommand(command);
595
+ }
596
+ if (_isSend(command.goto) || typeof command.goto === "string") {
597
+ destinations.push(command.goto);
598
+ }
599
+ else {
600
+ destinations.push(...command.goto);
601
+ }
586
602
  }
587
- return Array.isArray(value.goto) ? value.goto : [value.goto];
603
+ return destinations;
588
604
  }
589
605
  function _getControlBranch() {
590
606
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -16,6 +16,8 @@ const CONFIG_KEYS = [
16
16
  "streamMode",
17
17
  "store",
18
18
  "writer",
19
+ "interruptBefore",
20
+ "interruptAfter",
19
21
  ];
20
22
  const DEFAULT_RECURSION_LIMIT = 25;
21
23
  function ensureLangGraphConfig(...configs) {
@@ -13,6 +13,8 @@ const CONFIG_KEYS = [
13
13
  "streamMode",
14
14
  "store",
15
15
  "writer",
16
+ "interruptBefore",
17
+ "interruptAfter",
16
18
  ];
17
19
  const DEFAULT_RECURSION_LIMIT = 25;
18
20
  export function ensureLangGraphConfig(...configs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "0.2.34",
3
+ "version": "0.2.36",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {
@@ -72,7 +72,7 @@
72
72
  "pg": "^8.13.0",
73
73
  "prettier": "^2.8.3",
74
74
  "release-it": "^17.6.0",
75
- "rollup": "^4.22.4",
75
+ "rollup": "^4.24.1",
76
76
  "ts-jest": "^29.1.0",
77
77
  "tsx": "^4.7.0",
78
78
  "typescript": "^4.9.5 || ^5.4.5",