@langchain/langgraph 1.1.5 → 1.2.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.
Files changed (128) hide show
  1. package/dist/channels/binop.cjs +13 -2
  2. package/dist/channels/binop.cjs.map +1 -1
  3. package/dist/channels/binop.d.cts +4 -2
  4. package/dist/channels/binop.d.cts.map +1 -1
  5. package/dist/channels/binop.d.ts +4 -2
  6. package/dist/channels/binop.d.ts.map +1 -1
  7. package/dist/channels/binop.js +14 -3
  8. package/dist/channels/binop.js.map +1 -1
  9. package/dist/constants.cjs +78 -0
  10. package/dist/constants.cjs.map +1 -1
  11. package/dist/constants.d.cts +49 -1
  12. package/dist/constants.d.cts.map +1 -1
  13. package/dist/constants.d.ts +49 -1
  14. package/dist/constants.d.ts.map +1 -1
  15. package/dist/constants.js +76 -1
  16. package/dist/constants.js.map +1 -1
  17. package/dist/func/index.cjs +1 -1
  18. package/dist/func/index.d.cts +1 -1
  19. package/dist/func/index.d.ts +1 -1
  20. package/dist/func/index.js +1 -1
  21. package/dist/graph/annotation.cjs.map +1 -1
  22. package/dist/graph/annotation.d.cts +3 -2
  23. package/dist/graph/annotation.d.cts.map +1 -1
  24. package/dist/graph/annotation.d.ts +3 -2
  25. package/dist/graph/annotation.d.ts.map +1 -1
  26. package/dist/graph/annotation.js.map +1 -1
  27. package/dist/graph/graph.cjs +3 -6
  28. package/dist/graph/graph.cjs.map +1 -1
  29. package/dist/graph/graph.d.cts +2 -2
  30. package/dist/graph/graph.d.cts.map +1 -1
  31. package/dist/graph/graph.d.ts +2 -2
  32. package/dist/graph/graph.d.ts.map +1 -1
  33. package/dist/graph/graph.js +3 -6
  34. package/dist/graph/graph.js.map +1 -1
  35. package/dist/graph/index.cjs +1 -1
  36. package/dist/graph/index.d.ts +1 -1
  37. package/dist/graph/index.js +1 -1
  38. package/dist/graph/messages_annotation.d.cts +3 -2
  39. package/dist/graph/messages_annotation.d.cts.map +1 -1
  40. package/dist/graph/messages_annotation.d.ts +3 -2
  41. package/dist/graph/messages_annotation.d.ts.map +1 -1
  42. package/dist/graph/state.cjs +1 -1
  43. package/dist/graph/state.d.cts +1 -1
  44. package/dist/graph/state.d.ts +1 -1
  45. package/dist/graph/state.js +1 -1
  46. package/dist/graph/types.cjs +1 -1
  47. package/dist/graph/types.d.cts +1 -1
  48. package/dist/graph/types.d.ts +1 -1
  49. package/dist/graph/types.js +1 -1
  50. package/dist/graph/zod/meta.cjs.map +1 -1
  51. package/dist/graph/zod/meta.d.cts +3 -2
  52. package/dist/graph/zod/meta.d.cts.map +1 -1
  53. package/dist/graph/zod/meta.d.ts +3 -2
  54. package/dist/graph/zod/meta.d.ts.map +1 -1
  55. package/dist/graph/zod/meta.js.map +1 -1
  56. package/dist/index.cjs +2 -1
  57. package/dist/index.d.cts +2 -2
  58. package/dist/index.d.ts +2 -2
  59. package/dist/index.js +2 -2
  60. package/dist/interrupt.cjs +1 -1
  61. package/dist/interrupt.js +1 -1
  62. package/dist/prebuilt/react_agent_executor.cjs +1 -1
  63. package/dist/prebuilt/react_agent_executor.d.cts +5 -5
  64. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
  65. package/dist/prebuilt/react_agent_executor.d.ts +5 -5
  66. package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
  67. package/dist/prebuilt/react_agent_executor.js +1 -1
  68. package/dist/prebuilt/tool_node.cjs +1 -1
  69. package/dist/prebuilt/tool_node.d.cts +1 -1
  70. package/dist/prebuilt/tool_node.d.ts +1 -1
  71. package/dist/prebuilt/tool_node.js +1 -1
  72. package/dist/pregel/algo.cjs +1 -1
  73. package/dist/pregel/algo.d.ts +1 -1
  74. package/dist/pregel/algo.js +1 -1
  75. package/dist/pregel/index.cjs +13 -1
  76. package/dist/pregel/index.cjs.map +1 -1
  77. package/dist/pregel/index.d.cts +2 -1
  78. package/dist/pregel/index.d.cts.map +1 -1
  79. package/dist/pregel/index.d.ts +2 -1
  80. package/dist/pregel/index.d.ts.map +1 -1
  81. package/dist/pregel/index.js +14 -2
  82. package/dist/pregel/index.js.map +1 -1
  83. package/dist/pregel/io.cjs +1 -1
  84. package/dist/pregel/io.js +1 -1
  85. package/dist/pregel/loop.cjs +1 -1
  86. package/dist/pregel/loop.js +1 -1
  87. package/dist/pregel/read.cjs +4 -1
  88. package/dist/pregel/read.cjs.map +1 -1
  89. package/dist/pregel/read.d.cts.map +1 -1
  90. package/dist/pregel/read.d.ts.map +1 -1
  91. package/dist/pregel/read.js +4 -1
  92. package/dist/pregel/read.js.map +1 -1
  93. package/dist/pregel/remote.cjs +1 -1
  94. package/dist/pregel/remote.js +1 -1
  95. package/dist/pregel/retry.cjs +1 -1
  96. package/dist/pregel/retry.js +1 -1
  97. package/dist/pregel/runner.cjs +1 -1
  98. package/dist/pregel/runner.js +1 -1
  99. package/dist/pregel/stream.cjs +81 -0
  100. package/dist/pregel/stream.cjs.map +1 -1
  101. package/dist/pregel/stream.d.ts +2 -1
  102. package/dist/pregel/stream.js +81 -1
  103. package/dist/pregel/stream.js.map +1 -1
  104. package/dist/pregel/types.cjs.map +1 -1
  105. package/dist/pregel/types.d.cts +27 -2
  106. package/dist/pregel/types.d.cts.map +1 -1
  107. package/dist/pregel/types.d.ts +27 -2
  108. package/dist/pregel/types.d.ts.map +1 -1
  109. package/dist/pregel/types.js.map +1 -1
  110. package/dist/pregel/write.cjs +2 -1
  111. package/dist/pregel/write.cjs.map +1 -1
  112. package/dist/pregel/write.d.cts +1 -1
  113. package/dist/pregel/write.d.cts.map +1 -1
  114. package/dist/pregel/write.d.ts +1 -1
  115. package/dist/pregel/write.d.ts.map +1 -1
  116. package/dist/pregel/write.js +2 -1
  117. package/dist/pregel/write.js.map +1 -1
  118. package/dist/state/schema.cjs.map +1 -1
  119. package/dist/state/schema.d.cts +3 -2
  120. package/dist/state/schema.d.cts.map +1 -1
  121. package/dist/state/schema.d.ts +3 -2
  122. package/dist/state/schema.d.ts.map +1 -1
  123. package/dist/state/schema.js.map +1 -1
  124. package/dist/web.cjs +2 -1
  125. package/dist/web.d.cts +2 -2
  126. package/dist/web.d.ts +2 -2
  127. package/dist/web.js +2 -2
  128. package/package.json +4 -4
@@ -1,3 +1,4 @@
1
+ const require_constants = require('../constants.cjs');
1
2
  const require_errors = require('../errors.cjs');
2
3
  const require_base = require('./base.cjs');
3
4
 
@@ -28,10 +29,20 @@ var BinaryOperatorAggregate = class BinaryOperatorAggregate extends require_base
28
29
  let newValues = values;
29
30
  if (!newValues.length) return false;
30
31
  if (this.value === void 0) {
31
- [this.value] = newValues;
32
+ const first = newValues[0];
33
+ const [isOverwrite, overwriteVal] = require_constants._getOverwriteValue(first);
34
+ if (isOverwrite) this.value = overwriteVal;
35
+ else this.value = first;
32
36
  newValues = newValues.slice(1);
33
37
  }
34
- for (const value of newValues) if (this.value !== void 0) this.value = this.operator(this.value, value);
38
+ let seenOverwrite = false;
39
+ for (const incoming of newValues) if (require_constants._isOverwriteValue(incoming)) {
40
+ if (seenOverwrite) throw new require_errors.InvalidUpdateError("Can receive only one Overwrite value per step.");
41
+ const [, val] = require_constants._getOverwriteValue(incoming);
42
+ this.value = val;
43
+ seenOverwrite = true;
44
+ continue;
45
+ } else if (!seenOverwrite && this.value !== void 0) this.value = this.operator(this.value, incoming);
35
46
  return true;
36
47
  }
37
48
  get() {
@@ -1 +1 @@
1
- {"version":3,"file":"binop.cjs","names":["BaseChannel","EmptyChannelError"],"sources":["../../src/channels/binop.ts"],"sourcesContent":["import { EmptyChannelError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\nexport type BinaryOperator<ValueType, UpdateType> = (\n a: ValueType,\n b: UpdateType\n) => ValueType;\n\nconst isBinaryOperatorAggregate = (\n value: BaseChannel\n): value is BinaryOperatorAggregate<unknown, unknown> => {\n return value != null && value.lc_graph_name === \"BinaryOperatorAggregate\";\n};\n\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport class BinaryOperatorAggregate<\n ValueType,\n UpdateType = ValueType\n> extends BaseChannel<ValueType, UpdateType, ValueType> {\n lc_graph_name = \"BinaryOperatorAggregate\";\n\n value: ValueType | undefined;\n\n operator: BinaryOperator<ValueType, UpdateType>;\n\n initialValueFactory?: () => ValueType;\n\n constructor(\n operator: BinaryOperator<ValueType, UpdateType>,\n initialValueFactory?: () => ValueType\n ) {\n super();\n\n this.operator = operator;\n this.initialValueFactory = initialValueFactory;\n this.value = initialValueFactory?.();\n }\n\n public fromCheckpoint(checkpoint?: ValueType) {\n const empty = new BinaryOperatorAggregate(\n this.operator,\n this.initialValueFactory\n );\n if (typeof checkpoint !== \"undefined\") {\n empty.value = checkpoint;\n }\n return empty as this;\n }\n\n public update(values: UpdateType[]): boolean {\n let newValues = values;\n if (!newValues.length) return false;\n\n if (this.value === undefined) {\n [this.value as UpdateType] = newValues;\n newValues = newValues.slice(1);\n }\n\n for (const value of newValues) {\n if (this.value !== undefined) {\n this.value = this.operator(this.value, value);\n }\n }\n return true;\n }\n\n public get(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n public checkpoint(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n isAvailable(): boolean {\n return this.value !== undefined;\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Two BinaryOperatorAggregate channels are equal if they have the same operator function.\n * This follows the Python implementation which compares operator references.\n */\n equals(other: BaseChannel): boolean {\n if (this === other) return true;\n if (!isBinaryOperatorAggregate(other)) return false;\n return this.operator === other.operator;\n }\n}\n"],"mappings":";;;;AAQA,MAAM,6BACJ,UACuD;AACvD,QAAO,SAAS,QAAQ,MAAM,kBAAkB;;;;;AAMlD,IAAa,0BAAb,MAAa,gCAGHA,yBAA8C;CACtD,gBAAgB;CAEhB;CAEA;CAEA;CAEA,YACE,UACA,qBACA;AACA,SAAO;AAEP,OAAK,WAAW;AAChB,OAAK,sBAAsB;AAC3B,OAAK,QAAQ,uBAAuB;;CAGtC,AAAO,eAAe,YAAwB;EAC5C,MAAM,QAAQ,IAAI,wBAChB,KAAK,UACL,KAAK,oBACN;AACD,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ;AAEhB,SAAO;;CAGT,AAAO,OAAO,QAA+B;EAC3C,IAAI,YAAY;AAChB,MAAI,CAAC,UAAU,OAAQ,QAAO;AAE9B,MAAI,KAAK,UAAU,QAAW;AAC5B,IAAC,KAAK,SAAuB;AAC7B,eAAY,UAAU,MAAM,EAAE;;AAGhC,OAAK,MAAM,SAAS,UAClB,KAAI,KAAK,UAAU,OACjB,MAAK,QAAQ,KAAK,SAAS,KAAK,OAAO,MAAM;AAGjD,SAAO;;CAGT,AAAO,MAAiB;AACtB,MAAI,KAAK,UAAU,OACjB,OAAM,IAAIC,kCAAmB;AAE/B,SAAO,KAAK;;CAGd,AAAO,aAAwB;AAC7B,MAAI,KAAK,UAAU,OACjB,OAAM,IAAIA,kCAAmB;AAE/B,SAAO,KAAK;;CAGd,cAAuB;AACrB,SAAO,KAAK,UAAU;;;;;;;CAQxB,OAAO,OAA6B;AAClC,MAAI,SAAS,MAAO,QAAO;AAC3B,MAAI,CAAC,0BAA0B,MAAM,CAAE,QAAO;AAC9C,SAAO,KAAK,aAAa,MAAM"}
1
+ {"version":3,"file":"binop.cjs","names":["BaseChannel","_getOverwriteValue","_isOverwriteValue","InvalidUpdateError","EmptyChannelError"],"sources":["../../src/channels/binop.ts"],"sourcesContent":["import {\n _getOverwriteValue,\n _isOverwriteValue,\n type OverwriteValue,\n} from \"../constants.js\";\nimport { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\ntype OverwriteOrValue<ValueType, UpdateType> =\n | OverwriteValue<ValueType>\n | UpdateType;\n\nexport type BinaryOperator<ValueType, UpdateType> = (\n a: ValueType,\n b: UpdateType\n) => ValueType;\n\nconst isBinaryOperatorAggregate = (\n value: BaseChannel\n): value is BinaryOperatorAggregate<unknown, unknown> => {\n return value != null && value.lc_graph_name === \"BinaryOperatorAggregate\";\n};\n\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport class BinaryOperatorAggregate<\n ValueType,\n UpdateType = ValueType\n> extends BaseChannel<\n ValueType,\n OverwriteOrValue<ValueType, UpdateType>,\n ValueType\n> {\n lc_graph_name = \"BinaryOperatorAggregate\";\n\n value: ValueType | undefined;\n\n operator: BinaryOperator<ValueType, UpdateType>;\n\n initialValueFactory?: () => ValueType;\n\n constructor(\n operator: BinaryOperator<ValueType, UpdateType>,\n initialValueFactory?: () => ValueType\n ) {\n super();\n\n this.operator = operator;\n this.initialValueFactory = initialValueFactory;\n this.value = initialValueFactory?.();\n }\n\n public fromCheckpoint(checkpoint?: ValueType) {\n const empty = new BinaryOperatorAggregate(\n this.operator,\n this.initialValueFactory\n );\n if (typeof checkpoint !== \"undefined\") {\n empty.value = checkpoint;\n }\n return empty as this;\n }\n\n public update(values: OverwriteOrValue<ValueType, UpdateType>[]): boolean {\n let newValues = values;\n if (!newValues.length) return false;\n\n if (this.value === undefined) {\n const first = newValues[0];\n const [isOverwrite, overwriteVal] = _getOverwriteValue<ValueType>(first);\n if (isOverwrite) {\n this.value = overwriteVal;\n } else {\n this.value = first as ValueType;\n }\n newValues = newValues.slice(1);\n }\n\n let seenOverwrite = false;\n for (const incoming of newValues) {\n if (_isOverwriteValue<ValueType>(incoming)) {\n if (seenOverwrite) {\n throw new InvalidUpdateError(\n \"Can receive only one Overwrite value per step.\"\n );\n }\n const [, val] = _getOverwriteValue<ValueType>(incoming);\n this.value = val;\n seenOverwrite = true;\n continue;\n } else if (!seenOverwrite && this.value !== undefined) {\n this.value = this.operator(this.value, incoming);\n }\n }\n return true;\n }\n\n public get(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n public checkpoint(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n isAvailable(): boolean {\n return this.value !== undefined;\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Two BinaryOperatorAggregate channels are equal if they have the same operator function.\n * This follows the Python implementation which compares operator references.\n */\n equals(other: BaseChannel): boolean {\n if (this === other) return true;\n if (!isBinaryOperatorAggregate(other)) return false;\n return this.operator === other.operator;\n }\n}\n"],"mappings":";;;;;AAiBA,MAAM,6BACJ,UACuD;AACvD,QAAO,SAAS,QAAQ,MAAM,kBAAkB;;;;;AAMlD,IAAa,0BAAb,MAAa,gCAGHA,yBAIR;CACA,gBAAgB;CAEhB;CAEA;CAEA;CAEA,YACE,UACA,qBACA;AACA,SAAO;AAEP,OAAK,WAAW;AAChB,OAAK,sBAAsB;AAC3B,OAAK,QAAQ,uBAAuB;;CAGtC,AAAO,eAAe,YAAwB;EAC5C,MAAM,QAAQ,IAAI,wBAChB,KAAK,UACL,KAAK,oBACN;AACD,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ;AAEhB,SAAO;;CAGT,AAAO,OAAO,QAA4D;EACxE,IAAI,YAAY;AAChB,MAAI,CAAC,UAAU,OAAQ,QAAO;AAE9B,MAAI,KAAK,UAAU,QAAW;GAC5B,MAAM,QAAQ,UAAU;GACxB,MAAM,CAAC,aAAa,gBAAgBC,qCAA8B,MAAM;AACxE,OAAI,YACF,MAAK,QAAQ;OAEb,MAAK,QAAQ;AAEf,eAAY,UAAU,MAAM,EAAE;;EAGhC,IAAI,gBAAgB;AACpB,OAAK,MAAM,YAAY,UACrB,KAAIC,oCAA6B,SAAS,EAAE;AAC1C,OAAI,cACF,OAAM,IAAIC,kCACR,iDACD;GAEH,MAAM,GAAG,OAAOF,qCAA8B,SAAS;AACvD,QAAK,QAAQ;AACb,mBAAgB;AAChB;aACS,CAAC,iBAAiB,KAAK,UAAU,OAC1C,MAAK,QAAQ,KAAK,SAAS,KAAK,OAAO,SAAS;AAGpD,SAAO;;CAGT,AAAO,MAAiB;AACtB,MAAI,KAAK,UAAU,OACjB,OAAM,IAAIG,kCAAmB;AAE/B,SAAO,KAAK;;CAGd,AAAO,aAAwB;AAC7B,MAAI,KAAK,UAAU,OACjB,OAAM,IAAIA,kCAAmB;AAE/B,SAAO,KAAK;;CAGd,cAAuB;AACrB,SAAO,KAAK,UAAU;;;;;;;CAQxB,OAAO,OAA6B;AAClC,MAAI,SAAS,MAAO,QAAO;AAC3B,MAAI,CAAC,0BAA0B,MAAM,CAAE,QAAO;AAC9C,SAAO,KAAK,aAAa,MAAM"}
@@ -1,18 +1,20 @@
1
1
  import { BaseChannel } from "./base.cjs";
2
+ import { OverwriteValue } from "../constants.cjs";
2
3
 
3
4
  //#region src/channels/binop.d.ts
5
+ type OverwriteOrValue<ValueType, UpdateType> = OverwriteValue<ValueType> | UpdateType;
4
6
  type BinaryOperator<ValueType, UpdateType> = (a: ValueType, b: UpdateType) => ValueType;
5
7
  /**
6
8
  * Stores the result of applying a binary operator to the current value and each new value.
7
9
  */
8
- declare class BinaryOperatorAggregate<ValueType, UpdateType = ValueType> extends BaseChannel<ValueType, UpdateType, ValueType> {
10
+ declare class BinaryOperatorAggregate<ValueType, UpdateType = ValueType> extends BaseChannel<ValueType, OverwriteOrValue<ValueType, UpdateType>, ValueType> {
9
11
  lc_graph_name: string;
10
12
  value: ValueType | undefined;
11
13
  operator: BinaryOperator<ValueType, UpdateType>;
12
14
  initialValueFactory?: () => ValueType;
13
15
  constructor(operator: BinaryOperator<ValueType, UpdateType>, initialValueFactory?: () => ValueType);
14
16
  fromCheckpoint(checkpoint?: ValueType): this;
15
- update(values: UpdateType[]): boolean;
17
+ update(values: OverwriteOrValue<ValueType, UpdateType>[]): boolean;
16
18
  get(): ValueType;
17
19
  checkpoint(): ValueType;
18
20
  isAvailable(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"binop.d.cts","names":[],"sources":["../../src/channels/binop.ts"],"mappings":";;;KAGY,cAAA,2BACV,CAAA,EAAG,SAAA,EACH,CAAA,EAAG,UAAA,KACA,SAAA;;AAHL;;cAca,uBAAA,yBAEE,SAAA,UACL,WAAA,CAAY,SAAA,EAAW,UAA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import { OverwriteValue } from "../constants.js";
2
3
 
3
4
  //#region src/channels/binop.d.ts
5
+ type OverwriteOrValue<ValueType, UpdateType> = OverwriteValue<ValueType> | UpdateType;
4
6
  type BinaryOperator<ValueType, UpdateType> = (a: ValueType, b: UpdateType) => ValueType;
5
7
  /**
6
8
  * Stores the result of applying a binary operator to the current value and each new value.
7
9
  */
8
- declare class BinaryOperatorAggregate<ValueType, UpdateType = ValueType> extends BaseChannel<ValueType, UpdateType, ValueType> {
10
+ declare class BinaryOperatorAggregate<ValueType, UpdateType = ValueType> extends BaseChannel<ValueType, OverwriteOrValue<ValueType, UpdateType>, ValueType> {
9
11
  lc_graph_name: string;
10
12
  value: ValueType | undefined;
11
13
  operator: BinaryOperator<ValueType, UpdateType>;
12
14
  initialValueFactory?: () => ValueType;
13
15
  constructor(operator: BinaryOperator<ValueType, UpdateType>, initialValueFactory?: () => ValueType);
14
16
  fromCheckpoint(checkpoint?: ValueType): this;
15
- update(values: UpdateType[]): boolean;
17
+ update(values: OverwriteOrValue<ValueType, UpdateType>[]): boolean;
16
18
  get(): ValueType;
17
19
  checkpoint(): ValueType;
18
20
  isAvailable(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"binop.d.ts","names":[],"sources":["../../src/channels/binop.ts"],"mappings":";;;KAGY,cAAA,2BACV,CAAA,EAAG,SAAA,EACH,CAAA,EAAG,UAAA,KACA,SAAA;;AAHL;;cAca,uBAAA,yBAEE,SAAA,UACL,WAAA,CAAY,SAAA,EAAW,UAAA,EAAY,SAAA;EAC3C,aAAA;EAEA,KAAA,EAAO,SAAA;EAEP,QAAA,EAAU,cAAA,CAAe,SAAA,EAAW,UAAA;EAEpC,mBAAA,SAA4B,SAAA;EAE5B,WAAA,CACE,QAAA,EAAU,cAAA,CAAe,SAAA,EAAW,UAAA,GACpC,mBAAA,SAA4B,SAAA;EASvB,cAAA,CAAe,UAAA,GAAa,SAAA;EAW5B,MAAA,CAAO,MAAA,EAAQ,UAAA;EAiBf,GAAA,CAAA,GAAO,SAAA;EAOP,UAAA,CAAA,GAAc,SAAA;EAOrB,WAAA,CAAA;EA7EA;;;;AAYF;EA0EE,MAAA,CAAO,KAAA,EAAO,WAAA;AAAA"}
1
+ {"version":3,"file":"binop.d.ts","names":[],"sources":["../../src/channels/binop.ts"],"mappings":";;;;KAQK,gBAAA,0BACD,cAAA,CAAe,SAAA,IACf,UAAA;AAAA,KAEQ,cAAA,2BACV,CAAA,EAAG,SAAA,EACH,CAAA,EAAG,UAAA,KACA,SAAA;AATmC;;;AAAA,cAoB3B,uBAAA,yBAEE,SAAA,UACL,WAAA,CACR,SAAA,EACA,gBAAA,CAAiB,SAAA,EAAW,UAAA,GAC5B,SAAA;EAEA,aAAA;EAEA,KAAA,EAAO,SAAA;EAEP,QAAA,EAAU,cAAA,CAAe,SAAA,EAAW,UAAA;EAEpC,mBAAA,SAA4B,SAAA;EAE5B,WAAA,CACE,QAAA,EAAU,cAAA,CAAe,SAAA,EAAW,UAAA,GACpC,mBAAA,SAA4B,SAAA;EASvB,cAAA,CAAe,UAAA,GAAa,SAAA;EAW5B,MAAA,CAAO,MAAA,EAAQ,gBAAA,CAAiB,SAAA,EAAW,UAAA;EAkC3C,GAAA,CAAA,GAAO,SAAA;EAOP,UAAA,CAAA,GAAc,SAAA;EAOrB,WAAA,CAAA;EAtGY;AAEd;;;;EA6GE,MAAA,CAAO,KAAA,EAAO,WAAA;AAAA"}
@@ -1,4 +1,5 @@
1
- import { EmptyChannelError } from "../errors.js";
1
+ import { _getOverwriteValue, _isOverwriteValue } from "../constants.js";
2
+ import { EmptyChannelError, InvalidUpdateError } from "../errors.js";
2
3
  import { BaseChannel } from "./base.js";
3
4
 
4
5
  //#region src/channels/binop.ts
@@ -28,10 +29,20 @@ var BinaryOperatorAggregate = class BinaryOperatorAggregate extends BaseChannel
28
29
  let newValues = values;
29
30
  if (!newValues.length) return false;
30
31
  if (this.value === void 0) {
31
- [this.value] = newValues;
32
+ const first = newValues[0];
33
+ const [isOverwrite, overwriteVal] = _getOverwriteValue(first);
34
+ if (isOverwrite) this.value = overwriteVal;
35
+ else this.value = first;
32
36
  newValues = newValues.slice(1);
33
37
  }
34
- for (const value of newValues) if (this.value !== void 0) this.value = this.operator(this.value, value);
38
+ let seenOverwrite = false;
39
+ for (const incoming of newValues) if (_isOverwriteValue(incoming)) {
40
+ if (seenOverwrite) throw new InvalidUpdateError("Can receive only one Overwrite value per step.");
41
+ const [, val] = _getOverwriteValue(incoming);
42
+ this.value = val;
43
+ seenOverwrite = true;
44
+ continue;
45
+ } else if (!seenOverwrite && this.value !== void 0) this.value = this.operator(this.value, incoming);
35
46
  return true;
36
47
  }
37
48
  get() {
@@ -1 +1 @@
1
- {"version":3,"file":"binop.js","names":[],"sources":["../../src/channels/binop.ts"],"sourcesContent":["import { EmptyChannelError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\nexport type BinaryOperator<ValueType, UpdateType> = (\n a: ValueType,\n b: UpdateType\n) => ValueType;\n\nconst isBinaryOperatorAggregate = (\n value: BaseChannel\n): value is BinaryOperatorAggregate<unknown, unknown> => {\n return value != null && value.lc_graph_name === \"BinaryOperatorAggregate\";\n};\n\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport class BinaryOperatorAggregate<\n ValueType,\n UpdateType = ValueType\n> extends BaseChannel<ValueType, UpdateType, ValueType> {\n lc_graph_name = \"BinaryOperatorAggregate\";\n\n value: ValueType | undefined;\n\n operator: BinaryOperator<ValueType, UpdateType>;\n\n initialValueFactory?: () => ValueType;\n\n constructor(\n operator: BinaryOperator<ValueType, UpdateType>,\n initialValueFactory?: () => ValueType\n ) {\n super();\n\n this.operator = operator;\n this.initialValueFactory = initialValueFactory;\n this.value = initialValueFactory?.();\n }\n\n public fromCheckpoint(checkpoint?: ValueType) {\n const empty = new BinaryOperatorAggregate(\n this.operator,\n this.initialValueFactory\n );\n if (typeof checkpoint !== \"undefined\") {\n empty.value = checkpoint;\n }\n return empty as this;\n }\n\n public update(values: UpdateType[]): boolean {\n let newValues = values;\n if (!newValues.length) return false;\n\n if (this.value === undefined) {\n [this.value as UpdateType] = newValues;\n newValues = newValues.slice(1);\n }\n\n for (const value of newValues) {\n if (this.value !== undefined) {\n this.value = this.operator(this.value, value);\n }\n }\n return true;\n }\n\n public get(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n public checkpoint(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n isAvailable(): boolean {\n return this.value !== undefined;\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Two BinaryOperatorAggregate channels are equal if they have the same operator function.\n * This follows the Python implementation which compares operator references.\n */\n equals(other: BaseChannel): boolean {\n if (this === other) return true;\n if (!isBinaryOperatorAggregate(other)) return false;\n return this.operator === other.operator;\n }\n}\n"],"mappings":";;;;AAQA,MAAM,6BACJ,UACuD;AACvD,QAAO,SAAS,QAAQ,MAAM,kBAAkB;;;;;AAMlD,IAAa,0BAAb,MAAa,gCAGH,YAA8C;CACtD,gBAAgB;CAEhB;CAEA;CAEA;CAEA,YACE,UACA,qBACA;AACA,SAAO;AAEP,OAAK,WAAW;AAChB,OAAK,sBAAsB;AAC3B,OAAK,QAAQ,uBAAuB;;CAGtC,AAAO,eAAe,YAAwB;EAC5C,MAAM,QAAQ,IAAI,wBAChB,KAAK,UACL,KAAK,oBACN;AACD,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ;AAEhB,SAAO;;CAGT,AAAO,OAAO,QAA+B;EAC3C,IAAI,YAAY;AAChB,MAAI,CAAC,UAAU,OAAQ,QAAO;AAE9B,MAAI,KAAK,UAAU,QAAW;AAC5B,IAAC,KAAK,SAAuB;AAC7B,eAAY,UAAU,MAAM,EAAE;;AAGhC,OAAK,MAAM,SAAS,UAClB,KAAI,KAAK,UAAU,OACjB,MAAK,QAAQ,KAAK,SAAS,KAAK,OAAO,MAAM;AAGjD,SAAO;;CAGT,AAAO,MAAiB;AACtB,MAAI,KAAK,UAAU,OACjB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK;;CAGd,AAAO,aAAwB;AAC7B,MAAI,KAAK,UAAU,OACjB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK;;CAGd,cAAuB;AACrB,SAAO,KAAK,UAAU;;;;;;;CAQxB,OAAO,OAA6B;AAClC,MAAI,SAAS,MAAO,QAAO;AAC3B,MAAI,CAAC,0BAA0B,MAAM,CAAE,QAAO;AAC9C,SAAO,KAAK,aAAa,MAAM"}
1
+ {"version":3,"file":"binop.js","names":[],"sources":["../../src/channels/binop.ts"],"sourcesContent":["import {\n _getOverwriteValue,\n _isOverwriteValue,\n type OverwriteValue,\n} from \"../constants.js\";\nimport { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\ntype OverwriteOrValue<ValueType, UpdateType> =\n | OverwriteValue<ValueType>\n | UpdateType;\n\nexport type BinaryOperator<ValueType, UpdateType> = (\n a: ValueType,\n b: UpdateType\n) => ValueType;\n\nconst isBinaryOperatorAggregate = (\n value: BaseChannel\n): value is BinaryOperatorAggregate<unknown, unknown> => {\n return value != null && value.lc_graph_name === \"BinaryOperatorAggregate\";\n};\n\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport class BinaryOperatorAggregate<\n ValueType,\n UpdateType = ValueType\n> extends BaseChannel<\n ValueType,\n OverwriteOrValue<ValueType, UpdateType>,\n ValueType\n> {\n lc_graph_name = \"BinaryOperatorAggregate\";\n\n value: ValueType | undefined;\n\n operator: BinaryOperator<ValueType, UpdateType>;\n\n initialValueFactory?: () => ValueType;\n\n constructor(\n operator: BinaryOperator<ValueType, UpdateType>,\n initialValueFactory?: () => ValueType\n ) {\n super();\n\n this.operator = operator;\n this.initialValueFactory = initialValueFactory;\n this.value = initialValueFactory?.();\n }\n\n public fromCheckpoint(checkpoint?: ValueType) {\n const empty = new BinaryOperatorAggregate(\n this.operator,\n this.initialValueFactory\n );\n if (typeof checkpoint !== \"undefined\") {\n empty.value = checkpoint;\n }\n return empty as this;\n }\n\n public update(values: OverwriteOrValue<ValueType, UpdateType>[]): boolean {\n let newValues = values;\n if (!newValues.length) return false;\n\n if (this.value === undefined) {\n const first = newValues[0];\n const [isOverwrite, overwriteVal] = _getOverwriteValue<ValueType>(first);\n if (isOverwrite) {\n this.value = overwriteVal;\n } else {\n this.value = first as ValueType;\n }\n newValues = newValues.slice(1);\n }\n\n let seenOverwrite = false;\n for (const incoming of newValues) {\n if (_isOverwriteValue<ValueType>(incoming)) {\n if (seenOverwrite) {\n throw new InvalidUpdateError(\n \"Can receive only one Overwrite value per step.\"\n );\n }\n const [, val] = _getOverwriteValue<ValueType>(incoming);\n this.value = val;\n seenOverwrite = true;\n continue;\n } else if (!seenOverwrite && this.value !== undefined) {\n this.value = this.operator(this.value, incoming);\n }\n }\n return true;\n }\n\n public get(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n public checkpoint(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n isAvailable(): boolean {\n return this.value !== undefined;\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Two BinaryOperatorAggregate channels are equal if they have the same operator function.\n * This follows the Python implementation which compares operator references.\n */\n equals(other: BaseChannel): boolean {\n if (this === other) return true;\n if (!isBinaryOperatorAggregate(other)) return false;\n return this.operator === other.operator;\n }\n}\n"],"mappings":";;;;;AAiBA,MAAM,6BACJ,UACuD;AACvD,QAAO,SAAS,QAAQ,MAAM,kBAAkB;;;;;AAMlD,IAAa,0BAAb,MAAa,gCAGH,YAIR;CACA,gBAAgB;CAEhB;CAEA;CAEA;CAEA,YACE,UACA,qBACA;AACA,SAAO;AAEP,OAAK,WAAW;AAChB,OAAK,sBAAsB;AAC3B,OAAK,QAAQ,uBAAuB;;CAGtC,AAAO,eAAe,YAAwB;EAC5C,MAAM,QAAQ,IAAI,wBAChB,KAAK,UACL,KAAK,oBACN;AACD,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ;AAEhB,SAAO;;CAGT,AAAO,OAAO,QAA4D;EACxE,IAAI,YAAY;AAChB,MAAI,CAAC,UAAU,OAAQ,QAAO;AAE9B,MAAI,KAAK,UAAU,QAAW;GAC5B,MAAM,QAAQ,UAAU;GACxB,MAAM,CAAC,aAAa,gBAAgB,mBAA8B,MAAM;AACxE,OAAI,YACF,MAAK,QAAQ;OAEb,MAAK,QAAQ;AAEf,eAAY,UAAU,MAAM,EAAE;;EAGhC,IAAI,gBAAgB;AACpB,OAAK,MAAM,YAAY,UACrB,KAAI,kBAA6B,SAAS,EAAE;AAC1C,OAAI,cACF,OAAM,IAAI,mBACR,iDACD;GAEH,MAAM,GAAG,OAAO,mBAA8B,SAAS;AACvD,QAAK,QAAQ;AACb,mBAAgB;AAChB;aACS,CAAC,iBAAiB,KAAK,UAAU,OAC1C,MAAK,QAAQ,KAAK,SAAS,KAAK,OAAO,SAAS;AAGpD,SAAO;;CAGT,AAAO,MAAiB;AACtB,MAAI,KAAK,UAAU,OACjB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK;;CAGd,AAAO,aAAwB;AAC7B,MAAI,KAAK,UAAU,OACjB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK;;CAGd,cAAuB;AACrB,SAAO,KAAK,UAAU;;;;;;;CAQxB,OAAO,OAA6B;AAClC,MAAI,SAAS,MAAO,QAAO;AAC3B,MAAI,CAAC,0BAA0B,MAAM,CAAE,QAAO;AAC9C,SAAO,KAAK,aAAa,MAAM"}
@@ -155,6 +155,81 @@ var Send = class {
155
155
  function _isSend(x) {
156
156
  return x instanceof Send;
157
157
  }
158
+ const OVERWRITE = "__overwrite__";
159
+ /**
160
+ * Bypass a reducer and write the wrapped value directly to a
161
+ * {@link BinaryOperatorAggregate} channel.
162
+ *
163
+ * Receiving multiple `Overwrite` values for the same channel in a single
164
+ * super-step will raise an {@link InvalidUpdateError}.
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * import { Annotation, StateGraph, Overwrite } from "@langchain/langgraph";
169
+ *
170
+ * const State = Annotation.Root({
171
+ * messages: Annotation<string[]>({
172
+ * reducer: (a, b) => a.concat(b),
173
+ * default: () => [],
174
+ * }),
175
+ * });
176
+ *
177
+ * const replaceMessages = (_state: typeof State.State) => {
178
+ * return { messages: new Overwrite(["replacement"]) };
179
+ * };
180
+ * ```
181
+ */
182
+ var Overwrite = class {
183
+ lg_name = "Overwrite";
184
+ [OVERWRITE];
185
+ constructor(value) {
186
+ this[OVERWRITE] = value;
187
+ }
188
+ get value() {
189
+ return this[OVERWRITE];
190
+ }
191
+ toJSON() {
192
+ return { [OVERWRITE]: this[OVERWRITE] };
193
+ }
194
+ static isInstance(value) {
195
+ if (!value || typeof value !== "object") return false;
196
+ if (OVERWRITE in value) return true;
197
+ if ("lg_name" in value && value.lg_name === "Overwrite") return true;
198
+ return false;
199
+ }
200
+ };
201
+ /**
202
+ * Helper function to detect and extract the value from an Overwrite wrapper,
203
+ * supporting both the Overwrite class instance and the serialized object format.
204
+ *
205
+ * Use to check if a provided value represents an Overwrite: returns the
206
+ * unwrapped value if so, or undefined otherwise.
207
+ *
208
+ * - If the value is an Overwrite instance (preferred API), return its `.value`.
209
+ * - If the value is a wire-format object ({ [OVERWRITE]: value }), extract it.
210
+ * - Otherwise, returns undefined.
211
+ *
212
+ * @template ValueType - The expected type of the Overwrite value.
213
+ * @param value - The value to check (may be anything).
214
+ * @returns The unwrapped value if value is an Overwrite, or undefined otherwise.
215
+ * @internal
216
+ */
217
+ function _getOverwriteValue(value) {
218
+ if (typeof value === "object" && value !== null && OVERWRITE in value) return [true, value[OVERWRITE]];
219
+ return [false, void 0];
220
+ }
221
+ /**
222
+ * Type guard to check if a value is an Overwrite value -- either the class
223
+ * instance or the wire format object.
224
+ *
225
+ * @template ValueType - The expected type of the Overwrite value.
226
+ * @param value - The value to check (may be anything).
227
+ * @returns `true` if the value is an Overwrite value, `false` otherwise.
228
+ * @internal
229
+ */
230
+ function _isOverwriteValue(value) {
231
+ return _getOverwriteValue(value)[0];
232
+ }
158
233
  /**
159
234
  * Checks if the given graph invoke / stream chunk contains interrupt.
160
235
  *
@@ -387,6 +462,7 @@ exports.INPUT = INPUT;
387
462
  exports.INTERRUPT = INTERRUPT;
388
463
  exports.NO_WRITES = NO_WRITES;
389
464
  exports.NULL_TASK_ID = NULL_TASK_ID;
465
+ exports.Overwrite = Overwrite;
390
466
  exports.PREVIOUS = PREVIOUS;
391
467
  exports.PULL = PULL;
392
468
  exports.PUSH = PUSH;
@@ -399,6 +475,8 @@ exports.Send = Send;
399
475
  exports.TAG_HIDDEN = TAG_HIDDEN;
400
476
  exports.TAG_NOSTREAM = TAG_NOSTREAM;
401
477
  exports.TASKS = TASKS;
478
+ exports._getOverwriteValue = _getOverwriteValue;
479
+ exports._isOverwriteValue = _isOverwriteValue;
402
480
  exports._isSend = _isSend;
403
481
  exports._isSendInterface = _isSendInterface;
404
482
  exports.isCommand = isCommand;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\n\n/** Special reserved node name denoting the start of a graph. */\nexport const START = \"__start__\";\n/** Special reserved node name denoting the end of a graph. */\nexport const END = \"__end__\";\nexport const INPUT = \"__input__\";\nexport const COPY = \"__copy__\";\nexport const ERROR = \"__error__\";\n\n/** Special reserved cache namespaces */\nexport const CACHE_NS_WRITES = \"__pregel_ns_writes\";\n\nexport const CONFIG_KEY_SEND = \"__pregel_send\";\n/** config key containing function used to call a node (push task) */\nexport const CONFIG_KEY_CALL = \"__pregel_call\";\nexport const CONFIG_KEY_READ = \"__pregel_read\";\nexport const CONFIG_KEY_CHECKPOINTER = \"__pregel_checkpointer\";\nexport const CONFIG_KEY_RESUMING = \"__pregel_resuming\";\nexport const CONFIG_KEY_TASK_ID = \"__pregel_task_id\";\nexport const CONFIG_KEY_STREAM = \"__pregel_stream\";\nexport const CONFIG_KEY_RESUME_VALUE = \"__pregel_resume_value\";\nexport const CONFIG_KEY_RESUME_MAP = \"__pregel_resume_map\";\nexport const CONFIG_KEY_SCRATCHPAD = \"__pregel_scratchpad\";\n/** config key containing state from previous invocation of graph for the given thread */\nexport const CONFIG_KEY_PREVIOUS_STATE = \"__pregel_previous\";\nexport const CONFIG_KEY_DURABILITY = \"__pregel_durability\";\nexport const CONFIG_KEY_CHECKPOINT_ID = \"checkpoint_id\";\nexport const CONFIG_KEY_CHECKPOINT_NS = \"checkpoint_ns\";\n\nexport const CONFIG_KEY_NODE_FINISHED = \"__pregel_node_finished\";\n\n// this one is part of public API\nexport const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\n\nexport const CONFIG_KEY_ABORT_SIGNALS = \"__pregel_abort_signals\";\n\n/** Special channel reserved for graph interrupts */\nexport const INTERRUPT = \"__interrupt__\";\n/** Special channel reserved for graph resume */\nexport const RESUME = \"__resume__\";\n/** Special channel reserved for cases when a task exits without any writes */\nexport const NO_WRITES = \"__no_writes__\";\n/** Special channel reserved for graph return */\nexport const RETURN = \"__return__\";\n/** Special channel reserved for graph previous state */\nexport const PREVIOUS = \"__previous__\";\nexport const RUNTIME_PLACEHOLDER = \"__pregel_runtime_placeholder__\";\nexport const RECURSION_LIMIT_DEFAULT = 25;\n\nexport const TAG_HIDDEN = \"langsmith:hidden\";\nexport const TAG_NOSTREAM = \"langsmith:nostream\";\nexport const SELF = \"__self__\";\n\nexport const TASKS = \"__pregel_tasks\";\nexport const PUSH = \"__pregel_push\";\nexport const PULL = \"__pregel_pull\";\n\nexport const TASK_NAMESPACE = \"6ba7b831-9dad-11d1-80b4-00c04fd430c8\";\nexport const NULL_TASK_ID = \"00000000-0000-0000-0000-000000000000\";\n\nexport const RESERVED = [\n TAG_HIDDEN,\n INPUT,\n INTERRUPT,\n RESUME,\n ERROR,\n NO_WRITES,\n\n // reserved config.configurable keys\n CONFIG_KEY_SEND,\n CONFIG_KEY_READ,\n CONFIG_KEY_CHECKPOINTER,\n CONFIG_KEY_DURABILITY,\n CONFIG_KEY_STREAM,\n CONFIG_KEY_RESUMING,\n CONFIG_KEY_TASK_ID,\n CONFIG_KEY_CALL,\n CONFIG_KEY_RESUME_VALUE,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_PREVIOUS_STATE,\n CONFIG_KEY_CHECKPOINT_MAP,\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_CHECKPOINT_ID,\n];\n\nexport const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport const CHECKPOINT_NAMESPACE_END = \":\";\n\n/** @internal */\nconst COMMAND_SYMBOL = Symbol.for(\"langgraph.command\");\n\n/**\n * Instance of a {@link Command} class.\n *\n * This is used to avoid IntelliSense suggesting public fields\n * of {@link Command} class when a plain object is expected.\n *\n * @see {@link Command}\n * @internal\n */\nexport class CommandInstance<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string\n> {\n [COMMAND_SYMBOL]: CommandParams<Resume, Update, Nodes>;\n\n constructor(args: CommandParams<Resume, Update, Nodes>) {\n this[COMMAND_SYMBOL] = args;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SendInterface<Node extends string = string, Args = any> {\n node: Node;\n args: Args;\n}\n\nexport function _isSendInterface(x: unknown): x is SendInterface {\n const operation = x as SendInterface;\n return (\n operation !== null &&\n operation !== undefined &&\n typeof operation.node === \"string\" &&\n operation.args !== undefined\n );\n}\n\n/**\n *\n * A message or packet to send to a specific node in the graph.\n *\n * The `Send` class is used within a `StateGraph`'s conditional edges to\n * dynamically invoke a node with a custom state at the next step.\n *\n * Importantly, the sent state can differ from the core graph's state,\n * allowing for flexible and dynamic workflow management.\n *\n * One such example is a \"map-reduce\" workflow where your graph invokes\n * the same node multiple times in parallel with different states,\n * before aggregating the results back into the main graph's state.\n *\n * @example\n * ```typescript\n * import { Annotation, Send, StateGraph } from \"@langchain/langgraph\";\n *\n * const ChainState = Annotation.Root({\n * subjects: Annotation<string[]>,\n * jokes: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * }),\n * });\n *\n * const continueToJokes = async (state: typeof ChainState.State) => {\n * return state.subjects.map((subject) => {\n * return new Send(\"generate_joke\", { subjects: [subject] });\n * });\n * };\n *\n * const graph = new StateGraph(ChainState)\n * .addNode(\"generate_joke\", (state) => ({\n * jokes: [`Joke about ${state.subjects}`],\n * }))\n * .addConditionalEdges(\"__start__\", continueToJokes)\n * .addEdge(\"generate_joke\", \"__end__\")\n * .compile();\n *\n * const res = await graph.invoke({ subjects: [\"cats\", \"dogs\"] });\n * console.log(res);\n *\n * // Invoking with two subjects results in a generated joke for each\n * // { subjects: [\"cats\", \"dogs\"], jokes: [`Joke about cats`, `Joke about dogs`] }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Send<Node extends string = string, Args = any>\n implements SendInterface<Node, Args>\n{\n lg_name = \"Send\";\n\n public node: Node;\n\n public args: Args;\n\n constructor(node: Node, args: Args) {\n this.node = node;\n this.args = _deserializeCommandSendObjectGraph(args) as Args;\n }\n\n toJSON() {\n return { lg_name: this.lg_name, node: this.node, args: this.args };\n }\n}\n\nexport function _isSend(x: unknown): x is Send {\n // eslint-disable-next-line no-instanceof/no-instanceof\n return x instanceof Send;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Interrupt<Value = any> = {\n id?: string;\n value?: Value;\n};\n\n/**\n * Checks if the given graph invoke / stream chunk contains interrupt.\n *\n * @example\n * ```ts\n * import { INTERRUPT, isInterrupted } from \"@langchain/langgraph\";\n *\n * const values = await graph.invoke({ foo: \"bar\" });\n * if (isInterrupted<string>(values)) {\n * const interrupt = values[INTERRUPT][0].value;\n * }\n * ```\n *\n * @param values - The values to check.\n * @returns `true` if the values contain an interrupt, `false` otherwise.\n */\nexport function isInterrupted<Value = unknown>(\n values: unknown\n): values is { [INTERRUPT]: Interrupt<Value>[] } {\n if (!values || typeof values !== \"object\") return false;\n if (!(INTERRUPT in values)) return false;\n return Array.isArray(values[INTERRUPT]);\n}\n\nexport type CommandParams<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string\n> = {\n /**\n * A discriminator field used to identify the type of object. Must be populated when serializing.\n *\n * Optional because it's not required to specify this when directly constructing a {@link Command}\n * object.\n */\n lg_name?: \"Command\";\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - `Send` object (to execute a node with the input provided)\n * - sequence of `Send` objects\n */\n goto?:\n | Nodes\n | SendInterface<Nodes> // eslint-disable-line @typescript-eslint/no-explicit-any\n | (Nodes | SendInterface<Nodes>)[]; // eslint-disable-line @typescript-eslint/no-explicit-any\n};\n\n/**\n * One or more commands to update the graph's state and send messages to nodes.\n * Can be used to combine routing logic with state updates in lieu of conditional edges\n *\n * @example\n * ```ts\n * import { Annotation, Command } from \"@langchain/langgraph\";\n *\n * // Define graph state\n * const StateAnnotation = Annotation.Root({\n * foo: Annotation<string>,\n * });\n *\n * // Define the nodes\n * const nodeA = async (_state: typeof StateAnnotation.State) => {\n * console.log(\"Called A\");\n * // this is a replacement for a real conditional edge function\n * const goto = Math.random() > .5 ? \"nodeB\" : \"nodeC\";\n * // note how Command allows you to BOTH update the graph state AND route to the next node\n * return new Command({\n * // this is the state update\n * update: {\n * foo: \"a\",\n * },\n * // this is a replacement for an edge\n * goto,\n * });\n * };\n *\n * // Nodes B and C are unchanged\n * const nodeB = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called B\");\n * return {\n * foo: state.foo + \"|b\",\n * };\n * }\n *\n * const nodeC = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called C\");\n * return {\n * foo: state.foo + \"|c\",\n * };\n * }\n * \n * import { StateGraph } from \"@langchain/langgraph\";\n\n * // NOTE: there are no edges between nodes A, B and C!\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(\"nodeA\", nodeA, {\n * ends: [\"nodeB\", \"nodeC\"],\n * })\n * .addNode(\"nodeB\", nodeB)\n * .addNode(\"nodeC\", nodeC)\n * .addEdge(\"__start__\", \"nodeA\")\n * .compile();\n * \n * await graph.invoke({ foo: \"\" });\n *\n * // Randomly oscillates between\n * // { foo: 'a|c' } and { foo: 'a|b' }\n * ```\n */\nexport class Command<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string\n> extends CommandInstance<Resume, Update, Nodes> {\n readonly lg_name = \"Command\";\n\n lc_direct_tool_output = true;\n\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state as a result of executing the node that is returning the command.\n * Written to the state as if the node had simply returned this value instead of the Command object.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)\n * - sequence of {@link Send} objects\n */\n goto?: Nodes | Send<Nodes> | (Nodes | Send<Nodes>)[] = [];\n\n static PARENT = \"__parent__\";\n\n constructor(args: Omit<CommandParams<Resume, Update, Nodes>, \"lg_name\">) {\n super(args);\n this.resume = args.resume;\n this.graph = args.graph;\n this.update = args.update;\n if (args.goto) {\n type ValidArg = Nodes | Send<Nodes, Update>;\n\n this.goto = Array.isArray(args.goto)\n ? (_deserializeCommandSendObjectGraph(args.goto) as ValidArg[])\n : [_deserializeCommandSendObjectGraph(args.goto) as ValidArg];\n }\n }\n\n /**\n * Convert the update field to a list of {@link PendingWrite} tuples\n * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.\n * @internal\n */\n _updateAsTuples(): PendingWrite[] {\n if (\n this.update &&\n typeof this.update === \"object\" &&\n !Array.isArray(this.update)\n ) {\n return Object.entries(this.update);\n } else if (\n Array.isArray(this.update) &&\n this.update.every(\n (t): t is [string, unknown] =>\n Array.isArray(t) && t.length === 2 && typeof t[0] === \"string\"\n )\n ) {\n return this.update;\n } else {\n return [[\"__root__\", this.update]];\n }\n }\n\n toJSON() {\n let serializedGoto;\n if (typeof this.goto === \"string\") {\n serializedGoto = this.goto;\n } else if (_isSend(this.goto)) {\n serializedGoto = this.goto.toJSON();\n } else {\n serializedGoto = this.goto?.map((innerGoto) => {\n if (typeof innerGoto === \"string\") {\n return innerGoto;\n } else {\n return innerGoto.toJSON();\n }\n });\n }\n return {\n lg_name: this.lg_name,\n update: this.update,\n resume: this.resume,\n goto: serializedGoto,\n };\n }\n}\n\n/**\n * A type guard to check if the given value is a {@link Command}.\n *\n * Useful for type narrowing when working with the {@link Command} object.\n *\n * @param x - The value to check.\n * @returns `true` if the value is a {@link Command}, `false` otherwise.\n */\nexport function isCommand(x: unknown): x is Command {\n if (typeof x !== \"object\") {\n return false;\n }\n\n if (x === null || x === undefined) {\n return false;\n }\n\n if (\"lg_name\" in x && x.lg_name === \"Command\") {\n return true;\n }\n\n return false;\n}\n\n/**\n * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects\n * matching their interfaces.\n *\n * This is only exported for testing purposes. It is NOT intended to be used outside of\n * the Command and Send classes.\n *\n * @internal\n *\n * @param x - The command send tree to convert.\n * @param seen - A map of seen objects to avoid infinite loops.\n * @returns The converted command send tree.\n */\nexport function _deserializeCommandSendObjectGraph(\n x: unknown,\n seen: Map<object, unknown> = new Map()\n): unknown {\n if (x !== undefined && x !== null && typeof x === \"object\") {\n // If we've already processed this object, return the transformed version\n if (seen.has(x)) {\n return seen.get(x);\n }\n\n let result: unknown;\n\n if (Array.isArray(x)) {\n // Create the array first, then populate it\n result = [];\n // Add to seen map before processing elements to handle self-references\n seen.set(x, result);\n\n // Now populate the array\n x.forEach((item, index) => {\n (result as unknown[])[index] = _deserializeCommandSendObjectGraph(\n item,\n seen\n );\n });\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (isCommand(x) && !(x instanceof Command)) {\n result = new Command(x);\n seen.set(x, result);\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (_isSendInterface(x) && !(x instanceof Send)) {\n result = new Send(x.node, x.args);\n seen.set(x, result);\n } else if (isCommand(x) || _isSend(x)) {\n result = x;\n seen.set(x, result);\n } else if (\"lc_serializable\" in x && x.lc_serializable) {\n result = x;\n seen.set(x, result);\n } else {\n // Create empty object first\n result = {};\n // Add to seen map before processing properties to handle self-references\n seen.set(x, result);\n\n // Now populate the object\n for (const [key, value] of Object.entries(x)) {\n (result as Record<string, unknown>)[key] =\n _deserializeCommandSendObjectGraph(value, seen);\n }\n }\n\n return result;\n }\n return x;\n}\n"],"mappings":";;;AAGA,MAAa,QAAQ;;AAErB,MAAa,MAAM;AACnB,MAAa,QAAQ;AACrB,MAAa,OAAO;AACpB,MAAa,QAAQ;;AAGrB,MAAa,kBAAkB;AAE/B,MAAa,kBAAkB;;AAE/B,MAAa,kBAAkB;AAC/B,MAAa,kBAAkB;AAC/B,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;AAClC,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;;AAErC,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;AACrC,MAAa,2BAA2B;AACxC,MAAa,2BAA2B;AAExC,MAAa,2BAA2B;AAGxC,MAAa,4BAA4B;AAEzC,MAAa,2BAA2B;;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AgBT,SAAgB,mCACd,GACA,uBAA6B,IAAI,KAAK,EAC7B;AACT,KAAI,MAAM,UAAa,MAAM,QAAQ,OAAO,MAAM,UAAU;AAE1D,MAAI,KAAK,IAAI,EAAE,CACb,QAAO,KAAK,IAAI,EAAE;EAGpB,IAAI;AAEJ,MAAI,MAAM,QAAQ,EAAE,EAAE;AAEpB,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,KAAE,SAAS,MAAM,UAAU;AACzB,IAAC,OAAqB,SAAS,mCAC7B,MACA,KACD;KACD;aAEO,UAAU,EAAE,IAAI,EAAE,aAAa,UAAU;AAClD,YAAS,IAAI,QAAQ,EAAE;AACvB,QAAK,IAAI,GAAG,OAAO;aAEV,iBAAiB,EAAE,IAAI,EAAE,aAAa,OAAO;AACtD,YAAS,IAAI,KAAK,EAAE,MAAM,EAAE,KAAK;AACjC,QAAK,IAAI,GAAG,OAAO;aACV,UAAU,EAAE,IAAI,QAAQ,EAAE,EAAE;AACrC,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;aACV,qBAAqB,KAAK,EAAE,iBAAiB;AACtD,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;SACd;AAEL,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,EAAE,CAC1C,CAAC,OAAmC,OAClC,mCAAmC,OAAO,KAAK;;AAIrD,SAAO;;AAET,QAAO"}
1
+ {"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\n\n/** Special reserved node name denoting the start of a graph. */\nexport const START = \"__start__\";\n/** Special reserved node name denoting the end of a graph. */\nexport const END = \"__end__\";\nexport const INPUT = \"__input__\";\nexport const COPY = \"__copy__\";\nexport const ERROR = \"__error__\";\n\n/** Special reserved cache namespaces */\nexport const CACHE_NS_WRITES = \"__pregel_ns_writes\";\n\nexport const CONFIG_KEY_SEND = \"__pregel_send\";\n/** config key containing function used to call a node (push task) */\nexport const CONFIG_KEY_CALL = \"__pregel_call\";\nexport const CONFIG_KEY_READ = \"__pregel_read\";\nexport const CONFIG_KEY_CHECKPOINTER = \"__pregel_checkpointer\";\nexport const CONFIG_KEY_RESUMING = \"__pregel_resuming\";\nexport const CONFIG_KEY_TASK_ID = \"__pregel_task_id\";\nexport const CONFIG_KEY_STREAM = \"__pregel_stream\";\nexport const CONFIG_KEY_RESUME_VALUE = \"__pregel_resume_value\";\nexport const CONFIG_KEY_RESUME_MAP = \"__pregel_resume_map\";\nexport const CONFIG_KEY_SCRATCHPAD = \"__pregel_scratchpad\";\n/** config key containing state from previous invocation of graph for the given thread */\nexport const CONFIG_KEY_PREVIOUS_STATE = \"__pregel_previous\";\nexport const CONFIG_KEY_DURABILITY = \"__pregel_durability\";\nexport const CONFIG_KEY_CHECKPOINT_ID = \"checkpoint_id\";\nexport const CONFIG_KEY_CHECKPOINT_NS = \"checkpoint_ns\";\n\nexport const CONFIG_KEY_NODE_FINISHED = \"__pregel_node_finished\";\n\n// this one is part of public API\nexport const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\n\nexport const CONFIG_KEY_ABORT_SIGNALS = \"__pregel_abort_signals\";\n\n/** Special channel reserved for graph interrupts */\nexport const INTERRUPT = \"__interrupt__\";\n/** Special channel reserved for graph resume */\nexport const RESUME = \"__resume__\";\n/** Special channel reserved for cases when a task exits without any writes */\nexport const NO_WRITES = \"__no_writes__\";\n/** Special channel reserved for graph return */\nexport const RETURN = \"__return__\";\n/** Special channel reserved for graph previous state */\nexport const PREVIOUS = \"__previous__\";\nexport const RUNTIME_PLACEHOLDER = \"__pregel_runtime_placeholder__\";\nexport const RECURSION_LIMIT_DEFAULT = 25;\n\nexport const TAG_HIDDEN = \"langsmith:hidden\";\nexport const TAG_NOSTREAM = \"langsmith:nostream\";\nexport const SELF = \"__self__\";\n\nexport const TASKS = \"__pregel_tasks\";\nexport const PUSH = \"__pregel_push\";\nexport const PULL = \"__pregel_pull\";\n\nexport const TASK_NAMESPACE = \"6ba7b831-9dad-11d1-80b4-00c04fd430c8\";\nexport const NULL_TASK_ID = \"00000000-0000-0000-0000-000000000000\";\n\nexport const RESERVED = [\n TAG_HIDDEN,\n INPUT,\n INTERRUPT,\n RESUME,\n ERROR,\n NO_WRITES,\n\n // reserved config.configurable keys\n CONFIG_KEY_SEND,\n CONFIG_KEY_READ,\n CONFIG_KEY_CHECKPOINTER,\n CONFIG_KEY_DURABILITY,\n CONFIG_KEY_STREAM,\n CONFIG_KEY_RESUMING,\n CONFIG_KEY_TASK_ID,\n CONFIG_KEY_CALL,\n CONFIG_KEY_RESUME_VALUE,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_PREVIOUS_STATE,\n CONFIG_KEY_CHECKPOINT_MAP,\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_CHECKPOINT_ID,\n];\n\nexport const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport const CHECKPOINT_NAMESPACE_END = \":\";\n\n/** @internal */\nconst COMMAND_SYMBOL = Symbol.for(\"langgraph.command\");\n\n/**\n * Instance of a {@link Command} class.\n *\n * This is used to avoid IntelliSense suggesting public fields\n * of {@link Command} class when a plain object is expected.\n *\n * @see {@link Command}\n * @internal\n */\nexport class CommandInstance<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string\n> {\n [COMMAND_SYMBOL]: CommandParams<Resume, Update, Nodes>;\n\n constructor(args: CommandParams<Resume, Update, Nodes>) {\n this[COMMAND_SYMBOL] = args;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SendInterface<Node extends string = string, Args = any> {\n node: Node;\n args: Args;\n}\n\nexport function _isSendInterface(x: unknown): x is SendInterface {\n const operation = x as SendInterface;\n return (\n operation !== null &&\n operation !== undefined &&\n typeof operation.node === \"string\" &&\n operation.args !== undefined\n );\n}\n\n/**\n *\n * A message or packet to send to a specific node in the graph.\n *\n * The `Send` class is used within a `StateGraph`'s conditional edges to\n * dynamically invoke a node with a custom state at the next step.\n *\n * Importantly, the sent state can differ from the core graph's state,\n * allowing for flexible and dynamic workflow management.\n *\n * One such example is a \"map-reduce\" workflow where your graph invokes\n * the same node multiple times in parallel with different states,\n * before aggregating the results back into the main graph's state.\n *\n * @example\n * ```typescript\n * import { Annotation, Send, StateGraph } from \"@langchain/langgraph\";\n *\n * const ChainState = Annotation.Root({\n * subjects: Annotation<string[]>,\n * jokes: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * }),\n * });\n *\n * const continueToJokes = async (state: typeof ChainState.State) => {\n * return state.subjects.map((subject) => {\n * return new Send(\"generate_joke\", { subjects: [subject] });\n * });\n * };\n *\n * const graph = new StateGraph(ChainState)\n * .addNode(\"generate_joke\", (state) => ({\n * jokes: [`Joke about ${state.subjects}`],\n * }))\n * .addConditionalEdges(\"__start__\", continueToJokes)\n * .addEdge(\"generate_joke\", \"__end__\")\n * .compile();\n *\n * const res = await graph.invoke({ subjects: [\"cats\", \"dogs\"] });\n * console.log(res);\n *\n * // Invoking with two subjects results in a generated joke for each\n * // { subjects: [\"cats\", \"dogs\"], jokes: [`Joke about cats`, `Joke about dogs`] }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Send<Node extends string = string, Args = any>\n implements SendInterface<Node, Args>\n{\n lg_name = \"Send\";\n\n public node: Node;\n\n public args: Args;\n\n constructor(node: Node, args: Args) {\n this.node = node;\n this.args = _deserializeCommandSendObjectGraph(args) as Args;\n }\n\n toJSON() {\n return { lg_name: this.lg_name, node: this.node, args: this.args };\n }\n}\n\nexport function _isSend(x: unknown): x is Send {\n // eslint-disable-next-line no-instanceof/no-instanceof\n return x instanceof Send;\n}\n\nexport const OVERWRITE = \"__overwrite__\";\n\n/**\n * An object representing a direct overwrite of a value for a channel.\n * Used to signal that the channel value should be replaced with the given value,\n * bypassing any reducer or binary operator logic.\n *\n * @template ValueType - The type of the value being overwritten.\n * @property {ValueType} [OVERWRITE] - The value to directly set.\n *\n * @example\n * const overwriteObj: OverwriteValue<number> = { __overwrite__: 123 };\n */\nexport interface OverwriteValue<ValueType> {\n [OVERWRITE]: ValueType;\n}\n\n/**\n * Bypass a reducer and write the wrapped value directly to a\n * {@link BinaryOperatorAggregate} channel.\n *\n * Receiving multiple `Overwrite` values for the same channel in a single\n * super-step will raise an {@link InvalidUpdateError}.\n *\n * @example\n * ```typescript\n * import { Annotation, StateGraph, Overwrite } from \"@langchain/langgraph\";\n *\n * const State = Annotation.Root({\n * messages: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * default: () => [],\n * }),\n * });\n *\n * const replaceMessages = (_state: typeof State.State) => {\n * return { messages: new Overwrite([\"replacement\"]) };\n * };\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Overwrite<ValueType = any> implements OverwriteValue<ValueType> {\n lg_name = \"Overwrite\";\n\n readonly [OVERWRITE]: ValueType;\n\n constructor(value: ValueType) {\n this[OVERWRITE] = value;\n }\n\n get value(): ValueType {\n return this[OVERWRITE];\n }\n\n toJSON() {\n return { [OVERWRITE]: this[OVERWRITE] };\n }\n\n static isInstance<ValueType>(value: unknown): value is Overwrite<ValueType> {\n if (!value || typeof value !== \"object\") return false;\n if (OVERWRITE in value) return true;\n if (\"lg_name\" in value && value.lg_name === \"Overwrite\") return true;\n return false;\n }\n}\n\n/**\n * Helper function to detect and extract the value from an Overwrite wrapper,\n * supporting both the Overwrite class instance and the serialized object format.\n *\n * Use to check if a provided value represents an Overwrite: returns the\n * unwrapped value if so, or undefined otherwise.\n *\n * - If the value is an Overwrite instance (preferred API), return its `.value`.\n * - If the value is a wire-format object ({ [OVERWRITE]: value }), extract it.\n * - Otherwise, returns undefined.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns The unwrapped value if value is an Overwrite, or undefined otherwise.\n * @internal\n */\nexport function _getOverwriteValue<ValueType>(\n value: unknown\n): [true, ValueType] | [false, undefined] {\n if (typeof value === \"object\" && value !== null && OVERWRITE in value) {\n return [true, (value as Record<string, ValueType>)[OVERWRITE]];\n }\n return [false, undefined];\n}\n\n/**\n * Type guard to check if a value is an Overwrite value -- either the class\n * instance or the wire format object.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns `true` if the value is an Overwrite value, `false` otherwise.\n * @internal\n */\nexport function _isOverwriteValue<ValueType>(\n value: unknown\n): value is OverwriteValue<ValueType> {\n return _getOverwriteValue<ValueType>(value)[0];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Interrupt<Value = any> = {\n id?: string;\n value?: Value;\n};\n\n/**\n * Checks if the given graph invoke / stream chunk contains interrupt.\n *\n * @example\n * ```ts\n * import { INTERRUPT, isInterrupted } from \"@langchain/langgraph\";\n *\n * const values = await graph.invoke({ foo: \"bar\" });\n * if (isInterrupted<string>(values)) {\n * const interrupt = values[INTERRUPT][0].value;\n * }\n * ```\n *\n * @param values - The values to check.\n * @returns `true` if the values contain an interrupt, `false` otherwise.\n */\nexport function isInterrupted<Value = unknown>(\n values: unknown\n): values is { [INTERRUPT]: Interrupt<Value>[] } {\n if (!values || typeof values !== \"object\") return false;\n if (!(INTERRUPT in values)) return false;\n return Array.isArray(values[INTERRUPT]);\n}\n\nexport type CommandParams<\n Resume = unknown,\n Update = Record<string, unknown>,\n Nodes extends string = string\n> = {\n /**\n * A discriminator field used to identify the type of object. Must be populated when serializing.\n *\n * Optional because it's not required to specify this when directly constructing a {@link Command}\n * object.\n */\n lg_name?: \"Command\";\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - `Send` object (to execute a node with the input provided)\n * - sequence of `Send` objects\n */\n goto?:\n | Nodes\n | SendInterface<Nodes> // eslint-disable-line @typescript-eslint/no-explicit-any\n | (Nodes | SendInterface<Nodes>)[]; // eslint-disable-line @typescript-eslint/no-explicit-any\n};\n\n/**\n * One or more commands to update the graph's state and send messages to nodes.\n * Can be used to combine routing logic with state updates in lieu of conditional edges\n *\n * @example\n * ```ts\n * import { Annotation, Command } from \"@langchain/langgraph\";\n *\n * // Define graph state\n * const StateAnnotation = Annotation.Root({\n * foo: Annotation<string>,\n * });\n *\n * // Define the nodes\n * const nodeA = async (_state: typeof StateAnnotation.State) => {\n * console.log(\"Called A\");\n * // this is a replacement for a real conditional edge function\n * const goto = Math.random() > .5 ? \"nodeB\" : \"nodeC\";\n * // note how Command allows you to BOTH update the graph state AND route to the next node\n * return new Command({\n * // this is the state update\n * update: {\n * foo: \"a\",\n * },\n * // this is a replacement for an edge\n * goto,\n * });\n * };\n *\n * // Nodes B and C are unchanged\n * const nodeB = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called B\");\n * return {\n * foo: state.foo + \"|b\",\n * };\n * }\n *\n * const nodeC = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called C\");\n * return {\n * foo: state.foo + \"|c\",\n * };\n * }\n * \n * import { StateGraph } from \"@langchain/langgraph\";\n\n * // NOTE: there are no edges between nodes A, B and C!\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(\"nodeA\", nodeA, {\n * ends: [\"nodeB\", \"nodeC\"],\n * })\n * .addNode(\"nodeB\", nodeB)\n * .addNode(\"nodeC\", nodeC)\n * .addEdge(\"__start__\", \"nodeA\")\n * .compile();\n * \n * await graph.invoke({ foo: \"\" });\n *\n * // Randomly oscillates between\n * // { foo: 'a|c' } and { foo: 'a|b' }\n * ```\n */\nexport class Command<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string\n> extends CommandInstance<Resume, Update, Nodes> {\n readonly lg_name = \"Command\";\n\n lc_direct_tool_output = true;\n\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state as a result of executing the node that is returning the command.\n * Written to the state as if the node had simply returned this value instead of the Command object.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)\n * - sequence of {@link Send} objects\n */\n goto?: Nodes | Send<Nodes> | (Nodes | Send<Nodes>)[] = [];\n\n static PARENT = \"__parent__\";\n\n constructor(args: Omit<CommandParams<Resume, Update, Nodes>, \"lg_name\">) {\n super(args);\n this.resume = args.resume;\n this.graph = args.graph;\n this.update = args.update;\n if (args.goto) {\n type ValidArg = Nodes | Send<Nodes, Update>;\n\n this.goto = Array.isArray(args.goto)\n ? (_deserializeCommandSendObjectGraph(args.goto) as ValidArg[])\n : [_deserializeCommandSendObjectGraph(args.goto) as ValidArg];\n }\n }\n\n /**\n * Convert the update field to a list of {@link PendingWrite} tuples\n * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.\n * @internal\n */\n _updateAsTuples(): PendingWrite[] {\n if (\n this.update &&\n typeof this.update === \"object\" &&\n !Array.isArray(this.update)\n ) {\n return Object.entries(this.update);\n } else if (\n Array.isArray(this.update) &&\n this.update.every(\n (t): t is [string, unknown] =>\n Array.isArray(t) && t.length === 2 && typeof t[0] === \"string\"\n )\n ) {\n return this.update;\n } else {\n return [[\"__root__\", this.update]];\n }\n }\n\n toJSON() {\n let serializedGoto;\n if (typeof this.goto === \"string\") {\n serializedGoto = this.goto;\n } else if (_isSend(this.goto)) {\n serializedGoto = this.goto.toJSON();\n } else {\n serializedGoto = this.goto?.map((innerGoto) => {\n if (typeof innerGoto === \"string\") {\n return innerGoto;\n } else {\n return innerGoto.toJSON();\n }\n });\n }\n return {\n lg_name: this.lg_name,\n update: this.update,\n resume: this.resume,\n goto: serializedGoto,\n };\n }\n}\n\n/**\n * A type guard to check if the given value is a {@link Command}.\n *\n * Useful for type narrowing when working with the {@link Command} object.\n *\n * @param x - The value to check.\n * @returns `true` if the value is a {@link Command}, `false` otherwise.\n */\nexport function isCommand(x: unknown): x is Command {\n if (typeof x !== \"object\") {\n return false;\n }\n\n if (x === null || x === undefined) {\n return false;\n }\n\n if (\"lg_name\" in x && x.lg_name === \"Command\") {\n return true;\n }\n\n return false;\n}\n\n/**\n * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects\n * matching their interfaces.\n *\n * This is only exported for testing purposes. It is NOT intended to be used outside of\n * the Command and Send classes.\n *\n * @internal\n *\n * @param x - The command send tree to convert.\n * @param seen - A map of seen objects to avoid infinite loops.\n * @returns The converted command send tree.\n */\nexport function _deserializeCommandSendObjectGraph(\n x: unknown,\n seen: Map<object, unknown> = new Map()\n): unknown {\n if (x !== undefined && x !== null && typeof x === \"object\") {\n // If we've already processed this object, return the transformed version\n if (seen.has(x)) {\n return seen.get(x);\n }\n\n let result: unknown;\n\n if (Array.isArray(x)) {\n // Create the array first, then populate it\n result = [];\n // Add to seen map before processing elements to handle self-references\n seen.set(x, result);\n\n // Now populate the array\n x.forEach((item, index) => {\n (result as unknown[])[index] = _deserializeCommandSendObjectGraph(\n item,\n seen\n );\n });\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (isCommand(x) && !(x instanceof Command)) {\n result = new Command(x);\n seen.set(x, result);\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (_isSendInterface(x) && !(x instanceof Send)) {\n result = new Send(x.node, x.args);\n seen.set(x, result);\n } else if (isCommand(x) || _isSend(x)) {\n result = x;\n seen.set(x, result);\n } else if (\"lc_serializable\" in x && x.lc_serializable) {\n result = x;\n seen.set(x, result);\n } else {\n // Create empty object first\n result = {};\n // Add to seen map before processing properties to handle self-references\n seen.set(x, result);\n\n // Now populate the object\n for (const [key, value] of Object.entries(x)) {\n (result as Record<string, unknown>)[key] =\n _deserializeCommandSendObjectGraph(value, seen);\n }\n }\n\n return result;\n }\n return x;\n}\n"],"mappings":";;;AAGA,MAAa,QAAQ;;AAErB,MAAa,MAAM;AACnB,MAAa,QAAQ;AACrB,MAAa,OAAO;AACpB,MAAa,QAAQ;;AAGrB,MAAa,kBAAkB;AAE/B,MAAa,kBAAkB;;AAE/B,MAAa,kBAAkB;AAC/B,MAAa,kBAAkB;AAC/B,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;AAClC,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;;AAErC,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;AACrC,MAAa,2BAA2B;AACxC,MAAa,2BAA2B;AAExC,MAAa,2BAA2B;AAGxC,MAAa,4BAA4B;AAEzC,MAAa,2BAA2B;;AAGxC,MAAa,YAAY;;AAEzB,MAAa,SAAS;;AAEtB,MAAa,YAAY;;AAEzB,MAAa,SAAS;;AAEtB,MAAa,WAAW;AAIxB,MAAa,aAAa;AAC1B,MAAa,eAAe;AAC5B,MAAa,OAAO;AAEpB,MAAa,QAAQ;AACrB,MAAa,OAAO;AACpB,MAAa,OAAO;AAGpB,MAAa,eAAe;AAE5B,MAAa,WAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,iCAAiC;AAC9C,MAAa,2BAA2B;;AAGxC,MAAM,iBAAiB,OAAO,IAAI,oBAAoB;;;;;;;;;;AAWtD,IAAa,kBAA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,GAA0B;AAClD,KAAI,OAAO,MAAM,SACf,QAAO;AAGT,KAAI,MAAM,QAAQ,MAAM,OACtB,QAAO;AAGT,KAAI,aAAa,KAAK,EAAE,YAAY,UAClC,QAAO;AAGT,QAAO;;;;;;;;;;;;;;;AAgBT,SAAgB,mCACd,GACA,uBAA6B,IAAI,KAAK,EAC7B;AACT,KAAI,MAAM,UAAa,MAAM,QAAQ,OAAO,MAAM,UAAU;AAE1D,MAAI,KAAK,IAAI,EAAE,CACb,QAAO,KAAK,IAAI,EAAE;EAGpB,IAAI;AAEJ,MAAI,MAAM,QAAQ,EAAE,EAAE;AAEpB,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,KAAE,SAAS,MAAM,UAAU;AACzB,IAAC,OAAqB,SAAS,mCAC7B,MACA,KACD;KACD;aAEO,UAAU,EAAE,IAAI,EAAE,aAAa,UAAU;AAClD,YAAS,IAAI,QAAQ,EAAE;AACvB,QAAK,IAAI,GAAG,OAAO;aAEV,iBAAiB,EAAE,IAAI,EAAE,aAAa,OAAO;AACtD,YAAS,IAAI,KAAK,EAAE,MAAM,EAAE,KAAK;AACjC,QAAK,IAAI,GAAG,OAAO;aACV,UAAU,EAAE,IAAI,QAAQ,EAAE,EAAE;AACrC,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;aACV,qBAAqB,KAAK,EAAE,iBAAiB;AACtD,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;SACd;AAEL,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,EAAE,CAC1C,CAAC,OAAmC,OAClC,mCAAmC,OAAO,KAAK;;AAIrD,SAAO;;AAET,QAAO"}
@@ -85,6 +85,54 @@ declare class Send<Node extends string = string, Args = any> implements SendInte
85
85
  args: Args;
86
86
  };
87
87
  }
88
+ declare const OVERWRITE = "__overwrite__";
89
+ /**
90
+ * An object representing a direct overwrite of a value for a channel.
91
+ * Used to signal that the channel value should be replaced with the given value,
92
+ * bypassing any reducer or binary operator logic.
93
+ *
94
+ * @template ValueType - The type of the value being overwritten.
95
+ * @property {ValueType} [OVERWRITE] - The value to directly set.
96
+ *
97
+ * @example
98
+ * const overwriteObj: OverwriteValue<number> = { __overwrite__: 123 };
99
+ */
100
+ interface OverwriteValue<ValueType> {
101
+ [OVERWRITE]: ValueType;
102
+ }
103
+ /**
104
+ * Bypass a reducer and write the wrapped value directly to a
105
+ * {@link BinaryOperatorAggregate} channel.
106
+ *
107
+ * Receiving multiple `Overwrite` values for the same channel in a single
108
+ * super-step will raise an {@link InvalidUpdateError}.
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * import { Annotation, StateGraph, Overwrite } from "@langchain/langgraph";
113
+ *
114
+ * const State = Annotation.Root({
115
+ * messages: Annotation<string[]>({
116
+ * reducer: (a, b) => a.concat(b),
117
+ * default: () => [],
118
+ * }),
119
+ * });
120
+ *
121
+ * const replaceMessages = (_state: typeof State.State) => {
122
+ * return { messages: new Overwrite(["replacement"]) };
123
+ * };
124
+ * ```
125
+ */
126
+ declare class Overwrite<ValueType = any> implements OverwriteValue<ValueType> {
127
+ lg_name: string;
128
+ readonly [OVERWRITE]: ValueType;
129
+ constructor(value: ValueType);
130
+ get value(): ValueType;
131
+ toJSON(): {
132
+ __overwrite__: ValueType;
133
+ };
134
+ static isInstance<ValueType>(value: unknown): value is Overwrite<ValueType>;
135
+ }
88
136
  type Interrupt<Value = any> = {
89
137
  id?: string;
90
138
  value?: Value;
@@ -262,5 +310,5 @@ declare class Command<Resume = unknown, Update extends Record<string, unknown> =
262
310
  */
263
311
  declare function isCommand(x: unknown): x is Command;
264
312
  //#endregion
265
- export { Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, PREVIOUS, START, Send, isCommand, isInterrupted };
313
+ export { Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, PREVIOUS, START, Send, isCommand, isInterrupted };
266
314
  //# s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AAA,EAAQ,MAAA,EAAQ,KAAA;;;;;;EAmBrD,eAAA,CAAA,GAAmB,YAAA;EAoBnB,MAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;iBAgCc,SAAA,CAAU,CAAA,YAAa,CAAA,IAAK,OAAA"}
@@ -85,6 +85,54 @@ declare class Send<Node extends string = string, Args = any> implements SendInte
85
85
  args: Args;
86
86
  };
87
87
  }
88
+ declare const OVERWRITE = "__overwrite__";
89
+ /**
90
+ * An object representing a direct overwrite of a value for a channel.
91
+ * Used to signal that the channel value should be replaced with the given value,
92
+ * bypassing any reducer or binary operator logic.
93
+ *
94
+ * @template ValueType - The type of the value being overwritten.
95
+ * @property {ValueType} [OVERWRITE] - The value to directly set.
96
+ *
97
+ * @example
98
+ * const overwriteObj: OverwriteValue<number> = { __overwrite__: 123 };
99
+ */
100
+ interface OverwriteValue<ValueType> {
101
+ [OVERWRITE]: ValueType;
102
+ }
103
+ /**
104
+ * Bypass a reducer and write the wrapped value directly to a
105
+ * {@link BinaryOperatorAggregate} channel.
106
+ *
107
+ * Receiving multiple `Overwrite` values for the same channel in a single
108
+ * super-step will raise an {@link InvalidUpdateError}.
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * import { Annotation, StateGraph, Overwrite } from "@langchain/langgraph";
113
+ *
114
+ * const State = Annotation.Root({
115
+ * messages: Annotation<string[]>({
116
+ * reducer: (a, b) => a.concat(b),
117
+ * default: () => [],
118
+ * }),
119
+ * });
120
+ *
121
+ * const replaceMessages = (_state: typeof State.State) => {
122
+ * return { messages: new Overwrite(["replacement"]) };
123
+ * };
124
+ * ```
125
+ */
126
+ declare class Overwrite<ValueType = any> implements OverwriteValue<ValueType> {
127
+ lg_name: string;
128
+ readonly [OVERWRITE]: ValueType;
129
+ constructor(value: ValueType);
130
+ get value(): ValueType;
131
+ toJSON(): {
132
+ __overwrite__: ValueType;
133
+ };
134
+ static isInstance<ValueType>(value: unknown): value is Overwrite<ValueType>;
135
+ }
88
136
  type Interrupt<Value = any> = {
89
137
  id?: string;
90
138
  value?: Value;
@@ -262,5 +310,5 @@ declare class Command<Resume = unknown, Update extends Record<string, unknown> =
262
310
  */
263
311
  declare function isCommand(x: unknown): x is Command;
264
312
  //#endregion
265
- export { Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, PREVIOUS, START, Send, isCommand, isInterrupted };
313
+ export { Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, PREVIOUS, START, Send, isCommand, isInterrupted };
266
314
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;cAGa,KAAA;AAAb;AAAA,cAEa,GAAA;;cAiCA,SAAA;;cAQA,QAAA;;cA4CP,cAAA;;;;;;;AAwBN;;;cAba,eAAA,4BAEF,MAAA;EAAA,CAGR,cAAA,GAAiB,aAAA,CAAc,MAAA,EAAQ,MAAA,EAAQ,KAAA;EAEhD,WAAA,CAAY,IAAA,EAAM,aAAA,CAAc,MAAA,EAAQ,MAAA,EAAQ,KAAA;AAAA;AAAA,UAMjC,aAAA;EACf,IAAA,EAAM,IAAA;EACN,IAAA,EAAM,IAAA;AAAA;AA4DR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA;;;;;;;;;AAzBA,cAAa,IAAA,sDACA,aAAA,CAAc,IAAA,EAAM,IAAA;EAE/B,OAAA;EAEO,IAAA,EAAM,IAAA;EAEN,IAAA,EAAM,IAAA;EAEb,WAAA,CAAY,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA;EAK9B,MAAA,CAAA;;;;;;KAWU,SAAA;EACV,EAAA;EACA,KAAA,GAAQ,KAAA;AAAA;;AA2BV;;;;;;;;;;;;;;;iBARgB,aAAA,iBAAA,CACd,MAAA,YACC,MAAA;EAAA,CAAa,SAAA,GAAY,SAAA,CAAU,KAAA;AAAA;AAAA,KAM1B,aAAA,4BAED,MAAA;EAc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,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,KAAA;EAAA,SAC/B,OAAA;EAET,qBAAA;;;;;;;EAQA,KAAA;;;;;EAMA,MAAA,GAAS,MAAA;;;;EAKT,MAAA,GAAS,MAAA;;;;;;;;EAST,IAAA,GAAO,KAAA,GAAQ,IAAA,CAAK,KAAA,KAAU,KAAA,GAAQ,IAAA,CAAK,KAAA;EAAA,OAEpC,MAAA;EAEP,WAAA,CAAY,IAAA,EAAM,IAAA,CAAK,aAAA,CAAc,MAAA,EAAQ,MAAA,EAAQ,KAAA;;;;;;EAmBrD,eAAA,CAAA,GAAmB,YAAA;EAoBnB,MAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;iBAgCc,SAAA,CAAU,CAAA,YAAa,CAAA,IAAK,OAAA"}
package/dist/constants.js CHANGED
@@ -154,6 +154,81 @@ var Send = class {
154
154
  function _isSend(x) {
155
155
  return x instanceof Send;
156
156
  }
157
+ const OVERWRITE = "__overwrite__";
158
+ /**
159
+ * Bypass a reducer and write the wrapped value directly to a
160
+ * {@link BinaryOperatorAggregate} channel.
161
+ *
162
+ * Receiving multiple `Overwrite` values for the same channel in a single
163
+ * super-step will raise an {@link InvalidUpdateError}.
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * import { Annotation, StateGraph, Overwrite } from "@langchain/langgraph";
168
+ *
169
+ * const State = Annotation.Root({
170
+ * messages: Annotation<string[]>({
171
+ * reducer: (a, b) => a.concat(b),
172
+ * default: () => [],
173
+ * }),
174
+ * });
175
+ *
176
+ * const replaceMessages = (_state: typeof State.State) => {
177
+ * return { messages: new Overwrite(["replacement"]) };
178
+ * };
179
+ * ```
180
+ */
181
+ var Overwrite = class {
182
+ lg_name = "Overwrite";
183
+ [OVERWRITE];
184
+ constructor(value) {
185
+ this[OVERWRITE] = value;
186
+ }
187
+ get value() {
188
+ return this[OVERWRITE];
189
+ }
190
+ toJSON() {
191
+ return { [OVERWRITE]: this[OVERWRITE] };
192
+ }
193
+ static isInstance(value) {
194
+ if (!value || typeof value !== "object") return false;
195
+ if (OVERWRITE in value) return true;
196
+ if ("lg_name" in value && value.lg_name === "Overwrite") return true;
197
+ return false;
198
+ }
199
+ };
200
+ /**
201
+ * Helper function to detect and extract the value from an Overwrite wrapper,
202
+ * supporting both the Overwrite class instance and the serialized object format.
203
+ *
204
+ * Use to check if a provided value represents an Overwrite: returns the
205
+ * unwrapped value if so, or undefined otherwise.
206
+ *
207
+ * - If the value is an Overwrite instance (preferred API), return its `.value`.
208
+ * - If the value is a wire-format object ({ [OVERWRITE]: value }), extract it.
209
+ * - Otherwise, returns undefined.
210
+ *
211
+ * @template ValueType - The expected type of the Overwrite value.
212
+ * @param value - The value to check (may be anything).
213
+ * @returns The unwrapped value if value is an Overwrite, or undefined otherwise.
214
+ * @internal
215
+ */
216
+ function _getOverwriteValue(value) {
217
+ if (typeof value === "object" && value !== null && OVERWRITE in value) return [true, value[OVERWRITE]];
218
+ return [false, void 0];
219
+ }
220
+ /**
221
+ * Type guard to check if a value is an Overwrite value -- either the class
222
+ * instance or the wire format object.
223
+ *
224
+ * @template ValueType - The expected type of the Overwrite value.
225
+ * @param value - The value to check (may be anything).
226
+ * @returns `true` if the value is an Overwrite value, `false` otherwise.
227
+ * @internal
228
+ */
229
+ function _isOverwriteValue(value) {
230
+ return _getOverwriteValue(value)[0];
231
+ }
157
232
  /**
158
233
  * Checks if the given graph invoke / stream chunk contains interrupt.
159
234
  *
@@ -358,5 +433,5 @@ function _deserializeCommandSendObjectGraph(x, seen = /* @__PURE__ */ new Map())
358
433
  }
359
434
 
360
435
  //#endregion
361
- export { CACHE_NS_WRITES, CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_ABORT_SIGNALS, CONFIG_KEY_CALL, CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_CHECKPOINT_ID, CONFIG_KEY_CHECKPOINT_MAP, CONFIG_KEY_CHECKPOINT_NS, CONFIG_KEY_DURABILITY, CONFIG_KEY_NODE_FINISHED, CONFIG_KEY_PREVIOUS_STATE, CONFIG_KEY_READ, CONFIG_KEY_RESUME_MAP, CONFIG_KEY_RESUMING, CONFIG_KEY_SCRATCHPAD, CONFIG_KEY_SEND, CONFIG_KEY_STREAM, CONFIG_KEY_TASK_ID, COPY, Command, CommandInstance, END, ERROR, INPUT, INTERRUPT, NO_WRITES, NULL_TASK_ID, PREVIOUS, PULL, PUSH, RESERVED, RESUME, RETURN, SELF, START, Send, TAG_HIDDEN, TAG_NOSTREAM, TASKS, _isSend, _isSendInterface, isCommand, isInterrupted };
436
+ export { CACHE_NS_WRITES, CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_ABORT_SIGNALS, CONFIG_KEY_CALL, CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_CHECKPOINT_ID, CONFIG_KEY_CHECKPOINT_MAP, CONFIG_KEY_CHECKPOINT_NS, CONFIG_KEY_DURABILITY, CONFIG_KEY_NODE_FINISHED, CONFIG_KEY_PREVIOUS_STATE, CONFIG_KEY_READ, CONFIG_KEY_RESUME_MAP, CONFIG_KEY_RESUMING, CONFIG_KEY_SCRATCHPAD, CONFIG_KEY_SEND, CONFIG_KEY_STREAM, CONFIG_KEY_TASK_ID, COPY, Command, CommandInstance, END, ERROR, INPUT, INTERRUPT, NO_WRITES, NULL_TASK_ID, Overwrite, PREVIOUS, PULL, PUSH, RESERVED, RESUME, RETURN, SELF, START, Send, TAG_HIDDEN, TAG_NOSTREAM, TASKS, _getOverwriteValue, _isOverwriteValue, _isSend, _isSendInterface, isCommand, isInterrupted };
362
437
  //# sourceMappingURL=constants.js.map