@langchain/langgraph 1.0.14 → 1.1.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 (184) hide show
  1. package/dist/channels/base.cjs +11 -0
  2. package/dist/channels/base.cjs.map +1 -1
  3. package/dist/channels/base.d.cts +9 -0
  4. package/dist/channels/base.d.cts.map +1 -1
  5. package/dist/channels/base.d.ts +9 -0
  6. package/dist/channels/base.d.ts.map +1 -1
  7. package/dist/channels/base.js +11 -0
  8. package/dist/channels/base.js.map +1 -1
  9. package/dist/channels/binop.cjs +13 -0
  10. package/dist/channels/binop.cjs.map +1 -1
  11. package/dist/channels/binop.d.cts +6 -0
  12. package/dist/channels/binop.d.cts.map +1 -1
  13. package/dist/channels/binop.d.ts +6 -0
  14. package/dist/channels/binop.d.ts.map +1 -1
  15. package/dist/channels/binop.js +13 -0
  16. package/dist/channels/binop.js.map +1 -1
  17. package/dist/channels/index.cjs +2 -0
  18. package/dist/channels/index.d.cts +2 -1
  19. package/dist/channels/index.d.ts +2 -1
  20. package/dist/channels/index.js +2 -1
  21. package/dist/channels/untracked_value.cjs +83 -0
  22. package/dist/channels/untracked_value.cjs.map +1 -0
  23. package/dist/channels/untracked_value.d.cts +64 -0
  24. package/dist/channels/untracked_value.d.cts.map +1 -0
  25. package/dist/channels/untracked_value.d.ts +64 -0
  26. package/dist/channels/untracked_value.d.ts.map +1 -0
  27. package/dist/channels/untracked_value.js +83 -0
  28. package/dist/channels/untracked_value.js.map +1 -0
  29. package/dist/constants.cjs.map +1 -1
  30. package/dist/constants.d.cts +2 -2
  31. package/dist/constants.d.cts.map +1 -1
  32. package/dist/constants.d.ts +2 -2
  33. package/dist/constants.d.ts.map +1 -1
  34. package/dist/constants.js.map +1 -1
  35. package/dist/errors.cjs +36 -0
  36. package/dist/errors.cjs.map +1 -1
  37. package/dist/errors.d.cts +30 -1
  38. package/dist/errors.d.cts.map +1 -1
  39. package/dist/errors.d.ts +30 -1
  40. package/dist/errors.d.ts.map +1 -1
  41. package/dist/errors.js +36 -1
  42. package/dist/errors.js.map +1 -1
  43. package/dist/func/index.cjs +1 -1
  44. package/dist/func/index.cjs.map +1 -1
  45. package/dist/func/index.js +1 -1
  46. package/dist/func/index.js.map +1 -1
  47. package/dist/graph/index.cjs +1 -0
  48. package/dist/graph/index.js +2 -1
  49. package/dist/graph/message.cjs +2 -47
  50. package/dist/graph/message.cjs.map +1 -1
  51. package/dist/graph/message.d.cts +4 -11
  52. package/dist/graph/message.d.cts.map +1 -1
  53. package/dist/graph/message.d.ts +4 -11
  54. package/dist/graph/message.d.ts.map +1 -1
  55. package/dist/graph/message.js +2 -45
  56. package/dist/graph/message.js.map +1 -1
  57. package/dist/graph/messages_annotation.cjs +3 -3
  58. package/dist/graph/messages_annotation.cjs.map +1 -1
  59. package/dist/graph/messages_annotation.d.cts +2 -2
  60. package/dist/graph/messages_annotation.d.cts.map +1 -1
  61. package/dist/graph/messages_annotation.d.ts +1 -1
  62. package/dist/graph/messages_annotation.d.ts.map +1 -1
  63. package/dist/graph/messages_annotation.js +1 -1
  64. package/dist/graph/messages_annotation.js.map +1 -1
  65. package/dist/graph/messages_reducer.cjs +85 -0
  66. package/dist/graph/messages_reducer.cjs.map +1 -0
  67. package/dist/graph/messages_reducer.d.cts +54 -0
  68. package/dist/graph/messages_reducer.d.cts.map +1 -0
  69. package/dist/graph/messages_reducer.d.ts +54 -0
  70. package/dist/graph/messages_reducer.d.ts.map +1 -0
  71. package/dist/graph/messages_reducer.js +84 -0
  72. package/dist/graph/messages_reducer.js.map +1 -0
  73. package/dist/graph/state.cjs +30 -10
  74. package/dist/graph/state.cjs.map +1 -1
  75. package/dist/graph/state.d.cts +24 -15
  76. package/dist/graph/state.d.cts.map +1 -1
  77. package/dist/graph/state.d.ts +24 -15
  78. package/dist/graph/state.d.ts.map +1 -1
  79. package/dist/graph/state.js +31 -11
  80. package/dist/graph/state.js.map +1 -1
  81. package/dist/graph/types.d.cts +127 -0
  82. package/dist/graph/types.d.cts.map +1 -0
  83. package/dist/graph/types.d.ts +127 -0
  84. package/dist/graph/types.d.ts.map +1 -0
  85. package/dist/graph/zod/plugin.cjs +2 -2
  86. package/dist/graph/zod/plugin.cjs.map +1 -1
  87. package/dist/graph/zod/plugin.js +3 -3
  88. package/dist/graph/zod/plugin.js.map +1 -1
  89. package/dist/graph/zod/zod-registry.d.cts.map +1 -1
  90. package/dist/hash.cjs +4 -4
  91. package/dist/hash.cjs.map +1 -1
  92. package/dist/hash.js +4 -4
  93. package/dist/hash.js.map +1 -1
  94. package/dist/index.cjs +21 -3
  95. package/dist/index.cjs.map +1 -1
  96. package/dist/index.d.cts +12 -3
  97. package/dist/index.d.ts +12 -3
  98. package/dist/index.js +11 -3
  99. package/dist/index.js.map +1 -1
  100. package/dist/prebuilt/agent_executor.d.cts +5 -5
  101. package/dist/prebuilt/agent_executor.d.cts.map +1 -1
  102. package/dist/prebuilt/agent_executor.d.ts +5 -5
  103. package/dist/prebuilt/agent_executor.d.ts.map +1 -1
  104. package/dist/prebuilt/react_agent_executor.cjs +7 -6
  105. package/dist/prebuilt/react_agent_executor.cjs.map +1 -1
  106. package/dist/prebuilt/react_agent_executor.d.cts +4 -4
  107. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
  108. package/dist/prebuilt/react_agent_executor.d.ts +4 -4
  109. package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
  110. package/dist/prebuilt/react_agent_executor.js +5 -4
  111. package/dist/prebuilt/react_agent_executor.js.map +1 -1
  112. package/dist/pregel/algo.cjs +19 -0
  113. package/dist/pregel/algo.cjs.map +1 -1
  114. package/dist/pregel/algo.d.cts.map +1 -1
  115. package/dist/pregel/algo.d.ts.map +1 -1
  116. package/dist/pregel/algo.js +19 -1
  117. package/dist/pregel/algo.js.map +1 -1
  118. package/dist/pregel/loop.cjs +18 -3
  119. package/dist/pregel/loop.cjs.map +1 -1
  120. package/dist/pregel/loop.js +20 -5
  121. package/dist/pregel/loop.js.map +1 -1
  122. package/dist/pregel/runner.cjs +1 -1
  123. package/dist/pregel/runner.cjs.map +1 -1
  124. package/dist/pregel/runner.js +1 -1
  125. package/dist/pregel/runner.js.map +1 -1
  126. package/dist/state/adapter.cjs +53 -0
  127. package/dist/state/adapter.cjs.map +1 -0
  128. package/dist/state/adapter.d.cts +33 -0
  129. package/dist/state/adapter.d.cts.map +1 -0
  130. package/dist/state/adapter.d.ts +33 -0
  131. package/dist/state/adapter.d.ts.map +1 -0
  132. package/dist/state/adapter.js +52 -0
  133. package/dist/state/adapter.js.map +1 -0
  134. package/dist/state/index.cjs +8 -0
  135. package/dist/state/index.js +10 -0
  136. package/dist/state/prebuilt/index.cjs +1 -0
  137. package/dist/state/prebuilt/index.js +3 -0
  138. package/dist/state/prebuilt/messages.cjs +19 -0
  139. package/dist/state/prebuilt/messages.cjs.map +1 -0
  140. package/dist/state/prebuilt/messages.d.cts +10 -0
  141. package/dist/state/prebuilt/messages.d.cts.map +1 -0
  142. package/dist/state/prebuilt/messages.d.ts +10 -0
  143. package/dist/state/prebuilt/messages.d.ts.map +1 -0
  144. package/dist/state/prebuilt/messages.js +19 -0
  145. package/dist/state/prebuilt/messages.js.map +1 -0
  146. package/dist/state/schema.cjs +171 -0
  147. package/dist/state/schema.cjs.map +1 -0
  148. package/dist/state/schema.d.cts +208 -0
  149. package/dist/state/schema.d.cts.map +1 -0
  150. package/dist/state/schema.d.ts +208 -0
  151. package/dist/state/schema.d.ts.map +1 -0
  152. package/dist/state/schema.js +171 -0
  153. package/dist/state/schema.js.map +1 -0
  154. package/dist/state/types.cjs +17 -0
  155. package/dist/state/types.cjs.map +1 -0
  156. package/dist/state/types.d.cts +128 -0
  157. package/dist/state/types.d.cts.map +1 -0
  158. package/dist/state/types.d.ts +128 -0
  159. package/dist/state/types.d.ts.map +1 -0
  160. package/dist/state/types.js +14 -0
  161. package/dist/state/types.js.map +1 -0
  162. package/dist/state/values/index.cjs +2 -0
  163. package/dist/state/values/index.js +4 -0
  164. package/dist/state/values/reduced.cjs +72 -0
  165. package/dist/state/values/reduced.cjs.map +1 -0
  166. package/dist/state/values/reduced.d.cts +155 -0
  167. package/dist/state/values/reduced.d.cts.map +1 -0
  168. package/dist/state/values/reduced.d.ts +155 -0
  169. package/dist/state/values/reduced.d.ts.map +1 -0
  170. package/dist/state/values/reduced.js +71 -0
  171. package/dist/state/values/reduced.js.map +1 -0
  172. package/dist/state/values/untracked.cjs +64 -0
  173. package/dist/state/values/untracked.cjs.map +1 -0
  174. package/dist/state/values/untracked.d.cts +74 -0
  175. package/dist/state/values/untracked.d.cts.map +1 -0
  176. package/dist/state/values/untracked.d.ts +74 -0
  177. package/dist/state/values/untracked.d.ts.map +1 -0
  178. package/dist/state/values/untracked.js +63 -0
  179. package/dist/state/values/untracked.js.map +1 -0
  180. package/dist/web.cjs +26 -7
  181. package/dist/web.d.cts +12 -3
  182. package/dist/web.d.ts +12 -3
  183. package/dist/web.js +13 -4
  184. package/package.json +5 -4
@@ -44,6 +44,17 @@ var BaseChannel = class {
44
44
  throw error;
45
45
  }
46
46
  }
47
+ /**
48
+ * Compare this channel with another channel for equality.
49
+ * Used to determine if two channels with the same key are semantically equivalent.
50
+ * Subclasses should override this method to provide a meaningful comparison.
51
+ *
52
+ * @param {BaseChannel} other - The other channel to compare with.
53
+ * @returns {boolean} True if the channels are equal, false otherwise.
54
+ */
55
+ equals(other) {
56
+ return this === other;
57
+ }
47
58
  };
48
59
  const IS_ONLY_BASE_CHANNEL = Symbol.for("LG_IS_ONLY_BASE_CHANNEL");
49
60
  function getOnlyChannels(channels) {
@@ -1 +1 @@
1
- {"version":3,"file":"base.cjs","names":["EmptyChannelError"],"sources":["../../src/channels/base.ts"],"sourcesContent":["import {\n ReadonlyCheckpoint,\n uuid6,\n Checkpoint,\n} from \"@langchain/langgraph-checkpoint\";\nimport { EmptyChannelError } from \"../errors.js\";\n\nexport function isBaseChannel(obj: unknown): obj is BaseChannel {\n return obj != null && (obj as BaseChannel).lg_is_channel === true;\n}\n\n/** @internal */\nexport abstract class BaseChannel<\n ValueType = unknown,\n UpdateType = unknown,\n CheckpointType = unknown\n> {\n ValueType: ValueType;\n\n UpdateType: UpdateType;\n\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n\n /** @ignore */\n lg_is_channel = true;\n\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean {\n return false;\n }\n\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean {\n return false;\n }\n\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean {\n try {\n this.get();\n return true;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n return false;\n }\n throw error;\n }\n }\n}\n\nconst IS_ONLY_BASE_CHANNEL = Symbol.for(\"LG_IS_ONLY_BASE_CHANNEL\");\nexport function getOnlyChannels(\n channels: Record<string, BaseChannel>\n): Record<string, BaseChannel> {\n // @ts-expect-error - we know it's a record of base channels\n if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;\n\n const newChannels = {} as Record<string, BaseChannel>;\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n const value = channels[k];\n if (isBaseChannel(value)) newChannels[k] = value;\n }\n\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function emptyChannels<Cc extends Record<string, BaseChannel>>(\n channels: Cc,\n checkpoint: ReadonlyCheckpoint\n): Cc {\n const filteredChannels = getOnlyChannels(channels) as Cc;\n\n const newChannels = {} as Cc;\n for (const k in filteredChannels) {\n if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;\n const channelValue = checkpoint.channel_values[k];\n newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);\n }\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function createCheckpoint<ValueType>(\n checkpoint: ReadonlyCheckpoint,\n channels: Record<string, BaseChannel<ValueType>> | undefined,\n step: number,\n options?: { id?: string }\n): Checkpoint {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let values: Record<string, any>;\n if (channels === undefined) {\n values = checkpoint.channel_values;\n } else {\n values = {};\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n try {\n values[k] = channels[k].checkpoint();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n // no-op\n } else {\n throw error; // Rethrow unexpected errors\n }\n }\n }\n }\n\n return {\n v: 4,\n id: options?.id ?? uuid6(step),\n ts: new Date().toISOString(),\n channel_values: values,\n channel_versions: checkpoint.channel_versions,\n versions_seen: checkpoint.versions_seen,\n };\n}\n"],"mappings":";;;;AAOA,SAAgB,cAAc,KAAkC;AAC9D,QAAO,OAAO,QAAS,IAAoB,kBAAkB;;;AAI/D,IAAsB,cAAtB,MAIE;CACA;CAEA;;CAQA,gBAAgB;;;;;;;;CAkDhB,UAAmB;AACjB,SAAO;;;;;;;;CAST,SAAkB;AAChB,SAAO;;;;;;;CAQT,cAAuB;AACrB,MAAI;AACF,QAAK,KAAK;AACV,UAAO;WAEA,OAAY;AACnB,OAAI,MAAM,SAASA,iCAAkB,kBACnC,QAAO;AAET,SAAM;;;;AAKZ,MAAM,uBAAuB,OAAO,IAAI,0BAA0B;AAClE,SAAgB,gBACd,UAC6B;AAE7B,KAAI,SAAS,0BAA0B,KAAM,QAAO;CAEpD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,UAAU;AACxB,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;EACxD,MAAM,QAAQ,SAAS;AACvB,MAAI,cAAc,MAAM,CAAE,aAAY,KAAK;;AAG7C,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,cACd,UACA,YACI;CACJ,MAAM,mBAAmB,gBAAgB,SAAS;CAElD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,kBAAkB;AAChC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,kBAAkB,EAAE,CAAE;EAChE,MAAM,eAAe,WAAW,eAAe;AAC/C,cAAY,KAAK,iBAAiB,GAAG,eAAe,aAAa;;AAEnE,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,iBACd,YACA,UACA,MACA,SACY;CAEZ,IAAI;AACJ,KAAI,aAAa,OACf,UAAS,WAAW;MACf;AACL,WAAS,EAAE;AACX,OAAK,MAAM,KAAK,UAAU;AACxB,OAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;AACxD,OAAI;AACF,WAAO,KAAK,SAAS,GAAG,YAAY;YAE7B,OAAY;AACnB,QAAI,MAAM,SAASA,iCAAkB,mBAAmB,OAGtD,OAAM;;;;AAMd,QAAO;EACL,GAAG;EACH,IAAI,SAAS,iDAAY,KAAK;EAC9B,qBAAI,IAAI,MAAM,EAAC,aAAa;EAC5B,gBAAgB;EAChB,kBAAkB,WAAW;EAC7B,eAAe,WAAW;EAC3B"}
1
+ {"version":3,"file":"base.cjs","names":["EmptyChannelError"],"sources":["../../src/channels/base.ts"],"sourcesContent":["import {\n ReadonlyCheckpoint,\n uuid6,\n Checkpoint,\n} from \"@langchain/langgraph-checkpoint\";\nimport { EmptyChannelError } from \"../errors.js\";\n\nexport function isBaseChannel(obj: unknown): obj is BaseChannel {\n return obj != null && (obj as BaseChannel).lg_is_channel === true;\n}\n\n/** @internal */\nexport abstract class BaseChannel<\n ValueType = unknown,\n UpdateType = unknown,\n CheckpointType = unknown\n> {\n ValueType: ValueType;\n\n UpdateType: UpdateType;\n\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n\n /** @ignore */\n lg_is_channel = true;\n\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean {\n return false;\n }\n\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean {\n return false;\n }\n\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean {\n try {\n this.get();\n return true;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n return false;\n }\n throw error;\n }\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Used to determine if two channels with the same key are semantically equivalent.\n * Subclasses should override this method to provide a meaningful comparison.\n *\n * @param {BaseChannel} other - The other channel to compare with.\n * @returns {boolean} True if the channels are equal, false otherwise.\n */\n equals(other: BaseChannel): boolean {\n return this === other;\n }\n}\n\nconst IS_ONLY_BASE_CHANNEL = Symbol.for(\"LG_IS_ONLY_BASE_CHANNEL\");\nexport function getOnlyChannels(\n channels: Record<string, BaseChannel>\n): Record<string, BaseChannel> {\n // @ts-expect-error - we know it's a record of base channels\n if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;\n\n const newChannels = {} as Record<string, BaseChannel>;\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n const value = channels[k];\n if (isBaseChannel(value)) newChannels[k] = value;\n }\n\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function emptyChannels<Cc extends Record<string, BaseChannel>>(\n channels: Cc,\n checkpoint: ReadonlyCheckpoint\n): Cc {\n const filteredChannels = getOnlyChannels(channels) as Cc;\n\n const newChannels = {} as Cc;\n for (const k in filteredChannels) {\n if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;\n const channelValue = checkpoint.channel_values[k];\n newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);\n }\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function createCheckpoint<ValueType>(\n checkpoint: ReadonlyCheckpoint,\n channels: Record<string, BaseChannel<ValueType>> | undefined,\n step: number,\n options?: { id?: string }\n): Checkpoint {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let values: Record<string, any>;\n if (channels === undefined) {\n values = checkpoint.channel_values;\n } else {\n values = {};\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n try {\n values[k] = channels[k].checkpoint();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n // no-op\n } else {\n throw error; // Rethrow unexpected errors\n }\n }\n }\n }\n\n return {\n v: 4,\n id: options?.id ?? uuid6(step),\n ts: new Date().toISOString(),\n channel_values: values,\n channel_versions: checkpoint.channel_versions,\n versions_seen: checkpoint.versions_seen,\n };\n}\n"],"mappings":";;;;AAOA,SAAgB,cAAc,KAAkC;AAC9D,QAAO,OAAO,QAAS,IAAoB,kBAAkB;;;AAI/D,IAAsB,cAAtB,MAIE;CACA;CAEA;;CAQA,gBAAgB;;;;;;;;CAkDhB,UAAmB;AACjB,SAAO;;;;;;;;CAST,SAAkB;AAChB,SAAO;;;;;;;CAQT,cAAuB;AACrB,MAAI;AACF,QAAK,KAAK;AACV,UAAO;WAEA,OAAY;AACnB,OAAI,MAAM,SAASA,iCAAkB,kBACnC,QAAO;AAET,SAAM;;;;;;;;;;;CAYV,OAAO,OAA6B;AAClC,SAAO,SAAS;;;AAIpB,MAAM,uBAAuB,OAAO,IAAI,0BAA0B;AAClE,SAAgB,gBACd,UAC6B;AAE7B,KAAI,SAAS,0BAA0B,KAAM,QAAO;CAEpD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,UAAU;AACxB,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;EACxD,MAAM,QAAQ,SAAS;AACvB,MAAI,cAAc,MAAM,CAAE,aAAY,KAAK;;AAG7C,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,cACd,UACA,YACI;CACJ,MAAM,mBAAmB,gBAAgB,SAAS;CAElD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,kBAAkB;AAChC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,kBAAkB,EAAE,CAAE;EAChE,MAAM,eAAe,WAAW,eAAe;AAC/C,cAAY,KAAK,iBAAiB,GAAG,eAAe,aAAa;;AAEnE,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,iBACd,YACA,UACA,MACA,SACY;CAEZ,IAAI;AACJ,KAAI,aAAa,OACf,UAAS,WAAW;MACf;AACL,WAAS,EAAE;AACX,OAAK,MAAM,KAAK,UAAU;AACxB,OAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;AACxD,OAAI;AACF,WAAO,KAAK,SAAS,GAAG,YAAY;YAE7B,OAAY;AACnB,QAAI,MAAM,SAASA,iCAAkB,mBAAmB,OAGtD,OAAM;;;;AAMd,QAAO;EACL,GAAG;EACH,IAAI,SAAS,iDAAY,KAAK;EAC9B,qBAAI,IAAI,MAAM,EAAC,aAAa;EAC5B,gBAAgB;EAChB,kBAAkB,WAAW;EAC7B,eAAe,WAAW;EAC3B"}
@@ -69,6 +69,15 @@ declare abstract class BaseChannel<ValueType = unknown, UpdateType = unknown, Ch
69
69
  * implementation than calling get() and catching EmptyChannelError.
70
70
  */
71
71
  isAvailable(): boolean;
72
+ /**
73
+ * Compare this channel with another channel for equality.
74
+ * Used to determine if two channels with the same key are semantically equivalent.
75
+ * Subclasses should override this method to provide a meaningful comparison.
76
+ *
77
+ * @param {BaseChannel} other - The other channel to compare with.
78
+ * @returns {boolean} True if the channels are equal, false otherwise.
79
+ */
80
+ equals(other: BaseChannel): boolean;
72
81
  }
73
82
  declare function emptyChannels<Cc extends Record<string, BaseChannel>>(channels: Cc, checkpoint: ReadonlyCheckpoint): Cc;
74
83
  declare function createCheckpoint<ValueType>(checkpoint: ReadonlyCheckpoint, channels: Record<string, BaseChannel<ValueType>> | undefined, step: number, options?: {
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.cts","names":["ReadonlyCheckpoint","Checkpoint","isBaseChannel","BaseChannel","ValueType","UpdateType","CheckpointType","getOnlyChannels","Record","emptyChannels","Cc","createCheckpoint"],"sources":["../../src/channels/base.d.ts"],"sourcesContent":["import { ReadonlyCheckpoint, Checkpoint } from \"@langchain/langgraph-checkpoint\";\nexport declare function isBaseChannel(obj: unknown): obj is BaseChannel;\n/** @internal */\nexport declare abstract class BaseChannel<ValueType = unknown, UpdateType = unknown, CheckpointType = unknown> {\n ValueType: ValueType;\n UpdateType: UpdateType;\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n /** @ignore */\n lg_is_channel: boolean;\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean;\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean;\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean;\n}\nexport declare function getOnlyChannels(channels: Record<string, BaseChannel>): Record<string, BaseChannel>;\nexport declare function emptyChannels<Cc extends Record<string, BaseChannel>>(channels: Cc, checkpoint: ReadonlyCheckpoint): Cc;\nexport declare function createCheckpoint<ValueType>(checkpoint: ReadonlyCheckpoint, channels: Record<string, BaseChannel<ValueType>> | undefined, step: number, options?: {\n id?: string;\n}): Checkpoint;\n"],"mappings":";;;;AAG8BG,uBAAAA,WAAW,CAAA,YAAA,OAAA,EAAA,aAAA,OAAA,EAAA,iBAAA,OAAA,CAAA,CAAA;EAAA,SAAA,EAC1BC,SAD0B;YAC1BA,EACCC,UADDD;;;;WAqCKA,aAAAA,EAAAA,MAAAA;;EAOqB,aAAA,EAAA,OAAA;EAwBjBK;;;;;;;;EACAE,SAAAA,cAAgB,CAAA,UAAA,CAAA,EArDCL,cAqDD,CAAA,EAAA,IAAA;EAAA;;;;;;;;;;;;;0BAvCZD;;;;;;;kBAORD;;;;;;;yBAOOE;;;;;;;;;;;;;;;;;;;;;;;iBAwBHG,yBAAyBD,eAAeL,wBAAwBO,gBAAgBV,qBAAqBU;iBACrGC,wCAAwCX,8BAA8BQ,eAAeL,YAAYC;;IAErHH"}
1
+ {"version":3,"file":"base.d.cts","names":["ReadonlyCheckpoint","Checkpoint","isBaseChannel","BaseChannel","ValueType","UpdateType","CheckpointType","getOnlyChannels","Record","emptyChannels","Cc","createCheckpoint"],"sources":["../../src/channels/base.d.ts"],"sourcesContent":["import { ReadonlyCheckpoint, Checkpoint } from \"@langchain/langgraph-checkpoint\";\nexport declare function isBaseChannel(obj: unknown): obj is BaseChannel;\n/** @internal */\nexport declare abstract class BaseChannel<ValueType = unknown, UpdateType = unknown, CheckpointType = unknown> {\n ValueType: ValueType;\n UpdateType: UpdateType;\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n /** @ignore */\n lg_is_channel: boolean;\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean;\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean;\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean;\n /**\n * Compare this channel with another channel for equality.\n * Used to determine if two channels with the same key are semantically equivalent.\n * Subclasses should override this method to provide a meaningful comparison.\n *\n * @param {BaseChannel} other - The other channel to compare with.\n * @returns {boolean} True if the channels are equal, false otherwise.\n */\n equals(other: BaseChannel): boolean;\n}\nexport declare function getOnlyChannels(channels: Record<string, BaseChannel>): Record<string, BaseChannel>;\nexport declare function emptyChannels<Cc extends Record<string, BaseChannel>>(channels: Cc, checkpoint: ReadonlyCheckpoint): Cc;\nexport declare function createCheckpoint<ValueType>(checkpoint: ReadonlyCheckpoint, channels: Record<string, BaseChannel<ValueType>> | undefined, step: number, options?: {\n id?: string;\n}): Checkpoint;\n"],"mappings":";;;;AAG8BG,uBAAAA,WAAW,CAAA,YAAA,OAAA,EAAA,aAAA,OAAA,EAAA,iBAAA,OAAA,CAAA,CAAA;EAAA,SAAA,EAC1BC,SAD0B;YAC1BA,EACCC,UADDD;;;;WAqCKA,aAAAA,EAAAA,MAAAA;;eAqCFD,EAAAA,OAAAA;EAAW;AAG7B;;;;;;;EAA+H,SAAA,cAAA,CAAA,UAAA,CAAA,EA7DtFG,cA6DsF,CAAA,EAAA,IAAA;EACvGK;;;;;;;;;;;;;0BAhDIN;;;;;;;kBAORD;;;;;;;yBAOOE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA8BTH;;iBAGMM,yBAAyBD,eAAeL,wBAAwBO,gBAAgBV,qBAAqBU;iBACrGC,wCAAwCX,8BAA8BQ,eAAeL,YAAYC;;IAErHH"}
@@ -69,6 +69,15 @@ declare abstract class BaseChannel<ValueType = unknown, UpdateType = unknown, Ch
69
69
  * implementation than calling get() and catching EmptyChannelError.
70
70
  */
71
71
  isAvailable(): boolean;
72
+ /**
73
+ * Compare this channel with another channel for equality.
74
+ * Used to determine if two channels with the same key are semantically equivalent.
75
+ * Subclasses should override this method to provide a meaningful comparison.
76
+ *
77
+ * @param {BaseChannel} other - The other channel to compare with.
78
+ * @returns {boolean} True if the channels are equal, false otherwise.
79
+ */
80
+ equals(other: BaseChannel): boolean;
72
81
  }
73
82
  declare function emptyChannels<Cc extends Record<string, BaseChannel>>(channels: Cc, checkpoint: ReadonlyCheckpoint): Cc;
74
83
  declare function createCheckpoint<ValueType>(checkpoint: ReadonlyCheckpoint, channels: Record<string, BaseChannel<ValueType>> | undefined, step: number, options?: {
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","names":["ReadonlyCheckpoint","Checkpoint","isBaseChannel","BaseChannel","ValueType","UpdateType","CheckpointType","getOnlyChannels","Record","emptyChannels","Cc","createCheckpoint"],"sources":["../../src/channels/base.d.ts"],"sourcesContent":["import { ReadonlyCheckpoint, Checkpoint } from \"@langchain/langgraph-checkpoint\";\nexport declare function isBaseChannel(obj: unknown): obj is BaseChannel;\n/** @internal */\nexport declare abstract class BaseChannel<ValueType = unknown, UpdateType = unknown, CheckpointType = unknown> {\n ValueType: ValueType;\n UpdateType: UpdateType;\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n /** @ignore */\n lg_is_channel: boolean;\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean;\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean;\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean;\n}\nexport declare function getOnlyChannels(channels: Record<string, BaseChannel>): Record<string, BaseChannel>;\nexport declare function emptyChannels<Cc extends Record<string, BaseChannel>>(channels: Cc, checkpoint: ReadonlyCheckpoint): Cc;\nexport declare function createCheckpoint<ValueType>(checkpoint: ReadonlyCheckpoint, channels: Record<string, BaseChannel<ValueType>> | undefined, step: number, options?: {\n id?: string;\n}): Checkpoint;\n"],"mappings":";;;;AAG8BG,uBAAAA,WAAW,CAAA,YAAA,OAAA,EAAA,aAAA,OAAA,EAAA,iBAAA,OAAA,CAAA,CAAA;EAAA,SAAA,EAC1BC,SAD0B;YAC1BA,EACCC,UADDD;;;;WAqCKA,aAAAA,EAAAA,MAAAA;;EAOqB,aAAA,EAAA,OAAA;EAwBjBK;;;;;;;;EACAE,SAAAA,cAAgB,CAAA,UAAA,CAAA,EArDCL,cAqDD,CAAA,EAAA,IAAA;EAAA;;;;;;;;;;;;;0BAvCZD;;;;;;;kBAORD;;;;;;;yBAOOE;;;;;;;;;;;;;;;;;;;;;;;iBAwBHG,yBAAyBD,eAAeL,wBAAwBO,gBAAgBV,qBAAqBU;iBACrGC,wCAAwCX,8BAA8BQ,eAAeL,YAAYC;;IAErHH"}
1
+ {"version":3,"file":"base.d.ts","names":["ReadonlyCheckpoint","Checkpoint","isBaseChannel","BaseChannel","ValueType","UpdateType","CheckpointType","getOnlyChannels","Record","emptyChannels","Cc","createCheckpoint"],"sources":["../../src/channels/base.d.ts"],"sourcesContent":["import { ReadonlyCheckpoint, Checkpoint } from \"@langchain/langgraph-checkpoint\";\nexport declare function isBaseChannel(obj: unknown): obj is BaseChannel;\n/** @internal */\nexport declare abstract class BaseChannel<ValueType = unknown, UpdateType = unknown, CheckpointType = unknown> {\n ValueType: ValueType;\n UpdateType: UpdateType;\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n /** @ignore */\n lg_is_channel: boolean;\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean;\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean;\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean;\n /**\n * Compare this channel with another channel for equality.\n * Used to determine if two channels with the same key are semantically equivalent.\n * Subclasses should override this method to provide a meaningful comparison.\n *\n * @param {BaseChannel} other - The other channel to compare with.\n * @returns {boolean} True if the channels are equal, false otherwise.\n */\n equals(other: BaseChannel): boolean;\n}\nexport declare function getOnlyChannels(channels: Record<string, BaseChannel>): Record<string, BaseChannel>;\nexport declare function emptyChannels<Cc extends Record<string, BaseChannel>>(channels: Cc, checkpoint: ReadonlyCheckpoint): Cc;\nexport declare function createCheckpoint<ValueType>(checkpoint: ReadonlyCheckpoint, channels: Record<string, BaseChannel<ValueType>> | undefined, step: number, options?: {\n id?: string;\n}): Checkpoint;\n"],"mappings":";;;;AAG8BG,uBAAAA,WAAW,CAAA,YAAA,OAAA,EAAA,aAAA,OAAA,EAAA,iBAAA,OAAA,CAAA,CAAA;EAAA,SAAA,EAC1BC,SAD0B;YAC1BA,EACCC,UADDD;;;;WAqCKA,aAAAA,EAAAA,MAAAA;;eAqCFD,EAAAA,OAAAA;EAAW;AAG7B;;;;;;;EAA+H,SAAA,cAAA,CAAA,UAAA,CAAA,EA7DtFG,cA6DsF,CAAA,EAAA,IAAA;EACvGK;;;;;;;;;;;;;0BAhDIN;;;;;;;kBAORD;;;;;;;yBAOOE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA8BTH;;iBAGMM,yBAAyBD,eAAeL,wBAAwBO,gBAAgBV,qBAAqBU;iBACrGC,wCAAwCX,8BAA8BQ,eAAeL,YAAYC;;IAErHH"}
@@ -44,6 +44,17 @@ var BaseChannel = class {
44
44
  throw error;
45
45
  }
46
46
  }
47
+ /**
48
+ * Compare this channel with another channel for equality.
49
+ * Used to determine if two channels with the same key are semantically equivalent.
50
+ * Subclasses should override this method to provide a meaningful comparison.
51
+ *
52
+ * @param {BaseChannel} other - The other channel to compare with.
53
+ * @returns {boolean} True if the channels are equal, false otherwise.
54
+ */
55
+ equals(other) {
56
+ return this === other;
57
+ }
47
58
  };
48
59
  const IS_ONLY_BASE_CHANNEL = Symbol.for("LG_IS_ONLY_BASE_CHANNEL");
49
60
  function getOnlyChannels(channels) {
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":[],"sources":["../../src/channels/base.ts"],"sourcesContent":["import {\n ReadonlyCheckpoint,\n uuid6,\n Checkpoint,\n} from \"@langchain/langgraph-checkpoint\";\nimport { EmptyChannelError } from \"../errors.js\";\n\nexport function isBaseChannel(obj: unknown): obj is BaseChannel {\n return obj != null && (obj as BaseChannel).lg_is_channel === true;\n}\n\n/** @internal */\nexport abstract class BaseChannel<\n ValueType = unknown,\n UpdateType = unknown,\n CheckpointType = unknown\n> {\n ValueType: ValueType;\n\n UpdateType: UpdateType;\n\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n\n /** @ignore */\n lg_is_channel = true;\n\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean {\n return false;\n }\n\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean {\n return false;\n }\n\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean {\n try {\n this.get();\n return true;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n return false;\n }\n throw error;\n }\n }\n}\n\nconst IS_ONLY_BASE_CHANNEL = Symbol.for(\"LG_IS_ONLY_BASE_CHANNEL\");\nexport function getOnlyChannels(\n channels: Record<string, BaseChannel>\n): Record<string, BaseChannel> {\n // @ts-expect-error - we know it's a record of base channels\n if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;\n\n const newChannels = {} as Record<string, BaseChannel>;\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n const value = channels[k];\n if (isBaseChannel(value)) newChannels[k] = value;\n }\n\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function emptyChannels<Cc extends Record<string, BaseChannel>>(\n channels: Cc,\n checkpoint: ReadonlyCheckpoint\n): Cc {\n const filteredChannels = getOnlyChannels(channels) as Cc;\n\n const newChannels = {} as Cc;\n for (const k in filteredChannels) {\n if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;\n const channelValue = checkpoint.channel_values[k];\n newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);\n }\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function createCheckpoint<ValueType>(\n checkpoint: ReadonlyCheckpoint,\n channels: Record<string, BaseChannel<ValueType>> | undefined,\n step: number,\n options?: { id?: string }\n): Checkpoint {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let values: Record<string, any>;\n if (channels === undefined) {\n values = checkpoint.channel_values;\n } else {\n values = {};\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n try {\n values[k] = channels[k].checkpoint();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n // no-op\n } else {\n throw error; // Rethrow unexpected errors\n }\n }\n }\n }\n\n return {\n v: 4,\n id: options?.id ?? uuid6(step),\n ts: new Date().toISOString(),\n channel_values: values,\n channel_versions: checkpoint.channel_versions,\n versions_seen: checkpoint.versions_seen,\n };\n}\n"],"mappings":";;;;AAOA,SAAgB,cAAc,KAAkC;AAC9D,QAAO,OAAO,QAAS,IAAoB,kBAAkB;;;AAI/D,IAAsB,cAAtB,MAIE;CACA;CAEA;;CAQA,gBAAgB;;;;;;;;CAkDhB,UAAmB;AACjB,SAAO;;;;;;;;CAST,SAAkB;AAChB,SAAO;;;;;;;CAQT,cAAuB;AACrB,MAAI;AACF,QAAK,KAAK;AACV,UAAO;WAEA,OAAY;AACnB,OAAI,MAAM,SAAS,kBAAkB,kBACnC,QAAO;AAET,SAAM;;;;AAKZ,MAAM,uBAAuB,OAAO,IAAI,0BAA0B;AAClE,SAAgB,gBACd,UAC6B;AAE7B,KAAI,SAAS,0BAA0B,KAAM,QAAO;CAEpD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,UAAU;AACxB,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;EACxD,MAAM,QAAQ,SAAS;AACvB,MAAI,cAAc,MAAM,CAAE,aAAY,KAAK;;AAG7C,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,cACd,UACA,YACI;CACJ,MAAM,mBAAmB,gBAAgB,SAAS;CAElD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,kBAAkB;AAChC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,kBAAkB,EAAE,CAAE;EAChE,MAAM,eAAe,WAAW,eAAe;AAC/C,cAAY,KAAK,iBAAiB,GAAG,eAAe,aAAa;;AAEnE,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,iBACd,YACA,UACA,MACA,SACY;CAEZ,IAAI;AACJ,KAAI,aAAa,OACf,UAAS,WAAW;MACf;AACL,WAAS,EAAE;AACX,OAAK,MAAM,KAAK,UAAU;AACxB,OAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;AACxD,OAAI;AACF,WAAO,KAAK,SAAS,GAAG,YAAY;YAE7B,OAAY;AACnB,QAAI,MAAM,SAAS,kBAAkB,mBAAmB,OAGtD,OAAM;;;;AAMd,QAAO;EACL,GAAG;EACH,IAAI,SAAS,MAAM,MAAM,KAAK;EAC9B,qBAAI,IAAI,MAAM,EAAC,aAAa;EAC5B,gBAAgB;EAChB,kBAAkB,WAAW;EAC7B,eAAe,WAAW;EAC3B"}
1
+ {"version":3,"file":"base.js","names":[],"sources":["../../src/channels/base.ts"],"sourcesContent":["import {\n ReadonlyCheckpoint,\n uuid6,\n Checkpoint,\n} from \"@langchain/langgraph-checkpoint\";\nimport { EmptyChannelError } from \"../errors.js\";\n\nexport function isBaseChannel(obj: unknown): obj is BaseChannel {\n return obj != null && (obj as BaseChannel).lg_is_channel === true;\n}\n\n/** @internal */\nexport abstract class BaseChannel<\n ValueType = unknown,\n UpdateType = unknown,\n CheckpointType = unknown\n> {\n ValueType: ValueType;\n\n UpdateType: UpdateType;\n\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n\n /** @ignore */\n lg_is_channel = true;\n\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean {\n return false;\n }\n\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean {\n return false;\n }\n\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean {\n try {\n this.get();\n return true;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n return false;\n }\n throw error;\n }\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Used to determine if two channels with the same key are semantically equivalent.\n * Subclasses should override this method to provide a meaningful comparison.\n *\n * @param {BaseChannel} other - The other channel to compare with.\n * @returns {boolean} True if the channels are equal, false otherwise.\n */\n equals(other: BaseChannel): boolean {\n return this === other;\n }\n}\n\nconst IS_ONLY_BASE_CHANNEL = Symbol.for(\"LG_IS_ONLY_BASE_CHANNEL\");\nexport function getOnlyChannels(\n channels: Record<string, BaseChannel>\n): Record<string, BaseChannel> {\n // @ts-expect-error - we know it's a record of base channels\n if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;\n\n const newChannels = {} as Record<string, BaseChannel>;\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n const value = channels[k];\n if (isBaseChannel(value)) newChannels[k] = value;\n }\n\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function emptyChannels<Cc extends Record<string, BaseChannel>>(\n channels: Cc,\n checkpoint: ReadonlyCheckpoint\n): Cc {\n const filteredChannels = getOnlyChannels(channels) as Cc;\n\n const newChannels = {} as Cc;\n for (const k in filteredChannels) {\n if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;\n const channelValue = checkpoint.channel_values[k];\n newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);\n }\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function createCheckpoint<ValueType>(\n checkpoint: ReadonlyCheckpoint,\n channels: Record<string, BaseChannel<ValueType>> | undefined,\n step: number,\n options?: { id?: string }\n): Checkpoint {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let values: Record<string, any>;\n if (channels === undefined) {\n values = checkpoint.channel_values;\n } else {\n values = {};\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n try {\n values[k] = channels[k].checkpoint();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n // no-op\n } else {\n throw error; // Rethrow unexpected errors\n }\n }\n }\n }\n\n return {\n v: 4,\n id: options?.id ?? uuid6(step),\n ts: new Date().toISOString(),\n channel_values: values,\n channel_versions: checkpoint.channel_versions,\n versions_seen: checkpoint.versions_seen,\n };\n}\n"],"mappings":";;;;AAOA,SAAgB,cAAc,KAAkC;AAC9D,QAAO,OAAO,QAAS,IAAoB,kBAAkB;;;AAI/D,IAAsB,cAAtB,MAIE;CACA;CAEA;;CAQA,gBAAgB;;;;;;;;CAkDhB,UAAmB;AACjB,SAAO;;;;;;;;CAST,SAAkB;AAChB,SAAO;;;;;;;CAQT,cAAuB;AACrB,MAAI;AACF,QAAK,KAAK;AACV,UAAO;WAEA,OAAY;AACnB,OAAI,MAAM,SAAS,kBAAkB,kBACnC,QAAO;AAET,SAAM;;;;;;;;;;;CAYV,OAAO,OAA6B;AAClC,SAAO,SAAS;;;AAIpB,MAAM,uBAAuB,OAAO,IAAI,0BAA0B;AAClE,SAAgB,gBACd,UAC6B;AAE7B,KAAI,SAAS,0BAA0B,KAAM,QAAO;CAEpD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,UAAU;AACxB,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;EACxD,MAAM,QAAQ,SAAS;AACvB,MAAI,cAAc,MAAM,CAAE,aAAY,KAAK;;AAG7C,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,cACd,UACA,YACI;CACJ,MAAM,mBAAmB,gBAAgB,SAAS;CAElD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,kBAAkB;AAChC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,kBAAkB,EAAE,CAAE;EAChE,MAAM,eAAe,WAAW,eAAe;AAC/C,cAAY,KAAK,iBAAiB,GAAG,eAAe,aAAa;;AAEnE,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,iBACd,YACA,UACA,MACA,SACY;CAEZ,IAAI;AACJ,KAAI,aAAa,OACf,UAAS,WAAW;MACf;AACL,WAAS,EAAE;AACX,OAAK,MAAM,KAAK,UAAU;AACxB,OAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;AACxD,OAAI;AACF,WAAO,KAAK,SAAS,GAAG,YAAY;YAE7B,OAAY;AACnB,QAAI,MAAM,SAAS,kBAAkB,mBAAmB,OAGtD,OAAM;;;;AAMd,QAAO;EACL,GAAG;EACH,IAAI,SAAS,MAAM,MAAM,KAAK;EAC9B,qBAAI,IAAI,MAAM,EAAC,aAAa;EAC5B,gBAAgB;EAChB,kBAAkB,WAAW;EAC7B,eAAe,WAAW;EAC3B"}
@@ -2,6 +2,9 @@ const require_errors = require('../errors.cjs');
2
2
  const require_base = require('./base.cjs');
3
3
 
4
4
  //#region src/channels/binop.ts
5
+ const isBinaryOperatorAggregate = (value) => {
6
+ return value != null && value.lc_graph_name === "BinaryOperatorAggregate";
7
+ };
5
8
  /**
6
9
  * Stores the result of applying a binary operator to the current value and each new value.
7
10
  */
@@ -42,6 +45,16 @@ var BinaryOperatorAggregate = class BinaryOperatorAggregate extends require_base
42
45
  isAvailable() {
43
46
  return this.value !== void 0;
44
47
  }
48
+ /**
49
+ * Compare this channel with another channel for equality.
50
+ * Two BinaryOperatorAggregate channels are equal if they have the same operator function.
51
+ * This follows the Python implementation which compares operator references.
52
+ */
53
+ equals(other) {
54
+ if (this === other) return true;
55
+ if (!isBinaryOperatorAggregate(other)) return false;
56
+ return this.operator === other.operator;
57
+ }
45
58
  };
46
59
 
47
60
  //#endregion
@@ -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\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"],"mappings":";;;;;;;AAWA,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"}
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"}
@@ -16,6 +16,12 @@ declare class BinaryOperatorAggregate<ValueType, UpdateType = ValueType> extends
16
16
  get(): ValueType;
17
17
  checkpoint(): ValueType;
18
18
  isAvailable(): boolean;
19
+ /**
20
+ * Compare this channel with another channel for equality.
21
+ * Two BinaryOperatorAggregate channels are equal if they have the same operator function.
22
+ * This follows the Python implementation which compares operator references.
23
+ */
24
+ equals(other: BaseChannel): boolean;
19
25
  }
20
26
  //#endregion
21
27
  export { BinaryOperator, BinaryOperatorAggregate };
@@ -1 +1 @@
1
- {"version":3,"file":"binop.d.cts","names":["BaseChannel","BinaryOperator","ValueType","UpdateType","BinaryOperatorAggregate"],"sources":["../../src/channels/binop.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\nexport type BinaryOperator<ValueType, UpdateType> = (a: ValueType, b: UpdateType) => ValueType;\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport declare class BinaryOperatorAggregate<ValueType, UpdateType = ValueType> extends BaseChannel<ValueType, UpdateType, ValueType> {\n lc_graph_name: string;\n value: ValueType | undefined;\n operator: BinaryOperator<ValueType, UpdateType>;\n initialValueFactory?: () => ValueType;\n constructor(operator: BinaryOperator<ValueType, UpdateType>, initialValueFactory?: () => ValueType);\n fromCheckpoint(checkpoint?: ValueType): this;\n update(values: UpdateType[]): boolean;\n get(): ValueType;\n checkpoint(): ValueType;\n isAvailable(): boolean;\n}\n"],"mappings":";;;KACYC,4CAA4CC,cAAcC,eAAeD;;AAArF;;AAAwDA,cAInCE,uBAJmCF,CAAAA,SAAAA,EAAAA,aAIaA,SAJbA,CAAAA,SAIgCF,WAJhCE,CAI4CA,SAJ5CA,EAIuDC,UAJvDD,EAImEA,SAJnEA,CAAAA,CAAAA;eAAcC,EAAAA,MAAAA;OAAeD,EAM1EA,SAN0EA,GAAAA,SAAAA;EAAS,QAAA,EAOhFD,cAPgF,CAOjEC,SAPiE,EAOtDC,UAPsD,CAAA;EAIzEC,mBAAAA,CAAAA,EAAAA,GAAAA,GAIWF,SAJY;EAAA,WAAA,CAAA,QAAA,EAKlBD,cALkB,CAKHC,SALG,EAKQC,UALR,CAAA,EAAA,mBAAA,CAAA,EAAA,GAAA,GAKiDD,SALjD;gBAAyBA,CAAAA,UAAAA,CAAAA,EAMrCA,SANqCA,CAAAA,EAAAA,IAAAA;QAA+BA,CAAAA,MAAAA,EAOjFC,UAPiFD,EAAAA,CAAAA,EAAAA,OAAAA;KAAWC,CAAAA,CAAAA,EAQpGD,SARoGC;YAAYD,CAAAA,CAAAA,EASzGA,SATyGA;aAEhHA,CAAAA,CAAAA,EAAAA,OAAAA"}
1
+ {"version":3,"file":"binop.d.cts","names":["BaseChannel","BinaryOperator","ValueType","UpdateType","BinaryOperatorAggregate"],"sources":["../../src/channels/binop.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\nexport type BinaryOperator<ValueType, UpdateType> = (a: ValueType, b: UpdateType) => ValueType;\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport declare class BinaryOperatorAggregate<ValueType, UpdateType = ValueType> extends BaseChannel<ValueType, UpdateType, ValueType> {\n lc_graph_name: string;\n value: ValueType | undefined;\n operator: BinaryOperator<ValueType, UpdateType>;\n initialValueFactory?: () => ValueType;\n constructor(operator: BinaryOperator<ValueType, UpdateType>, initialValueFactory?: () => ValueType);\n fromCheckpoint(checkpoint?: ValueType): this;\n update(values: UpdateType[]): boolean;\n get(): ValueType;\n checkpoint(): ValueType;\n isAvailable(): boolean;\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}\n"],"mappings":";;;KACYC,4CAA4CC,cAAcC,eAAeD;;AAArF;;AAAwDA,cAInCE,uBAJmCF,CAAAA,SAAAA,EAAAA,aAIaA,SAJbA,CAAAA,SAIgCF,WAJhCE,CAI4CA,SAJ5CA,EAIuDC,UAJvDD,EAImEA,SAJnEA,CAAAA,CAAAA;eAAcC,EAAAA,MAAAA;OAAeD,EAM1EA,SAN0EA,GAAAA,SAAAA;EAAS,QAAA,EAOhFD,cAPgF,CAOjEC,SAPiE,EAOtDC,UAPsD,CAAA;EAIzEC,mBAAAA,CAAAA,EAAAA,GAAAA,GAIWF,SAJY;EAAA,WAAA,CAAA,QAAA,EAKlBD,cALkB,CAKHC,SALG,EAKQC,UALR,CAAA,EAAA,mBAAA,CAAA,EAAA,GAAA,GAKiDD,SALjD;gBAAyBA,CAAAA,UAAAA,CAAAA,EAMrCA,SANqCA,CAAAA,EAAAA,IAAAA;QAA+BA,CAAAA,MAAAA,EAOjFC,UAPiFD,EAAAA,CAAAA,EAAAA,OAAAA;KAAWC,CAAAA,CAAAA,EAQpGD,SARoGC;YAAYD,CAAAA,CAAAA,EASzGA,SATyGA;aAEhHA,CAAAA,CAAAA,EAAAA,OAAAA;;;;;;QAGyCC,CAAAA,KAAAA,EAWlCH,WAXkCG,CAAAA,EAAAA,OAAAA"}
@@ -16,6 +16,12 @@ declare class BinaryOperatorAggregate<ValueType, UpdateType = ValueType> extends
16
16
  get(): ValueType;
17
17
  checkpoint(): ValueType;
18
18
  isAvailable(): boolean;
19
+ /**
20
+ * Compare this channel with another channel for equality.
21
+ * Two BinaryOperatorAggregate channels are equal if they have the same operator function.
22
+ * This follows the Python implementation which compares operator references.
23
+ */
24
+ equals(other: BaseChannel): boolean;
19
25
  }
20
26
  //#endregion
21
27
  export { BinaryOperator, BinaryOperatorAggregate };
@@ -1 +1 @@
1
- {"version":3,"file":"binop.d.ts","names":["BaseChannel","BinaryOperator","ValueType","UpdateType","BinaryOperatorAggregate"],"sources":["../../src/channels/binop.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\nexport type BinaryOperator<ValueType, UpdateType> = (a: ValueType, b: UpdateType) => ValueType;\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport declare class BinaryOperatorAggregate<ValueType, UpdateType = ValueType> extends BaseChannel<ValueType, UpdateType, ValueType> {\n lc_graph_name: string;\n value: ValueType | undefined;\n operator: BinaryOperator<ValueType, UpdateType>;\n initialValueFactory?: () => ValueType;\n constructor(operator: BinaryOperator<ValueType, UpdateType>, initialValueFactory?: () => ValueType);\n fromCheckpoint(checkpoint?: ValueType): this;\n update(values: UpdateType[]): boolean;\n get(): ValueType;\n checkpoint(): ValueType;\n isAvailable(): boolean;\n}\n"],"mappings":";;;KACYC,4CAA4CC,cAAcC,eAAeD;;AAArF;;AAAwDA,cAInCE,uBAJmCF,CAAAA,SAAAA,EAAAA,aAIaA,SAJbA,CAAAA,SAIgCF,WAJhCE,CAI4CA,SAJ5CA,EAIuDC,UAJvDD,EAImEA,SAJnEA,CAAAA,CAAAA;eAAcC,EAAAA,MAAAA;OAAeD,EAM1EA,SAN0EA,GAAAA,SAAAA;EAAS,QAAA,EAOhFD,cAPgF,CAOjEC,SAPiE,EAOtDC,UAPsD,CAAA;EAIzEC,mBAAAA,CAAAA,EAAAA,GAAAA,GAIWF,SAJY;EAAA,WAAA,CAAA,QAAA,EAKlBD,cALkB,CAKHC,SALG,EAKQC,UALR,CAAA,EAAA,mBAAA,CAAA,EAAA,GAAA,GAKiDD,SALjD;gBAAyBA,CAAAA,UAAAA,CAAAA,EAMrCA,SANqCA,CAAAA,EAAAA,IAAAA;QAA+BA,CAAAA,MAAAA,EAOjFC,UAPiFD,EAAAA,CAAAA,EAAAA,OAAAA;KAAWC,CAAAA,CAAAA,EAQpGD,SARoGC;YAAYD,CAAAA,CAAAA,EASzGA,SATyGA;aAEhHA,CAAAA,CAAAA,EAAAA,OAAAA"}
1
+ {"version":3,"file":"binop.d.ts","names":["BaseChannel","BinaryOperator","ValueType","UpdateType","BinaryOperatorAggregate"],"sources":["../../src/channels/binop.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\nexport type BinaryOperator<ValueType, UpdateType> = (a: ValueType, b: UpdateType) => ValueType;\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport declare class BinaryOperatorAggregate<ValueType, UpdateType = ValueType> extends BaseChannel<ValueType, UpdateType, ValueType> {\n lc_graph_name: string;\n value: ValueType | undefined;\n operator: BinaryOperator<ValueType, UpdateType>;\n initialValueFactory?: () => ValueType;\n constructor(operator: BinaryOperator<ValueType, UpdateType>, initialValueFactory?: () => ValueType);\n fromCheckpoint(checkpoint?: ValueType): this;\n update(values: UpdateType[]): boolean;\n get(): ValueType;\n checkpoint(): ValueType;\n isAvailable(): boolean;\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}\n"],"mappings":";;;KACYC,4CAA4CC,cAAcC,eAAeD;;AAArF;;AAAwDA,cAInCE,uBAJmCF,CAAAA,SAAAA,EAAAA,aAIaA,SAJbA,CAAAA,SAIgCF,WAJhCE,CAI4CA,SAJ5CA,EAIuDC,UAJvDD,EAImEA,SAJnEA,CAAAA,CAAAA;eAAcC,EAAAA,MAAAA;OAAeD,EAM1EA,SAN0EA,GAAAA,SAAAA;EAAS,QAAA,EAOhFD,cAPgF,CAOjEC,SAPiE,EAOtDC,UAPsD,CAAA;EAIzEC,mBAAAA,CAAAA,EAAAA,GAAAA,GAIWF,SAJY;EAAA,WAAA,CAAA,QAAA,EAKlBD,cALkB,CAKHC,SALG,EAKQC,UALR,CAAA,EAAA,mBAAA,CAAA,EAAA,GAAA,GAKiDD,SALjD;gBAAyBA,CAAAA,UAAAA,CAAAA,EAMrCA,SANqCA,CAAAA,EAAAA,IAAAA;QAA+BA,CAAAA,MAAAA,EAOjFC,UAPiFD,EAAAA,CAAAA,EAAAA,OAAAA;KAAWC,CAAAA,CAAAA,EAQpGD,SARoGC;YAAYD,CAAAA,CAAAA,EASzGA,SATyGA;aAEhHA,CAAAA,CAAAA,EAAAA,OAAAA;;;;;;QAGyCC,CAAAA,KAAAA,EAWlCH,WAXkCG,CAAAA,EAAAA,OAAAA"}
@@ -2,6 +2,9 @@ import { EmptyChannelError } from "../errors.js";
2
2
  import { BaseChannel } from "./base.js";
3
3
 
4
4
  //#region src/channels/binop.ts
5
+ const isBinaryOperatorAggregate = (value) => {
6
+ return value != null && value.lc_graph_name === "BinaryOperatorAggregate";
7
+ };
5
8
  /**
6
9
  * Stores the result of applying a binary operator to the current value and each new value.
7
10
  */
@@ -42,6 +45,16 @@ var BinaryOperatorAggregate = class BinaryOperatorAggregate extends BaseChannel
42
45
  isAvailable() {
43
46
  return this.value !== void 0;
44
47
  }
48
+ /**
49
+ * Compare this channel with another channel for equality.
50
+ * Two BinaryOperatorAggregate channels are equal if they have the same operator function.
51
+ * This follows the Python implementation which compares operator references.
52
+ */
53
+ equals(other) {
54
+ if (this === other) return true;
55
+ if (!isBinaryOperatorAggregate(other)) return false;
56
+ return this.operator === other.operator;
57
+ }
45
58
  };
46
59
 
47
60
  //#endregion
@@ -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\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"],"mappings":";;;;;;;AAWA,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"}
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"}
@@ -6,6 +6,7 @@ const require_ephemeral_value = require('./ephemeral_value.cjs');
6
6
  const require_named_barrier_value = require('./named_barrier_value.cjs');
7
7
  const require_any_value = require('./any_value.cjs');
8
8
  const require_dynamic_barrier_value = require('./dynamic_barrier_value.cjs');
9
+ const require_untracked_value = require('./untracked_value.cjs');
9
10
 
10
11
  exports.AnyValue = require_any_value.AnyValue;
11
12
  exports.BaseChannel = require_base.BaseChannel;
@@ -17,5 +18,6 @@ exports.LastValueAfterFinish = require_last_value.LastValueAfterFinish;
17
18
  exports.NamedBarrierValue = require_named_barrier_value.NamedBarrierValue;
18
19
  exports.NamedBarrierValueAfterFinish = require_named_barrier_value.NamedBarrierValueAfterFinish;
19
20
  exports.Topic = require_topic.Topic;
21
+ exports.UntrackedValueChannel = require_untracked_value.UntrackedValueChannel;
20
22
  exports.createCheckpoint = require_base.createCheckpoint;
21
23
  exports.empty = require_base.emptyChannels;
@@ -6,4 +6,5 @@ import { DynamicBarrierValue, WaitForNames } from "./dynamic_barrier_value.cjs";
6
6
  import { EphemeralValue } from "./ephemeral_value.cjs";
7
7
  import { NamedBarrierValue, NamedBarrierValueAfterFinish } from "./named_barrier_value.cjs";
8
8
  import { Topic } from "./topic.cjs";
9
- export { AnyValue, BaseChannel, type BinaryOperator, BinaryOperatorAggregate, DynamicBarrierValue, EphemeralValue, LastValue, LastValueAfterFinish, NamedBarrierValue, NamedBarrierValueAfterFinish, Topic, type WaitForNames, createCheckpoint, emptyChannels as empty };
9
+ import { UntrackedValueChannel } from "./untracked_value.cjs";
10
+ export { AnyValue, BaseChannel, type BinaryOperator, BinaryOperatorAggregate, DynamicBarrierValue, EphemeralValue, LastValue, LastValueAfterFinish, NamedBarrierValue, NamedBarrierValueAfterFinish, Topic, UntrackedValueChannel, type WaitForNames, createCheckpoint, emptyChannels as empty };
@@ -6,4 +6,5 @@ import { DynamicBarrierValue, WaitForNames } from "./dynamic_barrier_value.js";
6
6
  import { EphemeralValue } from "./ephemeral_value.js";
7
7
  import { NamedBarrierValue, NamedBarrierValueAfterFinish } from "./named_barrier_value.js";
8
8
  import { Topic } from "./topic.js";
9
- export { AnyValue, BaseChannel, type BinaryOperator, BinaryOperatorAggregate, DynamicBarrierValue, EphemeralValue, LastValue, LastValueAfterFinish, NamedBarrierValue, NamedBarrierValueAfterFinish, Topic, type WaitForNames, createCheckpoint, emptyChannels as empty };
9
+ import { UntrackedValueChannel } from "./untracked_value.js";
10
+ export { AnyValue, BaseChannel, type BinaryOperator, BinaryOperatorAggregate, DynamicBarrierValue, EphemeralValue, LastValue, LastValueAfterFinish, NamedBarrierValue, NamedBarrierValueAfterFinish, Topic, UntrackedValueChannel, type WaitForNames, createCheckpoint, emptyChannels as empty };
@@ -6,5 +6,6 @@ import { EphemeralValue } from "./ephemeral_value.js";
6
6
  import { NamedBarrierValue, NamedBarrierValueAfterFinish } from "./named_barrier_value.js";
7
7
  import { AnyValue } from "./any_value.js";
8
8
  import { DynamicBarrierValue } from "./dynamic_barrier_value.js";
9
+ import { UntrackedValueChannel } from "./untracked_value.js";
9
10
 
10
- export { AnyValue, BaseChannel, BinaryOperatorAggregate, DynamicBarrierValue, EphemeralValue, LastValue, LastValueAfterFinish, NamedBarrierValue, NamedBarrierValueAfterFinish, Topic, createCheckpoint, emptyChannels as empty };
11
+ export { AnyValue, BaseChannel, BinaryOperatorAggregate, DynamicBarrierValue, EphemeralValue, LastValue, LastValueAfterFinish, NamedBarrierValue, NamedBarrierValueAfterFinish, Topic, UntrackedValueChannel, createCheckpoint, emptyChannels as empty };
@@ -0,0 +1,83 @@
1
+ const require_errors = require('../errors.cjs');
2
+ const require_base = require('./base.cjs');
3
+
4
+ //#region src/channels/untracked_value.ts
5
+ const MISSING = Symbol.for("langgraph.channel.missing");
6
+ /**
7
+ * Stores the last value received, never checkpointed.
8
+ *
9
+ * This channel stores values during graph execution but does NOT persist
10
+ * the value to checkpoints. On restoration from a checkpoint, the value
11
+ * will be reset to empty (or the initial value if provided).
12
+ *
13
+ * Useful for transient state like:
14
+ * - Database connections
15
+ * - Temporary caches
16
+ * - Runtime-only configuration
17
+ *
18
+ * @internal
19
+ */
20
+ var UntrackedValueChannel = class UntrackedValueChannel extends require_base.BaseChannel {
21
+ lc_graph_name = "UntrackedValue";
22
+ /**
23
+ * If true, throws an error when multiple values are received in a single step.
24
+ * If false, stores the last value received.
25
+ */
26
+ guard;
27
+ /**
28
+ * The current value. MISSING sentinel indicates no value has been set.
29
+ */
30
+ _value = MISSING;
31
+ /**
32
+ * Optional factory function for the initial value.
33
+ */
34
+ initialValueFactory;
35
+ constructor(options) {
36
+ super();
37
+ this.guard = options?.guard ?? true;
38
+ this.initialValueFactory = options?.initialValueFactory;
39
+ if (this.initialValueFactory) this._value = this.initialValueFactory();
40
+ }
41
+ /**
42
+ * Return a new channel, ignoring the checkpoint since we don't persist.
43
+ * The initial value (if any) is restored.
44
+ */
45
+ fromCheckpoint(_checkpoint) {
46
+ return new UntrackedValueChannel({
47
+ guard: this.guard,
48
+ initialValueFactory: this.initialValueFactory
49
+ });
50
+ }
51
+ /**
52
+ * Update the channel with the given values.
53
+ * If guard is true, throws if more than one value is received.
54
+ */
55
+ update(values) {
56
+ if (values.length === 0) return false;
57
+ if (values.length !== 1 && this.guard) throw new require_errors.InvalidUpdateError("UntrackedValue(guard=true) can receive only one value per step. Use guard=false if you want to store any one of multiple values.", { lc_error_code: "INVALID_CONCURRENT_GRAPH_UPDATE" });
58
+ this._value = values[values.length - 1];
59
+ return true;
60
+ }
61
+ /**
62
+ * Get the current value.
63
+ * @throws EmptyChannelError if no value has been set.
64
+ */
65
+ get() {
66
+ if (this._value === MISSING) throw new require_errors.EmptyChannelError();
67
+ return this._value;
68
+ }
69
+ /**
70
+ * Always returns undefined - untracked values are never checkpointed.
71
+ */
72
+ checkpoint() {}
73
+ /**
74
+ * Return true if a value has been set.
75
+ */
76
+ isAvailable() {
77
+ return this._value !== MISSING;
78
+ }
79
+ };
80
+
81
+ //#endregion
82
+ exports.UntrackedValueChannel = UntrackedValueChannel;
83
+ //# sourceMappingURL=untracked_value.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"untracked_value.cjs","names":["BaseChannel","InvalidUpdateError","EmptyChannelError"],"sources":["../../src/channels/untracked_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n// Sentinel value for missing/unset\nconst MISSING = Symbol.for(\"langgraph.channel.missing\");\n\n/**\n * Stores the last value received, never checkpointed.\n *\n * This channel stores values during graph execution but does NOT persist\n * the value to checkpoints. On restoration from a checkpoint, the value\n * will be reset to empty (or the initial value if provided).\n *\n * Useful for transient state like:\n * - Database connections\n * - Temporary caches\n * - Runtime-only configuration\n *\n * @internal\n */\nexport class UntrackedValueChannel<Value> extends BaseChannel<\n Value,\n Value,\n undefined\n> {\n lc_graph_name = \"UntrackedValue\";\n\n /**\n * If true, throws an error when multiple values are received in a single step.\n * If false, stores the last value received.\n */\n guard: boolean;\n\n /**\n * The current value. MISSING sentinel indicates no value has been set.\n */\n private _value: Value | typeof MISSING = MISSING;\n\n /**\n * Optional factory function for the initial value.\n */\n private initialValueFactory?: () => Value;\n\n constructor(options?: {\n guard?: boolean;\n initialValueFactory?: () => Value;\n }) {\n super();\n this.guard = options?.guard ?? true;\n this.initialValueFactory = options?.initialValueFactory;\n if (this.initialValueFactory) {\n this._value = this.initialValueFactory();\n }\n }\n\n /**\n * Return a new channel, ignoring the checkpoint since we don't persist.\n * The initial value (if any) is restored.\n */\n fromCheckpoint(_checkpoint?: undefined): this {\n const empty = new UntrackedValueChannel<Value>({\n guard: this.guard,\n initialValueFactory: this.initialValueFactory,\n });\n return empty as this;\n }\n\n /**\n * Update the channel with the given values.\n * If guard is true, throws if more than one value is received.\n */\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n\n if (values.length !== 1 && this.guard) {\n throw new InvalidUpdateError(\n \"UntrackedValue(guard=true) can receive only one value per step. \" +\n \"Use guard=false if you want to store any one of multiple values.\",\n { lc_error_code: \"INVALID_CONCURRENT_GRAPH_UPDATE\" }\n );\n }\n\n this._value = values[values.length - 1];\n return true;\n }\n\n /**\n * Get the current value.\n * @throws EmptyChannelError if no value has been set.\n */\n get(): Value {\n if (this._value === MISSING) {\n throw new EmptyChannelError();\n }\n return this._value;\n }\n\n /**\n * Always returns undefined - untracked values are never checkpointed.\n */\n checkpoint(): undefined {\n return undefined;\n }\n\n /**\n * Return true if a value has been set.\n */\n isAvailable(): boolean {\n return this._value !== MISSING;\n }\n}\n"],"mappings":";;;;AAIA,MAAM,UAAU,OAAO,IAAI,4BAA4B;;;;;;;;;;;;;;;AAgBvD,IAAa,wBAAb,MAAa,8BAAqCA,yBAIhD;CACA,gBAAgB;;;;;CAMhB;;;;CAKA,AAAQ,SAAiC;;;;CAKzC,AAAQ;CAER,YAAY,SAGT;AACD,SAAO;AACP,OAAK,QAAQ,SAAS,SAAS;AAC/B,OAAK,sBAAsB,SAAS;AACpC,MAAI,KAAK,oBACP,MAAK,SAAS,KAAK,qBAAqB;;;;;;CAQ5C,eAAe,aAA+B;AAK5C,SAJc,IAAI,sBAA6B;GAC7C,OAAO,KAAK;GACZ,qBAAqB,KAAK;GAC3B,CAAC;;;;;;CAQJ,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,EACpB,QAAO;AAGT,MAAI,OAAO,WAAW,KAAK,KAAK,MAC9B,OAAM,IAAIC,kCACR,oIAEA,EAAE,eAAe,mCAAmC,CACrD;AAGH,OAAK,SAAS,OAAO,OAAO,SAAS;AACrC,SAAO;;;;;;CAOT,MAAa;AACX,MAAI,KAAK,WAAW,QAClB,OAAM,IAAIC,kCAAmB;AAE/B,SAAO,KAAK;;;;;CAMd,aAAwB;;;;CAOxB,cAAuB;AACrB,SAAO,KAAK,WAAW"}
@@ -0,0 +1,64 @@
1
+ import { BaseChannel } from "./base.cjs";
2
+
3
+ //#region src/channels/untracked_value.d.ts
4
+
5
+ /**
6
+ * Stores the last value received, never checkpointed.
7
+ *
8
+ * This channel stores values during graph execution but does NOT persist
9
+ * the value to checkpoints. On restoration from a checkpoint, the value
10
+ * will be reset to empty (or the initial value if provided).
11
+ *
12
+ * Useful for transient state like:
13
+ * - Database connections
14
+ * - Temporary caches
15
+ * - Runtime-only configuration
16
+ *
17
+ * @internal
18
+ */
19
+ declare class UntrackedValueChannel<Value> extends BaseChannel<Value, Value, undefined> {
20
+ lc_graph_name: string;
21
+ /**
22
+ * If true, throws an error when multiple values are received in a single step.
23
+ * If false, stores the last value received.
24
+ */
25
+ guard: boolean;
26
+ /**
27
+ * The current value. MISSING sentinel indicates no value has been set.
28
+ */
29
+ private _value;
30
+ /**
31
+ * Optional factory function for the initial value.
32
+ */
33
+ private initialValueFactory?;
34
+ constructor(options?: {
35
+ guard?: boolean;
36
+ initialValueFactory?: () => Value;
37
+ });
38
+ /**
39
+ * Return a new channel, ignoring the checkpoint since we don't persist.
40
+ * The initial value (if any) is restored.
41
+ */
42
+ fromCheckpoint(_checkpoint?: undefined): this;
43
+ /**
44
+ * Update the channel with the given values.
45
+ * If guard is true, throws if more than one value is received.
46
+ */
47
+ update(values: Value[]): boolean;
48
+ /**
49
+ * Get the current value.
50
+ * @throws EmptyChannelError if no value has been set.
51
+ */
52
+ get(): Value;
53
+ /**
54
+ * Always returns undefined - untracked values are never checkpointed.
55
+ */
56
+ checkpoint(): undefined;
57
+ /**
58
+ * Return true if a value has been set.
59
+ */
60
+ isAvailable(): boolean;
61
+ }
62
+ //#endregion
63
+ export { UntrackedValueChannel };
64
+ //# sourceMappingURL=untracked_value.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"untracked_value.d.cts","names":["BaseChannel","UntrackedValueChannel","Value"],"sources":["../../src/channels/untracked_value.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\n/**\n * Stores the last value received, never checkpointed.\n *\n * This channel stores values during graph execution but does NOT persist\n * the value to checkpoints. On restoration from a checkpoint, the value\n * will be reset to empty (or the initial value if provided).\n *\n * Useful for transient state like:\n * - Database connections\n * - Temporary caches\n * - Runtime-only configuration\n *\n * @internal\n */\nexport declare class UntrackedValueChannel<Value> extends BaseChannel<Value, Value, undefined> {\n lc_graph_name: string;\n /**\n * If true, throws an error when multiple values are received in a single step.\n * If false, stores the last value received.\n */\n guard: boolean;\n /**\n * The current value. MISSING sentinel indicates no value has been set.\n */\n private _value;\n /**\n * Optional factory function for the initial value.\n */\n private initialValueFactory?;\n constructor(options?: {\n guard?: boolean;\n initialValueFactory?: () => Value;\n });\n /**\n * Return a new channel, ignoring the checkpoint since we don't persist.\n * The initial value (if any) is restored.\n */\n fromCheckpoint(_checkpoint?: undefined): this;\n /**\n * Update the channel with the given values.\n * If guard is true, throws if more than one value is received.\n */\n update(values: Value[]): boolean;\n /**\n * Get the current value.\n * @throws EmptyChannelError if no value has been set.\n */\n get(): Value;\n /**\n * Always returns undefined - untracked values are never checkpointed.\n */\n checkpoint(): undefined;\n /**\n * Return true if a value has been set.\n */\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;;AAeA;;;;;;;;;;;;cAAqBC,qCAAqCD,YAAYE,OAAOA;;;;;;;;;;;;;;;;;gCAiBzCA;;;;;;;;;;;iBAWjBA;;;;;SAKRA"}
@@ -0,0 +1,64 @@
1
+ import { BaseChannel } from "./base.js";
2
+
3
+ //#region src/channels/untracked_value.d.ts
4
+
5
+ /**
6
+ * Stores the last value received, never checkpointed.
7
+ *
8
+ * This channel stores values during graph execution but does NOT persist
9
+ * the value to checkpoints. On restoration from a checkpoint, the value
10
+ * will be reset to empty (or the initial value if provided).
11
+ *
12
+ * Useful for transient state like:
13
+ * - Database connections
14
+ * - Temporary caches
15
+ * - Runtime-only configuration
16
+ *
17
+ * @internal
18
+ */
19
+ declare class UntrackedValueChannel<Value> extends BaseChannel<Value, Value, undefined> {
20
+ lc_graph_name: string;
21
+ /**
22
+ * If true, throws an error when multiple values are received in a single step.
23
+ * If false, stores the last value received.
24
+ */
25
+ guard: boolean;
26
+ /**
27
+ * The current value. MISSING sentinel indicates no value has been set.
28
+ */
29
+ private _value;
30
+ /**
31
+ * Optional factory function for the initial value.
32
+ */
33
+ private initialValueFactory?;
34
+ constructor(options?: {
35
+ guard?: boolean;
36
+ initialValueFactory?: () => Value;
37
+ });
38
+ /**
39
+ * Return a new channel, ignoring the checkpoint since we don't persist.
40
+ * The initial value (if any) is restored.
41
+ */
42
+ fromCheckpoint(_checkpoint?: undefined): this;
43
+ /**
44
+ * Update the channel with the given values.
45
+ * If guard is true, throws if more than one value is received.
46
+ */
47
+ update(values: Value[]): boolean;
48
+ /**
49
+ * Get the current value.
50
+ * @throws EmptyChannelError if no value has been set.
51
+ */
52
+ get(): Value;
53
+ /**
54
+ * Always returns undefined - untracked values are never checkpointed.
55
+ */
56
+ checkpoint(): undefined;
57
+ /**
58
+ * Return true if a value has been set.
59
+ */
60
+ isAvailable(): boolean;
61
+ }
62
+ //#endregion
63
+ export { UntrackedValueChannel };
64
+ //# sourceMappingURL=untracked_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"untracked_value.d.ts","names":["BaseChannel","UntrackedValueChannel","Value"],"sources":["../../src/channels/untracked_value.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\n/**\n * Stores the last value received, never checkpointed.\n *\n * This channel stores values during graph execution but does NOT persist\n * the value to checkpoints. On restoration from a checkpoint, the value\n * will be reset to empty (or the initial value if provided).\n *\n * Useful for transient state like:\n * - Database connections\n * - Temporary caches\n * - Runtime-only configuration\n *\n * @internal\n */\nexport declare class UntrackedValueChannel<Value> extends BaseChannel<Value, Value, undefined> {\n lc_graph_name: string;\n /**\n * If true, throws an error when multiple values are received in a single step.\n * If false, stores the last value received.\n */\n guard: boolean;\n /**\n * The current value. MISSING sentinel indicates no value has been set.\n */\n private _value;\n /**\n * Optional factory function for the initial value.\n */\n private initialValueFactory?;\n constructor(options?: {\n guard?: boolean;\n initialValueFactory?: () => Value;\n });\n /**\n * Return a new channel, ignoring the checkpoint since we don't persist.\n * The initial value (if any) is restored.\n */\n fromCheckpoint(_checkpoint?: undefined): this;\n /**\n * Update the channel with the given values.\n * If guard is true, throws if more than one value is received.\n */\n update(values: Value[]): boolean;\n /**\n * Get the current value.\n * @throws EmptyChannelError if no value has been set.\n */\n get(): Value;\n /**\n * Always returns undefined - untracked values are never checkpointed.\n */\n checkpoint(): undefined;\n /**\n * Return true if a value has been set.\n */\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;;AAeA;;;;;;;;;;;;cAAqBC,qCAAqCD,YAAYE,OAAOA;;;;;;;;;;;;;;;;;gCAiBzCA;;;;;;;;;;;iBAWjBA;;;;;SAKRA"}