langchain 1.2.24 → 1.2.25

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 (325) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +24 -13
  3. package/dist/_virtual/_rolldown/runtime.js +36 -0
  4. package/dist/agents/ReactAgent.cjs +52 -65
  5. package/dist/agents/ReactAgent.cjs.map +1 -1
  6. package/dist/agents/ReactAgent.d.cts.map +1 -1
  7. package/dist/agents/ReactAgent.d.ts.map +1 -1
  8. package/dist/agents/ReactAgent.js +11 -24
  9. package/dist/agents/ReactAgent.js.map +1 -1
  10. package/dist/agents/RunnableCallable.cjs +7 -7
  11. package/dist/agents/RunnableCallable.cjs.map +1 -1
  12. package/dist/agents/RunnableCallable.js.map +1 -1
  13. package/dist/agents/annotation.cjs +41 -37
  14. package/dist/agents/annotation.cjs.map +1 -1
  15. package/dist/agents/annotation.js +21 -17
  16. package/dist/agents/annotation.js.map +1 -1
  17. package/dist/agents/constants.d.cts.map +1 -1
  18. package/dist/agents/constants.d.ts.map +1 -1
  19. package/dist/agents/errors.cjs +3 -3
  20. package/dist/agents/errors.cjs.map +1 -1
  21. package/dist/agents/errors.d.cts.map +1 -1
  22. package/dist/agents/errors.d.ts.map +1 -1
  23. package/dist/agents/errors.js.map +1 -1
  24. package/dist/agents/index.cjs.map +1 -1
  25. package/dist/agents/index.d.cts +2 -2
  26. package/dist/agents/index.d.cts.map +1 -1
  27. package/dist/agents/index.d.ts +2 -2
  28. package/dist/agents/index.d.ts.map +1 -1
  29. package/dist/agents/index.js.map +1 -1
  30. package/dist/agents/middleware/constants.cjs +2 -2
  31. package/dist/agents/middleware/constants.cjs.map +1 -1
  32. package/dist/agents/middleware/constants.js.map +1 -1
  33. package/dist/agents/middleware/contextEditing.cjs +14 -27
  34. package/dist/agents/middleware/contextEditing.cjs.map +1 -1
  35. package/dist/agents/middleware/contextEditing.d.cts +2 -3
  36. package/dist/agents/middleware/contextEditing.d.cts.map +1 -1
  37. package/dist/agents/middleware/contextEditing.d.ts +2 -3
  38. package/dist/agents/middleware/contextEditing.d.ts.map +1 -1
  39. package/dist/agents/middleware/contextEditing.js +5 -18
  40. package/dist/agents/middleware/contextEditing.js.map +1 -1
  41. package/dist/agents/middleware/dynamicSystemPrompt.cjs +3 -4
  42. package/dist/agents/middleware/dynamicSystemPrompt.cjs.map +1 -1
  43. package/dist/agents/middleware/dynamicSystemPrompt.d.cts +2 -2
  44. package/dist/agents/middleware/dynamicSystemPrompt.d.cts.map +1 -1
  45. package/dist/agents/middleware/dynamicSystemPrompt.d.ts +2 -2
  46. package/dist/agents/middleware/dynamicSystemPrompt.d.ts.map +1 -1
  47. package/dist/agents/middleware/dynamicSystemPrompt.js +1 -2
  48. package/dist/agents/middleware/dynamicSystemPrompt.js.map +1 -1
  49. package/dist/agents/middleware/error.cjs +2 -2
  50. package/dist/agents/middleware/error.cjs.map +1 -1
  51. package/dist/agents/middleware/error.js.map +1 -1
  52. package/dist/agents/middleware/hitl.cjs +16 -26
  53. package/dist/agents/middleware/hitl.cjs.map +1 -1
  54. package/dist/agents/middleware/hitl.d.cts.map +1 -1
  55. package/dist/agents/middleware/hitl.d.ts.map +1 -1
  56. package/dist/agents/middleware/hitl.js +8 -18
  57. package/dist/agents/middleware/hitl.js.map +1 -1
  58. package/dist/agents/middleware/index.js +2 -0
  59. package/dist/agents/middleware/llmToolSelector.cjs +9 -10
  60. package/dist/agents/middleware/llmToolSelector.cjs.map +1 -1
  61. package/dist/agents/middleware/llmToolSelector.d.cts +4 -4
  62. package/dist/agents/middleware/llmToolSelector.d.cts.map +1 -1
  63. package/dist/agents/middleware/llmToolSelector.d.ts +4 -4
  64. package/dist/agents/middleware/llmToolSelector.d.ts.map +1 -1
  65. package/dist/agents/middleware/llmToolSelector.js +3 -4
  66. package/dist/agents/middleware/llmToolSelector.js.map +1 -1
  67. package/dist/agents/middleware/modelCallLimit.cjs +5 -5
  68. package/dist/agents/middleware/modelCallLimit.cjs.map +1 -1
  69. package/dist/agents/middleware/modelCallLimit.d.cts +2 -2
  70. package/dist/agents/middleware/modelCallLimit.d.cts.map +1 -1
  71. package/dist/agents/middleware/modelCallLimit.d.ts +2 -2
  72. package/dist/agents/middleware/modelCallLimit.d.ts.map +1 -1
  73. package/dist/agents/middleware/modelCallLimit.js.map +1 -1
  74. package/dist/agents/middleware/modelFallback.cjs.map +1 -1
  75. package/dist/agents/middleware/modelFallback.d.cts +0 -1
  76. package/dist/agents/middleware/modelFallback.d.cts.map +1 -1
  77. package/dist/agents/middleware/modelFallback.d.ts +0 -1
  78. package/dist/agents/middleware/modelFallback.d.ts.map +1 -1
  79. package/dist/agents/middleware/modelFallback.js.map +1 -1
  80. package/dist/agents/middleware/modelRetry.cjs +19 -17
  81. package/dist/agents/middleware/modelRetry.cjs.map +1 -1
  82. package/dist/agents/middleware/modelRetry.d.cts +0 -1
  83. package/dist/agents/middleware/modelRetry.d.cts.map +1 -1
  84. package/dist/agents/middleware/modelRetry.d.ts +0 -1
  85. package/dist/agents/middleware/modelRetry.d.ts.map +1 -1
  86. package/dist/agents/middleware/modelRetry.js +15 -13
  87. package/dist/agents/middleware/modelRetry.js.map +1 -1
  88. package/dist/agents/middleware/pii.cjs +21 -32
  89. package/dist/agents/middleware/pii.cjs.map +1 -1
  90. package/dist/agents/middleware/pii.d.cts +0 -1
  91. package/dist/agents/middleware/pii.d.cts.map +1 -1
  92. package/dist/agents/middleware/pii.d.ts +0 -1
  93. package/dist/agents/middleware/pii.d.ts.map +1 -1
  94. package/dist/agents/middleware/pii.js +10 -21
  95. package/dist/agents/middleware/pii.js.map +1 -1
  96. package/dist/agents/middleware/piiRedaction.cjs +22 -28
  97. package/dist/agents/middleware/piiRedaction.cjs.map +1 -1
  98. package/dist/agents/middleware/piiRedaction.d.cts +0 -1
  99. package/dist/agents/middleware/piiRedaction.d.cts.map +1 -1
  100. package/dist/agents/middleware/piiRedaction.d.ts +0 -1
  101. package/dist/agents/middleware/piiRedaction.d.ts.map +1 -1
  102. package/dist/agents/middleware/piiRedaction.js +8 -14
  103. package/dist/agents/middleware/piiRedaction.js.map +1 -1
  104. package/dist/agents/middleware/provider/anthropic/promptCaching.cjs +5 -8
  105. package/dist/agents/middleware/provider/anthropic/promptCaching.cjs.map +1 -1
  106. package/dist/agents/middleware/provider/anthropic/promptCaching.d.cts +2 -2
  107. package/dist/agents/middleware/provider/anthropic/promptCaching.d.cts.map +1 -1
  108. package/dist/agents/middleware/provider/anthropic/promptCaching.d.ts +2 -2
  109. package/dist/agents/middleware/provider/anthropic/promptCaching.d.ts.map +1 -1
  110. package/dist/agents/middleware/provider/anthropic/promptCaching.js +3 -6
  111. package/dist/agents/middleware/provider/anthropic/promptCaching.js.map +1 -1
  112. package/dist/agents/middleware/provider/openai/moderation.cjs +17 -22
  113. package/dist/agents/middleware/provider/openai/moderation.cjs.map +1 -1
  114. package/dist/agents/middleware/provider/openai/moderation.d.cts +0 -2
  115. package/dist/agents/middleware/provider/openai/moderation.d.cts.map +1 -1
  116. package/dist/agents/middleware/provider/openai/moderation.d.ts +0 -2
  117. package/dist/agents/middleware/provider/openai/moderation.d.ts.map +1 -1
  118. package/dist/agents/middleware/provider/openai/moderation.js +10 -15
  119. package/dist/agents/middleware/provider/openai/moderation.js.map +1 -1
  120. package/dist/agents/middleware/summarization.cjs +39 -62
  121. package/dist/agents/middleware/summarization.cjs.map +1 -1
  122. package/dist/agents/middleware/summarization.d.cts +2 -2
  123. package/dist/agents/middleware/summarization.d.cts.map +1 -1
  124. package/dist/agents/middleware/summarization.d.ts +2 -2
  125. package/dist/agents/middleware/summarization.d.ts.map +1 -1
  126. package/dist/agents/middleware/summarization.js +17 -40
  127. package/dist/agents/middleware/summarization.js.map +1 -1
  128. package/dist/agents/middleware/todoListMiddleware.cjs +21 -27
  129. package/dist/agents/middleware/todoListMiddleware.cjs.map +1 -1
  130. package/dist/agents/middleware/todoListMiddleware.d.cts +4 -4
  131. package/dist/agents/middleware/todoListMiddleware.d.cts.map +1 -1
  132. package/dist/agents/middleware/todoListMiddleware.d.ts +4 -4
  133. package/dist/agents/middleware/todoListMiddleware.d.ts.map +1 -1
  134. package/dist/agents/middleware/todoListMiddleware.js +12 -18
  135. package/dist/agents/middleware/todoListMiddleware.js.map +1 -1
  136. package/dist/agents/middleware/toolCallLimit.cjs +24 -46
  137. package/dist/agents/middleware/toolCallLimit.cjs.map +1 -1
  138. package/dist/agents/middleware/toolCallLimit.d.cts +2 -3
  139. package/dist/agents/middleware/toolCallLimit.d.cts.map +1 -1
  140. package/dist/agents/middleware/toolCallLimit.d.ts +2 -3
  141. package/dist/agents/middleware/toolCallLimit.d.ts.map +1 -1
  142. package/dist/agents/middleware/toolCallLimit.js +17 -39
  143. package/dist/agents/middleware/toolCallLimit.js.map +1 -1
  144. package/dist/agents/middleware/toolEmulator.cjs +8 -13
  145. package/dist/agents/middleware/toolEmulator.cjs.map +1 -1
  146. package/dist/agents/middleware/toolEmulator.d.cts +0 -1
  147. package/dist/agents/middleware/toolEmulator.d.cts.map +1 -1
  148. package/dist/agents/middleware/toolEmulator.d.ts +0 -1
  149. package/dist/agents/middleware/toolEmulator.d.ts.map +1 -1
  150. package/dist/agents/middleware/toolEmulator.js +5 -10
  151. package/dist/agents/middleware/toolEmulator.js.map +1 -1
  152. package/dist/agents/middleware/toolRetry.cjs +19 -17
  153. package/dist/agents/middleware/toolRetry.cjs.map +1 -1
  154. package/dist/agents/middleware/toolRetry.d.cts +0 -1
  155. package/dist/agents/middleware/toolRetry.d.cts.map +1 -1
  156. package/dist/agents/middleware/toolRetry.d.ts +0 -1
  157. package/dist/agents/middleware/toolRetry.d.ts.map +1 -1
  158. package/dist/agents/middleware/toolRetry.js +15 -13
  159. package/dist/agents/middleware/toolRetry.js.map +1 -1
  160. package/dist/agents/middleware/types.cjs.map +1 -1
  161. package/dist/agents/middleware/types.d.cts +33 -33
  162. package/dist/agents/middleware/types.d.cts.map +1 -1
  163. package/dist/agents/middleware/types.d.ts +33 -33
  164. package/dist/agents/middleware/types.d.ts.map +1 -1
  165. package/dist/agents/middleware/types.js.map +1 -1
  166. package/dist/agents/middleware/utils.cjs +8 -8
  167. package/dist/agents/middleware/utils.cjs.map +1 -1
  168. package/dist/agents/middleware/utils.d.cts +0 -1
  169. package/dist/agents/middleware/utils.d.cts.map +1 -1
  170. package/dist/agents/middleware/utils.d.ts +0 -1
  171. package/dist/agents/middleware/utils.d.ts.map +1 -1
  172. package/dist/agents/middleware/utils.js +3 -3
  173. package/dist/agents/middleware/utils.js.map +1 -1
  174. package/dist/agents/middleware.cjs +1 -2
  175. package/dist/agents/middleware.cjs.map +1 -1
  176. package/dist/agents/middleware.d.cts +0 -1
  177. package/dist/agents/middleware.d.cts.map +1 -1
  178. package/dist/agents/middleware.d.ts +0 -1
  179. package/dist/agents/middleware.d.ts.map +1 -1
  180. package/dist/agents/middleware.js +1 -2
  181. package/dist/agents/middleware.js.map +1 -1
  182. package/dist/agents/model.cjs.map +1 -1
  183. package/dist/agents/model.js.map +1 -1
  184. package/dist/agents/nodes/AfterAgentNode.cjs +1 -2
  185. package/dist/agents/nodes/AfterAgentNode.cjs.map +1 -1
  186. package/dist/agents/nodes/AfterAgentNode.js +1 -2
  187. package/dist/agents/nodes/AfterAgentNode.js.map +1 -1
  188. package/dist/agents/nodes/AfterModelNode.cjs +1 -2
  189. package/dist/agents/nodes/AfterModelNode.cjs.map +1 -1
  190. package/dist/agents/nodes/AfterModelNode.js +1 -2
  191. package/dist/agents/nodes/AfterModelNode.js.map +1 -1
  192. package/dist/agents/nodes/AgentNode.cjs +46 -58
  193. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  194. package/dist/agents/nodes/AgentNode.js +16 -28
  195. package/dist/agents/nodes/AgentNode.js.map +1 -1
  196. package/dist/agents/nodes/BeforeAgentNode.cjs +1 -2
  197. package/dist/agents/nodes/BeforeAgentNode.cjs.map +1 -1
  198. package/dist/agents/nodes/BeforeAgentNode.js +1 -2
  199. package/dist/agents/nodes/BeforeAgentNode.js.map +1 -1
  200. package/dist/agents/nodes/BeforeModelNode.cjs +1 -2
  201. package/dist/agents/nodes/BeforeModelNode.cjs.map +1 -1
  202. package/dist/agents/nodes/BeforeModelNode.js +1 -2
  203. package/dist/agents/nodes/BeforeModelNode.js.map +1 -1
  204. package/dist/agents/nodes/ToolNode.cjs +25 -25
  205. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  206. package/dist/agents/nodes/ToolNode.js +6 -6
  207. package/dist/agents/nodes/ToolNode.js.map +1 -1
  208. package/dist/agents/nodes/middleware.cjs +3 -3
  209. package/dist/agents/nodes/middleware.cjs.map +1 -1
  210. package/dist/agents/nodes/middleware.js.map +1 -1
  211. package/dist/agents/nodes/types.d.cts +0 -1
  212. package/dist/agents/nodes/types.d.cts.map +1 -1
  213. package/dist/agents/nodes/types.d.ts +0 -1
  214. package/dist/agents/nodes/types.d.ts.map +1 -1
  215. package/dist/agents/nodes/utils.cjs +16 -17
  216. package/dist/agents/nodes/utils.cjs.map +1 -1
  217. package/dist/agents/nodes/utils.js +2 -3
  218. package/dist/agents/nodes/utils.js.map +1 -1
  219. package/dist/agents/responses.cjs +20 -30
  220. package/dist/agents/responses.cjs.map +1 -1
  221. package/dist/agents/responses.d.cts +0 -1
  222. package/dist/agents/responses.d.cts.map +1 -1
  223. package/dist/agents/responses.d.ts +0 -1
  224. package/dist/agents/responses.d.ts.map +1 -1
  225. package/dist/agents/responses.js +12 -22
  226. package/dist/agents/responses.js.map +1 -1
  227. package/dist/agents/runtime.d.cts +0 -1
  228. package/dist/agents/runtime.d.cts.map +1 -1
  229. package/dist/agents/runtime.d.ts +0 -1
  230. package/dist/agents/runtime.d.ts.map +1 -1
  231. package/dist/agents/state.cjs +1 -2
  232. package/dist/agents/state.cjs.map +1 -1
  233. package/dist/agents/state.js +1 -2
  234. package/dist/agents/state.js.map +1 -1
  235. package/dist/agents/tests/utils.cjs +21 -26
  236. package/dist/agents/tests/utils.cjs.map +1 -1
  237. package/dist/agents/tests/utils.d.cts +0 -1
  238. package/dist/agents/tests/utils.d.cts.map +1 -1
  239. package/dist/agents/tests/utils.d.ts +0 -1
  240. package/dist/agents/tests/utils.d.ts.map +1 -1
  241. package/dist/agents/tests/utils.js +12 -17
  242. package/dist/agents/tests/utils.js.map +1 -1
  243. package/dist/agents/types.d.cts +4 -5
  244. package/dist/agents/types.d.cts.map +1 -1
  245. package/dist/agents/types.d.ts +4 -5
  246. package/dist/agents/types.d.ts.map +1 -1
  247. package/dist/agents/utils.cjs +32 -32
  248. package/dist/agents/utils.cjs.map +1 -1
  249. package/dist/agents/utils.js +6 -6
  250. package/dist/agents/utils.js.map +1 -1
  251. package/dist/agents/withAgentName.cjs +5 -5
  252. package/dist/agents/withAgentName.cjs.map +1 -1
  253. package/dist/agents/withAgentName.js.map +1 -1
  254. package/dist/chat_models/universal.cjs +34 -41
  255. package/dist/chat_models/universal.cjs.map +1 -1
  256. package/dist/chat_models/universal.d.cts.map +1 -1
  257. package/dist/chat_models/universal.d.ts.map +1 -1
  258. package/dist/chat_models/universal.js +21 -29
  259. package/dist/chat_models/universal.js.map +1 -1
  260. package/dist/hub/base.cjs +3 -4
  261. package/dist/hub/base.cjs.map +1 -1
  262. package/dist/hub/base.d.cts +0 -1
  263. package/dist/hub/base.d.cts.map +1 -1
  264. package/dist/hub/base.d.ts +0 -1
  265. package/dist/hub/base.d.ts.map +1 -1
  266. package/dist/hub/base.js +1 -2
  267. package/dist/hub/base.js.map +1 -1
  268. package/dist/hub/index.cjs +2 -2
  269. package/dist/hub/index.cjs.map +1 -1
  270. package/dist/hub/index.d.cts +0 -1
  271. package/dist/hub/index.d.cts.map +1 -1
  272. package/dist/hub/index.d.ts +0 -1
  273. package/dist/hub/index.d.ts.map +1 -1
  274. package/dist/hub/index.js +1 -2
  275. package/dist/hub/index.js.map +1 -1
  276. package/dist/hub/node.cjs +7 -13
  277. package/dist/hub/node.cjs.map +1 -1
  278. package/dist/hub/node.d.cts +0 -1
  279. package/dist/hub/node.d.cts.map +1 -1
  280. package/dist/hub/node.d.ts +0 -1
  281. package/dist/hub/node.d.ts.map +1 -1
  282. package/dist/hub/node.js +6 -13
  283. package/dist/hub/node.js.map +1 -1
  284. package/dist/index.cjs +48 -48
  285. package/dist/index.d.cts +2 -1
  286. package/dist/index.d.ts +2 -1
  287. package/dist/index.js +2 -3
  288. package/dist/load/import_constants.cjs.map +1 -1
  289. package/dist/load/import_constants.js.map +1 -1
  290. package/dist/load/import_map.cjs +46 -47
  291. package/dist/load/import_map.cjs.map +1 -1
  292. package/dist/load/import_map.js +2 -3
  293. package/dist/load/import_map.js.map +1 -1
  294. package/dist/load/import_type.d.cts.map +1 -1
  295. package/dist/load/import_type.d.ts.map +1 -1
  296. package/dist/load/index.cjs +13 -3
  297. package/dist/load/index.cjs.map +1 -1
  298. package/dist/load/index.d.cts +9 -1
  299. package/dist/load/index.d.cts.map +1 -1
  300. package/dist/load/index.d.ts +9 -1
  301. package/dist/load/index.d.ts.map +1 -1
  302. package/dist/load/index.js +9 -0
  303. package/dist/load/index.js.map +1 -1
  304. package/dist/load/serializable.cjs +7 -6
  305. package/dist/load/serializable.js +4 -4
  306. package/dist/storage/encoder_backed.cjs +9 -10
  307. package/dist/storage/encoder_backed.cjs.map +1 -1
  308. package/dist/storage/encoder_backed.d.cts +0 -1
  309. package/dist/storage/encoder_backed.d.cts.map +1 -1
  310. package/dist/storage/encoder_backed.d.ts +0 -1
  311. package/dist/storage/encoder_backed.d.ts.map +1 -1
  312. package/dist/storage/encoder_backed.js +4 -6
  313. package/dist/storage/encoder_backed.js.map +1 -1
  314. package/dist/storage/file_system.cjs +12 -11
  315. package/dist/storage/file_system.cjs.map +1 -1
  316. package/dist/storage/file_system.d.cts +0 -1
  317. package/dist/storage/file_system.d.cts.map +1 -1
  318. package/dist/storage/file_system.d.ts +0 -1
  319. package/dist/storage/file_system.d.ts.map +1 -1
  320. package/dist/storage/file_system.js +5 -7
  321. package/dist/storage/file_system.js.map +1 -1
  322. package/dist/storage/in_memory.cjs +5 -5
  323. package/dist/storage/in_memory.js +2 -3
  324. package/package.json +6 -6
  325. package/dist/_virtual/rolldown_runtime.js +0 -25
@@ -1,11 +1,19 @@
1
1
  import { OptionalImportMap } from "./import_type.js";
2
2
 
3
3
  //#region src/load/index.d.ts
4
-
5
4
  /**
6
5
  * Load a LangChain module from a serialized text representation.
7
6
  * NOTE: This functionality is currently in beta.
8
7
  * Loaded classes may change independently of semver.
8
+ *
9
+ * **WARNING — insecure deserialization risk.** This function instantiates
10
+ * classes and invokes constructors based on the contents of `text`. Never
11
+ * call this on untrusted or user-supplied input. Only deserialize data that
12
+ * originates from a trusted source you control.
13
+ *
14
+ * See `@langchain/core/load` {@link LoadOptions} for detailed security
15
+ * guidance on `secretsFromEnv`, `secretsMap`, and import maps.
16
+ *
9
17
  * @param text Serialized text representation of the module.
10
18
  * @param secretsMap
11
19
  * @param optionalImportsMap
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["OptionalImportMap","load","T","Record","Promise"],"sources":["../../src/load/index.d.ts"],"sourcesContent":["import { OptionalImportMap } from \"./import_type.js\";\n/**\n * Load a LangChain module from a serialized text representation.\n * NOTE: This functionality is currently in beta.\n * Loaded classes may change independently of semver.\n * @param text Serialized text representation of the module.\n * @param secretsMap\n * @param optionalImportsMap\n * @param additionalImportsMap\n * @param secretsFromEnv\n * @returns A loaded instance of a LangChain module.\n */\nexport declare function load<T>(text: string, secretsMap?: Record<string, any>, optionalImportsMap?: OptionalImportMap & Record<string, any>, additionalImportsMap?: Record<string, any>, secretsFromEnv?: boolean): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;AAYA;;;;;;;AAA4N;;iBAApMC,mCAAmCE,0CAA0CH,oBAAoBG,4CAA4CA,gDAAgDC,QAAQF"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/load/index.ts"],"mappings":";;;;;AAyBA;;;;;;;;;;;;;;;;;;iBAAsB,IAAA,GAAA,CACpB,IAAA,UAEA,UAAA,GAAY,MAAA,eAEZ,kBAAA,GAAoB,iBAAA,GAAoB,MAAA,eAExC,oBAAA,GAAsB,MAAA,eACtB,cAAA,aACC,OAAA,CAAQ,CAAA"}
@@ -7,6 +7,15 @@ import { load as load$1 } from "@langchain/core/load";
7
7
  * Load a LangChain module from a serialized text representation.
8
8
  * NOTE: This functionality is currently in beta.
9
9
  * Loaded classes may change independently of semver.
10
+ *
11
+ * **WARNING — insecure deserialization risk.** This function instantiates
12
+ * classes and invokes constructors based on the contents of `text`. Never
13
+ * call this on untrusted or user-supplied input. Only deserialize data that
14
+ * originates from a trusted source you control.
15
+ *
16
+ * See `@langchain/core/load` {@link LoadOptions} for detailed security
17
+ * guidance on `secretsFromEnv`, `secretsMap`, and import maps.
18
+ *
10
19
  * @param text Serialized text representation of the module.
11
20
  * @param secretsMap
12
21
  * @param optionalImportsMap
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["text: string","secretsMap: Record<string, any>","optionalImportsMap: OptionalImportMap & Record<string, any>","additionalImportsMap: Record<string, any>","secretsFromEnv?: boolean","coreLoad","importMap"],"sources":["../../src/load/index.ts"],"sourcesContent":["import { load as coreLoad } from \"@langchain/core/load\";\nimport { optionalImportEntrypoints } from \"./import_constants.js\";\nimport * as importMap from \"./import_map.js\";\nimport { OptionalImportMap } from \"./import_type.js\";\n\n/**\n * Load a LangChain module from a serialized text representation.\n * NOTE: This functionality is currently in beta.\n * Loaded classes may change independently of semver.\n * @param text Serialized text representation of the module.\n * @param secretsMap\n * @param optionalImportsMap\n * @param additionalImportsMap\n * @param secretsFromEnv\n * @returns A loaded instance of a LangChain module.\n */\nexport async function load<T>(\n text: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n secretsMap: Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n optionalImportsMap: OptionalImportMap & Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n additionalImportsMap: Record<string, any> = {},\n secretsFromEnv?: boolean\n): Promise<T> {\n return coreLoad(text, {\n secretsMap,\n optionalImportsMap,\n optionalImportEntrypoints,\n importMap: { ...importMap, ...additionalImportsMap },\n secretsFromEnv,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,eAAsB,KACpBA,MAEAC,aAAkC,CAAE,GAEpCC,qBAA8D,CAAE,GAEhEC,uBAA4C,CAAE,GAC9CC,gBACY;AACZ,QAAOC,OAAS,MAAM;EACpB;EACA;EACA;EACA,WAAW;GAAE,GAAGC;GAAW,GAAG;EAAsB;EACpD;CACD,EAAC;AACH"}
1
+ {"version":3,"file":"index.js","names":["coreLoad","importMap"],"sources":["../../src/load/index.ts"],"sourcesContent":["import { load as coreLoad } from \"@langchain/core/load\";\nimport { optionalImportEntrypoints } from \"./import_constants.js\";\nimport * as importMap from \"./import_map.js\";\nimport { OptionalImportMap } from \"./import_type.js\";\n\n/**\n * Load a LangChain module from a serialized text representation.\n * NOTE: This functionality is currently in beta.\n * Loaded classes may change independently of semver.\n *\n * **WARNING — insecure deserialization risk.** This function instantiates\n * classes and invokes constructors based on the contents of `text`. Never\n * call this on untrusted or user-supplied input. Only deserialize data that\n * originates from a trusted source you control.\n *\n * See `@langchain/core/load` {@link LoadOptions} for detailed security\n * guidance on `secretsFromEnv`, `secretsMap`, and import maps.\n *\n * @param text Serialized text representation of the module.\n * @param secretsMap\n * @param optionalImportsMap\n * @param additionalImportsMap\n * @param secretsFromEnv\n * @returns A loaded instance of a LangChain module.\n */\nexport async function load<T>(\n text: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n secretsMap: Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n optionalImportsMap: OptionalImportMap & Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n additionalImportsMap: Record<string, any> = {},\n secretsFromEnv?: boolean\n): Promise<T> {\n return coreLoad(text, {\n secretsMap,\n optionalImportsMap,\n optionalImportEntrypoints,\n importMap: { ...importMap, ...additionalImportsMap },\n secretsFromEnv,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,eAAsB,KACpB,MAEA,aAAkC,EAAE,EAEpC,qBAA8D,EAAE,EAEhE,uBAA4C,EAAE,EAC9C,gBACY;AACZ,QAAOA,OAAS,MAAM;EACpB;EACA;EACA;EACA,WAAW;GAAE,GAAGC;GAAW,GAAG;GAAsB;EACpD;EACD,CAAC"}
@@ -1,8 +1,9 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
 
3
4
  //#region src/load/serializable.ts
4
- var serializable_exports = {};
5
- require_rolldown_runtime.__reExport(serializable_exports, require("@langchain/core/load/serializable"));
5
+ var serializable_exports = /* @__PURE__ */ require_runtime.__exportAll({});
6
+ require_runtime.__reExport(serializable_exports, require("@langchain/core/load/serializable"));
6
7
 
7
8
  //#endregion
8
9
  Object.defineProperty(exports, 'serializable_exports', {
@@ -11,11 +12,11 @@ Object.defineProperty(exports, 'serializable_exports', {
11
12
  return serializable_exports;
12
13
  }
13
14
  });
14
- var __langchain_core_load_serializable = require("@langchain/core/load/serializable");
15
- Object.keys(__langchain_core_load_serializable).forEach(function (k) {
15
+ var _langchain_core_load_serializable = require("@langchain/core/load/serializable");
16
+ Object.keys(_langchain_core_load_serializable).forEach(function (k) {
16
17
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
17
18
  enumerable: true,
18
- get: function () { return __langchain_core_load_serializable[k]; }
19
+ get: function () { return _langchain_core_load_serializable[k]; }
19
20
  });
20
21
  });
21
22
 
@@ -1,11 +1,11 @@
1
- import { __reExport } from "../_virtual/rolldown_runtime.js";
1
+ import { __exportAll, __reExport } from "../_virtual/_rolldown/runtime.js";
2
2
 
3
3
  export * from "@langchain/core/load/serializable"
4
4
 
5
5
  //#region src/load/serializable.ts
6
- var serializable_exports = {};
7
- import * as import___langchain_core_load_serializable from "@langchain/core/load/serializable";
8
- __reExport(serializable_exports, import___langchain_core_load_serializable);
6
+ var serializable_exports = /* @__PURE__ */ __exportAll({});
7
+ import * as import__langchain_core_load_serializable from "@langchain/core/load/serializable";
8
+ __reExport(serializable_exports, import__langchain_core_load_serializable);
9
9
 
10
10
  //#endregion
11
11
  export { serializable_exports };
@@ -1,10 +1,10 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const __langchain_core_stores = require_rolldown_runtime.__toESM(require("@langchain/core/stores"));
3
- const __langchain_core_documents = require_rolldown_runtime.__toESM(require("@langchain/core/documents"));
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _langchain_core_stores = require("@langchain/core/stores");
4
+ let _langchain_core_documents = require("@langchain/core/documents");
4
5
 
5
6
  //#region src/storage/encoder_backed.ts
6
- var encoder_backed_exports = {};
7
- require_rolldown_runtime.__export(encoder_backed_exports, {
7
+ var encoder_backed_exports = /* @__PURE__ */ require_runtime.__exportAll({
8
8
  EncoderBackedStore: () => EncoderBackedStore,
9
9
  createDocumentStoreFromByteStore: () => createDocumentStoreFromByteStore
10
10
  });
@@ -13,7 +13,7 @@ require_rolldown_runtime.__export(encoder_backed_exports, {
13
13
  * allowing for the encoding and decoding of keys and values. It extends
14
14
  * the BaseStore class.
15
15
  */
16
- var EncoderBackedStore = class extends __langchain_core_stores.BaseStore {
16
+ var EncoderBackedStore = class extends _langchain_core_stores.BaseStore {
17
17
  lc_namespace = ["langchain", "storage"];
18
18
  store;
19
19
  keyEncoder;
@@ -34,9 +34,8 @@ var EncoderBackedStore = class extends __langchain_core_stores.BaseStore {
34
34
  */
35
35
  async mget(keys) {
36
36
  const encodedKeys = keys.map(this.keyEncoder);
37
- const values = await this.store.mget(encodedKeys);
38
- return values.map((value) => {
39
- if (value === void 0) return void 0;
37
+ return (await this.store.mget(encodedKeys)).map((value) => {
38
+ if (value === void 0) return;
40
39
  return this.valueDeserializer(value);
41
40
  });
42
41
  }
@@ -78,7 +77,7 @@ function createDocumentStoreFromByteStore(store) {
78
77
  pageContent: doc.pageContent,
79
78
  metadata: doc.metadata
80
79
  })),
81
- valueDeserializer: (bytes) => new __langchain_core_documents.Document(JSON.parse(decoder.decode(bytes)))
80
+ valueDeserializer: (bytes) => new _langchain_core_documents.Document(JSON.parse(decoder.decode(bytes)))
82
81
  });
83
82
  }
84
83
 
@@ -1 +1 @@
1
- {"version":3,"file":"encoder_backed.cjs","names":["BaseStore","fields: {\n store: BaseStore<string, SerializedType>;\n keyEncoder: (key: K) => string;\n valueSerializer: (value: V) => SerializedType;\n valueDeserializer: (value: SerializedType) => V;\n }","keys: K[]","keyValuePairs: [K, V][]","encodedPairs: [string, SerializedType][]","prefix?: string | undefined","store: BaseStore<string, Uint8Array>","key: string","doc: Document","bytes: Uint8Array","Document"],"sources":["../../src/storage/encoder_backed.ts"],"sourcesContent":["import { Document } from \"@langchain/core/documents\";\nimport { BaseStore } from \"@langchain/core/stores\";\n\n/**\n * Class that provides a layer of abstraction over the base storage,\n * allowing for the encoding and decoding of keys and values. It extends\n * the BaseStore class.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class EncoderBackedStore<K, V, SerializedType = any> extends BaseStore<\n K,\n V\n> {\n lc_namespace = [\"langchain\", \"storage\"];\n\n store: BaseStore<string, SerializedType>;\n\n keyEncoder: (key: K) => string;\n\n valueSerializer: (value: V) => SerializedType;\n\n valueDeserializer: (value: SerializedType) => V;\n\n constructor(fields: {\n store: BaseStore<string, SerializedType>;\n keyEncoder: (key: K) => string;\n valueSerializer: (value: V) => SerializedType;\n valueDeserializer: (value: SerializedType) => V;\n }) {\n super(fields);\n this.store = fields.store;\n this.keyEncoder = fields.keyEncoder;\n this.valueSerializer = fields.valueSerializer;\n this.valueDeserializer = fields.valueDeserializer;\n }\n\n /**\n * Method to get multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keys Array of keys to get\n * @returns Promise that resolves with an array of values or undefined for each key\n */\n async mget(keys: K[]): Promise<(V | undefined)[]> {\n const encodedKeys = keys.map(this.keyEncoder);\n const values = await this.store.mget(encodedKeys);\n return values.map((value) => {\n if (value === undefined) {\n return undefined;\n }\n return this.valueDeserializer(value);\n });\n }\n\n /**\n * Method to set multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keyValuePairs Array of key-value pairs to set\n * @returns Promise that resolves when the operation is complete\n */\n async mset(keyValuePairs: [K, V][]): Promise<void> {\n const encodedPairs: [string, SerializedType][] = keyValuePairs.map(\n ([key, value]) => [this.keyEncoder(key), this.valueSerializer(value)]\n );\n return this.store.mset(encodedPairs);\n }\n\n /**\n * Method to delete multiple keys at once. It works with the encoded keys.\n * @param keys Array of keys to delete\n * @returns Promise that resolves when the operation is complete\n */\n async mdelete(keys: K[]): Promise<void> {\n const encodedKeys = keys.map(this.keyEncoder);\n return this.store.mdelete(encodedKeys);\n }\n\n /**\n * Method to yield keys. It works with the encoded keys.\n * @param prefix Optional prefix to filter keys\n * @returns AsyncGenerator that yields keys\n */\n async *yieldKeys(prefix?: string | undefined): AsyncGenerator<string | K> {\n yield* this.store.yieldKeys(prefix);\n }\n}\n\nexport function createDocumentStoreFromByteStore(\n store: BaseStore<string, Uint8Array>\n) {\n const encoder = new TextEncoder();\n const decoder = new TextDecoder();\n return new EncoderBackedStore({\n store,\n keyEncoder: (key: string) => key,\n valueSerializer: (doc: Document) =>\n encoder.encode(\n JSON.stringify({ pageContent: doc.pageContent, metadata: doc.metadata })\n ),\n valueDeserializer: (bytes: Uint8Array) =>\n new Document(JSON.parse(decoder.decode(bytes))),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AASA,IAAa,qBAAb,cAAoEA,kCAGlE;CACA,eAAe,CAAC,aAAa,SAAU;CAEvC;CAEA;CAEA;CAEA;CAEA,YAAYC,QAKT;EACD,MAAM,OAAO;EACb,KAAK,QAAQ,OAAO;EACpB,KAAK,aAAa,OAAO;EACzB,KAAK,kBAAkB,OAAO;EAC9B,KAAK,oBAAoB,OAAO;CACjC;;;;;;;CAQD,MAAM,KAAKC,MAAuC;EAChD,MAAM,cAAc,KAAK,IAAI,KAAK,WAAW;EAC7C,MAAM,SAAS,MAAM,KAAK,MAAM,KAAK,YAAY;AACjD,SAAO,OAAO,IAAI,CAAC,UAAU;AAC3B,OAAI,UAAU,OACZ,QAAO;AAET,UAAO,KAAK,kBAAkB,MAAM;EACrC,EAAC;CACH;;;;;;;CAQD,MAAM,KAAKC,eAAwC;EACjD,MAAMC,eAA2C,cAAc,IAC7D,CAAC,CAAC,KAAK,MAAM,KAAK,CAAC,KAAK,WAAW,IAAI,EAAE,KAAK,gBAAgB,MAAM,AAAC,EACtE;AACD,SAAO,KAAK,MAAM,KAAK,aAAa;CACrC;;;;;;CAOD,MAAM,QAAQF,MAA0B;EACtC,MAAM,cAAc,KAAK,IAAI,KAAK,WAAW;AAC7C,SAAO,KAAK,MAAM,QAAQ,YAAY;CACvC;;;;;;CAOD,OAAO,UAAUG,QAAyD;EACxE,OAAO,KAAK,MAAM,UAAU,OAAO;CACpC;AACF;AAED,SAAgB,iCACdC,OACA;CACA,MAAM,UAAU,IAAI;CACpB,MAAM,UAAU,IAAI;AACpB,QAAO,IAAI,mBAAmB;EAC5B;EACA,YAAY,CAACC,QAAgB;EAC7B,iBAAiB,CAACC,QAChB,QAAQ,OACN,KAAK,UAAU;GAAE,aAAa,IAAI;GAAa,UAAU,IAAI;EAAU,EAAC,CACzE;EACH,mBAAmB,CAACC,UAClB,IAAIC,oCAAS,KAAK,MAAM,QAAQ,OAAO,MAAM,CAAC;CACjD;AACF"}
1
+ {"version":3,"file":"encoder_backed.cjs","names":["BaseStore","Document"],"sources":["../../src/storage/encoder_backed.ts"],"sourcesContent":["import { Document } from \"@langchain/core/documents\";\nimport { BaseStore } from \"@langchain/core/stores\";\n\n/**\n * Class that provides a layer of abstraction over the base storage,\n * allowing for the encoding and decoding of keys and values. It extends\n * the BaseStore class.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class EncoderBackedStore<K, V, SerializedType = any> extends BaseStore<\n K,\n V\n> {\n lc_namespace = [\"langchain\", \"storage\"];\n\n store: BaseStore<string, SerializedType>;\n\n keyEncoder: (key: K) => string;\n\n valueSerializer: (value: V) => SerializedType;\n\n valueDeserializer: (value: SerializedType) => V;\n\n constructor(fields: {\n store: BaseStore<string, SerializedType>;\n keyEncoder: (key: K) => string;\n valueSerializer: (value: V) => SerializedType;\n valueDeserializer: (value: SerializedType) => V;\n }) {\n super(fields);\n this.store = fields.store;\n this.keyEncoder = fields.keyEncoder;\n this.valueSerializer = fields.valueSerializer;\n this.valueDeserializer = fields.valueDeserializer;\n }\n\n /**\n * Method to get multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keys Array of keys to get\n * @returns Promise that resolves with an array of values or undefined for each key\n */\n async mget(keys: K[]): Promise<(V | undefined)[]> {\n const encodedKeys = keys.map(this.keyEncoder);\n const values = await this.store.mget(encodedKeys);\n return values.map((value) => {\n if (value === undefined) {\n return undefined;\n }\n return this.valueDeserializer(value);\n });\n }\n\n /**\n * Method to set multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keyValuePairs Array of key-value pairs to set\n * @returns Promise that resolves when the operation is complete\n */\n async mset(keyValuePairs: [K, V][]): Promise<void> {\n const encodedPairs: [string, SerializedType][] = keyValuePairs.map(\n ([key, value]) => [this.keyEncoder(key), this.valueSerializer(value)]\n );\n return this.store.mset(encodedPairs);\n }\n\n /**\n * Method to delete multiple keys at once. It works with the encoded keys.\n * @param keys Array of keys to delete\n * @returns Promise that resolves when the operation is complete\n */\n async mdelete(keys: K[]): Promise<void> {\n const encodedKeys = keys.map(this.keyEncoder);\n return this.store.mdelete(encodedKeys);\n }\n\n /**\n * Method to yield keys. It works with the encoded keys.\n * @param prefix Optional prefix to filter keys\n * @returns AsyncGenerator that yields keys\n */\n async *yieldKeys(prefix?: string | undefined): AsyncGenerator<string | K> {\n yield* this.store.yieldKeys(prefix);\n }\n}\n\nexport function createDocumentStoreFromByteStore(\n store: BaseStore<string, Uint8Array>\n) {\n const encoder = new TextEncoder();\n const decoder = new TextDecoder();\n return new EncoderBackedStore({\n store,\n keyEncoder: (key: string) => key,\n valueSerializer: (doc: Document) =>\n encoder.encode(\n JSON.stringify({ pageContent: doc.pageContent, metadata: doc.metadata })\n ),\n valueDeserializer: (bytes: Uint8Array) =>\n new Document(JSON.parse(decoder.decode(bytes))),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AASA,IAAa,qBAAb,cAAoEA,iCAGlE;CACA,eAAe,CAAC,aAAa,UAAU;CAEvC;CAEA;CAEA;CAEA;CAEA,YAAY,QAKT;AACD,QAAM,OAAO;AACb,OAAK,QAAQ,OAAO;AACpB,OAAK,aAAa,OAAO;AACzB,OAAK,kBAAkB,OAAO;AAC9B,OAAK,oBAAoB,OAAO;;;;;;;;CASlC,MAAM,KAAK,MAAuC;EAChD,MAAM,cAAc,KAAK,IAAI,KAAK,WAAW;AAE7C,UADe,MAAM,KAAK,MAAM,KAAK,YAAY,EACnC,KAAK,UAAU;AAC3B,OAAI,UAAU,OACZ;AAEF,UAAO,KAAK,kBAAkB,MAAM;IACpC;;;;;;;;CASJ,MAAM,KAAK,eAAwC;EACjD,MAAM,eAA2C,cAAc,KAC5D,CAAC,KAAK,WAAW,CAAC,KAAK,WAAW,IAAI,EAAE,KAAK,gBAAgB,MAAM,CAAC,CACtE;AACD,SAAO,KAAK,MAAM,KAAK,aAAa;;;;;;;CAQtC,MAAM,QAAQ,MAA0B;EACtC,MAAM,cAAc,KAAK,IAAI,KAAK,WAAW;AAC7C,SAAO,KAAK,MAAM,QAAQ,YAAY;;;;;;;CAQxC,OAAO,UAAU,QAAyD;AACxE,SAAO,KAAK,MAAM,UAAU,OAAO;;;AAIvC,SAAgB,iCACd,OACA;CACA,MAAM,UAAU,IAAI,aAAa;CACjC,MAAM,UAAU,IAAI,aAAa;AACjC,QAAO,IAAI,mBAAmB;EAC5B;EACA,aAAa,QAAgB;EAC7B,kBAAkB,QAChB,QAAQ,OACN,KAAK,UAAU;GAAE,aAAa,IAAI;GAAa,UAAU,IAAI;GAAU,CAAC,CACzE;EACH,oBAAoB,UAClB,IAAIC,mCAAS,KAAK,MAAM,QAAQ,OAAO,MAAM,CAAC,CAAC;EAClD,CAAC"}
@@ -2,7 +2,6 @@ import { BaseStore } from "@langchain/core/stores";
2
2
  import { Document } from "@langchain/core/documents";
3
3
 
4
4
  //#region src/storage/encoder_backed.d.ts
5
-
6
5
  /**
7
6
  * Class that provides a layer of abstraction over the base storage,
8
7
  * allowing for the encoding and decoding of keys and values. It extends
@@ -1 +1 @@
1
- {"version":3,"file":"encoder_backed.d.cts","names":["Document","BaseStore","EncoderBackedStore","K","V","SerializedType","Promise","AsyncGenerator","createDocumentStoreFromByteStore","Uint8Array","Record","ArrayBufferLike"],"sources":["../../src/storage/encoder_backed.d.ts"],"sourcesContent":["import { Document } from \"@langchain/core/documents\";\nimport { BaseStore } from \"@langchain/core/stores\";\n/**\n * Class that provides a layer of abstraction over the base storage,\n * allowing for the encoding and decoding of keys and values. It extends\n * the BaseStore class.\n */\nexport declare class EncoderBackedStore<K, V, SerializedType = any> extends BaseStore<K, V> {\n lc_namespace: string[];\n store: BaseStore<string, SerializedType>;\n keyEncoder: (key: K) => string;\n valueSerializer: (value: V) => SerializedType;\n valueDeserializer: (value: SerializedType) => V;\n constructor(fields: {\n store: BaseStore<string, SerializedType>;\n keyEncoder: (key: K) => string;\n valueSerializer: (value: V) => SerializedType;\n valueDeserializer: (value: SerializedType) => V;\n });\n /**\n * Method to get multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keys Array of keys to get\n * @returns Promise that resolves with an array of values or undefined for each key\n */\n mget(keys: K[]): Promise<(V | undefined)[]>;\n /**\n * Method to set multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keyValuePairs Array of key-value pairs to set\n * @returns Promise that resolves when the operation is complete\n */\n mset(keyValuePairs: [K, V][]): Promise<void>;\n /**\n * Method to delete multiple keys at once. It works with the encoded keys.\n * @param keys Array of keys to delete\n * @returns Promise that resolves when the operation is complete\n */\n mdelete(keys: K[]): Promise<void>;\n /**\n * Method to yield keys. It works with the encoded keys.\n * @param prefix Optional prefix to filter keys\n * @returns AsyncGenerator that yields keys\n */\n yieldKeys(prefix?: string | undefined): AsyncGenerator<string | K>;\n}\nexport declare function createDocumentStoreFromByteStore(store: BaseStore<string, Uint8Array>): EncoderBackedStore<string, Document<Record<string, any>>, Uint8Array<ArrayBufferLike>>;\n//# sourceMappingURL=encoder_backed.d.ts.map"],"mappings":";;;;;;;AAOA;;;AAE6BK,cAFRH,kBAEQG,CAAAA,CAAAA,EAAAA,CAAAA,EAAAA,iBAAAA,GAAAA,CAAAA,SAF+CJ,SAE/CI,CAFyDF,CAEzDE,EAF4DD,CAE5DC,CAAAA,CAAAA;EAAlBJ,YAAAA,EAAAA,MAAAA,EAAAA;EACWE,KAAAA,EADXF,SACWE,CAAAA,MAAAA,EADOE,cACPF,CAAAA;EACOC,UAAAA,EAAAA,CAAAA,GAAAA,EADPD,CACOC,EAAAA,GAAAA,MAAAA;EAAMC,eAAAA,EAAAA,CAAAA,KAAAA,EAAND,CAAMC,EAAAA,GAAAA,cAAAA;EACJA,iBAAAA,EAAAA,CAAAA,KAAAA,EAAAA,cAAAA,EAAAA,GAAmBD,CAAnBC;EAAmBD,WAAAA,CAAAA,MAAAA,EAAAA;IAEjBC,KAAAA,EAAlBJ,SAAkBI,CAAAA,MAAAA,EAAAA,cAAAA,CAAAA;IAAlBJ,UAAAA,EAAAA,CAAAA,GAAAA,EACWE,CADXF,EAAAA,GAAAA,MAAAA;IACWE,eAAAA,EAAAA,CAAAA,KAAAA,EACOC,CADPD,EAAAA,GACaE,cADbF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AAA,GAAgB,CAAA,EAAG,CAAA,MAAO,OAAA;EAlD6B;;;;;EA8D5D,OAAA,CAAQ,IAAA,EAAM,CAAA,KAAM,OAAA;EA9DwC;;;;;EAwE3D,SAAA,CAAU,MAAA,wBAA8B,cAAA,UAAwB,CAAA;AAAA;AAAA,iBAKzD,gCAAA,CACd,KAAA,EAAO,SAAA,SAAkB,UAAA,IAAW,kBAAA,SAAA,QAAA,CAAA,MAAA,gBAAA,UAAA,CAAA,eAAA"}
@@ -2,7 +2,6 @@ import { BaseStore } from "@langchain/core/stores";
2
2
  import { Document } from "@langchain/core/documents";
3
3
 
4
4
  //#region src/storage/encoder_backed.d.ts
5
-
6
5
  /**
7
6
  * Class that provides a layer of abstraction over the base storage,
8
7
  * allowing for the encoding and decoding of keys and values. It extends
@@ -1 +1 @@
1
- {"version":3,"file":"encoder_backed.d.ts","names":["Document","BaseStore","EncoderBackedStore","K","V","SerializedType","Promise","AsyncGenerator","createDocumentStoreFromByteStore","Uint8Array","Record","ArrayBufferLike"],"sources":["../../src/storage/encoder_backed.d.ts"],"sourcesContent":["import { Document } from \"@langchain/core/documents\";\nimport { BaseStore } from \"@langchain/core/stores\";\n/**\n * Class that provides a layer of abstraction over the base storage,\n * allowing for the encoding and decoding of keys and values. It extends\n * the BaseStore class.\n */\nexport declare class EncoderBackedStore<K, V, SerializedType = any> extends BaseStore<K, V> {\n lc_namespace: string[];\n store: BaseStore<string, SerializedType>;\n keyEncoder: (key: K) => string;\n valueSerializer: (value: V) => SerializedType;\n valueDeserializer: (value: SerializedType) => V;\n constructor(fields: {\n store: BaseStore<string, SerializedType>;\n keyEncoder: (key: K) => string;\n valueSerializer: (value: V) => SerializedType;\n valueDeserializer: (value: SerializedType) => V;\n });\n /**\n * Method to get multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keys Array of keys to get\n * @returns Promise that resolves with an array of values or undefined for each key\n */\n mget(keys: K[]): Promise<(V | undefined)[]>;\n /**\n * Method to set multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keyValuePairs Array of key-value pairs to set\n * @returns Promise that resolves when the operation is complete\n */\n mset(keyValuePairs: [K, V][]): Promise<void>;\n /**\n * Method to delete multiple keys at once. It works with the encoded keys.\n * @param keys Array of keys to delete\n * @returns Promise that resolves when the operation is complete\n */\n mdelete(keys: K[]): Promise<void>;\n /**\n * Method to yield keys. It works with the encoded keys.\n * @param prefix Optional prefix to filter keys\n * @returns AsyncGenerator that yields keys\n */\n yieldKeys(prefix?: string | undefined): AsyncGenerator<string | K>;\n}\nexport declare function createDocumentStoreFromByteStore(store: BaseStore<string, Uint8Array>): EncoderBackedStore<string, Document<Record<string, any>>, Uint8Array<ArrayBufferLike>>;\n//# sourceMappingURL=encoder_backed.d.ts.map"],"mappings":";;;;;;;AAOA;;;AAE6BK,cAFRH,kBAEQG,CAAAA,CAAAA,EAAAA,CAAAA,EAAAA,iBAAAA,GAAAA,CAAAA,SAF+CJ,SAE/CI,CAFyDF,CAEzDE,EAF4DD,CAE5DC,CAAAA,CAAAA;EAAlBJ,YAAAA,EAAAA,MAAAA,EAAAA;EACWE,KAAAA,EADXF,SACWE,CAAAA,MAAAA,EADOE,cACPF,CAAAA;EACOC,UAAAA,EAAAA,CAAAA,GAAAA,EADPD,CACOC,EAAAA,GAAAA,MAAAA;EAAMC,eAAAA,EAAAA,CAAAA,KAAAA,EAAND,CAAMC,EAAAA,GAAAA,cAAAA;EACJA,iBAAAA,EAAAA,CAAAA,KAAAA,EAAAA,cAAAA,EAAAA,GAAmBD,CAAnBC;EAAmBD,WAAAA,CAAAA,MAAAA,EAAAA;IAEjBC,KAAAA,EAAlBJ,SAAkBI,CAAAA,MAAAA,EAAAA,cAAAA,CAAAA;IAAlBJ,UAAAA,EAAAA,CAAAA,GAAAA,EACWE,CADXF,EAAAA,GAAAA,MAAAA;IACWE,eAAAA,EAAAA,CAAAA,KAAAA,EACOC,CADPD,EAAAA,GACaE,cADbF;IACOC,iBAAAA,EAAAA,CAAAA,KAAAA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OAAA;EAlD6B;;;;;EA8D5D,OAAA,CAAQ,IAAA,EAAM,CAAA,KAAM,OAAA;EA9DwC;;;;;EAwE3D,SAAA,CAAU,MAAA,wBAA8B,cAAA,UAAwB,CAAA;AAAA;AAAA,iBAKzD,gCAAA,CACd,KAAA,EAAO,SAAA,SAAkB,UAAA,IAAW,kBAAA,SAAA,QAAA,CAAA,MAAA,gBAAA,UAAA,CAAA,eAAA"}
@@ -1,10 +1,9 @@
1
- import { __export } from "../_virtual/rolldown_runtime.js";
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
2
  import { BaseStore } from "@langchain/core/stores";
3
3
  import { Document } from "@langchain/core/documents";
4
4
 
5
5
  //#region src/storage/encoder_backed.ts
6
- var encoder_backed_exports = {};
7
- __export(encoder_backed_exports, {
6
+ var encoder_backed_exports = /* @__PURE__ */ __exportAll({
8
7
  EncoderBackedStore: () => EncoderBackedStore,
9
8
  createDocumentStoreFromByteStore: () => createDocumentStoreFromByteStore
10
9
  });
@@ -34,9 +33,8 @@ var EncoderBackedStore = class extends BaseStore {
34
33
  */
35
34
  async mget(keys) {
36
35
  const encodedKeys = keys.map(this.keyEncoder);
37
- const values = await this.store.mget(encodedKeys);
38
- return values.map((value) => {
39
- if (value === void 0) return void 0;
36
+ return (await this.store.mget(encodedKeys)).map((value) => {
37
+ if (value === void 0) return;
40
38
  return this.valueDeserializer(value);
41
39
  });
42
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"encoder_backed.js","names":["fields: {\n store: BaseStore<string, SerializedType>;\n keyEncoder: (key: K) => string;\n valueSerializer: (value: V) => SerializedType;\n valueDeserializer: (value: SerializedType) => V;\n }","keys: K[]","keyValuePairs: [K, V][]","encodedPairs: [string, SerializedType][]","prefix?: string | undefined","store: BaseStore<string, Uint8Array>","key: string","doc: Document","bytes: Uint8Array"],"sources":["../../src/storage/encoder_backed.ts"],"sourcesContent":["import { Document } from \"@langchain/core/documents\";\nimport { BaseStore } from \"@langchain/core/stores\";\n\n/**\n * Class that provides a layer of abstraction over the base storage,\n * allowing for the encoding and decoding of keys and values. It extends\n * the BaseStore class.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class EncoderBackedStore<K, V, SerializedType = any> extends BaseStore<\n K,\n V\n> {\n lc_namespace = [\"langchain\", \"storage\"];\n\n store: BaseStore<string, SerializedType>;\n\n keyEncoder: (key: K) => string;\n\n valueSerializer: (value: V) => SerializedType;\n\n valueDeserializer: (value: SerializedType) => V;\n\n constructor(fields: {\n store: BaseStore<string, SerializedType>;\n keyEncoder: (key: K) => string;\n valueSerializer: (value: V) => SerializedType;\n valueDeserializer: (value: SerializedType) => V;\n }) {\n super(fields);\n this.store = fields.store;\n this.keyEncoder = fields.keyEncoder;\n this.valueSerializer = fields.valueSerializer;\n this.valueDeserializer = fields.valueDeserializer;\n }\n\n /**\n * Method to get multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keys Array of keys to get\n * @returns Promise that resolves with an array of values or undefined for each key\n */\n async mget(keys: K[]): Promise<(V | undefined)[]> {\n const encodedKeys = keys.map(this.keyEncoder);\n const values = await this.store.mget(encodedKeys);\n return values.map((value) => {\n if (value === undefined) {\n return undefined;\n }\n return this.valueDeserializer(value);\n });\n }\n\n /**\n * Method to set multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keyValuePairs Array of key-value pairs to set\n * @returns Promise that resolves when the operation is complete\n */\n async mset(keyValuePairs: [K, V][]): Promise<void> {\n const encodedPairs: [string, SerializedType][] = keyValuePairs.map(\n ([key, value]) => [this.keyEncoder(key), this.valueSerializer(value)]\n );\n return this.store.mset(encodedPairs);\n }\n\n /**\n * Method to delete multiple keys at once. It works with the encoded keys.\n * @param keys Array of keys to delete\n * @returns Promise that resolves when the operation is complete\n */\n async mdelete(keys: K[]): Promise<void> {\n const encodedKeys = keys.map(this.keyEncoder);\n return this.store.mdelete(encodedKeys);\n }\n\n /**\n * Method to yield keys. It works with the encoded keys.\n * @param prefix Optional prefix to filter keys\n * @returns AsyncGenerator that yields keys\n */\n async *yieldKeys(prefix?: string | undefined): AsyncGenerator<string | K> {\n yield* this.store.yieldKeys(prefix);\n }\n}\n\nexport function createDocumentStoreFromByteStore(\n store: BaseStore<string, Uint8Array>\n) {\n const encoder = new TextEncoder();\n const decoder = new TextDecoder();\n return new EncoderBackedStore({\n store,\n keyEncoder: (key: string) => key,\n valueSerializer: (doc: Document) =>\n encoder.encode(\n JSON.stringify({ pageContent: doc.pageContent, metadata: doc.metadata })\n ),\n valueDeserializer: (bytes: Uint8Array) =>\n new Document(JSON.parse(decoder.decode(bytes))),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AASA,IAAa,qBAAb,cAAoE,UAGlE;CACA,eAAe,CAAC,aAAa,SAAU;CAEvC;CAEA;CAEA;CAEA;CAEA,YAAYA,QAKT;EACD,MAAM,OAAO;EACb,KAAK,QAAQ,OAAO;EACpB,KAAK,aAAa,OAAO;EACzB,KAAK,kBAAkB,OAAO;EAC9B,KAAK,oBAAoB,OAAO;CACjC;;;;;;;CAQD,MAAM,KAAKC,MAAuC;EAChD,MAAM,cAAc,KAAK,IAAI,KAAK,WAAW;EAC7C,MAAM,SAAS,MAAM,KAAK,MAAM,KAAK,YAAY;AACjD,SAAO,OAAO,IAAI,CAAC,UAAU;AAC3B,OAAI,UAAU,OACZ,QAAO;AAET,UAAO,KAAK,kBAAkB,MAAM;EACrC,EAAC;CACH;;;;;;;CAQD,MAAM,KAAKC,eAAwC;EACjD,MAAMC,eAA2C,cAAc,IAC7D,CAAC,CAAC,KAAK,MAAM,KAAK,CAAC,KAAK,WAAW,IAAI,EAAE,KAAK,gBAAgB,MAAM,AAAC,EACtE;AACD,SAAO,KAAK,MAAM,KAAK,aAAa;CACrC;;;;;;CAOD,MAAM,QAAQF,MAA0B;EACtC,MAAM,cAAc,KAAK,IAAI,KAAK,WAAW;AAC7C,SAAO,KAAK,MAAM,QAAQ,YAAY;CACvC;;;;;;CAOD,OAAO,UAAUG,QAAyD;EACxE,OAAO,KAAK,MAAM,UAAU,OAAO;CACpC;AACF;AAED,SAAgB,iCACdC,OACA;CACA,MAAM,UAAU,IAAI;CACpB,MAAM,UAAU,IAAI;AACpB,QAAO,IAAI,mBAAmB;EAC5B;EACA,YAAY,CAACC,QAAgB;EAC7B,iBAAiB,CAACC,QAChB,QAAQ,OACN,KAAK,UAAU;GAAE,aAAa,IAAI;GAAa,UAAU,IAAI;EAAU,EAAC,CACzE;EACH,mBAAmB,CAACC,UAClB,IAAI,SAAS,KAAK,MAAM,QAAQ,OAAO,MAAM,CAAC;CACjD;AACF"}
1
+ {"version":3,"file":"encoder_backed.js","names":[],"sources":["../../src/storage/encoder_backed.ts"],"sourcesContent":["import { Document } from \"@langchain/core/documents\";\nimport { BaseStore } from \"@langchain/core/stores\";\n\n/**\n * Class that provides a layer of abstraction over the base storage,\n * allowing for the encoding and decoding of keys and values. It extends\n * the BaseStore class.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class EncoderBackedStore<K, V, SerializedType = any> extends BaseStore<\n K,\n V\n> {\n lc_namespace = [\"langchain\", \"storage\"];\n\n store: BaseStore<string, SerializedType>;\n\n keyEncoder: (key: K) => string;\n\n valueSerializer: (value: V) => SerializedType;\n\n valueDeserializer: (value: SerializedType) => V;\n\n constructor(fields: {\n store: BaseStore<string, SerializedType>;\n keyEncoder: (key: K) => string;\n valueSerializer: (value: V) => SerializedType;\n valueDeserializer: (value: SerializedType) => V;\n }) {\n super(fields);\n this.store = fields.store;\n this.keyEncoder = fields.keyEncoder;\n this.valueSerializer = fields.valueSerializer;\n this.valueDeserializer = fields.valueDeserializer;\n }\n\n /**\n * Method to get multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keys Array of keys to get\n * @returns Promise that resolves with an array of values or undefined for each key\n */\n async mget(keys: K[]): Promise<(V | undefined)[]> {\n const encodedKeys = keys.map(this.keyEncoder);\n const values = await this.store.mget(encodedKeys);\n return values.map((value) => {\n if (value === undefined) {\n return undefined;\n }\n return this.valueDeserializer(value);\n });\n }\n\n /**\n * Method to set multiple keys at once. It works with the encoded keys and\n * serialized values.\n * @param keyValuePairs Array of key-value pairs to set\n * @returns Promise that resolves when the operation is complete\n */\n async mset(keyValuePairs: [K, V][]): Promise<void> {\n const encodedPairs: [string, SerializedType][] = keyValuePairs.map(\n ([key, value]) => [this.keyEncoder(key), this.valueSerializer(value)]\n );\n return this.store.mset(encodedPairs);\n }\n\n /**\n * Method to delete multiple keys at once. It works with the encoded keys.\n * @param keys Array of keys to delete\n * @returns Promise that resolves when the operation is complete\n */\n async mdelete(keys: K[]): Promise<void> {\n const encodedKeys = keys.map(this.keyEncoder);\n return this.store.mdelete(encodedKeys);\n }\n\n /**\n * Method to yield keys. It works with the encoded keys.\n * @param prefix Optional prefix to filter keys\n * @returns AsyncGenerator that yields keys\n */\n async *yieldKeys(prefix?: string | undefined): AsyncGenerator<string | K> {\n yield* this.store.yieldKeys(prefix);\n }\n}\n\nexport function createDocumentStoreFromByteStore(\n store: BaseStore<string, Uint8Array>\n) {\n const encoder = new TextEncoder();\n const decoder = new TextDecoder();\n return new EncoderBackedStore({\n store,\n keyEncoder: (key: string) => key,\n valueSerializer: (doc: Document) =>\n encoder.encode(\n JSON.stringify({ pageContent: doc.pageContent, metadata: doc.metadata })\n ),\n valueDeserializer: (bytes: Uint8Array) =>\n new Document(JSON.parse(decoder.decode(bytes))),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,IAAa,qBAAb,cAAoE,UAGlE;CACA,eAAe,CAAC,aAAa,UAAU;CAEvC;CAEA;CAEA;CAEA;CAEA,YAAY,QAKT;AACD,QAAM,OAAO;AACb,OAAK,QAAQ,OAAO;AACpB,OAAK,aAAa,OAAO;AACzB,OAAK,kBAAkB,OAAO;AAC9B,OAAK,oBAAoB,OAAO;;;;;;;;CASlC,MAAM,KAAK,MAAuC;EAChD,MAAM,cAAc,KAAK,IAAI,KAAK,WAAW;AAE7C,UADe,MAAM,KAAK,MAAM,KAAK,YAAY,EACnC,KAAK,UAAU;AAC3B,OAAI,UAAU,OACZ;AAEF,UAAO,KAAK,kBAAkB,MAAM;IACpC;;;;;;;;CASJ,MAAM,KAAK,eAAwC;EACjD,MAAM,eAA2C,cAAc,KAC5D,CAAC,KAAK,WAAW,CAAC,KAAK,WAAW,IAAI,EAAE,KAAK,gBAAgB,MAAM,CAAC,CACtE;AACD,SAAO,KAAK,MAAM,KAAK,aAAa;;;;;;;CAQtC,MAAM,QAAQ,MAA0B;EACtC,MAAM,cAAc,KAAK,IAAI,KAAK,WAAW;AAC7C,SAAO,KAAK,MAAM,QAAQ,YAAY;;;;;;;CAQxC,OAAO,UAAU,QAAyD;AACxE,SAAO,KAAK,MAAM,UAAU,OAAO;;;AAIvC,SAAgB,iCACd,OACA;CACA,MAAM,UAAU,IAAI,aAAa;CACjC,MAAM,UAAU,IAAI,aAAa;AACjC,QAAO,IAAI,mBAAmB;EAC5B;EACA,aAAa,QAAgB;EAC7B,kBAAkB,QAChB,QAAQ,OACN,KAAK,UAAU;GAAE,aAAa,IAAI;GAAa,UAAU,IAAI;GAAU,CAAC,CACzE;EACH,oBAAoB,UAClB,IAAI,SAAS,KAAK,MAAM,QAAQ,OAAO,MAAM,CAAC,CAAC;EAClD,CAAC"}
@@ -1,11 +1,13 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const __langchain_core_stores = require_rolldown_runtime.__toESM(require("@langchain/core/stores"));
3
- const node_fs_promises = require_rolldown_runtime.__toESM(require("node:fs/promises"));
4
- const node_path = require_rolldown_runtime.__toESM(require("node:path"));
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _langchain_core_stores = require("@langchain/core/stores");
4
+ let node_fs_promises = require("node:fs/promises");
5
+ node_fs_promises = require_runtime.__toESM(node_fs_promises);
6
+ let node_path = require("node:path");
7
+ node_path = require_runtime.__toESM(node_path);
5
8
 
6
9
  //#region src/storage/file_system.ts
7
- var file_system_exports = {};
8
- require_rolldown_runtime.__export(file_system_exports, { LocalFileStore: () => LocalFileStore });
10
+ var file_system_exports = /* @__PURE__ */ require_runtime.__exportAll({ LocalFileStore: () => LocalFileStore });
9
11
  /**
10
12
  * File system implementation of the BaseStore using a dictionary. Used for
11
13
  * storing key-value pairs in the file system.
@@ -36,7 +38,7 @@ require_rolldown_runtime.__export(file_system_exports, { LocalFileStore: () => L
36
38
  * Make sure that the path you specify when initializing the store is free
37
39
  * of other files.
38
40
  */
39
- var LocalFileStore = class extends __langchain_core_stores.BaseStore {
41
+ var LocalFileStore = class extends _langchain_core_stores.BaseStore {
40
42
  lc_namespace = ["langchain", "storage"];
41
43
  rootPath;
42
44
  constructor(fields) {
@@ -52,10 +54,10 @@ var LocalFileStore = class extends __langchain_core_stores.BaseStore {
52
54
  if (!/^[a-zA-Z0-9_\-:.]+$/.test(key)) throw new Error("Invalid key. Only alphanumeric characters, underscores, hyphens, colons, and periods are allowed.");
53
55
  try {
54
56
  const fileContent = await node_fs_promises.readFile(this.getFullPath(key));
55
- if (!fileContent) return void 0;
57
+ if (!fileContent) return;
56
58
  return fileContent;
57
59
  } catch (e) {
58
- if ("code" in e && e.code === "ENOENT") return void 0;
60
+ if ("code" in e && e.code === "ENOENT") return;
59
61
  throw new Error(`Error reading and parsing file at path: ${this.rootPath}.\nError: ${JSON.stringify(e)}`);
60
62
  }
61
63
  }
@@ -122,8 +124,7 @@ var LocalFileStore = class extends __langchain_core_stores.BaseStore {
122
124
  * @returns AsyncGenerator that yields keys from the store.
123
125
  */
124
126
  async *yieldKeys(prefix) {
125
- const allFiles = await node_fs_promises.readdir(this.rootPath);
126
- const allKeys = allFiles.map((file) => file.replace(".txt", ""));
127
+ const allKeys = (await node_fs_promises.readdir(this.rootPath)).map((file) => file.replace(".txt", ""));
127
128
  for (const key of allKeys) if (prefix === void 0 || key.startsWith(prefix)) yield key;
128
129
  }
129
130
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"file_system.cjs","names":["BaseStore","fields: { rootPath: string }","key: string","fs","e: any","content: Uint8Array","path","keys: string[]","values: (Uint8Array | undefined)[]","keyValuePairs: [string, Uint8Array][]","prefix?: string","rootPath: string"],"sources":["../../src/storage/file_system.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { BaseStore } from \"@langchain/core/stores\";\n\n/**\n * File system implementation of the BaseStore using a dictionary. Used for\n * storing key-value pairs in the file system.\n * @example\n * ```typescript\n * const store = await LocalFileStore.fromPath(\"./messages\");\n * await store.mset(\n * Array.from({ length: 5 }).map((_, index) => [\n * `message:id:${index}`,\n * new TextEncoder().encode(\n * JSON.stringify(\n * index % 2 === 0\n * ? new AIMessage(\"ai stuff...\")\n * : new HumanMessage(\"human stuff...\"),\n * ),\n * ),\n * ]),\n * );\n * const retrievedMessages = await store.mget([\"message:id:0\", \"message:id:1\"]);\n * console.log(retrievedMessages.map((v) => new TextDecoder().decode(v)));\n * for await (const key of store.yieldKeys(\"message:id:\")) {\n * await store.mdelete([key]);\n * }\n * ```\n *\n * @security **Security Notice** This file store\n * can alter any text file in the provided directory and any subfolders.\n * Make sure that the path you specify when initializing the store is free\n * of other files.\n */\nexport class LocalFileStore extends BaseStore<string, Uint8Array> {\n lc_namespace = [\"langchain\", \"storage\"];\n\n rootPath: string;\n\n constructor(fields: { rootPath: string }) {\n super(fields);\n this.rootPath = fields.rootPath;\n }\n\n /**\n * Read and parse the file at the given path.\n * @param key The key to read the file for.\n * @returns Promise that resolves to the parsed file content.\n */\n private async getParsedFile(key: string): Promise<Uint8Array | undefined> {\n // Validate the key to prevent path traversal\n if (!/^[a-zA-Z0-9_\\-:.]+$/.test(key)) {\n throw new Error(\n \"Invalid key. Only alphanumeric characters, underscores, hyphens, colons, and periods are allowed.\"\n );\n }\n try {\n const fileContent = await fs.readFile(this.getFullPath(key));\n if (!fileContent) {\n return undefined;\n }\n return fileContent;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n // File does not exist yet.\n if (\"code\" in e && e.code === \"ENOENT\") {\n return undefined;\n }\n throw new Error(\n `Error reading and parsing file at path: ${\n this.rootPath\n }.\\nError: ${JSON.stringify(e)}`\n );\n }\n }\n\n /**\n * Writes the given key-value pairs to the file at the given path.\n * @param fileContent An object with the key-value pairs to be written to the file.\n */\n private async setFileContent(content: Uint8Array, key: string) {\n try {\n await fs.writeFile(this.getFullPath(key), content);\n } catch (error) {\n throw new Error(\n `Error writing file at path: ${this.getFullPath(\n key\n )}.\\nError: ${JSON.stringify(error)}`\n );\n }\n }\n\n /**\n * Returns the full path of the file where the value of the given key is stored.\n * @param key the key to get the full path for\n */\n private getFullPath(key: string): string {\n try {\n const keyAsTxtFile = `${key}.txt`;\n\n // Validate the key to prevent path traversal\n if (!/^[a-zA-Z0-9_.\\-/]+$/.test(key)) {\n throw new Error(`Invalid characters in key: ${key}`);\n }\n\n const fullPath = path.resolve(this.rootPath, keyAsTxtFile);\n const commonPath = path.resolve(this.rootPath);\n\n if (!fullPath.startsWith(commonPath)) {\n throw new Error(\n `Invalid key: ${key}. Key should be relative to the root path. ` +\n `Root path: ${this.rootPath}, Full path: ${fullPath}`\n );\n }\n\n return fullPath;\n } catch (e) {\n throw new Error(\n `Error getting full path for key: ${key}.\\nError: ${String(e)}`\n );\n }\n }\n\n /**\n * Retrieves the values associated with the given keys from the store.\n * @param keys Keys to retrieve values for.\n * @returns Array of values associated with the given keys.\n */\n async mget(keys: string[]) {\n const values: (Uint8Array | undefined)[] = [];\n for (const key of keys) {\n const fileContent = await this.getParsedFile(key);\n values.push(fileContent);\n }\n return values;\n }\n\n /**\n * Sets the values for the given keys in the store.\n * @param keyValuePairs Array of key-value pairs to set in the store.\n * @returns Promise that resolves when all key-value pairs have been set.\n */\n async mset(keyValuePairs: [string, Uint8Array][]): Promise<void> {\n await Promise.all(\n keyValuePairs.map(([key, value]) => this.setFileContent(value, key))\n );\n }\n\n /**\n * Deletes the given keys and their associated values from the store.\n * @param keys Keys to delete from the store.\n * @returns Promise that resolves when all keys have been deleted.\n */\n async mdelete(keys: string[]): Promise<void> {\n await Promise.all(keys.map((key) => fs.unlink(this.getFullPath(key))));\n }\n\n /**\n * Asynchronous generator that yields keys from the store. If a prefix is\n * provided, it only yields keys that start with the prefix.\n * @param prefix Optional prefix to filter keys.\n * @returns AsyncGenerator that yields keys from the store.\n */\n async *yieldKeys(prefix?: string): AsyncGenerator<string> {\n const allFiles = await fs.readdir(this.rootPath);\n const allKeys = allFiles.map((file) => file.replace(\".txt\", \"\"));\n for (const key of allKeys) {\n if (prefix === undefined || key.startsWith(prefix)) {\n yield key;\n }\n }\n }\n\n /**\n * Static method for initializing the class.\n * Preforms a check to see if the directory exists, and if not, creates it.\n * @param path Path to the directory.\n * @returns Promise that resolves to an instance of the class.\n */\n static async fromPath(rootPath: string): Promise<LocalFileStore> {\n try {\n // Verifies the directory exists at the provided path, and that it is readable and writable.\n await fs.access(rootPath, fs.constants.R_OK | fs.constants.W_OK);\n } catch {\n try {\n // Directory does not exist, create it.\n await fs.mkdir(rootPath, { recursive: true });\n } catch (error) {\n throw new Error(\n `An error occurred creating directory at: ${rootPath}.\\nError: ${JSON.stringify(\n error\n )}`\n );\n }\n }\n\n return new this({ rootPath });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,iBAAb,cAAoCA,kCAA8B;CAChE,eAAe,CAAC,aAAa,SAAU;CAEvC;CAEA,YAAYC,QAA8B;EACxC,MAAM,OAAO;EACb,KAAK,WAAW,OAAO;CACxB;;;;;;CAOD,MAAc,cAAcC,KAA8C;AAExE,MAAI,CAAC,sBAAsB,KAAK,IAAI,CAClC,OAAM,IAAI,MACR;AAGJ,MAAI;GACF,MAAM,cAAc,MAAMC,iBAAG,SAAS,KAAK,YAAY,IAAI,CAAC;AAC5D,OAAI,CAAC,YACH,QAAO;AAET,UAAO;EAER,SAAQC,GAAQ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ACF;;;;;;CAOD,MAAM,QAAQF,MAA+B;EAC3C,MAAM,QAAQ,IAAI,KAAK,IAAI,CAAC,QAAQJ,iBAAG,OAAO,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC;CACvE;;;;;;;CAQD,OAAO,UAAUO,QAAyC;EACxD,MAAM,WAAW,MAAMP,iBAAG,QAAQ,KAAK,SAAS;EAChD,MAAM,UAAU,SAAS,IAAI,CAAC,SAAS,KAAK,QAAQ,QAAQ,GAAG,CAAC;AAChE,OAAK,MAAM,OAAO,QAChB,KAAI,WAAW,UAAa,IAAI,WAAW,OAAO,EAChD,MAAM;CAGX;;;;;;;CAQD,aAAa,SAASQ,UAA2C;AAC/D,MAAI;GAEF,MAAMR,iBAAG,OAAO,UAAUA,iBAAG,UAAU,OAAOA,iBAAG,UAAU,KAAK;EACjE,QAAO;AACN,OAAI;IAEF,MAAMA,iBAAG,MAAM,UAAU,EAAE,WAAW,KAAM,EAAC;GAC9C,SAAQ,OAAO;AACd,UAAM,IAAI,MACR,CAAC,yCAAyC,EAAE,SAAS,UAAU,EAAE,KAAK,UACpE,MACD,EAAE;GAEN;EACF;AAED,SAAO,IAAI,KAAK,EAAE,SAAU;CAC7B;AACF"}
1
+ {"version":3,"file":"file_system.cjs","names":["BaseStore","fs","path"],"sources":["../../src/storage/file_system.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { BaseStore } from \"@langchain/core/stores\";\n\n/**\n * File system implementation of the BaseStore using a dictionary. Used for\n * storing key-value pairs in the file system.\n * @example\n * ```typescript\n * const store = await LocalFileStore.fromPath(\"./messages\");\n * await store.mset(\n * Array.from({ length: 5 }).map((_, index) => [\n * `message:id:${index}`,\n * new TextEncoder().encode(\n * JSON.stringify(\n * index % 2 === 0\n * ? new AIMessage(\"ai stuff...\")\n * : new HumanMessage(\"human stuff...\"),\n * ),\n * ),\n * ]),\n * );\n * const retrievedMessages = await store.mget([\"message:id:0\", \"message:id:1\"]);\n * console.log(retrievedMessages.map((v) => new TextDecoder().decode(v)));\n * for await (const key of store.yieldKeys(\"message:id:\")) {\n * await store.mdelete([key]);\n * }\n * ```\n *\n * @security **Security Notice** This file store\n * can alter any text file in the provided directory and any subfolders.\n * Make sure that the path you specify when initializing the store is free\n * of other files.\n */\nexport class LocalFileStore extends BaseStore<string, Uint8Array> {\n lc_namespace = [\"langchain\", \"storage\"];\n\n rootPath: string;\n\n constructor(fields: { rootPath: string }) {\n super(fields);\n this.rootPath = fields.rootPath;\n }\n\n /**\n * Read and parse the file at the given path.\n * @param key The key to read the file for.\n * @returns Promise that resolves to the parsed file content.\n */\n private async getParsedFile(key: string): Promise<Uint8Array | undefined> {\n // Validate the key to prevent path traversal\n if (!/^[a-zA-Z0-9_\\-:.]+$/.test(key)) {\n throw new Error(\n \"Invalid key. Only alphanumeric characters, underscores, hyphens, colons, and periods are allowed.\"\n );\n }\n try {\n const fileContent = await fs.readFile(this.getFullPath(key));\n if (!fileContent) {\n return undefined;\n }\n return fileContent;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n // File does not exist yet.\n if (\"code\" in e && e.code === \"ENOENT\") {\n return undefined;\n }\n throw new Error(\n `Error reading and parsing file at path: ${\n this.rootPath\n }.\\nError: ${JSON.stringify(e)}`\n );\n }\n }\n\n /**\n * Writes the given key-value pairs to the file at the given path.\n * @param fileContent An object with the key-value pairs to be written to the file.\n */\n private async setFileContent(content: Uint8Array, key: string) {\n try {\n await fs.writeFile(this.getFullPath(key), content);\n } catch (error) {\n throw new Error(\n `Error writing file at path: ${this.getFullPath(\n key\n )}.\\nError: ${JSON.stringify(error)}`\n );\n }\n }\n\n /**\n * Returns the full path of the file where the value of the given key is stored.\n * @param key the key to get the full path for\n */\n private getFullPath(key: string): string {\n try {\n const keyAsTxtFile = `${key}.txt`;\n\n // Validate the key to prevent path traversal\n if (!/^[a-zA-Z0-9_.\\-/]+$/.test(key)) {\n throw new Error(`Invalid characters in key: ${key}`);\n }\n\n const fullPath = path.resolve(this.rootPath, keyAsTxtFile);\n const commonPath = path.resolve(this.rootPath);\n\n if (!fullPath.startsWith(commonPath)) {\n throw new Error(\n `Invalid key: ${key}. Key should be relative to the root path. ` +\n `Root path: ${this.rootPath}, Full path: ${fullPath}`\n );\n }\n\n return fullPath;\n } catch (e) {\n throw new Error(\n `Error getting full path for key: ${key}.\\nError: ${String(e)}`\n );\n }\n }\n\n /**\n * Retrieves the values associated with the given keys from the store.\n * @param keys Keys to retrieve values for.\n * @returns Array of values associated with the given keys.\n */\n async mget(keys: string[]) {\n const values: (Uint8Array | undefined)[] = [];\n for (const key of keys) {\n const fileContent = await this.getParsedFile(key);\n values.push(fileContent);\n }\n return values;\n }\n\n /**\n * Sets the values for the given keys in the store.\n * @param keyValuePairs Array of key-value pairs to set in the store.\n * @returns Promise that resolves when all key-value pairs have been set.\n */\n async mset(keyValuePairs: [string, Uint8Array][]): Promise<void> {\n await Promise.all(\n keyValuePairs.map(([key, value]) => this.setFileContent(value, key))\n );\n }\n\n /**\n * Deletes the given keys and their associated values from the store.\n * @param keys Keys to delete from the store.\n * @returns Promise that resolves when all keys have been deleted.\n */\n async mdelete(keys: string[]): Promise<void> {\n await Promise.all(keys.map((key) => fs.unlink(this.getFullPath(key))));\n }\n\n /**\n * Asynchronous generator that yields keys from the store. If a prefix is\n * provided, it only yields keys that start with the prefix.\n * @param prefix Optional prefix to filter keys.\n * @returns AsyncGenerator that yields keys from the store.\n */\n async *yieldKeys(prefix?: string): AsyncGenerator<string> {\n const allFiles = await fs.readdir(this.rootPath);\n const allKeys = allFiles.map((file) => file.replace(\".txt\", \"\"));\n for (const key of allKeys) {\n if (prefix === undefined || key.startsWith(prefix)) {\n yield key;\n }\n }\n }\n\n /**\n * Static method for initializing the class.\n * Preforms a check to see if the directory exists, and if not, creates it.\n * @param path Path to the directory.\n * @returns Promise that resolves to an instance of the class.\n */\n static async fromPath(rootPath: string): Promise<LocalFileStore> {\n try {\n // Verifies the directory exists at the provided path, and that it is readable and writable.\n await fs.access(rootPath, fs.constants.R_OK | fs.constants.W_OK);\n } catch {\n try {\n // Directory does not exist, create it.\n await fs.mkdir(rootPath, { recursive: true });\n } catch (error) {\n throw new Error(\n `An error occurred creating directory at: ${rootPath}.\\nError: ${JSON.stringify(\n error\n )}`\n );\n }\n }\n\n return new this({ rootPath });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,iBAAb,cAAoCA,iCAA8B;CAChE,eAAe,CAAC,aAAa,UAAU;CAEvC;CAEA,YAAY,QAA8B;AACxC,QAAM,OAAO;AACb,OAAK,WAAW,OAAO;;;;;;;CAQzB,MAAc,cAAc,KAA8C;AAExE,MAAI,CAAC,sBAAsB,KAAK,IAAI,CAClC,OAAM,IAAI,MACR,oGACD;AAEH,MAAI;GACF,MAAM,cAAc,MAAMC,iBAAG,SAAS,KAAK,YAAY,IAAI,CAAC;AAC5D,OAAI,CAAC,YACH;AAEF,UAAO;WAEA,GAAQ;AAEf,OAAI,UAAU,KAAK,EAAE,SAAS,SAC5B;AAEF,SAAM,IAAI,MACR,2CACE,KAAK,SACN,YAAY,KAAK,UAAU,EAAE,GAC/B;;;;;;;CAQL,MAAc,eAAe,SAAqB,KAAa;AAC7D,MAAI;AACF,SAAMA,iBAAG,UAAU,KAAK,YAAY,IAAI,EAAE,QAAQ;WAC3C,OAAO;AACd,SAAM,IAAI,MACR,+BAA+B,KAAK,YAClC,IACD,CAAC,YAAY,KAAK,UAAU,MAAM,GACpC;;;;;;;CAQL,AAAQ,YAAY,KAAqB;AACvC,MAAI;GACF,MAAM,eAAe,GAAG,IAAI;AAG5B,OAAI,CAAC,sBAAsB,KAAK,IAAI,CAClC,OAAM,IAAI,MAAM,8BAA8B,MAAM;GAGtD,MAAM,WAAWC,UAAK,QAAQ,KAAK,UAAU,aAAa;GAC1D,MAAM,aAAaA,UAAK,QAAQ,KAAK,SAAS;AAE9C,OAAI,CAAC,SAAS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ementation of the BaseStore using a dictionary. Used for
7
6
  * storing key-value pairs in the file system.
@@ -1 +1 @@
1
- {"version":3,"file":"file_system.d.cts","names":["BaseStore","LocalFileStore","Uint8Array","ArrayBufferLike","Promise","AsyncGenerator"],"sources":["../../src/storage/file_system.d.ts"],"sourcesContent":["import { BaseStore } from \"@langchain/core/stores\";\n/**\n * File system implementation of the BaseStore using a dictionary. Used for\n * storing key-value pairs in the file system.\n * @example\n * ```typescript\n * const store = await LocalFileStore.fromPath(\"./messages\");\n * await store.mset(\n * Array.from({ length: 5 }).map((_, index) => [\n * `message:id:${index}`,\n * new TextEncoder().encode(\n * JSON.stringify(\n * index % 2 === 0\n * ? new AIMessage(\"ai stuff...\")\n * : new HumanMessage(\"human stuff...\"),\n * ),\n * ),\n * ]),\n * );\n * const retrievedMessages = await store.mget([\"message:id:0\", \"message:id:1\"]);\n * console.log(retrievedMessages.map((v) => new TextDecoder().decode(v)));\n * for await (const key of store.yieldKeys(\"message:id:\")) {\n * await store.mdelete([key]);\n * }\n * ```\n *\n * @security **Security Notice** This file store\n * can alter any text file in the provided directory and any subfolders.\n * Make sure that the path you specify when initializing the store is free\n * of other files.\n */\nexport declare class LocalFileStore extends BaseStore<string, Uint8Array> {\n lc_namespace: string[];\n rootPath: string;\n constructor(fields: {\n rootPath: string;\n });\n private getParsedFile;\n private setFileContent;\n /**\n * Returns the full path of the file where the value of the given key is stored.\n * @param key the key to get the full path for\n */\n private getFullPath;\n /**\n * Retrieves the values associated with the given keys from the store.\n * @param keys Keys to retrieve values for.\n * @returns Array of values associated with the given keys.\n */\n mget(keys: string[]): Promise<(Uint8Array<ArrayBufferLike> | undefined)[]>;\n /**\n * Sets the values for the given keys in the store.\n * @param keyValuePairs Array of key-value pairs to set in the store.\n * @returns Promise that resolves when all key-value pairs have been set.\n */\n mset(keyValuePairs: [string, Uint8Array][]): Promise<void>;\n /**\n * Deletes the given keys and their associated values from the store.\n * @param keys Keys to delete from the store.\n * @returns Promise that resolves when all keys have been deleted.\n */\n mdelete(keys: string[]): Promise<void>;\n /**\n * Asynchronous generator that yields keys from the store. If a prefix is\n * provided, it only yields keys that start with the prefix.\n * @param prefix Optional prefix to filter keys.\n * @returns AsyncGenerator that yields keys from the store.\n */\n yieldKeys(prefix?: string): AsyncGenerator<string>;\n /**\n * Static method for initializing the class.\n * Preforms a check to see if the directory exists, and if not, creates it.\n * @param path Path to the directory.\n * @returns Promise that resolves to an instance of the class.\n */\n static fromPath(rootPath: string): Promise<LocalFileStore>;\n}\n//# sourceMappingURL=file_system.d.ts.map"],"mappings":";;;;;;AA+BA;;;;;;;;;;;;AAAqD;;;;;;;;;;;;;;;;cAAhCC,cAAAA,SAAuBD,kBAAkBE;;;;;;;;;;;;;;;;;;wBAkBpCE,SAASF,WAAWC;;;;;;+BAMbD,gBAAgBE;;;;;;2BAMpBA;;;;;;;8BAOGC;;;;;;;qCAOOD,QAAQH"}
1
+ {"version":3,"file":"file_system.d.cts","names":[],"sources":["../../src/storage/file_system.ts"],"mappings":";;;;;AAkCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,cAAA,SAAuB,SAAA,SAAkB,UAAA;EACpD,YAAA;EAEA,QAAA;EAEA,WAAA,CAAY,MAAA;IAAU,QAAA;EAAA;EAAA,QAUR,aAAA;EAAA,QA+BA,cAAA;EAyEA;;;;EAAA,QAzDN,WAAA;EAmFK;;;;;EAnDP,IAAA,CAAK,IAAA,aAAc,OAAA,EAAA,UAAA,CAAA,eAAA;;;;;;EAcnB,IAAA,CAAK,aAAA,WAAwB,UAAA,MAAgB,OAAA;;;;;;EAW7C,OAAA,CAAQ,IAAA,aAAiB,OAAA;;;;;;;EAUxB,SAAA,CAAU,MAAA,YAAkB,cAAA;;;;;;;SAgBtB,QAAA,CAAS,QAAA,WAAmB,OAAA,CAAQ,cAAA;AAAA"}
@@ -1,7 +1,6 @@
1
1
  import { BaseStore } from "@langchain/core/stores";
2
2
 
3
3
  //#region src/storage/file_system.d.ts
4
-
5
4
  /**
6
5
  * File system implementation of the BaseStore using a dictionary. Used for
7
6
  * storing key-value pairs in the file system.
@@ -1 +1 @@
1
- {"version":3,"file":"file_system.d.ts","names":["BaseStore","LocalFileStore","Uint8Array","ArrayBufferLike","Promise","AsyncGenerator"],"sources":["../../src/storage/file_system.d.ts"],"sourcesContent":["import { BaseStore } from \"@langchain/core/stores\";\n/**\n * File system implementation of the BaseStore using a dictionary. Used for\n * storing key-value pairs in the file system.\n * @example\n * ```typescript\n * const store = await LocalFileStore.fromPath(\"./messages\");\n * await store.mset(\n * Array.from({ length: 5 }).map((_, index) => [\n * `message:id:${index}`,\n * new TextEncoder().encode(\n * JSON.stringify(\n * index % 2 === 0\n * ? new AIMessage(\"ai stuff...\")\n * : new HumanMessage(\"human stuff...\"),\n * ),\n * ),\n * ]),\n * );\n * const retrievedMessages = await store.mget([\"message:id:0\", \"message:id:1\"]);\n * console.log(retrievedMessages.map((v) => new TextDecoder().decode(v)));\n * for await (const key of store.yieldKeys(\"message:id:\")) {\n * await store.mdelete([key]);\n * }\n * ```\n *\n * @security **Security Notice** This file store\n * can alter any text file in the provided directory and any subfolders.\n * Make sure that the path you specify when initializing the store is free\n * of other files.\n */\nexport declare class LocalFileStore extends BaseStore<string, Uint8Array> {\n lc_namespace: string[];\n rootPath: string;\n constructor(fields: {\n rootPath: string;\n });\n private getParsedFile;\n private setFileContent;\n /**\n * Returns the full path of the file where the value of the given key is stored.\n * @param key the key to get the full path for\n */\n private getFullPath;\n /**\n * Retrieves the values associated with the given keys from the store.\n * @param keys Keys to retrieve values for.\n * @returns Array of values associated with the given keys.\n */\n mget(keys: string[]): Promise<(Uint8Array<ArrayBufferLike> | undefined)[]>;\n /**\n * Sets the values for the given keys in the store.\n * @param keyValuePairs Array of key-value pairs to set in the store.\n * @returns Promise that resolves when all key-value pairs have been set.\n */\n mset(keyValuePairs: [string, Uint8Array][]): Promise<void>;\n /**\n * Deletes the given keys and their associated values from the store.\n * @param keys Keys to delete from the store.\n * @returns Promise that resolves when all keys have been deleted.\n */\n mdelete(keys: string[]): Promise<void>;\n /**\n * Asynchronous generator that yields keys from the store. If a prefix is\n * provided, it only yields keys that start with the prefix.\n * @param prefix Optional prefix to filter keys.\n * @returns AsyncGenerator that yields keys from the store.\n */\n yieldKeys(prefix?: string): AsyncGenerator<string>;\n /**\n * Static method for initializing the class.\n * Preforms a check to see if the directory exists, and if not, creates it.\n * @param path Path to the directory.\n * @returns Promise that resolves to an instance of the class.\n */\n static fromPath(rootPath: string): Promise<LocalFileStore>;\n}\n//# sourceMappingURL=file_system.d.ts.map"],"mappings":";;;;;;AA+BA;;;;;;;;;;;;AAAqD;;;;;;;;;;;;;;;;cAAhCC,cAAAA,SAAuBD,kBAAkBE;;;;;;;;;;;;;;;;;;wBAkBpCE,SAASF,WAAWC;;;;;;+BAMbD,gBAAgBE;;;;;;2BAMpBA;;;;;;;8BAOGC;;;;;;;qCAOOD,QAAQH"}
1
+ {"version":3,"file":"file_system.d.ts","names":[],"sources":["../../src/storage/file_system.ts"],"mappings":";;;;;AAkCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,cAAA,SAAuB,SAAA,SAAkB,UAAA;EACpD,YAAA;EAEA,QAAA;EAEA,WAAA,CAAY,MAAA;IAAU,QAAA;EAAA;EAAA,QAUR,aAAA;EAAA,QA+BA,cAAA;EAyEA;;;;EAAA,QAzDN,WAAA;EAmFK;;;;;EAnDP,IAAA,CAAK,IAAA,aAAc,OAAA,EAAA,UAAA,CAAA,eAAA;;;;;;EAcnB,IAAA,CAAK,aAAA,WAAwB,UAAA,MAAgB,OAAA;;;;;;EAW7C,OAAA,CAAQ,IAAA,aAAiB,OAAA;;;;;;;EAUxB,SAAA,CAAU,MAAA,YAAkB,cAAA;;;;;;;SAgBtB,QAAA,CAAS,QAAA,WAAmB,OAAA,CAAQ,cAAA;AAAA"}
@@ -1,11 +1,10 @@
1
- import { __export } from "../_virtual/rolldown_runtime.js";
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
2
  import { BaseStore } from "@langchain/core/stores";
3
3
  import * as fs from "node:fs/promises";
4
4
  import * as path from "node:path";
5
5
 
6
6
  //#region src/storage/file_system.ts
7
- var file_system_exports = {};
8
- __export(file_system_exports, { LocalFileStore: () => LocalFileStore });
7
+ var file_system_exports = /* @__PURE__ */ __exportAll({ LocalFileStore: () => LocalFileStore });
9
8
  /**
10
9
  * File system implementation of the BaseStore using a dictionary. Used for
11
10
  * storing key-value pairs in the file system.
@@ -52,10 +51,10 @@ var LocalFileStore = class extends BaseStore {
52
51
  if (!/^[a-zA-Z0-9_\-:.]+$/.test(key)) throw new Error("Invalid key. Only alphanumeric characters, underscores, hyphens, colons, and periods are allowed.");
53
52
  try {
54
53
  const fileContent = await fs.readFile(this.getFullPath(key));
55
- if (!fileContent) return void 0;
54
+ if (!fileContent) return;
56
55
  return fileContent;
57
56
  } catch (e) {
58
- if ("code" in e && e.code === "ENOENT") return void 0;
57
+ if ("code" in e && e.code === "ENOENT") return;
59
58
  throw new Error(`Error reading and parsing file at path: ${this.rootPath}.\nError: ${JSON.stringify(e)}`);
60
59
  }
61
60
  }
@@ -122,8 +121,7 @@ var LocalFileStore = class extends BaseStore {
122
121
  * @returns AsyncGenerator that yields keys from the store.
123
122
  */
124
123
  async *yieldKeys(prefix) {
125
- const allFiles = await fs.readdir(this.rootPath);
126
- const allKeys = allFiles.map((file) => file.replace(".txt", ""));
124
+ const allKeys = (await fs.readdir(this.rootPath)).map((file) => file.replace(".txt", ""));
127
125
  for (const key of allKeys) if (prefix === void 0 || key.startsWith(prefix)) yield key;
128
126
  }
129
127
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"file_system.js","names":["fields: { rootPath: string }","key: string","e: any","content: Uint8Array","keys: string[]","values: (Uint8Array | undefined)[]","keyValuePairs: [string, Uint8Array][]","prefix?: string","rootPath: string"],"sources":["../../src/storage/file_system.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { BaseStore } from \"@langchain/core/stores\";\n\n/**\n * File system implementation of the BaseStore using a dictionary. Used for\n * storing key-value pairs in the file system.\n * @example\n * ```typescript\n * const store = await LocalFileStore.fromPath(\"./messages\");\n * await store.mset(\n * Array.from({ length: 5 }).map((_, index) => [\n * `message:id:${index}`,\n * new TextEncoder().encode(\n * JSON.stringify(\n * index % 2 === 0\n * ? new AIMessage(\"ai stuff...\")\n * : new HumanMessage(\"human stuff...\"),\n * ),\n * ),\n * ]),\n * );\n * const retrievedMessages = await store.mget([\"message:id:0\", \"message:id:1\"]);\n * console.log(retrievedMessages.map((v) => new TextDecoder().decode(v)));\n * for await (const key of store.yieldKeys(\"message:id:\")) {\n * await store.mdelete([key]);\n * }\n * ```\n *\n * @security **Security Notice** This file store\n * can alter any text file in the provided directory and any subfolders.\n * Make sure that the path you specify when initializing the store is free\n * of other files.\n */\nexport class LocalFileStore extends BaseStore<string, Uint8Array> {\n lc_namespace = [\"langchain\", \"storage\"];\n\n rootPath: string;\n\n constructor(fields: { rootPath: string }) {\n super(fields);\n this.rootPath = fields.rootPath;\n }\n\n /**\n * Read and parse the file at the given path.\n * @param key The key to read the file for.\n * @returns Promise that resolves to the parsed file content.\n */\n private async getParsedFile(key: string): Promise<Uint8Array | undefined> {\n // Validate the key to prevent path traversal\n if (!/^[a-zA-Z0-9_\\-:.]+$/.test(key)) {\n throw new Error(\n \"Invalid key. Only alphanumeric characters, underscores, hyphens, colons, and periods are allowed.\"\n );\n }\n try {\n const fileContent = await fs.readFile(this.getFullPath(key));\n if (!fileContent) {\n return undefined;\n }\n return fileContent;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n // File does not exist yet.\n if (\"code\" in e && e.code === \"ENOENT\") {\n return undefined;\n }\n throw new Error(\n `Error reading and parsing file at path: ${\n this.rootPath\n }.\\nError: ${JSON.stringify(e)}`\n );\n }\n }\n\n /**\n * Writes the given key-value pairs to the file at the given path.\n * @param fileContent An object with the key-value pairs to be written to the file.\n */\n private async setFileContent(content: Uint8Array, key: string) {\n try {\n await fs.writeFile(this.getFullPath(key), content);\n } catch (error) {\n throw new Error(\n `Error writing file at path: ${this.getFullPath(\n key\n )}.\\nError: ${JSON.stringify(error)}`\n );\n }\n }\n\n /**\n * Returns the full path of the file where the value of the given key is stored.\n * @param key the key to get the full path for\n */\n private getFullPath(key: string): string {\n try {\n const keyAsTxtFile = `${key}.txt`;\n\n // Validate the key to prevent path traversal\n if (!/^[a-zA-Z0-9_.\\-/]+$/.test(key)) {\n throw new Error(`Invalid characters in key: ${key}`);\n }\n\n const fullPath = path.resolve(this.rootPath, keyAsTxtFile);\n const commonPath = path.resolve(this.rootPath);\n\n if (!fullPath.startsWith(commonPath)) {\n throw new Error(\n `Invalid key: ${key}. Key should be relative to the root path. ` +\n `Root path: ${this.rootPath}, Full path: ${fullPath}`\n );\n }\n\n return fullPath;\n } catch (e) {\n throw new Error(\n `Error getting full path for key: ${key}.\\nError: ${String(e)}`\n );\n }\n }\n\n /**\n * Retrieves the values associated with the given keys from the store.\n * @param keys Keys to retrieve values for.\n * @returns Array of values associated with the given keys.\n */\n async mget(keys: string[]) {\n const values: (Uint8Array | undefined)[] = [];\n for (const key of keys) {\n const fileContent = await this.getParsedFile(key);\n values.push(fileContent);\n }\n return values;\n }\n\n /**\n * Sets the values for the given keys in the store.\n * @param keyValuePairs Array of key-value pairs to set in the store.\n * @returns Promise that resolves when all key-value pairs have been set.\n */\n async mset(keyValuePairs: [string, Uint8Array][]): Promise<void> {\n await Promise.all(\n keyValuePairs.map(([key, value]) => this.setFileContent(value, key))\n );\n }\n\n /**\n * Deletes the given keys and their associated values from the store.\n * @param keys Keys to delete from the store.\n * @returns Promise that resolves when all keys have been deleted.\n */\n async mdelete(keys: string[]): Promise<void> {\n await Promise.all(keys.map((key) => fs.unlink(this.getFullPath(key))));\n }\n\n /**\n * Asynchronous generator that yields keys from the store. If a prefix is\n * provided, it only yields keys that start with the prefix.\n * @param prefix Optional prefix to filter keys.\n * @returns AsyncGenerator that yields keys from the store.\n */\n async *yieldKeys(prefix?: string): AsyncGenerator<string> {\n const allFiles = await fs.readdir(this.rootPath);\n const allKeys = allFiles.map((file) => file.replace(\".txt\", \"\"));\n for (const key of allKeys) {\n if (prefix === undefined || key.startsWith(prefix)) {\n yield key;\n }\n }\n }\n\n /**\n * Static method for initializing the class.\n * Preforms a check to see if the directory exists, and if not, creates it.\n * @param path Path to the directory.\n * @returns Promise that resolves to an instance of the class.\n */\n static async fromPath(rootPath: string): Promise<LocalFileStore> {\n try {\n // Verifies the directory exists at the provided path, and that it is readable and writable.\n await fs.access(rootPath, fs.constants.R_OK | fs.constants.W_OK);\n } catch {\n try {\n // Directory does not exist, create it.\n await fs.mkdir(rootPath, { recursive: true });\n } catch (error) {\n throw new Error(\n `An error occurred creating directory at: ${rootPath}.\\nError: ${JSON.stringify(\n error\n )}`\n );\n }\n }\n\n return new this({ rootPath });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,iBAAb,cAAoC,UAA8B;CAChE,eAAe,CAAC,aAAa,SAAU;CAEvC;CAEA,YAAYA,QAA8B;EACxC,MAAM,OAAO;EACb,KAAK,WAAW,OAAO;CACxB;;;;;;CAOD,MAAc,cAAcC,KAA8C;AAExE,MAAI,CAAC,sBAAsB,KAAK,IAAI,CAClC,OAAM,IAAI,MACR;AAGJ,MAAI;GACF,MAAM,cAAc,MAAM,GAAG,SAAS,KAAK,YAAY,IAAI,CAAC;AAC5D,OAAI,CAAC,YACH,QAAO;AAET,UAAO;EAER,SAAQC,GAAQ;AAEf,OAAI,UAAU,KAAK,EAAE,SAAS,SAC5B,QAAO;AAET,SAAM,IAAI,MACR,CAAC,wCAAwC,EACvC,KAAK,SACN,UAAU,EAAE,KAAK,UAAU,EAAE,EAAE;EAEnC;CACF;;;;;CAMD,MAAc,eAAeC,SAAqBF,KAAa;AAC7D,MAAI;GACF,MAAM,GAAG,UAAU,KAAK,YAAY,IAAI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IAAI,CAAC,SAAS,KAAK,QAAQ,QAAQ,GAAG,CAAC;AAChE,OAAK,MAAM,OAAO,QAChB,KAAI,WAAW,UAAa,IAAI,WAAW,OAAO,EAChD,MAAM;CAGX;;;;;;;CAQD,aAAa,SAASC,UAA2C;AAC/D,MAAI;GAEF,MAAM,GAAG,OAAO,UAAU,GAAG,UAAU,OAAO,GAAG,UAAU,KAAK;EACjE,QAAO;AACN,OAAI;IAEF,MAAM,GAAG,MAAM,UAAU,EAAE,WAAW,KAAM,EAAC;GAC9C,SAAQ,OAAO;AACd,UAAM,IAAI,MACR,CAAC,yCAAyC,EAAE,SAAS,UAAU,EAAE,KAAK,UACpE,MACD,EAAE;GAEN;EACF;AAED,SAAO,IAAI,KAAK,EAAE,SAAU;CAC7B;AACF"}
1
+ {"version":3,"file":"file_system.js","names":[],"sources":["../../src/storage/file_system.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { BaseStore } from \"@langchain/core/stores\";\n\n/**\n * File system implementation of the BaseStore using a dictionary. Used for\n * storing key-value pairs in the file system.\n * @example\n * ```typescript\n * const store = await LocalFileStore.fromPath(\"./messages\");\n * await store.mset(\n * Array.from({ length: 5 }).map((_, index) => [\n * `message:id:${index}`,\n * new TextEncoder().encode(\n * JSON.stringify(\n * index % 2 === 0\n * ? new AIMessage(\"ai stuff...\")\n * : new HumanMessage(\"human stuff...\"),\n * ),\n * ),\n * ]),\n * );\n * const retrievedMessages = await store.mget([\"message:id:0\", \"message:id:1\"]);\n * console.log(retrievedMessages.map((v) => new TextDecoder().decode(v)));\n * for await (const key of store.yieldKeys(\"message:id:\")) {\n * await store.mdelete([key]);\n * }\n * ```\n *\n * @security **Security Notice** This file store\n * can alter any text file in the provided directory and any subfolders.\n * Make sure that the path you specify when initializing the store is free\n * of other files.\n */\nexport class LocalFileStore extends BaseStore<string, Uint8Array> {\n lc_namespace = [\"langchain\", \"storage\"];\n\n rootPath: string;\n\n constructor(fields: { rootPath: string }) {\n super(fields);\n this.rootPath = fields.rootPath;\n }\n\n /**\n * Read and parse the file at the given path.\n * @param key The key to read the file for.\n * @returns Promise that resolves to the parsed file content.\n */\n private async getParsedFile(key: string): Promise<Uint8Array | undefined> {\n // Validate the key to prevent path traversal\n if (!/^[a-zA-Z0-9_\\-:.]+$/.test(key)) {\n throw new Error(\n \"Invalid key. Only alphanumeric characters, underscores, hyphens, colons, and periods are allowed.\"\n );\n }\n try {\n const fileContent = await fs.readFile(this.getFullPath(key));\n if (!fileContent) {\n return undefined;\n }\n return fileContent;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n // File does not exist yet.\n if (\"code\" in e && e.code === \"ENOENT\") {\n return undefined;\n }\n throw new Error(\n `Error reading and parsing file at path: ${\n this.rootPath\n }.\\nError: ${JSON.stringify(e)}`\n );\n }\n }\n\n /**\n * Writes the given key-value pairs to the file at the given path.\n * @param fileContent An object with the key-value pairs to be written to the file.\n */\n private async setFileContent(content: Uint8Array, key: string) {\n try {\n await fs.writeFile(this.getFullPath(key), content);\n } catch (error) {\n throw new Error(\n `Error writing file at path: ${this.getFullPath(\n key\n )}.\\nError: ${JSON.stringify(error)}`\n );\n }\n }\n\n /**\n * Returns the full path of the file where the value of the given key is stored.\n * @param key the key to get the full path for\n */\n private getFullPath(key: string): string {\n try {\n const keyAsTxtFile = `${key}.txt`;\n\n // Validate the key to prevent path traversal\n if (!/^[a-zA-Z0-9_.\\-/]+$/.test(key)) {\n throw new Error(`Invalid characters in key: ${key}`);\n }\n\n const fullPath = path.resolve(this.rootPath, keyAsTxtFile);\n const commonPath = path.resolve(this.rootPath);\n\n if (!fullPath.startsWith(commonPath)) {\n throw new Error(\n `Invalid key: ${key}. Key should be relative to the root path. ` +\n `Root path: ${this.rootPath}, Full path: ${fullPath}`\n );\n }\n\n return fullPath;\n } catch (e) {\n throw new Error(\n `Error getting full path for key: ${key}.\\nError: ${String(e)}`\n );\n }\n }\n\n /**\n * Retrieves the values associated with the given keys from the store.\n * @param keys Keys to retrieve values for.\n * @returns Array of values associated with the given keys.\n */\n async mget(keys: string[]) {\n const values: (Uint8Array | undefined)[] = [];\n for (const key of keys) {\n const fileContent = await this.getParsedFile(key);\n values.push(fileContent);\n }\n return values;\n }\n\n /**\n * Sets the values for the given keys in the store.\n * @param keyValuePairs Array of key-value pairs to set in the store.\n * @returns Promise that resolves when all key-value pairs have been set.\n */\n async mset(keyValuePairs: [string, Uint8Array][]): Promise<void> {\n await Promise.all(\n keyValuePairs.map(([key, value]) => this.setFileContent(value, key))\n );\n }\n\n /**\n * Deletes the given keys and their associated values from the store.\n * @param keys Keys to delete from the store.\n * @returns Promise that resolves when all keys have been deleted.\n */\n async mdelete(keys: string[]): Promise<void> {\n await Promise.all(keys.map((key) => fs.unlink(this.getFullPath(key))));\n }\n\n /**\n * Asynchronous generator that yields keys from the store. If a prefix is\n * provided, it only yields keys that start with the prefix.\n * @param prefix Optional prefix to filter keys.\n * @returns AsyncGenerator that yields keys from the store.\n */\n async *yieldKeys(prefix?: string): AsyncGenerator<string> {\n const allFiles = await fs.readdir(this.rootPath);\n const allKeys = allFiles.map((file) => file.replace(\".txt\", \"\"));\n for (const key of allKeys) {\n if (prefix === undefined || key.startsWith(prefix)) {\n yield key;\n }\n }\n }\n\n /**\n * Static method for initializing the class.\n * Preforms a check to see if the directory exists, and if not, creates it.\n * @param path Path to the directory.\n * @returns Promise that resolves to an instance of the class.\n */\n static async fromPath(rootPath: string): Promise<LocalFileStore> {\n try {\n // Verifies the directory exists at the provided path, and that it is readable and writable.\n await fs.access(rootPath, fs.constants.R_OK | fs.constants.W_OK);\n } catch {\n try {\n // Directory does not exist, create it.\n await fs.mkdir(rootPath, { recursive: true });\n } catch (error) {\n throw new Error(\n `An error occurred creating directory at: ${rootPath}.\\nError: ${JSON.stringify(\n error\n )}`\n );\n }\n }\n\n return new this({ rootPath });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAk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AAI;AACjD,UAAO,KAAK,YAAY;;AAE1B,SAAO;;;;;;;CAQT,MAAM,KAAK,eAAsD;AAC/D,QAAM,QAAQ,IACZ,cAAc,KAAK,CAAC,KAAK,WAAW,KAAK,eAAe,OAAO,IAAI,CAAC,CACrE;;;;;;;CAQH,MAAM,QAAQ,MAA+B;AAC3C,QAAM,QAAQ,IAAI,KAAK,KAAK,QAAQ,GAAG,OAAO,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC;;;;;;;;CASxE,OAAO,UAAU,QAAyC;EAExD,MAAM,WADW,MAAM,GAAG,QAAQ,KAAK,SAAS,EACvB,KAAK,SAAS,KAAK,QAAQ,QAAQ,GAAG,CAAC;AAChE,OAAK,MAAM,OAAO,QAChB,KAAI,WAAW,UAAa,IAAI,WAAW,OAAO,CAChD,OAAM;;;;;;;;CAWZ,aAAa,SAAS,UAA2C;AAC/D,MAAI;AAEF,SAAM,GAAG,OAAO,UAAU,GAAG,UAAU,OAAO,GAAG,UAAU,KAAK;UAC1D;AACN,OAAI;AAEF,UAAM,GAAG,MAAM,UAAU,EAAE,WAAW,MAAM,CAAC;YACtC,OAAO;AACd,UAAM,IAAI,MACR,4CAA4C,SAAS,YAAY,KAAK,UACpE,MACD,GACF;;;AAIL,SAAO,IAAI,KAAK,EAAE,UAAU,CAAC"}
@@ -1,15 +1,15 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const __langchain_core_stores = require_rolldown_runtime.__toESM(require("@langchain/core/stores"));
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _langchain_core_stores = require("@langchain/core/stores");
3
4
 
4
5
  //#region src/storage/in_memory.ts
5
- var in_memory_exports = {};
6
- require_rolldown_runtime.__export(in_memory_exports, { InMemoryStore: () => __langchain_core_stores.InMemoryStore });
6
+ var in_memory_exports = /* @__PURE__ */ require_runtime.__exportAll({ InMemoryStore: () => _langchain_core_stores.InMemoryStore });
7
7
 
8
8
  //#endregion
9
9
  Object.defineProperty(exports, 'InMemoryStore', {
10
10
  enumerable: true,
11
11
  get: function () {
12
- return __langchain_core_stores.InMemoryStore;
12
+ return _langchain_core_stores.InMemoryStore;
13
13
  }
14
14
  });
15
15
  Object.defineProperty(exports, 'in_memory_exports', {
@@ -1,9 +1,8 @@
1
- import { __export } from "../_virtual/rolldown_runtime.js";
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
2
  import { InMemoryStore } from "@langchain/core/stores";
3
3
 
4
4
  //#region src/storage/in_memory.ts
5
- var in_memory_exports = {};
6
- __export(in_memory_exports, { InMemoryStore: () => InMemoryStore });
5
+ var in_memory_exports = /* @__PURE__ */ __exportAll({ InMemoryStore: () => InMemoryStore });
7
6
 
8
7
  //#endregion
9
8
  export { InMemoryStore, in_memory_exports };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "1.2.24",
3
+ "version": "1.2.25",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  "@types/uuid": "^9",
39
39
  "@types/ws": "^8",
40
40
  "@vitest/coverage-v8": "^3.2.4",
41
- "cheerio": "1.0.0-rc.12",
41
+ "cheerio": "1.2.0",
42
42
  "dotenv": "^16.0.3",
43
43
  "dpdm": "^3.14.0",
44
44
  "eslint": "^9.34.0",
@@ -52,15 +52,15 @@
52
52
  "typescript": "~5.8.3",
53
53
  "vitest": "^3.2.4",
54
54
  "yaml": "^2.8.1",
55
- "@langchain/anthropic": "1.3.17",
56
- "@langchain/core": "^1.1.24",
55
+ "@langchain/anthropic": "1.3.18",
57
56
  "@langchain/cohere": "1.0.2",
57
+ "@langchain/core": "^1.1.26",
58
+ "@langchain/openai": "1.2.8",
58
59
  "@langchain/eslint": "0.1.1",
59
- "@langchain/openai": "1.2.7",
60
60
  "@langchain/tsconfig": "0.0.1"
61
61
  },
62
62
  "peerDependencies": {
63
- "@langchain/core": "^1.1.24"
63
+ "@langchain/core": "^1.1.26"
64
64
  },
65
65
  "dependencies": {
66
66
  "@langchain/langgraph": "^1.1.2",