@langchain/langgraph 1.2.2 → 1.2.3

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 (254) hide show
  1. package/dist/channels/any_value.cjs +3 -4
  2. package/dist/channels/any_value.cjs.map +1 -1
  3. package/dist/channels/any_value.js +1 -2
  4. package/dist/channels/any_value.js.map +1 -1
  5. package/dist/channels/base.cjs +2 -3
  6. package/dist/channels/base.cjs.map +1 -1
  7. package/dist/channels/base.js +1 -2
  8. package/dist/channels/base.js.map +1 -1
  9. package/dist/channels/binop.cjs +4 -5
  10. package/dist/channels/binop.cjs.map +1 -1
  11. package/dist/channels/binop.js +1 -2
  12. package/dist/channels/binop.js.map +1 -1
  13. package/dist/channels/dynamic_barrier_value.cjs +4 -5
  14. package/dist/channels/dynamic_barrier_value.cjs.map +1 -1
  15. package/dist/channels/dynamic_barrier_value.js +1 -2
  16. package/dist/channels/dynamic_barrier_value.js.map +1 -1
  17. package/dist/channels/ephemeral_value.cjs +3 -4
  18. package/dist/channels/ephemeral_value.cjs.map +1 -1
  19. package/dist/channels/ephemeral_value.js +1 -2
  20. package/dist/channels/ephemeral_value.js.map +1 -1
  21. package/dist/channels/index.cjs +11 -12
  22. package/dist/channels/index.js +1 -2
  23. package/dist/channels/last_value.cjs +3 -4
  24. package/dist/channels/last_value.cjs.map +1 -1
  25. package/dist/channels/last_value.js +1 -2
  26. package/dist/channels/last_value.js.map +1 -1
  27. package/dist/channels/named_barrier_value.cjs +3 -4
  28. package/dist/channels/named_barrier_value.cjs.map +1 -1
  29. package/dist/channels/named_barrier_value.js +1 -2
  30. package/dist/channels/named_barrier_value.js.map +1 -1
  31. package/dist/channels/topic.cjs +3 -4
  32. package/dist/channels/topic.cjs.map +1 -1
  33. package/dist/channels/topic.js +1 -2
  34. package/dist/channels/topic.js.map +1 -1
  35. package/dist/channels/untracked_value.cjs +3 -4
  36. package/dist/channels/untracked_value.cjs.map +1 -1
  37. package/dist/channels/untracked_value.js +1 -2
  38. package/dist/channels/untracked_value.js.map +1 -1
  39. package/dist/constants.cjs +4 -9
  40. package/dist/constants.cjs.map +1 -1
  41. package/dist/constants.js +5 -7
  42. package/dist/constants.js.map +1 -1
  43. package/dist/errors.cjs +1 -2
  44. package/dist/errors.cjs.map +1 -1
  45. package/dist/errors.js +1 -1
  46. package/dist/errors.js.map +1 -1
  47. package/dist/func/index.cjs +9 -10
  48. package/dist/func/index.cjs.map +1 -1
  49. package/dist/func/index.js +1 -2
  50. package/dist/func/index.js.map +1 -1
  51. package/dist/graph/annotation.cjs +3 -4
  52. package/dist/graph/annotation.cjs.map +1 -1
  53. package/dist/graph/annotation.js +1 -2
  54. package/dist/graph/annotation.js.map +1 -1
  55. package/dist/graph/graph.cjs +23 -24
  56. package/dist/graph/graph.cjs.map +1 -1
  57. package/dist/graph/graph.js +16 -17
  58. package/dist/graph/graph.js.map +1 -1
  59. package/dist/graph/index.cjs +6 -6
  60. package/dist/graph/index.js +7 -8
  61. package/dist/graph/message.cjs +4 -5
  62. package/dist/graph/message.cjs.map +1 -1
  63. package/dist/graph/message.js +1 -2
  64. package/dist/graph/message.js.map +1 -1
  65. package/dist/graph/messages_annotation.cjs +4 -5
  66. package/dist/graph/messages_annotation.cjs.map +1 -1
  67. package/dist/graph/messages_annotation.js +1 -2
  68. package/dist/graph/messages_annotation.js.map +1 -1
  69. package/dist/graph/messages_reducer.cjs +2 -3
  70. package/dist/graph/messages_reducer.cjs.map +1 -1
  71. package/dist/graph/messages_reducer.js +2 -3
  72. package/dist/graph/messages_reducer.js.map +1 -1
  73. package/dist/graph/state.cjs +24 -25
  74. package/dist/graph/state.cjs.map +1 -1
  75. package/dist/graph/state.js +10 -11
  76. package/dist/graph/state.js.map +1 -1
  77. package/dist/graph/types.cjs +4 -5
  78. package/dist/graph/types.cjs.map +1 -1
  79. package/dist/graph/types.js +2 -3
  80. package/dist/graph/types.js.map +1 -1
  81. package/dist/graph/zod/index.cjs +5 -6
  82. package/dist/graph/zod/index.js +1 -2
  83. package/dist/graph/zod/meta.cjs +4 -5
  84. package/dist/graph/zod/meta.cjs.map +1 -1
  85. package/dist/graph/zod/meta.js +2 -3
  86. package/dist/graph/zod/meta.js.map +1 -1
  87. package/dist/graph/zod/plugin.cjs +2 -3
  88. package/dist/graph/zod/plugin.cjs.map +1 -1
  89. package/dist/graph/zod/plugin.js +2 -3
  90. package/dist/graph/zod/plugin.js.map +1 -1
  91. package/dist/graph/zod/schema.cjs +5 -6
  92. package/dist/graph/zod/schema.cjs.map +1 -1
  93. package/dist/graph/zod/schema.js +4 -5
  94. package/dist/graph/zod/schema.js.map +1 -1
  95. package/dist/graph/zod/zod-registry.cjs +2 -3
  96. package/dist/graph/zod/zod-registry.cjs.map +1 -1
  97. package/dist/graph/zod/zod-registry.js +1 -2
  98. package/dist/graph/zod/zod-registry.js.map +1 -1
  99. package/dist/hash.cjs +1 -2
  100. package/dist/hash.cjs.map +1 -1
  101. package/dist/hash.js +1 -1
  102. package/dist/index.cjs +60 -61
  103. package/dist/index.cjs.map +1 -1
  104. package/dist/index.js +1 -2
  105. package/dist/index.js.map +1 -1
  106. package/dist/interrupt.cjs +7 -8
  107. package/dist/interrupt.cjs.map +1 -1
  108. package/dist/interrupt.js +5 -6
  109. package/dist/interrupt.js.map +1 -1
  110. package/dist/prebuilt/agentName.cjs +1 -2
  111. package/dist/prebuilt/agentName.cjs.map +1 -1
  112. package/dist/prebuilt/agentName.js +1 -2
  113. package/dist/prebuilt/agentName.js.map +1 -1
  114. package/dist/prebuilt/agent_executor.cjs +4 -5
  115. package/dist/prebuilt/agent_executor.cjs.map +1 -1
  116. package/dist/prebuilt/agent_executor.js +1 -2
  117. package/dist/prebuilt/agent_executor.js.map +1 -1
  118. package/dist/prebuilt/chat_agent_executor.cjs +4 -5
  119. package/dist/prebuilt/chat_agent_executor.cjs.map +1 -1
  120. package/dist/prebuilt/chat_agent_executor.js +1 -2
  121. package/dist/prebuilt/chat_agent_executor.js.map +1 -1
  122. package/dist/prebuilt/index.cjs +8 -9
  123. package/dist/prebuilt/index.js +1 -2
  124. package/dist/prebuilt/react_agent_executor.cjs +8 -9
  125. package/dist/prebuilt/react_agent_executor.cjs.map +1 -1
  126. package/dist/prebuilt/react_agent_executor.js +1 -2
  127. package/dist/prebuilt/react_agent_executor.js.map +1 -1
  128. package/dist/prebuilt/tool_executor.cjs +1 -2
  129. package/dist/prebuilt/tool_executor.cjs.map +1 -1
  130. package/dist/prebuilt/tool_executor.js +1 -2
  131. package/dist/prebuilt/tool_executor.js.map +1 -1
  132. package/dist/prebuilt/tool_node.cjs +4 -5
  133. package/dist/prebuilt/tool_node.cjs.map +1 -1
  134. package/dist/prebuilt/tool_node.js +1 -2
  135. package/dist/prebuilt/tool_node.js.map +1 -1
  136. package/dist/pregel/algo.cjs +30 -31
  137. package/dist/pregel/algo.cjs.map +1 -1
  138. package/dist/pregel/algo.js +23 -24
  139. package/dist/pregel/algo.js.map +1 -1
  140. package/dist/pregel/call.cjs +5 -6
  141. package/dist/pregel/call.cjs.map +1 -1
  142. package/dist/pregel/call.js +2 -3
  143. package/dist/pregel/call.js.map +1 -1
  144. package/dist/pregel/debug.cjs +10 -11
  145. package/dist/pregel/debug.cjs.map +1 -1
  146. package/dist/pregel/debug.js +8 -9
  147. package/dist/pregel/debug.js.map +1 -1
  148. package/dist/pregel/index.cjs +47 -48
  149. package/dist/pregel/index.cjs.map +1 -1
  150. package/dist/pregel/index.js +28 -29
  151. package/dist/pregel/index.js.map +1 -1
  152. package/dist/pregel/io.cjs +7 -8
  153. package/dist/pregel/io.cjs.map +1 -1
  154. package/dist/pregel/io.js +5 -6
  155. package/dist/pregel/io.js.map +1 -1
  156. package/dist/pregel/loop.cjs +29 -30
  157. package/dist/pregel/loop.cjs.map +1 -1
  158. package/dist/pregel/loop.js +20 -21
  159. package/dist/pregel/loop.js.map +1 -1
  160. package/dist/pregel/messages.cjs +4 -5
  161. package/dist/pregel/messages.cjs.map +1 -1
  162. package/dist/pregel/messages.js +4 -5
  163. package/dist/pregel/messages.js.map +1 -1
  164. package/dist/pregel/read.cjs +4 -5
  165. package/dist/pregel/read.cjs.map +1 -1
  166. package/dist/pregel/read.js +1 -2
  167. package/dist/pregel/read.js.map +1 -1
  168. package/dist/pregel/remote.cjs +9 -10
  169. package/dist/pregel/remote.cjs.map +1 -1
  170. package/dist/pregel/remote.js +7 -8
  171. package/dist/pregel/remote.js.map +1 -1
  172. package/dist/pregel/retry.cjs +8 -14
  173. package/dist/pregel/retry.cjs.map +1 -1
  174. package/dist/pregel/retry.js +4 -10
  175. package/dist/pregel/retry.js.map +1 -1
  176. package/dist/pregel/runner.cjs +8 -9
  177. package/dist/pregel/runner.cjs.map +1 -1
  178. package/dist/pregel/runner.js +4 -5
  179. package/dist/pregel/runner.js.map +1 -1
  180. package/dist/pregel/stream.cjs +3 -4
  181. package/dist/pregel/stream.cjs.map +1 -1
  182. package/dist/pregel/stream.js +3 -4
  183. package/dist/pregel/stream.js.map +1 -1
  184. package/dist/pregel/types.cjs +1 -2
  185. package/dist/pregel/types.cjs.map +1 -1
  186. package/dist/pregel/types.js +1 -1
  187. package/dist/pregel/types.js.map +1 -1
  188. package/dist/pregel/utils/config.cjs +6 -7
  189. package/dist/pregel/utils/config.cjs.map +1 -1
  190. package/dist/pregel/utils/config.js +6 -7
  191. package/dist/pregel/utils/config.js.map +1 -1
  192. package/dist/pregel/utils/index.cjs +2 -3
  193. package/dist/pregel/utils/index.cjs.map +1 -1
  194. package/dist/pregel/utils/index.js +1 -2
  195. package/dist/pregel/utils/index.js.map +1 -1
  196. package/dist/pregel/utils/subgraph.cjs +1 -2
  197. package/dist/pregel/utils/subgraph.cjs.map +1 -1
  198. package/dist/pregel/utils/subgraph.js +1 -1
  199. package/dist/pregel/validate.cjs +4 -5
  200. package/dist/pregel/validate.cjs.map +1 -1
  201. package/dist/pregel/validate.js +2 -3
  202. package/dist/pregel/validate.js.map +1 -1
  203. package/dist/pregel/write.cjs +5 -8
  204. package/dist/pregel/write.cjs.map +1 -1
  205. package/dist/pregel/write.js +2 -5
  206. package/dist/pregel/write.js.map +1 -1
  207. package/dist/remote.cjs +3 -4
  208. package/dist/remote.js +1 -2
  209. package/dist/setup/async_local_storage.cjs +1 -2
  210. package/dist/setup/async_local_storage.cjs.map +1 -1
  211. package/dist/setup/async_local_storage.js +1 -2
  212. package/dist/setup/async_local_storage.js.map +1 -1
  213. package/dist/state/adapter.cjs +2 -3
  214. package/dist/state/adapter.cjs.map +1 -1
  215. package/dist/state/adapter.js +1 -2
  216. package/dist/state/adapter.js.map +1 -1
  217. package/dist/state/index.cjs +8 -8
  218. package/dist/state/index.js +7 -8
  219. package/dist/state/prebuilt/index.cjs +1 -1
  220. package/dist/state/prebuilt/index.js +2 -3
  221. package/dist/state/prebuilt/messages.cjs +3 -4
  222. package/dist/state/prebuilt/messages.cjs.map +1 -1
  223. package/dist/state/prebuilt/messages.js +3 -7
  224. package/dist/state/prebuilt/messages.js.map +1 -1
  225. package/dist/state/schema.cjs +16 -12
  226. package/dist/state/schema.cjs.map +1 -1
  227. package/dist/state/schema.d.cts.map +1 -1
  228. package/dist/state/schema.d.ts.map +1 -1
  229. package/dist/state/schema.js +8 -4
  230. package/dist/state/schema.js.map +1 -1
  231. package/dist/state/types.cjs +1 -2
  232. package/dist/state/types.cjs.map +1 -1
  233. package/dist/state/types.js +1 -1
  234. package/dist/state/values/index.cjs +2 -2
  235. package/dist/state/values/index.js +3 -4
  236. package/dist/state/values/reduced.cjs +1 -2
  237. package/dist/state/values/reduced.cjs.map +1 -1
  238. package/dist/state/values/reduced.js +1 -1
  239. package/dist/state/values/reduced.js.map +1 -1
  240. package/dist/state/values/untracked.cjs +1 -2
  241. package/dist/state/values/untracked.cjs.map +1 -1
  242. package/dist/state/values/untracked.js +1 -1
  243. package/dist/state/values/untracked.js.map +1 -1
  244. package/dist/utils.cjs +2 -3
  245. package/dist/utils.cjs.map +1 -1
  246. package/dist/utils.js +1 -2
  247. package/dist/utils.js.map +1 -1
  248. package/dist/web.cjs +58 -59
  249. package/dist/web.js +1 -2
  250. package/dist/writer.cjs +1 -2
  251. package/dist/writer.cjs.map +1 -1
  252. package/dist/writer.js +1 -2
  253. package/dist/writer.js.map +1 -1
  254. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/state/schema.ts"],"mappings":";;;;;;;;;cAmBM,mBAAA;;AAFiD;;;;;AA2BvD;;;;;;;;;;;;;;;;;KAAY,yBAAA,MAA+B,CAAA,SAAU,YAAA,qBAIjD,WAAA,CAAY,CAAA,EAAG,cAAA,CAAe,CAAA,IAAK,CAAA,IACnC,CAAA,SAAU,cAAA,YACV,WAAA,CAAY,CAAA,EAAG,CAAA,IACf,CAAA,SAAU,kBAAA,qBACV,WAAA,CAAY,CAAA,EAAG,CAAA,IACf,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+BQ,kCAAA,iBACM,iBAAA,kBAEJ,OAAA,GAAU,yBAAA,CAA0B,OAAA,CAAQ,CAAA;;;;;KAO9C,gBAAA,2BAA2C,KAAA,IACnD,YAAA,CAAa,KAAA,EAAO,MAAA,IACpB,cAAA,CAAe,MAAA,IACf,kBAAA,CAAmB,KAAA,EAAO,MAAA;;;;;KAMlB,iBAAA;EAAA,CACT,GAAA,WAAc,gBAAA;AAAA;;;;;;;AAVjB;;KAqBY,qBAAA,iBAAsC,iBAAA,kBACpC,OAAA,GAAU,OAAA,CAAQ,CAAA,UAAW,YAAA,aACrC,OAAA,CAAQ,CAAA,iBACR,OAAA,CAAQ,CAAA,UAAW,cAAA,QACnB,OAAA,CAAQ,CAAA,iBACR,OAAA,CAAQ,CAAA,UAAW,kBAAA,uBACnB,OAAA;;;;;;;;;KAYM,sBAAA,iBAAuC,iBAAA,kBACrC,OAAA,IAAW,OAAA,CAAQ,CAAA,UAAW,YAAA,qBACtC,cAAA,CAAe,CAAA,IAAK,CAAA,GACpB,OAAA,CAAQ,CAAA,UAAW,c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Ae,CAAA,IAAK,CAAA,GACpB,OAAA,CAAQ,CAAA,UAAW,cAAA,QACnB,OAAA,CAAQ,CAAA,iBACR,OAAA,CAAQ,CAAA,UAAW,kBAAA,sBACnB,MAAA;;;;;;;;;;;;;AApCN;;;;;AAYA;;;;;;;;;;;;;;;;cA6Da,WAAA,iBAA4B,iBAAA;EAAA,SAwClB,MAAA,EAAQ,OAAA;EAhGY;;;;EAAA,kBA8DvB,mBAAA;EAlEN;;;;EAwEJ,KAAA,EAAO,qBAAA,CAAsB,OAAA;EAvEzB;;;;EA6EJ,MAAA,EAAQ,sBAAA,CAAuB,OAAA;EA3E3B;;;;;;;;AAcd;;;;;;;EA8EU,IAAA,EAAM,YAAA,CACZ,qBAAA,CAAsB,OAAA,GACtB,sBAAA,CAAuB,OAAA;EAGzB,WAAA,CAAqB,MAAA,EAAQ,OAAA;EAjFzB;;;;EAuFJ,WAAA,CAAA,GAAe,MAAA,SAAe,WAAA;EArF1B;;;;EA2HJ,aAAA,CAAA,GAAiB,UAAA;EA1HwB;;;;EAgLzC,kBAAA,CAAA,GAAsB,UAAA;EApLV;;;EAwNZ,cAAA,CAAA;EAxN6D;;;EA+N7D,UAAA,CAAA;EA9NwB;;;;;;;EAyOlB,aAAA,GAAA,CAAiB,IAAA,EAAM,CAAA,GAAI,OAAA,CAAQ,CAAA;EAtOlB;;;;;AAsCzB;EAtCyB,OA2RhB,UAAA,iBAA2B,iBAAA,CAAA,CAChC,KAAA,EAAO,WAAA,CAAY,OAAA,IAClB,KAAA,IAAS,WAAA,CAAY,OAAA;EAAA,OAEjB,UAAA,CAAW,KAAA,YAAiB,KAAA,IAAS,WAAA;AAAA;AAAA,KAclC,cAAA,GAAiB,WAAA"}
@@ -6,7 +6,6 @@ import { UntrackedValueChannel } from "../channels/untracked_value.js";
6
6
  import "../channels/index.js";
7
7
  import { ReducedValue } from "./values/reduced.js";
8
8
  import { UntrackedValue } from "./values/untracked.js";
9
-
10
9
  //#region src/state/schema.ts
11
10
  const STATE_SCHEMA_SYMBOL = Symbol.for("langgraph.state.state_schema");
12
11
  /**
@@ -110,8 +109,13 @@ var StateSchema = class {
110
109
  const properties = {};
111
110
  for (const [key, value] of Object.entries(this.fields)) {
112
111
  let fieldSchema;
113
- if (ReducedValue.isInstance(value)) fieldSchema = getJsonSchemaFromSchema(value.inputSchema);
114
- else if (UntrackedValue.isInstance(value)) fieldSchema = value.schema ? getJsonSchemaFromSchema(value.schema) : void 0;
112
+ if (ReducedValue.isInstance(value)) {
113
+ fieldSchema = getJsonSchemaFromSchema(value.inputSchema);
114
+ if (value.jsonSchemaExtra) fieldSchema = {
115
+ ...fieldSchema ?? {},
116
+ ...value.jsonSchemaExtra
117
+ };
118
+ } else if (UntrackedValue.isInstance(value)) fieldSchema = value.schema ? getJsonSchemaFromSchema(value.schema) : void 0;
115
119
  else if (isStandardSchema(value)) fieldSchema = getJsonSchemaFromSchema(value);
116
120
  if (fieldSchema) properties[key] = fieldSchema;
117
121
  }
@@ -164,7 +168,7 @@ var StateSchema = class {
164
168
  return typeof value === "object" && value !== null && STATE_SCHEMA_SYMBOL in value && value[STATE_SCHEMA_SYMBOL] === true;
165
169
  }
166
170
  };
167
-
168
171
  //#endregion
169
172
  export { StateSchema };
173
+
170
174
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../../src/state/schema.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { JSONSchema } from \"@langchain/core/utils/json_schema\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nimport type { RunnableLike } from \"../pregel/runnable_types.js\";\nimport {\n BaseChannel,\n LastValue,\n BinaryOperatorAggregate,\n} from \"../channels/index.js\";\nimport { UntrackedValueChannel } from \"../channels/untracked_value.js\";\n\nimport type { SerializableSchema } from \"./types.js\";\nimport { isStandardSchema } from \"./types.js\";\nimport { getJsonSchemaFromSchema, getSchemaDefaultGetter } from \"./adapter.js\";\nimport type { OverwriteValue } from \"../constants.js\";\nimport { ReducedValue } from \"./values/reduced.js\";\nimport { UntrackedValue } from \"./values/untracked.js\";\n\nconst STATE_SCHEMA_SYMBOL = Symbol.for(\"langgraph.state.state_schema\");\n\n/**\n * Maps a single StateSchema field definition to its corresponding Channel type.\n *\n * This utility type inspects the type of the field and returns an appropriate\n * `BaseChannel` type, parameterized with the state \"value\" and \"input\" types according to the field's shape.\n *\n * Rules:\n * - If the field (`F`) is a `ReducedValue<V, I>`, the channel will store values of type `V`\n * and accept input of type `I`.\n * - If the field is a `UntrackedValue<V>`, the channel will store and accept values of type `V`.\n * - If the field is a `SerializableSchema<I, O>`, the channel will store values of type `O`\n * (the schema's output/validated value) and accept input of type `I`.\n * - For all other types, a generic `BaseChannel<unknown, unknown>` is used as fallback.\n *\n * @template F - The StateSchema field type to map to a Channel type.\n *\n * @example\n * ```typescript\n * type MyField = ReducedValue<number, string>;\n * type ChannelType = StateSchemaFieldToChannel<MyField>;\n * // ChannelType is BaseChannel<number, string>\n * ```\n */\nexport type StateSchemaFieldToChannel<F> = F extends ReducedValue<\n infer V,\n infer I\n>\n ? BaseChannel<V, OverwriteValue<V> | I>\n : F extends UntrackedValue<infer V>\n ? BaseChannel<V, V>\n : F extends SerializableSchema<infer I, infer O>\n ? BaseChannel<O, I>\n : BaseChannel<unknown, unknown>;\n\n/**\n * Converts StateSchema fields into a strongly-typed\n * State Definition object, where each field is mapped to its channel type.\n *\n * This utility type is used internally to create the shape of the state channels for a given schema,\n * substituting each field with the result of `StateSchemaFieldToChannel`.\n *\n * If you define a state schema as:\n * ```typescript\n * const fields = {\n * a: ReducedValue<number, string>(),\n * b: UntrackedValue<boolean>(),\n * c: SomeSerializableSchemaType, // SerializableSchema<in, out>\n * }\n * ```\n * then `StateSchemaFieldsToStateDefinition<typeof fields>` yields:\n * ```typescript\n * {\n * a: BaseChannel<number, string>;\n * b: BaseChannel<boolean, boolean>;\n * c: BaseChannel<typeof schema's output type, typeof schema's input type>;\n * }\n * ```\n *\n * @template TFields - The mapping of field names to StateSchema field types.\n * @returns An object type mapping field names to channel types.\n *\n * @see StateSchemaFieldToChannel\n */\nexport type StateSchemaFieldsToStateDefinition<\n TFields extends StateSchemaFields\n> = {\n [K in keyof TFields]: StateSchemaFieldToChannel<TFields[K]>;\n};\n\n/**\n * Valid field types for StateSchema.\n * Either a LangGraph state value type or a raw schema (e.g., Zod schema).\n */\nexport type StateSchemaField<Input = unknown, Output = Input> =\n | ReducedValue<Input, Output>\n | UntrackedValue<Output>\n | SerializableSchema<Input, Output>;\n\n/**\n * Init object for StateSchema constructor.\n * Uses `any` to allow variance in generic types (e.g., ReducedValue<string, string[]>).\n */\nexport type StateSchemaFields = {\n [key: string]: StateSchemaField<any, any>;\n};\n\n/**\n * Infer the State type from a StateSchemaFields.\n * This is the type of the full state object.\n *\n * - ReducedValue<Value, Input> → Value (the stored type)\n * - UntrackedValue<Value> → Value\n * - SerializableSchema<Input, Output> → Output (the validated type)\n */\nexport type InferStateSchemaValue<TFields extends StateSchemaFields> = {\n [K in keyof TFields]: TFields[K] extends ReducedValue<any, any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends UntrackedValue<any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends SerializableSchema<any, infer TOutput>\n ? TOutput\n : never;\n};\n\n/**\n * Infer the Update type from a StateSchemaFields.\n * This is the type for partial updates to state.\n *\n * - ReducedValue<Value, Input> → Input (the reducer input type)\n * - UntrackedValue<Value> → Value\n * - SerializableSchema<Input, Output> → Input (what you provide)\n */\nexport type InferStateSchemaUpdate<TFields extends StateSchemaFields> = {\n [K in keyof TFields]?: TFields[K] extends ReducedValue<infer V, infer I>\n ? OverwriteValue<V> | I\n : TFields[K] extends UntrackedValue<any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends SerializableSchema<infer TInput, any>\n ? TInput\n : never;\n};\n\n/**\n * StateSchema provides a unified API for defining LangGraph state schemas.\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import { StateSchema, ReducedValue, MessagesValue } from \"@langchain/langgraph\";\n *\n * const AgentState = new StateSchema({\n * // Prebuilt messages value\n * messages: MessagesValue,\n * // Basic LastValue channel from any standard schema\n * currentStep: z.string(),\n * // LastValue with native default\n * count: z.number().default(0),\n * // ReducedValue for fields needing reducers\n * history: new ReducedValue(\n * z.array(z.string()).default(() => []),\n * {\n * inputSchema: z.string(),\n * reducer: (current, next) => [...current, next],\n * }\n * ),\n * });\n *\n * // Extract types\n * type State = typeof AgentState.State;\n * type Update = typeof AgentState.Update;\n *\n * // Use in StateGraph\n * const graph = new StateGraph(AgentState);\n * ```\n */\nexport class StateSchema<TFields extends StateSchemaFields> {\n /**\n * Symbol for runtime identification.\n * @internal Used by isInstance for runtime type checking\n */\n // @ts-expect-error - Symbol is read via `in` operator in isInstance\n private readonly [STATE_SCHEMA_SYMBOL] = true;\n\n /**\n * Type declaration for the full state type.\n * Use: `typeof myState.State`\n */\n declare State: InferStateSchemaValue<TFields>;\n\n /**\n * Type declaration for the update type.\n * Use: `typeof myState.Update`\n */\n declare Update: InferStateSchemaUpdate<TFields>;\n\n /**\n * Type declaration for node functions.\n * Use: `typeof myState.Node` to type node functions outside the graph builder.\n *\n * @example\n * ```typescript\n * const AgentState = new StateSchema({\n * count: z.number().default(0),\n * });\n *\n * const myNode: typeof AgentState.Node = (state) => {\n * return { count: state.count + 1 };\n * };\n * ```\n */\n declare Node: RunnableLike<\n InferStateSchemaValue<TFields>,\n InferStateSchemaUpdate<TFields>\n >;\n\n constructor(readonly fields: TFields) {}\n\n /**\n * Get the channel definitions for use with StateGraph.\n * This converts the StateSchema fields into BaseChannel instances.\n */\n getChannels(): Record<string, BaseChannel> {\n const channels: Record<string, BaseChannel> = {};\n\n for (const [key, value] of Object.entries(this.fields)) {\n if (ReducedValue.isInstance(value)) {\n // ReducedValue -> BinaryOperatorAggregate\n const defaultGetter = getSchemaDefaultGetter(value.valueSchema);\n channels[key] = new BinaryOperatorAggregate(\n value.reducer,\n defaultGetter\n );\n } else if (UntrackedValue.isInstance(value)) {\n // UntrackedValue -> UntrackedValueChannel\n const defaultGetter = value.schema\n ? getSchemaDefaultGetter(value.schema)\n : undefined;\n channels[key] = new UntrackedValueChannel({\n guard: value.guard,\n initialValueFactory: defaultGetter,\n });\n } else if (isStandardSchema(value)) {\n // Plain schema -> LastValue channel\n const defaultGetter = getSchemaDefaultGetter(value);\n channels[key] = new LastValue(defaultGetter);\n } else {\n throw new Error(\n `Invalid state field \"${key}\": must be a schema, ReducedValue, UntrackedValue, or ManagedValue`\n );\n }\n }\n\n return channels;\n }\n\n /**\n * Get the JSON schema for the full state type.\n * Used by Studio and API for schema introspection.\n */\n getJsonSchema(): JSONSchema {\n const properties: Record<string, JSONSchema> = {};\n const required: string[] = [];\n\n for (const [key, value] of Object.entries(this.fields)) {\n let fieldSchema: JSONSchema | undefined;\n\n if (ReducedValue.isInstance(value)) {\n fieldSchema = getJsonSchemaFromSchema(value.valueSchema) as JSONSchema;\n // Merge jsonSchemaExtra even if base schema is undefined\n if (value.jsonSchemaExtra) {\n fieldSchema = { ...(fieldSchema ?? {}), ...value.jsonSchemaExtra };\n }\n } else if (UntrackedValue.isInstance(value)) {\n fieldSchema = value.schema\n ? (getJsonSchemaFromSchema(value.schema) as JSONSchema)\n : undefined;\n } else if (isStandardSchema(value)) {\n fieldSchema = getJsonSchemaFromSchema(value) as JSONSchema;\n }\n\n if (fieldSchema) {\n properties[key] = fieldSchema;\n\n // Field is required if it doesn't have a default\n let hasDefault = false;\n if (ReducedValue.isInstance(value)) {\n hasDefault = getSchemaDefaultGetter(value.valueSchema) !== undefined;\n } else if (UntrackedValue.isInstance(value)) {\n hasDefault = value.schema\n ? getSchemaDefaultGetter(value.schema) !== undefined\n : false;\n } else {\n hasDefault = getSchemaDefaultGetter(value) !== undefined;\n }\n\n if (!hasDefault) {\n required.push(key);\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n required: required.length > 0 ? required : undefined,\n };\n }\n\n /**\n * Get the JSON schema for the update/input type.\n * All fields are optional in updates.\n */\n getInputJsonSchema(): JSONSchema {\n const properties: Record<string, JSONSchema> = {};\n\n for (const [key, value] of Object.entries(this.fields)) {\n let fieldSchema: JSONSchema | undefined;\n\n if (ReducedValue.isInstance(value)) {\n // Use input schema for updates\n fieldSchema = getJsonSchemaFromSchema(value.inputSchema) as JSONSchema;\n } else if (UntrackedValue.isInstance(value)) {\n fieldSchema = value.schema\n ? (getJsonSchemaFromSchema(value.schema) as JSONSchema)\n : undefined;\n } else if (isStandardSchema(value)) {\n fieldSchema = getJsonSchemaFromSchema(value) as JSONSchema;\n }\n\n if (fieldSchema) {\n properties[key] = fieldSchema;\n }\n }\n\n return {\n type: \"object\",\n properties,\n };\n }\n\n /**\n * Get the list of channel keys (excluding managed values).\n */\n getChannelKeys(): string[] {\n return Object.entries(this.fields).map(([key]) => key);\n }\n\n /**\n * Get all keys (channels + managed values).\n */\n getAllKeys(): string[] {\n return Object.keys(this.fields);\n }\n\n /**\n * Validate input data against the schema.\n * This validates each field using its corresponding schema.\n *\n * @param data - The input data to validate\n * @returns The validated data with coerced types\n */\n async validateInput<T>(data: T): Promise<T> {\n if (data == null || typeof data !== \"object\") {\n return data;\n }\n\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(data)) {\n const fieldDef = this.fields[key];\n\n if (fieldDef === undefined) {\n // Unknown field, pass through\n result[key] = value;\n continue;\n }\n\n // Get the schema to use for validation\n let schema: StandardSchemaV1 | undefined;\n\n if (ReducedValue.isInstance(fieldDef)) {\n schema = fieldDef.inputSchema;\n } else if (UntrackedValue.isInstance(fieldDef)) {\n schema = fieldDef.schema;\n } else if (isStandardSchema(fieldDef)) {\n schema = fieldDef;\n }\n\n if (schema) {\n // Validate using standard schema\n const validationResult = await schema[\"~standard\"].validate(value);\n if (validationResult.issues) {\n throw new Error(\n `Validation failed for field \"${key}\": ${JSON.stringify(\n validationResult.issues\n )}`\n );\n }\n result[key] = validationResult.value;\n } else {\n // No schema or not a standard schema, pass through\n result[key] = value;\n }\n }\n\n return result as T;\n }\n\n /**\n * Type guard to check if a value is a StateSchema instance.\n *\n * @param value - The value to check.\n * @returns True if the value is a StateSchema instance with the correct runtime tag.\n */\n static isInstance<TFields extends StateSchemaFields>(\n value: StateSchema<TFields>\n ): value is StateSchema<TFields>;\n\n static isInstance(value: unknown): value is StateSchema<any>;\n\n static isInstance<TFields extends StateSchemaFields>(\n value: unknown\n ): value is StateSchema<TFields> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n STATE_SCHEMA_SYMBOL in value &&\n value[STATE_SCHEMA_SYMBOL] === true\n );\n }\n}\n\nexport type AnyStateSchema = StateSchema<any>;\n"],"mappings":";;;;;;;;;;AAmBA,MAAM,sBAAsB,OAAO,IAAI,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6JtE,IAAa,cAAb,MAA4D;;;;;CAM1D,CAAkB,uBAAuB;CAkCzC,YAAY,AAAS,QAAiB;EAAjB;;;;;;CAMrB,cAA2C;EACzC,MAAM,WAAwC,EAAE;AAEhD,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,OAAO,CACpD,KAAI,aAAa,WAAW,MAAM,EAAE;GAElC,MAAM,gBAAgB,uBAAuB,MAAM,YAAY;AAC/D,YAAS,OAAO,IAAI,wBAClB,MAAM,SACN,cACD;aACQ,eAAe,WAAW,MAAM,EAAE;GAE3C,MAAM,gBAAgB,MAAM,SACxB,uBAAuB,MAAM,OAAO,GACpC;AACJ,YAAS,OAAO,IAAI,sBAAsB;IACxC,OAAO,MAAM;IACb,qBAAqB;IACtB,CAAC;aACO,iBAAiB,MAAM,CAGhC,UAAS,OAAO,IAAI,UADE,uBAAuB,MAAM,CACP;MAE5C,OAAM,IAAI,MACR,wBAAwB,IAAI,oEAC7B;AAIL,SAAO;;;;;;CAOT,gBAA4B;EAC1B,MAAM,aAAyC,EAAE;EACjD,MAAM,WAAqB,EAAE;AAE7B,OAAK,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cAAiB,MAAqB;AAC1C,MAAI,QAAQ,QAAQ,OAAO,SAAS,SAClC,QAAO;EAGT,MAAM,SAAkC,EAAE;AAE1C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,EAAE;GAC/C,MAAM,WAAW,KAAK,OAAO;AAE7B,OAAI,aAAa,QAAW;AAE1B,WAAO,OAAO;AACd;;GAIF,IAAI;AAEJ,OAAI,aAAa,WAAW,SAAS,CACnC,UAAS,SAAS;YACT,eAAe,WAAW,SAAS,CAC5C,UAAS,SAAS;YACT,iBAAiB,SAAS,CACnC,UAAS;AAGX,OAAI,QAAQ;IAEV,MAAM,mBAAmB,MAAM,OAAO,aAAa,SAAS,MAAM;AAClE,QAAI,iBAAiB,OACnB,OAAM,IAAI,MACR,gCAAgC,IAAI,KAAK,KAAK,UAC5C,iBAAiB,OAClB,GACF;AAEH,WAAO,OAAO,iBAAiB;SAG/B,QAAO,OAAO;;AAIlB,SAAO;;CAeT,OAAO,WACL,OAC+B;AAC/B,SACE,OAAO,UAAU,YACjB,UAAU,QACV,uBAAuB,SACvB,MAAM,yBAAyB"}
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../src/state/schema.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { JSONSchema } from \"@langchain/core/utils/json_schema\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nimport type { RunnableLike } from \"../pregel/runnable_types.js\";\nimport {\n BaseChannel,\n LastValue,\n BinaryOperatorAggregate,\n} from \"../channels/index.js\";\nimport { UntrackedValueChannel } from \"../channels/untracked_value.js\";\n\nimport type { SerializableSchema } from \"./types.js\";\nimport { isStandardSchema } from \"./types.js\";\nimport { getJsonSchemaFromSchema, getSchemaDefaultGetter } from \"./adapter.js\";\nimport type { OverwriteValue } from \"../constants.js\";\nimport { ReducedValue } from \"./values/reduced.js\";\nimport { UntrackedValue } from \"./values/untracked.js\";\n\nconst STATE_SCHEMA_SYMBOL = Symbol.for(\"langgraph.state.state_schema\");\n\n/**\n * Maps a single StateSchema field definition to its corresponding Channel type.\n *\n * This utility type inspects the type of the field and returns an appropriate\n * `BaseChannel` type, parameterized with the state \"value\" and \"input\" types according to the field's shape.\n *\n * Rules:\n * - If the field (`F`) is a `ReducedValue<V, I>`, the channel will store values of type `V`\n * and accept input of type `I`.\n * - If the field is a `UntrackedValue<V>`, the channel will store and accept values of type `V`.\n * - If the field is a `SerializableSchema<I, O>`, the channel will store values of type `O`\n * (the schema's output/validated value) and accept input of type `I`.\n * - For all other types, a generic `BaseChannel<unknown, unknown>` is used as fallback.\n *\n * @template F - The StateSchema field type to map to a Channel type.\n *\n * @example\n * ```typescript\n * type MyField = ReducedValue<number, string>;\n * type ChannelType = StateSchemaFieldToChannel<MyField>;\n * // ChannelType is BaseChannel<number, string>\n * ```\n */\nexport type StateSchemaFieldToChannel<F> = F extends ReducedValue<\n infer V,\n infer I\n>\n ? BaseChannel<V, OverwriteValue<V> | I>\n : F extends UntrackedValue<infer V>\n ? BaseChannel<V, V>\n : F extends SerializableSchema<infer I, infer O>\n ? BaseChannel<O, I>\n : BaseChannel<unknown, unknown>;\n\n/**\n * Converts StateSchema fields into a strongly-typed\n * State Definition object, where each field is mapped to its channel type.\n *\n * This utility type is used internally to create the shape of the state channels for a given schema,\n * substituting each field with the result of `StateSchemaFieldToChannel`.\n *\n * If you define a state schema as:\n * ```typescript\n * const fields = {\n * a: ReducedValue<number, string>(),\n * b: UntrackedValue<boolean>(),\n * c: SomeSerializableSchemaType, // SerializableSchema<in, out>\n * }\n * ```\n * then `StateSchemaFieldsToStateDefinition<typeof fields>` yields:\n * ```typescript\n * {\n * a: BaseChannel<number, string>;\n * b: BaseChannel<boolean, boolean>;\n * c: BaseChannel<typeof schema's output type, typeof schema's input type>;\n * }\n * ```\n *\n * @template TFields - The mapping of field names to StateSchema field types.\n * @returns An object type mapping field names to channel types.\n *\n * @see StateSchemaFieldToChannel\n */\nexport type StateSchemaFieldsToStateDefinition<\n TFields extends StateSchemaFields\n> = {\n [K in keyof TFields]: StateSchemaFieldToChannel<TFields[K]>;\n};\n\n/**\n * Valid field types for StateSchema.\n * Either a LangGraph state value type or a raw schema (e.g., Zod schema).\n */\nexport type StateSchemaField<Input = unknown, Output = Input> =\n | ReducedValue<Input, Output>\n | UntrackedValue<Output>\n | SerializableSchema<Input, Output>;\n\n/**\n * Init object for StateSchema constructor.\n * Uses `any` to allow variance in generic types (e.g., ReducedValue<string, string[]>).\n */\nexport type StateSchemaFields = {\n [key: string]: StateSchemaField<any, any>;\n};\n\n/**\n * Infer the State type from a StateSchemaFields.\n * This is the type of the full state object.\n *\n * - ReducedValue<Value, Input> → Value (the stored type)\n * - UntrackedValue<Value> → Value\n * - SerializableSchema<Input, Output> → Output (the validated type)\n */\nexport type InferStateSchemaValue<TFields extends StateSchemaFields> = {\n [K in keyof TFields]: TFields[K] extends ReducedValue<any, any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends UntrackedValue<any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends SerializableSchema<any, infer TOutput>\n ? TOutput\n : never;\n};\n\n/**\n * Infer the Update type from a StateSchemaFields.\n * This is the type for partial updates to state.\n *\n * - ReducedValue<Value, Input> → Input (the reducer input type)\n * - UntrackedValue<Value> → Value\n * - SerializableSchema<Input, Output> → Input (what you provide)\n */\nexport type InferStateSchemaUpdate<TFields extends StateSchemaFields> = {\n [K in keyof TFields]?: TFields[K] extends ReducedValue<infer V, infer I>\n ? OverwriteValue<V> | I\n : TFields[K] extends UntrackedValue<any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends SerializableSchema<infer TInput, any>\n ? TInput\n : never;\n};\n\n/**\n * StateSchema provides a unified API for defining LangGraph state schemas.\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import { StateSchema, ReducedValue, MessagesValue } from \"@langchain/langgraph\";\n *\n * const AgentState = new StateSchema({\n * // Prebuilt messages value\n * messages: MessagesValue,\n * // Basic LastValue channel from any standard schema\n * currentStep: z.string(),\n * // LastValue with native default\n * count: z.number().default(0),\n * // ReducedValue for fields needing reducers\n * history: new ReducedValue(\n * z.array(z.string()).default(() => []),\n * {\n * inputSchema: z.string(),\n * reducer: (current, next) => [...current, next],\n * }\n * ),\n * });\n *\n * // Extract types\n * type State = typeof AgentState.State;\n * type Update = typeof AgentState.Update;\n *\n * // Use in StateGraph\n * const graph = new StateGraph(AgentState);\n * ```\n */\nexport class StateSchema<TFields extends StateSchemaFields> {\n /**\n * Symbol for runtime identification.\n * @internal Used by isInstance for runtime type checking\n */\n // @ts-expect-error - Symbol is read via `in` operator in isInstance\n private readonly [STATE_SCHEMA_SYMBOL] = true;\n\n /**\n * Type declaration for the full state type.\n * Use: `typeof myState.State`\n */\n declare State: InferStateSchemaValue<TFields>;\n\n /**\n * Type declaration for the update type.\n * Use: `typeof myState.Update`\n */\n declare Update: InferStateSchemaUpdate<TFields>;\n\n /**\n * Type declaration for node functions.\n * Use: `typeof myState.Node` to type node functions outside the graph builder.\n *\n * @example\n * ```typescript\n * const AgentState = new StateSchema({\n * count: z.number().default(0),\n * });\n *\n * const myNode: typeof AgentState.Node = (state) => {\n * return { count: state.count + 1 };\n * };\n * ```\n */\n declare Node: RunnableLike<\n InferStateSchemaValue<TFields>,\n InferStateSchemaUpdate<TFields>\n >;\n\n constructor(readonly fields: TFields) {}\n\n /**\n * Get the channel definitions for use with StateGraph.\n * This converts the StateSchema fields into BaseChannel instances.\n */\n getChannels(): Record<string, BaseChannel> {\n const channels: Record<string, BaseChannel> = {};\n\n for (const [key, value] of Object.entries(this.fields)) {\n if (ReducedValue.isInstance(value)) {\n // ReducedValue -> BinaryOperatorAggregate\n const defaultGetter = getSchemaDefaultGetter(value.valueSchema);\n channels[key] = new BinaryOperatorAggregate(\n value.reducer,\n defaultGetter\n );\n } else if (UntrackedValue.isInstance(value)) {\n // UntrackedValue -> UntrackedValueChannel\n const defaultGetter = value.schema\n ? getSchemaDefaultGetter(value.schema)\n : undefined;\n channels[key] = new UntrackedValueChannel({\n guard: value.guard,\n initialValueFactory: defaultGetter,\n });\n } else if (isStandardSchema(value)) {\n // Plain schema -> LastValue channel\n const defaultGetter = getSchemaDefaultGetter(value);\n channels[key] = new LastValue(defaultGetter);\n } else {\n throw new Error(\n `Invalid state field \"${key}\": must be a schema, ReducedValue, UntrackedValue, or ManagedValue`\n );\n }\n }\n\n return channels;\n }\n\n /**\n * Get the JSON schema for the full state type.\n * Used by Studio and API for schema introspection.\n */\n getJsonSchema(): JSONSchema {\n const properties: Record<string, JSONSchema> = {};\n const required: string[] = [];\n\n for (const [key, value] of Object.entries(this.fields)) {\n let fieldSchema: JSONSchema | undefined;\n\n if (ReducedValue.isInstance(value)) {\n fieldSchema = getJsonSchemaFromSchema(value.valueSchema) as JSONSchema;\n // Merge jsonSchemaExtra (e.g. langgraph_type) into the field schema,\n // even if base schema is undefined\n if (value.jsonSchemaExtra) {\n fieldSchema = { ...(fieldSchema ?? {}), ...value.jsonSchemaExtra };\n }\n } else if (UntrackedValue.isInstance(value)) {\n fieldSchema = value.schema\n ? (getJsonSchemaFromSchema(value.schema) as JSONSchema)\n : undefined;\n } else if (isStandardSchema(value)) {\n fieldSchema = getJsonSchemaFromSchema(value) as JSONSchema;\n }\n\n if (fieldSchema) {\n properties[key] = fieldSchema;\n\n // Field is required if it doesn't have a default\n let hasDefault = false;\n if (ReducedValue.isInstance(value)) {\n hasDefault = getSchemaDefaultGetter(value.valueSchema) !== undefined;\n } else if (UntrackedValue.isInstance(value)) {\n hasDefault = value.schema\n ? getSchemaDefaultGetter(value.schema) !== undefined\n : false;\n } else {\n hasDefault = getSchemaDefaultGetter(value) !== undefined;\n }\n\n if (!hasDefault) {\n required.push(key);\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n required: required.length > 0 ? required : undefined,\n };\n }\n\n /**\n * Get the JSON schema for the update/input type.\n * All fields are optional in updates.\n */\n getInputJsonSchema(): JSONSchema {\n const properties: Record<string, JSONSchema> = {};\n\n for (const [key, value] of Object.entries(this.fields)) {\n let fieldSchema: JSONSchema | undefined;\n\n if (ReducedValue.isInstance(value)) {\n // Use input schema for updates\n fieldSchema = getJsonSchemaFromSchema(value.inputSchema) as JSONSchema;\n // Merge jsonSchemaExtra (e.g. langgraph_type) into the field schema,\n // even if base schema is undefined\n if (value.jsonSchemaExtra) {\n fieldSchema = { ...(fieldSchema ?? {}), ...value.jsonSchemaExtra };\n }\n } else if (UntrackedValue.isInstance(value)) {\n fieldSchema = value.schema\n ? (getJsonSchemaFromSchema(value.schema) as JSONSchema)\n : undefined;\n } else if (isStandardSchema(value)) {\n fieldSchema = getJsonSchemaFromSchema(value) as JSONSchema;\n }\n\n if (fieldSchema) {\n properties[key] = fieldSchema;\n }\n }\n\n return {\n type: \"object\",\n properties,\n };\n }\n\n /**\n * Get the list of channel keys (excluding managed values).\n */\n getChannelKeys(): string[] {\n return Object.entries(this.fields).map(([key]) => key);\n }\n\n /**\n * Get all keys (channels + managed values).\n */\n getAllKeys(): string[] {\n return Object.keys(this.fields);\n }\n\n /**\n * Validate input data against the schema.\n * This validates each field using its corresponding schema.\n *\n * @param data - The input data to validate\n * @returns The validated data with coerced types\n */\n async validateInput<T>(data: T): Promise<T> {\n if (data == null || typeof data !== \"object\") {\n return data;\n }\n\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(data)) {\n const fieldDef = this.fields[key];\n\n if (fieldDef === undefined) {\n // Unknown field, pass through\n result[key] = value;\n continue;\n }\n\n // Get the schema to use for validation\n let schema: StandardSchemaV1 | undefined;\n\n if (ReducedValue.isInstance(fieldDef)) {\n schema = fieldDef.inputSchema;\n } else if (UntrackedValue.isInstance(fieldDef)) {\n schema = fieldDef.schema;\n } else if (isStandardSchema(fieldDef)) {\n schema = fieldDef;\n }\n\n if (schema) {\n // Validate using standard schema\n const validationResult = await schema[\"~standard\"].validate(value);\n if (validationResult.issues) {\n throw new Error(\n `Validation failed for field \"${key}\": ${JSON.stringify(\n validationResult.issues\n )}`\n );\n }\n result[key] = validationResult.value;\n } else {\n // No schema or not a standard schema, pass through\n result[key] = value;\n }\n }\n\n return result as T;\n }\n\n /**\n * Type guard to check if a value is a StateSchema instance.\n *\n * @param value - The value to check.\n * @returns True if the value is a StateSchema instance with the correct runtime tag.\n */\n static isInstance<TFields extends StateSchemaFields>(\n value: StateSchema<TFields>\n ): value is StateSchema<TFields>;\n\n static isInstance(value: unknown): value is StateSchema<any>;\n\n static isInstance<TFields extends StateSchemaFields>(\n value: unknown\n ): value is StateSchema<TFields> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n STATE_SCHEMA_SYMBOL in value &&\n value[STATE_SCHEMA_SYMBOL] === true\n );\n }\n}\n\nexport type AnyStateSchema = StateSchema<any>;\n"],"mappings":";;;;;;;;;AAmBA,MAAM,sBAAsB,OAAO,IAAI,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6JtE,IAAa,cAAb,MAA4D;;;;;CAM1D,CAAkB,uBAAuB;CAkCzC,YAAY,QAA0B;AAAjB,OAAA,SAAA;;;;;;CAMrB,cAA2C;EACzC,MAAM,WAAwC,EAAE;AAEhD,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,OAAO,CACpD,KAAI,aAAa,WAAW,MAAM,EAAE;GAElC,MAAM,gBAAgB,uBAAuB,MAAM,YAAY;AAC/D,YAAS,OAAO,IAAI,wBAClB,MAAM,SACN,cACD;aACQ,eAAe,WAAW,MAAM,EAAE;GAE3C,MAAM,gBAAgB,MAAM,SACxB,uBAAuB,MAAM,OAAO,GACpC,KAAA;AACJ,YAAS,OAAO,IAAI,sBAAsB;IACxC,OAAO,MAAM;IACb,qBAAqB;IACtB,CAAC;aACO,iBAAiB,MAAM,CAGhC,UAAS,OAAO,IAAI,UADE,uBAAuB,MAAM,CACP;MAE5C,OAAM,IAAI,MACR,wBAAwB,IAAI,oEAC7B;AAIL,SAAO;;;;;;CAOT,gBAA4B;EAC1B,MAAM,aAAyC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GACD;;;;;CAMH,iBAA2B;AACzB,SAAO,OAAO,QAAQ,KAAK,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI;;;;;CAMxD,aAAuB;AACrB,SAAO,OAAO,KAAK,KAAK,OAAO;;;;;;;;;CAUjC,MAAM,cAAiB,MAAqB;AAC1C,MAAI,QAAQ,QAAQ,OAAO,SAAS,SAClC,QAAO;EAGT,MAAM,SAAkC,EAAE;AAE1C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,EAAE;GAC/C,MAAM,WAAW,KAAK,OAAO;AAE7B,OAAI,aAAa,KAAA,GAAW;AAE1B,WAAO,OAAO;AACd;;GAIF,IAAI;AAEJ,OAAI,aAAa,WAAW,SAAS,CACnC,UAAS,SAAS;YACT,eAAe,WAAW,SAAS,CAC5C,UAAS,SAAS;YACT,iBAAiB,SAAS,CACnC,UAAS;AAGX,OAAI,QAAQ;IAEV,MAAM,mBAAmB,MAAM,OAAO,aAAa,SAAS,MAAM;AAClE,QAAI,iBAAiB,OACnB,OAAM,IAAI,MACR,gCAAgC,IAAI,KAAK,KAAK,UAC5C,iBAAiB,OAClB,GACF;AAEH,WAAO,OAAO,iBAAiB;SAG/B,QAAO,OAAO;;AAIlB,SAAO;;CAeT,OAAO,WACL,OAC+B;AAC/B,SACE,OAAO,UAAU,YACjB,UAAU,QACV,uBAAuB,SACvB,MAAM,yBAAyB"}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/state/types.ts
3
2
  function isStandardSchema(schema) {
4
3
  return typeof schema === "object" && schema !== null && "~standard" in schema && typeof schema["~standard"] === "object" && schema["~standard"] !== null && "validate" in schema["~standard"];
@@ -9,9 +8,9 @@ function isStandardJSONSchema(schema) {
9
8
  function isSerializableSchema(schema) {
10
9
  return isStandardSchema(schema) && isStandardJSONSchema(schema);
11
10
  }
12
-
13
11
  //#endregion
14
12
  exports.isSerializableSchema = isSerializableSchema;
15
13
  exports.isStandardJSONSchema = isStandardJSONSchema;
16
14
  exports.isStandardSchema = isStandardSchema;
15
+
17
16
  //# sourceMappingURL=types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":[],"sources":["../../src/state/types.ts"],"sourcesContent":["import type {\n StandardSchemaV1,\n StandardJSONSchemaV1,\n StandardTypedV1,\n} from \"@standard-schema/spec\";\n\ninterface CombinedProps<Input = unknown, Output = Input>\n extends StandardSchemaV1.Props<Input, Output>,\n StandardJSONSchemaV1.Props<Input, Output> {}\n\n/**\n * SerializableSchema is the core interface for any schema used by LangGraph state.\n *\n * @template Input - The type of input data the schema can be used to validate.\n * @template Output - The type of output produced after validation, post-refinement/coercion.\n *\n * @remarks\n * - SerializableSchema provides a single property, `~standard`, which must conform to\n * both `StandardSchemaV1.Props` and `StandardJSONSchemaV1.Props`.\n * - This ensures all schemas are compatible with both runtime validation (e.g., type checks,\n * coercion, custom refinements) and structured schema export/generation (e.g., producing\n * a compatible JSON Schema).\n * - A value matching SerializableSchema can be passed directly to LangGraph state\n * definitions, reducers, or other schema-accepting APIs.\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n *\n * // complies with SerializableSchema\n * const zodSchema = z.object({ x: z.string() });\n *\n * // Use in a StateObject definition:\n * const AgentState = new StateObject({\n * data: schema\n * });\n * ```\n */\nexport interface SerializableSchema<Input = unknown, Output = Input> {\n \"~standard\": CombinedProps<Input, Output>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace SerializableSchema {\n /**\n * Infers the type of input expected by a SerializableSchema.\n *\n * @template T - A SerializableSchema instance.\n * @returns The type of data that may be passed to the schema for validation.\n *\n * @example\n * ```ts\n * type MyInput = SerializableSchema.InferInput<typeof schema>;\n * ```\n */\n export type InferInput<T extends SerializableSchema> =\n StandardTypedV1.InferInput<T>;\n\n /**\n * Infers the output type yielded by a SerializableSchema, after parsing or coercion.\n *\n * @template T - A SerializableSchema instance.\n * @returns The type produced by successfully validating/coercing input data.\n *\n * @example\n * ```ts\n * type MyOutput = SerializableSchema.InferOutput<typeof schema>;\n * ```\n */\n export type InferOutput<T extends SerializableSchema> =\n StandardTypedV1.InferOutput<T>;\n}\n\n/**\n * Type guard to check if a given value is a Standard Schema V1 object.\n *\n * @remarks\n * A Standard Schema object is expected to have a `~standard` property with a `validate` function.\n * This guard does NOT check for JSON schema support.\n *\n * @typeParam Input - The type of input validated by this schema.\n * @typeParam Output - The type of output produced after validation.\n * @param schema - The value to test.\n * @returns True if the schema conforms to the Standard Schema interface.\n *\n * @example\n * ```ts\n * if (isStandardSchema(mySchema)) {\n * const result = mySchema[\"~standard\"].validate(input);\n * }\n * ```\n */\nexport function isStandardSchema<Input = unknown, Output = Input>(\n schema: StandardSchemaV1<Input, Output>\n): schema is StandardSchemaV1<Input, Output>;\nexport function isStandardSchema<Input = unknown, Output = Input>(\n schema: unknown\n): schema is StandardSchemaV1<Input, Output>;\nexport function isStandardSchema<Input = unknown, Output = Input>(\n schema: StandardSchemaV1<Input, Output> | unknown\n): schema is StandardSchemaV1<Input, Output> {\n return (\n typeof schema === \"object\" &&\n schema !== null &&\n \"~standard\" in schema &&\n typeof schema[\"~standard\"] === \"object\" &&\n schema[\"~standard\"] !== null &&\n \"validate\" in schema[\"~standard\"]\n );\n}\n\n/**\n * Type guard to check if a given value is a Standard JSON Schema V1 object.\n *\n * @remarks\n * A Standard JSON Schema object is expected to have a `~standard` property with a `jsonSchema` function.\n * This may be used to generate a JSON Schema (for UI/form tooling, documentation, etc).\n *\n * @typeParam Input - The type of input described by this JSON schema.\n * @typeParam Output - The type of output described by this JSON schema.\n * @param schema - The value to test.\n * @returns True if the schema exposes JSON schema generation.\n *\n * @example\n * ```ts\n * if (isStandardJSONSchema(mySchema)) {\n * const jschema = mySchema[\"~standard\"].jsonSchema();\n * }\n * ```\n */\nexport function isStandardJSONSchema<Input = unknown, Output = Input>(\n schema: StandardJSONSchemaV1<Input, Output>\n): schema is StandardJSONSchemaV1<Input, Output>;\nexport function isStandardJSONSchema<Input = unknown, Output = Input>(\n schema: unknown\n): schema is StandardJSONSchemaV1<Input, Output>;\nexport function isStandardJSONSchema<Input = unknown, Output = Input>(\n schema: StandardJSONSchemaV1<Input, Output> | unknown\n): schema is StandardJSONSchemaV1<Input, Output> {\n return (\n typeof schema === \"object\" &&\n schema !== null &&\n \"~standard\" in schema &&\n typeof schema[\"~standard\"] === \"object\" &&\n schema[\"~standard\"] !== null &&\n \"jsonSchema\" in schema[\"~standard\"]\n );\n}\n\n/**\n * Type guard to check if a given value is a `SerializableSchema`, i.e.\n * both a Standard Schema and a Standard JSON Schema object.\n *\n * @remarks\n * This checks for both the presence of a Standard Schema V1 interface\n * and the ability to generate a JSON schema.\n *\n * @typeParam Input - The type of input described by the schema.\n * @typeParam Output - The type of output described by the schema.\n * @param schema - The value to test.\n * @returns True if the schema is a valid `SerializableSchema`.\n *\n * @example\n * ```ts\n * if (isSerializableSchema(schema)) {\n * schema[\"~standard\"].validate(data);\n * const json = schema[\"~standard\"].jsonSchema();\n * }\n * ```\n */\nexport function isSerializableSchema<Input = unknown, Output = Input>(\n schema: SerializableSchema<Input, Output>\n): schema is SerializableSchema<Input, Output>;\nexport function isSerializableSchema<Input = unknown, Output = Input>(\n schema: unknown\n): schema is SerializableSchema<Input, Output>;\nexport function isSerializableSchema<Input = unknown, Output = Input>(\n schema: SerializableSchema<Input, Output> | unknown\n): schema is SerializableSchema<Input, Output> {\n return isStandardSchema(schema) && isStandardJSONSchema(schema);\n}\n"],"mappings":";;AAkGA,SAAgB,iBACd,QAC2C;AAC3C,QACE,OAAO,WAAW,YAClB,WAAW,QACX,eAAe,UACf,OAAO,OAAO,iBAAiB,YAC/B,OAAO,iBAAiB,QACxB,cAAc,OAAO;;AA6BzB,SAAgB,qBACd,QAC+C;AAC/C,QACE,OAAO,WAAW,YAClB,WAAW,QACX,eAAe,UACf,OAAO,OAAO,iBAAiB,YAC/B,OAAO,iBAAiB,QACxB,gBAAgB,OAAO;;AA+B3B,SAAgB,qBACd,QAC6C;AAC7C,QAAO,iBAAiB,OAAO,IAAI,qBAAqB,OAAO"}
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../../src/state/types.ts"],"sourcesContent":["import type {\n StandardSchemaV1,\n StandardJSONSchemaV1,\n StandardTypedV1,\n} from \"@standard-schema/spec\";\n\ninterface CombinedProps<Input = unknown, Output = Input>\n extends StandardSchemaV1.Props<Input, Output>,\n StandardJSONSchemaV1.Props<Input, Output> {}\n\n/**\n * SerializableSchema is the core interface for any schema used by LangGraph state.\n *\n * @template Input - The type of input data the schema can be used to validate.\n * @template Output - The type of output produced after validation, post-refinement/coercion.\n *\n * @remarks\n * - SerializableSchema provides a single property, `~standard`, which must conform to\n * both `StandardSchemaV1.Props` and `StandardJSONSchemaV1.Props`.\n * - This ensures all schemas are compatible with both runtime validation (e.g., type checks,\n * coercion, custom refinements) and structured schema export/generation (e.g., producing\n * a compatible JSON Schema).\n * - A value matching SerializableSchema can be passed directly to LangGraph state\n * definitions, reducers, or other schema-accepting APIs.\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n *\n * // complies with SerializableSchema\n * const zodSchema = z.object({ x: z.string() });\n *\n * // Use in a StateObject definition:\n * const AgentState = new StateObject({\n * data: schema\n * });\n * ```\n */\nexport interface SerializableSchema<Input = unknown, Output = Input> {\n \"~standard\": CombinedProps<Input, Output>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace SerializableSchema {\n /**\n * Infers the type of input expected by a SerializableSchema.\n *\n * @template T - A SerializableSchema instance.\n * @returns The type of data that may be passed to the schema for validation.\n *\n * @example\n * ```ts\n * type MyInput = SerializableSchema.InferInput<typeof schema>;\n * ```\n */\n export type InferInput<T extends SerializableSchema> =\n StandardTypedV1.InferInput<T>;\n\n /**\n * Infers the output type yielded by a SerializableSchema, after parsing or coercion.\n *\n * @template T - A SerializableSchema instance.\n * @returns The type produced by successfully validating/coercing input data.\n *\n * @example\n * ```ts\n * type MyOutput = SerializableSchema.InferOutput<typeof schema>;\n * ```\n */\n export type InferOutput<T extends SerializableSchema> =\n StandardTypedV1.InferOutput<T>;\n}\n\n/**\n * Type guard to check if a given value is a Standard Schema V1 object.\n *\n * @remarks\n * A Standard Schema object is expected to have a `~standard` property with a `validate` function.\n * This guard does NOT check for JSON schema support.\n *\n * @typeParam Input - The type of input validated by this schema.\n * @typeParam Output - The type of output produced after validation.\n * @param schema - The value to test.\n * @returns True if the schema conforms to the Standard Schema interface.\n *\n * @example\n * ```ts\n * if (isStandardSchema(mySchema)) {\n * const result = mySchema[\"~standard\"].validate(input);\n * }\n * ```\n */\nexport function isStandardSchema<Input = unknown, Output = Input>(\n schema: StandardSchemaV1<Input, Output>\n): schema is StandardSchemaV1<Input, Output>;\nexport function isStandardSchema<Input = unknown, Output = Input>(\n schema: unknown\n): schema is StandardSchemaV1<Input, Output>;\nexport function isStandardSchema<Input = unknown, Output = Input>(\n schema: StandardSchemaV1<Input, Output> | unknown\n): schema is StandardSchemaV1<Input, Output> {\n return (\n typeof schema === \"object\" &&\n schema !== null &&\n \"~standard\" in schema &&\n typeof schema[\"~standard\"] === \"object\" &&\n schema[\"~standard\"] !== null &&\n \"validate\" in schema[\"~standard\"]\n );\n}\n\n/**\n * Type guard to check if a given value is a Standard JSON Schema V1 object.\n *\n * @remarks\n * A Standard JSON Schema object is expected to have a `~standard` property with a `jsonSchema` function.\n * This may be used to generate a JSON Schema (for UI/form tooling, documentation, etc).\n *\n * @typeParam Input - The type of input described by this JSON schema.\n * @typeParam Output - The type of output described by this JSON schema.\n * @param schema - The value to test.\n * @returns True if the schema exposes JSON schema generation.\n *\n * @example\n * ```ts\n * if (isStandardJSONSchema(mySchema)) {\n * const jschema = mySchema[\"~standard\"].jsonSchema();\n * }\n * ```\n */\nexport function isStandardJSONSchema<Input = unknown, Output = Input>(\n schema: StandardJSONSchemaV1<Input, Output>\n): schema is StandardJSONSchemaV1<Input, Output>;\nexport function isStandardJSONSchema<Input = unknown, Output = Input>(\n schema: unknown\n): schema is StandardJSONSchemaV1<Input, Output>;\nexport function isStandardJSONSchema<Input = unknown, Output = Input>(\n schema: StandardJSONSchemaV1<Input, Output> | unknown\n): schema is StandardJSONSchemaV1<Input, Output> {\n return (\n typeof schema === \"object\" &&\n schema !== null &&\n \"~standard\" in schema &&\n typeof schema[\"~standard\"] === \"object\" &&\n schema[\"~standard\"] !== null &&\n \"jsonSchema\" in schema[\"~standard\"]\n );\n}\n\n/**\n * Type guard to check if a given value is a `SerializableSchema`, i.e.\n * both a Standard Schema and a Standard JSON Schema object.\n *\n * @remarks\n * This checks for both the presence of a Standard Schema V1 interface\n * and the ability to generate a JSON schema.\n *\n * @typeParam Input - The type of input described by the schema.\n * @typeParam Output - The type of output described by the schema.\n * @param schema - The value to test.\n * @returns True if the schema is a valid `SerializableSchema`.\n *\n * @example\n * ```ts\n * if (isSerializableSchema(schema)) {\n * schema[\"~standard\"].validate(data);\n * const json = schema[\"~standard\"].jsonSchema();\n * }\n * ```\n */\nexport function isSerializableSchema<Input = unknown, Output = Input>(\n schema: SerializableSchema<Input, Output>\n): schema is SerializableSchema<Input, Output>;\nexport function isSerializableSchema<Input = unknown, Output = Input>(\n schema: unknown\n): schema is SerializableSchema<Input, Output>;\nexport function isSerializableSchema<Input = unknown, Output = Input>(\n schema: SerializableSchema<Input, Output> | unknown\n): schema is SerializableSchema<Input, Output> {\n return isStandardSchema(schema) && isStandardJSONSchema(schema);\n}\n"],"mappings":";AAkGA,SAAgB,iBACd,QAC2C;AAC3C,QACE,OAAO,WAAW,YAClB,WAAW,QACX,eAAe,UACf,OAAO,OAAO,iBAAiB,YAC/B,OAAO,iBAAiB,QACxB,cAAc,OAAO;;AA6BzB,SAAgB,qBACd,QAC+C;AAC/C,QACE,OAAO,WAAW,YAClB,WAAW,QACX,eAAe,UACf,OAAO,OAAO,iBAAiB,YAC/B,OAAO,iBAAiB,QACxB,gBAAgB,OAAO;;AA+B3B,SAAgB,qBACd,QAC6C;AAC7C,QAAO,iBAAiB,OAAO,IAAI,qBAAqB,OAAO"}
@@ -8,7 +8,7 @@ function isStandardJSONSchema(schema) {
8
8
  function isSerializableSchema(schema) {
9
9
  return isStandardSchema(schema) && isStandardJSONSchema(schema);
10
10
  }
11
-
12
11
  //#endregion
13
12
  export { isSerializableSchema, isStandardJSONSchema, isStandardSchema };
13
+
14
14
  //# sourceMappingURL=types.js.map
@@ -1,2 +1,2 @@
1
- const require_reduced = require('./reduced.cjs');
2
- const require_untracked = require('./untracked.cjs');
1
+ require("./reduced.cjs");
2
+ require("./untracked.cjs");
@@ -1,4 +1,3 @@
1
- import { ReducedValue } from "./reduced.js";
2
- import { UntrackedValue } from "./untracked.js";
3
-
4
- export { };
1
+ import "./reduced.js";
2
+ import "./untracked.js";
3
+ export {};
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/state/values/reduced.ts
3
2
  /**
4
3
  * Symbol for runtime identification of ReducedValue instances.
@@ -66,7 +65,7 @@ var ReducedValue = class {
66
65
  return typeof value === "object" && value !== null && REDUCED_VALUE_SYMBOL in value && value[REDUCED_VALUE_SYMBOL] === true;
67
66
  }
68
67
  };
69
-
70
68
  //#endregion
71
69
  exports.ReducedValue = ReducedValue;
70
+
72
71
  //# sourceMappingURL=reduced.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"reduced.cjs","names":[],"sources":["../../../src/state/values/reduced.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of ReducedValue instances.\n */\nexport const REDUCED_VALUE_SYMBOL: symbol = Symbol.for(\n \"langgraph.state.reduced_value\"\n);\n\ninterface ReducedValueInitBase<Value = unknown> {\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value, and must return the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new input value to apply to the reducer.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Value) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\ninterface ReducedValueInitWithSchema<Value = unknown, Input = Value> {\n /**\n * Schema describing the type and validation logic for reducer input values.\n *\n * @remarks\n * - If provided, new values passed to the reducer will be validated using this schema before reduction.\n * - This allows the reducer to accept inputs distinct from the type stored in the state (output type).\n */\n inputSchema: SerializableSchema<unknown, Input>;\n\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value (validated using `inputSchema`), and returns the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new validated input value to be applied.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\n/**\n * Initialization options for {@link ReducedValue}.\n *\n * Two forms are supported:\n * 1. Provide only a reducer (and optionally `jsonSchemaExtra`)—in this case, the reducer's inputs are validated using the output value schema.\n * 2. Provide an explicit `inputSchema` field to distinguish the reducer's input type from the stored/output type.\n *\n * @template Value - The type of value stored and produced after reduction.\n * @template Input - The type of inputs accepted by the reducer.\n *\n * @property inputSchema - The schema describing reducer inputs. If omitted, will use the value schema.\n * @property reducer - A function that receives the current output value and a new input, and returns the new output.\n * @property jsonSchemaExtra - (Optional) Extra fields to merge into the exported JSON Schema for documentation or additional constraints.\n */\nexport type ReducedValueInit<Value = unknown, Input = Value> =\n | ReducedValueInitWithSchema<Value, Input>\n | ReducedValueInitBase<Value>;\n\n/**\n * Represents a state field whose value is computed and updated using a reducer function.\n *\n * {@link ReducedValue} allows you to define accumulators, counters, aggregators, or other fields\n * whose value is determined incrementally by applying a reducer to incoming updates.\n *\n * Each time a new input is provided, the reducer function is called with the current output\n * and the new input, producing an updated value. Input validation can be controlled separately\n * from output validation by providing an explicit input schema.\n *\n * @template Value - The type of the value stored in state and produced by reduction.\n * @template Input - The type of updates accepted by the reducer.\n *\n * @example\n * // Accumulator with distinct input validation\n * const Sum = new ReducedValue(z.number(), {\n * inputSchema: z.number().min(1),\n * reducer: (total, toAdd) => total + toAdd\n * });\n *\n * @example\n * // Simple running max, using only the value schema\n * const Max = new ReducedValue(z.number(), {\n * reducer: (current, next) => Math.max(current, next)\n * });\n */\nexport class ReducedValue<Value = unknown, Input = Value> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [REDUCED_VALUE_SYMBOL] = true as const;\n\n /**\n * The schema that describes the type of value stored in state (i.e., after reduction).\n * Note: We use `unknown` for the input type to allow schemas with `.default()` wrappers,\n * where the input type includes `undefined`.\n */\n readonly valueSchema: SerializableSchema<unknown, Value>;\n\n /**\n * The schema used to validate reducer inputs.\n * If not specified explicitly, this defaults to `valueSchema`.\n */\n readonly inputSchema: SerializableSchema<unknown, Input | Value>;\n\n /**\n * The reducer function that combines a current output value and an incoming input.\n */\n readonly reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to merge into the generated JSON Schema (e.g., for documentation or constraints).\n */\n readonly jsonSchemaExtra?: Record<string, unknown>;\n\n /**\n * Represents the value stored after all reductions.\n */\n declare ValueType: Value;\n\n /**\n * Represents the type that may be provided as input on each update.\n */\n declare InputType: Input;\n\n /**\n * Constructs a ReducedValue instance, which combines a value schema and a reducer function (plus optional input schema).\n *\n * @param valueSchema - The schema that describes the type of value stored in state (the \"running total\").\n * @param init - An object specifying the reducer function (required), inputSchema (optional), and jsonSchemaExtra (optional).\n */\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInitWithSchema<Value, Input>\n );\n\n constructor(\n valueSchema: SerializableSchema<Input, Value>,\n init: ReducedValueInitBase<Value>\n );\n\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInit<Value, Input>\n ) {\n this.reducer = init.reducer as (current: Value, next: Input) => Value;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n this.valueSchema = valueSchema;\n this.inputSchema = \"inputSchema\" in init ? init.inputSchema : valueSchema;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n }\n\n /**\n * Type guard to check if a value is a ReducedValue instance.\n */\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input>\n ): value is ReducedValue<Value, Input>;\n\n static isInstance(value: unknown): value is ReducedValue;\n\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input> | unknown\n ): value is ReducedValue<Value, Input> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n REDUCED_VALUE_SYMBOL in value &&\n (value as Record<symbol, unknown>)[REDUCED_VALUE_SYMBOL] === true\n );\n }\n}\n"],"mappings":";;;;;AAKA,MAAa,uBAA+B,OAAO,IACjD,gCACD;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GD,IAAa,eAAb,MAA0D;;;;;CAKxD,CAAoB,wBAAwB;;;;;;CAO5C,AAAS;;;;;CAMT,AAAS;;;;CAKT,AAAS;;;;CAKT,AAAS;CA4BT,YACE,aACA,MACA;AACA,OAAK,UAAU,KAAK;AACpB,OAAK,kBAAkB,KAAK;AAC5B,OAAK,cAAc;AACnB,OAAK,cAAc,iBAAiB,OAAO,KAAK,cAAc;AAC9D,OAAK,kBAAkB,KAAK;;CAY9B,OAAO,WACL,OACqC;AACrC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,wBAAwB,SACvB,MAAkC,0BAA0B"}
1
+ {"version":3,"file":"reduced.cjs","names":[],"sources":["../../../src/state/values/reduced.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of ReducedValue instances.\n */\nexport const REDUCED_VALUE_SYMBOL: symbol = Symbol.for(\n \"langgraph.state.reduced_value\"\n);\n\ninterface ReducedValueInitBase<Value = unknown> {\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value, and must return the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new input value to apply to the reducer.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Value) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\ninterface ReducedValueInitWithSchema<Value = unknown, Input = Value> {\n /**\n * Schema describing the type and validation logic for reducer input values.\n *\n * @remarks\n * - If provided, new values passed to the reducer will be validated using this schema before reduction.\n * - This allows the reducer to accept inputs distinct from the type stored in the state (output type).\n */\n inputSchema: SerializableSchema<unknown, Input>;\n\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value (validated using `inputSchema`), and returns the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new validated input value to be applied.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\n/**\n * Initialization options for {@link ReducedValue}.\n *\n * Two forms are supported:\n * 1. Provide only a reducer (and optionally `jsonSchemaExtra`)—in this case, the reducer's inputs are validated using the output value schema.\n * 2. Provide an explicit `inputSchema` field to distinguish the reducer's input type from the stored/output type.\n *\n * @template Value - The type of value stored and produced after reduction.\n * @template Input - The type of inputs accepted by the reducer.\n *\n * @property inputSchema - The schema describing reducer inputs. If omitted, will use the value schema.\n * @property reducer - A function that receives the current output value and a new input, and returns the new output.\n * @property jsonSchemaExtra - (Optional) Extra fields to merge into the exported JSON Schema for documentation or additional constraints.\n */\nexport type ReducedValueInit<Value = unknown, Input = Value> =\n | ReducedValueInitWithSchema<Value, Input>\n | ReducedValueInitBase<Value>;\n\n/**\n * Represents a state field whose value is computed and updated using a reducer function.\n *\n * {@link ReducedValue} allows you to define accumulators, counters, aggregators, or other fields\n * whose value is determined incrementally by applying a reducer to incoming updates.\n *\n * Each time a new input is provided, the reducer function is called with the current output\n * and the new input, producing an updated value. Input validation can be controlled separately\n * from output validation by providing an explicit input schema.\n *\n * @template Value - The type of the value stored in state and produced by reduction.\n * @template Input - The type of updates accepted by the reducer.\n *\n * @example\n * // Accumulator with distinct input validation\n * const Sum = new ReducedValue(z.number(), {\n * inputSchema: z.number().min(1),\n * reducer: (total, toAdd) => total + toAdd\n * });\n *\n * @example\n * // Simple running max, using only the value schema\n * const Max = new ReducedValue(z.number(), {\n * reducer: (current, next) => Math.max(current, next)\n * });\n */\nexport class ReducedValue<Value = unknown, Input = Value> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [REDUCED_VALUE_SYMBOL] = true as const;\n\n /**\n * The schema that describes the type of value stored in state (i.e., after reduction).\n * Note: We use `unknown` for the input type to allow schemas with `.default()` wrappers,\n * where the input type includes `undefined`.\n */\n readonly valueSchema: SerializableSchema<unknown, Value>;\n\n /**\n * The schema used to validate reducer inputs.\n * If not specified explicitly, this defaults to `valueSchema`.\n */\n readonly inputSchema: SerializableSchema<unknown, Input | Value>;\n\n /**\n * The reducer function that combines a current output value and an incoming input.\n */\n readonly reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to merge into the generated JSON Schema (e.g., for documentation or constraints).\n */\n readonly jsonSchemaExtra?: Record<string, unknown>;\n\n /**\n * Represents the value stored after all reductions.\n */\n declare ValueType: Value;\n\n /**\n * Represents the type that may be provided as input on each update.\n */\n declare InputType: Input;\n\n /**\n * Constructs a ReducedValue instance, which combines a value schema and a reducer function (plus optional input schema).\n *\n * @param valueSchema - The schema that describes the type of value stored in state (the \"running total\").\n * @param init - An object specifying the reducer function (required), inputSchema (optional), and jsonSchemaExtra (optional).\n */\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInitWithSchema<Value, Input>\n );\n\n constructor(\n valueSchema: SerializableSchema<Input, Value>,\n init: ReducedValueInitBase<Value>\n );\n\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInit<Value, Input>\n ) {\n this.reducer = init.reducer as (current: Value, next: Input) => Value;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n this.valueSchema = valueSchema;\n this.inputSchema = \"inputSchema\" in init ? init.inputSchema : valueSchema;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n }\n\n /**\n * Type guard to check if a value is a ReducedValue instance.\n */\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input>\n ): value is ReducedValue<Value, Input>;\n\n static isInstance(value: unknown): value is ReducedValue;\n\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input> | unknown\n ): value is ReducedValue<Value, Input> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n REDUCED_VALUE_SYMBOL in value &&\n (value as Record<symbol, unknown>)[REDUCED_VALUE_SYMBOL] === true\n );\n }\n}\n"],"mappings":";;;;AAKA,MAAa,uBAA+B,OAAO,IACjD,gCACD;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GD,IAAa,eAAb,MAA0D;;;;;CAKxD,CAAoB,wBAAwB;;;;;;CAO5C;;;;;CAMA;;;;CAKA;;;;CAKA;CA4BA,YACE,aACA,MACA;AACA,OAAK,UAAU,KAAK;AACpB,OAAK,kBAAkB,KAAK;AAC5B,OAAK,cAAc;AACnB,OAAK,cAAc,iBAAiB,OAAO,KAAK,cAAc;AAC9D,OAAK,kBAAkB,KAAK;;CAY9B,OAAO,WACL,OACqC;AACrC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,wBAAwB,SACvB,MAAkC,0BAA0B"}
@@ -65,7 +65,7 @@ var ReducedValue = class {
65
65
  return typeof value === "object" && value !== null && REDUCED_VALUE_SYMBOL in value && value[REDUCED_VALUE_SYMBOL] === true;
66
66
  }
67
67
  };
68
-
69
68
  //#endregion
70
69
  export { ReducedValue };
70
+
71
71
  //# sourceMappingURL=reduced.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reduced.js","names":[],"sources":["../../../src/state/values/reduced.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of ReducedValue instances.\n */\nexport const REDUCED_VALUE_SYMBOL: symbol = Symbol.for(\n \"langgraph.state.reduced_value\"\n);\n\ninterface ReducedValueInitBase<Value = unknown> {\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value, and must return the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new input value to apply to the reducer.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Value) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\ninterface ReducedValueInitWithSchema<Value = unknown, Input = Value> {\n /**\n * Schema describing the type and validation logic for reducer input values.\n *\n * @remarks\n * - If provided, new values passed to the reducer will be validated using this schema before reduction.\n * - This allows the reducer to accept inputs distinct from the type stored in the state (output type).\n */\n inputSchema: SerializableSchema<unknown, Input>;\n\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value (validated using `inputSchema`), and returns the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new validated input value to be applied.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\n/**\n * Initialization options for {@link ReducedValue}.\n *\n * Two forms are supported:\n * 1. Provide only a reducer (and optionally `jsonSchemaExtra`)—in this case, the reducer's inputs are validated using the output value schema.\n * 2. Provide an explicit `inputSchema` field to distinguish the reducer's input type from the stored/output type.\n *\n * @template Value - The type of value stored and produced after reduction.\n * @template Input - The type of inputs accepted by the reducer.\n *\n * @property inputSchema - The schema describing reducer inputs. If omitted, will use the value schema.\n * @property reducer - A function that receives the current output value and a new input, and returns the new output.\n * @property jsonSchemaExtra - (Optional) Extra fields to merge into the exported JSON Schema for documentation or additional constraints.\n */\nexport type ReducedValueInit<Value = unknown, Input = Value> =\n | ReducedValueInitWithSchema<Value, Input>\n | ReducedValueInitBase<Value>;\n\n/**\n * Represents a state field whose value is computed and updated using a reducer function.\n *\n * {@link ReducedValue} allows you to define accumulators, counters, aggregators, or other fields\n * whose value is determined incrementally by applying a reducer to incoming updates.\n *\n * Each time a new input is provided, the reducer function is called with the current output\n * and the new input, producing an updated value. Input validation can be controlled separately\n * from output validation by providing an explicit input schema.\n *\n * @template Value - The type of the value stored in state and produced by reduction.\n * @template Input - The type of updates accepted by the reducer.\n *\n * @example\n * // Accumulator with distinct input validation\n * const Sum = new ReducedValue(z.number(), {\n * inputSchema: z.number().min(1),\n * reducer: (total, toAdd) => total + toAdd\n * });\n *\n * @example\n * // Simple running max, using only the value schema\n * const Max = new ReducedValue(z.number(), {\n * reducer: (current, next) => Math.max(current, next)\n * });\n */\nexport class ReducedValue<Value = unknown, Input = Value> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [REDUCED_VALUE_SYMBOL] = true as const;\n\n /**\n * The schema that describes the type of value stored in state (i.e., after reduction).\n * Note: We use `unknown` for the input type to allow schemas with `.default()` wrappers,\n * where the input type includes `undefined`.\n */\n readonly valueSchema: SerializableSchema<unknown, Value>;\n\n /**\n * The schema used to validate reducer inputs.\n * If not specified explicitly, this defaults to `valueSchema`.\n */\n readonly inputSchema: SerializableSchema<unknown, Input | Value>;\n\n /**\n * The reducer function that combines a current output value and an incoming input.\n */\n readonly reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to merge into the generated JSON Schema (e.g., for documentation or constraints).\n */\n readonly jsonSchemaExtra?: Record<string, unknown>;\n\n /**\n * Represents the value stored after all reductions.\n */\n declare ValueType: Value;\n\n /**\n * Represents the type that may be provided as input on each update.\n */\n declare InputType: Input;\n\n /**\n * Constructs a ReducedValue instance, which combines a value schema and a reducer function (plus optional input schema).\n *\n * @param valueSchema - The schema that describes the type of value stored in state (the \"running total\").\n * @param init - An object specifying the reducer function (required), inputSchema (optional), and jsonSchemaExtra (optional).\n */\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInitWithSchema<Value, Input>\n );\n\n constructor(\n valueSchema: SerializableSchema<Input, Value>,\n init: ReducedValueInitBase<Value>\n );\n\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInit<Value, Input>\n ) {\n this.reducer = init.reducer as (current: Value, next: Input) => Value;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n this.valueSchema = valueSchema;\n this.inputSchema = \"inputSchema\" in init ? init.inputSchema : valueSchema;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n }\n\n /**\n * Type guard to check if a value is a ReducedValue instance.\n */\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input>\n ): value is ReducedValue<Value, Input>;\n\n static isInstance(value: unknown): value is ReducedValue;\n\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input> | unknown\n ): value is ReducedValue<Value, Input> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n REDUCED_VALUE_SYMBOL in value &&\n (value as Record<symbol, unknown>)[REDUCED_VALUE_SYMBOL] === true\n );\n }\n}\n"],"mappings":";;;;AAKA,MAAa,uBAA+B,OAAO,IACjD,gCACD;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GD,IAAa,eAAb,MAA0D;;;;;CAKxD,CAAoB,wBAAwB;;;;;;CAO5C,AAAS;;;;;CAMT,AAAS;;;;CAKT,AAAS;;;;CAKT,AAAS;CA4BT,YACE,aACA,MACA;AACA,OAAK,UAAU,KAAK;AACpB,OAAK,kBAAkB,KAAK;AAC5B,OAAK,cAAc;AACnB,OAAK,cAAc,iBAAiB,OAAO,KAAK,cAAc;AAC9D,OAAK,kBAAkB,KAAK;;CAY9B,OAAO,WACL,OACqC;AACrC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,wBAAwB,SACvB,MAAkC,0BAA0B"}
1
+ {"version":3,"file":"reduced.js","names":[],"sources":["../../../src/state/values/reduced.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of ReducedValue instances.\n */\nexport const REDUCED_VALUE_SYMBOL: symbol = Symbol.for(\n \"langgraph.state.reduced_value\"\n);\n\ninterface ReducedValueInitBase<Value = unknown> {\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value, and must return the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new input value to apply to the reducer.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Value) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\ninterface ReducedValueInitWithSchema<Value = unknown, Input = Value> {\n /**\n * Schema describing the type and validation logic for reducer input values.\n *\n * @remarks\n * - If provided, new values passed to the reducer will be validated using this schema before reduction.\n * - This allows the reducer to accept inputs distinct from the type stored in the state (output type).\n */\n inputSchema: SerializableSchema<unknown, Input>;\n\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value (validated using `inputSchema`), and returns the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new validated input value to be applied.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\n/**\n * Initialization options for {@link ReducedValue}.\n *\n * Two forms are supported:\n * 1. Provide only a reducer (and optionally `jsonSchemaExtra`)—in this case, the reducer's inputs are validated using the output value schema.\n * 2. Provide an explicit `inputSchema` field to distinguish the reducer's input type from the stored/output type.\n *\n * @template Value - The type of value stored and produced after reduction.\n * @template Input - The type of inputs accepted by the reducer.\n *\n * @property inputSchema - The schema describing reducer inputs. If omitted, will use the value schema.\n * @property reducer - A function that receives the current output value and a new input, and returns the new output.\n * @property jsonSchemaExtra - (Optional) Extra fields to merge into the exported JSON Schema for documentation or additional constraints.\n */\nexport type ReducedValueInit<Value = unknown, Input = Value> =\n | ReducedValueInitWithSchema<Value, Input>\n | ReducedValueInitBase<Value>;\n\n/**\n * Represents a state field whose value is computed and updated using a reducer function.\n *\n * {@link ReducedValue} allows you to define accumulators, counters, aggregators, or other fields\n * whose value is determined incrementally by applying a reducer to incoming updates.\n *\n * Each time a new input is provided, the reducer function is called with the current output\n * and the new input, producing an updated value. Input validation can be controlled separately\n * from output validation by providing an explicit input schema.\n *\n * @template Value - The type of the value stored in state and produced by reduction.\n * @template Input - The type of updates accepted by the reducer.\n *\n * @example\n * // Accumulator with distinct input validation\n * const Sum = new ReducedValue(z.number(), {\n * inputSchema: z.number().min(1),\n * reducer: (total, toAdd) => total + toAdd\n * });\n *\n * @example\n * // Simple running max, using only the value schema\n * const Max = new ReducedValue(z.number(), {\n * reducer: (current, next) => Math.max(current, next)\n * });\n */\nexport class ReducedValue<Value = unknown, Input = Value> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [REDUCED_VALUE_SYMBOL] = true as const;\n\n /**\n * The schema that describes the type of value stored in state (i.e., after reduction).\n * Note: We use `unknown` for the input type to allow schemas with `.default()` wrappers,\n * where the input type includes `undefined`.\n */\n readonly valueSchema: SerializableSchema<unknown, Value>;\n\n /**\n * The schema used to validate reducer inputs.\n * If not specified explicitly, this defaults to `valueSchema`.\n */\n readonly inputSchema: SerializableSchema<unknown, Input | Value>;\n\n /**\n * The reducer function that combines a current output value and an incoming input.\n */\n readonly reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to merge into the generated JSON Schema (e.g., for documentation or constraints).\n */\n readonly jsonSchemaExtra?: Record<string, unknown>;\n\n /**\n * Represents the value stored after all reductions.\n */\n declare ValueType: Value;\n\n /**\n * Represents the type that may be provided as input on each update.\n */\n declare InputType: Input;\n\n /**\n * Constructs a ReducedValue instance, which combines a value schema and a reducer function (plus optional input schema).\n *\n * @param valueSchema - The schema that describes the type of value stored in state (the \"running total\").\n * @param init - An object specifying the reducer function (required), inputSchema (optional), and jsonSchemaExtra (optional).\n */\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInitWithSchema<Value, Input>\n );\n\n constructor(\n valueSchema: SerializableSchema<Input, Value>,\n init: ReducedValueInitBase<Value>\n );\n\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInit<Value, Input>\n ) {\n this.reducer = init.reducer as (current: Value, next: Input) => Value;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n this.valueSchema = valueSchema;\n this.inputSchema = \"inputSchema\" in init ? init.inputSchema : valueSchema;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n }\n\n /**\n * Type guard to check if a value is a ReducedValue instance.\n */\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input>\n ): value is ReducedValue<Value, Input>;\n\n static isInstance(value: unknown): value is ReducedValue;\n\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input> | unknown\n ): value is ReducedValue<Value, Input> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n REDUCED_VALUE_SYMBOL in value &&\n (value as Record<symbol, unknown>)[REDUCED_VALUE_SYMBOL] === true\n );\n }\n}\n"],"mappings":";;;;AAKA,MAAa,uBAA+B,OAAO,IACjD,gCACD;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GD,IAAa,eAAb,MAA0D;;;;;CAKxD,CAAoB,wBAAwB;;;;;;CAO5C;;;;;CAMA;;;;CAKA;;;;CAKA;CA4BA,YACE,aACA,MACA;AACA,OAAK,UAAU,KAAK;AACpB,OAAK,kBAAkB,KAAK;AAC5B,OAAK,cAAc;AACnB,OAAK,cAAc,iBAAiB,OAAO,KAAK,cAAc;AAC9D,OAAK,kBAAkB,KAAK;;CAY9B,OAAO,WACL,OACqC;AACrC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,wBAAwB,SACvB,MAAkC,0BAA0B"}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/state/values/untracked.ts
3
2
  /**
4
3
  * Symbol for runtime identification of UntrackedValue instances.
@@ -58,7 +57,7 @@ var UntrackedValue = class {
58
57
  return typeof value === "object" && value !== null && UNTRACKED_VALUE_SYMBOL in value;
59
58
  }
60
59
  };
61
-
62
60
  //#endregion
63
61
  exports.UntrackedValue = UntrackedValue;
62
+
64
63
  //# sourceMappingURL=untracked.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"untracked.cjs","names":[],"sources":["../../../src/state/values/untracked.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport const UNTRACKED_VALUE_SYMBOL: symbol = Symbol.for(\n \"langgraph.state.untracked_value\"\n);\n\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL] = true as const;\n\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n\n /**\n * Represents the type of value stored in this untracked state field.\n */\n declare ValueType: Value;\n\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit) {\n this.schema = schema;\n this.guard = init?.guard ?? true;\n }\n\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value>\n ): value is UntrackedValue<Value>;\n\n static isInstance(value: unknown): value is UntrackedValue;\n\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value> | unknown\n ): value is UntrackedValue<Value> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n UNTRACKED_VALUE_SYMBOL in value\n );\n }\n}\n"],"mappings":";;;;;AAKA,MAAa,yBAAiC,OAAO,IACnD,kCACD;;;;;;;;;;;;;;;;;;;;AAgCD,IAAa,iBAAb,MAA6C;;;;;CAK3C,CAAoB,0BAA0B;;;;;;CAO9C,AAAS;;;;;;;;;CAUT,AAAS;;;;;;;CAaT,YAAY,QAAoC,MAA2B;AACzE,OAAK,SAAS;AACd,OAAK,QAAQ,MAAM,SAAS;;CAY9B,OAAO,WACL,OACgC;AAChC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,0BAA0B"}
1
+ {"version":3,"file":"untracked.cjs","names":[],"sources":["../../../src/state/values/untracked.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport const UNTRACKED_VALUE_SYMBOL: symbol = Symbol.for(\n \"langgraph.state.untracked_value\"\n);\n\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL] = true as const;\n\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n\n /**\n * Represents the type of value stored in this untracked state field.\n */\n declare ValueType: Value;\n\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit) {\n this.schema = schema;\n this.guard = init?.guard ?? true;\n }\n\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value>\n ): value is UntrackedValue<Value>;\n\n static isInstance(value: unknown): value is UntrackedValue;\n\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value> | unknown\n ): value is UntrackedValue<Value> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n UNTRACKED_VALUE_SYMBOL in value\n );\n }\n}\n"],"mappings":";;;;AAKA,MAAa,yBAAiC,OAAO,IACnD,kCACD;;;;;;;;;;;;;;;;;;;;AAgCD,IAAa,iBAAb,MAA6C;;;;;CAK3C,CAAoB,0BAA0B;;;;;;CAO9C;;;;;;;;;CAUA;;;;;;;CAaA,YAAY,QAAoC,MAA2B;AACzE,OAAK,SAAS;AACd,OAAK,QAAQ,MAAM,SAAS;;CAY9B,OAAO,WACL,OACgC;AAChC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,0BAA0B"}
@@ -57,7 +57,7 @@ var UntrackedValue = class {
57
57
  return typeof value === "object" && value !== null && UNTRACKED_VALUE_SYMBOL in value;
58
58
  }
59
59
  };
60
-
61
60
  //#endregion
62
61
  export { UntrackedValue };
62
+
63
63
  //# sourceMappingURL=untracked.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"untracked.js","names":[],"sources":["../../../src/state/values/untracked.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport const UNTRACKED_VALUE_SYMBOL: symbol = Symbol.for(\n \"langgraph.state.untracked_value\"\n);\n\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL] = true as const;\n\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n\n /**\n * Represents the type of value stored in this untracked state field.\n */\n declare ValueType: Value;\n\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit) {\n this.schema = schema;\n this.guard = init?.guard ?? true;\n }\n\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value>\n ): value is UntrackedValue<Value>;\n\n static isInstance(value: unknown): value is UntrackedValue;\n\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value> | unknown\n ): value is UntrackedValue<Value> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n UNTRACKED_VALUE_SYMBOL in value\n );\n }\n}\n"],"mappings":";;;;AAKA,MAAa,yBAAiC,OAAO,IACnD,kCACD;;;;;;;;;;;;;;;;;;;;AAgCD,IAAa,iBAAb,MAA6C;;;;;CAK3C,CAAoB,0BAA0B;;;;;;CAO9C,AAAS;;;;;;;;;CAUT,AAAS;;;;;;;CAaT,YAAY,QAAoC,MAA2B;AACzE,OAAK,SAAS;AACd,OAAK,QAAQ,MAAM,SAAS;;CAY9B,OAAO,WACL,OACgC;AAChC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,0BAA0B"}
1
+ {"version":3,"file":"untracked.js","names":[],"sources":["../../../src/state/values/untracked.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport const UNTRACKED_VALUE_SYMBOL: symbol = Symbol.for(\n \"langgraph.state.untracked_value\"\n);\n\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL] = true as const;\n\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n\n /**\n * Represents the type of value stored in this untracked state field.\n */\n declare ValueType: Value;\n\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit) {\n this.schema = schema;\n this.guard = init?.guard ?? true;\n }\n\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value>\n ): value is UntrackedValue<Value>;\n\n static isInstance(value: unknown): value is UntrackedValue;\n\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value> | unknown\n ): value is UntrackedValue<Value> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n UNTRACKED_VALUE_SYMBOL in value\n );\n }\n}\n"],"mappings":";;;;AAKA,MAAa,yBAAiC,OAAO,IACnD,kCACD;;;;;;;;;;;;;;;;;;;;AAgCD,IAAa,iBAAb,MAA6C;;;;;CAK3C,CAAoB,0BAA0B;;;;;;CAO9C;;;;;;;;;CAUA;;;;;;;CAaA,YAAY,QAAoC,MAA2B;AACzE,OAAK,SAAS;AACd,OAAK,QAAQ,MAAM,SAAS;;CAY9B,OAAO,WACL,OACgC;AAChC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,0BAA0B"}
package/dist/utils.cjs CHANGED
@@ -1,7 +1,6 @@
1
- const require_config = require('./pregel/utils/config.cjs');
1
+ const require_config = require("./pregel/utils/config.cjs");
2
2
  let _langchain_core_singletons = require("@langchain/core/singletons");
3
3
  let _langchain_core_runnables = require("@langchain/core/runnables");
4
-
5
4
  //#region src/utils.ts
6
5
  var RunnableCallable = class extends _langchain_core_runnables.Runnable {
7
6
  lc_namespace = ["langgraph"];
@@ -74,7 +73,6 @@ function isAsyncGeneratorFunction(val) {
74
73
  function isGeneratorFunction(val) {
75
74
  return val != null && typeof val === "function" && val instanceof Object.getPrototypeOf(function* () {}).constructor;
76
75
  }
77
-
78
76
  //#endregion
79
77
  exports.RunnableCallable = RunnableCallable;
80
78
  exports.gatherIterator = gatherIterator;
@@ -83,4 +81,5 @@ exports.isAsyncGeneratorFunction = isAsyncGeneratorFunction;
83
81
  exports.isGeneratorFunction = isGeneratorFunction;
84
82
  exports.patchConfigurable = patchConfigurable;
85
83
  exports.prefixGenerator = prefixGenerator;
84
+
86
85
  //# sourceMappingURL=utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["Runnable","AsyncLocalStorageProviderSingleton","ensureLangGraphConfig"],"sources":["../src/utils.ts"],"sourcesContent":["import { CallbackManagerForChainRun } from \"@langchain/core/callbacks/manager\";\nimport {\n mergeConfigs,\n patchConfig,\n Runnable,\n RunnableConfig,\n} from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { ensureLangGraphConfig } from \"./pregel/utils/config.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface RunnableCallableArgs extends Partial<any> {\n name?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n func: (...args: any[]) => any;\n tags?: string[];\n trace?: boolean;\n recurse?: boolean;\n}\n\nexport class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n lc_namespace: string[] = [\"langgraph\"];\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n func: (...args: any[]) => any;\n\n tags?: string[];\n\n config?: RunnableConfig;\n\n trace: boolean = true;\n\n recurse: boolean = true;\n\n constructor(fields: RunnableCallableArgs) {\n super();\n this.name = fields.name ?? fields.func.name;\n this.func = fields.func;\n this.config = fields.tags ? { tags: fields.tags } : undefined;\n this.trace = fields.trace ?? this.trace;\n this.recurse = fields.recurse ?? this.recurse;\n }\n\n protected async _tracedInvoke(\n input: I,\n config?: Partial<RunnableConfig>,\n runManager?: CallbackManagerForChainRun\n ) {\n return new Promise<O>((resolve, reject) => {\n const childConfig = patchConfig(config, {\n callbacks: runManager?.getChild(),\n });\n void AsyncLocalStorageProviderSingleton.runWithConfig(\n childConfig,\n async () => {\n try {\n const output = await this.func(input, childConfig);\n resolve(output);\n } catch (e) {\n reject(e);\n }\n }\n );\n });\n }\n\n async invoke(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n input: I,\n options?: Partial<RunnableConfig> | undefined\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<O> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let returnValue: any;\n const config = ensureLangGraphConfig(options);\n const mergedConfig = mergeConfigs(this.config, config);\n\n if (this.trace) {\n returnValue = await this._callWithConfig(\n this._tracedInvoke,\n input,\n mergedConfig\n );\n } else {\n returnValue = await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => this.func(input, mergedConfig)\n );\n }\n\n if (Runnable.isRunnable(returnValue) && this.recurse) {\n return await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => returnValue.invoke(input, mergedConfig)\n );\n }\n\n return returnValue;\n }\n}\n\nexport function prefixGenerator<T, Prefix extends string>(\n generator: Generator<T>,\n prefix: Prefix\n): Generator<[Prefix, T]>;\n\nexport function prefixGenerator<T>(\n generator: Generator<T>,\n prefix?: undefined\n): Generator<T>;\n\nexport function prefixGenerator<\n T,\n Prefix extends string | undefined = undefined\n>(\n generator: Generator<T>,\n prefix?: Prefix | undefined\n): Generator<Prefix extends string ? [Prefix, T] : T>;\nexport function* prefixGenerator<\n T,\n Prefix extends string | undefined = undefined\n>(\n generator: Generator<T>,\n prefix?: Prefix | undefined\n): Generator<Prefix extends string ? [Prefix, T] : T> {\n if (prefix === undefined) {\n yield* generator as Generator<Prefix extends string ? [Prefix, T] : T>;\n } else {\n for (const value of generator) {\n yield [prefix, value] as Prefix extends string ? [Prefix, T] : T;\n }\n }\n}\n\n// https://github.com/tc39/proposal-array-from-async\nexport async function gatherIterator<T>(\n i:\n | AsyncIterable<T>\n | Promise<AsyncIterable<T>>\n | Iterable<T>\n | Promise<Iterable<T>>\n): Promise<Array<T>> {\n const out: T[] = [];\n for await (const item of await i) {\n out.push(item);\n }\n return out;\n}\n\nexport function gatherIteratorSync<T>(i: Iterable<T>): Array<T> {\n const out: T[] = [];\n for (const item of i) {\n out.push(item);\n }\n return out;\n}\n\nexport function patchConfigurable(\n config: RunnableConfig | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n patch: Record<string, any>\n): RunnableConfig {\n if (!config) {\n return {\n configurable: patch,\n };\n } else if (!(\"configurable\" in config)) {\n return {\n ...config,\n configurable: patch,\n };\n } else {\n return {\n ...config,\n configurable: {\n ...config.configurable,\n ...patch,\n },\n };\n }\n}\n\nexport function isAsyncGeneratorFunction(\n val: unknown\n): val is AsyncGeneratorFunction {\n return (\n val != null &&\n typeof val === \"function\" &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n val instanceof Object.getPrototypeOf(async function* () {}).constructor\n );\n}\n\nexport function isGeneratorFunction(val: unknown): val is GeneratorFunction {\n return (\n val != null &&\n typeof val === \"function\" &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n val instanceof Object.getPrototypeOf(function* () {}).constructor\n );\n}\n"],"mappings":";;;;;AAoBA,IAAa,mBAAb,cAAgEA,mCAAe;CAC7E,eAAyB,CAAC,YAAY;CAGtC;CAEA;CAEA;CAEA,QAAiB;CAEjB,UAAmB;CAEnB,YAAY,QAA8B;AACxC,SAAO;AACP,OAAK,OAAO,OAAO,QAAQ,OAAO,KAAK;AACvC,OAAK,OAAO,OAAO;AACnB,OAAK,SAAS,OAAO,OAAO,EAAE,MAAM,OAAO,MAAM,GAAG;AACpD,OAAK,QAAQ,OAAO,SAAS,KAAK;AAClC,OAAK,UAAU,OAAO,WAAW,KAAK;;CAGxC,MAAgB,cACd,OACA,QACA,YACA;AACA,SAAO,IAAI,SAAY,SAAS,WAAW;GACzC,MAAM,yDAA0B,QAAQ,EACtC,WAAW,YAAY,UAAU,EAClC,CAAC;AACF,GAAKC,8DAAmC,cACtC,aACA,YAAY;AACV,QAAI;AAEF,aADe,MAAM,KAAK,KAAK,OAAO,YAAY,CACnC;aACR,GAAG;AACV,YAAO,EAAE;;KAGd;IACD;;CAGJ,MAAM,OAEJ,OACA,SAEY;EAEZ,IAAI;EACJ,MAAM,SAASC,qCAAsB,QAAQ;EAC7C,MAAM,2DAA4B,KAAK,QAAQ,OAAO;AAEtD,MAAI,KAAK,MACP,eAAc,MAAM,KAAK,gBACvB,KAAK,eACL,OACA,aACD;MAED,eAAc,MAAMD,8DAAmC,cACrD,cACA,YAAY,KAAK,KAAK,OAAO,aAAa,CAC3C;AAGH,MAAID,mCAAS,WAAW,YAAY,IAAI,KAAK,QAC3C,QAAO,MAAMC,8DAAmC,cAC9C,cACA,YAAY,YAAY,OAAO,OAAO,aAAa,CACpD;AAGH,SAAO;;;AAqBX,UAAiB,gBAIf,WACA,QACoD;AACpD,KAAI,WAAW,OACb,QAAO;KAEP,MAAK,MAAM,SAAS,UAClB,OAAM,CAAC,QAAQ,MAAM;;AAM3B,eAAsB,eACpB,GAKmB;CACnB,MAAM,MAAW,EAAE;AACnB,YAAW,MAAM,QAAQ,MAAM,EAC7B,KAAI,KAAK,KAAK;AAEhB,QAAO;;AAGT,SAAgB,mBAAsB,GAA0B;CAC9D,MAAM,MAAW,EAAE;AACnB,MAAK,MAAM,QAAQ,EACjB,KAAI,KAAK,KAAK;AAEhB,QAAO;;AAGT,SAAgB,kBACd,QAEA,OACgB;AAChB,KAAI,CAAC,OACH,QAAO,EACL,cAAc,OACf;UACQ,EAAE,kBAAkB,QAC7B,QAAO;EACL,GAAG;EACH,cAAc;EACf;KAED,QAAO;EACL,GAAG;EACH,cAAc;GACZ,GAAG,OAAO;GACV,GAAG;GACJ;EACF;;AAIL,SAAgB,yBACd,KAC+B;AAC/B,QACE,OAAO,QACP,OAAO,QAAQ,cAEf,eAAe,OAAO,eAAe,mBAAmB,GAAG,CAAC;;AAIhE,SAAgB,oBAAoB,KAAwC;AAC1E,QACE,OAAO,QACP,OAAO,QAAQ,cAEf,eAAe,OAAO,eAAe,aAAa,GAAG,CAAC"}
1
+ {"version":3,"file":"utils.cjs","names":["Runnable","AsyncLocalStorageProviderSingleton","ensureLangGraphConfig"],"sources":["../src/utils.ts"],"sourcesContent":["import { CallbackManagerForChainRun } from \"@langchain/core/callbacks/manager\";\nimport {\n mergeConfigs,\n patchConfig,\n Runnable,\n RunnableConfig,\n} from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { ensureLangGraphConfig } from \"./pregel/utils/config.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface RunnableCallableArgs extends Partial<any> {\n name?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n func: (...args: any[]) => any;\n tags?: string[];\n trace?: boolean;\n recurse?: boolean;\n}\n\nexport class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n lc_namespace: string[] = [\"langgraph\"];\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n func: (...args: any[]) => any;\n\n tags?: string[];\n\n config?: RunnableConfig;\n\n trace: boolean = true;\n\n recurse: boolean = true;\n\n constructor(fields: RunnableCallableArgs) {\n super();\n this.name = fields.name ?? fields.func.name;\n this.func = fields.func;\n this.config = fields.tags ? { tags: fields.tags } : undefined;\n this.trace = fields.trace ?? this.trace;\n this.recurse = fields.recurse ?? this.recurse;\n }\n\n protected async _tracedInvoke(\n input: I,\n config?: Partial<RunnableConfig>,\n runManager?: CallbackManagerForChainRun\n ) {\n return new Promise<O>((resolve, reject) => {\n const childConfig = patchConfig(config, {\n callbacks: runManager?.getChild(),\n });\n void AsyncLocalStorageProviderSingleton.runWithConfig(\n childConfig,\n async () => {\n try {\n const output = await this.func(input, childConfig);\n resolve(output);\n } catch (e) {\n reject(e);\n }\n }\n );\n });\n }\n\n async invoke(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n input: I,\n options?: Partial<RunnableConfig> | undefined\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<O> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let returnValue: any;\n const config = ensureLangGraphConfig(options);\n const mergedConfig = mergeConfigs(this.config, config);\n\n if (this.trace) {\n returnValue = await this._callWithConfig(\n this._tracedInvoke,\n input,\n mergedConfig\n );\n } else {\n returnValue = await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => this.func(input, mergedConfig)\n );\n }\n\n if (Runnable.isRunnable(returnValue) && this.recurse) {\n return await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => returnValue.invoke(input, mergedConfig)\n );\n }\n\n return returnValue;\n }\n}\n\nexport function prefixGenerator<T, Prefix extends string>(\n generator: Generator<T>,\n prefix: Prefix\n): Generator<[Prefix, T]>;\n\nexport function prefixGenerator<T>(\n generator: Generator<T>,\n prefix?: undefined\n): Generator<T>;\n\nexport function prefixGenerator<\n T,\n Prefix extends string | undefined = undefined\n>(\n generator: Generator<T>,\n prefix?: Prefix | undefined\n): Generator<Prefix extends string ? [Prefix, T] : T>;\nexport function* prefixGenerator<\n T,\n Prefix extends string | undefined = undefined\n>(\n generator: Generator<T>,\n prefix?: Prefix | undefined\n): Generator<Prefix extends string ? [Prefix, T] : T> {\n if (prefix === undefined) {\n yield* generator as Generator<Prefix extends string ? [Prefix, T] : T>;\n } else {\n for (const value of generator) {\n yield [prefix, value] as Prefix extends string ? [Prefix, T] : T;\n }\n }\n}\n\n// https://github.com/tc39/proposal-array-from-async\nexport async function gatherIterator<T>(\n i:\n | AsyncIterable<T>\n | Promise<AsyncIterable<T>>\n | Iterable<T>\n | Promise<Iterable<T>>\n): Promise<Array<T>> {\n const out: T[] = [];\n for await (const item of await i) {\n out.push(item);\n }\n return out;\n}\n\nexport function gatherIteratorSync<T>(i: Iterable<T>): Array<T> {\n const out: T[] = [];\n for (const item of i) {\n out.push(item);\n }\n return out;\n}\n\nexport function patchConfigurable(\n config: RunnableConfig | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n patch: Record<string, any>\n): RunnableConfig {\n if (!config) {\n return {\n configurable: patch,\n };\n } else if (!(\"configurable\" in config)) {\n return {\n ...config,\n configurable: patch,\n };\n } else {\n return {\n ...config,\n configurable: {\n ...config.configurable,\n ...patch,\n },\n };\n }\n}\n\nexport function isAsyncGeneratorFunction(\n val: unknown\n): val is AsyncGeneratorFunction {\n return (\n val != null &&\n typeof val === \"function\" &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n val instanceof Object.getPrototypeOf(async function* () {}).constructor\n );\n}\n\nexport function isGeneratorFunction(val: unknown): val is GeneratorFunction {\n return (\n val != null &&\n typeof val === \"function\" &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n val instanceof Object.getPrototypeOf(function* () {}).constructor\n );\n}\n"],"mappings":";;;;AAoBA,IAAa,mBAAb,cAAgEA,0BAAAA,SAAe;CAC7E,eAAyB,CAAC,YAAY;CAGtC;CAEA;CAEA;CAEA,QAAiB;CAEjB,UAAm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SAAgB,mBAAsB,GAA0B;CAC9D,MAAM,MAAW,EAAE;AACnB,MAAK,MAAM,QAAQ,EACjB,KAAI,KAAK,KAAK;AAEhB,QAAO;;AAGT,SAAgB,kBACd,QAEA,OACgB;AAChB,KAAI,CAAC,OACH,QAAO,EACL,cAAc,OACf;UACQ,EAAE,kBAAkB,QAC7B,QAAO;EACL,GAAG;EACH,cAAc;EACf;KAED,QAAO;EACL,GAAG;EACH,cAAc;GACZ,GAAG,OAAO;GACV,GAAG;GACJ;EACF;;AAIL,SAAgB,yBACd,KAC+B;AAC/B,QACE,OAAO,QACP,OAAO,QAAQ,cAEf,eAAe,OAAO,eAAe,mBAAmB,GAAG,CAAC;;AAIhE,SAAgB,oBAAoB,KAAwC;AAC1E,QACE,OAAO,QACP,OAAO,QAAQ,cAEf,eAAe,OAAO,eAAe,aAAa,GAAG,CAAC"}
package/dist/utils.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { ensureLangGraphConfig } from "./pregel/utils/config.js";
2
2
  import { AsyncLocalStorageProviderSingleton } from "@langchain/core/singletons";
3
3
  import { Runnable, mergeConfigs, patchConfig } from "@langchain/core/runnables";
4
-
5
4
  //#region src/utils.ts
6
5
  var RunnableCallable = class extends Runnable {
7
6
  lc_namespace = ["langgraph"];
@@ -74,7 +73,7 @@ function isAsyncGeneratorFunction(val) {
74
73
  function isGeneratorFunction(val) {
75
74
  return val != null && typeof val === "function" && val instanceof Object.getPrototypeOf(function* () {}).constructor;
76
75
  }
77
-
78
76
  //#endregion
79
77
  export { RunnableCallable, gatherIterator, gatherIteratorSync, isAsyncGeneratorFunction, isGeneratorFunction, patchConfigurable, prefixGenerator };
78
+
80
79
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { CallbackManagerForChainRun } from \"@langchain/core/callbacks/manager\";\nimport {\n mergeConfigs,\n patchConfig,\n Runnable,\n RunnableConfig,\n} from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { ensureLangGraphConfig } from \"./pregel/utils/config.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface RunnableCallableArgs extends Partial<any> {\n name?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n func: (...args: any[]) => any;\n tags?: string[];\n trace?: boolean;\n recurse?: boolean;\n}\n\nexport class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n lc_namespace: string[] = [\"langgraph\"];\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n func: (...args: any[]) => any;\n\n tags?: string[];\n\n config?: RunnableConfig;\n\n trace: boolean = true;\n\n recurse: boolean = true;\n\n constructor(fields: RunnableCallableArgs) {\n super();\n this.name = fields.name ?? fields.func.name;\n this.func = fields.func;\n this.config = fields.tags ? { tags: fields.tags } : undefined;\n this.trace = fields.trace ?? this.trace;\n this.recurse = fields.recurse ?? this.recurse;\n }\n\n protected async _tracedInvoke(\n input: I,\n config?: Partial<RunnableConfig>,\n runManager?: CallbackManagerForChainRun\n ) {\n return new Promise<O>((resolve, reject) => {\n const childConfig = patchConfig(config, {\n callbacks: runManager?.getChild(),\n });\n void AsyncLocalStorageProviderSingleton.runWithConfig(\n childConfig,\n async () => {\n try {\n const output = await this.func(input, childConfig);\n resolve(output);\n } catch (e) {\n reject(e);\n }\n }\n );\n });\n }\n\n async invoke(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n input: I,\n options?: Partial<RunnableConfig> | undefined\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<O> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let returnValue: any;\n const config = ensureLangGraphConfig(options);\n const mergedConfig = mergeConfigs(this.config, config);\n\n if (this.trace) {\n returnValue = await this._callWithConfig(\n this._tracedInvoke,\n input,\n mergedConfig\n );\n } else {\n returnValue = await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => this.func(input, mergedConfig)\n );\n }\n\n if (Runnable.isRunnable(returnValue) && this.recurse) {\n return await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => returnValue.invoke(input, mergedConfig)\n );\n }\n\n return returnValue;\n }\n}\n\nexport function prefixGenerator<T, Prefix extends string>(\n generator: Generator<T>,\n prefix: Prefix\n): Generator<[Prefix, T]>;\n\nexport function prefixGenerator<T>(\n generator: Generator<T>,\n prefix?: undefined\n): Generator<T>;\n\nexport function prefixGenerator<\n T,\n Prefix extends string | undefined = undefined\n>(\n generator: Generator<T>,\n prefix?: Prefix | undefined\n): Generator<Prefix extends string ? [Prefix, T] : T>;\nexport function* prefixGenerator<\n T,\n Prefix extends string | undefined = undefined\n>(\n generator: Generator<T>,\n prefix?: Prefix | undefined\n): Generator<Prefix extends string ? [Prefix, T] : T> {\n if (prefix === undefined) {\n yield* generator as Generator<Prefix extends string ? [Prefix, T] : T>;\n } else {\n for (const value of generator) {\n yield [prefix, value] as Prefix extends string ? [Prefix, T] : T;\n }\n }\n}\n\n// https://github.com/tc39/proposal-array-from-async\nexport async function gatherIterator<T>(\n i:\n | AsyncIterable<T>\n | Promise<AsyncIterable<T>>\n | Iterable<T>\n | Promise<Iterable<T>>\n): Promise<Array<T>> {\n const out: T[] = [];\n for await (const item of await i) {\n out.push(item);\n }\n return out;\n}\n\nexport function gatherIteratorSync<T>(i: Iterable<T>): Array<T> {\n const out: T[] = [];\n for (const item of i) {\n out.push(item);\n }\n return out;\n}\n\nexport function patchConfigurable(\n config: RunnableConfig | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n patch: Record<string, any>\n): RunnableConfig {\n if (!config) {\n return {\n configurable: patch,\n };\n } else if (!(\"configurable\" in config)) {\n return {\n ...config,\n configurable: patch,\n };\n } else {\n return {\n ...config,\n configurable: {\n ...config.configurable,\n ...patch,\n },\n };\n }\n}\n\nexport function isAsyncGeneratorFunction(\n val: unknown\n): val is AsyncGeneratorFunction {\n return (\n val != null &&\n typeof val === \"function\" &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n val instanceof Object.getPrototypeOf(async function* () {}).constructor\n );\n}\n\nexport function isGeneratorFunction(val: unknown): val is GeneratorFunction {\n return (\n val != null &&\n typeof val === \"function\" &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n val instanceof Object.getPrototypeOf(function* () {}).constructor\n );\n}\n"],"mappings":";;;;;AAoBA,IAAa,mBAAb,cAAgE,SAAe;CAC7E,eAAyB,CAAC,YAAY;CAGtC;CAEA;CAEA;CAEA,QAAiB;CAEjB,UAAmB;CAEnB,YAAY,QAA8B;AACxC,SAAO;AACP,OAAK,OAAO,OAAO,QAAQ,OAAO,KAAK;AACvC,OAAK,OAAO,OAAO;AACnB,OAAK,SAAS,OAAO,OAAO,EAAE,MAAM,OAAO,MAAM,GAAG;AACpD,OAAK,QAAQ,OAAO,SAAS,KAAK;AAClC,OAAK,UAAU,OAAO,WAAW,KAAK;;CAGxC,MAAgB,cACd,OACA,QACA,YACA;AACA,SAAO,IAAI,SAAY,SAAS,WAAW;GACzC,MAAM,cAAc,YAAY,QAAQ,EACtC,WAAW,YAAY,UAAU,EAClC,CAAC;AACF,GAAK,mCAAmC,cACtC,aACA,YAAY;AACV,QAAI;AAEF,aADe,MAAM,KAAK,KAAK,OAAO,YAAY,CACnC;aACR,GAAG;AACV,YAAO,EAAE;;KAGd;IACD;;CAGJ,MAAM,OAEJ,OACA,SAEY;EAEZ,IAAI;EACJ,MAAM,SAAS,sBAAsB,QAAQ;EAC7C,MAAM,eAAe,aAAa,KAAK,QAAQ,OAAO;AAEtD,MAAI,KAAK,MACP,eAAc,MAAM,KAAK,gBACvB,KAAK,eACL,OACA,aACD;MAED,eAAc,MAAM,mCAAmC,cACrD,cACA,YAAY,KAAK,KAAK,OAAO,aAAa,CAC3C;AAGH,MAAI,SAAS,WAAW,YAAY,IAAI,KAAK,QAC3C,QAAO,MAAM,mCAAmC,cAC9C,cACA,YAAY,YAAY,OAAO,OAAO,aAAa,CACpD;AAGH,SAAO;;;AAqBX,UAAiB,gBAIf,WACA,QACoD;AACpD,KAAI,WAAW,OACb,QAAO;KAEP,MAAK,MAAM,SAAS,UAClB,OAAM,CAAC,QAAQ,MAAM;;AAM3B,eAAsB,eACpB,GAKmB;CACnB,MAAM,MAAW,EAAE;AACnB,YAAW,MAAM,QAAQ,MAAM,EAC7B,KAAI,KAAK,KAAK;AAEhB,QAAO;;AAGT,SAAgB,mBAAsB,GAA0B;CAC9D,MAAM,MAAW,EAAE;AACnB,MAAK,MAAM,QAAQ,EACjB,KAAI,KAAK,KAAK;AAEhB,QAAO;;AAGT,SAAgB,kBACd,QAEA,OACgB;AAChB,KAAI,CAAC,OACH,QAAO,EACL,cAAc,OACf;UACQ,EAAE,kBAAkB,QAC7B,QAAO;EACL,GAAG;EACH,cAAc;EACf;KAED,QAAO;EACL,GAAG;EACH,cAAc;GACZ,GAAG,OAAO;GACV,GAAG;GACJ;EACF;;AAIL,SAAgB,yBACd,KAC+B;AAC/B,QACE,OAAO,QACP,OAAO,QAAQ,cAEf,eAAe,OAAO,eAAe,mBAAmB,GAAG,CAAC;;AAIhE,SAAgB,oBAAoB,KAAwC;AAC1E,QACE,OAAO,QACP,OAAO,QAAQ,cAEf,eAAe,OAAO,eAAe,aAAa,GAAG,CAAC"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { CallbackManagerForChainRun } from \"@langchain/core/callbacks/manager\";\nimport {\n mergeConfigs,\n patchConfig,\n Runnable,\n RunnableConfig,\n} from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { ensureLangGraphConfig } from \"./pregel/utils/config.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface RunnableCallableArgs extends Partial<any> {\n name?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n func: (...args: any[]) => any;\n tags?: string[];\n trace?: boolean;\n recurse?: boolean;\n}\n\nexport class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n lc_namespace: string[] = [\"langgraph\"];\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n func: (...args: any[]) => any;\n\n tags?: string[];\n\n config?: RunnableConfig;\n\n trace: boolean = true;\n\n recurse: boolean = true;\n\n constructor(fields: RunnableCallableArgs) {\n super();\n this.name = fields.name ?? fields.func.name;\n this.func = fields.func;\n this.config = fields.tags ? { tags: fields.tags } : undefined;\n this.trace = fields.trace ?? this.trace;\n this.recurse = fields.recurse ?? this.recurse;\n }\n\n protected async _tracedInvoke(\n input: I,\n config?: Partial<RunnableConfig>,\n runManager?: CallbackManagerForChainRun\n ) {\n return new Promise<O>((resolve, reject) => {\n const childConfig = patchConfig(config, {\n callbacks: runManager?.getChild(),\n });\n void AsyncLocalStorageProviderSingleton.runWithConfig(\n childConfig,\n async () => {\n try {\n const output = await this.func(input, childConfig);\n resolve(output);\n } catch (e) {\n reject(e);\n }\n }\n );\n });\n }\n\n async invoke(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n input: I,\n options?: Partial<RunnableConfig> | undefined\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<O> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let returnValue: any;\n const config = ensureLangGraphConfig(options);\n const mergedConfig = mergeConfigs(this.config, config);\n\n if (this.trace) {\n returnValue = await this._callWithConfig(\n this._tracedInvoke,\n input,\n mergedConfig\n );\n } else {\n returnValue = await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => this.func(input, mergedConfig)\n );\n }\n\n if (Runnable.isRunnable(returnValue) && this.recurse) {\n return await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => returnValue.invoke(input, mergedConfig)\n );\n }\n\n return returnValue;\n }\n}\n\nexport function prefixGenerator<T, Prefix extends string>(\n generator: Generator<T>,\n prefix: Prefix\n): Generator<[Prefix, T]>;\n\nexport function prefixGenerator<T>(\n generator: Generator<T>,\n prefix?: undefined\n): Generator<T>;\n\nexport function prefixGenerator<\n T,\n Prefix extends string | undefined = undefined\n>(\n generator: Generator<T>,\n prefix?: Prefix | undefined\n): Generator<Prefix extends string ? [Prefix, T] : T>;\nexport function* prefixGenerator<\n T,\n Prefix extends string | undefined = undefined\n>(\n generator: Generator<T>,\n prefix?: Prefix | undefined\n): Generator<Prefix extends string ? [Prefix, T] : T> {\n if (prefix === undefined) {\n yield* generator as Generator<Prefix extends string ? [Prefix, T] : T>;\n } else {\n for (const value of generator) {\n yield [prefix, value] as Prefix extends string ? [Prefix, T] : T;\n }\n }\n}\n\n// https://github.com/tc39/proposal-array-from-async\nexport async function gatherIterator<T>(\n i:\n | AsyncIterable<T>\n | Promise<AsyncIterable<T>>\n | Iterable<T>\n | Promise<Iterable<T>>\n): Promise<Array<T>> {\n const out: T[] = [];\n for await (const item of await i) {\n out.push(item);\n }\n return out;\n}\n\nexport function gatherIteratorSync<T>(i: Iterable<T>): Array<T> {\n const out: T[] = [];\n for (const item of i) {\n out.push(item);\n }\n return out;\n}\n\nexport function patchConfigurable(\n config: RunnableConfig | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n patch: Record<string, any>\n): RunnableConfig {\n if (!config) {\n return {\n configurable: patch,\n };\n } else if (!(\"configurable\" in config)) {\n return {\n ...config,\n configurable: patch,\n };\n } else {\n return {\n ...config,\n configurable: {\n ...config.configurable,\n ...patch,\n },\n };\n }\n}\n\nexport function isAsyncGeneratorFunction(\n val: unknown\n): val is AsyncGeneratorFunction {\n return (\n val != null &&\n typeof val === \"function\" &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n val instanceof Object.getPrototypeOf(async function* () {}).constructor\n );\n}\n\nexport function isGeneratorFunction(val: unknown): val is GeneratorFunction {\n return (\n val != null &&\n typeof val === \"function\" &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n val instanceof Object.getPrototypeOf(function* ()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