@langchain/langgraph 1.0.6 → 1.0.12

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 (383) hide show
  1. package/package.json +7 -7
  2. package/CHANGELOG.md +0 -280
  3. package/dist/_virtual/rolldown_runtime.cjs +0 -25
  4. package/dist/channels/any_value.cjs +0 -46
  5. package/dist/channels/any_value.cjs.map +0 -1
  6. package/dist/channels/any_value.d.cts +0 -24
  7. package/dist/channels/any_value.d.cts.map +0 -1
  8. package/dist/channels/any_value.d.ts +0 -24
  9. package/dist/channels/any_value.d.ts.map +0 -1
  10. package/dist/channels/any_value.js +0 -46
  11. package/dist/channels/any_value.js.map +0 -1
  12. package/dist/channels/base.cjs +0 -102
  13. package/dist/channels/base.cjs.map +0 -1
  14. package/dist/channels/base.d.cts +0 -79
  15. package/dist/channels/base.d.cts.map +0 -1
  16. package/dist/channels/base.d.ts +0 -79
  17. package/dist/channels/base.d.ts.map +0 -1
  18. package/dist/channels/base.js +0 -97
  19. package/dist/channels/base.js.map +0 -1
  20. package/dist/channels/binop.cjs +0 -49
  21. package/dist/channels/binop.cjs.map +0 -1
  22. package/dist/channels/binop.d.cts +0 -22
  23. package/dist/channels/binop.d.cts.map +0 -1
  24. package/dist/channels/binop.d.ts +0 -22
  25. package/dist/channels/binop.d.ts.map +0 -1
  26. package/dist/channels/binop.js +0 -49
  27. package/dist/channels/binop.js.map +0 -1
  28. package/dist/channels/dynamic_barrier_value.cjs +0 -76
  29. package/dist/channels/dynamic_barrier_value.cjs.map +0 -1
  30. package/dist/channels/dynamic_barrier_value.d.cts +0 -42
  31. package/dist/channels/dynamic_barrier_value.d.cts.map +0 -1
  32. package/dist/channels/dynamic_barrier_value.d.ts +0 -42
  33. package/dist/channels/dynamic_barrier_value.d.ts.map +0 -1
  34. package/dist/channels/dynamic_barrier_value.js +0 -76
  35. package/dist/channels/dynamic_barrier_value.js.map +0 -1
  36. package/dist/channels/ephemeral_value.cjs +0 -46
  37. package/dist/channels/ephemeral_value.cjs.map +0 -1
  38. package/dist/channels/ephemeral_value.d.cts +0 -22
  39. package/dist/channels/ephemeral_value.d.cts.map +0 -1
  40. package/dist/channels/ephemeral_value.d.ts +0 -22
  41. package/dist/channels/ephemeral_value.d.ts.map +0 -1
  42. package/dist/channels/ephemeral_value.js +0 -46
  43. package/dist/channels/ephemeral_value.js.map +0 -1
  44. package/dist/channels/index.cjs +0 -21
  45. package/dist/channels/index.d.cts +0 -9
  46. package/dist/channels/index.d.ts +0 -9
  47. package/dist/channels/index.js +0 -10
  48. package/dist/channels/last_value.cjs +0 -98
  49. package/dist/channels/last_value.cjs.map +0 -1
  50. package/dist/channels/last_value.d.cts +0 -44
  51. package/dist/channels/last_value.d.cts.map +0 -1
  52. package/dist/channels/last_value.d.ts +0 -44
  53. package/dist/channels/last_value.d.ts.map +0 -1
  54. package/dist/channels/last_value.js +0 -97
  55. package/dist/channels/last_value.js.map +0 -1
  56. package/dist/channels/named_barrier_value.cjs +0 -118
  57. package/dist/channels/named_barrier_value.cjs.map +0 -1
  58. package/dist/channels/named_barrier_value.d.cts +0 -46
  59. package/dist/channels/named_barrier_value.d.cts.map +0 -1
  60. package/dist/channels/named_barrier_value.d.ts +0 -46
  61. package/dist/channels/named_barrier_value.d.ts.map +0 -1
  62. package/dist/channels/named_barrier_value.js +0 -116
  63. package/dist/channels/named_barrier_value.js.map +0 -1
  64. package/dist/channels/topic.cjs +0 -65
  65. package/dist/channels/topic.cjs.map +0 -1
  66. package/dist/channels/topic.d.cts +0 -32
  67. package/dist/channels/topic.d.cts.map +0 -1
  68. package/dist/channels/topic.d.ts +0 -32
  69. package/dist/channels/topic.d.ts.map +0 -1
  70. package/dist/channels/topic.js +0 -65
  71. package/dist/channels/topic.js.map +0 -1
  72. package/dist/constants.cjs +0 -406
  73. package/dist/constants.cjs.map +0 -1
  74. package/dist/constants.d.cts +0 -285
  75. package/dist/constants.d.cts.map +0 -1
  76. package/dist/constants.d.ts +0 -285
  77. package/dist/constants.d.ts.map +0 -1
  78. package/dist/constants.js +0 -362
  79. package/dist/constants.js.map +0 -1
  80. package/dist/errors.cjs +0 -163
  81. package/dist/errors.cjs.map +0 -1
  82. package/dist/errors.d.cts +0 -81
  83. package/dist/errors.d.cts.map +0 -1
  84. package/dist/errors.d.ts +0 -81
  85. package/dist/errors.d.ts.map +0 -1
  86. package/dist/errors.js +0 -146
  87. package/dist/errors.js.map +0 -1
  88. package/dist/func/index.cjs +0 -301
  89. package/dist/func/index.cjs.map +0 -1
  90. package/dist/func/index.d.cts +0 -293
  91. package/dist/func/index.d.cts.map +0 -1
  92. package/dist/func/index.d.ts +0 -293
  93. package/dist/func/index.d.ts.map +0 -1
  94. package/dist/func/index.js +0 -298
  95. package/dist/func/index.js.map +0 -1
  96. package/dist/func/types.d.cts +0 -64
  97. package/dist/func/types.d.cts.map +0 -1
  98. package/dist/func/types.d.ts +0 -64
  99. package/dist/func/types.d.ts.map +0 -1
  100. package/dist/graph/annotation.cjs +0 -101
  101. package/dist/graph/annotation.cjs.map +0 -1
  102. package/dist/graph/annotation.d.cts +0 -116
  103. package/dist/graph/annotation.d.cts.map +0 -1
  104. package/dist/graph/annotation.d.ts +0 -116
  105. package/dist/graph/annotation.d.ts.map +0 -1
  106. package/dist/graph/annotation.js +0 -99
  107. package/dist/graph/annotation.js.map +0 -1
  108. package/dist/graph/graph.cjs +0 -423
  109. package/dist/graph/graph.cjs.map +0 -1
  110. package/dist/graph/graph.d.cts +0 -132
  111. package/dist/graph/graph.d.cts.map +0 -1
  112. package/dist/graph/graph.d.ts +0 -132
  113. package/dist/graph/graph.d.ts.map +0 -1
  114. package/dist/graph/graph.js +0 -420
  115. package/dist/graph/graph.js.map +0 -1
  116. package/dist/graph/index.cjs +0 -5
  117. package/dist/graph/index.js +0 -7
  118. package/dist/graph/message.cjs +0 -99
  119. package/dist/graph/message.cjs.map +0 -1
  120. package/dist/graph/message.d.cts +0 -40
  121. package/dist/graph/message.d.cts.map +0 -1
  122. package/dist/graph/message.d.ts +0 -40
  123. package/dist/graph/message.d.ts.map +0 -1
  124. package/dist/graph/message.js +0 -95
  125. package/dist/graph/message.js.map +0 -1
  126. package/dist/graph/messages_annotation.cjs +0 -110
  127. package/dist/graph/messages_annotation.cjs.map +0 -1
  128. package/dist/graph/messages_annotation.d.cts +0 -112
  129. package/dist/graph/messages_annotation.d.cts.map +0 -1
  130. package/dist/graph/messages_annotation.d.ts +0 -112
  131. package/dist/graph/messages_annotation.d.ts.map +0 -1
  132. package/dist/graph/messages_annotation.js +0 -107
  133. package/dist/graph/messages_annotation.js.map +0 -1
  134. package/dist/graph/state.cjs +0 -501
  135. package/dist/graph/state.cjs.map +0 -1
  136. package/dist/graph/state.d.cts +0 -236
  137. package/dist/graph/state.d.cts.map +0 -1
  138. package/dist/graph/state.d.ts +0 -236
  139. package/dist/graph/state.d.ts.map +0 -1
  140. package/dist/graph/state.js +0 -499
  141. package/dist/graph/state.js.map +0 -1
  142. package/dist/graph/zod/index.cjs +0 -10
  143. package/dist/graph/zod/index.d.cts +0 -3
  144. package/dist/graph/zod/index.d.ts +0 -3
  145. package/dist/graph/zod/index.js +0 -5
  146. package/dist/graph/zod/meta.cjs +0 -145
  147. package/dist/graph/zod/meta.cjs.map +0 -1
  148. package/dist/graph/zod/meta.d.cts +0 -116
  149. package/dist/graph/zod/meta.d.cts.map +0 -1
  150. package/dist/graph/zod/meta.d.ts +0 -116
  151. package/dist/graph/zod/meta.d.ts.map +0 -1
  152. package/dist/graph/zod/meta.js +0 -141
  153. package/dist/graph/zod/meta.js.map +0 -1
  154. package/dist/graph/zod/plugin.cjs +0 -41
  155. package/dist/graph/zod/plugin.cjs.map +0 -1
  156. package/dist/graph/zod/plugin.js +0 -41
  157. package/dist/graph/zod/plugin.js.map +0 -1
  158. package/dist/graph/zod/schema.cjs +0 -99
  159. package/dist/graph/zod/schema.cjs.map +0 -1
  160. package/dist/graph/zod/schema.d.cts +0 -38
  161. package/dist/graph/zod/schema.d.cts.map +0 -1
  162. package/dist/graph/zod/schema.d.ts +0 -38
  163. package/dist/graph/zod/schema.d.ts.map +0 -1
  164. package/dist/graph/zod/schema.js +0 -94
  165. package/dist/graph/zod/schema.js.map +0 -1
  166. package/dist/graph/zod/zod-registry.cjs +0 -43
  167. package/dist/graph/zod/zod-registry.cjs.map +0 -1
  168. package/dist/graph/zod/zod-registry.d.cts +0 -51
  169. package/dist/graph/zod/zod-registry.d.cts.map +0 -1
  170. package/dist/graph/zod/zod-registry.d.ts +0 -51
  171. package/dist/graph/zod/zod-registry.d.ts.map +0 -1
  172. package/dist/graph/zod/zod-registry.js +0 -41
  173. package/dist/graph/zod/zod-registry.js.map +0 -1
  174. package/dist/hash.cjs +0 -271
  175. package/dist/hash.cjs.map +0 -1
  176. package/dist/hash.js +0 -269
  177. package/dist/hash.js.map +0 -1
  178. package/dist/index.cjs +0 -112
  179. package/dist/index.cjs.map +0 -1
  180. package/dist/index.d.cts +0 -26
  181. package/dist/index.d.ts +0 -26
  182. package/dist/index.js +0 -22
  183. package/dist/index.js.map +0 -1
  184. package/dist/interrupt.cjs +0 -82
  185. package/dist/interrupt.cjs.map +0 -1
  186. package/dist/interrupt.d.cts +0 -58
  187. package/dist/interrupt.d.cts.map +0 -1
  188. package/dist/interrupt.d.ts +0 -58
  189. package/dist/interrupt.d.ts.map +0 -1
  190. package/dist/interrupt.js +0 -81
  191. package/dist/interrupt.js.map +0 -1
  192. package/dist/prebuilt/agentName.cjs +0 -153
  193. package/dist/prebuilt/agentName.cjs.map +0 -1
  194. package/dist/prebuilt/agentName.d.cts +0 -42
  195. package/dist/prebuilt/agentName.d.cts.map +0 -1
  196. package/dist/prebuilt/agentName.d.ts +0 -42
  197. package/dist/prebuilt/agentName.d.ts.map +0 -1
  198. package/dist/prebuilt/agentName.js +0 -152
  199. package/dist/prebuilt/agentName.js.map +0 -1
  200. package/dist/prebuilt/agent_executor.cjs +0 -44
  201. package/dist/prebuilt/agent_executor.cjs.map +0 -1
  202. package/dist/prebuilt/agent_executor.d.cts +0 -58
  203. package/dist/prebuilt/agent_executor.d.cts.map +0 -1
  204. package/dist/prebuilt/agent_executor.d.ts +0 -58
  205. package/dist/prebuilt/agent_executor.d.ts.map +0 -1
  206. package/dist/prebuilt/agent_executor.js +0 -44
  207. package/dist/prebuilt/agent_executor.js.map +0 -1
  208. package/dist/prebuilt/chat_agent_executor.cjs +0 -68
  209. package/dist/prebuilt/chat_agent_executor.cjs.map +0 -1
  210. package/dist/prebuilt/chat_agent_executor.d.cts +0 -23
  211. package/dist/prebuilt/chat_agent_executor.d.cts.map +0 -1
  212. package/dist/prebuilt/chat_agent_executor.d.ts +0 -23
  213. package/dist/prebuilt/chat_agent_executor.d.ts.map +0 -1
  214. package/dist/prebuilt/chat_agent_executor.js +0 -67
  215. package/dist/prebuilt/chat_agent_executor.js.map +0 -1
  216. package/dist/prebuilt/index.cjs +0 -15
  217. package/dist/prebuilt/index.d.cts +0 -8
  218. package/dist/prebuilt/index.d.ts +0 -8
  219. package/dist/prebuilt/index.js +0 -8
  220. package/dist/prebuilt/interrupt.d.cts +0 -61
  221. package/dist/prebuilt/interrupt.d.cts.map +0 -1
  222. package/dist/prebuilt/interrupt.d.ts +0 -61
  223. package/dist/prebuilt/interrupt.d.ts.map +0 -1
  224. package/dist/prebuilt/react_agent_executor.cjs +0 -344
  225. package/dist/prebuilt/react_agent_executor.cjs.map +0 -1
  226. package/dist/prebuilt/react_agent_executor.d.cts +0 -230
  227. package/dist/prebuilt/react_agent_executor.d.cts.map +0 -1
  228. package/dist/prebuilt/react_agent_executor.d.ts +0 -230
  229. package/dist/prebuilt/react_agent_executor.d.ts.map +0 -1
  230. package/dist/prebuilt/react_agent_executor.js +0 -342
  231. package/dist/prebuilt/react_agent_executor.js.map +0 -1
  232. package/dist/prebuilt/tool_executor.cjs +0 -48
  233. package/dist/prebuilt/tool_executor.cjs.map +0 -1
  234. package/dist/prebuilt/tool_executor.d.cts +0 -42
  235. package/dist/prebuilt/tool_executor.d.cts.map +0 -1
  236. package/dist/prebuilt/tool_executor.d.ts +0 -42
  237. package/dist/prebuilt/tool_executor.d.ts.map +0 -1
  238. package/dist/prebuilt/tool_executor.js +0 -47
  239. package/dist/prebuilt/tool_executor.js.map +0 -1
  240. package/dist/prebuilt/tool_node.cjs +0 -248
  241. package/dist/prebuilt/tool_node.cjs.map +0 -1
  242. package/dist/prebuilt/tool_node.d.cts +0 -182
  243. package/dist/prebuilt/tool_node.d.cts.map +0 -1
  244. package/dist/prebuilt/tool_node.d.ts +0 -182
  245. package/dist/prebuilt/tool_node.d.ts.map +0 -1
  246. package/dist/prebuilt/tool_node.js +0 -246
  247. package/dist/prebuilt/tool_node.js.map +0 -1
  248. package/dist/pregel/algo.cjs +0 -573
  249. package/dist/pregel/algo.cjs.map +0 -1
  250. package/dist/pregel/algo.d.cts +0 -13
  251. package/dist/pregel/algo.d.cts.map +0 -1
  252. package/dist/pregel/algo.d.ts +0 -13
  253. package/dist/pregel/algo.d.ts.map +0 -1
  254. package/dist/pregel/algo.js +0 -567
  255. package/dist/pregel/algo.js.map +0 -1
  256. package/dist/pregel/call.cjs +0 -53
  257. package/dist/pregel/call.cjs.map +0 -1
  258. package/dist/pregel/call.js +0 -50
  259. package/dist/pregel/call.js.map +0 -1
  260. package/dist/pregel/debug.cjs +0 -175
  261. package/dist/pregel/debug.cjs.map +0 -1
  262. package/dist/pregel/debug.js +0 -169
  263. package/dist/pregel/debug.js.map +0 -1
  264. package/dist/pregel/index.cjs +0 -1170
  265. package/dist/pregel/index.cjs.map +0 -1
  266. package/dist/pregel/index.d.cts +0 -546
  267. package/dist/pregel/index.d.cts.map +0 -1
  268. package/dist/pregel/index.d.ts +0 -546
  269. package/dist/pregel/index.d.ts.map +0 -1
  270. package/dist/pregel/index.js +0 -1168
  271. package/dist/pregel/index.js.map +0 -1
  272. package/dist/pregel/io.cjs +0 -140
  273. package/dist/pregel/io.cjs.map +0 -1
  274. package/dist/pregel/io.js +0 -135
  275. package/dist/pregel/io.js.map +0 -1
  276. package/dist/pregel/loop.cjs +0 -548
  277. package/dist/pregel/loop.cjs.map +0 -1
  278. package/dist/pregel/loop.js +0 -547
  279. package/dist/pregel/loop.js.map +0 -1
  280. package/dist/pregel/messages.cjs +0 -108
  281. package/dist/pregel/messages.cjs.map +0 -1
  282. package/dist/pregel/messages.js +0 -107
  283. package/dist/pregel/messages.js.map +0 -1
  284. package/dist/pregel/read.cjs +0 -152
  285. package/dist/pregel/read.cjs.map +0 -1
  286. package/dist/pregel/read.d.cts +0 -51
  287. package/dist/pregel/read.d.cts.map +0 -1
  288. package/dist/pregel/read.d.ts +0 -51
  289. package/dist/pregel/read.d.ts.map +0 -1
  290. package/dist/pregel/read.js +0 -150
  291. package/dist/pregel/read.js.map +0 -1
  292. package/dist/pregel/remote.cjs +0 -346
  293. package/dist/pregel/remote.cjs.map +0 -1
  294. package/dist/pregel/remote.d.cts +0 -121
  295. package/dist/pregel/remote.d.cts.map +0 -1
  296. package/dist/pregel/remote.d.ts +0 -121
  297. package/dist/pregel/remote.d.ts.map +0 -1
  298. package/dist/pregel/remote.js +0 -345
  299. package/dist/pregel/remote.js.map +0 -1
  300. package/dist/pregel/retry.cjs +0 -92
  301. package/dist/pregel/retry.cjs.map +0 -1
  302. package/dist/pregel/retry.js +0 -92
  303. package/dist/pregel/retry.js.map +0 -1
  304. package/dist/pregel/runnable_types.d.cts +0 -49
  305. package/dist/pregel/runnable_types.d.cts.map +0 -1
  306. package/dist/pregel/runnable_types.d.ts +0 -49
  307. package/dist/pregel/runnable_types.d.ts.map +0 -1
  308. package/dist/pregel/runner.cjs +0 -228
  309. package/dist/pregel/runner.cjs.map +0 -1
  310. package/dist/pregel/runner.js +0 -228
  311. package/dist/pregel/runner.js.map +0 -1
  312. package/dist/pregel/stream.cjs +0 -199
  313. package/dist/pregel/stream.cjs.map +0 -1
  314. package/dist/pregel/stream.js +0 -196
  315. package/dist/pregel/stream.js.map +0 -1
  316. package/dist/pregel/types.cjs +0 -27
  317. package/dist/pregel/types.cjs.map +0 -1
  318. package/dist/pregel/types.d.cts +0 -453
  319. package/dist/pregel/types.d.cts.map +0 -1
  320. package/dist/pregel/types.d.ts +0 -453
  321. package/dist/pregel/types.d.ts.map +0 -1
  322. package/dist/pregel/types.js +0 -25
  323. package/dist/pregel/types.js.map +0 -1
  324. package/dist/pregel/utils/config.cjs +0 -122
  325. package/dist/pregel/utils/config.cjs.map +0 -1
  326. package/dist/pregel/utils/config.d.cts +0 -36
  327. package/dist/pregel/utils/config.d.cts.map +0 -1
  328. package/dist/pregel/utils/config.d.ts +0 -36
  329. package/dist/pregel/utils/config.d.ts.map +0 -1
  330. package/dist/pregel/utils/config.js +0 -115
  331. package/dist/pregel/utils/config.js.map +0 -1
  332. package/dist/pregel/utils/index.cjs +0 -103
  333. package/dist/pregel/utils/index.cjs.map +0 -1
  334. package/dist/pregel/utils/index.d.cts +0 -51
  335. package/dist/pregel/utils/index.d.cts.map +0 -1
  336. package/dist/pregel/utils/index.d.ts +0 -51
  337. package/dist/pregel/utils/index.d.ts.map +0 -1
  338. package/dist/pregel/utils/index.js +0 -97
  339. package/dist/pregel/utils/index.js.map +0 -1
  340. package/dist/pregel/utils/subgraph.cjs +0 -19
  341. package/dist/pregel/utils/subgraph.cjs.map +0 -1
  342. package/dist/pregel/utils/subgraph.js +0 -17
  343. package/dist/pregel/utils/subgraph.js.map +0 -1
  344. package/dist/pregel/validate.cjs +0 -45
  345. package/dist/pregel/validate.cjs.map +0 -1
  346. package/dist/pregel/validate.js +0 -44
  347. package/dist/pregel/validate.js.map +0 -1
  348. package/dist/pregel/write.cjs +0 -97
  349. package/dist/pregel/write.cjs.map +0 -1
  350. package/dist/pregel/write.d.cts +0 -35
  351. package/dist/pregel/write.d.cts.map +0 -1
  352. package/dist/pregel/write.d.ts +0 -35
  353. package/dist/pregel/write.d.ts.map +0 -1
  354. package/dist/pregel/write.js +0 -95
  355. package/dist/pregel/write.js.map +0 -1
  356. package/dist/remote.cjs +0 -3
  357. package/dist/remote.d.cts +0 -2
  358. package/dist/remote.d.ts +0 -2
  359. package/dist/remote.js +0 -3
  360. package/dist/setup/async_local_storage.cjs +0 -12
  361. package/dist/setup/async_local_storage.cjs.map +0 -1
  362. package/dist/setup/async_local_storage.js +0 -11
  363. package/dist/setup/async_local_storage.js.map +0 -1
  364. package/dist/utils.cjs +0 -88
  365. package/dist/utils.cjs.map +0 -1
  366. package/dist/utils.d.cts +0 -32
  367. package/dist/utils.d.cts.map +0 -1
  368. package/dist/utils.d.ts +0 -32
  369. package/dist/utils.d.ts.map +0 -1
  370. package/dist/utils.js +0 -81
  371. package/dist/utils.js.map +0 -1
  372. package/dist/web.cjs +0 -96
  373. package/dist/web.d.cts +0 -23
  374. package/dist/web.d.ts +0 -23
  375. package/dist/web.js +0 -15
  376. package/dist/writer.cjs +0 -15
  377. package/dist/writer.cjs.map +0 -1
  378. package/dist/writer.d.cts +0 -7
  379. package/dist/writer.d.cts.map +0 -1
  380. package/dist/writer.d.ts +0 -7
  381. package/dist/writer.d.ts.map +0 -1
  382. package/dist/writer.js +0 -14
  383. package/dist/writer.js.map +0 -1
@@ -1,145 +0,0 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- const require_binop = require('../../channels/binop.cjs');
3
- const require_last_value = require('../../channels/last_value.cjs');
4
- const __langchain_core_utils_types = require_rolldown_runtime.__toESM(require("@langchain/core/utils/types"));
5
-
6
- //#region src/graph/zod/meta.ts
7
- const META_EXTRAS_DESCRIPTION_PREFIX = "lg:";
8
- /**
9
- * A registry for storing and managing metadata associated with schemas.
10
- * This class provides methods to get, extend, remove, and check metadata for a given schema.
11
- */
12
- var SchemaMetaRegistry = class {
13
- /**
14
- * Internal map storing schema metadata.
15
- * @internal
16
- */
17
- _map = /* @__PURE__ */ new WeakMap();
18
- /**
19
- * Cache for extended schfemas.
20
- * @internal
21
- */
22
- _extensionCache = /* @__PURE__ */ new Map();
23
- /**
24
- * Retrieves the metadata associated with a given schema.
25
- * @template TValue The value type of the schema.
26
- * @template TUpdate The update type of the schema (defaults to TValue).
27
- * @param schema The schema to retrieve metadata for.
28
- * @returns The associated SchemaMeta, or undefined if not present.
29
- */
30
- get(schema) {
31
- return this._map.get(schema);
32
- }
33
- /**
34
- * Extends or sets the metadata for a given schema.
35
- * @template TValue The value type of the schema.
36
- * @template TUpdate The update type of the schema (defaults to TValue).
37
- * @param schema The schema to extend metadata for.
38
- * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.
39
- */
40
- extend(schema, predicate) {
41
- const existingMeta = this.get(schema);
42
- this._map.set(schema, predicate(existingMeta));
43
- }
44
- /**
45
- * Removes the metadata associated with a given schema.
46
- * @param schema The schema to remove metadata for.
47
- * @returns The SchemaMetaRegistry instance (for chaining).
48
- */
49
- remove(schema) {
50
- this._map.delete(schema);
51
- return this;
52
- }
53
- /**
54
- * Checks if metadata exists for a given schema.
55
- * @param schema The schema to check.
56
- * @returns True if metadata exists, false otherwise.
57
- */
58
- has(schema) {
59
- return this._map.has(schema);
60
- }
61
- /**
62
- * Returns a mapping of channel instances for each property in the schema
63
- * using the associated metadata in the registry.
64
- *
65
- * This is used to create the `channels` object that's passed to the `Graph` constructor.
66
- *
67
- * @template T The shape of the schema.
68
- * @param schema The schema to extract channels from.
69
- * @returns A mapping from property names to channel instances.
70
- */
71
- getChannelsForSchema(schema) {
72
- const channels = {};
73
- const shape = (0, __langchain_core_utils_types.getInteropZodObjectShape)(schema);
74
- for (const [key, channelSchema] of Object.entries(shape)) {
75
- const meta = this.get(channelSchema);
76
- if (meta?.reducer) channels[key] = new require_binop.BinaryOperatorAggregate(meta.reducer.fn, meta.default);
77
- else channels[key] = new require_last_value.LastValue(meta?.default);
78
- }
79
- return channels;
80
- }
81
- /**
82
- * Returns a modified schema that introspectively looks at all keys of the provided
83
- * object schema, and applies the augmentations based on meta provided with those keys
84
- * in the registry and the selectors provided in the `effects` parameter.
85
- *
86
- * This assumes that the passed in schema is the "root" schema object for a graph where
87
- * the keys of the schema are the channels of the graph. Because we need to represent
88
- * the input of a graph in a couple of different ways, the `effects` parameter allows
89
- * us to apply those augmentations based on pre determined conditions.
90
- *
91
- * @param schema The root schema object to extend.
92
- * @param effects The effects that are being applied.
93
- * @returns The extended schema.
94
- */
95
- getExtendedChannelSchemas(schema, effects) {
96
- if (Object.keys(effects).length === 0) return schema;
97
- const cacheKey = Object.entries(effects).filter(([, v]) => v === true).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}:${v}`).join("|");
98
- const cache = this._extensionCache.get(cacheKey) ?? /* @__PURE__ */ new WeakMap();
99
- if (cache.has(schema)) return cache.get(schema);
100
- let modifiedSchema = schema;
101
- if (effects.withReducerSchema || effects.withJsonSchemaExtrasAsDescription) {
102
- const newShapeEntries = Object.entries((0, __langchain_core_utils_types.getInteropZodObjectShape)(schema)).map(([key, schema$1]) => {
103
- const meta = this.get(schema$1);
104
- let outputSchema = effects.withReducerSchema ? meta?.reducer?.schema ?? schema$1 : schema$1;
105
- if (effects.withJsonSchemaExtrasAsDescription && meta?.jsonSchemaExtra) {
106
- const description = (0, __langchain_core_utils_types.getSchemaDescription)(outputSchema) ?? (0, __langchain_core_utils_types.getSchemaDescription)(schema$1);
107
- const strExtras = JSON.stringify({
108
- ...meta.jsonSchemaExtra,
109
- description
110
- });
111
- outputSchema = outputSchema.describe(`${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`);
112
- }
113
- return [key, outputSchema];
114
- });
115
- modifiedSchema = (0, __langchain_core_utils_types.extendInteropZodObject)(schema, Object.fromEntries(newShapeEntries));
116
- if ((0, __langchain_core_utils_types.isZodSchemaV3)(modifiedSchema)) modifiedSchema._def.unknownKeys = "strip";
117
- }
118
- if (effects.asPartial) modifiedSchema = (0, __langchain_core_utils_types.interopZodObjectPartial)(modifiedSchema);
119
- cache.set(schema, modifiedSchema);
120
- this._extensionCache.set(cacheKey, cache);
121
- return modifiedSchema;
122
- }
123
- };
124
- const schemaMetaRegistry = new SchemaMetaRegistry();
125
- function withLangGraph(schema, meta) {
126
- if (meta.reducer && !meta.default) {
127
- const defaultValueGetter = (0, __langchain_core_utils_types.getInteropZodDefaultGetter)(schema);
128
- if (defaultValueGetter != null) meta.default = defaultValueGetter;
129
- }
130
- if (meta.reducer) {
131
- const schemaWithReducer = Object.assign(schema, { lg_reducer_schema: meta.reducer?.schema ?? schema });
132
- schemaMetaRegistry.extend(schemaWithReducer, () => meta);
133
- return schemaWithReducer;
134
- } else {
135
- schemaMetaRegistry.extend(schema, () => meta);
136
- return schema;
137
- }
138
- }
139
-
140
- //#endregion
141
- exports.META_EXTRAS_DESCRIPTION_PREFIX = META_EXTRAS_DESCRIPTION_PREFIX;
142
- exports.SchemaMetaRegistry = SchemaMetaRegistry;
143
- exports.schemaMetaRegistry = schemaMetaRegistry;
144
- exports.withLangGraph = withLangGraph;
145
- //# sourceMappingURL=meta.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"meta.cjs","names":["BinaryOperatorAggregate","LastValue","modifiedSchema: InteropZodObject","schema"],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<unknown>\n ? ReducerSchema extends InteropZodType<infer U>\n ? U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new WeakMap<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schfemas.\n * @internal\n */\n _extensionCache = new Map<string, WeakMap<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new WeakMap();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;;AAgBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI;;;;;CAMX,kCAAkB,IAAI;;;;;;;;CAStB,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI;;;;;;;;;CAUvB,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB;AAC/C,OAAK,KAAK,IAAI,QAAQ,UAAU;;;;;;;CAQlC,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO;AACjB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI;;;;;;;;;;;;CAavB,qBACE,QACgC;EAChC,MAAM,WAAW;EACjB,MAAM,mEAAiC;AACvC,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,QA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tD,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU;AAE7C,qBAAmB,OAAO,yBAAyB;AACnD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc;AACxC,SAAO"}
@@ -1,116 +0,0 @@
1
- import { BaseChannel } from "../../channels/base.cjs";
2
- import { InteropZodObject, InteropZodObjectShape, InteropZodType } from "@langchain/core/utils/types";
3
-
4
- //#region src/graph/zod/meta.d.ts
5
- declare const META_EXTRAS_DESCRIPTION_PREFIX = "lg:";
6
- /** @internal */
7
- type ReducedZodChannel<T extends InteropZodType, TReducerSchema extends InteropZodType> = T & {
8
- lg_reducer_schema: TReducerSchema;
9
- };
10
- /** @internal */
11
- type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never };
12
- type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<unknown> ? ReducerSchema extends InteropZodType<infer U> ? U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never };
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- interface SchemaMeta<TValue = any, TUpdate = TValue> {
15
- jsonSchemaExtra?: {
16
- langgraph_nodes?: string[];
17
- langgraph_type?: "prompt" | "messages";
18
- [key: string]: unknown;
19
- };
20
- reducer?: {
21
- schema?: InteropZodType<TUpdate>;
22
- fn: (a: TValue, b: TUpdate) => TValue;
23
- };
24
- default?: () => TValue;
25
- }
26
- /**
27
- * A registry for storing and managing metadata associated with schemas.
28
- * This class provides methods to get, extend, remove, and check metadata for a given schema.
29
- */
30
- declare class SchemaMetaRegistry {
31
- /**
32
- * Internal map storing schema metadata.
33
- * @internal
34
- */
35
- _map: WeakMap<InteropZodType, SchemaMeta<any, any>>;
36
- /**
37
- * Cache for extended schfemas.
38
- * @internal
39
- */
40
- _extensionCache: Map<string, WeakMap<InteropZodType, InteropZodType>>;
41
- /**
42
- * Retrieves the metadata associated with a given schema.
43
- * @template TValue The value type of the schema.
44
- * @template TUpdate The update type of the schema (defaults to TValue).
45
- * @param schema The schema to retrieve metadata for.
46
- * @returns The associated SchemaMeta, or undefined if not present.
47
- */
48
- get<TValue, TUpdate = TValue>(schema: InteropZodType<TValue>): SchemaMeta<TValue, TUpdate> | undefined;
49
- /**
50
- * Extends or sets the metadata for a given schema.
51
- * @template TValue The value type of the schema.
52
- * @template TUpdate The update type of the schema (defaults to TValue).
53
- * @param schema The schema to extend metadata for.
54
- * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.
55
- */
56
- extend<TValue, TUpdate>(schema: InteropZodType<TValue>, predicate: (meta: SchemaMeta<TValue, TUpdate> | undefined) => SchemaMeta<TValue, TUpdate>): void;
57
- /**
58
- * Removes the metadata associated with a given schema.
59
- * @param schema The schema to remove metadata for.
60
- * @returns The SchemaMetaRegistry instance (for chaining).
61
- */
62
- remove(schema: InteropZodType): this;
63
- /**
64
- * Checks if metadata exists for a given schema.
65
- * @param schema The schema to check.
66
- * @returns True if metadata exists, false otherwise.
67
- */
68
- has(schema: InteropZodType): boolean;
69
- /**
70
- * Returns a mapping of channel instances for each property in the schema
71
- * using the associated metadata in the registry.
72
- *
73
- * This is used to create the `channels` object that's passed to the `Graph` constructor.
74
- *
75
- * @template T The shape of the schema.
76
- * @param schema The schema to extract channels from.
77
- * @returns A mapping from property names to channel instances.
78
- */
79
- getChannelsForSchema<T extends InteropZodObject>(schema: T): InteropZodToStateDefinition<T>;
80
- /**
81
- * Returns a modified schema that introspectively looks at all keys of the provided
82
- * object schema, and applies the augmentations based on meta provided with those keys
83
- * in the registry and the selectors provided in the `effects` parameter.
84
- *
85
- * This assumes that the passed in schema is the "root" schema object for a graph where
86
- * the keys of the schema are the channels of the graph. Because we need to represent
87
- * the input of a graph in a couple of different ways, the `effects` parameter allows
88
- * us to apply those augmentations based on pre determined conditions.
89
- *
90
- * @param schema The root schema object to extend.
91
- * @param effects The effects that are being applied.
92
- * @returns The extended schema.
93
- */
94
- getExtendedChannelSchemas<T extends InteropZodObject>(schema: T, effects: {
95
- /**
96
- * Augments the shape by using the reducer's schema if it exists
97
- */
98
- withReducerSchema?: boolean;
99
- /**
100
- * Applies the stringified jsonSchemaExtra as a description to the schema.
101
- */
102
- withJsonSchemaExtrasAsDescription?: boolean;
103
- /**
104
- * Applies the `.partial()` modifier to the schema.
105
- */
106
- asPartial?: boolean;
107
- }): InteropZodObject;
108
- }
109
- declare const schemaMetaRegistry: SchemaMetaRegistry;
110
- declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate> & {
111
- reducer?: undefined;
112
- }): TSchema;
113
- declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate>): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;
114
- //#endregion
115
- export { InteropZodToStateDefinition, META_EXTRAS_DESCRIPTION_PREFIX, ReducedZodChannel, SchemaMeta, SchemaMetaRegistry, UpdateType, schemaMetaRegistry, withLangGraph };
116
- //# sourceMappingURL=meta.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"meta.d.cts","names":["InteropZodObject","InteropZodType","InteropZodObjectShape","BaseChannel","META_EXTRAS_DESCRIPTION_PREFIX","ReducedZodChannel","T","TReducerSchema","InteropZodToStateDefinition","TShape","key","Schema","ReducerSchema","V","U","UpdateType","SchemaMeta","TValue","TUpdate","SchemaMetaRegistry","WeakMap","Map","schemaMetaRegistry","withLangGraph","TSchema"],"sources":["../../../src/graph/zod/meta.d.ts"],"sourcesContent":["import { InteropZodObject, InteropZodType, InteropZodObjectShape } from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nexport declare const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n/** @internal */\nexport type ReducedZodChannel<T extends InteropZodType, TReducerSchema extends InteropZodType> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n/** @internal */\nexport type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never;\n};\nexport type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<unknown> ? ReducerSchema extends InteropZodType<infer U> ? U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never;\n};\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport declare class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map: WeakMap<InteropZodType, SchemaMeta<any, any>>;\n /**\n * Cache for extended schfemas.\n * @internal\n */\n _extensionCache: Map<string, WeakMap<InteropZodType, InteropZodType>>;\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(schema: InteropZodType<TValue>): SchemaMeta<TValue, TUpdate> | undefined;\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(schema: InteropZodType<TValue>, predicate: (meta: SchemaMeta<TValue, TUpdate> | undefined) => SchemaMeta<TValue, TUpdate>): void;\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this;\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean;\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(schema: T): InteropZodToStateDefinition<T>;\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(schema: T, effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }): InteropZodObject;\n}\nexport declare const schemaMetaRegistry: SchemaMetaRegistry;\nexport declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate> & {\n reducer?: undefined;\n}): TSchema;\nexport declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate>): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\n"],"mappings":";;;;cAEqBI,8BAAAA;;AAAAA,KAETC,iBAFSD,CAAAA,UAEmBH,cAFW,EAAA,uBAE4BA,cAF5B,CAAA,GAE8CK,CAF9C,GAAA;EAEvCD,iBAAAA,EACWE,cADM;CAAA;;AAAkDN,KAInEO,2BAJmEP,CAAAA,UAI7BD,gBAJ6BC,EAAAA,SAIFC,qBAJED,CAIoBK,CAJpBL,CAAAA,CAAAA,GAAAA,UAAkBK,MAK/EG,MAL+EH,GAKtEG,MALsEH,CAK/DI,GAL+DJ,CAAAA,SAKlDD,iBALkDC,CAAAA,KAAAA,OAAAA,EAAAA,KAAAA,cAAAA,CAAAA,GAKKK,MALLL,SAKoBL,cALpBK,CAAAA,KAAAA,EAAAA,CAAAA,GAK8CM,aAL9CN,SAKoEL,cALpEK,CAAAA,KAAAA,EAAAA,CAAAA,GAK8FH,WAL9FG,CAK0GO,CAL1GP,EAK6GQ,CAL7GR,CAAAA,GAAAA,KAAAA,GAAAA,KAAAA,GAKkIG,MALlIH,CAKyII,GALzIJ,CAAAA,SAKsJL,cALtJK,CAAAA,KAAAA,EAAAA,EAAAA,KAAAA,EAAAA,CAAAA,GAKyLH,WALzLG,CAKqMO,CALrMP,EAKwMQ,CALxMR,CAAAA,GAAAA,KAAAA;KAOrFS,qBAAqBf,2BAA2BE,sBAAsBI,gBAHtEE,MA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B,CAAAA,EAAAA,SAAAA;IADnGA,OAC6HP;AAAQC,iBAAjHK,aAAiHL,CAAAA,MAAAA,EAAAA,OAAAA,EAAAA,gBAAlEjB,cAAkEiB,CAAnDD,MAAmDC,CAAAA,CAAAA,CAAAA,MAAAA,EAAlCM,OAAkCN,EAAAA,IAAAA,EAAnBF,UAAmBE,CAARD,MAAQC,EAAAA,OAAAA,CAAAA,CAAAA,EAAWb,iBAAXa,CAA6BM,OAA7BN,EAAsCjB,cAAtCiB,CAAqDA,OAArDA,CAAAA,CAAAA"}
@@ -1,116 +0,0 @@
1
- import { BaseChannel } from "../../channels/base.js";
2
- import { InteropZodObject, InteropZodObjectShape, InteropZodType } from "@langchain/core/utils/types";
3
-
4
- //#region src/graph/zod/meta.d.ts
5
- declare const META_EXTRAS_DESCRIPTION_PREFIX = "lg:";
6
- /** @internal */
7
- type ReducedZodChannel<T extends InteropZodType, TReducerSchema extends InteropZodType> = T & {
8
- lg_reducer_schema: TReducerSchema;
9
- };
10
- /** @internal */
11
- type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never };
12
- type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<unknown> ? ReducerSchema extends InteropZodType<infer U> ? U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never };
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- interface SchemaMeta<TValue = any, TUpdate = TValue> {
15
- jsonSchemaExtra?: {
16
- langgraph_nodes?: string[];
17
- langgraph_type?: "prompt" | "messages";
18
- [key: string]: unknown;
19
- };
20
- reducer?: {
21
- schema?: InteropZodType<TUpdate>;
22
- fn: (a: TValue, b: TUpdate) => TValue;
23
- };
24
- default?: () => TValue;
25
- }
26
- /**
27
- * A registry for storing and managing metadata associated with schemas.
28
- * This class provides methods to get, extend, remove, and check metadata for a given schema.
29
- */
30
- declare class SchemaMetaRegistry {
31
- /**
32
- * Internal map storing schema metadata.
33
- * @internal
34
- */
35
- _map: WeakMap<InteropZodType, SchemaMeta<any, any>>;
36
- /**
37
- * Cache for extended schfemas.
38
- * @internal
39
- */
40
- _extensionCache: Map<string, WeakMap<InteropZodType, InteropZodType>>;
41
- /**
42
- * Retrieves the metadata associated with a given schema.
43
- * @template TValue The value type of the schema.
44
- * @template TUpdate The update type of the schema (defaults to TValue).
45
- * @param schema The schema to retrieve metadata for.
46
- * @returns The associated SchemaMeta, or undefined if not present.
47
- */
48
- get<TValue, TUpdate = TValue>(schema: InteropZodType<TValue>): SchemaMeta<TValue, TUpdate> | undefined;
49
- /**
50
- * Extends or sets the metadata for a given schema.
51
- * @template TValue The value type of the schema.
52
- * @template TUpdate The update type of the schema (defaults to TValue).
53
- * @param schema The schema to extend metadata for.
54
- * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.
55
- */
56
- extend<TValue, TUpdate>(schema: InteropZodType<TValue>, predicate: (meta: SchemaMeta<TValue, TUpdate> | undefined) => SchemaMeta<TValue, TUpdate>): void;
57
- /**
58
- * Removes the metadata associated with a given schema.
59
- * @param schema The schema to remove metadata for.
60
- * @returns The SchemaMetaRegistry instance (for chaining).
61
- */
62
- remove(schema: InteropZodType): this;
63
- /**
64
- * Checks if metadata exists for a given schema.
65
- * @param schema The schema to check.
66
- * @returns True if metadata exists, false otherwise.
67
- */
68
- has(schema: InteropZodType): boolean;
69
- /**
70
- * Returns a mapping of channel instances for each property in the schema
71
- * using the associated metadata in the registry.
72
- *
73
- * This is used to create the `channels` object that's passed to the `Graph` constructor.
74
- *
75
- * @template T The shape of the schema.
76
- * @param schema The schema to extract channels from.
77
- * @returns A mapping from property names to channel instances.
78
- */
79
- getChannelsForSchema<T extends InteropZodObject>(schema: T): InteropZodToStateDefinition<T>;
80
- /**
81
- * Returns a modified schema that introspectively looks at all keys of the provided
82
- * object schema, and applies the augmentations based on meta provided with those keys
83
- * in the registry and the selectors provided in the `effects` parameter.
84
- *
85
- * This assumes that the passed in schema is the "root" schema object for a graph where
86
- * the keys of the schema are the channels of the graph. Because we need to represent
87
- * the input of a graph in a couple of different ways, the `effects` parameter allows
88
- * us to apply those augmentations based on pre determined conditions.
89
- *
90
- * @param schema The root schema object to extend.
91
- * @param effects The effects that are being applied.
92
- * @returns The extended schema.
93
- */
94
- getExtendedChannelSchemas<T extends InteropZodObject>(schema: T, effects: {
95
- /**
96
- * Augments the shape by using the reducer's schema if it exists
97
- */
98
- withReducerSchema?: boolean;
99
- /**
100
- * Applies the stringified jsonSchemaExtra as a description to the schema.
101
- */
102
- withJsonSchemaExtrasAsDescription?: boolean;
103
- /**
104
- * Applies the `.partial()` modifier to the schema.
105
- */
106
- asPartial?: boolean;
107
- }): InteropZodObject;
108
- }
109
- declare const schemaMetaRegistry: SchemaMetaRegistry;
110
- declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate> & {
111
- reducer?: undefined;
112
- }): TSchema;
113
- declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate>): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;
114
- //#endregion
115
- export { InteropZodToStateDefinition, META_EXTRAS_DESCRIPTION_PREFIX, ReducedZodChannel, SchemaMeta, SchemaMetaRegistry, UpdateType, schemaMetaRegistry, withLangGraph };
116
- //# sourceMappingURL=meta.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"meta.d.ts","names":["InteropZodObject","InteropZodType","InteropZodObjectShape","BaseChannel","META_EXTRAS_DESCRIPTION_PREFIX","ReducedZodChannel","T","TReducerSchema","InteropZodToStateDefinition","TShape","key","Schema","ReducerSchema","V","U","UpdateType","SchemaMeta","TValue","TUpdate","SchemaMetaRegistry","WeakMap","Map","schemaMetaRegistry","withLangGraph","TSchema"],"sources":["../../../src/graph/zod/meta.d.ts"],"sourcesContent":["import { InteropZodObject, InteropZodType, InteropZodObjectShape } from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nexport declare const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n/** @internal */\nexport type ReducedZodChannel<T extends InteropZodType, TReducerSchema extends InteropZodType> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n/** @internal */\nexport type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never;\n};\nexport type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<unknown> ? ReducerSchema extends InteropZodType<infer U> ? U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never;\n};\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport declare class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map: WeakMap<InteropZodType, SchemaMeta<any, any>>;\n /**\n * Cache for extended schfemas.\n * @internal\n */\n _extensionCache: Map<string, WeakMap<InteropZodType, InteropZodType>>;\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(schema: InteropZodType<TValue>): SchemaMeta<TValue, TUpdate> | undefined;\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(schema: InteropZodType<TValue>, predicate: (meta: SchemaMeta<TValue, TUpdate> | undefined) => SchemaMeta<TValue, TUpdate>): void;\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this;\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean;\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(schema: T): InteropZodToStateDefinition<T>;\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(schema: T, effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }): InteropZodObject;\n}\nexport declare const schemaMetaRegistry: SchemaMetaRegistry;\nexport declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate> & {\n reducer?: undefined;\n}): TSchema;\nexport declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate>): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\n"],"mappings":";;;;cAEqBI,8BAAAA;;AAAAA,KAETC,iBAFSD,CAAAA,UAEmBH,cAFW,EAAA,uBAE4BA,cAF5B,CAAA,GAE8CK,CAF9C,GAAA;EAEvCD,iBAAAA,EACWE,cADM;CAAA;;AAAkDN,KAInEO,2BAJmEP,CAAAA,UAI7BD,gBAJ6BC,EAAAA,SAIFC,qBAJED,CAIoBK,CAJpBL,CAAAA,CAAAA,GAAAA,UAAkBK,MAK/EG,MAL+EH,GAKtEG,MALsEH,CAK/DI,GAL+DJ,CAAAA,SAKlDD,iBALkDC,CAAAA,KAAAA,OAAAA,EAAAA,KAAAA,cAAAA,CAAAA,GAKKK,MALLL,SAKoBL,cALpBK,CAAAA,KAAAA,EAAAA,CAAAA,GAK8CM,aAL9CN,SAKoEL,cALpEK,CAAAA,KAAAA,EAAAA,CAAAA,GAK8FH,WAL9FG,CAK0GO,CAL1GP,EAK6GQ,CAL7GR,CAAAA,GAAAA,KAAAA,GAAAA,KAAAA,GAKkIG,MALlIH,CAKyII,GALzIJ,CAAAA,SAKsJL,cALtJK,CAAAA,KAAAA,EAAAA,EAAAA,KAAAA,EAAAA,CAAAA,GA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AA,EAHgCuB,OAGhCvB,EAAAA,IAAAA,EAH+Ce,UAG/Cf,CAH0DgB,MAG1DhB,EAHkEiB,OAGlEjB,CAAAA,GAAAA;SAAgCuB,CAAAA,EAAAA,SAAAA;IADnGA,OAC6HP;AAAQC,iBAAjHK,aAAiHL,CAAAA,MAAAA,EAAAA,OAAAA,EAAAA,gBAAlEjB,cAAkEiB,CAAnDD,MAAmDC,CAAAA,CAAAA,CAAAA,MAAAA,EAAlCM,OAAkCN,EAAAA,IAAAA,EAAnBF,UAAmBE,CAARD,MAAQC,EAAAA,OAAAA,CAAAA,CAAAA,EAAWb,iBAAXa,CAA6BM,OAA7BN,EAAsCjB,cAAtCiB,CAAqDA,OAArDA,CAAAA,CAAAA"}
@@ -1,141 +0,0 @@
1
- import { BinaryOperatorAggregate } from "../../channels/binop.js";
2
- import { LastValue } from "../../channels/last_value.js";
3
- import { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopZodObjectPartial, isZodSchemaV3 } from "@langchain/core/utils/types";
4
-
5
- //#region src/graph/zod/meta.ts
6
- const META_EXTRAS_DESCRIPTION_PREFIX = "lg:";
7
- /**
8
- * A registry for storing and managing metadata associated with schemas.
9
- * This class provides methods to get, extend, remove, and check metadata for a given schema.
10
- */
11
- var SchemaMetaRegistry = class {
12
- /**
13
- * Internal map storing schema metadata.
14
- * @internal
15
- */
16
- _map = /* @__PURE__ */ new WeakMap();
17
- /**
18
- * Cache for extended schfemas.
19
- * @internal
20
- */
21
- _extensionCache = /* @__PURE__ */ new Map();
22
- /**
23
- * Retrieves the metadata associated with a given schema.
24
- * @template TValue The value type of the schema.
25
- * @template TUpdate The update type of the schema (defaults to TValue).
26
- * @param schema The schema to retrieve metadata for.
27
- * @returns The associated SchemaMeta, or undefined if not present.
28
- */
29
- get(schema) {
30
- return this._map.get(schema);
31
- }
32
- /**
33
- * Extends or sets the metadata for a given schema.
34
- * @template TValue The value type of the schema.
35
- * @template TUpdate The update type of the schema (defaults to TValue).
36
- * @param schema The schema to extend metadata for.
37
- * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.
38
- */
39
- extend(schema, predicate) {
40
- const existingMeta = this.get(schema);
41
- this._map.set(schema, predicate(existingMeta));
42
- }
43
- /**
44
- * Removes the metadata associated with a given schema.
45
- * @param schema The schema to remove metadata for.
46
- * @returns The SchemaMetaRegistry instance (for chaining).
47
- */
48
- remove(schema) {
49
- this._map.delete(schema);
50
- return this;
51
- }
52
- /**
53
- * Checks if metadata exists for a given schema.
54
- * @param schema The schema to check.
55
- * @returns True if metadata exists, false otherwise.
56
- */
57
- has(schema) {
58
- return this._map.has(schema);
59
- }
60
- /**
61
- * Returns a mapping of channel instances for each property in the schema
62
- * using the associated metadata in the registry.
63
- *
64
- * This is used to create the `channels` object that's passed to the `Graph` constructor.
65
- *
66
- * @template T The shape of the schema.
67
- * @param schema The schema to extract channels from.
68
- * @returns A mapping from property names to channel instances.
69
- */
70
- getChannelsForSchema(schema) {
71
- const channels = {};
72
- const shape = getInteropZodObjectShape(schema);
73
- for (const [key, channelSchema] of Object.entries(shape)) {
74
- const meta = this.get(channelSchema);
75
- if (meta?.reducer) channels[key] = new BinaryOperatorAggregate(meta.reducer.fn, meta.default);
76
- else channels[key] = new LastValue(meta?.default);
77
- }
78
- return channels;
79
- }
80
- /**
81
- * Returns a modified schema that introspectively looks at all keys of the provided
82
- * object schema, and applies the augmentations based on meta provided with those keys
83
- * in the registry and the selectors provided in the `effects` parameter.
84
- *
85
- * This assumes that the passed in schema is the "root" schema object for a graph where
86
- * the keys of the schema are the channels of the graph. Because we need to represent
87
- * the input of a graph in a couple of different ways, the `effects` parameter allows
88
- * us to apply those augmentations based on pre determined conditions.
89
- *
90
- * @param schema The root schema object to extend.
91
- * @param effects The effects that are being applied.
92
- * @returns The extended schema.
93
- */
94
- getExtendedChannelSchemas(schema, effects) {
95
- if (Object.keys(effects).length === 0) return schema;
96
- const cacheKey = Object.entries(effects).filter(([, v]) => v === true).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}:${v}`).join("|");
97
- const cache = this._extensionCache.get(cacheKey) ?? /* @__PURE__ */ new WeakMap();
98
- if (cache.has(schema)) return cache.get(schema);
99
- let modifiedSchema = schema;
100
- if (effects.withReducerSchema || effects.withJsonSchemaExtrasAsDescription) {
101
- const newShapeEntries = Object.entries(getInteropZodObjectShape(schema)).map(([key, schema$1]) => {
102
- const meta = this.get(schema$1);
103
- let outputSchema = effects.withReducerSchema ? meta?.reducer?.schema ?? schema$1 : schema$1;
104
- if (effects.withJsonSchemaExtrasAsDescription && meta?.jsonSchemaExtra) {
105
- const description = getSchemaDescription(outputSchema) ?? getSchemaDescription(schema$1);
106
- const strExtras = JSON.stringify({
107
- ...meta.jsonSchemaExtra,
108
- description
109
- });
110
- outputSchema = outputSchema.describe(`${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`);
111
- }
112
- return [key, outputSchema];
113
- });
114
- modifiedSchema = extendInteropZodObject(schema, Object.fromEntries(newShapeEntries));
115
- if (isZodSchemaV3(modifiedSchema)) modifiedSchema._def.unknownKeys = "strip";
116
- }
117
- if (effects.asPartial) modifiedSchema = interopZodObjectPartial(modifiedSchema);
118
- cache.set(schema, modifiedSchema);
119
- this._extensionCache.set(cacheKey, cache);
120
- return modifiedSchema;
121
- }
122
- };
123
- const schemaMetaRegistry = new SchemaMetaRegistry();
124
- function withLangGraph(schema, meta) {
125
- if (meta.reducer && !meta.default) {
126
- const defaultValueGetter = getInteropZodDefaultGetter(schema);
127
- if (defaultValueGetter != null) meta.default = defaultValueGetter;
128
- }
129
- if (meta.reducer) {
130
- const schemaWithReducer = Object.assign(schema, { lg_reducer_schema: meta.reducer?.schema ?? schema });
131
- schemaMetaRegistry.extend(schemaWithReducer, () => meta);
132
- return schemaWithReducer;
133
- } else {
134
- schemaMetaRegistry.extend(schema, () => meta);
135
- return schema;
136
- }
137
- }
138
-
139
- //#endregion
140
- export { META_EXTRAS_DESCRIPTION_PREFIX, SchemaMetaRegistry, schemaMetaRegistry, withLangGraph };
141
- //# sourceMappingURL=meta.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"meta.js","names":["modifiedSchema: InteropZodObject","schema"],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<unknown>\n ? ReducerSchema extends InteropZodType<infer U>\n ? U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new WeakMap<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schfemas.\n * @internal\n */\n _extensionCache = new Map<string, WeakMap<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new WeakMap();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAgBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI;;;;;CAMX,kCAAkB,IAAI;;;;;;;;CAStB,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI;;;;;;;;;CAUvB,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB;AAC/C,OAAK,KAAK,IAAI,QAAQ,UAAU;;;;;;;CAQlC,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO;AACjB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI;;;;;;;;;;;;CAavB,qBACE,QACgC;EAChC,MAAM,WAAW;EACjB,MAAM,QAAQ,yBAAyB;AACvC,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,QAAQ;GACxD,MAAM,OAAO,KAAK,IAAI;AACtB,OAAI,MAAM,QACR,UAAS,OAAO,IAAI,wBAElB,KAAK,QAAQ,IAAI,KAAK;OAExB,UAAS,OAAO,IAAI,UAAU,MAAM;;AAGxC,SAAO;;;;;;;;;;;;;;;;CAiBT,0BACE,QACA,SAckB;AAElB,MAAI,OAAO,KAAK,SAAS,WAAW,EAClC,QAAO;EAIT,MAAM,WAAW,OAAO,QAAQ,SAC7B,QAAQ,GAAG,OAAO,MAAM,MACxB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,IACnC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,KACxB,KAAK;EAER,MAAM,QAAQ,KAAK,gBAAgB,IAAI,6BAAa,IAAI;AACxD,MAAI,MAAM,IAAI,QAAS,QAAO,MAAM,I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